@cortexkit/opencode-magic-context 0.49.25 → 0.49.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-search-worker.js +4 -4
- package/dist/chunk-embedding-write-worker.js +7 -7
- package/dist/{compartment-chunk-embedding-eypvn607.js → compartment-chunk-embedding-qgp0tbf7.js} +3 -3
- package/dist/config/schema/magic-context.d.ts +393 -393
- package/dist/{conflict-warning-hook-a27bhggg.js → conflict-warning-hook-tgnw019g.js} +4 -4
- package/dist/{context-keb00be8.js → context-t2k97d6v.js} +116 -116
- package/dist/{embedding-backfill-vddgmem3.js → embedding-backfill-cwnyr4fj.js} +5 -5
- package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +1 -4
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +1 -28
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/session-retention.fixture.d.ts +4 -0
- package/dist/features/magic-context/session-retention.fixture.d.ts.map +1 -0
- package/dist/features/magic-context/storage-session-tables.d.ts +5 -12
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/hooks/magic-context/caveman-cleanup.d.ts +14 -0
- package/dist/hooks/magic-context/caveman-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +11 -0
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/foreign-text-parts.d.ts +47 -0
- package/dist/hooks/magic-context/foreign-text-parts.d.ts.map +1 -0
- package/dist/hooks/magic-context/historian-history-wait.d.ts +10 -0
- package/dist/hooks/magic-context/historian-history-wait.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +0 -5
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +0 -10
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +21 -0
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +20 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +15 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/todo-view.d.ts +2 -2
- package/dist/hooks/magic-context/transform.d.ts +7 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-jcr6pe7z.js → index-077ht5cq.js} +1 -1
- package/dist/{index-ebsvmc5s.js → index-31y1mznz.js} +4 -4
- package/dist/{index-q7ywt6xt.js → index-4cpc59jv.js} +5 -5
- package/dist/{index-t6j3qxnd.js → index-4ypqzvhf.js} +1 -1
- package/dist/index-7gbcg8xv.js +559 -0
- package/dist/{index-9q1g3c5q.js → index-7kkphb6c.js} +1 -1
- package/dist/{index-bhyksfyy.js → index-89k1w6x2.js} +3 -3
- package/dist/{index-z05n7702.js → index-a2fz9hpa.js} +1 -1
- package/dist/{index-0s8454t2.js → index-dcqk0y27.js} +1560 -91
- package/dist/{index-n18sch77.js → index-dzfevacx.js} +9 -9
- package/dist/{index-axjgxeww.js → index-fq2p158w.js} +169 -13
- package/dist/{index-3d5wnkq7.js → index-mm93m7y6.js} +1 -1
- package/dist/{index-zzrzjnx5.js → index-n8qmmd7f.js} +3 -3
- package/dist/{index-whcgcfrv.js → index-np3rgfw4.js} +1 -1
- package/dist/{index-y6xpzjzr.js → index-qzbpbnqt.js} +585 -602
- package/dist/{index-7tdtpqrg.js → index-rverk2vz.js} +39 -8
- package/dist/{index-cfaet9cg.js → index-s1n8dd2n.js} +1 -1
- package/dist/{index-z928hmnp.js → index-t3rbb8wr.js} +2 -2
- package/dist/{index-2haxh8h3.js → index-tvzvjggy.js} +1 -1
- package/dist/{index-c9zrgcnt.js → index-v0dhhxsq.js} +1 -1
- package/dist/{index-szf8r0ba.js → index-v15ne3a3.js} +2 -5
- package/dist/{index-x9k3mqrf.js → index-xrnsygfq.js} +1 -1
- package/dist/{index-yrrsp47d.js → index-yzjhx10y.js} +20 -6
- package/dist/index.js +40 -38
- package/dist/{message-fts-rowid-map-9e1getgs.js → message-fts-rowid-map-va36knh4.js} +2 -4
- package/dist/{message-index-bounded-vaeqhp9w.js → message-index-bounded-7ayzb2ah.js} +22 -25
- package/dist/migration-worker.js +6 -6
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/{project-embedding-registry-rstzmb60.js → project-embedding-registry-94nncs5g.js} +4 -4
- package/dist/raw-ordinal-warmup-worker.js +7 -30
- package/dist/{read-session-chunk-z5gnc0zb.js → read-session-chunk-jzb6w9w5.js} +8 -6
- package/dist/{read-session-raw-s4amywnh.js → read-session-raw-b2sd67v4.js} +3 -1
- package/dist/{recomp-orchestrator-qwqeskhq.js → recomp-orchestrator-02sa2ngr.js} +17 -17
- package/dist/{search-archive-mfabzyn2.js → search-archive-q1vw7zg4.js} +7 -7
- package/dist/{search-84zfqeky.js → search-spq6nfyf.js} +14 -15
- package/dist/{send-session-notification-ygj4mja0.js → send-session-notification-afzzqy5b.js} +3 -3
- package/dist/{storage-tags-a77q4v77.js → storage-tags-6hvkk01c.js} +2 -2
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-hr1ntmjj.js → transform-postprocess-phase-6menyyxc.js} +17 -17
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/chunk-embedding-write-worker.js +7 -7
- package/dist/v2/{compartment-chunk-embedding-tk6g4q80.js → compartment-chunk-embedding-63dzs31c.js} +3 -3
- package/dist/v2/{context-y7wfvdve.js → context-na0esngr.js} +342 -218
- package/dist/v2/{embedding-backfill-w5qp7t28.js → embedding-backfill-rh5dgsva.js} +5 -5
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-fts-rowid-map-pqk3a55v.js → message-fts-rowid-map-78awh03v.js} +2 -4
- package/dist/v2/{message-index-bounded-te303atj.js → message-index-bounded-n09b74vr.js} +21 -24
- package/dist/v2/migration-worker.js +6 -6
- package/dist/v2/{project-embedding-registry-e7zftfvj.js → project-embedding-registry-6pak822h.js} +4 -4
- package/dist/v2/raw-ordinal-warmup-worker.js +7 -30
- package/dist/v2/{read-session-chunk-knvkq1hf.js → read-session-chunk-vpt69tw9.js} +7 -5
- package/dist/v2/{read-session-raw-ppjxnqk4.js → read-session-raw-5x088amc.js} +3 -1
- package/dist/v2/{recomp-orchestrator-e8a4jpvr.js → recomp-orchestrator-txsmbnvw.js} +14 -14
- package/dist/v2/{search-archive-vrwgxv6z.js → search-archive-t9bcz4ht.js} +6 -6
- package/dist/v2/{search-hav4dggf.js → search-dcy9b6gd.js} +13 -14
- package/dist/v2/{send-session-notification-f8scq6ae.js → send-session-notification-vdsgnf4c.js} +1 -1
- package/dist/v2/{server-pw21ypwb.js → server-4sn3at8p.js} +1 -1
- package/dist/v2/{server-8j2e7t31.js → server-6avtp9jp.js} +1 -1
- package/dist/v2/{server-wwaw5npa.js → server-6g98c227.js} +1 -1
- package/dist/v2/{server-swvhxhxz.js → server-6vd2n183.js} +39 -8
- package/dist/v2/{server-wxrdher8.js → server-awr8qa4c.js} +2 -5
- package/dist/v2/{server-7d6m1p2b.js → server-cqjvxyrp.js} +1 -1
- package/dist/v2/{server-e75vag9d.js → server-e3hc93wk.js} +5 -5
- package/dist/v2/{server-7weh65vd.js → server-jj9qye8y.js} +1520 -79
- package/dist/v2/{server-fa7vtp40.js → server-nxas8v1d.js} +1 -1
- package/dist/v2/{server-tfawsj08.js → server-txbc3czn.js} +9 -9
- package/dist/v2/{server-rqebawx1.js → server-v77xa5wj.js} +1 -1
- package/dist/v2/{server-5brp2rfn.js → server-xkvxss5g.js} +19 -5
- package/dist/v2/{server-q5z0gag0.js → server-yqek3s4k.js} +1 -1
- package/dist/v2/server-z2n2xaeh.js +538 -0
- package/dist/v2/{server-9xbbaekh.js → server-z3mk9jdc.js} +2 -2
- package/dist/v2/{server-m6yyn961.js → server-zmcrvpm3.js} +2 -2
- package/dist/v2/server.js +2 -2
- package/dist/v2/{storage-tags-q71rnr9f.js → storage-tags-18nbaanf.js} +2 -2
- package/dist/v2/store-reader.d.ts +0 -2
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{wrapup-orchestrator-ycs8y6n4.js → wrapup-orchestrator-gjkszser.js} +14 -14
- package/dist/{wrapup-orchestrator-f642w8n3.js → wrapup-orchestrator-n5h5sr1x.js} +18 -18
- package/package.json +1 -1
- package/src/shared/write-transaction-attribution.test.ts +1 -6
- package/dist/index-awcftgmx.js +0 -2251
- package/dist/message-index-3g966xn7.js +0 -61
- package/dist/v2/message-index-fz6b4jeh.js +0 -60
- package/dist/v2/server-6a8pxpxg.js +0 -2220
|
@@ -82,10 +82,25 @@ import {
|
|
|
82
82
|
getUncoveredCompartmentEndsThrough,
|
|
83
83
|
providerResponseFailed,
|
|
84
84
|
isSuccessfulProviderCompletion,
|
|
85
|
+
LkgRecoveryFenceError,
|
|
86
|
+
lkgServedArrayDigest,
|
|
87
|
+
hasCleanLkgRecoveryFence,
|
|
88
|
+
dirtyLkgRecoveryRevision,
|
|
89
|
+
ownsLkgDirtyFence,
|
|
90
|
+
invalidateCleanLkgRecoveryFence,
|
|
91
|
+
prepareLkgCaptureFence,
|
|
92
|
+
certifyCommittedLkgCapture,
|
|
93
|
+
markLkgRecoveryDirty,
|
|
85
94
|
rememberUnpublishedAutoSearchNoHint,
|
|
86
95
|
getUnpublishedAutoSearchNoHint,
|
|
87
96
|
forgetUnpublishedAutoSearchNoHint,
|
|
88
97
|
registerAutoSearchWork,
|
|
98
|
+
gaDatabasePath,
|
|
99
|
+
RAW_MESSAGE_TYPES,
|
|
100
|
+
V2StoreReaderPool,
|
|
101
|
+
V2StoreReader,
|
|
102
|
+
advanceSessionActivity,
|
|
103
|
+
backfillSessionActivity,
|
|
89
104
|
getOrCreateSessionMeta,
|
|
90
105
|
updateSessionMeta,
|
|
91
106
|
advanceToolReclaimWatermark,
|
|
@@ -263,6 +278,7 @@ import {
|
|
|
263
278
|
producerPromptFailureReason,
|
|
264
279
|
resolveHiddenCompletionExecutor,
|
|
265
280
|
createV1HiddenCompletionExecutor,
|
|
281
|
+
shouldWaitForNewHistorianHistory,
|
|
266
282
|
EMPTY_READ_REPLY,
|
|
267
283
|
noteTouchedAt,
|
|
268
284
|
renderGlance,
|
|
@@ -286,7 +302,7 @@ import {
|
|
|
286
302
|
startCompartmentAgent,
|
|
287
303
|
setRecompStarting2,
|
|
288
304
|
setRecompTerminal2
|
|
289
|
-
} from "./server-
|
|
305
|
+
} from "./server-jj9qye8y.js";
|
|
290
306
|
import {
|
|
291
307
|
resolveHistorianModel2
|
|
292
308
|
} from "./server-5kym00ag.js";
|
|
@@ -311,7 +327,7 @@ import {
|
|
|
311
327
|
openDatabaseAsync,
|
|
312
328
|
isDatabasePersisted,
|
|
313
329
|
getDatabasePersistenceError
|
|
314
|
-
} from "./server-
|
|
330
|
+
} from "./server-e3hc93wk.js";
|
|
315
331
|
import {
|
|
316
332
|
pruneMissingProjectIdentities,
|
|
317
333
|
setHomeProjectPermission,
|
|
@@ -329,39 +345,6 @@ import {
|
|
|
329
345
|
beginBootQuietPeriod,
|
|
330
346
|
scheduleAfterBootQuiet
|
|
331
347
|
} from "./server-qjvk4a9t.js";
|
|
332
|
-
import {
|
|
333
|
-
registerOwnRpcServerInstance,
|
|
334
|
-
rpcPortDir,
|
|
335
|
-
rpcPortFilePath,
|
|
336
|
-
parseRpcPortFile,
|
|
337
|
-
inspectProcessesAsync
|
|
338
|
-
} from "./server-k3t06fxr.js";
|
|
339
|
-
import {
|
|
340
|
-
LkgRecoveryFenceError,
|
|
341
|
-
lkgServedArrayDigest,
|
|
342
|
-
takeLkgRecoveryLockSweepPage,
|
|
343
|
-
hasCleanLkgRecoveryFence,
|
|
344
|
-
dirtyLkgRecoveryRevision,
|
|
345
|
-
ownsLkgDirtyFence,
|
|
346
|
-
invalidateCleanLkgRecoveryFence,
|
|
347
|
-
prepareLkgCaptureFence,
|
|
348
|
-
certifyCommittedLkgCapture,
|
|
349
|
-
markLkgRecoveryDirty,
|
|
350
|
-
gaDatabasePath,
|
|
351
|
-
RAW_MESSAGE_TYPES,
|
|
352
|
-
V2StoreReaderPool,
|
|
353
|
-
V2StoreReader,
|
|
354
|
-
cleanSearchText,
|
|
355
|
-
matchedSearchSnippet,
|
|
356
|
-
advanceSessionActivity,
|
|
357
|
-
backfillSessionActivity,
|
|
358
|
-
getLastIndexedOrdinal2,
|
|
359
|
-
getMessageIndexReconciliationStartOrdinal2,
|
|
360
|
-
isMessageIndexReconciledThrough2,
|
|
361
|
-
clearIndexedMessages2,
|
|
362
|
-
indexMessagesAfterOrdinal2,
|
|
363
|
-
sweepOrphanedOpenCodeMessageIndexesCooperatively2
|
|
364
|
-
} from "./server-6a8pxpxg.js";
|
|
365
348
|
import"./server-51779zs2.js";
|
|
366
349
|
import {
|
|
367
350
|
inRootAsyncContext2,
|
|
@@ -387,15 +370,7 @@ import {
|
|
|
387
370
|
buildInMemoryTailRawMessages2,
|
|
388
371
|
RawOrdinalsNotReady2,
|
|
389
372
|
runSessionWarmupWorker
|
|
390
|
-
} from "./server-
|
|
391
|
-
import {
|
|
392
|
-
resolveOpenCodeDbPath,
|
|
393
|
-
assertOpenCodeStoreGeneration,
|
|
394
|
-
openCodeDbPathExists,
|
|
395
|
-
recordOpenCodeDbReadFailure,
|
|
396
|
-
clearOpenCodeDbReadFailure,
|
|
397
|
-
claimOpenCodeDbDiagnosticOnce
|
|
398
|
-
} from "./server-2ra6pwf3.js";
|
|
373
|
+
} from "./server-6vd2n183.js";
|
|
399
374
|
import {
|
|
400
375
|
resolveModelCalibration,
|
|
401
376
|
calibrateBuckets,
|
|
@@ -490,7 +465,7 @@ import {
|
|
|
490
465
|
adoptNullOwnerToolTag2,
|
|
491
466
|
getCandidateToolOwners2,
|
|
492
467
|
pickNearestPriorOwner2
|
|
493
|
-
} from "./server-
|
|
468
|
+
} from "./server-nxas8v1d.js";
|
|
494
469
|
import {
|
|
495
470
|
textMentionsRecentCommit,
|
|
496
471
|
hasMeaningfulUserText2,
|
|
@@ -509,7 +484,15 @@ import {
|
|
|
509
484
|
freezeTemporalDecisions,
|
|
510
485
|
tagRevisionKey,
|
|
511
486
|
tagIdentityRevisionKey
|
|
512
|
-
} from "./server-
|
|
487
|
+
} from "./server-v77xa5wj.js";
|
|
488
|
+
import {
|
|
489
|
+
resolveOpenCodeDbPath,
|
|
490
|
+
assertOpenCodeStoreGeneration,
|
|
491
|
+
openCodeDbPathExists,
|
|
492
|
+
recordOpenCodeDbReadFailure,
|
|
493
|
+
clearOpenCodeDbReadFailure,
|
|
494
|
+
claimOpenCodeDbDiagnosticOnce
|
|
495
|
+
} from "./server-2ra6pwf3.js";
|
|
513
496
|
import {
|
|
514
497
|
openCodeDbExists,
|
|
515
498
|
withReadOnlySessionDb,
|
|
@@ -716,25 +699,23 @@ import {
|
|
|
716
699
|
readRawSessionMessageById2,
|
|
717
700
|
readSessionChunk2,
|
|
718
701
|
readRawSessionSeedTail2
|
|
719
|
-
} from "./server-
|
|
702
|
+
} from "./server-xkvxss5g.js";
|
|
720
703
|
import {
|
|
721
704
|
BoundedSessionMap,
|
|
722
705
|
recordToolDefinitionSet,
|
|
723
706
|
getCurrentToolSetHash,
|
|
724
707
|
getMeasuredToolDefinitionTokens
|
|
725
|
-
} from "./server-
|
|
726
|
-
import"./server-wxrdher8.js";
|
|
708
|
+
} from "./server-cqjvxyrp.js";
|
|
727
709
|
import {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
} from "./server-pw21ypwb.js";
|
|
710
|
+
cleanSearchText,
|
|
711
|
+
matchedSearchSnippet,
|
|
712
|
+
getLastIndexedOrdinal,
|
|
713
|
+
getMessageIndexReconciliationStartOrdinal,
|
|
714
|
+
isMessageIndexReconciledThrough,
|
|
715
|
+
clearIndexedMessages,
|
|
716
|
+
indexMessagesAfterOrdinal
|
|
717
|
+
} from "./server-z2n2xaeh.js";
|
|
718
|
+
import"./server-awr8qa4c.js";
|
|
738
719
|
import {
|
|
739
720
|
embedPauseBySession,
|
|
740
721
|
embedRunStateBySession,
|
|
@@ -764,7 +745,25 @@ import {
|
|
|
764
745
|
embedSessionCompartmentChunks2,
|
|
765
746
|
getEmbeddingCoverageStatus2,
|
|
766
747
|
getAutoEmbeddingSessionCoverage2
|
|
767
|
-
} from "./server-
|
|
748
|
+
} from "./server-yqek3s4k.js";
|
|
749
|
+
import {
|
|
750
|
+
SubcClient,
|
|
751
|
+
connectionFileExists,
|
|
752
|
+
SYNAPSE_DEFAULT_MODEL,
|
|
753
|
+
toSynapseLaneDescriptor,
|
|
754
|
+
formatSynapseLaneDescriptor,
|
|
755
|
+
SynapseEmbeddingProvider
|
|
756
|
+
} from "./server-ab1g0wn9.js";
|
|
757
|
+
import {
|
|
758
|
+
deleteChunkEmbedBackoffForSession2
|
|
759
|
+
} from "./server-4sn3at8p.js";
|
|
760
|
+
import {
|
|
761
|
+
registerOwnRpcServerInstance,
|
|
762
|
+
rpcPortDir,
|
|
763
|
+
rpcPortFilePath,
|
|
764
|
+
parseRpcPortFile,
|
|
765
|
+
inspectProcessesAsync
|
|
766
|
+
} from "./server-k3t06fxr.js";
|
|
768
767
|
import {
|
|
769
768
|
V2_MEMORY_CATEGORIES,
|
|
770
769
|
CATEGORY_PRIORITY
|
|
@@ -777,7 +776,7 @@ import {
|
|
|
777
776
|
resolveStoredPathWorkspaceIdentity,
|
|
778
777
|
storedPathBelongsToWorkspace,
|
|
779
778
|
computeWorkspaceEpochFingerprint
|
|
780
|
-
} from "./server-
|
|
779
|
+
} from "./server-6g98c227.js";
|
|
781
780
|
import {
|
|
782
781
|
configureContextDatabasePragmas2
|
|
783
782
|
} from "./server-fb3zxn06.js";
|
|
@@ -823,7 +822,7 @@ import {
|
|
|
823
822
|
readGitFileChangeTimesSince,
|
|
824
823
|
verificationFileExists,
|
|
825
824
|
normalizeVerificationFiles
|
|
826
|
-
} from "./server-
|
|
825
|
+
} from "./server-z3mk9jdc.js";
|
|
827
826
|
import {
|
|
828
827
|
deriveTriggerBudget2,
|
|
829
828
|
deriveHistorianChunkTokens2,
|
|
@@ -857,7 +856,7 @@ import {
|
|
|
857
856
|
} from "./server-vr4szghm.js";
|
|
858
857
|
import {
|
|
859
858
|
cosineSimilarity
|
|
860
|
-
} from "./server-
|
|
859
|
+
} from "./server-6avtp9jp.js";
|
|
861
860
|
import {
|
|
862
861
|
computeCueContentHash,
|
|
863
862
|
hasMuralCueColumns,
|
|
@@ -914,14 +913,14 @@ import {
|
|
|
914
913
|
resolveMemoriesByIdsForSearch2,
|
|
915
914
|
unifiedSearch2,
|
|
916
915
|
formatSearchResults2
|
|
917
|
-
} from "./server-
|
|
916
|
+
} from "./server-txbc3czn.js";
|
|
918
917
|
import {
|
|
919
918
|
resolvePromptContext2
|
|
920
919
|
} from "./server-fmsr7v69.js";
|
|
921
920
|
import"./server-kaqs6h31.js";
|
|
922
921
|
import {
|
|
923
922
|
renderSearchArchiveOffThread2
|
|
924
|
-
} from "./server-
|
|
923
|
+
} from "./server-zmcrvpm3.js";
|
|
925
924
|
import {
|
|
926
925
|
compareSemverCore
|
|
927
926
|
} from "./server-84w6rvvf.js";
|
|
@@ -1847,15 +1846,15 @@ async function reconcileSessionIndex(db, sessionId, readMessages) {
|
|
|
1847
1846
|
const revision = readMessages.getRevision?.(sessionId);
|
|
1848
1847
|
const previous = heapHolder.reconciledSnapshots.get(sessionId);
|
|
1849
1848
|
const finalWatermark = previous && revision === previous.revision ? previous.count : revision !== undefined && readMessages.getCountAfterRevision ? previous && revision > previous.revision ? previous.count + readMessages.getCountAfterRevision(sessionId, previous.revision, revision) : readMessages.getCountAfterRevision(sessionId, -1, revision) : readMessages.getCount ? readMessages.getCount(sessionId) : (fallbackSnapshot = fullReader?.(sessionId) ?? []).length;
|
|
1850
|
-
let cursor =
|
|
1849
|
+
let cursor = getMessageIndexReconciliationStartOrdinal(db, sessionId);
|
|
1851
1850
|
let after = cursor === previous?.count ? previous.after : undefined;
|
|
1852
1851
|
while (cursor < finalWatermark) {
|
|
1853
1852
|
const pageEnd = Math.min(finalWatermark, cursor + RECONCILIATION_BATCH_SIZE);
|
|
1854
1853
|
const messages = readMessages.readPage ? readMessages.readPage(sessionId, cursor, RECONCILIATION_BATCH_SIZE, finalWatermark, after) : (fallbackSnapshot ?? []).filter((message) => message.ordinal > cursor && message.ordinal <= pageEnd);
|
|
1855
1854
|
const retainedMessages = fallbackSnapshot ?? messages;
|
|
1856
1855
|
heapHolder.activeReconcilerBuffers.set(sessionId, retainedMessages);
|
|
1857
|
-
withSqliteBackgroundWriter2(() =>
|
|
1858
|
-
const nextCursor =
|
|
1856
|
+
withSqliteBackgroundWriter2(() => indexMessagesAfterOrdinal(db, sessionId, messages, cursor, pageEnd));
|
|
1857
|
+
const nextCursor = getMessageIndexReconciliationStartOrdinal(db, sessionId);
|
|
1859
1858
|
if (nextCursor <= cursor)
|
|
1860
1859
|
break;
|
|
1861
1860
|
cursor = nextCursor;
|
|
@@ -1865,7 +1864,7 @@ async function reconcileSessionIndex(db, sessionId, readMessages) {
|
|
|
1865
1864
|
await yieldToEventLoop();
|
|
1866
1865
|
}
|
|
1867
1866
|
}
|
|
1868
|
-
if (
|
|
1867
|
+
if (isMessageIndexReconciledThrough(db, sessionId, finalWatermark)) {
|
|
1869
1868
|
heapHolder.reconciledSessions.add(sessionId);
|
|
1870
1869
|
if (revision !== undefined) {
|
|
1871
1870
|
if (!after && finalWatermark > 0 && readMessages.readPage) {
|
|
@@ -1919,42 +1918,6 @@ function scheduleReconciliation(db, sessionId, readMessages) {
|
|
|
1919
1918
|
});
|
|
1920
1919
|
});
|
|
1921
1920
|
}
|
|
1922
|
-
async function sweepOrphanedOpenCodeMessageIndexesOffThread(db, openSource, options = {}) {
|
|
1923
|
-
if (getHarness2() === "opencode" || getHarness2() === "opencode2")
|
|
1924
|
-
options = {
|
|
1925
|
-
...options,
|
|
1926
|
-
fenceLockNames: options.fenceLockNames ?? takeLkgRecoveryLockSweepPage()
|
|
1927
|
-
};
|
|
1928
|
-
if (getHarness2() === "opencode2")
|
|
1929
|
-
openSource = () => new Database2(gaDatabasePath(getDataDir(), process.env.OPENCODE_CHANNEL ?? "latest"), {
|
|
1930
|
-
readonly: true,
|
|
1931
|
-
fileMustExist: true
|
|
1932
|
-
});
|
|
1933
|
-
const path = getSqliteDatabasePath2(db);
|
|
1934
|
-
if (!path || getHarness2() !== "opencode" && getHarness2() !== "opencode2")
|
|
1935
|
-
return sweepOrphanedOpenCodeMessageIndexesCooperatively2(db, openSource, options);
|
|
1936
|
-
let source = null;
|
|
1937
|
-
let sourcePath = null;
|
|
1938
|
-
try {
|
|
1939
|
-
source = openSource();
|
|
1940
|
-
if (source)
|
|
1941
|
-
sourcePath = getSqliteDatabasePath2(source);
|
|
1942
|
-
} catch {} finally {
|
|
1943
|
-
if (sourcePath)
|
|
1944
|
-
source?.close();
|
|
1945
|
-
}
|
|
1946
|
-
if (!sourcePath)
|
|
1947
|
-
return sweepOrphanedOpenCodeMessageIndexesCooperatively2(db, () => source, options);
|
|
1948
|
-
const reply = await runSessionWarmupWorker({
|
|
1949
|
-
path,
|
|
1950
|
-
sessionId: "",
|
|
1951
|
-
harness: getHarness2(),
|
|
1952
|
-
orphanSweep: { sourcePath, options }
|
|
1953
|
-
}, {});
|
|
1954
|
-
if (!("orphanSweep" in reply))
|
|
1955
|
-
throw new Error("message history orphan sweep worker failed");
|
|
1956
|
-
return reply.orphanSweep;
|
|
1957
|
-
}
|
|
1958
1921
|
function scheduleClearAndReindex(db, sessionId, readMessages) {
|
|
1959
1922
|
heapHolder.reconciledSessions.delete(sessionId);
|
|
1960
1923
|
heapHolder.reconciledSnapshots.delete(sessionId);
|
|
@@ -1977,7 +1940,7 @@ function scheduleClearAndReindex(db, sessionId, readMessages) {
|
|
|
1977
1940
|
heapHolder.reconciledSessions.delete(sessionId);
|
|
1978
1941
|
heapHolder.reconciledSnapshots.delete(sessionId);
|
|
1979
1942
|
clearCompletedIncrementalKeys(sessionId);
|
|
1980
|
-
|
|
1943
|
+
clearIndexedMessages(db, sessionId);
|
|
1981
1944
|
cleared = true;
|
|
1982
1945
|
}).then(() => cleared ? reconcileSessionIndex(db, sessionId, pending.source) : undefined).catch((error) => {
|
|
1983
1946
|
heapHolder.reconciledSessions.delete(sessionId);
|
|
@@ -6578,6 +6541,13 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
|
|
|
6578
6541
|
}
|
|
6579
6542
|
return { shouldFire: false };
|
|
6580
6543
|
}
|
|
6544
|
+
if (tailInfo.boundarySnapshot && shouldWaitForNewHistorianHistory(tailInfo.boundarySnapshot, {
|
|
6545
|
+
usagePercentage: usage.percentage,
|
|
6546
|
+
emergency: getOverflowState(db, sessionId).needsEmergencyRecovery
|
|
6547
|
+
})) {
|
|
6548
|
+
sessionLog2(sessionId, "compartment trigger: waiting for new history after no forward progress");
|
|
6549
|
+
return { shouldFire: false };
|
|
6550
|
+
}
|
|
6581
6551
|
const canClearReasoning = reasoningProjection?.canClearReasoning ?? modelAcceptsEmptyContent(reasoningProjection?.providerID);
|
|
6582
6552
|
const projectedPostDropPercentage = estimateProjectedPostDropPercentage(db, sessionId, usage, preloadedActiveTags ?? getActiveTagsBySession2(db, sessionId), keepReasoningTokens, sessionMeta.clearedReasoningThroughTag, canClearReasoning, reasoningProjection?.budgetCutoff, eligiblePendingDropTagIds);
|
|
6583
6553
|
const relativePostDropTarget = executeThresholdPercentage * POST_DROP_TARGET_RATIO;
|
|
@@ -8289,6 +8259,23 @@ function applyCompressedText(target, tagNumber, originalText, depth, state) {
|
|
|
8289
8259
|
target.setContent(`${target.textPrefix ?? ""}${compressed}`, { keepReasoning: true });
|
|
8290
8260
|
return target.getContent ? target.getContent() !== before : true;
|
|
8291
8261
|
}
|
|
8262
|
+
function cavemanReplayText(tagNumber, originalText, depth, state, textPrefix) {
|
|
8263
|
+
const level = DEPTH_TO_LEVEL[depth];
|
|
8264
|
+
if (!level)
|
|
8265
|
+
return null;
|
|
8266
|
+
let served = null;
|
|
8267
|
+
if (!state.currentRules || state.legacyReasoningTags.has(tagNumber)) {
|
|
8268
|
+
const legacy = cavemanCompress(originalText, level, "ascii-v1");
|
|
8269
|
+
if (legacy.length > 0)
|
|
8270
|
+
served = { text: legacy, dropsReasoning: true };
|
|
8271
|
+
if (!state.currentRules)
|
|
8272
|
+
return served;
|
|
8273
|
+
}
|
|
8274
|
+
const compressed = cavemanCompress(originalText, level, CURRENT_CAVEMAN_RULES, wordRulesFor(state));
|
|
8275
|
+
if (compressed.length === 0)
|
|
8276
|
+
return served;
|
|
8277
|
+
return { text: `${textPrefix}${compressed}`, dropsReasoning: served?.dropsReasoning ?? false };
|
|
8278
|
+
}
|
|
8292
8279
|
function replayCavemanCompression(sessionId, db, targets, tags) {
|
|
8293
8280
|
const compressedTags = tags.filter((tag) => tag.type === "message" && tag.status === "active" && tag.cavemanDepth > 0 && targets.has(tag.tagNumber));
|
|
8294
8281
|
if (compressedTags.length === 0)
|
|
@@ -8997,6 +8984,42 @@ function stripStructuralNoise(messages) {
|
|
|
8997
8984
|
}
|
|
8998
8985
|
return strippedParts;
|
|
8999
8986
|
}
|
|
8987
|
+
// src/hooks/magic-context/foreign-text-parts.ts
|
|
8988
|
+
function hasStringId(part) {
|
|
8989
|
+
return part !== null && typeof part === "object" && typeof part.id === "string";
|
|
8990
|
+
}
|
|
8991
|
+
function lastStoredPartIndex(parts) {
|
|
8992
|
+
for (let index = parts.length - 1;index >= 0; index -= 1) {
|
|
8993
|
+
if (hasStringId(parts[index]))
|
|
8994
|
+
return index;
|
|
8995
|
+
}
|
|
8996
|
+
return -1;
|
|
8997
|
+
}
|
|
8998
|
+
var legacyForeignTextTags = new Map;
|
|
8999
|
+
function rememberLegacyForeignTextTags(sessionId, tagNumbers) {
|
|
9000
|
+
for (const tagNumber of tagNumbers) {
|
|
9001
|
+
let known = legacyForeignTextTags.get(sessionId);
|
|
9002
|
+
if (!known) {
|
|
9003
|
+
known = new Set;
|
|
9004
|
+
legacyForeignTextTags.set(sessionId, known);
|
|
9005
|
+
}
|
|
9006
|
+
known.add(tagNumber);
|
|
9007
|
+
}
|
|
9008
|
+
}
|
|
9009
|
+
function isLegacyForeignTextTag(sessionId, tagNumber) {
|
|
9010
|
+
return legacyForeignTextTags.get(sessionId)?.has(tagNumber) ?? false;
|
|
9011
|
+
}
|
|
9012
|
+
var pendingOpForTagStatements = new WeakMap;
|
|
9013
|
+
function discardPendingOpForForeignTag(db, sessionId, tagNumber) {
|
|
9014
|
+
let statement = pendingOpForTagStatements.get(db);
|
|
9015
|
+
if (!statement) {
|
|
9016
|
+
statement = db.prepare("SELECT 1 AS present FROM pending_ops WHERE session_id = ? AND tag_id = ? LIMIT 1");
|
|
9017
|
+
pendingOpForTagStatements.set(db, statement);
|
|
9018
|
+
}
|
|
9019
|
+
if (statement.get(sessionId, tagNumber))
|
|
9020
|
+
removePendingOp(db, sessionId, tagNumber);
|
|
9021
|
+
}
|
|
9022
|
+
|
|
9000
9023
|
// src/hooks/magic-context/tag-id-fallback.ts
|
|
9001
9024
|
function parseScopedContentId(contentId) {
|
|
9002
9025
|
const match = /^(.*):(p|file)(\d+)$/.exec(contentId);
|
|
@@ -9188,6 +9211,62 @@ function deriveToolOwnerMessageId(sessionId, db, message, obs, unpaired, cache,
|
|
|
9188
9211
|
}
|
|
9189
9212
|
return obs.callId;
|
|
9190
9213
|
}
|
|
9214
|
+
function serveLegacyForeignText(legacy, current, options) {
|
|
9215
|
+
const prefixed = options.skipPrefixInjection ? current : prependTag(legacy.tagNumber, current);
|
|
9216
|
+
if (options.pastPartialEnd)
|
|
9217
|
+
return { text: prefixed, dropsReasoning: false };
|
|
9218
|
+
if (legacy.status === "dropped") {
|
|
9219
|
+
return { text: buildReplacementContent(legacy.tagNumber), dropsReasoning: true };
|
|
9220
|
+
}
|
|
9221
|
+
const unchanged = legacy.savedText !== undefined && stripTagPrefix(current) === legacy.savedText;
|
|
9222
|
+
if (legacy.status === "active" && legacy.cavemanDepth > 0 && options.caveman && unchanged && legacy.savedText) {
|
|
9223
|
+
const replayed = cavemanReplayText(legacy.tagNumber, legacy.savedText, legacy.cavemanDepth, options.caveman, options.skipPrefixInjection ? "" : prependTag(legacy.tagNumber, ""));
|
|
9224
|
+
if (replayed)
|
|
9225
|
+
return replayed;
|
|
9226
|
+
}
|
|
9227
|
+
return { text: prefixed, dropsReasoning: false };
|
|
9228
|
+
}
|
|
9229
|
+
function findLegacyForeignTextTags(sessionId, messages, assignments, db, isForeignTextPart, inertWhitespaceTagNumbers) {
|
|
9230
|
+
const legacy = new Map;
|
|
9231
|
+
for (const message of messages) {
|
|
9232
|
+
const messageId = typeof message.info.id === "string" ? message.info.id : null;
|
|
9233
|
+
if (!messageId)
|
|
9234
|
+
continue;
|
|
9235
|
+
const firstTrailingIndex = lastStoredPartIndex(message.parts) + 1;
|
|
9236
|
+
for (let partIndex = firstTrailingIndex;partIndex < message.parts.length; partIndex += 1) {
|
|
9237
|
+
const part = message.parts[partIndex];
|
|
9238
|
+
if (!isTextPart(part) || !isForeignTextPart(part))
|
|
9239
|
+
continue;
|
|
9240
|
+
const contentId = `${messageId}:p${partIndex}`;
|
|
9241
|
+
const tagNumber = assignments.get(contentId) ?? getTagNumberByMessageId2(db, sessionId, contentId);
|
|
9242
|
+
if (tagNumber === null || tagNumber === undefined)
|
|
9243
|
+
continue;
|
|
9244
|
+
if (inertWhitespaceTagNumbers.has(tagNumber))
|
|
9245
|
+
continue;
|
|
9246
|
+
const tag = getTagById2(db, sessionId, tagNumber);
|
|
9247
|
+
if (tag?.type !== "message")
|
|
9248
|
+
continue;
|
|
9249
|
+
legacy.set(part, {
|
|
9250
|
+
tagNumber,
|
|
9251
|
+
status: tag.status,
|
|
9252
|
+
cavemanDepth: tag.cavemanDepth
|
|
9253
|
+
});
|
|
9254
|
+
}
|
|
9255
|
+
}
|
|
9256
|
+
if (legacy.size > 0) {
|
|
9257
|
+
const tagNumbers = [...legacy.values()].map((entry) => entry.tagNumber);
|
|
9258
|
+
rememberLegacyForeignTextTags(sessionId, tagNumbers);
|
|
9259
|
+
for (const tagNumber of tagNumbers)
|
|
9260
|
+
discardPendingOpForForeignTag(db, sessionId, tagNumber);
|
|
9261
|
+
const compressed = [...legacy.values()].filter((entry) => entry.status === "active" && entry.cavemanDepth > 0);
|
|
9262
|
+
if (compressed.length > 0) {
|
|
9263
|
+
const saved = getSourceContents(db, sessionId, compressed.map((entry) => entry.tagNumber));
|
|
9264
|
+
for (const entry of compressed)
|
|
9265
|
+
entry.savedText = saved.get(entry.tagNumber);
|
|
9266
|
+
}
|
|
9267
|
+
}
|
|
9268
|
+
return legacy;
|
|
9269
|
+
}
|
|
9191
9270
|
function collectRelevantSourceTagIds(messages, assignments) {
|
|
9192
9271
|
const currentMessageIds = new Set(messages.flatMap((message) => typeof message.info.id === "string" ? [message.info.id] : []));
|
|
9193
9272
|
const relevantTagIds = new Set;
|
|
@@ -9310,8 +9389,17 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
9310
9389
|
logTransformTiming(sessionId, "tag.inertWhitespace", tInertWhitespace);
|
|
9311
9390
|
const assignments = tagger.getAssignments(sessionId);
|
|
9312
9391
|
const resolver = createExistingTagResolver(sessionId, tagger, db);
|
|
9392
|
+
const foreignTextParts = options.foreignTextParts;
|
|
9393
|
+
const isForeignTextPart = (part) => foreignTextParts !== undefined && part !== null && typeof part === "object" && foreignTextParts.has(part);
|
|
9394
|
+
const legacyForeignTags = findLegacyForeignTextTags(sessionId, messages, assignments, db, isForeignTextPart, inertWhitespaceTagNumbers);
|
|
9395
|
+
const legacyForeignTagNumbers = new Set([...legacyForeignTags.values()].map((legacy) => legacy.tagNumber));
|
|
9396
|
+
let cavemanState;
|
|
9397
|
+
const legacyCavemanState = () => {
|
|
9398
|
+
cavemanState ??= options.replaysCaveman ? getCavemanReplayState(db, sessionId) : null;
|
|
9399
|
+
return cavemanState;
|
|
9400
|
+
};
|
|
9313
9401
|
const tGetSourceContents = performance.now();
|
|
9314
|
-
const sourceContents = getSourceContents(db, sessionId, collectRelevantSourceTagIds(messages, assignments));
|
|
9402
|
+
const sourceContents = getSourceContents(db, sessionId, collectRelevantSourceTagIds(messages, assignments).filter((tagNumber) => !legacyForeignTagNumbers.has(tagNumber)));
|
|
9315
9403
|
logTransformTiming(sessionId, "tag.getSourceContents", tGetSourceContents);
|
|
9316
9404
|
let partialEndsCache;
|
|
9317
9405
|
const loadPartialEnds = () => {
|
|
@@ -9405,6 +9493,28 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
9405
9493
|
}
|
|
9406
9494
|
ownerByPartKey.set(part, { ownerMsgId, callId: toolObservation.callId });
|
|
9407
9495
|
}
|
|
9496
|
+
if (messageId && isTextPart(part) && isForeignTextPart(part)) {
|
|
9497
|
+
const legacy = legacyForeignTags.get(part);
|
|
9498
|
+
if (legacy) {
|
|
9499
|
+
const partialEnd = getPartialEnds().get(messageId);
|
|
9500
|
+
const served = serveLegacyForeignText(legacy, part.text, {
|
|
9501
|
+
skipPrefixInjection,
|
|
9502
|
+
pastPartialEnd: partialEnd !== undefined && partIndex > partialEnd,
|
|
9503
|
+
caveman: legacy.cavemanDepth > 0 ? legacyCavemanState() : null
|
|
9504
|
+
});
|
|
9505
|
+
part.text = served.text;
|
|
9506
|
+
if (served.dropsReasoning) {
|
|
9507
|
+
for (const thinkingPart of messageThinkingParts) {
|
|
9508
|
+
if (protectedThinkingParts.has(thinkingPart))
|
|
9509
|
+
continue;
|
|
9510
|
+
if (partialEnd !== undefined && message.parts.indexOf(thinkingPart) > partialEnd)
|
|
9511
|
+
continue;
|
|
9512
|
+
neutralizeDroppedReasoningPart(thinkingPart);
|
|
9513
|
+
}
|
|
9514
|
+
}
|
|
9515
|
+
}
|
|
9516
|
+
continue;
|
|
9517
|
+
}
|
|
9408
9518
|
if (messageId && isTextPart(part)) {
|
|
9409
9519
|
const textPart = part;
|
|
9410
9520
|
const thinkingParts = messageThinkingParts;
|
|
@@ -9446,7 +9556,7 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
9446
9556
|
}
|
|
9447
9557
|
} else {
|
|
9448
9558
|
existingTagId = resolver.resolve(messageId, "message", contentId, textOrdinal, {
|
|
9449
|
-
accept: (tagNumber) => !inertWhitespaceTagNumbers.has(tagNumber)
|
|
9559
|
+
accept: (tagNumber) => !inertWhitespaceTagNumbers.has(tagNumber) && !legacyForeignTagNumbers.has(tagNumber)
|
|
9450
9560
|
});
|
|
9451
9561
|
if (existingTagId === undefined && inertWhitespaceTagNumbers.has(tagger.getTag(sessionId, contentId, "message") ?? -1)) {
|
|
9452
9562
|
tagger.unbindTag(sessionId, contentId);
|
|
@@ -19158,6 +19268,7 @@ function createTransform(deps) {
|
|
|
19158
19268
|
const startTime = performance.now();
|
|
19159
19269
|
const historianRun = deps.resolveHistorianRun?.();
|
|
19160
19270
|
const messages = output.messages;
|
|
19271
|
+
const foreignTextParts = deps.transformMode === "rust" ? undefined : deps.collectForeignTextParts?.(messages);
|
|
19161
19272
|
const entryOrderForThinkingFit = messages.slice();
|
|
19162
19273
|
const coveredHostInstructions = takeCoveredInstructionRows(messages);
|
|
19163
19274
|
const passOutcome = createPassOutcome();
|
|
@@ -19822,6 +19933,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19822
19933
|
}
|
|
19823
19934
|
logTransformTiming(sessionId, "injectTemporalMarkers", tTemporal);
|
|
19824
19935
|
}
|
|
19936
|
+
const replaysCaveman = !reducedMode && !compactionOff && deps.cavemanTextCompression?.enabled === true;
|
|
19825
19937
|
let taggingSucceeded = false;
|
|
19826
19938
|
let recoveryBatch = null;
|
|
19827
19939
|
let recoveryNormalized = false;
|
|
@@ -19834,7 +19946,9 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19834
19946
|
skipPrefixInjection: !ctxReduceCallable,
|
|
19835
19947
|
servedMessages: messages,
|
|
19836
19948
|
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText,
|
|
19837
|
-
refreshSourceContents: deps.refreshSourceContents?.(sessionId)
|
|
19949
|
+
refreshSourceContents: deps.refreshSourceContents?.(sessionId),
|
|
19950
|
+
foreignTextParts,
|
|
19951
|
+
replaysCaveman
|
|
19838
19952
|
});
|
|
19839
19953
|
for (const [number, target] of tagged.targets)
|
|
19840
19954
|
targets.set(number, target);
|
|
@@ -19860,7 +19974,9 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19860
19974
|
scopedToolSweep,
|
|
19861
19975
|
servedMessages: messages,
|
|
19862
19976
|
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText,
|
|
19863
|
-
refreshSourceContents: deps.refreshSourceContents?.(sessionId)
|
|
19977
|
+
refreshSourceContents: deps.refreshSourceContents?.(sessionId),
|
|
19978
|
+
foreignTextParts,
|
|
19979
|
+
replaysCaveman
|
|
19864
19980
|
});
|
|
19865
19981
|
targets = result.targets;
|
|
19866
19982
|
if (thinkingRecovery.restore)
|
|
@@ -19916,7 +20032,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19916
20032
|
const t3 = performance.now();
|
|
19917
20033
|
const strippedStructuralNoise = canUseEmptySentinels && !compactionOff ? stripStructuralNoise(messages) : 0;
|
|
19918
20034
|
logTransformTiming(sessionId, "stripStructuralNoise", t3, `strippedParts=${strippedStructuralNoise}`);
|
|
19919
|
-
if (
|
|
20035
|
+
if (replaysCaveman) {
|
|
19920
20036
|
const tCavemanReplay = performance.now();
|
|
19921
20037
|
const replayedCaveman = replayCavemanCompression(sessionId, db, targets, activeTags);
|
|
19922
20038
|
if (replayedCaveman > 0) {
|
|
@@ -23825,8 +23941,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
23825
23941
|
const db = readDatabase();
|
|
23826
23942
|
if (!db)
|
|
23827
23943
|
return { ok: false, error: "db unavailable" };
|
|
23828
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
23829
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
23944
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-txsmbnvw.js"));
|
|
23945
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-vdsgnf4c.js"));
|
|
23830
23946
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
23831
23947
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
23832
23948
|
return {
|
|
@@ -23910,7 +24026,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
23910
24026
|
const db = readDatabase();
|
|
23911
24027
|
if (!db)
|
|
23912
24028
|
return { ok: false, error: "db unavailable" };
|
|
23913
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
24029
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-gjkszser.js"));
|
|
23914
24030
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
23915
24031
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
23916
24032
|
const ctx = {
|
|
@@ -34067,6 +34183,21 @@ function verifyAssistantText(messages) {
|
|
|
34067
34183
|
const start = text.lastIndexOf("<verify>");
|
|
34068
34184
|
return start >= 0 ? text.slice(start) : text;
|
|
34069
34185
|
}
|
|
34186
|
+
function validateVerifyCompletion(messages, text, expectedIds, responseText = text) {
|
|
34187
|
+
let parsed;
|
|
34188
|
+
try {
|
|
34189
|
+
parsed = validateVerifyManifest(text, expectedIds);
|
|
34190
|
+
} catch (error) {
|
|
34191
|
+
throw providerOutputFailureFromInvalidManifest(messages, responseText) ?? error;
|
|
34192
|
+
}
|
|
34193
|
+
const ids = [...parsed.verified, ...parsed.updated, ...parsed.archived, ...parsed.skipped].map((entry) => entry.id);
|
|
34194
|
+
if (ids.length !== expectedIds.size || ids.some((id) => !expectedIds.has(id))) {
|
|
34195
|
+
const providerFailure = providerOutputFailureFromInvalidManifest(messages, responseText);
|
|
34196
|
+
if (providerFailure)
|
|
34197
|
+
throw providerFailure;
|
|
34198
|
+
}
|
|
34199
|
+
return parsed;
|
|
34200
|
+
}
|
|
34070
34201
|
var IDENTICAL_PROVIDER_FAILURE_BATCH_LIMIT = 2;
|
|
34071
34202
|
var VERIFY_BATCH_FLOOR_MS = 30000;
|
|
34072
34203
|
function computeVerifyBatchSliceMs(remainingMs, _batchesRemaining) {
|
|
@@ -34225,6 +34356,7 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
34225
34356
|
const timer = setTimeout(() => batchController.abort(new Error(`verify slice timed out after ${sliceMs}ms`)), sliceMs);
|
|
34226
34357
|
const batchSignal = batchController.signal;
|
|
34227
34358
|
const tokenBudget = verifyBatchTokenBudget(batch.length, args.tokenBudget);
|
|
34359
|
+
const expectedIds = new Set(batch.map((memory) => memory.id));
|
|
34228
34360
|
let agentSessionId = null;
|
|
34229
34361
|
let hiddenSessionId = null;
|
|
34230
34362
|
let promptSettled = false;
|
|
@@ -34277,13 +34409,10 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
34277
34409
|
onBudgetUpdate({ spent: 0, finalizeFired: false, sessionId });
|
|
34278
34410
|
},
|
|
34279
34411
|
parse: (text, completion) => {
|
|
34280
|
-
const providerFailure = providerOutputFailureFromInvalidManifest(completion.messages ?? [], text);
|
|
34281
|
-
if (providerFailure)
|
|
34282
|
-
throw providerFailure;
|
|
34283
34412
|
const manifest = verifyAssistantText(completion.messages ?? []) ?? (text.trim() ? text : null);
|
|
34284
34413
|
if (!manifest)
|
|
34285
34414
|
throw new Error("verify returned no output");
|
|
34286
|
-
return
|
|
34415
|
+
return validateVerifyCompletion(completion.messages ?? [], manifest, expectedIds, text);
|
|
34287
34416
|
}
|
|
34288
34417
|
});
|
|
34289
34418
|
recordInvocation4(args, startedAt, {
|
|
@@ -34345,10 +34474,7 @@ async function verifyOneBatch(args, batch, sliceMs, signal) {
|
|
|
34345
34474
|
const text = verifyAssistantText(messages);
|
|
34346
34475
|
if (!text)
|
|
34347
34476
|
throw new Error("verify returned no output");
|
|
34348
|
-
|
|
34349
|
-
if (providerFailure)
|
|
34350
|
-
throw providerFailure;
|
|
34351
|
-
return validateVerifyManifest(text, new Set(batch.map((memory) => memory.id)));
|
|
34477
|
+
return validateVerifyCompletion(messages, text, expectedIds);
|
|
34352
34478
|
}
|
|
34353
34479
|
});
|
|
34354
34480
|
promptSettled = true;
|
|
@@ -36892,12 +37018,6 @@ async function runMessageHistoryMaintenance(db) {
|
|
|
36892
37018
|
log2(`[message-index] pending Rust session cleanup: cleared=${rustCleanup.cleared} failed=${rustCleanup.failedSessionIds.length}`);
|
|
36893
37019
|
}
|
|
36894
37020
|
}
|
|
36895
|
-
const sweep = await sweepOrphanedOpenCodeMessageIndexesOffThread(db, openOpenCodeDb);
|
|
36896
|
-
if (sweep.reason)
|
|
36897
|
-
log2(`[message-index] orphan sweep parked: ${sweep.reason}`);
|
|
36898
|
-
if (sweep.deleted > 0) {
|
|
36899
|
-
log2(`[message-index] orphan sweep: scanned=${sweep.scanned} deleted=${sweep.deleted} cursor=${sweep.cursor || "<complete>"}`);
|
|
36900
|
-
}
|
|
36901
37021
|
}
|
|
36902
37022
|
function startupJitterMs(directory) {
|
|
36903
37023
|
const existing = startupJitters.get(directory);
|
|
@@ -51803,7 +51923,7 @@ function singleLine(value) {
|
|
|
51803
51923
|
// src/tools/ctx-note/tools.ts
|
|
51804
51924
|
function captureAnchorOrdinal(db, sessionId) {
|
|
51805
51925
|
try {
|
|
51806
|
-
const ordinal =
|
|
51926
|
+
const ordinal = getLastIndexedOrdinal(db, sessionId);
|
|
51807
51927
|
return ordinal > 0 ? ordinal : null;
|
|
51808
51928
|
} catch {
|
|
51809
51929
|
return null;
|
|
@@ -52200,23 +52320,26 @@ function createCtxReduceTool(deps) {
|
|
|
52200
52320
|
dropIds = dropIds.filter((id) => !ctxReduceSelfStampIds.has(id));
|
|
52201
52321
|
const tagStatusMap = new Map(allTags.map((tag) => [tag.tagNumber, tag.status]));
|
|
52202
52322
|
const inertWhitespaceTagNumbers = new Set(getInertWhitespaceAssistantTagsByNumbers2(deps.db, sessionId, dropIds).map((tag) => tag.tagNumber));
|
|
52203
|
-
const
|
|
52204
|
-
|
|
52205
|
-
|
|
52206
|
-
|
|
52323
|
+
const foreignTextTagNumbers = new Set(dropIds.filter((id) => isLegacyForeignTextTag(sessionId, id)));
|
|
52324
|
+
const skippedTagNumbers = new Set([
|
|
52325
|
+
...inertWhitespaceTagNumbers,
|
|
52326
|
+
...foreignTextTagNumbers
|
|
52327
|
+
]);
|
|
52328
|
+
const skippedDropIds = [...new Set(dropIds.filter((id) => skippedTagNumbers.has(id)))];
|
|
52329
|
+
const inertNote = skippedDropIds.length > 0 ? `Skipped: ${skippedDropIds.map((id) => inertWhitespaceTagNumbers.has(id) ? `§${id}§ is provider framing, nothing to reclaim` : `§${id}§ is another plugin's text, nothing to reclaim`).join("; ")}.` : "";
|
|
52207
52330
|
const pendingOps = getPendingOps(deps.db, sessionId);
|
|
52208
52331
|
const pendingMap = new Map(pendingOps.map((op) => [op.tagId, op.operation]));
|
|
52209
52332
|
const conflicts = [];
|
|
52210
52333
|
for (const id of dropIds) {
|
|
52211
|
-
if (tagStatusMap.get(id) === "compacted" && !
|
|
52334
|
+
if (tagStatusMap.get(id) === "compacted" && !skippedTagNumbers.has(id)) {
|
|
52212
52335
|
conflicts.push(`§${id}§ is from before compaction`);
|
|
52213
52336
|
}
|
|
52214
52337
|
}
|
|
52215
52338
|
if (conflicts.length > 0) {
|
|
52216
52339
|
return `Error: Conflicting operations — ${conflicts.join("; ")}.`;
|
|
52217
52340
|
}
|
|
52218
|
-
const stampedCount = new Set(dropIds.filter((id) => !
|
|
52219
|
-
dropIds = dropIds.filter((id) => !
|
|
52341
|
+
const stampedCount = new Set(dropIds.filter((id) => !skippedTagNumbers.has(id))).size;
|
|
52342
|
+
dropIds = dropIds.filter((id) => !skippedTagNumbers.has(id) && tagStatusMap.get(id) !== "dropped" && pendingMap.get(id) !== "drop");
|
|
52220
52343
|
if (dropIds.length === 0) {
|
|
52221
52344
|
const reply = formatCtxReduceReply(stampedCount, ctxReduceSelfStampCount);
|
|
52222
52345
|
if (reply)
|
|
@@ -53709,6 +53832,88 @@ async function registerContext(context) {
|
|
|
53709
53832
|
...args.messages.filter((message) => message !== args.incoming)
|
|
53710
53833
|
];
|
|
53711
53834
|
};
|
|
53835
|
+
const initializeTransform = (database) => transform ??= createTransform({
|
|
53836
|
+
...createV2TransformFeatureDeps(config, compactionOff, directory, embeddings.ensureRegistered),
|
|
53837
|
+
cacheTtlConfig: config.cache_ttl,
|
|
53838
|
+
cacheTtlConfigured: config.cacheTtlConfigured,
|
|
53839
|
+
sampleCacheTtlConfig: () => liveConfigReader.poll().effective,
|
|
53840
|
+
db: database,
|
|
53841
|
+
tagger,
|
|
53842
|
+
...createV2ThresholdDeps(config),
|
|
53843
|
+
contextUsageMap: usage,
|
|
53844
|
+
compactionOff,
|
|
53845
|
+
storeGeneration: "v2",
|
|
53846
|
+
normalizeRestoredAssistantText: (text, providerID) => stripCopiedTagNotation(text, providerID === "anthropic"),
|
|
53847
|
+
refreshSourceContents: (sessionID) => nativeFoldReplay?.needsHeadRebuild(sessionID) ?? false,
|
|
53848
|
+
hostCleanupCompactionMarkers: () => ({
|
|
53849
|
+
verified: true,
|
|
53850
|
+
removedLineages: 0,
|
|
53851
|
+
removedRows: 0,
|
|
53852
|
+
retainedLineages: 0
|
|
53853
|
+
}),
|
|
53854
|
+
protectedTokens: config.protected_tokens,
|
|
53855
|
+
protectedTokenTierOverrides: getProtectedTokensTierOverrides(config),
|
|
53856
|
+
liveModelBySession: liveModels,
|
|
53857
|
+
getToolSetHash: (sessionId) => {
|
|
53858
|
+
const model = liveModels.get(sessionId);
|
|
53859
|
+
if (!model)
|
|
53860
|
+
return "";
|
|
53861
|
+
return getCurrentToolSetHash(model.providerID, model.modelID, agents.get(sessionId), sessionId);
|
|
53862
|
+
},
|
|
53863
|
+
channel1StateBySession: channel1,
|
|
53864
|
+
historyRefreshSessions,
|
|
53865
|
+
pendingMaterializationSessions,
|
|
53866
|
+
lastHeuristicsTurnId,
|
|
53867
|
+
commitSeenLastPass,
|
|
53868
|
+
variantBySession: variants,
|
|
53869
|
+
keepReasoningTokens: config.keep_reasoning_tokens,
|
|
53870
|
+
directory,
|
|
53871
|
+
sessionDirectoryBySession: sessionDirectories,
|
|
53872
|
+
projectPath: resolveProjectIdentityForSession(directory, config.allow_home_project),
|
|
53873
|
+
getHistorianChunkTokens: () => sampleHistorian().chunkTokens,
|
|
53874
|
+
getFallbackModelId: (sessionID) => {
|
|
53875
|
+
const model = liveModels.get(sessionID);
|
|
53876
|
+
return model ? `${model.providerID}/${model.modelID}` : undefined;
|
|
53877
|
+
},
|
|
53878
|
+
maybeAutoEmbedSession: createV2AutoEmbedSession({
|
|
53879
|
+
db: database,
|
|
53880
|
+
resolveDirectory: (sessionID) => sessionDirectories.get(sessionID) ?? directory,
|
|
53881
|
+
allowHomeProject: config.allow_home_project,
|
|
53882
|
+
recompProgressBySession: new Map
|
|
53883
|
+
}, embeddings.ensureRegistered),
|
|
53884
|
+
hiddenCompletionExecutor,
|
|
53885
|
+
historianRunnable: !compactionOff && hiddenCompletionExecutor !== undefined && config.historian?.disable !== true,
|
|
53886
|
+
historianModel: historianModels.primary,
|
|
53887
|
+
historianContextLimit: sampleHistorian().contextLimit,
|
|
53888
|
+
fallbackModels: historianModels.fallbacks,
|
|
53889
|
+
resolveHistorianRun: sampleHistorian,
|
|
53890
|
+
historianTimeoutMs: config.historian_timeout_ms,
|
|
53891
|
+
historianMaxOutputTokens: config.historian?.maxTokens,
|
|
53892
|
+
historianTwoPass: config.historian?.two_pass,
|
|
53893
|
+
historianExpandTools: config.historian?.expand_tools,
|
|
53894
|
+
historianRunner: config.historian?.runner,
|
|
53895
|
+
historianHostRunnerEnabled: config.historian?.host_runner?.enabled,
|
|
53896
|
+
compactionMarkerStrategy: rustModeModuleClient ? createV2RustCompactionMarkerStrategy((sessionID, endMessageID) => {
|
|
53897
|
+
const reader = openStoreReader();
|
|
53898
|
+
try {
|
|
53899
|
+
return resolveV2BoundaryUserMessage(reader, sessionID, endMessageID);
|
|
53900
|
+
} finally {
|
|
53901
|
+
reader.close();
|
|
53902
|
+
}
|
|
53903
|
+
}) : v2CompactionMarkerStrategy,
|
|
53904
|
+
transformMode: config.transform_mode,
|
|
53905
|
+
rustModeModuleClient,
|
|
53906
|
+
rustModeProjectRoot: directory,
|
|
53907
|
+
rustMemorySyncRequestedSessions,
|
|
53908
|
+
onRustModeParked: (sessionId, message) => pushNotification2("toast", {
|
|
53909
|
+
message: `Rust Magic Context paused: ${message}`,
|
|
53910
|
+
variant: "warning"
|
|
53911
|
+
}, sessionId),
|
|
53912
|
+
promptSurface: config.prompt_surface,
|
|
53913
|
+
promptSurfaceRuntime,
|
|
53914
|
+
onRustEngineReconnectRefusal: (refusal) => rustRefusalRecovery?.arm(refusal),
|
|
53915
|
+
...createHostSeams(context, readAllForConversion, pagedRead, liveModels)
|
|
53916
|
+
});
|
|
53712
53917
|
const runManagedContext = async (draft) => {
|
|
53713
53918
|
rememberHostMedia(draft.messages);
|
|
53714
53919
|
if (hiddenChildHook.apply(draft))
|
|
@@ -53974,88 +54179,7 @@ async function registerContext(context) {
|
|
|
53974
54179
|
});
|
|
53975
54180
|
await cacheV2SessionDirectory(context.session, draft.sessionID, sessionDirectories);
|
|
53976
54181
|
prepareHistorySession(draft.sessionID);
|
|
53977
|
-
transform
|
|
53978
|
-
...createV2TransformFeatureDeps(config, compactionOff, directory, embeddings.ensureRegistered),
|
|
53979
|
-
cacheTtlConfig: config.cache_ttl,
|
|
53980
|
-
cacheTtlConfigured: config.cacheTtlConfigured,
|
|
53981
|
-
sampleCacheTtlConfig: () => liveConfigReader.poll().effective,
|
|
53982
|
-
db,
|
|
53983
|
-
tagger,
|
|
53984
|
-
...createV2ThresholdDeps(config),
|
|
53985
|
-
contextUsageMap: usage,
|
|
53986
|
-
compactionOff,
|
|
53987
|
-
storeGeneration: "v2",
|
|
53988
|
-
normalizeRestoredAssistantText: (text, providerID) => stripCopiedTagNotation(text, providerID === "anthropic"),
|
|
53989
|
-
refreshSourceContents: (sessionID) => nativeFoldReplay?.needsHeadRebuild(sessionID) ?? false,
|
|
53990
|
-
hostCleanupCompactionMarkers: () => ({
|
|
53991
|
-
verified: true,
|
|
53992
|
-
removedLineages: 0,
|
|
53993
|
-
removedRows: 0,
|
|
53994
|
-
retainedLineages: 0
|
|
53995
|
-
}),
|
|
53996
|
-
protectedTokens: config.protected_tokens,
|
|
53997
|
-
protectedTokenTierOverrides: getProtectedTokensTierOverrides(config),
|
|
53998
|
-
liveModelBySession: liveModels,
|
|
53999
|
-
getToolSetHash: (sessionId) => {
|
|
54000
|
-
const model = liveModels.get(sessionId);
|
|
54001
|
-
if (!model)
|
|
54002
|
-
return "";
|
|
54003
|
-
return getCurrentToolSetHash(model.providerID, model.modelID, agents.get(sessionId), sessionId);
|
|
54004
|
-
},
|
|
54005
|
-
channel1StateBySession: channel1,
|
|
54006
|
-
historyRefreshSessions,
|
|
54007
|
-
pendingMaterializationSessions,
|
|
54008
|
-
lastHeuristicsTurnId,
|
|
54009
|
-
commitSeenLastPass,
|
|
54010
|
-
variantBySession: variants,
|
|
54011
|
-
keepReasoningTokens: config.keep_reasoning_tokens,
|
|
54012
|
-
directory,
|
|
54013
|
-
sessionDirectoryBySession: sessionDirectories,
|
|
54014
|
-
projectPath: resolveProjectIdentityForSession(directory, config.allow_home_project),
|
|
54015
|
-
getHistorianChunkTokens: () => sampleHistorian().chunkTokens,
|
|
54016
|
-
getFallbackModelId: (sessionID) => {
|
|
54017
|
-
const model = liveModels.get(sessionID);
|
|
54018
|
-
return model ? `${model.providerID}/${model.modelID}` : undefined;
|
|
54019
|
-
},
|
|
54020
|
-
maybeAutoEmbedSession: createV2AutoEmbedSession({
|
|
54021
|
-
db,
|
|
54022
|
-
resolveDirectory: (sessionID) => sessionDirectories.get(sessionID) ?? directory,
|
|
54023
|
-
allowHomeProject: config.allow_home_project,
|
|
54024
|
-
recompProgressBySession: new Map
|
|
54025
|
-
}, embeddings.ensureRegistered),
|
|
54026
|
-
hiddenCompletionExecutor,
|
|
54027
|
-
historianRunnable: !compactionOff && hiddenCompletionExecutor !== undefined && config.historian?.disable !== true,
|
|
54028
|
-
historianModel: historianModels.primary,
|
|
54029
|
-
historianContextLimit: sampleHistorian().contextLimit,
|
|
54030
|
-
fallbackModels: historianModels.fallbacks,
|
|
54031
|
-
resolveHistorianRun: sampleHistorian,
|
|
54032
|
-
historianTimeoutMs: config.historian_timeout_ms,
|
|
54033
|
-
historianMaxOutputTokens: config.historian?.maxTokens,
|
|
54034
|
-
historianTwoPass: config.historian?.two_pass,
|
|
54035
|
-
historianExpandTools: config.historian?.expand_tools,
|
|
54036
|
-
historianRunner: config.historian?.runner,
|
|
54037
|
-
historianHostRunnerEnabled: config.historian?.host_runner?.enabled,
|
|
54038
|
-
compactionMarkerStrategy: rustModeModuleClient ? createV2RustCompactionMarkerStrategy((sessionID, endMessageID) => {
|
|
54039
|
-
const reader = openStoreReader();
|
|
54040
|
-
try {
|
|
54041
|
-
return resolveV2BoundaryUserMessage(reader, sessionID, endMessageID);
|
|
54042
|
-
} finally {
|
|
54043
|
-
reader.close();
|
|
54044
|
-
}
|
|
54045
|
-
}) : v2CompactionMarkerStrategy,
|
|
54046
|
-
transformMode: config.transform_mode,
|
|
54047
|
-
rustModeModuleClient,
|
|
54048
|
-
rustModeProjectRoot: directory,
|
|
54049
|
-
rustMemorySyncRequestedSessions,
|
|
54050
|
-
onRustModeParked: (sessionId, message) => pushNotification2("toast", {
|
|
54051
|
-
message: `Rust Magic Context paused: ${message}`,
|
|
54052
|
-
variant: "warning"
|
|
54053
|
-
}, sessionId),
|
|
54054
|
-
promptSurface: config.prompt_surface,
|
|
54055
|
-
promptSurfaceRuntime,
|
|
54056
|
-
onRustEngineReconnectRefusal: (refusal) => rustRefusalRecovery?.arm(refusal),
|
|
54057
|
-
...createHostSeams(context, readAllForConversion, pagedRead, liveModels)
|
|
54058
|
-
});
|
|
54182
|
+
transform = initializeTransform(db);
|
|
54059
54183
|
const admitted = new Set;
|
|
54060
54184
|
let messageTimes;
|
|
54061
54185
|
const reader = openStoreReader();
|