@cortexkit/opencode-magic-context 0.49.14 → 0.49.16
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 +3 -3
- package/dist/chunk-embedding-write-worker.js +5 -3
- package/dist/config/schema/magic-context.d.ts +65 -65
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-mgq17yr3.js → conflict-warning-hook-znry4j76.js} +5 -5
- package/dist/{context-cpxqpkzv.js → context-3znk23va.js} +128 -24
- package/dist/{embedding-backfill-5e1t5wha.js → embedding-backfill-q4n8dend.js} +8 -6
- package/dist/embedding-worker.js +2 -2
- package/dist/features/magic-context/dreamer/verify.d.ts +22 -3
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/message-fts-rowid-map.d.ts +2 -2
- package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -1
- package/dist/features/magic-context/message-fts-session-filter.d.ts +2 -0
- package/dist/features/magic-context/message-fts-session-filter.d.ts.map +1 -1
- package/dist/features/magic-context/message-time-backfill.d.ts +2 -2
- package/dist/features/magic-context/message-time-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -2
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +2 -2
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts +2 -1
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-prompt.generated.d.ts +1 -1
- package/dist/hooks/magic-context/historian-prompt.generated.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +26 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +3 -3
- package/dist/hooks/magic-context/recomp-orchestrator.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.map +1 -1
- package/dist/{index-xn6q9pg6.js → index-4qfy7v57.js} +11 -62
- package/dist/{index-e4dsjj1p.js → index-5mwk1nek.js} +1 -1
- package/dist/index-6a6dq53h.js +96 -0
- package/dist/{index-e20m7284.js → index-7b2cfmaz.js} +1 -1
- package/dist/{index-mmfa86mt.js → index-7pa32z07.js} +169 -149
- package/dist/{index-3kdm78zp.js → index-9nkg2dzk.js} +3 -3
- package/dist/{index-t4q9zbbf.js → index-ayym1x7f.js} +119 -30
- package/dist/{index-dgs16axy.js → index-b17m64g9.js} +1 -1
- package/dist/{index-yxycg7fs.js → index-cj9g0j7a.js} +22 -14
- package/dist/{index-dyvbsvga.js → index-dqe8pq4x.js} +21 -10
- package/dist/{index-5591fg8y.js → index-ek1yxvvz.js} +44 -77
- package/dist/{index-3kx0kg0f.js → index-hehkf6zm.js} +3 -3
- package/dist/{index-944w16m0.js → index-j6zw70pf.js} +4 -4
- package/dist/index-kaqs6h31.js +58 -0
- package/dist/{index-w900fbhd.js → index-kn4t1haw.js} +15 -12
- package/dist/{index-1d289pq2.js → index-mtw9e71a.js} +1 -1
- package/dist/{index-mht7bq0z.js → index-nd7m2a5a.js} +7 -5
- package/dist/{index-thvnpfsv.js → index-p4vde22c.js} +14 -14
- package/dist/{index-y1qysm3q.js → index-qrahzcqv.js} +3 -3
- package/dist/{index-kf4epshg.js → index-v63beg1z.js} +3 -3
- package/dist/{index-tyckte5c.js → index-v9asb16b.js} +4 -4
- package/dist/{index-1sarmj9z.js → index-wgypt3cs.js} +6 -6
- package/dist/{index-bxdg2nbt.js → index-wv9n2zcq.js} +1 -1
- package/dist/index.js +38 -36
- package/dist/message-fts-rowid-map-yvx5a9jw.js +23 -0
- package/dist/{message-index-bounded-vtgpq6b4.js → message-index-bounded-6th8djy9.js} +8 -8
- package/dist/{message-index-a6gztaqx.js → message-index-t4pz7akd.js} +9 -9
- package/dist/{message-time-backfill-qjge9044.js → message-time-backfill-8egzkd3z.js} +4 -4
- package/dist/migration-worker.js +4 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/{project-embedding-registry-x45bv3qr.js → project-embedding-registry-2dea0a77.js} +7 -5
- package/dist/raw-ordinal-warmup-worker.js +37 -7
- package/dist/{read-session-chunk-3ae3nfdn.js → read-session-chunk-4pwqxm5a.js} +6 -6
- package/dist/{read-session-raw-m56hc7v2.js → read-session-raw-5ar8se5v.js} +1 -1
- package/dist/{recomp-orchestrator-xqb9gwgm.js → recomp-orchestrator-tjcaj5x7.js} +17 -17
- package/dist/search-archive-02jws7hw.js +25 -0
- package/dist/{search-deajrd90.js → search-rb01n29x.js} +15 -14
- package/dist/{send-session-notification-24r4esbh.js → send-session-notification-2x9edkrp.js} +4 -4
- package/dist/shared/model-suggestion-retry.d.ts +2 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/resolve-fallbacks.d.ts +3 -3
- package/dist/{storage-tags-s5bg1ahx.js → storage-tags-4z1w27xa.js} +1 -1
- package/dist/tools/ctx-expand/search-archive.d.ts +5 -1
- package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-k5t63qm5.js → transform-postprocess-phase-xaw5c3xp.js} +17 -17
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/chunk-embedding-write-worker.js +8 -6
- package/dist/v2/{context-k4jrq71s.js → context-acw1nhv8.js} +164 -91
- package/dist/v2/{embedding-backfill-jmaf8zrr.js → embedding-backfill-jyd6492b.js} +10 -8
- package/dist/v2/embedding-worker.js +2 -2
- package/dist/v2/hidden-completion.d.ts +20 -1
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +19 -0
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/message-fts-rowid-map-8vf0v7cr.js +22 -0
- package/dist/v2/{message-index-bounded-rxxznd34.js → message-index-bounded-dsrf49y7.js} +7 -7
- package/dist/v2/{message-index-f947qtbz.js → message-index-e6qzw477.js} +8 -8
- package/dist/v2/{message-time-backfill-bsteyc4d.js → message-time-backfill-q5pgxf0d.js} +4 -4
- package/dist/v2/migration-worker.js +6 -4
- package/dist/v2/{project-embedding-registry-0msp56p8.js → project-embedding-registry-rek75aqw.js} +9 -7
- package/dist/v2/raw-ordinal-warmup-worker.js +37 -7
- package/dist/v2/{read-session-chunk-rq9nx1nn.js → read-session-chunk-7bpygfv2.js} +5 -5
- package/dist/v2/{read-session-raw-b3tf6ra1.js → read-session-raw-pw2n1qgc.js} +1 -1
- package/dist/v2/{recomp-orchestrator-1j1nqrrr.js → recomp-orchestrator-hzpgg06e.js} +18 -18
- package/dist/v2/search-archive-fn4wy8sx.js +24 -0
- package/dist/v2/{search-n8wqxb1j.js → search-sf2vg5pk.js} +17 -16
- package/dist/v2/{send-session-notification-8ghn9tnv.js → send-session-notification-hmr7q0nt.js} +2 -2
- package/dist/v2/{server-k2bzedxk.js → server-00hx04yn.js} +1 -1
- package/dist/v2/{server-atbc19ab.js → server-0mzjjw3s.js} +7 -5
- package/dist/v2/{server-ehyava47.js → server-1hcbw661.js} +3 -3
- package/dist/v2/{server-th4y11y7.js → server-271qxsf5.js} +6 -6
- package/dist/v2/{server-prg55b7k.js → server-6714jebr.js} +22 -2
- package/dist/v2/{server-fnqxt9j6.js → server-6fyp0v67.js} +120 -31
- package/dist/v2/{server-yrvqaswb.js → server-785mb90s.js} +21 -10
- package/dist/v2/{server-ef89gdsx.js → server-aavz8pm6.js} +3 -3
- package/dist/v2/{server-gvkm8xaj.js → server-e3ftpk7v.js} +1 -1
- package/dist/v2/{server-e298hswg.js → server-g59aatsz.js} +14 -14
- package/dist/v2/{server-g10mdym6.js → server-gha9x4qq.js} +1 -1
- package/dist/v2/{server-4gn3z5an.js → server-hgg55hde.js} +1 -1
- package/dist/v2/server-kaqs6h31.js +58 -0
- package/dist/v2/{server-qhfvvfxj.js → server-kqpawe1a.js} +3 -3
- package/dist/v2/{server-hek6z3w6.js → server-kr2kc9dz.js} +5 -5
- package/dist/v2/{server-cfbr1s2x.js → server-n5q841qn.js} +12 -63
- package/dist/v2/{server-kmbarfmn.js → server-r9gjxcte.js} +24 -16
- package/dist/v2/{server-6cdy4rc0.js → server-vgpab6rd.js} +2 -2
- package/dist/v2/{server-zc3e54vy.js → server-y5pznjt9.js} +1 -1
- package/dist/v2/server-zyw55ygv.js +96 -0
- package/dist/v2/server.js +4 -4
- package/dist/v2/{storage-tags-hcc2adpf.js → storage-tags-hkwtbp3g.js} +1 -1
- package/dist/v2/store-reader.d.ts +27 -1
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{wrapup-orchestrator-hkv8apcc.js → wrapup-orchestrator-x4xj1782.js} +18 -18
- package/dist/{wrapup-orchestrator-kxqj4rwh.js → wrapup-orchestrator-vj2tbp22.js} +18 -18
- package/package.json +1 -1
- package/src/config/schema/magic-context.ts +14 -6
- package/src/shared/model-resolution.test.ts +22 -0
- package/src/shared/model-suggestion-retry.ts +9 -3
- package/src/shared/resolve-fallbacks.test.ts +2 -3
- package/src/shared/resolve-fallbacks.ts +3 -3
|
@@ -1153,6 +1153,7 @@ function ensureExitHook() {
|
|
|
1153
1153
|
function runSessionWarmupWorker(input, options) {
|
|
1154
1154
|
ensureExitHook();
|
|
1155
1155
|
return new Promise((resolve) => {
|
|
1156
|
+
const openCancellation = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
1156
1157
|
let worker;
|
|
1157
1158
|
let deadline;
|
|
1158
1159
|
let settled = false;
|
|
@@ -1160,7 +1161,9 @@ function runSessionWarmupWorker(input, options) {
|
|
|
1160
1161
|
if (settled)
|
|
1161
1162
|
return;
|
|
1162
1163
|
settled = true;
|
|
1164
|
+
Atomics.store(openCancellation, 0, 1);
|
|
1163
1165
|
clearTimeout(deadline);
|
|
1166
|
+
options.signal?.removeEventListener("abort", abort);
|
|
1164
1167
|
if (worker) {
|
|
1165
1168
|
activeWorkers.delete(worker);
|
|
1166
1169
|
const stopped = worker.terminate();
|
|
@@ -1179,8 +1182,16 @@ function runSessionWarmupWorker(input, options) {
|
|
|
1179
1182
|
deadline = setTimeout(() => finish({ failure, detail: `no reply within ${ms} ms` }), ms);
|
|
1180
1183
|
deadline.unref?.();
|
|
1181
1184
|
};
|
|
1185
|
+
const abort = () => finish({ failure: "stopped", detail: "stopped" });
|
|
1186
|
+
if (options.signal?.aborted) {
|
|
1187
|
+
abort();
|
|
1188
|
+
return;
|
|
1189
|
+
}
|
|
1190
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
1182
1191
|
try {
|
|
1183
|
-
worker = inRootAsyncContext2(() => new Worker(options.entry ?? defaultEntry(), {
|
|
1192
|
+
worker = inRootAsyncContext2(() => new Worker(options.entry ?? defaultEntry(), {
|
|
1193
|
+
workerData: { ...input, openCancellation: openCancellation.buffer }
|
|
1194
|
+
}));
|
|
1184
1195
|
} catch (error) {
|
|
1185
1196
|
finish({ failure: "start-failed", detail: String(error) });
|
|
1186
1197
|
return;
|
|
@@ -1203,8 +1214,17 @@ function runSessionWarmupWorker(input, options) {
|
|
|
1203
1214
|
finish({ orphanSweep: reply.result });
|
|
1204
1215
|
else if (reply.kind === "exact-ordinal-ids")
|
|
1205
1216
|
finish({ exactOrdinalIds: reply.ids });
|
|
1217
|
+
else if (reply.kind === "search-archive")
|
|
1218
|
+
finish({ searchArchive: reply.text });
|
|
1219
|
+
else if (reply.kind === "fts-rowid-backfill")
|
|
1220
|
+
finish({ ftsRowidBackfill: true });
|
|
1206
1221
|
else
|
|
1207
|
-
finish({
|
|
1222
|
+
finish({
|
|
1223
|
+
failure: "worker-error",
|
|
1224
|
+
detail: reply.error,
|
|
1225
|
+
code: reply.code,
|
|
1226
|
+
errcode: reply.errcode
|
|
1227
|
+
});
|
|
1208
1228
|
});
|
|
1209
1229
|
worker.on("error", (error) => finish({ failure: "worker-error", detail: String(error) }));
|
|
1210
1230
|
worker.on("exit", (code) => finish({ failure: "exited", detail: `exit code ${code}` }));
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
cortexKitProjectConfigBasePath,
|
|
18
18
|
resolveLegacyConfigSourcesForHarness,
|
|
19
19
|
loadPluginConfigDetailed
|
|
20
|
-
} from "./server-
|
|
20
|
+
} from "./server-y5pznjt9.js";
|
|
21
21
|
import {
|
|
22
22
|
catalogOutputReserve,
|
|
23
23
|
getSdkContextLimit,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
resolvePromptSurface,
|
|
31
31
|
DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
32
32
|
LIVE_RELOAD_CONFIG_PATHS
|
|
33
|
-
} from "./server-
|
|
33
|
+
} from "./server-271qxsf5.js";
|
|
34
34
|
import {
|
|
35
35
|
invalidateAutoEmbedSession,
|
|
36
36
|
drainBackgroundBatches,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
getProjectChunkEmbeddingModelId2,
|
|
40
40
|
getProjectEmbeddingMaxInputTokens2,
|
|
41
41
|
embedItemsForProject2
|
|
42
|
-
} from "./server-
|
|
42
|
+
} from "./server-kr2kc9dz.js";
|
|
43
43
|
import {
|
|
44
44
|
hasMeaningfulUserText2,
|
|
45
45
|
estimateTokens,
|
|
@@ -53,6 +53,12 @@ import {
|
|
|
53
53
|
withoutSqliteTransformPass2,
|
|
54
54
|
beginSqliteWriterAsync2
|
|
55
55
|
} from "./server-wafzvyhg.js";
|
|
56
|
+
import {
|
|
57
|
+
isStrictGapHealingMessage2,
|
|
58
|
+
noteRawSessionSummaryRowWritten2,
|
|
59
|
+
RawOrdinalsNotReady2,
|
|
60
|
+
runSessionWarmupWorker
|
|
61
|
+
} from "./server-6714jebr.js";
|
|
56
62
|
import {
|
|
57
63
|
buildCanonicalChunkTextFromFts,
|
|
58
64
|
buildCompartmentSummaryFallbackText,
|
|
@@ -62,7 +68,7 @@ import {
|
|
|
62
68
|
replaceCompartmentChunkEmbeddings,
|
|
63
69
|
deleteChunkEmbedBackoffForSession,
|
|
64
70
|
chunkWindowSourceKey
|
|
65
|
-
} from "./server-
|
|
71
|
+
} from "./server-kqpawe1a.js";
|
|
66
72
|
import {
|
|
67
73
|
isPidAlive
|
|
68
74
|
} from "./server-da07v4xp.js";
|
|
@@ -80,7 +86,7 @@ import {
|
|
|
80
86
|
toMessageIndexSource2,
|
|
81
87
|
clearIndexedMessagesInTransaction2,
|
|
82
88
|
indexSourcesAfterOrdinal2
|
|
83
|
-
} from "./server-
|
|
89
|
+
} from "./server-g59aatsz.js";
|
|
84
90
|
import {
|
|
85
91
|
detectOverflow,
|
|
86
92
|
SESSION_META_SELECT_COLUMNS,
|
|
@@ -173,7 +179,7 @@ import {
|
|
|
173
179
|
getRawSessionTagKeysThrough2,
|
|
174
180
|
getLegacyProtectedTailStartOrdinal2,
|
|
175
181
|
readSessionChunk2
|
|
176
|
-
} from "./server-
|
|
182
|
+
} from "./server-1hcbw661.js";
|
|
177
183
|
import {
|
|
178
184
|
getTableColumnNames
|
|
179
185
|
} from "./server-pwv4ezb0.js";
|
|
@@ -183,7 +189,7 @@ import {
|
|
|
183
189
|
LATEST_SUPPORTED_VERSION,
|
|
184
190
|
getPersistedSchemaVersion,
|
|
185
191
|
openDatabase
|
|
186
|
-
} from "./server-
|
|
192
|
+
} from "./server-r9gjxcte.js";
|
|
187
193
|
import {
|
|
188
194
|
providerMass,
|
|
189
195
|
calibrationForModelKey,
|
|
@@ -201,13 +207,7 @@ import {
|
|
|
201
207
|
foldShrunkPartTags2,
|
|
202
208
|
getTagNumberByMessageId2,
|
|
203
209
|
getActiveTagsBySession2
|
|
204
|
-
} from "./server-
|
|
205
|
-
import {
|
|
206
|
-
isStrictGapHealingMessage2,
|
|
207
|
-
noteRawSessionSummaryRowWritten2,
|
|
208
|
-
RawOrdinalsNotReady2,
|
|
209
|
-
runSessionWarmupWorker
|
|
210
|
-
} from "./server-prg55b7k.js";
|
|
210
|
+
} from "./server-0mzjjw3s.js";
|
|
211
211
|
import {
|
|
212
212
|
resolveOpenCodeDbPath,
|
|
213
213
|
assertOpenCodeStoreGeneration,
|
|
@@ -237,11 +237,11 @@ import {
|
|
|
237
237
|
resolveStoredPathWorkspaceIdentity,
|
|
238
238
|
sourceNameForMemory,
|
|
239
239
|
computeWorkspaceEpochFingerprint
|
|
240
|
-
} from "./server-
|
|
240
|
+
} from "./server-00hx04yn.js";
|
|
241
241
|
import {
|
|
242
242
|
shouldSkipHomeProjectMemory,
|
|
243
243
|
resolveProjectIdentity
|
|
244
|
-
} from "./server-
|
|
244
|
+
} from "./server-e3ftpk7v.js";
|
|
245
245
|
import {
|
|
246
246
|
getSessionNotes,
|
|
247
247
|
getReadySmartNotes,
|
|
@@ -250,7 +250,7 @@ import {
|
|
|
250
250
|
userFacingFailureCode,
|
|
251
251
|
promoteSessionFactsDurable,
|
|
252
252
|
embedPromotedFacts
|
|
253
|
-
} from "./server-
|
|
253
|
+
} from "./server-vgpab6rd.js";
|
|
254
254
|
import {
|
|
255
255
|
isMarkerCandidateBasisCurrent2,
|
|
256
256
|
invalidateMarkerCandidateBasis2,
|
|
@@ -1220,6 +1220,9 @@ class V2StoreReaderPool {
|
|
|
1220
1220
|
capacity;
|
|
1221
1221
|
connections = new Map;
|
|
1222
1222
|
closed = false;
|
|
1223
|
+
closing = false;
|
|
1224
|
+
holds = 0;
|
|
1225
|
+
idleWaiters = new Set;
|
|
1223
1226
|
constructor(capacity = 4) {
|
|
1224
1227
|
this.capacity = capacity;
|
|
1225
1228
|
if (!Number.isSafeInteger(capacity) || capacity < 1)
|
|
@@ -1264,13 +1267,63 @@ class V2StoreReaderPool {
|
|
|
1264
1267
|
if (connection.leases === 0)
|
|
1265
1268
|
closeConnection(connection);
|
|
1266
1269
|
}
|
|
1270
|
+
hold() {
|
|
1271
|
+
if (this.closed || this.closing)
|
|
1272
|
+
throw new Error("Store reader pool is closed");
|
|
1273
|
+
this.holds++;
|
|
1274
|
+
let released = false;
|
|
1275
|
+
return () => {
|
|
1276
|
+
if (released)
|
|
1277
|
+
return;
|
|
1278
|
+
released = true;
|
|
1279
|
+
this.holds--;
|
|
1280
|
+
if (this.holds === 0 && this.closing)
|
|
1281
|
+
this.finishClose();
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
isClosed() {
|
|
1285
|
+
return this.closed;
|
|
1286
|
+
}
|
|
1287
|
+
holdCount() {
|
|
1288
|
+
return this.holds;
|
|
1289
|
+
}
|
|
1267
1290
|
close() {
|
|
1291
|
+
if (this.closed || this.closing)
|
|
1292
|
+
return;
|
|
1293
|
+
this.closing = true;
|
|
1294
|
+
if (this.holds === 0)
|
|
1295
|
+
this.finishClose();
|
|
1296
|
+
}
|
|
1297
|
+
async closeWhenIdle(timeoutMs) {
|
|
1298
|
+
this.close();
|
|
1299
|
+
if (this.closed)
|
|
1300
|
+
return true;
|
|
1301
|
+
let timer;
|
|
1302
|
+
let waiter;
|
|
1303
|
+
try {
|
|
1304
|
+
await new Promise((resolve) => {
|
|
1305
|
+
waiter = resolve;
|
|
1306
|
+
this.idleWaiters.add(resolve);
|
|
1307
|
+
timer = setTimeout(resolve, Math.max(0, timeoutMs));
|
|
1308
|
+
});
|
|
1309
|
+
} finally {
|
|
1310
|
+
if (timer)
|
|
1311
|
+
clearTimeout(timer);
|
|
1312
|
+
if (waiter)
|
|
1313
|
+
this.idleWaiters.delete(waiter);
|
|
1314
|
+
}
|
|
1315
|
+
return this.closed;
|
|
1316
|
+
}
|
|
1317
|
+
finishClose() {
|
|
1268
1318
|
if (this.closed)
|
|
1269
1319
|
return;
|
|
1270
1320
|
this.closed = true;
|
|
1271
1321
|
for (const connection of this.connections.values())
|
|
1272
1322
|
this.retire(connection);
|
|
1273
1323
|
this.connections.clear();
|
|
1324
|
+
for (const resolve of this.idleWaiters)
|
|
1325
|
+
resolve();
|
|
1326
|
+
this.idleWaiters.clear();
|
|
1274
1327
|
}
|
|
1275
1328
|
}
|
|
1276
1329
|
|
|
@@ -6557,6 +6610,28 @@ function hiddenToolLoop(identity) {
|
|
|
6557
6610
|
function hiddenAgentAllowedTools(agent) {
|
|
6558
6611
|
return agent !== undefined && Object.hasOwn(AGENT_TOOLS, agent) ? AGENT_TOOLS[agent] : undefined;
|
|
6559
6612
|
}
|
|
6613
|
+
var HIDDEN_RUN_DISPOSED_REASON = "the Magic Context plugin instance that started this hidden run was disposed (OpenCode reloaded the plugin), so the run was cancelled; the work is retried on a later run";
|
|
6614
|
+
var DISPOSED_CHILDREN_KEY = Symbol.for("@cortexkit/magic-context/v2/disposed-hidden-children");
|
|
6615
|
+
var DISPOSED_CHILDREN_LIMIT = 512;
|
|
6616
|
+
function disposedChildren() {
|
|
6617
|
+
const store = globalThis;
|
|
6618
|
+
store[DISPOSED_CHILDREN_KEY] ??= new Set;
|
|
6619
|
+
return store[DISPOSED_CHILDREN_KEY];
|
|
6620
|
+
}
|
|
6621
|
+
function noteChildOfDisposedInstance(sessionID) {
|
|
6622
|
+
const children = disposedChildren();
|
|
6623
|
+
children.delete(sessionID);
|
|
6624
|
+
children.add(sessionID);
|
|
6625
|
+
while (children.size > DISPOSED_CHILDREN_LIMIT) {
|
|
6626
|
+
const oldest = children.values().next().value;
|
|
6627
|
+
if (oldest === undefined)
|
|
6628
|
+
break;
|
|
6629
|
+
children.delete(oldest);
|
|
6630
|
+
}
|
|
6631
|
+
}
|
|
6632
|
+
function isChildOfDisposedInstance(sessionID) {
|
|
6633
|
+
return disposedChildren().has(sessionID);
|
|
6634
|
+
}
|
|
6560
6635
|
function hiddenChildPermissions(agent, providerID) {
|
|
6561
6636
|
const tools = AGENT_TOOLS[agent] ?? [];
|
|
6562
6637
|
const visible = tools.length === 0 && needsBlockedRead(agent, providerID) ? ["read"] : tools;
|
|
@@ -6588,6 +6663,8 @@ async function registerHiddenChildAgents(agent) {
|
|
|
6588
6663
|
}
|
|
6589
6664
|
function hiddenToolCallRefusal(call, hook) {
|
|
6590
6665
|
const owned = hook.owns(call.sessionID);
|
|
6666
|
+
if (!owned && isChildOfDisposedInstance(call.sessionID))
|
|
6667
|
+
return `Magic Context hidden child ${call.sessionID} refused: ${HIDDEN_RUN_DISPOSED_REASON}; ${call.tool} refused`;
|
|
6591
6668
|
const agent = owned ? hook.agentFor(call.sessionID) ?? call.agent : call.agent;
|
|
6592
6669
|
const allowed = hiddenAgentAllowedTools(agent);
|
|
6593
6670
|
if (allowed === undefined) {
|
|
@@ -6717,6 +6794,9 @@ class HiddenChildHook {
|
|
|
6717
6794
|
}
|
|
6718
6795
|
compactionSummary(sessionID, agent) {
|
|
6719
6796
|
if (!this.owns(sessionID)) {
|
|
6797
|
+
if (isChildOfDisposedInstance(sessionID)) {
|
|
6798
|
+
this.refuse(`Refusing to compact a Magic Context hidden child of a disposed plugin instance: ${HIDDEN_RUN_DISPOSED_REASON}`, { sessionID, messages: [] }, undefined, undefined, "hidden_instance_disposed");
|
|
6799
|
+
}
|
|
6720
6800
|
if (hiddenAgentAllowedTools(agent) !== undefined) {
|
|
6721
6801
|
this.refuse("Refusing to compact a Magic Context hidden-agent session this instance did not register", { sessionID, messages: [] }, undefined);
|
|
6722
6802
|
}
|
|
@@ -6731,7 +6811,7 @@ class HiddenChildHook {
|
|
|
6731
6811
|
}
|
|
6732
6812
|
return marker;
|
|
6733
6813
|
}
|
|
6734
|
-
refuse(reason, draft, raw, inFlight) {
|
|
6814
|
+
refuse(reason, draft, raw, inFlight, code = "hidden_prompt_unrecognized") {
|
|
6735
6815
|
const registered = [...this.attempts.values()].filter((attempt) => attempt.childSessionId === draft.sessionID && attempt.marker).map((attempt) => {
|
|
6736
6816
|
const marker = attempt.marker;
|
|
6737
6817
|
return {
|
|
@@ -6752,7 +6832,7 @@ class HiddenChildHook {
|
|
|
6752
6832
|
active: this.active.has(draft.sessionID),
|
|
6753
6833
|
...inFlight === undefined ? {} : { in_flight: inFlight }
|
|
6754
6834
|
})}`);
|
|
6755
|
-
const refusal = new HiddenCompletionRefusal(
|
|
6835
|
+
const refusal = new HiddenCompletionRefusal(code, reason, true);
|
|
6756
6836
|
for (const attempt of this.attempts.values()) {
|
|
6757
6837
|
if (attempt.childSessionId === draft.sessionID)
|
|
6758
6838
|
attempt.refusal = refusal;
|
|
@@ -6767,6 +6847,9 @@ class HiddenChildHook {
|
|
|
6767
6847
|
}
|
|
6768
6848
|
apply(draft) {
|
|
6769
6849
|
if (!this.owns(draft.sessionID)) {
|
|
6850
|
+
if (isChildOfDisposedInstance(draft.sessionID)) {
|
|
6851
|
+
this.refuse(`Refusing a turn of a Magic Context hidden child of a disposed plugin instance: ${HIDDEN_RUN_DISPOSED_REASON}`, draft, newestUserText(draft), undefined, "hidden_instance_disposed");
|
|
6852
|
+
}
|
|
6770
6853
|
if (hiddenAgentAllowedTools(draft.agent) !== undefined) {
|
|
6771
6854
|
this.refuse("Refusing a Magic Context hidden-agent turn this instance did not register", draft, newestUserText(draft));
|
|
6772
6855
|
}
|
|
@@ -7179,14 +7262,14 @@ function throwWithPromptFailure(legacyError, failedAttempts, args, timeoutMs, tr
|
|
|
7179
7262
|
});
|
|
7180
7263
|
throw error;
|
|
7181
7264
|
}
|
|
7182
|
-
async function attemptOnce(client, args, timeoutMs, signal, callContext, label, transport) {
|
|
7265
|
+
async function attemptOnce(client, args, timeoutMs, signal, callContext, label, transport, allowModelSuggestions = true) {
|
|
7183
7266
|
const originalBody = { ...args.body };
|
|
7184
7267
|
const attemptArgs = copyPromptArgs(args, originalBody);
|
|
7185
7268
|
try {
|
|
7186
7269
|
await promptWithTimeout(client, attemptArgs, timeoutMs, signal, transport);
|
|
7187
7270
|
return;
|
|
7188
7271
|
} catch (error) {
|
|
7189
|
-
if (isNonRetryable(error, signal))
|
|
7272
|
+
if (isNonRetryable(error, signal) || !allowModelSuggestions)
|
|
7190
7273
|
throw error;
|
|
7191
7274
|
const suggestion = parseModelSuggestion(error);
|
|
7192
7275
|
if (!suggestion || !originalBody.model) {
|
|
@@ -7214,7 +7297,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
|
7214
7297
|
const explicitPrimaryLabel = baseBody.model?.providerID && baseBody.model.modelID ? `${baseBody.model.providerID}/${baseBody.model.modelID}` : "primary";
|
|
7215
7298
|
let lastError = null;
|
|
7216
7299
|
try {
|
|
7217
|
-
await attemptOnce(client, baseArgs, timeoutMs, options.signal, callContext, explicitPrimaryLabel, options.transport);
|
|
7300
|
+
await attemptOnce(client, baseArgs, timeoutMs, options.signal, callContext, explicitPrimaryLabel, options.transport, options.allowModelSuggestions);
|
|
7218
7301
|
return;
|
|
7219
7302
|
} catch (error) {
|
|
7220
7303
|
lastError = error;
|
|
@@ -7240,7 +7323,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
|
7240
7323
|
...fallback?.qualifier ? { variant: fallback.qualifier } : {}
|
|
7241
7324
|
});
|
|
7242
7325
|
try {
|
|
7243
|
-
await attemptOnce(client, attemptArgs, timeoutMs, options.signal, callContext, label, options.transport);
|
|
7326
|
+
await attemptOnce(client, attemptArgs, timeoutMs, options.signal, callContext, label, options.transport, options.allowModelSuggestions);
|
|
7244
7327
|
log2(`[${callContext}] fallback succeeded with ${label} (attempt ${i + 2}/${fallbacks.length + 1})`);
|
|
7245
7328
|
return;
|
|
7246
7329
|
} catch (error) {
|
|
@@ -7258,7 +7341,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
|
7258
7341
|
}
|
|
7259
7342
|
async function attemptAndValidate(client, args, timeoutMs, signal, callContext, attempt, options) {
|
|
7260
7343
|
try {
|
|
7261
|
-
await attemptOnce(client, args, timeoutMs, signal, callContext, attempt.label, options.transport);
|
|
7344
|
+
await attemptOnce(client, args, timeoutMs, signal, callContext, attempt.label, options.transport, options.allowModelSuggestions);
|
|
7262
7345
|
} catch (error) {
|
|
7263
7346
|
throw {
|
|
7264
7347
|
error,
|
|
@@ -8455,6 +8538,7 @@ Examples:
|
|
|
8455
8538
|
- Every displayed raw message ordinal MUST appear in exactly one compartment. Gaps between compartments are invalid. When a displayed block is pure tool-only noise with no narrative text, do NOT skip it — extend the preceding compartment's \`end\` to absorb the range, or fold it into the current compartment if it's part of an ongoing work unit. Never create a dedicated compartment just to cover a tool-only run.
|
|
8456
8539
|
- If a chunk is entirely tool-only with no narrative text (a long autonomous coding stretch), produce a single compartment whose narrative is derived from what the tools collectively accomplished.
|
|
8457
8540
|
- If the chunk ends mid-topic, leave the unfinished portion out and report its first message index in \`<unprocessed_from>\`.
|
|
8541
|
+
- If every message in the chunk is covered by a compartment, nothing is unprocessed: set \`<unprocessed_from>\` to the chunk's last message index + 1. Never write \`0\` or the last covered index in that case.
|
|
8458
8542
|
|
|
8459
8543
|
---
|
|
8460
8544
|
|
|
@@ -9582,6 +9666,7 @@ function buildHistorianRepairPrompt(originalPrompt, previousOutput, validationEr
|
|
|
9582
9666
|
"Return a corrected full XML response for the same existing state and new messages.",
|
|
9583
9667
|
"Do not skip any displayed raw ordinal or displayed raw range, even if the message looks trivial.",
|
|
9584
9668
|
"Every displayed message range must belong to exactly one compartment unless it is intentionally left in one trailing suffix marked by <unprocessed_from>.",
|
|
9669
|
+
"If every message in the chunk is covered by a compartment, nothing is unprocessed: set `<unprocessed_from>` to the chunk's last message index + 1.",
|
|
9585
9670
|
"",
|
|
9586
9671
|
"Previous invalid XML:",
|
|
9587
9672
|
previousOutput
|
|
@@ -9633,16 +9718,19 @@ function validateParsedCompartments(compartments, chunkStart, chunkEnd, unproces
|
|
|
9633
9718
|
expectedStart = compartment.endMessage + 1;
|
|
9634
9719
|
}
|
|
9635
9720
|
if (unprocessedFrom !== null) {
|
|
9721
|
+
if (expectedStart <= chunkEnd) {
|
|
9722
|
+
if (unprocessedFrom !== expectedStart) {
|
|
9723
|
+
return `<unprocessed_from> ${unprocessedFrom} does not match next uncovered message ${expectedStart}`;
|
|
9724
|
+
}
|
|
9725
|
+
return null;
|
|
9726
|
+
}
|
|
9636
9727
|
if (unprocessedFrom === chunkEnd + 1) {
|
|
9637
9728
|
return null;
|
|
9638
9729
|
}
|
|
9639
9730
|
if (unprocessedFrom < chunkStart || unprocessedFrom > chunkEnd) {
|
|
9640
9731
|
return `<unprocessed_from> ${unprocessedFrom} is outside chunk ${chunkStart}-${chunkEnd}`;
|
|
9641
9732
|
}
|
|
9642
|
-
|
|
9643
|
-
return `<unprocessed_from> ${unprocessedFrom} does not match next uncovered message ${expectedStart}`;
|
|
9644
|
-
}
|
|
9645
|
-
return null;
|
|
9733
|
+
return `<unprocessed_from> ${unprocessedFrom} does not match completed chunk boundary ${chunkEnd + 1}`;
|
|
9646
9734
|
}
|
|
9647
9735
|
if (expectedStart <= chunkEnd) {
|
|
9648
9736
|
return `output left uncovered messages ${expectedStart}-${chunkEnd} without <unprocessed_from>`;
|
|
@@ -15895,6 +15983,7 @@ async function runHistorianPrompt(args) {
|
|
|
15895
15983
|
return executor.attempt(opened, request);
|
|
15896
15984
|
}, { childSessionId: opened.childSessionId }),
|
|
15897
15985
|
timeoutMs: timeoutMs ?? DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
15986
|
+
allowModelSuggestions: false,
|
|
15898
15987
|
fallbackModels: modelOverride ? undefined : fallbackModels,
|
|
15899
15988
|
callContext: agentId === HISTORIAN_EDITOR_AGENT ? "historian:editor" : "historian"
|
|
15900
15989
|
});
|
|
@@ -15979,7 +16068,7 @@ async function runFallbackHistorianPass(args) {
|
|
|
15979
16068
|
const primary = toModelEntry(args.model);
|
|
15980
16069
|
for (const candidateInput of [
|
|
15981
16070
|
...args.fallbackModels ?? [],
|
|
15982
|
-
|
|
16071
|
+
...!primary && args.fallbackModelId ? [{ model: args.fallbackModelId }] : []
|
|
15983
16072
|
]) {
|
|
15984
16073
|
const candidate = toModelEntry(candidateInput);
|
|
15985
16074
|
if (!candidate)
|
|
@@ -17561,7 +17650,7 @@ async function runCompartmentAgent(deps) {
|
|
|
17561
17650
|
const projectPath = resolveProjectIdentity(directory ?? process.cwd());
|
|
17562
17651
|
const fallbackWindows = [
|
|
17563
17652
|
...(deps.fallbackModels ?? []).map((entry) => toModelEntry(entry)?.model),
|
|
17564
|
-
deps.fallbackModelId
|
|
17653
|
+
...toModelEntry(deps.model) ? [] : [deps.fallbackModelId]
|
|
17565
17654
|
].filter((key) => typeof key === "string" && key !== producerModel).map((key) => resolveHistorianProducerWindow(key, deps.historianMaxOutputTokens));
|
|
17566
17655
|
const promptFit = fitHistorianPrompt({
|
|
17567
17656
|
window: producerWindow,
|
|
@@ -19123,4 +19212,4 @@ ${failure}`;
|
|
|
19123
19212
|
}
|
|
19124
19213
|
}
|
|
19125
19214
|
|
|
19126
|
-
export { historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, 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, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, 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, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, isPromptTimeoutError, getPromptFailureDetail, raceWithSignal, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, failedInvocationStatus, 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, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, 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 };
|
|
19215
|
+
export { historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, 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, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, 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, isPromptTimeoutError, getPromptFailureDetail, raceWithSignal, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, failedInvocationStatus, 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, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, 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 };
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getSqliteDatabasePath2,
|
|
2
3
|
withSqliteBackgroundWriter2,
|
|
3
4
|
withoutSqliteTransformPass2
|
|
4
5
|
} from "./server-wafzvyhg.js";
|
|
6
|
+
import {
|
|
7
|
+
runSessionWarmupWorker
|
|
8
|
+
} from "./server-6714jebr.js";
|
|
5
9
|
import {
|
|
6
10
|
logSlowWriteTransaction
|
|
7
11
|
} from "./server-6pmqg9m4.js";
|
|
@@ -41,7 +45,7 @@ function getBackfillState(db) {
|
|
|
41
45
|
completed: row?.completed === 1
|
|
42
46
|
};
|
|
43
47
|
}
|
|
44
|
-
function
|
|
48
|
+
function recordMessageFtsRowid2(db, sessionId, messageOrdinal, ftsRowid, messageTimeMs = null) {
|
|
45
49
|
const numericRowid = Number(ftsRowid);
|
|
46
50
|
if (!Number.isSafeInteger(numericRowid) || numericRowid <= 0) {
|
|
47
51
|
throw new Error(`invalid message FTS rowid: ${String(ftsRowid)}`);
|
|
@@ -49,7 +53,7 @@ function recordMessageFtsRowid(db, sessionId, messageOrdinal, ftsRowid, messageT
|
|
|
49
53
|
const normalizedTime = typeof messageTimeMs === "number" && Number.isSafeInteger(messageTimeMs) && messageTimeMs >= 0 ? messageTimeMs : null;
|
|
50
54
|
getUpsertMapStatement(db).run(sessionId, messageOrdinal, numericRowid, normalizedTime);
|
|
51
55
|
}
|
|
52
|
-
function
|
|
56
|
+
function recordIndexedMessageTime2(db, sessionId, messageOrdinal, messageTimeMs) {
|
|
53
57
|
if (typeof messageTimeMs !== "number" || !Number.isSafeInteger(messageTimeMs) || messageTimeMs < 0) {
|
|
54
58
|
return;
|
|
55
59
|
}
|
|
@@ -91,7 +95,7 @@ function backfillMessageFtsRowidMapBatch(db, batchSize = MESSAGE_FTS_ROWID_MAP_B
|
|
|
91
95
|
watermarkRowid = ftsRowid;
|
|
92
96
|
}
|
|
93
97
|
if (typeof row.sessionId === "string" && Number.isSafeInteger(messageOrdinal) && messageOrdinal >= 0 && Number.isSafeInteger(ftsRowid) && ftsRowid > 0) {
|
|
94
|
-
|
|
98
|
+
recordMessageFtsRowid2(db, row.sessionId, messageOrdinal, ftsRowid);
|
|
95
99
|
}
|
|
96
100
|
}
|
|
97
101
|
const completed = rows.length < boundedBatchSize;
|
|
@@ -107,26 +111,33 @@ function backfillMessageFtsRowidMapBatch(db, batchSize = MESSAGE_FTS_ROWID_MAP_B
|
|
|
107
111
|
logSlowWriteTransaction("message_fts_rowid_backfill", transactionStartedAt);
|
|
108
112
|
return progress;
|
|
109
113
|
}
|
|
110
|
-
async function
|
|
114
|
+
async function runMessageFtsRowidMapBackfill2(db, signal) {
|
|
111
115
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
112
|
-
|
|
116
|
+
while (!signal?.aborted) {
|
|
113
117
|
const progress = backfillMessageFtsRowidMapBatch(db);
|
|
114
118
|
if (progress.completed)
|
|
115
119
|
return;
|
|
116
120
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
117
121
|
}
|
|
118
122
|
}
|
|
119
|
-
function
|
|
123
|
+
function startMessageFtsRowidMapBackfill2(db, signal) {
|
|
120
124
|
const active = activeBackfills.get(db);
|
|
121
125
|
if (active)
|
|
122
126
|
return active;
|
|
123
|
-
const
|
|
127
|
+
const path = getSqliteDatabasePath2(db);
|
|
128
|
+
const run = (path ? runSessionWarmupWorker({ path, sessionId: "", ftsRowidBackfill: true }, { signal }).then((result) => {
|
|
129
|
+
if (signal?.aborted)
|
|
130
|
+
return;
|
|
131
|
+
if (!("ftsRowidBackfill" in result)) {
|
|
132
|
+
throw Object.assign(new Error(`FTS rowid backfill unavailable: ${"failure" in result ? result.detail : "unexpected reply"}`), "failure" in result ? { code: result.code, errcode: result.errcode } : {});
|
|
133
|
+
}
|
|
134
|
+
}) : withoutSqliteTransformPass2(() => withSqliteBackgroundWriter2(() => runMessageFtsRowidMapBackfill2(db, signal)))).finally(() => {
|
|
124
135
|
activeBackfills.delete(db);
|
|
125
136
|
});
|
|
126
137
|
activeBackfills.set(db, run);
|
|
127
138
|
return run;
|
|
128
139
|
}
|
|
129
|
-
function
|
|
140
|
+
function messageFtsOrdinalRangeIsMapped2(db, sessionId, startOrdinal, endOrdinal) {
|
|
130
141
|
if (endOrdinal < startOrdinal)
|
|
131
142
|
return true;
|
|
132
143
|
if (getBackfillState(db).completed)
|
|
@@ -157,7 +168,7 @@ function messageFtsOrdinalRangeIsMapped(db, sessionId, startOrdinal, endOrdinal)
|
|
|
157
168
|
const ordinalCount = endOrdinal - startOrdinal + 1;
|
|
158
169
|
return row?.sourceOrdinalCount === ordinalCount && row.expectedMapCount === row.mappedCount;
|
|
159
170
|
}
|
|
160
|
-
function
|
|
171
|
+
function deleteUnmappedMessageFtsRows2(db, sessionIds) {
|
|
161
172
|
if (sessionIds.length === 0)
|
|
162
173
|
return;
|
|
163
174
|
const state = getBackfillState(db);
|
|
@@ -168,4 +179,4 @@ function deleteUnmappedMessageFtsRows(db, sessionIds) {
|
|
|
168
179
|
WHERE rowid > ? AND session_id IN (${placeholders})`).run(state.watermarkRowid, ...sessionIds);
|
|
169
180
|
}
|
|
170
181
|
|
|
171
|
-
export {
|
|
182
|
+
export { recordMessageFtsRowid2, recordIndexedMessageTime2, runMessageFtsRowidMapBackfill2, startMessageFtsRowidMapBackfill2, messageFtsOrdinalRangeIsMapped2, deleteUnmappedMessageFtsRows2 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
3
|
-
} from "./server-
|
|
3
|
+
} from "./server-271qxsf5.js";
|
|
4
4
|
import {
|
|
5
5
|
log2
|
|
6
6
|
} from "./server-f2xf5gcb.js";
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
} from "./server-rrqpvwqd.js";
|
|
11
11
|
import {
|
|
12
12
|
LocalEmbeddingProvider
|
|
13
|
-
} from "./server-
|
|
13
|
+
} from "./server-gha9x4qq.js";
|
|
14
14
|
import {
|
|
15
15
|
OpenAICompatibleEmbeddingProvider,
|
|
16
16
|
getProjectEmbeddingSnapshot2,
|
|
17
17
|
embedBatchForProject2
|
|
18
|
-
} from "./server-
|
|
18
|
+
} from "./server-kr2kc9dz.js";
|
|
19
19
|
import {
|
|
20
20
|
isEmbeddingHostBusy2
|
|
21
21
|
} from "./server-qt1qqasc.js";
|
|
@@ -708,4 +708,4 @@ function setBootQuietPeriodForTests(startAtMs) {
|
|
|
708
708
|
bootQuietUntilMs = startAtMs === null ? 0 : startAtMs + BOOT_QUIET_MS;
|
|
709
709
|
}
|
|
710
710
|
|
|
711
|
-
export { setHomeProjectPermission, shouldSkipHomeProjectMemory, ProjectIdentityError, takeDubiousOwnershipProjectIdentityWarning, isUserHomeDirectory, resolveProjectIdentity, directoryHasGitMetadata, describeUnresolvedProjectIdentity, isUsableProjectIdentity, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, beginBootQuietPeriod,
|
|
711
|
+
export { setHomeProjectPermission, shouldSkipHomeProjectMemory, ProjectIdentityError, takeDubiousOwnershipProjectIdentityWarning, isUserHomeDirectory, resolveProjectIdentity, directoryHasGitMetadata, describeUnresolvedProjectIdentity, isUsableProjectIdentity, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, beginBootQuietPeriod, scheduleAfterBootQuiet, setBootQuietPeriodForTests };
|
|
@@ -23,20 +23,20 @@ import {
|
|
|
23
23
|
} from "./server-pwv4ezb0.js";
|
|
24
24
|
import {
|
|
25
25
|
cleanUserText2
|
|
26
|
-
} from "./server-
|
|
26
|
+
} from "./server-1hcbw661.js";
|
|
27
27
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} from "./server-
|
|
28
|
+
recordMessageFtsRowid2,
|
|
29
|
+
recordIndexedMessageTime2,
|
|
30
|
+
messageFtsOrdinalRangeIsMapped2,
|
|
31
|
+
deleteUnmappedMessageFtsRows2
|
|
32
|
+
} from "./server-785mb90s.js";
|
|
33
33
|
import {
|
|
34
34
|
isPidAlive,
|
|
35
35
|
readProcessStartTime
|
|
36
36
|
} from "./server-da07v4xp.js";
|
|
37
37
|
import {
|
|
38
38
|
deleteChunkEmbedBackoffForSession
|
|
39
|
-
} from "./server-
|
|
39
|
+
} from "./server-kqpawe1a.js";
|
|
40
40
|
import {
|
|
41
41
|
closeQuietly
|
|
42
42
|
} from "./server-8ajstryz.js";
|
|
@@ -649,7 +649,7 @@ function deleteSessionScopedRows(db, sessionIds, harness, options = {}) {
|
|
|
649
649
|
FROM message_fts_rowid_map
|
|
650
650
|
WHERE session_id IN (${placeholders})
|
|
651
651
|
)`).run(...deletableSessionIds);
|
|
652
|
-
|
|
652
|
+
deleteUnmappedMessageFtsRows2(db, deletableSessionIds);
|
|
653
653
|
continue;
|
|
654
654
|
}
|
|
655
655
|
const predicates = [`session_id IN (${placeholders})`];
|
|
@@ -896,7 +896,7 @@ function getDeleteMessageFtsMapStatement(db) {
|
|
|
896
896
|
}
|
|
897
897
|
function insertMessageFtsRow(db, sessionId, messageOrdinal, messageId, role, content, messageTimeMs) {
|
|
898
898
|
const result = getInsertMessageStatement(db).run(sessionId, messageOrdinal, messageId, role, content);
|
|
899
|
-
|
|
899
|
+
recordMessageFtsRowid2(db, sessionId, messageOrdinal, result.lastInsertRowid, messageTimeMs ?? null);
|
|
900
900
|
}
|
|
901
901
|
function normalizeSourceVersion(version) {
|
|
902
902
|
if (typeof version === "number")
|
|
@@ -996,7 +996,7 @@ function deleteIndexedMessage2(db, sessionId, messageId) {
|
|
|
996
996
|
function clearIndexedMessagesInTransaction2(db, sessionId) {
|
|
997
997
|
deleteMessageIndexSkips(db, sessionId);
|
|
998
998
|
getDeleteFtsStatement(db).run(sessionId);
|
|
999
|
-
|
|
999
|
+
deleteUnmappedMessageFtsRows2(db, [sessionId]);
|
|
1000
1000
|
getDeleteFtsMapStatement(db).run(sessionId);
|
|
1001
1001
|
getDeleteMessageSourceStatement(db).run(sessionId);
|
|
1002
1002
|
getDeleteIndexStatement(db).run(sessionId);
|
|
@@ -1027,10 +1027,10 @@ function indexSingleMessageInTransaction(db, sessionId, message, now, dirtyFloor
|
|
|
1027
1027
|
const dirtyFloor = getDirtyIndexFloor(db, sessionId);
|
|
1028
1028
|
if (message.ordinal <= currentWatermark) {
|
|
1029
1029
|
if (isIndexSourceCurrent(db, sessionId, source)) {
|
|
1030
|
-
|
|
1030
|
+
recordIndexedMessageTime2(db, sessionId, message.ordinal, message.createdAt);
|
|
1031
1031
|
return false;
|
|
1032
1032
|
}
|
|
1033
|
-
if (!
|
|
1033
|
+
if (!messageFtsOrdinalRangeIsMapped2(db, sessionId, message.ordinal, message.ordinal)) {
|
|
1034
1034
|
return false;
|
|
1035
1035
|
}
|
|
1036
1036
|
getDeleteMessageFtsStatement(db).run(sessionId, message.id);
|
|
@@ -1060,7 +1060,7 @@ function indexSingleMessage2(db, sessionId, message, shouldCommit = () => true,
|
|
|
1060
1060
|
const source = preparedSource ?? getMessageSourceSnapshot(message);
|
|
1061
1061
|
const currentWatermark = getLastIndexedOrdinal2(db, sessionId);
|
|
1062
1062
|
if (message.ordinal <= currentWatermark && isIndexSourceCurrent(db, sessionId, source)) {
|
|
1063
|
-
|
|
1063
|
+
recordIndexedMessageTime2(db, sessionId, message.ordinal, message.createdAt);
|
|
1064
1064
|
return false;
|
|
1065
1065
|
}
|
|
1066
1066
|
const dirtyFloorBeforeAttempt = getDirtyIndexFloor(db, sessionId);
|
|
@@ -1101,7 +1101,7 @@ function indexItemsAfterOrdinal(db, sessionId, items, finalWatermark, toSource)
|
|
|
1101
1101
|
const currentWatermark = getLastIndexedOrdinal2(db, sessionId);
|
|
1102
1102
|
const dirtyFloor = getDirtyIndexFloor(db, sessionId);
|
|
1103
1103
|
const effectiveWatermark = dirtyFloor === null ? currentWatermark : Math.min(currentWatermark, Math.max(0, dirtyFloor - 1));
|
|
1104
|
-
if (dirtyFloor !== null && dirtyFloor <= currentWatermark && !
|
|
1104
|
+
if (dirtyFloor !== null && dirtyFloor <= currentWatermark && !messageFtsOrdinalRangeIsMapped2(db, sessionId, dirtyFloor, Math.min(currentWatermark, finalWatermark))) {
|
|
1105
1105
|
db.exec("COMMIT");
|
|
1106
1106
|
committed = true;
|
|
1107
1107
|
logSlowWriteTransaction("message_index_reconcile", transactionStartedAt);
|