@cortexkit/opencode-magic-context 0.44.1 → 0.44.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 (216) hide show
  1. package/README.md +6 -0
  2. package/dist/agents/dreamer.d.ts +4 -6
  3. package/dist/agents/dreamer.d.ts.map +1 -1
  4. package/dist/config/live-child-output-cap.d.ts.map +1 -1
  5. package/dist/config/schema/magic-context.d.ts +63 -10
  6. package/dist/config/schema/magic-context.d.ts.map +1 -1
  7. package/dist/{conflict-warning-hook-d14ah73v.js → conflict-warning-hook-hmpzxep6.js} +3 -3
  8. package/dist/{derive-budgets-gd2270s0.js → derive-budgets-vjmvh6pz.js} +3 -1
  9. package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
  10. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +11 -0
  11. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  12. package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
  13. package/dist/features/magic-context/dreamer/classify.d.ts.map +1 -1
  14. package/dist/features/magic-context/dreamer/docs-proposals.d.ts +2 -0
  15. package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
  16. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/lease.d.ts +1 -1
  18. package/dist/features/magic-context/dreamer/lease.d.ts.map +1 -1
  19. package/dist/features/magic-context/dreamer/manual-summary.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts +1 -1
  21. package/dist/features/magic-context/dreamer/map-memories-prompt.d.ts.map +1 -1
  22. package/dist/features/magic-context/dreamer/map-memories.d.ts +5 -0
  23. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  24. package/dist/features/magic-context/dreamer/refresh-primers.d.ts +5 -0
  25. package/dist/features/magic-context/dreamer/refresh-primers.d.ts.map +1 -1
  26. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +2 -2
  27. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
  28. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +8 -1
  29. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
  30. package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
  31. package/dist/features/magic-context/dreamer/task-executor.d.ts +5 -0
  32. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  33. package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
  34. package/dist/features/magic-context/dreamer/task-prompts.d.ts +18 -2
  35. package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
  36. package/dist/features/magic-context/dreamer/task-registry.d.ts +12 -0
  37. package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
  38. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +3 -1
  39. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  40. package/dist/features/magic-context/dreamer/token-budget.d.ts +33 -0
  41. package/dist/features/magic-context/dreamer/token-budget.d.ts.map +1 -0
  42. package/dist/features/magic-context/dreamer/verify-diff.d.ts +15 -0
  43. package/dist/features/magic-context/dreamer/verify-diff.d.ts.map +1 -0
  44. package/dist/features/magic-context/dreamer/verify-gate.d.ts.map +1 -1
  45. package/dist/features/magic-context/dreamer/verify-prompt.d.ts +5 -2
  46. package/dist/features/magic-context/dreamer/verify-prompt.d.ts.map +1 -1
  47. package/dist/features/magic-context/dreamer/verify-read-cap.d.ts +4 -0
  48. package/dist/features/magic-context/dreamer/verify-read-cap.d.ts.map +1 -0
  49. package/dist/features/magic-context/dreamer/verify.d.ts +5 -0
  50. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  51. package/dist/features/magic-context/git-commits/git-log-reader.d.ts.map +1 -1
  52. package/dist/features/magic-context/memory/project-identity-cache.d.ts +6 -0
  53. package/dist/features/magic-context/memory/project-identity-cache.d.ts.map +1 -0
  54. package/dist/features/magic-context/memory/project-identity.d.ts +11 -22
  55. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  56. package/dist/features/magic-context/memory/storage-memory-fts.d.ts +1 -0
  57. package/dist/features/magic-context/memory/storage-memory-fts.d.ts.map +1 -1
  58. package/dist/features/magic-context/memory/verification-paths.d.ts +1 -0
  59. package/dist/features/magic-context/memory/verification-paths.d.ts.map +1 -1
  60. package/dist/features/magic-context/message-index-async.d.ts +1 -1
  61. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  62. package/dist/features/magic-context/project-embedding-registry.d.ts +5 -0
  63. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  64. package/dist/features/magic-context/search.d.ts.map +1 -1
  65. package/dist/features/magic-context/session-activity.d.ts +10 -0
  66. package/dist/features/magic-context/session-activity.d.ts.map +1 -0
  67. package/dist/features/magic-context/session-project-backfill.d.ts +4 -1
  68. package/dist/features/magic-context/session-project-backfill.d.ts.map +1 -1
  69. package/dist/features/magic-context/session-project-storage.d.ts +5 -5
  70. package/dist/features/magic-context/session-project-storage.d.ts.map +1 -1
  71. package/dist/features/magic-context/smart-notes/compiler.d.ts +5 -0
  72. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  73. package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts +1 -0
  74. package/dist/features/magic-context/smart-notes/sandbox-runner.d.ts.map +1 -1
  75. package/dist/features/magic-context/smart-notes/storage.d.ts +1 -1
  76. package/dist/features/magic-context/smart-notes/storage.d.ts.map +1 -1
  77. package/dist/features/magic-context/smart-notes/types.d.ts +2 -0
  78. package/dist/features/magic-context/smart-notes/types.d.ts.map +1 -1
  79. package/dist/features/magic-context/storage-db.d.ts +2 -1
  80. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  81. package/dist/features/magic-context/storage-embedding-measurements.d.ts.map +1 -1
  82. package/dist/features/magic-context/storage-identity-merge.d.ts +4 -1
  83. package/dist/features/magic-context/storage-identity-merge.d.ts.map +1 -1
  84. package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
  85. package/dist/features/magic-context/v22-deferred-backfill.d.ts.map +1 -1
  86. package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
  87. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  88. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -1
  89. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  90. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  91. package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
  92. package/dist/hooks/magic-context/compartment-runner-types.d.ts +1 -0
  93. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  94. package/dist/hooks/magic-context/compartment-runner.d.ts +1 -0
  95. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  96. package/dist/hooks/magic-context/derive-budgets.d.ts +4 -0
  97. package/dist/hooks/magic-context/derive-budgets.d.ts.map +1 -1
  98. package/dist/hooks/magic-context/dropped-input-guard.d.ts.map +1 -1
  99. package/dist/hooks/magic-context/embed-session-state.d.ts +3 -0
  100. package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -1
  101. package/dist/hooks/magic-context/event-handler.d.ts +1 -0
  102. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  103. package/dist/hooks/magic-context/event-payloads.d.ts +1 -0
  104. package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -1
  105. package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
  106. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  107. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  108. package/dist/hooks/magic-context/lkg-persist.d.ts +1 -4
  109. package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
  110. package/dist/hooks/magic-context/lkg-replay.d.ts +6 -4
  111. package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
  112. package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
  113. package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
  114. package/dist/hooks/magic-context/producer-window-guard.d.ts +4 -1
  115. package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
  116. package/dist/hooks/magic-context/rust-mode-transform.d.ts +1 -0
  117. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  118. package/dist/hooks/magic-context/storage-busy-refusal.d.ts +13 -0
  119. package/dist/hooks/magic-context/storage-busy-refusal.d.ts.map +1 -0
  120. package/dist/hooks/magic-context/strip-content.d.ts +1 -0
  121. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  122. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  123. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  124. package/dist/{index-a9vbtdzv.js → index-33q7s9y2.js} +1 -1
  125. package/dist/{index-cz88kw0n.js → index-4an2p8qa.js} +183 -39
  126. package/dist/{index-d107az47.js → index-638hf49n.js} +1 -1
  127. package/dist/{index-stb5fg12.js → index-9y5p0d50.js} +31 -1
  128. package/dist/{index-s6b7h12g.js → index-dgg5y7er.js} +73 -2
  129. package/dist/{index-6w9p73jz.js → index-jqcbs2k1.js} +10 -0
  130. package/dist/{index-0rp6pj54.js → index-nf9sk8sh.js} +7 -5
  131. package/dist/index-q5p1aqvv.js +7260 -0
  132. package/dist/index-rdsaxnf2.js +125 -0
  133. package/dist/{index-jtdrvmcn.js → index-yhm60r53.js} +37544 -37072
  134. package/dist/index.d.ts.map +1 -1
  135. package/dist/index.js +8402 -14429
  136. package/dist/plugin/dream-timer.d.ts.map +1 -1
  137. package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
  138. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  139. package/dist/plugin/messages-transform.d.ts +10 -9
  140. package/dist/plugin/messages-transform.d.ts.map +1 -1
  141. package/dist/plugin/rpc-handlers.d.ts +1 -0
  142. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  143. package/dist/{read-session-chunk-fkdv2g5b.js → read-session-chunk-n072mcq4.js} +2 -2
  144. package/dist/{recomp-orchestrator-k4h5n0p3.js → recomp-orchestrator-19tr6zya.js} +6 -5
  145. package/dist/{send-session-notification-g2k03zyn.js → send-session-notification-04hvd54c.js} +2 -2
  146. package/dist/shared/model-suggestion-retry.d.ts +1 -1
  147. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  148. package/dist/shared/prompt-async-transport.d.ts +7 -7
  149. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  150. package/dist/shared/rpc-server.d.ts.map +1 -1
  151. package/dist/shared/rpc-utils.d.ts +21 -0
  152. package/dist/shared/rpc-utils.d.ts.map +1 -1
  153. package/dist/shared/run-token-log.d.ts +13 -0
  154. package/dist/shared/run-token-log.d.ts.map +1 -0
  155. package/dist/shared/sqlite-write-locker-test-support.d.ts.map +1 -1
  156. package/dist/shared/sqlite.d.ts +19 -0
  157. package/dist/shared/sqlite.d.ts.map +1 -1
  158. package/dist/shared/subagent-runner.d.ts +3 -1
  159. package/dist/shared/subagent-runner.d.ts.map +1 -1
  160. package/dist/shared/user-facing-codes.d.ts +5 -0
  161. package/dist/shared/user-facing-codes.d.ts.map +1 -1
  162. package/dist/{task-config-mgf5nsh3.js → task-config-2bm68628.js} +1 -1
  163. package/dist/transform-postprocess-phase-z2mfc5w1.js +36 -0
  164. package/dist/v2/hidden-completion.d.ts +9 -1
  165. package/dist/v2/hidden-completion.d.ts.map +1 -1
  166. package/dist/v2/hooks/context.d.ts.map +1 -1
  167. package/dist/v2/hooks/hidden-child.d.ts +1 -0
  168. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  169. package/dist/v2/hooks/hidden-terminal-error.d.ts +8 -0
  170. package/dist/v2/hooks/hidden-terminal-error.d.ts.map +1 -0
  171. package/dist/v2/hooks/lkg-system.d.ts +11 -0
  172. package/dist/v2/hooks/lkg-system.d.ts.map +1 -0
  173. package/dist/v2/hooks/session-project-backfill.d.ts +1 -1
  174. package/dist/v2/hooks/session-project-backfill.d.ts.map +1 -1
  175. package/dist/v2/hooks/storage-gate.d.ts +11 -5
  176. package/dist/v2/hooks/storage-gate.d.ts.map +1 -1
  177. package/dist/v2/hooks/tools.d.ts +1 -1
  178. package/dist/v2/hooks/tools.d.ts.map +1 -1
  179. package/dist/v2/host-service.d.ts +2 -1
  180. package/dist/v2/host-service.d.ts.map +1 -1
  181. package/dist/v2/server.js +24948 -22659
  182. package/dist/v2/store-reader.d.ts +2 -0
  183. package/dist/v2/store-reader.d.ts.map +1 -1
  184. package/dist/{wrapup-orchestrator-35y56636.js → wrapup-orchestrator-sy4m56a7.js} +7 -6
  185. package/package.json +1 -1
  186. package/src/agents/dreamer.ts +4 -6
  187. package/src/agents/hidden-agent-registrations.ts +3 -3
  188. package/src/agents/permissions.test.ts +3 -4
  189. package/src/config/latch-permanence-guard.test.ts +13 -0
  190. package/src/config/live-child-output-cap.test.ts +26 -0
  191. package/src/config/live-child-output-cap.ts +6 -2
  192. package/src/config/schema/magic-context.ts +21 -6
  193. package/src/features/magic-context/dreamer/task-registry.ts +13 -0
  194. package/src/shared/data-path.test.ts +1 -1
  195. package/src/shared/logger.test.ts +1 -0
  196. package/src/shared/model-suggestion-retry.ts +9 -2
  197. package/src/shared/models-dev-cache.test.ts +30 -1
  198. package/src/shared/prompt-async-transport.test.ts +254 -1
  199. package/src/shared/prompt-async-transport.ts +153 -44
  200. package/src/shared/rpc-async-probes.test.ts +230 -0
  201. package/src/shared/rpc-server.ts +6 -4
  202. package/src/shared/rpc-utils.test.ts +27 -1
  203. package/src/shared/rpc-utils.ts +161 -9
  204. package/src/shared/run-token-log.test.ts +65 -0
  205. package/src/shared/run-token-log.ts +39 -0
  206. package/src/shared/sqlite-acquisition-fence.test.ts +132 -0
  207. package/src/shared/sqlite-acquisition-routing.test.ts +102 -0
  208. package/src/shared/sqlite-pass-scope.test.ts +153 -0
  209. package/src/shared/sqlite-transaction-mode-guard.test.ts +42 -10
  210. package/src/shared/sqlite-write-locker-test-support.ts +1 -0
  211. package/src/shared/sqlite.ts +245 -56
  212. package/src/shared/storage-busy.test.ts +72 -0
  213. package/src/shared/subagent-runner.ts +4 -0
  214. package/src/shared/user-facing-codes.ts +6 -0
  215. package/src/shared/windows-hidden-spawns.test.ts +132 -0
  216. package/src/shared/write-transaction-attribution.test.ts +14 -11
