@bastani/atomic 0.9.18 → 0.9.19-alpha.10

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 (876) hide show
  1. package/CHANGELOG.md +206 -0
  2. package/README.md +2 -2
  3. package/dist/builtin/intercom/CHANGELOG.md +51 -0
  4. package/dist/builtin/intercom/README.md +28 -18
  5. package/dist/builtin/intercom/broker/broker.ts +81 -9
  6. package/dist/builtin/intercom/broker/client.ts +45 -1
  7. package/dist/builtin/intercom/broker/framing.ts +5 -2
  8. package/dist/builtin/intercom/broker/group-membership.ts +4 -2
  9. package/dist/builtin/intercom/broker/presence-handler.ts +14 -0
  10. package/dist/builtin/intercom/broker/send-handler.ts +61 -6
  11. package/dist/builtin/intercom/broker/terminal-questions.ts +29 -0
  12. package/dist/builtin/intercom/index.bundle.mjs +1120 -783
  13. package/dist/builtin/intercom/package.json +2 -2
  14. package/dist/builtin/intercom/recipient-purpose.ts +9 -0
  15. package/dist/builtin/intercom/recoverable-disconnect.ts +2 -3
  16. package/dist/builtin/intercom/retry-policy.ts +4 -2
  17. package/dist/builtin/intercom/skills/intercom/SKILL.md +8 -7
  18. package/dist/builtin/intercom/types.ts +18 -3
  19. package/dist/builtin/mcp/CHANGELOG.md +6 -0
  20. package/dist/builtin/mcp/README.md +2 -0
  21. package/dist/builtin/mcp/index.bundle.mjs +2201 -12000
  22. package/dist/builtin/mcp/package.json +2 -2
  23. package/dist/builtin/subagents/CHANGELOG.md +57 -0
  24. package/dist/builtin/subagents/README.md +46 -23
  25. package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
  26. package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
  27. package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
  28. package/dist/builtin/subagents/agents/codebase-online-researcher.md +8 -8
  29. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
  30. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
  31. package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
  32. package/dist/builtin/subagents/agents/debugger.md +2 -2
  33. package/dist/builtin/subagents/agents/worker.md +1 -1
  34. package/dist/builtin/subagents/package.json +2 -2
  35. package/dist/builtin/subagents/skills/herdr/LICENSE +201 -0
  36. package/dist/builtin/subagents/skills/herdr/SKILL.md +202 -0
  37. package/dist/builtin/subagents/skills/subagent/SKILL.md +41 -35
  38. package/dist/builtin/subagents/skills/tmux/SKILL.md +1 -1
  39. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1414 -656
  40. package/dist/builtin/web-access/CHANGELOG.md +19 -0
  41. package/dist/builtin/web-access/README.md +31 -24
  42. package/dist/builtin/web-access/index.bundle.mjs +42723 -26674
  43. package/dist/builtin/web-access/package.json +3 -2
  44. package/dist/builtin/workflows/CHANGELOG.md +131 -0
  45. package/dist/builtin/workflows/README.md +15 -16
  46. package/dist/builtin/workflows/builtin/adversarial-verification.js +5 -7
  47. package/dist/builtin/workflows/builtin/{chunk-hqpe2cyx.js → chunk-1jth021m.js} +85 -85
  48. package/dist/builtin/workflows/builtin/{chunk-7430zyas.js → chunk-2377r57g.js} +5 -3
  49. package/dist/builtin/workflows/builtin/{chunk-79fjkcvh.js → chunk-31j2gs7h.js} +18 -18
  50. package/dist/builtin/workflows/builtin/{chunk-wgccch41.js → chunk-6w6cvk6b.js} +16 -16
  51. package/dist/builtin/workflows/builtin/{chunk-zbekjqew.js → chunk-a2kdsqn8.js} +4 -4
  52. package/dist/builtin/workflows/builtin/{chunk-ze5x3d1r.js → chunk-fg9esgkj.js} +7 -7
  53. package/dist/builtin/workflows/builtin/{chunk-n8h4yyew.js → chunk-g0csgs7w.js} +11 -11
  54. package/dist/builtin/workflows/builtin/{chunk-b0v2xab1.js → chunk-ngkqkzej.js} +221 -23
  55. package/dist/builtin/workflows/builtin/{chunk-ed4jfn5t.js → chunk-nkrafh9s.js} +61 -61
  56. package/dist/builtin/workflows/builtin/{chunk-reqr3sr3.js → chunk-wf741bv3.js} +22 -22
  57. package/dist/builtin/workflows/builtin/{chunk-42s7sw0b.js → chunk-yeee2jrc.js} +19 -19
  58. package/dist/builtin/workflows/builtin/{chunk-6fqs7c01.js → chunk-z0d03ktm.js} +1 -1
  59. package/dist/builtin/workflows/builtin/{chunk-k3w87x8y.js → chunk-z29qbehr.js} +10 -10
  60. package/dist/builtin/workflows/builtin/classify-and-act.js +5 -6
  61. package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -4
  62. package/dist/builtin/workflows/builtin/generate-and-filter.js +5 -6
  63. package/dist/builtin/workflows/builtin/goal.js +7 -8
  64. package/dist/builtin/workflows/builtin/index.js +20 -22
  65. package/dist/builtin/workflows/builtin/loop-until-done.js +5 -6
  66. package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
  67. package/dist/builtin/workflows/builtin/ralph.js +7 -8
  68. package/dist/builtin/workflows/builtin/steering-context.js +3 -3
  69. package/dist/builtin/workflows/builtin/tournament.js +5 -7
  70. package/dist/builtin/workflows/package.json +6 -6
  71. package/dist/builtin/workflows/src/extension/index.bundle.mjs +57318 -25709
  72. package/dist/builtin/workflows/src/index.js +1413 -589
  73. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +4 -1
  74. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +1 -1
  75. package/dist/cli/config-selector.js.map +1 -1
  76. package/dist/cli/startup-ui.d.ts +1 -1
  77. package/dist/cli/startup-ui.js.map +1 -1
  78. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  79. package/dist/core/agent-session-auto-compaction.js +6 -5
  80. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  81. package/dist/core/agent-session-bash.d.ts +1 -1
  82. package/dist/core/agent-session-bash.d.ts.map +1 -1
  83. package/dist/core/agent-session-bash.js +5 -1
  84. package/dist/core/agent-session-bash.js.map +1 -1
  85. package/dist/core/agent-session-compaction.d.ts +1 -1
  86. package/dist/core/agent-session-compaction.js +1 -1
  87. package/dist/core/agent-session-compaction.js.map +1 -1
  88. package/dist/core/agent-session-custom-message-commit.d.ts +1 -1
  89. package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
  90. package/dist/core/agent-session-custom-message-commit.js +33 -2
  91. package/dist/core/agent-session-custom-message-commit.js.map +1 -1
  92. package/dist/core/agent-session-delivery-forwarding.d.ts +1 -1
  93. package/dist/core/agent-session-delivery-forwarding.js.map +1 -1
  94. package/dist/core/agent-session-events.d.ts.map +1 -1
  95. package/dist/core/agent-session-events.js +5 -0
  96. package/dist/core/agent-session-events.js.map +1 -1
  97. package/dist/core/agent-session-export.d.ts +1 -1
  98. package/dist/core/agent-session-export.js.map +1 -1
  99. package/dist/core/agent-session-extension-bindings.d.ts +8 -1
  100. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  101. package/dist/core/agent-session-extension-bindings.js +45 -3
  102. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  103. package/dist/core/agent-session-message-queue.d.ts +2 -2
  104. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  105. package/dist/core/agent-session-message-queue.js +22 -8
  106. package/dist/core/agent-session-message-queue.js.map +1 -1
  107. package/dist/core/agent-session-methods.d.ts +21 -8
  108. package/dist/core/agent-session-methods.d.ts.map +1 -1
  109. package/dist/core/agent-session-methods.js.map +1 -1
  110. package/dist/core/agent-session-persistent-custom-messages.d.ts +1 -1
  111. package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
  112. package/dist/core/agent-session-persistent-custom-messages.js +13 -3
  113. package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
  114. package/dist/core/agent-session-post-tool-compaction.js +1 -1
  115. package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
  116. package/dist/core/agent-session-prompt.d.ts +2 -2
  117. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  118. package/dist/core/agent-session-prompt.js +105 -18
  119. package/dist/core/agent-session-prompt.js.map +1 -1
  120. package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
  121. package/dist/core/agent-session-queue-pause.js +11 -0
  122. package/dist/core/agent-session-queue-pause.js.map +1 -1
  123. package/dist/core/agent-session-runtime-auth.d.ts +1 -1
  124. package/dist/core/agent-session-runtime-auth.js.map +1 -1
  125. package/dist/core/agent-session-runtime.d.ts +13 -4
  126. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  127. package/dist/core/agent-session-runtime.js +27 -4
  128. package/dist/core/agent-session-runtime.js.map +1 -1
  129. package/dist/core/agent-session-services.d.ts +5 -1
  130. package/dist/core/agent-session-services.d.ts.map +1 -1
  131. package/dist/core/agent-session-services.js +44 -34
  132. package/dist/core/agent-session-services.js.map +1 -1
  133. package/dist/core/agent-session-state.d.ts +1 -1
  134. package/dist/core/agent-session-state.js.map +1 -1
  135. package/dist/core/agent-session-tasks.d.ts +14 -0
  136. package/dist/core/agent-session-tasks.d.ts.map +1 -0
  137. package/dist/core/agent-session-tasks.js +120 -0
  138. package/dist/core/agent-session-tasks.js.map +1 -0
  139. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  140. package/dist/core/agent-session-tool-hooks.js +2 -0
  141. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  142. package/dist/core/agent-session-tool-registry.d.ts +1 -0
  143. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  144. package/dist/core/agent-session-tool-registry.js +52 -5
  145. package/dist/core/agent-session-tool-registry.js.map +1 -1
  146. package/dist/core/agent-session-transfer.d.ts.map +1 -1
  147. package/dist/core/agent-session-transfer.js +7 -0
  148. package/dist/core/agent-session-transfer.js.map +1 -1
  149. package/dist/core/agent-session-tree.d.ts.map +1 -1
  150. package/dist/core/agent-session-tree.js +3 -0
  151. package/dist/core/agent-session-tree.js.map +1 -1
  152. package/dist/core/agent-session-types.d.ts +4 -2
  153. package/dist/core/agent-session-types.d.ts.map +1 -1
  154. package/dist/core/agent-session-types.js +2 -0
  155. package/dist/core/agent-session-types.js.map +1 -1
  156. package/dist/core/agent-session.d.ts +8 -1
  157. package/dist/core/agent-session.d.ts.map +1 -1
  158. package/dist/core/agent-session.js +29 -1
  159. package/dist/core/agent-session.js.map +1 -1
  160. package/dist/core/bash-executor.d.ts +1 -1
  161. package/dist/core/bash-executor.js.map +1 -1
  162. package/dist/core/export-html/index.js.map +1 -1
  163. package/dist/core/export-html/tool-renderer.d.ts +1 -1
  164. package/dist/core/export-html/tool-renderer.js.map +1 -1
  165. package/dist/core/extension-session-state.js.map +1 -1
  166. package/dist/core/extensions/agent-events.d.ts +4 -4
  167. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  168. package/dist/core/extensions/agent-events.js.map +1 -1
  169. package/dist/core/extensions/api-types.d.ts +10 -2
  170. package/dist/core/extensions/api-types.d.ts.map +1 -1
  171. package/dist/core/extensions/api-types.js.map +1 -1
  172. package/dist/core/extensions/context-types.d.ts +15 -0
  173. package/dist/core/extensions/context-types.d.ts.map +1 -1
  174. package/dist/core/extensions/context-types.js.map +1 -1
  175. package/dist/core/extensions/event-results.d.ts +1 -1
  176. package/dist/core/extensions/event-results.js.map +1 -1
  177. package/dist/core/extensions/event-types.d.ts +2 -1
  178. package/dist/core/extensions/event-types.d.ts.map +1 -1
  179. package/dist/core/extensions/event-types.js.map +1 -1
  180. package/dist/core/extensions/index.d.ts +3 -2
  181. package/dist/core/extensions/index.d.ts.map +1 -1
  182. package/dist/core/extensions/index.js.map +1 -1
  183. package/dist/core/extensions/loader-api.d.ts +1 -1
  184. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  185. package/dist/core/extensions/loader-api.js +10 -0
  186. package/dist/core/extensions/loader-api.js.map +1 -1
  187. package/dist/core/extensions/loader-core.d.ts +1 -1
  188. package/dist/core/extensions/loader-core.js.map +1 -1
  189. package/dist/core/extensions/loader-discovery.d.ts +1 -1
  190. package/dist/core/extensions/loader-discovery.js.map +1 -1
  191. package/dist/core/extensions/loader-host-modules.d.ts +1 -1
  192. package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
  193. package/dist/core/extensions/loader-host-modules.js +5 -2
  194. package/dist/core/extensions/loader-host-modules.js.map +1 -1
  195. package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
  196. package/dist/core/extensions/loader-runtime.js +3 -0
  197. package/dist/core/extensions/loader-runtime.js.map +1 -1
  198. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  199. package/dist/core/extensions/loader-virtual-modules.js +6 -1
  200. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  201. package/dist/core/extensions/loader.d.ts +1 -1
  202. package/dist/core/extensions/loader.js.map +1 -1
  203. package/dist/core/extensions/message-types.d.ts +1 -1
  204. package/dist/core/extensions/message-types.js.map +1 -1
  205. package/dist/core/extensions/reactive-widget.d.ts +6 -0
  206. package/dist/core/extensions/reactive-widget.d.ts.map +1 -1
  207. package/dist/core/extensions/reactive-widget.js +7 -1
  208. package/dist/core/extensions/reactive-widget.js.map +1 -1
  209. package/dist/core/extensions/runner-context.d.ts +12 -2
  210. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  211. package/dist/core/extensions/runner-context.js +49 -4
  212. package/dist/core/extensions/runner-context.js.map +1 -1
  213. package/dist/core/extensions/runner-events.d.ts +1 -1
  214. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  215. package/dist/core/extensions/runner-events.js +17 -2
  216. package/dist/core/extensions/runner-events.js.map +1 -1
  217. package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
  218. package/dist/core/extensions/runner-shortcuts.js +32 -3
  219. package/dist/core/extensions/runner-shortcuts.js.map +1 -1
  220. package/dist/core/extensions/runner-ui.js.map +1 -1
  221. package/dist/core/extensions/runner.d.ts +17 -2
  222. package/dist/core/extensions/runner.d.ts.map +1 -1
  223. package/dist/core/extensions/runner.js +69 -19
  224. package/dist/core/extensions/runner.js.map +1 -1
  225. package/dist/core/extensions/runtime-types.d.ts +8 -1
  226. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  227. package/dist/core/extensions/runtime-types.js.map +1 -1
  228. package/dist/core/extensions/tool-types.d.ts +1 -1
  229. package/dist/core/extensions/tool-types.js.map +1 -1
  230. package/dist/core/extensions/types.d.ts +1 -0
  231. package/dist/core/extensions/types.d.ts.map +1 -1
  232. package/dist/core/extensions/types.js.map +1 -1
  233. package/dist/core/extensions/ui-types.d.ts +25 -1
  234. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  235. package/dist/core/extensions/ui-types.js.map +1 -1
  236. package/dist/core/extensions/workflow-activity-hub.d.ts +25 -0
  237. package/dist/core/extensions/workflow-activity-hub.d.ts.map +1 -0
  238. package/dist/core/extensions/workflow-activity-hub.js +183 -0
  239. package/dist/core/extensions/workflow-activity-hub.js.map +1 -0
  240. package/dist/core/extensions/workflow-events.d.ts +118 -0
  241. package/dist/core/extensions/workflow-events.d.ts.map +1 -0
  242. package/dist/core/extensions/workflow-events.js +2 -0
  243. package/dist/core/extensions/workflow-events.js.map +1 -0
  244. package/dist/core/footer-data-provider.d.ts +8 -4
  245. package/dist/core/footer-data-provider.d.ts.map +1 -1
  246. package/dist/core/footer-data-provider.js +97 -11
  247. package/dist/core/footer-data-provider.js.map +1 -1
  248. package/dist/core/index.d.ts +3 -3
  249. package/dist/core/index.js.map +1 -1
  250. package/dist/core/keybinding-identity.d.ts +4 -0
  251. package/dist/core/keybinding-identity.d.ts.map +1 -0
  252. package/dist/core/keybinding-identity.js +10 -0
  253. package/dist/core/keybinding-identity.js.map +1 -0
  254. package/dist/core/keybindings.d.ts +37 -2
  255. package/dist/core/keybindings.d.ts.map +1 -1
  256. package/dist/core/keybindings.js +9 -2
  257. package/dist/core/keybindings.js.map +1 -1
  258. package/dist/core/mandatory-runtime-tools.d.ts +1 -1
  259. package/dist/core/mandatory-runtime-tools.js.map +1 -1
  260. package/dist/core/model-fallback-failures.js +2 -2
  261. package/dist/core/model-fallback-failures.js.map +1 -1
  262. package/dist/core/model-registry.d.ts +5 -1
  263. package/dist/core/model-registry.d.ts.map +1 -1
  264. package/dist/core/model-registry.js +8 -0
  265. package/dist/core/model-registry.js.map +1 -1
  266. package/dist/core/model-resolver-defaults.js +1 -1
  267. package/dist/core/model-resolver-defaults.js.map +1 -1
  268. package/dist/core/resource-loader-assets.js.map +1 -1
  269. package/dist/core/resource-loader-core.d.ts +1 -1
  270. package/dist/core/resource-loader-core.js.map +1 -1
  271. package/dist/core/resource-loader-internals.d.ts +2 -2
  272. package/dist/core/resource-loader-internals.js.map +1 -1
  273. package/dist/core/resource-loader-reload.d.ts +2 -0
  274. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  275. package/dist/core/resource-loader-reload.js +231 -191
  276. package/dist/core/resource-loader-reload.js.map +1 -1
  277. package/dist/core/resource-loader-types.d.ts +4 -2
  278. package/dist/core/resource-loader-types.d.ts.map +1 -1
  279. package/dist/core/resource-loader-types.js.map +1 -1
  280. package/dist/core/retry-policy.d.ts +1 -0
  281. package/dist/core/retry-policy.d.ts.map +1 -1
  282. package/dist/core/retry-policy.js +2 -1
  283. package/dist/core/retry-policy.js.map +1 -1
  284. package/dist/core/sdk-exports.d.ts +3 -3
  285. package/dist/core/sdk-exports.d.ts.map +1 -1
  286. package/dist/core/sdk-exports.js +1 -1
  287. package/dist/core/sdk-exports.js.map +1 -1
  288. package/dist/core/sdk-types.d.ts +2 -2
  289. package/dist/core/sdk-types.js.map +1 -1
  290. package/dist/core/sdk.js.map +1 -1
  291. package/dist/core/settings-manager-basic-accessors.d.ts +6 -3
  292. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  293. package/dist/core/settings-manager-basic-accessors.js +25 -8
  294. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  295. package/dist/core/settings-manager-core.d.ts.map +1 -1
  296. package/dist/core/settings-manager-core.js +10 -4
  297. package/dist/core/settings-manager-core.js.map +1 -1
  298. package/dist/core/settings-manager.d.ts +1 -1
  299. package/dist/core/settings-manager.d.ts.map +1 -1
  300. package/dist/core/settings-manager.js.map +1 -1
  301. package/dist/core/settings-storage.d.ts +1 -0
  302. package/dist/core/settings-storage.d.ts.map +1 -1
  303. package/dist/core/settings-storage.js +18 -0
  304. package/dist/core/settings-storage.js.map +1 -1
  305. package/dist/core/settings-types.d.ts +17 -0
  306. package/dist/core/settings-types.d.ts.map +1 -1
  307. package/dist/core/settings-types.js.map +1 -1
  308. package/dist/core/slash-commands.d.ts.map +1 -1
  309. package/dist/core/slash-commands.js +6 -5
  310. package/dist/core/slash-commands.js.map +1 -1
  311. package/dist/core/system-prompt.d.ts.map +1 -1
  312. package/dist/core/system-prompt.js +5 -6
  313. package/dist/core/system-prompt.js.map +1 -1
  314. package/dist/core/tasks/agent-adapter.d.ts +44 -0
  315. package/dist/core/tasks/agent-adapter.d.ts.map +1 -0
  316. package/dist/core/tasks/agent-adapter.js +112 -0
  317. package/dist/core/tasks/agent-adapter.js.map +1 -0
  318. package/dist/core/tasks/command-output.d.ts +15 -0
  319. package/dist/core/tasks/command-output.d.ts.map +1 -0
  320. package/dist/core/tasks/command-output.js +29 -0
  321. package/dist/core/tasks/command-output.js.map +1 -0
  322. package/dist/core/tasks/completion-ordering.d.ts +11 -0
  323. package/dist/core/tasks/completion-ordering.d.ts.map +1 -0
  324. package/dist/core/tasks/completion-ordering.js +19 -0
  325. package/dist/core/tasks/completion-ordering.js.map +1 -0
  326. package/dist/core/tasks/completion.d.ts +36 -0
  327. package/dist/core/tasks/completion.d.ts.map +1 -0
  328. package/dist/core/tasks/completion.js +119 -0
  329. package/dist/core/tasks/completion.js.map +1 -0
  330. package/dist/core/tasks/contracts.d.ts +404 -0
  331. package/dist/core/tasks/contracts.d.ts.map +1 -0
  332. package/dist/core/tasks/contracts.js +2 -0
  333. package/dist/core/tasks/contracts.js.map +1 -0
  334. package/dist/core/tasks/execution-scope.d.ts +10 -0
  335. package/dist/core/tasks/execution-scope.d.ts.map +1 -0
  336. package/dist/core/tasks/execution-scope.js +27 -0
  337. package/dist/core/tasks/execution-scope.js.map +1 -0
  338. package/dist/core/tasks/owner-store.d.ts +53 -0
  339. package/dist/core/tasks/owner-store.d.ts.map +1 -0
  340. package/dist/core/tasks/owner-store.js +155 -0
  341. package/dist/core/tasks/owner-store.js.map +1 -0
  342. package/dist/core/tasks/pause.d.ts +4 -0
  343. package/dist/core/tasks/pause.d.ts.map +1 -0
  344. package/dist/core/tasks/pause.js +49 -0
  345. package/dist/core/tasks/pause.js.map +1 -0
  346. package/dist/core/tasks/supervisor.d.ts +123 -0
  347. package/dist/core/tasks/supervisor.d.ts.map +1 -0
  348. package/dist/core/tasks/supervisor.js +942 -0
  349. package/dist/core/tasks/supervisor.js.map +1 -0
  350. package/dist/core/tasks/transcript.d.ts +23 -0
  351. package/dist/core/tasks/transcript.d.ts.map +1 -0
  352. package/dist/core/tasks/transcript.js +74 -0
  353. package/dist/core/tasks/transcript.js.map +1 -0
  354. package/dist/core/tools/ask-user-question/ask-user-question.d.ts +2 -2
  355. package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
  356. package/dist/core/tools/ask-user-question/ask-user-question.js +8 -4
  357. package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
  358. package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts +1 -1
  359. package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
  360. package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +1 -1
  361. package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
  362. package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts +1 -1
  363. package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
  364. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts +1 -1
  365. package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -1
  366. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +1 -1
  367. package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
  368. package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts +1 -1
  369. package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
  370. package/dist/core/tools/ask-user-question/view/components/tab-bar.d.ts +1 -1
  371. package/dist/core/tools/ask-user-question/view/components/tab-bar.js.map +1 -1
  372. package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts +1 -1
  373. package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
  374. package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts +1 -1
  375. package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
  376. package/dist/core/tools/bash-pty-native.d.ts +32 -3
  377. package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
  378. package/dist/core/tools/bash-pty-native.js +198 -1
  379. package/dist/core/tools/bash-pty-native.js.map +1 -1
  380. package/dist/core/tools/bash.d.ts +25 -5
  381. package/dist/core/tools/bash.d.ts.map +1 -1
  382. package/dist/core/tools/bash.js +100 -10
  383. package/dist/core/tools/bash.js.map +1 -1
  384. package/dist/core/tools/edit.d.ts +3 -0
  385. package/dist/core/tools/edit.d.ts.map +1 -1
  386. package/dist/core/tools/edit.js +92 -14
  387. package/dist/core/tools/edit.js.map +1 -1
  388. package/dist/core/tools/file-mutation-coordinator.d.ts +255 -0
  389. package/dist/core/tools/file-mutation-coordinator.d.ts.map +1 -0
  390. package/dist/core/tools/file-mutation-coordinator.js +300 -0
  391. package/dist/core/tools/file-mutation-coordinator.js.map +1 -0
  392. package/dist/core/tools/file-mutation-queue.d.ts +14 -1
  393. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  394. package/dist/core/tools/file-mutation-queue.js +15 -3
  395. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  396. package/dist/core/tools/find.js.map +1 -1
  397. package/dist/core/tools/grep.js.map +1 -1
  398. package/dist/core/tools/hashline.d.ts +9 -0
  399. package/dist/core/tools/hashline.d.ts.map +1 -1
  400. package/dist/core/tools/hashline.js +12 -1
  401. package/dist/core/tools/hashline.js.map +1 -1
  402. package/dist/core/tools/index.d.ts +15 -4
  403. package/dist/core/tools/index.d.ts.map +1 -1
  404. package/dist/core/tools/index.js +79 -12
  405. package/dist/core/tools/index.js.map +1 -1
  406. package/dist/core/tools/kill.d.ts +17 -0
  407. package/dist/core/tools/kill.d.ts.map +1 -0
  408. package/dist/core/tools/kill.js +49 -0
  409. package/dist/core/tools/kill.js.map +1 -0
  410. package/dist/core/tools/ls.js.map +1 -1
  411. package/dist/core/tools/non-minting-snapshot-store.d.ts +49 -0
  412. package/dist/core/tools/non-minting-snapshot-store.d.ts.map +1 -0
  413. package/dist/core/tools/non-minting-snapshot-store.js +64 -0
  414. package/dist/core/tools/non-minting-snapshot-store.js.map +1 -0
  415. package/dist/core/tools/powershell.d.ts +100 -34
  416. package/dist/core/tools/powershell.d.ts.map +1 -1
  417. package/dist/core/tools/powershell.js +41 -11
  418. package/dist/core/tools/powershell.js.map +1 -1
  419. package/dist/core/tools/read-document-extract.js.map +1 -1
  420. package/dist/core/tools/read.d.ts.map +1 -1
  421. package/dist/core/tools/read.js +1 -2
  422. package/dist/core/tools/read.js.map +1 -1
  423. package/dist/core/tools/render-utils.d.ts +1 -1
  424. package/dist/core/tools/render-utils.js.map +1 -1
  425. package/dist/core/tools/resource-selectors.d.ts +1 -1
  426. package/dist/core/tools/resource-selectors.d.ts.map +1 -1
  427. package/dist/core/tools/resource-selectors.js +21 -10
  428. package/dist/core/tools/resource-selectors.js.map +1 -1
  429. package/dist/core/tools/search.js.map +1 -1
  430. package/dist/core/tools/todos-render.d.ts +1 -1
  431. package/dist/core/tools/todos-render.js.map +1 -1
  432. package/dist/core/tools/write.d.ts +30 -1
  433. package/dist/core/tools/write.d.ts.map +1 -1
  434. package/dist/core/tools/write.js +98 -10
  435. package/dist/core/tools/write.js.map +1 -1
  436. package/dist/core/workflow-stage-admission.d.ts +24 -0
  437. package/dist/core/workflow-stage-admission.d.ts.map +1 -1
  438. package/dist/core/workflow-stage-admission.js +87 -3
  439. package/dist/core/workflow-stage-admission.js.map +1 -1
  440. package/dist/extensions/herdr/activity.d.ts +15 -0
  441. package/dist/extensions/herdr/activity.d.ts.map +1 -0
  442. package/dist/extensions/herdr/activity.js +24 -0
  443. package/dist/extensions/herdr/activity.js.map +1 -0
  444. package/dist/extensions/herdr/environment.d.ts +7 -0
  445. package/dist/extensions/herdr/environment.d.ts.map +1 -0
  446. package/dist/extensions/herdr/environment.js +6 -0
  447. package/dist/extensions/herdr/environment.js.map +1 -0
  448. package/dist/extensions/herdr/index.d.ts +9 -0
  449. package/dist/extensions/herdr/index.d.ts.map +1 -0
  450. package/dist/extensions/herdr/index.js +225 -0
  451. package/dist/extensions/herdr/index.js.map +1 -0
  452. package/dist/extensions/herdr/pane-owner.d.ts +30 -0
  453. package/dist/extensions/herdr/pane-owner.d.ts.map +1 -0
  454. package/dist/extensions/herdr/pane-owner.js +111 -0
  455. package/dist/extensions/herdr/pane-owner.js.map +1 -0
  456. package/dist/extensions/herdr/transport.d.ts +8 -0
  457. package/dist/extensions/herdr/transport.d.ts.map +1 -0
  458. package/dist/extensions/herdr/transport.js +28 -0
  459. package/dist/extensions/herdr/transport.js.map +1 -0
  460. package/dist/extensions/index.d.ts.map +1 -1
  461. package/dist/extensions/index.js +2 -0
  462. package/dist/extensions/index.js.map +1 -1
  463. package/dist/extensions/llama/huggingface-ui.d.ts +1 -1
  464. package/dist/extensions/llama/huggingface-ui.js.map +1 -1
  465. package/dist/extensions/llama/ui.js.map +1 -1
  466. package/dist/index-extensions.d.ts +3 -2
  467. package/dist/index-extensions.d.ts.map +1 -1
  468. package/dist/index-extensions.js.map +1 -1
  469. package/dist/index.d.ts +14 -5
  470. package/dist/index.d.ts.map +1 -1
  471. package/dist/index.js +10 -1
  472. package/dist/index.js.map +1 -1
  473. package/dist/main-session.js.map +1 -1
  474. package/dist/main.d.ts.map +1 -1
  475. package/dist/main.js +149 -69
  476. package/dist/main.js.map +1 -1
  477. package/dist/modes/interactive/components/armin.js.map +1 -1
  478. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  479. package/dist/modes/interactive/components/atomic-banner.d.ts +1 -1
  480. package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
  481. package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
  482. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  483. package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
  484. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  485. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  486. package/dist/modes/interactive/components/chat-message-renderer.d.ts +12 -0
  487. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  488. package/dist/modes/interactive/components/chat-message-renderer.js +44 -0
  489. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  490. package/dist/modes/interactive/components/chat-session-host-actions.d.ts +1 -1
  491. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  492. package/dist/modes/interactive/components/chat-session-host-actions.js +43 -8
  493. package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
  494. package/dist/modes/interactive/components/chat-session-host-editor.d.ts +1 -1
  495. package/dist/modes/interactive/components/chat-session-host-editor.js.map +1 -1
  496. package/dist/modes/interactive/components/chat-session-host-events.d.ts +2 -2
  497. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  498. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts +2 -2
  499. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  500. package/dist/modes/interactive/components/chat-session-host-rendering.js +12 -3
  501. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  502. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +4 -5
  503. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
  504. package/dist/modes/interactive/components/chat-session-host-runtime.js +8 -6
  505. package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
  506. package/dist/modes/interactive/components/chat-session-host-state.d.ts +7 -2
  507. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  508. package/dist/modes/interactive/components/chat-session-host-state.js +1 -0
  509. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  510. package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts +1 -1
  511. package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.js.map +1 -1
  512. package/dist/modes/interactive/components/chat-session-host-types.d.ts +8 -3
  513. package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
  514. package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
  515. package/dist/modes/interactive/components/chat-session-host-utils.d.ts +1 -1
  516. package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -1
  517. package/dist/modes/interactive/components/chat-session-host-utils.js +2 -0
  518. package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -1
  519. package/dist/modes/interactive/components/chat-session-host.d.ts +17 -2
  520. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  521. package/dist/modes/interactive/components/chat-session-host.js +100 -3
  522. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  523. package/dist/modes/interactive/components/chat-transcript.d.ts +1 -0
  524. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  525. package/dist/modes/interactive/components/chat-transcript.js +1 -1
  526. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  527. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  528. package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
  529. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  530. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  531. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  532. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  533. package/dist/modes/interactive/components/custom-message.js +12 -0
  534. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  535. package/dist/modes/interactive/components/daxnuts.js.map +1 -1
  536. package/dist/modes/interactive/components/diff.js.map +1 -1
  537. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  538. package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  539. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  540. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  541. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  542. package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
  543. package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
  544. package/dist/modes/interactive/components/footer.d.ts +7 -6
  545. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  546. package/dist/modes/interactive/components/footer.js +27 -9
  547. package/dist/modes/interactive/components/footer.js.map +1 -1
  548. package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -1
  549. package/dist/modes/interactive/components/host-input-form.d.ts +1 -1
  550. package/dist/modes/interactive/components/host-input-form.js.map +1 -1
  551. package/dist/modes/interactive/components/index.d.ts +2 -2
  552. package/dist/modes/interactive/components/index.js.map +1 -1
  553. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  554. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  555. package/dist/modes/interactive/components/mermaid.d.ts +1 -1
  556. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  557. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  558. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  559. package/dist/modes/interactive/components/reserved-bottom-overlay.js.map +1 -1
  560. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  561. package/dist/modes/interactive/components/scroll-widget.d.ts +23 -0
  562. package/dist/modes/interactive/components/scroll-widget.d.ts.map +1 -0
  563. package/dist/modes/interactive/components/scroll-widget.js +61 -0
  564. package/dist/modes/interactive/components/scroll-widget.js.map +1 -0
  565. package/dist/modes/interactive/components/session-selector-header.js.map +1 -1
  566. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  567. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  568. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  569. package/dist/modes/interactive/components/settings-selector-submenus.d.ts +1 -1
  570. package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
  571. package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -1
  572. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  573. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  574. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  575. package/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
  576. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  577. package/dist/modes/interactive/components/task-completion-message.d.ts +13 -0
  578. package/dist/modes/interactive/components/task-completion-message.d.ts.map +1 -0
  579. package/dist/modes/interactive/components/task-completion-message.js +65 -0
  580. package/dist/modes/interactive/components/task-completion-message.js.map +1 -0
  581. package/dist/modes/interactive/components/task-detail.d.ts +27 -0
  582. package/dist/modes/interactive/components/task-detail.d.ts.map +1 -0
  583. package/dist/modes/interactive/components/task-detail.js +107 -0
  584. package/dist/modes/interactive/components/task-detail.js.map +1 -0
  585. package/dist/modes/interactive/components/task-inspector.d.ts +50 -0
  586. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -0
  587. package/dist/modes/interactive/components/task-inspector.js +599 -0
  588. package/dist/modes/interactive/components/task-inspector.js.map +1 -0
  589. package/dist/modes/interactive/components/task-list.d.ts +18 -0
  590. package/dist/modes/interactive/components/task-list.d.ts.map +1 -0
  591. package/dist/modes/interactive/components/task-list.js +59 -0
  592. package/dist/modes/interactive/components/task-list.js.map +1 -0
  593. package/dist/modes/interactive/components/task-live-transcript.d.ts +17 -0
  594. package/dist/modes/interactive/components/task-live-transcript.d.ts.map +1 -0
  595. package/dist/modes/interactive/components/task-live-transcript.js +41 -0
  596. package/dist/modes/interactive/components/task-live-transcript.js.map +1 -0
  597. package/dist/modes/interactive/components/task-navigation.d.ts +38 -0
  598. package/dist/modes/interactive/components/task-navigation.d.ts.map +1 -0
  599. package/dist/modes/interactive/components/task-navigation.js +93 -0
  600. package/dist/modes/interactive/components/task-navigation.js.map +1 -0
  601. package/dist/modes/interactive/components/task-row.d.ts +34 -0
  602. package/dist/modes/interactive/components/task-row.d.ts.map +1 -0
  603. package/dist/modes/interactive/components/task-row.js +165 -0
  604. package/dist/modes/interactive/components/task-row.js.map +1 -0
  605. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  606. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  607. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  608. package/dist/modes/interactive/components/transcript-follow-indicator.js.map +1 -1
  609. package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
  610. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  611. package/dist/modes/interactive/components/tree-selector-help.js.map +1 -1
  612. package/dist/modes/interactive/components/tree-selector-label-input.js.map +1 -1
  613. package/dist/modes/interactive/components/tree-selector-list.js.map +1 -1
  614. package/dist/modes/interactive/components/trust-selector.js.map +1 -1
  615. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  616. package/dist/modes/interactive/components/user-message.js.map +1 -1
  617. package/dist/modes/interactive/components/working-status.js.map +1 -1
  618. package/dist/modes/interactive/interactive-agent-events.js +8 -2
  619. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  620. package/dist/modes/interactive/interactive-auth-login.js +3 -1
  621. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  622. package/dist/modes/interactive/interactive-autocomplete.js +9 -30
  623. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  624. package/dist/modes/interactive/interactive-deferred-startup.js +2 -1
  625. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
  626. package/dist/modes/interactive/interactive-extension-context.js +14 -4
  627. package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
  628. package/dist/modes/interactive/interactive-extension-custom-ui.js +52 -4
  629. package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
  630. package/dist/modes/interactive/interactive-extension-runtime.js +11 -3
  631. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  632. package/dist/modes/interactive/interactive-extension-widgets.js +9 -1
  633. package/dist/modes/interactive/interactive-extension-widgets.js.map +1 -1
  634. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  635. package/dist/modes/interactive/interactive-input-handling.js +19 -0
  636. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  637. package/dist/modes/interactive/interactive-mode-base.d.ts +7 -1
  638. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  639. package/dist/modes/interactive/interactive-mode-base.js +10 -4
  640. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  641. package/dist/modes/interactive/interactive-mode-deps.d.ts +6 -6
  642. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  643. package/dist/modes/interactive/interactive-mode-surface.d.ts +3 -2
  644. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  645. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  646. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  647. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  648. package/dist/modes/interactive/interactive-mode.js +3 -0
  649. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  650. package/dist/modes/interactive/interactive-process-lifecycle.js +4 -1
  651. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  652. package/dist/modes/interactive/interactive-render-chat.js +30 -4
  653. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  654. package/dist/modes/interactive/interactive-session-routing.js +33 -23
  655. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  656. package/dist/modes/interactive/interactive-session-runtime.js +1 -0
  657. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  658. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  659. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  660. package/dist/modes/interactive/interactive-startup.js +3 -0
  661. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  662. package/dist/modes/interactive/interactive-summarization-retry-events.js +2 -2
  663. package/dist/modes/interactive/interactive-summarization-retry-events.js.map +1 -1
  664. package/dist/modes/interactive/interactive-task-projection.d.ts +13 -0
  665. package/dist/modes/interactive/interactive-task-projection.d.ts.map +1 -0
  666. package/dist/modes/interactive/interactive-task-projection.js +72 -0
  667. package/dist/modes/interactive/interactive-task-projection.js.map +1 -0
  668. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  669. package/dist/modes/interactive/interactive-windows-subshell.d.ts +17 -0
  670. package/dist/modes/interactive/interactive-windows-subshell.d.ts.map +1 -0
  671. package/dist/modes/interactive/interactive-windows-subshell.js +92 -0
  672. package/dist/modes/interactive/interactive-windows-subshell.js.map +1 -0
  673. package/dist/modes/interactive/skill-command-autocomplete.d.ts +12 -0
  674. package/dist/modes/interactive/skill-command-autocomplete.d.ts.map +1 -0
  675. package/dist/modes/interactive/skill-command-autocomplete.js +69 -0
  676. package/dist/modes/interactive/skill-command-autocomplete.js.map +1 -0
  677. package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
  678. package/dist/modes/interactive/theme/theme-class.js +4 -1
  679. package/dist/modes/interactive/theme/theme-class.js.map +1 -1
  680. package/dist/modes/interactive/theme/theme-controller.d.ts +1 -1
  681. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  682. package/dist/modes/interactive-engine/activity-watchdog.d.ts +2 -2
  683. package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -1
  684. package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
  685. package/dist/modes/interactive-engine/create-isolated-runtime.d.ts +1 -1
  686. package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
  687. package/dist/modes/interactive-engine/engine-custom-ui.d.ts +9 -10
  688. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  689. package/dist/modes/interactive-engine/engine-custom-ui.js +29 -12
  690. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  691. package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts +3 -1
  692. package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts.map +1 -1
  693. package/dist/modes/interactive-engine/engine-diagnostic-view.js +11 -0
  694. package/dist/modes/interactive-engine/engine-diagnostic-view.js.map +1 -1
  695. package/dist/modes/interactive-engine/engine-dialog-host.d.ts +2 -2
  696. package/dist/modes/interactive-engine/engine-dialog-host.d.ts.map +1 -1
  697. package/dist/modes/interactive-engine/engine-dialog-host.js +4 -1
  698. package/dist/modes/interactive-engine/engine-dialog-host.js.map +1 -1
  699. package/dist/modes/interactive-engine/engine-project-trust.d.ts +10 -0
  700. package/dist/modes/interactive-engine/engine-project-trust.d.ts.map +1 -0
  701. package/dist/modes/interactive-engine/engine-project-trust.js +28 -0
  702. package/dist/modes/interactive-engine/engine-project-trust.js.map +1 -0
  703. package/dist/modes/interactive-engine/engine-render-service.d.ts +1 -1
  704. package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
  705. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +3 -1
  706. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
  707. package/dist/modes/interactive-engine/extension-ui-bridge.js +7 -1
  708. package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
  709. package/dist/modes/interactive-engine/input-form-host.d.ts +2 -2
  710. package/dist/modes/interactive-engine/input-form-host.js.map +1 -1
  711. package/dist/modes/interactive-engine/isolated-auth.d.ts +1 -1
  712. package/dist/modes/interactive-engine/isolated-auth.js.map +1 -1
  713. package/dist/modes/interactive-engine/isolated-runtime.d.ts +5 -2
  714. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  715. package/dist/modes/interactive-engine/isolated-runtime.js +42 -4
  716. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  717. package/dist/modes/interactive-engine/protocol.d.ts +21 -1
  718. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  719. package/dist/modes/interactive-engine/protocol.js +53 -2
  720. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  721. package/dist/modes/interactive-engine/remote-component.d.ts +2 -2
  722. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  723. package/dist/modes/interactive-engine/remote-component.js +19 -8
  724. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  725. package/dist/modes/interactive-engine/remote-model-catalog.d.ts +1 -1
  726. package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -1
  727. package/dist/modes/interactive-engine/remote-renderer.d.ts +1 -1
  728. package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
  729. package/dist/modes/interactive-engine/session-picker-host.d.ts +2 -2
  730. package/dist/modes/interactive-engine/session-picker-host.js.map +1 -1
  731. package/dist/modes/json-event.d.ts +1 -1
  732. package/dist/modes/json-event.js.map +1 -1
  733. package/dist/modes/print-mode.js.map +1 -1
  734. package/dist/modes/rpc/rpc-bash-request-owners.d.ts +2 -2
  735. package/dist/modes/rpc/rpc-bash-request-owners.js.map +1 -1
  736. package/dist/modes/rpc/rpc-client-api.d.ts +2 -2
  737. package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
  738. package/dist/modes/rpc/rpc-client-api.js +2 -2
  739. package/dist/modes/rpc/rpc-client-api.js.map +1 -1
  740. package/dist/modes/rpc/rpc-client-process.d.ts +2 -0
  741. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  742. package/dist/modes/rpc/rpc-client-process.js +23 -1
  743. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  744. package/dist/modes/rpc/rpc-client-waits.d.ts +1 -1
  745. package/dist/modes/rpc/rpc-client-waits.js.map +1 -1
  746. package/dist/modes/rpc/rpc-client.d.ts +3 -1
  747. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  748. package/dist/modes/rpc/rpc-client.js +40 -3
  749. package/dist/modes/rpc/rpc-client.js.map +1 -1
  750. package/dist/modes/rpc/rpc-command-handler.d.ts +4 -2
  751. package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
  752. package/dist/modes/rpc/rpc-command-handler.js +12 -4
  753. package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
  754. package/dist/modes/rpc/rpc-extension-ui.d.ts +1 -1
  755. package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
  756. package/dist/modes/rpc/rpc-extension-ui.js +2 -1
  757. package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
  758. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  759. package/dist/modes/rpc/rpc-mode.js +12 -2
  760. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  761. package/dist/modes/rpc/rpc-provider-auth.d.ts +1 -1
  762. package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
  763. package/dist/modes/rpc/rpc-session-binding.d.ts +4 -1
  764. package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
  765. package/dist/modes/rpc/rpc-session-binding.js +35 -1
  766. package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
  767. package/dist/modes/rpc/rpc-types.d.ts +17 -1
  768. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  769. package/dist/modes/rpc/rpc-types.js.map +1 -1
  770. package/dist/modes/rpc/task-ui-bridge.d.ts +9 -0
  771. package/dist/modes/rpc/task-ui-bridge.d.ts.map +1 -0
  772. package/dist/modes/rpc/task-ui-bridge.js +146 -0
  773. package/dist/modes/rpc/task-ui-bridge.js.map +1 -0
  774. package/dist/self-update-plan.js.map +1 -1
  775. package/dist/utils/markit.d.ts +2 -0
  776. package/dist/utils/markit.d.ts.map +1 -1
  777. package/dist/utils/markit.js +65 -5
  778. package/dist/utils/markit.js.map +1 -1
  779. package/docs/background-tasks.md +232 -0
  780. package/docs/build.md +51 -0
  781. package/docs/changelog.mdx +8 -8
  782. package/docs/compaction/reference.md +267 -0
  783. package/docs/compaction.md +39 -200
  784. package/docs/computer-use.md +425 -0
  785. package/docs/containerization.md +9 -5
  786. package/docs/custom-provider/api-reference.md +145 -0
  787. package/docs/custom-provider/oauth.md +131 -0
  788. package/docs/custom-provider/override.md +34 -0
  789. package/docs/custom-provider/registration.md +163 -0
  790. package/docs/custom-provider/streaming.md +214 -0
  791. package/docs/custom-provider.md +43 -607
  792. package/docs/development.md +68 -30
  793. package/docs/docs.json +199 -73
  794. package/docs/environment-variables.md +2 -2
  795. package/docs/extensions/api-reference.md +1003 -0
  796. package/docs/extensions/authoring.md +676 -0
  797. package/docs/extensions/events.md +793 -0
  798. package/docs/extensions/examples.md +94 -0
  799. package/docs/extensions/ui.md +470 -0
  800. package/docs/extensions.md +241 -2623
  801. package/docs/getting-started/authentication.md +55 -0
  802. package/docs/getting-started/first-session.md +172 -0
  803. package/docs/getting-started/installation.md +154 -0
  804. package/docs/getting-started/project-instructions.md +43 -0
  805. package/docs/guides/configuration.md +65 -0
  806. package/docs/guides/intercom.md +24 -0
  807. package/docs/guides/non-interactive.md +33 -0
  808. package/docs/guides/subagents.md +24 -0
  809. package/docs/guides/workflows.md +27 -0
  810. package/docs/guides.md +41 -0
  811. package/docs/herdr.md +55 -0
  812. package/docs/index.md +13 -44
  813. package/docs/intercom/operations.md +178 -0
  814. package/docs/intercom/reference.md +150 -0
  815. package/docs/intercom.md +61 -251
  816. package/docs/json.md +17 -0
  817. package/docs/keybindings.md +36 -2
  818. package/docs/llama-cpp.md +5 -0
  819. package/docs/models/artificial-analysis-index.md +89 -0
  820. package/docs/models/evals.md +225 -148
  821. package/docs/models/model-selection.md +30 -21
  822. package/docs/models/pareto-efficiency.md +4 -4
  823. package/docs/models/reference.md +601 -0
  824. package/docs/models.md +45 -550
  825. package/docs/packages/authoring.md +88 -0
  826. package/docs/packages/reference.md +43 -0
  827. package/docs/packages.md +28 -107
  828. package/docs/programmatic.md +29 -0
  829. package/docs/prompt-templates.md +11 -0
  830. package/docs/providers/reference.md +23 -0
  831. package/docs/providers.md +59 -62
  832. package/docs/quickstart.md +45 -239
  833. package/docs/reference/cli.md +252 -0
  834. package/docs/reference.md +52 -0
  835. package/docs/rpc/examples.md +64 -0
  836. package/docs/rpc/extension-ui.md +198 -0
  837. package/docs/rpc/protocol.md +1341 -0
  838. package/docs/rpc.md +109 -1346
  839. package/docs/sdk/reference.md +1090 -0
  840. package/docs/sdk.md +64 -756
  841. package/docs/session-format.md +2 -0
  842. package/docs/sessions.md +6 -10
  843. package/docs/settings.md +45 -48
  844. package/docs/skills/authoring.md +95 -0
  845. package/docs/skills/reference.md +60 -0
  846. package/docs/skills.md +37 -117
  847. package/docs/subagents/authoring.md +37 -0
  848. package/docs/subagents/reference.md +60 -0
  849. package/docs/subagents.md +90 -78
  850. package/docs/terminal-setup.md +1 -1
  851. package/docs/themes/reference.md +176 -0
  852. package/docs/themes.md +25 -135
  853. package/docs/tmux.md +7 -0
  854. package/docs/tools/edit.md +5 -0
  855. package/docs/tools.md +67 -1
  856. package/docs/tui/reference.md +343 -0
  857. package/docs/tui.md +83 -285
  858. package/docs/usage.md +31 -210
  859. package/docs/web-access.md +50 -0
  860. package/docs/windows.md +6 -5
  861. package/docs/workflows/api-reference.md +31 -12
  862. package/docs/workflows/authoring.md +7 -5
  863. package/docs/workflows/builtins.md +11 -8
  864. package/docs/workflows/operations.md +117 -39
  865. package/docs/workflows/reliable-design.md +59 -10
  866. package/docs/workflows/verification.md +116 -32
  867. package/docs/workflows.md +7 -3
  868. package/examples/extensions/gondolin/index.ts +116 -148
  869. package/examples/extensions/gondolin/package.json +1 -1
  870. package/examples/extensions/ssh.ts +56 -34
  871. package/npm-shrinkwrap.json +798 -678
  872. package/package.json +11 -11
  873. /package/dist/builtin/workflows/builtin/{chunk-cg9tmks0.js → chunk-n1910xc4.js} +0 -0
  874. /package/dist/builtin/workflows/builtin/{chunk-wpckd35c.js → chunk-rc5ec5xx.js} +0 -0
  875. /package/dist/builtin/workflows/builtin/{chunk-7at6dnkr.js → chunk-tgt0s5e5.js} +0 -0
  876. /package/dist/builtin/workflows/builtin/{chunk-bfkmzv9h.js → chunk-xtxcq5tj.js} +0 -0
