docs
Developer docs

Zero to durable agent in 25 lines.

Node ≥ 20 · TypeScript-first · zero runtime dependencies. Full reference on the desktop page.

Install & verify

npm install @nexusaiframework/runtime

# or from source, to run tests + demo:
git clone github.com/BULMKT/NexusAIAgentFramework
npm install && npm test   # 171 tests

Define an agent

const runtime = new NexusRuntime({
  storage: new FileStorage('.nexus') });

runtime.register(defineAgent({
  name: 'support',
  provider: new AnthropicProvider(),
  model: 'claude-sonnet-4-5',
  tools: [lookup, refund],  // refund: requiresApproval
  budget: { maxUsd: 0.50 },
  approvalPolicy: ({ arguments: a }) =>
    a.amountUsd < 50 ? 'approve' : 'ask',
}));

The lifecycle

const run = await runtime.run('support', task);
// waiting_approval? decide from anywhere:
await runtime.approve(run.id);
// crashed? halted at budget?
await runtime.resume(run.id);
// finished? regression-test it:
const rep = await replayRun(run);  // $0.00

Durable MCP

const client = await McpClient.connect({
  command: 'npx', args: ['-y', '@your/mcp-server'] });
const tools = await mcpTools(client, {
  requiresApproval: ['issue_refund'] });

Operate

attachWebhook(runtime, { url: SLACK_URL, format: 'slack' });
$ nexus serve            # dashboard :3838
$ nexus runs --status waiting_approval
$ nexus show run_x --steps
$ nexus replay run_x

Observe & attribute

attachOtel(runtime, { endpoint: OTEL_ENDPOINT });
// GenAI spans over OTLP, zero deps
await runtime.run('support', task, {
  tags: { customerId: 'acme-42' } });
await runtime.listRuns({
  tags: { customerId: 'acme-42' } });

Richer approvals

await runtime.approve(id, callId, {
  edited: { amountUsd: 50 } });
await runtime.respond(id, callId, 'handled by phone');
$ nexus mcp   # expose Nexus as an MCP server

Storage

FileStorage (zero-dep default) · SqliteStorage (built-in node:sqlite, Node 22+) · PostgresStorage (multi-node, bring-your-own pg client) · MemoryStorage (tests). Four adapters, 5-method interface.

The format

Runs persist as Open Agent Run documents (CC0, oar/0.2) with hosted JSON Schemas, plus zero-dep validators and a stdlib-only Python reader. Auditable and portable forever.

Full source & examples on GitHub →