Agent
@daydreamsai/core / Agent
Interface: Agent<TContext>
Defined in: packages/core/src/types.ts:672
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:638
An array of actions available to the agent.
Inherited from
AgentDef.actions
container
container:
Container
Defined in: packages/core/src/types.ts:595
The container used by the agent.
Inherited from
AgentDef.container
context?
optionalcontext:TContext
Defined in: packages/core/src/types.ts:585
The current context of the agent.
Inherited from
AgentDef.context
debugger
debugger:
Debugger
Defined in: packages/core/src/types.ts:590
Debugger function for the agent.
Inherited from
AgentDef.debugger
emit()
emit: (...
args) =>void
Defined in: packages/core/src/types.ts:706
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:633
A record of event schemas for the agent.
Inherited from
AgentDef.events
exports?
optionalexports:ExportManager
Defined in: packages/core/src/types.ts:711
Export manager for episodes
exportTrainingData?
optionalexportTrainingData:boolean
Defined in: packages/core/src/types.ts:650
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:623
A record of input configurations for the agent.
Inherited from
AgentDef.inputs
logger
logger:
Logger
Defined in: packages/core/src/types.ts:570
Inherited from
AgentDef.logger
memory
memory:
MemorySystem
Defined in: packages/core/src/types.ts:580
The memory store and vector store used by the agent.
Inherited from
AgentDef.memory
model?
optionalmodel:LanguageModel
Defined in: packages/core/src/types.ts:605
The primary language model used by the agent.
Inherited from
AgentDef.model
modelSettings?
optionalmodelSettings:object
Defined in: packages/core/src/types.ts:610
Model settings for the agent.
Index Signature
[key: string]: any
maxTokens?
optionalmaxTokens:number
providerOptions?
optionalproviderOptions:Record<string,any>
stopSequences?
optionalstopSequences:string[]
temperature?
optionaltemperature:number
topK?
optionaltopK:number
topP?
optionaltopP:number
Inherited from
AgentDef.modelSettings
outputs
outputs:
Record<string,Omit<Output<any,any,TContext,any>,"name">>
Defined in: packages/core/src/types.ts:628
A record of output configurations for the agent.
Inherited from
AgentDef.outputs
registry
registry:
Registry
Defined in: packages/core/src/types.ts:674
run()
run: <
TContext,SubContextRefs>(opts) =>Promise<AnyRef[]>
Defined in: packages/core/src/types.ts:718
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>, "name">>
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:749
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>, "name">>
Returns
Promise<AnyRef[]>
A promise that resolves to an array of logs.
taskRunner
taskRunner:
TaskRunner
Defined in: packages/core/src/types.ts:600
The task runner used by the agent.
Inherited from
AgentDef.taskRunner
tracker
tracker:
SimpleTracker
Defined in: packages/core/src/types.ts:575
Analytics tracker automatically extracts metrics from logger events
Inherited from
AgentDef.tracker
trainingDataPath?
optionaltrainingDataPath:string
Defined in: packages/core/src/types.ts:655
Path to save training data
Inherited from
AgentDef.trainingDataPath
Methods
__subscribeChunk()
__subscribeChunk(
contextId,handler): () =>void
Defined in: packages/core/src/types.ts:836
Parameters
contextId
string
handler
(log) => void
Returns
():
void
Returns
void
deleteContext()
deleteContext(
contextId):Promise<void>
Defined in: packages/core/src/types.ts:829
Parameters
contextId
string
Returns
Promise<void>
getAgentContext()
getAgentContext():
Promise<undefined|ContextState<TContext>>
Defined in: packages/core/src/types.ts:796
Returns
Promise<undefined | ContextState<TContext>>
getContext()
getContext<
TContext>(params):Promise<ContextState<TContext>>
Defined in: packages/core/src/types.ts:803
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:818
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:791
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:782
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:681
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:690
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?
optionalhigh:number
priority.low?
optionallow:number
getWorkingMemory()
getWorkingMemory(
contextId):Promise<WorkingMemory>
Defined in: packages/core/src/types.ts:827
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:676
Returns
boolean
loadContext()
loadContext<
TContext>(params):Promise<null|ContextState<TContext>>
Defined in: packages/core/src/types.ts:808
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:813
Parameters
state
workingMemory?
Returns
Promise<boolean>
start()
start(
args?):Promise<Agent<TContext>>
Defined in: packages/core/src/types.ts:770
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:776
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:831
Parameters
contextId
string
handler
(log, done) => void
Returns
():
void
Returns
void