Agent
An agent, or one of its conversations. Returned by wardrik.agent.
- Most methods make one request, to the
agent.*operation of the same name. streamandreplyalso follow the run that answers a message.- Methods that can act on a conversation act on
conversation.
Extends
Section titled “Extends”Properties
Section titled “Properties”readonly agent: string;The agent's ID.
Inherited from
Section titled “Inherited from”conversation
Section titled “conversation”readonly conversation: string | undefined;The conversation the methods act on. undefined for the agent's own history.
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”stream()
Section titled “stream()”stream(input, options?): AsyncGenerator<WardrikEvent>;Sends a message and yields the events of the run that answers it, until the run ends.
for await (const event of agent.stream("What's on fire?")) { if (event.type === "wardrik.message.delta") process.stdout.write(event.data.delta); if (event.type === "wardrik.run.interrupted") { for (const interrupt of event.data.interrupts) await agent.approve(interrupt.id); }}An interrupted run carries on, on the same stream, once each interrupt is approved or denied.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
string | Ask |
options? |
StreamAskOptions |
Returns
Section titled “Returns”AsyncGenerator<WardrikEvent>
reply()
Section titled “reply()”reply(input, options?): Promise<Reply>;Sends a message and resolves when the run that answers it ends or waits on a person.
const reply = await agent.reply("What's on fire?");if (reply.status === "completed") console.log(reply.text);Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
string | Ask |
options? |
StreamAskOptions |
Returns
Section titled “Returns”Promise<Reply>
read()
Section titled “read()”read(options?): Promise<AgentSnapshot>;Read what an agent is doing now.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<AgentSnapshot>
Inherited from
Section titled “Inherited from”define()
Section titled “define()”define(input?, options?): Promise<AgentSnapshot>;Define an agent.
Starts the agent the definition describes, or brings the one running to it from its next turn. A definition put again replaces the last. A key nothing here supports yet answers not_supported, naming it.
Acts on the agent, never a conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input? |
AgentDefinition |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<AgentSnapshot>
Inherited from
Section titled “Inherited from”forget()
Section titled “forget()”forget(options?): Promise<void>;Forget an agent.
Acts on the agent, never a conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”ask(input, options?): Promise<{ id: string; cursor: string;}>;Send an agent a message.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
Ask |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<{
id: string;
cursor: string;
}>
Inherited from
Section titled “Inherited from”decide()
Section titled “decide()”decide(input, options?): Promise<object[]>;Approve or reject the calls an agent waits on.
The decisions are taken together and recorded as the caller's. A rejection's reason is what the model is told in place of the call's answer. An approval's note is what it reads beside the answer.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
Decisions |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<object[]>
Inherited from
Section titled “Inherited from”authorization()
Section titled “authorization()”authorization(interrupt, options?): Promise<Authorization>;Read where a person authorizes a call.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
interrupt |
string |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<Authorization>
Inherited from
Section titled “Inherited from”cancel()
Section titled “cancel()”cancel(options?): Promise<void>;Stop what an agent is doing.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”events()
Section titled “events()”events(input?, options?): Promise<Events>;Read an agent's log.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input? |
{ types?: string[]; after?: string; limit?: number; } |
- |
input.types? |
string[] |
The event types to read, as wardrik.run.completed, given once for each. Every type where left out. A wardrik.events.dropped comes whatever the types. |
input.after? |
string |
The cursor to read after: a page's next, the id of an event a stream gave, or a snapshot's cursor. |
input.limit? |
number |
How many to read, 100 unless set. |
options? |
CallOptions |
- |
Returns
Section titled “Returns”Promise<Events>
Inherited from
Section titled “Inherited from”streamEvents()
Section titled “streamEvents()”streamEvents(input?, options?): EventStream;Like events, then follows each new event as it's written. Starts after after, or at
the end of the log. See EventStream.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input? |
{ types?: string[]; after?: string; } |
- |
input.types? |
string[] |
The event types to read, as wardrik.run.completed, given once for each. Every type where left out. A wardrik.events.dropped comes whatever the types. |
input.after? |
string |
The cursor to read after: a page's next, the id of an event a stream gave, or a snapshot's cursor. |
options? |
StreamOptions |
- |
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”timeline()
Section titled “timeline()”timeline(options?): Promise<Timeline>;Read an agent's conversation as a person reads it.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<Timeline>
Inherited from
Section titled “Inherited from”runs()
Section titled “runs()”runs(options?): Promise<Runs>;Read what an agent's runs did and cost.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<Runs>
Inherited from
Section titled “Inherited from”approve()
Section titled “approve()”approve( interrupt, input?, options?): Promise<object[]>;Approve a call an agent waits on.
agent.decide with one approval. Recorded as the caller's.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
interrupt |
string |
input? |
Approve |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<object[]>
Inherited from
Section titled “Inherited from”deny()
Section titled “deny()”deny( interrupt, input?, options?): Promise<object[]>;Reject a call an agent waits on.
agent.decide with one rejection. Recorded as the caller's.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
interrupt |
string |
input? |
Deny |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<object[]>
Inherited from
Section titled “Inherited from”definition()
Section titled “definition()”definition(options?): Promise<DefinitionRead>;Read an agent's definition.
Acts on the agent, never a conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<DefinitionRead>
Inherited from
Section titled “Inherited from”spawn()
Section titled “spawn()”spawn(options?): Promise<AgentSummary>;Start an agent.
Acts on the agent, never a conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<AgentSummary>
Inherited from
Section titled “Inherited from”stop()
Section titled “stop()”stop(options?): Promise<AgentSummary>;Stop an agent.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<AgentSummary>
Inherited from
Section titled “Inherited from”clear()
Section titled “clear()”clear(options?): Promise<AgentSnapshot>;Clear an agent's history.
Empties its history. The agent, its definition and its other conversations stay. Answers conflict while it runs a turn or waits on a person.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<AgentSnapshot>
Inherited from
Section titled “Inherited from”calls()
Section titled “calls()”calls(options?): Promise<object[]>;List the tool calls an agent is running.
Answers not_found while the agent sleeps.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<object[]>
Inherited from
Section titled “Inherited from”kill()
Section titled “kill()”kill(call, options?): Promise<void>;Stop one tool call.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
call |
string |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”triggerSet()
Section titled “triggerSet()”triggerSet( trigger, input?, options?): Promise<TriggerDefinition>;Set one of an agent's triggers.
Sets or changes one trigger of an agent with a definition, which keeps it; not_found where it has none. A trigger whose every and timezone stay keeps its next run.
Acts on the agent, never a conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
trigger |
string |
input? |
TriggerDefinition |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<TriggerDefinition>
Inherited from
Section titled “Inherited from”triggerRemove()
Section titled “triggerRemove()”triggerRemove(trigger, options?): Promise<TriggerDefinition>;Remove one of an agent's triggers.
Acts on the agent, never a conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
trigger |
string |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<TriggerDefinition>
Inherited from
Section titled “Inherited from”move()
Section titled “move()”move(input, options?): Promise<AgentSummary>;Move an agent to another node.
Starts the agent again on node, as it was. A turn it's taking ends, and what it waits on is abandoned, so ask it again once it's moved.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
Node |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<AgentSummary>