@cortexkit/opencode-magic-context 0.49.43 → 0.49.45
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 +4 -4
- package/dist/chunk-embedding-write-worker.js +7 -7
- package/dist/{compaction-marker-candidates-5c44h1m9.js → compaction-marker-candidates-dkfp1q9j.js} +12 -2
- package/dist/compaction-marker-candidates-worker.js +5 -2
- package/dist/{compartment-chunk-embedding-ypktm0tk.js → compartment-chunk-embedding-snj51nmg.js} +5 -5
- package/dist/{conflict-warning-hook-b75jn458.js → conflict-warning-hook-w1aw6w5t.js} +4 -4
- package/dist/{context-zf1yj1g0.js → context-y85dvs6j.js} +28 -28
- package/dist/{embedding-backfill-rma0v2ct.js → embedding-backfill-kpy5shsa.js} +9 -9
- package/dist/embedding-worker.js +4 -4
- package/dist/features/magic-context/compaction-marker-candidates.d.ts +57 -4
- package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -1
- package/dist/features/magic-context/compaction-marker.d.ts +18 -3
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-query-deadline.d.ts +8 -0
- package/dist/features/magic-context/memory/embedding-query-deadline.d.ts.map +1 -0
- package/dist/features/magic-context/overflow-detection.d.ts +16 -6
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/scheduler.d.ts.map +1 -1
- package/dist/hooks/auto-update-checker/index.d.ts +6 -0
- package/dist/hooks/auto-update-checker/index.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts +5 -4
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts +4 -4
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +7 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-publication.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +7 -2
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/local-wire-reading.d.ts +54 -0
- package/dist/hooks/magic-context/local-wire-reading.d.ts.map +1 -0
- package/dist/hooks/magic-context/read-session-formatting.d.ts +2 -1
- package/dist/hooks/magic-context/read-session-formatting.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-date-refresh.d.ts +1 -2
- package/dist/hooks/magic-context/system-date-refresh.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-context-state.d.ts +38 -6
- package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +5 -2
- 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-ayk4we2k.js → index-0a79y98x.js} +41 -31
- package/dist/{index-jggt5gf2.js → index-1hwn96x1.js} +1 -1
- package/dist/{index-ae1ar4v1.js → index-25ka1jza.js} +1 -1
- package/dist/{index-c5dzns43.js → index-4dpvnp8k.js} +1 -1
- package/dist/{index-n8bsqg7b.js → index-7na94cjf.js} +3 -3
- package/dist/{index-fas76dft.js → index-980brvjr.js} +8 -8
- package/dist/{index-4xyjr62e.js → index-ak11t3gm.js} +4 -0
- package/dist/{index-vd2ywmfe.js → index-brj6was5.js} +1 -1
- package/dist/{index-gsqz39wk.js → index-bzq05g00.js} +3 -3
- package/dist/{index-ty4vhe4n.js → index-d4qw2h43.js} +4 -4
- package/dist/{index-5m2azs6v.js → index-dcdvyaeh.js} +4 -4
- package/dist/{index-g4t7850m.js → index-dj2p8653.js} +1 -1
- package/dist/{index-adt3jghq.js → index-fs3zfby1.js} +169 -61
- package/dist/{index-xjw9rres.js → index-gf1vx3bn.js} +3 -3
- package/dist/{index-3w1pbn85.js → index-gn6gfz4y.js} +64 -12
- package/dist/{index-8jjjmhab.js → index-gxqr0sbd.js} +1 -1
- package/dist/{index-b1ydbp95.js → index-h9m41624.js} +1 -1
- package/dist/{index-xd2p95m7.js → index-hkh8x221.js} +2 -2
- package/dist/{index-rdx17j04.js → index-jwa5t1s4.js} +6 -6
- package/dist/{index-dcjkw41m.js → index-qcz1fy7h.js} +3 -3
- package/dist/{index-1zv08avf.js → index-qdx8dq60.js} +5 -5
- package/dist/{index-z6v8086q.js → index-rk5hyc41.js} +5 -5
- package/dist/{index-21fgrfrf.js → index-s79g172v.js} +64 -22
- package/dist/{index-xnm0wq1r.js → index-sd2s4t4p.js} +1 -1
- package/dist/{index-jkanybgq.js → index-smtbdmc3.js} +1 -1
- package/dist/{index-p2e7j9p1.js → index-tvd2j34s.js} +2 -2
- package/dist/{index-zqsp3z0d.js → index-wwg1je98.js} +9 -6
- package/dist/{index-r2epb000.js → index-xa9mmq6c.js} +2 -1
- package/dist/{index-xmqj3cf5.js → index-xejh7cqv.js} +136 -63
- package/dist/{index-kfsqk1q7.js → index-z8dacvkt.js} +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -40
- package/dist/{message-fts-rowid-map-t6qsyg9s.js → message-fts-rowid-map-msffhkve.js} +2 -2
- package/dist/{message-index-bounded-5mj8p6nq.js → message-index-bounded-d8xt6q5c.js} +9 -9
- package/dist/migration-worker.js +5 -5
- package/dist/{project-embedding-registry-3yyegjma.js → project-embedding-registry-r6xfsrbe.js} +8 -8
- package/dist/raw-ordinal-warmup-worker.js +7 -7
- package/dist/{read-session-chunk-k70bhfjm.js → read-session-chunk-k3fqshw8.js} +7 -7
- package/dist/{read-session-raw-j7c9w57v.js → read-session-raw-x7a9b3jm.js} +1 -1
- package/dist/{recomp-orchestrator-2q4rmerf.js → recomp-orchestrator-y75thsc3.js} +21 -21
- package/dist/{render-36fvvwz6.js → render-3psbedzk.js} +14 -14
- package/dist/{search-archive-jwb2ctnq.js → search-archive-rvr7j5gx.js} +9 -9
- package/dist/{search-6v2na3af.js → search-hd16c8gq.js} +17 -17
- package/dist/{send-session-notification-14p3yje4.js → send-session-notification-j93pn2hn.js} +3 -3
- package/dist/shared/status-view.d.ts.map +1 -1
- package/dist/{storage-tags-vj0yj7ed.js → storage-tags-ye9aqrqy.js} +2 -2
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-0ms3ga4h.js → transform-postprocess-phase-1rzxmkhb.js} +22 -22
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/chunk-embedding-write-worker.js +7 -7
- package/dist/v2/compaction-marker-candidates-worker.js +5 -2
- package/dist/v2/{compaction-marker-candidates-jy65jt49.js → compaction-marker-candidates-y737qb1v.js} +12 -2
- package/dist/v2/{compartment-chunk-embedding-qfk791bd.js → compartment-chunk-embedding-nj5nrnbj.js} +5 -5
- package/dist/v2/{context-2xr6vbt2.js → context-0e946t63.js} +194 -76
- package/dist/v2/{embedding-backfill-00tw59rx.js → embedding-backfill-360efh1t.js} +9 -9
- package/dist/v2/embedding-worker.js +4 -4
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-fts-rowid-map-z86avy0n.js → message-fts-rowid-map-qe7cpksd.js} +2 -2
- package/dist/v2/{message-index-bounded-5341qsqd.js → message-index-bounded-wt64v2rn.js} +8 -8
- package/dist/v2/migration-worker.js +5 -5
- package/dist/v2/{project-embedding-registry-jqq2qeqb.js → project-embedding-registry-ek0cy0d5.js} +8 -8
- package/dist/v2/raw-ordinal-warmup-worker.js +7 -7
- package/dist/v2/{read-session-chunk-dgmq3ntm.js → read-session-chunk-4b31z6bz.js} +6 -6
- package/dist/v2/{read-session-raw-qpp6x9kg.js → read-session-raw-yss2ev98.js} +1 -1
- package/dist/v2/{recomp-orchestrator-2vmyhtst.js → recomp-orchestrator-6qrm2nea.js} +19 -19
- package/dist/v2/{render-kz0f40ws.js → render-f8mw16pp.js} +13 -13
- package/dist/v2/{search-archive-wajxd01m.js → search-archive-7d0xdp54.js} +8 -8
- package/dist/v2/{search-a9hwy1sw.js → search-ecjd7e50.js} +15 -15
- package/dist/v2/{send-session-notification-kxp47tsw.js → send-session-notification-na3q825m.js} +1 -1
- package/dist/v2/{server-09td1wgc.js → server-0ymsgh0j.js} +3 -3
- package/dist/v2/{server-nmyganc8.js → server-131h608x.js} +1 -1
- package/dist/v2/{server-7acq7815.js → server-2gjqhmn9.js} +64 -22
- package/dist/v2/{server-xy7w7hrd.js → server-2j87594q.js} +1 -1
- package/dist/v2/{server-7qc9tk6z.js → server-2qyfev3b.js} +5 -5
- package/dist/v2/{server-qehn6btp.js → server-39kzpp8q.js} +4 -4
- package/dist/v2/{server-969cdpmg.js → server-7vb38e51.js} +4 -0
- package/dist/v2/{server-sfcp13bn.js → server-an1ff8d8.js} +3 -3
- package/dist/v2/{server-tnzbk64q.js → server-b3r080cm.js} +2 -1
- package/dist/v2/{server-zzgtgqmd.js → server-ddw42d76.js} +1 -1
- package/dist/v2/{server-3m7p4g9w.js → server-ftyc8awt.js} +3 -3
- package/dist/v2/{server-xfjjbrkt.js → server-gwqfwtzq.js} +1 -1
- package/dist/v2/{server-dwpgzm0t.js → server-gwxys0d0.js} +64 -12
- package/dist/v2/{server-dqs8e4yt.js → server-hq7fdqfm.js} +7 -7
- package/dist/v2/{server-7zacmty5.js → server-p9s40wfa.js} +1 -1
- package/dist/v2/{server-nq3cb7be.js → server-pej5rnye.js} +1 -1
- package/dist/v2/{server-6vzh6wej.js → server-sg2qjkrb.js} +2 -2
- package/dist/v2/{server-gkse1wyz.js → server-sr8tf5dt.js} +4 -4
- package/dist/v2/{server-avdveykk.js → server-vjhk8v41.js} +1 -1
- package/dist/v2/{server-kqrpt2ht.js → server-vnpnmrsv.js} +8 -5
- package/dist/v2/{server-p78wdf43.js → server-wbxbk3za.js} +3 -3
- package/dist/v2/{server-cp1a03vc.js → server-y8n33d9j.js} +3 -3
- package/dist/v2/{server-5ydn39x3.js → server-zqzh2ybj.js} +135 -62
- package/dist/v2/server.js +4 -4
- package/dist/v2/{storage-tags-cw07ky67.js → storage-tags-8nttt1sk.js} +2 -2
- package/dist/v2/{v2-archive-reader-ag6sk771.js → v2-archive-reader-53kp5mme.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-2a077zew.js → wrapup-orchestrator-bng0dfxy.js} +19 -19
- package/dist/{v2-archive-reader-chk95syc.js → v2-archive-reader-0fcxs5e9.js} +1 -1
- package/dist/{wrapup-orchestrator-rhs675kj.js → wrapup-orchestrator-r5cqgyrg.js} +22 -22
- package/package.json +1 -1
- package/src/config/schema/magic-context.ts +1 -1
- package/src/shared/status-view.ts +3 -5
- package/src/tui/dialogs/status-dialog-render.test.ts +1 -1
|
@@ -147,7 +147,7 @@ import {
|
|
|
147
147
|
updateUserMemoryContent,
|
|
148
148
|
dismissUserMemory,
|
|
149
149
|
getOpenCodeDbPath,
|
|
150
|
-
|
|
150
|
+
startCompactionMarkerCandidatePreparation,
|
|
151
151
|
removeMcOwnedCompactionMarkers,
|
|
152
152
|
MARKER_SUMMARY_TEXT,
|
|
153
153
|
markerUpdateDefinitelyDidNotCut,
|
|
@@ -191,7 +191,7 @@ import {
|
|
|
191
191
|
snapRangeToCompartments,
|
|
192
192
|
getActiveCompartmentRun,
|
|
193
193
|
startCompartmentAgent
|
|
194
|
-
} from "./index-
|
|
194
|
+
} from "./index-xejh7cqv.js";
|
|
195
195
|
import {
|
|
196
196
|
hasTrustedAbsoluteWall,
|
|
197
197
|
applyProvenInputFloor,
|
|
@@ -217,7 +217,7 @@ import {
|
|
|
217
217
|
estimateTokens,
|
|
218
218
|
estimateFixedPromptTokens,
|
|
219
219
|
normalizeText
|
|
220
|
-
} from "./index-
|
|
220
|
+
} from "./index-ak11t3gm.js";
|
|
221
221
|
import {
|
|
222
222
|
protectedToolTokenCount,
|
|
223
223
|
peelLeadingMcTagNotation,
|
|
@@ -254,7 +254,7 @@ import {
|
|
|
254
254
|
getTagsByNumbers2,
|
|
255
255
|
getDroppedTagsByNumbers2,
|
|
256
256
|
getMaxDroppedTagNumber2
|
|
257
|
-
} from "./index-
|
|
257
|
+
} from "./index-gxqr0sbd.js";
|
|
258
258
|
import {
|
|
259
259
|
observeTemporalDecisions,
|
|
260
260
|
stableStringify
|
|
@@ -278,14 +278,14 @@ import {
|
|
|
278
278
|
DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
279
279
|
DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
280
280
|
DREAM_TASK_PROMOTION_DEFAULTS
|
|
281
|
-
} from "./index-
|
|
281
|
+
} from "./index-4dpvnp8k.js";
|
|
282
282
|
import {
|
|
283
283
|
areRustHistorianSyntheticParts2,
|
|
284
284
|
isRawCompactionSummaryInfo2,
|
|
285
285
|
extractInMemoryMessageViews2,
|
|
286
286
|
buildInMemoryTailRawMessages2,
|
|
287
287
|
RawOrdinalsNotReady2
|
|
288
|
-
} from "./index-
|
|
288
|
+
} from "./index-xa9mmq6c.js";
|
|
289
289
|
import {
|
|
290
290
|
openCodeDbExists,
|
|
291
291
|
withReadOnlySessionDb,
|
|
@@ -293,7 +293,7 @@ import {
|
|
|
293
293
|
latestPersistedMessageForRecovery,
|
|
294
294
|
latestRealUserTurnIdFromOpenCodeDb,
|
|
295
295
|
findLastAssistantModelFromOpenCodeDb
|
|
296
|
-
} from "./index-
|
|
296
|
+
} from "./index-brj6was5.js";
|
|
297
297
|
import {
|
|
298
298
|
askAnswerLines,
|
|
299
299
|
estimateTrueRawMessageTokens,
|
|
@@ -416,11 +416,11 @@ import {
|
|
|
416
416
|
readRawSessionMessageById2,
|
|
417
417
|
readSessionChunk2,
|
|
418
418
|
readRawSessionSeedTail2
|
|
419
|
-
} from "./index-
|
|
419
|
+
} from "./index-wwg1je98.js";
|
|
420
420
|
import {
|
|
421
421
|
BoundedSessionMap,
|
|
422
422
|
getMeasuredToolDefinitionTokens
|
|
423
|
-
} from "./index-
|
|
423
|
+
} from "./index-smtbdmc3.js";
|
|
424
424
|
import {
|
|
425
425
|
isFailClosedBlockingError,
|
|
426
426
|
shouldBypassFailClosedBlock,
|
|
@@ -446,7 +446,7 @@ import {
|
|
|
446
446
|
runSqliteOptimize,
|
|
447
447
|
openDatabase,
|
|
448
448
|
openCurrentDatabase
|
|
449
|
-
} from "./index-
|
|
449
|
+
} from "./index-z8dacvkt.js";
|
|
450
450
|
import {
|
|
451
451
|
unescapeXml,
|
|
452
452
|
resolveWorkspaceShareCategories,
|
|
@@ -477,7 +477,7 @@ import {
|
|
|
477
477
|
toSynapseLaneDescriptor,
|
|
478
478
|
formatSynapseLaneDescriptor,
|
|
479
479
|
SynapseEmbeddingProvider
|
|
480
|
-
} from "./index-
|
|
480
|
+
} from "./index-dj2p8653.js";
|
|
481
481
|
import {
|
|
482
482
|
getCompartments,
|
|
483
483
|
getLastCompartmentEndMessage,
|
|
@@ -555,10 +555,10 @@ import {
|
|
|
555
555
|
GLOBAL_USER_PROFILE_PROJECT_PATH,
|
|
556
556
|
getProjectState,
|
|
557
557
|
bumpProjectUserProfileVersion
|
|
558
|
-
} from "./index-
|
|
558
|
+
} from "./index-jwa5t1s4.js";
|
|
559
559
|
import {
|
|
560
560
|
getLastIndexedOrdinal
|
|
561
|
-
} from "./index-
|
|
561
|
+
} from "./index-bzq05g00.js";
|
|
562
562
|
import {
|
|
563
563
|
SESSION_NOTE_CONDITION_ERROR,
|
|
564
564
|
getNoteByIdInScope,
|
|
@@ -596,8 +596,9 @@ import {
|
|
|
596
596
|
getCachedLocalEmbeddingPooling,
|
|
597
597
|
preflightLocalEmbeddingPooling,
|
|
598
598
|
getLocalEmbeddingNativeMemoryStats
|
|
599
|
-
} from "./index-
|
|
599
|
+
} from "./index-hkh8x221.js";
|
|
600
600
|
import {
|
|
601
|
+
withQueryEmbeddingDeadline,
|
|
601
602
|
describeShadowBackfillWriteRefusal2,
|
|
602
603
|
markProjectLoadUntrusted2,
|
|
603
604
|
drainProjectEmbeddingIdentityMaintenance2,
|
|
@@ -616,7 +617,7 @@ import {
|
|
|
616
617
|
embedSessionCompartmentChunks2,
|
|
617
618
|
getEmbeddingCoverageStatus2,
|
|
618
619
|
getAutoEmbeddingSessionCoverage2
|
|
619
|
-
} from "./index-
|
|
620
|
+
} from "./index-s79g172v.js";
|
|
620
621
|
import {
|
|
621
622
|
saveEmbeddingIfHashMatches,
|
|
622
623
|
invalidateProject2,
|
|
@@ -624,7 +625,7 @@ import {
|
|
|
624
625
|
} from "./index-4dhv7mqz.js";
|
|
625
626
|
import {
|
|
626
627
|
cosineSimilarity
|
|
627
|
-
} from "./index-
|
|
628
|
+
} from "./index-d4qw2h43.js";
|
|
628
629
|
import {
|
|
629
630
|
computeCueContentHash,
|
|
630
631
|
hasMuralCueColumns,
|
|
@@ -670,7 +671,7 @@ import {
|
|
|
670
671
|
readGitFileChangeTimesSince,
|
|
671
672
|
verificationFileExists,
|
|
672
673
|
normalizeVerificationFiles
|
|
673
|
-
} from "./index-
|
|
674
|
+
} from "./index-sd2s4t4p.js";
|
|
674
675
|
import {
|
|
675
676
|
renderSingleStoreMigrationRequiredRefusal,
|
|
676
677
|
SingleStoreMigrationRequiredError,
|
|
@@ -691,23 +692,23 @@ import {
|
|
|
691
692
|
resolveMemoriesByIdsForSearch2,
|
|
692
693
|
unifiedSearch2,
|
|
693
694
|
formatSearchResults2
|
|
694
|
-
} from "./index-
|
|
695
|
+
} from "./index-980brvjr.js";
|
|
695
696
|
import {
|
|
696
697
|
scheduleReconciliation,
|
|
697
698
|
scheduleIncrementalIndex,
|
|
698
699
|
getMessageIndexQueueHeapStats,
|
|
699
700
|
clearSessionTracking
|
|
700
|
-
} from "./index-
|
|
701
|
+
} from "./index-tvd2j34s.js";
|
|
701
702
|
import {
|
|
702
703
|
flushIgnoredMessages2,
|
|
703
704
|
clearIgnoredMessages2,
|
|
704
705
|
observeIgnoredNotificationEvent2,
|
|
705
706
|
sendStatusNotification2
|
|
706
|
-
} from "./index-
|
|
707
|
+
} from "./index-25ka1jza.js";
|
|
707
708
|
import {
|
|
708
709
|
setRecompStarting2,
|
|
709
710
|
setRecompTerminal2
|
|
710
|
-
} from "./index-
|
|
711
|
+
} from "./index-dcdvyaeh.js";
|
|
711
712
|
import {
|
|
712
713
|
makeToolCompositeKey,
|
|
713
714
|
searchMessageHistoryOffThread,
|
|
@@ -772,7 +773,7 @@ import {
|
|
|
772
773
|
abortSessionFailClosed2,
|
|
773
774
|
evaluateEmergencyFailClosed2,
|
|
774
775
|
runPostTransformPhase2
|
|
775
|
-
} from "./index-
|
|
776
|
+
} from "./index-0a79y98x.js";
|
|
776
777
|
import {
|
|
777
778
|
ANNOUNCEMENT_VERSION2,
|
|
778
779
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -787,13 +788,13 @@ import {
|
|
|
787
788
|
renderMessageByOrdinal2,
|
|
788
789
|
renderVerboseRangeForTool2,
|
|
789
790
|
renderItemByTag2
|
|
790
|
-
} from "./index-
|
|
791
|
+
} from "./index-gf1vx3bn.js";
|
|
791
792
|
import {
|
|
792
793
|
readV2ArchiveOffThread2
|
|
793
|
-
} from "./index-
|
|
794
|
+
} from "./index-7na94cjf.js";
|
|
794
795
|
import {
|
|
795
796
|
renderSearchArchiveOffThread2
|
|
796
|
-
} from "./index-
|
|
797
|
+
} from "./index-rk5hyc41.js";
|
|
797
798
|
import {
|
|
798
799
|
COMPACTION_ENABLED_PATH,
|
|
799
800
|
isDreamerRunnable,
|
|
@@ -12859,7 +12860,7 @@ function parseCacheTtl(ttl) {
|
|
|
12859
12860
|
}
|
|
12860
12861
|
function createScheduler(config) {
|
|
12861
12862
|
return {
|
|
12862
|
-
shouldExecute(sessionMeta, contextUsage,
|
|
12863
|
+
shouldExecute(sessionMeta, contextUsage, _currentTime, sessionId, modelKey, contextLimit) {
|
|
12863
12864
|
if (contextUsage.percentage === 0 && sessionMeta.lastResponseTime === 0) {
|
|
12864
12865
|
return "defer";
|
|
12865
12866
|
}
|
|
@@ -12872,21 +12873,6 @@ function createScheduler(config) {
|
|
|
12872
12873
|
if (contextUsage.percentage >= threshold) {
|
|
12873
12874
|
return "execute";
|
|
12874
12875
|
}
|
|
12875
|
-
let ttlMs;
|
|
12876
|
-
try {
|
|
12877
|
-
ttlMs = parseCacheTtl(sessionMeta.cacheTtl);
|
|
12878
|
-
} catch (error) {
|
|
12879
|
-
if (sessionId) {
|
|
12880
|
-
sessionLog2(sessionId, `invalid cache_ttl "${sessionMeta.cacheTtl}"; falling back to default 5m`, error);
|
|
12881
|
-
} else {
|
|
12882
|
-
log2(`[magic-context] invalid cache_ttl "${sessionMeta.cacheTtl}"; falling back to default 5m`, error);
|
|
12883
|
-
}
|
|
12884
|
-
ttlMs = parseCacheTtl("5m");
|
|
12885
|
-
}
|
|
12886
|
-
const elapsedTime = currentTime - sessionMeta.lastResponseTime;
|
|
12887
|
-
if (elapsedTime > ttlMs) {
|
|
12888
|
-
return "execute";
|
|
12889
|
-
}
|
|
12890
12876
|
return "defer";
|
|
12891
12877
|
}
|
|
12892
12878
|
};
|
|
@@ -14368,7 +14354,7 @@ function executeStatus(db, sessionId, executeThresholdPercentageConfig = DEFAULT
|
|
|
14368
14354
|
`- ${formatCacheTtlDisplay(ttlDisplay)}`,
|
|
14369
14355
|
`- Last response: ${meta.lastResponseTime > 0 ? `${Math.round(elapsed / 1000)}s ago` : "never"}`,
|
|
14370
14356
|
`- Remaining: ${cacheExpired ? "expired" : ttlMs === Number.POSITIVE_INFINITY ? "never (MC never assumes expiry — external cache-keep)" : `${Math.round(remainingMs / 1000)}s`}`,
|
|
14371
|
-
`- Queue will auto-execute:
|
|
14357
|
+
`- Queue will auto-execute: when context >= ${executeThresholdPercentage}%`,
|
|
14372
14358
|
"",
|
|
14373
14359
|
"### Execute Threshold",
|
|
14374
14360
|
`- Execute threshold: ${formatExecuteThreshold(thresholdDetail, displayContextLimit)}`,
|
|
@@ -16418,8 +16404,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16418
16404
|
const db = readDatabase();
|
|
16419
16405
|
if (!db)
|
|
16420
16406
|
return { ok: false, error: "db unavailable" };
|
|
16421
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16422
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
16407
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-y75thsc3.js"));
|
|
16408
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-j93pn2hn.js"));
|
|
16423
16409
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
16424
16410
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
16425
16411
|
return {
|
|
@@ -16503,7 +16489,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16503
16489
|
const db = readDatabase();
|
|
16504
16490
|
if (!db)
|
|
16505
16491
|
return { ok: false, error: "db unavailable" };
|
|
16506
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16492
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-r5cqgyrg.js"));
|
|
16507
16493
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
16508
16494
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
16509
16495
|
const ctx = {
|
|
@@ -17410,6 +17396,43 @@ function recordCompartmentTriggerError(passOutcome, sessionId, error, log = sess
|
|
|
17410
17396
|
log(sessionId, "compartment trigger failed (non-fatal):", error);
|
|
17411
17397
|
}
|
|
17412
17398
|
|
|
17399
|
+
// src/hooks/magic-context/local-wire-reading.ts
|
|
17400
|
+
function createLocalWireReadings() {
|
|
17401
|
+
const readings = new Map;
|
|
17402
|
+
const isWindow = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
17403
|
+
return {
|
|
17404
|
+
schedulerUsage({
|
|
17405
|
+
sessionId,
|
|
17406
|
+
providerUsage,
|
|
17407
|
+
providerReadingMissing,
|
|
17408
|
+
modelKey,
|
|
17409
|
+
usableWindow
|
|
17410
|
+
}) {
|
|
17411
|
+
if (!providerReadingMissing)
|
|
17412
|
+
return providerUsage;
|
|
17413
|
+
const reading = readings.get(sessionId);
|
|
17414
|
+
if (!reading || reading.modelKey !== modelKey || !isWindow(usableWindow) || reading.usableWindow !== usableWindow || reading.usage.percentage <= providerUsage.percentage) {
|
|
17415
|
+
return providerUsage;
|
|
17416
|
+
}
|
|
17417
|
+
return reading.usage;
|
|
17418
|
+
},
|
|
17419
|
+
record({ sessionId, providerReadingMissing, modelKey, usableWindow, pressureTokens }) {
|
|
17420
|
+
if (!providerReadingMissing || !modelKey || !isWindow(usableWindow) || typeof pressureTokens !== "number" || !Number.isFinite(pressureTokens) || pressureTokens <= 0) {
|
|
17421
|
+
readings.delete(sessionId);
|
|
17422
|
+
return;
|
|
17423
|
+
}
|
|
17424
|
+
readings.set(sessionId, {
|
|
17425
|
+
modelKey,
|
|
17426
|
+
usableWindow,
|
|
17427
|
+
usage: {
|
|
17428
|
+
inputTokens: pressureTokens,
|
|
17429
|
+
percentage: pressureTokens / usableWindow * 100
|
|
17430
|
+
}
|
|
17431
|
+
});
|
|
17432
|
+
}
|
|
17433
|
+
};
|
|
17434
|
+
}
|
|
17435
|
+
|
|
17413
17436
|
// src/hooks/magic-context/pass-outcome.ts
|
|
17414
17437
|
var PASS_DEGRADATION_EFFECTS = {
|
|
17415
17438
|
"store-generation-rebase-failure": "changes-request",
|
|
@@ -20389,7 +20412,27 @@ function savedProviderReadingForPass(input) {
|
|
|
20389
20412
|
if (!Number.isFinite(percentage) || percentage <= 0 || !Number.isFinite(inputTokens) || inputTokens <= 0) {
|
|
20390
20413
|
return null;
|
|
20391
20414
|
}
|
|
20392
|
-
if (!(input.lastResponseTime > 0)
|
|
20415
|
+
if (!(input.lastResponseTime > 0))
|
|
20416
|
+
return null;
|
|
20417
|
+
if (persisted.lastObservedModelKey === null || input.currentModelKey === undefined || input.currentModelKey.length === 0 || piModelRefToCanonical(persisted.lastObservedModelKey) !== piModelRefToCanonical(input.currentModelKey)) {
|
|
20418
|
+
return null;
|
|
20419
|
+
}
|
|
20420
|
+
if (typeof input.contextLimit !== "number" || !(input.contextLimit > 0) || persisted.lastUsageContextLimit !== input.contextLimit) {
|
|
20421
|
+
return null;
|
|
20422
|
+
}
|
|
20423
|
+
return { percentage, inputTokens };
|
|
20424
|
+
}
|
|
20425
|
+
function firstPassExecuteReading(input) {
|
|
20426
|
+
if (!(input.passPercentage < input.executeThresholdPercentage))
|
|
20427
|
+
return null;
|
|
20428
|
+
const persisted = input.persisted;
|
|
20429
|
+
if (!persisted)
|
|
20430
|
+
return null;
|
|
20431
|
+
const { percentage, inputTokens } = persisted.usage;
|
|
20432
|
+
if (!Number.isFinite(percentage) || percentage < input.executeThresholdPercentage || !Number.isFinite(inputTokens) || inputTokens <= 0) {
|
|
20433
|
+
return null;
|
|
20434
|
+
}
|
|
20435
|
+
if (!(input.lastResponseTime > 0))
|
|
20393
20436
|
return null;
|
|
20394
20437
|
if (persisted.lastObservedModelKey === null || input.currentModelKey === undefined || input.currentModelKey.length === 0 || piModelRefToCanonical(persisted.lastObservedModelKey) !== piModelRefToCanonical(input.currentModelKey)) {
|
|
20395
20438
|
return null;
|
|
@@ -23157,9 +23200,10 @@ function createRustModeTransform(deps, options) {
|
|
|
23157
23200
|
timings.outputClone += performance.now() - outputCloneStartedAt;
|
|
23158
23201
|
}
|
|
23159
23202
|
pendingWireCache.nativeOutput = moduleMessages;
|
|
23203
|
+
if ((materializedBoundary || getPendingCompactionMarkerState(deps.db, sessionId) !== null) && !deps.compactionOff)
|
|
23204
|
+
startCompactionMarkerCandidatePreparation(sessionId);
|
|
23160
23205
|
if (!replayedFrozenRepresentation) {
|
|
23161
23206
|
if ((materializedBoundary || getPendingCompactionMarkerState(deps.db, sessionId) !== null) && !deps.compactionOff) {
|
|
23162
|
-
await prepareCompactionMarkerCandidates(sessionId);
|
|
23163
23207
|
try {
|
|
23164
23208
|
await withAsyncPrivilegedWriter2(deps.db, () => {
|
|
23165
23209
|
return;
|
|
@@ -24373,6 +24417,7 @@ function createTransform(deps) {
|
|
|
24373
24417
|
clearDiagnosticLogState(sessionId);
|
|
24374
24418
|
};
|
|
24375
24419
|
const unmanagedOverWindowSessions = new Set;
|
|
24420
|
+
const localWireReadings = createLocalWireReadings();
|
|
24376
24421
|
const rustModeTransform = deps.transformMode === "rust" && deps.rustModeModuleClient ? createRustModeTransform(deps, {
|
|
24377
24422
|
moduleClient: deps.rustModeModuleClient,
|
|
24378
24423
|
hostClient: deps.client,
|
|
@@ -24698,6 +24743,7 @@ function createTransform(deps) {
|
|
|
24698
24743
|
}
|
|
24699
24744
|
}
|
|
24700
24745
|
let contextUsageEarly = loadContextUsage(deps.contextUsageMap, db, sessionId, contextUsagePassSnapshot(sessionMeta));
|
|
24746
|
+
const providerReadingMissing = !(contextUsageEarly.inputTokens > 0) && !(contextUsageEarly.percentage > 0);
|
|
24701
24747
|
let recoveryNoHeadEscapeActive = false;
|
|
24702
24748
|
let emergencyRecoveryArmed = false;
|
|
24703
24749
|
let overflowStateMutatedThisPass = false;
|
|
@@ -24857,7 +24903,41 @@ function createTransform(deps) {
|
|
|
24857
24903
|
const { historyBudgetTokens, projectPath: projectIdentity } = renderOptions;
|
|
24858
24904
|
const emergencyCeilingLimit = thresholdContextLimit ?? 0;
|
|
24859
24905
|
const emergencyCeilingTokens = Number.isFinite(emergencyCeilingLimit) && emergencyCeilingLimit > 0 ? Math.floor(emergencyCeilingLimit * (effectiveExecuteThresholdPercentage / 100)) : undefined;
|
|
24860
|
-
const
|
|
24906
|
+
const localReadingWindow = resolvedContextLimit ?? windowGeometry?.usableSoft;
|
|
24907
|
+
const localReadingModelKey = modelForBudget ? `${modelForBudget.providerID}/${modelForBudget.modelID}` : undefined;
|
|
24908
|
+
const schedulerUsage = localWireReadings.schedulerUsage({
|
|
24909
|
+
sessionId,
|
|
24910
|
+
providerUsage: contextUsageEarly,
|
|
24911
|
+
providerReadingMissing,
|
|
24912
|
+
modelKey: localReadingModelKey,
|
|
24913
|
+
usableWindow: localReadingWindow
|
|
24914
|
+
});
|
|
24915
|
+
if (schedulerUsage !== contextUsageEarly && !compactionOff) {
|
|
24916
|
+
sessionLog2(sessionId, `transform: no provider usage reading; the execute decision reads the local count of the last served request percentage=${schedulerUsage.percentage.toFixed(1)} inputTokens=${schedulerUsage.inputTokens}`);
|
|
24917
|
+
}
|
|
24918
|
+
const liveModelForSavedReading = deps.liveModelBySession?.get(sessionId);
|
|
24919
|
+
const savedReadingForExecute = isFirstTransformPassForSession && !usageResetAfterRefusal && !compactionOff ? firstPassExecuteReading({
|
|
24920
|
+
persisted: persistedUsageBeforeResets,
|
|
24921
|
+
currentModelKey: currentModelKeyForBoundary ?? (liveModelForSavedReading ? `${liveModelForSavedReading.providerID}/${liveModelForSavedReading.modelID}` : undefined),
|
|
24922
|
+
contextLimit: resolvedContextLimit,
|
|
24923
|
+
lastResponseTime: sessionMeta.lastResponseTime,
|
|
24924
|
+
executeThresholdPercentage: effectiveExecuteThresholdPercentage,
|
|
24925
|
+
passPercentage: contextUsageEarly.percentage
|
|
24926
|
+
}) : null;
|
|
24927
|
+
let clearedReadingDefers = false;
|
|
24928
|
+
if (savedReadingForExecute) {
|
|
24929
|
+
try {
|
|
24930
|
+
clearedReadingDefers = deps.scheduler.shouldExecute(sessionMeta, schedulerUsage, undefined, sessionId, deps.getModelKey?.(sessionId), resolvedContextLimit) === "defer";
|
|
24931
|
+
} catch {
|
|
24932
|
+
clearedReadingDefers = false;
|
|
24933
|
+
}
|
|
24934
|
+
}
|
|
24935
|
+
const schedulerReadsSavedReading = savedReadingForExecute !== null && clearedReadingDefers;
|
|
24936
|
+
if (schedulerReadsSavedReading) {
|
|
24937
|
+
sessionLog2(sessionId, `transform: first pass after restart: saved reading ${savedReadingForExecute.percentage.toFixed(1)}% is at or above the ${effectiveExecuteThresholdPercentage}% execute threshold; the scheduler decides from it, every other pressure check keeps the cleared reading`);
|
|
24938
|
+
}
|
|
24939
|
+
const schedulerDecision = compactionOff ? "defer" : resolveSchedulerDecision(deps.scheduler, sessionMeta, schedulerReadsSavedReading ? savedReadingForExecute : schedulerUsage, sessionId, deps.getModelKey?.(sessionId), resolvedContextLimit);
|
|
24940
|
+
const executeFromSavedReading = schedulerReadsSavedReading && schedulerDecision === "execute";
|
|
24861
24941
|
const schedulerDeferReason = schedulerDecision === "defer" ? "scheduler_defer" : null;
|
|
24862
24942
|
const historyRefreshExplicitBeforePrepare = !freezeM0M1 && deps.historyRefreshSessions.has(sessionId);
|
|
24863
24943
|
const deferredHistoryWasPendingAtPassStart = !freezeM0M1 && deferredHistoryRefreshSessions.has(sessionId);
|
|
@@ -25042,7 +25122,6 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25042
25122
|
permission: {
|
|
25043
25123
|
signedThinkingHold: activeThinkingPrefixHold,
|
|
25044
25124
|
firstRender: false,
|
|
25045
|
-
idleExpiry: false,
|
|
25046
25125
|
emergency: contextUsageEarly.percentage >= forceMaterializationPercentage
|
|
25047
25126
|
}
|
|
25048
25127
|
}, pendingDropEligibility.read(sessionId, dropProjectionKey()), schedulerDecision === "execute");
|
|
@@ -25315,7 +25394,15 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25315
25394
|
...renderOptions,
|
|
25316
25395
|
hardSignals: m0HardSignals
|
|
25317
25396
|
}).value;
|
|
25318
|
-
const
|
|
25397
|
+
const pricedBeyondExecute = (canConsumeDeferred) => isCacheBusting || contextUsage.percentage >= forceMaterializationPercentage || deps.pendingMaterializationSessions.has(sessionId) || canConsumeDeferred && deferredMaterializationSessions.has(sessionId) || protectionFoldWillBust;
|
|
25398
|
+
const protectionCacheBustingPass = !compactionOff && (schedulerDecision === "execute" || pricedBeyondExecute(canConsumeDeferredLate));
|
|
25399
|
+
const sizeAsPricedPass = executeFromSavedReading ? pricedBeyondExecute(canConsumeDeferredOnThisPass({
|
|
25400
|
+
schedulerDecision: "defer",
|
|
25401
|
+
contextPercentage: contextUsageEarly.percentage,
|
|
25402
|
+
justAwaitedPublication: compartmentPhase.justAwaitedPublication,
|
|
25403
|
+
activeRunBlocksMaterialization: lateActiveRunBlocksMaterialization,
|
|
25404
|
+
forceMaterializationPercentage
|
|
25405
|
+
})) : protectionCacheBustingPass;
|
|
25319
25406
|
const calibrationBustReason = protectionFoldWillBust ? "fold" : contextUsage.percentage >= forceMaterializationPercentage ? "force" : deps.pendingMaterializationSessions.has(sessionId) ? "flush" : consumingDeferredEarly || compartmentPhase.justAwaitedPublication ? "refresh" : schedulerDecision === "execute" ? "execute" : "unknown";
|
|
25320
25407
|
sessionDecisionCalibration(db, sessionId, {
|
|
25321
25408
|
bustPermitted: protectionCacheBustingPass,
|
|
@@ -25324,14 +25411,13 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25324
25411
|
onAdopt: (message) => sessionLog2(sessionId, message)
|
|
25325
25412
|
});
|
|
25326
25413
|
let contextUsageFromEstimate = hostOverWindow;
|
|
25327
|
-
if (contextUsage.inputTokens <= 0 &&
|
|
25414
|
+
if (contextUsage.inputTokens <= 0 && sizeAsPricedPass) {
|
|
25328
25415
|
const overflowRecoveryPass = usagePercentageSynthetic || emergencyRecoveryArmed;
|
|
25329
25416
|
const savedProviderReading = overflowRecoveryPass || usageResetAfterRefusal ? null : savedProviderReadingForPass({
|
|
25330
25417
|
persisted: persistedUsageBeforeResets,
|
|
25331
25418
|
currentModelKey: currentModelKeyForBoundary ?? (hardModelKey || undefined),
|
|
25332
25419
|
contextLimit: resolvedContextLimit,
|
|
25333
|
-
lastResponseTime: sessionMeta.lastResponseTime
|
|
25334
|
-
cacheExpired: hardCacheExpired
|
|
25420
|
+
lastResponseTime: sessionMeta.lastResponseTime
|
|
25335
25421
|
});
|
|
25336
25422
|
let pressureEstimate;
|
|
25337
25423
|
try {
|
|
@@ -25552,6 +25638,31 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25552
25638
|
logIncompleteFinalWire(finalWireEstimate, messages);
|
|
25553
25639
|
sessionLog2(sessionId, `transform: final-wire telemetry estimate=${finalWireEstimate.tokens} trusted=${finalWireEstimate.trusted} conversation=${finalWireEstimate.messageTokens.conversation} tools=${finalWireEstimate.messageTokens.toolCall} system=${finalWireEstimate.systemTokens} toolDefinitions=${finalWireEstimate.toolDefinitionTokens ?? "unknown"} tail=${finalWireTail}`);
|
|
25554
25640
|
}
|
|
25641
|
+
let servedPressureTokens;
|
|
25642
|
+
if (providerReadingMissing) {
|
|
25643
|
+
servedPressureTokens = finalWireEstimate?.pressureTokens;
|
|
25644
|
+
if (servedPressureTokens === undefined) {
|
|
25645
|
+
try {
|
|
25646
|
+
servedPressureTokens = estimateFinalWireInputTokens({
|
|
25647
|
+
messages,
|
|
25648
|
+
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
25649
|
+
providerID: modelForBudget?.providerID,
|
|
25650
|
+
modelID: modelForBudget?.modelID,
|
|
25651
|
+
agentName: notificationParams.agent,
|
|
25652
|
+
sessionId
|
|
25653
|
+
}).pressureTokens;
|
|
25654
|
+
} catch (error) {
|
|
25655
|
+
sessionLog2(sessionId, `transform: local count of the served request unavailable: ${getErrorMessage(error)}`);
|
|
25656
|
+
}
|
|
25657
|
+
}
|
|
25658
|
+
}
|
|
25659
|
+
localWireReadings.record({
|
|
25660
|
+
sessionId,
|
|
25661
|
+
providerReadingMissing,
|
|
25662
|
+
modelKey: localReadingModelKey,
|
|
25663
|
+
usableWindow: localReadingWindow,
|
|
25664
|
+
pressureTokens: servedPressureTokens
|
|
25665
|
+
});
|
|
25555
25666
|
if ((finalWireEstimate?.refusalGrade || finalWireEstimate?.refusalBasis === "byte-bound" && finalWireEstimate.refusalTokens !== undefined) && boundaryContextLimit > 0 && (finalWireEstimate.refusalTokens ?? finalWireEstimate.tokens) > boundaryContextLimit) {
|
|
25556
25667
|
const signedFitRetryWanted = !thinkingFitRetries.has(sessionId) && activeThinkingPrefixHold && hasActiveAnthropicThinkingTurn(messages, resolvedProviderID, modelForBudget?.modelID);
|
|
25557
25668
|
if (signedFitRetryWanted && originalForThinkingFit) {
|
|
@@ -26268,7 +26379,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
26268
26379
|
}
|
|
26269
26380
|
const isCacheBusting = deps.systemPromptRefreshSessions.has(sessionId);
|
|
26270
26381
|
const idleCacheExpired = sessionMetaEarly !== undefined && computeHardCacheExpired(sessionMetaEarly.cacheTtl, sessionMetaEarly.lastResponseTime, Date.now());
|
|
26271
|
-
const adoptSystemChange =
|
|
26382
|
+
const adoptSystemChange = requestMessagesFinal && !isHeldHeadForRequest(sessionId, currentLkgRequestIdentity(sessionId));
|
|
26272
26383
|
const liveSystemContent = output.system.join(`
|
|
26273
26384
|
`);
|
|
26274
26385
|
if (liveSystemContent.length === 0)
|
|
@@ -26310,9 +26421,9 @@ function createSystemPromptHashHandler(deps) {
|
|
|
26310
26421
|
const contentOrPresetChanged = hasPersistedHash && stableCandidateHash !== previousHash;
|
|
26311
26422
|
const rewritePermission = systemDateRefreshPermission(deps.historyRefreshSessions, dateRequest);
|
|
26312
26423
|
const signedThinkingKept = systemDateSignedThinkingKept(deps.historyRefreshSessions, dateRequest);
|
|
26313
|
-
const systemDateMayMove = (rewrite, keptSignedThinking) =>
|
|
26424
|
+
const systemDateMayMove = (rewrite, keptSignedThinking) => rewrite && keptSignedThinking !== true;
|
|
26314
26425
|
let deferredDateRefresh = false;
|
|
26315
|
-
if (currentDate && stickyDate && currentDate !== stickyDate &&
|
|
26426
|
+
if (currentDate && stickyDate && currentDate !== stickyDate && isCacheBusting && !contentOrPresetChanged && !requestMessagesFinal) {
|
|
26316
26427
|
const liveElements = [...output.system];
|
|
26317
26428
|
deferredDateRefresh = waitForSystemDateRefresh(deps.historyRefreshSessions, dateRequest, (permitted, keptSignedThinking) => {
|
|
26318
26429
|
if (!systemDateMayMove(permitted, keptSignedThinking)) {
|
|
@@ -26372,7 +26483,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
26372
26483
|
const currentPrompt = previousPrompt && previousHash === currentHash ? previousPrompt : snapshotSystemPrompt(output.system, promptSurface.preset);
|
|
26373
26484
|
diagnosticPrompts.set(sessionId, currentPrompt);
|
|
26374
26485
|
if (previousHash !== "" && previousHash !== "0" && previousHash !== currentHash) {
|
|
26375
|
-
sessionLog2(sessionId, `system prompt hash changed: ${previousHash} → ${currentHash} (len=${systemContent.length}), ${
|
|
26486
|
+
sessionLog2(sessionId, `system prompt hash changed: ${previousHash} → ${currentHash} (len=${systemContent.length}), ${adoptSystemChange ? "adopting on the request whose messages are already final" : "triggering flush"}${idleCacheExpired ? " (idle-expired request)" : ""}; ${describeSystemPromptChange(previousPrompt, currentPrompt)}`);
|
|
26376
26487
|
noteSystemPromptHashChange(sessionId);
|
|
26377
26488
|
if (!adoptSystemChange) {
|
|
26378
26489
|
deps.historyRefreshSessions.add(sessionId);
|
|
@@ -29096,10 +29207,7 @@ function createCtxSearchTool(deps) {
|
|
|
29096
29207
|
limit: normalizeLimit2(args.limit),
|
|
29097
29208
|
memoryEnabled,
|
|
29098
29209
|
embeddingEnabled,
|
|
29099
|
-
embedQuery:
|
|
29100
|
-
const result = await embedTextForProject2(projectPath, text, signal, "query");
|
|
29101
|
-
return result;
|
|
29102
|
-
},
|
|
29210
|
+
embedQuery: (text, signal) => withQueryEmbeddingDeadline((embeddingSignal) => embedTextForProject2(projectPath, text, embeddingSignal, "query"), signal),
|
|
29103
29211
|
isEmbeddingRuntimeEnabled: () => embeddingEnabled === true,
|
|
29104
29212
|
readMessages: deps.readMessages,
|
|
29105
29213
|
maxMessageOrdinal: messageOrdinalCutoff,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
estimateTokens
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-ak11t3gm.js";
|
|
4
4
|
import {
|
|
5
5
|
expandToolPart,
|
|
6
6
|
visitRawSessionMessages2,
|
|
7
7
|
readRawSessionMessageById2
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-wwg1je98.js";
|
|
9
9
|
import {
|
|
10
10
|
getTagById2
|
|
11
|
-
} from "./index-
|
|
11
|
+
} from "./index-gxqr0sbd.js";
|
|
12
12
|
|
|
13
13
|
// src/tools/ctx-expand/render.ts
|
|
14
14
|
import { createHash } from "node:crypto";
|
|
@@ -26,9 +26,10 @@ var missingWorkerWarnings = new Set;
|
|
|
26
26
|
var ownWriteRevisions = new Map;
|
|
27
27
|
var exitRegistered = false;
|
|
28
28
|
function reportWorkerUnavailable(entry, detail) {
|
|
29
|
-
|
|
29
|
+
const key = `${entry.href}\x00${detail}`;
|
|
30
|
+
if (missingWorkerWarnings.has(key))
|
|
30
31
|
return;
|
|
31
|
-
missingWorkerWarnings.add(
|
|
32
|
+
missingWorkerWarnings.add(key);
|
|
32
33
|
const path = entry.protocol === "file:" ? fileURLToPath(entry) : entry.href;
|
|
33
34
|
log2(`[magic-context] [ERROR] compaction-marker: candidate worker unavailable ${path}: ${detail}; marker unchanged, advancement deferred`);
|
|
34
35
|
}
|
|
@@ -64,6 +65,9 @@ function invalidateMarkerCandidateBasis2(db, sessionId) {
|
|
|
64
65
|
if (revision !== undefined)
|
|
65
66
|
ownWriteRevisions.set(key, revision + 1);
|
|
66
67
|
}
|
|
68
|
+
function discardMarkerCandidateBasis2(db, sessionId) {
|
|
69
|
+
candidates.get(db)?.delete(sessionId);
|
|
70
|
+
}
|
|
67
71
|
function readMarkerCandidateBasis2(db, sessionId, readConnection = db) {
|
|
68
72
|
const basis = candidates.get(db)?.get(sessionId);
|
|
69
73
|
if (basis) {
|
|
@@ -94,7 +98,7 @@ function prepareMarkerCandidateBasis2(db, sessionId, options = {}) {
|
|
|
94
98
|
reportWorkerUnavailable(entry, "file missing");
|
|
95
99
|
return Promise.resolve(false);
|
|
96
100
|
}
|
|
97
|
-
const preparation = runCandidateWorker(path, sessionId, options).then((snapshot) => {
|
|
101
|
+
const preparation = runCandidateWorker(path, sessionId, options.references !== false, options).then((snapshot) => {
|
|
98
102
|
if (!snapshot)
|
|
99
103
|
return false;
|
|
100
104
|
const basis = {
|
|
@@ -124,7 +128,7 @@ function prepareMarkerCandidateBasis2(db, sessionId, options = {}) {
|
|
|
124
128
|
function markerWorkerEntry() {
|
|
125
129
|
return new URL(new URL(import.meta.url).pathname.endsWith(".ts") ? "./compaction-marker-candidates-worker.ts" : "./compaction-marker-candidates-worker.js", import.meta.url);
|
|
126
130
|
}
|
|
127
|
-
function runCandidateWorker(path, sessionId, options) {
|
|
131
|
+
function runCandidateWorker(path, sessionId, references, options) {
|
|
128
132
|
if (!exitRegistered) {
|
|
129
133
|
exitRegistered = true;
|
|
130
134
|
const controller = new AbortController;
|
|
@@ -164,10 +168,14 @@ function runCandidateWorker(path, sessionId, options) {
|
|
|
164
168
|
timer.unref?.();
|
|
165
169
|
};
|
|
166
170
|
try {
|
|
167
|
-
|
|
171
|
+
const pooled = !options.entry || options.shareWorker === true;
|
|
172
|
+
worker = inRootAsyncContext2(() => pooled ? reuseWorker(entry, { workerData: { path, sessionId, references } }) : new Worker(entry, { workerData: { path, sessionId, references } }));
|
|
168
173
|
workers.add(worker);
|
|
169
174
|
worker.unref();
|
|
170
|
-
|
|
175
|
+
if (pooled)
|
|
176
|
+
worker.once("online", () => deadline(options.acceptMs ?? 2000));
|
|
177
|
+
else
|
|
178
|
+
deadline(options.acceptMs ?? 2000);
|
|
171
179
|
worker.on("message", (reply) => {
|
|
172
180
|
if (reply.kind === "accepted")
|
|
173
181
|
deadline(options.resultMs ?? 600000);
|
|
@@ -205,20 +213,64 @@ function scanMarkerSummaryCandidates(db, sessionId) {
|
|
|
205
213
|
db.exec("ROLLBACK");
|
|
206
214
|
}
|
|
207
215
|
}
|
|
208
|
-
function scanMarkerCandidateSnapshot2(db, sessionId) {
|
|
216
|
+
function scanMarkerCandidateSnapshot2(db, sessionId, references = true) {
|
|
209
217
|
const ownsSnapshot = !db.inTransaction;
|
|
210
218
|
if (ownsSnapshot)
|
|
211
219
|
db.exec("BEGIN");
|
|
212
220
|
try {
|
|
213
221
|
const ids = scanMarkerSummaryCandidates(db, sessionId);
|
|
214
|
-
const frontier = db
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
return {
|
|
222
|
+
const frontier = readMarkerFrontier(db, "message");
|
|
223
|
+
if (!references)
|
|
224
|
+
return { ids, frontier };
|
|
225
|
+
return {
|
|
226
|
+
ids,
|
|
227
|
+
frontier,
|
|
228
|
+
references: {
|
|
229
|
+
partIds: readMarkerReferenceRows2(db, sessionId, "part").map((row) => row.id),
|
|
230
|
+
partFrontiers: readMarkerFrontiers2(db, "part")
|
|
231
|
+
}
|
|
232
|
+
};
|
|
218
233
|
} finally {
|
|
219
234
|
if (ownsSnapshot)
|
|
220
235
|
db.exec("ROLLBACK");
|
|
221
236
|
}
|
|
222
237
|
}
|
|
238
|
+
function readMarkerFrontier(db, table) {
|
|
239
|
+
const frontier = db.prepare(`SELECT rowid,id FROM ${table} ORDER BY rowid DESC LIMIT 1`).all()[0] ?? null;
|
|
240
|
+
if (frontier && !Number.isSafeInteger(frontier.rowid))
|
|
241
|
+
throw new Error(`marker ${table} frontier rowid is not a safe integer`);
|
|
242
|
+
return frontier;
|
|
243
|
+
}
|
|
244
|
+
var MARKER_FRONTIER_CANDIDATES = 3;
|
|
245
|
+
function readMarkerFrontiers2(db, table, count = MARKER_FRONTIER_CANDIDATES) {
|
|
246
|
+
const frontiers = db.prepare(`SELECT rowid,id FROM ${table} ORDER BY rowid DESC LIMIT ?`).all(count);
|
|
247
|
+
if (frontiers.some((frontier) => !Number.isSafeInteger(frontier.rowid)))
|
|
248
|
+
throw new Error(`marker ${table} frontier rowid is not a safe integer`);
|
|
249
|
+
return frontiers;
|
|
250
|
+
}
|
|
251
|
+
var MARKER_REFERENCE_FRONTIER_SQL = (table) => `SELECT rowid FROM ${table} WHERE id = ?`;
|
|
252
|
+
function certifiedMarkerReferenceFloor2(db, table, frontiers) {
|
|
253
|
+
if (frontiers.length === 0)
|
|
254
|
+
return 0;
|
|
255
|
+
const probe = db.prepare(MARKER_REFERENCE_FRONTIER_SQL(table));
|
|
256
|
+
for (const frontier of [...frontiers].sort((a, b) => b.rowid - a.rowid)) {
|
|
257
|
+
const current = probe.all(frontier.id);
|
|
258
|
+
if (current[0]?.rowid === frontier.rowid)
|
|
259
|
+
return frontier.rowid;
|
|
260
|
+
}
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
var MARKER_TAIL_REFERENCE_COLUMNS = `id,
|
|
264
|
+
CASE WHEN data LIKE '%tail_start_id%' THEN json_extract(data, '$.tail_start_id') END AS direct,
|
|
265
|
+
CASE WHEN data LIKE '%tail_start_id%' THEN json_extract(data, '$.compaction.tail_start_id') END AS nested`;
|
|
266
|
+
function readMarkerReferenceRows2(db, sessionId, table, afterRowid) {
|
|
267
|
+
return db.prepare(`SELECT ${MARKER_TAIL_REFERENCE_COLUMNS} FROM ${table}
|
|
268
|
+
WHERE ${afterRowid === undefined ? "session_id = ?" : "rowid > ? AND +session_id = ?"}
|
|
269
|
+
AND ${table === "part" ? "data LIKE '%compaction%' AND json_valid(data) AND json_extract(data, '$.type') = 'compaction'" : "(data LIKE '%compaction%' OR data LIKE '%tail_start_id%') AND json_valid(data) AND (json_type(data, '$.compaction') IS NOT NULL OR json_type(data, '$.tail_start_id') IS NOT NULL)"}`).all(...afterRowid === undefined ? [sessionId] : [afterRowid, sessionId]);
|
|
270
|
+
}
|
|
271
|
+
function readKnownMarkerReferenceRows2(db, sessionId, table, ids) {
|
|
272
|
+
const byId = db.prepare(`SELECT ${MARKER_TAIL_REFERENCE_COLUMNS} FROM ${table} WHERE id = ? AND session_id = ?`);
|
|
273
|
+
return ids.flatMap((id) => byId.all(id, sessionId));
|
|
274
|
+
}
|
|
223
275
|
|
|
224
|
-
export { isMarkerCandidateBasisCurrent2, invalidateMarkerCandidateBasis2, readMarkerCandidateBasis2, prepareMarkerCandidateBasis2, scanMarkerCandidateSnapshot2 };
|
|
276
|
+
export { isMarkerCandidateBasisCurrent2, invalidateMarkerCandidateBasis2, discardMarkerCandidateBasis2, readMarkerCandidateBasis2, prepareMarkerCandidateBasis2, scanMarkerCandidateSnapshot2, readMarkerFrontiers2, certifiedMarkerReferenceFloor2, readMarkerReferenceRows2, readKnownMarkerReferenceRows2 };
|