@bastani/atomic 0.8.27 → 0.8.28-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (397) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +120 -118
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/package.json +2 -2
  5. package/dist/builtin/subagents/package.json +1 -1
  6. package/dist/builtin/web-access/package.json +1 -1
  7. package/dist/builtin/workflows/CHANGELOG.md +22 -0
  8. package/dist/builtin/workflows/README.md +11 -9
  9. package/dist/builtin/workflows/builtin/open-claude-design.ts +150 -13
  10. package/dist/builtin/workflows/package.json +1 -1
  11. package/dist/builtin/workflows/src/authoring.d.ts +5 -2
  12. package/dist/builtin/workflows/src/extension/background-ui-adapter.ts +3 -1
  13. package/dist/builtin/workflows/src/extension/hil-answer-notifications.ts +17 -25
  14. package/dist/builtin/workflows/src/extension/index.ts +133 -18
  15. package/dist/builtin/workflows/src/extension/render-result.ts +22 -2
  16. package/dist/builtin/workflows/src/extension/workflow-schema.ts +3 -3
  17. package/dist/builtin/workflows/src/runs/foreground/executor.ts +210 -16
  18. package/dist/builtin/workflows/src/sdk-surface.ts +1 -1
  19. package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +42 -5
  20. package/dist/builtin/workflows/src/shared/store-types.ts +8 -2
  21. package/dist/builtin/workflows/src/shared/store.ts +51 -0
  22. package/dist/builtin/workflows/src/shared/types.ts +14 -4
  23. package/dist/builtin/workflows/src/tui/chat-surface.ts +32 -33
  24. package/dist/builtin/workflows/src/tui/graph-view.ts +4 -1
  25. package/dist/builtin/workflows/src/tui/prompt-card.ts +6 -0
  26. package/dist/builtin/workflows/src/tui/run-detail.ts +11 -4
  27. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +11 -1
  28. package/dist/builtin/workflows/src/tui/status-list.ts +32 -2
  29. package/dist/cli/args.d.ts +4 -0
  30. package/dist/cli/args.d.ts.map +1 -1
  31. package/dist/cli/args.js +35 -0
  32. package/dist/cli/args.js.map +1 -1
  33. package/dist/cli/project-trust.d.ts +10 -0
  34. package/dist/cli/project-trust.d.ts.map +1 -0
  35. package/dist/cli/project-trust.js +36 -0
  36. package/dist/cli/project-trust.js.map +1 -0
  37. package/dist/cli/startup-ui.d.ts +7 -0
  38. package/dist/cli/startup-ui.d.ts.map +1 -0
  39. package/dist/cli/startup-ui.js +57 -0
  40. package/dist/cli/startup-ui.js.map +1 -0
  41. package/dist/config.d.ts.map +1 -1
  42. package/dist/config.js +24 -3
  43. package/dist/config.js.map +1 -1
  44. package/dist/core/agent-session-runtime.d.ts +3 -1
  45. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  46. package/dist/core/agent-session-runtime.js +1 -0
  47. package/dist/core/agent-session-runtime.js.map +1 -1
  48. package/dist/core/agent-session-services.d.ts +2 -1
  49. package/dist/core/agent-session-services.d.ts.map +1 -1
  50. package/dist/core/agent-session-services.js +2 -2
  51. package/dist/core/agent-session-services.js.map +1 -1
  52. package/dist/core/agent-session.d.ts +9 -5
  53. package/dist/core/agent-session.d.ts.map +1 -1
  54. package/dist/core/agent-session.js +205 -51
  55. package/dist/core/agent-session.js.map +1 -1
  56. package/dist/core/auth-guidance.d.ts +10 -1
  57. package/dist/core/auth-guidance.d.ts.map +1 -1
  58. package/dist/core/auth-guidance.js +26 -1
  59. package/dist/core/auth-guidance.js.map +1 -1
  60. package/dist/core/auth-storage.d.ts.map +1 -1
  61. package/dist/core/auth-storage.js +4 -3
  62. package/dist/core/auth-storage.js.map +1 -1
  63. package/dist/core/compaction/branch-summarization.d.ts +5 -3
  64. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  65. package/dist/core/compaction/branch-summarization.js +16 -10
  66. package/dist/core/compaction/branch-summarization.js.map +1 -1
  67. package/dist/core/compaction/compaction.d.ts +4 -84
  68. package/dist/core/compaction/compaction.d.ts.map +1 -1
  69. package/dist/core/compaction/compaction.js +20 -502
  70. package/dist/core/compaction/compaction.js.map +1 -1
  71. package/dist/core/compaction/context-compaction.d.ts.map +1 -1
  72. package/dist/core/compaction/context-compaction.js +39 -82
  73. package/dist/core/compaction/context-compaction.js.map +1 -1
  74. package/dist/core/compaction/index.d.ts +1 -1
  75. package/dist/core/compaction/index.d.ts.map +1 -1
  76. package/dist/core/compaction/index.js +1 -1
  77. package/dist/core/compaction/index.js.map +1 -1
  78. package/dist/core/compaction/utils.d.ts +1 -1
  79. package/dist/core/compaction/utils.d.ts.map +1 -1
  80. package/dist/core/compaction/utils.js +1 -1
  81. package/dist/core/compaction/utils.js.map +1 -1
  82. package/dist/core/experimental.d.ts +2 -0
  83. package/dist/core/experimental.d.ts.map +1 -0
  84. package/dist/core/experimental.js +5 -0
  85. package/dist/core/experimental.js.map +1 -0
  86. package/dist/core/export-html/template.js +19 -6
  87. package/dist/core/extensions/index.d.ts +1 -1
  88. package/dist/core/extensions/index.d.ts.map +1 -1
  89. package/dist/core/extensions/index.js.map +1 -1
  90. package/dist/core/extensions/loader.d.ts +1 -1
  91. package/dist/core/extensions/loader.d.ts.map +1 -1
  92. package/dist/core/extensions/loader.js +6 -4
  93. package/dist/core/extensions/loader.js.map +1 -1
  94. package/dist/core/extensions/runner.d.ts +11 -4
  95. package/dist/core/extensions/runner.d.ts.map +1 -1
  96. package/dist/core/extensions/runner.js +53 -3
  97. package/dist/core/extensions/runner.js.map +1 -1
  98. package/dist/core/extensions/types.d.ts +44 -12
  99. package/dist/core/extensions/types.d.ts.map +1 -1
  100. package/dist/core/extensions/types.js.map +1 -1
  101. package/dist/core/footer-data-provider.d.ts +2 -0
  102. package/dist/core/footer-data-provider.d.ts.map +1 -1
  103. package/dist/core/footer-data-provider.js +27 -1
  104. package/dist/core/footer-data-provider.js.map +1 -1
  105. package/dist/core/index.d.ts +2 -1
  106. package/dist/core/index.d.ts.map +1 -1
  107. package/dist/core/index.js +1 -0
  108. package/dist/core/index.js.map +1 -1
  109. package/dist/core/messages.d.ts +1 -11
  110. package/dist/core/messages.d.ts.map +1 -1
  111. package/dist/core/messages.js +10 -25
  112. package/dist/core/messages.js.map +1 -1
  113. package/dist/core/model-registry.d.ts.map +1 -1
  114. package/dist/core/model-registry.js +64 -7
  115. package/dist/core/model-registry.js.map +1 -1
  116. package/dist/core/model-resolver.d.ts.map +1 -1
  117. package/dist/core/model-resolver.js +1 -0
  118. package/dist/core/model-resolver.js.map +1 -1
  119. package/dist/core/output-guard.d.ts +1 -0
  120. package/dist/core/output-guard.d.ts.map +1 -1
  121. package/dist/core/output-guard.js +52 -22
  122. package/dist/core/output-guard.js.map +1 -1
  123. package/dist/core/package-manager.d.ts +1 -0
  124. package/dist/core/package-manager.d.ts.map +1 -1
  125. package/dist/core/package-manager.js +20 -8
  126. package/dist/core/package-manager.js.map +1 -1
  127. package/dist/core/project-trust.d.ts +15 -0
  128. package/dist/core/project-trust.d.ts.map +1 -0
  129. package/dist/core/project-trust.js +58 -0
  130. package/dist/core/project-trust.js.map +1 -0
  131. package/dist/core/prompt-templates.d.ts +5 -4
  132. package/dist/core/prompt-templates.d.ts.map +1 -1
  133. package/dist/core/prompt-templates.js +30 -29
  134. package/dist/core/prompt-templates.js.map +1 -1
  135. package/dist/core/provider-attribution.d.ts +4 -0
  136. package/dist/core/provider-attribution.d.ts.map +1 -0
  137. package/dist/core/provider-attribution.js +73 -0
  138. package/dist/core/provider-attribution.js.map +1 -0
  139. package/dist/core/provider-display-names.d.ts.map +1 -1
  140. package/dist/core/provider-display-names.js +3 -0
  141. package/dist/core/provider-display-names.js.map +1 -1
  142. package/dist/core/resolve-config-value.d.ts +9 -1
  143. package/dist/core/resolve-config-value.d.ts.map +1 -1
  144. package/dist/core/resolve-config-value.js +134 -11
  145. package/dist/core/resolve-config-value.js.map +1 -1
  146. package/dist/core/resource-loader.d.ts +12 -2
  147. package/dist/core/resource-loader.d.ts.map +1 -1
  148. package/dist/core/resource-loader.js +108 -18
  149. package/dist/core/resource-loader.js.map +1 -1
  150. package/dist/core/sdk.d.ts.map +1 -1
  151. package/dist/core/sdk.js +12 -42
  152. package/dist/core/sdk.js.map +1 -1
  153. package/dist/core/session-manager.d.ts +11 -15
  154. package/dist/core/session-manager.d.ts.map +1 -1
  155. package/dist/core/session-manager.js +111 -111
  156. package/dist/core/session-manager.js.map +1 -1
  157. package/dist/core/settings-manager.d.ts +15 -5
  158. package/dist/core/settings-manager.d.ts.map +1 -1
  159. package/dist/core/settings-manager.js +69 -14
  160. package/dist/core/settings-manager.js.map +1 -1
  161. package/dist/core/slash-commands.d.ts.map +1 -1
  162. package/dist/core/slash-commands.js +1 -0
  163. package/dist/core/slash-commands.js.map +1 -1
  164. package/dist/core/system-prompt.d.ts.map +1 -1
  165. package/dist/core/system-prompt.js +0 -3
  166. package/dist/core/system-prompt.js.map +1 -1
  167. package/dist/core/tools/bash.d.ts.map +1 -1
  168. package/dist/core/tools/bash.js +2 -1
  169. package/dist/core/tools/bash.js.map +1 -1
  170. package/dist/core/tools/edit.d.ts.map +1 -1
  171. package/dist/core/tools/edit.js +7 -10
  172. package/dist/core/tools/edit.js.map +1 -1
  173. package/dist/core/tools/find.d.ts.map +1 -1
  174. package/dist/core/tools/find.js +1 -1
  175. package/dist/core/tools/find.js.map +1 -1
  176. package/dist/core/tools/grep.d.ts.map +1 -1
  177. package/dist/core/tools/grep.js +1 -1
  178. package/dist/core/tools/grep.js.map +1 -1
  179. package/dist/core/tools/ls.d.ts.map +1 -1
  180. package/dist/core/tools/ls.js +1 -1
  181. package/dist/core/tools/ls.js.map +1 -1
  182. package/dist/core/tools/oversized-tool-result.d.ts +53 -0
  183. package/dist/core/tools/oversized-tool-result.d.ts.map +1 -0
  184. package/dist/core/tools/oversized-tool-result.js +206 -0
  185. package/dist/core/tools/oversized-tool-result.js.map +1 -0
  186. package/dist/core/tools/read.d.ts +12 -0
  187. package/dist/core/tools/read.d.ts.map +1 -1
  188. package/dist/core/tools/read.js +99 -34
  189. package/dist/core/tools/read.js.map +1 -1
  190. package/dist/core/tools/render-utils.d.ts +6 -0
  191. package/dist/core/tools/render-utils.d.ts.map +1 -1
  192. package/dist/core/tools/render-utils.js +17 -1
  193. package/dist/core/tools/render-utils.js.map +1 -1
  194. package/dist/core/tools/tool-definition-wrapper.d.ts +6 -0
  195. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  196. package/dist/core/tools/tool-definition-wrapper.js +2 -0
  197. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  198. package/dist/core/tools/tool-limits.d.ts +25 -0
  199. package/dist/core/tools/tool-limits.d.ts.map +1 -0
  200. package/dist/core/tools/tool-limits.js +25 -0
  201. package/dist/core/tools/tool-limits.js.map +1 -0
  202. package/dist/core/tools/write.d.ts.map +1 -1
  203. package/dist/core/tools/write.js +1 -1
  204. package/dist/core/tools/write.js.map +1 -1
  205. package/dist/core/trust-manager.d.ts +31 -0
  206. package/dist/core/trust-manager.d.ts.map +1 -0
  207. package/dist/core/trust-manager.js +196 -0
  208. package/dist/core/trust-manager.js.map +1 -0
  209. package/dist/index.d.ts +12 -7
  210. package/dist/index.d.ts.map +1 -1
  211. package/dist/index.js +8 -4
  212. package/dist/index.js.map +1 -1
  213. package/dist/main.d.ts.map +1 -1
  214. package/dist/main.js +142 -30
  215. package/dist/main.js.map +1 -1
  216. package/dist/migrations.d.ts +3 -1
  217. package/dist/migrations.d.ts.map +1 -1
  218. package/dist/migrations.js +325 -7
  219. package/dist/migrations.js.map +1 -1
  220. package/dist/modes/index.d.ts +1 -1
  221. package/dist/modes/index.d.ts.map +1 -1
  222. package/dist/modes/index.js.map +1 -1
  223. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  224. package/dist/modes/interactive/components/bash-execution.js +2 -2
  225. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  226. package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -5
  227. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  228. package/dist/modes/interactive/components/chat-message-renderer.js +5 -9
  229. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  230. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  231. package/dist/modes/interactive/components/chat-session-host.js +0 -3
  232. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  233. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  234. package/dist/modes/interactive/components/footer.js +6 -0
  235. package/dist/modes/interactive/components/footer.js.map +1 -1
  236. package/dist/modes/interactive/components/index.d.ts +1 -1
  237. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  238. package/dist/modes/interactive/components/index.js +1 -1
  239. package/dist/modes/interactive/components/index.js.map +1 -1
  240. package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
  241. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  242. package/dist/modes/interactive/components/login-dialog.js +9 -16
  243. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  244. package/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  245. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  246. package/dist/modes/interactive/components/settings-selector.js +20 -0
  247. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  248. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  249. package/dist/modes/interactive/components/tool-execution.js +22 -0
  250. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  251. package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
  252. package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
  253. package/dist/modes/interactive/components/trust-selector.js +85 -0
  254. package/dist/modes/interactive/components/trust-selector.js.map +1 -0
  255. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  256. package/dist/modes/interactive/components/user-message.js +1 -1
  257. package/dist/modes/interactive/components/user-message.js.map +1 -1
  258. package/dist/modes/interactive/interactive-mode.d.ts +9 -0
  259. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  260. package/dist/modes/interactive/interactive-mode.js +134 -36
  261. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  262. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  263. package/dist/modes/interactive/theme/theme.js +10 -0
  264. package/dist/modes/interactive/theme/theme.js.map +1 -1
  265. package/dist/modes/print-mode.d.ts.map +1 -1
  266. package/dist/modes/print-mode.js +1 -0
  267. package/dist/modes/print-mode.js.map +1 -1
  268. package/dist/modes/rpc/rpc-client.d.ts +4 -1
  269. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  270. package/dist/modes/rpc/rpc-client.js +52 -8
  271. package/dist/modes/rpc/rpc-client.js.map +1 -1
  272. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  273. package/dist/modes/rpc/rpc-mode.js +24 -5
  274. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  275. package/dist/modes/rpc/rpc-types.d.ts +1 -1
  276. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  277. package/dist/modes/rpc/rpc-types.js.map +1 -1
  278. package/dist/package-manager-cli.d.ts +6 -2
  279. package/dist/package-manager-cli.d.ts.map +1 -1
  280. package/dist/package-manager-cli.js +104 -10
  281. package/dist/package-manager-cli.js.map +1 -1
  282. package/dist/utils/changelog.d.ts +1 -0
  283. package/dist/utils/changelog.d.ts.map +1 -1
  284. package/dist/utils/changelog.js +72 -0
  285. package/dist/utils/changelog.js.map +1 -1
  286. package/dist/utils/deprecation.d.ts +4 -0
  287. package/dist/utils/deprecation.d.ts.map +1 -0
  288. package/dist/utils/deprecation.js +13 -0
  289. package/dist/utils/deprecation.js.map +1 -0
  290. package/dist/utils/git.d.ts.map +1 -1
  291. package/dist/utils/git.js +54 -22
  292. package/dist/utils/git.js.map +1 -1
  293. package/dist/utils/json.d.ts +3 -0
  294. package/dist/utils/json.d.ts.map +1 -0
  295. package/dist/utils/json.js +7 -0
  296. package/dist/utils/json.js.map +1 -0
  297. package/dist/utils/open-browser.d.ts +9 -0
  298. package/dist/utils/open-browser.d.ts.map +1 -0
  299. package/dist/utils/open-browser.js +22 -0
  300. package/dist/utils/open-browser.js.map +1 -0
  301. package/docs/compaction.md +210 -181
  302. package/docs/containerization.md +111 -0
  303. package/docs/custom-provider.md +9 -9
  304. package/docs/development.md +1 -1
  305. package/docs/docs.json +2 -0
  306. package/docs/extensions.md +71 -24
  307. package/docs/index.md +2 -0
  308. package/docs/json.md +3 -4
  309. package/docs/models.md +10 -10
  310. package/docs/packages.md +1 -1
  311. package/docs/prompt-templates.md +9 -2
  312. package/docs/providers.md +18 -5
  313. package/docs/quickstart.md +1 -0
  314. package/docs/rpc.md +3 -2
  315. package/docs/sdk.md +5 -0
  316. package/docs/security.md +56 -0
  317. package/docs/session-format.md +14 -23
  318. package/docs/sessions.md +11 -1
  319. package/docs/settings.md +23 -9
  320. package/docs/skills.md +1 -1
  321. package/docs/terminal-setup.md +44 -2
  322. package/docs/themes.md +1 -1
  323. package/docs/tmux.md +4 -2
  324. package/docs/tui.md +14 -5
  325. package/docs/usage.md +17 -3
  326. package/docs/workflows.md +11 -9
  327. package/examples/README.md +1 -1
  328. package/examples/extensions/README.md +9 -6
  329. package/examples/extensions/bash-spawn-hook.ts +1 -1
  330. package/examples/extensions/built-in-tool-renderer.ts +1 -1
  331. package/examples/extensions/claude-rules.ts +1 -1
  332. package/examples/extensions/commands.ts +1 -1
  333. package/examples/extensions/custom-compaction.ts +43 -106
  334. package/examples/extensions/custom-header.ts +1 -1
  335. package/examples/extensions/custom-provider-anthropic/index.ts +3 -3
  336. package/examples/extensions/custom-provider-anthropic/package-lock.json +4 -4
  337. package/examples/extensions/custom-provider-anthropic/package.json +6 -6
  338. package/examples/extensions/custom-provider-gitlab-duo/index.ts +55 -4
  339. package/examples/extensions/custom-provider-gitlab-duo/package.json +3 -3
  340. package/examples/extensions/doom-overlay/README.md +1 -1
  341. package/examples/extensions/doom-overlay/index.ts +2 -2
  342. package/examples/extensions/git-merge-and-resolve.ts +115 -0
  343. package/examples/extensions/gondolin/index.ts +523 -0
  344. package/examples/extensions/gondolin/package-lock.json +185 -0
  345. package/examples/extensions/gondolin/package.json +19 -0
  346. package/examples/extensions/handoff.ts +7 -45
  347. package/examples/extensions/hidden-thinking-label.ts +1 -1
  348. package/examples/extensions/inline-bash.ts +2 -2
  349. package/examples/extensions/input-transform-streaming.ts +39 -0
  350. package/examples/extensions/input-transform.ts +3 -3
  351. package/examples/extensions/interactive-shell.ts +2 -2
  352. package/examples/extensions/mac-system-theme.ts +2 -2
  353. package/examples/extensions/minimal-mode.ts +1 -1
  354. package/examples/extensions/modal-editor.ts +1 -1
  355. package/examples/extensions/model-status.ts +1 -1
  356. package/examples/extensions/overlay-qa-tests.ts +198 -179
  357. package/examples/extensions/overlay-test.ts +1 -1
  358. package/examples/extensions/pirate.ts +1 -1
  359. package/examples/extensions/preset.ts +14 -12
  360. package/examples/extensions/project-trust.ts +64 -0
  361. package/examples/extensions/prompt-customizer.ts +1 -1
  362. package/examples/extensions/qna.ts +1 -1
  363. package/examples/extensions/question.ts +1 -1
  364. package/examples/extensions/questionnaire.ts +1 -1
  365. package/examples/extensions/rainbow-editor.ts +1 -1
  366. package/examples/extensions/sandbox/index.ts +16 -14
  367. package/examples/extensions/sandbox/package-lock.json +90 -90
  368. package/examples/extensions/sandbox/package.json +17 -17
  369. package/examples/extensions/snake.ts +1 -1
  370. package/examples/extensions/space-invaders.ts +1 -1
  371. package/examples/extensions/ssh.ts +2 -2
  372. package/examples/extensions/subagent/README.md +13 -13
  373. package/examples/extensions/subagent/agents.ts +4 -2
  374. package/examples/extensions/subagent/index.ts +6 -6
  375. package/examples/extensions/summarize.ts +1 -1
  376. package/examples/extensions/tic-tac-toe.ts +1 -1
  377. package/examples/extensions/titlebar-spinner.ts +1 -1
  378. package/examples/extensions/todo.ts +1 -1
  379. package/examples/extensions/tool-override.ts +1 -1
  380. package/examples/extensions/tools.ts +6 -1
  381. package/examples/extensions/trigger-compact.ts +5 -4
  382. package/examples/extensions/with-deps/package-lock.json +4 -4
  383. package/examples/extensions/with-deps/package.json +7 -7
  384. package/examples/extensions/working-indicator.ts +4 -4
  385. package/examples/extensions/working-message-test.ts +1 -1
  386. package/examples/sdk/01-minimal.ts +1 -1
  387. package/examples/sdk/03-custom-prompt.ts +1 -1
  388. package/examples/sdk/04-skills.ts +1 -1
  389. package/examples/sdk/06-extensions.ts +2 -2
  390. package/examples/sdk/08-prompt-templates.ts +1 -1
  391. package/examples/sdk/09-api-keys-and-oauth.ts +2 -2
  392. package/examples/sdk/README.md +2 -2
  393. package/package.json +8 -8
  394. package/dist/modes/interactive/components/compaction-summary-message.d.ts +0 -16
  395. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +0 -1
  396. package/dist/modes/interactive/components/compaction-summary-message.js +0 -43
  397. package/dist/modes/interactive/components/compaction-summary-message.js.map +0 -1
