@ponythewhite/base-context 1.0.8 → 1.0.10
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 +13 -0
- package/dist/base-context-runtime/pyproject.toml +1 -1
- package/dist/base-context-runtime/uv.lock +1 -1
- package/dist/build-info.json +1 -1
- package/dist/bundle/{bundled-modules-IGMJH2MU.js → bundled-modules-MX6YNAM2.js} +2 -2
- package/dist/bundle/{chunk-EXEFSSF4.js → chunk-CDXQNS5P.js} +176 -37
- package/dist/bundle/{chunk-RVJVXZCS.js → chunk-UHLGPYMI.js} +20 -40
- package/dist/bundle/{cli-main-BUK7QTHO.js → cli-main-D7W3WWCV.js} +2 -2
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/{main-2FWHT2WZ.js → main-5J3QBZ5Y.js} +2 -2
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +48 -5
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/canonical-context.d.ts.map +1 -1
- package/dist/core/canonical-context.js +115 -30
- package/dist/core/canonical-context.js.map +1 -1
- package/dist/core/context-epoch.d.ts +14 -3
- package/dist/core/context-epoch.d.ts.map +1 -1
- package/dist/core/context-epoch.js +5 -1
- package/dist/core/context-epoch.js.map +1 -1
- package/dist/core/inference-coordinator.d.ts +1 -1
- package/dist/core/inference-coordinator.d.ts.map +1 -1
- package/dist/core/inference-coordinator.js +2 -2
- package/dist/core/inference-coordinator.js.map +1 -1
- package/dist/core/public-context.d.ts.map +1 -1
- package/dist/core/public-context.js +20 -8
- package/dist/core/public-context.js.map +1 -1
- package/dist/core/request-view-selection.d.ts +4 -2
- package/dist/core/request-view-selection.d.ts.map +1 -1
- package/dist/core/request-view-selection.js +7 -4
- package/dist/core/request-view-selection.js.map +1 -1
- package/dist/core/session-manager.d.ts +2 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +38 -13
- package/dist/core/session-manager.js.map +1 -1
- package/dist/modes/daemon/daemon-mode.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-mode.js +15 -30
- package/dist/modes/daemon/daemon-mode.js.map +1 -1
- package/dist/modes/daemon/daemon-socket.d.ts +5 -0
- package/dist/modes/daemon/daemon-socket.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-socket.js +19 -0
- package/dist/modes/daemon/daemon-socket.js.map +1 -1
- package/dist/modes/daemon/daemon-supervisor.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-supervisor.js +6 -7
- package/dist/modes/daemon/daemon-supervisor.js.map +1 -1
- package/dist/modes/daemon/daemon-worker-client.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-worker-client.js +5 -5
- package/dist/modes/daemon/daemon-worker-client.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.10] - 2026-09-19
|
|
4
|
+
|
|
5
|
+
- Fixed session attachment disconnecting during concurrent transcript updates.
|
|
6
|
+
- Fixed worker request timeouts and connection closure hanging behind blocked socket writes.
|
|
7
|
+
- Fixed daemon shutdown waiting indefinitely for half-open client connections.
|
|
8
|
+
- Fixed idle eviction blocking the release of an existing session input pause.
|
|
9
|
+
- Fixed cold resume after an interruption before tool admission, preserving incomplete tool calls as historical data without rerunning them.
|
|
10
|
+
|
|
11
|
+
## [1.0.9] - 2026-09-19
|
|
12
|
+
|
|
13
|
+
- Fixed compaction and context checkpoint adoption rejecting concurrent child usage and session bookkeeping updates as branch changes. Real conversation, source, and branch changes still invalidate stale summaries.
|
|
14
|
+
- Fixed repeated automatic summary attempts on unchanged context after a failed threshold compaction. Manual retries and new input remain available.
|
|
15
|
+
|
|
3
16
|
## [1.0.8] - 2026-09-18
|
|
4
17
|
|
|
5
18
|
- Fixed harness-state saves to replace files atomically, preserve failed mutations, and report corrupt state without overwriting it.
|
package/dist/build-info.json
CHANGED
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
oauth_exports,
|
|
52
52
|
runPrintMode,
|
|
53
53
|
runRpcMode
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-UHLGPYMI.js";
|
|
55
55
|
import {
|
|
56
56
|
AgentSession,
|
|
57
57
|
CURRENT_SESSION_VERSION,
|
|
@@ -143,7 +143,7 @@ import {
|
|
|
143
143
|
withFileMutationQueue,
|
|
144
144
|
wrapRegisteredTool,
|
|
145
145
|
wrapRegisteredTools
|
|
146
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-CDXQNS5P.js";
|
|
147
147
|
import "./chunk-CFNASUYO.js";
|
|
148
148
|
import "./chunk-QKIFBA7N.js";
|
|
149
149
|
import {
|
|
@@ -27737,6 +27737,7 @@ var CONTEXT_POLICY_EPOCH_RENDERER = "native-canonical-epoch/5";
|
|
|
27737
27737
|
var CONTEXT_TOOL_EPOCH_RENDERER = "native-canonical-epoch/6";
|
|
27738
27738
|
var CONTEXT_SKILL_EPOCH_RENDERER = "native-canonical-epoch/7";
|
|
27739
27739
|
var CONTEXT_TOOL_SUMMARY_RENDERER = "native-canonical-epoch/8";
|
|
27740
|
+
var CONTEXT_INTERRUPTED_TOOL_RENDERER = "native-canonical-epoch/9";
|
|
27740
27741
|
function contextEpochMode(checkpoint, initial = "on") {
|
|
27741
27742
|
return checkpoint ? checkpoint.version === 5 || checkpoint.version === 8 ? checkpoint.mode : "on" : initial;
|
|
27742
27743
|
}
|
|
@@ -27785,7 +27786,7 @@ function readContextEpoch(details, maxBytes) {
|
|
|
27785
27786
|
if (!details || typeof details !== "object" || !(CONTEXT_EPOCH_DETAIL in details))
|
|
27786
27787
|
return;
|
|
27787
27788
|
const value = details[CONTEXT_EPOCH_DETAIL];
|
|
27788
|
-
if (!value || typeof value !== "object" || !("version" in value) || !("renderer" in value) || !(value.version === 1 && value.renderer === "native-canonical-epoch/1" || value.version === 2 && value.renderer === "native-canonical-epoch/2" || value.version === 3 && value.renderer === "native-canonical-epoch/3" || value.version === 4 && value.renderer === "native-canonical-epoch/4" || value.version === 5 && value.renderer === CONTEXT_POLICY_EPOCH_RENDERER || value.version === 6 && value.renderer === CONTEXT_TOOL_EPOCH_RENDERER || value.version === 8 && value.renderer === CONTEXT_TOOL_SUMMARY_RENDERER || [4, 5, 6].includes(value.version) && value.renderer === CONTEXT_SKILL_EPOCH_RENDERER) || (value.renderer === CONTEXT_SKILL_EPOCH_RENDERER || value.version === 8 && "selectedSkills" in value ? !("selectedSkills" in value) || !Array.isArray(value.selectedSkills) || value.selectedSkills.length === 0 || value.selectedSkills.some((item) => !item || typeof item.name !== "string" || !item.view || !["custom_message", "custom"].includes(item.view.ref?.kind) || typeof item.view.sourceRevision !== "string") || new Set(value.selectedSkills.map((item) => item.name)).size !== value.selectedSkills.length : "selectedSkills" in value) || !("source" in value) || !value.source || !("views" in value) || !Array.isArray(value.views) || !("literalTailId" in value) || typeof value.literalTailId !== "string" || !("representation" in value) || (value.version === 5 || value.version === 8 ? !("mode" in value) || value.mode !== "on" && value.mode !== "off" : "mode" in value) || value.version === 8 && (value.representation !== null || !("includeSummary" in value) || value.includeSummary !== true) || value.version === 5 && (value.representation !== null || !("policyOnly" in value) || value.policyOnly !== true) || "policyOnly" in value && (value.version !== 5 || value.policyOnly !== true || value.representation !== null || "includeSummary" in value) || "pendingRequestContract" in value && (value.version !== 5 || !("mode" in value) || value.mode !== "off" || value.pendingRequestContract !== true || "requestContract" in value) || "requestContract" in value && (value.version !== 5 || !isRequestContract(value.requestContract)) || !(typeof value.representation === "string" || value.version === 5 && value.representation === null && "policyOnly" in value && value.policyOnly === true || (value.version === 2 || value.version === 3 || value.version === 4 || value.version === 8) && value.representation === null && "includeSummary" in value && value.includeSummary === true) || "includeSummary" in value && (value.version !== 2 && value.version !== 3 && value.version !== 4 && value.version !== 8 || value.includeSummary !== true || value.representation !== null) || "replayContract" in value && value.replayContract !== "complete-context" && value.replayContract !== "message-groups" || "resourceRevision" in value && (typeof value.resourceRevision !== "string" || Buffer.byteLength(value.resourceRevision, "utf8") > MAX_RESOURCE_REVISION_BYTES) || "publicWindow" in value && (value.version !== 3 && value.version !== 4 && value.version !== 5 && value.version !== 6 && value.version !== 8 || value.publicWindow !== true) || "toolContinuations" in value && value.version !== 6 && value.version !== 8 || (value.version === 6 || value.version === 8) && (!("toolContinuations" in value) || !Array.isArray(value.toolContinuations) || !value.toolContinuations.length || !("replayContract" in value) || value.version === 6 && (!("publicWindow" in value) || value.publicWindow !== true || value.replayContract !== "message-groups")) || "continuation" in value && (value.version !== 3 && value.version !== 4 && value.version !== 5 && value.version !== 6 && value.version !== 8 || !value.continuation || typeof value.continuation !== "object" || !("kind" in value.continuation) || value.continuation.kind !== "harness-summary" && (value.version !== 4 && value.version !== 5 && value.version !== 6 || value.continuation.kind !== "portable-checkpoint") || !("publicTailThrough" in value.continuation) || !value.continuation.publicTailThrough))
|
|
27789
|
+
if (!value || typeof value !== "object" || !("version" in value) || !("renderer" in value) || !(value.version === 1 && value.renderer === "native-canonical-epoch/1" || value.version === 2 && value.renderer === "native-canonical-epoch/2" || value.version === 3 && value.renderer === "native-canonical-epoch/3" || value.version === 4 && value.renderer === "native-canonical-epoch/4" || value.version === 5 && value.renderer === CONTEXT_POLICY_EPOCH_RENDERER || value.version === 6 && value.renderer === CONTEXT_TOOL_EPOCH_RENDERER || value.version === 8 && value.renderer === CONTEXT_TOOL_SUMMARY_RENDERER || [6, 8].includes(value.version) && value.renderer === CONTEXT_INTERRUPTED_TOOL_RENDERER || [4, 5, 6].includes(value.version) && value.renderer === CONTEXT_SKILL_EPOCH_RENDERER) || (value.renderer === CONTEXT_SKILL_EPOCH_RENDERER || (value.version === 8 || value.renderer === CONTEXT_INTERRUPTED_TOOL_RENDERER) && "selectedSkills" in value ? !("selectedSkills" in value) || !Array.isArray(value.selectedSkills) || value.selectedSkills.length === 0 || value.selectedSkills.some((item) => !item || typeof item.name !== "string" || !item.view || !["custom_message", "custom"].includes(item.view.ref?.kind) || typeof item.view.sourceRevision !== "string") || new Set(value.selectedSkills.map((item) => item.name)).size !== value.selectedSkills.length : "selectedSkills" in value) || !("source" in value) || !value.source || !("views" in value) || !Array.isArray(value.views) || !("literalTailId" in value) || typeof value.literalTailId !== "string" || !("representation" in value) || (value.version === 5 || value.version === 8 ? !("mode" in value) || value.mode !== "on" && value.mode !== "off" : "mode" in value) || value.version === 8 && (value.representation !== null || !("includeSummary" in value) || value.includeSummary !== true) || value.version === 5 && (value.representation !== null || !("policyOnly" in value) || value.policyOnly !== true) || "policyOnly" in value && (value.version !== 5 || value.policyOnly !== true || value.representation !== null || "includeSummary" in value) || "pendingRequestContract" in value && (value.version !== 5 || !("mode" in value) || value.mode !== "off" || value.pendingRequestContract !== true || "requestContract" in value) || "requestContract" in value && (value.version !== 5 || !isRequestContract(value.requestContract)) || !(typeof value.representation === "string" || value.version === 5 && value.representation === null && "policyOnly" in value && value.policyOnly === true || (value.version === 2 || value.version === 3 || value.version === 4 || value.version === 8) && value.representation === null && "includeSummary" in value && value.includeSummary === true) || "includeSummary" in value && (value.version !== 2 && value.version !== 3 && value.version !== 4 && value.version !== 8 || value.includeSummary !== true || value.representation !== null) || "replayContract" in value && value.replayContract !== "complete-context" && value.replayContract !== "message-groups" || "resourceRevision" in value && (typeof value.resourceRevision !== "string" || Buffer.byteLength(value.resourceRevision, "utf8") > MAX_RESOURCE_REVISION_BYTES) || "publicWindow" in value && (value.version !== 3 && value.version !== 4 && value.version !== 5 && value.version !== 6 && value.version !== 8 || value.publicWindow !== true) || "toolContinuations" in value && value.version !== 6 && value.version !== 8 || (value.version === 6 || value.version === 8) && (!("toolContinuations" in value) || !Array.isArray(value.toolContinuations) || !value.toolContinuations.length || !("replayContract" in value) || value.version === 6 && (!("publicWindow" in value) || value.publicWindow !== true || value.replayContract !== "message-groups")) || "continuation" in value && (value.version !== 3 && value.version !== 4 && value.version !== 5 && value.version !== 6 && value.version !== 8 || !value.continuation || typeof value.continuation !== "object" || !("kind" in value.continuation) || value.continuation.kind !== "harness-summary" && (value.version !== 4 && value.version !== 5 && value.version !== 6 || value.continuation.kind !== "portable-checkpoint") || !("publicTailThrough" in value.continuation) || !value.continuation.publicTailThrough))
|
|
27789
27790
|
throw new Error("Invalid committed context epoch");
|
|
27790
27791
|
return snapshotContextEpoch(value, maxBytes);
|
|
27791
27792
|
}
|
|
@@ -28443,19 +28444,27 @@ function renderToolContinuation(message2, entryId, source, group, maxBytes) {
|
|
|
28443
28444
|
role: message2.role,
|
|
28444
28445
|
content,
|
|
28445
28446
|
...message2.role === "assistant" ? {
|
|
28446
|
-
calls: group.calls.map((call) =>
|
|
28447
|
+
calls: group.calls.map((call, sourceOrder) => call.admission === "absent" ? {
|
|
28448
|
+
sourceOrder,
|
|
28449
|
+
admission: "not_recorded",
|
|
28450
|
+
capturedHistory: {
|
|
28451
|
+
sessionId: call.source.sessionId,
|
|
28452
|
+
leafId: call.source.leafId,
|
|
28453
|
+
sourceSequence: call.source.sourceSequence
|
|
28454
|
+
}
|
|
28455
|
+
} : {
|
|
28447
28456
|
executionId: call.executionId,
|
|
28448
28457
|
intentEntryId: call.intent.id,
|
|
28449
28458
|
intent: "recorded",
|
|
28450
28459
|
outcome: call.outcome,
|
|
28451
28460
|
...call.result ? { resultEntryId: call.result.id } : {}
|
|
28452
|
-
})
|
|
28461
|
+
})
|
|
28453
28462
|
} : {}
|
|
28454
28463
|
}, maxBytes);
|
|
28455
28464
|
const rendered = {
|
|
28456
28465
|
role: "custom",
|
|
28457
28466
|
customType: PUBLIC_TOOL_CONTINUATION_RENDERER,
|
|
28458
|
-
content: `Recorded tool continuation data. Intent acknowledgment records intent only; an absent finalized result leaves the outcome unknown.
|
|
28467
|
+
content: `Recorded tool continuation data. Intent acknowledgment records intent only; an absent finalized result leaves the outcome unknown.${group.calls.some((call) => call.admission === "absent") ? " For calls marked admission not recorded, no qualified admission or finalized result is recorded in that captured history; the outcome is unknown. This historical view does not authorize tool execution." : ""}
|
|
28459
28468
|
${data}`,
|
|
28460
28469
|
display: false,
|
|
28461
28470
|
timestamp: message2.timestamp
|
|
@@ -31549,7 +31558,7 @@ function prepareCanonicalEpoch(messages, selectedUnitIds, representation, maxByt
|
|
|
31549
31558
|
return {
|
|
31550
31559
|
checkpoint: snapshotContextEpoch({
|
|
31551
31560
|
version: context.toolContinuations?.length ? 6 : 4,
|
|
31552
|
-
renderer: context.selectedSkills?.length ? CONTEXT_SKILL_EPOCH_RENDERER : context.toolContinuations?.length ? CONTEXT_TOOL_EPOCH_RENDERER : CONTEXT_EPOCH_RENDERER,
|
|
31561
|
+
renderer: context.toolContinuations?.some((group) => group.calls.some((call) => call.admission === "absent")) ? CONTEXT_INTERRUPTED_TOOL_RENDERER : context.selectedSkills?.length ? CONTEXT_SKILL_EPOCH_RENDERER : context.toolContinuations?.length ? CONTEXT_TOOL_EPOCH_RENDERER : CONTEXT_EPOCH_RENDERER,
|
|
31553
31562
|
...context.selectedSkills?.length ? { selectedSkills: context.selectedSkills } : {},
|
|
31554
31563
|
...context.toolContinuations?.length ? { toolContinuations: context.toolContinuations } : {},
|
|
31555
31564
|
source: context.source,
|
|
@@ -31620,7 +31629,7 @@ function prepareRecoveryCompaction(messages, firstKeptEntryId, maxBytes) {
|
|
|
31620
31629
|
return;
|
|
31621
31630
|
return snapshotContextEpoch({
|
|
31622
31631
|
...toolGroups.size ? { version: 8, mode: context.mode } : { version: 4 },
|
|
31623
|
-
renderer: toolGroups.size ? CONTEXT_TOOL_SUMMARY_RENDERER : context.selectedSkills?.length ? CONTEXT_SKILL_EPOCH_RENDERER : CONTEXT_EPOCH_RENDERER,
|
|
31632
|
+
renderer: context.toolContinuations?.some((group) => group.calls.some((call) => call.admission === "absent")) ? CONTEXT_INTERRUPTED_TOOL_RENDERER : toolGroups.size ? CONTEXT_TOOL_SUMMARY_RENDERER : context.selectedSkills?.length ? CONTEXT_SKILL_EPOCH_RENDERER : CONTEXT_EPOCH_RENDERER,
|
|
31624
31633
|
...toolGroups.size ? { toolContinuations: context.toolContinuations } : {},
|
|
31625
31634
|
...context.selectedSkills?.length ? { selectedSkills: context.selectedSkills } : {},
|
|
31626
31635
|
source: context.source,
|
|
@@ -32110,6 +32119,10 @@ ${JSON.stringify(selections.map((skill) => ({
|
|
|
32110
32119
|
}
|
|
32111
32120
|
const replayUnits = bindMessageReplayUnits(messages, sourceUnits, unitLimits);
|
|
32112
32121
|
const frozenGroups = checkpoint?.toolContinuations ?? [];
|
|
32122
|
+
const assistantSequences = messages.flatMap((message2) => {
|
|
32123
|
+
const reference = epochReferences.get(message2);
|
|
32124
|
+
return message2.role === "assistant" && reference ? [reference.ref.sequence] : [];
|
|
32125
|
+
}).sort((left, right) => left - right);
|
|
32113
32126
|
const candidates = messages.flatMap((message2, index) => {
|
|
32114
32127
|
if (message2.role !== "assistant")
|
|
32115
32128
|
return [];
|
|
@@ -32125,6 +32138,8 @@ ${JSON.stringify(selections.map((skill) => ({
|
|
|
32125
32138
|
index,
|
|
32126
32139
|
reference,
|
|
32127
32140
|
prior,
|
|
32141
|
+
nextAssistantSequence: assistantSequences.find((sequence) => sequence > reference.ref.sequence) ?? Infinity,
|
|
32142
|
+
unqualifiedIntent: false,
|
|
32128
32143
|
intents: /* @__PURE__ */ new Map()
|
|
32129
32144
|
}
|
|
32130
32145
|
];
|
|
@@ -32140,48 +32155,63 @@ ${JSON.stringify(selections.map((skill) => ({
|
|
|
32140
32155
|
countBytes(metadata);
|
|
32141
32156
|
return hydrateCapturedHistoryEntry(metadata, maxSourceBytes, view.readPayload);
|
|
32142
32157
|
};
|
|
32143
|
-
const acceptIntent = async (metadata) => {
|
|
32144
|
-
if (metadata.kind !== "tool_intent"
|
|
32158
|
+
const acceptIntent = async (metadata, selected = candidates) => {
|
|
32159
|
+
if (metadata.kind !== "tool_intent")
|
|
32145
32160
|
return;
|
|
32146
32161
|
const hydrated = await readToolEvidence(metadata);
|
|
32147
32162
|
const entry = hydrated.entry;
|
|
32148
|
-
if (entry.type !== "tool_intent"
|
|
32163
|
+
if (entry.type !== "tool_intent")
|
|
32149
32164
|
return;
|
|
32150
|
-
const
|
|
32165
|
+
const invocation = entry.invocation;
|
|
32166
|
+
const ownerMatch = selected.find((item) => item.reference.ref.entryId === entry.assistant?.entryId);
|
|
32167
|
+
const candidate = ownerMatch ?? selected.find((item) => metadata.sequence > item.reference.ref.sequence && metadata.sequence < item.nextAssistantSequence && item.message.content.some((part) => part.type === "toolCall" && part.id === invocation.toolCallId && part.name === invocation.toolName));
|
|
32151
32168
|
if (!candidate)
|
|
32152
32169
|
return;
|
|
32153
|
-
|
|
32170
|
+
if (metadata.qualification !== "native-tool-execution" || metadata.retention === "retained-import" || entry.assistant?.sessionId !== view.source.sessionId || entry.assistant.sessionFile !== view.source.sessionFile || entry.assistant.entryId !== candidate.reference.ref.entryId) {
|
|
32171
|
+
candidate.unqualifiedIntent = true;
|
|
32172
|
+
return;
|
|
32173
|
+
}
|
|
32154
32174
|
const call = candidate.message.content.filter((part) => part.type === "toolCall")[invocation.sourceOrder];
|
|
32155
32175
|
if (!Number.isSafeInteger(invocation.sourceOrder) || !call || call.id !== invocation.toolCallId || call.name !== invocation.toolName || !invocation.executionId || entry.id !== `${invocation.executionId}:intent` || metadata.sequence <= candidate.reference.ref.sequence || candidate.intents.has(invocation.sourceOrder))
|
|
32156
32176
|
throw new Error("Tool continuation has ambiguous original intent");
|
|
32157
32177
|
candidate.intents.set(invocation.sourceOrder, hydrated);
|
|
32158
32178
|
};
|
|
32179
|
+
const absentPrefixes = /* @__PURE__ */ new Map();
|
|
32159
32180
|
for (const candidate of candidates) {
|
|
32160
32181
|
if (!candidate.prior)
|
|
32161
32182
|
continue;
|
|
32162
32183
|
if (!Array.isArray(candidate.prior.calls))
|
|
32163
32184
|
throw new Error("Invalid committed tool continuation");
|
|
32164
32185
|
for (const call of candidate.prior.calls) {
|
|
32186
|
+
if (call.admission === "absent") {
|
|
32187
|
+
if (checkpoint?.renderer !== CONTEXT_INTERRUPTED_TOOL_RENDERER || !call.source || call.source.sourceSequence < candidate.reference.ref.sequence || call.intent !== void 0 || call.executionId !== void 0 || call.outcome !== void 0 || call.result !== void 0)
|
|
32188
|
+
throw new Error("Invalid committed absent tool admission");
|
|
32189
|
+
const key2 = JSON.stringify(call.source);
|
|
32190
|
+
const prefix = absentPrefixes.get(key2) ?? { source: call.source, candidates: [] };
|
|
32191
|
+
if (!prefix.candidates.includes(candidate))
|
|
32192
|
+
prefix.candidates.push(candidate);
|
|
32193
|
+
absentPrefixes.set(key2, prefix);
|
|
32194
|
+
continue;
|
|
32195
|
+
}
|
|
32165
32196
|
const actual = await view.get(call.intent.id);
|
|
32166
32197
|
if (!actual || actual.revision !== call.intent.revision || actual.sequence !== call.intent.sequence)
|
|
32167
32198
|
throw new Error("Committed tool intent is unavailable on this captured branch");
|
|
32168
|
-
await acceptIntent(actual);
|
|
32199
|
+
await acceptIntent(actual, [candidate]);
|
|
32169
32200
|
}
|
|
32170
32201
|
}
|
|
32171
|
-
const
|
|
32172
|
-
|
|
32173
|
-
let after = Math.min(...newGroups.map((candidate) => candidate.reference.ref.sequence));
|
|
32202
|
+
const scanIntents = async (readView, selected) => {
|
|
32203
|
+
let after = Math.min(...selected.map((candidate) => candidate.reference.ref.sequence));
|
|
32174
32204
|
let scanned = 0;
|
|
32175
32205
|
for (; ; ) {
|
|
32176
|
-
const page = await
|
|
32206
|
+
const page = await readView.page(after, Math.min(128, maxMessages - scanned + 1));
|
|
32177
32207
|
scanned += page.events.length;
|
|
32178
32208
|
if (scanned > maxMessages)
|
|
32179
32209
|
throw new Error("Tool continuation source item budget exceeded");
|
|
32180
32210
|
if (page.coverage !== "complete")
|
|
32181
32211
|
throw new Error("Tool continuation source coverage is incomplete");
|
|
32182
32212
|
for (const metadata of page.events) {
|
|
32183
|
-
if (!
|
|
32184
|
-
await acceptIntent(metadata);
|
|
32213
|
+
if (!selected.some((candidate) => [...candidate.intents.values()].some((intent) => intent.source.id === metadata.id)))
|
|
32214
|
+
await acceptIntent(metadata, selected);
|
|
32185
32215
|
}
|
|
32186
32216
|
if (page.nextAfter === null)
|
|
32187
32217
|
break;
|
|
@@ -32189,21 +32219,51 @@ ${JSON.stringify(selections.map((skill) => ({
|
|
|
32189
32219
|
throw new Error("Tool continuation source page did not advance");
|
|
32190
32220
|
after = page.nextAfter;
|
|
32191
32221
|
}
|
|
32222
|
+
};
|
|
32223
|
+
const newGroups = candidates.filter((candidate) => !candidate.prior);
|
|
32224
|
+
if (newGroups.length)
|
|
32225
|
+
await scanIntents(view, newGroups);
|
|
32226
|
+
for (const prefix of absentPrefixes.values()) {
|
|
32227
|
+
if (!view.atSnapshot)
|
|
32228
|
+
throw new Error("Absent tool admission requires its captured source");
|
|
32229
|
+
await scanIntents(await view.atSnapshot(prefix.source), prefix.candidates);
|
|
32192
32230
|
}
|
|
32231
|
+
const checkAbsentScope = async (candidate) => {
|
|
32232
|
+
const entry = next.get(candidate.reference.ref.entryId)?.entry;
|
|
32233
|
+
const output = entry?.type === "message" ? entry.requestOutput : void 0;
|
|
32234
|
+
if (!output || typeof output.operationId !== "string" || !output.operationId || !Array.isArray(output.attemptIds) || output.attemptIds.some((id) => typeof id !== "string") || !output.source || output.source.sessionId !== view.source.sessionId || output.source.sessionFile !== view.source.sessionFile || !output.source.persistent || !Number.isSafeInteger(output.source.sourceSequence) || output.source.sourceSequence >= candidate.reference.ref.sequence || !view.atSnapshot)
|
|
32235
|
+
throw new Error("View-unit replay group is incomplete: original tool owner is unqualified");
|
|
32236
|
+
await view.atSnapshot(output.source);
|
|
32237
|
+
};
|
|
32193
32238
|
const toolContinuations = [];
|
|
32194
32239
|
const pendingPublicMessageGroups = [];
|
|
32195
32240
|
for (const candidate of candidates) {
|
|
32196
32241
|
const toolCalls = candidate.message.content.filter((part) => part.type === "toolCall");
|
|
32197
|
-
if (!toolCalls.length || candidate.
|
|
32242
|
+
if (!toolCalls.length || candidate.unqualifiedIntent || candidate.prior && candidate.prior.calls.length !== toolCalls.length)
|
|
32198
32243
|
throw new Error("View-unit replay group is incomplete: original tool owner is unqualified");
|
|
32244
|
+
if (candidate.intents.size !== toolCalls.length)
|
|
32245
|
+
await checkAbsentScope(candidate);
|
|
32199
32246
|
const members = [candidate.index];
|
|
32200
32247
|
const calls = [];
|
|
32201
32248
|
for (let order = 0; order < toolCalls.length; order++) {
|
|
32202
32249
|
const intent = candidate.intents.get(order);
|
|
32250
|
+
const original = candidate.prior?.calls[order];
|
|
32251
|
+
if (!intent) {
|
|
32252
|
+
if (original && original.admission !== "absent")
|
|
32253
|
+
throw new Error("Committed tool intent is unavailable on this captured branch");
|
|
32254
|
+
if (messages.some((message2) => {
|
|
32255
|
+
const sequence = epochReferences.get(message2)?.ref.sequence;
|
|
32256
|
+
return message2.role === "toolResult" && message2.toolCallId === toolCalls[order].id && sequence !== void 0 && sequence > candidate.reference.ref.sequence && sequence < candidate.nextAssistantSequence;
|
|
32257
|
+
}))
|
|
32258
|
+
throw new Error("Tool outcome lacks its original finalized owner");
|
|
32259
|
+
calls.push(original ?? { admission: "absent", source: { ...view.source } });
|
|
32260
|
+
continue;
|
|
32261
|
+
}
|
|
32262
|
+
if (original?.admission === "absent")
|
|
32263
|
+
throw new Error("Committed absent tool admission changed");
|
|
32203
32264
|
if (intent.entry.type !== "tool_intent")
|
|
32204
32265
|
throw new Error("Invalid native tool intent");
|
|
32205
32266
|
const invocation = intent.entry.invocation;
|
|
32206
|
-
const original = candidate.prior?.calls[order];
|
|
32207
32267
|
if (original && (original.executionId !== invocation.executionId || original.intent.id !== intent.source.id))
|
|
32208
32268
|
throw new Error("Committed tool execution identity changed");
|
|
32209
32269
|
const actual = await view.get(invocation.executionId);
|
|
@@ -32297,6 +32357,7 @@ var PublicContextBudgetError = class extends RequestTokenBudgetError {
|
|
|
32297
32357
|
originalAssessment;
|
|
32298
32358
|
mandatoryAssessment;
|
|
32299
32359
|
taskFrameRebaseAvailable;
|
|
32360
|
+
isSourceCurrent;
|
|
32300
32361
|
source;
|
|
32301
32362
|
#compactionKey;
|
|
32302
32363
|
#summaryCapacity;
|
|
@@ -32306,11 +32367,12 @@ var PublicContextBudgetError = class extends RequestTokenBudgetError {
|
|
|
32306
32367
|
getCompactionKey() {
|
|
32307
32368
|
return this.#compactionKey;
|
|
32308
32369
|
}
|
|
32309
|
-
constructor(source, assessment, originalAssessment, mandatoryAssessment, taskFrameRebaseAvailable = false, compactionKey, summaryCapacity) {
|
|
32370
|
+
constructor(source, assessment, originalAssessment, mandatoryAssessment, taskFrameRebaseAvailable = false, compactionKey, summaryCapacity, isSourceCurrent) {
|
|
32310
32371
|
super(assessment);
|
|
32311
32372
|
this.originalAssessment = originalAssessment;
|
|
32312
32373
|
this.mandatoryAssessment = mandatoryAssessment;
|
|
32313
32374
|
this.taskFrameRebaseAvailable = taskFrameRebaseAvailable;
|
|
32375
|
+
this.isSourceCurrent = isSourceCurrent;
|
|
32314
32376
|
this.name = "PublicContextBudgetError";
|
|
32315
32377
|
if (mandatoryAssessment?.status === "over-budget")
|
|
32316
32378
|
this.message = "Context capacity exceeded: instructions, tools, mandatory evidence and output allowance cannot fit. Summarizing unrelated history cannot resolve this request.";
|
|
@@ -32319,7 +32381,7 @@ var PublicContextBudgetError = class extends RequestTokenBudgetError {
|
|
|
32319
32381
|
this.#summaryCapacity = summaryCapacity;
|
|
32320
32382
|
}
|
|
32321
32383
|
};
|
|
32322
|
-
function captureRequestViewBoundary(messages, commit, validate2, fixedPrepare) {
|
|
32384
|
+
function captureRequestViewBoundary(messages, commit, validate2, fixedPrepare, isSourceCurrent) {
|
|
32323
32385
|
const source = getCanonicalViewSelectionSource(messages);
|
|
32324
32386
|
if (!source)
|
|
32325
32387
|
throw new Error("Request view boundary requires compiled canonical messages");
|
|
@@ -32333,7 +32395,8 @@ function captureRequestViewBoundary(messages, commit, validate2, fixedPrepare) {
|
|
|
32333
32395
|
} : {},
|
|
32334
32396
|
commit,
|
|
32335
32397
|
validate: validate2,
|
|
32336
|
-
fixedPrepare
|
|
32398
|
+
fixedPrepare,
|
|
32399
|
+
isSourceCurrent
|
|
32337
32400
|
};
|
|
32338
32401
|
}
|
|
32339
32402
|
function providerMessageIndex(indices, canonicalIndex) {
|
|
@@ -32405,7 +32468,7 @@ function publicBudgetFailure(boundary, messages, request, projection, budget, as
|
|
|
32405
32468
|
const body = JSON.parse(request.body);
|
|
32406
32469
|
const input = body[inputKey];
|
|
32407
32470
|
if (!Array.isArray(input) || input.length !== projection.messageIndices.length)
|
|
32408
|
-
return new PublicContextBudgetError(boundary.source, assessment, original);
|
|
32471
|
+
return new PublicContextBudgetError(boundary.source, assessment, original, void 0, false, void 0, void 0, boundary.isSourceCurrent);
|
|
32409
32472
|
const graph = prepareViewSelection(source.units, boundary.limits);
|
|
32410
32473
|
const retainedInput = (retained) => {
|
|
32411
32474
|
const roots = source.units.filter((_2, index) => required.has(index) || retained.has(context.references[index]?.ref.entryId ?? "")).map((unit) => unit.id);
|
|
@@ -32434,7 +32497,7 @@ function publicBudgetFailure(boundary, messages, request, projection, budget, as
|
|
|
32434
32497
|
kept.splice(position < 0 ? kept.length : position, 0, summary);
|
|
32435
32498
|
const measured = budget.measure(withRequestBody(request, JSON.stringify({ ...body, [inputKey]: kept })));
|
|
32436
32499
|
return measured.status === "unknown" || measured.availableInputTokens === null || measured.estimatedInputTokens === null ? void 0 : Math.floor(measured.availableInputTokens - measured.estimatedInputTokens);
|
|
32437
|
-
});
|
|
32500
|
+
}, boundary.isSourceCurrent);
|
|
32438
32501
|
}
|
|
32439
32502
|
async function prepareFixedRequestView(boundary, request, projection, assessment) {
|
|
32440
32503
|
projection = canonicalRequestProjection(boundary, projection);
|
|
@@ -33168,13 +33231,13 @@ var InferenceCoordinator = class _InferenceCoordinator {
|
|
|
33168
33231
|
return captured;
|
|
33169
33232
|
}
|
|
33170
33233
|
/** Explicit Root-owned epoch boundary, on this same captured MAIN source only. */
|
|
33171
|
-
bindRequestViewBoundary(messages, commit, validate2, fixedPrepare) {
|
|
33234
|
+
bindRequestViewBoundary(messages, commit, validate2, fixedPrepare, isSourceCurrent) {
|
|
33172
33235
|
this.assertAdmission();
|
|
33173
33236
|
if (!this.capturedSink)
|
|
33174
33237
|
throw new Error("Request view boundary requires a captured inference owner");
|
|
33175
33238
|
if (this.requestViewBoundary)
|
|
33176
33239
|
throw new Error("Request view boundary is already bound");
|
|
33177
|
-
this.requestViewBoundary = captureRequestViewBoundary(messages, commit, validate2, fixedPrepare);
|
|
33240
|
+
this.requestViewBoundary = captureRequestViewBoundary(messages, commit, validate2, fixedPrepare, isSourceCurrent);
|
|
33178
33241
|
}
|
|
33179
33242
|
/** Read through an explicit capture, never by recapturing the mutable current session. */
|
|
33180
33243
|
async readHistory(read2) {
|
|
@@ -35812,6 +35875,15 @@ function readSessionCatalogHeader(filePath) {
|
|
|
35812
35875
|
// dist/core/session-manager.js
|
|
35813
35876
|
var CURRENT_SESSION_VERSION = 3;
|
|
35814
35877
|
var SESSION_ASYNC_PARSE_YIELD_BYTES = 4 * 1024 * 1024;
|
|
35878
|
+
var COMPACTION_BOOKKEEPING_ENTRY_TYPES = /* @__PURE__ */ new Set([
|
|
35879
|
+
"session_state",
|
|
35880
|
+
"agent_status",
|
|
35881
|
+
"git_state",
|
|
35882
|
+
"child_usage_attributed"
|
|
35883
|
+
]);
|
|
35884
|
+
function isCompactionBookkeeping(entry) {
|
|
35885
|
+
return COMPACTION_BOOKKEEPING_ENTRY_TYPES.has(entry.type) || entry.type === "custom_message" && entry.customType === COMPACTION_OUTCOME_CUSTOM_TYPE;
|
|
35886
|
+
}
|
|
35815
35887
|
var CONTENT_ENTRY_TYPES = /* @__PURE__ */ new Set([
|
|
35816
35888
|
"message",
|
|
35817
35889
|
"custom_message",
|
|
@@ -36636,6 +36708,7 @@ function newSessionWriteState() {
|
|
|
36636
36708
|
reservedLeaf: null,
|
|
36637
36709
|
leafId: null,
|
|
36638
36710
|
branchSelectionRevision: 0,
|
|
36711
|
+
compactionRevision: 0,
|
|
36639
36712
|
pins: 0,
|
|
36640
36713
|
retired: false,
|
|
36641
36714
|
closed: false,
|
|
@@ -37369,8 +37442,11 @@ var SessionManager = class _SessionManager {
|
|
|
37369
37442
|
}
|
|
37370
37443
|
Object.assign(state, metadata);
|
|
37371
37444
|
state.metadataRefs = void 0;
|
|
37372
|
-
if (advanceLeaf)
|
|
37445
|
+
if (advanceLeaf) {
|
|
37373
37446
|
state.leafId = snapshot.id;
|
|
37447
|
+
if (!isCompactionBookkeeping(snapshot))
|
|
37448
|
+
state.compactionRevision++;
|
|
37449
|
+
}
|
|
37374
37450
|
state.reservedLeaf = state.leafId;
|
|
37375
37451
|
if (this.writeState === state)
|
|
37376
37452
|
this.leafId = state.leafId;
|
|
@@ -37457,6 +37533,8 @@ var SessionManager = class _SessionManager {
|
|
|
37457
37533
|
target.message.usage = cloneUsage2(snapshot.aggregateUsage);
|
|
37458
37534
|
}
|
|
37459
37535
|
state.leafId = snapshot.id;
|
|
37536
|
+
if (!isCompactionBookkeeping(snapshot))
|
|
37537
|
+
state.compactionRevision++;
|
|
37460
37538
|
if (this.writeState === state) {
|
|
37461
37539
|
this.leafId = snapshot.id;
|
|
37462
37540
|
this._notifyPersistListeners();
|
|
@@ -37523,8 +37601,13 @@ var SessionManager = class _SessionManager {
|
|
|
37523
37601
|
let capturedSource;
|
|
37524
37602
|
let captureFailure;
|
|
37525
37603
|
let selectionRevision;
|
|
37604
|
+
let compactionRevision;
|
|
37605
|
+
let currentRevision;
|
|
37606
|
+
const isCurrent = (revision) => capturedSource !== void 0 && this.writeState === state && state.owner === owner && !state.retired && !state.closed && this.sessionId === sessionId && this.sessionFile === sessionFile && state.branchSelectionRevision === selectionRevision && state.compactionRevision === revision;
|
|
37526
37607
|
const sink = this._bindHistorySource((index, source, query) => createSessionHistoryReadScope(index, source, query, "source"), (source) => {
|
|
37527
37608
|
selectionRevision = state.branchSelectionRevision;
|
|
37609
|
+
compactionRevision = state.compactionRevision;
|
|
37610
|
+
currentRevision = compactionRevision;
|
|
37528
37611
|
if (!indexed)
|
|
37529
37612
|
residentBranch = this._readResidentBranches([source.leafId], capturedLimits, byId).branches[0];
|
|
37530
37613
|
capturedSource = source;
|
|
@@ -37553,7 +37636,7 @@ var SessionManager = class _SessionManager {
|
|
|
37553
37636
|
if (JSON.stringify(epoch.source) !== JSON.stringify(capturedSource))
|
|
37554
37637
|
throw new Error("Context epoch does not match the bound source capture");
|
|
37555
37638
|
}
|
|
37556
|
-
if (!
|
|
37639
|
+
if (!isCurrent(compactionRevision))
|
|
37557
37640
|
throw new Error("Compaction source or branch changed");
|
|
37558
37641
|
};
|
|
37559
37642
|
const args = [
|
|
@@ -37566,10 +37649,13 @@ var SessionManager = class _SessionManager {
|
|
|
37566
37649
|
snapshot.usage,
|
|
37567
37650
|
assertCurrent
|
|
37568
37651
|
];
|
|
37569
|
-
|
|
37652
|
+
const entryId = await (qualification || snapshot.requestOutputs ? this._appendCompaction(...args, qualification, snapshot.requestOutputs) : this.appendCompaction(...args));
|
|
37653
|
+
currentRevision = compactionRevision + 1;
|
|
37654
|
+
return entryId;
|
|
37570
37655
|
};
|
|
37571
37656
|
const bound = {
|
|
37572
37657
|
...sink,
|
|
37658
|
+
isCurrent: () => isCurrent(currentRevision),
|
|
37573
37659
|
readHistory: (read2) => sink.readHistory((history) => read2(history.branchContext)),
|
|
37574
37660
|
[readCopiedEpochSource]: (read2) => sink.readHistory(read2),
|
|
37575
37661
|
readBranch: async () => {
|
|
@@ -40822,6 +40908,23 @@ var DaemonSocketPathLease = class {
|
|
|
40822
40908
|
}
|
|
40823
40909
|
}
|
|
40824
40910
|
};
|
|
40911
|
+
async function closeDaemonServer(server, clients) {
|
|
40912
|
+
const closingClients = [...clients];
|
|
40913
|
+
for (const client of closingClients) {
|
|
40914
|
+
client.detachInput();
|
|
40915
|
+
client.socket.end();
|
|
40916
|
+
}
|
|
40917
|
+
const timeout = setTimeout(() => {
|
|
40918
|
+
for (const client of closingClients)
|
|
40919
|
+
client.socket.destroy();
|
|
40920
|
+
}, 1e3);
|
|
40921
|
+
timeout.unref();
|
|
40922
|
+
try {
|
|
40923
|
+
await new Promise((resolveClose) => server?.close(() => resolveClose()) ?? resolveClose());
|
|
40924
|
+
} finally {
|
|
40925
|
+
clearTimeout(timeout);
|
|
40926
|
+
}
|
|
40927
|
+
}
|
|
40825
40928
|
function defaultDaemonSocketPath(packageDir = getPackageDir()) {
|
|
40826
40929
|
if (process.platform === "win32") {
|
|
40827
40930
|
return `\\\\.\\pipe\\${PRODUCT.command}-${daemonScopeId(packageDir)}`;
|
|
@@ -45456,7 +45559,7 @@ async function loadExtensionModule(extensionPath) {
|
|
|
45456
45559
|
// (file-path aliases would load a second, divergent copy of each package).
|
|
45457
45560
|
// Also disable tryNative so jiti handles ALL imports (not just the entry point)
|
|
45458
45561
|
// Node/dev must also share the native AI registry and implementation identities.
|
|
45459
|
-
...isBunBinary || isBundledCli ? { virtualModules: (await import("./bundled-modules-
|
|
45562
|
+
...isBunBinary || isBundledCli ? { virtualModules: (await import("./bundled-modules-MX6YNAM2.js")).VIRTUAL_MODULES, tryNative: false } : {
|
|
45460
45563
|
alias: getAliases(),
|
|
45461
45564
|
virtualModules: {
|
|
45462
45565
|
"@ponythewhite/base-context-ai": src_exports,
|
|
@@ -58591,6 +58694,7 @@ var AgentSession = class _AgentSession {
|
|
|
58591
58694
|
runtimeServices;
|
|
58592
58695
|
_contextCompiler = new CanonicalContextCompiler();
|
|
58593
58696
|
_failedAutomaticCompaction;
|
|
58697
|
+
_failedThresholdCompaction;
|
|
58594
58698
|
_contextEpochsEnabled;
|
|
58595
58699
|
_initialContextMode;
|
|
58596
58700
|
_contextMode;
|
|
@@ -58990,7 +59094,7 @@ var AgentSession = class _AgentSession {
|
|
|
58990
59094
|
acknowledged = { entryId, result };
|
|
58991
59095
|
try {
|
|
58992
59096
|
assertResourceCurrent(resource);
|
|
58993
|
-
if (this.sessionManager !== epochManager ||
|
|
59097
|
+
if (this.sessionManager !== epochManager || !compaction.isCurrent())
|
|
58994
59098
|
throw new Error("Context epoch source changed before adoption");
|
|
58995
59099
|
this.agent.state.messages = prepared.messages;
|
|
58996
59100
|
committed = prepared.checkpoint;
|
|
@@ -59066,7 +59170,7 @@ var AgentSession = class _AgentSession {
|
|
|
59066
59170
|
committedEntry = { sessionId: epochContext.source.sessionId, entryId };
|
|
59067
59171
|
requestContract = nextContract;
|
|
59068
59172
|
assertResourceCurrent(resource);
|
|
59069
|
-
if (this.sessionManager !== epochManager ||
|
|
59173
|
+
if (this.sessionManager !== epochManager || !compaction.isCurrent())
|
|
59070
59174
|
throw new Error("Context contract source changed before acceptance");
|
|
59071
59175
|
}
|
|
59072
59176
|
if (!sameSelectedSkills(committed?.selectedSkills, epochContext.selectedSkills))
|
|
@@ -59081,7 +59185,7 @@ var AgentSession = class _AgentSession {
|
|
|
59081
59185
|
} catch (cause) {
|
|
59082
59186
|
throw commitFailure(cause);
|
|
59083
59187
|
}
|
|
59084
|
-
} : void 0);
|
|
59188
|
+
} : void 0, compaction.isCurrent);
|
|
59085
59189
|
}
|
|
59086
59190
|
this._compactionSetupFailure = void 0;
|
|
59087
59191
|
return { messages, adoptMessages: true, streamContext: captured, release: () => captured.dispose() };
|
|
@@ -59101,7 +59205,7 @@ var AgentSession = class _AgentSession {
|
|
|
59101
59205
|
if (!invocation || invocation.signal !== signal)
|
|
59102
59206
|
return false;
|
|
59103
59207
|
const owner = { ...invocation, pumpEpoch: this._sessionInputPumpEpoch };
|
|
59104
|
-
if (!this._isCompactionOwnerCurrent(owner) || !error.source.persistent || error.source.sessionId !== owner.sessionId || error.source.sessionFile !== owner.sessionFile || error.source.leafId
|
|
59208
|
+
if (!this._isCompactionOwnerCurrent(owner) || !error.source.persistent || error.source.sessionId !== owner.sessionId || error.source.sessionFile !== owner.sessionFile || !(error.isSourceCurrent?.() ?? error.source.leafId === owner.manager.getLeafId()))
|
|
59105
59209
|
return false;
|
|
59106
59210
|
if (error.taskFrameRebaseAvailable) {
|
|
59107
59211
|
this._contextCompiler.requestTaskFrameRebase();
|
|
@@ -59383,7 +59487,7 @@ var AgentSession = class _AgentSession {
|
|
|
59383
59487
|
result: { summary: "", firstKeptEntryId: prepared.checkpoint.literalTailId, tokensBefore: null }
|
|
59384
59488
|
};
|
|
59385
59489
|
this._contextMode = mode;
|
|
59386
|
-
if (this.sessionManager !== manager ||
|
|
59490
|
+
if (this.sessionManager !== manager || !compaction.isCurrent())
|
|
59387
59491
|
throw new Error("Context mode source changed before adoption");
|
|
59388
59492
|
assertResourceCurrent(resource);
|
|
59389
59493
|
this.agent.state.messages = prepared.messages;
|
|
@@ -60904,6 +61008,22 @@ var AgentSession = class _AgentSession {
|
|
|
60904
61008
|
return timestamp;
|
|
60905
61009
|
});
|
|
60906
61010
|
}
|
|
61011
|
+
_thresholdCompactionConfiguration() {
|
|
61012
|
+
return JSON.stringify({
|
|
61013
|
+
model: this.model,
|
|
61014
|
+
thinkingLevel: this.thinkingLevel,
|
|
61015
|
+
settings: this.settingsManager.getCompactionSettings()
|
|
61016
|
+
});
|
|
61017
|
+
}
|
|
61018
|
+
_hasFailedThresholdCompaction() {
|
|
61019
|
+
const failed = this._failedThresholdCompaction;
|
|
61020
|
+
if (!failed)
|
|
61021
|
+
return false;
|
|
61022
|
+
if (failed.isCurrent() && failed.configuration === this._thresholdCompactionConfiguration() && failed.systemPrompt === this.agent.state.systemPrompt && failed.tools === this.agent.state.tools)
|
|
61023
|
+
return true;
|
|
61024
|
+
this._failedThresholdCompaction = void 0;
|
|
61025
|
+
return false;
|
|
61026
|
+
}
|
|
60907
61027
|
async _thresholdCompactionNeeded(context, owner = this._captureCompactionOwner(), goalOwner = {
|
|
60908
61028
|
...this._captureGoalContinuationOwner(owner.signal),
|
|
60909
61029
|
checkpointOwner: owner
|
|
@@ -60922,6 +61042,8 @@ var AgentSession = class _AgentSession {
|
|
|
60922
61042
|
const contextTokens = this._getThresholdContextTokens(context.message, compactionTimestamp);
|
|
60923
61043
|
if (contextTokens === void 0 || !shouldCompact(contextTokens, contextWindow, settings))
|
|
60924
61044
|
return false;
|
|
61045
|
+
if (this._hasFailedThresholdCompaction())
|
|
61046
|
+
return false;
|
|
60925
61047
|
if (!this._isGoalContinuationOwnerCurrent(goalOwner))
|
|
60926
61048
|
return true;
|
|
60927
61049
|
if (!await this._queueGoalContinuationForThresholdCompaction(context.message, goalOwner)) {
|
|
@@ -62041,6 +62163,7 @@ var AgentSession = class _AgentSession {
|
|
|
62041
62163
|
*/
|
|
62042
62164
|
async disposeAsync(options) {
|
|
62043
62165
|
this._failedAutomaticCompaction = void 0;
|
|
62166
|
+
this._failedThresholdCompaction = void 0;
|
|
62044
62167
|
this._contextCompiler.clear();
|
|
62045
62168
|
this._nativeRecoveryCursors.clear();
|
|
62046
62169
|
for (const admission of this._rlmChildAdmissions)
|
|
@@ -62248,6 +62371,7 @@ var AgentSession = class _AgentSession {
|
|
|
62248
62371
|
}
|
|
62249
62372
|
dispose() {
|
|
62250
62373
|
this._failedAutomaticCompaction = void 0;
|
|
62374
|
+
this._failedThresholdCompaction = void 0;
|
|
62251
62375
|
this._contextCompiler.clear();
|
|
62252
62376
|
this._nativeRecoveryCursors.clear();
|
|
62253
62377
|
if (this._disposed) {
|
|
@@ -66407,6 +66531,8 @@ ${parsed.args}` : block;
|
|
|
66407
66531
|
if (contextTokens === void 0)
|
|
66408
66532
|
return false;
|
|
66409
66533
|
if (shouldCompact(contextTokens, contextWindow, settings)) {
|
|
66534
|
+
if (this._hasFailedThresholdCompaction())
|
|
66535
|
+
return false;
|
|
66410
66536
|
if (!this._pendingCheckpoint && queueAutonomousContinuation) {
|
|
66411
66537
|
if (!await this._queueGoalContinuationForThresholdCompaction(assistantMessage, goalOwner) && this._isGoalContinuationOwnerCurrent(goalOwner)) {
|
|
66412
66538
|
await this._queueAutonomousContinuationForThresholdCompaction(assistantMessage, owner, autonomousOwner);
|
|
@@ -66497,6 +66623,16 @@ This compaction outcome could not be saved to session history: ${persistenceErro
|
|
|
66497
66623
|
let compaction;
|
|
66498
66624
|
let committed;
|
|
66499
66625
|
let failure2;
|
|
66626
|
+
const thresholdConfiguration = reason === "threshold" && !resumeInPlace ? {
|
|
66627
|
+
configuration: this._thresholdCompactionConfiguration(),
|
|
66628
|
+
systemPrompt: this.agent.state.systemPrompt,
|
|
66629
|
+
tools: this.agent.state.tools
|
|
66630
|
+
} : void 0;
|
|
66631
|
+
const rememberThresholdFailure = () => {
|
|
66632
|
+
if (thresholdConfiguration && !abort.signal.aborted && this._isCompactionOwnerCurrent(owner) && compaction?.isCurrent()) {
|
|
66633
|
+
this._failedThresholdCompaction = { ...thresholdConfiguration, isCurrent: compaction.isCurrent };
|
|
66634
|
+
}
|
|
66635
|
+
};
|
|
66500
66636
|
try {
|
|
66501
66637
|
const selected = this._resolveCompactionModel();
|
|
66502
66638
|
const model = selected?.model;
|
|
@@ -66513,6 +66649,7 @@ This compaction outcome could not be saved to session history: ${persistenceErro
|
|
|
66513
66649
|
const detail = !model || !authResult ? "no model is selected" : authResult.ok ? "no API key is available" : authResult.error;
|
|
66514
66650
|
await this._endCompactionUnsuccessfully(reason, "failed", `Compaction failed: ${detail}`, { owner });
|
|
66515
66651
|
this._clearQueuedAutonomousContinuationsAfterSkippedThresholdCompaction(reason === "threshold" && shouldContinueAfterCompaction, queuedAutonomousContinuationsForThisCompaction);
|
|
66652
|
+
rememberThresholdFailure();
|
|
66516
66653
|
resumeAfterFailure();
|
|
66517
66654
|
return false;
|
|
66518
66655
|
}
|
|
@@ -66574,6 +66711,7 @@ This compaction outcome could not be saved to session history: ${persistenceErro
|
|
|
66574
66711
|
} else {
|
|
66575
66712
|
await this._endCompactionUnsuccessfully(reason, "failed", reason === "overflow" ? `Context overflow recovery failed: ${errorMessage4}` : reason === "requested" ? `Requested compaction failed: ${errorMessage4}` : `Auto-compaction failed: ${errorMessage4}`, { customInstructions, owner });
|
|
66576
66713
|
}
|
|
66714
|
+
rememberThresholdFailure();
|
|
66577
66715
|
resumeAfterFailure();
|
|
66578
66716
|
return false;
|
|
66579
66717
|
} finally {
|
|
@@ -69952,7 +70090,7 @@ import { resolve as resolve15 } from "node:path";
|
|
|
69952
70090
|
var BASE_CONTEXT_BUILD_ID_ENV = "BASE_CONTEXT_BUILD_ID";
|
|
69953
70091
|
var BASE_CONTEXT_LAUNCHER_PATH_ENV = "BASE_CONTEXT_LAUNCHER_PATH";
|
|
69954
70092
|
function bundledBuildId() {
|
|
69955
|
-
return false ? void 0 : "v1.0.
|
|
70093
|
+
return false ? void 0 : "v1.0.9-1-ge86dce7cb";
|
|
69956
70094
|
}
|
|
69957
70095
|
function getDaemonRuntimeIdentity(environment = process.env) {
|
|
69958
70096
|
const entrypoint = process.argv[1];
|
|
@@ -70744,6 +70882,7 @@ export {
|
|
|
70744
70882
|
maybeRunOwnedSessionWorkerFrontend,
|
|
70745
70883
|
installOwnedSessionWorkerOwnerWatch,
|
|
70746
70884
|
closeOwnedSessionWorkerOwnerWatch,
|
|
70885
|
+
closeDaemonServer,
|
|
70747
70886
|
defaultDaemonSocketPath,
|
|
70748
70887
|
acquireDaemonSocketPathLease,
|
|
70749
70888
|
prepareDaemonSocketPath,
|