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.
Files changed (404) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +364 -0
  3. package/bin/node-version.d.mts +3 -0
  4. package/bin/node-version.mjs +45 -0
  5. package/bin/somora.mjs +77 -0
  6. package/config.example.yaml +896 -0
  7. package/docs/agents.md +677 -0
  8. package/docs/api.md +3194 -0
  9. package/docs/browser.md +317 -0
  10. package/docs/builder.md +331 -0
  11. package/docs/cache-strategy.md +373 -0
  12. package/docs/compaction.md +253 -0
  13. package/docs/display.md +154 -0
  14. package/docs/dream-phases.md +891 -0
  15. package/docs/files.md +387 -0
  16. package/docs/imagegen.md +366 -0
  17. package/docs/images/somora-hero.png +0 -0
  18. package/docs/images/somora-mobile-2026-05-23.png +0 -0
  19. package/docs/images/somora-tui-2026-05-23.png +0 -0
  20. package/docs/images/somora-web-2026-05-23.png +0 -0
  21. package/docs/index.md +178 -0
  22. package/docs/lsp.md +93 -0
  23. package/docs/mcp.md +332 -0
  24. package/docs/memory.md +407 -0
  25. package/docs/mobile.md +310 -0
  26. package/docs/models.md +379 -0
  27. package/docs/projects.md +425 -0
  28. package/docs/realtime-voice.md +293 -0
  29. package/docs/resources.md +230 -0
  30. package/docs/sampling.md +128 -0
  31. package/docs/security.md +189 -0
  32. package/docs/sentinel.md +295 -0
  33. package/docs/setup.md +1217 -0
  34. package/docs/skills.md +501 -0
  35. package/docs/team.md +189 -0
  36. package/docs/thinking.md +463 -0
  37. package/docs/tmux.md +399 -0
  38. package/docs/tools.md +117 -0
  39. package/docs/videogen.md +191 -0
  40. package/docs/voice.md +288 -0
  41. package/docs/web.md +893 -0
  42. package/docs/wiki.md +583 -0
  43. package/npm-shrinkwrap.json +5670 -0
  44. package/package.json +116 -0
  45. package/src/attachments/store.ts +196 -0
  46. package/src/browser/change-stream.ts +31 -0
  47. package/src/browser/display.ts +108 -0
  48. package/src/browser/policy.ts +121 -0
  49. package/src/browser/screencast.ts +374 -0
  50. package/src/browser/service.ts +1337 -0
  51. package/src/browser/session.ts +15 -0
  52. package/src/browser/snapshot.ts +40 -0
  53. package/src/cli/auth.ts +117 -0
  54. package/src/cli/codex.ts +41 -0
  55. package/src/cli/lsp.ts +71 -0
  56. package/src/cli/resolvers/clawhub.ts +400 -0
  57. package/src/cli/setup.ts +835 -0
  58. package/src/cli/skill.ts +619 -0
  59. package/src/cli/somora.ts +548 -0
  60. package/src/cli/systemd-unit.ts +72 -0
  61. package/src/cli/team.ts +148 -0
  62. package/src/cli/tui/activity-stream.ts +121 -0
  63. package/src/cli/tui/api.ts +479 -0
  64. package/src/cli/tui/app.tsx +1169 -0
  65. package/src/cli/tui/autocomplete.tsx +55 -0
  66. package/src/cli/tui/commands.ts +913 -0
  67. package/src/cli/tui/dream-glyphs.ts +22 -0
  68. package/src/cli/tui/footer.tsx +15 -0
  69. package/src/cli/tui/format.ts +28 -0
  70. package/src/cli/tui/header.tsx +279 -0
  71. package/src/cli/tui/index.tsx +120 -0
  72. package/src/cli/tui/markdown.tsx +63 -0
  73. package/src/cli/tui/sampling.ts +162 -0
  74. package/src/cli/tui/separator.tsx +13 -0
  75. package/src/cli/tui/state.ts +42 -0
  76. package/src/cli/tui/stream.ts +330 -0
  77. package/src/cli/tui/thinking-text.ts +54 -0
  78. package/src/cli/tui/turn-views.tsx +499 -0
  79. package/src/cli/tui/types.ts +410 -0
  80. package/src/cli/tui/work-queue.ts +161 -0
  81. package/src/cli/update-args.ts +55 -0
  82. package/src/cli/wiki.ts +406 -0
  83. package/src/compaction/index.ts +28 -0
  84. package/src/compaction/midturn.ts +210 -0
  85. package/src/compaction/policy.ts +154 -0
  86. package/src/compaction/summarize.ts +691 -0
  87. package/src/compaction/template.ts +90 -0
  88. package/src/compaction/types.ts +148 -0
  89. package/src/config/loader.ts +276 -0
  90. package/src/config/reload.ts +43 -0
  91. package/src/config/types.ts +2292 -0
  92. package/src/dream/deep-actions.ts +324 -0
  93. package/src/dream/deep-dispatcher.ts +237 -0
  94. package/src/dream/deep-llm.ts +388 -0
  95. package/src/dream/deep-prompts.ts +106 -0
  96. package/src/dream/deep-runner.ts +757 -0
  97. package/src/dream/deep-skip-cache.ts +199 -0
  98. package/src/dream/deep-worker.ts +229 -0
  99. package/src/dream/json-salvage.ts +34 -0
  100. package/src/dream/judge.ts +188 -0
  101. package/src/dream/loop-state.ts +286 -0
  102. package/src/dream/lucid-actions.ts +303 -0
  103. package/src/dream/lucid-batches.ts +94 -0
  104. package/src/dream/lucid-prompt.ts +82 -0
  105. package/src/dream/lucid-runner.ts +744 -0
  106. package/src/dream/lucid-storage.ts +277 -0
  107. package/src/dream/lucid-structure.ts +102 -0
  108. package/src/dream/lucid-types.ts +137 -0
  109. package/src/dream/lucid-worker.ts +224 -0
  110. package/src/dream/rem-dedup.ts +502 -0
  111. package/src/dream/rem-extract.ts +782 -0
  112. package/src/dream/rem-reset-run.ts +67 -0
  113. package/src/dream/rem-runner.ts +696 -0
  114. package/src/dream/rem-worker.ts +527 -0
  115. package/src/dream/review-window.ts +71 -0
  116. package/src/dream/scheduler-state.ts +129 -0
  117. package/src/dream/storage.ts +497 -0
  118. package/src/dream/types.ts +133 -0
  119. package/src/dream/wiki-context.ts +133 -0
  120. package/src/engine/a2a.ts +33 -0
  121. package/src/engine/availability.ts +63 -0
  122. package/src/engine/claude-cli.ts +969 -0
  123. package/src/engine/codex-app-server-client.ts +294 -0
  124. package/src/engine/codex-bin.ts +49 -0
  125. package/src/engine/codex-cli.ts +1014 -0
  126. package/src/engine/codex-dynamic-tools.ts +239 -0
  127. package/src/engine/codex-home.ts +63 -0
  128. package/src/engine/codex-thread-config.ts +74 -0
  129. package/src/engine/context-budget.ts +257 -0
  130. package/src/engine/engine-meta-labels.ts +211 -0
  131. package/src/engine/grok-cli.ts +941 -0
  132. package/src/engine/inline-think.ts +59 -0
  133. package/src/engine/model-availability.ts +105 -0
  134. package/src/engine/openai-compatible.ts +2464 -0
  135. package/src/engine/reasoning-retry.ts +83 -0
  136. package/src/engine/registry.ts +13 -0
  137. package/src/engine/replay.ts +195 -0
  138. package/src/engine/sampling.ts +90 -0
  139. package/src/engine/thinking-params.ts +264 -0
  140. package/src/engine/types.ts +269 -0
  141. package/src/engine/user-tag.ts +24 -0
  142. package/src/imagegen/aspect.ts +128 -0
  143. package/src/imagegen/generate.ts +642 -0
  144. package/src/imagegen/references.ts +75 -0
  145. package/src/imagegen/types.ts +154 -0
  146. package/src/lsp/client.ts +183 -0
  147. package/src/lsp/fake-server.helper.mjs +42 -0
  148. package/src/lsp/format.ts +29 -0
  149. package/src/lsp/index.ts +21 -0
  150. package/src/lsp/manager.ts +238 -0
  151. package/src/lsp/registry.ts +151 -0
  152. package/src/mcp/config.ts +117 -0
  153. package/src/mcp/hub/audit.ts +55 -0
  154. package/src/mcp/hub/bridge.ts +115 -0
  155. package/src/mcp/hub/catalog.ts +69 -0
  156. package/src/mcp/hub/credentials.ts +406 -0
  157. package/src/mcp/hub/env-expand.ts +14 -0
  158. package/src/mcp/hub/manager.ts +770 -0
  159. package/src/mcp/hub/normalize.ts +213 -0
  160. package/src/mcp/server.ts +368 -0
  161. package/src/mcp/tool-schema.ts +20 -0
  162. package/src/media/capabilities.ts +392 -0
  163. package/src/media/records.ts +175 -0
  164. package/src/media/store.ts +217 -0
  165. package/src/media/types.ts +69 -0
  166. package/src/memory/chunking.ts +168 -0
  167. package/src/memory/embeddings.ts +262 -0
  168. package/src/memory/index.ts +15 -0
  169. package/src/memory/inject.ts +197 -0
  170. package/src/memory/manager.ts +996 -0
  171. package/src/memory/registry.ts +176 -0
  172. package/src/memory/rescan.ts +101 -0
  173. package/src/memory/retrieval.ts +586 -0
  174. package/src/memory/shared-index.ts +372 -0
  175. package/src/memory/slug.ts +39 -0
  176. package/src/memory/storage.ts +385 -0
  177. package/src/memory/watcher.ts +134 -0
  178. package/src/multimodal/blocks.ts +101 -0
  179. package/src/multimodal/dimensions.ts +214 -0
  180. package/src/multimodal/load.ts +86 -0
  181. package/src/multimodal/mime.ts +135 -0
  182. package/src/multimodal/pdf-render.ts +80 -0
  183. package/src/multimodal/user-content.ts +266 -0
  184. package/src/persona/files.ts +144 -0
  185. package/src/persona/loader.ts +598 -0
  186. package/src/persona/skill-gating-store.ts +59 -0
  187. package/src/persona/tool-gating-store.ts +113 -0
  188. package/src/projects/focus.ts +186 -0
  189. package/src/projects/prompt-block.ts +106 -0
  190. package/src/projects/scheme.ts +107 -0
  191. package/src/projects/store.ts +144 -0
  192. package/src/projects/types.ts +73 -0
  193. package/src/sentinel/dispatcher.ts +97 -0
  194. package/src/sentinel/schedule.ts +271 -0
  195. package/src/sentinel/scheduler.ts +840 -0
  196. package/src/sentinel/store.ts +259 -0
  197. package/src/sentinel/types.ts +221 -0
  198. package/src/server/activity-stream.ts +160 -0
  199. package/src/server/ask-calls.ts +137 -0
  200. package/src/server/ask-wait-graph.ts +171 -0
  201. package/src/server/async-tasks.ts +199 -0
  202. package/src/server/builder-busy.ts +86 -0
  203. package/src/server/builder-prompt.ts +204 -0
  204. package/src/server/builder-questions.ts +117 -0
  205. package/src/server/builder-session.ts +249 -0
  206. package/src/server/chat-aborts.ts +83 -0
  207. package/src/server/claude-config-dir.ts +71 -0
  208. package/src/server/claude-credential-sync.ts +454 -0
  209. package/src/server/env-file.ts +100 -0
  210. package/src/server/env.ts +115 -0
  211. package/src/server/heal-session.ts +151 -0
  212. package/src/server/history-page.ts +46 -0
  213. package/src/server/index.ts +7244 -0
  214. package/src/server/lockfile.ts +89 -0
  215. package/src/server/logger.ts +67 -0
  216. package/src/server/logs.ts +187 -0
  217. package/src/server/loopback-fetch.ts +130 -0
  218. package/src/server/openai-client.ts +89 -0
  219. package/src/server/prompt-assembly.ts +334 -0
  220. package/src/server/restart-reconcile.ts +139 -0
  221. package/src/server/run-turn-fallback.ts +275 -0
  222. package/src/server/run-turn-types.ts +91 -0
  223. package/src/server/run-turn.ts +1474 -0
  224. package/src/server/sanitize-assistant-text.ts +112 -0
  225. package/src/server/session-export.ts +220 -0
  226. package/src/server/session-queue.ts +376 -0
  227. package/src/server/session-workdir.ts +49 -0
  228. package/src/server/sse-h2-safe.ts +61 -0
  229. package/src/server/sse-liveness.ts +162 -0
  230. package/src/server/sse-serializer.ts +161 -0
  231. package/src/server/start-turn.ts +249 -0
  232. package/src/server/steer-inbox.ts +107 -0
  233. package/src/server/tls-keeper.ts +153 -0
  234. package/src/server/tool-format.ts +167 -0
  235. package/src/server/turn-framing.ts +52 -0
  236. package/src/server/turn-origin-kind.ts +74 -0
  237. package/src/server/turn-origin.ts +40 -0
  238. package/src/server/work-ledger.ts +975 -0
  239. package/src/server/workspace.ts +114 -0
  240. package/src/setup/config-edit.ts +201 -0
  241. package/src/setup/presets.ts +71 -0
  242. package/src/setup/prompt.ts +163 -0
  243. package/src/setup/tailscale.ts +44 -0
  244. package/src/skills/bin-checks.ts +227 -0
  245. package/src/skills/bootstrap.ts +347 -0
  246. package/src/skills/env-scope.ts +175 -0
  247. package/src/skills/gating.ts +71 -0
  248. package/src/skills/lint.ts +202 -0
  249. package/src/skills/load.ts +368 -0
  250. package/src/skills/path-helpers.ts +102 -0
  251. package/src/skills/registry.ts +178 -0
  252. package/src/ssh/exec.ts +142 -0
  253. package/src/ssh/index.ts +12 -0
  254. package/src/ssh/known-hosts.ts +109 -0
  255. package/src/ssh/pool.ts +307 -0
  256. package/src/storage/sessions.ts +602 -0
  257. package/src/team/render.ts +149 -0
  258. package/src/team/resolve.ts +122 -0
  259. package/src/team/store.ts +124 -0
  260. package/src/team/types.ts +111 -0
  261. package/src/team/write.ts +95 -0
  262. package/src/testing/isolated-home.mts +46 -0
  263. package/src/tmux/attention-watcher.ts +272 -0
  264. package/src/tmux/attention.ts +336 -0
  265. package/src/tmux/list.ts +91 -0
  266. package/src/tmux/origin-store.ts +102 -0
  267. package/src/tmux/tui-markers.ts +267 -0
  268. package/src/tools/agents/ask-cancel.ts +94 -0
  269. package/src/tools/agents/ask-result.ts +235 -0
  270. package/src/tools/agents/ask.ts +704 -0
  271. package/src/tools/agents/builder-dispatch.ts +217 -0
  272. package/src/tools/agents/images.ts +104 -0
  273. package/src/tools/agents/index.ts +42 -0
  274. package/src/tools/agents/long-task-timeouts.ts +39 -0
  275. package/src/tools/agents/session-list.ts +136 -0
  276. package/src/tools/agents/session-model.ts +106 -0
  277. package/src/tools/agents/spawn.ts +845 -0
  278. package/src/tools/agents/status.ts +589 -0
  279. package/src/tools/browser/index.ts +6 -0
  280. package/src/tools/browser/ops.ts +145 -0
  281. package/src/tools/browser/tools.ts +184 -0
  282. package/src/tools/builder/short-descriptions.ts +80 -0
  283. package/src/tools/builder/tools.ts +222 -0
  284. package/src/tools/docs/index.ts +1 -0
  285. package/src/tools/docs/tools.ts +228 -0
  286. package/src/tools/dream/index.ts +11 -0
  287. package/src/tools/dream/tools.ts +1002 -0
  288. package/src/tools/exec/allowlist.ts +233 -0
  289. package/src/tools/exec/background-detach.helper.mts +27 -0
  290. package/src/tools/exec/blacklist.ts +336 -0
  291. package/src/tools/exec/concurrency.ts +150 -0
  292. package/src/tools/exec/fit-output.ts +82 -0
  293. package/src/tools/exec/index.ts +7 -0
  294. package/src/tools/exec/internal-env.ts +89 -0
  295. package/src/tools/exec/job-store.ts +403 -0
  296. package/src/tools/exec/local.ts +649 -0
  297. package/src/tools/exec/remote.ts +399 -0
  298. package/src/tools/exec/tools.ts +934 -0
  299. package/src/tools/file/analyze.ts +378 -0
  300. package/src/tools/file/index.ts +2 -0
  301. package/src/tools/file/local.ts +707 -0
  302. package/src/tools/file/lsp-hook.ts +72 -0
  303. package/src/tools/file/persona-guard.ts +61 -0
  304. package/src/tools/file/policy.ts +292 -0
  305. package/src/tools/file/read-format.ts +129 -0
  306. package/src/tools/file/remote.ts +680 -0
  307. package/src/tools/file/replace.ts +507 -0
  308. package/src/tools/file/search-window.ts +224 -0
  309. package/src/tools/file/tools.ts +658 -0
  310. package/src/tools/file/write-scope.ts +182 -0
  311. package/src/tools/gating.ts +106 -0
  312. package/src/tools/image/budget.ts +82 -0
  313. package/src/tools/image/index.ts +7 -0
  314. package/src/tools/image/tools.ts +601 -0
  315. package/src/tools/index.ts +99 -0
  316. package/src/tools/memory/index.ts +12 -0
  317. package/src/tools/memory/tools.ts +399 -0
  318. package/src/tools/projects/index.ts +1 -0
  319. package/src/tools/projects/tools.ts +643 -0
  320. package/src/tools/registry.ts +427 -0
  321. package/src/tools/resources/index.ts +8 -0
  322. package/src/tools/resources/tools.ts +176 -0
  323. package/src/tools/resources/visibility.ts +60 -0
  324. package/src/tools/sentinel/index.ts +1 -0
  325. package/src/tools/sentinel/tools.ts +592 -0
  326. package/src/tools/skill/index.ts +4 -0
  327. package/src/tools/skill/tools.ts +285 -0
  328. package/src/tools/time/index.ts +5 -0
  329. package/src/tools/time/tools.ts +123 -0
  330. package/src/tools/tmux/index.ts +1 -0
  331. package/src/tools/tmux/local.ts +277 -0
  332. package/src/tools/tmux/remote.ts +168 -0
  333. package/src/tools/tmux/tools.ts +1064 -0
  334. package/src/tools/tool-output.ts +97 -0
  335. package/src/tools/types.ts +227 -0
  336. package/src/tools/video/index.ts +1 -0
  337. package/src/tools/video/tools.ts +425 -0
  338. package/src/tools/web/fetch.ts +337 -0
  339. package/src/tools/web/index.ts +4 -0
  340. package/src/tools/web/tools.ts +186 -0
  341. package/src/tools/wiki/index.ts +1 -0
  342. package/src/tools/wiki/tools.ts +445 -0
  343. package/src/tts/cache-gc.ts +128 -0
  344. package/src/tts/prepare-for-tts.ts +114 -0
  345. package/src/tts/service.ts +332 -0
  346. package/src/types/events.ts +695 -0
  347. package/src/types/turn-origin.ts +53 -0
  348. package/src/version.ts +21 -0
  349. package/src/videogen/dialects.ts +222 -0
  350. package/src/videogen/generate.ts +484 -0
  351. package/src/videogen/jobs.ts +178 -0
  352. package/src/videogen/runner.ts +125 -0
  353. package/src/videogen/wake.ts +119 -0
  354. package/src/voice/realtime/call.ts +948 -0
  355. package/src/voice/realtime/consult.ts +293 -0
  356. package/src/voice/realtime/fake-provider.ts +134 -0
  357. package/src/voice/realtime/manager.ts +384 -0
  358. package/src/voice/realtime/openai-provider.ts +471 -0
  359. package/src/voice/realtime/persona.ts +227 -0
  360. package/src/voice/realtime/session-match.ts +116 -0
  361. package/src/voice/realtime/types.ts +182 -0
  362. package/src/wiki/conflict.ts +113 -0
  363. package/src/wiki/explorer.ts +578 -0
  364. package/src/wiki/index-builder.ts +172 -0
  365. package/src/wiki/language.ts +134 -0
  366. package/src/wiki/log-builder.ts +150 -0
  367. package/src/wiki/map.ts +258 -0
  368. package/src/wiki/migration/analyze.ts +304 -0
  369. package/src/wiki/migration/execute.ts +689 -0
  370. package/src/wiki/migration/refine.ts +402 -0
  371. package/src/wiki/migration/store.ts +100 -0
  372. package/src/wiki/move-page.ts +57 -0
  373. package/src/wiki/structure-file.ts +192 -0
  374. package/src/wiki/taxonomy.ts +140 -0
  375. package/src/wiki/templates.ts +163 -0
  376. package/src/wiki/types.ts +133 -0
  377. package/templates/skills/README.md +24 -0
  378. package/templates/skills/_templates/api-wrapper/SKILL.md +26 -0
  379. package/templates/skills/_templates/cli-wrapper/BOOTSTRAP.md +32 -0
  380. package/templates/skills/_templates/cli-wrapper/SKILL.md +24 -0
  381. package/templates/skills/_templates/default/SKILL.md +25 -0
  382. package/templates/skills/builder-handover/SKILL.md +96 -0
  383. package/templates/skills/builder-handover/assets/ORDER.md +12 -0
  384. package/templates/skills/skill-author/SKILL.md +110 -0
  385. package/tsconfig.json +22 -0
  386. package/web/dist/assets/index-BaVv6pB2.js +631 -0
  387. package/web/dist/assets/index-BaVv6pB2.js.map +1 -0
  388. package/web/dist/assets/index-V3FV3Z25.css +32 -0
  389. package/web/dist/favicon.svg +8 -0
  390. package/web/dist/index.html +20 -0
  391. package/web/package.json +36 -0
  392. package/web/tsconfig.json +25 -0
  393. package/web-mobile/dist/apple-touch-icon.png +0 -0
  394. package/web-mobile/dist/assets/index-BqKt7IMx.css +1 -0
  395. package/web-mobile/dist/assets/index-X_vRr6cd.js +88 -0
  396. package/web-mobile/dist/assets/index-X_vRr6cd.js.map +1 -0
  397. package/web-mobile/dist/favicon.svg +8 -0
  398. package/web-mobile/dist/icon-192.png +0 -0
  399. package/web-mobile/dist/icon-512.png +0 -0
  400. package/web-mobile/dist/index.html +27 -0
  401. package/web-mobile/dist/manifest.webmanifest +32 -0
  402. package/web-mobile/dist/service-worker.js +90 -0
  403. package/web-mobile/package.json +28 -0
  404. package/web-mobile/tsconfig.json +25 -0
