@cortexkit/opencode-magic-context 0.49.63 → 0.49.65

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 (83) hide show
  1. package/dist/auto-search-worker.js +1 -1
  2. package/dist/chunk-embedding-write-worker.js +1 -1
  3. package/dist/{context-aaht09yh.js → context-3mfsdp1v.js} +14 -14
  4. package/dist/features/magic-context/overflow-detection.d.ts +0 -20
  5. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  6. package/dist/features/magic-context/storage-tags.d.ts +7 -0
  7. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  8. package/dist/hooks/magic-context/compartment-prompt.d.ts +8 -1
  9. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  10. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  11. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  12. package/dist/hooks/magic-context/compartment-runner-types.d.ts +5 -0
  13. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  14. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  15. package/dist/hooks/magic-context/historian-prompt-fit.d.ts +10 -3
  16. package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
  17. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  18. package/dist/hooks/magic-context/inject-compartments.d.ts +11 -0
  19. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  20. package/dist/hooks/magic-context/reference-retrieval.d.ts +3 -2
  21. package/dist/hooks/magic-context/reference-retrieval.d.ts.map +1 -1
  22. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  23. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts +1 -0
  25. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  26. package/dist/{index-tq20edcs.js → index-0ab398z2.js} +2 -2
  27. package/dist/{index-d0feqcs5.js → index-6kgsfb81.js} +1 -1
  28. package/dist/{index-3hk445am.js → index-71h616be.js} +1 -1
  29. package/dist/{index-ev2rrjfc.js → index-7dj3s7qq.js} +1 -1
  30. package/dist/{index-s2qsd3w9.js → index-8596jbnw.js} +6 -5
  31. package/dist/{index-3yyfftqq.js → index-c0k54yhd.js} +3 -3
  32. package/dist/{index-ywxvdwmj.js → index-ezr8mr1c.js} +1 -1
  33. package/dist/{index-s2jdky2x.js → index-g59gpt1j.js} +3 -3
  34. package/dist/{index-kv4ntrr6.js → index-gwb2wpz7.js} +2 -2
  35. package/dist/{index-8sc7vqt7.js → index-kvfrse61.js} +75 -43
  36. package/dist/{index-0cz8bsyx.js → index-qn27gh4e.js} +1 -1
  37. package/dist/{index-qdver0af.js → index-san8daqa.js} +6 -6
  38. package/dist/{index-bqd5dmm4.js → index-stqmv1mt.js} +65 -37
  39. package/dist/{index-3wq9btxt.js → index-wz0t5e5s.js} +3 -3
  40. package/dist/{index-4yjn3er4.js → index-x2hwwzk1.js} +65 -11
  41. package/dist/index.js +19 -18
  42. package/dist/{message-index-bounded-f6yz4xq8.js → message-index-bounded-zs7ah2te.js} +3 -3
  43. package/dist/migration-worker.js +1 -1
  44. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  45. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  46. package/dist/raw-ordinal-warmup-worker.js +4 -4
  47. package/dist/{read-session-chunk-8b1g06nz.js → read-session-chunk-jf2f8jz8.js} +2 -2
  48. package/dist/{recomp-orchestrator-7s8nyzhy.js → recomp-orchestrator-nyj8ca0y.js} +7 -7
  49. package/dist/{render-nrfbtkkw.js → render-n46wpv2n.js} +6 -6
  50. package/dist/{search-archive-1ppdjfm9.js → search-archive-9k6vsp44.js} +4 -4
  51. package/dist/{search-xha0r30f.js → search-s386bwwh.js} +5 -5
  52. package/dist/shared/tag-transcript.d.ts.map +1 -1
  53. package/dist/{storage-tags-spet01yb.js → storage-tags-2r952wqy.js} +1 -1
  54. package/dist/{transform-postprocess-phase-fxp1atm1.js → transform-postprocess-phase-8yjcca9t.js} +8 -8
  55. package/dist/v2/auto-search-worker.js +1 -1
  56. package/dist/v2/chunk-embedding-write-worker.js +1 -1
  57. package/dist/v2/{context-hk9x7ngz.js → context-34sr5ner.js} +62 -34
  58. package/dist/v2/{message-index-bounded-0w8eh8fc.js → message-index-bounded-axbs1s97.js} +3 -3
  59. package/dist/v2/migration-worker.js +1 -1
  60. package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
  61. package/dist/v2/{read-session-chunk-dxs1tgt9.js → read-session-chunk-41cm522x.js} +2 -2
  62. package/dist/v2/{recomp-orchestrator-zc1wdv9q.js → recomp-orchestrator-r4gqhhaw.js} +6 -6
  63. package/dist/v2/{render-9knrdrjs.js → render-7v7yx9xb.js} +6 -6
  64. package/dist/v2/{search-archive-2jmyvj69.js → search-archive-1yc8bh6y.js} +4 -4
  65. package/dist/v2/{search-a2a0qs3t.js → search-mabwkzw2.js} +4 -4
  66. package/dist/v2/{server-svx20ra2.js → server-8w9b5exq.js} +1 -1
  67. package/dist/v2/{server-8hcxmt1w.js → server-9rwm2z2h.js} +65 -11
  68. package/dist/v2/{server-9m5r04ws.js → server-anh8gf0w.js} +2 -2
  69. package/dist/v2/{server-ja6swvmb.js → server-bh9yzxpz.js} +2 -2
  70. package/dist/v2/{server-9ab9jnpq.js → server-bnka2vf2.js} +3 -3
  71. package/dist/v2/{server-8ycacd59.js → server-cdddk5d1.js} +1 -1
  72. package/dist/v2/{server-88n85n60.js → server-hb5zm7yh.js} +75 -43
  73. package/dist/v2/{server-tzh55x6d.js → server-hcgqsdrh.js} +1 -1
  74. package/dist/v2/{server-4r86tcs2.js → server-k97r77x3.js} +2 -2
  75. package/dist/v2/{server-t8tmrtcg.js → server-yxw43z2w.js} +1 -1
  76. package/dist/v2/server.js +2 -2
  77. package/dist/v2/{storage-tags-50wsqg3t.js → storage-tags-9zs0gc7w.js} +1 -1
  78. package/dist/v2/{v2-archive-reader-ycjh6a2d.js → v2-archive-reader-pgk140pb.js} +1 -1
  79. package/dist/v2/{wrapup-orchestrator-fyyb28jf.js → wrapup-orchestrator-p0ysz3s9.js} +7 -6
  80. package/dist/{v2-archive-reader-wec0a8fx.js → v2-archive-reader-cv6veqnz.js} +1 -1
  81. package/dist/{wrapup-orchestrator-560v99mk.js → wrapup-orchestrator-dxda1svq.js} +8 -8
  82. package/package.json +1 -1
  83. package/src/shared/tag-transcript.ts +105 -1
