Skip to content

@aeye/core — Agent

The Agent class orchestrates multiple components (tools, prompts, other agents) with developer-defined logic.

Constructor

typescript
new Agent<TContext, TMetadata, TName, TInput, TOutput, TRefs>(input: AgentInput)

AgentInput

PropertyTypeRequiredDescription
namestringYesUnique agent name
descriptionstringYesWhat the agent does
refsComponent[] as constYesChild components (typed tuple)
call(input, refs, ctx) => outputYesOrchestration function
applicable(ctx) => booleanNoAvailability check
metadataobjectNoStatic metadata
metadataFn(input, ctx) => objectNoDynamic metadata

Properties

PropertyTypeDescription
kind'agent'Component kind
nameTNameAgent name
descriptionstringAgent description
refsTRefsReferenced components
inputAgentInputFull configuration

Methods

run(input, ctx?)

Execute the agent:

typescript
const result = await agent.run({ query: 'search for files' }, ctx);

The call function receives:

  1. input — the input passed to run()
  2. refs — typed tuple of child components
  3. ctx — the merged context

applicable(ctx?)

Check if the agent is available.

metadata(input?, ctx?)

Get agent metadata.

Type Safety

Using as const on refs preserves individual component types:

typescript
const agent = ai.agent({
  refs: [myTool, myPrompt, otherAgent] as const,
  call: async (input, [tool, prompt, agent], ctx) => {
    // tool: typeof myTool
    // prompt: typeof myPrompt
    // agent: typeof otherAgent
  },
});

Released under the GPL-3.0 License.