@cortexkit/pi-magic-context 0.49.12 → 0.49.14
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 +3 -3
- package/dist/chunk-embedding-write-worker.js +87 -0
- package/dist/{embedding-backfill-14tqcfrn.js → embedding-backfill-7kj16fh9.js} +5 -4
- package/dist/embedding-worker.js +1 -1
- package/dist/historian-calibration-extension.js +1 -1
- package/dist/{index-gykw2zhn.js → index-0awvkeb5.js} +5 -5
- package/dist/index-1mrvw9en.js +225 -0
- package/dist/index-1vw4f2pe.js +907 -0
- package/dist/{index-zapgkmp7.js → index-65kty5te.js} +37 -48
- package/dist/{index-53xdqb3d.js → index-75ah9413.js} +1 -1
- package/dist/{index-af9nb5db.js → index-7qc73yk5.js} +60 -3
- package/dist/{index-xpsht877.js → index-7wagp5jp.js} +2 -2
- package/dist/{index-6hex51s9.js → index-a4pk5yv9.js} +2 -2
- package/dist/{index-z5ftst3e.js → index-ccsscaap.js} +3 -3
- package/dist/{index-ed9d2ded.js → index-j0n09wtp.js} +4 -1
- package/dist/{index-f6e8jsrh.js → index-nwbhe6qv.js} +188 -241
- package/dist/{index-xmdkde4v.js → index-y29y2j2w.js} +12 -1
- package/dist/index.js +2398 -2068
- package/dist/{message-index-bounded-ws37m1nt.js → message-index-bounded-z4d3x9ty.js} +4 -4
- package/dist/{message-index-dfs6k35a.js → message-index-dw4z9efj.js} +4 -4
- package/dist/migration-worker.js +2 -2
- package/dist/{project-embedding-registry-ymvne11v.js → project-embedding-registry-52zwmtbn.js} +4 -3
- package/dist/raw-ordinal-warmup-worker.js +3 -3
- package/dist/{read-session-chunk-83864b37.js → read-session-chunk-0fsgg2k1.js} +2 -2
- package/dist/{search-85e21wb8.js → search-ddbz6v60.js} +12 -11
- package/dist/{storage-tags-zmf30zqp.js → storage-tags-3kb5tvgg.js} +3 -1
- package/dist/subagent-entry.js +12 -11
- package/dist/tag-snapshot-worker-pi.js +235 -0
- package/package.json +3 -3
- /package/dist/{index-j24916mq.js → index-9jvktm7k.js} +0 -0
- /package/dist/{index-69vas84q.js → index-b7p25tm0.js} +0 -0
- /package/dist/{index-3cnarwf8.js → index-bet4sd3e.js} +0 -0
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
readRawSessionMessageIdOrdinalsForRange2,
|
|
57
57
|
readRawSessionMessageById2,
|
|
58
58
|
readSessionChunk2
|
|
59
|
-
} from "./index-
|
|
59
|
+
} from "./index-75ah9413.js";
|
|
60
60
|
import {
|
|
61
61
|
isRecord,
|
|
62
62
|
providerVisibleMessage,
|
|
@@ -70,7 +70,7 @@ import {
|
|
|
70
70
|
getTagNumberByMessageId2,
|
|
71
71
|
getTagsBySession2,
|
|
72
72
|
getTagById2
|
|
73
|
-
} from "./index-
|
|
73
|
+
} from "./index-j0n09wtp.js";
|
|
74
74
|
import {
|
|
75
75
|
estimateTokens
|
|
76
76
|
} from "./index-g4jf772p.js";
|
|
@@ -103,7 +103,7 @@ import {
|
|
|
103
103
|
clearLkgRecoveryFence,
|
|
104
104
|
deleteSessionScopedRows,
|
|
105
105
|
getLastIndexedOrdinal2
|
|
106
|
-
} from "./index-
|
|
106
|
+
} from "./index-a4pk5yv9.js";
|
|
107
107
|
import {
|
|
108
108
|
SubcClient,
|
|
109
109
|
connectionFileExists,
|
|
@@ -114,9 +114,22 @@ import {
|
|
|
114
114
|
import {
|
|
115
115
|
sameProjectDirectory
|
|
116
116
|
} from "./index-djxc8w8c.js";
|
|
117
|
+
import {
|
|
118
|
+
invalidateAutoEmbedSession,
|
|
119
|
+
drainBackgroundBatches,
|
|
120
|
+
markProjectLoadUntrusted2,
|
|
121
|
+
drainProjectEmbeddingIdentityMaintenance2,
|
|
122
|
+
registerProjectEmbedding2,
|
|
123
|
+
registerProjectShadowEmbedding2,
|
|
124
|
+
registerProjectInObservationMode2,
|
|
125
|
+
unregisterProjectShadowEmbedding2,
|
|
126
|
+
unregisterProjectEmbedding2,
|
|
127
|
+
getProjectEmbeddingSnapshot2,
|
|
128
|
+
embedTextForProject2
|
|
129
|
+
} from "./index-nwbhe6qv.js";
|
|
117
130
|
import {
|
|
118
131
|
getErrorMessage
|
|
119
|
-
} from "./index-
|
|
132
|
+
} from "./index-ccsscaap.js";
|
|
120
133
|
import {
|
|
121
134
|
V2_MEMORY_CATEGORIES,
|
|
122
135
|
CATEGORY_PRIORITY,
|
|
@@ -130,25 +143,13 @@ import {
|
|
|
130
143
|
expandWorkspaceIdentitySetWithAliases,
|
|
131
144
|
resolveStoredPathWorkspaceIdentity,
|
|
132
145
|
storedPathBelongsToWorkspace
|
|
133
|
-
} from "./index-
|
|
146
|
+
} from "./index-bet4sd3e.js";
|
|
134
147
|
import {
|
|
135
148
|
directoryHasGitMetadata,
|
|
136
149
|
resolveProjectIdentityForSession,
|
|
137
150
|
normalizeStoredProjectPath,
|
|
138
151
|
storedPathBelongsToIdentity
|
|
139
152
|
} from "./index-6ex901g3.js";
|
|
140
|
-
import {
|
|
141
|
-
drainBackgroundBatches,
|
|
142
|
-
markProjectLoadUntrusted2,
|
|
143
|
-
drainProjectEmbeddingIdentityMaintenance2,
|
|
144
|
-
registerProjectEmbedding2,
|
|
145
|
-
registerProjectShadowEmbedding2,
|
|
146
|
-
registerProjectInObservationMode2,
|
|
147
|
-
unregisterProjectShadowEmbedding2,
|
|
148
|
-
unregisterProjectEmbedding2,
|
|
149
|
-
getProjectEmbeddingSnapshot2,
|
|
150
|
-
embedTextForProject2
|
|
151
|
-
} from "./index-f6e8jsrh.js";
|
|
152
153
|
import {
|
|
153
154
|
getNoteByIdInScope,
|
|
154
155
|
getNotes,
|
|
@@ -165,7 +166,7 @@ import {
|
|
|
165
166
|
resolveMemoriesByIdsForSearch2,
|
|
166
167
|
unifiedSearch2,
|
|
167
168
|
formatSearchResults2
|
|
168
|
-
} from "./index-
|
|
169
|
+
} from "./index-0awvkeb5.js";
|
|
169
170
|
import {
|
|
170
171
|
computeCueContentHash,
|
|
171
172
|
getMuralCueState,
|
|
@@ -4499,11 +4500,12 @@ class V2StoreReader {
|
|
|
4499
4500
|
const head = Math.floor((maxChars - truncationMarker.length) / 2);
|
|
4500
4501
|
const tail = maxChars - truncationMarker.length - head;
|
|
4501
4502
|
return this.prepare(`WITH users AS (
|
|
4502
|
-
SELECT seq, time_created, data FROM session_message
|
|
4503
|
-
WHERE session_id = ? AND type = 'user' AND time_created ${before ? "<=" : ">"}
|
|
4503
|
+
SELECT session_id, seq, time_created, data FROM session_message
|
|
4504
|
+
WHERE session_id = ? AND type = 'user' AND time_created ${before ? "<=" : ">"}
|
|
4505
|
+
?
|
|
4504
4506
|
ORDER BY time_created ${direction}, seq ${direction} LIMIT ?
|
|
4505
4507
|
), texts AS (
|
|
4506
|
-
SELECT seq, time_created, CASE
|
|
4508
|
+
SELECT session_id, seq, time_created, CASE
|
|
4507
4509
|
WHEN json_extract(data, '$.synthetic') = 1 OR json_extract(data, '$.ignored') = 1 THEN ''
|
|
4508
4510
|
WHEN json_type(data, '$.text') = 'text' THEN json_extract(data, '$.text')
|
|
4509
4511
|
ELSE COALESCE((SELECT group_concat(json_extract(value, '$.text'), char(10))
|
|
@@ -4513,7 +4515,19 @@ class V2StoreReader {
|
|
|
4513
4515
|
AND COALESCE(json_extract(value, '$.ignored'), 0) <> 1), '') END AS text
|
|
4514
4516
|
FROM users WHERE json_valid(data)
|
|
4515
4517
|
) SELECT seq, time_created, CASE WHEN length(text) > ?
|
|
4516
|
-
THEN substr(text, 1, ?) || ? || substr(text, -?) ELSE text END AS text
|
|
4518
|
+
THEN substr(text, 1, ?) || ? || substr(text, -?) ELSE text END AS text,
|
|
4519
|
+
EXISTS (
|
|
4520
|
+
SELECT 1 FROM session_message assistant_reply
|
|
4521
|
+
WHERE assistant_reply.session_id = texts.session_id
|
|
4522
|
+
AND assistant_reply.type = 'assistant'
|
|
4523
|
+
AND assistant_reply.seq < texts.seq
|
|
4524
|
+
AND EXISTS (
|
|
4525
|
+
SELECT 1 FROM session_message prior_user
|
|
4526
|
+
WHERE prior_user.session_id = texts.session_id
|
|
4527
|
+
AND prior_user.type = 'user'
|
|
4528
|
+
AND prior_user.seq < assistant_reply.seq
|
|
4529
|
+
)
|
|
4530
|
+
) AS follows_assistant_reply
|
|
4517
4531
|
FROM texts ORDER BY time_created ${direction}, seq ${direction}`).all(sessionID, boundaryMs, limit, maxChars, head, truncationMarker, tail);
|
|
4518
4532
|
}
|
|
4519
4533
|
storedRowsAfter(sessionID, after) {
|
|
@@ -4948,31 +4962,6 @@ function clearSession(db, sessionId, rustModuleCleanupAcknowledged = false, perm
|
|
|
4948
4962
|
clearUnpublishedAutoSearchNoHints(sessionId);
|
|
4949
4963
|
logSlowWriteTransaction("clear-session", transactionStartedAt);
|
|
4950
4964
|
}
|
|
4951
|
-
// ../plugin/src/hooks/magic-context/embed-session-state.ts
|
|
4952
|
-
var embedPauseBySession = new Set;
|
|
4953
|
-
var embedRunStateBySession = new Map;
|
|
4954
|
-
var autoEmbedAttemptedBySession = new Set;
|
|
4955
|
-
var autoEmbedIdentityBySession = new Map;
|
|
4956
|
-
function invalidateAutoEmbedSession(sessionId) {
|
|
4957
|
-
autoEmbedAttemptedBySession.delete(sessionId);
|
|
4958
|
-
autoEmbedIdentityBySession.delete(sessionId);
|
|
4959
|
-
}
|
|
4960
|
-
function getEmbedDrainUiStatus(sessionId, progress) {
|
|
4961
|
-
if (embedPauseBySession.has(sessionId)) {
|
|
4962
|
-
return { status: "paused" };
|
|
4963
|
-
}
|
|
4964
|
-
const activeRun = embedRunStateBySession.get(sessionId);
|
|
4965
|
-
if (activeRun && !activeRun.signal.aborted || progress?.kind === "embed" && progress.phase === "recomp") {
|
|
4966
|
-
return { status: "running" };
|
|
4967
|
-
}
|
|
4968
|
-
if (progress?.kind === "embed" && (progress.phase === "failed" || progress.phase === "skipped") && progress.message) {
|
|
4969
|
-
if (/provider/i.test(progress.message)) {
|
|
4970
|
-
return { status: "stopped", detail: progress.message };
|
|
4971
|
-
}
|
|
4972
|
-
}
|
|
4973
|
-
return { status: "idle" };
|
|
4974
|
-
}
|
|
4975
|
-
|
|
4976
4965
|
// ../plugin/src/features/magic-context/compartment-lease.ts
|
|
4977
4966
|
var COMPARTMENT_LEASE_TTL_MS = 5 * 60 * 1000;
|
|
4978
4967
|
var COMPARTMENT_LEASE_RENEWAL_MS = 60 * 1000;
|
|
@@ -15565,4 +15554,4 @@ function registerMagicContextTools(pi, opts) {
|
|
|
15565
15554
|
}
|
|
15566
15555
|
}
|
|
15567
15556
|
|
|
15568
|
-
export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, formatWindowSource, isSaneLimit, resolveOutputReserve, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getSdkInputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject,
|
|
15557
|
+
export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, formatWindowSource, isSaneLimit, resolveOutputReserve, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getSdkInputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndThrough, isPartialCompartmentEnd, readProjectDocsCanonical, providerResponseFailed, isSuccessfulProviderCompletion, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemRefreshOwnership, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, acknowledgeSystemPromptDelivery, deferDeliveredSystemRefresh, clearSystemPromptDelivery, saveLkgSlotToDb, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, replayLkg, registerLkgPersistence, LKG_SNAPSHOT_ARRAY, LKG_SNAPSHOT_OBJECT, LKG_SNAPSHOT_KEY, LKG_SNAPSHOT_STRING, LKG_SNAPSHOT_NUMBER, LKG_SNAPSHOT_BOOLEAN, LKG_SNAPSHOT_NULL, LKG_SNAPSHOT_UNDEFINED, contentSnapshotValue, signatureForFields, lkgContentFields, lkgContentDigestFromFields, isLegacyLkgDigest, legacyLkgDigestFromFields, lkgFieldsMatchDigest, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, dropSlot, TOOL_SWEEP_SCOPED_MARKER, encodePiContentDecision, decodePiContentDecision, getPiContentDecisions, freezePiContentDecision, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, externalHistorianFailureReason, subprocessExitHistorianFailureReason, countHistorianRuns, recordHistorianRun, summarizeImportance, tallyFactsByCategory, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, noteTouchedAt, noteNudgePickIndex, formatNoteNudge, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, resolvePiRealStableId, isPiContentFallbackId, isPiIndexFallbackId, piContentFallbackIds, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findRestartModelSeedFromBranch, iterateEntriesToRawMessageRange, iterateAsyncEntriesToRawMessageRange, convertEntriesToRawMessages, convertPiAssistantEntryById, convertEntriesToRawMessagePage, countPiRawMessages, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getTaskScheduleState, getFailingDreamTasks, getSkippedDreamTasks, getMostRecentTaskRunAt, pruneNonCanonicalTaskRows, deleteTaskScheduleRowsForProject, seedTaskScheduleState, writeTaskScheduleState, isRetrospectiveWindowProcessed, recordRetrospectiveWindowProcessed, curateCategoryForMemoryCategory, peekCurateCategoryScope, beginCurateCategoryRun, curateTaskStateAfterSuccess, MEMORY_MURAL_BLOCK, buildMagicContextSection, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, MEMORY_RENDER_FORMAT_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, withCachedM0MemoryIds, readCachedM0MemoryIds, renderBudgetIdentityChanged, renderedBudgetSnapshot, renderedBudgetShrinkReason, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, TEMPORAL_MARKER_REPLAY_PATTERN, temporalMarkerPrefix, renderUserProfileContent, clearInjectionCache, getVisibleMemoryIds, orderHistorianMemories, renderHistorianMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, resetPrefixTrimFallbackState, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, loadPiConfig, loadPiConfigDetailed, unregisterPiProjectEmbeddings, ensureProjectRegisteredFromPiDirectory, resolvePiHarnessDetection, resolvePiHarnessKind, resolvePiOrdinalAlignment, piRawOrdinalOffsetSource, resolvePiOrdinalAlignmentForContext, isPiOrdinalAlignmentUnanchored, clearPiOrdinalAlignmentSession, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
|
|
@@ -858,13 +858,17 @@ function loadUnembeddedShadowChunkCandidates(db, projectPath, primaryModelId, sh
|
|
|
858
858
|
const rows = getShadowBackfillCandidateStatement(db).all(projectPath, projectPath, primaryModelId);
|
|
859
859
|
return selectHashIncompleteChunkCandidates(db, projectPath, shadowModelId, mapBackfillCandidateRows(rows), Math.max(1, limit), shadowMaxInputTokens);
|
|
860
860
|
}
|
|
861
|
-
async function loadUnembeddedCompartmentChunkCandidatesPolite(db, projectPath, modelId, limit, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS, leaseHeldRenumber = false) {
|
|
861
|
+
async function loadUnembeddedCompartmentChunkCandidatesPolite(db, projectPath, modelId, limit, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS, leaseHeldRenumber = false, isEligible) {
|
|
862
862
|
const rows = getBackfillCandidateStatement(db).all(projectPath);
|
|
863
863
|
const candidates = mapBackfillCandidateRows(rows);
|
|
864
864
|
const missing = [];
|
|
865
865
|
const stale = [];
|
|
866
866
|
let sliceStarted = performance.now();
|
|
867
867
|
for (const candidate of candidates) {
|
|
868
|
+
if (isEligible && !isEligible(candidate)) {
|
|
869
|
+
sliceStarted = await yieldCoverageSlice(sliceStarted);
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
868
872
|
const classification = classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens);
|
|
869
873
|
if (classification.defect === "missing")
|
|
870
874
|
missing.push(candidate);
|
|
@@ -1019,7 +1023,7 @@ function memoizedCoverageWindows(candidate, canonicalText, sourceKey, modelId, m
|
|
|
1019
1023
|
return windows;
|
|
1020
1024
|
}
|
|
1021
1025
|
async function yieldCoverageSlice(started) {
|
|
1022
|
-
if (performance.now() - started <
|
|
1026
|
+
if (performance.now() - started < 8)
|
|
1023
1027
|
return started;
|
|
1024
1028
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
1025
1029
|
return performance.now();
|
|
@@ -1093,6 +1097,47 @@ function selectHashIncompleteChunkCandidates(db, projectPath, modelId, candidate
|
|
|
1093
1097
|
return [...missing, ...stale].slice(0, limit);
|
|
1094
1098
|
}
|
|
1095
1099
|
var sessionBackfillCandidateStatements = new WeakMap;
|
|
1100
|
+
function loadUnembeddedSessionChunkCandidates(db, projectPath, sessionId, modelId, limit, excludeIds, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS, leaseHeldRenumber = false) {
|
|
1101
|
+
const exclusions = excludeIds && excludeIds.length > 0 ? excludeIds : [];
|
|
1102
|
+
const exclusionSql = exclusions.length > 0 ? `AND c.id NOT IN (${exclusions.map(() => "?").join(", ")})` : "";
|
|
1103
|
+
const stmt = exclusions.length > 0 ? db.prepare(`SELECT c.id AS id,
|
|
1104
|
+
c.session_id AS sessionId,
|
|
1105
|
+
c.start_message AS startMessage,
|
|
1106
|
+
c.end_message AS endMessage,
|
|
1107
|
+
c.title AS title
|
|
1108
|
+
FROM compartments c
|
|
1109
|
+
JOIN session_projects sp
|
|
1110
|
+
ON sp.session_id = c.session_id
|
|
1111
|
+
AND sp.harness = c.harness
|
|
1112
|
+
AND sp.project_path = ?
|
|
1113
|
+
WHERE c.session_id = ?
|
|
1114
|
+
AND c.start_message IS NOT NULL
|
|
1115
|
+
AND c.end_message IS NOT NULL
|
|
1116
|
+
${exclusionSql}
|
|
1117
|
+
ORDER BY c.start_message ASC, c.id ASC`) : (() => {
|
|
1118
|
+
let cached = sessionBackfillCandidateStatements.get(db);
|
|
1119
|
+
if (!cached) {
|
|
1120
|
+
cached = db.prepare(`SELECT c.id AS id,
|
|
1121
|
+
c.session_id AS sessionId,
|
|
1122
|
+
c.start_message AS startMessage,
|
|
1123
|
+
c.end_message AS endMessage,
|
|
1124
|
+
c.title AS title
|
|
1125
|
+
FROM compartments c
|
|
1126
|
+
JOIN session_projects sp
|
|
1127
|
+
ON sp.session_id = c.session_id
|
|
1128
|
+
AND sp.harness = c.harness
|
|
1129
|
+
AND sp.project_path = ?
|
|
1130
|
+
WHERE c.session_id = ?
|
|
1131
|
+
AND c.start_message IS NOT NULL
|
|
1132
|
+
AND c.end_message IS NOT NULL
|
|
1133
|
+
ORDER BY c.start_message ASC, c.id ASC`);
|
|
1134
|
+
sessionBackfillCandidateStatements.set(db, cached);
|
|
1135
|
+
}
|
|
1136
|
+
return cached;
|
|
1137
|
+
})();
|
|
1138
|
+
const rows = stmt.all(projectPath, sessionId, ...exclusions);
|
|
1139
|
+
return selectHashIncompleteChunkCandidates(db, projectPath, modelId, mapBackfillCandidateRows(rows), Math.max(1, limit), maxInputTokens, leaseHeldRenumber);
|
|
1140
|
+
}
|
|
1096
1141
|
async function loadUnembeddedSessionChunkCandidatesPolite(db, projectPath, sessionId, modelId, limit, excludeIds = [], maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS, leaseHeldRenumber = false) {
|
|
1097
1142
|
const excluded = new Set(excludeIds);
|
|
1098
1143
|
const missing = [];
|
|
@@ -1109,10 +1154,22 @@ async function loadUnembeddedSessionChunkCandidatesPolite(db, projectPath, sessi
|
|
|
1109
1154
|
else if (leaseHeldRenumber) {
|
|
1110
1155
|
applyLeaseHeldCoverageRepair(db, candidate, projectPath, modelId, classification);
|
|
1111
1156
|
}
|
|
1157
|
+
if (missing.length >= Math.max(1, limit))
|
|
1158
|
+
return missing;
|
|
1112
1159
|
started = await yieldCoverageSlice(started);
|
|
1113
1160
|
}
|
|
1114
1161
|
return [...missing, ...stale].slice(0, Math.max(1, limit));
|
|
1115
1162
|
}
|
|
1163
|
+
function countUnembeddedSessionCompartments(db, projectPath, sessionId, modelId, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS) {
|
|
1164
|
+
const rows = getSessionBackfillRows(db, projectPath, sessionId);
|
|
1165
|
+
let count = 0;
|
|
1166
|
+
for (const candidate of rows) {
|
|
1167
|
+
const { defect } = classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens);
|
|
1168
|
+
if (defect === "missing" || defect === "stale")
|
|
1169
|
+
count++;
|
|
1170
|
+
}
|
|
1171
|
+
return count;
|
|
1172
|
+
}
|
|
1116
1173
|
function countSessionCompartmentEmbedCoverage(db, projectPath, sessionId, modelId, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS) {
|
|
1117
1174
|
const candidates = getSessionBackfillRows(db, projectPath, sessionId);
|
|
1118
1175
|
let embedded = 0;
|
|
@@ -1165,4 +1222,4 @@ async function countUnembeddedSessionCompartmentsPolite(db, projectPath, session
|
|
|
1165
1222
|
return count;
|
|
1166
1223
|
}
|
|
1167
1224
|
|
|
1168
|
-
export { DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS, CHUNK_WINDOW_SAFETY_RATIO, normalizeCompartmentChunkMaxInputTokens, buildCanonicalChunkTextFromFts, buildCompartmentSummaryFallbackText, canonicalizeInMemoryChunkTextForEmbedding, chunkCanonicalText, chunkEmbeddingWindowsAreCurrent, replaceCompartmentChunkEmbeddings, loadCompartmentChunkEmbeddingsForSearch, loadUnembeddedShadowChunkCandidates, loadUnembeddedCompartmentChunkCandidatesPolite, deleteChunkEmbedBackoffForSession, recordChunkEmbedBackoff, chunkWindowSourceKey, loadUnembeddedSessionChunkCandidatesPolite, countSessionCompartmentEmbedCoverage, countSessionCompartmentEmbedCoveragePolite, countUnembeddedSessionCompartmentsPolite };
|
|
1225
|
+
export { DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS, CHUNK_WINDOW_SAFETY_RATIO, normalizeCompartmentChunkMaxInputTokens, buildCanonicalChunkTextFromFts, buildCompartmentSummaryFallbackText, canonicalizeInMemoryChunkTextForEmbedding, chunkCanonicalText, chunkEmbeddingWindowsAreCurrent, replaceCompartmentChunkEmbeddings, loadCompartmentChunkEmbeddingsForSearch, loadUnembeddedShadowChunkCandidates, loadUnembeddedCompartmentChunkCandidatesPolite, deleteChunkEmbedBackoffForSession, recordChunkEmbedBackoff, chunkWindowSourceKey, loadUnembeddedSessionChunkCandidates, loadUnembeddedSessionChunkCandidatesPolite, countUnembeddedSessionCompartments, countSessionCompartmentEmbedCoverage, countSessionCompartmentEmbedCoveragePolite, countUnembeddedSessionCompartmentsPolite };
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
} from "./index-6dz2ed1v.js";
|
|
11
11
|
import {
|
|
12
12
|
LocalEmbeddingProvider
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-9jvktm7k.js";
|
|
14
14
|
import {
|
|
15
15
|
OpenAICompatibleEmbeddingProvider,
|
|
16
16
|
getProjectEmbeddingSnapshot2,
|
|
17
17
|
embedBatchForProject2
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-nwbhe6qv.js";
|
|
19
19
|
import {
|
|
20
20
|
isEmbeddingHostBusy2
|
|
21
21
|
} from "./index-9p40dgkm.js";
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from "./index-djxc8w8c.js";
|
|
26
26
|
import {
|
|
27
27
|
deleteChunkEmbedBackoffForSession
|
|
28
|
-
} from "./index-
|
|
28
|
+
} from "./index-7qc73yk5.js";
|
|
29
29
|
import {
|
|
30
30
|
closeQuietly,
|
|
31
31
|
TAG_TOMBSTONE_OWNER_PREFIX,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
} from "./index-jrap43gc.js";
|
|
38
38
|
import {
|
|
39
39
|
cleanUserText2
|
|
40
|
-
} from "./index-
|
|
40
|
+
} from "./index-75ah9413.js";
|
|
41
41
|
import {
|
|
42
42
|
logSlowWriteTransaction
|
|
43
43
|
} from "./index-d4dt19md.js";
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
hasPendingMigrations,
|
|
52
52
|
getMainThreadMigrationBodyCount,
|
|
53
53
|
runMigrations
|
|
54
|
-
} from "./index-
|
|
54
|
+
} from "./index-bet4sd3e.js";
|
|
55
55
|
import {
|
|
56
56
|
closeQuietly,
|
|
57
57
|
ensureColumn,
|
|
@@ -1298,7 +1298,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1298
1298
|
startMessageFtsRowidMapBackfill(db).then(async () => {
|
|
1299
1299
|
if (!readsOpenCodeStore)
|
|
1300
1300
|
return;
|
|
1301
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1301
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-0fsgg2k1.js"));
|
|
1302
1302
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-r2ar1qvk.js"));
|
|
1303
1303
|
await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
|
|
1304
1304
|
readPage: readRawSessionMessagePage
|
|
@@ -2792,4 +2792,4 @@ function closeDatabase() {
|
|
|
2792
2792
|
}
|
|
2793
2793
|
}
|
|
2794
2794
|
|
|
2795
|
-
export { FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, createFailClosedController, getErrorMessage, describeError, startBootDeadline, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, applySqliteTuningPragmas, runSqliteOptimize, initializeDatabase, openDatabase, openCurrentDatabase, openDatabaseAsync, closeDatabase };
|
|
2795
|
+
export { FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, createFailClosedController, getErrorMessage, describeError, startBootDeadline, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, enforceSchemaFence, setSqlitePragmaConfig, applySqliteTuningPragmas, runSqliteOptimize, initializeDatabase, openDatabase, openCurrentDatabase, openDatabaseAsync, closeDatabase };
|
|
@@ -2511,6 +2511,9 @@ function toTagEntry(row) {
|
|
|
2511
2511
|
tokenCount: typeof row.token_count === "number" ? row.token_count : null
|
|
2512
2512
|
};
|
|
2513
2513
|
}
|
|
2514
|
+
function normalizeTagSnapshotRow2(row) {
|
|
2515
|
+
return isTagRow(row) ? toTagEntry(row) : null;
|
|
2516
|
+
}
|
|
2514
2517
|
function isTagNumberRow(row) {
|
|
2515
2518
|
if (row === null || typeof row !== "object")
|
|
2516
2519
|
return false;
|
|
@@ -3380,4 +3383,4 @@ function deleteToolTagsByOwner(db, sessionId, ownerMsgId) {
|
|
|
3380
3383
|
return getDeleteToolTagsByOwnerStatement(db).all(sessionId, ownerMsgId).length;
|
|
3381
3384
|
}
|
|
3382
3385
|
|
|
3383
|
-
export { UNKNOWN_FIT_RATIO, resolveDecisionCalibration, hasMeasuredDecisionCalibration, providerMass, localBudget, calibrationForModelKey, historyLocalBudget, adoptedProtectedToolsPolicy, protectedToolTagNumbers, protectedToolTokenCount, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, rememberCurrentToolOutputCount, currentReclaimableToolOutputCount, isRecord, TEXT_TAG_IDENTITY_MARKER, PI_FALLBACK_PREFIXES_JSON, contentTagOwnerMessageId, TailHygieneJsonMemo, piJsonHash, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisiblePart, providerVisibleMessage, TODO_STATUSES, TODO_PRIORITIES, TITLE_DONE_STATUSES, normalizeTodoStateJson, buildSyntheticTodoPart, stripChannel1ReminderSpans, compareMeasuredTailPrefix, formatTailHygienePrefixMismatch, freezeTailHygieneMeasurement, effectiveTailHygiene, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, decideChannel1, evaluateChannel2, buildChannel2Reminder, buildChannel1Reminder, planEmergencyDrop, measureEmergencyTag, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, updateTagByteSize2, getRecentTagOwnerMessageIds2, getActiveTagTokenAggregate2, AGE_RECLAIM_MIN_TOKENS2, getOldestActiveUnprotectedToolTags2, getActiveToolTagsForAgeReclaim2, getTriggerTagTokenUpperBound2, getActiveTagTokenTotalsByMessage2, updateTagInputByteSize2, updateTagTokenCount2, getPersistedToolTagAccounting2, getAllStatusTagTokenTotalsFlat2, getReasoningTokenEstimatesByMessage2, tryGetReasoningTokenEstimatesByMessage2, getMaxTagNumberByOwnerMessage2, scanTagOwnerSummary2, scanTagOwnerDelta2, updateTagInputTokenCount2, tagTokenCountIsNull2, backfillTagTokenCounts2, insertTag2, updateTagStatus2, markTagDropped2, getInertWhitespaceAssistantTagsByNumbers2, updateTagDropMode2, updateCavemanDepth2, updateTagMessageId2, hasPiFallbackMessageTags2, findAdoptableFallbackTags2, adoptFallbackTagMessageId2, foldShrunkPartTags2, hasPiFallbackToolOwnerTags2, findPiFallbackToolOwnerTags2, PiTagIdentityConflictError2, getPiMessageTagCandidates2, findPiTagIdentityConflict2, adoptPiFallbackToolOwnerTag2, adoptPiFallbackMessageTag2, markTagsCompactedByMessageIds2, deleteTagsByMessageId2, getMaxTagNumberBySession2, getTagNumberByMessageId2, getAssignableTagNumberByMessageId2, getMinMessageTagNumberForRawId2, deriveTagLoadFloor2, TAG_SELECT_COLUMNS2, getTagsBySession2, getActiveTagsBySession2, getTagsForPendingOperations2, getTagsByNumbers2, getNewestToolTagNumbers2, getDroppedTagsByNumbers2, getMaxDroppedTagNumber2, getTagById2, getTopNBySize2, getToolTagNumberByOwner2, getNullOwnerToolTag2, adoptNullOwnerToolTag2, getCandidateToolOwners2, pickNearestPriorOwner2 };
|
|
3386
|
+
export { UNKNOWN_FIT_RATIO, resolveDecisionCalibration, hasMeasuredDecisionCalibration, providerMass, localBudget, calibrationForModelKey, historyLocalBudget, adoptedProtectedToolsPolicy, protectedToolTagNumbers, protectedToolTokenCount, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, rememberCurrentToolOutputCount, currentReclaimableToolOutputCount, isRecord, TEXT_TAG_IDENTITY_MARKER, PI_FALLBACK_PREFIXES_JSON, contentTagOwnerMessageId, TailHygieneJsonMemo, piJsonHash, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisiblePart, providerVisibleMessage, TODO_STATUSES, TODO_PRIORITIES, TITLE_DONE_STATUSES, normalizeTodoStateJson, buildSyntheticTodoPart, stripChannel1ReminderSpans, compareMeasuredTailPrefix, formatTailHygienePrefixMismatch, freezeTailHygieneMeasurement, effectiveTailHygiene, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, decideChannel1, evaluateChannel2, buildChannel2Reminder, buildChannel1Reminder, planEmergencyDrop, measureEmergencyTag, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, updateTagByteSize2, getRecentTagOwnerMessageIds2, getActiveTagTokenAggregate2, AGE_RECLAIM_MIN_TOKENS2, getOldestActiveUnprotectedToolTags2, getActiveToolTagsForAgeReclaim2, getTriggerTagTokenUpperBound2, getActiveTagTokenTotalsByMessage2, updateTagInputByteSize2, updateTagTokenCount2, getPersistedToolTagAccounting2, getAllStatusTagTokenTotalsFlat2, getReasoningTokenEstimatesByMessage2, tryGetReasoningTokenEstimatesByMessage2, getMaxTagNumberByOwnerMessage2, scanTagOwnerSummary2, scanTagOwnerDelta2, updateTagInputTokenCount2, tagTokenCountIsNull2, backfillTagTokenCounts2, normalizeTagSnapshotRow2, insertTag2, updateTagStatus2, markTagDropped2, getInertWhitespaceAssistantTagsByNumbers2, updateTagDropMode2, updateCavemanDepth2, updateTagMessageId2, hasPiFallbackMessageTags2, findAdoptableFallbackTags2, adoptFallbackTagMessageId2, foldShrunkPartTags2, hasPiFallbackToolOwnerTags2, findPiFallbackToolOwnerTags2, PiTagIdentityConflictError2, getPiMessageTagCandidates2, findPiTagIdentityConflict2, adoptPiFallbackToolOwnerTag2, adoptPiFallbackMessageTag2, markTagsCompactedByMessageIds2, deleteTagsByMessageId2, getMaxTagNumberBySession2, getTagNumberByMessageId2, getAssignableTagNumberByMessageId2, getMinMessageTagNumberForRawId2, deriveTagLoadFloor2, TAG_SELECT_COLUMNS2, getTagsBySession2, getActiveTagsBySession2, getTagsForPendingOperations2, getTagsByNumbers2, getNewestToolTagNumbers2, getDroppedTagsByNumbers2, getMaxDroppedTagNumber2, getTagById2, getTopNBySize2, getToolTagNumberByOwner2, getNullOwnerToolTag2, adoptNullOwnerToolTag2, getCandidateToolOwners2, pickNearestPriorOwner2 };
|