somora 2026.930.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +364 -0
- package/bin/node-version.d.mts +3 -0
- package/bin/node-version.mjs +45 -0
- package/bin/somora.mjs +77 -0
- package/config.example.yaml +896 -0
- package/docs/agents.md +677 -0
- package/docs/api.md +3194 -0
- package/docs/browser.md +317 -0
- package/docs/builder.md +331 -0
- package/docs/cache-strategy.md +373 -0
- package/docs/compaction.md +253 -0
- package/docs/display.md +154 -0
- package/docs/dream-phases.md +891 -0
- package/docs/files.md +387 -0
- package/docs/imagegen.md +366 -0
- package/docs/images/somora-hero.png +0 -0
- package/docs/images/somora-mobile-2026-05-23.png +0 -0
- package/docs/images/somora-tui-2026-05-23.png +0 -0
- package/docs/images/somora-web-2026-05-23.png +0 -0
- package/docs/index.md +178 -0
- package/docs/lsp.md +93 -0
- package/docs/mcp.md +332 -0
- package/docs/memory.md +407 -0
- package/docs/mobile.md +310 -0
- package/docs/models.md +379 -0
- package/docs/projects.md +425 -0
- package/docs/realtime-voice.md +293 -0
- package/docs/resources.md +230 -0
- package/docs/sampling.md +128 -0
- package/docs/security.md +189 -0
- package/docs/sentinel.md +295 -0
- package/docs/setup.md +1217 -0
- package/docs/skills.md +501 -0
- package/docs/team.md +189 -0
- package/docs/thinking.md +463 -0
- package/docs/tmux.md +399 -0
- package/docs/tools.md +117 -0
- package/docs/videogen.md +191 -0
- package/docs/voice.md +288 -0
- package/docs/web.md +893 -0
- package/docs/wiki.md +583 -0
- package/npm-shrinkwrap.json +5670 -0
- package/package.json +116 -0
- package/src/attachments/store.ts +196 -0
- package/src/browser/change-stream.ts +31 -0
- package/src/browser/display.ts +108 -0
- package/src/browser/policy.ts +121 -0
- package/src/browser/screencast.ts +374 -0
- package/src/browser/service.ts +1337 -0
- package/src/browser/session.ts +15 -0
- package/src/browser/snapshot.ts +40 -0
- package/src/cli/auth.ts +117 -0
- package/src/cli/codex.ts +41 -0
- package/src/cli/lsp.ts +71 -0
- package/src/cli/resolvers/clawhub.ts +400 -0
- package/src/cli/setup.ts +835 -0
- package/src/cli/skill.ts +619 -0
- package/src/cli/somora.ts +548 -0
- package/src/cli/systemd-unit.ts +72 -0
- package/src/cli/team.ts +148 -0
- package/src/cli/tui/activity-stream.ts +121 -0
- package/src/cli/tui/api.ts +479 -0
- package/src/cli/tui/app.tsx +1169 -0
- package/src/cli/tui/autocomplete.tsx +55 -0
- package/src/cli/tui/commands.ts +913 -0
- package/src/cli/tui/dream-glyphs.ts +22 -0
- package/src/cli/tui/footer.tsx +15 -0
- package/src/cli/tui/format.ts +28 -0
- package/src/cli/tui/header.tsx +279 -0
- package/src/cli/tui/index.tsx +120 -0
- package/src/cli/tui/markdown.tsx +63 -0
- package/src/cli/tui/sampling.ts +162 -0
- package/src/cli/tui/separator.tsx +13 -0
- package/src/cli/tui/state.ts +42 -0
- package/src/cli/tui/stream.ts +330 -0
- package/src/cli/tui/thinking-text.ts +54 -0
- package/src/cli/tui/turn-views.tsx +499 -0
- package/src/cli/tui/types.ts +410 -0
- package/src/cli/tui/work-queue.ts +161 -0
- package/src/cli/update-args.ts +55 -0
- package/src/cli/wiki.ts +406 -0
- package/src/compaction/index.ts +28 -0
- package/src/compaction/midturn.ts +210 -0
- package/src/compaction/policy.ts +154 -0
- package/src/compaction/summarize.ts +691 -0
- package/src/compaction/template.ts +90 -0
- package/src/compaction/types.ts +148 -0
- package/src/config/loader.ts +276 -0
- package/src/config/reload.ts +43 -0
- package/src/config/types.ts +2292 -0
- package/src/dream/deep-actions.ts +324 -0
- package/src/dream/deep-dispatcher.ts +237 -0
- package/src/dream/deep-llm.ts +388 -0
- package/src/dream/deep-prompts.ts +106 -0
- package/src/dream/deep-runner.ts +757 -0
- package/src/dream/deep-skip-cache.ts +199 -0
- package/src/dream/deep-worker.ts +229 -0
- package/src/dream/json-salvage.ts +34 -0
- package/src/dream/judge.ts +188 -0
- package/src/dream/loop-state.ts +286 -0
- package/src/dream/lucid-actions.ts +303 -0
- package/src/dream/lucid-batches.ts +94 -0
- package/src/dream/lucid-prompt.ts +82 -0
- package/src/dream/lucid-runner.ts +744 -0
- package/src/dream/lucid-storage.ts +277 -0
- package/src/dream/lucid-structure.ts +102 -0
- package/src/dream/lucid-types.ts +137 -0
- package/src/dream/lucid-worker.ts +224 -0
- package/src/dream/rem-dedup.ts +502 -0
- package/src/dream/rem-extract.ts +782 -0
- package/src/dream/rem-reset-run.ts +67 -0
- package/src/dream/rem-runner.ts +696 -0
- package/src/dream/rem-worker.ts +527 -0
- package/src/dream/review-window.ts +71 -0
- package/src/dream/scheduler-state.ts +129 -0
- package/src/dream/storage.ts +497 -0
- package/src/dream/types.ts +133 -0
- package/src/dream/wiki-context.ts +133 -0
- package/src/engine/a2a.ts +33 -0
- package/src/engine/availability.ts +63 -0
- package/src/engine/claude-cli.ts +969 -0
- package/src/engine/codex-app-server-client.ts +294 -0
- package/src/engine/codex-bin.ts +49 -0
- package/src/engine/codex-cli.ts +1014 -0
- package/src/engine/codex-dynamic-tools.ts +239 -0
- package/src/engine/codex-home.ts +63 -0
- package/src/engine/codex-thread-config.ts +74 -0
- package/src/engine/context-budget.ts +257 -0
- package/src/engine/engine-meta-labels.ts +211 -0
- package/src/engine/grok-cli.ts +941 -0
- package/src/engine/inline-think.ts +59 -0
- package/src/engine/model-availability.ts +105 -0
- package/src/engine/openai-compatible.ts +2464 -0
- package/src/engine/reasoning-retry.ts +83 -0
- package/src/engine/registry.ts +13 -0
- package/src/engine/replay.ts +195 -0
- package/src/engine/sampling.ts +90 -0
- package/src/engine/thinking-params.ts +264 -0
- package/src/engine/types.ts +269 -0
- package/src/engine/user-tag.ts +24 -0
- package/src/imagegen/aspect.ts +128 -0
- package/src/imagegen/generate.ts +642 -0
- package/src/imagegen/references.ts +75 -0
- package/src/imagegen/types.ts +154 -0
- package/src/lsp/client.ts +183 -0
- package/src/lsp/fake-server.helper.mjs +42 -0
- package/src/lsp/format.ts +29 -0
- package/src/lsp/index.ts +21 -0
- package/src/lsp/manager.ts +238 -0
- package/src/lsp/registry.ts +151 -0
- package/src/mcp/config.ts +117 -0
- package/src/mcp/hub/audit.ts +55 -0
- package/src/mcp/hub/bridge.ts +115 -0
- package/src/mcp/hub/catalog.ts +69 -0
- package/src/mcp/hub/credentials.ts +406 -0
- package/src/mcp/hub/env-expand.ts +14 -0
- package/src/mcp/hub/manager.ts +770 -0
- package/src/mcp/hub/normalize.ts +213 -0
- package/src/mcp/server.ts +368 -0
- package/src/mcp/tool-schema.ts +20 -0
- package/src/media/capabilities.ts +392 -0
- package/src/media/records.ts +175 -0
- package/src/media/store.ts +217 -0
- package/src/media/types.ts +69 -0
- package/src/memory/chunking.ts +168 -0
- package/src/memory/embeddings.ts +262 -0
- package/src/memory/index.ts +15 -0
- package/src/memory/inject.ts +197 -0
- package/src/memory/manager.ts +996 -0
- package/src/memory/registry.ts +176 -0
- package/src/memory/rescan.ts +101 -0
- package/src/memory/retrieval.ts +586 -0
- package/src/memory/shared-index.ts +372 -0
- package/src/memory/slug.ts +39 -0
- package/src/memory/storage.ts +385 -0
- package/src/memory/watcher.ts +134 -0
- package/src/multimodal/blocks.ts +101 -0
- package/src/multimodal/dimensions.ts +214 -0
- package/src/multimodal/load.ts +86 -0
- package/src/multimodal/mime.ts +135 -0
- package/src/multimodal/pdf-render.ts +80 -0
- package/src/multimodal/user-content.ts +266 -0
- package/src/persona/files.ts +144 -0
- package/src/persona/loader.ts +598 -0
- package/src/persona/skill-gating-store.ts +59 -0
- package/src/persona/tool-gating-store.ts +113 -0
- package/src/projects/focus.ts +186 -0
- package/src/projects/prompt-block.ts +106 -0
- package/src/projects/scheme.ts +107 -0
- package/src/projects/store.ts +144 -0
- package/src/projects/types.ts +73 -0
- package/src/sentinel/dispatcher.ts +97 -0
- package/src/sentinel/schedule.ts +271 -0
- package/src/sentinel/scheduler.ts +840 -0
- package/src/sentinel/store.ts +259 -0
- package/src/sentinel/types.ts +221 -0
- package/src/server/activity-stream.ts +160 -0
- package/src/server/ask-calls.ts +137 -0
- package/src/server/ask-wait-graph.ts +171 -0
- package/src/server/async-tasks.ts +199 -0
- package/src/server/builder-busy.ts +86 -0
- package/src/server/builder-prompt.ts +204 -0
- package/src/server/builder-questions.ts +117 -0
- package/src/server/builder-session.ts +249 -0
- package/src/server/chat-aborts.ts +83 -0
- package/src/server/claude-config-dir.ts +71 -0
- package/src/server/claude-credential-sync.ts +454 -0
- package/src/server/env-file.ts +100 -0
- package/src/server/env.ts +115 -0
- package/src/server/heal-session.ts +151 -0
- package/src/server/history-page.ts +46 -0
- package/src/server/index.ts +7244 -0
- package/src/server/lockfile.ts +89 -0
- package/src/server/logger.ts +67 -0
- package/src/server/logs.ts +187 -0
- package/src/server/loopback-fetch.ts +130 -0
- package/src/server/openai-client.ts +89 -0
- package/src/server/prompt-assembly.ts +334 -0
- package/src/server/restart-reconcile.ts +139 -0
- package/src/server/run-turn-fallback.ts +275 -0
- package/src/server/run-turn-types.ts +91 -0
- package/src/server/run-turn.ts +1474 -0
- package/src/server/sanitize-assistant-text.ts +112 -0
- package/src/server/session-export.ts +220 -0
- package/src/server/session-queue.ts +376 -0
- package/src/server/session-workdir.ts +49 -0
- package/src/server/sse-h2-safe.ts +61 -0
- package/src/server/sse-liveness.ts +162 -0
- package/src/server/sse-serializer.ts +161 -0
- package/src/server/start-turn.ts +249 -0
- package/src/server/steer-inbox.ts +107 -0
- package/src/server/tls-keeper.ts +153 -0
- package/src/server/tool-format.ts +167 -0
- package/src/server/turn-framing.ts +52 -0
- package/src/server/turn-origin-kind.ts +74 -0
- package/src/server/turn-origin.ts +40 -0
- package/src/server/work-ledger.ts +975 -0
- package/src/server/workspace.ts +114 -0
- package/src/setup/config-edit.ts +201 -0
- package/src/setup/presets.ts +71 -0
- package/src/setup/prompt.ts +163 -0
- package/src/setup/tailscale.ts +44 -0
- package/src/skills/bin-checks.ts +227 -0
- package/src/skills/bootstrap.ts +347 -0
- package/src/skills/env-scope.ts +175 -0
- package/src/skills/gating.ts +71 -0
- package/src/skills/lint.ts +202 -0
- package/src/skills/load.ts +368 -0
- package/src/skills/path-helpers.ts +102 -0
- package/src/skills/registry.ts +178 -0
- package/src/ssh/exec.ts +142 -0
- package/src/ssh/index.ts +12 -0
- package/src/ssh/known-hosts.ts +109 -0
- package/src/ssh/pool.ts +307 -0
- package/src/storage/sessions.ts +602 -0
- package/src/team/render.ts +149 -0
- package/src/team/resolve.ts +122 -0
- package/src/team/store.ts +124 -0
- package/src/team/types.ts +111 -0
- package/src/team/write.ts +95 -0
- package/src/testing/isolated-home.mts +46 -0
- package/src/tmux/attention-watcher.ts +272 -0
- package/src/tmux/attention.ts +336 -0
- package/src/tmux/list.ts +91 -0
- package/src/tmux/origin-store.ts +102 -0
- package/src/tmux/tui-markers.ts +267 -0
- package/src/tools/agents/ask-cancel.ts +94 -0
- package/src/tools/agents/ask-result.ts +235 -0
- package/src/tools/agents/ask.ts +704 -0
- package/src/tools/agents/builder-dispatch.ts +217 -0
- package/src/tools/agents/images.ts +104 -0
- package/src/tools/agents/index.ts +42 -0
- package/src/tools/agents/long-task-timeouts.ts +39 -0
- package/src/tools/agents/session-list.ts +136 -0
- package/src/tools/agents/session-model.ts +106 -0
- package/src/tools/agents/spawn.ts +845 -0
- package/src/tools/agents/status.ts +589 -0
- package/src/tools/browser/index.ts +6 -0
- package/src/tools/browser/ops.ts +145 -0
- package/src/tools/browser/tools.ts +184 -0
- package/src/tools/builder/short-descriptions.ts +80 -0
- package/src/tools/builder/tools.ts +222 -0
- package/src/tools/docs/index.ts +1 -0
- package/src/tools/docs/tools.ts +228 -0
- package/src/tools/dream/index.ts +11 -0
- package/src/tools/dream/tools.ts +1002 -0
- package/src/tools/exec/allowlist.ts +233 -0
- package/src/tools/exec/background-detach.helper.mts +27 -0
- package/src/tools/exec/blacklist.ts +336 -0
- package/src/tools/exec/concurrency.ts +150 -0
- package/src/tools/exec/fit-output.ts +82 -0
- package/src/tools/exec/index.ts +7 -0
- package/src/tools/exec/internal-env.ts +89 -0
- package/src/tools/exec/job-store.ts +403 -0
- package/src/tools/exec/local.ts +649 -0
- package/src/tools/exec/remote.ts +399 -0
- package/src/tools/exec/tools.ts +934 -0
- package/src/tools/file/analyze.ts +378 -0
- package/src/tools/file/index.ts +2 -0
- package/src/tools/file/local.ts +707 -0
- package/src/tools/file/lsp-hook.ts +72 -0
- package/src/tools/file/persona-guard.ts +61 -0
- package/src/tools/file/policy.ts +292 -0
- package/src/tools/file/read-format.ts +129 -0
- package/src/tools/file/remote.ts +680 -0
- package/src/tools/file/replace.ts +507 -0
- package/src/tools/file/search-window.ts +224 -0
- package/src/tools/file/tools.ts +658 -0
- package/src/tools/file/write-scope.ts +182 -0
- package/src/tools/gating.ts +106 -0
- package/src/tools/image/budget.ts +82 -0
- package/src/tools/image/index.ts +7 -0
- package/src/tools/image/tools.ts +601 -0
- package/src/tools/index.ts +99 -0
- package/src/tools/memory/index.ts +12 -0
- package/src/tools/memory/tools.ts +399 -0
- package/src/tools/projects/index.ts +1 -0
- package/src/tools/projects/tools.ts +643 -0
- package/src/tools/registry.ts +427 -0
- package/src/tools/resources/index.ts +8 -0
- package/src/tools/resources/tools.ts +176 -0
- package/src/tools/resources/visibility.ts +60 -0
- package/src/tools/sentinel/index.ts +1 -0
- package/src/tools/sentinel/tools.ts +592 -0
- package/src/tools/skill/index.ts +4 -0
- package/src/tools/skill/tools.ts +285 -0
- package/src/tools/time/index.ts +5 -0
- package/src/tools/time/tools.ts +123 -0
- package/src/tools/tmux/index.ts +1 -0
- package/src/tools/tmux/local.ts +277 -0
- package/src/tools/tmux/remote.ts +168 -0
- package/src/tools/tmux/tools.ts +1064 -0
- package/src/tools/tool-output.ts +97 -0
- package/src/tools/types.ts +227 -0
- package/src/tools/video/index.ts +1 -0
- package/src/tools/video/tools.ts +425 -0
- package/src/tools/web/fetch.ts +337 -0
- package/src/tools/web/index.ts +4 -0
- package/src/tools/web/tools.ts +186 -0
- package/src/tools/wiki/index.ts +1 -0
- package/src/tools/wiki/tools.ts +445 -0
- package/src/tts/cache-gc.ts +128 -0
- package/src/tts/prepare-for-tts.ts +114 -0
- package/src/tts/service.ts +332 -0
- package/src/types/events.ts +695 -0
- package/src/types/turn-origin.ts +53 -0
- package/src/version.ts +21 -0
- package/src/videogen/dialects.ts +222 -0
- package/src/videogen/generate.ts +484 -0
- package/src/videogen/jobs.ts +178 -0
- package/src/videogen/runner.ts +125 -0
- package/src/videogen/wake.ts +119 -0
- package/src/voice/realtime/call.ts +948 -0
- package/src/voice/realtime/consult.ts +293 -0
- package/src/voice/realtime/fake-provider.ts +134 -0
- package/src/voice/realtime/manager.ts +384 -0
- package/src/voice/realtime/openai-provider.ts +471 -0
- package/src/voice/realtime/persona.ts +227 -0
- package/src/voice/realtime/session-match.ts +116 -0
- package/src/voice/realtime/types.ts +182 -0
- package/src/wiki/conflict.ts +113 -0
- package/src/wiki/explorer.ts +578 -0
- package/src/wiki/index-builder.ts +172 -0
- package/src/wiki/language.ts +134 -0
- package/src/wiki/log-builder.ts +150 -0
- package/src/wiki/map.ts +258 -0
- package/src/wiki/migration/analyze.ts +304 -0
- package/src/wiki/migration/execute.ts +689 -0
- package/src/wiki/migration/refine.ts +402 -0
- package/src/wiki/migration/store.ts +100 -0
- package/src/wiki/move-page.ts +57 -0
- package/src/wiki/structure-file.ts +192 -0
- package/src/wiki/taxonomy.ts +140 -0
- package/src/wiki/templates.ts +163 -0
- package/src/wiki/types.ts +133 -0
- package/templates/skills/README.md +24 -0
- package/templates/skills/_templates/api-wrapper/SKILL.md +26 -0
- package/templates/skills/_templates/cli-wrapper/BOOTSTRAP.md +32 -0
- package/templates/skills/_templates/cli-wrapper/SKILL.md +24 -0
- package/templates/skills/_templates/default/SKILL.md +25 -0
- package/templates/skills/builder-handover/SKILL.md +96 -0
- package/templates/skills/builder-handover/assets/ORDER.md +12 -0
- package/templates/skills/skill-author/SKILL.md +110 -0
- package/tsconfig.json +22 -0
- package/web/dist/assets/index-BaVv6pB2.js +631 -0
- package/web/dist/assets/index-BaVv6pB2.js.map +1 -0
- package/web/dist/assets/index-V3FV3Z25.css +32 -0
- package/web/dist/favicon.svg +8 -0
- package/web/dist/index.html +20 -0
- package/web/package.json +36 -0
- package/web/tsconfig.json +25 -0
- package/web-mobile/dist/apple-touch-icon.png +0 -0
- package/web-mobile/dist/assets/index-BqKt7IMx.css +1 -0
- package/web-mobile/dist/assets/index-X_vRr6cd.js +88 -0
- package/web-mobile/dist/assets/index-X_vRr6cd.js.map +1 -0
- package/web-mobile/dist/favicon.svg +8 -0
- package/web-mobile/dist/icon-192.png +0 -0
- package/web-mobile/dist/icon-512.png +0 -0
- package/web-mobile/dist/index.html +27 -0
- package/web-mobile/dist/manifest.webmanifest +32 -0
- package/web-mobile/dist/service-worker.js +90 -0
- package/web-mobile/package.json +28 -0
- package/web-mobile/tsconfig.json +25 -0
package/docs/api.md
ADDED
|
@@ -0,0 +1,3194 @@
|
|
|
1
|
+
# somora HTTP API reference
|
|
2
|
+
|
|
3
|
+
> All clients — TUI, web app, and any third-party tool — talk to the
|
|
4
|
+
> same HTTP+SSE+WebSocket surface. This document is the reference for
|
|
5
|
+
> that surface, so you can build your own client: a Telegram bridge,
|
|
6
|
+
> a status dashboard, a Voice frontend, a Stream-Deck integration,
|
|
7
|
+
> whatever you want to plug into your agents.
|
|
8
|
+
|
|
9
|
+
The server is a Hono app served by `@hono/node-server` over HTTP/2
|
|
10
|
+
(see [setup.md](setup.md) for TLS via Tailscale). The base URL in a
|
|
11
|
+
typical install is `https://<host>.<tailnet>.ts.net:18737`. The TUI
|
|
12
|
+
and web both live at this same origin (TUI is the binary that ships
|
|
13
|
+
with somora; web is mounted under `/web`).
|
|
14
|
+
|
|
15
|
+
## Authentication & deployment model
|
|
16
|
+
|
|
17
|
+
**There is no API key, no OAuth, no per-route auth.** somora's
|
|
18
|
+
security model is *LAN-trust*: the server binds to the loopback or
|
|
19
|
+
the Tailnet, and anyone who can reach the address is authorised.
|
|
20
|
+
|
|
21
|
+
This is a deliberate choice that follows from somora's positioning:
|
|
22
|
+
|
|
23
|
+
- **Local-first.** somora lives on your machine (or a server in your
|
|
24
|
+
Tailnet). It holds your memory, talks to your accounts. There is
|
|
25
|
+
no multi-tenancy concept.
|
|
26
|
+
- **Tailscale is the ACL.** Tailnet ACLs decide who can reach the
|
|
27
|
+
port; somora itself trusts whoever's already at the door.
|
|
28
|
+
- **Anything an agent can do, you can do.** The API surfaces the
|
|
29
|
+
same capabilities the agent has — memory writes, model switches,
|
|
30
|
+
dream triggers. If the model is allowed to do it, so is your
|
|
31
|
+
client.
|
|
32
|
+
|
|
33
|
+
**Do not expose the somora port to the public internet.** No auth
|
|
34
|
+
guard means anyone who finds the URL gets full agent control,
|
|
35
|
+
including the ability to read all memory + sessions + vault. Keep
|
|
36
|
+
it on Tailscale or on `127.0.0.1` and tunnel.
|
|
37
|
+
|
|
38
|
+
## Conventions
|
|
39
|
+
|
|
40
|
+
- **Encoding.** Request and response bodies are JSON (`Content-Type:
|
|
41
|
+
application/json`) unless otherwise noted. Attachments are
|
|
42
|
+
`multipart/form-data`.
|
|
43
|
+
- **Errors.** A non-2xx response carries `{ "error": "<message>" }`
|
|
44
|
+
in the body. Messages are human-readable strings and may be in
|
|
45
|
+
German (somora speaks both — error text follows the locale of the
|
|
46
|
+
originating component).
|
|
47
|
+
- **IDs.** Session IDs are `<YYYYMMDD>-<HHMMSS>_<slug>`. The literal
|
|
48
|
+
string `main` is the always-on default session per agent and is
|
|
49
|
+
always addressable. A route that takes `<slug|id>` resolves in this
|
|
50
|
+
order: `main`, an exact id, a session stored under exactly that name,
|
|
51
|
+
then the newest session with that slug. The third rule matters for
|
|
52
|
+
sessions written before the id format was enforced: whatever the
|
|
53
|
+
session list shows can be addressed under the name it was shown with.
|
|
54
|
+
An unknown reference is refused rather than resolved to a neighbour.
|
|
55
|
+
- **Polling cadence.** Endpoints that surface live state are cheap
|
|
56
|
+
by design — poll every 2 s for the dream loop, 30 s for dream
|
|
57
|
+
phases, 60 s for sessions. The server caches expensive lookups
|
|
58
|
+
(e.g. session sizes) so polling doesn't burn cycles.
|
|
59
|
+
- **SSE.** Streaming endpoints use Server-Sent Events with named
|
|
60
|
+
events (`chat`, `tool`, `memory_inject`, `status`, `heartbeat`).
|
|
61
|
+
See [SSE event vocabulary](web.md#sse-event-vocabulary).
|
|
62
|
+
|
|
63
|
+
## Versioning & stability
|
|
64
|
+
|
|
65
|
+
- The version returned by `GET /version` is a calendar version like
|
|
66
|
+
`2026.05.12.3`. somora doesn't follow semver; minor bumps within
|
|
67
|
+
the same day are common during active work.
|
|
68
|
+
- Most endpoints listed here are stable — the TUI and web both use
|
|
69
|
+
them, and breaking them would break the shipped clients.
|
|
70
|
+
- Endpoints marked **⚠ experimental** may change shape in any bump.
|
|
71
|
+
They are surfaced because the TUI/web already need them; lock
|
|
72
|
+
yourself to a specific somora version if your client depends on
|
|
73
|
+
them.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Core
|
|
78
|
+
|
|
79
|
+
### `GET /version`
|
|
80
|
+
|
|
81
|
+
Returns the running somora version.
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
curl https://<host>:18737/version
|
|
85
|
+
# { "version": "2026.05.12.3" }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### `GET /healthz`
|
|
89
|
+
|
|
90
|
+
Liveness probe. Returns the plain-text `ok` with status 200. Use it
|
|
91
|
+
to wait for server start, smoke-test load balancers, etc.
|
|
92
|
+
|
|
93
|
+
### `GET /health`
|
|
94
|
+
|
|
95
|
+
Diagnostic snapshot. Use this when something looks stuck — e.g. an
|
|
96
|
+
agent's session has stopped responding but the server is still
|
|
97
|
+
accepting HTTP. The response shows which `(agent, session)` is busy,
|
|
98
|
+
since when, what its current turn id is, queue depth behind it, and
|
|
99
|
+
how long ago the last engine event reached SSE subscribers. Read-only,
|
|
100
|
+
cheap (in-memory only).
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
curl https://<host>:18737/health
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"ok": true,
|
|
111
|
+
"serverPid": 12345,
|
|
112
|
+
"serverBootedAt": 1778756948428,
|
|
113
|
+
"serverUptimeMs": 5142,
|
|
114
|
+
"lockfilePid": 12345,
|
|
115
|
+
"lockfileStartedAt": "2026-05-14T11:09:08.429Z",
|
|
116
|
+
"activeSessions": 1,
|
|
117
|
+
"totalKnownSessions": 3,
|
|
118
|
+
"claudeAuth": {
|
|
119
|
+
"enabled": true,
|
|
120
|
+
"userExists": true,
|
|
121
|
+
"somoraExists": true,
|
|
122
|
+
"identical": true,
|
|
123
|
+
"userExpiresAt": 1785503549000,
|
|
124
|
+
"somoraExpiresAt": 1785503549000,
|
|
125
|
+
"lastSyncResult": "noop",
|
|
126
|
+
"lastSyncAt": 1785496349000
|
|
127
|
+
},
|
|
128
|
+
"memoryEmbedder": {
|
|
129
|
+
"state": "ok",
|
|
130
|
+
"provider": "local",
|
|
131
|
+
"model": "all-MiniLM-L6-v2",
|
|
132
|
+
"dim": 384,
|
|
133
|
+
"error": null,
|
|
134
|
+
"since": 1785496350120,
|
|
135
|
+
"attempts": 1,
|
|
136
|
+
"loadMs": 2373
|
|
137
|
+
},
|
|
138
|
+
"sharedIndex": {
|
|
139
|
+
"state": "ready",
|
|
140
|
+
"role": "owner",
|
|
141
|
+
"path": "/home/me/.somora/index/shared.db",
|
|
142
|
+
"files": 626,
|
|
143
|
+
"chunks": 1466,
|
|
144
|
+
"built_by": "seed:<agent>"
|
|
145
|
+
},
|
|
146
|
+
"sessions": [
|
|
147
|
+
{
|
|
148
|
+
"agent": "<your-agent>",
|
|
149
|
+
"session": "main",
|
|
150
|
+
"busy": true,
|
|
151
|
+
"activePriority": "user",
|
|
152
|
+
"activeSince": 1778757036447,
|
|
153
|
+
"activeAgeMs": 1024,
|
|
154
|
+
"activeCallId": null,
|
|
155
|
+
"activeTurnId": "b5b7a734-...",
|
|
156
|
+
"queueLength": 1,
|
|
157
|
+
"userWaiting": 0,
|
|
158
|
+
"agentWaiting": 1,
|
|
159
|
+
"queued": [
|
|
160
|
+
{ "id": "3f0c2b1e-…", "kind": "agent",
|
|
161
|
+
"preview": "Can you check whether the build log mentions …",
|
|
162
|
+
"enqueuedAt": 1778757040112, "position": 1 }
|
|
163
|
+
],
|
|
164
|
+
"lastEngineEventAt": 1778757036900,
|
|
165
|
+
"lastEngineEventAgoMs": 571,
|
|
166
|
+
"subscriberCount": 2,
|
|
167
|
+
"lastPublishOkAt": 1778757036900,
|
|
168
|
+
"lastPublishOkAgoMs": 571
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
`activeAgeMs` is how long the current turn has been holding the
|
|
175
|
+
per-session lock. `activeTurnId` is set for every running turn,
|
|
176
|
+
whatever started it — a typed message, an `agent_ask`, a sub-agent
|
|
177
|
+
brief, a sentinel fire, a tmux or browser wake, a voice consult or a
|
|
178
|
+
wake-up — so a session that looks stuck can always be matched to a
|
|
179
|
+
turn and stopped with `POST /chat/abort`. `queued` names the waiters
|
|
180
|
+
behind it in lock order: the entry's id (the `turnId` of a typed
|
|
181
|
+
message, the `call_id` of an `agent_ask`, the `task_id` of a sub-agent
|
|
182
|
+
brief or a sentinel fire), its origin `kind`, the first 160 characters
|
|
183
|
+
of its text and its `position` (1 = next). Any of these ids can go to
|
|
184
|
+
`DELETE /chat/queue/:id`; the per-session view
|
|
185
|
+
`GET /agents/:agent/sessions/:session/work` adds what is arriving and
|
|
186
|
+
what the session started elsewhere. `lastEngineEventAgoMs` ticks up while the engine is
|
|
187
|
+
silent — if it climbs past a few minutes on a chat turn (vs. a long
|
|
188
|
+
local-LLM job), the turn is wedged and the engine watchdog will abort
|
|
189
|
+
it. See [setup.md](setup.md#tunables) `engineWatchdog` to tune
|
|
190
|
+
thresholds per engine.
|
|
191
|
+
|
|
192
|
+
`claudeAuth` reports the shared-login credential sync between
|
|
193
|
+
`~/.claude` and somora's isolated claude-home (paths and mtimes
|
|
194
|
+
elided above; never token material). `identical: false` with both
|
|
195
|
+
sides present means the stores have diverged and the watcher hasn't
|
|
196
|
+
caught up yet — if it persists, claude-cli auth is about to break;
|
|
197
|
+
run `somora auth status` on the host. See
|
|
198
|
+
[setup.md](setup.md#isolated-claude-config-dir).
|
|
199
|
+
|
|
200
|
+
`sharedIndex` is the vault/wiki retrieval index shared by all agents
|
|
201
|
+
([memory.md](memory.md#mental-model--memory-inbox)). `state` is
|
|
202
|
+
`ready` when agents read vault/wiki from it, `building` while the
|
|
203
|
+
first build after an update is still running (agents then still answer
|
|
204
|
+
from their own DB), `disabled` when no vault is configured, `failed`
|
|
205
|
+
with `error` when the DB could not be opened or built. `built_by`
|
|
206
|
+
says where the content came from: `seed:<agent>` (copied out of that
|
|
207
|
+
agent's DB on the first boot after the update) or `sweep` (embedded
|
|
208
|
+
from disk). `null` until the server has opened it.
|
|
209
|
+
|
|
210
|
+
`memoryEmbedder` is the health of the embedding model behind memory
|
|
211
|
+
retrieval (see [memory.md](memory.md#hybrid-retrieval-mechanics)). The
|
|
212
|
+
server loads it once at boot; `state` is `ok` when the model is loaded,
|
|
213
|
+
`loading` while the (first-run) download is in flight, and `failed` when
|
|
214
|
+
the last attempt threw — `error` then carries the reason. `failed` means
|
|
215
|
+
every agent's memory search is BM25-only until the next retry succeeds
|
|
216
|
+
(one retry per agent per minute, on search): the server keeps working,
|
|
217
|
+
but semantic recall and dream dedup are silently degraded, so treat a
|
|
218
|
+
persistent `failed` as an incident. The model cache lives under
|
|
219
|
+
`~/.somora/models/transformers/` and survives updates.
|
|
220
|
+
|
|
221
|
+
`subscriberCount` is the number of currently-connected SSE clients
|
|
222
|
+
(web / mobile / TUI tail) watching this session. `lastPublishOkAt` only
|
|
223
|
+
advances when a broadcast reached at least one subscriber within the
|
|
224
|
+
`sse.publishTimeoutMs` budget; if `subscriberCount > 0` but
|
|
225
|
+
`lastPublishOkAgoMs` grows without bound, at least one client is wedged
|
|
226
|
+
— the next publish auto-evicts it (see `sse.publishTimeoutMs` in
|
|
227
|
+
[setup.md](setup.md#tunables)).
|
|
228
|
+
|
|
229
|
+
### `GET /host-stats`
|
|
230
|
+
|
|
231
|
+
Host machine resource snapshot — CPU load and memory usage of the box
|
|
232
|
+
somora is running on. Surfaced to the web taskbar's `cpu` / `mem`
|
|
233
|
+
widgets and handy when somora lives on a VM you don't otherwise have a
|
|
234
|
+
metrics view for.
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
curl https://<host>:18737/host-stats
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Returns:
|
|
241
|
+
|
|
242
|
+
```json
|
|
243
|
+
{
|
|
244
|
+
"cpu": {
|
|
245
|
+
"loadAvg1": 0.42,
|
|
246
|
+
"cores": 6,
|
|
247
|
+
"percent": 7.0
|
|
248
|
+
},
|
|
249
|
+
"mem": {
|
|
250
|
+
"totalBytes": 25186074624,
|
|
251
|
+
"availableBytes": 23197777920,
|
|
252
|
+
"usedBytes": 1988296704,
|
|
253
|
+
"percent": 7.9
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
`cpu.percent` is the 1-minute load average divided by core count and
|
|
259
|
+
expressed as a percentage. Values over 100 mean the box has more
|
|
260
|
+
runnable processes than CPUs — not capped, an overload signal is more
|
|
261
|
+
useful than a clamped number.
|
|
262
|
+
|
|
263
|
+
`mem.availableBytes` is "memory the kernel can hand back without I/O".
|
|
264
|
+
The reading is platform-specific so it matches what the OS-native
|
|
265
|
+
tools report:
|
|
266
|
+
|
|
267
|
+
- **Linux:** `/proc/meminfo:MemAvailable` (includes reclaimable page
|
|
268
|
+
cache). Falls back to `os.freemem()` on kernels that don't expose
|
|
269
|
+
it.
|
|
270
|
+
- **macOS:** `vm_stat` pages free + inactive + speculative, times
|
|
271
|
+
page size. Mirrors Activity Monitor's "Available" notion. Falls
|
|
272
|
+
back to `os.freemem()` if the `vm_stat` binary is unavailable.
|
|
273
|
+
- **Other:** `os.freemem()` straight (degraded but non-erroring).
|
|
274
|
+
|
|
275
|
+
`usedBytes` = `totalBytes − availableBytes`. Read-only, cheap (no disk
|
|
276
|
+
I/O on Linux, a sub-millisecond `vm_stat` spawn on macOS).
|
|
277
|
+
|
|
278
|
+
### `GET /tui-config` · `GET /mobile-config`
|
|
279
|
+
|
|
280
|
+
Display preferences for thin clients, read from config.yaml by the
|
|
281
|
+
server so no client parses the file itself. `/tui-config` returns
|
|
282
|
+
`{show: {memory, tools}, verbose: {tools, memory, system, thinking}}`
|
|
283
|
+
(the `tui:` block, see [display.md](display.md)); `/mobile-config`
|
|
284
|
+
returns `{show: {tools, memory}}` (the `mobile:` block). A custom
|
|
285
|
+
client is free to use either as its own defaults.
|
|
286
|
+
|
|
287
|
+
### `GET /env`
|
|
288
|
+
|
|
289
|
+
The environment overrides the running server resolved at boot, one
|
|
290
|
+
entry per variable: `{SOMORA_HOME, SOMORA_PORT, SOMORA_LOG_LEVEL,
|
|
291
|
+
SOMORA_CLAUDE_BIN, SOMORA_CODEX_BIN, SOMORA_CODEX_TOOL_TIMEOUT_SEC,
|
|
292
|
+
SOMORA_COMPACTION_TRIGGER_RATIO, SOMORA_COMPACTION_SAFETY_PAIRS,
|
|
293
|
+
SOMORA_COMPACTION_MODEL, SOMORA_COMPACTION_WORKERS}`, each `{value, isDefault, note?}` — `value`
|
|
294
|
+
is what is in force, `isDefault` says the variable was unset or
|
|
295
|
+
invalid, `note` explains a fallback (e.g. "unset → uses config.yaml
|
|
296
|
+
server.port"). Diagnostic; see [setup.md](setup.md).
|
|
297
|
+
|
|
298
|
+
### `GET /tools`
|
|
299
|
+
|
|
300
|
+
List every tool registered on the server (the same tools agents see).
|
|
301
|
+
Useful for clients that want to surface a tool catalog.
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
curl https://<host>:18737/tools
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Returns `{ count, tools: [{ name, toolset, description, inputSchema,
|
|
308
|
+
maxResultSizeChars, hasAvailabilityCheck }] }` — `inputSchema` is the
|
|
309
|
+
tool's JSON Schema, `maxResultSizeChars` is `null` when the tool uses
|
|
310
|
+
the default cap, `hasAvailabilityCheck` says the tool has a runtime
|
|
311
|
+
probe and may be hidden from some agents.
|
|
312
|
+
|
|
313
|
+
### `GET /agents/:agent/skills` · `PUT /agents/:agent/skills`
|
|
314
|
+
|
|
315
|
+
Per-agent skill visibility — the skills half of the web client's
|
|
316
|
+
Abilities matrix (the tools half is `GET/PUT /agents/:agent/tools`,
|
|
317
|
+
documented in [mcp.md](mcp.md)).
|
|
318
|
+
|
|
319
|
+
`GET` returns `{ agent, gating, hasPatternRules, skills: [{ name,
|
|
320
|
+
description, available, unavailableReason?, visible }] }` — every skill
|
|
321
|
+
installed on the instance, with `visible` telling whether this agent
|
|
322
|
+
sees it. `gating` is the agent's `skills:` section (`{deny, allow}`)
|
|
323
|
+
or `null`; `hasPatternRules` is true when it carries a hand-written
|
|
324
|
+
allow-list, which the UI shows read-only.
|
|
325
|
+
|
|
326
|
+
`PUT` takes `{ deny: string[], allow: string[] }` and rewrites only the
|
|
327
|
+
`skills:` block of the agent's `agent.yaml` (comments and the rest of
|
|
328
|
+
the file untouched; empty deny+allow removes the block). Names must
|
|
329
|
+
be skill names (`[a-z0-9-]`). Takes effect on the agent's next turn.
|
|
330
|
+
See [skills.md](skills.md#per-agent-visibility).
|
|
331
|
+
|
|
332
|
+
### `GET /agents/:agent/tools` · `PUT /agents/:agent/tools`
|
|
333
|
+
|
|
334
|
+
The tools half of the Abilities matrix (see [mcp.md](mcp.md)).
|
|
335
|
+
|
|
336
|
+
`GET` returns `{ agent, gating, hasPatternRules, tools: [{ name,
|
|
337
|
+
toolset, mcpServer?, description, visible, availableNow }] }` — every
|
|
338
|
+
tool configured on the instance, built-in and imported from external
|
|
339
|
+
MCP servers (`mcpServer` names the origin), with `visible` telling
|
|
340
|
+
whether this agent's gating lets it through. `gating` is the agent's
|
|
341
|
+
`tools:` section (`{deny, allow}`) or `null`; `hasPatternRules` is
|
|
342
|
+
true when it carries an allow-list or a `toolset:`/glob deny rule,
|
|
343
|
+
which the UI shows read-only.
|
|
344
|
+
|
|
345
|
+
`PUT` takes `{ deny: string[], allow: string[] }` and rewrites only the
|
|
346
|
+
`tools:` block of the agent's `agent.yaml`; `400` when the body has
|
|
347
|
+
the wrong shape or the write fails. Returns `{ok: true}`; takes effect
|
|
348
|
+
on the agent's next turn.
|
|
349
|
+
|
|
350
|
+
### `POST /agents/:agent/tools/:name`
|
|
351
|
+
|
|
352
|
+
Invoke a tool directly as an agent (without going through a chat
|
|
353
|
+
turn). The body is the tool's input shape; the response is the tool's
|
|
354
|
+
output. Same authorisation as everything else (LAN-trust).
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
curl -X POST https://<host>:18737/agents/<your-agent>/tools/memory_search \
|
|
358
|
+
-H 'Content-Type: application/json' \
|
|
359
|
+
-d '{"query":"voice satellites","limit":3}'
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Images
|
|
365
|
+
|
|
366
|
+
Present only when `imageGen.enabled` is set and at least one model is
|
|
367
|
+
configured; every route below answers `503` otherwise. See
|
|
368
|
+
[imagegen.md](imagegen.md) for configuration.
|
|
369
|
+
|
|
370
|
+
### `GET /images/status`
|
|
371
|
+
|
|
372
|
+
`{enabled, outputDir, maxImagesPerTurn, models: [{name, label, model, provider, defaults}]}`,
|
|
373
|
+
or `{enabled: false}`. Clients use this to decide whether to show an
|
|
374
|
+
image-generation surface at all.
|
|
375
|
+
|
|
376
|
+
### `GET /images`
|
|
377
|
+
|
|
378
|
+
Gallery listing, newest first. Query: `query` (prompt substring, case-
|
|
379
|
+
insensitive), `model`, `agent`, `since`/`until` (`YYYY-MM-DD`), `limit`
|
|
380
|
+
(default 60, max 200), `offset`.
|
|
381
|
+
|
|
382
|
+
Returns `{total, offset, items: [ImageRecord], totalBytes}`. `total`
|
|
383
|
+
is the unpaged count.
|
|
384
|
+
|
|
385
|
+
### `GET /images/:id`
|
|
386
|
+
|
|
387
|
+
One `ImageRecord`: prompt, model, specs, path, mime, bytes, cost,
|
|
388
|
+
agent, session. A record may carry a `linkedTo` field; nothing writes
|
|
389
|
+
it, and the clients show the one canonical path.
|
|
390
|
+
|
|
391
|
+
### `GET /images/:id/file`
|
|
392
|
+
|
|
393
|
+
The image bytes, with the record's MIME. `410` when the record exists
|
|
394
|
+
but the file was moved or deleted outside somora.
|
|
395
|
+
|
|
396
|
+
Files are addressed **by record id, never by path** — the client cannot
|
|
397
|
+
name a file, so a user-chosen images directory does not turn this into
|
|
398
|
+
a way to read arbitrary files.
|
|
399
|
+
|
|
400
|
+
### `GET /images/models/:name/capabilities`
|
|
401
|
+
|
|
402
|
+
`{model, source: 'catalog'|'config'|'unknown', known, values, maxN, maxReferences, sizeAlsoAccepts, defaults}`. `sizeAlsoAccepts` lists named ratios the endpoint takes in `size` (`null` when it publishes none) — see the aspect-ratio note in [imagegen.md](imagegen.md).
|
|
403
|
+
|
|
404
|
+
`values` maps a spec field to its allowed values. **A field absent from
|
|
405
|
+
`values` has no known constraint** — clients should offer free input
|
|
406
|
+
there rather than an empty dropdown.
|
|
407
|
+
|
|
408
|
+
### `GET /images/catalog`
|
|
409
|
+
|
|
410
|
+
`{provider, models: [{id, name?}]}` — what the provider currently
|
|
411
|
+
offers. `?provider=<name>` selects the provider; defaults to the one
|
|
412
|
+
behind the first configured model. Read-only discovery aid; config
|
|
413
|
+
still decides what somora will call.
|
|
414
|
+
|
|
415
|
+
### `POST /images/generate`
|
|
416
|
+
|
|
417
|
+
Body: `prompt` (required), optional `model` (a configured handle) and
|
|
418
|
+
any specs — `resolution`, `aspect_ratio`, `size`, `quality`,
|
|
419
|
+
`output_format`, `background`, `output_compression`, `seed`, `n` — plus
|
|
420
|
+
optional `reference_images`. A `save_to` field is accepted for
|
|
421
|
+
compatibility and ignored: every image lives in one place, the
|
|
422
|
+
configured images directory, and the response carries its path.
|
|
423
|
+
|
|
424
|
+
`reference_images` is **base64 on this route** — a browser has the bytes
|
|
425
|
+
of a file the user picked and no server-side path for it. The
|
|
426
|
+
`image_generate` tool takes file paths instead, for the mirror-image
|
|
427
|
+
reason: an agent works on the same machine, and base64 in a tool
|
|
428
|
+
argument would mean loading a file into its context just to send it
|
|
429
|
+
straight back out.
|
|
430
|
+
|
|
431
|
+
Returns `{images: [ImageRecord], costUsd, warnings?, fellBackFrom?}`.
|
|
432
|
+
`warnings` carries anything the endpoint did differently than asked — a
|
|
433
|
+
size or aspect ratio it substituted (detected by measuring the returned
|
|
434
|
+
image, not by trusting the endpoint to report it), an `aspect_ratio`
|
|
435
|
+
that had to be sent as the closest `size` on the OpenAI wire (see
|
|
436
|
+
[imagegen.md](imagegen.md)), plus any `ignored_params` or `warnings`
|
|
437
|
+
the provider itself sent.
|
|
438
|
+
`fellBackFrom` is present only when a `fallback:` chain had to be
|
|
439
|
+
walked, and names the models that were unavailable.
|
|
440
|
+
|
|
441
|
+
`503` when the model is configured but not loaded right now (an image
|
|
442
|
+
backend commonly shares a GPU box that runs one profile at a time and
|
|
443
|
+
says so) — distinct from `502`, which means the endpoint misbehaved.
|
|
444
|
+
|
|
445
|
+
`400` for anything the caller can fix, with a message naming the field
|
|
446
|
+
and the values that would have worked. `502` when the upstream itself
|
|
447
|
+
failed.
|
|
448
|
+
|
|
449
|
+
### `DELETE /images/:id`
|
|
450
|
+
|
|
451
|
+
Forgets the record. **The file on disk is kept** — returns
|
|
452
|
+
`{ok, path, fileKept: true}`.
|
|
453
|
+
|
|
454
|
+
## Media
|
|
455
|
+
|
|
456
|
+
One gallery over everything somora generated — images and videos.
|
|
457
|
+
The `/images/*` routes above are the image-only view; these are the
|
|
458
|
+
medium-agnostic ones the web Media window and the mobile PWA use.
|
|
459
|
+
|
|
460
|
+
### `GET /media`
|
|
461
|
+
|
|
462
|
+
Query: `kind` (`image` | `video`; omit for both), `agent`, `query`
|
|
463
|
+
(prompt substring), `limit` (default 60, max 200), `offset`.
|
|
464
|
+
|
|
465
|
+
Returns `{total, offset, items: [MediaRecord], totalBytes}`. A
|
|
466
|
+
`MediaRecord` is `{id, kind, createdAt, prompt, modelName, modelId,
|
|
467
|
+
provider, specs, path, filename, mime, bytes, width?, height?,
|
|
468
|
+
durationSec?, thumbPath?, thumbMime?, linkedTo, costUsd?, agent?,
|
|
469
|
+
session?, references?, batchId, batchIndex}` — `kind` is absent on
|
|
470
|
+
records written before video existed and then means `image`;
|
|
471
|
+
`durationSec` and the thumbnail fields are video-only.
|
|
472
|
+
|
|
473
|
+
### `GET /media/:id`
|
|
474
|
+
|
|
475
|
+
One `MediaRecord`, `404` when unknown.
|
|
476
|
+
|
|
477
|
+
### `GET /media/:id/file`
|
|
478
|
+
|
|
479
|
+
The bytes with the record's MIME, `Content-Disposition: inline`
|
|
480
|
+
(`?download=1` forces `attachment`), immutable cache headers, and
|
|
481
|
+
**HTTP Range support** (`206` / `416`) so a video player can seek
|
|
482
|
+
without re-downloading. `410` when the record exists but the file
|
|
483
|
+
left the disk.
|
|
484
|
+
|
|
485
|
+
### `GET /media/:id/thumb`
|
|
486
|
+
|
|
487
|
+
A video's still image (`image/webp` unless the record says otherwise),
|
|
488
|
+
same headers as `/file`. `404` when the provider served no thumbnail.
|
|
489
|
+
|
|
490
|
+
### `DELETE /media/:id`
|
|
491
|
+
|
|
492
|
+
Removes the record. Returns `{ok: true}` or `404`.
|
|
493
|
+
|
|
494
|
+
## Video
|
|
495
|
+
|
|
496
|
+
Video generation runs as **jobs**: `POST` starts one and returns at
|
|
497
|
+
once, the render continues in the main server, the finished file
|
|
498
|
+
becomes a `MediaRecord`, and an agent that started the job is woken
|
|
499
|
+
with a `from_system: 'job'` turn. Enabled by `videoGen.enabled` in
|
|
500
|
+
config.yaml; see [videogen.md](videogen.md).
|
|
501
|
+
|
|
502
|
+
### `GET /video/status`
|
|
503
|
+
|
|
504
|
+
`{enabled: false, reason}` when video is off or no model is
|
|
505
|
+
configured. Otherwise `{enabled: true, active, limit, models:
|
|
506
|
+
[{name, label, model, provider, wire}], jobs: [VideoJob]}` — `active`
|
|
507
|
+
and `limit` are the concurrent-job slot (`videoGen.maxConcurrent`,
|
|
508
|
+
default 4). `?agent=<name>` limits `jobs` to that agent's. A `VideoJob`
|
|
509
|
+
is `{id, providerJobId, modelName, provider, prompt, specs, status,
|
|
510
|
+
progress?, queuePosition?, error?, createdAt, updatedAt, mediaId?,
|
|
511
|
+
path?, agent?, session?, references?}` with `status` one of `queued`,
|
|
512
|
+
`in_progress`, `completed`, `failed`; `mediaId` appears once the file
|
|
513
|
+
is stored and is what `/media/:id` takes.
|
|
514
|
+
|
|
515
|
+
### `POST /video/generate`
|
|
516
|
+
|
|
517
|
+
Body: `prompt` (required), optional `model` (a configured handle),
|
|
518
|
+
the specs `seconds`, `size`, `aspect_ratio`, `audio`, `quality`,
|
|
519
|
+
`seed`, optional `reference_images` (**base64**, as on
|
|
520
|
+
`/images/generate`), and optional `agent` + `session` naming who
|
|
521
|
+
should be woken when the job finishes.
|
|
522
|
+
|
|
523
|
+
Returns `{job: VideoJob}` immediately. `400` for a bad request, `429`
|
|
524
|
+
when all job slots are busy, `503` when the model is configured but
|
|
525
|
+
not available right now, `502` when the provider failed. Poll
|
|
526
|
+
`GET /video/status` or watch the session for the completion turn.
|
|
527
|
+
|
|
528
|
+
## Files
|
|
529
|
+
|
|
530
|
+
### `GET /files/view`
|
|
531
|
+
|
|
532
|
+
Read a server-local file by absolute path. Used by the web client's
|
|
533
|
+
FileView window so users can click absolute-path links emitted in
|
|
534
|
+
agent messages (e.g. `[report.md](/home/user/somoraworkspace/...)`)
|
|
535
|
+
and see the content in-app without SSH-ing into the server.
|
|
536
|
+
|
|
537
|
+
Policy is reused 1:1 from the `file_read` tool — the same allowlist
|
|
538
|
+
(workspace + somora-home roots) and the same blocklist (`~/.ssh`,
|
|
539
|
+
credential stores, system dirs, …). Symlink-resolution prevents path
|
|
540
|
+
escapes via realpath check on the closest existing ancestor.
|
|
541
|
+
|
|
542
|
+
Read-only, no writes. This route answers *what a file is*; the bytes of
|
|
543
|
+
anything it cannot inline come from `GET /files/raw`.
|
|
544
|
+
|
|
545
|
+
**Query parameters**
|
|
546
|
+
|
|
547
|
+
| Name | Required | Description |
|
|
548
|
+
|---|---|---|
|
|
549
|
+
| `path` | yes | Absolute filesystem path. `~`-prefix is expanded server-side. Relative paths are rejected (no agent-context cwd here). |
|
|
550
|
+
|
|
551
|
+
**File kinds.** A known text extension decides how the text is
|
|
552
|
+
highlighted; everything else is classified from the file's magic bytes,
|
|
553
|
+
because an extension is a claim and not evidence — a `.dat` holding PNG
|
|
554
|
+
bytes is reported as an image. Nothing is refused for being the wrong
|
|
555
|
+
type: an unrecognised file still comes back described, with a download
|
|
556
|
+
link, which beats an error for a file the user can see referenced in
|
|
557
|
+
chat.
|
|
558
|
+
|
|
559
|
+
| | `kind` | Response carries |
|
|
560
|
+
|---|---|---|
|
|
561
|
+
| `.md`, `.markdown` | `markdown` | `content`, full Markdown render |
|
|
562
|
+
| `.txt`, `.log`, other text | `text` | `content`, monospace |
|
|
563
|
+
| `.json`, `.jsonl`, `.yaml`, `.yml`, `.toml`, `.svg` | `code` | `content`, syntax highlighting |
|
|
564
|
+
| PNG / JPEG / GIF / WebP bytes | `image` | `url`, `mime` |
|
|
565
|
+
| MP4 / MOV / WebM bytes | `video` | `url`, `mime` |
|
|
566
|
+
| WAV / MP3 / OGG / FLAC / M4A bytes | `audio` | `url`, `mime` |
|
|
567
|
+
| PDF bytes | `pdf` | `url`, `mime` |
|
|
568
|
+
| anything else | `binary` | `mime` and a download link only |
|
|
569
|
+
|
|
570
|
+
`.svg` is listed as `code`, not as an image: it is markup that can carry
|
|
571
|
+
script, so it is shown as its own source rather than rendered.
|
|
572
|
+
|
|
573
|
+
Text responses are capped at 200 000 characters and set
|
|
574
|
+
`truncated: true` past that. Every response carries `downloadUrl`.
|
|
575
|
+
|
|
576
|
+
**Success response (200), text**
|
|
577
|
+
|
|
578
|
+
```json
|
|
579
|
+
{
|
|
580
|
+
"path": "/home/user/somoraworkspace/somora_feedback/example.md",
|
|
581
|
+
"kind": "markdown",
|
|
582
|
+
"ext": ".md",
|
|
583
|
+
"bytes": 4321,
|
|
584
|
+
"content": "# Report\n…",
|
|
585
|
+
"truncated": false,
|
|
586
|
+
"downloadUrl": "/files/raw?download=1&path=…"
|
|
587
|
+
}
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
**Success response (200), media**
|
|
591
|
+
|
|
592
|
+
```json
|
|
593
|
+
{
|
|
594
|
+
"path": "/home/user/somoraworkspace/shots/run-12.png",
|
|
595
|
+
"kind": "image",
|
|
596
|
+
"ext": ".png",
|
|
597
|
+
"bytes": 184320,
|
|
598
|
+
"mime": "image/png",
|
|
599
|
+
"url": "/files/raw?path=…",
|
|
600
|
+
"downloadUrl": "/files/raw?download=1&path=…"
|
|
601
|
+
}
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
**Error responses**
|
|
605
|
+
|
|
606
|
+
| Status | When |
|
|
607
|
+
|---|---|
|
|
608
|
+
| `400` | Missing `path` query, relative path, path is a directory or non-regular file |
|
|
609
|
+
| `403` | Policy blocked (path resolves under a blacklisted root or a denied somora-internal location) |
|
|
610
|
+
| `404` | File does not exist |
|
|
611
|
+
|
|
612
|
+
```bash
|
|
613
|
+
curl -G "https://<host>:18737/files/view" \
|
|
614
|
+
--data-urlencode "path=/home/user/somoraworkspace/somora_feedback/example.md"
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
---
|
|
618
|
+
|
|
619
|
+
### `GET /files/raw`
|
|
620
|
+
|
|
621
|
+
The bytes behind a `/files/view` result: media the viewer displays
|
|
622
|
+
inline, and a download for every other type. Same path policy, applied
|
|
623
|
+
in the same two passes — the byte route is not a way around what the
|
|
624
|
+
metadata route refuses.
|
|
625
|
+
|
|
626
|
+
**Query parameters**
|
|
627
|
+
|
|
628
|
+
| Name | Required | Description |
|
|
629
|
+
|---|---|---|
|
|
630
|
+
| `path` | yes | Absolute filesystem path, as for `/files/view`. |
|
|
631
|
+
| `download` | no | `1` forces `Content-Disposition: attachment`, whatever the type. |
|
|
632
|
+
|
|
633
|
+
**Range requests are supported** (`Accept-Ranges: bytes`, `206` with
|
|
634
|
+
`Content-Range`, `416` past the end, and `bytes=-N` for a suffix). A
|
|
635
|
+
browser seeking inside a video depends on it; without Range, scrubbing
|
|
636
|
+
re-fetches the whole file. There is therefore no size cap.
|
|
637
|
+
|
|
638
|
+
`Content-Type` is taken from the magic bytes, never the extension, and
|
|
639
|
+
`X-Content-Type-Options: nosniff` is set so a browser cannot re-guess
|
|
640
|
+
it. `Content-Disposition: inline` is limited to image, video, audio and
|
|
641
|
+
PDF — anything else is served as an attachment, because a file
|
|
642
|
+
displayed inline runs on somora's own origin.
|
|
643
|
+
|
|
644
|
+
The path policy is the only boundary: files outside the workspace
|
|
645
|
+
(`/tmp/...` screenshots, for instance) are viewable as long as they are
|
|
646
|
+
not under a blocked root, which matches what `file_read` allows an
|
|
647
|
+
agent to see.
|
|
648
|
+
|
|
649
|
+
```bash
|
|
650
|
+
curl -G "https://<host>:18737/files/raw" \
|
|
651
|
+
--data-urlencode "path=/home/user/somoraworkspace/shots/run-12.png" \
|
|
652
|
+
-o run-12.png
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
---
|
|
656
|
+
|
|
657
|
+
## Agents
|
|
658
|
+
|
|
659
|
+
### `GET /agents`
|
|
660
|
+
|
|
661
|
+
List configured agents.
|
|
662
|
+
|
|
663
|
+
```bash
|
|
664
|
+
curl https://<host>:18737/agents
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
Returns an array of `AgentInfo`:
|
|
668
|
+
|
|
669
|
+
```json
|
|
670
|
+
[
|
|
671
|
+
{
|
|
672
|
+
"name": "<your-agent>",
|
|
673
|
+
"description": "scribe and personal-assistant",
|
|
674
|
+
"icon": "📝",
|
|
675
|
+
"color": "#6366f1",
|
|
676
|
+
"role": "Scribe"
|
|
677
|
+
}
|
|
678
|
+
]
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
Source: `~/.somora/agents/<name>/AGENTS.md` frontmatter.
|
|
682
|
+
|
|
683
|
+
### `GET /agents/:agent/system-prompt`
|
|
684
|
+
|
|
685
|
+
Returns the persona part of the system prompt (`SOUL.md`, `AGENTS.md`,
|
|
686
|
+
`USER.md` with somora's headings) — `{agent, systemPrompt}`. For the
|
|
687
|
+
complete prompt as a turn sends it, use `/prompt-preview` below.
|
|
688
|
+
|
|
689
|
+
### `GET /agents/:agent/prompt-preview`
|
|
690
|
+
|
|
691
|
+
The system prompt exactly as the next turn on `?session=<slug|id>`
|
|
692
|
+
(default `main`) would send it, without running a turn or touching the
|
|
693
|
+
session:
|
|
694
|
+
|
|
695
|
+
```json
|
|
696
|
+
{ "agent": "<your-agent>", "session": "main", "text": "…", "chars": 16210,
|
|
697
|
+
"parts": [{"key": "self", "label": "Self-pointer", "chars": 900},
|
|
698
|
+
{"key": "persona", "label": "Persona (SOUL.md · AGENTS.md · USER.md)", "chars": 9340},
|
|
699
|
+
{"key": "team", "label": "Team block", "chars": 2652}, …],
|
|
700
|
+
"tools": {"count": 41, "schemaChars": 26510, "names": ["exec", …]},
|
|
701
|
+
"budgets": {"teamBlockChars": 3000, "personaFileChars": 8000, "personaTotalChars": 14000},
|
|
702
|
+
"notIncluded": ["tool schemas (…)", "memory recall injected per turn", …] }
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
`parts` concatenate to `text` (separators included), in prompt order:
|
|
706
|
+
self-pointer, persona, team, tool reminder, wiki overview, skills,
|
|
707
|
+
session (which session this is, so the agent can name it to tools),
|
|
708
|
+
project. `tools` counts the tools this agent can see after gating and
|
|
709
|
+
the size of their JSON schemas — they travel on the API tool channel,
|
|
710
|
+
not in `text`, and engines load them direct or deferred. The list is
|
|
711
|
+
resolved against the model that session would actually use, including a
|
|
712
|
+
per-session `/model` override, because a capability-gated tool differs
|
|
713
|
+
per model: `analyze_file` is offered only where the model cannot see
|
|
714
|
+
images itself. Read-only: a
|
|
715
|
+
session whose wiki overview was never snapshotted is rendered without
|
|
716
|
+
persisting the snapshot.
|
|
717
|
+
|
|
718
|
+
### `GET /agents/:agent/persona`
|
|
719
|
+
|
|
720
|
+
`{agent, files: [{name, exists, content, hash, chars, bytes, mtime,
|
|
721
|
+
readOnly}], budgets, totals: {personaChars}}` — `AGENTS.md`, `SOUL.md`,
|
|
722
|
+
`USER.md` (editable) and `agent.yaml` (`readOnly: true`). `hash` is the
|
|
723
|
+
optimistic lock for the write below; `budgets` is
|
|
724
|
+
`config.promptBudgets`.
|
|
725
|
+
|
|
726
|
+
### `PUT /agents/:agent/persona/:file`
|
|
727
|
+
|
|
728
|
+
Body: `{content, baseHash}`; `file` is one of `AGENTS.md`, `SOUL.md`,
|
|
729
|
+
`USER.md`. Writes only when `baseHash` equals the hash of the file
|
|
730
|
+
currently on disk — agents self-edit these files, so a stale save must
|
|
731
|
+
not overwrite theirs: `409 {error, currentHash, currentContent}` tells
|
|
732
|
+
the client to reload. `AGENTS.md` must keep a parseable frontmatter
|
|
733
|
+
whose `name` (when set) matches the agent directory and a non-empty
|
|
734
|
+
body (`400` otherwise). The previous version is kept as
|
|
735
|
+
`<file>.bak-<timestamp>` (last five); the write is atomic. Returns
|
|
736
|
+
`{ok: true, hash, backup, chars}`. The next turn uses the new text.
|
|
737
|
+
|
|
738
|
+
---
|
|
739
|
+
|
|
740
|
+
## Team
|
|
741
|
+
|
|
742
|
+
The org chart from `~/.somora/team.yaml` (see [team.md](team.md)).
|
|
743
|
+
Readable and writable over HTTP; the file can also be edited by hand.
|
|
744
|
+
|
|
745
|
+
### `GET /team`
|
|
746
|
+
|
|
747
|
+
`{enabled, path, exists, valid, issues, file?, principal?, rules?,
|
|
748
|
+
agents?, order?, unlisted?, missing?, warnings?}` — `file` is the parsed
|
|
749
|
+
document as written; `agents` (keyed by name: `{name, title, reportsTo,
|
|
750
|
+
involveFor, notFor, notes?, children, depth}`), `order` (pre-order
|
|
751
|
+
walk), `unlisted` (agents on disk missing from the file) and `missing`
|
|
752
|
+
(file entries without a directory) are the resolved view. `enabled:
|
|
753
|
+
false` with `exists: false` means no file; with `valid: false` the
|
|
754
|
+
`issues` say what is wrong (`{path, message}`), and the server keeps
|
|
755
|
+
the last valid team in force.
|
|
756
|
+
|
|
757
|
+
### `GET /team/preview/:agent`
|
|
758
|
+
|
|
759
|
+
`{agent, enabled, block, chars, softMaxChars}` — the exact `# Your
|
|
760
|
+
team` text that agent gets in its system prompt. `404` for an unknown
|
|
761
|
+
agent.
|
|
762
|
+
|
|
763
|
+
### `GET /team/check`
|
|
764
|
+
|
|
765
|
+
`{exists, valid, issues, warnings, unlisted, missing, blocks: [{agent,
|
|
766
|
+
chars, overSoftMax}], softMaxChars}` — what `somora team check` prints,
|
|
767
|
+
minus the persona scan.
|
|
768
|
+
|
|
769
|
+
### `PUT /team`
|
|
770
|
+
|
|
771
|
+
Body: the whole document as JSON (`{version: 1, principal, rules?,
|
|
772
|
+
agents}` — the same shape `GET /team` returns under `file`). The server
|
|
773
|
+
validates exactly like the loader; `400 {error, issues: [{path,
|
|
774
|
+
message}]}` writes nothing. On success the previous file is kept as
|
|
775
|
+
`team.yaml.bak-<timestamp>` (last five), the new one is written
|
|
776
|
+
atomically, the read cache is dropped, and the response is `{ok: true,
|
|
777
|
+
backup, …}` plus everything `GET /team` returns. Agents see the change
|
|
778
|
+
on their next turn.
|
|
779
|
+
|
|
780
|
+
### `POST /team/init`
|
|
781
|
+
|
|
782
|
+
Body: `{principal?: string}`. Writes a first document with every agent
|
|
783
|
+
on disk reporting to the principal (titles from the frontmatter, the
|
|
784
|
+
default rules spelled out). `409` when a file already exists — this
|
|
785
|
+
never overwrites. Returns the same shape as `GET /team`.
|
|
786
|
+
|
|
787
|
+
### `POST /team/preview`
|
|
788
|
+
|
|
789
|
+
Body: `{file, agent}` — a draft document and the agent to render for.
|
|
790
|
+
Returns `{agent, valid, issues, warnings, block, chars, softMaxChars}`;
|
|
791
|
+
an invalid draft comes back with `valid: false` and its `issues`, and
|
|
792
|
+
nothing is written. This is what the web Team window's live preview
|
|
793
|
+
uses.
|
|
794
|
+
|
|
795
|
+
## Sessions
|
|
796
|
+
|
|
797
|
+
A session is a single conversation thread inside an agent. Each
|
|
798
|
+
agent has a magical `main` session plus any number of named sessions.
|
|
799
|
+
|
|
800
|
+
### `GET /agents/:agent/sessions`
|
|
801
|
+
|
|
802
|
+
List sessions for one agent. Archived sessions are filtered out by
|
|
803
|
+
default — pass `?include_archived=true` to surface them.
|
|
804
|
+
|
|
805
|
+
```bash
|
|
806
|
+
curl https://<host>:18737/agents/<your-agent>/sessions
|
|
807
|
+
curl https://<host>:18737/agents/<your-agent>/sessions?include_archived=true
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
Returns an array of `SessionSummary`:
|
|
811
|
+
|
|
812
|
+
```json
|
|
813
|
+
[
|
|
814
|
+
{
|
|
815
|
+
"id": "20260511-093251_research-notes",
|
|
816
|
+
"slug": "research-notes",
|
|
817
|
+
"isMain": false,
|
|
818
|
+
"createdAt": "2026-05-11T09:32:51.000Z",
|
|
819
|
+
"lastActivity": "2026-05-12T14:08:22.000Z",
|
|
820
|
+
"messageCount": 47,
|
|
821
|
+
"isArchived": false,
|
|
822
|
+
"byteSize": 18923,
|
|
823
|
+
"engine": "claude-cli",
|
|
824
|
+
"dreamCoverageTs": 1715520120000,
|
|
825
|
+
"dreamLagEvents": 4,
|
|
826
|
+
"unreadAt": "2026-05-12T14:08:22.000Z",
|
|
827
|
+
"seenAt": "2026-05-12T13:55:00.000Z"
|
|
828
|
+
}
|
|
829
|
+
]
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
`unreadAt` and `seenAt` drive the unread badge UX: a session is unread
|
|
833
|
+
when `unreadAt > seenAt` (or `seenAt` is null). See
|
|
834
|
+
[`/activity/stream`](#get-activitystream) for the live feed that
|
|
835
|
+
keeps these in sync across clients.
|
|
836
|
+
|
|
837
|
+
### `GET /sessions`
|
|
838
|
+
|
|
839
|
+
Cross-agent session list. Same data as the per-agent endpoint, but
|
|
840
|
+
flattened across every agent and wrapped as `{sessions: [...]}`, with
|
|
841
|
+
each row carrying its agent name. Used by the web Sessions tool and
|
|
842
|
+
by the `session_list` agent tool. Each row also says whether a turn is
|
|
843
|
+
running in that session right now: `busy`, `queueLength` (turns waiting
|
|
844
|
+
behind it) and `activeSince` (ms timestamp, `null` when idle).
|
|
845
|
+
|
|
846
|
+
```bash
|
|
847
|
+
curl https://<host>:18737/sessions
|
|
848
|
+
curl https://<host>:18737/sessions?include_archived=true
|
|
849
|
+
```
|
|
850
|
+
|
|
851
|
+
### `POST /agents/:agent/sessions`
|
|
852
|
+
|
|
853
|
+
Create a new named session.
|
|
854
|
+
|
|
855
|
+
```bash
|
|
856
|
+
curl -X POST https://<host>:18737/agents/<your-agent>/sessions \
|
|
857
|
+
-H 'Content-Type: application/json' \
|
|
858
|
+
-d '{"slug":"research-notes"}'
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
Returns `201 { id, slug, agent }`. The slug must match `[A-Za-z0-9_-]+`.
|
|
862
|
+
One live session per slug: when a non-archived session already carries
|
|
863
|
+
the name, the answer is `409 { error, id, slug, agent, exists: true }`
|
|
864
|
+
with that session's id — the web and TUI simply switch to it. Archiving
|
|
865
|
+
or resetting the session frees the name.
|
|
866
|
+
Cannot be the reserved string `main` (`400`).
|
|
867
|
+
|
|
868
|
+
### `POST /agents/:agent/sessions/:session/archive`
|
|
869
|
+
|
|
870
|
+
Hide a session from active views without deleting it. The `<id>.jsonl`
|
|
871
|
+
and `<id>.meta.json` stay on disk; only the `archived: true` flag
|
|
872
|
+
in meta is set. Reversible via unarchive.
|
|
873
|
+
|
|
874
|
+
```bash
|
|
875
|
+
curl -X POST https://<host>:18737/agents/<your-agent>/sessions/<id>/archive \
|
|
876
|
+
-H 'Content-Type: application/json' \
|
|
877
|
+
-d '{"reason":"old smoke test"}'
|
|
878
|
+
```
|
|
879
|
+
|
|
880
|
+
The `main` session cannot be archived directly — use `/reset` instead.
|
|
881
|
+
|
|
882
|
+
### `POST /agents/:agent/sessions/:session/unarchive`
|
|
883
|
+
|
|
884
|
+
Clears the `archived` flag.
|
|
885
|
+
|
|
886
|
+
### `GET /agents/:agent/sessions/:session/export`
|
|
887
|
+
|
|
888
|
+
Download the session as either raw JSONL (canonical, byte-identical to
|
|
889
|
+
the source-of-truth file on disk) or a rendered Markdown transcript
|
|
890
|
+
(human-readable, suitable for Obsidian / GitHub / blog posts).
|
|
891
|
+
|
|
892
|
+
Query param `format`:
|
|
893
|
+
- `json` — `Content-Type: application/x-ndjson`. The complete JSONL
|
|
894
|
+
with every event preserved (turn_start, tool_call, engine_meta, …).
|
|
895
|
+
Use this for backups and cross-host transfer.
|
|
896
|
+
- `markdown` (default) — `Content-Type: text/markdown`. Renders
|
|
897
|
+
user/assistant turns as `##` sections, tool calls as collapsible
|
|
898
|
+
`<details>` blocks with their JSON args/results, and engine_meta
|
|
899
|
+
items (e.g. codex's plan/todo lists) as task-style bullet lists
|
|
900
|
+
with status glyphs. Skips bookkeeping events (turn_start, turn_end,
|
|
901
|
+
assistant_audio) — those don't add value in a transcript.
|
|
902
|
+
|
|
903
|
+
Both responses set `Content-Disposition: attachment` so browsers
|
|
904
|
+
trigger a file save.
|
|
905
|
+
|
|
906
|
+
```bash
|
|
907
|
+
# Markdown transcript
|
|
908
|
+
curl https://<host>:18737/agents/<your-agent>/sessions/main/export?format=markdown \
|
|
909
|
+
-o <your-agent>-main.md
|
|
910
|
+
|
|
911
|
+
# Raw JSONL (full fidelity)
|
|
912
|
+
curl https://<host>:18737/agents/<your-agent>/sessions/main/export?format=json \
|
|
913
|
+
-o <your-agent>-main.jsonl
|
|
914
|
+
```
|
|
915
|
+
|
|
916
|
+
The web client surfaces this via per-row download icons in the
|
|
917
|
+
Sessions tool (file-text icon = markdown, file-json icon = JSONL).
|
|
918
|
+
The TUI has `/export [json|markdown] [path]` — see [display.md](display.md)
|
|
919
|
+
for the slash-command reference.
|
|
920
|
+
|
|
921
|
+
### `POST /agents/:agent/sessions/:session/reset`
|
|
922
|
+
|
|
923
|
+
Archive the current session content and start fresh. Triggers an
|
|
924
|
+
asynchronous REM extraction over the archived content if REM is
|
|
925
|
+
enabled for the agent.
|
|
926
|
+
|
|
927
|
+
```bash
|
|
928
|
+
curl -X POST https://<host>:18737/agents/<your-agent>/sessions/main/reset
|
|
929
|
+
# { "agent": "<your-agent>", "session": "main",
|
|
930
|
+
# "archivedId": "20260512-140822_main-archive",
|
|
931
|
+
# "dreamSpawned": true }
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
The reset returns immediately. The REM run continues in the
|
|
935
|
+
background; check its progress via `GET /dream-states` or via
|
|
936
|
+
the per-agent REM badge in the web AgentDock.
|
|
937
|
+
|
|
938
|
+
### Builder sessions
|
|
939
|
+
|
|
940
|
+
Agents of kind `builder` (see [builder.md](builder.md)) carry mode,
|
|
941
|
+
phase, plan file and task list per session, plus at most one open
|
|
942
|
+
question. The web task panel reads and writes these; the builder's own
|
|
943
|
+
tools (`todo_write`, `ask_user`, `plan_write`) call the same routes.
|
|
944
|
+
|
|
945
|
+
- `GET /agents/:agent/sessions/:session/builder` → `{agent, session,
|
|
946
|
+
kind, state, question, turn}` — `question` also carries the write-scope
|
|
947
|
+
question a builder's `file_write`/`file_patch` raises for a path outside
|
|
948
|
+
the project folder (attended mode; see builder.md) — `turn` is `{turnId, startedAt,
|
|
949
|
+
toolCalls, lastTool?, lastToolAt?}` while a turn runs on the session,
|
|
950
|
+
else `null`; `state` is `{mode: "attended"|"unattended",
|
|
951
|
+
phase: "plan"|"build", planPath, todos: [{content, status,
|
|
952
|
+
priority?}]}` or `null` before the session's first turn; `question`
|
|
953
|
+
is `{questionId, question, header?, options: [{label,
|
|
954
|
+
description?}], multiple, askedAt, expiresAt}` or `null`.
|
|
955
|
+
- `PATCH /agents/:agent/sessions/:session/builder` `{mode?, phase?,
|
|
956
|
+
planPath?, orderer?}` → `{agent, session, state}`. Publishes
|
|
957
|
+
`builder_state`. `orderer` `{agent, session?}` names the agent that
|
|
958
|
+
handed the order over (`builder_dispatch` sets it).
|
|
959
|
+
- `POST /lsp/diagnostics` `{agent, session, path, touch?}` →
|
|
960
|
+
`{diagnostics: {server, errors, errors_in_other_files} | null}` — the
|
|
961
|
+
language server's verdict on a file a builder just wrote (what
|
|
962
|
+
`file_write`/`file_patch` call; see [lsp.md](lsp.md)); `touch: true`
|
|
963
|
+
only starts the server. `GET /lsp/status` → the servers found, the
|
|
964
|
+
config and the running instances.
|
|
965
|
+
- `GET /builders` → `{builders: [{name, role, description, busy: [{session,
|
|
966
|
+
workdir, since}]}]}` — the agents of kind builder and the folders each
|
|
967
|
+
is working in right now.
|
|
968
|
+
- `GET /builders/busy?workdir=<path>` → `{workdir, busy: {agent, session,
|
|
969
|
+
turnId, workdir, since, reason} | null}` — whether a builder's running
|
|
970
|
+
turn claims that folder (or a parent/child of it). Without `workdir`:
|
|
971
|
+
`{claims: [...]}`.
|
|
972
|
+
- `POST /agents/:agent/sessions/:session/builder/go` `{note?}` →
|
|
973
|
+
`202 {agent, session, state, turnId, callId?, wakes?}` — sets the phase
|
|
974
|
+
to build and starts a turn telling the builder the plan is approved
|
|
975
|
+
(`note` is appended to that message). With an `orderer` in the state
|
|
976
|
+
the turn runs as that agent's detached ask (`callId` = `turnId`,
|
|
977
|
+
`wakes` = the orderer): it is woken with the report like after
|
|
978
|
+
`agent_ask` with `wait:false`. `409 {error, busy}` when another
|
|
979
|
+
builder's turn is working in the session's folder right now.
|
|
980
|
+
- `PUT /agents/:agent/sessions/:session/todos` `{todos: [{content,
|
|
981
|
+
status, priority?}], by_agent?}` → `{agent, session, todos}` — replaces
|
|
982
|
+
the whole list (max 100 items). Publishes `todo_updated`.
|
|
983
|
+
- `PUT /agents/:agent/sessions/:session/plan` `{content}` → `{path, bytes,
|
|
984
|
+
archived?, note?}` (what `plan_write` calls); `archived` names where a
|
|
985
|
+
plan file that was already there and not written by this session was
|
|
986
|
+
moved: `PLAN-<date>-<session>.md` beside it. The path is the session's
|
|
987
|
+
plan path (the pinned project's `PLAN.md`, else `<workspace>/PLAN.md`),
|
|
988
|
+
written atomically under the file write policy.
|
|
989
|
+
- `POST /agents/:agent/sessions/:session/ask` `{question, header?,
|
|
990
|
+
options: [{label, description?}] (2-6), multiple?, timeout_ms?}` —
|
|
991
|
+
**blocks** until the person answers or the wait runs out (default 30
|
|
992
|
+
min, max 4 h) and returns `{answered, answers: string[], text?}`.
|
|
993
|
+
Publishes `question_asked` when the question opens. A second question
|
|
994
|
+
on the same session supersedes the first (which returns unanswered).
|
|
995
|
+
- `POST /agents/:agent/sessions/:session/answer` `{questionId,
|
|
996
|
+
answers?: string[], text?}` → `{ok: true}`, or `404` when no such
|
|
997
|
+
question is open. Publishes `question_answered`.
|
|
998
|
+
|
|
999
|
+
### `GET /agents/:agent/sessions/:session/work`
|
|
1000
|
+
|
|
1001
|
+
What this session is doing right now, what waits behind it, which
|
|
1002
|
+
answers are about to arrive, and what it started elsewhere. This is
|
|
1003
|
+
the data behind the queue badge in the web client, the sheet on mobile
|
|
1004
|
+
and `/queue` in the TUI. Previews only: the first 160 characters of
|
|
1005
|
+
each message, never a prompt, a tool body or a secret.
|
|
1006
|
+
|
|
1007
|
+
```bash
|
|
1008
|
+
curl https://<host>:18737/agents/<your-agent>/sessions/main/work
|
|
1009
|
+
```
|
|
1010
|
+
|
|
1011
|
+
```json
|
|
1012
|
+
{
|
|
1013
|
+
"asOf": 1789300000000,
|
|
1014
|
+
"agent": "<your-agent>",
|
|
1015
|
+
"session": "20260913-101500_main",
|
|
1016
|
+
"busy": true,
|
|
1017
|
+
"active": {
|
|
1018
|
+
"id": "1f3a…", "kind": "agent", "state": "running",
|
|
1019
|
+
"preview": "Can you check whether the release notes mention …",
|
|
1020
|
+
"target": { "agent": "<your-agent>", "session": "20260913-101500_main" },
|
|
1021
|
+
"requester": { "agent": "<other-agent>", "session": "20260910-083000_main" },
|
|
1022
|
+
"enqueuedAt": 1789299990000, "startedAt": 1789299991000, "turnId": "1f3a…"
|
|
1023
|
+
},
|
|
1024
|
+
"queued": [
|
|
1025
|
+
{ "id": "b5b7…", "kind": "human", "state": "queued",
|
|
1026
|
+
"preview": "and the changelog too",
|
|
1027
|
+
"target": { "agent": "<your-agent>", "session": "20260913-101500_main" },
|
|
1028
|
+
"requester": { "human": true },
|
|
1029
|
+
"enqueuedAt": 1789299995000, "position": 1 },
|
|
1030
|
+
{ "id": "task-…", "kind": "sentinel", "state": "queued",
|
|
1031
|
+
"preview": "[sentinel] inbox digest …",
|
|
1032
|
+
"target": { "agent": "<your-agent>", "session": "20260913-101500_main" },
|
|
1033
|
+
"enqueuedAt": 1789299998000, "position": 2 }
|
|
1034
|
+
],
|
|
1035
|
+
"pendingWakes": [
|
|
1036
|
+
{ "id": "9d2c…", "kind": "agent", "about": "a2a", "state": "done",
|
|
1037
|
+
"preview": "Which of the three drafts …",
|
|
1038
|
+
"target": { "agent": "<other-agent>", "session": "20260910-083000_main" },
|
|
1039
|
+
"requester": { "agent": "<your-agent>", "session": "20260913-101500_main" },
|
|
1040
|
+
"enqueuedAt": 1789299900000, "startedAt": 1789299901000, "finishedAt": 1789299999500 }
|
|
1041
|
+
],
|
|
1042
|
+
"children": [
|
|
1043
|
+
{ "id": "task-…", "kind": "subagent", "state": "running",
|
|
1044
|
+
"preview": "Summarise the three …",
|
|
1045
|
+
"target": { "agent": "<your-agent>", "session": "sub-<your-agent>-20260913-101700" },
|
|
1046
|
+
"requester": { "agent": "<your-agent>", "session": "20260913-101500_main" },
|
|
1047
|
+
"enqueuedAt": 1789299970000, "startedAt": 1789299971000 }
|
|
1048
|
+
]
|
|
1049
|
+
}
|
|
1050
|
+
```
|
|
1051
|
+
|
|
1052
|
+
Every entry has the same shape:
|
|
1053
|
+
|
|
1054
|
+
- `id` — the work id: the `turnId` of a typed message, the `call_id`
|
|
1055
|
+
of an `agent_ask`, the `task_id` of a sub-agent brief or a sentinel
|
|
1056
|
+
fire, the consult id of a question from a call, the job id of a
|
|
1057
|
+
video render.
|
|
1058
|
+
- `kind` — where it came from: `human`, `agent`, `subagent`,
|
|
1059
|
+
`sentinel`, `tmux`, `browser`, `voice` or `wake`; a `wake` also says
|
|
1060
|
+
`about` (`a2a`, `subagent` or `job`).
|
|
1061
|
+
- `state` — `queued`, `running`, `done`, `failed`, `cancelled` or
|
|
1062
|
+
`dequeued` (taken out of the queue before it started).
|
|
1063
|
+
- `preview` — the first 160 characters of the text, line breaks folded
|
|
1064
|
+
to spaces. The only text exposed.
|
|
1065
|
+
- `target` — the `{agent, session}` the turn runs on.
|
|
1066
|
+
- `requester` — who asked for it: `{agent, session}` for an
|
|
1067
|
+
`agent_ask`, a sub-agent brief or a wake; `{human: true}` for a typed
|
|
1068
|
+
message; `{voiceCall}` for a question from a call. Absent for
|
|
1069
|
+
sentinel, tmux and browser turns, which nobody waits on.
|
|
1070
|
+
- `enqueuedAt`, `startedAt?`, `finishedAt?` — epoch ms. `turnId?` once
|
|
1071
|
+
the turn runs; `error?` for `failed`, `cancelled` and `dequeued`.
|
|
1072
|
+
|
|
1073
|
+
The four lists:
|
|
1074
|
+
|
|
1075
|
+
- `active` — the turn holding the session lock, or `null`. `busy` is
|
|
1076
|
+
the lock itself; when a turn holds it without a ledger entry the
|
|
1077
|
+
response carries `activeTurnId` instead.
|
|
1078
|
+
- `queued` — the waiters in lock order, each with `position` (1 =
|
|
1079
|
+
next). Any of them can be removed with `DELETE /chat/queue/:id`.
|
|
1080
|
+
- `pendingWakes` — work this session asked for that has finished and
|
|
1081
|
+
whose wake-up turn is scheduled (the grace is `agentLoop.wakeGraceMs`,
|
|
1082
|
+
see [setup.md](setup.md#tunables)); `about` says what kind of answer
|
|
1083
|
+
is on its way.
|
|
1084
|
+
- `children` — the sub-agents and `agent_ask` calls this session
|
|
1085
|
+
started that are still queued or running, with their target so a
|
|
1086
|
+
client can jump there.
|
|
1087
|
+
|
|
1088
|
+
Everything here lives in memory and is gone after a restart, like the
|
|
1089
|
+
sub-agent registry. `404` for an unknown agent or session.
|
|
1090
|
+
|
|
1091
|
+
---
|
|
1092
|
+
|
|
1093
|
+
## Models & thinking
|
|
1094
|
+
|
|
1095
|
+
Per-session overrides for the active model and the active thinking
|
|
1096
|
+
level. Both fall back to the persona default when unset.
|
|
1097
|
+
|
|
1098
|
+
### Model
|
|
1099
|
+
|
|
1100
|
+
```bash
|
|
1101
|
+
# Read current
|
|
1102
|
+
curl https://<host>:18737/agents/<your-agent>/sessions/main/model
|
|
1103
|
+
|
|
1104
|
+
# Set per-session override
|
|
1105
|
+
curl -X PUT https://<host>:18737/agents/<your-agent>/sessions/main/model \
|
|
1106
|
+
-H 'Content-Type: application/json' \
|
|
1107
|
+
-d '{"model":"claude-opus-4-7"}'
|
|
1108
|
+
|
|
1109
|
+
# Clear override (back to persona default)
|
|
1110
|
+
curl -X DELETE https://<host>:18737/agents/<your-agent>/sessions/main/model
|
|
1111
|
+
```
|
|
1112
|
+
|
|
1113
|
+
The `model` field accepts an alias (`claude-opus-4-7`), a
|
|
1114
|
+
`<provider>/<id>` tuple (`anthropic/claude-opus-4-20250514`), or
|
|
1115
|
+
anything else resolvable by `GET /models`.
|
|
1116
|
+
|
|
1117
|
+
A switch takes effect at the next turn: a turn that is already running
|
|
1118
|
+
keeps the model it started with. Every open client is told through the
|
|
1119
|
+
`session_model` SSE event.
|
|
1120
|
+
|
|
1121
|
+
Both routes take optional `by_agent` / `by_session` in the body — sent
|
|
1122
|
+
by the `session_model` agent tool. A switch made by an agent is written
|
|
1123
|
+
into the affected conversation as an `engine_meta` row (`engine:
|
|
1124
|
+
"somora"`, `itemType: "session_model"`, label `model switched`) naming
|
|
1125
|
+
who switched to what, so a person reading that session sees it. A
|
|
1126
|
+
switch without `by_agent` — a person using their own client — leaves no
|
|
1127
|
+
row.
|
|
1128
|
+
|
|
1129
|
+
Switching models mid-session is safe on every engine. On codex-cli the
|
|
1130
|
+
thread simply continues under the new model (`thread/resume` takes the
|
|
1131
|
+
model; Codex may compact the thread context once) and somora drops a
|
|
1132
|
+
`model switch` marker into the conversation. The somora session (id, history, meta) is untouched;
|
|
1133
|
+
alias changes that resolve to the same underlying model don't trigger a
|
|
1134
|
+
re-thread.
|
|
1135
|
+
|
|
1136
|
+
### Thinking
|
|
1137
|
+
|
|
1138
|
+
```bash
|
|
1139
|
+
# Read
|
|
1140
|
+
curl https://<host>:18737/agents/<your-agent>/sessions/main/thinking
|
|
1141
|
+
|
|
1142
|
+
# Set
|
|
1143
|
+
curl -X PUT https://<host>:18737/agents/<your-agent>/sessions/main/thinking \
|
|
1144
|
+
-H 'Content-Type: application/json' \
|
|
1145
|
+
-d '{"level":"medium"}'
|
|
1146
|
+
|
|
1147
|
+
# Clear override
|
|
1148
|
+
curl -X DELETE https://<host>:18737/agents/<your-agent>/sessions/main/thinking
|
|
1149
|
+
```
|
|
1150
|
+
|
|
1151
|
+
Levels: `off`, `low`, `medium`, `high` — anything else is a `400`.
|
|
1152
|
+
Per-model `reasoning.levels` in config.yaml decides which wire word
|
|
1153
|
+
(`minimal`, `xhigh`, `max`, …) each level becomes; see
|
|
1154
|
+
[thinking.md](thinking.md).
|
|
1155
|
+
|
|
1156
|
+
`GET` returns `{agent, session, effective, override, personaDefault,
|
|
1157
|
+
source, modelSupportsReasoning, wire}`: `effective` is the level in
|
|
1158
|
+
force (session override > persona default > `null` = engine default),
|
|
1159
|
+
`source` says which of those won (`session-override` /
|
|
1160
|
+
`persona-default` / `engine-default`), `modelSupportsReasoning` tells a
|
|
1161
|
+
client whether the setting is live or dormant on the current model,
|
|
1162
|
+
and `wire` is the value actually sent when it differs from the level
|
|
1163
|
+
(e.g. `high` → `xhigh`). `PUT` answers `{agent, session, level}`,
|
|
1164
|
+
`DELETE` answers `{agent, session, cleared: true}`.
|
|
1165
|
+
|
|
1166
|
+
The `GET …/model` payload is `{agent, session, provider, modelId,
|
|
1167
|
+
alias, engine, contextWindow, source, override, personaDefault}` with
|
|
1168
|
+
`source` `session-override` or `persona-default`; `PUT` answers
|
|
1169
|
+
`{agent, session, model, resolved: "<provider>/<modelId>"}` and `400`
|
|
1170
|
+
names an unknown model; `DELETE` answers `{agent, session, cleared:
|
|
1171
|
+
true}`.
|
|
1172
|
+
|
|
1173
|
+
### `GET /models`
|
|
1174
|
+
|
|
1175
|
+
List models the server knows about. Sources: config-level model
|
|
1176
|
+
definitions plus engine-discovered models.
|
|
1177
|
+
|
|
1178
|
+
```bash
|
|
1179
|
+
curl https://<host>:18737/models
|
|
1180
|
+
```
|
|
1181
|
+
|
|
1182
|
+
Each entry: `{ provider, id, alias, engine, contextWindow,
|
|
1183
|
+
capabilities, ref }`. `ref` is the canonical handle to pass to the
|
|
1184
|
+
model-set endpoints.
|
|
1185
|
+
|
|
1186
|
+
---
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
## External MCP servers
|
|
1190
|
+
|
|
1191
|
+
Status and control of the MCP hub (`mcp.servers` in config.yaml, see
|
|
1192
|
+
[mcp.md](mcp.md)). All three answer `503` when no external server is
|
|
1193
|
+
configured.
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
Each entry carries `unavailable: {since, until, reason}` (epoch ms)
|
|
1197
|
+
while the model is marked unreachable — a cascade (chat fallback, REM
|
|
1198
|
+
worker chain, compaction) hit a host error on it within the last
|
|
1199
|
+
`fallback.retryUnavailableMinutes`; cascades start past such models.
|
|
1200
|
+
|
|
1201
|
+
### `POST /models/availability/reset`
|
|
1202
|
+
|
|
1203
|
+
Forget every "unavailable" mark, so the next cascade tries the primaries
|
|
1204
|
+
again. `200 {ok: true, cleared, retryUnavailableMinutes}`. A config
|
|
1205
|
+
reload does the same as a side effect.
|
|
1206
|
+
|
|
1207
|
+
### `GET /mcp/status`
|
|
1208
|
+
|
|
1209
|
+
`{enabled: true, servers: {<name>: {state, toolCount, transport?,
|
|
1210
|
+
lastError?, lastConnectedAt?, consecutiveFailures}}}` — `state` is
|
|
1211
|
+
`pending`, `connected`, `failed`, `needs-auth` or `disabled`.
|
|
1212
|
+
|
|
1213
|
+
### `POST /mcp/servers/:name/reconnect`
|
|
1214
|
+
|
|
1215
|
+
Tears the connection down and reconnects immediately, resetting the
|
|
1216
|
+
backoff. `{ok: true, status}` with the server's new status entry;
|
|
1217
|
+
`400` when the name is unknown or the server is disabled in config.
|
|
1218
|
+
|
|
1219
|
+
### `POST /mcp/call`
|
|
1220
|
+
|
|
1221
|
+
Body: `server`, `tool` (the upstream tool name), `args` (object),
|
|
1222
|
+
optional `timeoutMs`. Calls the tool through the hub and returns
|
|
1223
|
+
`{isError, text, images: [{data, mimeType}]}`. `502` when the upstream
|
|
1224
|
+
call failed. This is the loopback path somora's own MCP children use;
|
|
1225
|
+
it bypasses per-agent tool gating, so treat it as an operator surface.
|
|
1226
|
+
|
|
1227
|
+
## Config reload + restart
|
|
1228
|
+
|
|
1229
|
+
```bash
|
|
1230
|
+
curl -sk https://<host>:18737/config/status # loadedAt, changedOnDisk, restartRequiredSections, restartAvailable
|
|
1231
|
+
curl -sk -X POST https://<host>:18737/config/reload # → { ok, changed: [...], restartRequired: [...] } or 400 with the schema issues
|
|
1232
|
+
curl -sk -X POST https://<host>:18737/server/restart # → { ok, via: "systemd", expectedDowntimeSeconds } or 409 without a systemd unit
|
|
1233
|
+
```
|
|
1234
|
+
|
|
1235
|
+
Reload validates the file first and keeps the running config on any
|
|
1236
|
+
error. Sections listed in `restartRequiredSections` (server, memory,
|
|
1237
|
+
obsidian, wiki, mcp, claudeCli, codexCli, stt, tts, sentinel, tmux,
|
|
1238
|
+
web, mobile) are consumed at boot and only change after a restart; the
|
|
1239
|
+
rest applies to the next request. See [web.md](web.md) for the taskbar
|
|
1240
|
+
surface and the TUI's `/reload` / `/restart`.
|
|
1241
|
+
|
|
1242
|
+
## Sampling
|
|
1243
|
+
|
|
1244
|
+
Per-session sampling override (`temperature`, `top_p`, …), merged over
|
|
1245
|
+
the agent's and the model's defaults. Only the `openai-compatible`
|
|
1246
|
+
engine applies it — `engineSupportsSampling` tells clients whether the
|
|
1247
|
+
setting is live or dormant. Full description in [sampling.md](sampling.md).
|
|
1248
|
+
|
|
1249
|
+
```bash
|
|
1250
|
+
curl https://<host>:18737/agents/<your-agent>/sessions/main/sampling
|
|
1251
|
+
|
|
1252
|
+
curl -X PUT https://<host>:18737/agents/<your-agent>/sessions/main/sampling \
|
|
1253
|
+
-H 'Content-Type: application/json' -d '{"temperature":0.7}' # merges; null drops a key
|
|
1254
|
+
|
|
1255
|
+
curl -X DELETE https://<host>:18737/agents/<your-agent>/sessions/main/sampling
|
|
1256
|
+
```
|
|
1257
|
+
|
|
1258
|
+
Keys: `temperature`, `top_p`, `top_k`, `min_p`, `frequency_penalty`,
|
|
1259
|
+
`presence_penalty`, `repetition_penalty`, `seed`, `stop`; an unknown key
|
|
1260
|
+
or an out-of-range value is a `400` naming the field. `GET` returns
|
|
1261
|
+
`{agent, session, effective, override, personaDefault, modelDefault,
|
|
1262
|
+
source, engineSupportsSampling}` (`source` is `session-override`,
|
|
1263
|
+
`persona-default`, `model-default` or `engine-default`). `PUT` merges
|
|
1264
|
+
the body into the override and returns `{agent, session, override}`
|
|
1265
|
+
(`null` once the last key is dropped); `DELETE` returns `{agent,
|
|
1266
|
+
session, cleared: true}`.
|
|
1267
|
+
|
|
1268
|
+
## Chat
|
|
1269
|
+
|
|
1270
|
+
### `POST /chat/send`
|
|
1271
|
+
|
|
1272
|
+
Fire-and-forget. The server returns 202 immediately; the actual
|
|
1273
|
+
turn runs in the background and emits SSE events to `/chat/stream`
|
|
1274
|
+
subscribers on the same `(agent, session)`.
|
|
1275
|
+
|
|
1276
|
+
```bash
|
|
1277
|
+
curl -X POST https://<host>:18737/chat/send \
|
|
1278
|
+
-H 'Content-Type: application/json' \
|
|
1279
|
+
-d '{"agent":"<your-agent>","session":"main","text":"Was steht heute an?"}'
|
|
1280
|
+
```
|
|
1281
|
+
|
|
1282
|
+
Body fields:
|
|
1283
|
+
- `agent` — agent name; when omitted the server falls back to the
|
|
1284
|
+
alphabetically first configured agent, so pass it
|
|
1285
|
+
- `session` (optional) — defaults to `"main"`
|
|
1286
|
+
- `text` (required) — user message
|
|
1287
|
+
- `attachments` (optional) — array of `{hash, name, mime, size}` —
|
|
1288
|
+
refs from prior `POST /attachments` calls
|
|
1289
|
+
- `input_modality` (optional) — `"voice"` when the client filled the
|
|
1290
|
+
text through its microphone (STT); recorded as
|
|
1291
|
+
`user_message.input.modality` and a precondition for a spoken reply
|
|
1292
|
+
- `stt_provider` (optional) — free-form tag of the STT path used
|
|
1293
|
+
- `auto_play_requested` (optional) — the client wants a spoken reply
|
|
1294
|
+
for this turn (`assistant_audio`); honoured only together with
|
|
1295
|
+
`input_modality: "voice"`, see [voice.md](voice.md)
|
|
1296
|
+
- `subagent_depth` (optional) — nesting depth when the turn is a
|
|
1297
|
+
sub-agent brief; the turn's `origin` becomes `{kind: "subagent"}`
|
|
1298
|
+
- `from_agent` (optional, A2A) — when set, the turn is attributed to
|
|
1299
|
+
another agent (used by `agent_ask` tool)
|
|
1300
|
+
- `from_session` (optional, A2A) — the session the asking agent wrote
|
|
1301
|
+
from; ignored without `from_agent`. Same meaning as on
|
|
1302
|
+
`/chat/send-sync`.
|
|
1303
|
+
- `agent_ask_call_id` (optional, A2A) — correlation UUID. A call id
|
|
1304
|
+
posted here is registered like one from `/chat/send-sync`, so
|
|
1305
|
+
`GET /a2a/ask-result` finds it while the turn is queued or running,
|
|
1306
|
+
not only in the target's history afterwards.
|
|
1307
|
+
- `steer` (optional, default false) — hand the text to the turn that is
|
|
1308
|
+
running on this session right now instead of queuing a turn of its
|
|
1309
|
+
own; see *Steering* below. Ignored together with `agent_ask_call_id`.
|
|
1310
|
+
|
|
1311
|
+
Response: `{ ok: true, turnId }`. The `turnId` is the server-issued
|
|
1312
|
+
identifier for the queued/running turn — clients echo it through to
|
|
1313
|
+
match later SSE events (`turn_queued`, `user_message`) back to the
|
|
1314
|
+
optimistic bubble they rendered locally. With `steer: true` the response
|
|
1315
|
+
is `{ ok: true, steered: true, steerId, turnId }` when the message went
|
|
1316
|
+
into the running turn (`turnId` is that turn's), or `{ ok: true, turnId,
|
|
1317
|
+
steered: false }` when nothing steerable was running and it queued as
|
|
1318
|
+
usual.
|
|
1319
|
+
|
|
1320
|
+
Streaming responses arrive via `/chat/stream`; this endpoint just
|
|
1321
|
+
acknowledges receipt.
|
|
1322
|
+
|
|
1323
|
+
#### Steering
|
|
1324
|
+
|
|
1325
|
+
A message for a session whose turn is still running can be handed
|
|
1326
|
+
**into** that turn instead of waiting behind it: `steer: true`. The
|
|
1327
|
+
server keeps it in a per-session letterbox; the engine reads the
|
|
1328
|
+
letterbox at its next step boundary — after the tools of the current
|
|
1329
|
+
round returned, before the next model call — and gives the model the
|
|
1330
|
+
text as a user message framed as "sent while you were working, delivered
|
|
1331
|
+
before your next step". The model then changes course, stops, or carries
|
|
1332
|
+
on as told. A running tool call is never interrupted; the message lands
|
|
1333
|
+
after it returns.
|
|
1334
|
+
|
|
1335
|
+
What a client sees: the `202` response carries `steerId`; a
|
|
1336
|
+
`steer_queued` SSE event tells the other windows on the session; and
|
|
1337
|
+
when the engine has handed the text to the model, a `user_message` event
|
|
1338
|
+
(and a session record) with `steer: true` and the same `steer_id`
|
|
1339
|
+
follows — that is the moment the bubble stops being "pending". The
|
|
1340
|
+
record sits in the session file exactly where the model read it, between
|
|
1341
|
+
the tool results of one round and the next assistant step.
|
|
1342
|
+
|
|
1343
|
+
Engines: `openai-compatible` (somora's own loop), `claude-cli`
|
|
1344
|
+
(streamed input) and `codex-cli` (`turn/steer`) take steer messages;
|
|
1345
|
+
any other engine does not, and the request queues instead (`steered:
|
|
1346
|
+
false`). A message that arrives when the turn is already finishing, too
|
|
1347
|
+
late for the engine to read it, becomes an ordinary queued turn of its
|
|
1348
|
+
own — nothing is dropped. Sub-agent and voice turns are steerable like
|
|
1349
|
+
any other; `agent_ask` calls are not steered (their answer must come
|
|
1350
|
+
from a turn of their own).
|
|
1351
|
+
|
|
1352
|
+
The web composer shows a **steer / queue** toggle next to Send while a
|
|
1353
|
+
turn runs: "steer" = the next message steers, "queue" = it queues. The agent's
|
|
1354
|
+
`steering:` setting in `agent.yaml` is the default position (see
|
|
1355
|
+
[agents.md](agents.md)).
|
|
1356
|
+
|
|
1357
|
+
#### Queuing
|
|
1358
|
+
|
|
1359
|
+
Sends on a `(agent, session)` that already has a turn running are
|
|
1360
|
+
**enqueued**, not rejected. The server holds a per-session lock with
|
|
1361
|
+
one FIFO queue, in arrival order, and every turn takes the same path
|
|
1362
|
+
into it: typed and dictated messages, `agent_ask` calls, sub-agent
|
|
1363
|
+
briefs, sentinel fires, tmux and browser wakes, voice consults and the
|
|
1364
|
+
wake-ups that bring a late answer, a finished sub-agent or a rendered
|
|
1365
|
+
video back. No origin jumps ahead of another. Turns are labelled by
|
|
1366
|
+
where they came from, for diagnostics only (`activePriority` in
|
|
1367
|
+
`/health`):
|
|
1368
|
+
- `user` — a person typing or dictating (no `from_agent`, no system
|
|
1369
|
+
origin)
|
|
1370
|
+
- `agent` — everything else
|
|
1371
|
+
|
|
1372
|
+
The currently-running turn always finishes — preempting would corrupt
|
|
1373
|
+
JSONL — so a queued turn starts only after the lock holder releases.
|
|
1374
|
+
Where a turn came from is recorded on its `user_message` as `origin`
|
|
1375
|
+
(see `GET /chat/stream`).
|
|
1376
|
+
|
|
1377
|
+
Every turn is an entry in one work ledger, whoever started it.
|
|
1378
|
+
`GET /agents/:agent/sessions/:session/work` shows the running entry,
|
|
1379
|
+
the waiters in order, the answers about to arrive and the sub-agents
|
|
1380
|
+
and `agent_ask` calls the session started; `/health` lists the waiters
|
|
1381
|
+
of every session next to its counters; and `DELETE /chat/queue/:id`
|
|
1382
|
+
takes any waiting entry out again.
|
|
1383
|
+
|
|
1384
|
+
Clients can opt into rendering a queue indicator by listening for the
|
|
1385
|
+
`turn_queued` SSE event (see below). UIs without it still work; the
|
|
1386
|
+
turn runs eventually, just without a visible "waiting" hint.
|
|
1387
|
+
|
|
1388
|
+
### `DELETE /chat/queue/:id`
|
|
1389
|
+
|
|
1390
|
+
Take a waiting turn back before it starts, whoever queued it. `:id` is
|
|
1391
|
+
the work id the queue views show: the `turnId` that `POST /chat/send`
|
|
1392
|
+
returned for a typed message, the `call_id` of an `agent_ask`, the
|
|
1393
|
+
`task_id` of a sub-agent brief or a sentinel fire. Nothing is written
|
|
1394
|
+
to the session — the message never became a turn.
|
|
1395
|
+
|
|
1396
|
+
Without a body the request acts as the person and may remove anything.
|
|
1397
|
+
With a body `{"requesting_agent": "<name>"}` it acts as that agent and
|
|
1398
|
+
may remove only entries that agent asked for itself; anything else is
|
|
1399
|
+
`403 {ok: false, reason: "forbidden"}`. This is what `agent_ask_cancel`
|
|
1400
|
+
sends.
|
|
1401
|
+
|
|
1402
|
+
- `200 {ok: true, id, kind, agent, session, text?, attachments?}` —
|
|
1403
|
+
the waiter is gone. For a typed message (`kind: "human"`) the payload
|
|
1404
|
+
comes back with `text` and `attachments: [{hash, name, mime, size}]`,
|
|
1405
|
+
so the client can put it into its composer (attachment refs are still
|
|
1406
|
+
valid, no re-upload needed). `turnId` carries the same id for older
|
|
1407
|
+
clients.
|
|
1408
|
+
- `409 {ok: false, reason: "already_started"}` — the lock went to this
|
|
1409
|
+
turn meanwhile; it is running. `POST /chat/abort` is the tool now.
|
|
1410
|
+
With a body `{"requesting_agent": "<name>", "withdraw_running": true}`
|
|
1411
|
+
(what `agent_ask_cancel` sends) a running call of that agent's own is
|
|
1412
|
+
instead **withdrawn**: `200 {ok: true, state: "withdrawn", id, turnId,
|
|
1413
|
+
agent, session, steered, steerId?, ranMs}` — its outcome wakes the
|
|
1414
|
+
requester no more, and when the target's turn reads its steer inbox
|
|
1415
|
+
(`steered: true`) a stop message is put there with a `steer_queued`
|
|
1416
|
+
SSE event like any steered message; the turn is not aborted. `403`
|
|
1417
|
+
when the call is not that agent's.
|
|
1418
|
+
- `404 {ok: false, reason: "unknown"}` — nothing waits under that id
|
|
1419
|
+
(started, finished, or never queued here).
|
|
1420
|
+
|
|
1421
|
+
Whoever asked for a removed entry is told:
|
|
1422
|
+
|
|
1423
|
+
- an `agent_ask`, on the line or already pending, reads
|
|
1424
|
+
`state: "failed"` with `error: "removed from the queue by the user
|
|
1425
|
+
before it started"` — as its inline result, through
|
|
1426
|
+
`agent_ask_result` and through `GET /a2a/ask-result`; an asker that
|
|
1427
|
+
had already stopped waiting is woken with an `[agent answer]` turn
|
|
1428
|
+
saying so, the same way it would have been woken with the answer;
|
|
1429
|
+
- a sub-agent brief reads `cancelled` with the same error in
|
|
1430
|
+
`subagent_status`, `subagent_result` and `/spawn-status`, and its
|
|
1431
|
+
parent is woken with a `[subagent attention]` turn saying there is
|
|
1432
|
+
no result;
|
|
1433
|
+
- a sentinel fire is recorded in the trigger's history as `skipped`
|
|
1434
|
+
with `skipReason: "removed from the queue by the user"`;
|
|
1435
|
+
- a wake-up turn is dropped quietly; the result it was bringing stays
|
|
1436
|
+
readable.
|
|
1437
|
+
|
|
1438
|
+
Side effects on success: a `turn_dequeued` SSE event for every open
|
|
1439
|
+
client on the session, followed by fresh `turn_queued` events for the
|
|
1440
|
+
typed messages that moved up (their `ahead` shrank).
|
|
1441
|
+
|
|
1442
|
+
### `POST /chat/send-sync`
|
|
1443
|
+
|
|
1444
|
+
Synchronous variant. Waits for the turn to finish and returns the
|
|
1445
|
+
full result inline. Slower (you block on it) but simpler for clients
|
|
1446
|
+
that don't want to manage SSE.
|
|
1447
|
+
|
|
1448
|
+
```bash
|
|
1449
|
+
curl -X POST https://<host>:18737/chat/send-sync \
|
|
1450
|
+
-H 'Content-Type: application/json' \
|
|
1451
|
+
-d '{"agent":"<your-agent>","session":"main","text":"…"}'
|
|
1452
|
+
```
|
|
1453
|
+
|
|
1454
|
+
Body fields: same as `/chat/send` (`agent`, `session`, `text`,
|
|
1455
|
+
`attachments`, `from_agent`, `agent_ask_call_id`, `subagent_depth`),
|
|
1456
|
+
plus:
|
|
1457
|
+
|
|
1458
|
+
- `model` (optional) — an alias or `provider/id` from config.yaml that
|
|
1459
|
+
answers this one turn instead of the session's model.
|
|
1460
|
+
- `max_rounds` (optional) — per-turn override of `agentLoop.maxRounds`.
|
|
1461
|
+
|
|
1462
|
+
- `attachments` (optional) — refs from `POST /attachments`, exactly as
|
|
1463
|
+
on `/chat/send`. This is the route the A2A tools use, so it is also
|
|
1464
|
+
how one agent hands another a picture the receiving model has to
|
|
1465
|
+
actually see. A target whose model has no vision gets the vision
|
|
1466
|
+
worker's description instead, the same as for a chat attachment.
|
|
1467
|
+
Agents normally do not build this by hand: `agent_ask` and
|
|
1468
|
+
`spawn_subagent` take `images: ["/absolute/path.png"]` and upload for
|
|
1469
|
+
them (see [agents.md](agents.md)).
|
|
1470
|
+
- `from_session` (optional, A2A) — the session the asking agent wrote
|
|
1471
|
+
from (id or `main`). Persisted as `user_message.from_session` and
|
|
1472
|
+
shown to the target in the attribution header
|
|
1473
|
+
(`[Message from agent <other-agent>, session <slug>]`) so it can address
|
|
1474
|
+
a follow-up. The server composes that header into the turn's frame
|
|
1475
|
+
(the stored row's `ephemeral`, see `user_message` under `GET
|
|
1476
|
+
/chat/stream`); the stored `text` is the message itself. Ignored
|
|
1477
|
+
without `from_agent`.
|
|
1478
|
+
- `waiter_agent` / `waiter_session` (optional, A2A) — identify the
|
|
1479
|
+
caller turn that blocks on this request. Used by `agent_ask` and
|
|
1480
|
+
`spawn_subagent` internally to register the wait in the server's
|
|
1481
|
+
deadlock guard; set both or neither.
|
|
1482
|
+
- `create_session` (optional, default false) — when `session` is a
|
|
1483
|
+
named slug that does not exist on the target yet, create it (with
|
|
1484
|
+
the standard timestamped id) and deliver the message into it. Only
|
|
1485
|
+
slugs: `main` always exists, exact ids and `sub-*` names answer
|
|
1486
|
+
`400`. The target is told beside its first message — in the turn's
|
|
1487
|
+
frame, not in the stored text — that the session was just created
|
|
1488
|
+
(`[Your session '<slug>' was just created by <agent> for this
|
|
1489
|
+
conversation; it runs on model <model>.]`).
|
|
1490
|
+
- `create_model` (optional, with `create_session`) — alias or
|
|
1491
|
+
`provider/id` pinned on the session **if this call creates it**
|
|
1492
|
+
(same effect as `PUT …/sessions/:session/model`). An unknown model
|
|
1493
|
+
is `400 {error, known_models}` and nothing is created. When the
|
|
1494
|
+
session already exists the model is ignored and the response
|
|
1495
|
+
carries `session_note` saying so.
|
|
1496
|
+
- `detach` (optional, with `from_agent` and `agent_ask_call_id`) —
|
|
1497
|
+
hand the message over and return at once instead of waiting for the
|
|
1498
|
+
reply: `202 {call_id, state: "pending", session_id,
|
|
1499
|
+
session_created?, session_model?, session_note?}`. The turn queues and
|
|
1500
|
+
runs as usual; the asker is woken with an `[agent answer]` turn when
|
|
1501
|
+
the reply lands (the record line names the target, the session and
|
|
1502
|
+
the first words of the answer; the instruction to read the whole
|
|
1503
|
+
answer with `agent_ask_result` accompanies it as the turn's frame),
|
|
1504
|
+
or reads it with `GET /a2a/ask-result`. This is `agent_ask` with
|
|
1505
|
+
`wait: false`. Ignored without the two A2A fields.
|
|
1506
|
+
|
|
1507
|
+
The success response is the turn result plus `session_id` (the
|
|
1508
|
+
resolved id), `session_created: true` and `session_model` when this
|
|
1509
|
+
call created the session, or `session_note` when `create_model` was
|
|
1510
|
+
ignored.
|
|
1511
|
+
|
|
1512
|
+
An unknown `session` answers `404` with the target's existing,
|
|
1513
|
+
non-archived session slugs, so a caller that guessed wrong can correct
|
|
1514
|
+
itself instead of retreating to `main`:
|
|
1515
|
+
|
|
1516
|
+
```json
|
|
1517
|
+
{ "error": "session 'reserch' not found for agent '<other-agent>'",
|
|
1518
|
+
"known_sessions": ["main", "research", "somora-dev"] }
|
|
1519
|
+
```
|
|
1520
|
+
|
|
1521
|
+
When `waiter_*` are present and the request would close a wait cycle
|
|
1522
|
+
(the target is already — directly or through a chain of waits —
|
|
1523
|
+
blocked on the caller), the server responds `409` instead of
|
|
1524
|
+
deadlocking:
|
|
1525
|
+
|
|
1526
|
+
```json
|
|
1527
|
+
{ "error": "circular A2A wait: …", "circular_wait": true,
|
|
1528
|
+
"chain": ["scribe/main", "coach/main", "scribe/main"] }
|
|
1529
|
+
```
|
|
1530
|
+
|
|
1531
|
+
Response on success: the full turn result (`finalText`, `usage`,
|
|
1532
|
+
`model`, `ms`, …). A call that a person removes from the target's
|
|
1533
|
+
queue before it starts (`DELETE /chat/queue/:id`) answers `200` with
|
|
1534
|
+
`outcome: "failed"`, `dequeued: true` and `error: "removed from the
|
|
1535
|
+
queue by the user before it started"`.
|
|
1536
|
+
|
|
1537
|
+
### Sub-agent tasks — `/spawn-*`
|
|
1538
|
+
|
|
1539
|
+
The HTTP twins of the `spawn_subagent` / `subagent_*` tools. Every
|
|
1540
|
+
spawn is one of these tasks, whether the tool was called with
|
|
1541
|
+
`wait: false` or `wait: true` — a synchronous spawn registers the task,
|
|
1542
|
+
runs it in the background and waits for it through the result route,
|
|
1543
|
+
which is why it is listed, stoppable and cancellable like any other
|
|
1544
|
+
task while the parent waits. Agents
|
|
1545
|
+
running in an MCP child (claude-cli, codex-cli) reach the task store
|
|
1546
|
+
this way; a custom client can use them to run a sealed background
|
|
1547
|
+
task in a fresh session and collect the result.
|
|
1548
|
+
|
|
1549
|
+
#### `POST /spawn-async`
|
|
1550
|
+
|
|
1551
|
+
Body: `agent` and `session` (required — a slug that does not exist is
|
|
1552
|
+
created with the standard timestamped id; an exact id that is gone is
|
|
1553
|
+
a `404`), `text` (the task), optional `from_agent`, `parent_agent` +
|
|
1554
|
+
`parent_session` (who to report back to; default the caller),
|
|
1555
|
+
`subagent_depth`, `model` (override), `max_rounds`, `attention`
|
|
1556
|
+
(`false` suppresses the `[subagent attention]` wake of the parent), and
|
|
1557
|
+
`attachments` (refs from `POST /attachments` — pictures that belong to
|
|
1558
|
+
the brief).
|
|
1559
|
+
|
|
1560
|
+
Returns `202 {task_id}` at once; the turn runs in the background under
|
|
1561
|
+
the target session's lock. `429` when the per-agent concurrent spawn
|
|
1562
|
+
cap is full.
|
|
1563
|
+
|
|
1564
|
+
#### `GET /spawn-status?task_id=…`
|
|
1565
|
+
|
|
1566
|
+
`{task_id, state, parent_agent, parent_session, target_agent,
|
|
1567
|
+
target_session, started_at, finished_at?, error?}` — `state` is
|
|
1568
|
+
`running`, `done`, `failed` or `cancelled`. `404` for an unknown id.
|
|
1569
|
+
|
|
1570
|
+
#### `GET /spawn-result?task_id=…`
|
|
1571
|
+
|
|
1572
|
+
Same fields plus `result` (the full turn result: `finalText`,
|
|
1573
|
+
`outcome`, `tool_calls`, `files_written`, `media`, `usage`, …) once
|
|
1574
|
+
terminal. `result.follow_ups: string[]` (oldest first) holds texts
|
|
1575
|
+
that reached the parent after the sub's report: the outcome of work
|
|
1576
|
+
the sub started and did not wait for — its own subs, agents it asked.
|
|
1577
|
+
Each one is announced to the parent with a `[subagent attention]`
|
|
1578
|
+
wake whose text says `Task '<task_id>' … has a follow-up: the work it
|
|
1579
|
+
started has finished. It begins: "…"` and whose frame reads `Fetch it
|
|
1580
|
+
with subagent_result({ task_id: "<task_id>" }) — the follow-up is in
|
|
1581
|
+
its follow_ups field — then continue whatever depended on it. If nothing
|
|
1582
|
+
does, a short acknowledgement to the user is enough.` (see
|
|
1583
|
+
[agents.md](agents.md)). A task still running answers
|
|
1584
|
+
`409 {task_id, state: "running", error}`. `wait_until_done=1` +
|
|
1585
|
+
`timeout_ms` block server-side (capped at
|
|
1586
|
+
`agentLoop.longTaskMaxTimeoutMs`); with `waiter_agent` /
|
|
1587
|
+
`waiter_session` the wait joins the deadlock guard and a cycle answers
|
|
1588
|
+
`409 {circular_wait: true, chain}`. Reading a terminal result here
|
|
1589
|
+
cancels the parent's pending `[subagent attention]` wake.
|
|
1590
|
+
|
|
1591
|
+
#### `GET /spawn-list?parent_agent=…`
|
|
1592
|
+
|
|
1593
|
+
`{tasks: [entry]}` — every task this agent spawned since server start
|
|
1594
|
+
(the store is in-memory).
|
|
1595
|
+
|
|
1596
|
+
#### `POST /spawn-cancel`
|
|
1597
|
+
|
|
1598
|
+
Body: `task_id`, optional `requesting_agent` (an agent must be the
|
|
1599
|
+
spawning agent — otherwise `403`; without it the request acts as a
|
|
1600
|
+
person and the parent reads `stopped by the user`), optional `reason`.
|
|
1601
|
+
Cancels the task — a running
|
|
1602
|
+
turn is aborted, a task still waiting in its session's queue is taken
|
|
1603
|
+
out of it — and cascades to child spawns; returns `{cancelled: [task_ids],
|
|
1604
|
+
skipped: [{task_id, state}]}` (tasks that were already terminal are
|
|
1605
|
+
skipped). Disk artifacts stay.
|
|
1606
|
+
|
|
1607
|
+
### `GET /a2a/ask-result`
|
|
1608
|
+
|
|
1609
|
+
Outcome of an `agent_ask` call by `call_id` — backs the
|
|
1610
|
+
`agent_ask_result` tool.
|
|
1611
|
+
|
|
1612
|
+
A call whose asker stopped waiting (`agent_ask` returned `pending`) does
|
|
1613
|
+
not depend on anyone remembering to poll: when the answer lands, the
|
|
1614
|
+
asker is woken in the session it asked from, with the first lines and
|
|
1615
|
+
the `call_id`. Reading the result — here or through the tool — cancels
|
|
1616
|
+
that wake, and a caller still on the line never gets one, because the
|
|
1617
|
+
answer reaches it as its tool result.
|
|
1618
|
+
|
|
1619
|
+
A `done` call may be followed later by a **follow-up**: when the target
|
|
1620
|
+
answered "I am working on it and will report back" and the work it
|
|
1621
|
+
started while answering — sub-agents, calls of its own, and whatever
|
|
1622
|
+
those start — finishes after its reply, the asker receives the outcome
|
|
1623
|
+
once, as an ordinary message from the target into the session it asked
|
|
1624
|
+
from. That message is a normal turn with `origin: { kind: "agent",
|
|
1625
|
+
from: { agent, session }, callId }` where `callId` is this `call_id`
|
|
1626
|
+
and `text` is the follow-up; its frame is the `[Follow-up on the
|
|
1627
|
+
question you sent earlier (call_id "…"): …]` note quoted under
|
|
1628
|
+
`user_message` in `GET /chat/stream`. Nobody waits for it, so `DELETE
|
|
1629
|
+
/chat/queue/:id` on it wakes no one. It is not sent when the asker was
|
|
1630
|
+
a person, when the call did not finish `done`, when the target already
|
|
1631
|
+
wrote to the asker itself in the meantime, when the asker read this
|
|
1632
|
+
route during the wake grace, or after a server restart (a restart
|
|
1633
|
+
instead wakes the asker once with a failure note, see agents.md); a follow-up
|
|
1634
|
+
whose reporting turn failed says so, with the error, in place of the
|
|
1635
|
+
text.
|
|
1636
|
+
|
|
1637
|
+
```
|
|
1638
|
+
GET /a2a/ask-result?call_id=<uuid>
|
|
1639
|
+
GET /a2a/ask-result?call_id=<uuid>&wait_until_done=1&timeout_ms=300000
|
|
1640
|
+
GET /a2a/ask-result?call_id=<uuid>&agent=<target>&session=<slug> # after a restart
|
|
1641
|
+
```
|
|
1642
|
+
|
|
1643
|
+
```json
|
|
1644
|
+
{ "call_id": "…", "state": "done", "target_agent": "<other-agent>",
|
|
1645
|
+
"target_session": "20260906-172957_research", "started_at": 1788…,
|
|
1646
|
+
"finished_at": 1788…, "response": "…", "outcome": "completed", "source": "registry" }
|
|
1647
|
+
```
|
|
1648
|
+
|
|
1649
|
+
`state` is `queued` (behind another turn on the target session),
|
|
1650
|
+
`running`, `done` or `failed`. A `failed` call carries `error`; the
|
|
1651
|
+
value `stopped by the user` means a person pressed Stop on the target's
|
|
1652
|
+
turn, and `removed from the queue by the user before it started` that a
|
|
1653
|
+
person took the waiting call out of the target's queue — the target
|
|
1654
|
+
never saw it. Neither is something to retry on the agent's own. The
|
|
1655
|
+
live registry is fed by `/chat/send-sync`
|
|
1656
|
+
and by `/chat/send` when it carries an `agent_ask_call_id`; when it has
|
|
1657
|
+
no record (server restarted since the
|
|
1658
|
+
call) pass `agent` + `session` and the route reads the target's JSONL
|
|
1659
|
+
(`user_message.agent_ask_call_id`) — `source: "history"`, and `state`
|
|
1660
|
+
becomes `unknown` when the turn never reached `turn_end`. With
|
|
1661
|
+
`wait_until_done` the request blocks until the call finishes or
|
|
1662
|
+
`timeout_ms` passes; `waiter_agent` / `waiter_session` register the
|
|
1663
|
+
wait in the deadlock guard, and a cycle answers `409` with
|
|
1664
|
+
`circular_wait: true` like `/spawn-result`.
|
|
1665
|
+
|
|
1666
|
+
### `GET /a2a/turn-origin/:agent/:session`
|
|
1667
|
+
|
|
1668
|
+
Who started the turn currently running on `agent/session`: the A2A
|
|
1669
|
+
asker (`from_agent`/`from_session` of the live turn, `kind: "a2a"`),
|
|
1670
|
+
for a sub-agent session the spawning parent from its spawn meta
|
|
1671
|
+
(`kind: "subagent"`), or — when the turn is an `[agent answer]` wake —
|
|
1672
|
+
the agent and session whose answer woke it (`kind: "wake"`), so a reply
|
|
1673
|
+
written from the wake turn goes back to the conversation it belongs to.
|
|
1674
|
+
|
|
1675
|
+
```json
|
|
1676
|
+
{ "origin": { "agent": "<other-agent>", "session": "20260906-172957_research", "kind": "a2a" } }
|
|
1677
|
+
{ "origin": null }
|
|
1678
|
+
```
|
|
1679
|
+
|
|
1680
|
+
`agent_ask` calls this when its `session` argument is omitted: if the
|
|
1681
|
+
target is the origin agent, the message goes back to the origin
|
|
1682
|
+
session instead of `main` (logged as `agent_ask.session_inferred`,
|
|
1683
|
+
reported as `session_inferred: true` in the tool result). An explicit
|
|
1684
|
+
`session` always wins. Every `agent_ask` result names the rule that
|
|
1685
|
+
applied as `routing_reason`: `explicit`, `reply_to_origin`, or
|
|
1686
|
+
`default_main` — the last with a `routing_note` when the caller sits in
|
|
1687
|
+
a non-main session, since a turn started by tmux, sentinel, a wake or a
|
|
1688
|
+
person has no origin and its report would land in the target's `main`
|
|
1689
|
+
unannounced.
|
|
1690
|
+
|
|
1691
|
+
### `GET /chat/stream`
|
|
1692
|
+
|
|
1693
|
+
Server-Sent Events stream for a single `(agent, session)`. Subscribe
|
|
1694
|
+
once per chat window you want to display.
|
|
1695
|
+
|
|
1696
|
+
```bash
|
|
1697
|
+
curl -N "https://<host>:18737/chat/stream?agent=<your-agent>&session=main"
|
|
1698
|
+
```
|
|
1699
|
+
|
|
1700
|
+
Event types:
|
|
1701
|
+
- `chat` — `{state: 'delta'|'final', text}` — streaming assistant
|
|
1702
|
+
output
|
|
1703
|
+
- `agent` — `{phase: 'start'|'end', usage?, contextWindow?, provider?,
|
|
1704
|
+
model?, thinking?, fallback?}` — turn lifecycle around the model call.
|
|
1705
|
+
`usage` carries `tokens_in`, `tokens_out`, optional `tokens_in_cached`,
|
|
1706
|
+
`tokens_out_reasoning` (+`_estimated`) and `context_tokens`. Read them
|
|
1707
|
+
as two different things: `tokens_in`/`tokens_out` are what the turn
|
|
1708
|
+
SPENT, summed over every request it made, so a tool-using turn exceeds
|
|
1709
|
+
the window several times over. `context_tokens` is OCCUPANCY, the
|
|
1710
|
+
prompt size of the turn's last request, and is the only one to compare
|
|
1711
|
+
against `contextWindow`. All three engines report it; a client should
|
|
1712
|
+
still treat it as optional.
|
|
1713
|
+
- `user_message` — `{text, ts, turnId?, origin?, input?, from_agent?,
|
|
1714
|
+
from_session?, from_system?, agent_ask_call_id?, steer?, steer_id?}`
|
|
1715
|
+
— broadcast when a turn's user_message is written to JSONL. `steer:
|
|
1716
|
+
true` marks a message that was handed into the running turn `turnId`
|
|
1717
|
+
(see *Steering* under `POST /chat/send`); `steer_id` pairs it with the
|
|
1718
|
+
`steer_queued` event and the send response. `input` is
|
|
1719
|
+
`{modality?: 'text'|'voice', source?: 'stt'|'realtime'}` when the
|
|
1720
|
+
turn was not typed — `stt` is the microphone button, `realtime` a
|
|
1721
|
+
sentence from a standing call — so the live bubble and the one
|
|
1722
|
+
rebuilt from history render the same way. Self-typed sends, A2A
|
|
1723
|
+
inbounds, and system wakes all flow through here; `from_system` is
|
|
1724
|
+
one of `sentinel`, `tmux`, `subagent`, `job`, `browser`, `voice`,
|
|
1725
|
+
`a2a`, and web, mobile and TUI draw each of them as a divider rather
|
|
1726
|
+
than a bubble. `turnId` lets a sending client match this event to
|
|
1727
|
+
the optimistic bubble it rendered after `POST /chat/send` (which
|
|
1728
|
+
echoes the same id).
|
|
1729
|
+
|
|
1730
|
+
`text` is the record of the turn: what a person typed, what an agent
|
|
1731
|
+
asked, what a trigger's prompt says, or the one-line statement of a
|
|
1732
|
+
wake-up. It is what the dream phase learns from, what recall is
|
|
1733
|
+
built from and what a reader sees. Everything the model is told
|
|
1734
|
+
*about* the turn — who wrote it, why it arrives now, what to do with
|
|
1735
|
+
it — is the turn's **frame**, and the frame travels in the stored
|
|
1736
|
+
row's `ephemeral` field beside the memory-recall block (frame first,
|
|
1737
|
+
then the recall block), never in `text`. Every engine puts
|
|
1738
|
+
`ephemeral` in front of the user message, and it replays
|
|
1739
|
+
byte-identically on later turns, so caching is unaffected. Per
|
|
1740
|
+
origin the frame is: the `[Message from agent <name>, session
|
|
1741
|
+
<slug>]` header and, for a session `agent_ask` created, the
|
|
1742
|
+
`[Your session '<slug>' was just created by …]` note, or for a
|
|
1743
|
+
follow-up on an earlier call the `[Follow-up on the question you
|
|
1744
|
+
sent earlier (call_id "…"): …]` note (`agent`, see below); the
|
|
1745
|
+
evidence block of a sentinel fire (`sentinel`); the inspect-now
|
|
1746
|
+
instructions of a tmux wake (`tmux`); the take-a-fresh-snapshot
|
|
1747
|
+
advice of a browser hand-back (`browser`); the call framing of a
|
|
1748
|
+
voice consult (`voice`); and the "read the whole answer with
|
|
1749
|
+
`agent_ask_result(…)`" / "fetch the full answer with
|
|
1750
|
+
`subagent_result(…)`" instruction of a wake-up (`wake`). `human` and
|
|
1751
|
+
`subagent` turns carry no frame. The SSE event carries `text` and
|
|
1752
|
+
`origin`; `ephemeral` is on the stored row only.
|
|
1753
|
+
|
|
1754
|
+
`origin` says where the turn came from as one value. It is present on
|
|
1755
|
+
the SSE event and on the stored `user_message` row of every turn;
|
|
1756
|
+
rows recorded by earlier releases have none, so a client keeps
|
|
1757
|
+
reading `from_*` as the fallback.
|
|
1758
|
+
|
|
1759
|
+
```ts
|
|
1760
|
+
origin?:
|
|
1761
|
+
| { kind: 'human'; via: 'chat' | 'voice-stt' }
|
|
1762
|
+
| { kind: 'agent'; from: { agent: string; session?: string }; callId?: string }
|
|
1763
|
+
| { kind: 'subagent'; parent?: { agent: string; session: string }; taskId?: string; depth: number }
|
|
1764
|
+
| { kind: 'sentinel'; triggerId: string; taskId: string; triggerName?: string }
|
|
1765
|
+
| { kind: 'tmux'; tmuxSession: string; tmuxKind?: string }
|
|
1766
|
+
| { kind: 'browser'; viewId: string; cause: 'handoff' | 'activity'; handoffId?: string }
|
|
1767
|
+
| { kind: 'voice'; callId?: string; consultId: string }
|
|
1768
|
+
| { kind: 'wake'; about: 'a2a' | 'subagent' | 'job'; ref: string; depth?: number };
|
|
1769
|
+
```
|
|
1770
|
+
|
|
1771
|
+
`human` is a person typing (`chat`) or dictating (`voice-stt`).
|
|
1772
|
+
`agent` is an `agent_ask` — or a follow-up on one: when the target
|
|
1773
|
+
answered and work it started while answering (sub-agents, calls of
|
|
1774
|
+
its own) finishes later, the target's session sends the asker one
|
|
1775
|
+
more turn with `origin.kind: "agent"` and `callId` = the original
|
|
1776
|
+
call. Its `text` is the follow-up itself; its frame, beside the
|
|
1777
|
+
`[Message from agent …]` header, is `[Follow-up on the question you
|
|
1778
|
+
sent earlier (call_id "<id>"): the work it started has finished.
|
|
1779
|
+
Below is its result — treat it as the answer to that question.
|
|
1780
|
+
Continue whatever depended on it; if nothing does, tell your human
|
|
1781
|
+
in one line.]`. It is broadcast as a `user_message` like any agent
|
|
1782
|
+
turn; there is no separate event. `subagent` a sealed brief running
|
|
1783
|
+
in its own `sub-…` session; `sentinel`, `tmux`, `browser` and `voice` the
|
|
1784
|
+
four system triggers; `wake` brings something the agent started
|
|
1785
|
+
earlier back to it — a late `agent_ask` answer (`ref` = call id), a
|
|
1786
|
+
finished async sub-agent (`ref` = task id) or a rendered video
|
|
1787
|
+
(`ref` = job id) — and, with `about: "subagent"`, a follow-up on a
|
|
1788
|
+
finished sub whose own work finished later (the text reads `Task
|
|
1789
|
+
'<id>' … has a follow-up: the work it started has finished. It
|
|
1790
|
+
begins: "…"`, and the frame points at the `follow_ups` field of `subagent_result`). The
|
|
1791
|
+
legacy fields stay and are derived from it:
|
|
1792
|
+
`agent` fills `from_agent`, `from_session` and `agent_ask_call_id`
|
|
1793
|
+
(= `callId`); `sentinel`, `tmux`, `browser` and `voice` set
|
|
1794
|
+
`from_system` to the same word; `wake` sets `from_system` to its
|
|
1795
|
+
`about`; `human` and `subagent` set none of them.
|
|
1796
|
+
- `steer_queued` — `{steerId, text, ts, turnId, origin}` — fired when
|
|
1797
|
+
`POST /chat/send` with `steer: true` accepted a message for the turn
|
|
1798
|
+
`turnId` that is running. Not yet in the session file: the matching
|
|
1799
|
+
`user_message` with `steer: true` and the same `steer_id` follows
|
|
1800
|
+
once the engine has handed the text to the model. Other windows on
|
|
1801
|
+
the session render a pending bubble from this.
|
|
1802
|
+
- `builder_state` — `{mode, phase, planPath}` — a builder session's
|
|
1803
|
+
mode or phase changed, or its plan file was set (see *Builder
|
|
1804
|
+
sessions*).
|
|
1805
|
+
- `todo_updated` — `{todos: [{content, status, priority?}], by?}` — the
|
|
1806
|
+
builder replaced its task list (`todo_write`).
|
|
1807
|
+
- `question_asked` — `{questionId, question, header?, options, multiple,
|
|
1808
|
+
expiresAt}` — the builder is waiting for the person (`ask_user`);
|
|
1809
|
+
answer with `POST …/answer`.
|
|
1810
|
+
- `question_answered` — `{questionId, answered}` — the open question
|
|
1811
|
+
was answered.
|
|
1812
|
+
- `turn_queued` — `{turnId, ahead, workId?, kind?}` — fired when `POST /chat/send`
|
|
1813
|
+
hit a busy lock and the turn had to wait. `ahead` is the number
|
|
1814
|
+
of turns this one must wait for (≥1, includes the currently-
|
|
1815
|
+
running one). Static snapshot at enqueue time, not updated as
|
|
1816
|
+
the queue drains — except after a `DELETE /chat/queue/:id`,
|
|
1817
|
+
which re-emits it for the waiters that moved up. Clients render
|
|
1818
|
+
`"queued · N ahead"` until the matching `user_message` event
|
|
1819
|
+
arrives (= the turn is now actually running, lock acquired).
|
|
1820
|
+
- `turn_dequeued` — `{turnId, workId}` — a waiting entry was taken
|
|
1821
|
+
back via `DELETE /chat/queue/:id`, whoever queued it; both fields
|
|
1822
|
+
carry the removed entry's id. Clients drop the optimistic bubble for
|
|
1823
|
+
a typed message with that id and refresh their queue view.
|
|
1824
|
+
- `turn_started` — `{turnId}` — the engine opened the turn; this is
|
|
1825
|
+
the engine's own id (`t-…`), the one `assistant_media`,
|
|
1826
|
+
`assistant_audio`, `turn_error` and the session file's `turn_end`
|
|
1827
|
+
carry. Clients stamp the assistant bubble they are about to build
|
|
1828
|
+
with it, so artifacts that arrive after the turn closed pair to
|
|
1829
|
+
THIS turn instead of "the most recent bubble".
|
|
1830
|
+
- `turn_error` — `{turnId?, message, engine}` — the turn ended with an
|
|
1831
|
+
error instead of (or after) an assistant message. The `status`
|
|
1832
|
+
event still carries the same text (`error: …` / `turn failed: …`)
|
|
1833
|
+
for older clients; this one adds the turn id so the failure can be
|
|
1834
|
+
rendered as a block inside the right turn.
|
|
1835
|
+
- `session_model` — `{model, resolved?, source}` — the session's model
|
|
1836
|
+
override was set (`PUT …/model`) or cleared (`DELETE …/model`,
|
|
1837
|
+
`model: null`, `source: "persona-default"`). Sent to every subscriber
|
|
1838
|
+
of the session, because the switch is often made from outside the
|
|
1839
|
+
window showing it (an orchestrator agent, another client). Clients
|
|
1840
|
+
re-read `GET …/model` and update their header.
|
|
1841
|
+
- `tool` — `{phase: 'call'|'result'|'error', tool, summary?,
|
|
1842
|
+
details?, error?}` — tool-call events
|
|
1843
|
+
- `thinking` — `{state: 'delta'|'final', text, truncated?}` — the
|
|
1844
|
+
model's reasoning text, cumulative deltas like `chat`; the `final`
|
|
1845
|
+
precedes the `chat` final of the same turn. Only engines that surface
|
|
1846
|
+
thinking send it; `thinkingContent.capture: false` in config.yaml
|
|
1847
|
+
suppresses it entirely. See [thinking.md](thinking.md).
|
|
1848
|
+
- `engine_meta` — `{engine, itemType, label, summary?, payload}` —
|
|
1849
|
+
engine-internal side-channel state. The canonical case is codex's
|
|
1850
|
+
`todo_list` (an internal plan/checklist the model updates mid-turn)
|
|
1851
|
+
— somora persists these so memory / REM-dream can read them later
|
|
1852
|
+
and clients can optionally render them. `label` is server-resolved
|
|
1853
|
+
(e.g. `todo_list` → `"plan"`); unknown item-types fall back to the
|
|
1854
|
+
raw `itemType`. `payload` is the engine's original event, opaque.
|
|
1855
|
+
Codex's own `error` notifications arrive as `error` — except those
|
|
1856
|
+
codex marks `willRetry`: a dropped stream it reconnects by itself is
|
|
1857
|
+
one `reconnecting` row per turn, and its switch to HTTPS after the
|
|
1858
|
+
retries is a `transport_fallback` row; neither is a failure.
|
|
1859
|
+
Besides engine-native items, somora emits its own: `model_switch`
|
|
1860
|
+
(codex thread continued under a new model), `thread_recreated` (the
|
|
1861
|
+
Codex thread no longer existed; a fresh one was started with the
|
|
1862
|
+
session history replayed), `tools_changed` (the agent's tool set
|
|
1863
|
+
changed — Abilities toggle, hub server, review loop, update — and
|
|
1864
|
+
Codex threads keep their tools, so a fresh thread was started with the
|
|
1865
|
+
history replayed), `mcp_server_renamed`
|
|
1866
|
+
(engine session rebuilt after somora's MCP server rename, label
|
|
1867
|
+
"session restarted"), `context_compacted` (history compacted after a
|
|
1868
|
+
context overflow — on `codex-cli` it means codex compacted its own
|
|
1869
|
+
thread and said so, which is otherwise invisible), `context_trimmed` (the oldest tool results in a
|
|
1870
|
+
running turn were shortened to keep the request inside the window —
|
|
1871
|
+
the turn continues, the model keeps the record that those tools already
|
|
1872
|
+
ran), `attachments_unsupported` (the engine cannot forward attachments,
|
|
1873
|
+
grok-cli), `voice_handover` (a call was handed to or
|
|
1874
|
+
from another agent), `voice_spoken` (what a voice call said out loud —
|
|
1875
|
+
found in sessions recorded by earlier releases), `reasoning_effort_adjusted` and `sampling_dropped`
|
|
1876
|
+
(backend rejected the parameter, turn retried without it). Each
|
|
1877
|
+
carries a human-readable `payload.text`.
|
|
1878
|
+
- `model_fallback` — `{requested, actual, reason, hops?}` (refs are
|
|
1879
|
+
`provider/modelId`) — the persona's primary model failed before
|
|
1880
|
+
producing anything and a configured `fallback:` model is answering
|
|
1881
|
+
this turn. `requested` is always the primary, `actual` the model
|
|
1882
|
+
now answering, `reason` the failure that triggered this hop. `hops`
|
|
1883
|
+
lists every model that failed so far, in order
|
|
1884
|
+
(`[{model, reason}, …]`, primary first) — with a fallback chain
|
|
1885
|
+
(`fallback: [a, b]`) one event is sent per hop and the last one
|
|
1886
|
+
carries the whole chain. Sent before the fallback's first delta;
|
|
1887
|
+
the following `agent` phase:'end' also carries `fallback` (same
|
|
1888
|
+
shape) and reports the ACTUAL `provider`/`model`. Persisted to
|
|
1889
|
+
history as the same kind, so a reload keeps the marker on that turn.
|
|
1890
|
+
- `memory` — `{count, topScore?, refs, fullText}` — the memory recall
|
|
1891
|
+
injected into this turn: number of hits, best fused score, the
|
|
1892
|
+
`source/slug` refs, and the full `<memory-context>` block text.
|
|
1893
|
+
Sent after `agent` phase:'start'; `count` is `0` with empty `refs`
|
|
1894
|
+
when recall found nothing.
|
|
1895
|
+
- `status` — `{msg}` — connection events, error notices
|
|
1896
|
+
- `heartbeat` — current ms timestamp, every `sse.heartbeatMs` (20 s). The
|
|
1897
|
+
server watches these writes: one that fails or stays pending for
|
|
1898
|
+
`sse.deadAfterMs` (60 s) marks the stream dead — it is closed and its
|
|
1899
|
+
socket destroyed, logged as `sse.disconnect {reason: 'dead'}`. On the
|
|
1900
|
+
TLS listener every HTTP/2 session is also PINGed (`sse.h2PingIntervalMs`)
|
|
1901
|
+
and destroyed when it stops answering (`sse.h2PingTimeoutMs`), and every
|
|
1902
|
+
socket carries TCP keepalive — a tab that vanished without closing is
|
|
1903
|
+
gone server-side in about a minute instead of never.
|
|
1904
|
+
|
|
1905
|
+
Tool names are normalised through the same path the wire serializer
|
|
1906
|
+
uses — clients receive `memory_search`, not
|
|
1907
|
+
`mcp__somora__memory_search`. Tool input/output payloads ride
|
|
1908
|
+
in the `details` field as pretty-printed JSON.
|
|
1909
|
+
|
|
1910
|
+
### `GET /activity/stream`
|
|
1911
|
+
|
|
1912
|
+
App-wide activity feed. One subscription per client gives streaming
|
|
1913
|
+
markers for every busy `(agent, session)` plus unread state for
|
|
1914
|
+
sessions the user hasn't viewed since new movement arrived. Distinct
|
|
1915
|
+
from `/chat/stream`, which is per-session and per-window.
|
|
1916
|
+
|
|
1917
|
+
```bash
|
|
1918
|
+
curl -N https://<host>:18737/activity/stream
|
|
1919
|
+
```
|
|
1920
|
+
|
|
1921
|
+
Event types:
|
|
1922
|
+
|
|
1923
|
+
- `streaming` — `{agent, session, phase: 'start'|'end'}` — emitted
|
|
1924
|
+
when any turn begins or ends on any session. Drives multi-agent
|
|
1925
|
+
streaming-dots in clients that aren't subscribed to every per-
|
|
1926
|
+
session `/chat/stream`.
|
|
1927
|
+
- `turn` — `{agent, session, unreadAt}` — a new unread-candidate
|
|
1928
|
+
event landed in the session's JSONL. Unread candidates are:
|
|
1929
|
+
- `chat:final` (assistant answer)
|
|
1930
|
+
- `user_message` with `from_agent` set (A2A peer wrote to us)
|
|
1931
|
+
- `user_message` with `from_system` set (`sentinel`, `tmux`,
|
|
1932
|
+
`subagent`, `job`, `browser`, `voice` or `a2a` woke us)
|
|
1933
|
+
Plain self-typed user messages, tool / memory / engine_meta events,
|
|
1934
|
+
and lifecycle (`agent:start`, `agent:end`) are excluded.
|
|
1935
|
+
- `seen` — `{agent, session, seenAt}` — broadcast when any client
|
|
1936
|
+
POSTs `/sessions/:agent/:session/seen`. Sibling clients clear
|
|
1937
|
+
their unread badge for that session.
|
|
1938
|
+
- `status` — `{msg}` — connection lifecycle.
|
|
1939
|
+
- `heartbeat` — current ms timestamp, every `sse.heartbeatMs`; same
|
|
1940
|
+
liveness rules as `/chat/stream`.
|
|
1941
|
+
|
|
1942
|
+
Unread state is persisted in the session's meta as `unreadAt` and
|
|
1943
|
+
`seenAt` (both ISO timestamps). A session is unread when
|
|
1944
|
+
`unreadAt > seenAt` (or `seenAt` is null). The persistence path is
|
|
1945
|
+
authoritative, so a server restart preserves the badge state.
|
|
1946
|
+
|
|
1947
|
+
### `POST /sessions/:agent/:session/seen`
|
|
1948
|
+
|
|
1949
|
+
Tell the server "I am looking at this session now". Updates `seenAt`
|
|
1950
|
+
in the session's meta and broadcasts a `seen` event on
|
|
1951
|
+
`/activity/stream` so other open clients clear their badge live.
|
|
1952
|
+
|
|
1953
|
+
```bash
|
|
1954
|
+
curl -X POST https://<host>:18737/sessions/<your-agent>/main/seen
|
|
1955
|
+
```
|
|
1956
|
+
|
|
1957
|
+
Optional body:
|
|
1958
|
+
|
|
1959
|
+
```json
|
|
1960
|
+
{ "ts": "2026-05-27T14:00:00.000Z" }
|
|
1961
|
+
```
|
|
1962
|
+
|
|
1963
|
+
`ts` lets a client claim an older "I last looked at this at …" time —
|
|
1964
|
+
useful for scrolling-into-view triggers where the wall-clock isn't
|
|
1965
|
+
exactly "now". The server clamps to `max(currentSeenAt, ts)`, so a
|
|
1966
|
+
later arrival can never regress the seen marker.
|
|
1967
|
+
|
|
1968
|
+
Response:
|
|
1969
|
+
|
|
1970
|
+
```json
|
|
1971
|
+
{ "ok": true, "agent": "<your-agent>", "session": "main", "seenAt": "2026-…" }
|
|
1972
|
+
```
|
|
1973
|
+
|
|
1974
|
+
### `GET /chat/history`
|
|
1975
|
+
|
|
1976
|
+
Snapshot of past events for a session. The TUI and web both
|
|
1977
|
+
hydrate this on open.
|
|
1978
|
+
|
|
1979
|
+
```bash
|
|
1980
|
+
curl "https://<host>:18737/chat/history?agent=<your-agent>&session=main"
|
|
1981
|
+
```
|
|
1982
|
+
|
|
1983
|
+
Rows are the session's JSONL events in order. A turn with thinking
|
|
1984
|
+
carries one `thinking_message` row (`{kind, ts, engine, text,
|
|
1985
|
+
truncated?}`) directly before its `assistant_message`; clients fold it
|
|
1986
|
+
onto that bubble.
|
|
1987
|
+
|
|
1988
|
+
```bash
|
|
1989
|
+
```
|
|
1990
|
+
|
|
1991
|
+
Pagination: pass `?limit=200` to get the last 200 events plus a
|
|
1992
|
+
`hasMore` + `oldestTs` cursor; subsequent calls supply
|
|
1993
|
+
`?before=<oldestTs>&limit=200` for older windows.
|
|
1994
|
+
|
|
1995
|
+
```json
|
|
1996
|
+
{
|
|
1997
|
+
"agent": "<your-agent>",
|
|
1998
|
+
"session": "20260511-093251_research-notes",
|
|
1999
|
+
"events": [...],
|
|
2000
|
+
"hasMore": true,
|
|
2001
|
+
"oldestTs": 1715512000000
|
|
2002
|
+
}
|
|
2003
|
+
```
|
|
2004
|
+
|
|
2005
|
+
Event kinds: `user_message`, `assistant_message`, `thinking_message`,
|
|
2006
|
+
`tool_call`, `tool_result`, `engine_meta`, `model_fallback` (precedes
|
|
2007
|
+
the assistant message the fallback model produced), `assistant_audio`,
|
|
2008
|
+
`assistant_media`, `project_switched`, `error`, `turn_start` and
|
|
2009
|
+
`turn_end`. Each carries `kind`, `ts`, and kind-specific fields. Tool names are normalised here too.
|
|
2010
|
+
`engine_meta` rows preserve the raw `itemType` + opaque `payload`;
|
|
2011
|
+
clients resolve the friendly label on render (see
|
|
2012
|
+
[setup.md](setup.md#engine-meta--codex-todo_list)).
|
|
2013
|
+
|
|
2014
|
+
### `POST /chat/abort`
|
|
2015
|
+
|
|
2016
|
+
Cancel an in-flight turn on a `(agent, session)`. The TUI fires it
|
|
2017
|
+
on ESC; web and mobile fire it from the Stop button overlaid on the
|
|
2018
|
+
streaming assistant bubble. Idempotent — returns `aborted: false`
|
|
2019
|
+
when no turn is running. Cancels the **currently-running** turn
|
|
2020
|
+
only; queued waiters keep their slots and still execute — a waiting
|
|
2021
|
+
entry is removed with `DELETE /chat/queue/:id` instead.
|
|
2022
|
+
|
|
2023
|
+
It stops whatever is running on the session, regardless of what
|
|
2024
|
+
started it — a command the turn is running through `exec` is killed with
|
|
2025
|
+
it (process group, `SIGTERM` then `SIGKILL`), on the in-process engine and
|
|
2026
|
+
in the MCP child alike, and its result says `killed: the turn was
|
|
2027
|
+
stopped`: a typed message, an `agent_ask` from another agent, a
|
|
2028
|
+
sub-agent brief, a sentinel fire, a tmux or browser wake, a voice
|
|
2029
|
+
consult or a wake-up. Whoever asked for that turn learns why it ended:
|
|
2030
|
+
an `agent_ask` still on the line, `agent_ask_result` and
|
|
2031
|
+
`subagent_result` report `state: "failed"` with `error: "stopped by
|
|
2032
|
+
the user"`, and a sentinel fire is recorded with outcome `error` and
|
|
2033
|
+
the same text. The tool descriptions tell the asking agent not to
|
|
2034
|
+
retry that on its own.
|
|
2035
|
+
|
|
2036
|
+
```bash
|
|
2037
|
+
curl -X POST "https://<host>:18737/chat/abort?agent=<your-agent>&session=main"
|
|
2038
|
+
```
|
|
2039
|
+
|
|
2040
|
+
---
|
|
2041
|
+
|
|
2042
|
+
## Memory
|
|
2043
|
+
|
|
2044
|
+
Each agent has its own memory layer — markdown notes under
|
|
2045
|
+
`~/.somora/agents/<agent>/memory/` plus, optionally, a shared Obsidian
|
|
2046
|
+
vault and wiki layer. See [memory.md](memory.md) for the storage
|
|
2047
|
+
architecture.
|
|
2048
|
+
|
|
2049
|
+
### `GET /agents/:agent/memory/notes`
|
|
2050
|
+
|
|
2051
|
+
List indexed notes for an agent. Optional `?source=memory|vault|wiki`
|
|
2052
|
+
to filter by source layer.
|
|
2053
|
+
|
|
2054
|
+
### `POST /agents/:agent/memory/recall-preview`
|
|
2055
|
+
|
|
2056
|
+
What auto-inject would recall for a message in a given conversation
|
|
2057
|
+
state — the turn's own recall path (query construction, history blend,
|
|
2058
|
+
search, block budget) without running a turn. Body:
|
|
2059
|
+
|
|
2060
|
+
```json
|
|
2061
|
+
{
|
|
2062
|
+
"text": "und wer gehört sonst noch zur familie?",
|
|
2063
|
+
"history": [
|
|
2064
|
+
{ "kind": "user_message", "text": "was kannst du mir über walter erzählen?" },
|
|
2065
|
+
{ "kind": "assistant_message", "text": "Walter ist …" }
|
|
2066
|
+
],
|
|
2067
|
+
"autoInject": { "historyWeight": 0.4 }
|
|
2068
|
+
}
|
|
2069
|
+
```
|
|
2070
|
+
|
|
2071
|
+
`history` is optional (oldest first; only `user_message` and
|
|
2072
|
+
`assistant_message` entries count). `autoInject` optionally overrides
|
|
2073
|
+
any `memory.autoInject` knob for this call only — for measuring a
|
|
2074
|
+
setting before changing config.yaml. Response: `hits` with `slug`,
|
|
2075
|
+
`source`, `score`, `vecScore`, `bm25Score`, line range, plus
|
|
2076
|
+
`injectedCount` and `ephemeralContextChars`. Used by the recall replay
|
|
2077
|
+
harness; loopback-only like every debug route.
|
|
2078
|
+
|
|
2079
|
+
### `GET /agents/:agent/memory/search`
|
|
2080
|
+
|
|
2081
|
+
Hybrid (BM25 + vector) search over the agent's own memory notes plus
|
|
2082
|
+
the shared vault/wiki index — the same `MemoryManager.search` the
|
|
2083
|
+
`memory_search` tool and auto-inject use: filler words are dropped
|
|
2084
|
+
from the keyword side, a page whose slug names a query word is boosted
|
|
2085
|
+
(`memory.hybrid.slugMatchBoost`), see [memory.md](memory.md). No
|
|
2086
|
+
history blend here — that is auto-inject's, use `recall-preview` above
|
|
2087
|
+
to see a turn's actual recall.
|
|
2088
|
+
|
|
2089
|
+
```bash
|
|
2090
|
+
curl "https://<host>:18737/agents/<your-agent>/memory/search?q=voice+satellites&limit=5&minScore=0.3"
|
|
2091
|
+
```
|
|
2092
|
+
|
|
2093
|
+
Query params: `q` (required), `limit` (1–50, default 5), `minScore`
|
|
2094
|
+
(0..1, default 0 — the route shows everything; auto-inject applies
|
|
2095
|
+
`autoInject.minScore`).
|
|
2096
|
+
|
|
2097
|
+
Returns `{ agent, query, limit, minScore, count, hits: [...] }`; each
|
|
2098
|
+
hit carries `slug`, `source` (`memory` | `wiki` | `vault`), `score`
|
|
2099
|
+
(fused, min-max normalised within this query's candidates — a rank,
|
|
2100
|
+
not a similarity), `vecScore`, `bm25Score`, `startLine`, `endLine`,
|
|
2101
|
+
`filePath` and the chunk `text`.
|
|
2102
|
+
|
|
2103
|
+
For full content of a hit, agents call `memory_get` via the tool
|
|
2104
|
+
endpoint (`POST /agents/:a/tools/memory_get`). Same path is
|
|
2105
|
+
available to your client.
|
|
2106
|
+
|
|
2107
|
+
---
|
|
2108
|
+
|
|
2109
|
+
## Wiki explorer
|
|
2110
|
+
|
|
2111
|
+
Read-only browse surface over the shared wiki, backing the web client's
|
|
2112
|
+
wiki window. All routes return **503** unless `wiki.enabled` and
|
|
2113
|
+
`obsidian.vault` are both configured.
|
|
2114
|
+
|
|
2115
|
+
Pages are addressed by **slug, never by path** — a request can only name
|
|
2116
|
+
pages the index already found under the wiki root, so traversal attempts
|
|
2117
|
+
come back as a plain 404 rather than needing a filter to catch them.
|
|
2118
|
+
|
|
2119
|
+
### `GET /wiki/status`
|
|
2120
|
+
|
|
2121
|
+
`{ enabled: boolean, root?: string }`. Cheap enough to call on UI mount;
|
|
2122
|
+
clients use it to decide whether to show the wiki entry point at all.
|
|
2123
|
+
|
|
2124
|
+
### `GET /wiki/tree`
|
|
2125
|
+
|
|
2126
|
+
```json
|
|
2127
|
+
{
|
|
2128
|
+
"root": "/path/to/vault/somora",
|
|
2129
|
+
"pages": 262,
|
|
2130
|
+
"builtAt": 1784750000000,
|
|
2131
|
+
"nodes": [
|
|
2132
|
+
{ "type": "dir", "name": "personen", "path": "personen",
|
|
2133
|
+
"children": [
|
|
2134
|
+
{ "type": "page", "slug": "personen/familie-klein",
|
|
2135
|
+
"name": "familie-klein.md", "title": "Familie Klein",
|
|
2136
|
+
"description": "…", "mtimeMs": 1784700000000 }
|
|
2137
|
+
] }
|
|
2138
|
+
]
|
|
2139
|
+
}
|
|
2140
|
+
```
|
|
2141
|
+
|
|
2142
|
+
Titles come from the page's first `# H1`, falling back to frontmatter
|
|
2143
|
+
`title`, then the filename.
|
|
2144
|
+
|
|
2145
|
+
### `GET /wiki/page?slug=<slug>`
|
|
2146
|
+
|
|
2147
|
+
Returns `markdown` plus resolved relationships:
|
|
2148
|
+
|
|
2149
|
+
```json
|
|
2150
|
+
{
|
|
2151
|
+
"slug": "projekte/somora", "title": "somora", "folder": "projekte",
|
|
2152
|
+
"mtimeMs": 1784700000000,
|
|
2153
|
+
"markdown": "## Aktueller Stand\n…",
|
|
2154
|
+
"frontmatter": { "type": "project", "created": "2026-05-08" },
|
|
2155
|
+
"links": [{ "slug": "personen/jane-doe", "title": "Jane" }],
|
|
2156
|
+
"backlinks": [{ "slug": "agenten/<your-agent>", "title": "Your Agent" }],
|
|
2157
|
+
"unresolved": ["personen/familie-doe"],
|
|
2158
|
+
"linkTargets": { "personen/jane-doe": "personen/jane-doe",
|
|
2159
|
+
"familie-doe": null }
|
|
2160
|
+
}
|
|
2161
|
+
```
|
|
2162
|
+
|
|
2163
|
+
`linkTargets` maps every raw `[[target]]` in the body to a slug, or
|
|
2164
|
+
`null` when nothing matches. Resolution — exact slug, case-insensitive
|
|
2165
|
+
slug, unique basename — lives here so clients don't reimplement
|
|
2166
|
+
Obsidian's matching. An ambiguous basename resolves to `null` on
|
|
2167
|
+
purpose: guessing one of several same-named pages fabricates a
|
|
2168
|
+
relationship.
|
|
2169
|
+
|
|
2170
|
+
404 when the slug names no page.
|
|
2171
|
+
|
|
2172
|
+
### `GET /wiki/graph?scope=local&slug=<slug>` · `?scope=global`
|
|
2173
|
+
|
|
2174
|
+
```json
|
|
2175
|
+
{
|
|
2176
|
+
"scope": "local",
|
|
2177
|
+
"nodes": [{ "id": "projekte/somora", "label": "somora",
|
|
2178
|
+
"folder": "projekte", "degree": 41 }],
|
|
2179
|
+
"edges": [{ "from": "agenten/<your-agent>", "to": "projekte/somora",
|
|
2180
|
+
"type": "wikilink" }],
|
|
2181
|
+
"truncated": false
|
|
2182
|
+
}
|
|
2183
|
+
```
|
|
2184
|
+
|
|
2185
|
+
`local` returns the page, everything it points at, everything pointing
|
|
2186
|
+
at it, and the edges among those neighbours. `global` returns the whole
|
|
2187
|
+
wiki, capped at the 400 most-connected pages — `truncated` says whether
|
|
2188
|
+
the cap bit. `degree` always counts the full wiki, so a node stays
|
|
2189
|
+
recognisable as a hub inside a local view.
|
|
2190
|
+
|
|
2191
|
+
`index.md` is excluded from both scopes: it links to every page by
|
|
2192
|
+
construction, which makes it a table of contents rather than a
|
|
2193
|
+
relationship.
|
|
2194
|
+
|
|
2195
|
+
Edge `type` is `wikilink` for inline `[[links]]` and `related` for
|
|
2196
|
+
frontmatter `related:` entries.
|
|
2197
|
+
|
|
2198
|
+
### `POST /wiki/refresh`
|
|
2199
|
+
|
|
2200
|
+
Drops the cache and re-scans. The index otherwise caches for 10 seconds
|
|
2201
|
+
and then re-parses only files whose mtime or size changed, so ordinary
|
|
2202
|
+
edits appear without this call.
|
|
2203
|
+
|
|
2204
|
+
---
|
|
2205
|
+
|
|
2206
|
+
## Dream system
|
|
2207
|
+
|
|
2208
|
+
The dream system runs in three phases (REM, Deep, Lucid) — see
|
|
2209
|
+
[dream-phases.md](dream-phases.md) for the model. Some of these
|
|
2210
|
+
endpoints surface state for monitoring; others trigger phases
|
|
2211
|
+
manually.
|
|
2212
|
+
|
|
2213
|
+
### `GET /dream/loop-state`
|
|
2214
|
+
|
|
2215
|
+
Read-only snapshot of the active Lucid review loop, if any.
|
|
2216
|
+
|
|
2217
|
+
```json
|
|
2218
|
+
{ "active": true, "agent": "<your-agent>", "dreamId": "lucid-...",
|
|
2219
|
+
"startedAt": "…", "lastActivityAt": "…" }
|
|
2220
|
+
```
|
|
2221
|
+
|
|
2222
|
+
Returns `{ active: false }` when no loop is held.
|
|
2223
|
+
|
|
2224
|
+
### `GET /dream-states` ⚠ experimental
|
|
2225
|
+
|
|
2226
|
+
Per-agent REM state + server-global Deep / Lucid state. Drives the
|
|
2227
|
+
web AgentDock pulse indicators and REM badges.
|
|
2228
|
+
|
|
2229
|
+
```json
|
|
2230
|
+
{
|
|
2231
|
+
"rem": {
|
|
2232
|
+
"<your-agent>": { "active": false, "pendingCount": 3 },
|
|
2233
|
+
"<agent-b>": { "active": true, "pendingCount": 0 }
|
|
2234
|
+
},
|
|
2235
|
+
"deep": { "active": false },
|
|
2236
|
+
"lucid": { "active": false, "pendingRuns": 0, "pendingFindings": 0 }
|
|
2237
|
+
}
|
|
2238
|
+
```
|
|
2239
|
+
|
|
2240
|
+
`rem[<agent>].active` is filesystem-driven (presence of
|
|
2241
|
+
`<agent>/memory/.dreams/<id>.dream.running.md`).
|
|
2242
|
+
`rem[<agent>].pendingCount` is the number of completed REM dreams
|
|
2243
|
+
waiting for review (`<id>.dream.md` files in `.dreams/`, not in
|
|
2244
|
+
`processed/`).
|
|
2245
|
+
|
|
2246
|
+
### `POST /dream/run-deep`
|
|
2247
|
+
|
|
2248
|
+
Trigger a Deep run manually. Default is fire-and-forget (returns
|
|
2249
|
+
immediately); set `{"wait": true}` to wait for the run to finish and
|
|
2250
|
+
get the result inline.
|
|
2251
|
+
|
|
2252
|
+
```bash
|
|
2253
|
+
curl -X POST https://<host>:18737/dream/run-deep \
|
|
2254
|
+
-H 'Content-Type: application/json' \
|
|
2255
|
+
-d '{"wait":true, "force":false}'
|
|
2256
|
+
```
|
|
2257
|
+
|
|
2258
|
+
`force: true` bypasses the per-agent skip-cache so every memory file
|
|
2259
|
+
gets re-evaluated.
|
|
2260
|
+
|
|
2261
|
+
### `POST /dream/run-lucid`
|
|
2262
|
+
|
|
2263
|
+
Same shape as `run-deep`, for the Lucid (wiki review) phase. While a
|
|
2264
|
+
previous run still has findings waiting for review, no new run starts
|
|
2265
|
+
(the response names that run); `{"force": true}` runs anyway.
|
|
2266
|
+
|
|
2267
|
+
### `POST /wiki/migration/plan`
|
|
2268
|
+
|
|
2269
|
+
Step one of moving a grown wiki onto the folder template
|
|
2270
|
+
([wiki.md](wiki.md#migrating-a-grown-wiki)): read the whole wiki and
|
|
2271
|
+
write down what a migration would do — nothing in the wiki is touched.
|
|
2272
|
+
The plan lands under `~/.somora/wiki-migration/<id>/plan.md` (and
|
|
2273
|
+
`plan.json`). **400** when the wiki layer is off.
|
|
2274
|
+
|
|
2275
|
+
```json
|
|
2276
|
+
{ "id": "20260929-104047", "plan": "/home/you/.somora/wiki-migration/20260929-104047/plan.md",
|
|
2277
|
+
"pagesTotal": 991, "foldersTotal": 71,
|
|
2278
|
+
"summary": { "move_folder": { "items": 19, "pages": 40 }, "unite_twins": { "items": 19, "pages": 38 },
|
|
2279
|
+
"fold_report": { "items": 190, "pages": 190 }, "review_pages": { "items": 37, "pages": 447 },
|
|
2280
|
+
"describe_folder": { "items": 0, "pages": 0 }, "unclear": { "items": 0, "pages": 0 } },
|
|
2281
|
+
"durationMs": 1830 }
|
|
2282
|
+
```
|
|
2283
|
+
|
|
2284
|
+
### `POST /wiki/migration/refine`
|
|
2285
|
+
|
|
2286
|
+
Step two: the Lucid model (falling back to the Deep model) judges every
|
|
2287
|
+
page the plan is unsure about, and every page a rule would move — keep,
|
|
2288
|
+
move to a folder, fold into an existing page, or unclear — in batches
|
|
2289
|
+
of 25 pages. Body `{ "id": "<plan id>", "wait": false, "batchSize": 25 }`.
|
|
2290
|
+
Runs in the background by default and writes `refined.md` /
|
|
2291
|
+
`refined.json` next to the plan; `wait: true` returns the result inline.
|
|
2292
|
+
Still no write into the wiki. **404** for an unknown plan, **409** while
|
|
2293
|
+
a refine for that plan is running.
|
|
2294
|
+
|
|
2295
|
+
```json
|
|
2296
|
+
{ "id": "20260929-104047", "started": true, "message": "Refine started in background. GET /wiki/migration/plans/:id for progress." }
|
|
2297
|
+
```
|
|
2298
|
+
|
|
2299
|
+
### `GET /wiki/migration/plans/:id`
|
|
2300
|
+
|
|
2301
|
+
The plan's summary, the progress of a running refine or execute
|
|
2302
|
+
(`done` / `total`), the approvals, and the refined result's groups
|
|
2303
|
+
when it exists.
|
|
2304
|
+
|
|
2305
|
+
```json
|
|
2306
|
+
{ "id": "20260929-104047", "dir": "…/wiki-migration/20260929-104047",
|
|
2307
|
+
"plan": { "pagesTotal": 991, "foldersTotal": 71, "summary": { … }, "createdAt": "…" },
|
|
2308
|
+
"refine": { "started": "…", "done": 12, "total": 27 },
|
|
2309
|
+
"execute": null,
|
|
2310
|
+
"approvals": { "planId": "…", "groups": { "move:regeln": { "status": "approved", "at": "…" } }, "twins": {} },
|
|
2311
|
+
"refined": { "model": "…", "pagesJudged": 943, "batchesTotal": 38, "batchesFailed": 0,
|
|
2312
|
+
"groups": [ { "action": "move", "target": "regeln", "pages": 50 }, … ] } }
|
|
2313
|
+
```
|
|
2314
|
+
|
|
2315
|
+
### `POST /wiki/migration/reindex`
|
|
2316
|
+
|
|
2317
|
+
One full sweep of the shared search index now (`somora wiki migrate
|
|
2318
|
+
undo` calls it after putting a backup back). Returns `{ indexed,
|
|
2319
|
+
skipped }`; **503** while the index is still building.
|
|
2320
|
+
|
|
2321
|
+
### `POST /wiki/migration/plans/:id/relink`
|
|
2322
|
+
|
|
2323
|
+
A second pass over every page with the renames a finished run of this
|
|
2324
|
+
plan recorded: `[[links]]` and frontmatter `related:` entries that
|
|
2325
|
+
still name a moved, folded or united page are pointed at its new
|
|
2326
|
+
place. Idempotent. `{"dryRun": true}` only counts. Runs before
|
|
2327
|
+
v2026.09.29.07 left `related:` untouched — this is the repair.
|
|
2328
|
+
|
|
2329
|
+
```json
|
|
2330
|
+
{ "id": "…", "dryRun": false, "renames": 819, "refsRewritten": 393, "pagesTouched": 224 }
|
|
2331
|
+
```
|
|
2332
|
+
|
|
2333
|
+
### `POST /wiki/migration/plans/:id/approve`
|
|
2334
|
+
|
|
2335
|
+
Mark groups of the refined plan. Body: `groups` (group keys such as
|
|
2336
|
+
`move:regeln` or `fold:projekte/somora`), or `action` (`move` / `fold`
|
|
2337
|
+
/ `unclear` — every group of that action), or `twins` (names, or
|
|
2338
|
+
`"all"`); `status` is `approved` (default), `dismissed` or `pending`.
|
|
2339
|
+
**404** until the plan has a refined result.
|
|
2340
|
+
|
|
2341
|
+
```json
|
|
2342
|
+
{ "id": "…", "status": "approved", "touched": 3, "approvedGroups": 12, "approvedPages": 310, "approvedTwins": 19 }
|
|
2343
|
+
```
|
|
2344
|
+
|
|
2345
|
+
### `POST /wiki/migration/plans/:id/execute`
|
|
2346
|
+
|
|
2347
|
+
Run the approved part. Default `{"dryRun": true}` writes `dry-run.md`
|
|
2348
|
+
next to the plan and touches nothing. A real run needs
|
|
2349
|
+
`{"dryRun": false, "confirm": "move my wiki"}`, copies the whole wiki
|
|
2350
|
+
into `backup-<time>/` under the plan first, and refuses to start when
|
|
2351
|
+
the copy is incomplete. Background by default (`wait: true` for the
|
|
2352
|
+
result inline); **409** while a run for that plan is going. See
|
|
2353
|
+
[wiki.md](wiki.md#migrating-a-grown-wiki) for what a run does.
|
|
2354
|
+
|
|
2355
|
+
```json
|
|
2356
|
+
{ "id": "…", "dryRun": false, "report": "…/execution-20260929-131500.md",
|
|
2357
|
+
"counts": { "move": 207, "fold": 540, "unite": 19, "failed": 2, "skipped": 0 },
|
|
2358
|
+
"linksRewritten": 812, "foldersRemoved": 51, "backupDir": "…/backup-20260929-131412",
|
|
2359
|
+
"reindex": { "indexed": 610, "skipped": 380 } }
|
|
2360
|
+
```
|
|
2361
|
+
|
|
2362
|
+
### `POST /agents/:agent/dream/run-rem`
|
|
2363
|
+
|
|
2364
|
+
Catch up one agent's unread conversations now: starts the REM cycle the
|
|
2365
|
+
idle timer would start — resume a paused dream, else read the sessions
|
|
2366
|
+
with unread events one after another — without waiting for silence.
|
|
2367
|
+
Always in the background; chat activity pauses it as usual.
|
|
2368
|
+
|
|
2369
|
+
```json
|
|
2370
|
+
{ "agent": "<your-agent>", "outcome": "started", "started": true, "message": "…" }
|
|
2371
|
+
```
|
|
2372
|
+
|
|
2373
|
+
`outcome` is `started`, `busy` (a cycle is already running) or
|
|
2374
|
+
`nothing_to_do`. `400` when REM is not enabled for the agent, `404` for
|
|
2375
|
+
an unknown agent, `409` when REM was enabled after the server started.
|
|
2376
|
+
|
|
2377
|
+
---
|
|
2378
|
+
|
|
2379
|
+
## Projects
|
|
2380
|
+
|
|
2381
|
+
Curated pointer-file manifests linking a session to a real-world
|
|
2382
|
+
project. **Opt-in feature** — every route below returns `503` when
|
|
2383
|
+
`projects.enabled` is `false` in `config.yaml`. Clients should probe
|
|
2384
|
+
[`GET /projects/feature`](#get-projectsfeature) once at boot to
|
|
2385
|
+
decide whether to surface the feature at all. See
|
|
2386
|
+
[projects.md](projects.md) for the user-level model.
|
|
2387
|
+
|
|
2388
|
+
### `GET /projects/feature`
|
|
2389
|
+
|
|
2390
|
+
Feature-flag probe. **Always returns 200**, regardless of the
|
|
2391
|
+
configured state — clients use this to detect availability without
|
|
2392
|
+
ambiguity (empty entities array vs. feature off).
|
|
2393
|
+
|
|
2394
|
+
```json
|
|
2395
|
+
{ "enabled": true, "entityCount": 2 }
|
|
2396
|
+
```
|
|
2397
|
+
|
|
2398
|
+
### `GET /projects/entities`
|
|
2399
|
+
|
|
2400
|
+
The controlled entity vocabulary from `config.projects.entities`.
|
|
2401
|
+
|
|
2402
|
+
```json
|
|
2403
|
+
{
|
|
2404
|
+
"entities": [
|
|
2405
|
+
{ "slug": "privat", "label": "Privat" },
|
|
2406
|
+
{ "slug": "enovom", "label": "enovom GmbH" }
|
|
2407
|
+
]
|
|
2408
|
+
}
|
|
2409
|
+
```
|
|
2410
|
+
|
|
2411
|
+
Agents call this before `project_create` when they're uncertain
|
|
2412
|
+
about an entity name they heard via STT — the response is the
|
|
2413
|
+
canonical match list. Direct clients fetch it once to populate
|
|
2414
|
+
filter dropdowns.
|
|
2415
|
+
|
|
2416
|
+
### `GET /projects`
|
|
2417
|
+
|
|
2418
|
+
List configured projects.
|
|
2419
|
+
|
|
2420
|
+
Query params (all optional):
|
|
2421
|
+
- `entity=<slug>` — filter to one entity
|
|
2422
|
+
- `tag=<string>` — filter to projects whose `tags[]` contains this
|
|
2423
|
+
- `includeArchived=true` — include soft-deleted projects (hidden by
|
|
2424
|
+
default)
|
|
2425
|
+
|
|
2426
|
+
```json
|
|
2427
|
+
{
|
|
2428
|
+
"total": 3,
|
|
2429
|
+
"projects": [
|
|
2430
|
+
{
|
|
2431
|
+
"slug": "heimkino",
|
|
2432
|
+
"name": "Heimkino",
|
|
2433
|
+
"entity": "privat",
|
|
2434
|
+
"description": "Receiver, beamer, …",
|
|
2435
|
+
"color": "#4f46e5",
|
|
2436
|
+
"tags": ["hardware", "wip"],
|
|
2437
|
+
"created": "2026-04-15T10:23:00Z",
|
|
2438
|
+
"updated": "2026-05-13T09:42:00Z",
|
|
2439
|
+
"archived": false,
|
|
2440
|
+
"paths": [
|
|
2441
|
+
{ "ref": "~/code/heimkino", "label": "Sourcecode" },
|
|
2442
|
+
{ "ref": "https://drive.google.com/..." }
|
|
2443
|
+
]
|
|
2444
|
+
}
|
|
2445
|
+
]
|
|
2446
|
+
}
|
|
2447
|
+
```
|
|
2448
|
+
|
|
2449
|
+
### `GET /projects/:slug`
|
|
2450
|
+
|
|
2451
|
+
Full project file content. `404` if the slug doesn't exist.
|
|
2452
|
+
|
|
2453
|
+
```bash
|
|
2454
|
+
curl https://<host>:18737/projects/heimkino
|
|
2455
|
+
```
|
|
2456
|
+
|
|
2457
|
+
### `POST /projects`
|
|
2458
|
+
|
|
2459
|
+
Create a new project. Returns `201` with the full project on
|
|
2460
|
+
success.
|
|
2461
|
+
|
|
2462
|
+
Body:
|
|
2463
|
+
```json
|
|
2464
|
+
{
|
|
2465
|
+
"slug": "heimkino",
|
|
2466
|
+
"name": "Heimkino",
|
|
2467
|
+
"entity": "privat",
|
|
2468
|
+
"description": "Receiver, beamer, acoustic treatment",
|
|
2469
|
+
"color": "#4f46e5",
|
|
2470
|
+
"tags": ["hardware", "wip"],
|
|
2471
|
+
"expires": null,
|
|
2472
|
+
"paths": [
|
|
2473
|
+
{ "ref": "~/code/heimkino", "label": "Sourcecode" },
|
|
2474
|
+
{ "ref": "https://drive.google.com/..." }
|
|
2475
|
+
],
|
|
2476
|
+
"workdir": "~/code/heimkino"
|
|
2477
|
+
}
|
|
2478
|
+
```
|
|
2479
|
+
|
|
2480
|
+
`workdir` (optional) is the project's working directory — pinning the
|
|
2481
|
+
project to a session makes it that session's working directory (see
|
|
2482
|
+
[projects.md](projects.md)).
|
|
2483
|
+
|
|
2484
|
+
Validation:
|
|
2485
|
+
- `slug` must match `[a-z0-9_-]+` and be unique (`409` on collision)
|
|
2486
|
+
- `entity` must match one of `config.projects.entities[].slug`
|
|
2487
|
+
(`400` with the available list when unknown)
|
|
2488
|
+
- each `paths[].ref` must be scheme-recognised — `https://...`,
|
|
2489
|
+
`~/abs`, `/abs`, or `<resource-slug>:/path` where the slug
|
|
2490
|
+
exists in `config.resources` (`400` with the available list
|
|
2491
|
+
when the resource is unknown)
|
|
2492
|
+
|
|
2493
|
+
### `PATCH /projects/:slug`
|
|
2494
|
+
|
|
2495
|
+
Transactional multi-op update. All ops validate first; if any one
|
|
2496
|
+
fails, **nothing is written**. Returns `200` with the updated
|
|
2497
|
+
project on success.
|
|
2498
|
+
|
|
2499
|
+
Body:
|
|
2500
|
+
```json
|
|
2501
|
+
{
|
|
2502
|
+
"ops": [
|
|
2503
|
+
{ "op": "add_path", "ref": "~/research/atmos.md", "label": "Atmos notes" },
|
|
2504
|
+
{ "op": "set_field", "field": "description", "value": "Updated" },
|
|
2505
|
+
{ "op": "set_tags", "tags": ["hardware", "wip", "avr"] }
|
|
2506
|
+
]
|
|
2507
|
+
}
|
|
2508
|
+
```
|
|
2509
|
+
|
|
2510
|
+
Supported op shapes:
|
|
2511
|
+
|
|
2512
|
+
| `op` | Required fields | Effect |
|
|
2513
|
+
|---|---|---|
|
|
2514
|
+
| `set_field` | `field` ∈ {name,description,color,expires}, `value` (string or null) | Update top-level field; `null` clears optional fields (cannot clear `name`). |
|
|
2515
|
+
| `add_path` | `ref`, `label?` | Append a pointer. Same scheme validation as `POST /projects`. |
|
|
2516
|
+
| `remove_path` | `ref` | Remove by exact ref match. `400` if `ref` isn't in the list. |
|
|
2517
|
+
| `set_tags` | `tags: string[]` | Replace the full tag array. |
|
|
2518
|
+
| `archive` | `reason?` | Soft-delete. |
|
|
2519
|
+
| `unarchive` | — | Restore. |
|
|
2520
|
+
|
|
2521
|
+
Slug and entity are intentionally **not** mutable in v1 — would
|
|
2522
|
+
break session pins. Workaround: delete the file and recreate.
|
|
2523
|
+
|
|
2524
|
+
### `GET /agents/:agent/sessions/:session/project`
|
|
2525
|
+
|
|
2526
|
+
Current pinned project for a session. Always returns `200` (or
|
|
2527
|
+
`404` if the agent/session itself doesn't exist).
|
|
2528
|
+
|
|
2529
|
+
```json
|
|
2530
|
+
{
|
|
2531
|
+
"agent": "<your-agent>",
|
|
2532
|
+
"session": "main",
|
|
2533
|
+
"slug": "heimkino",
|
|
2534
|
+
"project": { … full ProjectInfo … }
|
|
2535
|
+
}
|
|
2536
|
+
```
|
|
2537
|
+
|
|
2538
|
+
When no project is pinned: `{ "agent": …, "session": …, "slug": null, "project": null }`.
|
|
2539
|
+
When the slug is set but the file is missing on disk:
|
|
2540
|
+
`{ …, "slug": "ghost", "project": null, "missing": true }`.
|
|
2541
|
+
|
|
2542
|
+
### `POST /agents/:agent/sessions/:session/project`
|
|
2543
|
+
|
|
2544
|
+
Pin a project to a session.
|
|
2545
|
+
|
|
2546
|
+
```bash
|
|
2547
|
+
curl -X POST https://<host>:18737/agents/<your-agent>/sessions/main/project \
|
|
2548
|
+
-H 'Content-Type: application/json' \
|
|
2549
|
+
-d '{"slug":"heimkino"}'
|
|
2550
|
+
```
|
|
2551
|
+
|
|
2552
|
+
Returns `{ agent, session, previousSlug, currentSlug }`. Re-pinning
|
|
2553
|
+
the same project is a noop — no `project_switched` event is written
|
|
2554
|
+
to the JSONL.
|
|
2555
|
+
|
|
2556
|
+
Emits an SSE `project` event to every subscriber of (agent, session).
|
|
2557
|
+
|
|
2558
|
+
### `DELETE /agents/:agent/sessions/:session/project`
|
|
2559
|
+
|
|
2560
|
+
Clear the pin. Returns `{ agent, session, cleared: true, previousSlug }`.
|
|
2561
|
+
Also emits an SSE `project` event.
|
|
2562
|
+
|
|
2563
|
+
---
|
|
2564
|
+
|
|
2565
|
+
## Realtime voice
|
|
2566
|
+
|
|
2567
|
+
Talking to an agent: a standing, interruptible call where a realtime
|
|
2568
|
+
model speaks and the agent knows. Off unless `realtimeVoice.enabled`.
|
|
2569
|
+
Concept and configuration in [realtime-voice.md](realtime-voice.md);
|
|
2570
|
+
this is not the dictation/TTS path ([voice.md](voice.md)).
|
|
2571
|
+
|
|
2572
|
+
### `GET /voice/status`
|
|
2573
|
+
|
|
2574
|
+
```json
|
|
2575
|
+
{ "enabled": true, "provider": "openai", "model": "gpt-realtime-2.1-mini",
|
|
2576
|
+
"maxCallMinutes": 20, "agents": ["<your-agent>", "<other-agent>"], "calls": [] }
|
|
2577
|
+
```
|
|
2578
|
+
|
|
2579
|
+
`agents` lists who may be called — realtime voice on, and the agent's
|
|
2580
|
+
`agent.yaml` carries `voice.enabled: true`. With the feature off the
|
|
2581
|
+
answer is `{ "enabled": false, "agents": [] }` (200, not an error: a
|
|
2582
|
+
client asks this to decide whether to show the tile at all).
|
|
2583
|
+
|
|
2584
|
+
### `GET /voice/instructions?agent=<name>&session=<slug>`
|
|
2585
|
+
|
|
2586
|
+
Exactly what the speaking model would be told, without starting a call:
|
|
2587
|
+
|
|
2588
|
+
```json
|
|
2589
|
+
{ "agent": "<your-agent>", "session": "main", "text": "You are <your-agent>, speaking out loud …",
|
|
2590
|
+
"chars": 1528, "source": "derived", "voice": "ash", "language": "de",
|
|
2591
|
+
"consultPolicy": "always" }
|
|
2592
|
+
```
|
|
2593
|
+
|
|
2594
|
+
`source` is `derived` (built from the persona plus `agent.yaml voice:`)
|
|
2595
|
+
or `VOICE.md` when the operator wrote one. The derived text exists only
|
|
2596
|
+
in memory — this is the only way to read it. `503` when voice is off,
|
|
2597
|
+
`404` when that agent has no voice.
|
|
2598
|
+
|
|
2599
|
+
### `WS /voice/attach?agent=<name>&session=<slug>`
|
|
2600
|
+
|
|
2601
|
+
The call itself. One JSON frame format in both directions; the browser
|
|
2602
|
+
holds no provider knowledge, no key, and never sees a tool call.
|
|
2603
|
+
|
|
2604
|
+
Client → server:
|
|
2605
|
+
|
|
2606
|
+
```json
|
|
2607
|
+
{ "type": "audio", "base64": "<PCM16 24 kHz mono>" }
|
|
2608
|
+
{ "type": "interrupt" }
|
|
2609
|
+
{ "type": "hangup" }
|
|
2610
|
+
```
|
|
2611
|
+
|
|
2612
|
+
Keep sending audio while nobody speaks. The provider ends a turn on
|
|
2613
|
+
SILENCE, not on missing packets — a client that stops sending gets one
|
|
2614
|
+
"speech started" and then nothing at all.
|
|
2615
|
+
|
|
2616
|
+
Server → client:
|
|
2617
|
+
|
|
2618
|
+
```json
|
|
2619
|
+
{ "type": "ready", "call": { … }, "rateHz": 24000 }
|
|
2620
|
+
{ "type": "audio", "base64": "…", "rateHz": 24000 }
|
|
2621
|
+
{ "type": "state", "call": { "state": "consulting", "consults": 2, "target": { … } } }
|
|
2622
|
+
{ "type": "event", "event": { "kind": "user_transcript", "text": "…", "final": true }, "call": { … } }
|
|
2623
|
+
```
|
|
2624
|
+
|
|
2625
|
+
`state` is `connecting | listening | consulting | speaking | closed`.
|
|
2626
|
+
`consulting` is somora running a real turn in the bound session — no
|
|
2627
|
+
provider event announces it. `target` changes when a call is handed to
|
|
2628
|
+
another agent, and the client follows it.
|
|
2629
|
+
|
|
2630
|
+
Closing the socket ends the call: a standing connection bills by the
|
|
2631
|
+
minute. Work the agent already accepted keeps running — hanging up and
|
|
2632
|
+
cancelling are two different things.
|
|
2633
|
+
|
|
2634
|
+
## Attachments
|
|
2635
|
+
|
|
2636
|
+
Files attached to chat turns (images, PDFs, plain-text snippets)
|
|
2637
|
+
travel via this two-step flow: upload first, then ref the hash on
|
|
2638
|
+
`/chat/send`.
|
|
2639
|
+
|
|
2640
|
+
### `POST /attachments`
|
|
2641
|
+
|
|
2642
|
+
Upload **one** file as the raw request body, with its name in the
|
|
2643
|
+
`X-Somora-Filename` header (URL-encoded, so spaces and non-ASCII
|
|
2644
|
+
survive). Content is stored once on disk, deduped by hash.
|
|
2645
|
+
|
|
2646
|
+
Raw bytes rather than a form upload is deliberate: multipart parsing
|
|
2647
|
+
pulls the whole file into memory, while a raw body streams and keeps
|
|
2648
|
+
the size cap meaningful. A `multipart/form-data` request is refused
|
|
2649
|
+
with `415` rather than stored as an opaque text attachment.
|
|
2650
|
+
|
|
2651
|
+
```bash
|
|
2652
|
+
curl -X POST https://<host>:18737/attachments \
|
|
2653
|
+
--data-binary @./screenshot.png \
|
|
2654
|
+
-H "Content-Type: image/png" \
|
|
2655
|
+
-H "X-Somora-Filename: screenshot.png"
|
|
2656
|
+
```
|
|
2657
|
+
|
|
2658
|
+
Returns one object (the type is sniffed from the bytes, not the name):
|
|
2659
|
+
```json
|
|
2660
|
+
{ "hash": "sha256-…",
|
|
2661
|
+
"name": "screenshot.png",
|
|
2662
|
+
"mime": "image/png",
|
|
2663
|
+
"kind": "image",
|
|
2664
|
+
"size": 184320 }
|
|
2665
|
+
```
|
|
2666
|
+
|
|
2667
|
+
Collect the objects for as many files as you need and pass them as
|
|
2668
|
+
`attachments[]` on the next `/chat/send` or `/chat/send-sync`. The
|
|
2669
|
+
per-turn count and per-file size come from `config.attachments`.
|
|
2670
|
+
|
|
2671
|
+
### `GET /attachments/:hash`
|
|
2672
|
+
|
|
2673
|
+
Serve the bytes for a previously-uploaded attachment. Useful for
|
|
2674
|
+
clients that want to preview the same image the agent saw.
|
|
2675
|
+
|
|
2676
|
+
---
|
|
2677
|
+
|
|
2678
|
+
## Tmux integration
|
|
2679
|
+
|
|
2680
|
+
somora knows about tmux sessions on the host and lets clients attach
|
|
2681
|
+
to them through a WebSocket bridge. See [tmux.md](tmux.md) for the
|
|
2682
|
+
full model.
|
|
2683
|
+
|
|
2684
|
+
### `GET /tmux/sessions`
|
|
2685
|
+
|
|
2686
|
+
List live tmux sessions, joined with somora's origin store so each
|
|
2687
|
+
session carries the agent/session that created it (if known).
|
|
2688
|
+
|
|
2689
|
+
```bash
|
|
2690
|
+
curl https://<host>:18737/tmux/sessions
|
|
2691
|
+
```
|
|
2692
|
+
|
|
2693
|
+
### `WS /tmux/attach?session=<name>`
|
|
2694
|
+
|
|
2695
|
+
WebSocket bridge to `tmux attach-session -d -t <name>`. Binary
|
|
2696
|
+
frames carry the terminal stream; text frames carry control messages
|
|
2697
|
+
(`{type:'resize',cols,rows}`).
|
|
2698
|
+
|
|
2699
|
+
### `WS /terminal/attach`
|
|
2700
|
+
|
|
2701
|
+
Fresh shell (no tmux session). Same binary/text frame protocol as
|
|
2702
|
+
`/tmux/attach`.
|
|
2703
|
+
|
|
2704
|
+
---
|
|
2705
|
+
|
|
2706
|
+
## Browser — shared managed Chromium
|
|
2707
|
+
|
|
2708
|
+
Served by the somora web server. See [browser.md](browser.md). Mutating
|
|
2709
|
+
HTTP routes answer `503` while `browser.enabled` is false; status and
|
|
2710
|
+
the change stream return `{enabled:false,browsers:[],warnings:[]}`.
|
|
2711
|
+
The viewer WebSocket refuses attachment when disabled.
|
|
2712
|
+
|
|
2713
|
+
### `GET /logs`
|
|
2714
|
+
|
|
2715
|
+
The server's own log, for the log window in the web client. Query:
|
|
2716
|
+
`day` (`YYYY-MM-DD`, default the newest file), `minLevel` (pino numbers:
|
|
2717
|
+
20 debug, 30 info, 40 warn, 50 error), `q` (case-insensitive substring
|
|
2718
|
+
over the raw line), `agent`, `limit` (default 300, max 2000).
|
|
2719
|
+
|
|
2720
|
+
Returns `{ day, days, lines: [{ ts, level, msg, agent?, session?, fields }],
|
|
2721
|
+
offset, truncated }`. `days` lists every day that has a file, newest
|
|
2722
|
+
first. `offset` is a byte position to continue from. `truncated` says
|
|
2723
|
+
older lines were outside the read window.
|
|
2724
|
+
|
|
2725
|
+
Only the tail of one day's file is read (512 KiB), so the cost does not
|
|
2726
|
+
grow with the log — the directory routinely holds hundreds of megabytes.
|
|
2727
|
+
The caller names a day, never a path.
|
|
2728
|
+
|
|
2729
|
+
### `GET /logs/since`
|
|
2730
|
+
|
|
2731
|
+
`?offset=<n>` plus the same filters. Returns `{ lines, offset, day }`
|
|
2732
|
+
with only what was appended after `offset` — the follow path for the log
|
|
2733
|
+
window. A file that shrank (rotation, truncation) snaps the offset back
|
|
2734
|
+
to its real size instead of reading backwards.
|
|
2735
|
+
|
|
2736
|
+
### `POST /browser/op`
|
|
2737
|
+
|
|
2738
|
+
Run one `browser` tool operation for an agent, in that agent's window — the path the MCP tool
|
|
2739
|
+
child takes for claude-cli/codex-cli turns, because the Chromium lives
|
|
2740
|
+
in the server process. Body `{ agent, session?, input }` where `input`
|
|
2741
|
+
is the tool's argument object (`{ op: "open", url }`, `{ op:
|
|
2742
|
+
"snapshot", tab }`, …). Returns the tool's result object (`ok`,
|
|
2743
|
+
`error`, `hint`, `tab`, `snapshot`, …), never a non-2xx for a tool-level
|
|
2744
|
+
refusal.
|
|
2745
|
+
|
|
2746
|
+
### `GET /browser/status`
|
|
2747
|
+
|
|
2748
|
+
`{ enabled, headed, browsers: [{ view_id, agent, browser_id, profile,
|
|
2749
|
+
ephemeral, state, control, human_by?, handoff?, tabs: [{ tab_id, url,
|
|
2750
|
+
title, agent, session?, generation, emulation? }], last_used, headed? }],
|
|
2751
|
+
warnings }` — one entry per open **window**, not per Chromium process:
|
|
2752
|
+
`view_id` is `<browser_id>@<agent>` and `agent` owns it. Agents sharing
|
|
2753
|
+
a profile run in one process (`browser_id`) with one window each, own
|
|
2754
|
+
tabs, own control state, own handoff. Stopped browsers are not listed,
|
|
2755
|
+
except one still holding a pending handoff. `control` is
|
|
2756
|
+
`agent_control`, `handoff_requested`, `human_control` or `paused`.
|
|
2757
|
+
`headed` is the host plan for `browser.headed` (`headless`, `display`,
|
|
2758
|
+
`xvfb`, `unavailable`); `warnings` lists what the operator must fix
|
|
2759
|
+
(no Chromium found, headed configured but no display and no Xvfb).
|
|
2760
|
+
`emulation` shows a tab's `device` / `locale` from `open`.
|
|
2761
|
+
|
|
2762
|
+
### `GET /browser/stream`
|
|
2763
|
+
|
|
2764
|
+
SSE events `browsers` contain `{enabled,browsers,warnings}` with the same
|
|
2765
|
+
browser entries as `/browser/status`. Every connection starts with a
|
|
2766
|
+
complete snapshot; later events replace it. `heartbeat` follows the
|
|
2767
|
+
normal SSE liveness settings. Slow readers receive coalesced snapshots;
|
|
2768
|
+
stalled writes terminate the connection.
|
|
2769
|
+
|
|
2770
|
+
### `POST /browser/:id/restart`
|
|
2771
|
+
|
|
2772
|
+
Explicitly reopen a known stopped browser with a blank page and the
|
|
2773
|
+
same profile. `:id` may be a window id or a browser id — a restart is
|
|
2774
|
+
per process; every window that existed comes back with its control
|
|
2775
|
+
state. No old navigation or input is replayed. Pending handoffs
|
|
2776
|
+
remain pending. Returns `{ok:true}` or `409` with `{error}` when recovery
|
|
2777
|
+
is refused (unknown browser or removed shared-profile configuration).
|
|
2778
|
+
|
|
2779
|
+
### `POST /browser/:id/control`
|
|
2780
|
+
|
|
2781
|
+
`:id` is a window id (`profile:team@<your-agent>`); a bare browser id works
|
|
2782
|
+
while only one agent has a window on that process, and is otherwise
|
|
2783
|
+
refused as ambiguous. Body `{ mode: "human" | "agent", by?, handoffId? }`.
|
|
2784
|
+
`human` takes control of that window: its agent's ops are refused until
|
|
2785
|
+
handed back, while other agents on the same process keep working.
|
|
2786
|
+
`agent` hands it back; with a pending handoff the requesting agent is
|
|
2787
|
+
woken once in its session (pass the `handoffId` from the status so a
|
|
2788
|
+
stale button press after a newer handoff does not wake twice). Without a
|
|
2789
|
+
pending handoff, a hand-back after real activity wakes the window's own
|
|
2790
|
+
agent, in the session of the last tab it used there. `404`
|
|
2791
|
+
when the browser is not running, `409` on a state conflict. A mismatched
|
|
2792
|
+
handoff ID is refused; a duplicate completed ID does not release a newer
|
|
2793
|
+
manual takeover. With `by`, a different current controller cannot be
|
|
2794
|
+
handed back. The web client sends control over its viewer WebSocket so
|
|
2795
|
+
the identity matches subsequent input. Wake dispatch is not a durable
|
|
2796
|
+
queue; see the recovery limitations in [browser.md](browser.md).
|
|
2797
|
+
|
|
2798
|
+
### `GET /browser/attach` (WebSocket)
|
|
2799
|
+
|
|
2800
|
+
`?view=<viewId>&tab=<tabId>&viewer=<id>` — the live view behind the web
|
|
2801
|
+
client's browser window. `viewId` is `<browser_id>@<agent>`; only that
|
|
2802
|
+
window's tabs are reachable, and `browser=` is still accepted as the
|
|
2803
|
+
parameter name. Control, input and hand-back over this socket act on
|
|
2804
|
+
that window. Binary frames carry one JPEG each:
|
|
2805
|
+
`[u32 BE header length][JSON header][JPEG]`, header `{ tabId,
|
|
2806
|
+
generation, seq, url, cssWidth, cssHeight, scrollX, scrollY, ts }`.
|
|
2807
|
+
Frames are ack-paced (`browser.stream.maxFps`, default 15, at most 20 fps) and skipped for a viewer whose
|
|
2808
|
+
socket has more than 2 MB pending. Text frames (JSON):
|
|
2809
|
+
|
|
2810
|
+
- server → viewer: `ping` (answer `{"type":"pong"}`; 80 s of silence
|
|
2811
|
+
drops the socket), `ready` `{browser, tabId, viewerId}` after attach
|
|
2812
|
+
or a tab switch, `tabs` `{browser}` whenever tabs or control changed,
|
|
2813
|
+
`control` `{control}` after a control request, `notice`/`error`
|
|
2814
|
+
`{text}`.
|
|
2815
|
+
- viewer → server: `control` `{mode:"human"|"agent", handoffId?}`,
|
|
2816
|
+
`tab` `{tabId}` (switch the streamed tab), and — only while this
|
|
2817
|
+
viewer holds human control — `navigate` `{url}` (same policy as the
|
|
2818
|
+
tool), `newtab`, `closetab` `{tabId}`, `resize` `{width,height}`,
|
|
2819
|
+
`mousemove`/`click`/`mousedown`/`mouseup` `{x,y,button?,clickCount?}`
|
|
2820
|
+
in CSS pixels of the streamed viewport, `wheel` `{x,y,deltaX,deltaY}`,
|
|
2821
|
+
`text` `{text}` (composed text incl. paste; CDP `Input.insertText`),
|
|
2822
|
+
`key` `{key, ctrl?, alt?, shift?, meta?, action?}` (Playwright key
|
|
2823
|
+
names, e.g. `Enter`, `Control+a`), `back`, `forward`, `reload`. Input
|
|
2824
|
+
from a viewer without control gets a `notice`, nothing is applied.
|
|
2825
|
+
Input other than `navigate`, `newtab`, `closetab`, `tab` and `control`
|
|
2826
|
+
must also carry `frameTab` and `generation` from the displayed frame;
|
|
2827
|
+
obsolete metadata is refused. Messages above 64 KiB and queues above
|
|
2828
|
+
64 commands close the connection.
|
|
2829
|
+
|
|
2830
|
+
Close codes: `1008` bad request (unknown browser, disabled), `4000`
|
|
2831
|
+
heartbeat timeout, `4001` tab closed, `1009` oversized input, `1012` server
|
|
2832
|
+
shutdown. `1008` also covers excessive pending input.
|
|
2833
|
+
|
|
2834
|
+
## Sentinel — proactive triggers
|
|
2835
|
+
|
|
2836
|
+
Sentinel installs time-based triggers that wake agents on a schedule.
|
|
2837
|
+
The agent does its work into its own chat session — same surface as
|
|
2838
|
+
when you interact with it directly. See [sentinel.md](sentinel.md) for
|
|
2839
|
+
the conceptual overview.
|
|
2840
|
+
|
|
2841
|
+
The same operations are also exposed as the `sentinel` tool agents
|
|
2842
|
+
can call (`POST /agents/:agent/tools/sentinel`); the HTTP routes below
|
|
2843
|
+
are for the web-UI sentinel tab and for external clients.
|
|
2844
|
+
|
|
2845
|
+
### `GET /sentinel/triggers`
|
|
2846
|
+
|
|
2847
|
+
List all triggers. Optional query filters:
|
|
2848
|
+
|
|
2849
|
+
- `?owner=<agent>` — only triggers whose `ownerAgent` matches
|
|
2850
|
+
- `?status=active|paused|error|completed`
|
|
2851
|
+
|
|
2852
|
+
```bash
|
|
2853
|
+
curl https://<host>:18737/sentinel/triggers?status=active
|
|
2854
|
+
```
|
|
2855
|
+
|
|
2856
|
+
```json
|
|
2857
|
+
{
|
|
2858
|
+
"count": 2,
|
|
2859
|
+
"triggers": [
|
|
2860
|
+
{
|
|
2861
|
+
"id": "morning-mail-summary-a7c3",
|
|
2862
|
+
"name": "morning-mail-summary",
|
|
2863
|
+
"ownerAgent": "<other-agent>",
|
|
2864
|
+
"source": { "type": "time", "spec": { "type": "daily", "time": "08:00" } },
|
|
2865
|
+
"evaluator": { "type": "none" },
|
|
2866
|
+
"dispatch": { "agent": "<other-agent>", "session": "morning-routine",
|
|
2867
|
+
"prompt": "Check inbox via gog skill…" },
|
|
2868
|
+
"createdAt": "2026-05-17T11:00:00.000Z",
|
|
2869
|
+
"status": "active",
|
|
2870
|
+
"fireCount": 5,
|
|
2871
|
+
"lastSuccessAt": "2026-05-17T08:00:01.234Z",
|
|
2872
|
+
"errorStreak": 0,
|
|
2873
|
+
"nextFireAt": "2026-05-18T08:00:00.000Z"
|
|
2874
|
+
}
|
|
2875
|
+
]
|
|
2876
|
+
}
|
|
2877
|
+
```
|
|
2878
|
+
|
|
2879
|
+
### `GET /sentinel/triggers/:id`
|
|
2880
|
+
|
|
2881
|
+
`{trigger}` — the full trigger document for a single id. 404 if missing.
|
|
2882
|
+
|
|
2883
|
+
### `GET /sentinel/triggers/:id/history`
|
|
2884
|
+
|
|
2885
|
+
Newest-first fire log. `?limit=N` capped at 200, default 50.
|
|
2886
|
+
|
|
2887
|
+
```json
|
|
2888
|
+
{
|
|
2889
|
+
"count": 5,
|
|
2890
|
+
"entries": [
|
|
2891
|
+
{
|
|
2892
|
+
"firedAt": "2026-05-17T08:00:01.234Z",
|
|
2893
|
+
"scheduledFor": "2026-05-17T08:00:00.000Z",
|
|
2894
|
+
"outcome": "success",
|
|
2895
|
+
"taskId": "task-..."
|
|
2896
|
+
},
|
|
2897
|
+
{
|
|
2898
|
+
"firedAt": "2026-05-16T08:00:00.500Z",
|
|
2899
|
+
"scheduledFor": "2026-05-16T08:00:00.000Z",
|
|
2900
|
+
"outcome": "skipped",
|
|
2901
|
+
"skipReason": "cooldown (1320s remaining)"
|
|
2902
|
+
}
|
|
2903
|
+
]
|
|
2904
|
+
}
|
|
2905
|
+
```
|
|
2906
|
+
|
|
2907
|
+
Outcomes: `success` / `error` (with `error: string`) / `skipped`
|
|
2908
|
+
(with `skipReason: string`). Plus optional `catchUp: true` (boot
|
|
2909
|
+
recovery fire) and `testMode: true` (fired via `/test`). A fire that a
|
|
2910
|
+
person took out of the session's queue before it started is `skipped`
|
|
2911
|
+
with `skipReason: "removed from the queue by the user"`; one stopped
|
|
2912
|
+
while running is `error` with `stopped by the user`.
|
|
2913
|
+
|
|
2914
|
+
`404` once the trigger is deleted (its history file goes with it).
|
|
2915
|
+
|
|
2916
|
+
### `POST /sentinel/triggers/:id/pause`
|
|
2917
|
+
|
|
2918
|
+
Set status to `paused`. Trigger stops firing until explicitly resumed.
|
|
2919
|
+
Returns `{"ok": true}`. 404 if missing.
|
|
2920
|
+
|
|
2921
|
+
### `POST /sentinel/triggers/:id/resume`
|
|
2922
|
+
|
|
2923
|
+
Set status back to `active`, recompute `nextFireAt` from the spec.
|
|
2924
|
+
Idempotent for already-active triggers. 404 if missing.
|
|
2925
|
+
|
|
2926
|
+
### `POST /sentinel/triggers/:id/test`
|
|
2927
|
+
|
|
2928
|
+
Fire NOW, bypassing cooldown and daily-cap. The fire is recorded with
|
|
2929
|
+
`testMode: true` in history. The dispatched agent receives the same
|
|
2930
|
+
evidence-prefixed prompt as a real fire.
|
|
2931
|
+
|
|
2932
|
+
```bash
|
|
2933
|
+
curl -X POST https://<host>:18737/sentinel/triggers/morning-mail-summary-a7c3/test
|
|
2934
|
+
```
|
|
2935
|
+
|
|
2936
|
+
### `DELETE /sentinel/triggers/:id`
|
|
2937
|
+
|
|
2938
|
+
Remove the trigger and its history file. Idempotent — already-deleted
|
|
2939
|
+
ids return 404.
|
|
2940
|
+
|
|
2941
|
+
### `GET /sentinel/status`
|
|
2942
|
+
|
|
2943
|
+
Scheduler diagnostic snapshot. Useful when sanity-checking that the
|
|
2944
|
+
scheduler is armed for the next due trigger.
|
|
2945
|
+
|
|
2946
|
+
```json
|
|
2947
|
+
{ "started": true, "nextFireAt": 1779013800000 }
|
|
2948
|
+
```
|
|
2949
|
+
|
|
2950
|
+
### Creating triggers
|
|
2951
|
+
|
|
2952
|
+
Triggers are created through the agent-facing tool, not a dedicated
|
|
2953
|
+
HTTP route, so the safeguards (min-interval, per-agent cap, limit
|
|
2954
|
+
enforcement) all run through the same validation path:
|
|
2955
|
+
|
|
2956
|
+
```bash
|
|
2957
|
+
curl -X POST https://<host>:18737/agents/<your-agent>/tools/sentinel \
|
|
2958
|
+
-H 'Content-Type: application/json' \
|
|
2959
|
+
-d '{
|
|
2960
|
+
"action": "create",
|
|
2961
|
+
"name": "morning-mail-summary",
|
|
2962
|
+
"intent": "Daily 8am inbox digest",
|
|
2963
|
+
"source": { "type": "time", "spec": { "type": "daily", "time": "08:00" } },
|
|
2964
|
+
"dispatch": {
|
|
2965
|
+
"agent": "<other-agent>",
|
|
2966
|
+
"session": "morning-routine",
|
|
2967
|
+
"prompt": "Check inbox via the gog skill, group by topic, tell me what is important."
|
|
2968
|
+
}
|
|
2969
|
+
}'
|
|
2970
|
+
```
|
|
2971
|
+
|
|
2972
|
+
The full `sentinel` tool surface (`create` / `list` / `get` /
|
|
2973
|
+
`pause` / `resume` / `delete` / `test` / `history` / `purge_completed`)
|
|
2974
|
+
is described in [sentinel.md](sentinel.md).
|
|
2975
|
+
|
|
2976
|
+
---
|
|
2977
|
+
|
|
2978
|
+
## Voice
|
|
2979
|
+
|
|
2980
|
+
Two flows: STT for filling chat drafts, TTS for spoken replies. Plus
|
|
2981
|
+
`/voice/turn` as the audio-in/audio-out endpoint for integrations.
|
|
2982
|
+
All routes return 503 when the matching block is missing or disabled
|
|
2983
|
+
in `config.yaml`. See [voice.md](voice.md) for the full picture.
|
|
2984
|
+
|
|
2985
|
+
### `GET /stt/config`
|
|
2986
|
+
|
|
2987
|
+
Reports STT availability + the default language hint.
|
|
2988
|
+
|
|
2989
|
+
```json
|
|
2990
|
+
{ "enabled": true, "language": "de" }
|
|
2991
|
+
```
|
|
2992
|
+
|
|
2993
|
+
Returns `{ "enabled": false }` when STT is off in config — clients
|
|
2994
|
+
auto-hide their mic button.
|
|
2995
|
+
|
|
2996
|
+
### `POST /stt/transcribe`
|
|
2997
|
+
|
|
2998
|
+
Forwards a multipart audio recording to the configured upstream's
|
|
2999
|
+
`/v1/audio/transcriptions` and returns the transcript.
|
|
3000
|
+
|
|
3001
|
+
```http
|
|
3002
|
+
POST /stt/transcribe
|
|
3003
|
+
Content-Type: multipart/form-data
|
|
3004
|
+
|
|
3005
|
+
file=@recording.webm
|
|
3006
|
+
language=de # optional, overrides config default
|
|
3007
|
+
```
|
|
3008
|
+
|
|
3009
|
+
Response: `{ "text": "<transcript>" }`. 503 when disabled.
|
|
3010
|
+
|
|
3011
|
+
### `GET /tts/config`
|
|
3012
|
+
|
|
3013
|
+
Reports TTS availability + supported wire formats + per-client
|
|
3014
|
+
auto-play defaults.
|
|
3015
|
+
|
|
3016
|
+
```json
|
|
3017
|
+
{
|
|
3018
|
+
"enabled": true,
|
|
3019
|
+
"formats": ["audio/wav", "audio/opus", "audio/mp4"],
|
|
3020
|
+
"language": "de",
|
|
3021
|
+
"voice": null,
|
|
3022
|
+
"clients": {
|
|
3023
|
+
"web": { "autoPlayVoiceReplies": false, "allowUserOverride": true },
|
|
3024
|
+
"mobile": { "autoPlayVoiceReplies": false, "allowUserOverride": true }
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
```
|
|
3028
|
+
|
|
3029
|
+
### `POST /tts/synthesize`
|
|
3030
|
+
|
|
3031
|
+
Generate (or fetch from cache) spoken audio for a piece of text.
|
|
3032
|
+
Content-negotiates the wire format from `Accept`.
|
|
3033
|
+
|
|
3034
|
+
```http
|
|
3035
|
+
POST /tts/synthesize
|
|
3036
|
+
Content-Type: application/json
|
|
3037
|
+
Accept: audio/opus, audio/wav;q=0.5
|
|
3038
|
+
|
|
3039
|
+
{ "text": "Es ist 10:29 Uhr.", "voice": null, "language": "de" }
|
|
3040
|
+
```
|
|
3041
|
+
|
|
3042
|
+
Response body is audio bytes. Useful response headers:
|
|
3043
|
+
|
|
3044
|
+
- `Content-Type` — `audio/wav`, `audio/opus`, or `audio/mp4`.
|
|
3045
|
+
- `X-Tts-Cache` — `hit` or `miss`.
|
|
3046
|
+
- `X-Tts-Cache-Key` — sha256 hex used for caching.
|
|
3047
|
+
- `X-Tts-Duration-Ms` — set on WAV cache misses; omitted otherwise
|
|
3048
|
+
(clients can compute on-play).
|
|
3049
|
+
|
|
3050
|
+
400 on missing `text` or text > 4000 chars. 502 on upstream failure.
|
|
3051
|
+
503 when TTS disabled.
|
|
3052
|
+
|
|
3053
|
+
### `GET /tts/cache/:filename`
|
|
3054
|
+
|
|
3055
|
+
Stream a previously-generated audio file by its cache key. Filenames
|
|
3056
|
+
are `<64-hex>.<wav|opus|m4a>`; anything else returns 400. Supports
|
|
3057
|
+
single-range requests (`Range: bytes=N-`) so mobile `<audio>` can
|
|
3058
|
+
seek.
|
|
3059
|
+
|
|
3060
|
+
This is the URL emitted as `assistant_audio.url` in SSE and JSONL —
|
|
3061
|
+
clients render it directly into `<audio src=…>` without ever calling
|
|
3062
|
+
`/tts/synthesize` for cached turns.
|
|
3063
|
+
|
|
3064
|
+
### `POST /voice/turn`
|
|
3065
|
+
|
|
3066
|
+
Independent audio-in → audio-out endpoint. STT-transcribes the
|
|
3067
|
+
recording, runs a normal agent turn (with `input_modality=voice`),
|
|
3068
|
+
sanitizes the assistant reply for speech, generates TTS, and returns
|
|
3069
|
+
JSON with the artifact URL. The session JSONL + SSE stream see the
|
|
3070
|
+
turn live, same as a `/chat/send` turn.
|
|
3071
|
+
|
|
3072
|
+
```http
|
|
3073
|
+
POST /voice/turn
|
|
3074
|
+
Content-Type: multipart/form-data
|
|
3075
|
+
Accept: audio/opus, audio/wav;q=0.5
|
|
3076
|
+
|
|
3077
|
+
agent=<name> # required
|
|
3078
|
+
session=<name> # required: "main" / exact id / new slug (creates)
|
|
3079
|
+
audio=@recording.webm # required
|
|
3080
|
+
voice=<voice-id> # optional, falls back to tts.voice
|
|
3081
|
+
language=<lang> # optional, falls back to tts.language
|
|
3082
|
+
```
|
|
3083
|
+
|
|
3084
|
+
Response:
|
|
3085
|
+
|
|
3086
|
+
```json
|
|
3087
|
+
{
|
|
3088
|
+
"ok": true,
|
|
3089
|
+
"agent": "<your-agent>",
|
|
3090
|
+
"session": "main",
|
|
3091
|
+
"transcript": "Wie spät ist es?",
|
|
3092
|
+
"text": "Es ist 10:29 Uhr.",
|
|
3093
|
+
"audio": {
|
|
3094
|
+
"url": "/tts/cache/abc123….opus",
|
|
3095
|
+
"mime": "audio/opus",
|
|
3096
|
+
"durationMs": 1800,
|
|
3097
|
+
"cacheKey": "abc123…"
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
```
|
|
3101
|
+
|
|
3102
|
+
- Session lock priority: `user` (treated as human input).
|
|
3103
|
+
- Always generates audio, regardless of any per-chat auto-play
|
|
3104
|
+
toggle (those toggles only affect `/chat/send`).
|
|
3105
|
+
- 404 when `session=<exact-id>` doesn't exist; auto-creates for free-
|
|
3106
|
+
form slug names. 503 if either `stt` or `tts` is disabled.
|
|
3107
|
+
|
|
3108
|
+
### `assistant_audio` SSE event
|
|
3109
|
+
|
|
3110
|
+
After a turn whose reply got TTS (auto or via `/voice/turn`), the
|
|
3111
|
+
session's SSE stream emits:
|
|
3112
|
+
|
|
3113
|
+
```
|
|
3114
|
+
event: assistant_audio
|
|
3115
|
+
data: {"turnId":"…","url":"/tts/cache/…","mime":"audio/opus","durationMs":1800,"cacheKey":"…"}
|
|
3116
|
+
```
|
|
3117
|
+
|
|
3118
|
+
Clients pair on `turnId` and render a Play-button on the matching
|
|
3119
|
+
assistant bubble. The event is also appended to the session JSONL,
|
|
3120
|
+
so `/chat/history` returns it on reload and Play-buttons survive.
|
|
3121
|
+
|
|
3122
|
+
---
|
|
3123
|
+
|
|
3124
|
+
## Web bundle
|
|
3125
|
+
|
|
3126
|
+
### `GET /web/`
|
|
3127
|
+
|
|
3128
|
+
Serves the bundled web UI from `web/dist/`. Same-origin as the API,
|
|
3129
|
+
so the web app's `fetch('/agents')` works without CORS. `GET /web`
|
|
3130
|
+
(no slash) redirects here.
|
|
3131
|
+
|
|
3132
|
+
### `GET /mobile/`
|
|
3133
|
+
|
|
3134
|
+
Serves the mobile PWA from `web-mobile/dist/` the same way; `GET
|
|
3135
|
+
/mobile` redirects to it. Both bundles are static files — a custom
|
|
3136
|
+
client does not need them, every function they use is in the routes
|
|
3137
|
+
above.
|
|
3138
|
+
|
|
3139
|
+
---
|
|
3140
|
+
|
|
3141
|
+
## Building a custom client — typical flow
|
|
3142
|
+
|
|
3143
|
+
A minimal client that wants to send a message and stream the
|
|
3144
|
+
response back works like this:
|
|
3145
|
+
|
|
3146
|
+
```bash
|
|
3147
|
+
# 1. Discover agents
|
|
3148
|
+
curl https://<host>:18737/agents
|
|
3149
|
+
|
|
3150
|
+
# 2. Optionally set the model + thinking for this conversation
|
|
3151
|
+
curl -X PUT https://<host>:18737/agents/<your-agent>/sessions/main/model \
|
|
3152
|
+
-H 'Content-Type: application/json' \
|
|
3153
|
+
-d '{"model":"claude-opus-4-7"}'
|
|
3154
|
+
|
|
3155
|
+
# 3. Subscribe to the stream (background)
|
|
3156
|
+
curl -N "https://<host>:18737/chat/stream?agent=<your-agent>&session=main" &
|
|
3157
|
+
|
|
3158
|
+
# 4. Send a message — server fires the turn, events arrive on the stream
|
|
3159
|
+
curl -X POST https://<host>:18737/chat/send \
|
|
3160
|
+
-H 'Content-Type: application/json' \
|
|
3161
|
+
-d '{"agent":"<your-agent>","session":"main","text":"Was steht heute an?"}'
|
|
3162
|
+
```
|
|
3163
|
+
|
|
3164
|
+
For richer clients (a dashboard, a desktop app, a phone bridge), the
|
|
3165
|
+
typical loop is:
|
|
3166
|
+
|
|
3167
|
+
1. **On boot:** `GET /agents` + `GET /sessions` + `GET /version` to
|
|
3168
|
+
build the navigation.
|
|
3169
|
+
2. **For each open chat window:** open one SSE subscription
|
|
3170
|
+
(`/chat/stream`) and one history hydration (`/chat/history?limit=200`).
|
|
3171
|
+
3. **On user input:** `POST /attachments` for any files, then
|
|
3172
|
+
`POST /chat/send` with `attachments[]` set.
|
|
3173
|
+
4. **On user reset:** `POST /agents/:a/sessions/:s/reset`. The server
|
|
3174
|
+
triggers REM in the background; your UI can show the resulting
|
|
3175
|
+
pending count via `/dream-states`.
|
|
3176
|
+
5. **For monitoring:** poll `/dream-states` every 30 s for dream-phase
|
|
3177
|
+
indicators, `/dream/loop-state` every 2 s if you want to surface
|
|
3178
|
+
the Lucid review loop.
|
|
3179
|
+
|
|
3180
|
+
The TUI's API client lives at `src/cli/tui/api.ts`; the web's at
|
|
3181
|
+
`web/src/lib/api.ts`. Both are short, focused, typed wrappers over
|
|
3182
|
+
the surface above and make good starting points for your own.
|
|
3183
|
+
|
|
3184
|
+
---
|
|
3185
|
+
|
|
3186
|
+
## Files of interest in the somora source
|
|
3187
|
+
|
|
3188
|
+
- `src/server/index.ts` — every route definition lives here
|
|
3189
|
+
- `src/server/sse-serializer.ts` — wire format for SSE events
|
|
3190
|
+
- `src/server/tool-format.ts` — tool name + arg + result
|
|
3191
|
+
pre-formatting (normalises `mcp__…` prefixes)
|
|
3192
|
+
- `src/cli/tui/api.ts` — reference client (TypeScript)
|
|
3193
|
+
- `web/src/lib/api.ts` — second reference client (TypeScript,
|
|
3194
|
+
browser-targeted)
|