@cortexkit/opencode-magic-context 0.49.28 → 0.49.30

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 (128) hide show
  1. package/dist/auto-search-worker.js +3 -3
  2. package/dist/chunk-embedding-write-worker.js +1 -1
  3. package/dist/config/commit-retention-recovery.d.ts +9 -0
  4. package/dist/config/commit-retention-recovery.d.ts.map +1 -0
  5. package/dist/config/index.d.ts +2 -1
  6. package/dist/config/index.d.ts.map +1 -1
  7. package/dist/config/live-child-output-cap.d.ts.map +1 -1
  8. package/dist/config/live-run-config.d.ts.map +1 -1
  9. package/dist/config/project-security.d.ts +1 -0
  10. package/dist/config/project-security.d.ts.map +1 -1
  11. package/dist/{conflict-warning-hook-tgnw019g.js → conflict-warning-hook-xgskea1v.js} +3 -3
  12. package/dist/{context-dxfztzsd.js → context-vnfr6d7t.js} +210 -50
  13. package/dist/{embedding-backfill-cwnyr4fj.js → embedding-backfill-mms9nb0h.js} +2 -2
  14. package/dist/features/magic-context/dreamer/evaluate-smart-notes.d.ts.map +1 -1
  15. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  16. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  18. package/dist/features/magic-context/dreamer/verify-diff.d.ts.map +1 -1
  19. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  20. package/dist/features/magic-context/git-commits/indexer.d.ts +2 -0
  21. package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -1
  22. package/dist/features/magic-context/project-embedding-registry.d.ts +3 -1
  23. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  24. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  25. package/dist/features/magic-context/work-metrics.d.ts +5 -3
  26. package/dist/features/magic-context/work-metrics.d.ts.map +1 -1
  27. package/dist/hooks/magic-context/apply-operations.d.ts +2 -0
  28. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  29. package/dist/hooks/magic-context/compartment-runner-types.d.ts +5 -1
  30. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  31. package/dist/hooks/magic-context/history-boundary-repair.d.ts +1 -1
  32. package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
  33. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts +3 -1
  34. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts.map +1 -1
  35. package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/lkg-slot.d.ts +7 -0
  37. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/read-session-db.d.ts +3 -2
  40. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  41. package/dist/hooks/magic-context/replay-committed-drops.d.ts.map +1 -1
  42. package/dist/hooks/magic-context/strip-content.d.ts +1 -1
  43. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  44. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  45. package/dist/{index-yzjhx10y.js → index-0fe4q77z.js} +12 -6
  46. package/dist/{index-89k1w6x2.js → index-3jmx3fae.js} +2 -2
  47. package/dist/{index-7gbcg8xv.js → index-4s4zq97n.js} +1 -1
  48. package/dist/{index-31y1mznz.js → index-69gd2scx.js} +4 -4
  49. package/dist/{index-n8qmmd7f.js → index-adr4vfys.js} +3 -3
  50. package/dist/{index-k9jx7ma9.js → index-ekzzw66a.js} +328 -249
  51. package/dist/{index-tvzvjggy.js → index-gkee6p4g.js} +1 -1
  52. package/dist/{index-a2fz9hpa.js → index-gxkhzmjq.js} +4 -2
  53. package/dist/{index-4cpc59jv.js → index-hbt0sbv2.js} +1 -1
  54. package/dist/{index-dcqk0y27.js → index-k0dpkyn7.js} +139 -28
  55. package/dist/{index-t3rbb8wr.js → index-pe6b4bhs.js} +1 -1
  56. package/dist/{index-4ypqzvhf.js → index-vnn5405n.js} +1 -1
  57. package/dist/{index-dzfevacx.js → index-vtz789ex.js} +10 -6
  58. package/dist/{index-fq2p158w.js → index-vzz570j8.js} +13 -7
  59. package/dist/{index-077ht5cq.js → index-waktfbjy.js} +1 -1
  60. package/dist/{index-v0dhhxsq.js → index-y1qwzvxn.js} +5 -5
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +26 -30
  63. package/dist/{message-index-bounded-7ayzb2ah.js → message-index-bounded-zq7a5nm6.js} +3 -3
  64. package/dist/migration-worker.js +1 -1
  65. package/dist/plugin/dream-timer.d.ts.map +1 -1
  66. package/dist/plugin/embedding-bootstrap-helpers.d.ts +5 -1
  67. package/dist/plugin/embedding-bootstrap-helpers.d.ts.map +1 -1
  68. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  69. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  70. package/dist/{project-embedding-registry-94nncs5g.js → project-embedding-registry-cg281d9j.js} +1 -1
  71. package/dist/raw-ordinal-warmup-worker.js +2 -2
  72. package/dist/{read-session-chunk-jzb6w9w5.js → read-session-chunk-1ndphmb8.js} +2 -2
  73. package/dist/{recomp-orchestrator-02sa2ngr.js → recomp-orchestrator-w3pjp33d.js} +10 -10
  74. package/dist/{search-archive-q1vw7zg4.js → search-archive-sr07c6aj.js} +3 -3
  75. package/dist/{search-spq6nfyf.js → search-fbaz1m8r.js} +7 -7
  76. package/dist/{send-session-notification-afzzqy5b.js → send-session-notification-vz86nt79.js} +2 -2
  77. package/dist/shared/marker-only-text.d.ts +2 -0
  78. package/dist/shared/marker-only-text.d.ts.map +1 -0
  79. package/dist/{transform-postprocess-phase-6menyyxc.js → transform-postprocess-phase-6ccazq85.js} +10 -10
  80. package/dist/v2/auto-search-worker.js +3 -3
  81. package/dist/v2/chunk-embedding-write-worker.js +1 -1
  82. package/dist/v2/{context-0qhz1nnj.js → context-wx4sfhgr.js} +345 -102
  83. package/dist/v2/{embedding-backfill-rh5dgsva.js → embedding-backfill-35k6czrr.js} +2 -2
  84. package/dist/v2/hidden-child-cleanup.d.ts.map +1 -1
  85. package/dist/v2/hidden-child-native.d.ts.map +1 -1
  86. package/dist/v2/hidden-completion.d.ts.map +1 -1
  87. package/dist/v2/hooks/context.d.ts.map +1 -1
  88. package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
  89. package/dist/v2/hooks/store.d.ts.map +1 -1
  90. package/dist/v2/{message-index-bounded-n09b74vr.js → message-index-bounded-jvgz7vk9.js} +3 -3
  91. package/dist/v2/message-times.d.ts +17 -0
  92. package/dist/v2/message-times.d.ts.map +1 -0
  93. package/dist/v2/migration-worker.js +1 -1
  94. package/dist/v2/{project-embedding-registry-6pak822h.js → project-embedding-registry-p1p10ks7.js} +1 -1
  95. package/dist/v2/raw-ordinal-warmup-worker.js +2 -2
  96. package/dist/v2/{read-session-chunk-vpt69tw9.js → read-session-chunk-djzgm4jg.js} +2 -2
  97. package/dist/v2/{recomp-orchestrator-txsmbnvw.js → recomp-orchestrator-wb28kr9k.js} +10 -10
  98. package/dist/v2/{search-archive-t9bcz4ht.js → search-archive-n3dhns4r.js} +3 -3
  99. package/dist/v2/{search-dcy9b6gd.js → search-q3jjw6zp.js} +7 -7
  100. package/dist/v2/{send-session-notification-vdsgnf4c.js → send-session-notification-x5nzy34v.js} +2 -2
  101. package/dist/v2/{server-txbc3czn.js → server-42nebt63.js} +10 -6
  102. package/dist/v2/{server-94wk1ey3.js → server-835q39kd.js} +45 -5
  103. package/dist/v2/{server-3vhxy2k5.js → server-a7x00tw8.js} +5 -5
  104. package/dist/v2/{server-e3hc93wk.js → server-d01pe8q5.js} +1 -1
  105. package/dist/v2/{server-z2n2xaeh.js → server-hwag0khr.js} +1 -1
  106. package/dist/v2/{server-jj9qye8y.js → server-k33t88h3.js} +97 -25
  107. package/dist/v2/{server-6avtp9jp.js → server-p0snacz3.js} +1 -1
  108. package/dist/v2/{server-z3mk9jdc.js → server-ph300d6m.js} +1 -1
  109. package/dist/v2/{server-6v3cdzsx.js → server-qc915kw2.js} +1 -1
  110. package/dist/v2/{server-xkvxss5g.js → server-rb8m4vry.js} +12 -6
  111. package/dist/v2/{server-zmcrvpm3.js → server-rr4cbkr0.js} +2 -2
  112. package/dist/v2/{server-yqek3s4k.js → server-zh3esb0z.js} +4 -2
  113. package/dist/v2/server.js +3 -3
  114. package/dist/v2/store-reader.d.ts +14 -2
  115. package/dist/v2/store-reader.d.ts.map +1 -1
  116. package/dist/v2/{wrapup-orchestrator-gjkszser.js → wrapup-orchestrator-2t0pdqzm.js} +10 -10
  117. package/dist/{wrapup-orchestrator-n5h5sr1x.js → wrapup-orchestrator-kjmkms5g.js} +11 -11
  118. package/package.json +1 -1
  119. package/src/config/commit-retention-recovery.ts +34 -0
  120. package/src/config/index.ts +22 -2
  121. package/src/config/live-child-output-cap.test.ts +28 -0
  122. package/src/config/live-child-output-cap.ts +2 -0
  123. package/src/config/live-run-config.test.ts +44 -1
  124. package/src/config/live-run-config.ts +8 -1
  125. package/src/config/project-config-trust-boundary.test.ts +57 -0
  126. package/src/config/project-security.ts +6 -2
  127. package/src/shared/marker-only-text.ts +8 -0
  128. package/src/shared/windows-hidden-spawns.test.ts +133 -23
