Type any task. Watch tokens stream in, the run pause for approval (approve, edit, deny, or respond), halt at the budget, survive a kill -9, and replay for free, while OTel spans export and cost is tagged to a customer. The model here is simulated, no API calls leave your browser, but the state machine, journal, budgets, streaming, approval verbs, tags, and telemetry are exactly the real runtime's.
Drag left to watch the run halt mid-flight, before spending, not after.
Rides the record, journal, webhooks, and OTel spans. Every dollar attributed to this customer.
What's simulated, what's real: the model responses here are scripted so the demo runs offline in your browser (real providers stream over SSE the same way). Everything else, the seven-state machine, pre-flight budget enforcement, durable approval pauses with approve/edit/deny/respond, buffered tool results, crash resume, journal step types, run tags, OTel span export, and $0 replay, matches the open-source runtime exactly. Run the real thing with npm run demo, or the new capabilities with npx tsx examples/03-observability-and-hitl.ts.
import { NexusRuntime, FileStorage, AnthropicProvider, defineAgent, defineTool } from '@nexusaiframework/runtime'; const runtime = new NexusRuntime({ storage: new FileStorage('.nexus') }); runtime.register(defineAgent({ name: 'support', provider: new AnthropicProvider(), model: 'claude-sonnet-4-5', tools: [lookupCustomer, issueRefund], // issueRefund: requiresApproval budget: { maxUsd: 0.50 }, approvalPolicy: ({ arguments: a }) => a.amountUsd < 50 ? 'approve' : 'ask', }));
attachOtel(runtime, { endpoint: OTLP_URL }); // spans to Datadog/Grafana const run = await runtime.run('support', 'Refund jane $250', { tags: { customerId: 'acme' } }); // cost, attributed // waiting_approval, durably paused. Four moves: await runtime.approve(run.id, callId, { amountUsd: 200 }); // edit await runtime.respond(run.id, callId, 'use account B'); // answer await runtime.resume(run.id); // crashed? pick up where it died const report = await replayRun(run); // re-run offline, $0.00