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 an agent's current status.
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.
Creates the agent from this definition, or updates a running agent from its next turn. Each call replaces the whole definition. An unsupported key returns not_supported with the key's name.
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>;Delete 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 a message to an agent.
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 pending tool calls.
All decisions are applied together and recorded under the caller. A rejection's reason is sent to the model instead of the tool's result. An approval's note is sent with the result.
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 the authorization URL for a pending 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>;Cancel an agent's current turn.
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 events.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input? |
{ types?: string[]; after?: string; before?: string; order?: "oldest" | "newest"; limit?: number; } |
- |
input.types? |
string[] |
The event types to return, for example wardrik.run.completed. List each type once. Defaults to all types. wardrik.events.dropped is always returned. |
input.after? |
string |
Return events after this cursor. Use the next value from the previous page, an event ID from a stream, or the cursor from agent.read, agent.timeline or agent.runs. |
input.before? |
string |
With order newest, return events before this cursor. Use the next value from the previous page. |
input.order? |
"oldest" | "newest" |
oldest returns the oldest events first, after the cursor; newest returns the newest first, before the cursor or from the end. Defaults to oldest. |
input.limit? |
number |
The maximum number to return. Defaults to 100. |
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; before?: string; order?: "oldest" | "newest"; } |
- |
input.types? |
string[] |
The event types to return, for example wardrik.run.completed. List each type once. Defaults to all types. wardrik.events.dropped is always returned. |
input.after? |
string |
Return events after this cursor. Use the next value from the previous page, an event ID from a stream, or the cursor from agent.read, agent.timeline or agent.runs. |
input.before? |
string |
With order newest, return events before this cursor. Use the next value from the previous page. |
input.order? |
"oldest" | "newest" |
oldest returns the oldest events first, after the cursor; newest returns the newest first, before the cursor or from the end. Defaults to oldest. |
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.
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 an agent's runs and their 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 pending tool call.
Same as agent.decide with one approval. Recorded under the caller.
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 pending tool call.
Same as agent.decide with one rejection. Recorded under the caller.
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.
Deletes the agent's history. The agent, its definition and its other conversations are kept. Returns conflict while the agent is running a turn or waiting for an approval.
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 an agent's running tool calls.
Returns not_found while the agent is asleep.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<object[]>
Inherited from
Section titled “Inherited from”runtime()
Section titled “runtime()”runtime(options?): Promise<AgentRuntime>;Read an agent's resource use.
Returns the memory, mailbox size and work of a running agent's processes. Returns not_found while the agent is asleep.
Acts on the agent, never a conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<AgentRuntime>
Inherited from
Section titled “Inherited from”resolved()
Section titled “resolved()”resolved(options?): Promise<AgentResolved>;Read what an agent gets.
Returns what the app gives the agent: who it works for, its policies, MCP servers and their tools, notify targets, channels and workspaces.
Acts on the agent, never a conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
CallOptions |
Returns
Section titled “Returns”Promise<AgentResolved>
Inherited from
Section titled “Inherited from”files()
Section titled “files()”files(input?, options?): Promise<AgentFile[]>;List an agent's files.
Returns the files in the agent's workspace, newest first, at most 500. Files shared with it from other workspaces aren't listed.
Acts on the agent, never a conversation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input? |
{ glob?: string; } |
- |
input.glob? |
string |
Return only the paths this glob matches: * within a folder, ? one character, ** across folders. Defaults to **. |
options? |
CallOptions |
- |
Returns
Section titled “Returns”Promise<AgentFile[]>
Inherited from
Section titled “Inherited from”file()
Section titled “file()”file(input, options?): Promise<AgentFileContent>;Read an agent's file.
Returns a file in the agent's workspace, with its content and version. Returns not_found if there's no file at the path.
Acts on the agent, never a conversation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input |
{ path: string; } |
- |
input.path |
string |
The file's path in the workspace, such as notes/today.md. |
options? |
CallOptions |
- |
Returns
Section titled “Returns”Promise<AgentFileContent>
Inherited from
Section titled “Inherited from”filePut()
Section titled “filePut()”filePut(input, options?): Promise<AgentFile>;Write an agent's file.
Writes a file in the agent's workspace. With version, writes only over that version and returns conflict if the file has changed. Without version, replaces any file at the path. The file carries no labels.
Acts on the agent, never a conversation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
AgentFilePut |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<AgentFile>
Inherited from
Section titled “Inherited from”fileDelete()
Section titled “fileDelete()”fileDelete(input, options?): Promise<void>;Delete an agent's file.
Deletes a file in the agent's workspace. Returns not_found if there's no file at the path.
Acts on the agent, never a conversation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input |
{ path: string; } |
- |
input.path |
string |
The file's path in the workspace, such as notes/today.md. |
options? |
CallOptions |
- |
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”kill()
Section titled “kill()”kill(call, options?): Promise<void>;Stop a 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>;Create or update an agent's trigger.
Creates or updates one trigger and saves it in the agent's definition. Returns not_found if the agent has no definition. If every and timezone don't change, the next run time is kept.
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 an agent's trigger.
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.
Restarts the agent on the given node, with its state. A turn in progress is stopped, and pending approvals are dropped. Send the request again after the move.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
Node |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<AgentSummary>