Agent
@daydreamsai/core / Agent
Interface: Agent<TContext>
Defined in: packages/core/src/types.ts:688
Represents an agent with various configurations and methods for handling contexts, inputs, outputs, and more.
Template
The type of memory used by the agent.
Extends
AgentDef
<TContext
>
Type Parameters
TContext
TContext
extends AnyContext
= AnyContext
The type of context used by the agent.
Properties
actions
actions:
Action
<any
,any
,unknown
,AnyContext
,Agent
<TContext
>,ActionState
<any
>>[]
Defined in: packages/core/src/types.ts:654
An array of actions available to the agent.
Inherited from
AgentDef.actions
container
container:
Container
Defined in: packages/core/src/types.ts:611
The container used by the agent.
Inherited from
AgentDef.container
context?
optional
context:TContext
Defined in: packages/core/src/types.ts:601
The current context of the agent.
Inherited from
AgentDef.context
debugger
debugger:
Debugger
Defined in: packages/core/src/types.ts:606
Debugger function for the agent.
Inherited from
AgentDef.debugger
emit()
emit: (...
args
) =>void
Defined in: packages/core/src/types.ts:722
Emits an event with the provided arguments.
Parameters
args
...any
[]
Arguments to pass to the event handler.
Returns
void
events
events:
Record
<string
,z.ZodObject
>
Defined in: packages/core/src/types.ts:649
A record of event schemas for the agent.
Inherited from
AgentDef.events
exports?
optional
exports:ExportManager
Defined in: packages/core/src/types.ts:727
Export manager for episodes
exportTrainingData?
optional
exportTrainingData:boolean
Defined in: packages/core/src/types.ts:666
Whether to export training data for episodes
Inherited from
AgentDef.exportTrainingData
inputs
inputs:
Record
<string
,InputConfig
<any
,AnyContext
,Agent
<TContext
>>>
Defined in: packages/core/src/types.ts:639
A record of input configurations for the agent.
Inherited from
AgentDef.inputs
logger
logger:
Logger
Defined in: packages/core/src/types.ts:586
Inherited from
AgentDef.logger
memory
memory:
MemorySystem
Defined in: packages/core/src/types.ts:596
The memory store and vector store used by the agent.
Inherited from
AgentDef.memory
model?
optional
model:LanguageModel
Defined in: packages/core/src/types.ts:621
The primary language model used by the agent.
Inherited from
AgentDef.model
modelSettings?
optional
modelSettings:object
Defined in: packages/core/src/types.ts:626
Model settings for the agent.
Index Signature
[key
: string
]: any
maxTokens?
optional
maxTokens:number
providerOptions?
optional
providerOptions:Record
<string
,any
>
stopSequences?
optional
stopSequences:string
[]
temperature?
optional
temperature:number
topK?
optional
topK:number
topP?
optional
topP:number
Inherited from
AgentDef.modelSettings
outputs
outputs:
Record
<string
,Omit
<Output
<any
,any
,TContext
,any
>,"type"
>>
Defined in: packages/core/src/types.ts:644
A record of output configurations for the agent.
Inherited from
AgentDef.outputs
registry
registry:
Registry
Defined in: packages/core/src/types.ts:690
run()
run: <
TContext
,SubContextRefs
>(opts
) =>Promise
<AnyRef
[]>
Defined in: packages/core/src/types.ts:734
Runs the agent with the provided options.
Type Parameters
TContext
TContext
extends AnyContext
SubContextRefs
SubContextRefs
extends AnyContext
[] = AnyContext
[]
Parameters
opts
Options for running the agent.
abortSignal?
AbortSignal
actions?
args
InferSchemaArguments
<TContext
["schema"
]>
chain?
Log
[]
context
TContext
contexts?
ContextRefArray
<SubContextRefs
>
handlers?
Partial
<Handlers
>
model?
LanguageModel
modelSettings?
{[key
: string
]: any
; maxTokens?
: number
; providerOptions?
: Record
<string
, any
>; stopSequences?
: string
[]; temperature?
: number
; topK?
: number
; topP?
: number
; }
modelSettings.maxTokens?
number
modelSettings.providerOptions?
Record
<string
, any
>
modelSettings.stopSequences?
string
[]
modelSettings.temperature?
number
modelSettings.topK?
number
modelSettings.topP?
number
outputs?
Record
<string
, Omit
<Output
<any
, any
, TContext
, any
>, "type"
>>
priority?
number
Task priority for execution ordering (higher = more priority)
Returns
Promise
<AnyRef
[]>
A promise that resolves to an array of logs.
send()
send: <
SContext
,SubContextRefs
>(opts
) =>Promise
<AnyRef
[]>
Defined in: packages/core/src/types.ts:765
Sends an input to the agent with the provided options.
Type Parameters
SContext
SContext
extends AnyContext
SubContextRefs
SubContextRefs
extends AnyContext
[] = AnyContext
[]
Parameters
opts
Options for sending input to the agent.
abortSignal?
AbortSignal
actions?
args
InferSchemaArguments
<SContext
["schema"
]>
chain?
Log
[]
context
SContext
contexts?
ContextRefArray
<SubContextRefs
>
handlers?
Partial
<Handlers
>
input
{ data
: any
; type
: string
; }
input.data
any
input.type
string
model?
LanguageModel
outputs?
Record
<string
, Omit
<Output
<any
, any
, SContext
, any
>, "type"
>>
Returns
Promise
<AnyRef
[]>
A promise that resolves to an array of logs.
taskRunner
taskRunner:
TaskRunner
Defined in: packages/core/src/types.ts:616
The task runner used by the agent.
Inherited from
AgentDef.taskRunner
tracker
tracker:
SimpleTracker
Defined in: packages/core/src/types.ts:591
Analytics tracker automatically extracts metrics from logger events
Inherited from
AgentDef.tracker
trainingDataPath?
optional
trainingDataPath:string
Defined in: packages/core/src/types.ts:671
Path to save training data
Inherited from
AgentDef.trainingDataPath
Methods
__subscribeChunk()
__subscribeChunk(
contextId
,handler
): () =>void
Defined in: packages/core/src/types.ts:852
Parameters
contextId
string
handler
(log
) => void
Returns
():
void
Returns
void
deleteContext()
deleteContext(
contextId
):Promise
<void
>
Defined in: packages/core/src/types.ts:845
Parameters
contextId
string
Returns
Promise
<void
>
getAgentContext()
getAgentContext():
Promise
<undefined
|ContextState
<TContext
>>
Defined in: packages/core/src/types.ts:812
Returns
Promise
<undefined
| ContextState
<TContext
>>
getContext()
getContext<
TContext
>(params
):Promise
<ContextState
<TContext
>>
Defined in: packages/core/src/types.ts:819
Retrieves the state of a given context and arguments.
Type Parameters
TContext
TContext
extends AnyContext
Parameters
params
Parameters for retrieving the context state.
args
InferSchemaArguments
<TContext
["schema"
]>
context
TContext
Returns
Promise
<ContextState
<TContext
>>
A promise that resolves to the context state.
getContextById()
getContextById<
TContext
>(id
):Promise
<null
|ContextState
<TContext
>>
Defined in: packages/core/src/types.ts:834
Type Parameters
TContext
TContext
extends AnyContext
Parameters
id
string
Returns
Promise
<null
| ContextState
<TContext
>>
getContextId()
getContextId<
TContext
>(params
):string
Defined in: packages/core/src/types.ts:807
Retrieves the ID for a given context and arguments.
Type Parameters
TContext
TContext
extends AnyContext
= AnyContext
Parameters
params
Parameters for retrieving the context ID.
args
InferSchemaArguments
<TContext
["schema"
]>
context
TContext
Returns
string
The context ID.
getContexts()
getContexts():
Promise
<object
[]>
Defined in: packages/core/src/types.ts:798
Retrieves the contexts managed by the agent.
Returns
Promise
<object
[]>
A promise that resolves to an array of context objects.
getPriorityLevels()
getPriorityLevels():
object
Defined in: packages/core/src/types.ts:697
Gets the configured task priority levels
Returns
object
default
default:
number
high
high:
number
low
low:
number
getTaskConfig()
getTaskConfig():
object
Defined in: packages/core/src/types.ts:706
Gets the current task configuration
Returns
object
concurrency
concurrency:
object
concurrency.default
default:
number
concurrency.llm
llm:
number
priority
priority:
object
priority.default
default:
number
priority.high?
optional
high:number
priority.low?
optional
low:number
getWorkingMemory()
getWorkingMemory(
contextId
):Promise
<WorkingMemory
>
Defined in: packages/core/src/types.ts:843
Retrieves the working memory for a given context ID.
Parameters
contextId
string
The ID of the context.
Returns
Promise
<WorkingMemory
>
A promise that resolves to the working memory.
isBooted()
isBooted():
boolean
Defined in: packages/core/src/types.ts:692
Returns
boolean
loadContext()
loadContext<
TContext
>(params
):Promise
<null
|ContextState
<TContext
>>
Defined in: packages/core/src/types.ts:824
Type Parameters
TContext
TContext
extends AnyContext
Parameters
params
args
InferSchemaArguments
<TContext
["schema"
]>
context
TContext
Returns
Promise
<null
| ContextState
<TContext
>>
saveContext()
saveContext(
state
,workingMemory?
):Promise
<boolean
>
Defined in: packages/core/src/types.ts:829
Parameters
state
workingMemory?
Returns
Promise
<boolean
>
start()
start(
args?
):Promise
<Agent
<TContext
>>
Defined in: packages/core/src/types.ts:786
Starts the agent with the provided arguments.
Parameters
args?
InferSchemaArguments
<TContext
["schema"
]>
Arguments to pass to the agent on start.
Returns
Promise
<Agent
<TContext
>>
A promise that resolves to the agent instance.
stop()
stop():
Promise
<void
>
Defined in: packages/core/src/types.ts:792
Stops the agent.
Returns
Promise
<void
>
A promise that resolves when the agent is stopped.
subscribeContext()
subscribeContext(
contextId
,handler
): () =>void
Defined in: packages/core/src/types.ts:847
Parameters
contextId
string
handler
(log
, done
) => void
Returns
():
void
Returns
void