@cortexkit/opencode-magic-context 0.49.52 → 0.49.54

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 (156) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +3 -4
  3. package/dist/{context-bkkd7br4.js → context-vx5gw5h2.js} +117 -80
  4. package/dist/{embedding-backfill-3wdjzrvs.js → embedding-backfill-2dvf3rcn.js} +4 -4
  5. package/dist/embedding-worker.js +2 -2
  6. package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -1
  7. package/dist/features/magic-context/message-fts-session-filter.d.ts +1 -1
  8. package/dist/features/magic-context/message-fts-session-filter.d.ts.map +1 -1
  9. package/dist/features/magic-context/project-embedding-registry.d.ts +8 -0
  10. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  11. package/dist/features/magic-context/search.d.ts.map +1 -1
  12. package/dist/features/magic-context/storage-host-instruction-retention.d.ts +10 -3
  13. package/dist/features/magic-context/storage-host-instruction-retention.d.ts.map +1 -1
  14. package/dist/features/magic-context/storage-meta-persisted.d.ts +19 -0
  15. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  16. package/dist/features/magic-context/storage-meta.d.ts +1 -1
  17. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  18. package/dist/features/magic-context/storage.d.ts +1 -1
  19. package/dist/features/magic-context/storage.d.ts.map +1 -1
  20. package/dist/features/magic-context/transform-decision-log.d.ts +1 -1
  21. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  22. package/dist/hooks/magic-context/active-anthropic-turn.d.ts +6 -0
  23. package/dist/hooks/magic-context/active-anthropic-turn.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/compaction-marker-manager.d.ts +2 -1
  25. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
  26. package/dist/hooks/magic-context/emergency-drop.d.ts +75 -2
  27. package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
  28. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  29. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +14 -0
  30. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  31. package/dist/hooks/magic-context/heuristic-cleanup.d.ts +12 -0
  32. package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
  33. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  34. package/dist/hooks/magic-context/host-served-rows.d.ts +12 -2
  35. package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/inject-compartments.d.ts +10 -0
  37. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/latest-assistant-turn.d.ts +43 -0
  39. package/dist/hooks/magic-context/latest-assistant-turn.d.ts.map +1 -1
  40. package/dist/hooks/magic-context/latest-thinking-recovery.d.ts +102 -26
  41. package/dist/hooks/magic-context/latest-thinking-recovery.d.ts.map +1 -1
  42. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts +18 -2
  43. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts.map +1 -1
  44. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
  46. package/dist/hooks/magic-context/pending-marker-rearm.d.ts +20 -0
  47. package/dist/hooks/magic-context/pending-marker-rearm.d.ts.map +1 -0
  48. package/dist/hooks/magic-context/priced-pass-sizing.d.ts +7 -0
  49. package/dist/hooks/magic-context/priced-pass-sizing.d.ts.map +1 -1
  50. package/dist/hooks/magic-context/routine-cleanup-decision.d.ts +11 -1
  51. package/dist/hooks/magic-context/routine-cleanup-decision.d.ts.map +1 -1
  52. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  53. package/dist/hooks/magic-context/served-check.d.ts +127 -0
  54. package/dist/hooks/magic-context/served-check.d.ts.map +1 -0
  55. package/dist/hooks/magic-context/signed-thinking-hold.d.ts +32 -4
  56. package/dist/hooks/magic-context/signed-thinking-hold.d.ts.map +1 -1
  57. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  58. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +35 -1
  59. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  60. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  61. package/dist/index-29ff546v.js +2747 -0
  62. package/dist/{index-8d7gkgjs.js → index-2vsd5064.js} +3 -3
  63. package/dist/{index-kaqs6h31.js → index-52x68mj4.js} +1 -1
  64. package/dist/{index-k2efzh9r.js → index-567xsm72.js} +7 -5
  65. package/dist/{index-q9m97m5g.js → index-5gqszjq9.js} +4 -4
  66. package/dist/{index-a4zmmhxs.js → index-5ptp2de1.js} +6 -8
  67. package/dist/{index-jjy5a5w0.js → index-6nqz8hsz.js} +16 -5
  68. package/dist/{index-a6aqpfp6.js → index-9mggb1nv.js} +403 -1
  69. package/dist/{index-kanfby7e.js → index-9n6mdfqy.js} +452 -442
  70. package/dist/{index-fxgaaptn.js → index-a3n2dczz.js} +8 -7
  71. package/dist/{index-g3j49m95.js → index-b6rdv8re.js} +1 -1
  72. package/dist/{index-qbda6a8k.js → index-by14cr73.js} +30 -19
  73. package/dist/{index-25tm250q.js → index-dhdv88e5.js} +1 -1
  74. package/dist/{index-4xpff2m1.js → index-eyr425dx.js} +820 -179
  75. package/dist/{index-x4h461yf.js → index-h62j8z2r.js} +1 -1
  76. package/dist/{index-xqhejxmd.js → index-pdh4tdcq.js} +1 -1
  77. package/dist/{index-9gs34125.js → index-sk6p6esd.js} +3777 -2544
  78. package/dist/{index-pb8ysnq2.js → index-sv5tn72j.js} +1 -1
  79. package/dist/{index-bamnjp2t.js → index-sx1sppd6.js} +11 -7
  80. package/dist/{index-x7jcqpy6.js → index-tx8nfw85.js} +539 -29
  81. package/dist/{index-42n4fhxy.js → index-xj5bap1r.js} +61 -54
  82. package/dist/{index-rbs27k1d.js → index-xstbytjn.js} +1 -1
  83. package/dist/{index-0jc25yjf.js → index-xvtjwhm6.js} +3 -3
  84. package/dist/{index-qtpkkzan.js → index-yamsmkmh.js} +4 -4
  85. package/dist/index.js +87 -68
  86. package/dist/{message-index-bounded-71b75npz.js → message-index-bounded-xav3h8qe.js} +5 -6
  87. package/dist/migration-worker.js +3 -4
  88. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  89. package/dist/plugin/messages-transform.d.ts +6 -0
  90. package/dist/plugin/messages-transform.d.ts.map +1 -1
  91. package/dist/{project-embedding-registry-5dwh5zfn.js → project-embedding-registry-f2azrq24.js} +5 -3
  92. package/dist/raw-ordinal-warmup-worker.js +4 -4
  93. package/dist/{read-session-chunk-bfv831yx.js → read-session-chunk-70aam2c1.js} +4 -5
  94. package/dist/{recomp-orchestrator-8gj1b7pz.js → recomp-orchestrator-wbm4kpq9.js} +15 -16
  95. package/dist/{render-b3zcz9x4.js → render-73vrt30h.js} +10 -11
  96. package/dist/{search-archive-dp9afcv1.js → search-archive-ew4c3bsw.js} +7 -8
  97. package/dist/{search-y3w590tn.js → search-jfwb4ms3.js} +14 -15
  98. package/dist/shared/test-open-files.d.ts +17 -0
  99. package/dist/shared/test-open-files.d.ts.map +1 -0
  100. package/dist/{storage-tags-kdb4qsyq.js → storage-tags-arnkn5t1.js} +4 -2
  101. package/dist/tools/ctx-expand/search-archive.d.ts.map +1 -1
  102. package/dist/{transform-postprocess-phase-8awze16a.js → transform-postprocess-phase-mt4dcbhd.js} +16 -17
  103. package/dist/v2/auto-search-worker.js +3 -3
  104. package/dist/v2/chunk-embedding-write-worker.js +3 -4
  105. package/dist/v2/{context-99v7x7fm.js → context-13er940g.js} +1147 -467
  106. package/dist/v2/{embedding-backfill-x1zpc04f.js → embedding-backfill-48qbnh7p.js} +4 -4
  107. package/dist/v2/embedding-worker.js +2 -2
  108. package/dist/v2/fold/instruction-supersession.d.ts.map +1 -1
  109. package/dist/v2/hooks/context.d.ts.map +1 -1
  110. package/dist/v2/{message-index-bounded-2pev910h.js → message-index-bounded-sw8hyqw1.js} +5 -6
  111. package/dist/v2/migration-worker.js +3 -4
  112. package/dist/v2/{project-embedding-registry-v2fxrs8b.js → project-embedding-registry-kwahtjgg.js} +5 -3
  113. package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
  114. package/dist/v2/{read-session-chunk-a454a4d2.js → read-session-chunk-nqkn0yb4.js} +4 -5
  115. package/dist/v2/{recomp-orchestrator-03fskpsa.js → recomp-orchestrator-cdkfynz4.js} +15 -16
  116. package/dist/v2/{render-cryx4xsj.js → render-a7j6fqbd.js} +10 -11
  117. package/dist/v2/{search-2qj4w7rw.js → search-8dc9ex0a.js} +13 -14
  118. package/dist/v2/{search-archive-xw2rsq81.js → search-archive-3a36887a.js} +7 -8
  119. package/dist/v2/{server-kreheyw5.js → server-0ayyh3mx.js} +5 -7
  120. package/dist/v2/{server-t8n27rbt.js → server-4x0xq8a1.js} +1 -1
  121. package/dist/v2/{server-kaqs6h31.js → server-52x68mj4.js} +1 -1
  122. package/dist/v2/{server-cpstyzvy.js → server-578pc4tf.js} +3 -3
  123. package/dist/v2/{server-sb55ddgn.js → server-5p0bjk3y.js} +1 -1
  124. package/dist/v2/{server-58h6rrnx.js → server-6k0rnwbd.js} +1 -1
  125. package/dist/v2/{server-y5cma2j1.js → server-79tbtk5w.js} +8 -7
  126. package/dist/v2/{server-b3h8vqa6.js → server-7rmf6a57.js} +538 -28
  127. package/dist/v2/{server-xjzx27w2.js → server-7waad75d.js} +29 -18
  128. package/dist/v2/{server-wq9y9a03.js → server-96g41nad.js} +61 -54
  129. package/dist/v2/{server-txdsx71h.js → server-avfc9ezb.js} +4 -4
  130. package/dist/v2/{server-ww7xbxxf.js → server-b0357as4.js} +357 -1
  131. package/dist/v2/{server-qsvm6w79.js → server-beydmd68.js} +3763 -2484
  132. package/dist/v2/server-gge95a03.js +2687 -0
  133. package/dist/v2/{server-kfw4m268.js → server-jwydbwcx.js} +1 -1
  134. package/dist/v2/{server-brsx45r6.js → server-kwtnrhv3.js} +1 -1
  135. package/dist/v2/{server-4h4acntc.js → server-rpmkz5ta.js} +11 -7
  136. package/dist/v2/{server-0ms13pc8.js → server-rz6g5xne.js} +16 -5
  137. package/dist/v2/{server-dkfs58nq.js → server-v817sf79.js} +1 -1
  138. package/dist/v2/{server-vjadwb3j.js → server-ycvqg2s3.js} +3 -3
  139. package/dist/v2/server.js +4 -4
  140. package/dist/v2/{storage-tags-rzv7y0n3.js → storage-tags-19da4c0m.js} +4 -2
  141. package/dist/v2/{v2-archive-reader-3575hw8s.js → v2-archive-reader-jm3d7ccj.js} +1 -1
  142. package/dist/v2/{wrapup-orchestrator-shzv6t4v.js → wrapup-orchestrator-xnqq81c4.js} +18 -18
  143. package/dist/{v2-archive-reader-75fdm0te.js → v2-archive-reader-9bbfh131.js} +1 -1
  144. package/dist/{wrapup-orchestrator-e0z7nvnx.js → wrapup-orchestrator-svhee0fn.js} +16 -17
  145. package/package.json +1 -1
  146. package/src/shared/escalation-bands.test.ts +16 -1
  147. package/src/shared/sqlite-placeholders.test.ts +103 -0
  148. package/src/shared/storage-file-mutex-review.test.ts +5 -7
  149. package/src/shared/test-open-files.test.ts +194 -0
  150. package/src/shared/test-open-files.ts +71 -0
  151. package/dist/index-bkg4hdyh.js +0 -3865
  152. package/dist/index-d9vfe7xq.js +0 -16
  153. package/dist/index-hsv31e69.js +0 -405
  154. package/dist/v2/server-d9vfe7xq.js +0 -16
  155. package/dist/v2/server-kgq2e2hh.js +0 -361
  156. package/dist/v2/server-rcchadw0.js +0 -3865
