@astralyn/pi 1.3.1 → 1.4.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 +52 -0
- package/dist/bundle/chunks/anthropic-messages-HWL6AS7T.js +6 -0
- package/dist/bundle/chunks/azure-openai-responses-4YYPDYV5.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +8 -8
- package/dist/bundle/chunks/chunk-24FY4C5S.js +2 -0
- package/dist/bundle/chunks/chunk-6JS2SOFO.js +11 -0
- package/dist/bundle/chunks/chunk-ANCZPKX7.js +2 -0
- package/dist/bundle/chunks/{chunk-VOAXAPU6.js → chunk-KSKBY3VV.js} +161 -91
- package/dist/bundle/chunks/chunk-MMNIHCU7.js +2 -0
- package/dist/bundle/chunks/{chunk-KSCGI7JW.js → chunk-MZJC45TM.js} +2 -2
- package/dist/bundle/chunks/{chunk-LXR54CGB.js → chunk-N77PYEXG.js} +1 -1
- package/dist/bundle/chunks/{chunk-J75WV3FL.js → chunk-OV2VMHBX.js} +1 -1
- package/dist/bundle/chunks/chunk-TPVFPFJP.js +2 -0
- package/dist/bundle/chunks/chunk-ZAIGBRV5.js +16 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-7BKATOEJ.js +2 -0
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/google-generative-ai-HTUSU45F.js +2 -0
- package/dist/bundle/chunks/google-vertex-AVQV4P76.js +2 -0
- package/dist/bundle/chunks/{llama-cpp-classify-H3IZDR5O.js → llama-cpp-classify-27QYLJZY.js} +2 -2
- package/dist/bundle/chunks/{mistral-conversations-6E6SS3WF.js → mistral-conversations-V2JJTMJ5.js} +1 -1
- package/dist/bundle/chunks/openai-codex-responses-Q25MHDFX.js +10 -0
- package/dist/bundle/chunks/openai-completions-TXZXILJR.js +7 -0
- package/dist/bundle/chunks/{openai-decisions-TVCDIPZX.js → openai-decisions-3WYFPGSK.js} +1 -1
- package/dist/bundle/chunks/openai-responses-E4BNZIQK.js +4 -0
- package/dist/bundle/chunks/openrouter-images-CBP3OPOD.js +2 -0
- package/dist/bundle/chunks/pi-messages-LBJQ4NGP.js +8 -0
- package/dist/bundle/chunks/typesafe-system-one-BNICP2LS.js +2 -0
- package/dist/bundle/chunks/virtual-modules-XNEYDLXF.js +2 -0
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/agent-session.d.ts +7 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +61 -13
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/client-identity.d.ts +8 -0
- package/dist/core/client-identity.d.ts.map +1 -0
- package/dist/core/client-identity.js +15 -0
- package/dist/core/client-identity.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +25 -20
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +2 -0
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.html +1 -0
- package/dist/core/export-html/template.js +2 -1
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +30 -29
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +3 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +3 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/model-config.d.ts +915 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +48 -24
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.js +7 -7
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +6 -3
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +7 -3
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +9 -10
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/tasks/presentation.d.ts.map +1 -1
- package/dist/core/tasks/presentation.js +3 -1
- package/dist/core/tasks/presentation.js.map +1 -1
- package/dist/core/tasks/reminder.d.ts +15 -0
- package/dist/core/tasks/reminder.d.ts.map +1 -0
- package/dist/core/tasks/reminder.js +54 -0
- package/dist/core/tasks/reminder.js.map +1 -0
- package/dist/core/tasks/runtime.d.ts +4 -1
- package/dist/core/tasks/runtime.d.ts.map +1 -1
- package/dist/core/tasks/runtime.js +37 -11
- package/dist/core/tasks/runtime.js.map +1 -1
- package/dist/core/tasks/session.d.ts +9 -0
- package/dist/core/tasks/session.d.ts.map +1 -1
- package/dist/core/tasks/session.js +24 -0
- package/dist/core/tasks/session.js.map +1 -1
- package/dist/core/tasks/types.d.ts +6 -1
- package/dist/core/tasks/types.d.ts.map +1 -1
- package/dist/core/tasks/types.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +3 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/shell-tool.js +2 -2
- package/dist/core/tools/shell-tool.js.map +1 -1
- package/dist/core/tools/tasks/actions.d.ts +1 -1
- package/dist/core/tools/tasks/actions.d.ts.map +1 -1
- package/dist/core/tools/tasks/actions.js +98 -5
- package/dist/core/tools/tasks/actions.js.map +1 -1
- package/dist/core/tools/tasks/schema.d.ts +1 -1
- package/dist/core/tools/tasks/schema.d.ts.map +1 -1
- package/dist/core/tools/tasks/schema.js +9 -6
- package/dist/core/tools/tasks/schema.js.map +1 -1
- package/dist/core/tools/tasks/types.d.ts +9 -3
- package/dist/core/tools/tasks/types.d.ts.map +1 -1
- package/dist/core/tools/tasks/types.js.map +1 -1
- package/dist/core/tools/tasks.d.ts +1 -1
- package/dist/core/tools/tasks.d.ts.map +1 -1
- package/dist/core/tools/tasks.js +2 -2
- package/dist/core/tools/tasks.js.map +1 -1
- package/dist/extensions/cached-compaction/index.d.ts +3 -0
- package/dist/extensions/cached-compaction/index.d.ts.map +1 -0
- package/dist/extensions/cached-compaction/index.js +91 -0
- package/dist/extensions/cached-compaction/index.js.map +1 -0
- package/dist/extensions/cached-compaction/render.d.ts +11 -0
- package/dist/extensions/cached-compaction/render.d.ts.map +1 -0
- package/dist/extensions/cached-compaction/render.js +19 -0
- package/dist/extensions/cached-compaction/render.js.map +1 -0
- package/dist/extensions/cached-compaction/summary.d.ts +15 -0
- package/dist/extensions/cached-compaction/summary.d.ts.map +1 -0
- package/dist/extensions/cached-compaction/summary.js +131 -0
- package/dist/extensions/cached-compaction/summary.js.map +1 -0
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +99 -24
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +2 -0
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +3 -2
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +11 -15
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +68 -109
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/tasks/render.d.ts.map +1 -1
- package/dist/modes/interactive/tasks/render.js +17 -9
- package/dist/modes/interactive/tasks/render.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +2 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts.map +1 -1
- package/dist/utils/clipboard-command.js +3 -0
- package/dist/utils/clipboard-command.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts +1 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js +3 -2
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +45 -13
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +4 -3
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/bundled/extensions/cached-compaction.md +35 -0
- package/docs/bundled/tasks.md +17 -7
- package/docs/codemode.md +2 -2
- package/docs/compaction.md +5 -3
- package/docs/custom-provider.md +53 -1
- package/docs/docs.json +8 -0
- package/docs/environment-variables.md +1 -0
- package/docs/extensions.md +98 -3
- package/docs/models-configuration.md +196 -0
- package/docs/models.md +9 -5
- package/docs/sdk.md +2 -2
- package/docs/session-format.md +2 -2
- package/docs/settings.md +2 -2
- package/docs/tui.md +71 -0
- package/docs/windows.md +28 -0
- 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/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +150 -137
- package/package.json +7 -6
- package/schemas/models.schema.json +83 -29
- package/dist/bundle/chunks/anthropic-messages-MSB6JBS2.js +0 -6
- package/dist/bundle/chunks/azure-openai-responses-ATZ757I2.js +0 -2
- package/dist/bundle/chunks/chunk-4XZYHGVN.js +0 -11
- package/dist/bundle/chunks/chunk-7UBIBLPN.js +0 -2
- package/dist/bundle/chunks/chunk-LUYFHZ6W.js +0 -11
- package/dist/bundle/chunks/chunk-NM2KGRFS.js +0 -2
- package/dist/bundle/chunks/chunk-QDDSFJ35.js +0 -2
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-HGOVFZDC.js +0 -2
- package/dist/bundle/chunks/google-generative-ai-QRLQ4MCJ.js +0 -2
- package/dist/bundle/chunks/google-vertex-L3T6EGTL.js +0 -2
- package/dist/bundle/chunks/openai-codex-responses-4GUO76XJ.js +0 -10
- package/dist/bundle/chunks/openai-completions-O4TKZCIM.js +0 -7
- package/dist/bundle/chunks/openai-responses-VBQKJFNO.js +0 -3
- package/dist/bundle/chunks/openrouter-images-TDLJV5N4.js +0 -2
- package/dist/bundle/chunks/pi-messages-3POWZ43C.js +0 -8
- package/dist/bundle/chunks/typesafe-system-one-LWPJYTJP.js +0 -2
- package/dist/bundle/chunks/virtual-modules-CKPHR6LX.js +0 -2
- package/dist/core/provider-attribution.d.ts +0 -4
- package/dist/core/provider-attribution.d.ts.map +0 -1
- package/dist/core/provider-attribution.js +0 -72
- package/dist/core/provider-attribution.js.map +0 -1
|
@@ -16,7 +16,7 @@ import { createTasksToolDefinition } from "./tools/tasks.js";
|
|
|
16
16
|
import { readFileSync } from "node:fs";
|
|
17
17
|
import { basename, dirname } from "node:path";
|
|
18
18
|
import { runToolCall, } from "@earendil-works/pi-agent-core";
|
|
19
|
-
import { contentText, getCurrentSystemMessage, retryDelayMs } from "@earendil-works/pi-ai";
|
|
19
|
+
import { contentText, getCurrentSystemMessage, getCurrentTools, retryDelayMs } from "@earendil-works/pi-ai";
|
|
20
20
|
import { clampThinkingLevel, cleanupSessionResources, getSupportedThinkingLevels, isContextOverflow, isRecoverableLength, isRetryableAssistantError, modelsAreEqual, resetApiProviders, streamSimple, } from "@earendil-works/pi-ai/compat";
|
|
21
21
|
import { getThemeByName, theme } from "../modes/interactive/theme/theme.js";
|
|
22
22
|
import { stripFrontmatter } from "../utils/frontmatter.js";
|
|
@@ -110,7 +110,6 @@ export class AgentSession {
|
|
|
110
110
|
this._turnIndex = 0;
|
|
111
111
|
this._entryIdsByMessage = new WeakMap();
|
|
112
112
|
this._boundaryDispatchedMessages = new WeakSet();
|
|
113
|
-
this._lastAssistantToolResults = [];
|
|
114
113
|
this._lastActivityOutcome = "completed";
|
|
115
114
|
this._isBeforeSettle = false;
|
|
116
115
|
this._abortDuringBeforeSettle = false;
|
|
@@ -140,6 +139,11 @@ export class AgentSession {
|
|
|
140
139
|
this._handleAgentEvent = async (event) => {
|
|
141
140
|
if (event.type === "message_start")
|
|
142
141
|
this._tasksHost.delivery.messageStarted(event.message);
|
|
142
|
+
if (event.type === "message_end" &&
|
|
143
|
+
event.message.role === "assistant" &&
|
|
144
|
+
event.message.stopReason !== "error" &&
|
|
145
|
+
event.message.stopReason !== "aborted")
|
|
146
|
+
this._tasksHost.noteAssistantCompleted();
|
|
143
147
|
// An abort requested while the run was starting, e.g. during before_agent_start, stops it
|
|
144
148
|
// here. agent_start is awaited before the first request.
|
|
145
149
|
if (event.type === "agent_start" && this._agentRunAbortRequested)
|
|
@@ -228,7 +232,6 @@ export class AgentSession {
|
|
|
228
232
|
// extension and listener dispatch above also picks up messages that turn_end
|
|
229
233
|
// handlers queued.
|
|
230
234
|
if (event.type === "turn_end") {
|
|
231
|
-
this._lastAssistantToolResults = event.toolResults;
|
|
232
235
|
this._flushPendingCustomMessages();
|
|
233
236
|
}
|
|
234
237
|
if (event.type === "agent_end")
|
|
@@ -251,6 +254,7 @@ export class AgentSession {
|
|
|
251
254
|
deliver: (message, waitForPersistence) => {
|
|
252
255
|
if (this.isStreaming) {
|
|
253
256
|
this.agent.steer(message);
|
|
257
|
+
this._tasksHost.interruptWaits();
|
|
254
258
|
return waitForPersistence();
|
|
255
259
|
}
|
|
256
260
|
// An idle delivery starts its own custom-message run, which consumes the
|
|
@@ -291,6 +295,7 @@ export class AgentSession {
|
|
|
291
295
|
this._installAgentBoundaryHooks();
|
|
292
296
|
this._installHiddenDeclarationsProjection();
|
|
293
297
|
this._installAgentForcedPromptProjection();
|
|
298
|
+
this._installTaskContextReminderProjection();
|
|
294
299
|
this._buildRuntime({
|
|
295
300
|
activeToolNames: this._initialActiveToolNames,
|
|
296
301
|
includeAllExtensionTools: true,
|
|
@@ -883,7 +888,24 @@ export class AgentSession {
|
|
|
883
888
|
}
|
|
884
889
|
return undefined;
|
|
885
890
|
}
|
|
886
|
-
|
|
891
|
+
/**
|
|
892
|
+
* Persistently omit a failed attempt and its tool results from model context. Results are
|
|
893
|
+
* found in the projected context, so the pair stays together whether the attempt comes from
|
|
894
|
+
* the current run or a resumed session. An unpaired result fails the next request (#11227).
|
|
895
|
+
*/
|
|
896
|
+
_omitRecoveryAttempt(message) {
|
|
897
|
+
const toolCallIds = new Set(message.content.flatMap((block) => (block.type === "toolCall" ? [block.id] : [])));
|
|
898
|
+
// A context edit replaces the projected copy, so match it by source entry as well.
|
|
899
|
+
const entryId = this._findPersistedMessageEntryId(message);
|
|
900
|
+
const messages = this.agent.state.messages;
|
|
901
|
+
const index = messages.findIndex((m) => m === message || (entryId !== undefined && this._entryIdsByMessage.get(m) === entryId));
|
|
902
|
+
const toolResults = [];
|
|
903
|
+
for (const m of index < 0 ? [] : messages.slice(index + 1)) {
|
|
904
|
+
if (m.role === "assistant")
|
|
905
|
+
break;
|
|
906
|
+
if (m.role === "toolResult" && toolCallIds.has(m.toolCallId))
|
|
907
|
+
toolResults.push(m);
|
|
908
|
+
}
|
|
887
909
|
const targets = [message, ...toolResults];
|
|
888
910
|
const targetIds = targets.map((target) => this._findPersistedMessageEntryId(target));
|
|
889
911
|
const unresolvedProjectedTarget = targets.some((target, index) => targetIds[index] === undefined && this.agent.state.messages.includes(target));
|
|
@@ -1412,6 +1434,14 @@ export class AgentSession {
|
|
|
1412
1434
|
return [head, ...transformed.filter((message) => message.role !== "system")];
|
|
1413
1435
|
};
|
|
1414
1436
|
}
|
|
1437
|
+
/** Reminders live only in the request projection and survive failed requests until observed. */
|
|
1438
|
+
_installTaskContextReminderProjection() {
|
|
1439
|
+
const previousTransformContext = this.agent.transformContext;
|
|
1440
|
+
this.agent.transformContext = async (messages, signal) => {
|
|
1441
|
+
const transformed = previousTransformContext ? await previousTransformContext(messages, signal) : messages;
|
|
1442
|
+
return this._tasksHost.projectContextReminder(transformed);
|
|
1443
|
+
};
|
|
1444
|
+
}
|
|
1415
1445
|
/**
|
|
1416
1446
|
* Restore the active tool loadout declared by the session transcript, if it declares one.
|
|
1417
1447
|
* Tools reachable only from other tools are never declared, but they do not depend on the active
|
|
@@ -1420,11 +1450,27 @@ export class AgentSession {
|
|
|
1420
1450
|
*/
|
|
1421
1451
|
_restoreToolsFromTranscript(modifiers = []) {
|
|
1422
1452
|
this._pendingToolNames.clear();
|
|
1423
|
-
|
|
1424
|
-
|
|
1453
|
+
// All system messages on the branch, including those before a compaction. Compaction snapshots
|
|
1454
|
+
// are derived from these, so replaying them gives the current loadout.
|
|
1455
|
+
const systemMessages = this.sessionManager
|
|
1456
|
+
.getBranch()
|
|
1457
|
+
.flatMap((entry) => (entry.type === "message" && entry.message.role === "system" ? [entry.message] : []));
|
|
1458
|
+
// No recorded loadout: keep the current tools.
|
|
1459
|
+
if (systemMessages.length === 0)
|
|
1425
1460
|
return;
|
|
1426
|
-
|
|
1461
|
+
// Tools the branch ever added or removed. Removed tools stay inactive.
|
|
1462
|
+
const mentioned = new Set(systemMessages
|
|
1463
|
+
.flatMap((message) => [...(message.toolsAdded ?? []), ...(message.toolsRemoved ?? [])])
|
|
1464
|
+
.map((tool) => tool.name));
|
|
1465
|
+
// Extension tools the branch never mentioned were registered after it recorded its loadout, so
|
|
1466
|
+
// they are activated like newly registered tools. Built-in tools follow `defaultTools` instead.
|
|
1467
|
+
const newTools = [...this._toolRegistry.keys()].filter((name) => !mentioned.has(name) && !this._baseToolDefinitions.has(name) && this._isActivatedOnRegistration(name));
|
|
1468
|
+
// The recorded loadout plus the new tools, with `--tools +name`/`-name` applied.
|
|
1469
|
+
const names = applyToolModifiers([...getCurrentTools(systemMessages).map((tool) => tool.name), ...newTools], modifiers);
|
|
1470
|
+
// Recorded tools that are not registered yet, such as MCP tools of servers still connecting, are
|
|
1471
|
+
// activated when they register. Excluded tools never register, so they are not kept pending.
|
|
1427
1472
|
this._pendingToolNames = new Set(names.filter((name) => this._isAllowedTool(name)));
|
|
1473
|
+
// Ignores names that are not registered.
|
|
1428
1474
|
this._setActiveTools(names);
|
|
1429
1475
|
}
|
|
1430
1476
|
// =========================================================================
|
|
@@ -1547,9 +1593,7 @@ export class AgentSession {
|
|
|
1547
1593
|
}
|
|
1548
1594
|
async _handlePostAgentRun() {
|
|
1549
1595
|
const message = this._lastAssistantMessage;
|
|
1550
|
-
const toolResults = this._lastAssistantToolResults;
|
|
1551
1596
|
this._lastAssistantMessage = undefined;
|
|
1552
|
-
this._lastAssistantToolResults = [];
|
|
1553
1597
|
if (this._agentRunAbortRequested) {
|
|
1554
1598
|
this._finishCancelledRetry();
|
|
1555
1599
|
return false;
|
|
@@ -1575,7 +1619,7 @@ export class AgentSession {
|
|
|
1575
1619
|
});
|
|
1576
1620
|
this._retryAttempt = 0;
|
|
1577
1621
|
}
|
|
1578
|
-
if (await this._checkCompaction(message
|
|
1622
|
+
if (await this._checkCompaction(message)) {
|
|
1579
1623
|
return !this._agentRunAbortRequested;
|
|
1580
1624
|
}
|
|
1581
1625
|
// The low-level loop drains both queues before agent_end. Messages queued by
|
|
@@ -1853,6 +1897,7 @@ export class AgentSession {
|
|
|
1853
1897
|
content,
|
|
1854
1898
|
timestamp: Date.now(),
|
|
1855
1899
|
});
|
|
1900
|
+
this._tasksHost.interruptWaits();
|
|
1856
1901
|
}
|
|
1857
1902
|
/**
|
|
1858
1903
|
* Internal: Queue a follow-up message (already expanded, no extension command check).
|
|
@@ -1909,6 +1954,7 @@ export class AgentSession {
|
|
|
1909
1954
|
}
|
|
1910
1955
|
else {
|
|
1911
1956
|
this.agent.steer(appMessage);
|
|
1957
|
+
this._tasksHost.interruptWaits();
|
|
1912
1958
|
}
|
|
1913
1959
|
}
|
|
1914
1960
|
else if (options?.triggerTurn) {
|
|
@@ -2349,6 +2395,7 @@ export class AgentSession {
|
|
|
2349
2395
|
throw new Error("Compaction cancelled");
|
|
2350
2396
|
}
|
|
2351
2397
|
this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromExtension, usage);
|
|
2398
|
+
this._tasksHost.noteCompaction();
|
|
2352
2399
|
const newEntries = this.sessionManager.getEntries();
|
|
2353
2400
|
this._refreshFinalizedContext();
|
|
2354
2401
|
const estimatedTokensAfter = estimateMessagesTokens(this.sessionManager.buildSessionProjection().messages);
|
|
@@ -2442,7 +2489,7 @@ export class AgentSession {
|
|
|
2442
2489
|
* @param skipAbortedCheck If false, include aborted messages (for pre-prompt check). Default: true
|
|
2443
2490
|
* @returns Whether the post-run loop should call `agent.continue()` for overflow recovery or queued messages
|
|
2444
2491
|
*/
|
|
2445
|
-
async _checkCompaction(assistantMessage, skipAbortedCheck = true
|
|
2492
|
+
async _checkCompaction(assistantMessage, skipAbortedCheck = true) {
|
|
2446
2493
|
const settings = this.settingsManager.getCompactionSettings(this._modelForMessage(assistantMessage) ?? this.model);
|
|
2447
2494
|
if (!settings.enabled)
|
|
2448
2495
|
return false;
|
|
@@ -2519,7 +2566,7 @@ export class AgentSession {
|
|
|
2519
2566
|
}
|
|
2520
2567
|
// Persistently omit the selected final attempt before post-run recovery compaction.
|
|
2521
2568
|
this._overflowRecoveryAttempted = true;
|
|
2522
|
-
this._omitRecoveryAttempt(assistantMessage
|
|
2569
|
+
this._omitRecoveryAttempt(assistantMessage);
|
|
2523
2570
|
const retry = await this._runAutoCompaction("overflow", willRetry);
|
|
2524
2571
|
if (retry)
|
|
2525
2572
|
this._failedResponse = assistantMessage;
|
|
@@ -2641,6 +2688,7 @@ export class AgentSession {
|
|
|
2641
2688
|
}
|
|
2642
2689
|
abortController.signal.throwIfAborted();
|
|
2643
2690
|
this.sessionManager.appendCompaction(summary, firstKeptEntryId, tokensBefore, details, fromExtension, usage);
|
|
2691
|
+
this._tasksHost.noteCompaction();
|
|
2644
2692
|
const newEntries = this.sessionManager.getEntries();
|
|
2645
2693
|
this._refreshFinalizedContext();
|
|
2646
2694
|
const estimatedTokensAfter = estimateMessagesTokens(this.sessionManager.buildSessionProjection().messages);
|
|
@@ -3045,7 +3093,7 @@ export class AgentSession {
|
|
|
3045
3093
|
bash: { commandPrefix: shellCommandPrefix, shellPath },
|
|
3046
3094
|
});
|
|
3047
3095
|
this._baseToolDefinitions = new Map(Object.entries(baseToolDefinitions).map(([name, tool]) => [name, tool]));
|
|
3048
|
-
this._baseToolDefinitions.set("tasks", createTasksToolDefinition((callId, taskId) => this._tasksHost.delivery.prepareWait(callId, taskId)));
|
|
3096
|
+
this._baseToolDefinitions.set("tasks", createTasksToolDefinition((callId, taskId) => this._tasksHost.delivery.prepareWait(callId, taskId), () => this._tasksHost.waitInterruptSignal));
|
|
3049
3097
|
const extensionsResult = this._resourceLoader.getExtensions();
|
|
3050
3098
|
if (options.flagValues) {
|
|
3051
3099
|
for (const [name, value] of options.flagValues) {
|