@@ -29,32 +29,48 @@ Extensions are TypeScript modules that extend Atomic's behavior. They can subscr
29
29
 
30
30
  See [examples/extensions/](https://github.com/bastani-inc/atomic/tree/main/packages/coding-agent/examples/extensions) for working implementations.
31
31
 
32
+ Atomic also ships an environment-gated [Herdr reporter](/herdr). It combines settled agent activity, extension prompt events, and observed workflow roots under one parent pane owner. It defers to loaded community or legacy reporters and can be disabled with `herdr.enabled` in settings. See [Herdr setup](/herdr#setup) for the supported version and [status indicators](/herdr#status-indicators) for reported activity.
33
+
34
+ ## Where to go next
35
+
36
+ Extensions are TypeScript modules that add tools, commands, event handlers, and custom UI. Read this page for startup behavior, locations, imports, and a first extension, then continue:
37
+
38
+ - [Writing extensions](/extensions/authoring) — build one, manage its state, and register custom tools.
39
+ - [Extension events](/extensions/events) — every event, its payload, and its return contract.
40
+ - [Extension UI](/extensions/ui) — render custom UI from an extension.
41
+ - [Extension API reference](/extensions/api-reference) — `ExtensionContext`, `ExtensionCommandContext`, `ExtensionAPI` methods, and error handling.
42
+ - [Extension examples](/extensions/examples) — runnable examples shipped with Atomic.
43
+ - [Security](/security) — the project-trust boundary that decides whether a project's extensions load, and what an extension can reach once it does. Read this before installing an extension you did not write.
44
+
45
+ If an extension is heavier than you need, compare the lighter mechanisms on [Build with Atomic](/build).
46
+
32
47
  ## Table of Contents
33
48
 
34
- - [Startup and lazy discovery](#startup-and-lazy-discovery)
35
- - [Interactive callback isolation](#interactive-callback-isolation)
36
- - [Quick Start](#quick-start)
37
- - [Extension Locations](#extension-locations)
38
- - [Available Imports](#available-imports)
39
- - [Writing an Extension](#writing-an-extension)
40
- - [Extension Styles](#extension-styles)
41
- - [Events](#events)
42
- - [Lifecycle Overview](#lifecycle-overview)
43
- - [Resource Events](#resource-events)
44
- - [Session Events](#session-events)
45
- - [Agent Events](#agent-events)
46
- - [Model Events](#model-events)
47
- - [Tool Events](#tool-events)
48
- - [ExtensionContext](#extensioncontext)
49
- - [ExtensionCommandContext](#extensioncommandcontext)
50
- - [ExtensionAPI Methods](#extensionapi-methods)
51
- - [State Management](#state-management)
52
- - [Session-scoped in-memory state](#session-scoped-in-memory-state)
53
- - [Custom Tools](#custom-tools)
54
- - [Custom UI](#custom-ui)
55
- - [Error Handling](#error-handling)
56
- - [Mode Behavior](#mode-behavior)
57
- - [Examples Reference](#examples-reference)
49
+ - [Startup and lazy discovery](/extensions#startup-and-lazy-discovery)
50
+ - [Interactive callback isolation](/extensions#interactive-callback-isolation)
51
+ - [Quick Start](/extensions#quick-start)
52
+ - [Extension Locations](/extensions#extension-locations)
53
+ - [Available Imports](/extensions#available-imports)
54
+ - [Writing an Extension](/extensions/authoring#writing-an-extension)
55
+ - [Extension Styles](/extensions/authoring#extension-styles)
56
+ - [Events](/extensions/events#events)
57
+ - [Lifecycle Overview](/extensions/events#lifecycle-overview)
58
+ - [Resource Events](/extensions/events#resource-events)
59
+ - [Session Events](/extensions/events#session-events)
60
+ - [Agent Events](/extensions/events#agent-events)
61
+ - [Model Events](/extensions/events#model-events)
62
+ - [Tool Events](/extensions/events#tool-events)
63
+ - [Workflow activity and lifecycle hooks](/extensions/events#workflow-activity-and-lifecycle-hooks)
64
+ - [ExtensionContext](/extensions/api-reference#extensioncontext)
65
+ - [ExtensionCommandContext](/extensions/api-reference#extensioncommandcontext)
66
+ - [ExtensionAPI Methods](/extensions/api-reference#extensionapi-methods)
67
+ - [State Management](/extensions/authoring#state-management)
68
+ - [Session-scoped in-memory state](/extensions/authoring#session-scoped-in-memory-state)
69
+ - [Custom Tools](/extensions/authoring#custom-tools)
70
+ - [Custom UI](/extensions/ui#custom-ui)
71
+ - [Error Handling](/extensions/api-reference#error-handling)
72
+ - [Mode Behavior](/extensions#mode-behavior)
73
+ - [Examples Reference](/extensions/examples#examples-reference)
58
74
 
59
75
  ## Startup and lazy discovery
60
76
 
@@ -106,9 +122,9 @@ The engine child is launched with an environment that never contains Atomic's en
106
122
 
107
123
  Dialogs and `ctx.ui.custom()` components are proxied to the host as rendered lines with asynchronous input forwarding. Custom UI results must be JSON-safe. APIs that require a synchronous callback in the terminal process—raw `onTerminalInput` transforms, synchronous `getEditorText`, custom editor factories, autocomplete wrappers, component-factory widgets, and custom header/footer factories—are unavailable in isolated interactive mode and produce a warning rather than executing extension code in the host. Print and public RPC modes retain their existing execution model.
108
124
 
109
- For session-style list pickers use `ctx.ui.hostSessionPicker(request)` instead of remote-rendering a selector through `ctx.ui.custom()`: the terminal host mounts the real built-in session selector natively, fed with JSON-safe rows (`HostSessionPickerRow`: `SessionInfo` with `createdAt`/`modifiedAt` epoch millis). Arrow-key navigation and search never cross the process boundary; only semantic events do — the returned handle exposes `result` (resolves with the selected row's `path`, or `undefined` on cancel), `update(rows)`, `error(message)`, and `close()`, and the request's `onDelete(path)` callback owns deletion (the host keeps the row until the extension replies with `update` or `error`). Every interactive host implements the identical API — in-process (no IPC) when not isolated, over the engine protocol when isolated — so callers never branch; the member is absent only on non-interactive surfaces (headless RPC, print), where commands should fail with an actionable error. See [Host-native session picker](/tui#host-native-session-picker) for an example.
125
+ For session-style list pickers use `ctx.ui.hostSessionPicker(request)` instead of remote-rendering a selector through `ctx.ui.custom()`: the terminal host mounts the real built-in session selector natively, fed with JSON-safe rows (`HostSessionPickerRow`: `SessionInfo` with `createdAt`/`modifiedAt` epoch millis). Arrow-key navigation and search never cross the process boundary; only semantic events do — the returned handle exposes `result` (resolves with the selected row's `path`, or `undefined` on cancel), `update(rows)`, `error(message)`, and `close()`, and the request's `onDelete(path)` callback owns deletion (the host keeps the row until the extension replies with `update` or `error`). Every interactive host implements the identical API — in-process (no IPC) when not isolated, over the engine protocol when isolated — so callers never branch; the member is absent only on non-interactive surfaces (headless RPC, print), where commands should fail with an actionable error. See [Host-native session picker](/tui/reference#host-native-session-picker) for an example.
110
126
 
111
- For structured forms use `ctx.ui.hostInputForm(request)`. It accepts JSON-safe field descriptors (`string`, `text`, `number`, `integer`, `boolean`, or `select`, each with a raw `initialValue`) and resolves to a raw string record or `undefined` on cancellation. The terminal host owns the component, focus, validation, configured-keybinding handling, and mutable text state, so Tab, arrows, editing, Enter, Escape, and Ctrl+C are host-local rather than asynchronously forwarded to the engine child. Both interactive modes expose the same optional API; headless RPC and print omit it. See [Host-native input form](/tui#host-native-input-form).
127
+ For structured forms use `ctx.ui.hostInputForm(request)`. It accepts JSON-safe field descriptors (`string`, `text`, `number`, `integer`, `boolean`, or `select`, each with a raw `initialValue`) and resolves to a raw string record or `undefined` on cancellation. The terminal host owns the component, focus, validation, configured-keybinding handling, and mutable text state, so Tab, arrows, editing, Enter, Escape, and Ctrl+C are host-local rather than asynchronously forwarded to the engine child. Both interactive modes expose the same optional API; headless RPC and print omit it. See [Host-native input form](/tui/reference#host-native-input-form).
112
128
 
113
129
  ## Quick Start
114
130
 
@@ -220,2793 +236,471 @@ Node.js built-ins (`node:fs`, `node:path`, etc.) are also available.
220
236
 
221
237
  ## Writing an Extension
222
238
 
223
- An extension exports a default factory function that receives `ExtensionAPI`. The factory can be synchronous or asynchronous:
224
-
225
- ```typescript
226
- import type { ExtensionAPI } from "@bastani/atomic";
227
-
228
- export default function (pi: ExtensionAPI) {
229
- // Subscribe to events
230
- pi.on("event_name", async (event, ctx) => {
231
- // ctx.ui for user interaction
232
- const ok = await ctx.ui.confirm("Title", "Are you sure?");
233
- ctx.ui.notify("Done!", "info");
234
- ctx.ui.setStatus("my-ext", "Processing..."); // Footer status
235
- ctx.ui.setWidget("my-ext", ["Line 1", "Line 2"]); // Widget above editor (default)
236
- });
237
-
238
- // Register tools, commands, shortcuts, flags
239
- pi.registerTool({ ... });
240
- pi.registerCommand("name", { ... });
241
- pi.registerShortcut("ctrl+x", { ... });
242
- pi.registerFlag("my-flag", { ... });
243
- }
244
- ```
245
-
246
- Editable user, project, and package extensions and user workflows are loaded through [jiti](https://github.com/unjs/jiti), so TypeScript works without compilation. `/reload` uses content-hash invalidation across the complete imported file graph: an unchanged graph can reuse its evaluated factory, while a direct edit or a transitive dependency edit re-evaluates that extension's modules.
247
-
248
- In Bun compiled or bundled single-file builds, Atomic's five fixed installed builtin extension bundles (workflows, subagents, MCP, web access, and Intercom) take a separate startup path. Atomic installs its live host-module bridge, imports each precompiled bundle natively once, and reuses the evaluated factory across `/reload`. This avoids jiti source reads, transforms, hashing, and graph manifests for immutable shipped code. A builtin bundle's module-scoped state is therefore **not** re-evaluated by `/reload` in those builds. This optimization is limited to exact installed entries of identity-verified Atomic packages; editable extensions and workflows retain the dynamic behavior above.
249
-
250
- If the factory returns a `Promise`, Atomic awaits it before continuing startup. That means async initialization completes before `session_start`, before `resources_discover`, and before provider registrations queued via `pi.registerProvider()` are flushed.
239
+ Moved to [Writing extensions](/extensions/authoring#writing-an-extension).
251
240
 
252
241
  ### Async factory functions
253
242
 
254
- Use an async factory for one-time startup work such as fetching remote configuration or dynamically discovering available models.
255
-
256
- ```typescript
257
- import type { ExtensionAPI } from "@bastani/atomic";
258
-
259
- export default async function (pi: ExtensionAPI) {
260
- const response = await fetch("http://localhost:1234/v1/models");
261
- const payload = (await response.json()) as {
262
- data: Array<{
263
- id: string;
264
- name?: string;
265
- context_window?: number;
266
- max_tokens?: number;
267
- }>;
268
- };
269
-
270
- pi.registerProvider("local-openai", {
271
- baseUrl: "http://localhost:1234/v1",
272
- apiKey: "$LOCAL_OPENAI_API_KEY",
273
- api: "openai-completions",
274
- models: payload.data.map((model) => ({
275
- id: model.id,
276
- name: model.name ?? model.id,
277
- reasoning: false,
278
- input: ["text"],
279
- cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
280
- contextWindow: model.context_window ?? 128000,
281
- maxTokens: model.max_tokens ?? 4096,
282
- })),
283
- });
284
- }
285
- ```
286
-
287
- This pattern makes the fetched models available during normal startup and to `atomic --list-models`.
243
+ Moved to [Writing extensions](/extensions/authoring#async-factory-functions).
288
244
 
289
245
  ### Long-lived resources and shutdown
290
246
 
291
- Extension factories may run in invocations that never start a session, such as metadata commands or early configuration checks. Do not start background resources such as processes, sockets, file watchers, or timers from the factory.
292
-
293
- Defer background resource startup until `session_start` or the command/tool/event that needs the resource. Register an idempotent `session_shutdown` handler to close any session-scoped resources you start.
247
+ Moved to [Writing extensions](/extensions/authoring#long-lived-resources-and-shutdown).
294
248
 
295
249
  ### Extension Styles
296
250
 
297
- **Single file** - simplest, for small extensions:
298
-
299
- ```
300
- ~/.atomic/agent/extensions/
301
- └── my-extension.ts
302
- ```
303
-
304
- **Directory with index.ts** - for multi-file extensions:
305
-
306
- ```
307
- ~/.atomic/agent/extensions/
308
- └── my-extension/
309
- ├── index.ts # Entry point (exports default function)
310
- ├── tools.ts # Helper module
311
- └── utils.ts # Helper module
312
- ```
313
-
314
- **Package with dependencies** - for extensions that need npm packages:
315
-
316
- ```
317
- ~/.atomic/agent/extensions/
318
- └── my-extension/
319
- ├── package.json # Declares dependencies and entry points
320
- ├── bun.lock
321
- ├── node_modules/ # After dependency install
322
- └── src/
323
- └── index.ts
324
- ```
325
-
326
- ```json
327
- // package.json
328
- {
329
- "name": "my-extension",
330
- "dependencies": {
331
- "zod": "^3.0.0",
332
- "chalk": "^5.0.0"
333
- },
334
- "atomic": {
335
- "extensions": ["./src/index.ts"]
336
- }
337
- }
338
- ```
339
-
340
- The manifest key is the configured Atomic app name (`atomic` here, from the running Atomic package/config), not the extension package's own `"name"` field. The legacy `pi` key is still accepted as a compatibility shim. Run `bun install` in the extension directory, then imports from `node_modules/` work automatically.
251
+ Moved to [Writing extensions](/extensions/authoring#extension-styles).
341
252
 
342
253
  ## Events
343
254
 
255
+ Moved to [Extension events](/extensions/events#events).
256
+
344
257
  ### Lifecycle Overview
345
258
 
346
- ```
347
- Atomic starts
348
-
349
- ├─► project_trust (user/global and CLI extensions only, before project resources load)
350
- ├─► session_start { reason: "startup" }
351
- └─► resources_discover { reason: "startup" }
352
-
353
-
354
- user sends prompt ─────────────────────────────────────────┐
355
- │ │
356
- ├─► (extension commands checked first, bypass if found) │
357
- ├─► input (can intercept, transform, or handle) │
358
- ├─► (skill/template expansion if not handled) │
359
- ├─► before_agent_start (can inject message, modify system prompt)
360
- ├─► agent_start │
361
- ├─► message_start / message_update / message_end │
362
- │ │
363
- │ ┌─── turn (repeats while LLM calls tools) ───┐ │
364
- │ │ │ │
365
- │ ├─► turn_start │ │
366
- │ ├─► context (can modify messages) │ │
367
- │ ├─► before_provider_request (can inspect or replace payload)
368
- │ ├─► after_provider_response (status + headers, before stream consume)
369
- │ │ │ │
370
- │ │ LLM responds, may call tools: │ │
371
- │ │ ├─► tool_execution_start │ │
372
- │ │ ├─► tool_call (can block) │ │
373
- │ │ ├─► tool_execution_update │ │
374
- │ │ ├─► tool_result (can modify) │ │
375
- │ │ └─► tool_execution_end │ │
376
- │ │ │ │
377
- │ ├─► turn_end │ │
378
- │ └─► post-tool threshold preflight │ │
379
- │ (may compact before the next provider request) │
380
- └─► agent_end │
381
-
382
- user sends another prompt ◄────────────────────────────────┘
383
-
384
- /new (new session) or /resume (switch session)
385
- ├─► session_before_switch (can cancel)
386
- ├─► session_shutdown
387
- ├─► session_start { reason: "new" | "resume", previousSessionFile? }
388
- └─► resources_discover { reason: "startup" }
389
-
390
- /fork or /clone
391
- ├─► session_before_fork (can cancel)
392
- ├─► session_shutdown
393
- ├─► session_start { reason: "fork", previousSessionFile }
394
- └─► resources_discover { reason: "startup" }
395
-
396
- /compact or auto-compaction
397
- ├─► compaction_start / compaction_end (verbatim line-compaction status)
398
- ├─► session_before_compact (can cancel or provide compactedText)
399
- ├─► session_compact (after the compaction boundary is persisted)
400
- └─► session_compact_failed (failure or cancellation)
401
-
402
- /tree navigation
403
- ├─► session_before_tree (can cancel or customize)
404
- └─► session_tree
405
-
406
- /model or CTRL+P (model selection/cycling)
407
- ├─► thinking_level_select (if model change changes/clamps thinking level)
408
- └─► model_select
409
-
410
- thinking level changes (settings, keybinding, pi.setThinkingLevel())
411
- └─► thinking_level_select
412
-
413
- exit (CTRL+C, CTRL+D, SIGHUP, SIGTERM)
414
- └─► session_shutdown
415
- ```
259
+ Moved to [Extension events](/extensions/events#lifecycle-overview).
416
260
 
417
261
  ### Startup Events
418
262
 
419
- #### project_trust
420
-
421
- 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 cwd whose trust has not been resolved in the current process. Only user/global extensions and CLI `-e` extensions participate; project-local extensions are not loaded until after trust is resolved.
263
+ Moved to [Extension events](/extensions/events#startup-events).
422
264
 
423
- ```typescript
424
- pi.on("project_trust", async (event, ctx) => {
425
- // event.cwd - current working directory
426
- // ctx has a limited trust context: cwd, mode, hasUI, and select/confirm/input/notify UI helpers
427
- if (ctx.hasUI && await ctx.ui.confirm("Trust project?", event.cwd)) {
428
- return { trusted: "yes", remember: true };
429
- }
430
- return { trusted: "undecided" };
431
- });
432
- ```
265
+ #### project_trust
433
266
 
434
- A `project_trust` handler must return `{ trusted: "yes" | "no" | "undecided" }`. A user/global or CLI extension that returns `"yes"` or `"no"` owns the decision; the first yes/no decision wins and suppresses the built-in trust prompt. Use `remember: true` to persist a yes/no decision; otherwise it applies only to the current process. Return `"undecided"` to let later handlers or the built-in trust flow decide. Check `ctx.hasUI` before prompting. If no handler returns yes/no, normal trust resolution continues: saved `trust.json` decisions apply first, then `defaultProjectTrust` controls whether Atomic asks, trusts, or declines by default.
267
+ Moved to [Extension events](/extensions/events#project_trust).
435
268
 
436
269
  ### Resource Events
437
270
 
438
- #### resources_discover
271
+ Moved to [Extension events](/extensions/events#resource-events).
439
272
 
440
- Fired after `session_start` so extensions can contribute additional skill, prompt, and theme paths.
441
- The startup path uses `reason: "startup"`. Reload uses `reason: "reload"`.
273
+ #### resources_discover
442
274
 
443
- ```typescript
444
- pi.on("resources_discover", async (event, _ctx) => {
445
- // event.cwd - current working directory
446
- // event.reason - "startup" | "reload"
447
- return {
448
- skillPaths: ["/path/to/skills"],
449
- promptPaths: ["/path/to/prompts"],
450
- themePaths: ["/path/to/themes"],
451
- };
452
- });
453
- ```
275
+ Moved to [Extension events](/extensions/events#resources_discover).
454
276
 
455
277
  ### Session Events
456
278
 
457
- See [Session Format](/session-format) for session storage internals and the SessionManager API.
279
+ Moved to [Extension events](/extensions/events#session-events).
458
280
 
459
281
  #### session_start
460
282
 
461
- Fired when a session is started, loaded, or reloaded.
462
-
463
- ```typescript
464
- pi.on("session_start", async (event, ctx) => {
465
- // event.reason - "startup" | "reload" | "new" | "resume" | "fork"
466
- // event.previousSessionFile - present for "new", "resume", and "fork"
467
- ctx.ui.notify(`Session: ${ctx.sessionManager.getSessionFile() ?? "ephemeral"}`, "info");
468
- });
469
- ```
283
+ Moved to [Extension events](/extensions/events#session_start).
470
284
 
471
285
  #### session_info_changed
472
286
 
473
- Fired when the current session display name is set via `/name`, RPC, or `pi.setSessionName()`.
474
-
475
- ```typescript
476
- pi.on("session_info_changed", async (event, ctx) => {
477
- // event.name - current normalized name, or undefined if cleared
478
- ctx.ui.notify(`Session renamed: ${event.name ?? "(none)"}`, "info");
479
- });
480
- ```
287
+ Moved to [Extension events](/extensions/events#session_info_changed).
481
288
 
482
289
  #### session_before_switch
483
290
 
484
- Fired before starting a new session (`/new`) or switching sessions (`/resume`).
485
-
486
- ```typescript
487
- pi.on("session_before_switch", async (event, ctx) => {
488
- // event.reason - "new" or "resume"
489
- // event.targetSessionFile - session we're switching to (only for "resume")
490
-
491
- if (event.reason === "new") {
492
- const ok = await ctx.ui.confirm("Clear?", "Delete all messages?");
493
- if (!ok) return { cancel: true };
494
- }
495
- });
496
- ```
497
-
498
- 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 `previousSessionFile`.
499
- Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `session_start`.
291
+ Moved to [Extension events](/extensions/events#session_before_switch).
500
292
 
501
293
  #### session_before_fork
502
294
 
503
- Fired when forking via `/fork` or cloning via `/clone`.
504
-
505
- ```typescript
506
- pi.on("session_before_fork", async (event, ctx) => {
507
- // event.entryId - ID of the selected entry
508
- // event.position - "before" for /fork, "at" for /clone
509
- return { cancel: true }; // Cancel fork/clone
510
- // OR
511
- return { skipConversationRestore: true }; // Reserved for future conversation restore control
512
- });
513
- ```
514
-
515
- 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 `previousSessionFile`.
516
- Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `session_start`.
295
+ Moved to [Extension events](/extensions/events#session_before_fork).
517
296
 
518
297
  #### session_before_compact / session_compact / session_compact_failed
519
298
 
520
- Fired by `/compact` and auto-compaction, including a threshold crossing detected after tool results enter the prospective next-turn context. Atomic prepares the complete active transcript except for the exact newest `preserve_recent` context-visible messages. Extensions may cancel or provide a complete, non-empty `compactedText` replacement for that region; they cannot move `firstKeptEntryId`. The override is persisted verbatim and works without provider credentials. A successful post-tool compaction returns its rebuilt context directly to the already-active Pi loop; it does not start a separate continuation. Cancellation or failure prevents that loop's follow-up provider request.
521
-
522
- ```typescript
523
- pi.on("session_before_compact", async (event) => {
524
- const { preparation, branchEntries, parameters, reason, signal } = event;
525
-
526
- // preparation.region.lines - unnumbered compactable transcript lines
527
- // preparation.firstKeptEntryId - fixed start of the exact tail, or null when the tail is empty
528
- // preparation.tokensBefore - whole-context token estimate
529
- // parameters - compression_ratio, preserve_recent, query
530
- // branchEntries - raw entries on the active branch
531
- // reason - "manual" | "threshold" | "overflow"
532
- // preparation is a deep-frozen clone
533
-
534
- if (signal.aborted) return { cancel: true };
535
-
536
- // Cancel compaction:
537
- return { cancel: true };
538
-
539
- // Or replace only the prepared region. Whitespace-only text is rejected.
540
- return {
541
- compactedText: preparation.region.lines.slice(0, 40).join("\n"),
542
- };
543
- });
544
-
545
- pi.on("session_compact", async (event) => {
546
- // event.result - VerbatimCompactionResult (text, boundary, stats, parameters, rung)
547
- // event.compactionEntry - saved CompactionEntry with strategy "verbatim-lines"
548
- // event.fromExtension - true when session_before_compact provided compactedText
549
- // Observe-only: errors are isolated after persistence.
550
- });
551
-
552
- pi.on("session_compact_failed", async (event) => {
553
- // event.reason - "manual" | "threshold" | "overflow"
554
- // event.errorMessage - absent for cancellation
555
- // event.aborted / event.willRetry - terminal state
556
- // event.fromExtension - whether extension-provided text was active
557
- });
558
- ```
299
+ Moved to [Extension events](/extensions/events#session_before_compact-/-session_compact-/-session_compact_failed).
559
300
 
560
301
  #### session_before_tree / session_tree
561
302
 
562
- Fired on `/tree` navigation. See [Sessions](/sessions) for tree navigation concepts.
563
-
564
- ```typescript
565
- pi.on("session_before_tree", async (event, ctx) => {
566
- const { preparation, signal } = event;
567
- return { cancel: true };
568
- // OR provide custom summary:
569
- return { summary: { summary: "...", details: {} } };
570
- });
571
-
572
- pi.on("session_tree", async (event, ctx) => {
573
- // event.newLeafId, oldLeafId, summaryEntry, fromExtension
574
- });
575
- ```
303
+ Moved to [Extension events](/extensions/events#session_before_tree-/-session_tree).
576
304
 
577
305
  #### session_shutdown
578
306
 
579
- Fired before a started session runtime is torn down. Use this to clean up resources opened from `session_start` or other session-scoped hooks.
580
-
581
- ```typescript
582
- pi.on("session_shutdown", async (event, ctx) => {
583
- // event.reason - "quit" | "reload" | "new" | "resume" | "fork"
584
- // event.targetSessionFile - destination session for session replacement flows
585
- // Cleanup, save state, etc.
586
- });
587
- ```
307
+ Moved to [Extension events](/extensions/events#session_shutdown).
588
308
 
589
309
  ### Agent Events
590
310
 
591
- #### before_agent_start
592
-
593
- Fired after user submits prompt, before agent loop. Can inject a message and/or modify the system prompt.
311
+ Moved to [Extension events](/extensions/events#agent-events).
594
312
 
595
- ```typescript
596
- pi.on("before_agent_start", async (event, ctx) => {
597
- // event.prompt - user's prompt text
598
- // event.images - attached images (if any)
599
- // event.systemPrompt - current chained system prompt for this handler
600
- // (includes changes from earlier before_agent_start handlers)
601
- // event.systemPromptOptions - structured options used to build the system prompt
602
- // .customPrompt - any custom system prompt (from --system-prompt, SYSTEM.md, or custom templates)
603
- // .selectedTools - tools currently active in the prompt
604
- // .toolSnippets - one-line descriptions for each tool
605
- // .promptGuidelines - custom guideline bullets
606
- // .appendSystemPrompt - text from --append-system-prompt flags
607
- // .cwd - working directory
608
- // .contextFiles - AGENTS.md files and other loaded context files
609
- // .skills - loaded skills
610
-
611
- return {
612
- // Inject a persistent message (stored in session, sent to LLM)
613
- message: {
614
- customType: "my-extension",
615
- content: "Additional context for the LLM",
616
- display: true,
617
- },
618
- // Replace the system prompt for this turn (chained across extensions)
619
- systemPrompt: event.systemPrompt + "\n\nExtra instructions for this turn...",
620
- };
621
- });
622
- ```
623
-
624
- The `systemPromptOptions` field gives extensions access to the same structured data Atomic uses to build the system prompt. This lets you inspect what Atomic has loaded — custom prompts, guidelines, tool snippets, context files, skills — without re-discovering resources or re-parsing flags. Use it when your extension needs to make deep, informed changes to the system prompt while respecting user-provided configuration.
313
+ #### before_agent_start
625
314
 
626
- 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.
315
+ Moved to [Extension events](/extensions/events#before_agent_start).
627
316
 
628
317
  #### agent_start / agent_end / agent_settled
629
318
 
630
- `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. Use `agent_settled` when a status integration needs to know Atomic has no automatic continuation left.
631
-
632
- ```typescript
633
- pi.on("agent_start", async (_event, ctx) => {});
634
- pi.on("agent_end", async (event, ctx) => {
635
- // event.messages - messages from this low-level run
636
- });
637
- pi.on("agent_settled", async (_event, ctx) => {
638
- // ctx.isIdle() is true unless another extension started a run.
639
- });
640
- ```
319
+ Moved to [Extension events](/extensions/events#agent_start-/-agent_end-/-agent_settled).
641
320
 
642
321
  #### ui_prompt_start / ui_prompt_end
643
322
 
644
- These notification-only events wrap blocking user-facing extension prompts opened through `ctx.ui.select()`, `ctx.ui.confirm()`, `ctx.ui.input()`, `ctx.ui.editor()`, and `ctx.ui.custom()`. Each event has `reason: "ui_prompt"`, the prompt `kind`, and the prompt `title` when that method accepts one. Host and status integrations can use the pair to report that Atomic is waiting for the user instead of still working.
323
+ Moved to [Extension events](/extensions/events#ui_prompt_start-/-ui_prompt_end).
645
324
 
646
- Atomic coalesces nested or overlapping prompts into one outer span. The end event keeps the outer prompt's kind and title and fires after every prompt in that span settles, including rejected promises and synchronous failures. Rebinding the host UI context closes an active span before a prompt from the new context can begin.
325
+ #### turn_start / turn_end
647
326
 
648
- Handlers run best-effort from the microtask queue. Atomic does not await them before opening or closing the prompt, so a slow handler cannot delay the UI.
327
+ Moved to [Extension events](/extensions/events#turn_start-/-turn_end).
649
328
 
650
- ```typescript
651
- pi.on("ui_prompt_start", (event) => {
652
- // event.kind - "select" | "confirm" | "input" | "editor" | "custom"
653
- // event.title - prompt title when available
654
- });
655
-
656
- pi.on("ui_prompt_end", (event) => {
657
- // Atomic is no longer waiting on this outer prompt span.
658
- });
659
- ```
329
+ #### message_start / message_update / message_end
660
330
 
661
- #### turn_start / turn_end
331
+ Moved to [Extension events](/extensions/events#message_start-/-message_update-/-message_end).
662
332
 
663
- Fired for each turn (one LLM response + tool calls).
333
+ #### tool_execution_start / tool_execution_update / tool_execution_end
664
334
 
665
- ```typescript
666
- pi.on("turn_start", async (event, ctx) => {
667
- // event.turnIndex, event.timestamp
668
- });
335
+ Moved to [Extension events](/extensions/events#tool_execution_start-/-tool_execution_update-/-tool_execution_end).
669
336
 
670
- pi.on("turn_end", async (event, ctx) => {
671
- // event.turnIndex, event.message, event.toolResults
672
- });
673
- ```
337
+ #### context
674
338
 
675
- #### message_start / message_update / message_end
339
+ Moved to [Extension events](/extensions/events#context).
676
340
 
677
- Fired for message lifecycle updates.
341
+ #### before_provider_headers
678
342
 
679
- - `message_start` and `message_end` fire for user, assistant, and toolResult messages.
680
- - `message_update` fires for assistant streaming updates.
681
- - `message_end` handlers can return `{ message }` to replace the finalized message. The replacement must keep the same `role`.
343
+ Moved to [Extension events](/extensions/events#before_provider_headers).
682
344
 
683
- ```typescript
684
- pi.on("message_start", async (event, ctx) => {
685
- // event.message
686
- });
687
-
688
- pi.on("message_update", async (event, ctx) => {
689
- // event.assistantMessageEvent (token-by-token delta; no cumulative message)
690
- });
691
-
692
- pi.on("message_end", async (event, ctx) => {
693
- if (event.message.role !== "assistant") return;
694
-
695
- return {
696
- message: {
697
- ...event.message,
698
- usage: {
699
- ...event.message.usage,
700
- cost: {
701
- ...event.message.usage.cost,
702
- total: 0.123,
703
- },
704
- },
705
- },
706
- };
707
- });
708
- ```
345
+ #### before_provider_request
709
346
 
710
- #### tool_execution_start / tool_execution_update / tool_execution_end
347
+ Moved to [Extension events](/extensions/events#before_provider_request).
711
348
 
712
- Fired for tool execution lifecycle updates.
349
+ #### after_provider_response
713
350
 
714
- In parallel tool mode:
715
- - `tool_execution_start` is emitted in assistant source order during the preflight phase
716
- - `tool_execution_update` events may interleave across tools
717
- - `tool_execution_end` is emitted in tool completion order after each tool is finalized
718
- - final `toolResult` message events are still emitted later in assistant source order
351
+ Moved to [Extension events](/extensions/events#after_provider_response).
719
352
 
720
- ```typescript
721
- pi.on("tool_execution_start", async (event, ctx) => {
722
- // event.toolCallId, event.toolName, event.args
723
- });
353
+ ### Model Events
724
354
 
725
- pi.on("tool_execution_update", async (event, ctx) => {
726
- // event.toolCallId, event.toolName, event.args, event.partialResult
727
- });
355
+ Moved to [Extension events](/extensions/events#model-events).
728
356
 
729
- pi.on("tool_execution_end", async (event, ctx) => {
730
- // event.toolCallId, event.toolName, event.result, event.isError
731
- });
732
- ```
357
+ #### model_select
733
358
 
734
- #### context
359
+ Moved to [Extension events](/extensions/events#model_select).
735
360
 
736
- 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.
361
+ #### thinking_level_select
737
362
 
738
- ```typescript
739
- pi.on("context", async (event, ctx) => {
740
- // event.messages - deep copy, safe to modify
741
- const filtered = event.messages.filter(m => !shouldPrune(m));
742
- return { messages: filtered };
743
- });
744
- ```
363
+ Moved to [Extension events](/extensions/events#thinking_level_select).
745
364
 
746
- #### before_provider_headers
365
+ ### Tool Events
747
366
 
748
- Fires after outgoing HTTP headers are assembled. Mutate `event.headers` to add, override, or remove headers. The event also identifies the provider and model.
367
+ Moved to [Extension events](/extensions/events#tool-events).
749
368
 
750
- ```typescript
751
- pi.on("before_provider_headers", (event, ctx) => {
752
- event.headers["x-session-id"] = ctx.sessionManager.getSessionId();
753
- delete event.headers["x-remove-me"];
754
- });
755
- ```
369
+ #### tool_call
756
370
 
757
- #### before_provider_request
371
+ Moved to [Extension events](/extensions/events#tool_call).
758
372
 
759
- 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.
373
+ #### Typing custom tool input
760
374
 
761
- 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.
375
+ Moved to [Extension events](/extensions/events#typing-custom-tool-input).
762
376
 
763
- ```typescript
764
- pi.on("before_provider_request", (event, ctx) => {
765
- console.log(JSON.stringify(event.payload, null, 2));
377
+ #### tool_result
766
378
 
767
- // Optional: replace payload
768
- // return { ...event.payload, temperature: 0 };
769
- });
770
- ```
379
+ Moved to [Extension events](/extensions/events#tool_result).
771
380
 
772
- This is mainly useful for debugging provider serialization and cache behavior.
381
+ ### User Bash Events
773
382
 
774
- #### after_provider_response
383
+ Moved to [Extension events](/extensions/events#user-bash-events).
775
384
 
776
- Fired after an HTTP response is received and before its stream body is consumed. Handlers run in extension load order.
385
+ #### user_bash
777
386
 
778
- ```typescript
779
- pi.on("after_provider_response", (event, ctx) => {
780
- // event.status - HTTP status code
781
- // event.headers - normalized response headers
782
- if (event.status === 429) {
783
- console.log("rate limited", event.headers["retry-after"]);
784
- }
785
- });
786
- ```
387
+ Moved to [Extension events](/extensions/events#user_bash).
787
388
 
788
- Header availability depends on provider and transport. Providers that abstract HTTP responses may not expose headers.
389
+ ### Input Events
789
390
 
790
- ### Model Events
391
+ Moved to [Extension events](/extensions/events#input-events).
791
392
 
792
- #### model_select
393
+ #### input
793
394
 
794
- Fired when the model changes via `/model` command, model cycling (`CTRL+P`), or session restore.
395
+ Moved to [Extension events](/extensions/events#input).
795
396
 
796
- ```typescript
797
- pi.on("model_select", async (event, ctx) => {
798
- // event.model - newly selected model
799
- // event.previousModel - previous model (undefined if first selection)
800
- // event.source - "set" | "cycle" | "restore"
801
-
802
- const prev = event.previousModel
803
- ? `${event.previousModel.provider}/${event.previousModel.id}`
804
- : "none";
805
- const next = `${event.model.provider}/${event.model.id}`;
806
-
807
- ctx.ui.notify(`Model changed (${event.source}): ${prev} -> ${next}`, "info");
808
- });
809
- ```
397
+ ## ExtensionContext
810
398
 
811
- Use this to update UI elements (status bars, footers) or perform model-specific initialization when the active model changes.
399
+ Moved to [Extension API reference](/extensions/api-reference#extensioncontext).
812
400
 
813
- #### thinking_level_select
401
+ ### ctx.ui
814
402
 
815
- Fired when the thinking level changes. This is notification-only; handler return values are ignored.
403
+ Moved to [Extension API reference](/extensions/api-reference#ctx-ui).
816
404
 
817
- ```typescript
818
- pi.on("thinking_level_select", async (event, ctx) => {
819
- // event.level - newly selected thinking level
820
- // event.previousLevel - previous thinking level
405
+ ### ctx.hasUI
821
406
 
822
- ctx.ui.setStatus("thinking", `thinking: ${event.level}`);
823
- });
824
- ```
407
+ Moved to [Extension API reference](/extensions/api-reference#ctx-hasui).
825
408
 
826
- Use this to update extension UI when `pi.setThinkingLevel()`, model changes, or built-in thinking-level controls change the active thinking level.
409
+ ### ctx.cwd
827
410
 
828
- ### Tool Events
411
+ Moved to [Extension API reference](/extensions/api-reference#ctx-cwd).
829
412
 
830
- #### tool_call
413
+ ### ctx.isProjectTrusted()
831
414
 
832
- Fired after `tool_execution_start`, before the tool executes. **Can block.** Use `isToolCallEventType` to narrow and get typed inputs.
415
+ Moved to [Extension API reference](/extensions/api-reference#ctx-isprojecttrusted).
833
416
 
834
- 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.
417
+ ### ctx.sessionManager
835
418
 
836
- 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`.
419
+ Moved to [Extension API reference](/extensions/api-reference#ctx-sessionmanager).
837
420
 
838
- `event.input` is mutable. Mutate it in place to patch tool arguments before execution.
421
+ ### ctx.modelRegistry / ctx.model / ctx.scopedModels
839
422
 
840
- Behavior guarantees:
841
- - Mutations to `event.input` affect the actual tool execution
842
- - Later `tool_call` handlers see mutations made by earlier handlers
843
- - No re-validation is performed after your mutation
844
- - Return values from `tool_call` control blocking via `{ block: true, reason?: string, terminate?: boolean }`
845
- - `terminate` only applies to a blocked call; the agent stops early only when every finalized result in the batch is terminating
846
- - `terminate` applies only to a blocked call; the agent stops early only when every finalized result in the batch is terminating
423
+ Moved to [Extension API reference](/extensions/api-reference#ctx-modelregistry-/-ctx-model-/-ctx-scopedmodels).
847
424
 
848
- ```typescript
849
- import { isToolCallEventType } from "@bastani/atomic";
425
+ ### ctx.signal
850
426
 
851
- pi.on("tool_call", async (event, ctx) => {
852
- // event.toolName - "bash", "powershell", "read", "write", "edit", "find", "search", etc.
853
- // event.toolCallId
854
- // event.input - tool parameters (mutable)
427
+ Moved to [Extension API reference](/extensions/api-reference#ctx-signal).
855
428
 
856
- // Built-in tools: no type params needed
857
- if (isToolCallEventType("bash", event)) {
858
- // event.input is { command: string; timeout?: number }
859
- event.input.command = `source ~/.profile\n${event.input.command}`;
429
+ ### ctx.isIdle() / ctx.abort() / ctx.hasPendingMessages()
860
430
 
861
- if (event.input.command.includes("rm -rf")) {
862
- return { block: true, reason: "Dangerous command", terminate: true };
863
- }
864
- }
865
-
866
- if (isToolCallEventType("powershell", event)) {
867
- // event.input is typed as PowerShellToolInput
868
- event.input.command = `$ErrorActionPreference = "Stop"\n${event.input.command}`;
869
- }
870
-
871
- if (isToolCallEventType("read", event)) {
872
- // event.input is { path: string }
873
- console.log(`Reading: ${event.input.path}`);
874
- }
875
-
876
- if (isToolCallEventType("search", event)) {
877
- // event.input is typed as SearchToolInput
878
- event.input.paths ??= ".";
879
- }
880
- });
881
- ```
431
+ Moved to [Extension API reference](/extensions/api-reference#ctx-isidle-/-ctx-abort-/-ctx-haspendingmessages).
882
432
 
883
- #### Typing custom tool input
433
+ ### ctx.isProjectTrusted()
884
434
 
885
- Custom tools should export their input type:
435
+ Moved to [Extension API reference](/extensions/api-reference#ctx-isprojecttrusted-2).
886
436
 
887
- ```typescript
888
- // my-extension.ts
889
- export type MyToolInput = Static<typeof myToolSchema>;
890
- ```
437
+ ### ctx.shutdown()
891
438
 
892
- Use `isToolCallEventType` with explicit type parameters:
439
+ Moved to [Extension API reference](/extensions/api-reference#ctx-shutdown).
893
440
 
894
- ```typescript
895
- import { isToolCallEventType } from "@bastani/atomic";
896
- import type { MyToolInput } from "my-extension";
897
-
898
- pi.on("tool_call", (event) => {
899
- if (isToolCallEventType<"my_tool", MyToolInput>("my_tool", event)) {
900
- event.input.action; // typed
901
- }
902
- });
903
- ```
441
+ ### ctx.getContextUsage()
904
442
 
905
- #### tool_result
443
+ Moved to [Extension API reference](/extensions/api-reference#ctx-getcontextusage).
906
444
 
907
- Fired after tool execution finishes and before `tool_execution_end` plus the final tool result message events are emitted. **Can modify result.**
445
+ ### ctx.compact()
908
446
 
909
- 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.
447
+ Moved to [Extension API reference](/extensions/api-reference#ctx-compact).
910
448
 
911
- `tool_result` handlers chain like middleware:
912
- - Handlers run in extension load order
913
- - Each handler sees the latest result after previous handler changes
914
- - Handlers can return partial patches (`content`, `details`, or `isError`); omitted fields keep their current values
449
+ ### ctx.getSystemPrompt()
915
450
 
916
- 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.
451
+ Moved to [Extension API reference](/extensions/api-reference#ctx-getsystemprompt).
917
452
 
918
- 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.
453
+ ### ctx.getSkillCatalog()
919
454
 
920
- ```typescript
921
- import { isBashToolResult, isPowerShellToolResult, isSearchToolResult } from "@bastani/atomic";
455
+ Moved to [Extension API reference](/extensions/api-reference#ctx-getskillcatalog).
922
456
 
923
- pi.on("tool_result", async (event, ctx) => {
924
- // event.toolName, event.toolCallId, event.input
925
- // event.content, event.details, event.isError
457
+ ## ExtensionCommandContext
926
458
 
927
- if (isBashToolResult(event)) {
928
- // event.details is typed as BashToolDetails
929
- }
459
+ Moved to [Extension API reference](/extensions/api-reference#extensioncommandcontext).
930
460
 
931
- if (isPowerShellToolResult(event)) {
932
- // event.details is typed as PowerShellToolDetails | undefined
933
- }
461
+ ### ctx.waitForIdle()
934
462
 
935
- if (isSearchToolResult(event)) {
936
- // event.details is typed as SearchToolDetails | undefined
937
- }
463
+ Moved to [Extension API reference](/extensions/api-reference#ctx-waitforidle).
938
464
 
939
- const response = await fetch("https://example.com/summarize", {
940
- method: "POST",
941
- body: JSON.stringify({ content: event.content }),
942
- signal: ctx.signal,
943
- });
465
+ ### ctx.newSession(options?)
944
466
 
945
- // Modify result:
946
- return { content: [...], details: {...}, isError: false };
947
- });
948
- ```
467
+ Moved to [Extension API reference](/extensions/api-reference#ctx-newsession-options).
949
468
 
950
- ### User Bash Events
469
+ ### ctx.fork(entryId, options?)
951
470
 
952
- #### user_bash
471
+ Moved to [Extension API reference](/extensions/api-reference#ctx-fork-entryid-options).
953
472
 
954
- Fired when user executes `!` or `!!` commands. **Can intercept.**
473
+ ### ctx.navigateTree(targetId, options?)
955
474
 
956
- ```typescript
957
- import { createLocalBashOperations } from "@bastani/atomic";
958
-
959
- pi.on("user_bash", (event, ctx) => {
960
- // event.command - the bash command
961
- // event.excludeFromContext - true if !! prefix
962
- // event.cwd - working directory
963
-
964
- // Option 1: Provide custom operations (e.g., SSH)
965
- return { operations: remoteBashOps };
966
-
967
- // Option 2: Wrap atomic's built-in local bash backend
968
- const local = createLocalBashOperations();
969
- return {
970
- operations: {
971
- exec(command, cwd, options) {
972
- return local.exec(`source ~/.profile\n${command}`, cwd, options);
973
- }
974
- }
975
- };
475
+ Moved to [Extension API reference](/extensions/api-reference#ctx-navigatetree-targetid-options).
976
476
 
977
- // Option 3: Full replacement - return result directly
978
- return { result: { output: "...", exitCode: 0, cancelled: false, truncated: false } };
979
- });
980
- ```
477
+ ### ctx.switchSession(sessionPath, options?)
981
478
 
982
- ### Input Events
479
+ Moved to [Extension API reference](/extensions/api-reference#ctx-switchsession-sessionpath-options).
983
480
 
984
- #### input
481
+ ### Session replacement lifecycle and footguns
985
482
 
986
- Fired when user input is received, after extension commands are checked but before skill and template expansion. The event sees the raw input text, so `/skill:foo` and `/template` are not yet expanded.
483
+ Moved to [Extension API reference](/extensions/api-reference#session-replacement-lifecycle-and-footguns).
987
484
 
988
- **Processing order:**
989
- 1. Extension commands (`/cmd`) checked first - if found, handler runs and input event is skipped
990
- 2. `input` event fires - can intercept, transform, or handle
991
- 3. If not handled: skill commands (`/skill:name`) expanded to skill content
992
- 4. If not handled: prompt templates (`/template`) expanded to template content
993
- 5. Agent processing begins (`before_agent_start`, etc.)
485
+ ### ctx.reload()
994
486
 
995
- ```typescript
996
- pi.on("input", async (event, ctx) => {
997
- // event.text - raw input (before skill/template expansion)
998
- // event.images - attached images, if any
999
- // event.source - "interactive" (typed), "rpc" (API), or "extension" (via sendUserMessage)
1000
-
1001
- // Transform: rewrite input before expansion
1002
- if (event.text.startsWith("?quick "))
1003
- return { action: "transform", text: `Respond briefly: ${event.text.slice(7)}` };
1004
-
1005
- // Handle: respond without LLM (extension shows its own feedback)
1006
- if (event.text === "ping") {
1007
- ctx.ui.notify("pong", "info");
1008
- return { action: "handled" };
1009
- }
1010
-
1011
- // Route by source: skip processing for extension-injected messages
1012
- if (event.source === "extension") return { action: "continue" };
1013
-
1014
- // Intercept skill commands before expansion
1015
- if (event.text.startsWith("/skill:")) {
1016
- // Could transform, block, or let pass through
1017
- }
1018
-
1019
- return { action: "continue" }; // Default: pass through to expansion
1020
- });
1021
- ```
487
+ Moved to [Extension API reference](/extensions/api-reference#ctx-reload).
1022
488
 
1023
- **Results:**
1024
- - `continue` - pass through unchanged (default if handler returns nothing)
1025
- - `transform` - modify text/images, then continue to expansion
1026
- - `handled` - skip agent entirely (first handler to return this wins)
489
+ ## ExtensionAPI Methods
1027
490
 
1028
- 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.
491
+ Moved to [Extension API reference](/extensions/api-reference#extensionapi-methods).
1029
492
 
1030
- ## ExtensionContext
493
+ ### pi.on(event, handler)
1031
494
 
1032
- All handlers receive `ctx: ExtensionContext`.
495
+ Moved to [Extension API reference](/extensions/api-reference#pi-on-event-handler).
1033
496
 
1034
- ### ctx.ui
497
+ ### pi.registerTool(definition)
1035
498
 
1036
- UI methods for user interaction. See [Custom UI](#custom-ui) for full details.
499
+ Moved to [Extension API reference](/extensions/api-reference#pi-registertool-definition).
1037
500
 
1038
- ### ctx.hasUI
501
+ #### Built-in tool prompt contributions
1039
502
 
1040
- `false` in print mode (`-p`) and JSON mode. `true` in interactive and RPC mode. In RPC mode, dialog methods (`select`, `confirm`, `input`, `editor`) work via the extension UI sub-protocol, and fire-and-forget methods (`notify`, `setStatus`, `setWidget`, `setTitle`, `setEditorText`) emit requests to the client. Some TUI-specific methods are no-ops or return defaults (see [RPC mode](/rpc#extension-ui-protocol)).
503
+ Moved to [Extension API reference](/extensions/api-reference#built-in-tool-prompt-contributions).
1041
504
 
1042
- ### ctx.cwd
505
+ ### pi.sendMessage(message, options?)
1043
506
 
1044
- Current working directory.
507
+ Moved to [Extension API reference](/extensions/api-reference#pi-sendmessage-message-options).
1045
508
 
1046
- Built-in cwd-sensitive tools (`read`, `write`, `edit`, `search`, `find`, `ls`, `bash`, `powershell`) resolve relative paths against `ctx.cwd` when an extension invokes them, falling back to the cwd captured when the tool was created. An extension that registers a tool and forwards its own context therefore gets paths resolved against the live session cwd rather than a stale one.
509
+ ### pi.sendMessages(messages, options?)
1047
510
 
1048
- Use `CONFIG_DIR_NAME` instead of hardcoding `.atomic` (or legacy `.pi`) when constructing project-local config paths. Rebranded distributions can use a different config directory name.
511
+ Moved to [Extension API reference](/extensions/api-reference#pi-sendmessages-messages-options).
1049
512
 
1050
- ```typescript
1051
- import { CONFIG_DIR_NAME, type ExtensionAPI } from "@bastani/atomic";
1052
- import { join } from "node:path";
513
+ ### pi.sendUserMessage(content, options?)
1053
514
 
1054
- export default function (pi: ExtensionAPI) {
1055
- pi.on("session_start", (_event, ctx) => {
1056
- const projectConfigPath = join(ctx.cwd, CONFIG_DIR_NAME, "my-extension.json");
1057
- // ...
1058
- });
1059
- }
1060
- ```
515
+ Moved to [Extension API reference](/extensions/api-reference#pi-sendusermessage-content-options).
1061
516
 
1062
- ### ctx.isProjectTrusted()
517
+ ### pi.appendEntry(customType, data?)
1063
518
 
1064
- Returns whether project-local trust is active for the current session context. This includes temporary trust decisions and CLI trust overrides, not just saved decisions in the global trust store.
519
+ Moved to [Extension API reference](/extensions/api-reference#pi-appendentry-customtype-data).
1065
520
 
1066
- Use this before reading project-local extension configuration that should only be honored for trusted projects.
521
+ ### pi.registerEntryRenderer(customType, renderer)
1067
522
 
523
+ Moved to [Extension API reference](/extensions/api-reference#pi-registerentryrenderer-customtype-renderer).
1068
524
 
1069
- ### ctx.sessionManager
525
+ ### pi.setSessionName(name)
1070
526
 
1071
- Read-only access to session state. See [Session Format](/session-format) for the full SessionManager API and entry types.
527
+ Moved to [Extension API reference](/extensions/api-reference#pi-setsessionname-name).
1072
528
 
1073
- For `tool_call`, this state is synchronized through the current assistant message before handlers run. In parallel tool execution mode it is still not guaranteed to include sibling tool results from the same assistant message.
529
+ ### pi.getSessionName()
1074
530
 
1075
- ```typescript
1076
- ctx.sessionManager.getEntries() // All entries
1077
- ctx.sessionManager.getBranch() // Current branch
1078
- ctx.sessionManager.getLeafId() // Current leaf entry ID
1079
- ```
531
+ Moved to [Extension API reference](/extensions/api-reference#pi-getsessionname).
1080
532
 
1081
- ### ctx.modelRegistry / ctx.model / ctx.scopedModels
533
+ ### pi.setLabel(entryId, label)
1082
534
 
1083
- Access models, auth state, and provider-aware requests.
535
+ Moved to [Extension API reference](/extensions/api-reference#pi-setlabel-entryid-label).
1084
536
 
1085
- Use `ctx.modelRegistry.complete()` for an extension model request that must use Atomic's provider composition. It dispatches through the active `ModelRuntime`, retaining registered custom providers and resolved request auth: the credential-specific `baseUrl`, headers (including `null` suppression markers), and environment values.
537
+ ### pi.registerCommand(name, options)
1086
538
 
1087
- ```typescript
1088
- const model = ctx.modelRegistry.find("github-copilot", "gpt-5.5");
1089
- if (!model) throw new Error("Model not found");
539
+ Moved to [Extension API reference](/extensions/api-reference#pi-registercommand-name-options).
1090
540
 
1091
- const response = await ctx.modelRegistry.complete(
1092
- model,
1093
- { messages },
1094
- { signal: ctx.signal },
1095
- );
1096
- ```
541
+ ### pi.getCommands()
1097
542
 
1098
- Use `getApiKeyAndHeaders()` only when an extension must inspect auth before dispatch; normal requests do not need to resolve or overlay auth themselves.
543
+ Moved to [Extension API reference](/extensions/api-reference#pi-getcommands).
1099
544
 
1100
- `await ctx.modelRegistry.refresh(options)` returns `{ aborted, errors }`, not just completion. `errors` is a per-provider map, so extensions can report partial refresh failures; `aborted` reports cancellation. Host integrations that call `ModelRuntime.setRuntimeApiKey(providerId, apiKey, options)` must note that it records the runtime credential but does not refresh the catalog; call `refresh({ providers: [providerId], signal })` explicitly when a fresh catalog is needed.
545
+ ### pi.registerMessageRenderer(customType, renderer)
1101
546
 
1102
- `ctx.scopedModels` is the read-only list of models scoped to the current session — the same set the `/scoped-models` command shows. It is resolved from the `--models` CLI flag and the `enabledModels` setting, matched against the available catalogue. It is empty when no scoping is configured, meaning every available model is usable. Each entry is `{ model, thinkingLevel? }`, where `thinkingLevel` is set only when a pattern pinned it (for example `anthropic/*:high`). Use it to populate a model picker that mirrors the built-in one instead of enumerating the whole catalogue.
547
+ Moved to [Extension API reference](/extensions/api-reference#pi-registermessagerenderer-customtype-renderer).
1103
548
 
1104
- The value is resolved at access time, so it tracks session replacement. Under the isolated interactive engine it reflects the engine's catalogue rather than a stale host snapshot.
549
+ ### pi.registerMarkdownTransformer(transformer)
1105
550
 
1106
- It reports the scope and cannot change it. `ctx.scopedModels` is a getter with no setter, typed `readonly ScopedModel[]`, so assigning to it or pushing an entry is a compile error. The guarantee also holds at runtime, where the type does not reach: each read returns a fresh copy — of the array, of every `{ model, thinkingLevel }` entry in it, and of each entry's model — and all three are frozen. A JavaScript extension, or one that asserts the `readonly` away, therefore cannot widen the set of models the session may use by pushing an entry, nor change which model it selects by swapping one in place; the attempt throws rather than quietly working. Read it, and change scope through the commands and settings that own it.
551
+ Moved to [Extension API reference](/extensions/api-reference#pi-registermarkdowntransformer-transformer).
1107
552
 
1108
- ```typescript
1109
- for (const { model, thinkingLevel } of ctx.scopedModels) {
1110
- console.log(`${model.provider}/${model.id}${thinkingLevel ? `:${thinkingLevel}` : ""}`);
1111
- }
1112
- ```
553
+ ### pi.registerShortcut(shortcut, options)
1113
554
 
1114
- Both types are exported: `ScopedModel` for one entry, `ExtensionScopedModels` for the accessor's own type. They are declared at the public extension type path (`core/extensions/types.ts`) and re-exported from the package root, so an extension never reaches into an internal module to describe what it just read.
555
+ Moved to [Extension API reference](/extensions/api-reference#pi-registershortcut-shortcut-options).
1115
556
 
1116
- ```typescript
1117
- import type { ExtensionScopedModels, ScopedModel } from "@bastani/atomic";
557
+ ### pi.registerFlag(name, options)
1118
558
 
1119
- function firstScoped(scope: ExtensionScopedModels): ScopedModel | undefined {
1120
- return scope[0];
1121
- }
1122
- ```
559
+ Moved to [Extension API reference](/extensions/api-reference#pi-registerflag-name-options).
1123
560
 
1124
- ### ctx.signal
561
+ ### pi.exec(command, args, options?)
1125
562
 
1126
- The current agent abort signal, or `undefined` when no agent turn is active.
563
+ Moved to [Extension API reference](/extensions/api-reference#pi-exec-command-args-options).
1127
564
 
1128
- Use this for abort-aware nested work started by extension handlers, for example:
1129
- - `fetch(..., { signal: ctx.signal })`
1130
- - model calls that accept `signal`
1131
- - file or process helpers that accept `AbortSignal`
565
+ ### pi.getActiveTools() / pi.getAllTools() / pi.setActiveTools(names)
1132
566
 
1133
- `ctx.signal` is typically defined during active turn events such as `tool_call`, `tool_result`, `message_update`, and `turn_end`.
1134
- It is usually `undefined` in idle or non-turn contexts such as session events, extension commands, and shortcuts fired while Atomic is idle.
567
+ Moved to [Extension API reference](/extensions/api-reference#pi-getactivetools-/-pi-getalltools-/-pi-setactivetools-names).
1135
568
 
1136
- ```typescript
1137
- pi.on("tool_result", async (event, ctx) => {
1138
- const response = await fetch("https://example.com/api", {
1139
- method: "POST",
1140
- body: JSON.stringify(event),
1141
- signal: ctx.signal,
1142
- });
569
+ ### pi.setModel(model)
1143
570
 
1144
- const data = await response.json();
1145
- return { details: data };
1146
- });
1147
- ```
571
+ Moved to [Extension API reference](/extensions/api-reference#pi-setmodel-model).
1148
572
 
1149
- ### ctx.isIdle() / ctx.abort() / ctx.hasPendingMessages()
573
+ ### pi.getThinkingLevel() / pi.setThinkingLevel(level)
1150
574
 
1151
- Control flow helpers.
575
+ Moved to [Extension API reference](/extensions/api-reference#pi-getthinkinglevel-/-pi-setthinkinglevel-level).
1152
576
 
1153
- ### ctx.isProjectTrusted()
577
+ ### pi.events
1154
578
 
1155
- Returns whether project-local trust is active for the current extension context. Use this before reading project-local config, loading project-local resources, or exposing actions that should only run after the user has trusted the cwd.
579
+ Moved to [Extension API reference](/extensions/api-reference#pi-events).
1156
580
 
1157
- ```typescript
1158
- pi.registerCommand("project-status", {
1159
- description: "Show trust state",
1160
- handler: async (_args, ctx) => {
1161
- ctx.ui.notify(ctx.isProjectTrusted() ? "Project is trusted" : "Project is not trusted", "info");
1162
- },
1163
- });
1164
- ```
581
+ ### Native providers
1165
582
 
1166
- ### ctx.shutdown()
583
+ Moved to [Extension API reference](/extensions/api-reference#native-providers).
1167
584
 
1168
- Request a graceful shutdown of Atomic.
585
+ ### pi.registerProvider(name, config)
1169
586
 
1170
- - **Interactive mode:** Deferred until the agent becomes idle (after processing all queued steering and follow-up messages).
1171
- - **RPC mode:** Deferred until the next idle state (after completing the current command response, when waiting for the next command).
1172
- - **Print mode:** No-op. The process exits automatically when all prompts are processed.
587
+ Moved to [Extension API reference](/extensions/api-reference#pi-registerprovider-name-config).
1173
588
 
1174
- Emits `session_shutdown` event to all extensions before exiting. Available in all contexts (event handlers, tools, commands, shortcuts).
589
+ ### pi.unregisterProvider(name)
1175
590
 
1176
- ```typescript
1177
- pi.on("tool_call", (event, ctx) => {
1178
- if (isFatal(event.input)) {
1179
- ctx.shutdown();
1180
- }
1181
- });
1182
- ```
591
+ Moved to [Extension API reference](/extensions/api-reference#pi-unregisterprovider-name).
1183
592
 
1184
- ### ctx.getContextUsage()
593
+ ## State Management
1185
594
 
1186
- Returns current context usage for the active model. Uses last assistant usage when available, then estimates tokens for trailing messages.
595
+ Moved to [Writing extensions](/extensions/authoring#state-management).
1187
596
 
1188
- ```typescript
1189
- const usage = ctx.getContextUsage();
1190
- if (usage && usage.tokens > 100_000) {
1191
- // ...
1192
- }
1193
- ```
597
+ ### Session-scoped in-memory state
1194
598
 
1195
- ### ctx.compact()
599
+ Moved to [Writing extensions](/extensions/authoring#session-scoped-in-memory-state).
1196
600
 
1197
- Trigger Atomic's verbatim line compactor without awaiting completion. The planner emits numbered deleted-line ranges only; Atomic validates them and reconstructs retained text mechanically. Use `compression_ratio` (fraction of compactable lines to keep), client-side `preserve_recent` (an exact context-visible message count), and `query` to tune the run, and `onComplete`/`onError` for follow-up actions.
601
+ ## Custom Tools
1198
602
 
1199
- ```typescript
1200
- ctx.compact({
1201
- compression_ratio: 0.5, // fraction of compactable lines to keep
1202
- preserve_recent: 2, // protect exactly the newest two context-visible messages
1203
- query: "keep active migration details",
1204
- onComplete: (result) => {
1205
- ctx.ui.notify(`Compaction kept ${result.stats.linesKept}/${result.stats.linesBefore} lines`, "info");
1206
- },
1207
- onError: (error) => {
1208
- ctx.ui.notify(`Compaction failed: ${error.message}`, "error");
1209
- },
1210
- });
1211
- ```
603
+ Moved to [Writing extensions](/extensions/authoring#custom-tools).
1212
604
 
1213
- The planner cannot author context text: only validated line ranges enter the mechanical reconstruction path. The `query` parameter guides relevance selection inside the fixed prompt; it is not replacement prose. Extensions that need an offline replacement can return `compactedText` from `session_before_compact`.
605
+ ### Tool Definition
1214
606
 
1215
- ### ctx.getSystemPrompt()
607
+ Moved to [Writing extensions](/extensions/authoring#tool-definition).
1216
608
 
1217
- Returns Atomic's current system prompt string.
609
+ #### Constrained sampling
1218
610
 
1219
- - During `before_agent_start`, this reflects chained system-prompt changes made so far for the current turn.
1220
- - It does not include later `context` message mutations.
1221
- - It does not include `before_provider_request` payload rewrites.
1222
- - If later-loaded extensions run after yours, they can still change what is ultimately sent.
611
+ Moved to [Writing extensions](/extensions/authoring#constrained-sampling).
1223
612
 
1224
- ```typescript
1225
- pi.on("before_agent_start", (event, ctx) => {
1226
- const prompt = ctx.getSystemPrompt();
1227
- console.log(`System prompt length: ${prompt.length}`);
1228
- });
1229
- ```
1230
-
1231
- ### ctx.getSkillCatalog()
1232
-
1233
- Returns the current loader-owned skill catalog when the host provides one. Use it to resolve exact skill selectors, including source-qualified names such as `tdd@builtin`, without falling back to the bare precedence winner.
1234
-
1235
- ```typescript
1236
- pi.on("session_start", (_event, ctx) => {
1237
- const catalog = ctx.getSkillCatalog?.();
1238
- const resolved = catalog?.resolve("tdd@builtin");
1239
- if (resolved?.ok) {
1240
- ctx.ui.notify(`Using ${resolved.candidate.selector}`, "info");
1241
- }
1242
- });
1243
- ```
1244
-
1245
- `pi.getCommands()` already includes the same advertised `/skill:name` and `/skill:name@source` names. See [Skill Commands](/skills#skill-commands).
1246
-
1247
- ## ExtensionCommandContext
1248
-
1249
- Command handlers receive `ExtensionCommandContext`, which extends `ExtensionContext` with session control methods. These are only available in commands because they can deadlock if called from event handlers.
1250
-
1251
- ### ctx.waitForIdle()
1252
-
1253
- Wait for the agent to finish streaming:
1254
-
1255
- ```typescript
1256
- pi.registerCommand("my-cmd", {
1257
- handler: async (args, ctx) => {
1258
- await ctx.waitForIdle();
1259
- // Agent is now idle, safe to modify session
1260
- },
1261
- });
1262
- ```
1263
-
1264
- ### ctx.newSession(options?)
1265
-
1266
- Create a new session:
1267
-
1268
- ```typescript
1269
- const parentSession = ctx.sessionManager.getSessionFile();
1270
- const kickoff = "Continue in the replacement session";
1271
-
1272
- const result = await ctx.newSession({
1273
- parentSession,
1274
- setup: async (sm) => {
1275
- sm.appendMessage({
1276
- role: "user",
1277
- content: [{ type: "text", text: "Context from previous session..." }],
1278
- timestamp: Date.now(),
1279
- });
1280
- },
1281
- withSession: async (ctx) => {
1282
- // Use only the replacement-session ctx here.
1283
- await ctx.sendUserMessage(kickoff);
1284
- },
1285
- });
1286
-
1287
- if (result.cancelled) {
1288
- // An extension cancelled the new session
1289
- }
1290
- ```
1291
-
1292
- Options:
1293
- - `parentSession`: parent session file to record in the new session header
1294
- - `setup`: mutate the new session's `SessionManager` before `withSession` runs
1295
- - `withSession`: run post-switch work against a fresh replacement-session context. Do not use captured old `pi` / command `ctx`; see [Session replacement lifecycle and footguns](#session-replacement-lifecycle-and-footguns).
1296
-
1297
- ### ctx.fork(entryId, options?)
1298
-
1299
- Fork from a specific entry, creating a new session file:
1300
-
1301
- ```typescript
1302
- const result = await ctx.fork("entry-id-123", {
1303
- withSession: async (ctx) => {
1304
- // Use only the replacement-session ctx here.
1305
- ctx.ui.notify("Now in the forked session", "info");
1306
- },
1307
- });
1308
- if (result.cancelled) {
1309
- // An extension cancelled the fork
1310
- }
1311
-
1312
- const cloneResult = await ctx.fork("entry-id-456", { position: "at" });
1313
- if (cloneResult.cancelled) {
1314
- // An extension cancelled the clone
1315
- }
1316
- ```
1317
-
1318
- Options:
1319
- - `position`: `"before"` (default) forks before the selected user message, restoring that prompt into the editor
1320
- - `position`: `"at"` duplicates the active path through the selected entry without restoring editor text
1321
- - `withSession`: run post-switch work against a fresh replacement-session context. Do not use captured old `pi` / command `ctx`; see [Session replacement lifecycle and footguns](#session-replacement-lifecycle-and-footguns).
1322
-
1323
- ### ctx.navigateTree(targetId, options?)
1324
-
1325
- Navigate to a different point in the session tree:
1326
-
1327
- ```typescript
1328
- const result = await ctx.navigateTree("entry-id-456", {
1329
- summarize: true,
1330
- customInstructions: "Focus on error handling changes",
1331
- replaceInstructions: false, // true = replace default prompt entirely
1332
- label: "review-checkpoint",
1333
- });
1334
- ```
1335
-
1336
- Options:
1337
- - `summarize`: Whether to generate a summary of the abandoned branch
1338
- - `customInstructions`: Custom instructions for the summarizer
1339
- - `replaceInstructions`: If true, `customInstructions` replaces the default prompt instead of being appended
1340
- - `label`: Label to attach to the branch summary entry (or target entry if not summarizing)
1341
-
1342
- ### ctx.switchSession(sessionPath, options?)
1343
-
1344
- Switch to a different session file:
1345
-
1346
- ```typescript
1347
- const result = await ctx.switchSession("/path/to/session.jsonl", {
1348
- withSession: async (ctx) => {
1349
- await ctx.sendUserMessage("Resume work in the replacement session");
1350
- },
1351
- });
1352
- if (result.cancelled) {
1353
- // An extension cancelled the switch via session_before_switch
1354
- }
1355
- ```
1356
-
1357
- Options:
1358
- - `withSession`: run post-switch work against a fresh replacement-session context. Do not use captured old `pi` / command `ctx`; see [Session replacement lifecycle and footguns](#session-replacement-lifecycle-and-footguns).
1359
-
1360
- To discover available sessions, use the static `SessionManager.list()` or `SessionManager.listAll()` methods:
1361
-
1362
- ```typescript
1363
- import { SessionManager } from "@bastani/atomic";
1364
-
1365
- pi.registerCommand("switch", {
1366
- description: "Switch to another session",
1367
- handler: async (args, ctx) => {
1368
- const sessions = await SessionManager.list(ctx.cwd);
1369
- if (sessions.length === 0) return;
1370
- const choice = await ctx.ui.select(
1371
- "Pick session:",
1372
- sessions.map(s => s.file),
1373
- );
1374
- if (choice) {
1375
- await ctx.switchSession(choice, {
1376
- withSession: async (ctx) => {
1377
- ctx.ui.notify("Switched session", "info");
1378
- },
1379
- });
1380
- }
1381
- },
1382
- });
1383
- ```
1384
-
1385
- ### Session replacement lifecycle and footguns
1386
-
1387
- `withSession` receives a fresh `ReplacedSessionContext`, which extends `ExtensionCommandContext` with async `sendMessage()` and `sendUserMessage()` helpers bound to the replacement session.
1388
-
1389
- Lifecycle and footguns:
1390
- - `withSession` runs only after the old session has emitted `session_shutdown`, the old runtime has been torn down, the replacement session has been rebound, and the new extension instance has already received `session_start`.
1391
- - The callback still executes in the original closure, not inside the new extension instance. That means your old extension instance may already have run its shutdown cleanup before `withSession` starts.
1392
- - Captured old `pi` / old command `ctx` session-bound objects are stale after replacement and will throw if used. Use only the `ctx` passed to `withSession` for session-bound work.
1393
- - Previously extracted raw objects are still your responsibility. For example, if you capture `const sm = ctx.sessionManager` before replacement, `sm` is still the old `SessionManager` object. Do not reuse it after replacement.
1394
- - Code in `withSession` should assume any state invalidated by your `session_shutdown` handler is already gone. Only capture plain data that survives shutdown cleanly, such as strings, ids, and serialized config.
1395
- - Long-lived callbacks that need to classify a stale API error should use `isStaleExtensionContextError(error)` from `@bastani/atomic`, not match the host's error message.
1396
-
1397
- Safe pattern:
1398
-
1399
- ```typescript
1400
- pi.registerCommand("handoff", {
1401
- handler: async (_args, ctx) => {
1402
- const kickoff = "Continue from the replacement session";
1403
- await ctx.newSession({
1404
- withSession: async (ctx) => {
1405
- await ctx.sendUserMessage(kickoff);
1406
- },
1407
- });
1408
- },
1409
- });
1410
- ```
1411
-
1412
- Unsafe pattern:
1413
-
1414
- ```typescript
1415
- pi.registerCommand("handoff", {
1416
- handler: async (_args, ctx) => {
1417
- const oldSessionManager = ctx.sessionManager;
1418
- await ctx.newSession({
1419
- withSession: async (_ctx) => {
1420
- // stale old objects: do not do this
1421
- oldSessionManager.getSessionFile();
1422
- pi.sendUserMessage("wrong");
1423
- },
1424
- });
1425
- },
1426
- });
1427
- ```
1428
-
1429
- ### ctx.reload()
1430
-
1431
- Run the same reload flow as `/reload`.
1432
-
1433
- ```typescript
1434
- pi.registerCommand("reload-runtime", {
1435
- description: "Reload extensions, skills, prompts, and themes",
1436
- handler: async (_args, ctx) => {
1437
- await ctx.reload();
1438
- return;
1439
- },
1440
- });
1441
- ```
1442
-
1443
- Important behavior:
1444
- - `await ctx.reload()` emits `session_shutdown` for the current extension runtime
1445
- - It then reloads resources and emits `session_start` with `reason: "reload"` and `resources_discover` with reason `"reload"`
1446
- - The currently running command handler still continues in the old call frame
1447
- - Code after `await ctx.reload()` still runs from the pre-reload version
1448
- - Code after `await ctx.reload()` must not assume old in-memory extension state is still valid
1449
- - After the handler returns, future commands/events/tool calls use the new extension version
1450
-
1451
- For predictable behavior, treat reload as terminal for that handler (`await ctx.reload(); return;`).
1452
-
1453
- Tools run with `ExtensionContext`, so they cannot call `ctx.reload()` directly. Use a command as the reload entrypoint, then expose a tool that queues that command as a follow-up user message.
1454
-
1455
- Example tool the LLM can call to trigger reload:
1456
-
1457
- ```typescript
1458
- import type { ExtensionAPI } from "@bastani/atomic";
1459
- import { Type } from "typebox";
1460
-
1461
- export default function (pi: ExtensionAPI) {
1462
- pi.registerCommand("reload-runtime", {
1463
- description: "Reload extensions, skills, prompts, and themes",
1464
- handler: async (_args, ctx) => {
1465
- await ctx.reload();
1466
- return;
1467
- },
1468
- });
1469
-
1470
- pi.registerTool({
1471
- name: "reload_runtime",
1472
- label: "Reload Runtime",
1473
- description: "Reload extensions, skills, prompts, and themes",
1474
- parameters: Type.Object({}),
1475
- async execute() {
1476
- pi.sendUserMessage("/reload-runtime", { deliverAs: "followUp" });
1477
- return {
1478
- content: [{ type: "text", text: "Queued /reload-runtime as a follow-up command." }],
1479
- };
1480
- },
1481
- });
1482
- }
1483
- ```
1484
-
1485
- ## ExtensionAPI Methods
1486
-
1487
- ### pi.on(event, handler)
1488
-
1489
- Subscribe to events. See [Events](#events) for event types and return values.
1490
-
1491
- ### pi.registerTool(definition)
1492
-
1493
- Register a custom tool callable by the LLM. See [Custom Tools](#custom-tools) for full details.
1494
-
1495
- `pi.registerTool()` works both during extension load and after startup. You can call it inside `session_start`, command handlers, or other event handlers. New tools are refreshed immediately in the same session, so they appear in `pi.getAllTools()` and are callable by the LLM without `/reload`.
1496
-
1497
- Use `pi.setActiveTools()` to enable or disable tools (including dynamically added tools) at runtime. Atomic always restores mandatory ordinary `intercom`; other tool behavior is unchanged.
1498
-
1499
- Use `promptSnippet` to opt a custom tool into a one-line entry in `Available tools`, and `promptGuidelines` to append tool-specific bullets to the default `Guidelines` section when the tool is active.
1500
-
1501
- **Important:** `promptGuidelines` bullets are appended flat to the `Guidelines` section with no tool name prefix. Each guideline must name the tool it refers to — avoid "Use this tool when..." because the LLM cannot tell which tool "this" means. Write "Use my_tool when..." instead.
1502
-
1503
- See [dynamic-tools.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/dynamic-tools.ts) for a full example.
1504
-
1505
- #### Built-in tool prompt contributions
1506
-
1507
- Atomic exports immutable prompt metadata for its built-in coding tools. Use these constants when a custom harness or tool registry needs the same prompt entries as the built-in factories:
1508
-
1509
- ```typescript
1510
- import {
1511
- bashToolSystemPromptContribution,
1512
- editToolSystemPromptContribution,
1513
- findToolSystemPromptContribution,
1514
- lsToolSystemPromptContribution,
1515
- readToolSystemPromptContribution,
1516
- searchToolSystemPromptContribution,
1517
- writeToolSystemPromptContribution,
1518
- } from "@bastani/atomic";
1519
-
1520
- const { snippet, guidelines } = readToolSystemPromptContribution;
1521
- ```
1522
-
1523
- Each contribution has a readonly `snippet` for the `Available tools` section and readonly `guidelines` for the active tool's `Guidelines` entries. The seven exports are `bash`, `edit`, `find`, `ls`, `read`, `search`, and `write`; Atomic's public `search` export is the corresponding surface for pi's upstream `grep` tool. The built-in factories use these values directly, so consumers do not need to duplicate prompt text.
1524
-
1525
- Use Atomic's export rather than importing `StringEnum` directly from Pi. It preserves Pi's Google-compatible runtime schema while keeping the schema typed against Atomic's direct TypeBox version.
1526
-
1527
- ```typescript
1528
- import { Type } from "typebox";
1529
- import { StringEnum } from "@bastani/atomic";
1530
-
1531
- pi.registerTool({
1532
- name: "my_tool",
1533
- label: "My Tool",
1534
- description: "What this tool does",
1535
- promptSnippet: "Summarize or transform text according to action",
1536
- promptGuidelines: ["Use my_tool when the user asks to summarize previously generated text."],
1537
- parameters: Type.Object({
1538
- action: StringEnum(["list", "add"] as const),
1539
- text: Type.Optional(Type.String()),
1540
- }),
1541
- prepareArguments(args) {
1542
- // Optional compatibility shim. Runs before schema validation.
1543
- // Return the current schema shape, for example to fold legacy fields
1544
- // into the modern parameter object.
1545
- return args;
1546
- },
1547
-
1548
- async execute(toolCallId, params, signal, onUpdate, ctx) {
1549
- // Stream progress
1550
- onUpdate?.({ content: [{ type: "text", text: "Working..." }] });
1551
-
1552
- return {
1553
- content: [{ type: "text", text: "Done" }],
1554
- details: { result: "..." },
1555
- };
1556
- },
1557
-
1558
- // Optional: Custom rendering
1559
- renderCall(args, theme, context) { ... },
1560
- renderResult(result, options, theme, context) { ... },
1561
- });
1562
- ```
1563
-
1564
- ### pi.sendMessage(message, options?)
1565
-
1566
- Inject a custom message into the session. The call returns `void | Promise<void>` for compatibility with synchronous hosts; use `await Promise.resolve(pi.sendMessage(...))` when admission or routing failure must be observed. Atomic's AgentSession runtime returns an admission receipt: it settles after the message is accepted by the local queue or workflow late-message route, without waiting for the resulting model turn to finish.
1567
-
1568
- ```typescript
1569
- pi.sendMessage({
1570
- customType: "my-extension",
1571
- content: "Message text",
1572
- display: true,
1573
- details: { ... },
1574
- }, {
1575
- triggerTurn: true,
1576
- deliverAs: "steer",
1577
- });
1578
- ```
1579
-
1580
- **Options:**
1581
- - `deliverAs` - Delivery mode:
1582
- - `"steer"` (default) - Queues the message while streaming. Delivered after the current assistant turn finishes executing its tool calls, before the next LLM call.
1583
- - `"followUp"` - Waits for agent to finish. Delivered only when agent has no more tool calls.
1584
- - `"nextTurn"` - Queued for next user prompt. Does not interrupt or trigger anything.
1585
- - `"interrupt"` - With `triggerTurn: true`, aborts an active streaming turn and immediately starts a new turn with the custom message. When idle, behaves like a triggered custom message.
1586
- - `triggerTurn: true` - If agent is idle, trigger an LLM response immediately. Required for `"interrupt"`; ignored for `"nextTurn"`.
1587
- - `excludeFromContext: true` - Render and persist the custom message without adding it to LLM context. With no `deliverAs`, this remains display-only even while the agent is streaming.
1588
- - `interruptAbortMessage` - Optional text used to replace generic abort results (for example `Operation aborted`) when `deliverAs: "interrupt"` aborts an active turn.
1589
-
1590
- ### pi.sendMessages(messages, options?)
1591
-
1592
- Atomically admit a batch of custom messages in array order. The call returns `void | Promise<void>` for compatibility with synchronous hosts; use `await Promise.resolve(pi.sendMessages(...))` when admission or routing failure must be observed. The promise is an admission receipt and does not wait for the resulting model turn. Admission is indivisible; use this when a prelude and terminal notice must stay contiguous without globally serializing other extension work.
1593
-
1594
- ```typescript
1595
- pi.sendMessages([
1596
- { customType: "worker-update", content: "Ready", display: true },
1597
- { customType: "worker-terminal", content: "Completed", display: true },
1598
- ], { triggerTurn: true });
1599
- ```
1600
-
1601
- The batch supports `triggerTurn`, `excludeFromContext`, and `deliverAs: "steer" | "followUp" | "nextTurn"`. Interrupt delivery remains a single-message operation.
1602
-
1603
- ### pi.sendUserMessage(content, options?)
1604
-
1605
- Send a user message to the agent. Unlike `sendMessage()` which sends custom messages, this sends an actual user message that appears as if typed by the user. Always triggers a turn.
1606
-
1607
- ```typescript
1608
- // Simple text message
1609
- pi.sendUserMessage("What is 2+2?");
1610
-
1611
- // With content array (text + images)
1612
- pi.sendUserMessage([
1613
- { type: "text", text: "Describe this image:" },
1614
- { type: "image", source: { type: "base64", mediaType: "image/png", data: "..." } },
1615
- ]);
1616
-
1617
- // During streaming - must specify delivery mode
1618
- pi.sendUserMessage("Focus on error handling", { deliverAs: "steer" });
1619
- pi.sendUserMessage("And then summarize", { deliverAs: "followUp" });
1620
-
1621
- // Opt in to extension command dispatch and skill/prompt template expansion
1622
- pi.sendUserMessage("/review src/index.ts", { expandPromptTemplates: true });
1623
- ```
1624
-
1625
- **Options:**
1626
- - `deliverAs` - Required when agent is streaming:
1627
- - `"steer"` - Queues the message for delivery after the current assistant turn finishes executing its tool calls
1628
- - `"followUp"` - Waits for agent to finish all tools
1629
-
1630
- - `expandPromptTemplates` - Dispatch extension commands and expand skill commands and prompt templates instead of sending the text literally. Defaults to `false`, so an extension-authored message is sent as-is unless it opts in; an unknown command falls through to a literal send.
1631
-
1632
- When not streaming, the message is sent immediately and triggers a new turn. When streaming without `deliverAs`, throws an error.
1633
-
1634
- See [send-user-message.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/send-user-message.ts) for a complete example.
1635
-
1636
- ### pi.appendEntry(customType, data?)
1637
-
1638
- Persist extension state (does NOT participate in LLM context).
1639
-
1640
- ```typescript
1641
- pi.appendEntry("my-state", { count: 42 });
1642
-
1643
- // Restore on reload
1644
- pi.on("session_start", async (_event, ctx) => {
1645
- for (const entry of ctx.sessionManager.getEntries()) {
1646
- if (entry.type === "custom" && entry.customType === "my-state") {
1647
- // Reconstruct from entry.data
1648
- }
1649
- }
1650
- });
1651
- ```
1652
-
1653
- Appending emits `entry_appended` with the durable entry. This lets extensions react to session entries without polling.
1654
-
1655
- ### pi.registerEntryRenderer(customType, renderer)
1656
-
1657
- Register a TUI renderer for durable custom entries created by `pi.appendEntry()`. These entries render in the transcript but do not enter model context.
1658
-
1659
- ```typescript
1660
- import { Text } from "@earendil-works/pi-tui";
1661
-
1662
- pi.registerEntryRenderer("status-card", (entry, { expanded }, theme) =>
1663
- new Text(theme.fg("accent", `${expanded ? "Details" : "Status"}: ${JSON.stringify(entry.data)}`), 0, 0)
1664
- );
1665
- ```
1666
-
1667
-
1668
- ### pi.setSessionName(name)
1669
-
1670
- Set the session display name (shown in session selector instead of first message).
1671
-
1672
- ```typescript
1673
- pi.setSessionName("Refactor auth module");
1674
- ```
1675
-
1676
- ### pi.getSessionName()
1677
-
1678
- Get the current session name, if set.
1679
-
1680
- ```typescript
1681
- const name = pi.getSessionName();
1682
- if (name) {
1683
- console.log(`Session: ${name}`);
1684
- }
1685
- ```
1686
-
1687
- ### pi.setLabel(entryId, label)
1688
-
1689
- Set or clear a label on an entry. Labels are user-defined markers for bookmarking and navigation (shown in `/tree` selector).
1690
-
1691
- ```typescript
1692
- // Set a label
1693
- pi.setLabel(entryId, "checkpoint-before-refactor");
1694
-
1695
- // Clear a label
1696
- pi.setLabel(entryId, undefined);
1697
-
1698
- // Read labels via sessionManager
1699
- const label = ctx.sessionManager.getLabel(entryId);
1700
- ```
1701
-
1702
- Labels persist in the session and survive restarts. Use them to mark important points (turns, checkpoints) in the conversation tree.
1703
-
1704
- ### pi.registerCommand(name, options)
1705
-
1706
- Register a command.
1707
-
1708
- If multiple extensions register the same command name, Atomic keeps them all and assigns numeric invocation suffixes in load order, for example `/review:1` and `/review:2`.
1709
-
1710
- ```typescript
1711
- pi.registerCommand("stats", {
1712
- description: "Show session statistics",
1713
- handler: async (args, ctx) => {
1714
- const count = ctx.sessionManager.getEntries().length;
1715
- ctx.ui.notify(`${count} entries`, "info");
1716
- }
1717
- });
1718
- ```
1719
-
1720
- Optional: add argument auto-completion for `/command ...`:
1721
-
1722
- ```typescript
1723
- import type { AutocompleteItem } from "@earendil-works/pi-tui";
1724
-
1725
- pi.registerCommand("deploy", {
1726
- description: "Deploy to an environment",
1727
- getArgumentCompletions: (prefix: string): AutocompleteItem[] | null => {
1728
- const envs = ["dev", "staging", "prod"];
1729
- const items = envs.map((e) => ({ value: e, label: e }));
1730
- const filtered = items.filter((i) => i.value.startsWith(prefix));
1731
- return filtered.length > 0 ? filtered : null;
1732
- },
1733
- handler: async (args, ctx) => {
1734
- ctx.ui.notify(`Deploying: ${args}`, "info");
1735
- },
1736
- });
1737
- ```
1738
-
1739
- ### pi.getCommands()
1740
-
1741
- Get the slash commands available for invocation via `prompt` in the current session. Includes extension commands, prompt templates, and skill commands.
1742
- The list matches the RPC `get_commands` ordering: extensions first, then templates, then skills.
1743
-
1744
- ```typescript
1745
- const commands = pi.getCommands();
1746
- const bySource = commands.filter((command) => command.source === "extension");
1747
- const userScoped = commands.filter((command) => command.sourceInfo.scope === "user");
1748
- ```
1749
-
1750
- Each entry has this shape:
1751
-
1752
- ```typescript
1753
- {
1754
- name: string; // Invokable command name without the leading slash. May be suffixed like "review:1"
1755
- description?: string;
1756
- source: "extension" | "prompt" | "skill";
1757
- sourceInfo: {
1758
- path: string;
1759
- source: string;
1760
- scope: "user" | "project" | "temporary";
1761
- origin: "package" | "top-level";
1762
- baseDir?: string;
1763
- };
1764
- }
1765
- ```
1766
-
1767
- Use `sourceInfo` as the canonical provenance field. Do not infer ownership from command names or from ad hoc path parsing.
1768
-
1769
- Built-in interactive commands (like `/model` and `/settings`) are not included here. They are handled only in interactive
1770
- mode and would not execute if sent via `prompt`.
1771
-
1772
- ### pi.registerMessageRenderer(customType, renderer)
1773
-
1774
- Register a custom TUI renderer for messages with your `customType`. The renderer options contain `expanded` and the current numeric `outputPad`, so custom output can align with built-in messages. The same options are provided in normal and isolated-engine rendering. See [Custom UI](#custom-ui).
1775
-
1776
- ### pi.registerMarkdownTransformer(transformer)
1777
-
1778
- Register a synchronous, display-only transformer for Markdown in normal user text, assistant text, and thinking blocks. Atomic runs transformers in extension load order. Each extension retains one transformer, so a later call from that extension replaces its prior transformer. Each transformer receives the Markdown returned by the prior transformer, then Atomic renders the final value with its built-in Markdown renderer.
1779
-
1780
- The transformer receives the Markdown string and a context with:
1781
-
1782
- - `messageType` — `"user"`, `"assistant"`, or `"assistant-thinking"`
1783
- - `isStreaming` — `true` for partial assistant updates; `false` for user, finalized assistant, and restored messages
1784
- - `availableWidth` — exact terminal columns available for the transformed Markdown content
1785
-
1786
- Return the transformed Markdown:
1787
-
1788
- ```typescript
1789
- pi.registerMarkdownTransformer((markdown, { messageType, isStreaming }) => {
1790
- if (isStreaming || messageType === "assistant-thinking") return markdown;
1791
- return markdown.replaceAll("-->", "→");
1792
- });
1793
- ```
1794
-
1795
- If a transformer throws, Atomic keeps the Markdown produced so far and continues with the next transformer. The hook never changes the original message, session transcript, or model context. It runs for new user messages, assistant streaming updates, restored session messages, and terminal-width changes, so keep transformers synchronous and inexpensive. Isolated-engine rendering does not run host-side display transformers.
1796
-
1797
- ### pi.registerShortcut(shortcut, options)
1798
-
1799
- Register a keyboard shortcut. See [Keybindings](/keybindings) for the shortcut format and built-in keybindings.
1800
-
1801
- ```typescript
1802
- pi.registerShortcut("ctrl+shift+p", {
1803
- description: "Toggle plan mode",
1804
- handler: async (ctx) => {
1805
- ctx.ui.notify("Toggled!");
1806
- },
1807
- });
1808
- ```
1809
-
1810
- ### pi.registerFlag(name, options)
1811
-
1812
- Register a CLI flag.
1813
-
1814
- ```typescript
1815
- pi.registerFlag("plan", {
1816
- description: "Start in plan mode",
1817
- type: "boolean",
1818
- default: false,
1819
- });
1820
-
1821
- // Check value
1822
- if (pi.getFlag("plan")) {
1823
- // Plan mode enabled
1824
- }
1825
- ```
1826
-
1827
- ### pi.exec(command, args, options?)
1828
-
1829
- Execute a shell command.
1830
-
1831
- ```typescript
1832
- const result = await pi.exec("git", ["status"], { signal, timeout: 5000 });
1833
- // result.stdout, result.stderr, result.code, result.killed
1834
- ```
1835
-
1836
- ### pi.getActiveTools() / pi.getAllTools() / pi.setActiveTools(names)
1837
-
1838
- Manage active tools. This works for both built-in tools and dynamically registered tools. `pi.getActiveTools()` returns the active tool names as `string[]`; `pi.getAllTools()` returns metadata for all configured tools.
1839
-
1840
- ```typescript
1841
- const active = pi.getActiveTools(); // ["read", "bash", ...]
1842
- const all = pi.getAllTools();
1843
- // all = [{
1844
- // name: "read",
1845
- // description: "Read file contents...",
1846
- // parameters: ...,
1847
- // promptGuidelines: ["Use read to examine files instead of cat or sed."],
1848
- // sourceInfo: { path: "<builtin:read>", source: "builtin", scope: "temporary", origin: "top-level" }
1849
- // }, ...]
1850
- const builtinTools = all.filter((t) => t.sourceInfo.source === "builtin");
1851
- const extensionTools = all.filter((t) => t.sourceInfo.source !== "builtin" && t.sourceInfo.source !== "sdk");
1852
- pi.setActiveTools([...new Set([...active, "my_custom_tool"])]); // Keep current tools and enable my_custom_tool
1853
- pi.setActiveTools(["read", "bash"]); // Switch to read-only
1854
- ```
1855
-
1856
- `pi.getAllTools()` returns `name`, `description`, `parameters`, `promptGuidelines`, and `sourceInfo`.
1857
-
1858
- Typical `sourceInfo.source` values:
1859
- - `builtin` for built-in tools
1860
- - `sdk` for tools passed via `createAgentSession({ customTools })`
1861
- - extension source metadata for tools registered by extensions
1862
-
1863
- ### pi.setModel(model)
1864
-
1865
- Set the model for the current session. The change is recorded in session history and restored when that session is resumed, but it does not change the configured `defaultProvider` or `defaultModel` used by new sessions. Returns `false` if authentication is not configured for the model's provider. See [Custom models](/models) for configuring custom models.
1866
-
1867
- ```typescript
1868
- const model = ctx.modelRegistry.find("anthropic", "claude-sonnet-4-5");
1869
- if (model) {
1870
- const success = await pi.setModel(model);
1871
- if (!success) {
1872
- ctx.ui.notify("No API key for this model", "error");
1873
- }
1874
- }
1875
- ```
1876
-
1877
- ### pi.getThinkingLevel() / pi.setThinkingLevel(level)
1878
-
1879
- Get the current thinking level. Level is clamped to model capabilities (non-reasoning models always use `"off"`; `"xhigh"` and `"max"` require model support). Changes emit `thinking_level_select`.
1880
-
1881
- `pi.setThinkingLevel()` changes the thinking level for the current session. The change is recorded in session history and restored when that session is resumed, but it does not change the configured default used by new sessions.
1882
-
1883
- ```typescript
1884
- const current = pi.getThinkingLevel(); // "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"
1885
- pi.setThinkingLevel("high");
1886
- ```
1887
-
1888
- ### pi.events
1889
-
1890
- Shared event bus for communication between active extensions. A subscription made with `on()` is removed automatically when its extension reloads or the session disposes. Use the returned function if you need to stop listening sooner:
1891
-
1892
- ```typescript
1893
- const unsubscribe = pi.events.on("my:event", (data) => { ... });
1894
- pi.events.emit("my:event", { ... });
1895
- unsubscribe();
1896
- ```
1897
-
1898
- `pi.events` belongs to the extension instance that received it. Register listeners again when that instance reloads, and do not retain the object for later use: calling `on()` or `emit()` through a captured handle after reload or disposal throws. To keep in-memory state across `/reload`, pass this facade to [`sessionScopedExtensionState`](#session-scoped-in-memory-state); do not capture the facade itself.
1899
-
1900
- If you implement an `ExtensionRuntime` for an embedded host, provide `trackEventBusSubscription(unsubscribe)` and retain each returned subscription until that extension runtime is reloaded or disposed. `ExtensionUIContext.getChatRenderSettings()` must return `markdownTransformers`; it may also return `renderLatex` to control terminal math rendering. These fields keep event subscriptions and display transforms scoped to the active extension instance.
1901
-
1902
-
1903
- ### Native providers
1904
-
1905
- In addition to `registerProvider(name, config)`, extensions can register a complete native `Provider` from `@bastani/pi-ai` with `pi.registerProvider(provider)`. Use the native overload for provider-owned authentication, catalog refresh, and transport behavior; use the config overload for ordinary proxies and custom endpoints.
1906
-
1907
- ### pi.registerProvider(name, config)
1908
-
1909
- Register or override a model provider dynamically. Useful for proxies, custom endpoints, or team-wide model configurations.
1910
-
1911
- Calls made during the extension factory function are queued and applied once the runner initialises. Calls made after that — for example from a command handler following a user setup flow — take effect immediately without requiring a `/reload`.
1912
-
1913
- If you need to discover models from a remote endpoint, prefer an async extension factory over deferring the fetch to `session_start`. Atomic waits for the factory before startup continues, so the registered models are available immediately, including to `atomic --list-models`.
1914
-
1915
- ```typescript
1916
- // Register a new provider with custom models
1917
- pi.registerProvider("my-proxy", {
1918
- name: "My Proxy",
1919
- baseUrl: "https://proxy.example.com",
1920
- apiKey: "$PROXY_API_KEY", // env var reference; omit $ for a literal
1921
- api: "anthropic-messages",
1922
- models: [
1923
- {
1924
- id: "claude-sonnet-4-20250514",
1925
- name: "Claude 4 Sonnet (proxy)",
1926
- reasoning: false,
1927
- input: ["text", "image"],
1928
- cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
1929
- contextWindow: 200000,
1930
- maxTokens: 16384
1931
- }
1932
- ]
1933
- });
1934
-
1935
- // Override baseUrl for an existing provider (keeps all models)
1936
- pi.registerProvider("anthropic", {
1937
- baseUrl: "https://proxy.example.com"
1938
- });
1939
-
1940
- // Register provider with OAuth support for /login
1941
- pi.registerProvider("corporate-ai", {
1942
- baseUrl: "https://ai.corp.com",
1943
- api: "openai-responses",
1944
- models: [...],
1945
- oauth: {
1946
- name: "Corporate AI (SSO)",
1947
- async login(callbacks, signal) {
1948
- // Custom OAuth flow
1949
- callbacks.onAuth({ url: "https://sso.corp.com/..." });
1950
- const code = await callbacks.onPrompt({ message: "Enter code:" });
1951
- signal.throwIfAborted();
1952
- return { refresh: code, access: code, expires: Date.now() + 3600000 };
1953
- },
1954
- async refreshToken(credentials, signal) {
1955
- // Forward signal to the refresh request.
1956
- signal.throwIfAborted();
1957
- return credentials;
1958
- },
1959
- getApiKey(credentials) {
1960
- return credentials.access;
1961
- }
1962
- }
1963
- });
1964
-
1965
- // Register provider-owned API-key setup for /login
1966
- pi.registerProvider("local-server", {
1967
- name: "Local Server",
1968
- auth: {
1969
- apiKey: {
1970
- name: "Local server connection",
1971
- async login({ signal, prompt }) {
1972
- const baseUrl = await prompt({
1973
- type: "text",
1974
- message: "Server URL",
1975
- placeholder: "http://localhost:8080"
1976
- });
1977
- if (signal.aborted) throw new Error("Login cancelled");
1978
- return { type: "api_key", env: { LOCAL_SERVER_URL: baseUrl } };
1979
- }
1980
- }
1981
- }
1982
- });
1983
- ```
1984
-
1985
- **Config options:**
1986
- - `name` - Display name for the provider in UI such as `/login`.
1987
- - `baseUrl` - API endpoint URL. Required when defining models.
1988
- - `apiKey` - API key literal or explicit environment variable reference (`$ENV_VAR` or `${ENV_VAR}`). Required when defining models (unless `oauth` provided).
1989
- - `api` - API type: `"anthropic-messages"`, `"openai-completions"`, `"openai-responses"`, etc.
1990
- - `headers` - Custom headers to include in requests.
1991
- - `authHeader` - If true, adds `Authorization: Bearer` header automatically.
1992
- - `models` - Array of model definitions. If provided, replaces all existing models for this provider. Model definitions can set `baseUrl` to override the provider endpoint for that model.
1993
- - `oauth` - OAuth provider config for `/login` support. When provided, the provider appears in the login menu.
1994
- - `auth.apiKey` - Provider-owned API-key or connection setup for `/login`. Its `name` appears in the provider list and `login({ signal, prompt })` returns the credential Atomic persists. Extension providers registered only in the isolated interactive engine child are synchronized into the host's `/login` list; their login callback and credential-dependent model refresh still execute in the child, while prompts are rendered by the terminal host.
1995
- - `streamSimple` - Custom streaming implementation for non-standard APIs.
1996
-
1997
- See [Custom providers](/custom-provider) for advanced topics: custom streaming APIs, OAuth details, model definition reference.
1998
-
1999
- ### pi.unregisterProvider(name)
2000
-
2001
- Remove a previously registered provider and its models. Built-in models that were overridden by the provider are restored. Has no effect if the provider was not registered.
2002
-
2003
- Like `registerProvider`, this takes effect immediately when called after the initial load phase, so a `/reload` is not required.
2004
-
2005
- ```typescript
2006
- pi.registerCommand("my-setup-teardown", {
2007
- description: "Remove the custom proxy provider",
2008
- handler: async (_args, _ctx) => {
2009
- pi.unregisterProvider("my-proxy");
2010
- },
2011
- });
2012
- ```
2013
-
2014
- ## State Management
2015
-
2016
- Choose the store that matches the lifetime you need:
2017
-
2018
- - **Tool result `details`** — reconstructs across `/branch` and `/resume` from the transcript.
2019
- - **`pi.appendEntry()`** — durable custom entries that survive process restart. They do not enter model context.
2020
- - **`sessionScopedExtensionState()`** — in-memory objects that survive `/reload` for the current process. They do not survive process restart.
2021
-
2022
- In Bun single-file builds, an editable file extension whose imported graph is unchanged can reuse its evaluated factory, so its module-scoped variables may survive `/reload`. An edit anywhere in that graph re-evaluates its modules and resets those singletons. The five fixed installed builtin bundles always reuse their evaluated factories and module state across `/reload`, as described above.
2023
-
2024
- Extensions with state that must follow conversation branches should store it in tool result `details`:
2025
-
2026
- ```typescript
2027
- export default function (pi: ExtensionAPI) {
2028
- let items: string[] = [];
2029
-
2030
- // Reconstruct state from session
2031
- pi.on("session_start", async (_event, ctx) => {
2032
- items = [];
2033
- for (const entry of ctx.sessionManager.getBranch()) {
2034
- if (entry.type === "message" && entry.message.role === "toolResult") {
2035
- if (entry.message.toolName === "my_tool") {
2036
- items = entry.message.details?.items ?? [];
2037
- }
2038
- }
2039
- }
2040
- });
2041
-
2042
- pi.registerTool({
2043
- name: "my_tool",
2044
- // ...
2045
- async execute(toolCallId, params, signal, onUpdate, ctx) {
2046
- items.push("new item");
2047
- return {
2048
- content: [{ type: "text", text: "Added" }],
2049
- details: { items: [...items] }, // Store for reconstruction
2050
- };
2051
- },
2052
- });
2053
- }
2054
- ```
2055
-
2056
- ### Session-scoped in-memory state
2057
-
2058
- Import `sessionScopedExtensionState` from `@bastani/atomic` when an extension must keep a live object across `/reload` — registries, abort controllers, connection pools, or any other handle that cannot be rebuilt from the transcript.
2059
-
2060
- ```typescript
2061
- import { sessionScopedExtensionState, type ExtensionAPI } from "@bastani/atomic";
2062
-
2063
- interface CounterState {
2064
- count: number;
2065
- }
613
+ ### Fireworks deferred tool loading
2066
614
 
2067
- export default function (pi: ExtensionAPI) {
2068
- const state = sessionScopedExtensionState(pi.events, "my-extension:counter:v1", () => ({
2069
- count: 0,
2070
- }));
2071
-
2072
- pi.registerCommand("bump", {
2073
- description: "Increment a counter that survives /reload",
2074
- handler: async (_args, ctx) => {
2075
- state.count += 1;
2076
- ctx.ui.notify(`count=${state.count}`, "info");
2077
- },
2078
- });
2079
- }
2080
- ```
2081
-
2082
- **Required scope.** Pass the extension's `pi.events` facade (or the session `EventBus` itself). The host resolves that facade to the canonical session bus, so every load generation of one session re-binds to the same object. Two in-process sessions with distinct buses stay isolated. Do not pass an arbitrary object: an unregistered scope is treated as its own bus and will not re-bind after reload.
2083
-
2084
- **Session-wide key namespace.** Keys are not automatically namespaced by extension. Two extensions that pass the same key on the same session receive the first extension's object; the later factory is not called. Prefix every key with a stable extension identity.
2085
-
2086
- **Key-versioning.** Append a version suffix and bump it when the stored shape changes, for example `"my-extension:counter:v1"` → `"my-extension:counter:v2"`. The new key declines the incompatible predecessor instead of reusing it under a new type.
2087
-
2088
- **Reload behavior.** `/reload` builds a new `pi.events` facade that still forwards to the same bus. Calling `sessionScopedExtensionState` again with the same namespaced key returns the existing object and does not invoke `create`. The reload transaction does not clone this object or roll back mutations that extension factory code makes to it. Keep factory setup idempotent, and mutate durable state only after the new generation starts when failed reloads must not affect it. Entries live exactly as long as that bus. They are not written to the session file; use `pi.appendEntry()` when the data must survive process restart.
2089
-
2090
- **Shutdown.** `session_shutdown` still runs for resources you opened. If the object holds sockets, watchers, or timers, close them there. The next `session_start` or first use can recreate them inside the same session-scoped object.
2091
-
2092
-
2093
- ## Custom Tools
2094
-
2095
- Register tools the LLM can call via `pi.registerTool()`. Tools appear in the system prompt and can have custom rendering.
2096
-
2097
- Use `promptSnippet` for a short one-line entry in the `Available tools` section in the default system prompt. If omitted, custom tools are left out of that section.
2098
-
2099
- Use `promptGuidelines` to add tool-specific bullets to the default system prompt `Guidelines` section. These bullets are included only while the tool is active (for example, after `pi.setActiveTools([...])`).
2100
-
2101
- **Important:** `promptGuidelines` bullets are appended flat to the `Guidelines` section with no tool name prefix or grouping. Each guideline must name the tool it refers to — avoid "Use this tool when..." because the LLM cannot tell which tool "this" means. Write "Use my_tool when..." instead.
2102
-
2103
- Note: Some models are idiots and include the @ prefix in tool path arguments. Built-in tools strip a leading @ before resolving paths. If your custom tool accepts a path, normalize a leading @ as well.
2104
-
2105
- If your custom tool mutates files, use `withFileMutationQueue()` so it participates in the same per-file queue as built-in `edit` and `write`. This matters because tool calls run in parallel by default. Without the queue, two tools can read the same old file contents, compute different updates, and then whichever write lands last overwrites the other.
2106
-
2107
- Example failure case: your custom tool edits `foo.ts` while built-in `edit` also changes `foo.ts` in the same assistant turn. If your tool does not participate in the queue, both can read the original `foo.ts`, apply separate changes, and one of those changes is lost.
2108
-
2109
- Pass the real target file path to `withFileMutationQueue()`, not the raw user argument. Resolve it to an absolute path first, relative to `ctx.cwd` or your tool's working directory. For existing files, the helper canonicalizes through `realpath()`, so symlink aliases for the same file share one queue. For new files, it falls back to the resolved absolute path because there is nothing to `realpath()` yet.
2110
-
2111
- Queue the entire mutation window on that target path. That includes read-modify-write logic, not just the final write.
2112
-
2113
- ```typescript
2114
- import { withFileMutationQueue } from "@bastani/atomic";
2115
- import { mkdir, readFile, writeFile } from "node:fs/promises";
2116
- import { dirname, resolve } from "node:path";
2117
-
2118
- async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
2119
- const absolutePath = resolve(ctx.cwd, params.path);
2120
-
2121
- return withFileMutationQueue(absolutePath, async () => {
2122
- await mkdir(dirname(absolutePath), { recursive: true });
2123
- const current = await readFile(absolutePath, "utf8");
2124
- const next = current.replace(params.oldText, params.newText);
2125
- await writeFile(absolutePath, next, "utf8");
2126
-
2127
- return {
2128
- content: [{ type: "text", text: `Updated ${params.path}` }],
2129
- details: {},
2130
- };
2131
- });
2132
- }
2133
- ```
2134
-
2135
- ### Tool Definition
2136
-
2137
- ```typescript
2138
- import { Type } from "typebox";
2139
- import { StringEnum } from "@bastani/atomic";
2140
- import { Text } from "@earendil-works/pi-tui";
2141
-
2142
- pi.registerTool({
2143
- name: "my_tool",
2144
- label: "My Tool",
2145
- description: "What this tool does (shown to LLM)",
2146
- promptSnippet: "List or add items in the project todo list",
2147
- promptGuidelines: [
2148
- "Use my_tool for todo planning instead of direct file edits when the user asks for a task list."
2149
- ],
2150
- parameters: Type.Object({
2151
- action: StringEnum(["list", "add"] as const), // Atomic's Pi-compatible TypeBox helper
2152
- text: Type.Optional(Type.String()),
2153
- }),
2154
- prepareArguments(args) {
2155
- if (!args || typeof args !== "object") return args;
2156
- const input = args as { action?: string; oldAction?: string };
2157
- if (typeof input.oldAction === "string" && input.action === undefined) {
2158
- return { ...input, action: input.oldAction };
2159
- }
2160
- return args;
2161
- },
2162
-
2163
- async execute(toolCallId, params, signal, onUpdate, ctx) {
2164
- // Check for cancellation
2165
- if (signal?.aborted) {
2166
- return { content: [{ type: "text", text: "Cancelled" }] };
2167
- }
2168
-
2169
- // Stream progress updates
2170
- onUpdate?.({
2171
- content: [{ type: "text", text: "Working..." }],
2172
- details: { progress: 50 },
2173
- });
2174
-
2175
- // Run commands via pi.exec (captured from extension closure)
2176
- const result = await pi.exec("some-command", [], { signal });
2177
-
2178
- // Return result
2179
- return {
2180
- content: [{ type: "text", text: "Done" }], // Sent to LLM
2181
- details: { data: result }, // For rendering & state
2182
- // Optional: stop after this tool batch when every finalized tool result
2183
- // in the batch also returns terminate: true.
2184
- terminate: true,
2185
- };
2186
- },
2187
-
2188
- // Optional: Custom rendering
2189
- renderCall(args, theme, context) { ... },
2190
- renderResult(result, options, theme, context) { ... },
2191
- });
2192
- ```
2193
-
2194
- **Signaling errors:** To mark a tool execution as failed (sets `isError: true` on the result and reports it to the LLM), throw an error from `execute`. Returning a value never sets the error flag regardless of what properties you include in the return object.
2195
-
2196
- **Early termination:** Return `terminate: true` from `execute()` to hint that the automatic follow-up LLM call should be skipped after the current tool batch. This only takes effect when every finalized tool result in that batch is terminating. Atomic does not register `structured_output` in normal agent sessions by default; use `createStructuredOutputTool({ schema, capture, output, name })` when an extension, SDK session, or workflow stage needs a schema-backed final-answer tool. The factory uses the supplied schema as the tool parameters directly, captures the tool arguments as whatever JSON value matches the schema, emits the same pretty-printed JSON as the terminating tool-result text for `atomic -p`, optionally writes them to the configured `output.outputPath`, and terminates the turn. In text print mode, a terminating result from a factory-created structured-output tool is emitted to stdout as the final response. Custom factory names are opt-in tools: if you register `final_decision`, include `final_decision` in any explicit `tools` allowlist; if you register the default `structured_output` name, it is available only to that session/runtime.
2197
-
2198
- ```typescript
2199
- // Correct: throw to signal an error
2200
- async execute(toolCallId, params) {
2201
- if (!isValid(params.input)) {
2202
- throw new Error(`Invalid input: ${params.input}`);
2203
- }
2204
- return { content: [{ type: "text", text: "OK" }], details: {} };
2205
- }
2206
- ```
2207
-
2208
- **Important:** Use `StringEnum` from `@bastani/atomic` for string enums. It retains Pi's Google-compatible schema and composes with Atomic's direct TypeBox types; `Type.Union`/`Type.Literal` doesn't work with Google's API.
2209
-
2210
- #### Constrained sampling
2211
-
2212
- `ToolDefinition.constrainedSampling` is preserved for extension tools, SDK `customTools`, wrappers, and isolated execution. It accepts `false` or the exported `ConstrainedSamplingConfig`:
2213
-
2214
- ```typescript
2215
- pi.registerTool({
2216
- name: "strict_edit",
2217
- label: "Strict edit",
2218
- description: "Edit one file",
2219
- parameters: Type.Object({ path: Type.String(), content: Type.String() }),
2220
- constrainedSampling: { type: "json_schema", strict: "prefer" },
2221
- async execute(_id, params) {
2222
- return { content: [{ type: "text", text: params.path }], details: {} };
2223
- },
2224
- });
2225
- ```
2226
-
2227
- Exact modes:
2228
-
2229
- - `{ type: "json_schema", strict: "prefer" }` requests strict provider enforcement and falls back to ordinary tool calling when unavailable.
2230
- - `{ type: "json_schema", strict: "require" }` fails the request rather than silently weakening the constraint.
2231
- - `{ type: "grammar", variants: { openai_lark?: string, openai_regex?: string } }` requests an OpenAI custom grammar tool; Lark wins when both non-empty variants are present.
2232
- - `false` explicitly opts out. Its runtime effect matches omission, but public tool inspection preserves `false` as a present property.
2233
-
2234
- Atomic preserves the optional property's exact own-key state across wrappers, active-session inspection, staged extension inspection, bundled tools, and isolated transport: omission stays absent; explicitly present `undefined` stays present; `false` and config objects remain unchanged. This distinction matters to SDK/extension code that uses `Object.hasOwn()` rather than an ordinary property read.
2235
-
2236
- Grammar tools require an object schema with exactly one required string property. They are emitted only when model metadata advertises `supportsOpenAIGrammarTools` (also exposed as Atomic's `supportsGrammarTools` alias); otherwise provider handling falls back to the normal function/JSON-schema path. Older OpenAI models and gateways that rewrite schemas cannot honor custom grammar tools. Typed RPC clients receive these claims through optional `ModelInfo.compat`. See [Custom Models](/models#constrained-tool-sampling) and [RPC](/rpc#get_available_models).
2237
-
2238
- **Argument preparation:** `prepareArguments(args)` is optional. If defined, it runs before schema validation and before `execute()`. Use it only when a custom tool must normalize arguments before validation. Return the object you want validated against `parameters`, keep the public schema strict, and avoid advertising deprecated fields.
2239
-
2240
- ```typescript
2241
- pi.registerTool({
2242
- name: "deploy_plan",
2243
- label: "Deploy Plan",
2244
- description: "Create a deployment plan for one target environment",
2245
- parameters: Type.Object({
2246
- environment: Type.String(),
2247
- dryRun: Type.Optional(Type.Boolean()),
2248
- }),
2249
- prepareArguments(args) {
2250
- if (!args || typeof args !== "object") return args;
2251
- const input = args as { env?: unknown; environment?: unknown; dryRun?: unknown };
2252
- if (typeof input.environment === "string") return args;
2253
- if (typeof input.env !== "string") return args;
2254
- return { environment: input.env, dryRun: input.dryRun };
2255
- },
2256
- async execute(toolCallId, params) {
2257
- return {
2258
- content: [{ type: "text", text: `Planning deploy to ${params.environment}` }],
2259
- details: {},
2260
- };
2261
- },
2262
- });
2263
- ```
615
+ Moved to [Writing extensions](/extensions/authoring#fireworks-deferred-tool-loading).
2264
616
 
2265
617
  ### Overriding Built-in Tools
2266
618
 
2267
- Extensions can override built-in tools (`read`, `bash`, `powershell`, `edit`, `write`, `find`, `search`, `ask_user_question`, `todo`) by registering a tool with the same name. Interactive mode displays a warning when this happens.
2268
-
2269
- ```bash
2270
- # Extension's read tool replaces built-in read
2271
- atomic -e ./tool-override.ts
2272
- ```
2273
-
2274
- Alternatively, use `--no-builtin-tools` to start without any built-in tools while keeping extension tools enabled:
2275
- ```bash
2276
- # No built-in tools, only extension tools
2277
- atomic --no-builtin-tools -e ./my-extension.ts
2278
- ```
2279
-
2280
- See [examples/extensions/tool-override.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/tool-override.ts) for a complete example that overrides `read` with logging and access control.
2281
-
2282
- **Rendering:** Built-in renderer inheritance is resolved per slot. Execution override and rendering override are independent. If your override omits `renderCall`, the built-in `renderCall` is used. If your override omits `renderResult`, the built-in `renderResult` is used. If your override omits both, the built-in renderer is used automatically (syntax highlighting, diffs, etc.). This lets you wrap built-in tools for logging or access control without reimplementing the UI.
2283
-
2284
- **Prompt metadata:** `promptSnippet` and `promptGuidelines` are not inherited from the built-in tool. If your override should keep those prompt instructions, define them on the override explicitly.
2285
-
2286
- **Your implementation must match the exact result shape**, including the `details` type. The UI and session logic depend on these shapes for rendering and state tracking.
2287
-
2288
- Built-in tool implementations:
2289
- - [read.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/tools/read.ts) - `ReadToolDetails`
2290
- - [bash.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/tools/bash.ts) - `BashToolDetails`
2291
- - [edit.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/tools/edit.ts)
2292
- - [write.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/tools/write.ts)
2293
- - [grep.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/tools/grep.ts) - `GrepToolDetails`
2294
- - [find.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/tools/find.ts) - `FindToolDetails`
2295
- - [ls.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/tools/ls.ts) - `LsToolDetails`
619
+ Moved to [Writing extensions](/extensions/authoring#overriding-built-in-tools).
2296
620
 
2297
621
  ### Remote Execution
2298
622
 
2299
- Built-in tools support pluggable operations for delegating to remote systems (SSH, containers, etc.):
2300
-
2301
- ```typescript
2302
- import { createReadTool, createBashTool, type ReadOperations } from "@bastani/atomic";
2303
-
2304
- // Create tool with custom operations
2305
- const remoteRead = createReadTool(cwd, {
2306
- operations: {
2307
- readFile: (path) => sshExec(remote, `cat ${path}`),
2308
- access: (path) => sshExec(remote, `test -r ${path}`).then(() => {}),
2309
- }
2310
- });
2311
-
2312
- // Register, checking flag at execution time
2313
- pi.registerTool({
2314
- ...remoteRead,
2315
- async execute(id, params, signal, onUpdate, _ctx) {
2316
- const ssh = getSshConfig();
2317
- if (ssh) {
2318
- const tool = createReadTool(cwd, { operations: createRemoteOps(ssh) });
2319
- return tool.execute(id, params, signal, onUpdate);
2320
- }
2321
- return localRead.execute(id, params, signal, onUpdate);
2322
- },
2323
- });
2324
- ```
2325
-
2326
- `ReadOperations` may also provide `stat` and `listDir` to keep directory-tree reads on the injected filesystem. The Harness factory supplies both. A custom read backend without both members keeps the existing file-only remote behavior. Archive, SQLite, internal-resource, notebook, and path-variant helpers still use Atomic's local filesystem unless the tool gains dedicated remote seams.
2327
-
2328
- **Operations interfaces:** `ReadOperations`, `WriteOperations`, `EditOperations`, `BashOperations`, `LsOperations`, `GrepOperations`, `FindOperations`
2329
-
2330
- For `user_bash`, extensions can reuse atomic's local shell backend via `createLocalBashOperations()` instead of reimplementing local process spawning, shell resolution, and process-tree termination.
2331
-
2332
- The bash tool also supports a spawn hook to adjust the command, cwd, or env before execution:
2333
-
2334
- ```typescript
2335
- import { createBashTool } from "@bastani/atomic";
2336
-
2337
- const bashTool = createBashTool(cwd, {
2338
- spawnHook: ({ command, cwd, env }) => ({
2339
- command: `source ~/.profile\n${command}`,
2340
- cwd: `/mnt/sandbox${cwd}`,
2341
- env: { ...env, CI: "1" },
2342
- }),
2343
- });
2344
- ```
2345
-
2346
- See [examples/extensions/ssh.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/ssh.ts) for a complete SSH example with `--ssh` flag.
623
+ Moved to [Writing extensions](/extensions/authoring#remote-execution).
2347
624
 
2348
625
  ### Output Truncation
2349
626
 
2350
- **Tools MUST truncate their output** to avoid overwhelming the LLM context. Large outputs can cause:
2351
- - Context overflow errors (prompt too long)
2352
- - Compaction failures
2353
- - Degraded model performance
2354
-
2355
- The built-in limit is **50KB** (~10k tokens) and **2000 lines**, whichever is hit first. Use the exported truncation utilities:
2356
-
2357
- ```typescript
2358
- import {
2359
- truncateHead, // Keep first N lines/bytes (good for file reads, search results)
2360
- truncateTail, // Keep last N lines/bytes (good for logs, command output)
2361
- truncateLine, // Truncate a single line to maxBytes with ellipsis
2362
- formatSize, // Human-readable size (e.g., "50KB", "1.5MB")
2363
- DEFAULT_MAX_BYTES, // 50KB
2364
- DEFAULT_MAX_LINES, // 2000
2365
- } from "@bastani/atomic";
2366
-
2367
- async execute(toolCallId, params, signal, onUpdate, ctx) {
2368
- const output = await runCommand();
2369
-
2370
- // Apply truncation
2371
- const truncation = truncateHead(output, {
2372
- maxLines: DEFAULT_MAX_LINES,
2373
- maxBytes: DEFAULT_MAX_BYTES,
2374
- });
2375
-
2376
- let result = truncation.content;
2377
-
2378
- if (truncation.truncated) {
2379
- // Write full output to temp file
2380
- const tempFile = writeTempFile(output);
2381
-
2382
- // Inform the LLM where to find complete output
2383
- result += `\n\n[Output truncated: ${truncation.outputLines} of ${truncation.totalLines} lines`;
2384
- result += ` (${formatSize(truncation.outputBytes)} of ${formatSize(truncation.totalBytes)}).`;
2385
- result += ` Full output saved to: ${tempFile}]`;
2386
- }
2387
-
2388
- return { content: [{ type: "text", text: result }] };
2389
- }
2390
- ```
2391
-
2392
- **Key points:**
2393
- - Use `truncateHead` for content where the beginning matters (search results, file reads)
2394
- - Use `truncateTail` for content where the end matters (logs, command output)
2395
- - Always inform the LLM when output is truncated and where to find the full version
2396
- - Document the truncation limits in your tool's description
2397
-
2398
- See [examples/extensions/truncated-tool.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/truncated-tool.ts) for a complete example wrapping `rg` (ripgrep) with proper truncation.
627
+ Moved to [Writing extensions](/extensions/authoring#output-truncation).
2399
628
 
2400
629
  ### Multiple Tools
2401
630
 
2402
- One extension can register multiple tools with shared state:
2403
-
2404
- ```typescript
2405
- export default function (pi: ExtensionAPI) {
2406
- let connection = null;
2407
-
2408
- pi.registerTool({ name: "db_connect", ... });
2409
- pi.registerTool({ name: "db_query", ... });
2410
- pi.registerTool({ name: "db_close", ... });
2411
-
2412
- pi.on("session_shutdown", async () => {
2413
- connection?.close();
2414
- });
2415
- }
2416
- ```
631
+ Moved to [Writing extensions](/extensions/authoring#multiple-tools).
2417
632
 
2418
633
  ### Custom Rendering
2419
634
 
2420
- Tools can provide `renderCall` and `renderResult` for custom TUI display. See [TUI components](/tui) for the full component API and [tool-execution.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/modes/interactive/components/tool-execution.ts) for how tool rows are composed.
2421
-
2422
- By default, tool output is wrapped in a `Box` that handles padding and background. A defined `renderCall` or `renderResult` must return a `Component`. If a slot renderer is not defined, `tool-execution.ts` uses fallback rendering for that slot.
2423
-
2424
- Set `renderShell: "self"` when the tool should render its own shell instead of using the default `Box`. This is useful for tools that need complete control over framing or background behavior, for example large previews that must stay visually stable after the tool settles.
2425
-
2426
- ```typescript
2427
- pi.registerTool({
2428
- name: "my_tool",
2429
- label: "My Tool",
2430
- description: "Custom shell example",
2431
- parameters: Type.Object({}),
2432
- renderShell: "self",
2433
- async execute() {
2434
- return { content: [{ type: "text", text: "ok" }], details: undefined };
2435
- },
2436
- renderCall(args, theme, context) {
2437
- return new Text(theme.fg("accent", "my custom shell"), 0, 0);
2438
- },
2439
- });
2440
- ```
2441
-
2442
- `renderCall` and `renderResult` each receive a `context` object with:
2443
- - `args` - the current tool call arguments
2444
- - `state` - shared row-local state across `renderCall` and `renderResult`
2445
- - `lastComponent` - the previously returned component for that slot, if any
2446
- - `invalidate()` - request a rerender of this tool row
2447
- - `toolCallId`, `cwd`, `executionStarted`, `argsComplete`, `isPartial`, `expanded`, `showImages`, `isError`
2448
-
2449
- Use `context.state` for cross-slot shared state. Keep slot-local caches on the returned component instance when you want to reuse and mutate the same component across renders.
635
+ Moved to [Writing extensions](/extensions/authoring#custom-rendering).
2450
636
 
2451
637
  #### renderCall
2452
638
 
2453
- Renders the tool call or header:
2454
-
2455
- ```typescript
2456
- import { Text } from "@earendil-works/pi-tui";
2457
-
2458
- renderCall(args, theme, context) {
2459
- const text = (context.lastComponent as Text | undefined) ?? new Text("", 0, 0);
2460
- let content = theme.fg("toolTitle", theme.bold("my_tool "));
2461
- content += theme.fg("muted", args.action);
2462
- if (args.text) {
2463
- content += " " + theme.fg("dim", `"${args.text}"`);
2464
- }
2465
- text.setText(content);
2466
- return text;
2467
- }
2468
- ```
639
+ Moved to [Writing extensions](/extensions/authoring#rendercall).
2469
640
 
2470
641
  #### renderResult
2471
642
 
2472
- Renders the tool result or output:
2473
-
2474
- ```typescript
2475
- renderResult(result, { expanded, isPartial }, theme, context) {
2476
- if (isPartial) {
2477
- return new Text(theme.fg("warning", "Processing..."), 0, 0);
2478
- }
2479
-
2480
- if (result.details?.error) {
2481
- return new Text(theme.fg("error", `Error: ${result.details.error}`), 0, 0);
2482
- }
2483
-
2484
- let text = theme.fg("success", "✓ Done");
2485
- if (expanded && result.details?.items) {
2486
- for (const item of result.details.items) {
2487
- text += "\n " + theme.fg("dim", item);
2488
- }
2489
- }
2490
- return new Text(text, 0, 0);
2491
- }
2492
- ```
2493
-
2494
- If a slot intentionally has no visible content, return an empty `Component` such as an empty `Container`.
643
+ Moved to [Writing extensions](/extensions/authoring#renderresult).
2495
644
 
2496
645
  #### Keybinding Hints
2497
646
 
2498
- Use `keyHintIfBound()` when an affordance should disappear if the action has no effective keybinding. Add surrounding punctuation only when the helper returns text:
2499
-
2500
- ```typescript
2501
- import { keyHintIfBound } from "@bastani/atomic";
2502
-
2503
- renderResult(result, { expanded }, theme, context) {
2504
- let text = theme.fg("success", "✓ Done");
2505
- const expandHint = keyHintIfBound("app.tools.expand", "to expand");
2506
- if (!expanded && expandHint) {
2507
- text += ` (${expandHint})`;
2508
- }
2509
- return new Text(text, 0, 0);
2510
- }
2511
- ```
2512
-
2513
- Available functions:
2514
- - `keyHint(keybinding, description)` - Formats a configured keybinding id such as `"app.tools.expand"` or `"tui.select.confirm"`; use it when the binding is required by the surrounding UI
2515
- - `keyHintIfBound(keybinding, description)` - Formats the hint only when the action has an effective key list; use it for optional affordances and conditionally compose parentheses or separators
2516
- - `keyText(keybinding)` - Returns the raw configured key text for a keybinding id
2517
- - `rawKeyHint(key, description)` - Format a raw key string
2518
-
2519
- Use namespaced keybinding ids:
2520
- - Coding-agent ids use the `app.*` namespace, for example `app.tools.expand`, `app.editor.external`, `app.session.rename`
2521
- - Shared TUI ids use the `tui.*` namespace, for example `tui.select.confirm`, `tui.select.cancel`, `tui.input.tab`
2522
-
2523
- For the exhaustive list of keybinding ids and defaults, see [Keybindings](/keybindings). `keybindings.json` uses those same namespaced ids.
2524
-
2525
- Custom editors and `ctx.ui.custom()` components receive `keybindings: KeybindingsManager` as an injected argument. They should use that injected manager directly instead of calling `getKeybindings()` or `setKeybindings()`.
647
+ Moved to [Writing extensions](/extensions/authoring#keybinding-hints).
2526
648
 
2527
649
  #### Best Practices
2528
650
 
2529
- - Use `Text` with padding `(0, 0)`. The default Box handles padding.
2530
- - Use `\n` for multi-line content.
2531
- - Handle `isPartial` for streaming progress.
2532
- - Support `expanded` for detail on demand.
2533
- - Keep default view compact.
2534
- - Read `context.args` in `renderResult` instead of copying args into `context.state`.
2535
- - Use `context.state` only for data that must be shared across call and result slots.
2536
- - Reuse `context.lastComponent` when the same component instance can be updated in place.
2537
- - Use `renderShell: "self"` only when the default boxed shell gets in the way. In self-shell mode the tool is responsible for its own framing, padding, and background.
651
+ Moved to [Writing extensions](/extensions/authoring#best-practices).
2538
652
 
2539
653
  #### Fallback
2540
654
 
2541
- If a slot renderer is not defined or throws:
2542
- - `renderCall`: Shows the tool name
2543
- - `renderResult`: Shows raw text from `content`
655
+ Moved to [Writing extensions](/extensions/authoring#fallback).
2544
656
 
2545
657
  ## Custom UI
2546
658
 
2547
- Extensions can interact with users via `ctx.ui` methods and customize how messages/tools render.
2548
-
2549
- **For custom components, see [TUI components](/tui)** which has copy-paste patterns for:
2550
- - Selection dialogs (SelectList)
2551
- - Async operations with cancel (BorderedLoader)
2552
- - Settings toggles (SettingsList)
2553
- - Status indicators (setStatus)
2554
- - Working message, visibility, and indicator from accepted prompt startup through active turns (`setWorkingMessage`, `setWorkingVisible`, `setWorkingIndicator`)
2555
- - Widgets above/below editor (setWidget)
2556
- - Autocomplete providers layered on top of built-in slash/path completion (addAutocompleteProvider)
2557
- - Custom footers (setFooter)
659
+ Moved to [Extension UI](/extensions/ui#custom-ui).
2558
660
 
2559
661
  ### Dialogs
2560
662
 
2561
- ```typescript
2562
- // Select from options
2563
- const choice = await ctx.ui.select("Pick one:", ["A", "B", "C"]);
2564
-
2565
- // Confirm dialog
2566
- const ok = await ctx.ui.confirm("Delete?", "This cannot be undone");
2567
-
2568
- // Text input
2569
- const name = await ctx.ui.input("Name:", "placeholder");
2570
-
2571
- // Multi-line editor
2572
- const text = await ctx.ui.editor("Edit:", "prefilled text");
2573
-
2574
- // Notification (non-blocking)
2575
- ctx.ui.notify("Done!", "info"); // "info" | "warning" | "error"
2576
- ```
2577
-
2578
- Notifications emitted while extensions load or startup is in progress always appear below the startup `RESOURCES` disclosure line, never above it.
663
+ Moved to [Extension UI](/extensions/ui#dialogs).
2579
664
 
2580
665
  #### Timed Dialogs with Countdown
2581
666
 
2582
- Dialogs support a `timeout` option that auto-dismisses with a live countdown display:
2583
-
2584
- ```typescript
2585
- // Dialog shows "Title (5s)" → "Title (4s)" → ... → auto-dismisses at 0
2586
- const confirmed = await ctx.ui.confirm(
2587
- "Timed Confirmation",
2588
- "This dialog will auto-cancel in 5 seconds. Confirm?",
2589
- { timeout: 5000 }
2590
- );
2591
-
2592
- if (confirmed) {
2593
- // User confirmed
2594
- } else {
2595
- // User cancelled or timed out
2596
- }
2597
- ```
2598
-
2599
- **Return values on timeout:**
2600
- - `select()` returns `undefined`
2601
- - `confirm()` returns `false`
2602
- - `input()` returns `undefined`
667
+ Moved to [Extension UI](/extensions/ui#timed-dialogs-with-countdown).
2603
668
 
2604
669
  #### Manual Dismissal with AbortSignal
2605
670
 
2606
- For more control (e.g., to distinguish timeout from user cancel), use `AbortSignal`:
2607
-
2608
- ```typescript
2609
- const controller = new AbortController();
2610
- const timeoutId = setTimeout(() => controller.abort(), 5000);
2611
-
2612
- const confirmed = await ctx.ui.confirm(
2613
- "Timed Confirmation",
2614
- "This dialog will auto-cancel in 5 seconds. Confirm?",
2615
- { signal: controller.signal }
2616
- );
2617
-
2618
- clearTimeout(timeoutId);
2619
-
2620
- if (confirmed) {
2621
- // User confirmed
2622
- } else if (controller.signal.aborted) {
2623
- // Dialog timed out
2624
- } else {
2625
- // User cancelled (pressed Escape or selected "No")
2626
- }
2627
- ```
2628
-
2629
- See [examples/extensions/timed-confirm.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/timed-confirm.ts) for complete examples.
671
+ Moved to [Extension UI](/extensions/ui#manual-dismissal-with-abortsignal).
2630
672
 
2631
673
  ### Widgets, Status, and Footer
2632
674
 
2633
- ```typescript
2634
- // Status in footer (persistent until cleared)
2635
- ctx.ui.setStatus("my-ext", "Processing...");
2636
- ctx.ui.setStatus("my-ext", undefined); // Clear
2637
-
2638
- // Working loader customization (active from accepted prompt startup through the agent turn)
2639
- ctx.ui.setWorkingMessage("Thinking deeply...");
2640
- ctx.ui.setWorkingMessage(); // Restore default
2641
- ctx.ui.setWorkingVisible(false); // Hide the built-in working indicator entirely
2642
- ctx.ui.setWorkingVisible(true); // Show the built-in working indicator
2643
-
2644
- // Working indicator customization (same lifecycle; see TUI Pattern 4b)
2645
- ctx.ui.setWorkingIndicator({ frames: [ctx.ui.theme.fg("accent", "●")] }); // Static dot
2646
- ctx.ui.setWorkingIndicator({
2647
- frames: [
2648
- ctx.ui.theme.fg("dim", "·"),
2649
- ctx.ui.theme.fg("muted", "•"),
2650
- ctx.ui.theme.fg("accent", "●"),
2651
- ctx.ui.theme.fg("muted", "•"),
2652
- ],
2653
- intervalMs: 120,
2654
- });
2655
- ctx.ui.setWorkingIndicator({ frames: [] }); // Hide indicator
2656
- ctx.ui.setWorkingIndicator(); // Restore the default one-cell ∀ luminance ramp
2657
- // The working status uses a standalone row by default. A CustomEditor can opt
2658
- // into placing it in the top border with { embedWorkingStatus: true }.
2659
-
2660
- // Widget above editor (default)
2661
- ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"]);
2662
- // Widget below editor
2663
- ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"], { placement: "belowEditor" });
2664
- ctx.ui.setWidget("my-widget", (tui, theme) => new Text(theme.fg("accent", "Custom"), 0, 0));
2665
- ctx.ui.setWidget("my-widget", undefined); // Clear
2666
-
2667
- // Custom footer (replaces built-in footer entirely)
2668
- ctx.ui.setFooter((tui, theme) => ({
2669
- render(width) { return [theme.fg("dim", "Custom footer")]; },
2670
- invalidate() {},
2671
- }));
2672
- ctx.ui.setFooter(undefined); // Restore built-in footer
2673
-
2674
- // Terminal title
2675
- ctx.ui.setTitle("atomic - my-project");
2676
-
2677
- // Editor text
2678
- ctx.ui.setEditorText("Prefill text");
2679
- const current = ctx.ui.getEditorText();
2680
-
2681
- // Paste into editor (triggers paste handling, including collapse for large content)
2682
- ctx.ui.pasteToEditor("pasted content");
2683
-
2684
- // Stack custom autocomplete behavior on top of the built-in provider
2685
- ctx.ui.addAutocompleteProvider((current) => ({
2686
- async getSuggestions(lines, line, col, options) {
2687
- const beforeCursor = (lines[line] ?? "").slice(0, col);
2688
- const match = beforeCursor.match(/(?:^|[ \t])#([^\s#]*)$/);
2689
- if (!match) {
2690
- return current.getSuggestions(lines, line, col, options);
2691
- }
2692
-
2693
- return {
2694
- prefix: `#${match[1] ?? ""}`,
2695
- items: [{ value: "#2983", label: "#2983", description: "Extension API for autocomplete" }],
2696
- };
2697
- },
2698
- applyCompletion(lines, line, col, item, prefix) {
2699
- return current.applyCompletion(lines, line, col, item, prefix);
2700
- },
2701
- shouldTriggerFileCompletion(lines, line, col) {
2702
- return current.shouldTriggerFileCompletion?.(lines, line, col) ?? true;
2703
- },
2704
- }));
2705
-
2706
- // Tool output expansion
2707
- const wasExpanded = ctx.ui.getToolsExpanded();
2708
- ctx.ui.setToolsExpanded(true);
2709
- ctx.ui.setToolsExpanded(wasExpanded);
2710
-
2711
- // Custom editor (vim mode, emacs mode, etc.)
2712
- ctx.ui.setEditorComponent((tui, theme, keybindings) => new VimEditor(tui, theme, keybindings));
2713
- const currentEditor = ctx.ui.getEditorComponent();
2714
- ctx.ui.setEditorComponent((tui, theme, keybindings) =>
2715
- new WrappedEditor(tui, theme, keybindings, currentEditor?.(tui, theme, keybindings))
2716
- );
2717
- ctx.ui.setEditorComponent(undefined); // Restore default editor
2718
-
2719
- // Theme management (see themes.md for creating themes)
2720
- const themes = ctx.ui.getAllThemes(); // [{ name: "dark", path: "/..." | undefined }, ...]
2721
- const lightTheme = ctx.ui.getTheme("light"); // Load without switching
2722
- const result = ctx.ui.setTheme("light"); // Switch by name
2723
- if (!result.success) {
2724
- ctx.ui.notify(`Failed: ${result.error}`, "error");
2725
- }
2726
- ctx.ui.setTheme(lightTheme!); // Or switch by Theme object
2727
- ctx.ui.theme.fg("accent", "styled text"); // Access current theme
2728
- ```
2729
-
2730
- Calling `setToolsExpanded()` with the current value is a no-op.
2731
-
2732
- Atomic's default working indicator keeps the literal one-cell `∀` fixed while following the active theme's optional `workingIndicator` tone overrides through a dark → accent → bright/bold → accent → dark ramp every 88ms. Any omitted tones are derived from selected-surface, `accent`, and `text` roles. `NO_COLOR` keeps regular/bold activity without foreground-color escapes, and `ATOMIC_REDUCED_MOTION=1` uses a static regular accent `∀` without a timer. Custom working-indicator frames and intervals are rendered verbatim. If you want colors, add them to the frame strings yourself, for example with `ctx.ui.theme.fg(...)`.
2733
-
2734
- These APIs customize presentation only; they do not start work or emit an extension stream event before prompt startup. See [Working Indicator Customization](/tui#pattern-4b-working-indicator-customization) for accepted-prompt, pre-stream, and agent-turn handoff timing.
675
+ Moved to [Extension UI](/extensions/ui#widgets-status-and-footer).
2735
676
 
2736
677
  ### Autocomplete Providers
2737
678
 
2738
- Use `ctx.ui.addAutocompleteProvider()` to stack custom autocomplete logic on top of the built-in slash-command and path provider.
2739
-
2740
- Typical pattern:
2741
-
2742
- - inspect the text before the cursor
2743
- - return your own suggestions when your extension-specific syntax matches
2744
- - otherwise delegate to `current.getSuggestions(...)`
2745
- - delegate `applyCompletion(...)` unless you need custom insertion behavior
2746
-
2747
- ```typescript
2748
- pi.on("session_start", (_event, ctx) => {
2749
- ctx.ui.addAutocompleteProvider((current) => ({
2750
- async getSuggestions(lines, cursorLine, cursorCol, options) {
2751
- const line = lines[cursorLine] ?? "";
2752
- const beforeCursor = line.slice(0, cursorCol);
2753
- const match = beforeCursor.match(/(?:^|[ \t])#([^\s#]*)$/);
2754
- if (!match) {
2755
- return current.getSuggestions(lines, cursorLine, cursorCol, options);
2756
- }
2757
-
2758
- return {
2759
- prefix: `#${match[1] ?? ""}`,
2760
- items: [
2761
- { value: "#2983", label: "#2983", description: "Extension API for registering custom @ autocomplete providers" },
2762
- { value: "#2753", label: "#2753", description: "Reload stale resource settings" },
2763
- ],
2764
- };
2765
- },
2766
-
2767
- applyCompletion(lines, cursorLine, cursorCol, item, prefix) {
2768
- return current.applyCompletion(lines, cursorLine, cursorCol, item, prefix);
2769
- },
2770
-
2771
- shouldTriggerFileCompletion(lines, cursorLine, cursorCol) {
2772
- return current.shouldTriggerFileCompletion?.(lines, cursorLine, cursorCol) ?? true;
2773
- },
2774
- }));
2775
- });
2776
- ```
2777
-
2778
- See [github-issue-autocomplete.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/github-issue-autocomplete.ts) for a complete example that preloads the latest open GitHub issues with `gh issue list` and filters them locally for fast `#...` completion. It requires GitHub CLI (`gh`) and a GitHub repository checkout.
679
+ Moved to [Extension UI](/extensions/ui#autocomplete-providers).
2779
680
 
2780
681
  ### Custom Components
2781
682
 
2782
- For complex UI, use `ctx.ui.custom()`. This temporarily replaces the editor with your component until `done()` is called:
2783
-
2784
- ```typescript
2785
- import { Text, type Component } from "@earendil-works/pi-tui";
2786
-
2787
- class ConfirmPrompt implements Component {
2788
- render(width: number): string[] {
2789
- return new Text("Enter Confirm · Escape Cancel", 1, 1).render(width);
2790
- }
2791
-
2792
- invalidate(): void {}
2793
-
2794
- handleInput(data: string): boolean {
2795
- if (data === "\r") {
2796
- this.done(true);
2797
- return true;
2798
- }
2799
- if (data === "\x1b") {
2800
- this.done(false);
2801
- return true;
2802
- }
2803
- return false;
2804
- }
2805
-
2806
- constructor(private readonly done: (value: boolean) => void) {}
2807
- }
2808
-
2809
- const result = await ctx.ui.custom<boolean>((_tui, _theme, _keybindings, done) => {
2810
- return new ConfirmPrompt(done);
2811
- });
2812
-
2813
- if (result) {
2814
- // User pressed Enter
2815
- }
2816
- ```
2817
-
2818
- The callback receives:
2819
- - `tui` - TUI instance (for screen dimensions, focus management)
2820
- - `theme` - Current theme for styling
2821
- - `keybindings` - App keybinding manager (for checking shortcuts)
2822
- - `done(value)` - Call to close component and return value
2823
-
2824
- Pass `{ signal }` to dismiss the custom UI if an operation is aborted; the returned promise rejects with the signal reason.
2825
- Custom component `handleInput` methods must return `true` when they consume an input and `false` (or `undefined`) when they do not. In fullscreen mode, an unhandled viewport key continues to the transcript; remote components also fall through on a failed or timed-out reply.
2826
-
2827
- Custom component `handleInput` methods must return `true` when they consume an input and `false` or `undefined` when they do not. In fullscreen mode, an unhandled viewport key continues to the transcript; remote components also fall through on a failed or timed-out reply. Return `true` for a handled key so it is not applied twice.
2828
-
2829
- A handler that returns a promise is judged when it settles: only a resolved `true` consumes the key, while `false`, `undefined`, and a rejection fall through to the viewport. A component with no `handleInput` declines everything, so viewport keys still scroll the transcript behind it.
2830
-
2831
- Pass `{ handlesCtrlC: true }` when the component binds Ctrl+C itself (cancel, skip, close). In isolated interactive sessions the host otherwise closes a component that owns input on the first Ctrl+C, so that a component which never resolves cannot trap the keyboard. See [Interactive callback isolation](#interactive-callback-isolation).
2832
-
2833
- See [TUI components](/tui) for the full component API.
683
+ Moved to [Extension UI](/extensions/ui#custom-components).
2834
684
 
2835
685
  #### Overlay Mode (Experimental)
2836
686
 
2837
- Pass `{ overlay: true }` to render the component as a floating modal on top of existing content, without clearing the screen:
2838
-
2839
- ```typescript
2840
- const result = await ctx.ui.custom<string | null>(
2841
- (tui, theme, keybindings, done) => new MyOverlayComponent({ onClose: done }),
2842
- { overlay: true }
2843
- );
2844
- ```
2845
-
2846
- For advanced positioning (anchors, margins, percentages, responsive visibility), pass `overlayOptions`. Use `onHandle` to control visibility programmatically:
2847
-
2848
- ```typescript
2849
- const result = await ctx.ui.custom<string | null>(
2850
- (tui, theme, keybindings, done) => new MyOverlayComponent({ onClose: done }),
2851
- {
2852
- overlay: true,
2853
- overlayOptions: { anchor: "top-right", width: "50%", margin: 2 },
2854
- onHandle: (handle) => { /* handle.setHidden(true/false) */ }
2855
- }
2856
- );
2857
- ```
2858
-
2859
- See [TUI components](/tui) for the full `OverlayOptions` API and [overlay-qa-tests.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/extensions/overlay-qa-tests.ts) for examples.
2860
-
2861
- Pass `{ reserveTranscriptRows: true }` for a blocking bottom-anchored dialog. A reserving overlay must set `overlayOptions.anchor` to `bottom-left`, `bottom-center`, or `bottom-right`; `row` and a nonzero `offsetY` are rejected because they invalidate the transcript-intersection model. Horizontal placement options remain supported. An overlay is composited over the transcript rather than measured into the layout, so without this option a tall dialog can cover the whole screen and the transcript rows it covers can never be scrolled above it. With it, the host bounds the overlay so at least six transcript rows stay visible. Top and bottom margins limit the wrapper before pi-tui composition, preventing a second fixed-head crop. Numeric and percentage `maxHeight` values are also resolved before active-row windowing and removed from the options passed to pi-tui. The host computes each visible bottom overlay's real intersection with the transcript and reserves the connected covered suffix once, so scrolling to the end keeps the newest output readable. A measured height change on mount or resize requests one automatic settling repaint. Margins, overlapping overlays, resize, and temporary visibility changes are reflected each frame. A temporarily hidden overlay — through `OverlayHandle.setHidden(true)` or a false `OverlayOptions.visible` result — contributes no intersection until it becomes visible again. Permanent handle removal, closure, and raw host removal release that exact overlay's registration; the shared reserve remains until its final overlay leaves. Leave the option unset for an overlay that is meant to take the screen, such as a full-screen graph. The built-in `ask_user_question` dialog sets it.
2862
-
2863
- ```typescript
2864
- const result = await ctx.ui.custom<string | null>(
2865
- (tui, theme, keybindings, done) => new MyDialog({ onClose: done }),
2866
- {
2867
- overlay: true,
2868
- reserveTranscriptRows: true,
2869
- overlayOptions: { anchor: "bottom-center", width: "100%" },
2870
- }
2871
- );
2872
- ```
2873
-
2874
- A component mounted with `reserveTranscriptRows` always releases configured fullscreen transcript actions and vertical wheel input to the host viewport, including while a nested input has focus. The component keeps all other keyboard and mouse input, including text editing, arrows, confirmation, cancellation, and clicks. This rule applies only to reserving overlays; other focused overlays still receive page and wheel input first and can keep it by returning `true`.
2875
-
2876
- Bounding a tall dialog means dropping rows, and the host would otherwise have to guess which. Embed `OVERLAY_ACTIVE_ROW_MARKER` in the line your component most needs kept — the selected row of a list — and the host places what it keeps around that row instead of taking a fixed head, even when the effective `maxHeight` is only one row. The mark is a zero-width APC sequence that `visibleWidth` measures as zero, terminated with ST as ECMA-48 requires. The renderer strips it centrally, in the last transform over the composited screen before it is written out, so it never reaches the terminal — from a reserving overlay, an ordinary overlay, an inline mount, a widget, or a workflow stage chat alike. Embed it once per frame; the host uses the first line that carries it. Put it anywhere on that line: a mark buried mid-line is removed just as a trailing one is. The `ask_user_question` dialog marks every active selectable row, including single- and multi-select options, Next, Submit, Cancel, and inline sentinel rows. Focused pi-tui inputs also anchor the bound through their cursor marker, so arrow keys and text input stay visible on a 16-row terminal.
2877
-
2878
- ```typescript
2879
- import { OVERLAY_ACTIVE_ROW_MARKER } from "@bastani/atomic";
2880
-
2881
- render(width: number): string[] {
2882
- return this.items.map((item, index) =>
2883
- index === this.selected ? `${this.row(item, width)}${OVERLAY_ACTIVE_ROW_MARKER}` : this.row(item, width),
2884
- );
2885
- }
2886
- ```
687
+ Moved to [Extension UI](/extensions/ui#overlay-mode-experimental).
2887
688
 
2888
689
  ### Custom Editor
2889
690
 
2890
- Replace the main input editor with a custom implementation (vim mode, emacs mode, etc.):
2891
-
2892
- ```typescript
2893
- import { CustomEditor, type ExtensionAPI } from "@bastani/atomic";
2894
- import { matchesKey } from "@earendil-works/pi-tui";
2895
-
2896
- class VimEditor extends CustomEditor {
2897
- private mode: "normal" | "insert" = "insert";
2898
-
2899
- handleInput(data: string): boolean {
2900
- if (matchesKey(data, "escape") && this.mode === "insert") {
2901
- this.mode = "normal";
2902
- return true;
2903
- }
2904
- if (this.mode === "normal" && data === "i") {
2905
- this.mode = "insert";
2906
- return true;
2907
- }
2908
- return super.handleInput(data); // App keybindings + text editing
2909
- }
2910
- }
2911
-
2912
- export default function (pi: ExtensionAPI) {
2913
- pi.on("session_start", (_event, ctx) => {
2914
- ctx.ui.setEditorComponent((tui, theme, keybindings) =>
2915
- new VimEditor(tui, theme, keybindings)
2916
- );
2917
- });
2918
- }
2919
- ```
2920
-
2921
- **Key points:**
2922
- - Extend `CustomEditor` (not base `Editor`) to get app keybindings (escape to abort, ctrl+d, model switching)
2923
- - Call `super.handleInput(data)` for keys you don't handle
2924
- - Editors keep the standalone working row by default. Pass `{ embedWorkingStatus: true }` as the fourth `CustomEditor` constructor argument to opt into the editor-border spinner.
2925
- - Factory receives `tui`, `theme`, and `keybindings` from the app
2926
- - Use `ctx.ui.getEditorComponent()` before `setEditorComponent()` to wrap the previously configured custom editor
2927
- - Pass `undefined` to restore default: `ctx.ui.setEditorComponent(undefined)`
2928
- - When a custom editor installed through `ctx.ui.setEditorComponent()` exposes `setAutocompleteMaxVisible()`, Atomic initializes it from the active `autocompleteMaxVisible` setting.
2929
-
2930
- To compose with another extension that already replaced the editor, capture the previous factory before setting yours:
2931
-
2932
- ```typescript
2933
- const previous = ctx.ui.getEditorComponent();
2934
- ctx.ui.setEditorComponent((tui, theme, keybindings) =>
2935
- new MyEditor(tui, theme, keybindings, { base: previous?.(tui, theme, keybindings) })
2936
- );
2937
- ```
2938
-
2939
- See [TUI components](/tui) Pattern 7 for a complete example with mode indicator.
691
+ Moved to [Extension UI](/extensions/ui#custom-editor).
2940
692
 
2941
693
  ### Message Rendering
2942
694
 
2943
- Register a custom renderer for messages with your `customType`:
2944
-
2945
- ```typescript
2946
- import { Text } from "@earendil-works/pi-tui";
2947
-
2948
- pi.registerMessageRenderer("my-extension", (message, options, theme) => {
2949
- const { expanded, outputPad } = options;
2950
- let text = theme.fg("accent", `[${message.customType}] `);
2951
- text += message.content;
2952
-
2953
- if (expanded && message.details) {
2954
- text += "\n" + theme.fg("dim", JSON.stringify(message.details, null, 2));
2955
- }
2956
-
2957
- return new Text(text, outputPad, 0);
2958
- });
2959
- ```
2960
-
2961
- Messages are sent via `pi.sendMessage()`:
2962
-
2963
- ```typescript
2964
- pi.sendMessage({
2965
- customType: "my-extension", // Matches registerMessageRenderer
2966
- content: "Status update",
2967
- display: true, // Show in TUI
2968
- details: { ... }, // Available in renderer
2969
- });
2970
- ```
695
+ Moved to [Extension UI](/extensions/ui#message-rendering).
2971
696
 
2972
697
  ### Theme Colors
2973
698
 
2974
- All render functions receive a `theme` object. See [Themes](/themes) for creating custom themes and the full color palette.
2975
-
2976
- ```typescript
2977
- // Foreground colors
2978
- theme.fg("toolTitle", text) // Tool names
2979
- theme.fg("accent", text) // Highlights
2980
- theme.fg("success", text) // Success (green)
2981
- theme.fg("error", text) // Errors (red)
2982
- theme.fg("warning", text) // Warnings (yellow)
2983
- theme.fg("muted", text) // Secondary text
2984
- theme.fg("dim", text) // Tertiary text
2985
-
2986
- // Text styles
2987
- theme.bold(text)
2988
- theme.italic(text)
2989
- theme.strikethrough(text)
2990
- ```
2991
-
2992
- For syntax highlighting in custom tool renderers:
2993
-
2994
- ```typescript
2995
- import { highlightCode, getLanguageFromPath } from "@bastani/atomic";
2996
-
2997
- // Highlight code with explicit language
2998
- const highlighted = highlightCode("const x = 1;", "typescript", theme);
2999
-
3000
- // Auto-detect language from file path
3001
- const lang = getLanguageFromPath("/path/to/file.rs"); // "rust"
3002
- const highlighted = highlightCode(code, lang, theme);
3003
- ```
699
+ Moved to [Extension UI](/extensions/ui#theme-colors).
3004
700
 
3005
701
  ## Error Handling
3006
702
 
3007
- - Extension errors are logged, agent continues
3008
- - `tool_call` errors block the tool (fail-safe)
3009
- - Tool `execute` errors must be signaled by throwing; the thrown error is caught, reported to the LLM with `isError: true`, and execution continues
703
+ Moved to [Extension API reference](/extensions/api-reference#error-handling).
3010
704
 
3011
705
  ## Mode Behavior
3012
706
 
@@ -3021,84 +715,8 @@ In non-interactive modes, check `ctx.hasUI` before using UI methods.
3021
715
 
3022
716
  ## Examples Reference
3023
717
 
3024
- All examples in [examples/extensions/](https://github.com/bastani-inc/atomic/tree/main/packages/coding-agent/examples/extensions).
3025
-
3026
- | Example | Description | Key APIs |
3027
- |---------|-------------|----------|
3028
- | **Tools** |||
3029
- | `hello.ts` | Minimal tool registration | `registerTool` |
3030
- | `question.ts` | Width-wrapped single-question custom UI with option descriptions and typed answers | `registerTool`, `ui.custom` |
3031
- | `questionnaire.ts` | Width-wrapped multi-step wizard with tab navigation and typed answers | `registerTool`, `ui.custom` |
3032
- | `todo.ts` | Stateful tool with persistence | `registerTool`, `appendEntry`, `renderResult`, session events |
3033
- | `dynamic-tools.ts` | Register tools after startup and during commands | `registerTool`, `session_start`, `registerCommand` |
3034
- | `structured-output.ts` | Opt-in schema-specific `structured_output` tool using the canonical factory | `createStructuredOutputTool`, `registerTool`, terminating tool results |
3035
- | `truncated-tool.ts` | Output truncation example | `registerTool`, `truncateHead` |
3036
- | `tool-override.ts` | Override built-in read tool | `registerTool` (same name as built-in) |
3037
- | **Commands** |||
3038
- | `pirate.ts` | Modify system prompt per-turn | `registerCommand`, `before_agent_start` |
3039
- | `summarize.ts` | Conversation summary command | `registerCommand`, `ui.custom` |
3040
- | `handoff.ts` | Cross-provider model handoff | `registerCommand`, `ui.editor`, `ui.custom` |
3041
- | `qna.ts` | Q&A with custom UI | `registerCommand`, `ui.custom`, `setEditorText` |
3042
- | `send-user-message.ts` | Inject user messages | `registerCommand`, `sendUserMessage` |
3043
- | `reload-runtime.ts` | Reload command and LLM tool handoff | `registerCommand`, `ctx.reload()`, `sendUserMessage` |
3044
- | `shutdown-command.ts` | Graceful shutdown command | `registerCommand`, `shutdown()` |
3045
- | **Events & Gates** |||
3046
- | `permission-gate.ts` | Block dangerous commands | `on("tool_call")`, `ui.confirm` |
3047
- | `protected-paths.ts` | Block writes to specific paths | `on("tool_call")` |
3048
- | `confirm-destructive.ts` | Confirm session changes | `on("session_before_switch")`, `on("session_before_fork")` |
3049
- | `dirty-repo-guard.ts` | Warn on dirty git repo | `on("session_before_*")`, `exec` |
3050
- | `input-transform.ts` | Transform user input | `on("input")` |
3051
- | `input-transform-streaming.ts` | Streaming-aware input transform | `on("input")`, `streamingBehavior` |
3052
- | `project-trust.ts` | Decide or defer project trust from a user/global or CLI extension | `on("project_trust")`, trust UI, required trust result |
3053
- | `model-status.ts` | React to model changes | `on("model_select")`, `setStatus` |
3054
- | `provider-payload.ts` | Inspect payloads and provider response headers | `on("before_provider_request")`, `on("after_provider_response")` |
3055
- | `system-prompt-header.ts` | Display system prompt info | `on("agent_start")`, `getSystemPrompt` |
3056
- | `claude-rules.ts` | Load rules from files | `on("session_start")`, `on("before_agent_start")` |
3057
- | `prompt-customizer.ts` | Add context-aware tool guidance using `systemPromptOptions` | `on("before_agent_start")`, `BuildSystemPromptOptions` |
3058
- | `file-trigger.ts` | File watcher triggers messages | `sendMessage` |
3059
- | **Compaction & Sessions** |||
3060
- | `custom-compaction.ts` | Offline compacted-text override | `on("session_before_compact")` |
3061
- | `trigger-compact.ts` | Trigger compaction manually | `compact()` |
3062
- | `git-checkpoint.ts` | Git stash on turns | `on("turn_start")`, `on("session_before_fork")`, `exec` |
3063
- | `auto-commit-on-exit.ts` | Commit on shutdown | `on("session_shutdown")`, `exec` |
3064
- | **UI Components** |||
3065
- | `status-line.ts` | Footer status indicator | `setStatus`, session events |
3066
- | `working-indicator.ts` | Customize the Working indicator used during prompt startup and active turns | `setWorkingIndicator`, `registerCommand` |
3067
- | `github-issue-autocomplete.ts` | Add `#1234` issue completions on top of built-in autocomplete by preloading recent open issues from `gh issue list` | `addAutocompleteProvider`, `on("session_start")`, `exec` |
3068
- | `custom-footer.ts` | Replace footer entirely | `registerCommand`, `setFooter` |
3069
- | `custom-header.ts` | Replace startup header | `on("session_start")`, `setHeader` |
3070
- | `modal-editor.ts` | Vim-style modal editor | `setEditorComponent`, `CustomEditor` |
3071
- | `rainbow-editor.ts` | Custom editor styling | `setEditorComponent` |
3072
- | `widget-placement.ts` | Widget above/below editor | `setWidget` |
3073
- | `overlay-test.ts` | Overlay components | `ui.custom` with overlay options |
3074
- | `overlay-qa-tests.ts` | Comprehensive overlay tests | `ui.custom`, all overlay options |
3075
- | `notify.ts` | Simple notifications | `ui.notify` |
3076
- | `timed-confirm.ts` | Dialogs with timeout | `ui.confirm` with timeout/signal |
3077
- | `mac-system-theme.ts` | Auto-switch theme | `setTheme`, `exec` |
3078
- | **Complex Extensions** |||
3079
- | `plan-mode/` | Full plan mode implementation | All event types, `registerCommand`, `registerShortcut`, `registerFlag`, `setStatus`, `setWidget`, `sendMessage`, `setActiveTools` |
3080
- | `preset.ts` | Saveable presets (model, tools, thinking) | `registerCommand`, `registerShortcut`, `registerFlag`, `setModel`, `setActiveTools`, `setThinkingLevel`, `appendEntry` |
3081
- | `tools.ts` | Toggle tools on/off UI | `registerCommand`, `setActiveTools`, `SettingsList`, session events |
3082
- | **Remote & Sandbox** |||
3083
- | `ssh.ts` | SSH remote execution | `registerFlag`, `on("user_bash")`, `on("before_agent_start")`, tool operations |
3084
- | `interactive-shell.ts` | Persistent shell session | `on("user_bash")` |
3085
- | `sandbox/` | Sandboxed tool execution | Tool operations |
3086
- | `gondolin/` | Route built-in tools and `!` commands into a Gondolin micro-VM | Tool operations, built-in tool overrides, `on("user_bash")` |
3087
- | `subagent/` | Spawn sub-agents | `registerTool`, `exec` |
3088
- | **Games** |||
3089
- | `snake.ts` | Snake game | `registerCommand`, `ui.custom`, keyboard handling |
3090
- | `space-invaders.ts` | Space Invaders game | `registerCommand`, `ui.custom` |
3091
- | `doom-overlay/` | Doom in overlay | `ui.custom` with overlay |
3092
- | **Providers** |||
3093
- | `custom-provider-anthropic/` | Custom Anthropic proxy | `registerProvider` |
3094
- | `custom-provider-gitlab-duo/` | GitLab Duo integration | `registerProvider` with OAuth |
3095
- | **Messages & Communication** |||
3096
- | `message-renderer.ts` | Custom message rendering | `registerMessageRenderer`, `sendMessage` |
3097
- | `event-bus.ts` | Inter-extension events | `pi.events` |
3098
- | **Session Metadata** |||
3099
- | `session-name.ts` | Name sessions for selector | `setSessionName`, `getSessionName` |
3100
- | `bookmark.ts` | Bookmark entries for /tree | `setLabel` |
3101
- | **Misc** |||
3102
- | `inline-bash.ts` | Inline bash in tool calls | `on("tool_call")` |
3103
- | `bash-spawn-hook.ts` | Adjust bash command, cwd, and env before execution | `createBashTool`, `spawnHook` |
3104
- | `with-deps/` | Extension with npm dependencies | Package structure with `package.json` |
718
+ Moved to [Extension examples](/extensions/examples#examples-reference).
719
+
720
+ ## Workflow activity and lifecycle hooks
721
+
722
+ Moved to [Extension events](/extensions/events#workflow-activity-and-lifecycle-hooks).