@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
|
@@ -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(
|
|
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(
|
|
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
|
-
|
|
163
|
+
interface StageScope {
|
|
164
|
+
readonly runId: string;
|
|
165
|
+
readonly stageId: string;
|
|
166
|
+
}
|
|
164
167
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
interface ActiveToolCall extends StageScope {
|
|
169
|
+
readonly callId: string;
|
|
170
|
+
readonly name: string;
|
|
171
|
+
readonly startedAt: number;
|
|
172
|
+
}
|
|
168
173
|
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
178
|
+
function activeCallKey(runId: string, stageId: string, callId: string): string {
|
|
179
|
+
return `${runId}\0${stageId}\0${callId}`;
|
|
180
|
+
}
|
|
175
181
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
if (
|
|
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
|
|
185
|
-
|
|
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
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
const
|
|
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
|
-
|
|
194
|
-
|
|
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
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
-
|
|
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
|
|
240
|
-
|
|
223
|
+
const snap = storeInstance.snapshot();
|
|
224
|
+
pruneActiveToolCalls(snap);
|
|
225
|
+
|
|
226
|
+
const scope = resolveExplicitStageScope(payload);
|
|
227
|
+
if (!scope || !hasLiveStageScope(scope, snap)) return;
|
|
241
228
|
|
|
242
|
-
|
|
243
|
-
|
|
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
|
|
239
|
+
startedAt,
|
|
246
240
|
});
|
|
247
|
-
|
|
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
|
-
|
|
254
|
-
const ids = activeAskCall ?? resolveIds(payload, false);
|
|
255
|
-
if (!ids) return;
|
|
255
|
+
pruneActiveToolCalls(storeInstance.snapshot());
|
|
256
256
|
|
|
257
|
-
|
|
258
|
-
|
|
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:
|
|
263
|
+
startedAt: active.call.startedAt,
|
|
261
264
|
endedAt: payload.endedAt ?? payload.ended_at ?? Date.now(),
|
|
262
265
|
output: payload.output,
|
|
263
266
|
});
|
|
264
|
-
|
|
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",
|
|
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",
|
|
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
|
-
*
|
|
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
|
-
|
|
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.
|