@bastani/atomic 0.8.26-alpha.1 → 0.8.26-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 (303) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/README.md +5 -5
  3. package/dist/builtin/intercom/CHANGELOG.md +54 -0
  4. package/dist/builtin/intercom/package.json +2 -2
  5. package/dist/builtin/mcp/CHANGELOG.md +54 -0
  6. package/dist/builtin/mcp/package.json +3 -3
  7. package/dist/builtin/subagents/CHANGELOG.md +55 -0
  8. package/dist/builtin/subagents/agents/codebase-online-researcher.md +9 -9
  9. package/dist/builtin/subagents/agents/debugger.md +6 -6
  10. package/dist/builtin/subagents/package.json +4 -4
  11. package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +1 -1
  12. package/dist/builtin/subagents/skills/browser/EXAMPLES.md +151 -0
  13. package/dist/builtin/subagents/skills/browser/LICENSE.txt +21 -0
  14. package/dist/builtin/subagents/skills/browser/REFERENCE.md +451 -0
  15. package/dist/builtin/subagents/skills/browser/SKILL.md +170 -0
  16. package/dist/builtin/subagents/skills/subagent/SKILL.md +4 -4
  17. package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +55 -12
  18. package/dist/builtin/subagents/src/runs/foreground/execution.ts +71 -12
  19. package/dist/builtin/subagents/src/runs/shared/acceptance.ts +2 -1
  20. package/dist/builtin/subagents/src/runs/shared/final-drain.ts +34 -0
  21. package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +416 -7
  22. package/dist/builtin/subagents/src/runs/shared/worktree.ts +2 -2
  23. package/dist/builtin/web-access/CHANGELOG.md +54 -0
  24. package/dist/builtin/web-access/package.json +2 -2
  25. package/dist/builtin/workflows/CHANGELOG.md +66 -0
  26. package/dist/builtin/workflows/README.md +10 -8
  27. package/dist/builtin/workflows/builtin/deep-research-codebase.ts +11 -8
  28. package/dist/builtin/workflows/builtin/goal.ts +137 -109
  29. package/dist/builtin/workflows/builtin/index.d.ts +2 -0
  30. package/dist/builtin/workflows/builtin/open-claude-design.ts +228 -151
  31. package/dist/builtin/workflows/builtin/ralph.d.ts +2 -0
  32. package/dist/builtin/workflows/builtin/ralph.ts +452 -279
  33. package/dist/builtin/workflows/package.json +2 -2
  34. package/dist/builtin/workflows/skills/create-spec/SKILL.md +14 -0
  35. package/dist/builtin/workflows/skills/research-codebase/SKILL.md +29 -10
  36. package/dist/builtin/workflows/src/extension/index.ts +10 -2
  37. package/dist/builtin/workflows/src/extension/runtime.ts +35 -3
  38. package/dist/builtin/workflows/src/extension/wiring.ts +13 -1
  39. package/dist/builtin/workflows/src/runs/background/status.ts +52 -6
  40. package/dist/builtin/workflows/src/runs/foreground/executor.ts +453 -21
  41. package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +77 -11
  42. package/dist/builtin/workflows/src/runs/shared/model-fallback.ts +402 -8
  43. package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -2
  44. package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +2 -2
  45. package/dist/builtin/workflows/src/shared/persistence-restore.ts +182 -6
  46. package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +76 -6
  47. package/dist/builtin/workflows/src/shared/stage-prompt.ts +33 -2
  48. package/dist/builtin/workflows/src/shared/store-types.ts +31 -0
  49. package/dist/builtin/workflows/src/shared/store.ts +160 -18
  50. package/dist/builtin/workflows/src/shared/types.ts +3 -3
  51. package/dist/builtin/workflows/src/shared/workflow-failures.ts +758 -132
  52. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +39 -3
  53. package/dist/builtin/workflows/src/tui/store-widget-installer.ts +74 -74
  54. package/dist/core/agent-session.d.ts +33 -6
  55. package/dist/core/agent-session.d.ts.map +1 -1
  56. package/dist/core/agent-session.js +157 -182
  57. package/dist/core/agent-session.js.map +1 -1
  58. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  59. package/dist/core/atomic-guide-command.js +11 -9
  60. package/dist/core/atomic-guide-command.js.map +1 -1
  61. package/dist/core/compaction/branch-summarization.d.ts +1 -1
  62. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  63. package/dist/core/compaction/branch-summarization.js +6 -3
  64. package/dist/core/compaction/branch-summarization.js.map +1 -1
  65. package/dist/core/compaction/compaction.d.ts.map +1 -1
  66. package/dist/core/compaction/compaction.js +23 -10
  67. package/dist/core/compaction/compaction.js.map +1 -1
  68. package/dist/core/compaction/context-compaction.d.ts +175 -0
  69. package/dist/core/compaction/context-compaction.d.ts.map +1 -0
  70. package/dist/core/compaction/context-compaction.js +1636 -0
  71. package/dist/core/compaction/context-compaction.js.map +1 -0
  72. package/dist/core/compaction/index.d.ts +1 -0
  73. package/dist/core/compaction/index.d.ts.map +1 -1
  74. package/dist/core/compaction/index.js +1 -0
  75. package/dist/core/compaction/index.js.map +1 -1
  76. package/dist/core/extensions/types.d.ts +3 -2
  77. package/dist/core/extensions/types.d.ts.map +1 -1
  78. package/dist/core/extensions/types.js.map +1 -1
  79. package/dist/core/footer-data-provider.d.ts.map +1 -1
  80. package/dist/core/footer-data-provider.js +3 -0
  81. package/dist/core/footer-data-provider.js.map +1 -1
  82. package/dist/core/index.d.ts +1 -1
  83. package/dist/core/index.d.ts.map +1 -1
  84. package/dist/core/index.js.map +1 -1
  85. package/dist/core/package-manager.d.ts.map +1 -1
  86. package/dist/core/package-manager.js +14 -7
  87. package/dist/core/package-manager.js.map +1 -1
  88. package/dist/core/session-manager.d.ts +41 -1
  89. package/dist/core/session-manager.d.ts.map +1 -1
  90. package/dist/core/session-manager.js +146 -7
  91. package/dist/core/session-manager.js.map +1 -1
  92. package/dist/core/slash-commands.d.ts.map +1 -1
  93. package/dist/core/slash-commands.js +1 -1
  94. package/dist/core/slash-commands.js.map +1 -1
  95. package/dist/core/tools/ask-user-question/tool/format-answer.d.ts +5 -5
  96. package/dist/core/tools/ask-user-question/tool/format-answer.d.ts.map +1 -1
  97. package/dist/core/tools/ask-user-question/tool/format-answer.js +5 -5
  98. package/dist/core/tools/ask-user-question/tool/format-answer.js.map +1 -1
  99. package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts +16 -3
  100. package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts.map +1 -1
  101. package/dist/core/tools/ask-user-question/tool/response-envelope.js +21 -3
  102. package/dist/core/tools/ask-user-question/tool/response-envelope.js.map +1 -1
  103. package/dist/index.d.ts +4 -3
  104. package/dist/index.d.ts.map +1 -1
  105. package/dist/index.js +3 -2
  106. package/dist/index.js.map +1 -1
  107. package/dist/modes/index.d.ts +1 -1
  108. package/dist/modes/index.d.ts.map +1 -1
  109. package/dist/modes/index.js.map +1 -1
  110. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  111. package/dist/modes/interactive/components/chat-session-host.js +17 -0
  112. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  113. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts +17 -0
  114. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts.map +1 -0
  115. package/dist/modes/interactive/components/context-compaction-summary-message.js +83 -0
  116. package/dist/modes/interactive/components/context-compaction-summary-message.js.map +1 -0
  117. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  118. package/dist/modes/interactive/components/footer.js +4 -1
  119. package/dist/modes/interactive/components/footer.js.map +1 -1
  120. package/dist/modes/interactive/components/index.d.ts +1 -0
  121. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  122. package/dist/modes/interactive/components/index.js +1 -0
  123. package/dist/modes/interactive/components/index.js.map +1 -1
  124. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  125. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  126. package/dist/modes/interactive/interactive-mode.js +75 -10
  127. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  128. package/dist/modes/rpc/rpc-client.d.ts +13 -8
  129. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  130. package/dist/modes/rpc/rpc-client.js +8 -1
  131. package/dist/modes/rpc/rpc-client.js.map +1 -1
  132. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  133. package/dist/modes/rpc/rpc-mode.js +4 -0
  134. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  135. package/dist/modes/rpc/rpc-types.d.ts +14 -3
  136. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  137. package/dist/modes/rpc/rpc-types.js.map +1 -1
  138. package/dist/utils/git-env.d.ts +10 -0
  139. package/dist/utils/git-env.d.ts.map +1 -0
  140. package/dist/utils/git-env.js +33 -0
  141. package/dist/utils/git-env.js.map +1 -0
  142. package/docs/compaction.md +185 -50
  143. package/docs/custom-provider.md +11 -9
  144. package/docs/extensions.md +46 -42
  145. package/docs/index.md +13 -6
  146. package/docs/json.md +15 -12
  147. package/docs/packages.md +2 -0
  148. package/docs/providers.md +4 -1
  149. package/docs/quickstart.md +18 -11
  150. package/docs/rpc.md +38 -23
  151. package/docs/sdk.md +17 -8
  152. package/docs/session-format.md +26 -13
  153. package/docs/sessions.md +3 -3
  154. package/docs/settings.md +2 -2
  155. package/docs/skills.md +1 -15
  156. package/docs/termux.md +9 -10
  157. package/docs/themes.md +2 -2
  158. package/docs/tmux.md +3 -3
  159. package/docs/tui.md +19 -32
  160. package/docs/usage.md +2 -2
  161. package/docs/workflows.md +60 -16
  162. package/package.json +6 -12
  163. package/dist/builtin/subagents/skills/browser-use/SKILL.md +0 -234
  164. package/dist/builtin/subagents/skills/browser-use/references/cdp-python.md +0 -76
  165. package/dist/builtin/subagents/skills/browser-use/references/multi-session.md +0 -92
  166. package/node_modules/@earendil-works/pi-tui/README.md +0 -779
  167. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +0 -54
  168. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +0 -1
  169. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +0 -632
  170. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +0 -1
  171. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +0 -22
  172. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +0 -1
  173. package/node_modules/@earendil-works/pi-tui/dist/components/box.js +0 -104
  174. package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +0 -1
  175. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts +0 -22
  176. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts.map +0 -1
  177. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js +0 -35
  178. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js.map +0 -1
  179. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +0 -249
  180. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +0 -1
  181. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +0 -1857
  182. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +0 -1
  183. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts +0 -28
  184. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +0 -1
  185. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +0 -89
  186. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +0 -1
  187. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts +0 -37
  188. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +0 -1
  189. package/node_modules/@earendil-works/pi-tui/dist/components/input.js +0 -378
  190. package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +0 -1
  191. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +0 -31
  192. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts.map +0 -1
  193. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js +0 -69
  194. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js.map +0 -1
  195. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +0 -96
  196. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +0 -1
  197. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +0 -644
  198. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +0 -1
  199. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +0 -50
  200. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +0 -1
  201. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +0 -159
  202. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +0 -1
  203. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +0 -50
  204. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +0 -1
  205. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +0 -185
  206. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +0 -1
  207. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts +0 -12
  208. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts.map +0 -1
  209. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js +0 -23
  210. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js.map +0 -1
  211. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +0 -19
  212. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +0 -1
  213. package/node_modules/@earendil-works/pi-tui/dist/components/text.js +0 -89
  214. package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +0 -1
  215. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts +0 -13
  216. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts.map +0 -1
  217. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js +0 -51
  218. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js.map +0 -1
  219. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts +0 -39
  220. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts.map +0 -1
  221. package/node_modules/@earendil-works/pi-tui/dist/editor-component.js +0 -2
  222. package/node_modules/@earendil-works/pi-tui/dist/editor-component.js.map +0 -1
  223. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts +0 -16
  224. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts.map +0 -1
  225. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +0 -110
  226. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js.map +0 -1
  227. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +0 -23
  228. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +0 -1
  229. package/node_modules/@earendil-works/pi-tui/dist/index.js +0 -32
  230. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +0 -1
  231. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +0 -193
  232. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +0 -1
  233. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +0 -174
  234. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +0 -1
  235. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts +0 -184
  236. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +0 -1
  237. package/node_modules/@earendil-works/pi-tui/dist/keys.js +0 -1173
  238. package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +0 -1
  239. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts +0 -28
  240. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts.map +0 -1
  241. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js +0 -44
  242. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js.map +0 -1
  243. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts +0 -3
  244. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts.map +0 -1
  245. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js +0 -53
  246. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js.map +0 -1
  247. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +0 -50
  248. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +0 -1
  249. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +0 -361
  250. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +0 -1
  251. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +0 -90
  252. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +0 -1
  253. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +0 -366
  254. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +0 -1
  255. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +0 -113
  256. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +0 -1
  257. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +0 -472
  258. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +0 -1
  259. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +0 -227
  260. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +0 -1
  261. package/node_modules/@earendil-works/pi-tui/dist/tui.js +0 -1106
  262. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +0 -1
  263. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts +0 -17
  264. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts.map +0 -1
  265. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js +0 -25
  266. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js.map +0 -1
  267. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +0 -84
  268. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +0 -1
  269. package/node_modules/@earendil-works/pi-tui/dist/utils.js +0 -1029
  270. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +0 -1
  271. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts +0 -25
  272. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts.map +0 -1
  273. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js +0 -96
  274. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js.map +0 -1
  275. package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
  276. package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
  277. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  278. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  279. package/node_modules/@earendil-works/pi-tui/package.json +0 -47
  280. package/node_modules/get-east-asian-width/index.d.ts +0 -60
  281. package/node_modules/get-east-asian-width/index.js +0 -30
  282. package/node_modules/get-east-asian-width/license +0 -9
  283. package/node_modules/get-east-asian-width/lookup-data.js +0 -21
  284. package/node_modules/get-east-asian-width/lookup.js +0 -138
  285. package/node_modules/get-east-asian-width/package.json +0 -71
  286. package/node_modules/get-east-asian-width/readme.md +0 -65
  287. package/node_modules/get-east-asian-width/utilities.js +0 -24
  288. package/node_modules/marked/LICENSE.md +0 -44
  289. package/node_modules/marked/README.md +0 -106
  290. package/node_modules/marked/bin/main.js +0 -282
  291. package/node_modules/marked/bin/marked.js +0 -15
  292. package/node_modules/marked/lib/marked.cjs +0 -2211
  293. package/node_modules/marked/lib/marked.cjs.map +0 -7
  294. package/node_modules/marked/lib/marked.d.cts +0 -728
  295. package/node_modules/marked/lib/marked.d.ts +0 -728
  296. package/node_modules/marked/lib/marked.esm.js +0 -2189
  297. package/node_modules/marked/lib/marked.esm.js.map +0 -7
  298. package/node_modules/marked/lib/marked.umd.js +0 -2213
  299. package/node_modules/marked/lib/marked.umd.js.map +0 -7
  300. package/node_modules/marked/man/marked.1 +0 -111
  301. package/node_modules/marked/man/marked.1.md +0 -92
  302. package/node_modules/marked/marked.min.js +0 -69
  303. package/node_modules/marked/package.json +0 -111