@@ -196,7 +196,7 @@ import {
196
196
  snapRangeToCompartments,
197
197
  getActiveCompartmentRun,
198
198
  startCompartmentAgent
199
- } from "./index-4yjn3er4.js";
199
+ } from "./index-x2hwwzk1.js";
200
200
  import {
201
201
  hasTrustedAbsoluteWall,
202
202
  applyProvenInputFloor,
@@ -355,7 +355,7 @@ import {
355
355
  getTagsByNumbers2,
356
356
  getDroppedTagsByNumbers2,
357
357
  getMaxDroppedTagNumber2
358
- } from "./index-8sc7vqt7.js";
358
+ } from "./index-kvfrse61.js";
359
359
  import {
360
360
  BoundedSessionMap,
361
361
  observeTemporalDecisions,
@@ -427,7 +427,7 @@ import {
427
427
  readRawSessionMessageById2,
428
428
  readSessionChunk2,
429
429
  readRawSessionSeedTail2
430
- } from "./index-d0feqcs5.js";
430
+ } from "./index-6kgsfb81.js";
431
431
  import {
432
432
  isFailClosedBlockingError,
433
433
  shouldBypassFailClosedBlock,
@@ -453,7 +453,7 @@ import {
453
453
  runSqliteOptimize,
454
454
  openDatabase,
455
455
  openCurrentDatabase
456
- } from "./index-0cz8bsyx.js";
456
+ } from "./index-qn27gh4e.js";
457
457
  import {
458
458
  unescapeXml,
459
459
  resolveWorkspaceShareCategories,
@@ -569,10 +569,10 @@ import {
569
569
  GLOBAL_USER_PROFILE_PROJECT_PATH,
570
570
  getProjectState,
571
571
  bumpProjectUserProfileVersion
572
- } from "./index-ywxvdwmj.js";
572
+ } from "./index-ezr8mr1c.js";
573
573
  import {
574
574
  getLastIndexedOrdinal
575
- } from "./index-ev2rrjfc.js";
575
+ } from "./index-7dj3s7qq.js";
576
576
  import {
577
577
  SESSION_NOTE_CONDITION_ERROR,
578
578
  getNoteByIdInScope,
@@ -706,13 +706,13 @@ import {
706
706
  resolveMemoriesByIdsForSearch2,
707
707
  unifiedSearch2,
708
708
  formatSearchResults2
709
- } from "./index-3yyfftqq.js";
709
+ } from "./index-c0k54yhd.js";
710
710
  import {
711
711
  scheduleReconciliation,
712
712
  scheduleIncrementalIndex,
713
713
  getMessageIndexQueueHeapStats,
714
714
  clearSessionTracking
715
- } from "./index-3hk445am.js";
715
+ } from "./index-71h616be.js";
716
716
  import {
717
717
  flushIgnoredMessages2,
718
718
  clearIgnoredMessages2,
@@ -722,7 +722,7 @@ import {
722
722
  import {
723
723
  setRecompStarting2,
724
724
  setRecompTerminal2
725
- } from "./index-3wq9btxt.js";
725
+ } from "./index-wz0t5e5s.js";
726
726
  import {
727
727
  makeToolCompositeKey,
728
728
  searchMessageHistoryOffThread,
@@ -807,7 +807,7 @@ import {
807
807
  abortSessionFailClosed2,
808
808
  evaluateEmergencyFailClosed2,
809
809
  runPostTransformPhase2
810
- } from "./index-qdver0af.js";
810
+ } from "./index-san8daqa.js";
811
811
  import {
812
812
  ANNOUNCEMENT_VERSION2,
813
813
  ANNOUNCEMENT_FEATURES2,
@@ -822,13 +822,13 @@ import {
822
822
  renderMessageByOrdinal2,
823
823
  renderVerboseRangeForTool2,
824
824
  renderItemByTag2
825
- } from "./index-tq20edcs.js";
825
+ } from "./index-0ab398z2.js";
826
826
  import {
827
827
  readV2ArchiveOffThread2
828
- } from "./index-s2jdky2x.js";
828
+ } from "./index-g59gpt1j.js";
829
829
  import {
830
830
  renderSearchArchiveOffThread2
831
- } from "./index-kv4ntrr6.js";
831
+ } from "./index-gwb2wpz7.js";
832
832
  import {
833
833
  COMPACTION_ENABLED_PATH,
834
834
  isDreamerRunnable,
@@ -13917,7 +13917,6 @@ function isHistorianDrainBudgetSpent(args) {
13917
13917
  var PROACTIVE_TRIGGER_OFFSET_PERCENTAGE = 2;
13918
13918
  var POST_DROP_TARGET_RATIO = 0.75;
13919
13919
  var MIN_PROACTIVE_TAIL_TOKEN_ESTIMATE = 6000;
13920
- var MIN_PROACTIVE_TAIL_MESSAGE_COUNT = 12;
13921
13920
  var DEFAULT_MIN_COMMIT_CLUSTERS_FOR_TRIGGER = 3;
13922
13921
  var TAIL_SIZE_TRIGGER_MULTIPLIER = 3;
13923
13922
  var BLOCK_UNTIL_DONE_PERCENTAGE = 95;
@@ -14027,7 +14026,6 @@ var TAIL_INFO_DEFAULTS = {
14027
14026
  nextStartOrdinal: 1,
14028
14027
  hasNewRawHistory: false,
14029
14028
  hasProtectedEligibleHead: false,
14030
- isMeaningful: false,
14031
14029
  tokenEstimate: 0,
14032
14030
  chunkHasMore: false,
14033
14031
  trueRawEligibleTokens: 0,
@@ -14041,6 +14039,17 @@ function resolveBoundaryContextLimit(usage, fallbackContextLimit) {
14041
14039
  }
14042
14040
  return 128000;
14043
14041
  }
14042
+ function scanFormattedHead(db, sessionId, triggerBudget, offset, eligibleEnd) {
14043
+ const seed = sessionDecisionCalibration(db, sessionId);
14044
+ const sourceRatio = Math.max(seed.proseRatio, seed.toolsRatio);
14045
+ const scanBudget = Math.floor(Math.max(MIN_PROACTIVE_TAIL_TOKEN_ESTIMATE, triggerBudget * TAIL_SIZE_TRIGGER_MULTIPLIER) / sourceRatio);
14046
+ const chunk = readSessionChunk2(sessionId, scanBudget, offset, eligibleEnd);
14047
+ return {
14048
+ tokenEstimate: Math.ceil(chunk.tokenEstimate * sourceRatio),
14049
+ chunkHasMore: chunk.hasMore,
14050
+ commitClusterCount: chunk.commitClusterCount
14051
+ };
14052
+ }
14044
14053
  function getUnsummarizedTailInfo(db, sessionId, triggerBudget, usage, executeThresholdPercentage, contextLimit, inMemoryTail, taggerFloor = 0, liftLivePromptFloor = false) {
14045
14054
  return withRawSessionMessageCache2(() => {
14046
14055
  try {
@@ -14083,20 +14092,15 @@ function getUnsummarizedTailInfo(db, sessionId, triggerBudget, usage, executeThr
14083
14092
  boundarySnapshot: boundary
14084
14093
  };
14085
14094
  }
14086
- const seed = sessionDecisionCalibration(db, sessionId);
14087
- const sourceRatio = Math.max(seed.proseRatio, seed.toolsRatio);
14088
- const scanBudget = Math.floor(Math.max(MIN_PROACTIVE_TAIL_TOKEN_ESTIMATE, triggerBudget * TAIL_SIZE_TRIGGER_MULTIPLIER) / sourceRatio);
14089
- const chunk = readSessionChunk2(sessionId, scanBudget, rawEligibility.offset, boundary.eligibleEndOrdinal);
14090
- const isMeaningful = chunk.hasMore || boundary.trueRawEligibleTokens >= MIN_PROACTIVE_TAIL_TOKEN_ESTIMATE || Math.ceil(chunk.tokenEstimate * sourceRatio) >= MIN_PROACTIVE_TAIL_TOKEN_ESTIMATE || chunk.messageCount >= MIN_PROACTIVE_TAIL_MESSAGE_COUNT;
14095
+ const formatted = scanFormattedHead(db, sessionId, triggerBudget, rawEligibility.offset, boundary.eligibleEndOrdinal);
14096
+ const proactiveAdmission = formatted.chunkHasMore ? "has_more" : boundary.trueRawEligibleTokens >= MIN_PROACTIVE_TAIL_TOKEN_ESTIMATE ? "true_raw" : formatted.tokenEstimate >= MIN_PROACTIVE_TAIL_TOKEN_ESTIMATE ? "formatted" : undefined;
14091
14097
  return {
14092
14098
  nextStartOrdinal: rawEligibility.offset,
14093
14099
  hasNewRawHistory: true,
14094
14100
  hasProtectedEligibleHead,
14095
- isMeaningful,
14096
- tokenEstimate: Math.ceil(chunk.tokenEstimate * sourceRatio),
14097
- chunkHasMore: chunk.hasMore,
14101
+ proactiveAdmission,
14102
+ ...formatted,
14098
14103
  trueRawEligibleTokens: boundary.trueRawEligibleTokens,
14099
- commitClusterCount: chunk.commitClusterCount,
14100
14104
  boundarySnapshot: boundary
14101
14105
  };
14102
14106
  } catch (error) {
@@ -14212,8 +14216,12 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
14212
14216
  sessionLog2(sessionId, `historian redundancy skip: summarizer not needed this pass — force band is ${forceMaterializationPercentage}%; queued/automatic drops are projected to reclaim to ${projectedPostDropPercentage.toFixed(1)}% (target ${relativePostDropTarget.toFixed(1)}%) on this pass (${rideLabel})`);
14213
14217
  return { shouldFire: false };
14214
14218
  }
14215
- sessionLog2(sessionId, `compartment trigger: force-firing at ${usage.percentage.toFixed(1)}% (projected post-drop ${formatProjectedPostDropPercentage(projectedPostDropPercentage)})`);
14219
+ const admittedBy = recovery ? "overflow_recovery" : usage.percentage >= BLOCK_UNTIL_DONE_PERCENTAGE ? "emergency_95" : "force_band";
14220
+ const logForceFire = (trueRawTokens, formattedTokens) => {
14221
+ sessionLog2(sessionId, `compartment trigger: force-firing at ${usage.percentage.toFixed(1)}% (projected post-drop ${formatProjectedPostDropPercentage(projectedPostDropPercentage)}) admittedBy=${admittedBy} trueRawTokens=${trueRawTokens} formattedTokens=${formattedTokens}`);
14222
+ };
14216
14223
  if (tailInfo.boundarySnapshot && hasRunnableCompartmentWindow(tailInfo.boundarySnapshot)) {
14224
+ logForceFire(tailInfo.trueRawEligibleTokens, tailInfo.tokenEstimate);
14217
14225
  return {
14218
14226
  shouldFire: true,
14219
14227
  reason: "force_band",
@@ -14229,7 +14237,7 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
14229
14237
  absoluteMessageCount: resolvedInMemoryTail.absoluteMessageCount
14230
14238
  });
14231
14239
  }
14232
- return resolveOpenCodeProtectedTailBoundary({
14240
+ const boundary = resolveOpenCodeProtectedTailBoundary({
14233
14241
  db,
14234
14242
  sessionId,
14235
14243
  mode: "trigger",
@@ -14240,8 +14248,18 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
14240
14248
  emergencyTailScale: scale,
14241
14249
  recovery
14242
14250
  });
14251
+ if (!hasRunnableCompartmentWindow(boundary))
14252
+ return null;
14253
+ let formattedTokens;
14254
+ try {
14255
+ formattedTokens = scanFormattedHead(db, sessionId, triggerBudget, boundary.offset, boundary.eligibleEndOrdinal).tokenEstimate;
14256
+ } catch {
14257
+ formattedTokens = "unavailable";
14258
+ }
14259
+ logForceFire(boundary.trueRawEligibleTokens, formattedTokens);
14260
+ return boundary;
14243
14261
  });
14244
- if (hasRunnableCompartmentWindow(scaledBoundary)) {
14262
+ if (scaledBoundary) {
14245
14263
  return { shouldFire: true, reason: "force_band", boundarySnapshot: scaledBoundary };
14246
14264
  }
14247
14265
  sessionLog2(sessionId, "compartment trigger: force_band skipped — no protected head meets summary admission after emergency tail scale");
@@ -14250,7 +14268,7 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
14250
14268
  const clusterEnabled = commitClusterTrigger?.enabled ?? true;
14251
14269
  const minClusters = commitClusterTrigger?.min_clusters ?? DEFAULT_MIN_COMMIT_CLUSTERS_FOR_TRIGGER;
14252
14270
  if (clusterEnabled && tailInfo.commitClusterCount >= minClusters && tailInfo.tokenEstimate >= triggerBudget) {
14253
- sessionLog2(sessionId, `compartment trigger: commit-cluster fire — ${tailInfo.commitClusterCount} clusters (min=${minClusters}), ~${tailInfo.tokenEstimate} tokens in eligible prefix`);
14271
+ sessionLog2(sessionId, `compartment trigger: commit-cluster fire — ${tailInfo.commitClusterCount} clusters (min=${minClusters}) admittedBy=commit_clusters trueRawTokens=${tailInfo.trueRawEligibleTokens} formattedTokens=${tailInfo.tokenEstimate}`);
14254
14272
  return {
14255
14273
  shouldFire: true,
14256
14274
  reason: "commit_clusters",
@@ -14258,7 +14276,8 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
14258
14276
  };
14259
14277
  }
14260
14278
  if (tailInfo.tokenEstimate >= triggerBudget * TAIL_SIZE_TRIGGER_MULTIPLIER || tailInfo.chunkHasMore && tailInfo.tokenEstimate > 0) {
14261
- sessionLog2(sessionId, `compartment trigger: tail-size fire — ~${tailInfo.tokenEstimate} TC-chunked tokens (hasMore=${tailInfo.chunkHasMore}, true-raw ~${tailInfo.trueRawEligibleTokens}) exceeds ${triggerBudget * TAIL_SIZE_TRIGGER_MULTIPLIER} budget threshold`);
14279
+ const admittedBy = tailInfo.chunkHasMore ? "has_more" : "formatted";
14280
+ sessionLog2(sessionId, `compartment trigger: tail-size fire — budget threshold ${triggerBudget * TAIL_SIZE_TRIGGER_MULTIPLIER} admittedBy=${admittedBy} trueRawTokens=${tailInfo.trueRawEligibleTokens} formattedTokens=${tailInfo.tokenEstimate}`);
14262
14281
  return {
14263
14282
  shouldFire: true,
14264
14283
  reason: "tail_size",
@@ -14274,13 +14293,13 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
14274
14293
  sessionLog2(sessionId, `historian redundancy skip: summarizer not needed this pass — usage is ${usage.percentage.toFixed(1)}%; queued/automatic drops are projected to reclaim to ${projectedPostDropPercentage.toFixed(1)}% (target ${relativePostDropTarget.toFixed(1)}%) on this pass (${rideLabel})`);
14275
14294
  return { shouldFire: false };
14276
14295
  }
14277
- if (!tailInfo.hasProtectedEligibleHead || !tailInfo.isMeaningful) {
14296
+ if (!tailInfo.hasProtectedEligibleHead || !tailInfo.proactiveAdmission) {
14278
14297
  let floorOnly = false;
14279
14298
  const boundary = tailInfo.boundarySnapshot;
14280
14299
  const floor = boundary?.diagnostics?.livePromptFloor;
14281
14300
  if (!consumedFloorMark && floor?.ordinal && floor.from > floor.to) {
14282
14301
  const withoutFloor = getUnsummarizedTailInfo(db, sessionId, triggerBudget, usage, executeThresholdPercentage, contextLimit, resolvedInMemoryTail, taggerFloor, true);
14283
- floorOnly = withoutFloor.hasProtectedEligibleHead && withoutFloor.isMeaningful;
14302
+ floorOnly = withoutFloor.hasProtectedEligibleHead && withoutFloor.proactiveAdmission !== undefined;
14284
14303
  if (floorOnly && primaryExecute && usage.percentage >= executeThresholdPercentage && writeExecuteReclaimState(db, sessionId, {
14285
14304
  floorOrdinal: floor.ordinal,
14286
14305
  floorPromptId: floor.messageId ?? null
@@ -14292,7 +14311,7 @@ function checkCompartmentTrigger(db, sessionId, sessionMeta, usage, _previousPer
14292
14311
  sessionLog2(sessionId, `compartment trigger: not firing at ${usage.percentage.toFixed(1)}% — ${refusal}; offset=${tailInfo.nextStartOrdinal} protectedStart=${boundary?.protectedTailStart ?? "none"} eligibleEnd=${boundary?.eligibleEndOrdinal ?? "none"} rawTokens=${tailInfo.trueRawEligibleTokens} chunkTokens=${tailInfo.tokenEstimate}`);
14293
14312
  return { shouldFire: false };
14294
14313
  }
14295
- sessionLog2(sessionId, `compartment trigger: proactive fire at ${usage.percentage.toFixed(1)}% (floor=${proactiveTriggerPercentage}% projected post-drop=${formatProjectedPostDropPercentage(projectedPostDropPercentage)} target=${relativePostDropTarget.toFixed(1)}%)`);
14314
+ sessionLog2(sessionId, `compartment trigger: proactive fire at ${usage.percentage.toFixed(1)}% (floor=${proactiveTriggerPercentage}% projected post-drop=${formatProjectedPostDropPercentage(projectedPostDropPercentage)} target=${relativePostDropTarget.toFixed(1)}%) admittedBy=${tailInfo.proactiveAdmission} trueRawTokens=${tailInfo.trueRawEligibleTokens} formattedTokens=${tailInfo.tokenEstimate}`);
14296
14315
  return {
14297
14316
  shouldFire: true,
14298
14317
  reason: "projected_headroom",
@@ -16449,7 +16468,7 @@ function registerRpcHandlers(rpcServer, args) {
16449
16468
  const db = readDatabase();
16450
16469
  if (!db)
16451
16470
  return { ok: false, error: "db unavailable" };
16452
- const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-7s8nyzhy.js"));
16471
+ const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-nyj8ca0y.js"));
16453
16472
  const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-ykvt5k2s.js"));
16454
16473
  log2(`[rpc] recomp requested for session ${sessionId}`);
16455
16474
  if (!args.client && !args.hiddenCompletionExecutor) {
@@ -16534,11 +16553,12 @@ function registerRpcHandlers(rpcServer, args) {
16534
16553
  const db = readDatabase();
16535
16554
  if (!db)
16536
16555
  return { ok: false, error: "db unavailable" };
16537
- const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-560v99mk.js"));
16556
+ const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-dxda1svq.js"));
16538
16557
  const model = liveSessionState.liveModelBySession.get(sessionId);
16539
16558
  const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
16540
16559
  const ctx = {
16541
16560
  ...await buildManagedCtx(db),
16561
+ memoryInjectionBudgetTokens: config.memory?.injection_budget_tokens,
16542
16562
  contextLimit,
16543
16563
  executeThresholdPercentage: resolveExecuteThresholdDetail(config.execute_threshold_percentage ?? 65, model ? `${model.providerID}/${model.modelID}` : undefined, 65, {
16544
16564
  tokensConfig: config.execute_threshold_tokens,
@@ -24425,7 +24445,7 @@ async function runCompartmentPhaseImpl(args) {
24425
24445
  const budgetMs = resolveHistorianInlineJoinBudget(args.historianTimeoutMs);
24426
24446
  return { timeoutMs: budgetMs, budgetMs };
24427
24447
  }
24428
- function historianRunDeps(boundarySnapshot) {
24448
+ function historianRunDeps(boundarySnapshot, recoveryTriggerReason) {
24429
24449
  return {
24430
24450
  client: args.client,
24431
24451
  hiddenCompletionExecutor: args.hiddenCompletionExecutor,
@@ -24434,6 +24454,7 @@ async function runCompartmentPhaseImpl(args) {
24434
24454
  sessionId: args.sessionId,
24435
24455
  historianChunkTokens: args.historianChunkTokens,
24436
24456
  boundarySnapshot,
24457
+ recoveryTriggerReason,
24437
24458
  currentContextLimit: args.boundaryContextLimit,
24438
24459
  historyBudgetTokens: args.historyBudgetTokens,
24439
24460
  historianTimeoutMs: args.historianTimeoutMs,
@@ -24450,6 +24471,8 @@ async function runCompartmentPhaseImpl(args) {
24450
24471
  historianTwoPass: args.historianTwoPass,
24451
24472
  historianExpandTools: args.historianExpandTools,
24452
24473
  memoryEnabled: args.memoryEnabled,
24474
+ memoryInjectionBudgetTokens: args.injectionBudgetTokens,
24475
+ memoryProjectPath: args.projectPath ?? null,
24453
24476
  autoPromote: args.autoPromote,
24454
24477
  onCompartmentStatePublished: args.onCompartmentStatePublished,
24455
24478
  preserveInjectionCacheUntilConsumed: true
@@ -24512,7 +24535,7 @@ async function runCompartmentPhaseImpl(args) {
24512
24535
  sessionLog2(args.sessionId, `transform: recovery chain stops: the historian's drain budget is spent; the request is still about ${fit.tokens} tokens, over the 95% line ${fit.lineTokens}`);
24513
24536
  return "stopped";
24514
24537
  }
24515
- startCompartmentAgent(historianRunDeps(boundary));
24538
+ startCompartmentAgent(historianRunDeps(boundary, "recovery_chain"));
24516
24539
  const nextRun = getActiveCompartmentRun(args.sessionId);
24517
24540
  if (!nextRun || nextRun === lastRun) {
24518
24541
  sessionLog2(args.sessionId, "transform: recovery chain stops: the next historian run did not start");
@@ -24587,6 +24610,8 @@ async function runCompartmentPhaseImpl(args) {
24587
24610
  historianTwoPass: args.historianTwoPass,
24588
24611
  historianExpandTools: args.historianExpandTools,
24589
24612
  memoryEnabled: args.memoryEnabled,
24613
+ memoryInjectionBudgetTokens: args.injectionBudgetTokens,
24614
+ memoryProjectPath: args.projectPath ?? null,
24590
24615
  autoPromote: args.autoPromote,
24591
24616
  onCompartmentStatePublished: args.onCompartmentStatePublished,
24592
24617
  preserveInjectionCacheUntilConsumed: true
@@ -24605,7 +24630,7 @@ async function runCompartmentPhaseImpl(args) {
24605
24630
  let activeRun = getActiveCompartmentRun(args.sessionId);
24606
24631
  if (!activeRun && hasEligibleHistoryForCompartment() && (args.client || args.hiddenCompletionExecutor)) {
24607
24632
  sessionLog2(args.sessionId, `transform: 95% reached (${args.contextUsage.percentage.toFixed(1)}%), force-starting compartment agent and blocking`);
24608
- startCompartmentAgent(historianRunDeps(getBoundarySnapshotForCompartment() ?? undefined));
24633
+ startCompartmentAgent(historianRunDeps(getBoundarySnapshotForCompartment() ?? undefined, "emergency_95"));
24609
24634
  activeRun = getActiveCompartmentRun(args.sessionId);
24610
24635
  } else if (!activeRun && hasEligibleHistoryForCompartment()) {
24611
24636
  sessionLog2(args.sessionId, "transform: cannot force-start compartment agent without client");
@@ -25482,6 +25507,7 @@ function createTransform(deps) {
25482
25507
  sessionId,
25483
25508
  historianChunkTokens: historianRun?.chunkTokens ?? deps.getHistorianChunkTokens?.() ?? 20000,
25484
25509
  boundarySnapshot: boundarySnapshot ?? undefined,
25510
+ recoveryTriggerReason: emergencyRecoveryArmed ? "overflow_recovery" : urgent ? "emergency_95" : "startup_recovery",
25485
25511
  currentContextLimit: boundaryContextLimit,
25486
25512
  historyBudgetTokens,
25487
25513
  historianTimeoutMs: historianRun?.timeoutMs ?? deps.historianTimeoutMs,
@@ -25496,6 +25522,8 @@ function createTransform(deps) {
25496
25522
  historianTwoPass: historianRun?.twoPass ?? deps.historianTwoPass,
25497
25523
  historianExpandTools: historianRun?.expandTools ?? deps.historianExpandTools,
25498
25524
  memoryEnabled: deps.memoryConfig?.enabled,
25525
+ memoryInjectionBudgetTokens: deps.memoryConfig?.injectionBudgetTokens,
25526
+ memoryProjectPath: projectIdentity ?? null,
25499
25527
  autoPromote: historianRun?.autoPromote ?? deps.memoryConfig?.autoPromote,
25500
25528
  ensureProjectRegistered: deps.ensureProjectRegistered,
25501
25529
  preserveInjectionCacheUntilConsumed: true,
@@ -3,14 +3,14 @@ import {
3
3
  } from "./index-ywrz4wy2.js";
4
4
  import {
5
5
  clearEmergencyRecovery
6
- } from "./index-8sc7vqt7.js";
6
+ } from "./index-kvfrse61.js";
7
7
  import {
8
8
  requestPendingMaterialization,
9
9
  dropSlot
10
- } from "./index-ywxvdwmj.js";
10
+ } from "./index-ezr8mr1c.js";
11
11
  import {
12
12
  executeContextRecomp
13
- } from "./index-4yjn3er4.js";
13
+ } from "./index-x2hwwzk1.js";
14
14
  import {
15
15
  renderUserFacingFailure,
16
16
  userFacingFailureCode
@@ -35,7 +35,7 @@ import {
35
35
  getRawSessionTagKeysThrough2,
36
36
  getLegacyProtectedTailStartOrdinal2,
37
37
  readSessionChunk2
38
- } from "./index-d0feqcs5.js";
38
+ } from "./index-6kgsfb81.js";
39
39
  import {
40
40
  getHarness2,
41
41
  harnessOwnsOpenCodeStore2
@@ -113,7 +113,7 @@ import {
113
113
  LATEST_SUPPORTED_VERSION,
114
114
  getPersistedSchemaVersion,
115
115
  openDatabase
116
- } from "./index-0cz8bsyx.js";
116
+ } from "./index-qn27gh4e.js";
117
117
  import {
118
118
  areRustHistorianSyntheticParts2,
119
119
  isStrictGapHealingMessage2,
@@ -200,14 +200,14 @@ import {
200
200
  getProjectState,
201
201
  recordSubagentInvocation,
202
202
  getLatestHistorianInvocationId
203
- } from "./index-ywxvdwmj.js";
203
+ } from "./index-ezr8mr1c.js";
204
204
  import {
205
205
  clearCompressionDepth,
206
206
  clearCompressionDepthRange,
207
207
  toMessageIndexSource,
208
208
  clearIndexedMessagesInTransaction,
209
209
  indexSourcesAfterOrdinal
210
- } from "./index-ev2rrjfc.js";
210
+ } from "./index-7dj3s7qq.js";
211
211
  import {
212
212
  stripWellFormedLeadingTagPrefix,
213
213
  peelLeadingMcTagNotation,
@@ -256,7 +256,7 @@ import {
256
256
  foldShrunkPartTags2,
257
257
  getTagNumberByMessageId2,
258
258
  getActiveTagsBySession2
259
- } from "./index-8sc7vqt7.js";
259
+ } from "./index-kvfrse61.js";
260
260
  import {
261
261
  openCodeDbExists,
262
262
  withReadOnlySessionDb,
@@ -4323,11 +4323,11 @@ var USER_OBSERVATIONS_DISABLED_TOGGLE = `<user_observation_extraction>disabled</
4323
4323
  User-memory review is not running (the dreamer is disabled): do NOT emit a <user_observations> block.`;
4324
4324
  function buildCompartmentAgentPrompt(inputs) {
4325
4325
  const parts = [];
4326
+ parts.push(...readEnabledProjectMemories(inputs.memoryEnabled, () => inputs.projectMemory ? [inputs.projectMemory] : []));
4326
4327
  if (inputs.seedExamples)
4327
4328
  parts.push(inputs.seedExamples);
4328
4329
  if (inputs.sessionReferences)
4329
4330
  parts.push(inputs.sessionReferences);
4330
- parts.push(...readEnabledProjectMemories(inputs.memoryEnabled, () => inputs.projectMemory ? [inputs.projectMemory] : []));
4331
4331
  if (inputs.extractionFree) {
4332
4332
  parts.push(`<extraction>disabled</extraction>
4333
4333
  Structural recomp mode: emit compartments and <meta> only. Do NOT emit <facts>, <events>, <user_observations>, or <primer_candidates>.`);
@@ -4347,6 +4347,34 @@ Memory is disabled for this project: do NOT emit a <facts> block. Produce compar
4347
4347
 
4348
4348
  `);
4349
4349
  }
4350
+ function logHistorianPromptSizes(sessionId, system, prompt) {
4351
+ const sourceStart = prompt.indexOf(`<new_messages>
4352
+
4353
+ `);
4354
+ const sourceEnd = prompt.lastIndexOf(`
4355
+
4356
+ </new_messages>
4357
+
4358
+ ${HISTORIAN_TRANSCRIPT_GUARD}`);
4359
+ const hasSource = sourceStart !== -1 && sourceEnd > sourceStart;
4360
+ const blockBytes = (tag) => {
4361
+ if (!hasSource)
4362
+ return 0;
4363
+ const start = prompt.indexOf(`<${tag}>`);
4364
+ const close = `</${tag}>`;
4365
+ const end = prompt.indexOf(close, start + 1);
4366
+ return start >= 0 && end > start && end < sourceStart ? Buffer.byteLength(prompt.slice(start, end + close.length)) : 0;
4367
+ };
4368
+ const memoryBytes = blockBytes("project-memory");
4369
+ const seedBytes = blockBytes("compartment_examples_from_other_projects");
4370
+ const referenceBytes = blockBytes("session_references");
4371
+ const newMessageBytes = hasSource ? Buffer.byteLength(prompt.slice(sourceStart, sourceEnd + `
4372
+
4373
+ </new_messages>`.length)) : 0;
4374
+ const systemBytes = Buffer.byteLength(system);
4375
+ const userBytes = Buffer.byteLength(prompt);
4376
+ sessionLog2(sessionId, `historian request sizes: systemBytes=${systemBytes} userBytes=${userBytes} memoryBytes=${memoryBytes} seedBytes=${seedBytes} referenceBytes=${referenceBytes} newMessageBytes=${newMessageBytes}`);
4377
+ }
4350
4378
 
4351
4379
  // src/hooks/magic-context/producer-window-guard.ts
4352
4380
  var PRODUCER_WINDOW_REFUSAL_MARGIN = 0.03;
@@ -10661,6 +10689,9 @@ function sourceNamesForMemories(args) {
10661
10689
  }
10662
10690
  return names.size > 0 ? names : undefined;
10663
10691
  }
10692
+ function readM0ProjectMemories(db, projectPath, workspace, at = Date.now()) {
10693
+ return workspace.isWorkspaced ? getMemoriesByProjects2(db, workspace.expandedIdentities, ["active", "permanent"], at, workspace.ownIdentities, workspace.shareCategories) : getMemoriesByProject2(db, projectPath, ["active", "permanent"], at);
10694
+ }
10664
10695
  function memoryCanonicalIdentity(memory, workspace) {
10665
10696
  return resolveStoredPathWorkspaceIdentity(memory.projectPath, workspace.identities, workspace.canonicalIdentityByStoredPath);
10666
10697
  }
@@ -11437,7 +11468,7 @@ function materializeM0(options) {
11437
11468
  snapshotMarkers.projectDocsHash = docs.canonicalHash;
11438
11469
  compartments = options.compactionOff ? [] : readM0Compartments(options.db, options.sessionId);
11439
11470
  facts = [];
11440
- memories = projectPath ? workspace.isWorkspaced ? getMemoriesByProjects2(options.db, workspace.expandedIdentities, ["active", "permanent"], foldMaterializedAt, workspace.ownIdentities, workspace.shareCategories) : getMemoriesByProject2(options.db, projectPath, ["active", "permanent"], foldMaterializedAt) : [];
11471
+ memories = projectPath ? readM0ProjectMemories(options.db, projectPath, workspace, foldMaterializedAt) : [];
11441
11472
  userMemories = options.memoryEnabled === false ? [] : safeGetActiveUserMemories(options.db);
11442
11473
  options.db.exec("COMMIT");
11443
11474
  } catch (error) {
@@ -14299,9 +14330,9 @@ function fnv1a(input) {
14299
14330
  }
14300
14331
  return h >>> 0;
14301
14332
  }
14302
- function selectSeeds(sessionId, chunkStart, count = SEED_FLOOR) {
14333
+ function selectSeeds(sessionId, _chunkStart, count = SEED_FLOOR) {
14303
14334
  const bands = seedsByBand();
14304
- const seed = fnv1a(`${sessionId}:${chunkStart}`);
14335
+ const seed = fnv1a(sessionId);
14305
14336
  const picks = [];
14306
14337
  const bandOrder = [];
14307
14338
  for (let i = 0;i < SEED_BANDS.length; i++) {
@@ -14448,7 +14479,22 @@ function fitHistorianPrompt(args) {
14448
14479
  const requested = Math.max(0, Math.floor(args.requestedChunkTokens));
14449
14480
  const seeds = selectSeeds(args.sessionId, args.chunkStart);
14450
14481
  const references = selectSessionReferences(args.sessionCompartments, seeds, args.sessionId, args.chunkStart);
14451
- const memories = orderHistorianMemories(readEnabledProjectMemories(args.memoryEnabled, () => typeof args.memories === "function" ? args.memories() : args.memories));
14482
+ const memories = readEnabledProjectMemories(args.memoryEnabled, () => {
14483
+ const project = args.memoryProject;
14484
+ const projectPath = project?.projectPath;
14485
+ const workspace = project && resolveWorkspaceRenderContext(project);
14486
+ const rows = project ? projectPath && workspace ? readM0ProjectMemories(project.db, projectPath, workspace) : [] : (typeof args.memories === "function" ? args.memories() : args.memories) ?? [];
14487
+ const budget = args.memoryInjectionBudgetTokens ?? DEFAULT_MEMORY_BUDGET_TOKENS;
14488
+ const { selected } = workspace?.isWorkspaced ? trimWorkspaceMemoriesToBudgetV2(args.sessionId, rows, budget, workspace, {
14489
+ sourceNameByMemoryId: sourceNamesForMemories({
14490
+ memories: rows,
14491
+ projectPath,
14492
+ workspace
14493
+ })
14494
+ }) : trimMemoriesToBudgetV2(args.sessionId, rows, budget);
14495
+ const selectedIds = new Set(selected.map((memory) => memory.id));
14496
+ return orderHistorianMemories(rows.filter((memory) => selectedIds.has(memory.id)));
14497
+ });
14452
14498
  const render = (refs, memoryCount, seedCount) => ({
14453
14499
  seedExamples: renderSeedExamplesBlock(seeds.slice(0, seedCount)),
14454
14500
  sessionReferences: renderSessionReferencesBlock(references, refs),
@@ -15010,6 +15056,7 @@ async function runHistorianPrompt(args) {
15010
15056
  });
15011
15057
  if (failure)
15012
15058
  throw new Error(failure);
15059
+ logHistorianPromptSizes(parentSessionId, system, prompt);
15013
15060
  return executor.attempt(opened, request);
15014
15061
  }, { childSessionId: opened.childSessionId }),
15015
15062
  timeoutMs: timeoutMs ?? DEFAULT_HISTORIAN_TIMEOUT_MS,
@@ -17866,7 +17913,11 @@ async function runCompartmentAgent(deps) {
17866
17913
  chunkStart: Math.max(1, offset),
17867
17914
  lastOrdinal: eligibleEndOrdinal - 1,
17868
17915
  sessionCompartments: priorCompartments,
17869
- memories: () => getMemoriesByProject2(db, projectPath, ["active", "permanent"]),
17916
+ memoryProject: {
17917
+ db,
17918
+ projectPath: deps.memoryProjectPath === undefined ? projectPath : deps.memoryProjectPath ?? undefined
17919
+ },
17920
+ memoryInjectionBudgetTokens: deps.memoryInjectionBudgetTokens,
17870
17921
  memoryEnabled: deps.memoryEnabled !== false,
17871
17922
  userObservationsRequested: deps.userObservationsRequested
17872
17923
  });
@@ -17987,6 +18038,9 @@ async function runCompartmentAgent(deps) {
17987
18038
  }
17988
18039
  historianRunStarted = true;
17989
18040
  deps.onHistorianRunStarted?.();
18041
+ if (deps.recoveryTriggerReason) {
18042
+ sessionLog2(sessionId, `historian recovery fire: admittedBy=${deps.recoveryTriggerReason} trueRawTokens=${boundarySnapshot.trueRawEligibleTokens} formattedChunkTokens=${chunk.tokenEstimate}`);
18043
+ }
17990
18044
  const prompt = buildCompartmentAgentPrompt({
17991
18045
  seedExamples: promptFit.seedExamples,
17992
18046
  sessionReferences: promptFit.sessionReferences,
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  recordToolParameters,
5
5
  createDroppedInputToolExecuteBeforeHook,
6
6
  readRawSessionMessages2
7
- } from "./index-d0feqcs5.js";
7
+ } from "./index-6kgsfb81.js";
8
8
  import {
9
9
  setHarness2
10
10
  } from "./index-pavzsdc6.js";
@@ -58,7 +58,7 @@ import {
58
58
  checkCompactionMarkerConsistency,
59
59
  clearInjectionCache,
60
60
  clearNoteNudgeTriggerOnly
61
- } from "./index-4yjn3er4.js";
61
+ } from "./index-x2hwwzk1.js";
62
62
  import"./index-sd3egckz.js";
63
63
  import {
64
64
  hasTrustedAbsoluteWall,
@@ -143,7 +143,7 @@ import {
143
143
  parameterDescriptionsFor,
144
144
  MagicContextRpcServer,
145
145
  applyHiddenSubagentTemperature
146
- } from "./index-bqd5dmm4.js";
146
+ } from "./index-stqmv1mt.js";
147
147
  import {
148
148
  resolveOpenCodeDbPath,
149
149
  openCodeDbPathExists,
@@ -195,7 +195,7 @@ import {
195
195
  dropServedRecord,
196
196
  registerLkgPersistence,
197
197
  dropSlot
198
- } from "./index-ywxvdwmj.js";
198
+ } from "./index-ezr8mr1c.js";
199
199
  import {
200
200
  recordSessionProjectIdentity
201
201
  } from "./index-jg7sbt3v.js";
@@ -210,7 +210,7 @@ import {
210
210
  openDatabaseAsync,
211
211
  isDatabasePersisted,
212
212
  getDatabasePersistenceError
213
- } from "./index-0cz8bsyx.js";
213
+ } from "./index-qn27gh4e.js";
214
214
  import {
215
215
  registerExitAbort,
216
216
  unregisterExitAbort
@@ -230,7 +230,7 @@ import"./index-pxnzyvjc.js";
230
230
  import {
231
231
  getDefaultSubcConnectionFile,
232
232
  SubcModuleTransport
233
- } from "./index-3yyfftqq.js";
233
+ } from "./index-c0k54yhd.js";
234
234
  import"./index-qt1qqasc.js";
235
235
  import"./index-e6ncz7a6.js";
236
236
  import {
@@ -280,7 +280,7 @@ import {
280
280
  isAnthropicFamilyRoute,
281
281
  deleteTagsByMessageId2,
282
282
  getMaxTagNumberBySession2
283
- } from "./index-8sc7vqt7.js";
283
+ } from "./index-kvfrse61.js";
284
284
  import {
285
285
  resolveHistorianModel2,
286
286
  resolveOpenCodeAgentOverrides2,
@@ -293,7 +293,7 @@ import {
293
293
  import"./index-snbpdpa3.js";
294
294
  import {
295
295
  deleteIndexedMessage
296
- } from "./index-ev2rrjfc.js";
296
+ } from "./index-7dj3s7qq.js";
297
297
  import"./index-6athgjba.js";
298
298
  import"./index-tebcx987.js";
299
299
  import {
@@ -317,13 +317,13 @@ import {
317
317
  armBindingRecoverySafely,
318
318
  collectForeignTextParts,
319
319
  resetDegradedCacheCount2
320
- } from "./index-qdver0af.js";
320
+ } from "./index-san8daqa.js";
321
321
  import {
322
322
  scheduleClearAndReindex
323
- } from "./index-3hk445am.js";
323
+ } from "./index-71h616be.js";
324
324
  import {
325
325
  runManagedRecomp2
326
- } from "./index-3wq9btxt.js";
326
+ } from "./index-wz0t5e5s.js";
327
327
  import {
328
328
  isValidSemver,
329
329
  compareSemverCore
@@ -331,11 +331,11 @@ import {
331
331
  import"./index-fmsr7v69.js";
332
332
  import {
333
333
  runManagedWrapup2
334
- } from "./index-s2qsd3w9.js";
335
- import"./index-tq20edcs.js";
334
+ } from "./index-8596jbnw.js";
335
+ import"./index-0ab398z2.js";
336
336
  import"./index-52x68mj4.js";
337
- import"./index-s2jdky2x.js";
338
- import"./index-kv4ntrr6.js";
337
+ import"./index-g59gpt1j.js";
338
+ import"./index-gwb2wpz7.js";
339
339
  import {
340
340
  isDreamerRunnable,
341
341
  isSmartNoteSurfaceAvailable,
@@ -8203,7 +8203,7 @@ var require_src2 = __commonJS(function(exports, module) {
8203
8203
  // package.json
8204
8204
  var package_default = {
8205
8205
  name: "@cortexkit/opencode-magic-context",
8206
- version: "0.49.63",
8206
+ version: "0.49.65",
8207
8207
  type: "module",
8208
8208
  description: "OpenCode plugin for Magic Context — cross-session memory and context management",
8209
8209
  main: "dist/index.js",
@@ -10439,6 +10439,7 @@ function createMagicContextHook(deps) {
10439
10439
  };
10440
10440
  const buildManagedWrapupCtx = (sessionId) => ({
10441
10441
  ...buildManagedRecompCtx(sessionId),
10442
+ memoryInjectionBudgetTokens: deps.config.memory?.injection_budget_tokens,
10442
10443
  contextLimit: (() => {
10443
10444
  const model = resolveLiveModel(sessionId);
10444
10445
  return model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
@@ -12081,7 +12082,7 @@ async function setup(context) {
12081
12082
  if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
12082
12083
  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.`);
12083
12084
  }
12084
- const { registerContext } = await import("./context-aaht09yh.js");
12085
+ const { registerContext } = await import("./context-3mfsdp1v.js");
12085
12086
  setHarness2("opencode2");
12086
12087
  bindStaleBuildNotice({}, import.meta.url, "opencode2");
12087
12088
  const duties = await registerContext(context);
@@ -12554,7 +12555,7 @@ var server = async (ctx) => {
12554
12555
  rustReplayParticipant: () => magicContextRuntime.magicContext?.getRustReplayParticipant?.() ?? null,
12555
12556
  onStorageBusyRefusal: async (sessionId, message) => {
12556
12557
  const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-ykvt5k2s.js"));
12557
- const { abortSessionFailClosed } = await importPluginModule(() => import("./transform-postprocess-phase-fxp1atm1.js"));
12558
+ const { abortSessionFailClosed } = await importPluginModule(() => import("./transform-postprocess-phase-8yjcca9t.js"));
12558
12559
  await sendStatusNotification(ctx.client, sessionId, message, {
12559
12560
  toastDurationMs: 15000
12560
12561
  });