Wardrik
A client for one Wardrik server.
const wardrik = new Wardrik();const agent = wardrik.agent("support-bot");await agent.define({ model: "anthropic:claude-sonnet-4-5" });
for await (const event of agent.stream("What's on fire?")) { if (event.type === "wardrik.message.delta") process.stdout.write(event.data.delta);}Throws a TypeError without a token.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Wardrik(options?): Wardrik;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
WardrikOptions |
Returns
Section titled “Returns”Wardrik
Overrides
Section titled “Overrides”Operations.constructorProperties
Section titled “Properties”agents
Section titled “agents”readonly agents: AgentsOperations;The agents.* operations.
Inherited from
Section titled “Inherited from”interrupts
Section titled “interrupts”readonly interrupts: InterruptsOperations;The interrupts.* operations.
Inherited from
Section titled “Inherited from”events
Section titled “events”readonly events: EventsOperations;The events.* operations.
Inherited from
Section titled “Inherited from”readonly audit: AuditOperations;The audit.* operations.
Inherited from
Section titled “Inherited from”deployment
Section titled “deployment”readonly deployment: DeploymentOperations;The deployment.* operations.
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”agent()
Section titled “agent()”agent(id, options?): Agent;Returns an agent, or one of its conversations. Makes no request.
const agent = wardrik.agent("support-bot");const thread = wardrik.agent("support-bot", { conversation: "C1-1696.1234" });Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
string |
options? |
AgentOptions |
Returns
Section titled “Returns”run<Id>( id, input, options?): Promise<Outputs[Id]>;Runs an operation by its ID, with all its parameters in input.
await wardrik.run("agent.ask", { agent: "support-bot", content: "Hi" });Type Parameters
Section titled “Type Parameters”Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
id |
Id |
input |
Inputs[Id] |
options? |
CallOptions |
Returns
Section titled “Returns”Promise<Outputs[Id]>
listen()
Section titled “listen()”listen(handlers, options?): Promise<void>;Passes each event to the handler for its type, with the cursor after it.
await wardrik.listen( { "wardrik.run.completed": (event, cursor) => saveRun(event, cursor) }, { agents: ["support-bot"], after: savedCursor },);- Waits for each handler before the next event.
- Each event arrives at least once. Drop repeats by
event.id. - Resolves when
signalaborts. Rejects with what a handler throws.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
handlers |
Handlers |
options? |
ListenOptions |
Returns
Section titled “Returns”Promise<void>
tool()
Section titled “tool()”tool<Input>(definition): this;Adds a tool that runs in this process. Agents whose tools include workers/* call it as
workers__<name>.
wardrik.tool({ name: "refund_order", description: "Refund an order in full.", input: z.object({ orderId: z.string() }), idempotent: true, run: ({ orderId }, { idempotencyKey }) => stripe.refunds.create({ payment_intent: orderId }, { idempotencyKey }),});
await wardrik.work();Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Input extends StandardSchemaWithJSON |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
definition |
ToolDefinition<Input> |
Returns
Section titled “Returns”this
work()
Section titled “work()”work(options?): Promise<void>;Answers calls to the tools added with tool until signal aborts. Reconnects on its own.
Throws a WardrikError if the token is refused.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options? |
WorkOptions |
Returns
Section titled “Returns”Promise<void>