@cortexkit/opencode-magic-context 0.49.23 → 0.49.25

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.
Files changed (122) hide show
  1. package/README.md +0 -26
  2. package/dist/agents/permissions.d.ts +8 -3
  3. package/dist/agents/permissions.d.ts.map +1 -1
  4. package/dist/auto-search-worker.js +4 -4
  5. package/dist/chunk-embedding-write-worker.js +5 -5
  6. package/dist/{compartment-chunk-embedding-he60aaa2.js → compartment-chunk-embedding-eypvn607.js} +3 -3
  7. package/dist/{conflict-warning-hook-2r32hyx6.js → conflict-warning-hook-a27bhggg.js} +4 -4
  8. package/dist/{context-j7hp43a0.js → context-keb00be8.js} +30 -24
  9. package/dist/{embedding-backfill-dtke6tck.js → embedding-backfill-vddgmem3.js} +5 -5
  10. package/dist/features/magic-context/dreamer/primer-seed.d.ts.map +1 -1
  11. package/dist/features/magic-context/tool-definition-tokens.d.ts +113 -57
  12. package/dist/features/magic-context/tool-definition-tokens.d.ts.map +1 -1
  13. package/dist/hooks/magic-context/ask-answer-notice.d.ts +25 -0
  14. package/dist/hooks/magic-context/ask-answer-notice.d.ts.map +1 -0
  15. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +1 -1
  16. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  17. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +12 -4
  18. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  19. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  20. package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
  21. package/dist/hooks/magic-context/lkg-replay-fit.d.ts.map +1 -1
  22. package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +8 -0
  24. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  25. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  26. package/dist/hooks/magic-context/read-session-raw.d.ts +10 -0
  27. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  28. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  29. package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts +42 -0
  30. package/dist/hooks/magic-context/signed-thinking-fit-snapshot.d.ts.map +1 -0
  31. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  32. package/dist/{index-y76rhsnr.js → index-0s8454t2.js} +50 -31
  33. package/dist/{index-1gtfne2c.js → index-2haxh8h3.js} +1 -1
  34. package/dist/{index-m32esgmj.js → index-3d5wnkq7.js} +1 -1
  35. package/dist/{index-jfem3dgz.js → index-7tdtpqrg.js} +5 -1
  36. package/dist/{index-mnnkgq0q.js → index-awcftgmx.js} +7 -49
  37. package/dist/{index-1kbznkft.js → index-axjgxeww.js} +10 -8
  38. package/dist/{index-j32jj2t8.js → index-bhyksfyy.js} +3 -3
  39. package/dist/{index-ksq50rg0.js → index-c9zrgcnt.js} +1 -1
  40. package/dist/index-cfaet9cg.js +405 -0
  41. package/dist/{index-jmq8kfe7.js → index-ebsvmc5s.js} +4 -4
  42. package/dist/{index-66eby7hx.js → index-jcr6pe7z.js} +1 -1
  43. package/dist/{index-syaazvy2.js → index-n18sch77.js} +5 -5
  44. package/dist/{index-a9zvn5fe.js → index-q7ywt6xt.js} +3 -3
  45. package/dist/{index-x6cbrv9h.js → index-szf8r0ba.js} +1 -1
  46. package/dist/{index-rxqr723x.js → index-t6j3qxnd.js} +1 -1
  47. package/dist/{index-11gzxvf4.js → index-y6xpzjzr.js} +98 -48
  48. package/dist/{index-mnhcdfxg.js → index-yrrsp47d.js} +91 -17
  49. package/dist/{index-zy67whjr.js → index-z05n7702.js} +1 -1
  50. package/dist/{index-3svaejkh.js → index-z928hmnp.js} +1 -1
  51. package/dist/{index-ffzhwfzy.js → index-zzrzjnx5.js} +3 -3
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +43 -38
  54. package/dist/{message-fts-rowid-map-e79b7b6x.js → message-fts-rowid-map-9e1getgs.js} +2 -2
  55. package/dist/{message-index-4q8ek2fc.js → message-index-3g966xn7.js} +7 -7
  56. package/dist/{message-index-bounded-rydsg9r5.js → message-index-bounded-vaeqhp9w.js} +7 -7
  57. package/dist/migration-worker.js +4 -4
  58. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  59. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  60. package/dist/{project-embedding-registry-hn529988.js → project-embedding-registry-rstzmb60.js} +4 -4
  61. package/dist/raw-ordinal-warmup-worker.js +6 -6
  62. package/dist/{read-session-chunk-t039f0m5.js → read-session-chunk-z5gnc0zb.js} +4 -4
  63. package/dist/{read-session-raw-aw6jgvwg.js → read-session-raw-s4amywnh.js} +3 -1
  64. package/dist/{recomp-orchestrator-hbm53jj5.js → recomp-orchestrator-qwqeskhq.js} +14 -14
  65. package/dist/{search-hea079d7.js → search-84zfqeky.js} +11 -11
  66. package/dist/{search-archive-weh164mh.js → search-archive-mfabzyn2.js} +5 -5
  67. package/dist/{send-session-notification-gqzkz7da.js → send-session-notification-ygj4mja0.js} +3 -3
  68. package/dist/shared/slow-test.d.ts +7 -0
  69. package/dist/shared/slow-test.d.ts.map +1 -0
  70. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  71. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  72. package/dist/tools/parameter-descriptions.d.ts +6 -6
  73. package/dist/tools/parameter-descriptions.d.ts.map +1 -1
  74. package/dist/{transform-postprocess-phase-0b04tm1p.js → transform-postprocess-phase-hr1ntmjj.js} +14 -14
  75. package/dist/v2/auto-search-worker.js +4 -4
  76. package/dist/v2/chunk-embedding-write-worker.js +5 -5
  77. package/dist/v2/{compartment-chunk-embedding-8jjmcgeg.js → compartment-chunk-embedding-tk6g4q80.js} +3 -3
  78. package/dist/v2/{context-ea3x7smm.js → context-y7wfvdve.js} +106 -50
  79. package/dist/v2/{embedding-backfill-5e74ae0m.js → embedding-backfill-w5qp7t28.js} +5 -5
  80. package/dist/v2/hooks/context.d.ts +4 -0
  81. package/dist/v2/hooks/context.d.ts.map +1 -1
  82. package/dist/v2/{message-fts-rowid-map-n8fdg2ja.js → message-fts-rowid-map-pqk3a55v.js} +2 -2
  83. package/dist/v2/{message-index-bounded-8rcd7qq9.js → message-index-bounded-te303atj.js} +6 -6
  84. package/dist/v2/{message-index-qz9wdp82.js → message-index-fz6b4jeh.js} +6 -6
  85. package/dist/v2/migration-worker.js +4 -4
  86. package/dist/v2/{project-embedding-registry-v38q4xd5.js → project-embedding-registry-e7zftfvj.js} +4 -4
  87. package/dist/v2/raw-ordinal-warmup-worker.js +6 -6
  88. package/dist/v2/{read-session-chunk-wazfyxcg.js → read-session-chunk-knvkq1hf.js} +3 -3
  89. package/dist/v2/{read-session-raw-b70cpwzj.js → read-session-raw-ppjxnqk4.js} +3 -1
  90. package/dist/v2/{recomp-orchestrator-b12zaptj.js → recomp-orchestrator-e8a4jpvr.js} +11 -11
  91. package/dist/v2/{search-archive-x64rtz1z.js → search-archive-vrwgxv6z.js} +4 -4
  92. package/dist/v2/{search-hza9x72a.js → search-hav4dggf.js} +10 -10
  93. package/dist/v2/{send-session-notification-8eqe259v.js → send-session-notification-f8scq6ae.js} +1 -1
  94. package/dist/v2/{server-m4bfaevz.js → server-5brp2rfn.js} +90 -16
  95. package/dist/v2/{server-ppcd1qxh.js → server-6a8pxpxg.js} +7 -49
  96. package/dist/v2/server-7d6m1p2b.js +361 -0
  97. package/dist/v2/{server-zg5y109h.js → server-7weh65vd.js} +45 -27
  98. package/dist/v2/{server-qteg2kt9.js → server-8j2e7t31.js} +1 -1
  99. package/dist/v2/{server-d48x3m4x.js → server-9xbbaekh.js} +1 -1
  100. package/dist/v2/{server-j8h7bsca.js → server-e75vag9d.js} +3 -3
  101. package/dist/v2/{server-132h8twc.js → server-m6yyn961.js} +2 -2
  102. package/dist/v2/{server-62g58aaz.js → server-pw21ypwb.js} +1 -1
  103. package/dist/v2/{server-ad18djzs.js → server-q5z0gag0.js} +1 -1
  104. package/dist/v2/{server-4kjmrjn4.js → server-swvhxhxz.js} +5 -1
  105. package/dist/v2/{server-33nqbqkw.js → server-tfawsj08.js} +5 -5
  106. package/dist/v2/{server-dtp8hcjh.js → server-wxrdher8.js} +1 -1
  107. package/dist/v2/server.js +5 -5
  108. package/dist/v2/{wrapup-orchestrator-3ssd5yy1.js → wrapup-orchestrator-ycs8y6n4.js} +11 -11
  109. package/dist/{wrapup-orchestrator-5vpcd1zx.js → wrapup-orchestrator-f642w8n3.js} +15 -15
  110. package/package.json +4 -4
  111. package/src/agents/permissions.ts +22 -6
  112. package/src/agents/smart-notes-dreamer-gate.golden.json +241 -241
  113. package/src/agents/smart-notes-on.golden.json +4 -4
  114. package/src/config/compaction-accessor-guard.test.ts +0 -5
  115. package/src/config/removed-config-keys.test.ts +12 -26
  116. package/src/shared/announcement.test.ts +55 -59
  117. package/src/shared/prompt-surface-a1-golden.md +6 -7
  118. package/src/shared/slow-test.ts +24 -0
  119. package/src/shared/stable-json-linear.test.ts +18 -10
  120. package/dist/index-j76ah6d7.js +0 -120
  121. package/dist/v2/server-d1dzgvwd.js +0 -120
  122. package/src/config/latch-permanence-guard.test.ts +0 -258