@@ -0,0 +1,125 @@
1
+ import {
2
+ renderUserFacingFailure,
3
+ userFacingFailureCode,
4
+ clearEmergencyRecovery,
5
+ dropSlot,
6
+ executeContextRecomp
7
+ } from "./index-yhm60r53.js";
8
+ import {
9
+ sessionLog
10
+ } from "./index-3bygzk2d.js";
11
+
12
+ // src/hooks/magic-context/recomp-orchestrator.ts
13
+ function resolveLiveModelKey(liveSessionState, sessionId) {
14
+ const model = liveSessionState.liveModelBySession.get(sessionId);
15
+ return model ? `${model.providerID}/${model.modelID}` : undefined;
16
+ }
17
+ function isRecompFailure(message) {
18
+ return /—\s*(Failed|Skipped)/.test(message);
19
+ }
20
+ function isRecompSkip(message) {
21
+ return /—\s*Skipped|already mutating compartment state|already running/i.test(message);
22
+ }
23
+ function extractRecompReason(raw) {
24
+ const meaningful = raw.split(`
25
+ `).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#"));
26
+ return meaningful.join(" ").trim() || "Recomp finished";
27
+ }
28
+ var RECOMP_DONE_GRACE_MS = 30000;
29
+ function setRecompStarting2(liveSessionState, sessionId, note, kind = "recomp") {
30
+ dropSlot(sessionId, "recomp-start");
31
+ liveSessionState.recompProgressBySession.set(sessionId, {
32
+ sessionId,
33
+ kind,
34
+ phase: "recomp",
35
+ processedMessages: 0,
36
+ totalMessages: 0,
37
+ passCount: 0,
38
+ compartmentsCreated: 0,
39
+ startedAt: Date.now(),
40
+ updatedAt: Date.now(),
41
+ note
42
+ });
43
+ }
44
+ function setRecompTerminal2(liveSessionState, sessionId, phase, message) {
45
+ const existing = liveSessionState.recompProgressBySession.get(sessionId);
46
+ liveSessionState.recompProgressBySession.set(sessionId, {
47
+ sessionId,
48
+ kind: existing?.kind ?? "recomp",
49
+ phase,
50
+ processedMessages: existing?.processedMessages ?? 0,
51
+ totalMessages: existing?.totalMessages ?? 0,
52
+ passCount: existing?.passCount ?? 0,
53
+ compartmentsCreated: existing?.compartmentsCreated ?? 0,
54
+ startedAt: existing?.startedAt ?? Date.now(),
55
+ updatedAt: Date.now(),
56
+ message
57
+ });
58
+ if (phase === "done" || phase === "skipped") {
59
+ const t = setTimeout(() => {
60
+ const cur = liveSessionState.recompProgressBySession.get(sessionId);
61
+ if (cur?.phase === phase)
62
+ liveSessionState.recompProgressBySession.delete(sessionId);
63
+ }, RECOMP_DONE_GRACE_MS);
64
+ t.unref?.();
65
+ }
66
+ }
67
+ function buildRecompDeps(ctx, sessionId) {
68
+ return {
69
+ client: ctx.client,
70
+ hiddenCompletionExecutor: ctx.hiddenCompletionExecutor,
71
+ db: ctx.db,
72
+ sessionId,
73
+ historianChunkTokens: ctx.historianChunkTokens,
74
+ historianTimeoutMs: ctx.historianTimeoutMs,
75
+ directory: ctx.directory,
76
+ memoryEnabled: ctx.memoryEnabled,
77
+ autoPromote: ctx.autoPromote,
78
+ model: ctx.historianModel,
79
+ historianContextLimit: ctx.historianContextLimit,
80
+ historianMaxOutputTokens: ctx.historianMaxOutputTokens,
81
+ fallbackModels: ctx.fallbackModels,
82
+ language: ctx.language,
83
+ fallbackModelId: ctx.fallbackModelId ?? resolveLiveModelKey(ctx.liveSessionState, sessionId),
84
+ historianTwoPass: ctx.historianTwoPass,
85
+ ensureProjectRegistered: ctx.ensureProjectRegistered,
86
+ getNotificationParams: () => ctx.getNotificationParams(sessionId),
87
+ onCompartmentStatePublished: (sid) => {
88
+ ctx.liveSessionState.historyRefreshSessions.add(sid);
89
+ ctx.liveSessionState.pendingMaterializationSessions.add(sid);
90
+ },
91
+ onDeferredMarkerPending: (sid) => {
92
+ ctx.liveSessionState.deferredHistoryRefreshSessions.add(sid);
93
+ },
94
+ onRecompProgress: (p) => {
95
+ const prevKind = ctx.liveSessionState.recompProgressBySession.get(sessionId)?.kind ?? "recomp";
96
+ ctx.liveSessionState.recompProgressBySession.set(sessionId, {
97
+ ...p,
98
+ kind: p.kind ?? prevKind
99
+ });
100
+ }
101
+ };
102
+ }
103
+ async function runManagedRecomp2(ctx, sessionId, options) {
104
+ setRecompStarting2(ctx.liveSessionState, sessionId, "Starting recomp…", "recomp");
105
+ try {
106
+ const message = await executeContextRecomp(buildRecompDeps(ctx, sessionId), options);
107
+ const terminalPhase = isRecompSkip(message) ? "skipped" : isRecompFailure(message) ? "failed" : "done";
108
+ if (terminalPhase === "done") {
109
+ try {
110
+ clearEmergencyRecovery(ctx.db, sessionId);
111
+ } catch {}
112
+ }
113
+ setRecompTerminal2(ctx.liveSessionState, sessionId, terminalPhase, extractRecompReason(message));
114
+ return message;
115
+ } catch (error) {
116
+ const failure = renderUserFacingFailure("recomp_unavailable");
117
+ sessionLog(sessionId, `recomp failed code=${userFacingFailureCode("recomp_unavailable")}`, error);
118
+ setRecompTerminal2(ctx.liveSessionState, sessionId, "failed", failure);
119
+ return `## Magic Recomp — Failed
120
+
121
+ ${failure}`;
122
+ }
123
+ }
124
+
125
+ export { setRecompStarting2, setRecompTerminal2, runManagedRecomp2 };