@bastani/atomic 0.10.9 → 0.10.10-alpha.2

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 (406) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/README.md +226 -163
  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} +150 -62
  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 +87 -116
  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 +61 -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 +74 -141
  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 +61 -88
  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 +238 -243
  297. package/docs/build.md +21 -15
  298. package/docs/changelog.mdx +1 -1
  299. package/docs/codemode.md +68 -51
  300. package/docs/compaction/reference.md +65 -26
  301. package/docs/compaction.md +118 -66
  302. package/docs/computer-use.md +179 -146
  303. package/docs/containerization.md +87 -33
  304. package/docs/custom-provider/api-reference.md +152 -13
  305. package/docs/custom-provider/oauth.md +45 -28
  306. package/docs/custom-provider/override.md +14 -7
  307. package/docs/custom-provider/registration.md +77 -67
  308. package/docs/custom-provider/streaming.md +42 -19
  309. package/docs/custom-provider.md +26 -62
  310. package/docs/development.md +81 -42
  311. package/docs/docs.json +54 -38
  312. package/docs/environment-variables.md +92 -64
  313. package/docs/extensions/api-reference.md +326 -735
  314. package/docs/extensions/authoring.md +186 -269
  315. package/docs/extensions/events.md +308 -375
  316. package/docs/extensions/examples.md +122 -74
  317. package/docs/extensions/ui.md +217 -197
  318. package/docs/extensions.md +189 -259
  319. package/docs/getting-started/authentication.md +27 -14
  320. package/docs/getting-started/first-session.md +25 -26
  321. package/docs/getting-started/installation.md +62 -84
  322. package/docs/getting-started/project-instructions.md +39 -14
  323. package/docs/guides/configuration.md +62 -20
  324. package/docs/guides/intercom.md +20 -12
  325. package/docs/guides/non-interactive.md +31 -16
  326. package/docs/guides/orchestration.md +17 -9
  327. package/docs/guides/resume-on-any-machine.md +63 -52
  328. package/docs/guides/subagents.md +26 -14
  329. package/docs/guides/team-setup.md +49 -27
  330. package/docs/guides.md +30 -23
  331. package/docs/herdr.md +22 -17
  332. package/docs/index.md +24 -17
  333. package/docs/intercom/operations.md +90 -66
  334. package/docs/intercom/reference.md +219 -192
  335. package/docs/intercom.md +111 -92
  336. package/docs/json.md +73 -71
  337. package/docs/keybindings.md +74 -48
  338. package/docs/libraries/agent-core.md +52 -9
  339. package/docs/libraries/ai.md +90 -63
  340. package/docs/libraries/codemode.md +31 -8
  341. package/docs/libraries/schema.md +12 -9
  342. package/docs/libraries/storage-libsql.md +92 -0
  343. package/docs/libraries/storage-postgres.md +119 -0
  344. package/docs/libraries/telemetry.md +42 -9
  345. package/docs/libraries/tui.md +74 -94
  346. package/docs/libraries.md +25 -8
  347. package/docs/llama-cpp.md +38 -33
  348. package/docs/mcp-servers.md +140 -88
  349. package/docs/models/reference.md +53 -36
  350. package/docs/models-configuration.md +19 -13
  351. package/docs/models.md +102 -87
  352. package/docs/orchestration/migrating-workflows.md +22 -20
  353. package/docs/orchestration/patterns.md +36 -21
  354. package/docs/orchestration.md +24 -21
  355. package/docs/packages/authoring.md +29 -18
  356. package/docs/packages/reference.md +77 -16
  357. package/docs/packages.md +34 -34
  358. package/docs/programmatic.md +28 -21
  359. package/docs/prompt-templates.md +65 -41
  360. package/docs/providers/reference.md +36 -20
  361. package/docs/providers.md +78 -76
  362. package/docs/quickstart.md +42 -54
  363. package/docs/reference/cli.md +256 -254
  364. package/docs/reference.md +30 -23
  365. package/docs/rpc/examples.md +121 -17
  366. package/docs/rpc/extension-ui.md +86 -63
  367. package/docs/rpc/protocol.md +817 -358
  368. package/docs/rpc.md +78 -152
  369. package/docs/sdk/reference.md +309 -73
  370. package/docs/sdk/storage.md +614 -0
  371. package/docs/sdk/structured-decisions.md +168 -65
  372. package/docs/sdk/web-server.md +80 -46
  373. package/docs/sdk.md +168 -215
  374. package/docs/security.md +117 -44
  375. package/docs/session-format.md +127 -76
  376. package/docs/sessions.md +155 -113
  377. package/docs/settings.md +293 -205
  378. package/docs/shell-aliases.md +15 -6
  379. package/docs/skills/authoring.md +17 -9
  380. package/docs/skills/reference.md +23 -21
  381. package/docs/skills.md +148 -97
  382. package/docs/storage.md +172 -260
  383. package/docs/subagents/authoring.md +148 -15
  384. package/docs/subagents/reference.md +105 -29
  385. package/docs/subagents.md +247 -250
  386. package/docs/terminal-setup.md +97 -69
  387. package/docs/termux.md +51 -85
  388. package/docs/themes/reference.md +51 -37
  389. package/docs/themes.md +52 -55
  390. package/docs/tmux.md +38 -21
  391. package/docs/tools.md +209 -147
  392. package/docs/tui/reference.md +64 -32
  393. package/docs/tui.md +38 -66
  394. package/docs/usage.md +94 -86
  395. package/docs/verification.md +25 -25
  396. package/docs/web-access.md +106 -54
  397. package/docs/windows.md +55 -57
  398. package/docs/worktree-snapshots.md +82 -74
  399. package/examples/sdk/11-sessions.ts +4 -4
  400. package/package.json +8 -8
  401. package/schemas/models.schema.json +58 -7
  402. package/dist/_shared/sdk-OSBEPR3Q.js.map +0 -1
  403. package/dist/_shared/startup-0-0-TYUFUOJZ.js.map +0 -1
  404. package/dist/_shared/startup-0-1-W2G2UY7R.js.map +0 -1
  405. package/dist/_shared/startup-0-2-UXBUEOXW.js.map +0 -1
  406. package/dist/_shared/startup-0-4-HN5EB4K7.js.map +0 -1
@@ -1,111 +1,38 @@
1
1
  ---
