Class: Agent
Constructors
new Agent()
new Agent(
agentArgs
: {objectgeneratorOptions
:ModelConfig
;providerConfig
:ProviderConfig
;systemPrompt
:string
; }):Agent
Parameters
Parameter | Type |
---|---|
agentArgs | object |
agentArgs.objectgeneratorOptions ? | ModelConfig |
agentArgs.providerConfig | ProviderConfig |
agentArgs.systemPrompt ? | string |
Returns
Defined in
Properties
systemPrompt?
optional
systemPrompt:string
Defined in
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
Parameter | Type | Description |
---|---|---|
prompt | CoreMessage [] | The prompt to send to the model |
commandSchema | T | The schema to validate the response |
opts | object | Options for actionCall function |
opts.autoSlice | boolean | Whether to automatically slice the response |
opts.maxDelay | number | Maximum delay |
opts.numOfAttempts | number | Maximum number of retries |
opts.startingDelay | number | Initial delay in milliseconds |
opts.timeMultiple | number | Multiplier for the delay |
Returns
Promise
<any
>
The parsed response data as
Command Schema
Defined in
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
Parameter | Type |
---|---|
prompt | CoreMessage [] |
schema | T |
opts | object |
opts.maxDelay | number |
opts.numOfAttempts | number |
opts.startingDelay | number |
opts.timeMultiple | number |
Returns
Promise
<any
>
Defined in
call()
call<
T
>(prompt
:CoreMessage
[],responseSchema
:T
,opts
?: {autoSlice
:boolean
; }):Promise
<T
>
Type Parameters
Type Parameter |
---|
T extends ZodType <any , ZodTypeDef , any > |
Parameters
Parameter | Type |
---|---|
prompt | CoreMessage [] |
responseSchema | T |
opts ? | object |
opts.autoSlice ? | boolean |
Returns
Promise
<T
>
Defined in
chat()
chat(
prompt
:string
):Promise
<any
>
Chat with
Parameters
Parameter | Type | Description |
---|---|---|
prompt | string |
Returns
Promise
<any
>
The response from the model
Defined in
defaultObjectGeneratorOptions()
defaultObjectGeneratorOptions(
model
:string
):ObjectGeneratorOptions
Parameters
Parameter | Type |
---|---|
model | string |
Returns
ObjectGeneratorOptions
Defined in
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
Parameter | Type |
---|---|
currentState | object |
currentState.ariaTree | string |
currentState.kind | "ObjectiveState" |
currentState.objective | string |
currentState.progress | string [] |
currentState.url | string |
memories | object |
memories.actionStep | object |
memories.actionStep.command ? | any |
memories.actionStep.description | string |
memories.actionStep.objectiveComplete ? | {kind : "ObjectiveComplete" ;result : string ; } | {} |
memories.actionStep.progressAssessment | string |
memories.objectiveState | object |
memories.objectiveState.ariaTree | string |
memories.objectiveState.kind | "ObjectiveState" |
memories.objectiveState.objective | string |
memories.objectiveState.progress | string [] |
memories.objectiveState.url | string |
responseSchema | T |
Returns
Promise
<TypeOf
<T
>>
Defined in
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
Parameter | Type |
---|---|
currentState | object |
currentState.ariaTree | string |
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
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
Parameter | Type | Description |
---|---|---|
currentState | object | The current state of the objective |
currentState.ariaTree | string | - |
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 ? | object | Configuration options for the prompt |
config.inventory ? | Inventory | The inventory to use for the prompt |
config.systemPrompt ? | string | The system prompt to use for the prompt |
Returns
CoreMessage
[]
string - The prompt for the user to complete the objective
Defined in
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
Parameter | Type | Description |
---|---|---|
prompt | CoreMessage [] | The prompt to send to the model |
responseSchema | T | The schema to validate the response |
opts | object | Options for actionCall function |
opts.autoSlice | boolean | Whether to automatically slice the response |
opts.maxDelay | number | Maximum delay |
opts.numOfAttempts | number | Maximum number of retries |
opts.startingDelay | number | Initial delay in milliseconds |
opts.timeMultiple | number | Multiplier for the delay |
Returns
Promise
<TypeOf
<T
>>
The parsed response data as