@@ -4,7 +4,7 @@ import {
4
4
  } from "./index-h7tgn49j.js";
5
5
  import {
6
6
  sendStatusNotification2
7
- } from "./index-077ht5cq.js";
7
+ } from "./index-waktfbjy.js";
8
8
  import {
9
9
  formatConflictShort
10
10
  } from "./index-4pnsgvfk.js";
@@ -1397,6 +1397,7 @@ function snapshotFor(registration) {
1397
1397
  runtimeFingerprint: registration.runtimeFingerprint,
1398
1398
  generation: registration.generation,
1399
1399
  features: { ...registration.features },
1400
+ ...registration.memoryDisabledReason ? { memoryDisabledReason: registration.memoryDisabledReason } : {},
1400
1401
  enabled,
1401
1402
  historyEnabled,
1402
1403
  gitCommitEnabled,
@@ -2366,7 +2367,7 @@ async function runShadowWorker() {
2366
2367
  await new Promise((resolve) => setTimeout(resolve, 0));
2367
2368
  }
2368
2369
  }
2369
- function registerProjectInObservationMode2(db, projectIdentity, sourceDirectory, failedConfig, failureSummary) {
2370
+ function registerProjectInObservationMode2(db, projectIdentity, sourceDirectory, failedConfig, failureSummary, memoryDisabledReason) {
2370
2371
  const prior = projectRegistrations.get(projectIdentity);
2371
2372
  const runtimeFingerprint = `observation:${sha256Prefix(failureSummary)}`;
2372
2373
  const generation = prior?.runtimeFingerprint === runtimeFingerprint && prior.observationMode ? prior.generation : ++globalRegistrationGeneration;
@@ -2381,7 +2382,8 @@ function registerProjectInObservationMode2(db, projectIdentity, sourceDirectory,
2381
2382
  features: { memoryEnabled: false, gitCommitEnabled: false },
2382
2383
  modelId: "off",
2383
2384
  chunkModelId: "off",
2384
- observationMode: true
2385
+ observationMode: true,
2386
+ memoryDisabledReason
2385
2387
  };
2386
2388
  projectRegistrations.set(projectIdentity, registration);
2387
2389
  disposeProvider(prior?.provider ?? null);
@@ -1279,7 +1279,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1279
1279
  state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
1280
1280
  if (signal.aborted || !readsOpenCodeStore)
1281
1281
  return;
1282
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-jzb6w9w5.js"));
1282
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-1ndphmb8.js"));
1283
1283
  const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-4qva0b4f.js"));
1284
1284
  if (signal.aborted)
1285
1285
  return;
@@ -98,7 +98,7 @@ import {
98
98
  getRawSessionTagKeysThrough2,
99
99
  getLegacyProtectedTailStartOrdinal2,
100
100
  readSessionChunk2
101
- } from "./index-yzjhx10y.js";
101
+ } from "./index-0fe4q77z.js";
102
102
  import {
103
103
  getHarness2,
104
104
  harnessOwnsOpenCodeStore2
@@ -174,7 +174,7 @@ import {
174
174
  LATEST_SUPPORTED_VERSION,
175
175
  getPersistedSchemaVersion,
176
176
  openDatabase
177
- } from "./index-4cpc59jv.js";
177
+ } from "./index-hbt0sbv2.js";
178
178
  import {
179
179
  inRootAsyncContext2,
180
180
  Database2,
@@ -237,7 +237,7 @@ import {
237
237
  getProjectChunkEmbeddingModelId2,
238
238
  getProjectEmbeddingMaxInputTokens2,
239
239
  embedItemsForProject2
240
- } from "./index-a2fz9hpa.js";
240
+ } from "./index-gxkhzmjq.js";
241
241
  import {
242
242
  buildCanonicalChunkTextFromFts2,
243
243
  buildCompartmentSummaryFallbackText2,
@@ -254,7 +254,7 @@ import {
254
254
  toMessageIndexSource,
255
255
  clearIndexedMessagesInTransaction,
256
256
  indexSourcesAfterOrdinal
257
- } from "./index-7gbcg8xv.js";
257
+ } from "./index-4s4zq97n.js";
258
258
  import {
259
259
  stripWellFormedLeadingTagPrefix,
260
260
  stripTagPrefix,
@@ -272,7 +272,7 @@ import {
272
272
  openCodeDbExists,
273
273
  withReadOnlySessionDb,
274
274
  getMessageTimesFromOpenCodeDb
275
- } from "./index-v0dhhxsq.js";
275
+ } from "./index-y1qwzvxn.js";
276
276
  import {
277
277
  renderUserFacingFailure,
278
278
  userFacingFailureCode,
@@ -281,7 +281,7 @@ import {
281
281
  insertPrimerCandidates,
282
282
  promoteSessionFactsDurable,
283
283
  embedPromotedFacts
284
- } from "./index-t3rbb8wr.js";
284
+ } from "./index-pe6b4bhs.js";
285
285
  import {
286
286
  pushNotification2
287
287
  } from "./index-x8a7jmkh.js";
@@ -301,7 +301,7 @@ import {
301
301
  } from "./index-qgh1qwjj.js";
302
302
  import {
303
303
  sendStatusNotification2
304
- } from "./index-077ht5cq.js";
304
+ } from "./index-waktfbjy.js";
305
305
  import {
306
306
  isCompactionEnabled,
307
307
  migrateLegacyAgentEnabledInMemory
@@ -641,6 +641,30 @@ function claimConfigParseFailuresOnce(surface, failures) {
641
641
  });
