@bastani/atomic 0.8.26-alpha.1 → 0.8.26-alpha.11

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 (308) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +5 -5
  3. package/dist/builtin/intercom/CHANGELOG.md +60 -0
  4. package/dist/builtin/intercom/package.json +2 -2
  5. package/dist/builtin/mcp/CHANGELOG.md +60 -0
  6. package/dist/builtin/mcp/package.json +3 -3
  7. package/dist/builtin/subagents/CHANGELOG.md +61 -0
  8. package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
  9. package/dist/builtin/subagents/agents/codebase-locator.md +1 -1
  10. package/dist/builtin/subagents/agents/codebase-online-researcher.md +9 -9
  11. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +1 -1
  12. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
  13. package/dist/builtin/subagents/agents/codebase-research-locator.md +1 -1
  14. package/dist/builtin/subagents/agents/debugger.md +6 -6
  15. package/dist/builtin/subagents/package.json +4 -4
  16. package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +1 -1
  17. package/dist/builtin/subagents/skills/browser/EXAMPLES.md +151 -0
  18. package/dist/builtin/subagents/skills/browser/LICENSE.txt +21 -0
  19. package/dist/builtin/subagents/skills/browser/REFERENCE.md +451 -0
  20. package/dist/builtin/subagents/skills/browser/SKILL.md +170 -0
  21. package/dist/builtin/subagents/skills/subagent/SKILL.md +4 -4
  22. package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +55 -12
  23. package/dist/builtin/subagents/src/runs/foreground/execution.ts +71 -12
  24. package/dist/builtin/subagents/src/runs/shared/acceptance.ts +2 -1
  25. package/dist/builtin/subagents/src/runs/shared/final-drain.ts +34 -0
  26. package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +416 -7
  27. package/dist/builtin/subagents/src/runs/shared/worktree.ts +2 -2
  28. package/dist/builtin/web-access/CHANGELOG.md +60 -0
  29. package/dist/builtin/web-access/package.json +2 -2
  30. package/dist/builtin/workflows/CHANGELOG.md +72 -0
  31. package/dist/builtin/workflows/README.md +10 -8
  32. package/dist/builtin/workflows/builtin/deep-research-codebase.ts +11 -8
  33. package/dist/builtin/workflows/builtin/goal.ts +137 -109
  34. package/dist/builtin/workflows/builtin/index.d.ts +2 -0
  35. package/dist/builtin/workflows/builtin/open-claude-design.ts +228 -151
  36. package/dist/builtin/workflows/builtin/ralph.d.ts +2 -0
  37. package/dist/builtin/workflows/builtin/ralph.ts +452 -279
  38. package/dist/builtin/workflows/package.json +2 -2
  39. package/dist/builtin/workflows/skills/create-spec/SKILL.md +14 -0
  40. package/dist/builtin/workflows/skills/research-codebase/SKILL.md +29 -10
  41. package/dist/builtin/workflows/src/extension/index.ts +10 -2
  42. package/dist/builtin/workflows/src/extension/runtime.ts +35 -3
  43. package/dist/builtin/workflows/src/extension/wiring.ts +13 -1
  44. package/dist/builtin/workflows/src/runs/background/status.ts +52 -6
  45. package/dist/builtin/workflows/src/runs/foreground/executor.ts +453 -21
  46. package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +77 -11
  47. package/dist/builtin/workflows/src/runs/shared/model-fallback.ts +402 -8
  48. package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -2
  49. package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +2 -2
  50. package/dist/builtin/workflows/src/shared/persistence-restore.ts +182 -6
  51. package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +76 -6
  52. package/dist/builtin/workflows/src/shared/stage-prompt.ts +33 -2
  53. package/dist/builtin/workflows/src/shared/store-types.ts +31 -0
  54. package/dist/builtin/workflows/src/shared/store.ts +160 -18
  55. package/dist/builtin/workflows/src/shared/types.ts +3 -3
  56. package/dist/builtin/workflows/src/shared/workflow-failures.ts +758 -132
  57. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +39 -3
  58. package/dist/builtin/workflows/src/tui/store-widget-installer.ts +74 -74
  59. package/dist/core/agent-session.d.ts +33 -6
  60. package/dist/core/agent-session.d.ts.map +1 -1
  61. package/dist/core/agent-session.js +157 -182
  62. package/dist/core/agent-session.js.map +1 -1
  63. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  64. package/dist/core/atomic-guide-command.js +11 -9
  65. package/dist/core/atomic-guide-command.js.map +1 -1
  66. package/dist/core/compaction/branch-summarization.d.ts +1 -1
  67. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  68. package/dist/core/compaction/branch-summarization.js +6 -3
  69. package/dist/core/compaction/branch-summarization.js.map +1 -1
  70. package/dist/core/compaction/compaction.d.ts.map +1 -1
  71. package/dist/core/compaction/compaction.js +23 -10
  72. package/dist/core/compaction/compaction.js.map +1 -1
  73. package/dist/core/compaction/context-compaction.d.ts +175 -0
  74. package/dist/core/compaction/context-compaction.d.ts.map +1 -0
  75. package/dist/core/compaction/context-compaction.js +1636 -0
  76. package/dist/core/compaction/context-compaction.js.map +1 -0
  77. package/dist/core/compaction/index.d.ts +1 -0
  78. package/dist/core/compaction/index.d.ts.map +1 -1
  79. package/dist/core/compaction/index.js +1 -0
  80. package/dist/core/compaction/index.js.map +1 -1
  81. package/dist/core/extensions/types.d.ts +3 -2
  82. package/dist/core/extensions/types.d.ts.map +1 -1
  83. package/dist/core/extensions/types.js.map +1 -1
  84. package/dist/core/footer-data-provider.d.ts.map +1 -1
  85. package/dist/core/footer-data-provider.js +3 -0
  86. package/dist/core/footer-data-provider.js.map +1 -1
  87. package/dist/core/index.d.ts +1 -1
  88. package/dist/core/index.d.ts.map +1 -1
  89. package/dist/core/index.js.map +1 -1
  90. package/dist/core/package-manager.d.ts.map +1 -1
  91. package/dist/core/package-manager.js +14 -7
  92. package/dist/core/package-manager.js.map +1 -1
  93. package/dist/core/session-manager.d.ts +41 -1
  94. package/dist/core/session-manager.d.ts.map +1 -1
  95. package/dist/core/session-manager.js +146 -7
  96. package/dist/core/session-manager.js.map +1 -1
  97. package/dist/core/slash-commands.d.ts.map +1 -1
  98. package/dist/core/slash-commands.js +1 -1
  99. package/dist/core/slash-commands.js.map +1 -1
  100. package/dist/core/tools/ask-user-question/tool/format-answer.d.ts +5 -5
  101. package/dist/core/tools/ask-user-question/tool/format-answer.d.ts.map +1 -1
  102. package/dist/core/tools/ask-user-question/tool/format-answer.js +5 -5
  103. package/dist/core/tools/ask-user-question/tool/format-answer.js.map +1 -1
  104. package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts +16 -3
  105. package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts.map +1 -1
  106. package/dist/core/tools/ask-user-question/tool/response-envelope.js +21 -3
  107. package/dist/core/tools/ask-user-question/tool/response-envelope.js.map +1 -1
  108. package/dist/index.d.ts +4 -3
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +3 -2
  111. package/dist/index.js.map +1 -1
  112. package/dist/modes/index.d.ts +1 -1
  113. package/dist/modes/index.d.ts.map +1 -1
  114. package/dist/modes/index.js.map +1 -1
  115. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  116. package/dist/modes/interactive/components/chat-session-host.js +17 -0
  117. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  118. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts +17 -0
  119. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts.map +1 -0
  120. package/dist/modes/interactive/components/context-compaction-summary-message.js +83 -0
  121. package/dist/modes/interactive/components/context-compaction-summary-message.js.map +1 -0
  122. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  123. package/dist/modes/interactive/components/footer.js +4 -1
  124. package/dist/modes/interactive/components/footer.js.map +1 -1
  125. package/dist/modes/interactive/components/index.d.ts +1 -0
  126. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  127. package/dist/modes/interactive/components/index.js +1 -0
  128. package/dist/modes/interactive/components/index.js.map +1 -1
  129. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  130. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  131. package/dist/modes/interactive/interactive-mode.js +75 -10
  132. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  133. package/dist/modes/rpc/rpc-client.d.ts +13 -8
  134. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  135. package/dist/modes/rpc/rpc-client.js +8 -1
  136. package/dist/modes/rpc/rpc-client.js.map +1 -1
  137. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  138. package/dist/modes/rpc/rpc-mode.js +4 -0
  139. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  140. package/dist/modes/rpc/rpc-types.d.ts +14 -3
  141. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  142. package/dist/modes/rpc/rpc-types.js.map +1 -1
  143. package/dist/utils/git-env.d.ts +10 -0
  144. package/dist/utils/git-env.d.ts.map +1 -0
  145. package/dist/utils/git-env.js +33 -0
  146. package/dist/utils/git-env.js.map +1 -0
  147. package/docs/compaction.md +185 -50
  148. package/docs/custom-provider.md +11 -9
  149. package/docs/extensions.md +46 -42
  150. package/docs/index.md +13 -6
  151. package/docs/json.md +15 -12
  152. package/docs/packages.md +2 -0
  153. package/docs/providers.md +4 -1
  154. package/docs/quickstart.md +18 -11
  155. package/docs/rpc.md +38 -23
  156. package/docs/sdk.md +17 -8
  157. package/docs/session-format.md +26 -13
  158. package/docs/sessions.md +3 -3
  159. package/docs/settings.md +2 -2
  160. package/docs/skills.md +1 -15
  161. package/docs/termux.md +9 -10
  162. package/docs/themes.md +2 -2
  163. package/docs/tmux.md +3 -3
  164. package/docs/tui.md +19 -32
  165. package/docs/usage.md +2 -2
  166. package/docs/workflows.md +60 -16
  167. package/package.json +6 -12
  168. package/dist/builtin/subagents/skills/browser-use/SKILL.md +0 -234
  169. package/dist/builtin/subagents/skills/browser-use/references/cdp-python.md +0 -76
  170. package/dist/builtin/subagents/skills/browser-use/references/multi-session.md +0 -92
  171. package/node_modules/@earendil-works/pi-tui/README.md +0 -779
  172. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +0 -54
  173. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +0 -1
  174. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +0 -632
  175. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +0 -1
  176. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +0 -22
  177. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +0 -1
  178. package/node_modules/@earendil-works/pi-tui/dist/components/box.js +0 -104
  179. package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +0 -1
  180. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts +0 -22
  181. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts.map +0 -1
  182. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js +0 -35
  183. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js.map +0 -1
  184. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +0 -249
  185. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +0 -1
  186. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +0 -1857
  187. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +0 -1
  188. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts +0 -28
  189. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +0 -1
  190. package/node_modules/@earendil-works/pi-tui/dist/components/image.js +0 -89
  191. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +0 -1
  192. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts +0 -37
  193. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +0 -1
  194. package/node_modules/@earendil-works/pi-tui/dist/components/input.js +0 -378
  195. package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +0 -1
  196. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +0 -31
  197. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts.map +0 -1
  198. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js +0 -69
  199. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js.map +0 -1
  200. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +0 -96
  201. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +0 -1
  202. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +0 -644
  203. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +0 -1
  204. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +0 -50
  205. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +0 -1
  206. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +0 -159
  207. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +0 -1
  208. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +0 -50
  209. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +0 -1
  210. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +0 -185
  211. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +0 -1
  212. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts +0 -12
  213. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts.map +0 -1
  214. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js +0 -23
  215. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js.map +0 -1
  216. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +0 -19
  217. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +0 -1
  218. package/node_modules/@earendil-works/pi-tui/dist/components/text.js +0 -89
  219. package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +0 -1
  220. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts +0 -13
  221. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts.map +0 -1
  222. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js +0 -51
  223. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js.map +0 -1
  224. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts +0 -39
  225. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts.map +0 -1
  226. package/node_modules/@earendil-works/pi-tui/dist/editor-component.js +0 -2
  227. package/node_modules/@earendil-works/pi-tui/dist/editor-component.js.map +0 -1
  228. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts +0 -16
  229. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts.map +0 -1
  230. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +0 -110
  231. package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js.map +0 -1
  232. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +0 -23
  233. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +0 -1
  234. package/node_modules/@earendil-works/pi-tui/dist/index.js +0 -32
  235. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +0 -1
  236. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +0 -193
  237. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +0 -1
  238. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +0 -174
  239. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +0 -1
  240. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts +0 -184
  241. package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +0 -1
  242. package/node_modules/@earendil-works/pi-tui/dist/keys.js +0 -1173
  243. package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +0 -1
  244. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts +0 -28
  245. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts.map +0 -1
  246. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js +0 -44
  247. package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js.map +0 -1
  248. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts +0 -3
  249. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts.map +0 -1
  250. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js +0 -53
  251. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js.map +0 -1
  252. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +0 -50
  253. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +0 -1
  254. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +0 -361
  255. package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +0 -1
  256. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +0 -90
  257. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +0 -1
  258. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +0 -366
  259. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +0 -1
  260. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +0 -113
  261. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +0 -1
  262. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +0 -472
  263. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +0 -1
  264. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +0 -227
  265. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +0 -1
  266. package/node_modules/@earendil-works/pi-tui/dist/tui.js +0 -1106
  267. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +0 -1
  268. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts +0 -17
  269. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts.map +0 -1
  270. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js +0 -25
  271. package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js.map +0 -1
  272. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +0 -84
  273. package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +0 -1
  274. package/node_modules/@earendil-works/pi-tui/dist/utils.js +0 -1029
  275. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +0 -1
  276. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts +0 -25
  277. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts.map +0 -1
  278. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js +0 -96
  279. package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js.map +0 -1
  280. package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
  281. package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
  282. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  283. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  284. package/node_modules/@earendil-works/pi-tui/package.json +0 -47
  285. package/node_modules/get-east-asian-width/index.d.ts +0 -60
  286. package/node_modules/get-east-asian-width/index.js +0 -30
  287. package/node_modules/get-east-asian-width/license +0 -9
  288. package/node_modules/get-east-asian-width/lookup-data.js +0 -21
  289. package/node_modules/get-east-asian-width/lookup.js +0 -138
  290. package/node_modules/get-east-asian-width/package.json +0 -71
  291. package/node_modules/get-east-asian-width/readme.md +0 -65
  292. package/node_modules/get-east-asian-width/utilities.js +0 -24
  293. package/node_modules/marked/LICENSE.md +0 -44
  294. package/node_modules/marked/README.md +0 -106
  295. package/node_modules/marked/bin/main.js +0 -282
  296. package/node_modules/marked/bin/marked.js +0 -15
  297. package/node_modules/marked/lib/marked.cjs +0 -2211
  298. package/node_modules/marked/lib/marked.cjs.map +0 -7
  299. package/node_modules/marked/lib/marked.d.cts +0 -728
  300. package/node_modules/marked/lib/marked.d.ts +0 -728
  301. package/node_modules/marked/lib/marked.esm.js +0 -2189
  302. package/node_modules/marked/lib/marked.esm.js.map +0 -7
  303. package/node_modules/marked/lib/marked.umd.js +0 -2213
  304. package/node_modules/marked/lib/marked.umd.js.map +0 -7
  305. package/node_modules/marked/man/marked.1 +0 -111
  306. package/node_modules/marked/man/marked.1.md +0 -92
  307. package/node_modules/marked/marked.min.js +0 -69
  308. package/node_modules/marked/package.json +0 -111
