@cortexkit/opencode-magic-context 0.49.100 → 0.49.103

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 (131) hide show
  1. package/dist/agents/dreamer.d.ts +3 -2
  2. package/dist/agents/dreamer.d.ts.map +1 -1
  3. package/dist/agents/permissions.d.ts +2 -0
  4. package/dist/agents/permissions.d.ts.map +1 -1
  5. package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts +3 -1
  6. package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts.map +1 -1
  7. package/dist/auto-search-worker.js +5 -5
  8. package/dist/chunk-embedding-write-worker.js +1 -1
  9. package/dist/{context-k2tdh146.js → context-jk7bgc3s.js} +227 -43
  10. package/dist/{embedding-backfill-79br4kk6.js → embedding-backfill-anty7zdf.js} +3 -3
  11. package/dist/{embedding-cache-zn4r1c31.js → embedding-cache-dveynq4m.js} +1 -1
  12. package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts +1 -0
  13. package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  15. package/dist/features/magic-context/dreamer/task-prompts.d.ts +7 -1
  16. package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
  17. package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts +2 -1
  18. package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts.map +1 -1
  19. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  20. package/dist/features/magic-context/project-embedding-registry.d.ts +5 -2
  21. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  22. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/host-served-rows.d.ts +7 -0
  25. package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
  26. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  27. package/dist/{index-zyb7tndy.js → index-3nxhxeeg.js} +5 -5
  28. package/dist/{index-esym6cw4.js → index-42fg6tzz.js} +3 -3
  29. package/dist/{index-z1hc2g06.js → index-4536jdzj.js} +2 -2
  30. package/dist/{index-mfx7hzyc.js → index-4dywj733.js} +1 -1
  31. package/dist/{index-63kp05sy.js → index-4v50y0jr.js} +1 -1
  32. package/dist/{index-zg5r2syy.js → index-6gd9akdt.js} +1 -1
  33. package/dist/{index-0tqhr9zs.js → index-6t6v8prs.js} +5 -5
  34. package/dist/{index-0eyxarpb.js → index-7jvc0rhh.js} +100 -28
  35. package/dist/{index-kjhgxkdx.js → index-9jqaha1g.js} +1 -1
  36. package/dist/{index-634cww4x.js → index-9mxkvdtp.js} +9 -9
  37. package/dist/{index-3cgh0ght.js → index-f455a0g3.js} +1 -1
  38. package/dist/{index-6hjbeeth.js → index-jg5whyrd.js} +4 -4
  39. package/dist/{index-qjcye18f.js → index-jjxpmypb.js} +3 -3
  40. package/dist/{index-e6s2jpr8.js → index-jyj9jg9f.js} +2 -2
  41. package/dist/{index-ajmy0v5j.js → index-ke0mkz7g.js} +13 -0
  42. package/dist/{index-txthzqrm.js → index-mes48s7a.js} +152 -75
  43. package/dist/{index-jjy4shhy.js → index-p8nc9axh.js} +1 -1
  44. package/dist/{index-9emdjcb5.js → index-pw1f07vg.js} +1 -1
  45. package/dist/{v2/server-qjwpqvnf.js → index-qbydvfev.js} +4 -3
  46. package/dist/{index-rjxg7a7m.js → index-qzfz2tvk.js} +5 -1
  47. package/dist/{index-n3tebmah.js → index-t2h3484a.js} +8 -8
  48. package/dist/{index-mhdavdd4.js → index-vhx6yph7.js} +11 -8
  49. package/dist/{index-rakm1eay.js → index-zh683xh2.js} +2 -2
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +43 -42
  52. package/dist/{message-index-bounded-289186ah.js → message-index-bounded-8s8sx40x.js} +3 -3
  53. package/dist/migration-worker.js +1 -1
  54. package/dist/plugin/dream-timer.d.ts.map +1 -1
  55. package/dist/plugin/subagent-tool-policy.d.ts.map +1 -1
  56. package/dist/plugin/tool-registry.d.ts.map +1 -1
  57. package/dist/{project-embedding-registry-xy8dcdys.js → project-embedding-registry-4cv7n37m.js} +2 -2
  58. package/dist/raw-ordinal-warmup-worker.js +4 -4
  59. package/dist/{read-session-chunk-frnwxnjg.js → read-session-chunk-wwg20mte.js} +2 -2
  60. package/dist/{recomp-orchestrator-e7n124g0.js → recomp-orchestrator-vg4cxyp7.js} +13 -13
  61. package/dist/{render-argap54x.js → render-f32trg2t.js} +7 -7
  62. package/dist/{search-archive-ads5mh9s.js → search-archive-yh6xtvrx.js} +5 -5
  63. package/dist/{search-fxtb4844.js → search-ygtyb91s.js} +11 -11
  64. package/dist/{storage-memory-hhrvfw0x.js → storage-memory-p91f7b5h.js} +2 -2
  65. package/dist/{storage-tags-2d2ba8e9.js → storage-tags-5nke1bdt.js} +1 -1
  66. package/dist/{store-reader-01e8t5j0.js → store-reader-c5fwa9qx.js} +1 -1
  67. package/dist/{store-235fjtsn.js → store-wpx314rk.js} +2 -2
  68. package/dist/tools/ctx-memory/constants.d.ts +2 -0
  69. package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
  70. package/dist/tools/ctx-memory/tools.d.ts +1 -0
  71. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  72. package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
  73. package/dist/{transform-postprocess-phase-2y0st4gk.js → transform-postprocess-phase-958fmjs5.js} +14 -14
  74. package/dist/v2/auto-search-worker.js +5 -5
  75. package/dist/v2/chunk-embedding-write-worker.js +1 -1
  76. package/dist/v2/{context-v56v40cx.js → context-3g3jvxg8.js} +347 -88
  77. package/dist/v2/{embedding-backfill-nhgp8znm.js → embedding-backfill-ra9gbbs4.js} +3 -3
  78. package/dist/v2/{embedding-cache-zn4r1c31.js → embedding-cache-dveynq4m.js} +1 -1
  79. package/dist/v2/fold/instruction-supersession.d.ts +18 -1
  80. package/dist/v2/fold/instruction-supersession.d.ts.map +1 -1
  81. package/dist/v2/hooks/context.d.ts +2 -1
  82. package/dist/v2/hooks/context.d.ts.map +1 -1
  83. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  84. package/dist/v2/hooks/revert-message-state.d.ts +6 -0
  85. package/dist/v2/hooks/revert-message-state.d.ts.map +1 -1
  86. package/dist/v2/hooks/tools.d.ts.map +1 -1
  87. package/dist/v2/{message-index-bounded-p69v4wpy.js → message-index-bounded-j1sxtefe.js} +3 -3
  88. package/dist/v2/migration-worker.js +1 -1
  89. package/dist/v2/{project-embedding-registry-qz9x79kn.js → project-embedding-registry-gdaqb7h0.js} +2 -2
  90. package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
  91. package/dist/v2/{read-session-chunk-qzw3vedr.js → read-session-chunk-p6z3kmdj.js} +2 -2
  92. package/dist/v2/{recomp-orchestrator-5gkzamy2.js → recomp-orchestrator-29m3cc5b.js} +12 -12
  93. package/dist/v2/{render-atxj9eaf.js → render-jpj43axy.js} +7 -7
  94. package/dist/v2/{search-archive-vgwnvdx2.js → search-archive-wbhxp0p1.js} +5 -5
  95. package/dist/v2/{search-51qr14ed.js → search-ybyc7vmx.js} +10 -10
  96. package/dist/v2/{server-bhr92yb4.js → server-1qxdyz4p.js} +2 -2
  97. package/dist/v2/{server-8vby30m5.js → server-8f92sd2r.js} +2 -2
  98. package/dist/v2/{server-08jh9wew.js → server-8m5wk6aq.js} +5 -5
  99. package/dist/v2/{server-606mnrv4.js → server-9ms9b75c.js} +5 -1
  100. package/dist/v2/{server-s3m2y97h.js → server-b01a7dhj.js} +1 -1
  101. package/dist/v2/{server-rwdp3hw6.js → server-df5scn4q.js} +71 -11
  102. package/dist/v2/{server-7wpw3wc6.js → server-fagcnt6j.js} +11 -8
  103. package/dist/v2/{server-b25nvm9c.js → server-ga6y57vh.js} +1 -1
  104. package/dist/v2/{server-2ek9exbe.js → server-kx5egpt7.js} +3 -3
  105. package/dist/v2/{server-e14d7ebh.js → server-mc5t7k8v.js} +1 -1
  106. package/dist/v2/{server-9emdjcb5.js → server-pw1f07vg.js} +1 -1
  107. package/dist/{index-qjwpqvnf.js → v2/server-qbydvfev.js} +4 -3
  108. package/dist/v2/{server-c1vcbszm.js → server-qdpd8h27.js} +1 -1
  109. package/dist/v2/{server-ysg14rv1.js → server-qg8jyfxa.js} +13 -0
  110. package/dist/v2/{server-d2a639dg.js → server-r851hxn5.js} +8 -8
  111. package/dist/v2/{server-p2wxmjc3.js → server-t45hgcsg.js} +2 -2
  112. package/dist/v2/{server-awth2wsg.js → server-x22jtpna.js} +1 -1
  113. package/dist/v2/{server-wdmcqhv6.js → server-xpy46ddq.js} +3 -3
  114. package/dist/v2/server.js +2 -2
  115. package/dist/v2/{storage-memory-hhrvfw0x.js → storage-memory-p91f7b5h.js} +2 -2
  116. package/dist/v2/{storage-tags-4t9fb4ch.js → storage-tags-s7nvvyg8.js} +1 -1
  117. package/dist/v2/{store-0kjfynwp.js → store-mba47sxn.js} +2 -2
  118. package/dist/v2/{store-reader-w0srb18d.js → store-reader-w7w8vfsy.js} +1 -1
  119. package/dist/v2/store-reader.d.ts +7 -0
  120. package/dist/v2/store-reader.d.ts.map +1 -1
  121. package/dist/v2/{v2-archive-reader-1wc5wb1a.js → v2-archive-reader-5njmg3a3.js} +1 -1
  122. package/dist/v2/{wrapup-orchestrator-ksdn2emb.js → wrapup-orchestrator-ahkq8a61.js} +12 -12
  123. package/dist/{v2-archive-reader-4pk46nc1.js → v2-archive-reader-y38khjax.js} +1 -1
  124. package/dist/{wrapup-orchestrator-sc2fsfct.js → wrapup-orchestrator-gjqaac65.js} +14 -14
  125. package/package.json +1 -1
  126. package/src/agents/dreamer.ts +3 -2
  127. package/src/agents/hidden-agent-registrations.ts +2 -2
  128. package/src/agents/permissions.test.ts +89 -3
  129. package/src/agents/permissions.ts +32 -0
  130. package/src/agents/smart-notes-dreamer-gate.fixture.ts +27 -4
  131. package/src/agents/smart-notes-dreamer-gate.test.ts +5 -1
