@cortexkit/opencode-magic-context 0.41.1 → 0.41.3

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 (200) hide show
  1. package/README.md +9 -3
  2. package/dist/announcement-3c1vertn.js +14 -0
  3. package/dist/config/project-security.d.ts.map +1 -1
  4. package/dist/config/schema/magic-context.d.ts +756 -4
  5. package/dist/config/schema/magic-context.d.ts.map +1 -1
  6. package/dist/conflict-warning-hook-z5sd697e.js +16 -0
  7. package/dist/derive-budgets-901a0pk0.js +11 -0
  8. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +4 -1
  9. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  10. package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -1
  11. package/dist/features/magic-context/compartment-lease.d.ts +6 -0
  12. package/dist/features/magic-context/compartment-lease.d.ts.map +1 -1
  13. package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts +21 -0
  14. package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -0
  15. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  16. package/dist/features/magic-context/dreamer/task-prompts.d.ts +1 -6
  17. package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
  18. package/dist/features/magic-context/memory/embedding-failure.d.ts +10 -2
  19. package/dist/features/magic-context/memory/embedding-failure.d.ts.map +1 -1
  20. package/dist/features/magic-context/memory/embedding-local.d.ts +7 -0
  21. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  22. package/dist/features/magic-context/memory/onnxruntime-node-wasm-shim.d.ts +3 -0
  23. package/dist/features/magic-context/memory/onnxruntime-node-wasm-shim.d.ts.map +1 -0
  24. package/dist/features/magic-context/memory/sharp-wasm-shim.d.ts +2 -0
  25. package/dist/features/magic-context/memory/sharp-wasm-shim.d.ts.map +1 -0
  26. package/dist/features/magic-context/memory/transformers-node-wasm-entry.d.ts +3 -0
  27. package/dist/features/magic-context/memory/transformers-node-wasm-entry.d.ts.map +1 -0
  28. package/dist/features/magic-context/message-fts-rowid-map.d.ts +28 -0
  29. package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -0
  30. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  31. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  32. package/dist/features/magic-context/overflow-detection.d.ts +15 -2
  33. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  34. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  35. package/dist/features/magic-context/storage-db.d.ts +20 -2
  36. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  37. package/dist/features/magic-context/storage-meta-persisted.d.ts +30 -14
  38. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  39. package/dist/features/magic-context/storage-meta-session.d.ts +3 -2
  40. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  41. package/dist/features/magic-context/storage-meta.d.ts +2 -2
  42. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  43. package/dist/features/magic-context/storage-schema-helpers.d.ts.map +1 -1
  44. package/dist/features/magic-context/storage-session-tables.d.ts +9 -1
  45. package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
  46. package/dist/features/magic-context/storage-subagent-invocations.d.ts +3 -2
  47. package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -1
  48. package/dist/features/magic-context/storage-tags.d.ts +19 -0
  49. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  50. package/dist/features/magic-context/storage.d.ts +2 -2
  51. package/dist/features/magic-context/storage.d.ts.map +1 -1
  52. package/dist/features/magic-context/subagent-token-capture.d.ts +2 -1
  53. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/compaction-marker-manager.d.ts +6 -1
  55. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
  56. package/dist/hooks/magic-context/compartment-runner.d.ts +2 -1
  57. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  58. package/dist/hooks/magic-context/event-handler.d.ts +4 -1
  59. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  60. package/dist/hooks/magic-context/format-embed-failure.d.ts.map +1 -1
  61. package/dist/hooks/magic-context/hook-handlers.d.ts +3 -0
  62. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  63. package/dist/hooks/magic-context/hook.d.ts +4 -1
  64. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  65. package/dist/hooks/magic-context/inject-compartments.d.ts +6 -0
  66. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  67. package/dist/hooks/magic-context/live-session-state.d.ts +3 -1
  68. package/dist/hooks/magic-context/live-session-state.d.ts.map +1 -1
  69. package/dist/hooks/magic-context/module-state-sync.d.ts +2 -1
  70. package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
  71. package/dist/hooks/magic-context/module-transport.d.ts +11 -4
  72. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  73. package/dist/hooks/magic-context/module-wire.d.ts +6 -1
  74. package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
  75. package/dist/hooks/magic-context/read-session-db.d.ts +15 -0
  76. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  77. package/dist/hooks/magic-context/rust-mode-transform.d.ts +19 -1
  78. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  79. package/dist/hooks/magic-context/send-session-notification.d.ts +6 -0
  80. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  81. package/dist/hooks/magic-context/sentinel.d.ts +18 -53
  82. package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
  83. package/dist/hooks/magic-context/strip-content.d.ts +12 -5
  84. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  85. package/dist/hooks/magic-context/tag-id-fallback.d.ts +3 -1
  86. package/dist/hooks/magic-context/tag-id-fallback.d.ts.map +1 -1
  87. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  88. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +57 -2
  89. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  90. package/dist/hooks/magic-context/transform.d.ts +1 -1
  91. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  92. package/dist/{index-z893kjyt.js → index-0bycg0np.js} +90 -26
  93. package/dist/{index-1yh8g550.js → index-22jkk6wg.js} +2 -15
  94. package/dist/{index-dmvy29z0.js → index-3wzdwt6p.js} +11 -15
  95. package/dist/{index-d1mxrd3p.js → index-7k55qm8a.js} +17 -12
  96. package/dist/{index-4x691bz5.js → index-dkv2dn46.js} +5 -2
  97. package/dist/{index-2d4kf2ve.js → index-dn1rwpd8.js} +16 -11
  98. package/dist/{index-rgdqj8nj.js → index-e7vx3byk.js} +1 -1
  99. package/dist/{index-szf8w1p5.js → index-fmsr7v69.js} +2 -2
  100. package/dist/{index-d62ypazr.js → index-jdxxq8cz.js} +6 -11
  101. package/dist/{index-9j3tx8hy.js → index-may8skc8.js} +6 -25
  102. package/dist/{index-eq9wr75c.js → index-npx8vhmy.js} +57 -108
  103. package/dist/{index-zwjhba2r.js → index-q264erdp.js} +122 -41
  104. package/dist/{index-b9j85d29.js → index-raatkvw5.js} +49 -11
  105. package/dist/{index-9xexf8s7.js → index-rn7gafjr.js} +1 -9
  106. package/dist/index-v6t0tg85.js +13 -0
  107. package/dist/{index-dh0vfghk.js → index-vmmjdpc0.js} +2594 -11271
  108. package/dist/index.d.ts.map +1 -1
  109. package/dist/index.js +3414 -2620
  110. package/dist/model-resolution-dxatzjde.js +12 -0
  111. package/dist/{index-dynqfgx1.js → module-asyncify-2EFITU5U-rkqjhjxd.js} +69 -8
  112. package/dist/plugin/boot-deadline.d.ts +47 -0
  113. package/dist/plugin/boot-deadline.d.ts.map +1 -0
  114. package/dist/plugin/conflict-warning-hook.d.ts +10 -0
  115. package/dist/plugin/conflict-warning-hook.d.ts.map +1 -1
  116. package/dist/plugin/dream-timer.d.ts +4 -0
  117. package/dist/plugin/dream-timer.d.ts.map +1 -1
  118. package/dist/plugin/hooks/create-session-hooks.d.ts +4 -2
  119. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  120. package/dist/plugin/messages-transform.d.ts.map +1 -1
  121. package/dist/prompt-context-5y5ms8f9.js +6 -0
  122. package/dist/recomp-orchestrator-f5m2wk74.js +19 -0
  123. package/dist/rpc-notifications-4amf6mf4.js +14 -0
  124. package/dist/{index-vnz6jvdc.js → safe-notification-target-q9z81zt3.js} +4 -3
  125. package/dist/send-session-notification-hdh02wy9.js +16 -0
  126. package/dist/shared/conflict-detector.d.ts +3 -1
  127. package/dist/shared/conflict-detector.d.ts.map +1 -1
  128. package/dist/shared/harness.d.ts +3 -3
  129. package/dist/shared/harness.d.ts.map +1 -1
  130. package/dist/shared/index.d.ts +1 -0
  131. package/dist/shared/index.d.ts.map +1 -1
  132. package/dist/shared/model-resolution.d.ts +3 -3
  133. package/dist/shared/model-resolution.d.ts.map +1 -1
  134. package/dist/shared/prompt-surface-runtime.d.ts +2 -2
  135. package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
  136. package/dist/shared/rpc-utils.d.ts +3 -1
  137. package/dist/shared/rpc-utils.d.ts.map +1 -1
  138. package/dist/shared/summarize-child-stderr.d.ts +2 -0
  139. package/dist/shared/summarize-child-stderr.d.ts.map +1 -0
  140. package/dist/shared/tag-transcript.d.ts.map +1 -1
  141. package/dist/shared/transcript.d.ts +2 -1
  142. package/dist/shared/transcript.d.ts.map +1 -1
  143. package/dist/shared/window-geometry.d.ts +2 -0
  144. package/dist/shared/window-geometry.d.ts.map +1 -1
  145. package/dist/storage-meta-session-3rxx9ekm.js +20 -0
  146. package/dist/task-config-hnv93r7p.js +9 -0
  147. package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
  148. package/dist/tools/ctx-memory/types.d.ts +2 -0
  149. package/dist/tools/ctx-memory/types.d.ts.map +1 -1
  150. package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
  151. package/dist/transformers-node-wasm.js +25676 -0
  152. package/dist/transformers-web.js +72 -72
  153. package/dist/{transformers.node-b1wa0hgx.js → transformers.node-dpmf3wpx.js} +74 -74
  154. package/package.json +4 -3
  155. package/src/config/index.test.ts +69 -0
  156. package/src/config/latch-permanence-guard.test.ts +5 -0
  157. package/src/config/project-security.hostile-matrix.test.ts +78 -9
  158. package/src/config/project-security.ts +4 -3
  159. package/src/config/schema/magic-context.test.ts +64 -0
  160. package/src/config/schema/magic-context.ts +100 -6
  161. package/src/shared/conflict-detector.test.ts +24 -0
  162. package/src/shared/conflict-detector.ts +25 -7
  163. package/src/shared/harness.ts +3 -3
  164. package/src/shared/index.ts +1 -0
  165. package/src/shared/model-resolution.test.ts +78 -13
  166. package/src/shared/model-resolution.ts +14 -5
  167. package/src/shared/prompt-surface-runtime.ts +3 -3
  168. package/src/shared/rpc-utils.test.ts +246 -5
  169. package/src/shared/rpc-utils.ts +340 -49
  170. package/src/shared/summarize-child-stderr.test.ts +55 -0
  171. package/src/shared/summarize-child-stderr.ts +33 -0
  172. package/src/shared/tag-transcript.ts +11 -0
  173. package/src/shared/transcript.ts +3 -1
  174. package/src/shared/window-geometry.ts +9 -0
  175. package/dist/announcement-3g9xg433.js +0 -18
  176. package/dist/conflict-warning-hook-rf17b6et.js +0 -17
  177. package/dist/derive-budgets-bb7mrpzs.js +0 -14
  178. package/dist/emscripten-module-49k43zfy.js +0 -507
  179. package/dist/emscripten-module-ex4v0x4z.js +0 -606
  180. package/dist/emscripten-module-jfs3d1dq.js +0 -1536
  181. package/dist/emscripten-module-ss4g4spn.js +0 -4563
  182. package/dist/ffi-bbm9vkfa.js +0 -92
  183. package/dist/ffi-kb5r0x1j.js +0 -92
  184. package/dist/ffi-qnrt0y78.js +0 -80
  185. package/dist/ffi-yx2hpf4p.js +0 -80
  186. package/dist/index-8sseka65.js +0 -251
  187. package/dist/index-ss632za9.js +0 -77
  188. package/dist/model-resolution-6w6wzw18.js +0 -17
  189. package/dist/module-ES6BEMUI-1yjdz59c.js +0 -14
  190. package/dist/module-asyncify-2EFITU5U-fdkx4fhy.js +0 -9
  191. package/dist/prompt-context-29qkb28f.js +0 -7
  192. package/dist/recomp-orchestrator-w7xg48e3.js +0 -34
  193. package/dist/rpc-notifications-1ffm755w.js +0 -17
  194. package/dist/safe-notification-target-2a8py95v.js +0 -11
  195. package/dist/send-session-notification-bw7eex6w.js +0 -20
  196. package/dist/storage-meta-session-gr4zn7sq.js +0 -21
  197. package/dist/task-config-gv6s04fp.js +0 -18
  198. /package/dist/{index-37yzyeca.js → index-3fe78beq.js} +0 -0
  199. /package/dist/{index-8mtsfhyg.js → index-jfpk81yt.js} +0 -0
  200. /package/dist/{index-2wchnyk6.js → index-kby1sng5.js} +0 -0
