@cortexkit/opencode-magic-context 0.49.43 → 0.49.44
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 +1 -1
- 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/{context-zf1yj1g0.js → context-ws6gbyrr.js} +19 -19
- package/dist/{embedding-backfill-rma0v2ct.js → embedding-backfill-zxj35jkq.js} +4 -4
- package/dist/embedding-worker.js +2 -2
- 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/scheduler.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/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-zqsp3z0d.js → index-1j8m4ad0.js} +1 -1
- package/dist/{index-5m2azs6v.js → index-24y47287.js} +4 -4
- package/dist/{index-c5dzns43.js → index-4dpvnp8k.js} +1 -1
- package/dist/{index-ty4vhe4n.js → index-66qexmjw.js} +3 -3
- package/dist/{index-kfsqk1q7.js → index-6qnhaaa0.js} +1 -1
- package/dist/{index-n8bsqg7b.js → index-7y8c2n52.js} +3 -3
- package/dist/{index-ayk4we2k.js → index-8w3y6pxc.js} +36 -26
- package/dist/{index-p2e7j9p1.js → index-91y4xvx6.js} +1 -1
- package/dist/{index-rdx17j04.js → index-dasvhxwg.js} +1 -1
- package/dist/{index-z6v8086q.js → index-g0mjm7e4.js} +2 -2
- package/dist/{index-1zv08avf.js → index-g7rrfjkq.js} +4 -4
- package/dist/{index-3w1pbn85.js → index-gn6gfz4y.js} +64 -12
- package/dist/{index-xnm0wq1r.js → index-kgk64zyx.js} +1 -1
- package/dist/{index-xjw9rres.js → index-knnscj54.js} +1 -1
- package/dist/{index-gsqz39wk.js → index-m1mttf6y.js} +1 -1
- package/dist/{index-adt3jghq.js → index-ntssp0dt.js} +159 -49
- package/dist/{index-xd2p95m7.js → index-p6gs3xpx.js} +1 -1
- package/dist/{index-21fgrfrf.js → index-rhcwddn9.js} +2 -2
- package/dist/{index-fas76dft.js → index-v64se1t6.js} +5 -5
- package/dist/{index-xmqj3cf5.js → index-wapyeb06.js} +129 -56
- package/dist/index.js +23 -23
- package/dist/{message-index-bounded-5mj8p6nq.js → message-index-bounded-dmq6ne7d.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/{project-embedding-registry-3yyegjma.js → project-embedding-registry-m47vg1ce.js} +3 -3
- package/dist/raw-ordinal-warmup-worker.js +3 -3
- package/dist/{read-session-chunk-k70bhfjm.js → read-session-chunk-3m7z9v3t.js} +2 -2
- package/dist/{recomp-orchestrator-2q4rmerf.js → recomp-orchestrator-9wtcpd7d.js} +12 -12
- package/dist/{render-36fvvwz6.js → render-esw55s0k.js} +6 -6
- package/dist/{search-6v2na3af.js → search-3b4kbhtw.js} +9 -9
- package/dist/{search-archive-jwb2ctnq.js → search-archive-wna5basn.js} +4 -4
- package/dist/shared/status-view.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-0ms3ga4h.js → transform-postprocess-phase-1y6p9ccc.js} +13 -13
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/chunk-embedding-write-worker.js +1 -1
- 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/{context-2xr6vbt2.js → context-sfgk72cj.js} +184 -64
- package/dist/v2/{embedding-backfill-00tw59rx.js → embedding-backfill-ahwzfc7v.js} +4 -4
- package/dist/v2/embedding-worker.js +2 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-5341qsqd.js → message-index-bounded-mapha2ag.js} +3 -3
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-jqq2qeqb.js → project-embedding-registry-mn403rp5.js} +3 -3
- package/dist/v2/raw-ordinal-warmup-worker.js +3 -3
- package/dist/v2/{read-session-chunk-dgmq3ntm.js → read-session-chunk-svcthp0n.js} +2 -2
- package/dist/v2/{recomp-orchestrator-2vmyhtst.js → recomp-orchestrator-2bkv46am.js} +12 -12
- package/dist/v2/{render-kz0f40ws.js → render-315tv10c.js} +6 -6
- package/dist/v2/{search-archive-wajxd01m.js → search-archive-hnx40ts0.js} +4 -4
- package/dist/v2/{search-a9hwy1sw.js → search-bhrr075t.js} +8 -8
- package/dist/v2/{server-7qc9tk6z.js → server-1c720m9s.js} +1 -1
- package/dist/v2/{server-qehn6btp.js → server-1yx5455s.js} +2 -2
- package/dist/v2/{server-p78wdf43.js → server-63cz4w5t.js} +1 -1
- package/dist/v2/{server-kqrpt2ht.js → server-78mc9sxx.js} +1 -1
- package/dist/v2/{server-7acq7815.js → server-86sk7h34.js} +2 -2
- package/dist/v2/{server-6vzh6wej.js → server-8xdnk7vz.js} +1 -1
- package/dist/v2/{server-gkse1wyz.js → server-aqgg41wb.js} +3 -3
- package/dist/v2/{server-3m7p4g9w.js → server-g8xvnxcf.js} +1 -1
- package/dist/v2/{server-dwpgzm0t.js → server-gwxys0d0.js} +64 -12
- package/dist/v2/{server-5ydn39x3.js → server-ngdrh7rv.js} +130 -57
- package/dist/v2/{server-7zacmty5.js → server-p9s40wfa.js} +1 -1
- package/dist/v2/{server-dqs8e4yt.js → server-qs0mdpc1.js} +4 -4
- package/dist/v2/{server-sfcp13bn.js → server-rqypazrp.js} +3 -3
- package/dist/v2/{server-09td1wgc.js → server-t5gxvcc3.js} +1 -1
- package/dist/v2/{server-avdveykk.js → server-vjhk8v41.js} +1 -1
- package/dist/v2/{server-nq3cb7be.js → server-xnz3nrt2.js} +1 -1
- package/dist/v2/server.js +4 -4
- package/dist/v2/{v2-archive-reader-ag6sk771.js → v2-archive-reader-qwn0me88.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-2a077zew.js → wrapup-orchestrator-ts0sqwp3.js} +12 -12
- package/dist/{v2-archive-reader-chk95syc.js → v2-archive-reader-vqqjkeaq.js} +1 -1
- package/dist/{wrapup-orchestrator-rhs675kj.js → wrapup-orchestrator-qxvbvr4r.js} +13 -13
- 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-wapyeb06.js";
|
|
195
195
|
import {
|
|
196
196
|
hasTrustedAbsoluteWall,
|
|
197
197
|
applyProvenInputFloor,
|
|
@@ -278,7 +278,7 @@ 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,
|
|
@@ -416,7 +416,7 @@ import {
|
|
|
416
416
|
readRawSessionMessageById2,
|
|
417
417
|
readSessionChunk2,
|
|
418
418
|
readRawSessionSeedTail2
|
|
419
|
-
} from "./index-
|
|
419
|
+
} from "./index-1j8m4ad0.js";
|
|
420
420
|
import {
|
|
421
421
|
BoundedSessionMap,
|
|
422
422
|
getMeasuredToolDefinitionTokens
|
|
@@ -446,7 +446,7 @@ import {
|
|
|
446
446
|
runSqliteOptimize,
|
|
447
447
|
openDatabase,
|
|
448
448
|
openCurrentDatabase
|
|
449
|
-
} from "./index-
|
|
449
|
+
} from "./index-6qnhaaa0.js";
|
|
450
450
|
import {
|
|
451
451
|
unescapeXml,
|
|
452
452
|
resolveWorkspaceShareCategories,
|
|
@@ -555,10 +555,10 @@ import {
|
|
|
555
555
|
GLOBAL_USER_PROFILE_PROJECT_PATH,
|
|
556
556
|
getProjectState,
|
|
557
557
|
bumpProjectUserProfileVersion
|
|
558
|
-
} from "./index-
|
|
558
|
+
} from "./index-dasvhxwg.js";
|
|
559
559
|
import {
|
|
560
560
|
getLastIndexedOrdinal
|
|
561
|
-
} from "./index-
|
|
561
|
+
} from "./index-m1mttf6y.js";
|
|
562
562
|
import {
|
|
563
563
|
SESSION_NOTE_CONDITION_ERROR,
|
|
564
564
|
getNoteByIdInScope,
|
|
@@ -596,7 +596,7 @@ import {
|
|
|
596
596
|
getCachedLocalEmbeddingPooling,
|
|
597
597
|
preflightLocalEmbeddingPooling,
|
|
598
598
|
getLocalEmbeddingNativeMemoryStats
|
|
599
|
-
} from "./index-
|
|
599
|
+
} from "./index-p6gs3xpx.js";
|
|
600
600
|
import {
|
|
601
601
|
describeShadowBackfillWriteRefusal2,
|
|
602
602
|
markProjectLoadUntrusted2,
|
|
@@ -616,7 +616,7 @@ import {
|
|
|
616
616
|
embedSessionCompartmentChunks2,
|
|
617
617
|
getEmbeddingCoverageStatus2,
|
|
618
618
|
getAutoEmbeddingSessionCoverage2
|
|
619
|
-
} from "./index-
|
|
619
|
+
} from "./index-rhcwddn9.js";
|
|
620
620
|
import {
|
|
621
621
|
saveEmbeddingIfHashMatches,
|
|
622
622
|
invalidateProject2,
|
|
@@ -624,7 +624,7 @@ import {
|
|
|
624
624
|
} from "./index-4dhv7mqz.js";
|
|
625
625
|
import {
|
|
626
626
|
cosineSimilarity
|
|
627
|
-
} from "./index-
|
|
627
|
+
} from "./index-66qexmjw.js";
|
|
628
628
|
import {
|
|
629
629
|
computeCueContentHash,
|
|
630
630
|
hasMuralCueColumns,
|
|
@@ -670,7 +670,7 @@ import {
|
|
|
670
670
|
readGitFileChangeTimesSince,
|
|
671
671
|
verificationFileExists,
|
|
672
672
|
normalizeVerificationFiles
|
|
673
|
-
} from "./index-
|
|
673
|
+
} from "./index-kgk64zyx.js";
|
|
674
674
|
import {
|
|
675
675
|
renderSingleStoreMigrationRequiredRefusal,
|
|
676
676
|
SingleStoreMigrationRequiredError,
|
|
@@ -691,13 +691,13 @@ import {
|
|
|
691
691
|
resolveMemoriesByIdsForSearch2,
|
|
692
692
|
unifiedSearch2,
|
|
693
693
|
formatSearchResults2
|
|
694
|
-
} from "./index-
|
|
694
|
+
} from "./index-v64se1t6.js";
|
|
695
695
|
import {
|
|
696
696
|
scheduleReconciliation,
|
|
697
697
|
scheduleIncrementalIndex,
|
|
698
698
|
getMessageIndexQueueHeapStats,
|
|
699
699
|
clearSessionTracking
|
|
700
|
-
} from "./index-
|
|
700
|
+
} from "./index-91y4xvx6.js";
|
|
701
701
|
import {
|
|
702
702
|
flushIgnoredMessages2,
|
|
703
703
|
clearIgnoredMessages2,
|
|
@@ -707,7 +707,7 @@ import {
|
|
|
707
707
|
import {
|
|
708
708
|
setRecompStarting2,
|
|
709
709
|
setRecompTerminal2
|
|
710
|
-
} from "./index-
|
|
710
|
+
} from "./index-24y47287.js";
|
|
711
711
|
import {
|
|
712
712
|
makeToolCompositeKey,
|
|
713
713
|
searchMessageHistoryOffThread,
|
|
@@ -772,7 +772,7 @@ import {
|
|
|
772
772
|
abortSessionFailClosed2,
|
|
773
773
|
evaluateEmergencyFailClosed2,
|
|
774
774
|
runPostTransformPhase2
|
|
775
|
-
} from "./index-
|
|
775
|
+
} from "./index-8w3y6pxc.js";
|
|
776
776
|
import {
|
|
777
777
|
ANNOUNCEMENT_VERSION2,
|
|
778
778
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -787,13 +787,13 @@ import {
|
|
|
787
787
|
renderMessageByOrdinal2,
|
|
788
788
|
renderVerboseRangeForTool2,
|
|
789
789
|
renderItemByTag2
|
|
790
|
-
} from "./index-
|
|
790
|
+
} from "./index-knnscj54.js";
|
|
791
791
|
import {
|
|
792
792
|
readV2ArchiveOffThread2
|
|
793
|
-
} from "./index-
|
|
793
|
+
} from "./index-7y8c2n52.js";
|
|
794
794
|
import {
|
|
795
795
|
renderSearchArchiveOffThread2
|
|
796
|
-
} from "./index-
|
|
796
|
+
} from "./index-g0mjm7e4.js";
|
|
797
797
|
import {
|
|
798
798
|
COMPACTION_ENABLED_PATH,
|
|
799
799
|
isDreamerRunnable,
|
|
@@ -12859,7 +12859,7 @@ function parseCacheTtl(ttl) {
|
|
|
12859
12859
|
}
|
|
12860
12860
|
function createScheduler(config) {
|
|
12861
12861
|
return {
|
|
12862
|
-
shouldExecute(sessionMeta, contextUsage,
|
|
12862
|
+
shouldExecute(sessionMeta, contextUsage, _currentTime, sessionId, modelKey, contextLimit) {
|
|
12863
12863
|
if (contextUsage.percentage === 0 && sessionMeta.lastResponseTime === 0) {
|
|
12864
12864
|
return "defer";
|
|
12865
12865
|
}
|
|
@@ -12872,21 +12872,6 @@ function createScheduler(config) {
|
|
|
12872
12872
|
if (contextUsage.percentage >= threshold) {
|
|
12873
12873
|
return "execute";
|
|
12874
12874
|
}
|
|
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
12875
|
return "defer";
|
|
12891
12876
|
}
|
|
12892
12877
|
};
|
|
@@ -14368,7 +14353,7 @@ function executeStatus(db, sessionId, executeThresholdPercentageConfig = DEFAULT
|
|
|
14368
14353
|
`- ${formatCacheTtlDisplay(ttlDisplay)}`,
|
|
14369
14354
|
`- Last response: ${meta.lastResponseTime > 0 ? `${Math.round(elapsed / 1000)}s ago` : "never"}`,
|
|
14370
14355
|
`- 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:
|
|
14356
|
+
`- Queue will auto-execute: when context >= ${executeThresholdPercentage}%`,
|
|
14372
14357
|
"",
|
|
14373
14358
|
"### Execute Threshold",
|
|
14374
14359
|
`- Execute threshold: ${formatExecuteThreshold(thresholdDetail, displayContextLimit)}`,
|
|
@@ -16418,7 +16403,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16418
16403
|
const db = readDatabase();
|
|
16419
16404
|
if (!db)
|
|
16420
16405
|
return { ok: false, error: "db unavailable" };
|
|
16421
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16406
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-9wtcpd7d.js"));
|
|
16422
16407
|
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-14p3yje4.js"));
|
|
16423
16408
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
16424
16409
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
@@ -16503,7 +16488,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16503
16488
|
const db = readDatabase();
|
|
16504
16489
|
if (!db)
|
|
16505
16490
|
return { ok: false, error: "db unavailable" };
|
|
16506
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16491
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-qxvbvr4r.js"));
|
|
16507
16492
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
16508
16493
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
16509
16494
|
const ctx = {
|
|
@@ -17410,6 +17395,43 @@ function recordCompartmentTriggerError(passOutcome, sessionId, error, log = sess
|
|
|
17410
17395
|
log(sessionId, "compartment trigger failed (non-fatal):", error);
|
|
17411
17396
|
}
|
|
17412
17397
|
|
|
17398
|
+
// src/hooks/magic-context/local-wire-reading.ts
|
|
17399
|
+
function createLocalWireReadings() {
|
|
17400
|
+
const readings = new Map;
|
|
17401
|
+
const isWindow = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
17402
|
+
return {
|
|
17403
|
+
schedulerUsage({
|
|
17404
|
+
sessionId,
|
|
17405
|
+
providerUsage,
|
|
17406
|
+
providerReadingMissing,
|
|
17407
|
+
modelKey,
|
|
17408
|
+
usableWindow
|
|
17409
|
+
}) {
|
|
17410
|
+
if (!providerReadingMissing)
|
|
17411
|
+
return providerUsage;
|
|
17412
|
+
const reading = readings.get(sessionId);
|
|
17413
|
+
if (!reading || reading.modelKey !== modelKey || !isWindow(usableWindow) || reading.usableWindow !== usableWindow || reading.usage.percentage <= providerUsage.percentage) {
|
|
17414
|
+
return providerUsage;
|
|
17415
|
+
}
|
|
17416
|
+
return reading.usage;
|
|
17417
|
+
},
|
|
17418
|
+
record({ sessionId, providerReadingMissing, modelKey, usableWindow, pressureTokens }) {
|
|
17419
|
+
if (!providerReadingMissing || !modelKey || !isWindow(usableWindow) || typeof pressureTokens !== "number" || !Number.isFinite(pressureTokens) || pressureTokens <= 0) {
|
|
17420
|
+
readings.delete(sessionId);
|
|
17421
|
+
return;
|
|
17422
|
+
}
|
|
17423
|
+
readings.set(sessionId, {
|
|
17424
|
+
modelKey,
|
|
17425
|
+
usableWindow,
|
|
17426
|
+
usage: {
|
|
17427
|
+
inputTokens: pressureTokens,
|
|
17428
|
+
percentage: pressureTokens / usableWindow * 100
|
|
17429
|
+
}
|
|
17430
|
+
});
|
|
17431
|
+
}
|
|
17432
|
+
};
|
|
17433
|
+
}
|
|
17434
|
+
|
|
17413
17435
|
// src/hooks/magic-context/pass-outcome.ts
|
|
17414
17436
|
var PASS_DEGRADATION_EFFECTS = {
|
|
17415
17437
|
"store-generation-rebase-failure": "changes-request",
|
|
@@ -20389,7 +20411,27 @@ function savedProviderReadingForPass(input) {
|
|
|
20389
20411
|
if (!Number.isFinite(percentage) || percentage <= 0 || !Number.isFinite(inputTokens) || inputTokens <= 0) {
|
|
20390
20412
|
return null;
|
|
20391
20413
|
}
|
|
20392
|
-
if (!(input.lastResponseTime > 0)
|
|
20414
|
+
if (!(input.lastResponseTime > 0))
|
|
20415
|
+
return null;
|
|
20416
|
+
if (persisted.lastObservedModelKey === null || input.currentModelKey === undefined || input.currentModelKey.length === 0 || piModelRefToCanonical(persisted.lastObservedModelKey) !== piModelRefToCanonical(input.currentModelKey)) {
|
|
20417
|
+
return null;
|
|
20418
|
+
}
|
|
20419
|
+
if (typeof input.contextLimit !== "number" || !(input.contextLimit > 0) || persisted.lastUsageContextLimit !== input.contextLimit) {
|
|
20420
|
+
return null;
|
|
20421
|
+
}
|
|
20422
|
+
return { percentage, inputTokens };
|
|
20423
|
+
}
|
|
20424
|
+
function firstPassExecuteReading(input) {
|
|
20425
|
+
if (!(input.passPercentage < input.executeThresholdPercentage))
|
|
20426
|
+
return null;
|
|
20427
|
+
const persisted = input.persisted;
|
|
20428
|
+
if (!persisted)
|
|
20429
|
+
return null;
|
|
20430
|
+
const { percentage, inputTokens } = persisted.usage;
|
|
20431
|
+
if (!Number.isFinite(percentage) || percentage < input.executeThresholdPercentage || !Number.isFinite(inputTokens) || inputTokens <= 0) {
|
|
20432
|
+
return null;
|
|
20433
|
+
}
|
|
20434
|
+
if (!(input.lastResponseTime > 0))
|
|
20393
20435
|
return null;
|
|
20394
20436
|
if (persisted.lastObservedModelKey === null || input.currentModelKey === undefined || input.currentModelKey.length === 0 || piModelRefToCanonical(persisted.lastObservedModelKey) !== piModelRefToCanonical(input.currentModelKey)) {
|
|
20395
20437
|
return null;
|
|
@@ -23157,9 +23199,10 @@ function createRustModeTransform(deps, options) {
|
|
|
23157
23199
|
timings.outputClone += performance.now() - outputCloneStartedAt;
|
|
23158
23200
|
}
|
|
23159
23201
|
pendingWireCache.nativeOutput = moduleMessages;
|
|
23202
|
+
if ((materializedBoundary || getPendingCompactionMarkerState(deps.db, sessionId) !== null) && !deps.compactionOff)
|
|
23203
|
+
startCompactionMarkerCandidatePreparation(sessionId);
|
|
23160
23204
|
if (!replayedFrozenRepresentation) {
|
|
23161
23205
|
if ((materializedBoundary || getPendingCompactionMarkerState(deps.db, sessionId) !== null) && !deps.compactionOff) {
|
|
23162
|
-
await prepareCompactionMarkerCandidates(sessionId);
|
|
23163
23206
|
try {
|
|
23164
23207
|
await withAsyncPrivilegedWriter2(deps.db, () => {
|
|
23165
23208
|
return;
|
|
@@ -24373,6 +24416,7 @@ function createTransform(deps) {
|
|
|
24373
24416
|
clearDiagnosticLogState(sessionId);
|
|
24374
24417
|
};
|
|
24375
24418
|
const unmanagedOverWindowSessions = new Set;
|
|
24419
|
+
const localWireReadings = createLocalWireReadings();
|
|
24376
24420
|
const rustModeTransform = deps.transformMode === "rust" && deps.rustModeModuleClient ? createRustModeTransform(deps, {
|
|
24377
24421
|
moduleClient: deps.rustModeModuleClient,
|
|
24378
24422
|
hostClient: deps.client,
|
|
@@ -24698,6 +24742,7 @@ function createTransform(deps) {
|
|
|
24698
24742
|
}
|
|
24699
24743
|
}
|
|
24700
24744
|
let contextUsageEarly = loadContextUsage(deps.contextUsageMap, db, sessionId, contextUsagePassSnapshot(sessionMeta));
|
|
24745
|
+
const providerReadingMissing = !(contextUsageEarly.inputTokens > 0) && !(contextUsageEarly.percentage > 0);
|
|
24701
24746
|
let recoveryNoHeadEscapeActive = false;
|
|
24702
24747
|
let emergencyRecoveryArmed = false;
|
|
24703
24748
|
let overflowStateMutatedThisPass = false;
|
|
@@ -24857,7 +24902,41 @@ function createTransform(deps) {
|
|
|
24857
24902
|
const { historyBudgetTokens, projectPath: projectIdentity } = renderOptions;
|
|
24858
24903
|
const emergencyCeilingLimit = thresholdContextLimit ?? 0;
|
|
24859
24904
|
const emergencyCeilingTokens = Number.isFinite(emergencyCeilingLimit) && emergencyCeilingLimit > 0 ? Math.floor(emergencyCeilingLimit * (effectiveExecuteThresholdPercentage / 100)) : undefined;
|
|
24860
|
-
const
|
|
24905
|
+
const localReadingWindow = resolvedContextLimit ?? windowGeometry?.usableSoft;
|
|
24906
|
+
const localReadingModelKey = modelForBudget ? `${modelForBudget.providerID}/${modelForBudget.modelID}` : undefined;
|
|
24907
|
+
const schedulerUsage = localWireReadings.schedulerUsage({
|
|
24908
|
+
sessionId,
|
|
24909
|
+
providerUsage: contextUsageEarly,
|
|
24910
|
+
providerReadingMissing,
|
|
24911
|
+
modelKey: localReadingModelKey,
|
|
24912
|
+
usableWindow: localReadingWindow
|
|
24913
|
+
});
|
|
24914
|
+
if (schedulerUsage !== contextUsageEarly && !compactionOff) {
|
|
24915
|
+
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}`);
|
|
24916
|
+
}
|
|
24917
|
+
const liveModelForSavedReading = deps.liveModelBySession?.get(sessionId);
|
|
24918
|
+
const savedReadingForExecute = isFirstTransformPassForSession && !usageResetAfterRefusal && !compactionOff ? firstPassExecuteReading({
|
|
24919
|
+
persisted: persistedUsageBeforeResets,
|
|
24920
|
+
currentModelKey: currentModelKeyForBoundary ?? (liveModelForSavedReading ? `${liveModelForSavedReading.providerID}/${liveModelForSavedReading.modelID}` : undefined),
|
|
24921
|
+
contextLimit: resolvedContextLimit,
|
|
24922
|
+
lastResponseTime: sessionMeta.lastResponseTime,
|
|
24923
|
+
executeThresholdPercentage: effectiveExecuteThresholdPercentage,
|
|
24924
|
+
passPercentage: contextUsageEarly.percentage
|
|
24925
|
+
}) : null;
|
|
24926
|
+
let clearedReadingDefers = false;
|
|
24927
|
+
if (savedReadingForExecute) {
|
|
24928
|
+
try {
|
|
24929
|
+
clearedReadingDefers = deps.scheduler.shouldExecute(sessionMeta, schedulerUsage, undefined, sessionId, deps.getModelKey?.(sessionId), resolvedContextLimit) === "defer";
|
|
24930
|
+
} catch {
|
|
24931
|
+
clearedReadingDefers = false;
|
|
24932
|
+
}
|
|
24933
|
+
}
|
|
24934
|
+
const schedulerReadsSavedReading = savedReadingForExecute !== null && clearedReadingDefers;
|
|
24935
|
+
if (schedulerReadsSavedReading) {
|
|
24936
|
+
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`);
|
|
24937
|
+
}
|
|
24938
|
+
const schedulerDecision = compactionOff ? "defer" : resolveSchedulerDecision(deps.scheduler, sessionMeta, schedulerReadsSavedReading ? savedReadingForExecute : schedulerUsage, sessionId, deps.getModelKey?.(sessionId), resolvedContextLimit);
|
|
24939
|
+
const executeFromSavedReading = schedulerReadsSavedReading && schedulerDecision === "execute";
|
|
24861
24940
|
const schedulerDeferReason = schedulerDecision === "defer" ? "scheduler_defer" : null;
|
|
24862
24941
|
const historyRefreshExplicitBeforePrepare = !freezeM0M1 && deps.historyRefreshSessions.has(sessionId);
|
|
24863
24942
|
const deferredHistoryWasPendingAtPassStart = !freezeM0M1 && deferredHistoryRefreshSessions.has(sessionId);
|
|
@@ -25042,7 +25121,6 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25042
25121
|
permission: {
|
|
25043
25122
|
signedThinkingHold: activeThinkingPrefixHold,
|
|
25044
25123
|
firstRender: false,
|
|
25045
|
-
idleExpiry: false,
|
|
25046
25124
|
emergency: contextUsageEarly.percentage >= forceMaterializationPercentage
|
|
25047
25125
|
}
|
|
25048
25126
|
}, pendingDropEligibility.read(sessionId, dropProjectionKey()), schedulerDecision === "execute");
|
|
@@ -25315,7 +25393,15 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25315
25393
|
...renderOptions,
|
|
25316
25394
|
hardSignals: m0HardSignals
|
|
25317
25395
|
}).value;
|
|
25318
|
-
const
|
|
25396
|
+
const pricedBeyondExecute = (canConsumeDeferred) => isCacheBusting || contextUsage.percentage >= forceMaterializationPercentage || deps.pendingMaterializationSessions.has(sessionId) || canConsumeDeferred && deferredMaterializationSessions.has(sessionId) || protectionFoldWillBust;
|
|
25397
|
+
const protectionCacheBustingPass = !compactionOff && (schedulerDecision === "execute" || pricedBeyondExecute(canConsumeDeferredLate));
|
|
25398
|
+
const sizeAsPricedPass = executeFromSavedReading ? pricedBeyondExecute(canConsumeDeferredOnThisPass({
|
|
25399
|
+
schedulerDecision: "defer",
|
|
25400
|
+
contextPercentage: contextUsageEarly.percentage,
|
|
25401
|
+
justAwaitedPublication: compartmentPhase.justAwaitedPublication,
|
|
25402
|
+
activeRunBlocksMaterialization: lateActiveRunBlocksMaterialization,
|
|
25403
|
+
forceMaterializationPercentage
|
|
25404
|
+
})) : protectionCacheBustingPass;
|
|
25319
25405
|
const calibrationBustReason = protectionFoldWillBust ? "fold" : contextUsage.percentage >= forceMaterializationPercentage ? "force" : deps.pendingMaterializationSessions.has(sessionId) ? "flush" : consumingDeferredEarly || compartmentPhase.justAwaitedPublication ? "refresh" : schedulerDecision === "execute" ? "execute" : "unknown";
|
|
25320
25406
|
sessionDecisionCalibration(db, sessionId, {
|
|
25321
25407
|
bustPermitted: protectionCacheBustingPass,
|
|
@@ -25324,14 +25410,13 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25324
25410
|
onAdopt: (message) => sessionLog2(sessionId, message)
|
|
25325
25411
|
});
|
|
25326
25412
|
let contextUsageFromEstimate = hostOverWindow;
|
|
25327
|
-
if (contextUsage.inputTokens <= 0 &&
|
|
25413
|
+
if (contextUsage.inputTokens <= 0 && sizeAsPricedPass) {
|
|
25328
25414
|
const overflowRecoveryPass = usagePercentageSynthetic || emergencyRecoveryArmed;
|
|
25329
25415
|
const savedProviderReading = overflowRecoveryPass || usageResetAfterRefusal ? null : savedProviderReadingForPass({
|
|
25330
25416
|
persisted: persistedUsageBeforeResets,
|
|
25331
25417
|
currentModelKey: currentModelKeyForBoundary ?? (hardModelKey || undefined),
|
|
25332
25418
|
contextLimit: resolvedContextLimit,
|
|
25333
|
-
lastResponseTime: sessionMeta.lastResponseTime
|
|
25334
|
-
cacheExpired: hardCacheExpired
|
|
25419
|
+
lastResponseTime: sessionMeta.lastResponseTime
|
|
25335
25420
|
});
|
|
25336
25421
|
let pressureEstimate;
|
|
25337
25422
|
try {
|
|
@@ -25552,6 +25637,31 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25552
25637
|
logIncompleteFinalWire(finalWireEstimate, messages);
|
|
25553
25638
|
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
25639
|
}
|
|
25640
|
+
let servedPressureTokens;
|
|
25641
|
+
if (providerReadingMissing) {
|
|
25642
|
+
servedPressureTokens = finalWireEstimate?.pressureTokens;
|
|
25643
|
+
if (servedPressureTokens === undefined) {
|
|
25644
|
+
try {
|
|
25645
|
+
servedPressureTokens = estimateFinalWireInputTokens({
|
|
25646
|
+
messages,
|
|
25647
|
+
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
25648
|
+
providerID: modelForBudget?.providerID,
|
|
25649
|
+
modelID: modelForBudget?.modelID,
|
|
25650
|
+
agentName: notificationParams.agent,
|
|
25651
|
+
sessionId
|
|
25652
|
+
}).pressureTokens;
|
|
25653
|
+
} catch (error) {
|
|
25654
|
+
sessionLog2(sessionId, `transform: local count of the served request unavailable: ${getErrorMessage(error)}`);
|
|
25655
|
+
}
|
|
25656
|
+
}
|
|
25657
|
+
}
|
|
25658
|
+
localWireReadings.record({
|
|
25659
|
+
sessionId,
|
|
25660
|
+
providerReadingMissing,
|
|
25661
|
+
modelKey: localReadingModelKey,
|
|
25662
|
+
usableWindow: localReadingWindow,
|
|
25663
|
+
pressureTokens: servedPressureTokens
|
|
25664
|
+
});
|
|
25555
25665
|
if ((finalWireEstimate?.refusalGrade || finalWireEstimate?.refusalBasis === "byte-bound" && finalWireEstimate.refusalTokens !== undefined) && boundaryContextLimit > 0 && (finalWireEstimate.refusalTokens ?? finalWireEstimate.tokens) > boundaryContextLimit) {
|
|
25556
25666
|
const signedFitRetryWanted = !thinkingFitRetries.has(sessionId) && activeThinkingPrefixHold && hasActiveAnthropicThinkingTurn(messages, resolvedProviderID, modelForBudget?.modelID);
|
|
25557
25667
|
if (signedFitRetryWanted && originalForThinkingFit) {
|
|
@@ -26268,7 +26378,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
26268
26378
|
}
|
|
26269
26379
|
const isCacheBusting = deps.systemPromptRefreshSessions.has(sessionId);
|
|
26270
26380
|
const idleCacheExpired = sessionMetaEarly !== undefined && computeHardCacheExpired(sessionMetaEarly.cacheTtl, sessionMetaEarly.lastResponseTime, Date.now());
|
|
26271
|
-
const adoptSystemChange =
|
|
26381
|
+
const adoptSystemChange = requestMessagesFinal && !isHeldHeadForRequest(sessionId, currentLkgRequestIdentity(sessionId));
|
|
26272
26382
|
const liveSystemContent = output.system.join(`
|
|
26273
26383
|
`);
|
|
26274
26384
|
if (liveSystemContent.length === 0)
|
|
@@ -26310,9 +26420,9 @@ function createSystemPromptHashHandler(deps) {
|
|
|
26310
26420
|
const contentOrPresetChanged = hasPersistedHash && stableCandidateHash !== previousHash;
|
|
26311
26421
|
const rewritePermission = systemDateRefreshPermission(deps.historyRefreshSessions, dateRequest);
|
|
26312
26422
|
const signedThinkingKept = systemDateSignedThinkingKept(deps.historyRefreshSessions, dateRequest);
|
|
26313
|
-
const systemDateMayMove = (rewrite, keptSignedThinking) =>
|
|
26423
|
+
const systemDateMayMove = (rewrite, keptSignedThinking) => rewrite && keptSignedThinking !== true;
|
|
26314
26424
|
let deferredDateRefresh = false;
|
|
26315
|
-
if (currentDate && stickyDate && currentDate !== stickyDate &&
|
|
26425
|
+
if (currentDate && stickyDate && currentDate !== stickyDate && isCacheBusting && !contentOrPresetChanged && !requestMessagesFinal) {
|
|
26316
26426
|
const liveElements = [...output.system];
|
|
26317
26427
|
deferredDateRefresh = waitForSystemDateRefresh(deps.historyRefreshSessions, dateRequest, (permitted, keptSignedThinking) => {
|
|
26318
26428
|
if (!systemDateMayMove(permitted, keptSignedThinking)) {
|
|
@@ -26372,7 +26482,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
26372
26482
|
const currentPrompt = previousPrompt && previousHash === currentHash ? previousPrompt : snapshotSystemPrompt(output.system, promptSurface.preset);
|
|
26373
26483
|
diagnosticPrompts.set(sessionId, currentPrompt);
|
|
26374
26484
|
if (previousHash !== "" && previousHash !== "0" && previousHash !== currentHash) {
|
|
26375
|
-
sessionLog2(sessionId, `system prompt hash changed: ${previousHash} → ${currentHash} (len=${systemContent.length}), ${
|
|
26485
|
+
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
26486
|
noteSystemPromptHashChange(sessionId);
|
|
26377
26487
|
if (!adoptSystemChange) {
|
|
26378
26488
|
deps.historyRefreshSessions.add(sessionId);
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
} from "./index-dcjkw41m.js";
|
|
47
47
|
import {
|
|
48
48
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
49
|
-
} from "./index-
|
|
49
|
+
} from "./index-4dpvnp8k.js";
|
|
50
50
|
import {
|
|
51
51
|
embeddingModelsMatch,
|
|
52
52
|
resolveEmbeddingTextPrefixes,
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
getEmbeddingProviderIdentity,
|
|
57
57
|
dominantEmbeddingFailure,
|
|
58
58
|
LocalEmbeddingProvider
|
|
59
|
-
} from "./index-
|
|
59
|
+
} from "./index-p6gs3xpx.js";
|
|
60
60
|
import {
|
|
61
61
|
embedPauseBySession,
|
|
62
62
|
activeEmbeddingSessions,
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
enqueueShadowEmbeddingItems2,
|
|
41
41
|
getProjectEmbeddingSnapshot2,
|
|
42
42
|
embedItemsForProject2
|
|
43
|
-
} from "./index-
|
|
43
|
+
} from "./index-rhcwddn9.js";
|
|
44
44
|
import {
|
|
45
45
|
recordEmbeddingMeasurement
|
|
46
46
|
} from "./index-2amn2s73.js";
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
isEmbeddingEnabled,
|
|
53
53
|
embedText,
|
|
54
54
|
ensureMemoryEmbeddings2
|
|
55
|
-
} from "./index-
|
|
55
|
+
} from "./index-66qexmjw.js";
|
|
56
56
|
import {
|
|
57
57
|
ModuleMemoryAuthorityError2,
|
|
58
58
|
getMemoriesByProject2,
|
|
@@ -65,18 +65,18 @@ import {
|
|
|
65
65
|
sanitizeFtsQuery,
|
|
66
66
|
searchMemoriesFTS,
|
|
67
67
|
searchMemoriesFTSUnion
|
|
68
|
-
} from "./index-
|
|
68
|
+
} from "./index-kgk64zyx.js";
|
|
69
69
|
import {
|
|
70
70
|
matchedSearchSnippet,
|
|
71
71
|
getIndexedMessageCorpusSize
|
|
72
|
-
} from "./index-
|
|
72
|
+
} from "./index-m1mttf6y.js";
|
|
73
73
|
import {
|
|
74
74
|
getMessageIndexEpoch,
|
|
75
75
|
isMessageIndexSearchable,
|
|
76
76
|
withMemoryHintContent,
|
|
77
77
|
autoSearchRelevance,
|
|
78
78
|
recordAutoSearchLane
|
|
79
|
-
} from "./index-
|
|
79
|
+
} from "./index-91y4xvx6.js";
|
|
80
80
|
import {
|
|
81
81
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
82
82
|
withMessageFtsSessionFilter
|