@@ -0,0 +1,170 @@
1
+ ---
2
+ name: browser
3
+ description: Automate web browser interactions using natural language via CLI commands. Use when the user asks to browse websites, navigate web pages, extract data from websites, take screenshots, fill forms, click buttons, or interact with web applications. Supports remote Browserbase sessions with Browserbase Identity, Verified browsers, automatic CAPTCHA solving, and residential proxies — ideal for protected websites and JavaScript-heavy pages.
4
+ compatibility: "Requires the browse CLI (`npm install -g browse`). Remote Browserbase sessions need `BROWSERBASE_API_KEY`. Local mode uses Chrome/Chromium on your machine."
5
+ license: MIT
6
+ allowed-tools: Bash
7
+ metadata:
8
+ openclaw:
9
+ requires:
10
+ bins:
11
+ - browse
12
+ install:
13
+ - kind: node
14
+ package: "browse"
15
+ bins: [browse]
16
+ homepage: https://github.com/browserbase/skills
17
+ ---
18
+
19
+ # Browser Automation
20
+
21
+ Automate browser interactions using the browse CLI with Claude.
22
+
23
+ ## Setup check
24
+
25
+ Before running any browser commands, verify the CLI is available:
26
+
27
+ ```bash
28
+ which browse || npm install -g browse
29
+ ```
30
+
31
+ ## Environment Selection (Local vs Remote)
32
+
33
+ The CLI supports explicit per-command environment flags. If you do nothing, the next session defaults to Browserbase when `BROWSERBASE_API_KEY` is set and to local otherwise.
34
+
35
+ ### Local mode
36
+ - `browse open <url> --local` starts a clean isolated local browser
37
+ - `browse open <url> --auto-connect` attaches to an already-running debuggable Chrome; use `--local` when no debuggable Chrome is available
38
+ - `browse open <url> --cdp <port|url>` attaches to a specific CDP target
39
+ - Best for: development, localhost, trusted sites, and reproducible runs
40
+
41
+ ### Remote mode (Browserbase)
42
+ - `browse open <url> --remote` starts a Browserbase session
43
+ - Without a local flag, Browserbase is also the default when `BROWSERBASE_API_KEY` is set
44
+ - Provides: Browserbase Identity, Verified browsers, automatic CAPTCHA solving, residential proxies, session persistence
45
+ - **Use remote mode when:** the target site has bot detection, CAPTCHAs, IP rate limiting, Cloudflare protection, or requires geo-specific access
46
+ - Get credentials at https://browserbase.com/settings
47
+
48
+ ### When to choose which
49
+ - **Repeatable local testing / clean state**: `browse open <url> --local`
50
+ - **Reuse your local login/cookies**: `browse open <url> --auto-connect`
51
+ - **Simple browsing** (docs, wikis, public APIs): local mode is fine
52
+ - **Protected sites** (login walls, CAPTCHAs, anti-scraping): use remote mode
53
+ - **If local mode fails** with bot detection or access denied: switch to remote mode
54
+
55
+ ## Commands
56
+
57
+ Most driver commands work across local, remote, and CDP sessions after the daemon starts.
58
+
59
+ ### Navigation
60
+ ```bash
61
+ browse open <url> # Go to URL
62
+ browse open <url> --local # Go to URL in a clean local browser
63
+ browse open <url> --remote # Go to URL in a Browserbase session
64
+ browse reload # Reload current page
65
+ browse back # Go back in history
66
+ browse forward # Go forward in history
67
+ ```
68
+
69
+ ### Page state (prefer snapshot over screenshot)
70
+ ```bash
71
+ browse snapshot # Get accessibility tree with element refs (fast, structured)
72
+ browse screenshot --path <path> # Take visual screenshot (slow, uses vision tokens)
73
+ browse get url # Get current URL
74
+ browse get title # Get page title
75
+ browse get text <selector> # Get text content (use "body" for all text)
76
+ browse get html <selector> # Get HTML content of element
77
+ browse get value <selector> # Get form field value
78
+ ```
79
+
80
+ Use `browse snapshot` as your default for understanding page state — it returns the accessibility tree with element refs you can use to interact. Only use `browse screenshot` when you need visual context (layout, images, debugging).
81
+
82
+ ### Interaction
83
+ ```bash
84
+ browse click <ref> # Click element by ref from snapshot (e.g., @0-5)
85
+ browse type <text> # Type text into focused element
86
+ browse fill <selector> <value> # Fill input; add --press-enter if Enter is needed
87
+ browse select <selector> <values...> # Select dropdown option(s)
88
+ browse press <key> # Press key (Enter, Tab, Escape, Cmd+A, etc.)
89
+ browse mouse drag <fromX> <fromY> <toX> <toY> # Drag from one point to another
90
+ browse mouse scroll <x> <y> <deltaX> <deltaY> # Scroll at coordinates
91
+ browse highlight <selector> # Highlight element on page
92
+ browse is visible <selector> # Check if element is visible
93
+ browse is checked <selector> # Check if element is checked
94
+ browse wait <type> [arg] # Wait for: load, selector, timeout
95
+ ```
96
+
97
+ ### Session management
98
+ ```bash
99
+ browse stop # Stop the browser daemon
100
+ browse status # Check daemon status and resolved mode
101
+ browse tab list # List all open tabs
102
+ browse tab switch <index-or-target-id> # Switch to tab by index or target ID
103
+ browse tab close [index-or-target-id] # Close tab
104
+ ```
105
+
106
+ ### Typical workflow
107
+ If the environment matters, put `--local`, `--remote`, `--auto-connect`, or `--cdp <port|url>` on the first browser command.
108
+
109
+ 1. `browse open <url> --local` or `browse open <url> --remote` — navigate to the page
110
+ 2. `browse snapshot` — read the accessibility tree to understand page structure and get element refs
111
+ 3. `browse click <ref>` / `browse type <text>` / `browse fill <selector> <value>` — interact using refs from snapshot
112
+ 4. `browse snapshot` — confirm the action worked
113
+ 5. Repeat 3-4 as needed
114
+ 6. `browse stop` — close the browser when done
115
+
116
+ ## Quick Example
117
+
118
+ ```bash
119
+ browse open https://example.com
120
+ browse snapshot # see page structure + element refs
121
+ browse click @0-5 # click element with ref 0-5
122
+ browse get title
123
+ browse stop
124
+ ```
125
+
126
+ ## Mode Comparison
127
+
128
+ | Feature | Local | Browserbase |
129
+ |---------|-------|-------------|
130
+ | Speed | Faster | Slightly slower |
131
+ | Setup | Chrome required | API key required |
132
+ | Reuse existing local cookies | With `browse open <url> --auto-connect` | N/A |
133
+ | Verified browser | No | Yes (Browserbase Verified browser via Identity) |
134
+ | CAPTCHA solving | No | Yes (automatic reCAPTCHA/hCaptcha) |
135
+ | Residential proxies | No | Yes (201 countries, geo-targeting) |
136
+ | Session persistence | No | Yes (cookies/auth persist via contexts) |
137
+ | Best for | Development/simple pages | Protected sites, Browserbase Identity + Verified access, production scraping |
138
+
139
+ ## Best Practices
140
+
141
+ 1. **Choose the local strategy deliberately**: use `browse open <url> --local` for clean state, `browse open <url> --auto-connect` for existing local credentials, and `browse open <url> --remote` for protected sites
142
+ 2. **Always `browse open` first** before interacting
143
+ 3. **Use `browse snapshot`** to check page state — it's fast and gives you element refs
144
+ 4. **Only screenshot when visual context is needed** (layout checks, images, debugging)
145
+ 5. **Use refs from snapshot** to click/interact — e.g., `browse click @0-5`
146
+ 6. **`browse stop`** when done to clean up the browser session and clear the env override
147
+
148
+ ## Troubleshooting
149
+
150
+ - **"No active page"**: Run `browse stop`, then check `browse status`. If it still says running, kill the zombie daemon with `pkill -f "browse.*daemon"`, then retry `browse open`
151
+ - **Chrome not found**: Install Chrome, use `browse open <url> --auto-connect` if you already have a debuggable Chrome running, or switch to `browse open <url> --remote`
152
+ - **Action fails**: Run `browse snapshot` to see available elements and their refs
153
+ - **Browserbase fails**: Verify API key is set
154
+
155
+ ## Switching to Remote Mode
156
+
157
+ Switch to remote when you detect: CAPTCHAs (reCAPTCHA, hCaptcha, Turnstile), bot detection pages ("Checking your browser..."), HTTP 403/429, empty pages on sites that should have content, or the user asks for it.
158
+
159
+ Don't switch for simple sites (docs, wikis, public APIs, localhost).
160
+
161
+ ```bash
162
+ browse open <url> --local # clean isolated local browser
163
+ browse open <url> --auto-connect # attach to existing debuggable Chrome
164
+ browse open <url> --remote # Browserbase session
165
+ ```
166
+
167
+ Mode flags are applied when a session starts. After `browse stop`, the next start falls back to env-var-based auto detection. Use `browse status` to inspect the resolved mode and target while the daemon is running.
168
+
169
+ For detailed examples, see [EXAMPLES.md](EXAMPLES.md).
170
+ For API reference, see [REFERENCE.md](REFERENCE.md).
@@ -20,7 +20,7 @@ Use this skill when the parent orchestrator needs to launch a specialized subage
20
20
  - **Parallel codebase discovery**: combine `codebase-locator`, `codebase-analyzer`, and `codebase-pattern-finder` to map where code lives, how it works, and what existing conventions look like — concurrently, with fresh context per child.
