Quickstart: replay() Governance
Get replay() running in under 5 minutes with the primary public path: zero-config governance plus Governance Studio.
Prerequisites
- Node.js 20+
- An OpenAI or Anthropic API key
- npm or yarn
1. Install
npm install vesanor <provider-sdk>
Anthropic works too. Install
@anthropic-ai/sdkinstead ofopenaiand pass an Anthropic client. The SDK detects the provider automatically.
2. Wrap your client
The fastest path needs no local contracts and no local YAML:
import OpenAI from "openai";
import { replay } from "vesanor";
const client = new OpenAI();
const session = replay(client, {
apiKey: process.env.VESANOR_API_KEY,
agent: "orders-bot",
});
const response = await session.client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Process this order" }],
tools: myToolDefinitions,
});
That is enough to start the zero-config governance flow.
3. Open Governance Studio
Run your app. Then open Governance Studio and review:
- the workspace draft
- open judgments
- impact preview
- approval preview
Approval is the Studio-side authority boundary for the browser path.
4. Approve
After approval:
- development keeps behavior non-blocking
- staging evaluates in advisory mode
- production enforces protectively and fails closed when governance is unavailable
That is the main public runtime path.
What just happened
When you called session.client.chat.completions.create(), the zero-config governance flow ran:
- Lookup —
replay()looked up governance state for the agent/environment - Attach behavior — the SDK chose monitor/protect/govern behavior based on environment and approved-plan state
- Capture — request, response, tool definitions, and usage were buffered for upload
- Review — the hosted side built or updated review state for Studio
- Enforce after approval — when an approved compiled artifact exists, the SDK rehydrates it and applies the corresponding runtime behavior
What to add next
| Feature | What it does | Guide |
|---|---|---|
| Approval model | Understand what Studio approval freezes and what runtime attaches to | Approval Model |
| Runtime states | Understand attachment, degraded state, and fail-closed behavior | Runtime States |
| Kill switch | Emergency stop for runaway agents | Kill Switch |
| Server-backed state | Durable governed sessions with stronger evidence on the wrapped path | Govern Mode |
| Operations runbook | Practical responses for common states and failures | Operations Playbook |
Archived local-pack path
If you explicitly need local YAML packs, hand-authored contract packs, or recorded local workflows, use the archived docs under docs/legacy/advanced-local/ in the repo.