@@ -9,7 +9,7 @@ import {
9
9
  } from "./server-pavzsdc6.js";
10
10
  import {
11
11
  cleanUserText2
12
- } from "./server-qsvm6w79.js";
12
+ } from "./server-gge95a03.js";
13
13
  import {
14
14
  recordMessageFtsRowid2,
15
15
  recordIndexedMessageTime2,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_LOCAL_EMBEDDING_MODEL
3
- } from "./server-0ms13pc8.js";
3
+ } from "./server-rz6g5xne.js";
4
4
  import {
5
5
  getHarness2
6
6
  } from "./server-pavzsdc6.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_LOCAL_EMBEDDING_MODEL
3
- } from "./server-0ms13pc8.js";
3
+ } from "./server-rz6g5xne.js";
4
4
  import {
5
5
  embedPauseBySession,
6
6
  activeEmbeddingSessions,
@@ -83,7 +83,7 @@ import {
83
83
  logLocalEmbeddingPoolingUnavailableOnce,
84
84
  getEmbeddingProviderIdentity,
85
85
  LocalEmbeddingProvider
86
- } from "./server-brsx45r6.js";
86
+ } from "./server-kwtnrhv3.js";
87
87
  import {
88
88
  isKnownAutocommit
89
89
  } from "./server-8ajstryz.js";