21
21
  - **Local research mining**: pair `codebase-research-locator` with `codebase-research-analyzer` to surface prior decisions in `research/` and `specs/` and extract what still applies.
22
22
  - **External research**: use `codebase-online-researcher` for authoritative web sources, with persisted findings in `research/web/`.
23
- - **Debug and fix**: use `debugger` to reproduce, diagnose, and patch failing behavior with `tdd` and `browser-use` support.
23
+ - **Debug and fix**: use `debugger` to reproduce, diagnose, and patch failing behavior with `tdd` and `browser` support.
24
24
  - **Refinement**: use `code-simplifier` to clean up recently changed code without altering behavior.
25
25
  - **Adversarial review**: compose read-only specialists (`codebase-analyzer`, `codebase-pattern-finder`, `debugger` in inspect-only mode, `codebase-online-researcher`) into a parallel review pass — there is no generic `reviewer` agent.
26
26
  - **Long-running work**: launch async/background runs and inspect them later.
@@ -158,9 +158,9 @@ Builtin agents load at the lowest priority. Project agents override user agents,
158
158
  | `codebase-pattern-finder` | Find similar implementations or conventions | `openai/gpt-5.4-mini` | low | read, grep, find, ls, bash | Read-only. Returns code snippets with `file:line` references. |
