@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,61 +1,63 @@
1
1
  ---
2
- title: Extension events
3
- description: Every extension event, its payload, and its return contract.
2
+ title: "Extension events"
3
+ sidebarTitle: "Events"
4
+ description: "Reference for extension lifecycle events, payloads, handler chaining rules, and return contracts."
4
5
  ---
5
6
 
6
- # Extension events
7
+ <div id="events" />
7
8
 
8
- ## Events
9
+ Subscribe to lifecycle events with `atomic.on(event, handler)`. Every `atomic.on()` call returns an unsubscribe function `() => void` if you need to detach a listener before reload or shutdown.
9
10
 
10
- ### Lifecycle overview
11
+ ## Lifecycle overview
11
12
 
12
- Interactive trust-gated startup first emits `session_start` and `resources_discover` for the permitted trust-safe extensions, then resolves `project_trust`. After authorization, newly loaded extensions receive `session_start`, and resource discovery runs again against the completed set.
13
+ When interactive startup needs to ask whether you trust a project, user, global, and CLI `-e` extensions start first (receiving `session_start` and `resources_discover`) so they can participate in `project_trust` and display UI. After trust is granted, project extensions load, receive `session_start`, and `resources_discover` runs again for the full set.
13
14
 
14
- A `resources_discover` handler that fails both times with the same error is reported once. Different handlers are reported separately, even if they throw the same message or share a display name. Existing reporters keep their session and do not receive a second `session_start`. Noninteractive startup resolves trust before the ordinary session lifecycle.
15
+ A `resources_discover` handler that fails both passes with the same error is reported once. Different handlers are reported separately even if they throw the same message. Extensions already started during the first pass keep their session and do not receive a second `session_start`. Non-interactive startup resolves trust before running the normal lifecycle.
15
16
 
16
- ```
17
+ ```text
17
18
  Atomic starts
18
19
  │
19
- ├─► session_start / resources_discover (trust-safe interactive bootstrap, when needed)
20
- ├─► project_trust (user/global and CLI extensions only, before project resources load)
21
- ├─► session_start { reason: "startup" } (extensions not already started)
20
+ ├─► session_start / resources_discover (user/global and CLI -e extensions when trust is needed)
21
+ ├─► project_trust (user/global and CLI -e extensions only, before project resources load)
22
+ ├─► session_start { reason: "startup" } (remaining extensions)
22
23
  ├─► resources_discover { reason: "startup" }
23
24
  └─► after the transcript renders: session_recovery_restore / session_recovery_replay
24
25
  │
25
26
  ▼
26
27
  user sends prompt ─────────────────────────────────────────┐
27
28
  │ │
28
- ├─► (extension commands checked first, bypass if found) │
29
+ ├─► (extension commands checked first; bypass if found) │
29
30
  ├─► input (can intercept, transform, or handle) │
30
31
  ├─► (skill/template expansion if not handled) │
31
- ├─► before_agent_start (can inject message, modify system prompt)
32
+ ├─► before_agent_start (can inject message, adjust prompt)
32
33
  ├─► agent_start │
33
34
  ├─► message_start / message_update / message_end │
34
35
  │ │
35
- │ ┌─── turn (repeats while LLM calls tools) ───┐ │
36
+ │ ┌─── turn (repeats while model calls tools) ─┐ │
36
37
  │ │ │ │
37
38
  │ ├─► turn_start │ │
38
- │ ├─► context (can modify conversation messages) │
39
- │ ├─► context_with_system (can modify the full transcript)
40
- │ ├─► before_provider_request (can inspect or replace payload)
41
- │ ├─► after_provider_response (status + headers, before stream consume)
42
- │ ├─► provider_stream_event (each parsed provider event, before normalization)
39
+ │ ├─► context (modify conversation messages) │ │
40
+ │ ├─► context_with_system (modify full list) │ │
41
+ │ ├─► before_provider_headers (mutate headers) │ │
42
+ │ ├─► before_provider_request (edit payload) │ │
43
+ │ ├─► after_provider_response (status+headers) │ │
44
+ │ ├─► provider_stream_event (raw chunk events) │ │
43
45
  │ │ │ │
44
- │ │ LLM responds, may call tools: │ │
46
+ │ │ Model responds, may call tools: │ │
45
47
  │ │ ├─► tool_execution_start │ │
46
- │ │ ├─► tool_call (can block) │ │
48
+ │ │ ├─► tool_call (can block or patch) │ │
47
49
  │ │ ├─► tool_execution_update │ │
48
- │ │ ├─► tool_result (can modify) │ │
50
+ │ │ ├─► tool_result (can modify result) │ │
49
51
  │ │ └─► tool_execution_end │ │
50
52
  │ │ │ │
51
- │ ├─► turn_end (can append entries and continue) │
52
- │ └─► post-tool threshold preflight │ │
53
- │ (may compact before the next provider request) │
53
+ │ ├─► turn_end (can append entries & continue) │ │
54
+ │ └─► context-size check after tool results │ │
55
+ │ (may compact before next model request) │ │
54
56
  ├─► agent_end │
55
- ├─► retry backoff or final-attempt recovery (when selected)
57
+ ├─► retry backoff or final-attempt recovery (when needed)│
56
58
  │ └─► fresh agent_start on successful recovery │
57
- ├─► agent_before_settle (can append entries and continue)│
58
- └─► agent_settled (final, notification only) │
59
+ ├─► agent_before_settle (append entries & continue) │
60
+ └─► agent_settled (final, notification-only) │
59
61
  │
60
62
  user sends another prompt ◄────────────────────────────────┘
61
63
 
@@ -75,7 +77,6 @@ user sends another prompt ◄─────────────────
75
77
  └─► resources_discover { reason: "startup" }
76
78
 
77
79
  /compact or auto-compaction
78
- ├─► compaction_start / compaction_end (compaction status)
79
80
  ├─► session_before_compact (can cancel or provide compactedText)
80
81
  ├─► session_compact (after the compaction boundary is persisted)
81
82
  └─► session_compact_failed (failure or cancellation)
@@ -85,45 +86,45 @@ user sends another prompt ◄─────────────────
85
86
  └─► session_tree
86
87
 
87
88
  /model or CTRL+P (model selection/cycling)
88
- ├─► thinking_level_select (if model change changes/clamps thinking level)
89
+ ├─► thinking_level_select (if model change clamps thinking level)
89
90
  └─► model_select
90
91
 
91
92
  thinking level changes (settings, keybinding, atomic.setThinkingLevel())
92
93
  └─► thinking_level_select
93
94
 
94
95
  prompt cache warming (when enabled)
95
- └─► cache_warming_decision (can return `{ action: "warm" | "stop" }`)
96
+ └─► cache_warming_decision (can return { action: "warm" | "stop" })
96
97
 
97
98
  exit (CTRL+C, CTRL+D, SIGHUP, SIGTERM)
98
99
  └─► session_shutdown
99
100
  ```
100
101
 
101
- ### Startup events
102
+ ## Startup events
102
103
 
103
- #### project_trust
104
+ ### project_trust
104
105
 
105
- Fired before Atomic decides whether to trust a project with dynamic configs (`.atomic`, legacy `.pi`, or `.agents/skills`). It runs during startup and when session replacement (for example `/resume`) enters a working directory whose trust has not been resolved in the current process. Only user or global extensions and CLI `-e` extensions participate; project-local extensions load only after trust is resolved.
106
+ Fired before Atomic decides whether to trust a project with local configuration (`.atomic`, legacy `.pi`, or `.agents/skills`). Runs during startup and when switching sessions (such as `/resume`) enters a working directory whose trust has not been resolved in this process. Only user, global, and CLI `-e` extensions participate because project extensions load after trust is granted.
106
107
 
107
108
  ```typescript