package/README.md CHANGED
@@ -368,32 +368,6 @@ bun run format # Format (Biome)
368
368
 
369
369
  Dream execution requires a live OpenCode server (the dreamer creates ephemeral child sessions). Use `/ctx-dream` inside OpenCode for on-demand maintenance.
370
370
 
371
- ### Mutation catalogue
372
-
373
- A passing safety test proves little until it has been seen to fail. [`mutations.toml`](mutations.toml) is the checked-in catalogue: each row deliberately breaks one guard in production code and names the test that must fail because of it, so a guard cannot quietly stop guarding. A row earns its place by guarding a silent, costly failure: a prompt-cache bust, a refusal that must fail closed, a wire contract, crash safety, data loss, file permissions. Every exactly-once guard (a lease, a compare-and-set clear) has at least one row through the real production path. Style and cosmetics do not get rows.
374
-
375
- The pinned [`ck-mutate`](https://github.com/cortexkit/commons/tree/7d08e73722fa3e79bbcc2607753978ab768f1c6b/crates/cortexkit-mutate) runner replays it from a clean tree: it checks that each named test passes, applies the break, requires the test to fail, and restores the source byte for byte.
376
-
377
- ```sh
378
- cargo install --locked --git https://github.com/cortexkit/commons --rev 7d08e73722fa3e79bbcc2607753978ab768f1c6b cortexkit-mutate
379
- bun install --frozen-lockfile
380
- ck-mutate check # anchors match exactly once; cargo test names exist
381
- ck-mutate run --all # every row (slow: the Rust rows rebuild mc-module)
382
- ck-mutate run --diff origin/master # only the rows a change touches
383
- ck-mutate run --only ts-schema-fence-refuses-newer-database
384
- ```
385
-
386
- Every row must report CAUGHT. [`mutations.yml`](.github/workflows/mutations.yml) replays the rows a pull request (or a `train/**` push) touches, the full catalogue on every push to master, and the full catalogue with `--broad` nightly. Never `git checkout` a file while a replay runs: it removes the mutation and fakes a survivor.
387
-
388
- To add a row:
389
-
390
- 1. Pick the production line that *is* the guard and copy `old` from the file, never from memory. Make `new` the smallest edit that removes the protection (`if (false)`, `return true`, a dropped condition), not an edit that breaks compilation.
391
- 2. Find the test that should catch it. Apply the edit by hand, run that test file, and confirm the test goes red for the guarded reason, then restore the file. If nothing goes red, that is a finding: add the missing test first, in its own commit.
392
- 3. Add the row. Bun tests are `command` rows: copy an existing row and set `expect_red` to the anchored `-t` regex of the full test name (describe names and test name joined by spaces, regex metacharacters escaped, each space written `\s`). Rust tests in mc-module are `command` rows running `cargo test --lib -- --exact`; small Rust targets are `cargo` rows with `only = true`. Add `expect_message` (a substring, or `/regex/`) whenever the test could also fail for an unrelated reason.
393
- 4. Run `ck-mutate check`, then `ck-mutate run --only <id>`, and commit the row only once it reports CAUGHT.
394
-
395
- A row that stops being caught is a finding to fix, not a row to delete.
396
-
397
371
  ---
398
372
 
399
373
  ### Cache-bust sentinel
@@ -75,9 +75,14 @@ export declare function buildAllowOnlyPermission(allowedTools: readonly string[]
75
75
  * OpenCode accepts either a whole-permission action or a pattern map for
76
76
  * `permission.task`; its visibility evaluator uses the last matching rule.
77
77
  * Normalize the whole-permission form, retain unrelated user rules, then append
78
- * our exact agent-id denies. When the ambient task policy has a wildcard deny,
79
- * re-emit that wildcard after the named denies so the Task tool is hidden rather
80
- * than shown as a callable-but-refused tool.
78
+ * our exact agent-id denies. When the ambient task policy is a wildcard deny
79
+ * whose only companions are our own appended agent-id denies, re-emit that
80
+ * wildcard after the named denies so the Task tool is hidden rather than shown
81
+ * as a callable-but-refused tool. When the wildcard deny sits next to any of
82
+ * the agent's own rules (the deny-by-default-with-exceptions shape), keep the
83
+ * agent's own ordering untouched: OpenCode resolves with the last matching
84
+ * rule, so moving the wildcard to the end there would override every named
85
+ * allow and empty the Task tool (#777).
81
86
  */
82
87
  export declare function denyTaskRoutingToAgents(permission: unknown, internalAgentIds: readonly string[]): Record<string, unknown>;
83
88
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/agents/permissions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACpC,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAC3C,UAAU,CAAC,EAAE,MAAM,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAoBlC;AAYD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACnC,UAAU,EAAE,OAAO,EACnB,gBAAgB,EAAE,SAAS,MAAM,EAAE,GACpC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgCzB;AAgBD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CACzC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACrD,gBAAgB,EAAE,SAAS,MAAM,EAAE,GACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAczC;AAED,wFAAwF;AACxF,eAAO,MAAM,uBAAuB,aAAc,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,UAAU,EAAE,SAAS,MAAM,EAAE,GAC9B,SAAS,MAAM,EAAE,CAGnB;AAQD,eAAO,MAAM,mCAAmC,yBAA0B,CAAC;AAE3E;;;;;GAKG;AACH,eAAO,MAAM,yCAAyC,0FAQ5C,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,aAAc,CAAC"}
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/agents/permissions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACpC,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAC3C,UAAU,CAAC,EAAE,MAAM,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAoBlC;AAYD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CACnC,UAAU,EAAE,OAAO,EACnB,gBAAgB,EAAE,SAAS,MAAM,EAAE,GACpC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA2CzB;AAgBD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CACzC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACrD,gBAAgB,EAAE,SAAS,MAAM,EAAE,GACpC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAczC;AAED,wFAAwF;AACxF,eAAO,MAAM,uBAAuB,aAAc,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,UAAU,EAAE,SAAS,MAAM,EAAE,GAC9B,SAAS,MAAM,EAAE,CAGnB;AAQD,eAAO,MAAM,mCAAmC,yBAA0B,CAAC;AAE3E;;;;;GAKG;AACH,eAAO,MAAM,yCAAyC,0FAQ5C,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,aAAc,CAAC"}
@@ -24,12 +24,12 @@ var [
24
24
  { Database, registerSqliteDiagnosticSink },
25
25
  { log }
26
26
  ] = await Promise.all([
27
- import("./embedding-backfill-dtke6tck.js"),
27
+ import("./embedding-backfill-vddgmem3.js"),
28
28
  import("./embedding-cache-mgyr73ef.js"),
29
29
  import("./storage-memory-e6a7mb0k.js"),
30
- import("./project-embedding-registry-hn529988.js"),
31
- import("./search-hea079d7.js"),
32
- import("./compartment-chunk-embedding-he60aaa2.js"),
30
+ import("./project-embedding-registry-rstzmb60.js"),
31
+ import("./search-84zfqeky.js"),
32
+ import("./compartment-chunk-embedding-eypvn607.js"),
33
33
  import("./embedding-activity-g1dhes6g.js"),
34
34
  import("./harness-e4avh192.js"),
35
35
  import("./sqlite-zdgm52sv.js"),
@@ -16,14 +16,14 @@ import"./index-g2q4htwp.js";
16
16
  import"./index-h7tgn49j.js";
17
17
  import"./index-wfybj1dw.js";
18
18
  import"./index-v0p37hm2.js";
19
- import"./index-jfem3dgz.js";
20
- import"./index-x6cbrv9h.js";
19
+ import"./index-7tdtpqrg.js";
20
+ import"./index-szf8r0ba.js";
21
21
  import {
22
22
  replaceCompartmentChunkEmbeddings2,
23
23
  recordChunkEmbedBackoff2,
24
24
  loadUnembeddedSessionChunkCandidates2,
25
25
  countUnembeddedSessionCompartments2
26
- } from "./index-m32esgmj.js";
26
+ } from "./index-3d5wnkq7.js";
27
27
  import {
28
28
  recordSessionProjectIdentity,
29
29
  acquireGitSweepLease,
@@ -35,12 +35,12 @@ import"./index-c7phnbvk.js";
35
35
  import {
36
36
  LATEST_SUPPORTED_VERSION,
37
37
  enforceSchemaFence
38
- } from "./index-a9zvn5fe.js";
38
+ } from "./index-q7ywt6xt.js";
39
39
  import"./index-9q1g3c5q.js";
40
40
  import"./index-x9k3mqrf.js";
41
41
  import"./index-fr0wbhdn.js";
42
42
  import"./index-58e3y90n.js";
43
- import"./index-j76ah6d7.js";
43
+ import"./index-cfaet9cg.js";
44
44
  import"./index-t5pck3ss.js";
45
45
 
46
46
  // src/features/magic-context/chunk-embedding-write-worker.ts
@@ -24,10 +24,10 @@ import {
24
24
  countSessionCompartmentEmbedCoverage2,
25
25
  countSessionCompartmentEmbedCoveragePolite2,
26
26
  countUnembeddedSessionCompartmentsPolite2
27
- } from "./index-m32esgmj.js";
27
+ } from "./index-3d5wnkq7.js";
28
28
  import"./index-wfybj1dw.js";
29
- import"./index-x6cbrv9h.js";
30
- import"./index-jfem3dgz.js";
29
+ import"./index-szf8r0ba.js";
30
+ import"./index-7tdtpqrg.js";
31
31
  import"./index-v0p37hm2.js";
32
32
  import"./index-t5pck3ss.js";
33
33
  import"./index-b88dwwrh.js";
@@ -4,15 +4,15 @@ import {
4
4
  cleanupConflictWarnings2,
5
5
  sendSchemaFenceWarning2,
6
6
  sendStartupAnnouncement2
7
- } from "./index-1gtfne2c.js";
7
+ } from "./index-2haxh8h3.js";
8
8
  import"./index-4pnsgvfk.js";
9
9
  import"./index-sd3egckz.js";
10
- import"./index-66eby7hx.js";
10
+ import"./index-jcr6pe7z.js";
11
11
  import"./index-qt1qqasc.js";
12
- import"./index-ksq50rg0.js";
12
+ import"./index-c9zrgcnt.js";
13
13
  import"./index-rrv26qjz.js";
14
14
  import"./index-58e3y90n.js";
15
- import"./index-jfem3dgz.js";
15
+ import"./index-7tdtpqrg.js";
16
16
  import"./index-v0p37hm2.js";
17
17
  import"./index-gzy5w8ya.js";
18
18
  import"./index-h7tgn49j.js";
@@ -59,7 +59,7 @@ import {
59
59
  rebaseSessionCoordinatesAsync,
60
60
  resolveOpenCodeProtectedTailBoundary,
61
61
  getActiveCompartmentRun
62
- } from "./index-y76rhsnr.js";
62
+ } from "./index-0s8454t2.js";
63
63
  import"./index-sd3egckz.js";
64
64
  import {
65
65
  getHarness2
@@ -151,7 +151,7 @@ import {
151
151
  applyJsonSchemaParameterDescriptions,
152
152
  MagicContextRpcServer,
153
153
  subagentTemperature
154
- } from "./index-11gzxvf4.js";
154
+ } from "./index-y6xpzjzr.js";
155
155
  import {
156
156
  resolveHistorianModel2
157
157
  } from "./index-5kym00ag.js";
@@ -166,7 +166,7 @@ import {
166
166
  openDatabaseAsync,
167
167
  isDatabasePersisted,
168
168
  getDatabasePersistenceError
169
- } from "./index-a9zvn5fe.js";
169
+ } from "./index-q7ywt6xt.js";
170
170
  import {
171
171
  setHomeProjectPermission,
172
172
  resolveProjectIdentityForSession,
@@ -174,14 +174,13 @@ import {
174
174
  } from "./index-kq5w68dp.js";
175
175
  import"./index-c7phnbvk.js";
176
176
  import {
177
- BoundedSessionMap,
178
177
  advanceSessionActivity,
179
178
  backfillSessionActivity,
180
179
  gaDatabasePath,
181
180
  RAW_MESSAGE_TYPES,
182
181
  V2StoreReaderPool,
183
182
  V2StoreReader
184
- } from "./index-mnnkgq0q.js";
183
+ } from "./index-awcftgmx.js";
185
184
  import"./index-v0p37hm2.js";