159
159
  | `codebase-research-locator` | Discover prior `research/` and `specs/` docs | `openai/gpt-5.4-mini` | low | read, grep, find, ls, bash | Read-only. Sorts by date, tiers by recency, flags supersession. |
160
160
  | `codebase-research-analyzer` | Extract decisions and constraints from prior docs | `openai/gpt-5.5` | low | read, grep, find, ls, bash | Read-only. Filters aggressively for what still applies today. |
161
- | `codebase-online-researcher` | Web research with authoritative sources | `openai/gpt-5.5` | low | read, grep, find, ls, bash, write, web_search, fetch_content, get_search_content | Has the `browser-use` skill. Persists keepers to `research/web/`. |
161
+ | `codebase-online-researcher` | Web research with authoritative sources | `openai/gpt-5.5` | low | read, grep, find, ls, bash, write, web_search, fetch_content, get_search_content | Has the `browser` skill. Persists keepers to `research/web/`. |
162
162
  | `code-simplifier` | Clean up recently changed code without changing behavior | `openai/gpt-5.5` | low | read, edit, write, grep, find, ls, bash | **Writer.** Scopes to recently modified code by default; preserves all observable behavior. |
163
- | `debugger` | Reproduce, diagnose, and fix failing behavior | `openai/gpt-5.5` | high | read, edit, write, grep, find, ls, bash, web_search, fetch_content, get_search_content | **Writer.** Has the `tdd` and `browser-use` skills. Inspect-only mode requires an explicit instruction. |
163
+ | `debugger` | Reproduce, diagnose, and fix failing behavior | `openai/gpt-5.5` | high | read, edit, write, grep, find, ls, bash, web_search, fetch_content, get_search_content | **Writer.** Has the `tdd` and `browser` skills. Inspect-only mode requires an explicit instruction. |
164
164
 