108
109
  atomic.on("project_trust", async (event, ctx) => {
109
110
  // event.cwd - current working directory
110
111
  // ctx has a limited trust context: cwd, mode, hasUI, and select/confirm/input/notify UI helpers
111
- if (ctx.hasUI && await ctx.ui.confirm("Trust project?", event.cwd)) {
112
+ if (ctx.hasUI && (await ctx.ui.confirm("Trust project?", event.cwd))) {
112
113
  return { trusted: "yes", remember: true };
113
114
  }
114
115
  return { trusted: "undecided" };
115
116
  });
116
117
  ```
117
118
 
118
- A `project_trust` handler must return `{ trusted: "yes" | "no" | "undecided" }`. The first yes or no decision from a user, global, or CLI extension wins and suppresses the built-in trust prompt. Set `remember: true` to persist the decision; otherwise it applies only to the current process.
119
+ A `project_trust` handler must return `{ trusted: "yes" | "no" | "undecided" }`. The first `"yes"` or `"no"` decision wins and suppresses the built-in trust prompt. Set `remember: true` to persist the decision; otherwise it applies to the current process only.
119
120
 
120
- Return `"undecided"` to let later handlers or the built-in trust flow decide, and check `ctx.hasUI` before prompting. If no handler returns yes or no, saved `trust.json` decisions apply first, then `defaultProjectTrust` decides whether Atomic asks, trusts, or declines.
121
+ Return `"undecided"` to pass control to later handlers or Atomic's built-in trust flow, and check `ctx.hasUI` before prompting. If no handler decides, saved `trust.json` decisions apply first, then `defaultProjectTrust` decides whether Atomic asks, trusts, or declines.
121
122
 
122
- ### Resource events
123
+ ## Resource events
123
124
 
124
- #### resources_discover
125
+ ### resources_discover
125
126
 
126
- Fired after `session_start` so extensions can contribute additional skill, prompt, and theme paths. Startup uses `reason: "startup"`, and `/reload` uses `reason: "reload"`.
127
+ Fired after `session_start` so extensions can contribute skill, prompt template, and theme paths. Startup passes `reason: "startup"`; `/reload` passes `reason: "reload"`.
127
128
 
128
129
  ```typescript
129
130
  atomic.on("resources_discover", async (event, _ctx) => {
@@ -137,67 +138,78 @@ atomic.on("resources_discover", async (event, _ctx) => {
137
138
  });
138
139
  ```
139
140
 
140
- ### Session events
141
+ ## Session events
141
142
 
142
143
  See [Session format](/session-format) for session storage details and the `SessionManager` API.
143
144
 
144
- #### session_start
145
+ For all cancellable `session_before_*` events (`session_before_switch`, `session_before_fork`, `session_before_compact`, `session_before_tree`), the **first** handler returning `{ cancel: true }` immediately short-circuits remaining handlers and cancels the action. Otherwise, the last non-empty result wins.
146
+
147
+ ### session_start
145
148
 
146
- Fired when a session is started, loaded, or reloaded.
149
+ Fired when a session starts, reloads, switches, or forks.
147
150
 
148
151
  ```typescript
149
152
  atomic.on("session_start", async (event, ctx) => {
150
153
  // event.reason - "startup" | "reload" | "new" | "resume" | "fork"
151
154
  // event.previousSessionId - present for "new", "resume", and "fork"
155
+ // event.engineRestart - true only when a crashed interactive worker process restarted
152
156
  ctx.ui.notify(`Session: ${ctx.sessionManager.getSessionId()}`, "info");
153
157
  });
154
158
  ```
155
159
 
156
- If the handler throws, the interactive terminal shows the error with the extension's path and keeps the session; print mode, RPC mode and SDK sessions fail startup instead. See [Error Handling](/extensions/api-reference#error-handling).
160
+ If a handler throws, interactive mode shows the error with the extension's path and keeps the session open; print mode, RPC mode, and SDK sessions fail startup instead. See [Error handling](/extensions/api-reference#error-handling).
161
+
162
+ ### session_recovery_restore / session_recovery_replay
157
163
 
158
- #### session_recovery_restore / session_recovery_replay
164
+ Fired once per session when recovering unfinished work from an earlier process. Interactive mode runs them after the transcript renders; SDK and RPC hosts run them when calling `session.startPendingRecovery()` or sending `start_pending_recovery`.
159
165
 
160
- Fired once per session when the host recovers work an earlier process left unfinished. The interactive host does this after the transcript is visible. SDK and RPC hosts do it when they call `session.startPendingRecovery()` or send `start_pending_recovery`. Startup binding never fires them.
166
+ `session_recovery_restore` runs first so extensions can restore background work such as child agents. It receives `event.reason` (`"startup" | "resume"`) and `event.engineRestart` (`true` when triggered after an automatic worker restart).
161
167
 
162
- `session_recovery_restore` comes first. Restore background work here, such as child agents.
168
+ `session_recovery_replay` follows only when delivery cards shown before exit never reached the model. Each decision in `decisions` takes `{ entryId, action }`, where `action` is:
163
169
 
164
- `session_recovery_replay` follows, but only when delivery cards that were shown before the exit never reached the model. Return a `drop` decision for each card whose sender or target no longer exists; the card is closed and never offered again. Return `defer` when you cannot tell yet, for example because the peer's service is unreachable: the card stays pending without a turn, and the next recovery of the session offers it again. If handlers disagree, `drop` wins over `defer`. Cards with no decision are replayed in a visible turn.
170
+ - `"replay"`: explicitly deliver the pending card in a visible turn (also the default when no handler returns a decision for that card).
171
+ - `"drop"`: permanently close a card whose sender or target no longer exists.
172
+ - `"defer"`: leave the card pending without starting a turn so the next recovery offers it again (useful when a peer service is unreachable).
165
173
 
166
- Notices from either event go into one message for the user and the agent. That message never starts a turn.
174
+ If handlers disagree on the same card, `"drop"` wins over `"defer"`. Notices returned from either event combine into one non-triggering message for the user and model.
167
175
 
168
176
  ```typescript
169
- atomic.on("session_recovery_restore", async (event, ctx) => {
177
+ atomic.on("session_recovery_restore", async (event) => {
170
178
  // event.reason - "startup" | "resume"
179
+ // event.engineRestart - true after a worker restart
171
180
  return { notices: ["Worker reviewer could not be restored and is gone."] };
172
181
  });
173
182
 
174
- atomic.on("session_recovery_replay", async (event, ctx) => {
183
+ atomic.on("session_recovery_replay", async (event) => {
175
184
  // event.pending - [{ entryId, customType, content, details, timestamp, stageAdmissionKey?, delivery }]
176
- const stale = event.pending.filter((entry) => entry.customType === "my-extension:worker-note");
177
- return { decisions: stale.map((entry) => ({ entryId: entry.entryId, action: "drop" })) };
185
+ return {
186
+ decisions: event.pending.map((entry) => ({
187
+ entryId: entry.entryId,
188
+ action: entry.customType === "my-extension:stale" ? "drop" : "replay",
189
+ })),
190
+ };
178
191
  });
179
192
  ```
180
193
 
181
- #### session_info_changed
194
+ ### session_info_changed
182
195
 
183
- Fired when the current session display name is set via `/name`, RPC, or `atomic.setSessionName()`.
196
+ Fired when the session display name changes via `/name`, RPC, or `atomic.setSessionName()`.
184
197
 
185
198
  ```typescript
186
199
  atomic.on("session_info_changed", async (event, ctx) => {
187
- // event.name - current normalized name, or undefined if cleared
200
+ // event.name - normalized name, or undefined if cleared
188
201
  ctx.ui.notify(`Session renamed: ${event.name ?? "(none)"}`, "info");
189
202
  });
190
203
  ```
191
204
 
192
- #### session_before_switch
205
+ ### session_before_switch
193
206
 
194
- Fired before starting a new session (`/new`) or switching sessions (`/resume`).
207
+ Fired before `/new` or `/resume`. The first handler returning `{ cancel: true }` stops the switch and skips later handlers.
195
208
 
196
209
  ```typescript
197
210
  atomic.on("session_before_switch", async (event, ctx) => {
198
- // event.reason - "new" or "resume"
199
- // event.targetSessionId - session we're switching to (only for "resume")
200
-
211
+ // event.reason - "new" | "resume"
212
+ // event.targetSessionId - destination session ID (only for "resume")
201
213
  if (event.reason === "new") {
202
214
  const ok = await ctx.ui.confirm("Clear?", "Delete all messages?");
203
215
  if (!ok) return { cancel: true };
@@ -205,54 +217,47 @@ atomic.on("session_before_switch", async (event, ctx) => {
205
217
  });
206
218
  ```
207
219
 
208
- After a successful switch or new-session action, Atomic emits `session_shutdown` for the old extension instance, reloads and rebinds extensions for the new session, then emits `session_start` with `reason: "new" | "resume"` and `previousSessionId`.
209
- Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `session_start`.
220
+ After a successful switch, Atomic emits `session_shutdown` for the previous instance, reloads extensions for the new session, and emits `session_start` with `reason: "new" | "resume"` and `previousSessionId`.
210
221
 
211
- #### session_before_fork
222
+ ### session_before_fork
212
223
 
213
- Fired when forking via `/fork` or cloning via `/clone`.
224
+ Fired before `/fork` or `/clone`. The first handler returning `{ cancel: true }` cancels the action and skips later handlers.
214
225
 
215
226
  ```typescript
216
- atomic.on("session_before_fork", async (event, ctx) => {
227
+ atomic.on("session_before_fork", async (event) => {
217
228
  // event.entryId - ID of the selected entry
218
229
  // event.position - "before" for /fork, "at" for /clone
219
- return { cancel: true }; // Cancel fork/clone
220
- // OR
221
- return { skipConversationRestore: true }; // Reserved for future conversation restore control
230
+ return { cancel: true };
231
+ // Or: return { skipConversationRestore: true };
222
232
  });
223
233
  ```
224
234
 
225
- After a successful fork or clone, Atomic emits `session_shutdown` for the old extension instance, reloads and rebinds extensions for the new session, then emits `session_start` with `reason: "fork"` and `previousSessionId`.
226
- Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `session_start`.
235
+ After a successful fork or clone, Atomic emits `session_shutdown`, reloads extensions for the new session, and emits `session_start` with `reason: "fork"` and `previousSessionId`.
227
236
 
228
- #### session_before_compact / session_compact / session_compact_failed
237
+ ### session_before_compact / session_compact / session_compact_failed
229
238
 
230
- Fired by `/compact` and auto-compaction, including a threshold crossing detected after tool results enter the prospective next-turn context. Atomic prepares everything in context since the last boundary.
239
+ Fired by `/compact` and automatic compaction, including when tool output pushes the prospective next-turn context past the threshold. Atomic prepares all context since the last compaction boundary.
231
240
 
232
- Extensions can cancel compaction or return a `compactedText` replacement. When you provide `compactedText`, the model sees that text in a `Context compacted` message followed by instructions for recovering the rest from session history, and Atomic does not call the configured compactor. Empty or whitespace-only text counts as no replacement, so the configured form runs instead.
241
+ Handlers on `session_before_compact` can cancel compaction (`{ cancel: true }`, short-circuiting later handlers) or return `{ compactedText }`. When `compactedText` is provided, Atomic skips the configured compactor and inserts that text verbatim into a `Context compacted` boundary message followed by history recovery instructions. Empty or whitespace-only text counts as no replacement.
233
242
 
234
- Text over the compactor's output limit, or too long to fit below the automatic trigger with the system prompt and recovery instructions, clears the context instead. The replacement is saved verbatim and works without provider credentials. A successful post-tool compaction returns its rebuilt context directly to the already-active agent loop without starting a separate continuation. Cancellation or failure stops that loop's follow-up provider request.
243
+ If replacement text exceeds the compactor's output limit or still exceeds the automatic trigger together with the system prompt and recovery instructions, Atomic clears the context instead. A successful post-tool compaction feeds its rebuilt context directly into the active turn loop; cancellation or failure stops the follow-up model request.
235
244
 
236
245
  ```typescript
237
246
  atomic.on("session_before_compact", async (event) => {
238
247
  const { preparation, branchEntries, parameters, reason, signal } = event;
239
-
240
- // preparation.region.lines - the context since the last boundary, as role-tagged lines
241
- // preparation.firstKeptEntryId - always null: no earlier message stays in context
248
+ // preparation.region.lines - role-tagged lines since the last boundary (deep-frozen)
249
+ // preparation.firstKeptEntryId - always null
242
250
  // preparation.tokensBefore - whole-context token estimate
243
- // parameters.query - the /compact instructions, or the latest user request
251
+ // parameters.query - /compact instructions or latest user request
244
252
  // branchEntries - raw entries on the active branch
245
253
  // reason - "manual" | "threshold" | "overflow"
246
- // preparation is a deep-frozen clone
247
254
 
248
255
  if (signal.aborted) return { cancel: true };
249
256
 
250
- // Cancel compaction:
251
- return { cancel: true };
252
-
253
- // Or replace the context with your own text. Whitespace-only text is no replacement.
254
257
  return {
255
- compactedText: preparation.region.lines.filter((line) => line.startsWith("[User]: ")).join("\n"),
258
+ compactedText: preparation.region.lines
259
+ .filter((line) => line.startsWith("[User]: "))
260
+ .join("\n"),
256
261
  };
257
262
  });
258
263
 
@@ -260,154 +265,148 @@ atomic.on("session_compact", async (event) => {
260
265
  // event.result - VerbatimCompactionResult (compactedText, form, backend, model, fallbackReason, history, stats)
261
266
  // event.compactionEntry - saved CompactionEntry with strategy "verbatim-lines"
262
267
  // event.fromExtension - true when session_before_compact provided compactedText
263
- // Observe-only: errors are isolated after persistence.
268
+ // Notification-only: handler errors are logged and do not affect the saved compaction.
264
269
  });
265
270
 
266
271
  atomic.on("session_compact_failed", async (event) => {
267
272
  // event.reason - "manual" | "threshold" | "overflow"
268
- // event.errorMessage - absent for cancellation
273
+ // event.errorMessage - absent on cancellation
269
274
  // event.aborted / event.willRetry - terminal state
270
275
  // event.fromExtension - whether extension-provided text was active
271
276
  });
272
277
  ```
273
278
 
274
- #### session_before_tree / session_tree
275
-
276
- When a user navigates with `/tree`, `session_before_tree` receives the real entries of the abandoned branch segment in `event.preparation.entriesToSummarize`, even if the user did not request a summary. This is a temporary exception to the context-window limit for an explicit navigation with a handler or summarizer. Without either, Atomic does not load that segment. The manager does not retain those entries after navigation; if your extension keeps the array, it owns that memory.
279
+ ### session_before_tree / session_tree
277
280
 
278
281
  Fired on `/tree` navigation. See [Sessions](/sessions) for tree navigation concepts.
279
282
 
283
+ When a handler is registered or summarization is requested, `event.preparation.entriesToSummarize` contains the entries of the abandoned branch segment (even when `userWantsSummary` is `false`). Atomic releases that array after navigation; if your extension retains a reference, it owns that memory.
284
+
280
285
  ```typescript
281
- atomic.on("session_before_tree", async (event, ctx) => {
286
+ atomic.on("session_before_tree", async (event) => {
282
287
  const { preparation, signal } = event;
283
- return { cancel: true };
284
- // OR provide custom summary:
285
- return { summary: { summary: "...", details: {} } };
288
+ // preparation.targetId - destination entry ID
289
+ // preparation.oldLeafId - leaf ID before navigation
290
+ // preparation.commonAncestorId - shared ancestor entry ID
291
+ // preparation.entriesToSummarize - entries leaving the active branch
292
+ // preparation.userWantsSummary - whether the user requested a branch summary
293
+ // preparation.customInstructions / preparation.replaceInstructions / preparation.label
294
+
295
+ if (signal.aborted) return { cancel: true };
296
+
297
+ // Cancel navigation:
298
+ // return { cancel: true };
299
+
300
+ // Customize summary prompt or label without replacing summarization:
301
+ // return { customInstructions: "Keep API contract decisions", replaceInstructions: false, label: "branch-cut" };
302
+
303
+ // Or supply a custom summary directly:
304
+ return { summary: { summary: "Explored approach A; switched to B.", details: {} }, label: "approach-a" };
286
305
  });
287
306
 
288
- atomic.on("session_tree", async (event, ctx) => {
289
- // event.newLeafId, oldLeafId, summaryEntry, fromExtension
307
+ atomic.on("session_tree", async (event) => {
308
+ // event.newLeafId, event.oldLeafId, event.summaryEntry, event.fromExtension
290
309
  });
291
310
  ```
292
311
 
293
- #### session_shutdown
312
+ ### session_shutdown
294
313
 
295
- Fired before a started session runtime is torn down. Use this to clean up resources opened from `session_start` or other session-scoped hooks.
314
+ Fired before a started session shuts down, reloads, switches, or forks. Close background resources opened in `session_start` here.
296
315
 
297
316
  ```typescript
298
- atomic.on("session_shutdown", async (event, ctx) => {
317
+ atomic.on("session_shutdown", async (event) => {
299
318
  // event.reason - "quit" | "reload" | "new" | "resume" | "fork"
300
- // event.targetSessionId - destination session for session replacement flows
301
- // event.fromSignal - true when a "quit" came from a host SIGTERM/SIGHUP, not an explicit quit
302
- // Cleanup, save state, etc.
319
+ // event.targetSessionId - destination session ID on switches or forks
320
+ // event.fromSignal - true when "quit" came from SIGTERM/SIGHUP rather than explicit quit
303
321
  });
304
322
  ```
305
323
 
306
- `fromSignal` is set only on `reason: "quit"`. Ctrl+D and `/quit` leave it unset. Use it to distinguish a deliberate exit from the host stopping the process, for example to keep externally registered state that a restart can resume from.
324
+ `fromSignal` is set only when `reason === "quit"` came from an OS signal (`SIGTERM`, `SIGHUP`, or terminal close); `Ctrl+D` and `/quit` leave it unset.
307
325
 
308
- When you quit the interactive app, `session_shutdown` handlers have about five seconds to finish before the rest of the session stops. The same applies with `fromSignal: true` when Atomic receives `SIGTERM` or `SIGHUP` or its terminal window closes on Linux or macOS; a second `SIGTERM` stops the session immediately.
326
+ Handlers have about 5 seconds to finish on Linux and macOS quit or signal shutdown (a second `SIGTERM` exits immediately), and about 4 seconds on Windows console close or OS shutdown after startup finishes. Any running [`atomic.exec`](/extensions/api-reference#atomic-exec-command-args-options) command is stopped first so it cannot block shutdown handlers.
309
327
 
310
- Closing the console window on Windows gives handlers about four seconds before Windows ends the process, and processes started on that console (such as MCP servers) may already have ended. Signing out of Windows, or restarting or shutting it down, also gives handlers about four seconds once Atomic has finished starting up; before that, Windows ends Atomic without running `session_shutdown`.
328
+ ## Agent events
311
329
 
312
- A signal that arrives while a quit is already shutting down joins that shutdown instead of ending Atomic immediately; only a second `SIGTERM` forces an immediate exit. Any [`atomic.exec`](/extensions/api-reference#atomic-exec-command-args-options) command still running when you quit is stopped first so it cannot hold up shutdown handlers.
330
+ ### before_agent_start
313
331
 
314
- ### Agent events
332
+ Fired before a run starts from a user prompt or from `atomic.sendMessage(..., { triggerTurn: true })` while idle. Multiple handlers returning `message` all inject their messages in extension load order. Returning `systemPrompt` updates `systemPromptOptions.forceSystemPrompt` (last handler wins), while `event.systemPrompt` and `ctx.getSystemPrompt()` update live for each subsequent handler.
315
333
 
316
- #### before_agent_start
317
-
318
- Fired before a run starts from a user prompt or from `atomic.sendMessage(..., { triggerTurn: true })` while idle. Can inject a message and/or modify the system prompt for the whole run, including requests after tool calls. Messages sent while this hook runs join the starting run rather than starting a second run.
319
-
320
- Check `event.messageType` before reading the starting input. A `"user"` event has `prompt` and optional `images`; a `"custom"` event has `message`, the custom message that started the run. Existing handlers that read `event.prompt` or `event.images` should first narrow to `event.messageType === "user"`.
334
+ Always check `event.messageType` before reading the trigger payload: `"user"` events carry `prompt` and optional `images`, while `"custom"` events carry `message`.
321
335
 
322
336
  ```typescript
323
- atomic.on("before_agent_start", async (event, ctx) => {
337
+ atomic.on("before_agent_start", async (event) => {
324
338
  if (event.messageType === "user") {
325
- // event.prompt - user's prompt text
326
- // event.images - attached images (if any)
339
+ // event.prompt, event.images
327
340
  } else {
328
- // event.message - starting custom message
341
+ // event.message (starting custom message)
329
342
  }
330
- // event.systemPrompt - current chained system prompt for this handler
331
- // (includes changes from earlier before_agent_start handlers)
332
- // event.systemPromptOptions - structured options used to build the system prompt
333
- // .customPrompt - prompt prefix from --system-prompt, SYSTEM.md, or custom templates
334
- // .forceSystemPrompt - optional exact replacement for the complete prompt
335
- // .selectedTools - tools currently active in the prompt
336
- // .toolSnippets - one-line descriptions for each tool
337
- // .toolGuidelines - guideline bullets keyed by tool name
338
- // .sections - custom XML-wrapped sections keyed by tag name
339
- // .promptGuidelines - custom guideline bullets
340
- // .appendSystemPrompt - text from --append-system-prompt flags
341
- // .cwd - working directory
342
- // .contextFiles - AGENTS.md files and other loaded context files
343
- // .skills - loaded skills
343
+ // event.systemPrompt - chained system prompt so far
344
+ // event.systemPromptOptions - mutable BuildSystemPromptOptions:
345
+ // customPrompt, forceSystemPrompt, selectedTools, toolSnippets, toolGuidelines,
346
+ // sections, promptGuidelines, appendSystemPrompt, cwd, contextFiles, skills
344
347
 
345
348
  return {
346
- // Inject a persistent message (stored in session, sent to LLM)
347
349
  message: {
348
350
  customType: "my-extension",
349
- content: "Additional context for the LLM",
351
+ content: "Additional context for the model",
350
352
  display: true,
351
353
  },
352
- // Replace the system prompt for this turn (chained across extensions)
353
- systemPrompt: event.systemPrompt + "\n\nExtra instructions for this turn...",
354
+ systemPrompt: `${event.systemPrompt}\n\nExtra instructions for this run.`,
354
355
  };
355
356
  });
356
357
  ```
357
358
 
358
- The `systemPromptOptions` collections are mutable. Prefer editing `sections`, `selectedTools`, or `promptGuidelines`: Atomic records only changed prompt sections and tool declarations as chronological system messages. Editing `selectedTools`, or calling `atomic.setActiveTools()` inside the handler, changes the same request's executable tools as well as their prompt contributions.
359
-
360
- Returning `systemPrompt`, or setting `forceSystemPrompt`, replaces the complete provider prompt for the run without recording the forced text. The transcript still records structured sections. Models supporting mid-conversation system messages receive patches in place; other models receive the replayed leading prompt. A forced replacement or unsupported tool transition can invalidate the cached prefix.
361
-
362
- Inside `before_agent_start`, `event.systemPrompt` and `ctx.getSystemPrompt()` both reflect the chained system prompt as of the current handler. Later `before_agent_start` handlers can still modify it again.
363
-
364
- #### agent_start / agent_end / agent_before_settle / agent_settled
359
+ Prefer mutating `event.systemPromptOptions.sections`, `selectedTools`, or `promptGuidelines` instead of returning a full `systemPrompt` override so prompt caching stays intact. Editing `selectedTools` or calling `atomic.setActiveTools()` here applies to the same run's executable tools as well as its prompt text.
365
360
 
366
- `agent_start` begins a low-level run. `agent_end` fires when that run ends, but Atomic may still retry, compact and retry, or deliver queued follow-ups. `agent_before_settle` is the final actionable boundary: it can append session entries and request one continuation. `agent_settled` is final and notification-only; use it when a status integration needs to know Atomic has no automatic continuation left, including a chain of repeated output-cap continuations. Silence during a provider request or between these runs is not settlement.
361
+ ### agent_start / agent_end / agent_before_settle / agent_settled
367
362
 
368
- `agent_settled` includes `aborted: true` when the prompt was cancelled, including cancellation during `agent_before_settle`. Otherwise it is `false`. Use this field to distinguish cancellation from normal completion; an aborted prompt still emits the final settlement notification.
363
+ - `agent_start` marks the start of one low-level model run.
364
+ - `agent_end` marks the end of that run (Atomic may still retry, compact and retry, or deliver queued follow-ups).
365
+ - `agent_before_settle` is the final actionable boundary before going idle: handlers can append entries and request one continuation (`continue: true`).
366
+ - `agent_settled` is final and notification-only, with `event.aborted: boolean` (`true` if cancelled, including during `agent_before_settle`).
369
367
 
370
368
  ```typescript
371
- atomic.on("agent_start", async (_event, ctx) => {});
372
- atomic.on("agent_end", async (event, ctx) => {
373
- // event.messages - messages from this low-level run
369
+ atomic.on("agent_start", async () => {});
370
+ atomic.on("agent_end", async (event) => {
371
+ // event.messages - messages produced in this run
374
372
  });
375
373
 
376
374
  let addedReviewReminder = false;
377
- atomic.on("agent_before_settle", async (event, ctx) => {
375
+ atomic.on("agent_before_settle", async (event) => {
378
376
  if (addedReviewReminder) return;
379
377
  addedReviewReminder = true;
380
378
  return {
381
- entries: [...event.entries, {
382
- type: "custom_message",
383
- customType: "review-reminder",
384
- content: "Review the final diff before replying.",
385
- display: false,
386
- }],
379
+ entries: [
380
+ ...event.entries,
381
+ {
382
+ type: "custom_message",
383
+ customType: "review-reminder",
384
+ content: "Review the final diff before replying.",
385
+ display: false,
386
+ },
387
+ ],
387
388
  continue: true,
388
389
  };
389
390
  });
390
391
 
391
- atomic.on("agent_settled", async (_event, ctx) => {
392
- // ctx.isIdle() is true; runs requested here start after all settled handlers finish.
392
+ atomic.on("agent_settled", async (event, ctx) => {
393
+ // event.aborted - true when cancelled
394
+ // ctx.isIdle() is true; any new prompt started here waits until all agent_settled handlers finish.
393
395
  });
394
396
  ```
395
397
 
396
- If the run is aborted while `agent_before_settle` handlers are running, valid returned entries are still committed, but requested continuation is suppressed. Work requested from `agent_settled` is deferred until every settled handler completes, so notification dispatch is non-reentrant. Input sent from an `agent_before_settle` handler with `deliverAs: "steer"` or `"followUp"` queues for the requested continuation instead of starting a second run.
398
+ If aborted during `agent_before_settle`, valid entries still persist while `continue: true` is suppressed. Input queued from `agent_before_settle` with `deliverAs: "steer"` or `"followUp"` joins the requested continuation instead of starting a second run.
397
399
 
398
- Each provider request is built from the persisted session after every queued handler for the events before it (`agent_start`, `turn_start`, `message_start`, `message_end`, `tool_execution_*`) has finished, because a `message_end` handler may replace the message that gets persisted. Handlers run without blocking the event that triggered them, but a handler that waits for something later in the same run, such as the provider's response, stalls that run; wait in `agent_end` or `agent_settled` instead.
400
+ Each provider request builds from the persisted session after earlier event handlers (`agent_start`, `turn_start`, `message_start`, `message_end`, `tool_execution_*`) settle, because `message_end` can modify a saved message. Do not await something later in the same run inside one of those handlers; wait in `agent_end` or `agent_settled` instead.
399
401
 
400
- #### ui_prompt_start / ui_prompt_end
402
+ ### ui_prompt_start / ui_prompt_end
401
403
 
402
- These notification-only events wrap blocking user-facing prompts. Each event has `reason: "ui_prompt" | "project_trust"`, the prompt `kind`, and the prompt `title` when available. Host and status integrations can use the pair to distinguish waiting for the user from active work.
404
+ Notification-only events wrapping blocking user-facing prompts:
403
405
 
404
- - `ui_prompt`: extension prompts opened through `ctx.ui.select()`, `ctx.ui.confirm()`, `ctx.ui.input()`, `ctx.ui.editor()`, and `ctx.ui.custom()`.
405
- Custom inspection/navigation components can pass `{ purpose: "navigation" }` to omit their own prompt span. The default remains `"prompt"`. Nested approval calls still emit events.
406
- - `project_trust`: interactive startup/resume trust dialogs, trust-hook dialogs, borrowed extension-source authorization, and the built-in `/trust` selector. Silent saved/default/CLI decisions and noninteractive startup do not emit artificial waits.
406
+ - `reason: "ui_prompt"`: prompts opened via `ctx.ui.select()`, `confirm()`, `input()`, `editor()`, and `custom()` (unless `{ purpose: "navigation" }` is passed).
407
+ - `reason: "project_trust"`: interactive trust dialogs and `/trust`.
407
408
 
408
- Trust-safe extensions receive a live context before the trust prompt. Newly authorized project extensions load afterward and do not receive historical prompt events. Resume trust dialogs use the outgoing session context; failed preparation leaves that session active.
409
-
410
- Nested or overlapping prompts share one outer span. Its end retains the original reason, kind, and title and fires after all nested prompts settle. Prompt display and answers never wait for observers. An observer's asynchronous start and end work can overlap, so update lifecycle state before awaiting unrelated work. During session replacement, pending notification delivery has a 1,000 ms limit; do not assume an old context remains valid beyond it.
409
+ Nested or overlapping prompts emit a single start/end pair that closes only after all nested prompts finish, preserving the original `reason`, `kind`, and `title`. Prompt display never waits for observers, so update your tracking state before awaiting async work. During session switches, pending notification delivery has a 1,000 ms limit.
411
410
 
412
411
  ```typescript
413
412
  atomic.on("ui_prompt_start", (event) => {
@@ -417,24 +416,25 @@ atomic.on("ui_prompt_start", (event) => {
417
416
  });
418
417
 
419
418
  atomic.on("ui_prompt_end", (event) => {
420
- // Atomic is no longer waiting on this outer prompt span.
419
+ // All prompts in this span have closed.
421
420
  });
422
421
  ```
423
422
 
424
- #### turn_start / turn_end
423
+ ### turn_start / turn_end
425
424
 
426
- Fired for each turn (one LLM response + tool calls).
425
+ Fired around each turn (one model response plus its tool calls). `turn_end` runs after the assistant message and tool results persist, and lets extensions append structural entries and request a continuation.
427
426
 
428
427
  ```typescript
429
- atomic.on("turn_start", async (event, ctx) => {
428
+ atomic.on("turn_start", async (event) => {
430
429
  // event.turnIndex, event.timestamp
431
430
  });
432
431
 
433
432
  let replacedResponse = false;
434
- atomic.on("turn_end", async (event, ctx) => {
433
+ atomic.on("turn_end", async (event) => {
435
434
  // event.turnIndex, event.message, event.toolResults
436
435
  // event.messageEntryId, event.toolResultEntryIds, event.outcome
437
- // event.entries contains the structural entries proposed so far.
436
+ // event.entries - entries proposed by earlier handlers
437
+ // event.context - rebuilt projection (contextEntries, contextMessages, llmMessages, pendingMessages, canContinue)
438
438
  if (replacedResponse || event.outcome !== "completed" || event.toolResults.length > 0) return;
439
439
  replacedResponse = true;
440
440
  return {
@@ -453,148 +453,128 @@ atomic.on("turn_end", async (event, ctx) => {
453
453
  });
454
454
  ```
455
455
 
456
- `turn_end` runs after the assistant and tool-result messages have been persisted. Retry backoff and final-attempt recovery still happen after `agent_end`, and `agent_before_settle` sees the repaired projection after that work completes.
457
-
458
- Boundary handlers run in extension load and registration order. Each handler sees earlier proposals in `event.entries` and `event.context` rebuilt from them (`contextEntries`, `contextMessages`, `llmMessages`, `pendingMessages`, `canContinue`). Returning `entries` or `continue` replaces only that field; omitted fields keep the current proposal.
456
+ Boundary rules shared by `turn_end` and `agent_before_settle`:
459
457
 
460
- Allowed draft entry types are `custom`, `custom_message`, `context_edit`, and `compaction` (`summary` is the compacted transcript text; `firstKeptEntryId: null` keeps no preceding entries). Atomic validates the complete proposal before appending it in list order after all handlers finish. A handler error is reported and later handlers still run. Validation prevents partially applied semantic errors, though persistence is not transactional.
458
+ - Allowed draft entry types are `custom`, `custom_message`, `context_edit`, and `compaction` (`summary` text with `firstKeptEntryId: null`).
459
+ - Returning `entries` or `continue` updates only that field; omitted fields keep earlier handlers' proposals.
460
+ - Atomic validates the combined proposal before appending entries in order. A handler error is reported without stopping later handlers.
461
+ - `continue: true` ensures one next model request when tool results, steering, or follow-ups do not already trigger one. Always guard `continue: true` so it cannot loop indefinitely. Error and aborted outcomes stop regardless.
461
462
 
462
- `continue: true` requests one next provider request for that boundary invocation. If tool results, steering, or a follow-up already trigger that request, they satisfy it and no extra request is made; otherwise Atomic makes one context-only request. Error and aborted responses remain hard exits, and `continue: false` never suppresses natural work. Guard continuation conditions because an unconditional `continue: true` runs again after the next response and can loop indefinitely. A `custom_message` draft contributes a user-role model message without running human input hooks, slash commands, skills, or prompt templates.
463
+ ### message_start / message_update / message_end
463
464
 
464
- #### message_start / message_update / message_end
465
-
466
- Fired for message lifecycle updates.
467
-
468
- - `message_start` and `message_end` fire for user, assistant, and toolResult messages.
469
- - `message_update` fires for assistant streaming updates.
470
- - `message_end` handlers can return `{ message }` to replace the finalized message. The replacement must keep the same `role`.
465
+ - `message_start` and `message_end` fire for `user`, `assistant`, and `toolResult` messages.
466
+ - `message_update` fires for streaming assistant deltas (`event.assistantMessageEvent`).
467
+ - `message_end` handlers can return `{ message }` to replace the finalized message. The replacement must keep the same `role`; returning a different `role` reports an extension error and ignores that handler's replacement (keeping the previous message).
471
468
 
472
469
  ```typescript
473
- atomic.on("message_start", async (event, ctx) => {
470
+ atomic.on("message_start", async (event) => {
474
471
  // event.message
475
472
  });
476
473
 
477
- atomic.on("message_update", async (event, ctx) => {
478
- // event.assistantMessageEvent (token-by-token delta; no cumulative message)
474
+ atomic.on("message_update", async (event) => {
475
+ // event.assistantMessageEvent (token-by-token delta)
479
476
  });
480
477
 
481
- atomic.on("message_end", async (event, ctx) => {
478
+ atomic.on("message_end", async (event) => {
482
479
  if (event.message.role !== "assistant") return;
483
-
484
480
  return {
485
481
  message: {
486
482
  ...event.message,
487
- usage: {
488
- ...event.message.usage,
489
- cost: {
490
- ...event.message.usage.cost,
491
- total: 0.123,
492
- },
493
- },
483
+ usage: { ...event.message.usage, cost: { ...event.message.usage.cost, total: 0.123 } },
494
484
  },
495
485
  };
496
486
  });
497
487
  ```
498
488
 
499
- #### tool_execution_start / tool_execution_update / tool_execution_end
489
+ ### tool_execution_start / tool_execution_update / tool_execution_end
500
490
 
501
- Fired for tool execution lifecycle updates.
491
+ Fired around each tool execution. Nested tool calls invoked through `ctx.executeTool()` include `event.parentToolCallId`.
502
492
 
503
493
  In parallel tool mode:
504
- - `tool_execution_start` is emitted in assistant source order during the preflight phase
505
- - `tool_execution_update` events may interleave across tools
506
- - `tool_execution_end` is emitted in tool completion order after each tool is finalized
507
- - final `toolResult` message events are still emitted later in assistant source order
494
+
495
+ - `tool_execution_start` fires in assistant message order while calls are checked sequentially before parallel execution begins.
496
+ - `tool_execution_update` events can interleave across concurrent calls.
497
+ - `tool_execution_end` fires in completion order (`durationMs` measures time spent in `execute()` via a monotonic clock, or is omitted if the tool did not run).
498
+ - Final `toolResult` message events still emit in assistant message order.
508
499
 
509
500
  ```typescript
510
- atomic.on("tool_execution_start", async (event, ctx) => {
511
- // event.toolCallId, event.toolName, event.args
501
+ atomic.on("tool_execution_start", async (event) => {
502
+ // event.toolCallId, event.toolName, event.args, event.parentToolCallId?
512
503
  });
513
504
 
514
- atomic.on("tool_execution_update", async (event, ctx) => {
515
- // event.toolCallId, event.toolName, event.args, event.partialResult
505
+ atomic.on("tool_execution_update", async (event) => {
506
+ // event.toolCallId, event.toolName, event.args, event.partialResult, event.parentToolCallId?
516
507
  });
517
508
 
518
- atomic.on("tool_execution_end", async (event, ctx) => {
519
- // event.toolCallId, event.toolName, event.result, event.isError, event.durationMs
509
+ atomic.on("tool_execution_end", async (event) => {
510
+ // event.toolCallId, event.toolName, event.result, event.isError, event.durationMs, event.parentToolCallId?
520
511
  });
521
512
  ```
522
513
 
523
- `durationMs` is the time spent in the tool's `execute()`, measured with a monotonic clock. It is absent when the tool did not run.
524
-
525
- #### context
514
+ ### context
526
515
 
527
- Fired before each LLM call. Modify messages non-destructively. See [Session Format](/session-format) for message types. When tool output crosses the buffered compaction threshold, the post-tool compaction preflight finishes before this hook runs for the follow-up call, so `event.messages` contains the rebuilt compacted context.
516
+ Fired before each model request to filter or adjust conversation messages non-destructively. If tool output crossed the compaction threshold, the context-size check and compaction finish before `context` runs, so `event.messages` reflects the compacted transcript.
528
517
 
529
518
  ```typescript
530
- atomic.on("context", async (event, ctx) => {
519
+ atomic.on("context", async (event) => {
531
520
  // event.messages - deep copy without system messages, safe to modify
532
- const filtered = event.messages.filter(m => !shouldPrune(m));
521
+ const filtered = event.messages.filter((m) => !shouldPrune(m));
533
522
  return { messages: filtered };
534
523
  });
535
524
  ```
536
525
 
537
- `event.messages` holds the conversation without system messages. The prompt and tool declarations belong to Atomic and are not part of this hook. When a handler returns a changed list or edits `event.messages` in place, Atomic replays the current prompt sections and tool declarations into one leading system message ahead of the returned messages, so filtering or windowing cannot drop them.
538
-
539
- An unchanged list keeps mid-conversation system messages in place so models that accept them keep their cached prefix. System messages a handler adds stay after Atomic's leading message. To change the prompt or tool set durably, use [`before_agent_start`](#before_agent_start) or `atomic.setActiveTools()`; to edit system messages for one request, use [`context_with_system`](#context_with_system).
526
+ `event.messages` excludes system messages so filtering cannot drop Atomic's prompt or tool declarations. When a handler modifies or returns a new message list, Atomic replays the active prompt sections and tool declarations into one leading system message ahead of your returned messages. Leaving `event.messages` unchanged preserves mid-conversation system patches for prompt caching. To change prompts or tools durably, use [`before_agent_start`](#before_agent_start) or `atomic.setActiveTools()`; to edit system messages directly for one request, use [`context_with_system`](#context_with_system).
540
527
 
541
- #### context_with_system
528
+ ### context_with_system
542
529
 
543
- Fired before each LLM call, after every `context` handler has run and Atomic has restored the prompt and tool state. `event.messages` is the full transcript, including the leading system message and any mid-conversation prompt or tool patches (see [Session Format](/session-format)). The returned messages are sent as they are: this hook owns the prompt and tool declarations for the request.
530
+ Fired after every `context` handler runs and Atomic restores prompt and tool state. `event.messages` contains the complete transcript including system messages. The returned list is sent verbatim.
544
531
 
545
532
  ```typescript
546
533
  import { getCurrentSystemMessage } from "@bastani/atomic-ai";
547
534
 
548
- atomic.on("context_with_system", async (event, ctx) => {
535
+ atomic.on("context_with_system", async (event) => {
549
536
  const cut = findCutIndex(event.messages);
550
- // Fold the dropped prefix so its prompt and tool state survives as the new head.
551
537
  const head = getCurrentSystemMessage(event.messages.slice(0, cut));
552
538
  return { messages: head ? [head, ...event.messages.slice(cut)] : event.messages.slice(cut) };
553
539
  });
554
540
  ```
555
541
 
556
- Rules: keep a system message at index 0 (providers read the prompt and initial tool declarations there; Atomic reports an extension error if a handler drops it). Removing a system message removes the tool declarations and section patches it carries. Check your output with `getCurrentSystemPrompt()` and `getCurrentTools()` from `@bastani/atomic-ai`. Handlers run in extension load order; a `systemPrompt` forced from `before_agent_start` is still projected onto the request afterwards.
542
+ Keep a system message at index `0` (dropping it triggers an extension error). Verify your result with `getCurrentSystemPrompt()` and `getCurrentTools()` from `@bastani/atomic-ai`. A `systemPrompt` forced in `before_agent_start` still applies afterward.
557
543
 
558
- #### before_provider_headers
544
+ ### before_provider_headers
559
545
 
560
- Fires after outgoing HTTP headers are assembled. Mutate `event.headers` to add, override, or remove headers. The event also identifies the provider and model. Atomic's default `User-Agent` and provider attribution headers (OpenRouter, NVIDIA NIM, OpenCode) are added after this event, so handlers do not see them; headers you set here or in `models.json` take precedence over them. For OpenCode models the `x-opencode-session` header is already present, so a handler can read, replace, or remove it.
546
+ Fired after outgoing HTTP headers are assembled. `event` contains only `{ type: "before_provider_headers", headers }`; read `ctx.model` if you need the active provider or model ID. Mutate `event.headers` in place to add, change, or remove headers.
561
547
 
562
- When Atomic retries a request with credentials saved by another process after a credential rejection, this event fires again for the retry.
548
+ Atomic's default `User-Agent` and provider attribution headers (OpenRouter, NVIDIA NIM, OpenCode) are added afterward, so headers you set here or in `models.json` take precedence. For OpenCode models, `x-opencode-session` is already present and can be read, replaced, or deleted. Fires again if Atomic retries a request with updated credentials.
563
549
 
564
550
  ```typescript
565
551
  atomic.on("before_provider_headers", (event, ctx) => {
566
- event.headers["x-session-id"] = ctx.sessionManager.getSessionId();
552
+ if (ctx.model?.provider === "openai") {
553
+ event.headers["x-session-id"] = ctx.sessionManager.getSessionId();
554
+ }
567
555
  delete event.headers["x-remove-me"];
568
556
  });
569
557
  ```
570
558
 
571
- #### before_provider_request
572
-
573
- Fired after the provider-specific payload is built, right before the request is sent. Handlers run in extension load order. Returning `undefined` keeps the payload unchanged. Returning any other value replaces the payload for later handlers and for the actual request.
559
+ ### before_provider_request
574
560
 
575
- Like `before_provider_headers`, it fires again when Atomic retries a request after a credential rejection.
561
+ Fired right before sending the serialized provider request body. Handlers run in load order; returning `undefined` leaves the payload unchanged, while returning any other value replaces the payload for later handlers and the request. Fires again on credential-refresh retries.
576
562
 
577
- This hook can rewrite provider-level system instructions or remove them entirely. Those payload-level changes are not reflected by `ctx.getSystemPrompt()`, which reports Atomic's system prompt string rather than the final serialized provider payload.
578
-
579
- The payload is the full request. Providers that continue from a previous response (OpenAI Codex over WebSocket, Anthropic message threads) may send only the part that is new since the previous request.
563
+ Payload edits here do not update `ctx.getSystemPrompt()`. Providers using stateful continuations (OpenAI Codex WebSockets, Anthropic threads) may send only the new delta since the prior request.
580
564
 
581
565
  ```typescript
582
- atomic.on("before_provider_request", (event, ctx) => {
566
+ atomic.on("before_provider_request", (event) => {
583
567
  console.log(JSON.stringify(event.payload, null, 2));
584
-
585
- // Optional: replace payload
586
- // return { ...event.payload, temperature: 0 };
568
+ // Optional: return { ...event.payload, temperature: 0 };
587
569
  });
588
570
  ```
589
571
 
590
- This is mainly useful for debugging provider serialization and cache behavior.
572
+ ### after_provider_response
591
573
 
592
- #### after_provider_response
593
-
594
- Fired after an HTTP response is received and before its stream body is consumed. Handlers run in extension load order.
574
+ Fired after an HTTP response arrives and before its stream body is consumed. Header availability depends on the provider transport.
595
575
 
596
576
  ```typescript
597
- atomic.on("after_provider_response", (event, ctx) => {
577
+ atomic.on("after_provider_response", (event) => {
598
578
  // event.status - HTTP status code
599
579
  // event.headers - normalized response headers
600
580
  if (event.status === 429) {
@@ -603,66 +583,50 @@ atomic.on("after_provider_response", (event, ctx) => {
603
583
  });
604
584
  ```
605
585
 
606
- Header availability depends on provider and transport. Providers that abstract HTTP responses may not expose headers.
607
-
608
- #### provider_stream_event
586
+ ### provider_stream_event
609
587
 
610
- Fired for each parsed provider stream event before Atomic normalizes it into assistant message events. Use it to inspect provider-specific fields that Atomic does not keep in the assistant message.
588
+ Fired for each parsed provider stream chunk before Atomic normalizes it into assistant message events.
611
589
 
612
590
  ```typescript
613
- atomic.on("provider_stream_event", (event, ctx) => {
614
- // event.provider, event.api, event.model - the model that produced the event
615
- // event.data - the parsed provider event (read-only)
591
+ atomic.on("provider_stream_event", (event) => {
592
+ // event.provider, event.api, event.model
593
+ // event.data - parsed provider chunk (treat as read-only)
616
594
  const chunk = event.data as Record<string, unknown>;
617
595
  if (chunk.openrouter_metadata) console.log(chunk.openrouter_metadata);
618
596
  });
619
597
  ```
620
598
 
621
- `event.data` is the earliest structured value available to Atomic, not necessarily the original HTTP bytes or SSE frame, and SDK-backed providers expose only the fields their SDK keeps. Treat it as read-only: changing it can change how the response is normalized. The event is notification-only and is not saved to the session. Cache-warming requests do not emit it.
599
+ Notification-only and not persisted to the session; cache-warming requests do not emit it. Handlers are awaited in stream order, so keep them fast. Custom providers using `streamSimple` emit this event only when they call `options.onProviderStreamEvent`. See [`debug-provider.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/debug-provider.ts).
622
600
 
623
- Handlers run in stream order and are awaited, so a slow handler delays the response. Handler errors are reported without changing the provider response. Custom providers registered with `streamSimple` emit this event only if they call `options.onProviderStreamEvent`. See [`debug-provider.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/debug-provider.ts) for an opt-in viewer.
601
+ ## Model events
624
602
 
625
- ### Model events
603
+ ### model_select
626
604
 
627
- #### model_select
628
-
629
- Fired when the model changes via `/model`, model cycling (`Ctrl+P`), session restore, or fallback selection.
605
+ Fired when the active model changes via `/model`, `Ctrl+P`, session restore, or fallback selection.
630
606
 
631
607
  ```typescript
632
608
  atomic.on("model_select", async (event, ctx) => {
633
- // event.model - newly selected model
634
- // event.previousModel - previous model (undefined if first selection)
609
+ // event.model, event.previousModel (undefined on initial selection)
635
610
  // event.source - "set" | "cycle" | "restore" | "fallback"
636
-
637
- const prev = event.previousModel
638
- ? `${event.previousModel.provider}/${event.previousModel.id}`
639
- : "none";
640
611
  const next = `${event.model.provider}/${event.model.id}`;
641
-
642
- ctx.ui.notify(`Model changed (${event.source}): ${prev} to ${next}`, "info");
612
+ ctx.ui.notify(`Model changed (${event.source}): ${next}`, "info");
643
613
  });
644
614
  ```
645
615
 
646
- Use this to update UI elements (status bars, footers) or perform model-specific initialization when the active model changes.
616
+ ### thinking_level_select
647
617
 
648
- #### thinking_level_select
649
-
650
- Fired when the thinking level changes. This is notification-only; handler return values are ignored.
618
+ Notification-only event fired when the thinking level changes via settings, keybindings, model clamping, or `atomic.setThinkingLevel()`.
651
619
 
652
620
  ```typescript
653
621
  atomic.on("thinking_level_select", async (event, ctx) => {
654
- // event.level - newly selected thinking level
655
- // event.previousLevel - previous thinking level
656
-
622
+ // event.level, event.previousLevel
657
623
  ctx.ui.setStatus("thinking", `thinking: ${event.level}`);
658
624
  });
659
625
  ```
660
626
 
661
- Use this to update extension UI when `atomic.setThinkingLevel()`, model changes, or built-in thinking-level controls change the active thinking level.
627
+ ### cache_warming_decision
662
628
 
663
- #### cache_warming_decision
664
-
665
- Fired when prompt cache warming evaluates whether to send a warming request. Handlers run in load order and receive `warmCost`, `missCost`, `continuationProbability`, and the current `action` (`"warm"` or `"stop"`). Return `{ action: "warm" }` or `{ action: "stop" }` to override the decision for later handlers and the cache warmer.
629
+ Fired when prompt cache warming decides whether to send a warming request. Handlers run in load order and receive `warmCost`, `missCost`, `continuationProbability`, and the current `action` (`"warm"` or `"stop"`). Return `{ action: "warm" }` or `{ action: "stop" }` to override the decision for later handlers and the warmer.
666
630
 
667
631
  ```typescript
668
632
  atomic.on("cache_warming_decision", (event) => {
@@ -672,57 +636,42 @@ atomic.on("cache_warming_decision", (event) => {
672
636
  });
673
637
  ```
674
638
 
675
- ### Tool events
676
-
677
- #### tool_call
639
+ ## Tool events
678
640
 
679
- Fired after `tool_execution_start`, before the tool executes. **Can block.** Use `isToolCallEventType` to narrow and get typed inputs.
641
+ ### tool_call
680
642
 
681
- Before `tool_call` runs, Atomic waits for previously emitted Agent events to finish draining through `AgentSession`. This means `ctx.sessionManager` is up to date through the current assistant tool-calling message.
643
+ Fired after `tool_execution_start` and before `execute()`. **Can block or patch arguments.**
682
644
 
683
- In the default parallel tool execution mode, sibling tool calls from the same assistant message are preflighted sequentially, then executed concurrently. `tool_call` is not guaranteed to see sibling tool results from that same assistant message in `ctx.sessionManager`.
645
+ Before `tool_call` runs, `ctx.sessionManager` is synced through the current assistant tool-calling message. In parallel tool mode, sibling calls from the same assistant message are checked sequentially before running concurrently, so `tool_call` may not see sibling tool results from that message. Nested `ctx.executeTool()` calls run `tool_call` too and include `event.parentToolCallId` (see [Structured results and nested tools](/extensions/authoring#structured-results-and-nested-tools)).
684
646
 
685
- Nested calls made inside a tool through `ctx.executeTool()` run the same hooks and execution events. Their events include `parentToolCallId`; use that field to distinguish them from model-issued calls. Nested calls do not add standalone transcript messages. See [nested tools](/extensions/authoring#structured-results-and-nested-tools).
647
+ Chaining and mutation rules:
686
648
 
687
- `event.input` is mutable. Mutate it in place to patch tool arguments before execution.
688
-
689
- Behavior guarantees:
690
- - Mutations to `event.input` affect the actual tool execution
691
- - Later `tool_call` handlers see mutations made by earlier handlers
692
- - No re-validation is performed after your mutation
693
- - Return values from `tool_call` control blocking via `{ block: true, reason?: string, terminate?: boolean }`
694
- - `terminate` only applies to a blocked call; the agent stops early only when every finalized result in the batch is terminating
649
+ - `event.input` is mutable; later `tool_call` handlers and `execute()` see in-place edits without re-validation.
650
+ - The **first** handler returning `{ block: true, reason?, terminate? }` immediately short-circuits later handlers and blocks the tool call.
651
+ - If a `tool_call` handler **throws an error**, Atomic immediately blocks the tool call with that error and skips remaining handlers.
652
+ - `terminate: true` applies only on a blocked call; the turn ends early only when every finalized result in the batch is terminating.
695
653
 
696
654
  ```typescript
697
655
  import { isToolCallEventType } from "@bastani/atomic";
698
656
 
699
- atomic.on("tool_call", async (event, ctx) => {
700
- // event.toolName - "bash", "powershell", "read", "write", "edit", "find", "search", etc.
701
- // event.toolCallId
702
- // event.input - tool parameters (mutable)
703
-
704
- // Built-in tools: no type params needed
657
+ atomic.on("tool_call", async (event) => {
658
+ // event.toolName, event.toolCallId, event.input (mutable), event.parentToolCallId?
705
659
  if (isToolCallEventType("bash", event)) {
706
- // event.input is { command: string; timeout?: number }
707
660
  event.input.command = `source ~/.profile\n${event.input.command}`;
708
-
709
661
  if (event.input.command.includes("rm -rf")) {
710
662
  return { block: true, reason: "Dangerous command", terminate: true };
711
663
  }
712
664
  }
713
665
 
714
666
  if (isToolCallEventType("powershell", event)) {
715
- // event.input is typed as PowerShellToolInput
716
667
  event.input.command = `$ErrorActionPreference = "Stop"\n${event.input.command}`;
717
668
  }
718
669
 
719
670
  if (isToolCallEventType("read", event)) {
720
- // event.input is { path: string }
721
671
  console.log(`Reading: ${event.input.path}`);
722
672
  }
723
673
 
724
674
  if (isToolCallEventType("search", event)) {
725
- // event.input is typed as SearchToolInput
726
675
  event.input.paths ??= ".";
727
676
  }
728
677
  });
@@ -730,58 +679,53 @@ atomic.on("tool_call", async (event, ctx) => {
730
679
 
731
680
  #### Typing custom tool input
732
681
 
733
- Custom tools should export their input type:
734
-
735
- ```typescript
736
- // my-extension.ts
737
- export type MyToolInput = Static<typeof myToolSchema>;
738
- ```
739
-
740
- Use `isToolCallEventType` with explicit type parameters:
682
+ Export the static input type from your tool module and pass type arguments to `isToolCallEventType`:
741
683
 
742
684
  ```typescript
743
685
  import { isToolCallEventType } from "@bastani/atomic";
744
- import type { MyToolInput } from "my-extension";
686
+ import type { MyToolInput } from "./my-tool.js";
745
687
 
746
688
  atomic.on("tool_call", (event) => {
747
689
  if (isToolCallEventType<"my_tool", MyToolInput>("my_tool", event)) {
748
- event.input.action; // typed
690
+ console.log(event.input.action);
749
691
  }
750
692
  });
751
693
  ```
752
694
 
753
- #### tool_result
695
+ ### tool_result
754
696
 
755
- Fired after tool execution finishes and before `tool_execution_end` plus the final tool result message events are emitted. **Can modify result.**
697
+ Fired after a tool finishes and before `tool_execution_end` and the final `toolResult` message event. **Can modify the result.**
756
698
 
757
- In parallel tool mode, `tool_result` and `tool_execution_end` may interleave in tool completion order, while final `toolResult` message events are still emitted later in assistant source order.
699
+ In parallel mode, `tool_result` runs in tool completion order while final `toolResult` transcript messages still emit in assistant message order.
758
700
 
759
- `tool_result` handlers chain like middleware:
760
- - Handlers run in extension load order
761
- - Each handler sees the latest result after previous handler changes
762
- - Handlers can return partial patches (`content`, `structuredContent`, `details`, `usage`, or `isError`); omitted fields keep their current values, except replacing `content` without replacing `structuredContent` drops the structured value
701
+ Handlers chain in extension load order, each seeing prior changes. Return partial patches for `content`, `structuredContent`, `details`, `usage`, or `isError`. Omitted fields stay unchanged, except replacing `content` without replacing `structuredContent` drops `structuredContent` so redacted data cannot leak. After all handlers finish, Atomic applies `images.autoResize` to returned images.
763
702
 
764
- After all handlers finish, Atomic normalizes image blocks returned by the tool or inserted by a handler according to `images.autoResize` before saving the result to history. If image processing fails, the original image remains in the result.
765
-
766
- Use `ctx.signal` for nested async work inside the handler. This lets Escape cancel model calls, `fetch()`, and other abort-aware operations started by the extension.
703
+ Built-in result type guards exported from `@bastani/atomic`: `isBashToolResult`, `isPowerShellToolResult`, `isReadToolResult`, `isEditToolResult`, `isWriteToolResult`, `isFindToolResult`, `isSearchToolResult`, and `isLsToolResult`.
767
704
 
768
705
  ```typescript
769
- import { isBashToolResult, isPowerShellToolResult, isSearchToolResult } from "@bastani/atomic";
706
+ import {
707
+ isBashToolResult,
708
+ isEditToolResult,
709
+ isFindToolResult,
710
+ isLsToolResult,
711
+ isPowerShellToolResult,
712
+ isReadToolResult,
713
+ isSearchToolResult,
714
+ isWriteToolResult,
715
+ } from "@bastani/atomic";
770
716
 
771
717
  atomic.on("tool_result", async (event, ctx) => {
772
- // event.toolName, event.toolCallId, event.input
773
- // event.content, event.details, event.isError
718
+ // event.toolName, event.toolCallId, event.input, event.parentToolCallId?
719
+ // event.content, event.structuredContent, event.details, event.usage, event.isError
774
720
 
775
721
  if (isBashToolResult(event)) {
776
- // event.details is typed as BashToolDetails
722
+ // event.details is BashToolDetails | undefined
777
723
  }
778
-
779
- if (isPowerShellToolResult(event)) {
780
- // event.details is typed as PowerShellToolDetails | undefined
724
+ if (isReadToolResult(event) || isEditToolResult(event) || isWriteToolResult(event)) {
725
+ // Narrowed built-in details types
781
726
  }
782
-
783
- if (isSearchToolResult(event)) {
784
- // event.details is typed as SearchToolDetails | undefined
727
+ if (isFindToolResult(event) || isSearchToolResult(event) || isLsToolResult(event) || isPowerShellToolResult(event)) {
728
+ // Narrowed built-in details types
785
729
  }
786
730
 
787
731
  const response = await fetch("https://example.com/summarize", {
@@ -790,97 +734,86 @@ atomic.on("tool_result", async (event, ctx) => {
790
734
  signal: ctx.signal,
791
735
  });
792
736
 
793
- // Modify result:
794
- return { content: [...], details: {...}, isError: false };
737
+ return { content: event.content, details: await response.json(), isError: false };
795
738
  });
796
739
  ```
797
740
 
798
- ### User bash events
741
+ ## User bash events
799
742
 
800
- #### user_bash
743
+ ### user_bash
801
744
 
802
- Fired when user executes `!` or `!!` commands. **Can intercept.**
745
+ Fired when the user runs `!` or `!!` shell commands. Return `{ operations }` to customize execution (optionally wrapping `createLocalBashOperations()` from `@bastani/atomic`) or `{ result }` to return a result directly.
803
746
 
804
747
  ```typescript
805
748
  import { createLocalBashOperations } from "@bastani/atomic";
806
749
 
807
- atomic.on("user_bash", (event, ctx) => {
808
- // event.command - the bash command
809
- // event.excludeFromContext - true if !! prefix
810
- // event.cwd - working directory
750
+ atomic.on("user_bash", (event) => {
751
+ // event.command, event.excludeFromContext (true for !!), event.cwd
811
752
 
812
- // Option 1: Provide custom operations (e.g., SSH)
813
- return { operations: remoteBashOps };
753
+ // Option 1: Custom operations (such as SSH)
754
+ // return { operations: remoteBashOps };
814
755
 
815
- // Option 2: Wrap atomic's built-in local bash backend
756
+ // Option 2: Wrap Atomic's local bash backend
816
757
  const local = createLocalBashOperations();
817
758
  return {
818
759
  operations: {
819
760
  exec(command, cwd, options) {
820
761
  return local.exec(`source ~/.profile\n${command}`, cwd, options);
821
- }
822
- }
762
+ },
763
+ },
823
764
  };
824
765
 
825
- // Option 3: Full replacement - return result directly
826
- return { result: { output: "...", exitCode: 0, cancelled: false, truncated: false } };
766
+ // Option 3: Full replacement
767
+ // return { result: { output: "...", exitCode: 0, cancelled: false, truncated: false } };
827
768
  });
828
769
  ```
829
770
 
830
- ### Input events
771
+ ## Input events
831
772
 
832
- #### input
773
+ ### input
833
774
 
834
- Fired when user input is received, after extension commands are checked and before skill and template expansion. The event sees the raw input text, so `/skill:foo` and `/template` are not yet expanded.
835
-
836
- Direct `session.steer()` and `session.followUp()` calls also run input handlers before skill and template expansion and queue admission. Handled input is not queued; transformed text and images are queued instead. Their optional third argument sets `source`, defaulting to `interactive`; RPC queue commands use `rpc`.
775
+ Fired on user input after extension commands are checked and before `/skill:` and prompt template expansion. Direct `session.steer()` and `session.followUp()` calls also run `input` handlers before queueing (`source` defaults to `"interactive"`, or `"rpc"` for RPC queue commands).
837
776
 
838
777
  Processing order:
839
778
 
840
- 1. Extension commands (`/cmd`) are checked first. If one matches, its handler runs and the `input` event is skipped.
841
- 2. The `input` event fires and can intercept, transform, or handle the text.
842
- 3. If not handled, skill commands (`/skill:name`) expand to skill content.
843
- 4. If not handled, prompt templates (`/template`) expand to template content.
844
- 5. Agent processing begins (`before_agent_start`, and then the turn lifecycle).
779
+ 1. Extension slash commands (`/cmd`) match first and skip `input`.
780
+ 2. `input` handlers run and can return `"continue"`, `"transform"`, or `"handled"`.
781
+ 3. If not handled, `/skill:<name>` commands expand.
782
+ 4. If not handled, prompt templates (`/template`) expand.
783
+ 5. Agent execution begins (`before_agent_start`).
784
+
785
+ `event.streamingBehavior` tells you whether the input is an immediate submission (`undefined`) or queued while a turn is running (`"steer"` or `"followUp"`):
845
786
 
846
787
  ```typescript
847
788
  atomic.on("input", async (event, ctx) => {
848
- // event.text - raw input (before skill/template expansion)
789
+ // event.text - raw text before skill/template expansion
849
790
  // event.images - attached images, if any
850
- // event.source - "interactive" (typed), "rpc" (API), or "extension" (via sendUserMessage)
791
+ // event.source - "interactive" | "rpc" | "extension"
792
+ // event.streamingBehavior - undefined (immediate) | "steer" | "followUp" (queued while streaming)
851
793
 
852
- // Transform: rewrite input before expansion
853
- if (event.text.startsWith("?quick "))
794
+ if (event.text.startsWith("?quick ")) {
854
795
  return { action: "transform", text: `Respond briefly: ${event.text.slice(7)}` };
796
+ }
855
797
 
856
- // Handle: respond without LLM (extension shows its own feedback)
857
798
  if (event.text === "ping") {
858
799
  ctx.ui.notify("pong", "info");
859
800
  return { action: "handled" };
860
801
  }
861
802
 
862
- // Route by source: skip processing for extension-injected messages
863
803
  if (event.source === "extension") return { action: "continue" };
864
804
 
865
- // Intercept skill commands before expansion
866
- if (event.text.startsWith("/skill:")) {
867
- // Could transform, block, or let pass through
868
- }
869
-
870
- return { action: "continue" }; // Default: pass through to expansion
805
+ return { action: "continue" };
871
806
  });
872
807
  ```
873
808
 
874
- Results:
875
-
876
- - `continue`. Pass through unchanged (default when a handler returns nothing).
877
- - `transform`. Modify text or images, then continue to expansion.
878
- - `handled`. Skip the agent completely (the first handler returning `handled` wins).
809
+ Return actions:
879
810
 
880
- Transforms change the input sent to the agent and the prompt the session saves, including input queued while a turn runs or while queued messages are paused. Ctrl+R prompt search lists the transformed text. The Up and Down arrow keys in the editor still walk through what was typed during the current run.
811
+ - `"continue"`: pass through unchanged (default when returning `undefined`).
812
+ - `"transform"`: replace `text` or `images` and continue to later handlers and expansion. Transformed text is what enters the session and `Ctrl+R` search, while Up/Down editor history keeps what you typed.
813
+ - `"handled"`: stop processing without sending to the model (first `"handled"` result wins).
881
814
 
882
- Transforms chain across handlers. See [input-transform.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/input-transform.ts) and [input-transform-streaming.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/input-transform-streaming.ts) for `streamingBehavior`-aware routing.
815
+ See [input-transform.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/input-transform.ts) and [input-transform-streaming.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/input-transform-streaming.ts).
883
816
 
884
817
  ## Next steps
885
818
 
886
- Continue with [extension UI](/extensions/ui) to add user interaction. Look up the context available to event handlers in the [Extension API reference](/extensions/api-reference#extensioncontext).
819
+ Continue with [Extension UI](/extensions/ui) to add dialogs, pickers, widgets, and custom components, or inspect all context properties in the [Extension API reference](/extensions/api-reference#extensioncontext).