@cortexkit/opencode-magic-context 0.49.10 → 0.49.12
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/README.md +1 -1
- package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts +28 -0
- package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts.map +1 -0
- package/dist/{announcement-hdbkt8v5.js → announcement-g789dmt6.js} +2 -2
- package/dist/auto-search-worker.js +4 -4
- package/dist/{compaction-marker-candidates-xxz35vwp.js → compaction-marker-candidates-v5c6997n.js} +3 -3
- package/dist/compaction-marker-candidates-worker.js +1 -1
- package/dist/config/agent-disable.d.ts +14 -0
- package/dist/config/agent-disable.d.ts.map +1 -1
- package/dist/config/dependency-notes.d.ts +34 -0
- package/dist/config/dependency-notes.d.ts.map +1 -0
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-w3crzrar.js → conflict-warning-hook-f4x5wed7.js} +8 -8
- package/dist/{context-ey3ap3cc.js → context-dam8p201.js} +306 -119
- package/dist/{derive-budgets-3nbxsyss.js → derive-budgets-5306b1jt.js} +3 -3
- package/dist/embedding-backfill-qbfcbp87.js +21 -0
- package/dist/embedding-worker-process.js +2 -2
- package/dist/embedding-worker.js +6 -6
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +12 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-config.d.ts +22 -4
- package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-registry.d.ts +22 -0
- package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts +4 -1
- package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-openai.d.ts +32 -0
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/project-identity.d.ts +1 -0
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/memory/unborn-head.d.ts +34 -0
- package/dist/features/magic-context/memory/unborn-head.d.ts.map +1 -0
- package/dist/features/magic-context/memory-enabled.d.ts +5 -0
- package/dist/features/magic-context/memory-enabled.d.ts.map +1 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/search-pool-fixture.d.ts +39 -0
- package/dist/features/magic-context/search-pool-fixture.d.ts.map +1 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +2 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts +57 -2
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/{history-owner-ty29fz0f.js → history-owner-xp3pngv7.js} +3 -3
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-prompt.d.ts +6 -0
- package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +3 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger-error.d.ts +12 -0
- package/dist/hooks/magic-context/compartment-trigger-error.d.ts.map +1 -0
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts +14 -2
- package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/pending-materialization.d.ts +2 -0
- package/dist/hooks/magic-context/pending-materialization.d.ts.map +1 -1
- package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +12 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-exact-ordinal-read.d.ts +58 -0
- package/dist/hooks/magic-context/raw-exact-ordinal-read.d.ts.map +1 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +7 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts +5 -0
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +19 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +2 -0
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/render-options.d.ts +21 -0
- package/dist/hooks/magic-context/render-options.d.ts.map +1 -0
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +4 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +2 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +5 -7
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
- package/dist/{index-21919gcq.js → index-05n6ykca.js} +4 -4
- package/dist/{index-q76br5zn.js → index-1d289pq2.js} +26 -21
- package/dist/{index-w28y7d0z.js → index-1sarmj9z.js} +15 -15
- package/dist/{index-x57ep4fp.js → index-1wwh38fk.js} +323 -121
- package/dist/{index-pgy3h49n.js → index-2pgxcncf.js} +4 -4
- package/dist/{index-ffa8x2as.js → index-6sytd5w3.js} +18 -13
- package/dist/{index-16vwdyy5.js → index-6sz25c3s.js} +3 -3
- package/dist/{index-4hb8nt93.js → index-7h8a1xpc.js} +3 -3
- package/dist/{index-rg1cezmj.js → index-7zd5asz9.js} +140 -17
- package/dist/{index-jw4gbfkv.js → index-8ketfacn.js} +2 -2
- package/dist/{index-nenz4gpb.js → index-95s8xaj1.js} +6 -5
- package/dist/{index-bmwfzz28.js → index-9vqb5p1s.js} +4 -4
- package/dist/{index-0jz47061.js → index-a8bvhwqs.js} +190 -30
- package/dist/{index-wpwpn7nj.js → index-b16gpywn.js} +9 -9
- package/dist/{index-g7jkrz0x.js → index-bp5083x2.js} +1 -1
- package/dist/{index-mp2kghkv.js → index-dyvbsvga.js} +1 -1
- package/dist/{index-s178h9z8.js → index-f71thw8j.js} +1 -1
- package/dist/{index-kvw6xew3.js → index-fkx2qnvw.js} +2 -2
- package/dist/{index-f8cn4xqa.js → index-fwefky9w.js} +18 -5
- package/dist/{index-a43xq1pg.js → index-fx90bvjd.js} +5 -5
- package/dist/{index-0sahzkwr.js → index-g2q4htwp.js} +46 -2
- package/dist/{index-7bjgyaj1.js → index-gf0psee3.js} +243 -135
- package/dist/{index-mw7c950g.js → index-gp3kcpc4.js} +1 -1
- package/dist/{index-gjvjh960.js → index-hqkczed7.js} +1 -1
- package/dist/{index-mvvephtj.js → index-j75v2476.js} +1 -1
- package/dist/{index-150zz6fh.js → index-k29z4aqh.js} +1 -1
- package/dist/{index-b64n4d0h.js → index-kee4kn5j.js} +1 -1
- package/dist/index-ksdyrrav.js +52 -0
- package/dist/{index-angx1s0k.js → index-mmfa86mt.js} +16 -6
- package/dist/{index-9jvab89d.js → index-n6m03s3n.js} +2 -2
- package/dist/{index-q28hsbpg.js → index-nj7yykkx.js} +1 -1
- package/dist/{index-ghc9f0n7.js → index-p5y3k4g7.js} +29 -1
- package/dist/{index-6k86es2p.js → index-qtbdx42g.js} +54 -25
- package/dist/{index-a865mj02.js → index-tdn0zkw4.js} +4 -4
- package/dist/{index-0x9cn9w1.js → index-wqs4q74r.js} +8 -8
- package/dist/{index-swgpe402.js → index-x2xjyq8f.js} +11 -11
- package/dist/{index-a4b0gbyg.js → index-y9f76s3f.js} +1 -1
- package/dist/{index-3403gbzj.js → index-yx5kgp2x.js} +288 -127
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +97 -76
- package/dist/{logger-wn328tfg.js → logger-jm3sqqzr.js} +2 -2
- package/dist/{message-index-bounded-fskdyc81.js → message-index-bounded-nq6rp8xa.js} +16 -16
- package/dist/{message-index-6r1x9cqh.js → message-index-df7swgy1.js} +16 -16
- package/dist/{message-time-backfill-nb5hhnrt.js → message-time-backfill-qjge9044.js} +3 -3
- package/dist/migration-worker.js +11 -11
- 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/tool-registry.d.ts.map +1 -1
- package/dist/{project-embedding-registry-vy7sv9jt.js → project-embedding-registry-q0ysjyzc.js} +11 -11
- package/dist/raw-ordinal-warmup-worker.js +12 -7
- package/dist/{read-session-chunk-zgpvs423.js → read-session-chunk-ax05f7gr.js} +11 -11
- package/dist/{read-session-raw-gm6xj30v.js → read-session-raw-m56hc7v2.js} +7 -3
- package/dist/{recomp-orchestrator-77xc8wpe.js → recomp-orchestrator-a0mvby4e.js} +29 -29
- package/dist/{safe-notification-target-jdynm677.js → safe-notification-target-1szv1k5k.js} +3 -3
- package/dist/{search-72fkjwk2.js → search-fm002702.js} +23 -23
- package/dist/{send-session-notification-q8ngbap3.js → send-session-notification-y2wg3fkh.js} +6 -6
- package/dist/shared/data-path.d.ts +4 -0
- package/dist/shared/data-path.d.ts.map +1 -1
- package/dist/shared/prompt-surface-runtime.d.ts +5 -0
- package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
- package/dist/{storage-tags-35m4gms2.js → storage-tags-yygfb9c8.js} +7 -5
- package/dist/{task-config-cgpg0nvh.js → task-config-x3qmayd2.js} +6 -2
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-r8d406j0.js → transform-postprocess-phase-s84rdf32.js} +29 -29
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/{compaction-marker-candidates-a15w3mqh.js → compaction-marker-candidates-1vqwr3s5.js} +2 -2
- package/dist/v2/compaction-marker-candidates-worker.js +1 -1
- package/dist/v2/{context-z2yagwy4.js → context-x60fa16g.js} +758 -286
- package/dist/v2/{derive-budgets-0rmpmxjw.js → derive-budgets-z25jw3py.js} +3 -3
- package/dist/v2/embedding-backfill-mbjyza2a.js +20 -0
- package/dist/v2/embedding-worker-process.js +1 -1
- package/dist/v2/embedding-worker.js +5 -5
- package/dist/v2/{history-owner-2cr9py37.js → history-owner-42e16w0n.js} +2 -2
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/dream-manual.d.ts +1 -0
- package/dist/v2/hooks/dream-manual.d.ts.map +1 -1
- package/dist/v2/hooks/dream-timer.d.ts +3 -1
- package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
- package/dist/v2/hooks/dream-trigger.d.ts +6 -1
- package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts +1 -1
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/transform-decision-binding.d.ts +15 -0
- package/dist/v2/hooks/transform-decision-binding.d.ts.map +1 -0
- package/dist/v2/hooks/transform-features.d.ts +40 -0
- package/dist/v2/hooks/transform-features.d.ts.map +1 -0
- package/dist/v2/{logger-te6e1j72.js → logger-7qt02bnb.js} +1 -1
- package/dist/v2/{message-index-9ezq6wze.js → message-index-5nayhm1r.js} +15 -15
- package/dist/v2/{message-index-bounded-rqc603f2.js → message-index-bounded-pgv1ndpb.js} +15 -15
- package/dist/v2/{message-time-backfill-rz1pnpaj.js → message-time-backfill-bsteyc4d.js} +2 -2
- package/dist/v2/migration-worker.js +10 -10
- package/dist/v2/{project-embedding-registry-ja23aygk.js → project-embedding-registry-jbmjc0p4.js} +12 -10
- package/dist/v2/raw-ordinal-warmup-worker.js +12 -7
- package/dist/v2/{read-session-chunk-7f87tg2q.js → read-session-chunk-hr3w5bjk.js} +10 -10
- package/dist/v2/{read-session-raw-h4azh85b.js → read-session-raw-b3tf6ra1.js} +6 -2
- package/dist/v2/recomp-orchestrator-8w3449eb.js +59 -0
- package/dist/v2/{safe-notification-target-936374xx.js → safe-notification-target-qg7n2s77.js} +2 -2
- package/dist/v2/{search-2td1b1wy.js → search-mhmxgq0e.js} +22 -22
- package/dist/v2/{send-session-notification-6n7chhyp.js → send-session-notification-jevgj9fe.js} +5 -5
- package/dist/v2/{server-npm52h2q.js → server-05xjtq6c.js} +1 -1
- package/dist/v2/{server-s6jqh8bj.js → server-0ppsweh6.js} +1 -1
- package/dist/v2/server-0s95v3en.js +49 -0
- package/dist/v2/{server-2hxypdx5.js → server-25tg45b4.js} +17 -12
- package/dist/v2/{server-44ryn9rb.js → server-2x42esxd.js} +3 -3
- package/dist/v2/{server-4qr18rfg.js → server-37ngj8qw.js} +10 -51
- package/dist/v2/{server-4zwx20yg.js → server-4c10404h.js} +3 -3
- package/dist/v2/{server-23znwjqk.js → server-50mkkhy1.js} +14 -11
- package/dist/v2/{server-c9w52qss.js → server-5gvkzzrf.js} +290 -76
- package/dist/v2/{server-7dv9wt9r.js → server-6pmqg9m4.js} +1 -1
- package/dist/v2/{server-ak7w74j9.js → server-83ygfha2.js} +4 -4
- package/dist/v2/{server-4rs8sm06.js → server-9ewkzqgd.js} +5 -5
- package/dist/v2/{server-kmapq3v0.js → server-bxpwy6fy.js} +18 -5
- package/dist/v2/{server-zrwaj29a.js → server-d8tj10db.js} +25 -20
- package/dist/v2/{server-cxsr0ng6.js → server-da07v4xp.js} +1 -1
- package/dist/v2/{server-9e5r8y60.js → server-f2xf5gcb.js} +46 -2
- package/dist/v2/{server-hn9fb3v0.js → server-f7jfmrrz.js} +2 -2
- package/dist/v2/{server-f27he3j1.js → server-fa75w6gp.js} +4 -4
- package/dist/v2/{server-njnx39q2.js → server-gvkm8xaj.js} +189 -29
- package/dist/v2/{server-ckrb5rm8.js → server-h0410h0v.js} +1 -1
- package/dist/v2/{server-nveratm5.js → server-kn9n2qgd.js} +1 -1
- package/dist/v2/{server-gc8x2xdb.js → server-m97brnat.js} +9 -9
- package/dist/v2/{server-z0rjemg1.js → server-nmrm2rjy.js} +8 -8
- package/dist/v2/{server-bx59ezg6.js → server-prg55b7k.js} +16 -6
- package/dist/v2/{server-89fcbe37.js → server-pwv4ezb0.js} +1 -1
- package/dist/v2/{server-r5p3b1wy.js → server-qd11g795.js} +29 -1
- package/dist/v2/{server-988cqjme.js → server-rrqpvwqd.js} +2 -2
- package/dist/v2/{server-4easnf78.js → server-sz8jj92q.js} +150 -18
- package/dist/v2/{server-7e087rvk.js → server-th4y11y7.js} +16 -16
- package/dist/v2/{server-9a6bwc12.js → server-vknbt0gq.js} +255 -135
- package/dist/v2/{server-63ha7f0f.js → server-yrvqaswb.js} +1 -1
- package/dist/v2/{server-xqf2d2mg.js → server-zs8d0s3b.js} +2 -2
- package/dist/v2/server.d.ts.map +1 -1
- package/dist/v2/server.js +13 -6
- package/dist/v2/{storage-tags-c4zfcxv4.js → storage-tags-a2gq6dw7.js} +6 -4
- package/dist/v2/store-reader.d.ts +4 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{task-config-x0hq3qfd.js → task-config-nvz8mapa.js} +6 -2
- package/dist/v2/{wrapup-orchestrator-wg8dmmm9.js → wrapup-orchestrator-r82y780v.js} +30 -29
- package/dist/wrapup-orchestrator-vmt6z3q5.js +47 -0
- package/package.json +1 -1
- package/src/agents/smart-notes-dreamer-gate.fixture.ts +171 -0
- package/src/agents/smart-notes-dreamer-gate.golden.json +245 -0
- package/src/agents/smart-notes-dreamer-gate.test.ts +161 -0
- package/src/config/agent-disable.ts +13 -0
- package/src/config/dependency-notes.test.ts +114 -0
- package/src/config/dependency-notes.ts +80 -0
- package/src/config/schema/magic-context.ts +23 -14
- package/src/features/magic-context/dreamer/task-registry.ts +40 -0
- package/src/shared/chunk-vector-writer-guard.test.ts +72 -0
- package/src/shared/data-path.test.ts +35 -1
- package/src/shared/data-path.ts +57 -1
- package/src/shared/prompt-surface-runtime.test.ts +15 -0
- package/src/shared/prompt-surface-runtime.ts +12 -0
- package/dist/embedding-backfill-3h2m5n0q.js +0 -21
- package/dist/v2/embedding-backfill-vr7wdtrf.js +0 -20
- package/dist/v2/recomp-orchestrator-s5tdpsbs.js +0 -59
- package/dist/wrapup-orchestrator-b1z99yg5.js +0 -47
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMagicContextBuiltinCommands,
|
|
3
3
|
readJsoncFile,
|
|
4
|
-
COMPACTION_ENABLED_PATH,
|
|
5
|
-
isDreamerRunnable,
|
|
6
|
-
isCompactionEnabled,
|
|
7
4
|
cortexKitUserConfigBasePath,
|
|
8
5
|
cortexKitProjectConfigBasePath,
|
|
9
6
|
resolveLegacyConfigSources,
|
|
10
7
|
getProtectedTokensTierOverrides,
|
|
11
8
|
loadPluginConfigDetailed
|
|
12
|
-
} from "./server-
|
|
9
|
+
} from "./server-37ngj8qw.js";
|
|
13
10
|
import {
|
|
14
11
|
getHarness2,
|
|
15
12
|
harnessOwnsOpenCodeStore2
|
|
@@ -24,7 +21,7 @@ import {
|
|
|
24
21
|
log2,
|
|
25
22
|
sessionLog2,
|
|
26
23
|
getLoggerDiagnostics2
|
|
27
|
-
} from "./server-
|
|
24
|
+
} from "./server-f2xf5gcb.js";
|
|
28
25
|
import {
|
|
29
26
|
hasTrustedAbsoluteWall,
|
|
30
27
|
applyProvenInputFloor,
|
|
@@ -36,8 +33,9 @@ import {
|
|
|
36
33
|
getSdkContextLimit,
|
|
37
34
|
getSdkOutputLimit,
|
|
38
35
|
getModelsDevCacheState
|
|
39
|
-
} from "./server-
|
|
36
|
+
} from "./server-kn9n2qgd.js";
|
|
40
37
|
import {
|
|
38
|
+
isValidLanguageCode,
|
|
41
39
|
withContentLanguageDirective,
|
|
42
40
|
parseCron,
|
|
43
41
|
nextOccurrence,
|
|
@@ -48,7 +46,25 @@ import {
|
|
|
48
46
|
DEFAULT_HISTORIAN_TIMEOUT_MS,
|
|
49
47
|
DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
50
48
|
DREAM_TASK_PROMOTION_DEFAULTS
|
|
51
|
-
} from "./server-
|
|
49
|
+
} from "./server-th4y11y7.js";
|
|
50
|
+
import {
|
|
51
|
+
CANONICAL_DREAM_TASKS,
|
|
52
|
+
DREAM_TASK_CAPABILITIES,
|
|
53
|
+
toolLoopDreamTasks,
|
|
54
|
+
formatUnsupportedDreamTasks,
|
|
55
|
+
formatDreamTaskBacklogs,
|
|
56
|
+
processedDreamTaskItems,
|
|
57
|
+
PROJECT_MEMORY_DREAM_TASKS,
|
|
58
|
+
dreamTaskAllowedBySettings,
|
|
59
|
+
leaseKindFor,
|
|
60
|
+
leaseKeyFor,
|
|
61
|
+
isCanonicalDreamTask,
|
|
62
|
+
compareTaskOrder,
|
|
63
|
+
buildDreamTaskRuntimeConfigs2,
|
|
64
|
+
userMemoryCollectionEnabled2,
|
|
65
|
+
userObservationCollectionEnabled2,
|
|
66
|
+
userObservationsRequested2
|
|
67
|
+
} from "./server-qd11g795.js";
|
|
52
68
|
import {
|
|
53
69
|
historianRunConfig,
|
|
54
70
|
dreamerRunConfig,
|
|
@@ -57,8 +73,11 @@ import {
|
|
|
57
73
|
withLiveDreamerOutputCap,
|
|
58
74
|
embedPauseBySession,
|
|
59
75
|
embedRunStateBySession,
|
|
76
|
+
autoEmbedAttemptedBySession,
|
|
77
|
+
autoEmbedIdentityBySession,
|
|
60
78
|
invalidateAutoEmbedSession,
|
|
61
79
|
getEmbedDrainUiStatus,
|
|
80
|
+
clearEmbedSessionState,
|
|
62
81
|
acquireCompartmentLease,
|
|
63
82
|
releaseCompartmentLeaseBestEffort,
|
|
64
83
|
isCompartmentLeaseHeld,
|
|
@@ -87,6 +106,7 @@ import {
|
|
|
87
106
|
clearSession,
|
|
88
107
|
requestPendingMaterialization,
|
|
89
108
|
pendingMaterializationOrigin,
|
|
109
|
+
hasPendingMaterializationOrigin,
|
|
90
110
|
clearPendingMaterialization,
|
|
91
111
|
recordSystemPromptForRequest,
|
|
92
112
|
recordHeldHeadForRequest,
|
|
@@ -201,7 +221,7 @@ import {
|
|
|
201
221
|
createPromptAsyncTransport,
|
|
202
222
|
CTX_NOTE_LIGHT_DESCRIPTION,
|
|
203
223
|
ACTIVE_TOOL_IDS,
|
|
204
|
-
|
|
224
|
+
systemPromptFingerprint,
|
|
205
225
|
createPromptSurfaceRuntime,
|
|
206
226
|
createPromptSurfaceGuidanceEpochCache,
|
|
207
227
|
MARKER_SUMMARY_TEXT,
|
|
@@ -261,25 +281,12 @@ import {
|
|
|
261
281
|
getRawHistoryEligibility,
|
|
262
282
|
hasRunnableCompartmentWindow,
|
|
263
283
|
recordHighPressureNoEligibleHead,
|
|
284
|
+
noteTransformPassForExactOrdinalReads,
|
|
264
285
|
getActiveCompartmentRun,
|
|
265
286
|
startCompartmentAgent,
|
|
266
287
|
setRecompStarting2,
|
|
267
288
|
setRecompTerminal2
|
|
268
|
-
} from "./server-
|
|
269
|
-
import {
|
|
270
|
-
CANONICAL_DREAM_TASKS,
|
|
271
|
-
DREAM_TASK_CAPABILITIES,
|
|
272
|
-
toolLoopDreamTasks,
|
|
273
|
-
formatUnsupportedDreamTasks,
|
|
274
|
-
formatDreamTaskBacklogs,
|
|
275
|
-
processedDreamTaskItems,
|
|
276
|
-
leaseKindFor,
|
|
277
|
-
leaseKeyFor,
|
|
278
|
-
isCanonicalDreamTask,
|
|
279
|
-
compareTaskOrder,
|
|
280
|
-
buildDreamTaskRuntimeConfigs2,
|
|
281
|
-
userMemoryCollectionEnabled2
|
|
282
|
-
} from "./server-r5p3b1wy.js";
|
|
289
|
+
} from "./server-5gvkzzrf.js";
|
|
283
290
|
import {
|
|
284
291
|
resolveHistorianModel2
|
|
285
292
|
} from "./server-8cd2j99z.js";
|
|
@@ -296,6 +303,7 @@ import {
|
|
|
296
303
|
getMigrationOnOpenRefusal,
|
|
297
304
|
LATEST_SUPPORTED_VERSION,
|
|
298
305
|
BOOT_SQLITE_BUSY_TIMEOUT_MS,
|
|
306
|
+
getDatabasePath,
|
|
299
307
|
getPersistedSchemaVersion,
|
|
300
308
|
runSqliteOptimize,
|
|
301
309
|
openDatabase,
|
|
@@ -303,7 +311,7 @@ import {
|
|
|
303
311
|
openDatabaseAsync,
|
|
304
312
|
isDatabasePersisted,
|
|
305
313
|
getDatabasePersistenceError
|
|
306
|
-
} from "./server-
|
|
314
|
+
} from "./server-50mkkhy1.js";
|
|
307
315
|
import {
|
|
308
316
|
setHomeProjectPermission,
|
|
309
317
|
shouldSkipHomeProjectMemory,
|
|
@@ -319,7 +327,7 @@ import {
|
|
|
319
327
|
storedPathBelongsToIdentity,
|
|
320
328
|
beginBootQuietPeriod,
|
|
321
329
|
scheduleAfterBootQuiet
|
|
322
|
-
} from "./server-
|
|
330
|
+
} from "./server-gvkm8xaj.js";
|
|
323
331
|
import {
|
|
324
332
|
detectLatestTurnThinkingMismatch,
|
|
325
333
|
isPrefixBoundThinkingModel,
|
|
@@ -506,7 +514,7 @@ import {
|
|
|
506
514
|
readRawSessionMessageById2,
|
|
507
515
|
readSessionChunk2,
|
|
508
516
|
readRawSessionSeedTail2
|
|
509
|
-
} from "./server-
|
|
517
|
+
} from "./server-m97brnat.js";
|
|
510
518
|
import {
|
|
511
519
|
textMentionsRecentCommit,
|
|
512
520
|
hasMeaningfulUserText2,
|
|
@@ -517,7 +525,7 @@ import {
|
|
|
517
525
|
estimateTokens,
|
|
518
526
|
estimateFixedPromptTokens,
|
|
519
527
|
normalizeText
|
|
520
|
-
} from "./server-
|
|
528
|
+
} from "./server-0ppsweh6.js";
|
|
521
529
|
import {
|
|
522
530
|
SubcClient,
|
|
523
531
|
connectionFileExists,
|
|
@@ -525,7 +533,7 @@ import {
|
|
|
525
533
|
toSynapseLaneDescriptor,
|
|
526
534
|
formatSynapseLaneDescriptor,
|
|
527
535
|
SynapseEmbeddingProvider
|
|
528
|
-
} from "./server-
|
|
536
|
+
} from "./server-rrqpvwqd.js";
|
|
529
537
|
import {
|
|
530
538
|
inRootAsyncContext2,
|
|
531
539
|
getTagIdentityWriteGeneration2,
|
|
@@ -540,17 +548,17 @@ import {
|
|
|
540
548
|
SqliteAcquisitionBusyError2,
|
|
541
549
|
withAsyncPrivilegedWriter2
|
|
542
550
|
} from "./server-wafzvyhg.js";
|
|
543
|
-
import"./server-
|
|
551
|
+
import"./server-yrvqaswb.js";
|
|
544
552
|
import {
|
|
545
553
|
deleteChunkEmbedBackoffForSession
|
|
546
|
-
} from "./server-
|
|
554
|
+
} from "./server-vknbt0gq.js";
|
|
547
555
|
import {
|
|
548
556
|
registerOwnRpcServerInstance,
|
|
549
557
|
rpcPortDir,
|
|
550
558
|
rpcPortFilePath,
|
|
551
559
|
parseRpcPortFile,
|
|
552
560
|
inspectProcessesAsync
|
|
553
|
-
} from "./server-
|
|
561
|
+
} from "./server-da07v4xp.js";
|
|
554
562
|
import {
|
|
555
563
|
BoundedSessionMap,
|
|
556
564
|
LkgRecoveryFenceError,
|
|
@@ -569,14 +577,14 @@ import {
|
|
|
569
577
|
isMessageIndexReconciledThrough2,
|
|
570
578
|
indexMessagesAfterOrdinal2,
|
|
571
579
|
sweepOrphanedOpenCodeMessageIndexes2
|
|
572
|
-
} from "./server-
|
|
580
|
+
} from "./server-nmrm2rjy.js";
|
|
573
581
|
import {
|
|
574
582
|
stableStringify,
|
|
575
583
|
getTemporalDecisions,
|
|
576
584
|
observeTemporalDecisions,
|
|
577
585
|
freezeTemporalDecisions,
|
|
578
586
|
tagIdentityRevisionKey
|
|
579
|
-
} from "./server-
|
|
587
|
+
} from "./server-pwv4ezb0.js";
|
|
580
588
|
import {
|
|
581
589
|
resolveModelCalibration,
|
|
582
590
|
calibrateBuckets,
|
|
@@ -643,6 +651,7 @@ import {
|
|
|
643
651
|
backfillTagTokenCounts2,
|
|
644
652
|
insertTag2,
|
|
645
653
|
updateTagStatus2,
|
|
654
|
+
markTagDropped2,
|
|
646
655
|
markWhitespaceAssistantTagInert2,
|
|
647
656
|
getInertWhitespaceAssistantTags2,
|
|
648
657
|
getInertWhitespaceAssistantTagsByNumbers2,
|
|
@@ -668,14 +677,15 @@ import {
|
|
|
668
677
|
adoptNullOwnerToolTag2,
|
|
669
678
|
getCandidateToolOwners2,
|
|
670
679
|
pickNearestPriorOwner2
|
|
671
|
-
} from "./server-
|
|
680
|
+
} from "./server-bxpwy6fy.js";
|
|
672
681
|
import"./server-51779zs2.js";
|
|
673
682
|
import {
|
|
674
683
|
isRawCompactionSummaryInfo2,
|
|
675
684
|
extractInMemoryMessageViews2,
|
|
676
685
|
buildInMemoryTailRawMessages2,
|
|
686
|
+
RawOrdinalsNotReady2,
|
|
677
687
|
runSessionWarmupWorker
|
|
678
|
-
} from "./server-
|
|
688
|
+
} from "./server-prg55b7k.js";
|
|
679
689
|
import {
|
|
680
690
|
resolveOpenCodeDbPath,
|
|
681
691
|
assertOpenCodeStoreGeneration,
|
|
@@ -691,12 +701,12 @@ import {
|
|
|
691
701
|
latestRealUserTurnIdFromOpenCodeDb,
|
|
692
702
|
getMessageTimesFromOpenCodeDb,
|
|
693
703
|
findLastAssistantModelFromOpenCodeDb
|
|
694
|
-
} from "./server-
|
|
704
|
+
} from "./server-d8tj10db.js";
|
|
695
705
|
import {
|
|
696
706
|
getCurrentToolSetHash,
|
|
697
707
|
recordToolDefinition,
|
|
698
708
|
getMeasuredToolDefinitionTokens
|
|
699
|
-
} from "./server-
|
|
709
|
+
} from "./server-zs8d0s3b.js";
|
|
700
710
|
import {
|
|
701
711
|
V2_MEMORY_CATEGORIES,
|
|
702
712
|
CATEGORY_PRIORITY
|
|
@@ -709,7 +719,7 @@ import {
|
|
|
709
719
|
resolveStoredPathWorkspaceIdentity,
|
|
710
720
|
storedPathBelongsToWorkspace,
|
|
711
721
|
computeWorkspaceEpochFingerprint
|
|
712
|
-
} from "./server-
|
|
722
|
+
} from "./server-fa75w6gp.js";
|
|
713
723
|
import {
|
|
714
724
|
GIT_SWEEP_LEASE_RENEWAL_MS,
|
|
715
725
|
acquireGitSweepLease,
|
|
@@ -735,9 +745,12 @@ import {
|
|
|
735
745
|
embedUnembeddedMemoriesForProjectOutcome2,
|
|
736
746
|
drainCommitBacklogForProject2,
|
|
737
747
|
embedSessionCompartmentChunks2,
|
|
738
|
-
getEmbeddingCoverageStatus2
|
|
739
|
-
|
|
740
|
-
|
|
748
|
+
getEmbeddingCoverageStatus2,
|
|
749
|
+
getAutoEmbeddingSessionCoverage2
|
|
750
|
+
} from "./server-sz8jj92q.js";
|
|
751
|
+
import {
|
|
752
|
+
configureContextDatabasePragmas2
|
|
753
|
+
} from "./server-fb3zxn06.js";
|
|
741
754
|
import {
|
|
742
755
|
SESSION_NOTE_CONDITION_ERROR,
|
|
743
756
|
getNoteByIdInScope,
|
|
@@ -780,15 +793,15 @@ import {
|
|
|
780
793
|
readGitFileChangeTimesSince,
|
|
781
794
|
verificationFileExists,
|
|
782
795
|
normalizeVerificationFiles
|
|
783
|
-
} from "./server-
|
|
796
|
+
} from "./server-4c10404h.js";
|
|
784
797
|
import {
|
|
785
798
|
deriveTriggerBudget2,
|
|
786
799
|
deriveHistorianChunkTokens2,
|
|
787
800
|
resolveKnownHistorianContextLimit2,
|
|
788
801
|
resolveHistorianProducerLimits2,
|
|
789
802
|
resolveHistorianContextLimit2
|
|
790
|
-
} from "./server-
|
|
791
|
-
import"./server-
|
|
803
|
+
} from "./server-f7jfmrrz.js";
|
|
804
|
+
import"./server-05xjtq6c.js";
|
|
792
805
|
import {
|
|
793
806
|
isEmbeddingHostBusy2
|
|
794
807
|
} from "./server-qt1qqasc.js";
|
|
@@ -799,10 +812,10 @@ import {
|
|
|
799
812
|
} from "./server-4dhv7mqz.js";
|
|
800
813
|
import {
|
|
801
814
|
getLocalEmbeddingNativeMemoryStats
|
|
802
|
-
} from "./server-
|
|
815
|
+
} from "./server-2x42esxd.js";
|
|
803
816
|
import {
|
|
804
817
|
cosineSimilarity
|
|
805
|
-
} from "./server-
|
|
818
|
+
} from "./server-9ewkzqgd.js";
|
|
806
819
|
import {
|
|
807
820
|
computeCueContentHash,
|
|
808
821
|
hasMuralCueColumns,
|
|
@@ -835,11 +848,11 @@ import {
|
|
|
835
848
|
drainNotifications2,
|
|
836
849
|
isTuiConnected2
|
|
837
850
|
} from "./server-x8a7jmkh.js";
|
|
838
|
-
import"./server-
|
|
851
|
+
import"./server-h0410h0v.js";
|
|
839
852
|
import {
|
|
840
853
|
flushIgnoredMessages2,
|
|
841
854
|
sendStatusNotification2
|
|
842
|
-
} from "./server-
|
|
855
|
+
} from "./server-83ygfha2.js";
|
|
843
856
|
import {
|
|
844
857
|
renderSingleStoreMigrationRequiredRefusal,
|
|
845
858
|
SingleStoreMigrationRequiredError,
|
|
@@ -860,13 +873,19 @@ import {
|
|
|
860
873
|
resolveMemoriesByIdsForSearch2,
|
|
861
874
|
unifiedSearch2,
|
|
862
875
|
formatSearchResults2
|
|
863
|
-
} from "./server-
|
|
876
|
+
} from "./server-25tg45b4.js";
|
|
864
877
|
import {
|
|
865
878
|
resolvePromptContext2
|
|
866
879
|
} from "./server-fmsr7v69.js";
|
|
867
880
|
import {
|
|
868
881
|
compareSemverCore
|
|
869
882
|
} from "./server-84w6rvvf.js";
|
|
883
|
+
import {
|
|
884
|
+
COMPACTION_ENABLED_PATH,
|
|
885
|
+
isDreamerRunnable,
|
|
886
|
+
isSmartNoteSurfaceAvailable,
|
|
887
|
+
isCompactionEnabled
|
|
888
|
+
} from "./server-0s95v3en.js";
|
|
870
889
|
import {
|
|
871
890
|
__toESM,
|
|
872
891
|
__export
|
|
@@ -904,7 +923,7 @@ import {
|
|
|
904
923
|
} from "./server-8ajstryz.js";
|
|
905
924
|
import {
|
|
906
925
|
logSlowWriteTransaction
|
|
907
|
-
} from "./server-
|
|
926
|
+
} from "./server-6pmqg9m4.js";
|
|
908
927
|
|
|
909
928
|
// ../../node_modules/.bun/zod@4.1.8/node_modules/zod/v4/classic/external.js
|
|
910
929
|
var exports_external = {};
|
|
@@ -1604,6 +1623,39 @@ __export(exports_coerce, {
|
|
|
1604
1623
|
string: () => string3
|
|
1605
1624
|
});
|
|
1606
1625
|
|
|
1626
|
+
// src/config/dependency-notes.ts
|
|
1627
|
+
function scheduledTasks(config) {
|
|
1628
|
+
const tasks = config.dreamer?.tasks ?? {};
|
|
1629
|
+
return Object.entries(tasks).filter(([, task]) => typeof task?.schedule === "string" && task.schedule.trim() !== "").map(([name]) => name);
|
|
1630
|
+
}
|
|
1631
|
+
function configDependencyNotes(config) {
|
|
1632
|
+
const notes = [];
|
|
1633
|
+
const dreamerRunnable = isDreamerRunnable(config);
|
|
1634
|
+
const dreamerDisabled = config.dreamer?.disable === true;
|
|
1635
|
+
const memoryOff = config.memory?.enabled === false;
|
|
1636
|
+
const memoryTasks = scheduledTasks(config).filter((task) => PROJECT_MEMORY_DREAM_TASKS.includes(task));
|
|
1637
|
+
if (dreamerRunnable && memoryOff && memoryTasks.length > 0) {
|
|
1638
|
+
notes.push(`memory.enabled is false, so these scheduled dreamer tasks do not run for this project, on schedule or through /ctx-dream: ${memoryTasks.join(", ")}. maintain-docs, evaluate-smart-notes and review-user-memories still run.`);
|
|
1639
|
+
}
|
|
1640
|
+
if (dreamerDisabled && config.smart_notes?.enabled !== false) {
|
|
1641
|
+
notes.push("dreamer.disable is true, so smart_notes.enabled has no effect: ctx_note does not offer surface_condition and pending smart notes are not evaluated.");
|
|
1642
|
+
}
|
|
1643
|
+
const reviewSchedule = config.dreamer?.tasks?.["review-user-memories"]?.schedule;
|
|
1644
|
+
if (dreamerDisabled && typeof reviewSchedule === "string" && reviewSchedule.trim() !== "") {
|
|
1645
|
+
notes.push("dreamer.disable is true, so dreamer.tasks.review-user-memories.schedule has no effect: the historian does not collect user observations and the <user-profile> block gets no new entries.");
|
|
1646
|
+
}
|
|
1647
|
+
return notes;
|
|
1648
|
+
}
|
|
1649
|
+
var loggedNotes = new Set;
|
|
1650
|
+
function logConfigDependencyNotesOnce(config, log) {
|
|
1651
|
+
const fresh = configDependencyNotes(config).filter((note) => !loggedNotes.has(note));
|
|
1652
|
+
for (const note of fresh) {
|
|
1653
|
+
loggedNotes.add(note);
|
|
1654
|
+
log(`[magic-context] config note: ${note}`);
|
|
1655
|
+
}
|
|
1656
|
+
return fresh;
|
|
1657
|
+
}
|
|
1658
|
+
|
|
1607
1659
|
// src/features/magic-context/dreamer/manual-summary.ts
|
|
1608
1660
|
function summarizeManualDream(summary) {
|
|
1609
1661
|
const lines = ["## /ctx-dream", ""];
|
|
@@ -2416,6 +2468,275 @@ function createTagger() {
|
|
|
2416
2468
|
};
|
|
2417
2469
|
}
|
|
2418
2470
|
|
|
2471
|
+
// src/features/magic-context/transform-decision-log.ts
|
|
2472
|
+
var TRANSFORM_DECISIONS_RETENTION = 2000;
|
|
2473
|
+
var canonicalReasons = new Set([
|
|
2474
|
+
"system_hash",
|
|
2475
|
+
"model_change",
|
|
2476
|
+
"project_memory_epoch",
|
|
2477
|
+
"ttl_idle",
|
|
2478
|
+
"explicit_flush",
|
|
2479
|
+
"user_flush",
|
|
2480
|
+
"fit_retry",
|
|
2481
|
+
"pending_materialization",
|
|
2482
|
+
"variant_change",
|
|
2483
|
+
"recomp",
|
|
2484
|
+
"boundary_repair",
|
|
2485
|
+
"host_history_change",
|
|
2486
|
+
"thinking_hold",
|
|
2487
|
+
"mutation_drift",
|
|
2488
|
+
"max_mutation_id",
|
|
2489
|
+
"first_render",
|
|
2490
|
+
"pressure_refold",
|
|
2491
|
+
"upgrade_state",
|
|
2492
|
+
"cached_m1_missing",
|
|
2493
|
+
"project_change",
|
|
2494
|
+
"compartment_render_epoch",
|
|
2495
|
+
"m1_delta",
|
|
2496
|
+
"ttl_expiry",
|
|
2497
|
+
"epoch_change",
|
|
2498
|
+
"coverage_fold",
|
|
2499
|
+
"profile_transition",
|
|
2500
|
+
"host_compaction",
|
|
2501
|
+
"tag_identity_repair"
|
|
2502
|
+
]);
|
|
2503
|
+
var piReasonAliases = {
|
|
2504
|
+
project_memory_change: "project_memory_epoch",
|
|
2505
|
+
pending_mutations: "max_mutation_id",
|
|
2506
|
+
renderer_upgrade: "upgrade_state",
|
|
2507
|
+
cache_invalid: "cached_m1_missing",
|
|
2508
|
+
drift: "pressure_refold"
|
|
2509
|
+
};
|
|
2510
|
+
var sharedReasonAliases = {
|
|
2511
|
+
model_key: "model_change",
|
|
2512
|
+
pressure: "pressure_refold"
|
|
2513
|
+
};
|
|
2514
|
+
var pendingDecisionBySession = new Map;
|
|
2515
|
+
var pendingPiDecisionBySession = new Map;
|
|
2516
|
+
var lastBoundMessageIdBySession = new Map;
|
|
2517
|
+
var scheduledWriteTokensBySession = new Map;
|
|
2518
|
+
var systemHashChangedSessions = new Set;
|
|
2519
|
+
var piSystemHashChangedSessions = new Set;
|
|
2520
|
+
var unbustedPassBySession = new Map;
|
|
2521
|
+
var newestInputAssistantBySession = new Map;
|
|
2522
|
+
var stagedV2DecisionBySession = new Map;
|
|
2523
|
+
var writerOverrideForTests = null;
|
|
2524
|
+
var retentionOverrideForTests = null;
|
|
2525
|
+
function normalizeMaterializeReason(harness, reason, rematerialized) {
|
|
2526
|
+
const raw = typeof reason === "string" ? reason.trim() : "";
|
|
2527
|
+
if (raw.length > 0) {
|
|
2528
|
+
const alias = sharedReasonAliases[raw] ?? (harness === "pi" ? piReasonAliases[raw] : undefined) ?? undefined;
|
|
2529
|
+
if (alias)
|
|
2530
|
+
return alias;
|
|
2531
|
+
if (canonicalReasons.has(raw))
|
|
2532
|
+
return raw;
|
|
2533
|
+
return null;
|
|
2534
|
+
}
|
|
2535
|
+
return rematerialized ? "pressure_refold" : null;
|
|
2536
|
+
}
|
|
2537
|
+
function writeRustTransformDecision(args) {
|
|
2538
|
+
const rawDecision = args.decision.trim();
|
|
2539
|
+
const decisionUpper = rawDecision.toUpperCase();
|
|
2540
|
+
const mapped = decisionUpper === "HARD" || decisionUpper === "MIGRATE_HARD" ? { decision: "execute", materialized: true, bustedThisPass: true } : decisionUpper === "SOFT" || decisionUpper === "EXECUTE" || args.materializeReason === "ttl_idle" ? { decision: "execute", materialized: false, bustedThisPass: true } : decisionUpper === "SOFT+" ? { decision: "defer", materialized: false, bustedThisPass: false } : {
|
|
2541
|
+
decision: rawDecision.toLowerCase() || "unknown",
|
|
2542
|
+
materialized: false,
|
|
2543
|
+
bustedThisPass: false
|
|
2544
|
+
};
|
|
2545
|
+
pendingDecisionBySession.set(args.sessionId, {
|
|
2546
|
+
tsMs: args.tsMs ?? Date.now(),
|
|
2547
|
+
decision: mapped.decision,
|
|
2548
|
+
materialized: mapped.materialized,
|
|
2549
|
+
materializeReason: args.materializeReason,
|
|
2550
|
+
systemHashPrev: null,
|
|
2551
|
+
systemHashNew: null,
|
|
2552
|
+
m0ModelKeyPrev: null,
|
|
2553
|
+
m0ModelKeyNew: null,
|
|
2554
|
+
m0ToolSetHashPrev: null,
|
|
2555
|
+
m0ToolSetHashNew: null,
|
|
2556
|
+
emergency: false,
|
|
2557
|
+
droppedTokens: 0,
|
|
2558
|
+
droppedCount: 0,
|
|
2559
|
+
inputTokens: args.inputTokens,
|
|
2560
|
+
bustedThisPass: mapped.bustedThisPass,
|
|
2561
|
+
lkgFrozenReleaseReason: args.lkgFrozenReleaseReason
|
|
2562
|
+
});
|
|
2563
|
+
}
|
|
2564
|
+
function clearOpenCodePendingTransformDecision(sessionId, inputMessages) {
|
|
2565
|
+
pendingDecisionBySession.delete(sessionId);
|
|
2566
|
+
unbustedPassBySession.delete(sessionId);
|
|
2567
|
+
if (!inputMessages)
|
|
2568
|
+
return;
|
|
2569
|
+
let newestAssistant = "";
|
|
2570
|
+
for (const message of inputMessages) {
|
|
2571
|
+
const id = message.info?.id;
|
|
2572
|
+
if (message.info?.role !== "assistant" || typeof id !== "string")
|
|
2573
|
+
continue;
|
|
2574
|
+
if (id > newestAssistant)
|
|
2575
|
+
newestAssistant = id;
|
|
2576
|
+
}
|
|
2577
|
+
newestInputAssistantBySession.set(sessionId, newestAssistant);
|
|
2578
|
+
}
|
|
2579
|
+
function noteSystemPromptHashChange(sessionId) {
|
|
2580
|
+
systemHashChangedSessions.add(sessionId);
|
|
2581
|
+
}
|
|
2582
|
+
function noteOpenCodeUnbustedPass(sessionId, decision) {
|
|
2583
|
+
unbustedPassBySession.set(sessionId, decision);
|
|
2584
|
+
}
|
|
2585
|
+
var IDLE_EXPIRY_REASONS = new Set([
|
|
2586
|
+
"ttl_idle",
|
|
2587
|
+
"ttl_expiry"
|
|
2588
|
+
]);
|
|
2589
|
+
function withSystemHashReason(decision) {
|
|
2590
|
+
if (IDLE_EXPIRY_REASONS.has(decision.materializeReason))
|
|
2591
|
+
return decision;
|
|
2592
|
+
return { ...decision, materializeReason: "system_hash" };
|
|
2593
|
+
}
|
|
2594
|
+
function unknownPassDecision() {
|
|
2595
|
+
return {
|
|
2596
|
+
tsMs: Date.now(),
|
|
2597
|
+
decision: "unknown",
|
|
2598
|
+
materialized: false,
|
|
2599
|
+
materializeReason: null,
|
|
2600
|
+
systemHashPrev: null,
|
|
2601
|
+
systemHashNew: null,
|
|
2602
|
+
m0ModelKeyPrev: null,
|
|
2603
|
+
m0ModelKeyNew: null,
|
|
2604
|
+
emergency: false,
|
|
2605
|
+
droppedTokens: 0,
|
|
2606
|
+
droppedCount: 0,
|
|
2607
|
+
inputTokens: 0,
|
|
2608
|
+
bustedThisPass: false
|
|
2609
|
+
};
|
|
2610
|
+
}
|
|
2611
|
+
function takeOpenCodeDecisionForBinding(sessionId, applySystemHashChange) {
|
|
2612
|
+
const pending = pendingDecisionBySession.get(sessionId);
|
|
2613
|
+
const unbusted = unbustedPassBySession.get(sessionId);
|
|
2614
|
+
pendingDecisionBySession.delete(sessionId);
|
|
2615
|
+
unbustedPassBySession.delete(sessionId);
|
|
2616
|
+
if (!applySystemHashChange || !systemHashChangedSessions.has(sessionId))
|
|
2617
|
+
return pending;
|
|
2618
|
+
systemHashChangedSessions.delete(sessionId);
|
|
2619
|
+
return withSystemHashReason(pending ?? unbusted ?? unknownPassDecision());
|
|
2620
|
+
}
|
|
2621
|
+
function recordPendingTransformDecision(sessionId, decision) {
|
|
2622
|
+
if (!decision.bustedThisPass) {
|
|
2623
|
+
pendingDecisionBySession.delete(sessionId);
|
|
2624
|
+
return;
|
|
2625
|
+
}
|
|
2626
|
+
pendingDecisionBySession.set(sessionId, decision);
|
|
2627
|
+
}
|
|
2628
|
+
function stageOpenCodeV2TransformDecision(args) {
|
|
2629
|
+
const systemHashChanged = systemHashChangedSessions.has(args.sessionId);
|
|
2630
|
+
const decision = takeOpenCodeDecisionForBinding(args.sessionId, true);
|
|
2631
|
+
stagedV2DecisionBySession.delete(args.sessionId);
|
|
2632
|
+
if (!decision || args.responseAfterSequence === undefined)
|
|
2633
|
+
return false;
|
|
2634
|
+
if (!decision.bustedThisPass && !systemHashChanged)
|
|
2635
|
+
return false;
|
|
2636
|
+
stagedV2DecisionBySession.set(args.sessionId, {
|
|
2637
|
+
decision,
|
|
2638
|
+
responseAfterSequence: args.responseAfterSequence
|
|
2639
|
+
});
|
|
2640
|
+
return true;
|
|
2641
|
+
}
|
|
2642
|
+
function bindOpenCodeV2TransformDecision(args) {
|
|
2643
|
+
const staged = stagedV2DecisionBySession.get(args.sessionId);
|
|
2644
|
+
if (!staged)
|
|
2645
|
+
return false;
|
|
2646
|
+
const reply = args.firstAssistantAfter(staged.responseAfterSequence);
|
|
2647
|
+
if (!reply || reply.state === "running") {
|
|
2648
|
+
if (args.passStarting)
|
|
2649
|
+
stagedV2DecisionBySession.delete(args.sessionId);
|
|
2650
|
+
return false;
|
|
2651
|
+
}
|
|
2652
|
+
stagedV2DecisionBySession.delete(args.sessionId);
|
|
2653
|
+
if (reply.state === "failed")
|
|
2654
|
+
return false;
|
|
2655
|
+
const dbPath = getDatabasePath(args.db);
|
|
2656
|
+
if (!dbPath)
|
|
2657
|
+
return false;
|
|
2658
|
+
const token = addScheduledWriteToken(args.sessionId);
|
|
2659
|
+
inRootAsyncContext2(() => setTimeout(() => {
|
|
2660
|
+
try {
|
|
2661
|
+
if (!hasScheduledWriteToken(args.sessionId, token))
|
|
2662
|
+
return;
|
|
2663
|
+
writeTransformDecisionBestEffort(dbPath, {
|
|
2664
|
+
...staged.decision,
|
|
2665
|
+
sessionId: args.sessionId,
|
|
2666
|
+
harness: "opencode2",
|
|
2667
|
+
messageId: reply.id,
|
|
2668
|
+
inputTokens: Number.isFinite(reply.inputTokens) ? reply.inputTokens : staged.decision.inputTokens
|
|
2669
|
+
});
|
|
2670
|
+
} finally {
|
|
2671
|
+
deleteScheduledWriteToken(args.sessionId, token);
|
|
2672
|
+
}
|
|
2673
|
+
}, 0));
|
|
2674
|
+
return true;
|
|
2675
|
+
}
|
|
2676
|
+
function addScheduledWriteToken(sessionId) {
|
|
2677
|
+
const token = Symbol(sessionId);
|
|
2678
|
+
let tokens = scheduledWriteTokensBySession.get(sessionId);
|
|
2679
|
+
if (!tokens) {
|
|
2680
|
+
tokens = new Set;
|
|
2681
|
+
scheduledWriteTokensBySession.set(sessionId, tokens);
|
|
2682
|
+
}
|
|
2683
|
+
tokens.add(token);
|
|
2684
|
+
return token;
|
|
2685
|
+
}
|
|
2686
|
+
function hasScheduledWriteToken(sessionId, token) {
|
|
2687
|
+
return scheduledWriteTokensBySession.get(sessionId)?.has(token) === true;
|
|
2688
|
+
}
|
|
2689
|
+
function deleteScheduledWriteToken(sessionId, token) {
|
|
2690
|
+
const tokens = scheduledWriteTokensBySession.get(sessionId);
|
|
2691
|
+
if (!tokens)
|
|
2692
|
+
return;
|
|
2693
|
+
tokens.delete(token);
|
|
2694
|
+
if (tokens.size === 0)
|
|
2695
|
+
scheduledWriteTokensBySession.delete(sessionId);
|
|
2696
|
+
}
|
|
2697
|
+
function writeTransformDecisionBestEffort(dbPath, row) {
|
|
2698
|
+
try {
|
|
2699
|
+
const writer = writerOverrideForTests ?? writeTransformDecisionRow;
|
|
2700
|
+
writer(dbPath, row);
|
|
2701
|
+
} catch {}
|
|
2702
|
+
}
|
|
2703
|
+
function writeTransformDecisionRow(dbPath, row) {
|
|
2704
|
+
const db = new Database2(dbPath);
|
|
2705
|
+
try {
|
|
2706
|
+
db.exec("PRAGMA busy_timeout=0");
|
|
2707
|
+
configureContextDatabasePragmas2(db);
|
|
2708
|
+
writeTransformDecisionRowOnDatabase(db, row, true);
|
|
2709
|
+
} finally {
|
|
2710
|
+
closeQuietly(db);
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
function writeTransformDecisionRowOnDatabase(db, row, configureBusyTimeout) {
|
|
2714
|
+
if (configureBusyTimeout)
|
|
2715
|
+
db.exec("PRAGMA busy_timeout=0");
|
|
2716
|
+
const systemHashPrev = row.materialized ? row.systemHashPrev : null;
|
|
2717
|
+
const systemHashNew = row.materialized ? row.systemHashNew : null;
|
|
2718
|
+
const m0ModelKeyPrev = row.materialized ? row.m0ModelKeyPrev : null;
|
|
2719
|
+
const m0ModelKeyNew = row.materialized ? row.m0ModelKeyNew : null;
|
|
2720
|
+
const m0ToolSetHashPrev = row.m0ToolSetHashPrev ?? null;
|
|
2721
|
+
const m0ToolSetHashNew = row.m0ToolSetHashNew ?? null;
|
|
2722
|
+
const persistedMaterializeReason = row.lkgFrozenReleaseReason ? `lkg_frozen_release:${row.lkgFrozenReleaseReason}` + (row.materializeReason ? `;materialize_reason=${row.materializeReason}` : "") : row.materializeReason;
|
|
2723
|
+
db.prepare(`INSERT OR REPLACE INTO transform_decisions (
|
|
2724
|
+
session_id, harness, message_id, ts_ms, decision, materialized,
|
|
2725
|
+
materialize_reason, system_hash_prev, system_hash_new,
|
|
2726
|
+
m0_tool_set_hash_prev, m0_tool_set_hash_new,
|
|
2727
|
+
m0_model_key_prev, m0_model_key_new, emergency, dropped_tokens,
|
|
2728
|
+
dropped_count, input_tokens
|
|
2729
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(row.sessionId, row.harness, row.messageId, row.tsMs, row.decision, row.materialized ? 1 : 0, persistedMaterializeReason, systemHashPrev, systemHashNew, m0ToolSetHashPrev, m0ToolSetHashNew, m0ModelKeyPrev, m0ModelKeyNew, row.emergency ? 1 : 0, Math.max(0, Math.floor(row.droppedTokens)), Math.max(0, Math.floor(row.droppedCount)), Math.max(0, Math.floor(row.inputTokens)));
|
|
2730
|
+
db.prepare(`DELETE FROM transform_decisions
|
|
2731
|
+
WHERE session_id = ? AND harness = ?
|
|
2732
|
+
AND rowid NOT IN (
|
|
2733
|
+
SELECT rowid FROM transform_decisions
|
|
2734
|
+
WHERE session_id = ? AND harness = ?
|
|
2735
|
+
ORDER BY ts_ms DESC, rowid DESC
|
|
2736
|
+
LIMIT ?
|
|
2737
|
+
)`).run(row.sessionId, row.harness, row.sessionId, row.harness, retentionOverrideForTests ?? TRANSFORM_DECISIONS_RETENTION);
|
|
2738
|
+
}
|
|
2739
|
+
|
|
2419
2740
|
// src/hooks/magic-context/ctx-reduce-availability.ts
|
|
2420
2741
|
var ctxReduceRegisteredGlobally = true;
|
|
2421
2742
|
function setCtxReduceRegisteredGlobally(registered) {
|
|
@@ -3628,6 +3949,12 @@ function applyUltraAbbreviationsUnicode(text) {
|
|
|
3628
3949
|
return working;
|
|
3629
3950
|
}
|
|
3630
3951
|
var CURRENT_CAVEMAN_RULES = "unicode-v2";
|
|
3952
|
+
function cavemanWordRulesForLanguage(language) {
|
|
3953
|
+
const code = typeof language === "string" ? language.trim().toLowerCase() : "";
|
|
3954
|
+
if (code === "en" || code.startsWith("en-"))
|
|
3955
|
+
return "english";
|
|
3956
|
+
return isValidLanguageCode(code) ? "none" : "english";
|
|
3957
|
+
}
|
|
3631
3958
|
function cavemanCompress(text, level, rules = CURRENT_CAVEMAN_RULES, wordRules = "english") {
|
|
3632
3959
|
if (text.length === 0)
|
|
3633
3960
|
return text;
|
|
@@ -6494,6 +6821,36 @@ function createModuleToolBackends(options) {
|
|
|
6494
6821
|
};
|
|
6495
6822
|
}
|
|
6496
6823
|
|
|
6824
|
+
// src/hooks/magic-context/render-options.ts
|
|
6825
|
+
function createM0RenderOptions(controls, contextUsage, modelKey, resolvedContextLimit, projectPath) {
|
|
6826
|
+
return {
|
|
6827
|
+
projectPath: controls.memoryConfig?.enabled ? projectPath : undefined,
|
|
6828
|
+
memoryEnabled: controls.memoryConfig?.enabled,
|
|
6829
|
+
memoryInjectionBudgetTokens: controls.memoryConfig?.injectionBudgetTokens,
|
|
6830
|
+
injectDocs: controls.injectDocs,
|
|
6831
|
+
muralEnabled: controls.muralEnabled,
|
|
6832
|
+
temporalAwareness: controls.experimentalTemporalAwareness,
|
|
6833
|
+
historyBudgetTokens: resolveHistoryBudgetTokens(controls.historyBudgetPercentage, contextUsage, controls.executeThresholdPercentage, modelKey, controls.executeThresholdTokens, resolvedContextLimit),
|
|
6834
|
+
historyBudgetPolicyIdentity: historyBudgetPolicyIdentity(controls.historyBudgetPercentage, controls.executeThresholdPercentage, modelKey, controls.executeThresholdTokens)
|
|
6835
|
+
};
|
|
6836
|
+
}
|
|
6837
|
+
function resolveHistoryBudgetTokens(historyBudgetPercentage, contextUsage, executeThresholdPercentage, modelKey, executeThresholdTokens, resolvedContextLimit) {
|
|
6838
|
+
if (!historyBudgetPercentage)
|
|
6839
|
+
return;
|
|
6840
|
+
let contextLimit = resolvedContextLimit && resolvedContextLimit > 0 ? resolvedContextLimit : 0;
|
|
6841
|
+
if (contextLimit <= 0) {
|
|
6842
|
+
if (contextUsage.percentage <= 0)
|
|
6843
|
+
return;
|
|
6844
|
+
contextLimit = contextUsage.inputTokens / (contextUsage.percentage / 100);
|
|
6845
|
+
}
|
|
6846
|
+
if (!Number.isFinite(contextLimit) || contextLimit <= 0)
|
|
6847
|
+
return;
|
|
6848
|
+
return Math.floor(contextLimit * (resolveExecuteThreshold(executeThresholdPercentage ?? 65, modelKey, 65, {
|
|
6849
|
+
tokensConfig: executeThresholdTokens,
|
|
6850
|
+
contextLimit
|
|
6851
|
+
}) / 100) * historyBudgetPercentage);
|
|
6852
|
+
}
|
|
6853
|
+
|
|
6497
6854
|
// src/hooks/magic-context/apply-operations.ts
|
|
6498
6855
|
var RECENT_TOOL_SKELETON_WINDOW = 20;
|
|
6499
6856
|
function buildReplacementContent(tagId) {
|
|
@@ -6560,13 +6917,20 @@ function foldBustsServedPrefix(reason, before, after) {
|
|
|
6560
6917
|
return CACHE_LOSING_FOLD_REASONS.has(reason ?? "") || foldChangesServedPrefix(before, after);
|
|
6561
6918
|
}
|
|
6562
6919
|
function prepareLegacyToolSkeletonConversions(db, sessionId, targets, options = {}) {
|
|
6563
|
-
const
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6920
|
+
const candidates = [...targets.keys()].sort((a, b) => a - b);
|
|
6921
|
+
const readRows = (connection) => {
|
|
6922
|
+
if (candidates.length === 0)
|
|
6923
|
+
return [];
|
|
6924
|
+
const statement = connection.prepare(`SELECT tag_number AS tagNumber, drop_mode AS dropMode, message_id AS callId
|
|
6925
|
+
FROM tags WHERE session_id = ? AND tag_number = ?
|
|
6926
|
+
AND type = 'tool' AND status = 'dropped'
|
|
6927
|
+
AND drop_mode IN ('truncated', 'full')`);
|
|
6928
|
+
return candidates.flatMap((tagNumber) => {
|
|
6929
|
+
const row = statement.get(sessionId, tagNumber);
|
|
6930
|
+
return row ? [row] : [];
|
|
6931
|
+
});
|
|
6932
|
+
};
|
|
6568
6933
|
const rows = readRows(db);
|
|
6569
|
-
const identity = JSON.stringify(rows);
|
|
6570
6934
|
const converted = new Map;
|
|
6571
6935
|
for (const row of rows) {
|
|
6572
6936
|
const target = targets.get(row.tagNumber);
|
|
@@ -6587,7 +6951,10 @@ function prepareLegacyToolSkeletonConversions(db, sessionId, targets, options =
|
|
|
6587
6951
|
}
|
|
6588
6952
|
return {
|
|
6589
6953
|
converted,
|
|
6590
|
-
isCurrent: (connection) =>
|
|
6954
|
+
isCurrent: (connection) => {
|
|
6955
|
+
const current = readRows(connection);
|
|
6956
|
+
return current.length === rows.length && current.every((row, index) => row.tagNumber === rows[index].tagNumber && row.dropMode === rows[index].dropMode && row.callId === rows[index].callId);
|
|
6957
|
+
},
|
|
6591
6958
|
persist: (connection) => {
|
|
6592
6959
|
for (const [tagNumber, mode] of converted)
|
|
6593
6960
|
updateTagDropMode2(connection, sessionId, tagNumber, mode);
|
|
@@ -6674,9 +7041,7 @@ function applyPendingOperations(sessionId, db, targets, protectedTagIds, preload
|
|
|
6674
7041
|
try {
|
|
6675
7042
|
db.transaction(() => {
|
|
6676
7043
|
startedAt = performance.now();
|
|
6677
|
-
|
|
6678
|
-
updateTagDropMode2(db, sessionId, pendingOp.tagId, mode);
|
|
6679
|
-
updateTagStatus2(db, sessionId, pendingOp.tagId, "dropped");
|
|
7044
|
+
markTagDropped2(db, sessionId, pendingOp.tagId, mode);
|
|
6680
7045
|
if (!synthetic)
|
|
6681
7046
|
removePendingOp(db, sessionId, pendingOp.tagId);
|
|
6682
7047
|
}).immediate();
|
|
@@ -9215,6 +9580,25 @@ function finalizeMessageRepresentation(messages, resolvedProviderID, options) {
|
|
|
9215
9580
|
}
|
|
9216
9581
|
return { clearedParts, mergedReasoningParts };
|
|
9217
9582
|
}
|
|
9583
|
+
function legacyPublishedHeadChanged(args) {
|
|
9584
|
+
if (!args.pendingCompartmentInjection || !args.readLastServedMessages)
|
|
9585
|
+
return false;
|
|
9586
|
+
const served = args.readLastServedMessages();
|
|
9587
|
+
if (served === null)
|
|
9588
|
+
return true;
|
|
9589
|
+
const previous = served[0];
|
|
9590
|
+
if (!Array.isArray(previous?.parts) || !args.pendingCompartmentInjection)
|
|
9591
|
+
return false;
|
|
9592
|
+
const text = previous.parts.find((part) => typeof part === "object" && part !== null && ("type" in part) && part.type === "text" && ("text" in part))?.text;
|
|
9593
|
+
if (typeof text !== "string")
|
|
9594
|
+
return false;
|
|
9595
|
+
const block = `<session-history>
|
|
9596
|
+
${args.pendingCompartmentInjection.block}
|
|
9597
|
+
</session-history>`;
|
|
9598
|
+
return text !== block && !text.startsWith(`${block}
|
|
9599
|
+
|
|
9600
|
+
`);
|
|
9601
|
+
}
|
|
9218
9602
|
async function runPostTransformPhase(args) {
|
|
9219
9603
|
const tPostprocessSetup = performance.now();
|
|
9220
9604
|
const compactionOff = args.compactionOff === true;
|
|
@@ -9456,8 +9840,8 @@ async function runPostTransformPhase(args) {
|
|
|
9456
9840
|
subagentExecute: !args.fullFeatureMode && args.schedulerDecision === "execute",
|
|
9457
9841
|
hardFold: foldBustsServedPrefixThisPass || firstRenderBust || idleExpiryRebuild,
|
|
9458
9842
|
force: emergencyDropEligible && (args.contextUsage.percentage >= 95 || getEmergencyInputSample(args.db, args.sessionId) === 0),
|
|
9459
|
-
explicitFlush: isExplicitFlush
|
|
9460
|
-
publishedHistory: publishedM1RefreshedThisPass || !m0M1EnabledForFold && (args.pendingCompartmentInjection?.compartmentCount ?? 0) > 0 && (args
|
|
9843
|
+
explicitFlush: isExplicitFlush && hasPendingMaterializationOrigin(args.pendingMaterializationSessions, args.sessionId, "user_flush"),
|
|
9844
|
+
publishedHistory: !prefixPreflightFailed && (publishedM1RefreshedThisPass || !m0M1EnabledForFold && (args.pendingCompartmentInjection?.compartmentCount ?? 0) > 0 && legacyPublishedHeadChanged(args))
|
|
9461
9845
|
};
|
|
9462
9846
|
const publishedWorkDrainAllowed = !compactionOff && (!activeThinkingPrefixHold || firstRenderBust || idleExpiryRebuild || emergencyDropEligible) && hasReclaimRide(rideSignals);
|
|
9463
9847
|
const shouldApplyPendingOps = publishedWorkDrainAllowed;
|
|
@@ -10691,9 +11075,6 @@ class StorageBusyRefusalError extends Error {
|
|
|
10691
11075
|
}
|
|
10692
11076
|
}
|
|
10693
11077
|
|
|
10694
|
-
// src/hooks/magic-context/system-prompt-hash.ts
|
|
10695
|
-
import { createHash } from "node:crypto";
|
|
10696
|
-
|
|
10697
11078
|
// src/hooks/magic-context/system-prompt-dates.ts
|
|
10698
11079
|
function replaceHostDates(prompt, replace) {
|
|
10699
11080
|
const fields = /<(plugin-env|environment|env)>[\s\S]*?<\/\1>|Today's date: [^\r\n<]+/g;
|
|
@@ -10940,7 +11321,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
10940
11321
|
const dates = systemPromptDates(liveSystemContent, stickyDate);
|
|
10941
11322
|
const currentDate = dates.live;
|
|
10942
11323
|
const stableCandidate = dates.stable;
|
|
10943
|
-
const stableCandidateHash =
|
|
11324
|
+
const stableCandidateHash = systemPromptFingerprint(stableCandidate, promptSurface.preset);
|
|
10944
11325
|
const contentOrPresetChanged = hasPersistedHash && stableCandidateHash !== previousHash;
|
|
10945
11326
|
const rewritePermission = systemDateRefreshPermission(deps.historyRefreshSessions, dateRequest);
|
|
10946
11327
|
let deferredDateRefresh = false;
|
|
@@ -10954,7 +11335,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
10954
11335
|
try {
|
|
10955
11336
|
const content = liveElements.join(`
|
|
10956
11337
|
`);
|
|
10957
|
-
const hash =
|
|
11338
|
+
const hash = systemPromptFingerprint(content, promptSurface.preset);
|
|
10958
11339
|
updateSessionMeta(deps.db, sessionId, {
|
|
10959
11340
|
systemPromptHash: hash,
|
|
10960
11341
|
cachedM0SystemHash: hash,
|
|
@@ -10994,7 +11375,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
10994
11375
|
`);
|
|
10995
11376
|
if (!availability.frozen || !modelKey)
|
|
10996
11377
|
return;
|
|
10997
|
-
const currentHash =
|
|
11378
|
+
const currentHash = systemPromptFingerprint(systemContent, promptSurface.preset);
|
|
10998
11379
|
recordSystemPromptForRequest(sessionId, currentLkgRequestIdentity(sessionId), currentHash, deps.db, previousHash !== currentHash ? !deps.historyRefreshSessions.has(sessionId) : undefined, deps.historyRefreshSessions, deps.pendingMaterializationSessions);
|
|
10999
11380
|
if (!sessionMetaEarly) {
|
|
11000
11381
|
return;
|
|
@@ -11002,6 +11383,7 @@ function createSystemPromptHashHandler(deps) {
|
|
|
11002
11383
|
const sessionMeta = sessionMetaEarly;
|
|
11003
11384
|
if (previousHash !== "" && previousHash !== "0" && previousHash !== currentHash) {
|
|
11004
11385
|
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"}`);
|
|
11386
|
+
noteSystemPromptHashChange(sessionId);
|
|
11005
11387
|
if (!adoptSystemChange) {
|
|
11006
11388
|
deps.historyRefreshSessions.add(sessionId);
|
|
11007
11389
|
deps.systemPromptRefreshSessions.add(sessionId);
|
|
@@ -11054,102 +11436,6 @@ function createSystemPromptHashHandler(deps) {
|
|
|
11054
11436
|
};
|
|
11055
11437
|
}
|
|
11056
11438
|
|
|
11057
|
-
// src/features/magic-context/transform-decision-log.ts
|
|
11058
|
-
var canonicalReasons = new Set([
|
|
11059
|
-
"system_hash",
|
|
11060
|
-
"model_change",
|
|
11061
|
-
"project_memory_epoch",
|
|
11062
|
-
"ttl_idle",
|
|
11063
|
-
"explicit_flush",
|
|
11064
|
-
"user_flush",
|
|
11065
|
-
"fit_retry",
|
|
11066
|
-
"pending_materialization",
|
|
11067
|
-
"variant_change",
|
|
11068
|
-
"recomp",
|
|
11069
|
-
"boundary_repair",
|
|
11070
|
-
"host_history_change",
|
|
11071
|
-
"thinking_hold",
|
|
11072
|
-
"mutation_drift",
|
|
11073
|
-
"max_mutation_id",
|
|
11074
|
-
"first_render",
|
|
11075
|
-
"pressure_refold",
|
|
11076
|
-
"upgrade_state",
|
|
11077
|
-
"cached_m1_missing",
|
|
11078
|
-
"project_change",
|
|
11079
|
-
"compartment_render_epoch",
|
|
11080
|
-
"m1_delta",
|
|
11081
|
-
"ttl_expiry",
|
|
11082
|
-
"epoch_change",
|
|
11083
|
-
"coverage_fold",
|
|
11084
|
-
"profile_transition",
|
|
11085
|
-
"host_compaction",
|
|
11086
|
-
"tag_identity_repair"
|
|
11087
|
-
]);
|
|
11088
|
-
var piReasonAliases = {
|
|
11089
|
-
project_memory_change: "project_memory_epoch",
|
|
11090
|
-
pending_mutations: "max_mutation_id",
|
|
11091
|
-
renderer_upgrade: "upgrade_state",
|
|
11092
|
-
cache_invalid: "cached_m1_missing",
|
|
11093
|
-
drift: "pressure_refold"
|
|
11094
|
-
};
|
|
11095
|
-
var sharedReasonAliases = {
|
|
11096
|
-
model_key: "model_change",
|
|
11097
|
-
pressure: "pressure_refold"
|
|
11098
|
-
};
|
|
11099
|
-
var pendingDecisionBySession = new Map;
|
|
11100
|
-
var pendingPiDecisionBySession = new Map;
|
|
11101
|
-
var lastBoundMessageIdBySession = new Map;
|
|
11102
|
-
var scheduledWriteTokensBySession = new Map;
|
|
11103
|
-
function normalizeMaterializeReason(harness, reason, rematerialized) {
|
|
11104
|
-
const raw = typeof reason === "string" ? reason.trim() : "";
|
|
11105
|
-
if (raw.length > 0) {
|
|
11106
|
-
const alias = sharedReasonAliases[raw] ?? (harness === "pi" ? piReasonAliases[raw] : undefined) ?? undefined;
|
|
11107
|
-
if (alias)
|
|
11108
|
-
return alias;
|
|
11109
|
-
if (canonicalReasons.has(raw))
|
|
11110
|
-
return raw;
|
|
11111
|
-
return null;
|
|
11112
|
-
}
|
|
11113
|
-
return rematerialized ? "pressure_refold" : null;
|
|
11114
|
-
}
|
|
11115
|
-
function writeRustTransformDecision(args) {
|
|
11116
|
-
const rawDecision = args.decision.trim();
|
|
11117
|
-
const decisionUpper = rawDecision.toUpperCase();
|
|
11118
|
-
const mapped = decisionUpper === "HARD" || decisionUpper === "MIGRATE_HARD" ? { decision: "execute", materialized: true, bustedThisPass: true } : decisionUpper === "SOFT" || decisionUpper === "EXECUTE" || args.materializeReason === "ttl_idle" ? { decision: "execute", materialized: false, bustedThisPass: true } : decisionUpper === "SOFT+" ? { decision: "defer", materialized: false, bustedThisPass: false } : {
|
|
11119
|
-
decision: rawDecision.toLowerCase() || "unknown",
|
|
11120
|
-
materialized: false,
|
|
11121
|
-
bustedThisPass: false
|
|
11122
|
-
};
|
|
11123
|
-
pendingDecisionBySession.set(args.sessionId, {
|
|
11124
|
-
tsMs: args.tsMs ?? Date.now(),
|
|
11125
|
-
decision: mapped.decision,
|
|
11126
|
-
materialized: mapped.materialized,
|
|
11127
|
-
materializeReason: args.materializeReason,
|
|
11128
|
-
systemHashPrev: null,
|
|
11129
|
-
systemHashNew: null,
|
|
11130
|
-
m0ModelKeyPrev: null,
|
|
11131
|
-
m0ModelKeyNew: null,
|
|
11132
|
-
m0ToolSetHashPrev: null,
|
|
11133
|
-
m0ToolSetHashNew: null,
|
|
11134
|
-
emergency: false,
|
|
11135
|
-
droppedTokens: 0,
|
|
11136
|
-
droppedCount: 0,
|
|
11137
|
-
inputTokens: args.inputTokens,
|
|
11138
|
-
bustedThisPass: mapped.bustedThisPass,
|
|
11139
|
-
lkgFrozenReleaseReason: args.lkgFrozenReleaseReason
|
|
11140
|
-
});
|
|
11141
|
-
}
|
|
11142
|
-
function clearOpenCodePendingTransformDecision(sessionId) {
|
|
11143
|
-
pendingDecisionBySession.delete(sessionId);
|
|
11144
|
-
}
|
|
11145
|
-
function recordPendingTransformDecision(sessionId, decision) {
|
|
11146
|
-
if (!decision.bustedThisPass) {
|
|
11147
|
-
pendingDecisionBySession.delete(sessionId);
|
|
11148
|
-
return;
|
|
11149
|
-
}
|
|
11150
|
-
pendingDecisionBySession.set(sessionId, decision);
|
|
11151
|
-
}
|
|
11152
|
-
|
|
11153
11439
|
// src/hooks/magic-context/compaction-off-transition.ts
|
|
11154
11440
|
import { existsSync } from "node:fs";
|
|
11155
11441
|
var loggedUnverifiedMarkerCleanupRetry = false;
|
|
@@ -11296,6 +11582,16 @@ function commitCompactionModeRecord(db, sessionId, record) {
|
|
|
11296
11582
|
setCompactionModeRecord(db, sessionId, record);
|
|
11297
11583
|
}
|
|
11298
11584
|
|
|
11585
|
+
// src/hooks/magic-context/compartment-trigger-error.ts
|
|
11586
|
+
function recordCompartmentTriggerError(passOutcome, sessionId, error, log = sessionLog2) {
|
|
11587
|
+
passOutcome.record("compartment-trigger-failure");
|
|
11588
|
+
if (error instanceof RawOrdinalsNotReady2) {
|
|
11589
|
+
log(sessionId, "compartment trigger deferred: raw ordinals not ready; the next pass evaluates it again");
|
|
11590
|
+
return;
|
|
11591
|
+
}
|
|
11592
|
+
log(sessionId, "compartment trigger failed (non-fatal):", error);
|
|
11593
|
+
}
|
|
11594
|
+
|
|
11299
11595
|
// src/hooks/magic-context/pass-outcome.ts
|
|
11300
11596
|
var PASS_DEGRADATION_EFFECTS = {
|
|
11301
11597
|
"store-generation-rebase-failure": "changes-request",
|
|
@@ -11359,7 +11655,7 @@ function createPassOutcome() {
|
|
|
11359
11655
|
}
|
|
11360
11656
|
|
|
11361
11657
|
// src/hooks/magic-context/rust-mode-transform.ts
|
|
11362
|
-
import { createHash as
|
|
11658
|
+
import { createHash as createHash4, randomUUID as randomUUID2 } from "node:crypto";
|
|
11363
11659
|
|
|
11364
11660
|
// src/features/magic-context/memory/single-store-embedding-drain.ts
|
|
11365
11661
|
function isWatermarkRow(row) {
|
|
@@ -11423,7 +11719,7 @@ function advanceEmbeddedWatermark(db, projectPath, upTo) {
|
|
|
11423
11719
|
}
|
|
11424
11720
|
|
|
11425
11721
|
// src/features/magic-context/mural/source-revision.ts
|
|
11426
|
-
import { createHash
|
|
11722
|
+
import { createHash } from "node:crypto";
|
|
11427
11723
|
var statements = new WeakMap;
|
|
11428
11724
|
function muralSourceRevision(db, projectPath) {
|
|
11429
11725
|
let statement = statements.get(db);
|
|
@@ -11440,7 +11736,7 @@ function muralSourceRevision(db, projectPath) {
|
|
|
11440
11736
|
statements.set(db, statement);
|
|
11441
11737
|
}
|
|
11442
11738
|
const row = statement.get(projectPath, Date.now());
|
|
11443
|
-
return
|
|
11739
|
+
return createHash("sha256").update(row.revision).digest("hex");
|
|
11444
11740
|
}
|
|
11445
11741
|
|
|
11446
11742
|
// src/features/magic-context/install-instance-id.ts
|
|
@@ -13814,7 +14110,7 @@ function noteExternalLkgReplay(participant, sessionId, inputMessages, servedMess
|
|
|
13814
14110
|
}
|
|
13815
14111
|
|
|
13816
14112
|
// src/hooks/magic-context/rust-served-raw.ts
|
|
13817
|
-
import { createHash as
|
|
14113
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
13818
14114
|
class RustServedRawConflict extends EmergencyFailClosedError {
|
|
13819
14115
|
reason;
|
|
13820
14116
|
messageIds;
|
|
@@ -13828,7 +14124,7 @@ class RustServedRawConflict extends EmergencyFailClosedError {
|
|
|
13828
14124
|
}
|
|
13829
14125
|
function partDigest(part) {
|
|
13830
14126
|
const serialized = JSON.stringify(part);
|
|
13831
|
-
return
|
|
14127
|
+
return createHash3("sha256").update(stableStringify(serialized === undefined ? undefined : JSON.parse(serialized))).digest("hex");
|
|
13832
14128
|
}
|
|
13833
14129
|
function records(doc) {
|
|
13834
14130
|
if (doc.rustServedRaw === undefined)
|
|
@@ -14316,10 +14612,10 @@ function messageCacheSignature(message) {
|
|
|
14316
14612
|
const parts = Array.isArray(message.parts) ? message.parts : [];
|
|
14317
14613
|
const serializedParts = JSON.stringify(parts) ?? "null";
|
|
14318
14614
|
const serializedMessage = JSON.stringify(message) ?? "null";
|
|
14319
|
-
return `${messageIdOf(message) ?? ""}:${parts.length}:${Buffer.byteLength(serializedParts)}:${
|
|
14615
|
+
return `${messageIdOf(message) ?? ""}:${parts.length}:${Buffer.byteLength(serializedParts)}:${createHash4("sha256").update(serializedMessage).digest("hex")}`;
|
|
14320
14616
|
}
|
|
14321
14617
|
function advanceWireFingerprint(previous, encoded) {
|
|
14322
|
-
return
|
|
14618
|
+
return createHash4("sha256").update(previous).update("\\0").update(JSON.stringify(encoded) ?? "null").digest("hex");
|
|
14323
14619
|
}
|
|
14324
14620
|
function buildWireFingerprint(encoded) {
|
|
14325
14621
|
let fingerprint = "rust-wire-v1";
|
|
@@ -16100,7 +16396,7 @@ function createRustModeTransform(deps, options) {
|
|
|
16100
16396
|
const id = messageIdOf(message) ?? `index:${todoStart + offset}`;
|
|
16101
16397
|
const parts = message.parts?.filter((part) => isRecord4(part) && part.type === "tool" && part.tool === "todowrite");
|
|
16102
16398
|
if (parts?.length) {
|
|
16103
|
-
todoCalls.set(id,
|
|
16399
|
+
todoCalls.set(id, createHash4("sha256").update(JSON.stringify(parts)).digest("hex"));
|
|
16104
16400
|
} else {
|
|
16105
16401
|
todoCalls.delete(id);
|
|
16106
16402
|
}
|
|
@@ -17522,6 +17818,7 @@ async function runCompartmentPhaseImpl(args) {
|
|
|
17522
17818
|
ensureProjectRegistered: args.ensureProjectRegistered,
|
|
17523
17819
|
getNotificationParams: args.getNotificationParams,
|
|
17524
17820
|
experimentalUserMemories: args.experimentalUserMemories,
|
|
17821
|
+
userObservationsRequested: args.userObservationsRequested,
|
|
17525
17822
|
historianTwoPass: args.historianTwoPass,
|
|
17526
17823
|
historianExpandTools: args.historianExpandTools,
|
|
17527
17824
|
memoryEnabled: args.memoryEnabled,
|
|
@@ -17563,6 +17860,7 @@ async function runCompartmentPhaseImpl(args) {
|
|
|
17563
17860
|
ensureProjectRegistered: args.ensureProjectRegistered,
|
|
17564
17861
|
getNotificationParams: args.getNotificationParams,
|
|
17565
17862
|
experimentalUserMemories: args.experimentalUserMemories,
|
|
17863
|
+
userObservationsRequested: args.userObservationsRequested,
|
|
17566
17864
|
historianTwoPass: args.historianTwoPass,
|
|
17567
17865
|
historianExpandTools: args.historianExpandTools,
|
|
17568
17866
|
memoryEnabled: args.memoryEnabled,
|
|
@@ -17790,7 +18088,7 @@ function createTransform(deps) {
|
|
|
17790
18088
|
return historianRun?.toastDurationMs === undefined ? params : { ...params, toastDurationMs: historianRun.toastDurationMs };
|
|
17791
18089
|
};
|
|
17792
18090
|
beginLkgPass(sessionId);
|
|
17793
|
-
clearOpenCodePendingTransformDecision(sessionId);
|
|
18091
|
+
clearOpenCodePendingTransformDecision(sessionId, messages);
|
|
17794
18092
|
const db = deps.db;
|
|
17795
18093
|
try {
|
|
17796
18094
|
const tPrepare = performance.now();
|
|
@@ -18157,9 +18455,10 @@ function createTransform(deps) {
|
|
|
18157
18455
|
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;
|
|
18158
18456
|
const boundaryUsageForProtectedTail = persistedUsageFreshForBoundary ?? contextUsageEarly;
|
|
18159
18457
|
const boundaryUsageSource = persistedUsageFreshForBoundary ? "persisted" : "live";
|
|
18160
|
-
const historyPolicyIdentity = historyBudgetPolicyIdentity(deps.historyBudgetPercentage, deps.executeThresholdPercentage, currentModelKeyForBoundary, deps.executeThresholdTokens);
|
|
18161
18458
|
const historyContextLimit = resolvedContextLimit ?? (currentModelKeyForBoundary && persistedUsageBeforeResets?.lastObservedModelKey && piModelRefToCanonical(currentModelKeyForBoundary) === piModelRefToCanonical(persistedUsageBeforeResets.lastObservedModelKey) && persistedUsageBeforeResets.lastUsageContextLimit > 0 ? persistedUsageBeforeResets.lastUsageContextLimit : undefined);
|
|
18162
|
-
const
|
|
18459
|
+
const memoryProjectDirectory = compartmentDirectory || process.cwd();
|
|
18460
|
+
const renderOptions = createM0RenderOptions(deps, contextUsageEarly, currentModelKeyForBoundary, historyContextLimit, deps.memoryConfig?.enabled ? resolveProjectIdentityForSession(memoryProjectDirectory, deps.allowHomeProject) : undefined);
|
|
18461
|
+
const { historyBudgetTokens, projectPath: projectIdentity } = renderOptions;
|
|
18163
18462
|
const emergencyCeilingLimit = thresholdContextLimit ?? 0;
|
|
18164
18463
|
const emergencyCeilingTokens = Number.isFinite(emergencyCeilingLimit) && emergencyCeilingLimit > 0 ? Math.floor(emergencyCeilingLimit * (effectiveExecuteThresholdPercentage / 100)) : undefined;
|
|
18165
18464
|
const schedulerDecision = compactionOff ? "defer" : resolveSchedulerDecision(deps.scheduler, sessionMeta, contextUsageEarly, sessionId, deps.getModelKey?.(sessionId), resolvedContextLimit);
|
|
@@ -18257,6 +18556,7 @@ function createTransform(deps) {
|
|
|
18257
18556
|
fallbackModelId,
|
|
18258
18557
|
getNotificationParams: () => notificationParams,
|
|
18259
18558
|
experimentalUserMemories: historianRun?.userMemoriesEnabled ?? deps.experimentalUserMemories,
|
|
18559
|
+
userObservationsRequested: historianRun?.userObservationsRequested ?? deps.userObservationsRequested,
|
|
18260
18560
|
experimentalTemporalAwareness: deps.experimentalTemporalAwareness,
|
|
18261
18561
|
historianTwoPass: historianRun?.twoPass ?? deps.historianTwoPass,
|
|
18262
18562
|
historianExpandTools: historianRun?.expandTools ?? deps.historianExpandTools,
|
|
@@ -18293,8 +18593,6 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
18293
18593
|
});
|
|
18294
18594
|
}
|
|
18295
18595
|
logTransformTiming(sessionId, "emergencyRecoveryBlock", tFirstPass);
|
|
18296
|
-
const memoryProjectDirectory = compartmentDirectory || process.cwd();
|
|
18297
|
-
const projectIdentity = deps.memoryConfig?.enabled ? resolveProjectIdentityForSession(memoryProjectDirectory, deps.allowHomeProject) : undefined;
|
|
18298
18596
|
if (deps.memoryConfig?.enabled) {
|
|
18299
18597
|
maybeSendProjectIdentityWarning(deps, sessionId, memoryProjectDirectory, notificationParams);
|
|
18300
18598
|
}
|
|
@@ -18314,6 +18612,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
18314
18612
|
sessionLog2(sessionId, `tag floor: 0 (full-scan fallback) — no leading wire message resolved a tag across ${messages.length} msgs`);
|
|
18315
18613
|
}
|
|
18316
18614
|
const ownerRatio = sessionDecisionCalibration(db, sessionId).proseRatio;
|
|
18615
|
+
noteTransformPassForExactOrdinalReads(sessionId);
|
|
18317
18616
|
prewarmTagOwners(db, sessionId, ownerRatio);
|
|
18318
18617
|
const tagOwnersReady = isTagOwnerSummaryReady2(db, sessionId, ownerRatio);
|
|
18319
18618
|
let triggerBoundarySnapshot;
|
|
@@ -18337,8 +18636,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
18337
18636
|
triggerBoundarySnapshot = triggerResult.boundarySnapshot;
|
|
18338
18637
|
}
|
|
18339
18638
|
} catch (error) {
|
|
18340
|
-
passOutcome
|
|
18341
|
-
sessionLog2(sessionId, "compartment trigger failed (non-fatal):", error);
|
|
18639
|
+
recordCompartmentTriggerError(passOutcome, sessionId, error);
|
|
18342
18640
|
}
|
|
18343
18641
|
logTransformTiming(sessionId, "compartmentTrigger", tTrigger);
|
|
18344
18642
|
}
|
|
@@ -18529,6 +18827,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
18529
18827
|
safeForBackgroundCompression: historianRunnable && (isCacheBusting || schedulerDecision === "execute"),
|
|
18530
18828
|
deferredHistoryRefreshSessions,
|
|
18531
18829
|
experimentalUserMemories: historianRun?.userMemoriesEnabled ?? deps.experimentalUserMemories,
|
|
18830
|
+
userObservationsRequested: historianRun?.userObservationsRequested ?? deps.userObservationsRequested,
|
|
18532
18831
|
experimentalTemporalAwareness: deps.experimentalTemporalAwareness,
|
|
18533
18832
|
historianTwoPass: historianRun?.twoPass ?? deps.historianTwoPass,
|
|
18534
18833
|
historianExpandTools: historianRun?.expandTools ?? deps.historianExpandTools,
|
|
@@ -18579,14 +18878,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
18579
18878
|
db,
|
|
18580
18879
|
sessionId,
|
|
18581
18880
|
state: sessionMeta,
|
|
18582
|
-
projectPath: projectIdentity,
|
|
18583
18881
|
projectDirectory: sessionDirectory,
|
|
18584
|
-
|
|
18585
|
-
memoryEnabled: deps.memoryConfig?.enabled,
|
|
18586
|
-
muralEnabled: deps.muralEnabled,
|
|
18587
|
-
memoryInjectionBudgetTokens: deps.memoryConfig?.injectionBudgetTokens,
|
|
18588
|
-
historyBudgetTokens,
|
|
18589
|
-
historyBudgetPolicyIdentity: historyPolicyIdentity,
|
|
18882
|
+
...renderOptions,
|
|
18590
18883
|
hardSignals: m0HardSignals
|
|
18591
18884
|
}).value;
|
|
18592
18885
|
const protectionCacheBustingPass = !compactionOff && (schedulerDecision === "execute" || isCacheBusting || contextUsage.percentage >= forceMaterializationPercentage || deps.pendingMaterializationSessions.has(sessionId) || canConsumeDeferredLate && deferredMaterializationSessions.has(sessionId) || protectionFoldWillBust);
|
|
@@ -18727,16 +19020,9 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
18727
19020
|
passOutcome,
|
|
18728
19021
|
historyRefreshSessions: deps.historyRefreshSessions,
|
|
18729
19022
|
m0M1: {
|
|
18730
|
-
projectPath: projectIdentity,
|
|
18731
19023
|
projectDirectory: sessionDirectory,
|
|
18732
|
-
|
|
18733
|
-
|
|
18734
|
-
memoryInjectionBudgetTokens: deps.memoryConfig?.injectionBudgetTokens,
|
|
18735
|
-
historyBudgetTokens,
|
|
18736
|
-
historyBudgetPolicyIdentity: historyPolicyIdentity,
|
|
18737
|
-
temporalAwareness: deps.experimentalTemporalAwareness,
|
|
18738
|
-
hardSignals: m0HardSignals,
|
|
18739
|
-
muralEnabled: deps.muralEnabled
|
|
19024
|
+
...renderOptions,
|
|
19025
|
+
hardSignals: m0HardSignals
|
|
18740
19026
|
}
|
|
18741
19027
|
});
|
|
18742
19028
|
if (recovery.prefix && !recoveryNormalized) {
|
|
@@ -18980,6 +19266,24 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
18980
19266
|
bustedThisPass: true,
|
|
18981
19267
|
lkgFrozenReleaseReason: recoveryReleaseReason
|
|
18982
19268
|
});
|
|
19269
|
+
} else {
|
|
19270
|
+
noteOpenCodeUnbustedPass(sessionId, {
|
|
19271
|
+
tsMs: Date.now(),
|
|
19272
|
+
decision: schedulerDecision,
|
|
19273
|
+
materialized: postTransformResult.materialized,
|
|
19274
|
+
materializeReason: normalizeMaterializeReason("opencode", postTransformResult.materializeReason, postTransformResult.materialized),
|
|
19275
|
+
systemHashPrev: postTransformResult.systemHashPrev,
|
|
19276
|
+
systemHashNew: postTransformResult.systemHashNew,
|
|
19277
|
+
m0ToolSetHashPrev: postTransformResult.m0ToolSetHashPrev,
|
|
19278
|
+
m0ToolSetHashNew: postTransformResult.m0ToolSetHashNew,
|
|
19279
|
+
m0ModelKeyPrev: postTransformResult.m0ModelKeyPrev,
|
|
19280
|
+
m0ModelKeyNew: postTransformResult.m0ModelKeyNew,
|
|
19281
|
+
emergency: postTransformResult.emergency,
|
|
19282
|
+
droppedTokens: postTransformResult.droppedTokens,
|
|
19283
|
+
droppedCount: postTransformResult.droppedCount,
|
|
19284
|
+
inputTokens: contextUsage.inputTokens,
|
|
19285
|
+
bustedThisPass: false
|
|
19286
|
+
});
|
|
18983
19287
|
}
|
|
18984
19288
|
logTransformTiming(sessionId, "postTransformPhase", tPostProcess);
|
|
18985
19289
|
const msgTokens = getMessageTokensCache(sessionId);
|
|
@@ -19110,24 +19414,14 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
|
|
|
19110
19414
|
}
|
|
19111
19415
|
});
|
|
19112
19416
|
}
|
|
19113
|
-
|
|
19114
|
-
|
|
19115
|
-
|
|
19116
|
-
|
|
19117
|
-
let contextLimit = resolvedContextLimit && resolvedContextLimit > 0 ? resolvedContextLimit : 0;
|
|
19118
|
-
if (contextLimit <= 0) {
|
|
19119
|
-
if (contextUsage.percentage <= 0) {
|
|
19120
|
-
return;
|
|
19121
|
-
}
|
|
19122
|
-
contextLimit = contextUsage.inputTokens / (contextUsage.percentage / 100);
|
|
19123
|
-
}
|
|
19124
|
-
if (!Number.isFinite(contextLimit) || contextLimit <= 0) {
|
|
19417
|
+
|
|
19418
|
+
// src/plugin/dream-timer-module-client.ts
|
|
19419
|
+
function createDreamTimerModuleClient(moduleClient) {
|
|
19420
|
+
if (!moduleClient)
|
|
19125
19421
|
return;
|
|
19126
|
-
|
|
19127
|
-
|
|
19128
|
-
|
|
19129
|
-
contextLimit
|
|
19130
|
-
}) / 100) * historyBudgetPercentage);
|
|
19422
|
+
return {
|
|
19423
|
+
call: (args) => moduleClient.call(args)
|
|
19424
|
+
};
|
|
19131
19425
|
}
|
|
19132
19426
|
|
|
19133
19427
|
// src/shared/recovery-reasoning-prefix.ts
|
|
@@ -20762,7 +21056,7 @@ function computeOpenCodeWorkMetricsIncremental(openCodeDb, sessionId, carry) {
|
|
|
20762
21056
|
import { readFileSync, statSync } from "node:fs";
|
|
20763
21057
|
|
|
20764
21058
|
// src/plugin/embedding-bootstrap-helpers.ts
|
|
20765
|
-
import { createHash as
|
|
21059
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
20766
21060
|
var EMBEDDING_AFFECTING_KEYS = new Set([
|
|
20767
21061
|
"embedding.api_key",
|
|
20768
21062
|
"embedding.endpoint",
|
|
@@ -20810,7 +21104,7 @@ var EMBEDDING_WARNING_TERMS = [
|
|
|
20810
21104
|
];
|
|
20811
21105
|
var loggedFailureSignatures = new Map;
|
|
20812
21106
|
function sha256Prefix(value, length = 16) {
|
|
20813
|
-
return
|
|
21107
|
+
return createHash5("sha256").update(value).digest("hex").slice(0, length);
|
|
20814
21108
|
}
|
|
20815
21109
|
function warningLooksEmbeddingRelated(message) {
|
|
20816
21110
|
const lower = message.toLowerCase();
|
|
@@ -22265,9 +22559,9 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22265
22559
|
return { count: buildCompartmentCount(db, sessionId, moduleStatus) };
|
|
22266
22560
|
});
|
|
22267
22561
|
const buildManagedCtx = async (db) => {
|
|
22268
|
-
const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-
|
|
22562
|
+
const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-z25jw3py.js"));
|
|
22269
22563
|
const { resolveHistorianModel } = await importPluginModule(() => import("./model-resolution-nx97z3x7.js"));
|
|
22270
|
-
const {
|
|
22564
|
+
const { userObservationCollectionEnabled, userObservationsRequested } = await importPluginModule(() => import("./task-config-nvz8mapa.js"));
|
|
22271
22565
|
const DEFAULT_HISTORIAN_TIMEOUT_MS = 10 * 60 * 1000;
|
|
22272
22566
|
const runConfig = historianRunConfig(config, currentPluginConfigReader(directory)?.poll().effective ?? config);
|
|
22273
22567
|
const historianModel = resolveHistorianModel(runConfig, "opencode");
|
|
@@ -22285,7 +22579,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22285
22579
|
autoPromote: runConfig.memory?.auto_promote ?? true,
|
|
22286
22580
|
historianModel: historianModel.primary,
|
|
22287
22581
|
fallbackModels: historianModel.fallbacks,
|
|
22288
|
-
userMemoriesEnabled:
|
|
22582
|
+
userMemoriesEnabled: userObservationCollectionEnabled(runConfig.dreamer),
|
|
22583
|
+
userObservationsRequested: userObservationsRequested(runConfig.dreamer),
|
|
22289
22584
|
historianTwoPass: runConfig.historian?.two_pass === true,
|
|
22290
22585
|
historianExpandTools: runConfig.historian?.expand_tools,
|
|
22291
22586
|
getNotificationParams: (sessionId) => getLiveNotificationParams(sessionId, liveSessionState.liveModelBySession, liveSessionState.variantBySession, liveSessionState.agentBySession, runConfig.toast_duration_ms)
|
|
@@ -22297,7 +22592,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22297
22592
|
return { ok: false, error: "no session" };
|
|
22298
22593
|
const readDirectory = args.readSessionDirectory;
|
|
22299
22594
|
if (readDirectory) {
|
|
22300
|
-
const { handoffHistoryWork } = await import("./history-owner-
|
|
22595
|
+
const { handoffHistoryWork } = await import("./history-owner-42e16w0n.js");
|
|
22301
22596
|
const handed = await handoffHistoryWork({
|
|
22302
22597
|
storageDir: args.storageDir ?? getMagicContextStorageDir(),
|
|
22303
22598
|
directory,
|
|
@@ -22316,8 +22611,8 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22316
22611
|
const db = readDatabase();
|
|
22317
22612
|
if (!db)
|
|
22318
22613
|
return { ok: false, error: "db unavailable" };
|
|
22319
|
-
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-
|
|
22320
|
-
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-
|
|
22614
|
+
const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-8w3449eb.js"));
|
|
22615
|
+
const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-jevgj9fe.js"));
|
|
22321
22616
|
log2(`[rpc] recomp requested for session ${sessionId}`);
|
|
22322
22617
|
if (!args.client && !args.hiddenCompletionExecutor) {
|
|
22323
22618
|
return {
|
|
@@ -22375,7 +22670,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22375
22670
|
rpcServer.handle("wrapup", async (params) => {
|
|
22376
22671
|
const readDirectory = args.readSessionDirectory;
|
|
22377
22672
|
if (readDirectory && params.sessionId) {
|
|
22378
|
-
const { handoffHistoryWork } = await import("./history-owner-
|
|
22673
|
+
const { handoffHistoryWork } = await import("./history-owner-42e16w0n.js");
|
|
22379
22674
|
const sessionId = String(params.sessionId);
|
|
22380
22675
|
const handed = await handoffHistoryWork({
|
|
22381
22676
|
storageDir: args.storageDir ?? getMagicContextStorageDir(),
|
|
@@ -22401,7 +22696,7 @@ function registerRpcHandlers(rpcServer, args) {
|
|
|
22401
22696
|
const db = readDatabase();
|
|
22402
22697
|
if (!db)
|
|
22403
22698
|
return { ok: false, error: "db unavailable" };
|
|
22404
|
-
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-
|
|
22699
|
+
const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-r82y780v.js"));
|
|
22405
22700
|
const model = liveSessionState.liveModelBySession.get(sessionId);
|
|
22406
22701
|
const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
|
|
22407
22702
|
const ctx = {
|
|
@@ -23390,8 +23685,8 @@ function hostMediaFromEncoded(value) {
|
|
|
23390
23685
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
23391
23686
|
|
|
23392
23687
|
// src/v2/fold/owner.ts
|
|
23393
|
-
import { createHash as
|
|
23394
|
-
var foldDigest = (value) =>
|
|
23688
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
23689
|
+
var foldDigest = (value) => createHash6("sha256").update(value).digest("hex");
|
|
23395
23690
|
|
|
23396
23691
|
class FoldOwner {
|
|
23397
23692
|
storage;
|
|
@@ -23834,7 +24129,7 @@ function rebuildFileContent(value, output, attachments) {
|
|
|
23834
24129
|
rebuilt.unshift({ type: "text", text: output });
|
|
23835
24130
|
return { type: "content", value: rebuilt };
|
|
23836
24131
|
}
|
|
23837
|
-
function adaptPayload(draft, admittedIDs = new Set) {
|
|
24132
|
+
function adaptPayload(draft, admittedIDs = new Set, messageTimes = new Map) {
|
|
23838
24133
|
const existingHeads = new Map(draft.messages.filter((m) => HEAD_IDS.some((id) => m.id === id)).map((m) => [m.id, m]));
|
|
23839
24134
|
const source = draft.messages.filter((m) => !existingHeads.has(m.id));
|
|
23840
24135
|
const results = new Map;
|
|
@@ -23944,6 +24239,7 @@ function adaptPayload(draft, admittedIDs = new Set) {
|
|
|
23944
24239
|
id: message.id,
|
|
23945
24240
|
sessionID: draft.sessionID,
|
|
23946
24241
|
role: message.role,
|
|
24242
|
+
time: message.id ? messageTimes.get(message.id) : undefined,
|
|
23947
24243
|
...{
|
|
23948
24244
|
providerID: draft.model.providerID,
|
|
23949
24245
|
modelID: draft.model.id,
|
|
@@ -25999,11 +26295,11 @@ class DeletedSessionTombstones {
|
|
|
25999
26295
|
}
|
|
26000
26296
|
|
|
26001
26297
|
// src/features/magic-context/dreamer/task-executor.ts
|
|
26002
|
-
import { createHash as
|
|
26298
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
26003
26299
|
import { existsSync as existsSync7, readFileSync as readFileSync8 } from "node:fs";
|
|
26004
26300
|
|
|
26005
26301
|
// src/features/magic-context/mural/compress-cues.ts
|
|
26006
|
-
import { createHash as
|
|
26302
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
26007
26303
|
|
|
26008
26304
|
// src/features/magic-context/dreamer/storage-dream-state.ts
|
|
26009
26305
|
var getDreamStateStatements = new WeakMap;
|
|
@@ -26733,7 +27029,7 @@ async function applyCuesThroughModule(args, chunk, manifestText, signal) {
|
|
|
26733
27029
|
log2(`[dreamer] compress-cues: skipped cue for memory ${entry.id} (${failure.reason}; rejection ${rejectionCount}/${CUE_REJECTION_LATCH_THRESHOLD})`);
|
|
26734
27030
|
}
|
|
26735
27031
|
}
|
|
26736
|
-
const commandId = `mural-cues:${route.moduleCommandId}:${
|
|
27032
|
+
const commandId = `mural-cues:${route.moduleCommandId}:${createHash7("sha256").update(chunk.map((candidate) => candidate.memory.id).join(",")).digest("hex").slice(0, 24)}`;
|
|
26737
27033
|
let response;
|
|
26738
27034
|
try {
|
|
26739
27035
|
response = await route.moduleClient.call({
|
|
@@ -27321,7 +27617,7 @@ function applyReviewVerdict(args, leaseKey, parsed, result) {
|
|
|
27321
27617
|
}
|
|
27322
27618
|
|
|
27323
27619
|
// src/features/magic-context/dreamer/classify.ts
|
|
27324
|
-
import { createHash as
|
|
27620
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
27325
27621
|
|
|
27326
27622
|
// src/plugin/rust-tool-backends.ts
|
|
27327
27623
|
function isRustAuthorityDrainingError(error) {
|
|
@@ -27758,7 +28054,7 @@ async function runClassifyThroughModule(args, chunk, anchors, signal, runOnHost)
|
|
|
27758
28054
|
if (entry.qualifier)
|
|
27759
28055
|
modelVariants[entry.model] = entry.qualifier;
|
|
27760
28056
|
}
|
|
27761
|
-
const commandId = `classify:${args.moduleCommandId ?? Date.now()}:${
|
|
28057
|
+
const commandId = `classify:${args.moduleCommandId ?? Date.now()}:${createHash8("sha256").update(chunk.map((candidate) => candidate.id).join(",")).digest("hex").slice(0, 24)}`;
|
|
27762
28058
|
const runTask = (hostCompletion) => args.moduleClient?.call({
|
|
27763
28059
|
sessionId: args.moduleSessionId,
|
|
27764
28060
|
projectRoot: args.moduleProjectRoot,
|
|
@@ -28033,7 +28329,7 @@ function takeCurateSafetyRefusalCount(sessionId) {
|
|
|
28033
28329
|
|
|
28034
28330
|
// src/features/magic-context/dreamer/docs-proposals.ts
|
|
28035
28331
|
import { execFileSync } from "node:child_process";
|
|
28036
|
-
import { createHash as
|
|
28332
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
28037
28333
|
import {
|
|
28038
28334
|
existsSync as existsSync4,
|
|
28039
28335
|
mkdirSync,
|
|
@@ -28048,7 +28344,7 @@ import {
|
|
|
28048
28344
|
import { tmpdir } from "node:os";
|
|
28049
28345
|
import { join as join7 } from "node:path";
|
|
28050
28346
|
var FILES = ["ARCHITECTURE.md", "STRUCTURE.md"];
|
|
28051
|
-
var hash = (text) =>
|
|
28347
|
+
var hash = (text) => createHash9("sha256").update(text).digest("hex");
|
|
28052
28348
|
var proposalDir = (projectDir) => join7(projectDir, ".cortexkit/magic-context/docs-update-proposals");
|
|
28053
28349
|
function docsBaseHashes(projectDir) {
|
|
28054
28350
|
return Object.fromEntries(FILES.map((name) => [
|
|
@@ -28584,7 +28880,7 @@ function throwIfAborted2(signal) {
|
|
|
28584
28880
|
}
|
|
28585
28881
|
|
|
28586
28882
|
// src/features/magic-context/smart-notes/compiler.ts
|
|
28587
|
-
import { createHash as
|
|
28883
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
28588
28884
|
|
|
28589
28885
|
// src/features/magic-context/smart-notes/compiler-prompt.ts
|
|
28590
28886
|
var SMART_NOTE_COMPILER_SYSTEM_PROMPT = `You are the Magic Context smart-note compiler for the magic-context system.
|
|
@@ -28923,7 +29219,7 @@ function manifestAdvisoryWarnings(code, manifest) {
|
|
|
28923
29219
|
return warnings;
|
|
28924
29220
|
}
|
|
28925
29221
|
function hashCheck(surfaceCondition, compiledCheck, manifest, checkCron) {
|
|
28926
|
-
return
|
|
29222
|
+
return createHash10("sha256").update(surfaceCondition ?? "").update("\x00").update(compiledCheck).update("\x00").update(JSON.stringify(manifest)).update("\x00").update(checkCron).digest("hex");
|
|
28927
29223
|
}
|
|
28928
29224
|
function extractJsonObject(output) {
|
|
28929
29225
|
const fenced = output.match(/```(?:json)?\s*([\s\S]*?)```/i);
|
|
@@ -29689,7 +29985,7 @@ function snapshotMaintainDocsFiles(docsDir) {
|
|
|
29689
29985
|
}
|
|
29690
29986
|
|
|
29691
29987
|
// src/features/magic-context/dreamer/map-memories.ts
|
|
29692
|
-
import { createHash as
|
|
29988
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
29693
29989
|
|
|
29694
29990
|
// src/features/magic-context/dreamer/map-memories-prompt.ts
|
|
29695
29991
|
import { execFile as execFile2 } from "node:child_process";
|
|
@@ -29924,7 +30220,7 @@ function readRetries(db, project) {
|
|
|
29924
30220
|
}
|
|
29925
30221
|
}
|
|
29926
30222
|
function contentKey2(memory) {
|
|
29927
|
-
return
|
|
30223
|
+
return createHash11("sha256").update(`${memory.category}
|
|
29928
30224
|
${memory.content}`).digest("hex");
|
|
29929
30225
|
}
|
|
29930
30226
|
function isDeferred(memory, retries) {
|
|
@@ -30323,7 +30619,7 @@ async function applyParsedBatchMappings(args, batch, parsed, budgetFinalized = f
|
|
|
30323
30619
|
name: "memory.set_mapping",
|
|
30324
30620
|
arguments: {
|
|
30325
30621
|
memory_project: args.projectIdentity,
|
|
30326
|
-
command_id: `${args.moduleRoute.moduleCommandId}:${
|
|
30622
|
+
command_id: `${args.moduleRoute.moduleCommandId}:${createHash11("sha256").update(rows.map((row) => row.memory_id).join(",")).digest("hex").slice(0, 16)}`,
|
|
30327
30623
|
rows
|
|
30328
30624
|
}
|
|
30329
30625
|
}
|
|
@@ -31604,7 +31900,7 @@ function insertDreamRun(db, run) {
|
|
|
31604
31900
|
}
|
|
31605
31901
|
|
|
31606
31902
|
// src/features/magic-context/dreamer/verify.ts
|
|
31607
|
-
import { createHash as
|
|
31903
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
31608
31904
|
|
|
31609
31905
|
// src/features/magic-context/dreamer/verify-diff.ts
|
|
31610
31906
|
import { execFile as execFile3 } from "node:child_process";
|
|
@@ -32348,7 +32644,7 @@ async function applyParsedVerifyManifest(args, batch, parsed, headAtPrompt, budg
|
|
|
32348
32644
|
name: "memory.set_verification",
|
|
32349
32645
|
arguments: {
|
|
32350
32646
|
memory_project: args.projectIdentity,
|
|
32351
|
-
command_id: `${args.moduleRoute.moduleCommandId}:${
|
|
32647
|
+
command_id: `${args.moduleRoute.moduleCommandId}:${createHash12("sha256").update(rows.map((row) => row.memory_id).join(",")).digest("hex").slice(0, 16)}`,
|
|
32352
32648
|
rows
|
|
32353
32649
|
}
|
|
32354
32650
|
}
|
|
@@ -33154,7 +33450,7 @@ function parseFrictionGateVerdict(verdict) {
|
|
|
33154
33450
|
}
|
|
33155
33451
|
function computeRetrospectiveWindowKey(flagged) {
|
|
33156
33452
|
const anchors = flagged.map((message) => `${message.sessionId}:${message.ts}`).sort().join("|");
|
|
33157
|
-
return
|
|
33453
|
+
return createHash13("sha256").update(anchors).digest("hex").slice(0, 32);
|
|
33158
33454
|
}
|
|
33159
33455
|
function renderFrictionWindow(messages, flaggedOrdinals, radius = 2) {
|
|
33160
33456
|
const flagged = new Set(flaggedOrdinals);
|
|
@@ -33868,6 +34164,12 @@ function pruneIdleScheduleIdentities(db, now) {
|
|
|
33868
34164
|
|
|
33869
34165
|
// src/features/magic-context/dreamer/task-scheduler.ts
|
|
33870
34166
|
var MAX_TASK_RETRIES = 3;
|
|
34167
|
+
function tasksAllowedBySettings(deps) {
|
|
34168
|
+
return deps.tasks.filter((config) => dreamTaskAllowedBySettings(config.task, {
|
|
34169
|
+
projectMemoryEnabled: deps.projectMemoryEnabled,
|
|
34170
|
+
smartNotesEnabled: deps.smartNotesEnabled
|
|
34171
|
+
}));
|
|
34172
|
+
}
|
|
33871
34173
|
function ensureSeeded(db, projectIdentity, config, now) {
|
|
33872
34174
|
if (getTaskScheduleState(db, projectIdentity, config.task))
|
|
33873
34175
|
return;
|
|
@@ -34086,16 +34388,17 @@ async function runManualDream(deps) {
|
|
|
34086
34388
|
};
|
|
34087
34389
|
if (!isUsableProjectIdentity(deps.projectIdentity))
|
|
34088
34390
|
return result;
|
|
34391
|
+
const allowed = tasksAllowedBySettings(deps);
|
|
34089
34392
|
let selected;
|
|
34090
34393
|
let forceGate = false;
|
|
34091
34394
|
if (deps.task) {
|
|
34092
|
-
const cfg =
|
|
34395
|
+
const cfg = allowed.find((t) => t.task === deps.task);
|
|
34093
34396
|
if (!cfg)
|
|
34094
34397
|
return result;
|
|
34095
34398
|
selected = [cfg];
|
|
34096
34399
|
forceGate = true;
|
|
34097
34400
|
} else {
|
|
34098
|
-
selected =
|
|
34401
|
+
selected = allowed.filter((t) => t.schedule.trim() !== "");
|
|
34099
34402
|
}
|
|
34100
34403
|
if (selected.length === 0)
|
|
34101
34404
|
return result;
|
|
@@ -34162,10 +34465,11 @@ async function runManualDream(deps) {
|
|
|
34162
34465
|
async function runDueTasksForProject(deps) {
|
|
34163
34466
|
if (!isUsableProjectIdentity(deps.projectIdentity))
|
|
34164
34467
|
return 0;
|
|
34165
|
-
|
|
34468
|
+
const tasks = tasksAllowedBySettings(deps);
|
|
34469
|
+
if (tasks.length === 0)
|
|
34166
34470
|
return 0;
|
|
34167
34471
|
const now = deps.now ?? Date.now();
|
|
34168
|
-
const due = planDueTasks(deps.db, deps.projectIdentity,
|
|
34472
|
+
const due = planDueTasks(deps.db, deps.projectIdentity, tasks, now);
|
|
34169
34473
|
if (due.length === 0)
|
|
34170
34474
|
return 0;
|
|
34171
34475
|
const gated = [];
|
|
@@ -34301,6 +34605,8 @@ async function runManualDreamNow(args) {
|
|
|
34301
34605
|
const summary = await runManualDream({
|
|
34302
34606
|
db: args.db,
|
|
34303
34607
|
projectIdentity: args.projectIdentity,
|
|
34608
|
+
projectMemoryEnabled: args.memoryEnabled,
|
|
34609
|
+
smartNotesEnabled: args.smartNotesEnabled,
|
|
34304
34610
|
tasks: selection.runnable,
|
|
34305
34611
|
executor,
|
|
34306
34612
|
...args.task !== undefined ? { task: args.task } : {}
|
|
@@ -34686,7 +34992,7 @@ function scheduleInitialProjectRun(reg, db) {
|
|
|
34686
34992
|
async function runProjectMaintenance(reg, origin, db) {
|
|
34687
34993
|
const sampled = reg.sampleDreamRun?.();
|
|
34688
34994
|
const current = sampled ? { ...reg, ...sampled } : reg;
|
|
34689
|
-
const projectMaintenanceEnabled = Boolean(current.dreamerConfig && current.dreamerConfig.disable !== true) || reg.memoryEnabled === true ||
|
|
34995
|
+
const projectMaintenanceEnabled = Boolean(current.dreamerConfig && current.dreamerConfig.disable !== true) || reg.memoryEnabled === true || current.gitCommitIndexing?.enabled === true || reg.historianChildSweep !== undefined;
|
|
34690
34996
|
if (!projectMaintenanceEnabled)
|
|
34691
34997
|
return;
|
|
34692
34998
|
await reg.ensureRegistered(reg.directory, db);
|
|
@@ -34697,7 +35003,7 @@ async function runProjectMaintenance(reg, origin, db) {
|
|
|
34697
35003
|
log2(`[magic-context] proactively embedded ${embeddedCount} ${embeddedCount === 1 ? "memory" : "memories"} for project ${reg.projectIdentity}`);
|
|
34698
35004
|
}
|
|
34699
35005
|
}
|
|
34700
|
-
await sweepProject(current, origin, db);
|
|
35006
|
+
await sweepProject(current, origin, db, current.gitCommitIndexing?.enabled === true);
|
|
34701
35007
|
}
|
|
34702
35008
|
async function sweepProject(reg, origin, db, gitCommitEnabled) {
|
|
34703
35009
|
if (!directoryStillExists(reg.directory)) {
|
|
@@ -34778,7 +35084,8 @@ async function sweepProject(reg, origin, db, gitCommitEnabled) {
|
|
|
34778
35084
|
projectIdentity: reg.projectIdentity,
|
|
34779
35085
|
tasks: runtimeConfigs,
|
|
34780
35086
|
executor,
|
|
34781
|
-
projectMemoryEnabled: reg.memoryEnabled !== false
|
|
35087
|
+
projectMemoryEnabled: reg.memoryEnabled !== false,
|
|
35088
|
+
smartNotesEnabled: reg.smartNotesEnabled
|
|
34782
35089
|
});
|
|
34783
35090
|
if (ran > 0) {
|
|
34784
35091
|
log2(`[dreamer] timer tick (${origin}) ${reg.projectIdentity} — ran ${ran} task(s)`);
|
|
@@ -34934,7 +35241,11 @@ function registerV2DreamScheduleTimer(args) {
|
|
|
34934
35241
|
dreamerConfig: dreamer,
|
|
34935
35242
|
sampleDreamRun: () => {
|
|
34936
35243
|
const current = dreamerRunConfig(config, args.liveConfig());
|
|
34937
|
-
return {
|
|
35244
|
+
return {
|
|
35245
|
+
dreamerConfig: current.dreamer ?? dreamer,
|
|
35246
|
+
mural: current.mural,
|
|
35247
|
+
gitCommitIndexing: current.memory.git_commit_indexing
|
|
35248
|
+
};
|
|
34938
35249
|
},
|
|
34939
35250
|
validateTaskModels: (tasks) => selectRunnableDreamTasks({ tasks, toolsSupported: executor.capabilities.tools }).runnable,
|
|
34940
35251
|
language: config.language,
|
|
@@ -34944,6 +35255,8 @@ function registerV2DreamScheduleTimer(args) {
|
|
|
34944
35255
|
retinaHandoff: config.smart_notes.retina_handoff,
|
|
34945
35256
|
smartNotesEnabled: config.smart_notes.enabled,
|
|
34946
35257
|
embeddingConfig: config.embedding,
|
|
35258
|
+
transformMode: config.transform_mode,
|
|
35259
|
+
moduleClient: createDreamTimerModuleClient(args.rustModeModuleClient),
|
|
34947
35260
|
gitCommitIndexing: gitCommitIndexing?.enabled ? {
|
|
34948
35261
|
enabled: true,
|
|
34949
35262
|
since_days: gitCommitIndexing.since_days,
|
|
@@ -35010,6 +35323,7 @@ function startDreamTrigger(context, args) {
|
|
|
35010
35323
|
db,
|
|
35011
35324
|
projectIdentity: args.projectIdentity(),
|
|
35012
35325
|
projectMemoryEnabled: args.projectMemoryEnabled,
|
|
35326
|
+
smartNotesEnabled: args.smartNotesEnabled,
|
|
35013
35327
|
tasks: runnable,
|
|
35014
35328
|
executor: createDreamTaskExecutor({
|
|
35015
35329
|
hiddenCompletionExecutor: args.executor,
|
|
@@ -35019,6 +35333,10 @@ function startDreamTrigger(context, args) {
|
|
|
35019
35333
|
retrospectiveRawProvider: (db) => new V2RetrospectiveRawProvider(db),
|
|
35020
35334
|
language: args.language,
|
|
35021
35335
|
mural: sampled?.mural ?? args.mural,
|
|
35336
|
+
memoryInjectionBudgetTokens: args.memoryInjectionBudgetTokens,
|
|
35337
|
+
retinaHandoff: args.retinaHandoff,
|
|
35338
|
+
transformMode: args.transformMode,
|
|
35339
|
+
moduleClient: args.moduleClient,
|
|
35022
35340
|
smartNotesEnabled: args.smartNotesEnabled
|
|
35023
35341
|
})
|
|
35024
35342
|
});
|
|
@@ -35108,9 +35426,9 @@ function hiddenTerminalError(event) {
|
|
|
35108
35426
|
}
|
|
35109
35427
|
|
|
35110
35428
|
// src/v2/hooks/lkg-system.ts
|
|
35111
|
-
import { createHash as
|
|
35429
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
35112
35430
|
function identity(slot) {
|
|
35113
|
-
return
|
|
35431
|
+
return createHash14("sha256").update(JSON.stringify({
|
|
35114
35432
|
capturedAt: slot.capturedAt,
|
|
35115
35433
|
captureSequence: slot.captureSequence,
|
|
35116
35434
|
rowVersion: slot.rowVersion,
|
|
@@ -47938,7 +48256,7 @@ function resolveCtxExpandMode(args, domain) {
|
|
|
47938
48256
|
}
|
|
47939
48257
|
|
|
47940
48258
|
// src/tools/ctx-expand/render.ts
|
|
47941
|
-
import { createHash as
|
|
48259
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
47942
48260
|
function isRecord6(value) {
|
|
47943
48261
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
47944
48262
|
}
|
|
@@ -48162,7 +48480,7 @@ function renderItemByTag(db, sessionId, number, textIndexDomain = "part") {
|
|
|
48162
48480
|
const index = scoped ? Number(scoped[2]) : 0;
|
|
48163
48481
|
const piText = message.parts.filter((part) => isRecord6(part) && part.type === "text");
|
|
48164
48482
|
const part = message.parts[index];
|
|
48165
|
-
const matching = derived ? piText.filter((part) => isRecord6(part) && typeof part.text === "string" &&
|
|
48483
|
+
const matching = derived ? piText.filter((part) => isRecord6(part) && typeof part.text === "string" && createHash15("sha256").update(part.text).digest("hex") === derived[3]) : [];
|
|
48166
48484
|
const selected = derived ? matching[Number(derived[4])] : textIndexDomain === "text" ? piText[index] : part;
|
|
48167
48485
|
return selected ? renderPartFull(selected) ?? "" : `Tag ${number}'s original text part is no longer in stored history.`;
|
|
48168
48486
|
}
|
|
@@ -49553,12 +49871,13 @@ function parseNoteIds(action, value) {
|
|
|
49553
49871
|
}
|
|
49554
49872
|
function createCtxNoteTool(deps) {
|
|
49555
49873
|
const { surface_condition: _condition, ...plainArgs } = ctxNoteArgsShape;
|
|
49874
|
+
const smartNoteSurface = deps.smartNotesEnabled !== false && deps.dreamerEnabled !== false;
|
|
49556
49875
|
return tool({
|
|
49557
|
-
description:
|
|
49558
|
-
args:
|
|
49876
|
+
description: smartNoteSurface ? CTX_NOTE_DESCRIPTION : withoutSmartNoteText(CTX_NOTE_DESCRIPTION),
|
|
49877
|
+
args: smartNoteSurface ? ctxNoteArgsShape : {
|
|
49559
49878
|
...plainArgs,
|
|
49560
49879
|
filter: ctxNoteArgsShape.filter.describe(NOTES_FILTER_DESCRIPTION)
|
|
49561
|
-
}
|
|
49880
|
+
},
|
|
49562
49881
|
async execute(rawArgs, toolContext) {
|
|
49563
49882
|
const parsedArgs = ctxNoteArgsSchema.safeParse(rawArgs);
|
|
49564
49883
|
let args = parsedArgs.success ? parsedArgs.data : rawArgs;
|
|
@@ -49738,7 +50057,7 @@ function formatCtxReduceReply(stampedCount, selfStampCount = 0) {
|
|
|
49738
50057
|
return parts.join(" ");
|
|
49739
50058
|
}
|
|
49740
50059
|
// src/tools/ctx-reduce/tools.ts
|
|
49741
|
-
import { createHash as
|
|
50060
|
+
import { createHash as createHash16 } from "node:crypto";
|
|
49742
50061
|
|
|
49743
50062
|
// src/features/magic-context/range-parser.ts
|
|
49744
50063
|
function parseRangeString(input) {
|
|
@@ -49801,11 +50120,11 @@ function createCtxReduceTool(deps) {
|
|
|
49801
50120
|
const stableId = `oc-${sessionId}-${callId}`;
|
|
49802
50121
|
if (Buffer.byteLength(stableId) <= 128)
|
|
49803
50122
|
return stableId;
|
|
49804
|
-
return `oc-${
|
|
50123
|
+
return `oc-${createHash16("sha256").update(stableId).digest("hex")}`;
|
|
49805
50124
|
}
|
|
49806
50125
|
fallbackCommandSequence += 1;
|
|
49807
50126
|
const monotonicId = `oc-${sessionId}-${fallbackCommandSequence}`;
|
|
49808
|
-
return Buffer.byteLength(monotonicId) <= 128 ? monotonicId : `oc-${
|
|
50127
|
+
return Buffer.byteLength(monotonicId) <= 128 ? monotonicId : `oc-${createHash16("sha256").update(monotonicId).digest("hex")}`;
|
|
49809
50128
|
};
|
|
49810
50129
|
return tool({
|
|
49811
50130
|
description: CTX_REDUCE_DESCRIPTION,
|
|
@@ -50186,6 +50505,113 @@ async function registerTools(context, db, config, rustToolBackends, isInternalCh
|
|
|
50186
50505
|
return { dispose: () => controller.abort() };
|
|
50187
50506
|
}
|
|
50188
50507
|
|
|
50508
|
+
// src/v2/hooks/transform-decision-binding.ts
|
|
50509
|
+
function bindV2TransformDecision(args) {
|
|
50510
|
+
try {
|
|
50511
|
+
return bindOpenCodeV2TransformDecision({
|
|
50512
|
+
db: args.db,
|
|
50513
|
+
sessionId: args.sessionId,
|
|
50514
|
+
passStarting: args.passStarting,
|
|
50515
|
+
firstAssistantAfter: (sequence) => {
|
|
50516
|
+
const first = args.reader.assistantSince(args.sessionId, sequence)[0];
|
|
50517
|
+
if (!first)
|
|
50518
|
+
return;
|
|
50519
|
+
const completion = {
|
|
50520
|
+
completedAt: first.data.time?.completed,
|
|
50521
|
+
finish: first.data.finish,
|
|
50522
|
+
error: first.data.error
|
|
50523
|
+
};
|
|
50524
|
+
return {
|
|
50525
|
+
id: first.id,
|
|
50526
|
+
state: providerResponseFailed(completion) ? "failed" : isSuccessfulProviderCompletion(completion) ? "succeeded" : "running",
|
|
50527
|
+
inputTokens: lkgProviderInputTotal(first.data.tokens)
|
|
50528
|
+
};
|
|
50529
|
+
}
|
|
50530
|
+
});
|
|
50531
|
+
} catch {
|
|
50532
|
+
return false;
|
|
50533
|
+
}
|
|
50534
|
+
}
|
|
50535
|
+
|
|
50536
|
+
// src/v2/hooks/transform-features.ts
|
|
50537
|
+
function createV2TransformFeatureDeps(config, compactionOff, directory) {
|
|
50538
|
+
return {
|
|
50539
|
+
protectedTools: config.protected_tools,
|
|
50540
|
+
commitClusterTrigger: config.commit_cluster_trigger,
|
|
50541
|
+
allowHomeProject: config.allow_home_project,
|
|
50542
|
+
injectDocs: config.dreamer?.inject_docs !== false,
|
|
50543
|
+
memoryConfig: {
|
|
50544
|
+
enabled: config.memory.enabled,
|
|
50545
|
+
injectionBudgetTokens: config.memory.injection_budget_tokens,
|
|
50546
|
+
autoPromote: config.memory.auto_promote
|
|
50547
|
+
},
|
|
50548
|
+
ensureProjectRegistered: ensureProjectRegisteredFromOpenCodeDirectory,
|
|
50549
|
+
historyBudgetPercentage: config.history_budget_percentage,
|
|
50550
|
+
experimentalUserMemories: userObservationCollectionEnabled2(config.dreamer),
|
|
50551
|
+
userObservationsRequested: userObservationsRequested2(config.dreamer),
|
|
50552
|
+
experimentalTemporalAwareness: config.temporal_awareness === true,
|
|
50553
|
+
muralEnabled: config.mural?.enabled === true,
|
|
50554
|
+
autoSearch: {
|
|
50555
|
+
enabled: config.memory.auto_search?.enabled ?? true,
|
|
50556
|
+
scoreThreshold: config.memory.auto_search?.score_threshold ?? 0.6,
|
|
50557
|
+
minPromptChars: config.memory.auto_search?.min_prompt_chars ?? 20,
|
|
50558
|
+
directory,
|
|
50559
|
+
ensureProjectRegistered: ensureProjectRegisteredFromOpenCodeDirectory,
|
|
50560
|
+
wordRules: cavemanWordRulesForLanguage(config.language)
|
|
50561
|
+
},
|
|
50562
|
+
cavemanTextCompression: compactionOff ? undefined : config.caveman_text_compression?.enabled === true ? {
|
|
50563
|
+
enabled: true,
|
|
50564
|
+
minChars: config.caveman_text_compression.min_chars ?? 500,
|
|
50565
|
+
wordRules: cavemanWordRulesForLanguage(config.language)
|
|
50566
|
+
} : undefined
|
|
50567
|
+
};
|
|
50568
|
+
}
|
|
50569
|
+
function createV2AutoEmbedSession(deps) {
|
|
50570
|
+
return (sessionId) => {
|
|
50571
|
+
if (isEmbeddingHostBusy2())
|
|
50572
|
+
return;
|
|
50573
|
+
const directory = deps.resolveDirectory(sessionId);
|
|
50574
|
+
const identity = resolveProjectIdentityForSession(directory, deps.allowHomeProject);
|
|
50575
|
+
const snapshot = identity ? getProjectEmbeddingSnapshot2(identity) : undefined;
|
|
50576
|
+
const embedIdentity = snapshot ? JSON.stringify([
|
|
50577
|
+
snapshot.providerIdentity,
|
|
50578
|
+
snapshot.chunkModelId,
|
|
50579
|
+
snapshot.runtimeFingerprint
|
|
50580
|
+
]) : "off";
|
|
50581
|
+
if (autoEmbedIdentityBySession.get(sessionId) !== embedIdentity)
|
|
50582
|
+
invalidateAutoEmbedSession(sessionId);
|
|
50583
|
+
if (autoEmbedAttemptedBySession.has(sessionId) || embedPauseBySession.has(sessionId))
|
|
50584
|
+
return;
|
|
50585
|
+
autoEmbedAttemptedBySession.add(sessionId);
|
|
50586
|
+
autoEmbedIdentityBySession.set(sessionId, embedIdentity);
|
|
50587
|
+
(async () => {
|
|
50588
|
+
try {
|
|
50589
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
50590
|
+
if (isEmbeddingHostBusy2()) {
|
|
50591
|
+
invalidateAutoEmbedSession(sessionId);
|
|
50592
|
+
return;
|
|
50593
|
+
}
|
|
50594
|
+
await ensureProjectRegisteredFromOpenCodeDirectory(directory, deps.db);
|
|
50595
|
+
const project = resolveProjectIdentityForSession(directory, deps.allowHomeProject);
|
|
50596
|
+
if (!project) {
|
|
50597
|
+
invalidateAutoEmbedSession(sessionId);
|
|
50598
|
+
return;
|
|
50599
|
+
}
|
|
50600
|
+
const coverage = await getAutoEmbeddingSessionCoverage2(deps.db, project, sessionId);
|
|
50601
|
+
if (!coverage.enabled) {
|
|
50602
|
+
invalidateAutoEmbedSession(sessionId);
|
|
50603
|
+
return;
|
|
50604
|
+
}
|
|
50605
|
+
if (coverage.total <= coverage.embedded)
|
|
50606
|
+
return;
|
|
50607
|
+
await runEmbedHistoryDrain(deps, sessionId, { silent: true });
|
|
50608
|
+
} catch (error) {
|
|
50609
|
+
log2("[magic-context] auto-embed drain failed:", error);
|
|
50610
|
+
}
|
|
50611
|
+
})();
|
|
50612
|
+
};
|
|
50613
|
+
}
|
|
50614
|
+
|
|
50189
50615
|
// src/v2/hooks/usage-reading.ts
|
|
50190
50616
|
function usageReadingMatchesDraft(reading, draftModel) {
|
|
50191
50617
|
return reading.modelKey === undefined || reading.modelKey === `${draftModel.providerID}/${draftModel.id}`;
|
|
@@ -50500,6 +50926,7 @@ async function registerContext(context) {
|
|
|
50500
50926
|
directory,
|
|
50501
50927
|
warn: (message) => log2(`[magic-context] config warning: ${message}`)
|
|
50502
50928
|
});
|
|
50929
|
+
logConfigDependencyNotesOnce(config, log2);
|
|
50503
50930
|
const storage = createV2StorageGate({
|
|
50504
50931
|
onUnavailable: (reason) => {
|
|
50505
50932
|
const message = formatFailClosedBlockingMessage(reason);
|
|
@@ -50636,29 +51063,39 @@ async function registerContext(context) {
|
|
|
50636
51063
|
projectIdentity: () => resolveProjectIdentityForSession(directory, config.allow_home_project) ?? "",
|
|
50637
51064
|
projectMemoryEnabled: config.memory.enabled,
|
|
50638
51065
|
language: config.language,
|
|
50639
|
-
mural: config.mural
|
|
51066
|
+
mural: config.mural,
|
|
51067
|
+
memoryInjectionBudgetTokens: config.memory.injection_budget_tokens,
|
|
51068
|
+
retinaHandoff: config.smart_notes.retina_handoff,
|
|
51069
|
+
transformMode: config.transform_mode,
|
|
51070
|
+
moduleClient: createDreamTimerModuleClient(rustModeModuleClient)
|
|
50640
51071
|
});
|
|
50641
|
-
|
|
51072
|
+
return trigger;
|
|
51073
|
+
};
|
|
51074
|
+
let hiddenCompletionExecutor = db && isDatabasePersisted(db) && resolveProjectIdentityForSession(directory, config.allow_home_project) ? await createHiddenExecutor(db) : undefined;
|
|
51075
|
+
let dreamTrigger = hiddenCompletionExecutor ? startDreamer(hiddenCompletionExecutor) : undefined;
|
|
51076
|
+
const lateHiddenExecutor = createLateHiddenExecutor(() => hiddenCompletionExecutor);
|
|
51077
|
+
let maintenanceTimer;
|
|
51078
|
+
const startMaintenance = () => {
|
|
51079
|
+
const timerProjectIdentity = resolveProjectIdentityForSession(directory, config.allow_home_project);
|
|
51080
|
+
if (!timerProjectIdentity || maintenanceTimer)
|
|
51081
|
+
return;
|
|
51082
|
+
maintenanceTimer = registerV2DreamScheduleTimer({
|
|
50642
51083
|
directory,
|
|
50643
|
-
projectIdentity,
|
|
51084
|
+
projectIdentity: timerProjectIdentity,
|
|
50644
51085
|
config,
|
|
50645
51086
|
dreamer: dreamerAtBoot,
|
|
50646
51087
|
liveConfig: () => liveConfigReader.poll().effective,
|
|
50647
|
-
executor:
|
|
50648
|
-
openReader: openStoreReader
|
|
51088
|
+
executor: withLiveDreamerOutputCap(lateHiddenExecutor, config, () => liveConfigReader.poll().effective),
|
|
51089
|
+
openReader: openStoreReader,
|
|
51090
|
+
rustModeModuleClient
|
|
50649
51091
|
});
|
|
50650
|
-
return {
|
|
50651
|
-
async dispose() {
|
|
50652
|
-
await Promise.all([trigger.dispose(), timer.dispose()]);
|
|
50653
|
-
}
|
|
50654
|
-
};
|
|
50655
51092
|
};
|
|
50656
|
-
|
|
50657
|
-
|
|
50658
|
-
const lateHiddenExecutor = createLateHiddenExecutor(() => hiddenCompletionExecutor);
|
|
51093
|
+
if (db && isDatabasePersisted(db))
|
|
51094
|
+
startMaintenance();
|
|
50659
51095
|
let hiddenWorkRecovery;
|
|
50660
51096
|
const recoverHiddenWork = (database) => !resolveProjectIdentityForSession(directory, config.allow_home_project) ? Promise.resolve(false) : hiddenWorkRecovery ??= (async () => {
|
|
50661
51097
|
try {
|
|
51098
|
+
startMaintenance();
|
|
50662
51099
|
hiddenCompletionExecutor ??= await createHiddenExecutor(database);
|
|
50663
51100
|
dreamTrigger ??= startDreamer(hiddenCompletionExecutor);
|
|
50664
51101
|
return true;
|
|
@@ -50679,7 +51116,8 @@ async function registerContext(context) {
|
|
|
50679
51116
|
twoPass: fresh.historian?.two_pass === true,
|
|
50680
51117
|
expandTools: fresh.historian?.expand_tools,
|
|
50681
51118
|
autoPromote: fresh.memory?.auto_promote ?? true,
|
|
50682
|
-
userMemoriesEnabled:
|
|
51119
|
+
userMemoriesEnabled: userObservationCollectionEnabled2(fresh.dreamer),
|
|
51120
|
+
userObservationsRequested: userObservationsRequested2(fresh.dreamer),
|
|
50683
51121
|
commitClusterTrigger: fresh.commit_cluster_trigger,
|
|
50684
51122
|
chunkTokens: deriveHistorianChunkTokens2(resolveHistorianContextLimit2(models.primary?.model))
|
|
50685
51123
|
};
|
|
@@ -50693,6 +51131,7 @@ async function registerContext(context) {
|
|
|
50693
51131
|
registerSystemDateRefresh(historyRefreshSessions);
|
|
50694
51132
|
const pendingMaterializationSessions = new Set;
|
|
50695
51133
|
const lastHeuristicsTurnId = new Map;
|
|
51134
|
+
const commitSeenLastPass = new Map;
|
|
50696
51135
|
const restoredRows = new RestoredRowCache;
|
|
50697
51136
|
const rawProviders = new Map;
|
|
50698
51137
|
let passDuties;
|
|
@@ -50802,7 +51241,7 @@ async function registerContext(context) {
|
|
|
50802
51241
|
}
|
|
50803
51242
|
};
|
|
50804
51243
|
const latestLkgResponseIds = new BoundedSessionMap(1000);
|
|
50805
|
-
const recordUsage = async (draft) => {
|
|
51244
|
+
const recordUsage = async (draft, passStarting = false) => {
|
|
50806
51245
|
let unsafe = false;
|
|
50807
51246
|
try {
|
|
50808
51247
|
await storage.probe();
|
|
@@ -50817,6 +51256,12 @@ async function registerContext(context) {
|
|
|
50817
51256
|
} catch (error) {
|
|
50818
51257
|
sessionLog2(draft.sessionID, "v2 response ownership unavailable; keeping system identity pending", error);
|
|
50819
51258
|
}
|
|
51259
|
+
bindV2TransformDecision({
|
|
51260
|
+
db,
|
|
51261
|
+
sessionId: draft.sessionID,
|
|
51262
|
+
reader,
|
|
51263
|
+
passStarting
|
|
51264
|
+
});
|
|
50820
51265
|
if (latest)
|
|
50821
51266
|
noteLkgProviderResponse({
|
|
50822
51267
|
sessionId: draft.sessionID,
|
|
@@ -50946,6 +51391,8 @@ async function registerContext(context) {
|
|
|
50946
51391
|
variants.delete(sessionID);
|
|
50947
51392
|
agents.delete(sessionID);
|
|
50948
51393
|
channel1.delete(sessionID);
|
|
51394
|
+
commitSeenLastPass.delete(sessionID);
|
|
51395
|
+
clearEmbedSessionState(sessionID);
|
|
50949
51396
|
historyRefreshSessions.delete(sessionID);
|
|
50950
51397
|
clearPendingMaterialization(pendingMaterializationSessions, sessionID);
|
|
50951
51398
|
lastHeuristicsTurnId.delete(sessionID);
|
|
@@ -50977,16 +51424,22 @@ async function registerContext(context) {
|
|
|
50977
51424
|
const materialize = (draft) => {
|
|
50978
51425
|
db = storage.require();
|
|
50979
51426
|
const state = getOrCreateSessionMeta(db, draft.sessionID);
|
|
51427
|
+
const modelKey = `${draft.model.providerID}/${draft.model.id}`;
|
|
51428
|
+
const contextLimit = resolveContextLimit(draft.model.providerID, draft.model.id, {
|
|
51429
|
+
db,
|
|
51430
|
+
sessionID: draft.sessionID
|
|
51431
|
+
}) || draft.model.limit?.context || (state.lastObservedModelKey === modelKey ? state.lastUsageContextLimit : undefined);
|
|
50980
51432
|
return materializeM0({
|
|
51433
|
+
...createM0RenderOptions({
|
|
51434
|
+
...createV2TransformFeatureDeps(config, compactionOff, directory),
|
|
51435
|
+
...createV2ThresholdDeps(config)
|
|
51436
|
+
}, usage.get(draft.sessionID)?.usage ?? { percentage: 0, inputTokens: 0 }, modelKey, contextLimit, resolveProjectIdentityForSession(directory, config.allow_home_project)),
|
|
50981
51437
|
db,
|
|
50982
51438
|
sessionId: draft.sessionID,
|
|
50983
51439
|
state,
|
|
50984
|
-
projectPath: resolveProjectIdentityForSession(directory, config.allow_home_project) ?? "",
|
|
50985
51440
|
projectDirectory: directory,
|
|
50986
|
-
memoryEnabled: config.memory.enabled && !!resolveProjectIdentityForSession(directory, config.allow_home_project),
|
|
50987
|
-
memoryInjectionBudgetTokens: config.memory.injection_budget_tokens,
|
|
50988
51441
|
hardSignals: {
|
|
50989
|
-
systemHash:
|
|
51442
|
+
systemHash: state.systemPromptHash ?? "",
|
|
50990
51443
|
toolSetHash: getCurrentToolSetHash(draft.model.providerID, draft.model.id, draft.agent),
|
|
50991
51444
|
modelKey: `${draft.model.providerID}/${draft.model.id}`,
|
|
50992
51445
|
cacheExpired: false,
|
|
@@ -51006,6 +51459,7 @@ async function registerContext(context) {
|
|
|
51006
51459
|
rememberHostMedia(draft.messages);
|
|
51007
51460
|
const reader = openStoreReader();
|
|
51008
51461
|
try {
|
|
51462
|
+
await storage.probe();
|
|
51009
51463
|
const watermark = reader.latestSequenceForIds(draft.sessionID, draft.messages.flatMap((message) => message.id ? [message.id] : []));
|
|
51010
51464
|
const running = reader.latestRunningCompaction(draft.sessionID);
|
|
51011
51465
|
const moduleBaseline = rustModeModuleClient ? servedModuleM0Text(draft.sessionID) : undefined;
|
|
@@ -51080,7 +51534,7 @@ async function registerContext(context) {
|
|
|
51080
51534
|
if (!modelLimitCacheWarm())
|
|
51081
51535
|
withoutSqliteTransformPass2(() => warmModelLimitCacheFromCatalog(context));
|
|
51082
51536
|
agents.set(draft.sessionID, draft.agent);
|
|
51083
|
-
applyV2PromptSurfaceTools(draft, promptSurfaceRuntime, config.prompt_surface, config
|
|
51537
|
+
applyV2PromptSurfaceTools(draft, promptSurfaceRuntime, config.prompt_surface, isSmartNoteSurfaceAvailable(config));
|
|
51084
51538
|
const admissionDb = db ?? storage.current();
|
|
51085
51539
|
const replayFits = (messages) => {
|
|
51086
51540
|
const system = structuredClone(draft.system);
|
|
@@ -51144,7 +51598,7 @@ async function registerContext(context) {
|
|
|
51144
51598
|
if (admissionDb)
|
|
51145
51599
|
hideSubagentTools(draft, admissionDb);
|
|
51146
51600
|
recordV2ToolDefinitions(draft);
|
|
51147
|
-
if (await recordUsage(draft) && !compactionOff) {
|
|
51601
|
+
if (await recordUsage(draft, true) && !compactionOff) {
|
|
51148
51602
|
const storageReason = storage.current() ? null : storage.reason();
|
|
51149
51603
|
if (storageReason) {
|
|
51150
51604
|
noticeStorageRefusal(draft.sessionID, storageReason);
|
|
@@ -51226,6 +51680,7 @@ async function registerContext(context) {
|
|
|
51226
51680
|
await cacheV2SessionDirectory(context.session, draft.sessionID, sessionDirectories);
|
|
51227
51681
|
prepareHistorySession(draft.sessionID);
|
|
51228
51682
|
transform ??= createTransform({
|
|
51683
|
+
...createV2TransformFeatureDeps(config, compactionOff, directory),
|
|
51229
51684
|
cacheTtlConfig: config.cache_ttl,
|
|
51230
51685
|
cacheTtlConfigured: config.cacheTtlConfigured,
|
|
51231
51686
|
sampleCacheTtlConfig: () => liveConfigReader.poll().effective,
|
|
@@ -51255,14 +51710,27 @@ async function registerContext(context) {
|
|
|
51255
51710
|
historyRefreshSessions,
|
|
51256
51711
|
pendingMaterializationSessions,
|
|
51257
51712
|
lastHeuristicsTurnId,
|
|
51713
|
+
commitSeenLastPass,
|
|
51258
51714
|
variantBySession: variants,
|
|
51259
51715
|
keepReasoningTokens: config.keep_reasoning_tokens,
|
|
51260
51716
|
directory,
|
|
51261
51717
|
sessionDirectoryBySession: sessionDirectories,
|
|
51262
|
-
projectPath: directory,
|
|
51718
|
+
projectPath: resolveProjectIdentityForSession(directory, config.allow_home_project),
|
|
51719
|
+
getHistorianChunkTokens: () => sampleHistorian().chunkTokens,
|
|
51720
|
+
getFallbackModelId: (sessionID) => {
|
|
51721
|
+
const model = liveModels.get(sessionID);
|
|
51722
|
+
return model ? `${model.providerID}/${model.modelID}` : undefined;
|
|
51723
|
+
},
|
|
51724
|
+
maybeAutoEmbedSession: createV2AutoEmbedSession({
|
|
51725
|
+
db,
|
|
51726
|
+
resolveDirectory: (sessionID) => sessionDirectories.get(sessionID) ?? directory,
|
|
51727
|
+
allowHomeProject: config.allow_home_project,
|
|
51728
|
+
recompProgressBySession: new Map
|
|
51729
|
+
}),
|
|
51263
51730
|
hiddenCompletionExecutor,
|
|
51264
51731
|
historianRunnable: !compactionOff && hiddenCompletionExecutor !== undefined && config.historian?.disable !== true,
|
|
51265
51732
|
historianModel: historianModels.primary,
|
|
51733
|
+
historianContextLimit: sampleHistorian().contextLimit,
|
|
51266
51734
|
fallbackModels: historianModels.fallbacks,
|
|
51267
51735
|
resolveHistorianRun: sampleHistorian,
|
|
51268
51736
|
historianTimeoutMs: config.historian_timeout_ms,
|
|
@@ -51290,14 +51758,10 @@ async function registerContext(context) {
|
|
|
51290
51758
|
promptSurface: config.prompt_surface,
|
|
51291
51759
|
promptSurfaceRuntime,
|
|
51292
51760
|
onRustEngineReconnectRefusal: (refusal) => rustRefusalRecovery?.arm(refusal),
|
|
51293
|
-
memoryConfig: {
|
|
51294
|
-
enabled: config.memory.enabled,
|
|
51295
|
-
injectionBudgetTokens: config.memory.injection_budget_tokens,
|
|
51296
|
-
autoPromote: config.memory.auto_promote
|
|
51297
|
-
},
|
|
51298
51761
|
...createHostSeams(context, readAllForConversion, pagedRead, liveModels)
|
|
51299
51762
|
});
|
|
51300
51763
|
const admitted = new Set;
|
|
51764
|
+
let messageTimes;
|
|
51301
51765
|
const reader = openStoreReader();
|
|
51302
51766
|
let checkpoint;
|
|
51303
51767
|
let submitted;
|
|
@@ -51368,6 +51832,8 @@ async function registerContext(context) {
|
|
|
51368
51832
|
} : undefined));
|
|
51369
51833
|
draft.messages.splice(0, draft.messages.length, ...restored, ...draft.messages.filter((message) => message !== incoming));
|
|
51370
51834
|
}
|
|
51835
|
+
if (config.temporal_awareness === true)
|
|
51836
|
+
messageTimes = reader.messageTimes(draft.sessionID, draft.messages.flatMap((message) => message.id ? [message.id] : []));
|
|
51371
51837
|
} finally {
|
|
51372
51838
|
reader.close();
|
|
51373
51839
|
}
|
|
@@ -51384,7 +51850,7 @@ async function registerContext(context) {
|
|
|
51384
51850
|
nativeFoldReplay.invalidate(draft.sessionID, true);
|
|
51385
51851
|
}
|
|
51386
51852
|
}
|
|
51387
|
-
const mapped = adaptPayload(draft, admitted);
|
|
51853
|
+
const mapped = adaptPayload(draft, admitted, messageTimes);
|
|
51388
51854
|
bindSystemDateRequestIdentity(mapped, draft);
|
|
51389
51855
|
await createMessagesTransformHandler({
|
|
51390
51856
|
magicContext: { "experimental.chat.messages.transform": transform },
|
|
@@ -51394,6 +51860,10 @@ async function registerContext(context) {
|
|
|
51394
51860
|
rustReplayParticipant: () => transform?.getRustReplayParticipant() ?? null
|
|
51395
51861
|
})({}, mapped);
|
|
51396
51862
|
mapped.commit();
|
|
51863
|
+
stageOpenCodeV2TransformDecision({
|
|
51864
|
+
sessionId: draft.sessionID,
|
|
51865
|
+
responseAfterSequence
|
|
51866
|
+
});
|
|
51397
51867
|
if (db) {
|
|
51398
51868
|
await deliverPendingChannel2(context, db, draft.sessionID, channel1.get(draft.sessionID));
|
|
51399
51869
|
}
|
|
@@ -51560,6 +52030,7 @@ ${baseline}
|
|
|
51560
52030
|
db: runDb,
|
|
51561
52031
|
dreamer: manualDreamer,
|
|
51562
52032
|
smartNotesEnabled: config.smart_notes.enabled,
|
|
52033
|
+
memoryEnabled: config.memory.enabled,
|
|
51563
52034
|
projectIdentity: resolveProjectIdentityForSession(directory, config.allow_home_project) ?? "",
|
|
51564
52035
|
directory,
|
|
51565
52036
|
language: config.language,
|
|
@@ -51610,6 +52081,7 @@ ${baseline}
|
|
|
51610
52081
|
await usageDone;
|
|
51611
52082
|
deletedSessions.clear();
|
|
51612
52083
|
await dreamTrigger?.dispose();
|
|
52084
|
+
await maintenanceTimer?.dispose();
|
|
51613
52085
|
for (const release of rawProviders.values())
|
|
51614
52086
|
release();
|
|
51615
52087
|
rawProviders.clear();
|