@@ -20,9 +20,9 @@ import { stripFrontmatter } from "../utils/frontmatter.js";
20
20
  import { resolvePath } from "../utils/paths.js";
21
21
  import { sleep } from "../utils/sleep.js";
22
22
  import { ATOMIC_GUIDE_COMMAND_NAME, ATOMIC_GUIDE_HELP_CHOICES, atomicGuideModeForChoice, getAtomicGuideMessage, isAtomicGuideHelpChoice, normalizeAtomicGuideMode, } from "./atomic-guide-command.js";
23
- import { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage } from "./auth-guidance.js";
23
+ import { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage, formatUnresolvedModelMessage, } from "./auth-guidance.js";
24
24
  import { executeBashWithOperations } from "./bash-executor.js";
25
- import { calculateContextTokens, collectEntriesForBranchSummary, contextCompact as runContextCompact, estimateContextTokens, generateBranchSummary, prepareContextCompaction, shouldCompact, } from "./compaction/index.js";
25
+ import { calculateContextTokens, collectEntriesForBranchSummary, contextCompact as runContextCompact, estimateContextTokens, generateBranchSummary, prepareContextCompaction, shouldCompact, validateContextDeletionRequest, } from "./compaction/index.js";
26
26
  import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
27
27
  import { exportSessionToHtml } from "./export-html/index.js";