@@ -2573,17 +2573,21 @@ async function embedItemsForProject2(projectIdentity, items, signal, db, session
2573
2573
  }
2574
2574
  return { vectors, modelId, generation };
2575
2575
  }
2576
- async function embedItemsWindowBounded(projectIdentity, items, signal, db) {
2576
+ async function embedItemsWindowBounded2(projectIdentity, items, signal, db, sessionId = projectIdentity, options = {}) {
2577
2577
  if (items.length <= MAX_WINDOWS_PER_EMBED_CALL) {
2578
- return embedItemsForProject2(projectIdentity, items, signal, db, projectIdentity);
2578
+ return embedItemsForProject2(projectIdentity, items, signal, db, sessionId);
2579
2579
  }
2580
2580
  const vectors = new Map;
2581
2581
  let modelId = null;
2582
2582
  let generation = null;
2583
2583
  for (let start = 0;start < items.length; start += MAX_WINDOWS_PER_EMBED_CALL) {
2584
- const result = await embedItemsForProject2(projectIdentity, items.slice(start, start + MAX_WINDOWS_PER_EMBED_CALL), signal, db, projectIdentity);
2584
+ const slice = items.slice(start, start + MAX_WINDOWS_PER_EMBED_CALL);
2585
+ const result = await embedItemsForProject2(projectIdentity, slice, signal, db, sessionId);
2585
2586
  if (!result)
2586
2587
  return null;
2588
+ if (options.stopOnIncompleteSlice && slice.some((item) => !result.vectors.has(item.id))) {
2589
+ return null;
2590
+ }
2587
2591
  if (modelId === null) {
2588
2592
  modelId = result.modelId;
2589
2593
  generation = result.generation;
@@ -2796,7 +2800,7 @@ async function embedCandidateChunkBatch(db, projectIdentity, modelId, candidates
2796
2800
  let result = null;
2797
2801
  const attemptStart = Date.now();
2798
2802
  try {
2799
- result = await embedItemsWindowBounded(projectIdentity, items, signal, db);
2803
+ result = await embedItemsWindowBounded2(projectIdentity, items, signal, db);
2800
2804
  } catch (error) {
2801
2805
  log2("[magic-context] failed to proactively embed compartment chunks:", error);
2802
2806
  }
@@ -3160,4 +3164,4 @@ function _resetProjectEmbeddingRegistryForTests2() {
3160
3164
  setBootQuietPeriodForTests(null);
3161
3165
  }
3162
3166
 
3163
- export { saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitSha, enforceProjectCap, withQueryEmbeddingDeadline, OpenAICompatibleEmbeddingProvider, describeShadowBackfillWriteRefusal2, listShadowBackfillStalls2, retainProjectEmbedding2, getShadowBackfillStopReason2, markProjectLoadUntrusted2, contentSha2562, drainProjectEmbeddingIdentityMaintenance2, drainStaleEmbeddingIdentitiesForProject2, registerProjectEmbedding2, registerProjectShadowEmbedding2, getShadowEmbeddingMeasurementCohort2, getPrimaryEmbeddingMeasurementCohort2, embedShadowTextForProject2, enqueueShadowEmbeddingItems2, getShadowBackfillRemaining2, flushShadowEmbeddingBacklog2, registerProjectInObservationMode2, unregisterProjectShadowEmbedding2, unregisterProjectEmbedding2, getProjectEmbeddingSnapshot2, installProjectEmbeddingSearchBridge2, getProjectChunkEmbeddingModelId2, getProjectEmbeddingMaxInputTokens2, embedTextForProject2, embedBatchForProject2, embedItemsForProject2, embedUnembeddedMemoriesForProject2, embedUnembeddedMemoriesForProjectOutcome2, drainCommitBacklogForProject2, embedUnembeddedCompartmentChunksForProject2, embedSessionCompartmentChunks2, getEmbeddingCoverageStatus2, getAutoEmbeddingSessionCoverage2, sweepAllRegisteredProjects2, _setTestProviderFactoryForProject2, _resetProjectEmbeddingRegistryForTests2 };
3167
+ export { saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitSha, enforceProjectCap, withQueryEmbeddingDeadline, OpenAICompatibleEmbeddingProvider, describeShadowBackfillWriteRefusal2, listShadowBackfillStalls2, retainProjectEmbedding2, getShadowBackfillStopReason2, markProjectLoadUntrusted2, contentSha2562, drainProjectEmbeddingIdentityMaintenance2, drainStaleEmbeddingIdentitiesForProject2, registerProjectEmbedding2, registerProjectShadowEmbedding2, getShadowEmbeddingMeasurementCohort2, getPrimaryEmbeddingMeasurementCohort2, embedShadowTextForProject2, enqueueShadowEmbeddingItems2, getShadowBackfillRemaining2, flushShadowEmbeddingBacklog2, registerProjectInObservationMode2, unregisterProjectShadowEmbedding2, unregisterProjectEmbedding2, getProjectEmbeddingSnapshot2, installProjectEmbeddingSearchBridge2, getProjectChunkEmbeddingModelId2, getProjectEmbeddingMaxInputTokens2, embedTextForProject2, embedBatchForProject2, embedItemsForProject2, embedItemsWindowBounded2, embedUnembeddedMemoriesForProject2, embedUnembeddedMemoriesForProjectOutcome2, drainCommitBacklogForProject2, embedUnembeddedCompartmentChunksForProject2, embedSessionCompartmentChunks2, getEmbeddingCoverageStatus2, getAutoEmbeddingSessionCoverage2, sweepAllRegisteredProjects2, _setTestProviderFactoryForProject2, _resetProjectEmbeddingRegistryForTests2 };
@@ -1,7 +1,3 @@
1
- import {
2
- DEFAULT_PROTECTED_TOOLS,
3
- mergeProtectedTools
4
- } from "./server-d9vfe7xq.js";
5
1
  import {
6
2
  modelRefLookupOrder
7
3
  } from "./server-avwt563y.js";
@@ -6554,6 +6550,21 @@ function resolvePromptSurface(config, modelKey) {
6554
6550
  return { preset: fallback, source: "default" };
6555
6551
  }
6556
6552
 
6553
+ // src/shared/protected-tools-policy.ts
6554
+ var DEFAULT_PROTECTED_TOOLS = {
6555
+ todowrite: 1,
6556
+ ctx_reduce: 3
6557
+ };
6558
+ function normalizeProtectedToolName(name) {
6559
+ return (name ?? "").toLowerCase().replace(/^mcp_/, "");
6560
+ }
6561
+ function mergeProtectedTools(...maps) {
6562
+ return Object.fromEntries([DEFAULT_PROTECTED_TOOLS, ...maps].flatMap((map) => Object.entries(map ?? {}).map(([name, count]) => [
6563
+ normalizeProtectedToolName(name),
6564
+ count
6565
+ ])));
6566
+ }
6567
+
6557
6568
  // src/config/schema/agent-overrides.ts
6558
6569
  var PermissionValueSchema = _enum(["ask", "allow", "deny"]);
6559
6570
  var PermissionSchema = object({
@@ -7180,4 +7191,4 @@ function deriveDefaultProtectedTokens(usableSoft) {
7180
7191
  return Math.min(64000, Math.max(lowerBound, target));
7181
7192
  }
7182
7193
 
7183
- export { string, number, boolean, unknown, array, object, union, tuple, record, literal, isValidLanguageCode, withContentLanguageDirective, buildPrimaryLanguageDirective, parseCron, nextOccurrence, nextDueAtMs, renderToolTemplate, promptSurfaceConfigIdentity, resolveModelConfigValue, resolvePromptSurface, DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE, DEFAULT_HISTORIAN_TIMEOUT_MS, PROTECTED_TOKENS_MIN, DEFAULT_LOCAL_EMBEDDING_MODEL, PER_HARNESS_MIGRATION_INVENTORY, PER_HARNESS_MODEL_KEYS, ConfigProfilesSchema, DREAM_TASK_PROMOTION_DEFAULTS, MagicContextConfigSchema, LIVE_RELOAD_CONFIG_PATHS, deriveDefaultProtectedTokens };
7194
+ export { string, number, boolean, unknown, array, object, union, tuple, record, literal, isValidLanguageCode, withContentLanguageDirective, buildPrimaryLanguageDirective, parseCron, nextOccurrence, nextDueAtMs, renderToolTemplate, promptSurfaceConfigIdentity, resolveModelConfigValue, resolvePromptSurface, DEFAULT_PROTECTED_TOOLS, normalizeProtectedToolName, mergeProtectedTools, DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE, DEFAULT_HISTORIAN_TIMEOUT_MS, PROTECTED_TOKENS_MIN, DEFAULT_LOCAL_EMBEDDING_MODEL, PER_HARNESS_MIGRATION_INVENTORY, PER_HARNESS_MODEL_KEYS, ConfigProfilesSchema, DREAM_TASK_PROMOTION_DEFAULTS, MagicContextConfigSchema, LIVE_RELOAD_CONFIG_PATHS, deriveDefaultProtectedTokens };
@@ -10,7 +10,7 @@ import {
10
10
  } from "./server-bb6kf05j.js";
11
11
  import {
12
12
  embedTextForProject2
13
- } from "./server-4h4acntc.js";
13
+ } from "./server-rpmkz5ta.js";
14
14
  import {
15
15
  saveEmbeddingIfHashMatches
16
16
  } from "./server-4dhv7mqz.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_LOCAL_EMBEDDING_MODEL
3
- } from "./server-0ms13pc8.js";
3
+ } from "./server-rz6g5xne.js";
4
4
  import {
5
5
  log2
6
6
  } from "./server-bb6kf05j.js";
@@ -10,12 +10,12 @@ import {
10
10
  } from "./server-mxsy9h1d.js";
11
11
  import {
12
12
  LocalEmbeddingProvider
13
- } from "./server-brsx45r6.js";
13
+ } from "./server-kwtnrhv3.js";
14
14
  import {
15
15
  OpenAICompatibleEmbeddingProvider,
16
16
  getProjectEmbeddingSnapshot2,
17
17
  embedBatchForProject2
18
- } from "./server-4h4acntc.js";
18
+ } from "./server-rpmkz5ta.js";
19
19
  import {
20
20
  isEmbeddingHostBusy2
21
21
  } from "./server-qt1qqasc.js";
package/dist/v2/server.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  loadPluginConfigDetailed
3
- } from "./server-sb55ddgn.js";
3
+ } from "./server-5p0bjk3y.js";
4
4
  import {
5
5
  setHarness2
6
6
  } from "./server-pavzsdc6.js";
