@cortexkit/opencode-magic-context 0.49.32 → 0.49.34
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/dist/auto-search-worker.js +1 -1
- package/dist/chunk-embedding-write-worker.js +1 -1
- package/dist/{context-n27jdyyh.js → context-p3xrarzt.js} +15 -10
- package/dist/features/magic-context/compaction-marker.d.ts +22 -6
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/request-tool-definitions.d.ts +25 -0
- package/dist/features/magic-context/request-tool-definitions.d.ts.map +1 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts +7 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +5 -5
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-publication.d.ts +9 -0
- package/dist/hooks/magic-context/compaction-marker-publication.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts +7 -0
- package/dist/hooks/magic-context/compartment-render-epoch.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +7 -2
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +1 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-94ef0qe2.js → index-04z754rd.js} +1 -1
- package/dist/{index-qr2mb02j.js → index-0677w9sd.js} +2 -2
- package/dist/{index-t6b3px80.js → index-07vskjn8.js} +3 -3
- package/dist/{index-0fe4q77z.js → index-7g9dr8gy.js} +34 -2
- package/dist/{index-3drcgsnf.js → index-97spytxq.js} +12 -11
- package/dist/{index-4s4zq97n.js → index-9gpw8hrm.js} +1 -1
- package/dist/{index-bzwh06cp.js → index-atekmqef.js} +327 -61
- package/dist/{index-hbt0sbv2.js → index-fm36bjv4.js} +1 -1
- package/dist/{index-2agkcr3y.js → index-ftr84kkv.js} +2 -2
- package/dist/{index-g0kqnc6y.js → index-hbx7m8he.js} +9 -4
- package/dist/{index-3jmx3fae.js → index-m1x9ghk5.js} +1 -1
- package/dist/index.js +14 -14
- package/dist/{message-index-bounded-zq7a5nm6.js → message-index-bounded-qh91fdr3.js} +2 -2
- package/dist/migration-worker.js +1 -1
- package/dist/raw-ordinal-warmup-worker.js +2 -2
- package/dist/{read-session-chunk-1ndphmb8.js → read-session-chunk-kaghtr75.js} +1 -1
- package/dist/{recomp-orchestrator-6ncc6wrw.js → recomp-orchestrator-0y983w7h.js} +5 -5
- package/dist/{search-archive-sr07c6aj.js → search-archive-1kw2rp19.js} +2 -2
- package/dist/{search-040pac3a.js → search-p684j8ww.js} +4 -4
- package/dist/{transform-postprocess-phase-wvt1k03d.js → transform-postprocess-phase-ph38mhrs.js} +6 -6
- package/dist/v2/auto-search-worker.js +1 -1
- package/dist/v2/chunk-embedding-write-worker.js +1 -1
- package/dist/v2/{context-ehews84p.js → context-s60hcatx.js} +19 -8
- package/dist/v2/hooks/context.d.ts +3 -3
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-jvgz7vk9.js → message-index-bounded-4htdr1j6.js} +2 -2
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
- package/dist/v2/{read-session-chunk-djzgm4jg.js → read-session-chunk-1fa9qzwb.js} +1 -1
- package/dist/v2/{recomp-orchestrator-3r9kcs61.js → recomp-orchestrator-7q9nvxte.js} +4 -4
- package/dist/v2/{search-archive-n3dhns4r.js → search-archive-xfp51s0g.js} +2 -2
- package/dist/v2/{search-q3wkpe8t.js → search-wf8rqxhm.js} +3 -3
- package/dist/v2/{server-n14edf07.js → server-ajxhrgjv.js} +1 -1
- package/dist/v2/{server-rr4cbkr0.js → server-grakwy1v.js} +1 -1
- package/dist/v2/{server-d01pe8q5.js → server-jw5qe9y8.js} +1 -1
- package/dist/v2/{server-hwag0khr.js → server-m1pfg2d4.js} +1 -1
- package/dist/v2/{server-rb8m4vry.js → server-qvy4qavp.js} +34 -2
- package/dist/v2/{server-4n176b5m.js → server-z2wft9zv.js} +352 -87
- package/dist/v2/server.js +2 -2
- package/dist/v2/{wrapup-orchestrator-ddmvbkra.js → wrapup-orchestrator-wxf7n5k6.js} +4 -4
- package/dist/{wrapup-orchestrator-fyvyzcbm.js → wrapup-orchestrator-ys2nrkkb.js} +6 -6
- package/package.json +1 -1
- package/src/shared/sqlite-transaction-mode-guard.test.ts +2 -0
|
@@ -88,7 +88,7 @@ import {
|
|
|
88
88
|
toMessageIndexSource,
|
|
89
89
|
clearIndexedMessagesInTransaction,
|
|
90
90
|
indexSourcesAfterOrdinal
|
|
91
|
-
} from "./server-
|
|
91
|
+
} from "./server-m1pfg2d4.js";
|
|
92
92
|
import {
|
|
93
93
|
retreatPastHostUnservedRows,
|
|
94
94
|
snapTerminalCompartmentToServedRow,
|
|
@@ -154,7 +154,9 @@ import {
|
|
|
154
154
|
getOverflowState,
|
|
155
155
|
clearEmergencyRecovery,
|
|
156
156
|
getPersistedCompactionMarkerState,
|
|
157
|
-
|
|
157
|
+
getCompactionMarkerPublicationState,
|
|
158
|
+
compareAndSetCompactionMarkerPublicationState,
|
|
159
|
+
getDeferredClearedCompactionMarkerState,
|
|
158
160
|
parseStrippedPlaceholderState,
|
|
159
161
|
serializeStrippedPlaceholderState,
|
|
160
162
|
THINKING_BINDING_RECOVERY_FROZEN_PREFIX,
|
|
@@ -187,7 +189,7 @@ import {
|
|
|
187
189
|
getRawSessionTagKeysThrough2,
|
|
188
190
|
getLegacyProtectedTailStartOrdinal2,
|
|
189
191
|
readSessionChunk2
|
|
190
|
-
} from "./server-
|
|
192
|
+
} from "./server-qvy4qavp.js";
|
|
191
193
|
import {
|
|
192
194
|
getTableColumnNames,
|
|
193
195
|
tagTombstoneOwnerRange,
|
|
@@ -202,7 +204,7 @@ import {
|
|
|
202
204
|
LATEST_SUPPORTED_VERSION,
|
|
203
205
|
getPersistedSchemaVersion,
|
|
204
206
|
openDatabase
|
|
205
|
-
} from "./server-
|
|
207
|
+
} from "./server-jw5qe9y8.js";
|
|
206
208
|
import {
|
|
207
209
|
providerMass,
|
|
208
210
|
calibrationForModelKey,
|
|
@@ -550,6 +552,44 @@ function withLiveDreamerOutputCap(executor, boot, fresh) {
|
|
|
550
552
|
};
|
|
551
553
|
}
|
|
552
554
|
|
|
555
|
+
// src/features/magic-context/request-tool-definitions.ts
|
|
556
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
557
|
+
var IDENTITY_SCOPE = "names-descriptions-v1";
|
|
558
|
+
var sha = (value) => createHash2("sha256").update(JSON.stringify(value)).digest("hex");
|
|
559
|
+
function v2ToolDefinitionsHash(tools) {
|
|
560
|
+
const pairs = Object.entries(tools).map(([name, tool]) => [name, tool.description]).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
|
|
561
|
+
return JSON.stringify({
|
|
562
|
+
scope: IDENTITY_SCOPE,
|
|
563
|
+
hash: sha(pairs),
|
|
564
|
+
tools: pairs.map(([name, description]) => [name, sha([name, description])])
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function needsRequestToolIdentityAdoption(previous, current) {
|
|
568
|
+
return readIdentity(current).scope === IDENTITY_SCOPE && readIdentity(previous).scope !== IDENTITY_SCOPE;
|
|
569
|
+
}
|
|
570
|
+
function readIdentity(value) {
|
|
571
|
+
try {
|
|
572
|
+
const parsed = JSON.parse(value);
|
|
573
|
+
if (typeof parsed.hash === "string" && Array.isArray(parsed.tools) && parsed.tools.every((item) => Array.isArray(item) && item.length === 2 && item.every((part) => typeof part === "string")))
|
|
574
|
+
return parsed;
|
|
575
|
+
} catch {}
|
|
576
|
+
return { hash: value, tools: [] };
|
|
577
|
+
}
|
|
578
|
+
function describeRequestToolDefinitionChange(previous, current) {
|
|
579
|
+
const before = readIdentity(previous);
|
|
580
|
+
const after = readIdentity(current);
|
|
581
|
+
let firstDifferingTool = "unknown";
|
|
582
|
+
for (let index = 0;index < Math.max(before.tools.length, after.tools.length); index++) {
|
|
583
|
+
const left = before.tools[index];
|
|
584
|
+
const right = after.tools[index];
|
|
585
|
+
if (left?.[0] === right?.[0] && left?.[1] === right?.[1])
|
|
586
|
+
continue;
|
|
587
|
+
firstDifferingTool = left?.[0] === right?.[0] ? left?.[0] ?? "unknown" : `${left?.[0] ?? "(absent)"}→${right?.[0] ?? "(absent)"}`;
|
|
588
|
+
break;
|
|
589
|
+
}
|
|
590
|
+
return { previousHash: before.hash, currentHash: after.hash, firstDifferingTool };
|
|
591
|
+
}
|
|
592
|
+
|
|
553
593
|
// src/features/magic-context/compartment-lease.ts
|
|
554
594
|
var COMPARTMENT_LEASE_TTL_MS = 5 * 60 * 1000;
|
|
555
595
|
var COMPARTMENT_LEASE_RENEWAL_MS = 60 * 1000;
|
|
@@ -905,7 +945,7 @@ function isPartialCompartmentEnd(db, sessionId, messageId) {
|
|
|
905
945
|
return Boolean(db.prepare("SELECT 1 FROM compartments WHERE session_id=? AND end_message_id=? AND end_block_index IS NOT NULL LIMIT 1").get(sessionId, messageId));
|
|
906
946
|
}
|
|
907
947
|
// src/features/magic-context/project-docs-hash.ts
|
|
908
|
-
import { createHash as
|
|
948
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
909
949
|
import { lstatSync, readFileSync as readFileSync2, statSync as statSync2 } from "node:fs";
|
|
910
950
|
import path from "node:path";
|
|
911
951
|
var PROJECT_DOC_FILES = ["ARCHITECTURE.md", "STRUCTURE.md"];
|
|
@@ -1004,7 +1044,7 @@ function hashCanonicalPieces(hashPieces) {
|
|
|
1004
1044
|
if (hashPieces.length === 0) {
|
|
1005
1045
|
return "";
|
|
1006
1046
|
}
|
|
1007
|
-
return
|
|
1047
|
+
return createHash3("sha256").update(hashPieces.join(PROJECT_DOCS_DELIMITER), "utf8").digest("hex");
|
|
1008
1048
|
}
|
|
1009
1049
|
function readProjectDocsCanonical(projectDirectory) {
|
|
1010
1050
|
canonicalReadCountForTests += 1;
|
|
@@ -1030,10 +1070,10 @@ function readProjectDocsCanonical(projectDirectory) {
|
|
|
1030
1070
|
return { renderedBlock, canonicalHash };
|
|
1031
1071
|
}
|
|
1032
1072
|
// src/hooks/magic-context/lkg-slot.ts
|
|
1033
|
-
import { createHash as
|
|
1073
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
1034
1074
|
|
|
1035
1075
|
// src/hooks/magic-context/lkg-measured-request.ts
|
|
1036
|
-
import { createHash as
|
|
1076
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
1037
1077
|
|
|
1038
1078
|
// src/shared/provider-response-completion.ts
|
|
1039
1079
|
function providerResponseFailed(input) {
|
|
@@ -1051,16 +1091,16 @@ function isSuccessfulProviderCompletion(input) {
|
|
|
1051
1091
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
1052
1092
|
|
|
1053
1093
|
// src/hooks/magic-context/lkg-recovery-fence.ts
|
|
1054
|
-
import { createHash as
|
|
1094
|
+
import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
|
|
1055
1095
|
import { lstatSync as lstatSync2, readdirSync as readdirSync2, readFileSync as readFileSync4, rmdirSync, rmSync as rmSync2 } from "node:fs";
|
|
1056
1096
|
import { basename, dirname, join as join2 } from "node:path";
|
|
1057
1097
|
|
|
1058
1098
|
// src/shared/storage-file-mutex.ts
|
|
1059
1099
|
import { execFileSync } from "node:child_process";
|
|
1060
|
-
import { createHash as
|
|
1100
|
+
import { createHash as createHash4, randomUUID } from "node:crypto";
|
|
1061
1101
|
import { readdirSync, readFileSync as readFileSync3, rmSync } from "node:fs";
|
|
1062
1102
|
import { join } from "node:path";
|
|
1063
|
-
var ticketChecksum = (name, ticket) =>
|
|
1103
|
+
var ticketChecksum = (name, ticket) => createHash4("sha256").update(JSON.stringify([name, ticket.choosing, ticket.number, ticket.birth])).digest("hex");
|
|
1064
1104
|
function processBirth(pid) {
|
|
1065
1105
|
if (process.platform === "linux") {
|
|
1066
1106
|
try {
|
|
@@ -1190,7 +1230,7 @@ function clearLkgFenceProcessState(sessionId) {
|
|
|
1190
1230
|
knownFences.clear();
|
|
1191
1231
|
}
|
|
1192
1232
|
var durableFencesSupported = () => platform !== "win32";
|
|
1193
|
-
var hash = (value) =>
|
|
1233
|
+
var hash = (value) => createHash5("sha256").update(value).digest("hex");
|
|
1194
1234
|
var lkgServedArrayDigest = hash;
|
|
1195
1235
|
function lkgRecoveryFencePath(sessionId) {
|
|
1196
1236
|
return join2(getMagicContextStorageDir(), "lkg-recovery-fences", `${hash(sessionId)}.json`);
|
|
@@ -1207,7 +1247,7 @@ function metadata(slot) {
|
|
|
1207
1247
|
];
|
|
1208
1248
|
}
|
|
1209
1249
|
function representationKey(slot) {
|
|
1210
|
-
return
|
|
1250
|
+
return createHash5("sha256").update(slot.jsonPrefix).update(JSON.stringify(metadata(slot))).digest("hex");
|
|
1211
1251
|
}
|
|
1212
1252
|
function lkgRecoverySlotKey(slot) {
|
|
1213
1253
|
return hash(JSON.stringify([
|
|
@@ -1526,7 +1566,7 @@ function cancelAutoSearchWork(sessionId) {
|
|
|
1526
1566
|
}
|
|
1527
1567
|
|
|
1528
1568
|
// src/v2/store-reader.ts
|
|
1529
|
-
import { createHash as
|
|
1569
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
1530
1570
|
import { statSync as statSync3 } from "node:fs";
|
|
1531
1571
|
import { hostname } from "node:os";
|
|
1532
1572
|
import { resolve } from "node:path";
|
|
@@ -1798,7 +1838,7 @@ class V2StoreReader {
|
|
|
1798
1838
|
this.db = this.connection.db;
|
|
1799
1839
|
}
|
|
1800
1840
|
hostIdentity() {
|
|
1801
|
-
return
|
|
1841
|
+
return createHash6("sha256").update(JSON.stringify([hostname(), resolve(this.path), this.connection.identity])).digest("hex");
|
|
1802
1842
|
}
|
|
1803
1843
|
prepare(sql) {
|
|
1804
1844
|
if (this.closed)
|
|
@@ -2842,7 +2882,7 @@ function lkgProviderInputTotal(tokens) {
|
|
|
2842
2882
|
return counts.every((count) => Number.isSafeInteger(count) && count >= 0) ? counts.reduce((sum, count) => sum + count, 0) : Number.NaN;
|
|
2843
2883
|
}
|
|
2844
2884
|
function identity(slot) {
|
|
2845
|
-
return
|
|
2885
|
+
return createHash7("sha256").update(JSON.stringify([
|
|
2846
2886
|
slot.capturedAt,
|
|
2847
2887
|
slot.captureSequence,
|
|
2848
2888
|
slot.rowVersion,
|
|
@@ -2938,7 +2978,7 @@ function clearCapturedLkgMeasurement(sessionId) {
|
|
|
2938
2978
|
}
|
|
2939
2979
|
|
|
2940
2980
|
// src/hooks/magic-context/lkg-persist.ts
|
|
2941
|
-
import { createHash as
|
|
2981
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
2942
2982
|
function parseStringArray(value) {
|
|
2943
2983
|
if (typeof value !== "string")
|
|
2944
2984
|
return null;
|
|
@@ -3052,7 +3092,7 @@ function rememberFingerprint(db, sessionId, fingerprint) {
|
|
|
3052
3092
|
saved.set(sessionId, fingerprint);
|
|
3053
3093
|
}
|
|
3054
3094
|
function slotFingerprint(slot) {
|
|
3055
|
-
return
|
|
3095
|
+
return createHash8("sha256").update(JSON.stringify([
|
|
3056
3096
|
slot.jsonPrefix,
|
|
3057
3097
|
slot.inputIdSeq,
|
|
3058
3098
|
slot.inputContentDigests,
|
|
@@ -4225,7 +4265,7 @@ var DIGEST_CHUNK_BYTES = 64 * 1024;
|
|
|
4225
4265
|
var digestChunk;
|
|
4226
4266
|
function lkgContentDigestFromFields(fields) {
|
|
4227
4267
|
lkgDigestsComputed += 1;
|
|
4228
|
-
const hash =
|
|
4268
|
+
const hash = createHash9("sha256");
|
|
4229
4269
|
digestChunk ??= Buffer.allocUnsafe(DIGEST_CHUNK_BYTES);
|
|
4230
4270
|
const chunk = digestChunk;
|
|
4231
4271
|
let offset = 0;
|
|
@@ -4288,7 +4328,7 @@ function legacyLkgDigestFromFields(fields) {
|
|
|
4288
4328
|
const value = typeof field === "symbol" ? field.description ?? "" : String(field);
|
|
4289
4329
|
key += `${typeof field}:${value.length}:${value}\x00`;
|
|
4290
4330
|
}
|
|
4291
|
-
return
|
|
4331
|
+
return createHash9("sha256").update(key).digest("base64url");
|
|
4292
4332
|
}
|
|
4293
4333
|
function legacyLkgContentDigest(message) {
|
|
4294
4334
|
const fields = flattenContentFields(withoutEmptyUserDiffSummary(message));
|
|
@@ -6383,14 +6423,14 @@ class HiddenCompletionRefusal extends Error {
|
|
|
6383
6423
|
}
|
|
6384
6424
|
|
|
6385
6425
|
// src/features/magic-context/compaction-marker.ts
|
|
6386
|
-
import { createHash as
|
|
6426
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
6387
6427
|
import { existsSync, statSync as statSync4 } from "node:fs";
|
|
6388
6428
|
var BASE62_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
6389
6429
|
var ID_PREFIX_HEX_LENGTH = 12;
|
|
6390
6430
|
var ID_SUFFIX_LENGTH = 14;
|
|
6391
6431
|
var ID_PREFIX_MASK = (1n << BigInt(ID_PREFIX_HEX_LENGTH * 4)) - 1n;
|
|
6392
6432
|
function deterministicBase62(seed, length) {
|
|
6393
|
-
let value = BigInt(`0x${
|
|
6433
|
+
let value = BigInt(`0x${createHash10("sha256").update(seed).digest("hex")}`);
|
|
6394
6434
|
const chars = Array(length);
|
|
6395
6435
|
for (let index = length - 1;index >= 0; index -= 1) {
|
|
6396
6436
|
chars[index] = BASE62_CHARS[Number(value % 62n)];
|
|
@@ -6611,6 +6651,80 @@ function getOpenCodeMessageById(sessionId, messageId) {
|
|
|
6611
6651
|
const row = db.prepare(`SELECT id FROM message WHERE session_id = ? AND id = ? LIMIT 1`).get(sessionId, messageId);
|
|
6612
6652
|
return row ?? null;
|
|
6613
6653
|
}
|
|
6654
|
+
function planCompactionMarker(args, boundary) {
|
|
6655
|
+
const identity = `${args.sessionId}\x00${args.endMessageId}`;
|
|
6656
|
+
return {
|
|
6657
|
+
boundaryMessageId: boundary.id,
|
|
6658
|
+
summaryMessageId: generateMessageId(boundary.timeCreated + 1, 1n, `${identity}\x00summary-message`),
|
|
6659
|
+
compactionPartId: generatePartId(boundary.timeCreated, 1n, `${identity}\x00compaction-part`),
|
|
6660
|
+
summaryPartId: generatePartId(boundary.timeCreated + 1, 2n, `${identity}\x00summary-part`)
|
|
6661
|
+
};
|
|
6662
|
+
}
|
|
6663
|
+
function isCompactionMarkerIntentAbsent(marker, targetEndMessageId) {
|
|
6664
|
+
if (!targetEndMessageId)
|
|
6665
|
+
return false;
|
|
6666
|
+
const db = getWritableOpenCodeDb();
|
|
6667
|
+
return !db.prepare(`SELECT 1 FROM message WHERE id IN (?, ?)
|
|
6668
|
+
UNION ALL SELECT 1 FROM part WHERE id IN (?, ?) LIMIT 1`).get(targetEndMessageId, marker.summaryMessageId, marker.compactionPartId, marker.summaryPartId);
|
|
6669
|
+
}
|
|
6670
|
+
function withCompactionMarkerPublicationLock(operation) {
|
|
6671
|
+
return runMarkerWriteTransaction(getWritableOpenCodeDb(), "compaction-marker-replace", operation);
|
|
6672
|
+
}
|
|
6673
|
+
function inspectCompactionMarkerPublication(sessionId, recognized, summaryText) {
|
|
6674
|
+
const db = getWritableOpenCodeDb();
|
|
6675
|
+
const basis = readMarkerCandidateBasis2(db, sessionId);
|
|
6676
|
+
if (!basis)
|
|
6677
|
+
return { kind: "deferred" };
|
|
6678
|
+
const pairs = [];
|
|
6679
|
+
for (const id of basis.ids) {
|
|
6680
|
+
const rows = db.prepare(`SELECT m.id AS summaryId, p.message_id AS boundaryId, p.id AS partId
|
|
6681
|
+
FROM message m JOIN part p ON p.message_id = json_extract(m.data, '$.parentID')
|
|
6682
|
+
AND +p.session_id = m.session_id
|
|
6683
|
+
WHERE m.id = ? AND m.session_id = ? AND json_extract(m.data, '$.summary') = 1
|
|
6684
|
+
AND COALESCE(json_extract(m.data, '$.finish'), '') <> ''
|
|
6685
|
+
AND json_extract(p.data, '$.type') = 'compaction'`).all(id, sessionId);
|
|
6686
|
+
pairs.push(...rows);
|
|
6687
|
+
}
|
|
6688
|
+
if (pairs.length > 1)
|
|
6689
|
+
return { kind: "ambiguous" };
|
|
6690
|
+
if (pairs.length === 0) {
|
|
6691
|
+
for (const marker of recognized) {
|
|
6692
|
+
if (db.prepare(`SELECT 1 FROM message WHERE id = ?
|
|
6693
|
+
UNION ALL SELECT 1 FROM part WHERE id IN (?, ?) LIMIT 1`).get(marker.summaryMessageId, marker.compactionPartId, marker.summaryPartId))
|
|
6694
|
+
return { kind: "ambiguous" };
|
|
6695
|
+
}
|
|
6696
|
+
return { kind: "verified", marker: null };
|
|
6697
|
+
}
|
|
6698
|
+
const pair = pairs[0];
|
|
6699
|
+
const marker = recognized.find((item) => item.summaryMessageId === pair.summaryId && item.boundaryMessageId === pair.boundaryId && item.compactionPartId === pair.partId);
|
|
6700
|
+
if (!marker)
|
|
6701
|
+
return { kind: "ambiguous" };
|
|
6702
|
+
for (const other of recognized) {
|
|
6703
|
+
if (other.summaryMessageId === marker.summaryMessageId && other.compactionPartId === marker.compactionPartId && other.summaryPartId === marker.summaryPartId)
|
|
6704
|
+
continue;
|
|
6705
|
+
if (db.prepare(`SELECT 1 FROM message WHERE id = ?
|
|
6706
|
+
UNION ALL SELECT 1 FROM part WHERE id IN (?, ?) LIMIT 1`).get(other.summaryMessageId, other.compactionPartId, other.summaryPartId))
|
|
6707
|
+
return { kind: "ambiguous" };
|
|
6708
|
+
}
|
|
6709
|
+
const row = db.prepare(`SELECT c.data AS compactionData FROM message m
|
|
6710
|
+
JOIN message b ON b.id = ? AND b.session_id = m.session_id
|
|
6711
|
+
JOIN part c ON c.id = ? AND c.message_id = b.id AND c.session_id = m.session_id
|
|
6712
|
+
JOIN part t ON t.id = ? AND t.message_id = m.id AND t.session_id = m.session_id
|
|
6713
|
+
WHERE m.id = ? AND m.session_id = ?
|
|
6714
|
+
AND json_extract(b.data, '$.role') = 'user'
|
|
6715
|
+
AND json_extract(m.data, '$.role') = 'assistant'
|
|
6716
|
+
AND json_extract(m.data, '$.parentID') = b.id
|
|
6717
|
+
AND json_extract(m.data, '$.summary') = 1
|
|
6718
|
+
AND json_extract(m.data, '$.finish') = 'stop'
|
|
6719
|
+
AND json_extract(m.data, '$.error') IS NULL
|
|
6720
|
+
AND json_extract(m.data, '$.providerID') = 'magic-context'
|
|
6721
|
+
AND json_extract(m.data, '$.modelID') = 'magic-context'
|
|
6722
|
+
AND json_extract(t.data, '$.type') = 'text' AND json_extract(t.data, '$.text') = ?
|
|
6723
|
+
AND (SELECT COUNT(*) FROM part p WHERE p.message_id = m.id AND +p.session_id = m.session_id) = 1`).get(marker.boundaryMessageId, marker.compactionPartId, marker.summaryPartId, marker.summaryMessageId, sessionId, summaryText);
|
|
6724
|
+
if (!row || !isMcCanonicalCompactionPartData(JSON.parse(row.compactionData)) || findBoundaryUserMessage(sessionId, marker.boundaryMessageId)?.id !== marker.boundaryMessageId)
|
|
6725
|
+
return { kind: "ambiguous" };
|
|
6726
|
+
return { kind: "verified", marker };
|
|
6727
|
+
}
|
|
6614
6728
|
var LEGACY_MARKER_LINEAGE_SQL = `SELECT m.id
|
|
6615
6729
|
FROM message m
|
|
6616
6730
|
WHERE +m.session_id = ? AND m.id IN (SELECT value FROM json_each(?)) AND m.id <> ?
|
|
@@ -6660,10 +6774,11 @@ function injectCompactionMarkerFromBasis(args, validatedBasis) {
|
|
|
6660
6774
|
return null;
|
|
6661
6775
|
}
|
|
6662
6776
|
const boundaryTime = boundary.timeCreated;
|
|
6663
|
-
const
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6777
|
+
const {
|
|
6778
|
+
summaryMessageId: summaryMsgId,
|
|
6779
|
+
compactionPartId,
|
|
6780
|
+
summaryPartId
|
|
6781
|
+
} = planCompactionMarker(args, boundary);
|
|
6667
6782
|
const summaryMsgData = JSON.stringify({
|
|
6668
6783
|
role: "assistant",
|
|
6669
6784
|
parentID: boundary.id,
|
|
@@ -6823,10 +6938,12 @@ function listSessionCompactionMarkers(sessionId) {
|
|
|
6823
6938
|
markers.sort((left, right) => left.timeCreated - right.timeCreated || left.compactionPartId.localeCompare(right.compactionPartId));
|
|
6824
6939
|
return markers.map(({ timeCreated: _, ...marker }) => marker);
|
|
6825
6940
|
}
|
|
6826
|
-
function removeForeignCompactionMarker(sessionId, marker, protectedSummaryMessageId) {
|
|
6941
|
+
function removeForeignCompactionMarker(sessionId, marker, protectedSummaryMessageId, shouldRemove) {
|
|
6827
6942
|
try {
|
|
6828
6943
|
const db = getWritableOpenCodeDb("removal");
|
|
6829
6944
|
runMarkerRemovalTransaction(db, () => {
|
|
6945
|
+
if (shouldRemove && !shouldRemove())
|
|
6946
|
+
return;
|
|
6830
6947
|
const deletePartsOfMessage = db.prepare("DELETE FROM part WHERE +session_id = ? AND message_id = ?");
|
|
6831
6948
|
const deleteMessage = db.prepare("DELETE FROM message WHERE session_id = ? AND id = ?");
|
|
6832
6949
|
for (const summaryMessageId of marker.summaryMessageIds) {
|
|
@@ -7240,7 +7357,7 @@ function parseUserMemoryRow(row) {
|
|
|
7240
7357
|
}
|
|
7241
7358
|
// src/features/magic-context/dreamer/provider-output-failure.ts
|
|
7242
7359
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7243
|
-
import { createHash as
|
|
7360
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
7244
7361
|
var MAX_NEAR_ZERO_OUTPUT_TOKENS = 32;
|
|
7245
7362
|
|
|
7246
7363
|
class DreamerProviderOutputFailureError extends Error {
|
|
@@ -7337,12 +7454,12 @@ function providerOutputFailureFromInvalidManifest(messages, responseText, now =
|
|
|
7337
7454
|
const resetAt = quotaResetAt(responseText, now);
|
|
7338
7455
|
if (resetAt === undefined && completion.outputTokens > MAX_NEAR_ZERO_OUTPUT_TOKENS)
|
|
7339
7456
|
return null;
|
|
7340
|
-
const fingerprint =
|
|
7457
|
+
const fingerprint = createHash11("sha256").update(normalized).digest("hex").slice(0, 16);
|
|
7341
7458
|
return new DreamerProviderOutputFailureError(fingerprint, completion.outputTokens, completion.reasoningTokens, responseText, resetAt);
|
|
7342
7459
|
}
|
|
7343
7460
|
|
|
7344
7461
|
// src/v2/hooks/hidden-child.ts
|
|
7345
|
-
import { createHash as
|
|
7462
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
7346
7463
|
|
|
7347
7464
|
// src/agents/dreamer.ts
|
|
7348
7465
|
var DREAMER_AGENT = "dreamer";
|
|
@@ -7567,7 +7684,7 @@ function markerCandidates(text) {
|
|
|
7567
7684
|
function textDigest(text) {
|
|
7568
7685
|
return {
|
|
7569
7686
|
length: text.length,
|
|
7570
|
-
sha256:
|
|
7687
|
+
sha256: createHash12("sha256").update(text).digest("hex").slice(0, 16)
|
|
7571
7688
|
};
|
|
7572
7689
|
}
|
|
7573
7690
|
function firstDifference(a, b) {
|
|
@@ -9167,7 +9284,7 @@ async function promptAsyncAndWaitForIdle(client, request, options = {}) {
|
|
|
9167
9284
|
}
|
|
9168
9285
|
}
|
|
9169
9286
|
// src/shared/prompt-surface-runtime.ts
|
|
9170
|
-
import { createHash as
|
|
9287
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
9171
9288
|
import { existsSync as existsSync2, readFileSync as readFileSync5, statSync as statSync5 } from "node:fs";
|
|
9172
9289
|
import { dirname as dirname2, isAbsolute, resolve as resolve2 } from "node:path";
|
|
9173
9290
|
|
|
@@ -9200,7 +9317,7 @@ function promptSurfaceHashMaterial(systemContent, preset = "full") {
|
|
|
9200
9317
|
\x00magic-context-prompt-surface:${preset}`;
|
|
9201
9318
|
}
|
|
9202
9319
|
function systemPromptFingerprint(systemContent, preset = "full") {
|
|
9203
|
-
return
|
|
9320
|
+
return createHash13("md5").update(promptSurfaceHashMaterial(systemContent, preset)).digest("hex");
|
|
9204
9321
|
}
|
|
9205
9322
|
var PROMPT_SURFACE_TOOL_ID_SET = new Set(ACTIVE_TOOL_IDS);
|
|
9206
9323
|
function resolveUserConfigDirectory(options) {
|
|
@@ -9312,24 +9429,118 @@ function createPromptSurfaceGuidanceEpochCache(runtime) {
|
|
|
9312
9429
|
guidanceEpochCacheByRuntime.set(runtime, cache);
|
|
9313
9430
|
return cache;
|
|
9314
9431
|
}
|
|
9315
|
-
// src/hooks/magic-context/compaction-marker-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9320
|
-
|
|
9321
|
-
|
|
9322
|
-
|
|
9323
|
-
let
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9432
|
+
// src/hooks/magic-context/compaction-marker-publication.ts
|
|
9433
|
+
function samePair(left, right) {
|
|
9434
|
+
return left.boundaryMessageId === right.boundaryMessageId && left.summaryMessageId === right.summaryMessageId && left.compactionPartId === right.compactionPartId && left.summaryPartId === right.summaryPartId;
|
|
9435
|
+
}
|
|
9436
|
+
function publishRecoverableCompactionMarker(db, args, targetIsCurrent) {
|
|
9437
|
+
const { sessionId } = args;
|
|
9438
|
+
let raw = "";
|
|
9439
|
+
let previous = null;
|
|
9440
|
+
let oldSummary = null;
|
|
9441
|
+
let intended;
|
|
9442
|
+
let reason = "publication-failed";
|
|
9443
|
+
let recovered;
|
|
9444
|
+
let cut = "uncertain";
|
|
9445
|
+
let writingState = false;
|
|
9446
|
+
const persist = (state) => {
|
|
9447
|
+
writingState = true;
|
|
9448
|
+
db.transaction(() => {
|
|
9449
|
+
raw = compareAndSetCompactionMarkerPublicationState(db, sessionId, raw, state, null);
|
|
9450
|
+
if (previous && previous.summaryMessageId !== state.summaryMessageId) {
|
|
9451
|
+
const tag = getTagNumberByMessageId2(db, sessionId, `${previous.summaryMessageId}:p0`);
|
|
9452
|
+
if (tag !== null)
|
|
9453
|
+
updateTagStatus2(db, sessionId, tag, "dropped");
|
|
9454
|
+
}
|
|
9455
|
+
}).immediate();
|
|
9456
|
+
writingState = false;
|
|
9457
|
+
previous = state;
|
|
9458
|
+
};
|
|
9459
|
+
try {
|
|
9460
|
+
cut = getCompactionMarkerPublicationState(db, sessionId).pending ? "uncertain" : "definitely-no-cut";
|
|
9461
|
+
const result = withCompactionMarkerPublicationLock(() => {
|
|
9462
|
+
const snapshot = getCompactionMarkerPublicationState(db, sessionId);
|
|
9463
|
+
if (snapshot.pending)
|
|
9464
|
+
cut = "uncertain";
|
|
9465
|
+
raw = snapshot.raw;
|
|
9466
|
+
previous = getPersistedCompactionMarkerState(db, sessionId) ?? getDeferredClearedCompactionMarkerState(db, sessionId);
|
|
9467
|
+
oldSummary = previous?.summaryMessageId ?? null;
|
|
9468
|
+
if (snapshot.pending && (snapshot.pending.boundaryOrdinal > args.endOrdinal || snapshot.pending.boundaryOrdinal === args.endOrdinal && snapshot.pending.targetEndMessageId !== args.endMessageId) && !isCompactionMarkerIntentAbsent(snapshot.pending, snapshot.pending.targetEndMessageId))
|
|
9469
|
+
throw new Error("a newer marker publication intent is pending");
|
|
9470
|
+
const boundary = findBoundaryUserMessage(sessionId, args.endMessageId);
|
|
9471
|
+
if (!targetIsCurrent() || !boundary || boundary.id !== args.resolvedBoundary?.id || boundary.timeCreated !== args.resolvedBoundary.timeCreated)
|
|
9472
|
+
throw new Error("marker publication frontier changed before publication");
|
|
9473
|
+
intended = {
|
|
9474
|
+
...planCompactionMarker(args, boundary),
|
|
9475
|
+
boundaryOrdinal: args.endOrdinal,
|
|
9476
|
+
targetEndMessageId: args.endMessageId
|
|
9477
|
+
};
|
|
9478
|
+
let pending = snapshot.pending;
|
|
9479
|
+
if (pending) {
|
|
9480
|
+
const pendingTarget = pending.targetEndMessageId;
|
|
9481
|
+
const pendingBoundary = pendingTarget ? findBoundaryUserMessage(sessionId, pendingTarget) : null;
|
|
9482
|
+
const compartments = pendingTarget ? getCompartmentsByEndMessageId(db, sessionId, pendingTarget) : [];
|
|
9483
|
+
const validTarget = pending.targetEndMessageId === args.endMessageId && pending.boundaryOrdinal === args.endOrdinal || compartments.length === 1 && compartments[0].endMessage === pending.boundaryOrdinal;
|
|
9484
|
+
if (!validTarget || !pendingBoundary || !pendingTarget || !samePair(pending, planCompactionMarker({ ...args, endMessageId: pendingTarget }, pendingBoundary)))
|
|
9485
|
+
pending = null;
|
|
9486
|
+
}
|
|
9487
|
+
const inspection = inspectCompactionMarkerPublication(sessionId, [intended, ...previous ? [previous] : [], ...pending ? [pending] : []], args.summaryText);
|
|
9488
|
+
if (inspection.kind === "deferred") {
|
|
9489
|
+
reason = "candidate-preparation";
|
|
9490
|
+
return {
|
|
9491
|
+
kind: cut === "uncertain" ? "uncertain" : "deferred",
|
|
9492
|
+
error: new Error("marker candidate preparation pending")
|
|
9493
|
+
};
|
|
9494
|
+
}
|
|
9495
|
+
if (inspection.kind === "ambiguous") {
|
|
9496
|
+
reason = "ambiguous-left-alone";
|
|
9497
|
+
return {
|
|
9498
|
+
kind: cut,
|
|
9499
|
+
error: new Error("unverified or ambiguous host marker pairs; left alone")
|
|
9500
|
+
};
|
|
9501
|
+
}
|
|
9502
|
+
cut = "definitely-no-cut";
|
|
9503
|
+
const host = inspection.marker;
|
|
9504
|
+
if (host && (pending && samePair(host, pending) || samePair(host, intended))) {
|
|
9505
|
+
const adopted = pending && samePair(host, pending) ? pending : intended;
|
|
9506
|
+
recovered = adopted === pending ? "pending-intent-recovered" : "adopted-existing-pair";
|
|
9507
|
+
cut = "uncertain";
|
|
9508
|
+
if (samePair(host, intended))
|
|
9509
|
+
return { kind: "committed", marker: host };
|
|
9510
|
+
persist(adopted);
|
|
9511
|
+
}
|
|
9512
|
+
writingState = true;
|
|
9513
|
+
raw = compareAndSetCompactionMarkerPublicationState(db, sessionId, raw, previous, intended);
|
|
9514
|
+
writingState = false;
|
|
9515
|
+
cut = "uncertain";
|
|
9516
|
+
const replacement = replaceCompactionMarker(host, {
|
|
9517
|
+
...args,
|
|
9518
|
+
resolvedBoundary: boundary
|
|
9519
|
+
});
|
|
9520
|
+
if (recovered && replacement.kind !== "committed")
|
|
9521
|
+
return { kind: "uncertain", error: replacement.error };
|
|
9522
|
+
if (replacement.kind !== "committed")
|
|
9523
|
+
cut = replacement.kind === "uncertain" ? "uncertain" : "definitely-no-cut";
|
|
9524
|
+
return replacement;
|
|
9525
|
+
});
|
|
9526
|
+
if (result.kind === "committed") {
|
|
9527
|
+
if (!intended)
|
|
9528
|
+
throw new Error("committed marker has no publication intent");
|
|
9529
|
+
persist(intended);
|
|
9530
|
+
reason = recovered ?? "published";
|
|
9329
9531
|
}
|
|
9330
|
-
|
|
9331
|
-
|
|
9532
|
+
return result;
|
|
9533
|
+
} catch (error) {
|
|
9534
|
+
if (writingState)
|
|
9535
|
+
reason = "state-write-failed";
|
|
9536
|
+
return { kind: cut, error: error instanceof Error ? error : new Error(String(error)) };
|
|
9537
|
+
} finally {
|
|
9538
|
+
sessionLog2(sessionId, `compaction-marker publication reason=${reason} oldSummary=${oldSummary ?? "none"} newSummary=${intended?.summaryMessageId ?? "none"} target=${args.endMessageId} at=${Date.now()}`);
|
|
9539
|
+
}
|
|
9332
9540
|
}
|
|
9541
|
+
|
|
9542
|
+
// src/hooks/magic-context/compaction-marker-manager.ts
|
|
9543
|
+
var MARKER_SUMMARY_TEXT = "[Compacted by magic-context — session history is managed by the plugin]";
|
|
9333
9544
|
function markerUpdateDefinitelyDidNotCut(outcome) {
|
|
9334
9545
|
return outcome.kind === "already-current" || outcome.kind === "deferred" || outcome.kind === "stale-skip" || outcome.kind === "retryable-failure" && outcome.cut === "definitely-no-cut";
|
|
9335
9546
|
}
|
|
@@ -9398,7 +9609,7 @@ function boundaryWouldDiscardUncoveredMessage(db, sessionId, ordinal, boundaryMe
|
|
|
9398
9609
|
return false;
|
|
9399
9610
|
}
|
|
9400
9611
|
function applyDeferredCompactionMarker(db, sessionId, pending, directory, trustedBoundary) {
|
|
9401
|
-
let cut = "
|
|
9612
|
+
let cut = "uncertain";
|
|
9402
9613
|
let stepStartedAt = performance.now();
|
|
9403
9614
|
const stepMs = [];
|
|
9404
9615
|
const endStep = (name) => {
|
|
@@ -9407,41 +9618,61 @@ function applyDeferredCompactionMarker(db, sessionId, pending, directory, truste
|
|
|
9407
9618
|
stepStartedAt = now;
|
|
9408
9619
|
};
|
|
9409
9620
|
try {
|
|
9621
|
+
cut = getCompactionMarkerPublicationState(db, sessionId).pending ? "uncertain" : "definitely-no-cut";
|
|
9622
|
+
const unresolvedIntentFailure = () => {
|
|
9623
|
+
const alreadyUncertain = cut === "uncertain";
|
|
9624
|
+
cut = "uncertain";
|
|
9625
|
+
if (getCompactionMarkerPublicationState(db, sessionId).pending || alreadyUncertain) {
|
|
9626
|
+
return {
|
|
9627
|
+
kind: "retryable-failure",
|
|
9628
|
+
cut,
|
|
9629
|
+
error: new Error("unresolved marker publication intent; retaining retry state")
|
|
9630
|
+
};
|
|
9631
|
+
}
|
|
9632
|
+
cut = "definitely-no-cut";
|
|
9633
|
+
return null;
|
|
9634
|
+
};
|
|
9410
9635
|
const responseFencesTarget = trustedBoundary !== undefined && Number.isSafeInteger(trustedBoundary.rowVersion) && trustedBoundary.rowVersion > 0 && trustedBoundary.ordinal === pending.ordinal && trustedBoundary.endMessageId === pending.endMessageId;
|
|
9411
9636
|
const validation = responseFencesTarget ? "ok" : validatePendingTarget(db, sessionId, pending);
|
|
9412
9637
|
endStep("validate");
|
|
9413
9638
|
if (validation !== "ok") {
|
|
9639
|
+
const unresolved = unresolvedIntentFailure();
|
|
9640
|
+
if (unresolved)
|
|
9641
|
+
return unresolved;
|
|
9414
9642
|
sessionLog2(sessionId, `compaction-marker drain: stale-skip (${validation}) for ordinal ${pending.ordinal} endMessageId=${pending.endMessageId}`);
|
|
9415
9643
|
return { kind: "stale-skip", reason: validation };
|
|
9416
9644
|
}
|
|
9417
9645
|
const existing = getPersistedCompactionMarkerState(db, sessionId);
|
|
9418
9646
|
if (existing && existingMarkerAlreadyCoversTarget(sessionId, existing, pending.ordinal, pending.endMessageId)) {
|
|
9419
|
-
|
|
9647
|
+
if (!unresolvedIntentFailure())
|
|
9648
|
+
return { kind: "already-current" };
|
|
9420
9649
|
}
|
|
9421
9650
|
const boundary = findBoundaryUserMessage(sessionId, pending.endMessageId);
|
|
9422
9651
|
endStep("boundary");
|
|
9423
9652
|
if (!boundary) {
|
|
9424
|
-
return {
|
|
9653
|
+
return unresolvedIntentFailure() ?? {
|
|
9425
9654
|
kind: "retryable-failure",
|
|
9426
9655
|
cut: "definitely-no-cut",
|
|
9427
9656
|
error: new Error(`no user boundary found at or before endMessageId ${pending.endMessageId} (ordinal ${pending.ordinal}); preserving existing marker`)
|
|
9428
9657
|
};
|
|
9429
9658
|
}
|
|
9430
9659
|
if (boundaryWouldDiscardUncoveredMessage(db, sessionId, pending.ordinal, boundary.id)) {
|
|
9660
|
+
const unresolved = unresolvedIntentFailure();
|
|
9661
|
+
if (unresolved)
|
|
9662
|
+
return unresolved;
|
|
9431
9663
|
sessionLog2(sessionId, `compaction-marker drain: stale-skip (partial-message-boundary) for ordinal ${pending.ordinal} endMessageId=${pending.endMessageId}`);
|
|
9432
9664
|
return { kind: "stale-skip", reason: "partial-message-boundary" };
|
|
9433
9665
|
}
|
|
9434
9666
|
endStep("discardCheck");
|
|
9435
|
-
const removedSummaryMessageId = existing?.summaryMessageId ?? null;
|
|
9436
9667
|
cut = "uncertain";
|
|
9437
|
-
const replacement =
|
|
9668
|
+
const replacement = publishRecoverableCompactionMarker(db, {
|
|
9438
9669
|
sessionId,
|
|
9439
9670
|
endOrdinal: pending.ordinal,
|
|
9440
9671
|
endMessageId: pending.endMessageId,
|
|
9441
9672
|
summaryText: MARKER_SUMMARY_TEXT,
|
|
9442
9673
|
directory: directory ?? process.cwd(),
|
|
9443
9674
|
resolvedBoundary: boundary
|
|
9444
|
-
});
|
|
9675
|
+
}, () => JSON.stringify(getPersistedCompactionMarkerState(db, sessionId)) === JSON.stringify(existing) && (responseFencesTarget || validatePendingTarget(db, sessionId, pending) === "ok"));
|
|
9445
9676
|
endStep("replace");
|
|
9446
9677
|
if (replacement.kind === "deferred")
|
|
9447
9678
|
return { kind: "deferred", reason: "candidate-preparation" };
|
|
@@ -9452,14 +9683,8 @@ function applyDeferredCompactionMarker(db, sessionId, pending, directory, truste
|
|
|
9452
9683
|
error: replacement.error
|
|
9453
9684
|
};
|
|
9454
9685
|
}
|
|
9455
|
-
const result = replacement.marker;
|
|
9456
|
-
persistMarkerStateAndDropReplacedTag(db, sessionId, {
|
|
9457
|
-
...result,
|
|
9458
|
-
boundaryOrdinal: pending.ordinal,
|
|
9459
|
-
targetEndMessageId: pending.endMessageId
|
|
9460
|
-
}, removedSummaryMessageId);
|
|
9461
9686
|
endStep("persist");
|
|
9462
|
-
sessionLog2(sessionId, `compaction-marker drain: applied at ordinal ${pending.ordinal}, boundary user msg ${
|
|
9687
|
+
sessionLog2(sessionId, `compaction-marker drain: applied at ordinal ${pending.ordinal}, boundary user msg ${replacement.marker.boundaryMessageId} ${stepMs.join(" ")}`);
|
|
9463
9688
|
return {
|
|
9464
9689
|
kind: "applied",
|
|
9465
9690
|
markerOrdinal: pending.ordinal
|
|
@@ -9480,8 +9705,7 @@ function updateCompactionMarkerAfterPublication(db, sessionId, lastCompartmentEn
|
|
|
9480
9705
|
return false;
|
|
9481
9706
|
}
|
|
9482
9707
|
const existing = getPersistedCompactionMarkerState(db, sessionId);
|
|
9483
|
-
|
|
9484
|
-
if (existing) {
|
|
9708
|
+
if (existing && !getCompactionMarkerPublicationState(db, sessionId).pending) {
|
|
9485
9709
|
if (existingMarkerAlreadyCoversTarget(sessionId, existing, lastCompartmentEnd, targetEndMessageId)) {
|
|
9486
9710
|
return true;
|
|
9487
9711
|
}
|
|
@@ -9494,33 +9718,26 @@ function updateCompactionMarkerAfterPublication(db, sessionId, lastCompartmentEn
|
|
|
9494
9718
|
if (boundaryWouldDiscardUncoveredMessage(db, sessionId, lastCompartmentEnd, boundary.id)) {
|
|
9495
9719
|
return false;
|
|
9496
9720
|
}
|
|
9497
|
-
const replacement =
|
|
9721
|
+
const replacement = publishRecoverableCompactionMarker(db, {
|
|
9498
9722
|
sessionId,
|
|
9499
9723
|
endOrdinal: lastCompartmentEnd,
|
|
9500
9724
|
endMessageId: targetEndMessageId,
|
|
9501
9725
|
summaryText: MARKER_SUMMARY_TEXT,
|
|
9502
9726
|
directory: directory ?? process.cwd(),
|
|
9503
9727
|
resolvedBoundary: boundary
|
|
9504
|
-
});
|
|
9728
|
+
}, () => JSON.stringify(getPersistedCompactionMarkerState(db, sessionId)) === JSON.stringify(existing) && getCompartmentEndMessageIdForOrdinal(db, sessionId, lastCompartmentEnd) === targetEndMessageId);
|
|
9505
9729
|
if (replacement.kind === "committed") {
|
|
9506
|
-
const result = replacement.marker;
|
|
9507
|
-
persistMarkerStateAndDropReplacedTag(db, sessionId, {
|
|
9508
|
-
...result,
|
|
9509
|
-
boundaryOrdinal: lastCompartmentEnd,
|
|
9510
|
-
targetEndMessageId
|
|
9511
|
-
}, removedSummaryMessageId);
|
|
9512
|
-
sessionLog2(sessionId, `compaction-marker: injected at ordinal ${lastCompartmentEnd}, boundary user msg ${result.boundaryMessageId}`);
|
|
9513
9730
|
return true;
|
|
9514
9731
|
}
|
|
9515
9732
|
return false;
|
|
9516
9733
|
}
|
|
9517
|
-
function reconcileForkOrphanedCompactionMarkers(db, sessionId) {
|
|
9518
|
-
if (getHarness2() !== "opencode") {
|
|
9734
|
+
function reconcileForkOrphanedCompactionMarkers(db, sessionId, isCacheBusting) {
|
|
9735
|
+
if (!isCacheBusting || getHarness2() !== "opencode") {
|
|
9519
9736
|
return { removed: 0, failed: false };
|
|
9520
9737
|
}
|
|
9521
9738
|
try {
|
|
9522
9739
|
const owned = getPersistedCompactionMarkerState(db, sessionId);
|
|
9523
|
-
if (!owned) {
|
|
9740
|
+
if (!owned || getCompactionMarkerPublicationState(db, sessionId).pending) {
|
|
9524
9741
|
return { removed: 0, failed: false };
|
|
9525
9742
|
}
|
|
9526
9743
|
const markers = listSessionCompactionMarkers(sessionId);
|
|
@@ -9541,7 +9758,15 @@ function reconcileForkOrphanedCompactionMarkers(db, sessionId) {
|
|
|
9541
9758
|
if (!currentOwned || marker.compactionPartId === currentOwned.compactionPartId) {
|
|
9542
9759
|
continue;
|
|
9543
9760
|
}
|
|
9544
|
-
|
|
9761
|
+
let protectedByState = false;
|
|
9762
|
+
const ok = removeForeignCompactionMarker(sessionId, marker, currentOwned.summaryMessageId, () => db.transaction(() => {
|
|
9763
|
+
const publication = getCompactionMarkerPublicationState(db, sessionId);
|
|
9764
|
+
const latestOwned = getPersistedCompactionMarkerState(db, sessionId);
|
|
9765
|
+
protectedByState = Boolean(publication.pending || !latestOwned || marker.compactionPartId === latestOwned.compactionPartId || marker.summaryMessageIds.includes(latestOwned.summaryMessageId) || compareOpenCodeMessagesByCanonicalOrder(sessionId, marker.boundaryMessageId, latestOwned.boundaryMessageId) !== 1);
|
|
9766
|
+
return !protectedByState;
|
|
9767
|
+
}).deferred());
|
|
9768
|
+
if (protectedByState)
|
|
9769
|
+
continue;
|
|
9545
9770
|
if (ok) {
|
|
9546
9771
|
removed += 1;
|
|
9547
9772
|
sessionLog2(sessionId, `compaction-marker hygiene: removed fork-orphaned marker part=${marker.compactionPartId} boundary=${marker.boundaryMessageId} (outranked owned boundary ${currentOwned.boundaryMessageId})`);
|
|
@@ -11098,7 +11323,7 @@ function compareMemorySelectionPriority(left, right) {
|
|
|
11098
11323
|
}
|
|
11099
11324
|
|
|
11100
11325
|
// src/features/magic-context/mural/render-trigger.ts
|
|
11101
|
-
import { createHash as
|
|
11326
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
11102
11327
|
|
|
11103
11328
|
// src/features/magic-context/mural/mural-selection.ts
|
|
11104
11329
|
var DEFAULT_MURAL_MEMORY_BUDGET = 8000;
|
|
@@ -11802,7 +12027,7 @@ function ensureMuralRendered(db, projectIdentity, budgetTokens = DEFAULT_MURAL_M
|
|
|
11802
12027
|
return { ...cached.result };
|
|
11803
12028
|
}
|
|
11804
12029
|
const plan = planMuralRender(entries);
|
|
11805
|
-
const textHash =
|
|
12030
|
+
const textHash = createHash14("sha256").update(plan.layout.text).digest("hex");
|
|
11806
12031
|
if (existing && existing.contentHash === textHash && existing.width === plan.width && existing.height === plan.height) {
|
|
11807
12032
|
return rememberRender(db, projectIdentity, key, existing.image, {
|
|
11808
12033
|
hasMural: true,
|
|
@@ -11867,6 +12092,7 @@ var MURAL_COMPONENT_PREFIX = "|mural-enabled:";
|
|
|
11867
12092
|
var BUDGET_COMPONENT_PREFIX = "|render-budgets:";
|
|
11868
12093
|
var RENDERED_BUDGETS_COMPONENT_PREFIX = "|rendered-budgets:";
|
|
11869
12094
|
var M0_MEMORY_IDS_COMPONENT_PREFIX = "|m0-memory-ids:";
|
|
12095
|
+
var TOOL_DEFINITIONS_COMPONENT_PREFIX = "|request-tool-definitions:";
|
|
11870
12096
|
function encodeCachedM0UpgradeIdentity(upgradeState, compartmentRenderEpoch = COMPARTMENT_RENDER_EPOCH, muralEnabled = null, renderBudgetIdentity = null, memoryRenderEpoch = MEMORY_RENDER_FORMAT_EPOCH, renderedBudgets = null) {
|
|
11871
12097
|
let encoded = upgradeState ?? "";
|
|
11872
12098
|
if (compartmentRenderEpoch !== null) {
|
|
@@ -11912,7 +12138,8 @@ function decodeCachedM0UpgradeIdentity(value) {
|
|
|
11912
12138
|
value.indexOf(MURAL_COMPONENT_PREFIX),
|
|
11913
12139
|
value.indexOf(BUDGET_COMPONENT_PREFIX),
|
|
11914
12140
|
value.indexOf(RENDERED_BUDGETS_COMPONENT_PREFIX),
|
|
11915
|
-
value.indexOf(M0_MEMORY_IDS_COMPONENT_PREFIX)
|
|
12141
|
+
value.indexOf(M0_MEMORY_IDS_COMPONENT_PREFIX),
|
|
12142
|
+
value.indexOf(TOOL_DEFINITIONS_COMPONENT_PREFIX)
|
|
11916
12143
|
].filter((index) => index >= 0);
|
|
11917
12144
|
const identityEnd = componentIndexes.length > 0 ? Math.min(...componentIndexes) : value.length;
|
|
11918
12145
|
const upgradeState = value.slice(0, identityEnd);
|
|
@@ -11930,6 +12157,22 @@ function withCachedM0MemoryIds(identity, ids) {
|
|
|
11930
12157
|
const withoutIds = (identity ?? "").replace(/\|m0-memory-ids:[^|]*/g, "");
|
|
11931
12158
|
return `${withoutIds}${M0_MEMORY_IDS_COMPONENT_PREFIX}${JSON.stringify(ids)}`;
|
|
11932
12159
|
}
|
|
12160
|
+
function withCachedM0ToolDefinitionsHash(identity, hash) {
|
|
12161
|
+
const withoutHash = (identity ?? "").replace(/\|request-tool-definitions:[^|]*/g, "");
|
|
12162
|
+
if (hash === null)
|
|
12163
|
+
return withoutHash || null;
|
|
12164
|
+
return `${withoutHash}${TOOL_DEFINITIONS_COMPONENT_PREFIX}${encodeURIComponent(hash)}`;
|
|
12165
|
+
}
|
|
12166
|
+
function readCachedM0ToolDefinitionsHash(identity) {
|
|
12167
|
+
const encoded = component(identity ?? "", TOOL_DEFINITIONS_COMPONENT_PREFIX);
|
|
12168
|
+
if (!encoded)
|
|
12169
|
+
return null;
|
|
12170
|
+
try {
|
|
12171
|
+
return decodeURIComponent(encoded) || null;
|
|
12172
|
+
} catch {
|
|
12173
|
+
return null;
|
|
12174
|
+
}
|
|
12175
|
+
}
|
|
11933
12176
|
function readCachedM0MemoryIds(identity, legacyVisibleIds, maxMemoryId) {
|
|
11934
12177
|
const encoded = component(identity ?? "", M0_MEMORY_IDS_COMPONENT_PREFIX);
|
|
11935
12178
|
if (encoded !== null) {
|
|
@@ -12623,8 +12866,8 @@ function prepareCompartmentInjection(db, sessionId, messages, isCacheBusting, co
|
|
|
12623
12866
|
resultEndMessageId = trimEndMessageId;
|
|
12624
12867
|
} else {
|
|
12625
12868
|
const degradedCount = noteDegradedRebuild(sessionId);
|
|
12626
|
-
if (
|
|
12627
|
-
reconcileForkOrphanedCompactionMarkers(db, sessionId);
|
|
12869
|
+
if (isCacheBusting) {
|
|
12870
|
+
reconcileForkOrphanedCompactionMarkers(db, sessionId, isCacheBusting);
|
|
12628
12871
|
}
|
|
12629
12872
|
let reAnchored = false;
|
|
12630
12873
|
if (degradedCount >= REANCHOR_MIN_DEGRADED_PASSES && isCacheBusting) {
|
|
@@ -13026,6 +13269,7 @@ function readCurrentM0SnapshotMarkersUncached(args) {
|
|
|
13026
13269
|
memoryRenderEpoch: MEMORY_RENDER_FORMAT_EPOCH,
|
|
13027
13270
|
systemHash: hard.systemHash,
|
|
13028
13271
|
toolSetHash: hard.toolSetHash ?? "",
|
|
13272
|
+
toolDefinitionsHash: hard.toolDefinitionsHash ?? null,
|
|
13029
13273
|
modelKey: piModelRefToCanonical(hard.modelKey),
|
|
13030
13274
|
projectIdentity: args.projectPath ?? null,
|
|
13031
13275
|
muralEnabled: args.memoryEnabled !== false && args.muralEnabled === true,
|
|
@@ -13041,6 +13285,7 @@ function refreshVolatileMarkerInputs(markers, args) {
|
|
|
13041
13285
|
materializedAt: Date.now(),
|
|
13042
13286
|
systemHash: hard.systemHash,
|
|
13043
13287
|
toolSetHash: hard.toolSetHash ?? "",
|
|
13288
|
+
toolDefinitionsHash: hard.toolDefinitionsHash ?? null,
|
|
13044
13289
|
modelKey: hard.modelKey,
|
|
13045
13290
|
projectIdentity: args.projectPath ?? null,
|
|
13046
13291
|
muralEnabled: args.memoryEnabled !== false && args.muralEnabled === true,
|
|
@@ -13111,6 +13356,7 @@ function snapshotMarkersFromCachedM0(state) {
|
|
|
13111
13356
|
memoryRenderEpoch: cachedUpgradeIdentity.memoryRenderEpoch,
|
|
13112
13357
|
systemHash: state.cachedM0SystemHash ?? "",
|
|
13113
13358
|
toolSetHash: state.cachedM0ToolSetHash ?? "",
|
|
13359
|
+
toolDefinitionsHash: readCachedM0ToolDefinitionsHash(state.cachedM0UpgradeState),
|
|
13114
13360
|
modelKey: state.cachedM0ModelKey ?? "",
|
|
13115
13361
|
projectIdentity: state.cachedM0ProjectIdentity ?? null,
|
|
13116
13362
|
muralHash: state.cachedM0MuralHash ?? null,
|
|
@@ -13171,6 +13417,23 @@ function mustMaterialize(args) {
|
|
|
13171
13417
|
systemHashNew: hard.systemHash
|
|
13172
13418
|
};
|
|
13173
13419
|
}
|
|
13420
|
+
const liveDefinitionsHash = hard.toolDefinitionsHash;
|
|
13421
|
+
if (liveDefinitionsHash) {
|
|
13422
|
+
const cachedDefinitionsHash = readCachedM0ToolDefinitionsHash(args.state.cachedM0UpgradeState);
|
|
13423
|
+
if (!cachedDefinitionsHash || needsRequestToolIdentityAdoption(cachedDefinitionsHash, liveDefinitionsHash)) {
|
|
13424
|
+
const previousIdentity = args.state.cachedM0UpgradeState;
|
|
13425
|
+
const adoptedIdentity = withCachedM0ToolDefinitionsHash(previousIdentity, liveDefinitionsHash);
|
|
13426
|
+
const adopted = args.db.prepare("UPDATE session_meta SET cached_m0_upgrade_state = ? WHERE session_id = ? AND cached_m0_upgrade_state IS ?").run(adoptedIdentity, args.sessionId, previousIdentity);
|
|
13427
|
+
if (adopted.changes > 0)
|
|
13428
|
+
args.state.cachedM0UpgradeState = adoptedIdentity;
|
|
13429
|
+
} else if (cachedDefinitionsHash !== liveDefinitionsHash) {
|
|
13430
|
+
return {
|
|
13431
|
+
value: true,
|
|
13432
|
+
reason: "tool_definitions",
|
|
13433
|
+
toolDefinitionsChange: describeRequestToolDefinitionChange(cachedDefinitionsHash, liveDefinitionsHash)
|
|
13434
|
+
};
|
|
13435
|
+
}
|
|
13436
|
+
}
|
|
13174
13437
|
const liveToolSetHash = hard.toolSetHash ?? "";
|
|
13175
13438
|
const toolSetHashComparison = liveToolSetHash !== "" ? {
|
|
13176
13439
|
m0ToolSetHashPrev: args.state.cachedM0ToolSetHash,
|
|
@@ -13504,7 +13767,7 @@ function applyMarkersToState(state, m0Bytes, markers, m1Bytes, renderedM0Ids) {
|
|
|
13504
13767
|
state.cachedM0ProjectDocsHash = markers.projectDocsHash;
|
|
13505
13768
|
state.cachedM0MaterializedAt = markers.materializedAt;
|
|
13506
13769
|
state.cachedM0SessionFactsVersion = markers.sessionFactsVersion;
|
|
13507
|
-
state.cachedM0UpgradeState = withCachedM0MemoryIds(encodeCachedM0UpgradeIdentity(markers.upgradeState, markers.compartmentRenderEpoch, markers.muralEnabled, markers.renderBudgetIdentity, markers.memoryRenderEpoch, markers.renderedBudgets ?? null), renderedM0Ids);
|
|
13770
|
+
state.cachedM0UpgradeState = withCachedM0ToolDefinitionsHash(withCachedM0MemoryIds(encodeCachedM0UpgradeIdentity(markers.upgradeState, markers.compartmentRenderEpoch, markers.muralEnabled, markers.renderBudgetIdentity, markers.memoryRenderEpoch, markers.renderedBudgets ?? null), renderedM0Ids), markers.toolDefinitionsHash ?? null);
|
|
13508
13771
|
state.cachedM0SystemHash = markers.systemHash;
|
|
13509
13772
|
state.cachedM0ToolSetHash = markers.toolSetHash;
|
|
13510
13773
|
state.cachedM0ModelKey = markers.modelKey;
|
|
@@ -13629,7 +13892,7 @@ function materializeM0(options) {
|
|
|
13629
13892
|
const renderedMemoryIds = trimmed.renderOrder.map((m) => m.id);
|
|
13630
13893
|
options.beforePhase3ForTest?.();
|
|
13631
13894
|
const steps = new WriteTransactionSteps;
|
|
13632
|
-
const upgradeIdentity = withCachedM0MemoryIds(encodeCachedM0UpgradeIdentity(snapshotMarkers.upgradeState, snapshotMarkers.compartmentRenderEpoch, snapshotMarkers.muralEnabled, snapshotMarkers.renderBudgetIdentity, snapshotMarkers.memoryRenderEpoch, snapshotMarkers.renderedBudgets ?? null), renderedMemoryIds);
|
|
13895
|
+
const upgradeIdentity = withCachedM0ToolDefinitionsHash(withCachedM0MemoryIds(encodeCachedM0UpgradeIdentity(snapshotMarkers.upgradeState, snapshotMarkers.compartmentRenderEpoch, snapshotMarkers.muralEnabled, snapshotMarkers.renderBudgetIdentity, snapshotMarkers.memoryRenderEpoch, snapshotMarkers.renderedBudgets ?? null), renderedMemoryIds), snapshotMarkers.toolDefinitionsHash ?? null);
|
|
13633
13896
|
const baselineEndMessageId = lastCompartmentBoundaryId(compartments);
|
|
13634
13897
|
steps.mark("pre_metadata");
|
|
13635
13898
|
const commitFold = options.onFoldPrepare?.();
|
|
@@ -13662,6 +13925,7 @@ function materializeM0(options) {
|
|
|
13662
13925
|
memoryRenderEpoch: MEMORY_RENDER_FORMAT_EPOCH,
|
|
13663
13926
|
systemHash: snapshotMarkers.systemHash,
|
|
13664
13927
|
toolSetHash: snapshotMarkers.toolSetHash,
|
|
13928
|
+
toolDefinitionsHash: snapshotMarkers.toolDefinitionsHash,
|
|
13665
13929
|
modelKey: snapshotMarkers.modelKey,
|
|
13666
13930
|
projectIdentity: projectPath ?? null,
|
|
13667
13931
|
muralEnabled: snapshotMarkers.muralEnabled,
|
|
@@ -13919,7 +14183,7 @@ function readCachedM0M1Row(db, sessionId) {
|
|
|
13919
14183
|
cached_m0_session_facts_version,
|
|
13920
14184
|
cached_m0_upgrade_state,
|
|
13921
14185
|
cached_m0_system_hash,
|
|
13922
|
-
|
|
14186
|
+
cached_m0_tool_set_hash,
|
|
13923
14187
|
cached_m0_model_key,
|
|
13924
14188
|
cached_m0_project_identity,
|
|
13925
14189
|
cached_m0_last_baseline_end_message_id,
|
|
@@ -13961,6 +14225,7 @@ function markersFromCachedRow(row) {
|
|
|
13961
14225
|
memoryRenderEpoch: cachedUpgradeIdentity.memoryRenderEpoch,
|
|
13962
14226
|
systemHash: row.cached_m0_system_hash ?? "",
|
|
13963
14227
|
toolSetHash: row.cached_m0_tool_set_hash ?? "",
|
|
14228
|
+
toolDefinitionsHash: readCachedM0ToolDefinitionsHash(row.cached_m0_upgrade_state),
|
|
13964
14229
|
modelKey: row.cached_m0_model_key ?? "",
|
|
13965
14230
|
projectIdentity: row.cached_m0_project_identity ?? null,
|
|
13966
14231
|
muralHash: row.cached_m0_mural_hash ?? null,
|
|
@@ -13991,7 +14256,7 @@ function applyCachedRowToState(state, row) {
|
|
|
13991
14256
|
state.cachedM0ProjectDocsHash = markers.projectDocsHash;
|
|
13992
14257
|
state.cachedM0MaterializedAt = markers.materializedAt;
|
|
13993
14258
|
state.cachedM0SessionFactsVersion = markers.sessionFactsVersion;
|
|
13994
|
-
state.cachedM0UpgradeState = encodeCachedM0UpgradeIdentity(markers.upgradeState, markers.compartmentRenderEpoch, markers.muralEnabled, markers.renderBudgetIdentity, markers.memoryRenderEpoch, markers.renderedBudgets ?? null);
|
|
14259
|
+
state.cachedM0UpgradeState = withCachedM0ToolDefinitionsHash(encodeCachedM0UpgradeIdentity(markers.upgradeState, markers.compartmentRenderEpoch, markers.muralEnabled, markers.renderBudgetIdentity, markers.memoryRenderEpoch, markers.renderedBudgets ?? null), markers.toolDefinitionsHash ?? null);
|
|
13995
14260
|
state.cachedM0SystemHash = markers.systemHash;
|
|
13996
14261
|
state.cachedM0ToolSetHash = markers.toolSetHash;
|
|
13997
14262
|
state.cachedM0ModelKey = markers.modelKey;
|
|
@@ -20575,4 +20840,4 @@ ${failure}`;
|
|
|
20575
20840
|
}
|
|
20576
20841
|
}
|
|
20577
20842
|
|
|
20578
|
-
export { historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, LkgRecoveryFenceError, lkgServedArrayDigest, hasCleanLkgRecoveryFence, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, advanceSessionActivity, backfillSessionActivity, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, readPersistedLkgUntaggedInputIds, persistLkgUntaggedInputIds, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, lkgInputIdentity, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, queueMemoryMutation, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, readCoordinateGeneration, rebaseSessionCoordinatesAsync, HiddenCompletionRefusal, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, prepareCompactionMarkerCandidates, removeMcOwnedCompactionMarkers, getCompartmentEvents, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, DreamerProviderOutputFailureError, withDreamerModelCooldown, providerOutputFailureFromInvalidManifest, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, HIDDEN_HISTORIAN_AGENT, HIDDEN_DREAMER_AGENT, HIDDEN_CURATE_AGENT, hiddenAgentFor, hiddenToolLoop, HIDDEN_RUN_DISPOSED_REASON, noteChildOfDisposedInstance, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, ModelProducedNoOutputError, noteModelActivityMonitored, noteModelOutputReceived, isPromptTimeoutError, getPromptFailureDetail, raceWithSignal, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, annotateSubagentInvocationError, failedInvocationStatus, emptyTokenTotals, sumTokensFromChildMessages, recordChildInvocation, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, teardownChildSession, runTokenLog, formatRunTokenLog, createChildSessionWithFence, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, extractM0Block, formatDate, TEMPORAL_MARKER_REPLAY_PATTERN, collectTemporalCandidates, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, MaterializeContentionError, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, materializeM0, hydrateCachedM0Mural, resetPrefixTrimFallbackState, findHostCompactionWindow, capturePrefixTrimSourceOrder, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, shouldWaitForNewHistorianHistory, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, omitIncompleteFileTokenTotals, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, noteTransformPassForExactOrdinalReads, runCompartmentAgent, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, isRecompFailure2, isRecompSkip2, extractRecompReason2, setRecompStarting2, setRecompNote2, setRecompTerminal2, buildRecompDeps2, runManagedRecomp2 };
|
|
20843
|
+
export { historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, v2ToolDefinitionsHash, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, LkgRecoveryFenceError, lkgServedArrayDigest, hasCleanLkgRecoveryFence, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, advanceSessionActivity, backfillSessionActivity, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, readPersistedLkgUntaggedInputIds, persistLkgUntaggedInputIds, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, lkgInputIdentity, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, queueMemoryMutation, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, readCoordinateGeneration, rebaseSessionCoordinatesAsync, HiddenCompletionRefusal, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, prepareCompactionMarkerCandidates, removeMcOwnedCompactionMarkers, getCompartmentEvents, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, DreamerProviderOutputFailureError, withDreamerModelCooldown, providerOutputFailureFromInvalidManifest, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, HIDDEN_HISTORIAN_AGENT, HIDDEN_DREAMER_AGENT, HIDDEN_CURATE_AGENT, hiddenAgentFor, hiddenToolLoop, HIDDEN_RUN_DISPOSED_REASON, noteChildOfDisposedInstance, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, ModelProducedNoOutputError, noteModelActivityMonitored, noteModelOutputReceived, isPromptTimeoutError, getPromptFailureDetail, raceWithSignal, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, annotateSubagentInvocationError, failedInvocationStatus, emptyTokenTotals, sumTokensFromChildMessages, recordChildInvocation, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, teardownChildSession, runTokenLog, formatRunTokenLog, createChildSessionWithFence, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, extractM0Block, formatDate, TEMPORAL_MARKER_REPLAY_PATTERN, collectTemporalCandidates, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, MaterializeContentionError, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, materializeM0, hydrateCachedM0Mural, resetPrefixTrimFallbackState, findHostCompactionWindow, capturePrefixTrimSourceOrder, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, shouldWaitForNewHistorianHistory, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, omitIncompleteFileTokenTotals, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, noteTransformPassForExactOrdinalReads, runCompartmentAgent, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, isRecompFailure2, isRecompSkip2, extractRecompReason2, setRecompStarting2, setRecompNote2, setRecompTerminal2, buildRecompDeps2, runManagedRecomp2 };
|