Skip to content

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.
  • stream and reply also follow the run that answers a message.
  • Methods that can act on a conversation act on conversation.
readonly agent: string;

The agent's ID.

AgentOperations.agent


readonly conversation: string | undefined;

The conversation the methods act on. undefined for the agent's own history.

AgentOperations.conversation

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.

Parameter Type
input string | Ask
options? StreamAskOptions

AsyncGenerator<WardrikEvent>


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);
Parameter Type
input string | Ask
options? StreamAskOptions

Promise<Reply>


read(options?): Promise<AgentSnapshot>;

Read an agent's current status.

Parameter Type
options? CallOptions

Promise<AgentSnapshot>

AgentOperations.read


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.

Parameter Type
input? AgentDefinition
options? CallOptions

Promise<AgentSnapshot>

AgentOperations.define


forget(options?): Promise<void>;

Delete an agent.

Acts on the agent, never a conversation.

Parameter Type
options? CallOptions

Promise<void>

AgentOperations.forget


ask(input, options?): Promise<{
id: string;
cursor: string;
}>;

Send a message to an agent.

Parameter Type
input Ask
options? CallOptions

Promise<{ id: string; cursor: string; }>

AgentOperations.ask


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.

Parameter Type
input Decisions
options? CallOptions

Promise<object[]>

AgentOperations.decide


authorization(interrupt, options?): Promise<Authorization>;

Read the authorization URL for a pending call.

Parameter Type
interrupt string
options? CallOptions

Promise<Authorization>

AgentOperations.authorization


cancel(options?): Promise<void>;

Cancel an agent's current turn.

Parameter Type
options? CallOptions

Promise<void>

AgentOperations.cancel


events(input?, options?): Promise<Events>;

Read an agent's events.

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 -

Promise<Events>

AgentOperations.events


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.

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 -

EventStream

AgentOperations.streamEvents


timeline(options?): Promise<Timeline>;

Read an agent's conversation.

Parameter Type
options? CallOptions

Promise<Timeline>

AgentOperations.timeline


runs(options?): Promise<Runs>;

Read an agent's runs and their cost.

Parameter Type
options? CallOptions

Promise<Runs>

AgentOperations.runs


approve(
interrupt,
input?,
options?
): Promise<object[]>;

Approve a pending tool call.

Same as agent.decide with one approval. Recorded under the caller.

Parameter Type
interrupt string
input? Approve
options? CallOptions

Promise<object[]>

AgentOperations.approve


deny(
interrupt,
input?,
options?
): Promise<object[]>;

Reject a pending tool call.

Same as agent.decide with one rejection. Recorded under the caller.

Parameter Type
interrupt string
input? Deny
options? CallOptions

Promise<object[]>

AgentOperations.deny


definition(options?): Promise<DefinitionRead>;

Read an agent's definition.

Acts on the agent, never a conversation.

Parameter Type
options? CallOptions

Promise<DefinitionRead>

AgentOperations.definition


spawn(options?): Promise<AgentSummary>;

Start an agent.

Acts on the agent, never a conversation.

Parameter Type
options? CallOptions

Promise<AgentSummary>

AgentOperations.spawn


stop(options?): Promise<AgentSummary>;

Stop an agent.

Parameter Type
options? CallOptions

Promise<AgentSummary>

AgentOperations.stop


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.

Parameter Type
options? CallOptions

Promise<AgentSnapshot>

AgentOperations.clear


calls(options?): Promise<object[]>;

List an agent's running tool calls.

Returns not_found while the agent is asleep.

Parameter Type
options? CallOptions

Promise<object[]>

AgentOperations.calls


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.

Parameter Type
options? CallOptions

Promise<AgentRuntime>

AgentOperations.runtime


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.

Parameter Type
options? CallOptions

Promise<AgentResolved>

AgentOperations.resolved


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.

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 -

Promise<AgentFile[]>

AgentOperations.files


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.

Parameter Type Description
input { path: string; } -
input.path string The file's path in the workspace, such as notes/today.md.
options? CallOptions -

Promise<AgentFileContent>

AgentOperations.file


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.

Parameter Type
input AgentFilePut
options? CallOptions

Promise<AgentFile>

AgentOperations.filePut


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.

Parameter Type Description
input { path: string; } -
input.path string The file's path in the workspace, such as notes/today.md.
options? CallOptions -

Promise<void>

AgentOperations.fileDelete


kill(call, options?): Promise<void>;

Stop a tool call.

Parameter Type
call string
options? CallOptions

Promise<void>

AgentOperations.kill


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.

Parameter Type
trigger string
input? TriggerDefinition
options? CallOptions

Promise<TriggerDefinition>

AgentOperations.triggerSet


triggerRemove(trigger, options?): Promise<TriggerDefinition>;

Remove an agent's trigger.

Acts on the agent, never a conversation.

Parameter Type
trigger string
options? CallOptions

Promise<TriggerDefinition>

AgentOperations.triggerRemove


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.

Parameter Type
input Node
options? CallOptions

Promise<AgentSummary>

AgentOperations.move