jonaki

Examples

Six runnable projects, from hello world to an offline replay test.

Every example lives in examples/ and runs against a real model. Clone the repo, add one API key, and go:

git clone https://github.com/rohhitrz/jonaki.git
cd jonaki
pnpm install
cp .env.example .env    # add one key
pnpm build

01 · Hello

One agent, one tool. The shape of every Jonaki program.

pnpm example
The weather in Guwahati is currently 22°C with clear skies.

[2 turns · 1334 in / 79 out · $0.0052]

02 · Memory

A CLI chat that remembers across process restarts, backed by SQLite.

pnpm example:memory
pnpm example:memory -- --session work   # separate conversations
pnpm example:memory -- --history        # print the transcript

Quit with /exit, start it again, and ask what your name is — it still knows, because the session outlived the run that created it.

jonaki chat — session "default"
Resuming with 2 remembered messages.

you  What's my name?
bot  Your name is Rohit.

03 · Handoff

A triage agent that routes to a billing or technical specialist, with a context filter on one of them.

pnpm example:handoff
user      I was charged twice for invoice INV-1190. What happened?

↪ handoff  triage → billing  (Customer reports a duplicate charge)
🔧 tool     lookup_invoice [ok]

agent(billing)  Invoice INV-1190 for $420.00 is marked as a duplicate of
INV-1189. This needs to be refunded.

[3 turns · depth 1 · $0.0112]

04 · Guardrails

PII redaction plus a refund that needs a human.

pnpm example:guardrails
user (raw)      Hi, I'm rohit@example.com, card 4111 1111 1111 1111...
model saw       Hi, I'm [REDACTED_EMAIL], card [REDACTED_CREDITCARD]...

PII in state?   none — the raw values never entered the transcript

status          awaiting_approval
waiting on      issue_refund({"amountUSD":850,"reason":"Service was down"})

The second run pauses and returns. The process could exit there.

05 · Structured

Typed extraction from a deliberately messy email — including a self-correction the writer made mid-sentence.

pnpm example:structured
order      A-7741
customer   Priya Raghunathan <priya.r@northwind.co>
total      $184.97
sentiment  angry
escalate   yes
items      3
   2 × WL-220   walnut desk lamp
   1 × CT-09    cable tidy kit
   3 × CS-114   felt coasters

06 · Replay

The differentiator. A recorded booking run, replayed offline as a vitest suite.

pnpm example:replay

No API key required. The recording is committed to the repo:

✓ replays a recorded run without touching the network
✓ really executes the tools — they are not replayed
✓ searches the route the user asked for
✓ books the cheaper of the two flights
✓ surfaces a tool that now throws
✓ throws REPLAY_DIVERGED when a tool is deleted

To record your own:

pnpm --filter @jonaki/example-06-replay record   # needs a key
pnpm --filter @jonaki/example-06-replay test     # needs nothing

Or from the CLI:

npx jonaki test runs/runs --agent ./agent.ts

Starting your own

mkdir my-agent && cd my-agent
npm init -y
npm install @rohhitrz/jonaki zod tsx
npx @rohhitrz/jonaki init

That scaffolds agent.ts, .env.example, jonaki.test.ts, and AGENTS.md — a machine-readable API spec that helps Claude Code or Cursor write correct Jonaki code on the first try.

On this page