@@ -521,6 +521,7 @@ export class StageChatView implements Component, Focusable {
521
521
  }
522
522
  if (!this.promptState || this.promptState.prompt.id !== prompt.id) {
523
523
  this.promptState = createPromptCardState(prompt);
524
+ this._seedPromptTextState(prompt);
524
525
  this._resetPromptEditor(prompt);
525
526
  this._resetPromptScroll();
526
527
  return true;
@@ -533,19 +534,49 @@ export class StageChatView implements Component, Focusable {
533
534
  this.promptMaxScroll = 0;
534
535
  }
535
536
 
537
+ private _promptSeedText(prompt: PendingPrompt): string {
538
+ const draft = this.store.getStagePromptDraft(this.runId, this.stageId, prompt.id);
539
+ if (draft !== undefined) return draft;
540
+ return typeof prompt.initial === "string" ? prompt.initial : "";
541
+ }
542
+
543
+ private _seedPromptTextState(prompt: PendingPrompt): void {
544
+ if (prompt.kind !== "input" && prompt.kind !== "editor") return;
545
+ if (!this.promptState || this.promptState.prompt.id !== prompt.id) return;
546
+ const seed = this._promptSeedText(prompt);
547
+ this.promptState.rawText = seed;
548
+ this.promptState.caret = seed.length;
549
+ }
550
+
551
+ private _recordPromptDraft(promptId: string, text: string): void {
552
+ this.store.recordStagePromptDraft(this.runId, this.stageId, promptId, text);
553
+ }
554
+
555
+ private _recordCurrentPromptDraft(): void {
556
+ const state = this.promptState;
557
+ if (!state) return;
558
+ const prompt = state.prompt;
559
+ if (prompt.kind !== "input" && prompt.kind !== "editor") return;
560
+ const text = this.promptEditor && this.promptEditorPromptId === prompt.id
561
+ ? this.promptEditor.getText()
562
+ : state.rawText;
563
+ this._recordPromptDraft(prompt.id, text);
564
+ }
565
+
536
566
  private _resetPromptEditor(prompt: PendingPrompt): void {
537
567
  this._disposePromptEditor();
538
568
  if ((prompt.kind !== "input" && prompt.kind !== "editor") || !this.piTui) return;
539
569
  const editor = this.piEditorFactory
540
570
  ? this.piEditorFactory(this.piTui, editorThemeFromGraphTheme(this.theme), this.piKeybindings)
541
571
  : new Editor(this.piTui, editorThemeFromGraphTheme(this.theme), { paddingX: 0 });
542
- editor.setText(typeof prompt.initial === "string" ? prompt.initial : "");
572
+ editor.setText(this.promptState?.prompt.id === prompt.id ? this.promptState.rawText : this._promptSeedText(prompt));
543
573
  setEditorPlaceholder(editor, "Type your response…");
544
574
  setEditorBorderColor(editor, (text) => hexToAnsi(this.theme.accent) + text + RESET);
545
575
  editor.onChange = (text: string) => {
546
576
  if (this.promptState?.prompt.id !== prompt.id) return;
547
577
  this.promptState.rawText = text;
548
578
  this.promptState.caret = text.length;
579
+ this._recordPromptDraft(prompt.id, text);
549
580
  this.requestRender?.();
550
581
  };
551
582
  editor.onSubmit = (text: string) => {
@@ -634,11 +665,12 @@ export class StageChatView implements Component, Focusable {
634
665
  const [command, ...rest] = text.trim().split(/\s+/);
635
666
  switch (command) {
636
667
  case "/compact": {
668
+ if (rest.length > 0) return true;
637
669
  const handle = this._liveHandle();
638
670
  if (!handle) return false;
639
671
  await handle.ensureAttached();
640
672
  if (!handle.agentSession) return false;
641
- await handle.agentSession.compact(rest.join(" ") || undefined);
673
+ await handle.agentSession.compact();
642
674
  return true;
643
675
  }
644
676
  case "/quit":
@@ -1248,11 +1280,14 @@ export class StageChatView implements Component, Focusable {
1248
1280
  return;
1249
1281
  }
1250
1282
  const action = handlePromptCardInput(data, state, this._promptKeybindings());
1283
+ const prompt = state.prompt;
1284
+ if (prompt.kind === "input" || prompt.kind === "editor") {
1285
+ this._recordPromptDraft(prompt.id, state.rawText);
1286
+ }
1251
1287
  if (action.kind === "noop") {
1252
1288
  this.requestRender?.();
1253
1289
  return;
1254
1290
  }
1255
- const prompt = state.prompt;
1256
1291
  const response = action.kind === "submit"
1257
1292
  ? action.response
1258
1293
  : defaultResponseFor(prompt);
@@ -1306,6 +1341,7 @@ export class StageChatView implements Component, Focusable {
1306
1341
  const readOnlyPromptArchive = readOnlyArchive && stage?.promptFootprint !== undefined;
1307
1342
  if (matchesKey(data, Key.ctrl("d"))) {
1308
1343
  if (!this.promptState && this.chatHost.hasInputText()) return this.chatHost.handleInput(data);
1344
+ this._recordCurrentPromptDraft();
1309
1345
  this.onDetach();
1310
1346
  return true;
1311
1347
  }
@@ -160,121 +160,125 @@ export function installToolExecutionHooks(pi: LiveWidgetAPI, storeInstance: Stor
160
160
  const extensionOn = pi.on;
161
161
  if (typeof eventBusOn !== "function" && typeof extensionOn !== "function") return;
162
162
 
163
- const activeAskUserQuestionCalls = new Map<string, { runId: string; stageId: string; callId: string }>();
163
+ interface StageScope {
164
+ readonly runId: string;
165
+ readonly stageId: string;
166
+ }
164
167
 
165
- function resolveIds(payload: ToolExecutionStartPayload, includeAwaitingInput = false): { runId: string; stageId: string } | null {
166
- const runId = payload.runId ?? payload.run_id ?? storeInstance.activeRunId();
167
- if (!runId) return null;
168
+ interface ActiveToolCall extends StageScope {
169
+ readonly callId: string;
170
+ readonly name: string;
171
+ readonly startedAt: number;
172
+ }
168
173
 
169
- const stageId = payload.stageId ?? payload.stage_id;
170
- if (stageId) return { runId, stageId };
174
+ const terminalRunStatuses = new Set(["completed", "failed", "killed"]);
175
+ const terminalStageStatuses = new Set(["completed", "failed", "skipped"]);
176
+ const activeToolCalls = new Map<string, ActiveToolCall>();
171
177
 
172
- const run = storeInstance.runs().find((candidate) => candidate.id === runId);
173
- const runningStage = run?.stages.find((s) => s.status === "running");
174
- if (runningStage) return { runId, stageId: runningStage.id };
178
+ function activeCallKey(runId: string, stageId: string, callId: string): string {
179
+ return `${runId}\0${stageId}\0${callId}`;
180
+ }
175
181
 
176
- if (includeAwaitingInput) {
177
- const awaitingStage = run?.stages.find((s) => s.status === "awaiting_input");
178
- if (awaitingStage) return { runId, stageId: awaitingStage.id };
182
+ function firstNonEmptyString(...values: readonly unknown[]): string | null {
183
+ for (const value of values) {
184
+ if (typeof value === "string" && value.length > 0) return value;
179
185
  }
180
-
181
186
  return null;
182
187
  }
183
188
 
184
- function activeCallKey(runId: string, stageId: string, callId: string): string {
185
- return `${runId}:${stageId}:${callId}`;
189
+ function resolveExplicitStageScope(payload: ToolExecutionStartPayload): StageScope | null {
190
+ const runId = firstNonEmptyString(payload.runId, payload.run_id);
191
+ const stageId = firstNonEmptyString(payload.stageId, payload.stage_id);
192
+ if (runId === null || stageId === null) return null;
193
+ return { runId, stageId };
186
194
  }
187
195
 
188
- function findActiveAskCall(payload: ToolExecutionStartPayload): { runId: string; stageId: string; callId: string } | undefined {
189
- const runId = payload.runId ?? payload.run_id;
190
- const stageId = payload.stageId ?? payload.stage_id;
191
- const callId = toolCallId(payload);
196
+ function hasLiveStageScope(scope: StageScope, snap: StoreSnapshot): boolean {
197
+ const run = snap.runs.find((candidate) => candidate.id === scope.runId);
198
+ if (!run || run.endedAt !== undefined || terminalRunStatuses.has(run.status)) return false;
199
+ const stage = run.stages.find((candidate) => candidate.id === scope.stageId);
200
+ return stage !== undefined && !terminalStageStatuses.has(stage.status);
201
+ }
192
202
 
193
- if (runId !== undefined && stageId !== undefined) {
194
- return activeAskUserQuestionCalls.get(activeCallKey(runId, stageId, callId));
203
+ function pruneActiveToolCalls(snap: StoreSnapshot): void {
204
+ for (const [key, call] of activeToolCalls) {
205
+ if (!hasLiveStageScope(call, snap)) activeToolCalls.delete(key);
195
206
  }
196
-
197
- const matches = [...activeAskUserQuestionCalls.values()].filter((entry) => {
198
- if (entry.callId !== callId) return false;
199
- if (runId !== undefined && entry.runId !== runId) return false;
200
- if (stageId !== undefined && entry.stageId !== stageId) return false;
201
- return true;
202
- });
203
- return matches.length === 1 ? matches[0] : undefined;
204
207
  }
205
208
 
206
- function stageHasActiveAskCall(runId: string, stageId: string): boolean {
207
- return [...activeAskUserQuestionCalls.values()].some(
208
- (entry) => entry.runId === runId && entry.stageId === stageId,
209
- );
210
- }
209
+ function activeToolCallForPayload(payload: ToolExecutionStartPayload): { key: string; call: ActiveToolCall } | null {
210
+ const scope = resolveExplicitStageScope(payload);
211
+ if (!scope) return null;
211
212
 
212
- function recordAskUserQuestionStart(payload: ToolExecutionStartPayload, ids: { runId: string; stageId: string }): void {
213
- if (!isAskUserQuestionToolName(toolName(payload))) return;
214
- const callId = toolCallId(payload);
215
- activeAskUserQuestionCalls.set(activeCallKey(ids.runId, ids.stageId, callId), {
216
- ...ids,
217
- callId,
218
- });
219
- storeInstance.recordStageAwaitingInput(ids.runId, ids.stageId, true, payload.ts);
213
+ const key = activeCallKey(scope.runId, scope.stageId, toolCallId(payload));
214
+ const call = activeToolCalls.get(key);
215
+ return call ? { key, call } : null;
220
216
  }
221
217
 
222
- function recordAskUserQuestionEnd(payload: ToolExecutionStartPayload, ids: { runId: string; stageId: string } | null): void {
223
- const activeCall = findActiveAskCall(payload);
224
- const resolvedIds = activeCall ?? ids;
225
- if (resolvedIds === null || resolvedIds === undefined) return;
226
-
227
- const shouldClear = activeCall !== undefined || isAskUserQuestionToolName(toolName(payload));
228
- if (!shouldClear) return;
229
-
230
- activeAskUserQuestionCalls.delete(activeCallKey(resolvedIds.runId, resolvedIds.stageId, toolCallId(payload)));
231
- if (!stageHasActiveAskCall(resolvedIds.runId, resolvedIds.stageId)) {
232
- storeInstance.recordStageAwaitingInput(resolvedIds.runId, resolvedIds.stageId, false);
233
- }
234
- }
218
+ storeInstance.subscribe(pruneActiveToolCalls);
235
219
 
236
220
  function recordToolStart(payload: unknown): void {
237
221
  if (!isToolExecutionPayload(payload)) return;
238
222
 
239
- const ids = resolveIds(payload);
240
- if (!ids) return;
223
+ const snap = storeInstance.snapshot();
224
+ pruneActiveToolCalls(snap);
225
+
226
+ const scope = resolveExplicitStageScope(payload);
227
+ if (!scope || !hasLiveStageScope(scope, snap)) return;
241
228
 
242
- storeInstance.recordToolStart(ids.runId, ids.stageId, {
243
- name: toolName(payload),
229
+ const callId = toolCallId(payload);
230
+ const key = activeCallKey(scope.runId, scope.stageId, callId);
231
+ if (activeToolCalls.has(key)) return;
232
+
233
+ const name = toolName(payload);
234
+ const startedAt = payload.ts ?? Date.now();
235
+ activeToolCalls.set(key, { ...scope, callId, name, startedAt });
236
+ storeInstance.recordToolStart(scope.runId, scope.stageId, {
237
+ name,
244
238
  input: toolInput(payload),
245
- startedAt: payload.ts ?? Date.now(),
239
+ startedAt,
246
240
  });
247
- recordAskUserQuestionStart(payload, ids);
241
+ }
242
+
243
+ function recordToolUpdate(payload: unknown): void {
244
+ if (!isToolExecutionPayload(payload)) return;
245
+
246
+ pruneActiveToolCalls(storeInstance.snapshot());
247
+
248
+ if (!activeToolCallForPayload(payload)) return;
249
+ // Updates are attach-only until the store has an explicit update API.
248
250
  }
249
251
 
250
252
  function recordToolEnd(payload: unknown): void {
251
253
  if (!isToolExecutionPayload(payload)) return;
252
254
 
253
- const activeAskCall = findActiveAskCall(payload);
254
- const ids = activeAskCall ?? resolveIds(payload, false);
255
- if (!ids) return;
255
+ pruneActiveToolCalls(storeInstance.snapshot());
256
256
 
257
- storeInstance.recordToolEnd(ids.runId, ids.stageId, {
258
- name: toolName(payload),
257
+ const active = activeToolCallForPayload(payload);
258
+ if (!active) return;
259
+
260
+ storeInstance.recordToolEnd(active.call.runId, active.call.stageId, {
261
+ name: active.call.name,
259
262
  input: toolInput(payload),
260
- startedAt: payload.ts ?? Date.now(),
263
+ startedAt: active.call.startedAt,
261
264
  endedAt: payload.endedAt ?? payload.ended_at ?? Date.now(),
262
265
  output: payload.output,
263
266
  });
264
- recordAskUserQuestionEnd(payload, activeAskCall ?? ids);
267
+ activeToolCalls.delete(active.key);
265
268
  }
266
269
 
267
270
  const safeStart = safelyHandle(recordToolStart);
271
+ const safeUpdate = safelyHandle(recordToolUpdate);
268
272
  const safeEnd = safelyHandle(recordToolEnd);
269
273
 
270
274
  if (typeof eventBusOn === "function") {
271
275
  eventBusOn.call(pi.events, "tool_execution_start", safeStart);
272
- eventBusOn.call(pi.events, "tool_execution_update", safeStart);
276
+ eventBusOn.call(pi.events, "tool_execution_update", safeUpdate);
273
277
  eventBusOn.call(pi.events, "tool_execution_end", safeEnd);
274
278
  }
275
279
  if (typeof extensionOn === "function") {
276
280
  extensionOn.call(pi, "tool_execution_start", safeStart);
277
- extensionOn.call(pi, "tool_execution_update", safeStart);
281
+ extensionOn.call(pi, "tool_execution_update", safeUpdate);
278
282
  extensionOn.call(pi, "tool_execution_end", safeEnd);
279
283
  extensionOn.call(pi, "tool_call", safeStart);
280
284
  extensionOn.call(pi, "tool_result", safeEnd);
@@ -306,7 +310,3 @@ function toolCallId(payload: ToolExecutionStartPayload): string {
306
310
  function toolInput(payload: ToolExecutionStartPayload): Record<string, unknown> | undefined {
307
311
  return payload.input ?? payload.args;
308
312
  }
309
-
310
- function isAskUserQuestionToolName(name: string): boolean {
311
- return name.toLowerCase().replace(/[^a-z0-9]/g, "") === "askuserquestion";
312
- }
@@ -15,7 +15,7 @@
15
15
  import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from "@earendil-works/pi-agent-core";
16
16
  import type { Api, ImageContent, Model, TextContent } from "@earendil-works/pi-ai";
17
17
  import { type BashResult } from "./bash-executor.ts";
18
- import { type CompactionResult } from "./compaction/index.ts";
18
+ import { type CompactionResult, type ContextCompactionResult } from "./compaction/index.ts";
19
19
  import { type ContextUsage, type ExtensionCommandContextActions, type ExtensionErrorListener, ExtensionRunner, type ExtensionUIContext, type InputSource, type OrchestrationContext, type ReplacedSessionContext, type SendMessageOptions, type SessionStartEvent, type ShutdownHandler, type ToolDefinition, type ToolInfo } from "./extensions/index.ts";
20
20
  import type { CustomMessage } from "./messages.ts";
21
21
  import type { ModelRegistry } from "./model-registry.ts";
@@ -44,6 +44,9 @@ export type AgentSessionEvent = AgentEvent | {
44
44
  } | {
45
45
  type: "compaction_start";
46
46
  reason: "manual" | "threshold" | "overflow";
47
+ } | {
48
+ type: "context_compaction_start";
49
+ reason: "manual";
47
50
  } | {
48
51
  type: "session_info_changed";
49
52
  name: string | undefined;
@@ -58,10 +61,17 @@ export type AgentSessionEvent = AgentEvent | {
58
61
  } | {
59
62
  type: "compaction_end";
60
63
  reason: "manual" | "threshold" | "overflow";
61
- result: CompactionResult | undefined;
64
+ result: CompactionResult | ContextCompactionResult | undefined;
62
65
  aborted: boolean;
63
66
  willRetry: boolean;
64
67
  errorMessage?: string;
68
+ } | {
69
+ type: "context_compaction_end";
70
+ reason: "manual";
71
+ result: ContextCompactionResult | undefined;
72
+ aborted: boolean;
73
+ willRetry: false;
74
+ errorMessage?: string;
65
75
  } | {
66
76
  type: "auto_retry_start";
67
77
  attempt: number;
@@ -473,12 +483,17 @@ export declare class AgentSession {
473
483
  * Saves to settings.
474
484
  */
475
485
  setFollowUpMode(mode: "all" | "one-at-a-time"): void;
486
+ private _applyContextVerbatimCompaction;
487
+ /**
488
+ * Manually compact the session context using deletion-only verbatim context compaction.
489
+ * Aborts current agent operation first. Custom summary instructions are not accepted.
490
+ */
491
+ compact(customInstructions?: string): Promise<ContextCompactionResult>;
476
492
  /**
477
- * Manually compact the session context.
478
- * Aborts current agent operation first.
479
- * @param customInstructions Optional instructions for the compaction summary
493
+ * Manually compact the session context by applying validated logical deletions.
494
+ * Retained transcript entries/content blocks stay verbatim; no user prompt text is accepted.
480
495
  */
481
- compact(customInstructions?: string): Promise<CompactionResult>;
496
+ contextCompact(): Promise<ContextCompactionResult>;
482
497
  /**
483
498
  * Cancel in-progress compaction (manual or auto).
484
499
  */
@@ -488,6 +503,18 @@ export declare class AgentSession {
488
503
  */
489
504
  abortBranchSummary(): void;
490
505
  private _checkCompaction;
506
+ /**
507
+ * Internal: remove the trailing overflow error from retry context if it is still present.
508
+ */
509
+ private _dropTrailingOverflowAssistantErrorIfPresent;
510
+ /**
511
+ * Internal: schedule a live post-event continuation probe after compaction_end listeners can flush queues.
512
+ */
513
+ private _schedulePostAutoCompactionContinuationProbe;
514
+ /**
515
+ * Internal: resume generation after successful auto-compaction only when active work remains.
516
+ */
517
+ private _resumeAfterAutoCompaction;
491
518
  private _runAutoCompaction;
492
519
  /**
493
520
  * Toggle auto-compaction setting.