@ashx-j/lunr 0.2.26 → 0.2.28
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 +25 -1
- package/LICENSE +22 -0
- package/dist/builtin-extensions/ashxj-thinking.d.ts +1 -1
- package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-thinking.js +1 -1
- package/dist/builtin-extensions/ashxj-thinking.js.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.d.ts +11 -1
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.js +6 -10
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
- package/dist/builtin-extensions/lunr-cron.d.ts +4 -5
- package/dist/builtin-extensions/lunr-cron.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-cron.js +94 -108
- package/dist/builtin-extensions/lunr-cron.js.map +1 -1
- package/dist/builtin-extensions/lunr-local-providers/local-servers.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-local-providers/local-servers.js +3 -1
- package/dist/builtin-extensions/lunr-local-providers/local-servers.js.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js +5 -2
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.js +2 -2
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.js.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.js +2 -2
- package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.js +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js +1 -15
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.d.ts +6 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.js +187 -132
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.d.ts +8 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.js +142 -112
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts +12 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js +14 -7
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.d.ts +11 -3
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.js +67 -41
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.d.ts +4 -2
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.js +3 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts +2 -1
- package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/commands.js +6 -6
- package/dist/builtin-extensions/pi-mcp-adapter/commands.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/config.d.ts +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/config.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/config.js +11 -5
- package/dist/builtin-extensions/pi-mcp-adapter/config.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js +2 -2
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.js +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.js +48 -40
- package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.js +3 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.d.ts +12 -40
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js +166 -235
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.d.ts +5 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js +43 -13
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.d.ts +14 -3
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js +73 -21
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js +4 -4
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js +2 -2
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts +2 -0
- package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/state.js.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.js +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.js.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts +11 -5
- package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/models.js +12 -32
- package/dist/builtin-extensions/pi-ollama-cloud/models.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/index.js +5 -3
- package/dist/builtin-extensions/pi-prompt-template-model/index.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts +2 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js +21 -12
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js +7 -24
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +39 -77
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.d.ts +4 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +6 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js +17 -31
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js +7 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts +5 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +78 -42
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +8 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts +0 -3
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +134 -28
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +26 -5
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +7 -8
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js +60 -32
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.d.ts +7 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js +70 -38
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +9 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.js +15 -5
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +4 -3
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +13 -62
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +18 -9
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js +3 -3
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js.map +1 -1
- package/dist/builtin-extensions/pi-tps.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-tps.js +28 -17
- package/dist/builtin-extensions/pi-tps.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/activity.d.ts +1 -0
- package/dist/builtin-extensions/pi-web-access/activity.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/activity.js +27 -5
- package/dist/builtin-extensions/pi-web-access/activity.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/bounded-body.d.ts +3 -0
- package/dist/builtin-extensions/pi-web-access/bounded-body.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/bounded-body.js +43 -0
- package/dist/builtin-extensions/pi-web-access/bounded-body.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/content-page.d.ts +24 -0
- package/dist/builtin-extensions/pi-web-access/content-page.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/content-page.js +57 -0
- package/dist/builtin-extensions/pi-web-access/content-page.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/extract.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/extract.js +7 -2
- package/dist/builtin-extensions/pi-web-access/extract.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.d.ts +0 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.js +147 -36
- package/dist/builtin-extensions/pi-web-access/github-extract.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.js +48 -73
- package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts +12 -4
- package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/session-cleanup.js +35 -12
- package/dist/builtin-extensions/pi-web-access/session-cleanup.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/storage.d.ts +9 -6
- package/dist/builtin-extensions/pi-web-access/storage.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/storage.js +36 -24
- package/dist/builtin-extensions/pi-web-access/storage.js.map +1 -1
- package/dist/builtin-extensions/simple-pi-memory.d.ts +1 -1
- package/dist/builtin-extensions/simple-pi-memory.d.ts.map +1 -1
- package/dist/builtin-extensions/simple-pi-memory.js +1 -1
- package/dist/builtin-extensions/simple-pi-memory.js.map +1 -1
- package/dist/catalog/models.json +1 -1
- package/dist/catalog/providers/google-vertex.json +1 -1
- package/dist/catalog/providers/google.json +1 -1
- package/dist/catalog/publication.json +3 -3
- package/dist/cli/install-cli.d.ts.map +1 -1
- package/dist/cli/install-cli.js +38 -30
- package/dist/cli/install-cli.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +13 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +75 -11
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +46 -21
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +344 -126
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/browser/runtime.d.ts +2 -0
- package/dist/core/browser/runtime.d.ts.map +1 -1
- package/dist/core/browser/runtime.js +80 -45
- package/dist/core/browser/runtime.js.map +1 -1
- package/dist/core/browser/setup.d.ts.map +1 -1
- package/dist/core/browser/setup.js +12 -1
- package/dist/core/browser/setup.js.map +1 -1
- package/dist/core/cache-stats.d.ts +1 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +1 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +2 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +5 -11
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +38 -92
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/computer-use/adapter.d.ts.map +1 -1
- package/dist/core/computer-use/adapter.js +7 -2
- package/dist/core/computer-use/adapter.js.map +1 -1
- package/dist/core/computer-use/image.d.ts.map +1 -1
- package/dist/core/computer-use/image.js +17 -5
- package/dist/core/computer-use/image.js.map +1 -1
- package/dist/core/computer-use/schemas.d.ts.map +1 -1
- package/dist/core/computer-use/schemas.js +23 -6
- package/dist/core/computer-use/schemas.js.map +1 -1
- package/dist/core/computer-use/workflow.d.ts.map +1 -1
- package/dist/core/computer-use/workflow.js +459 -119
- package/dist/core/computer-use/workflow.js.map +1 -1
- package/dist/core/context-breakdown.d.ts +2 -2
- package/dist/core/context-breakdown.d.ts.map +1 -1
- package/dist/core/context-breakdown.js +22 -20
- package/dist/core/context-breakdown.js.map +1 -1
- package/dist/core/cron/jobs.d.ts +26 -8
- package/dist/core/cron/jobs.d.ts.map +1 -1
- package/dist/core/cron/jobs.js +357 -232
- package/dist/core/cron/jobs.js.map +1 -1
- package/dist/core/cron/origin-context.d.ts +1 -0
- package/dist/core/cron/origin-context.d.ts.map +1 -1
- package/dist/core/cron/origin-context.js.map +1 -1
- package/dist/core/cron/scheduler.d.ts +22 -17
- package/dist/core/cron/scheduler.d.ts.map +1 -1
- package/dist/core/cron/scheduler.js +153 -73
- package/dist/core/cron/scheduler.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +8 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +11 -1
- 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 +4 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +22 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/large-subagent-launch.d.ts +1 -1
- package/dist/core/large-subagent-launch.d.ts.map +1 -1
- package/dist/core/large-subagent-launch.js +7 -7
- package/dist/core/large-subagent-launch.js.map +1 -1
- package/dist/core/model-registry.d.ts +2 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +5 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-runtime.d.ts +4 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +40 -4
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/permissions.d.ts +3 -3
- package/dist/core/permissions.d.ts.map +1 -1
- package/dist/core/permissions.js +11 -35
- package/dist/core/permissions.js.map +1 -1
- package/dist/core/plan-mode.d.ts +5 -13
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +126 -116
- package/dist/core/plan-mode.js.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +1 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/prompt-resource-bridge.d.ts +12 -0
- package/dist/core/prompt-resource-bridge.d.ts.map +1 -0
- package/dist/core/prompt-resource-bridge.js +9 -0
- package/dist/core/prompt-resource-bridge.js.map +1 -0
- package/dist/core/protected-targets.d.ts +6 -0
- package/dist/core/protected-targets.d.ts.map +1 -0
- package/dist/core/protected-targets.js +45 -0
- package/dist/core/protected-targets.js.map +1 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +7 -0
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/rollback.d.ts +19 -3
- package/dist/core/rollback.d.ts.map +1 -1
- package/dist/core/rollback.js +172 -56
- package/dist/core/rollback.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +3 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +14 -1
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts +3 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +11 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +111 -33
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-ownership.d.ts.map +1 -1
- package/dist/core/session-ownership.js +8 -3
- package/dist/core/session-ownership.js.map +1 -1
- package/dist/core/session-retention.d.ts.map +1 -1
- package/dist/core/session-retention.js +18 -7
- package/dist/core/session-retention.js.map +1 -1
- package/dist/core/session-startup-settings.d.ts +10 -0
- package/dist/core/session-startup-settings.d.ts.map +1 -0
- package/dist/core/session-startup-settings.js +70 -0
- package/dist/core/session-startup-settings.js.map +1 -0
- package/dist/core/subscriptions.d.ts +16 -7
- package/dist/core/subscriptions.d.ts.map +1 -1
- package/dist/core/subscriptions.js +96 -55
- package/dist/core/subscriptions.js.map +1 -1
- package/dist/core/trust-manager.d.ts +2 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +6 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/update-check.d.ts.map +1 -1
- package/dist/core/update-check.js.map +1 -1
- package/dist/core/usage-accounting.d.ts +47 -0
- package/dist/core/usage-accounting.d.ts.map +1 -0
- package/dist/core/usage-accounting.js +205 -0
- package/dist/core/usage-accounting.js.map +1 -0
- package/dist/core/usage-adapters/kimi-coding.d.ts +2 -2
- package/dist/core/usage-adapters/kimi-coding.d.ts.map +1 -1
- package/dist/core/usage-adapters/kimi-coding.js +2 -2
- package/dist/core/usage-adapters/kimi-coding.js.map +1 -1
- package/dist/core/usage-adapters/openai-codex.d.ts +3 -2
- package/dist/core/usage-adapters/openai-codex.d.ts.map +1 -1
- package/dist/core/usage-adapters/openai-codex.js +3 -3
- package/dist/core/usage-adapters/openai-codex.js.map +1 -1
- package/dist/core/usage-adapters/xai.d.ts +2 -2
- package/dist/core/usage-adapters/xai.d.ts.map +1 -1
- package/dist/core/usage-adapters/xai.js +3 -3
- package/dist/core/usage-adapters/xai.js.map +1 -1
- package/dist/core/usage-adapters/zai.d.ts +2 -2
- package/dist/core/usage-adapters/zai.d.ts.map +1 -1
- package/dist/core/usage-adapters/zai.js +2 -2
- package/dist/core/usage-adapters/zai.js.map +1 -1
- package/dist/core/usage-history.d.ts +1 -18
- package/dist/core/usage-history.d.ts.map +1 -1
- package/dist/core/usage-history.js +46 -114
- package/dist/core/usage-history.js.map +1 -1
- package/dist/core/usage-service.d.ts +9 -2
- package/dist/core/usage-service.d.ts.map +1 -1
- package/dist/core/usage-service.js +95 -50
- package/dist/core/usage-service.js.map +1 -1
- package/dist/gateway/agent-bridge.d.ts +9 -1
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +91 -37
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/buttons.d.ts +8 -1
- package/dist/gateway/buttons.d.ts.map +1 -1
- package/dist/gateway/buttons.js +76 -18
- package/dist/gateway/buttons.js.map +1 -1
- package/dist/gateway/commands.d.ts +1 -0
- package/dist/gateway/commands.d.ts.map +1 -1
- package/dist/gateway/commands.js +10 -4
- package/dist/gateway/commands.js.map +1 -1
- package/dist/gateway/cron.d.ts +12 -11
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +65 -56
- package/dist/gateway/cron.js.map +1 -1
- package/dist/gateway/index.d.ts.map +1 -1
- package/dist/gateway/index.js +2 -1
- package/dist/gateway/index.js.map +1 -1
- package/dist/gateway/mobile-commands.d.ts +1 -0
- package/dist/gateway/mobile-commands.d.ts.map +1 -1
- package/dist/gateway/mobile-commands.js +69 -15
- package/dist/gateway/mobile-commands.js.map +1 -1
- package/dist/gateway/presenter.d.ts +12 -2
- package/dist/gateway/presenter.d.ts.map +1 -1
- package/dist/gateway/presenter.js +73 -38
- package/dist/gateway/presenter.js.map +1 -1
- package/dist/gateway/router.d.ts +2 -2
- package/dist/gateway/router.d.ts.map +1 -1
- package/dist/gateway/router.js +17 -2
- package/dist/gateway/router.js.map +1 -1
- package/dist/gateway/service.d.ts +2 -0
- package/dist/gateway/service.d.ts.map +1 -1
- package/dist/gateway/service.js +153 -0
- package/dist/gateway/service.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +86 -33
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +6 -4
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/context-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/context-view.js +2 -2
- package/dist/modes/interactive/components/context-view.js.map +1 -1
- package/dist/modes/interactive/components/copyable-text.d.ts.map +1 -1
- package/dist/modes/interactive/components/copyable-text.js +3 -2
- package/dist/modes/interactive/components/copyable-text.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +1 -1
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +8 -12
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/usage-view.d.ts +5 -0
- package/dist/modes/interactive/components/usage-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/usage-view.js +21 -6
- package/dist/modes/interactive/components/usage-view.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +3 -7
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +151 -131
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/smooth-streaming.d.ts.map +1 -1
- package/dist/modes/interactive/smooth-streaming.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/node-runtime/{adapter-VFG7WNPX.js → adapter-247RTYLS.js} +4 -5
- package/dist/node-runtime/agent-session-services-RTUGP3XR.js +54 -0
- package/dist/node-runtime/{brave-UWDA3I22.js → brave-2AFFAXNN.js} +1 -1
- package/dist/node-runtime/{builtin-extensions-I2HIFEMY.js → builtin-extensions-N4EUD6SB.js} +8 -7
- package/dist/node-runtime/{chunk-QH6YL7VK.js → chunk-252ZVPPF.js} +3 -3
- package/dist/node-runtime/{chunk-PCEW76PM.js → chunk-2OIPYKLZ.js} +6 -6
- package/dist/node-runtime/{chunk-XBWPBZBN.js → chunk-2SWW7KMW.js} +1 -1
- package/dist/node-runtime/{chunk-UQUCFAJ3.js → chunk-2VIW3IMF.js} +40 -7
- package/dist/node-runtime/{chunk-UOEDI7RP.js → chunk-4KNKQGHM.js} +2 -2
- package/dist/node-runtime/chunk-4QRUZ64T.js +1203 -0
- package/dist/node-runtime/{chunk-FQMM2EZ2.js → chunk-64XTQNLA.js} +29 -7
- package/dist/node-runtime/{chunk-SPVDBUOS.js → chunk-6O3IW3IA.js} +2 -2
- package/dist/node-runtime/{chunk-5ZQXRPMC.js → chunk-6ZZHGUSA.js} +2 -2
- package/dist/node-runtime/{chunk-WIF24I7G.js → chunk-APVM5NEU.js} +149 -144
- package/dist/node-runtime/{chunk-LWYIVUGV.js → chunk-B2IBAXNX.js} +48 -31
- package/dist/node-runtime/{chunk-M3LZLQW2.js → chunk-BDRGN3L2.js} +1 -0
- package/dist/node-runtime/{chunk-LJTIVM7I.js → chunk-BMRXLQWQ.js} +464 -160
- package/dist/node-runtime/{chunk-GJ2RDBRL.js → chunk-BYC6RKCN.js} +4 -2
- package/dist/node-runtime/{chunk-T4DA4XE7.js → chunk-DFMPRAQQ.js} +162 -82
- package/dist/node-runtime/{chunk-SN2KSMPQ.js → chunk-DQSCFU7R.js} +13 -7
- package/dist/node-runtime/{chunk-UVWCDQYF.js → chunk-E5DQGNJI.js} +455 -278
- package/dist/node-runtime/{chunk-4SBQAI4T.js → chunk-EBLAZVSA.js} +2058 -73
- package/dist/node-runtime/{chunk-CSFI6YXL.js → chunk-ES6PBSIE.js} +1 -1
- package/dist/node-runtime/{chunk-IF24A3FH.js → chunk-EVM653DD.js} +4 -4
- package/dist/node-runtime/{chunk-HTFRRDSF.js → chunk-F2SMQ6ES.js} +3 -2
- package/dist/node-runtime/chunk-F2V2F4ZG.js +114 -0
- package/dist/node-runtime/{chunk-IKU6Y7DL.js → chunk-FE3WZI7F.js} +9 -6
- package/dist/node-runtime/{chunk-6VYZ5UFP.js → chunk-FLGEEH27.js} +1 -1
- package/dist/node-runtime/{chunk-5EFIU3OM.js → chunk-FTKEZL27.js} +1 -1
- package/dist/node-runtime/{chunk-RGQAEOM5.js → chunk-FYIFPFXE.js} +23 -6
- package/dist/node-runtime/{chunk-HMBGROQK.js → chunk-GLDXBBL6.js} +3 -3
- package/dist/node-runtime/{chunk-KWA4OC2J.js → chunk-H6YBCWKG.js} +1 -1
- package/dist/node-runtime/{chunk-2MI5OPMN.js → chunk-HNNHHJAB.js} +68 -50
- package/dist/node-runtime/{chunk-I74LN5JG.js → chunk-HUD2RFJW.js} +2 -2
- package/dist/node-runtime/{chunk-XHIRAZ26.js → chunk-IAZSK7KK.js} +1 -1
- package/dist/node-runtime/{chunk-GYIXXQAO.js → chunk-ICKGAKWX.js} +23 -59
- package/dist/node-runtime/{chunk-X3PGBLQ7.js → chunk-IHHTWSXN.js} +9 -9
- package/dist/node-runtime/{chunk-DAPBPCBP.js → chunk-IPP5BIV5.js} +25 -3
- package/dist/node-runtime/{chunk-QFWG2RVL.js → chunk-IXG6F4NT.js} +11 -0
- package/dist/node-runtime/{chunk-L24TPBS4.js → chunk-JEK35V2M.js} +45 -31
- package/dist/node-runtime/{chunk-RDDAZOMU.js → chunk-JL4HYQXK.js} +1 -1
- package/dist/node-runtime/{chunk-2HMIRK7W.js → chunk-LHV3V67B.js} +5 -5
- package/dist/node-runtime/{chunk-UAEOTO52.js → chunk-MNQXDFPV.js} +6 -2
- package/dist/node-runtime/{chunk-MPKSOJBT.js → chunk-NHATCSOI.js} +4 -7
- package/dist/node-runtime/{chunk-RMQZU2YU.js → chunk-NNNR3QIY.js} +1 -1
- package/dist/node-runtime/{chunk-2KIPT4HJ.js → chunk-PWHTSQC4.js} +83 -21
- package/dist/node-runtime/{chunk-RWTKOC3B.js → chunk-QBTJG3UM.js} +1 -1
- package/dist/node-runtime/{chunk-RCR3XAQY.js → chunk-QT3F6UEV.js} +233 -169
- package/dist/node-runtime/{chunk-GS42T6MX.js → chunk-QW3AAHWN.js} +1 -1
- package/dist/node-runtime/{chunk-DVQSHCVP.js → chunk-R4WSB2MQ.js} +5 -5
- package/dist/node-runtime/{chunk-B4HP6ZWM.js → chunk-RHCGYWO7.js} +1 -1
- package/dist/node-runtime/{chunk-2CFDTH5B.js → chunk-RLGY2QIL.js} +45 -59
- package/dist/node-runtime/{chunk-CDVHZOOK.js → chunk-RY3FJ6WI.js} +29 -27
- package/dist/node-runtime/{chunk-KKUTQQV7.js → chunk-RYRGL7P4.js} +1 -1
- package/dist/node-runtime/{chunk-I54LGHWM.js → chunk-STMX7W5I.js} +3 -3
- package/dist/node-runtime/chunk-SWWHZ2RI.js +158 -0
- package/dist/node-runtime/{chunk-5Q4A37RB.js → chunk-TCT6PCUR.js} +32 -11
- package/dist/node-runtime/{chunk-P7XBVXGT.js → chunk-U3YVZ6UC.js} +18 -14
- package/dist/node-runtime/{chunk-D5UCKPBQ.js → chunk-UBWW2PID.js} +1 -1
- package/dist/node-runtime/{chunk-E75WFZ33.js → chunk-UNUZICC4.js} +3 -3
- package/dist/node-runtime/{chunk-RAK2QA2B.js → chunk-UYRKUKFE.js} +4 -4
- package/dist/node-runtime/{chunk-LWJXTA6Z.js → chunk-VSUEAI7O.js} +1377 -45
- package/dist/node-runtime/{chunk-NAY6UUQZ.js → chunk-WDIVLMOH.js} +1 -1
- package/dist/node-runtime/{chunk-E24EO34J.js → chunk-WPXUR3HE.js} +1 -1
- package/dist/node-runtime/{chunk-SLVOAQOY.js → chunk-WXYNALHD.js} +113 -1
- package/dist/node-runtime/{chunk-KJ6DWS3K.js → chunk-XEOCUEUJ.js} +121 -60
- package/dist/node-runtime/chunk-YD3IZAZ7.js +47 -0
- package/dist/node-runtime/chunk-YSB6URMT.js +41 -0
- package/dist/node-runtime/{chunk-YWOJIGFY.js → chunk-ZEVFBFNF.js} +95 -142
- package/dist/node-runtime/{chunk-5B6VKFEV.js → chunk-ZIQUS5QO.js} +1 -1
- package/dist/node-runtime/cli-runtime.js +4 -4
- package/dist/node-runtime/{command-FSBU2EVZ.js → command-YRT7I2BW.js} +5 -5
- package/dist/node-runtime/{commands-NAAL7KNT.js → commands-2ETOWWRA.js} +16 -16
- package/dist/node-runtime/{commands-EMBQQVVT.js → commands-D6A6H4TS.js} +11 -18
- package/dist/node-runtime/{config-QDD5PUE2.js → config-CU7M7BTK.js} +1 -1
- package/dist/node-runtime/{config-D4QUPAHX.js → config-DS7XLMEM.js} +2 -2
- package/dist/node-runtime/{direct-tool-executor-4D7UXYU4.js → direct-tool-executor-2QJXVQD2.js} +6 -11
- package/dist/node-runtime/{exa-LL64QZR2.js → exa-6VBZNPGE.js} +1 -1
- package/dist/node-runtime/{export-html-VM4J2MNR.js → export-html-DBQRRMAY.js} +4 -4
- package/dist/node-runtime/{extension-input-E7BJZ35H.js → extension-input-VBBMX7YV.js} +5 -5
- package/dist/node-runtime/{extension-selector-WU42XDTU.js → extension-selector-T5AOG5XB.js} +5 -5
- package/dist/node-runtime/{extract-EQJE7FZZ.js → extract-BFX2N35A.js} +3 -3
- package/dist/node-runtime/{gateway-DQM333YV.js → gateway-V6K2CDWN.js} +51 -42
- package/dist/node-runtime/{gemini-search-35OCRFLN.js → gemini-search-C66QHDT6.js} +2 -2
- package/dist/node-runtime/{gemini-url-context-UQY3PHHW.js → gemini-url-context-T7DEK73R.js} +3 -3
- package/dist/node-runtime/{github-extract-F64RZOEA.js → github-extract-HOGE3D6F.js} +107 -38
- package/dist/node-runtime/{goal-NJEE5CTU.js → goal-J7TYMOBK.js} +14 -8
- package/dist/node-runtime/index.js +51 -48
- package/dist/node-runtime/{init-P5AUV77I.js → init-JBQJIPYI.js} +3 -6
- package/dist/node-runtime/{install-cli-NN4YAU44.js → install-cli-INGHIVBY.js} +30 -25
- package/dist/node-runtime/interactive-mode-ASZ7APYP.js +75 -0
- package/dist/node-runtime/{interactive-view-NGFAMHPW.js → interactive-view-K33PM4OS.js} +8 -8
- package/dist/node-runtime/{lsp-manager-3ASUSO4T.js → lsp-manager-S554V5HR.js} +240 -155
- package/dist/node-runtime/{lunr-browser-IR7TL3J7.js → lunr-browser-H4FDOR3C.js} +7 -7
- package/dist/node-runtime/{lunr-computer-use-Y23CCDIJ.js → lunr-computer-use-VDP2QNRQ.js} +9 -9
- package/dist/node-runtime/{lunr-cron-USHC4LXH.js → lunr-cron-WD3YH4CR.js} +93 -80
- package/dist/node-runtime/main.js +43 -41
- package/dist/node-runtime/{mobile-commands-O5LCHL32.js → mobile-commands-ICUXFW5V.js} +12 -12
- package/dist/node-runtime/{model-runtime-OO5HFLWE.js → model-runtime-MZ2JMDV4.js} +4 -4
- package/dist/node-runtime/{openai-search-B3MSNCQA.js → openai-search-K72LJDYN.js} +1 -1
- package/dist/node-runtime/{package-manager-cli-Q7BL6KZO.js → package-manager-cli-CYM262SI.js} +20 -20
- package/dist/node-runtime/{parallel-AI2MNSCU.js → parallel-X724NCNU.js} +1 -1
- package/dist/node-runtime/{perplexity-QVJW3I35.js → perplexity-RDHQHVMK.js} +2 -2
- package/dist/node-runtime/{pi-intercom-QM53RLTS.js → pi-intercom-NHHEPBMI.js} +2 -2
- package/dist/node-runtime/{pi-mcp-adapter-3PHF4KZ4.js → pi-mcp-adapter-PP3GQJQ2.js} +98 -94
- package/dist/node-runtime/{pi-ollama-cloud-2F3Y2QNM.js → pi-ollama-cloud-4MNWIMFN.js} +11 -24
- package/dist/node-runtime/{pi-prompt-template-model-QWTCGLJU.js → pi-prompt-template-model-FTGELLS5.js} +32 -36
- package/dist/node-runtime/{pi-subagents-7IBSSGEW.js → pi-subagents-QPU3OXE4.js} +114 -167
- package/dist/node-runtime/{pi-web-access-WTGMNZ32.js → pi-web-access-Z3LP246C.js} +144 -108
- package/dist/node-runtime/{print-mode-XQ76CYMT.js → print-mode-2XHN5SUA.js} +3 -3
- package/dist/node-runtime/{process-registry-4FAKZQOL.js → process-registry-Q4QWIU33.js} +3 -3
- package/dist/node-runtime/{proxy-modes-5FAPSZEZ.js → proxy-modes-VEGC6QG5.js} +8 -15
- package/dist/node-runtime/rpc-entry.js +43 -41
- package/dist/node-runtime/{rpc-mode-O3XV4SID.js → rpc-mode-32DHJPEJ.js} +4 -4
- package/dist/node-runtime/{runtime-4VA6JKNF.js → runtime-EDUUGAQD.js} +56 -46
- package/dist/node-runtime/{runtime-EFPPD2UW.js → runtime-UGXM4NPQ.js} +2 -2
- package/dist/node-runtime/{runtime-bridges-7WVCLI76.js → runtime-bridges-DNKMNJCF.js} +7 -7
- package/dist/node-runtime/{service-MDQIPQ26.js → service-IHLGFLBT.js} +6 -4
- package/dist/node-runtime/{session-handoff-GWARVEWT.js → session-handoff-LYH53ESV.js} +4 -4
- package/dist/node-runtime/{session-manager-JB5J6XBN.js → session-manager-ZJ3N5Q74.js} +3 -3
- package/dist/node-runtime/{session-selector-GIM4DHQ2.js → session-selector-I73U3EIO.js} +7 -7
- package/dist/node-runtime/{settings-manager-DJDM5AHM.js → settings-manager-P2TKGYTR.js} +5 -5
- package/dist/node-runtime/{setup-JBKOLJ6F.js → setup-H7CCELIL.js} +15 -1
- package/dist/node-runtime/{setup-PFBWRNUI.js → setup-OLQ4GXWS.js} +17 -17
- package/dist/node-runtime/{src-IVPNZ2BX.js → src-6RV4PXKJ.js} +64 -36
- package/dist/node-runtime/{subagent-executor-LPZ4BHWE.js → subagent-executor-UI6SHG3X.js} +412 -288
- package/dist/node-runtime/{tavily-WEZFVFP7.js → tavily-KZBFYQB6.js} +1 -1
- package/dist/node-runtime/{theme-UOO5RVFN.js → theme-YLVZKKZD.js} +2 -2
- package/dist/node-runtime/{trust-manager-MMISNCYO.js → trust-manager-ZCU76D23.js} +2 -2
- package/dist/node-runtime/{update-cli-HNMOTNGX.js → update-cli-F3XXJANQ.js} +6 -6
- package/dist/node-runtime/{usage-service-LFB2SWYV.js → usage-service-CPAGBED5.js} +1 -1
- package/dist/node-runtime/{video-extract-OOZHR7SU.js → video-extract-UPKYIBW3.js} +3 -3
- package/dist/node-runtime/{workflow-OHPBEFO4.js → workflow-ICDI4N3J.js} +208 -78
- package/dist/node-runtime/{youtube-extract-FNPAUNHU.js → youtube-extract-77NT7FWH.js} +4 -4
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +25 -10
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +2 -0
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/paths.d.ts +4 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +33 -2
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/sanitize-terminal-text.d.ts +7 -0
- package/dist/utils/sanitize-terminal-text.d.ts.map +1 -0
- package/dist/utils/sanitize-terminal-text.js +67 -0
- package/dist/utils/sanitize-terminal-text.js.map +1 -0
- package/docs/browser.md +1 -1
- package/docs/custom-provider.md +3 -3
- package/docs/extensions.md +8 -4
- package/docs/features.md +25 -7
- package/docs/keybindings.md +1 -1
- package/docs/models.md +5 -5
- package/docs/packages.md +1 -1
- package/docs/providers.md +2 -2
- package/docs/rpc.md +7 -7
- package/docs/security.md +10 -5
- package/docs/sessions.md +2 -2
- package/docs/skills.md +1 -1
- package/docs/terminal-setup.md +7 -7
- package/docs/themes.md +1 -1
- package/docs/usage.md +1 -1
- package/examples/extensions/auto-commit-on-exit.ts +1 -1
- package/examples/extensions/bash-spawn-hook.ts +1 -1
- package/examples/extensions/built-in-tool-renderer.ts +1 -1
- package/examples/extensions/claude-rules.ts +1 -1
- package/examples/extensions/commands.ts +1 -1
- package/examples/extensions/custom-compaction.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +3 -3
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/doom-overlay/index.ts +1 -1
- package/examples/extensions/git-merge-and-resolve.ts +2 -2
- package/examples/extensions/gondolin/index.ts +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/hidden-thinking-label.ts +1 -1
- package/examples/extensions/inline-bash.ts +2 -2
- package/examples/extensions/input-transform-streaming.ts +2 -2
- package/examples/extensions/input-transform.ts +2 -2
- package/examples/extensions/interactive-shell.ts +1 -1
- package/examples/extensions/kimi-deferred-tools.ts +1 -1
- package/examples/extensions/mac-system-theme.ts +1 -1
- package/examples/extensions/minimal-mode.ts +1 -1
- package/examples/extensions/modal-editor.ts +1 -1
- package/examples/extensions/model-status.ts +1 -1
- package/examples/extensions/notify.ts +3 -3
- package/examples/extensions/overlay-qa-tests.ts +1 -1
- package/examples/extensions/overlay-test.ts +1 -1
- package/examples/extensions/pirate.ts +1 -1
- package/examples/extensions/preset.ts +3 -3
- package/examples/extensions/project-trust.ts +4 -4
- package/examples/extensions/prompt-customizer.ts +1 -1
- package/examples/extensions/rainbow-editor.ts +1 -1
- package/examples/extensions/rpc-demo.ts +1 -1
- package/examples/extensions/sandbox/index.ts +7 -7
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/shutdown-command.ts +5 -5
- package/examples/extensions/ssh.ts +2 -2
- package/examples/extensions/subagent/README.md +3 -3
- package/examples/extensions/subagent/index.ts +2 -2
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/extensions/tool-override.ts +1 -1
- package/examples/extensions/tools.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/extensions/working-indicator.ts +1 -1
- package/examples/extensions/working-message-test.ts +1 -1
- package/examples/sdk/01-minimal.ts +1 -1
- package/examples/sdk/03-custom-prompt.ts +1 -1
- package/examples/sdk/04-skills.ts +1 -1
- package/examples/sdk/06-extensions.ts +2 -2
- package/examples/sdk/08-prompt-templates.ts +1 -1
- package/install-lock/package-lock.json +24 -24
- package/install-lock/package.json +2 -2
- package/npm-shrinkwrap.json +60 -24
- package/package.json +9 -9
- package/dist/modes/interactive/components/exit-card.d.ts +0 -22
- package/dist/modes/interactive/components/exit-card.d.ts.map +0 -1
- package/dist/modes/interactive/components/exit-card.js +0 -69
- package/dist/modes/interactive/components/exit-card.js.map +0 -1
- package/dist/node-runtime/agent-session-services-5YXS2PLF.js +0 -51
- package/dist/node-runtime/chunk-2IDTZAG5.js +0 -1415
- package/dist/node-runtime/chunk-3MISGG4S.js +0 -769
- package/dist/node-runtime/chunk-4HXHDDCF.js +0 -16
- package/dist/node-runtime/chunk-5B5QN3ZQ.js +0 -356
- package/dist/node-runtime/chunk-7IQGBKBJ.js +0 -2033
- package/dist/node-runtime/chunk-AUXVGBO4.js +0 -19
- package/dist/node-runtime/chunk-PTFBPO3C.js +0 -50
- package/dist/node-runtime/interactive-mode-YOHZVMKX.js +0 -74
- package/dist/node-runtime/mcp-auth-flow-QVLFVLEO.js +0 -33
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { collectChildUsage, collectUsageRequests, totalChildUsage, totalRequestUsage, } from "./usage-accounting.js";
|
|
1
2
|
/**
|
|
2
3
|
* AgentSession - Core abstraction for agent lifecycle and session management.
|
|
3
4
|
*
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
*/
|
|
15
16
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
16
17
|
import { basename, dirname, join, resolve } from "node:path";
|
|
17
|
-
import { clampThinkingLevel, cleanupSessionResources, getSupportedThinkingLevels, isContextOverflow, isRetryableAssistantError, modelsAreEqual, resetApiProviders, streamSimple, } from "@ashx-j/lunr-ai/compat";
|
|
18
|
+
import { clampThinkingLevel, cleanupSessionResources, estimateContextTokens as estimateRequestContextTokens, getSupportedThinkingLevels, isContextOverflow, isRetryableAssistantError, modelsAreEqual, resetApiProviders, streamSimple, } from "@ashx-j/lunr-ai/compat";
|
|
18
19
|
import { getAgentDir } from "../config.js";
|
|
19
20
|
import { getThemeByName, theme } from "../modes/interactive/theme/theme.js";
|
|
20
21
|
import { stripFrontmatter } from "../utils/frontmatter.js";
|
|
@@ -27,13 +28,16 @@ import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
|
|
|
27
28
|
import { ExtensionRunner, wrapRegisteredTools, } from "./extensions/index.js";
|
|
28
29
|
import { emitSessionShutdownEvent } from "./extensions/runner.js";
|
|
29
30
|
import { MEMORY_TOOL_NAMES } from "./memory-cap.js";
|
|
31
|
+
import { convertToLlm } from "./messages.js";
|
|
30
32
|
import { isUserInstructionsPath, loadSelectedUserInstructions } from "./model-instructions.js";
|
|
31
33
|
import { ModelRegistry } from "./model-registry.js";
|
|
32
|
-
import { gateToolCall } from "./permissions.js";
|
|
34
|
+
import { AUTO_MODE_ADDENDUM, deletePermissionContext, gateToolCall, getPermissionMode, initializePermissionContext, setPermissionMode, } from "./permissions.js";
|
|
35
|
+
import { READ_ONLY_MODE_ADDENDUM } from "./plan-mode.js";
|
|
33
36
|
import { expandPromptTemplate } from "./prompt-templates.js";
|
|
34
37
|
import { rollbackSnapshotBeforeWrite } from "./rollback.js";
|
|
35
38
|
import { CURRENT_SESSION_VERSION, getLatestCompactionEntry } from "./session-manager.js";
|
|
36
39
|
import { createSyntheticSourceInfo } from "./source-info.js";
|
|
40
|
+
import { isSubagentChildProcess, resolveChildRuntimePermissionMode, SUBAGENT_CHILD_PERMISSION_ENV, } from "./subagent-permission-inherit.js";
|
|
37
41
|
import { registerSubagentWaitInterruptionOwner, } from "./subagent-wait-interruption.js";
|
|
38
42
|
import { buildSystemPrompt } from "./system-prompt.js";
|
|
39
43
|
import { measureStartup } from "./timings.js";
|
|
@@ -113,7 +117,12 @@ export class AgentSession {
|
|
|
113
117
|
_retryAbortController = undefined;
|
|
114
118
|
_retryAttempt = 0;
|
|
115
119
|
// Bash execution state
|
|
116
|
-
|
|
120
|
+
_bashOperations = new Map();
|
|
121
|
+
_operations = new Set();
|
|
122
|
+
_closing = false;
|
|
123
|
+
_disposed = false;
|
|
124
|
+
_drainPromise;
|
|
125
|
+
_shutdownPromise;
|
|
117
126
|
_pendingBashMessages = [];
|
|
118
127
|
// Extension system
|
|
119
128
|
_extensionRunner;
|
|
@@ -146,7 +155,7 @@ export class AgentSession {
|
|
|
146
155
|
_baseSystemPrompt = "";
|
|
147
156
|
_baseSystemPromptOptions;
|
|
148
157
|
_systemPromptOverride;
|
|
149
|
-
//
|
|
158
|
+
// Optional host-owned prompt append, separate from session permission guidance.
|
|
150
159
|
_systemPromptAppend;
|
|
151
160
|
// lunr: core-owned tool-call gates (read-only mode) checked before extension tool_call handlers
|
|
152
161
|
_toolCallGates = [];
|
|
@@ -154,6 +163,13 @@ export class AgentSession {
|
|
|
154
163
|
this.agent = config.agent;
|
|
155
164
|
this.sessionManager = config.sessionManager;
|
|
156
165
|
this.settingsManager = config.settingsManager;
|
|
166
|
+
const permissionMode = config.permissionMode ??
|
|
167
|
+
(isSubagentChildProcess()
|
|
168
|
+
? resolveChildRuntimePermissionMode(process.env[SUBAGENT_CHILD_PERMISSION_ENV])
|
|
169
|
+
: undefined) ??
|
|
170
|
+
this.sessionManager.getPermissionMode() ??
|
|
171
|
+
this.settingsManager.getDefaultPermissionMode();
|
|
172
|
+
initializePermissionContext(this.sessionId, permissionMode, config.permissionMode);
|
|
157
173
|
this._scopedModels = config.scopedModels ?? [];
|
|
158
174
|
this._resourceLoader = config.resourceLoader;
|
|
159
175
|
this._customTools = config.customTools ?? [];
|
|
@@ -341,12 +357,17 @@ export class AgentSession {
|
|
|
341
357
|
: undefined);
|
|
342
358
|
this.agent.prepareNextTurnWithContext = async (turn, signal) => {
|
|
343
359
|
const previousSnapshot = await previousPrepareNextTurnWithContext?.(turn, signal);
|
|
344
|
-
let previousContext =
|
|
360
|
+
let previousContext = {
|
|
361
|
+
...(previousSnapshot?.context ?? turn.context),
|
|
362
|
+
systemPrompt: this._withSystemPromptAppend(this._systemPromptOverride ?? this._baseSystemPrompt),
|
|
363
|
+
tools: this.agent.state.tools.slice(),
|
|
364
|
+
};
|
|
345
365
|
const model = this.model;
|
|
346
366
|
const settings = this.settingsManager.getCompactionSettings();
|
|
347
367
|
if (model?.provider === "openai-codex" &&
|
|
348
368
|
settings.enabled &&
|
|
349
|
-
shouldCompact(
|
|
369
|
+
shouldCompact(estimateRequestContextTokens({ ...previousContext, messages: convertToLlm(previousContext.messages) })
|
|
370
|
+
.tokens, model.contextWindow, settings)) {
|
|
350
371
|
const previousCompactionId = getLatestCompactionEntry(this.sessionManager.getBranch())?.id;
|
|
351
372
|
await this._runAutoCompaction("threshold", true);
|
|
352
373
|
const currentCompaction = getLatestCompactionEntry(this.sessionManager.getBranch());
|
|
@@ -435,6 +456,8 @@ export class AgentSession {
|
|
|
435
456
|
}
|
|
436
457
|
}
|
|
437
458
|
}
|
|
459
|
+
if (event.type === "message_end")
|
|
460
|
+
this._activePromptRun?.completion?.messages.push(event.message);
|
|
438
461
|
// Emit to extensions first
|
|
439
462
|
await this._emitExtensionEvent(event);
|
|
440
463
|
// Notify all listeners
|
|
@@ -659,27 +682,80 @@ export class AgentSession {
|
|
|
659
682
|
}
|
|
660
683
|
assertCanStartWork() {
|
|
661
684
|
this.sessionManager.assertWritable();
|
|
685
|
+
if (this._closing)
|
|
686
|
+
throw new Error("Session is closing. New work is not accepted.");
|
|
662
687
|
if (this.transferring)
|
|
663
688
|
throw new Error("Session transfer is in progress. Wait or reclaim the session.");
|
|
664
689
|
}
|
|
665
|
-
|
|
690
|
+
/** Stop admission synchronously, retaining listeners and session ownership. */
|
|
691
|
+
stopAdmission() {
|
|
692
|
+
this._closing = true;
|
|
666
693
|
this._invalidateWaitPromptHandoffs("Session closed before the pending prompt could run.");
|
|
667
|
-
|
|
668
|
-
|
|
694
|
+
}
|
|
695
|
+
async _trackOperation(operation) {
|
|
696
|
+
let settle = () => { };
|
|
697
|
+
const completion = new Promise((resolve) => {
|
|
698
|
+
settle = resolve;
|
|
699
|
+
});
|
|
700
|
+
this._operations.add(completion);
|
|
669
701
|
try {
|
|
670
|
-
|
|
671
|
-
this.abortCompaction();
|
|
672
|
-
this.abortBranchSummary();
|
|
673
|
-
this.abortBash();
|
|
674
|
-
this.agent.abort();
|
|
702
|
+
return await operation();
|
|
675
703
|
}
|
|
676
|
-
|
|
677
|
-
|
|
704
|
+
finally {
|
|
705
|
+
this._operations.delete(completion);
|
|
706
|
+
settle();
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
/** Cancel owned work and wait for final persistence before extension shutdown. */
|
|
710
|
+
drain() {
|
|
711
|
+
if (this._drainPromise)
|
|
712
|
+
return this._drainPromise;
|
|
713
|
+
this.stopAdmission();
|
|
714
|
+
if (this._activePromptRun)
|
|
715
|
+
this._activePromptRun.gracefulStopRequested = true;
|
|
716
|
+
this.abortRetry();
|
|
717
|
+
this.abortCompaction();
|
|
718
|
+
this.abortBranchSummary();
|
|
719
|
+
this.abortBash();
|
|
720
|
+
this.clearQueue();
|
|
721
|
+
this.agent.abort();
|
|
722
|
+
this._drainPromise = (async () => {
|
|
723
|
+
await Promise.all([...this._operations]);
|
|
724
|
+
await this.waitForIdle();
|
|
725
|
+
await this.agent.waitForIdle();
|
|
726
|
+
this._flushPendingBashMessages();
|
|
727
|
+
})();
|
|
728
|
+
return this._drainPromise;
|
|
729
|
+
}
|
|
730
|
+
/** Await cancellation and persistence, then release listeners and ownership. */
|
|
731
|
+
shutdown() {
|
|
732
|
+
if (!this._shutdownPromise) {
|
|
733
|
+
this._shutdownPromise = this.drain().then(() => this._disposeSettled());
|
|
678
734
|
}
|
|
735
|
+
return this._shutdownPromise;
|
|
736
|
+
}
|
|
737
|
+
/** Compatibility wrapper. Use await shutdown() when release must be complete. */
|
|
738
|
+
dispose() {
|
|
739
|
+
if (this._operations.size === 0 && !this._isAgentRunActive && !this.agent.state.isStreaming) {
|
|
740
|
+
this.stopAdmission();
|
|
741
|
+
this._disposeSettled();
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
void this.shutdown().catch(() => {
|
|
745
|
+
/* Awaitable callers receive shutdown failures. */
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
_disposeSettled() {
|
|
749
|
+
if (this._disposed)
|
|
750
|
+
return;
|
|
751
|
+
this._disposed = true;
|
|
752
|
+
for (const unregister of this._unregisterSubagentWaitInterruptionOwners.splice(0))
|
|
753
|
+
unregister();
|
|
679
754
|
this._extensionRunner.invalidate("This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload().");
|
|
680
755
|
this._disconnectFromAgent();
|
|
681
756
|
this._eventListeners = [];
|
|
682
757
|
cleanupSessionResources(this.sessionId);
|
|
758
|
+
deletePermissionContext(this.sessionId);
|
|
683
759
|
this.sessionManager.dispose();
|
|
684
760
|
}
|
|
685
761
|
// =========================================================================
|
|
@@ -737,8 +813,23 @@ export class AgentSession {
|
|
|
737
813
|
this._systemPromptAppend = next;
|
|
738
814
|
this.agent.state.systemPrompt = this._withSystemPromptAppend(this._systemPromptOverride ?? this._baseSystemPrompt);
|
|
739
815
|
}
|
|
816
|
+
get permissionMode() {
|
|
817
|
+
return getPermissionMode(this.sessionId);
|
|
818
|
+
}
|
|
819
|
+
_permissionAddendum(mode) {
|
|
820
|
+
return mode === "read-only" ? READ_ONLY_MODE_ADDENDUM : mode === "auto" ? AUTO_MODE_ADDENDUM : undefined;
|
|
821
|
+
}
|
|
822
|
+
/** Update the same permission context consulted by headless and interactive tools. */
|
|
823
|
+
setPermissionMode(mode) {
|
|
824
|
+
this.assertCanStartWork();
|
|
825
|
+
setPermissionMode(mode, this.sessionId);
|
|
826
|
+
this.sessionManager.setPermissionMode(mode);
|
|
827
|
+
this.agent.state.systemPrompt = this._withSystemPromptAppend(this._systemPromptOverride ?? this._baseSystemPrompt);
|
|
828
|
+
}
|
|
740
829
|
_withSystemPromptAppend(prompt) {
|
|
741
|
-
return this.
|
|
830
|
+
return [prompt, this._permissionAddendum(this.permissionMode), this._systemPromptAppend]
|
|
831
|
+
.filter(Boolean)
|
|
832
|
+
.join("\n\n");
|
|
742
833
|
}
|
|
743
834
|
/** Current retry attempt (0 if not retrying) */
|
|
744
835
|
get retryAttempt() {
|
|
@@ -944,28 +1035,67 @@ export class AgentSession {
|
|
|
944
1035
|
for (const reservation of handoff.reservations.splice(0))
|
|
945
1036
|
reservation.reject(error);
|
|
946
1037
|
}
|
|
947
|
-
|
|
1038
|
+
_reservePromptRun() {
|
|
1039
|
+
this.assertCanStartWork();
|
|
1040
|
+
if (this._isAgentRunActive || this._manualCompactionPromise) {
|
|
1041
|
+
throw new Error("Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.");
|
|
1042
|
+
}
|
|
948
1043
|
const run = { waits: new Set(), gracefulStopRequested: false };
|
|
949
1044
|
this._activePromptRun = run;
|
|
950
1045
|
this._isAgentRunActive = true;
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1046
|
+
return run;
|
|
1047
|
+
}
|
|
1048
|
+
async _releasePromptRun(run) {
|
|
1049
|
+
if (this._activePromptRun !== run)
|
|
1050
|
+
return;
|
|
1051
|
+
this._activePromptRun = undefined;
|
|
1052
|
+
this._systemPromptOverride = undefined;
|
|
1053
|
+
this._flushPendingBashMessages();
|
|
1054
|
+
await this._emitAgentSettled();
|
|
1055
|
+
}
|
|
1056
|
+
async _runAgentPrompt(messages, owner) {
|
|
1057
|
+
const run = owner ?? this._reservePromptRun();
|
|
1058
|
+
await this._trackOperation(async () => {
|
|
1059
|
+
try {
|
|
1060
|
+
this.assertCanStartWork();
|
|
1061
|
+
if (run.gracefulStopRequested)
|
|
1062
|
+
throw new Error("Prompt was cancelled during preparation.");
|
|
1063
|
+
await this.agent.prompt(Array.isArray(messages) ? messages : [messages], {
|
|
1064
|
+
consumeFollowUps: !run.completion,
|
|
1065
|
+
});
|
|
1066
|
+
while (await this._handlePostAgentRun(run)) {
|
|
1067
|
+
if (run.gracefulStopRequested || this._closing || run.completion?.cancelled)
|
|
1068
|
+
break;
|
|
1069
|
+
await this.agent.continue({ consumeFollowUps: !run.completion });
|
|
1070
|
+
}
|
|
1071
|
+
if (run.completion) {
|
|
1072
|
+
const completion = run.completion;
|
|
1073
|
+
run.completion = undefined;
|
|
1074
|
+
completion.detach?.();
|
|
1075
|
+
const hasQueuedWork = !run.gracefulStopRequested && !this._closing && this.agent.hasQueuedMessages();
|
|
1076
|
+
if (!hasQueuedWork)
|
|
1077
|
+
await this._releasePromptRun(run);
|
|
1078
|
+
completion.settle();
|
|
1079
|
+
// Later queued work retains normal session lifecycle, with a fresh queue admission.
|
|
1080
|
+
if (hasQueuedWork) {
|
|
1081
|
+
await this.agent.continueQueued();
|
|
1082
|
+
while (await this._handlePostAgentRun(run)) {
|
|
1083
|
+
if (run.gracefulStopRequested || this._closing)
|
|
1084
|
+
break;
|
|
1085
|
+
await this.agent.continue();
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
955
1089
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
this._systemPromptOverride = undefined;
|
|
961
|
-
this._flushPendingBashMessages();
|
|
962
|
-
await this._emitAgentSettled();
|
|
963
|
-
}
|
|
1090
|
+
finally {
|
|
1091
|
+
await this._releasePromptRun(run);
|
|
1092
|
+
}
|
|
1093
|
+
});
|
|
964
1094
|
}
|
|
965
1095
|
async _handlePostAgentRun(run) {
|
|
966
1096
|
const msg = this._lastAssistantMessage;
|
|
967
1097
|
this._lastAssistantMessage = undefined;
|
|
968
|
-
if (!msg || run.gracefulStopRequested) {
|
|
1098
|
+
if (!msg || run.gracefulStopRequested || run.completion?.signal?.aborted) {
|
|
969
1099
|
return false;
|
|
970
1100
|
}
|
|
971
1101
|
// lunr: quota-dead or auth-invalid keys rotate immediately — same-key backoff
|
|
@@ -992,9 +1122,9 @@ export class AgentSession {
|
|
|
992
1122
|
if (await this._checkCompaction(msg)) {
|
|
993
1123
|
return true;
|
|
994
1124
|
}
|
|
995
|
-
//
|
|
996
|
-
//
|
|
997
|
-
return this.agent.hasQueuedMessages();
|
|
1125
|
+
// Correlated requests leave follow-ups queued. Ordinary runs also continue
|
|
1126
|
+
// messages queued by agent_end extension handlers.
|
|
1127
|
+
return !run.completion && this.agent.hasQueuedMessages();
|
|
998
1128
|
}
|
|
999
1129
|
/**
|
|
1000
1130
|
* Send a prompt to the agent.
|
|
@@ -1007,36 +1137,116 @@ export class AgentSession {
|
|
|
1007
1137
|
*/
|
|
1008
1138
|
async prompt(text, options) {
|
|
1009
1139
|
this.assertCanStartWork();
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1012
|
-
|
|
1140
|
+
const commandName = text.startsWith("/") ? text.slice(1).split(" ")[0] : undefined;
|
|
1141
|
+
// Lifecycle commands may replace the session; they cannot own a run they must drain.
|
|
1142
|
+
if ((options?.expandPromptTemplates ?? true) && commandName && this._extensionRunner.getCommand(commandName)) {
|
|
1143
|
+
try {
|
|
1144
|
+
await this._tryExecuteExtensionCommand(text);
|
|
1145
|
+
options?.preflightResult?.(true);
|
|
1146
|
+
}
|
|
1147
|
+
catch (error) {
|
|
1148
|
+
options?.preflightResult?.(false);
|
|
1149
|
+
throw error;
|
|
1150
|
+
}
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
return this._trackOperation(() => this._prompt(text, options));
|
|
1154
|
+
}
|
|
1155
|
+
async _prompt(text, options, completion) {
|
|
1156
|
+
let run;
|
|
1157
|
+
let accepted = false;
|
|
1013
1158
|
try {
|
|
1014
|
-
|
|
1159
|
+
this.assertCanStartWork();
|
|
1160
|
+
const wasStreaming = this.isStreaming;
|
|
1161
|
+
if (!wasStreaming) {
|
|
1162
|
+
run = this._reservePromptRun();
|
|
1163
|
+
run.completion = completion;
|
|
1164
|
+
if (completion?.signal) {
|
|
1165
|
+
const owner = run;
|
|
1166
|
+
const cancel = () => {
|
|
1167
|
+
if (this._activePromptRun !== owner || owner.completion !== completion)
|
|
1168
|
+
return;
|
|
1169
|
+
completion.cancelled = true;
|
|
1170
|
+
this.agent.abort();
|
|
1171
|
+
this.abortRetry();
|
|
1172
|
+
this._autoCompactionAbortController?.abort();
|
|
1173
|
+
};
|
|
1174
|
+
completion.signal.addEventListener("abort", cancel, { once: true });
|
|
1175
|
+
completion.detach = () => completion.signal?.removeEventListener("abort", cancel);
|
|
1176
|
+
completion.signal.throwIfAborted();
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
else if (!options?.streamingBehavior) {
|
|
1180
|
+
throw new Error("Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.");
|
|
1181
|
+
}
|
|
1182
|
+
const prepared = await this._preparePromptInput(text, options, wasStreaming ? options?.streamingBehavior : undefined);
|
|
1183
|
+
this.assertCanStartWork();
|
|
1184
|
+
run?.completion?.signal?.throwIfAborted();
|
|
1185
|
+
if (run?.gracefulStopRequested)
|
|
1186
|
+
throw new Error("Prompt was cancelled during preparation.");
|
|
1015
1187
|
if (!prepared) {
|
|
1016
|
-
|
|
1188
|
+
accepted = true;
|
|
1189
|
+
options?.preflightResult?.(true);
|
|
1017
1190
|
return;
|
|
1018
1191
|
}
|
|
1019
|
-
if (this.isStreaming) {
|
|
1020
|
-
if (
|
|
1021
|
-
throw new Error("Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.");
|
|
1022
|
-
}
|
|
1023
|
-
if (options.streamingBehavior === "followUp") {
|
|
1192
|
+
if (wasStreaming && this.isStreaming) {
|
|
1193
|
+
if (options?.streamingBehavior === "followUp")
|
|
1024
1194
|
await this._queueFollowUp(prepared.text, prepared.images);
|
|
1025
|
-
|
|
1026
|
-
else {
|
|
1195
|
+
else
|
|
1027
1196
|
await this._queueSteer(prepared.text, prepared.images);
|
|
1028
|
-
|
|
1029
|
-
preflightResult?.(true);
|
|
1197
|
+
accepted = true;
|
|
1198
|
+
options?.preflightResult?.(true);
|
|
1030
1199
|
return;
|
|
1031
1200
|
}
|
|
1032
|
-
|
|
1201
|
+
run ??= this._reservePromptRun();
|
|
1202
|
+
run.completion = completion;
|
|
1203
|
+
const messages = await this._createPromptMessages(prepared);
|
|
1204
|
+
this.assertCanStartWork();
|
|
1205
|
+
run.completion?.signal?.throwIfAborted();
|
|
1206
|
+
if (run.gracefulStopRequested)
|
|
1207
|
+
throw new Error("Prompt was cancelled during preparation.");
|
|
1208
|
+
accepted = true;
|
|
1209
|
+
options?.preflightResult?.(true);
|
|
1210
|
+
await this._runAgentPrompt(messages, run);
|
|
1033
1211
|
}
|
|
1034
1212
|
catch (error) {
|
|
1035
|
-
|
|
1213
|
+
if (!accepted)
|
|
1214
|
+
options?.preflightResult?.(false);
|
|
1036
1215
|
throw error;
|
|
1037
1216
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1217
|
+
finally {
|
|
1218
|
+
completion?.detach?.();
|
|
1219
|
+
if (run)
|
|
1220
|
+
await this._releasePromptRun(run);
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* Admit one scheduled request, including steering, retries and compaction.
|
|
1225
|
+
* Completes before later follow-ups; signal cancellation belongs only to this request.
|
|
1226
|
+
*/
|
|
1227
|
+
async promptWithCompletion(text, options) {
|
|
1228
|
+
this.assertCanStartWork();
|
|
1229
|
+
if (!this.isIdle || this.isBashRunning || this.isCompacting || this.pendingMessageCount > 0) {
|
|
1230
|
+
throw new Error("Session is busy. Retry the scheduled prompt after its work settles.");
|
|
1231
|
+
}
|
|
1232
|
+
if (text.startsWith("/") && (options?.expandPromptTemplates ?? true))
|
|
1233
|
+
this._throwIfExtensionCommand(text);
|
|
1234
|
+
options?.signal?.throwIfAborted();
|
|
1235
|
+
const messages = [];
|
|
1236
|
+
return new Promise((resolve, reject) => {
|
|
1237
|
+
const completion = {
|
|
1238
|
+
messages,
|
|
1239
|
+
signal: options?.signal,
|
|
1240
|
+
settle: () => {
|
|
1241
|
+
if (completion.cancelled)
|
|
1242
|
+
reject(completion.signal?.reason);
|
|
1243
|
+
else
|
|
1244
|
+
resolve({ messages });
|
|
1245
|
+
},
|
|
1246
|
+
};
|
|
1247
|
+
// Track the full session operation while returning only the admitted request's completion.
|
|
1248
|
+
void this._trackOperation(() => this._prompt(text, options, completion)).then(completion.settle, reject);
|
|
1249
|
+
});
|
|
1040
1250
|
}
|
|
1041
1251
|
async _preparePromptInput(text, options, streamingBehavior) {
|
|
1042
1252
|
const expandPromptTemplates = options?.expandPromptTemplates ?? true;
|
|
@@ -1113,7 +1323,9 @@ export class AgentSession {
|
|
|
1113
1323
|
return messages;
|
|
1114
1324
|
}
|
|
1115
1325
|
async interruptSubagentWaitWithPrompt(text, options) {
|
|
1116
|
-
|
|
1326
|
+
this.assertCanStartWork();
|
|
1327
|
+
const previousAcceptance = this._waitPromptAcceptance;
|
|
1328
|
+
const acceptance = this._trackOperation(() => previousAcceptance.then(() => this._reserveWaitPrompt(text, options)));
|
|
1117
1329
|
this._waitPromptAcceptance = acceptance.then(() => { }, () => { });
|
|
1118
1330
|
return acceptance;
|
|
1119
1331
|
}
|
|
@@ -1147,6 +1359,9 @@ export class AgentSession {
|
|
|
1147
1359
|
}
|
|
1148
1360
|
throw error;
|
|
1149
1361
|
}
|
|
1362
|
+
this.assertCanStartWork();
|
|
1363
|
+
if (handoff.generation !== this._waitPromptGeneration)
|
|
1364
|
+
throw new Error("Pending prompt was cancelled during preparation.");
|
|
1150
1365
|
if (!prepared) {
|
|
1151
1366
|
if (handoff.reservations.length === 0 && this._waitPromptHandoff === handoff) {
|
|
1152
1367
|
this._waitPromptHandoff = undefined;
|
|
@@ -1176,17 +1391,21 @@ export class AgentSession {
|
|
|
1176
1391
|
handoff.generation === this._waitPromptGeneration &&
|
|
1177
1392
|
handoff.reservations.length > 0) {
|
|
1178
1393
|
const reservation = handoff.reservations[0];
|
|
1394
|
+
let run;
|
|
1179
1395
|
try {
|
|
1180
1396
|
this.assertCanStartWork();
|
|
1397
|
+
run = this._reservePromptRun();
|
|
1181
1398
|
const messages = await this._createPromptMessages(reservation.input);
|
|
1182
1399
|
handoff.accepting = false;
|
|
1183
|
-
await this._runAgentPrompt(messages);
|
|
1400
|
+
await this._runAgentPrompt(messages, run);
|
|
1184
1401
|
reservation.resolve();
|
|
1185
1402
|
}
|
|
1186
1403
|
catch (error) {
|
|
1187
1404
|
reservation.reject(error);
|
|
1188
1405
|
}
|
|
1189
1406
|
finally {
|
|
1407
|
+
if (run)
|
|
1408
|
+
await this._releasePromptRun(run);
|
|
1190
1409
|
if (handoff.reservations[0] === reservation)
|
|
1191
1410
|
handoff.reservations.shift();
|
|
1192
1411
|
}
|
|
@@ -1448,8 +1667,13 @@ export class AgentSession {
|
|
|
1448
1667
|
async abort() {
|
|
1449
1668
|
this._invalidateWaitPromptHandoffs("The active run was aborted before the pending prompt could run.");
|
|
1450
1669
|
this.abortRetry();
|
|
1670
|
+
if (this._activePromptRun && !this.agent.signal)
|
|
1671
|
+
this._activePromptRun.gracefulStopRequested = true;
|
|
1672
|
+
const bash = [...this._bashOperations.values()];
|
|
1673
|
+
this.abortBash();
|
|
1451
1674
|
this.agent.abort();
|
|
1452
1675
|
await this.waitForIdle();
|
|
1676
|
+
await Promise.all(bash);
|
|
1453
1677
|
}
|
|
1454
1678
|
async waitForIdle() {
|
|
1455
1679
|
if (this.isIdle) {
|
|
@@ -1690,12 +1914,13 @@ export class AgentSession {
|
|
|
1690
1914
|
* @param customInstructions Optional instructions for the compaction summary
|
|
1691
1915
|
*/
|
|
1692
1916
|
async compact(customInstructions) {
|
|
1917
|
+
this.assertCanStartWork();
|
|
1693
1918
|
const existing = this._latestCompactionResult();
|
|
1694
1919
|
if (existing)
|
|
1695
1920
|
return existing;
|
|
1696
1921
|
if (this._manualCompactionPromise)
|
|
1697
1922
|
return this._manualCompactionPromise;
|
|
1698
|
-
const promise = this._compact(customInstructions);
|
|
1923
|
+
const promise = this._trackOperation(() => this._compact(customInstructions));
|
|
1699
1924
|
this._manualCompactionPromise = promise;
|
|
1700
1925
|
try {
|
|
1701
1926
|
return await promise;
|
|
@@ -1706,16 +1931,15 @@ export class AgentSession {
|
|
|
1706
1931
|
}
|
|
1707
1932
|
}
|
|
1708
1933
|
async _compact(customInstructions) {
|
|
1709
|
-
this._disconnectFromAgent();
|
|
1710
1934
|
await this.abort();
|
|
1935
|
+
this.assertCanStartWork();
|
|
1711
1936
|
const existing = this._latestCompactionResult();
|
|
1712
|
-
if (existing)
|
|
1713
|
-
this._reconnectToAgent();
|
|
1937
|
+
if (existing)
|
|
1714
1938
|
return existing;
|
|
1715
|
-
|
|
1939
|
+
this._disconnectFromAgent();
|
|
1716
1940
|
this._compactionAbortController = new AbortController();
|
|
1717
|
-
this._emit({ type: "compaction_start", reason: "manual" });
|
|
1718
1941
|
try {
|
|
1942
|
+
this._emit({ type: "compaction_start", reason: "manual" });
|
|
1719
1943
|
if (!this.model) {
|
|
1720
1944
|
throw new Error(formatNoModelSelectedMessage());
|
|
1721
1945
|
}
|
|
@@ -1764,7 +1988,7 @@ export class AgentSession {
|
|
|
1764
1988
|
}
|
|
1765
1989
|
else {
|
|
1766
1990
|
// Generate compaction result
|
|
1767
|
-
const result = await compact(preparation, this.model, apiKey, headers, customInstructions, this._compactionAbortController.signal, this.thinkingLevel, this.agent.streamFn, env);
|
|
1991
|
+
const result = await compact(preparation, this.model, apiKey, headers, customInstructions, this._compactionAbortController.signal, this.thinkingLevel, this.agent.streamFn, env, (response) => this.sessionManager.appendRequestUsage("compaction", response));
|
|
1768
1992
|
summary = result.summary;
|
|
1769
1993
|
firstKeptEntryId = result.firstKeptEntryId;
|
|
1770
1994
|
tokensBefore = result.tokensBefore;
|
|
@@ -1998,7 +2222,7 @@ export class AgentSession {
|
|
|
1998
2222
|
}
|
|
1999
2223
|
else {
|
|
2000
2224
|
// Generate compaction result
|
|
2001
|
-
const compactResult = await compact(preparation, this.model, apiKey, headers, undefined, this._autoCompactionAbortController.signal, this.thinkingLevel, this.agent.streamFn, env);
|
|
2225
|
+
const compactResult = await compact(preparation, this.model, apiKey, headers, undefined, this._autoCompactionAbortController.signal, this.thinkingLevel, this.agent.streamFn, env, (response) => this.sessionManager.appendRequestUsage("compaction", response));
|
|
2002
2226
|
summary = compactResult.summary;
|
|
2003
2227
|
firstKeptEntryId = compactResult.firstKeptEntryId;
|
|
2004
2228
|
tokensBefore = compactResult.tokensBefore;
|
|
@@ -2046,9 +2270,9 @@ export class AgentSession {
|
|
|
2046
2270
|
}
|
|
2047
2271
|
return true;
|
|
2048
2272
|
}
|
|
2049
|
-
//
|
|
2050
|
-
//
|
|
2051
|
-
return this.agent.hasQueuedMessages();
|
|
2273
|
+
// Only ordinary runs continue queued requests after successful compaction.
|
|
2274
|
+
// Correlated completion must settle before those requests begin.
|
|
2275
|
+
return !this._activePromptRun?.completion && this.agent.hasQueuedMessages();
|
|
2052
2276
|
}
|
|
2053
2277
|
catch (error) {
|
|
2054
2278
|
const errorMessage = error instanceof Error ? error.message : "compaction failed";
|
|
@@ -2310,6 +2534,7 @@ export class AgentSession {
|
|
|
2310
2534
|
}, {
|
|
2311
2535
|
getModel: () => this.resolvedCatalogModel(),
|
|
2312
2536
|
isIdle: () => this.isIdle,
|
|
2537
|
+
promptWithCompletion: (text, options) => this.promptWithCompletion(text, options),
|
|
2313
2538
|
isProjectTrusted: () => this.settingsManager.isProjectTrusted(),
|
|
2314
2539
|
getSignal: () => this.agent.signal,
|
|
2315
2540
|
abort: () => {
|
|
@@ -2569,19 +2794,17 @@ export class AgentSession {
|
|
|
2569
2794
|
* false when rotation is impossible, leaving the error as the final message.
|
|
2570
2795
|
*/
|
|
2571
2796
|
async _tryRotateSubscriptionKey(message) {
|
|
2572
|
-
const
|
|
2573
|
-
if (!
|
|
2797
|
+
const requestKey = this._modelRuntime.getRequestSubscriptionKey(message);
|
|
2798
|
+
if (!requestKey)
|
|
2574
2799
|
return false;
|
|
2575
|
-
const providerId =
|
|
2800
|
+
const providerId = requestKey.providerId;
|
|
2576
2801
|
// A runtime --api-key override wins over auth.json in RuntimeCredentials.read(),
|
|
2577
2802
|
// so mirroring a rotated key into the store would have no effect — skip rotation.
|
|
2578
2803
|
if (this._modelRuntime.hasRuntimeApiKey(providerId))
|
|
2579
2804
|
return false;
|
|
2580
2805
|
const manager = this._modelRuntime.subscriptionManager;
|
|
2581
|
-
if ((await manager.list(providerId)).length < 2)
|
|
2582
|
-
return false;
|
|
2583
2806
|
const errorMessage = message.errorMessage ?? "Unknown error";
|
|
2584
|
-
const entry = await manager.rotateOnFailure(providerId, errorMessage);
|
|
2807
|
+
const entry = await manager.rotateOnFailure(providerId, errorMessage, requestKey.fingerprint);
|
|
2585
2808
|
if (!entry)
|
|
2586
2809
|
return false;
|
|
2587
2810
|
// Close out any in-flight retry indicator; a fresh key gets a fresh retry budget.
|
|
@@ -2630,21 +2853,29 @@ export class AgentSession {
|
|
|
2630
2853
|
*/
|
|
2631
2854
|
async executeBash(command, onChunk, options) {
|
|
2632
2855
|
this.assertCanStartWork();
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
const
|
|
2636
|
-
|
|
2637
|
-
|
|
2856
|
+
const controller = new AbortController();
|
|
2857
|
+
let settle = () => { };
|
|
2858
|
+
const completion = new Promise((resolve) => {
|
|
2859
|
+
settle = resolve;
|
|
2860
|
+
});
|
|
2861
|
+
this._bashOperations.set(controller, completion);
|
|
2862
|
+
this._operations.add(completion);
|
|
2638
2863
|
try {
|
|
2864
|
+
// Apply the configured shell prefix within this operation's cleanup boundary.
|
|
2865
|
+
const prefix = this.settingsManager.getShellCommandPrefix();
|
|
2866
|
+
const shellPath = this.settingsManager.getShellPath();
|
|
2867
|
+
const resolvedCommand = prefix ? `${prefix}\n${command}` : command;
|
|
2639
2868
|
const result = await executeBashWithOperations(resolvedCommand, this.sessionManager.getCwd(), options?.operations ?? createLocalBashOperations({ shellPath, sessionId: this.sessionId }), {
|
|
2640
2869
|
onChunk,
|
|
2641
|
-
signal:
|
|
2870
|
+
signal: controller.signal,
|
|
2642
2871
|
});
|
|
2643
2872
|
this.recordBashResult(command, result, options);
|
|
2644
2873
|
return result;
|
|
2645
2874
|
}
|
|
2646
2875
|
finally {
|
|
2647
|
-
this.
|
|
2876
|
+
this._bashOperations.delete(controller);
|
|
2877
|
+
this._operations.delete(completion);
|
|
2878
|
+
settle();
|
|
2648
2879
|
}
|
|
2649
2880
|
}
|
|
2650
2881
|
/**
|
|
@@ -2676,14 +2907,15 @@ export class AgentSession {
|
|
|
2676
2907
|
}
|
|
2677
2908
|
}
|
|
2678
2909
|
/**
|
|
2679
|
-
* Cancel running bash
|
|
2910
|
+
* Cancel every running direct bash operation.
|
|
2680
2911
|
*/
|
|
2681
2912
|
abortBash() {
|
|
2682
|
-
this.
|
|
2913
|
+
for (const controller of this._bashOperations.keys())
|
|
2914
|
+
controller.abort();
|
|
2683
2915
|
}
|
|
2684
2916
|
/** Whether a bash command is currently running */
|
|
2685
2917
|
get isBashRunning() {
|
|
2686
|
-
return this.
|
|
2918
|
+
return this._bashOperations.size > 0;
|
|
2687
2919
|
}
|
|
2688
2920
|
/** Whether there are pending bash messages waiting to be flushed */
|
|
2689
2921
|
get hasPendingBashMessages() {
|
|
@@ -2731,6 +2963,12 @@ export class AgentSession {
|
|
|
2731
2963
|
* @returns Result with editorText (if user message) and cancelled status
|
|
2732
2964
|
*/
|
|
2733
2965
|
async navigateTree(targetId, options = {}) {
|
|
2966
|
+
this.assertCanStartWork();
|
|
2967
|
+
if (this._branchSummaryAbortController)
|
|
2968
|
+
throw new Error("Tree navigation is already in progress.");
|
|
2969
|
+
return this._trackOperation(() => this._navigateTree(targetId, options));
|
|
2970
|
+
}
|
|
2971
|
+
async _navigateTree(targetId, options = {}) {
|
|
2734
2972
|
const oldLeafId = this.sessionManager.getLeafId();
|
|
2735
2973
|
// No-op if already at target
|
|
2736
2974
|
if (targetId === oldLeafId) {
|
|
@@ -2807,6 +3045,7 @@ export class AgentSession {
|
|
|
2807
3045
|
replaceInstructions,
|
|
2808
3046
|
reserveTokens: branchSummarySettings.reserveTokens,
|
|
2809
3047
|
streamFn: this.agent.streamFn,
|
|
3048
|
+
onUsage: (response) => this.sessionManager.appendRequestUsage("branch-summary", response),
|
|
2810
3049
|
});
|
|
2811
3050
|
if (result.aborted) {
|
|
2812
3051
|
return { cancelled: true, aborted: true };
|
|
@@ -2824,6 +3063,8 @@ export class AgentSession {
|
|
|
2824
3063
|
summaryText = extensionSummary.summary;
|
|
2825
3064
|
summaryDetails = extensionSummary.details;
|
|
2826
3065
|
}
|
|
3066
|
+
if (this._branchSummaryAbortController.signal.aborted)
|
|
3067
|
+
return { cancelled: true, aborted: true };
|
|
2827
3068
|
// Determine the new leaf position based on target type
|
|
2828
3069
|
let newLeafId;
|
|
2829
3070
|
let editorText;
|
|
@@ -2929,7 +3170,7 @@ export class AgentSession {
|
|
|
2929
3170
|
/**
|
|
2930
3171
|
* Get session statistics. Aggregates over ALL session entries (including
|
|
2931
3172
|
* history that was compacted away), so token/cost totals reflect what was
|
|
2932
|
-
*
|
|
3173
|
+
* reported or estimated across requests incurred in this session.
|
|
2933
3174
|
*/
|
|
2934
3175
|
getSessionStats() {
|
|
2935
3176
|
let userMessages = 0;
|
|
@@ -2937,11 +3178,12 @@ export class AgentSession {
|
|
|
2937
3178
|
let toolResults = 0;
|
|
2938
3179
|
let totalMessages = 0;
|
|
2939
3180
|
let toolCalls = 0;
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
3181
|
+
const entries = this.sessionManager.getEntries();
|
|
3182
|
+
const parentUsage = totalRequestUsage(collectUsageRequests(entries));
|
|
3183
|
+
const childUsage = totalChildUsage(collectChildUsage(entries));
|
|
3184
|
+
const combinedUsage = { ...parentUsage };
|
|
3185
|
+
for (const key of Object.keys(combinedUsage))
|
|
3186
|
+
combinedUsage[key] += childUsage[key];
|
|
2945
3187
|
for (const entry of this.sessionManager.getEntries()) {
|
|
2946
3188
|
if (entry.type !== "message")
|
|
2947
3189
|
continue;
|
|
@@ -2959,12 +3201,6 @@ export class AgentSession {
|
|
|
2959
3201
|
if (Array.isArray(assistantMsg.content)) {
|
|
2960
3202
|
toolCalls += assistantMsg.content.filter((c) => c.type === "toolCall").length;
|
|
2961
3203
|
}
|
|
2962
|
-
const usage = assistantMsg.usage;
|
|
2963
|
-
totalInput += usage.input;
|
|
2964
|
-
totalOutput += usage.output;
|
|
2965
|
-
totalCacheRead += usage.cacheRead;
|
|
2966
|
-
totalCacheWrite += usage.cacheWrite;
|
|
2967
|
-
totalCost += usage.cost.total;
|
|
2968
3204
|
}
|
|
2969
3205
|
}
|
|
2970
3206
|
return {
|
|
@@ -2976,13 +3212,16 @@ export class AgentSession {
|
|
|
2976
3212
|
toolResults,
|
|
2977
3213
|
totalMessages,
|
|
2978
3214
|
tokens: {
|
|
2979
|
-
input:
|
|
2980
|
-
output:
|
|
2981
|
-
cacheRead:
|
|
2982
|
-
cacheWrite:
|
|
2983
|
-
total:
|
|
3215
|
+
input: parentUsage.input,
|
|
3216
|
+
output: parentUsage.output,
|
|
3217
|
+
cacheRead: parentUsage.cacheRead,
|
|
3218
|
+
cacheWrite: parentUsage.cacheWrite,
|
|
3219
|
+
total: parentUsage.total,
|
|
2984
3220
|
},
|
|
2985
|
-
cost:
|
|
3221
|
+
cost: parentUsage.cost,
|
|
3222
|
+
parentUsage,
|
|
3223
|
+
childUsage,
|
|
3224
|
+
combinedUsage,
|
|
2986
3225
|
contextUsage: this.getContextUsage(),
|
|
2987
3226
|
};
|
|
2988
3227
|
}
|
|
@@ -2993,38 +3232,17 @@ export class AgentSession {
|
|
|
2993
3232
|
const contextWindow = model.contextWindow ?? 0;
|
|
2994
3233
|
if (contextWindow <= 0)
|
|
2995
3234
|
return undefined;
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
if (latestCompaction) {
|
|
3002
|
-
// Check if there's a valid assistant usage after the compaction boundary
|
|
3003
|
-
const compactionIndex = branchEntries.lastIndexOf(latestCompaction);
|
|
3004
|
-
let hasPostCompactionUsage = false;
|
|
3005
|
-
for (let i = branchEntries.length - 1; i > compactionIndex; i--) {
|
|
3006
|
-
const entry = branchEntries[i];
|
|
3007
|
-
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
3008
|
-
const assistant = entry.message;
|
|
3009
|
-
if (assistant.stopReason !== "aborted" && assistant.stopReason !== "error") {
|
|
3010
|
-
const contextTokens = calculateContextTokens(assistant.usage);
|
|
3011
|
-
if (contextTokens > 0) {
|
|
3012
|
-
hasPostCompactionUsage = true;
|
|
3013
|
-
break;
|
|
3014
|
-
}
|
|
3015
|
-
}
|
|
3016
|
-
}
|
|
3017
|
-
}
|
|
3018
|
-
if (!hasPostCompactionUsage) {
|
|
3019
|
-
return { tokens: null, contextWindow, percent: null };
|
|
3020
|
-
}
|
|
3021
|
-
}
|
|
3022
|
-
const estimate = estimateContextTokens(this.messages);
|
|
3235
|
+
const estimate = estimateRequestContextTokens({
|
|
3236
|
+
systemPrompt: this.systemPrompt,
|
|
3237
|
+
tools: this.agent.state.tools,
|
|
3238
|
+
messages: convertToLlm(this.messages),
|
|
3239
|
+
});
|
|
3023
3240
|
const percent = (estimate.tokens / contextWindow) * 100;
|
|
3024
3241
|
return {
|
|
3025
3242
|
tokens: estimate.tokens,
|
|
3026
3243
|
contextWindow,
|
|
3027
3244
|
percent,
|
|
3245
|
+
estimated: estimate.lastUsageIndex === null || estimate.trailingTokens > 0,
|
|
3028
3246
|
};
|
|
3029
3247
|
}
|
|
3030
3248
|
/**
|