@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-wgypt3cs.js";
|
|
4
4
|
import {
|
|
5
5
|
log2
|
|
6
6
|
} from "./index-j75v2476.js";
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
} from "./index-fkx2qnvw.js";
|
|
11
11
|
import {
|
|
12
12
|
LocalEmbeddingProvider
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-7b2cfmaz.js";
|
|
14
14
|
import {
|
|
15
15
|
OpenAICompatibleEmbeddingProvider,
|
|
16
16
|
getProjectEmbeddingSnapshot2,
|
|
17
17
|
embedBatchForProject2
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-qrahzcqv.js";
|
|
19
19
|
import {
|
|
20
20
|
isEmbeddingHostBusy2
|
|
21
21
|
} from "./index-qt1qqasc.js";
|
|
@@ -92,7 +92,7 @@ import {
|
|
|
92
92
|
getRawSessionTagKeysThrough2,
|
|
93
93
|
getLegacyProtectedTailStartOrdinal2,
|
|
94
94
|
readSessionChunk2
|
|
95
|
-
} from "./index-
|
|
95
|
+
} from "./index-j6zw70pf.js";
|
|
96
96
|
import {
|
|
97
97
|
getHarness2,
|
|
98
98
|
harnessOwnsOpenCodeStore2
|
|
@@ -142,7 +142,7 @@ import {
|
|
|
142
142
|
ConfigProfilesSchema,
|
|
143
143
|
MagicContextConfigSchema,
|
|
144
144
|
LIVE_RELOAD_CONFIG_PATHS
|
|
145
|
-
} from "./index-
|
|
145
|
+
} from "./index-wgypt3cs.js";
|
|
146
146
|
import {
|
|
147
147
|
providerMass,
|
|
148
148
|
calibrationForModelKey,
|
|
@@ -159,7 +159,7 @@ import {
|
|
|
159
159
|
LATEST_SUPPORTED_VERSION,
|
|
160
160
|
getPersistedSchemaVersion,
|
|
161
161
|
openDatabase
|
|
162
|
-
} from "./index-
|
|
162
|
+
} from "./index-cj9g0j7a.js";
|
|
163
163
|
import {
|
|
164
164
|
inRootAsyncContext2,
|
|
165
165
|
Database2,
|
|
@@ -175,6 +175,12 @@ import {
|
|
|
175
175
|
import {
|
|
176
176
|
isPidAlive
|
|
177
177
|
} from "./index-nj7yykkx.js";
|
|
178
|
+
import {
|
|
179
|
+
isStrictGapHealingMessage2,
|
|
180
|
+
noteRawSessionSummaryRowWritten2,
|
|
181
|
+
RawOrdinalsNotReady2,
|
|
182
|
+
runSessionWarmupWorker
|
|
183
|
+
} from "./index-7pa32z07.js";
|
|
178
184
|
import {
|
|
179
185
|
layoutLkgPrefix,
|
|
180
186
|
assembleLkgPrefix,
|
|
@@ -211,7 +217,7 @@ import {
|
|
|
211
217
|
getProjectChunkEmbeddingModelId2,
|
|
212
218
|
getProjectEmbeddingMaxInputTokens2,
|
|
213
219
|
embedItemsForProject2
|
|
214
|
-
} from "./index-
|
|
220
|
+
} from "./index-qrahzcqv.js";
|
|
215
221
|
import {
|
|
216
222
|
buildCanonicalChunkTextFromFts,
|
|
217
223
|
buildCompartmentSummaryFallbackText,
|
|
@@ -221,7 +227,7 @@ import {
|
|
|
221
227
|
replaceCompartmentChunkEmbeddings,
|
|
222
228
|
deleteChunkEmbedBackoffForSession,
|
|
223
229
|
chunkWindowSourceKey
|
|
224
|
-
} from "./index-
|
|
230
|
+
} from "./index-hehkf6zm.js";
|
|
225
231
|
import {
|
|
226
232
|
BoundedSessionMap,
|
|
227
233
|
clearCompressionDepth,
|
|
@@ -236,7 +242,7 @@ import {
|
|
|
236
242
|
toMessageIndexSource2,
|
|
237
243
|
clearIndexedMessagesInTransaction2,
|
|
238
244
|
indexSourcesAfterOrdinal2
|
|
239
|
-
} from "./index-
|
|
245
|
+
} from "./index-p4vde22c.js";
|
|
240
246
|
import {
|
|
241
247
|
stripWellFormedLeadingTagPrefix,
|
|
242
248
|
stripTagPrefix,
|
|
@@ -249,18 +255,12 @@ import {
|
|
|
249
255
|
foldShrunkPartTags2,
|
|
250
256
|
getTagNumberByMessageId2,
|
|
251
257
|
getActiveTagsBySession2
|
|
252
|
-
} from "./index-
|
|
253
|
-
import {
|
|
254
|
-
isStrictGapHealingMessage2,
|
|
255
|
-
noteRawSessionSummaryRowWritten2,
|
|
256
|
-
RawOrdinalsNotReady2,
|
|
257
|
-
runSessionWarmupWorker
|
|
258
|
-
} from "./index-mmfa86mt.js";
|
|
258
|
+
} from "./index-nd7m2a5a.js";
|
|
259
259
|
import {
|
|
260
260
|
openCodeDbExists,
|
|
261
261
|
withReadOnlySessionDb,
|
|
262
262
|
getMessageTimesFromOpenCodeDb
|
|
263
|
-
} from "./index-
|
|
263
|
+
} from "./index-mtw9e71a.js";
|
|
264
264
|
import {
|
|
265
265
|
renderUserFacingFailure,
|
|
266
266
|
userFacingFailureCode,
|
|
@@ -269,7 +269,7 @@ import {
|
|
|
269
269
|
insertPrimerCandidates,
|
|
270
270
|
promoteSessionFactsDurable,
|
|
271
271
|
embedPromotedFacts
|
|
272
|
-
} from "./index-
|
|
272
|
+
} from "./index-wv9n2zcq.js";
|
|
273
273
|
import {
|
|
274
274
|
pushNotification2
|
|
275
275
|
} from "./index-x8a7jmkh.js";
|
|
@@ -289,7 +289,7 @@ import {
|
|
|
289
289
|
} from "./index-f71thw8j.js";
|
|
290
290
|
import {
|
|
291
291
|
sendStatusNotification2
|
|
292
|
-
} from "./index-
|
|
292
|
+
} from "./index-b17m64g9.js";
|
|
293
293
|
import {
|
|
294
294
|
isCompactionEnabled,
|
|
295
295
|
migrateLegacyAgentEnabledInMemory
|
|
@@ -3482,6 +3482,7 @@ Examples:
|
|
|
3482
3482
|
- 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.
|
|
3483
3483
|
- 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.
|
|
3484
3484
|
- If the chunk ends mid-topic, leave the unfinished portion out and report its first message index in \`<unprocessed_from>\`.
|
|
3485
|
+
- 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.
|
|
3485
3486
|
|
|
3486
3487
|
---
|
|
3487
3488
|
|
|
@@ -5129,6 +5130,9 @@ class V2StoreReaderPool {
|
|
|
5129
5130
|
capacity;
|
|
5130
5131
|
connections = new Map;
|
|
5131
5132
|
closed = false;
|
|
5133
|
+
closing = false;
|
|
5134
|
+
holds = 0;
|
|
5135
|
+
idleWaiters = new Set;
|
|
5132
5136
|
constructor(capacity = 4) {
|
|
5133
5137
|
this.capacity = capacity;
|
|
5134
5138
|
if (!Number.isSafeInteger(capacity) || capacity < 1)
|
|
@@ -5173,13 +5177,63 @@ class V2StoreReaderPool {
|
|
|
5173
5177
|
if (connection.leases === 0)
|
|
5174
5178
|
closeConnection(connection);
|
|
5175
5179
|
}
|
|
5180
|
+
hold() {
|
|
5181
|
+
if (this.closed || this.closing)
|
|
5182
|
+
throw new Error("Store reader pool is closed");
|
|
5183
|
+
this.holds++;
|
|
5184
|
+
let released = false;
|
|
5185
|
+
return () => {
|
|
5186
|
+
if (released)
|
|
5187
|
+
return;
|
|
5188
|
+
released = true;
|
|
5189
|
+
this.holds--;
|
|
5190
|
+
if (this.holds === 0 && this.closing)
|
|
5191
|
+
this.finishClose();
|
|
5192
|
+
};
|
|
5193
|
+
}
|
|
5194
|
+
isClosed() {
|
|
5195
|
+
return this.closed;
|
|
5196
|
+
}
|
|
5197
|
+
holdCount() {
|
|
5198
|
+
return this.holds;
|
|
5199
|
+
}
|
|
5176
5200
|
close() {
|
|
5201
|
+
if (this.closed || this.closing)
|
|
5202
|
+
return;
|
|
5203
|
+
this.closing = true;
|
|
5204
|
+
if (this.holds === 0)
|
|
5205
|
+
this.finishClose();
|
|
5206
|
+
}
|
|
5207
|
+
async closeWhenIdle(timeoutMs) {
|
|
5208
|
+
this.close();
|
|
5209
|
+
if (this.closed)
|
|
5210
|
+
return true;
|
|
5211
|
+
let timer;
|
|
5212
|
+
let waiter;
|
|
5213
|
+
try {
|
|
5214
|
+
await new Promise((resolve) => {
|
|
5215
|
+
waiter = resolve;
|
|
5216
|
+
this.idleWaiters.add(resolve);
|
|
5217
|
+
timer = setTimeout(resolve, Math.max(0, timeoutMs));
|
|
5218
|
+
});
|
|
5219
|
+
} finally {
|
|
5220
|
+
if (timer)
|
|
5221
|
+
clearTimeout(timer);
|
|
5222
|
+
if (waiter)
|
|
5223
|
+
this.idleWaiters.delete(waiter);
|
|
5224
|
+
}
|
|
5225
|
+
return this.closed;
|
|
5226
|
+
}
|
|
5227
|
+
finishClose() {
|
|
5177
5228
|
if (this.closed)
|
|
5178
5229
|
return;
|
|
5179
5230
|
this.closed = true;
|
|
5180
5231
|
for (const connection of this.connections.values())
|
|
5181
5232
|
this.retire(connection);
|
|
5182
5233
|
this.connections.clear();
|
|
5234
|
+
for (const resolve of this.idleWaiters)
|
|
5235
|
+
resolve();
|
|
5236
|
+
this.idleWaiters.clear();
|
|
5183
5237
|
}
|
|
5184
5238
|
}
|
|
5185
5239
|
|
|
@@ -8966,6 +9020,28 @@ function hiddenToolLoop(identity) {
|
|
|
8966
9020
|
function hiddenAgentAllowedTools(agent) {
|
|
8967
9021
|
return agent !== undefined && Object.hasOwn(AGENT_TOOLS, agent) ? AGENT_TOOLS[agent] : undefined;
|
|
8968
9022
|
}
|
|
9023
|
+
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";
|
|
9024
|
+
var DISPOSED_CHILDREN_KEY = Symbol.for("@cortexkit/magic-context/v2/disposed-hidden-children");
|
|
9025
|
+
var DISPOSED_CHILDREN_LIMIT = 512;
|
|
9026
|
+
function disposedChildren() {
|
|
9027
|
+
const store = globalThis;
|
|
9028
|
+
store[DISPOSED_CHILDREN_KEY] ??= new Set;
|
|
9029
|
+
return store[DISPOSED_CHILDREN_KEY];
|
|
9030
|
+
}
|
|
9031
|
+
function noteChildOfDisposedInstance(sessionID) {
|
|
9032
|
+
const children = disposedChildren();
|
|
9033
|
+
children.delete(sessionID);
|
|
9034
|
+
children.add(sessionID);
|
|
9035
|
+
while (children.size > DISPOSED_CHILDREN_LIMIT) {
|
|
9036
|
+
const oldest = children.values().next().value;
|
|
9037
|
+
if (oldest === undefined)
|
|
9038
|
+
break;
|
|
9039
|
+
children.delete(oldest);
|
|
9040
|
+
}
|
|
9041
|
+
}
|
|
9042
|
+
function isChildOfDisposedInstance(sessionID) {
|
|
9043
|
+
return disposedChildren().has(sessionID);
|
|
9044
|
+
}
|
|
8969
9045
|
function hiddenChildPermissions(agent, providerID) {
|
|
8970
9046
|
const tools = AGENT_TOOLS[agent] ?? [];
|
|
8971
9047
|
const visible = tools.length === 0 && needsBlockedRead(agent, providerID) ? ["read"] : tools;
|
|
@@ -8997,6 +9073,8 @@ async function registerHiddenChildAgents(agent) {
|
|
|
8997
9073
|
}
|
|
8998
9074
|
function hiddenToolCallRefusal(call, hook) {
|
|
8999
9075
|
const owned = hook.owns(call.sessionID);
|
|
9076
|
+
if (!owned && isChildOfDisposedInstance(call.sessionID))
|
|
9077
|
+
return `Magic Context hidden child ${call.sessionID} refused: ${HIDDEN_RUN_DISPOSED_REASON}; ${call.tool} refused`;
|
|
9000
9078
|
const agent = owned ? hook.agentFor(call.sessionID) ?? call.agent : call.agent;
|
|
9001
9079
|
const allowed = hiddenAgentAllowedTools(agent);
|
|
9002
9080
|
if (allowed === undefined) {
|
|
@@ -9126,6 +9204,9 @@ class HiddenChildHook {
|
|
|
9126
9204
|
}
|
|
9127
9205
|
compactionSummary(sessionID, agent) {
|
|
9128
9206
|
if (!this.owns(sessionID)) {
|
|
9207
|
+
if (isChildOfDisposedInstance(sessionID)) {
|
|
9208
|
+
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");
|
|
9209
|
+
}
|
|
9129
9210
|
if (hiddenAgentAllowedTools(agent) !== undefined) {
|
|
9130
9211
|
this.refuse("Refusing to compact a Magic Context hidden-agent session this instance did not register", { sessionID, messages: [] }, undefined);
|
|
9131
9212
|
}
|
|
@@ -9140,7 +9221,7 @@ class HiddenChildHook {
|
|
|
9140
9221
|
}
|
|
9141
9222
|
return marker;
|
|
9142
9223
|
}
|
|
9143
|
-
refuse(reason, draft, raw, inFlight) {
|
|
9224
|
+
refuse(reason, draft, raw, inFlight, code = "hidden_prompt_unrecognized") {
|
|
9144
9225
|
const registered = [...this.attempts.values()].filter((attempt) => attempt.childSessionId === draft.sessionID && attempt.marker).map((attempt) => {
|
|
9145
9226
|
const marker = attempt.marker;
|
|
9146
9227
|
return {
|
|
@@ -9161,7 +9242,7 @@ class HiddenChildHook {
|
|
|
9161
9242
|
active: this.active.has(draft.sessionID),
|
|
9162
9243
|
...inFlight === undefined ? {} : { in_flight: inFlight }
|
|
9163
9244
|
})}`);
|
|
9164
|
-
const refusal = new HiddenCompletionRefusal(
|
|
9245
|
+
const refusal = new HiddenCompletionRefusal(code, reason, true);
|
|
9165
9246
|
for (const attempt of this.attempts.values()) {
|
|
9166
9247
|
if (attempt.childSessionId === draft.sessionID)
|
|
9167
9248
|
attempt.refusal = refusal;
|
|
@@ -9176,6 +9257,9 @@ class HiddenChildHook {
|
|
|
9176
9257
|
}
|
|
9177
9258
|
apply(draft) {
|
|
9178
9259
|
if (!this.owns(draft.sessionID)) {
|
|
9260
|
+
if (isChildOfDisposedInstance(draft.sessionID)) {
|
|
9261
|
+
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");
|
|
9262
|
+
}
|
|
9179
9263
|
if (hiddenAgentAllowedTools(draft.agent) !== undefined) {
|
|
9180
9264
|
this.refuse("Refusing a Magic Context hidden-agent turn this instance did not register", draft, newestUserText(draft));
|
|
9181
9265
|
}
|
|
@@ -9588,14 +9672,14 @@ function throwWithPromptFailure(legacyError, failedAttempts, args, timeoutMs, tr
|
|
|
9588
9672
|
});
|
|
9589
9673
|
throw error;
|
|
9590
9674
|
}
|
|
9591
|
-
async function attemptOnce(client, args, timeoutMs, signal, callContext, label, transport) {
|
|
9675
|
+
async function attemptOnce(client, args, timeoutMs, signal, callContext, label, transport, allowModelSuggestions = true) {
|
|
9592
9676
|
const originalBody = { ...args.body };
|
|
9593
9677
|
const attemptArgs = copyPromptArgs(args, originalBody);
|
|
9594
9678
|
try {
|
|
9595
9679
|
await promptWithTimeout(client, attemptArgs, timeoutMs, signal, transport);
|
|
9596
9680
|
return;
|
|
9597
9681
|
} catch (error) {
|
|
9598
|
-
if (isNonRetryable(error, signal))
|
|
9682
|
+
if (isNonRetryable(error, signal) || !allowModelSuggestions)
|
|
9599
9683
|
throw error;
|
|
9600
9684
|
const suggestion = parseModelSuggestion(error);
|
|
9601
9685
|
if (!suggestion || !originalBody.model) {
|
|
@@ -9623,7 +9707,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
|
9623
9707
|
const explicitPrimaryLabel = baseBody.model?.providerID && baseBody.model.modelID ? `${baseBody.model.providerID}/${baseBody.model.modelID}` : "primary";
|
|
9624
9708
|
let lastError = null;
|
|
9625
9709
|
try {
|
|
9626
|
-
await attemptOnce(client, baseArgs, timeoutMs, options.signal, callContext, explicitPrimaryLabel, options.transport);
|
|
9710
|
+
await attemptOnce(client, baseArgs, timeoutMs, options.signal, callContext, explicitPrimaryLabel, options.transport, options.allowModelSuggestions);
|
|
9627
9711
|
return;
|
|
9628
9712
|
} catch (error) {
|
|
9629
9713
|
lastError = error;
|
|
@@ -9649,7 +9733,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
|
9649
9733
|
...fallback?.qualifier ? { variant: fallback.qualifier } : {}
|
|
9650
9734
|
});
|
|
9651
9735
|
try {
|
|
9652
|
-
await attemptOnce(client, attemptArgs, timeoutMs, options.signal, callContext, label, options.transport);
|
|
9736
|
+
await attemptOnce(client, attemptArgs, timeoutMs, options.signal, callContext, label, options.transport, options.allowModelSuggestions);
|
|
9653
9737
|
log2(`[${callContext}] fallback succeeded with ${label} (attempt ${i + 2}/${fallbacks.length + 1})`);
|
|
9654
9738
|
return;
|
|
9655
9739
|
} catch (error) {
|
|
@@ -9667,7 +9751,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
|
9667
9751
|
}
|
|
9668
9752
|
async function attemptAndValidate(client, args, timeoutMs, signal, callContext, attempt, options) {
|
|
9669
9753
|
try {
|
|
9670
|
-
await attemptOnce(client, args, timeoutMs, signal, callContext, attempt.label, options.transport);
|
|
9754
|
+
await attemptOnce(client, args, timeoutMs, signal, callContext, attempt.label, options.transport, options.allowModelSuggestions);
|
|
9671
9755
|
} catch (error) {
|
|
9672
9756
|
throw {
|
|
9673
9757
|
error,
|
|
@@ -10650,6 +10734,7 @@ function buildHistorianRepairPrompt(originalPrompt, previousOutput, validationEr
|
|
|
10650
10734
|
"Return a corrected full XML response for the same existing state and new messages.",
|
|
10651
10735
|
"Do not skip any displayed raw ordinal or displayed raw range, even if the message looks trivial.",
|
|
10652
10736
|
"Every displayed message range must belong to exactly one compartment unless it is intentionally left in one trailing suffix marked by <unprocessed_from>.",
|
|
10737
|
+
"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.",
|
|
10653
10738
|
"",
|
|
10654
10739
|
"Previous invalid XML:",
|
|
10655
10740
|
previousOutput
|
|
@@ -10701,16 +10786,19 @@ function validateParsedCompartments(compartments, chunkStart, chunkEnd, unproces
|
|
|
10701
10786
|
expectedStart = compartment.endMessage + 1;
|
|
10702
10787
|
}
|
|
10703
10788
|
if (unprocessedFrom !== null) {
|
|
10789
|
+
if (expectedStart <= chunkEnd) {
|
|
10790
|
+
if (unprocessedFrom !== expectedStart) {
|
|
10791
|
+
return `<unprocessed_from> ${unprocessedFrom} does not match next uncovered message ${expectedStart}`;
|
|
10792
|
+
}
|
|
10793
|
+
return null;
|
|
10794
|
+
}
|
|
10704
10795
|
if (unprocessedFrom === chunkEnd + 1) {
|
|
10705
10796
|
return null;
|
|
10706
10797
|
}
|
|
10707
10798
|
if (unprocessedFrom < chunkStart || unprocessedFrom > chunkEnd) {
|
|
10708
10799
|
return `<unprocessed_from> ${unprocessedFrom} is outside chunk ${chunkStart}-${chunkEnd}`;
|
|
10709
10800
|
}
|
|
10710
|
-
|
|
10711
|
-
return `<unprocessed_from> ${unprocessedFrom} does not match next uncovered message ${expectedStart}`;
|
|
10712
|
-
}
|
|
10713
|
-
return null;
|
|
10801
|
+
return `<unprocessed_from> ${unprocessedFrom} does not match completed chunk boundary ${chunkEnd + 1}`;
|
|
10714
10802
|
}
|
|
10715
10803
|
if (expectedStart <= chunkEnd) {
|
|
10716
10804
|
return `output left uncovered messages ${expectedStart}-${chunkEnd} without <unprocessed_from>`;
|
|
@@ -17945,6 +18033,7 @@ async function runHistorianPrompt(args) {
|
|
|
17945
18033
|
return executor.attempt(opened, request);
|
|
17946
18034
|
}, { childSessionId: opened.childSessionId }),
|
|
17947
18035
|
timeoutMs: timeoutMs ?? DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
18036
|
+
allowModelSuggestions: false,
|
|
17948
18037
|
fallbackModels: modelOverride ? undefined : fallbackModels,
|
|
17949
18038
|
callContext: agentId === HISTORIAN_EDITOR_AGENT ? "historian:editor" : "historian"
|
|
17950
18039
|
});
|
|
@@ -18029,7 +18118,7 @@ async function runFallbackHistorianPass(args) {
|
|
|
18029
18118
|
const primary = toModelEntry(args.model);
|
|
18030
18119
|
for (const candidateInput of [
|
|
18031
18120
|
...args.fallbackModels ?? [],
|
|
18032
|
-
|
|
18121
|
+
...!primary && args.fallbackModelId ? [{ model: args.fallbackModelId }] : []
|
|
18033
18122
|
]) {
|
|
18034
18123
|
const candidate = toModelEntry(candidateInput);
|
|
18035
18124
|
if (!candidate)
|
|
@@ -20405,7 +20494,7 @@ async function runCompartmentAgent(deps) {
|
|
|
20405
20494
|
const projectPath = resolveProjectIdentity(directory ?? process.cwd());
|
|
20406
20495
|
const fallbackWindows = [
|
|
20407
20496
|
...(deps.fallbackModels ?? []).map((entry) => toModelEntry(entry)?.model),
|
|
20408
|
-
deps.fallbackModelId
|
|
20497
|
+
...toModelEntry(deps.model) ? [] : [deps.fallbackModelId]
|
|
20409
20498
|
].filter((key) => typeof key === "string" && key !== producerModel).map((key) => resolveHistorianProducerWindow(key, deps.historianMaxOutputTokens));
|
|
20410
20499
|
const promptFit = fitHistorianPrompt({
|
|
20411
20500
|
window: producerWindow,
|
|
@@ -21842,4 +21931,4 @@ async function executeContextRecomp(deps, options = {}) {
|
|
|
21842
21931
|
return (await executeContextRecompWithResult(deps, options)).message;
|
|
21843
21932
|
}
|
|
21844
21933
|
|
|
21845
|
-
export { denyTaskRoutingToCallerAgents, buildHiddenAgentRegistrations, buildZenReadAgentRegistrations, buildHiddenAgentConfig, getMagicContextBuiltinCommands, formatConfigParseStatusLine, claimConfigParseFailuresOnce, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, loadPluginConfigDetailed, historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, createDreamerOutputCapSampler, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, 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, createDbLkgPersistence, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, registerLkgPersistence, 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, createChildSessionWithFence, HiddenCompletionRefusal, DreamerProviderOutputFailureError, withDreamerModelCooldown, providerOutputFailureFromInvalidManifest, 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, recordPromptSessionError, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, setKeepSubagents, teardownChildSession, getCompartmentEvents, runTokenLog, formatRunTokenLog, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, prepareCompactionMarkerCandidates, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, 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, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, readCoordinateGeneration, readCoordinateRebaseNotice, formatCoordinateRebaseNotice, rebaseSessionCoordinatesAsync, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, noteTransformPassForExactOrdinalReads, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, executeContextRecomp };
|
|
21934
|
+
export { denyTaskRoutingToCallerAgents, buildHiddenAgentRegistrations, buildZenReadAgentRegistrations, buildHiddenAgentConfig, getMagicContextBuiltinCommands, formatConfigParseStatusLine, claimConfigParseFailuresOnce, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, loadPluginConfigDetailed, historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, createDreamerOutputCapSampler, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, 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, createDbLkgPersistence, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, registerLkgPersistence, 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, createChildSessionWithFence, HiddenCompletionRefusal, DreamerProviderOutputFailureError, withDreamerModelCooldown, providerOutputFailureFromInvalidManifest, 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, recordPromptSessionError, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, setKeepSubagents, teardownChildSession, getCompartmentEvents, runTokenLog, formatRunTokenLog, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, prepareCompactionMarkerCandidates, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, 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, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, readCoordinateGeneration, readCoordinateRebaseNotice, formatCoordinateRebaseNotice, rebaseSessionCoordinatesAsync, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, noteTransformPassForExactOrdinalReads, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, executeContextRecomp };
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
withPrivilegedWriter2
|
|
17
17
|
} from "./index-wafzvyhg.js";
|
|
18
18
|
import {
|
|
19
|
-
bootQuietRemainingMs,
|
|
20
19
|
scheduleAfterBootQuiet
|
|
21
20
|
} from "./index-a8bvhwqs.js";
|
|
22
21
|
import {
|
|
@@ -42,8 +41,8 @@ import {
|
|
|
42
41
|
configureContextDatabasePragmas2
|
|
43
42
|
} from "./index-fb3zxn06.js";
|
|
44
43
|
import {
|
|
45
|
-
|
|
46
|
-
} from "./index-
|
|
44
|
+
startMessageFtsRowidMapBackfill2
|
|
45
|
+
} from "./index-dqe8pq4x.js";
|
|
47
46
|
import {
|
|
48
47
|
LKG_SLOT_CHUNKS_DDL,
|
|
49
48
|
SESSION_REPLAY_DECISIONS_DDL,
|
|
@@ -821,6 +820,8 @@ registerSlowWriteReporter2(logSlowWriteTransaction);
|
|
|
821
820
|
registerSqliteDiagnosticSink2((message) => log2(message), getHarness2);
|
|
822
821
|
var databases = new Map;
|
|
823
822
|
var pendingAsyncOpens = new Map;
|
|
823
|
+
var pendingDatabaseCloses = new Set;
|
|
824
|
+
var startupBackfills = new WeakMap;
|
|
824
825
|
var persistenceByDatabase = new WeakMap;
|
|
825
826
|
var persistenceErrorByDatabase = new WeakMap;
|
|
826
827
|
var pathByDatabase = new WeakMap;
|
|
@@ -1258,8 +1259,14 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1258
1259
|
healWedgedChannel2Claims(db);
|
|
1259
1260
|
if (!explicitDbPath) {
|
|
1260
1261
|
const readsOpenCodeStore = harnessOwnsOpenCodeStore2();
|
|
1262
|
+
const state = { controller: new AbortController };
|
|
1263
|
+
startupBackfills.set(db, state);
|
|
1264
|
+
const { signal } = state.controller;
|
|
1261
1265
|
let busyRetryMs = 100;
|
|
1262
1266
|
const runBackfills = () => withoutSqliteTransformPass2(() => withSqliteBackgroundWriter2(() => {
|
|
1267
|
+
state.timer = undefined;
|
|
1268
|
+
if (signal.aborted)
|
|
1269
|
+
return;
|
|
1263
1270
|
if (readsOpenCodeStore) {
|
|
1264
1271
|
try {
|
|
1265
1272
|
runToolOwnerBackfill(db);
|
|
@@ -1267,19 +1274,23 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1267
1274
|
log2(`[magic-context] tool-owner backfill failed (continuing with lazy adoption fallback): ${getErrorMessage(error)}`);
|
|
1268
1275
|
}
|
|
1269
1276
|
}
|
|
1270
|
-
|
|
1271
|
-
if (!readsOpenCodeStore)
|
|
1277
|
+
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1278
|
+
if (signal.aborted || !readsOpenCodeStore)
|
|
1279
|
+
return;
|
|
1280
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-4pwqxm5a.js"));
|
|
1281
|
+
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-8egzkd3z.js"));
|
|
1282
|
+
if (signal.aborted)
|
|
1272
1283
|
return;
|
|
1273
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-3ae3nfdn.js"));
|
|
1274
|
-
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-qjge9044.js"));
|
|
1275
1284
|
await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
|
|
1276
1285
|
readPage: readRawSessionMessagePage
|
|
1277
|
-
}));
|
|
1286
|
+
}), signal);
|
|
1278
1287
|
}).catch((error) => {
|
|
1288
|
+
if (signal.aborted)
|
|
1289
|
+
return;
|
|
1279
1290
|
if (isTransientSqliteError2(error)) {
|
|
1280
1291
|
withoutSqliteTransformPass2(() => {
|
|
1281
|
-
|
|
1282
|
-
timer.unref();
|
|
1292
|
+
state.timer = setTimeout(runBackfills, busyRetryMs);
|
|
1293
|
+
state.timer.unref?.();
|
|
1283
1294
|
});
|
|
1284
1295
|
busyRetryMs = Math.min(30000, busyRetryMs * 2);
|
|
1285
1296
|
return;
|
|
@@ -1287,10 +1298,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1287
1298
|
log2(`[magic-context] message-index backfill failed (will resume next startup): ${getErrorMessage(error)}`);
|
|
1288
1299
|
});
|
|
1289
1300
|
}));
|
|
1290
|
-
|
|
1291
|
-
scheduleAfterBootQuiet(runBackfills);
|
|
1292
|
-
else
|
|
1293
|
-
runBackfills();
|
|
1301
|
+
state.timer = scheduleAfterBootQuiet(runBackfills);
|
|
1294
1302
|
}
|
|
1295
1303
|
setDatabase(db);
|
|
1296
1304
|
loadToolDefinitionMeasurements(db);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getSqliteDatabasePath2,
|
|
2
3
|
withSqliteBackgroundWriter2,
|
|
3
4
|
withoutSqliteTransformPass2
|
|
4
5
|
} from "./index-wafzvyhg.js";
|
|
6
|
+
import {
|
|
7
|
+
runSessionWarmupWorker
|
|
8
|
+
} from "./index-7pa32z07.js";
|
|
5
9
|
import {
|
|
6
10
|
logSlowWriteTransaction
|
|
7
11
|
} from "./index-k29z4aqh.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 };
|