@bastani/atomic 0.10.9-alpha.1 → 0.10.10-alpha.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 (401) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +211 -155
  3. package/dist/_shared/dist-KOELCESV.js +2 -2
  4. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  5. package/dist/_shared/lib-4PES5P4V.js +2 -2
  6. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +27 -12
  7. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
  8. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +47 -7
  9. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
  10. package/dist/_shared/mode-shared-2QJSCUM6.js +48 -19
  11. package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
  12. package/dist/_shared/{p1a-prewarm-UQY3X2UK.js → p1a-prewarm-XIU57JHF.js} +5 -5
  13. package/dist/_shared/{p1a-prewarm-UQY3X2UK.js.map → p1a-prewarm-XIU57JHF.js.map} +1 -1
  14. package/dist/_shared/p2-shell-main-B2WIALFD.js +30 -25
  15. package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
  16. package/dist/_shared/runtime-O4KCSG4C.js +5 -5
  17. package/dist/_shared/{sdk-OSBEPR3Q.js → sdk-RRLVN7ER.js} +15 -9
  18. package/dist/_shared/sdk-RRLVN7ER.js.map +1 -0
  19. package/dist/_shared/session-data-AHTU7IS6.js +2 -2
  20. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  21. package/dist/_shared/settings-startup-8-DNZ2RIHM.js +4 -1
  22. package/dist/_shared/settings-startup-8-DNZ2RIHM.js.map +1 -1
  23. package/dist/_shared/{startup-0-0-TYUFUOJZ.js → startup-0-0-4VG2G44V.js} +427 -33
  24. package/dist/_shared/startup-0-0-4VG2G44V.js.map +1 -0
  25. package/dist/_shared/{startup-0-1-W2G2UY7R.js → startup-0-1-XTIL65D4.js} +18 -11
  26. package/dist/_shared/startup-0-1-XTIL65D4.js.map +1 -0
  27. package/dist/_shared/{startup-0-2-UXBUEOXW.js → startup-0-2-27OWFHV6.js} +145 -58
  28. package/dist/_shared/startup-0-2-27OWFHV6.js.map +1 -0
  29. package/dist/_shared/startup-0-3-T4DVFYWX.js +15 -25
  30. package/dist/_shared/startup-0-3-T4DVFYWX.js.map +1 -1
  31. package/dist/_shared/{startup-0-4-HN5EB4K7.js → startup-0-4-ZMJV547D.js} +81 -12
  32. package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -0
  33. package/dist/_shared/startup-0-5-FD2P735I.js +90 -50
  34. package/dist/_shared/startup-0-5-FD2P735I.js.map +1 -1
  35. package/dist/_shared/startup-10-0-TDQNBDDL.js +5 -5
  36. package/dist/_shared/startup-12-0-55AAXBJZ.js +13 -7
  37. package/dist/_shared/startup-12-0-55AAXBJZ.js.map +1 -1
  38. package/dist/_shared/startup-14-0-MLX36RBG.js +4 -4
  39. package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
  40. package/dist/_shared/startup-15-1-4S7FLMNG.js +88 -28
  41. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  42. package/dist/_shared/startup-8-0-34CBHPZH.js +5 -5
  43. package/dist/_shared/startup-8-1-4KANEHRA.js +61 -17
  44. package/dist/_shared/startup-8-1-4KANEHRA.js.map +1 -1
  45. package/dist/_shared/storage-command-7MGXLJGZ.js +4 -4
  46. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  47. package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
  48. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  49. package/dist/builtin/intercom/README.md +85 -114
  50. package/dist/builtin/intercom/broker/broker.bundle.mjs +3 -3
  51. package/dist/builtin/intercom/broker/presence-handler.ts +1 -1
  52. package/dist/builtin/intercom/group.ts +7 -3
  53. package/dist/builtin/intercom/index.bundle.mjs +1 -1
  54. package/dist/builtin/intercom/package.json +1 -1
  55. package/dist/builtin/mcp/README.md +37 -27
  56. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  57. package/dist/builtin/mcp/package.json +1 -1
  58. package/dist/builtin/subagents/CHANGELOG.md +8 -0
  59. package/dist/builtin/subagents/README.md +71 -138
  60. package/dist/builtin/subagents/package.json +1 -1
  61. package/dist/builtin/subagents/src/extension/index.bundle.mjs +213 -74
  62. package/dist/builtin/web-access/CHANGELOG.md +9 -0
  63. package/dist/builtin/web-access/README.md +60 -87
  64. package/dist/builtin/web-access/index.bundle.mjs +387 -351
  65. package/dist/builtin/web-access/package.json +1 -1
  66. package/dist/cli/args.js +2 -2
  67. package/dist/cli/auth-cli.code.js +4 -4
  68. package/dist/cli/auth-cli.impl.js +3 -3
  69. package/dist/cli/auth-cli.js +3 -3
  70. package/dist/cli/blueprint-command.code.js +2 -2
  71. package/dist/cli/blueprint-command.impl.js +3 -3
  72. package/dist/cli/blueprint-command.js +3 -3
  73. package/dist/cli/intercom-command.code.js +3 -3
  74. package/dist/cli/intercom-command.impl.js +3 -3
  75. package/dist/cli/intercom-command.js +3 -3
  76. package/dist/cli/list-models.code.js +3 -3
  77. package/dist/cli/list-models.impl.js +3 -3
  78. package/dist/cli/list-models.js +3 -3
  79. package/dist/cli/session-picker.code.js +2 -2
  80. package/dist/cli/session-picker.impl.js +3 -3
  81. package/dist/cli/session-picker.js +3 -3
  82. package/dist/cli/startup-ui.code.js +2 -2
  83. package/dist/cli/startup-ui.impl.js +3 -3
  84. package/dist/cli/startup-ui.js +3 -3
  85. package/dist/cli/storage-command.impl.js +3 -3
  86. package/dist/cli/storage-command.js +3 -3
  87. package/dist/cli/storage-search-session.code.js +2 -2
  88. package/dist/cli/storage-search-session.impl.js +3 -3
  89. package/dist/cli/storage-search-session.js +3 -3
  90. package/dist/cli/team-command.code.js +2 -2
  91. package/dist/cli/team-command.impl.js +3 -3
  92. package/dist/cli/team-command.js +3 -3
  93. package/dist/cli.js +2 -2
  94. package/dist/core/agent-session-methods.d.ts +4 -1
  95. package/dist/core/agent-session-methods.js.map +1 -1
  96. package/dist/core/agent-session.d.ts +3 -0
  97. package/dist/core/compaction/compactor.d.ts +20 -14
  98. package/dist/core/compaction/errors.d.ts +120 -0
  99. package/dist/core/compaction/index.d.ts +1 -0
  100. package/dist/core/compaction/model-resolver.d.ts +2 -2
  101. package/dist/core/debug.impl.js +3 -3
  102. package/dist/core/debug.js +3 -3
  103. package/dist/core/export-html/card-projection.impl.js +3 -3
  104. package/dist/core/export-html/card-projection.js +3 -3
  105. package/dist/core/export-html/index.code.js +2 -2
  106. package/dist/core/export-html/index.impl.js +3 -3
  107. package/dist/core/export-html/index.js +3 -3
  108. package/dist/core/export-html/json-spans.impl.js +3 -3
  109. package/dist/core/export-html/json-spans.js +3 -3
  110. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  111. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  112. package/dist/core/export-html/tool-renderer.code.js +1 -1
  113. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  114. package/dist/core/export-html/tool-renderer.js +3 -3
  115. package/dist/core/extensions/api-types.d.ts +1 -1
  116. package/dist/core/extensions/api-types.js.map +1 -1
  117. package/dist/core/extensions/index.d.ts +1 -1
  118. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  119. package/dist/core/extensions/jiti-loader.js +3 -3
  120. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  121. package/dist/core/extensions/jiti-static-loader.js +3 -3
  122. package/dist/core/extensions/loader-host-modules.code.js +1 -1
  123. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  124. package/dist/core/extensions/loader-host-modules.js +3 -3
  125. package/dist/core/extensions/loader-virtual-modules.js +1 -1
  126. package/dist/core/extensions/provider-types.d.ts +18 -6
  127. package/dist/core/extensions/provider-types.js.map +1 -1
  128. package/dist/core/extensions/runner-context.js +1 -1
  129. package/dist/core/intercom-broker-control-host.code.js +1 -1
  130. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  131. package/dist/core/intercom-broker-control-host.js +3 -3
  132. package/dist/core/intercom-broker-control.code.js +3 -3
  133. package/dist/core/intercom-broker-control.impl.js +3 -3
  134. package/dist/core/intercom-broker-control.js +3 -3
  135. package/dist/core/model-config.d.ts +40 -0
  136. package/dist/core/model-registry.js +1 -1
  137. package/dist/core/model-resolver-scope.d.ts +4 -4
  138. package/dist/core/model-runtime.d.ts +1 -1
  139. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  140. package/dist/core/package-manager-storage-adapters.js +3 -3
  141. package/dist/core/provider-composer-internal.d.ts +11 -2
  142. package/dist/core/sdk.code.js +3 -3
  143. package/dist/core/sdk.impl.js +3 -3
  144. package/dist/core/sdk.js +3 -3
  145. package/dist/core/session-manager-core.js +5 -5
  146. package/dist/core/session-manager-list.impl.js +3 -3
  147. package/dist/core/session-manager-list.js +3 -3
  148. package/dist/core/session-manager.code.js +1 -1
  149. package/dist/core/session-manager.impl.js +3 -3
  150. package/dist/core/session-manager.js +3 -3
  151. package/dist/core/session-storage.impl.js +3 -3
  152. package/dist/core/session-storage.js +3 -3
  153. package/dist/core/settings-manager-basic-accessors.d.ts +6 -2
  154. package/dist/core/storage/index.js +2 -2
  155. package/dist/core/storage/node-sqlite-thread.js +2 -2
  156. package/dist/core/storage/node-sqlite.js +2 -2
  157. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  158. package/dist/core/storage/offline-snapshot-file.js +3 -3
  159. package/dist/core/storage/provider.js +2 -2
  160. package/dist/core/storage/selection.js +2 -2
  161. package/dist/core/storage/session/branch-fork-source.code.js +2 -2
  162. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  163. package/dist/core/storage/session/branch-fork-source.js +3 -3
  164. package/dist/core/storage/session/card-view.impl.js +3 -3
  165. package/dist/core/storage/session/card-view.js +3 -3
  166. package/dist/core/storage/session/child-reader.code.js +3 -3
  167. package/dist/core/storage/session/child-reader.impl.js +3 -3
  168. package/dist/core/storage/session/child-reader.js +3 -3
  169. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  170. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  171. package/dist/core/storage/session/expanded-child-details.code.js +2 -2
  172. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  173. package/dist/core/storage/session/expanded-child-details.js +3 -3
  174. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  175. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  176. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  177. package/dist/core/storage/session/fork-row-index.js +3 -3
  178. package/dist/core/storage/session/fork-staging.code.js +2 -2
  179. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  180. package/dist/core/storage/session/fork-staging.js +3 -3
  181. package/dist/core/storage/session/fork-window.code.js +3 -3
  182. package/dist/core/storage/session/fork-window.impl.js +3 -3
  183. package/dist/core/storage/session/fork-window.js +3 -3
  184. package/dist/core/storage/session/history-pages.impl.js +3 -3
  185. package/dist/core/storage/session/history-pages.js +3 -3
  186. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  187. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  188. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  189. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  190. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  191. package/dist/core/storage/session/memory-session-store.js +3 -3
  192. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  193. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  194. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  195. package/dist/core/storage/session/released-history-files.code.js +3 -3
  196. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  197. package/dist/core/storage/session/released-history-files.js +3 -3
  198. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  199. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  200. package/dist/core/storage/session/session-resume.impl.js +3 -3
  201. package/dist/core/storage/session/session-resume.js +3 -3
  202. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  203. package/dist/core/storage/session/snapshot-cut.js +3 -3
  204. package/dist/core/storage/session/snapshot-history.code.js +3 -3
  205. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  206. package/dist/core/storage/session/snapshot-history.js +3 -3
  207. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  208. package/dist/core/storage/session/sql-session-store.impl.js +3 -3
  209. package/dist/core/storage/session/sql-session-store.js +3 -3
  210. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  211. package/dist/core/storage/session/tree-outline.js +3 -3
  212. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  213. package/dist/core/storage/session/tree-presentation.js +3 -3
  214. package/dist/core/storage/storage-status.impl.js +3 -3
  215. package/dist/core/storage/storage-status.js +3 -3
  216. package/dist/core/storage/team.impl.js +3 -3
  217. package/dist/core/storage/team.js +3 -3
  218. package/dist/core/structured-output/index.code.js +1 -1
  219. package/dist/core/structured-output/index.impl.js +3 -3
  220. package/dist/core/structured-output/index.js +3 -3
  221. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  222. package/dist/core/tasks/task-completion-entry.js +3 -3
  223. package/dist/core/tasks/task-file-history.code.js +3 -3
  224. package/dist/core/tasks/task-file-history.impl.js +3 -3
  225. package/dist/core/tasks/task-file-history.js +3 -3
  226. package/dist/core/tasks/task-reference-archive.code.js +4 -4
  227. package/dist/core/tasks/task-reference-archive.js +3 -3
  228. package/dist/core/tasks/task-reference-identity.code.js +1 -1
  229. package/dist/core/tasks/task-reference-identity.js +3 -3
  230. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  231. package/dist/core/tasks/task-reference-stream.js +3 -3
  232. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  233. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  234. package/dist/core/tasks/task-view-source.impl.js +3 -3
  235. package/dist/core/tasks/task-view-source.js +3 -3
  236. package/dist/core/tools/read-url.code.js +2 -2
  237. package/dist/core/tools/read-url.impl.js +3 -3
  238. package/dist/core/tools/read-url.js +3 -3
  239. package/dist/core/worktree-snapshot/blob-store.js +2 -2
  240. package/dist/core/worktree-snapshot/errors.code.js +3 -3
  241. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  242. package/dist/core/worktree-snapshot/errors.js +3 -3
  243. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  244. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  245. package/dist/extensions/codemode/execute.code.js +1 -1
  246. package/dist/extensions/codemode/execute.impl.js +3 -3
  247. package/dist/extensions/codemode/execute.js +3 -3
  248. package/dist/extensions/codemode/renderer.code.js +2 -2
  249. package/dist/extensions/codemode/renderer.impl.js +3 -3
  250. package/dist/extensions/codemode/renderer.js +3 -3
  251. package/dist/extensions/mcp/cli.code.js +2 -2
  252. package/dist/extensions/mcp/cli.impl.js +3 -3
  253. package/dist/extensions/mcp/cli.js +3 -3
  254. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  255. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  256. package/dist/extensions/mcp/cli.lazy.js +3 -3
  257. package/dist/extensions/mcp/runtime.code.js +1 -1
  258. package/dist/extensions/mcp/runtime.impl.js +3 -3
  259. package/dist/extensions/mcp/runtime.js +3 -3
  260. package/dist/index-extensions.d.ts +1 -1
  261. package/dist/index.d.ts +8 -1
  262. package/dist/index.js +7 -7
  263. package/dist/main-first-time-setup.code.js +2 -2
  264. package/dist/main-first-time-setup.impl.js +3 -3
  265. package/dist/main-first-time-setup.js +3 -3
  266. package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -0
  267. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  268. package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
  269. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  270. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  271. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  272. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  273. package/dist/modes/interactive/theme/color-utils.d.ts +5 -5
  274. package/dist/modes/interactive/theme/theme-loading.d.ts +1 -0
  275. package/dist/modes/interactive-engine/engine-prewarm.js +1 -1
  276. package/dist/modes/interactive-engine/remote-model-catalog.d.ts +1 -0
  277. package/dist/modes/print-mode.js +1 -1
  278. package/dist/modes/rpc/rpc-client-api.d.ts +6 -0
  279. package/dist/modes/rpc/rpc-types.d.ts +29 -2
  280. package/dist/package-manager-cli.code.js +5 -5
  281. package/dist/package-manager-cli.impl.js +3 -3
  282. package/dist/package-manager-cli.js +3 -3
  283. package/dist/rpc-entry.js +1 -1
  284. package/dist/startup-files.json +1 -1
  285. package/dist/startup-stages/5.js +1 -1
  286. package/dist/startup-stages/7.js +1 -1
  287. package/dist/startup-stages/8.js +1 -2
  288. package/dist/startup-stages/9.js +2 -1
  289. package/dist/utils/native-module.d.ts +44 -0
  290. package/dist/utils/startup-database-spare.code.js +3 -3
  291. package/dist/utils/startup-database-spare.impl.js +3 -3
  292. package/dist/utils/startup-database-spare.js +3 -3
  293. package/dist/utils/tools-manager.code.js +1 -1
  294. package/dist/utils/tools-manager.impl.js +3 -3
  295. package/dist/utils/tools-manager.js +3 -3
  296. package/docs/background-tasks.md +235 -243
  297. package/docs/build.md +12 -11
  298. package/docs/codemode.md +60 -51
  299. package/docs/compaction/reference.md +61 -24
  300. package/docs/compaction.md +117 -65
  301. package/docs/computer-use.md +179 -146
  302. package/docs/containerization.md +79 -33
  303. package/docs/custom-provider/api-reference.md +148 -11
  304. package/docs/custom-provider/oauth.md +44 -27
  305. package/docs/custom-provider/override.md +14 -7
  306. package/docs/custom-provider/registration.md +75 -65
  307. package/docs/custom-provider/streaming.md +42 -19
  308. package/docs/custom-provider.md +25 -61
  309. package/docs/development.md +47 -43
  310. package/docs/docs.json +33 -33
  311. package/docs/environment-variables.md +83 -57
  312. package/docs/extensions/api-reference.md +323 -734
  313. package/docs/extensions/authoring.md +186 -269
  314. package/docs/extensions/events.md +308 -375
  315. package/docs/extensions/examples.md +122 -74
  316. package/docs/extensions/ui.md +217 -197
  317. package/docs/extensions.md +152 -259
  318. package/docs/getting-started/authentication.md +27 -14
  319. package/docs/getting-started/first-session.md +25 -26
  320. package/docs/getting-started/installation.md +62 -84
  321. package/docs/getting-started/project-instructions.md +39 -14
  322. package/docs/guides/configuration.md +42 -20
  323. package/docs/guides/intercom.md +17 -13
  324. package/docs/guides/non-interactive.md +29 -16
  325. package/docs/guides/orchestration.md +16 -10
  326. package/docs/guides/resume-on-any-machine.md +54 -49
  327. package/docs/guides/subagents.md +22 -14
  328. package/docs/guides/team-setup.md +37 -26
  329. package/docs/guides.md +22 -21
  330. package/docs/herdr.md +21 -16
  331. package/docs/index.md +16 -17
  332. package/docs/intercom/operations.md +68 -66
  333. package/docs/intercom/reference.md +196 -191
  334. package/docs/intercom.md +103 -92
  335. package/docs/json.md +71 -71
  336. package/docs/keybindings.md +63 -50
  337. package/docs/libraries/agent-core.md +49 -8
  338. package/docs/libraries/ai.md +21 -12
  339. package/docs/libraries/codemode.md +28 -6
  340. package/docs/libraries/schema.md +7 -7
  341. package/docs/libraries/telemetry.md +7 -7
  342. package/docs/libraries/tui.md +74 -94
  343. package/docs/libraries.md +5 -5
  344. package/docs/llama-cpp.md +38 -33
  345. package/docs/mcp-servers.md +96 -90
  346. package/docs/models/reference.md +46 -33
  347. package/docs/models-configuration.md +12 -6
  348. package/docs/models.md +93 -88
  349. package/docs/orchestration/migrating-workflows.md +21 -19
  350. package/docs/orchestration/patterns.md +35 -20
  351. package/docs/orchestration.md +22 -21
  352. package/docs/packages/authoring.md +28 -19
  353. package/docs/packages/reference.md +75 -16
  354. package/docs/packages.md +31 -33
  355. package/docs/programmatic.md +22 -21
  356. package/docs/prompt-templates.md +63 -41
  357. package/docs/providers/reference.md +35 -19
  358. package/docs/providers.md +61 -71
  359. package/docs/quickstart.md +32 -46
  360. package/docs/reference/cli.md +249 -252
  361. package/docs/reference.md +23 -20
  362. package/docs/rpc/examples.md +74 -17
  363. package/docs/rpc/extension-ui.md +79 -62
  364. package/docs/rpc/protocol.md +816 -358
  365. package/docs/rpc.md +75 -151
  366. package/docs/sdk/reference.md +175 -45
  367. package/docs/sdk/structured-decisions.md +92 -62
  368. package/docs/sdk/web-server.md +79 -46
  369. package/docs/sdk.md +237 -195
  370. package/docs/security.md +106 -43
  371. package/docs/session-format.md +96 -59
  372. package/docs/sessions.md +149 -113
  373. package/docs/settings.md +289 -204
  374. package/docs/shell-aliases.md +15 -6
  375. package/docs/skills/authoring.md +17 -9
  376. package/docs/skills/reference.md +23 -21
  377. package/docs/skills.md +104 -97
  378. package/docs/storage.md +140 -242
  379. package/docs/subagents/authoring.md +147 -16
  380. package/docs/subagents/reference.md +100 -30
  381. package/docs/subagents.md +220 -252
  382. package/docs/terminal-setup.md +97 -69
  383. package/docs/termux.md +51 -85
  384. package/docs/themes/reference.md +51 -37
  385. package/docs/themes.md +49 -54
  386. package/docs/tmux.md +38 -21
  387. package/docs/tools.md +198 -147
  388. package/docs/tui/reference.md +64 -32
  389. package/docs/tui.md +38 -66
  390. package/docs/usage.md +76 -78
  391. package/docs/verification.md +25 -25
  392. package/docs/web-access.md +72 -55
  393. package/docs/windows.md +53 -58
  394. package/docs/worktree-snapshots.md +62 -65
  395. package/package.json +8 -8
  396. package/schemas/models.schema.json +51 -0
  397. package/dist/_shared/sdk-OSBEPR3Q.js.map +0 -1
  398. package/dist/_shared/startup-0-0-TYUFUOJZ.js.map +0 -1
  399. package/dist/_shared/startup-0-1-W2G2UY7R.js.map +0 -1
  400. package/dist/_shared/startup-0-2-UXBUEOXW.js.map +0 -1
  401. package/dist/_shared/startup-0-4-HN5EB4K7.js.map +0 -1