642
642
  }
643
643
 
644
+ // src/config/commit-retention-recovery.ts
645
+ var pausedRetention = new WeakSet;
646
+ var RETENTION_FIELD = "memory.git_commit_indexing.max_commits";
647
+ function applyCommitRetentionRecovery(config, recoveredFieldPaths, warnings) {
648
+ if (!recoveredFieldPaths.some((path) => RETENTION_FIELD === path || RETENTION_FIELD.startsWith(`${path}.`)))
649
+ return;
650
+ pausedRetention.add(config.memory.git_commit_indexing);
651
+ const message = `${RETENTION_FIELD}: retention eviction is paused until the invalid value is fixed.`;
652
+ const index = warnings.findIndex((warning) => warning.includes(RETENTION_FIELD));
653
+ if (index >= 0)
654
+ warnings[index] = `${warnings[index]} ${message}`;
655
+ else
656
+ warnings.push(message);
657
+ }
658
+ function isCommitRetentionPaused(settings) {
659
+ return pausedRetention.has(settings);
660
+ }
661
+ function copyCommitRetentionRecovery(from, to) {
662
+ if (pausedRetention.has(from))
663
+ pausedRetention.add(to);
664
+ else
665
+ pausedRetention.delete(to);
666
+ }
667
+
644
668
  // src/config/deprecated-config.ts
645
669
  var MURAL_MODEL_DEPRECATION_WARNING = "mural.model is deprecated and ignored; compress-cues now uses the dreamer model for each harness, like every other dreamer task. To override it, set dreamer.opencode.tasks.compress-cues.model (or the pi/omp equivalent). This key no longer does anything; remove it.";
646
670
  var WINDOW_OVERLAY_PATH_DEPRECATION_WARNING = "models.window_overlay_path is deprecated and ignored; Fusiform no longer publishes window-overlay data, so this setting no longer changes model window geometry. Remove this key.";
@@ -2028,7 +2052,11 @@ function restoreTrustedValuesOverInvalidProjectValues(args) {
2028
2052
  if (!changed)
2029
2053
  break;
2030
2054
  }
2031
- return { warnings, restoredTopLevelKeys: [...restoredTopLevelKeys] };
2055
+ return {
2056
+ warnings,
2057
+ restoredTopLevelKeys: [...restoredTopLevelKeys],
2058
+ restoredFieldPaths: [...restored]
2059
+ };
2032
2060
  }
2033
2061
  var PROJECT_COMMAND_STRING_FIELDS = ["description", "agent", "model"];
2034
2062
  function wellFormedCommand(value) {
@@ -2804,7 +2832,7 @@ function warnProtectedTagsDeprecationOnce() {
2804
2832
  log2("[magic-context] protected_tags is deprecated and ignored; use protected_tokens instead.");
2805
2833
  }
2806
2834
  }