2
- title: Extensions
3
- description: Extend Atomic with TypeScript modules that register tools, commands, event handlers, and custom UI.
2
+ title: "Extensions overview"
3
+ sidebarTitle: "Extensions overview"
4
+ description: "Build TypeScript extensions that add tools, slash commands, lifecycle hooks, and custom terminal UI to Atomic."
4
5
  ---
5
6
 
6
- # Extensions
7
-
8
- Extensions are TypeScript modules that extend Atomic's behavior. They can subscribe to lifecycle events, register custom tools callable by the LLM, add commands, and render custom UI.
9
-
10
- ## Reloading and startup behavior
11
-
12
- Put extensions in `~/.atomic/agent/extensions/` (global) or `.atomic/extensions/` (project-local) for auto-discovery; legacy `.pi` paths remain supported. Use `atomic -e ./path.ts` for quick tests.
13
-
14
- Auto-discovered extensions hot-reload with `/reload`. Atomic evaluates each extension file and the local modules and JSON files it imports through its own transform, including plain JavaScript (`.mjs`, `.cjs`, and `.js`). ESM keeps `import.meta.url`, strict mode, top-level await, and package or Node built-in imports. CommonJS keeps `require`, `module.exports`, `__filename`, `__dirname`, and sloppy mode.
15
-
16
- Under Bun, extensions also load through Atomic's extension loader on the first load (not only on `/reload`). That keeps `typebox` and Atomic package imports pointing to Atomic's own copies right away and matches native `import.meta` values (including Windows backslashes). Because the loader reads runtime globals through `globalThis`, modules that declare a top-level `globalThis` binding cannot be loaded this way under Node or Bun.
17
-
18
- Packages imported by name resolve from the importing file as Node or Bun would, falling back to Atomic's copy of a host package only when none is installed. Named packages, files under `node_modules` outside the extension's own package, and modules loaded through `createRequire()` load once per process, so restart Atomic after editing them.
19
-
20
- If `/reload` reports `Reload retiring cleanup failed`, the error includes the extension cleanup cause. The replacement extensions, updated settings, and joined Intercom groups stay active. Fix the cleanup error before reloading again.
21
-
22
- If an optional extension fails to import or initialize during interactive startup or `/reload`, Atomic skips it and shows its path and reason under `[Extension issues]` while keeping the session usable. Fix the extension or its dependencies and run `/reload`. Print mode (`-p`) and standalone RPC mode (`--mode rpc`) report the named failure and exit with status 1 instead so scripts do not silently run without a requested extension. Required built-in failures and failed cleanup stop startup in every mode.
23
-
24
- Legacy extensions can import the running host API from `@mariozechner/pi-coding-agent` or `@earendil-works/pi-coding-agent`, including in release-archive installs, without a separate installation.
7
+ Extensions are TypeScript or JavaScript modules that customize how Atomic behaves. You can use them to add custom tools, intercept lifecycle events, register slash commands, store session state, or render custom terminal UI.
25
8
 
26
9
  Key capabilities:
27
10
 
28
- - **Custom tools.** Register tools the LLM can call via `atomic.registerTool()`.
29
- - **Event interception.** Block or modify tool calls, inject context, observe or replace compaction, and customize branch summaries.
30
- - **User interaction.** Prompt users via `ctx.ui` (`select`, `confirm`, `input`, `editor`, `notify`).
31
- - **Custom UI components.** Render interactive TUI components with keyboard input via `ctx.ui.custom()`.
32
- - **Custom commands.** Register slash commands such as `/mycommand` via `atomic.registerCommand()`.
33
- - **Session persistence.** Store durable state that survives restarts via `atomic.appendEntry()`.
34
- - **Reload-surviving state.** Keep in-memory objects alive across `/reload` via `sessionScopedExtensionState()`.
35
- - **Custom rendering.** Control how tool calls, tool results, and custom messages appear in the TUI.
11
+ - **Custom tools.** Register tools the model can call with `atomic.registerTool()`.
12
+ - **Event hooks.** Block or modify tool calls, adjust context before requests, observe or replace compaction, and customize branch summaries.
13
+ - **User interaction.** Show interactive prompts and notifications via `ctx.ui` (`select`, `confirm`, `input`, `editor`, `notify`).
14
+ - **Custom UI components.** Render interactive terminal components and overlays with `ctx.ui.custom()`.
15
+ - **Custom commands.** Register slash commands such as `/mycommand` with `atomic.registerCommand()`.
16
+ - **Session persistence.** Store durable data across restarts with `atomic.appendEntry()`.
17
+ - **Reload-surviving state.** Keep in-memory objects alive across `/reload` with `sessionScopedExtensionState()`.
18
+ - **Custom rendering.** Control how tool calls, tool results, and custom messages appear in the terminal.
36
19
 
