@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.
- package/dist/{context-c72brxe5.js → context-xx09sh1g.js} +1279 -408
- package/dist/features/magic-context/message-index-async.d.ts +6 -2
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts +5 -8
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +5 -1
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +2 -0
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-host-instruction-retention.d.ts +4 -0
- package/dist/features/magic-context/storage-host-instruction-retention.d.ts.map +1 -0
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-shared.d.ts +2 -2
- package/dist/features/magic-context/storage-meta-shared.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts +9 -1
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-hint.d.ts +3 -0
- package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts +2 -2
- package/dist/hooks/magic-context/compartment-runner-validation.d.ts.map +1 -1
- package/dist/hooks/magic-context/diagnostic-log-state.d.ts +4 -0
- package/dist/hooks/magic-context/diagnostic-log-state.d.ts.map +1 -0
- package/dist/hooks/magic-context/emergency-drop.d.ts.map +1 -1
- package/dist/hooks/magic-context/file-token-coverage.d.ts +11 -0
- package/dist/hooks/magic-context/file-token-coverage.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/host-served-rows.d.ts +10 -0
- package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts +1 -1
- package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
- package/dist/hooks/magic-context/nudge-evaluation-log.d.ts +3 -0
- package/dist/hooks/magic-context/nudge-evaluation-log.d.ts.map +1 -0
- package/dist/hooks/magic-context/pass-outcome.d.ts +2 -0
- package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
- package/dist/hooks/magic-context/pending-drop-eligibility.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +2 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts +3 -3
- package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-date-refresh.d.ts +3 -2
- package/dist/hooks/magic-context/system-date-refresh.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts +4 -0
- package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts.map +1 -0
- package/dist/hooks/magic-context/tag-content-primitives.d.ts +1 -1
- package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +15 -2
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/text-complete.d.ts +1 -1
- package/dist/hooks/magic-context/text-complete.d.ts.map +1 -1
- package/dist/hooks/magic-context/todo-view.d.ts +2 -2
- package/dist/hooks/magic-context/tool-drop-target.d.ts +3 -2
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +1 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +6 -0
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-stage-logger.d.ts +3 -0
- package/dist/hooks/magic-context/transform-stage-logger.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +4 -2
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-kahkxcqw.js → index-0d40b4q8.js} +14740 -14292
- package/dist/{index-48e9znrc.js → index-1vxffj5j.js} +75 -22
- package/dist/{index-ykq24x1n.js → index-bpjjcdy9.js} +1 -1
- package/dist/{index-r7s7d350.js → index-k25thxq7.js} +1 -1
- package/dist/{index-27ddyx39.js → index-mjf0p7yq.js} +1 -1
- package/dist/{index-dwh99z66.js → index-pte3cfs9.js} +194 -5
- package/dist/index.js +2 -2
- package/dist/{message-time-backfill-j96x1sab.js → message-time-backfill-g9py24yt.js} +1 -1
- package/dist/plugin/subagent-tool-policy.d.ts +4 -0
- package/dist/plugin/subagent-tool-policy.d.ts.map +1 -1
- package/dist/{read-session-chunk-t8bg6wkz.js → read-session-chunk-eb3fy45y.js} +3 -3
- package/dist/{recomp-orchestrator-k760qy1n.js → recomp-orchestrator-mmpy5cb7.js} +6 -6
- package/dist/{send-session-notification-njjf3b4s.js → send-session-notification-zpqs213d.js} +3 -3
- package/dist/shared/model-suggestion-retry.d.ts +2 -0
- package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
- package/dist/shared/rpc-discovery-cleanup.d.ts +3 -0
- package/dist/shared/rpc-discovery-cleanup.d.ts.map +1 -0
- package/dist/shared/rpc-server.d.ts +2 -0
- package/dist/shared/rpc-server.d.ts.map +1 -1
- package/dist/shared/search-text.d.ts +8 -0
- package/dist/shared/search-text.d.ts.map +1 -0
- package/dist/shared/sqlite.d.ts +6 -1
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/storage-file-mutex.d.ts.map +1 -1
- package/dist/shared/system-directive.d.ts +2 -0
- package/dist/shared/system-directive.d.ts.map +1 -1
- package/dist/v2/fold/native-replay.d.ts +11 -2
- package/dist/v2/fold/native-replay.d.ts.map +1 -1
- package/dist/v2/fold/policy.d.ts.map +1 -1
- package/dist/v2/fold/restore.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/generate.d.ts +36 -1
- package/dist/v2/hooks/generate.d.ts.map +1 -1
- package/dist/v2/hooks/lkg-system.d.ts +35 -4
- package/dist/v2/hooks/lkg-system.d.ts.map +1 -1
- package/dist/v2/hooks/payload.d.ts +10 -1
- package/dist/v2/hooks/payload.d.ts.map +1 -1
- package/dist/v2/hooks/store.d.ts +2 -0
- package/dist/v2/hooks/store.d.ts.map +1 -1
- package/dist/v2/hooks/types.d.ts +12 -0
- package/dist/v2/hooks/types.d.ts.map +1 -1
- package/dist/v2/server.js +9033 -7461
- package/dist/v2/store-reader.d.ts +11 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/web/main.js +229 -8
- package/dist/{wrapup-orchestrator-b2gswatj.js → wrapup-orchestrator-jq589pgr.js} +6 -6
- package/package.json +1 -1
- package/src/config/latch-permanence-guard.test.ts +4 -0
- package/src/shared/model-suggestion-retry.test.ts +52 -0
- package/src/shared/model-suggestion-retry.ts +8 -3
- package/src/shared/rpc-discovery-cleanup.test.ts +125 -0
- package/src/shared/rpc-discovery-cleanup.ts +57 -0
- package/src/shared/rpc-server.ts +36 -13
- package/src/shared/search-text.test.ts +30 -0
- package/src/shared/search-text.ts +62 -0
- package/src/shared/sqlite-turn-deadline.test.ts +286 -0
- package/src/shared/sqlite.ts +237 -9
- package/src/shared/storage-file-mutex.test.ts +51 -2
- package/src/shared/storage-file-mutex.ts +11 -1
- package/src/shared/system-directive.test.ts +37 -0
- package/src/shared/system-directive.ts +19 -1
- 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-
|
|
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-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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})
|
|
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(
|
|
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})
|
|
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)})
|
|
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
|
|
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,
|
|
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 };
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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.
|
|
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-
|
|
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");
|
|
@@ -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-
|
|
28
|
-
import"./index-
|
|
29
|
-
import"./index-
|
|
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-
|
|
6
|
-
import"./index-
|
|
7
|
-
import"./index-
|
|
8
|
-
import"./index-
|
|
9
|
-
import"./index-
|
|
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-
|
|
11
|
+
import"./index-pte3cfs9.js";
|
|
12
12
|
import"./index-jdxxq8cz.js";
|
|
13
13
|
import"./index-kmbme1v1.js";
|
|
14
14
|
import"./index-5ty9rnbx.js";
|
package/dist/{send-session-notification-njjf3b4s.js → send-session-notification-zpqs213d.js}
RENAMED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
clearIgnoredMessages2,
|
|
5
5
|
observeIgnoredNotificationEvent2,
|
|
6
6
|
sendStatusNotification2
|
|
7
|
-
} from "./index-
|
|
8
|
-
import"./index-
|
|
9
|
-
import"./index-
|
|
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,O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8ID;;;;;;;;;;;;;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 @@
|
|
|
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. */
|