@draht/coding-agent 2026.6.11 → 2026.7.7
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 +15 -0
- package/README.md +1 -4
- package/dist/bun/register-bedrock.d.ts.map +1 -1
- package/dist/bun/register-bedrock.js +1 -1
- package/dist/bun/register-bedrock.js.map +1 -1
- package/dist/bun/restore-sandbox-env.d.ts +4 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
- package/dist/bun/restore-sandbox-env.js +4 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +4 -4
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts +4 -2
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +13 -25
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/session-picker.d.ts +2 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +5 -4
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.d.ts +5 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +94 -22
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts +6 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -16
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +10 -4
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +124 -83
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +11 -12
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +25 -26
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +3 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +5 -4
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +23 -20
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/export-html/vendor/marked.min.js +75 -3
- 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/loader.d.ts +2 -3
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +77 -14
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +2 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +33 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +29 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts +1 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +45 -2
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +3 -6
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts +2 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +32 -67
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +11 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +37 -19
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-manager.d.ts +5 -2
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +99 -43
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +4 -3
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/provider-attribution.d.ts +2 -2
- package/dist/core/provider-attribution.d.ts.map +1 -1
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +1 -1
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts +7 -8
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +24 -26
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader.d.ts +3 -2
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +16 -6
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +9 -9
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +21 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +121 -77
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +10 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +29 -3
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +7 -7
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/timings.d.ts +4 -2
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +24 -14
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +32 -8
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +23 -4
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +99 -20
- 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 +2 -2
- 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 +19 -11
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +12 -25
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/trust-manager.d.ts +8 -3
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +26 -11
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +2 -2
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +47 -15
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +1 -123
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +3 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +23 -15
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +34 -3
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +284 -29
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-entry.js +52 -0
- package/dist/modes/interactive/components/custom-entry.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +3 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +12 -3
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +2 -2
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +4 -0
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +0 -1
- 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 +2 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +4 -1
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +0 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +14 -8
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +188 -16
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -0
- package/dist/modes/interactive/components/status-indicator.js +60 -0
- package/dist/modes/interactive/components/status-indicator.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +130 -15
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +4 -4
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +6 -2
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +19 -6
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +13 -11
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +252 -233
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -0
- package/dist/modes/interactive/model-search.js +15 -0
- package/dist/modes/interactive/model-search.js.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +102 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +2 -1
- package/dist/modes/interactive/theme/theme.d.ts +27 -8
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +64 -42
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +19 -4
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +14 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +17 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +26 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +2 -2
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +152 -48
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/brainstorm.md +148 -0
- package/dist/rpc-entry.d.ts +3 -0
- package/dist/rpc-entry.d.ts.map +1 -0
- package/dist/rpc-entry.js +10 -0
- package/dist/rpc-entry.js.map +1 -0
- package/dist/utils/child-process.d.ts +7 -4
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +23 -5
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/image-convert.d.ts +1 -0
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js +21 -15
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-process.d.ts +18 -0
- package/dist/utils/image-process.d.ts.map +1 -0
- package/dist/utils/image-process.js +83 -0
- package/dist/utils/image-process.js.map +1 -0
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js +41 -0
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +12 -5
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +4 -27
- package/dist/utils/version-check.js.map +1 -1
- package/docs/extensions.md +55 -8
- package/docs/keybindings.md +1 -1
- package/docs/packages.md +2 -2
- package/docs/providers.md +2 -1
- package/docs/rpc.md +58 -0
- package/docs/sdk.md +50 -0
- package/docs/session-format.md +18 -8
- package/docs/settings.md +10 -0
- package/docs/usage.md +2 -2
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/custom-compaction.ts +2 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
- 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 +9 -5
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +1 -1
- package/examples/extensions/entry-renderer.ts +41 -0
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/handoff.ts +2 -2
- package/examples/extensions/plan-mode/index.ts +87 -37
- package/examples/extensions/preset.ts +10 -4
- package/examples/extensions/provider-payload.ts +5 -5
- package/examples/extensions/qna.ts +2 -2
- package/examples/extensions/question.ts +32 -18
- package/examples/extensions/questionnaire.ts +41 -28
- package/examples/extensions/sandbox/index.ts +2 -2
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/subagent/agents.ts +2 -2
- package/examples/extensions/subagent/index.ts +9 -3
- package/examples/extensions/summarize.ts +2 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/02-custom-model.ts +1 -1
- package/examples/sdk/12-full-control.ts +2 -2
- package/package.json +14 -15
- package/prompts/commands/brainstorm.md +148 -0
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
16
16
|
import { basename, dirname } from "node:path";
|
|
17
|
-
import { clampThinkingLevel, cleanupSessionResources, getSupportedThinkingLevels, isContextOverflow, modelsAreEqual, resetApiProviders, streamSimple, } from "@draht/ai";
|
|
18
|
-
import { theme } from "../modes/interactive/theme/theme.js";
|
|
17
|
+
import { clampThinkingLevel, cleanupSessionResources, getSupportedThinkingLevels, isContextOverflow, isRetryableAssistantError, modelsAreEqual, resetApiProviders, streamSimple, } from "@draht/ai/compat";
|
|
18
|
+
import { getThemeByName, theme } from "../modes/interactive/theme/theme.js";
|
|
19
19
|
import { stripFrontmatter } from "../utils/frontmatter.js";
|
|
20
20
|
import { resolvePath } from "../utils/paths.js";
|
|
21
21
|
import { sleep } from "../utils/sleep.js";
|
|
22
22
|
import { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage } from "./auth-guidance.js";
|
|
23
23
|
import { executeBashWithOperations } from "./bash-executor.js";
|
|
24
|
-
import { calculateContextTokens, collectEntriesForBranchSummary, compact, estimateContextTokens, generateBranchSummary, prepareCompaction, shouldCompact, } from "./compaction/index.js";
|
|
24
|
+
import { calculateContextTokens, collectEntriesForBranchSummary, compact, estimateContextTokens, estimateTokens, generateBranchSummary, prepareCompaction, shouldCompact, } from "./compaction/index.js";
|
|
25
25
|
import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
|
|
26
26
|
import { exportSessionToHtml } from "./export-html/index.js";
|
|
27
27
|
import { createToolHtmlRenderer } from "./export-html/tool-renderer.js";
|
|
@@ -49,6 +49,13 @@ export function parseSkillBlock(text) {
|
|
|
49
49
|
userMessage: match[4]?.trim() || undefined,
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
+
function estimateMessagesTokens(messages) {
|
|
53
|
+
let tokens = 0;
|
|
54
|
+
for (const message of messages) {
|
|
55
|
+
tokens += estimateTokens(message);
|
|
56
|
+
}
|
|
57
|
+
return tokens;
|
|
58
|
+
}
|
|
52
59
|
// ============================================================================
|
|
53
60
|
// Constants
|
|
54
61
|
// ============================================================================
|
|
@@ -113,6 +120,7 @@ export class AgentSession {
|
|
|
113
120
|
// Base system prompt (without extension appends) - used to apply fresh appends each turn
|
|
114
121
|
_baseSystemPrompt = "";
|
|
115
122
|
_baseSystemPromptOptions;
|
|
123
|
+
_systemPromptOverride;
|
|
116
124
|
constructor(config) {
|
|
117
125
|
this.agent = config.agent;
|
|
118
126
|
this.sessionManager = config.sessionManager;
|
|
@@ -132,6 +140,7 @@ export class AgentSession {
|
|
|
132
140
|
// (session persistence, extensions, auto-compaction, retry logic)
|
|
133
141
|
this._unsubscribeAgent = this.agent.subscribe(this._handleAgentEvent);
|
|
134
142
|
this._installAgentToolHooks();
|
|
143
|
+
this._installAgentNextTurnRefresh();
|
|
135
144
|
this._buildRuntime({
|
|
136
145
|
activeToolNames: this._initialActiveToolNames,
|
|
137
146
|
includeAllExtensionTools: true,
|
|
@@ -150,7 +159,7 @@ export class AgentSession {
|
|
|
150
159
|
throw new Error(result.error);
|
|
151
160
|
}
|
|
152
161
|
if (result.apiKey) {
|
|
153
|
-
return { apiKey: result.apiKey, headers: result.headers };
|
|
162
|
+
return { apiKey: result.apiKey, headers: result.headers, env: result.env };
|
|
154
163
|
}
|
|
155
164
|
const isOAuth = this._modelRegistry.isUsingOAuth(model);
|
|
156
165
|
if (isOAuth) {
|
|
@@ -165,7 +174,7 @@ export class AgentSession {
|
|
|
165
174
|
return this._getRequiredRequestAuth(model);
|
|
166
175
|
}
|
|
167
176
|
const result = await this._modelRegistry.getApiKeyAndHeaders(model);
|
|
168
|
-
return result.ok ? { apiKey: result.apiKey, headers: result.headers } : {};
|
|
177
|
+
return result.ok ? { apiKey: result.apiKey, headers: result.headers, env: result.env } : {};
|
|
169
178
|
}
|
|
170
179
|
/**
|
|
171
180
|
* Install tool hooks once on the Agent instance.
|
|
@@ -220,6 +229,26 @@ export class AgentSession {
|
|
|
220
229
|
};
|
|
221
230
|
};
|
|
222
231
|
}
|
|
232
|
+
_installAgentNextTurnRefresh() {
|
|
233
|
+
const previousPrepareNextTurnWithContext = this.agent.prepareNextTurnWithContext ??
|
|
234
|
+
(this.agent.prepareNextTurn
|
|
235
|
+
? async (_turn, signal) => await this.agent.prepareNextTurn?.(signal)
|
|
236
|
+
: undefined);
|
|
237
|
+
this.agent.prepareNextTurnWithContext = async (turn, signal) => {
|
|
238
|
+
const previousSnapshot = await previousPrepareNextTurnWithContext?.(turn, signal);
|
|
239
|
+
const previousContext = previousSnapshot?.context ?? turn.context;
|
|
240
|
+
return {
|
|
241
|
+
...previousSnapshot,
|
|
242
|
+
context: {
|
|
243
|
+
...previousContext,
|
|
244
|
+
systemPrompt: this._systemPromptOverride ?? this._baseSystemPrompt,
|
|
245
|
+
tools: this.agent.state.tools.slice(),
|
|
246
|
+
},
|
|
247
|
+
model: this.agent.state.model,
|
|
248
|
+
thinkingLevel: this.agent.state.thinkingLevel,
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
}
|
|
223
252
|
// =========================================================================
|
|
224
253
|
// Event Subscription
|
|
225
254
|
// =========================================================================
|
|
@@ -397,7 +426,16 @@ export class AgentSession {
|
|
|
397
426
|
};
|
|
398
427
|
const replacement = await this._extensionRunner.emitMessageEnd(extensionEvent);
|
|
399
428
|
if (replacement) {
|
|
400
|
-
|
|
429
|
+
// Untyped extension handlers can return messages with null/missing content;
|
|
430
|
+
// normalize so it never enters agent state or session history.
|
|
431
|
+
const normalized = (replacement.role === "user" ||
|
|
432
|
+
replacement.role === "assistant" ||
|
|
433
|
+
replacement.role === "toolResult" ||
|
|
434
|
+
replacement.role === "custom") &&
|
|
435
|
+
replacement.content == null
|
|
436
|
+
? { ...replacement, content: [] }
|
|
437
|
+
: replacement;
|
|
438
|
+
this._replaceMessageInPlace(event.message, normalized);
|
|
401
439
|
}
|
|
402
440
|
}
|
|
403
441
|
else if (event.type === "tool_execution_start") {
|
|
@@ -553,7 +591,7 @@ export class AgentSession {
|
|
|
553
591
|
this.agent.state.tools = tools;
|
|
554
592
|
// Rebuild base system prompt with new tool set
|
|
555
593
|
this._baseSystemPrompt = this._rebuildSystemPrompt(validToolNames);
|
|
556
|
-
this.agent.state.systemPrompt = this._baseSystemPrompt;
|
|
594
|
+
this.agent.state.systemPrompt = this._systemPromptOverride ?? this._baseSystemPrompt;
|
|
557
595
|
}
|
|
558
596
|
/** Whether compaction or branch summarization is currently running */
|
|
559
597
|
get isCompacting() {
|
|
@@ -661,6 +699,7 @@ export class AgentSession {
|
|
|
661
699
|
}
|
|
662
700
|
}
|
|
663
701
|
finally {
|
|
702
|
+
this._systemPromptOverride = undefined;
|
|
664
703
|
this._flushPendingBashMessages();
|
|
665
704
|
}
|
|
666
705
|
}
|
|
@@ -762,18 +801,11 @@ export class AgentSession {
|
|
|
762
801
|
}
|
|
763
802
|
throw new Error(formatNoApiKeyFoundMessage(this.model.provider));
|
|
764
803
|
}
|
|
765
|
-
// Check if we need to compact before sending (catches aborted responses)
|
|
804
|
+
// Check if we need to compact before sending (catches aborted responses).
|
|
805
|
+
// The user's new prompt is sent below, so do not call agent.continue() here.
|
|
766
806
|
const lastAssistant = this._findLastAssistantMessage();
|
|
767
|
-
if (lastAssistant
|
|
768
|
-
|
|
769
|
-
await this.agent.continue();
|
|
770
|
-
while (await this._handlePostAgentRun()) {
|
|
771
|
-
await this.agent.continue();
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
finally {
|
|
775
|
-
this._flushPendingBashMessages();
|
|
776
|
-
}
|
|
807
|
+
if (lastAssistant) {
|
|
808
|
+
await this._checkCompaction(lastAssistant, false);
|
|
777
809
|
}
|
|
778
810
|
// Build messages array (custom message if any, then user message)
|
|
779
811
|
messages = [];
|
|
@@ -800,7 +832,8 @@ export class AgentSession {
|
|
|
800
832
|
messages.push({
|
|
801
833
|
role: "custom",
|
|
802
834
|
customType: msg.customType,
|
|
803
|
-
content
|
|
835
|
+
// Untyped extensions can pass null/missing content; normalize at ingestion.
|
|
836
|
+
content: msg.content ?? [],
|
|
804
837
|
display: msg.display,
|
|
805
838
|
details: msg.details,
|
|
806
839
|
timestamp: Date.now(),
|
|
@@ -808,11 +841,13 @@ export class AgentSession {
|
|
|
808
841
|
}
|
|
809
842
|
}
|
|
810
843
|
// Apply extension-modified system prompt, or reset to base
|
|
811
|
-
if (result?.systemPrompt) {
|
|
844
|
+
if (result?.systemPrompt !== undefined) {
|
|
845
|
+
this._systemPromptOverride = result.systemPrompt;
|
|
812
846
|
this.agent.state.systemPrompt = result.systemPrompt;
|
|
813
847
|
}
|
|
814
848
|
else {
|
|
815
849
|
// Ensure we're using the base prompt (in case previous turn had modifications)
|
|
850
|
+
this._systemPromptOverride = undefined;
|
|
816
851
|
this.agent.state.systemPrompt = this._baseSystemPrompt;
|
|
817
852
|
}
|
|
818
853
|
}
|
|
@@ -977,7 +1012,8 @@ export class AgentSession {
|
|
|
977
1012
|
const appMessage = {
|
|
978
1013
|
role: "custom",
|
|
979
1014
|
customType: message.customType,
|
|
980
|
-
content
|
|
1015
|
+
// Untyped extensions can pass null/missing content; normalize at ingestion.
|
|
1016
|
+
content: message.content ?? [],
|
|
981
1017
|
display: message.display,
|
|
982
1018
|
details: message.details,
|
|
983
1019
|
timestamp: Date.now(),
|
|
@@ -1273,7 +1309,7 @@ export class AgentSession {
|
|
|
1273
1309
|
if (!this.model) {
|
|
1274
1310
|
throw new Error(formatNoModelSelectedMessage());
|
|
1275
1311
|
}
|
|
1276
|
-
const { apiKey, headers } = await this._getCompactionRequestAuth(this.model);
|
|
1312
|
+
const { apiKey, headers, env } = await this._getCompactionRequestAuth(this.model);
|
|
1277
1313
|
const pathEntries = this.sessionManager.getBranch();
|
|
1278
1314
|
const settings = this.settingsManager.getCompactionSettings();
|
|
1279
1315
|
const preparation = prepareCompaction(pathEntries, settings);
|
|
@@ -1293,6 +1329,8 @@ export class AgentSession {
|
|
|
1293
1329
|
preparation,
|
|
1294
1330
|
branchEntries: pathEntries,
|
|
1295
1331
|
customInstructions,
|
|
1332
|
+
reason: "manual",
|
|
1333
|
+
willRetry: false,
|
|
1296
1334
|
signal: this._compactionAbortController.signal,
|
|
1297
1335
|
}));
|
|
1298
1336
|
if (result?.cancel) {
|
|
@@ -1316,7 +1354,7 @@ export class AgentSession {
|
|
|
1316
1354
|
}
|
|
1317
1355
|
else {
|
|
1318
1356
|
// Generate compaction result
|
|
1319
|
-
const result = await compact(preparation, this.model, apiKey, headers, customInstructions, this._compactionAbortController.signal, this.thinkingLevel, this.agent.streamFn);
|
|
1357
|
+
const result = await compact(preparation, this.model, apiKey, headers, customInstructions, this._compactionAbortController.signal, this.thinkingLevel, this.agent.streamFn, env);
|
|
1320
1358
|
summary = result.summary;
|
|
1321
1359
|
firstKeptEntryId = result.firstKeptEntryId;
|
|
1322
1360
|
tokensBefore = result.tokensBefore;
|
|
@@ -1329,6 +1367,7 @@ export class AgentSession {
|
|
|
1329
1367
|
const newEntries = this.sessionManager.getEntries();
|
|
1330
1368
|
const sessionContext = this.sessionManager.buildSessionContext();
|
|
1331
1369
|
this.agent.state.messages = sessionContext.messages;
|
|
1370
|
+
const estimatedTokensAfter = estimateMessagesTokens(sessionContext.messages);
|
|
1332
1371
|
// Get the saved compaction entry for the extension event
|
|
1333
1372
|
const savedCompactionEntry = newEntries.find((e) => e.type === "compaction" && e.summary === summary);
|
|
1334
1373
|
if (this._extensionRunner && savedCompactionEntry) {
|
|
@@ -1336,12 +1375,15 @@ export class AgentSession {
|
|
|
1336
1375
|
type: "session_compact",
|
|
1337
1376
|
compactionEntry: savedCompactionEntry,
|
|
1338
1377
|
fromExtension,
|
|
1378
|
+
reason: "manual",
|
|
1379
|
+
willRetry: false,
|
|
1339
1380
|
});
|
|
1340
1381
|
}
|
|
1341
1382
|
const compactionResult = {
|
|
1342
1383
|
summary,
|
|
1343
1384
|
firstKeptEntryId,
|
|
1344
1385
|
tokensBefore,
|
|
1386
|
+
estimatedTokensAfter,
|
|
1345
1387
|
details,
|
|
1346
1388
|
};
|
|
1347
1389
|
this._emit({
|
|
@@ -1416,8 +1458,15 @@ export class AgentSession {
|
|
|
1416
1458
|
if (assistantIsFromBeforeCompaction) {
|
|
1417
1459
|
return false;
|
|
1418
1460
|
}
|
|
1419
|
-
// Case 1: Overflow - LLM returned context overflow error
|
|
1461
|
+
// Case 1: Overflow - LLM returned context overflow error, or reported usage exceeded
|
|
1462
|
+
// the configured window. A successful response over the configured window should compact
|
|
1463
|
+
// but must not retry: the assistant answer already completed and agent.continue() cannot
|
|
1464
|
+
// continue from an assistant message.
|
|
1420
1465
|
if (sameModel && isContextOverflow(assistantMessage, contextWindow)) {
|
|
1466
|
+
const willRetry = assistantMessage.stopReason !== "stop";
|
|
1467
|
+
if (!willRetry) {
|
|
1468
|
+
return await this._runAutoCompaction("overflow", false);
|
|
1469
|
+
}
|
|
1421
1470
|
if (this._overflowRecoveryAttempted) {
|
|
1422
1471
|
this._emit({
|
|
1423
1472
|
type: "compaction_end",
|
|
@@ -1436,13 +1485,15 @@ export class AgentSession {
|
|
|
1436
1485
|
if (messages.length > 0 && messages[messages.length - 1].role === "assistant") {
|
|
1437
1486
|
this.agent.state.messages = messages.slice(0, -1);
|
|
1438
1487
|
}
|
|
1439
|
-
return await this._runAutoCompaction("overflow",
|
|
1488
|
+
return await this._runAutoCompaction("overflow", willRetry);
|
|
1440
1489
|
}
|
|
1441
1490
|
// Case 2: Threshold - context is getting large
|
|
1442
|
-
// For error messages
|
|
1443
|
-
// This ensures sessions that hit persistent API errors (e.g. 529)
|
|
1491
|
+
// For error messages or all-zero usage messages, estimate from the last valid response.
|
|
1492
|
+
// This ensures sessions that hit persistent API errors (e.g. 529) or malformed zero-usage
|
|
1493
|
+
// responses can still compact and do not reset context accounting.
|
|
1444
1494
|
let contextTokens;
|
|
1445
|
-
|
|
1495
|
+
const directContextTokens = assistantMessage.usage ? calculateContextTokens(assistantMessage.usage) : 0;
|
|
1496
|
+
if (assistantMessage.stopReason === "error" || directContextTokens === 0) {
|
|
1446
1497
|
const messages = this.agent.state.messages;
|
|
1447
1498
|
const estimate = estimateContextTokens(messages);
|
|
1448
1499
|
if (estimate.lastUsageIndex === null)
|
|
@@ -1459,7 +1510,7 @@ export class AgentSession {
|
|
|
1459
1510
|
contextTokens = estimate.tokens;
|
|
1460
1511
|
}
|
|
1461
1512
|
else {
|
|
1462
|
-
contextTokens =
|
|
1513
|
+
contextTokens = directContextTokens;
|
|
1463
1514
|
}
|
|
1464
1515
|
if (shouldCompact(contextTokens, contextWindow, settings)) {
|
|
1465
1516
|
return await this._runAutoCompaction("threshold", false);
|
|
@@ -1471,51 +1522,34 @@ export class AgentSession {
|
|
|
1471
1522
|
*/
|
|
1472
1523
|
async _runAutoCompaction(reason, willRetry) {
|
|
1473
1524
|
const settings = this.settingsManager.getCompactionSettings();
|
|
1474
|
-
|
|
1475
|
-
this._autoCompactionAbortController = new AbortController();
|
|
1525
|
+
let started = false;
|
|
1476
1526
|
try {
|
|
1477
1527
|
if (!this.model) {
|
|
1478
|
-
this._emit({
|
|
1479
|
-
type: "compaction_end",
|
|
1480
|
-
reason,
|
|
1481
|
-
result: undefined,
|
|
1482
|
-
aborted: false,
|
|
1483
|
-
willRetry: false,
|
|
1484
|
-
});
|
|
1485
1528
|
return false;
|
|
1486
1529
|
}
|
|
1487
1530
|
let apiKey;
|
|
1488
1531
|
let headers;
|
|
1532
|
+
let env;
|
|
1489
1533
|
if (this.agent.streamFn === streamSimple) {
|
|
1490
1534
|
const authResult = await this._modelRegistry.getApiKeyAndHeaders(this.model);
|
|
1491
1535
|
if (!authResult.ok || !authResult.apiKey) {
|
|
1492
|
-
this._emit({
|
|
1493
|
-
type: "compaction_end",
|
|
1494
|
-
reason,
|
|
1495
|
-
result: undefined,
|
|
1496
|
-
aborted: false,
|
|
1497
|
-
willRetry: false,
|
|
1498
|
-
});
|
|
1499
1536
|
return false;
|
|
1500
1537
|
}
|
|
1501
1538
|
apiKey = authResult.apiKey;
|
|
1502
1539
|
headers = authResult.headers;
|
|
1540
|
+
env = authResult.env;
|
|
1503
1541
|
}
|
|
1504
1542
|
else {
|
|
1505
|
-
({ apiKey, headers } = await this._getCompactionRequestAuth(this.model));
|
|
1543
|
+
({ apiKey, headers, env } = await this._getCompactionRequestAuth(this.model));
|
|
1506
1544
|
}
|
|
1507
1545
|
const pathEntries = this.sessionManager.getBranch();
|
|
1508
1546
|
const preparation = prepareCompaction(pathEntries, settings);
|
|
1509
1547
|
if (!preparation) {
|
|
1510
|
-
this._emit({
|
|
1511
|
-
type: "compaction_end",
|
|
1512
|
-
reason,
|
|
1513
|
-
result: undefined,
|
|
1514
|
-
aborted: false,
|
|
1515
|
-
willRetry: false,
|
|
1516
|
-
});
|
|
1517
1548
|
return false;
|
|
1518
1549
|
}
|
|
1550
|
+
this._emit({ type: "compaction_start", reason });
|
|
1551
|
+
this._autoCompactionAbortController = new AbortController();
|
|
1552
|
+
started = true;
|
|
1519
1553
|
let extensionCompaction;
|
|
1520
1554
|
let fromExtension = false;
|
|
1521
1555
|
if (this._extensionRunner.hasHandlers("session_before_compact")) {
|
|
@@ -1524,6 +1558,8 @@ export class AgentSession {
|
|
|
1524
1558
|
preparation,
|
|
1525
1559
|
branchEntries: pathEntries,
|
|
1526
1560
|
customInstructions: undefined,
|
|
1561
|
+
reason,
|
|
1562
|
+
willRetry,
|
|
1527
1563
|
signal: this._autoCompactionAbortController.signal,
|
|
1528
1564
|
}));
|
|
1529
1565
|
if (extensionResult?.cancel) {
|
|
@@ -1554,7 +1590,7 @@ export class AgentSession {
|
|
|
1554
1590
|
}
|
|
1555
1591
|
else {
|
|
1556
1592
|
// Generate compaction result
|
|
1557
|
-
const compactResult = await compact(preparation, this.model, apiKey, headers, undefined, this._autoCompactionAbortController.signal, this.thinkingLevel, this.agent.streamFn);
|
|
1593
|
+
const compactResult = await compact(preparation, this.model, apiKey, headers, undefined, this._autoCompactionAbortController.signal, this.thinkingLevel, this.agent.streamFn, env);
|
|
1558
1594
|
summary = compactResult.summary;
|
|
1559
1595
|
firstKeptEntryId = compactResult.firstKeptEntryId;
|
|
1560
1596
|
tokensBefore = compactResult.tokensBefore;
|
|
@@ -1574,6 +1610,7 @@ export class AgentSession {
|
|
|
1574
1610
|
const newEntries = this.sessionManager.getEntries();
|
|
1575
1611
|
const sessionContext = this.sessionManager.buildSessionContext();
|
|
1576
1612
|
this.agent.state.messages = sessionContext.messages;
|
|
1613
|
+
const estimatedTokensAfter = estimateMessagesTokens(sessionContext.messages);
|
|
1577
1614
|
// Get the saved compaction entry for the extension event
|
|
1578
1615
|
const savedCompactionEntry = newEntries.find((e) => e.type === "compaction" && e.summary === summary);
|
|
1579
1616
|
if (this._extensionRunner && savedCompactionEntry) {
|
|
@@ -1581,12 +1618,15 @@ export class AgentSession {
|
|
|
1581
1618
|
type: "session_compact",
|
|
1582
1619
|
compactionEntry: savedCompactionEntry,
|
|
1583
1620
|
fromExtension,
|
|
1621
|
+
reason,
|
|
1622
|
+
willRetry,
|
|
1584
1623
|
});
|
|
1585
1624
|
}
|
|
1586
1625
|
const result = {
|
|
1587
1626
|
summary,
|
|
1588
1627
|
firstKeptEntryId,
|
|
1589
1628
|
tokensBefore,
|
|
1629
|
+
estimatedTokensAfter,
|
|
1590
1630
|
details,
|
|
1591
1631
|
};
|
|
1592
1632
|
this._emit({ type: "compaction_end", reason, result, aborted: false, willRetry });
|
|
@@ -1604,16 +1644,18 @@ export class AgentSession {
|
|
|
1604
1644
|
}
|
|
1605
1645
|
catch (error) {
|
|
1606
1646
|
const errorMessage = error instanceof Error ? error.message : "compaction failed";
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1647
|
+
if (started) {
|
|
1648
|
+
this._emit({
|
|
1649
|
+
type: "compaction_end",
|
|
1650
|
+
reason,
|
|
1651
|
+
result: undefined,
|
|
1652
|
+
aborted: false,
|
|
1653
|
+
willRetry: false,
|
|
1654
|
+
errorMessage: reason === "overflow"
|
|
1655
|
+
? `Context overflow recovery failed: ${errorMessage}`
|
|
1656
|
+
: `Auto-compaction failed: ${errorMessage}`,
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1617
1659
|
return false;
|
|
1618
1660
|
}
|
|
1619
1661
|
finally {
|
|
@@ -1754,7 +1796,11 @@ export class AgentSession {
|
|
|
1754
1796
|
});
|
|
1755
1797
|
},
|
|
1756
1798
|
appendEntry: (customType, data) => {
|
|
1757
|
-
this.sessionManager.appendCustomEntry(customType, data);
|
|
1799
|
+
const entryId = this.sessionManager.appendCustomEntry(customType, data);
|
|
1800
|
+
const entry = this.sessionManager.getEntry(entryId);
|
|
1801
|
+
if (entry) {
|
|
1802
|
+
this._emit({ type: "entry_appended", entry });
|
|
1803
|
+
}
|
|
1758
1804
|
},
|
|
1759
1805
|
setSessionName: (name) => {
|
|
1760
1806
|
this.setSessionName(name);
|
|
@@ -1932,7 +1978,7 @@ export class AgentSession {
|
|
|
1932
1978
|
includeAllExtensionTools: options.includeAllExtensionTools,
|
|
1933
1979
|
});
|
|
1934
1980
|
}
|
|
1935
|
-
async reload() {
|
|
1981
|
+
async reload(options) {
|
|
1936
1982
|
const previousFlagValues = this._extensionRunner.getFlagValues();
|
|
1937
1983
|
await emitSessionShutdownEvent(this._extensionRunner, { type: "session_shutdown", reason: "reload" });
|
|
1938
1984
|
await this.settingsManager.reload();
|
|
@@ -1949,6 +1995,7 @@ export class AgentSession {
|
|
|
1949
1995
|
this._extensionShutdownHandler ||
|
|
1950
1996
|
this._extensionErrorListener;
|
|
1951
1997
|
if (hasBindings) {
|
|
1998
|
+
await options?.beforeSessionStart?.();
|
|
1952
1999
|
await this._extensionRunner.emit({ type: "session_start", reason: "reload" });
|
|
1953
2000
|
await this.extendResourcesFromExtensions("reload");
|
|
1954
2001
|
}
|
|
@@ -1956,25 +2003,15 @@ export class AgentSession {
|
|
|
1956
2003
|
// =========================================================================
|
|
1957
2004
|
// Auto-Retry
|
|
1958
2005
|
// =========================================================================
|
|
1959
|
-
_isNonRetryableProviderLimitError(errorMessage) {
|
|
1960
|
-
return /GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(errorMessage);
|
|
1961
|
-
}
|
|
1962
2006
|
/**
|
|
1963
2007
|
* Check if an error is retryable (overloaded, rate limit, server errors).
|
|
1964
2008
|
* Context overflow errors are NOT retryable (handled by compaction instead).
|
|
1965
2009
|
*/
|
|
1966
2010
|
_isRetryableError(message) {
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
// Context overflow is handled by compaction, not retry
|
|
1970
|
-
const contextWindow = this.model?.contextWindow ?? 0;
|
|
1971
|
-
if (isContextOverflow(message, contextWindow))
|
|
1972
|
-
return false;
|
|
1973
|
-
const err = message.errorMessage;
|
|
1974
|
-
if (this._isNonRetryableProviderLimitError(err))
|
|
2011
|
+
// Context overflow is handled by compaction, not retry.
|
|
2012
|
+
if (isContextOverflow(message, this.model?.contextWindow ?? 0))
|
|
1975
2013
|
return false;
|
|
1976
|
-
|
|
1977
|
-
return /overloaded|provider.?returned.?error|rate.?limit|too many requests|429|500|502|503|504|service.?unavailable|server.?error|internal.?error|network.?error|connection.?error|connection.?refused|connection.?lost|websocket.?closed|websocket.?error|other side closed|fetch failed|upstream.?connect|reset before headers|socket hang up|ended without|stream ended before message_stop|http2 request did not get a response|timed? out|timeout|terminated|retry delay/i.test(err);
|
|
2014
|
+
return isRetryableAssistantError(message);
|
|
1978
2015
|
}
|
|
1979
2016
|
/**
|
|
1980
2017
|
* Prepare a retryable error for continuation with exponential backoff.
|
|
@@ -2140,7 +2177,9 @@ export class AgentSession {
|
|
|
2140
2177
|
*/
|
|
2141
2178
|
setSessionName(name) {
|
|
2142
2179
|
this.sessionManager.appendSessionInfo(name);
|
|
2143
|
-
|
|
2180
|
+
const event = { type: "session_info_changed", name: this.sessionManager.getSessionName() };
|
|
2181
|
+
this._emit(event);
|
|
2182
|
+
void this._extensionRunner.emit(event);
|
|
2144
2183
|
}
|
|
2145
2184
|
// =========================================================================
|
|
2146
2185
|
// Tree Navigation
|
|
@@ -2221,12 +2260,13 @@ export class AgentSession {
|
|
|
2221
2260
|
let summaryDetails;
|
|
2222
2261
|
if (options.summarize && entriesToSummarize.length > 0 && !extensionSummary) {
|
|
2223
2262
|
const model = this.model;
|
|
2224
|
-
const { apiKey, headers } = await this._getRequiredRequestAuth(model);
|
|
2263
|
+
const { apiKey, headers, env } = await this._getRequiredRequestAuth(model);
|
|
2225
2264
|
const branchSummarySettings = this.settingsManager.getBranchSummarySettings();
|
|
2226
2265
|
const result = await generateBranchSummary(entriesToSummarize, {
|
|
2227
2266
|
model,
|
|
2228
2267
|
apiKey,
|
|
2229
2268
|
headers,
|
|
2269
|
+
env,
|
|
2230
2270
|
signal: this._branchSummaryAbortController.signal,
|
|
2231
2271
|
customInstructions,
|
|
2232
2272
|
replaceInstructions,
|
|
@@ -2411,8 +2451,8 @@ export class AgentSession {
|
|
|
2411
2451
|
const contextTokens = calculateContextTokens(assistant.usage);
|
|
2412
2452
|
if (contextTokens > 0) {
|
|
2413
2453
|
hasPostCompactionUsage = true;
|
|
2454
|
+
break;
|
|
2414
2455
|
}
|
|
2415
|
-
break;
|
|
2416
2456
|
}
|
|
2417
2457
|
}
|
|
2418
2458
|
}
|
|
@@ -2434,7 +2474,8 @@ export class AgentSession {
|
|
|
2434
2474
|
* @returns Path to exported file
|
|
2435
2475
|
*/
|
|
2436
2476
|
async exportToHtml(outputPath) {
|
|
2437
|
-
const
|
|
2477
|
+
const configuredThemeName = this.settingsManager.getTheme();
|
|
2478
|
+
const themeName = configuredThemeName && getThemeByName(configuredThemeName) ? configuredThemeName : undefined;
|
|
2438
2479
|
// Create tool renderer if we have an extension runner (for custom tool HTML rendering)
|
|
2439
2480
|
const toolRenderer = createToolHtmlRenderer({
|
|
2440
2481
|
getToolDefinition: (name) => this.getToolDefinition(name),
|