37
- Common use cases include permission gates, git checkpointing, path protection, compaction policies, conversation summaries (`summarize.ts`), interactive wizards, stateful tools, webhooks or file watchers, and waiting-time games (`snake.ts`). See [examples/extensions/](https://github.com/bastani-inc/atomic/tree/main/packages/coding-agent/examples/extensions) for working implementations.
38
-
39
- Atomic also ships an environment-gated [Herdr reporter](/herdr) that reports the parent session's activity, running tasks, and approval requests in its pane. It defers to loaded community or legacy reporters and can be disabled with `herdr.enabled` in settings. See [Herdr setup](/herdr#setup) and [status indicators](/herdr#status-indicators).
20
+ Common use cases include permission gates, git checkpointing, path protection, compaction policies, conversation summaries, interactive wizards, webhooks or file watchers, and waiting-time games. See [Extension examples](/extensions/examples) for runnable code.
40
21
 
41
22
  ## Where to go next
42
23
 
43
- Read this page for startup behavior, locations, imports, and a first extension, then continue:
24
+ Read this overview for a working first extension, discovery locations, imports, and runtime behavior, then continue:
44
25
 
45
- - [Writing extensions](/extensions/authoring). Build an extension, manage its state, and register custom tools.
46
- - [Extension events](/extensions/events). Look up every event, its payload, and its return contract.
47
- - [Extension UI](/extensions/ui). Render dialogs, widgets, and custom UI components.
48
- - [Extension API reference](/extensions/api-reference). Reference `ExtensionContext`, `ExtensionCommandContext`, `ExtensionAPI` methods, and error handling.
49
- - [Extension examples](/extensions/examples). Browse runnable examples shipped with Atomic.
26
+ - [Write an extension](/extensions/authoring). Structure an extension, manage state, register custom tools, and customize rendering.
27
+ - [Extension events](/extensions/events). Look up every lifecycle event, its payload, and its return contract.
28
+ - [Extension UI](/extensions/ui). Build dialogs, widgets, host-native pickers and forms, custom components, and message renderers.
29
+ - [Extension API reference](/extensions/api-reference). Reference `ExtensionContext`, `ExtensionToolContext`, `ExtensionCommandContext`, `ExtensionAPI` methods, and error handling.
30
+ - [Extension examples](/extensions/examples). Browse runnable extensions shipped with Atomic.
31
+ - [SDK extensions](/sdk/reference#extensions) and [Structured decisions](/sdk/structured-decisions). Load extensions programmatically with `DefaultResourceLoader`, pass standalone `customTools`, or run schema-validated decisions.
50
32
  - [Security](/security). Review the project-trust boundary that controls whether a project's extensions load.
51
33
 
52
34
  If an extension is heavier than you need, compare lighter options on [Build with Atomic](/build).
53
35
 
54
- ## Startup and lazy discovery
55
-
56
- Built-in MCP, subagent, web-access, and Intercom commands are available at startup. Their first use may wait for discovery or connection.
57
-
58
- Commands wait for the resources they need before returning results, including MCP tool calls and explicit reloads. Discovery scope depends on the operation:
59
-
60
- - Enabled MCP servers connect in the background when a session starts. The first prompt waits up to 10 seconds for servers with direct tools.
61
- - Codemode waits for the MCP namespaces a script names; `searchTools()` and `ALL_TOOLS` require all enabled servers. Tool search and resource tools also wait for discovery.
62
- - `/mcp` provides server management; `/mcp login`, `/mcp logout`, and `/mcp reconnect` accept an optional server name. Completion lists actions and eligible servers.
63
- - Autocomplete falls back to current and administrative completions when lazy discovery fails.
64
-
65
- Failed connections can be retried with `/mcp reconnect`, and dropped MCP connections reconnect on the next call. Web-access batches with no successful items report a tool error; partial successes keep their completed items.
66
-
67
- MCP `timeout` is an inactivity limit in seconds (default 60 seconds), reset by progress rather than a fixed total deadline. See [MCP servers](/mcp-servers) for configuration, exposure, resources, OAuth, and shell commands.
68
-
69
- ## Interactive callback isolation
70
-
71
- Interactive sessions isolate extension callbacks from terminal input handling so a busy callback does not block keyboard input or spinners.
72
-
73
- Escape requests cooperative cancellation from the engine and waits as long as the engine takes. There is no deadline on that wait, and Escape never terminates or replaces the engine, so an interrupt cannot discard in-flight tool state.
74
-
75
- Ctrl+C is the host's escape hatch in two situations.
76
-
77
- First, while an engine-owned `ctx.ui.custom()` component or overlay holds input, every key goes to the engine child. Ownership of Ctrl+C is declared per mount:
78
-
79
- - A component mounted with `handlesCtrlC: true` receives the first Ctrl+C press and keeps its own skip, close, or cancel binding. If that same component still holds input on the next Ctrl+C press, the host closes it so no component can trap the keyboard.
80
- - A component without `handlesCtrlC: true` is closed on the first Ctrl+C press through the ordinary close path: its `ctx.ui.custom()` promise resolves with `undefined`, the editor returns, and the engine keeps running (along with any other mounted component).
81
-
82
- Declare `handlesCtrlC: true` whenever your component's hint row offers `ctrl+c`. Native host selectors, dialogs, input forms, session pickers, and unrelated native overlays keep Ctrl+C as their own cancel.
83
-
84
- ```typescript
85
- await ctx.ui.custom<string | undefined>(
86
- (tui, theme, keybindings, done) => new PromptCard(tui, theme, done),
87
- { overlay: true, handlesCtrlC: true },
88
- );
89
- ```
90
-
91
- Both safety keys match by physical key identity rather than the configured `app.clear` action, so rebinding `app.clear` (even to Escape) cannot route Escape into engine replacement or disable Ctrl+C recovery. Rebinding `app.clear` to another key keeps normal editor clearing, and key-release events never act.
92
-
93
- Second, if the engine is unresponsive, an abort or replacement has waited over one second, or replacement failed, Ctrl+C terminates and replaces the engine. This takes precedence over custom UI bindings. A failed replacement remains recoverable with another Ctrl+C; Atomic does not keep retrying automatically.
94
-
95
- After an unexpected engine stop, Atomic closes custom UI and attempts one automatic restart. A clean restart prints nothing unless messages were still queued.
96
-
97
- If messages were queued, main-chat messages return to the editor (steering first) with the warning `Engine restarted; 2 queued messages weren't sent and are back in the editor`. For a subagent chat, known-unsent queued messages (both messages confirmed absent from disk and messages still listed in its queue) return ahead of any draft into that subagent's own editor (immediately if its view is open and writable, or on the first writable reopen in the same session with `Engine restarted; 2 queued messages to <agent> weren't sent; they're back in its editor when you open it`); when the subagent view is read-only or confirmation is unavailable, Atomic prints `Engine restarted; 2 queued messages to <agent> weren't sent:` and never writes into main's editor. None are sent twice, and unstarted submissions return as exact drafts while accepted work is not retried automatically. With debug logging enabled, the restart cause goes to the debug log. A failed restart leaves the editor usable and reports `Interactive engine restart failed: ...`.
98
-
99
- If a saved tool call has no recorded result, reopening the session marks its result unavailable. **Inspect files or external systems before retrying because the tool may already have had side effects.**
100
-
101
- When spawning processes from an extension, pass an explicit `env` derived from `process.env`. Engine-only bootstrap values are not exposed there.
102
-
103
- Dialogs, `ctx.ui.custom()` components, and component-factory widgets run in the isolated engine child and proxy rendered lines to the host with asynchronous input forwarding. Custom UI results must be JSON-safe. APIs that require a synchronous callback in the terminal host (raw `onTerminalInput` transforms, synchronous `getEditorText`, custom editor factories, autocomplete wrappers, and custom header or footer factories) are unavailable in isolated interactive mode and produce a warning instead of running extension code in the host. Print and public RPC modes keep their own execution models.
104
-
105
- Use `ctx.ui.hostSessionPicker(request)` for a session-style picker with local navigation and search. Pass JSON-safe `HostSessionPickerRow` values (`SessionInfo` with `createdAt` and `modifiedAt` in epoch milliseconds). The returned handle provides `result`, `update(rows)`, `error(message)`, and `close()`. `result` resolves to the selected `path` or `undefined` on cancel, and your `onDelete(path)` callback owns deletion. This API works in both interactive modes and is absent in print and headless RPC. See [Host-native session picker](/tui/reference#host-native-session-picker).
106
-
107
- For structured forms, use `ctx.ui.hostInputForm(request)` with JSON-safe descriptors (`string`, `text`, `number`, `integer`, `boolean`, or `select`) and raw `initialValue` fields. It resolves to a raw string record or `undefined` on cancel, and rejects with `"The host could not read this input form."` if the host cannot read the form. Editing, navigation, validation, and configured keybindings run locally in both interactive modes. Print and headless RPC omit this API. See [Host-native input form](/tui/reference#host-native-input-form).
108
-
109
36
  ## Quick start
110
37
 
111
38
  Create `~/.atomic/agent/extensions/my-extension.ts` (the factory parameter can have any name; older extensions and examples call it `pi`):
@@ -135,7 +62,7 @@ export default function (atomic: ExtensionAPI) {
135
62
  parameters: Type.Object({
136
63
  name: Type.String({ description: "Name to greet" }),
137
64
  }),
138
- async execute(toolCallId, params, signal, onUpdate, ctx) {
65
+ async execute(_toolCallId, params) {
139
66
  return {
140
67
  content: [{ type: "text", text: `Hello, ${params.name}!` }],
141
68
  details: {},
@@ -153,30 +80,70 @@ export default function (atomic: ExtensionAPI) {
153
80
  }
154
81
  ```
155
82
 
156
- Test with `--extension` (or `-e`):
83
+ Test it for one run with `-e` (or `--extension`):
157
84
 
158
85
  ```bash
159
86
  atomic -e ./my-extension.ts
160
87
  ```
161
88
 
89
+ ### Loading in the SDK
90
+
91
+ Embedded apps can load extension files, pass inline factories through `DefaultResourceLoader`, or register standalone tools directly with `createAgentSession({ customTools })`:
92
+
93
+ ```typescript
94
+ import { createAgentSession, DefaultResourceLoader, defineTool } from "@bastani/atomic";
95
+ import { Type } from "@bastani/atomic/typebox";
96
+
97
+ const loader = new DefaultResourceLoader({
98
+ additionalExtensionPaths: ["./my-extension.ts"],
99
+ extensionFactories: [
100
+ (atomic) => {
101
+ atomic.on("agent_start", () => console.log("Starting run"));
102
+ },
103
+ ],
104
+ });
105
+ await loader.reload();
106
+
107
+ const pingTool = defineTool({
108
+ name: "ping",
109
+ label: "Ping",
110
+ description: "Return pong",
111
+ parameters: Type.Object({}),
112
+ async execute() {
113
+ return { content: [{ type: "text", text: "pong" }], details: {} };
114
+ },
115
+ });
116
+
117
+ const { session } = await createAgentSession({
118
+ resourceLoader: loader,
119
+ customTools: [pingTool],
120
+ });
121
+ ```
122
+
123
+ See [SDK extensions](/sdk/reference#extensions) and [SDK custom tools](/sdk/reference#custom-tools).
124
+
162
125
  ## Extension locations
163
126
 
164
127
  > **Security:** Extensions run with your full system permissions and can execute arbitrary code. Install only from sources you trust.
165
128
 
166
- Extensions are auto-discovered from:
129
+ Atomic auto-discovers extensions from these locations:
167
130
 
168
131
  | Location | Scope |
169
- |----------|-------|
170
- | `~/.atomic/agent/extensions/*.ts` | Global (all projects) |
171
- | `~/.atomic/agent/extensions/*/index.ts` | Global (subdirectory) |
172
- | `.atomic/extensions/*.ts` | Project-local (trusted projects only) |
173
- | `.atomic/extensions/*/index.ts` | Project-local subdirectory (trusted projects only) |
132
+ | --- | --- |
133
+ | `~/.atomic/agent/extensions/*.{ts,js}` | Global single-file extensions (all projects) |
134
+ | `~/.atomic/agent/extensions/*/index.{ts,js}` | Global subdirectory extensions |
135
+ | `~/.atomic/agent/extensions/*/package.json` | Global subdirectories declaring `atomic.extensions` (or legacy `pi.extensions`) |
136
+ | `.atomic/extensions/*.{ts,js}` | Project single-file extensions (trusted projects only) |
137
+ | `.atomic/extensions/*/index.{ts,js}` | Project subdirectory extensions (trusted projects only) |
138
+ | `.atomic/extensions/*/package.json` | Project subdirectories declaring `atomic.extensions` (trusted projects only) |
174
139
 
175
- Atomic also discovers extensions and package resources inherited from legacy `~/.pi/agent` and `.pi` configuration. When an inherited extension uses the exact same tool, command, prompt, flag, or shortcut name as a bundled Atomic extension, Atomic keeps the bundled registration and ignores only the conflicting inherited registration while keeping its other resources. Interactive startup reports those overlaps in one yellow summary; print and RPC modes apply the same winners without editing legacy settings or package files.
140
+ Discovery rules:
176
141
 
177
- This compatibility rule applies only to inherited legacy resources. Extensions configured through `.atomic` or passed with `--extension` keep the normal override and load-order rules.
142
+ - Scanning respects `.gitignore`, `.ignore`, and `.fdignore` inside extension directories, and skips dotfiles, dot-directories, and `node_modules`.
143
+ - Disable extension discovery with `--no-extensions` (short flag `-ne`). Explicit `-e` paths and the mandatory bundled Intercom extension still load.
144
+ - Atomic also discovers extensions and packages inherited from legacy `~/.pi/agent` and `.pi` directories. If an inherited legacy extension registers the exact same tool, command, prompt, flag, or shortcut name as a bundled Atomic extension, Atomic keeps the bundled registration and skips only that conflicting registration (summarized in yellow on interactive startup). Extensions configured through `.atomic` or passed with `-e` follow normal override rules.
178
145
 
179
- Configure additional paths in `settings.json`:
146
+ Configure extra paths or packages in `settings.json`:
180
147
 
181
148
  ```json
182
149
  {
@@ -191,204 +158,167 @@ Configure additional paths in `settings.json`:
191
158
  }
192
159
  ```
193
160
 
161
+ To distribute extensions over npm or git, see [Install and manage packages](/packages).
162
+
194
163
  ### Built-in extension resources
195
164
 
196
- Atomic exposes `builtin:llama.cpp`, `builtin:codemode`, and `builtin:tool-search` as extension resources rather than filesystem paths. Disable one in `settings.json`:
165
+ Atomic exposes `builtin:llama.cpp` ([llama.cpp](/llama-cpp)), `builtin:codemode` ([Codemode](/codemode)), and `builtin:tool-search` (which registers the [`tool_search`](/tools#tool_search) tool) as built-in extension resources rather than filesystem paths. Toggle them interactively in `atomic config`, or disable one in `settings.json`:
197
166
 
198
167
  ```json
199
168
  { "extensions": ["-builtin:codemode"] }
200
169
  ```
201
170
 
202
- A trusted project `"+builtin:codemode"` entry can override a global exclusion. Explicit loading also works with `--no-extensions`: `atomic --no-extensions -e builtin:codemode --tools read,codemode`. Loading the resource registers the tool. Codemode is in the default selection, so a replacement tool list must name it; tool search is opt-in.
171
+ A trusted project `"+builtin:codemode"` entry overrides a global exclusion. You can also load one explicitly alongside `--no-extensions` (`-ne`):
172
+
173
+ ```bash
174
+ atomic --no-extensions -e builtin:codemode --tools read,codemode
175
+ ```
203
176
 
204
- Codemode and tool search are replaceable: an extension that registers the same tool, command, or flag can take over, and Atomic reports the replacement and its owner. Disable that extension through `atomic config` when you want the built-in implementation instead.
177
+ Passing an unrecognized `builtin:<name>` with `-e` stops with `Unknown built-in extension: builtin:<name>`.
205
178
 
206
- These symbolic names do not replace Atomic's bundled MCP, subagent, web-access, or Intercom packages. There are no `builtin:mcp` or `builtin:subagents` aliases; keep using package settings and MCP configuration.
179
+ Loading a built-in resource registers its tool. `codemode` is enabled in the default tool list (so a custom `--tools` list must name it), while `tool_search` is opt-in. Both `codemode` and `tool-search` are replaceable: a custom extension that registers the same tool, command, or flag takes over, and Atomic reports the replacement. Disable that extension in `atomic config` to restore the built-in version.
207
180
 
208
- To share extensions via npm or git as Atomic packages, see [Atomic packages](/packages).
181
+ These built-in names do not replace Atomic's bundled MCP, subagent, web-access, or Intercom packages. There are no `builtin:mcp` or `builtin:subagents` aliases; configure those through package settings and MCP configuration.
209
182
 
210
183
  ## Available imports
211
184
 
185
+ Extensions can import Atomic's bundled packages without installing them in `node_modules`:
186
+
212
187
  | Package | Purpose |
213
- |---------|---------|
214
- | `@bastani/atomic` | Extension types (`ExtensionAPI`, `ExtensionContext`, events) and helpers such as `StringEnum` |
215
- | `typebox` | Schema definitions for tool parameters. Direct `typebox` imports (including subpaths such as `typebox/format`) resolve to Atomic's copy so formats registered with `Format.Set()` apply to tool validation |
216
- | [`@bastani/atomic-ai`](/libraries/ai) | AI utilities (also exports `StringEnum`), provider APIs, and image generation helpers |
217
- | [`@bastani/atomic-tui`](/libraries/tui) | TUI components for custom rendering |
188
+ | --- | --- |
189
+ | [`@bastani/atomic`](/sdk) | Extension types (`ExtensionAPI`, `ExtensionContext`, events), helpers (`StringEnum`, `defineTool`), and built-in tool factories |
190
+ | [`@bastani/atomic/storage`](/sdk/storage) | Storage adapter interfaces, `createSqliteDatabase()`, and storage errors |
191
+ | `@bastani/atomic/typebox` | Atomic's copy of TypeBox plus subpaths (`/compile`, `/error`, `/format`, `/guard`, `/schema`, `/system`, `/type`, `/value`) |
192
+ | `typebox` and `@sinclair/typebox` | Direct schema imports (including `typebox/*`, `@sinclair/typebox/compile`, and `@sinclair/typebox/value`) resolve to Atomic's copy so formats registered with `Format.Set()` apply to tool validation |
193
+ | [`@bastani/atomic-ai`](/libraries/ai) | AI utilities, provider APIs, image generation, and subpaths (`/oauth`, `/models`, `/providers/all`) |
194
+ | [`@bastani/atomic-tui`](/libraries/tui) | Terminal UI components for custom rendering |
218
195
  | [`@bastani/atomic-agent-core`](/libraries/agent-core) | Agent loop types and helpers |
219
- | [`@bastani/atomic-codemode`](/libraries/codemode) | Codemode sandbox and declaration helpers |
220
- | [`@bastani/atomic-schema`](/libraries/schema) | JSON Schema builders and validation |
221
- | [`@bastani/atomic-telemetry`](/libraries/telemetry) | Telemetry contracts |
196
+ | [`@bastani/atomic-codemode`](/libraries/codemode) | Codemode sandbox and declaration helpers (`@bastani/atomic-codemode/*`) |
197
+ | [`@bastani/atomic-schema`](/libraries/schema) | JSON Schema builders, validation, and `/formats` |
198
+ | [`@bastani/atomic-telemetry`](/libraries/telemetry) | Telemetry contracts and `/render` |
199
+
200
+ Atomic maintains these packages directly; [Libraries](/libraries) documents each one. Legacy import names (`@earendil-works/pi-*`, `@mariozechner/pi-*`, and `@bastani/pi-ai`) resolve to the same modules, including in release-archive installs. New extensions should import the `@bastani/atomic-*` names.
222
201
 
223
- Atomic maintains these packages directly; [Libraries](/libraries) documents each one. Legacy extension names (`@earendil-works/pi-*`, `@mariozechner/pi-*`, and `@bastani/pi-ai`) resolve to the same modules, including their subpaths. New extensions should import the `@bastani/atomic-*` names.
202
+ Node.js built-ins (`node:fs`, `node:path`, and the rest of `node:*`) are always available.
224
203
 
225
- **Sharing TypeBox from dependencies and SDK apps.** Direct `typebox` imports inside an extension file are mapped to Atomic's copy automatically. If a separate package your extension depends on (or an SDK application) registers custom TypeBox formats, settings, or locales that must reach Atomic's tool validation, import from `@bastani/atomic/typebox` and its subpaths (`/compile`, `/error`, `/format`, `/guard`, `/schema`, `/system`, `/type`, `/value`) rather than from a separate `typebox` dependency.
204
+ **Sharing TypeBox from dependencies and SDK apps.** Direct `typebox` imports inside an extension file map to Atomic's copy automatically. If a separate dependency or SDK app registers custom TypeBox formats, settings, or locales that must reach Atomic's tool validation, import from `@bastani/atomic/typebox` and its subpaths rather than from a separate `typebox` dependency. See [Sharing Atomic's TypeBox registry](/sdk#sharing-atomics-typebox-registry).
226
205
 
227
- Registry dependencies work too. Add a `package.json` next to your extension (or in a parent directory) and install dependencies with npm (or pnpm or Bun):
206
+ **Third-party npm dependencies.** Add a `package.json` next to your extension (or in a parent directory) and install dependencies with npm, pnpm, or Bun:
228
207
 
229
208
  ```bash
230
209
  npm install
231
210
  ```
232
211
 
233
- Imports from `node_modules/` resolve automatically.
234
-
235
- For distributed Atomic packages installed with `atomic install` (npm or git), declare runtime dependencies in `dependencies`. Package installation installs production dependencies by default, so `devDependencies` are not available at runtime. When `npmCommand` is configured, git packages run a plain `install` for wrapper compatibility.
212
+ Imports from `node_modules/` resolve automatically. For distributed packages installed with `atomic install` (npm or git), declare runtime dependencies in `dependencies`; `devDependencies` are omitted by default. When `npmCommand` is configured in `settings.json`, git package installs still detect `npm`, `pnpm`, or `bun` inside wrapper commands (such as `["mise", "exec", "node@20", "--", "npm"]`) and pass manager-specific flags to skip dev and peer dependencies. Plain `install` runs only for unrecognized package manager commands.
236
213
 
237
214
  ### Tool parameter schemas
238
215
 
239
- A tool's `parameters` can be a TypeBox schema or any plain JSON Schema object. Atomic validates the model's arguments against it after coercing loosely typed values (such as a numeric string to a number, `"true"` to `true`, or dropping `null` in an optional property):
240
-
241
- - **TypeBox schemas** are converted and checked by TypeBox, so TypeBox features outside JSON Schema (such as `Type.Refine()` and formats registered with `Format.Set()`) apply and validation errors use TypeBox's messages.
242
- - **Plain JSON Schema** (such as an MCP server's tool schema or a schema built with `@bastani/atomic-schema`) is coerced and checked by `@bastani/atomic-schema`. A single value is wrapped into a one-item array when an array is expected, the `url` and `json-pointer-uri-fragment` formats are checked, and an unresolved `$ref` rejects only the argument at that field instead of every call. Validation errors use `@bastani/atomic-schema`'s messages, such as `- path: missing` or `- limit: expected number, got string`.
216
+ A tool's `parameters` can be a TypeBox schema or any plain JSON Schema object. Atomic validates arguments from the model after coercing loosely typed values (such as a numeric string to a number, `"true"` to `true`, or dropping `null` on an optional property):
243
217
 
244
- Node.js built-ins (`node:fs`, `node:path`, and the rest of `node:*`) are also available.
218
+ - **TypeBox schemas** are validated by TypeBox, so TypeBox features outside JSON Schema (such as `Type.Refine()` and formats registered with `Format.Set()`) apply and errors use TypeBox's format.
219
+ - **Plain JSON Schema** (such as an MCP server's schema or one built with `@bastani/atomic-schema`) is coerced and checked by `@bastani/atomic-schema`. Single values wrap into one-item arrays when an array is expected, `url` and `json-pointer-uri-fragment` formats are checked, and an unresolved `$ref` rejects only that field instead of every call. Errors use `@bastani/atomic-schema`'s format, such as `- path: missing` or `- limit: expected number, got string`.
245
220
 
246
221
  ## Mode behavior
247
222
 
248
223
  | Mode | UI methods | Notes |
249
- |------|-----------|-------|
250
- | Interactive | Full TUI | Normal operation |
224
+ | --- | --- | --- |
225
+ | Interactive | Full TUI | Extensions run in a background worker so slow callbacks do not freeze the terminal |
251
226
  | RPC (`--mode rpc`) | JSON protocol | Host handles UI; see [RPC mode](/rpc) |
252
227
  | JSON (`--mode json`) | No-op | Event stream to stdout; see [JSON mode](/json) |
253
228
  | Print (`-p`) | No-op | Extensions run without interactive prompts |
254
229
 
255
- In non-interactive modes, check `ctx.hasUI` before using UI methods.
230
+ Check `ctx.hasUI` (or `ctx.mode === "tui"`) before using UI methods in extensions that may run outside interactive mode.
231
+
232
+ ## Reloading and startup behavior
233
+
234
+ Auto-discovered extensions hot-reload when you run `/reload`. Atomic transpiles each extension file along with local TypeScript, JavaScript (`.mjs`, `.cjs`, `.js`), and JSON files it imports by relative path, so edits to those local files take effect on `/reload`.
235
+
236
+ - **Module format.** ESM files keep `import.meta.url`, strict mode, top-level `await`, and package or Node built-in imports. CommonJS files keep `require`, `module.exports`, `__filename`, and `__dirname`.
237
+ - **Caching on `/reload`.** Named npm packages, files under `node_modules` outside the extension's own package, and modules loaded via `createRequire()` are loaded once per process. Restart Atomic after editing those files.
238
+ - **Bun and `globalThis`.** Under Bun, extensions load through Atomic's loader on initial startup as well as `/reload`, keeping `typebox` and `@bastani/atomic-*` imports pinned to Atomic's own copies. Modules that declare a top-level variable named `globalThis` cannot be loaded under either Node or Bun.
239
+ - **Load failures.** If an optional extension fails to import or initialize during interactive startup or `/reload`, Atomic skips it, lists its path and error under `[Extension issues]`, and keeps the session open. Fix the issue and run `/reload`. In print (`-p`) and standalone RPC (`--mode rpc`) modes, any extension load failure prints the error and exits with code 1. Required built-in failures and cleanup failures stop startup in every mode.
240
+ - **Reload cleanup failures.** If `/reload` reports `Reload retiring cleanup failed`, the error names the failing cleanup callback while keeping the replacement extensions, updated settings, and Intercom groups active. Fix the cleanup bug before reloading again.
241
+ - **Built-in Herdr status reporter.** Inside a Herdr pane, Atomic automatically reports parent session status and resume commands with its built-in [Herdr integration](/herdr) and skips Herdr's legacy `herdr-agent-state.ts` or `.js` file (outside a Herdr pane, that legacy file loads normally). If you installed a separate `herdr-atomic-reporter` extension, disable either that extension or `herdr.enabled` in `settings.json` to prevent flickering status updates. See [Herdr setup](/herdr#setup).
242
+
243
+ ## Startup and lazy discovery
244
+
245
+ Built-in [MCP](/mcp-servers), [subagent](/subagents), [web-access](/web-access), and [Intercom](/intercom) commands are available immediately at startup. Their first call may wait for background discovery or connection to finish:
246
+
247
+ - Enabled MCP servers connect in the background at startup. Your first prompt waits up to 10 seconds for servers that expose direct tools.
248
+ - Codemode waits for the MCP namespaces a script names; `searchTools()` and `ALL_TOOLS` wait for all enabled servers. Tool search and resource tools wait for discovery too.
249
+ - `/mcp` manages servers, and `/mcp login`, `/mcp logout`, and `/mcp reconnect` accept an optional server name. If lazy discovery fails, autocomplete falls back to currently known commands.
250
+ - Dropped MCP connections reconnect on the next call, and failed connections can be retried with `/mcp reconnect`. Web-access batches report a tool error when every item fails and keep completed items on partial success.
251
+
252
+ MCP `timeout` is an inactivity limit in seconds (default 60 seconds) that resets on progress rather than a fixed total deadline. See [MCP servers](/mcp-servers) for details.
253
+
254
+ <div id="interactive-callback-isolation" />
255
+
256
+ ## Responsive UI and crash recovery
257
+
258
+ In default interactive mode, Atomic runs extensions in a separate background worker process so slow or stuck extension code does not freeze keyboard input or terminal spinners.
259
+
260
+ ### Cancellation and Ctrl+C safety
261
+
262
+ - **Escape** asks the active turn or tool to cancel cooperatively and waits until it finishes. Escape never kills the worker process, so in-flight tool state is not discarded mid-operation.
263
+ - **Ctrl+C while custom UI is open:**
264
+ - If a `ctx.ui.custom()` component sets `{ handlesCtrlC: true }`, it receives the first `Ctrl+C` press for its own skip, close, or cancel behavior. If the same component still holds input on a second `Ctrl+C`, Atomic closes it so no extension can trap your keyboard.
265
+ - Without `handlesCtrlC: true`, the first `Ctrl+C` closes the component immediately, resolves its `ctx.ui.custom()` promise with `undefined`, and returns focus to the editor while the session keeps running.
266
+ - Set `handlesCtrlC: true` whenever your component displays a `ctrl+c` hint. Built-in selectors, dialogs, input forms, and session pickers handle `Ctrl+C` directly.
267
+
268
+ ```typescript
269
+ await ctx.ui.custom<string | undefined>(
270
+ (tui, theme, keybindings, done) => new PromptCard(tui, theme, done),
271
+ { overlay: true, handlesCtrlC: true },
272
+ );
273
+ ```
274
+
275
+ - **Ctrl+C when the worker is hung:** If the extension worker stops responding, an abort or restart waits longer than one second, or a prior restart failed, `Ctrl+C` terminates and restarts the worker (taking priority over custom UI bindings). Both `Escape` and `Ctrl+C` match physical keys, so rebinding `app.clear` cannot disable recovery.
276
+
277
+ ### Automatic restart and queued messages
278
+
279
+ If the extension worker crashes unexpectedly, Atomic closes open custom UI and attempts one automatic restart. A clean restart stays quiet unless messages were still queued:
280
+
281
+ - Queued main-chat messages return to the editor (steering messages first) with a warning such as `Engine restarted; 2 queued messages weren't sent and are back in the editor`.
282
+ - Queued subagent messages confirmed not yet sent return ahead of any draft in that subagent's editor (immediately if open and writable, or when reopened), or print a notice if the subagent view is read-only. They are never placed into the main chat editor or sent twice.
283
+ - Drafts that never started are restored verbatim; work that already started is not retried automatically. If a saved tool call has no recorded result, reopening the session marks its result unavailable. **Inspect affected files or external systems before retrying because the tool may already have had side effects.**
284
+ - If you spawn child processes from an extension, derive an explicit `env` object from `process.env`; internal startup variables are not exported there.
285
+
286
+ ### UI APIs in default interactive mode
287
+
288
+ Dialogs, `ctx.ui.custom()` components, and widget factories run inside the extension worker and forward rendered output to the terminal. Values returned from `ctx.ui.custom()` must be JSON-serializable.
289
+
290
+ APIs that require synchronous access inside the terminal UI process (`ctx.ui.onTerminalInput`, synchronous `ctx.ui.getEditorText`, `ctx.ui.setEditorComponent`, `ctx.ui.addAutocompleteProvider`, `ctx.ui.setHeader`, and `ctx.ui.setFooter`) do not run in default interactive mode and emit a warning instead. For interactive pickers and structured forms that work natively in default interactive mode, use `ctx.ui.hostSessionPicker()` and `ctx.ui.hostInputForm()`. See [Host-native pickers and forms](/extensions/ui#host-native-pickers-and-forms).
256
291
 
257
292
  ## Moved sections
258
293
 
259
- <a id="writing-an-extension" />
260
- <a id="async-factory-functions" />
261
- <a id="long-lived-resources-and-shutdown" />
262
- <a id="extension-styles" />
263
- <a id="state-management" />
264
- <a id="session-scoped-in-memory-state" />
265
- <a id="custom-tools" />
266
- <a id="tool-definition" />
267
- <a id="constrained-sampling" />
268
- <a id="fireworks-deferred-tool-loading" />
269
- <a id="overriding-built-in-tools" />
270
- <a id="remote-execution" />
271
- <a id="output-truncation" />
272
- <a id="multiple-tools" />
273
- <a id="custom-rendering" />
274
- <a id="tool-rendering" />
275
- <a id="rendercall" />
276
- <a id="renderresult" />
277
- <a id="keybinding-hints" />
278
- <a id="best-practices" />
279
- <a id="fallback" />
280
-
281
- - Extension structure, state management, custom tools, overrides, remote execution, truncation, and custom rendering moved to [Writing extensions](/extensions/authoring).
282
-
283
- <a id="events" />
284
- <a id="lifecycle-overview" />
285
- <a id="startup-events" />
286
- <a id="project_trust" />
287
- <a id="resource-events" />
288
- <a id="resources_discover" />
289
- <a id="session-events" />
290
- <a id="session_start" />
291
- <a id="session_info_changed" />
292
- <a id="session_before_switch" />
293
- <a id="session_before_fork" />
294
- <a id="session_before_compact-/-session_compact-/-session_compact_failed" />
295
- <a id="session_before_tree-/-session_tree" />
296
- <a id="session_shutdown" />
297
- <a id="agent-events" />
298
- <a id="before_agent_start" />
299
- <a id="agent_start-/-agent_end-/-agent_before_settle-/-agent_settled" />
300
- <a id="ui_prompt_start-/-ui_prompt_end" />
301
- <a id="turn_start-/-turn_end" />
302
- <a id="message_start-/-message_update-/-message_end" />
303
- <a id="tool_execution_start-/-tool_execution_update-/-tool_execution_end" />
304
- <a id="context" />
305
- <a id="context_with_system" />
306
- <a id="before_provider_headers" />
307
- <a id="before_provider_request" />
308
- <a id="after_provider_response" />
309
- <a id="model-events" />
310
- <a id="model_select" />
311
- <a id="thinking_level_select" />
312
- <a id="tool-events" />
313
- <a id="tool_call" />
314
- <a id="typing-custom-tool-input" />
315
- <a id="tool_result" />
316
- <a id="user-bash-events" />
317
- <a id="user_bash" />
318
- <a id="input-events" />
319
- <a id="input" />
294
+ <div id="session-scoped-in-memory-state" />
295
+
296
+ <div id="custom-rendering" />
297
+
298
+ - Extension structure, state management, custom tools, overrides, remote execution, truncation, and custom rendering moved to [Write an extension](/extensions/authoring).
299
+
300
+ <div id="before_agent_start" />
301
+
302
+ <div id="message_start--message_update--message_end" />
303
+
304
+ <div id="before_provider_request" />
305
+
306
+ <div id="thinking_level_select" />
307
+
308
+ <div id="tool-call-events" />
309
+
310
+ <div id="user_bash" />
320
311
 
321
312
  - Lifecycle diagrams, event payloads, and return contracts moved to [Extension events](/extensions/events).
322
313
 
323
- <a id="custom-ui" />
324
- <a id="dialogs" />
325
- <a id="timed-dialogs-with-countdown" />
326
- <a id="manual-dismissal-with-abortsignal" />
327
- <a id="widgets-status-and-footer" />
328
- <a id="autocomplete-providers" />
329
- <a id="custom-components" />
330
- <a id="overlay-mode-experimental" />
331
- <a id="custom-editor" />
332
- <a id="message-rendering" />
333
- <a id="theme-colors" />
314
+ <div id="widgets-status-and-footer" />
334
315
 
335
- - Dialogs, widgets, autocomplete providers, custom components, overlays, custom editors, and theme helpers moved to [Extension UI](/extensions/ui).
316
+ <div id="autocomplete-providers" />
336
317
 
337
- <a id="extensioncontext" />
338
- <a id="ctx-ui" />
339
- <a id="ctx-hasui" />
340
- <a id="ctx-cwd" />
341
- <a id="ctx-isprojecttrusted" />
342
- <a id="ctx-sessionmanager" />
343
- <a id="ctx-modelregistry-/-ctx-model-/-ctx-scopedmodels" />
344
- <a id="ctx-signal" />
345
- <a id="ctx-isidle-/-ctx-abort-/-ctx-haspendingmessages" />
346
- <a id="ctx-isprojecttrusted-2" />
347
- <a id="ctx-shutdown" />
348
- <a id="ctx-getcontextusage" />
349
- <a id="ctx-compact" />
350
- <a id="ctx-getsystemprompt" />
351
- <a id="ctx-getskillcatalog" />
352
- <a id="extensioncommandcontext" />
353
- <a id="ctx-waitforidle" />
354
- <a id="ctx-newsession-options" />
355
- <a id="ctx-fork-entryid-options" />
356
- <a id="ctx-navigatetree-targetid-options" />
357
- <a id="ctx-switchsession-sessionid-options" />
358
- <a id="session-replacement-lifecycle-and-footguns" />
359
- <a id="ctx-reload" />
360
- <a id="extensionapi-methods" />
361
- <a id="pi-on-event-handler" />
362
- <a id="pi-registertool-definition" />
363
- <a id="built-in-tool-prompt-contributions" />
364
- <a id="pi-sendmessage-message-options" />
365
- <a id="pi-sendmessages-messages-options" />
366
- <a id="pi-sendusermessage-content-options" />
367
- <a id="pi-appendentry-customtype-data" />
368
- <a id="pi-registerentryrenderer-customtype-renderer" />
369
- <a id="pi-setsessionname-name" />
370
- <a id="pi-getsessionname" />
371
- <a id="pi-setlabel-entryid-label" />
372
- <a id="pi-registercommand-name-options" />
373
- <a id="pi-getcommands" />
374
- <a id="pi-registermessagerenderer-customtype-renderer" />
375
- <a id="pi-registermarkdowntransformer-transformer" />
376
- <a id="pi-registershortcut-shortcut-options" />
377
- <a id="pi-registerflag-name-options" />
378
- <a id="pi-registeragentpanelsource-source" />
379
- <a id="pi-exec-command-args-options" />
380
- <a id="pi-getactivetools-/-pi-getalltools-/-pi-setactivetools-names" />
381
- <a id="pi-setmodel-model" />
382
- <a id="pi-getthinkinglevel-/-pi-setthinkinglevel-level" />
383
- <a id="pi-events" />
384
- <a id="native-providers" />
385
- <a id="pi-registerprovider-name-config" />
386
- <a id="pi-unregisterprovider-name" />
387
- <a id="pi-registermcpserver-name-config" />
388
- <a id="error-handling" />
318
+ - Dialogs, widgets, autocomplete providers, custom components, overlays, custom editors, and theme helpers moved to [Extension UI](/extensions/ui).
389
319
 
390
- - `ExtensionContext`, `ExtensionCommandContext`, `ExtensionAPI` methods, and error handling moved to [Extension API reference](/extensions/api-reference).
320
+ <div id="ctxsignal" />
391
321
 
392
- <a id="examples-reference" />
322
+ <div id="pigetcommands" />
393
323
 
394
- - Runnable extension examples moved to [Extension examples](/extensions/examples).
324
+ - `ExtensionContext`, `ExtensionCommandContext`, `ExtensionAPI` methods, and error handling moved to [Extension API reference](/extensions/api-reference).