@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
|
@@ -55,8 +55,9 @@ import {
|
|
|
55
55
|
SqliteAcquisitionBusyError2,
|
|
56
56
|
withAsyncPrivilegedWriter2,
|
|
57
57
|
indexCoordinationInput2
|
|
58
|
-
} from "./index-
|
|
58
|
+
} from "./index-beht37jy.js";
|
|
59
59
|
import {
|
|
60
|
+
pruneMissingProjectIdentities,
|
|
60
61
|
shouldSkipHomeProjectMemory,
|
|
61
62
|
ProjectIdentityError,
|
|
62
63
|
takeDubiousOwnershipProjectIdentityWarning,
|
|
@@ -70,7 +71,7 @@ import {
|
|
|
70
71
|
storedPathBelongsToIdentity,
|
|
71
72
|
beginBootQuietPeriod,
|
|
72
73
|
scheduleAfterBootQuiet
|
|
73
|
-
} from "./index-
|
|
74
|
+
} from "./index-2vxtcb95.js";
|
|
74
75
|
import {
|
|
75
76
|
recordSessionProjectIdentity,
|
|
76
77
|
hasRecordedSessionProjectIdentity,
|
|
@@ -80,7 +81,7 @@ import {
|
|
|
80
81
|
markGitSweepSuccessAndRelease,
|
|
81
82
|
parkGitSweepNonIndexable,
|
|
82
83
|
releaseGitSweepLease
|
|
83
|
-
} from "./index-
|
|
84
|
+
} from "./index-rr2bb45z.js";
|
|
84
85
|
import {
|
|
85
86
|
hasTrustedAbsoluteWall,
|
|
86
87
|
applyProvenInputFloor,
|
|
@@ -106,7 +107,7 @@ import {
|
|
|
106
107
|
estimateTokens,
|
|
107
108
|
estimateFixedPromptTokens,
|
|
108
109
|
normalizeText
|
|
109
|
-
} from "./index-
|
|
110
|
+
} from "./index-c5pytzne.js";
|
|
110
111
|
import {
|
|
111
112
|
protectedToolTokenCount,
|
|
112
113
|
peelLeadingMcTagNotation,
|
|
@@ -143,7 +144,7 @@ import {
|
|
|
143
144
|
getDroppedTagsByNumbers2,
|
|
144
145
|
getMaxDroppedTagNumber2,
|
|
145
146
|
getTagById2
|
|
146
|
-
} from "./index-
|
|
147
|
+
} from "./index-hqhm3wke.js";
|
|
147
148
|
import {
|
|
148
149
|
observeTemporalDecisions,
|
|
149
150
|
stableStringify
|
|
@@ -160,14 +161,14 @@ import {
|
|
|
160
161
|
DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
161
162
|
DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
162
163
|
DREAM_TASK_PROMOTION_DEFAULTS
|
|
163
|
-
} from "./index-
|
|
164
|
+
} from "./index-wgypt3cs.js";
|
|
164
165
|
import {
|
|
165
166
|
isRawCompactionSummaryInfo2,
|
|
166
167
|
extractInMemoryMessageViews2,
|
|
167
168
|
buildInMemoryTailRawMessages2,
|
|
168
169
|
RawOrdinalsNotReady2,
|
|
169
170
|
runSessionWarmupWorker
|
|
170
|
-
} from "./index-
|
|
171
|
+
} from "./index-s734jcsr.js";
|
|
171
172
|
import {
|
|
172
173
|
openCodeDbExists,
|
|
173
174
|
withReadOnlySessionDb,
|
|
@@ -175,7 +176,7 @@ import {
|
|
|
175
176
|
latestPersistedMessageForRecovery,
|
|
176
177
|
latestRealUserTurnIdFromOpenCodeDb,
|
|
177
178
|
findLastAssistantModelFromOpenCodeDb
|
|
178
|
-
} from "./index-
|
|
179
|
+
} from "./index-kq82mtg0.js";
|
|
179
180
|
import {
|
|
180
181
|
expandToolPart,
|
|
181
182
|
estimateTrueRawMessageTokens,
|
|
@@ -296,10 +297,10 @@ import {
|
|
|
296
297
|
readRawSessionMessageById2,
|
|
297
298
|
readSessionChunk2,
|
|
298
299
|
readRawSessionSeedTail2
|
|
299
|
-
} from "./index-
|
|
300
|
+
} from "./index-p7m7j0cp.js";
|
|
300
301
|
import {
|
|
301
302
|
getMeasuredToolDefinitionTokens
|
|
302
|
-
} from "./index-
|
|
303
|
+
} from "./index-ke416mdc.js";
|
|
303
304
|
import {
|
|
304
305
|
isFailClosedBlockingError,
|
|
305
306
|
shouldBypassFailClosedBlock,
|
|
@@ -313,7 +314,7 @@ import {
|
|
|
313
314
|
runSqliteOptimize,
|
|
314
315
|
openDatabase,
|
|
315
316
|
openCurrentDatabase
|
|
316
|
-
} from "./index-
|
|
317
|
+
} from "./index-fb2qxs2y.js";
|
|
317
318
|
import {
|
|
318
319
|
registerOwnRpcServerInstance,
|
|
319
320
|
rpcPortDir,
|
|
@@ -332,7 +333,7 @@ import {
|
|
|
332
333
|
resolveStoredPathWorkspaceIdentity,
|
|
333
334
|
storedPathBelongsToWorkspace,
|
|
334
335
|
computeWorkspaceEpochFingerprint
|
|
335
|
-
} from "./index-
|
|
336
|
+
} from "./index-qn7xstt2.js";
|
|
336
337
|
import {
|
|
337
338
|
V2_MEMORY_CATEGORIES,
|
|
338
339
|
CATEGORY_PRIORITY
|
|
@@ -503,7 +504,7 @@ import {
|
|
|
503
504
|
snapRangeToCompartments,
|
|
504
505
|
getActiveCompartmentRun,
|
|
505
506
|
startCompartmentAgent
|
|
506
|
-
} from "./index-
|
|
507
|
+
} from "./index-a7c4r5re.js";
|
|
507
508
|
import {
|
|
508
509
|
embedPauseBySession,
|
|
509
510
|
embedRunStateBySession,
|
|
@@ -531,7 +532,7 @@ import {
|
|
|
531
532
|
embedSessionCompartmentChunks2,
|
|
532
533
|
getEmbeddingCoverageStatus2,
|
|
533
534
|
getAutoEmbeddingSessionCoverage2
|
|
534
|
-
} from "./index-
|
|
535
|
+
} from "./index-ze7mvk54.js";
|
|
535
536
|
import {
|
|
536
537
|
SubcClient,
|
|
537
538
|
connectionFileExists,
|
|
@@ -539,7 +540,7 @@ import {
|
|
|
539
540
|
toSynapseLaneDescriptor,
|
|
540
541
|
formatSynapseLaneDescriptor,
|
|
541
542
|
SynapseEmbeddingProvider
|
|
542
|
-
} from "./index-
|
|
543
|
+
} from "./index-6x57ar45.js";
|
|
543
544
|
import {
|
|
544
545
|
BoundedSessionMap,
|
|
545
546
|
LkgRecoveryFenceError,
|
|
@@ -551,6 +552,7 @@ import {
|
|
|
551
552
|
prepareLkgCaptureFence,
|
|
552
553
|
certifyCommittedLkgCapture,
|
|
553
554
|
markLkgRecoveryDirty,
|
|
555
|
+
gaDatabasePath,
|
|
554
556
|
getMessageIndexSourceIdentity2,
|
|
555
557
|
isMessageIndexSourceCurrent2,
|
|
556
558
|
getLastIndexedOrdinal2,
|
|
@@ -559,8 +561,8 @@ import {
|
|
|
559
561
|
clearIndexedMessages2,
|
|
560
562
|
indexSingleMessage2,
|
|
561
563
|
indexMessagesAfterOrdinal2,
|
|
562
|
-
|
|
563
|
-
} from "./index-
|
|
564
|
+
sweepOrphanedOpenCodeMessageIndexesCooperatively2
|
|
565
|
+
} from "./index-cwzfcbtq.js";
|
|
564
566
|
import {
|
|
565
567
|
renderUserFacingFailure,
|
|
566
568
|
userFacingFailureCode,
|
|
@@ -604,7 +606,7 @@ import {
|
|
|
604
606
|
readGitFileChangeTimesSince,
|
|
605
607
|
verificationFileExists,
|
|
606
608
|
normalizeVerificationFiles
|
|
607
|
-
} from "./index-
|
|
609
|
+
} from "./index-v8awdgvd.js";
|
|
608
610
|
import {
|
|
609
611
|
registerNotificationSink2,
|
|
610
612
|
pushNotification2,
|
|
@@ -614,7 +616,7 @@ import {
|
|
|
614
616
|
} from "./index-x8a7jmkh.js";
|
|
615
617
|
import {
|
|
616
618
|
getLocalEmbeddingNativeMemoryStats
|
|
617
|
-
} from "./index-
|
|
619
|
+
} from "./index-bjcnntmz.js";
|
|
618
620
|
import {
|
|
619
621
|
saveEmbeddingIfHashMatches,
|
|
620
622
|
invalidateProject2,
|
|
@@ -622,7 +624,7 @@ import {
|
|
|
622
624
|
} from "./index-4dhv7mqz.js";
|
|
623
625
|
import {
|
|
624
626
|
cosineSimilarity
|
|
625
|
-
} from "./index-
|
|
627
|
+
} from "./index-24fezq97.js";
|
|
626
628
|
import {
|
|
627
629
|
computeCueContentHash,
|
|
628
630
|
hasMuralCueColumns,
|
|
@@ -647,7 +649,7 @@ import {
|
|
|
647
649
|
mergeMemoryStats2,
|
|
648
650
|
archiveMemory2,
|
|
649
651
|
getMemoryCountsByStatus2
|
|
650
|
-
} from "./index-
|
|
652
|
+
} from "./index-n37sebck.js";
|
|
651
653
|
import {
|
|
652
654
|
renderSingleStoreMigrationRequiredRefusal,
|
|
653
655
|
SingleStoreMigrationRequiredError,
|
|
@@ -663,23 +665,22 @@ import {
|
|
|
663
665
|
SubcModuleTransport,
|
|
664
666
|
indexCommitsForProject,
|
|
665
667
|
embedUnembeddedCommits,
|
|
666
|
-
withMessageFtsSessionFilter,
|
|
667
668
|
createUnifiedSearchDiagnostics2,
|
|
668
669
|
parseIdShapedQuery2,
|
|
669
670
|
resolveMemoriesByIdsForSearch2,
|
|
670
671
|
unifiedSearch2,
|
|
671
672
|
formatSearchResults2
|
|
672
|
-
} from "./index-
|
|
673
|
+
} from "./index-vrzjhftj.js";
|
|
673
674
|
import {
|
|
674
675
|
flushIgnoredMessages2,
|
|
675
676
|
clearIgnoredMessages2,
|
|
676
677
|
observeIgnoredNotificationEvent2,
|
|
677
678
|
sendStatusNotification2
|
|
678
|
-
} from "./index-
|
|
679
|
+
} from "./index-s74zqahq.js";
|
|
679
680
|
import {
|
|
680
681
|
setRecompStarting2,
|
|
681
682
|
setRecompTerminal2
|
|
682
|
-
} from "./index-
|
|
683
|
+
} from "./index-nkpmm9q8.js";
|
|
683
684
|
import {
|
|
684
685
|
makeToolCompositeKey,
|
|
685
686
|
searchMessageHistoryOffThread,
|
|
@@ -721,6 +722,7 @@ import {
|
|
|
721
722
|
prewarmTagOwners,
|
|
722
723
|
waitForTagOwners,
|
|
723
724
|
stripStructuralNoise,
|
|
725
|
+
withTransformTimingSummary,
|
|
724
726
|
logTransformTiming,
|
|
725
727
|
hasRecentAssistantCommit,
|
|
726
728
|
tagMessages,
|
|
@@ -732,7 +734,7 @@ import {
|
|
|
732
734
|
abortSessionFailClosed2,
|
|
733
735
|
evaluateEmergencyFailClosed2,
|
|
734
736
|
runPostTransformPhase2
|
|
735
|
-
} from "./index-
|
|
737
|
+
} from "./index-4yt7dtf4.js";
|
|
736
738
|
import {
|
|
737
739
|
ANNOUNCEMENT_VERSION2,
|
|
738
740
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -743,6 +745,9 @@ import {
|
|
|
743
745
|
import {
|
|
744
746
|
resolvePromptContext2
|
|
745
747
|
} from "./index-fmsr7v69.js";
|
|
748
|
+
import {
|
|
749
|
+
renderSearchArchiveOffThread2
|
|
750
|
+
} from "./index-kmdj7dsq.js";
|
|
746
751
|
import {
|
|
747
752
|
COMPACTION_ENABLED_PATH,
|
|
748
753
|
isDreamerRunnable,
|
|
@@ -11609,9 +11614,14 @@ async function indexSingleMessageOffThread(db, sessionId, message) {
|
|
|
11609
11614
|
return result.inserted;
|
|
11610
11615
|
}
|
|
11611
11616
|
async function sweepOrphanedOpenCodeMessageIndexesOffThread(db, openSource, options = {}) {
|
|
11617
|
+
if (getHarness2() === "opencode2")
|
|
11618
|
+
openSource = () => new Database2(gaDatabasePath(getDataDir(), process.env.OPENCODE_CHANNEL ?? "latest"), {
|
|
11619
|
+
readonly: true,
|
|
11620
|
+
fileMustExist: true
|
|
11621
|
+
});
|
|
11612
11622
|
const path = getSqliteDatabasePath2(db);
|
|
11613
|
-
if (!path || getHarness2() !== "opencode")
|
|
11614
|
-
return
|
|
11623
|
+
if (!path || getHarness2() !== "opencode" && getHarness2() !== "opencode2")
|
|
11624
|
+
return sweepOrphanedOpenCodeMessageIndexesCooperatively2(db, openSource, options);
|
|
11615
11625
|
let source = null;
|
|
11616
11626
|
let sourcePath = null;
|
|
11617
11627
|
try {
|
|
@@ -11623,7 +11633,7 @@ async function sweepOrphanedOpenCodeMessageIndexesOffThread(db, openSource, opti
|
|
|
11623
11633
|
source?.close();
|
|
11624
11634
|
}
|
|
11625
11635
|
if (!sourcePath)
|
|
11626
|
-
return
|
|
11636
|
+
return sweepOrphanedOpenCodeMessageIndexesCooperatively2(db, () => source, options);
|
|
11627
11637
|
const reply = await runSessionWarmupWorker({
|
|
11628
11638
|
path,
|
|
11629
11639
|
sessionId: "",
|
|
@@ -11822,7 +11832,7 @@ function runTick(origin) {
|
|
|
11822
11832
|
if (tickInFlight)
|
|
11823
11833
|
return;
|
|
11824
11834
|
tickInFlight = true;
|
|
11825
|
-
log2(`[
|
|
11835
|
+
log2(`[magic-context] maintenance tick (${origin}) — projects=${registeredProjects.size}`);
|
|
11826
11836
|
(async () => {
|
|
11827
11837
|
try {
|
|
11828
11838
|
const db = openTimerDatabaseOrNull("maintenance tick");
|
|
@@ -11872,6 +11882,9 @@ function persistTickOutcome(db, failure) {
|
|
|
11872
11882
|
}
|
|
11873
11883
|
}
|
|
11874
11884
|
async function runMessageHistoryMaintenance(db) {
|
|
11885
|
+
const prunedIdentities = await pruneMissingProjectIdentities();
|
|
11886
|
+
if (prunedIdentities > 0)
|
|
11887
|
+
log2(`[magic-context] pruned ${prunedIdentities} missing project identities`);
|
|
11875
11888
|
try {
|
|
11876
11889
|
await drainStaleLkgSlots(db);
|
|
11877
11890
|
} catch (error) {
|
|
@@ -12105,10 +12118,20 @@ async function sweepGitCommits(args) {
|
|
|
12105
12118
|
const holderId = crypto.randomUUID();
|
|
12106
12119
|
const lease = acquireGitSweepLease(db, projectIdentity, holderId);
|
|
12107
12120
|
if (!lease.acquired) {
|
|
12108
|
-
|
|
12121
|
+
if (lease.reason === "cooldown_active")
|
|
12122
|
+
return;
|
|
12123
|
+
const reason = `lease held by ${lease.leaseHolder ?? "another holder"} until ${lease.leaseExpiresAt ?? "unknown"}`;
|
|
12109
12124
|
log2(`[git-commits] sweep skipped for ${projectIdentity}: ${reason}`);
|
|
12110
12125
|
return;
|
|
12111
12126
|
}
|
|
12127
|
+
if (projectIdentity.startsWith("dir:")) {
|
|
12128
|
+
if (parkGitSweepNonIndexable(db, projectIdentity, holderId)) {
|
|
12129
|
+
log2(`[git-commits] sweep parked for ${projectIdentity}: directory identity has no commits`);
|
|
12130
|
+
} else {
|
|
12131
|
+
releaseGitSweepLease(db, projectIdentity, holderId);
|
|
12132
|
+
}
|
|
12133
|
+
return;
|
|
12134
|
+
}
|
|
12112
12135
|
const startedAt = Date.now();
|
|
12113
12136
|
const stopRenewal = startGitSweepLeaseRenewal(db, projectIdentity, holderId);
|
|
12114
12137
|
log2(`[git-commits] sweep starting for ${projectIdentity} (sinceDays=${gitCommitIndexing.since_days} maxCommits=${gitCommitIndexing.max_commits})`);
|
|
@@ -16270,8 +16293,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16270
16293
|
const db = readDatabase();
|
|
16271
16294
|
if (!db)
|
|
16272
16295
|
return { ok: false, error: "db unavailable" };
|
|
16273
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16274
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
16296
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-z3ecszx6.js"));
|
|
16297
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-6ve0e8p4.js"));
|
|
16275
16298
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
16276
16299
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
16277
16300
|
return {
|
|
@@ -16355,7 +16378,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16355
16378
|
const db = readDatabase();
|
|
16356
16379
|
if (!db)
|
|
16357
16380
|
return { ok: false, error: "db unavailable" };
|
|
16358
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16381
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-j7d7ry5b.js"));
|
|
16359
16382
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
16360
16383
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
16361
16384
|
const ctx = {
|
|
@@ -17848,6 +17871,7 @@ class HistorianHostRunner {
|
|
|
17848
17871
|
throw new Error("hidden completion carrier returned no session id");
|
|
17849
17872
|
const run = await promptSyncWithValidatedOutputRetry(undefined, {
|
|
17850
17873
|
path: { id: handle.id },
|
|
17874
|
+
cacheTail: "skip",
|
|
17851
17875
|
query: { directory: sessionDirectory },
|
|
17852
17876
|
body: {
|
|
17853
17877
|
agent: "historian",
|
|
@@ -17878,6 +17902,7 @@ class HistorianHostRunner {
|
|
|
17878
17902
|
timeoutMs: attemptMs,
|
|
17879
17903
|
signal,
|
|
17880
17904
|
fallbackModels: rest.map(withVariant),
|
|
17905
|
+
allowModelSuggestions: false,
|
|
17881
17906
|
callContext: `historian-host:${claim.runId}`,
|
|
17882
17907
|
fetchOutput: () => withinAttempt(executor.collect(handle, 50), attemptStartedAt + attemptMs - Date.now(), attemptMs, signal).catch((error) => {
|
|
17883
17908
|
recordAttempt(undefined, error);
|
|
@@ -23984,6 +24009,7 @@ function resolveTransformHostSeams(deps) {
|
|
|
23984
24009
|
hostRefuse: deps.hostRefuse ?? abortSessionFailClosed2
|
|
23985
24010
|
};
|
|
23986
24011
|
}
|
|
24012
|
+
var SIGNED_FIT_REFUSED_MARKER = "signed_fit:refused:v1";
|
|
23987
24013
|
function createTransform(deps) {
|
|
23988
24014
|
registerSystemDateRefresh(deps.historyRefreshSessions);
|
|
23989
24015
|
const finalWireUsage = createFinalWireUsageTracker();
|
|
@@ -24657,7 +24683,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24657
24683
|
const tagged = tagMessages(sessionId, tail, deps.tagger, db, {
|
|
24658
24684
|
skipPrefixInjection: !ctxReduceCallable,
|
|
24659
24685
|
servedMessages: messages,
|
|
24660
|
-
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText
|
|
24686
|
+
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText,
|
|
24687
|
+
refreshSourceContents: deps.refreshSourceContents?.(sessionId)
|
|
24661
24688
|
});
|
|
24662
24689
|
for (const [number, target] of tagged.targets)
|
|
24663
24690
|
targets.set(number, target);
|
|
@@ -24682,7 +24709,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24682
24709
|
skipPrefixInjection,
|
|
24683
24710
|
scopedToolSweep,
|
|
24684
24711
|
servedMessages: messages,
|
|
24685
|
-
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText
|
|
24712
|
+
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText,
|
|
24713
|
+
refreshSourceContents: deps.refreshSourceContents?.(sessionId)
|
|
24686
24714
|
});
|
|
24687
24715
|
targets = result.targets;
|
|
24688
24716
|
if (thinkingRecovery.restore)
|
|
@@ -24905,7 +24933,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24905
24933
|
const protectedTagIds = protectedTagNumbers;
|
|
24906
24934
|
const protectedCutoff = protectionWindow.cutoff;
|
|
24907
24935
|
const tPostProcess = performance.now();
|
|
24908
|
-
dropProjectionEmergency =
|
|
24936
|
+
dropProjectionEmergency = contextUsage.percentage >= 95;
|
|
24909
24937
|
const postTransformResult = await runPostTransformPhase2({
|
|
24910
24938
|
opencode2: deps.storeGeneration === "v2",
|
|
24911
24939
|
normalizeRecoveryTail,
|
|
@@ -24924,7 +24952,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24924
24952
|
client: deps.client,
|
|
24925
24953
|
activeAgent,
|
|
24926
24954
|
batch,
|
|
24927
|
-
contextUsage
|
|
24955
|
+
contextUsage,
|
|
24928
24956
|
usableWindow: resolvedContextLimit ?? 0,
|
|
24929
24957
|
schedulerDecision,
|
|
24930
24958
|
schedulerDeferReason,
|
|
@@ -25009,6 +25037,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25009
25037
|
postTransformResult.bustedThisPass = true;
|
|
25010
25038
|
passOutcome.markFinalized();
|
|
25011
25039
|
const finalWireTail = describeFinalWireTail(messages);
|
|
25040
|
+
const signedFitPreviouslyRefused = !compactionOff && getMergedReasoningStrippedIds(db, sessionId).has(SIGNED_FIT_REFUSED_MARKER);
|
|
25012
25041
|
let finalWireEstimate;
|
|
25013
25042
|
if (postTransformResult.bustedThisPass) {
|
|
25014
25043
|
try {
|
|
@@ -25026,7 +25055,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25026
25055
|
}
|
|
25027
25056
|
if (!compactionOff) {
|
|
25028
25057
|
const emergencyUsagePercentage = usagePercentageSynthetic ? Math.max(95, contextUsage.percentage) : windowGeometry?.usableHard && contextUsage.inputTokens > 0 ? contextUsage.inputTokens / windowGeometry.usableHard * 100 : contextUsage.percentage;
|
|
25029
|
-
finalWireEstimate = finalWireEstimate ?? (emergencyUsagePercentage >= 95 || schedulerDecision === "execute" ? finalWireUsage.estimate(sessionId, {
|
|
25058
|
+
finalWireEstimate = finalWireEstimate ?? (emergencyUsagePercentage >= 95 || schedulerDecision === "execute" || signedFitPreviouslyRefused ? finalWireUsage.estimate(sessionId, {
|
|
25030
25059
|
messages,
|
|
25031
25060
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
25032
25061
|
providerID: modelForBudget?.providerID,
|
|
@@ -25049,8 +25078,11 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25049
25078
|
}
|
|
25050
25079
|
return;
|
|
25051
25080
|
}
|
|
25052
|
-
if (thinkingFitRetries.has(sessionId) || postTransformResult.thinkingReleasedForFit)
|
|
25081
|
+
if (thinkingFitRetries.has(sessionId) || postTransformResult.thinkingReleasedForFit || signedFitPreviouslyRefused) {
|
|
25082
|
+
if (!signedFitPreviouslyRefused && !addMergedReasoningStrippedIds(db, sessionId, [SIGNED_FIT_REFUSED_MARKER]))
|
|
25083
|
+
throw contextRefusalError("Cannot persist the signed-fit refusal");
|
|
25053
25084
|
throw contextRefusalError("The request remains over the model window after stripping signed thinking and reclaiming context");
|
|
25085
|
+
}
|
|
25054
25086
|
}
|
|
25055
25087
|
if (postTransformResult.prefixTrimStatus === "refused") {
|
|
25056
25088
|
const untrimmed = finalWireEstimate ?? estimateFinalWireInputTokens({
|
|
@@ -25362,7 +25394,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25362
25394
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
25363
25395
|
});
|
|
25364
25396
|
};
|
|
25365
|
-
|
|
25397
|
+
const timedTransform = (input, output) => withTransformTimingSummary(() => transform(input, output));
|
|
25398
|
+
return Object.assign(timedTransform, {
|
|
25366
25399
|
clearSessionLogState,
|
|
25367
25400
|
invalidateRustWireState(sessionId) {
|
|
25368
25401
|
rustModeTransform?.invalidateWireState(sessionId);
|
|
@@ -25583,6 +25616,26 @@ function systemPromptDates(prompt, sticky) {
|
|
|
25583
25616
|
return { live: values.length ? JSON.stringify(values) : undefined, stable };
|
|
25584
25617
|
}
|
|
25585
25618
|
|
|
25619
|
+
// src/hooks/magic-context/system-prompt-diagnostics.ts
|
|
25620
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
25621
|
+
function snapshotSystemPrompt(system, preset) {
|
|
25622
|
+
return { elements: system.map((element) => Buffer.from(element)), preset };
|
|
25623
|
+
}
|
|
25624
|
+
function describeSystemPromptChange(previous, current) {
|
|
25625
|
+
const metadata = (element) => element === undefined ? "absent" : `bytes=${element.length},md5=${createHash13("md5").update(element).digest("hex")}`;
|
|
25626
|
+
const elements = [];
|
|
25627
|
+
for (let index = 0;index < Math.max(previous?.elements.length ?? 0, current.elements.length); index++) {
|
|
25628
|
+
const before = previous?.elements[index];
|
|
25629
|
+
const after = current.elements[index];
|
|
25630
|
+
let offset = 0;
|
|
25631
|
+
while (before && after && offset < Math.min(before.length, after.length) && before[offset] === after[offset])
|
|
25632
|
+
offset++;
|
|
25633
|
+
const status = !previous ? "unknown" : !before ? "added" : !after ? "removed" : before.equals(after) ? "unchanged" : "changed";
|
|
25634
|
+
elements.push(`${index}:${status}(${metadata(before)} -> ${metadata(after)},firstDiffByte=${!previous ? "unknown" : status === "unchanged" ? "none" : offset})`);
|
|
25635
|
+
}
|
|
25636
|
+
return `presetChanged=${previous ? previous.preset !== current.preset : "unknown"} elements=[${elements.join("; ")}]`;
|
|
25637
|
+
}
|
|
25638
|
+
|
|
25586
25639
|
// src/hooks/magic-context/system-prompt-hash.ts
|
|
25587
25640
|
var MAGIC_CONTEXT_MARKER = "## Magic Context";
|
|
25588
25641
|
var SYSTEM_PROMPT_GUIDANCE_SEPARATOR = `
|
|
@@ -25605,6 +25658,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
25605
25658
|
});
|
|
25606
25659
|
const guidanceEpochs = createPromptSurfaceGuidanceEpochCache(promptSurfaceRuntime);
|
|
25607
25660
|
const stickyDateBySession = new Map;
|
|
25661
|
+
const diagnosticPrompts = new Map;
|
|
25608
25662
|
const processSystemPrompt = async (input, output) => {
|
|
25609
25663
|
const sessionId = input.sessionID;
|
|
25610
25664
|
if (!sessionId)
|
|
@@ -25737,8 +25791,11 @@ function createSystemPromptHashHandler(deps) {
|
|
|
25737
25791
|
return;
|
|
25738
25792
|
}
|
|
25739
25793
|
const sessionMeta = sessionMetaEarly;
|
|
25794
|
+
const previousPrompt = diagnosticPrompts.get(sessionId);
|
|
25795
|
+
const currentPrompt = previousPrompt && previousHash === currentHash ? previousPrompt : snapshotSystemPrompt(output.system, promptSurface.preset);
|
|
25796
|
+
diagnosticPrompts.set(sessionId, currentPrompt);
|
|
25740
25797
|
if (previousHash !== "" && previousHash !== "0" && previousHash !== currentHash) {
|
|
25741
|
-
sessionLog2(sessionId, `system prompt hash changed: ${previousHash} → ${currentHash} (len=${systemContent.length}), ${idleCacheExpired ? "adopting on idle-expired request" : requestMessagesFinal ? "adopting on the request whose messages are already final" : "triggering flush"}`);
|
|
25798
|
+
sessionLog2(sessionId, `system prompt hash changed: ${previousHash} → ${currentHash} (len=${systemContent.length}), ${idleCacheExpired ? "adopting on idle-expired request" : requestMessagesFinal ? "adopting on the request whose messages are already final" : "triggering flush"}; ${describeSystemPromptChange(previousPrompt, currentPrompt)}`);
|
|
25742
25799
|
noteSystemPromptHashChange(sessionId);
|
|
25743
25800
|
if (!adoptSystemChange) {
|
|
25744
25801
|
deps.historyRefreshSessions.add(sessionId);
|
|
@@ -25782,6 +25839,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
25782
25839
|
return {
|
|
25783
25840
|
handler,
|
|
25784
25841
|
clearSession: (sessionId) => {
|
|
25842
|
+
diagnosticPrompts.delete(sessionId);
|
|
25785
25843
|
clearSystemDateRefresh(deps.historyRefreshSessions, sessionId);
|
|
25786
25844
|
guidanceEpochs.clear(sessionId);
|
|
25787
25845
|
clearSystemPromptHashSession(sessionId, {
|
|
@@ -26510,7 +26568,7 @@ function resolveCtxExpandMode(args, domain) {
|
|
|
26510
26568
|
}
|
|
26511
26569
|
|
|
26512
26570
|
// src/tools/ctx-expand/render.ts
|
|
26513
|
-
import { createHash as
|
|
26571
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
26514
26572
|
function isRecord4(value) {
|
|
26515
26573
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
26516
26574
|
}
|
|
@@ -26734,61 +26792,11 @@ function renderItemByTag(db, sessionId, number, textIndexDomain = "part") {
|
|
|
26734
26792
|
const index = scoped ? Number(scoped[2]) : 0;
|
|
26735
26793
|
const piText = message.parts.filter((part) => isRecord4(part) && part.type === "text");
|
|
26736
26794
|
const part = message.parts[index];
|
|
26737
|
-
const matching = derived ? piText.filter((part) => isRecord4(part) && typeof part.text === "string" &&
|
|
26795
|
+
const matching = derived ? piText.filter((part) => isRecord4(part) && typeof part.text === "string" && createHash14("sha256").update(part.text).digest("hex") === derived[3]) : [];
|
|
26738
26796
|
const selected = derived ? matching[Number(derived[4])] : textIndexDomain === "text" ? piText[index] : part;
|
|
26739
26797
|
return selected ? renderPartFull(selected) ?? "" : `Tag ${number}'s original text part is no longer in stored history.`;
|
|
26740
26798
|
}
|
|
26741
26799
|
|
|
26742
|
-
// src/tools/ctx-expand/search-archive.ts
|
|
26743
|
-
function renderSearchArchive(db, sessionId, start, end, tokenBudget, archiveOnly = false) {
|
|
26744
|
-
return withMessageFtsSessionFilter(db, sessionId, (sessionFirst) => {
|
|
26745
|
-
let rawIds;
|
|
26746
|
-
const rows = db.prepare(sessionFirst ? `SELECT f.message_ordinal AS ordinal, f.message_id AS id, f.role, f.content
|
|
26747
|
-
FROM message_fts_rowid_map AS m
|
|
26748
|
-
JOIN message_history_fts AS f ON f.rowid = m.fts_rowid
|
|
26749
|
-
WHERE m.session_id = ?1 AND m.message_ordinal BETWEEN ?2 AND ?3
|
|
26750
|
-
AND f.session_id = ?1 AND f.message_ordinal BETWEEN ?2 AND ?3
|
|
26751
|
-
ORDER BY m.message_ordinal` : `SELECT message_ordinal AS ordinal, message_id AS id, role, content
|
|
26752
|
-
FROM message_history_fts
|
|
26753
|
-
WHERE session_id = ?1 AND message_ordinal BETWEEN ?2 AND ?3
|
|
26754
|
-
ORDER BY CAST(message_ordinal AS INTEGER)`);
|
|
26755
|
-
const blocks = [];
|
|
26756
|
-
let tokens = 0;
|
|
26757
|
-
let lastOrdinal = start - 1;
|
|
26758
|
-
let truncated = false;
|
|
26759
|
-
for (const row of rows.iterate(sessionId, start, end)) {
|
|
26760
|
-
if (!row.content)
|
|
26761
|
-
continue;
|
|
26762
|
-
if (!archiveOnly) {
|
|
26763
|
-
rawIds ??= readRawSessionMessageIdOrdinalsForRange2(sessionId, start, end);
|
|
26764
|
-
if (rawIds.get(row.id) === row.ordinal)
|
|
26765
|
-
continue;
|
|
26766
|
-
}
|
|
26767
|
-
const block = `[${row.ordinal}] ${row.role === "user" ? "U" : "A"}: ${row.content}`;
|
|
26768
|
-
const cost = estimateTokens(block);
|
|
26769
|
-
if (blocks.length > 0 && tokens + cost > tokenBudget) {
|
|
26770
|
-
truncated = true;
|
|
26771
|
-
break;
|
|
26772
|
-
}
|
|
26773
|
-
blocks.push(block);
|
|
26774
|
-
tokens += cost;
|
|
26775
|
-
lastOrdinal = row.ordinal;
|
|
26776
|
-
}
|
|
26777
|
-
if (blocks.length === 0)
|
|
26778
|
-
return null;
|
|
26779
|
-
const text = [
|
|
26780
|
-
"From the search archive: indexed text only; no surrounding messages or tool output.",
|
|
26781
|
-
"",
|
|
26782
|
-
...blocks
|
|
26783
|
-
];
|
|
26784
|
-
if (truncated) {
|
|
26785
|
-
text.push("", `Truncated at message ${lastOrdinal} (budget: ~${tokenBudget} tokens). Call ctx_expand(start=${lastOrdinal + 1}, end=${end}) for more archived text.`);
|
|
26786
|
-
}
|
|
26787
|
-
return text.join(`
|
|
26788
|
-
`);
|
|
26789
|
-
});
|
|
26790
|
-
}
|
|
26791
|
-
|
|
26792
26800
|
// src/tools/ctx-expand/tools.ts
|
|
26793
26801
|
var ctxExpandArgsShape = {
|
|
26794
26802
|
tag: tool.schema.union([tool.schema.number(), tool.schema.string()]).optional().describe("Tag number from a §N§ tag or a [dropped §N§] placeholder, not a message ordinal. Returns that one item in full. Use alone."),
|
|
@@ -26822,7 +26830,7 @@ function createCtxExpandTool(deps) {
|
|
|
26822
26830
|
return renderItemByTag(deps.db, sessionId, mode.tag);
|
|
26823
26831
|
}
|
|
26824
26832
|
if (mode.kind === "message") {
|
|
26825
|
-
return
|
|
26833
|
+
return await renderSearchArchiveOffThread2(deps.db, sessionId, mode.message, mode.message, CTX_EXPAND_TOKEN_BUDGET) ?? renderMessageByOrdinal(sessionId, mode.message);
|
|
26826
26834
|
}
|
|
26827
26835
|
const { start, end, verbose } = mode;
|
|
26828
26836
|
const lastCompartmentEnd = getLastCompartmentEndMessage(deps.db, sessionId);
|
|
@@ -26830,7 +26838,7 @@ function createCtxExpandTool(deps) {
|
|
|
26830
26838
|
return `Range ${start}-${end} is entirely within the live tail (after the last compacted message ${lastCompartmentEnd}); those messages are already visible in context.`;
|
|
26831
26839
|
}
|
|
26832
26840
|
const effectiveEnd = lastCompartmentEnd >= 0 ? Math.min(end, lastCompartmentEnd) : end;
|
|
26833
|
-
const archived =
|
|
26841
|
+
const archived = await renderSearchArchiveOffThread2(deps.db, sessionId, start, effectiveEnd, CTX_EXPAND_TOKEN_BUDGET);
|
|
26834
26842
|
if (archived)
|
|
26835
26843
|
return archived;
|
|
26836
26844
|
if (verbose) {
|
|
@@ -28340,7 +28348,7 @@ function formatCtxReduceReply(stampedCount, selfStampCount = 0) {
|
|
|
28340
28348
|
return parts.join(" ");
|
|
28341
28349
|
}
|
|
28342
28350
|
// src/tools/ctx-reduce/tools.ts
|
|
28343
|
-
import { createHash as
|
|
28351
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
28344
28352
|
import { tool as tool4 } from "@opencode-ai/plugin";
|
|
28345
28353
|
|
|
28346
28354
|
// src/features/magic-context/range-parser.ts
|
|
@@ -28404,11 +28412,11 @@ function createCtxReduceTool(deps) {
|
|
|
28404
28412
|
const stableId = `oc-${sessionId}-${callId}`;
|
|
28405
28413
|
if (Buffer.byteLength(stableId) <= 128)
|
|
28406
28414
|
return stableId;
|
|
28407
|
-
return `oc-${
|
|
28415
|
+
return `oc-${createHash15("sha256").update(stableId).digest("hex")}`;
|
|
28408
28416
|
}
|
|
28409
28417
|
fallbackCommandSequence += 1;
|
|
28410
28418
|
const monotonicId = `oc-${sessionId}-${fallbackCommandSequence}`;
|
|
28411
|
-
return Buffer.byteLength(monotonicId) <= 128 ? monotonicId : `oc-${
|
|
28419
|
+
return Buffer.byteLength(monotonicId) <= 128 ? monotonicId : `oc-${createHash15("sha256").update(monotonicId).digest("hex")}`;
|
|
28412
28420
|
};
|
|
28413
28421
|
return tool4({
|
|
28414
28422
|
description: CTX_REDUCE_DESCRIPTION,
|
|
@@ -28815,7 +28823,58 @@ function applyJsonSchemaParameterDescriptions(toolId, input, preset, smartNotesE
|
|
|
28815
28823
|
|
|
28816
28824
|
// src/shared/rpc-server.ts
|
|
28817
28825
|
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
28818
|
-
import { readdirSync as readdirSync2, readFileSync as readFileSync6, unlinkSync } from "node:fs";
|
|
28826
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync6, rmdirSync, unlinkSync } from "node:fs";
|
|
28827
|
+
|
|
28828
|
+
// src/shared/rpc-discovery-cleanup.ts
|
|
28829
|
+
import { promises as fs } from "node:fs";
|
|
28830
|
+
import { join as join7 } from "node:path";
|
|
28831
|
+
async function reapDeadRpcDiscovery(storageDir) {
|
|
28832
|
+
const root = join7(storageDir, "rpc");
|
|
28833
|
+
let directories;
|
|
28834
|
+
try {
|
|
28835
|
+
directories = await fs.readdir(root, { withFileTypes: true });
|
|
28836
|
+
} catch {
|
|
28837
|
+
return;
|
|
28838
|
+
}
|
|
28839
|
+
const records = [];
|
|
28840
|
+
const projectDirs = [];
|
|
28841
|
+
for (const entry of directories) {
|
|
28842
|
+
if (!entry.isDirectory() || !/^[0-9a-f]{16}$/.test(entry.name))
|
|
28843
|
+
continue;
|
|
28844
|
+
const directory = join7(root, entry.name);
|
|
28845
|
+
projectDirs.push(directory);
|
|
28846
|
+
try {
|
|
28847
|
+
for (const name of await fs.readdir(directory)) {
|
|
28848
|
+
const match = /^port-(\d+)(?:-[0-9a-f]+)?\.json$/.exec(name);
|
|
28849
|
+
if (!match)
|
|
28850
|
+
continue;
|
|
28851
|
+
const path = join7(directory, name);
|
|
28852
|
+
try {
|
|
28853
|
+
const content = await fs.readFile(path, "utf8");
|
|
28854
|
+
const record = parseRpcPortFile(content, Number(match[1]));
|
|
28855
|
+
if (record && record.pid === Number(match[1]))
|
|
28856
|
+
records.push({ path, content, pid: record.pid });
|
|
28857
|
+
} catch {}
|
|
28858
|
+
}
|
|
28859
|
+
} catch {}
|
|
28860
|
+
}
|
|
28861
|
+
const processes = records.length ? await inspectProcessesAsync(true) : undefined;
|
|
28862
|
+
for (const record of records) {
|
|
28863
|
+
if (processes?.liveness(record.pid) !== "dead")
|
|
28864
|
+
continue;
|
|
28865
|
+
try {
|
|
28866
|
+
if (await fs.readFile(record.path, "utf8") === record.content)
|
|
28867
|
+
await fs.unlink(record.path);
|
|
28868
|
+
} catch {}
|
|
28869
|
+
}
|
|
28870
|
+
for (const directory of projectDirs) {
|
|
28871
|
+
try {
|
|
28872
|
+
await fs.rmdir(directory);
|
|
28873
|
+
} catch {}
|
|
28874
|
+
}
|
|
28875
|
+
}
|
|
28876
|
+
|
|
28877
|
+
// src/shared/rpc-server.ts
|
|
28819
28878
|
var MAX_BODY_BYTES = 1048576;
|
|
28820
28879
|
var WS_AUTH_TIMEOUT_MS = 5000;
|
|
28821
28880
|
var WS_CLOSE_UNAUTHORIZED = 4401;
|
|
@@ -28838,17 +28897,20 @@ function websocketToken(req) {
|
|
|
28838
28897
|
}
|
|
28839
28898
|
|
|
28840
28899
|
class MagicContextRpcServer {
|
|
28900
|
+
storageDir;
|
|
28841
28901
|
server = null;
|
|
28842
28902
|
port = 0;
|
|
28843
28903
|
handlers = new Map;
|
|
28844
28904
|
portFilePath;
|
|
28845
28905
|
portDir;
|
|
28846
28906
|
startedAt = Date.now();
|
|
28907
|
+
stopped = false;
|
|
28847
28908
|
instanceId = randomBytes(8).toString("hex");
|
|
28848
28909
|
unregisterOwnInstance = null;
|
|
28849
28910
|
sockets = new Set;
|
|
28850
28911
|
token = randomBytes(32).toString("hex");
|
|
28851
28912
|
constructor(storageDir, directory) {
|
|
28913
|
+
this.storageDir = storageDir;
|
|
28852
28914
|
this.portFilePath = rpcPortFilePath(storageDir, directory, process.pid, this.instanceId);
|
|
28853
28915
|
this.portDir = rpcPortDir(storageDir, directory);
|
|
28854
28916
|
}
|
|
@@ -28866,6 +28928,10 @@ class MagicContextRpcServer {
|
|
|
28866
28928
|
log2("rpc server skipped: Bun runtime not available (no TUI consumer)");
|
|
28867
28929
|
return 0;
|
|
28868
28930
|
}
|
|
28931
|
+
this.stopped = false;
|
|
28932
|
+
await reapDeadRpcDiscovery(this.storageDir);
|
|
28933
|
+
if (this.stopped)
|
|
28934
|
+
return 0;
|
|
28869
28935
|
this.startedAt = Date.now();
|
|
28870
28936
|
const self = this;
|
|
28871
28937
|
const server = inRootAsyncContext2(() => Bun.serve({
|
|
@@ -28897,7 +28963,7 @@ class MagicContextRpcServer {
|
|
|
28897
28963
|
try {
|
|
28898
28964
|
this.warnIfOtherLiveInstance();
|
|
28899
28965
|
this.unregisterOwnInstance ??= registerOwnRpcServerInstance(this.instanceId);
|
|
28900
|
-
writeStorageFileAtomicSync(this.portFilePath, JSON.stringify({
|
|
28966
|
+
const publish = () => writeStorageFileAtomicSync(this.portFilePath, JSON.stringify({
|
|
28901
28967
|
port: this.port,
|
|
28902
28968
|
pid: process.pid,
|
|
28903
28969
|
started_at: this.startedAt,
|
|
@@ -28905,6 +28971,13 @@ class MagicContextRpcServer {
|
|
|
28905
28971
|
token: this.token,
|
|
28906
28972
|
instance_id: this.instanceId
|
|
28907
28973
|
}));
|
|
28974
|
+
try {
|
|
28975
|
+
publish();
|
|
28976
|
+
} catch (error) {
|
|
28977
|
+
if (error.code !== "ENOENT")
|
|
28978
|
+
throw error;
|
|
28979
|
+
publish();
|
|
28980
|
+
}
|
|
28908
28981
|
log2(`[rpc] server listening on 127.0.0.1:${this.port}`);
|
|
28909
28982
|
} catch (err) {
|
|
28910
28983
|
log2(`[rpc] failed to write port file: ${err}`);
|
|
@@ -28912,6 +28985,7 @@ class MagicContextRpcServer {
|
|
|
28912
28985
|
return this.port;
|
|
28913
28986
|
}
|
|
28914
28987
|
stop() {
|
|
28988
|
+
this.stopped = true;
|
|
28915
28989
|
for (const ws of this.sockets) {
|
|
28916
28990
|
try {
|
|
28917
28991
|
if (ws.data.authTimer)
|
|
@@ -28928,6 +29002,9 @@ class MagicContextRpcServer {
|
|
|
28928
29002
|
try {
|
|
28929
29003
|
unlinkSync(this.portFilePath);
|
|
28930
29004
|
} catch {}
|
|
29005
|
+
try {
|
|
29006
|
+
rmdirSync(this.portDir);
|
|
29007
|
+
} catch {}
|
|
28931
29008
|
this.unregisterOwnInstance?.();
|
|
28932
29009
|
this.unregisterOwnInstance = null;
|
|
28933
29010
|
}
|
|
@@ -29075,7 +29152,7 @@ function json(body, status = 200) {
|
|
|
29075
29152
|
// src/shared/models-dev-temperature.ts
|
|
29076
29153
|
import { readFileSync as readFileSync7, statSync as statSync4 } from "node:fs";
|
|
29077
29154
|
import { homedir as homedir2 } from "node:os";
|
|
29078
|
-
import { join as
|
|
29155
|
+
import { join as join8 } from "node:path";
|
|
29079
29156
|
var CATALOG_PROVIDER_ALIASES = {
|
|
29080
29157
|
"google-antigravity": "google",
|
|
29081
29158
|
"opencode-zen": "opencode"
|
|
@@ -29085,7 +29162,7 @@ var cached;
|
|
|
29085
29162
|
function modelsDevCatalogPath(env = process.env) {
|
|
29086
29163
|
if (env.OPENCODE_MODELS_PATH)
|
|
29087
29164
|
return env.OPENCODE_MODELS_PATH;
|
|
29088
|
-
return
|
|
29165
|
+
return join8(env.XDG_CACHE_HOME || join8(homedir2(), ".cache"), "opencode", "models.json");
|
|
29089
29166
|
}
|
|
29090
29167
|
function buildIndex(raw) {
|
|
29091
29168
|
const index = new Map;
|