@cortexkit/opencode-magic-context 0.49.7 → 0.49.9
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/agents/hidden-agent-registrations.d.ts +5 -3
- package/dist/agents/hidden-agent-registrations.d.ts.map +1 -1
- package/dist/auto-search-worker.js +6 -6
- package/dist/compaction-marker-candidates-worker.js +2 -2
- package/dist/{compaction-marker-candidates-a0edbqrr.js → compaction-marker-candidates-xxz35vwp.js} +3 -3
- package/dist/config/schema/agent-overrides.d.ts +13 -13
- package/dist/config/schema/magic-context.d.ts +500 -500
- package/dist/{conflict-warning-hook-myk5hbt9.js → conflict-warning-hook-w3crzrar.js} +8 -8
- package/dist/{context-ffr7e0g7.js → context-ey3ap3cc.js} +81 -53
- package/dist/{derive-budgets-j4ry8j8n.js → derive-budgets-3nbxsyss.js} +2 -2
- package/dist/embedding-backfill-3h2m5n0q.js +21 -0
- package/dist/embedding-worker-process.js +6 -2
- package/dist/embedding-worker.js +6 -5
- package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/cron.d.ts +2 -0
- package/dist/features/magic-context/dreamer/cron.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/provider-output-failure.d.ts +1 -0
- package/dist/features/magic-context/dreamer/provider-output-failure.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/migration-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/primer-clustering.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/compiler-prompt.d.ts +1 -1
- package/dist/features/magic-context/smart-notes/compiler-prompt.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
- package/dist/features/magic-context/smart-notes/wake-plane.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/history-owner-ty29fz0f.js +244 -0
- package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
- package/dist/hooks/magic-context/__fixtures__/tail-hygiene-refresh.d.ts +34 -0
- package/dist/hooks/magic-context/__fixtures__/tail-hygiene-refresh.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts +1 -0
- package/dist/hooks/magic-context/ctx-reduce-nudge.d.ts.map +1 -1
- package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
- package/dist/hooks/magic-context/edit-marker.d.ts +2 -0
- package/dist/hooks/magic-context/edit-marker.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +2 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts +1 -0
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/provider-visible-parts.d.ts +10 -4
- package/dist/hooks/magic-context/provider-visible-parts.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts +8 -4
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +1 -0
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-refusal-recovery.d.ts.map +1 -1
- package/dist/hooks/magic-context/supersession-reclaim.d.ts +5 -3
- package/dist/hooks/magic-context/supersession-reclaim.d.ts.map +1 -1
- package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts +18 -0
- package/dist/hooks/magic-context/tail-hygiene-output-count.d.ts.map +1 -0
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts +5 -1
- package/dist/hooks/magic-context/tail-hygiene-walk.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-reclaim.d.ts +5 -2
- package/dist/hooks/magic-context/tool-reclaim.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +1 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/unresolved-history-boundary.d.ts +5 -1
- package/dist/hooks/magic-context/unresolved-history-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
- package/dist/{index-g8qbdb03.js → index-0jz47061.js} +6 -3
- package/dist/{index-wq16ahsn.js → index-0x9cn9w1.js} +8 -8
- package/dist/{index-4mjhqadz.js → index-150zz6fh.js} +1 -1
- package/dist/{index-n7kwfw2r.js → index-16vwdyy5.js} +7 -7
- package/dist/{index-rwmpkss5.js → index-21919gcq.js} +4 -4
- package/dist/{index-5tbvdff4.js → index-3403gbzj.js} +200 -135
- package/dist/{index-0gyq3djm.js → index-4hb8nt93.js} +3 -3
- package/dist/{index-ebnngykq.js → index-6k86es2p.js} +142 -27
- package/dist/{index-ax2jhztn.js → index-7bjgyaj1.js} +4 -4
- package/dist/{index-h2wc01qk.js → index-9jvab89d.js} +2 -2
- package/dist/{index-w6bd03dc.js → index-a43xq1pg.js} +5 -5
- package/dist/{index-tqf7yg27.js → index-a4b0gbyg.js} +1 -1
- package/dist/{index-j5hce1ab.js → index-a865mj02.js} +5 -5
- package/dist/{index-37q80veb.js → index-angx1s0k.js} +4 -3
- package/dist/{index-z1tjp257.js → index-b64n4d0h.js} +1 -1
- package/dist/{index-gbmqa9x9.js → index-bmwfzz28.js} +9 -6
- package/dist/{index-tmtty2x5.js → index-f8cn4xqa.js} +290 -61
- package/dist/{index-j58gqrn2.js → index-ffa8x2as.js} +31 -24
- package/dist/{index-1bt88epp.js → index-g7jkrz0x.js} +36 -16
- package/dist/{index-qx53vezw.js → index-gjvjh960.js} +1 -1
- package/dist/{index-w23dh319.js → index-jw4gbfkv.js} +1 -1
- package/dist/index-knvkbfvh.js +25 -0
- package/dist/{index-vkbqdnkj.js → index-kvw6xew3.js} +6 -3
- package/dist/{index-rzmjkdd6.js → index-mp2kghkv.js} +3 -27
- package/dist/{index-nsjyysj0.js → index-mvvephtj.js} +5 -1
- package/dist/{index-9yyqq3mm.js → index-n78avt2p.js} +1 -1
- package/dist/{index-w6vr754t.js → index-nenz4gpb.js} +13 -9
- package/dist/{index-vt4sf4ep.js → index-pgy3h49n.js} +4 -4
- package/dist/{v2/server-1rfgbjfn.js → index-q28hsbpg.js} +15 -3
- package/dist/{index-a8acx4gc.js → index-q76br5zn.js} +3 -3
- package/dist/{index-sf94at64.js → index-rg1cezmj.js} +22 -22
- package/dist/{index-sh91t19a.js → index-s178h9z8.js} +4 -3
- package/dist/{index-4btknbqh.js → index-swgpe402.js} +48 -38
- package/dist/{index-k6xvbj2e.js → index-w28y7d0z.js} +2 -0
- package/dist/{index-j8epsc0g.js → index-wafzvyhg.js} +33 -10
- package/dist/{index-n5a170gs.js → index-wpwpn7nj.js} +166 -63
- package/dist/{index-tagss15p.js → index-x57ep4fp.js} +124 -63
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +84 -79
- package/dist/{logger-ewak5q1s.js → logger-wn328tfg.js} +1 -1
- package/dist/{message-index-rqtse28y.js → message-index-6r1x9cqh.js} +16 -16
- package/dist/{message-index-bounded-04rycpx4.js → message-index-bounded-fskdyc81.js} +16 -16
- package/dist/{message-time-backfill-a5ytnp53.js → message-time-backfill-nb5hhnrt.js} +3 -3
- package/dist/migration-worker.js +11 -11
- package/dist/plugin/boot-quiet.d.ts.map +1 -1
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/rpc-handlers.d.ts +2 -0
- package/dist/plugin/rpc-handlers.d.ts.map +1 -1
- package/dist/{project-embedding-registry-k0sd9k7v.js → project-embedding-registry-vy7sv9jt.js} +11 -11
- package/dist/raw-ordinal-warmup-worker.js +6 -6
- package/dist/{read-session-chunk-h1btx938.js → read-session-chunk-zgpvs423.js} +11 -11
- package/dist/{read-session-raw-vdf4wh78.js → read-session-raw-gm6xj30v.js} +3 -3
- package/dist/recomp-orchestrator-77xc8wpe.js +60 -0
- package/dist/{safe-notification-target-q0cyrx3x.js → safe-notification-target-jdynm677.js} +2 -2
- package/dist/{search-3rbdx6hw.js → search-72fkjwk2.js} +24 -24
- package/dist/{send-session-notification-2tp44tfa.js → send-session-notification-q8ngbap3.js} +6 -6
- package/dist/shared/hidden-zen-read.d.ts +24 -0
- package/dist/shared/hidden-zen-read.d.ts.map +1 -0
- package/dist/shared/history-owner.d.ts +12 -0
- package/dist/shared/history-owner.d.ts.map +1 -0
- package/dist/shared/off-thread-migration-clock.d.ts +8 -1
- package/dist/shared/off-thread-migration-clock.d.ts.map +1 -1
- package/dist/shared/reclaim-distance.d.ts +33 -0
- package/dist/shared/reclaim-distance.d.ts.map +1 -0
- package/dist/shared/redaction.d.ts.map +1 -1
- package/dist/shared/rpc-server.d.ts.map +1 -1
- package/dist/shared/sqlite.d.ts +2 -0
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/stable-json.d.ts +7 -0
- package/dist/shared/stable-json.d.ts.map +1 -1
- package/dist/shared/tail-hygiene-json.d.ts +22 -0
- package/dist/shared/tail-hygiene-json.d.ts.map +1 -0
- package/dist/shared/transcript.d.ts +5 -0
- package/dist/shared/transcript.d.ts.map +1 -1
- package/dist/shared/user-facing-codes.d.ts +2 -2
- package/dist/{sqlite-j3tvg8r0.js → sqlite-4pqyynrs.js} +3 -1
- package/dist/{storage-memory-8168bgef.js → storage-memory-j3v3hc83.js} +2 -2
- package/dist/{storage-tags-61z5j2f9.js → storage-tags-35m4gms2.js} +5 -5
- package/dist/{transform-postprocess-phase-7qts7h54.js → transform-postprocess-phase-r8d406j0.js} +30 -30
- package/dist/v2/auto-search-worker.js +6 -6
- package/dist/v2/{compaction-marker-candidates-6nypjkpf.js → compaction-marker-candidates-a15w3mqh.js} +3 -3
- package/dist/v2/compaction-marker-candidates-worker.js +2 -2
- package/dist/v2/{context-xq4rtywr.js → context-z2yagwy4.js} +293 -91
- package/dist/v2/{derive-budgets-enckmg7y.js → derive-budgets-0rmpmxjw.js} +3 -3
- package/dist/v2/embedding-backfill-vr7wdtrf.js +20 -0
- package/dist/v2/embedding-worker-process.js +6 -2
- package/dist/v2/embedding-worker.js +6 -5
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/history-owner-2cr9py37.js +243 -0
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts +2 -2
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts +1 -0
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/{logger-pj02s7sr.js → logger-te6e1j72.js} +1 -1
- package/dist/v2/{message-index-8e5z2xx8.js → message-index-9ezq6wze.js} +16 -16
- package/dist/v2/{message-index-bounded-5vh1h2g7.js → message-index-bounded-rqc603f2.js} +16 -16
- package/dist/v2/{message-time-backfill-2z365239.js → message-time-backfill-rz1pnpaj.js} +3 -3
- package/dist/v2/migration-worker.js +11 -11
- package/dist/v2/{project-embedding-registry-b77awytr.js → project-embedding-registry-ja23aygk.js} +11 -11
- package/dist/v2/raw-ordinal-warmup-worker.js +6 -6
- package/dist/v2/{read-session-chunk-4sat83cx.js → read-session-chunk-7f87tg2q.js} +11 -11
- package/dist/v2/{read-session-raw-a3hw9jsp.js → read-session-raw-h4azh85b.js} +3 -3
- package/dist/v2/recomp-orchestrator-s5tdpsbs.js +59 -0
- package/dist/v2/{safe-notification-target-y3p1hce9.js → safe-notification-target-936374xx.js} +2 -2
- package/dist/v2/search-2td1b1wy.js +46 -0
- package/dist/v2/{send-session-notification-ppgc8qdz.js → send-session-notification-6n7chhyp.js} +6 -6
- package/dist/v2/{server-v4fwha43.js → server-23znwjqk.js} +48 -38
- package/dist/v2/{server-nfan6zb6.js → server-2hxypdx5.js} +31 -24
- package/dist/v2/{server-ras2sxnc.js → server-44ryn9rb.js} +9 -6
- package/dist/v2/{server-fw31krgq.js → server-4easnf78.js} +19 -19
- package/dist/v2/{server-d6g4whc2.js → server-4qr18rfg.js} +3 -3
- package/dist/v2/{server-sy4b1sra.js → server-4rs8sm06.js} +5 -5
- package/dist/v2/{server-jdwd03ep.js → server-4zwx20yg.js} +7 -7
- package/dist/v2/{server-brhj8qtd.js → server-63ha7f0f.js} +3 -27
- package/dist/v2/{server-3t0q2cqx.js → server-7dv9wt9r.js} +1 -1
- package/dist/v2/{server-cw6521wn.js → server-7e087rvk.js} +2 -0
- package/dist/v2/{server-6byqfbqf.js → server-89fcbe37.js} +36 -16
- package/dist/v2/{server-hb6xhh9q.js → server-988cqjme.js} +6 -3
- package/dist/v2/{server-fpqe39as.js → server-9a6bwc12.js} +4 -4
- package/dist/v2/{server-t4k4qexw.js → server-9e5r8y60.js} +5 -1
- package/dist/v2/{server-qcw43339.js → server-ak7w74j9.js} +4 -4
- package/dist/v2/{server-dd0nja67.js → server-bx59ezg6.js} +4 -3
- package/dist/v2/{server-mv1w7t6z.js → server-c9w52qss.js} +99 -43
- package/dist/v2/{server-676xw7at.js → server-ckrb5rm8.js} +1 -1
- package/dist/{index-w4mw92w3.js → v2/server-cxsr0ng6.js} +15 -3
- package/dist/v2/{server-hcvcxzx7.js → server-f27he3j1.js} +5 -5
- package/dist/v2/{server-gtv9wbhq.js → server-gc8x2xdb.js} +144 -63
- package/dist/v2/{server-t528t8qm.js → server-hn9fb3v0.js} +2 -2
- package/dist/v2/{server-w3zeywp1.js → server-kmapq3v0.js} +289 -60
- package/dist/v2/server-knvkbfvh.js +25 -0
- package/dist/v2/{server-9yyqq3mm.js → server-n78avt2p.js} +1 -1
- package/dist/v2/{server-kdrezdy0.js → server-njnx39q2.js} +6 -3
- package/dist/v2/{server-x08d1xf3.js → server-npm52h2q.js} +4 -3
- package/dist/v2/{server-vb7pbd9p.js → server-nveratm5.js} +1 -1
- package/dist/v2/{server-kzns2hbz.js → server-s6jqh8bj.js} +1 -1
- package/dist/v2/{server-j8epsc0g.js → server-wafzvyhg.js} +33 -10
- package/dist/v2/{server-7ekna9zs.js → server-xqf2d2mg.js} +2 -2
- package/dist/v2/{server-7srtwsa4.js → server-z0rjemg1.js} +9 -9
- package/dist/v2/{server-wkdgjjch.js → server-zrwaj29a.js} +2 -2
- package/dist/v2/server.js +7 -6
- package/dist/v2/{sqlite-j3tvg8r0.js → sqlite-4pqyynrs.js} +3 -1
- package/dist/v2/{storage-memory-8168bgef.js → storage-memory-j3v3hc83.js} +2 -2
- package/dist/v2/{storage-tags-j2fzq3sw.js → storage-tags-c4zfcxv4.js} +5 -5
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{wrapup-orchestrator-s92ebfzv.js → wrapup-orchestrator-wg8dmmm9.js} +38 -35
- package/dist/wrapup-orchestrator-b1z99yg5.js +47 -0
- package/package.json +1 -1
- package/src/agents/hidden-agent-registrations.ts +22 -4
- package/src/config/compaction-accessor-guard.test.ts +3 -0
- package/src/features/magic-context/dreamer/cron.ts +8 -0
- package/src/shared/hidden-zen-read.test.ts +99 -0
- package/src/shared/hidden-zen-read.ts +88 -0
- package/src/shared/history-owner.test.ts +60 -0
- package/src/shared/history-owner.ts +43 -0
- package/src/shared/host-stall-profiler-node.ts +3 -1
- package/src/shared/host-stall-profiler.ts +3 -1
- package/src/shared/off-thread-migration-clock.test.ts +80 -10
- package/src/shared/off-thread-migration-clock.ts +37 -13
- package/src/shared/reclaim-distance.test.ts +111 -0
- package/src/shared/reclaim-distance.ts +91 -0
- package/src/shared/redaction.test.ts +16 -0
- package/src/shared/redaction.ts +8 -1
- package/src/shared/root-async-context.probe.mjs +36 -0
- package/src/shared/root-async-context.test.ts +49 -0
- package/src/shared/rpc-server.ts +27 -23
- package/src/shared/sqlite-busy-budget-review.test.ts +291 -0
- package/src/shared/sqlite-foreground-wait.test.ts +253 -1
- package/src/shared/sqlite.ts +55 -14
- package/src/shared/stable-json.ts +56 -14
- package/src/shared/tail-hygiene-json.test.ts +117 -0
- package/src/shared/tail-hygiene-json.ts +217 -0
- package/src/shared/transcript.ts +7 -0
- package/src/shared/user-facing-codes.ts +2 -2
- package/dist/embedding-backfill-re16xncd.js +0 -21
- package/dist/recomp-orchestrator-trcgmm23.js +0 -60
- package/dist/v2/embedding-backfill-xd9ygzgd.js +0 -20
- package/dist/v2/recomp-orchestrator-n11zv1f1.js +0 -59
- package/dist/v2/search-mvgqtkkz.js +0 -46
- package/dist/wrapup-orchestrator-df61jmz9.js +0 -47
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
resolveLegacyConfigSources,
|
|
10
10
|
getProtectedTokensTierOverrides,
|
|
11
11
|
loadPluginConfigDetailed
|
|
12
|
-
} from "./server-
|
|
12
|
+
} from "./server-4qr18rfg.js";
|
|
13
13
|
import {
|
|
14
14
|
getHarness2,
|
|
15
15
|
harnessOwnsOpenCodeStore2
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
log2,
|
|
25
25
|
sessionLog2,
|
|
26
26
|
getLoggerDiagnostics2
|
|
27
|
-
} from "./server-
|
|
27
|
+
} from "./server-9e5r8y60.js";
|
|
28
28
|
import {
|
|
29
29
|
hasTrustedAbsoluteWall,
|
|
30
30
|
applyProvenInputFloor,
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
getSdkContextLimit,
|
|
37
37
|
getSdkOutputLimit,
|
|
38
38
|
getModelsDevCacheState
|
|
39
|
-
} from "./server-
|
|
39
|
+
} from "./server-nveratm5.js";
|
|
40
40
|
import {
|
|
41
41
|
withContentLanguageDirective,
|
|
42
42
|
parseCron,
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
49
49
|
DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
50
50
|
DREAM_TASK_PROMOTION_DEFAULTS
|
|
51
|
-
} from "./server-
|
|
51
|
+
} from "./server-7e087rvk.js";
|
|
52
52
|
import {
|
|
53
53
|
historianRunConfig,
|
|
54
54
|
dreamerRunConfig,
|
|
@@ -265,7 +265,7 @@ import {
|
|
|
265
265
|
startCompartmentAgent,
|
|
266
266
|
setRecompStarting2,
|
|
267
267
|
setRecompTerminal2
|
|
268
|
-
} from "./server-
|
|
268
|
+
} from "./server-c9w52qss.js";
|
|
269
269
|
import {
|
|
270
270
|
CANONICAL_DREAM_TASKS,
|
|
271
271
|
DREAM_TASK_CAPABILITIES,
|
|
@@ -303,7 +303,7 @@ import {
|
|
|
303
303
|
openDatabaseAsync,
|
|
304
304
|
isDatabasePersisted,
|
|
305
305
|
getDatabasePersistenceError
|
|
306
|
-
} from "./server-
|
|
306
|
+
} from "./server-23znwjqk.js";
|
|
307
307
|
import {
|
|
308
308
|
setHomeProjectPermission,
|
|
309
309
|
shouldSkipHomeProjectMemory,
|
|
@@ -319,7 +319,7 @@ import {
|
|
|
319
319
|
storedPathBelongsToIdentity,
|
|
320
320
|
beginBootQuietPeriod,
|
|
321
321
|
scheduleAfterBootQuiet
|
|
322
|
-
} from "./server-
|
|
322
|
+
} from "./server-njnx39q2.js";
|
|
323
323
|
import {
|
|
324
324
|
detectLatestTurnThinkingMismatch,
|
|
325
325
|
isPrefixBoundThinkingModel,
|
|
@@ -337,6 +337,7 @@ import {
|
|
|
337
337
|
toolPartHasUserAnswer,
|
|
338
338
|
DreamTokenBudgetExceeded,
|
|
339
339
|
createDreamTokenBudget,
|
|
340
|
+
needsBlockedRead,
|
|
340
341
|
recordToolParameters,
|
|
341
342
|
createDroppedInputGuard,
|
|
342
343
|
assertExecutableToolInput,
|
|
@@ -473,6 +474,7 @@ import {
|
|
|
473
474
|
reasoningTextAndOpaque,
|
|
474
475
|
opencodeReasoningBudgetCutoff,
|
|
475
476
|
describeFinalWireTail,
|
|
477
|
+
estimatePartImageTokens,
|
|
476
478
|
estimateMessageTokens,
|
|
477
479
|
wireContentBytes,
|
|
478
480
|
createFinalWireUsageTracker,
|
|
@@ -499,11 +501,12 @@ import {
|
|
|
499
501
|
readRawSessionMessageIdOrdinalsForRange2,
|
|
500
502
|
readRawSessionMessagePartsById2,
|
|
501
503
|
readRawSessionBoundaryEndpoints2,
|
|
504
|
+
hasRawSessionMessageById2,
|
|
502
505
|
readRawSessionMessageOrdinalById2,
|
|
503
506
|
readRawSessionMessageById2,
|
|
504
507
|
readSessionChunk2,
|
|
505
508
|
readRawSessionSeedTail2
|
|
506
|
-
} from "./server-
|
|
509
|
+
} from "./server-gc8x2xdb.js";
|
|
507
510
|
import {
|
|
508
511
|
textMentionsRecentCommit,
|
|
509
512
|
hasMeaningfulUserText2,
|
|
@@ -514,7 +517,7 @@ import {
|
|
|
514
517
|
estimateTokens,
|
|
515
518
|
estimateFixedPromptTokens,
|
|
516
519
|
normalizeText
|
|
517
|
-
} from "./server-
|
|
520
|
+
} from "./server-s6jqh8bj.js";
|
|
518
521
|
import {
|
|
519
522
|
SubcClient,
|
|
520
523
|
connectionFileExists,
|
|
@@ -522,8 +525,9 @@ import {
|
|
|
522
525
|
toSynapseLaneDescriptor,
|
|
523
526
|
formatSynapseLaneDescriptor,
|
|
524
527
|
SynapseEmbeddingProvider
|
|
525
|
-
} from "./server-
|
|
528
|
+
} from "./server-988cqjme.js";
|
|
526
529
|
import {
|
|
530
|
+
inRootAsyncContext2,
|
|
527
531
|
getTagIdentityWriteGeneration2,
|
|
528
532
|
Database2,
|
|
529
533
|
getSqliteDatabasePath2,
|
|
@@ -535,21 +539,18 @@ import {
|
|
|
535
539
|
isTransientSqliteError2,
|
|
536
540
|
SqliteAcquisitionBusyError2,
|
|
537
541
|
withAsyncPrivilegedWriter2
|
|
538
|
-
} from "./server-
|
|
539
|
-
import
|
|
540
|
-
sameProjectDirectory,
|
|
541
|
-
canonicalProjectDirectory
|
|
542
|
-
} from "./server-brhj8qtd.js";
|
|
542
|
+
} from "./server-wafzvyhg.js";
|
|
543
|
+
import"./server-63ha7f0f.js";
|
|
543
544
|
import {
|
|
544
545
|
deleteChunkEmbedBackoffForSession
|
|
545
|
-
} from "./server-
|
|
546
|
+
} from "./server-9a6bwc12.js";
|
|
546
547
|
import {
|
|
547
548
|
registerOwnRpcServerInstance,
|
|
548
549
|
rpcPortDir,
|
|
549
550
|
rpcPortFilePath,
|
|
550
551
|
parseRpcPortFile,
|
|
551
552
|
inspectProcessesAsync
|
|
552
|
-
} from "./server-
|
|
553
|
+
} from "./server-cxsr0ng6.js";
|
|
553
554
|
import {
|
|
554
555
|
BoundedSessionMap,
|
|
555
556
|
LkgRecoveryFenceError,
|
|
@@ -568,14 +569,14 @@ import {
|
|
|
568
569
|
isMessageIndexReconciledThrough2,
|
|
569
570
|
indexMessagesAfterOrdinal2,
|
|
570
571
|
sweepOrphanedOpenCodeMessageIndexes2
|
|
571
|
-
} from "./server-
|
|
572
|
+
} from "./server-z0rjemg1.js";
|
|
572
573
|
import {
|
|
573
574
|
stableStringify,
|
|
574
575
|
getTemporalDecisions,
|
|
575
576
|
observeTemporalDecisions,
|
|
576
577
|
freezeTemporalDecisions,
|
|
577
578
|
tagIdentityRevisionKey
|
|
578
|
-
} from "./server-
|
|
579
|
+
} from "./server-89fcbe37.js";
|
|
579
580
|
import {
|
|
580
581
|
resolveModelCalibration,
|
|
581
582
|
calibrateBuckets,
|
|
@@ -590,6 +591,7 @@ import {
|
|
|
590
591
|
peelLeadingMcTagNotation,
|
|
591
592
|
prependTag,
|
|
592
593
|
isThinkingPart,
|
|
594
|
+
currentReclaimableToolOutputCount,
|
|
593
595
|
isRecord,
|
|
594
596
|
contentTagOwnerMessageId,
|
|
595
597
|
estimateImageTokensFromDataUrl,
|
|
@@ -614,7 +616,6 @@ import {
|
|
|
614
616
|
evaluateChannel2,
|
|
615
617
|
formatChannel1Evaluation,
|
|
616
618
|
formatChannel2Evaluation,
|
|
617
|
-
reclaimableToolOutputCount,
|
|
618
619
|
buildChannel2Reminder,
|
|
619
620
|
buildChannel1Reminder,
|
|
620
621
|
estimateEmergencyDropReclaimTokens,
|
|
@@ -667,14 +668,14 @@ import {
|
|
|
667
668
|
adoptNullOwnerToolTag2,
|
|
668
669
|
getCandidateToolOwners2,
|
|
669
670
|
pickNearestPriorOwner2
|
|
670
|
-
} from "./server-
|
|
671
|
+
} from "./server-kmapq3v0.js";
|
|
671
672
|
import"./server-51779zs2.js";
|
|
672
673
|
import {
|
|
673
674
|
isRawCompactionSummaryInfo2,
|
|
674
675
|
extractInMemoryMessageViews2,
|
|
675
676
|
buildInMemoryTailRawMessages2,
|
|
676
677
|
runSessionWarmupWorker
|
|
677
|
-
} from "./server-
|
|
678
|
+
} from "./server-bx59ezg6.js";
|
|
678
679
|
import {
|
|
679
680
|
resolveOpenCodeDbPath,
|
|
680
681
|
assertOpenCodeStoreGeneration,
|
|
@@ -690,12 +691,12 @@ import {
|
|
|
690
691
|
latestRealUserTurnIdFromOpenCodeDb,
|
|
691
692
|
getMessageTimesFromOpenCodeDb,
|
|
692
693
|
findLastAssistantModelFromOpenCodeDb
|
|
693
|
-
} from "./server-
|
|
694
|
+
} from "./server-zrwaj29a.js";
|
|
694
695
|
import {
|
|
695
696
|
getCurrentToolSetHash,
|
|
696
697
|
recordToolDefinition,
|
|
697
698
|
getMeasuredToolDefinitionTokens
|
|
698
|
-
} from "./server-
|
|
699
|
+
} from "./server-xqf2d2mg.js";
|
|
699
700
|
import {
|
|
700
701
|
V2_MEMORY_CATEGORIES,
|
|
701
702
|
CATEGORY_PRIORITY
|
|
@@ -708,7 +709,7 @@ import {
|
|
|
708
709
|
resolveStoredPathWorkspaceIdentity,
|
|
709
710
|
storedPathBelongsToWorkspace,
|
|
710
711
|
computeWorkspaceEpochFingerprint
|
|
711
|
-
} from "./server-
|
|
712
|
+
} from "./server-f27he3j1.js";
|
|
712
713
|
import {
|
|
713
714
|
GIT_SWEEP_LEASE_RENEWAL_MS,
|
|
714
715
|
acquireGitSweepLease,
|
|
@@ -735,7 +736,7 @@ import {
|
|
|
735
736
|
drainCommitBacklogForProject2,
|
|
736
737
|
embedSessionCompartmentChunks2,
|
|
737
738
|
getEmbeddingCoverageStatus2
|
|
738
|
-
} from "./server-
|
|
739
|
+
} from "./server-4easnf78.js";
|
|
739
740
|
import"./server-fb3zxn06.js";
|
|
740
741
|
import {
|
|
741
742
|
SESSION_NOTE_CONDITION_ERROR,
|
|
@@ -779,15 +780,15 @@ import {
|
|
|
779
780
|
readGitFileChangeTimesSince,
|
|
780
781
|
verificationFileExists,
|
|
781
782
|
normalizeVerificationFiles
|
|
782
|
-
} from "./server-
|
|
783
|
+
} from "./server-4zwx20yg.js";
|
|
783
784
|
import {
|
|
784
785
|
deriveTriggerBudget2,
|
|
785
786
|
deriveHistorianChunkTokens2,
|
|
786
787
|
resolveKnownHistorianContextLimit2,
|
|
787
788
|
resolveHistorianProducerLimits2,
|
|
788
789
|
resolveHistorianContextLimit2
|
|
789
|
-
} from "./server-
|
|
790
|
-
import"./server-
|
|
790
|
+
} from "./server-hn9fb3v0.js";
|
|
791
|
+
import"./server-npm52h2q.js";
|
|
791
792
|
import {
|
|
792
793
|
isEmbeddingHostBusy2
|
|
793
794
|
} from "./server-qt1qqasc.js";
|
|
@@ -798,10 +799,10 @@ import {
|
|
|
798
799
|
} from "./server-4dhv7mqz.js";
|
|
799
800
|
import {
|
|
800
801
|
getLocalEmbeddingNativeMemoryStats
|
|
801
|
-
} from "./server-
|
|
802
|
+
} from "./server-44ryn9rb.js";
|
|
802
803
|
import {
|
|
803
804
|
cosineSimilarity
|
|
804
|
-
} from "./server-
|
|
805
|
+
} from "./server-4rs8sm06.js";
|
|
805
806
|
import {
|
|
806
807
|
computeCueContentHash,
|
|
807
808
|
hasMuralCueColumns,
|
|
@@ -826,7 +827,7 @@ import {
|
|
|
826
827
|
mergeMemoryStats2,
|
|
827
828
|
archiveMemory2,
|
|
828
829
|
getMemoryCountsByStatus2
|
|
829
|
-
} from "./server-
|
|
830
|
+
} from "./server-n78avt2p.js";
|
|
830
831
|
import {
|
|
831
832
|
registerNotificationSink2,
|
|
832
833
|
pushNotification2,
|
|
@@ -834,11 +835,11 @@ import {
|
|
|
834
835
|
drainNotifications2,
|
|
835
836
|
isTuiConnected2
|
|
836
837
|
} from "./server-x8a7jmkh.js";
|
|
837
|
-
import"./server-
|
|
838
|
+
import"./server-ckrb5rm8.js";
|
|
838
839
|
import {
|
|
839
840
|
flushIgnoredMessages2,
|
|
840
841
|
sendStatusNotification2
|
|
841
|
-
} from "./server-
|
|
842
|
+
} from "./server-ak7w74j9.js";
|
|
842
843
|
import {
|
|
843
844
|
renderSingleStoreMigrationRequiredRefusal,
|
|
844
845
|
SingleStoreMigrationRequiredError,
|
|
@@ -859,7 +860,7 @@ import {
|
|
|
859
860
|
resolveMemoriesByIdsForSearch2,
|
|
860
861
|
unifiedSearch2,
|
|
861
862
|
formatSearchResults2
|
|
862
|
-
} from "./server-
|
|
863
|
+
} from "./server-2hxypdx5.js";
|
|
863
864
|
import {
|
|
864
865
|
resolvePromptContext2
|
|
865
866
|
} from "./server-fmsr7v69.js";
|
|
@@ -873,6 +874,10 @@ import {
|
|
|
873
874
|
import {
|
|
874
875
|
computeNormalizedHash
|
|
875
876
|
} from "./server-2bvekkfy.js";
|
|
877
|
+
import {
|
|
878
|
+
sameProjectDirectory,
|
|
879
|
+
canonicalProjectDirectory
|
|
880
|
+
} from "./server-knvkbfvh.js";
|
|
876
881
|
import {
|
|
877
882
|
getErrorMessage,
|
|
878
883
|
describeError
|
|
@@ -899,7 +904,7 @@ import {
|
|
|
899
904
|
} from "./server-8ajstryz.js";
|
|
900
905
|
import {
|
|
901
906
|
logSlowWriteTransaction
|
|
902
|
-
} from "./server-
|
|
907
|
+
} from "./server-7dv9wt9r.js";
|
|
903
908
|
|
|
904
909
|
// ../../node_modules/.bun/zod@4.1.8/node_modules/zod/v4/classic/external.js
|
|
905
910
|
var exports_external = {};
|
|
@@ -2968,10 +2973,10 @@ async function sourceReady(source, sessionId) {
|
|
|
2968
2973
|
function defer(fn) {
|
|
2969
2974
|
const immediate = globalThis.setImmediate;
|
|
2970
2975
|
if (typeof immediate === "function") {
|
|
2971
|
-
immediate(fn);
|
|
2976
|
+
inRootAsyncContext2(() => immediate(fn));
|
|
2972
2977
|
return;
|
|
2973
2978
|
}
|
|
2974
|
-
setTimeout(fn, 0);
|
|
2979
|
+
inRootAsyncContext2(() => setTimeout(fn, 0));
|
|
2975
2980
|
}
|
|
2976
2981
|
function yieldToEventLoop() {
|
|
2977
2982
|
return new Promise((resolve) => defer(resolve));
|
|
@@ -3055,14 +3060,14 @@ function scheduleReconciliation(db, sessionId, readMessages) {
|
|
|
3055
3060
|
reconcileSessionIndex(db, sessionId, readMessages).then((ran) => {
|
|
3056
3061
|
if (ran)
|
|
3057
3062
|
return;
|
|
3058
|
-
setTimeout(() => {
|
|
3063
|
+
inRootAsyncContext2(() => setTimeout(() => {
|
|
3059
3064
|
heapHolder.reconciliationScheduledSessions.delete(sessionId);
|
|
3060
3065
|
scheduleReconciliation(db, sessionId, readMessages);
|
|
3061
|
-
}, PREPARE_RETRY_MS).unref?.();
|
|
3066
|
+
}, PREPARE_RETRY_MS)).unref?.();
|
|
3062
3067
|
}).catch((error) => {
|
|
3063
3068
|
logIndexingError(sessionId, "reconciliation", error);
|
|
3064
3069
|
if (isDatabaseLockedError(error))
|
|
3065
|
-
setTimeout(() => scheduleReconciliation(db, sessionId, readMessages), 1000).unref();
|
|
3070
|
+
inRootAsyncContext2(() => setTimeout(() => scheduleReconciliation(db, sessionId, readMessages), 1000)).unref();
|
|
3066
3071
|
}).finally(() => {
|
|
3067
3072
|
heapHolder.reconciliationScheduledSessions.delete(sessionId);
|
|
3068
3073
|
});
|
|
@@ -3872,7 +3877,7 @@ function queueAutoSearchBackfill(db, sessionId, projectPath, query) {
|
|
|
3872
3877
|
pending.delete(key);
|
|
3873
3878
|
resolve();
|
|
3874
3879
|
};
|
|
3875
|
-
const queued = setTimeout(() => {
|
|
3880
|
+
const queued = inRootAsyncContext2(() => setTimeout(() => {
|
|
3876
3881
|
lifecycle.signal.removeEventListener("abort", cancel);
|
|
3877
3882
|
if (lifecycle.signal.aborted)
|
|
3878
3883
|
return done();
|
|
@@ -3883,7 +3888,7 @@ function queueAutoSearchBackfill(db, sessionId, projectPath, query) {
|
|
|
3883
3888
|
clearTimeout(timeout);
|
|
3884
3889
|
done();
|
|
3885
3890
|
});
|
|
3886
|
-
}, 0);
|
|
3891
|
+
}, 0));
|
|
3887
3892
|
const cancel = () => {
|
|
3888
3893
|
clearTimeout(queued);
|
|
3889
3894
|
done();
|
|
@@ -3930,7 +3935,7 @@ async function executeAutoSearchWorker(db, sessionId, projectPath, query, option
|
|
|
3930
3935
|
deadlineUnixMs: autoSearchDeadlineUnixMs(deadlineSignal)
|
|
3931
3936
|
};
|
|
3932
3937
|
return new Promise((resolve, reject) => {
|
|
3933
|
-
const worker = new Worker(entry, { workerData: input });
|
|
3938
|
+
const worker = inRootAsyncContext2(() => new Worker(entry, { workerData: input }));
|
|
3934
3939
|
let settled = false;
|
|
3935
3940
|
const finish = (results, error) => {
|
|
3936
3941
|
if (settled)
|
|
@@ -4042,7 +4047,7 @@ function searchMessageHistoryOffThread(db, request, entry = defaultAutoSearchWor
|
|
|
4042
4047
|
deadline.unref?.();
|
|
4043
4048
|
};
|
|
4044
4049
|
try {
|
|
4045
|
-
worker = new Worker(entry, { workerData: input });
|
|
4050
|
+
worker = inRootAsyncContext2(() => new Worker(entry, { workerData: input }));
|
|
4046
4051
|
} catch (error) {
|
|
4047
4052
|
finish(null, "start-failed", error);
|
|
4048
4053
|
return;
|
|
@@ -5931,7 +5936,7 @@ function maybeInjectChannel1Nudge(args, sessionId, tool, output) {
|
|
|
5931
5936
|
setChannel1NudgeState(args.db, sessionId, nextNudgeState);
|
|
5932
5937
|
return;
|
|
5933
5938
|
}
|
|
5934
|
-
out.output += buildChannel1Reminder(decision.level, decision.undroppedTokens,
|
|
5939
|
+
out.output += buildChannel1Reminder(decision.level, decision.undroppedTokens, currentReclaimableToolOutputCount(state), state.oldestReclaimableToolTags, decision.sticky);
|
|
5935
5940
|
setChannel1NudgeState(args.db, sessionId, {
|
|
5936
5941
|
...nextNudgeState,
|
|
5937
5942
|
ordinal: state.realUserTurnCount
|
|
@@ -7672,7 +7677,7 @@ function buildEditSupersessionReclaim(input) {
|
|
|
7672
7677
|
seenFile.add(filePath);
|
|
7673
7678
|
continue;
|
|
7674
7679
|
}
|
|
7675
|
-
if (input.recentMessageIds && (tag.toolOwnerMessageId === null || input.recentMessageIds.has(tag.toolOwnerMessageId))) {
|
|
7680
|
+
if (tag.tagNumber > input.watermark || input.recentMessageIds && (tag.toolOwnerMessageId === null || input.recentMessageIds.has(tag.toolOwnerMessageId))) {
|
|
7676
7681
|
continue;
|
|
7677
7682
|
}
|
|
7678
7683
|
if (realPendingTagIds.has(tag.tagNumber))
|
|
@@ -7770,6 +7775,51 @@ async function waitForTagOwners(db, sessionId, ratio, waitMs = 250) {
|
|
|
7770
7775
|
}
|
|
7771
7776
|
}
|
|
7772
7777
|
|
|
7778
|
+
// src/shared/reclaim-distance.ts
|
|
7779
|
+
var RECLAIM_DISTANCE_USER_TURNS = 3;
|
|
7780
|
+
var RECLAIM_DISTANCE_WINDOW_FRACTION = 0.25;
|
|
7781
|
+
function isReclaimUserTurn(args) {
|
|
7782
|
+
return args.role === "user" && !args.syntheticHead && !args.synthetic && !args.ignored && args.parts.some((part) => {
|
|
7783
|
+
if (part.synthetic || part.ignored)
|
|
7784
|
+
return false;
|
|
7785
|
+
if (part.kind !== "text" && part.kind !== "image" && part.kind !== "file")
|
|
7786
|
+
return false;
|
|
7787
|
+
if (part.kind !== "text")
|
|
7788
|
+
return true;
|
|
7789
|
+
return stripReclaimMcText(part.text ?? "").trim().length > 0;
|
|
7790
|
+
});
|
|
7791
|
+
}
|
|
7792
|
+
function stripReclaimMcText(text) {
|
|
7793
|
+
return text.replace(/^§\d+§\s*/, "").replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, (reminder) => /^(?:Your next step: call ctx_reduce on the outputs you've already used|Still unstamped:|Housekeeping: .* are reclaimable\. Stamp each output with ctx_reduce|.* are reclaimable\. Make a ctx_reduce pass now|.* are still unstamped\. Call ctx_reduce now)/.test(reminder.slice("<system-reminder>".length).trimStart()) ? "" : reminder).replace(/<instruction name="deferred_notes">[\s\S]*?<\/instruction>/g, "");
|
|
7794
|
+
}
|
|
7795
|
+
function farBehindToolBookmark(entries, usableWindow) {
|
|
7796
|
+
let newerTurns = 0;
|
|
7797
|
+
let newerTokens = 0;
|
|
7798
|
+
const farTags = [];
|
|
7799
|
+
let firstYoungTag = Infinity;
|
|
7800
|
+
const seenOutputs = new Set;
|
|
7801
|
+
const tokenDistance = usableWindow > 0 && Number.isFinite(usableWindow) ? usableWindow * RECLAIM_DISTANCE_WINDOW_FRACTION : Infinity;
|
|
7802
|
+
for (let index = entries.length - 1;index >= 0; index--) {
|
|
7803
|
+
const entry = entries[index];
|
|
7804
|
+
if (!entry)
|
|
7805
|
+
continue;
|
|
7806
|
+
const tag = entry.toolOutputTag;
|
|
7807
|
+
if (tag !== undefined && !seenOutputs.has(tag)) {
|
|
7808
|
+
seenOutputs.add(tag);
|
|
7809
|
+
if (newerTurns >= RECLAIM_DISTANCE_USER_TURNS || newerTokens >= tokenDistance) {
|
|
7810
|
+
farTags.push(tag);
|
|
7811
|
+
} else {
|
|
7812
|
+
firstYoungTag = Math.min(firstYoungTag, tag);
|
|
7813
|
+
}
|
|
7814
|
+
}
|
|
7815
|
+
if (entry.userTurn)
|
|
7816
|
+
newerTurns++;
|
|
7817
|
+
if (Number.isFinite(entry.tokens) && entry.tokens > 0)
|
|
7818
|
+
newerTokens += entry.tokens;
|
|
7819
|
+
}
|
|
7820
|
+
return farTags.reduce((bookmark, tag) => tag < firstYoungTag ? Math.max(bookmark, tag) : bookmark, 0);
|
|
7821
|
+
}
|
|
7822
|
+
|
|
7773
7823
|
// src/hooks/magic-context/tool-reclaim.ts
|
|
7774
7824
|
function buildSyntheticToolReclaimOps(input) {
|
|
7775
7825
|
const watermark = Math.max(0, input.watermark);
|
|
@@ -7801,10 +7851,74 @@ function buildSyntheticToolReclaimOps(input) {
|
|
|
7801
7851
|
}
|
|
7802
7852
|
return synthetic;
|
|
7803
7853
|
}
|
|
7804
|
-
function
|
|
7805
|
-
const
|
|
7806
|
-
advanceToolReclaimWatermark(db, sessionId,
|
|
7807
|
-
return
|
|
7854
|
+
function advanceToolReclaimWatermarkByDistance(db, sessionId, entries, usableWindow) {
|
|
7855
|
+
const bookmark = farBehindToolBookmark(entries, usableWindow);
|
|
7856
|
+
advanceToolReclaimWatermark(db, sessionId, bookmark);
|
|
7857
|
+
return bookmark;
|
|
7858
|
+
}
|
|
7859
|
+
function toolReclaimDistanceEntries(messages, targets) {
|
|
7860
|
+
const outputTags = new Map;
|
|
7861
|
+
for (const [tag, target] of targets) {
|
|
7862
|
+
for (const location of target.mutationParts ?? []) {
|
|
7863
|
+
const part = distancePart(location.part);
|
|
7864
|
+
if (part.kind === "tool_result" || part.kind === "tool")
|
|
7865
|
+
outputTags.set(location.part, tag);
|
|
7866
|
+
}
|
|
7867
|
+
}
|
|
7868
|
+
const entries = [];
|
|
7869
|
+
for (const message of messages) {
|
|
7870
|
+
const parts = message.parts.map(distancePart);
|
|
7871
|
+
let userTurn = isReclaimUserTurn({ ...message.info, parts });
|
|
7872
|
+
for (const [index, part] of parts.entries()) {
|
|
7873
|
+
const authored = isReclaimUserTurn({ role: "user", parts: [part] });
|
|
7874
|
+
entries.push({
|
|
7875
|
+
tokens: message.info.syntheticHead ? 0 : estimateTokens(stripReclaimMcText(part.text ?? "")) + part.imageTokens,
|
|
7876
|
+
userTurn: userTurn && authored,
|
|
7877
|
+
toolOutputTag: outputTags.get(message.parts[index])
|
|
7878
|
+
});
|
|
7879
|
+
if (authored)
|
|
7880
|
+
userTurn = false;
|
|
7881
|
+
}
|
|
7882
|
+
}
|
|
7883
|
+
return entries;
|
|
7884
|
+
}
|
|
7885
|
+
function distancePart(raw) {
|
|
7886
|
+
if (!raw || typeof raw !== "object")
|
|
7887
|
+
return { kind: "structural", imageTokens: 0 };
|
|
7888
|
+
const part = raw;
|
|
7889
|
+
const provenance = { synthetic: part.synthetic === true, ignored: part.ignored === true };
|
|
7890
|
+
if (typeof part.getText === "function") {
|
|
7891
|
+
const text = part.getText();
|
|
7892
|
+
return {
|
|
7893
|
+
...provenance,
|
|
7894
|
+
kind: String(part.kind),
|
|
7895
|
+
text: typeof text === "string" ? text : undefined,
|
|
7896
|
+
imageTokens: typeof part.imageTokens === "function" ? Number(part.imageTokens()) : 0
|
|
7897
|
+
};
|
|
7898
|
+
}
|
|
7899
|
+
const metadata = { ...provenance, imageTokens: estimatePartImageTokens(raw) };
|
|
7900
|
+
if (part.type === "tool") {
|
|
7901
|
+
const state = part.state;
|
|
7902
|
+
return {
|
|
7903
|
+
...metadata,
|
|
7904
|
+
kind: "tool",
|
|
7905
|
+
text: `${JSON.stringify(state?.input ?? {})}
|
|
7906
|
+
${typeof state?.output === "string" ? state.output : JSON.stringify(state?.output ?? "")}`
|
|
7907
|
+
};
|
|
7908
|
+
}
|
|
7909
|
+
if (part.type === "tool_use")
|
|
7910
|
+
return { ...metadata, kind: "tool_use", text: JSON.stringify(part.input ?? {}) };
|
|
7911
|
+
if (part.type === "tool_result")
|
|
7912
|
+
return {
|
|
7913
|
+
...metadata,
|
|
7914
|
+
kind: "tool_result",
|
|
7915
|
+
text: typeof part.content === "string" ? part.content : JSON.stringify(part.content ?? "")
|
|
7916
|
+
};
|
|
7917
|
+
return {
|
|
7918
|
+
...metadata,
|
|
7919
|
+
kind: String(part.type),
|
|
7920
|
+
text: typeof part.text === "string" ? part.text : typeof part.thinking === "string" ? part.thinking : undefined
|
|
7921
|
+
};
|
|
7808
7922
|
}
|
|
7809
7923
|
// src/hooks/magic-context/strip-structural-noise.ts
|
|
7810
7924
|
var STRUCTURAL_PART_TYPES = new Set(["meta", "step-start", "step-finish", "reasoning"]);
|
|
@@ -9349,6 +9463,7 @@ async function runPostTransformPhase(args) {
|
|
|
9349
9463
|
const shouldApplyPendingOps = publishedWorkDrainAllowed;
|
|
9350
9464
|
const shouldRunHeuristics = publishedWorkDrainAllowed && (rideSignals.publishedHistory || materializationRequested || forceMaterialization || foldBustsServedPrefixThisPass || firstRenderBust || heldIdleExpiryRebuild || emergencyDropEligible || args.schedulerDecision === "execute" && (!alreadyRanThisTurn || !args.fullFeatureMode));
|
|
9351
9465
|
const isCacheBustingPass = publishedWorkDrainAllowed;
|
|
9466
|
+
const reclaimDistance = isCacheBustingPass ? toolReclaimDistanceEntries(args.messages, args.targets) : [];
|
|
9352
9467
|
const canEditWholePrefix = isCacheBustingPass && !activeThinkingPrefixHold;
|
|
9353
9468
|
const previousTemporalDecisions = args.temporalCandidates && !compactionOff ? new Map([
|
|
9354
9469
|
...args.temporalObservedDecisions ?? [],
|
|
@@ -9692,6 +9807,7 @@ async function runPostTransformPhase(args) {
|
|
|
9692
9807
|
}
|
|
9693
9808
|
}
|
|
9694
9809
|
const editReclaim = buildEditSupersessionReclaim({
|
|
9810
|
+
watermark: args.sessionMeta.toolReclaimWatermark ?? 0,
|
|
9695
9811
|
db: args.db,
|
|
9696
9812
|
sessionId: args.sessionId,
|
|
9697
9813
|
targets: newTargets,
|
|
@@ -9730,7 +9846,7 @@ async function runPostTransformPhase(args) {
|
|
|
9730
9846
|
const tBatchFinalize = performance.now();
|
|
9731
9847
|
args.batch?.finalize();
|
|
9732
9848
|
if (toolReclaimApplicationOpportunity) {
|
|
9733
|
-
const maxTagNumber =
|
|
9849
|
+
const maxTagNumber = advanceToolReclaimWatermarkByDistance(args.db, args.sessionId, reclaimDistance, args.usableWindow);
|
|
9734
9850
|
args.sessionMeta.toolReclaimWatermark = Math.max(args.sessionMeta.toolReclaimWatermark ?? 0, maxTagNumber);
|
|
9735
9851
|
}
|
|
9736
9852
|
if (autoReclaimTargetCount > 0) {
|
|
@@ -10409,6 +10525,7 @@ async function runPostTransformPhase(args) {
|
|
|
10409
10525
|
const hygieneCalibration = sessionDecisionCalibration(args.db, args.sessionId);
|
|
10410
10526
|
const hygieneUnitsVersion = transitionSessionHygieneUnits(args.db, args.sessionId, bustedThisPass, hygieneCalibration);
|
|
10411
10527
|
const baseline = refreshTailHygieneBaseline({
|
|
10528
|
+
opencode2: args.opencode2,
|
|
10412
10529
|
messages: args.messages,
|
|
10413
10530
|
tags,
|
|
10414
10531
|
protectedTagNumbers: args.protectedTagNumbers,
|
|
@@ -10425,7 +10542,7 @@ async function runPostTransformPhase(args) {
|
|
|
10425
10542
|
sessionLog2(args.sessionId, formatTailHygienePrefixMismatch(baseline.lastPrefixMismatch, baseline.baselineGeneration));
|
|
10426
10543
|
}
|
|
10427
10544
|
const tTailState = performance.now();
|
|
10428
|
-
const structuralSignature = tailHygieneStructuralSignature(args.messages);
|
|
10545
|
+
const structuralSignature = tailHygieneStructuralSignature(args.messages, args.opencode2);
|
|
10429
10546
|
const effective = effectiveTailHygiene(baseline);
|
|
10430
10547
|
const durableGrace = baseline.evaluable && !baseline.generationInvalidated ? captureChannel1PostReduceGraceBaseline(args.db, args.sessionId, effective.u) : getChannel1NudgeState(args.db, args.sessionId);
|
|
10431
10548
|
baseline.channel1PostReduceGrace = durableGrace.postReduceGracePending || durableGrace.postReduceGraceBaselineU !== undefined ? {
|
|
@@ -10437,7 +10554,7 @@ async function runPostTransformPhase(args) {
|
|
|
10437
10554
|
...baseline,
|
|
10438
10555
|
usableWindow: args.usableWindow,
|
|
10439
10556
|
realUserTurnCount: countRealUserMessages(args.messages),
|
|
10440
|
-
reducedSinceRefresh: baseline.baselineGeneration !== previous?.baselineGeneration ? false : previous?.reducedSinceRefresh ?? false,
|
|
10557
|
+
reducedSinceRefresh: baseline.baselineGeneration !== previous?.baselineGeneration || (previous?.generationInvalidated === true || previous?.evaluable === false) && baseline.evaluable && !baseline.generationInvalidated ? false : previous?.reducedSinceRefresh ?? false,
|
|
10441
10558
|
agentDropsAppliedThisPass: pendingOpsDidMutate,
|
|
10442
10559
|
oldestReclaimableToolTags: postprocessOldestTags(args.db, args.sessionId, args.protectedTagNumbers)
|
|
10443
10560
|
});
|
|
@@ -10475,7 +10592,7 @@ async function runPostTransformPhase(args) {
|
|
|
10475
10592
|
const tTailGuard = performance.now();
|
|
10476
10593
|
if (assertedBaseline) {
|
|
10477
10594
|
try {
|
|
10478
|
-
const servedSignature = tailHygieneStructuralSignature(args.messages);
|
|
10595
|
+
const servedSignature = tailHygieneStructuralSignature(args.messages, args.opencode2);
|
|
10479
10596
|
if (!sameTailHygieneStructuralSignature(assertedBaseline.structuralSignature, servedSignature)) {
|
|
10480
10597
|
sessionLog2(args.sessionId, `ERROR [tail-hygiene-last-writer-mismatch]: served messages changed after tail-hygiene baseline refresh (expected messages=${assertedBaseline.structuralSignature.messageCount}, parts=[${assertedBaseline.structuralSignature.partCounts.join(",")}], bytes=${assertedBaseline.structuralSignature.totalBytes}; actual messages=${servedSignature.messageCount}, parts=[${servedSignature.partCounts.join(",")}], bytes=${servedSignature.totalBytes})`);
|
|
10481
10598
|
}
|
|
@@ -10483,6 +10600,7 @@ async function runPostTransformPhase(args) {
|
|
|
10483
10600
|
sessionLog2(args.sessionId, "ERROR [tail-hygiene-last-writer-check-failed]: structural production guard failed open:", error);
|
|
10484
10601
|
}
|
|
10485
10602
|
assertTailHygieneContentUnchangedIfEnabled({
|
|
10603
|
+
opencode2: args.opencode2,
|
|
10486
10604
|
messages: args.messages,
|
|
10487
10605
|
tags: assertedBaseline.tags,
|
|
10488
10606
|
protectedTagNumbers: assertedBaseline.protectedTagNumbers,
|
|
@@ -14159,16 +14277,19 @@ function rustCaptureDigests(inputs, prior, acceptedInputs) {
|
|
|
14159
14277
|
} : undefined);
|
|
14160
14278
|
return { ...incremental, inputContentSignatures };
|
|
14161
14279
|
}
|
|
14280
|
+
var contentSnapshotFieldVisitObserverForTests;
|
|
14162
14281
|
function messageMatchesContentSnapshot(message, snapshot) {
|
|
14163
14282
|
let fieldIndex = 0;
|
|
14164
14283
|
const matched = visitMessageContentFields(contentSnapshotValue(message), {
|
|
14165
14284
|
field(value) {
|
|
14285
|
+
contentSnapshotFieldVisitObserverForTests?.();
|
|
14166
14286
|
if (!Object.is(value, snapshot.fields[fieldIndex]))
|
|
14167
14287
|
return false;
|
|
14168
14288
|
fieldIndex += 1;
|
|
14169
14289
|
return true;
|
|
14170
14290
|
},
|
|
14171
14291
|
beginObject() {
|
|
14292
|
+
contentSnapshotFieldVisitObserverForTests?.();
|
|
14172
14293
|
const expectedCount = snapshot.fields[fieldIndex];
|
|
14173
14294
|
if (typeof expectedCount !== "number")
|
|
14174
14295
|
return;
|
|
@@ -17504,15 +17625,27 @@ class UnmanagedOverWindowError extends Error {
|
|
|
17504
17625
|
}
|
|
17505
17626
|
|
|
17506
17627
|
// src/hooks/magic-context/unresolved-history-boundary.ts
|
|
17628
|
+
function storedHistoryBoundaryPresence(db, sessionId) {
|
|
17629
|
+
try {
|
|
17630
|
+
const row = db.prepare("SELECT cached_m0_last_baseline_end_message_id AS id FROM session_meta WHERE session_id = ?").get(sessionId);
|
|
17631
|
+
return row?.id ? hasRawSessionMessageById2(sessionId, row.id) : undefined;
|
|
17632
|
+
} catch {
|
|
17633
|
+
return;
|
|
17634
|
+
}
|
|
17635
|
+
}
|
|
17636
|
+
|
|
17507
17637
|
class UnresolvedHistoryBoundaryError extends Error {
|
|
17508
17638
|
estimatedTokens;
|
|
17509
17639
|
contextLimitTokens;
|
|
17640
|
+
boundaryPresent;
|
|
17510
17641
|
code = "UNRESOLVED_HISTORY_BOUNDARY";
|
|
17511
17642
|
recoverable = true;
|
|
17512
|
-
constructor(estimatedTokens, contextLimitTokens) {
|
|
17513
|
-
|
|
17643
|
+
constructor(estimatedTokens, contextLimitTokens, boundaryPresent) {
|
|
17644
|
+
const reason = boundaryPresent === true ? "The boundary row is present in the host store but out of order relative to the loaded history. " : boundaryPresent === false ? "The boundary row is missing from the host store. " : "";
|
|
17645
|
+
super(reason + renderUserFacingFailure("history_boundary_unresolved", "plain"));
|
|
17514
17646
|
this.estimatedTokens = estimatedTokens;
|
|
17515
17647
|
this.contextLimitTokens = contextLimitTokens;
|
|
17648
|
+
this.boundaryPresent = boundaryPresent;
|
|
17516
17649
|
this.name = "UnresolvedHistoryBoundaryError";
|
|
17517
17650
|
}
|
|
17518
17651
|
}
|
|
@@ -18509,6 +18642,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
18509
18642
|
const protectedCutoff = protectionWindow.cutoff;
|
|
18510
18643
|
const tPostProcess = performance.now();
|
|
18511
18644
|
const postTransformResult = await runPostTransformPhase({
|
|
18645
|
+
opencode2: deps.storeGeneration === "v2",
|
|
18512
18646
|
normalizeRecoveryTail,
|
|
18513
18647
|
compactionMarkerStrategy: deps.compactionMarkerStrategy ?? defaultCompactionMarkerStrategy,
|
|
18514
18648
|
sessionId,
|
|
@@ -18669,7 +18803,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
18669
18803
|
});
|
|
18670
18804
|
if (untrimmed.tokens > boundaryContextLimit) {
|
|
18671
18805
|
sessionLog2(sessionId, `history boundary unresolved: prefix trim refused and the untrimmed request estimate ${untrimmed.tokens} (trusted=${untrimmed.trusted}) exceeds the context limit ${boundaryContextLimit}; not sending it`);
|
|
18672
|
-
throw new UnresolvedHistoryBoundaryError(untrimmed.tokens, boundaryContextLimit);
|
|
18806
|
+
throw new UnresolvedHistoryBoundaryError(untrimmed.tokens, boundaryContextLimit, storedHistoryBoundaryPresence(db, sessionId));
|
|
18673
18807
|
}
|
|
18674
18808
|
}
|
|
18675
18809
|
if (unmanagedOverWindowPass) {
|
|
@@ -21715,6 +21849,7 @@ function buildStatusDetail(db, sessionId, directory, modelKey, config, liveSessi
|
|
|
21715
21849
|
const ops = db.prepare("SELECT tag_id, operation FROM pending_ops WHERE session_id = ? LIMIT 100").all(sessionId);
|
|
21716
21850
|
detail.pendingOps = ops.map((o) => ({ tagId: o.tag_id, operation: o.operation }));
|
|
21717
21851
|
} catch {}
|
|
21852
|
+
modelKey ??= persistedModelKey ?? undefined;
|
|
21718
21853
|
const modelSlash = modelKey?.indexOf("/") ?? -1;
|
|
21719
21854
|
if (modelKey && modelSlash > 0) {
|
|
21720
21855
|
detail.windowGeometry = resolveContextWindowGeometry(modelKey.slice(0, modelSlash), modelKey.slice(modelSlash + 1), { db, sessionID: sessionId });
|
|
@@ -22059,7 +22194,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22059
22194
|
const sessionId = String(params.sessionId ?? "");
|
|
22060
22195
|
if (!sessionId)
|
|
22061
22196
|
return { owner: false };
|
|
22062
|
-
const sessionDirectory =
|
|
22197
|
+
const sessionDirectory = args.readSessionDirectory ? await args.readSessionDirectory(sessionId) : await readHostSessionDirectory(args.client, sessionId) ?? liveSessionState.sessionDirectoryBySession.get(sessionId);
|
|
22063
22198
|
if (!sessionDirectory)
|
|
22064
22199
|
return { owner: false };
|
|
22065
22200
|
return {
|
|
@@ -22130,7 +22265,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22130
22265
|
return { count: buildCompartmentCount(db, sessionId, moduleStatus) };
|
|
22131
22266
|
});
|
|
22132
22267
|
const buildManagedCtx = async (db) => {
|
|
22133
|
-
const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-
|
|
22268
|
+
const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-0rmpmxjw.js"));
|
|
22134
22269
|
const { resolveHistorianModel } = await importPluginModule(() => import("./model-resolution-nx97z3x7.js"));
|
|
22135
22270
|
const { userMemoryCollectionEnabled } = await importPluginModule(() => import("./task-config-x0hq3qfd.js"));
|
|
22136
22271
|
const DEFAULT_HISTORIAN_TIMEOUT_MS = 10 * 60 * 1000;
|
|
@@ -22145,6 +22280,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22145
22280
|
directory,
|
|
22146
22281
|
historianChunkTokens: deriveHistorianChunkTokens(resolveHistorianContextLimit(historianModel.primary?.model)),
|
|
22147
22282
|
historianTimeoutMs: runConfig.historian_timeout_ms ?? DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
22283
|
+
historianMaxOutputTokens: runConfig.historian?.maxTokens,
|
|
22148
22284
|
memoryEnabled: config.memory?.enabled ?? true,
|
|
22149
22285
|
autoPromote: runConfig.memory?.auto_promote ?? true,
|
|
22150
22286
|
historianModel: historianModel.primary,
|
|
@@ -22159,6 +22295,20 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22159
22295
|
const sessionId = String(params.sessionId ?? "");
|
|
22160
22296
|
if (!sessionId)
|
|
22161
22297
|
return { ok: false, error: "no session" };
|
|
22298
|
+
const readDirectory = args.readSessionDirectory;
|
|
22299
|
+
if (readDirectory) {
|
|
22300
|
+
const { handoffHistoryWork } = await import("./history-owner-2cr9py37.js");
|
|
22301
|
+
const handed = await handoffHistoryWork({
|
|
22302
|
+
storageDir: args.storageDir ?? getMagicContextStorageDir(),
|
|
22303
|
+
directory,
|
|
22304
|
+
sessionId,
|
|
22305
|
+
method: "recomp",
|
|
22306
|
+
params,
|
|
22307
|
+
readDirectory: () => readDirectory(sessionId)
|
|
22308
|
+
});
|
|
22309
|
+
if (handed)
|
|
22310
|
+
return handed;
|
|
22311
|
+
}
|
|
22162
22312
|
const dir = String(params.directory ?? directory);
|
|
22163
22313
|
if (config.transform_mode === "rust") {
|
|
22164
22314
|
return executeRustRecompRpc(rustModeModuleClient, sessionId, dir);
|
|
@@ -22166,8 +22316,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22166
22316
|
const db = readDatabase();
|
|
22167
22317
|
if (!db)
|
|
22168
22318
|
return { ok: false, error: "db unavailable" };
|
|
22169
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
22170
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
22319
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-s5tdpsbs.js"));
|
|
22320
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-6n7chhyp.js"));
|
|
22171
22321
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
22172
22322
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
22173
22323
|
return {
|
|
@@ -22223,6 +22373,21 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22223
22373
|
return { ok: true, message };
|
|
22224
22374
|
});
|
|
22225
22375
|
rpcServer.handle("wrapup", async (params) => {
|
|
22376
|
+
const readDirectory = args.readSessionDirectory;
|
|
22377
|
+
if (readDirectory && params.sessionId) {
|
|
22378
|
+
const { handoffHistoryWork } = await import("./history-owner-2cr9py37.js");
|
|
22379
|
+
const sessionId = String(params.sessionId);
|
|
22380
|
+
const handed = await handoffHistoryWork({
|
|
22381
|
+
storageDir: args.storageDir ?? getMagicContextStorageDir(),
|
|
22382
|
+
directory,
|
|
22383
|
+
sessionId,
|
|
22384
|
+
method: "wrapup",
|
|
22385
|
+
params,
|
|
22386
|
+
readDirectory: () => readDirectory(sessionId)
|
|
22387
|
+
});
|
|
22388
|
+
if (handed)
|
|
22389
|
+
return handed;
|
|
22390
|
+
}
|
|
22226
22391
|
const sessionId = String(params.sessionId ?? "");
|
|
22227
22392
|
if (!sessionId)
|
|
22228
22393
|
return { ok: false, error: "no session" };
|
|
@@ -22236,7 +22401,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22236
22401
|
const db = readDatabase();
|
|
22237
22402
|
if (!db)
|
|
22238
22403
|
return { ok: false, error: "db unavailable" };
|
|
22239
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
22404
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-wg8dmmm9.js"));
|
|
22240
22405
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
22241
22406
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
22242
22407
|
const ctx = {
|
|
@@ -22661,7 +22826,7 @@ class MagicContextRpcServer {
|
|
|
22661
22826
|
}
|
|
22662
22827
|
this.startedAt = Date.now();
|
|
22663
22828
|
const self = this;
|
|
22664
|
-
const server = Bun.serve({
|
|
22829
|
+
const server = inRootAsyncContext2(() => Bun.serve({
|
|
22665
22830
|
port: 0,
|
|
22666
22831
|
hostname: "127.0.0.1",
|
|
22667
22832
|
fetch(req, srv) {
|
|
@@ -22684,7 +22849,7 @@ class MagicContextRpcServer {
|
|
|
22684
22849
|
self.sockets.delete(ws);
|
|
22685
22850
|
}
|
|
22686
22851
|
}
|
|
22687
|
-
});
|
|
22852
|
+
}));
|
|
22688
22853
|
this.server = server;
|
|
22689
22854
|
this.port = server.port ?? 0;
|
|
22690
22855
|
try {
|
|
@@ -24732,7 +24897,7 @@ function childCreateInput(identity, role, model) {
|
|
|
24732
24897
|
},
|
|
24733
24898
|
location: { directory: identity.directory },
|
|
24734
24899
|
metadata: { magic_context: "hidden-run", role },
|
|
24735
|
-
permissions: hiddenChildPermissions(agent)
|
|
24900
|
+
permissions: hiddenChildPermissions(agent, model.providerID)
|
|
24736
24901
|
};
|
|
24737
24902
|
}
|
|
24738
24903
|
function assistantOutcome(row) {
|
|
@@ -24817,7 +24982,7 @@ function createNativeHiddenChildren(host, removeSession, options) {
|
|
|
24817
24982
|
}
|
|
24818
24983
|
const directory = stored.location?.directory;
|
|
24819
24984
|
if (options.directory !== undefined && directory !== undefined && !sameProjectDirectory(directory, options.directory)) {
|
|
24820
|
-
throw new HiddenCompletionRefusal("hidden_prompt_unrecognized", `hidden child ${sessionID} is bound to ${directory}, not to this instance's ${options.directory}
|
|
24985
|
+
throw new HiddenCompletionRefusal("hidden_prompt_unrecognized", `hidden child ${sessionID} is bound to ${directory}, not to this instance's ${options.directory}. Reopen the parent session in ${directory}, then run /ctx-recomp so its owning instance can rebuild history.`, true);
|
|
24821
24986
|
}
|
|
24822
24987
|
if (stored.parentID === parentID || parentDroppedNoted)
|
|
24823
24988
|
return;
|
|
@@ -25412,6 +25577,9 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
25412
25577
|
body.temperature = temperature;
|
|
25413
25578
|
request = { ...request, body };
|
|
25414
25579
|
}
|
|
25580
|
+
if (needsBlockedRead(run.identity.agent, run.child.model.providerID) !== needsBlockedRead(run.identity.agent, requested.providerID)) {
|
|
25581
|
+
retire(run, "hidden-run-tool-surface-changed");
|
|
25582
|
+
}
|
|
25415
25583
|
if (run.retired) {
|
|
25416
25584
|
run.child = await lifecycle.create(run.identity, run.role, requested);
|
|
25417
25585
|
run.failed = false;
|
|
@@ -25444,7 +25612,7 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
25444
25612
|
budgetReject = reject;
|
|
25445
25613
|
});
|
|
25446
25614
|
if (budget) {
|
|
25447
|
-
budgetPoll = setInterval(() => {
|
|
25615
|
+
budgetPoll = inRootAsyncContext2(() => setInterval(() => {
|
|
25448
25616
|
try {
|
|
25449
25617
|
const fresh = withReader(options.openReader, (reader) => reader.assistantSince?.(run.child.id, usageSeq) ?? (() => {
|
|
25450
25618
|
const latest = reader.latestAssistant(run.child.id);
|
|
@@ -25458,7 +25626,10 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
25458
25626
|
const decision = budget.charge(Math.max(0, tokens?.input ?? 0), Math.max(0, tokens?.cache?.read ?? 0), Math.max(0, tokens?.cache?.write ?? 0), row.data.finish === "stop" && !(row.data.content ?? []).some((part) => part.type === "tool-call"), false);
|
|
25459
25627
|
const onBudgetUpdate = run.identity.metadata?.onBudgetUpdate;
|
|
25460
25628
|
if (typeof onBudgetUpdate === "function")
|
|
25461
|
-
onBudgetUpdate({
|
|
25629
|
+
onBudgetUpdate({
|
|
25630
|
+
...budget.snapshot(),
|
|
25631
|
+
sessionId: run.child.id
|
|
25632
|
+
});
|
|
25462
25633
|
if (decision !== "continue") {
|
|
25463
25634
|
if (budgetPoll)
|
|
25464
25635
|
clearInterval(budgetPoll);
|
|
@@ -25472,7 +25643,7 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
25472
25643
|
clearInterval(budgetPoll);
|
|
25473
25644
|
budgetReject(error instanceof Error ? error : new Error(String(error)));
|
|
25474
25645
|
}
|
|
25475
|
-
}, POLL_INTERVAL_MS);
|
|
25646
|
+
}, POLL_INTERVAL_MS));
|
|
25476
25647
|
}
|
|
25477
25648
|
let abortReject;
|
|
25478
25649
|
const aborted = new Promise((_resolve, reject) => {
|
|
@@ -25520,8 +25691,14 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
25520
25691
|
const system = typeof request.body.system === "string" ? request.body.system : run.identity.system;
|
|
25521
25692
|
const tokens = row.data.tokens;
|
|
25522
25693
|
const tokenNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
25523
|
-
const
|
|
25524
|
-
const
|
|
25694
|
+
const steps = withReader(options.openReader, (reader) => reader.assistantSince?.(run.child.id, baseline) ?? [row]).filter((step) => step.seq > baseline && step.seq <= row.seq);
|
|
25695
|
+
const reportedUsage = steps.some((step) => tokenNumber(step.data.tokens?.input) !== undefined || tokenNumber(step.data.tokens?.output) !== undefined);
|
|
25696
|
+
const usage = steps.reduce((total, step) => ({
|
|
25697
|
+
input: total.input + (tokenNumber(step.data.tokens?.input) ?? 0),
|
|
25698
|
+
output: total.output + (tokenNumber(step.data.tokens?.output) ?? 0),
|
|
25699
|
+
cacheRead: total.cacheRead + (tokenNumber(step.data.tokens?.cache?.read) ?? 0),
|
|
25700
|
+
cacheWrite: total.cacheWrite + (tokenNumber(step.data.tokens?.cache?.write) ?? 0)
|
|
25701
|
+
}), { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
|
|
25525
25702
|
if (request.signal?.aborted || run.retired || Date.now() >= deadline) {
|
|
25526
25703
|
await interruptAndRetire(run, "prompt-aborted-or-timeout");
|
|
25527
25704
|
throw new Error(request.signal?.aborted ? "Hidden completion prompt aborted" : "Hidden completion prompt timed out");
|
|
@@ -25531,12 +25708,7 @@ async function createV2HiddenCompletionExecutor(host, options) {
|
|
|
25531
25708
|
tokenLog: runTokenLog(tokens, run.identity.maxOutputTokens, row.data.finish),
|
|
25532
25709
|
...hiddenToolLoop(run.identity) ? { messages: toolLoopMessages(attempt) } : {},
|
|
25533
25710
|
reasoning: text ? null : assistantReasoning(row),
|
|
25534
|
-
usage:
|
|
25535
|
-
input: reportedInput ?? 0,
|
|
25536
|
-
output: reportedOutput ?? 0,
|
|
25537
|
-
cacheRead: tokenNumber(tokens?.cache?.read) ?? 0,
|
|
25538
|
-
cacheWrite: tokenNumber(tokens?.cache?.write) ?? 0
|
|
25539
|
-
} : meter(system, promptText(request), text ?? ""),
|
|
25711
|
+
usage: reportedUsage ? usage : meter(system, promptText(request), text ?? ""),
|
|
25540
25712
|
lengthCapped: ["length", "max_tokens"].includes(row.data.finish ?? ""),
|
|
25541
25713
|
providerId: row.data.model?.providerID ?? requested.providerID,
|
|
25542
25714
|
modelId: row.data.model?.id ?? requested.modelID
|
|
@@ -25637,7 +25809,7 @@ async function deliverPendingChannel2(context, db, sessionID, baseline) {
|
|
|
25637
25809
|
if (!claimChannel2NudgeState(db, sessionID, token))
|
|
25638
25810
|
return;
|
|
25639
25811
|
try {
|
|
25640
|
-
await deliverSynthetic(context, sessionID, buildChannel2Reminder(evaluation.reclaimableTokens,
|
|
25812
|
+
await deliverSynthetic(context, sessionID, buildChannel2Reminder(evaluation.reclaimableTokens, currentReclaimableToolOutputCount(baseline)));
|
|
25641
25813
|
} catch (error) {
|
|
25642
25814
|
casChannel2NudgeClaim(db, sessionID, "pending", token);
|
|
25643
25815
|
throw error;
|
|
@@ -26034,7 +26206,7 @@ function startLeaseHeartbeat(db, holderId, leaseKey, onLost, intervalOrAcquisiti
|
|
|
26034
26206
|
}
|
|
26035
26207
|
};
|
|
26036
26208
|
beat();
|
|
26037
|
-
const timer = lost ? undefined : setInterval(() => withSqliteBackgroundWriter2(beat), intervalMs);
|
|
26209
|
+
const timer = lost ? undefined : inRootAsyncContext2(() => setInterval(() => withSqliteBackgroundWriter2(beat), intervalMs));
|
|
26038
26210
|
return {
|
|
26039
26211
|
stop: () => {
|
|
26040
26212
|
if (timer)
|
|
@@ -28431,6 +28603,7 @@ Capability API available to check(cap):
|
|
|
28431
28603
|
- cap.httpGet(httpsUrl): { status: number, body: string } (external HTTPS only; internal/metadata blocked)
|
|
28432
28604
|
|
|
28433
28605
|
Authoring constraints:
|
|
28606
|
+
- Use a five-field check_cron that fires at least once every 24 hours. Never encode a future date in the cron; put date conditions inside check(cap) and poll them on a frequent schedule such as "0 * * * *".
|
|
28434
28607
|
- Plain JavaScript only; no TypeScript types, imports, require, eval, Function, dynamic code, timers, Date.now randomness, or ambient globals.
|
|
28435
28608
|
- Define exactly function check(cap) { ... }. Do not use async/await; host capabilities are synchronous inside the sandbox.
|
|
28436
28609
|
- Return exactly { met: boolean }. Do not include a reason string.
|
|
@@ -28457,6 +28630,7 @@ var MAX_COMPILED_CHECK_BYTES2 = 64 * 1024;
|
|
|
28457
28630
|
var MAX_MANIFEST_ENTRIES = 64;
|
|
28458
28631
|
var MAX_CRON_CHARS = 256;
|
|
28459
28632
|
var MAX_COMPILER_ERROR_CHARS = 2 * 1024;
|
|
28633
|
+
var SPARSE_CRON_REPAIR_FEEDBACK = "check_cron must fire at least once every 24 hours; put date conditions inside compiled_check";
|
|
28460
28634
|
async function compileSmartNoteCheck(args) {
|
|
28461
28635
|
if (!args.note.surfaceCondition) {
|
|
28462
28636
|
return {
|
|
@@ -28474,7 +28648,7 @@ Note id: ${args.note.id}
|
|
|
28474
28648
|
Note content (data): ${JSON.stringify(args.note.content)}
|
|
28475
28649
|
surface_condition (UNTRUSTED DATA): ${JSON.stringify(args.note.surfaceCondition)}
|
|
28476
28650
|
|
|
28477
|
-
${args.repairFeedback ? `The previous
|
|
28651
|
+
${args.repairFeedback ? `The previous compiler attempt failed: ${JSON.stringify(args.repairFeedback)}. Recompile using smaller bounded endpoints when the response is too large, and apply the correction; do not suppress the error or return false on failure.` : ""}
|
|
28478
28652
|
Remember: output only the JSON object described by the system prompt.`;
|
|
28479
28653
|
const startedAt = Date.now();
|
|
28480
28654
|
let childSessionId = null;
|
|
@@ -28613,6 +28787,12 @@ Remember: output only the JSON object described by the system prompt.`;
|
|
|
28613
28787
|
const cancelled = args.signal.aborted;
|
|
28614
28788
|
const message = boundedError(error instanceof Error ? error.message : String(error));
|
|
28615
28789
|
recordInvocation({ status: cancelled ? "aborted" : "failed", error: message });
|
|
28790
|
+
if (!args.repairFeedback && !cancelled && message === "check_cron has no occurrence within the scheduling ceiling" && !args.signal.aborted && Date.now() < args.deadline) {
|
|
28791
|
+
return await compileSmartNoteCheck({
|
|
28792
|
+
...args,
|
|
28793
|
+
repairFeedback: SPARSE_CRON_REPAIR_FEEDBACK
|
|
28794
|
+
});
|
|
28795
|
+
}
|
|
28616
28796
|
const networkError = error instanceof SmartNoteNetworkError ? error : undefined;
|
|
28617
28797
|
return {
|
|
28618
28798
|
ok: false,
|
|
@@ -28837,10 +29017,10 @@ async function probeWakePlaneCatalog() {
|
|
|
28837
29017
|
if (!await connectionFileExists(file)) {
|
|
28838
29018
|
throw new Error("subc connection is not configured");
|
|
28839
29019
|
}
|
|
28840
|
-
const client = await SubcClient.connect({
|
|
29020
|
+
const client = await inRootAsyncContext2(() => SubcClient.connect({
|
|
28841
29021
|
connectionFile: file,
|
|
28842
29022
|
handshakeTimeoutMs: WAKE_PLANE_HANDSHAKE_TIMEOUT_MS
|
|
28843
|
-
});
|
|
29023
|
+
}));
|
|
28844
29024
|
try {
|
|
28845
29025
|
return await client.catalogList();
|
|
28846
29026
|
} finally {
|
|
@@ -30250,7 +30430,11 @@ function buildPrimerClusters(args) {
|
|
|
30250
30430
|
centroid: cloneVector(primer.questionEmbedding),
|
|
30251
30431
|
modelId: primer.questionEmbeddingModelId
|
|
30252
30432
|
}));
|
|
30253
|
-
const sorted = args.candidates.slice().sort((a, b) =>
|
|
30433
|
+
const sorted = args.candidates.slice().sort((a, b) => {
|
|
30434
|
+
const left = candidateSortKey(a);
|
|
30435
|
+
const right = candidateSortKey(b);
|
|
30436
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
30437
|
+
});
|
|
30254
30438
|
for (const candidate of sorted) {
|
|
30255
30439
|
let best = null;
|
|
30256
30440
|
for (const cluster of clusters) {
|
|
@@ -34358,7 +34542,7 @@ async function startDreamScheduleTimer(args) {
|
|
|
34358
34542
|
startupTickTimer = null;
|
|
34359
34543
|
runTick("startup");
|
|
34360
34544
|
});
|
|
34361
|
-
const timer = setInterval(() => runTick("interval"), DREAM_TIMER_INTERVAL_MS);
|
|
34545
|
+
const timer = inRootAsyncContext2(() => setInterval(() => runTick("interval"), DREAM_TIMER_INTERVAL_MS));
|
|
34362
34546
|
if (typeof timer === "object" && "unref" in timer) {
|
|
34363
34547
|
timer.unref();
|
|
34364
34548
|
}
|
|
@@ -34654,7 +34838,7 @@ async function runCompiledSmartNoteSweep(reg, db) {
|
|
|
34654
34838
|
}
|
|
34655
34839
|
}
|
|
34656
34840
|
function startGitSweepLeaseRenewal(db, projectIdentity, holderId) {
|
|
34657
|
-
const timer = setInterval(() => {
|
|
34841
|
+
const timer = inRootAsyncContext2(() => setInterval(() => {
|
|
34658
34842
|
try {
|
|
34659
34843
|
if (!renewGitSweepLease(db, projectIdentity, holderId)) {
|
|
34660
34844
|
log2(`[git-commits] sweep lease renewal failed for ${projectIdentity}`);
|
|
@@ -34662,7 +34846,7 @@ function startGitSweepLeaseRenewal(db, projectIdentity, holderId) {
|
|
|
34662
34846
|
} catch (error) {
|
|
34663
34847
|
log2(`[git-commits] sweep lease renewal errored for ${projectIdentity}: ${error instanceof Error ? error.message : String(error)}`);
|
|
34664
34848
|
}
|
|
34665
|
-
}, GIT_SWEEP_LEASE_RENEWAL_MS);
|
|
34849
|
+
}, GIT_SWEEP_LEASE_RENEWAL_MS));
|
|
34666
34850
|
timer.unref?.();
|
|
34667
34851
|
return () => clearInterval(timer);
|
|
34668
34852
|
}
|
|
@@ -35201,12 +35385,12 @@ function createRustRefusalRecovery(options) {
|
|
|
35201
35385
|
watchers.delete(sessionId);
|
|
35202
35386
|
};
|
|
35203
35387
|
const schedule = (sessionId, watcher) => {
|
|
35204
|
-
watcher.timer = setTimeout(() => void poll(sessionId, watcher), pollIntervalMs);
|
|
35388
|
+
watcher.timer = inRootAsyncContext2(() => setTimeout(() => void poll(sessionId, watcher), pollIntervalMs));
|
|
35205
35389
|
};
|
|
35206
35390
|
const probe = async (watcher, sessionId) => {
|
|
35207
35391
|
const controller = new AbortController;
|
|
35208
35392
|
const timeoutError = new Error("rust refusal recovery probe timed out");
|
|
35209
|
-
const timer = setTimeout(() => controller.abort(timeoutError), probeTimeoutMs);
|
|
35393
|
+
const timer = inRootAsyncContext2(() => setTimeout(() => controller.abort(timeoutError), probeTimeoutMs));
|
|
35210
35394
|
try {
|
|
35211
35395
|
await Promise.race([
|
|
35212
35396
|
options.moduleClient.call({
|
|
@@ -35888,6 +36072,14 @@ function createV2RawMessageReader(openReader) {
|
|
|
35888
36072
|
reader.close();
|
|
35889
36073
|
}
|
|
35890
36074
|
},
|
|
36075
|
+
orderOf: (sessionID, messageID) => {
|
|
36076
|
+
const reader = openReader();
|
|
36077
|
+
try {
|
|
36078
|
+
return reader.sequenceForId(sessionID, messageID) ?? null;
|
|
36079
|
+
} finally {
|
|
36080
|
+
reader.close();
|
|
36081
|
+
}
|
|
36082
|
+
},
|
|
35891
36083
|
ordinalMapForRange: (sessionID, fromOrdinal, toOrdinal) => {
|
|
35892
36084
|
const reader = openReader();
|
|
35893
36085
|
try {
|
|
@@ -35945,6 +36137,9 @@ function createV2RawMessageProvider(reader, sessionID) {
|
|
|
35945
36137
|
readMessagePartsById: (messageID) => reader.findPartsById(sessionID, messageID),
|
|
35946
36138
|
hasMessageById: (messageID) => reader.hasById(sessionID, messageID),
|
|
35947
36139
|
readMessageOrdinalById: (messageID) => reader.ordinalOf(sessionID, messageID),
|
|
36140
|
+
...reader.orderOf ? {
|
|
36141
|
+
readMessageOrderById: (messageID) => reader.orderOf?.(sessionID, messageID) ?? null
|
|
36142
|
+
} : {},
|
|
35948
36143
|
readMessageIdOrdinalsForRange: (fromOrdinal, toOrdinal) => reader.ordinalMapForRange(sessionID, fromOrdinal, toOrdinal),
|
|
35949
36144
|
readMessageOrdinalPage: (after, limit) => reader.readOrdinalPage(sessionID, after, limit),
|
|
35950
36145
|
getMessageCount: () => reader.getCount(sessionID),
|
|
@@ -51326,6 +51521,13 @@ ${baseline}
|
|
|
51326
51521
|
hiddenCompletionExecutor: storageOpenedAtBoot ? hiddenCompletionExecutor : lateHiddenExecutor,
|
|
51327
51522
|
compactionMarkerStrategy: v2CompactionMarkerStrategy,
|
|
51328
51523
|
prepareHistorySession,
|
|
51524
|
+
readSessionDirectory: async (sessionID) => {
|
|
51525
|
+
try {
|
|
51526
|
+
return (await context.session.get({ sessionID })).location?.directory ?? null;
|
|
51527
|
+
} catch {
|
|
51528
|
+
return null;
|
|
51529
|
+
}
|
|
51530
|
+
},
|
|
51329
51531
|
storageDir
|
|
51330
51532
|
});
|
|
51331
51533
|
rpcServer.handle("dream", async (params) => {
|
|
@@ -51393,11 +51595,11 @@ ${baseline}
|
|
|
51393
51595
|
directory,
|
|
51394
51596
|
compactionEnabled: !compactionOff
|
|
51395
51597
|
});
|
|
51396
|
-
setTimeout(() => {
|
|
51598
|
+
inRootAsyncContext2(() => setTimeout(() => {
|
|
51397
51599
|
if (rpcStopped)
|
|
51398
51600
|
return;
|
|
51399
51601
|
rpcServer.start().catch((error) => log2("[magic-context] v2 RPC server failed to start", error));
|
|
51400
|
-
}, 0);
|
|
51602
|
+
}, 0));
|
|
51401
51603
|
return {
|
|
51402
51604
|
async dispose() {
|
|
51403
51605
|
rpcStopped = true;
|