@cortexkit/opencode-magic-context 0.49.16 → 0.49.18
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 +11 -11
- 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 +394 -394
- package/dist/{conflict-warning-hook-znry4j76.js → conflict-warning-hook-4pmz879v.js} +5 -5
- package/dist/{context-3znk23va.js → context-m897gfp9.js} +304 -145
- package/dist/{embedding-backfill-q4n8dend.js → embedding-backfill-fmz50tsy.js} +11 -11
- package/dist/embedding-worker-process.js +1 -1
- package/dist/embedding-worker.js +4 -4
- 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-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/search.d.ts +6 -1
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-host-instruction-retention.d.ts +11 -0
- package/dist/features/magic-context/storage-host-instruction-retention.d.ts.map +1 -0
- package/dist/features/magic-context/storage-meta-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/cache-busting-signals.d.ts +22 -1
- package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -0
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +4 -2
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/file-token-coverage.d.ts +11 -0
- package/dist/hooks/magic-context/file-token-coverage.d.ts.map +1 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +9 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/host-served-rows.d.ts +25 -0
- package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +7 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/pass-outcome.d.ts +2 -0
- package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +2 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/signed-thinking-hold.d.ts +59 -0
- package/dist/hooks/magic-context/signed-thinking-hold.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-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-content-primitives.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-compartment-phase.d.ts +6 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-context-state.d.ts +19 -0
- package/dist/hooks/magic-context/transform-context-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +19 -0
- 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-9nkg2dzk.js → index-24fezq97.js} +3 -3
- package/dist/{index-v9asb16b.js → index-24jbw52d.js} +5 -5
- package/dist/{index-a8bvhwqs.js → index-2vxtcb95.js} +32 -3
- package/dist/{index-f71thw8j.js → index-4s3t0nd0.js} +1 -1
- package/dist/{index-6a6dq53h.js → index-6s5941tm.js} +5 -5
- package/dist/{index-fkx2qnvw.js → index-6x57ar45.js} +2 -2
- package/dist/{index-ek1yxvvz.js → index-936py2wm.js} +361 -70
- package/dist/{index-dqe8pq4x.js → index-a6mc0v4d.js} +6 -3
- package/dist/{index-hehkf6zm.js → index-b5vqckbw.js} +12 -6
- package/dist/{v2/server-wafzvyhg.js → index-beht37jy.js} +8 -0
- package/dist/{index-7b2cfmaz.js → index-bjcnntmz.js} +2 -2
- package/dist/{index-hqkczed7.js → index-c5pytzne.js} +22 -2
- package/dist/{index-nd7m2a5a.js → index-cf74k5ak.js} +27 -5
- package/dist/{index-kn4t1haw.js → index-e4xv8890.js} +531 -253
- package/dist/{index-cj9g0j7a.js → index-fgncb0ng.js} +7 -7
- package/dist/{index-5mwk1nek.js → index-jn12fvvh.js} +1 -1
- package/dist/{index-n6m03s3n.js → index-ke416mdc.js} +1 -1
- package/dist/{index-mtw9e71a.js → index-kq82mtg0.js} +2 -2
- package/dist/{index-n78avt2p.js → index-n37sebck.js} +1 -1
- package/dist/{index-wk0n1cgt.js → index-qn7xstt2.js} +2 -2
- package/dist/{index-v63beg1z.js → index-r4nkrs05.js} +3 -3
- package/dist/{index-j6zw70pf.js → index-rmwykbbb.js} +60 -21
- package/dist/{index-saews2s3.js → index-rr2bb45z.js} +1 -1
- package/dist/{index-ayym1x7f.js → index-s1ex9y6p.js} +195 -748
- package/dist/{index-7pa32z07.js → index-s734jcsr.js} +1 -1
- package/dist/{index-b17m64g9.js → index-s74zqahq.js} +1 -1
- package/dist/{index-4qfy7v57.js → index-s7j8tvhv.js} +31 -20
- package/dist/{index-wv9n2zcq.js → index-v8awdgvd.js} +4 -4
- package/dist/{index-p4vde22c.js → index-x4njr8df.js} +965 -77
- package/dist/{index-qrahzcqv.js → index-ze7mvk54.js} +10 -7
- package/dist/index.js +39 -39
- package/dist/{message-fts-rowid-map-yvx5a9jw.js → message-fts-rowid-map-17s0dfn4.js} +5 -3
- package/dist/{message-index-t4pz7akd.js → message-index-66jv6fh4.js} +13 -13
- package/dist/{message-index-bounded-6th8djy9.js → message-index-bounded-n1frdn85.js} +17 -17
- package/dist/{message-time-backfill-8egzkd3z.js → message-time-backfill-73mmm76q.js} +1 -1
- package/dist/migration-worker.js +8 -8
- 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-2dea0a77.js → project-embedding-registry-z74mhqkf.js} +10 -10
- package/dist/raw-ordinal-warmup-worker.js +10 -10
- package/dist/{read-session-chunk-4pwqxm5a.js → read-session-chunk-v06g3vka.js} +7 -7
- package/dist/{read-session-raw-5ar8se5v.js → read-session-raw-rsc8c7qy.js} +2 -2
- package/dist/{recomp-orchestrator-tjcaj5x7.js → recomp-orchestrator-ghpk2dtq.js} +24 -24
- package/dist/{search-archive-02jws7hw.js → search-archive-4d53y23e.js} +8 -8
- package/dist/{search-rb01n29x.js → search-nkf271d4.js} +20 -20
- package/dist/{send-session-notification-2x9edkrp.js → send-session-notification-6ve0e8p4.js} +4 -4
- 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 +2 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- 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-4z1w27xa.js → storage-tags-r7k9tjcv.js} +8 -4
- package/dist/{transform-postprocess-phase-xaw5c3xp.js → transform-postprocess-phase-zpgav0h7.js} +24 -24
- package/dist/v2/auto-search-worker.js +76 -63
- package/dist/v2/chunk-embedding-write-worker.js +11 -11
- 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-acw1nhv8.js → context-f2xh7ba4.js} +1171 -448
- package/dist/v2/embedding-backfill-7c7yr69y.js +23 -0
- package/dist/v2/embedding-worker-process.js +1 -1
- package/dist/v2/embedding-worker.js +4 -4
- 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/payload.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-8vf0v7cr.js → message-fts-rowid-map-wfx67gfd.js} +5 -3
- package/dist/v2/{message-index-e6qzw477.js → message-index-48f7hw7a.js} +13 -13
- package/dist/v2/{message-index-bounded-dsrf49y7.js → message-index-bounded-w3hfm29z.js} +17 -17
- package/dist/v2/{message-time-backfill-q5pgxf0d.js → message-time-backfill-04t0km1z.js} +1 -1
- package/dist/v2/migration-worker.js +8 -8
- package/dist/v2/{project-embedding-registry-rek75aqw.js → project-embedding-registry-gnkj56xp.js} +10 -10
- package/dist/v2/raw-ordinal-warmup-worker.js +10 -10
- package/dist/v2/{read-session-chunk-7bpygfv2.js → read-session-chunk-zpgmxwte.js} +7 -7
- package/dist/v2/{read-session-raw-pw2n1qgc.js → read-session-raw-yaegtjzh.js} +2 -2
- package/dist/v2/{recomp-orchestrator-hzpgg06e.js → recomp-orchestrator-4vfxej9t.js} +24 -24
- package/dist/v2/{search-archive-fn4wy8sx.js → search-archive-vv48s2aa.js} +8 -8
- package/dist/v2/{search-sf2vg5pk.js → search-kza414f0.js} +20 -20
- package/dist/v2/{send-session-notification-hmr7q0nt.js → send-session-notification-3pxn658x.js} +4 -4
- package/dist/v2/{server-n5q841qn.js → server-1nyybqan.js} +31 -20
- package/dist/v2/{server-785mb90s.js → server-1wy7b9de.js} +6 -3
- package/dist/v2/{server-0mzjjw3s.js → server-27gq4mfz.js} +27 -5
- package/dist/v2/{server-g59aatsz.js → server-2ehj0bw7.js} +965 -77
- package/dist/v2/{server-kqpawe1a.js → server-46neh5fa.js} +12 -6
- package/dist/v2/{server-rrqpvwqd.js → server-6tmj0s7j.js} +2 -2
- package/dist/v2/{server-kr2kc9dz.js → server-8by8qfec.js} +10 -7
- package/dist/v2/{server-r9gjxcte.js → server-a2eqhkxr.js} +7 -7
- 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-6fyp0v67.js → server-bfpda1tb.js} +195 -749
- package/dist/v2/{server-05xjtq6c.js → server-d04vrx0j.js} +1 -1
- package/dist/v2/{server-zs8d0s3b.js → server-g3qma5c0.js} +1 -1
- package/dist/v2/{server-00hx04yn.js → server-gpvay0xz.js} +2 -2
- package/dist/v2/{server-gha9x4qq.js → server-h1v0pyxb.js} +2 -2
- package/dist/v2/{server-hgg55hde.js → server-hy3d3vsx.js} +1 -1
- package/dist/v2/{server-vgpab6rd.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-y5pznjt9.js → server-nj659894.js} +5 -5
- package/dist/v2/{server-zyw55ygv.js → server-qv7f0hhe.js} +5 -5
- package/dist/v2/{server-e3ftpk7v.js → server-rmygf5pn.js} +32 -3
- package/dist/v2/{server-0ppsweh6.js → server-tgnbmwah.js} +22 -2
- package/dist/v2/{server-1hcbw661.js → server-xhab8jx8.js} +60 -21
- package/dist/v2/{server-6714jebr.js → server-xj136kt8.js} +1 -1
- package/dist/v2/{server-aavz8pm6.js → server-zzkj2fch.js} +3 -3
- package/dist/v2/server.js +4 -4
- 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-hkwtbp3g.js → storage-tags-3wdb8zph.js} +8 -4
- package/dist/v2/store-reader.d.ts +8 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{wrapup-orchestrator-x4xj1782.js → wrapup-orchestrator-psqz7yh0.js} +24 -24
- package/dist/wrapup-orchestrator-s9zc5b00.js +48 -0
- package/package.json +1 -1
- package/src/config/latch-permanence-guard.test.ts +4 -0
- package/src/shared/historian-cache.test.ts +69 -0
- package/src/shared/historian-cache.ts +55 -0
- package/src/shared/model-suggestion-retry.ts +2 -0
- 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/v2/embedding-backfill-jyd6492b.js +0 -23
- package/dist/wrapup-orchestrator-vj2tbp22.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-cf74k5ak.js";
|
|
147
148
|
import {
|
|
148
149
|
observeTemporalDecisions,
|
|
149
150
|
stableStringify
|
|
@@ -167,7 +168,7 @@ import {
|
|
|
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,9 +176,11 @@ import {
|
|
|
175
176
|
latestPersistedMessageForRecovery,
|
|
176
177
|
latestRealUserTurnIdFromOpenCodeDb,
|
|
177
178
|
findLastAssistantModelFromOpenCodeDb
|
|
178
|
-
} from "./index-
|
|
179
|
+
} from "./index-kq82mtg0.js";
|
|
179
180
|
import {
|
|
180
181
|
expandToolPart,
|
|
182
|
+
takeCoveredInstructionRows,
|
|
183
|
+
cloneKeepingCoveredInstructionMarks,
|
|
181
184
|
estimateTrueRawMessageTokens,
|
|
182
185
|
isTextPart,
|
|
183
186
|
toolPartHasUserAnswer,
|
|
@@ -267,6 +270,7 @@ import {
|
|
|
267
270
|
snapshotTrailingBlankSourceDecisions,
|
|
268
271
|
projectOpencodeReasoningBudgetCutoff,
|
|
269
272
|
resolveKeepReasoningTokens,
|
|
273
|
+
reasoningStepCost,
|
|
270
274
|
reasoningBudgetCutoff,
|
|
271
275
|
describeFinalWireTail,
|
|
272
276
|
estimateMessageTokens,
|
|
@@ -296,10 +300,10 @@ import {
|
|
|
296
300
|
readRawSessionMessageById2,
|
|
297
301
|
readSessionChunk2,
|
|
298
302
|
readRawSessionSeedTail2
|
|
299
|
-
} from "./index-
|
|
303
|
+
} from "./index-rmwykbbb.js";
|
|
300
304
|
import {
|
|
301
305
|
getMeasuredToolDefinitionTokens
|
|
302
|
-
} from "./index-
|
|
306
|
+
} from "./index-ke416mdc.js";
|
|
303
307
|
import {
|
|
304
308
|
isFailClosedBlockingError,
|
|
305
309
|
shouldBypassFailClosedBlock,
|
|
@@ -313,7 +317,7 @@ import {
|
|
|
313
317
|
runSqliteOptimize,
|
|
314
318
|
openDatabase,
|
|
315
319
|
openCurrentDatabase
|
|
316
|
-
} from "./index-
|
|
320
|
+
} from "./index-fgncb0ng.js";
|
|
317
321
|
import {
|
|
318
322
|
registerOwnRpcServerInstance,
|
|
319
323
|
rpcPortDir,
|
|
@@ -332,7 +336,7 @@ import {
|
|
|
332
336
|
resolveStoredPathWorkspaceIdentity,
|
|
333
337
|
storedPathBelongsToWorkspace,
|
|
334
338
|
computeWorkspaceEpochFingerprint
|
|
335
|
-
} from "./index-
|
|
339
|
+
} from "./index-qn7xstt2.js";
|
|
336
340
|
import {
|
|
337
341
|
V2_MEMORY_CATEGORIES,
|
|
338
342
|
CATEGORY_PRIORITY
|
|
@@ -366,6 +370,7 @@ import {
|
|
|
366
370
|
retryPendingSessionCleanups,
|
|
367
371
|
retryPendingRustSessionCleanupsForProject,
|
|
368
372
|
requestPendingMaterialization,
|
|
373
|
+
hasPendingMaterializationOrigin,
|
|
369
374
|
clearPendingMaterialization,
|
|
370
375
|
recordSystemPromptForRequest,
|
|
371
376
|
recordHeldHeadForRequest,
|
|
@@ -492,6 +497,7 @@ import {
|
|
|
492
497
|
onNoteTrigger,
|
|
493
498
|
clearNoteNudgeTriggerAndCooldown,
|
|
494
499
|
resetNoteNudgeCooldownOnly,
|
|
500
|
+
omitIncompleteFileTokenTotals,
|
|
495
501
|
RECOVERY_NO_HEAD_LIMIT,
|
|
496
502
|
deriveProtectedTailTokenTarget,
|
|
497
503
|
selectPerRunCap,
|
|
@@ -503,7 +509,7 @@ import {
|
|
|
503
509
|
snapRangeToCompartments,
|
|
504
510
|
getActiveCompartmentRun,
|
|
505
511
|
startCompartmentAgent
|
|
506
|
-
} from "./index-
|
|
512
|
+
} from "./index-s1ex9y6p.js";
|
|
507
513
|
import {
|
|
508
514
|
embedPauseBySession,
|
|
509
515
|
embedRunStateBySession,
|
|
@@ -531,7 +537,7 @@ import {
|
|
|
531
537
|
embedSessionCompartmentChunks2,
|
|
532
538
|
getEmbeddingCoverageStatus2,
|
|
533
539
|
getAutoEmbeddingSessionCoverage2
|
|
534
|
-
} from "./index-
|
|
540
|
+
} from "./index-ze7mvk54.js";
|
|
535
541
|
import {
|
|
536
542
|
SubcClient,
|
|
537
543
|
connectionFileExists,
|
|
@@ -539,7 +545,7 @@ import {
|
|
|
539
545
|
toSynapseLaneDescriptor,
|
|
540
546
|
formatSynapseLaneDescriptor,
|
|
541
547
|
SynapseEmbeddingProvider
|
|
542
|
-
} from "./index-
|
|
548
|
+
} from "./index-6x57ar45.js";
|
|
543
549
|
import {
|
|
544
550
|
BoundedSessionMap,
|
|
545
551
|
LkgRecoveryFenceError,
|
|
@@ -551,6 +557,7 @@ import {
|
|
|
551
557
|
prepareLkgCaptureFence,
|
|
552
558
|
certifyCommittedLkgCapture,
|
|
553
559
|
markLkgRecoveryDirty,
|
|
560
|
+
gaDatabasePath,
|
|
554
561
|
getMessageIndexSourceIdentity2,
|
|
555
562
|
isMessageIndexSourceCurrent2,
|
|
556
563
|
getLastIndexedOrdinal2,
|
|
@@ -559,8 +566,8 @@ import {
|
|
|
559
566
|
clearIndexedMessages2,
|
|
560
567
|
indexSingleMessage2,
|
|
561
568
|
indexMessagesAfterOrdinal2,
|
|
562
|
-
|
|
563
|
-
} from "./index-
|
|
569
|
+
sweepOrphanedOpenCodeMessageIndexesCooperatively2
|
|
570
|
+
} from "./index-x4njr8df.js";
|
|
564
571
|
import {
|
|
565
572
|
renderUserFacingFailure,
|
|
566
573
|
userFacingFailureCode,
|
|
@@ -604,7 +611,7 @@ import {
|
|
|
604
611
|
readGitFileChangeTimesSince,
|
|
605
612
|
verificationFileExists,
|
|
606
613
|
normalizeVerificationFiles
|
|
607
|
-
} from "./index-
|
|
614
|
+
} from "./index-v8awdgvd.js";
|
|
608
615
|
import {
|
|
609
616
|
registerNotificationSink2,
|
|
610
617
|
pushNotification2,
|
|
@@ -614,7 +621,7 @@ import {
|
|
|
614
621
|
} from "./index-x8a7jmkh.js";
|
|
615
622
|
import {
|
|
616
623
|
getLocalEmbeddingNativeMemoryStats
|
|
617
|
-
} from "./index-
|
|
624
|
+
} from "./index-bjcnntmz.js";
|
|
618
625
|
import {
|
|
619
626
|
saveEmbeddingIfHashMatches,
|
|
620
627
|
invalidateProject2,
|
|
@@ -622,7 +629,7 @@ import {
|
|
|
622
629
|
} from "./index-4dhv7mqz.js";
|
|
623
630
|
import {
|
|
624
631
|
cosineSimilarity
|
|
625
|
-
} from "./index-
|
|
632
|
+
} from "./index-24fezq97.js";
|
|
626
633
|
import {
|
|
627
634
|
computeCueContentHash,
|
|
628
635
|
hasMuralCueColumns,
|
|
@@ -647,7 +654,7 @@ import {
|
|
|
647
654
|
mergeMemoryStats2,
|
|
648
655
|
archiveMemory2,
|
|
649
656
|
getMemoryCountsByStatus2
|
|
650
|
-
} from "./index-
|
|
657
|
+
} from "./index-n37sebck.js";
|
|
651
658
|
import {
|
|
652
659
|
renderSingleStoreMigrationRequiredRefusal,
|
|
653
660
|
SingleStoreMigrationRequiredError,
|
|
@@ -668,17 +675,17 @@ import {
|
|
|
668
675
|
resolveMemoriesByIdsForSearch2,
|
|
669
676
|
unifiedSearch2,
|
|
670
677
|
formatSearchResults2
|
|
671
|
-
} from "./index-
|
|
678
|
+
} from "./index-s7j8tvhv.js";
|
|
672
679
|
import {
|
|
673
680
|
flushIgnoredMessages2,
|
|
674
681
|
clearIgnoredMessages2,
|
|
675
682
|
observeIgnoredNotificationEvent2,
|
|
676
683
|
sendStatusNotification2
|
|
677
|
-
} from "./index-
|
|
684
|
+
} from "./index-s74zqahq.js";
|
|
678
685
|
import {
|
|
679
686
|
setRecompStarting2,
|
|
680
687
|
setRecompTerminal2
|
|
681
|
-
} from "./index-
|
|
688
|
+
} from "./index-r4nkrs05.js";
|
|
682
689
|
import {
|
|
683
690
|
makeToolCompositeKey,
|
|
684
691
|
searchMessageHistoryOffThread,
|
|
@@ -697,6 +704,7 @@ import {
|
|
|
697
704
|
resolveTodowriteAvailability,
|
|
698
705
|
canConsumeDeferredOnThisPass,
|
|
699
706
|
hasReclaimRide,
|
|
707
|
+
reclaimRidePermitted,
|
|
700
708
|
reclaimRideLabel,
|
|
701
709
|
captureOpencodeReasoningBudgetStatus,
|
|
702
710
|
reasoningBudgetStatusLine,
|
|
@@ -720,6 +728,7 @@ import {
|
|
|
720
728
|
prewarmTagOwners,
|
|
721
729
|
waitForTagOwners,
|
|
722
730
|
stripStructuralNoise,
|
|
731
|
+
withTransformTimingSummary,
|
|
723
732
|
logTransformTiming,
|
|
724
733
|
hasRecentAssistantCommit,
|
|
725
734
|
tagMessages,
|
|
@@ -731,7 +740,7 @@ import {
|
|
|
731
740
|
abortSessionFailClosed2,
|
|
732
741
|
evaluateEmergencyFailClosed2,
|
|
733
742
|
runPostTransformPhase2
|
|
734
|
-
} from "./index-
|
|
743
|
+
} from "./index-e4xv8890.js";
|
|
735
744
|
import {
|
|
736
745
|
ANNOUNCEMENT_VERSION2,
|
|
737
746
|
ANNOUNCEMENT_FEATURES2,
|
|
@@ -744,7 +753,7 @@ import {
|
|
|
744
753
|
} from "./index-fmsr7v69.js";
|
|
745
754
|
import {
|
|
746
755
|
renderSearchArchiveOffThread2
|
|
747
|
-
} from "./index-
|
|
756
|
+
} from "./index-6s5941tm.js";
|
|
748
757
|
import {
|
|
749
758
|
COMPACTION_ENABLED_PATH,
|
|
750
759
|
isDreamerRunnable,
|
|
@@ -11611,9 +11620,14 @@ async function indexSingleMessageOffThread(db, sessionId, message) {
|
|
|
11611
11620
|
return result.inserted;
|
|
11612
11621
|
}
|
|
11613
11622
|
async function sweepOrphanedOpenCodeMessageIndexesOffThread(db, openSource, options = {}) {
|
|
11623
|
+
if (getHarness2() === "opencode2")
|
|
11624
|
+
openSource = () => new Database2(gaDatabasePath(getDataDir(), process.env.OPENCODE_CHANNEL ?? "latest"), {
|
|
11625
|
+
readonly: true,
|
|
11626
|
+
fileMustExist: true
|
|
11627
|
+
});
|
|
11614
11628
|
const path = getSqliteDatabasePath2(db);
|
|
11615
|
-
if (!path || getHarness2() !== "opencode")
|
|
11616
|
-
return
|
|
11629
|
+
if (!path || getHarness2() !== "opencode" && getHarness2() !== "opencode2")
|
|
11630
|
+
return sweepOrphanedOpenCodeMessageIndexesCooperatively2(db, openSource, options);
|
|
11617
11631
|
let source = null;
|
|
11618
11632
|
let sourcePath = null;
|
|
11619
11633
|
try {
|
|
@@ -11625,7 +11639,7 @@ async function sweepOrphanedOpenCodeMessageIndexesOffThread(db, openSource, opti
|
|
|
11625
11639
|
source?.close();
|
|
11626
11640
|
}
|
|
11627
11641
|
if (!sourcePath)
|
|
11628
|
-
return
|
|
11642
|
+
return sweepOrphanedOpenCodeMessageIndexesCooperatively2(db, () => source, options);
|
|
11629
11643
|
const reply = await runSessionWarmupWorker({
|
|
11630
11644
|
path,
|
|
11631
11645
|
sessionId: "",
|
|
@@ -11824,7 +11838,7 @@ function runTick(origin) {
|
|
|
11824
11838
|
if (tickInFlight)
|
|
11825
11839
|
return;
|
|
11826
11840
|
tickInFlight = true;
|
|
11827
|
-
log2(`[
|
|
11841
|
+
log2(`[magic-context] maintenance tick (${origin}) — projects=${registeredProjects.size}`);
|
|
11828
11842
|
(async () => {
|
|
11829
11843
|
try {
|
|
11830
11844
|
const db = openTimerDatabaseOrNull("maintenance tick");
|
|
@@ -11874,6 +11888,9 @@ function persistTickOutcome(db, failure) {
|
|
|
11874
11888
|
}
|
|
11875
11889
|
}
|
|
11876
11890
|
async function runMessageHistoryMaintenance(db) {
|
|
11891
|
+
const prunedIdentities = await pruneMissingProjectIdentities();
|
|
11892
|
+
if (prunedIdentities > 0)
|
|
11893
|
+
log2(`[magic-context] pruned ${prunedIdentities} missing project identities`);
|
|
11877
11894
|
try {
|
|
11878
11895
|
await drainStaleLkgSlots(db);
|
|
11879
11896
|
} catch (error) {
|
|
@@ -12107,10 +12124,20 @@ async function sweepGitCommits(args) {
|
|
|
12107
12124
|
const holderId = crypto.randomUUID();
|
|
12108
12125
|
const lease = acquireGitSweepLease(db, projectIdentity, holderId);
|
|
12109
12126
|
if (!lease.acquired) {
|
|
12110
|
-
|
|
12127
|
+
if (lease.reason === "cooldown_active")
|
|
12128
|
+
return;
|
|
12129
|
+
const reason = `lease held by ${lease.leaseHolder ?? "another holder"} until ${lease.leaseExpiresAt ?? "unknown"}`;
|
|
12111
12130
|
log2(`[git-commits] sweep skipped for ${projectIdentity}: ${reason}`);
|
|
12112
12131
|
return;
|
|
12113
12132
|
}
|
|
12133
|
+
if (projectIdentity.startsWith("dir:")) {
|
|
12134
|
+
if (parkGitSweepNonIndexable(db, projectIdentity, holderId)) {
|
|
12135
|
+
log2(`[git-commits] sweep parked for ${projectIdentity}: directory identity has no commits`);
|
|
12136
|
+
} else {
|
|
12137
|
+
releaseGitSweepLease(db, projectIdentity, holderId);
|
|
12138
|
+
}
|
|
12139
|
+
return;
|
|
12140
|
+
}
|
|
12114
12141
|
const startedAt = Date.now();
|
|
12115
12142
|
const stopRenewal = startGitSweepLeaseRenewal(db, projectIdentity, holderId);
|
|
12116
12143
|
log2(`[git-commits] sweep starting for ${projectIdentity} (sinceDays=${gitCommitIndexing.since_days} maxCommits=${gitCommitIndexing.max_commits})`);
|
|
@@ -14055,8 +14082,9 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
|
|
|
14055
14082
|
const canClearReasoning = reasoningProjection?.canClearReasoning ?? modelAcceptsEmptyContent(reasoningProjection?.providerID);
|
|
14056
14083
|
const projectedPostDropPercentage = estimateProjectedPostDropPercentage(db, sessionId, usage, preloadedActiveTags ?? getActiveTagsBySession2(db, sessionId), keepReasoningTokens, sessionMeta.clearedReasoningThroughTag, canClearReasoning, reasoningProjection?.budgetCutoff, eligiblePendingDropTagIds);
|
|
14057
14084
|
const relativePostDropTarget = executeThresholdPercentage * POST_DROP_TARGET_RATIO;
|
|
14085
|
+
const ridePermitted = reclaimRide !== undefined && (reclaimRide.permission ? reclaimRidePermitted(reclaimRide, reclaimRide.permission) : hasReclaimRide(reclaimRide));
|
|
14058
14086
|
const rideLabel = reclaimRide ? reclaimRideLabel(reclaimRide) : "ride=none";
|
|
14059
|
-
const dropsCanLand =
|
|
14087
|
+
const dropsCanLand = ridePermitted;
|
|
14060
14088
|
const forceMaterializationPercentage = escalationBands(executeThresholdPercentage).forceMaterializationPercentage;
|
|
14061
14089
|
if (usage.percentage >= forceMaterializationPercentage) {
|
|
14062
14090
|
if (dropsCanLand && projectedPostDropPercentage !== null && projectedPostDropPercentage <= relativePostDropTarget) {
|
|
@@ -16272,8 +16300,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16272
16300
|
const db = readDatabase();
|
|
16273
16301
|
if (!db)
|
|
16274
16302
|
return { ok: false, error: "db unavailable" };
|
|
16275
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
16276
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
16303
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-ghpk2dtq.js"));
|
|
16304
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-6ve0e8p4.js"));
|
|
16277
16305
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
16278
16306
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
16279
16307
|
return {
|
|
@@ -16357,7 +16385,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
16357
16385
|
const db = readDatabase();
|
|
16358
16386
|
if (!db)
|
|
16359
16387
|
return { ok: false, error: "db unavailable" };
|
|
16360
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
16388
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-s9zc5b00.js"));
|
|
16361
16389
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
16362
16390
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
16363
16391
|
const ctx = {
|
|
@@ -17283,7 +17311,9 @@ var PASS_DEGRADATION_EFFECTS = {
|
|
|
17283
17311
|
"trailing-blank-decision-exception": "changes-request",
|
|
17284
17312
|
"proactive-thinking-strip-persistence-failure": "changes-request",
|
|
17285
17313
|
"reasoning-removal-read-failure": "changes-request",
|
|
17286
|
-
"reasoning-removal-persistence-failure": "changes-request"
|
|
17314
|
+
"reasoning-removal-persistence-failure": "changes-request",
|
|
17315
|
+
"host-instruction-retention-read-failure": "changes-request",
|
|
17316
|
+
"host-instruction-retention-persistence-failure": "changes-request"
|
|
17287
17317
|
};
|
|
17288
17318
|
function degradationChangesRequest(site) {
|
|
17289
17319
|
return PASS_DEGRADATION_EFFECTS[site] === "changes-request";
|
|
@@ -17850,6 +17880,7 @@ class HistorianHostRunner {
|
|
|
17850
17880
|
throw new Error("hidden completion carrier returned no session id");
|
|
17851
17881
|
const run = await promptSyncWithValidatedOutputRetry(undefined, {
|
|
17852
17882
|
path: { id: handle.id },
|
|
17883
|
+
cacheTail: "skip",
|
|
17853
17884
|
query: { directory: sessionDirectory },
|
|
17854
17885
|
body: {
|
|
17855
17886
|
agent: "historian",
|
|
@@ -20153,6 +20184,24 @@ function contextUsagePassSnapshot(sessionMeta) {
|
|
|
20153
20184
|
} : null
|
|
20154
20185
|
};
|
|
20155
20186
|
}
|
|
20187
|
+
function savedProviderReadingForPass(input) {
|
|
20188
|
+
const persisted = input.persisted;
|
|
20189
|
+
if (!persisted)
|
|
20190
|
+
return null;
|
|
20191
|
+
const { percentage, inputTokens } = persisted.usage;
|
|
20192
|
+
if (!Number.isFinite(percentage) || percentage <= 0 || !Number.isFinite(inputTokens) || inputTokens <= 0) {
|
|
20193
|
+
return null;
|
|
20194
|
+
}
|
|
20195
|
+
if (!(input.lastResponseTime > 0) || input.cacheExpired)
|
|
20196
|
+
return null;
|
|
20197
|
+
if (persisted.lastObservedModelKey === null || input.currentModelKey === undefined || input.currentModelKey.length === 0 || piModelRefToCanonical(persisted.lastObservedModelKey) !== piModelRefToCanonical(input.currentModelKey)) {
|
|
20198
|
+
return null;
|
|
20199
|
+
}
|
|
20200
|
+
if (typeof input.contextLimit !== "number" || !(input.contextLimit > 0) || persisted.lastUsageContextLimit !== input.contextLimit) {
|
|
20201
|
+
return null;
|
|
20202
|
+
}
|
|
20203
|
+
return { percentage, inputTokens };
|
|
20204
|
+
}
|
|
20156
20205
|
function resolveUnknownUsageFromWireEstimate(input) {
|
|
20157
20206
|
if (input.usage.inputTokens > 0 || !input.pricedPass)
|
|
20158
20207
|
return input.usage;
|
|
@@ -23505,6 +23554,101 @@ function createRustModeTransform(deps, options) {
|
|
|
23505
23554
|
return adapter;
|
|
23506
23555
|
}
|
|
23507
23556
|
|
|
23557
|
+
// src/hooks/magic-context/signed-thinking-hold.ts
|
|
23558
|
+
var HEAVY_REASONING_TOKENS = 1500;
|
|
23559
|
+
var HEAVY_REASONING_WINDOW_STEPS = 15;
|
|
23560
|
+
var HOLD_CAP_POINTS = 10;
|
|
23561
|
+
var REASONING_TYPES = new Set(["reasoning", "thinking"]);
|
|
23562
|
+
function role(message) {
|
|
23563
|
+
if (!isRecord(message))
|
|
23564
|
+
return;
|
|
23565
|
+
return isRecord(message.info) ? message.info.role : message.role;
|
|
23566
|
+
}
|
|
23567
|
+
function parts(message) {
|
|
23568
|
+
if (!isRecord(message))
|
|
23569
|
+
return [];
|
|
23570
|
+
if (Array.isArray(message.parts))
|
|
23571
|
+
return message.parts;
|
|
23572
|
+
return Array.isArray(message.content) ? message.content : [];
|
|
23573
|
+
}
|
|
23574
|
+
function recordedReasoningTokens(message) {
|
|
23575
|
+
if (!isRecord(message))
|
|
23576
|
+
return;
|
|
23577
|
+
const info = isRecord(message.info) ? message.info : undefined;
|
|
23578
|
+
const candidates = [];
|
|
23579
|
+
if (info && isRecord(info.tokens))
|
|
23580
|
+
candidates.push(info.tokens.reasoning);
|
|
23581
|
+
if (isRecord(message.usage)) {
|
|
23582
|
+
candidates.push(message.usage.reasoning, message.usage.reasoningTokens);
|
|
23583
|
+
}
|
|
23584
|
+
for (const value of candidates) {
|
|
23585
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0)
|
|
23586
|
+
return value;
|
|
23587
|
+
}
|
|
23588
|
+
return;
|
|
23589
|
+
}
|
|
23590
|
+
function stepReasoningTokens(message, estimateTextTokens) {
|
|
23591
|
+
let text = "";
|
|
23592
|
+
let opaque = false;
|
|
23593
|
+
for (const part of parts(message)) {
|
|
23594
|
+
if (!isRecord(part))
|
|
23595
|
+
continue;
|
|
23596
|
+
const type = String(part.type ?? part.kind);
|
|
23597
|
+
if (type === "redacted_thinking" || part.redacted === true) {
|
|
23598
|
+
opaque = true;
|
|
23599
|
+
continue;
|
|
23600
|
+
}
|
|
23601
|
+
if (!REASONING_TYPES.has(type))
|
|
23602
|
+
continue;
|
|
23603
|
+
const body = typeof part.thinking === "string" ? part.thinking : typeof part.text === "string" ? part.text : "";
|
|
23604
|
+
if (body.length > 0)
|
|
23605
|
+
text += body;
|
|
23606
|
+
else
|
|
23607
|
+
opaque = true;
|
|
23608
|
+
}
|
|
23609
|
+
if (!text && !opaque)
|
|
23610
|
+
return 0;
|
|
23611
|
+
return reasoningStepCost(recordedReasoningTokens(message), text ? estimateTextTokens(text) : 0, opaque);
|
|
23612
|
+
}
|
|
23613
|
+
function decideSignedThinkingHold(args) {
|
|
23614
|
+
const capPercentage = args.executeThresholdPercentage + HOLD_CAP_POINTS;
|
|
23615
|
+
let heavyStepsBack = null;
|
|
23616
|
+
let heavyStepTokens = 0;
|
|
23617
|
+
const start = latestAssistantTurnStart(args.messages);
|
|
23618
|
+
let stepsBack = 0;
|
|
23619
|
+
for (let index = args.messages.length - 1;index >= start; index--) {
|
|
23620
|
+
const message = args.messages[index];
|
|
23621
|
+
if (role(message) !== "assistant" || parts(message).length === 0)
|
|
23622
|
+
continue;
|
|
23623
|
+
stepsBack++;
|
|
23624
|
+
if (stepsBack > HEAVY_REASONING_WINDOW_STEPS)
|
|
23625
|
+
break;
|
|
23626
|
+
const tokens = stepReasoningTokens(message, args.estimateTextTokens);
|
|
23627
|
+
if (tokens > HEAVY_REASONING_TOKENS) {
|
|
23628
|
+
heavyStepsBack = stepsBack;
|
|
23629
|
+
heavyStepTokens = tokens;
|
|
23630
|
+
break;
|
|
23631
|
+
}
|
|
23632
|
+
}
|
|
23633
|
+
if (heavyStepsBack === null)
|
|
23634
|
+
return {
|
|
23635
|
+
held: false,
|
|
23636
|
+
reason: "no_recent_heavy_reasoning",
|
|
23637
|
+
heavyStepsBack,
|
|
23638
|
+
heavyStepTokens,
|
|
23639
|
+
capPercentage
|
|
23640
|
+
};
|
|
23641
|
+
if (!(args.usagePercentage < capPercentage))
|
|
23642
|
+
return { held: false, reason: "above_cap", heavyStepsBack, heavyStepTokens, capPercentage };
|
|
23643
|
+
return {
|
|
23644
|
+
held: true,
|
|
23645
|
+
reason: "heavy_reasoning",
|
|
23646
|
+
heavyStepsBack,
|
|
23647
|
+
heavyStepTokens,
|
|
23648
|
+
capPercentage
|
|
23649
|
+
};
|
|
23650
|
+
}
|
|
23651
|
+
|
|
23508
23652
|
// src/hooks/magic-context/temporal-served-projection.ts
|
|
23509
23653
|
function readLkgTemporalDecisions(db, sessionId, runtime) {
|
|
23510
23654
|
const slot = getInMemorySlot(sessionId) ?? loadPersistedLkgSlot(db, sessionId);
|
|
@@ -23728,7 +23872,7 @@ async function runCompartmentPhaseImpl(args) {
|
|
|
23728
23872
|
justAwaitedPublication = activeRun.published;
|
|
23729
23873
|
published = published || activeRun.published;
|
|
23730
23874
|
const historyReprepareShouldBust = activeRun.published && args.deferredHistoryRefreshSessions.has(args.sessionId);
|
|
23731
|
-
pendingCompartmentInjection = prepareCompartmentInjection(args.db, args.resolvedSessionId, args.messages, historyReprepareShouldBust, args.projectPath, args.injectionBudgetTokens, args.experimentalTemporalAwareness);
|
|
23875
|
+
pendingCompartmentInjection = prepareCompartmentInjection(args.db, args.resolvedSessionId, args.messages, historyReprepareShouldBust, args.coveredInstructions, args.projectPath, args.injectionBudgetTokens, args.experimentalTemporalAwareness);
|
|
23732
23876
|
if (historyReprepareShouldBust) {
|
|
23733
23877
|
rebuiltHistoryThisPass = true;
|
|
23734
23878
|
}
|
|
@@ -24028,7 +24172,8 @@ function createTransform(deps) {
|
|
|
24028
24172
|
const startTime = performance.now();
|
|
24029
24173
|
const historianRun = deps.resolveHistorianRun?.();
|
|
24030
24174
|
const messages = output.messages;
|
|
24031
|
-
const originalForThinkingFit = messages.some((message) => message.parts.some((part) => isRecord(part) && ["reasoning", "thinking", "redacted_thinking"].includes(String(part.type)))) ?
|
|
24175
|
+
const originalForThinkingFit = messages.some((message) => message.parts.some((part) => isRecord(part) && ["reasoning", "thinking", "redacted_thinking"].includes(String(part.type)))) ? cloneKeepingCoveredInstructionMarks(messages) : null;
|
|
24176
|
+
const coveredHostInstructions = takeCoveredInstructionRows(messages);
|
|
24032
24177
|
const passOutcome = createPassOutcome();
|
|
24033
24178
|
const tSessionId = performance.now();
|
|
24034
24179
|
const sessionId = findSessionId(messages);
|
|
@@ -24226,8 +24371,8 @@ function createTransform(deps) {
|
|
|
24226
24371
|
return true;
|
|
24227
24372
|
}
|
|
24228
24373
|
})();
|
|
24229
|
-
let activeThinkingPrefixHold =
|
|
24230
|
-
let freezeM0M1 = unresolvedDirectoryHold
|
|
24374
|
+
let activeThinkingPrefixHold = false;
|
|
24375
|
+
let freezeM0M1 = unresolvedDirectoryHold;
|
|
24231
24376
|
const compartmentDirectory = sessionDirectory;
|
|
24232
24377
|
const historianRunnable = deps.historianRunnable !== false;
|
|
24233
24378
|
const canRunCompartments = fullFeatureMode && !compactionOff && historianRunnable && (deps.client !== undefined || deps.hiddenCompletionExecutor !== undefined) && compartmentDirectory.length > 0;
|
|
@@ -24355,13 +24500,7 @@ function createTransform(deps) {
|
|
|
24355
24500
|
}
|
|
24356
24501
|
const resolvedProviderID = modelForBudget?.providerID;
|
|
24357
24502
|
activeThinkingTurn ||= hasActiveAnthropicThinkingTurn(messages, resolvedProviderID, modelForBudget?.modelID);
|
|
24358
|
-
|
|
24359
|
-
freezeM0M1 ||= activeThinkingPrefixHold;
|
|
24360
|
-
if (freezeM0M1 && prefixHoldLogTurnIds.get(sessionId) !== currentTurnId) {
|
|
24361
|
-
prefixHoldLogTurnIds.set(sessionId, currentTurnId);
|
|
24362
|
-
const reason = activeThinkingPrefixHold ? "active thinking turn (prefix-bound model)" : "session directory unresolved";
|
|
24363
|
-
sessionLog2(sessionId, `m[0]/m[1] frozen: ${reason}; replaying the frozen prefix and deferring any rebuild`);
|
|
24364
|
-
}
|
|
24503
|
+
const signedThinkingPrefixBound = activeThinkingTurn && (isPrefixBoundThinkingModel(activeThinkingModel?.providerID, activeThinkingModel?.modelID) || isPrefixBoundThinkingModel(resolvedProviderID, modelForBudget?.modelID));
|
|
24365
24504
|
const canUseEmptySentinels = modelAcceptsEmptyContent(resolvedProviderID);
|
|
24366
24505
|
const protectedThinkingMessages = activeThinkingTurn || isAnthropicFamilyRoute(resolvedProviderID, modelForBudget?.modelID) ? latestAssistantTurnMessages(messages) : new Set;
|
|
24367
24506
|
const resolvedContextLimit = modelForBudget ? resolveTrustedContextLimit(modelForBudget.providerID, modelForBudget.modelID, {
|
|
@@ -24415,6 +24554,29 @@ function createTransform(deps) {
|
|
|
24415
24554
|
const effectiveExecuteThresholdPercentage = executeThresholdDetail.percentage;
|
|
24416
24555
|
sessionLog2(sessionId, `transform threshold: model=${currentModelKeyForBoundary ?? "unknown"} matchedModel=${executeThresholdDetail.matchedKey ?? "scalar"} mode=${executeThresholdDetail.mode} threshold=${effectiveExecuteThresholdPercentage}% proactiveFloor=${getProactiveCompartmentTriggerPercentage(effectiveExecuteThresholdPercentage)}%`);
|
|
24417
24556
|
const { forceMaterializationPercentage } = escalationBands(effectiveExecuteThresholdPercentage);
|
|
24557
|
+
let holdProseRatio;
|
|
24558
|
+
const signedThinkingHold = signedThinkingPrefixBound ? decideSignedThinkingHold({
|
|
24559
|
+
messages,
|
|
24560
|
+
usagePercentage: contextUsageEarly.percentage,
|
|
24561
|
+
executeThresholdPercentage: effectiveExecuteThresholdPercentage,
|
|
24562
|
+
estimateTextTokens: (text) => {
|
|
24563
|
+
holdProseRatio ??= sessionDecisionCalibration(db, sessionId).proseRatio;
|
|
24564
|
+
return estimateTokens(text) * holdProseRatio;
|
|
24565
|
+
}
|
|
24566
|
+
}) : null;
|
|
24567
|
+
activeThinkingPrefixHold = signedThinkingPrefixBound && (compactionOff || signedThinkingHold?.held === true);
|
|
24568
|
+
freezeM0M1 ||= activeThinkingPrefixHold;
|
|
24569
|
+
const prefixHoldLogKey = signedThinkingHold ? `${currentTurnId}:${signedThinkingHold.reason}:${signedThinkingHold.heavyStepsBack ?? "none"}` : freezeM0M1 ? `${currentTurnId}:directory` : null;
|
|
24570
|
+
if (prefixHoldLogKey !== null && prefixHoldLogTurnIds.get(sessionId) !== prefixHoldLogKey) {
|
|
24571
|
+
prefixHoldLogTurnIds.set(sessionId, prefixHoldLogKey);
|
|
24572
|
+
if (signedThinkingHold) {
|
|
24573
|
+
sessionLog2(sessionId, `signed thinking hold: held=${signedThinkingHold.held} reason=${signedThinkingHold.reason} heavyStepsBack=${signedThinkingHold.heavyStepsBack ?? "none"} heavyStepTokens=${signedThinkingHold.heavyStepTokens} usage=${contextUsageEarly.percentage.toFixed(1)}% cap=${signedThinkingHold.capPercentage}%`);
|
|
24574
|
+
}
|
|
24575
|
+
if (freezeM0M1) {
|
|
24576
|
+
const reason = activeThinkingPrefixHold ? compactionOff ? "active thinking turn in compaction-off mode (prefix-bound model)" : "recent heavy reasoning in the active thinking turn (prefix-bound model)" : "session directory unresolved";
|
|
24577
|
+
sessionLog2(sessionId, `m[0]/m[1] frozen: ${reason}; replaying the frozen prefix and deferring any rebuild`);
|
|
24578
|
+
}
|
|
24579
|
+
}
|
|
24418
24580
|
const persistedUsageFreshForBoundary = persistedUsageBeforeResets && Date.now() - persistedUsageBeforeResets.updatedAt <= 10 * 60 * 1000 && (persistedUsageBeforeResets.lastObservedModelKey === null || currentModelKeyForBoundary === undefined || piModelRefToCanonical(persistedUsageBeforeResets.lastObservedModelKey) === piModelRefToCanonical(currentModelKeyForBoundary)) && (resolvedContextLimit === undefined || persistedUsageBeforeResets.lastUsageContextLimit === 0 || persistedUsageBeforeResets.lastUsageContextLimit === resolvedContextLimit) ? persistedUsageBeforeResets.usage : null;
|
|
24419
24581
|
const boundaryUsageForProtectedTail = persistedUsageFreshForBoundary ?? contextUsageEarly;
|
|
24420
24582
|
const boundaryUsageSource = persistedUsageFreshForBoundary ? "persisted" : "live";
|
|
@@ -24601,8 +24763,14 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24601
24763
|
}, {
|
|
24602
24764
|
hardFold: false,
|
|
24603
24765
|
force: contextUsageEarly.percentage >= forceMaterializationPercentage && (contextUsageEarly.percentage >= 95 || getEmergencyInputSample(db, sessionId) === 0),
|
|
24604
|
-
explicitFlush: deps.pendingMaterializationSessions
|
|
24605
|
-
publishedHistory: isCacheBusting
|
|
24766
|
+
explicitFlush: hasPendingMaterializationOrigin(deps.pendingMaterializationSessions, sessionId, "user_flush"),
|
|
24767
|
+
publishedHistory: isCacheBusting,
|
|
24768
|
+
permission: {
|
|
24769
|
+
signedThinkingHold: activeThinkingPrefixHold,
|
|
24770
|
+
firstRender: false,
|
|
24771
|
+
idleExpiry: false,
|
|
24772
|
+
emergency: contextUsageEarly.percentage >= forceMaterializationPercentage
|
|
24773
|
+
}
|
|
24606
24774
|
}, pendingDropEligibility.read(sessionId, dropProjectionKey()));
|
|
24607
24775
|
if (triggerResult.shouldFire) {
|
|
24608
24776
|
sessionLog2(sessionId, `compartment trigger: firing (reason=${triggerResult.reason})`);
|
|
@@ -24622,7 +24790,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24622
24790
|
const messagesBeforeInitialPrepare = isCacheBusting && deferredHistoryWasPendingAtPassStart ? [...messages] : null;
|
|
24623
24791
|
if (fullFeatureMode && !compactionOff) {
|
|
24624
24792
|
const tInj = performance.now();
|
|
24625
|
-
pendingCompartmentInjection = prepareCompartmentInjection(db, sessionId, messages, isCacheBusting, projectIdentity, deps.memoryConfig?.injectionBudgetTokens, deps.experimentalTemporalAwareness);
|
|
24793
|
+
pendingCompartmentInjection = prepareCompartmentInjection(db, sessionId, messages, isCacheBusting, coveredHostInstructions, projectIdentity, deps.memoryConfig?.injectionBudgetTokens, deps.experimentalTemporalAwareness);
|
|
24626
24794
|
if (messagesBeforeInitialPrepare) {
|
|
24627
24795
|
const skippedVisibleMessages = pendingCompartmentInjection?.skippedVisibleMessages ?? 0;
|
|
24628
24796
|
trimmedMessagesAtCompactionBoundary = messagesBeforeInitialPrepare.slice(0, skippedVisibleMessages);
|
|
@@ -24661,7 +24829,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24661
24829
|
const tagged = tagMessages(sessionId, tail, deps.tagger, db, {
|
|
24662
24830
|
skipPrefixInjection: !ctxReduceCallable,
|
|
24663
24831
|
servedMessages: messages,
|
|
24664
|
-
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText
|
|
24832
|
+
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText,
|
|
24833
|
+
refreshSourceContents: deps.refreshSourceContents?.(sessionId)
|
|
24665
24834
|
});
|
|
24666
24835
|
for (const [number, target] of tagged.targets)
|
|
24667
24836
|
targets.set(number, target);
|
|
@@ -24686,7 +24855,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24686
24855
|
skipPrefixInjection,
|
|
24687
24856
|
scopedToolSweep,
|
|
24688
24857
|
servedMessages: messages,
|
|
24689
|
-
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText
|
|
24858
|
+
normalizeRestoredAssistantText: deps.normalizeRestoredAssistantText,
|
|
24859
|
+
refreshSourceContents: deps.refreshSourceContents?.(sessionId)
|
|
24690
24860
|
});
|
|
24691
24861
|
targets = result.targets;
|
|
24692
24862
|
if (thinkingRecovery.restore)
|
|
@@ -24794,6 +24964,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24794
24964
|
fallbackModels: historianRun?.fallbackModels ?? deps.fallbackModels,
|
|
24795
24965
|
compartmentDirectory,
|
|
24796
24966
|
messages,
|
|
24967
|
+
coveredInstructions: coveredHostInstructions,
|
|
24797
24968
|
pendingCompartmentInjection,
|
|
24798
24969
|
fallbackModelId,
|
|
24799
24970
|
projectPath: projectIdentity,
|
|
@@ -24865,30 +25036,53 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24865
25036
|
bustReason: calibrationBustReason,
|
|
24866
25037
|
onAdopt: (message) => sessionLog2(sessionId, message)
|
|
24867
25038
|
});
|
|
25039
|
+
let contextUsageFromEstimate = false;
|
|
24868
25040
|
if (contextUsage.inputTokens <= 0 && protectionCacheBustingPass) {
|
|
25041
|
+
const overflowRecoveryPass = usagePercentageSynthetic || emergencyRecoveryArmed;
|
|
25042
|
+
const savedProviderReading = overflowRecoveryPass ? null : savedProviderReadingForPass({
|
|
25043
|
+
persisted: persistedUsageBeforeResets,
|
|
25044
|
+
currentModelKey: currentModelKeyForBoundary ?? (hardModelKey || undefined),
|
|
25045
|
+
contextLimit: resolvedContextLimit,
|
|
25046
|
+
lastResponseTime: sessionMeta.lastResponseTime,
|
|
25047
|
+
cacheExpired: hardCacheExpired
|
|
25048
|
+
});
|
|
25049
|
+
let pressureEstimate;
|
|
24869
25050
|
try {
|
|
24870
|
-
|
|
25051
|
+
pressureEstimate = estimateFinalWireInputTokens({
|
|
24871
25052
|
messages,
|
|
24872
25053
|
systemPromptTokens: sessionMeta.systemPromptTokens,
|
|
24873
25054
|
providerID: modelForBudget?.providerID,
|
|
24874
25055
|
modelID: modelForBudget?.modelID,
|
|
24875
25056
|
agentName: notificationParams.agent
|
|
24876
25057
|
});
|
|
25058
|
+
} catch (error) {
|
|
25059
|
+
sessionLog2(sessionId, `transform: wire-estimate pressure fallback unavailable: ${getErrorMessage(error)}`);
|
|
25060
|
+
}
|
|
25061
|
+
const usableHard = windowGeometry?.usableHard;
|
|
25062
|
+
const countPercentage = pressureEstimate?.pressureTokens !== undefined && Number.isFinite(pressureEstimate.pressureTokens) && typeof usableHard === "number" && usableHard > 0 ? pressureEstimate.pressureTokens / usableHard * 100 : 0;
|
|
25063
|
+
const grewPastSavedReading = savedProviderReading !== null && countPercentage >= 95 && countPercentage > savedProviderReading.percentage;
|
|
25064
|
+
if (savedProviderReading && !grewPastSavedReading) {
|
|
25065
|
+
contextUsage = {
|
|
25066
|
+
inputTokens: savedProviderReading.inputTokens,
|
|
25067
|
+
percentage: Math.max(contextUsage.percentage, savedProviderReading.percentage)
|
|
25068
|
+
};
|
|
25069
|
+
sessionLog2(sessionId, `transform: unknown provider usage; using saved provider reading for priced pass inputTokens=${contextUsage.inputTokens} percentage=${contextUsage.percentage.toFixed(1)} countPercentage=${countPercentage.toFixed(1)}`);
|
|
25070
|
+
} else if (pressureEstimate) {
|
|
25071
|
+
const percentageBeforeEstimate = contextUsage.percentage;
|
|
24877
25072
|
contextUsage = resolveUnknownUsageFromWireEstimate({
|
|
24878
25073
|
usage: contextUsage,
|
|
24879
25074
|
pricedPass: true,
|
|
24880
|
-
wireEstimateTokens: pressureEstimate.tokens,
|
|
25075
|
+
wireEstimateTokens: overflowRecoveryPass ? pressureEstimate.tokens : pressureEstimate.pressureTokens,
|
|
24881
25076
|
wireEstimateTrusted: pressureEstimate.trusted,
|
|
24882
25077
|
providerProvenInputTokens: providerProvenInputForRecovery,
|
|
24883
25078
|
providerProvenLimitTokens: providerProvenLimitForRecovery,
|
|
24884
|
-
usableHardLimit:
|
|
25079
|
+
usableHardLimit: usableHard
|
|
24885
25080
|
});
|
|
24886
25081
|
if (contextUsage.inputTokens > 0) {
|
|
24887
25082
|
const usedProviderInput = !pressureEstimate.trusted && providerProvenLimitForRecovery !== undefined && providerProvenInputForRecovery !== undefined && contextUsage.inputTokens >= providerProvenInputForRecovery;
|
|
24888
|
-
|
|
25083
|
+
contextUsageFromEstimate = !overflowRecoveryPass && !usedProviderInput && !usagePercentageSynthetic && contextUsage.percentage > percentageBeforeEstimate;
|
|
25084
|
+
sessionLog2(sessionId, `transform: unknown provider usage; using ${usedProviderInput ? "provider-proven input" : "wire estimate"} for priced pass inputTokens=${contextUsage.inputTokens} percentage=${contextUsage.percentage.toFixed(1)} trusted=${pressureEstimate.trusted} wireTokens=${pressureEstimate.tokens} pressureTokens=${pressureEstimate.pressureTokens}${grewPastSavedReading ? ` grewPastSavedReading=${savedProviderReading?.percentage.toFixed(1)}` : ""}`);
|
|
24889
25085
|
}
|
|
24890
|
-
} catch (error) {
|
|
24891
|
-
sessionLog2(sessionId, `transform: wire-estimate pressure fallback unavailable: ${getErrorMessage(error)}`);
|
|
24892
25086
|
}
|
|
24893
25087
|
}
|
|
24894
25088
|
const protectionUsableSoft = windowGeometry?.usableSoft ?? boundaryContextLimit;
|
|
@@ -24929,6 +25123,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24929
25123
|
activeAgent,
|
|
24930
25124
|
batch,
|
|
24931
25125
|
contextUsage,
|
|
25126
|
+
contextUsageFromEstimate,
|
|
24932
25127
|
usableWindow: resolvedContextLimit ?? 0,
|
|
24933
25128
|
schedulerDecision,
|
|
24934
25129
|
schedulerDeferReason,
|
|
@@ -24974,6 +25169,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
24974
25169
|
emergencyCeilingTokens,
|
|
24975
25170
|
pendingCompartmentInjection,
|
|
24976
25171
|
prefixTrimSourceOrder,
|
|
25172
|
+
coveredHostInstructions,
|
|
24977
25173
|
hiddenMessagesAtCompactionSeam,
|
|
24978
25174
|
trimmedMessagesAtCompactionBoundary,
|
|
24979
25175
|
didMutateFromFlushedStatuses,
|
|
@@ -25174,7 +25370,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25174
25370
|
if (!finalWireEstimate) {
|
|
25175
25371
|
sessionLog2(sessionId, `transform: final-wire telemetry estimate=unavailable trusted=false conversation=unknown tools=unknown system=unknown toolDefinitions=unknown tail=${finalWireTail}`);
|
|
25176
25372
|
}
|
|
25177
|
-
finishSystemDateRefresh(deps.historyRefreshSessions, dateRequest, postTransformResult.bustedThisPass && !activeThinkingPrefixHold || postTransformResult.thinkingReleasedForFit === true);
|
|
25373
|
+
finishSystemDateRefresh(deps.historyRefreshSessions, dateRequest, postTransformResult.bustedThisPass && !activeThinkingPrefixHold && postTransformResult.openTurnSignedThinkingKept !== true || postTransformResult.thinkingReleasedForFit === true);
|
|
25178
25374
|
if (activeThinkingPrefixHold && !postTransformResult.thinkingReleasedForFit && sessionMeta.cachedM0Bytes != null && sessionMeta.cachedM1Bytes != null) {
|
|
25179
25375
|
recordHeldHeadForRequest(sessionId, currentLkgRequestIdentity(sessionId), (ownsHistory) => deferDeliveredSystemRefresh(deps, sessionId, ownsHistory));
|
|
25180
25376
|
}
|
|
@@ -25275,7 +25471,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25275
25471
|
});
|
|
25276
25472
|
if (uncachedMessageIds.length > 0) {
|
|
25277
25473
|
try {
|
|
25278
|
-
storedByMessage = getActiveTagTokenTotalsByMessage2(db, sessionId, uncachedMessageIds);
|
|
25474
|
+
storedByMessage = omitIncompleteFileTokenTotals(db, sessionId, messages.flatMap((message) => message.info.id ? [{ id: message.info.id, parts: message.parts }] : []), getActiveTagTokenTotalsByMessage2(db, sessionId, uncachedMessageIds));
|
|
25279
25475
|
} catch {
|
|
25280
25476
|
storedByMessage = new Map;
|
|
25281
25477
|
}
|
|
@@ -25370,7 +25566,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
25370
25566
|
systemPromptHash: sessionMeta.systemPromptHash
|
|
25371
25567
|
});
|
|
25372
25568
|
};
|
|
25373
|
-
|
|
25569
|
+
const timedTransform = (input, output) => withTransformTimingSummary(() => transform(input, output));
|
|
25570
|
+
return Object.assign(timedTransform, {
|
|
25374
25571
|
clearSessionLogState,
|
|
25375
25572
|
invalidateRustWireState(sessionId) {
|
|
25376
25573
|
rustModeTransform?.invalidateWireState(sessionId);
|
|
@@ -25591,6 +25788,26 @@ function systemPromptDates(prompt, sticky) {
|
|
|
25591
25788
|
return { live: values.length ? JSON.stringify(values) : undefined, stable };
|
|
25592
25789
|
}
|
|
25593
25790
|
|
|
25791
|
+
// src/hooks/magic-context/system-prompt-diagnostics.ts
|
|
25792
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
25793
|
+
function snapshotSystemPrompt(system, preset) {
|
|
25794
|
+
return { elements: system.map((element) => Buffer.from(element)), preset };
|
|
25795
|
+
}
|
|
25796
|
+
function describeSystemPromptChange(previous, current) {
|
|
25797
|
+
const metadata = (element) => element === undefined ? "absent" : `bytes=${element.length},md5=${createHash13("md5").update(element).digest("hex")}`;
|
|
25798
|
+
const elements = [];
|
|
25799
|
+
for (let index = 0;index < Math.max(previous?.elements.length ?? 0, current.elements.length); index++) {
|
|
25800
|
+
const before = previous?.elements[index];
|
|
25801
|
+
const after = current.elements[index];
|
|
25802
|
+
let offset = 0;
|
|
25803
|
+
while (before && after && offset < Math.min(before.length, after.length) && before[offset] === after[offset])
|
|
25804
|
+
offset++;
|
|
25805
|
+
const status = !previous ? "unknown" : !before ? "added" : !after ? "removed" : before.equals(after) ? "unchanged" : "changed";
|
|
25806
|
+
elements.push(`${index}:${status}(${metadata(before)} -> ${metadata(after)},firstDiffByte=${!previous ? "unknown" : status === "unchanged" ? "none" : offset})`);
|
|
25807
|
+
}
|
|
25808
|
+
return `presetChanged=${previous ? previous.preset !== current.preset : "unknown"} elements=[${elements.join("; ")}]`;
|
|
25809
|
+
}
|
|
25810
|
+
|
|
25594
25811
|
// src/hooks/magic-context/system-prompt-hash.ts
|
|
25595
25812
|
var MAGIC_CONTEXT_MARKER = "## Magic Context";
|
|
25596
25813
|
var SYSTEM_PROMPT_GUIDANCE_SEPARATOR = `
|
|
@@ -25613,6 +25830,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
25613
25830
|
});
|
|
25614
25831
|
const guidanceEpochs = createPromptSurfaceGuidanceEpochCache(promptSurfaceRuntime);
|
|
25615
25832
|
const stickyDateBySession = new Map;
|
|
25833
|
+
const diagnosticPrompts = new Map;
|
|
25616
25834
|
const processSystemPrompt = async (input, output) => {
|
|
25617
25835
|
const sessionId = input.sessionID;
|
|
25618
25836
|
if (!sessionId)
|
|
@@ -25745,8 +25963,11 @@ function createSystemPromptHashHandler(deps) {
|
|
|
25745
25963
|
return;
|
|
25746
25964
|
}
|
|
25747
25965
|
const sessionMeta = sessionMetaEarly;
|
|
25966
|
+
const previousPrompt = diagnosticPrompts.get(sessionId);
|
|
25967
|
+
const currentPrompt = previousPrompt && previousHash === currentHash ? previousPrompt : snapshotSystemPrompt(output.system, promptSurface.preset);
|
|
25968
|
+
diagnosticPrompts.set(sessionId, currentPrompt);
|
|
25748
25969
|
if (previousHash !== "" && previousHash !== "0" && previousHash !== currentHash) {
|
|
25749
|
-
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"}`);
|
|
25970
|
+
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)}`);
|
|
25750
25971
|
noteSystemPromptHashChange(sessionId);
|
|
25751
25972
|
if (!adoptSystemChange) {
|
|
25752
25973
|
deps.historyRefreshSessions.add(sessionId);
|
|
@@ -25790,6 +26011,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
25790
26011
|
return {
|
|
25791
26012
|
handler,
|
|
25792
26013
|
clearSession: (sessionId) => {
|
|
26014
|
+
diagnosticPrompts.delete(sessionId);
|
|
25793
26015
|
clearSystemDateRefresh(deps.historyRefreshSessions, sessionId);
|
|
25794
26016
|
guidanceEpochs.clear(sessionId);
|
|
25795
26017
|
clearSystemPromptHashSession(sessionId, {
|
|
@@ -26518,7 +26740,7 @@ function resolveCtxExpandMode(args, domain) {
|
|
|
26518
26740
|
}
|
|
26519
26741
|
|
|
26520
26742
|
// src/tools/ctx-expand/render.ts
|
|
26521
|
-
import { createHash as
|
|
26743
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
26522
26744
|
function isRecord4(value) {
|
|
26523
26745
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
26524
26746
|
}
|
|
@@ -26742,7 +26964,7 @@ function renderItemByTag(db, sessionId, number, textIndexDomain = "part") {
|
|
|
26742
26964
|
const index = scoped ? Number(scoped[2]) : 0;
|
|
26743
26965
|
const piText = message.parts.filter((part) => isRecord4(part) && part.type === "text");
|
|
26744
26966
|
const part = message.parts[index];
|
|
26745
|
-
const matching = derived ? piText.filter((part) => isRecord4(part) && typeof part.text === "string" &&
|
|
26967
|
+
const matching = derived ? piText.filter((part) => isRecord4(part) && typeof part.text === "string" && createHash14("sha256").update(part.text).digest("hex") === derived[3]) : [];
|
|
26746
26968
|
const selected = derived ? matching[Number(derived[4])] : textIndexDomain === "text" ? piText[index] : part;
|
|
26747
26969
|
return selected ? renderPartFull(selected) ?? "" : `Tag ${number}'s original text part is no longer in stored history.`;
|
|
26748
26970
|
}
|
|
@@ -28298,7 +28520,7 @@ function formatCtxReduceReply(stampedCount, selfStampCount = 0) {
|
|
|
28298
28520
|
return parts.join(" ");
|
|
28299
28521
|
}
|
|
28300
28522
|
// src/tools/ctx-reduce/tools.ts
|
|
28301
|
-
import { createHash as
|
|
28523
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
28302
28524
|
import { tool as tool4 } from "@opencode-ai/plugin";
|
|
28303
28525
|
|
|
28304
28526
|
// src/features/magic-context/range-parser.ts
|
|
@@ -28362,11 +28584,11 @@ function createCtxReduceTool(deps) {
|
|
|
28362
28584
|
const stableId = `oc-${sessionId}-${callId}`;
|
|
28363
28585
|
if (Buffer.byteLength(stableId) <= 128)
|
|
28364
28586
|
return stableId;
|
|
28365
|
-
return `oc-${
|
|
28587
|
+
return `oc-${createHash15("sha256").update(stableId).digest("hex")}`;
|
|
28366
28588
|
}
|
|
28367
28589
|
fallbackCommandSequence += 1;
|
|
28368
28590
|
const monotonicId = `oc-${sessionId}-${fallbackCommandSequence}`;
|
|
28369
|
-
return Buffer.byteLength(monotonicId) <= 128 ? monotonicId : `oc-${
|
|
28591
|
+
return Buffer.byteLength(monotonicId) <= 128 ? monotonicId : `oc-${createHash15("sha256").update(monotonicId).digest("hex")}`;
|
|
28370
28592
|
};
|
|
28371
28593
|
return tool4({
|
|
28372
28594
|
description: CTX_REDUCE_DESCRIPTION,
|
|
@@ -28773,7 +28995,58 @@ function applyJsonSchemaParameterDescriptions(toolId, input, preset, smartNotesE
|
|
|
28773
28995
|
|
|
28774
28996
|
// src/shared/rpc-server.ts
|
|
28775
28997
|
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
28776
|
-
import { readdirSync as readdirSync2, readFileSync as readFileSync6, unlinkSync } from "node:fs";
|
|
28998
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync6, rmdirSync, unlinkSync } from "node:fs";
|
|
28999
|
+
|
|
29000
|
+
// src/shared/rpc-discovery-cleanup.ts
|
|
29001
|
+
import { promises as fs } from "node:fs";
|
|
29002
|
+
import { join as join7 } from "node:path";
|
|
29003
|
+
async function reapDeadRpcDiscovery(storageDir) {
|
|
29004
|
+
const root = join7(storageDir, "rpc");
|
|
29005
|
+
let directories;
|
|
29006
|
+
try {
|
|
29007
|
+
directories = await fs.readdir(root, { withFileTypes: true });
|
|
29008
|
+
} catch {
|
|
29009
|
+
return;
|
|
29010
|
+
}
|
|
29011
|
+
const records = [];
|
|
29012
|
+
const projectDirs = [];
|
|
29013
|
+
for (const entry of directories) {
|
|
29014
|
+
if (!entry.isDirectory() || !/^[0-9a-f]{16}$/.test(entry.name))
|
|
29015
|
+
continue;
|
|
29016
|
+
const directory = join7(root, entry.name);
|
|
29017
|
+
projectDirs.push(directory);
|
|
29018
|
+
try {
|
|
29019
|
+
for (const name of await fs.readdir(directory)) {
|
|
29020
|
+
const match = /^port-(\d+)(?:-[0-9a-f]+)?\.json$/.exec(name);
|
|
29021
|
+
if (!match)
|
|
29022
|
+
continue;
|
|
29023
|
+
const path = join7(directory, name);
|
|
29024
|
+
try {
|
|
29025
|
+
const content = await fs.readFile(path, "utf8");
|
|
29026
|
+
const record = parseRpcPortFile(content, Number(match[1]));
|
|
29027
|
+
if (record && record.pid === Number(match[1]))
|
|
29028
|
+
records.push({ path, content, pid: record.pid });
|
|
29029
|
+
} catch {}
|
|
29030
|
+
}
|
|
29031
|
+
} catch {}
|
|
29032
|
+
}
|
|
29033
|
+
const processes = records.length ? await inspectProcessesAsync(true) : undefined;
|
|
29034
|
+
for (const record of records) {
|
|
29035
|
+
if (processes?.liveness(record.pid) !== "dead")
|
|
29036
|
+
continue;
|
|
29037
|
+
try {
|
|
29038
|
+
if (await fs.readFile(record.path, "utf8") === record.content)
|
|
29039
|
+
await fs.unlink(record.path);
|
|
29040
|
+
} catch {}
|
|
29041
|
+
}
|
|
29042
|
+
for (const directory of projectDirs) {
|
|
29043
|
+
try {
|
|
29044
|
+
await fs.rmdir(directory);
|
|
29045
|
+
} catch {}
|
|
29046
|
+
}
|
|
29047
|
+
}
|
|
29048
|
+
|
|
29049
|
+
// src/shared/rpc-server.ts
|
|
28777
29050
|
var MAX_BODY_BYTES = 1048576;
|
|
28778
29051
|
var WS_AUTH_TIMEOUT_MS = 5000;
|
|
28779
29052
|
var WS_CLOSE_UNAUTHORIZED = 4401;
|
|
@@ -28796,17 +29069,20 @@ function websocketToken(req) {
|
|
|
28796
29069
|
}
|
|
28797
29070
|
|
|
28798
29071
|
class MagicContextRpcServer {
|
|
29072
|
+
storageDir;
|
|
28799
29073
|
server = null;
|
|
28800
29074
|
port = 0;
|
|
28801
29075
|
handlers = new Map;
|
|
28802
29076
|
portFilePath;
|
|
28803
29077
|
portDir;
|
|
28804
29078
|
startedAt = Date.now();
|
|
29079
|
+
stopped = false;
|
|
28805
29080
|
instanceId = randomBytes(8).toString("hex");
|
|
28806
29081
|
unregisterOwnInstance = null;
|
|
28807
29082
|
sockets = new Set;
|
|
28808
29083
|
token = randomBytes(32).toString("hex");
|
|
28809
29084
|
constructor(storageDir, directory) {
|
|
29085
|
+
this.storageDir = storageDir;
|
|
28810
29086
|
this.portFilePath = rpcPortFilePath(storageDir, directory, process.pid, this.instanceId);
|
|
28811
29087
|
this.portDir = rpcPortDir(storageDir, directory);
|
|
28812
29088
|
}
|
|
@@ -28824,6 +29100,10 @@ class MagicContextRpcServer {
|
|
|
28824
29100
|
log2("rpc server skipped: Bun runtime not available (no TUI consumer)");
|
|
28825
29101
|
return 0;
|
|
28826
29102
|
}
|
|
29103
|
+
this.stopped = false;
|
|
29104
|
+
await reapDeadRpcDiscovery(this.storageDir);
|
|
29105
|
+
if (this.stopped)
|
|
29106
|
+
return 0;
|
|
28827
29107
|
this.startedAt = Date.now();
|
|
28828
29108
|
const self = this;
|
|
28829
29109
|
const server = inRootAsyncContext2(() => Bun.serve({
|
|
@@ -28855,7 +29135,7 @@ class MagicContextRpcServer {
|
|
|
28855
29135
|
try {
|
|
28856
29136
|
this.warnIfOtherLiveInstance();
|
|
28857
29137
|
this.unregisterOwnInstance ??= registerOwnRpcServerInstance(this.instanceId);
|
|
28858
|
-
writeStorageFileAtomicSync(this.portFilePath, JSON.stringify({
|
|
29138
|
+
const publish = () => writeStorageFileAtomicSync(this.portFilePath, JSON.stringify({
|
|
28859
29139
|
port: this.port,
|
|
28860
29140
|
pid: process.pid,
|
|
28861
29141
|
started_at: this.startedAt,
|
|
@@ -28863,6 +29143,13 @@ class MagicContextRpcServer {
|
|
|
28863
29143
|
token: this.token,
|
|
28864
29144
|
instance_id: this.instanceId
|
|
28865
29145
|
}));
|
|
29146
|
+
try {
|
|
29147
|
+
publish();
|
|
29148
|
+
} catch (error) {
|
|
29149
|
+
if (error.code !== "ENOENT")
|
|
29150
|
+
throw error;
|
|
29151
|
+
publish();
|
|
29152
|
+
}
|
|
28866
29153
|
log2(`[rpc] server listening on 127.0.0.1:${this.port}`);
|
|
28867
29154
|
} catch (err) {
|
|
28868
29155
|
log2(`[rpc] failed to write port file: ${err}`);
|
|
@@ -28870,6 +29157,7 @@ class MagicContextRpcServer {
|
|
|
28870
29157
|
return this.port;
|
|
28871
29158
|
}
|
|
28872
29159
|
stop() {
|
|
29160
|
+
this.stopped = true;
|
|
28873
29161
|
for (const ws of this.sockets) {
|
|
28874
29162
|
try {
|
|
28875
29163
|
if (ws.data.authTimer)
|
|
@@ -28886,6 +29174,9 @@ class MagicContextRpcServer {
|
|
|
28886
29174
|
try {
|
|
28887
29175
|
unlinkSync(this.portFilePath);
|
|
28888
29176
|
} catch {}
|
|
29177
|
+
try {
|
|
29178
|
+
rmdirSync(this.portDir);
|
|
29179
|
+
} catch {}
|
|
28889
29180
|
this.unregisterOwnInstance?.();
|
|
28890
29181
|
this.unregisterOwnInstance = null;
|
|
28891
29182
|
}
|
|
@@ -29033,7 +29324,7 @@ function json(body, status = 200) {
|
|
|
29033
29324
|
// src/shared/models-dev-temperature.ts
|
|
29034
29325
|
import { readFileSync as readFileSync7, statSync as statSync4 } from "node:fs";
|
|
29035
29326
|
import { homedir as homedir2 } from "node:os";
|
|
29036
|
-
import { join as
|
|
29327
|
+
import { join as join8 } from "node:path";
|
|
29037
29328
|
var CATALOG_PROVIDER_ALIASES = {
|
|
29038
29329
|
"google-antigravity": "google",
|
|
29039
29330
|
"opencode-zen": "opencode"
|
|
@@ -29043,7 +29334,7 @@ var cached;
|
|
|
29043
29334
|
function modelsDevCatalogPath(env = process.env) {
|
|
29044
29335
|
if (env.OPENCODE_MODELS_PATH)
|
|
29045
29336
|
return env.OPENCODE_MODELS_PATH;
|
|
29046
|
-
return
|
|
29337
|
+
return join8(env.XDG_CACHE_HOME || join8(homedir2(), ".cache"), "opencode", "models.json");
|
|
29047
29338
|
}
|
|
29048
29339
|
function buildIndex(raw) {
|
|
29049
29340
|
const index = new Map;
|