28
28
  import { createToolHtmlRenderer } from "./export-html/tool-renderer.js";
@@ -34,7 +34,17 @@ import { createSyntheticSourceInfo } from "./source-info.js";
34
34
  import { buildSystemPrompt } from "./system-prompt.js";
35
35
  import { createLocalBashOperations } from "./tools/bash.js";
36
36
  import { createAllToolDefinitions, defaultToolNames } from "./tools/index.js";
37
+ import { redirectOversizedToolResult } from "./tools/oversized-tool-result.js";
37
38
  import { createToolDefinitionFromAgentTool } from "./tools/tool-definition-wrapper.js";
39
+ function deepFreeze(value) {
40
+ if (value && typeof value === "object") {
41
+ Object.freeze(value);
42
+ for (const nested of Object.values(value)) {
43
+ deepFreeze(nested);
44
+ }
45
+ }
46
+ return value;
47
+ }
38
48
  /**
39
49
  * Parse a skill block from message text.
40
50
  * Returns null if the text doesn't contain a skill block.
@@ -149,6 +159,7 @@ export class AgentSession {
149
159
  this._pendingBashMessages = [];
150
160
  this._turnIndex = 0;
151
161
  this._baseToolDefinitions = new Map();
162
+ this._extensionMode = "print";
152
163
  // Tool registry for extension getTools/setTools
153
164
  this._toolRegistry = new Map();
154
165
  this._toolDefinitions = new Map();
@@ -253,26 +264,43 @@ export class AgentSession {
253
264
  };
254
265
  this.agent.afterToolCall = async ({ toolCall, args, result, isError }) => {
255
266
  const runner = this._extensionRunner;
256
- if (!runner.hasHandlers("tool_result")) {
257
- return undefined;
258
- }
259
- const hookResult = await runner.emitToolResult({
260
- type: "tool_result",
267
+ const hookResult = runner.hasHandlers("tool_result")
268
+ ? await runner.emitToolResult({
269
+ type: "tool_result",
270
+ toolName: toolCall.name,
271
+ toolCallId: toolCall.id,
272
+ input: args,
273
+ content: result.content,
274
+ details: result.details,
275
+ isError,
276
+ })
277
+ : undefined;
278
+ const extensionReplacement = hookResult
279
+ ? {
280
+ content: hookResult.content,
281
+ details: hookResult.details,
282
+ isError: hookResult.isError ?? isError,
283
+ }
284
+ : undefined;
285
+ const finalResult = hookResult
286
+ ? {
287
+ content: hookResult.content ?? result.content,
288
+ // Preserve original details when an extension hook rewrites only content;
289
+ // the redirect check only replaces model-visible content blocks.
290
+ details: hookResult.details ?? result.details,
291
+ }
292
+ : result;
293
+ const finalIsError = hookResult?.isError ?? isError;
294
+ const redirectReplacement = await redirectOversizedToolResult({
261
295
  toolName: toolCall.name,
262
296
  toolCallId: toolCall.id,
263
- input: args,
264
- content: result.content,
265
- details: result.details,
266
- isError,
297
+ result: finalResult,
298
+ isError: finalIsError,
299
+ sessionId: this.sessionManager.getSessionId(),
300
+ sessionDir: this.sessionManager.getSessionDir() || undefined,
301
+ maxResultSizeChars: this.getToolDefinition(toolCall.name)?.maxResultSizeChars,
267
302
  });
268
- if (!hookResult) {
269
- return undefined;
270
- }
271
- return {
272
- content: hookResult.content,
273
- details: hookResult.details,
274
- isError: hookResult.isError ?? isError,
275
- };
303
+ return redirectReplacement ?? extensionReplacement;
276
304
  };
277
305
  }
278
306
  // =========================================================================
@@ -357,7 +385,7 @@ export class AgentSession {
357
385
  // Regular LLM message - persist as SessionMessageEntry
358
386
  this.sessionManager.appendMessage(event.message);
359
387
  }
360
- // Other message types (bashExecution, compactionSummary, branchSummary) are persisted elsewhere
388
+ // Other message types (bashExecution, branchSummary) are persisted elsewhere
361
389
  // Track assistant message for auto-compaction (checked on agent_end)
362
390
  if (event.message.role === "assistant") {
363
391
  this._lastAssistantMessage = event.message;
@@ -624,6 +652,7 @@ export class AgentSession {
624
652
  name: definition.name,
625
653
  description: definition.description,
626
654
  parameters: definition.parameters,
655
+ promptGuidelines: definition.promptGuidelines,
627
656
  sourceInfo,
628
657
  }));
629
658
  }
@@ -788,7 +817,7 @@ export class AgentSession {
788
817
  let currentText = text;
789
818
  let currentImages = options?.images;
790
819
  if (this._extensionRunner.hasHandlers("input")) {
791
- const inputResult = await this._extensionRunner.emitInput(currentText, currentImages, options?.source ?? "interactive");
820
+ const inputResult = await this._extensionRunner.emitInput(currentText, currentImages, options?.source ?? "interactive", this.isStreaming ? options?.streamingBehavior : undefined);
792
821
  if (inputResult.action === "handled") {
793
822
  preflightResult?.(true);
794
823
  return;
@@ -824,6 +853,15 @@ export class AgentSession {
824
853
  if (!this.model) {
825
854
  throw new Error(formatNoModelSelectedMessage());
826
855
  }
856
+ // Defensive guard: a model that never resolved to a real provider
857
+ // (for example an unknown/unresolved model id that reached this path
858
+ // as a bare string) has no `provider`, which would otherwise fail deep
859
+ // in auth resolution as the confusing "No API key found for undefined".
860
+ // Surface a clear, accurate "unknown model" error instead.
861
+ const resolvedProvider = this.model.provider;
862
+ if (typeof resolvedProvider !== "string" || resolvedProvider.length === 0) {
863
+ throw new Error(formatUnresolvedModelMessage(this.model));
864
+ }
827
865
  if (!this._modelRegistry.hasConfiguredAuth(this.model)) {
828
866
  const isOAuth = this._modelRegistry.isUsingOAuth(this.model);
829
867
  if (isOAuth) {
@@ -887,8 +925,20 @@ export class AgentSession {
887
925
  return;
888
926
  }
889
927
  preflightResult?.(true);
928
+ await this._runAgentPrompt(messages);
929
+ }
930
+ async _runAgentPrompt(messages) {
890
931
  await this.agent.prompt(messages);
891
932
  await this.waitForRetry();
933
+ await this._continueQueuedAgentMessages();
934
+ }
935
+ async _continueQueuedAgentMessages() {
936
+ await this._agentEventQueue;
937
+ while (this.agent.hasQueuedMessages()) {
938
+ await this.agent.continue();
939
+ await this.waitForRetry();
940
+ await this._agentEventQueue;
941
+ }
892
942
  }
893
943
  /**
894
944
  * Try to execute a built-in slash command. Returns true if command was found and executed.
@@ -1092,7 +1142,7 @@ export class AgentSession {
1092
1142
  this._queueAgentMessage(appMessage, options?.deliverAs === "followUp" ? "followUp" : "steer");
1093
1143
  }
1094
1144
  else if (options?.triggerTurn) {
1095
- await this.agent.prompt(appMessage);
1145
+ await this._runAgentPrompt(appMessage);
1096
1146
  }
1097
1147
  else {
1098
1148
  this._appendCustomMessage(appMessage);
@@ -1483,6 +1533,9 @@ export class AgentSession {
1483
1533
  if (!this.model) {
1484
1534
  throw new Error(formatNoModelSelectedMessage());
1485
1535
  }
1536
+ // Capture the narrowed model now (control-flow narrowing holds immediately after the
1537
+ // guard) so the lazy planner-fallback closure below can use a non-undefined model.
1538
+ const model = this.model;
1486
1539
  const pathEntries = this.sessionManager.getBranch();
1487
1540
  const settings = this.settingsManager.getCompactionSettings();
1488
1541
  const mode = options.mode ?? "standard";
@@ -1490,28 +1543,118 @@ export class AgentSession {
1490
1543
  if (!preparation) {
1491
1544
  return undefined;
1492
1545
  }
1493
- const validated = await runContextCompact(preparation, this.model, options.apiKey, options.headers, options.abortController.signal, this.thinkingLevel, mode);
1546
+ // Planner fallback used when no extension supplies a deletionRequest. Auth is resolved
1547
+ // lazily here so extension-provided deletion requests keep working offline. Returns
1548
+ // undefined when auth is unavailable (auto-mode resolvers), signaling a no-op compaction.
1549
+ const runPlanner = async () => {
1550
+ const auth = await options.resolvePlannerAuth();
1551
+ if (!auth)
1552
+ return undefined;
1553
+ return runContextCompact(preparation, model, auth.apiKey, auth.headers, options.abortController.signal, this.thinkingLevel, mode);
1554
+ };
1555
+ // Emit session_before_compact to allow extensions to cancel or provide a deletion request.
1556
+ // This happens BEFORE any auth resolution so local extension deletion requests work
1557
+ // without configured API credentials.
1558
+ let fromExtension = false;
1559
+ let validated;
1560
+ if (this._extensionRunner.hasHandlers("session_before_compact")) {
1561
+ // Deep-clone the preparation only when a before-compact handler actually exists. Extensions
1562
+ // receive an isolated, frozen snapshot so they cannot mutate protection metadata
1563
+ // (protectedEntryIds, entry .protected flags, etc.) on the internal preparation used for
1564
+ // validation. Building it lazily avoids deep-cloning the transcript — largest exactly when
1565
+ // compaction fires — on the common no-extension path.
1566
+ let extensionPreparation;
1567
+ try {
1568
+ extensionPreparation = deepFreeze(structuredClone(preparation));
1569
+ }
1570
+ catch (error) {
1571
+ // structuredClone only throws if an entry carries a non-cloneable value (a function or a
1572
+ // class instance). Transcript entries are plain data today, so this guards a latent
1573
+ // invariant: surface a clear error instead of letting a raw DataCloneError abort an
1574
+ // otherwise-viable compaction.
1575
+ throw new Error(`Failed to snapshot transcript for compaction extensions: ${error instanceof Error ? error.message : String(error)}`);
1576
+ }
1577
+ const hookResult = (await this._extensionRunner.emit({
1578
+ type: "session_before_compact",
1579
+ reason: options.reason,
1580
+ mode,
1581
+ preparation: extensionPreparation,
1582
+ branchEntries: pathEntries,
1583
+ signal: options.abortController.signal,
1584
+ }));
1585
+ if (hookResult?.cancel) {
1586
+ throw new Error("Compaction cancelled");
1587
+ }
1588
+ if (hookResult?.deletionRequest) {
1589
+ const extensionDeletionRequest = hookResult.deletionRequest;
1590
+ // Reject empty deletion requests before any side effects (backup, append, rebuild).
1591
+ if (!Array.isArray(extensionDeletionRequest.deletions) || extensionDeletionRequest.deletions.length === 0) {
1592
+ throw new Error("No safe context deletions proposed by extension");
1593
+ }
1594
+ // Validate against the internal transcript snapshot, not the extension-facing clone.
1595
+ // Auth is NOT resolved here — local extension deletion requests work offline.
1596
+ validated = validateContextDeletionRequest(extensionDeletionRequest, preparation.transcript, { mode });
1597
+ // Reject if reconciliation reduced deletions to zero.
1598
+ if (validated.deletedTargets.length === 0) {
1599
+ throw new Error("No safe context deletions proposed by extension");
1600
+ }
1601
+ fromExtension = true;
1602
+ }
1603
+ }
1604
+ // Planner fallback shared by both paths: no before-compact handler at all, or a handler that
1605
+ // observed without supplying a deletionRequest. Resolves auth lazily; undefined means auth is
1606
+ // unavailable (auto-mode resolvers), so compaction is a no-op.
1607
+ if (!validated) {
1608
+ const plannerResult = await runPlanner();
1609
+ if (!plannerResult) {
1610
+ return undefined;
1611
+ }
1612
+ validated = plannerResult;
1613
+ }
1494
1614
  if (options.abortController.signal.aborted) {
1495
1615
  throw new Error("Compaction cancelled");
1496
1616
  }
1497
1617
  const backupPath = this.sessionManager.writeBackupSnapshot(options.backupLabel);
1498
- this.sessionManager.appendContextCompaction(validated.deletedTargets, validated.protectedEntryIds, validated.stats, backupPath);
1618
+ const compactionEntryId = this.sessionManager.appendContextCompaction(validated.deletedTargets, validated.protectedEntryIds, validated.stats, backupPath);
1499
1619
  const sessionContext = this.sessionManager.buildSessionContext();
1500
1620
  this.agent.state.messages = sessionContext.messages;
1501
- return {
1621
+ const result = {
1502
1622
  ...validated,
1503
1623
  promptVersion: 1,
1504
1624
  ...(backupPath ? { backupPath } : {}),
1505
1625
  };
1626
+ // Emit session_compact so extensions can observe the validated result. This is a pure
1627
+ // observation hook fired AFTER the compaction has been committed (backup written,
1628
+ // context_compaction entry persisted, active context rebuilt). A misbehaving observer must
1629
+ // never turn a successful, already-persisted compaction into a reported failure, so any
1630
+ // throw is routed to the non-fatal extension-error channel and compaction still reports
1631
+ // success.
1632
+ const contextCompactionEntry = this.sessionManager.getEntry(compactionEntryId);
1633
+ try {
1634
+ await this._extensionRunner.emit({
1635
+ type: "session_compact",
1636
+ reason: options.reason,
1637
+ mode,
1638
+ result,
1639
+ contextCompactionEntry,
1640
+ fromExtension,
1641
+ });
1642
+ }
1643
+ catch (error) {
1644
+ this._extensionRunner.emitError({
1645
+ extensionPath: "<session_compact>",
1646
+ event: "session_compact",
1647
+ error: error instanceof Error ? error.message : String(error),
1648
+ stack: error instanceof Error ? error.stack : undefined,
1649
+ });
1650
+ }
1651
+ return result;
1506
1652
  }
1507
1653
  /**
1508
1654
  * Manually compact the session context using deletion-only verbatim context compaction.
1509
- * Aborts current agent operation first. Custom summary instructions are not accepted.
1655
+ * Aborts current agent operation first.
1510
1656
  */