@@ -22,7 +22,7 @@ import {
22
22
  union,
23
23
  tuple,
24
24
  record
25
- } from "./server-0ms13pc8.js";
25
+ } from "./server-rz6g5xne.js";
26
26
  import {
27
27
  pushNotification2
28
28
  } from "./server-x8a7jmkh.js";
@@ -7875,7 +7875,7 @@ var require_src2 = __commonJS(function(exports, module) {
7875
7875
  // package.json
7876
7876
  var package_default = {
7877
7877
  name: "@cortexkit/opencode-magic-context",
7878
- version: "0.49.52",
7878
+ version: "0.49.54",
7879
7879
  type: "module",
7880
7880
  description: "OpenCode plugin for Magic Context — cross-session memory and context management",
7881
7881
  main: "dist/index.js",
@@ -8196,7 +8196,7 @@ async function setup(context) {
8196
8196
  if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
8197
8197
  log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
8198
8198
  }
8199
- const { registerContext } = await import("./context-99v7x7fm.js");
8199
+ const { registerContext } = await import("./context-13er940g.js");
8200
8200
  setHarness2("opencode2");
8201
8201
  bindStaleBuildNotice({}, import.meta.url, "opencode2");
8202
8202
  const duties = await registerContext(context);
@@ -64,9 +64,11 @@ import {
64
64
  adoptNullOwnerToolTag2,
65
65
  getCandidateToolOwners2,
66
66
  pickNearestPriorOwner2
67
- } from "./server-rcchadw0.js";
67
+ } from "./server-beydmd68.js";
68
68
  import"./server-1zx87sdm.js";
69
- import"./server-ww7xbxxf.js";
69
+ import"./server-rz6g5xne.js";
70
+ import"./server-b0357as4.js";
71
+ import"./server-np27dgyt.js";
70
72
  import"./server-3jc6qmdz.js";
71
73
  import"./server-gzy5w8ya.js";
72
74
  import"./server-bb6kf05j.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  readV2ArchiveOffThread2,
3
3
  serveV2ArchiveReads2
4
- } from "./server-cpstyzvy.js";
4
+ } from "./server-578pc4tf.js";
5
5
  import"./server-v0p37hm2.js";
