Agent
openmolt / Agent
Class: Agent
Defined in: Agent.ts:76
An autonomous agent that uses the Maestro reasoning loop to complete tasks.
Create via OpenMolt.createAgent rather than instantiating directly.
Example
const agent = om.createAgent({ name: 'Writer', model: 'openai:gpt-4o', instructions: '...' });
const result = await agent.run('Write a haiku about TypeScript');
Constructors
Constructor
new Agent(
config,omConfig,integrations):Agent
Defined in: Agent.ts:97
Parameters
config
Agent configuration.
omConfig
Parent OpenMolt configuration.
integrations
Map<string, Integration>
All integrations registered in the OpenMolt instance.
Returns
Agent
Properties
name
readonlyname:string
Defined in: Agent.ts:78
The agent's display name.
Methods
cancelSchedule()
cancelSchedule(
scheduleId):boolean
Defined in: Agent.ts:282
Cancel a previously registered schedule.
Parameters
scheduleId
string
ID returned by schedule.
Returns
boolean
off()
off<
K>(event,handler):this
Defined in: Agent.ts:248
Remove an event listener.
Type Parameters
K
K extends keyof AgentEventMap
Parameters
event
K
Event name.
handler
(e) => void
The exact handler reference to remove.
Returns
this
on()
on<
K>(event,handler):this
Defined in: Agent.ts:234
Register an event listener.
Type Parameters
K
K extends keyof AgentEventMap
Parameters
event
K
Event name.
handler
(e) => void
Handler function.
Returns
this
run()
run(
input):Promise<unknown>
Defined in: Agent.ts:144
Run the agent with the provided input.
The agent will iterate the Maestro loop until it issues a finish command
or the maximum number of steps is reached.
Parameters
input
unknown
Initial input to the agent (string, object, or any serialisable value).
Returns
Promise<unknown>
The output from the agent's finish command.
schedule()
schedule(
config):string
Defined in: Agent.ts:263
Schedule the agent to run automatically.
Parameters
config
Schedule configuration (interval or daily).
Returns
string
A schedule ID that can be passed to cancelSchedule.