package/docs/build.md CHANGED
@@ -1,10 +1,9 @@
1
1
  ---
2
- title: Build with Atomic
3
- description: Extend Atomic with skills, subagents, Intercom, codemode, extensions, prompt templates, themes, packages, custom models and providers, and programmatic integrations.
2
+ title: "Build with Atomic"
3
+ sidebarTitle: "Overview"
4
+ description: "Choose how to customize an Atomic session, extend it with TypeScript or MCP, or embed it in your own software."
4
5
  ---
5
6
 
6
- # Build with Atomic
7
-
8
7
  Customize an Atomic session or embed it in your own software. Choose a starting point below.
9
8
 
10
9
  New to Atomic? Start with the [Quickstart](/quickstart). To look up an exact contract, use the [Reference index](/reference).
@@ -15,20 +14,22 @@ Work down this list and stop at the first mechanism that solves your problem.
15
14
 
16
15
  1. [Prompt templates](/prompt-templates). Expand reusable Markdown prompts from a slash command without writing code.
17
16
  2. [Skills](/skills). Provide on-demand instructions and optional scripts that the agent loads when a task matches.
18
- 3. [Subagents](/subagents). Delegate a focused, bounded task to a child agent.
19
- 4. [Intercom](/intercom). Coordinate sessions on the same machine or across machines sharing a database.
20
- 5. [Orchestration](/orchestration). Use codemode to launch children, check results, and pick up after an interruption.
21
- 6. [Extensions](/extensions). Write TypeScript that adds tools, commands, events, and custom UI when nothing lighter fits.
22
- 7. [Atomic packages](/packages). Bundle and distribute your extensions, skills, prompt templates, themes, subagents, MCP servers, or storage adapters.
17
+ 3. [MCP servers](/mcp-servers). Connect external tools and data sources over Model Context Protocol without writing an extension.
18
+ 4. [Subagents](/subagents). Delegate a focused, bounded task to a child agent.
19
+ 5. [Intercom](/intercom). Coordinate sessions on the same machine or across machines sharing a database.
20
+ 6. [Orchestration](/orchestration). Use codemode to launch children, check results, and pick up after an interruption.
21
+ 7. [Extensions](/extensions). Write TypeScript that adds tools, commands, events, and custom UI when nothing lighter fits.
22
+ 8. [Atomic packages](/packages). Bundle and distribute your extensions, skills, prompt templates, themes, subagents, MCP servers, or storage adapters.
23
23
 