@@ -1,14 +1,14 @@
1
- import {
2
- modelRefLookupOrder
3
- } from "./index-2wchnyk6.js";
4
1
  import {
5
2
  sessionLog
6
- } from "./index-4x691bz5.js";
3
+ } from "./index-dkv2dn46.js";
4
+ import {
5
+ modelRefLookupOrder
6
+ } from "./index-kby1sng5.js";
7
7
  import {
8
- getDataDir,
9
8
  getHarness,
9
+ getDataDir,
10
10
  getMagicContextStorageDir
11
- } from "./index-37yzyeca.js";
11
+ } from "./index-3fe78beq.js";
12
12
 
13
13
  // src/shared/models-dev-cache.ts
14
14
  import { mkdirSync, readFileSync as readFileSync2, renameSync, writeFileSync } from "node:fs";
@@ -215,6 +215,11 @@ function readWindowOverlayFile(path, log = (message) => sessionLog("global", mes
215
215
  return parsed.overlay;
216
216
  }
217
217
  function setWindowOverlayPath(path) {
218
+ if (configuredOverlayPath === path)
219
+ return;
220
+ reloadWindowOverlay(path);
221
+ }
222
+ function reloadWindowOverlay(path) {
218
223
  configuredOverlayPath = path;
219
224
  loadedOverlayPath = undefined;
220
225
  loadedOverlay = undefined;
@@ -549,7 +554,7 @@ function setCachedModelMetadata(cache, key, model) {
549
554
  if (rawLimit === undefined)
550
555
  return;
551
556
  const values = [model?.capabilities, model?.modalities, model?.input, model?.attachment];
552
- const vision = values.some((value2) => JSON.stringify(value2 ?? "").toLowerCase().includes("image") || JSON.stringify(value2 ?? "").toLowerCase().includes("vision"));
557
+ const vision = values.some((value) => JSON.stringify(value ?? "").toLowerCase().includes("image") || JSON.stringify(value ?? "").toLowerCase().includes("vision"));
553
558
  const value = {
554
559
  limit: rawLimit,
555
560
  contextLimit: isSaneLimit(contextLimit) ? contextLimit : undefined,
@@ -697,7 +702,7 @@ var HISTORIAN_CHUNK_PERCENTAGE = 0.25;
697
702
  var HISTORIAN_CHUNK_MIN = 8000;
698
703
  var HISTORIAN_CHUNK_MAX = 50000;
699
704
  var DEFAULT_HISTORIAN_CONTEXT_FALLBACK = 128000;
700
- function deriveTriggerBudget(mainContextLimit, executeThresholdPercentage) {
705
+ function deriveTriggerBudget2(mainContextLimit, executeThresholdPercentage) {
701
706
  if (!Number.isFinite(mainContextLimit) || mainContextLimit <= 0) {
702
707
  return TRIGGER_BUDGET_MIN;
703
708
  }
@@ -706,14 +711,14 @@ function deriveTriggerBudget(mainContextLimit, executeThresholdPercentage) {
706
711
  const derived = Math.round(usable * TRIGGER_BUDGET_PERCENTAGE);
707
712
  return Math.max(TRIGGER_BUDGET_MIN, Math.min(TRIGGER_BUDGET_MAX, derived));
708
713
  }
709
- function deriveHistorianChunkTokens(historianContextLimit) {
714
+ function deriveHistorianChunkTokens2(historianContextLimit) {
710
715
  if (!Number.isFinite(historianContextLimit) || historianContextLimit <= 0) {
711
716
  return HISTORIAN_CHUNK_MIN;
712
717
  }
713
718
  const derived = Math.round(historianContextLimit * HISTORIAN_CHUNK_PERCENTAGE);
714
719
  return Math.max(HISTORIAN_CHUNK_MIN, Math.min(HISTORIAN_CHUNK_MAX, derived));
715
720
  }
716
- function resolveHistorianContextLimit(historianModelOverride) {
721
+ function resolveHistorianContextLimit2(historianModelOverride) {
717
722
  if (typeof historianModelOverride === "string" && historianModelOverride.includes("/")) {
718
723
  const [providerID, ...rest] = historianModelOverride.split("/");
719
724
  const modelID = rest.join("/");
@@ -730,4 +735,4 @@ function resolveHistorianContextLimit(historianModelOverride) {
730
735
  return DEFAULT_HISTORIAN_CONTEXT_FALLBACK;
731
736
  }
732
737
 
733
- export { setStoragePrivatePermissionEnforcement, shouldEnforcePrivateStoragePermissions, setWindowOverlayPath, formatWindowDerivationLine, isSaneLimit, setOutputReserveConfig, refreshModelLimitsFromApi, refreshModelLimitsAfterAuthOnce, getSdkWindowGeometry, getSdkContextLimit, modelSupportsVision, deriveTriggerBudget, deriveHistorianChunkTokens, resolveHistorianContextLimit };
738
+ export { setStoragePrivatePermissionEnforcement, shouldEnforcePrivateStoragePermissions, setWindowOverlayPath, reloadWindowOverlay, formatWindowDerivationLine, isSaneLimit, setOutputReserveConfig, refreshModelLimitsFromApi, refreshModelLimitsAfterAuthOnce, getSdkWindowGeometry, getSdkContextLimit, modelSupportsVision, deriveTriggerBudget2, deriveHistorianChunkTokens2, resolveHistorianContextLimit2 };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __commonJS,
3
3
  __require
4
- } from "./index-1yh8g550.js";
4
+ } from "./index-22jkk6wg.js";
5
5
 
6
6
  // ../../node_modules/.bun/@jitl+quickjs-ffi-types@0.32.0/node_modules/@jitl/quickjs-ffi-types/dist/index.js
7
7
  var require_dist = __commonJS(function(exports, module) {
@@ -40,7 +40,7 @@ function isComplete(ctx) {
40
40
  return Boolean(ctx.agent && ctx.model && ctx.variant);
41
41
  }
42
42
  var PROMPT_CONTEXT_MESSAGE_LIMIT = 50;
43
- async function resolvePromptContext(client, sessionId) {
43
+ async function resolvePromptContext2(client, sessionId) {
44
44
  if (!client || !sessionId)
45
45
  return null;
46
46
  const c = client;
@@ -72,4 +72,4 @@ async function resolvePromptContext(client, sessionId) {
72
72
  return result;
73
73
  }
74
74
 
75
- export { resolvePromptContext };
75
+ export { resolvePromptContext2 };
@@ -2,7 +2,7 @@
2
2
  var queue = [];
3
3
  var nextNotificationId = 1;
4
4
  var sinks = new Set;
5
- function registerNotificationSink(sink) {
5
+ function registerNotificationSink2(sink) {
6
6
  sinks.add(sink);
7
7
  return () => {
8
8
  sinks.delete(sink);
@@ -15,7 +15,7 @@ function notificationMatchesSink(notification, sink) {
15
15
  return notification.sessionId === sink.sessionId;
16
16
  return sink.protocol !== 2;
17
17
  }
18
- function pushNotification(type, payload, sessionId) {
18
+ function pushNotification2(type, payload, sessionId) {
19
19
  const notification = { id: nextNotificationId++, type, payload, sessionId };
20
20
  queue.push(notification);
21
21
  for (const sink of sinks) {
@@ -40,21 +40,16 @@ function pushNotification(type, payload, sessionId) {
40
40
  queue.splice(evictionIndex >= 0 ? evictionIndex : 0, 1);
41
41
  }
42
42
  }
43
- function acknowledgeNotifications(ids) {
43
+ function acknowledgeNotifications2(ids) {
44
44
  const acknowledged = new Set(ids.filter((id) => Number.isSafeInteger(id) && id > 0));
45
45
  if (acknowledged.size === 0)
46
46
  return;
47
47
  queue = queue.filter((notification) => !acknowledged.has(notification.id));
48
48
  }
49
- function __resetNotificationStateForTests() {
50
- queue = [];
51
- nextNotificationId = 1;
52
- sinks.clear();
53
- }
54
49
  function cursor(value) {
55
50
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
56
51
  }
57
- function drainNotifications(lastReceivedId = 0, sessionId, options = {}) {
52
+ function drainNotifications2(lastReceivedId = 0, sessionId, options = {}) {
58
53
  const sessionCursor = cursor(lastReceivedId);
59
54
  if (options.globalOnly) {
60
55
  queue = queue.filter((notification) => notification.sessionId !== undefined || notification.id > sessionCursor);
@@ -87,7 +82,7 @@ function drainNotifications(lastReceivedId = 0, sessionId, options = {}) {
87
82
  }
88
83
  return queue.filter((notification) => notification.id > sessionCursor && matchesClient(notification));
89
84
  }
90
- function isTuiConnected(sessionId) {
85
+ function isTuiConnected2(sessionId) {
91
86
  if (sinks.size === 0)
92
87
  return false;
93
88
  if (sessionId === undefined)
@@ -101,4 +96,4 @@ function isTuiConnected(sessionId) {
101
96
  return false;
102
97
  }
103
98
 
104
- export { registerNotificationSink, pushNotification, acknowledgeNotifications, __resetNotificationStateForTests, drainNotifications, isTuiConnected };
99
+ export { registerNotificationSink2, pushNotification2, acknowledgeNotifications2, drainNotifications2, isTuiConnected2 };
@@ -1,6 +1,6 @@
1
1
  import {
2
- resolveDreamerTaskModel
3
- } from "./index-d1mxrd3p.js";
2
+ resolveDreamerTaskModel2
3
+ } from "./index-7k55qm8a.js";
4
4
 
5
5
  // src/features/magic-context/dreamer/task-registry.ts
6
6
  var CANONICAL_DREAM_TASKS = [
@@ -68,9 +68,9 @@ function compareTaskOrder(a, b) {
68
68
  }
69
69
 
70
70
  // src/features/magic-context/dreamer/task-config.ts
71
- function buildDreamTaskRuntimeConfigs(dreamer, harness, language, muralModel) {
71
+ function buildDreamTaskRuntimeConfigs2(dreamer, harness, language, muralModel) {
72
72
  return CANONICAL_DREAM_TASKS.map((task) => {
73
- const resolved = resolveDreamerTaskModel({
73
+ const resolved = resolveDreamerTaskModel2({
74
74
  config: { dreamer },
75
75
  harness,
76
76
  task,
@@ -88,27 +88,8 @@ function buildDreamTaskRuntimeConfigs(dreamer, harness, language, muralModel) {
88
88
  };
89
89
  });
90
90
  }
91
- function userMemoryCollectionEnabled(dreamer) {
91
+ function userMemoryCollectionEnabled2(dreamer) {
92
92
  const schedule = dreamer?.tasks?.["review-user-memories"]?.schedule;
93
93
  return typeof schedule === "string" && schedule.trim() !== "";
94
94
  }
95
- function userMemoryPromotionThreshold(dreamer) {
96
- return dreamer?.tasks?.["review-user-memories"]?.promotion_threshold ?? 3;
97
- }
98
- function dreamTaskScheduled(dreamer, task) {
99
- const schedule = dreamer?.tasks?.[task]?.schedule;
100
- return typeof schedule === "string" && schedule.trim() !== "";
101
- }
102
- function enabledDreamTasks(dreamer) {
103
- if (!dreamer?.tasks)
104
- return [];
105
- return CANONICAL_DREAM_TASKS.filter((t) => dreamer.tasks[t]?.schedule?.trim());
106
- }
107
- function summarizeDreamSchedule(dreamer) {
108
- const enabled = enabledDreamTasks(dreamer);
109
- if (enabled.length === 0)
110
- return "manual-only";
111
- return enabled.map((t) => `${t} ${dreamer?.tasks[t]?.schedule}`).join(", ");
112
- }
113
-
114
- export { CANONICAL_DREAM_TASKS, formatDreamTaskBacklogs, processedDreamTaskItems, leaseKindFor, leaseKeyFor, isCanonicalDreamTask, compareTaskOrder, buildDreamTaskRuntimeConfigs, userMemoryCollectionEnabled, userMemoryPromotionThreshold, dreamTaskScheduled, enabledDreamTasks, summarizeDreamSchedule };
95
+ export { CANONICAL_DREAM_TASKS, formatDreamTaskBacklogs, processedDreamTaskItems, leaseKindFor, leaseKeyFor, isCanonicalDreamTask, compareTaskOrder, buildDreamTaskRuntimeConfigs2, userMemoryCollectionEnabled2 };
@@ -1,15 +1,12 @@
1
- import {
2
- readJsoncFile
3
- } from "./index-8mtsfhyg.js";
4
- import {
5
- waitForSafeNotificationTarget
6
- } from "./index-vnz6jvdc.js";
7
1
  import {
8
2
  log
9
- } from "./index-4x691bz5.js";
3
+ } from "./index-dkv2dn46.js";
10
4
  import {
11
- __require
12
- } from "./index-1yh8g550.js";
5
+ sendIgnoredMessage2
6
+ } from "./index-q264erdp.js";
7
+ import {
8
+ readJsoncFile
9
+ } from "./index-jfpk81yt.js";
13
10
 
14
11
  // src/plugin/conflict-warning-hook.ts
15
12
  import { existsSync, readFileSync } from "node:fs";
@@ -97,11 +94,20 @@ function detectConflicts(directory, options) {
97
94
  };
98
95
  }
99
96
  async function resolveCompactionForBoot(client, timeoutMs = 2000) {
97
+ const controller = new AbortController;
98
+ let timer;
100
99
  try {
101
- const result = await Promise.race([
102
- client.config.get(),
103
- new Promise((_, reject) => setTimeout(() => reject(new Error("config.get() timed out")), timeoutMs))
104
- ]);
100
+ const timeout = new Promise((resolve) => {
101
+ timer = setTimeout(() => {
102
+ controller.abort(new Error("config.get() timed out"));
103
+ resolve(null);
104
+ }, Math.max(0, timeoutMs));
105
+ timer.unref?.();
106
+ });
107
+ const request = Promise.resolve().then(() => client.config.get({ signal: controller.signal }));
108
+ const result = await Promise.race([request, timeout]);
109
+ if (result === null)
110
+ return null;
105
111
  const compaction = result?.data?.compaction;
106
112
  if (typeof compaction?.auto !== "boolean" || typeof compaction?.prune !== "boolean") {
107
113
  log(`[magic-context] conflict-detector: resolved config carried no explicit compaction block (${JSON.stringify(compaction) ?? "absent"}); falling back to file-based detection`);
@@ -110,6 +116,9 @@ async function resolveCompactionForBoot(client, timeoutMs = 2000) {
110
116
  return { auto: compaction.auto, prune: compaction.prune };
111
117
  } catch {
112
118
  return null;
119
+ } finally {
120
+ if (timer)
121
+ clearTimeout(timer);
113
122
  }
114
123
  }
115
124
  function checkCompaction(directory) {
@@ -392,43 +401,21 @@ async function getSessionMessages(client, sessionId) {
392
401
  }
393
402
  return [];
394
403
  }
395
- async function sendConflictWarning(client, directory, conflictResult) {
404
+ async function sendConflictWarning2(client, directory, conflictResult) {
396
405
  const { sessionId } = getDesktopState(directory);
397
406
  if (!sessionId) {
398
407
  log("[magic-context] conflict-warning: could not find active session for Desktop warning");
399
408
  return;
400
409
  }
401
- if (await waitForSafeNotificationTarget(client, sessionId) === "skip")
402
- return;
403
410
  const warningText = formatConflictShort(conflictResult);
404
411
  log(`[magic-context] sending conflict warning to session ${sessionId}: ${conflictResult.reasons.join(", ")}`);
405
412
  try {
406
- const c = client;
407
- const promptInput = {
408
- path: { id: sessionId },
409
- body: {
410
- noReply: true,
411
- parts: [
412
- {
413
- type: "text",
414
- text: warningText,
415
- ignored: true
416
- }
417
- ]
418
- }
419
- };
420
- if (typeof c.session?.prompt === "function") {
421
- await Promise.resolve(c.session.prompt(promptInput));
422
- } else if (typeof c.session?.promptAsync === "function") {
423
- await c.session.promptAsync(promptInput);
424
- } else {
425
- log("[magic-context] conflict-warning: session prompt API unavailable");
426
- }
413
+ await sendIgnoredMessage2(client, sessionId, warningText, {});
427
414
  } catch (error) {
428
415
  log(`[magic-context] conflict-warning: failed to send: ${error instanceof Error ? error.message : String(error)}`);
429
416
  }
430
417
  }
431
- async function cleanupConflictWarnings(client, directory, serverUrl) {
418
+ async function cleanupConflictWarnings2(client, directory, serverUrl) {
432
419
  const { sessionId } = getDesktopState(directory);
433
420
  if (!sessionId) {
434
421
  log("[magic-context] cleanup: no active Desktop session found");
@@ -467,43 +454,33 @@ async function cleanupConflictWarnings(client, directory, serverUrl) {
467
454
  log(`[magic-context] deleted conflict warning message ${messageId}`);
468
455
  }
469
456
  }
470
- if (await waitForSafeNotificationTarget(client, sessionId) === "skip")
471
- return;
472
457
  const enabledText = `${ENABLED_MARKER}. Enjoy! ✨`;
458
+ const scheduleEnabledCleanup = () => {
459
+ setTimeout(async () => {
460
+ try {
461
+ const freshMessages = await getSessionMessages(client, sessionId);
462
+ for (let i = freshMessages.length - 1;i >= 0; i--) {
463
+ const msg = freshMessages[i];
464
+ const msgId = msg.info?.id;
465
+ const msgRole = msg.info?.role;
466
+ if (!msgId || msgRole !== "user")
467
+ break;
468
+ const parts = msg.parts ?? [];
469
+ const isEnabled = parts.length > 0 && parts.every((p) => p.ignored === true && p.type === "text" && typeof p.text === "string" && p.text.startsWith(ENABLED_MARKER));
470
+ if (isEnabled) {
471
+ await deleteMessage(serverUrl, sessionId, msgId);
472
+ } else {
473
+ break;
474
+ }
475
+ }
476
+ } catch {}
477
+ }, 1000);
478
+ };
473
479
  try {
474
- const c = client;
475
- const promptInput = {
476
- path: { id: sessionId },
477
- body: {
478
- noReply: true,
479
- parts: [{ type: "text", text: enabledText, ignored: true }]
480
- }
481
- };
482
- if (typeof c.session?.prompt === "function") {
483
- await Promise.resolve(c.session.prompt(promptInput));
484
- } else if (typeof c.session?.promptAsync === "function") {
485
- await c.session.promptAsync(promptInput);
486
- }
480
+ await sendIgnoredMessage2(client, sessionId, enabledText, {
481
+ onDelivered: scheduleEnabledCleanup
482
+ });
487
483
  } catch {}
488
- setTimeout(async () => {
489
- try {
490
- const freshMessages = await getSessionMessages(client, sessionId);
491
- for (let i = freshMessages.length - 1;i >= 0; i--) {
492
- const msg = freshMessages[i];
493
- const msgId = msg.info?.id;
494
- const msgRole = msg.info?.role;
495
- if (!msgId || msgRole !== "user")
496
- break;
497
- const parts = msg.parts ?? [];
498
- const isEnabled = parts.length > 0 && parts.every((p) => p.ignored === true && p.type === "text" && typeof p.text === "string" && p.text.startsWith(ENABLED_MARKER));
499
- if (isEnabled) {
500
- await deleteMessage(serverUrl, sessionId, msgId);
501
- } else {
502
- break;
503
- }
504
- }
505
- } catch {}
506
- }, 1000);
507
484
  }
508
485
  async function cleanupEnabledMessages(messages, serverUrl, sessionId) {
509
486
  if (!serverUrl)
@@ -523,12 +500,10 @@ async function cleanupEnabledMessages(messages, serverUrl, sessionId) {
523
500
  }
524
501
  }
525
502
  }
526
- async function sendSchemaFenceWarning(client, directory, detail) {
503
+ async function sendSchemaFenceWarning2(client, directory, detail) {
527
504
  const { sessionId } = getDesktopState(directory);
528
505
  if (!sessionId)
529
506
  return;
530
- if (await waitForSafeNotificationTarget(client, sessionId) === "skip")
531
- return;
532
507
  const text = [
533
508
  `${SCHEMA_FENCE_MARKER}`,
534
509
  "",
@@ -546,32 +521,21 @@ async function sendSchemaFenceWarning(client, directory, detail) {
546
521
  ].join(`
547
522
  `);
548
523
  try {
549
- const c = client;
550
- const promptInput = {
551
- path: { id: sessionId },
552
- body: { noReply: true, parts: [{ type: "text", text, ignored: true }] }
553
- };
554
- if (typeof c.session?.prompt === "function") {
555
- await Promise.resolve(c.session.prompt(promptInput));
556
- } else if (typeof c.session?.promptAsync === "function") {
557
- await c.session.promptAsync(promptInput);
558
- }
524
+ await sendIgnoredMessage2(client, sessionId, text, {});
559
525
  } catch {
560
526
  return;
561
527
  }
562
528
  }
563
- async function sendStartupAnnouncement(client, directory, version, features, footer, markSeen) {
529
+ async function sendStartupAnnouncement2(client, directory, version, features, footer, markSeen) {
564
530
  if (!version || features.length === 0)
565
531
  return;
566
532
  const { sessionId } = getDesktopState(directory);
567
533
  if (!sessionId) {
568
534
  return;
569
535
  }
570
- const { isTuiConnected } = await import("./rpc-notifications-1ffm755w.js");
536
+ const { isTuiConnected } = await import("./rpc-notifications-4amf6mf4.js");
571
537
  if (isTuiConnected(sessionId) || isTuiConnected())
572
538
  return;
573
- if (await waitForSafeNotificationTarget(client, sessionId) === "skip")
574
- return;
575
539
  const bullets = features.map((line) => ` • ${line}`).join(`
576
540
  `);
577
541
  const sections = [`${ANNOUNCEMENT_MARKER} v${version}:`, "", bullets];
@@ -582,27 +546,12 @@ async function sendStartupAnnouncement(client, directory, version, features, foo
582
546
  `);
583
547
  log(`[magic-context] sending startup announcement for v${version} to session ${sessionId}`);
584
548
  try {
585
- const c = client;
586
- const promptInput = {
587
- path: { id: sessionId },
588
- body: {
589
- noReply: true,
590
- parts: [{ type: "text", text, ignored: true }]
591
- }
592
- };
593
- if (typeof c.session?.prompt === "function") {
594
- await Promise.resolve(c.session.prompt(promptInput));
595
- } else if (typeof c.session?.promptAsync === "function") {
596
- await c.session.promptAsync(promptInput);
597
- } else {
598
- log("[magic-context] announcement: session prompt API unavailable");
599
- return;
600
- }
549
+ await sendIgnoredMessage2(client, sessionId, text, {
550
+ onDelivered: () => markSeen(version)
551
+ });
601
552
  } catch (error) {
602
553
  log(`[magic-context] announcement: failed to send: ${error instanceof Error ? error.message : String(error)}`);
603
- return;
604
554
  }
605
- markSeen(version);
606
555
  }
607
556
 
608
- export { detectConflicts, resolveCompactionForBoot, sendConflictWarning, cleanupConflictWarnings, sendSchemaFenceWarning, sendStartupAnnouncement };
557
+ export { detectConflicts, resolveCompactionForBoot, sendConflictWarning2, cleanupConflictWarnings2, sendSchemaFenceWarning2, sendStartupAnnouncement2 };