A small HTTP API that lets a separate application server on the same machine put its users in conversation with specific bots, by text and by voice. The app owns its own users, profiles and PINs; the harness knows none of that. The harness trusts exactly one thing: the bearer token.
Implementation: src/commands/app-api.ts (keep this file in step with it).
Tokens: src/lib/app-tokens.ts. Envelope math: src/lib/wav-envelope.ts.
127.0.0.1 only, default port 4302.
SEEYOURAI_APP_PORT=<port> moves it; SEEYOURAI_APP_PORT=off turns it
off. It starts with the daemon (seeyourai daemon)./api/app/v1/*.
A loopback check on the dashboard port would not mean “local”: tailscale
serve, or any local reverse proxy, delivers remote callers from
127.0.0.1. A separate socket that no proxy points at is the only honest
“local caller” signal.403):
| code | refused when |
| — | — |
| not_loopback | the peer address is not 127.0.0.0/8 or ::1 |
| proxied | any of Forwarded, X-Forwarded-For/-Host/-Proto, X-Real-IP is present |
| browser_origin | an Origin header is present — call it from your server, never from a browser |
| bad_host | Host is not 127.0.0.1, localhost or [::1] (DNS rebinding) |seeyourai app create <name> --bots <bot>[,<bot>…] # prints the token ONCE
seeyourai app list # names, dates, bots — never tokens
seeyourai app revoke <name> # stops working on the next request
bhapp_<43 chars>. Only its SHA-256 digest is stored, in
<harness home>/auth/apps.json (mode 0600). A lost token is replaced
(revoke + create), not recovered.403 forbidden. Remote bot@host addresses are not allowed in v1.Authorization: Bearer <token>. Missing or unknown → 401
unauthorized (with WWW-Authenticate: Bearer) on every path, so an
unauthenticated caller learns nothing about which bots or paths exist.Every error is JSON: { "error": "<human text>", "code": "<machine code>" },
with Cache-Control: no-store. Codes below; a Retry-After header (seconds)
accompanies every 503 and 429.
Base: http://127.0.0.1:4302/api/app/v1. <bot> is a local bot name in the
token’s list.
GET /healthThe token’s bots only, never the whole fleet.
{
"bots": {
"alphabot": { "awake": true, "busy": false, "running": true, "waking": false, "state": "awake" },
"betabot": { "awake": false, "busy": false, "running": true, "waking": false, "state": "asleep" },
"ghostbot": { "awake": false, "busy": false, "running": false, "waking": false, "state": "stopped", "exists": false }
},
"features": ["early-transcribe"], // absent on an older host; ignore names you do not know
"talk_sdk": "2026.12.1", // this host's version (its release tag), which is its talk SDK's (docs/talk-sdk.md); absent on an older host
"talk_sdk_sources": "a0db…" // the sha256 of its talk SDK sources; null if it cannot say, absent on an older host
}
| field | meaning |
|---|---|
awake |
ready to take a message right now |
busy |
mid-turn (it is thinking/working); a message still queues behind the turn |
running |
its session exists at all (an idle-stopped bot keeps its session: asleep is not down) |
waking |
being woken; ready in seconds |
state |
awake · sleeping · asleep · waking · stopped (no session) |
exists: false |
in the token’s list but no such bot on this host |
talk_sdk (top level) |
the host’s version: its release tag without the “v” (2026.12.1, 2026.12.2-beta.1), or <last tag>-dev+<sha> off a release. The @seeyourai/talk-sdk it ships is that version: talk-sdk check warns when it is newer than the app’s |
talk_sdk_sources (top level) |
the sha256 of the host’s talk SDK sources (what a build’s dist/build.json calls sources): talk-sdk check fails an app whose tarball of the same version was built from other sources |
While any of the token’s bots is waking, /health answers 503 with
Retry-After: 5 — and the same per-bot body, so a client watching several
bots can see which one is not ready.
Sleep state comes from an idle-stop watchdog’s record,
<BOT_DIR>/.watchdog/idle-state.json ({"state": "awake"|"sleeping"|"asleep"|"waking", …}).
A missing, unreadable or unknown record means awake — hosts without idle-stop
behave exactly as before.
POST /bots/<bot>/messages// request (Content-Type: application/json, body ≤ 64 KiB)
{ "text": "what's on today?", "idempotency_key": "client-generated-uuid" }
| outcome | status | body |
|---|---|---|
| delivered (or queued behind a busy turn) | 200 |
{ "id": "<line id>", "busy": false } |
| bot asleep / falling asleep — accepted, and the line wakes it | 202 |
{ "id": "…", "busy": false, "waking": true } |
repeat of an idempotency_key with the same text |
200 |
{ "id": "<the original id>", "busy": …, "duplicate": true } |
| same key, different text | 409 |
idempotency_conflict |
| bot waking | 503 + Retry-After: 5 |
bot_waking — retry with the same key |
| bot not running | 503 + Retry-After: 30 |
bot_not_running — an operator has to start it |
| empty / not a string / bad key / bad JSON | 400 |
bad_request |
a line that is an [attached …: …] marker |
400 |
attachment_marker (no images in v1; it would name a host file) |
text over 4000 characters |
413 |
too_large |
app (<harness home>/channels/<bot>/web/threads/app.jsonl), and the
bot’s web channel delivers it into its normal session. It therefore appears
in transcripts, digests and the dashboard’s Talk tab exactly like any web
chat, and whatever restrictions the bot runs under apply unchanged. The API
never calls a model itself.busy
is reported so a UI can say “thinking…”.202: refusing would leave the bot asleep forever, because the
pending line on the thread is itself the wake trigger. Expect the reply to
take longer (the session is resumed first).GET /bots/<bot>/messagesLong-poll, not SSE.
| query | behaviour |
|---|---|
(no after) |
the last 30 lines of the app thread, oldest first |
after=<id> |
every line after that id (at most 200; page forward with the last id) |
after=<id>&waitMs=<n> |
held until a bot line lands after <id>, or n ms pass (capped at 25000); a timeout is 200 { "lines": [] }, not an error |
{
"lines": [
{ "id": "…", "role": "user", "text": "what's on today?", "ts": "2026-…Z" },
{ "id": "…", "role": "bot", "text": "Here is **the** plan: https://…",
"speech": "Here is the plan: a link", "ts": "…",
"attachments": [{ "kind": "image", "name": "abc123.png" }] }
]
}
role is user (anything written into the thread, by any app or the
dashboard) or bot.text has attachment marker lines removed; attachments lists them by kind
and name only. No images in v1 — they are not downloadable through this
API. A marker that does not point into the bot’s own attachments dir is not
an attachment and stays in text verbatim.speech (bot lines only): the text as it should be read aloud — markdown,
code, links and markers removed. Feed it to /speak.after that is not in the recent history → 404 unknown_after: read again
without after to resync.POST → take its id → GET ?after=<id>&waitMs=25000 until
a bot line arrives → after=<last id> for the next round.POST /bots/<bot>/transcribeRaw audio in the body; Content-Type one of audio/webm, audio/ogg,
audio/wav (audio/x-wav, audio/wave), audio/mp4 (audio/m4a,
audio/x-m4a); parameters such as ;codecs=opus are fine. Max 12 MiB.
{ "text": "what's on today", "empty": false }
{ "text": "", "empty": true, "reason": "silence" } // or "nothing-heard", "too-short"
The host’s local speech-to-text. It does not need the bot to be awake, and
nothing but the caller’s own context (below) is put in front of the decoder:
no bot name, no host roster and no SEEYOURAI_VOICE_PROMPT. (The dashboard’s
own voice input still uses those.) Errors: 415 unsupported_media_type, 413
too_large, 400 bad_context, 429 voice_busy, 503 voice_unavailable, 502
voice_failed, 504 voice_timeout.
?early=1: the clip so far, at a pause that may not be the end (see
docs/live-talk.md). Refused with 429 while anyone is being transcribed, given up
with 429 as soon as an ordinary clip comes, and stopped when the request is
aborted. It never delays anybody; on any error send the finished clip without it.
Only send it when /health lists early-transcribe: an older host ignores the
parameter and would put the clip in the queue in front of the finished one.
X-Speech-Context (optional): words the speaker may usePOST /api/app/v1/bots/alphabot/transcribe HTTP/1.1
Host: 127.0.0.1:4302
Authorization: Bearer bhapp_…
Content-Type: audio/webm;codecs=opus
X-Speech-Context: teapot%2C%20spout%2C%20handle%2C%20lid
<raw audio bytes>
encodeURIComponent(text); + is
not a space). A header because the body is the audio and query strings get
logged. Not valid percent-encoded ASCII, or over 8192 bytes encoded → 400
bad_context. Empty or absent = no context.--prompt in an argument list, with no shell.
It is never logged by the harness, stored, or sent to the bot. Like any
argument, it is visible to processes of the same host while whisper runs.empty, and the
hint is never used. If something is there it is heard again with the hint, and
the hinted wording is returned only when the two sound alike; otherwise you
get the unhinted one. So real answers made of context words survive.empty. When two spellings sound alike the hinted one wins, so a wrong or
stale hint can still swap a word for a similar-sounding one. Noise that
whisper turns into words without a hint still comes through, as it does with
no context.Two per host: the normal one (SEEYOURAI_WHISPER_MODEL) and an optional
alternate, normally larger and slower (SEEYOURAI_WHISPER_MODEL_ALT in the
daemon’s environment). A bot uses the alternate when its declaration
(<harness home>/bots/<bot>.env) says:
SPEECH_MODEL=alt # or `default`; nothing else is accepted, and never a path
It is read per request (no restart), applies to the dashboard’s voice input too,
and changes the model choice only: no network access, permission or tool
depends on it. An unknown value means default and is logged. No alternate configured, or its
file missing, means the normal model. For a provisioned bot:
seeyourai provision add --app <app> --external-id <uuid> --template <file> --speech-model alt …
seeyourai provision update --app <app> --external-id <uuid> --speech-model default|alt [--dry-run]
update changes that one key in the bot’s .env (atomic rename, mode 0600) and
refuses any bot provision add did not make.
POST /bots/<bot>/speak{ "text": "Good morning", "voice": "optional-installed-voice-id", "engine": "piper" } // voice, engine: optional
200 audio/wav in the bot’s own voice (its memory/page.json
voice section — name, pitch, rate), falling back to the host default. An
explicit voice is used as given, without the bot’s pitch/rate. Headers:
X-Voice-Engine, and X-Voice-Fallback when the engine fell back."engine": "piper" does not try Kokoro: the host’s fallback voice, with the
bot’s own pitch and rate. Any other value is ignored.?envelope=1 → JSON instead, for animating a speaking face without
decoding the audio twice:
{
"audio_b64": "UklGR…", // the same WAV, base64
"sample_rate": 24000,
"duration_ms": 1840,
"window_ms": 20,
"envelope": [0, 0, 0.12, 0.87, 1, …], // loudness per 20 ms frame, 0..1
"engine": "kokoro"
}
envelope is RMS loudness per 20 ms window, normalized so the loudest window
of this clip is 1; windows below about -60 dBFS are 0 (so pauses close the
mouth). ceil(duration / 20 ms) values; the last window may be partial.
413; empty → 400; unknown voice → 400;
engine errors as for transcribe.The host renders a whole text before it answers, so a long reply is a long
silence. Split the line’s speech yourself and ask for one piece at a time; every
piece is an ordinary /speak (with ?envelope=1 too: the envelope is normalized
per piece). Two files do it, and import nothing, so copy them:
src/ui/page-sdk/sentences.ts: splitSpeech(text) → pieces of at most 140
characters, every word kept, of the first 2000 characters of the text.src/ui/page-sdk/pieces.ts: playPieces(pieces, { render, play, … }, signal)
plays them in order, fetching one ahead and never two.const left = await playPieces(splitSpeech(line.speech), {
async render(text, { engine, signal }) {
const r = await speakViaYourServer({ text, engine: engine ?? undefined }, signal)
return { clip: r, engine: r.engine, fellBack: r.fellBack } // X-Voice-Engine; is X-Voice-Fallback there?
},
play: clip => yourPlayer.play(clip), // resolves when it has ENDED; stop the sound yourself on abort
onStart() {}, // the first sound of the reply, once
}, abort.signal)
if (left.length) sayAnotherWay(left.join(' ')) // [] = all said, or aborted
X-Voice-Fallback, the
rest are asked for with its engine, so the voice does not switch back.left is what
could not be said at all: nothing had sounded yet, two in a row failed, it was the
end, the host refused (reject with the HTTP status as status: a 4xx is not asked
again) or took long to fail, a clip would not play, or nothing was heard for 75 s
(maxGapMs; Infinity waits). Until then a host that has not answered is waited
for: it may be rendering somebody else’s text.An app can ask the operator for one bot per user. What such a bot is for is the
app’s business: the app supplies its CLAUDE.md. The harness names the bot,
locks it down and registers it.
seeyourai provision add --app <app> --external-id <uuid> --template <CLAUDE.md template>
[--prefix <p>] [--name "<display name>"] [--about <text> | --about-file <path>|-]
[--approver-bot <bot>] [--speech-model default|alt]
[--talk-journal THREADS|off] [--talk-journal-guidance PATH]
[--otel-endpoint URL] [--json] [--dry-run] [--no-start]
seeyourai provision update --app <app> --external-id <uuid> [--name …] [--about … | --about-file …]
[--speech-model …] [--talk-journal …] [--talk-journal-guidance …] [--json] [--dry-run]
seeyourai provision list [--app <app>] [--json]
seeyourai provision remove (--bot <bot> | --app <app> --external-id <uuid>) [--json] [--dry-run]
seeyourai app add-bot <app> <bot> # widen an app's bot list (token unchanged, never reprinted)
seeyourai app remove-bot <app> <bot> # narrow it
<prefix>- + the first 8 hex of the external id (a UUID v4; anything
else is refused). The prefix is the app’s name unless --prefix says otherwise.
If that name is taken, it lengthens to 12, 16, … 32 hex. It never overwrites.
The app and the full id are stored in the bot’s .env (PROVISIONED=1,
PROVISIONED_APP, PROVISIONED_EXTERNAL_ID), so re-running add for the same
user prints the same name and fills in any file a crashed earlier run left
missing. The app must already have a token (app create).BOT_DIR=~/.seeyourai/provisioned/<bot>/ (mode 0700), outside any
git repo, with GIT_SYNC=off, so a user’s chats are never pushed anywhere.bots/<bot>.env, bots/<bot>.settings.json and
bots/<bot>.claude-template.md (outside the bot’s folder, so the bot cannot
edit them), and CLAUDE.md, memory/MEMORY.md, .mcp.json and .watchdog/
in BOT_DIR. On macOS it also writes ~/Library/LaunchAgents/bot.<bot>.plist,
then launchctl bootstraps it (skipped by --no-start, or when it is already
loaded). --dry-run prints every file and action and writes nothing.claude --restricted --tools
Read,Write,Edit,Glob,Grep --strict-mcp-config with only bot-mesh + web,
external settings (dontAsk; allow = read its own folder + write its own
memory/; denies cover Bash/Web/Agent/Skill, the approver bot’s folder,
~/.claude, the harness home’s other entries, every other provisioned bot’s
folder and provisioned/.removed). It runs with no
--dangerously-skip-permissions, --remote-control, Telegram or browser.
--add-dir BOT_DIR plus CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 is
what makes --restricted load CLAUDE.md. Permission rules have no negation,
so adding a bot re-writes every other provisioned bot’s deny list to name the
new folder.{{DISPLAY_NAME}}, {{APP}}, {{BOT}} and {{APPROVER_BOT}} (the last
needs --approver-bot); any other {{UPPER_CASE}} is refused.
templates/provisioned-bot/CLAUDE.md is an example to copy.CLAUDE.md, never in the .env,
the plist or a shell command.{{/}} and the characters < > { } ` @ are removed (@path is
a CLAUDE.md import, and </> could close the markers); then it is trimmed
and cut to 300. It is rendered after the template’s body, between
<!-- about:start --> and <!-- about:end -->, under “About (from the app)”
and a line saying it is background, not instructions, and can’t change any rule
in the file. With no about, the two markers are still written with nothing
between them. provision update --about … rewrites only what is between the
markers (same text twice is a no-op; --about '' clears it) and takes effect on
the bot’s next session. add for a user who already has a bot leaves its name
and about alone. --about-file (or - for stdin) keeps the text off the shell
command line entirely, which is the safe way to pass text from a web form.--otel-endpoint http://host:4317, or PROVISION_OTEL_ENDPOINT=
in <harness home>/config. With neither, no telemetry is configured.provisioned/.removed/<bot>-<UTC stamp>/. Its .env, settings, plist, web
threads, mailbox and schedule runs go under that folder’s .harness/. Nothing is deleted. It
refuses any bot that provision add did not make.send_mail cannot be limited by recipient, so the approver bot (and every
peer) must treat mail from a provisioned bot as its user speaking.The harness does not listen for these. The app sends them to whoever operates the host (for example as a message to an operator bot), and the operator runs the matching command. The message format is between the app and the operator. Every field is untrusted: check its shape, and that the external id is a UUID v4, before running anything, and report anything off-shape instead of running it.
| The app’s user was | Command |
|---|---|
| added | provision add --app <app> --external-id <uuid> --template <file> --name <display name> [--about-file <file holding the about>] --json |
| changed | provision update --app <app> --external-id <uuid> --about-file <file holding the about> |
| removed | provision remove --app <app> --external-id <uuid> |
add is idempotent: a repeat names the same bot and changes nothing. It prints
{"app":…,"external_id":…,"bot":…,"bot_dir":…}; the app needs bot, to map its
user to it.add fail with nothing written;
the app should ask for a plainer name.remove never deletes: see Remove above.bot@host) and no remote callers.app thread. If an app
needs per-user separation, it owns that (and says who is speaking in the text).app:<user>) so two app users sharing one bot don’t
mix histories in the bot’s context; v1 assumes one user per bot.