Class: Agent

Constructors

new Agent()

new Agent(agentArgs: {objectgeneratorOptions: ModelConfig;providerConfig: ProviderConfig;systemPrompt: string; }): Agent

Parameters

ParameterType
agentArgsobject
agentArgs.objectgeneratorOptions?ModelConfig
agentArgs.providerConfigProviderConfig
agentArgs.systemPrompt?string

Returns

Agent

Defined in

src/agent/agent.ts:33

Properties

systemPrompt?

optional systemPrompt: string

Defined in

src/agent/agent.ts:31

Methods

actionCall()

actionCall<T>(prompt: CoreMessage[], commandSchema: T, opts: {autoSlice: true;maxDelay: 10000;numOfAttempts: 5;startingDelay: 1000;timeMultiple: 2; }): Promise<any>

Generate a command response from the model and return the parsed data

Type Parameters

Type Parameter
T extends ZodType<any, ZodTypeDef, any>

Parameters

ParameterTypeDescription
promptCoreMessage[]The prompt to send to the model
commandSchemaTThe schema to validate the response
optsobjectOptions for actionCall function
opts.autoSlicebooleanWhether to automatically slice the response
opts.maxDelaynumberMaximum delay
opts.numOfAttemptsnumberMaximum number of retries
opts.startingDelaynumberInitial delay in milliseconds
opts.timeMultiplenumberMultiplier for the delay

Returns

Promise<any>

The parsed response data as

Command Schema

Defined in

src/agent/agent.ts:229


askCommand()

askCommand<T>(prompt: CoreMessage[], schema: T, opts: {maxDelay: 10000;numOfAttempts: 5;startingDelay: 1000;timeMultiple: 2; }): Promise<any>

Type Parameters

Type Parameter
T extends ZodObject<any, UnknownKeysParam, ZodTypeAny, {}, {}>

Parameters

ParameterType
promptCoreMessage[]
schemaT
optsobject
opts.maxDelaynumber
opts.numOfAttemptsnumber
opts.startingDelaynumber
opts.timeMultiplenumber

Returns

Promise<any>

Defined in

src/agent/agent.ts:182


call()

call<T>(prompt: CoreMessage[], responseSchema: T, opts?: {autoSlice: boolean; }): Promise<T>

Type Parameters

Type Parameter
T extends ZodType<any, ZodTypeDef, any>

Parameters

ParameterType
promptCoreMessage[]
responseSchemaT
opts?object
opts.autoSlice?boolean

Returns

Promise<T>

Defined in

src/agent/agent.ts:202


chat()

chat(prompt: string): Promise<any>

Chat with

Parameters

ParameterTypeDescription
promptstring

Returns

Promise<any>

The response from the model

Defined in

src/agent/agent.ts:281


defaultObjectGeneratorOptions()

defaultObjectGeneratorOptions(model: string): ObjectGeneratorOptions

Parameters

ParameterType
modelstring

Returns

ObjectGeneratorOptions

Defined in

src/agent/agent.ts:45


generateResponseType()

generateResponseType<T>(currentState: {ariaTree: string;kind: "ObjectiveState";objective: string;progress: string[];url: string; }, memories: {actionStep: {command: any;description: string;objectiveComplete: {kind: "ObjectiveComplete";result: string; } | {};progressAssessment: string; };objectiveState: ObjectiveState; }, responseSchema: T): Promise<TypeOf<T>>

Type Parameters

Type Parameter
T extends ZodObject<any, UnknownKeysParam, ZodTypeAny, {}, {}>

Parameters

ParameterType
currentStateobject
currentState.ariaTreestring
currentState.kind"ObjectiveState"
currentState.objectivestring
currentState.progressstring[]
currentState.urlstring
memoriesobject
memories.actionStepobject
memories.actionStep.command?any
memories.actionStep.descriptionstring
memories.actionStep.objectiveComplete?{kind: "ObjectiveComplete";result: string; } | {}
memories.actionStep.progressAssessmentstring
memories.objectiveStateobject
memories.objectiveState.ariaTreestring
memories.objectiveState.kind"ObjectiveState"
memories.objectiveState.objectivestring
memories.objectiveState.progressstring[]
memories.objectiveState.urlstring
responseSchemaT