186
185
  import {
187
186
  inRootAsyncContext2,
@@ -191,7 +190,7 @@ import {
191
190
  withAsyncPrivilegedWriter2
192
191
  } from "./index-gzy5w8ya.js";
193
192
  import"./index-cpjk5jd2.js";
194
- import"./index-jfem3dgz.js";
193
+ import"./index-7tdtpqrg.js";
195
194
  import"./index-58e3y90n.js";
196
195
  import"./index-1zx87sdm.js";
197
196
  import {
@@ -208,7 +207,7 @@ import {
208
207
  estimateTokens
209
208
  } from "./index-b88dwwrh.js";
210
209
  import"./index-x9k3mqrf.js";
211
- import"./index-ksq50rg0.js";
210
+ import"./index-c9zrgcnt.js";
212
211
  import {
213
212
  needsBlockedRead,
214
213
  markHostUnservedRow,
@@ -244,28 +243,29 @@ import {
244
243
  cleanUserText2,
245
244
  readRawSessionMessageIdOrdinalsForRange2,
246
245
  readRawSessionMessageOrdinalById2
247
- } from "./index-mnhcdfxg.js";
246
+ } from "./index-yrrsp47d.js";
248
247
  import {
249
- getCurrentToolSetHash,
250
- recordToolDefinition
251
- } from "./index-j76ah6d7.js";
252
- import"./index-x6cbrv9h.js";
248
+ BoundedSessionMap,
249
+ recordToolDefinitionSet,
250
+ getCurrentToolSetHash
251
+ } from "./index-cfaet9cg.js";
252
+ import"./index-szf8r0ba.js";
253
253
  import"./index-wfybj1dw.js";
254
254
  import {
255
255
  deleteChunkEmbedBackoffForSession2
256
- } from "./index-m32esgmj.js";
256
+ } from "./index-3d5wnkq7.js";
257
257
  import {
258
258
  invalidateAutoEmbedSession,
259
259
  clearEmbedSessionState,
260
260
  retainProjectEmbedding2
261
- } from "./index-zy67whjr.js";
261
+ } from "./index-z05n7702.js";
262
262
  import"./index-fr0wbhdn.js";
