@draht/coding-agent 2026.11.5-1 → 2026.11.14-1
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 +66 -0
- package/dist/bundle/chunks/anthropic-messages-C5ZJVCKX.js +6 -0
- package/dist/bundle/chunks/{azure-openai-responses-NCMJPZVJ.js → azure-openai-responses-TNRID5YC.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +2 -2
- package/dist/bundle/chunks/chunk-2CHTECAU.js +2 -0
- package/dist/bundle/chunks/{chunk-DWOGGNWY.js → chunk-2IQVBLH6.js} +1 -1
- package/dist/bundle/chunks/{chunk-P7O36UDU.js → chunk-4FPBO5KP.js} +5 -1
- package/dist/bundle/chunks/{chunk-Q2QKCYPU.js → chunk-5C4MAPF6.js} +1 -1
- package/dist/bundle/chunks/chunk-5WEOWREV.js +82 -0
- package/dist/bundle/chunks/{chunk-DN7SM3LX.js → chunk-ATYP3OSV.js} +3 -1
- package/dist/bundle/chunks/chunk-B6S2UR4T.js +2 -0
- package/dist/bundle/chunks/chunk-EBTEI43G.js +20 -0
- package/dist/bundle/chunks/{chunk-F5TDVH26.js → chunk-GAABJAG4.js} +12 -15
- package/dist/bundle/chunks/{chunk-PMINB7UH.js → chunk-JHKMYVPC.js} +169 -130
- package/dist/bundle/chunks/{chunk-EOXOMUKR.js → chunk-LCTFXH4P.js} +1 -1
- package/dist/bundle/chunks/{chunk-UFACUBF2.js → chunk-MPJIXESS.js} +1 -1
- package/dist/bundle/chunks/{chunk-PZKD35UB.js → chunk-MXA4WY3C.js} +1 -1
- package/dist/bundle/chunks/chunk-O2XYFH2E.js +30 -0
- package/dist/bundle/chunks/{chunk-CA23BDNK.js → chunk-OUXJRC2W.js} +1 -1
- package/dist/bundle/chunks/{chunk-3BJ462DN.js → chunk-RI7HJ6AF.js} +1 -1
- package/dist/bundle/chunks/chunk-RVXTPNXQ.js +44 -0
- package/dist/bundle/chunks/{chunk-QBUTRTYN.js → chunk-SXHVGWCU.js} +1 -1
- package/dist/bundle/chunks/chunk-WNZ64GW3.js +2 -0
- package/dist/bundle/chunks/chunk-XWZLYE4L.js +9 -0
- package/dist/bundle/chunks/{chunk-HJ3PS7QP.js → chunk-YSE3VKKB.js} +2 -2
- package/dist/bundle/chunks/{cli-4SUT6MJ6.js → cli-2QKCAPPD.js} +3 -3
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-BJVMNETD.js → cloudflare-workers-ai-system-one-UCG6T3XP.js} +1 -1
- package/dist/bundle/chunks/codemode-worker.js +2 -0
- package/dist/bundle/chunks/{execute-ZI7T2SUH.js → execute-KGJOWTPG.js} +2 -2
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/google-generative-ai-GPBKPOXA.js +2 -0
- package/dist/bundle/chunks/google-vertex-USZY53NF.js +2 -0
- package/dist/bundle/chunks/{llama-cpp-classify-L4URPZ4F.js → llama-cpp-classify-7DEQ4ZUF.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-CK2BS74V.js → mistral-conversations-UOGXPDZ3.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-XGVNKP4D.js → openai-codex-responses-VUDXQ3EU.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-72XZO4Q3.js → openai-completions-UQOOS7NM.js} +3 -3
- package/dist/bundle/chunks/{openai-decisions-P5OCXLLD.js → openai-decisions-24WNXO2R.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-RGLZ4E3Q.js → openai-responses-5AF6MZ5L.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-LSBWMZDK.js → openrouter-images-OUXVVTYQ.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-CL4MEVNS.js → pi-messages-DRMOEO6B.js} +1 -1
- package/dist/bundle/chunks/{runtime-FJYRBK3O.js → runtime-FZKS2BWI.js} +1 -1
- package/dist/bundle/chunks/{runtime-F4362CZF.js → runtime-L23MZBKL.js} +1 -1
- package/dist/bundle/chunks/{settings-manager-T6G6KKY3.js → settings-manager-CWRQW6PZ.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-BFYS6AEA.js → typesafe-system-one-K63EBJDD.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-JZV35VDE.js +2 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +5 -3
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-command.d.ts.map +1 -1
- package/dist/cli/auth-command.js +30 -6
- package/dist/cli/auth-command.js.map +1 -1
- package/dist/cli/auth-login.d.ts +15 -0
- package/dist/cli/auth-login.d.ts.map +1 -0
- package/dist/cli/auth-login.js +232 -0
- package/dist/cli/auth-login.js.map +1 -0
- package/dist/cli/auth-logout.d.ts +14 -0
- package/dist/cli/auth-logout.d.ts.map +1 -0
- package/dist/cli/auth-logout.js +57 -0
- package/dist/cli/auth-logout.js.map +1 -0
- package/dist/cli/auth-terminal.d.ts +17 -0
- package/dist/cli/auth-terminal.d.ts.map +1 -0
- package/dist/cli/auth-terminal.js +63 -0
- package/dist/cli/auth-terminal.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +5 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +16 -2
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +20 -9
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +71 -29
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/ai-schemas.d.ts +1 -0
- package/dist/core/ai-schemas.d.ts.map +1 -1
- package/dist/core/builtins/budgets.d.ts.map +1 -1
- package/dist/core/builtins/budgets.js +6 -3
- package/dist/core/builtins/budgets.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +4 -37
- package/dist/core/cache-warmer.d.ts.map +1 -1
- package/dist/core/cache-warmer.js +11 -91
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +2 -1
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/exec.d.ts +1 -0
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +4 -1
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/ansi-to-html.d.ts +5 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/dist/core/export-html/ansi-to-html.js +57 -20
- package/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/dist/core/export-html/template.js +1 -1
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +2 -3
- package/dist/core/export-html/tool-renderer.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/model-config.d.ts +13 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-resolver.d.ts +0 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +17 -24
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +5 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +7 -0
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/polyphase/render/format.d.ts +2 -0
- package/dist/core/polyphase/render/format.d.ts.map +1 -1
- package/dist/core/polyphase/render/format.js +6 -0
- package/dist/core/polyphase/render/format.js.map +1 -1
- package/dist/core/polyphase/render/run-block.d.ts +4 -0
- package/dist/core/polyphase/render/run-block.d.ts.map +1 -1
- package/dist/core/polyphase/render/run-block.js +71 -12
- package/dist/core/polyphase/render/run-block.js.map +1 -1
- package/dist/core/polyphase/render/snapshot.d.ts +1 -1
- package/dist/core/polyphase/render/snapshot.d.ts.map +1 -1
- package/dist/core/polyphase/render/snapshot.js +22 -7
- package/dist/core/polyphase/render/snapshot.js.map +1 -1
- package/dist/core/polyphase/ui/dock.d.ts.map +1 -1
- package/dist/core/polyphase/ui/dock.js +34 -2
- package/dist/core/polyphase/ui/dock.js.map +1 -1
- package/dist/core/polyphase/ui/inspector.d.ts +18 -6
- package/dist/core/polyphase/ui/inspector.d.ts.map +1 -1
- package/dist/core/polyphase/ui/inspector.js +125 -44
- package/dist/core/polyphase/ui/inspector.js.map +1 -1
- package/dist/core/polyphase/ui/transcript-layout.d.ts.map +1 -1
- package/dist/core/polyphase/ui/transcript-layout.js +5 -1
- package/dist/core/polyphase/ui/transcript-layout.js.map +1 -1
- package/dist/core/preferred-providers.d.ts +17 -0
- package/dist/core/preferred-providers.d.ts.map +1 -0
- package/dist/core/preferred-providers.js +24 -0
- package/dist/core/preferred-providers.js.map +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +18 -2
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +2 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/provider-matching.d.ts +6 -0
- package/dist/core/provider-matching.d.ts.map +1 -0
- package/dist/core/provider-matching.js +8 -0
- package/dist/core/provider-matching.js.map +1 -0
- package/dist/core/radius-mcp.d.ts +13 -0
- package/dist/core/radius-mcp.d.ts.map +1 -0
- package/dist/core/radius-mcp.js +29 -0
- package/dist/core/radius-mcp.js.map +1 -0
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +2 -0
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +8 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +15 -1
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/session-cwd.d.ts +7 -0
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +9 -1
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +45 -36
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +1 -1
- package/dist/core/settings-defaults.d.ts.map +1 -1
- package/dist/core/settings-defaults.js +1 -1
- package/dist/core/settings-defaults.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +35 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +23 -14
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +182 -41
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +8 -7
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +57 -16
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +4 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +20 -8
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +4 -1
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +15 -2
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/read.d.ts +13 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +146 -35
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/renderers/read.d.ts.map +1 -1
- package/dist/core/tools/renderers/read.js +6 -2
- package/dist/core/tools/renderers/read.js.map +1 -1
- package/dist/core/tools/truncate.d.ts +4 -0
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +24 -1
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/extensions/codemode/execute.js +4 -4
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +34 -12
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +1 -1
- package/dist/extensions/llama/provider.js +1 -1
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +15 -3
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/cli.js +5 -8
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +2 -1
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +3 -2
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/dist/extensions/tool-search/tool.js +18 -6
- package/dist/extensions/tool-search/tool.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +67 -15
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +2 -19
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +14 -6
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +10 -3
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +32 -5
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/provider-brand.d.ts +14 -0
- package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
- package/dist/modes/interactive/components/provider-brand.js +66 -0
- package/dist/modes/interactive/components/provider-brand.js.map +1 -0
- package/dist/modes/interactive/components/radius-login-selector.d.ts +1 -2
- package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/radius-login-selector.js +6 -37
- package/dist/modes/interactive/components/radius-login-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +6 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +23 -5
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +3 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +11 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +133 -78
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-share.js +2 -0
- package/dist/modes/interactive/session-share.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +27 -4
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/test-audit.md +84 -0
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js +3 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/terminal-question.d.ts +8 -0
- package/dist/utils/terminal-question.d.ts.map +1 -0
- package/dist/utils/terminal-question.js +24 -0
- package/dist/utils/terminal-question.js.map +1 -0
- package/dist/utils/web-url.d.ts +12 -0
- package/dist/utils/web-url.d.ts.map +1 -0
- package/dist/utils/web-url.js +20 -0
- package/dist/utils/web-url.js.map +1 -0
- package/docs/cli.md +14 -1
- package/docs/extensions.md +6 -4
- package/docs/llama-cpp.md +5 -5
- package/docs/models-configuration.md +2 -1
- package/docs/nvidia-rtx-llama-cpp.md +5 -5
- package/docs/polyphase.md +13 -1
- package/docs/prompt-templates.md +1 -1
- package/docs/providers.md +4 -2
- package/docs/quickstart.md +1 -1
- package/docs/rpc-commands.md +1 -1
- package/docs/rpc.md +1 -1
- package/docs/sessions.md +7 -1
- package/docs/settings.md +1 -1
- package/docs/tui.md +1 -1
- package/examples/extensions/gondolin/index.ts +4 -7
- package/examples/extensions/subagent/index.ts +5 -1
- package/package.json +10 -10
- package/prompts/commands/test-audit.md +84 -0
- package/schemas/models.schema.json +5 -1
- package/schemas/settings.schema.json +1 -1
- package/dist/bundle/chunks/anthropic-messages-UJZ4SGHU.js +0 -6
- package/dist/bundle/chunks/chunk-AOCWORXE.js +0 -2
- package/dist/bundle/chunks/chunk-BK5LXGIH.js +0 -2
- package/dist/bundle/chunks/chunk-DQ4G4IS4.js +0 -20
- package/dist/bundle/chunks/chunk-SUVMF4W5.js +0 -2
- package/dist/bundle/chunks/chunk-VXO6B72D.js +0 -9
- package/dist/bundle/chunks/chunk-WXASQQBZ.js +0 -44
- package/dist/bundle/chunks/chunk-YD5VPPI4.js +0 -30
- package/dist/bundle/chunks/chunk-YWRWN7ZB.js +0 -82
- package/dist/bundle/chunks/google-generative-ai-N5IPPKQY.js +0 -2
- package/dist/bundle/chunks/google-vertex-A4BKUE4H.js +0 -2
- package/dist/bundle/chunks/virtual-modules-BPZIVXNK.js +0 -2
|
@@ -113,6 +113,20 @@ const LOCAL_SURFACE_BY_MODE = Object.freeze({
|
|
|
113
113
|
// ============================================================================
|
|
114
114
|
// AgentSession Class
|
|
115
115
|
// ============================================================================
|
|
116
|
+
/**
|
|
117
|
+
* Index of the model to cycle to, or undefined when there is nothing to switch to.
|
|
118
|
+
* When the current model is not in the list (currentIndex -1), forward picks the first
|
|
119
|
+
* entry and backward the last, so a one-entry list still selects its only model.
|
|
120
|
+
*/
|
|
121
|
+
function getNextCycleIndex(currentIndex, length, direction) {
|
|
122
|
+
if (length === 0)
|
|
123
|
+
return undefined;
|
|
124
|
+
if (currentIndex === -1)
|
|
125
|
+
return direction === "forward" ? 0 : length - 1;
|
|
126
|
+
if (length === 1)
|
|
127
|
+
return undefined;
|
|
128
|
+
return direction === "forward" ? (currentIndex + 1) % length : (currentIndex - 1 + length) % length;
|
|
129
|
+
}
|
|
116
130
|
export class AgentSession {
|
|
117
131
|
agent;
|
|
118
132
|
sessionManager;
|
|
@@ -174,9 +188,11 @@ export class AgentSession {
|
|
|
174
188
|
/**
|
|
175
189
|
* Tools of the restored or reloaded loadout that are not registered yet, such as tools of MCP
|
|
176
190
|
* servers that are still connecting. They are activated when they are registered, and dropped when
|
|
177
|
-
* `setActiveToolsByName()` deactivates a tool or the next agent run starts.
|
|
191
|
+
* `setActiveToolsByName()` deactivates a tool of that loadout or the next agent run starts.
|
|
178
192
|
*/
|
|
179
193
|
_pendingToolNames = new Set();
|
|
194
|
+
/** The restored or reloaded loadout that `_pendingToolNames` belongs to. */
|
|
195
|
+
_restoredToolNames = new Set();
|
|
180
196
|
_usesDefaultTools;
|
|
181
197
|
_defaultToolModifiers;
|
|
182
198
|
/** Matches the `--tools` entries: tool names or patterns. */
|
|
@@ -328,19 +344,25 @@ export class AgentSession {
|
|
|
328
344
|
return this._modelRuntime.getPhysicalModel(message.provider, message.model);
|
|
329
345
|
return model?.provider === message.provider && model.id === message.model ? model : undefined;
|
|
330
346
|
}
|
|
347
|
+
/** Record the live model and thinking level on the current branch, so a resume restores them. */
|
|
348
|
+
_recordSelection() {
|
|
349
|
+
const branch = this.sessionManager.getBranch();
|
|
350
|
+
this._recordModelSelection(branch);
|
|
351
|
+
this._recordThinkingLevel(branch);
|
|
352
|
+
}
|
|
331
353
|
/**
|
|
332
|
-
* Record the
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
354
|
+
* Record the model on the current branch when the branch implies another one. Tree navigation
|
|
355
|
+
* can leave the latest `model_change` on another branch; responses cannot record a virtual
|
|
356
|
+
* selection because they name physical models. Responses do record a physical selection unless
|
|
357
|
+
* the branch holds a virtual one; checking a physical selection against responses would record
|
|
358
|
+
* it on every prompt while `prepareRequest` redirects to another model.
|
|
337
359
|
*/
|
|
338
|
-
|
|
360
|
+
_recordModelSelection(branch) {
|
|
339
361
|
const model = this.model;
|
|
340
362
|
if (!model)
|
|
341
363
|
return;
|
|
342
364
|
const getModel = (provider, modelId) => this._modelRuntime.getModel(provider, modelId);
|
|
343
|
-
const recorded = getBranchSelection(
|
|
365
|
+
const recorded = getBranchSelection(branch, getModel);
|
|
344
366
|
if (!recorded || (recorded.provider === model.provider && recorded.modelId === model.id))
|
|
345
367
|
return;
|
|
346
368
|
const recordedModel = getModel(recorded.provider, recorded.modelId);
|
|
@@ -348,6 +370,25 @@ export class AgentSession {
|
|
|
348
370
|
return;
|
|
349
371
|
this.sessionManager.appendModelChange(model.provider, model.id);
|
|
350
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Record the thinking level on the current branch when the branch implies another one (#11451).
|
|
375
|
+
* Tree navigation can leave the latest `thinking_level_change` on another branch. The recorded
|
|
376
|
+
* level is compared after clamping to the current model, so a level clamped on resume (e.g.
|
|
377
|
+
* `xhigh` running as `high`) is not recorded over the requested one.
|
|
378
|
+
*/
|
|
379
|
+
_recordThinkingLevel(branch) {
|
|
380
|
+
const recorded = branch.findLast((entry) => entry.type === "thinking_level_change");
|
|
381
|
+
if (!recorded)
|
|
382
|
+
return;
|
|
383
|
+
const recordedLevel = recorded.thinkingLevel;
|
|
384
|
+
const availableLevels = this.getAvailableThinkingLevels();
|
|
385
|
+
const effective = availableLevels.includes(recordedLevel)
|
|
386
|
+
? recordedLevel
|
|
387
|
+
: this._clampThinkingLevel(recordedLevel, availableLevels);
|
|
388
|
+
if (effective === this.thinkingLevel)
|
|
389
|
+
return;
|
|
390
|
+
this.sessionManager.appendThinkingLevelChange(this.thinkingLevel);
|
|
391
|
+
}
|
|
351
392
|
/** The model whose limits apply to the conversation. */
|
|
352
393
|
_limitsModel() {
|
|
353
394
|
return this.routedModel?.model ?? this.model;
|
|
@@ -1171,11 +1212,14 @@ export class AgentSession {
|
|
|
1171
1212
|
setActiveToolsByName(toolNames) {
|
|
1172
1213
|
const previous = this.getActiveToolNames();
|
|
1173
1214
|
this._setActiveTools(toolNames);
|
|
1174
|
-
// A loadout that deactivates a tool
|
|
1175
|
-
// One that only adds tools, like activating tool_search, keeps them
|
|
1215
|
+
// A loadout that deactivates a tool of the restored one replaces it, and its pending tools are
|
|
1216
|
+
// dropped. One that only adds tools, like activating tool_search, keeps them, and so does one
|
|
1217
|
+
// that only deactivates tools outside the restored loadout, such as an extension's own tool that
|
|
1218
|
+
// the restore or reload activated as newly registered.
|
|
1176
1219
|
const active = new Set(this.getActiveToolNames());
|
|
1177
|
-
if (previous.some((name) => !active.has(name)))
|
|
1220
|
+
if (previous.some((name) => !active.has(name) && this._restoredToolNames.has(name))) {
|
|
1178
1221
|
this._pendingToolNames.clear();
|
|
1222
|
+
}
|
|
1179
1223
|
}
|
|
1180
1224
|
_setActiveTools(toolNames) {
|
|
1181
1225
|
const tools = this._applyToolLoadout(toolNames);
|
|
@@ -1445,6 +1489,7 @@ export class AgentSession {
|
|
|
1445
1489
|
*/
|
|
1446
1490
|
_restoreToolsFromTranscript(modifiers = []) {
|
|
1447
1491
|
this._pendingToolNames.clear();
|
|
1492
|
+
this._restoredToolNames.clear();
|
|
1448
1493
|
// All system messages on the branch, including those before a compaction. Compaction snapshots
|
|
1449
1494
|
// are derived from these, so replaying them gives the current loadout.
|
|
1450
1495
|
const systemMessages = this.sessionManager
|
|
@@ -1465,6 +1510,7 @@ export class AgentSession {
|
|
|
1465
1510
|
// Recorded tools that are not registered yet, such as MCP tools of servers still connecting, are
|
|
1466
1511
|
// activated when they register. Excluded tools never register, so they are not kept pending.
|
|
1467
1512
|
this._pendingToolNames = new Set(names.filter((name) => this._isAllowedTool(name)));
|
|
1513
|
+
this._restoredToolNames = new Set(applyToolModifiers(getCurrentTools(systemMessages).map((tool) => tool.name), modifiers));
|
|
1468
1514
|
// Ignores names that are not registered.
|
|
1469
1515
|
this._setActiveTools(names);
|
|
1470
1516
|
}
|
|
@@ -2150,14 +2196,11 @@ export class AgentSession {
|
|
|
2150
2196
|
async _cycleScopedModel(direction, options) {
|
|
2151
2197
|
const availableIds = new Set(this._modelRuntime.getAvailableSnapshot().map((model) => `${model.provider}\0${model.id}`));
|
|
2152
2198
|
const scopedModels = this._scopedModels.filter((scoped) => availableIds.has(`${scoped.model.provider}\0${scoped.model.id}`));
|
|
2153
|
-
if (scopedModels.length <= 1)
|
|
2154
|
-
return undefined;
|
|
2155
2199
|
const currentModel = this.model;
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
const nextIndex = direction === "forward" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;
|
|
2200
|
+
const currentIndex = scopedModels.findIndex((sm) => modelsAreEqual(sm.model, currentModel));
|
|
2201
|
+
const nextIndex = getNextCycleIndex(currentIndex, scopedModels.length, direction);
|
|
2202
|
+
if (nextIndex === undefined)
|
|
2203
|
+
return undefined;
|
|
2161
2204
|
const next = scopedModels[nextIndex];
|
|
2162
2205
|
const thinkingLevel = this._getThinkingLevelForModelSwitch(next.model, next.thinkingLevel);
|
|
2163
2206
|
// Apply model
|
|
@@ -2178,14 +2221,11 @@ export class AgentSession {
|
|
|
2178
2221
|
}
|
|
2179
2222
|
async _cycleAvailableModel(direction, options) {
|
|
2180
2223
|
const availableModels = this._modelRuntime.getAvailableSnapshot();
|
|
2181
|
-
if (availableModels.length <= 1)
|
|
2182
|
-
return undefined;
|
|
2183
2224
|
const currentModel = this.model;
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
const nextIndex = direction === "forward" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;
|
|
2225
|
+
const currentIndex = availableModels.findIndex((m) => modelsAreEqual(m, currentModel));
|
|
2226
|
+
const nextIndex = getNextCycleIndex(currentIndex, availableModels.length, direction);
|
|
2227
|
+
if (nextIndex === undefined)
|
|
2228
|
+
return undefined;
|
|
2189
2229
|
const nextModel = availableModels[nextIndex];
|
|
2190
2230
|
const thinkingLevel = this._getThinkingLevelForModelSwitch(nextModel);
|
|
2191
2231
|
this.agent.state.model = nextModel;
|
|
@@ -3198,6 +3238,7 @@ export class AgentSession {
|
|
|
3198
3238
|
// Tools the new extensions register later, such as MCP tools, are pending until then.
|
|
3199
3239
|
for (const name of this.getActiveToolNames())
|
|
3200
3240
|
this._pendingToolNames.add(name);
|
|
3241
|
+
this._restoredToolNames = new Set(this.getActiveToolNames());
|
|
3201
3242
|
this._buildRuntime({
|
|
3202
3243
|
activeToolNames: [...this.getActiveToolNames(), ...addedDefaultTools],
|
|
3203
3244
|
flagValues: previousFlagValues,
|
|
@@ -3773,9 +3814,9 @@ export class AgentSession {
|
|
|
3773
3814
|
// Utilities
|
|
3774
3815
|
// =========================================================================
|
|
3775
3816
|
/**
|
|
3776
|
-
* Get text content of last assistant
|
|
3817
|
+
* Get text content of the last assistant reply.
|
|
3777
3818
|
* Useful for /copy command.
|
|
3778
|
-
* @returns Text content, or undefined if no assistant message exists
|
|
3819
|
+
* @returns Text content, or undefined if no assistant message exists or the last reply has no text
|
|
3779
3820
|
*/
|
|
3780
3821
|
getLastAssistantText() {
|
|
3781
3822
|
const lastAssistant = this.messages
|
|
@@ -3785,8 +3826,9 @@ export class AgentSession {
|
|
|
3785
3826
|
if (m.role !== "assistant")
|
|
3786
3827
|
return false;
|
|
3787
3828
|
const msg = m;
|
|
3788
|
-
// Skip aborted
|
|
3789
|
-
|
|
3829
|
+
// Skip messages without text from a turn that did not end normally: aborted, failed or only
|
|
3830
|
+
// calling tools (#12119). A reply that ended normally stays the last reply even without text.
|
|
3831
|
+
if (msg.stopReason !== "stop" && !msg.content.some((c) => c.type === "text" && c.text.trim()))
|
|
3790
3832
|
return false;
|
|
3791
3833
|
return true;
|
|
3792
3834
|
});
|