API Reference

Public surfaces you will use most — with links to the concept pages.

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();
MemberRole
use(plugin)Install a plugin
registerAgentMake agents resolvable for handoffs
executeCreate a runner and run it
createRunnerAdvanced: build a runner without executing yet
providerRegistry / toolRegistryShared 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",
  })
);

Providers · Plugins

Run options#

Passed as the third argument to execute:

OptionPurpose
sessionIdAttach session continuity
maxIterationsCap tool/provider loops
signalCancellation
metadataRun-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());

Tracing · Studio

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, …

Error Handling