@@ -0,0 +1,317 @@
1
+ # Shared browser
2
+
3
+ A real Chromium on the somora host that an agent drives with the
4
+ `browser` tool — and that you can watch and take over in the web
5
+ client, so a login with credentials the agent does not have, a 2FA
6
+ code or a passkey is yours to do and the agent continues in the same,
7
+ now signed-in tab. Everything else it does on its own — a captcha or
8
+ image puzzle included: it screenshots, reads the picture with a vision
9
+ model and tries, and asks for you only when that keeps failing.
10
+
11
+ The web client includes the live picture, manual control, browser list,
12
+ a chat notice with **Open browser** when an agent asks for you, and a
13
+ taskbar marker for pending requests. Chat, taskbar and list share one
14
+ change stream; reconnecting restores the current state automatically.
15
+
16
+ ## Setup
17
+
18
+ ```yaml
19
+ browser:
20
+ enabled: true
21
+ # executablePath: /usr/bin/chromium # auto-detected when unset
22
+ headed: false # true = Chromium with a window, see "Headed mode"
23
+ extraArgs: [] # extra Chromium flags, e.g. ["--proxy-server=http://proxy:3128"]
24
+ maxTabsPerAgent: 8
25
+ idleStopMinutes: 30
26
+ viewport: { width: 1280, height: 800 }
27
+ allowPrivate: [] # LAN hosts/CIDRs agents may open
28
+ deny: [] # hostnames never opened
29
+ profiles: {} # shared profiles, see below
30
+ ```
31
+
32
+ somora looks for `chromium`, `chromium-browser`, `google-chrome` and
33
+ the macOS app bundles; set `executablePath` for anything else. Without a
34
+ browser the tool is still listed but every op answers with what was
35
+ tried. `playwright-core` (no bundled browser) drives it.
36
+
37
+ The tool appears only when `browser.enabled` is true, and can be denied
38
+ per agent like any other toolset (`tools.deny: ['toolset:browser']` in
39
+ agent.yaml, or the Abilities window).
40
+
41
+ ## Headed mode
42
+
43
+ Headless Chromium tells every server and every page what it is: the
44
+ user agent reads `HeadlessChrome/151…` and `navigator.webdriver` is
45
+ true. Services with any bot filtering see that on the first request.
46
+ `headed: true` starts Chromium with a window instead, without the
47
+ automation flag and without Blink's `AutomationControlled` feature —
48
+ the user agent is the normal `Chrome/151…` and `navigator.webdriver`
49
+ is false, like a browser a person opened.
50
+
51
+ On a desktop the window goes to `$DISPLAY`. On a server without a
52
+ display somora starts a virtual X server per browser — **Xvfb**, a
53
+ system package you install once (Debian/Ubuntu `sudo apt install
54
+ xvfb`, Fedora `sudo dnf install xorg-x11-server-Xvfb`, Arch `sudo
55
+ pacman -S xorg-server-xvfb`; macOS needs nothing). It is stopped with
56
+ the browser. Nobody looks at that screen; the web client's live view
57
+ keeps working, it streams over CDP either way.
58
+
59
+ Without a display and without Xvfb the browser **refuses to start**
60
+ and says so — in the tool result, in `browser status`, in the browser
61
+ list of the web client and as `browser.headed_unavailable` in the log.
62
+ It does not fall back to headless, because that would silently bring
63
+ back the signals you switched headed on to avoid. Headed rendering
64
+ costs some CPU and memory more per browser.
65
+
66
+ What headed does not do: TLS fingerprints, canvas and behaviour
67
+ analysis, Turnstile-style challenges. A service with serious bot
68
+ protection may still tell.
69
+
70
+ `extraArgs` appends Chromium launch flags verbatim (proxy, window
71
+ size, sandbox flags). Both settings are per process: they apply to
72
+ every profile and take effect on the next browser start.
73
+
74
+ ## Per-tab device and locale
75
+
76
+ An agent can open a tab as a phone or in another language, the way
77
+ the device mode in Chrome DevTools does:
78
+
79
+ ```
80
+ browser { op: "open", url: "https://example.com", device: "iPhone 15", locale: "de-AT" }
81
+ ```
82
+
83
+ `device` is a Playwright device name (`iPhone 15`, `Pixel 7`, `iPad
84
+ Pro 11`, …; an unknown name is refused with examples) and sets user
85
+ agent, viewport, pixel ratio and touch of that one tab. `locale` is a
86
+ BCP-47 tag and sets `Accept-Language` and `navigator.language`. Other
87
+ tabs of the same browser are untouched; the tab's `emulation` field
88
+ in `tabs`/`status` shows what is active. Ask an agent "open the mobile
89
+ version" and it uses this.
90
+
91
+ ## Profiles and windows
92
+
93
+ A Chromium profile is a cookie jar. Every agent gets its own under
94
+ `~/.somora/browser/profiles/<agent>/`, so one agent being signed in to
95
+ a site does not sign another in. A profile is one Chromium process; it
96
+ starts on the first `open` and stops after `idleStopMinutes` without a
97
+ tool call or viewer — the profile, and with it the logins, stays on disk.
98
+
99
+ Agents that should share logins get a named profile:
100
+
101
+ ```yaml
102
+ browser:
103
+ profiles:
104
+ shared:
105
+ agents: [<agent-a>, <agent-b>]
106
+ ```
107
+
108
+ Shared means shared cookies and one Chromium process — Chromium allows
109
+ only one process per profile directory. It does **not** mean shared
110
+ tabs: every agent gets its own **window** on that process.
111
+
112
+ A window is `<browser id>@<agent>`, for example `profile:shared@<agent-a>`
113
+ or `agent:<your-agent>@<your-agent>`. It is the unit for everything you
114
+ and the agents touch:
115
+
116
+ - Each window lists and drives only its own tabs. An agent cannot
117
+ snapshot or click a tab in another agent's window, and `stop` closes
118
+ its own window; the process ends when the last window is gone.
119
+ - `maxTabsPerAgent` counts per window, not per process.
120
+ - Control, handoff and take-over are per window. While you drive one
121
+ agent's window, the other keeps working in its own, on the same Chromium.
122
+ - A login is still shared, because the cookie jar is. That is the point
123
+ of a shared profile: sign in once in one agent's window and the other
124
+ agent is signed in too.
125
+
126
+ An agent not listed on a profile cannot touch it.
127
+
128
+ `open` with `ephemeral: true` uses a throw-away profile next to the
129
+ agent's own — for "look at this without my logins" — deleted on `stop`.
130
+
131
+ ## The `browser` tool
132
+
133
+ One tool, `op`-variants:
134
+
135
+ | op | what |
136
+ |---|---|
137
+ | `open` | `url`, optional `tab` to navigate an existing tab, `ephemeral`, `device` / `locale` (per-tab emulation, see above). Returns `tab`, `generation`. |
138
+ | `snapshot` | Compact accessibility tree of a tab; interactive elements carry `[ref=e12]`. `full: true` for the raw tree. |
139
+ | `act` | `action` `click` / `fill` / `press` / `scroll` / `select` on a `ref` (`press`/`scroll` also without one), optional `value`, optional `generation`. |
140
+ | `screenshot` | PNG into `<workspace>/browser/<agent>/`, path returned. |
141
+ | `tabs`, `status` | What is open in **your** window; whether the browser runs, which profile and window (`view_id`), who controls it, the headed plan (`headless` / `display` / `xvfb` / `unavailable` with reason) and operator warnings. |
142
+ | `request_handoff` | `reason`, optional `resume_note`. Marks the browser as waiting for you. |
143
+ | `close_tab`, `stop` | Clean up. `stop` closes your window and keeps the profile; the Chromium stays up for other agents that still have one. |
144
+
145
+ The loop an agent runs is `open` → `snapshot` → `act` → `snapshot`.
146
+ Refs are valid until the next snapshot or navigation of that tab; the
147
+ tab's `generation` bumps on every navigation and `act` refuses a ref or
148
+ generation from an older page state, so a click never lands on an
149
+ element that happens to be new. Snapshot text is data from a website —
150
+ the tool description says so to the model.
151
+
152
+ ## Navigation policy
153
+
154
+ Public http(s) hosts are allowed unless on `deny`. Private networks
155
+ (RFC1918, loopback, link-local, ULA) are blocked unless the host or CIDR
156
+ is on `allowPrivate` — a page an agent reads could otherwise send it to
157
+ an internal service. Hostnames are resolved before the check. `file:`,
158
+ `chrome:` and everything else never load.
159
+
160
+ Checked before every `open`, on every document request the browser
161
+ makes (route interception) and after every navigation: a redirect into
162
+ a forbidden host cannot be intercepted before Chromium follows it, so
163
+ the tab is reset to `about:blank` right after and the next op reports
164
+ where it was sent. That first request has been made by then — same
165
+ limit OpenClaw documents; not a network firewall.
166
+
167
+ ## In the web client
168
+
169
+ A **browser** tile appears on the desktop once `browser.enabled` is
170
+ true. It opens the **browser sessions** list: one row per open window,
171
+ named by the agent that owns it, with its profile, tab count, the
172
+ active tab's title and the control state — *agent controls*, *waiting
173
+ for you*, *human controls*. Two agents on a shared profile are two
174
+ rows. A row opens that window.
175
+
176
+ Only running windows are listed, the way the tmux session list only
177
+ shows live sessions. The single exception is a stopped browser that
178
+ still holds an unanswered handoff: it stays, with **Reopen browser**,
179
+ because it is the only trail back to that request.
180
+
181
+ The window streams the active tab live (JPEG screencast over a
182
+ WebSocket, paced so a slow viewer drops frames instead of buffering
183
+ them), with a tab bar, URL bar, back/forward/reload and the two
184
+ buttons that matter:
185
+
186
+ - **Take over** — you take control of this window: clicks, wheel,
187
+ typing (umlauts, dead keys and paste included) and the URL bar go to
188
+ the page, the remote viewport follows your window size, and this
189
+ agent's operations are refused until you hand back. Another agent
190
+ sharing the profile keeps working in its own window. Other viewers of
191
+ the same window keep watching. A tab you open here belongs to this
192
+ window, so the agent can use it afterwards.
193
+ - **Hand back** — hands control back. If the agent had asked for
194
+ you (`request_handoff`), it is woken once in the session it asked
195
+ from: `[browser] The user handed browser '<view>' back to you
196
+ (handoff <id>). Reason you asked for it: …` plus its own resume
197
+ note, and the advice to take a fresh snapshot first accompanies the
198
+ turn beside that text. If you took over on your own
199
+ and did something (navigated, clicked, typed), the owner of this
200
+ window is woken, in the session of the last tab it used here:
201
+ `[browser] The user took over browser '<view>', did something there
202
+ (navigation, clicks or typing) and handed it back to you.`
203
+ The window you worked in decides who is woken, never the busiest
204
+ agent on the process. Looking and handing back unchanged wakes nobody. The wake shows up
205
+ in the chat as a centered *browser · <agent> · handed back* divider
206
+ (`from_system: 'browser'`), like tmux and sentinel wakes.
207
+
208
+ Watching needs no take-over. Closing the window stops the stream, not
209
+ the browser and not the agent's work. Control is per window, not per
210
+ tab: while you hold it, none of that agent's tabs move. The footer shows the streamed tab, the viewport size, the page
211
+ generation and the frame counter — useful when a picture looks stale
212
+ right after a navigation.
213
+
214
+ ## Handing the browser over
215
+
216
+ When a page needs you, the agent calls `request_handoff` and ends its
217
+ turn. The browser is now `handoff_requested`: every agent op is refused
218
+ with `BROWSER_HUMAN_CONTROL`, and the tool description tells the model
219
+ not to retry. The take-over buttons live in the browser window; the same
220
+ switch is an HTTP route:
221
+
222
+ ```bash
223
+ curl -sk -X POST https://localhost:18737/browser/agent:<your-agent>@<your-agent>/control \
224
+ -H 'Content-Type: application/json' -d '{"mode":"human"}'
225
+ # … sign in …
226
+ curl -sk -X POST https://localhost:18737/browser/agent:<your-agent>@<your-agent>/control \
227
+ -H 'Content-Type: application/json' -d '{"mode":"agent","handoffId":"<id>"}'
228
+ ```
229
+
230
+ The path is the window id. A bare browser id still works while only one
231
+ agent has a window on that process.
232
+
233
+ Handing back schedules one wake for the requesting agent in the session it
234
+ asked from (idempotent per handoff id). The wake's text records the
235
+ hand-back with the reason and the agent's own resume note; the
236
+ instruction to take a fresh snapshot before acting, because the page
237
+ may have changed while the user had it, is the turn's frame beside
238
+ that text (the same per-turn field that carries the memory-recall
239
+ block). A pending
240
+ handoff survives a server restart. It belongs to one window: another
241
+ agent on the same profile neither sees the request nor the hand-back.
242
+
243
+ The notice appears in the requesting chat, including when that chat is
244
+ opened later. Its reason and **Open browser** button remain until the
245
+ handoff is returned. The taskbar marker opens the browser list even
246
+ when that chat or browser window is closed. These are current-state
247
+ notices, not historical transcript messages.
248
+
249
+ `GET /browser/status` lists the open windows, plus stopped ones that
250
+ still hold a pending handoff.
251
+ `GET /browser/stream` sends that state initially and on changes; the web
252
+ client uses this stream instead of repeatedly fetching the list.
253
+
254
+ ## Recovery and limits
255
+
256
+ A viewer reconnects after a broken connection and keeps its selected
257
+ tab and controller identity. A disconnect never gives control back to
258
+ the agent. A different viewer can explicitly take over; only the current
259
+ controller can send input or hand back through the viewer socket.
260
+ Old-tab or old-navigation frames are discarded, and inputs based on
261
+ an obsolete frame are refused. Capture replacement waits for the old
262
+ CDP session to stop.
263
+
264
+ After a browser crash or server restart, every window that existed
265
+ comes back with its control state, and pending handoffs remain visible. **Reopen browser** launches a blank page in the
266
+ same persistent profile; saved cookies remain, but old tabs, submitted
267
+ forms and clicks are not replayed. Temporary profiles lose their data.
268
+ A pending handoff must still be returned by the user. Without a pending
269
+ handoff, a new explicit agent `open` may resume a stopped profile.
270
+
271
+ State writes use an atomic file replacement. A failed control-state write
272
+ refuses the transition. The wake is dispatched after the handoff is
273
+ cleared; there is no durable wake queue. If the server dies between that
274
+ write and dispatch, or the wake fails, the user must continue the chat
275
+ manually. Missing or archived source sessions are refused rather than
276
+ creating a new conversation under an arbitrary name.
277
+
278
+ Capture uses `browser.stream.maxFps` (default 15, capped at 20 by ack
279
+ pacing). A viewer with 2 MB buffered drops frames; a slow status reader
280
+ gets coalesced snapshots. Viewer input is limited to 64 KiB per message
281
+ and 64 pending commands. WebSocket ping/pong detects a dead viewer after
282
+ 80 seconds. The status stream has heartbeats and bounded writes too.
283
+ Idle cleanup does not stop a browser with a pending handoff, human
284
+ control, or an operation in progress.
285
+
286
+ The global browser switch and per-agent browser ability apply to direct
287
+ `/browser/op` requests as well as tool visibility. Human viewer access
288
+ uses the web application's existing access boundary.
289
+
290
+ ## Verification
291
+
292
+ Run `node --import tsx src/browser/service.test.mts` for real-Chromium
293
+ service tests, and the `change-stream.test.mts`, `screencast.test.mts`,
294
+ and `session.test.mts` files in the same directory for focused tests
295
+ (use `SOMORA_HOME=/tmp/somora-browser-unit` for isolated test logs).
296
+ After `npm --prefix web run build`, run:
297
+
298
+ ```bash
299
+ SOMORA_BROWSER_WEB_SMOKE=1 node --import tsx src/browser/web-smoke.test.mts
300
+ ```
301
+
302
+ This starts an isolated server, local OTP page and local model fixture,
303
+ with two agents on one shared profile, then drives `/web` through
304
+ takeover, OTP entry, reconnect and hand-back. It checks that the list
305
+ shows one row per window, that the second agent keeps working while you
306
+ control the first, notice removal, exactly one wake into the session
307
+ that asked, and the direct ability gate. It uses
308
+ temporary profiles and requires Chromium and permission to bind local
309
+ ports; the running installation is not used.
310
+
311
+ ## What it does not do
312
+
313
+ No upload/download UI, no passkeys or hardware keys (the remote
314
+ browser cannot see your devices), no audio/video, no free JavaScript
315
+ evaluation. Anti-bot detection is not evaded: a site that blocks
316
+ automation blocks this too, so test with your own applications before
317
+ a service like LinkedIn.
@@ -0,0 +1,331 @@
1
+ # Builder agents
2
+
3
+ A **builder** is an agent of a second kind. It is a coding harness inside
4
+ somora: the same server, the same sessions, tools and team as every
5
+ other agent, but in front of the conversation stands what a coding
6
+ harness puts there — rules for working in a repository, an environment
7
+ block, the repository's own instructions — instead of a persona's
8
+ personality, a wiki map and a memory-recall block. It gets a short
9
+ coding tool set, turns that may run for hours, a task list and a way to
10
+ ask the person watching. You talk to it in the chat like to any other
11
+ agent; another agent can hand it a brief the same way.
12
+
13
+ The kind is fixed at creation. A chat agent never becomes a builder and
14
+ a builder never becomes a chat agent: the files differ (a builder has no
15
+ `SOUL.md` and no `USER.md`), the prompt differs, the defaults differ.
16
+
17
+ ## Creating one
18
+
19
+ ```
20
+ ~/.somora/agents/<name>/
21
+ AGENTS.md frontmatter: name, description, role, icon, color — body: extra rules, optional
22
+ agent.yaml kind: builder, model, workspace, …
23
+ ```
24
+
25
+ ```yaml
26
+ # ~/.somora/agents/rudi/agent.yaml
27
+ kind: builder
28
+ model: deepseek # any configured alias; local models work well here
29
+ workspace:
30
+ path: ~/somoraworkspace # the default working directory (a pinned project overrides it)
31
+ steering: true # a message typed while it works goes INTO the turn
32
+ # agentLoop: # optional — the builder defaults are 500 rounds,
33
+ # maxRounds: 500 # 2000 tool calls and 8 hours per turn
34
+ # maxToolCallsPerTurn: 2000
35
+ # maxTurnMs: 28800000
36
+ # tools: # optional — add to or remove from the builder set
37
+ # allow: [browser]
38
+ # deny: [web_fetch]
39
+ ```
40
+
41
+ ```markdown
42
+ ---
43
+ name: rudi
44
+ description: Builds and changes software in the repository it is pointed at.
45
+ role: builder
46
+ icon: 🔨
47
+ ---
48
+ Repository-independent rules for this builder go here (short). The
49
+ harness rules come from somora; a repository's own AGENTS.md or
50
+ CLAUDE.md is read from the working directory.
51
+ ```
52
+
53
+ The dock shows the kind under the name and frames the tile grey. The
54
+ Abilities window has two views by kind: a builder's own set as one group
55
+ (switch off = `tools.deny`) and everything else under "more" (switch on
56
+ = `tools.allow`); a chat agent's full programme minus the three
57
+ builder-only tools. Skills the same way: a builder's switches edit the
58
+ allow-list, a chat agent's the denies.
59
+
60
+ ## What a builder sees
61
+
62
+ The system prompt, in order (`GET /agents/:agent/prompt-preview` shows
63
+ it byte for byte):
64
+
65
+ 1. **Identity + environment** — one line who it is; working directory,
66
+ whether that is a git repository, platform, model, date.
67
+ 2. **Harness rules** — how to work: everything through tools ("code in
68
+ your text is not saved"), read before patch, search before assuming,
69
+ verify after every change with the repository's own build/test
70
+ commands, smallest correct change, keep going until done, no
71
+ repeated identical calls, shell for terminal work only, git only when
72
+ asked, no secrets. The task list, decisions and questions, helpers
73
+ and colleagues, and what the final report contains.
74
+ 3. **Team (compact)** — the principal and the colleagues it can consult
75
+ with `agent_ask`, one line each, plus the team rules. No org chart.
76
+ 4. **Tool reminder**, **repository instructions** (`AGENTS.md`,
77
+ `CLAUDE.md` or `CONTEXT.md` from the working directory, first found,
78
+ capped at 20 000 chars), **skills**, **this session** with the
79
+ session's **mode and phase** (below), **project**.
80
+
81
+ Not in it: SOUL/USER prose, the wiki overview, and the per-turn memory
82
+ recall block — a builder gets no `<memory-context>`; it has
83
+ `memory_search` and `memory_get` as tools instead. Dreaming (REM) is off
84
+ unless `rem.enabled` is set in its `agent.yaml`.
85
+
86
+ Tools by default (`src/tools/gating.ts` `BUILDER_TOOL_ALLOW`):
87
+ `file_read`, `file_write`, `file_patch`, `file_search`, `file_list`,
88
+ `analyze_file` (offered only when the builder's model cannot see
89
+ images), `exec`, `process`, `todo_write`, `ask_user`, `plan_write`,
90
+ `spawn_subagent`, `subagent_result`, `subagent_cancel`, `agent_ask`, `agent_ask_result`,
91
+ `skill`, `skill_list`, `web_fetch`, `web_search`, `project_get`, `project_list`,
92
+ `project_create`, `project_focus`, `memory_search`, `memory_get`,
93
+ `time_now`. Everything else is off until `tools.allow` names it.
94
+
95
+ ## Mode and phase
96
+
97
+ Every builder session carries two switches, set on its first turn from
98
+ where that turn came from and changed any time in the task panel
99
+ (`PATCH …/builder`):
100
+
101
+ | | default when | what it does |
102
+ |---|---|---|
103
+ | **attended** | a person opened the session | `ask_user` is offered; the prompt says "for a real fork in the road, ask". |
104
+ | **unattended** | an agent handed over a brief | `ask_user` is hidden; the prompt says "decide yourself, note it in the report, never wait". |
105
+ | **plan** | a person opened the session | read, search, run read-only commands, ask; the only file written is the plan (`plan_write`). `file_write`, `file_patch`, `process`, `spawn_subagent` are hidden. Ends with **Go**. |
106
+ | **build** | an agent handed over a brief | edit, run, test, report. The plan file, if there is one, is approved. |
107
+
108
+ **The plan file** is `PLAN.md` in the pinned project's folder (the agent's
109
+ workspace when no project is pinned; the path moves into the folder as
110
+ soon as a project is pinned, an already written plan with it). A plan
111
+ file that is already there when a session writes its first plan — an
112
+ earlier build's, or one a person wrote — is not overwritten: it moves
113
+ aside as `PLAN-<date>-<session>.md`, the new plan becomes `PLAN.md`,
114
+ and the builder is told to say what of the old plan still stands.
115
+
116
+ **Go** (the button in the panel, `POST …/builder/go`) switches the phase
117
+ to build and sends the builder a message: the plan is approved, execute
118
+ it, keep the task list, end with the report. So a project can start
119
+ directly with the builder — describe it, let it plan, press Go — with
120
+ no orchestrator in between. When the order came from another agent
121
+ (`builder_dispatch` with `phase: "plan"`), Go runs the build as that
122
+ agent's detached ask: it is woken with the report when the build ends,
123
+ the same way it was woken with the plan.
124
+
125
+ ## The task panel
126
+
127
+ A builder's chat window has a panel docked on the right:
128
+
129
+ - **Running for** — while a turn runs: elapsed time, the number of
130
+ tool calls so far and the last tool, ticking every second; when the
131
+ last call is more than a minute old the age is shown too, so a stuck
132
+ turn is visible at a glance.
133
+ - **Mode** and **phase** switches, **Go** while planning, the plan
134
+ file's path.
135
+ - **Tasks** — the list the builder keeps with `todo_write`: one item
136
+ `in_progress` at a time, `completed` the moment it is verified.
137
+ - **Question** — when the builder called `ask_user`: the question, its
138
+ options as buttons (multiple choice when it said so), a free-text
139
+ field, and how long it will wait. The turn blocks until you answer or
140
+ the wait runs out (default 30 min); an unanswered question comes back
141
+ to the builder as "unanswered — decide yourself".
142
+
143
+ The panel reads `GET …/builder` and refreshes on every turn event and
144
+ every two seconds; the SSE events `builder_state`, `todo_updated`,
145
+ `question_asked` and `question_answered` exist for other clients.
146
+
147
+ ## Steering
148
+
149
+ A builder's turns are long. A message typed while it works goes into
150
+ the running turn before its next step when steering is on (the
151
+ **steer / queue** toggle next to Send; `steering: true` in agent.yaml
152
+ makes steer the default)
153
+ — see the *Steering* section of [api.md](api.md).
154
+
155
+ ## Handing over a brief
156
+
157
+ The bundled skill `builder-handover` (seeded into `~/.somora/skills/`
158
+ on start, see [skills.md](skills.md)) is the procedure for the agent
159
+ that plans with the person and hands the implementation over: switch it
160
+ on for that agent in its abilities. In short:
161
+
162
+ From another agent (an orchestrator) the hand-over is one call:
163
+ `builder_dispatch` creates a fresh session on the builder, pins the
164
+ project (its `workdir` becomes the working directory), sets the session
165
+ to unattended + build (or `phase: "plan"`: plan first, stop with "Plan
166
+ ready", the person presses Go) and sends the order; the caller returns at once
167
+ and is woken with the builder's report (an `[agent answer]` wake, read
168
+ with `agent_ask_result`). The builder's final answer is that report: an
169
+ order must not ask it to message the caller back. Without a project, name
170
+ the repository in the order. `builder` may be left out when exactly one
171
+ builder exists; with several, the caller names one, chosen by the team
172
+ description each builder carries (its role and what it is for).
173
+
174
+ **One builder per folder.** A builder's running turn claims its working
175
+ directory. A hand-over into a project whose folder is claimed — by any
176
+ builder, the same one in another session included — is refused with the
177
+ name of who works there; so is Go. Nested folders count as the same
178
+ folder. Orders into different folders run side by side; the claim ends
179
+ with the turn. A message typed straight into a builder session whose
180
+ folder another builder holds is refused the same way (the turn fails
181
+ with `folder busy: …` naming who works there). `GET /builders` lists the builders and where each is
182
+ working, `GET /builders/busy?workdir=…` answers for one folder. The order itself, in `task` (plus `plan_path`, `done_criteria`,
183
+ `report_path`):
184
+
185
+ > Read the plan at `<path>`. Implement it. Done means: `<criterion,
186
+ > e.g. tests green and feature X usable>`. Write the report to `<path>`
187
+ > at the end. Decide open questions yourself and list them in the
188
+ > report.
189
+
190
+ Then wait for the report — no interim check-ins, no corrections into
191
+ running work; a correction is a new message into that session, which
192
+ steers into the running turn or starts the next one. The session opened
193
+ this way starts **unattended** and in **build**. Every colleague's team
194
+ block says the same about a builder, so an orchestrator on any model
195
+ sees the rule.
196
+
197
+ ## Working directory
198
+
199
+ A builder works where its session points: the folder of the pinned
200
+ project (`workdir`, see [projects.md](projects.md)), else the agent's
201
+ workspace. Without a pinned project folder the prompt tells an attended
202
+ builder to ask for the repository or create and pin the project itself
203
+ (`project_create` with `workdir`, `project_focus`), and an unattended
204
+ one to report that no project folder was given. Helpers it spawns
205
+ inherit the pin and the folder, the mode and the build phase, and run on
206
+ the builder's own model (a helper is a clone of the agent, not of the
207
+ session's model override). The harness tells the builder to wait for a
208
+ helper (`subagent_result` with `wait:true`), never to message one while
209
+ it works, and never to let two helpers edit the same file — measured on
210
+ a Codex-driven build: 34 one-second polls and a note into a running
211
+ helper's session before the rule.
212
+
213
+ ## Errors after every write
214
+
215
+ With a language server installed (`somora lsp install`), every
216
+ `file_write` and `file_patch` result of a builder carries the errors the
217
+ server found in that file, and in other files this write broke — see
218
+ [lsp.md](lsp.md). The builder's environment block says which servers
219
+ are there.
220
+
221
+ ## Where a builder may write
222
+
223
+ A builder session pinned to a project folder writes only there and in
224
+ its own temp folder (`~/.somora/agents/<agent>/tmp/`). `file_write` and
225
+ `file_patch` check it after the path blacklist, on every engine:
226
+
227
+ - **unattended** — the write is refused; the message names the two
228
+ allowed folders and tells the builder to use a path inside the project
229
+ or explain in its report why a file is needed elsewhere.
230
+ - **attended** — a question appears in the task panel: *allow once*,
231
+ *allow this folder for the session* (kept on the session, so the next
232
+ write there passes), *deny*. No answer within five minutes counts as
233
+ deny.
234
+
235
+ The pin itself holds while the builder works: unpinning or switching the
236
+ project during a running builder turn is refused (the scope and the
237
+ working directory would move under it); a first pin is allowed. Chat agents
238
+ and a builder without a pinned folder keep the old rule (the blacklist
239
+ alone). The shell is not gated: `exec` can still write
240
+ anywhere, which is what command approvals would cover — and deleting
241
+ inside the project folder, `rm -rf` of its subfolders included, stays
242
+ allowed on purpose: the folder is the builder's to rebuild.
243
+
244
+ ## Limits and loop
245
+
246
+ A builder's turn on the openai-compatible engine runs with `maxRounds`
247
+ 500, `maxToolCallsPerTurn` 2000 and `maxTurnMs` 8 h (agent.yaml
248
+ `agentLoop:` overrides). Two brakes end a turn early with a request for
249
+ the report: the wall-clock cap, and a **doom loop** — the same tool
250
+ calls with the same arguments five rounds in a row (a notice goes to
251
+ the model after three). Both leave a trace in the session — engine
252
+ rows "loop noticed" and "loop stopped" naming the repeated calls — so a
253
+ reviewer sees why a turn was cut short, not only that it was. The
254
+ forced final answer names the reason (`turn_end.forced_final`:
255
+ `round_cap`, `tool_budget`, `time_cap`, `doom_loop`, `scaffold_leak`).
256
+
257
+ A round that produced reasoning but neither text nor a tool call was cut
258
+ off while thinking — the model's output cap (`maxTokens`, which includes
259
+ reasoning) ended the response inside the plan it was making, and the
260
+ stop reason cannot be trusted because routers rewrite it. The engine
261
+ does not take that silence as the answer: it tells the model its response
262
+ was cut off and to continue with shorter thinking, twice per turn at
263
+ most (`engine.reasoning_only_round` in the log). This applies to every
264
+ agent on the engine, not only builders; a chat agent that used to get an
265
+ empty reply gets the nudge instead.
266
+
267
+ ## Routes
268
+
269
+ - `GET /agents/:agent/sessions/:session/builder` → `{agent, session,
270
+ kind, state: {mode, phase, planPath, todos, orderer?} | null, question | null,
271
+ turn: {turnId, startedAt, toolCalls, lastTool?, lastToolAt?} | null}`
272
+ - `PATCH …/builder` `{mode?, phase?, planPath?, orderer?}` → `{state}`;
273
+ publishes `builder_state`
274
+ - `POST …/builder/go` `{note?}` → `{state, turnId, callId?, wakes?}`
275
+ (202): phase build + the Go message as a new turn; with an `orderer`
276
+ the turn is its detached ask (`callId`) and it is woken with the report
277
+ - `PUT …/todos` `{todos: [{content, status, priority?}]}` → `{todos}`;
278
+ publishes `todo_updated` (what `todo_write` calls)
279
+ - `PUT …/plan` `{content}` → `{path, bytes}` (what `plan_write` calls)
280
+ - `POST …/ask` `{question, header?, options[], multiple?, timeout_ms?}`
281
+ → blocks until `{answered, answers[], text?}` (what `ask_user` calls);
282
+ publishes `question_asked`
283
+ - `POST …/answer` `{questionId, answers?, text?}` → `{ok}`; publishes
284
+ `question_answered`
285
+
286
+ ## What keeps the builder's prompt small
287
+
288
+ Everything below hangs on `kind: builder`; chat agents are untouched:
289
+
290
+ - **Tool descriptions.** A builder's model sees a short description per
291
+ tool (`src/tools/builder/short-descriptions.ts`), a few lines of what
292
+ the tool takes and returns; the policy ("use file_read instead of
293
+ cat", when to ask) lives in the harness rules instead. A hidden tool
294
+ sends no description at all, and the harness section that names it
295
+ (task list, questions, helpers) is left out too. When a tool's
296
+ parameters change, the short text must follow — one file, one place.
297
+ - **Skills.** A builder sees no skill unless its `agent.yaml` allows it
298
+ (the Abilities window adds them one by one); a chat agent sees all but
299
+ the denied ones.
300
+ - **Team.** The compact team block names the principal and the
301
+ colleagues with their titles; the org chart and the involve-for lists
302
+ are for orchestrators.
303
+ - **No tool reminder, no wiki map, no memory recall block.**
304
+ - **Own rules.** The body of the builder's `AGENTS.md` (below the
305
+ frontmatter) is its "Rules for this builder" section, after the
306
+ harness rules. SOUL.md and USER.md are not read — the Agent window
307
+ does not offer them for a builder.
308
+
309
+ ## Long turns
310
+
311
+ Two things happen inside a builder turn on the openai-compatible engine
312
+ that a chat turn never needs:
313
+
314
+ - **Mid-turn compaction.** When the next request would not fit the
315
+ context window, the older rounds of the running turn (from its user
316
+ message up to the last six rounds) are summarised by a compaction
317
+ worker into a work-state block — objective, details, completed /
318
+ active / blocked, next move, relevant files — and replaced by one
319
+ message carrying it; the last six rounds stay verbatim and the turn
320
+ continues; the task list as last written with `todo_write` travels
321
+ with that block verbatim, so the builder keeps ticking it off after
322
+ the compaction. The session file keeps every record. The chat shows
323
+ an `engine_meta` row `context_compacted`. When no worker answers, the
324
+ old tool-result shortening applies as for chat agents.
325
+ - **A stale task list** — no `todo_write` for twelve tool rounds while
326
+ items are open — gets one line asking for an update, with the item
327
+ that is in progress named; measured, a model deep in its work stops
328
+ writing the list otherwise, and the list is what the person watches.
329
+ - **Checkpoints.** Every 100 tool rounds the builder is told to refresh
330
+ its task list and append a short status to its report file, so a
331
+ crash late in a long night loses minutes.