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/tmux.md
ADDED
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
# tmux — Driving Long-Running Terminal Sessions
|
|
2
|
+
|
|
3
|
+
The `tmux` tool gives the agent a persistent terminal session whose
|
|
4
|
+
state survives between tool calls. Use it when you need to spawn
|
|
5
|
+
something that runs across many turns (`claude --dangerously-skip-
|
|
6
|
+
permissions` for delegated coding, `codex` for the same, `vim` for
|
|
7
|
+
edit-and-walk-away, a REPL that needs incremental input).
|
|
8
|
+
|
|
9
|
+
For one-shot commands prefer `exec` — tmux is overkill, and
|
|
10
|
+
forgotten sessions accumulate.
|
|
11
|
+
|
|
12
|
+
## Lifecycle
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
tmux({ action: "create", name: "<slug>", cwd?: "<path>" })
|
|
16
|
+
→ tmux({ action: "send", name, keys })
|
|
17
|
+
→ tmux({ action: "capture", name, … })
|
|
18
|
+
→ … many send/capture pairs across turns …
|
|
19
|
+
→ tmux({ action: "kill", name })
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`action: "list"` shows running sessions on the target.
|
|
23
|
+
|
|
24
|
+
## Shell vs TUI sessions
|
|
25
|
+
|
|
26
|
+
There are two fundamentally different things you might run in a
|
|
27
|
+
tmux pane and they need different `wait_pattern` semantics. Pick
|
|
28
|
+
deliberately.
|
|
29
|
+
|
|
30
|
+
### Shell session
|
|
31
|
+
|
|
32
|
+
You spawn a shell (the default `bash`/`zsh`/`fish` of the target),
|
|
33
|
+
type commands, watch their output, see a prompt come back. The pane
|
|
34
|
+
ends with `$`/`#`/`>` when idle. Output streams from top to bottom
|
|
35
|
+
as commands run.
|
|
36
|
+
|
|
37
|
+
### TUI session
|
|
38
|
+
|
|
39
|
+
You spawn an interactive program with its own input UI: Claude Code,
|
|
40
|
+
codex, vim, htop, fzf, lazygit, jupyter, an IPython REPL with rich
|
|
41
|
+
prompt. The pane shows a fixed layout (often with box-drawing
|
|
42
|
+
characters), redraws in place as state changes, has its own input
|
|
43
|
+
field — there's no shell prompt at the bottom waiting for you.
|
|
44
|
+
|
|
45
|
+
## `wait_mode` — three matching strategies
|
|
46
|
+
|
|
47
|
+
`tmux({ action: "capture", wait_pattern: "X", wait_mode: "…" })`
|
|
48
|
+
controls how the call decides "matched":
|
|
49
|
+
|
|
50
|
+
| Mode | Match when | Use for |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| `auto` (default) | Pattern occurrences GREW past baseline (= new output appeared) **OR** pattern is present and buffer ends with shell prompt sigil (`$`/`#`/`>`) | Shell sessions. Survives the typed-command-echoes-the-pattern false-positive. |
|
|
53
|
+
| `present` | Pattern is in the current pane content | TUI sessions. The pattern is part of a static rendered panel, no shell prompt to detect, count never grows. |
|
|
54
|
+
| `idle` | Pattern is in pane AND content has been stable for `idle_stable_ms` (default 500ms) | "Wait until the TUI/command stops changing". Useful when you don't want to match too eagerly mid-render. |
|
|
55
|
+
|
|
56
|
+
Examples:
|
|
57
|
+
|
|
58
|
+
```jsonc
|
|
59
|
+
// Shell: wait for command output. wait_mode defaults to 'auto'.
|
|
60
|
+
tmux({ action:"send", name:"shell-1", keys:"./build.sh\n" })
|
|
61
|
+
tmux({ action:"capture", name:"shell-1",
|
|
62
|
+
wait_pattern:"Build succeeded", wait_timeout_ms: 60000 })
|
|
63
|
+
|
|
64
|
+
// TUI (Claude Code post-init): wait for the welcome panel.
|
|
65
|
+
tmux({ action:"send", name:"claude-1",
|
|
66
|
+
keys:"claude --dangerously-skip-permissions\n" })
|
|
67
|
+
tmux({ action:"capture", name:"claude-1",
|
|
68
|
+
wait_pattern:"bypass permissions on",
|
|
69
|
+
wait_mode:"present", wait_timeout_ms: 15000 })
|
|
70
|
+
|
|
71
|
+
// TUI: wait for the pane to stop changing while a pattern is on screen.
|
|
72
|
+
// (Pattern-free waiting is `action: "wait_idle"` — see the `kind` section.)
|
|
73
|
+
tmux({ action:"capture", name:"claude-1",
|
|
74
|
+
wait_pattern:"❯", wait_mode:"idle",
|
|
75
|
+
idle_stable_ms: 1500, wait_timeout_ms: 600000 })
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
If `wait_mode` is wrong for your session shape you typically get a
|
|
79
|
+
silent timeout (matched=false at the wait_timeout_ms ceiling) — pick
|
|
80
|
+
the other mode, that's the fix.
|
|
81
|
+
|
|
82
|
+
## `multiline_safe` — Multi-line input into TUIs that auto-submit on Enter
|
|
83
|
+
|
|
84
|
+
By default `\n` in `keys` is sent as a plain Enter. That's right for
|
|
85
|
+
shells (each `\n` runs the previous line) but wrong for input boxes
|
|
86
|
+
in modern coding TUIs (Claude Code, codex, IPython, fish prompt, the
|
|
87
|
+
input fields in Slack/Discord/etc.) — those treat Enter as "submit"
|
|
88
|
+
and split a multi-line message into N separate submissions.
|
|
89
|
+
|
|
90
|
+
When you set `multiline_safe: true`, every embedded `\n` is sent as
|
|
91
|
+
M-Enter (`Esc` + `CR`, equivalent to Alt+Enter / Shift+Enter in
|
|
92
|
+
those TUIs) — the soft-newline convention they all follow. The
|
|
93
|
+
trailing `\n` of `keys` still becomes a plain Enter so the message
|
|
94
|
+
finally submits.
|
|
95
|
+
|
|
96
|
+
```jsonc
|
|
97
|
+
// Sending a multi-line message to a coding TUI:
|
|
98
|
+
tmux({ action:"send", name:"claude-1",
|
|
99
|
+
keys: "Please build a Tetris game.\n\n" +
|
|
100
|
+
"1. Next.js + TS\n" +
|
|
101
|
+
"2. 10x20 grid\n" +
|
|
102
|
+
"3. Arrow keys\n",
|
|
103
|
+
multiline_safe: true })
|
|
104
|
+
// → Claude Code receives one multi-line message, responds once.
|
|
105
|
+
// Without multiline_safe, the four \n would have submitted four
|
|
106
|
+
// separate prompts.
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Caveat: M-Enter is a convention. Plain bash readline ignores it (so
|
|
110
|
+
`multiline_safe:true` against a bare shell harmlessly concatenates
|
|
111
|
+
your lines instead of newline-separating them — but you wouldn't be
|
|
112
|
+
using `multiline_safe` against bash anyway).
|
|
113
|
+
|
|
114
|
+
## `kind` — Declaring what runs in the pane
|
|
115
|
+
|
|
116
|
+
For known coding-TUIs you can tell somora what's running inside the
|
|
117
|
+
session at create-time. Set `kind: "claude-code"`, `kind: "codex"` or
|
|
118
|
+
`kind: "opencode"` and two things happen automatically on every `capture` and
|
|
119
|
+
`wait_idle` against that session:
|
|
120
|
+
|
|
121
|
+
1. A structured `tui_state: { state, markers, suggestion_visible,
|
|
122
|
+
suggestion_text }` block is added to the result. `state` is one of
|
|
123
|
+
`"ready" | "queued" | "running" | "idle_unknown"`. `markers` is the
|
|
124
|
+
list of substrings that matched the kind's marker table.
|
|
125
|
+
`suggestion_visible` / `suggestion_text` report ghost text (the
|
|
126
|
+
TUI's dim auto-suggestion on its input line) — detected via an
|
|
127
|
+
automatic ANSI probe, so you don't need `include_ansi` for this.
|
|
128
|
+
A visible suggestion is a hint the TUI renders for a human; it is
|
|
129
|
+
NOT real typed input — ignore it (don't clear it, don't mention
|
|
130
|
+
it, don't submit it).
|
|
131
|
+
2. `wait_idle` does not return prematurely on a content-stable-but-
|
|
132
|
+
not-actually-ready pane. A `claude --dangerously-skip-permissions`
|
|
133
|
+
session that's sitting on `Press up to edit queued messages` is
|
|
134
|
+
content-stable but the TUI hasn't processed the input yet —
|
|
135
|
+
without `kind`, `became_idle` would flip to `true` and the agent
|
|
136
|
+
would proceed too early. With `kind: "claude-code"`, the queued
|
|
137
|
+
marker is recognised and `wait_idle` waits until the state is
|
|
138
|
+
actually `ready`.
|
|
139
|
+
|
|
140
|
+
The kinds and what they detect:
|
|
141
|
+
|
|
142
|
+
| `kind` | Watches for | Use for |
|
|
143
|
+
|---|---|---|
|
|
144
|
+
| `shell` (default) | nothing — pure content-stability | bash/zsh/fish, build scripts, REPLs, vim/htop, anything not in the list below |
|
|
145
|
+
| `claude-code` | `Press up to edit queued messages` (queued), `esc to interrupt` + spinner words like `Tempering…` / `Whisking…` (running) | `claude` / `claude --dangerously-skip-permissions` |
|
|
146
|
+
| `codex` | `esc to interrupt` (running) | `codex` CLI |
|
|
147
|
+
| `opencode` | `QUEUED` label under a message submitted mid-turn (queued), `esc interrupt` footer cue and the `esc again to interrupt` confirmation after a first Escape (running — the child command is still alive until the second Escape) | `opencode` TUI ([sst/opencode](https://github.com/sst/opencode)) |
|
|
148
|
+
|
|
149
|
+
Pick `shell` (or omit the field) when unsure — the TUI flags are
|
|
150
|
+
additive and only help if the correct kind is declared. A wrong
|
|
151
|
+
`kind` doesn't break the session, but the markers won't match the
|
|
152
|
+
actual TUI so the extra detection is wasted.
|
|
153
|
+
|
|
154
|
+
```jsonc
|
|
155
|
+
// Claude Code workflow with TUI-aware wait_idle.
|
|
156
|
+
tmux({ action: "create", name: "claude-1",
|
|
157
|
+
kind: "claude-code",
|
|
158
|
+
cwd: "/path/to/project" })
|
|
159
|
+
tmux({ action: "send", name: "claude-1",
|
|
160
|
+
keys: "claude --dangerously-skip-permissions\n" })
|
|
161
|
+
// … later, after sending a long multi-line prompt …
|
|
162
|
+
const r = await tmux({ action: "wait_idle", name: "claude-1",
|
|
163
|
+
wait_timeout_ms: 600_000 })
|
|
164
|
+
if (r.tui_state?.state === "queued") {
|
|
165
|
+
// Input is in Claude Code's composer but wasn't submitted.
|
|
166
|
+
// Don't proceed — submit explicitly or ask the user.
|
|
167
|
+
} else if (r.tui_state?.state === "running") {
|
|
168
|
+
// Still working. Either wait longer or send key:"Escape" to interrupt.
|
|
169
|
+
} else if (r.became_idle && r.tui_state?.state === "ready") {
|
|
170
|
+
// Truly done — proceed with the next step.
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
```jsonc
|
|
175
|
+
// Codex workflow.
|
|
176
|
+
tmux({ action: "create", name: "codex-1",
|
|
177
|
+
kind: "codex",
|
|
178
|
+
cwd: "/path/to/project" })
|
|
179
|
+
tmux({ action: "send", name: "codex-1", keys: "codex\n" })
|
|
180
|
+
const r = await tmux({ action: "wait_idle", name: "codex-1",
|
|
181
|
+
wait_timeout_ms: 120_000 })
|
|
182
|
+
if (r.tui_state?.state === "running") {
|
|
183
|
+
// esc-to-interrupt marker present — codex is still working.
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```jsonc
|
|
188
|
+
// OpenCode workflow — same shape. Two OpenCode specifics:
|
|
189
|
+
// - a "△ Permission required" dialog (Allow once / Allow always /
|
|
190
|
+
// Reject) reads as `ready`: it is waiting for you. `capture` shows
|
|
191
|
+
// the dialog; answer with key:"Enter" (Allow once is preselected)
|
|
192
|
+
// or arrow keys + Enter to pick another option.
|
|
193
|
+
// - a message sent while a turn runs is QUEUED and auto-submitted when
|
|
194
|
+
// the turn ends, so `queued` means "still going to work after this".
|
|
195
|
+
tmux({ action: "create", name: "oc-1", kind: "opencode", cwd: "/path/to/project" })
|
|
196
|
+
tmux({ action: "send", name: "oc-1", keys: "opencode\n" })
|
|
197
|
+
const r = await tmux({ action: "wait_idle", name: "oc-1", wait_timeout_ms: 600_000 })
|
|
198
|
+
if (r.became_idle && r.tui_state?.state === "ready") {
|
|
199
|
+
const c = await tmux({ action: "capture", name: "oc-1" })
|
|
200
|
+
if (c.content.includes("Permission required")) {
|
|
201
|
+
tmux({ action: "send", name: "oc-1", key: "Enter" }) // Allow once
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
OpenCode's model comes from `~/.config/opencode/opencode.json`; any
|
|
207
|
+
OpenAI-compatible endpoint works (a local model behind LiteLLM/vLLM/
|
|
208
|
+
sglang, for instance), so this is the natural kind for driving a
|
|
209
|
+
self-hosted coding model.
|
|
210
|
+
|
|
211
|
+
## Attention watcher — wake me when the CLI is done
|
|
212
|
+
|
|
213
|
+
Sessions created with `kind: "claude-code"`, `kind: "codex"` or
|
|
214
|
+
`kind: "opencode"` are
|
|
215
|
+
watched server-side: somora polls the pane every few seconds and
|
|
216
|
+
detects the moment the CLI goes from *running* to *ready* — which
|
|
217
|
+
means "finished" or "waiting for input" (e.g. a permission prompt).
|
|
218
|
+
|
|
219
|
+
What happens then depends on whether the agent that created the
|
|
220
|
+
session saw it happen:
|
|
221
|
+
|
|
222
|
+
- **The agent observed it itself** (its `wait_idle` returned the ready
|
|
223
|
+
state, or a later `capture` saw it) → nothing. No duplicate nudge.
|
|
224
|
+
- **The agent missed it** (its `wait_idle` timed out and its turn
|
|
225
|
+
ended while the CLI kept working) → somora dispatches a wake turn to
|
|
226
|
+
the originating agent + session. The text of that turn is the
|
|
227
|
+
record, `[tmux attention] Session '<name>' (<kind>) became ready.`;
|
|
228
|
+
the instructions — it was running and is now idle, finished or
|
|
229
|
+
waiting for input, capture it with the tmux tool first, then decide
|
|
230
|
+
whether to reply, handle a prompt, report or wrap up, and never send
|
|
231
|
+
a new prompt blind — accompany the turn as its frame, beside the
|
|
232
|
+
text. The turn renders as a `tmux` system divider in
|
|
233
|
+
web/mobile/TUI, exactly like Sentinel triggers do.
|
|
234
|
+
|
|
235
|
+
Rules that keep this calm:
|
|
236
|
+
|
|
237
|
+
- One wake per completion. An ignored wake is never repeated — the
|
|
238
|
+
session re-arms only after the agent interacts with it again.
|
|
239
|
+
- Configurable cooldown between wakes and a daily per-session cap
|
|
240
|
+
(see below). Past the cap only the `needs_attention` flag is set.
|
|
241
|
+
- Only somora-created sessions with a coding-CLI `kind` are watched.
|
|
242
|
+
Manual `tmux new` sessions and `kind: "shell"` are never touched.
|
|
243
|
+
- Opt out per session with `attention: false` on create.
|
|
244
|
+
|
|
245
|
+
`capture`, `wait_idle` and `list` responses include an `attention`
|
|
246
|
+
block for watched sessions:
|
|
247
|
+
|
|
248
|
+
```jsonc
|
|
249
|
+
"attention": {
|
|
250
|
+
"needs_attention": true, // completion nobody has looked at yet
|
|
251
|
+
"last_event_at": 1785150000000,
|
|
252
|
+
"last_wake_at": null,
|
|
253
|
+
"wakes_today": 0,
|
|
254
|
+
"state": "ready"
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Config (`config.yaml`):
|
|
259
|
+
|
|
260
|
+
```yaml
|
|
261
|
+
tmux:
|
|
262
|
+
attention:
|
|
263
|
+
enabled: true # watcher + metadata/badge
|
|
264
|
+
wake: true # agent-wakeup stage (false = flag only)
|
|
265
|
+
pollMs: 3000
|
|
266
|
+
cooldownS: 60
|
|
267
|
+
dailyCapPerSession: 40
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## `inherit_agent_env` — Sharing somora's isolated Claude tree
|
|
271
|
+
|
|
272
|
+
By default, sessions you create with `tmux({ action: "create" })` get
|
|
273
|
+
somora's internal env vars **stripped** before the user's shell
|
|
274
|
+
starts: the claude isolation pair (`CLAUDE_CONFIG_DIR`,
|
|
275
|
+
`SOMORA_CLAUDE_BIN`), the engine overrides (`SOMORA_CODEX_BIN`,
|
|
276
|
+
`SOMORA_GROK_BIN`, `SOMORA_BIN_PATH`, `SOMORA_CODEX_SHELL_ENV_POLICY`),
|
|
277
|
+
the runtime's own
|
|
278
|
+
`TSX_TSCONFIG_PATH` and `NODE_ENV`, and the markers Claude Code puts
|
|
279
|
+
on its MCP children (`CLAUDECODE`, `CLAUDE_PROJECT_DIR`,
|
|
280
|
+
`CLAUDE_CODE_ENTRYPOINT`, `CLAUDE_CODE_SESSION_ID`,
|
|
281
|
+
`CLAUDE_CODE_MESSAGING_*`). That's almost always what you want: a tmux
|
|
282
|
+
session in a project directory should behave like a normal terminal —
|
|
283
|
+
a `claude` or `codex` started inside the pane should see the user's
|
|
284
|
+
normal `~/.claude` login state, and a project's own `tsx` should
|
|
285
|
+
resolve its path aliases against the project's tsconfig, not somora's.
|
|
286
|
+
The agent's identity (`SOMORA_AGENT`, `SOMORA_SESSION`) and the server
|
|
287
|
+
address vars stay, so skill scripts can still call back into somora.
|
|
288
|
+
|
|
289
|
+
The rare opt-in is `inherit_agent_env: true` on `create` — somora's
|
|
290
|
+
internal env carries through. Use this when:
|
|
291
|
+
|
|
292
|
+
- you intentionally want a nested `claude-cli` inside tmux to talk
|
|
293
|
+
to the same isolated state somora's own engine uses;
|
|
294
|
+
- you're debugging a state-related issue and need to compare what
|
|
295
|
+
somora sees vs what you see in a normal shell;
|
|
296
|
+
- you've pointed `CLAUDE_CONFIG_DIR` at a hand-curated config tree
|
|
297
|
+
via `~/.somora/somora.env` and want the agent's tmux children to
|
|
298
|
+
use it too.
|
|
299
|
+
|
|
300
|
+
```jsonc
|
|
301
|
+
// Default: pane behaves like a user-opened terminal.
|
|
302
|
+
tmux({ action: "create", name: "shell-1", cwd: "/path/to/project" })
|
|
303
|
+
|
|
304
|
+
// Opt-in: tmux child shares somora's isolated claude tree.
|
|
305
|
+
tmux({ action: "create", name: "claude-debug-1",
|
|
306
|
+
inherit_agent_env: true,
|
|
307
|
+
cwd: "/path/to/project" })
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
The same flag exists on `exec({ inherit_agent_env: true })` for
|
|
311
|
+
one-shot commands. Default is `false` on both tools.
|
|
312
|
+
|
|
313
|
+
## `include_ansi` — Distinguishing real input from auto-suggestions
|
|
314
|
+
|
|
315
|
+
Capture defaults to ANSI-stripped output for easy pattern matching.
|
|
316
|
+
Set `include_ansi: true` to get raw bytes including escape sequences
|
|
317
|
+
— colors, dim/bold attributes, cursor moves.
|
|
318
|
+
|
|
319
|
+
The motivating use case: modern coding TUIs render auto-suggestions
|
|
320
|
+
in their input field —
|
|
321
|
+
text in dim/gray that looks _identical_ to user-typed text once the
|
|
322
|
+
ANSI is stripped:
|
|
323
|
+
|
|
324
|
+
```text
|
|
325
|
+
❯ works now, thanks ← actually typed by the user
|
|
326
|
+
❯ delete the project ← auto-suggestion the TUI rendered
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
In stripped output both look the same. With `include_ansi:true`,
|
|
330
|
+
the suggestion arrives wrapped in dim-color escapes (e.g.
|
|
331
|
+
`\x1b[2m…\x1b[0m`) and the typed text doesn't.
|
|
332
|
+
|
|
333
|
+
### **Safety rule (read this once, remember always):**
|
|
334
|
+
|
|
335
|
+
> **Never blindly press Enter on a buffer that already shows pending
|
|
336
|
+
> input you didn't type yourself.** It might be an auto-suggestion.
|
|
337
|
+
> Submitting a suggestion you didn't type can trigger destructive
|
|
338
|
+
> actions ("delete project", "clear all"). When in doubt:
|
|
339
|
+
>
|
|
340
|
+
> 1. Capture with `include_ansi:true` to inspect the styling.
|
|
341
|
+
> 2. Or ask the user before submitting.
|
|
342
|
+
|
|
343
|
+
Real-world scenario: a Claude Code auto-suggestion `❯ clean everything
|
|
344
|
+
up, delete the project` looks like real user input. With
|
|
345
|
+
stripped output the agent can't tell typed text from a dim-color
|
|
346
|
+
suggestion — ask before submitting, or capture with
|
|
347
|
+
`include_ansi:true` first.
|
|
348
|
+
|
|
349
|
+
If you declared `kind: "claude-code"` or `kind: "codex"` on the
|
|
350
|
+
session, you rarely need manual ANSI inspection for this anymore:
|
|
351
|
+
`tui_state.suggestion_visible` / `suggestion_text` report ghost text
|
|
352
|
+
on the input line directly (somora runs the ANSI probe for you), and
|
|
353
|
+
`tui_state.state === "queued"` is the structured form of "there's
|
|
354
|
+
pending input that hasn't been submitted". Manual `include_ansi`
|
|
355
|
+
capture remains the fallback for undeclared sessions or when you
|
|
356
|
+
want to inspect the raw styling yourself.
|
|
357
|
+
|
|
358
|
+
## Result shape
|
|
359
|
+
|
|
360
|
+
All actions return `{ action, ok, target, name, … }` plus action-
|
|
361
|
+
specific fields. Notable for `capture`:
|
|
362
|
+
|
|
363
|
+
```jsonc
|
|
364
|
+
{
|
|
365
|
+
action: "capture",
|
|
366
|
+
ok: true,
|
|
367
|
+
target: "local",
|
|
368
|
+
name: "claude-1",
|
|
369
|
+
content: "<the captured pane bytes, stripped or with ANSI>",
|
|
370
|
+
matched_pattern: true, // false on timeout or no wait_pattern
|
|
371
|
+
wait_pattern: "bypass…", // echoed back if set
|
|
372
|
+
ms: 287,
|
|
373
|
+
// Present only when the session was created with kind != "shell":
|
|
374
|
+
tui_state: {
|
|
375
|
+
state: "ready", // "ready" | "queued" | "running" | "idle_unknown"
|
|
376
|
+
markers: [], // marker substrings that matched
|
|
377
|
+
},
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
And for `wait_idle`:
|
|
382
|
+
|
|
383
|
+
```jsonc
|
|
384
|
+
{
|
|
385
|
+
action: "wait_idle",
|
|
386
|
+
ok: true,
|
|
387
|
+
target: "local",
|
|
388
|
+
name: "claude-1",
|
|
389
|
+
content: "<final pane snapshot>",
|
|
390
|
+
became_idle: true, // for kind != "shell", true only when both
|
|
391
|
+
// content-stable AND tui_state.state === "ready"
|
|
392
|
+
ms: 1492,
|
|
393
|
+
tui_state: { state: "ready", markers: [] }, // only when kind != "shell"
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
## Cross-references
|
|
398
|
+
|
|
399
|
+
- `tools.md` — full tool family overview
|
package/docs/tools.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Tools
|
|
2
|
+
|
|
3
|
+
somora exposes tools to the agent through a single registry. Every
|
|
4
|
+
tool is **engine-agnostic**: claude-cli (and grok-cli) see them via an
|
|
5
|
+
MCP server somora spawns per turn, codex-cli receives them as Codex
|
|
6
|
+
dynamic tools on the app-server and somora answers the calls,
|
|
7
|
+
openai-compatible sees them in-process. The model never knows which
|
|
8
|
+
path it's on.
|
|
9
|
+
|
|
10
|
+
## Tool families
|
|
11
|
+
|
|
12
|
+
| Toolset | Tools | Purpose |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| `memory` | `memory_search`, `memory_get`, `memory_list`, `memory_write`, `memory_edit`, `memory_delete` | Read/write across the three layers — agent memory inbox, shared wiki, read-only vault. Hybrid retrieval (vector + BM25) with per-source boost; filler words are dropped from the keyword side and a page whose slug names a query word is lifted, so `memory_search "walter"` finds the page about Walter, not the pages that mention him most (see `memory.md`). |
|
|
15
|
+
| `dream` | `dream_list`, `dream_get`, `dream_apply`, `dream_dismiss`, `dream_run`, `dream_review` | Inspect findings from REM (per-agent) and Lucid (platform-wide); trigger Deep/Lucid via `dream_run({phase: 'deep'\|'lucid'})`. `dream_review({dream_id, action:'start'\|'end'})` opens/closes a conversational wiki-edit loop for a Lucid run. See `dream-phases.md`. |
|
|
16
|
+
| `wiki` | `wiki_edit`, `wiki_create`, `wiki_delete`, `wiki_move` | Loop-scoped wiki write tools. Only exposed to the agent currently holding the active `dream_review` loop; otherwise hidden. `wiki_edit` mutates body and/or `related:`/`sources:` frontmatter; `wiki_move` moves or renames a page into a folder the wiki map lists and rewrites every `[[link]]` to it. A per-turn cap on wiki_* calls (`wiki.lucid.maxCallsPerTurn`, default 3) keeps the model from batch-editing without user check-in. See `dream-phases.md`. |
|
|
17
|
+
| `time` | `time_now` | Current date/time/timezone — model never hallucinates "today". |
|
|
18
|
+
| `web` | `web_search`, `web_fetch` | Search via Brave + fetch web pages as Markdown (Mozilla Readability + SSRF guards). |
|
|
19
|
+
| `file` | `file_read`, `file_write`, `file_patch`, `file_search`, `file_list`, `analyze_file` | Generic filesystem I/O — local or against any configured SSH resource via `target=...`. `analyze_file` is the multimodal companion for models that cannot see: it dispatches images/PDFs to the configured `vision.worker` — a single model or an ordered chain tried until one answers — and returns a text description. It is hidden from any agent whose active model has the `image` capability (see `files.md`). `file_read` returns numbered lines (`N: text`, 2000 per call, with the offset to continue), `file_patch` tolerates whitespace and indentation drift between the model's `old_string` and the file and shows a diff of what changed, `file_search` takes `include` globs, `context` lines and `files_only`, `file_list` walks recursively with a glob and honours `.gitignore`; output that had to be shortened is kept in full under `~/.somora/agents/<agent>/tool-output/` and the result names the file. Limits and the matching chain in `files.md`. For a builder agent, a write or patch result also carries the language server's `errors` for the file (`lsp.md`). |
|
|
20
|
+
| `exec` | `exec`, `process` | One-shot shell commands (sync + background) on local or any SSH resource. Hard-blacklisted destructive patterns; per-resource `allowBlocked` opt-in lets dedicated agent-workstations whitelist admin commands like `sudo …` or `systemctl reboot` (see `resources.md`). Background jobs are fully detached (survive somora/MCP restarts until they finish or are killed) and disk-tracked with poll/log/kill via `process` — poll verifies real process liveness (exit-code file + PID probe), never a stale in-memory state. |
|
|
21
|
+
| `exec` (tool `tmux`) | `tmux` | Persistent multi-turn terminal sessions (claude/codex/vim/REPLs). One typed tool with `action: create | send | capture | list | kill` against `target: local | <ssh-resource>`. See `tmux.md` for shell-vs-TUI patterns, `wait_mode` choices, `multiline_safe`, `include_ansi`, and the auto-suggestion safety rule. |
|
|
22
|
+
| `agents` | `spawn_subagent`, `spawn_subagents`, `subagent_status`, `subagent_result`, `subagent_list`, `subagent_cancel`, `agent_ask`, `agent_ask_result`, `agent_ask_cancel`, `session_list`, `session_model`, `builder_dispatch` | Agent-to-agent orchestration. `spawn_*` create sealed sub-sessions for delegated work; `subagent_*` poll/collect results — a `done` result carries the sub's final text plus runtime-derived facts the model cannot fake: `outcome` (`completed` / `partial` — the engine had to force a finish at the round cap or tool budget / `degraded` — the text is a somora marker, the sub looped or never answered / `failed`) with `outcome_reason`, `tool_calls` and `rounds`, `files_written` (files created or edited via `file_write`/`file_patch`), and `media` (absolute paths of every image or video the sub generated, straight from the media store). All of these are present even when the final text degraded, and the `[subagent attention]` wake names outcome, files and media too; `subagent_cancel` cancels a spawn tree of your own, running or still waiting in its queue (cascades to child-spawns, disk artifacts untouched). Finished async subs wake their parent with a `[subagent attention]` turn unless spawned with `attention:false` or the result was already fetched. Every spawn is such a background task: `wait:true` waits for it and returns the result inline plus its `task_id`, so a synchronous sub is listed by `subagent_list`, stoppable, and reached by `subagent_cancel` together with its children while the parent waits; when the wait runs out (`agentLoop.longTaskMaxTimeoutMs`) the tool returns `state: "pending"` with the `task_id`, the sub keeps running and the parent is woken when it finishes. Child spawns count against the parent persona's concurrent cap (4), with the last slot reserved for top-level spawns so an orchestrator sub can never lock its own agent out. `agent_ask` posts a live question into another agent's existing session (request-response: the target's normal reply flows back as the tool result). The target sees `[Message from agent <name>, session <slug>]`, so it can address a follow-up; an `agent_ask` without `session` that answers the agent who wrote to it (or a sub's spawning parent, or — from an `[agent answer]` wake turn — the agent whose answer woke it) goes back to the session that message came from, otherwise to `main` — an explicit `session` always wins, and an unknown slug returns the target's existing sessions instead of a bare 404. With `create_session: true` (and optionally `model: "<alias>"`) a missing project session is created on the target, the model pinned on it and the target told — so "work with <agent-a> and <agent-b> in their <project> sessions, create them if needed, <agent-a> on <alias-1> and <agent-b> on <alias-2>" is two calls; the model is only applied to a session the call creates, never to an existing one. When the target does not answer within `timeout_ms`, `agent_ask` returns `state: "pending"` with a `call_id` — and when that answer finally lands, the asker is **woken** with the first lines of it and the call_id to read the rest (the same attention wake a finished sub-agent sends). `wait: false` hands the message over and returns `pending` at once, for jobs that may take their time; the wake is the same. `agent_ask_result` fetches or waits for that call's outcome (`done` / `failed` / `pending` with `phase` queued or running) — the message is never re-sent, so the target's work cannot run twice. `agent_ask_cancel` takes a call of your own back: out of the target's queue while it waits (`removed`), or, while it runs, by telling the target to stop through its running turn and letting the outcome wake nobody (`withdrawn`, `steered` says whether the stop message reached the turn) — it never aborts the target's turn. A target that answered "I am working on it with sub-agents and will report back" does not have to remember to: when the work it started while answering finishes later — its subs, calls of its own, and whatever those start — the asker hears the outcome once, as a follow-up: an ordinary message from the target under the original `call_id` for an agent, one more `[subagent attention]` wake with the text in `follow_ups` of `subagent_result` for a parent, a spoken follow-up for a voice call; so an asker never re-asks. Both `agent_ask` and the `spawn_*` tools take `images: ["/absolute/path.png"]` — pictures the receiving agent SEES (somora uploads them and puts them on that turn), because a path in the message text is just text to a model; a target whose model has no vision gets the vision worker's description instead. Blocking A2A waits are deadlock-guarded — the server tracks who waits on whom and rejects any call that would close a wait cycle (even across chains of 3+ agents) with an instructive error instead of letting both sessions hang. `session_model` switches the model of an EXISTING session — the agent's own (default: the one it is in) or another agent's, named by `agent` + `session` — or clears the override with `clear:true`; the running turn keeps its model, the next one uses the new one, and the switch is written into that conversation with the agent's name and shown in every open window. (`agent_ask` with `create_session` + `model` remains the way to pin a model on a session that does not exist yet.) `session_list` is the read-only view of somora's chat sessions — the agent's own by default, another agent's with `agent`, everyone's with `"*"`: session name (usable as `session` in `agent_ask` and sentinel dispatch), last activity, message count, pinned project, whether a turn is running there right now and how many wait behind it, and which row is the session the agent is in. See `agents.md`. `builder_dispatch` hands a build order to a builder agent (kind: builder, see `builder.md`) in one call — fresh session, project pinned, unattended + build — and returns a call_id; the caller is woken with the builder's report like with any agent_ask (wait:false). `builder` may be omitted when exactly one builder exists; a project folder another builder is working in right now is refused (one builder per folder, see `builder.md`). |
|
|
23
|
+
| `media` | `media_list` | Find images and video generated earlier, newest first, with an optional `type` filter. Its own toolset because the gallery is shared: a video-only install still needs to list what it made. |
|
|
24
|
+
| `video` | `video_generate`, `video_status`, `video_models` | Job-based text-to-video. `video_generate` returns immediately and the agent is woken when the render lands — it never waits. Global concurrency cap; the caller that finds it full is refused with the numbers rather than queued. `reference_images` takes paths and the order means something (one = opening frame, two = opening and closing). Hidden unless `videoGen` is configured. See `videogen.md`. |
|
|
25
|
+
| `image` | `image_generate`, `image_models` | Text-to-image against a configured image model, plus an index over everything generated. Specs (`aspect_ratio`, `resolution`, `quality`, `n`, …) are real request fields, validated against what the selected model actually accepts; the prompt is passed through verbatim. Returns paths and metadata rather than bytes — `return_image: true` opts into the image entering the agent's context. `reference_images` takes file paths (image-to-image); several may be combined. `image_models` lists the configured handles and what each one accepts. Hidden unless `imageGen` is configured. See `imagegen.md`. |
|
|
26
|
+
| `memory` (tag) | `somora_docs_list`, `somora_docs_read` | Read somora's own documentation (this directory). Tagged `memory` for gating (`toolset:memory`), grouped with the other read-only discovery tools. |
|
|
27
|
+
| `memory` (tag) | `resource_list`, `resource_test` | Discover and probe configured remote SSH targets. Tagged `memory` for gating, like the docs tools. |
|
|
28
|
+
| `mcp` | `mcp__<server>__*` | Tools imported from external [MCP servers](mcp.md) configured in `mcp.servers`. Discovered at runtime, schema-sanitized, namespaced per server, and gateable per agent like any built-in tool. |
|
|
29
|
+
| `browser` (optional) | `browser` | A managed Chromium per agent profile, with one window per agent when a profile is shared: `open` (with per-tab `device`/`locale` emulation), `snapshot` (accessibility tree with element refs), `act` (click/fill/press/scroll/select), `screenshot`, `tabs`, `status`, `request_handoff` (the user signs in or decides in the web client, the agent is woken to continue in the same tab), `close_tab`, `stop`. Hidden unless `browser.enabled`; the browser ability is also checked at execution. Handoffs appear in the source chat and taskbar, belong to the requesting agent's window alone, and require an existing, non-archived source session. See `browser.md`. |
|
|
30
|
+
| `builder` | `todo_write`, `ask_user`, `plan_write` | The builder kind's own tools (see `builder.md`): the session task list shown in the task panel, a question to the person watching (blocks until answered or timed out; only offered while the session is attended), and the plan file (the one write allowed in the plan phase). Offered to builders by their kind allow-list; a chat agent sees them only when its `tools.allow` names them. |
|
|
31
|
+
| `sentinel` | `sentinel` | Time-based triggers that wake an agent on a schedule — one action-enum tool: `create`, `list` (fired one-shots hidden unless `include_completed`), `get`, `pause`, `resume`, `delete`, `test`, `history`, `purge_completed` (drop every fired one-shot at once). See `sentinel.md`. |
|
|
32
|
+
| `projects` (optional) | `entity_list`, `project_list`, `project_get`, `project_create`, `project_update`, `project_focus` | Pointer-file manifests that bind a session to a real-world thing. Visible only with `projects.enabled: true` (registered always, hidden by their availability probe otherwise). See `projects.md`. |
|
|
33
|
+
| `skills` | `skill`, `skill_list` | Activate a Markdown skill ("how to do task X with our tools"), or list all skills available to the agent. Skills live at `~/.somora/skills/<slug>/SKILL.md` (agentskills.io format). The system prompt carries a name+description registry; `skill` loads the full body on demand, `skill_list` re-fetches the registry fresh from disk (useful when an engine froze the system prompt at session start). See `skills.md`. |
|
|
34
|
+
|
|
35
|
+
## Definition shape
|
|
36
|
+
|
|
37
|
+
A tool is a `ToolDefinition` (see `src/tools/types.ts`) with:
|
|
38
|
+
|
|
39
|
+
- `name` — globally unique (also the MCP method / OpenAI function name)
|
|
40
|
+
- `toolset` — grouping tag
|
|
41
|
+
- `description` — what the LLM sees in the tool list. Long-form
|
|
42
|
+
preferred: descriptions are policy, not just API docs ("use this
|
|
43
|
+
INSTEAD of running `cat` via exec").
|
|
44
|
+
- `inputSchema` — Zod schema for runtime validation
|
|
45
|
+
- `jsonSchema` — JSON Schema for MCP / OpenAI tool definitions
|
|
46
|
+
- `handler(input, ctx)` — receives validated input + a `ToolContext`
|
|
47
|
+
(`{ agent, getMemoryManager, config }`)
|
|
48
|
+
- `available?(ctx)` — optional runtime probe; tools that fail are
|
|
49
|
+
hidden from the model entirely (no API key → no `web_search`
|
|
50
|
+
exposed, etc.)
|
|
51
|
+
- `maxResultSizeChars?` — cap on the JSON-stringified result;
|
|
52
|
+
default 100 000 (≈25–35k tokens)
|
|
53
|
+
|
|
54
|
+
The registry truncates oversized results to a `{ truncated, preview,
|
|
55
|
+
hint, … }` marker so a runaway tool can't blow context.
|
|
56
|
+
|
|
57
|
+
## Where tools are wired
|
|
58
|
+
|
|
59
|
+
Two `ToolRegistry` instances exist by necessity:
|
|
60
|
+
|
|
61
|
+
- **In-process registry** in `src/server/index.ts` — used by the
|
|
62
|
+
openai-compatible engine's agent-loop and by HTTP debug endpoints
|
|
63
|
+
(`GET /tools`).
|
|
64
|
+
- **MCP child-process registry** in `src/mcp/server.ts` — spawned per
|
|
65
|
+
turn by claude-cli and grok-cli (different process, separate
|
|
66
|
+
memory). codex-cli uses the in-process registry: the app-server asks
|
|
67
|
+
somora (`item/tool/call`) and the tool runs in the server.
|
|
68
|
+
|
|
69
|
+
Both populate from a single `registerAllTools(registry)` function in
|
|
70
|
+
`src/tools/index.ts`. Adding a new tool bundle = ONE new
|
|
71
|
+
`registerMany()` line there; both engine surfaces pick it up. The
|
|
72
|
+
two registries are physically separate (process boundary) but the
|
|
73
|
+
code that fills them is shared, so the effective tool set is
|
|
74
|
+
identical across all three engines.
|
|
75
|
+
|
|
76
|
+
## When a call arrives broken
|
|
77
|
+
|
|
78
|
+
A model streams the arguments of a tool call as text, so a call can
|
|
79
|
+
arrive unusable in two different ways, and they need different answers:
|
|
80
|
+
|
|
81
|
+
- **Cut off** — the text stops mid-value, usually because the answer ran
|
|
82
|
+
out of output allowance while writing it. Retrying the same request
|
|
83
|
+
reproduces it exactly, so somora does not retry: it answers the call
|
|
84
|
+
with "arrived cut off after N characters … call it again with less in
|
|
85
|
+
one go", and adds the numbers when the round demonstrably spent its
|
|
86
|
+
whole allowance.
|
|
87
|
+
- **Malformed** — complete but not valid JSON, the kind of slip a second
|
|
88
|
+
attempt usually does not repeat. somora silently sends the same
|
|
89
|
+
request again, up to twice. Only if the model keeps producing invalid
|
|
90
|
+
JSON does it get told, with the parser's complaint and the reminder
|
|
91
|
+
that a tool without required parameters takes `{}`.
|
|
92
|
+
|
|
93
|
+
The two are told apart structurally: a complete JSON value ends on its
|
|
94
|
+
closing bracket. Not by the provider's stop reason — routers rewrite it.
|
|
95
|
+
vLLM replaces `length` with `tool_calls` whenever it parsed a tool call,
|
|
96
|
+
so the stop reason cannot show an output limit at all.
|
|
97
|
+
|
|
98
|
+
Neither fault ever travels back to the model. Backends parse tool-call
|
|
99
|
+
arguments while building the next prompt, so returning the text means
|
|
100
|
+
the whole request is rejected — and since the call sits in the running
|
|
101
|
+
conversation, every following round of that turn is rejected too. The
|
|
102
|
+
call keeps its place in the message (dropping it would leave a reply
|
|
103
|
+
without its call, which backends refuse just as hard) but its arguments
|
|
104
|
+
are replaced by an empty object. The unparsed text stays in the session
|
|
105
|
+
record, where it is evidence rather than a payload.
|
|
106
|
+
|
|
107
|
+
## Background reading
|
|
108
|
+
|
|
109
|
+
- `display.md` — `/show` and `/verbose` toggles for the TUI
|
|
110
|
+
- `thinking.md` — cross-engine thinking depth control
|
|
111
|
+
- `memory.md` — per-agent memory inbox + retrieval mechanics
|
|
112
|
+
- `wiki.md` — shared long-term wiki layer
|
|
113
|
+
- `dream-phases.md` — REM/Deep/Lucid background consolidation
|
|
114
|
+
- `resources.md` — SSH targets that file_* / exec / tmux dispatch to
|
|
115
|
+
- `skills.md` — Markdown skill system + per-agent visibility (deny/allow, Abilities window)
|
|
116
|
+
- `files.md` — file_* tools + multimodal `analyze_file`
|
|
117
|
+
- `tmux.md` — shell-vs-TUI session patterns + capture/send modes
|