API Reference
This page is a map of public surfaces. Prefer the concept pages for why; use this page to check what exists.
Engine#
import { Engine } from "@shiro-sdk/core";
const engine = new Engine({ events: traces /* optional services */ });
engine.use(plugin);
engine.registerAgent(agent);
engine.start(); // usually implicit on first execute
const result = await engine.execute(agent, input, options);
engine.stop();| Member | Role |
|---|---|
use(plugin) | Install a plugin |
registerAgent | Make agents resolvable for handoffs |
execute | Create a runner and run it |
createRunner | Advanced: build a runner without executing yet |
providerRegistry / toolRegistry | Shared registries |
→ Engine
Agent#
import { Agent } from "@shiro-sdk/core";
new Agent({
name: "support",
instructions: "...",
provider: "openai", // required: id or Provider instance
tools: [...],
output: schema, // optional .parse()
handoff: strategy, // optional HandoffStrategy
});
Agent.builder().name("support").provider("openai").build();→ Agents
Tool#
import { tool } from "@shiro-sdk/core";
tool({
name: "lookupInvoice",
description: "...",
parameters: schema, // required, must implement .parse()
requiresApproval: true, // optional
execute: async (input, context) => result,
});→ Tools
Provider plugin (OpenAI)#
import { OpenAIPlugin } from "@shiro-sdk/openai";
engine.use(
new OpenAIPlugin({
apiKey: process.env.OPENAI_API_KEY!,
model: "gpt-5",
})
);Run options#
Passed as the third argument to execute:
| Option | Purpose |
|---|---|
sessionId | Attach session continuity |
maxIterations | Cap tool/provider loops |
signal | Cancellation |
metadata | Run-level metadata for traces |
Tracing#
import { JsonTraceExporter, TraceManager } from "@shiro-sdk/core";
const traces = new TraceManager();
const engine = new Engine({ events: traces });
await engine.execute(agent, input);
await traces.export(new JsonTraceExporter());RunResult#
result.runId;
result.output;
result.messages;
result.finishReason;
result.context;Observability is via the event / trace pipeline, not a hidden result.trace field.
Errors#
ShiroError, ProviderError, ToolExecutionError, ValidationError,
ApprovalRejectedError, ConfigurationError, …