2807
- function parsePluginConfig(rawConfig, recoveredTopLevelKeys = []) {
2835
+ function parsePluginConfig(rawConfig, recoveredTopLevelKeys = [], recoveredFieldPaths = []) {
2808
2836
  const preMigrationWarnings = [];
2809
2837
  const configWithoutRemovedAgent = stripRemovedAgentConfig(rawConfig, preMigrationWarnings);
2810
2838
  if (Object.hasOwn(rawConfig, "clear_reasoning_age")) {
@@ -2886,11 +2914,13 @@ function parsePluginConfig(rawConfig, recoveredTopLevelKeys = []) {
2886
2914
  }
2887
2915
  if (prunedLeaves.length === issuePaths.length) {
2888
2916
  patched[key] = prunedBlock;
2917
+ recoveredFieldPaths.push(...prunedLeaves.map((leaf) => `${key}.${leaf}`));
2889
2918
  const reason = customMessagesByKey.get(key);
2890
2919
  warnings.push(`"${key}": invalid nested field(s) ${prunedLeaves.map((leaf) => `"${key}.${leaf}"`).join(", ")}, using defaults for those.${reason ? ` ${reason}` : ""}`);
2891
2920
  continue;
2892
2921
  }
2893
2922
  }
2923
+ recoveredFieldPaths.push(key);
2894
2924
  if (isAgentConfig) {
2895
2925
  delete patched[key];
2896
2926
  warnings.push(`"${key}": invalid agent configuration, ignoring. Check your magic-context.jsonc.`);
@@ -2917,6 +2947,7 @@ function parsePluginConfig(rawConfig, recoveredTopLevelKeys = []) {
2917
2947
  };
2918
2948
  }
2919
2949
  warnings.push("Config recovery failed, using all defaults.");
2950
+ recoveredFieldPaths.push("embedding", "memory", "subc", "shadow_embedding", "allow_home_project");
2920
2951
  return {
2921
2952
  ...defaults,
2922
2953
  disabled_hooks: disabledHooks,
@@ -3025,6 +3056,7 @@ function loadPluginConfigDetailed(directory, applyRuntimeGlobals = true) {
3025
3056
  let mergedRaw = trustedProfiledRaw;
3026
3057
  const trustedBaseConfig = parsePluginConfig(trustedProfiledRaw);
3027
3058
  let projectRestoredTopLevelKeys = [];
3059
+ let projectRestoredFieldPaths = [];
3028
3060
  if (projectLoaded) {
3029
3061
  mergedRaw = deepMergeRawConfig(mergedRaw, profileResolution.projectBase);
3030
3062
  for (const warning of dropInheritedEmbeddingKeyOnRedirect(projectRaw, mergedRaw, profileResolution.userBase)) {
@@ -3047,6 +3079,7 @@ function loadPluginConfigDetailed(directory, applyRuntimeGlobals = true) {
3047
3079
  allWarnings.push(`[project config] ${warning}`);
3048
3080
  }
3049
3081
  projectRestoredTopLevelKeys = restoredOverProject.restoredTopLevelKeys;
3082
+ projectRestoredFieldPaths = restoredOverProject.restoredFieldPaths;
3050
3083
  for (const warning of constrainProjectCommands({
3051
3084
  mergedRaw,
3052
3085
  trustedRaw: trustedProfiledRaw,
@@ -3057,8 +3090,10 @@ function loadPluginConfigDetailed(directory, applyRuntimeGlobals = true) {
3057
3090
  }
3058
3091
  }
3059
3092
  const recoveredTopLevelKeys = [];
3093
+ const recoveredFieldPaths = [];
3060
3094
  const cacheTtlConfigured = Object.hasOwn(mergedRaw, "cache_ttl");
3061
- const config = parsePluginConfig(mergedRaw, recoveredTopLevelKeys);
3095
+ const config = parsePluginConfig(mergedRaw, recoveredTopLevelKeys, recoveredFieldPaths);
3096
+ recoveredFieldPaths.push(...projectRestoredFieldPaths);
3062
3097
  for (const key of projectRestoredTopLevelKeys) {
3063
3098
  if (!recoveredTopLevelKeys.includes(key))
3064
3099
  recoveredTopLevelKeys.push(key);
@@ -3072,7 +3107,11 @@ function loadPluginConfigDetailed(directory, applyRuntimeGlobals = true) {
3072
3107
  if (applyRuntimeGlobals) {
3073
3108
  setOutputReserveConfig(config.output_reserve);
3074
3109
  }
3075
- const leafValidationWarnings = [...config.configWarnings ?? []];
3110
+ const recoveryWarnings = config.configWarnings ?? [];
3111
+ applyCommitRetentionRecovery(config, recoveredFieldPaths, recoveryWarnings);
3112
+ if (recoveryWarnings.length > 0)
3113
+ config.configWarnings = recoveryWarnings;
3114
+ const leafValidationWarnings = [...recoveryWarnings];
3076
3115
  if (config.configWarnings?.length) {
3077
3116
  allWarnings.push(...config.configWarnings.map((w) => {
3078
3117
  if (userLoaded && projectLoaded)
@@ -3124,6 +3163,7 @@ function loadPluginConfigDetailed(directory, applyRuntimeGlobals = true) {
3124
3163
  sources,
3125
3164
  substitutionFailures,
3126
3165
  recoveredTopLevelKeys,
3166
+ recoveredFieldPaths,
3127
3167
  configParseFailures,
3128
3168
  warningDetails,
3129
3169
  cacheTtlConfigured
@@ -3289,7 +3329,13 @@ function sampleLiveConfig(boot, fresh) {
3289
3329
  if (leaf !== undefined)
3290
3330
  target[leaf] = value;
3291
3331
  }
3292
- return result;
3332
+ const sampled = result;
3333
+ const freshCommitIndexing = fresh.memory?.git_commit_indexing;
3334
+ const sampledCommitIndexing = sampled.memory?.git_commit_indexing;
3335
+ if (freshCommitIndexing && sampledCommitIndexing) {
3336
+ copyCommitRetentionRecovery(freshCommitIndexing, sampledCommitIndexing);
3337
+ }
3338
+ return sampled;
3293
3339
  }
3294
3340
  function removeLeaf(root, parts) {
3295
3341
  const parents = parts.slice(0, -1);
@@ -3354,6 +3400,7 @@ function withLiveDreamerOutputCap(executor, boot, fresh) {
3354
3400
  }),
3355
3401
  attempt: (handle, request) => executor.attempt(handle, request),
3356
3402
  collect: (handle, limit) => executor.collect(handle, limit),
3403
+ collectPartial: (handle, limit) => executor.collectPartial?.(handle, limit) ?? executor.collect(handle, limit),
3357
3404
  close: (handle, settlement) => executor.close(handle, settlement)
3358
3405
  };
3359
3406
  }
@@ -5766,9 +5813,10 @@ class V2StoreReaderPool {
5766
5813
  this.idleWaiters.clear();
5767
5814
  }
5768
5815
  }
5769
- function messageTimesQuery(count) {
5816
+ function messageTimesQuery(count, withVersions = false) {
5770
5817
  return `SELECT id, COALESCE(time_created, json_extract(data, '$.time.created')) AS created,
5771
5818
  json_extract(data, '$.time.completed') AS completed
5819
+ ${withVersions ? ", type, seq, time_created AS version_created, time_updated AS version_updated" : ""}
5772
5820
  FROM session_message WHERE +session_id = ? AND id IN (${Array.from({ length: count }, () => "?").join(",")})`;
5773
5821
  }
5774
5822
 
@@ -5993,16 +6041,46 @@ class V2StoreReader {
5993
6041
  return row ? decode(row) : null;
5994
6042
  });
5995
6043
  }
5996
- messageTimes(sessionID, ids) {
5997
- const times = new Map;
6044
+ messageTimeVersions(sessionID, ids, span) {
6045
+ const versions = new Map;
6046
+ if (ids.length > 0 && span && span.last - span.first < ids.length * 2) {
6047
+ const wanted = new Set(ids);
6048
+ const rows = this.prepare(`SELECT id, type, seq, time_created AS created, time_updated AS updated
6049
+ FROM session_message WHERE session_id = ? AND seq >= ? AND seq <= ?`).all(sessionID, span.first, span.last);
6050
+ for (const row of rows)
6051
+ if (wanted.has(row.id))
6052
+ versions.set(row.id, row);
6053
+ for (const [id, version] of this.messageTimeVersions(sessionID, ids.filter((id) => !versions.has(id))))
6054
+ versions.set(id, version);
6055
+ return versions;
6056
+ }
5998
6057
  for (let offset = 0;offset < ids.length; offset += 500) {
5999
6058
  const batch = ids.slice(offset, offset + 500);
6000
- const rows = this.prepare(messageTimesQuery(batch.length)).all(sessionID, ...batch);
6059
+ const rows = this.prepare(`SELECT id, type, seq, time_created AS created, time_updated AS updated
6060
+ FROM session_message WHERE +session_id = ? AND id IN (${batch.map(() => "?").join(",")})`).all(sessionID, ...batch);
6001
6061
  for (const row of rows)
6062
+ versions.set(row.id, row);
6063
+ }
6064
+ return versions;
6065
+ }
6066
+ messageTimes(sessionID, ids, versions) {
6067
+ const times = new Map;
6068
+ for (let offset = 0;offset < ids.length; offset += 500) {
6069
+ const batch = ids.slice(offset, offset + 500);
6070
+ const rows = this.prepare(messageTimesQuery(batch.length, versions !== undefined)).all(sessionID, ...batch);
6071
+ for (const row of rows) {
6002
6072
  times.set(row.id, {
6003
6073
  created: typeof row.created === "number" ? row.created : undefined,
6004
6074
  completed: typeof row.completed === "number" ? row.completed : undefined
6005
6075
  });
6076
+ versions?.set(row.id, {
6077
+ id: row.id,
6078
+ type: row.type,
6079
+ seq: row.seq,
6080
+ created: row.version_created,
6081
+ updated: row.version_updated
6082
+ });
6083
+ }
6006
6084
  }
6007
6085
  return times;
6008
6086
  }
@@ -7313,6 +7391,8 @@ function projectEntryWithDigests(messages, digests) {
7313
7391
  value: () => contentDigest,
7314
7392
  enumerable: false
7315
7393
  });
7394
+ if (isCoveredInstructionRow(message.info))
7395
+ markCoveredInstructionRow(projection);
7316
7396
  return projection;
7317
7397
  });
7318
7398
  }
@@ -7389,7 +7469,7 @@ function asEntryProjection(input) {
7389
7469
  }
7390
7470
  return projectLkgEntry(input);
7391
7471
  }
7392
- function outputMessageIsPostAnchor(message, inputIndexById, anchorIndex) {
7472
+ function outputMessageIsPostAnchor(message, inputIndexById, anchorIndex, systemIndices) {
7393
7473
  const id = messageId(message);
7394
7474
  if (id !== null) {
7395
7475
  const inputIndex = inputIndexById.get(id);
@@ -7408,6 +7488,10 @@ function outputMessageIsPostAnchor(message, inputIndexById, anchorIndex) {
7408
7488
  }
7409
7489
  if (isCoveredInstructionRow(message.info))
7410
7490
  return false;
7491
+ if (messageRole(message) === "system") {
7492
+ const index = systemIndices.get(message);
7493
+ return index === undefined ? null : index > anchorIndex;
7494
+ }
7411
7495
  if (!isSyntheticOutput(message))
7412
7496
  return null;
7413
7497
  const linked = ["sourceMessageId", "ownerMessageId", "anchorMessageId"].map((key) => recordValue(message.info, key)).find((value) => typeof value === "string");
@@ -7421,7 +7505,7 @@ function buildLkgPrefix(input, output, completeOutput = false) {
7421
7505
  const anchorIndex = completeOutput && projected.length > 0 ? projected.length - 1 : findLkgAnchor(projected);
7422
7506
  if (anchorIndex === null)
7423
7507
  return null;
7424
- const ids = projected.map((message) => message.id);
7508
+ const ids = projected.map((message, index) => lkgInputIdentity(message.id, message.role, index));
7425
7509
  if (ids.some((id) => id === null))
7426
7510
  return null;
7427
7511
  const validIds = ids;
@@ -7432,9 +7516,27 @@ function buildLkgPrefix(input, output, completeOutput = false) {
7432
7516
  if (inputContentDigests.some((digest) => digest === null))
7433
7517
  return null;
7434
7518
  const inputIndexById = new Map(validIds.map((id, index) => [id, index]));
7519
+ const systemIndices = new Map;
7520
+ if (!completeOutput) {
7521
+ const inputSystems = projected.flatMap((message, index) => message.id === null && message.role === "system" && !isCoveredInstructionRow(message) ? [{ message, index }] : []);
7522
+ const outputSystems = output.filter((message) => messageId(message) === null && messageRole(message) === "system");
7523
+ const restoredCount = outputSystems.length - inputSystems.length;
7524
+ if (restoredCount < 0 || outputSystems.slice(0, restoredCount).some((message) => !isCoveredInstructionRow(message.info)))
7525
+ return null;
7526
+ for (let index = 0;index < inputSystems.length; index += 1) {
7527
+ const source = inputSystems[index];
7528
+ const message = outputSystems[index + restoredCount];
7529
+ const digest = source.message.contentDigest?.();
7530
+ if (!digest || lkgContentDigest(message) !== digest)
7531
+ return null;
7532
+ if (isCoveredInstructionRow(message.info) && source.index > anchorIndex)
7533
+ return null;
7534
+ systemIndices.set(message, source.index);
7535
+ }
7536
+ }
7435
7537
  const prefix = [];
7436
7538
  for (const message of output) {
7437
- const postAnchor = completeOutput ? false : outputMessageIsPostAnchor(message, inputIndexById, anchorIndex);
7539
+ const postAnchor = completeOutput ? false : outputMessageIsPostAnchor(message, inputIndexById, anchorIndex, systemIndices);
7438
7540
  if (postAnchor === null)
7439
7541
  return null;
7440
7542
  if (!postAnchor)
@@ -7861,6 +7963,12 @@ function noteLkgRecoveryPrefix(args) {
7861
7963
  return true;
7862
7964
  }
7863
7965
  function readLkgRecoveryPrefix(sessionId, inputs, messages, db) {
7966
+ return readRecoveryIdentityPrefix(sessionId, inputs.map((input, index) => ({
7967
+ id: lkgInputIdentity(input.id, input.role, index),
7968
+ contentDigest: input.contentDigest
7969
+ })), messages, db);
7970
+ }
7971
+ function readRecoveryIdentityPrefix(sessionId, inputs, messages, db) {
7864
7972
  const state = sessions.get(sessionId);
7865
7973
  const slot = db && (!state || state.prefix || state.uncertifiedNormal) ? loadPersistedLkgSlot(db, sessionId, true) ?? getSlot(sessionId) : getSlot(sessionId);
7866
7974
  const prefix = state?.prefix;
@@ -7879,8 +7987,8 @@ function noteLkgHealthyPrefix(sessionId, inputs, messages, release) {
7879
7987
  fenceRevision: sessions.get(sessionId)?.fenceRevision,
7880
7988
  prefix: prefix && !release ? {
7881
7989
  ...prefix,
7882
- inputs: inputs.map((input) => ({
7883
- id: input.id ?? "",
7990
+ inputs: inputs.map((input, index) => ({
7991
+ id: lkgInputIdentity(input.id, input.role, index) ?? "",
7884
7992
  digest: input.contentDigest?.() ?? ""
7885
7993
  })),
7886
7994
  json: JSON.stringify(messages)
@@ -7899,10 +8007,16 @@ function lkgRecoveryEntryUnproven(sessionId, entry, messages) {
7899
8007
  id,
7900
8008
  contentDigest: () => digests[index] ?? null
7901
8009
  }));
7902
- return !!readLkgRecoveryPrefix(sessionId, inputs, messages).rebuildReason;
8010
+ return !!readRecoveryIdentityPrefix(sessionId, inputs, messages).rebuildReason;
7903
8011
  }
7904
8012
 
7905
8013
  // src/hooks/magic-context/lkg-slot.ts
8014
+ var POSITIONAL_SYSTEM_KEY = "\x00mc-system:";
8015
+ function lkgInputIdentity(id, role, index) {
8016
+ if (typeof id === "string" && id.length > 0)
8017
+ return id.startsWith(POSITIONAL_SYSTEM_KEY) ? null : id;
8018
+ return role === "system" ? `${POSITIONAL_SYSTEM_KEY}${index}` : null;
8019
+ }
7906
8020
  var LKG_SINGLE_SLOT_BYTES = 72 * 1024 * 1024;
7907
8021
  var LKG_TOTAL_BYTES = 160 * 1024 * 1024;
7908
8022
  var LKG_METADATA_BYTES = 256;
@@ -8401,11 +8515,8 @@ function noteEntry(sessionId, input) {
8401
8515
  const slot = getSlot(sessionId);
8402
8516
  if (!slot)
8403
8517
  return null;
8404
- const messages = input.some((message) => isCoveredInstructionRow(message.info)) ? input.filter((message) => !isCoveredInstructionRow(message.info)) : input;
8405
- const entryInputIds = messages.map((message) => {
8406
- const id = message.info?.id;
8407
- return typeof id === "string" ? id : "";
8408
- });
8518
+ const messages = input;
8519
+ const entryInputIds = messages.map((message, index) => lkgInputIdentity(message.info?.id, message.info?.role, index) ?? "");
8409
8520
  const anchorIndex = entryInputIds.indexOf(slot.lastInputMessageId);
8410
8521
  if (anchorIndex < 0)
8411
8522
  return null;
@@ -23262,4 +23373,4 @@ async function executeContextRecomp(deps, options = {}) {
23262
23373
  return (await executeContextRecompWithResult(deps, options)).message;
23263
23374
  }
23264
23375
 
23265
- export { denyTaskRoutingToCallerAgents, buildHiddenAgentRegistrations, buildZenReadAgentRegistrations, buildHiddenAgentConfig, getMagicContextBuiltinCommands, formatConfigParseStatusLine, claimConfigParseFailuresOnce, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, loadPluginConfigDetailed, historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, createDreamerOutputCapSampler, advanceSessionActivity, observeSessionActivity, backfillSessionActivity, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, LkgRecoveryFenceError, lkgServedArrayDigest, hasCleanLkgRecoveryFence, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, readPersistedLkgUntaggedInputIds, persistLkgUntaggedInputIds, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, registerLkgPersistence, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, queueMemoryMutation, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, createChildSessionWithFence, HiddenCompletionRefusal, DreamerProviderOutputFailureError, withDreamerModelCooldown, providerOutputFailureFromInvalidManifest, HIDDEN_HISTORIAN_AGENT, HIDDEN_DREAMER_AGENT, HIDDEN_CURATE_AGENT, hiddenAgentFor, hiddenToolLoop, HIDDEN_RUN_DISPOSED_REASON, noteChildOfDisposedInstance, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, ModelProducedNoOutputError, noteModelActivityMonitored, noteModelOutputReceived, isPromptTimeoutError, getPromptFailureDetail, raceWithSignal, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, annotateSubagentInvocationError, failedInvocationStatus, sumTokensFromChildMessages, recordChildInvocation, recordPromptSessionError, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, setKeepSubagents, teardownChildSession, getCompartmentEvents, runTokenLog, formatRunTokenLog, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, prepareCompactionMarkerCandidates, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, extractM0Block, formatDate, TEMPORAL_MARKER_REPLAY_PATTERN, collectTemporalCandidates, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, MaterializeContentionError, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, materializeM0, hydrateCachedM0Mural, resetPrefixTrimFallbackState, findHostCompactionWindow, capturePrefixTrimSourceOrder, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, readCoordinateGeneration, readCoordinateRebaseNotice, formatCoordinateRebaseNotice, rebaseSessionCoordinatesAsync, shouldWaitForNewHistorianHistory, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, omitIncompleteFileTokenTotals, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, noteTransformPassForExactOrdinalReads, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, executeContextRecomp };
23376
+ export { denyTaskRoutingToCallerAgents, buildHiddenAgentRegistrations, buildZenReadAgentRegistrations, buildHiddenAgentConfig, getMagicContextBuiltinCommands, formatConfigParseStatusLine, claimConfigParseFailuresOnce, isCommitRetentionPaused, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, resolveLegacyConfigSources, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, loadPluginConfigDetailed, historianRunConfig, dreamerRunConfig, pluginConfigReader, currentPluginConfigReader, withLiveDreamerOutputCap, createDreamerOutputCapSampler, advanceSessionActivity, observeSessionActivity, backfillSessionActivity, COMPARTMENT_AGENT_SYSTEM_PROMPT, HISTORIAN_EDITOR_SYSTEM_PROMPT, COMPARTMENT_STRUCTURAL_SYSTEM_PROMPT, clampProducerAtomChars, producerInputTokenLimit, historianProducerReserve, producerPromptFailureReason, DREAMER_AGENT, DREAMER_RETROSPECTIVE_AGENT, DREAMER_PRIMER_INVESTIGATOR_AGENT, DREAMER_MEMORY_MAPPER_AGENT, DREAMER_CLASSIFIER_AGENT, DREAMER_DOCS_AGENT, DREAMER_REVIEWER_AGENT, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getUncoveredCompartmentEndsThrough, providerResponseFailed, isSuccessfulProviderCompletion, LkgRecoveryFenceError, lkgServedArrayDigest, hasCleanLkgRecoveryFence, dirtyLkgRecoveryRevision, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, prepareLkgCaptureFence, certifyCommittedLkgCapture, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, gaDatabasePath, RAW_MESSAGE_TYPES, V2StoreReaderPool, V2StoreReader, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, markSessionCleanupPending, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, clearSession, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, isHeldHeadForRequest, deferDeliveredSystemRefresh, retirePendingSystemPromptDelivery, lkgProviderInputTotal, beginV2LkgRequest, claimLkgRequestIdentity, currentLkgRequestIdentity, noteCapturedLkgRequest, noteLkgProviderResponse, measuredLkgPrefix, clearLkgMeasuredRequest, saveLkgSlotToDb, clearPersistedLkgSlotStrict, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, resolveLkgModelKeys, createLkgEntryProjector, captureLkgSlot, validateAnthropicReasoningRuns, validateLkgSeam, replayLkg, coldStartRawServedIndex, coldStartUncapturedReplay, noteUncertifiedNormalLkg, hasProcessLocalLkgProof, lkgDirtyRevision, rememberLkgDirtyRevision, readPersistedLkgUntaggedInputIds, persistLkgUntaggedInputIds, noteLkgRecoveryPrefix, readLkgRecoveryPrefix, noteLkgHealthyPrefix, lkgRecoveryReplayUnproven, lkgRecoveryEntryUnproven, lkgInputIdentity, registerLkgPersistence, beginLkgPass, visitMessageContentFields, contentSnapshotValue, messageContentFields, signatureForFields, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, forgetInMemorySlot, dropSlot, noteEntry, getLkgSlotHeapStats, TOOL_SWEEP_SCOPED_MARKER, useScopedToolSweep, createPreAdoptionToolSweepResolver, copySessionStateForClone, queueMemoryMutation, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, createChildSessionWithFence, HiddenCompletionRefusal, DreamerProviderOutputFailureError, withDreamerModelCooldown, providerOutputFailureFromInvalidManifest, HIDDEN_HISTORIAN_AGENT, HIDDEN_DREAMER_AGENT, HIDDEN_CURATE_AGENT, hiddenAgentFor, hiddenToolLoop, HIDDEN_RUN_DISPOSED_REASON, noteChildOfDisposedInstance, hiddenChildPermissions, registerHiddenChildAgents, hiddenToolCallRefusal, HiddenAgentStepLimit, HiddenChildHook, extractLatestAssistantText, hasLengthCappedOutput, parseProviderModel, modelBodyField, toModelEntry, ModelProducedNoOutputError, noteModelActivityMonitored, noteModelOutputReceived, isPromptTimeoutError, getPromptFailureDetail, raceWithSignal, promptSyncWithValidatedOutputRetry, normalizeSDKResponse, annotateSubagentInvocationError, failedInvocationStatus, emptyTokenTotals, sumTokensFromChildMessages, recordChildInvocation, recordPromptSessionError, createPromptAsyncTransport, CTX_NOTE_LIGHT_DESCRIPTION, ACTIVE_TOOL_IDS, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, setKeepSubagents, teardownChildSession, getCompartmentEvents, runTokenLog, formatRunTokenLog, buildMagicContextSection, getMuralIdentity, getMural, modelKeyAcceptsImages, resolveMuralWire, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getOpenCodeDbPath, compareOpenCodeMessagesByCanonicalOrder, prepareCompactionMarkerCandidates, removeMcOwnedCompactionMarkers, MARKER_SUMMARY_TEXT, markerUpdateDefinitelyDidNotCut, applyDeferredCompactionMarker, removeCompactionMarkerForSession, checkCompactionMarkerConsistency, extractM0Block, formatDate, TEMPORAL_MARKER_REPLAY_PATTERN, collectTemporalCandidates, injectTemporalMarkers, clearInjectionCache, getVisibleMemoryIds, selectHiddenMessagesAtCompactionSeam, prepareCompartmentInjection, renderCompartmentInjection, MaterializeContentionError, mustMaterialize, trimMemoriesToBudgetV2, renderMemoryBlockV2, materializeM0, hydrateCachedM0Mural, resetPrefixTrimFallbackState, findHostCompactionWindow, capturePrefixTrimSourceOrder, prepareCachedM0M1Replay, hasCompleteCachedM0M1, injectM0M1, resolveHiddenCompletionExecutor, createV1HiddenCompletionExecutor, readCoordinateGeneration, readCoordinateRebaseNotice, formatCoordinateRebaseNotice, rebaseSessionCoordinatesAsync, shouldWaitForNewHistorianHistory, EMPTY_READ_REPLY, noteTouchedAt, renderGlance, renderNotesById, formatWriteReply, observeNoteNudgeServe, onNoteTrigger, peekNoteNudgeText, markNoteNudgeDelivered, clearNoteNudgeTriggerAndCooldown, resetNoteNudgeCooldownOnly, clearNoteNudgeTriggerOnly, omitIncompleteFileTokenTotals, describeBoundaryDiagnostics, RECOVERY_NO_HEAD_LIMIT, deriveProtectedTailTokenTarget, selectPerRunCap, resolveOpenCodeProtectedTailBoundary, resolveWrapupProtectedTailBoundary, getRawHistoryEligibility, hasRunnableCompartmentWindow, recordHighPressureNoEligibleHead, noteTransformPassForExactOrdinalReads, runCompartmentAgent, snapRangeToCompartments, getActiveCompartmentRun, markActiveCompartmentRunPublished, registerActiveCompartmentRun, startCompartmentAgent, executeContextRecomp };
@@ -17,7 +17,7 @@ import {
17
17
  } from "./index-7kkphb6c.js";
18
18
  import {
19
19
  embedTextForProject2
20
- } from "./index-a2fz9hpa.js";
20
+ } from "./index-gxkhzmjq.js";
21
21
  import {
22
22
  saveEmbeddingIfHashMatches
23
23
  } from "./index-4dhv7mqz.js";
@@ -15,7 +15,7 @@ import {
15
15
  OpenAICompatibleEmbeddingProvider,
16
16
  getProjectEmbeddingSnapshot2,
17
17
  embedBatchForProject2
18
- } from "./index-a2fz9hpa.js";
18
+ } from "./index-gxkhzmjq.js";
19
19
  import {
20
20
  isEmbeddingHostBusy2
21
21
  } from "./index-qt1qqasc.js";
@@ -41,7 +41,7 @@ import {
41
41
  enqueueShadowEmbeddingItems2,
42
42
  getProjectEmbeddingSnapshot2,
43
43
  embedItemsForProject2
44
- } from "./index-a2fz9hpa.js";
44
+ } from "./index-gxkhzmjq.js";
45
45
  import {
46
46
  getProjectEmbeddings2
47
47
  } from "./index-4dhv7mqz.js";
@@ -50,7 +50,7 @@ import {
50
50
  isEmbeddingEnabled,
51
51
  embedText,
52
52
  ensureMemoryEmbeddings2
53
- } from "./index-4ypqzvhf.js";
53
+ } from "./index-vnn5405n.js";
54
54
  import {
55
55
  ModuleMemoryAuthorityError2,
56
56
  getMemoriesByProject2,
@@ -65,13 +65,13 @@ import {
65
65
  sanitizeFtsQuery,
66
66
  searchMemoriesFTS,
67
67
  searchMemoriesFTSUnion
68
- } from "./index-t3rbb8wr.js";
68
+ } from "./index-pe6b4bhs.js";
69
69
  import {
70
70
  cleanSearchText,
71
71
  keywordRelevance,
72
72
  matchedSearchSnippet,
73
73
  getIndexedMessageCorpusSize
74
- } from "./index-7gbcg8xv.js";
74
+ } from "./index-4s4zq97n.js";
75
75
  import {
76
76
  MESSAGE_FTS_SESSION_FILTER_SQL,
77
77
  withMessageFtsSessionFilter
@@ -1000,7 +1000,9 @@ async function indexCommitsForProject(db, projectPath, directory, options) {
1000
1000
  return result;
1001
1001
  }
1002
1002
  if (commits.length === 0) {
1003
- result.evicted = enforceProjectCap(db, projectPath, options.maxCommits);
1003
+ if (!options.skipRetention) {
1004
+ result.evicted = enforceProjectCap(db, projectPath, options.maxCommits);
1005
+ }
1004
1006
  log2(`[git-commits] no new commits for ${projectPath} (sinceMs=${sinceMs} latestIndexed=${latestIndexed?.slice(0, 7) ?? "none"} evicted=${result.evicted})`);
1005
1007
  return result;
1006
1008
  }
@@ -1008,7 +1010,9 @@ async function indexCommitsForProject(db, projectPath, directory, options) {
1008
1010
  const upsert = upsertCommits(db, projectPath, commits);
1009
1011
  result.inserted = upsert.inserted;
1010
1012
  result.updated = upsert.updated;
1011
- result.evicted = enforceProjectCap(db, projectPath, options.maxCommits);
1013
+ if (!options.skipRetention) {
1014
+ result.evicted = enforceProjectCap(db, projectPath, options.maxCommits);
1015
+ }
1012
1016
  const snapshot = getProjectEmbeddingSnapshot2(projectPath);
1013
1017
  if (options.skipEmbed || !snapshot?.gitCommitEnabled) {
1014
1018
  log2(`[git-commits] indexed ${projectPath}: scanned=${result.scanned} inserted=${result.inserted} updated=${result.updated} evicted=${result.evicted} embedded=0 (embedding skipped: skipEmbed=${options.skipEmbed === true} gitCommitEnabled=${snapshot?.gitCommitEnabled === true})`);
@@ -98,7 +98,7 @@ import {
98
98
  getProjectEmbeddingSnapshot2,
99
99
  embedTextForProject2,
100
100
  embedBatchForProject2
101
- } from "./index-a2fz9hpa.js";
101
+ } from "./index-gxkhzmjq.js";
102
102
  import {
103
103
  createWorkerShutdown
104
104
  } from "./index-cpjk5jd2.js";
@@ -140,11 +140,11 @@ import {
140
140
  peekNoteNudgeText,
141
141
  markNoteNudgeDelivered,
142
142
  getActiveCompartmentRun
143
- } from "./index-dcqk0y27.js";
143
+ } from "./index-k0dpkyn7.js";
144
144
  import {
145
145
  cleanSearchText,
146
146
  matchedSearchSnippet
147
- } from "./index-7gbcg8xv.js";
147
+ } from "./index-4s4zq97n.js";
148
148
  import {
149
149
  stripSystemInjection,
150
150
  isTextPart,
@@ -242,7 +242,7 @@ import {
242
242
  extractToolCallObservation,
243
243
  ToolMutationBatch,
244
244
  createToolDropTarget
245
- } from "./index-yzjhx10y.js";
245
+ } from "./index-0fe4q77z.js";
246
246
  import {
247
247
  isValidLanguageCode
248
248
  } from "./index-nxrsns5x.js";
@@ -253,13 +253,13 @@ import {
253
253
  openCodeDbExists,
254
254
  withReadOnlySessionDb,
255
255
  getMessageTimesFromOpenCodeDb
256
- } from "./index-v0dhhxsq.js";
256
+ } from "./index-y1qwzvxn.js";
257
257
  import {
258
258
  BoundedSessionMap
259
259
  } from "./index-s1n8dd2n.js";
260
260
  import {
261
261
  userFacingFailureCode
262
- } from "./index-t3rbb8wr.js";
262
+ } from "./index-pe6b4bhs.js";
263
263
  import {
264
264
  normalizeProtectedToolName,
265
265
  mergeProtectedTools
@@ -3327,6 +3327,12 @@ var RECENT_TOOL_SKELETON_WINDOW = 20;
3327
3327
  function buildReplacementContent(tagId) {
3328
3328
  return `[dropped §${tagId}§]`;
3329
3329
  }
3330
+ var FROZEN_TEXT_ANNOTATION_SUFFIX = /(?:\n\n(?:<instruction name="deferred_notes">(?:(?!<\/instruction>)[\s\S])*<\/instruction>|<ctx-search-hint>(?:(?!<\/ctx-search-hint>)[\s\S])*<\/ctx-search-hint>))+$/;
3331
+ function renderDroppedText(tagId, renderedText) {
3332
+ const placeholder = buildReplacementContent(tagId);
3333
+ const annotations = renderedText?.match(FROZEN_TEXT_ANNOTATION_SUFFIX)?.[0] ?? "";
3334
+ return placeholder + annotations;
3335
+ }
3330
3336
  function applyNewToolDrop(target, options) {
3331
3337
  const plan = planNewToolDrop(target, options, !!options.persist);
3332
3338
  if (!plan)
@@ -7581,4 +7587,4 @@ function checkM0MutationDriftAndSignal2(args) {
7581
7587
  return false;
7582
7588
  }
7583
7589
 
7584
- export { makeToolCompositeKey, createTagger, cavemanWordRulesForLanguage, searchMessageHistoryOffThread, findSessionId, findLastUserMessageId, clearAutoSearchForSession, setCtxReduceRegisteredGlobally, resolveCtxReduceAvailabilityFromMessages, resolveCtxReduceAvailability, primeCtxReduceSpawnPermission, ctxReduceSpawnPermissionReadNeeded, spawnAgentFromMessages, spawnAgentFromOpenCodeDb, todowritePermissionDenied, cachedToolPermissionDenied, clearToolPermissionDenied, resolveTodowriteAvailabilityFromMessages, resolveTodowriteAvailability, diagnosticStateChanged, clearDiagnosticLogState, canConsumeDeferredOnThisPass, hasReclaimRide, reclaimRidePermitted, reclaimRideLabel, pendingDropEligibilityKey, createPendingDropEligibilityCache, readExecuteReclaimState, writeExecuteReclaimState, maintainExecuteFloorMark, captureOpencodeReasoningBudgetStatus, reasoningBudgetStatusLine, ENGINE_RECONNECTING_USER_MESSAGE, ENGINE_BUSY_USER_MESSAGE, SIGNED_THINKING_RESET_FENCE_FAILED, contextRefusalError, protectedToolRefusal, outgoingContextRefusal, signedTurnContextRefusal, EmergencyFailClosedError, latestAssistantTurnStart, latestAssistantTurnMessages, hasActiveAnthropicThinkingTurn, replayCavemanCompression, DegradedPassRefusalError, degradedPassError, applyFlushedStatuses, prewarmTagOwners, waitForTagOwners, stripStructuralNoise, collectForeignTextParts, isLegacyForeignTextTag, withTransformTimingSummary, logTransformTiming, hasRecentAssistantCommit, tagMessages, resetDegradedCacheCount2, isSyntheticHeadMessage2, applyTodoSynthesis2, freezeReasoningOnBustingPass2, servesThinkingBlock2, firstServedDivergenceIndex2, rustModeServedKeyAfterPersistedStrips2, replayRustModeBindingMismatchStrips2, RUST_MARKER_LOCK_SKIP_LOG2, applyRustModeDeferredCompactionMarker2, clearRustModeBoundaryRecord2, runRustModePostprocess2, reconcileMarkerRepresentation2, clearPendingCompactionMarkerAfterSuccessfulDrain2, defaultCompactionMarkerStrategy2, abortSessionFailClosed2, evaluateEmergencyFailClosed2, finalizeMessageRepresentation2, runPostTransformPhase2, checkM0MutationDriftAndSignal2 };
7590
+ export { makeToolCompositeKey, createTagger, cavemanWordRulesForLanguage, searchMessageHistoryOffThread, findSessionId, findLastUserMessageId, clearAutoSearchForSession, setCtxReduceRegisteredGlobally, resolveCtxReduceAvailabilityFromMessages, resolveCtxReduceAvailability, primeCtxReduceSpawnPermission, ctxReduceSpawnPermissionReadNeeded, spawnAgentFromMessages, spawnAgentFromOpenCodeDb, todowritePermissionDenied, cachedToolPermissionDenied, clearToolPermissionDenied, resolveTodowriteAvailabilityFromMessages, resolveTodowriteAvailability, diagnosticStateChanged, clearDiagnosticLogState, canConsumeDeferredOnThisPass, hasReclaimRide, reclaimRidePermitted, reclaimRideLabel, pendingDropEligibilityKey, createPendingDropEligibilityCache, readExecuteReclaimState, writeExecuteReclaimState, maintainExecuteFloorMark, captureOpencodeReasoningBudgetStatus, reasoningBudgetStatusLine, ENGINE_RECONNECTING_USER_MESSAGE, ENGINE_BUSY_USER_MESSAGE, SIGNED_THINKING_RESET_FENCE_FAILED, contextRefusalError, protectedToolRefusal, outgoingContextRefusal, signedTurnContextRefusal, EmergencyFailClosedError, latestAssistantTurnStart, latestAssistantTurnMessages, hasActiveAnthropicThinkingTurn, replayCavemanCompression, DegradedPassRefusalError, degradedPassError, renderDroppedText, applyFlushedStatuses, prewarmTagOwners, waitForTagOwners, stripStructuralNoise, collectForeignTextParts, isLegacyForeignTextTag, withTransformTimingSummary, logTransformTiming, hasRecentAssistantCommit, tagMessages, resetDegradedCacheCount2, isSyntheticHeadMessage2, applyTodoSynthesis2, freezeReasoningOnBustingPass2, servesThinkingBlock2, firstServedDivergenceIndex2, rustModeServedKeyAfterPersistedStrips2, replayRustModeBindingMismatchStrips2, RUST_MARKER_LOCK_SKIP_LOG2, applyRustModeDeferredCompactionMarker2, clearRustModeBoundaryRecord2, runRustModePostprocess2, reconcileMarkerRepresentation2, clearPendingCompactionMarkerAfterSuccessfulDrain2, defaultCompactionMarkerStrategy2, abortSessionFailClosed2, evaluateEmergencyFailClosed2, finalizeMessageRepresentation2, runPostTransformPhase2, checkM0MutationDriftAndSignal2 };
@@ -10,7 +10,7 @@ import {
10
10
  } from "./index-rrv26qjz.js";
11
11
  import {
12
12
  shouldHoldIgnoredNotification
13
- } from "./index-v0dhhxsq.js";
13
+ } from "./index-y1qwzvxn.js";
14
14
  import {
15
15
  getErrorMessage
16
16
  } from "./index-y8v6yerm.js";
@@ -25,8 +25,8 @@ import {
25
25
  } from "./index-8ajstryz.js";
26
26
 
27
27
  // src/hooks/magic-context/read-session-db.ts
28
- function openCodeDbExists() {
29
- return harnessOwnsOpenCodeStore2() && openCodeDbPathExists(resolveOpenCodeDbPath());
28
+ function openCodeDbExists(generation = "v1") {
29
+ return harnessOwnsOpenCodeStore2() && openCodeDbPathExists(resolveOpenCodeDbPath(generation));
30
30
  }
31
31
  var cachedReadOnlyDbs = {
32
32
  v1: null,
@@ -49,7 +49,7 @@ function getReadOnlySessionDb(generation = "v1") {
49
49
  if (!harnessOwnsOpenCodeStore2()) {
50
50
  throw new Error("OpenCode session database is not readable from a Pi-compatible process; its history lives in Pi sessions");
51
51
  }
52
- const resolution = resolveOpenCodeDbPath();
52
+ const resolution = resolveOpenCodeDbPath(generation);
53
53
  const dbPath = resolution.path;
54
54
  if (!openCodeDbPathExists(resolution)) {
55
55
  throw new Error(`OpenCode session database is unavailable at ${dbPath} (source=${resolution.source})`);
@@ -70,8 +70,8 @@ function getReadOnlySessionDb(generation = "v1") {
70
70
  clearOpenCodeDbReadFailure();
71
71
  return db;
72
72
  }
73
- function withReadOnlySessionDb(fn) {
74
- return fn(getReadOnlySessionDb());
73
+ function withReadOnlySessionDb(fn, generation = "v1") {
74
+ return fn(getReadOnlySessionDb(generation));
75
75
  }
76
76
  function getRawSessionMessageCountFromDb(db, sessionId) {
77
77
  const row = db.prepare(`SELECT COUNT(*) as count FROM message WHERE session_id = ?
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAmHvE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAikCpC,QAAA,MAAM,MAAM,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAIjD,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAmHvE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AA6jCpC,QAAA,MAAM,MAAM,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,KAAK,CAAA;CAIjD,CAAC;AAEF,eAAe,MAAM,CAAC"}