@cortexkit/opencode-magic-context 0.49.17 → 0.49.19
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 +6 -2
- package/dist/chunk-embedding-write-worker.js +2 -2
- package/dist/{context-yhetp0kn.js → context-j31m2dv7.js} +27 -14
- package/dist/features/magic-context/dreamer/classify.d.ts +3 -0
- package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +11 -0
- package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/map-memories.d.ts +3 -0
- package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/verify.d.ts +3 -0
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
- package/dist/features/magic-context/storage-host-instruction-retention.d.ts +11 -0
- package/dist/features/magic-context/storage-host-instruction-retention.d.ts.map +1 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts +13 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-worker-evaluation.fixture.d.ts +2 -0
- package/dist/hooks/magic-context/auto-search-worker-evaluation.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/cache-busting-signals.d.ts +22 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +4 -2
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/file-token-coverage.d.ts +11 -0
- package/dist/hooks/magic-context/file-token-coverage.d.ts.map +1 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +9 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/host-served-rows.d.ts +25 -0
- package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +7 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts +13 -0
- package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/pass-outcome.d.ts +2 -0
- package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +2 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/signed-thinking-hold.d.ts +59 -0
- package/dist/hooks/magic-context/signed-thinking-hold.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-date-refresh.d.ts +15 -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/tag-content-primitives.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +6 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-context-state.d.ts +19 -0
- package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +21 -0
- 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-aabzay3h.js → index-3esx8tkf.js} +256 -50
- package/dist/{index-v8awdgvd.js → index-3h4dp9wb.js} +1 -1
- package/dist/{index-5a1ex6x8.js → index-4911rn0b.js} +3 -3
- package/dist/{index-qn7xstt2.js → index-63k48rv9.js} +1 -2
- package/dist/{index-p7m7j0cp.js → index-9zcsy3hh.js} +53 -7
- package/dist/{index-nkpmm9q8.js → index-c1p88z1y.js} +3 -3
- package/dist/{index-hqhm3wke.js → index-cf74k5ak.js} +2 -2
- package/dist/{index-vrzjhftj.js → index-dxmq29t1.js} +4 -4
- package/dist/{index-kmdj7dsq.js → index-edmpdxcw.js} +1 -1
- package/dist/{index-4yt7dtf4.js → index-jhghdnsm.js} +113 -44
- package/dist/{index-fb2qxs2y.js → index-jrr131e0.js} +2 -2
- package/dist/{index-a7c4r5re.js → index-rpxdjkm0.js} +216 -40
- package/dist/{index-cwzfcbtq.js → index-se4m2g6w.js} +10 -1
- package/dist/index.js +21 -17
- package/dist/{message-index-bounded-1633vc7f.js → message-index-bounded-zyc8h32y.js} +3 -3
- package/dist/{message-index-dprebmtt.js → message-index-gtpqnj8w.js} +3 -3
- package/dist/migration-worker.js +2 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-4zp09ejb.js → read-session-chunk-jjb48bt9.js} +2 -2
- package/dist/{recomp-orchestrator-z3ecszx6.js → recomp-orchestrator-999jj4bc.js} +8 -8
- package/dist/{search-archive-znyy44ve.js → search-archive-6vm0e2f5.js} +3 -3
- package/dist/{search-6mee3vty.js → search-xsqk1bj4.js} +6 -6
- package/dist/shared/model-suggestion-retry.d.ts +30 -1
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/prompt-async-transport.d.ts.map +1 -1
- package/dist/{storage-tags-8qns3012.js → storage-tags-r7k9tjcv.js} +1 -1
- package/dist/tools/ctx-expand/rust-mode-tag.test-support.d.ts +15 -0
- package/dist/tools/ctx-expand/rust-mode-tag.test-support.d.ts.map +1 -0
- package/dist/tools/ctx-expand/tools.d.ts +11 -0
- package/dist/tools/ctx-expand/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-3ydzxa62.js → transform-postprocess-phase-jj99r7z2.js} +8 -8
- package/dist/v2/auto-search-worker.js +6 -2
- package/dist/v2/chunk-embedding-write-worker.js +2 -2
- package/dist/v2/{context-jn3zpeqh.js → context-y5yamxak.js} +378 -92
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts.map +1 -1
- package/dist/v2/{message-index-pxehjpzx.js → message-index-8vz2pq76.js} +3 -3
- package/dist/v2/{message-index-bounded-hpejqyd8.js → message-index-bounded-spd8r7pj.js} +3 -3
- package/dist/v2/migration-worker.js +2 -2
- package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
- package/dist/v2/{read-session-chunk-zdppn4bj.js → read-session-chunk-cwkxrmns.js} +2 -2
- package/dist/v2/{recomp-orchestrator-cmqnfpp3.js → recomp-orchestrator-f6m9jr7p.js} +7 -7
- package/dist/v2/{search-archive-gfh11vs0.js → search-archive-wve3tq1k.js} +3 -3
- package/dist/v2/{search-66842dya.js → search-hwg7jfbj.js} +6 -6
- package/dist/v2/{server-zyzawhdw.js → server-27gq4mfz.js} +2 -2
- package/dist/v2/{server-3rhpvy84.js → server-2ar62dyx.js} +10 -1
- package/dist/v2/{server-ec4ca92p.js → server-45q69hkq.js} +1 -1
- package/dist/v2/{server-fw7wrk01.js → server-6vdzn1td.js} +216 -40
- package/dist/v2/{server-kh7dpa1a.js → server-9hx7g5jp.js} +53 -7
- package/dist/v2/{server-gtfhttbr.js → server-bmymkx73.js} +2 -2
- package/dist/v2/{server-vsw8tmm6.js → server-gsxjv2q2.js} +4 -4
- package/dist/v2/{server-my7k4eds.js → server-hm38q7r0.js} +1 -1
- package/dist/v2/{server-gpvay0xz.js → server-xq7dfjke.js} +1 -2
- package/dist/v2/server.js +2 -2
- package/dist/v2/{storage-tags-1h8k6ra9.js → storage-tags-3wdb8zph.js} +1 -1
- package/dist/v2/store-reader.d.ts +6 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{wrapup-orchestrator-xs8redz9.js → wrapup-orchestrator-embdz8gj.js} +7 -7
- package/dist/{wrapup-orchestrator-j7d7ry5b.js → wrapup-orchestrator-whhbjmaz.js} +9 -9
- package/package.json +1 -1
- package/src/shared/model-suggestion-retry.test.ts +166 -0
- package/src/shared/model-suggestion-retry.ts +165 -14
- package/src/shared/prompt-async-transport.test.ts +107 -0
- package/src/shared/prompt-async-transport.ts +39 -0
|
@@ -127,6 +127,8 @@ import {
|
|
|
127
127
|
hasProcessLocalLkgProof,
|
|
128
128
|
lkgDirtyRevision,
|
|
129
129
|
rememberLkgDirtyRevision,
|
|
130
|
+
readPersistedLkgUntaggedInputIds,
|
|
131
|
+
persistLkgUntaggedInputIds,
|
|
130
132
|
noteLkgRecoveryPrefix,
|
|
131
133
|
readLkgRecoveryPrefix,
|
|
132
134
|
noteLkgHealthyPrefix,
|
|
@@ -267,6 +269,7 @@ import {
|
|
|
267
269
|
peekNoteNudgeText,
|
|
268
270
|
markNoteNudgeDelivered,
|
|
269
271
|
clearNoteNudgeTriggerAndCooldown,
|
|
272
|
+
omitIncompleteFileTokenTotals,
|
|
270
273
|
RECOVERY_NO_HEAD_LIMIT,
|
|
271
274
|
deriveProtectedTailTokenTarget,
|
|
272
275
|
selectPerRunCap,
|
|
@@ -279,7 +282,7 @@ import {
|
|
|
279
282
|
startCompartmentAgent,
|
|
280
283
|
setRecompStarting2,
|
|
281
284
|
setRecompTerminal2
|
|
282
|
-
} from "./server-
|
|
285
|
+
} from "./server-6vdzn1td.js";
|
|
283
286
|
import {
|
|
284
287
|
resolveHistorianModel2
|
|
285
288
|
} from "./server-8cd2j99z.js";
|
|
@@ -304,7 +307,7 @@ import {
|
|
|
304
307
|
openDatabaseAsync,
|
|
305
308
|
isDatabasePersisted,
|
|
306
309
|
getDatabasePersistenceError
|
|
307
|
-
} from "./server-
|
|
310
|
+
} from "./server-bmymkx73.js";
|
|
308
311
|
import {
|
|
309
312
|
pruneMissingProjectIdentities,
|
|
310
313
|
setHomeProjectPermission,
|
|
@@ -331,12 +334,15 @@ import {
|
|
|
331
334
|
clearCachedM0,
|
|
332
335
|
expandToolPart,
|
|
333
336
|
markHostUnservedRow,
|
|
337
|
+
markCoveredInstructionRow,
|
|
338
|
+
isCoveredInstructionRow,
|
|
339
|
+
takeCoveredInstructionRows,
|
|
340
|
+
cloneKeepingCoveredInstructionMarks,
|
|
334
341
|
estimateTrueRawMessageTokens,
|
|
335
342
|
stripSystemInjection,
|
|
336
343
|
isTextPart,
|
|
337
344
|
isToolPartWithOutput,
|
|
338
345
|
isFilePart,
|
|
339
|
-
buildFileSourceContent,
|
|
340
346
|
toolPartHasUserAnswer,
|
|
341
347
|
DreamTokenBudgetExceeded,
|
|
342
348
|
createDreamTokenBudget,
|
|
@@ -414,6 +420,8 @@ import {
|
|
|
414
420
|
applyStrippedPlaceholderDelta,
|
|
415
421
|
THINKING_BINDING_RECOVERY_FROZEN_PREFIX,
|
|
416
422
|
thinkingBindingRecoveryFrozenId,
|
|
423
|
+
compactionOffThinkingFrozenId,
|
|
424
|
+
compactionOffFrozenThinkingIds,
|
|
417
425
|
getThinkingBindingRecoveryTarget,
|
|
418
426
|
clearThinkingBindingRecoveryIf,
|
|
419
427
|
getMergedReasoningStrippedIds,
|
|
@@ -474,6 +482,7 @@ import {
|
|
|
474
482
|
projectOpencodeReasoningBudgetCutoff,
|
|
475
483
|
DEFAULT_KEEP_REASONING_TOKENS,
|
|
476
484
|
resolveKeepReasoningTokens,
|
|
485
|
+
reasoningStepCost,
|
|
477
486
|
reasoningBudgetCutoff,
|
|
478
487
|
reasoningTextAndOpaque,
|
|
479
488
|
opencodeReasoningBudgetCutoff,
|
|
@@ -510,7 +519,7 @@ import {
|
|
|
510
519
|
readRawSessionMessageById2,
|
|
511
520
|
readSessionChunk2,
|
|
512
521
|
readRawSessionSeedTail2
|
|
513
|
-
} from "./server-
|
|
522
|
+
} from "./server-9hx7g5jp.js";
|
|
514
523
|
import {
|
|
515
524
|
embedPauseBySession,
|
|
516
525
|
embedRunStateBySession,
|
|
@@ -616,7 +625,7 @@ import {
|
|
|
616
625
|
isMessageIndexReconciledThrough2,
|
|
617
626
|
indexMessagesAfterOrdinal2,
|
|
618
627
|
sweepOrphanedOpenCodeMessageIndexesCooperatively2
|
|
619
|
-
} from "./server-
|
|
628
|
+
} from "./server-2ar62dyx.js";
|
|
620
629
|
import {
|
|
621
630
|
stableStringify,
|
|
622
631
|
getTemporalDecisions,
|
|
@@ -719,7 +728,7 @@ import {
|
|
|
719
728
|
adoptNullOwnerToolTag2,
|
|
720
729
|
getCandidateToolOwners2,
|
|
721
730
|
pickNearestPriorOwner2
|
|
722
|
-
} from "./server-
|
|
731
|
+
} from "./server-27gq4mfz.js";
|
|
723
732
|
import {
|
|
724
733
|
resolveOpenCodeDbPath,
|
|
725
734
|
assertOpenCodeStoreGeneration,
|
|
@@ -753,7 +762,7 @@ import {
|
|
|
753
762
|
resolveStoredPathWorkspaceIdentity,
|
|
754
763
|
storedPathBelongsToWorkspace,
|
|
755
764
|
computeWorkspaceEpochFingerprint
|
|
756
|
-
} from "./server-
|
|
765
|
+
} from "./server-xq7dfjke.js";
|
|
757
766
|
import {
|
|
758
767
|
configureContextDatabasePragmas2
|
|
759
768
|
} from "./server-fb3zxn06.js";
|
|
@@ -799,7 +808,7 @@ import {
|
|
|
799
808
|
readGitFileChangeTimesSince,
|
|
800
809
|
verificationFileExists,
|
|
801
810
|
normalizeVerificationFiles
|
|
802
|
-
} from "./server-
|
|
811
|
+
} from "./server-hm38q7r0.js";
|
|
803
812
|
import {
|
|
804
813
|
deriveTriggerBudget2,
|
|
805
814
|
deriveHistorianChunkTokens2,
|
|
@@ -888,14 +897,14 @@ import {
|
|
|
888
897
|
resolveMemoriesByIdsForSearch2,
|
|
889
898
|
unifiedSearch2,
|
|
890
899
|
formatSearchResults2
|
|
891
|
-
} from "./server-
|
|
900
|
+
} from "./server-gsxjv2q2.js";
|
|
892
901
|
import {
|
|
893
902
|
resolvePromptContext2
|
|
894
903
|
} from "./server-fmsr7v69.js";
|
|
895
904
|
import"./server-kaqs6h31.js";
|
|
896
905
|
import {
|
|
897
906
|
renderSearchArchiveOffThread2
|
|
898
|
-
} from "./server-
|
|
907
|
+
} from "./server-45q69hkq.js";
|
|
899
908
|
import {
|
|
900
909
|
compareSemverCore
|
|
901
910
|
} from "./server-84w6rvvf.js";
|
|
@@ -5804,6 +5813,12 @@ function canConsumeDeferredOnThisPass(args) {
|
|
|
5804
5813
|
function hasReclaimRide(signals) {
|
|
5805
5814
|
return signals.hardFold || signals.force || signals.explicitFlush || signals.publishedHistory || signals.subagentExecute === true;
|
|
5806
5815
|
}
|
|
5816
|
+
function prefixMutationPermitted(gate) {
|
|
5817
|
+
return !gate.signedThinkingHold || gate.firstRender || gate.idleExpiry || gate.emergency;
|
|
5818
|
+
}
|
|
5819
|
+
function reclaimRidePermitted(signals, gate) {
|
|
5820
|
+
return prefixMutationPermitted(gate) && hasReclaimRide(signals);
|
|
5821
|
+
}
|
|
5807
5822
|
var RECLAIM_RIDE_NAMES = [
|
|
5808
5823
|
"hardFold",
|
|
5809
5824
|
"force",
|
|
@@ -6099,8 +6114,9 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
|
|
|
6099
6114
|
const canClearReasoning = reasoningProjection?.canClearReasoning ?? modelAcceptsEmptyContent(reasoningProjection?.providerID);
|
|
6100
6115
|
const projectedPostDropPercentage = estimateProjectedPostDropPercentage(db, sessionId, usage, preloadedActiveTags ?? getActiveTagsBySession2(db, sessionId), keepReasoningTokens, sessionMeta.clearedReasoningThroughTag, canClearReasoning, reasoningProjection?.budgetCutoff, eligiblePendingDropTagIds);
|
|
6101
6116
|
const relativePostDropTarget = executeThresholdPercentage * POST_DROP_TARGET_RATIO;
|
|
6117
|
+
const ridePermitted = reclaimRide !== undefined && (reclaimRide.permission ? reclaimRidePermitted(reclaimRide, reclaimRide.permission) : hasReclaimRide(reclaimRide));
|
|
6102
6118
|
const rideLabel = reclaimRide ? reclaimRideLabel(reclaimRide) : "ride=none";
|
|
6103
|
-
const dropsCanLand =
|
|
6119
|
+
const dropsCanLand = ridePermitted;
|
|
6104
6120
|
const forceMaterializationPercentage = escalationBands(executeThresholdPercentage).forceMaterializationPercentage;
|
|
6105
6121
|
if (usage.percentage >= forceMaterializationPercentage) {
|
|
6106
6122
|
if (dropsCanLand && projectedPostDropPercentage !== null && projectedPostDropPercentage <= relativePostDropTarget) {
|
|
@@ -7023,6 +7039,27 @@ function resolveHistoryBudgetTokens(historyBudgetPercentage, contextUsage, execu
|
|
|
7023
7039
|
}) / 100) * historyBudgetPercentage);
|
|
7024
7040
|
}
|
|
7025
7041
|
|
|
7042
|
+
// src/features/magic-context/storage-host-instruction-retention.ts
|
|
7043
|
+
var NAMESPACE = "hostInstructionRetention";
|
|
7044
|
+
var enabled = true;
|
|
7045
|
+
function hostInstructionRetentionEnabled() {
|
|
7046
|
+
return enabled;
|
|
7047
|
+
}
|
|
7048
|
+
function isHostInstructionRetentionOn(db, sessionId) {
|
|
7049
|
+
const lane = readReplayEnvelope(db, sessionId)[NAMESPACE];
|
|
7050
|
+
return typeof lane === "object" && lane !== null && lane.on === true;
|
|
7051
|
+
}
|
|
7052
|
+
function markHostInstructionRetention(db, sessionId) {
|
|
7053
|
+
return updateReplayDocument(db, sessionId, (doc) => {
|
|
7054
|
+
const lane = doc[NAMESPACE];
|
|
7055
|
+
if (typeof lane === "object" && lane !== null && lane.on === true)
|
|
7056
|
+
return false;
|
|
7057
|
+
doc.version = 2;
|
|
7058
|
+
doc[NAMESPACE] = { on: true };
|
|
7059
|
+
return true;
|
|
7060
|
+
});
|
|
7061
|
+
}
|
|
7062
|
+
|
|
7026
7063
|
// src/hooks/magic-context/pending-drop-eligibility.ts
|
|
7027
7064
|
function pendingDropVeto(tagNumber, target, protectedTagIds) {
|
|
7028
7065
|
if (protectedTagIds.has(tagNumber))
|
|
@@ -7646,7 +7683,7 @@ function foldExecutesThisPass(foldDue, materialized) {
|
|
|
7646
7683
|
}
|
|
7647
7684
|
|
|
7648
7685
|
// src/features/magic-context/storage-caveman-rules.ts
|
|
7649
|
-
var
|
|
7686
|
+
var NAMESPACE2 = "caveman";
|
|
7650
7687
|
var CURRENT_RULES_VERSION = 2;
|
|
7651
7688
|
var ORIGINAL_RULES = {
|
|
7652
7689
|
currentRules: false,
|
|
@@ -7665,7 +7702,7 @@ function parseState(lane) {
|
|
|
7665
7702
|
}
|
|
7666
7703
|
function getCavemanReplayState(db, sessionId) {
|
|
7667
7704
|
try {
|
|
7668
|
-
return parseState(readReplayEnvelope(db, sessionId)[
|
|
7705
|
+
return parseState(readReplayEnvelope(db, sessionId)[NAMESPACE2]);
|
|
7669
7706
|
} catch (error) {
|
|
7670
7707
|
if (error instanceof ReplayDocumentError)
|
|
7671
7708
|
return ORIGINAL_RULES;
|
|
@@ -7675,11 +7712,11 @@ function getCavemanReplayState(db, sessionId) {
|
|
|
7675
7712
|
function recordCavemanCurrentRules(db, sessionId, englishWordRules, legacyReasoningTags) {
|
|
7676
7713
|
const tags = [...new Set(legacyReasoningTags)].sort((a, b) => a - b);
|
|
7677
7714
|
const persisted = updateReplayDocument(db, sessionId, (doc) => {
|
|
7678
|
-
const current = parseState(doc[
|
|
7715
|
+
const current = parseState(doc[NAMESPACE2]);
|
|
7679
7716
|
if (current.currentRules && current.englishWordRules === englishWordRules)
|
|
7680
7717
|
return false;
|
|
7681
7718
|
doc.version = 2;
|
|
7682
|
-
doc[
|
|
7719
|
+
doc[NAMESPACE2] = {
|
|
7683
7720
|
rules: CURRENT_RULES_VERSION,
|
|
7684
7721
|
legacyReasoningTags: current.currentRules ? [...current.legacyReasoningTags].sort((a, b) => a - b) : tags,
|
|
7685
7722
|
...englishWordRules ? {} : { englishWordRules: false }
|
|
@@ -9160,25 +9197,12 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
9160
9197
|
const filePart = part;
|
|
9161
9198
|
const messageParts = message.parts;
|
|
9162
9199
|
const contentId = `${messageId}:file${partIndex}`;
|
|
9163
|
-
const existingTagId = resolver.resolve(messageId, "file", contentId, fileOrdinal);
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
|
|
9169
|
-
}));
|
|
9170
|
-
accAssignTag += performance.now() - _tAssignFile;
|
|
9171
|
-
if (existingTagId === undefined) {
|
|
9172
|
-
const sourceContent = buildFileSourceContent(message.parts);
|
|
9173
|
-
if (sourceContent) {
|
|
9174
|
-
const _tSaveFile = performance.now();
|
|
9175
|
-
if (options.refreshSourceContents)
|
|
9176
|
-
replaceSourceContent(db, sessionId, tagId, sourceContent);
|
|
9177
|
-
else
|
|
9178
|
-
saveSourceContent(db, sessionId, tagId, sourceContent);
|
|
9179
|
-
accSaveSource += performance.now() - _tSaveFile;
|
|
9180
|
-
}
|
|
9181
|
-
}
|
|
9200
|
+
const existingTagId = resolver.resolve(messageId, "file", contentId, fileOrdinal) ?? getTagNumberByMessageId2(db, sessionId, contentId) ?? undefined;
|
|
9201
|
+
fileOrdinal += 1;
|
|
9202
|
+
if (existingTagId === undefined)
|
|
9203
|
+
continue;
|
|
9204
|
+
const tagId = existingTagId;
|
|
9205
|
+
tagger.bindTag(sessionId, contentId, tagId);
|
|
9182
9206
|
messageTagNumbers.set(message, Math.max(messageTagNumbers.get(message) ?? 0, tagId));
|
|
9183
9207
|
targets.set(tagId, {
|
|
9184
9208
|
message,
|
|
@@ -9200,7 +9224,6 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
9200
9224
|
return true;
|
|
9201
9225
|
}
|
|
9202
9226
|
});
|
|
9203
|
-
fileOrdinal += 1;
|
|
9204
9227
|
}
|
|
9205
9228
|
}
|
|
9206
9229
|
if (message.info.role === "assistant" && !messageHasTextPart) {
|
|
@@ -9385,7 +9408,10 @@ function freezeReasoningOnBustingPass(args) {
|
|
|
9385
9408
|
return { strip: null, persistenceFailed: false };
|
|
9386
9409
|
let persisted = false;
|
|
9387
9410
|
try {
|
|
9388
|
-
persisted = addMergedReasoningStrippedIds(args.db, args.sessionId,
|
|
9411
|
+
persisted = addMergedReasoningStrippedIds(args.db, args.sessionId, [
|
|
9412
|
+
...messageIds.map(thinkingBindingRecoveryFrozenId),
|
|
9413
|
+
...args.compactionOff ? messageIds.map(compactionOffThinkingFrozenId) : []
|
|
9414
|
+
]);
|
|
9389
9415
|
} catch (error) {
|
|
9390
9416
|
sessionLog2(args.sessionId, "proactive thinking strip: persistence threw:", error);
|
|
9391
9417
|
}
|
|
@@ -9895,7 +9921,7 @@ function finalizeMessageRepresentation(messages, resolvedProviderID, options) {
|
|
|
9895
9921
|
clearedParts = stripClearedReasoning(targetedMessages.filter((message) => !restoredMessages.has(message)));
|
|
9896
9922
|
}
|
|
9897
9923
|
}
|
|
9898
|
-
const bindingRecoveryParts =
|
|
9924
|
+
const bindingRecoveryParts = stripReasoningFromAssistantIds(messages, resolvedProviderID, options?.frozenThinkingBindingMessageIds ?? new Set, restoredMessages);
|
|
9899
9925
|
const mergedReasoningParts = bindingRecoveryParts + (options?.skipMergedReasoningStrip ? 0 : stripReasoningFromMergedAssistants(messages, resolvedProviderID, {
|
|
9900
9926
|
mutationExemptMessage: options?.reasoningMutationExemptMessage,
|
|
9901
9927
|
frozenMessageIds: options?.mergedReasoningStrippedIds,
|
|
@@ -9964,7 +9990,7 @@ async function runPostTransformPhase(args) {
|
|
|
9964
9990
|
routinePressureAppliedBySession.set(args.sessionId, true);
|
|
9965
9991
|
}
|
|
9966
9992
|
const routinePressureAlreadyApplied = args.fullFeatureMode && executePressureEligible && routinePressureAppliedBySession.get(args.sessionId) === true;
|
|
9967
|
-
if (args.contextUsage.percentage > 0 && args.contextUsage.percentage < args.forceMaterializationPercentage - 5 && getEmergencyInputSample(args.db, args.sessionId) > 0) {
|
|
9993
|
+
if (args.contextUsageFromEstimate !== true && args.contextUsage.percentage > 0 && args.contextUsage.percentage < args.forceMaterializationPercentage - 5 && getEmergencyInputSample(args.db, args.sessionId) > 0) {
|
|
9968
9994
|
clearEmergencyDropSample(args.db, args.sessionId);
|
|
9969
9995
|
}
|
|
9970
9996
|
const activeCompartmentRun = args.canRunCompartments ? getActiveCompartmentRun(args.sessionId) : undefined;
|
|
@@ -9972,8 +9998,9 @@ async function runPostTransformPhase(args) {
|
|
|
9972
9998
|
let deferredMaterialize = args.canConsumeDeferredLate && deferredMaterializationWasPending;
|
|
9973
9999
|
let materializationRequested = isExplicitFlush || deferredMaterialize;
|
|
9974
10000
|
const m0M1EnabledForFold = args.m0M1 !== undefined && (!!args.m0M1.projectPath || !!args.m0M1.projectDirectory) && (args.fullFeatureMode || compactionOff);
|
|
9975
|
-
const frozenThinking = new Set(args.activeThinkingTurn ? getMergedReasoningStrippedIds(args.db, args.sessionId) : []);
|
|
9976
|
-
const
|
|
10001
|
+
const frozenThinking = new Set(args.activeThinkingTurn || compactionOff ? getMergedReasoningStrippedIds(args.db, args.sessionId) : []);
|
|
10002
|
+
const compactionOffFrozenThinking = compactionOff ? compactionOffFrozenThinkingIds(frozenThinking) : new Set;
|
|
10003
|
+
const bindingThinking = compactionOff ? new Set(compactionOffFrozenThinking) : new Set([...frozenThinking].filter((id) => id.startsWith(THINKING_BINDING_RECOVERY_FROZEN_PREFIX)).map((id) => id.slice(THINKING_BINDING_RECOVERY_FROZEN_PREFIX.length)));
|
|
9977
10004
|
const retainedThinking = args.activeThinkingTurn ? retainedActiveThinkingParts({
|
|
9978
10005
|
messages: args.messages,
|
|
9979
10006
|
providerID: args.resolvedProviderID,
|
|
@@ -9994,19 +10021,24 @@ async function runPostTransformPhase(args) {
|
|
|
9994
10021
|
if (tag && tag > 0)
|
|
9995
10022
|
safeReasoningCutoff = Math.min(safeReasoningCutoff, tag - 1);
|
|
9996
10023
|
}
|
|
9997
|
-
let activeThinkingPrefixHold = args.activeThinkingPrefixHold === true
|
|
10024
|
+
let activeThinkingPrefixHold = args.activeThinkingPrefixHold === true;
|
|
9998
10025
|
let freezeM0M1 = args.freezeM0M1 === true || activeThinkingPrefixHold;
|
|
9999
10026
|
let rewritingSignedPrefix = false;
|
|
10000
10027
|
let thinkingReleasedForFit = false;
|
|
10001
|
-
const releaseThinkingForRewrite = (forFit = false) => {
|
|
10028
|
+
const releaseThinkingForRewrite = (forFit = false, stripInCompactionOff = false) => {
|
|
10029
|
+
const stripOffWire = compactionOff && stripInCompactionOff;
|
|
10002
10030
|
const stripped = freezeReasoningOnBustingPass({
|
|
10003
10031
|
db: args.db,
|
|
10004
10032
|
sessionId: args.sessionId,
|
|
10005
10033
|
messages: args.messages,
|
|
10006
|
-
alreadyFrozen: bindingThinking
|
|
10034
|
+
alreadyFrozen: bindingThinking,
|
|
10035
|
+
compactionOff: stripOffWire
|
|
10007
10036
|
});
|
|
10008
10037
|
if (stripped.persistenceFailed)
|
|
10009
10038
|
throw new Error("Cannot persist signed thinking omission before prefix rewrite");
|
|
10039
|
+
if (stripOffWire)
|
|
10040
|
+
for (const id of stripped.strip?.messageIds ?? [])
|
|
10041
|
+
compactionOffFrozenThinking.add(id);
|
|
10010
10042
|
retainedThinking.clear();
|
|
10011
10043
|
protectedThinkingMessages.clear();
|
|
10012
10044
|
activeThinkingTurn = false;
|
|
@@ -10016,7 +10048,7 @@ async function runPostTransformPhase(args) {
|
|
|
10016
10048
|
rewritingSignedPrefix = true;
|
|
10017
10049
|
thinkingReleasedForFit ||= forFit;
|
|
10018
10050
|
};
|
|
10019
|
-
if (activeThinkingPrefixHold && args.
|
|
10051
|
+
if (args.forceSignedRebuildForFit && (activeThinkingPrefixHold || activeThinkingTurn && args.thinkingBindingRecoveryEnabledForModel === true)) {
|
|
10020
10052
|
releaseThinkingForRewrite(true);
|
|
10021
10053
|
}
|
|
10022
10054
|
const foldDueDecision = m0M1EnabledForFold && args.m0M1 && !freezeM0M1 ? mustMaterialize({
|
|
@@ -10104,7 +10136,7 @@ async function runPostTransformPhase(args) {
|
|
|
10104
10136
|
});
|
|
10105
10137
|
preparedPrefix = foldResult;
|
|
10106
10138
|
if (activeThinkingPrefixHold && firstRenderBust && committedFoldBustsServedPrefix) {
|
|
10107
|
-
releaseThinkingForRewrite();
|
|
10139
|
+
releaseThinkingForRewrite(false, true);
|
|
10108
10140
|
}
|
|
10109
10141
|
prefixPreflightFailed = foldResult.materializationContentionRetryExhausted === true;
|
|
10110
10142
|
foldExecutedThisPass = foldExecutesThisPass(foldDueDecision.value || softRefreshOpportunity, foldResult.m0RematerializedThisPass);
|
|
@@ -10153,7 +10185,7 @@ async function runPostTransformPhase(args) {
|
|
|
10153
10185
|
const shouldReadPendingOps = !compactionOff && (materializationRequested || publishedM1RefreshedThisPass || args.schedulerDecision === "execute" || forceMaterialization || foldExecutedThisPass || firstRenderBust || compartmentRunning);
|
|
10154
10186
|
const pendingOps = shouldReadPendingOps ? getPendingOps(args.db, args.sessionId) : [];
|
|
10155
10187
|
const hasPendingUserOps = pendingOps.length > 0;
|
|
10156
|
-
if (args.schedulerDecision === "execute" && pendingOps.some((op) => newTargets.get(op.tagId)?.thinkingDropProtected))
|
|
10188
|
+
if (args.schedulerDecision === "execute" && args.thinkingBindingRecoveryEnabledForModel !== true && pendingOps.some((op) => newTargets.get(op.tagId)?.thinkingDropProtected))
|
|
10157
10189
|
requestPendingMaterialization(args.pendingMaterializationSessions, args.sessionId, "thinking_hold");
|
|
10158
10190
|
const formatPendingOpsDepth = () => {
|
|
10159
10191
|
const depth = getPendingOpsCount(args.db, args.sessionId);
|
|
@@ -10164,16 +10196,34 @@ async function runPostTransformPhase(args) {
|
|
|
10164
10196
|
const rideSignals = {
|
|
10165
10197
|
subagentExecute: !args.fullFeatureMode && args.schedulerDecision === "execute",
|
|
10166
10198
|
hardFold: rewritingSignedPrefix || foldBustsServedPrefixThisPass || firstRenderBust || idleExpiryRebuild,
|
|
10167
|
-
force: emergencyDropEligible && (args.contextUsage.percentage >= 95 || getEmergencyInputSample(args.db, args.sessionId) === 0),
|
|
10199
|
+
force: emergencyDropEligible && (args.contextUsage.percentage >= 95 || args.contextUsageFromEstimate !== true && getEmergencyInputSample(args.db, args.sessionId) === 0),
|
|
10168
10200
|
explicitFlush: isExplicitFlush && hasPendingMaterializationOrigin(args.pendingMaterializationSessions, args.sessionId, "user_flush"),
|
|
10169
10201
|
publishedHistory: !prefixPreflightFailed && (publishedM1RefreshedThisPass || !m0M1EnabledForFold && (args.pendingCompartmentInjection?.compartmentCount ?? 0) > 0 && legacyPublishedHeadChanged(args))
|
|
10170
10202
|
};
|
|
10171
|
-
const publishedWorkDrainAllowed = !compactionOff && (
|
|
10203
|
+
const publishedWorkDrainAllowed = !compactionOff && reclaimRidePermitted(rideSignals, {
|
|
10204
|
+
signedThinkingHold: activeThinkingPrefixHold,
|
|
10205
|
+
firstRender: firstRenderBust,
|
|
10206
|
+
idleExpiry: idleExpiryRebuild,
|
|
10207
|
+
emergency: emergencyDropEligible
|
|
10208
|
+
});
|
|
10172
10209
|
const shouldApplyPendingOps = publishedWorkDrainAllowed;
|
|
10173
10210
|
const shouldRunHeuristics = publishedWorkDrainAllowed && (rideSignals.publishedHistory || materializationRequested || forceMaterialization || foldBustsServedPrefixThisPass || firstRenderBust || heldIdleExpiryRebuild || emergencyDropEligible || args.schedulerDecision === "execute" && (!alreadyRanThisTurn || !args.fullFeatureMode));
|
|
10174
10211
|
const isCacheBustingPass = publishedWorkDrainAllowed;
|
|
10175
|
-
|
|
10212
|
+
let unheldSignedTurnBust = false;
|
|
10213
|
+
if (isCacheBustingPass && !activeThinkingPrefixHold && activeThinkingTurn && args.thinkingBindingRecoveryEnabledForModel === true) {
|
|
10214
|
+
if (foldBustsServedPrefixThisPass || firstRenderBust || publishedM1RefreshedThisPass)
|
|
10215
|
+
releaseThinkingForRewrite();
|
|
10216
|
+
else {
|
|
10217
|
+
unheldSignedTurnBust = true;
|
|
10218
|
+
retainedThinking.clear();
|
|
10219
|
+
protectedThinkingMessages.clear();
|
|
10220
|
+
newTargets = args.targets;
|
|
10221
|
+
}
|
|
10222
|
+
}
|
|
10223
|
+
let recoveryTailNormalizedThisPass = false;
|
|
10224
|
+
if (args.normalizeRecoveryTail && isCacheBustingPass && !activeThinkingPrefixHold) {
|
|
10176
10225
|
args.normalizeRecoveryTail();
|
|
10226
|
+
recoveryTailNormalizedThisPass = true;
|
|
10177
10227
|
args.tags = getTagsBySession2(args.db, args.sessionId);
|
|
10178
10228
|
newTargets = protectNewTagMutations(args.messages, args.targets, retainedThinking, args.thinkingBindingRecoveryEnabledForModel === true);
|
|
10179
10229
|
}
|
|
@@ -10644,6 +10694,26 @@ async function runPostTransformPhase(args) {
|
|
|
10644
10694
|
}
|
|
10645
10695
|
}
|
|
10646
10696
|
const m0M1Enabled = m0M1EnabledForFold;
|
|
10697
|
+
if (m0M1Enabled && args.m0M1 && !compactionOff && args.opencode2) {
|
|
10698
|
+
const covered = args.coveredHostInstructions ?? [];
|
|
10699
|
+
if (covered.length > 0 || canEditWholePrefix) {
|
|
10700
|
+
let retain = false;
|
|
10701
|
+
if (hostInstructionRetentionEnabled()) {
|
|
10702
|
+
try {
|
|
10703
|
+
retain = isHostInstructionRetentionOn(args.db, args.sessionId);
|
|
10704
|
+
} catch (error) {
|
|
10705
|
+
failPass("host-instruction-retention-read-failure", error);
|
|
10706
|
+
}
|
|
10707
|
+
if (!retain && canEditWholePrefix) {
|
|
10708
|
+
if (!markHostInstructionRetention(args.db, args.sessionId))
|
|
10709
|
+
failPass("host-instruction-retention-persistence-failure");
|
|
10710
|
+
retain = true;
|
|
10711
|
+
}
|
|
10712
|
+
}
|
|
10713
|
+
if (retain && covered.length > 0)
|
|
10714
|
+
args.messages.unshift(...covered);
|
|
10715
|
+
}
|
|
10716
|
+
}
|
|
10647
10717
|
if (m0M1Enabled && args.m0M1) {
|
|
10648
10718
|
if (freezeM0M1 && !preparedPrefix) {
|
|
10649
10719
|
preparedPrefix = prepareCachedM0M1Replay(args.db, args.sessionId);
|
|
@@ -10984,7 +11054,10 @@ async function runPostTransformPhase(args) {
|
|
|
10984
11054
|
const mergedReasoningStrippedIds = new Set(replaySnapshot?.mergedReasoningStrippedIds ?? []);
|
|
10985
11055
|
const frozenThinkingBindingMessageIds = new Set;
|
|
10986
11056
|
let thinkingBindingRecovery = null;
|
|
10987
|
-
if (
|
|
11057
|
+
if (compactionOff) {
|
|
11058
|
+
for (const id of compactionOffFrozenThinking)
|
|
11059
|
+
frozenThinkingBindingMessageIds.add(id);
|
|
11060
|
+
} else {
|
|
10988
11061
|
try {
|
|
10989
11062
|
for (const id of mergedReasoningStrippedIds) {
|
|
10990
11063
|
if (id.startsWith(THINKING_BINDING_RECOVERY_FROZEN_PREFIX)) {
|
|
@@ -11166,7 +11239,7 @@ async function runPostTransformPhase(args) {
|
|
|
11166
11239
|
}
|
|
11167
11240
|
}
|
|
11168
11241
|
}
|
|
11169
|
-
const prefixEditBesidesReasoningTrim = firstRenderBust || heldIdleExpiryRebuild || materializationRequested || explicitMaterializedSuccessfully || deferredMaterializedSuccessfully || foldBustsServedPrefixThisPass || publishedM1RefreshedThisPass || m0RematerializedThisPass || m0M1InjectedThisPass && historyWasConsumedThisPass || historyWasConsumedThisPass || pendingOpsDidMutate || heuristicOrReasoningEditBesidesTrim || emergency || autoReclaimDidMutateThisPass || convertedToolSkeletonsDidMutate || deferredClearedMarkerRetires || noteNudgeAppendedThisPass || todoAnchorMovedThisPass || autoSearchHintAppendedThisPass || dropModeSwitchesThisPass || firstApplicationEdits.beforeNewerThinking;
|
|
11242
|
+
const prefixEditBesidesReasoningTrim = firstRenderBust || heldIdleExpiryRebuild || materializationRequested || explicitMaterializedSuccessfully || deferredMaterializedSuccessfully || foldBustsServedPrefixThisPass || publishedM1RefreshedThisPass || m0RematerializedThisPass || m0M1InjectedThisPass && historyWasConsumedThisPass || historyWasConsumedThisPass || pendingOpsDidMutate || heuristicOrReasoningEditBesidesTrim || emergency || autoReclaimDidMutateThisPass || convertedToolSkeletonsDidMutate || deferredClearedMarkerRetires || noteNudgeAppendedThisPass || todoAnchorMovedThisPass || autoSearchHintAppendedThisPass || dropModeSwitchesThisPass || recoveryTailNormalizedThisPass || firstApplicationEdits.beforeNewerThinking;
|
|
11170
11243
|
let proactiveThinkingStrip = null;
|
|
11171
11244
|
if (!compactionOff && args.thinkingBindingRecoveryEnabledForModel === true && proactiveThinkingStripPermitted && prefixEditBesidesReasoningTrim) {
|
|
11172
11245
|
const outcome = freezeReasoningOnBustingPass({
|
|
@@ -11183,7 +11256,11 @@ async function runPostTransformPhase(args) {
|
|
|
11183
11256
|
mergedReasoningStrippedIds.add(thinkingBindingRecoveryFrozenId(messageId));
|
|
11184
11257
|
}
|
|
11185
11258
|
bustedThisPass = true;
|
|
11259
|
+
if (unheldSignedTurnBust)
|
|
11260
|
+
rewritingSignedPrefix = true;
|
|
11186
11261
|
} else if (outcome.persistenceFailed) {
|
|
11262
|
+
if (unheldSignedTurnBust)
|
|
11263
|
+
throw new Error("Cannot persist signed thinking omission after a mid-turn edit");
|
|
11187
11264
|
failPass("proactive-thinking-strip-persistence-failure");
|
|
11188
11265
|
}
|
|
11189
11266
|
}
|
|
@@ -11342,7 +11419,8 @@ async function runPostTransformPhase(args) {
|
|
|
11342
11419
|
prefixTrimStatus: deliveredPrefix?.prefixTrimStatus ?? null,
|
|
11343
11420
|
thinkingBindingRecovery,
|
|
11344
11421
|
proactiveThinkingStrip,
|
|
11345
|
-
thinkingReleasedForFit
|
|
11422
|
+
thinkingReleasedForFit,
|
|
11423
|
+
openTurnSignedThinkingKept: args.thinkingBindingRecoveryEnabledForModel === true && activeThinkingTurn && !rewritingSignedPrefix
|
|
11346
11424
|
};
|
|
11347
11425
|
}
|
|
11348
11426
|
function checkM0MutationDriftAndSignal(args) {
|
|
@@ -11512,6 +11590,7 @@ function beginSystemDateRequest(history, sessionId, stage, turnId, identity) {
|
|
|
11512
11590
|
systemDone: false,
|
|
11513
11591
|
messagesSeen: false,
|
|
11514
11592
|
permitted: undefined,
|
|
11593
|
+
signedThinkingKept: undefined,
|
|
11515
11594
|
ambiguous: identity === undefined && (turnId === undefined || sameTurn)
|
|
11516
11595
|
};
|
|
11517
11596
|
const blocked = [...requests.values()].filter((candidate) => !candidate.explicit && candidate.ambiguous && !(candidate.systemSeen && candidate.messagesSeen) && candidate.turnId === turnId).length;
|
|
@@ -11534,6 +11613,10 @@ function systemDateRefreshPermission(history, request) {
|
|
|
11534
11613
|
const current = state(history, request);
|
|
11535
11614
|
return current?.ambiguous ? undefined : current?.permitted;
|
|
11536
11615
|
}
|
|
11616
|
+
function systemDateSignedThinkingKept(history, request) {
|
|
11617
|
+
const current = state(history, request);
|
|
11618
|
+
return current?.ambiguous ? undefined : current?.signedThinkingKept;
|
|
11619
|
+
}
|
|
11537
11620
|
function waitForSystemDateRefresh(history, request, apply) {
|
|
11538
11621
|
const current = state(history, request);
|
|
11539
11622
|
if (!current)
|
|
@@ -11548,7 +11631,7 @@ function retire(history, current) {
|
|
|
11548
11631
|
if (unpairable) {
|
|
11549
11632
|
const apply = current.waiting;
|
|
11550
11633
|
current.waiting = undefined;
|
|
11551
|
-
apply?.(false);
|
|
11634
|
+
apply?.(false, undefined);
|
|
11552
11635
|
}
|
|
11553
11636
|
const channel = channels.get(history);
|
|
11554
11637
|
const requests = channel?.get(current.sessionId);
|
|
@@ -11556,14 +11639,15 @@ function retire(history, current) {
|
|
|
11556
11639
|
if (requests?.size === 0)
|
|
11557
11640
|
channel?.delete(current.sessionId);
|
|
11558
11641
|
}
|
|
11559
|
-
function finishSystemDateRefresh(history, request, permitted) {
|
|
11642
|
+
function finishSystemDateRefresh(history, request, permitted, signedThinkingKept) {
|
|
11560
11643
|
const current = state(history, request);
|
|
11561
11644
|
if (!current)
|
|
11562
11645
|
return;
|
|
11563
11646
|
current.permitted = current.ambiguous ? false : permitted;
|
|
11647
|
+
current.signedThinkingKept = current.ambiguous ? undefined : signedThinkingKept;
|
|
11564
11648
|
const apply = current.waiting;
|
|
11565
11649
|
current.waiting = undefined;
|
|
11566
|
-
apply?.(current.permitted);
|
|
11650
|
+
apply?.(current.permitted, current.signedThinkingKept);
|
|
11567
11651
|
retire(history, current);
|
|
11568
11652
|
}
|
|
11569
11653
|
function finishSystemDateHook(history, request) {
|
|
@@ -11675,11 +11759,14 @@ function createSystemPromptHashHandler(deps) {
|
|
|
11675
11759
|
const stableCandidateHash = systemPromptFingerprint(stableCandidate, promptSurface.preset);
|
|
11676
11760
|
const contentOrPresetChanged = hasPersistedHash && stableCandidateHash !== previousHash;
|
|
11677
11761
|
const rewritePermission = systemDateRefreshPermission(deps.historyRefreshSessions, dateRequest);
|
|
11762
|
+
const signedThinkingKept = systemDateSignedThinkingKept(deps.historyRefreshSessions, dateRequest);
|
|
11763
|
+
const idleDateMayAdvance = idleCacheExpired && signedThinkingKept !== true;
|
|
11764
|
+
const prefixBoundModel = isPrefixBoundThinkingModel(liveModel?.providerID, liveModel?.modelID);
|
|
11678
11765
|
let deferredDateRefresh = false;
|
|
11679
|
-
if (currentDate && stickyDate && currentDate !== stickyDate &&
|
|
11766
|
+
if (currentDate && stickyDate && currentDate !== stickyDate && (idleCacheExpired ? prefixBoundModel : isCacheBusting) && !contentOrPresetChanged && !requestMessagesFinal) {
|
|
11680
11767
|
const liveElements = [...output.system];
|
|
11681
|
-
deferredDateRefresh = waitForSystemDateRefresh(deps.historyRefreshSessions, dateRequest, (permitted) => {
|
|
11682
|
-
if (!permitted) {
|
|
11768
|
+
deferredDateRefresh = waitForSystemDateRefresh(deps.historyRefreshSessions, dateRequest, (permitted, keptSignedThinking) => {
|
|
11769
|
+
if (!permitted && !(idleCacheExpired && keptSignedThinking !== true)) {
|
|
11683
11770
|
deps.systemPromptRefreshSessions.add(sessionId);
|
|
11684
11771
|
return;
|
|
11685
11772
|
}
|
|
@@ -11703,7 +11790,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
11703
11790
|
}
|
|
11704
11791
|
});
|
|
11705
11792
|
}
|
|
11706
|
-
const dateMayAdvance =
|
|
11793
|
+
const dateMayAdvance = idleDateMayAdvance && !deferredDateRefresh || contentOrPresetChanged || isCacheBusting && !deferredDateRefresh && (dateRequest ? rewritePermission === true : rewritePermission !== false);
|
|
11707
11794
|
if (currentDate && !stickyDate) {
|
|
11708
11795
|
stickyDateBySession.set(sessionId, currentDate);
|
|
11709
11796
|
} else if (currentDate && stickyDate && currentDate !== stickyDate) {
|
|
@@ -11981,7 +12068,9 @@ var PASS_DEGRADATION_EFFECTS = {
|
|
|
11981
12068
|
"trailing-blank-decision-exception": "changes-request",
|
|
11982
12069
|
"proactive-thinking-strip-persistence-failure": "changes-request",
|
|
11983
12070
|
"reasoning-removal-read-failure": "changes-request",
|
|
11984
|
-
"reasoning-removal-persistence-failure": "changes-request"
|
|
12071
|
+
"reasoning-removal-persistence-failure": "changes-request",
|
|
12072
|
+
"host-instruction-retention-read-failure": "changes-request",
|
|
12073
|
+
"host-instruction-retention-persistence-failure": "changes-request"
|
|
11985
12074
|
};
|
|
11986
12075
|
function degradationChangesRequest(site) {
|
|
11987
12076
|
return PASS_DEGRADATION_EFFECTS[site] === "changes-request";
|
|
@@ -14711,6 +14800,24 @@ function contextUsagePassSnapshot(sessionMeta) {
|
|
|
14711
14800
|
} : null
|
|
14712
14801
|
};
|
|
14713
14802
|
}
|
|
14803
|
+
function savedProviderReadingForPass(input) {
|
|
14804
|
+
const persisted = input.persisted;
|
|
14805
|
+
if (!persisted)
|
|
14806
|
+
return null;
|
|
14807
|
+
const { percentage, inputTokens } = persisted.usage;
|
|
14808
|
+
if (!Number.isFinite(percentage) || percentage <= 0 || !Number.isFinite(inputTokens) || inputTokens <= 0) {
|
|
14809
|
+
return null;
|
|
14810
|
+
}
|
|
14811
|
+
if (!(input.lastResponseTime > 0) || input.cacheExpired)
|
|
14812
|
+
return null;
|
|
14813
|
+
if (persisted.lastObservedModelKey === null || input.currentModelKey === undefined || input.currentModelKey.length === 0 || piModelRefToCanonical(persisted.lastObservedModelKey) !== piModelRefToCanonical(input.currentModelKey)) {
|
|
14814
|
+
return null;
|
|
14815
|
+
}
|
|
14816
|
+
if (typeof input.contextLimit !== "number" || !(input.contextLimit > 0) || persisted.lastUsageContextLimit !== input.contextLimit) {
|
|
14817
|
+
return null;
|
|
14818
|
+
}
|
|
14819
|
+
return { percentage, inputTokens };
|
|
14820
|
+
}
|
|
14714
14821
|
function resolveUnknownUsageFromWireEstimate(input) {
|
|
14715
14822
|
if (input.usage.inputTokens > 0 || !input.pricedPass)
|
|
14716
14823
|
return input.usage;
|
|
@@ -17918,6 +18025,101 @@ function createRustModeTransform(deps, options) {
|
|
|
17918
18025
|
return adapter;
|
|
17919
18026
|
}
|
|
17920
18027
|
|
|
18028
|
+
// src/hooks/magic-context/signed-thinking-hold.ts
|
|
18029
|
+
var HEAVY_REASONING_TOKENS = 1500;
|
|
18030
|
+
var HEAVY_REASONING_WINDOW_STEPS = 15;
|
|
18031
|
+
var HOLD_CAP_POINTS = 10;
|
|
18032
|
+
var REASONING_TYPES = new Set(["reasoning", "thinking"]);
|
|
18033
|
+
function role2(message) {
|
|
18034
|
+
if (!isRecord(message))
|
|
18035
|
+
return;
|
|
18036
|
+
return isRecord(message.info) ? message.info.role : message.role;
|
|
18037
|
+
}
|
|
18038
|
+
function parts(message) {
|
|
18039
|
+
if (!isRecord(message))
|
|
18040
|
+
return [];
|
|
18041
|
+
if (Array.isArray(message.parts))
|
|
18042
|
+
return message.parts;
|
|
18043
|
+
return Array.isArray(message.content) ? message.content : [];
|
|
18044
|
+
}
|
|
18045
|
+
function recordedReasoningTokens(message) {
|
|
18046
|
+
if (!isRecord(message))
|
|
18047
|
+
return;
|
|
18048
|
+
const info = isRecord(message.info) ? message.info : undefined;
|
|
18049
|
+
const candidates = [];
|
|
18050
|
+
if (info && isRecord(info.tokens))
|
|
18051
|
+
candidates.push(info.tokens.reasoning);
|
|
18052
|
+
if (isRecord(message.usage)) {
|
|
18053
|
+
candidates.push(message.usage.reasoning, message.usage.reasoningTokens);
|
|
18054
|
+
}
|
|
18055
|
+
for (const value of candidates) {
|
|
18056
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0)
|
|
18057
|
+
return value;
|
|
18058
|
+
}
|
|
18059
|
+
return;
|
|
18060
|
+
}
|
|
18061
|
+
function stepReasoningTokens(message, estimateTextTokens) {
|
|
18062
|
+
let text = "";
|
|
18063
|
+
let opaque = false;
|
|
18064
|
+
for (const part of parts(message)) {
|
|
18065
|
+
if (!isRecord(part))
|
|
18066
|
+
continue;
|
|
18067
|
+
const type = String(part.type ?? part.kind);
|
|
18068
|
+
if (type === "redacted_thinking" || part.redacted === true) {
|
|
18069
|
+
opaque = true;
|
|
18070
|
+
continue;
|
|
18071
|
+
}
|
|
18072
|
+
if (!REASONING_TYPES.has(type))
|
|
18073
|
+
continue;
|
|
18074
|
+
const body = typeof part.thinking === "string" ? part.thinking : typeof part.text === "string" ? part.text : "";
|
|
18075
|
+
if (body.length > 0)
|
|
18076
|
+
text += body;
|
|
18077
|
+
else
|
|
18078
|
+
opaque = true;
|
|
18079
|
+
}
|
|
18080
|
+
if (!text && !opaque)
|
|
18081
|
+
return 0;
|
|
18082
|
+
return reasoningStepCost(recordedReasoningTokens(message), text ? estimateTextTokens(text) : 0, opaque);
|
|
18083
|
+
}
|
|
18084
|
+
function decideSignedThinkingHold(args) {
|
|
18085
|
+
const capPercentage = args.executeThresholdPercentage + HOLD_CAP_POINTS;
|
|
18086
|
+
let heavyStepsBack = null;
|
|
18087
|
+
let heavyStepTokens = 0;
|
|
18088
|
+
const start = latestAssistantTurnStart(args.messages);
|
|
18089
|
+
let stepsBack = 0;
|
|
18090
|
+
for (let index = args.messages.length - 1;index >= start; index--) {
|
|
18091
|
+
const message = args.messages[index];
|
|
18092
|
+
if (role2(message) !== "assistant" || parts(message).length === 0)
|
|
18093
|
+
continue;
|
|
18094
|
+
stepsBack++;
|
|
18095
|
+
if (stepsBack > HEAVY_REASONING_WINDOW_STEPS)
|
|
18096
|
+
break;
|
|
18097
|
+
const tokens = stepReasoningTokens(message, args.estimateTextTokens);
|
|
18098
|
+
if (tokens > HEAVY_REASONING_TOKENS) {
|
|
18099
|
+
heavyStepsBack = stepsBack;
|
|
18100
|
+
heavyStepTokens = tokens;
|
|
18101
|
+
break;
|
|
18102
|
+
}
|
|
18103
|
+
}
|
|
18104
|
+
if (heavyStepsBack === null)
|
|
18105
|
+
return {
|
|
18106
|
+
held: false,
|
|
18107
|
+
reason: "no_recent_heavy_reasoning",
|
|
18108
|
+
heavyStepsBack,
|
|
18109
|
+
heavyStepTokens,
|
|
18110
|
+
capPercentage
|
|
18111
|
+
};
|
|
18112
|
+
if (!(args.usagePercentage < capPercentage))
|
|
18113
|
+
return { held: false, reason: "above_cap", heavyStepsBack, heavyStepTokens, capPercentage };
|
|
18114
|
+
return {
|
|
18115
|
+
held: true,
|
|
18116
|
+
reason: "heavy_reasoning",
|
|
18117
|
+
heavyStepsBack,
|
|
18118
|
+
heavyStepTokens,
|
|
18119
|
+
capPercentage
|
|
18120
|
+
};
|
|
18121
|
+
}
|
|
18122
|
+
|
|
17921
18123
|
// src/hooks/magic-context/temporal-served-projection.ts
|
|
17922
18124
|
function readLkgTemporalDecisions(db, sessionId, runtime) {
|
|
17923
18125
|
const slot = getInMemorySlot(sessionId) ?? loadPersistedLkgSlot(db, sessionId);
|
|
@@ -18141,7 +18343,7 @@ async function runCompartmentPhaseImpl(args) {
|
|
|
18141
18343
|
justAwaitedPublication = activeRun.published;
|
|
18142
18344
|
published = published || activeRun.published;
|
|
18143
18345
|
const historyReprepareShouldBust = activeRun.published && args.deferredHistoryRefreshSessions.has(args.sessionId);
|
|
18144
|
-
pendingCompartmentInjection = prepareCompartmentInjection(args.db, args.resolvedSessionId, args.messages, historyReprepareShouldBust, args.projectPath, args.injectionBudgetTokens, args.experimentalTemporalAwareness);
|
|
18346
|
+
pendingCompartmentInjection = prepareCompartmentInjection(args.db, args.resolvedSessionId, args.messages, historyReprepareShouldBust, args.coveredInstructions, args.projectPath, args.injectionBudgetTokens, args.experimentalTemporalAwareness);
|
|
18145
18347
|
if (historyReprepareShouldBust) {
|
|
18146
18348
|
rebuiltHistoryThisPass = true;
|
|
18147
18349
|
}
|
|
@@ -18432,7 +18634,8 @@ function createTransform(deps) {
|
|
|
18432
18634
|
const startTime = performance.now();
|
|
18433
18635
|
const historianRun = deps.resolveHistorianRun?.();
|
|
18434
18636
|
const messages = output.messages;
|
|
18435
|
-
const originalForThinkingFit = messages.some((message) => message.parts.some((part) => isRecord(part) && ["reasoning", "thinking", "redacted_thinking"].includes(String(part.type)))) ?
|
|
18637
|
+
const originalForThinkingFit = messages.some((message) => message.parts.some((part) => isRecord(part) && ["reasoning", "thinking", "redacted_thinking"].includes(String(part.type)))) ? cloneKeepingCoveredInstructionMarks(messages) : null;
|
|
18638
|
+
const coveredHostInstructions = takeCoveredInstructionRows(messages);
|
|
18436
18639
|
const passOutcome = createPassOutcome();
|
|
18437
18640
|
const tSessionId = performance.now();
|
|
18438
18641
|
const sessionId = findSessionId(messages);
|
|
@@ -18448,6 +18651,11 @@ function createTransform(deps) {
|
|
|
18448
18651
|
const tLkgEntry = performance.now();
|
|
18449
18652
|
const lkgInput = deps.transformMode === "rust" ? [] : projectEntry(sessionId, messages);
|
|
18450
18653
|
const recovery = deps.compactionOff || deps.transformMode === "rust" ? {} : readLkgRecoveryPrefix(sessionId, lkgInput, messages, deps.db);
|
|
18654
|
+
const persistedUntaggedInputIds = deps.compactionOff || deps.transformMode === "rust" ? [] : readPersistedLkgUntaggedInputIds(deps.db, sessionId);
|
|
18655
|
+
const untaggedReplayIds = new Set([
|
|
18656
|
+
...recovery.prefix?.untaggedInputIds ?? [],
|
|
18657
|
+
...persistedUntaggedInputIds
|
|
18658
|
+
]);
|
|
18451
18659
|
logTransformTiming(sessionId, "lkg.entryProjection", tLkgEntry, deps.transformMode === "rust" || !entryReuse ? undefined : `reused=${entryReuse.reused} retained=${entryReuse.retained} retainedBytes=${entryReuse.retainedBytes}`);
|
|
18452
18660
|
const resolvedSessionId = sessionId;
|
|
18453
18661
|
const runNotificationParams = (sid) => {
|
|
@@ -18630,8 +18838,8 @@ function createTransform(deps) {
|
|
|
18630
18838
|
return true;
|
|
18631
18839
|
}
|
|
18632
18840
|
})();
|
|
18633
|
-
let activeThinkingPrefixHold =
|
|
18634
|
-
let freezeM0M1 = unresolvedDirectoryHold
|
|
18841
|
+
let activeThinkingPrefixHold = false;
|
|
18842
|
+
let freezeM0M1 = unresolvedDirectoryHold;
|
|
18635
18843
|
const compartmentDirectory = sessionDirectory;
|
|
18636
18844
|
const historianRunnable = deps.historianRunnable !== false;
|
|
18637
18845
|
const canRunCompartments = fullFeatureMode && !compactionOff && historianRunnable && (deps.client !== undefined || deps.hiddenCompletionExecutor !== undefined) && compartmentDirectory.length > 0;
|
|
@@ -18759,13 +18967,7 @@ function createTransform(deps) {
|
|
|
18759
18967
|
}
|
|
18760
18968
|
const resolvedProviderID = modelForBudget?.providerID;
|
|
18761
18969
|
activeThinkingTurn ||= hasActiveAnthropicThinkingTurn(messages, resolvedProviderID, modelForBudget?.modelID);
|
|
18762
|
-
|
|
18763
|
-
freezeM0M1 ||= activeThinkingPrefixHold;
|
|
18764
|
-
if (freezeM0M1 && prefixHoldLogTurnIds.get(sessionId) !== currentTurnId) {
|
|
18765
|
-
prefixHoldLogTurnIds.set(sessionId, currentTurnId);
|
|
18766
|
-
const reason = activeThinkingPrefixHold ? "active thinking turn (prefix-bound model)" : "session directory unresolved";
|
|
18767
|
-
sessionLog2(sessionId, `m[0]/m[1] frozen: ${reason}; replaying the frozen prefix and deferring any rebuild`);
|
|
18768
|
-
}
|
|
18970
|
+
const signedThinkingPrefixBound = activeThinkingTurn && (isPrefixBoundThinkingModel(activeThinkingModel?.providerID, activeThinkingModel?.modelID) || isPrefixBoundThinkingModel(resolvedProviderID, modelForBudget?.modelID));
|
|
18769
18971
|
const canUseEmptySentinels = modelAcceptsEmptyContent(resolvedProviderID);
|
|
18770
18972
|
const protectedThinkingMessages = activeThinkingTurn || isAnthropicFamilyRoute(resolvedProviderID, modelForBudget?.modelID) ? latestAssistantTurnMessages(messages) : new Set;
|
|
18771
18973
|
const resolvedContextLimit = modelForBudget ? resolveTrustedContextLimit(modelForBudget.providerID, modelForBudget.modelID, {
|
|
@@ -18819,6 +19021,29 @@ function createTransform(deps) {
|
|
|
18819
19021
|
const effectiveExecuteThresholdPercentage = executeThresholdDetail.percentage;
|
|
18820
19022
|
sessionLog2(sessionId, `transform threshold: model=${currentModelKeyForBoundary ?? "unknown"} matchedModel=${executeThresholdDetail.matchedKey ?? "scalar"} mode=${executeThresholdDetail.mode} threshold=${effectiveExecuteThresholdPercentage}% proactiveFloor=${getProactiveCompartmentTriggerPercentage(effectiveExecuteThresholdPercentage)}%`);
|
|
18821
19023
|
const { forceMaterializationPercentage } = escalationBands(effectiveExecuteThresholdPercentage);
|
|
19024
|
+
let holdProseRatio;
|
|
19025
|
+
const signedThinkingHold = signedThinkingPrefixBound ? decideSignedThinkingHold({
|
|
19026
|
+
messages,
|
|
19027
|
+
usagePercentage: contextUsageEarly.percentage,
|
|
19028
|
+
executeThresholdPercentage: effectiveExecuteThresholdPercentage,
|
|
19029
|
+
estimateTextTokens: (text) => {
|
|
19030
|
+
holdProseRatio ??= sessionDecisionCalibration(db, sessionId).proseRatio;
|
|
19031
|
+
return estimateTokens(text) * holdProseRatio;
|
|
19032
|
+
}
|
|
19033
|
+
}) : null;
|
|
19034
|
+
activeThinkingPrefixHold = signedThinkingPrefixBound && (compactionOff || signedThinkingHold?.held === true);
|
|
19035
|
+
freezeM0M1 ||= activeThinkingPrefixHold;
|
|
19036
|
+
const prefixHoldLogKey = signedThinkingHold ? `${currentTurnId}:${signedThinkingHold.reason}:${signedThinkingHold.heavyStepsBack ?? "none"}` : freezeM0M1 ? `${currentTurnId}:directory` : null;
|
|
19037
|
+
if (prefixHoldLogKey !== null && prefixHoldLogTurnIds.get(sessionId) !== prefixHoldLogKey) {
|
|
19038
|
+
prefixHoldLogTurnIds.set(sessionId, prefixHoldLogKey);
|
|
19039
|
+
if (signedThinkingHold) {
|
|
19040
|
+
sessionLog2(sessionId, `signed thinking hold: held=${signedThinkingHold.held} reason=${signedThinkingHold.reason} heavyStepsBack=${signedThinkingHold.heavyStepsBack ?? "none"} heavyStepTokens=${signedThinkingHold.heavyStepTokens} usage=${contextUsageEarly.percentage.toFixed(1)}% cap=${signedThinkingHold.capPercentage}%`);
|
|
19041
|
+
}
|
|
19042
|
+
if (freezeM0M1) {
|
|
19043
|
+
const reason = activeThinkingPrefixHold ? compactionOff ? "active thinking turn in compaction-off mode (prefix-bound model)" : "recent heavy reasoning in the active thinking turn (prefix-bound model)" : "session directory unresolved";
|
|
19044
|
+
sessionLog2(sessionId, `m[0]/m[1] frozen: ${reason}; replaying the frozen prefix and deferring any rebuild`);
|
|
19045
|
+
}
|
|
19046
|
+
}
|
|
18822
19047
|
const persistedUsageFreshForBoundary = persistedUsageBeforeResets && Date.now() - persistedUsageBeforeResets.updatedAt <= 10 * 60 * 1000 && (persistedUsageBeforeResets.lastObservedModelKey === null || currentModelKeyForBoundary === undefined || piModelRefToCanonical(persistedUsageBeforeResets.lastObservedModelKey) === piModelRefToCanonical(currentModelKeyForBoundary)) && (resolvedContextLimit === undefined || persistedUsageBeforeResets.lastUsageContextLimit === 0 || persistedUsageBeforeResets.lastUsageContextLimit === resolvedContextLimit) ? persistedUsageBeforeResets.usage : null;
|
|
18823
19048
|
const boundaryUsageForProtectedTail = persistedUsageFreshForBoundary ?? contextUsageEarly;
|
|
18824
19049
|
const boundaryUsageSource = persistedUsageFreshForBoundary ? "persisted" : "live";
|
|
@@ -19005,8 +19230,14 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19005
19230
|
}, {
|
|
19006
19231
|
hardFold: false,
|
|
19007
19232
|
force: contextUsageEarly.percentage >= forceMaterializationPercentage && (contextUsageEarly.percentage >= 95 || getEmergencyInputSample(db, sessionId) === 0),
|
|
19008
|
-
explicitFlush: deps.pendingMaterializationSessions
|
|
19009
|
-
publishedHistory: isCacheBusting
|
|
19233
|
+
explicitFlush: hasPendingMaterializationOrigin(deps.pendingMaterializationSessions, sessionId, "user_flush"),
|
|
19234
|
+
publishedHistory: isCacheBusting,
|
|
19235
|
+
permission: {
|
|
19236
|
+
signedThinkingHold: activeThinkingPrefixHold,
|
|
19237
|
+
firstRender: false,
|
|
19238
|
+
idleExpiry: false,
|
|
19239
|
+
emergency: contextUsageEarly.percentage >= forceMaterializationPercentage
|
|
19240
|
+
}
|
|
19010
19241
|
}, pendingDropEligibility.read(sessionId, dropProjectionKey()));
|
|
19011
19242
|
if (triggerResult.shouldFire) {
|
|
19012
19243
|
sessionLog2(sessionId, `compartment trigger: firing (reason=${triggerResult.reason})`);
|
|
@@ -19026,7 +19257,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19026
19257
|
const messagesBeforeInitialPrepare = isCacheBusting && deferredHistoryWasPendingAtPassStart ? [...messages] : null;
|
|
19027
19258
|
if (fullFeatureMode && !compactionOff) {
|
|
19028
19259
|
const tInj = performance.now();
|
|
19029
|
-
pendingCompartmentInjection = prepareCompartmentInjection(db, sessionId, messages, isCacheBusting, projectIdentity, deps.memoryConfig?.injectionBudgetTokens, deps.experimentalTemporalAwareness);
|
|
19260
|
+
pendingCompartmentInjection = prepareCompartmentInjection(db, sessionId, messages, isCacheBusting, coveredHostInstructions, projectIdentity, deps.memoryConfig?.injectionBudgetTokens, deps.experimentalTemporalAwareness);
|
|
19030
19261
|
if (messagesBeforeInitialPrepare) {
|
|
19031
19262
|
const skippedVisibleMessages = pendingCompartmentInjection?.skippedVisibleMessages ?? 0;
|
|
19032
19263
|
trimmedMessagesAtCompactionBoundary = messagesBeforeInitialPrepare.slice(0, skippedVisibleMessages);
|
|
@@ -19058,10 +19289,11 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19058
19289
|
let taggingSucceeded = false;
|
|
19059
19290
|
let recoveryBatch = null;
|
|
19060
19291
|
let recoveryNormalized = false;
|
|
19061
|
-
const
|
|
19292
|
+
const untaggedReplayTailServed = !!recovery.prefix || untaggedReplayIds.size > 0 && messages.some((message) => untaggedReplayIds.has(message.info.id ?? ""));
|
|
19293
|
+
const normalizeRecoveryTail = untaggedReplayTailServed ? () => {
|
|
19062
19294
|
if (recoveryNormalized)
|
|
19063
19295
|
return;
|
|
19064
|
-
const tail = messages.filter((message) =>
|
|
19296
|
+
const tail = messages.filter((message) => untaggedReplayIds.has(message.info.id ?? ""));
|
|
19065
19297
|
const tagged = tagMessages(sessionId, tail, deps.tagger, db, {
|
|
19066
19298
|
skipPrefixInjection: !ctxReduceCallable,
|
|
19067
19299
|
servedMessages: messages,
|
|
@@ -19087,7 +19319,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19087
19319
|
const messagesForTagging = messagesBeforeInitialPrepare && hiddenMessagesAtCompactionSeam.length > 0 ? messagesBeforeInitialPrepare : messages;
|
|
19088
19320
|
const canAdoptScopedToolSweep = isCacheBusting || canConsumeDeferredEarly;
|
|
19089
19321
|
const scopedToolSweep = useScopedToolSweep(db, sessionId, canAdoptScopedToolSweep) ? true : createPreAdoptionToolSweepResolver(db, sessionId);
|
|
19090
|
-
const result = tagMessages(sessionId,
|
|
19322
|
+
const result = tagMessages(sessionId, untaggedReplayIds.size > 0 ? messagesForTagging.filter((message) => !untaggedReplayIds.has(message.info.id ?? "")) : messagesForTagging, deps.tagger, db, {
|
|
19091
19323
|
skipPrefixInjection,
|
|
19092
19324
|
scopedToolSweep,
|
|
19093
19325
|
servedMessages: messages,
|
|
@@ -19200,6 +19432,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19200
19432
|
fallbackModels: historianRun?.fallbackModels ?? deps.fallbackModels,
|
|
19201
19433
|
compartmentDirectory,
|
|
19202
19434
|
messages,
|
|
19435
|
+
coveredInstructions: coveredHostInstructions,
|
|
19203
19436
|
pendingCompartmentInjection,
|
|
19204
19437
|
fallbackModelId,
|
|
19205
19438
|
projectPath: projectIdentity,
|
|
@@ -19271,30 +19504,53 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19271
19504
|
bustReason: calibrationBustReason,
|
|
19272
19505
|
onAdopt: (message) => sessionLog2(sessionId, message)
|
|
19273
19506
|
});
|
|
19507
|
+
let contextUsageFromEstimate = false;
|
|
19274
19508
|
if (contextUsage.inputTokens <= 0 && protectionCacheBustingPass) {
|
|
19509
|
+
const overflowRecoveryPass = usagePercentageSynthetic || emergencyRecoveryArmed;
|
|
19510
|
+
const savedProviderReading = overflowRecoveryPass ? null : savedProviderReadingForPass({
|
|
19511
|
+
persisted: persistedUsageBeforeResets,
|
|
19512
|
+
currentModelKey: currentModelKeyForBoundary ?? (hardModelKey || undefined),
|
|
19513
|
+
contextLimit: resolvedContextLimit,
|
|
19514
|
+
lastResponseTime: sessionMeta.lastResponseTime,
|
|
19515
|
+
cacheExpired: hardCacheExpired
|
|
19516
|
+
});
|
|
19517
|
+
let pressureEstimate;
|
|
19275
19518
|
try {
|
|
19276
|
-
|
|
19519
|
+
pressureEstimate = estimateFinalWireInputTokens({
|
|
19277
19520
|
messages,
|
|
19278
19521
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
19279
19522
|
providerID: modelForBudget?.providerID,
|
|
19280
19523
|
modelID: modelForBudget?.modelID,
|
|
19281
19524
|
agentName: notificationParams.agent
|
|
19282
19525
|
});
|
|
19526
|
+
} catch (error) {
|
|
19527
|
+
sessionLog2(sessionId, `transform: wire-estimate pressure fallback unavailable: ${getErrorMessage(error)}`);
|
|
19528
|
+
}
|
|
19529
|
+
const usableHard = windowGeometry?.usableHard;
|
|
19530
|
+
const countPercentage = pressureEstimate?.pressureTokens !== undefined && Number.isFinite(pressureEstimate.pressureTokens) && typeof usableHard === "number" && usableHard > 0 ? pressureEstimate.pressureTokens / usableHard * 100 : 0;
|
|
19531
|
+
const grewPastSavedReading = savedProviderReading !== null && countPercentage >= 95 && countPercentage > savedProviderReading.percentage;
|
|
19532
|
+
if (savedProviderReading && !grewPastSavedReading) {
|
|
19533
|
+
contextUsage = {
|
|
19534
|
+
inputTokens: savedProviderReading.inputTokens,
|
|
19535
|
+
percentage: Math.max(contextUsage.percentage, savedProviderReading.percentage)
|
|
19536
|
+
};
|
|
19537
|
+
sessionLog2(sessionId, `transform: unknown provider usage; using saved provider reading for priced pass inputTokens=${contextUsage.inputTokens} percentage=${contextUsage.percentage.toFixed(1)} countPercentage=${countPercentage.toFixed(1)}`);
|
|
19538
|
+
} else if (pressureEstimate) {
|
|
19539
|
+
const percentageBeforeEstimate = contextUsage.percentage;
|
|
19283
19540
|
contextUsage = resolveUnknownUsageFromWireEstimate({
|
|
19284
19541
|
usage: contextUsage,
|
|
19285
19542
|
pricedPass: true,
|
|
19286
|
-
wireEstimateTokens: pressureEstimate.tokens,
|
|
19543
|
+
wireEstimateTokens: overflowRecoveryPass ? pressureEstimate.tokens : pressureEstimate.pressureTokens,
|
|
19287
19544
|
wireEstimateTrusted: pressureEstimate.trusted,
|
|
19288
19545
|
providerProvenInputTokens: providerProvenInputForRecovery,
|
|
19289
19546
|
providerProvenLimitTokens: providerProvenLimitForRecovery,
|
|
19290
|
-
usableHardLimit:
|
|
19547
|
+
usableHardLimit: usableHard
|
|
19291
19548
|
});
|
|
19292
19549
|
if (contextUsage.inputTokens > 0) {
|
|
19293
19550
|
const usedProviderInput = !pressureEstimate.trusted && providerProvenLimitForRecovery !== undefined && providerProvenInputForRecovery !== undefined && contextUsage.inputTokens >= providerProvenInputForRecovery;
|
|
19294
|
-
|
|
19551
|
+
contextUsageFromEstimate = !overflowRecoveryPass && !usedProviderInput && !usagePercentageSynthetic && contextUsage.percentage > percentageBeforeEstimate;
|
|
19552
|
+
sessionLog2(sessionId, `transform: unknown provider usage; using ${usedProviderInput ? "provider-proven input" : "wire estimate"} for priced pass inputTokens=${contextUsage.inputTokens} percentage=${contextUsage.percentage.toFixed(1)} trusted=${pressureEstimate.trusted} wireTokens=${pressureEstimate.tokens} pressureTokens=${pressureEstimate.pressureTokens}${grewPastSavedReading ? ` grewPastSavedReading=${savedProviderReading?.percentage.toFixed(1)}` : ""}`);
|
|
19295
19553
|
}
|
|
19296
|
-
} catch (error) {
|
|
19297
|
-
sessionLog2(sessionId, `transform: wire-estimate pressure fallback unavailable: ${getErrorMessage(error)}`);
|
|
19298
19554
|
}
|
|
19299
19555
|
}
|
|
19300
19556
|
const protectionUsableSoft = windowGeometry?.usableSoft ?? boundaryContextLimit;
|
|
@@ -19335,6 +19591,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19335
19591
|
activeAgent,
|
|
19336
19592
|
batch,
|
|
19337
19593
|
contextUsage,
|
|
19594
|
+
contextUsageFromEstimate,
|
|
19338
19595
|
usableWindow: resolvedContextLimit ?? 0,
|
|
19339
19596
|
schedulerDecision,
|
|
19340
19597
|
schedulerDeferReason,
|
|
@@ -19380,6 +19637,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19380
19637
|
emergencyCeilingTokens,
|
|
19381
19638
|
pendingCompartmentInjection,
|
|
19382
19639
|
prefixTrimSourceOrder,
|
|
19640
|
+
coveredHostInstructions,
|
|
19383
19641
|
hiddenMessagesAtCompactionSeam,
|
|
19384
19642
|
trimmedMessagesAtCompactionBoundary,
|
|
19385
19643
|
didMutateFromFlushedStatuses,
|
|
@@ -19419,7 +19677,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19419
19677
|
postTransformResult.bustedThisPass = true;
|
|
19420
19678
|
passOutcome.markFinalized();
|
|
19421
19679
|
const finalWireTail = describeFinalWireTail(messages);
|
|
19422
|
-
const signedFitPreviouslyRefused = !compactionOff && getMergedReasoningStrippedIds(db, sessionId).has(SIGNED_FIT_REFUSED_MARKER);
|
|
19680
|
+
const signedFitPreviouslyRefused = !compactionOff && activeThinkingPrefixHold && getMergedReasoningStrippedIds(db, sessionId).has(SIGNED_FIT_REFUSED_MARKER);
|
|
19423
19681
|
let finalWireEstimate;
|
|
19424
19682
|
if (postTransformResult.bustedThisPass) {
|
|
19425
19683
|
try {
|
|
@@ -19580,7 +19838,12 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19580
19838
|
if (!finalWireEstimate) {
|
|
19581
19839
|
sessionLog2(sessionId, `transform: final-wire telemetry estimate=unavailable trusted=false conversation=unknown tools=unknown system=unknown toolDefinitions=unknown tail=${finalWireTail}`);
|
|
19582
19840
|
}
|
|
19583
|
-
|
|
19841
|
+
if (!compactionOff) {
|
|
19842
|
+
const stillUntagged = untaggedReplayTailServed && !recoveryNormalized ? [...untaggedReplayIds] : [];
|
|
19843
|
+
if (JSON.stringify([...new Set(stillUntagged)].sort()) !== JSON.stringify([...new Set(persistedUntaggedInputIds)].sort()) && !persistLkgUntaggedInputIds(db, sessionId, stillUntagged))
|
|
19844
|
+
throw new Error("Cannot persist the last-good untagged-message record");
|
|
19845
|
+
}
|
|
19846
|
+
finishSystemDateRefresh(deps.historyRefreshSessions, dateRequest, postTransformResult.bustedThisPass && !activeThinkingPrefixHold && postTransformResult.openTurnSignedThinkingKept !== true || postTransformResult.thinkingReleasedForFit === true, postTransformResult.openTurnSignedThinkingKept === true);
|
|
19584
19847
|
if (activeThinkingPrefixHold && !postTransformResult.thinkingReleasedForFit && sessionMeta.cachedM0Bytes != null && sessionMeta.cachedM1Bytes != null) {
|
|
19585
19848
|
recordHeldHeadForRequest(sessionId, currentLkgRequestIdentity(sessionId), (ownsHistory) => deferDeliveredSystemRefresh(deps, sessionId, ownsHistory));
|
|
19586
19849
|
}
|
|
@@ -19681,7 +19944,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19681
19944
|
});
|
|
19682
19945
|
if (uncachedMessageIds.length > 0) {
|
|
19683
19946
|
try {
|
|
19684
|
-
storedByMessage = getActiveTagTokenTotalsByMessage2(db, sessionId, uncachedMessageIds);
|
|
19947
|
+
storedByMessage = omitIncompleteFileTokenTotals(db, sessionId, messages.flatMap((message) => message.info.id ? [{ id: message.info.id, parts: message.parts }] : []), getActiveTagTokenTotalsByMessage2(db, sessionId, uncachedMessageIds));
|
|
19685
19948
|
} catch {
|
|
19686
19949
|
storedByMessage = new Map;
|
|
19687
19950
|
}
|
|
@@ -20128,7 +20391,8 @@ function tryMessagesTransformLkgReplay(args) {
|
|
|
20128
20391
|
sessionId,
|
|
20129
20392
|
entry,
|
|
20130
20393
|
messages: replay.messages,
|
|
20131
|
-
...keys
|
|
20394
|
+
...keys,
|
|
20395
|
+
db
|
|
20132
20396
|
}))
|
|
20133
20397
|
return false;
|
|
20134
20398
|
retirePendingSystemPromptDelivery(sessionId);
|
|
@@ -22999,7 +23263,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22999
23263
|
const db = readDatabase();
|
|
23000
23264
|
if (!db)
|
|
23001
23265
|
return { ok: false, error: "db unavailable" };
|
|
23002
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
23266
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-f6m9jr7p.js"));
|
|
23003
23267
|
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-3pxn658x.js"));
|
|
23004
23268
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
23005
23269
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
@@ -23084,7 +23348,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
23084
23348
|
const db = readDatabase();
|
|
23085
23349
|
if (!db)
|
|
23086
23350
|
return { ok: false, error: "db unavailable" };
|
|
23087
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
23351
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-embdz8gj.js"));
|
|
23088
23352
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
23089
23353
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
23090
23354
|
const ctx = {
|
|
@@ -24706,6 +24970,8 @@ function adaptPayload(draft, admittedIDs = new Set, messageTimes = new Map) {
|
|
|
24706
24970
|
parts
|
|
24707
24971
|
};
|
|
24708
24972
|
originals.set(mapped, message);
|
|
24973
|
+
if (isCoveredInstructionRow(message))
|
|
24974
|
+
markCoveredInstructionRow(mapped.info);
|
|
24709
24975
|
if (typeof message.id !== "string")
|
|
24710
24976
|
bridgesByCarrier.set(mapped, byCallID);
|
|
24711
24977
|
messages.push(mapped);
|
|
@@ -27770,6 +28036,7 @@ async function applyCuesThroughModule(args, chunk, manifestText, signal) {
|
|
|
27770
28036
|
}
|
|
27771
28037
|
|
|
27772
28038
|
// src/features/magic-context/dreamer/hidden-single-shot.ts
|
|
28039
|
+
var DREAMER_FIRST_OUTPUT_TIMEOUT_MS = 90000;
|
|
27773
28040
|
async function runHiddenSingleShotPrompt(args) {
|
|
27774
28041
|
const system = withContentLanguageDirective(args.system, args.language);
|
|
27775
28042
|
const opening = args.executor.open({
|
|
@@ -27811,6 +28078,7 @@ async function runHiddenSingleShotPrompt(args) {
|
|
|
27811
28078
|
}, {
|
|
27812
28079
|
transport: Object.assign((request) => args.executor.attempt(handle, request), { childSessionId: handle.childSessionId }),
|
|
27813
28080
|
timeoutMs: args.timeoutMs,
|
|
28081
|
+
...args.firstOutputTimeoutMs !== undefined ? { firstOutputTimeoutMs: args.firstOutputTimeoutMs } : {},
|
|
27814
28082
|
...args.signal ? { signal: args.signal } : {},
|
|
27815
28083
|
fallbackModels: args.fallbackModels,
|
|
27816
28084
|
callContext: args.callContext,
|
|
@@ -28664,6 +28932,7 @@ async function classifyOneChunk(args, chunk, anchors, sliceMs, signal) {
|
|
|
28664
28932
|
}, {
|
|
28665
28933
|
transport: Object.assign((request) => executor.attempt(opened, request), { childSessionId: opened.childSessionId }),
|
|
28666
28934
|
timeoutMs: sliceMs,
|
|
28935
|
+
firstOutputTimeoutMs: args.firstOutputTimeoutMs ?? DREAMER_FIRST_OUTPUT_TIMEOUT_MS,
|
|
28667
28936
|
signal,
|
|
28668
28937
|
fallbackModels: args.fallbackModels,
|
|
28669
28938
|
callContext: "dreamer:classify-memories",
|
|
@@ -31138,6 +31407,7 @@ async function mapOneBatch(args, batch, sliceMs, signal) {
|
|
|
31138
31407
|
model: args.model,
|
|
31139
31408
|
fallbackModels: args.fallbackModels,
|
|
31140
31409
|
timeoutMs: sliceMs,
|
|
31410
|
+
firstOutputTimeoutMs: args.firstOutputTimeoutMs ?? DREAMER_FIRST_OUTPUT_TIMEOUT_MS,
|
|
31141
31411
|
signal,
|
|
31142
31412
|
onOpened: () => {
|
|
31143
31413
|
stage = "prompt";
|
|
@@ -31192,6 +31462,7 @@ async function mapOneBatch(args, batch, sliceMs, signal) {
|
|
|
31192
31462
|
onBudgetUpdate
|
|
31193
31463
|
}),
|
|
31194
31464
|
timeoutMs: sliceMs,
|
|
31465
|
+
firstOutputTimeoutMs: args.firstOutputTimeoutMs ?? DREAMER_FIRST_OUTPUT_TIMEOUT_MS,
|
|
31195
31466
|
signal,
|
|
31196
31467
|
fallbackModels: args.fallbackModels,
|
|
31197
31468
|
callContext: "dreamer:map-memories",
|
|
@@ -33269,6 +33540,7 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
33269
33540
|
fallbackModels: args.fallbackModels,
|
|
33270
33541
|
language: args.language,
|
|
33271
33542
|
timeoutMs: sliceMs,
|
|
33543
|
+
firstOutputTimeoutMs: args.firstOutputTimeoutMs ?? DREAMER_FIRST_OUTPUT_TIMEOUT_MS,
|
|
33272
33544
|
signal: batchSignal,
|
|
33273
33545
|
onFailureOutput: (completion) => {
|
|
33274
33546
|
failedCompletion = completion;
|
|
@@ -33326,6 +33598,7 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
33326
33598
|
onBudgetUpdate
|
|
33327
33599
|
}),
|
|
33328
33600
|
timeoutMs: sliceMs,
|
|
33601
|
+
firstOutputTimeoutMs: args.firstOutputTimeoutMs ?? DREAMER_FIRST_OUTPUT_TIMEOUT_MS,
|
|
33329
33602
|
signal: batchSignal,
|
|
33330
33603
|
fallbackModels: args.fallbackModels,
|
|
33331
33604
|
callContext: "dreamer:verify",
|
|
@@ -49405,6 +49678,7 @@ function renderItemByTag(db, sessionId, number, textIndexDomain = "part") {
|
|
|
49405
49678
|
}
|
|
49406
49679
|
|
|
49407
49680
|
// src/tools/ctx-expand/tools.ts
|
|
49681
|
+
var CTX_EXPAND_RUST_TAG_REFUSAL = "Tag lookup isn't available on this session: its §N§ tags are numbered by the Rust transform engine and ctx_expand cannot resolve those numbers, so no content was returned. Expand by message instead: ctx_expand(message=<ordinal>) or ctx_expand(start=<ordinal>, end=<ordinal>), using ordinals from a <session-history> heading or a ctx_search hit.";
|
|
49408
49682
|
var ctxExpandArgsShape = {
|
|
49409
49683
|
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."),
|
|
49410
49684
|
start: tool.schema.number().optional().describe("First message ordinal of the range (a <session-history> heading's start, or a ctx_search hit), not a tag number."),
|
|
@@ -49427,9 +49701,12 @@ function createCtxExpandTool(deps) {
|
|
|
49427
49701
|
message: "number"
|
|
49428
49702
|
});
|
|
49429
49703
|
const sessionId = toolContext.sessionID;
|
|
49704
|
+
const mode = resolveCtxExpandMode(args, "positive");
|
|
49705
|
+
if (mode.kind === "tag" && deps.transformMode === "rust") {
|
|
49706
|
+
return CTX_EXPAND_RUST_TAG_REFUSAL;
|
|
49707
|
+
}
|
|
49430
49708
|
if (!await prepareRawSessionOrdinals2(sessionId))
|
|
49431
49709
|
return "Session ordinals are warming in the background. Retry ctx_expand shortly; no approximate ordinal was served.";
|
|
49432
|
-
const mode = resolveCtxExpandMode(args, "positive");
|
|
49433
49710
|
if (mode.kind === "error") {
|
|
49434
49711
|
return mode.message;
|
|
49435
49712
|
}
|
|
@@ -51316,7 +51593,11 @@ async function registerTools(context, db, config, rustToolBackends, isInternalCh
|
|
|
51316
51593
|
getProtectionWindow: (sessionID) => getProtectionWindowForSession(db, sessionID, getObservedEpochFloor(db, sessionID)),
|
|
51317
51594
|
...rustToolBackends ? { rustToolBackends } : {}
|
|
51318
51595
|
}) : {},
|
|
51319
|
-
...createCtxExpandTools({
|
|
51596
|
+
...createCtxExpandTools({
|
|
51597
|
+
db,
|
|
51598
|
+
expandTools: config.historian?.expand_tools,
|
|
51599
|
+
transformMode: config.transform_mode
|
|
51600
|
+
}),
|
|
51320
51601
|
...createCtxNoteTools({
|
|
51321
51602
|
...project,
|
|
51322
51603
|
dreamerEnabled: isDreamerRunnable(config),
|
|
@@ -51796,6 +52077,11 @@ async function applyV2SystemPrompt(systemPrompt, draft) {
|
|
|
51796
52077
|
text
|
|
51797
52078
|
})));
|
|
51798
52079
|
}
|
|
52080
|
+
function coveredInstructionRows(reader, sessionID, throughSeq, model) {
|
|
52081
|
+
if (throughSeq < 0)
|
|
52082
|
+
return [];
|
|
52083
|
+
return reader.instructionRowsThrough(sessionID, throughSeq).flatMap((row) => restoreRow(row, model)).map((message) => markCoveredInstructionRow(message));
|
|
52084
|
+
}
|
|
51799
52085
|
async function registerContext(context) {
|
|
51800
52086
|
const directory = context.location.directory;
|
|
51801
52087
|
const config = loadPluginConfigDetailed(directory).config;
|
|
@@ -52791,7 +53077,7 @@ async function registerContext(context) {
|
|
|
52791
53077
|
asset: hostMediaAsset,
|
|
52792
53078
|
unavailable: (detail) => sessionLog2(draft.sessionID, `v2 restore: attachment replaced by a note row=${detail.rowID} name=${JSON.stringify(detail.name ?? null)} mediaType=${detail.mediaType} reason=${JSON.stringify(detail.reason)}`)
|
|
52793
53079
|
} : undefined));
|
|
52794
|
-
draft.messages.splice(0, draft.messages.length, ...restored, ...draft.messages.filter((message) => message !== incoming));
|
|
53080
|
+
draft.messages.splice(0, draft.messages.length, ...rustModeModuleClient ? [] : coveredInstructionRows(reader, draft.sessionID, Math.min(boundary, cut.seq), draft.model), ...restored, ...draft.messages.filter((message) => message !== incoming));
|
|
52795
53081
|
}
|
|
52796
53082
|
if (config.temporal_awareness === true)
|
|
52797
53083
|
messageTimes = reader.messageTimes(draft.sessionID, draft.messages.flatMap((message) => message.id ? [message.id] : []));
|