6
6
  import"./server-gzy5w8ya.js";
7
7
  import"./server-1d042x6w.js";
@@ -11,7 +11,7 @@ import {
11
11
  releaseCompartmentLeaseBestEffort,
12
12
  getCompartments,
13
13
  getLastCompartmentEndMessage
14
- } from "./server-b3h8vqa6.js";
14
+ } from "./server-7rmf6a57.js";
15
15
  import"./server-2amn2s73.js";
16
16
  import"./server-3jc6qmdz.js";
17
17
  import"./server-mxsy9h1d.js";
@@ -24,31 +24,31 @@ import"./server-1d042x6w.js";
24
24
  import"./server-rz5jnhnv.js";
25
25
  import"./server-966dq3pd.js";
26
26
  import"./server-g61hgy1y.js";
27
- import"./server-kfw4m268.js";
27
+ import"./server-jwydbwcx.js";
28
28
  import {
29
29
  getWrapupInProgressState,
30
30
  acquireWrapupInProgress,
31
31
  updateWrapupInProgress,
32
32
  releaseWrapupInProgress,
33
33
  getHistorianFailureState,
34
- clearEmergencyRecovery,
35
- prepareRawSessionOrdinals2
36
- } from "./server-qsvm6w79.js";
37
- import"./server-ww7xbxxf.js";
38
- import"./server-kreheyw5.js";
34
+ clearEmergencyRecovery
35
+ } from "./server-beydmd68.js";
36
+ import"./server-b0357as4.js";
37
+ import"./server-0ayyh3mx.js";
39
38
  import"./server-1zx87sdm.js";