165
165
  Each builtin declares an explicit `model` and `fallbackModels` chain (typically `github-copilot/<same>`, then `anthropic/claude-opus-4-8`, then `github-copilot/claude-opus-4.7`). The current user-selected model is automatically appended as the last fallback and de-duplicated. Override per run with inline config:
166
166
 
@@ -186,7 +186,7 @@ A strong subagent prompt usually includes:
186
186
  - **Output**: the expected summary shape, artifact path, or finding format.
187
187
  - **Stop rules**: when to stop after enough evidence, and when not to keep searching.
188
188
 
189
- Avoid carrying over old prompt habits that over-specify every step. Use `must`, `always`, and `never` for real invariants; for judgment calls, give decision rules. For example, tell `codebase-analyzer` to trace the staged diff directly and report only evidence-backed findings, rather than prescribing every file or command. Tell `codebase-online-researcher` the retrieval budget: start with broad targeted searches, fetch the strongest sources via `fetch_content`, fall back to `browser-use` only when JS execution is required, and stop when the question is answered.
189
+ Avoid carrying over old prompt habits that over-specify every step. Use `must`, `always`, and `never` for real invariants; for judgment calls, give decision rules. For example, tell `codebase-analyzer` to trace the staged diff directly and report only evidence-backed findings, rather than prescribing every file or command. Tell `codebase-online-researcher` the retrieval budget: start with broad targeted searches, fetch the strongest sources via `fetch_content`, fall back to `browser` only when JS execution is required, and stop when the question is answered.
190
190
 
