@retaw106/mmc-oc 2.4.0 → 2.5.0

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 (132) hide show
  1. package/dist/{context-c72brxe5.js → context-xx09sh1g.js} +1279 -408
  2. package/dist/features/magic-context/message-index-async.d.ts +6 -2
  3. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  4. package/dist/features/magic-context/message-index.d.ts +5 -8
  5. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  6. package/dist/features/magic-context/search.d.ts +5 -1
  7. package/dist/features/magic-context/search.d.ts.map +1 -1
  8. package/dist/features/magic-context/storage-db.d.ts +2 -0
  9. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  10. package/dist/features/magic-context/storage-host-instruction-retention.d.ts +4 -0
  11. package/dist/features/magic-context/storage-host-instruction-retention.d.ts.map +1 -0
  12. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  13. package/dist/features/magic-context/storage-meta-shared.d.ts +2 -2
  14. package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
  15. package/dist/features/magic-context/storage-session-tables.d.ts +9 -1
  16. package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
  17. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  18. package/dist/hooks/magic-context/auto-search-hint.d.ts +3 -0
  19. package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
  20. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  21. package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
  22. package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -2
  23. package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
  24. package/dist/hooks/magic-context/diagnostic-log-state.d.ts +4 -0
  25. package/dist/hooks/magic-context/diagnostic-log-state.d.ts.map +1 -0
  26. package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
  27. package/dist/hooks/magic-context/file-token-coverage.d.ts +11 -0
  28. package/dist/hooks/magic-context/file-token-coverage.d.ts.map +1 -0
  29. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  30. package/dist/hooks/magic-context/host-served-rows.d.ts +10 -0
  31. package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
  32. package/dist/hooks/magic-context/inject-compartments.d.ts +1 -1
  33. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  34. package/dist/hooks/magic-context/lkg-recovery-fence.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 +1 -1
  37. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/nudge-evaluation-log.d.ts +3 -0
  39. package/dist/hooks/magic-context/nudge-evaluation-log.d.ts.map +1 -0
  40. package/dist/hooks/magic-context/pass-outcome.d.ts +2 -0
  41. package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
  42. package/dist/hooks/magic-context/pending-drop-eligibility.d.ts.map +1 -1
  43. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +2 -0
  44. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  46. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +3 -3
  47. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/system-date-refresh.d.ts +3 -2
  49. package/dist/hooks/magic-context/system-date-refresh.d.ts.map +1 -1
  50. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  51. package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts +4 -0
  52. package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts.map +1 -0
  53. package/dist/hooks/magic-context/tag-content-primitives.d.ts +1 -1
  54. package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/tag-messages.d.ts +15 -2
  56. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  57. package/dist/hooks/magic-context/text-complete.d.ts +1 -1
  58. package/dist/hooks/magic-context/text-complete.d.ts.map +1 -1
  59. package/dist/hooks/magic-context/todo-view.d.ts +2 -2
  60. package/dist/hooks/magic-context/tool-drop-target.d.ts +3 -2
  61. package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
  62. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +1 -0
  63. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  64. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +6 -0
  65. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  66. package/dist/hooks/magic-context/transform-stage-logger.d.ts +3 -0
  67. package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/transform.d.ts +4 -2
  69. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  70. package/dist/{index-kahkxcqw.js → index-0d40b4q8.js} +14740 -14292
  71. package/dist/{index-48e9znrc.js → index-1vxffj5j.js} +75 -22
  72. package/dist/{index-ykq24x1n.js → index-bpjjcdy9.js} +1 -1
  73. package/dist/{index-r7s7d350.js → index-k25thxq7.js} +1 -1
  74. package/dist/{index-27ddyx39.js → index-mjf0p7yq.js} +1 -1
  75. package/dist/{index-dwh99z66.js → index-pte3cfs9.js} +194 -5
  76. package/dist/index.js +2 -2
  77. package/dist/{message-time-backfill-j96x1sab.js → message-time-backfill-g9py24yt.js} +1 -1
  78. package/dist/plugin/subagent-tool-policy.d.ts +4 -0
  79. package/dist/plugin/subagent-tool-policy.d.ts.map +1 -1
  80. package/dist/{read-session-chunk-t8bg6wkz.js → read-session-chunk-eb3fy45y.js} +3 -3
  81. package/dist/{recomp-orchestrator-k760qy1n.js → recomp-orchestrator-mmpy5cb7.js} +6 -6
  82. package/dist/{send-session-notification-njjf3b4s.js → send-session-notification-zpqs213d.js} +3 -3
  83. package/dist/shared/model-suggestion-retry.d.ts +2 -0
  84. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  85. package/dist/shared/rpc-discovery-cleanup.d.ts +3 -0
  86. package/dist/shared/rpc-discovery-cleanup.d.ts.map +1 -0
  87. package/dist/shared/rpc-server.d.ts +2 -0
  88. package/dist/shared/rpc-server.d.ts.map +1 -1
  89. package/dist/shared/search-text.d.ts +8 -0
  90. package/dist/shared/search-text.d.ts.map +1 -0
  91. package/dist/shared/sqlite.d.ts +6 -1
  92. package/dist/shared/sqlite.d.ts.map +1 -1
  93. package/dist/shared/storage-file-mutex.d.ts.map +1 -1
  94. package/dist/shared/system-directive.d.ts +2 -0
  95. package/dist/shared/system-directive.d.ts.map +1 -1
  96. package/dist/v2/fold/native-replay.d.ts +11 -2
  97. package/dist/v2/fold/native-replay.d.ts.map +1 -1
  98. package/dist/v2/fold/policy.d.ts.map +1 -1
  99. package/dist/v2/fold/restore.d.ts.map +1 -1
  100. package/dist/v2/hooks/context.d.ts +1 -1
  101. package/dist/v2/hooks/context.d.ts.map +1 -1
  102. package/dist/v2/hooks/generate.d.ts +36 -1
  103. package/dist/v2/hooks/generate.d.ts.map +1 -1
  104. package/dist/v2/hooks/lkg-system.d.ts +35 -4
  105. package/dist/v2/hooks/lkg-system.d.ts.map +1 -1
  106. package/dist/v2/hooks/payload.d.ts +10 -1
  107. package/dist/v2/hooks/payload.d.ts.map +1 -1
  108. package/dist/v2/hooks/store.d.ts +2 -0
  109. package/dist/v2/hooks/store.d.ts.map +1 -1
  110. package/dist/v2/hooks/types.d.ts +12 -0
  111. package/dist/v2/hooks/types.d.ts.map +1 -1
  112. package/dist/v2/server.js +9033 -7461
  113. package/dist/v2/store-reader.d.ts +11 -0
  114. package/dist/v2/store-reader.d.ts.map +1 -1
  115. package/dist/web/main.js +229 -8
  116. package/dist/{wrapup-orchestrator-b2gswatj.js → wrapup-orchestrator-jq589pgr.js} +6 -6
  117. package/package.json +1 -1
  118. package/src/config/latch-permanence-guard.test.ts +4 -0
  119. package/src/shared/model-suggestion-retry.test.ts +52 -0
  120. package/src/shared/model-suggestion-retry.ts +8 -3
  121. package/src/shared/rpc-discovery-cleanup.test.ts +125 -0
  122. package/src/shared/rpc-discovery-cleanup.ts +57 -0
  123. package/src/shared/rpc-server.ts +36 -13
  124. package/src/shared/search-text.test.ts +30 -0
  125. package/src/shared/search-text.ts +62 -0
  126. package/src/shared/sqlite-turn-deadline.test.ts +286 -0
  127. package/src/shared/sqlite.ts +237 -9
  128. package/src/shared/storage-file-mutex.test.ts +51 -2
  129. package/src/shared/storage-file-mutex.ts +11 -1
  130. package/src/shared/system-directive.test.ts +37 -0
  131. package/src/shared/system-directive.ts +19 -1
  132. package/src/shared/tag-transcript.ts +16 -4