24
24
  ## Change the model layer
25
25
 
26
26
  - [Custom models](/models). Add model entries for a supported provider API.
27
27
  - [Custom providers](/custom-provider). Implement a provider API or OAuth flow that Atomic does not ship.
28
28
 
29
- ## Customization
29
+ ## Customize appearance and controls
30
30
 
31
- Use [Themes](/themes) to restyle the terminal with a built-in or custom theme.
31
+ - [Themes](/themes). Restyle the terminal with a built-in or custom JSON theme.
32
+ - [Keybindings](/keybindings). Rebind interactive shortcuts and navigation keys.
32
33
 
33
34
  ## Embed Atomic in your own software
34
35
 
package/docs/codemode.md CHANGED
@@ -1,84 +1,87 @@
1
1
  ---
2
- title: "Codemode"
3
- description: "The codemode script reference: globals, tool calls, stored values, classifier and image models, and limits."
2
+ title: "Codemode reference"
3
+ sidebarTitle: "Codemode"
4
+ description: "Write JavaScript scripts inside Atomic's sandbox to compose tool calls, persist state across turns, and call classifier or image models."
4
5
  ---
5
6
 
6
- # Codemode
7
-
8
- `codemode` lets the model run a JavaScript script that calls Atomic tools and non-LLM models (classifiers and image generators) and returns only the filtered result. It is enabled by default; see [`codemode` in Built-in tools](/tools#codemode) to toggle it. To embed the sandbox in your own app, see [`@bastani/atomic-codemode`](/libraries/codemode).
7
+ `codemode` lets the model run a JavaScript script that calls Atomic tools and non-LLM models (classifiers and image generators) and returns only the filtered result. It is enabled by default; see [`codemode` in Built-in tools](/tools#codemode) to toggle it. To embed the sandbox in your own application, see [`@bastani/atomic-codemode`](/libraries/codemode).
9
8
 
10
9
  ## Scripts
11
10
 
12
- Pass raw JavaScript source (no JSON wrapper or markdown code fences). Code runs as an async function body inside a QuickJS sandbox, so top-level `await` and `return` work. The sandbox has no Node APIs, filesystem, network, or timers; external access goes exclusively through `tools` and `models`.
11
+ Pass raw JavaScript source with no JSON wrapper or markdown code fences. Code runs as an async function body inside a sandboxed JavaScript runtime, so top-level `await` and `return` work. The sandbox has no Node or Bun APIs, filesystem, network, or timers; all external access goes through `tools` and `models`.
13
12
 
14
- Optional first-line directives configure output budget and timeout (must be line 1 or the call fails):
13
+ An optional first-line directive sets the output budget and timeout. It must be line 1 followed by JavaScript code; unknown keys or a script with no code after the directive fail immediately:
15
14
 
16
- ```js
15
+ ```javascript
17
16
  // @options: {"max_output_tokens": 2000, "timeout_ms": 60000}
18
17
  ```
19
18
 
20
- - **`max_output_tokens` (default `10000`).** Caps returned text. Overflow keeps the start and end and writes full output to a temp file whose path is included.
21
- - **`timeout_ms` (unset by default).** Hard deadline for the whole script, including waiting for a worker slot. Avoid short deadlines when generating images, which can take minutes.
19
+ - **`max_output_tokens` (default `10000`).** Non-negative safe integer (`0` is accepted; budget is `max_output_tokens * 4` characters). Overflow keeps the start and end and writes full output to a temp file whose path is included in the result.
20
+ - **`timeout_ms` (unset by default).** Hard deadline in milliseconds for the whole script, including waiting for a worker slot. Must be a positive integer up to `2147483647` (about 24.8 days); `0`, negative numbers, decimals, or larger values fail before running. Avoid short deadlines when generating images, which can take minutes.
22
21
 
23
22
  **Result format.** Starts with `Script completed` or `Script failed` plus wall time, followed by text and image items in order. Multiple text items (from `text()` or `return`) are separated by `==> text N/M <==`. `console.*` output follows in one `<console_output>` block. On failure, partial output is kept before `Script error:`. Side effects from completed tool calls are **not** rolled back; still-running calls are cancelled and unawaited promises are dropped when the script exits.
24
23
 
25
24
  ## Globals
26
25
 
27
- | Global | Purpose |
28
- | --- | --- |
29
- | `tools.<name>(args)` | Call a permitted tool. See [Call tools](#call-tools). |
30
- | `text(value)` | Emit a text item (strings verbatim, other values as JSON). |
31
- | `image(value)` | Emit an image from a base64 `data:` URL, `{ image_url }`, or `{ type: "image", data, mimeType }` (PNG, JPEG, GIF, WebP; no remote URLs or SVG; see [Generate images](#generate-images)). Also saves to a temp file and prints its path. |
32
- | `console.log(...)` | Append a space-joined line to `<console_output>` (`info`, `warn`, `error`, and `debug` behave identically). |
33
- | `return value` | Top-level `return` emits `value` like `text()`. |
34
- | `exit()` | End the script immediately with success. |
35
- | `store(key, value)` / `load(key)` | Persist small JSON values across `codemode` calls on this branch. See [Store values](#store-values). |
36
- | `ALL_TOOLS` | Array of `{ name, description }` for every script-callable tool (excludes [model-only tools](#model-only-tools)). |
37
- | `searchTools(query, { limit?, namespace? })` | BM25 search over script-callable tools (default `limit: 8`). Exact tool names or suffixes after `__` (such as `thread_read` for `mcp__app__thread_read`) rank first. An exact active model-only tool name returns a hint to call it directly. |
38
- | `describeTool(name)` | Returns a script-callable tool's description and TypeScript declaration, a direct-call hint for an active model-only tool, or `undefined`. |
39
- | `describeNamespace(name)` | Returns `{ name, description?, instructions?, tools }` for a namespace (such as an MCP server), or `undefined`. |
40
- | `models` | Inspect and invoke classifier and image models. See [Models](#models). |
26
+ Use `await` with every async global (`tools.*`, `searchTools()`, `describeTool()`, `describeNamespace()`, and `models.*`). Output, store, and exit helpers are synchronous.
27
+
28
+ | Global | Sync / Async | Purpose |
29
+ | --- | --- | --- |
30
+ | `tools.<name>(args)` | Async (`await`) | Call a permitted tool. See [Call tools](#call-tools). |
31
+ | `text(value)` | Sync | Emit a text item (strings verbatim, other values as JSON). |
32
+ | `image(value)` | Sync | Emit an image from a base64 `data:` URL, `{ image_url }`, or `{ type: "image", data, mimeType }` (PNG, JPEG except JPEG-LS, GIF, or WebP; no remote URLs or SVG; see [Generate images](#generate-images)). Inspects base64 magic bytes instead of trusting the declared MIME type, strips whitespace and newlines, throws `TypeError` on invalid or mismatched base64, saves a temp file, and prints its path. |
33
+ | `console.log(...)` | Sync | Append a space-joined line to `<console_output>` (`info`, `warn`, `error`, and `debug` behave identically). |
34
+ | `return value` | Sync | Top-level `return` emits `value` like `text()`. |
35
+ | `exit()` | Sync | End the script immediately with success. Persists prior `store()` writes, takes no argument (call `text()` first to emit output), and ignores further `text()` or `image()` calls inside `finally` blocks. |
36
+ | `store(key, value)` / `load(key)` | Sync | Persist small JSON values across `codemode` calls on this branch. See [Store values](#store-values). |
37
+ | `ALL_TOOLS` | Value | Array of `{ name, description }` for every script-callable tool (excludes [model-only tools](#model-only-tools)). |
38
+ | `searchTools(query, { limit?, namespace? })` | Async (`await`) | BM25 search over script-callable tools (`limit` must be a positive integer, default `8`). Exact tool names or suffixes after `__` (such as `thread_read` for `mcp__app__thread_read`) rank first. Querying an exact active model-only tool name returns a hint to call it directly unless `namespace` is passed. |
39
+ | `describeTool(name)` | Async (`await`) | Returns a script-callable tool's description and TypeScript declaration, a direct-call hint for an active model-only tool, or `undefined`. Accepts exact names, JS identifiers, `mcp.<server>.<tool>`, `mcp__<raw-server>__<tool>`, `<server>__<tool>`, or `<tool>` suffixes, and throws an ambiguity error if a shorthand matches multiple tools. |
40
+ | `describeNamespace(name)` | Async (`await`) | Returns `{ name, description?, instructions?, tools }` for a namespace (such as an MCP server), or `undefined`. |
41
+ | `models` | Async methods (`await`) | Inspect and invoke classifier and image models. See [Models](#models). Not exposed in routing-only subagents. |
41
42
 
42
43
  ## Call tools
43
44
 
44
- Every script-callable tool is exposed on `tools` with non-identifier characters converted to `_` (for example `mcp__dev-docs__search` becomes `tools.mcp__dev_docs__search`). Each method accepts one argument object.
45
+ Every script-callable tool is exposed on `tools` under both its normalized JavaScript identifier (non-identifier characters replaced with `_`, such as `tools.mcp__dev_docs__search`) and its raw tool name (`tools["mcp__dev-docs__search"]`). If two tool names normalize to the same identifier, the first registered tool keeps the normalized key. Each method accepts one argument object.
45
46
 
46
47
  **Return values:**
47
- - **Tools with `outputSchema`.** Resolve to their structured object (including structured failures). `bash` resolves to `{ output, truncated, full_output_path?, exit_code, wall_time_seconds }` even for nonzero exit codes; `output` keeps up to 1 MiB (first and last 512 KiB around an omission marker if truncated, with full text in `full_output_path`).
48
- - **MCP tools.** Resolve to `CallToolResult` (`content`, `isError`, and typed `structuredContent`).
49
- - **`read`.** Resolves to text (including path headers and line numbers unless `:raw`), or for images to `{ type: "image", data, mimeType, note }` usable directly with `image()`.
48
+ - **Tools with `outputSchema`.** Resolve to their structured object (including structured failures). `bash` resolves to `{ output, truncated, full_output_path?, exit_code, wall_time_seconds }` even for nonzero exit codes; `output` keeps up to 1 MiB (the first and last 512 KiB around an omission marker if truncated, with full text in `full_output_path`).
49
+ - **MCP tools.** Resolve to `CallToolResult` (`content`, `isError`, and typed `structuredContent`, with `_meta` stripped).
50
+ - **`read`.** Resolves to plain LF text with `[Lines S-E of N]` range headers on partial reads (no per-line numbers or local path headers; URL reads include `URL:`, `Status:`, and `Content-Type:` headers; append `:raw` for exact bytes). For images, resolves to `{ type: "image", data, mimeType, note }` usable directly with `image()`.
50
51
  - **Other tools (`edit`, `write`, and similar).** Resolve to text.
51
52
 
52
53
  **Errors and discovery:**
53
54
  - Failed, blocked, or invalid calls reject with `Error` (except schema-backed tools that return a structured error value; check `exit_code` or `isError`). Use `Promise.allSettled()` for independent calls.
54
55
  - Accessing an unknown tool throws with close-match suggestions (for example `tools.Bash` suggests `tools.bash`). Check availability with `"name" in tools`.
55
- - Inline tool declarations share a `3000`-token budget (`codemode.inlineBudget` in [settings](/settings#tools)); deferred tools stay unlisted and are found via `searchTools()`, `describeTool()`, `describeNamespace()`, or `ALL_TOOLS`.
56
+ - Inline tool declarations share a `3000`-token budget (`codemode.inlineBudget` in [settings](/settings#tools)); deferred tools stay unlisted and are found via `await searchTools()`, `await describeTool()`, `await describeNamespace()`, or `ALL_TOOLS`.
56
57
  - `codemode.mode` in [settings](/settings#tools) controls tool visibility: `"on"` (default) keeps direct tools declared alongside codemode; `"only"` hides ordinary direct tools so the model calls them through codemode while keeping active model-only tools (like `ask_user_question`) top-level. Declarations in `codemode`, `describeTool()`, and `ALL_TOOLS` carry each tool's prompt guidelines.
57
58
 
58
59
  ### Model-only tools
59
60
 
60
- Tools without script access (such as `ask_user_question`) are absent from `tools`, `ALL_TOOLS`, and `searchTools()` rankings. Call them as top-level tools instead. Querying their exact name with `searchTools()` or `describeTool()` returns a hint to call them directly without making them script-callable.
61
+ Tools without script access (such as `ask_user_question` and `tool_search`) are absent from `tools`, `ALL_TOOLS`, and `searchTools()` rankings. Call them as top-level tools instead. Querying their exact name with `await searchTools()` or `await describeTool()` returns a hint to call them directly without making them script-callable.
61
62
 
62
63
  Two tools expose a script-safe subset:
63
- - **`tools.subagent`.** Launches children (`{ agent, task }` or `{ tasks }`) and returns task IDs at admission; also supports `status`, bounded `wait`, `pause`, `quit`, `resume`, and agent and model inspection. A script timeout cancels `wait`, not the child; admitted children continue after a script returns or throws. See [Subagents from codemode scripts](/subagents#from-codemode-scripts).
64
+ - **`tools.subagent`.** Launches subagents (`{ agent, task }` or `{ tasks }`) and returns task IDs at admission; also supports `status`, bounded `wait`, `pause`, `quit`, `resume`, and agent and model inspection. A script timeout cancels `wait`, not the subagent; admitted subagents continue after a script returns or throws. See [Subagents from codemode scripts](/subagents#from-codemode-scripts).
64
65
  - **`tools.intercom`.** Supports `list`, `status`, `pending`, and `send` to an exact target (returning structured results). Other actions and glob or `subagents:` targets must be called directly. See [Intercom from codemode scripts](/intercom/reference#from-codemode-scripts).
65
66
 
66
67
  ## Store values
67
68
 
68
- `store(key, value)` saves a JSON value for subsequent `codemode` calls; `store(key, undefined)` deletes it; `load(key)` reads it back (or `undefined`).
69
+ `store(key, value)` synchronously saves a JSON value for subsequent `codemode` calls; `store(key, undefined)` deletes it; `load(key)` synchronously reads it back (or returns `undefined`).
69
70
 
70
- - Persists only when the script succeeds by appending a `codemode-store` session entry, so values survive resume and stay isolated per session branch.
71
- - Size caps: 262,144 JSON characters per value, 1,048,576 characters total across all keys. Do not store images; emit them with `image()`, which writes a temp file automatically.
71
+ - Writes become visible to `load()` immediately inside the same script. They persist to the session history only when the script succeeds (including via `exit()`), so values survive resume and stay isolated per session branch. Failed scripts discard uncommitted writes.
72
+ - Keys must be strings. Non-JSON-serializable values (functions, BigInt, circular references) throw `TypeError`.
73
+ - Size caps are 262,144 JSON characters per value (`json.length`) and 1,048,576 characters total across all stored entries (`key.length + json.length`). Do not store images; emit them with `image()`, which writes a temp file automatically.
72
74
 
73
75
  ## Models
74
76
 
75
- `models` accesses the model catalog and calls non-LLM models using the session's credentials:
77
+ `models` accesses the model catalog and calls non-LLM models using the session's credentials. Routing-only subagents do not expose `models`.
78
+
76
79
  - **Classifiers.** Answer typed questions about JSON state (and images when supported). Examples: [TypeSafe Jev](/providers#typesafe-jev), [OpenAI GPT-6 Luna](/models#use-classifier-models), and [local llama.cpp models](/llama-cpp).
77
80
  - **Image models.** Generate or edit images. Examples: OpenRouter (`provider: "openrouter"`, IDs such as `google/gemini-2.5-flash-image` and `black-forest-labs/flux.2-pro`, reusing your OpenRouter credential) and OpenAI (`provider: "openai-images"`, such as `gpt-image-2.6-flare`, reusing your [OpenAI API key](/providers#subscription-and-api-key-at-the-same-time)).
78
81
 
79
- Chat models are listed in the catalog but cannot be called from scripts. Neither classifiers nor image models appear in `/model`.
82
+ Chat models are listed in the catalog (with active service-tier pricing) but cannot be called from scripts. Neither classifiers nor image models appear in `/model`.
80
83
 
81
- ```ts
84
+ ```typescript
82
85
  type ModelType = "chat" | "image" | "classifier";
83
86
 
84
87
  interface ModelInfo {
@@ -88,7 +91,10 @@ interface ModelInfo {
88
91
  name: string;
89
92
  api: string;
90
93
  input: ("text" | "image")[];
94
+ reasoning?: boolean;
91
95
  contextWindow?: number;
96
+ maxTokens?: number;
97
+ cost?: { input: number; output: number; cacheRead: number; cacheWrite: number };
92
98
  [key: string]: unknown;
93
99
  }
94
100
 
@@ -107,7 +113,7 @@ declare const models: {
107
113
 
108
114
  ### Classify
109
115
 
110
- ```ts
116
+ ```typescript
111
117
  interface ClassifierContext {
112
118
  state: Record<string, unknown>;
113
119
  images?: { type: "image"; data: string; mimeType: string }[];
@@ -138,7 +144,7 @@ type ModelUsage = { input: number; output: number; totalTokens: number; cost: {
138
144
 
139
145
  Classify multiple items in parallel:
140
146
 
141
- ```js
147
+ ```javascript
142
148
  const jev = await models.getModelOfType("classifier", "typesafe", "jev-latest");
143
149
  const results = await Promise.all(
144
150
  messages.map((message) =>
@@ -166,9 +172,9 @@ return results.map((result, i) =>
166
172
  );
167
173
  ```
168
174
 
169
- When a classifier's `input` includes `"image"`, pass image blocks (such as those returned by `tools.read()`) in `images` (text-only models return an error result for non-empty `images`):
175
+ When a classifier's `input` includes `"image"`, pass image blocks (such as those returned by `tools.read()`) in `images`. Text-only models return an error result for non-empty `images`:
170
176
 
171
- ```js
177
+ ```javascript
172
178
  const luna = await models.getModelOfType("classifier", "openai-decisions", "gpt-6-luna");
173
179
  const photo = await tools.read({ path: "screenshot.png" });
174
180
  const result = await models.classify(luna, {
@@ -187,7 +193,7 @@ return result.stopReason === "stop" ? result.answers : result.errorMessage;
187
193
 
188
194
  ### Generate images
189
195
 
190
- ```ts
196
+ ```typescript
191
197
  interface ImagesContext {
192
198
  input: (TextBlock | ImageBlock)[];
193
199
  }
@@ -203,7 +209,7 @@ interface ImagesOptions {
203
209
  frameCount?: number;
204
210
  frameDurationMs?: number;
205
211
  complexity?: "low" | "medium" | "high";
206
- svg?: { model: string; reasoning?: { effort?: string } };
212
+ svg?: { model: string; reasoning?: { effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" } };
207
213
  moderation?: "auto" | "low";
208
214
  safetyIdentifier?: string;
209
215
  }
@@ -223,13 +229,14 @@ type TextBlock = { type: "text"; text: string };
223
229
  type ImageBlock = { type: "image"; data: string; mimeType: string; role?: "markup" | "mask" };
224
230
  ```
225
231
 
226
- - **Provider options.** `ImagesOptions` targets OpenAI's `openai-images` models (OpenRouter models ignore them). The first untagged image is the base image to edit; additional untagged images are references. `role: "markup"` is a same-size transparent PNG overlay; `role: "mask"` is an alpha mask (mutually exclusive).
227
- - **GIF and SVG.** `outputFormat: "gif"` (`frameCount` `2` to `16`, `frameDurationMs` `20` to `2000`) and `"svg"` require a GPT Image 2.6 model with text-only input.
232
+ - **Provider options.** `ImagesOptions` targets OpenAI's `openai-images` models (OpenRouter models ignore them). The first untagged image is the base image to edit; additional untagged images are references. `role: "markup"` (a same-size transparent PNG overlay) and `role: "mask"` (an alpha mask) are mutually exclusive and require an untagged base image earlier in `input`.
233
+ - **OpenAI option validation.** `outputCompression` accepts integers `0` to `100` and is valid only with `outputFormat: "jpeg"` or `"webp"`. `background: "transparent"` is valid only with `"png"`, `"webp"`, or the default format. `safetyIdentifier` has a 128-character limit. `complexity` (`"low"`, `"medium"`, or `"high"`, API default `"high"`) applies to GPT Image 2.6 only.
234
+ - **GIF and SVG.** `outputFormat: "gif"` and `"svg"` require a GPT Image 2.6 model with text-only input. For GIF, `frameCount` (`2` to `16`, API default `9`) and `frameDurationMs` (`20` to `2000`, API default `200`, rounded to 10 ms) are rejected unless `outputFormat` is `"gif"`. For SVG, `n` must be `1` or omitted, and the `svg` option is rejected unless `outputFormat` is `"svg"`.
228
235
  - **SVG authoring model.** `{ outputFormat: "svg" }` works without extra options. If an account requires `svg.model` and you omitted `svg`, Atomic retries once with `gpt-6.1-sol` (reported in `result.svgModel`), and retries once without `svg` if rejected as unsupported. An explicit `svg: { model, reasoning }` is sent verbatim without automatic fallback. Allow at least `timeout_ms: 180000` for SVG requests (Atomic's own request timeout is at least 10 minutes).
229
- - **Structured errors.** Invalid options fail locally with `stopReason: "error"`, `error.code: "invalid-option"`, and `error.fields.field` (plus `error.fields.reason`: `required-by-api`, `rejected-by-api`, or `unsupported-by-api` for SVG). Other codes: `moderation-blocked`, `user-error`, `quota-exceeded`, `rate-limited`, `server-error`, `timeout`, `api-error`. Branch on `error.code` and `error.retryable` (see [Image generation](/extensions/api-reference#ctx-modelregistry-/-ctx-model-/-ctx-scopedmodels)).
236
+ - **Structured errors.** Invalid options fail locally with `stopReason: "error"`, `error.code: "invalid-option"`, and `error.fields.field` (plus `error.fields.reason`: `required-by-api`, `rejected-by-api`, or `unsupported-by-api` for SVG). Other codes are `moderation-blocked`, `user-error`, `quota-exceeded`, `rate-limited`, `server-error`, `timeout`, and `api-error`. Branch on `error.code` and `error.retryable` (see [Image generation](/extensions/api-reference#ctx-modelregistry-/-ctx-model-/-ctx-scopedmodels)).
230
237
  - **Displaying and saving output.** Call `image(block)` for PNG, JPEG, GIF, and WebP (never print base64 `data` via `text()` or `return`; scripts that generate images without showing any receive a note). `image()` also saves each image to a private temp file and prints its path. For SVG (`image/svg+xml`), Atomic automatically saves a private temp `.svg` file (`[SVG saved to <path> (image/svg+xml, <size>)]`), and scripts can inspect XML text via `atob(block.data)`.
231
238
 
232
- ```js
239
+ ```javascript
233
240
  // @options: {"timeout_ms": 300000}
234
241
  const painter = await models.getModelOfType("image", "openrouter", "google/gemini-2.5-flash-image");
235
242
  const result = await models.generateImages(painter, {
@@ -244,7 +251,7 @@ for (const block of result.output) {
244
251
 
245
252
  SVG and animated GIF with GPT Image 2.6:
246
253
 
247
- ```js
254
+ ```javascript
248
255
  // @options: {"timeout_ms": 180000}
249
256
  const flare = await models.getModelOfType("image", "openai-images", "gpt-image-2.6-flare");
250
257
  const logo = await models.generateImages(flare, {
@@ -264,7 +271,9 @@ Extensions can call `ctx.modelRegistry.classify()` and `ctx.modelRegistry.genera
264
271
 
265
272
  ## Limits
266
273
 
267
- - **Memory.** 256 MiB per script VM (`InternalError: out of memory`); filter or aggregate data instead of buffering everything.
268
- - **Cancellation.** Stopping a script or hitting `timeout_ms` cancels the call promptly. In the standalone Bun binary, non-interruptible native built-ins (such as a long regex or string search) finish before the worker exits.
269
- - **Worker concurrency.** Default max `2` live workers per Atomic process (override with `ATOMIC_CODEMODE_MAX_WORKERS`). Cancelled workers occupy a slot until exit. Additional scripts queue in FIFO order and fail if no slot opens within 60 seconds (or `timeout_ms`).
274
+ - **Memory.** 256 MiB per script sandbox (`InternalError: out of memory`); filter or aggregate data instead of buffering everything in memory.
275
+ - **Hard output caps.** Across `text()`, `image()`, and `console.*`, a script can emit at most 16 MiB (`16,777,216` characters) total and `100,000` items. Exceeding either cap stops the script immediately with an uncatchable `RangeError`.
276
+ - **Frozen built-in prototypes.** Standard JavaScript globals and built-in prototypes are frozen before your script starts. Monkey-patching built-in prototypes throws `TypeError`; normal own properties on your own objects (`name`, `message`, `toString`, `toJSON`, and custom keys) work normally.
277
+ - **Cancellation.** Stopping a script or hitting `timeout_ms` cancels execution promptly. In the standalone binary release, a single long-running native built-in operation (such as a catastrophic regex) finishes before the worker exits.
278
+ - **Worker concurrency.** Default limit is `2` concurrent script workers per Atomic process (override with `ATOMIC_CODEMODE_MAX_WORKERS` or legacy `PI_CODEMODE_MAX_WORKERS`). Cancelled workers occupy a slot until they exit. Additional scripts queue in FIFO order and fail if no slot opens within 60 seconds (or `timeout_ms`).
270
279
  - **Deadlocks and nesting.** Waiting on a promise with no pending tool call fails immediately because there are no timers. Scripts cannot invoke `codemode` recursively.
@@ -1,30 +1,41 @@
1
1
  ---
2
- title: Compaction reference
3
- sidebarTitle: "Compaction internals"
4
- description: Compaction parameters, saved boundaries, extension hooks, exports, formats, and settings.
2
+ title: "Compaction reference"
3
+ sidebarTitle: "Compaction"
4
+ description: "Reference for compaction parameters, saved boundary fields, extension hooks, SDK concurrency, exports, branch summary format, and settings."
5
5
  ---
6
6
 
7
- # Compaction reference
8
-
9
7
  ## Parameters
10
8
 
11
9
  Extension events and compaction results carry one parameter:
12
10
 
13
11
  | Parameter | Default | Meaning |
14
12
  | --- | --- | --- |
15
- | `query` | Latest user request | Your `/compact` instructions when provided, otherwise the text of the latest user request. A compactor model receives it as its query. |
13
+ | `query` | Latest user request | Your `/compact` instructions when provided, otherwise the text of the latest user request (or `"the latest user request"` when no user message exists on the active branch). A compactor model receives it as its query. |
16
14
 
17
15
  Instructions passed to `/compact`, `session.compact({ query })`, `ctx.compact({ query })`, or RPC `compact` are also appended to the boundary message after the recovery steps. Automatic compaction passes no custom instructions.
18
16
 
19
- `compression_ratio` and `preserve_recent` are no longer compaction options and are ignored if supplied. The compactor ratio, request timeout, and output cap are fixed constants exported from `@bastani/atomic`:
17
+ `compression_ratio` and `preserve_recent` are not top-level `session.compact()` or `settings.json` compaction options and are ignored if supplied there, keeping default context-clearing compaction free of endpoint knobs. Configure API-specific parameters directly on each compactor model in [`models.json`](/models#remote-compaction-models) (`compactionParams`, `endpointPath`, `timeoutMs`, `maxTokens`, `headers`) or via [`atomic.registerProvider()`](/custom-provider/api-reference) (`ProviderCompactorModelConfig`). When `compactionParams` is omitted, Atomic does not inject provider-specific body fields so the remote API applies its own defaults.
20
18
 
21
- | Value | Export | Meaning |
22
- | --- | --- | --- |
23
- | `0.5` | `COMPACTOR_COMPRESSION_RATIO` | Share of the conversation the compactor is asked to keep |
24
- | `120000` | `COMPACTOR_REQUEST_TIMEOUT_MS` | Wall-clock limit on one compactor request, in milliseconds |
25
- | `32000` | `COMPACTED_OUTPUT_MAX_TOKENS` | Largest allowed compacted text in estimated tokens (or half of the automatic trigger budget on small context windows) |
19
+ Safety bounds used when a compactor model omits an override are exported from `@bastani/atomic`:
20
+
21
+ | Default | Export | Model override field | Meaning |
22
+ | --- | --- | --- | --- |
23
+ | `120000` | `COMPACTOR_REQUEST_TIMEOUT_MS` | `timeoutMs` | Wall-clock limit on one compactor request, in milliseconds |
24
+ | `32000` | `COMPACTED_OUTPUT_MAX_TOKENS` | `maxTokens` | Largest allowed compacted text in estimated tokens (always also capped at `COMPACTED_OUTPUT_MAX_TRIGGER_SHARE` = 50% of the automatic trigger budget) |
25
+ | `2000` | `COMPACTOR_LINE_WIDTH` | None | Character width at which long lines wrap before framing |
26
+
27
+ ### Compactor request contract
28
+
29
+ Each compactor provider defines its own `api` identifier and `baseUrl` (for example, built-in `morph/morph-compactor` defines `api: "morph-compact"` and `baseUrl: "https://api.morphllm.com/v1"`). Custom compactors in `models.json` or `atomic.registerProvider()` must declare `api` at the provider or model level unless overriding an existing compactor model.
30
+
31
+ Atomic POSTs JSON to `<baseUrl><endpointPath>` (`endpointPath` defaults to `"/compact"`; `""` POSTs directly to `baseUrl`):
32
+
33
+ - **Payload:** sends `{ ...compactionParams, messages, query, model }`. Atomic never injects hard-coded Morph parameters; any API-specific options come solely from the model's `compactionParams`.
34
+ - **Headers and authentication:** sends `Content-Type: application/json`, merges resolved provider and model `headers`, and adds `Authorization: Bearer <apiKey>` when `apiKey` is present and no explicit `Authorization` header was set. The API key and sensitive auth headers (`Authorization`, `Proxy-Authorization`, `X-API-Key`, `API-Key`) are redacted from HTTP error excerpts and compacted output.
35
+ - **Response parsing:** reads joined non-empty `messages[].content` entries when present, otherwise `output`, plus optional `usage.input_tokens` and `usage.output_tokens`.
36
+ - **Automatic fallback:** any failure (missing `baseUrl`, missing credentials, network/HTTP error, timeout, malformed/empty output, output exceeding `maxTokens` or 50% of the automatic trigger, boundary overflowing the trigger, or pressing `Escape` / `abortCompaction()`) falls back automatically to clearing the context (`form: "cleared"`) with `fallbackReason` set.
26
37
 
27
- Compaction resets Claude's signed reasoning chain, so `thinking` and `redacted_thinking` blocks do not survive a boundary. See [Preserved thinking and model switches](/models/reference#preserved-thinking-and-model-switches) for behavior between boundaries.
38
+ Long lines sent to a compactor wrap at 2,000 characters. Compaction resets Claude's signed reasoning chain, so `thinking` and `redacted_thinking` blocks do not survive a boundary. See [Preserved thinking and model switches](/models/reference#preserved-thinking-and-model-switches) for behavior between boundaries.
28
39
 
29
40
  ## Persistence and resume
30
41
 
@@ -57,6 +68,8 @@ A successful compaction appends a `type: "compaction"` entry:
57
68
  | `tokensBefore` | Provider-aware whole-context token count before the boundary, used for budgeting and the chat boundary line |
58
69
  | `coveredThroughEntryId` | Written only by earlier versions while a tool call waited for its result; new boundaries are never written while a call waits |
59
70
  | `usage` | Compactor endpoint usage when reported |
71
+ | `fromHook` | `true` when an extension supplied compacted text from `session_before_compact` |
72
+ | `systemMessage` | Optional replayed system prompt and tool state checkpoint at this boundary |
60
73
  | `details.form` | `"cleared"` (no model call) or `"compacted"` (compactor or extension supplied replacement text) |
61
74
  | `details.backend` | `"compactor"` or `"extension"`, present only on `"compacted"` boundaries |
62
75
  | `details.model` | Compactor ID as `provider/model` when a compactor produced the text |
@@ -64,7 +77,7 @@ A successful compaction appends a `type: "compaction"` entry:
64
77
  | `details.history` | Boundary location in `history://sessions/<sessionId>`: `rangeUnit: "entries"`, `entriesBefore`, `boundaryEntry`, and `totalEntries` |
65
78
  | `details.historyAccess` | `"read-search"` or `"session-history-tool"`. Resumed sessions receive `session_history` whenever `read` or `search` is absent from resumed tools |
66
79
  | `details.stats` | Heuristic estimates: `tokensAfter` counts the system prompt and boundary message, `linesBefore` counts replaced context lines, `linesKept` counts compacted lines (`0` on a clear), and `rangeCount` is `0` |
67
- | `details.backupPath` | Path to the pre-compaction backup when written |
80
+ | `details.backupPath` | Path to the pre-compaction backup (`<sessionFile>.<timestamp>.<label>.bak`, never auto-deleted). Populated only for JSONL stores, never SQLite, libSQL, PostgreSQL, or memory stores. |
68
81
 
69
82
  Only `compaction` entries with `details.strategy: "verbatim-lines"` affect active context. Resuming uses the saved boundary text directly without another model request, and messages appended after the boundary stay ordinary messages. Inactive legacy formats do not reapply historical omissions, so content they previously hid may reappear on resume.
70
83
 
@@ -87,11 +100,11 @@ atomic.on("session_before_compact", async (event) => {
87
100
  });
88
101
  ```
89
102
 
90
- `preparation` is a deep-frozen clone. `preparation.region.lines` holds the entire active context since the last boundary serialized as role-tagged lines (`[User]: `, `[Assistant]: `, `[Assistant tool calls]: `, `[Tool result]: `), starting with any previous boundary text. `firstKeptEntryId` is `null`, `keptTailMessageCount` is `0`, and `parameters.query` holds the `/compact` instructions or latest user request.
103
+ `preparation` is a deep-frozen clone (attempting to mutate it throws a `TypeError`). `preparation.region.lines` holds the entire active context since the last boundary serialized as role-tagged lines (`[User]: `, `[Assistant]: `, `[Assistant tool calls]: `, `[Tool result]: `), starting with any previous boundary text. `firstKeptEntryId` is `null`, `keptTailMessageCount` is `0`, and `parameters.query` holds the `/compact` instructions or latest user request.
91
104
 
92
105
  Return `{ cancel: true }` to cancel compaction. Return `{ compactedText }` to write a `Context compacted` boundary offline without provider credentials; the model sees your text in a `<compacted-context>` block followed by recovery instructions.
93
106
 
94
- Empty or whitespace-only text counts as no replacement, so the configured compaction form runs normally. Replacement text exceeding the compactor output cap or automatic trigger budget is rejected and falls back to context clearing with fallback reason `extension failed: output too long (...)`.
107
+ Empty or whitespace-only text counts as no replacement, so the configured compaction form runs normally. If `compactedText` exceeds the compactor output cap or makes `systemPrompt + boundary >= trigger`, Atomic rejects it, falls back to clearing the context with `fallbackReason` starting with `extension failed: output too long`, and emits `session_compact` with `fromExtension: false`.
95
108
 
96
109
  ### `session_compact`
97
110
 
@@ -122,23 +135,50 @@ atomic.on("session_compact_failed", async (event) => {
122
135
 
123
136
  `errorMessage` is absent when cancelled. `fromExtension` marks failures after a `session_before_compact` handler supplied replacement text, and no boundary is saved. A compactor failure is not a compaction failure because Atomic falls back to clearing context and reports `fallbackReason` on `session_compact`.
124
137
 
138
+ ## SDK concurrency and message queuing
139
+
140
+ - **Shared manual runs.** Concurrent manual SDK `session.compact()` calls share one run and resolve to the same result. Calling `abortCompaction()` cancels the run for all waiters, or falls back to clearing context if a compactor request is already in flight.
141
+ - **Manual takeover.** A manual compaction request arriving during automatic compaction cancels the automatic work and its continuation, then runs once the active work settles (or follows the automatic boundary if it already committed).
142
+ - **Automatic continuations.** Automatic continuations, including output-cap continuations, belong to the original prompt. Both the `prompt()` promise and `agent_settled` finish only after the full continuation chain completes.
143
+ - **Waiting messages.** User messages arriving during compaction (from typed input, prompt templates, skills, SDK `prompt()`, RPC `prompt`, or extension `sendUserMessage()`) wait in arrival order until compaction ends, then run once. If an earlier waiting message has already started a turn, later messages without `streamingBehavior` or `deliverAs` queue behind it as steering.
144
+ - **Inspecting and clearing queued input.** Waiting messages appear in `getSteeringMessages()`, `getFollowUpMessages()`, and `queue_update` events, and `clearQueue()` returns them without sending them. Before the TUI runs an extension command during compaction, it hands already-typed messages to the session so messages sent by the command run after them.
145
+ - **Turn hooks.** SDK `prepareNextTurn` and `prepareNextTurnWithContext` callbacks receive the rebuilt context after mid-turn compaction. Returning `{ action: "end" }` from `finishTurn` keeps queued input pending until an explicit prompt or continuation, while mid-turn compaction resumes streaming automatically.
146
+
147
+ ## Compaction errors
148
+
149
+ Compaction settings, session compaction calls, and direct `requestCompactorOutput()` calls throw subclasses of `CompactionError`. Branch on the class or `error.code` (never on the message string):
150
+
151
+ | Class | `code` | `retryable` | When |
152
+ | --- | --- | --- | --- |
153
+ | `CompactionConfigError` | `invalid-setting` | `false` | `setCompactionModel()` or RPC `set_compaction_model` receives a non-string, whitespace-padded string, or invalid `scope`/`persist` |
154
+ | `CompactionCancelledError` | `cancelled` | `false` | Compaction is cancelled via abort signal or `session_before_compact` returning `{ cancel: true }` |
155
+ | `CompactionStateError` | `nothing-to-compact`, `pending-tool-call`, `no-model-selected`, `snapshot-failed`, `boundary-not-built` | `false` | `session.compact()` cannot proceed in the current session state |
156
+ | `CompactorFailure` | `missing-base-url`, `missing-credentials`, `request-aborted`, `timeout`, `http-error`, `network-error`, `malformed-response`, `empty-output`, `compactor-failed` | `true` for `timeout`, `network-error`, and HTTP `408`/`429`/`5xx`; `false` otherwise | Direct `requestCompactorOutput()` fails (during `session.compact()`, Atomic catches `CompactorFailure` and falls back to clearing context) |
157
+
158
+ Every `CompactionError` carries `code`, `hint`, `retryable`, and `fields()`. Use `isCompactionError`, `isCompactionConfigError`, `isCompactionCancelledError`, `isCompactionStateError`, `isCompactorFailure`, `findCompactionError`, and `isRetryableCompactionError` to match errors across realms or cause chains. Use `serializeCompactionError`, `parseSerializedCompactionError`, and `rehydrateCompactionError` to preserve the typed class across worker or RPC boundaries (the RPC client rehydrates `compaction_error` responses automatically).
159
+
125
160
  ## Package exports
126
161
 
127
- `@bastani/atomic` exports these compaction helpers and types:
162
+ `@bastani/atomic` exports these compaction helpers, errors, and types:
128
163
 
129
164
  | Export | Use |
130
165
  | --- | --- |
166
+ | `CompactionError`, `CompactionConfigError`, `CompactionCancelledError`, `CompactionStateError`, `CompactorFailure` | Typed compaction error family, matching the SDK error convention (`code`, `hint`, `retryable`, `fields()`) |
167
+ | `isCompactionError`, `isCompactionConfigError`, `isCompactionCancelledError`, `isCompactionStateError`, `isCompactorFailure`, `findCompactionError`, `isRetryableCompactionError` | Type guards and cause-chain helpers for compaction errors |
168
+ | `serializeCompactionError`, `parseSerializedCompactionError`, `rehydrateCompactionError` | Cross-process serialization and rehydration for `CompactionError` |
131
169
  | `buildBoundaryText(input, totalEntries)` | Build the boundary message for a session, history location, and optional instructions or compacted text |
132
170
  | `buildCompactorMessages(messages, isBoundary)` | Frame active context messages in the format sent to a compactor |
133
- | `requestCompactorOutput(request)` | Send one `CompactorRequest` to a compactor endpoint; resolves `{ text, usage? }` or throws `CompactorFailure` |
171
+ | `requestCompactorOutput(request)` | Send one `CompactorRequest` to a compactor endpoint; resolves `{ text, usage? }` or throws `CompactorFailure` / `CompactionCancelledError` |
134
172
  | `resolveCompactionModel(configured, models)` | Resolve `compactionModel` to a `CompactionModelSelection` (`auto` with any fallback reason, or a compactor) |
173
+ | `classifyCompactionModel(configured, models)` | Classify a `compactionModel` string as `"auto"`, `"compactor"`, `"chat"`, `"classifier"`, or `"unknown"` |
174
+ | `compactedOutputTokenCap(triggerTokens, maxOutputTokens?)` | Compute the effective compacted output cap in estimated tokens |
135
175
  | `SESSION_HISTORY_TOOL_NAME` | `"session_history"`, the read-only history tool granted after clearing when `read` or `search` is absent |
136
176
 
137
- The types `CompactionForm`, `CompactionBackend`, `CompactionHistoryLocation`, `CompactionModelSelection`, `CompactorMessage`, `CompactorRequest`, and `BranchSummaryEntry` are exported alongside them.
177
+ The types `CompactorModel`, `CompactorApi`, `ProviderCompactorModelConfig`, `CompactionForm`, `CompactionBackend`, `CompactionHistoryLocation`, `CompactionModelKind`, `CompactionModelSelection`, `CompactorMessage`, `CompactorRequest`, `CompactionErrorCode`, `SerializedCompactionError`, and `BranchSummaryEntry` are exported alongside them.
138
178
 
139
179
  ## Branch summary format
140
180
 
141
- Branch summarization writes structured Markdown:
181
+ Built-in branch summarization prepends the preamble `"The user explored a different conversation branch before returning here.\nSummary of that exploration:\n\n"` and writes structured Markdown with these sections:
142
182
 
143
183
  ```markdown
144
184
  ## Goal
@@ -163,9 +203,6 @@ Branch summarization writes structured Markdown:
163
203
  ## Next Steps
164
204
  1. [What should happen next]
165
205
 
166
- ## Critical Context
167
- - [Data needed to continue]
168
-
169
206
  <read-files>
170
207
  path/to/file1.ts
171
208
  path/to/file2.ts
@@ -211,7 +248,7 @@ Branch-summary prompts serialize conversation messages with role labels so the m
211
248
  [Tool result]: Output from tool
212
249
  ```
213
250
 
214
- Thinking blocks are omitted. Tool results longer than 2,000 characters are truncated with a marker stating how many characters were removed.
251
+ Thinking blocks are omitted. Built-in branch summarization truncates every tool result to **500 characters** before serialization (with a marker stating how many characters were removed). Calling `serializeConversation()` directly on unshortened messages truncates tool results at 2,000 characters.
215
252
 
216
253
  ## Extension hooks for branch summarization
217
254