191
191
  For implementation handoffs to `debugger` or `code-simplifier`, name the approved scope and success criteria more clearly than the process. Good prompts say what to change, what not to change, where the evidence lives, how to validate, and when to escalate. They should not ask the child to create another subagent plan or continue the parent conversation.
192
192
 
@@ -48,7 +48,12 @@ import { outputEntryFromAsyncResult, resolveOutputReferences } from "../shared/c
48
48
  import { createStructuredOutputRuntime, readStructuredOutput } from "../shared/structured-output.ts";
49
49
  import { collectDynamicResults, DynamicFanoutError, materializeDynamicParallelStep, validateDynamicCollection } from "../shared/dynamic-fanout.ts";
50
50
  import { nestedSummaryFromAsyncStatus, writeNestedEvent } from "../shared/nested-events.ts";
51
- import { formatModelAttemptNote, isRetryableModelFailure } from "../shared/model-fallback.ts";
51
+ import { formatModelAttemptNote, isRetryableModelFailure, modelFailureMessage } from "../shared/model-fallback.ts";
52
+ import {
53
+ assistantStopReason,
54
+ isAssistantFailureStopReason,
55
+ shouldStartSubagentFinalDrain,
56
+ } from "../shared/final-drain.ts";
52
57
  import { attachPostExitStdioGuard, trySignalChild } from "../../shared/post-exit-stdio-guard.ts";
53
58
  import { detectSubagentError, extractTextFromContent, extractToolArgsPreview, getFinalOutput } from "../../shared/utils.ts";
54
59
  import { evaluateCompletionMutationGuard } from "../shared/completion-guard.ts";
@@ -230,6 +235,7 @@ interface RunPiStreamingResult {
230
235
  finalOutput: string;
231
236
  interrupted?: boolean;
232
237
  observedMutationAttempt?: boolean;
238
+ modelFailureSignal?: unknown;
233
239
  }
234
240
 
235
241
  function runPiStreaming(
@@ -270,6 +276,7 @@ function runPiStreaming(
270
276
  let model: string | undefined;
271
277
  let error: string | undefined;
272
278
  let assistantError: string | undefined;
279
+ let assistantFailureSignal: unknown;
273
280
  let interrupted = false;
274
281
  let observedMutationAttempt = false;
275
282
  const rawStdoutLines: string[] = [];
@@ -330,7 +337,6 @@ function runPiStreaming(
330
337
 
331
338
  if (event.type !== "message_end" || event.message.role !== "assistant") return;
332
339
  if (event.message.model) model = event.message.model;
333
- if (event.message.errorMessage) assistantError = event.message.errorMessage;
334
340
  const eventUsage = event.message.usage;
335
341
  if (eventUsage) {
336
342
  usage.turns++;
@@ -340,12 +346,21 @@ function runPiStreaming(
340
346
  usage.cacheWrite += eventUsage.cacheWrite ?? 0;
341
347
  usage.cost += eventUsage.cost?.total ?? 0;
342
348
  }
343
- const stopReason = (event.message as { stopReason?: string }).stopReason;
344
- const hasToolCall = Array.isArray(event.message.content)
345
- && event.message.content.some((part) => (part as { type?: string }).type === "toolCall");
346
- if (stopReason === "stop" && !hasToolCall) {
347
- if (!event.message.errorMessage && extractTextFromContent(event.message.content).trim()) assistantError = undefined;
348
- cleanTerminalAssistantStopReceived ||= !event.message.errorMessage;
349
+ const stopReason = assistantStopReason(event.message);
350
+ if (event.message.errorMessage) {
351
+ assistantError = event.message.errorMessage;
352
+ assistantFailureSignal = event.message;
353
+ }
354
+ if (isAssistantFailureStopReason(stopReason)) {
355
+ assistantError = modelFailureMessage(event.message);
356
+ assistantFailureSignal = event.message;
357
+ }
358
+ if (shouldStartSubagentFinalDrain(event.message)) {
359
+ if (extractTextFromContent(event.message.content).trim()) {
360
+ assistantError = undefined;
361
+ assistantFailureSignal = undefined;
362
+ }
363
+ cleanTerminalAssistantStopReceived = true;
349
364
  startFinalDrain();
350
365
  }
351
366
  }
@@ -448,6 +463,9 @@ function runPiStreaming(
448
463
  finalOutput,
449
464
  interrupted,
450
465
  observedMutationAttempt,
466
+ ...(assistantFailureSignal !== undefined && finalError === assistantError
467
+ ? { modelFailureSignal: assistantFailureSignal }
468
+ : {}),
451
469
  });
452
470
  });
453
471
 
@@ -459,7 +477,20 @@ function runPiStreaming(
459
477
  outputStream.end();
460
478
  const finalOutput = getFinalOutput(messages) || rawStdoutLines.join("\n").trim();
461
479
  const spawnErrorMessage = spawnError instanceof Error ? spawnError.message : String(spawnError);
462
- resolve({ stderr, exitCode: 1, messages, usage, model, error: error ?? assistantError ?? spawnErrorMessage, finalOutput, observedMutationAttempt });
480
+ const finalError = error ?? assistantError ?? spawnErrorMessage;
481
+ resolve({
482
+ stderr,
483
+ exitCode: 1,
484
+ messages,
485
+ usage,
486
+ model,
487
+ error: finalError,
488
+ finalOutput,
489
+ observedMutationAttempt,
490
+ ...(assistantFailureSignal !== undefined && finalError === assistantError
491
+ ? { modelFailureSignal: assistantFailureSignal }
492
+ : {}),
493
+ });
463
494
  });
464
495
  });
465
496
  }