263
263
  import"./index-9q1g3c5q.js";
264
264
  import"./index-fb3zxn06.js";
265
265
  import {
266
266
  renderUserFacingFailure,
267
267
  userFacingFailureCode
268
- } from "./index-3svaejkh.js";
268
+ } from "./index-z928hmnp.js";
269
269
  import {
270
270
  createTagger,
271
271
  cavemanWordRulesForLanguage,
@@ -274,29 +274,29 @@ import {
274
274
  EmergencyFailClosedError,
275
275
  DegradedPassRefusalError,
276
276
  isSyntheticHeadMessage2
277
- } from "./index-1kbznkft.js";
277
+ } from "./index-axjgxeww.js";
278
278
  import"./index-qgh1qwjj.js";
279
279
  import"./index-qt1qqasc.js";
280
280
  import"./index-kfyb3k6n.js";
281
281
  import"./index-4dhv7mqz.js";
282
282
  import"./index-51rdvtkz.js";
283
- import"./index-rxqr723x.js";
283
+ import"./index-t6j3qxnd.js";
284
284
  import"./index-jjvbk92s.js";
285
285
  import {
286
286
  pushNotification2,
287
287
  isTuiConnected2
288
288
  } from "./index-x8a7jmkh.js";
289
289
  import"./index-rrv26qjz.js";