@@ -11,7 +11,8 @@ export declare const DREAMER_DOCS_AGENT = "dreamer-docs";
11
11
  export declare const DREAMER_DOCS_ALLOWED_TOOLS: readonly ["read", "grep", "glob", "aft_outline", "aft_zoom", "aft_search"];
12
12
  export declare const DREAMER_REVIEWER_AGENT = "dreamer-reviewer";
13
13
  /** Curate receives its category snapshot from the host and edits memories via
14
- * ctx_memory. It does not read code; the verify task checks memory accuracy.
14
+ * ctx_memory_curate. Plain ctx_memory is still accepted for older callers.
15
+ * It does not read code; the verify task checks memory accuracy.
15
16
  * Keep the `dreamer` id because memory-tool authorization matches that id. */
16
- export declare const DREAMER_CURATE_ALLOWED_TOOLS: readonly ["ctx_memory"];
17
+ export declare const DREAMER_CURATE_ALLOWED_TOOLS: readonly ["ctx_memory", "ctx_memory_curate"];
17
18
  //# sourceMappingURL=dreamer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dreamer.d.ts","sourceRoot":"","sources":["../../src/agents/dreamer.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,2BAA2B,0BAA0B,CAAC;AAOnE,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAQ/E,eAAO,MAAM,2BAA2B,0BAA0B,CAAC;AAEnE;0EAC0E;AAC1E,eAAO,MAAM,mCAAmC,4EAOtC,CAAC;AAMX,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAG7D,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,yDAAyD;AACzD,eAAO,MAAM,0BAA0B,4EAO7B,CAAC;AAKX,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AAEzD;;+EAE+E;AAC/E,eAAO,MAAM,4BAA4B,yBAA0B,CAAC"}