@@ -7,7 +7,7 @@ import {
7
7
  } from "./index-x37vg474.js";
8
8
  import {
9
9
  getTagIdentityWriteGeneration
10
- } from "./index-dwh99z66.js";
10
+ } from "./index-pte3cfs9.js";
11
11
  import {
12
12
  getHarness,
13
13
  sessionLog
@@ -28,7 +28,7 @@ import {
28
28
  withReadOnlySessionDb,
29
29
  getRawSessionMessageCountFromDb,
30
30
  getMessageTimesFromOpenCodeDb
31
- } from "./index-ykq24x1n.js";
31
+ } from "./index-bpjjcdy9.js";
32
32
 
33
33
  // src/shared/protected-tools-policy.ts
34
34
  var DEFAULT_PROTECTED_TOOLS = {
@@ -102,7 +102,27 @@ function isSystemDirective(text) {
102
102
  return text.trimStart().startsWith(SYSTEM_DIRECTIVE_PREFIX);
103
103
  }
104
104
  function removeSystemReminders(text) {
105
- return text.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/gi, "").trim();
105
+ return removeNestedBlocks(text, ["system-reminder"]).trim();
106
+ }
107
+ function removeNestedBlocks(text, names) {
108
+ const tags = new RegExp(`<(/?)(${names.join("|")})(?:\\s[^<>]*?)?\\s*(/?)>`, "gi");
109
+ const stack = [];
110
+ let end = 0;
111
+ let result = "";
112
+ for (const match of text.matchAll(tags)) {
113
+ if (stack.length === 0)
114
+ result += text.slice(end, match.index);
115
+ const name = match[2].toLowerCase();
116
+ if (match[1]) {
117
+ if (stack[stack.length - 1] === name)
118
+ stack.pop();
119
+ } else if (!match[3])
120
+ stack.push(name);
121
+ end = match.index + match[0].length;
122
+ }
123
+ if (stack.length === 0)
124
+ result += text.slice(end);
125
+ return result;
106
126
  }
107
127
 
108
128
  // src/hooks/magic-context/token-count-exact.ts