40
- import"./server-rcchadw0.js";
41
- import"./server-0ms13pc8.js";
39
+ import"./server-rz6g5xne.js";
42
40
  import"./server-2ra6pwf3.js";
43
41
  import"./server-7vrtk78d.js";
44
- import"./server-kgq2e2hh.js";
42
+ import {
43
+ prepareRawSessionOrdinals2
44
+ } from "./server-gge95a03.js";
45
45
  import"./server-fr0wbhdn.js";
46
- import"./server-58h6rrnx.js";
46
+ import"./server-6k0rnwbd.js";
47
47
  import"./server-3yk44ddz.js";
48
48
  import"./server-rthnpmbp.js";
49
49
  import"./server-fb3zxn06.js";
50
50
  import"./server-468mya5v.js";
51
- import"./server-t8n27rbt.js";
51
+ import"./server-4x0xq8a1.js";
52
52
  import {
53
53
  pushNotification2
54
54
  } from "./server-x8a7jmkh.js";
@@ -63,16 +63,16 @@ import {
63
63
  registerActiveCompartmentRun,
64
64
  setRecompStarting2,
65
65
  setRecompTerminal2
66
- } from "./server-wq9y9a03.js";
66
+ } from "./server-96g41nad.js";
67
67
  import"./server-qt1qqasc.js";
68
- import"./server-4h4acntc.js";
68
+ import"./server-rpmkz5ta.js";
69
69
  import"./server-qp5sj6n5.js";
70
70
  import"./server-4dhv7mqz.js";
71
- import"./server-brsx45r6.js";
72
- import"./server-vjadwb3j.js";
71
+ import"./server-kwtnrhv3.js";
72
+ import"./server-ycvqg2s3.js";
73
73
  import"./server-jjvbk92s.js";
74
- import"./server-dkfs58nq.js";
75
- import"./server-sb55ddgn.js";
74
+ import"./server-v817sf79.js";
75
+ import"./server-5p0bjk3y.js";
76
76
  import"./server-sa1fdt41.js";
77
77
  import"./server-5kgesxck.js";
78
78
  import"./server-91gb0vh8.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  readV2ArchiveOffThread2,
3
3
  serveV2ArchiveReads2
4
- } from "./index-0jc25yjf.js";
4
+ } from "./index-xvtjwhm6.js";
5
5
  import"./index-v0p37hm2.js";
6
6
  import"./index-gzy5w8ya.js";
7
7
  import"./index-1d042x6w.js";
@@ -1,44 +1,43 @@
1
1
  import {
2
2
  runManagedWrapup2
3
- } from "./index-k2efzh9r.js";
4
- import"./index-qtpkkzan.js";
5
- import"./index-42n4fhxy.js";
3
+ } from "./index-567xsm72.js";
4
+ import"./index-yamsmkmh.js";
5
+ import"./index-xj5bap1r.js";
6
6
  import"./index-90z05d0p.js";
7
7
  import"./index-sd3egckz.js";
8
- import"./index-xqhejxmd.js";
9
- import"./index-8d7gkgjs.js";
8
+ import"./index-pdh4tdcq.js";
9
+ import"./index-2vsd5064.js";
10
10
  import"./index-jjvbk92s.js";