Returns

Promise<TypeOf<T>>

Defined in

src/agent/agent.ts:94


modifyActions()

modifyActions(currentState: {ariaTree: string;kind: "ObjectiveState";objective: string;progress: string[];url: string; }, memory: {actionStep: {command: any;description: string;objectiveComplete: {kind: "ObjectiveComplete";result: string; } | {};progressAssessment: string; };objectiveState: ObjectiveState; }, config?: {inventory: Inventory;maxAttempts: number;systemPrompt: string; }): Promise<undefined | {command: any;description: string;objectiveComplete: {kind: "ObjectiveComplete";result: string; } | {};progressAssessment: string; }>

Parameters

ParameterType
currentStateobject
currentState.ariaTreestring
currentState.kind"ObjectiveState"
currentState.objective?string
currentState.progress?string[]
currentState.url?string
memory?object
memory.actionStep?object
memory.actionStep.command?any
memory.actionStep.description?string
memory.actionStep.objectiveComplete?{kind: "ObjectiveComplete";result: string; } | {}
memory.actionStep.progressAssessment?string
memory.objectiveState?object
memory.objectiveState.ariaTree?string
memory.objectiveState.kind?"ObjectiveState"
memory.objectiveState.objective?string
memory.objectiveState.progress?string[]
memory.objectiveState.url?string
config?object
config.inventory?Inventory
config.maxAttempts?number
config.systemPrompt?string

Returns

Promise<undefined | {command: any;description: string;objectiveComplete: {kind: "ObjectiveComplete";result: string; } | {};progressAssessment: string; }>

Defined in

src/agent/agent.ts:121


prompt()

prompt(currentState: {ariaTree: string;kind: "ObjectiveState";objective: string;progress: string[];url: string; }, memories: {actionStep: {command: any;description: string;objectiveComplete: {kind: "ObjectiveComplete";result: string; } | {};progressAssessment: string; };objectiveState: ObjectiveState; }[], config?: {inventory: Inventory;systemPrompt: string; }): CoreMessage[]

Generate a prompt for the user to complete an objective

Parameters

ParameterTypeDescription
currentStateobjectThe current state of the objective
currentState.ariaTreestring-
currentState.kind"ObjectiveState"-
currentState.objective?string-
currentState.progress?string[]-
currentState.url?string-
memories?{actionStep: {command: any;description: string;objectiveComplete: {kind: "ObjectiveComplete";result: string; } | {};progressAssessment: string; };objectiveState: ObjectiveState; }[]The memories to use as examples
config?objectConfiguration options for the prompt
config.inventory?InventoryThe inventory to use for the prompt
config.systemPrompt?stringThe system prompt to use for the prompt

Returns

CoreMessage[]

string - The prompt for the user to complete the objective

Defined in

src/agent/agent.ts:64


returnCall()

returnCall<T>(prompt: CoreMessage[], responseSchema: T, opts: {autoSlice: true;maxDelay: 10000;numOfAttempts: 5;startingDelay: 1000;timeMultiple: 2; }): Promise<TypeOf<T>>

Get information from the model and return the parsed data

Type Parameters

Type Parameter
T extends ZodType<any, ZodTypeDef, any>

Parameters

ParameterTypeDescription
promptCoreMessage[]The prompt to send to the model
responseSchemaTThe schema to validate the response
optsobjectOptions for actionCall function
opts.autoSlicebooleanWhether to automatically slice the response
opts.maxDelaynumberMaximum delay
opts.numOfAttemptsnumberMaximum number of retries
opts.startingDelaynumberInitial delay in milliseconds
opts.timeMultiplenumberMultiplier for the delay

Returns

Promise<TypeOf<T>>

The parsed response data as

Response Schema

Defined in

src/agent/agent.ts:261