1511
- async compact(customInstructions) {
1512
- if (customInstructions?.trim()) {
1513
- throw new Error("Custom compaction instructions are not supported; use /compact without arguments");
1514
- }
1657
+ async compact() {
1515
1658
  this._disconnectFromAgent();
1516
1659
  await this.abort();
1517
1660
  this._compactionAbortController = new AbortController();
@@ -1520,12 +1663,14 @@ export class AgentSession {
1520
1663
  if (!this.model) {
1521
1664
  throw new Error(formatNoModelSelectedMessage());
1522
1665
  }
1523
- const { apiKey, headers } = await this._getRequiredRequestAuth(this.model);
1666
+ // Auth is resolved lazily: only called when the planner fallback is needed.
1667
+ // Extensions that provide a deletionRequest work without configured credentials.
1668
+ const model = this.model;
1524
1669
  const result = await this._applyContextVerbatimCompaction({
1525
- apiKey,
1526
- headers,
1670
+ resolvePlannerAuth: () => this._getRequiredRequestAuth(model),
1527
1671
  abortController: this._compactionAbortController,
1528
1672
  backupLabel: "compact",
1673
+ reason: "manual",
1529
1674
  });
1530
1675
  if (!result) {
1531
1676
  throw new Error("Nothing to compact (session too small)");
@@ -1570,12 +1715,14 @@ export class AgentSession {
1570
1715
  if (!this.model) {
1571
1716
  throw new Error(formatNoModelSelectedMessage());
1572
1717
  }
1573
- const { apiKey, headers } = await this._getRequiredRequestAuth(this.model);
1718
+ // Auth is resolved lazily: only called when the planner fallback is needed.
1719
+ // Extensions that provide a deletionRequest work without configured credentials.
1720
+ const model = this.model;
1574
1721
  const result = await this._applyContextVerbatimCompaction({
1575
- apiKey,
1576
- headers,
1722
+ resolvePlannerAuth: () => this._getRequiredRequestAuth(model),
1577
1723
  abortController: this._compactionAbortController,
1578
1724
  backupLabel: "context-compact",
1725
+ reason: "manual",
1579
1726
  });
1580
1727
  if (!result) {
1581
1728
  throw new Error("Nothing to context-compact (session too small)");
@@ -1754,23 +1901,24 @@ export class AgentSession {
1754
1901
  });
1755
1902
  return;
1756
1903
  }
1757
- const authResult = await this._modelRegistry.getApiKeyAndHeaders(this.model);
1758
- if (!authResult.ok || !authResult.apiKey) {
1759
- this._emit({
1760
- type: "compaction_end",
1761
- reason,
1762
- result: undefined,
1763
- aborted: false,
1764
- willRetry: false,
1765
- });
1766
- return;
1767
- }
1904
+ // Auth is resolved lazily: only called when the planner fallback is needed.
1905
+ // This allows extension-provided deletion requests to run before auth is checked,
1906
+ // enabling local extension compaction even when API credentials are unavailable.
1907
+ // Auto-mode resolver returns undefined (rather than throwing) when auth is missing,
1908
+ // so compaction silently no-ops if the planner would be needed but credentials are absent.
1909
+ const model = this.model;
1768
1910
  const result = await this._applyContextVerbatimCompaction({
1769
- apiKey: authResult.apiKey,
1770
- headers: authResult.headers,
1911
+ resolvePlannerAuth: async () => {
1912
+ const authResult = await this._modelRegistry.getApiKeyAndHeaders(model);
1913
+ if (!authResult.ok || !authResult.apiKey) {
1914
+ return undefined;
1915
+ }
1916
+ return { apiKey: authResult.apiKey, headers: authResult.headers };
1917
+ },
1771
1918
  abortController: this._autoCompactionAbortController,
1772
1919
  backupLabel: reason === "overflow" ? "overflow-auto-compact" : "auto-compact",
1773
1920
  mode: reason === "overflow" ? "critical_overflow" : "standard",
1921
+ reason,
1774
1922
  });
1775
1923
  if (!result) {
1776
1924
  this._emit({
@@ -1822,6 +1970,9 @@ export class AgentSession {
1822
1970
  if (bindings.uiContext !== undefined) {
1823
1971
  this._extensionUIContext = bindings.uiContext;
1824
1972
  }
1973
+ if (bindings.mode !== undefined) {
1974
+ this._extensionMode = bindings.mode;
1975
+ }
1825
1976
  if (bindings.commandContextActions !== undefined) {
1826
1977
  this._extensionCommandContextActions = bindings.commandContextActions;
1827
1978
  }
@@ -1876,7 +2027,7 @@ export class AgentSession {
1876
2027
  return `extension:${name}`;
1877
2028
  }
1878
2029
  _applyExtensionBindings(runner) {
1879
- runner.setUIContext(this._extensionUIContext);
2030
+ runner.setUIContext(this._extensionUIContext, this._extensionMode);
1880
2031
  runner.bindCommandContext(this._extensionCommandContextActions);
1881
2032
  this._extensionErrorUnsubscriber?.();
1882
2033
  this._extensionErrorUnsubscriber = this._extensionErrorListener
@@ -1964,6 +2115,7 @@ export class AgentSession {
1964
2115
  }, {
1965
2116
  getModel: () => this.model,
1966
2117
  isIdle: () => !this.isStreaming,
2118
+ isProjectTrusted: () => this.settingsManager.isProjectTrusted(),
1967
2119
  getSignal: () => this.agent.signal,
1968
2120
  abort: () => this.abort(),
1969
2121
  hasPendingMessages: () => this.pendingMessageCount > 0,
@@ -1974,7 +2126,7 @@ export class AgentSession {
1974
2126
  compact: (options) => {
1975
2127
  void (async () => {
1976
2128
  try {
1977
- const result = await this.compact(options?.customInstructions);
2129
+ const result = await this.compact();
1978
2130
  options?.onComplete?.(result);
1979
2131
  }
1980
2132
  catch (error) {
@@ -1984,6 +2136,7 @@ export class AgentSession {
1984
2136
  })();
1985
2137
  },
1986
2138
  getSystemPrompt: () => this.systemPrompt,
2139
+ getSystemPromptOptions: () => this._baseSystemPromptOptions,
1987
2140
  }, {
1988
2141
  registerProvider: (name, config) => {
1989
2142
  this._modelRegistry.registerProvider(name, config);
@@ -2442,6 +2595,7 @@ export class AgentSession {
2442
2595
  customInstructions,
2443
2596
  replaceInstructions,
2444
2597
  reserveTokens: branchSummarySettings.reserveTokens,
2598
+ streamFn: this.agent.streamFn,
2445
2599
  });
2446
2600
  if (result.aborted) {
2447
2601
  return { cancelled: true, aborted: true };