@ponythewhite/base-context 1.0.14 → 1.0.15
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 +9 -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-UODO7ZR7.js → bundled-modules-O67MEO74.js} +2 -2
- package/dist/bundle/{chunk-NLRWERWA.js → chunk-DGO66I3L.js} +51 -20
- package/dist/bundle/{chunk-SX7CAXWU.js → chunk-RQFC34FM.js} +131 -49
- package/dist/bundle/{cli-main-6GXXIMQQ.js → cli-main-2RER6PBE.js} +2 -2
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/{main-HF64B4HM.js → main-YERLD3T4.js} +2 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +36 -24
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +11 -9
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/inference-coordinator.d.ts.map +1 -1
- package/dist/core/inference-coordinator.js +13 -2
- package/dist/core/inference-coordinator.js.map +1 -1
- package/dist/core/kernel/repl-manager.d.ts.map +1 -1
- package/dist/core/kernel/repl-manager.js +5 -0
- package/dist/core/kernel/repl-manager.js.map +1 -1
- package/dist/core/session-manager.d.ts +8 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +57 -0
- 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 +17 -17
- package/dist/modes/daemon/daemon-mode.js.map +1 -1
- package/dist/modes/daemon/daemon-worker-client.d.ts +1 -0
- package/dist/modes/daemon/daemon-worker-client.d.ts.map +1 -1
- package/dist/modes/daemon/daemon-worker-client.js +8 -0
- package/dist/modes/daemon/daemon-worker-client.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +2 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +29 -4
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/upstream-1.0.15.md +83 -0
- package/package.json +4 -4
|
@@ -27268,7 +27268,7 @@ function formatPathRelativeToCwdOrAbsolute(filePath, cwd) {
|
|
|
27268
27268
|
}
|
|
27269
27269
|
|
|
27270
27270
|
// dist/core/session-manager.js
|
|
27271
|
-
import { isDeepStrictEqual as
|
|
27271
|
+
import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
|
|
27272
27272
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
27273
27273
|
import { existsSync as existsSync8, readdirSync as readdirSync4, readFileSync as readFileSync6, realpathSync as realpathSync3, statSync as statSync5 } from "fs";
|
|
27274
27274
|
import { opendir, open as openFile, stat } from "fs/promises";
|
|
@@ -27688,6 +27688,7 @@ function stringifyBoundedJson(value, maxBytes) {
|
|
|
27688
27688
|
// dist/core/inference-coordinator.js
|
|
27689
27689
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
27690
27690
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
27691
|
+
import { isDeepStrictEqual } from "node:util";
|
|
27691
27692
|
|
|
27692
27693
|
// dist/core/resource-view.js
|
|
27693
27694
|
var RESOURCE_VIEW_CUSTOM_TYPE = "native_resource_view";
|
|
@@ -33704,6 +33705,7 @@ var InferenceCoordinator = class _InferenceCoordinator {
|
|
|
33704
33705
|
}) : void 0;
|
|
33705
33706
|
let publicAccepted = false;
|
|
33706
33707
|
let selectedContextEpoch;
|
|
33708
|
+
let preparedRequest;
|
|
33707
33709
|
const attempts = {
|
|
33708
33710
|
...responsesMessageIds ? { responsesMessageIds } : {},
|
|
33709
33711
|
...requiredPublic ? {
|
|
@@ -33715,6 +33717,9 @@ var InferenceCoordinator = class _InferenceCoordinator {
|
|
|
33715
33717
|
...budget || canSelect ? {
|
|
33716
33718
|
prepareRequest: async (representation, projection, countInput) => {
|
|
33717
33719
|
try {
|
|
33720
|
+
if (!projection && preparedRequest && isDeepStrictEqual(representation, preparedRequest))
|
|
33721
|
+
return;
|
|
33722
|
+
preparedRequest = void 0;
|
|
33718
33723
|
selectedContextEpoch = void 0;
|
|
33719
33724
|
publicAccepted = false;
|
|
33720
33725
|
if (JSON.parse(representation.body).model !== model.id)
|
|
@@ -33732,8 +33737,10 @@ var InferenceCoordinator = class _InferenceCoordinator {
|
|
|
33732
33737
|
if (budget && assessment)
|
|
33733
33738
|
budget.assert(assessment);
|
|
33734
33739
|
const accepted = await prepareFixedRequestView(boundary, representation, projection, assessment);
|
|
33735
|
-
if (accepted)
|
|
33740
|
+
if (accepted) {
|
|
33736
33741
|
selectedContextEpoch = Object.freeze({ ...accepted });
|
|
33742
|
+
preparedRequest = structuredClone(representation);
|
|
33743
|
+
}
|
|
33737
33744
|
return;
|
|
33738
33745
|
}
|
|
33739
33746
|
return await selectRequestView({
|
|
@@ -33741,8 +33748,10 @@ var InferenceCoordinator = class _InferenceCoordinator {
|
|
|
33741
33748
|
...responsesMessageIds ? { responseItemIdentity: this.work.responsesIdentity } : {},
|
|
33742
33749
|
commit: async (candidate) => {
|
|
33743
33750
|
const accepted = await boundary.commit(candidate);
|
|
33744
|
-
if (accepted)
|
|
33751
|
+
if (accepted) {
|
|
33745
33752
|
selectedContextEpoch = Object.freeze({ ...accepted });
|
|
33753
|
+
preparedRequest = structuredClone(candidate.request);
|
|
33754
|
+
}
|
|
33746
33755
|
publicAccepted = Boolean(accepted && candidate.publicMessages && candidate.projection.publicWindow && !candidate.projection.pendingPublicMessageGroups?.length);
|
|
33747
33756
|
return accepted || void 0;
|
|
33748
33757
|
}
|
|
@@ -34512,18 +34521,20 @@ ${previousSummary}
|
|
|
34512
34521
|
const textContent = response.content.filter((c) => c.type === "text").map((c) => c.text).join("\n");
|
|
34513
34522
|
return captureSummarySlice({ summary: textContent, usage: response.usage }, requests, completion, "history");
|
|
34514
34523
|
}
|
|
34515
|
-
function prepareViewCompaction(messages, entryIds, pathEntries, settings, maxCutEntryId, allowShortSession = false, budgetPressure = false) {
|
|
34524
|
+
function prepareViewCompaction(messages, entryIds, pathEntries, settings, maxCutEntryId, allowShortSession = false, budgetPressure = false, capturedSuffixAnchors) {
|
|
34516
34525
|
if (messages.length !== entryIds.length)
|
|
34517
34526
|
throw new Error("Compaction views do not match their source anchors");
|
|
34518
34527
|
const selectedIds = new Set(entryIds);
|
|
34519
|
-
const suffixAnchors =
|
|
34520
|
-
|
|
34521
|
-
|
|
34522
|
-
|
|
34523
|
-
|
|
34524
|
-
|
|
34525
|
-
|
|
34526
|
-
|
|
34528
|
+
const suffixAnchors = new Set(capturedSuffixAnchors);
|
|
34529
|
+
if (!capturedSuffixAnchors) {
|
|
34530
|
+
for (let index = pathEntries.length - 1; index >= 0; index--) {
|
|
34531
|
+
const entry = pathEntries[index];
|
|
34532
|
+
if (!getMessageFromEntryForCompaction(entry))
|
|
34533
|
+
continue;
|
|
34534
|
+
if (!selectedIds.has(entry.id))
|
|
34535
|
+
break;
|
|
34536
|
+
suffixAnchors.add(entry.id);
|
|
34537
|
+
}
|
|
34527
34538
|
}
|
|
34528
34539
|
let cuts = messages.flatMap((message2, index) => entryIds[index] && suffixAnchors.has(entryIds[index]) && message2.role !== "toolResult" && message2.role !== "compactionSummary" ? [index] : []);
|
|
34529
34540
|
let relaxRetention = false;
|
|
@@ -34794,7 +34805,7 @@ ${TURN_PREFIX_SUMMARIZATION_PROMPT}`;
|
|
|
34794
34805
|
}
|
|
34795
34806
|
|
|
34796
34807
|
// dist/core/context-epoch-copy.js
|
|
34797
|
-
import { isDeepStrictEqual } from "node:util";
|
|
34808
|
+
import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
34798
34809
|
var readCopiedEpochSource = /* @__PURE__ */ Symbol("readCopiedEpochSource");
|
|
34799
34810
|
function captureEpochCopyEntry(entry, source) {
|
|
34800
34811
|
const updateTarget = entry.type === "message" ? entry.message.role === "assistant" ? { kind: "assistant-usage", targetId: entry.id } : entry.message.role === "toolResult" && entry.message.toolName === "ipython" ? { kind: "ipython-sent-message", toolCallId: entry.message.toolCallId } : void 0 : void 0;
|
|
@@ -34895,7 +34906,7 @@ async function rebuildCopiedContextEpoch(history, copied, limits, metadataMaxByt
|
|
|
34895
34906
|
await prefix(checkpoint.source);
|
|
34896
34907
|
const copyReference = async (pinned) => {
|
|
34897
34908
|
const old = oldById.get(pinned.ref.entryId);
|
|
34898
|
-
if (!old || old.revision !== pinned.ref.revision || old.sequence !== pinned.ref.sequence || old.kind !== pinned.ref.kind || !
|
|
34909
|
+
if (!old || old.revision !== pinned.ref.revision || old.sequence !== pinned.ref.sequence || old.kind !== pinned.ref.kind || !isDeepStrictEqual2(old.locator, pinned.ref.locator))
|
|
34899
34910
|
throw new Error("Copied epoch recipe does not match its captured source");
|
|
34900
34911
|
const read2 = await prefix(pinned.source);
|
|
34901
34912
|
const actual = await read2.get(old.id);
|
|
@@ -34918,7 +34929,7 @@ async function rebuildCopiedContextEpoch(history, copied, limits, metadataMaxByt
|
|
|
34918
34929
|
throw new Error("Copied epoch frozen revisions are unavailable");
|
|
34919
34930
|
const updates = old.updateTarget ? (await read2.contextUpdates(old.updateTarget)).refs : [];
|
|
34920
34931
|
const expected = original.slice(1).map((revision) => oldByRevision.get(revision));
|
|
34921
|
-
if (expected.some((source) => !source || source.sequence > pinned.source.sourceSequence) || !
|
|
34932
|
+
if (expected.some((source) => !source || source.sequence > pinned.source.sourceSequence) || !isDeepStrictEqual2(expected.map((source) => source.id), updates.map((source) => source.entryId)))
|
|
34922
34933
|
throw new Error("Copied epoch update sources were not preserved");
|
|
34923
34934
|
sourceRevision = JSON.stringify([actual.revision, ...updates.map((update) => update.revision)]);
|
|
34924
34935
|
} else if (pinned.sourceRevision !== old.revision || pinned.retainedMessageCount === void 0) {
|
|
@@ -37866,6 +37877,10 @@ var SessionManager = class _SessionManager {
|
|
|
37866
37877
|
isCurrent: () => isCurrent(currentRevision),
|
|
37867
37878
|
readHistory: (read2) => sink.readHistory((history) => read2(history.branchContext)),
|
|
37868
37879
|
[readCopiedEpochSource]: (read2) => sink.readHistory(read2),
|
|
37880
|
+
readCompactionEntries: (entryIds) => {
|
|
37881
|
+
const ids = [...new Set(entryIds)];
|
|
37882
|
+
return sink.readHistory((history) => this._readCompactionEntriesAt(history, ids, capturedLimits));
|
|
37883
|
+
},
|
|
37869
37884
|
readBranch: async () => {
|
|
37870
37885
|
if (indexed)
|
|
37871
37886
|
return sink.readHistory(async (history) => (await this._readBranchesAt(history, [history.source.leafId], capturedLimits)).branches[0]);
|
|
@@ -37972,7 +37987,7 @@ var SessionManager = class _SessionManager {
|
|
|
37972
37987
|
throw new Error("Session journal requires explicit legacy migration");
|
|
37973
37988
|
const snapshot = await source;
|
|
37974
37989
|
const request = JSON.parse(stringifyBoundedJson(event, 1024 * 1024));
|
|
37975
|
-
if (!
|
|
37990
|
+
if (!isDeepStrictEqual3(request.source, snapshot))
|
|
37976
37991
|
throw new Error("Request event does not match its bound source");
|
|
37977
37992
|
const id = `${request.attemptId}:${request.type}`;
|
|
37978
37993
|
const entry = {
|
|
@@ -37985,7 +38000,7 @@ var SessionManager = class _SessionManager {
|
|
|
37985
38000
|
const json = stringifyBoundedJson(entry, 1024 * 1024 - 1);
|
|
37986
38001
|
if (indexed) {
|
|
37987
38002
|
await this._appendIndexedEntry(state, entry, true, void 0, (existing) => {
|
|
37988
|
-
if (existing.type !== "request" || !
|
|
38003
|
+
if (existing.type !== "request" || !isDeepStrictEqual3(existing.request, request))
|
|
37989
38004
|
throw new Error(`Conflicting request event: ${id}`);
|
|
37990
38005
|
return existing;
|
|
37991
38006
|
}, false);
|
|
@@ -37994,7 +38009,7 @@ var SessionManager = class _SessionManager {
|
|
|
37994
38009
|
await this._enqueue(state, Buffer.byteLength(json), async () => {
|
|
37995
38010
|
const existing = byId.get(id);
|
|
37996
38011
|
if (existing) {
|
|
37997
|
-
if (existing.type !== "request" || !
|
|
38012
|
+
if (existing.type !== "request" || !isDeepStrictEqual3(existing.request, request))
|
|
37998
38013
|
throw new Error(`Conflicting request event: ${id}`);
|
|
37999
38014
|
return;
|
|
38000
38015
|
}
|
|
@@ -38017,7 +38032,7 @@ var SessionManager = class _SessionManager {
|
|
|
38017
38032
|
};
|
|
38018
38033
|
if (persistent && indexed && writer?.format === "framed") {
|
|
38019
38034
|
const capture = (association) => {
|
|
38020
|
-
if (!outputSource || !ownsOutputSource() || !
|
|
38035
|
+
if (!outputSource || !ownsOutputSource() || !isDeepStrictEqual3(association.source, outputSource))
|
|
38021
38036
|
return void 0;
|
|
38022
38037
|
return structuredClone(association);
|
|
38023
38038
|
};
|
|
@@ -38711,6 +38726,54 @@ var SessionManager = class _SessionManager {
|
|
|
38711
38726
|
return entries;
|
|
38712
38727
|
});
|
|
38713
38728
|
}
|
|
38729
|
+
async _readCompactionEntriesAt(history, entryIds, limits) {
|
|
38730
|
+
const { maxEntries, maxSourceBytes } = limits;
|
|
38731
|
+
if (!Number.isSafeInteger(maxEntries) || maxEntries <= 0 || !Number.isSafeInteger(maxSourceBytes) || maxSourceBytes <= 0)
|
|
38732
|
+
throw new Error("Invalid compaction source limits");
|
|
38733
|
+
if (entryIds.length > maxEntries)
|
|
38734
|
+
throw new Error("Compaction entry budget exceeded");
|
|
38735
|
+
const selected = new Set(entryIds);
|
|
38736
|
+
const references = [];
|
|
38737
|
+
for (const id of entryIds) {
|
|
38738
|
+
const reference = await history.branchContext.get(id);
|
|
38739
|
+
if (!reference)
|
|
38740
|
+
throw new Error("Compaction entry is outside its captured branch");
|
|
38741
|
+
references.push(reference);
|
|
38742
|
+
}
|
|
38743
|
+
references.sort((a, b2) => a.sequence - b2.sequence);
|
|
38744
|
+
const suffixAnchors = /* @__PURE__ */ new Set();
|
|
38745
|
+
const visited = /* @__PURE__ */ new Set();
|
|
38746
|
+
let current = history.source.leafId;
|
|
38747
|
+
let leafKind;
|
|
38748
|
+
while (current !== null) {
|
|
38749
|
+
if (visited.has(current))
|
|
38750
|
+
throw new Error("Compaction parent path is unresolved");
|
|
38751
|
+
visited.add(current);
|
|
38752
|
+
const reference = await history.branchContext.get(current);
|
|
38753
|
+
if (!reference)
|
|
38754
|
+
throw new Error("Compaction parent path is unresolved");
|
|
38755
|
+
leafKind ??= reference.kind;
|
|
38756
|
+
if (["message", "custom_message", "branch_summary"].includes(reference.kind)) {
|
|
38757
|
+
if (!selected.has(reference.id))
|
|
38758
|
+
break;
|
|
38759
|
+
suffixAnchors.add(reference.id);
|
|
38760
|
+
}
|
|
38761
|
+
current = reference.parentId;
|
|
38762
|
+
}
|
|
38763
|
+
const entries = [];
|
|
38764
|
+
let sourceBytes = 0;
|
|
38765
|
+
for (const reference of references) {
|
|
38766
|
+
const remaining = maxSourceBytes - sourceBytes;
|
|
38767
|
+
sourceBytes += reference.locator.length;
|
|
38768
|
+
if (sourceBytes > maxSourceBytes)
|
|
38769
|
+
throw new Error("Compaction source byte budget exceeded");
|
|
38770
|
+
const value = await history.hydrateEntry(reference.id, remaining);
|
|
38771
|
+
if (!value)
|
|
38772
|
+
throw new Error("Compaction entry source is unavailable");
|
|
38773
|
+
entries.push(withEntryRetention(value.entry, value.source.retention, value.source.qualification));
|
|
38774
|
+
}
|
|
38775
|
+
return { entries, suffixAnchors, leafKind };
|
|
38776
|
+
}
|
|
38714
38777
|
async _readBranchesAt(history, leafIds, limits) {
|
|
38715
38778
|
const { maxEntries, maxSourceBytes } = limits;
|
|
38716
38779
|
if (!Number.isSafeInteger(maxEntries) || maxEntries <= 0 || !Number.isSafeInteger(maxSourceBytes) || maxSourceBytes <= 0)
|
|
@@ -41585,7 +41648,7 @@ import { randomUUID as randomUUID12 } from "node:crypto";
|
|
|
41585
41648
|
import { existsSync as existsSync24, mkdirSync as mkdirSync8, mkdtempSync as mkdtempSync2 } from "node:fs";
|
|
41586
41649
|
import { tmpdir as tmpdir9 } from "node:os";
|
|
41587
41650
|
import { basename as basename10, dirname as dirname18, join as join29, resolve as resolve13 } from "node:path";
|
|
41588
|
-
import { isDeepStrictEqual as
|
|
41651
|
+
import { isDeepStrictEqual as isDeepStrictEqual5 } from "node:util";
|
|
41589
41652
|
|
|
41590
41653
|
// dist/utils/sleep.js
|
|
41591
41654
|
function sleep(ms, signal) {
|
|
@@ -46096,7 +46159,7 @@ async function loadExtensionModule(extensionPath) {
|
|
|
46096
46159
|
// (file-path aliases would load a second, divergent copy of each package).
|
|
46097
46160
|
// Also disable tryNative so jiti handles ALL imports (not just the entry point)
|
|
46098
46161
|
// Node/dev must also share the native AI registry and implementation identities.
|
|
46099
|
-
...isBunBinary || isBundledCli ? { virtualModules: (await import("./bundled-modules-
|
|
46162
|
+
...isBunBinary || isBundledCli ? { virtualModules: (await import("./bundled-modules-O67MEO74.js")).VIRTUAL_MODULES, tryNative: false } : {
|
|
46100
46163
|
alias: getAliases(),
|
|
46101
46164
|
virtualModules: {
|
|
46102
46165
|
"@ponythewhite/base-context-ai": src_exports,
|
|
@@ -47387,7 +47450,7 @@ import { randomUUID as randomUUID11 } from "node:crypto";
|
|
|
47387
47450
|
import { closeSync as closeSync5, existsSync as existsSync18, fstatSync as fstatSync2, mkdirSync as mkdirSync6, openSync as openSync4, readSync as readSync3, renameSync as renameSync4, statSync as statSync9, unlinkSync as unlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
|
|
47388
47451
|
import { appendFile, mkdir as mkdir2 } from "node:fs/promises";
|
|
47389
47452
|
import { join as join25 } from "node:path";
|
|
47390
|
-
import { isDeepStrictEqual as
|
|
47453
|
+
import { isDeepStrictEqual as isDeepStrictEqual4 } from "node:util";
|
|
47391
47454
|
var REFINEMENT_CUSTOM_TYPE = "prime-agent.refinement";
|
|
47392
47455
|
var REFINE_SKILL_NAME = "refine";
|
|
47393
47456
|
var HARNESS_STATE_DIR_NAME = "harness";
|
|
@@ -48114,7 +48177,7 @@ function applyRefinementProposal(state, proposal, options) {
|
|
|
48114
48177
|
rollbackOf: options.rollbackOf,
|
|
48115
48178
|
scope: options.scope
|
|
48116
48179
|
};
|
|
48117
|
-
if (application && state === application.state && options.id === application.native.id && options.scope === application.scope && options.rollbackOf === void 0 && options.baselineState === application.native.baselineState && matchesNativePlannerPlan(application.plan, application.native) && matchesPlannerOptions(application.options, application.native.options) &&
|
|
48180
|
+
if (application && state === application.state && options.id === application.native.id && options.scope === application.scope && options.rollbackOf === void 0 && options.baselineState === application.native.baselineState && matchesNativePlannerPlan(application.plan, application.native) && matchesPlannerOptions(application.options, application.native.options) && isDeepStrictEqual4(proposal, application.projection)) {
|
|
48118
48181
|
nativePlannerResults.set(result, { native: application.native, scope: application.scope, edits: appliedEdits });
|
|
48119
48182
|
}
|
|
48120
48183
|
return result;
|
|
@@ -48162,7 +48225,7 @@ var nativePlannerPlans = /* @__PURE__ */ new WeakMap();
|
|
|
48162
48225
|
var nativePlannerApplications = /* @__PURE__ */ new WeakMap();
|
|
48163
48226
|
var nativePlannerResults = /* @__PURE__ */ new WeakMap();
|
|
48164
48227
|
function matchesNativePlannerPlan(plan, native) {
|
|
48165
|
-
return plan.proposal === native.proposal && plan.id === native.id && plan.rollbackOf === void 0 && plan.rollbackScope === void 0 && plan.baselineState === native.baselineState &&
|
|
48228
|
+
return plan.proposal === native.proposal && plan.id === native.id && plan.rollbackOf === void 0 && plan.rollbackScope === void 0 && plan.baselineState === native.baselineState && isDeepStrictEqual4(plan.proposal, native.projection);
|
|
48166
48229
|
}
|
|
48167
48230
|
function matchesPlannerOptions(options, captured) {
|
|
48168
48231
|
return options.instructions === captured.instructions && options.global === captured.global && options.rollbackId === captured.rollbackId;
|
|
@@ -57244,6 +57307,11 @@ var ReplKernelManager = class {
|
|
|
57244
57307
|
return;
|
|
57245
57308
|
this.appendKernelDiagnostic(`kernel stdout error: ${errorMessage3(error)}`);
|
|
57246
57309
|
});
|
|
57310
|
+
child.stderr?.on("error", (error) => {
|
|
57311
|
+
if (this.child !== child)
|
|
57312
|
+
return;
|
|
57313
|
+
this.appendKernelDiagnostic(`kernel stderr error: ${errorMessage3(error)}`);
|
|
57314
|
+
});
|
|
57247
57315
|
child.once("exit", () => {
|
|
57248
57316
|
globalThis.setImmediate(() => child.stderr?.destroy());
|
|
57249
57317
|
});
|
|
@@ -61692,7 +61760,7 @@ var AgentSession = class _AgentSession {
|
|
|
61692
61760
|
const { state, snapshot: original, arrivalEpoch, cwd } = capture;
|
|
61693
61761
|
const before = this._snapshotAutonomousRuntimeState(original);
|
|
61694
61762
|
const candidate = structuredClone(original);
|
|
61695
|
-
const current = () => this._isCompactionOwnerCurrent(owner) && this._autonomousState === state &&
|
|
61763
|
+
const current = () => this._isCompactionOwnerCurrent(owner) && this._autonomousState === state && isDeepStrictEqual5(state, original);
|
|
61696
61764
|
if (!current())
|
|
61697
61765
|
return void 0;
|
|
61698
61766
|
let messageToQueue;
|
|
@@ -61802,7 +61870,7 @@ var AgentSession = class _AgentSession {
|
|
|
61802
61870
|
const actions = new Set(current.map((continuation) => continuation.action));
|
|
61803
61871
|
const cancelled = this._cancelSessionActions((action) => actions.has(action), new Error("Queued autonomous continuation was cleared before delivery."));
|
|
61804
61872
|
if (options.restoreAutonomousState) {
|
|
61805
|
-
const continuation = current.find((candidate) => this._isCompactionOwnerCurrent(candidate.owner) && cancelled.includes(candidate.action) && !primaryDeliveryRecord(candidate.action).durable && this._autonomousState === candidate.state &&
|
|
61873
|
+
const continuation = current.find((candidate) => this._isCompactionOwnerCurrent(candidate.owner) && cancelled.includes(candidate.action) && !primaryDeliveryRecord(candidate.action).durable && this._autonomousState === candidate.state && isDeepStrictEqual5(candidate.state, candidate.after));
|
|
61806
61874
|
if (continuation)
|
|
61807
61875
|
this._restoreAutonomousRuntimeSnapshot(continuation.before);
|
|
61808
61876
|
}
|
|
@@ -61883,12 +61951,14 @@ var AgentSession = class _AgentSession {
|
|
|
61883
61951
|
this._assertCompactionOwner(owner);
|
|
61884
61952
|
const compaction = owner.manager.bindCompactionSink();
|
|
61885
61953
|
const captured = owner.requests.capture(compaction);
|
|
61886
|
-
let branch;
|
|
61887
61954
|
let preparation;
|
|
61955
|
+
let leafKind;
|
|
61888
61956
|
try {
|
|
61889
|
-
|
|
61890
|
-
|
|
61891
|
-
|
|
61957
|
+
if (this.isStreaming) {
|
|
61958
|
+
const prepared = await this._prepareCapturedCompaction(settings, captured, compaction, owner);
|
|
61959
|
+
preparation = prepared.preparation;
|
|
61960
|
+
leafKind = prepared.leafKind;
|
|
61961
|
+
}
|
|
61892
61962
|
} catch (error) {
|
|
61893
61963
|
try {
|
|
61894
61964
|
await captured.dispose();
|
|
@@ -61907,10 +61977,9 @@ var AgentSession = class _AgentSession {
|
|
|
61907
61977
|
reason: "no active turn; compaction can only be requested while a turn is running"
|
|
61908
61978
|
};
|
|
61909
61979
|
if (!preparation) {
|
|
61910
|
-
const lastEntry = branch.at(-1);
|
|
61911
61980
|
return {
|
|
61912
61981
|
scheduled: false,
|
|
61913
|
-
reason:
|
|
61982
|
+
reason: leafKind === "compaction" ? "already compacted" : "session is too short to compact"
|
|
61914
61983
|
};
|
|
61915
61984
|
}
|
|
61916
61985
|
this._assertContextOptimizationAllowed();
|
|
@@ -62237,7 +62306,7 @@ var AgentSession = class _AgentSession {
|
|
|
62237
62306
|
const autonomousState = this._autonomousState;
|
|
62238
62307
|
const autonomousSnapshot = structuredClone(autonomousState);
|
|
62239
62308
|
const cwd = this._cwd;
|
|
62240
|
-
const autonomousOwnerIsCurrent = () => this._autonomousState === autonomousState &&
|
|
62309
|
+
const autonomousOwnerIsCurrent = () => this._autonomousState === autonomousState && isDeepStrictEqual5(autonomousState, autonomousSnapshot);
|
|
62241
62310
|
const goalOutcome = await this._getGoalContinuationMessages(context, signal, owner);
|
|
62242
62311
|
if (!this._isGoalContinuationOwnerCurrent(owner))
|
|
62243
62312
|
return this._stoppedContinuationOutcome(signal);
|
|
@@ -64828,8 +64897,9 @@ ${parsed.args}` : block;
|
|
|
64828
64897
|
actionId: action.id,
|
|
64829
64898
|
submittedText: input.submitted?.text
|
|
64830
64899
|
};
|
|
64900
|
+
const clearedGoal = Boolean(this._goalState.objective) && this._parseGoalSlashCommand(input.text)?.kind === "clear";
|
|
64831
64901
|
await this._handleGoalSlashCommand(input.text, input.images, goalOrigin);
|
|
64832
|
-
resultText = this._goalState.objective ? `Goal ${this._goalState.status}: ${this._goalState.objective}` : "No active goal.";
|
|
64902
|
+
resultText = this._goalState.objective ? `Goal ${this._goalState.status}: ${this._goalState.objective}` : clearedGoal ? "Goal cleared." : "No active goal.";
|
|
64833
64903
|
break;
|
|
64834
64904
|
}
|
|
64835
64905
|
case "autonomous":
|
|
@@ -66002,14 +66072,12 @@ ${parsed.args}` : block;
|
|
|
66002
66072
|
const semanticEdges = owner.semanticEdges;
|
|
66003
66073
|
compaction = owner.manager.bindCompactionSink();
|
|
66004
66074
|
requests = owner.requests.capture(compaction);
|
|
66005
|
-
const pathEntries = await compaction.readBranch();
|
|
66006
66075
|
this._assertCompactionOwner(owner);
|
|
66007
66076
|
const { apiKey, headers } = await this._getRequiredRequestAuth(model);
|
|
66008
66077
|
this._assertCompactionOwner(owner);
|
|
66009
66078
|
committed = await this._performCompaction({
|
|
66010
66079
|
model,
|
|
66011
66080
|
thinkingLevel,
|
|
66012
|
-
pathEntries,
|
|
66013
66081
|
settings,
|
|
66014
66082
|
requests,
|
|
66015
66083
|
compaction,
|
|
@@ -66093,30 +66161,46 @@ ${parsed.args}` : block;
|
|
|
66093
66161
|
}
|
|
66094
66162
|
}
|
|
66095
66163
|
/** A private compiled context keeps extension summary edits separate from retained source recipes. */
|
|
66096
|
-
async _prepareCapturedCompaction(
|
|
66164
|
+
async _prepareCapturedCompaction(settings, requests, compaction, owner = this._captureCompactionOwner(), allowShortSession = false, budgetPressure = false, capacity) {
|
|
66097
66165
|
this._assertCompactionOwner(owner);
|
|
66098
66166
|
const limits = this.settingsManager.getCanonicalContextLimits();
|
|
66099
66167
|
const resource = this._captureKernelResource();
|
|
66100
66168
|
const source = await compaction.source;
|
|
66101
66169
|
this._assertCompactionOwner(owner);
|
|
66102
|
-
if (!source.persistent)
|
|
66170
|
+
if (!source.persistent) {
|
|
66171
|
+
const pathEntries = await compaction.readBranch();
|
|
66172
|
+
this._assertCompactionOwner(owner);
|
|
66103
66173
|
return {
|
|
66104
66174
|
preparation: prepareCompaction(pathEntries, settings, allowShortSession),
|
|
66175
|
+
pathEntries,
|
|
66176
|
+
leafKind: pathEntries.at(-1)?.type,
|
|
66105
66177
|
maxSourceBytes: limits.maxSourceBytes
|
|
66106
66178
|
};
|
|
66179
|
+
}
|
|
66107
66180
|
return requests.readHistory(async (view) => {
|
|
66108
66181
|
const messages = await new CanonicalContextCompiler().compile(view, limits, void 0, {}, resource, this._initialContextMode, false, "read");
|
|
66109
66182
|
this._assertCompactionOwner(owner);
|
|
66110
66183
|
const context = getCanonicalEpochContext(messages);
|
|
66111
|
-
|
|
66112
|
-
|
|
66184
|
+
const entryIds = context.references.map((ref) => ref?.ref.entryId);
|
|
66185
|
+
const selected = await compaction.readCompactionEntries(entryIds.filter((id) => id !== void 0));
|
|
66186
|
+
this._assertCompactionOwner(owner);
|
|
66187
|
+
const pathEntries = selected.entries;
|
|
66188
|
+
if (context.checkpoint?.includeSummary && selected.leafKind === "compaction")
|
|
66189
|
+
return {
|
|
66190
|
+
preparation: void 0,
|
|
66191
|
+
pathEntries,
|
|
66192
|
+
leafKind: selected.leafKind,
|
|
66193
|
+
maxSourceBytes: limits.maxSourceBytes
|
|
66194
|
+
};
|
|
66113
66195
|
const authorization = getRecoveryCompactionAuthorization(capacity);
|
|
66114
66196
|
const boundary = canonicalRecoveryBoundary(messages, authorization);
|
|
66115
|
-
const preparation =
|
|
66197
|
+
const preparation = prepareViewCompaction(messages, entryIds, pathEntries, settings, boundary, allowShortSession, budgetPressure, selected.suffixAnchors);
|
|
66116
66198
|
if (preparation)
|
|
66117
66199
|
prepareRecoveryCompaction(messages, preparation.firstKeptEntryId, limits.maxSourceBytes, authorization);
|
|
66118
66200
|
return {
|
|
66119
66201
|
preparation,
|
|
66202
|
+
pathEntries,
|
|
66203
|
+
leafKind: selected.leafKind,
|
|
66120
66204
|
messages,
|
|
66121
66205
|
resource: context.resourceRevision !== void 0 ? resource : void 0,
|
|
66122
66206
|
maxSourceBytes: limits.maxSourceBytes
|
|
@@ -66129,15 +66213,15 @@ ${parsed.args}` : block;
|
|
|
66129
66213
|
* Error("Compaction cancelled") on abort or extension cancel.
|
|
66130
66214
|
*/
|
|
66131
66215
|
async _performCompaction(options) {
|
|
66132
|
-
const { model, apiKey, headers, customInstructions, signal, thinkingLevel, requests, compaction, semanticEdges,
|
|
66133
|
-
const prepared = await this._prepareCapturedCompaction(
|
|
66216
|
+
const { model, apiKey, headers, customInstructions, signal, thinkingLevel, requests, compaction, semanticEdges, settings, owner = this._captureCompactionOwner(), allowShortSession = false, budgetPressure = false } = options;
|
|
66217
|
+
const prepared = await this._prepareCapturedCompaction(settings, requests, compaction, owner, allowShortSession, budgetPressure, options.capacity);
|
|
66134
66218
|
this._assertCompactionOwner(owner);
|
|
66135
66219
|
if (prepared.resource)
|
|
66136
66220
|
assertResourceCurrent(prepared.resource);
|
|
66137
66221
|
const preparation = prepared.preparation;
|
|
66222
|
+
const pathEntries = prepared.pathEntries;
|
|
66138
66223
|
if (!preparation) {
|
|
66139
|
-
|
|
66140
|
-
if (lastEntry?.type === "compaction") {
|
|
66224
|
+
if (prepared.leafKind === "compaction") {
|
|
66141
66225
|
throw new CompactionSkippedError("Already compacted");
|
|
66142
66226
|
}
|
|
66143
66227
|
throw new CompactionSkippedError("Session is too short to compact \u2014 try again once it grows");
|
|
@@ -66799,7 +66883,7 @@ ${parsed.args}` : block;
|
|
|
66799
66883
|
const harnessState = this._loadMergedHarnessState();
|
|
66800
66884
|
const evidence = await this._autoRefineEvidence(harnessState);
|
|
66801
66885
|
signal?.throwIfAborted();
|
|
66802
|
-
if (
|
|
66886
|
+
if (isDeepStrictEqual5(evidence, this._lastAutoRefineEvidence))
|
|
66803
66887
|
return { shouldRefine: false, rationale: "No new task evidence since the previous automatic review." };
|
|
66804
66888
|
this._lastAutoRefineEvidence = evidence;
|
|
66805
66889
|
if (this._autoRefineReviewer)
|
|
@@ -67376,7 +67460,6 @@ This compaction outcome could not be saved to session history: ${persistenceErro
|
|
|
67376
67460
|
const semanticEdges = owner.semanticEdges;
|
|
67377
67461
|
compaction = owner.manager.bindCompactionSink();
|
|
67378
67462
|
requests = owner.requests.capture(compaction);
|
|
67379
|
-
const pathEntries = await compaction.readBranch();
|
|
67380
67463
|
this._assertCompactionOwner(owner);
|
|
67381
67464
|
const authResult = model ? await this._modelRegistry.getApiKeyAndHeaders(model) : void 0;
|
|
67382
67465
|
this._assertCompactionOwner(owner);
|
|
@@ -67391,7 +67474,6 @@ This compaction outcome could not be saved to session history: ${persistenceErro
|
|
|
67391
67474
|
committed = await this._performCompaction({
|
|
67392
67475
|
model,
|
|
67393
67476
|
thinkingLevel,
|
|
67394
|
-
pathEntries,
|
|
67395
67477
|
settings,
|
|
67396
67478
|
requests,
|
|
67397
67479
|
compaction,
|
|
@@ -70929,7 +71011,7 @@ import { resolve as resolve15 } from "node:path";
|
|
|
70929
71011
|
var BASE_CONTEXT_BUILD_ID_ENV = "BASE_CONTEXT_BUILD_ID";
|
|
70930
71012
|
var BASE_CONTEXT_LAUNCHER_PATH_ENV = "BASE_CONTEXT_LAUNCHER_PATH";
|
|
70931
71013
|
function bundledBuildId() {
|
|
70932
|
-
return false ? void 0 : "v1.0.14";
|
|
71014
|
+
return false ? void 0 : "v1.0.14-2-g7486ffe2b";
|
|
70933
71015
|
}
|
|
70934
71016
|
function getDaemonRuntimeIdentity(environment = process.env) {
|
|
70935
71017
|
const entrypoint = process.argv[1];
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
isOwnedSessionWorkerProcess,
|
|
6
6
|
maybeRunOwnedSessionWorkerFrontend,
|
|
7
7
|
maybeStartDaemonEarly
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RQFC34FM.js";
|
|
9
9
|
import {
|
|
10
10
|
APP_NAME
|
|
11
11
|
} from "./chunk-IEM74GZ5.js";
|
|
@@ -39,7 +39,7 @@ async function runCli() {
|
|
|
39
39
|
}
|
|
40
40
|
const [{ EnvHttpProxyAgent, setGlobalDispatcher }, { main }] = await Promise.all([
|
|
41
41
|
import("undici"),
|
|
42
|
-
import("./main-
|
|
42
|
+
import("./main-YERLD3T4.js")
|
|
43
43
|
]);
|
|
44
44
|
setGlobalDispatcher(new EnvHttpProxyAgent({ bodyTimeout: 0, headersTimeout: 0 }));
|
|
45
45
|
try {
|
package/dist/bundle/cli.js
CHANGED
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
shouldUseDaemonClientRuntime,
|
|
18
18
|
shouldUseDaemonInteractive,
|
|
19
19
|
shouldUseEphemeralSessionManagerForDaemonInteractive
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-DGO66I3L.js";
|
|
21
|
+
import "./chunk-RQFC34FM.js";
|
|
22
22
|
import "./chunk-CFNASUYO.js";
|
|
23
23
|
import "./chunk-V6LOBH6X.js";
|
|
24
24
|
import "./chunk-IEM74GZ5.js";
|