ai world/ sami
Manual · ed. 2026

The manual.

Everything you need to use, extend, and self-host the workshop.

01

Quick start

Pick an agent on the home page or visit /chat. Each agent has its own system prompt. Type a question, get a streamed reply. No login required.

# local dev
pnpm install
cp .env.example .env.local
pnpm dev
02

Architecture

Single Next.js 14 app. One streaming endpoint serves all 8 agents. Each agent is a system prompt + metadata in src/lib/agents.ts.

src/
├── app/ # routes
├── components/ # UI
├── lib/
│ ├── agents.ts # agent registry
│ ├── auth.ts # BetterAuth (optional)
│ └── db.ts # Postgres pool
03

Streaming protocol

POST /api/agent with { agentId, messages }. Response is text/plain ReadableStream. Tokens land on the client as they arrive from OpenAI.

const res = await fetch("/api/agent", {
 method: "POST",
 body: JSON.stringify({ agentId, messages })
});
const reader = res.body.getReader();
// decode chunks → render
04

Adding an agent

Append to AGENTS in src/lib/agents.ts. Cards, routes, and chat pick it up automatically — no other file to touch.

{
 id: "my-agent",
 number: "09",
 name: "The Apprentice",
 role: "Helper",
 systemPrompt: "You are…",
 starters: [...],
 rules: [...]
}
More?
Open the source.
github ↗