290
- import"./index-66eby7hx.js";
291
- import"./index-syaazvy2.js";
292
- import"./index-ffzhwfzy.js";
290
+ import"./index-jcr6pe7z.js";
291
+ import"./index-n18sch77.js";
292
+ import"./index-zzrzjnx5.js";
293
293
  import"./index-gp3kcpc4.js";
294
294
  import {
295
295
  detectConflicts
296
296
  } from "./index-4pnsgvfk.js";
297
297
  import"./index-fmsr7v69.js";
298
298
  import"./index-kaqs6h31.js";
299
- import"./index-j32jj2t8.js";
299
+ import"./index-bhyksfyy.js";
300
300
  import {
301
301
  isDreamerRunnable,
302
302
  isSmartNoteSurfaceAvailable,
@@ -4985,12 +4985,18 @@ function applyV2PromptSurfaceTools(draft, runtime, config, smartNotesEnabled = t
4985
4985
  function recordV2ToolDefinitions(draft) {
4986
4986
  if (!draft.tools)
4987
4987
  return;
4988
+ const tools = [];
4988
4989
  for (const [id, tool] of Object.entries(draft.tools)) {
4989
4990
  if (!tool)
4990
4991
  continue;
4991
4992
  recordToolParameters(id, tool.input);
4992
- recordToolDefinition(draft.model.providerID, draft.model.id, draft.agent, id, typeof tool.description === "string" ? tool.description : "", tool.input);
4993
+ tools.push({
4994
+ id,
4995
+ description: typeof tool.description === "string" ? tool.description : "",
4996
+ parameters: tool.input
4997
+ });
4993
4998
  }
4999
+ recordToolDefinitionSet(draft.model.providerID, draft.model.id, draft.agent, tools, draft.sessionID);
4994
5000
  }
4995
5001
  async function applyV2SystemPrompt(systemPrompt, draft) {
4996
5002
  resolveCtxReduceAvailabilityFromMessages(draft.sessionID, draft.messages.map((message) => ({
@@ -5643,7 +5649,7 @@ async function registerContext(context) {
5643
5649
  projectDirectory: directory,
5644
5650
  hardSignals: {
5645
5651
  systemHash: state.systemPromptHash ?? "",
5646
- toolSetHash: getCurrentToolSetHash(draft.model.providerID, draft.model.id, draft.agent),
5652
+ toolSetHash: getCurrentToolSetHash(draft.model.providerID, draft.model.id, draft.agent, draft.sessionID),
5647
5653
  modelKey: `${draft.model.providerID}/${draft.model.id}`,
5648
5654
  cacheExpired: false,
5649
5655
  lastResponseTime: state.lastResponseTime
@@ -6031,7 +6037,7 @@ async function registerContext(context) {
6031
6037
  const model = liveModels.get(sessionId);
6032
6038
  if (!model)
6033
6039
  return "";
6034
- return getCurrentToolSetHash(model.providerID, model.modelID, agents.get(sessionId));
6040
+ return getCurrentToolSetHash(model.providerID, model.modelID, agents.get(sessionId), sessionId);
6035
6041
  },
6036
6042
  channel1StateBySession: channel1,
6037
6043
  historyRefreshSessions,
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  ensureMemoryEmbeddings2
3
- } from "./index-rxqr723x.js";
4
- import"./index-zy67whjr.js";
3
+ } from "./index-t6j3qxnd.js";
4
+ import"./index-z05n7702.js";
5
5
  import"./index-4dhv7mqz.js";
6
6
  import"./index-qt1qqasc.js";
7
7
  import"./index-51rdvtkz.js";
8
8
  import"./index-nxrsns5x.js";
9
9
  import"./index-kfyb3k6n.js";
10
- import"./index-m32esgmj.js";
10
+ import"./index-3d5wnkq7.js";
11
11
  import"./index-wfybj1dw.js";
12
12
  import"./index-kq5w68dp.js";
13
- import"./index-x6cbrv9h.js";
14
- import"./index-jfem3dgz.js";
13
+ import"./index-szf8r0ba.js";
14
+ import"./index-7tdtpqrg.js";
15
15
  import"./index-v0p37hm2.js";
16
16
  import"./index-t5pck3ss.js";
17
17
  import"./index-b88dwwrh.js";
@@ -1 +1 @@
1
- {"version":3,"file":"primer-seed.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/primer-seed.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAA4B,KAAK,MAAM,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEjG;;0BAE0B;AAC1B,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C,MAAM,WAAW,UAAU;IACvB;mDAC+C;IAC/C,IAAI,EAAE,KAAK,GAAG,aAAa,CAAC;IAC5B,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAsED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACvC,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,GACf,eAAe,GAAG,SAAS,CAI7B;AAgDD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAMxE;AAED,uGAAuG;AACvG,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAuB5F"}
1
+ {"version":3,"file":"primer-seed.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/primer-seed.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAA4B,KAAK,MAAM,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEjG;;0BAE0B;AAC1B,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C,MAAM,WAAW,UAAU;IACvB;mDAC+C;IAC/C,IAAI,EAAE,KAAK,GAAG,aAAa,CAAC;IAC5B,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AA0ED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACvC,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,GACf,eAAe,GAAG,SAAS,CAI7B;AAgDD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAMxE;AAED,uGAAuG;AACvG,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAuB5F"}
@@ -1,89 +1,145 @@
1
1
  /**
2
2
  * Tool-definition token measurement store.
3
3
  *
4
- * OpenCode's `tool.definition` hook fires once per tool per
5
- * `ToolRegistry.tools()` call, with `{ toolID }` as input and
6
- * `{ description, parameters }` as output. Crucially the hook input does NOT
7
- * carry `sessionID` — the tool set is computed per
8
- * `{providerID, modelID, agent}` combination, independent of session.
4
+ * Every provider request carries the definitions of the tools offered on it,
5
+ * and those definitions take room in the context window. This store measures
6
+ * them so estimates of a request's size can include them. Each tool's
7
+ * description + JSON-schema parameters is tokenized with the same Claude
8
+ * tokenizer used everywhere else in the plugin and stored per tool under a
9
+ * `${providerID}/${modelID}/${agentName}` route key.
9
10
  *
10
- * We measure each tool's description + JSON-schema parameters, tokenize with
11
- * the same Claude tokenizer used everywhere else in the plugin, and store
12
- * per-tool totals keyed by `${providerID}/${modelID}/${agentName}`. Inner map
13
- * keys on `toolID` so every hook fire idempotently overwrites its own slot
14
- * (same tool set on each turn → same key → same measured total).
11
+ * What a total counts: the tools of the current request. A tool the host
12
+ * stopped offering, or a tool another session was offered, must not add to it
13
+ * for long, and a tool the request does carry must never be left out. The
14
+ * totals feed the 95% size refusal and the replay fits as a trusted figure, so
15
+ * counting too few tools is the dangerous direction; counting a few too many
16
+ * for a while is the safe one. How the current request's tools are known
17
+ * depends on the host:
15
18
  *
16
- * Consumers (RPC sidebar/status handlers) look up the active session's
17
- * measurement via `getMeasuredToolDefinitionTokens(providerID, modelID,
18
- * agentName)`. Returns `undefined` when the key has never been measured — the
19
- * caller is expected to fall back to residual math or show zero.
19
+ * - OpenCode 1 fires its `tool.definition` hook once per tool per
20
+ * `ToolRegistry.tools()` call (once per request, all tools at once, before
21
+ * the messages transform of that request), with `{ toolID }` as input and
22
+ * no session and no "last tool" signal. Calls on one route can run at the
23
+ * same time and their fires interleave, so fires cannot be grouped into
24
+ * requests. Instead a route's total counts every tool fired within
25
+ * `ACTIVITY_WINDOW_MS` of the route's latest fire, measured on the route's
26
+ * own activity clock (see `advanceClock`): idle time does not age a tool,
27
+ * so an idle route keeps its whole set, and a tool leaves only after the
28
+ * route has gone on firing for ten minutes without it.
29
+ * - OpenCode 2 has no such hook, but each request draft carries its whole tool
30
+ * set, so `recordToolDefinitionSet` replaces the route's set with exactly
31
+ * that set and remembers it for the draft's session. A read with that
32
+ * session id returns that session's own set, even when another session on
33
+ * the same route was offered different tools since.
20
34
  *
21
35
  * Persistence (v9+): measurements are also written to SQLite so that a
22
- * plugin restart can repopulate the in-memory map without waiting for the
23
- * next chat.message → tool.definition hook chain. The in-memory Map remains
24
- * the hot read path; SQLite is a write-through mirror that backs cold starts.
25
- * If `setDatabase()` hasn't been called yet (cold path before openDatabase
26
- * completes), `recordToolDefinition` still updates the in-memory map and
27
- * silently skips persistence — first measurement after init lands both.
36
+ * plugin restart can show a "Tool Defs" figure before the first request of
37
+ * the new process. A row is deleted when its tool leaves the route's count,
38
+ * so the table holds each route's recent set. Rows loaded at startup count as
39
+ * if fired at load time: until the route's first live fire, and on OpenCode 1
40
+ * until the route has gone on firing for `ACTIVITY_WINDOW_MS` without them.
41
+ * The exception is rows an older version of this store wrote: it never
42
+ * deleted a row, so its rows can hold every tool a route was ever offered
43
+ * (the overcount reported in GitHub issue 797). Those "legacy" rows count
44
+ * only until the route's first live fire. Which rows are legacy is told by a
45
+ * marker in `schema_migrations_meta` (see `WINDOWED_SINCE_KEY`). If
46
+ * `setDatabase()` hasn't been called yet (cold path before openDatabase
47
+ * completes), measurements still update the in-memory map and are written
48
+ * once a database is bound.
28
49
  *
29
50
  * Hot-path optimization: `tool.definition` fires once per tool per LLM
30
51
  * flight (~58 tools × 5–18ms SQLite write = ~1.4s of redundant work per
31
52
  * flight on large MC databases). Tool descriptions and parameters almost
32
- * never change between flights, so we keep a per-key content-fingerprint
33
- * Map and bail out at the top of `recordToolDefinition` when the new fire
34
- * carries the same fingerprint as the previous one. This collapses
35
- * steady-state hook overhead from ~1.4s to <1ms while still re-measuring
36
- * any tool whose description/schema actually changed (e.g. MCP server
37
- * restart, OpenCode upgrade). Cached prepared statement avoids repeated
38
- * `db.prepare()` compile cost on first-flight rebuilds.
53
+ * never change between flights, so each tool keeps the content fingerprint of
54
+ * its last measurement and an identical fire only refreshes its last-fire
55
+ * time, without tokenizing or writing. A tool that left the count keeps its
56
+ * fingerprint and token count in a small per-route cache, so when it comes
57
+ * back unchanged it is not tokenized again, and its row is written again only
58
+ * if it was actually deleted. Any tool whose description or schema actually
59
+ * changed (e.g. MCP server restart, OpenCode upgrade) is re-measured. Cached
60
+ * prepared statements avoid repeated `db.prepare()` compile cost.
39
61
  */
40
62
  import type { Database } from "../../shared/sqlite";
41
- /**
42
- * Hash the observed names in the provider tool set for one model/agent route.
43
- *
44
- * Tool names alone identify the prefix change this marker explains. Schema
45
- * fingerprints remain necessary for measurement de-duplication, but including
46
- * them here would add cost without improving cache-bust attribution. An empty
47
- * string means the route has not reported any tool definitions, not an empty
48
- * provider `tools` array.
49
- */
50
- export declare function getCurrentToolSetHash(providerID: string, modelID: string, agentName: string | undefined): string;
51
- /** Hash observed tool IDs and full schemas so usage is reused only for the same definitions. */
52
- export declare function getToolDefinitionMeasurementSignature(providerID: string, modelID: string, agentName: string | undefined): string | undefined;
53
63
  /**
54
64
  * Register the database used to persist measurements. Called by
55
65
  * openDatabase() after runMigrations() has ensured the
56
- * `tool_definition_measurements` table exists. Subsequent
57
- * recordToolDefinition() calls will write through to SQLite.
66
+ * `tool_definition_measurements` table exists. Subsequent measurements will
67
+ * write through to SQLite.
58
68
  */
59
69
  export declare function setDatabase(db: Database): void;
60
70
  /**
61
- * Populate the in-memory measurements map from the
62
- * `tool_definition_measurements` table. Called once at startup after
63
- * setDatabase(), before the first sidebar snapshot or status query, so the
64
- * sidebar's "Tool Defs" segment shows the correct value immediately on
65
- * restart instead of 0.
71
+ * Populate the in-memory store from the `tool_definition_measurements` table.
72
+ * Called once at startup after setDatabase(), before the first sidebar
73
+ * snapshot or status query, so the sidebar's "Tool Defs" segment shows a
74
+ * figure immediately on restart instead of 0.
75
+ *
76
+ * Loaded rows count as if their tools fired at load time: they stand in for
77
+ * the route until its first live fire and then, on OpenCode 1, until the
78
+ * route has gone on firing for the activity window without them. A read in
79
+ * the middle of the first request after a restart therefore still counts the
80
+ * stored set. Legacy rows (written before `WINDOWED_SINCE_KEY`, or in a table
81
+ * without it) can hold every tool a route was ever offered, so they stop
82
+ * counting at the route's first live fire. Since this process never measured
83
+ * a loaded row's content, it carries no fingerprint.
66
84
  *
67
85
  * Idempotent: re-running over the same DB reapplies the same values; the
68
- * inner-map key (toolID) ensures duplicates overwrite rather than accumulate.
86
+ * per-route tool key ensures duplicates overwrite rather than accumulate.
87
+ * Routes already measured in this process are left alone.
69
88
  */
70
89
  export declare function loadToolDefinitionMeasurements(db: Database): void;
71
90
  /**
72
- * Tokenize a single tool's schema and store it under the given key. Called
73
- * from the `tool.definition` plugin hook once per tool per flight. Same
74
- * toolID on a later flight overwrites its slot — the total for the key stays
75
- * consistent even if descriptions or parameters drift between turns.
91
+ * OpenCode 1: measure one tool the host is offering on the current request.
92
+ * Called from the `tool.definition` plugin hook once per tool per flight.
93
+ * `sessionId` is the session the request is believed to belong to (the hook
94
+ * carries none); it only records which route that session last flew.
95
+ */
96
+ export declare function recordToolDefinition(providerID: string, modelID: string, agentName: string | undefined, toolID: string, description: string, parameters: unknown, sessionId?: string): void;
97
+ /**
98
+ * OpenCode 2: record the exact tool set one request carries. The route's set
99
+ * becomes exactly `tools` (tools no longer offered are forgotten and their
100
+ * stored rows deleted), and `sessionId`'s figure becomes this set until its
101
+ * next request. Unchanged tools are not tokenized or written again.
102
+ */
103
+ export declare function recordToolDefinitionSet(providerID: string, modelID: string, agentName: string | undefined, tools: Iterable<{
104
+ id: string;
105
+ description: string;
106
+ parameters: unknown;
107
+ }>, sessionId?: string): void;
108
+ /**
109
+ * Hash the tool names of the current tool set for one model/agent route.
110
+ *
111
+ * Tool names alone identify the prefix change this marker explains. Schema
112
+ * fingerprints remain necessary for measurement de-duplication, but including
113
+ * them here would add cost without improving cache-bust attribution. An empty
114
+ * string is returned both before any measurement and for a request that
115
+ * carried no tools; it does not tell those cases apart.
116
+ */
117
+ export declare function getCurrentToolSetHash(providerID: string, modelID: string, agentName: string | undefined, sessionId?: string): string;
118
+ /**
119
+ * Hash the current tool set's IDs and full schemas so provider usage is reused
120
+ * only for the same definitions. Undefined when a counted tool's content was
121
+ * not measured in this process.
122
+ */
123
+ export declare function getToolDefinitionMeasurementSignature(providerID: string, modelID: string, agentName: string | undefined, sessionId?: string): string | undefined;
124
+ /**
125
+ * Returns the measured tokens of the current tool set for a
126
+ * `{provider, model, agent}` route, or `undefined` when never measured (e.g.
127
+ * fresh session before first turn). With `sessionId`, an OpenCode 2 session
128
+ * whose last request flew this route gets that request's exact set.
76
129
  */
77
- export declare function recordToolDefinition(providerID: string, modelID: string, agentName: string | undefined, toolID: string, description: string, parameters: unknown): void;
130
+ export declare function getMeasuredToolDefinitionTokens(providerID: string, modelID: string, agentName: string | undefined, sessionId?: string): number | undefined;
78
131
  /**
79
- * Returns the summed measured tokens for a `{provider, model, agent}` key,
80
- * or `undefined` when never measured (e.g. fresh session before first turn).
132
+ * The tool-definition total of the route `sessionId` last flew: on OpenCode 2
133
+ * the exact set of that session's last request, on OpenCode 1 the route's
134
+ * recent-activity total. For a session whose current route has no
135
+ * measurement yet (for example right after a model switch), this is the best
136
+ * evidence of the tools it is offered; undefined when the session never had
137
+ * its tools measured.
81
138
  */
82
- export declare function getLargestMeasuredToolDefinitionTokens(): number | undefined;
83
- export declare function getMeasuredToolDefinitionTokens(providerID: string, modelID: string, agentName: string | undefined): number | undefined;
139
+ export declare function getSessionToolDefinitionTokens(sessionId: string | undefined): number | undefined;
84
140
  /** Test helper: reset the store so suites don't leak measurements. */
85
141
  export declare function __resetToolDefinitionMeasurements(): void;
86
- /** Inspection helper: snapshot the current store (for debug logging/tests). */
142
+ /** Inspection helper: snapshot each route's current set (for debug logging/tests). */
87
143
  export declare function getToolDefinitionSnapshot(): Array<{
88
144
  key: string;
89
145
  totalTokens: number;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-definition-tokens.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/tool-definition-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,qBAAqB,CAAC;AA0C/D;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACjC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,CAKR;AAED,gGAAgG;AAChG,wBAAgB,qCAAqC,CACjD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,GAAG,SAAS,CAQpB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAK9C;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAkCjE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,OAAO,GACpB,IAAI,CAwEN;AAED;;;GAGG;AACH,wBAAgB,sCAAsC,IAAI,MAAM,GAAG,SAAS,CAQ3E;AAED,wBAAgB,+BAA+B,CAC3C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,GAAG,SAAS,CAOpB;AAED,sEAAsE;AACtE,wBAAgB,iCAAiC,IAAI,IAAI,CAKxD;AAED,+EAA+E;AAC/E,wBAAgB,yBAAyB,IAAI,KAAK,CAAC;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC,CAMD"}
1
+ {"version":3,"file":"tool-definition-tokens.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/tool-definition-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,qBAAqB,CAAC;AAqd/D;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA4B9C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA0CjE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,OAAO,EACnB,SAAS,CAAC,EAAE,MAAM,GACnB,IAAI,CAgCN;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACnC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,KAAK,EAAE,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,EACzE,SAAS,CAAC,EAAE,MAAM,GACnB,IAAI,CAiCN;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACjC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,CAAC,EAAE,MAAM,GACnB,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,qCAAqC,CACjD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,CAAC,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC3C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,CAAC,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAOhG;AAED,sEAAsE;AACtE,wBAAgB,iCAAiC,IAAI,IAAI,CAQxD;AAED,sFAAsF;AACtF,wBAAgB,yBAAyB,IAAI,KAAK,CAAC;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC,CASD"}
@@ -0,0 +1,25 @@
1
+ /** One answer the user gave to a parked ask, as rendered by Prefrontal. */
2
+ export interface AskAnswerNotice {
3
+ /** The question text as Prefrontal rendered it, on one line. */
4
+ question: string;
5
+ /** The user's answer, as Prefrontal rendered it, newlines and all. */
6
+ answer: string;
7
+ }
8
+ /**
9
+ * The one reminder the historian keeps verbatim: the user's own answer to a
10
+ * parked ask, rendered by Prefrontal. Returns one entry per answer notice in
11
+ * delivery order; an empty array for text with no answer notice.
12
+ */
13
+ export declare function extractAskAnswerNotices(text: string): AskAnswerNotice[];
14
+ /** `U (answered "<question>"): <answer>`, the line the historian reads. */
15
+ export declare function formatAskAnswerNotice(notice: AskAnswerNotice): string;
16
+ /**
17
+ * One `U (answered "<question>"): <answer>` line per answer notice in `text`, in
18
+ * delivery order. The chunk readers append these after the user's own words, so a
19
+ * decision the user made by answering an ask reaches the historian as the user's
20
+ * line instead of only as the agent's restatement. A text with no answer notice
21
+ * yields no lines, which leaves every other user message rendered exactly as it
22
+ * was before this existed.
23
+ */
24
+ export declare function askAnswerLines(text: string): string[];
25
+ //# sourceMappingURL=ask-answer-notice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ask-answer-notice.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/ask-answer-notice.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,WAAW,eAAe;IAC5B,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;CAClB;AAiED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,EAAE,CAOvE;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAErE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAErD"}
@@ -1,5 +1,5 @@
1
1
  import type { HiddenCompartmentRunnerDeps } from "./compartment-runner-types";
2
- export declare function v2NonNarrativeStoredGapRanges(db: HiddenCompartmentRunnerDeps["db"], sessionId: string, compartments: ReadonlyArray<{
2
+ export declare function nonNarrativeStoredGapRanges(db: HiddenCompartmentRunnerDeps["db"], sessionId: string, compartments: ReadonlyArray<{
3
3
  startMessage: number;
4
4
  endMessage: number;
5
5
  }>): Array<{
@@ -1 +1 @@
1
- {"version":3,"file":"compartment-runner-incremental.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-incremental.ts"],"names":[],"mappings":"AAuEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAuE9E,wBAAgB,6BAA6B,CACzC,EAAE,EAAE,2BAA2B,CAAC,IAAI,CAAC,EACrC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,aAAa,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,GAC1E,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBvC;AAGD;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,QAAiB,CAAC;AAwBpE,MAAM,WAAW,2BAA2B;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;+EAC+E;AAC/E,wBAAgB,+BAA+B,CAC3C,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACxB,CAAC,EACF,aAAa,GAAE,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAkC,GAC5F,2BAA2B,GAAG,IAAI,CAkBpC;AAED,+DAA+D;AAC/D,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CA4uC1F"}
1
+ {"version":3,"file":"compartment-runner-incremental.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-incremental.ts"],"names":[],"mappings":"AAuEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AA2E9E,wBAAgB,2BAA2B,CACvC,EAAE,EAAE,2BAA2B,CAAC,IAAI,CAAC,EACrC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,aAAa,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,GAC1E,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAwBvC;AAeD;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,QAAiB,CAAC;AAwBpE,MAAM,WAAW,2BAA2B;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,GAAG,KAAK,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;+EAC+E;AAC/E,wBAAgB,+BAA+B,CAC3C,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACxB,CAAC,EACF,aAAa,GAAE,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAkC,GAC5F,2BAA2B,GAAG,IAAI,CAkBpC;AAED,+DAA+D;AAC/D,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAGhE;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAovC1F"}