@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.
- package/CHANGELOG.md +79 -0
- package/README.md +5 -5
- package/dist/builtin/intercom/CHANGELOG.md +60 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +60 -0
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/subagents/CHANGELOG.md +61 -0
- package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-locator.md +1 -1
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +9 -9
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-locator.md +1 -1
- 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 +60 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +72 -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
|
@@ -22,14 +22,14 @@ import { sleep } from "../utils/sleep.js";
|
|
|
22
22
|
import { ATOMIC_GUIDE_COMMAND_NAME, ATOMIC_GUIDE_HELP_CHOICES, atomicGuideModeForChoice, getAtomicGuideMessage, isAtomicGuideHelpChoice, normalizeAtomicGuideMode, } from "./atomic-guide-command.js";
|
|
23
23
|
import { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage } from "./auth-guidance.js";
|
|
24
24
|
import { executeBashWithOperations } from "./bash-executor.js";
|
|
25
|
-
import { calculateContextTokens, collectEntriesForBranchSummary,
|
|
25
|
+
import { calculateContextTokens, collectEntriesForBranchSummary, contextCompact as runContextCompact, estimateContextTokens, generateBranchSummary, prepareContextCompaction, shouldCompact, } from "./compaction/index.js";
|
|
26
26
|
import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
|
|
27
27
|
import { exportSessionToHtml } from "./export-html/index.js";
|
|
28
28
|
import { createToolHtmlRenderer } from "./export-html/tool-renderer.js";
|
|
29
29
|
import { ExtensionRunner, wrapRegisteredTools, } from "./extensions/index.js";
|
|
30
30
|
import { emitSessionShutdownEvent } from "./extensions/runner.js";
|
|
31
31
|
import { expandPromptTemplate } from "./prompt-templates.js";
|
|
32
|
-
import { CURRENT_SESSION_VERSION,
|
|
32
|
+
import { CURRENT_SESSION_VERSION, getLatestCompactionBoundaryEntry } from "./session-manager.js";
|
|
33
33
|
import { createSyntheticSourceInfo } from "./source-info.js";
|
|
34
34
|
import { buildSystemPrompt } from "./system-prompt.js";
|
|
35
35
|
import { createLocalBashOperations } from "./tools/bash.js";
|
|
@@ -1476,11 +1476,42 @@ export class AgentSession {
|
|
|
1476
1476
|
// Compaction
|
|
1477
1477
|
// =========================================================================
|
|
1478
1478
|
/**
|
|
1479
|
-
*
|
|
1480
|
-
*
|
|
1481
|
-
|
|
1479
|
+
* Apply validated logical deletions and rebuild active agent context.
|
|
1480
|
+
* Retained transcript entries/content blocks stay verbatim.
|
|
1481
|
+
*/
|
|
1482
|
+
async _applyContextVerbatimCompaction(options) {
|
|
1483
|
+
if (!this.model) {
|
|
1484
|
+
throw new Error(formatNoModelSelectedMessage());
|
|
1485
|
+
}
|
|
1486
|
+
const pathEntries = this.sessionManager.getBranch();
|
|
1487
|
+
const settings = this.settingsManager.getCompactionSettings();
|
|
1488
|
+
const mode = options.mode ?? "standard";
|
|
1489
|
+
const preparation = prepareContextCompaction(pathEntries, settings, { mode });
|
|
1490
|
+
if (!preparation) {
|
|
1491
|
+
return undefined;
|
|
1492
|
+
}
|
|
1493
|
+
const validated = await runContextCompact(preparation, this.model, options.apiKey, options.headers, options.abortController.signal, undefined, mode);
|
|
1494
|
+
if (options.abortController.signal.aborted) {
|
|
1495
|
+
throw new Error("Compaction cancelled");
|
|
1496
|
+
}
|
|
1497
|
+
const backupPath = this.sessionManager.writeBackupSnapshot(options.backupLabel);
|
|
1498
|
+
this.sessionManager.appendContextCompaction(validated.deletedTargets, validated.protectedEntryIds, validated.stats, backupPath);
|
|
1499
|
+
const sessionContext = this.sessionManager.buildSessionContext();
|
|
1500
|
+
this.agent.state.messages = sessionContext.messages;
|
|
1501
|
+
return {
|
|
1502
|
+
...validated,
|
|
1503
|
+
promptVersion: 1,
|
|
1504
|
+
...(backupPath ? { backupPath } : {}),
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Manually compact the session context using deletion-only verbatim context compaction.
|
|
1509
|
+
* Aborts current agent operation first. Custom summary instructions are not accepted.
|
|
1482
1510
|
*/
|
|
1483
1511
|
async compact(customInstructions) {
|
|
1512
|
+
if (customInstructions?.trim()) {
|
|
1513
|
+
throw new Error("Custom compaction instructions are not supported; use /compact without arguments");
|
|
1514
|
+
}
|
|
1484
1515
|
this._disconnectFromAgent();
|
|
1485
1516
|
await this.abort();
|
|
1486
1517
|
this._compactionAbortController = new AbortController();
|
|
@@ -1490,84 +1521,23 @@ export class AgentSession {
|
|
|
1490
1521
|
throw new Error(formatNoModelSelectedMessage());
|
|
1491
1522
|
}
|
|
1492
1523
|
const { apiKey, headers } = await this._getRequiredRequestAuth(this.model);
|
|
1493
|
-
const
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
throw new Error("Already compacted");
|
|
1501
|
-
}
|
|
1524
|
+
const result = await this._applyContextVerbatimCompaction({
|
|
1525
|
+
apiKey,
|
|
1526
|
+
headers,
|
|
1527
|
+
abortController: this._compactionAbortController,
|
|
1528
|
+
backupLabel: "compact",
|
|
1529
|
+
});
|
|
1530
|
+
if (!result) {
|
|
1502
1531
|
throw new Error("Nothing to compact (session too small)");
|
|
1503
1532
|
}
|
|
1504
|
-
let extensionCompaction;
|
|
1505
|
-
let fromExtension = false;
|
|
1506
|
-
if (this._extensionRunner.hasHandlers("session_before_compact")) {
|
|
1507
|
-
const result = (await this._extensionRunner.emit({
|
|
1508
|
-
type: "session_before_compact",
|
|
1509
|
-
preparation,
|
|
1510
|
-
branchEntries: pathEntries,
|
|
1511
|
-
customInstructions,
|
|
1512
|
-
signal: this._compactionAbortController.signal,
|
|
1513
|
-
}));
|
|
1514
|
-
if (result?.cancel) {
|
|
1515
|
-
throw new Error("Compaction cancelled");
|
|
1516
|
-
}
|
|
1517
|
-
if (result?.compaction) {
|
|
1518
|
-
extensionCompaction = result.compaction;
|
|
1519
|
-
fromExtension = true;
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
let summary;
|
|
1523
|
-
let firstKeptEntryId;
|
|
1524
|
-
let tokensBefore;
|
|
1525
|
-
let details;
|
|
1526
|
-
if (extensionCompaction) {
|
|
1527
|
-
// Extension provided compaction content
|
|
1528
|
-
summary = extensionCompaction.summary;
|
|
1529
|
-
firstKeptEntryId = extensionCompaction.firstKeptEntryId;
|
|
1530
|
-
tokensBefore = extensionCompaction.tokensBefore;
|
|
1531
|
-
details = extensionCompaction.details;
|
|
1532
|
-
}
|
|
1533
|
-
else {
|
|
1534
|
-
// Generate compaction result
|
|
1535
|
-
const result = await compact(preparation, this.model, apiKey, headers, customInstructions, this._compactionAbortController.signal, this.thinkingLevel);
|
|
1536
|
-
summary = result.summary;
|
|
1537
|
-
firstKeptEntryId = result.firstKeptEntryId;
|
|
1538
|
-
tokensBefore = result.tokensBefore;
|
|
1539
|
-
details = result.details;
|
|
1540
|
-
}
|
|
1541
|
-
if (this._compactionAbortController.signal.aborted) {
|
|
1542
|
-
throw new Error("Compaction cancelled");
|
|
1543
|
-
}
|
|
1544
|
-
this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromExtension);
|
|
1545
|
-
const newEntries = this.sessionManager.getEntries();
|
|
1546
|
-
const sessionContext = this.sessionManager.buildSessionContext();
|
|
1547
|
-
this.agent.state.messages = sessionContext.messages;
|
|
1548
|
-
// Get the saved compaction entry for the extension event
|
|
1549
|
-
const savedCompactionEntry = newEntries.find((e) => e.type === "compaction" && e.summary === summary);
|
|
1550
|
-
if (this._extensionRunner && savedCompactionEntry) {
|
|
1551
|
-
await this._extensionRunner.emit({
|
|
1552
|
-
type: "session_compact",
|
|
1553
|
-
compactionEntry: savedCompactionEntry,
|
|
1554
|
-
fromExtension,
|
|
1555
|
-
});
|
|
1556
|
-
}
|
|
1557
|
-
const compactionResult = {
|
|
1558
|
-
summary,
|
|
1559
|
-
firstKeptEntryId,
|
|
1560
|
-
tokensBefore,
|
|
1561
|
-
details,
|
|
1562
|
-
};
|
|
1563
1533
|
this._emit({
|
|
1564
1534
|
type: "compaction_end",
|
|
1565
1535
|
reason: "manual",
|
|
1566
|
-
result
|
|
1536
|
+
result,
|
|
1567
1537
|
aborted: false,
|
|
1568
1538
|
willRetry: false,
|
|
1569
1539
|
});
|
|
1570
|
-
return
|
|
1540
|
+
return result;
|
|
1571
1541
|
}
|
|
1572
1542
|
catch (error) {
|
|
1573
1543
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -1587,6 +1557,56 @@ export class AgentSession {
|
|
|
1587
1557
|
this._reconnectToAgent();
|
|
1588
1558
|
}
|
|
1589
1559
|
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Manually compact the session context by applying validated logical deletions.
|
|
1562
|
+
* Retained transcript entries/content blocks stay verbatim; no user prompt text is accepted.
|
|
1563
|
+
*/
|
|
1564
|
+
async contextCompact() {
|
|
1565
|
+
this._disconnectFromAgent();
|
|
1566
|
+
await this.abort();
|
|
1567
|
+
this._compactionAbortController = new AbortController();
|
|
1568
|
+
this._emit({ type: "context_compaction_start", reason: "manual" });
|
|
1569
|
+
try {
|
|
1570
|
+
if (!this.model) {
|
|
1571
|
+
throw new Error(formatNoModelSelectedMessage());
|
|
1572
|
+
}
|
|
1573
|
+
const { apiKey, headers } = await this._getRequiredRequestAuth(this.model);
|
|
1574
|
+
const result = await this._applyContextVerbatimCompaction({
|
|
1575
|
+
apiKey,
|
|
1576
|
+
headers,
|
|
1577
|
+
abortController: this._compactionAbortController,
|
|
1578
|
+
backupLabel: "context-compact",
|
|
1579
|
+
});
|
|
1580
|
+
if (!result) {
|
|
1581
|
+
throw new Error("Nothing to context-compact (session too small)");
|
|
1582
|
+
}
|
|
1583
|
+
this._emit({
|
|
1584
|
+
type: "context_compaction_end",
|
|
1585
|
+
reason: "manual",
|
|
1586
|
+
result,
|
|
1587
|
+
aborted: false,
|
|
1588
|
+
willRetry: false,
|
|
1589
|
+
});
|
|
1590
|
+
return result;
|
|
1591
|
+
}
|
|
1592
|
+
catch (error) {
|
|
1593
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1594
|
+
const aborted = message === "Compaction cancelled" || (error instanceof Error && error.name === "AbortError");
|
|
1595
|
+
this._emit({
|
|
1596
|
+
type: "context_compaction_end",
|
|
1597
|
+
reason: "manual",
|
|
1598
|
+
result: undefined,
|
|
1599
|
+
aborted,
|
|
1600
|
+
willRetry: false,
|
|
1601
|
+
errorMessage: aborted ? undefined : `Context compaction failed: ${message}`,
|
|
1602
|
+
});
|
|
1603
|
+
throw error;
|
|
1604
|
+
}
|
|
1605
|
+
finally {
|
|
1606
|
+
this._compactionAbortController = undefined;
|
|
1607
|
+
this._reconnectToAgent();
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1590
1610
|
/**
|
|
1591
1611
|
* Cancel in-progress compaction (manual or auto).
|
|
1592
1612
|
*/
|
|
@@ -1606,7 +1626,7 @@ export class AgentSession {
|
|
|
1606
1626
|
*
|
|
1607
1627
|
* Two cases:
|
|
1608
1628
|
* 1. Overflow: LLM returned context overflow error, remove error message from agent state, compact, auto-retry
|
|
1609
|
-
* 2. Threshold: Context over threshold, compact,
|
|
1629
|
+
* 2. Threshold: Context over threshold, compact, resume queued active-turn work if present; otherwise wait for user
|
|
1610
1630
|
*
|
|
1611
1631
|
* @param assistantMessage The assistant message to check
|
|
1612
1632
|
* @param skipAbortedCheck If false, include aborted messages (for pre-prompt check). Default: true
|
|
@@ -1627,9 +1647,10 @@ export class AgentSession {
|
|
|
1627
1647
|
// Skip compaction checks if this assistant message is older than the latest
|
|
1628
1648
|
// compaction boundary. This prevents a stale pre-compaction usage/error
|
|
1629
1649
|
// from retriggering compaction on the first prompt after compaction.
|
|
1630
|
-
const
|
|
1631
|
-
const
|
|
1632
|
-
|
|
1650
|
+
const compactionBoundaryEntry = getLatestCompactionBoundaryEntry(this.sessionManager.getBranch());
|
|
1651
|
+
const assistantIsFromBeforeCompactionBoundary = compactionBoundaryEntry !== null &&
|
|
1652
|
+
assistantMessage.timestamp <= new Date(compactionBoundaryEntry.timestamp).getTime();
|
|
1653
|
+
if (assistantIsFromBeforeCompactionBoundary) {
|
|
1633
1654
|
return;
|
|
1634
1655
|
}
|
|
1635
1656
|
// Case 1: Overflow - LLM returned context overflow error
|
|
@@ -1668,9 +1689,9 @@ export class AgentSession {
|
|
|
1668
1689
|
// have stale usage reflecting the old (larger) context and would falsely
|
|
1669
1690
|
// trigger compaction right after one just finished.
|
|
1670
1691
|
const usageMsg = messages[estimate.lastUsageIndex];
|
|
1671
|
-
if (
|
|
1692
|
+
if (compactionBoundaryEntry &&
|
|
1672
1693
|
usageMsg.role === "assistant" &&
|
|
1673
|
-
usageMsg.timestamp <= new Date(
|
|
1694
|
+
usageMsg.timestamp <= new Date(compactionBoundaryEntry.timestamp).getTime()) {
|
|
1674
1695
|
return;
|
|
1675
1696
|
}
|
|
1676
1697
|
contextTokens = estimate.tokens;
|
|
@@ -1682,11 +1703,44 @@ export class AgentSession {
|
|
|
1682
1703
|
await this._runAutoCompaction("threshold", false);
|
|
1683
1704
|
}
|
|
1684
1705
|
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Internal: remove the trailing overflow error from retry context if it is still present.
|
|
1708
|
+
*/
|
|
1709
|
+
_dropTrailingOverflowAssistantErrorIfPresent() {
|
|
1710
|
+
const messages = this.agent.state.messages;
|
|
1711
|
+
const lastMsg = messages[messages.length - 1];
|
|
1712
|
+
if (lastMsg?.role === "assistant" && lastMsg.stopReason === "error") {
|
|
1713
|
+
this.agent.state.messages = messages.slice(0, -1);
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
/**
|
|
1717
|
+
* Internal: schedule a live post-event continuation probe after compaction_end listeners can flush queues.
|
|
1718
|
+
*/
|
|
1719
|
+
_schedulePostAutoCompactionContinuationProbe(reason, willRetry) {
|
|
1720
|
+
setTimeout(() => {
|
|
1721
|
+
if (this.isCompacting || this.isStreaming) {
|
|
1722
|
+
return;
|
|
1723
|
+
}
|
|
1724
|
+
if (reason === "overflow" && willRetry) {
|
|
1725
|
+
this._resumeAfterAutoCompaction();
|
|
1726
|
+
return;
|
|
1727
|
+
}
|
|
1728
|
+
if (!this.agent.hasQueuedMessages()) {
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1731
|
+
this._resumeAfterAutoCompaction();
|
|
1732
|
+
}, 100);
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Internal: resume generation after successful auto-compaction only when active work remains.
|
|
1736
|
+
*/
|
|
1737
|
+
_resumeAfterAutoCompaction() {
|
|
1738
|
+
this.agent.continue().catch(() => { });
|
|
1739
|
+
}
|
|
1685
1740
|
/**
|
|
1686
1741
|
* Internal: Run auto-compaction with events.
|
|
1687
1742
|
*/
|
|
1688
1743
|
async _runAutoCompaction(reason, willRetry) {
|
|
1689
|
-
const settings = this.settingsManager.getCompactionSettings();
|
|
1690
1744
|
this._emit({ type: "compaction_start", reason });
|
|
1691
1745
|
this._autoCompactionAbortController = new AbortController();
|
|
1692
1746
|
try {
|
|
@@ -1711,10 +1765,14 @@ export class AgentSession {
|
|
|
1711
1765
|
});
|
|
1712
1766
|
return;
|
|
1713
1767
|
}
|
|
1714
|
-
const
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1768
|
+
const result = await this._applyContextVerbatimCompaction({
|
|
1769
|
+
apiKey: authResult.apiKey,
|
|
1770
|
+
headers: authResult.headers,
|
|
1771
|
+
abortController: this._autoCompactionAbortController,
|
|
1772
|
+
backupLabel: reason === "overflow" ? "overflow-auto-compact" : "auto-compact",
|
|
1773
|
+
mode: reason === "overflow" ? "critical_overflow" : "standard",
|
|
1774
|
+
});
|
|
1775
|
+
if (!result) {
|
|
1718
1776
|
this._emit({
|
|
1719
1777
|
type: "compaction_end",
|
|
1720
1778
|
reason,
|
|
@@ -1724,109 +1782,26 @@ export class AgentSession {
|
|
|
1724
1782
|
});
|
|
1725
1783
|
return;
|
|
1726
1784
|
}
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
if (this._extensionRunner.hasHandlers("session_before_compact")) {
|
|
1730
|
-
const extensionResult = (await this._extensionRunner.emit({
|
|
1731
|
-
type: "session_before_compact",
|
|
1732
|
-
preparation,
|
|
1733
|
-
branchEntries: pathEntries,
|
|
1734
|
-
customInstructions: undefined,
|
|
1735
|
-
signal: this._autoCompactionAbortController.signal,
|
|
1736
|
-
}));
|
|
1737
|
-
if (extensionResult?.cancel) {
|
|
1738
|
-
this._emit({
|
|
1739
|
-
type: "compaction_end",
|
|
1740
|
-
reason,
|
|
1741
|
-
result: undefined,
|
|
1742
|
-
aborted: true,
|
|
1743
|
-
willRetry: false,
|
|
1744
|
-
});
|
|
1745
|
-
return;
|
|
1746
|
-
}
|
|
1747
|
-
if (extensionResult?.compaction) {
|
|
1748
|
-
extensionCompaction = extensionResult.compaction;
|
|
1749
|
-
fromExtension = true;
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
let summary;
|
|
1753
|
-
let firstKeptEntryId;
|
|
1754
|
-
let tokensBefore;
|
|
1755
|
-
let details;
|
|
1756
|
-
if (extensionCompaction) {
|
|
1757
|
-
// Extension provided compaction content
|
|
1758
|
-
summary = extensionCompaction.summary;
|
|
1759
|
-
firstKeptEntryId = extensionCompaction.firstKeptEntryId;
|
|
1760
|
-
tokensBefore = extensionCompaction.tokensBefore;
|
|
1761
|
-
details = extensionCompaction.details;
|
|
1785
|
+
if (reason === "overflow" && willRetry) {
|
|
1786
|
+
this._dropTrailingOverflowAssistantErrorIfPresent();
|
|
1762
1787
|
}
|
|
1763
|
-
else {
|
|
1764
|
-
// Generate compaction result
|
|
1765
|
-
const compactResult = await compact(preparation, this.model, apiKey, headers, undefined, this._autoCompactionAbortController.signal, this.thinkingLevel);
|
|
1766
|
-
summary = compactResult.summary;
|
|
1767
|
-
firstKeptEntryId = compactResult.firstKeptEntryId;
|
|
1768
|
-
tokensBefore = compactResult.tokensBefore;
|
|
1769
|
-
details = compactResult.details;
|
|
1770
|
-
}
|
|
1771
|
-
if (this._autoCompactionAbortController.signal.aborted) {
|
|
1772
|
-
this._emit({
|
|
1773
|
-
type: "compaction_end",
|
|
1774
|
-
reason,
|
|
1775
|
-
result: undefined,
|
|
1776
|
-
aborted: true,
|
|
1777
|
-
willRetry: false,
|
|
1778
|
-
});
|
|
1779
|
-
return;
|
|
1780
|
-
}
|
|
1781
|
-
this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromExtension);
|
|
1782
|
-
const newEntries = this.sessionManager.getEntries();
|
|
1783
|
-
const sessionContext = this.sessionManager.buildSessionContext();
|
|
1784
|
-
this.agent.state.messages = sessionContext.messages;
|
|
1785
|
-
// Get the saved compaction entry for the extension event
|
|
1786
|
-
const savedCompactionEntry = newEntries.find((e) => e.type === "compaction" && e.summary === summary);
|
|
1787
|
-
if (this._extensionRunner && savedCompactionEntry) {
|
|
1788
|
-
await this._extensionRunner.emit({
|
|
1789
|
-
type: "session_compact",
|
|
1790
|
-
compactionEntry: savedCompactionEntry,
|
|
1791
|
-
fromExtension,
|
|
1792
|
-
});
|
|
1793
|
-
}
|
|
1794
|
-
const result = {
|
|
1795
|
-
summary,
|
|
1796
|
-
firstKeptEntryId,
|
|
1797
|
-
tokensBefore,
|
|
1798
|
-
details,
|
|
1799
|
-
};
|
|
1800
1788
|
this._emit({ type: "compaction_end", reason, result, aborted: false, willRetry });
|
|
1801
|
-
|
|
1802
|
-
const messages = this.agent.state.messages;
|
|
1803
|
-
const lastMsg = messages[messages.length - 1];
|
|
1804
|
-
if (lastMsg?.role === "assistant" && lastMsg.stopReason === "error") {
|
|
1805
|
-
this.agent.state.messages = messages.slice(0, -1);
|
|
1806
|
-
}
|
|
1807
|
-
setTimeout(() => {
|
|
1808
|
-
this.agent.continue().catch(() => { });
|
|
1809
|
-
}, 100);
|
|
1810
|
-
}
|
|
1811
|
-
else if (this.agent.hasQueuedMessages()) {
|
|
1812
|
-
// Auto-compaction can complete while follow-up/steering/custom messages are waiting.
|
|
1813
|
-
// Kick the loop so queued messages are actually delivered.
|
|
1814
|
-
setTimeout(() => {
|
|
1815
|
-
this.agent.continue().catch(() => { });
|
|
1816
|
-
}, 100);
|
|
1817
|
-
}
|
|
1789
|
+
this._schedulePostAutoCompactionContinuationProbe(reason, willRetry);
|
|
1818
1790
|
}
|
|
1819
1791
|
catch (error) {
|
|
1820
1792
|
const errorMessage = error instanceof Error ? error.message : "compaction failed";
|
|
1793
|
+
const aborted = errorMessage === "Compaction cancelled" || (error instanceof Error && error.name === "AbortError");
|
|
1821
1794
|
this._emit({
|
|
1822
1795
|
type: "compaction_end",
|
|
1823
1796
|
reason,
|
|
1824
1797
|
result: undefined,
|
|
1825
|
-
aborted
|
|
1798
|
+
aborted,
|
|
1826
1799
|
willRetry: false,
|
|
1827
|
-
errorMessage:
|
|
1828
|
-
?
|
|
1829
|
-
:
|
|
1800
|
+
errorMessage: aborted
|
|
1801
|
+
? undefined
|
|
1802
|
+
: reason === "overflow"
|
|
1803
|
+
? `Context overflow recovery failed: ${errorMessage}`
|
|
1804
|
+
: `Auto-compaction failed: ${errorMessage}`,
|
|
1830
1805
|
});
|
|
1831
1806
|
}
|
|
1832
1807
|
finally {
|
|
@@ -2633,10 +2608,10 @@ export class AgentSession {
|
|
|
2633
2608
|
// We can only trust usage from an assistant that responded after the latest compaction.
|
|
2634
2609
|
// If no such assistant exists, context token count is unknown until the next LLM response.
|
|
2635
2610
|
const branchEntries = this.sessionManager.getBranch();
|
|
2636
|
-
const
|
|
2637
|
-
if (
|
|
2611
|
+
const latestCompactionBoundary = getLatestCompactionBoundaryEntry(branchEntries);
|
|
2612
|
+
if (latestCompactionBoundary) {
|
|
2638
2613
|
// Check if there's a valid assistant usage after the compaction boundary
|
|
2639
|
-
const compactionIndex = branchEntries.lastIndexOf(
|
|
2614
|
+
const compactionIndex = branchEntries.lastIndexOf(latestCompactionBoundary);
|
|
2640
2615
|
let hasPostCompactionUsage = false;
|
|
2641
2616
|
for (let i = branchEntries.length - 1; i > compactionIndex; i--) {
|
|
2642
2617
|
const entry = branchEntries[i];
|