11
- import"./index-bamnjp2t.js";
11
+ import"./index-sx1sppd6.js";
12
12
  import"./index-4dhv7mqz.js";
13
- import"./index-x7jcqpy6.js";
14
- import"./index-25tm250q.js";
15
- import"./index-x4h461yf.js";
13
+ import"./index-tx8nfw85.js";
14
+ import"./index-dhdv88e5.js";
15
+ import"./index-h62j8z2r.js";
16
16
  import"./index-2amn2s73.js";
17
17
  import"./index-6athgjba.js";
18
18
  import"./index-gapnh6tk.js";
19
19
  import"./index-r9agn061.js";
20
20
  import"./index-qt1qqasc.js";
21
- import"./index-9gs34125.js";
22
- import"./index-bkg4hdyh.js";
21
+ import"./index-29ff546v.js";
22
+ import"./index-sk6p6esd.js";
23
23
  import"./index-1zx87sdm.js";
24
24
  import"./index-em92bp7f.js";
25
25
  import"./index-x8a7jmkh.js";
26
26
  import"./index-gz001bx7.js";
27
- import"./index-rbs27k1d.js";
28
- import"./index-jjy5a5w0.js";
27
+ import"./index-xstbytjn.js";
28
+ import"./index-6nqz8hsz.js";
29
29
  import"./index-qperbvjn.js";
30
30
  import"./index-hexdee98.js";
31
31
  import"./index-hsyczpn7.js";
32
- import"./index-a4zmmhxs.js";
32
+ import"./index-5ptp2de1.js";
33
33
  import"./index-fb3zxn06.js";
34
- import"./index-pb8ysnq2.js";
34
+ import"./index-sv5tn72j.js";
35
35
  import"./index-fr0wbhdn.js";
36
36
  import"./index-0k283v27.js";
37
37
  import"./index-2ny9xwdn.js";
38
38
  import"./index-wh9fxds5.js";
39
39
  import"./index-ga5q492k.js";
40
- import"./index-hsv31e69.js";
41
- import"./index-a6aqpfp6.js";
40
+ import"./index-9mggb1nv.js";
42
41
  import"./index-36wseasx.js";
43
42
  import"./index-96ztjvkn.js";
44
43
  import"./index-v0p37hm2.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-magic-context",
3
- "version": "0.49.52",
3
+ "version": "0.49.54",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, test } from "bun:test";
2
- import { escalationBands } from "./escalation-bands";
2
+ import { escalationBands, MAX_EXECUTE_THRESHOLD } from "./escalation-bands";
3
3
 