1
+ {"version":3,"file":"dreamer.d.ts","sourceRoot":"","sources":["../../src/agents/dreamer.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,2BAA2B,0BAA0B,CAAC;AAOnE,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAQ/E,eAAO,MAAM,2BAA2B,0BAA0B,CAAC;AAEnE;0EAC0E;AAC1E,eAAO,MAAM,mCAAmC,4EAOtC,CAAC;AAMX,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAG7D,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAEjD,yDAAyD;AACzD,eAAO,MAAM,0BAA0B,4EAO7B,CAAC;AAKX,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AAEzD;;;+EAG+E;AAC/E,eAAO,MAAM,4BAA4B,8CAA+C,CAAC"}
@@ -93,6 +93,8 @@ export declare function denyTaskRoutingToAgents(permission: unknown, internalAge
93
93
  * seed only the built-in interactive callers and configured primary agents.
94
94
  */
95
95
  export declare function denyTaskRoutingToCallerAgents(agentConfigs: Record<string, Record<string, unknown>>, internalAgentIds: readonly string[]): Record<string, Record<string, unknown>>;
96
+ /** OpenCode 1 appends agent rules after global rules, and the last match wins. */
97
+ export declare function denyCurateToolToOtherAgents(agentConfigs: Record<string, Record<string, unknown>>): Record<string, Record<string, unknown>>;
96
98
  /** Historians summarize the supplied transcript; no file access or tools are needed. */
97
99
  export declare const HISTORIAN_ALLOWED_TOOLS: readonly [];
98
100
  /**
@@ -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;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CACnC,UAAU,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,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;AAWD,kFAAkF;AAClF,wBAAgB,2BAA2B,CACvC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACtD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAgBzC;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"}
@@ -2,7 +2,7 @@ import type { MagicContextPluginConfig } from "../config";
2
2
  import type { Database } from "../shared/sqlite";
3
3
  export declare const GATE_CASE_COUNT = 240;
4
4
  export declare function gateCases(): Record<string, unknown>[];
5
- /** `note` digests ctx_note's { description, schema }; `other` digests every other tool. */
5
+ /** `note` digests ctx_note's { description, schema }; `other` digests the other legacy registrations. */
6
6
  export interface HostDigests {
7
7
  note: string;
8
8
  other: string;
@@ -12,6 +12,8 @@ export interface ToolSurfaceDigests {
12
12
  oc1: HostDigests;
13
13
  /** OpenCode 2 registration after the per-request description rewrite. */
14
14
  oc2: HostDigests;
15
+ /** Dreamer-only tools added after the original OpenCode 2 registration capture. */
16
+ oc2DreamerOnly: Record<string, string>;
15
17
  /** Full text per host, kept out of the golden; used for content checks. */
16
18
  text: {
17
19
  oc1: string;
@@ -1 +1 @@
1
- {"version":3,"file":"smart-notes-dreamer-gate.fixture.d.ts","sourceRoot":"","sources":["../../src/agents/smart-notes-dreamer-gate.fixture.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAG1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,eAAO,MAAM,eAAe,MAAM,CAAC;AAmCnC,wBAAgB,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAgBrD;AAKD,2FAA2F;AAC3F,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IAC/B,2BAA2B;IAC3B,GAAG,EAAE,WAAW,CAAC;IACjB,yEAAyE;IACzE,GAAG,EAAE,WAAW,CAAC;IACjB,2EAA2E;IAC3E,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACtC;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,wBAAwB,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,QAAQ,CAAC;IACb,uEAAuE;IACvE,aAAa,EAAE,OAAO,CAAC;CAC1B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAoE9B"}
1
+ {"version":3,"file":"smart-notes-dreamer-gate.fixture.d.ts","sourceRoot":"","sources":["../../src/agents/smart-notes-dreamer-gate.fixture.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAG1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAQjD,eAAO,MAAM,eAAe,MAAM,CAAC;AAmCnC,wBAAgB,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAgBrD;AAKD,yGAAyG;AACzG,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IAC/B,2BAA2B;IAC3B,GAAG,EAAE,WAAW,CAAC;IACjB,yEAAyE;IACzE,GAAG,EAAE,WAAW,CAAC;IACjB,mFAAmF;IACnF,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,2EAA2E;IAC3E,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACtC;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,wBAAwB,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,QAAQ,CAAC;IACb,uEAAuE;IACvE,aAAa,EAAE,OAAO,CAAC;CAC1B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAoF9B"}
@@ -27,11 +27,11 @@ serveWorkerJobs(async (initial, port) => {
27
27
  { Database, registerSqliteDiagnosticSink },
28
28
  { log }
29
29
  ] = await Promise.all([
30
- import("./embedding-backfill-79br4kk6.js"),
31
- import("./embedding-cache-zn4r1c31.js"),
32
- import("./storage-memory-hhrvfw0x.js"),
33
- import("./project-embedding-registry-xy8dcdys.js"),
34
- import("./search-fxtb4844.js"),
30
+ import("./embedding-backfill-anty7zdf.js"),
31
+ import("./embedding-cache-dveynq4m.js"),
32
+ import("./storage-memory-p91f7b5h.js"),
33
+ import("./project-embedding-registry-4cv7n37m.js"),
34
+ import("./search-ygtyb91s.js"),
35
35
  import("./compartment-chunk-embedding-gnemmf79.js"),
36
36
  import("./embedding-activity-g1dhes6g.js"),
37
37
  import("./harness-e4avh192.js"),
@@ -36,7 +36,7 @@ import"./index-vegw385y.js";
36
36
  import {
37
37
  LATEST_SUPPORTED_VERSION,
38
38
  enforceSchemaFence
39
- } from "./index-3cgh0ght.js";
39
+ } from "./index-f455a0g3.js";
40
40
  import"./index-8k9qpyjf.js";
41
41
  import"./index-hyvxmz3e.js";
42
42
  import"./index-xtv4d4hv.js";
@@ -1,4 +1,7 @@
1
1
  import {
2
+ CTX_MEMORY_CURATE_TOOL_NAME,
3
+ DREAMER_ONLY_MEMORY_TOOL_NAMES,
4
+ DREAMER_AGENT,
2
5
  getMagicContextBuiltinCommands,
3
6
  getProtectedTokensTierOverrides,
4
7
  loadPluginConfigDetailed,
@@ -51,7 +54,7 @@ import {
51
54
  clearNoteNudgeTriggerOnly,
52
55
  nonNarrativeStoredGapRanges,
53
56
  getActiveCompartmentRun
54
- } from "./index-0eyxarpb.js";
57
+ } from "./index-7jvc0rhh.js";
55
58
  import"./index-sd3egckz.js";
56
59
  import {
57
60
  getHarness2
@@ -141,7 +144,7 @@ import {
141
144
  storedSubagentMode,
142
145
  createCtxExpandTools,
143
146
  createCtxMemoryTools,
144
- createCtxMemoryListTools,
147
+ createDreamerMemoryTools,
145
148
  CTX_NOTE_DESCRIPTION,
146
149
  withoutSmartNoteText,
147
150
  createCtxNoteTools,
@@ -150,7 +153,7 @@ import {
150
153
  applyJsonSchemaParameterDescriptions,
151
154
  MagicContextRpcServer,
152
155
  subagentTemperature
153
- } from "./index-txthzqrm.js";
156
+ } from "./index-mes48s7a.js";
154
157
  import {
155
158
  invalidateAutoEmbedSession,
156
159
  clearEmbedSessionState
@@ -216,8 +219,8 @@ import {
216
219
  getSlot,
217
220
  dropSlot,
218
221
  copySessionStateForClone
219
- } from "./index-z1hc2g06.js";
220
- import"./index-jjy4shhy.js";
222
+ } from "./index-4536jdzj.js";
223
+ import"./index-p8nc9axh.js";
221
224
  import {
222
225
  stripPersistedAssistantText,
223
226
  currentReclaimableToolOutputCount,
@@ -267,7 +270,7 @@ import {
267
270
  estimateFinalWireInputTokens,
268
271
  getMaxTagNumberBySession2,
269
272
  getTagsBySession2
270
- } from "./index-rjxg7a7m.js";
273
+ } from "./index-qzfz2tvk.js";
271
274
  import {
272
275
  BoundedSessionMap,
273
276
  getTableColumnNames,
@@ -310,10 +313,10 @@ import {
310
313
  cleanUserText2,
311
314
  readRawSessionMessageIdOrdinalsForRange2,
312
315
  readRawSessionMessageOrdinalById2
313
- } from "./index-kjhgxkdx.js";
316
+ } from "./index-9jqaha1g.js";
314
317
  import {
315
318
  scheduleClearAndReindex
316
- } from "./index-63kp05sy.js";
319
+ } from "./index-4v50y0jr.js";
317
320
  import {
318
321
  startBootDeadline,
319
322
  getSchemaFenceRejection,
@@ -323,7 +326,7 @@ import {
323
326
  openDatabaseAsync,
324
327
  isDatabasePersisted,
325
328
  getDatabasePersistenceError
326
- } from "./index-3cgh0ght.js";
329
+ } from "./index-f455a0g3.js";
327
330
  import"./index-fr0wbhdn.js";
328
331
  import"./index-hyvxmz3e.js";
329
332
  import {
@@ -331,7 +334,7 @@ import {
331
334
  RAW_MESSAGE_TYPES2,
332
335
  V2StoreReaderPool2,
333
336
  V2StoreReader2
334
- } from "./index-ajmy0v5j.js";
337
+ } from "./index-ke0mkz7g.js";
335
338
  import"./index-fb3zxn06.js";
336
339
  import"./index-ab86c21b.js";
337
340
  import {
@@ -353,21 +356,21 @@ import {
353
356
  servedHeadChanged,
354
357
  noteHostCheckpointCommit,
355
358
  isSyntheticHeadMessage2
356
- } from "./index-n3tebmah.js";
359
+ } from "./index-t2h3484a.js";
357
360
  import"./index-qxzk5s30.js";
358
361
  import"./index-qt1qqasc.js";
359
362
  import {
360
363
  retainProjectEmbedding2
361
- } from "./index-mhdavdd4.js";
364
+ } from "./index-vhx6yph7.js";
362
365
  import"./index-fd3hkyk1.js";
363
- import"./index-qjwpqvnf.js";
366
+ import"./index-qbydvfev.js";
364
367
  import"./index-nyjztqyj.js";
365
368
  import {
366
369
  renderUserFacingFailure,
367
370
  userFacingFailureCode
368
- } from "./index-esym6cw4.js";
369
- import"./index-e6s2jpr8.js";
370
- import"./index-9emdjcb5.js";
371
+ } from "./index-42fg6tzz.js";
372
+ import"./index-jyj9jg9f.js";
373
+ import"./index-pw1f07vg.js";
371
374
  import {
372
375
  pushLiveNotification2,
373
376
  pushNotification2,
@@ -375,8 +378,8 @@ import {
375
378
  } from "./index-y14pawe1.js";
376
379
  import"./index-y5f5yg5a.js";
377
380
  import"./index-61a853ky.js";
378
- import"./index-634cww4x.js";
379
- import"./index-6hjbeeth.js";
381
+ import"./index-9mxkvdtp.js";
382
+ import"./index-jg5whyrd.js";
380
383
  import"./index-cayqdwf9.js";
381
384
  import {
382
385
  detectConflicts
@@ -406,12 +409,12 @@ import {
406
409
  readV2RawMessagePagesForConversion2,
407
410
  createV2RawMessageReader2,
408
411
  createV2RawMessageProvider2
409
- } from "./index-mfx7hzyc.js";
412
+ } from "./index-4dywj733.js";
410
413
  import"./index-fmsr7v69.js";
411
- import"./index-rakm1eay.js";
412
- import"./index-zg5r2syy.js";
413
- import"./index-zyb7tndy.js";
414
- import"./index-qjcye18f.js";
414
+ import"./index-zh683xh2.js";
415
+ import"./index-6gd9akdt.js";
416
+ import"./index-3nxhxeeg.js";
417
+ import"./index-jjxpmypb.js";
415
418
  import {
416
419
  markHostInstructionRow,
417
420
  hostInstructionRow,
@@ -1105,6 +1108,82 @@ var coveredOn = (value) => typeof value === "object" && value !== null && value.
1105
1108
  function retiredLiveInstructionIDs(db, sessionID) {
1106
1109
  return decode(readReplayEnvelope(db, sessionID)[namespace]);
1107
1110
  }
1111
+ var throughNamespace = "instructionSupersessionThrough";
1112
+ function decodeThrough(value, sessionID) {
1113
+ if (value === undefined)
1114
+ return { kind: "absent" };
1115
+ const { session, through } = value ?? {};
1116
+ if (typeof session !== "string" || session.length === 0 || typeof through !== "number" || !Number.isSafeInteger(through) || through < -1)
1117
+ throw new Error("Invalid instruction supersession replay state");
1118
+ return session === sessionID ? { kind: "own", through } : { kind: "foreign" };
1119
+ }
1120
+ var pendingLowerings = new WeakMap;
1121
+ function pendingLowering(db, sessionID) {
1122
+ return pendingLowerings.get(db)?.get(sessionID);
1123
+ }
1124
+ function setPendingLowering(db, sessionID, through) {
1125
+ let sessions = pendingLowerings.get(db);
1126
+ if (!sessions)
1127
+ pendingLowerings.set(db, sessions = new Map);
1128
+ sessions.set(sessionID, { through });
1129
+ }
1130
+ function clearPendingLowering(db, sessionID, pending) {
1131
+ const sessions = pendingLowerings.get(db);
1132
+ if (sessions?.get(sessionID) === pending)
1133
+ sessions.delete(sessionID);
1134
+ }
1135
+ function readThrough(db, sessionID) {
1136
+ const stored = decodeThrough(readReplayEnvelope(db, sessionID)[throughNamespace], sessionID);
1137
+ const pending = pendingLowering(db, sessionID);
1138
+ return stored.kind === "own" && pending && pending.through < stored.through ? { kind: "own", through: pending.through } : stored;
1139
+ }
1140
+ function isRetiredThrough(row, through) {
1141
+ return row.seq <= through && isMarkedInstructionUpdate(row);
1142
+ }
1143
+ var revertCounts = new WeakMap;
1144
+ function revertCount(db, sessionID) {
1145
+ return revertCounts.get(db)?.get(sessionID) ?? 0;
1146
+ }
1147
+ function lowerRetiredInstructionThrough(db, sessionID, before) {
1148
+ let sessions = revertCounts.get(db);
1149
+ if (!sessions)
1150
+ revertCounts.set(db, sessions = new Map);
1151
+ sessions.set(sessionID, revertCount(db, sessionID) + 1);
1152
+ return saveLowering(db, sessionID, before);
1153
+ }
1154
+ function saveLowering(db, sessionID, before) {
1155
+ const pending = pendingLowering(db, sessionID);
1156
+ const limit = Math.min(before ?? -1, pending?.through ?? Number.POSITIVE_INFINITY);
1157
+ let failure = "the replay document could not be written";
1158
+ let saved = false;
1159
+ try {
1160
+ saved = updateReplayDocument(db, sessionID, (doc) => {
1161
+ const current = decodeThrough(doc[throughNamespace], sessionID);
1162
+ if (current.kind !== "own" || current.through <= limit)
1163
+ return false;
1164
+ doc.version = 2;
1165
+ doc[throughNamespace] = { session: sessionID, through: limit };
1166
+ return true;
1167
+ });
1168
+ } catch (error) {
1169
+ failure = error;
1170
+ }
1171
+ if (saved) {
1172
+ if (pending)
1173
+ clearPendingLowering(db, sessionID, pending);
1174
+ return true;
1175
+ }
1176
+ if (pending?.through !== limit) {
1177
+ setPendingLowering(db, sessionID, limit);
1178
+ sessionLog2(sessionID, "committed revert: retired instruction rows kept lowered in memory until saved:", failure);
1179
+ }
1180
+ return false;
1181
+ }
1182
+ function retryRetiredInstructionLowering(db, sessionID) {
1183
+ const pending = pendingLowering(db, sessionID);
1184
+ if (pending)
1185
+ saveLowering(db, sessionID, pending.through);
1186
+ }
1108
1187
  function coveredInstructionSupersessionOn(db, sessionID) {
1109
1188
  return coveredOn(readReplayEnvelope(db, sessionID)[coveredNamespace]);
1110
1189
  }
@@ -1159,7 +1238,8 @@ function isMarkedInstructionUpdate(row) {
1159
1238
  const sources = metadata.instructionSources;
1160
1239
  return row.type === "system" && "notice" in metadata && metadata.notice === "instructions" && Array.isArray(sources) && sources.length > 0 && sources.every((source) => typeof source === "string" && source.length > 0);
1161
1240
  }
1162
- function reclaimInstructionRows(db, sessionID, messages, permitted, folded = new Set, covered = [], checkpointSequence, checkpointCoveredThrough) {
1241
+ function reclaimInstructionRows(db, sessionID, messages, permitted, folded = new Map, covered = [], checkpointSequence, checkpointCoveredThrough, localCheckpointSequence) {
1242
+ const builtAfterReverts = revertCount(db, sessionID);
1163
1243
  const instructionRows = (list) => list.flatMap((message) => {
1164
1244
  const row = hostInstructionRow(message.info);
1165
1245
  return row ? [{ message, row }] : [];
@@ -1167,7 +1247,19 @@ function reclaimInstructionRows(db, sessionID, messages, permitted, folded = new
1167
1247
  const coveredRows = coveredSupersessionEnabled ? instructionRows(covered) : [];
1168
1248
  const rows = [...coveredRows, ...instructionRows(messages)];
1169
1249
  const coveredMessages = new Set(coveredRows.map(({ message }) => message));
1170
- const retired = rows.length ? retiredLiveInstructionIDs(db, sessionID) : new Set;
1250
+ const retired = new Set(rows.length ? retiredLiveInstructionIDs(db, sessionID) : []);
1251
+ let stored = { kind: "foreign" };
1252
+ if (rows.length)
1253
+ stored = readThrough(db, sessionID);
1254
+ else if (checkpointSequence !== undefined) {
1255
+ try {
1256
+ stored = readThrough(db, sessionID);
1257
+ } catch {}
1258
+ }
1259
+ const through = stored.kind === "own" ? stored.through : -1;
1260
+ for (const { row } of rows)
1261
+ if (isRetiredThrough(row, through))
1262
+ retired.add(row.id);
1171
1263
  const coveredFollowed = rows.length > 0 && (coveredRows.length > 0 || permitted) && coveredInstructionSupersessionOn(db, sessionID);
1172
1264
  const switchCovered = permitted && rows.length > 0 && !coveredFollowed && coveredSupersessionEnabled;
1173
1265
  const selected = permitted ? supersededInstructionIDs(rows.map(({ row }) => row)) : new Set;
@@ -1180,6 +1272,13 @@ function reclaimInstructionRows(db, sessionID, messages, permitted, folded = new
1180
1272
  const newlyRetired = new Set([...selected].filter((id) => !retired.has(id)));
1181
1273
  const omitted = new Set([...retired, ...newlyRetired]);
1182
1274
  const omits = (message, id) => omitted.has(id) && (!coveredMessages.has(message) || coveredFollowed || switchCovered);
1275
+ let servedFrom = Number.POSITIVE_INFINITY;
1276
+ for (const { message, row } of rows) {
1277
+ if (isMarkedInstructionUpdate(row) && !omits(message, row.id))
1278
+ servedFrom = Math.min(servedFrom, row.seq);
1279
+ }
1280
+ const coverable = (seq) => Math.min(seq, servedFrom - 1);
1281
+ const initialThrough = stored.kind === "absent" && localCheckpointSequence !== undefined ? Math.max(-1, coverable(localCheckpointSequence - 1)) : undefined;
1183
1282
  const edits = [];
1184
1283
  for (const { message, row } of rows) {
1185
1284
  if (!omits(message, row.id))
@@ -1189,33 +1288,81 @@ function reclaimInstructionRows(db, sessionID, messages, permitted, folded = new
1189
1288
  edits.push(message);
1190
1289
  message.parts = [];
1191
1290
  }
1291
+ const decisions = newlyRetired.size > 0 || switchCovered;
1292
+ const pending = pendingLowering(db, sessionID);
1293
+ let wrote;
1192
1294
  return {
1193
1295
  edits,
1194
- hasDecisions: newlyRetired.size > 0 || switchCovered,
1296
+ hasDecisions: decisions,
1195
1297
  record(doc) {
1196
- if (newlyRetired.size === 0 && !switchCovered)
1298
+ if (!decisions)
1197
1299
  return false;
1198
1300
  const current = decode(doc[namespace]);
1199
1301
  if ([...newlyRetired].every((id) => current.has(id)) && (!switchCovered || coveredOn(doc[coveredNamespace])))
1200
1302
  return false;
1201
- for (const id of folded)
1202
- current.delete(id);
1303
+ const storedNow = decodeThrough(doc[throughNamespace], sessionID);
1304
+ let nextThrough = storedNow.kind === "own" ? Math.min(storedNow.through, pending?.through ?? Number.POSITIVE_INFINITY) : undefined;
1305
+ let dropped = -1;
1306
+ if (revertCount(db, sessionID) === builtAfterReverts) {
1307
+ for (const [id, seq] of folded) {
1308
+ if (current.delete(id) && Number.isFinite(seq))
1309
+ dropped = Math.max(dropped, seq);
1310
+ }
1311
+ }
1203
1312
  for (const id of newlyRetired)
1204
1313
  current.add(id);
1314
+ if (coverable(dropped) >= 0)
1315
+ nextThrough = Math.max(nextThrough ?? -1, coverable(dropped));
1205
1316
  doc.version = 2;
1206
1317
  doc[namespace] = [...current];
1207
1318
  if (switchCovered)
1208
1319
  doc[coveredNamespace] = { on: true };
1320
+ wrote = undefined;
1321
+ if (nextThrough !== undefined && (storedNow.kind !== "own" || nextThrough !== storedNow.through)) {
1322
+ doc[throughNamespace] = { session: sessionID, through: nextThrough };
1323
+ wrote = nextThrough;
1324
+ }
1209
1325
  return true;
1210
1326
  },
1211
1327
  markRetired() {
1328
+ if (pending && wrote !== undefined)
1329
+ clearPendingLowering(db, sessionID, pending);
1212
1330
  for (const { message, row } of rows) {
1213
1331
  if (omits(message, row.id))
1214
1332
  markRetiredInstructionRow(message.info);
1215
1333
  }
1334
+ },
1335
+ settle() {
1336
+ if (initialThrough === undefined || revertCount(db, sessionID) !== builtAfterReverts)
1337
+ return;
1338
+ const initial = initialThrough;
1339
+ let failure = "the replay document could not be written";
1340
+ try {
1341
+ const saved = updateReplayDocument(db, sessionID, (doc) => {
1342
+ const now = decodeThrough(doc[throughNamespace], sessionID);
1343
+ const raisable = now.kind === "absent" || now.kind === "own" && wrote !== undefined && now.through === wrote && wrote < initial;
1344
+ if (!raisable)
1345
+ return false;
1346
+ doc.version = 2;
1347
+ doc[throughNamespace] = { session: sessionID, through: initial };
1348
+ return true;
1349
+ });
1350
+ if (saved)
1351
+ return;
1352
+ } catch (error) {
1353
+ failure = error;
1354
+ }
1355
+ let logged = initialFailuresLogged.get(db);
1356
+ if (!logged)
1357
+ initialFailuresLogged.set(db, logged = new Set);
1358
+ if (logged.has(sessionID))
1359
+ return;
1360
+ logged.add(sessionID);
1361
+ sessionLog2(sessionID, "retired instruction rows: value from the checkpoint not saved; a later pass tries again:", failure);
1216
1362
  }
1217
1363
  };
1218
1364
  }
1365
+ var initialFailuresLogged = new WeakMap;
1219
1366
 
1220
1367
  // src/v2/fold/manual-baseline.ts
1221
1368
  var text = (value) => value == null ? null : typeof value === "string" ? value : Buffer.from(value).toString("utf8");
@@ -7094,8 +7241,10 @@ class V2RevertMessageCleanup {
7094
7241
  const reader = this.openStoreReader();
7095
7242
  try {
7096
7243
  const suffix = reader.revertSuffix(sessionID, cutoff, MAX_STAGED_SUFFIX_ROWS);
7097
- this.staged.set(sessionID, suffix ? { cutoff, host: reader.hostIdentity(), suffix } : {
7244
+ const before = suffix ? suffix.predecessor.seq : reader.sequenceBefore(sessionID, cutoff);
7245
+ this.staged.set(sessionID, suffix ? { cutoff, host: reader.hostIdentity(), suffix, before } : {
7098
7246
  cutoff,
7247
+ before,
7099
7248
  unavailable: "stage did not prove a bounded suffix and retained predecessor"
7100
7249
  });
7101
7250
  } finally {
@@ -7105,6 +7254,10 @@ class V2RevertMessageCleanup {
7105
7254
  this.staged.set(sessionID, { cutoff, unavailable: "host store read failed at stage" });
7106
7255
  }
7107
7256
  }
7257
+ stagedPredecessor(sessionID, to) {
7258
+ const staged = this.staged.peek(sessionID);
7259
+ return staged && staged.cutoff === to ? staged.before : undefined;
7260
+ }
7108
7261
  discardStageProof(sessionID) {
7109
7262
  this.staged.delete(sessionID);
7110
7263
  }
@@ -7408,7 +7561,7 @@ async function registerTools(context, db, config, rustToolBackends, isInternalCh
7408
7561
  ...project,
7409
7562
  ...rustToolBackends ? { rustToolBackends } : {}
7410
7563
  }),
7411
- ...createCtxMemoryListTools({
7564
+ ...createDreamerMemoryTools({
7412
7565
  ...project,
7413
7566
  ...rustToolBackends ? { rustToolBackends } : {}
7414
7567
  })
@@ -7426,7 +7579,7 @@ async function registerTools(context, db, config, rustToolBackends, isInternalCh
7426
7579
  const refusal = subagentToolRefusal(db, name, call.sessionID, isInternalChild);
7427
7580
  if (refusal)
7428
7581
  return { content: refusal };
7429
- if (name === "ctx_memory" || name === "ctx_note" || name === "ctx_reduce")
7582
+ if (name === "ctx_memory" || name === "ctx_note" || name === "ctx_reduce" || name === CTX_MEMORY_CURATE_TOOL_NAME && call.agent === DREAMER_AGENT)
7430
7583
  await withAsyncPrivilegedWriter2(db, () => {
7431
7584
  return;
7432
7585
  });
@@ -8020,9 +8173,11 @@ function catalogModels(listed, draftModel) {
8020
8173
  }
8021
8174
  return models;
8022
8175
  }
8023
- function removeDreamerOnlyTools(draft) {
8024
- if (draft.tools)
8025
- delete draft.tools.ctx_memory_list;
8176
+ function removeDreamerOnlyTools(draft, ids = DREAMER_ONLY_MEMORY_TOOL_NAMES) {
8177
+ if (!draft.tools)
8178
+ return;
8179
+ for (const id of ids)
8180
+ delete draft.tools[id];
8026
8181
  }
8027
8182
  function applyV2PromptSurfaceTools(draft, runtime, config, smartNotesEnabled = true) {
8028
8183
  if (!draft.tools)
@@ -8866,6 +9021,27 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
8866
9021
  }
8867
9022
  };
8868
9023
  const usageController = new AbortController;
9024
+ const lowerRetiredInstructionsOnRevert = (database, sessionID, event) => {
9025
+ try {
9026
+ let before = revertMessageCleanup.stagedPredecessor(sessionID, event.data?.to);
9027
+ const commitSeq = event.durable?.seq;
9028
+ if (before === undefined && event.durable?.aggregateID === sessionID && typeof commitSeq === "number" && Number.isSafeInteger(commitSeq)) {
9029
+ const reader = openStoreReader();
9030
+ try {
9031
+ before = reader.highestSequenceBelow(sessionID, commitSeq);
9032
+ } finally {
9033
+ reader.close();
9034
+ }
9035
+ }
9036
+ if (before === undefined) {
9037
+ sessionLog2(sessionID, "committed revert: last kept row unknown; retired instruction rows left as they are");
9038
+ return;
9039
+ }
9040
+ lowerRetiredInstructionThrough(database, sessionID, before);
9041
+ } catch (error) {
9042
+ sessionLog2(sessionID, "committed revert: retired instruction rows not updated:", error);
9043
+ }
9044
+ };
8869
9045
  cleanup.abortUsage = () => {
8870
9046
  usageController.abort();
8871
9047
  httpRefusalCounts.dispose();
@@ -8928,6 +9104,7 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
8928
9104
  const indexDb = db;
8929
9105
  withoutSqliteTransformPass2(() => {
8930
9106
  scheduleClearAndReindex(indexDb, sessionID, pagedRead);
9107
+ lowerRetiredInstructionsOnRevert(indexDb, sessionID, event);
8931
9108
  try {
8932
9109
  if (revertMessageCleanup.pruneOnCommit(indexDb, sessionID, event.data?.to, !compactionOff && !rustModeModuleClient)) {
8933
9110
  tagger.cleanup(sessionID);
@@ -9103,8 +9280,10 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
9103
9280
  draft.result = { summary: hiddenSummary, metadata: { keepID: undefined } };
9104
9281
  return;
9105
9282
  }
9106
- if (compactionOff)
9283
+ if (compactionOff) {
9284
+ removeDreamerOnlyTools(draft, [CTX_MEMORY_CURATE_TOOL_NAME]);
9107
9285
  return;
9286
+ }
9108
9287
  if (nativeFoldReplay)
9109
9288
  rememberHostMedia(draft.messages);
9110
9289
  const reader = openStoreReader();
@@ -9196,11 +9375,13 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
9196
9375
  if (!recorded)
9197
9376
  return messages;
9198
9377
  if (db) {
9199
- foldedInstructionIDs.set(sessionID, new Set([...retiredLiveInstructionIDs(db, sessionID)].filter((id) => recorded({
9200
- type: "system",
9201
- id,
9202
- seq: reader.sequenceForId(sessionID, id) ?? Infinity
9203
- }))));
9378
+ const folded = new Map;
9379
+ for (const id of retiredLiveInstructionIDs(db, sessionID)) {
9380
+ const seq = reader.sequenceForId(sessionID, id) ?? Infinity;
9381
+ if (recorded({ type: "system", id, seq }))
9382
+ folded.set(id, seq);
9383
+ }
9384
+ foldedInstructionIDs.set(sessionID, folded);
9204
9385
  }
9205
9386
  const retired = (row) => recorded(row) || isLeftOutInstruction(leftOut, row);
9206
9387
  return messages.filter((message) => {
@@ -9304,7 +9485,7 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
9304
9485
  const pass = contextPass.getStore();
9305
9486
  if (pass)
9306
9487
  pass.legacyCoveredReclaimPermitted = permitted;
9307
- return reclaimInstructionRows(database, sessionID, messages, permitted, foldedInstructionIDs.get(sessionID), covered, pass?.checkpointSequence, pass?.checkpointCoveredThrough);
9488
+ return reclaimInstructionRows(database, sessionID, messages, permitted, foldedInstructionIDs.get(sessionID), covered, pass?.checkpointSequence, pass?.checkpointCoveredThrough, pass?.localCheckpointSequence);
9308
9489
  },
9309
9490
  compactionOff,
9310
9491
  storeGeneration: "v2",
@@ -9696,6 +9877,7 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
9696
9877
  let messageTimes;
9697
9878
  let instructionRows = new Map;
9698
9879
  let legacyInstructions;
9880
+ retryRetiredInstructionLowering(db, draft.sessionID);
9699
9881
  const reader = openStoreReader();
9700
9882
  let checkpoint;
9701
9883
  let submitted;
@@ -9706,8 +9888,10 @@ async function setupContext(context, config, nativeRemove, compactionOff, cleanu
9706
9888
  try {
9707
9889
  syntheticIDs = await readSyntheticProvenance(reader, draft.messages);
9708
9890
  const cut = reader.latestCompaction(draft.sessionID);
9709
- if (!rustModeModuleClient)
9891
+ if (!rustModeModuleClient) {
9710
9892
  pass.checkpointSequence = cut?.seq;
9893
+ pass.localCheckpointSequence = cut && isLocalCheckpoint(cut) ? cut.seq : undefined;
9894
+ }
9711
9895
  if (nativeFoldReplay)
9712
9896
  draftSourceIdentity = await nativeFoldReplay.observeSource(draft.sessionID, reader);
9713
9897
  const boundaryRepair = !rustModeModuleClient && db && !compactionOff ? revertMessageCleanup.retireProvenHistory(db, draft.sessionID, reader) ?? checkHistoryBoundary(db, reader, draft.sessionID) : undefined;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  ensureMemoryEmbeddings2
3
- } from "./index-e6s2jpr8.js";
4
- import"./index-mhdavdd4.js";
5
- import"./index-qjwpqvnf.js";
3
+ } from "./index-jyj9jg9f.js";
4
+ import"./index-vhx6yph7.js";
5
+ import"./index-qbydvfev.js";
6
6
  import"./index-2amn2s73.js";
7
7
  import"./index-qt1qqasc.js";
8
8
  import"./index-nyjztqyj.js";
@@ -7,7 +7,7 @@ import {
7
7
  invalidateMemory2,
8
8
  resetEmbeddingCacheForTests2,
9
9
  setEmbeddingCacheTtlForTests2
10
- } from "./index-qjwpqvnf.js";
10
+ } from "./index-qbydvfev.js";
11
11
  export {
12
12
  getProjectEmbeddings2 as getProjectEmbeddings,
13
13
  invalidateMemory2 as invalidateMemory,
@@ -20,6 +20,7 @@ export declare function assessCurateMutationSafety(args: {
20
20
  projectIdentity: (memory: Memory) => string;
21
21
  }): CurateSafetyRefusal | null;
22
22
  export declare function recordCurateSafetyRefusal(sessionId: string, refusal: CurateSafetyRefusal): number;
23
+ export declare function curateSafetyRefusalsForMemory(sessionId: string, memoryId: number): number;
23
24
  export declare function takeCurateSafetyRefusalCount(sessionId: string): number;
24
25
  export {};
25
26
  //# sourceMappingURL=curate-memory-safety.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"curate-memory-safety.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/curate-memory-safety.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAOxC,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,QAAQ,CAAC;AACzD,QAAA,MAAM,6BAA6B,4IAKzB,CAAC;AACX,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAC;AAIvF,iJAAiJ;AACjJ,wBAAgB,wBAAwB,CACpC,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,MAAM,GACf,yBAAyB,EAAE,GAAG,IAAI,CAapC;AAED,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,qBAAqB,CAAC;IAC/B,MAAM,EAAE,yBAAyB,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAoBD,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,qBAAqB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC/C,GAAG,mBAAmB,GAAG,IAAI,CAgD7B;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAWjG;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAItE"}
1
+ {"version":3,"file":"curate-memory-safety.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/curate-memory-safety.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAOxC,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,QAAQ,CAAC;AACzD,QAAA,MAAM,6BAA6B,4IAKzB,CAAC;AACX,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM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