Agent HTTP API
The agent's own API, the one the apps use: pair once for a device token, then JSON over HTTPS and one live event stream.
Everything the apps do goes through this API on your agent's public URL (https://rusuban-agent-….sprites.app). There is no Rusuban server in between.
Pairing and auth
POST /pair
Content-Type: application/json
{ "code": "123456", "name": "My laptop", "platform": "web" }201 returns { token, device }. Send the token on every /api call:
Authorization: Bearer <token>| Rule | |
|---|---|
| Codes | 6 digits, 10 minutes, once; 5 wrong tries end every live code |
| Pair limit | 5 per address and 30 in total per 10 minutes |
| Tokens | 32 random bytes, stored as a SHA-256 hash, revoked from Devices |
| Roles | owner uses everything; viewer only /api/whoami (its app shows /public/state) |
| Body limit | 1 MiB (413 too_large) |
| CORS | /api and /pair only from the origins in WEB_ORIGINS |
| Busy | while a Rewind runs or the boot check is underway, writes answer 503 agent_busy |
Public, no token
| Method and path | |
|---|---|
GET /health | ok, name, version, uptime, whether it's inside a Sprite |
GET /public/state | the redacted live view; any origin, 60 a minute per address. Live view |
POST /hooks/tick | the QStash tick; checks the signature against the public URL, each signature once |
GET /s/<token> | a shared mini-app, frozen and sandboxed |
Live events
GET /api/stream?after=<seq> (or Last-Event-ID) is a Server-Sent Events stream: it replays everything after seq, then follows live, with a ping every 15 seconds and a ready event that says whether the client should reload. It closes when the device is removed. The app opens it while it's in front and closes it in the background.
Chat
POST /api/chat | the AI SDK UI-message body ({id, messages}) or {conversationId, text}; answers with the run's stream, replayed from its first chunk |
GET /api/chat/:id/stream | resume the active run (204 if none) |
GET /api/conversations, GET /api/conversations/:id/messages | history |
Cards
GET /api/approvals (?status=recent) | waiting cards, or the last 50 decided; each has allowable |
POST /api/approvals/:id/decide | {decision: "once" | "conversation" | "always" | "deny" | "handled"}; returns the card, when it sends, and any rule card |
POST /api/approvals/:id/edit | {args}: a new card that replaces this one |
POST /api/approvals/:id/undo | cancels inside the window, or queues the compensating action |
Everything else
| Area | Routes |
|---|---|
| Needs you | GET /api/items, /items/:id, POST /items/:id/hide | move | snooze | done, GET /api/brief, /calendar/next, /inbox |
| Money | GET /api/money, /cases, /cases/:id, POST /cases/:id/resolve | dismiss | reopen | draft | call, POST /money/scan |
| Calls | GET /api/calls, /calls/:id |
| Watchers | GET/POST /api/watchers, POST /watchers/:id/pause | resume | stop | check |
| Errands | GET /api/errands, /errands/:id, /errands/:id/live (frames), POST /errands/:id/input | takeover | handback | paid | stop |
| Code | GET /api/code/setup, PUT /code/engine, the ChatGPT sign-in routes, GET /code/repos/available, PUT /code/repos, GET/POST /code/tasks, POST /code/tasks/:id/cancel |
| Mini-apps | GET/POST /api/mini-apps, GET /mini-apps/:id, POST /mini-apps/:id/rebuild | publish | share | archive |
| You | /api/you, /settings, /memory, /rules (+ /rules/what-if), /routines, /quiet, /activity (+ /facets, /heatmap, /export), /usage, /connections, /devices, /agent (+ /checkpoint, /rewind), /search |
| Push | GET /api/push/vapid, POST /push/tokens, DELETE /push/mine, POST /push/test |
Errands have no create route: they start from chat, as a plan card.
Set up your own
One command on your Mac creates the agent and its workshop as Sprites in your Fly.io account, connects your keys through hidden prompts, and prints a pairing code.
Security
What stops it acting on its own, what stops outside text steering it, and what each part can and can't reach, with the limits stated plainly.