4
4
  describe("escalationBands", () => {
5
5
  test.each([
@@ -20,4 +20,19 @@ describe("escalationBands", () => {
20
20
  expect(escalationBands(65).forceMaterializationPercentage).toBe(85);
21
21
  expect(escalationBands(80).forceMaterializationPercentage).toBe(85);
22
22
  });
23
+
24
+ // No threshold puts the force band at or above 95%. A pass held for signed
25
+ // thinking therefore never reaches 95% with compaction on (the hold ends in
26
+ // force-band pressure), and neither the OpenCode postprocess phase nor
27
+ // Pi's pipeline has a 95% release for a held turn any more: that removal
28
+ // rests on this bound. Raising the
29
+ // threshold clamp past 92% would let a reading in [95%, threshold + 2%) be
30
+ // held again.
31
+ test("the force band starts below 95% for every threshold", () => {
32
+ expect(escalationBands(Infinity).forceMaterializationPercentage).toBeLessThan(95);
33
+ expect(escalationBands(Number.MAX_VALUE).forceMaterializationPercentage).toBeLessThan(95);
34
+ expect(escalationBands(MAX_EXECUTE_THRESHOLD).forceMaterializationPercentage).toBeLessThan(
35
+ 95,
36
+ );
37
+ });
23
38
  });
@@ -0,0 +1,103 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { readdirSync, readFileSync } from "node:fs";
3
+ import { join, relative, resolve } from "node:path";
4
+ import ts from "typescript";
5
+
6
+ const packagesRoot = resolve(import.meta.dir, "../../..");
7
+ const reason =
8
+ "node:sqlite on Node 22.16 to 22.19 and 24.0 to 24.6 rejects positional arguments for numbered placeholders; use plain ? and pass the value again";
9
+ const sqlStart =
10
+ /^\s*(?:SELECT|WITH|INSERT|UPDATE|DELETE|REPLACE|CREATE|ALTER|DROP|PRAGMA|EXPLAIN)\b/i;
11
+
12
+ function sourceFiles(directory: string): string[] {
13
+ return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
14
+ if (["node_modules", "dist", "target", ".git"].includes(entry.name)) return [];
15
+ const path = join(directory, entry.name);
16
+ return entry.isDirectory() ? sourceFiles(path) : path.endsWith(".ts") ? [path] : [];
17
+ });
18
+ }
19
+
20
+ function numberedSqlPlaceholders(path: string, text = readFileSync(path, "utf8")): string[] {
21
+ if (!/\?[0-9]/.test(text)) return [];
22
+ const source = ts.createSourceFile(path, text, ts.ScriptTarget.Latest, true);
23
+ const violations = new Set<number>();
24
+ function checkLiterals(node: ts.Node): void {
25
+ if (
26
+ (ts.isStringLiteralLike(node) || ts.isTemplateLiteralToken(node)) &&
27
+ /\?[0-9]/.test(node.text)
28
+ ) {
29
+ violations.add(source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1);
30
+ }
31
+ ts.forEachChild(node, checkLiterals);
32
+ }
33
+ function visit(node: ts.Node): void {
34
+ // The AST excludes comments and regex literals. Inspect whole SQL expressions
35
+ // so a numbered placeholder inside a template interpolation is caught too.
36
+ if (ts.isCallExpression(node)) {
37
+ const callee = node.expression;
38
+ const name = ts.isPropertyAccessExpression(callee)
39
+ ? callee.name.text
40
+ : ts.isIdentifier(callee)
41
+ ? callee.text
42
+ : "";
43
+ if (["prepare", "exec", "query"].includes(name) && node.arguments[0])
44
+ checkLiterals(node.arguments[0]);
45
+ }
46
+ if (
47
+ ts.isVariableDeclaration(node) &&
48
+ ts.isIdentifier(node.name) &&
49
+ /sql/i.test(node.name.text) &&
50
+ node.initializer
51
+ ) {
52
+ checkLiterals(node.initializer);
53
+ }
54
+ const head = ts.isTemplateExpression(node)
55
+ ? node.head.text
56
+ : ts.isStringLiteralLike(node)
57
+ ? node.text
58
+ : "";
59
+ if (sqlStart.test(head)) checkLiterals(node);
60
+ ts.forEachChild(node, visit);
61
+ }
62
+ visit(source);
63
+ return [...violations]
64
+ .sort((a, b) => a - b)
65
+ .map((line) => `${relative(packagesRoot, path)}:${line}`);
66
+ }
67
+
68
+ describe("SQLite positional placeholders", () => {
69
+ test("rejects numbered SQL placeholders across every package", () => {
70
+ const violations = sourceFiles(packagesRoot).flatMap((path) =>
71
+ numberedSqlPlaceholders(path),
72
+ );
73
+ expect(violations, reason).toEqual([]);
74
+ });
75
+
76
+ test("finds SQL calls, named fragments, returned SQL and interpolated placeholders", () => {
77
+ const fixtures = [
78
+ 'db.prepare("SELECT ?1").get(value)',
79
+ "db.query(`SELECT ${flag ? '?1' : '?'}`).get(value)",
80
+ 'db.exec("INSERT INTO t VALUES (?2)")',
81
+ 'const MESSAGE_FILTER_SQL = " AND session_id = ?1"',
82
+ 'function select() { return "SELECT ?3"; }',
83
+ 'db.prepare<{ x: string }>("SELECT ?1")',
84
+ ];
85
+ for (const fixture of fixtures)
86
+ expect(numberedSqlPlaceholders("fixture.ts", fixture)).toHaveLength(1);
87
+ });
88
+
89
+ test("ignores comments, regexes, prose and anonymous SQL bindings", () => {
90
+ expect(
91
+ numberedSqlPlaceholders(
92
+ "fixture.ts",
93
+ [
94
+ "// SELECT ?1",
95
+ "/* db.prepare('SELECT ?2') */",
96
+ "const model = /[-_.]?5[-_.]1/;",
97
+ 'const prose = "Did you mean ?1 or ?2?";',
98
+ 'db.prepare("SELECT ?, ?").get(x, x);',
99
+ ].join("\n"),
100
+ ),
101
+ ).toEqual([]);
102
+ });
103
+ });
@@ -1,10 +1,10 @@
1
1
  import { expect, spyOn, test } from "bun:test";
2
- import { spawnSync } from "node:child_process";
3
2
  import { readdirSync, readFileSync, rmdirSync, writeFileSync } from "node:fs";
4
3
  import { join } from "node:path";
5
4
  import { __resetRpcIdentityTestHooks, __setRpcIdentityTestHooks } from "./rpc-utils";
6
5
  import { withStorageFileMutex } from "./storage-file-mutex";
7
6
  import * as permissions from "./storage-permissions";
7
+ import { listOpenFiles } from "./test-open-files";
8
8
  import { createTestTempDir } from "./test-temp-dir";
9
9
 
10
10
  const mutex = join(import.meta.dir, "storage-file-mutex.ts");
@@ -54,12 +54,10 @@ withStorageFileMutex(${JSON.stringify(join(root, "locks"))}, () => {
54
54
  expect(new TextDecoder().decode(first.value)).toContain("HELD");
55
55
  reader.releaseLock();
56
56
  if (process.platform === "darwin") {
57
- const files = spawnSync("/usr/sbin/lsof", ["-p", String(child.pid), "-Fn"], {
58
- encoding: "utf8",
59
- windowsHide: true,
60
- });
61
- expect(files.status).toBe(0);
62
- const names = files.stdout.split("\n").filter((line) => line.startsWith("n"));
57
+ const files = listOpenFiles(child.pid);
58
+ // A paused child's isolation cannot be established from a missing inventory.
59
+ if (!files.available) throw new Error(files.reason);
60
+ const names = files.paths;
63
61
  expect(
64
62
  names.some((line) =>
65
63
  /\/(?:\.local\/share\/opencode|\.local\/share\/cortexkit\/magic-context|\.config\/(?:opencode|cortexkit))\//.test(