@cortexkit/opencode-magic-context 0.49.15 → 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-0m46day0.js → context-3znk23va.js} +26 -20
- package/dist/{embedding-backfill-5e1t5wha.js → embedding-backfill-q4n8dend.js} +8 -6
- package/dist/embedding-worker.js +2 -2
- 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-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/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-snp5wbge.js → index-ayym1x7f.js} +25 -23
- 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-42vcjcwe.js → index-ek1yxvvz.js} +34 -76
- 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-ts1hjk1h.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-1vc7jrkg.js → index-v63beg1z.js} +3 -3
- package/dist/{index-mc1cqza6.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-nwzcfhx4.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-ne3z1zmt.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-4qczzck7.js → context-acw1nhv8.js} +52 -86
- package/dist/v2/{embedding-backfill-jmaf8zrr.js → embedding-backfill-jyd6492b.js} +10 -8
- package/dist/v2/embedding-worker.js +2 -2
- package/dist/v2/hooks/context.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-5zhxtwha.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-dd0tz6cn.js → server-6fyp0v67.js} +26 -24
- 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/{wrapup-orchestrator-65pwye0d.js → wrapup-orchestrator-x4xj1782.js} +18 -18
- package/dist/{wrapup-orchestrator-28xzsj5q.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
|
|
@@ -9672,14 +9672,14 @@ function throwWithPromptFailure(legacyError, failedAttempts, args, timeoutMs, tr
|
|
|
9672
9672
|
});
|
|
9673
9673
|
throw error;
|
|
9674
9674
|
}
|
|
9675
|
-
async function attemptOnce(client, args, timeoutMs, signal, callContext, label, transport) {
|
|
9675
|
+
async function attemptOnce(client, args, timeoutMs, signal, callContext, label, transport, allowModelSuggestions = true) {
|
|
9676
9676
|
const originalBody = { ...args.body };
|
|
9677
9677
|
const attemptArgs = copyPromptArgs(args, originalBody);
|
|
9678
9678
|
try {
|
|
9679
9679
|
await promptWithTimeout(client, attemptArgs, timeoutMs, signal, transport);
|
|
9680
9680
|
return;
|
|
9681
9681
|
} catch (error) {
|
|
9682
|
-
if (isNonRetryable(error, signal))
|
|
9682
|
+
if (isNonRetryable(error, signal) || !allowModelSuggestions)
|
|
9683
9683
|
throw error;
|
|
9684
9684
|
const suggestion = parseModelSuggestion(error);
|
|
9685
9685
|
if (!suggestion || !originalBody.model) {
|
|
@@ -9707,7 +9707,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
|
9707
9707
|
const explicitPrimaryLabel = baseBody.model?.providerID && baseBody.model.modelID ? `${baseBody.model.providerID}/${baseBody.model.modelID}` : "primary";
|
|
9708
9708
|
let lastError = null;
|
|
9709
9709
|
try {
|
|
9710
|
-
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);
|
|
9711
9711
|
return;
|
|
9712
9712
|
} catch (error) {
|
|
9713
9713
|
lastError = error;
|
|
@@ -9733,7 +9733,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
|
9733
9733
|
...fallback?.qualifier ? { variant: fallback.qualifier } : {}
|
|
9734
9734
|
});
|
|
9735
9735
|
try {
|
|
9736
|
-
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);
|
|
9737
9737
|
log2(`[${callContext}] fallback succeeded with ${label} (attempt ${i + 2}/${fallbacks.length + 1})`);
|
|
9738
9738
|
return;
|
|
9739
9739
|
} catch (error) {
|
|
@@ -9751,7 +9751,7 @@ async function promptSyncWithModelSuggestionRetry(client, args, options = {}) {
|
|
|
9751
9751
|
}
|
|
9752
9752
|
async function attemptAndValidate(client, args, timeoutMs, signal, callContext, attempt, options) {
|
|
9753
9753
|
try {
|
|
9754
|
-
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);
|
|
9755
9755
|
} catch (error) {
|
|
9756
9756
|
throw {
|
|
9757
9757
|
error,
|
|
@@ -10734,6 +10734,7 @@ function buildHistorianRepairPrompt(originalPrompt, previousOutput, validationEr
|
|
|
10734
10734
|
"Return a corrected full XML response for the same existing state and new messages.",
|
|
10735
10735
|
"Do not skip any displayed raw ordinal or displayed raw range, even if the message looks trivial.",
|
|
10736
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.",
|
|
10737
10738
|
"",
|
|
10738
10739
|
"Previous invalid XML:",
|
|
10739
10740
|
previousOutput
|
|
@@ -18032,6 +18033,7 @@ async function runHistorianPrompt(args) {
|
|
|
18032
18033
|
return executor.attempt(opened, request);
|
|
18033
18034
|
}, { childSessionId: opened.childSessionId }),
|
|
18034
18035
|
timeoutMs: timeoutMs ?? DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
18036
|
+
allowModelSuggestions: false,
|
|
18035
18037
|
fallbackModels: modelOverride ? undefined : fallbackModels,
|
|
18036
18038
|
callContext: agentId === HISTORIAN_EDITOR_AGENT ? "historian:editor" : "historian"
|
|
18037
18039
|
});
|
|
@@ -18116,7 +18118,7 @@ async function runFallbackHistorianPass(args) {
|
|
|
18116
18118
|
const primary = toModelEntry(args.model);
|
|
18117
18119
|
for (const candidateInput of [
|
|
18118
18120
|
...args.fallbackModels ?? [],
|
|
18119
|
-
|
|
18121
|
+
...!primary && args.fallbackModelId ? [{ model: args.fallbackModelId }] : []
|
|
18120
18122
|
]) {
|
|
18121
18123
|
const candidate = toModelEntry(candidateInput);
|
|
18122
18124
|
if (!candidate)
|
|
@@ -20492,7 +20494,7 @@ async function runCompartmentAgent(deps) {
|
|
|
20492
20494
|
const projectPath = resolveProjectIdentity(directory ?? process.cwd());
|
|
20493
20495
|
const fallbackWindows = [
|
|
20494
20496
|
...(deps.fallbackModels ?? []).map((entry) => toModelEntry(entry)?.model),
|
|
20495
|
-
deps.fallbackModelId
|
|
20497
|
+
...toModelEntry(deps.model) ? [] : [deps.fallbackModelId]
|
|
20496
20498
|
].filter((key) => typeof key === "string" && key !== producerModel).map((key) => resolveHistorianProducerWindow(key, deps.historianMaxOutputTokens));
|
|
20497
20499
|
const promptFit = fitHistorianPrompt({
|
|
20498
20500
|
window: producerWindow,
|
|
@@ -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 };
|