@@ -650,6 +681,7 @@ async function runSingleStep(
650
681
  const attemptedModels: string[] = [];
651
682
  const modelAttempts: ModelAttempt[] = [];
652
683
  const attemptNotes: string[] = [];
684
+ const pendingAttemptNotes: string[] = [];
653
685
  const eventsPath = path.join(path.dirname(ctx.outputFile), "events.jsonl");
654
686
  let finalResult: RunPiStreamingResult | undefined;
655
687
  let finalFastMode: boolean | undefined;
@@ -768,9 +800,20 @@ async function runSingleStep(
768
800
  finalFastMode = attemptFastMode;
769
801
  finalOutputSnapshot = outputSnapshot;
770
802
  finalResult = { ...run, exitCode: effectiveExitCode, model: candidate ?? run.model, error, structuredOutput } as RunPiStreamingResult & { structuredOutput?: unknown };
771
- if (attempt.success || completionGuardTriggered) break;
772
- if (!isRetryableModelFailure(error) || index === candidates.length - 1) break;
773
- attemptNotes.push(formatModelAttemptNote(attempt, candidates[index + 1]));
803
+ if (attempt.success) break;
804
+ const retrySignal = run.modelFailureSignal ?? error;
805
+ if (
806
+ !completionGuardTriggered
807
+ && structuredError === undefined
808
+ && hiddenError?.hasError !== true
809
+ && isRetryableModelFailure(retrySignal)
810
+ && index < candidates.length - 1
811
+ ) {
812
+ pendingAttemptNotes.push(formatModelAttemptNote(attempt, candidates[index + 1]));
813
+ continue;
814
+ }
815
+ attemptNotes.push(...pendingAttemptNotes);
816
+ break;
774
817
  }
775
818
 
776
819
  const rawOutput = finalResult?.finalOutput ?? "";
@@ -17,6 +17,7 @@ import {
17
17
  type AgentProgress,
18
18
  type ArtifactPaths,
19
19
  type ControlEvent,
20
+ type Details,
20
21
  type ModelAttempt,
21
22
  type RunSyncOptions,
22
23
  type SingleResult,
@@ -53,7 +54,13 @@ import {
53
54
  buildModelCandidates,
54
55
  formatModelAttemptNote,
55
56
  isRetryableModelFailure,
57
+ modelFailureMessage,
56
58
  } from "../shared/model-fallback.ts";
59
+ import {
60
+ assistantStopReason,
61
+ isAssistantFailureStopReason,
62
+ shouldStartSubagentFinalDrain,
63
+ } from "../shared/final-drain.ts";
57
64
  import {
58
65
  createMutatingFailureState,
59
66
  didMutatingToolFail,
@@ -75,6 +82,7 @@ import { acceptanceFailureMessage, evaluateAcceptance, formatAcceptancePrompt, r
75
82
 
76
83
  const artifactOutputByResult = new WeakMap<SingleResult, string>();
77
84
  const acceptanceOutputByResult = new WeakMap<SingleResult, string>();
85
+ const modelFailureSignalByResult = new WeakMap<SingleResult, unknown>();
78
86
 
79
87
  function emptyUsage(): Usage {
80
88
  return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 };
@@ -139,6 +147,29 @@ function snapshotResult(result: SingleResult, progress: AgentProgress): SingleRe
139
147
  };
140
148
  }
141
149
 
150
+ type RunSyncUpdate = import("@earendil-works/pi-agent-core").AgentToolResult<Details>;
151
+
152
+ function extractUpdateText(update: RunSyncUpdate): string | undefined {
153
+ const text = update.content
154
+ .map((item) => item.type === "text" ? item.text : undefined)
155
+ .filter((item): item is string => Boolean(item?.trim()))
156
+ .join("\n");
157
+ return text || undefined;
158
+ }
159
+
160
+ export function shouldSuppressIntermediateRetryableFailureUpdate(update: RunSyncUpdate): boolean {
161
+ const result = update.details?.results?.[0];
162
+ if (!result) return false;
163
+ const progress = update.details?.progress?.[0];
164
+ const status = result.progress?.status ?? progress?.status;
165
+ if (status !== "failed") return false;
166
+ const failureText = result.error
167
+ ?? result.progress?.error
168
+ ?? progress?.error
169
+ ?? extractUpdateText(update);
170
+ return isRetryableModelFailure(failureText);
171
+ }
172
+
142
173
  async function runSingleAttempt(
143
174
  runtimeCwd: string,
144
175
  agent: AgentConfig,
@@ -269,6 +300,7 @@ async function runSingleAttempt(
269
300
  let detached = false;
270
301
  let intercomStarted = false;
271
302
  let assistantError: string | undefined;
303
+ let assistantFailureSignal: unknown;
272
304
  let removeAbortListener: (() => void) | undefined;
273
305
  let removeInterruptListener: (() => void) | undefined;
274
306
  let activityTimer: NodeJS.Timeout | undefined;
@@ -520,16 +552,25 @@ async function runSingleAttempt(
520
552
  progress.tokens = result.usage.input + result.usage.output;
521
553
  }
522
554
  if (!result.model && evt.message.model) result.model = evt.message.model;
523
- if (evt.message.errorMessage) assistantError = evt.message.errorMessage;
524
555
  const assistantText = extractTextFromContent(evt.message.content);
525
556
  appendRecentOutput(progress, assistantText.split("\n").slice(-10));
526
- // Final assistant message: start the exit drain window.
527
- const stopReason = (evt.message as { stopReason?: string }).stopReason;
528
- const hasToolCall = Array.isArray(evt.message.content)
529
- && evt.message.content.some((part) => (part as { type?: string }).type === "toolCall");
530
- if (stopReason === "stop" && !hasToolCall) {
531
- if (!evt.message.errorMessage && assistantText.trim()) assistantError = undefined;
532
- cleanTerminalAssistantStopReceived ||= !evt.message.errorMessage;
557
+ // Clean final assistant stops start the exit drain window; provider error/aborted
558
+ // stop reasons remain failure evidence so pi-ai can auto-retry before exit.
559
+ const stopReason = assistantStopReason(evt.message);
560
+ if (evt.message.errorMessage) {
561
+ assistantError = evt.message.errorMessage;
562
+ assistantFailureSignal = evt.message;
563
+ }
564
+ if (isAssistantFailureStopReason(stopReason)) {
565
+ assistantError = modelFailureMessage(evt.message);
566
+ assistantFailureSignal = evt.message;
567
+ }
568
+ if (shouldStartSubagentFinalDrain(evt.message)) {
569
+ if (assistantText.trim()) {
570
+ assistantError = undefined;
571
+ assistantFailureSignal = undefined;
572
+ }
573
+ cleanTerminalAssistantStopReceived = true;
533
574
  startFinalDrain();
534
575
  }
535
576
  }
@@ -609,6 +650,9 @@ async function runSingleAttempt(
609
650
  processClosed = true;
610
651
  if (buf.trim()) processLine(buf);
611
652
  if (!result.error && assistantError) result.error = assistantError;
653
+ if (assistantFailureSignal !== undefined && result.error === assistantError) {
654
+ modelFailureSignalByResult.set(result, assistantFailureSignal);
655
+ }
612
656
  const forcedDrainAfterFinalSuccess = forcedTerminationSignal && cleanTerminalAssistantStopReceived && !result.error;
613
657
  if (code !== 0 && stderrBuf.trim() && !result.error && !forcedDrainAfterFinalSuccess) {
614
658
  result.error = stderrBuf.trim();
@@ -875,6 +919,7 @@ export async function runSync(
875
919
  const modelAttempts: ModelAttempt[] = [];
876
920
  const aggregateUsage = emptyUsage();
877
921
  const attemptNotes: string[] = [];
922
+ const pendingAttemptNotes: string[] = [];
878
923
  let totalToolCount = 0;
879
924
  let totalDurationMs = 0;
880
925
 
@@ -897,7 +942,18 @@ export async function runSync(
897
942
  const candidate = modelsToTry[i];
898
943
  if (candidate) attemptedModels.push(candidate);
899
944
  const outputSnapshot = captureSingleOutputSnapshot(options.outputPath);
900
- const result = await runSingleAttempt(runtimeCwd, agent, taskWithAcceptance, candidate, options, {
945
+ let attemptOptions = options;
946
+ if (i < modelsToTry.length - 1 && options.onUpdate) {
947
+ const forwardUpdate = options.onUpdate;
948
+ attemptOptions = {
949
+ ...options,
950
+ onUpdate: (update) => {
951
+ if (shouldSuppressIntermediateRetryableFailureUpdate(update)) return;
952
+ forwardUpdate(update);
953
+ },
954
+ };
955
+ }
956
+ const result = await runSingleAttempt(runtimeCwd, agent, taskWithAcceptance, candidate, attemptOptions, {
901
957
  sessionEnabled,
902
958
  systemPrompt,
903
959
  resolvedSkillNames: resolvedSkills.length > 0 ? resolvedSkills.map((skill) => skill.name) : undefined,
@@ -928,10 +984,13 @@ export async function runSync(
928
984
  if (attemptSucceeded) {
929
985
  break;
930
986
  }
931
- if (!isRetryableModelFailure(result.error) || i === modelsToTry.length - 1) {
932
- break;
987
+ const retrySignal = modelFailureSignalByResult.get(result) ?? result.error;
988
+ if (isRetryableModelFailure(retrySignal) && i < modelsToTry.length - 1) {
989
+ pendingAttemptNotes.push(formatModelAttemptNote(attempt, modelsToTry[i + 1]));
990
+ continue;
933
991
  }
934
- attemptNotes.push(formatModelAttemptNote(attempt, modelsToTry[i + 1]));
992
+ attemptNotes.push(...pendingAttemptNotes);
993
+ break;
935
994
  }
936
995
 
937
996
  const result = lastResult ?? {
@@ -1,6 +1,7 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { spawnSync } from "node:child_process";
3
3
  import * as path from "node:path";
4
+ import { createGitEnvironment } from "@bastani/atomic";
4
5
  import type {
5
6
  AcceptanceConfig,
6
7
  AcceptanceEvidenceKind,
@@ -399,7 +400,7 @@ function reportEvidencePresent(report: AcceptanceReport, kind: AcceptanceEvidenc
399
400
  }
400
401
 
401
402
  function checkNoStagedFiles(cwd: string): AcceptanceRuntimeCheck {
402
- const result = spawnSync("git", ["status", "--short"], { cwd, encoding: "utf-8" });
403
+ const result = spawnSync("git", ["status", "--short"], { cwd, env: createGitEnvironment(), encoding: "utf-8" });
403
404
  if (result.status !== 0) {
404
405
  return { id: "no-staged-files", status: "not-applicable", message: "git status unavailable; no staged-files check skipped" };
405
406
  }
@@ -0,0 +1,34 @@
1
+ export interface SubagentAssistantDrainMessage {
2
+ readonly role?: unknown;
3
+ readonly content?: unknown;
4
+ readonly stopReason?: unknown;
5
+ readonly errorMessage?: unknown;
6
+ }
7
+
8
+ export function assistantStopReason(message: SubagentAssistantDrainMessage): string | undefined {
9
+ return typeof message.stopReason === "string" ? message.stopReason : undefined;
10
+ }
11
+
12
+ export function isAssistantFailureStopReason(stopReason: string | undefined): boolean {
13
+ return stopReason === "error" || stopReason === "aborted";
14
+ }
15
+
16
+ export function assistantMessageHasToolCall(message: SubagentAssistantDrainMessage): boolean {
17
+ return Array.isArray(message.content)
18
+ && message.content.some((part) => part !== null
19
+ && typeof part === "object"
20
+ && (part as { readonly type?: unknown }).type === "toolCall");
21
+ }
22
+
23
+ function assistantMessageHasError(message: SubagentAssistantDrainMessage): boolean {
24
+ const errorMessage = message.errorMessage;
25
+ if (typeof errorMessage === "string") return errorMessage.trim().length > 0;
26
+ return errorMessage !== undefined && errorMessage !== null;
27
+ }
28
+
29
+ export function shouldStartSubagentFinalDrain(message: SubagentAssistantDrainMessage): boolean {
30
+ if (message.role !== undefined && message.role !== "assistant") return false;
31
+ return assistantStopReason(message) === "stop"
32
+ && !assistantMessageHasError(message)
33
+ && !assistantMessageHasToolCall(message);
34
+ }