@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
|
@@ -143,7 +143,7 @@ import {
|
|
|
143
143
|
getDroppedTagsByNumbers2,
|
|
144
144
|
getMaxDroppedTagNumber2,
|
|
145
145
|
getTagById2
|
|
146
|
-
} from "./index-
|
|
146
|
+
} from "./index-nd7m2a5a.js";
|
|
147
147
|
import {
|
|
148
148
|
observeTemporalDecisions,
|
|
149
149
|
stableStringify
|
|
@@ -160,14 +160,14 @@ import {
|
|
|
160
160
|
DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
161
161
|
DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
162
162
|
DREAM_TASK_PROMOTION_DEFAULTS
|
|
163
|
-
} from "./index-
|
|
163
|
+
} from "./index-wgypt3cs.js";
|
|
164
164
|
import {
|
|
165
165
|
isRawCompactionSummaryInfo2,
|
|
166
166
|
extractInMemoryMessageViews2,
|
|
167
167
|
buildInMemoryTailRawMessages2,
|
|
168
168
|
RawOrdinalsNotReady2,
|
|
169
169
|
runSessionWarmupWorker
|
|
170
|
-
} from "./index-
|
|
170
|
+
} from "./index-7pa32z07.js";
|
|
171
171
|
import {
|
|
172
172
|
openCodeDbExists,
|
|
173
173
|
withReadOnlySessionDb,
|
|
@@ -175,7 +175,7 @@ import {
|
|
|
175
175
|
latestPersistedMessageForRecovery,
|
|
176
176
|
latestRealUserTurnIdFromOpenCodeDb,
|
|
177
177
|
findLastAssistantModelFromOpenCodeDb
|
|
178
|
-
} from "./index-
|
|
178
|
+
} from "./index-mtw9e71a.js";
|
|
179
179
|
import {
|
|
180
180
|
expandToolPart,
|
|
181
181
|
estimateTrueRawMessageTokens,
|
|
@@ -296,7 +296,7 @@ import {
|
|
|
296
296
|
readRawSessionMessageById2,
|
|
297
297
|
readSessionChunk2,
|
|
298
298
|
readRawSessionSeedTail2
|
|
299
|
-
} from "./index-
|
|
299
|
+
} from "./index-j6zw70pf.js";
|
|
300
300
|
import {
|
|
301
301
|
getMeasuredToolDefinitionTokens
|
|
302
302
|
} from "./index-n6m03s3n.js";
|
|
@@ -313,7 +313,7 @@ import {
|
|
|
313
313
|
runSqliteOptimize,
|
|
314
314
|
openDatabase,
|
|
315
315
|
openCurrentDatabase
|
|
316
|
-
} from "./index-
|
|
316
|
+
} from "./index-cj9g0j7a.js";
|
|
317
317
|
import {
|
|
318
318
|
registerOwnRpcServerInstance,
|
|
319
319
|
rpcPortDir,
|
|
@@ -503,7 +503,7 @@ import {
|
|
|
503
503
|
snapRangeToCompartments,
|
|
504
504
|
getActiveCompartmentRun,
|
|
505
505
|
startCompartmentAgent
|
|
506
|
-
} from "./index-
|
|
506
|
+
} from "./index-ayym1x7f.js";
|
|
507
507
|
import {
|
|
508
508
|
embedPauseBySession,
|
|
509
509
|
embedRunStateBySession,
|
|
@@ -531,7 +531,7 @@ import {
|
|
|
531
531
|
embedSessionCompartmentChunks2,
|
|
532
532
|
getEmbeddingCoverageStatus2,
|
|
533
533
|
getAutoEmbeddingSessionCoverage2
|
|
534
|
-
} from "./index-
|
|
534
|
+
} from "./index-qrahzcqv.js";
|
|
535
535
|
import {
|
|
536
536
|
SubcClient,
|
|
537
537
|
connectionFileExists,
|
|
@@ -560,7 +560,7 @@ import {
|
|
|
560
560
|
indexSingleMessage2,
|
|
561
561
|
indexMessagesAfterOrdinal2,
|
|
562
562
|
sweepOrphanedOpenCodeMessageIndexes2
|
|
563
|
-
} from "./index-
|
|
563
|
+
} from "./index-p4vde22c.js";
|
|
564
564
|
import {
|
|
565
565
|
renderUserFacingFailure,
|
|
566
566
|
userFacingFailureCode,
|
|
@@ -604,7 +604,7 @@ import {
|
|
|
604
604
|
readGitFileChangeTimesSince,
|
|
605
605
|
verificationFileExists,
|
|
606
606
|
normalizeVerificationFiles
|
|
607
|
-
} from "./index-
|
|
607
|
+
} from "./index-wv9n2zcq.js";
|
|
608
608
|
import {
|
|
609
609
|
registerNotificationSink2,
|
|
610
610
|
pushNotification2,
|
|
@@ -614,7 +614,7 @@ import {
|
|
|
614
614
|
} from "./index-x8a7jmkh.js";
|
|
615
615
|
import {
|
|
616
616
|
getLocalEmbeddingNativeMemoryStats
|
|
617
|
-
} from "./index-
|
|
617
|
+
} from "./index-7b2cfmaz.js";
|
|
618
618
|
import {
|
|
619
619
|
saveEmbeddingIfHashMatches,
|
|
620
620
|
invalidateProject2,
|
|
@@ -622,7 +622,7 @@ import {
|
|
|
622
622
|
} from "./index-4dhv7mqz.js";
|
|
623
623
|
import {
|
|
624
624
|
cosineSimilarity
|
|
625
|
-
} from "./index-
|
|
625
|
+
} from "./index-9nkg2dzk.js";
|
|
626
626
|
import {
|
|
627
627
|
computeCueContentHash,
|
|
628
628
|
hasMuralCueColumns,
|
|
@@ -663,23 +663,22 @@ import {
|
|
|
663
663
|
SubcModuleTransport,
|
|
664
664
|
indexCommitsForProject,
|
|
665
665
|
embedUnembeddedCommits,
|
|
666
|
-
withMessageFtsSessionFilter,
|
|
667
666
|
createUnifiedSearchDiagnostics2,
|
|
668
667
|
parseIdShapedQuery2,
|
|
669
668
|
resolveMemoriesByIdsForSearch2,
|
|
670
669
|
unifiedSearch2,
|
|
671
670
|
formatSearchResults2
|
|
672
|
-
} from "./index-
|
|
671
|
+
} from "./index-4qfy7v57.js";
|
|
673
672
|
import {
|
|
674
673
|
flushIgnoredMessages2,
|
|
675
674
|
clearIgnoredMessages2,
|
|
676
675
|
observeIgnoredNotificationEvent2,
|
|
677
676
|
sendStatusNotification2
|
|
678
|
-
} from "./index-
|
|
677
|
+
} from "./index-b17m64g9.js";
|
|
679
678
|
import {
|
|
680
679
|
setRecompStarting2,
|
|
681
680
|
setRecompTerminal2
|
|
682
|
-
} from "./index-
|
|
681
|
+
} from "./index-v63beg1z.js";
|
|
683
682
|
import {
|
|
684
683
|
makeToolCompositeKey,
|
|
685
684
|
searchMessageHistoryOffThread,
|
|
@@ -732,7 +731,7 @@ import {
|
|
|
732
731
|
abortSessionFailClosed2,
|
|
733
732
|
evaluateEmergencyFailClosed2,
|
|
734
733
|
runPostTransformPhase2
|
|
735
|
-
} from "./index-
|
|
734
|
+
} from "./index-kn4t1haw.js";
|
|
736
735
|
import {
|
|
737
736
|
ANNOUNCEMENT_VERSION2,
|
|
738
737
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -743,6 +742,9 @@ import {
|
|
|
743
742
|
import {
|
|
744
743
|
resolvePromptContext2
|
|
745
744
|
} from "./index-fmsr7v69.js";
|
|
745
|
+
import {
|
|
746
|
+
renderSearchArchiveOffThread2
|
|
747
|
+
} from "./index-6a6dq53h.js";
|
|
746
748
|
import {
|
|
747
749
|
COMPACTION_ENABLED_PATH,
|
|
748
750
|
isDreamerRunnable,
|
|
@@ -16270,8 +16272,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16270
16272
|
const db = readDatabase();
|
|
16271
16273
|
if (!db)
|
|
16272
16274
|
return { ok: false, error: "db unavailable" };
|
|
16273
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16274
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
16275
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-tjcaj5x7.js"));
|
|
16276
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-2x9edkrp.js"));
|
|
16275
16277
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
16276
16278
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
16277
16279
|
return {
|
|
@@ -16355,7 +16357,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16355
16357
|
const db = readDatabase();
|
|
16356
16358
|
if (!db)
|
|
16357
16359
|
return { ok: false, error: "db unavailable" };
|
|
16358
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16360
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-vj2tbp22.js"));
|
|
16359
16361
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
16360
16362
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
16361
16363
|
const ctx = {
|
|
@@ -17878,6 +17880,7 @@ class HistorianHostRunner {
|
|
|
17878
17880
|
timeoutMs: attemptMs,
|
|
17879
17881
|
signal,
|
|
17880
17882
|
fallbackModels: rest.map(withVariant),
|
|
17883
|
+
allowModelSuggestions: false,
|
|
17881
17884
|
callContext: `historian-host:${claim.runId}`,
|
|
17882
17885
|
fetchOutput: () => withinAttempt(executor.collect(handle, 50), attemptStartedAt + attemptMs - Date.now(), attemptMs, signal).catch((error) => {
|
|
17883
17886
|
recordAttempt(undefined, error);
|
|
@@ -23984,6 +23987,7 @@ function resolveTransformHostSeams(deps) {
|
|
|
23984
23987
|
hostRefuse: deps.hostRefuse ?? abortSessionFailClosed2
|
|
23985
23988
|
};
|
|
23986
23989
|
}
|
|
23990
|
+
var SIGNED_FIT_REFUSED_MARKER = "signed_fit:refused:v1";
|
|
23987
23991
|
function createTransform(deps) {
|
|
23988
23992
|
registerSystemDateRefresh(deps.historyRefreshSessions);
|
|
23989
23993
|
const finalWireUsage = createFinalWireUsageTracker();
|
|
@@ -24905,7 +24909,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24905
24909
|
const protectedTagIds = protectedTagNumbers;
|
|
24906
24910
|
const protectedCutoff = protectionWindow.cutoff;
|
|
24907
24911
|
const tPostProcess = performance.now();
|
|
24908
|
-
dropProjectionEmergency =
|
|
24912
|
+
dropProjectionEmergency = contextUsage.percentage >= 95;
|
|
24909
24913
|
const postTransformResult = await runPostTransformPhase2({
|
|
24910
24914
|
opencode2: deps.storeGeneration === "v2",
|
|
24911
24915
|
normalizeRecoveryTail,
|
|
@@ -24924,7 +24928,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24924
24928
|
client: deps.client,
|
|
24925
24929
|
activeAgent,
|
|
24926
24930
|
batch,
|
|
24927
|
-
contextUsage
|
|
24931
|
+
contextUsage,
|
|
24928
24932
|
usableWindow: resolvedContextLimit ?? 0,
|
|
24929
24933
|
schedulerDecision,
|
|
24930
24934
|
schedulerDeferReason,
|
|
@@ -25009,6 +25013,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25009
25013
|
postTransformResult.bustedThisPass = true;
|
|
25010
25014
|
passOutcome.markFinalized();
|
|
25011
25015
|
const finalWireTail = describeFinalWireTail(messages);
|
|
25016
|
+
const signedFitPreviouslyRefused = !compactionOff && getMergedReasoningStrippedIds(db, sessionId).has(SIGNED_FIT_REFUSED_MARKER);
|
|
25012
25017
|
let finalWireEstimate;
|
|
25013
25018
|
if (postTransformResult.bustedThisPass) {
|
|
25014
25019
|
try {
|
|
@@ -25026,7 +25031,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25026
25031
|
}
|
|
25027
25032
|
if (!compactionOff) {
|
|
25028
25033
|
const emergencyUsagePercentage = usagePercentageSynthetic ? Math.max(95, contextUsage.percentage) : windowGeometry?.usableHard && contextUsage.inputTokens > 0 ? contextUsage.inputTokens / windowGeometry.usableHard * 100 : contextUsage.percentage;
|
|
25029
|
-
finalWireEstimate = finalWireEstimate ?? (emergencyUsagePercentage >= 95 || schedulerDecision === "execute" ? finalWireUsage.estimate(sessionId, {
|
|
25034
|
+
finalWireEstimate = finalWireEstimate ?? (emergencyUsagePercentage >= 95 || schedulerDecision === "execute" || signedFitPreviouslyRefused ? finalWireUsage.estimate(sessionId, {
|
|
25030
25035
|
messages,
|
|
25031
25036
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
25032
25037
|
providerID: modelForBudget?.providerID,
|
|
@@ -25049,8 +25054,11 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25049
25054
|
}
|
|
25050
25055
|
return;
|
|
25051
25056
|
}
|
|
25052
|
-
if (thinkingFitRetries.has(sessionId) || postTransformResult.thinkingReleasedForFit)
|
|
25057
|
+
if (thinkingFitRetries.has(sessionId) || postTransformResult.thinkingReleasedForFit || signedFitPreviouslyRefused) {
|
|
25058
|
+
if (!signedFitPreviouslyRefused && !addMergedReasoningStrippedIds(db, sessionId, [SIGNED_FIT_REFUSED_MARKER]))
|
|
25059
|
+
throw contextRefusalError("Cannot persist the signed-fit refusal");
|
|
25053
25060
|
throw contextRefusalError("The request remains over the model window after stripping signed thinking and reclaiming context");
|
|
25061
|
+
}
|
|
25054
25062
|
}
|
|
25055
25063
|
if (postTransformResult.prefixTrimStatus === "refused") {
|
|
25056
25064
|
const untrimmed = finalWireEstimate ?? estimateFinalWireInputTokens({
|
|
@@ -26739,56 +26747,6 @@ function renderItemByTag(db, sessionId, number, textIndexDomain = "part") {
|
|
|
26739
26747
|
return selected ? renderPartFull(selected) ?? "" : `Tag ${number}'s original text part is no longer in stored history.`;
|
|
26740
26748
|
}
|
|
26741
26749
|
|
|
26742
|
-
// src/tools/ctx-expand/search-archive.ts
|
|
26743
|
-
function renderSearchArchive(db, sessionId, start, end, tokenBudget, archiveOnly = false) {
|
|
26744
|
-
return withMessageFtsSessionFilter(db, sessionId, (sessionFirst) => {
|
|
26745
|
-
let rawIds;
|
|
26746
|
-
const rows = db.prepare(sessionFirst ? `SELECT f.message_ordinal AS ordinal, f.message_id AS id, f.role, f.content
|
|
26747
|
-
FROM message_fts_rowid_map AS m
|
|
26748
|
-
JOIN message_history_fts AS f ON f.rowid = m.fts_rowid
|
|
26749
|
-
WHERE m.session_id = ?1 AND m.message_ordinal BETWEEN ?2 AND ?3
|
|
26750
|
-
AND f.session_id = ?1 AND f.message_ordinal BETWEEN ?2 AND ?3
|
|
26751
|
-
ORDER BY m.message_ordinal` : `SELECT message_ordinal AS ordinal, message_id AS id, role, content
|
|
26752
|
-
FROM message_history_fts
|
|
26753
|
-
WHERE session_id = ?1 AND message_ordinal BETWEEN ?2 AND ?3
|
|
26754
|
-
ORDER BY CAST(message_ordinal AS INTEGER)`);
|
|
26755
|
-
const blocks = [];
|
|
26756
|
-
let tokens = 0;
|
|
26757
|
-
let lastOrdinal = start - 1;
|
|
26758
|
-
let truncated = false;
|
|
26759
|
-
for (const row of rows.iterate(sessionId, start, end)) {
|
|
26760
|
-
if (!row.content)
|
|
26761
|
-
continue;
|
|
26762
|
-
if (!archiveOnly) {
|
|
26763
|
-
rawIds ??= readRawSessionMessageIdOrdinalsForRange2(sessionId, start, end);
|
|
26764
|
-
if (rawIds.get(row.id) === row.ordinal)
|
|
26765
|
-
continue;
|
|
26766
|
-
}
|
|
26767
|
-
const block = `[${row.ordinal}] ${row.role === "user" ? "U" : "A"}: ${row.content}`;
|
|
26768
|
-
const cost = estimateTokens(block);
|
|
26769
|
-
if (blocks.length > 0 && tokens + cost > tokenBudget) {
|
|
26770
|
-
truncated = true;
|
|
26771
|
-
break;
|
|
26772
|
-
}
|
|
26773
|
-
blocks.push(block);
|
|
26774
|
-
tokens += cost;
|
|
26775
|
-
lastOrdinal = row.ordinal;
|
|
26776
|
-
}
|
|
26777
|
-
if (blocks.length === 0)
|
|
26778
|
-
return null;
|
|
26779
|
-
const text = [
|
|
26780
|
-
"From the search archive: indexed text only; no surrounding messages or tool output.",
|
|
26781
|
-
"",
|
|
26782
|
-
...blocks
|
|
26783
|
-
];
|
|
26784
|
-
if (truncated) {
|
|
26785
|
-
text.push("", `Truncated at message ${lastOrdinal} (budget: ~${tokenBudget} tokens). Call ctx_expand(start=${lastOrdinal + 1}, end=${end}) for more archived text.`);
|
|
26786
|
-
}
|
|
26787
|
-
return text.join(`
|
|
26788
|
-
`);
|
|
26789
|
-
});
|
|
26790
|
-
}
|
|
26791
|
-
|
|
26792
26750
|
// src/tools/ctx-expand/tools.ts
|
|
26793
26751
|
var ctxExpandArgsShape = {
|
|
26794
26752
|
tag: tool.schema.union([tool.schema.number(), tool.schema.string()]).optional().describe("Tag number from a §N§ tag or a [dropped §N§] placeholder, not a message ordinal. Returns that one item in full. Use alone."),
|
|
@@ -26822,7 +26780,7 @@ function createCtxExpandTool(deps) {
|
|
|
26822
26780
|
return renderItemByTag(deps.db, sessionId, mode.tag);
|
|
26823
26781
|
}
|
|
26824
26782
|
if (mode.kind === "message") {
|
|
26825
|
-
return
|
|
26783
|
+
return await renderSearchArchiveOffThread2(deps.db, sessionId, mode.message, mode.message, CTX_EXPAND_TOKEN_BUDGET) ?? renderMessageByOrdinal(sessionId, mode.message);
|
|
26826
26784
|
}
|
|
26827
26785
|
const { start, end, verbose } = mode;
|
|
26828
26786
|
const lastCompartmentEnd = getLastCompartmentEndMessage(deps.db, sessionId);
|
|
@@ -26830,7 +26788,7 @@ function createCtxExpandTool(deps) {
|
|
|
26830
26788
|
return `Range ${start}-${end} is entirely within the live tail (after the last compacted message ${lastCompartmentEnd}); those messages are already visible in context.`;
|
|
26831
26789
|
}
|
|
26832
26790
|
const effectiveEnd = lastCompartmentEnd >= 0 ? Math.min(end, lastCompartmentEnd) : end;
|
|
26833
|
-
const archived =
|
|
26791
|
+
const archived = await renderSearchArchiveOffThread2(deps.db, sessionId, start, effectiveEnd, CTX_EXPAND_TOKEN_BUDGET);
|
|
26834
26792
|
if (archived)
|
|
26835
26793
|
return archived;
|
|
26836
26794
|
if (verbose) {
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
isSynapseEmbeddingTruncated
|
|
13
13
|
} from "./index-fkx2qnvw.js";
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
} from "./index-
|
|
15
|
+
messageFtsOrdinalRangeIsMapped2
|
|
16
|
+
} from "./index-dqe8pq4x.js";
|
|
17
17
|
|
|
18
18
|
// src/features/magic-context/compartment-chunk-embedding.ts
|
|
19
19
|
import { createHash } from "node:crypto";
|
|
@@ -514,7 +514,7 @@ function toFloat32Array(blob) {
|
|
|
514
514
|
function buildCanonicalChunkTextFromFts(db, sessionId, startOrdinal, endOrdinal) {
|
|
515
515
|
if (endOrdinal < startOrdinal)
|
|
516
516
|
return "";
|
|
517
|
-
if (!
|
|
517
|
+
if (!messageFtsOrdinalRangeIsMapped2(db, sessionId, startOrdinal, endOrdinal))
|
|
518
518
|
return null;
|
|
519
519
|
const rows = getLoadFtsRowsStatement(db).all(sessionId, startOrdinal, endOrdinal).map((row) => row);
|
|
520
520
|
const lines = [];
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
TAG_SELECT_COLUMNS2,
|
|
24
24
|
getCandidateToolOwners2,
|
|
25
25
|
pickNearestPriorOwner2
|
|
26
|
-
} from "./index-
|
|
26
|
+
} from "./index-nd7m2a5a.js";
|
|
27
27
|
import {
|
|
28
28
|
OMO_INTERNAL_INITIATOR_MARKER,
|
|
29
29
|
isSystemDirective,
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
renderToolTemplate,
|
|
52
52
|
resolveModelConfigValue,
|
|
53
53
|
deriveDefaultProtectedTokens
|
|
54
|
-
} from "./index-
|
|
54
|
+
} from "./index-wgypt3cs.js";
|
|
55
55
|
import {
|
|
56
56
|
readRawSessionMessagesFromDb2,
|
|
57
57
|
readRawSessionMessagePageFromDb2,
|
|
@@ -68,13 +68,13 @@ import {
|
|
|
68
68
|
readRawSeedTailFromDb2,
|
|
69
69
|
readRawSessionBoundaryEndpointsFromDb2,
|
|
70
70
|
prewarmRawSessionOrdinalsForDb
|
|
71
|
-
} from "./index-
|
|
71
|
+
} from "./index-7pa32z07.js";
|
|
72
72
|
import {
|
|
73
73
|
openCodeDbExists,
|
|
74
74
|
withReadOnlySessionDb,
|
|
75
75
|
getRawSessionMessageCountFromDb,
|
|
76
76
|
getMessageTimesFromOpenCodeDb
|
|
77
|
-
} from "./index-
|
|
77
|
+
} from "./index-mtw9e71a.js";
|
|
78
78
|
import {
|
|
79
79
|
getToolDefinitionMeasurementSignature,
|
|
80
80
|
getLargestMeasuredToolDefinitionTokens,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/features/magic-context/message-fts-session-filter.ts
|
|
2
|
+
var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
|
|
3
|
+
SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
|
|
4
|
+
) AND `;
|
|
5
|
+
var coverageCaches = new WeakMap;
|
|
6
|
+
var coverageScansOnThisThread = 0;
|
|
7
|
+
function getCoverageCache(db) {
|
|
8
|
+
let cache = coverageCaches.get(db);
|
|
9
|
+
if (!cache) {
|
|
10
|
+
cache = {
|
|
11
|
+
pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
|
|
12
|
+
stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
|
|
13
|
+
missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
|
|
14
|
+
FROM message_history_fts WHERE rowid IN (
|
|
15
|
+
SELECT id FROM message_history_fts_docsize
|
|
16
|
+
EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
|
|
17
|
+
)`)
|
|
18
|
+
};
|
|
19
|
+
coverageCaches.set(db, cache);
|
|
20
|
+
}
|
|
21
|
+
return cache;
|
|
22
|
+
}
|
|
23
|
+
function withMessageFtsSessionFilter(db, sessionId, read) {
|
|
24
|
+
let cacheable = false;
|
|
25
|
+
try {
|
|
26
|
+
const transaction = db;
|
|
27
|
+
cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
|
|
28
|
+
if (!cacheable)
|
|
29
|
+
coverageCaches.delete(db);
|
|
30
|
+
} catch {
|
|
31
|
+
coverageCaches.delete(db);
|
|
32
|
+
}
|
|
33
|
+
return db.transaction(() => {
|
|
34
|
+
let sessionFirst = false;
|
|
35
|
+
try {
|
|
36
|
+
const cache = getCoverageCache(db);
|
|
37
|
+
cache.pin.get();
|
|
38
|
+
const stamp = cache.stamp.get();
|
|
39
|
+
let incomplete = cache.incompleteSessions;
|
|
40
|
+
if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
|
|
41
|
+
coverageScansOnThisThread += 1;
|
|
42
|
+
const rows = cache.missing.all();
|
|
43
|
+
incomplete = new Set(rows.map((row) => row.sessionId));
|
|
44
|
+
if (cacheable) {
|
|
45
|
+
cache.version = stamp.version;
|
|
46
|
+
cache.changes = stamp.changes;
|
|
47
|
+
cache.incompleteSessions = incomplete;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
sessionFirst = !incomplete.has(sessionId);
|
|
51
|
+
} catch {
|
|
52
|
+
coverageCaches.delete(db);
|
|
53
|
+
}
|
|
54
|
+
return read(sessionFirst);
|
|
55
|
+
}).deferred();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { MESSAGE_FTS_SESSION_FILTER_SQL, withMessageFtsSessionFilter };
|
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
adoptNullOwnerToolTag2,
|
|
72
72
|
getCandidateToolOwners2,
|
|
73
73
|
pickNearestPriorOwner2
|
|
74
|
-
} from "./index-
|
|
74
|
+
} from "./index-nd7m2a5a.js";
|
|
75
75
|
import {
|
|
76
76
|
textMentionsRecentCommit,
|
|
77
77
|
hasMeaningfulUserText2,
|
|
@@ -90,12 +90,15 @@ import {
|
|
|
90
90
|
} from "./index-wafzvyhg.js";
|
|
91
91
|
import {
|
|
92
92
|
isValidLanguageCode
|
|
93
|
-
} from "./index-
|
|
93
|
+
} from "./index-wgypt3cs.js";
|
|
94
|
+
import {
|
|
95
|
+
runSessionWarmupWorker
|
|
96
|
+
} from "./index-7pa32z07.js";
|
|
94
97
|
import {
|
|
95
98
|
getProjectEmbeddingSnapshot2,
|
|
96
99
|
embedTextForProject2,
|
|
97
100
|
embedBatchForProject2
|
|
98
|
-
} from "./index-
|
|
101
|
+
} from "./index-qrahzcqv.js";
|
|
99
102
|
import {
|
|
100
103
|
isEmbeddingHostBusy2
|
|
101
104
|
} from "./index-qt1qqasc.js";
|
|
@@ -193,7 +196,7 @@ import {
|
|
|
193
196
|
extractToolCallObservation,
|
|
194
197
|
ToolMutationBatch,
|
|
195
198
|
createToolDropTarget
|
|
196
|
-
} from "./index-
|
|
199
|
+
} from "./index-j6zw70pf.js";
|
|
197
200
|
import {
|
|
198
201
|
getMaxM0MutationId,
|
|
199
202
|
rememberUnpublishedAutoSearchNoHint,
|
|
@@ -228,21 +231,18 @@ import {
|
|
|
228
231
|
peekNoteNudgeText,
|
|
229
232
|
markNoteNudgeDelivered,
|
|
230
233
|
getActiveCompartmentRun
|
|
231
|
-
} from "./index-
|
|
232
|
-
import {
|
|
233
|
-
runSessionWarmupWorker
|
|
234
|
-
} from "./index-mmfa86mt.js";
|
|
234
|
+
} from "./index-ayym1x7f.js";
|
|
235
235
|
import {
|
|
236
236
|
openCodeDbExists,
|
|
237
237
|
withReadOnlySessionDb,
|
|
238
238
|
getMessageTimesFromOpenCodeDb
|
|
239
|
-
} from "./index-
|
|
239
|
+
} from "./index-mtw9e71a.js";
|
|
240
240
|
import {
|
|
241
241
|
BoundedSessionMap
|
|
242
|
-
} from "./index-
|
|
242
|
+
} from "./index-p4vde22c.js";
|
|
243
243
|
import {
|
|
244
244
|
userFacingFailureCode
|
|
245
|
-
} from "./index-
|
|
245
|
+
} from "./index-wv9n2zcq.js";
|
|
246
246
|
import {
|
|
247
247
|
normalizeProtectedToolName,
|
|
248
248
|
mergeProtectedTools
|
|
@@ -5483,6 +5483,9 @@ async function runPostTransformPhase2(args) {
|
|
|
5483
5483
|
rewritingSignedPrefix = true;
|
|
5484
5484
|
thinkingReleasedForFit ||= forFit;
|
|
5485
5485
|
};
|
|
5486
|
+
if (activeThinkingPrefixHold && args.forceSignedRebuildForFit) {
|
|
5487
|
+
releaseThinkingForRewrite(true);
|
|
5488
|
+
}
|
|
5486
5489
|
const foldDueDecision = m0M1EnabledForFold && args.m0M1 && !freezeM0M1 ? mustMaterialize({
|
|
5487
5490
|
db: args.db,
|
|
5488
5491
|
sessionId: args.sessionId,
|
|
@@ -5627,7 +5630,7 @@ async function runPostTransformPhase2(args) {
|
|
|
5627
5630
|
const idleExpiryRebuild = (!freezeM0M1 || activeThinkingPrefixHold) && args.m0M1?.hardSignals?.cacheExpired === true;
|
|
5628
5631
|
const rideSignals = {
|
|
5629
5632
|
subagentExecute: !args.fullFeatureMode && args.schedulerDecision === "execute",
|
|
5630
|
-
hardFold: foldBustsServedPrefixThisPass || firstRenderBust || idleExpiryRebuild,
|
|
5633
|
+
hardFold: rewritingSignedPrefix || foldBustsServedPrefixThisPass || firstRenderBust || idleExpiryRebuild,
|
|
5631
5634
|
force: emergencyDropEligible && (args.contextUsage.percentage >= 95 || getEmergencyInputSample(args.db, args.sessionId) === 0),
|
|
5632
5635
|
explicitFlush: isExplicitFlush && hasPendingMaterializationOrigin(args.pendingMaterializationSessions, args.sessionId, "user_flush"),
|
|
5633
5636
|
publishedHistory: !prefixPreflightFailed && (publishedM1RefreshedThisPass || !m0M1EnabledForFold && (args.pendingCompartmentInjection?.compartmentCount ?? 0) > 0 && legacyPublishedHeadChanged(args))
|
|
@@ -2039,9 +2039,11 @@ function planEmergencyDrop(input) {
|
|
|
2039
2039
|
const workingSpan = Math.max(ceilingTokens - fixedFloor, 0);
|
|
2040
2040
|
const target = fixedFloor + TARGET_FRACTION * workingSpan;
|
|
2041
2041
|
const reclaimTokens = Math.round(currentTotalInputTokens - target);
|
|
2042
|
-
|
|
2042
|
+
if (fixedFloor > ceilingTokens) {
|
|
2043
|
+
return noop(`fixed floor ≈${Math.round(fixedFloor)} already exceeds ceiling ${Math.round(ceilingTokens)}: tool drops cannot reach the target`);
|
|
2044
|
+
}
|
|
2043
2045
|
if (reclaimTokens <= EMERGENCY_REARM_MIN_TOKENS) {
|
|
2044
|
-
return noop(`reclaim<=min (${reclaimTokens} <= ${EMERGENCY_REARM_MIN_TOKENS})
|
|
2046
|
+
return noop(`reclaim<=min (${reclaimTokens} <= ${EMERGENCY_REARM_MIN_TOKENS})`);
|
|
2045
2047
|
}
|
|
2046
2048
|
const cutoff = input.protectedCutoff;
|
|
2047
2049
|
const windowYields = absoluteEmergency;
|
|
@@ -2096,16 +2098,16 @@ function planEmergencyDrop(input) {
|
|
|
2096
2098
|
}
|
|
2097
2099
|
}
|
|
2098
2100
|
if (selected.length === 0) {
|
|
2099
|
-
return noop(
|
|
2101
|
+
return noop("no-candidates");
|
|
2100
2102
|
}
|
|
2101
2103
|
if (!input.passAlreadyPriced && reclaimed < EMERGENCY_MIN_ACHIEVABLE_RECLAIM_TOKENS) {
|
|
2102
|
-
return noop(`achievable reclaim below minimum (${selected.length} tags, reclaim≈${Math.round(reclaimed)} < ${EMERGENCY_MIN_ACHIEVABLE_RECLAIM_TOKENS} against gap ${reclaimTokens})
|
|
2104
|
+
return noop(`achievable reclaim below minimum (${selected.length} tags, reclaim≈${Math.round(reclaimed)} < ${EMERGENCY_MIN_ACHIEVABLE_RECLAIM_TOKENS} against gap ${reclaimTokens})`);
|
|
2103
2105
|
}
|
|
2104
2106
|
return {
|
|
2105
2107
|
shouldDrop: true,
|
|
2106
2108
|
tagNumbers: selected,
|
|
2107
2109
|
reclaimTokens,
|
|
2108
|
-
reason: `tiered drop: ${selected.length} tags, reclaim≈${reclaimed}/${reclaimTokens} tokens (floor≈${fixedFloor}, ceiling=${Math.round(ceilingTokens)})
|
|
2110
|
+
reason: `tiered drop: ${selected.length} tags, reclaim≈${reclaimed}/${reclaimTokens} tokens (floor≈${fixedFloor}, ceiling=${Math.round(ceilingTokens)})`
|
|
2109
2111
|
};
|
|
2110
2112
|
}
|
|
2111
2113
|
function measureEmergencyTag(tag, target, calibration, skeleton) {
|
|
@@ -23,20 +23,20 @@ import {
|
|
|
23
23
|
} from "./index-wafzvyhg.js";
|
|
24
24
|
import {
|
|
25
25
|
cleanUserText2
|
|
26
|
-
} from "./index-
|
|
26
|
+
} from "./index-j6zw70pf.js";
|
|
27
27
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} from "./index-
|
|
28
|
+
recordMessageFtsRowid2,
|
|
29
|
+
recordIndexedMessageTime2,
|
|
30
|
+
messageFtsOrdinalRangeIsMapped2,
|
|
31
|
+
deleteUnmappedMessageFtsRows2
|
|
32
|
+
} from "./index-dqe8pq4x.js";
|
|
33
33
|
import {
|
|
34
34
|
isPidAlive,
|
|
35
35
|
readProcessStartTime
|
|
36
36
|
} from "./index-nj7yykkx.js";
|
|
37
37
|
import {
|
|
38
38
|
deleteChunkEmbedBackoffForSession
|
|
39
|
-
} from "./index-
|
|
39
|
+
} from "./index-hehkf6zm.js";
|
|
40
40
|
import {
|
|
41
41
|
closeQuietly
|
|
42
42
|
} from "./index-8ajstryz.js";
|
|
@@ -680,7 +680,7 @@ function deleteSessionScopedRows(db, sessionIds, harness, options = {}) {
|
|
|
680
680
|
FROM message_fts_rowid_map
|
|
681
681
|
WHERE session_id IN (${placeholders})
|
|
682
682
|
)`).run(...deletableSessionIds);
|
|
683
|
-
|
|
683
|
+
deleteUnmappedMessageFtsRows2(db, deletableSessionIds);
|
|
684
684
|
continue;
|
|
685
685
|
}
|
|
686
686
|
const predicates = [`session_id IN (${placeholders})`];
|
|
@@ -927,7 +927,7 @@ function getDeleteMessageFtsMapStatement(db) {
|
|
|
927
927
|
}
|
|
928
928
|
function insertMessageFtsRow(db, sessionId, messageOrdinal, messageId, role, content, messageTimeMs) {
|
|
929
929
|
const result = getInsertMessageStatement(db).run(sessionId, messageOrdinal, messageId, role, content);
|
|
930
|
-
|
|
930
|
+
recordMessageFtsRowid2(db, sessionId, messageOrdinal, result.lastInsertRowid, messageTimeMs ?? null);
|
|
931
931
|
}
|
|
932
932
|
function normalizeSourceVersion(version) {
|
|
933
933
|
if (typeof version === "number")
|
|
@@ -1027,7 +1027,7 @@ function deleteIndexedMessage2(db, sessionId, messageId) {
|
|
|
1027
1027
|
function clearIndexedMessagesInTransaction2(db, sessionId) {
|
|
1028
1028
|
deleteMessageIndexSkips(db, sessionId);
|
|
1029
1029
|
getDeleteFtsStatement(db).run(sessionId);
|
|
1030
|
-
|
|
1030
|
+
deleteUnmappedMessageFtsRows2(db, [sessionId]);
|
|
1031
1031
|
getDeleteFtsMapStatement(db).run(sessionId);
|
|
1032
1032
|
getDeleteMessageSourceStatement(db).run(sessionId);
|
|
1033
1033
|
getDeleteIndexStatement(db).run(sessionId);
|
|
@@ -1058,10 +1058,10 @@ function indexSingleMessageInTransaction(db, sessionId, message, now, dirtyFloor
|
|
|
1058
1058
|
const dirtyFloor = getDirtyIndexFloor(db, sessionId);
|
|
1059
1059
|
if (message.ordinal <= currentWatermark) {
|
|
1060
1060
|
if (isIndexSourceCurrent(db, sessionId, source)) {
|
|
1061
|
-
|
|
1061
|
+
recordIndexedMessageTime2(db, sessionId, message.ordinal, message.createdAt);
|
|
1062
1062
|
return false;
|
|
1063
1063
|
}
|
|
1064
|
-
if (!
|
|
1064
|
+
if (!messageFtsOrdinalRangeIsMapped2(db, sessionId, message.ordinal, message.ordinal)) {
|
|
1065
1065
|
return false;
|
|
1066
1066
|
}
|
|
1067
1067
|
getDeleteMessageFtsStatement(db).run(sessionId, message.id);
|
|
@@ -1091,7 +1091,7 @@ function indexSingleMessage2(db, sessionId, message, shouldCommit = () => true,
|
|
|
1091
1091
|
const source = preparedSource ?? getMessageSourceSnapshot(message);
|
|
1092
1092
|
const currentWatermark = getLastIndexedOrdinal2(db, sessionId);
|
|
1093
1093
|
if (message.ordinal <= currentWatermark && isIndexSourceCurrent(db, sessionId, source)) {
|
|
1094
|
-
|
|
1094
|
+
recordIndexedMessageTime2(db, sessionId, message.ordinal, message.createdAt);
|
|
1095
1095
|
return false;
|
|
1096
1096
|
}
|
|
1097
1097
|
const dirtyFloorBeforeAttempt = getDirtyIndexFloor(db, sessionId);
|
|
@@ -1132,7 +1132,7 @@ function indexItemsAfterOrdinal(db, sessionId, items, finalWatermark, toSource)
|
|
|
1132
1132
|
const currentWatermark = getLastIndexedOrdinal2(db, sessionId);
|
|
1133
1133
|
const dirtyFloor = getDirtyIndexFloor(db, sessionId);
|
|
1134
1134
|
const effectiveWatermark = dirtyFloor === null ? currentWatermark : Math.min(currentWatermark, Math.max(0, dirtyFloor - 1));
|
|
1135
|
-
if (dirtyFloor !== null && dirtyFloor <= currentWatermark && !
|
|
1135
|
+
if (dirtyFloor !== null && dirtyFloor <= currentWatermark && !messageFtsOrdinalRangeIsMapped2(db, sessionId, dirtyFloor, Math.min(currentWatermark, finalWatermark))) {
|
|
1136
1136
|
db.exec("COMMIT");
|
|
1137
1137
|
committed = true;
|
|
1138
1138
|
logSlowWriteTransaction("message_index_reconcile", transactionStartedAt);
|
|
@@ -38,17 +38,17 @@ import {
|
|
|
38
38
|
countSessionCompartmentEmbedCoverage,
|
|
39
39
|
countSessionCompartmentEmbedCoveragePolite,
|
|
40
40
|
countUnembeddedSessionCompartmentsPolite
|
|
41
|
-
} from "./index-
|
|
41
|
+
} from "./index-hehkf6zm.js";
|
|
42
42
|
import {
|
|
43
43
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-wgypt3cs.js";
|
|
45
45
|
import {
|
|
46
46
|
embeddingModelsMatch,
|
|
47
47
|
resolveEmbeddingTextPrefixes,
|
|
48
48
|
getEmbeddingProviderIdentity,
|
|
49
49
|
dominantEmbeddingFailure,
|
|
50
50
|
LocalEmbeddingProvider
|
|
51
|
-
} from "./index-
|
|
51
|
+
} from "./index-7b2cfmaz.js";
|
|
52
52
|
import {
|
|
53
53
|
setBootQuietPeriodForTests
|
|
54
54
|
} from "./index-a8bvhwqs.js";
|
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
} from "./index-j75v2476.js";
|
|
4
4
|
import {
|
|
5
5
|
clearEmergencyRecovery
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-j6zw70pf.js";
|
|
7
7
|
import {
|
|
8
8
|
requestPendingMaterialization,
|
|
9
9
|
dropSlot,
|
|
10
10
|
executeContextRecomp
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-ayym1x7f.js";
|
|
12
12
|
import {
|
|
13
13
|
renderUserFacingFailure,
|
|
14
14
|
userFacingFailureCode
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-wv9n2zcq.js";
|
|
16
16
|
|
|
17
17
|
// src/hooks/magic-context/recomp-orchestrator.ts
|
|
18
18
|
function resolveLiveModelKey(liveSessionState, sessionId) {
|