@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.
- package/CHANGELOG.md +73 -0
- package/README.md +5 -5
- package/dist/builtin/intercom/CHANGELOG.md +54 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +54 -0
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/subagents/CHANGELOG.md +55 -0
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +9 -9
- package/dist/builtin/subagents/agents/debugger.md +6 -6
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +1 -1
- package/dist/builtin/subagents/skills/browser/EXAMPLES.md +151 -0
- package/dist/builtin/subagents/skills/browser/LICENSE.txt +21 -0
- package/dist/builtin/subagents/skills/browser/REFERENCE.md +451 -0
- package/dist/builtin/subagents/skills/browser/SKILL.md +170 -0
- package/dist/builtin/subagents/skills/subagent/SKILL.md +4 -4
- package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +55 -12
- package/dist/builtin/subagents/src/runs/foreground/execution.ts +71 -12
- package/dist/builtin/subagents/src/runs/shared/acceptance.ts +2 -1
- package/dist/builtin/subagents/src/runs/shared/final-drain.ts +34 -0
- package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +416 -7
- package/dist/builtin/subagents/src/runs/shared/worktree.ts +2 -2
- package/dist/builtin/web-access/CHANGELOG.md +54 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +66 -0
- package/dist/builtin/workflows/README.md +10 -8
- package/dist/builtin/workflows/builtin/deep-research-codebase.ts +11 -8
- package/dist/builtin/workflows/builtin/goal.ts +137 -109
- package/dist/builtin/workflows/builtin/index.d.ts +2 -0
- package/dist/builtin/workflows/builtin/open-claude-design.ts +228 -151
- package/dist/builtin/workflows/builtin/ralph.d.ts +2 -0
- package/dist/builtin/workflows/builtin/ralph.ts +452 -279
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/create-spec/SKILL.md +14 -0
- package/dist/builtin/workflows/skills/research-codebase/SKILL.md +29 -10
- package/dist/builtin/workflows/src/extension/index.ts +10 -2
- package/dist/builtin/workflows/src/extension/runtime.ts +35 -3
- package/dist/builtin/workflows/src/extension/wiring.ts +13 -1
- package/dist/builtin/workflows/src/runs/background/status.ts +52 -6
- package/dist/builtin/workflows/src/runs/foreground/executor.ts +453 -21
- package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +77 -11
- package/dist/builtin/workflows/src/runs/shared/model-fallback.ts +402 -8
- package/dist/builtin/workflows/src/runs/shared/worktree.ts +2 -2
- package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +2 -2
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +182 -6
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +76 -6
- package/dist/builtin/workflows/src/shared/stage-prompt.ts +33 -2
- package/dist/builtin/workflows/src/shared/store-types.ts +31 -0
- package/dist/builtin/workflows/src/shared/store.ts +160 -18
- package/dist/builtin/workflows/src/shared/types.ts +3 -3
- package/dist/builtin/workflows/src/shared/workflow-failures.ts +758 -132
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +39 -3
- package/dist/builtin/workflows/src/tui/store-widget-installer.ts +74 -74
- package/dist/core/agent-session.d.ts +33 -6
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +157 -182
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +11 -9
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +6 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +23 -10
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/context-compaction.d.ts +175 -0
- package/dist/core/compaction/context-compaction.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction.js +1636 -0
- package/dist/core/compaction/context-compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/extensions/types.d.ts +3 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +3 -0
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +14 -7
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/session-manager.d.ts +41 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +146 -7
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/ask-user-question/tool/format-answer.d.ts +5 -5
- package/dist/core/tools/ask-user-question/tool/format-answer.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/tool/format-answer.js +5 -5
- package/dist/core/tools/ask-user-question/tool/format-answer.js.map +1 -1
- package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts +16 -3
- package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/tool/response-envelope.js +21 -3
- package/dist/core/tools/ask-user-question/tool/response-envelope.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/modes/index.d.ts +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +17 -0
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/context-compaction-summary-message.d.ts +17 -0
- package/dist/modes/interactive/components/context-compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/context-compaction-summary-message.js +83 -0
- package/dist/modes/interactive/components/context-compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +4 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +75 -10
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +13 -8
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +8 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +4 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +14 -3
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/utils/git-env.d.ts +10 -0
- package/dist/utils/git-env.d.ts.map +1 -0
- package/dist/utils/git-env.js +33 -0
- package/dist/utils/git-env.js.map +1 -0
- package/docs/compaction.md +185 -50
- package/docs/custom-provider.md +11 -9
- package/docs/extensions.md +46 -42
- package/docs/index.md +13 -6
- package/docs/json.md +15 -12
- package/docs/packages.md +2 -0
- package/docs/providers.md +4 -1
- package/docs/quickstart.md +18 -11
- package/docs/rpc.md +38 -23
- package/docs/sdk.md +17 -8
- package/docs/session-format.md +26 -13
- package/docs/sessions.md +3 -3
- package/docs/settings.md +2 -2
- package/docs/skills.md +1 -15
- package/docs/termux.md +9 -10
- package/docs/themes.md +2 -2
- package/docs/tmux.md +3 -3
- package/docs/tui.md +19 -32
- package/docs/usage.md +2 -2
- package/docs/workflows.md +60 -16
- package/package.json +6 -12
- package/dist/builtin/subagents/skills/browser-use/SKILL.md +0 -234
- package/dist/builtin/subagents/skills/browser-use/references/cdp-python.md +0 -76
- package/dist/builtin/subagents/skills/browser-use/references/multi-session.md +0 -92
- package/node_modules/@earendil-works/pi-tui/README.md +0 -779
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +0 -54
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +0 -632
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +0 -22
- package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/box.js +0 -104
- package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts +0 -22
- package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js +0 -35
- package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +0 -249
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +0 -1857
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts +0 -28
- package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.js +0 -89
- package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts +0 -37
- package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/input.js +0 -378
- package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +0 -31
- package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/loader.js +0 -69
- package/node_modules/@earendil-works/pi-tui/dist/components/loader.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +0 -96
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +0 -644
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +0 -50
- package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +0 -159
- package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +0 -50
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +0 -185
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts +0 -12
- package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js +0 -23
- package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +0 -19
- package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/text.js +0 -89
- package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts +0 -13
- package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js +0 -51
- package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts +0 -39
- package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/editor-component.js +0 -2
- package/node_modules/@earendil-works/pi-tui/dist/editor-component.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts +0 -16
- package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +0 -110
- package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +0 -23
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js +0 -32
- package/node_modules/@earendil-works/pi-tui/dist/index.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +0 -193
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +0 -174
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts +0 -184
- package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/keys.js +0 -1173
- package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts +0 -28
- package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js +0 -44
- package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts +0 -3
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js +0 -53
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +0 -50
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +0 -361
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +0 -90
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +0 -366
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +0 -113
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js +0 -472
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +0 -227
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js +0 -1106
- package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts +0 -17
- package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js +0 -25
- package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +0 -84
- package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.js +0 -1029
- package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts +0 -25
- package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js +0 -96
- package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/node_modules/@earendil-works/pi-tui/package.json +0 -47
- package/node_modules/get-east-asian-width/index.d.ts +0 -60
- package/node_modules/get-east-asian-width/index.js +0 -30
- package/node_modules/get-east-asian-width/license +0 -9
- package/node_modules/get-east-asian-width/lookup-data.js +0 -21
- package/node_modules/get-east-asian-width/lookup.js +0 -138
- package/node_modules/get-east-asian-width/package.json +0 -71
- package/node_modules/get-east-asian-width/readme.md +0 -65
- package/node_modules/get-east-asian-width/utilities.js +0 -24
- package/node_modules/marked/LICENSE.md +0 -44
- package/node_modules/marked/README.md +0 -106
- package/node_modules/marked/bin/main.js +0 -282
- package/node_modules/marked/bin/marked.js +0 -15
- package/node_modules/marked/lib/marked.cjs +0 -2211
- package/node_modules/marked/lib/marked.cjs.map +0 -7
- package/node_modules/marked/lib/marked.d.cts +0 -728
- package/node_modules/marked/lib/marked.d.ts +0 -728
- package/node_modules/marked/lib/marked.esm.js +0 -2189
- package/node_modules/marked/lib/marked.esm.js.map +0 -7
- package/node_modules/marked/lib/marked.umd.js +0 -2213
- package/node_modules/marked/lib/marked.umd.js.map +0 -7
- package/node_modules/marked/man/marked.1 +0 -111
- package/node_modules/marked/man/marked.1.md +0 -92
- package/node_modules/marked/marked.min.js +0 -69
- package/node_modules/marked/package.json +0 -111
|
@@ -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
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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
|
-
|
|
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
|
|
772
|
-
|
|
773
|
-
|
|
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
|
-
//
|
|
527
|
-
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
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
|
-
|
|
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
|
-
|
|
932
|
-
|
|
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(
|
|
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
|
+
}
|