@@ -807,13 +827,16 @@ function stripDanglingTagNotationGlobally(value) {
807
827
  function stripTagSectionCharacters(value) {
808
828
  return value.replace(STRAY_SECTION_CHAR_REGEX, "");
809
829
  }
810
- function stripPersistedAssistantText(value) {
830
+ function stripPersistedAssistantText(value, acceptsEmpty = true) {
831
+ if (!acceptsEmpty && !value.includes("§") && !value.trim())
832
+ return value;
811
833
  let text = stripWellFormedLeadingTagPrefix(value);
812
834
  text = stripCompleteTagPairsGlobally(text);
813
835
  text = stripMalformedTagNotationGlobally(text);
814
836
  text = stripDanglingTagNotationGlobally(text);
815
837
  text = stripTagSectionCharacters(text);
816
- return text.trim();
838
+ const stripped = text.trim();
839
+ return !acceptsEmpty && value.trim().length > 0 && stripped.length === 0 ? value : stripped;
817
840
  }
818
841
  function byteSize(value) {
819
842
  return encoder.encode(value).length;
@@ -2832,9 +2855,11 @@ function planEmergencyDrop(input) {
2832
2855
  const workingSpan = Math.max(ceilingTokens - fixedFloor, 0);
2833
2856
  const target = fixedFloor + TARGET_FRACTION * workingSpan;
2834
2857
  const reclaimTokens = Math.round(currentTotalInputTokens - target);
2835
- const floorNote = fixedFloor > ceilingTokens ? `; fixed floor ≈${Math.round(fixedFloor)} already exceeds ceiling ${Math.round(ceilingTokens)}: tool drops cannot reach the target` : "";
2858
+ if (fixedFloor > ceilingTokens) {
2859
+ return noop(`fixed floor ≈${Math.round(fixedFloor)} already exceeds ceiling ${Math.round(ceilingTokens)}: tool drops cannot reach the target`);
2860
+ }
2836
2861
  if (reclaimTokens <= EMERGENCY_REARM_MIN_TOKENS) {
2837
- return noop(`reclaim<=min (${reclaimTokens} <= ${EMERGENCY_REARM_MIN_TOKENS})${floorNote}`);
2862
+ return noop(`reclaim<=min (${reclaimTokens} <= ${EMERGENCY_REARM_MIN_TOKENS})`);
2838
2863
  }
2839
2864
  const cutoff = input.protectedCutoff;
2840
2865
  const windowYields = absoluteEmergency;
@@ -2889,16 +2914,16 @@ function planEmergencyDrop(input) {
2889
2914
  }
2890
2915
  }
2891
2916
  if (selected.length === 0) {
2892
- return noop(`no-candidates${floorNote}`);
2917
+ return noop("no-candidates");
2893
2918
  }
2894
2919
  if (!input.passAlreadyPriced && reclaimed < EMERGENCY_MIN_ACHIEVABLE_RECLAIM_TOKENS) {
2895
- return noop(`achievable reclaim below minimum (${selected.length} tags, reclaim≈${Math.round(reclaimed)} < ${EMERGENCY_MIN_ACHIEVABLE_RECLAIM_TOKENS} against gap ${reclaimTokens})${floorNote}`);
2920
+ return noop(`achievable reclaim below minimum (${selected.length} tags, reclaim≈${Math.round(reclaimed)} < ${EMERGENCY_MIN_ACHIEVABLE_RECLAIM_TOKENS} against gap ${reclaimTokens})`);
2896
2921
  }
2897
2922
  return {
2898
2923
  shouldDrop: true,
2899
2924
  tagNumbers: selected,
2900
2925
  reclaimTokens,
2901
- reason: `tiered drop: ${selected.length} tags, reclaim≈${reclaimed}/${reclaimTokens} tokens (floor≈${fixedFloor}, ceiling=${Math.round(ceilingTokens)})${floorNote}`
2926
+ reason: `tiered drop: ${selected.length} tags, reclaim≈${reclaimed}/${reclaimTokens} tokens (floor≈${fixedFloor}, ceiling=${Math.round(ceilingTokens)})`
2902
2927
  };
2903
2928
  }
2904
2929
  function measureEmergencyTag(tag, target, calibration, skeleton) {
@@ -4723,6 +4748,35 @@ function isHostRenderedSystemMessage(message) {
4723
4748
  const id = message.info.id;
4724
4749
  return (typeof id !== "string" || id.length === 0) && message.info.role === "system";
4725
4750
  }
4751
+ var COVERED_INSTRUCTION_ROW = "coveredInstructionRow";
4752
+ function markCoveredInstructionRow(target) {
4753
+ Object.defineProperty(target, COVERED_INSTRUCTION_ROW, {
4754
+ value: true,
4755
+ enumerable: false,
4756
+ configurable: true
4757
+ });
4758
+ return target;
4759
+ }
4760
+ function isCoveredInstructionRow(value) {
4761
+ return typeof value === "object" && value !== null && value[COVERED_INSTRUCTION_ROW] === true;
4762
+ }
4763
+ function takeCoveredInstructionRows(messages) {
4764
+ const taken = messages.filter((message) => isCoveredInstructionRow(message.info));
4765
+ if (taken.length > 0) {
4766
+ const kept = messages.filter((message) => !isCoveredInstructionRow(message.info));
4767
+ messages.splice(0, messages.length, ...kept);
4768
+ }
4769
+ return taken;
4770
+ }
4771
+ function cloneKeepingCoveredInstructionMarks(messages) {
4772
+ const copy = structuredClone(messages);
4773
+ messages.forEach((message, index) => {
4774
+ const copied = copy[index];
4775
+ if (copied && isCoveredInstructionRow(message.info))
4776
+ markCoveredInstructionRow(copied.info);
4777
+ });
4778
+ return copy;
4779
+ }
4726
4780
 
4727
4781
  // src/hooks/magic-context/read-session-true-raw-tokens.ts
4728
4782
  function completedToolArcCrossesBoundary(invOrdinal, resOrdinal, boundary) {
@@ -5355,11 +5409,6 @@ function isFilePart(part) {
5355
5409
  const p = part;
5356
5410
  return p.type === "file" && typeof p.url === "string";
5357
5411
  }
5358
- function buildFileSourceContent(parts) {
5359
- const content = parts.filter(isTextPart).map((part) => stripTagPrefix(part.text)).join(`
5360
- `).trim();
5361
- return content.length > 0 ? content : null;
5362
- }
5363
5412
 
5364
5413
  // src/shared/user-answer.ts
5365
5414
  function hasUserAnswerMetadata(value) {
@@ -6616,7 +6665,7 @@ class ToolMutationBatch {
6616
6665
  this.partsToRemove.add(servedPart(occurrence));
6617
6666
  this.affectedMessages.add(occurrence.message);
6618
6667
  }
6619
- wouldStrandConversationEnd(occurrences) {
6668
+ wouldStrandConversationEnd(occurrences, plannedRemovals) {
6620
6669
  const served = this.servedMessages ?? this.messages;
6621
6670
  let end;
6622
6671
  for (let i = served.length - 1;i >= 0 && end === undefined; i -= 1) {
@@ -6626,7 +6675,7 @@ class ToolMutationBatch {
6626
6675
  if (!end || !occurrences.some((occurrence) => occurrence.message === end))
6627
6676
  return false;
6628
6677
  const leaving = new Set(occurrences.map(servedPart));
6629
- const survives = (part) => !leaving.has(part) && !this.partsToRemove.has(part);
6678
+ const survives = (part) => !leaving.has(part) && !this.partsToRemove.has(part) && !plannedRemovals?.has(part);
6630
6679
  return end.info.role === "assistant" ? !end.parts.some((part) => partHasCompletedResult(part) && survives(part)) : !end.parts.some((part) => hasMeaningfulPart(part) && survives(part));
6631
6680
  }
6632
6681
  finalize() {
@@ -6800,11 +6849,16 @@ function createToolDropTarget(compositeKey, thinkingParts, index, batch, tagId)
6800
6849
  return null;
6801
6850
  return toolInputStringBytes(readRawInput());
6802
6851
  },
6803
- wouldStrandConversationEnd: () => {
6852
+ wouldStrandConversationEnd: (plannedRemovals) => {
6804
6853
  const entry = index.get(compositeKey);
6805
6854
  if (!entry || entry.occurrences.length === 0)
6806
6855
  return false;
6807
- return batch.wouldStrandConversationEnd(entry.occurrences);
6856
+ return batch.wouldStrandConversationEnd(entry.occurrences, plannedRemovals);
6857
+ },
6858
+ notePlannedRemoval: (plannedRemovals) => {
6859
+ for (const occurrence of index.get(compositeKey)?.occurrences ?? []) {
6860
+ plannedRemovals.add(servedPart(occurrence));
6861
+ }
6808
6862
  },
6809
6863
  prepareDrop: () => {
6810
6864
  const entry = index.get(compositeKey);
@@ -6896,9 +6950,8 @@ function setBoundedRawMessageProvider2(sessionId, provider) {
6896
6950
  }
6897
6951
  return setRawMessageProvider(sessionId, wrapper);
6898
6952
  }
6899
- var SYSTEM_REMINDER_BLOCK_REGEX = /<system-reminder>[\s\S]*?<\/system-reminder>/gi;
6900
6953
  function cleanUserText2(text) {
6901
- return stripOutsideSteeringWrappers(text, (segment) => segment.replace(SYSTEM_REMINDER_BLOCK_REGEX, "").replace(OMO_INTERNAL_INITIATOR_MARKER, "")).trim();
6954
+ return stripOutsideSteeringWrappers(text, (segment) => removeSystemReminders(segment).replace(OMO_INTERNAL_INITIATOR_MARKER, "")).trim();
6902
6955
  }
6903
6956
  function hasMeaningfulChunkUserText(parts) {
6904
6957
  for (const part of parts) {
@@ -7668,4 +7721,4 @@ function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdina
7668
7721
  toolResultBoundaries
7669
7722
  };
7670
7723
  }
7671
- export { toolTemplateError, DEFAULT_PROTECTED_TOOLS, normalizeProtectedToolName, mergeProtectedTools, detectLatestTurnThinkingMismatch, isPrefixBoundThinkingModel, detectOverflow, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, isRecord, protectedToolTagNumbers, protectedToolTokenCount, textMentionsRecentCommit, removeSystemReminders, hasMeaningfulUserText2, extractTexts2, getTokenizerNativeMemoryStats, preloadTokenizer, estimateTokens, estimateFixedPromptTokens, currentReclaimableToolOutputCount, stableStringify, contentTagOwnerMessageId, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisibleMessage, normalizeTodoStateJson, buildSyntheticTodoPart, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, formatTailHygienePrefixMismatch, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchangedIfEnabled, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, isDroppedToolOutput, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, measureEmergencyTag, installV3PerfSchema, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, tagTombstoneOwnerRange, tagTombstoneOwnerKey, tagRevisionKey, tagIdentityRevisionKey, installTagIdentityRevisionTrigger, deleteTagIdentityRevisions, getRecentTagOwnerMessageIds, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, getActiveTagTokenTotalsByMessage, getAllStatusTagTokenTotalsFlat, getReasoningTokenEstimatesByMessage, tryGetReasoningTokenEstimatesByMessage, getMaxTagNumberByOwnerMessage, scanTagOwnerSummary, isTagOwnerSummaryReady, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, markTagDropped, markWhitespaceAssistantTagInert, getInertWhitespaceAssistantTags, getInertWhitespaceAssistantTagsByNumbers, updateTagDropMode, updateCavemanDepth, updateTagMessageId, foldShrunkPartTags, markTagsCompactedByMessageIds, getMaxTagNumberBySession, getTagNumberByMessageId, getAssignableTagNumberByMessageId, deriveTagLoadFloor, TAG_SELECT_COLUMNS, getTagsBySession, getActiveTagsBySession, getTailHygieneTags, getTagsByNumbers, getNewestToolTagNumbers, getDroppedTagsByNumbers, getMaxDroppedTagNumber, getTagById, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, getCandidateToolOwners, pickNearestPriorOwner, expandToolPart, markHostUnservedRow, retreatPastHostUnservedRows, snapTerminalCompartmentToServedRow, isHostRenderedSystemMessage, completedToolArcCrossesBoundary, estimateTrueRawMessageTokens, buildToolArcs, fenceBoundaryForCompletedToolArcs, fenceBoundaryForToolArcs, buildTrueRawTokenIndex, computeRawRangeFingerprint, stripSystemInjection, isTextPart, isToolPartWithOutput, isFilePart, buildFileSourceContent, toolPartHasUserAnswer, recordToolParameters, createDroppedInputGuard, assertExecutableToolInput, isEditTool, getCurrentToolSetHash, setDatabase, loadToolDefinitionMeasurements, recordToolDefinition, getMeasuredToolDefinitionTokens, describeFinalWireTail, estimatePartImageTokens, estimateMessageTokens, wireContentBytes, createFinalWireUsageTracker, estimateFinalWireInputTokens, modelAcceptsEmptyContent, isAnthropicFamilyRoute, neutralizeDroppedReasoningPart, restoreNeutralizedReasoningPart, isNeutralizedReasoningPart, neutralizedReasoningSource, variantChangeBustsProviderCache, makeSentinel, makeWholeMessageSentinel, neutralizeWholeMessage, isSentinel, replaySentinelByMessageIds, SKELETON_REAL_INPUT_MAX_BYTES, partHasCompletedResult, extractToolCallObservation, ToolMutationBatch, createToolDropTarget, resolveHostServedBoundaryId2, hasRawMessageProvider2, setBoundedRawMessageProvider2, cleanUserText2, withRawSessionMessageCache2, readRawSessionMessages2, readRawSessionMessagePage2, getRawSessionMessageOrdinalCount2, visitRawSessionMessages2, readRawSessionMessageRange2, prepareRawSessionOrdinals2, primeTailRawMessageCache2, getCachedAbsoluteMessageCount2, primeInMemoryTailRawMessageCache2, readRawSessionMessageIdOrdinalsForRange2, hasRawSessionMessageById2, readRawSessionMessageOrdinalById2, compareRawSessionMessageOrder2, readRawSessionMessageById2, getRawSessionMessageCount2, getRawSessionTagKeysThrough2, getLegacyProtectedTailStartOrdinal2, readSessionChunk2 };
7724
+ export { toolTemplateError, DEFAULT_PROTECTED_TOOLS, normalizeProtectedToolName, mergeProtectedTools, detectLatestTurnThinkingMismatch, isPrefixBoundThinkingModel, detectOverflow, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, isRecord, protectedToolTagNumbers, protectedToolTokenCount, textMentionsRecentCommit, removeSystemReminders, removeNestedBlocks, hasMeaningfulUserText2, extractTexts2, getTokenizerNativeMemoryStats, preloadTokenizer, estimateTokens, estimateFixedPromptTokens, currentReclaimableToolOutputCount, stableStringify, contentTagOwnerMessageId, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisibleMessage, normalizeTodoStateJson, buildSyntheticTodoPart, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, formatTailHygienePrefixMismatch, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchangedIfEnabled, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, isDroppedToolOutput, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, measureEmergencyTag, installV3PerfSchema, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, TAG_TOMBSTONE_OWNER_PREFIX, tagTombstoneOwnerRange, tagTombstoneOwnerKey, tagRevisionKey, tagIdentityRevisionKey, installTagIdentityRevisionTrigger, deleteTagIdentityRevisions, getRecentTagOwnerMessageIds, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, getActiveTagTokenTotalsByMessage, getAllStatusTagTokenTotalsFlat, getReasoningTokenEstimatesByMessage, tryGetReasoningTokenEstimatesByMessage, getMaxTagNumberByOwnerMessage, scanTagOwnerSummary, isTagOwnerSummaryReady, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, markTagDropped, markWhitespaceAssistantTagInert, getInertWhitespaceAssistantTags, getInertWhitespaceAssistantTagsByNumbers, updateTagDropMode, updateCavemanDepth, updateTagMessageId, foldShrunkPartTags, markTagsCompactedByMessageIds, getMaxTagNumberBySession, getTagNumberByMessageId, getAssignableTagNumberByMessageId, deriveTagLoadFloor, TAG_SELECT_COLUMNS, getTagsBySession, getActiveTagsBySession, getTailHygieneTags, getTagsByNumbers, getNewestToolTagNumbers, getDroppedTagsByNumbers, getMaxDroppedTagNumber, getTagById, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, getCandidateToolOwners, pickNearestPriorOwner, expandToolPart, markHostUnservedRow, retreatPastHostUnservedRows, snapTerminalCompartmentToServedRow, isHostRenderedSystemMessage, markCoveredInstructionRow, isCoveredInstructionRow, takeCoveredInstructionRows, cloneKeepingCoveredInstructionMarks, completedToolArcCrossesBoundary, estimateTrueRawMessageTokens, buildToolArcs, fenceBoundaryForCompletedToolArcs, fenceBoundaryForToolArcs, buildTrueRawTokenIndex, computeRawRangeFingerprint, stripSystemInjection, isTextPart, isToolPartWithOutput, isFilePart, toolPartHasUserAnswer, recordToolParameters, createDroppedInputGuard, assertExecutableToolInput, isEditTool, getCurrentToolSetHash, setDatabase, loadToolDefinitionMeasurements, recordToolDefinition, getMeasuredToolDefinitionTokens, describeFinalWireTail, estimatePartImageTokens, estimateMessageTokens, wireContentBytes, createFinalWireUsageTracker, estimateFinalWireInputTokens, modelAcceptsEmptyContent, isAnthropicFamilyRoute, neutralizeDroppedReasoningPart, restoreNeutralizedReasoningPart, isNeutralizedReasoningPart, neutralizedReasoningSource, variantChangeBustsProviderCache, makeSentinel, makeWholeMessageSentinel, neutralizeWholeMessage, isSentinel, replaySentinelByMessageIds, SKELETON_REAL_INPUT_MAX_BYTES, partHasCompletedResult, extractToolCallObservation, ToolMutationBatch, createToolDropTarget, resolveHostServedBoundaryId2, hasRawMessageProvider2, setBoundedRawMessageProvider2, cleanUserText2, withRawSessionMessageCache2, readRawSessionMessages2, readRawSessionMessagePage2, getRawSessionMessageOrdinalCount2, visitRawSessionMessages2, readRawSessionMessageRange2, prepareRawSessionOrdinals2, primeTailRawMessageCache2, getCachedAbsoluteMessageCount2, primeInMemoryTailRawMessageCache2, readRawSessionMessageIdOrdinalsForRange2, hasRawSessionMessageById2, readRawSessionMessageOrdinalById2, compareRawSessionMessageOrder2, readRawSessionMessageById2, getRawSessionMessageCount2, getRawSessionTagKeysThrough2, getLegacyProtectedTailStartOrdinal2, readSessionChunk2 };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Database,
3
3
  getSqliteDatabasePath
4
- } from "./index-dwh99z66.js";
4
+ } from "./index-pte3cfs9.js";
5
5
  import {
6
6
  harnessOwnsOpenCodeStore,
7
7
  log
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-k59af64t.js";
4
4
  import {
5
5
  shouldHoldIgnoredNotification
6
- } from "./index-ykq24x1n.js";
6
+ } from "./index-bpjjcdy9.js";
7
7
 
8
8
  // src/shared/error-message.ts
9
9
  function getErrorMessage(error) {
@@ -4,7 +4,7 @@ import {
4
4
  renderUserFacingFailure,
5
5
  userFacingFailureCode,
6
6
  executeContextRecomp
7
- } from "./index-kahkxcqw.js";
7
+ } from "./index-0d40b4q8.js";
8
8
  import {
9
9
  sessionLog
10
10
  } from "./index-k59af64t.js";
@@ -167,6 +167,177 @@ function topLevelCommaSegments(text) {
167
167
  function getTagIdentityWriteGeneration() {
168
168
  return tagIdentityWriteGeneration;
169
169
  }
170
+ var busyTimeoutStates = new WeakMap;
171
+ var BUSY_TIMEOUT_QUERY = /^\s*PRAGMA\s+(?:(?:\w+|"[^"]+"|`[^`]+`|\[[^\]]+\])\s*\.\s*)?(?:busy_timeout|"busy_timeout"|`busy_timeout`|\[busy_timeout\])\s*;?\s*$/i;
172
+ var BUSY_TIMEOUT_SETTER = /^\s*PRAGMA\s+(?:(?:\w+|"[^"]+"|`[^`]+`|\[[^\]]+\])\s*\.\s*)?(?:busy_timeout|"busy_timeout"|`busy_timeout`|\[busy_timeout\])\s*(?==|\()/i;
173
+ function literalBusyTimeout(sql) {
174
+ const head = BUSY_TIMEOUT_SETTER.exec(sql);
175
+ if (!head)
176
+ return;
177
+ const match = /^(?:=\s*|\(\s*)(?:'(-?\d+)'|"(-?\d+)"|(-?\d+))\s*\)?\s*;?\s*$/.exec(sql.slice(head[0].length));
178
+ if (!match)
179
+ return;
180
+ const value = Number(match[1] ?? match[2] ?? match[3]);
181
+ return value < 0 ? 0 : value <= 2147483647 ? value : undefined;
182
+ }
183
+ function busyTimeoutStatements(sql) {
184
+ const statements = [];
185
+ let statement = "";
186
+ let quote = "";
187
+ for (let i = 0;i < sql.length; i++) {
188
+ const char = sql[i];
189
+ if (quote) {
190
+ statement += char;
191
+ if (char === quote) {
192
+ if (sql[i + 1] === quote)
193
+ statement += sql[++i];
194
+ else
195
+ quote = "";
196
+ }
197
+ } else if (char === "'" || char === '"' || char === "`" || char === "[") {
198
+ quote = char === "[" ? "]" : char;
199
+ statement += char;
200
+ } else if (char === "-" && sql[i + 1] === "-") {
201
+ while (i + 1 < sql.length && sql[i + 1] !== `
202
+ `)
203
+ i++;
204
+ statement += " ";
205
+ } else if (char === "/" && sql[i + 1] === "*") {
206
+ i += 2;
207
+ while (i < sql.length && !(sql[i] === "*" && sql[i + 1] === "/"))
208
+ i++;
209
+ i++;
210
+ statement += " ";
211
+ } else if (char === ";") {
212
+ statements.push(statement);
213
+ statement = "";
214
+ } else
215
+ statement += char;
216
+ }
217
+ statements.push(statement);
218
+ return statements.filter((part) => part.trim().length > 0);
219
+ }
220
+ function installNativeDeadlineRouting(db) {
221
+ const rawExec = db.exec.bind(db);
222
+ const rawPrepare = db.prepare.bind(db);
223
+ const readTimeout = () => {
224
+ const statement = rawPrepare("PRAGMA busy_timeout");
225
+ try {
226
+ return Object.values(statement.get())[0];
227
+ } finally {
228
+ statement.finalize?.();
229
+ }
230
+ };
231
+ const timeoutState = { current: readTimeout() };
232
+ busyTimeoutStates.set(db, timeoutState);
233
+ const setBusyTimeout = (timeout) => {
234
+ rawExec(`PRAGMA busy_timeout=${timeout}`);
235
+ timeoutState.current = timeout;
236
+ };
237
+ const withinDeadline = (operation) => {
238
+ const deadline = nativeWaitScope?.getStore();
239
+ if (!deadline?.active || !deadline.remainingMs)
240
+ return operation();
241
+ const remaining = deadline.remainingMs();
242
+ if (remaining === Infinity)
243
+ return operation();
244
+ const previous = timeoutState.current;
245
+ const timeout = Math.min(previous, Math.max(0, Math.floor(remaining)));
246
+ if (timeout === previous)
247
+ return operation();
248
+ setBusyTimeout(timeout);
249
+ try {
250
+ return operation();
251
+ } finally {
252
+ setBusyTimeout(previous);
253
+ }
254
+ };
255
+ Object.defineProperty(db, "exec", {
256
+ configurable: true,
257
+ writable: true,
258
+ value: (sql) => {
259
+ const parts = /\bbusy_timeout\b/i.test(sql) ? busyTimeoutStatements(sql) : [];
260
+ if (parts.length === 1 && BUSY_TIMEOUT_QUERY.test(parts[0]))
261
+ return rawExec(sql);
262
+ const singleSetter = parts.length === 1 && BUSY_TIMEOUT_SETTER.test(parts[0]);
263
+ const setting = singleSetter ? literalBusyTimeout(parts[0]) : undefined;
264
+ if (singleSetter) {
265
+ const result = rawExec(sql);
266
+ timeoutState.current = setting ?? readTimeout();
267
+ return result;
268
+ }
269
+ if (!/\bbusy_timeout\b/i.test(sql))
270
+ return withinDeadline(() => rawExec(sql));
271
+ const setters = parts.filter((part) => BUSY_TIMEOUT_SETTER.test(part));
272
+ return withinDeadline(() => {
273
+ try {
274
+ const result = rawExec(sql);
275
+ if (setters.length)
276
+ timeoutState.current = literalBusyTimeout(setters[setters.length - 1]) ?? readTimeout();
277
+ return result;
278
+ } catch (error) {
279
+ if (setters.length)
280
+ timeoutState.current = readTimeout();
281
+ throw error;
282
+ }
283
+ });
284
+ }
285
+ });
286
+ const nativePrepare = (sql) => BUSY_TIMEOUT_QUERY.test(sql) || BUSY_TIMEOUT_SETTER.test(sql) ? rawPrepare(sql) : withinDeadline(() => rawPrepare(sql));
287
+ Object.defineProperty(db, "prepare", {
288
+ configurable: true,
289
+ writable: true,
290
+ value: (sql) => {
291
+ const statement = nativePrepare(sql);
292
+ const normalized = /\bbusy_timeout\b/i.test(sql) ? busyTimeoutStatements(sql)[0] ?? sql : sql;
293
+ const setting = literalBusyTimeout(normalized);
294
+ const timeoutSetter = BUSY_TIMEOUT_SETTER.test(normalized);
295
+ const timeoutQuery = BUSY_TIMEOUT_QUERY.test(normalized);
296
+ if (timeoutSetter)
297
+ timeoutState.current = setting ?? readTimeout();
298
+ for (const method of ["run", "get", "all", "values"]) {
299
+ const execute = statement[method]?.bind(statement);
300
+ if (!execute)
301
+ continue;
302
+ Object.defineProperty(statement, method, {
303
+ configurable: true,
304
+ value: (...args) => {
305
+ if (timeoutQuery)
306
+ return execute(...args);
307
+ if (!timeoutSetter)
308
+ return withinDeadline(() => execute(...args));
309
+ const result = execute(...args);
310
+ timeoutState.current = readTimeout();
311
+ return result;
312
+ }
313
+ });
314
+ }
315
+ if (typeof statement.iterate === "function") {
316
+ const iterate = statement.iterate.bind(statement);
317
+ Object.defineProperty(statement, "iterate", {
318
+ configurable: true,
319
+ value: (...args) => {
320
+ const iterator = !timeoutSetter && !timeoutQuery ? withinDeadline(() => iterate(...args)) : iterate(...args);
321
+ const next = iterator.next.bind(iterator);
322
+ if (timeoutSetter)
323
+ timeoutState.current = readTimeout();
324
+ iterator.next = () => {
325
+ if (timeoutQuery)
326
+ return next();
327
+ if (!timeoutSetter)
328
+ return withinDeadline(next);
329
+ const result = next();
330
+ timeoutState.current = readTimeout();
331
+ return result;
332
+ };
333
+ return iterator;
334
+ }
335
+ });
336
+ }
337
+ return statement;
338
+ }
339
+ });
340
+ }
170
341
  function installTransactionRouting(db, readonly) {
171
342
  const nativeExec = db.exec.bind(db);
172
343
  Object.defineProperty(db, "exec", {
@@ -304,7 +475,7 @@ function wrapRemainingTagWriteForms(statement) {
304
475
  });
305
476
  }
306
477
  }
307
- function trackSqliteConnection(db, filename, options) {
478
+ function trackSqliteConnection(db, filename, options, turnDeadlines = false) {
308
479
  const originalClose = db.close.bind(db);
309
480
  const sequence = nextSqliteConnectionSequence++;
310
481
  const metadata = {
@@ -312,6 +483,8 @@ function trackSqliteConnection(db, filename, options) {
312
483
  filename: typeof filename === "string" ? filename : Buffer.isBuffer(filename) ? "<buffer>" : ":memory:",
313
484
  readonly: Boolean(options) && typeof options === "object" && (options.readonly === true || options.readOnly === true)
314
485
  };
486
+ if (turnDeadlines)
487
+ installNativeDeadlineRouting(db);
315
488
  installTransactionRouting(db, metadata.readonly);
316
489
  Object.defineProperty(db, "close", {
317
490
  configurable: true,
@@ -364,6 +537,12 @@ function buildNodeSqliteDatabaseClass(DatabaseSync) {
364
537
  return NodeSqliteDatabase;
365
538
  }
366
539
  var Database = TrackedDatabase;
540
+ function createSqliteTurnDatabase(filename, options) {
541
+ return trackSqliteConnection(new DatabaseImpl(filename, options), filename, options, true);
542
+ }
543
+ function hasSqliteTurnDeadlineRouting(db) {
544
+ return busyTimeoutStates.has(db);
545
+ }
367
546
  function getSqliteDatabasePath(db) {
368
547
  for (const connection of trackedSqliteConnections.values()) {
369
548
  if (connection.reference.deref() === db) {
@@ -383,6 +562,11 @@ function pragmaValue(db, name) {
383
562
  return row[name] ?? Object.values(row)[0];
384
563
  }
385
564
  function pragmaNumber(db, name) {
565
+ if (name === "busy_timeout") {
566
+ const state = busyTimeoutStates.get(db);
567
+ if (state)
568
+ return state.current;
569
+ }
386
570
  try {
387
571
  const value = pragmaValue(db, name);
388
572
  return typeof value === "number" && Number.isFinite(value) ? value : null;
@@ -513,11 +697,14 @@ function prepareCachedStatement(db, sql) {
513
697
  return ownPreparedStatement(db, db.prepare(sql));
514
698
  }
515
699
  var privilegeDepth = new WeakMap;
700
+ var nativeWaitScope;
516
701
  var transformPassScope = new AsyncLocalStorage;
517
702
  var admissionScope = new AsyncLocalStorage;
518
703
  var backgroundWriterScope = new AsyncLocalStorage;
519
704
  function withSqliteBackgroundWriter(operation) {
520
- return backgroundWriterScope.run(true, operation);
705
+ if (!nativeWaitScope?.getStore())
706
+ return backgroundWriterScope.run(true, operation);
707
+ return nativeWaitScope.run(undefined, () => backgroundWriterScope.run(true, operation));
521
708
  }
522
709
  function withSqliteTransformPass(operation) {
523
710
  const existing = transformPassScope.getStore();
@@ -548,7 +735,9 @@ function withSqliteTransformPass(operation) {
548
735
  return typeof reservation === "function" ? run(reservation) : reservation.then(run);
549
736
  }
550
737
  function withoutSqliteTransformPass(operation) {
551
- return transformPassScope.run(undefined, operation);
738
+ if (!nativeWaitScope?.getStore())
739
+ return transformPassScope.run(undefined, operation);
740
+ return nativeWaitScope.run(undefined, () => transformPassScope.run(undefined, operation));
552
741
  }
553
742
  function assertTransformWrite() {
554
743
  if (!backgroundWriterScope.getStore())
@@ -744,7 +933,7 @@ async function withAsyncPrivilegedWriter(db, operation, options = {}) {
744
933
  } catch (error) {
745
934
  if (entered || !(error instanceof SqliteAcquisitionBusyError))
746
935
  throw error;
747
- options.beforeRetry?.(error);
936
+ await options.beforeRetry?.(error);
748
937
  const elapsed = performance.now() - started;
749
938
  if (elapsed >= budgetMs) {
750
939
  reportSqliteDiagnostic(`sqlite writer site=privileged_writer lane=foreground acquire_ms=${Math.round(elapsed)} attempts=${attempts} outcome=busy`);
@@ -879,4 +1068,4 @@ async function withIndexChunk(input, operation) {
879
1068
  }
880
1069
  }
881
1070
 
882
- export { inRootAsyncContext, registerSlowWriteReporter, registerSqliteDiagnosticSink, detectSqliteRuntime, getTagIdentityWriteGeneration, Database, getSqliteDatabasePath, getSqliteMemoryStats, prepareCachedStatement, withSqliteBackgroundWriter, withSqliteTransformPass, withoutSqliteTransformPass, isTransientSqliteError, SqliteAcquisitionBusyError, beginSqliteWriterAsync, withAsyncPrivilegedWriter, withPrivilegedWriter, indexCoordinationInput, withIndexChunk };
1071
+ export { inRootAsyncContext, registerSlowWriteReporter, registerSqliteDiagnosticSink, detectSqliteRuntime, getTagIdentityWriteGeneration, Database, createSqliteTurnDatabase, hasSqliteTurnDeadlineRouting, getSqliteDatabasePath, getSqliteMemoryStats, prepareCachedStatement, withSqliteBackgroundWriter, withSqliteTransformPass, withoutSqliteTransformPass, isTransientSqliteError, SqliteAcquisitionBusyError, beginSqliteWriterAsync, withAsyncPrivilegedWriter, withPrivilegedWriter, indexCoordinationInput, withIndexChunk };
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@retaw106/mmc-oc",
9
- version: "2.4.0",
9
+ version: "2.5.0",
10
10
  type: "module",
11
11
  description: "OpenCode plugin for Magic Context — cross-session memory and context management",
12
12
  main: "dist/index.js",
@@ -127,7 +127,7 @@ async function setup(context) {
127
127
  log("v2 setup() called on a host without session.hook; v1 server lane owns this host, v2 lane inert");
128
128
  return async () => {};
129
129
  }
130
- const { registerContext } = await import("./context-c72brxe5.js");
130
+ const { registerContext } = await import("./context-xx09sh1g.js");
131
131
  setHarness("opencode2");
132
132
  const duties = await registerContext(context);
133
133
  log("[magic-context] @retaw106/mmc-oc v2 setup");
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  withSqliteBackgroundWriter,
3
3
  withoutSqliteTransformPass
4
- } from "./index-dwh99z66.js";
4
+ } from "./index-pte3cfs9.js";
5
5
  import"./index-k59af64t.js";
6
6
  import {
7
7
  logSlowWriteTransaction
@@ -6,4 +6,8 @@ export declare function hideSubagentTools(draft: {
6
6
  sessionID: string;
7
7
  tools: Record<string, unknown>;
8
8
  }, db: Database): void;
9
+ /** Apply the same request-local filtering when writer admission is unavailable. */
10
+ export declare function removePrimaryOnlyTools(tools: Record<string, unknown>): void;
11
+ /** Missing/unclassified sessions cannot authorize a busy replay. Never writes. */
12
+ export declare function storedSubagentMode(db: Database, sessionId: string): boolean | undefined;
9
13
  //# sourceMappingURL=subagent-tool-policy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subagent-tool-policy.d.ts","sourceRoot":"","sources":["../../src/plugin/subagent-tool-policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,sFAAsF;AACtF,wBAAgB,mBAAmB,CAC/B,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,eAAe,GAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAqB,GAC9D,MAAM,GAAG,SAAS,CASpB;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EAC5D,EAAE,EAAE,QAAQ,GACb,IAAI,CAGN"}
1
+ {"version":3,"file":"subagent-tool-policy.d.ts","sourceRoot":"","sources":["../../src/plugin/subagent-tool-policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,sFAAsF;AACtF,wBAAgB,mBAAmB,CAC/B,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,eAAe,GAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAqB,GAC9D,MAAM,GAAG,SAAS,CASpB;AAED,kFAAkF;AAClF,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,EAC5D,EAAE,EAAE,QAAQ,GACb,IAAI,CAGN;AAED,mFAAmF;AACnF,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAE3E;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAMvF"}
@@ -24,9 +24,9 @@ import {
24
24
  getRawSessionTagKeysThrough2,
25
25
  getLegacyProtectedTailStartOrdinal2,
26
26
  readSessionChunk2
27
- } from "./index-48e9znrc.js";
28
- import"./index-ykq24x1n.js";
29
- import"./index-dwh99z66.js";
27
+ } from "./index-1vxffj5j.js";
28
+ import"./index-bpjjcdy9.js";
29
+ import"./index-pte3cfs9.js";
30
30
  import"./index-x37vg474.js";
31
31
  import"./index-k59af64t.js";
32
32
  export {
@@ -2,13 +2,13 @@ import {
2
2
  setRecompStarting2,
3
3
  setRecompTerminal2,
4
4
  runManagedRecomp2
5
- } from "./index-27ddyx39.js";
6
- import"./index-kahkxcqw.js";
7
- import"./index-r7s7d350.js";
8
- import"./index-48e9znrc.js";
9
- import"./index-ykq24x1n.js";
5
+ } from "./index-mjf0p7yq.js";
6
+ import"./index-0d40b4q8.js";
7
+ import"./index-k25thxq7.js";
8
+ import"./index-1vxffj5j.js";
9
+ import"./index-bpjjcdy9.js";
10
10
  import"./index-yjv8dpht.js";
11
- import"./index-dwh99z66.js";
11
+ import"./index-pte3cfs9.js";
12
12
  import"./index-jdxxq8cz.js";
13
13
  import"./index-kmbme1v1.js";
14
14
  import"./index-5ty9rnbx.js";
@@ -4,9 +4,9 @@ import {
4
4
  clearIgnoredMessages2,
5
5
  observeIgnoredNotificationEvent2,
6
6
  sendStatusNotification2
7
- } from "./index-r7s7d350.js";
8
- import"./index-ykq24x1n.js";
9
- import"./index-dwh99z66.js";
7
+ } from "./index-k25thxq7.js";
8
+ import"./index-bpjjcdy9.js";
9
+ import"./index-pte3cfs9.js";
10
10
  import"./index-kmbme1v1.js";
11
11
  import"./index-k59af64t.js";
12
12
  export {
@@ -41,6 +41,8 @@ export interface PromptAttemptInfo {
41
41
  export interface PromptRetryOptions {
42
42
  transport?: PromptTransport;
43
43
  timeoutMs?: number;
44
+ /** False for callers whose configured model chain must not accept provider suggestions. Defaults to true. */
45
+ allowModelSuggestions?: boolean;
44
46
  /** External abort signal — cancels the in-flight LLM prompt immediately when aborted */
45
47
  signal?: AbortSignal;
46
48
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"model-suggestion-retry.d.ts","sourceRoot":"","sources":["../../src/shared/model-suggestion-retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAW7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAUrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,GAAG,SAAS,CAAC;AAElE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG;IAClE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CACpC,CAAC;AAOF,MAAM,MAAM,UAAU,GAAG;IACrB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AAO,CAsBpF;AA8ID;;;;;;;;;;;;;GAaG;AACH,wBAAsB,kCAAkC,CACpD,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,kBAAuB,GACjC,OAAO,CAAC,IAAI,CAAC,CAmGf;AA+ED;;;;GAIG;AACH,wBAAsB,kCAAkC,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,EAClF,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,2BAA2B,CAAC,OAAO,EAAE,UAAU,CAAC,GAC1D,OAAO,CAAC,0BAA0B,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAmK1D"}
@@ -0,0 +1,3 @@
1
+ /** Reap only records proven dead; live, unreadable and uncertain records stay. */
2
+ export declare function reapDeadRpcDiscovery(storageDir: string): Promise<void>;
3
+ //# sourceMappingURL=rpc-discovery-cleanup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-discovery-cleanup.d.ts","sourceRoot":"","sources":["../../src/shared/rpc-discovery-cleanup.ts"],"names":[],"mappings":"AAIA,kFAAkF;AAClF,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAmD5E"}
@@ -12,12 +12,14 @@ type RpcHandler = (params: Record<string, unknown>) => Promise<Record<string, un
12
12
  * of idle TUI CPU (#200). Pi never imports this module, so `Bun.serve` is safe.
13
13
  */
14
14
  export declare class MagicContextRpcServer {
15
+ private storageDir;
15
16
  private server;
16
17
  private port;
17
18
  private handlers;
18
19
  private portFilePath;
19
20
  private portDir;
20
21
  private startedAt;
22
+ private stopped;
21
23
  private readonly instanceId;
22
24
  private unregisterOwnInstance;
23
25
  /** Every authenticated WS socket, so dispose can close them all. */