@cortexkit/opencode-magic-context 0.49.15 → 0.49.17
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 +76 -63
- package/dist/chunk-embedding-write-worker.js +12 -10
- package/dist/{compaction-marker-candidates-v5c6997n.js → compaction-marker-candidates-n4krhat4.js} +2 -2
- package/dist/compaction-marker-candidates-worker.js +2 -2
- package/dist/config/schema/magic-context.d.ts +343 -343
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-mgq17yr3.js → conflict-warning-hook-4pmz879v.js} +6 -6
- package/dist/{context-0m46day0.js → context-yhetp0kn.js} +297 -141
- package/dist/embedding-backfill-fmz50tsy.js +24 -0
- package/dist/embedding-worker-process.js +1 -1
- package/dist/embedding-worker.js +5 -5
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +1 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity-cache.d.ts +2 -0
- package/dist/features/magic-context/memory/project-identity-cache.d.ts.map +1 -1
- package/dist/features/magic-context/message-fts-rowid-map.d.ts +2 -2
- package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -1
- package/dist/features/magic-context/message-fts-session-filter.d.ts +2 -0
- package/dist/features/magic-context/message-fts-session-filter.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +1 -1
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +5 -0
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/message-time-backfill.d.ts +2 -2
- package/dist/features/magic-context/message-time-backfill.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +6 -1
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-shared.d.ts +2 -2
- package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts +9 -1
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-deadline.d.ts +2 -1
- package/dist/hooks/magic-context/auto-search-deadline.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-hint.d.ts +3 -0
- package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts +10 -2
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +4 -2
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts +2 -1
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +26 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +3 -3
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-diagnostics.d.ts +8 -0
- package/dist/hooks/magic-context/system-prompt-diagnostics.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +6 -1
- 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/tool-drop-target.d.ts +3 -2
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-stage-logger.d.ts +3 -0
- package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +1 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-3kdm78zp.js → index-24fezq97.js} +4 -4
- package/dist/{index-a8bvhwqs.js → index-2vxtcb95.js} +32 -3
- package/dist/{index-f71thw8j.js → index-4s3t0nd0.js} +1 -1
- package/dist/{index-ts1hjk1h.js → index-4yt7dtf4.js} +453 -227
- package/dist/{index-mc1cqza6.js → index-5a1ex6x8.js} +5 -5
- package/dist/{index-fkx2qnvw.js → index-6x57ar45.js} +2 -2
- package/dist/{index-dyvbsvga.js → index-a6mc0v4d.js} +25 -11
- package/dist/{index-snp5wbge.js → index-a7c4r5re.js} +160 -749
- package/dist/{index-42vcjcwe.js → index-aabzay3h.js} +180 -103
- package/dist/{index-3kx0kg0f.js → index-b5vqckbw.js} +14 -8
- package/dist/{v2/server-wafzvyhg.js → index-beht37jy.js} +8 -0
- package/dist/{index-e20m7284.js → index-bjcnntmz.js} +3 -3
- package/dist/{index-hqkczed7.js → index-c5pytzne.js} +22 -2
- package/dist/{index-thvnpfsv.js → index-cwzfcbtq.js} +967 -88
- package/dist/{index-yxycg7fs.js → index-fb2qxs2y.js} +26 -18
- package/dist/{index-mht7bq0z.js → index-hqhm3wke.js} +32 -8
- package/dist/{index-e4dsjj1p.js → index-jn12fvvh.js} +1 -1
- package/dist/index-kaqs6h31.js +58 -0
- package/dist/{index-n6m03s3n.js → index-ke416mdc.js} +1 -1
- package/dist/index-kmdj7dsq.js +96 -0
- package/dist/{index-1d289pq2.js → index-kq82mtg0.js} +2 -2
- package/dist/{index-n78avt2p.js → index-n37sebck.js} +1 -1
- package/dist/{index-1vc7jrkg.js → index-nkpmm9q8.js} +3 -3
- package/dist/{index-944w16m0.js → index-p7m7j0cp.js} +25 -17
- package/dist/{index-wk0n1cgt.js → index-qn7xstt2.js} +2 -2
- package/dist/{index-saews2s3.js → index-rr2bb45z.js} +1 -1
- package/dist/{index-mmfa86mt.js → index-s734jcsr.js} +169 -149
- package/dist/{index-dgs16axy.js → index-s74zqahq.js} +1 -1
- package/dist/{index-bxdg2nbt.js → index-v8awdgvd.js} +4 -4
- package/dist/{index-xn6q9pg6.js → index-vrzjhftj.js} +36 -76
- package/dist/{index-1sarmj9z.js → index-wgypt3cs.js} +6 -6
- package/dist/{index-y1qysm3q.js → index-ze7mvk54.js} +11 -8
- package/dist/index.js +47 -45
- package/dist/message-fts-rowid-map-17s0dfn4.js +25 -0
- package/dist/{message-index-bounded-vtgpq6b4.js → message-index-bounded-1633vc7f.js} +17 -17
- package/dist/{message-index-a6gztaqx.js → message-index-dprebmtt.js} +15 -15
- package/dist/{message-time-backfill-qjge9044.js → message-time-backfill-73mmm76q.js} +5 -5
- package/dist/migration-worker.js +9 -7
- package/dist/plugin/dream-timer.d.ts +11 -0
- 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-x45bv3qr.js → project-embedding-registry-z74mhqkf.js} +12 -10
- package/dist/raw-ordinal-warmup-worker.js +40 -10
- package/dist/{read-session-chunk-3ae3nfdn.js → read-session-chunk-4zp09ejb.js} +9 -9
- package/dist/{read-session-raw-m56hc7v2.js → read-session-raw-rsc8c7qy.js} +2 -2
- package/dist/{recomp-orchestrator-nwzcfhx4.js → recomp-orchestrator-z3ecszx6.js} +26 -26
- package/dist/{search-deajrd90.js → search-6mee3vty.js} +23 -22
- package/dist/search-archive-znyy44ve.js +25 -0
- package/dist/{send-session-notification-24r4esbh.js → send-session-notification-6ve0e8p4.js} +5 -5
- package/dist/shared/historian-cache.d.ts +8 -0
- package/dist/shared/historian-cache.d.ts.map +1 -0
- package/dist/shared/model-suggestion-retry.d.ts +4 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/resolve-fallbacks.d.ts +3 -3
- package/dist/shared/rpc-discovery-cleanup.d.ts +3 -0
- package/dist/shared/rpc-discovery-cleanup.d.ts.map +1 -0
- package/dist/shared/rpc-server.d.ts +2 -0
- package/dist/shared/rpc-server.d.ts.map +1 -1
- package/dist/shared/search-text.d.ts +8 -0
- package/dist/shared/search-text.d.ts.map +1 -0
- package/dist/shared/sqlite.d.ts +4 -2
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/storage-file-mutex.d.ts.map +1 -1
- package/dist/shared/subagent-runner.d.ts +2 -0
- package/dist/shared/subagent-runner.d.ts.map +1 -1
- package/dist/shared/system-directive.d.ts +2 -0
- package/dist/shared/system-directive.d.ts.map +1 -1
- package/dist/{sqlite-4pqyynrs.js → sqlite-zf72c52d.js} +1 -1
- package/dist/{storage-memory-j3v3hc83.js → storage-memory-y3qmy00r.js} +2 -2
- package/dist/{storage-tags-s5bg1ahx.js → storage-tags-8qns3012.js} +8 -4
- package/dist/tools/ctx-expand/search-archive.d.ts +5 -1
- package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-ne3z1zmt.js → transform-postprocess-phase-3ydzxa62.js} +26 -26
- package/dist/v2/auto-search-worker.js +76 -63
- package/dist/v2/chunk-embedding-write-worker.js +12 -10
- package/dist/v2/{compaction-marker-candidates-1vqwr3s5.js → compaction-marker-candidates-ebx3388k.js} +2 -2
- package/dist/v2/compaction-marker-candidates-worker.js +2 -2
- package/dist/v2/{context-4qczzck7.js → context-jn3zpeqh.js} +909 -454
- package/dist/v2/embedding-backfill-7c7yr69y.js +23 -0
- package/dist/v2/embedding-worker-process.js +1 -1
- package/dist/v2/embedding-worker.js +5 -5
- package/dist/v2/fold/native-replay.d.ts +11 -2
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/fold/policy.d.ts.map +1 -1
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +8 -0
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/types.d.ts +17 -0
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/message-fts-rowid-map-wfx67gfd.js +24 -0
- package/dist/v2/{message-index-bounded-rxxznd34.js → message-index-bounded-hpejqyd8.js} +17 -17
- package/dist/v2/{message-index-f947qtbz.js → message-index-pxehjpzx.js} +15 -15
- package/dist/v2/{message-time-backfill-bsteyc4d.js → message-time-backfill-04t0km1z.js} +5 -5
- package/dist/v2/migration-worker.js +9 -7
- package/dist/v2/{project-embedding-registry-0msp56p8.js → project-embedding-registry-gnkj56xp.js} +12 -10
- package/dist/v2/raw-ordinal-warmup-worker.js +40 -10
- package/dist/v2/{read-session-chunk-rq9nx1nn.js → read-session-chunk-zdppn4bj.js} +9 -9
- package/dist/v2/{read-session-raw-b3tf6ra1.js → read-session-raw-yaegtjzh.js} +2 -2
- package/dist/v2/{recomp-orchestrator-5zhxtwha.js → recomp-orchestrator-cmqnfpp3.js} +26 -26
- package/dist/v2/{search-n8wqxb1j.js → search-66842dya.js} +23 -22
- package/dist/v2/search-archive-gfh11vs0.js +24 -0
- package/dist/v2/{send-session-notification-8ghn9tnv.js → send-session-notification-3pxn658x.js} +5 -5
- package/dist/v2/{server-yrvqaswb.js → server-1wy7b9de.js} +25 -11
- package/dist/v2/{server-th4y11y7.js → server-271qxsf5.js} +6 -6
- package/dist/v2/{server-e298hswg.js → server-3rhpvy84.js} +967 -88
- package/dist/v2/{server-qhfvvfxj.js → server-46neh5fa.js} +14 -8
- package/dist/v2/{server-rrqpvwqd.js → server-6tmj0s7j.js} +2 -2
- package/dist/v2/{server-hek6z3w6.js → server-8by8qfec.js} +11 -8
- package/dist/v2/{server-vbe4se57.js → server-a9xqj88f.js} +1 -1
- package/dist/{index-wafzvyhg.js → v2/server-beht37jy.js} +8 -0
- package/dist/v2/{server-05xjtq6c.js → server-d04vrx0j.js} +1 -1
- package/dist/v2/server-ec4ca92p.js +96 -0
- package/dist/v2/{server-dd0tz6cn.js → server-fw7wrk01.js} +160 -750
- package/dist/v2/{server-zs8d0s3b.js → server-g3qma5c0.js} +1 -1
- package/dist/v2/{server-k2bzedxk.js → server-gpvay0xz.js} +2 -2
- package/dist/v2/{server-kmbarfmn.js → server-gtfhttbr.js} +26 -18
- package/dist/v2/{server-g10mdym6.js → server-h1v0pyxb.js} +3 -3
- package/dist/v2/{server-4gn3z5an.js → server-hy3d3vsx.js} +1 -1
- package/dist/v2/server-kaqs6h31.js +58 -0
- package/dist/v2/{server-ehyava47.js → server-kh7dpa1a.js} +25 -17
- package/dist/v2/{server-6cdy4rc0.js → server-my7k4eds.js} +4 -4
- package/dist/v2/{server-d8tj10db.js → server-n1prf1g6.js} +1 -1
- package/dist/v2/{server-n78avt2p.js → server-n37sebck.js} +1 -1
- package/dist/v2/{server-zc3e54vy.js → server-nj659894.js} +6 -6
- package/dist/v2/{server-gvkm8xaj.js → server-rmygf5pn.js} +32 -3
- package/dist/v2/{server-0ppsweh6.js → server-tgnbmwah.js} +22 -2
- package/dist/v2/{server-cfbr1s2x.js → server-vsw8tmm6.js} +36 -76
- package/dist/v2/{server-prg55b7k.js → server-xj136kt8.js} +23 -3
- package/dist/v2/{server-atbc19ab.js → server-zyzawhdw.js} +32 -8
- package/dist/v2/{server-ef89gdsx.js → server-zzkj2fch.js} +4 -4
- package/dist/v2/server.js +5 -5
- package/dist/v2/{sqlite-4pqyynrs.js → sqlite-zf72c52d.js} +1 -1
- package/dist/v2/{storage-memory-j3v3hc83.js → storage-memory-y3qmy00r.js} +2 -2
- package/dist/v2/{storage-tags-hcc2adpf.js → storage-tags-1h8k6ra9.js} +8 -4
- package/dist/v2/store-reader.d.ts +2 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{wrapup-orchestrator-65pwye0d.js → wrapup-orchestrator-xs8redz9.js} +26 -26
- package/dist/wrapup-orchestrator-j7d7ry5b.js +48 -0
- package/package.json +1 -1
- package/src/config/latch-permanence-guard.test.ts +4 -0
- package/src/config/schema/magic-context.ts +14 -6
- package/src/shared/historian-cache.test.ts +69 -0
- package/src/shared/historian-cache.ts +55 -0
- package/src/shared/model-resolution.test.ts +22 -0
- package/src/shared/model-suggestion-retry.ts +11 -3
- package/src/shared/resolve-fallbacks.test.ts +2 -3
- package/src/shared/resolve-fallbacks.ts +3 -3
- package/src/shared/rpc-discovery-cleanup.test.ts +57 -0
- package/src/shared/rpc-discovery-cleanup.ts +57 -0
- package/src/shared/rpc-server.ts +36 -13
- package/src/shared/search-text.test.ts +47 -0
- package/src/shared/search-text.ts +63 -0
- package/src/shared/sqlite.test.ts +56 -0
- package/src/shared/sqlite.ts +51 -2
- package/src/shared/storage-file-mutex-review.test.ts +22 -2
- package/src/shared/storage-file-mutex.ts +11 -1
- package/src/shared/subagent-runner.ts +2 -0
- package/src/shared/system-directive.ts +19 -1
- package/src/shared/tag-transcript.ts +12 -4
- package/dist/embedding-backfill-5e1t5wha.js +0 -22
- package/dist/v2/embedding-backfill-jmaf8zrr.js +0 -21
- package/dist/wrapup-orchestrator-28xzsj5q.js +0 -48
|
@@ -34,10 +34,12 @@ import {
|
|
|
34
34
|
getPendingOps,
|
|
35
35
|
getPendingOpsCount,
|
|
36
36
|
removePendingOp,
|
|
37
|
+
updateTagByteSize2,
|
|
37
38
|
getRecentTagOwnerMessageIds2,
|
|
38
39
|
AGE_RECLAIM_MIN_TOKENS2,
|
|
39
40
|
getOldestActiveUnprotectedToolTags2,
|
|
40
41
|
getActiveToolTagsForAgeReclaim2,
|
|
42
|
+
updateTagTokenCount2,
|
|
41
43
|
tryGetReasoningTokenEstimatesByMessage2,
|
|
42
44
|
cachedTagOwnerRatios2,
|
|
43
45
|
tagOwnerWarmupState2,
|
|
@@ -71,12 +73,12 @@ import {
|
|
|
71
73
|
adoptNullOwnerToolTag2,
|
|
72
74
|
getCandidateToolOwners2,
|
|
73
75
|
pickNearestPriorOwner2
|
|
74
|
-
} from "./index-
|
|
76
|
+
} from "./index-hqhm3wke.js";
|
|
75
77
|
import {
|
|
76
78
|
textMentionsRecentCommit,
|
|
77
79
|
hasMeaningfulUserText2,
|
|
78
80
|
estimateTokens
|
|
79
|
-
} from "./index-
|
|
81
|
+
} from "./index-c5pytzne.js";
|
|
80
82
|
import {
|
|
81
83
|
log2,
|
|
82
84
|
sessionLog2
|
|
@@ -87,18 +89,56 @@ import {
|
|
|
87
89
|
getSqliteDatabasePath2,
|
|
88
90
|
assertTransformWrite2,
|
|
89
91
|
isTransientSqliteError2
|
|
90
|
-
} from "./index-
|
|
91
|
-
import {
|
|
92
|
-
isValidLanguageCode
|
|
93
|
-
} from "./index-1sarmj9z.js";
|
|
92
|
+
} from "./index-beht37jy.js";
|
|
94
93
|
import {
|
|
95
94
|
getProjectEmbeddingSnapshot2,
|
|
96
95
|
embedTextForProject2,
|
|
97
96
|
embedBatchForProject2
|
|
98
|
-
} from "./index-
|
|
97
|
+
} from "./index-ze7mvk54.js";
|
|
99
98
|
import {
|
|
100
|
-
|
|
101
|
-
} from "./index-
|
|
99
|
+
runSessionWarmupWorker
|
|
100
|
+
} from "./index-s734jcsr.js";
|
|
101
|
+
import {
|
|
102
|
+
getMaxM0MutationId,
|
|
103
|
+
getLastCompartmentEndMessage,
|
|
104
|
+
rememberUnpublishedAutoSearchNoHint,
|
|
105
|
+
getUnpublishedAutoSearchNoHint,
|
|
106
|
+
forgetUnpublishedAutoSearchNoHint,
|
|
107
|
+
registerAutoSearchWork,
|
|
108
|
+
cancelAutoSearchWork,
|
|
109
|
+
updateSessionMeta,
|
|
110
|
+
advanceToolReclaimWatermark,
|
|
111
|
+
requestPendingMaterialization,
|
|
112
|
+
pendingMaterializationOrigin,
|
|
113
|
+
hasPendingMaterializationOrigin,
|
|
114
|
+
clearPendingMaterialization,
|
|
115
|
+
saveSourceContent,
|
|
116
|
+
replaceSourceContent,
|
|
117
|
+
getSourceContents,
|
|
118
|
+
compareOpenCodeMessagesByCanonicalOrder,
|
|
119
|
+
prepareCompactionMarkerCandidates,
|
|
120
|
+
MARKER_SUMMARY_TEXT,
|
|
121
|
+
applyDeferredCompactionMarker,
|
|
122
|
+
injectTemporalMarkers,
|
|
123
|
+
clearInjectionCache,
|
|
124
|
+
getVisibleMemoryIds,
|
|
125
|
+
renderCompartmentInjection,
|
|
126
|
+
MaterializeContentionError,
|
|
127
|
+
mustMaterialize,
|
|
128
|
+
hydrateCachedM0Mural,
|
|
129
|
+
prepareCachedM0M1Replay,
|
|
130
|
+
hasCompleteCachedM0M1,
|
|
131
|
+
injectM0M1,
|
|
132
|
+
observeNoteNudgeServe,
|
|
133
|
+
peekNoteNudgeText,
|
|
134
|
+
markNoteNudgeDelivered,
|
|
135
|
+
getActiveCompartmentRun
|
|
136
|
+
} from "./index-a7c4r5re.js";
|
|
137
|
+
import {
|
|
138
|
+
BoundedSessionMap,
|
|
139
|
+
cleanSearchText,
|
|
140
|
+
matchedSearchSnippet
|
|
141
|
+
} from "./index-cwzfcbtq.js";
|
|
102
142
|
import {
|
|
103
143
|
stripSystemInjection,
|
|
104
144
|
isTextPart,
|
|
@@ -193,56 +233,21 @@ import {
|
|
|
193
233
|
extractToolCallObservation,
|
|
194
234
|
ToolMutationBatch,
|
|
195
235
|
createToolDropTarget
|
|
196
|
-
} from "./index-
|
|
236
|
+
} from "./index-p7m7j0cp.js";
|
|
197
237
|
import {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
getUnpublishedAutoSearchNoHint,
|
|
201
|
-
forgetUnpublishedAutoSearchNoHint,
|
|
202
|
-
registerAutoSearchWork,
|
|
203
|
-
cancelAutoSearchWork,
|
|
204
|
-
updateSessionMeta,
|
|
205
|
-
advanceToolReclaimWatermark,
|
|
206
|
-
requestPendingMaterialization,
|
|
207
|
-
pendingMaterializationOrigin,
|
|
208
|
-
hasPendingMaterializationOrigin,
|
|
209
|
-
clearPendingMaterialization,
|
|
210
|
-
saveSourceContent,
|
|
211
|
-
replaceSourceContent,
|
|
212
|
-
getSourceContents,
|
|
213
|
-
compareOpenCodeMessagesByCanonicalOrder,
|
|
214
|
-
prepareCompactionMarkerCandidates,
|
|
215
|
-
MARKER_SUMMARY_TEXT,
|
|
216
|
-
applyDeferredCompactionMarker,
|
|
217
|
-
injectTemporalMarkers,
|
|
218
|
-
clearInjectionCache,
|
|
219
|
-
getVisibleMemoryIds,
|
|
220
|
-
renderCompartmentInjection,
|
|
221
|
-
MaterializeContentionError,
|
|
222
|
-
mustMaterialize,
|
|
223
|
-
hydrateCachedM0Mural,
|
|
224
|
-
prepareCachedM0M1Replay,
|
|
225
|
-
hasCompleteCachedM0M1,
|
|
226
|
-
injectM0M1,
|
|
227
|
-
observeNoteNudgeServe,
|
|
228
|
-
peekNoteNudgeText,
|
|
229
|
-
markNoteNudgeDelivered,
|
|
230
|
-
getActiveCompartmentRun
|
|
231
|
-
} from "./index-snp5wbge.js";
|
|
238
|
+
isValidLanguageCode
|
|
239
|
+
} from "./index-wgypt3cs.js";
|
|
232
240
|
import {
|
|
233
|
-
|
|
234
|
-
} from "./index-
|
|
241
|
+
isEmbeddingHostBusy2
|
|
242
|
+
} from "./index-qt1qqasc.js";
|
|
235
243
|
import {
|
|
236
244
|
openCodeDbExists,
|
|
237
245
|
withReadOnlySessionDb,
|
|
238
246
|
getMessageTimesFromOpenCodeDb
|
|
239
|
-
} from "./index-
|
|
240
|
-
import {
|
|
241
|
-
BoundedSessionMap
|
|
242
|
-
} from "./index-thvnpfsv.js";
|
|
247
|
+
} from "./index-kq82mtg0.js";
|
|
243
248
|
import {
|
|
244
249
|
userFacingFailureCode
|
|
245
|
-
} from "./index-
|
|
250
|
+
} from "./index-v8awdgvd.js";
|
|
246
251
|
import {
|
|
247
252
|
normalizeProtectedToolName,
|
|
248
253
|
mergeProtectedTools
|
|
@@ -620,7 +625,8 @@ function createTagger() {
|
|
|
620
625
|
}
|
|
621
626
|
|
|
622
627
|
// src/hooks/magic-context/auto-search-deadline.ts
|
|
623
|
-
var AUTO_SEARCH_TIMEOUT_MS =
|
|
628
|
+
var AUTO_SEARCH_TIMEOUT_MS = 1000;
|
|
629
|
+
var AUTO_SEARCH_VECTOR_TIMEOUT_MS = 200;
|
|
624
630
|
var operationDeadlines = new WeakMap;
|
|
625
631
|
function autoSearchDeadlineUnixMs(signal) {
|
|
626
632
|
const deadline = signal && operationDeadlines.get(signal);
|
|
@@ -1176,32 +1182,32 @@ function formatAge(committedAtMs) {
|
|
|
1176
1182
|
const years = Math.floor(days / 365);
|
|
1177
1183
|
return years === 1 ? "1y ago" : `${years}y ago`;
|
|
1178
1184
|
}
|
|
1179
|
-
function renderFragment(result, charCap, wordRules) {
|
|
1185
|
+
function renderFragment(result, charCap, wordRules, query) {
|
|
1180
1186
|
switch (result.source) {
|
|
1181
1187
|
case "memory": {
|
|
1182
|
-
const compressed = cavemanCompress(result.content, "ultra", CURRENT_CAVEMAN_RULES, wordRules);
|
|
1188
|
+
const compressed = cavemanCompress(cleanSearchText(result.content), "ultra", CURRENT_CAVEMAN_RULES, wordRules);
|
|
1183
1189
|
return truncate(compressed, charCap);
|
|
1184
1190
|
}
|
|
1185
1191
|
case "git_commit": {
|
|
1186
|
-
const subject = result.content.split(/\r?\n/)[0] ?? result.content;
|
|
1192
|
+
const subject = cleanSearchText(result.content.split(/\r?\n/)[0] ?? result.content);
|
|
1187
1193
|
const body = truncate(subject, Math.max(10, charCap - 20));
|
|
1188
1194
|
return `commit ${result.shortSha} ${formatAge(result.committedAtMs)}: ${body}`;
|
|
1189
1195
|
}
|
|
1190
1196
|
case "message": {
|
|
1191
|
-
const compressed = cavemanCompress(result.content, "ultra", CURRENT_CAVEMAN_RULES, wordRules);
|
|
1197
|
+
const compressed = cavemanCompress(query ? matchedSearchSnippet(result.content, query, charCap) : cleanSearchText(result.content), "ultra", CURRENT_CAVEMAN_RULES, wordRules);
|
|
1192
1198
|
return truncate(compressed, charCap);
|
|
1193
1199
|
}
|
|
1194
1200
|
case "compartment": {
|
|
1195
|
-
const source = result.
|
|
1201
|
+
const source = cleanSearchText(result.title);
|
|
1196
1202
|
const compressed = cavemanCompress(source, "ultra", CURRENT_CAVEMAN_RULES, wordRules);
|
|
1197
1203
|
return truncate(compressed, charCap);
|
|
1198
1204
|
}
|
|
1199
1205
|
case "primer": {
|
|
1200
|
-
const compressed = cavemanCompress(result.content, "ultra", CURRENT_CAVEMAN_RULES, wordRules);
|
|
1206
|
+
const compressed = cavemanCompress(cleanSearchText(result.content), "ultra", CURRENT_CAVEMAN_RULES, wordRules);
|
|
1201
1207
|
return truncate(compressed, charCap);
|
|
1202
1208
|
}
|
|
1203
1209
|
case "note": {
|
|
1204
|
-
const compressed = cavemanCompress(result.content, "ultra", CURRENT_CAVEMAN_RULES, wordRules);
|
|
1210
|
+
const compressed = cavemanCompress(cleanSearchText(result.content), "ultra", CURRENT_CAVEMAN_RULES, wordRules);
|
|
1205
1211
|
return truncate(compressed, charCap);
|
|
1206
1212
|
}
|
|
1207
1213
|
}
|
|
@@ -1212,7 +1218,7 @@ function buildAutoSearchHint(results, options = {}) {
|
|
|
1212
1218
|
const picks = results.slice(0, maxFragments);
|
|
1213
1219
|
const lines = [];
|
|
1214
1220
|
for (const result of picks) {
|
|
1215
|
-
const fragment = renderFragment(result, fragmentCharCap, options.wordRules ?? "english");
|
|
1221
|
+
const fragment = renderFragment(result, fragmentCharCap, options.wordRules ?? "english", options.query ?? "");
|
|
1216
1222
|
if (fragment.length === 0)
|
|
1217
1223
|
continue;
|
|
1218
1224
|
lines.push(`- ${fragment}`);
|
|
@@ -1235,6 +1241,9 @@ ${trimmedBody}…
|
|
|
1235
1241
|
}
|
|
1236
1242
|
return wrapped;
|
|
1237
1243
|
}
|
|
1244
|
+
function selectAutoSearchResults(results, threshold) {
|
|
1245
|
+
return results.filter((result) => (result.relevanceScore ?? result.score) >= threshold);
|
|
1246
|
+
}
|
|
1238
1247
|
|
|
1239
1248
|
// src/hooks/magic-context/auto-search-worker-client.ts
|
|
1240
1249
|
import { Worker } from "node:worker_threads";
|
|
@@ -1330,6 +1339,63 @@ async function searchAutoHint(db, sessionId, projectPath, query, options, entry
|
|
|
1330
1339
|
return executeAutoSearchWorker(db, sessionId, projectPath, query, options, entry, "search");
|
|
1331
1340
|
}
|
|
1332
1341
|
var pendingBackfills = new WeakMap;
|
|
1342
|
+
var searchWorkers = new WeakMap;
|
|
1343
|
+
var liveSearchWorkers = new Set;
|
|
1344
|
+
var MAX_IDLE_SEARCH_WORKERS = 4;
|
|
1345
|
+
var SEARCH_WORKER_IDLE_MS = 5 * 60000;
|
|
1346
|
+
var workersCreated = 0;
|
|
1347
|
+
var workersReused = 0;
|
|
1348
|
+
async function acquireSearchWorker(db, key, entry, input, signal) {
|
|
1349
|
+
const pool = searchWorkers.get(db) ?? new Map;
|
|
1350
|
+
searchWorkers.set(db, pool);
|
|
1351
|
+
while (!signal.aborted) {
|
|
1352
|
+
let slot = pool.get(key);
|
|
1353
|
+
if (slot?.busy) {
|
|
1354
|
+
const current = slot;
|
|
1355
|
+
await new Promise((resolve) => {
|
|
1356
|
+
const done = () => {
|
|
1357
|
+
signal.removeEventListener("abort", done);
|
|
1358
|
+
resolve();
|
|
1359
|
+
};
|
|
1360
|
+
signal.addEventListener("abort", done, { once: true });
|
|
1361
|
+
current.busy?.then(done);
|
|
1362
|
+
if (signal.aborted)
|
|
1363
|
+
done();
|
|
1364
|
+
});
|
|
1365
|
+
continue;
|
|
1366
|
+
}
|
|
1367
|
+
const fresh = !slot;
|
|
1368
|
+
if (!slot) {
|
|
1369
|
+
const worker = inRootAsyncContext2(() => new Worker(entry, { workerData: { ...input, persistent: true } }));
|
|
1370
|
+
slot = {
|
|
1371
|
+
worker,
|
|
1372
|
+
dispose() {
|
|
1373
|
+
clearTimeout(this.idleTimer);
|
|
1374
|
+
if (pool.get(key) === this)
|
|
1375
|
+
pool.delete(key);
|
|
1376
|
+
liveSearchWorkers.delete(this);
|
|
1377
|
+
worker.terminate();
|
|
1378
|
+
worker.unref();
|
|
1379
|
+
}
|
|
1380
|
+
};
|
|
1381
|
+
workersCreated++;
|
|
1382
|
+
pool.set(key, slot);
|
|
1383
|
+
liveSearchWorkers.add(slot);
|
|
1384
|
+
const current = slot;
|
|
1385
|
+
worker.on("error", () => current.dispose());
|
|
1386
|
+
worker.on("exit", () => current.dispose());
|
|
1387
|
+
} else
|
|
1388
|
+
workersReused++;
|
|
1389
|
+
clearTimeout(slot.idleTimer);
|
|
1390
|
+
const current = slot;
|
|
1391
|
+
current.busy = new Promise((resolve) => {
|
|
1392
|
+
current.release = resolve;
|
|
1393
|
+
});
|
|
1394
|
+
current.worker.ref();
|
|
1395
|
+
return { slot: current, fresh };
|
|
1396
|
+
}
|
|
1397
|
+
return null;
|
|
1398
|
+
}
|
|
1333
1399
|
function queueAutoSearchBackfill(db, sessionId, projectPath, query) {
|
|
1334
1400
|
if (isEmbeddingHostBusy2())
|
|
1335
1401
|
return Promise.resolve();
|
|
@@ -1394,6 +1460,7 @@ async function executeAutoSearchWorker(db, sessionId, projectPath, query, option
|
|
|
1394
1460
|
query,
|
|
1395
1461
|
options: {
|
|
1396
1462
|
...serializable,
|
|
1463
|
+
autoHint: true,
|
|
1397
1464
|
backfillMemoryEmbeddings: false,
|
|
1398
1465
|
countRetrievals: false,
|
|
1399
1466
|
measurementDisabled: true
|
|
@@ -1403,8 +1470,20 @@ async function executeAutoSearchWorker(db, sessionId, projectPath, query, option
|
|
|
1403
1470
|
snapshot,
|
|
1404
1471
|
deadlineUnixMs: autoSearchDeadlineUnixMs(deadlineSignal)
|
|
1405
1472
|
};
|
|
1473
|
+
let lease;
|
|
1474
|
+
try {
|
|
1475
|
+
lease = await acquireSearchWorker(db, `${input.harness}\x00${projectPath}\x00${job}\x00${entry.href}`, entry, input, signal);
|
|
1476
|
+
} catch (error) {
|
|
1477
|
+
lifecycle.done();
|
|
1478
|
+
throw error;
|
|
1479
|
+
}
|
|
1480
|
+
if (!lease) {
|
|
1481
|
+
lifecycle.done();
|
|
1482
|
+
return [];
|
|
1483
|
+
}
|
|
1484
|
+
const { slot, fresh } = lease;
|
|
1485
|
+
const worker = slot.worker;
|
|
1406
1486
|
return new Promise((resolve, reject) => {
|
|
1407
|
-
const worker = inRootAsyncContext2(() => new Worker(entry, { workerData: input }));
|
|
1408
1487
|
let settled = false;
|
|
1409
1488
|
const finish = (results, error) => {
|
|
1410
1489
|
if (settled)
|
|
@@ -1413,7 +1492,25 @@ async function executeAutoSearchWorker(db, sessionId, projectPath, query, option
|
|
|
1413
1492
|
signal?.removeEventListener("abort", abort);
|
|
1414
1493
|
lifecycle.signal.removeEventListener("abort", abort);
|
|
1415
1494
|
lifecycle.done();
|
|
1416
|
-
worker.
|
|
1495
|
+
worker.off("message", onMessage);
|
|
1496
|
+
worker.off("error", onError);
|
|
1497
|
+
worker.off("exit", onExit);
|
|
1498
|
+
if (error || signal.aborted || entry.href !== defaultAutoSearchWorkerEntry().href)
|
|
1499
|
+
slot.dispose();
|
|
1500
|
+
else {
|
|
1501
|
+
slot.idleTimer = setTimeout(() => slot.dispose(), SEARCH_WORKER_IDLE_MS);
|
|
1502
|
+
slot.idleTimer.unref?.();
|
|
1503
|
+
}
|
|
1504
|
+
const release = slot.release;
|
|
1505
|
+
slot.busy = undefined;
|
|
1506
|
+
slot.release = undefined;
|
|
1507
|
+
release?.();
|
|
1508
|
+
const reusable = liveSearchWorkers.delete(slot);
|
|
1509
|
+
if (reusable)
|
|
1510
|
+
liveSearchWorkers.add(slot);
|
|
1511
|
+
const idle = [...liveSearchWorkers].filter((candidate) => !candidate.busy);
|
|
1512
|
+
for (const prior of idle.slice(0, Math.max(0, idle.length - MAX_IDLE_SEARCH_WORKERS)))
|
|
1513
|
+
prior.dispose();
|
|
1417
1514
|
worker.unref();
|
|
1418
1515
|
if (error)
|
|
1419
1516
|
reject(error);
|
|
@@ -1423,9 +1520,9 @@ async function executeAutoSearchWorker(db, sessionId, projectPath, query, option
|
|
|
1423
1520
|
const abort = () => finish([]);
|
|
1424
1521
|
signal?.addEventListener("abort", abort, { once: true });
|
|
1425
1522
|
lifecycle.signal.addEventListener("abort", abort, { once: true });
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1523
|
+
const onError = (error) => finish([], error);
|
|
1524
|
+
const onExit = (code) => finish([], new Error(`auto-search worker exited (${code})`));
|
|
1525
|
+
const onMessage = async (reply) => {
|
|
1429
1526
|
if (settled)
|
|
1430
1527
|
return;
|
|
1431
1528
|
if (reply.kind === "result") {
|
|
@@ -1444,7 +1541,7 @@ async function executeAutoSearchWorker(db, sessionId, projectPath, query, option
|
|
|
1444
1541
|
const response = { id: reply.id };
|
|
1445
1542
|
try {
|
|
1446
1543
|
if (reply.kind === "query")
|
|
1447
|
-
response.result = await (job === "backfill" ? embedTextForProject2(projectPath, reply.text, signal, "query") : embedQuery
|
|
1544
|
+
response.result = await (job === "backfill" ? embedTextForProject2(projectPath, reply.text, signal, "query") : boundedHintEmbedding(embedQuery, reply.text, signal)) ?? null;
|
|
1448
1545
|
else {
|
|
1449
1546
|
const passage = await embedBatchForProject2(projectPath, reply.texts, signal, reply.purpose);
|
|
1450
1547
|
const current = getProjectEmbeddingSnapshot2(projectPath);
|
|
@@ -1459,13 +1556,46 @@ async function executeAutoSearchWorker(db, sessionId, projectPath, query, option
|
|
|
1459
1556
|
response.error = error instanceof Error ? error.message : String(error);
|
|
1460
1557
|
}
|
|
1461
1558
|
response.embeddingHostBusy = isEmbeddingHostBusy2();
|
|
1462
|
-
if (!settled && !signal?.aborted)
|
|
1463
|
-
|
|
1464
|
-
|
|
1559
|
+
if (!settled && !signal?.aborted) {
|
|
1560
|
+
try {
|
|
1561
|
+
worker.postMessage(response);
|
|
1562
|
+
} catch (error) {
|
|
1563
|
+
finish([], error instanceof Error ? error : new Error(String(error)));
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
worker.on("error", onError);
|
|
1568
|
+
worker.on("exit", onExit);
|
|
1569
|
+
worker.on("message", onMessage);
|
|
1465
1570
|
if (signal?.aborted)
|
|
1466
1571
|
abort();
|
|
1572
|
+
else if (!fresh) {
|
|
1573
|
+
try {
|
|
1574
|
+
worker.postMessage({ kind: "run", input });
|
|
1575
|
+
} catch (error) {
|
|
1576
|
+
finish([], error instanceof Error ? error : new Error(String(error)));
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1467
1579
|
});
|
|
1468
1580
|
}
|
|
1581
|
+
async function boundedHintEmbedding(embed, text, signal) {
|
|
1582
|
+
const controller = new AbortController;
|
|
1583
|
+
const combined = AbortSignal.any([signal, controller.signal]);
|
|
1584
|
+
let timer;
|
|
1585
|
+
try {
|
|
1586
|
+
return await Promise.race([
|
|
1587
|
+
Promise.resolve().then(() => embed?.(text, combined) ?? null),
|
|
1588
|
+
new Promise((resolve) => {
|
|
1589
|
+
timer = setTimeout(() => {
|
|
1590
|
+
resolve(null);
|
|
1591
|
+
controller.abort();
|
|
1592
|
+
}, AUTO_SEARCH_VECTOR_TIMEOUT_MS);
|
|
1593
|
+
})
|
|
1594
|
+
]);
|
|
1595
|
+
} finally {
|
|
1596
|
+
clearTimeout(timer);
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1469
1599
|
function defaultAutoSearchWorkerEntry() {
|
|
1470
1600
|
return new URL(new URL(import.meta.url).pathname.endsWith(".ts") ? "./auto-search-worker.ts" : "./auto-search-worker.js", import.meta.url);
|
|
1471
1601
|
}
|
|
@@ -1773,6 +1903,8 @@ async function runAutoSearchHint(args) {
|
|
|
1773
1903
|
const gitCommitsEnabled = embeddingSnapshot?.gitCommitEnabled ?? options.gitCommitsEnabled ?? false;
|
|
1774
1904
|
const searchOptions = {
|
|
1775
1905
|
limit: 10,
|
|
1906
|
+
maxMessageOrdinal: Math.max(0, getLastCompartmentEndMessage(db, sessionId)),
|
|
1907
|
+
excludeMessageId: userMsgId,
|
|
1776
1908
|
memoryEnabled,
|
|
1777
1909
|
embeddingEnabled,
|
|
1778
1910
|
gitCommitsEnabled,
|
|
@@ -1810,11 +1942,15 @@ async function runAutoSearchHint(args) {
|
|
|
1810
1942
|
if (results.length === 0) {
|
|
1811
1943
|
return writeNoHintAndReconcile("empty");
|
|
1812
1944
|
}
|
|
1813
|
-
|
|
1814
|
-
|
|
1945
|
+
results = selectAutoSearchResults(results, options.scoreThreshold);
|
|
1946
|
+
if (results.length === 0) {
|
|
1947
|
+
sessionLog2(sessionId, `auto-search: no fragment meets relevance threshold ${options.scoreThreshold}`);
|
|
1815
1948
|
return writeNoHintAndReconcile("below-threshold");
|
|
1816
1949
|
}
|
|
1817
|
-
const hintText = buildAutoSearchHint(results, {
|
|
1950
|
+
const hintText = buildAutoSearchHint(results, {
|
|
1951
|
+
wordRules: options.wordRules,
|
|
1952
|
+
query: rawPrompt
|
|
1953
|
+
});
|
|
1818
1954
|
if (!hintText) {
|
|
1819
1955
|
return writeNoHintAndReconcile("empty");
|
|
1820
1956
|
}
|
|
@@ -2858,27 +2994,43 @@ function buildReplacementContent(tagId) {
|
|
|
2858
2994
|
return `[dropped §${tagId}§]`;
|
|
2859
2995
|
}
|
|
2860
2996
|
function applyNewToolDrop(target, options) {
|
|
2861
|
-
|
|
2997
|
+
const plan = planNewToolDrop(target, options, !!options.persist);
|
|
2998
|
+
if (!plan)
|
|
2862
2999
|
return { result: "incomplete", mode: "full" };
|
|
3000
|
+
options.persist?.(plan.mode);
|
|
3001
|
+
return plan.apply();
|
|
3002
|
+
}
|
|
3003
|
+
function planNewToolDrop(target, options, prepare, plannedRemovals) {
|
|
3004
|
+
if (prepare && (target?.prepareDrop?.() ?? target?.canDrop?.()) === false) {
|
|
3005
|
+
return;
|
|
2863
3006
|
}
|
|
2864
3007
|
if (!target) {
|
|
2865
|
-
|
|
2866
|
-
return { result: "absent", mode: "full" };
|
|
3008
|
+
return { mode: "full", apply: () => ({ result: "absent", mode: "full" }) };
|
|
2867
3009
|
}
|
|
2868
|
-
if (options.inWindow && hasSmallToolInput(target) || options.keepSkeleton === true || target.cannotRemove?.() === true || target.wouldStrandConversationEnd?.() === true) {
|
|
3010
|
+
if (options.inWindow && hasSmallToolInput(target) || options.keepSkeleton === true || target.cannotRemove?.() === true || target.wouldStrandConversationEnd?.(plannedRemovals) === true) {
|
|
2869
3011
|
const strip = target.hasAttachments?.() === true;
|
|
2870
|
-
|
|
3012
|
+
const mode = strip ? "skeleton_stripped" : "skeleton_real";
|
|
2871
3013
|
return {
|
|
2872
|
-
|
|
2873
|
-
|
|
3014
|
+
mode,
|
|
3015
|
+
apply: () => ({
|
|
3016
|
+
result: (strip ? target.skeletonStripped?.() : target.skeletonReal?.()) ?? "absent",
|
|
3017
|
+
mode
|
|
3018
|
+
})
|
|
2874
3019
|
};
|
|
2875
3020
|
}
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
3021
|
+
return {
|
|
3022
|
+
mode: "full",
|
|
3023
|
+
apply: () => {
|
|
3024
|
+
const result = target.drop?.() ?? "absent";
|
|
3025
|
+
if (result === "truncated" && target.hasAttachments?.() === true) {
|
|
3026
|
+
return {
|
|
3027
|
+
result: target.skeletonStripped?.() ?? "absent",
|
|
3028
|
+
mode: "skeleton_stripped"
|
|
3029
|
+
};
|
|
3030
|
+
}
|
|
3031
|
+
return { result, mode: result === "truncated" ? "skeleton_real" : "full" };
|
|
3032
|
+
}
|
|
3033
|
+
};
|
|
2882
3034
|
}
|
|
2883
3035
|
function applyPersistedToolDrop(db, sessionId, tagNumber, target, options, afterWrite) {
|
|
2884
3036
|
return applyNewToolDrop(target, {
|
|
@@ -2972,6 +3124,7 @@ function renderConvertedToolSkeletons(targets, converted) {
|
|
|
2972
3124
|
}
|
|
2973
3125
|
return didMutate;
|
|
2974
3126
|
}
|
|
3127
|
+
var PENDING_OPERATION_CHUNK_SIZE = 64;
|
|
2975
3128
|
function applyPendingOperations(sessionId, db, targets, protectedTagIds, preloadedTags, preloadedPendingOps, syntheticPendingOps = [], editMarkerTagIds = new Set, onTagReduced, onBatchComplete, onEligibilitySnapshot) {
|
|
2976
3129
|
let didMutateMessage = false;
|
|
2977
3130
|
let diagnostics;
|
|
@@ -2981,153 +3134,184 @@ function applyPendingOperations(sessionId, db, targets, protectedTagIds, preload
|
|
|
2981
3134
|
diagnostics.reasons[reason] = (diagnostics.reasons[reason] ?? 0) + 1;
|
|
2982
3135
|
};
|
|
2983
3136
|
let admitted = false;
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
const tagStatusById = new Map(tags.map((tag) => [tag.tagNumber, tag.status]));
|
|
2999
|
-
const tagTypeById = new Map(tags.map((tag) => [tag.tagNumber, tag.type]));
|
|
3000
|
-
const opsToApply = [
|
|
3001
|
-
...pendingOps.map((op) => ({ op, synthetic: false })),
|
|
3002
|
-
...syntheticPendingOps.map((op) => ({ op, synthetic: true }))
|
|
3003
|
-
];
|
|
3004
|
-
diagnostics = {
|
|
3005
|
-
source: pendingOps.length > 0 && syntheticPendingOps.length > 0 ? "mixed" : syntheticPendingOps.length > 0 ? "synthetic" : "pending",
|
|
3006
|
-
total: opsToApply.length,
|
|
3007
|
-
mutated: 0,
|
|
3008
|
-
persistedWithoutMutation: 0,
|
|
3009
|
-
reasons: {}
|
|
3010
|
-
};
|
|
3011
|
-
const skeletonWindow = new Set(preloadedTags ? tags.filter((tag) => tag.type === "tool").map((tag) => tag.tagNumber).sort((left, right) => right - left).slice(0, RECENT_TOOL_SKELETON_WINDOW) : getNewestToolTagNumbers2(db, sessionId, RECENT_TOOL_SKELETON_WINDOW));
|
|
3012
|
-
for (const { op: pendingOp, synthetic } of opsToApply) {
|
|
3013
|
-
let operationMutated = false;
|
|
3014
|
-
const tagStatus = tagStatusById.get(pendingOp.tagId);
|
|
3015
|
-
if (tagStatus === "compacted" || tagStatus === "dropped") {
|
|
3016
|
-
reject("already_reduced");
|
|
3017
|
-
if (!synthetic)
|
|
3018
|
-
removePendingOp(db, sessionId, pendingOp.tagId);
|
|
3019
|
-
continue;
|
|
3020
|
-
}
|
|
3021
|
-
const target = targets.get(pendingOp.tagId);
|
|
3022
|
-
const veto = pendingDropVeto(pendingOp.tagId, target, protectedTagIds);
|
|
3023
|
-
if (veto) {
|
|
3024
|
-
reject(veto);
|
|
3025
|
-
continue;
|
|
3026
|
-
}
|
|
3027
|
-
const isToolTag = tagTypeById.get(pendingOp.tagId) === "tool";
|
|
3028
|
-
if (synthetic) {
|
|
3029
|
-
if (!isToolTag) {
|
|
3030
|
-
reject("synthetic_non_tool");
|
|
3031
|
-
continue;
|
|
3032
|
-
}
|
|
3033
|
-
if (target?.canDrop?.() !== true) {
|
|
3034
|
-
reject("synthetic_target_not_droppable");
|
|
3035
|
-
continue;
|
|
3036
|
-
}
|
|
3137
|
+
let startedAt = 0;
|
|
3138
|
+
const mutations = [];
|
|
3139
|
+
let drainChunk;
|
|
3140
|
+
let hasMore = false;
|
|
3141
|
+
do {
|
|
3142
|
+
admitted = false;
|
|
3143
|
+
startedAt = 0;
|
|
3144
|
+
try {
|
|
3145
|
+
db.transaction(() => {
|
|
3146
|
+
admitted = true;
|
|
3147
|
+
startedAt = performance.now();
|
|
3148
|
+
if (drainChunk) {
|
|
3149
|
+
drainChunk();
|
|
3150
|
+
return;
|
|
3037
3151
|
}
|
|
3038
|
-
const
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3152
|
+
const pendingOps = preloadedPendingOps ?? getPendingOps(db, sessionId);
|
|
3153
|
+
onEligibilitySnapshot?.(capturePendingDropEligibility(targets, protectedTagIds));
|
|
3154
|
+
const tags = preloadedTags ?? getTagsByNumbers2(db, sessionId, [
|
|
3155
|
+
...new Set([
|
|
3156
|
+
...pendingOps.map((op) => op.tagId),
|
|
3157
|
+
...syntheticPendingOps.map((op) => op.tagId)
|
|
3158
|
+
])
|
|
3159
|
+
]);
|
|
3160
|
+
const tagById = new Map(tags.map((tag) => [tag.tagNumber, tag]));
|
|
3161
|
+
const tagStatusById = new Map(tags.map((tag) => [tag.tagNumber, tag.status]));
|
|
3162
|
+
const tagTypeById = new Map(tags.map((tag) => [tag.tagNumber, tag.type]));
|
|
3163
|
+
const opsToApply = [
|
|
3164
|
+
...pendingOps.map((op) => ({ op, synthetic: false })),
|
|
3165
|
+
...syntheticPendingOps.map((op) => ({ op, synthetic: true }))
|
|
3166
|
+
];
|
|
3167
|
+
diagnostics = {
|
|
3168
|
+
source: pendingOps.length > 0 && syntheticPendingOps.length > 0 ? "mixed" : syntheticPendingOps.length > 0 ? "synthetic" : "pending",
|
|
3169
|
+
total: opsToApply.length,
|
|
3170
|
+
mutated: 0,
|
|
3171
|
+
persistedWithoutMutation: 0,
|
|
3172
|
+
reasons: {}
|
|
3173
|
+
};
|
|
3174
|
+
const skeletonWindow = new Set(preloadedTags ? tags.filter((tag) => tag.type === "tool").map((tag) => tag.tagNumber).sort((left, right) => right - left).slice(0, RECENT_TOOL_SKELETON_WINDOW) : getNewestToolTagNumbers2(db, sessionId, RECENT_TOOL_SKELETON_WINDOW));
|
|
3175
|
+
const plannedRemovals = new Set;
|
|
3176
|
+
const removedTagIds = new Set;
|
|
3177
|
+
const record = (mutated) => {
|
|
3178
|
+
if (!diagnostics)
|
|
3179
|
+
return;
|
|
3180
|
+
if (mutated) {
|
|
3181
|
+
didMutateMessage = true;
|
|
3182
|
+
diagnostics.mutated += 1;
|
|
3183
|
+
} else
|
|
3184
|
+
diagnostics.persistedWithoutMutation += 1;
|
|
3185
|
+
};
|
|
3186
|
+
let cursor = 0;
|
|
3187
|
+
drainChunk = () => {
|
|
3188
|
+
const chunk = opsToApply.slice(cursor, cursor + PENDING_OPERATION_CHUNK_SIZE);
|
|
3189
|
+
cursor += chunk.length;
|
|
3190
|
+
hasMore = cursor < opsToApply.length;
|
|
3191
|
+
for (const { op: pendingOp, synthetic } of chunk) {
|
|
3192
|
+
const tagStatus = tagStatusById.get(pendingOp.tagId);
|
|
3193
|
+
if (tagStatus === "compacted" || tagStatus === "dropped") {
|
|
3194
|
+
reject("already_reduced");
|
|
3044
3195
|
if (!synthetic)
|
|
3045
3196
|
removePendingOp(db, sessionId, pendingOp.tagId);
|
|
3046
|
-
}).immediate();
|
|
3047
|
-
} finally {
|
|
3048
|
-
if (startedAt)
|
|
3049
|
-
logSlowWriteTransaction("apply_pending_operation", startedAt);
|
|
3050
|
-
}
|
|
3051
|
-
};
|
|
3052
|
-
let shouldPersistDrop = false;
|
|
3053
|
-
if (isToolTag) {
|
|
3054
|
-
if (editMarkerTagIds.has(pendingOp.tagId)) {
|
|
3055
|
-
const strip = target?.hasAttachments?.() === true;
|
|
3056
|
-
if (target?.canDrop?.() === false || target?.prepareDrop?.() === false || !target) {
|
|
3057
|
-
reject("edit_marker_incomplete");
|
|
3058
3197
|
continue;
|
|
3059
3198
|
}
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
if (markResult === "incomplete" || markResult === "absent") {
|
|
3063
|
-
reject(`edit_marker_${markResult}`);
|
|
3199
|
+
if (removedTagIds.has(pendingOp.tagId)) {
|
|
3200
|
+
reject("drop_incomplete");
|
|
3064
3201
|
continue;
|
|
3065
3202
|
}
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
} else {
|
|
3071
|
-
const { result: dropResult, mode: appliedMode } = applyNewToolDrop(target, {
|
|
3072
|
-
inWindow: skeletonWindow.has(pendingOp.tagId),
|
|
3073
|
-
persist: persistDrop
|
|
3074
|
-
});
|
|
3075
|
-
if (dropResult === "incomplete" || synthetic && dropResult !== "removed" && dropResult !== "truncated") {
|
|
3076
|
-
reject(`drop_${dropResult}`);
|
|
3203
|
+
const target = targets.get(pendingOp.tagId);
|
|
3204
|
+
const veto = pendingDropVeto(pendingOp.tagId, target, protectedTagIds);
|
|
3205
|
+
if (veto) {
|
|
3206
|
+
reject(veto);
|
|
3077
3207
|
continue;
|
|
3078
3208
|
}
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3209
|
+
const isToolTag = tagTypeById.get(pendingOp.tagId) === "tool";
|
|
3210
|
+
if (synthetic) {
|
|
3211
|
+
if (!isToolTag) {
|
|
3212
|
+
reject("synthetic_non_tool");
|
|
3213
|
+
continue;
|
|
3214
|
+
}
|
|
3215
|
+
if (target?.canDrop?.() !== true) {
|
|
3216
|
+
reject("synthetic_target_not_droppable");
|
|
3217
|
+
continue;
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
const persistDrop = (mode) => {
|
|
3221
|
+
markTagDropped2(db, sessionId, pendingOp.tagId, mode);
|
|
3222
|
+
if (!synthetic)
|
|
3223
|
+
removePendingOp(db, sessionId, pendingOp.tagId);
|
|
3224
|
+
};
|
|
3225
|
+
if (isToolTag) {
|
|
3226
|
+
if (editMarkerTagIds.has(pendingOp.tagId)) {
|
|
3227
|
+
const strip = target?.hasAttachments?.() === true;
|
|
3228
|
+
if (target?.canDrop?.() === false || target?.prepareDrop?.() === false || !target) {
|
|
3229
|
+
reject("edit_marker_incomplete");
|
|
3230
|
+
continue;
|
|
3231
|
+
}
|
|
3232
|
+
persistDrop(strip ? "edit_marker_stripped" : "edit_marker");
|
|
3233
|
+
mutations.push(() => {
|
|
3234
|
+
const markResult = (strip ? target?.editMarkerStripped?.() : target?.editMarker?.()) ?? "absent";
|
|
3235
|
+
if (markResult === "incomplete" || markResult === "absent") {
|
|
3236
|
+
reject(`edit_marker_${markResult}`);
|
|
3237
|
+
return;
|
|
3238
|
+
}
|
|
3239
|
+
record(true);
|
|
3240
|
+
onTagReduced?.({
|
|
3241
|
+
tagNumber: pendingOp.tagId,
|
|
3242
|
+
mode: "edit_marker"
|
|
3243
|
+
});
|
|
3244
|
+
});
|
|
3245
|
+
} else {
|
|
3246
|
+
const plan = planNewToolDrop(target, { inWindow: skeletonWindow.has(pendingOp.tagId) }, true, plannedRemovals);
|
|
3247
|
+
if (!plan) {
|
|
3248
|
+
reject("drop_incomplete");
|
|
3249
|
+
continue;
|
|
3250
|
+
}
|
|
3251
|
+
persistDrop(plan.mode);
|
|
3252
|
+
if (plan.mode === "full" && target?.drop) {
|
|
3253
|
+
target.notePlannedRemoval?.(plannedRemovals);
|
|
3254
|
+
removedTagIds.add(pendingOp.tagId);
|
|
3255
|
+
}
|
|
3256
|
+
mutations.push(() => {
|
|
3257
|
+
const { result: dropResult, mode: appliedMode } = plan.apply();
|
|
3258
|
+
if (dropResult === "incomplete" || synthetic && dropResult !== "removed" && dropResult !== "truncated") {
|
|
3259
|
+
reject(`drop_${dropResult}`);
|
|
3260
|
+
return;
|
|
3261
|
+
}
|
|
3262
|
+
if (dropResult === "removed" || dropResult === "truncated") {
|
|
3263
|
+
record(true);
|
|
3264
|
+
onTagReduced?.({
|
|
3265
|
+
tagNumber: pendingOp.tagId,
|
|
3266
|
+
mode: appliedMode === "full" ? "full" : "truncated"
|
|
3267
|
+
});
|
|
3268
|
+
} else {
|
|
3269
|
+
reject(`drop_${dropResult}`);
|
|
3270
|
+
record(false);
|
|
3271
|
+
}
|
|
3272
|
+
});
|
|
3273
|
+
}
|
|
3274
|
+
} else if (target) {
|
|
3275
|
+
const replacement = buildReplacementContent(pendingOp.tagId);
|
|
3276
|
+
persistDrop();
|
|
3277
|
+
mutations.push(() => {
|
|
3278
|
+
const priorContent = target.getContent?.();
|
|
3279
|
+
const changed = target.setContent(replacement);
|
|
3280
|
+
record(changed);
|
|
3281
|
+
if (changed) {
|
|
3282
|
+
const originalCharacters = typeof priorContent === "string" ? priorContent.length : tagById.get(pendingOp.tagId)?.byteSize ?? replacement.length;
|
|
3283
|
+
onTagReduced?.({
|
|
3284
|
+
tagNumber: pendingOp.tagId,
|
|
3285
|
+
mode: "partial",
|
|
3286
|
+
removedCharacters: Math.max(0, originalCharacters - replacement.length)
|
|
3287
|
+
});
|
|
3288
|
+
} else {
|
|
3289
|
+
reject("content_unchanged");
|
|
3290
|
+
}
|
|
3085
3291
|
});
|
|
3086
|
-
} else {
|
|
3087
|
-
reject(
|
|
3292
|
+
} else if (!synthetic) {
|
|
3293
|
+
reject("target_absent");
|
|
3294
|
+
persistDrop();
|
|
3295
|
+
mutations.push(() => record(false));
|
|
3088
3296
|
}
|
|
3089
|
-
shouldPersistDrop = true;
|
|
3090
|
-
}
|
|
3091
|
-
} else if (target) {
|
|
3092
|
-
const replacement = buildReplacementContent(pendingOp.tagId);
|
|
3093
|
-
const priorContent = target.getContent?.();
|
|
3094
|
-
persistDrop();
|
|
3095
|
-
const changed = target.setContent(replacement);
|
|
3096
|
-
if (changed) {
|
|
3097
|
-
didMutateMessage = true;
|
|
3098
|
-
operationMutated = true;
|
|
3099
|
-
const originalCharacters = typeof priorContent === "string" ? priorContent.length : tagById.get(pendingOp.tagId)?.byteSize ?? replacement.length;
|
|
3100
|
-
onTagReduced?.({
|
|
3101
|
-
tagNumber: pendingOp.tagId,
|
|
3102
|
-
mode: "partial",
|
|
3103
|
-
removedCharacters: Math.max(0, originalCharacters - replacement.length)
|
|
3104
|
-
});
|
|
3105
|
-
} else {
|
|
3106
|
-
reject("content_unchanged");
|
|
3107
3297
|
}
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
}
|
|
3118
|
-
if (operationMutated)
|
|
3119
|
-
diagnostics.mutated += 1;
|
|
3120
|
-
else
|
|
3121
|
-
diagnostics.persistedWithoutMutation += 1;
|
|
3298
|
+
};
|
|
3299
|
+
drainChunk();
|
|
3300
|
+
}).immediate();
|
|
3301
|
+
} catch (error) {
|
|
3302
|
+
if (!admitted && /database (?:table )?is locked|sqlite_(busy|locked)/i.test(String(error))) {
|
|
3303
|
+
sessionLog2(sessionId, "pending operations write admission busy; retaining remaining operations for retry");
|
|
3304
|
+
hasMore = false;
|
|
3305
|
+
} else {
|
|
3306
|
+
throw error;
|
|
3122
3307
|
}
|
|
3308
|
+
} finally {
|
|
3309
|
+
if (startedAt)
|
|
3310
|
+
logSlowWriteTransaction("apply_pending_operations", startedAt);
|
|
3123
3311
|
}
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
return false;
|
|
3128
|
-
}
|
|
3129
|
-
throw error;
|
|
3130
|
-
}
|
|
3312
|
+
for (const mutate of mutations.splice(0))
|
|
3313
|
+
mutate();
|
|
3314
|
+
} while (hasMore);
|
|
3131
3315
|
if (diagnostics) {
|
|
3132
3316
|
onBatchComplete?.(diagnostics);
|
|
3133
3317
|
if (diagnostics.total > 0 && diagnostics.mutated === 0) {
|
|
@@ -4170,10 +4354,41 @@ function createExistingTagResolver(sessionId, tagger, db) {
|
|
|
4170
4354
|
}
|
|
4171
4355
|
|
|
4172
4356
|
// src/hooks/magic-context/transform-stage-logger.ts
|
|
4173
|
-
|
|
4174
|
-
|
|
4357
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4358
|
+
var SLOW_STAGE_MS = 100;
|
|
4359
|
+
var passes = new AsyncLocalStorage;
|
|
4360
|
+
async function withTransformTimingSummary(run) {
|
|
4361
|
+
const pass = {
|
|
4362
|
+
stages: [],
|
|
4363
|
+
slow: [],
|
|
4364
|
+
closed: false,
|
|
4365
|
+
sessionId: undefined
|
|
4366
|
+
};
|
|
4367
|
+
return passes.run(pass, async () => {
|
|
4368
|
+
try {
|
|
4369
|
+
return await run();
|
|
4370
|
+
} finally {
|
|
4371
|
+
pass.closed = true;
|
|
4372
|
+
if (pass.sessionId)
|
|
4373
|
+
sessionLog2(pass.sessionId, `transform stages: ${pass.stages.join(" ")} slow>=${SLOW_STAGE_MS}ms=[${pass.slow.join(",")}]`);
|
|
4374
|
+
}
|
|
4375
|
+
});
|
|
4376
|
+
}
|
|
4377
|
+
function logTransformElapsed(sessionId, stage, elapsedMs, extra) {
|
|
4378
|
+
const elapsed = elapsedMs.toFixed(1);
|
|
4175
4379
|
const suffix = extra ? ` ${extra}` : "";
|
|
4176
|
-
|
|
4380
|
+
const pass = passes.getStore();
|
|
4381
|
+
if (pass && !pass.closed) {
|
|
4382
|
+
pass.sessionId = sessionId;
|
|
4383
|
+
pass.stages.push(`${stage}=${elapsed}ms${extra ? `(${extra})` : ""}`);
|
|
4384
|
+
if (elapsedMs >= SLOW_STAGE_MS)
|
|
4385
|
+
pass.slow.push(stage);
|
|
4386
|
+
}
|
|
4387
|
+
if (elapsedMs >= SLOW_STAGE_MS)
|
|
4388
|
+
sessionLog2(sessionId, `transform stage: stage=${stage} elapsed=${elapsed}ms${suffix}`);
|
|
4389
|
+
}
|
|
4390
|
+
function logTransformTiming(sessionId, stage, startMs, extra) {
|
|
4391
|
+
logTransformElapsed(sessionId, stage, performance.now() - startMs, extra);
|
|
4177
4392
|
}
|
|
4178
4393
|
|
|
4179
4394
|
// src/hooks/magic-context/tag-messages.ts
|
|
@@ -4539,13 +4754,18 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
4539
4754
|
}));
|
|
4540
4755
|
accAssignTag += performance.now() - _tAssignText;
|
|
4541
4756
|
const persistedSource = sourceContents.get(tagId);
|
|
4542
|
-
if (persistedSource !== undefined) {
|
|
4757
|
+
if (persistedSource !== undefined && !options.refreshSourceContents) {
|
|
4543
4758
|
textPart.text = options.normalizeRestoredAssistantText && message.info.role === "assistant" ? options.normalizeRestoredAssistantText(persistedSource) : persistedSource;
|
|
4544
4759
|
} else {
|
|
4545
4760
|
const sourceContent = stripTagPrefix(textPart.text);
|
|
4546
|
-
if (sourceContent.trim().length > 0) {
|
|
4761
|
+
if (sourceContent.trim().length > 0 || options.refreshSourceContents) {
|
|
4547
4762
|
const _tSaveText = performance.now();
|
|
4548
|
-
|
|
4763
|
+
if (options.refreshSourceContents) {
|
|
4764
|
+
replaceSourceContent(db, sessionId, tagId, sourceContent);
|
|
4765
|
+
updateTagByteSize2(db, sessionId, tagId, byteSize(sourceContent));
|
|
4766
|
+
updateTagTokenCount2(db, sessionId, tagId, estimateTextTagTokenCount(sourceContent));
|
|
4767
|
+
} else
|
|
4768
|
+
saveSourceContent(db, sessionId, tagId, sourceContent);
|
|
4549
4769
|
accSaveSource += performance.now() - _tSaveText;
|
|
4550
4770
|
}
|
|
4551
4771
|
}
|
|
@@ -4638,7 +4858,10 @@ function tagMessages(sessionId, messages, tagger, db, options = {}) {
|
|
|
4638
4858
|
const sourceContent = buildFileSourceContent(message.parts);
|
|
4639
4859
|
if (sourceContent) {
|
|
4640
4860
|
const _tSaveFile = performance.now();
|
|
4641
|
-
|
|
4861
|
+
if (options.refreshSourceContents)
|
|
4862
|
+
replaceSourceContent(db, sessionId, tagId, sourceContent);
|
|
4863
|
+
else
|
|
4864
|
+
saveSourceContent(db, sessionId, tagId, sourceContent);
|
|
4642
4865
|
accSaveSource += performance.now() - _tSaveFile;
|
|
4643
4866
|
}
|
|
4644
4867
|
}
|
|
@@ -5483,6 +5706,9 @@ async function runPostTransformPhase2(args) {
|
|
|
5483
5706
|
rewritingSignedPrefix = true;
|
|
5484
5707
|
thinkingReleasedForFit ||= forFit;
|
|
5485
5708
|
};
|
|
5709
|
+
if (activeThinkingPrefixHold && args.forceSignedRebuildForFit) {
|
|
5710
|
+
releaseThinkingForRewrite(true);
|
|
5711
|
+
}
|
|
5486
5712
|
const foldDueDecision = m0M1EnabledForFold && args.m0M1 && !freezeM0M1 ? mustMaterialize({
|
|
5487
5713
|
db: args.db,
|
|
5488
5714
|
sessionId: args.sessionId,
|
|
@@ -5627,7 +5853,7 @@ async function runPostTransformPhase2(args) {
|
|
|
5627
5853
|
const idleExpiryRebuild = (!freezeM0M1 || activeThinkingPrefixHold) && args.m0M1?.hardSignals?.cacheExpired === true;
|
|
5628
5854
|
const rideSignals = {
|
|
5629
5855
|
subagentExecute: !args.fullFeatureMode && args.schedulerDecision === "execute",
|
|
5630
|
-
hardFold: foldBustsServedPrefixThisPass || firstRenderBust || idleExpiryRebuild,
|
|
5856
|
+
hardFold: rewritingSignedPrefix || foldBustsServedPrefixThisPass || firstRenderBust || idleExpiryRebuild,
|
|
5631
5857
|
force: emergencyDropEligible && (args.contextUsage.percentage >= 95 || getEmergencyInputSample(args.db, args.sessionId) === 0),
|
|
5632
5858
|
explicitFlush: isExplicitFlush && hasPendingMaterializationOrigin(args.pendingMaterializationSessions, args.sessionId, "user_flush"),
|
|
5633
5859
|
publishedHistory: !prefixPreflightFailed && (publishedM1RefreshedThisPass || !m0M1EnabledForFold && (args.pendingCompartmentInjection?.compartmentCount ?? 0) > 0 && legacyPublishedHeadChanged(args))
|
|
@@ -6821,4 +7047,4 @@ function checkM0MutationDriftAndSignal2(args) {
|
|
|
6821
7047
|
return false;
|
|
6822
7048
|
}
|
|
6823
7049
|
|
|
6824
|
-
export { makeToolCompositeKey, createTagger, cavemanWordRulesForLanguage, searchMessageHistoryOffThread, findSessionId, findLastUserMessageId, clearAutoSearchForSession, setCtxReduceRegisteredGlobally, resolveCtxReduceAvailabilityFromMessages, resolveCtxReduceAvailability, primeCtxReduceSpawnPermission, ctxReduceSpawnPermissionReadNeeded, spawnAgentFromMessages, spawnAgentFromOpenCodeDb, todowritePermissionDenied, cachedToolPermissionDenied, clearToolPermissionDenied, resolveTodowriteAvailabilityFromMessages, resolveTodowriteAvailability, canConsumeDeferredOnThisPass, hasReclaimRide, reclaimRideLabel, captureOpencodeReasoningBudgetStatus, reasoningBudgetStatusLine, ENGINE_RECONNECTING_USER_MESSAGE, ENGINE_BUSY_USER_MESSAGE, SIGNED_THINKING_RESET_FENCE_FAILED, contextRefusalError, protectedToolRefusal, outgoingContextRefusal, signedTurnContextRefusal, EmergencyFailClosedError, latestAssistantTurnStart, latestAssistantTurnMessages, hasActiveAnthropicThinkingTurn, replayCavemanCompression, DegradedPassRefusalError, degradedPassError, pendingDropEligibilityKey, createPendingDropEligibilityCache, applyFlushedStatuses, prewarmTagOwners, waitForTagOwners, stripStructuralNoise, logTransformTiming, hasRecentAssistantCommit, tagMessages, resetDegradedCacheCount2, isSyntheticHeadMessage2, applyTodoSynthesis2, freezeReasoningOnBustingPass2, firstServedDivergenceIndex2, rustModeServedKeyAfterPersistedStrips2, replayRustModeBindingMismatchStrips2, RUST_MARKER_LOCK_SKIP_LOG2, applyRustModeDeferredCompactionMarker2, clearRustModeBoundaryRecord2, runRustModePostprocess2, reconcileMarkerRepresentation2, clearPendingCompactionMarkerAfterSuccessfulDrain2, defaultCompactionMarkerStrategy2, abortSessionFailClosed2, evaluateEmergencyFailClosed2, finalizeMessageRepresentation2, runPostTransformPhase2, checkM0MutationDriftAndSignal2 };
|
|
7050
|
+
export { makeToolCompositeKey, createTagger, cavemanWordRulesForLanguage, searchMessageHistoryOffThread, findSessionId, findLastUserMessageId, clearAutoSearchForSession, setCtxReduceRegisteredGlobally, resolveCtxReduceAvailabilityFromMessages, resolveCtxReduceAvailability, primeCtxReduceSpawnPermission, ctxReduceSpawnPermissionReadNeeded, spawnAgentFromMessages, spawnAgentFromOpenCodeDb, todowritePermissionDenied, cachedToolPermissionDenied, clearToolPermissionDenied, resolveTodowriteAvailabilityFromMessages, resolveTodowriteAvailability, canConsumeDeferredOnThisPass, hasReclaimRide, reclaimRideLabel, captureOpencodeReasoningBudgetStatus, reasoningBudgetStatusLine, ENGINE_RECONNECTING_USER_MESSAGE, ENGINE_BUSY_USER_MESSAGE, SIGNED_THINKING_RESET_FENCE_FAILED, contextRefusalError, protectedToolRefusal, outgoingContextRefusal, signedTurnContextRefusal, EmergencyFailClosedError, latestAssistantTurnStart, latestAssistantTurnMessages, hasActiveAnthropicThinkingTurn, replayCavemanCompression, DegradedPassRefusalError, degradedPassError, pendingDropEligibilityKey, createPendingDropEligibilityCache, applyFlushedStatuses, prewarmTagOwners, waitForTagOwners, stripStructuralNoise, withTransformTimingSummary, logTransformTiming, hasRecentAssistantCommit, tagMessages, resetDegradedCacheCount2, isSyntheticHeadMessage2, applyTodoSynthesis2, freezeReasoningOnBustingPass2, firstServedDivergenceIndex2, rustModeServedKeyAfterPersistedStrips2, replayRustModeBindingMismatchStrips2, RUST_MARKER_LOCK_SKIP_LOG2, applyRustModeDeferredCompactionMarker2, clearRustModeBoundaryRecord2, runRustModePostprocess2, reconcileMarkerRepresentation2, clearPendingCompactionMarkerAfterSuccessfulDrain2, defaultCompactionMarkerStrategy2, abortSessionFailClosed2, evaluateEmergencyFailClosed2, finalizeMessageRepresentation2, runPostTransformPhase2, checkM0MutationDriftAndSignal2 };
|