@cortexkit/pi-magic-context 0.49.23 → 0.49.25
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/auto-search-worker.js +4 -4
- package/dist/chunk-embedding-write-worker.js +6 -6
- package/dist/{compartment-chunk-embedding-y01m95c2.js → compartment-chunk-embedding-g9a977b8.js} +3 -3
- package/dist/{embedding-backfill-2vh6m3bg.js → embedding-backfill-qxzjy5v2.js} +5 -5
- package/dist/{index-w1twp2kp.js → index-00c5a49f.js} +1 -1
- package/dist/{index-3c3ztwgc.js → index-0dr64gsy.js} +1 -1
- package/dist/{index-2bx7ge3x.js → index-1g0r4req.js} +35 -35
- package/dist/{index-8976mezv.js → index-23t8ryqw.js} +148 -12
- package/dist/{index-579m1751.js → index-8a2wvrda.js} +1 -1
- package/dist/{index-at6py2k3.js → index-8hmqdav2.js} +5 -1
- package/dist/{index-gqjxy2p7.js → index-cm9e52mb.js} +78 -6
- package/dist/{index-st4gwt64.js → index-cms6wfmd.js} +1 -1
- package/dist/{index-dbgg6hsf.js → index-d53veb5e.js} +4 -4
- package/dist/{index-5j6vwg4z.js → index-fzfpq5bd.js} +32 -22
- package/dist/{index-pe5gz5c4.js → index-nxq2srg9.js} +1 -1
- package/dist/{index-vx6f7wff.js → index-wb2t932e.js} +1 -1
- package/dist/{index-wgmhk91m.js → index-zmg1td73.js} +6 -50
- package/dist/{index-ftvm2acc.js → index-zn2xdbjy.js} +5 -5
- package/dist/index.js +537 -158
- package/dist/{message-fts-rowid-map-59y476bk.js → message-fts-rowid-map-1tb3qjtc.js} +2 -2
- package/dist/{message-index-bounded-4ngt600v.js → message-index-bounded-yj7s7cwz.js} +6 -6
- package/dist/{message-index-3snxf11x.js → message-index-fedjhja5.js} +6 -6
- package/dist/migration-worker.js +5 -5
- package/dist/{project-embedding-registry-hfyzs654.js → project-embedding-registry-9e82qsb6.js} +4 -4
- package/dist/raw-ordinal-warmup-worker.js +6 -6
- package/dist/{read-session-chunk-5dmc77q2.js → read-session-chunk-rndwjfrx.js} +3 -3
- package/dist/{read-session-raw-yxv2fv34.js → read-session-raw-napqv76k.js} +3 -1
- package/dist/{search-jhfh3tsj.js → search-2aa5kzyp.js} +10 -10
- package/dist/{search-archive-3daj5ttc.js → search-archive-qa1sf8hc.js} +4 -4
- package/dist/subagent-entry.js +13 -13
- package/dist/tag-snapshot-worker-pi.js +6 -6
- package/package.json +4 -3
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
recordOpenCodeDbReadFailure,
|
|
56
56
|
clearOpenCodeDbReadFailure,
|
|
57
57
|
claimOpenCodeDbDiagnosticOnce
|
|
58
|
-
} from "./index-
|
|
58
|
+
} from "./index-23t8ryqw.js";
|
|
59
59
|
import {
|
|
60
60
|
prewarmRawSessionOrdinalsForDb,
|
|
61
61
|
readRawSessionMessagesFromDb2,
|
|
@@ -72,7 +72,7 @@ import {
|
|
|
72
72
|
hasRawSessionMessageByIdFromDb2,
|
|
73
73
|
readRawSeedTailFromDb2,
|
|
74
74
|
readRawSessionBoundaryEndpointsFromDb2
|
|
75
|
-
} from "./index-
|
|
75
|
+
} from "./index-8hmqdav2.js";
|
|
76
76
|
import {
|
|
77
77
|
logSlowWriteTransaction
|
|
78
78
|
} from "./index-hqw0rt9k.js";
|
|
@@ -2941,6 +2941,70 @@ function expandToolPart(part, overrides, legacyPreview = false) {
|
|
|
2941
2941
|
return renderToolTemplate(template, input, state?.output ?? state?.error, legacyPreview);
|
|
2942
2942
|
}
|
|
2943
2943
|
|
|
2944
|
+
// ../plugin/src/hooks/magic-context/ask-answer-notice.ts
|
|
2945
|
+
var ANSWER_HEADER_PREFIX = /^Inbox [^\n]* notice from user via user_answer \(user_answer\)/;
|
|
2946
|
+
var ANSWER_TRAILER = /\n([\s\S]*?)\nThis ask is now closed; no dismiss is needed\. Continue accordingly\.$/;
|
|
2947
|
+
var ANSWER_ANSWER_LINE = /^The user answered your parked question (\S+)\.\nQuestion: ([^\n]+)\nAnswer: /;
|
|
2948
|
+
var ANSWER_QUESTION_LINE = /^Question: ([^\n]+)\nAnswer: /;
|
|
2949
|
+
var reminderEnvelopePattern = /<system-reminder>([\s\S]*?)<\/system-reminder>/gi;
|
|
2950
|
+
function reminderBodies(text) {
|
|
2951
|
+
reminderEnvelopePattern.lastIndex = 0;
|
|
2952
|
+
const bodies = [];
|
|
2953
|
+
for (const match of text.matchAll(reminderEnvelopePattern)) {
|
|
2954
|
+
const body = match[1];
|
|
2955
|
+
if (body !== undefined)
|
|
2956
|
+
bodies.push(body);
|
|
2957
|
+
}
|
|
2958
|
+
return bodies;
|
|
2959
|
+
}
|
|
2960
|
+
function parseAnswerBody(body) {
|
|
2961
|
+
const lines = body.replace(/\r\n/g, `
|
|
2962
|
+
`).replace(/^\n+|\n+$/g, "");
|
|
2963
|
+
if (!ANSWER_HEADER_PREFIX.test(lines))
|
|
2964
|
+
return null;
|
|
2965
|
+
if (lines.includes("The user dismissed this question"))
|
|
2966
|
+
return null;
|
|
2967
|
+
const framed = ANSWER_TRAILER.exec(lines);
|
|
2968
|
+
if (framed === null)
|
|
2969
|
+
return null;
|
|
2970
|
+
const content = framed[1] ?? "";
|
|
2971
|
+
const narrated = ANSWER_ANSWER_LINE.exec(content);
|
|
2972
|
+
if (narrated !== null) {
|
|
2973
|
+
const question = narrated[2] ?? "";
|
|
2974
|
+
const answer = content.slice(narrated[0].length);
|
|
2975
|
+
return closedAnswer(question, answer);
|
|
2976
|
+
}
|
|
2977
|
+
const bare = ANSWER_QUESTION_LINE.exec(content);
|
|
2978
|
+
if (bare !== null) {
|
|
2979
|
+
const question = bare[1] ?? "";
|
|
2980
|
+
const answer = content.slice(bare[0].length);
|
|
2981
|
+
return closedAnswer(question, answer);
|
|
2982
|
+
}
|
|
2983
|
+
return null;
|
|
2984
|
+
}
|
|
2985
|
+
function closedAnswer(question, answer) {
|
|
2986
|
+
if (question.trim().length === 0)
|
|
2987
|
+
return null;
|
|
2988
|
+
if (answer.trim().length === 0)
|
|
2989
|
+
return null;
|
|
2990
|
+
return { question, answer };
|
|
2991
|
+
}
|
|
2992
|
+
function extractAskAnswerNotices(text) {
|
|
2993
|
+
const notices = [];
|
|
2994
|
+
for (const body of reminderBodies(text)) {
|
|
2995
|
+
const notice = parseAnswerBody(body);
|
|
2996
|
+
if (notice !== null)
|
|
2997
|
+
notices.push(notice);
|
|
2998
|
+
}
|
|
2999
|
+
return notices;
|
|
3000
|
+
}
|
|
3001
|
+
function formatAskAnswerNotice(notice) {
|
|
3002
|
+
return `U (answered "${notice.question}"): ${notice.answer}`;
|
|
3003
|
+
}
|
|
3004
|
+
function askAnswerLines(text) {
|
|
3005
|
+
return extractAskAnswerNotices(text).map(formatAskAnswerNotice);
|
|
3006
|
+
}
|
|
3007
|
+
|
|
2944
3008
|
// ../plugin/src/hooks/magic-context/host-served-rows.ts
|
|
2945
3009
|
var HOST_UNSERVED_ROW = "hostUnservedRow";
|
|
2946
3010
|
function markHostUnservedRow(target) {
|
|
@@ -4238,6 +4302,9 @@ function withRawMessageProvider2(sessionId, provider, fn) {
|
|
|
4238
4302
|
function cleanUserText2(text) {
|
|
4239
4303
|
return stripOutsideSteeringWrappers(text, (segment) => removeSystemReminders(segment).replace(OMO_INTERNAL_INITIATOR_MARKER, "")).trim();
|
|
4240
4304
|
}
|
|
4305
|
+
function answerLineParts(rawText) {
|
|
4306
|
+
return askAnswerLines(rawText).map(normalizeText).filter((value) => value.length > 0);
|
|
4307
|
+
}
|
|
4241
4308
|
function hasMeaningfulChunkUserText(parts) {
|
|
4242
4309
|
for (const part of parts) {
|
|
4243
4310
|
if (part === null || typeof part !== "object")
|
|
@@ -4254,7 +4321,7 @@ function hasMeaningfulChunkUserText(parts) {
|
|
|
4254
4321
|
continue;
|
|
4255
4322
|
return true;
|
|
4256
4323
|
}
|
|
4257
|
-
return
|
|
4324
|
+
return parts.some((part) => part !== null && typeof part === "object" && part.type === "text" && typeof part.text === "string" && part.ignored !== true && askAnswerLines(part.text).length > 0);
|
|
4258
4325
|
}
|
|
4259
4326
|
function withRawSessionMessageCache2(fn) {
|
|
4260
4327
|
const outerCache = activeRawMessageCache;
|
|
@@ -5008,8 +5075,10 @@ function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdina
|
|
|
5008
5075
|
}
|
|
5009
5076
|
const role = compactRole(msg.role);
|
|
5010
5077
|
const textParts = extractTexts2(msg.parts).map((t) => msg.role === "user" ? cleanUserText2(t) : t).map(normalizeText).filter((value) => value.length > 0);
|
|
5078
|
+
const answerParts = msg.role === "user" ? extractTexts2(msg.parts).flatMap((text) => answerLineParts(text)) : [];
|
|
5079
|
+
const userParts = answerParts.length > 0 ? [...textParts, ...answerParts] : textParts;
|
|
5011
5080
|
const allParts = options.expand === false ? [
|
|
5012
|
-
...
|
|
5081
|
+
...userParts,
|
|
5013
5082
|
...textParts.length === 0 ? extractToolCallSummaries(msg.parts) : []
|
|
5014
5083
|
] : msg.parts.flatMap((part) => {
|
|
5015
5084
|
if (expandedResults.has(part))
|
|
@@ -5018,6 +5087,9 @@ function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdina
|
|
|
5018
5087
|
if (expansion !== null)
|
|
5019
5088
|
return [`TC: ${expansion}`];
|
|
5020
5089
|
const texts = extractTexts2([part]).map((t) => msg.role === "user" ? cleanUserText2(t) : t).map(normalizeText).filter(Boolean);
|
|
5090
|
+
if (msg.role === "user") {
|
|
5091
|
+
texts.push(...extractTexts2([part]).flatMap((text) => answerLineParts(text)));
|
|
5092
|
+
}
|
|
5021
5093
|
return texts.length ? texts : textParts.length === 0 ? extractToolCallSummaries([part]) : [];
|
|
5022
5094
|
});
|
|
5023
5095
|
const compacted = compactTextForSummary(allParts.join(" / "), msg.role);
|
|
@@ -5026,7 +5098,7 @@ function readSessionChunk2(sessionId, tokenBudget, offset = 1, eligibleEndOrdina
|
|
|
5026
5098
|
recordFilteredNoise(meta);
|
|
5027
5099
|
continue;
|
|
5028
5100
|
}
|
|
5029
|
-
const msgHasNarrative =
|
|
5101
|
+
const msgHasNarrative = userParts.length > 0;
|
|
5030
5102
|
if (currentBlock && currentBlock.role === role) {
|
|
5031
5103
|
currentBlock.endOrdinal = msg.ordinal;
|
|
5032
5104
|
currentBlock.parts.push(text);
|
|
@@ -5128,4 +5200,4 @@ function readRawSessionSeedTail2(sessionId, boundaryId, onQuery) {
|
|
|
5128
5200
|
});
|
|
5129
5201
|
}
|
|
5130
5202
|
|
|
5131
|
-
export { detectThinkingBindingMismatch, detectLatestTurnThinkingMismatch, isPrefixBoundThinkingModel, detectOverflow, MAX_EXECUTE_THRESHOLD, escalationBands, MERGED_REASONING_PARTS_PREFIX, decodeMergedReasoningParts, HYGIENE_PROVIDER_UNITS_VERSION, sessionDecisionCalibration, transitionSessionHygieneUnits, computeProtectionWindow, readEpochFloorSnapshot, getProtectionWindowForSession, SESSION_META_SELECT_COLUMNS, META_COLUMNS, BOOLEAN_META_KEYS, NULL_BIND_META_KEYS, isSessionMetaRow, getDefaultSessionMeta, ensureSessionMetaRow, toSessionMeta, persistCachedM0, clearCachedM0M1, isRustMarkerAdmissionFenced, ReplayDocumentError, readReplayEnvelope, readReplayDocument, updateReplayDocument, writeReplayDocument, isProviderOverflowFailClosedProven, getEmergencyRecoveryArmedAt, describeProtectedTailDrainBudgetSkip, loadProtectedTailMeta, markProtectedTailPolicyV3Seeded, recordProtectedTailPublicationFloor, recordProtectedTailNoEligibleHead, getWrapupInProgressState, isWrapupInProgress, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, EMERGENCY_DRAIN_FAILURE_BACKOFF_MS, getProtectedTailDrainBudgetSkip, reserveProtectedTailDrainTokens, clearEmergencyDrainLatch, recordHistorianDrainFailure, clearHistorianDrainFailure, rollbackProtectedTailDrainReservation, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, setPersistedNoteNudgeTrigger, setPersistedNoteNudgeTriggerMessageId, getNoteNudgeAnchors, getAutoSearchHintDecisions, deliverNoteNudgeAtomic, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, queueAutoSearchHintDecisionRetirement, flushAutoSearchHintDecisionRetirement, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, getNoteLastReadAt, setNoteLastReadAt, getHistorianFailureState, incrementHistorianFailure, clearHistorianFailureState, getOverflowState, recordOverflowDetected, clearEmergencyRecovery, clearDetectedContextLimit, getPersistedCompactionMarkerState, setPersistedCompactionMarkerState, parseStrippedPlaceholderState, serializeStrippedPlaceholderState, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, THINKING_BINDING_STRIP_ORDER_END_MARKER, thinkingBindingRecoveryFrozenId, COMPACTION_OFF_THINKING_FROZEN_PREFIX, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getProcessedImageStrippedIds, parseProcessedImageMarkers, serializeProcessedImageMarkers, addProcessedImageStrippedIds, getPendingCompactionMarkerState, getCompactionMarkerHealth, loadPostprocessReplaySnapshot, clearPendingCompactionMarkerStateIf, getPendingPiCompactionMarkerState, setPendingPiCompactionMarkerState, clearPendingPiCompactionMarkerStateIf, logPiCompactionMarkerClear, getSessionsWithPendingPiMarker, setSessionWorkMetrics, getSessionWorkMetrics, resolveEpochFloorForPass, withReadOnlySessionDb, expandToolPart, retreatPastHostUnservedRows, isCoveredInstructionRow, completedToolArcCrossesBoundary, estimateTrueRawMessageTokens, buildToolArcs, fenceBoundaryForCompletedToolArcs, fenceBoundaryForToolArcs, buildTrueRawTokenIndex, computeRawRangeFingerprint, invalidateTrueRawTokenCache, stripSystemInjection, isFilePart, hasUserAnswerMetadata, DreamTokenBudgetExceeded, TOKEN_BUDGET_FINALIZE_MESSAGE, TOKEN_BUDGET_TOOL_REFUSAL, registerBudgetFinalizeChild, releaseBudgetFinalizeChild, createDreamTokenBudget, droppedInputMarker, createDroppedInputGuard, isEditTool, applyEditMarkerToInput, modelAcceptsEmptyContent, isAnthropicFamilyRoute, variantChangeBustsProviderCache, isInActiveAnthropicTurn, activeAnthropicTurnStart, hasAnthropicReasoning, findLatestAssistantReasoningMutationExemptMessage, DEFAULT_KEEP_REASONING_TOKENS, resolveKeepReasoningTokens, reasoningStepCost, reasoningBudgetCutoff, reasoningTextAndOpaque, opaqueThinkingCost, estimatePartImageTokens, SKELETON_REAL_INPUT_MAX_BYTES, toolInputStringBytes, resolveHostServedBoundaryId2, hasRawMessageProvider2, setRawMessageProvider2, setBoundedRawMessageProvider2, withRawMessageProvider2, cleanUserText2, withRawSessionMessageCache2, readRawSessionMessages2, readRawSessionMessagePage2, getRawSessionMessageOrdinalCount2, RAW_MESSAGE_VISIT_PAGE_SIZE2, visitRawSessionMessages2, visitRawSessionMessagesAsync2, readRawSessionMessageRange2, prepareRawSessionOrdinals2, primeTailRawMessageCache2, getCachedAbsoluteMessageCount2, primeInMemoryTailRawMessageCache2, readRawSessionMessageOrdinalPage2, getRawSessionStoredMessageCount2, readRawSessionMessageIdOrdinalsForRange2, readRawSessionMessageIdOrdinals2, readRawSessionMessagePartsById2, readRawSessionBoundaryEndpoints2, hasRawSessionMessageById2, readRawSessionMessageOrdinalById2, compareRawSessionMessageOrder2, readRawSessionMessageById2, getRawSessionMessageCount2, RAW_SESSION_TAG_KEY_PAGE_SIZE2, getRawSessionTagKeysThrough2, getLegacyProtectedTailStartOrdinal2, getProtectedTailStartOrdinal2, readSessionChunk2, getRawSessionMessageIdsThrough2, readRawSessionSeedTail2 };
|
|
5203
|
+
export { detectThinkingBindingMismatch, detectLatestTurnThinkingMismatch, isPrefixBoundThinkingModel, detectOverflow, MAX_EXECUTE_THRESHOLD, escalationBands, MERGED_REASONING_PARTS_PREFIX, decodeMergedReasoningParts, HYGIENE_PROVIDER_UNITS_VERSION, sessionDecisionCalibration, transitionSessionHygieneUnits, computeProtectionWindow, readEpochFloorSnapshot, getProtectionWindowForSession, SESSION_META_SELECT_COLUMNS, META_COLUMNS, BOOLEAN_META_KEYS, NULL_BIND_META_KEYS, isSessionMetaRow, getDefaultSessionMeta, ensureSessionMetaRow, toSessionMeta, persistCachedM0, clearCachedM0M1, isRustMarkerAdmissionFenced, ReplayDocumentError, readReplayEnvelope, readReplayDocument, updateReplayDocument, writeReplayDocument, isProviderOverflowFailClosedProven, getEmergencyRecoveryArmedAt, describeProtectedTailDrainBudgetSkip, loadProtectedTailMeta, markProtectedTailPolicyV3Seeded, recordProtectedTailPublicationFloor, recordProtectedTailNoEligibleHead, getWrapupInProgressState, isWrapupInProgress, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, EMERGENCY_DRAIN_FAILURE_BACKOFF_MS, getProtectedTailDrainBudgetSkip, reserveProtectedTailDrainTokens, clearEmergencyDrainLatch, recordHistorianDrainFailure, clearHistorianDrainFailure, rollbackProtectedTailDrainReservation, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, setPersistedNoteNudgeTrigger, setPersistedNoteNudgeTriggerMessageId, getNoteNudgeAnchors, getAutoSearchHintDecisions, deliverNoteNudgeAtomic, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, queueAutoSearchHintDecisionRetirement, flushAutoSearchHintDecisionRetirement, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, getNoteLastReadAt, setNoteLastReadAt, getHistorianFailureState, incrementHistorianFailure, clearHistorianFailureState, getOverflowState, recordOverflowDetected, clearEmergencyRecovery, clearDetectedContextLimit, getPersistedCompactionMarkerState, setPersistedCompactionMarkerState, parseStrippedPlaceholderState, serializeStrippedPlaceholderState, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, THINKING_BINDING_STRIP_ORDER_END_MARKER, thinkingBindingRecoveryFrozenId, COMPACTION_OFF_THINKING_FROZEN_PREFIX, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getProcessedImageStrippedIds, parseProcessedImageMarkers, serializeProcessedImageMarkers, addProcessedImageStrippedIds, getPendingCompactionMarkerState, getCompactionMarkerHealth, loadPostprocessReplaySnapshot, clearPendingCompactionMarkerStateIf, getPendingPiCompactionMarkerState, setPendingPiCompactionMarkerState, clearPendingPiCompactionMarkerStateIf, logPiCompactionMarkerClear, getSessionsWithPendingPiMarker, setSessionWorkMetrics, getSessionWorkMetrics, resolveEpochFloorForPass, withReadOnlySessionDb, expandToolPart, askAnswerLines, retreatPastHostUnservedRows, isCoveredInstructionRow, completedToolArcCrossesBoundary, estimateTrueRawMessageTokens, buildToolArcs, fenceBoundaryForCompletedToolArcs, fenceBoundaryForToolArcs, buildTrueRawTokenIndex, computeRawRangeFingerprint, invalidateTrueRawTokenCache, stripSystemInjection, isFilePart, hasUserAnswerMetadata, DreamTokenBudgetExceeded, TOKEN_BUDGET_FINALIZE_MESSAGE, TOKEN_BUDGET_TOOL_REFUSAL, registerBudgetFinalizeChild, releaseBudgetFinalizeChild, createDreamTokenBudget, droppedInputMarker, createDroppedInputGuard, isEditTool, applyEditMarkerToInput, modelAcceptsEmptyContent, isAnthropicFamilyRoute, variantChangeBustsProviderCache, isInActiveAnthropicTurn, activeAnthropicTurnStart, hasAnthropicReasoning, findLatestAssistantReasoningMutationExemptMessage, DEFAULT_KEEP_REASONING_TOKENS, resolveKeepReasoningTokens, reasoningStepCost, reasoningBudgetCutoff, reasoningTextAndOpaque, opaqueThinkingCost, estimatePartImageTokens, SKELETON_REAL_INPUT_MAX_BYTES, toolInputStringBytes, resolveHostServedBoundaryId2, hasRawMessageProvider2, setRawMessageProvider2, setBoundedRawMessageProvider2, withRawMessageProvider2, cleanUserText2, withRawSessionMessageCache2, readRawSessionMessages2, readRawSessionMessagePage2, getRawSessionMessageOrdinalCount2, RAW_MESSAGE_VISIT_PAGE_SIZE2, visitRawSessionMessages2, visitRawSessionMessagesAsync2, readRawSessionMessageRange2, prepareRawSessionOrdinals2, primeTailRawMessageCache2, getCachedAbsoluteMessageCount2, primeInMemoryTailRawMessageCache2, readRawSessionMessageOrdinalPage2, getRawSessionStoredMessageCount2, readRawSessionMessageIdOrdinalsForRange2, readRawSessionMessageIdOrdinals2, readRawSessionMessagePartsById2, readRawSessionBoundaryEndpoints2, hasRawSessionMessageById2, readRawSessionMessageOrdinalById2, compareRawSessionMessageOrder2, readRawSessionMessageById2, getRawSessionMessageCount2, RAW_SESSION_TAG_KEY_PAGE_SIZE2, getRawSessionTagKeysThrough2, getLegacyProtectedTailStartOrdinal2, getProtectedTailStartOrdinal2, readSessionChunk2, getRawSessionMessageIdsThrough2, readRawSessionSeedTail2 };
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
} from "./index-fapenpch.js";
|
|
43
43
|
import {
|
|
44
44
|
startMessageFtsRowidMapBackfill2
|
|
45
|
-
} from "./index-
|
|
45
|
+
} from "./index-8a2wvrda.js";
|
|
46
46
|
import {
|
|
47
47
|
LKG_SLOT_CHUNKS_DDL,
|
|
48
48
|
SESSION_REPLAY_DECISIONS_DDL,
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
hasPendingMigrations,
|
|
53
53
|
getMainThreadMigrationBodyCount,
|
|
54
54
|
runMigrations
|
|
55
|
-
} from "./index-
|
|
55
|
+
} from "./index-0dr64gsy.js";
|
|
56
56
|
import {
|
|
57
57
|
closeQuietly,
|
|
58
58
|
ensureColumn,
|
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
hasV1MessageTables,
|
|
65
65
|
setDatabase,
|
|
66
66
|
loadToolDefinitionMeasurements
|
|
67
|
-
} from "./index-
|
|
67
|
+
} from "./index-23t8ryqw.js";
|
|
68
68
|
import {
|
|
69
69
|
logSlowWriteTransaction
|
|
70
70
|
} from "./index-hqw0rt9k.js";
|
|
@@ -1307,7 +1307,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1307
1307
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1308
1308
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1309
1309
|
return;
|
|
1310
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1310
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-rndwjfrx.js"));
|
|
1311
1311
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-e3r8ddh1.js"));
|
|
1312
1312
|
if (signal.aborted)
|
|
1313
1313
|
return;
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./index-2qtx0q6h.js";
|
|
16
16
|
import {
|
|
17
17
|
createFailClosedBlockingError
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-d53veb5e.js";
|
|
19
19
|
import {
|
|
20
20
|
createWorkerShutdown
|
|
21
21
|
} from "./index-54wmg4rj.js";
|
|
@@ -407,7 +407,7 @@ function startPiTagSnapshotWorker(request, options = {}) {
|
|
|
407
407
|
reject(new PiTagHydrationError(`worker exited with code ${code} before a clean complete result`));
|
|
408
408
|
});
|
|
409
409
|
});
|
|
410
|
-
function abort(error = new PiTagHydrationError("cancelled")) {
|
|
410
|
+
function abort(error = new PiTagHydrationError("cancelled", "cancelled")) {
|
|
411
411
|
if (settled)
|
|
412
412
|
return;
|
|
413
413
|
settled = true;
|
|
@@ -535,9 +535,9 @@ function createPiTagSnapshotReader(db) {
|
|
|
535
535
|
const managed = new Set;
|
|
536
536
|
const epoch = ++connectionEpoch;
|
|
537
537
|
const sessionEpochs = new Map;
|
|
538
|
+
let closed = false;
|
|
538
539
|
let jobId = 0;
|
|
539
540
|
let current;
|
|
540
|
-
let desiredSession;
|
|
541
541
|
let failedUntil = 0;
|
|
542
542
|
let lastFailure;
|
|
543
543
|
let failedSession;
|
|
@@ -580,24 +580,30 @@ function createPiTagSnapshotReader(db) {
|
|
|
580
580
|
};
|
|
581
581
|
const cancel = (sessionId) => {
|
|
582
582
|
sessionEpochs.set(sessionId, (sessionEpochs.get(sessionId) ?? 0) + 1);
|
|
583
|
-
if (desiredSession === sessionId)
|
|
584
|
-
desiredSession = undefined;
|
|
585
583
|
if (current?.sessionId === sessionId)
|
|
586
584
|
current.cancel();
|
|
587
585
|
};
|
|
588
|
-
const load = (sessionId) => inSnapshotRoot(async () => {
|
|
586
|
+
const load = (sessionId, kind) => inSnapshotRoot(async () => {
|
|
587
|
+
if (closed)
|
|
588
|
+
throw new PiTagHydrationError("connection closed");
|
|
589
589
|
managed.add(sessionId);
|
|
590
590
|
if (ready(sessionId))
|
|
591
591
|
return;
|
|
592
|
-
desiredSession = sessionId;
|
|
593
592
|
if (current) {
|
|
594
|
-
if (current.sessionId === sessionId && !current.
|
|
593
|
+
if (current.sessionId === sessionId && !current.retryable && !current.preempted) {
|
|
594
|
+
if (kind === "turn")
|
|
595
|
+
current.kind = "turn";
|
|
595
596
|
return current.result;
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
597
|
+
}
|
|
598
|
+
if (kind === "turn" && current.kind === "prewarm" && current.sessionId !== sessionId && !current.preempted) {
|
|
599
|
+
current.preempted = true;
|
|
600
|
+
current.cancel();
|
|
601
|
+
}
|
|
602
|
+
const epoch = sessionEpochs.get(sessionId) ?? 0;
|
|
603
|
+
await Promise.allSettled([current.result, current.released]);
|
|
604
|
+
if (epoch !== (sessionEpochs.get(sessionId) ?? 0))
|
|
605
|
+
throw new PiTagHydrationError("session hydration cancelled while queued", "cancelled");
|
|
606
|
+
return load(sessionId, kind);
|
|
601
607
|
}
|
|
602
608
|
if (failedSession === sessionId && performance.now() < failedUntil)
|
|
603
609
|
throw lastFailure;
|
|
@@ -620,6 +626,7 @@ function createPiTagSnapshotReader(db) {
|
|
|
620
626
|
}, previous?.tags ?? []);
|
|
621
627
|
const destination = {
|
|
622
628
|
sessionId,
|
|
629
|
+
kind,
|
|
623
630
|
result: Promise.resolve(),
|
|
624
631
|
released: worker.released,
|
|
625
632
|
cancel: worker.cancel
|
|
@@ -639,8 +646,10 @@ function createPiTagSnapshotReader(db) {
|
|
|
639
646
|
};
|
|
640
647
|
jobs.add(lifetime);
|
|
641
648
|
destination.result = worker.result.then(({ candidate, generation }) => {
|
|
649
|
+
if (destination.preempted)
|
|
650
|
+
throw new PiTagHydrationError("prewarm yielded to a turn", "cancelled");
|
|
642
651
|
const live = stamps(sessionId, token.jobId);
|
|
643
|
-
if (
|
|
652
|
+
if (closed || current !== destination || !samePiTagSnapshotToken(token, live) || token.totalRevision !== live.totalRevision || generation.revision !== token.totalRevision || generation.durable !== token.durableVersion)
|
|
644
653
|
throw new PiTagHydrationError("owner generation or lifetime changed", "stale");
|
|
645
654
|
const snapshot = {
|
|
646
655
|
firstAllocationPending: live.revisionPresent ? undefined : candidate.tags.length === 0 && !db.prepare("SELECT 1 FROM tags WHERE session_id = ? LIMIT 1").get(sessionId) ? "empty" : "legacy",
|
|
@@ -669,12 +678,13 @@ function createPiTagSnapshotReader(db) {
|
|
|
669
678
|
}
|
|
670
679
|
cache.set(sessionId, snapshot);
|
|
671
680
|
}).catch((error) => {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
681
|
+
const retryable = error instanceof PiTagHydrationError && (error.code === "stale" || error.code === "cancelled");
|
|
682
|
+
if (retryable)
|
|
683
|
+
destination.retryable = true;
|
|
684
|
+
if (!destination.preempted && current === destination && token.sessionEpoch === (sessionEpochs.get(sessionId) ?? 0)) {
|
|
675
685
|
failedSession = sessionId;
|
|
676
686
|
lastFailure = error;
|
|
677
|
-
failedUntil = performance.now() + (
|
|
687
|
+
failedUntil = performance.now() + (retryable ? 0 : 500);
|
|
678
688
|
}
|
|
679
689
|
throw error;
|
|
680
690
|
});
|
|
@@ -795,7 +805,7 @@ function createPiTagSnapshotReader(db) {
|
|
|
795
805
|
configurable: true,
|
|
796
806
|
writable: true,
|
|
797
807
|
value: (...args) => {
|
|
798
|
-
|
|
808
|
+
closed = true;
|
|
799
809
|
nativeWaiters.clear();
|
|
800
810
|
current?.cancel();
|
|
801
811
|
cache.clear();
|
|
@@ -979,7 +989,7 @@ var activeJobs = new Map;
|
|
|
979
989
|
var waitDeadlines = new WeakMap;
|
|
980
990
|
function prewarmPiTagSnapshot(db, sessionId) {
|
|
981
991
|
createPiTagSnapshotReader(db);
|
|
982
|
-
owners.get(db)?.load(sessionId).catch(() => {});
|
|
992
|
+
owners.get(db)?.load(sessionId, "prewarm").catch(() => {});
|
|
983
993
|
}
|
|
984
994
|
function cancelPiTagSnapshotSession(sessionId) {
|
|
985
995
|
for (const job of activeJobs.get(sessionId) ?? [])
|
|
@@ -1023,7 +1033,7 @@ function ensurePiTagSnapshotReady(db, sessionId, budget) {
|
|
|
1023
1033
|
const releaseNativeWaiter = owner.addNativeWaiter(() => budget.remainingOutcome() - PI_CONTEXT_BUDGET.completionReserveMs);
|
|
1024
1034
|
try {
|
|
1025
1035
|
await budget.wait(Promise.race([
|
|
1026
|
-
owner.load(sessionId),
|
|
1036
|
+
owner.load(sessionId, "turn"),
|
|
1027
1037
|
new Promise((_, reject) => {
|
|
1028
1038
|
timer = setTimeout(() => reject(new PiTagHydrationError("remaining pass budget exhausted waiting for tag snapshot; turn not sent, retry", "deadline")), allowance);
|
|
1029
1039
|
})
|
|
@@ -1033,7 +1043,7 @@ function ensurePiTagSnapshotReady(db, sessionId, budget) {
|
|
|
1033
1043
|
return;
|
|
1034
1044
|
} catch (error) {
|
|
1035
1045
|
budget.assert();
|
|
1036
|
-
if (!(error instanceof PiTagHydrationError && error.code === "stale"))
|
|
1046
|
+
if (!(error instanceof PiTagHydrationError && (error.code === "stale" || error.code === "cancelled")))
|
|
1037
1047
|
throw error;
|
|
1038
1048
|
} finally {
|
|
1039
1049
|
clearTimeout(timer);
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "./index-gwxaz0z5.js";
|
|
14
14
|
import {
|
|
15
15
|
messageFtsOrdinalRangeIsMapped2
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-8a2wvrda.js";
|
|
17
17
|
|
|
18
18
|
// ../plugin/src/features/magic-context/compartment-chunk-embedding.ts
|
|
19
19
|
import { createHash } from "node:crypto";
|
|
@@ -9,9 +9,10 @@ import {
|
|
|
9
9
|
readProcessStartTime
|
|
10
10
|
} from "./index-n4wyxcgr.js";
|
|
11
11
|
import {
|
|
12
|
+
BoundedSessionMap,
|
|
12
13
|
resolveOpenCodeDbPath,
|
|
13
14
|
assertOpenCodeStoreGeneration
|
|
14
|
-
} from "./index-
|
|
15
|
+
} from "./index-23t8ryqw.js";
|
|
15
16
|
import {
|
|
16
17
|
Database2,
|
|
17
18
|
getSqliteDatabasePath2,
|
|
@@ -31,10 +32,10 @@ import {
|
|
|
31
32
|
messageFtsOrdinalRangeIsMapped2,
|
|
32
33
|
getMessageFtsRowidMapBackfillProgress2,
|
|
33
34
|
deleteUnmappedMessageFtsRows2
|
|
34
|
-
} from "./index-
|
|
35
|
+
} from "./index-8a2wvrda.js";
|
|
35
36
|
import {
|
|
36
37
|
deleteChunkEmbedBackoffForSession2
|
|
37
|
-
} from "./index-
|
|
38
|
+
} from "./index-wb2t932e.js";
|
|
38
39
|
import {
|
|
39
40
|
closeQuietly,
|
|
40
41
|
TAG_TOMBSTONE_OWNER_PREFIX,
|
|
@@ -46,7 +47,7 @@ import {
|
|
|
46
47
|
} from "./index-w1avzkdt.js";
|
|
47
48
|
import {
|
|
48
49
|
cleanUserText2
|
|
49
|
-
} from "./index-
|
|
50
|
+
} from "./index-cm9e52mb.js";
|
|
50
51
|
import {
|
|
51
52
|
sameProjectDirectory
|
|
52
53
|
} from "./index-wrr9rp9a.js";
|
|
@@ -73,51 +74,6 @@ import {
|
|
|
73
74
|
} from "node:fs";
|
|
74
75
|
import { basename, dirname, join as join2 } from "node:path";
|
|
75
76
|
|
|
76
|
-
// ../plugin/src/shared/bounded-session-map.ts
|
|
77
|
-
class BoundedSessionMap {
|
|
78
|
-
maxEntries;
|
|
79
|
-
store = new Map;
|
|
80
|
-
constructor(maxEntries) {
|
|
81
|
-
if (!Number.isFinite(maxEntries) || maxEntries < 1) {
|
|
82
|
-
throw new Error(`BoundedSessionMap: maxEntries must be >= 1, got ${maxEntries}`);
|
|
83
|
-
}
|
|
84
|
-
this.maxEntries = maxEntries;
|
|
85
|
-
}
|
|
86
|
-
get(sessionId) {
|
|
87
|
-
const value = this.store.get(sessionId);
|
|
88
|
-
if (value === undefined)
|
|
89
|
-
return;
|
|
90
|
-
this.store.delete(sessionId);
|
|
91
|
-
this.store.set(sessionId, value);
|
|
92
|
-
return value;
|
|
93
|
-
}
|
|
94
|
-
peek(sessionId) {
|
|
95
|
-
return this.store.get(sessionId);
|
|
96
|
-
}
|
|
97
|
-
has(sessionId) {
|
|
98
|
-
return this.store.has(sessionId);
|
|
99
|
-
}
|
|
100
|
-
set(sessionId, value) {
|
|
101
|
-
if (this.store.has(sessionId)) {
|
|
102
|
-
this.store.delete(sessionId);
|
|
103
|
-
} else if (this.store.size >= this.maxEntries) {
|
|
104
|
-
const oldest = this.store.keys().next().value;
|
|
105
|
-
if (oldest !== undefined)
|
|
106
|
-
this.store.delete(oldest);
|
|
107
|
-
}
|
|
108
|
-
this.store.set(sessionId, value);
|
|
109
|
-
}
|
|
110
|
-
delete(sessionId) {
|
|
111
|
-
return this.store.delete(sessionId);
|
|
112
|
-
}
|
|
113
|
-
clear() {
|
|
114
|
-
this.store.clear();
|
|
115
|
-
}
|
|
116
|
-
get size() {
|
|
117
|
-
return this.store.size;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
77
|
// ../plugin/src/shared/storage-file-mutex.ts
|
|
122
78
|
import { execFileSync } from "node:child_process";
|
|
123
79
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -2141,4 +2097,4 @@ async function sweepOrphanedOpenCodeMessageIndexesCooperatively2(db, openSource,
|
|
|
2141
2097
|
}));
|
|
2142
2098
|
}
|
|
2143
2099
|
|
|
2144
|
-
export {
|
|
2100
|
+
export { LkgRecoveryFenceError, clearLkgFenceProcessState, takeLkgRecoveryLockSweepPage, lkgFenceRequiresRebuild, lkgRecoveryFenceUnclean, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, markLkgRecoveryDirty, commitLkgWithRecoveryFence, clearLkgRecoveryFence, gaDatabasePath, V2StoreReader, readSessionActivity, observeSessionActivity, backfillSessionActivity, deleteSessionScopedRows, clearCompressionDepth, clearCompressionDepthRange, cleanSearchText, keywordRelevance, matchedSearchSnippet, MESSAGE_INDEX_MAX_FTS_BYTES2, messageIndexSkipKey2, toMessageIndexSource2, getMessageIndexSourceIdentity2, isMessageIndexSourceCurrent2, getLastIndexedOrdinal2, getIndexedMessageCorpusSize2, markMessageIndexDirty2, getMessageIndexReconciliationStartOrdinal2, isMessageIndexReconciledThrough2, deleteIndexedMessage2, clearIndexedMessagesInTransaction2, clearIndexedMessages2, getIndexableContent2, indexSingleMessage2, indexMessagesAfterOrdinal2, indexSourcesAfterOrdinal2, sweepOrphanedOpenCodeMessageIndexesCooperatively2 };
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveStoredPathWorkspaceIdentity,
|
|
23
23
|
sourceNameForMemory,
|
|
24
24
|
managedAuthorityNoteRow
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-0dr64gsy.js";
|
|
26
26
|
import {
|
|
27
27
|
isKnownAutocommit
|
|
28
28
|
} from "./index-w1avzkdt.js";
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
loadCompartmentChunkEmbeddingsForSearch2,
|
|
35
35
|
peekCompartmentChunkSearchPool2,
|
|
36
36
|
warmCompartmentChunkSearchPool2
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-wb2t932e.js";
|
|
38
38
|
import {
|
|
39
39
|
recordEmbeddingMeasurement,
|
|
40
40
|
saveCommitEmbedding,
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
getProjectEmbeddingSnapshot2,
|
|
53
53
|
embedTextForProject2,
|
|
54
54
|
embedItemsForProject2
|
|
55
|
-
} from "./index-
|
|
55
|
+
} from "./index-00c5a49f.js";
|
|
56
56
|
import {
|
|
57
57
|
saveEmbeddingIfHashMatches,
|
|
58
58
|
getProjectEmbeddings2
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
isEmbeddingEnabled,
|
|
63
63
|
embedText,
|
|
64
64
|
ensureMemoryEmbeddings2
|
|
65
|
-
} from "./index-
|
|
65
|
+
} from "./index-nxq2srg9.js";
|
|
66
66
|
import {
|
|
67
67
|
getMemorySelectColumns2,
|
|
68
68
|
isMemoryRow2,
|
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
keywordRelevance,
|
|
83
83
|
matchedSearchSnippet,
|
|
84
84
|
getIndexedMessageCorpusSize2
|
|
85
|
-
} from "./index-
|
|
85
|
+
} from "./index-zmg1td73.js";
|
|
86
86
|
import {
|
|
87
87
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
88
88
|
withMessageFtsSessionFilter
|