@cortexkit/pi-magic-context 0.49.52 → 0.49.54
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 +3 -4
- package/dist/{embedding-backfill-fbhpk2yy.js → embedding-backfill-qde2zywg.js} +4 -4
- package/dist/embedding-worker.js +2 -2
- package/dist/{index-0hewsw7v.js → index-2pptpxq8.js} +1 -1
- package/dist/index-5n3e2gq5.js +6469 -0
- package/dist/{index-rjz01pvv.js → index-625kbnqd.js} +5 -7
- package/dist/{index-73c292h9.js → index-6ahmfva8.js} +3 -3
- package/dist/{index-1cvyaw9a.js → index-8d2z6503.js} +1 -1
- package/dist/{index-ktez4jwz.js → index-9kaj9ty1.js} +7 -6
- package/dist/{index-46wk0td0.js → index-awpx91y5.js} +1 -1
- package/dist/{index-mb34ngfr.js → index-c3mms4dp.js} +27 -16
- package/dist/{index-zc6fdyx7.js → index-d40ecdbn.js} +1 -1
- package/dist/{index-r6dj8rm9.js → index-erkb5dee.js} +11 -7
- package/dist/{index-38pf5bqw.js → index-hec3bwev.js} +1 -1
- package/dist/{index-ty2m0s0s.js → index-jnh7a6a3.js} +3 -3
- package/dist/{index-akmmkmhf.js → index-k2z7r444.js} +523 -30
- package/dist/{index-pkg07s54.js → index-nhpvvdhw.js} +2 -2
- package/dist/index-rekymyxd.js +2287 -0
- package/dist/{index-cc73przv.js → index-tn38he5d.js} +44 -31
- package/dist/{index-jxm4bvm4.js → index-v858d5d1.js} +168 -1
- package/dist/{index-aec63gtj.js → index-vcegxfwg.js} +16 -6
- package/dist/index.js +970 -352
- package/dist/{message-index-bounded-d50b5f2z.js → message-index-bounded-ac4qg6aw.js} +5 -6
- package/dist/migration-worker.js +3 -4
- package/dist/{project-embedding-registry-hpca84nz.js → project-embedding-registry-qx2zjbgs.js} +5 -3
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-9yr9mava.js → read-session-chunk-jyfcykg4.js} +4 -5
- package/dist/{render-3s7kbr61.js → render-bqqx15n8.js} +9 -10
- package/dist/{search-archive-dd1z7xn0.js → search-archive-31054zxj.js} +7 -8
- package/dist/{search-2vgt4717.js → search-w12nc025.js} +12 -13
- package/dist/{storage-tags-ahhwtfdq.js → storage-tags-g0328gwp.js} +4 -2
- package/dist/subagent-entry.js +39 -18
- package/dist/tag-snapshot-worker-pi.js +6 -6
- package/dist/{v2-archive-reader-6jbyaafn.js → v2-archive-reader-hg4c36em.js} +1 -1
- package/package.json +3 -1
- package/dist/index-674f6qs2.js +0 -16
- package/dist/index-c6wbq66z.js +0 -168
- package/dist/index-fec4ezww.js +0 -5271
- package/dist/index-qcsjj9m0.js +0 -3412
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
PER_HARNESS_MODEL_KEYS,
|
|
31
31
|
ConfigProfilesSchema,
|
|
32
32
|
MagicContextConfigSchema
|
|
33
|
-
} from "./index-
|
|
33
|
+
} from "./index-vcegxfwg.js";
|
|
34
34
|
import {
|
|
35
35
|
V2_MEMORY_CATEGORIES,
|
|
36
36
|
CATEGORY_PRIORITY,
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
import {
|
|
57
57
|
piHarnessKindFromExecutable,
|
|
58
58
|
getErrorMessage
|
|
59
|
-
} from "./index-
|
|
59
|
+
} from "./index-625kbnqd.js";
|
|
60
60
|
import {
|
|
61
61
|
getOrCreateSessionMeta,
|
|
62
62
|
updateSessionMeta,
|
|
@@ -70,23 +70,30 @@ import {
|
|
|
70
70
|
renderMessageByOrdinal2,
|
|
71
71
|
renderVerboseRange2,
|
|
72
72
|
renderItemByTag2
|
|
73
|
-
} from "./index-
|
|
73
|
+
} from "./index-k2z7r444.js";
|
|
74
74
|
import {
|
|
75
75
|
getLastIndexedOrdinal
|
|
76
|
-
} from "./index-
|
|
76
|
+
} from "./index-2pptpxq8.js";
|
|
77
77
|
import {
|
|
78
|
+
TODO_STATUSES,
|
|
79
|
+
TODO_PRIORITIES,
|
|
80
|
+
TITLE_DONE_STATUSES,
|
|
81
|
+
queuePendingOp,
|
|
82
|
+
getPendingOps,
|
|
83
|
+
updateTagStatus2,
|
|
84
|
+
getInertWhitespaceAssistantTagsByNumbers2,
|
|
85
|
+
getTagNumberByMessageId2,
|
|
86
|
+
getTagsBySession2,
|
|
78
87
|
setNoteLastReadAt,
|
|
79
88
|
getPersistedCompactionMarkerState,
|
|
80
89
|
getCompactionMarkerPublicationState,
|
|
81
90
|
compareAndSetCompactionMarkerPublicationState,
|
|
82
|
-
getDeferredClearedCompactionMarkerState
|
|
83
|
-
|
|
84
|
-
setRawMessageProvider2,
|
|
85
|
-
readSessionChunk2
|
|
86
|
-
} from "./index-fec4ezww.js";
|
|
91
|
+
getDeferredClearedCompactionMarkerState
|
|
92
|
+
} from "./index-5n3e2gq5.js";
|
|
87
93
|
import {
|
|
88
|
-
stableStringify
|
|
89
|
-
|
|
94
|
+
stableStringify,
|
|
95
|
+
BoundedSessionMap
|
|
96
|
+
} from "./index-v858d5d1.js";
|
|
90
97
|
import {
|
|
91
98
|
computeCueContentHash,
|
|
92
99
|
getMuralCueState,
|
|
@@ -109,7 +116,7 @@ import {
|
|
|
109
116
|
} from "./index-yhzhdp3m.js";
|
|
110
117
|
import {
|
|
111
118
|
preflightLocalEmbeddingPooling
|
|
112
|
-
} from "./index-
|
|
119
|
+
} from "./index-hec3bwev.js";
|
|
113
120
|
import {
|
|
114
121
|
withQueryEmbeddingDeadline,
|
|
115
122
|
markProjectLoadUntrusted2,
|
|
@@ -121,7 +128,7 @@ import {
|
|
|
121
128
|
unregisterProjectEmbedding2,
|
|
122
129
|
getProjectEmbeddingSnapshot2,
|
|
123
130
|
embedTextForProject2
|
|
124
|
-
} from "./index-
|
|
131
|
+
} from "./index-erkb5dee.js";
|
|
125
132
|
import {
|
|
126
133
|
directoryHasGitMetadata,
|
|
127
134
|
resolveProjectIdentityForSession,
|
|
@@ -134,32 +141,23 @@ import {
|
|
|
134
141
|
resolveMemoriesByIdsForSearch2,
|
|
135
142
|
unifiedSearch2,
|
|
136
143
|
formatSearchResults2
|
|
137
|
-
} from "./index-
|
|
138
|
-
import {
|
|
139
|
-
TODO_STATUSES,
|
|
140
|
-
TODO_PRIORITIES,
|
|
141
|
-
TITLE_DONE_STATUSES,
|
|
142
|
-
queuePendingOp,
|
|
143
|
-
getPendingOps,
|
|
144
|
-
updateTagStatus2,
|
|
145
|
-
getInertWhitespaceAssistantTagsByNumbers2,
|
|
146
|
-
getTagNumberByMessageId2,
|
|
147
|
-
getTagsBySession2
|
|
148
|
-
} from "./index-qcsjj9m0.js";
|
|
144
|
+
} from "./index-c3mms4dp.js";
|
|
149
145
|
import {
|
|
150
146
|
resolveOpenCodeDbPath,
|
|
151
147
|
assertOpenCodeStoreGeneration
|
|
152
148
|
} from "./index-n0zjvs3h.js";
|
|
153
149
|
import {
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
hasRawMessageProvider2,
|
|
151
|
+
setRawMessageProvider2,
|
|
152
|
+
readSessionChunk2
|
|
153
|
+
} from "./index-rekymyxd.js";
|
|
156
154
|
import {
|
|
157
155
|
resolveWorkspaceShareCategories,
|
|
158
156
|
resolveWorkspaceIdentitySet,
|
|
159
157
|
expandWorkspaceIdentitySetWithAliases,
|
|
160
158
|
resolveStoredPathWorkspaceIdentity,
|
|
161
159
|
storedPathBelongsToWorkspace
|
|
162
|
-
} from "./index-
|
|
160
|
+
} from "./index-d40ecdbn.js";
|
|
163
161
|
import {
|
|
164
162
|
getNoteByIdInScope,
|
|
165
163
|
getNotes,
|
|
@@ -170,7 +168,7 @@ import {
|
|
|
170
168
|
updateNote,
|
|
171
169
|
dismissNotes,
|
|
172
170
|
dismissNote
|
|
173
|
-
} from "./index-
|
|
171
|
+
} from "./index-awpx91y5.js";
|
|
174
172
|
import {
|
|
175
173
|
isMarkerCandidateBasisCurrent2,
|
|
176
174
|
invalidateMarkerCandidateBasis2,
|
|
@@ -184,7 +182,7 @@ import {
|
|
|
184
182
|
} from "./index-xssjy4z9.js";
|
|
185
183
|
import {
|
|
186
184
|
renderSearchArchive2
|
|
187
|
-
} from "./index-
|
|
185
|
+
} from "./index-9kaj9ty1.js";
|
|
188
186
|
import {
|
|
189
187
|
computeNormalizedHash
|
|
190
188
|
} from "./index-9x1f96r8.js";
|
|
@@ -7521,6 +7519,21 @@ function resolvePiHarnessKind() {
|
|
|
7521
7519
|
return "pi";
|
|
7522
7520
|
}
|
|
7523
7521
|
|
|
7522
|
+
// src/subagent-startup.ts
|
|
7523
|
+
var SUBAGENT_STARTUP_ERROR_EVENT = "magic_context_startup_error";
|
|
7524
|
+
function readSubagentStartupError(event) {
|
|
7525
|
+
if (typeof event !== "object" || event === null)
|
|
7526
|
+
return;
|
|
7527
|
+
const value = event;
|
|
7528
|
+
return value.type === SUBAGENT_STARTUP_ERROR_EVENT && typeof value.error === "string" && value.error.length > 0 ? value.error : undefined;
|
|
7529
|
+
}
|
|
7530
|
+
async function reportSubagentStartupError(error) {
|
|
7531
|
+
await new Promise((resolve) => {
|
|
7532
|
+
process.stdout.write(`${JSON.stringify({ type: SUBAGENT_STARTUP_ERROR_EVENT, error })}
|
|
7533
|
+
`, () => resolve());
|
|
7534
|
+
});
|
|
7535
|
+
}
|
|
7536
|
+
|
|
7524
7537
|
// src/pi-ordinal-alignment.ts
|
|
7525
7538
|
var ALIGNED = { kind: "aligned", offset: 0 };
|
|
7526
7539
|
var resolvedByEntries = new WeakMap;
|
|
@@ -10814,4 +10827,4 @@ function registerMagicContextTools(pi, opts) {
|
|
|
10814
10827
|
}
|
|
10815
10828
|
}
|
|
10816
10829
|
|
|
10817
|
-
export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, isCommitRetentionPaused, copyCommitRetentionRecovery, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, OPENCODE_OUTPUT_CAP, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, formatWindowSource, isSaneLimit, resolveOutputReserve, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getSdkInputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, 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, requestToolsFingerprint, classifyRequestToolsChange, requestToolSchemaDigest, 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, neutralizeOmpMentions, restoreOmpMentions, resolvePiHarnessDetection, resolvePiHarnessKind, resolvePiOrdinalAlignment, piRawOrdinalOffsetSource, resolvePiOrdinalAlignmentForContext, isPiOrdinalAlignmentUnanchored, clearPiOrdinalAlignmentSession, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
|
|
10830
|
+
export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, isCommitRetentionPaused, copyCommitRetentionRecovery, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, OPENCODE_OUTPUT_CAP, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, formatWindowSource, isSaneLimit, resolveOutputReserve, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getSdkInputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, 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, requestToolsFingerprint, classifyRequestToolsChange, requestToolSchemaDigest, 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, neutralizeOmpMentions, restoreOmpMentions, resolvePiHarnessDetection, resolvePiHarnessKind, readSubagentStartupError, reportSubagentStartupError, resolvePiOrdinalAlignment, piRawOrdinalOffsetSource, resolvePiOrdinalAlignmentForContext, isPiOrdinalAlignmentUnanchored, clearPiOrdinalAlignmentSession, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
|
|
@@ -68,6 +68,173 @@ function jsonHashSink(prefix = "") {
|
|
|
68
68
|
return { write, digest: () => (hash >>> 0).toString(16).padStart(8, "0") };
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
// ../plugin/src/shared/bounded-session-map.ts
|
|
72
|
+
class BoundedSessionMap {
|
|
73
|
+
maxEntries;
|
|
74
|
+
store = new Map;
|
|
75
|
+
constructor(maxEntries) {
|
|
76
|
+
if (!Number.isFinite(maxEntries) || maxEntries < 1) {
|
|
77
|
+
throw new Error(`BoundedSessionMap: maxEntries must be >= 1, got ${maxEntries}`);
|
|
78
|
+
}
|
|
79
|
+
this.maxEntries = maxEntries;
|
|
80
|
+
}
|
|
81
|
+
get(sessionId) {
|
|
82
|
+
const value = this.store.get(sessionId);
|
|
83
|
+
if (value === undefined)
|
|
84
|
+
return;
|
|
85
|
+
this.store.delete(sessionId);
|
|
86
|
+
this.store.set(sessionId, value);
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
peek(sessionId) {
|
|
90
|
+
return this.store.get(sessionId);
|
|
91
|
+
}
|
|
92
|
+
has(sessionId) {
|
|
93
|
+
return this.store.has(sessionId);
|
|
94
|
+
}
|
|
95
|
+
set(sessionId, value) {
|
|
96
|
+
if (this.store.has(sessionId)) {
|
|
97
|
+
this.store.delete(sessionId);
|
|
98
|
+
} else if (this.store.size >= this.maxEntries) {
|
|
99
|
+
const oldest = this.store.keys().next().value;
|
|
100
|
+
if (oldest !== undefined)
|
|
101
|
+
this.store.delete(oldest);
|
|
102
|
+
}
|
|
103
|
+
this.store.set(sessionId, value);
|
|
104
|
+
}
|
|
105
|
+
delete(sessionId) {
|
|
106
|
+
return this.store.delete(sessionId);
|
|
107
|
+
}
|
|
108
|
+
clear() {
|
|
109
|
+
this.store.clear();
|
|
110
|
+
}
|
|
111
|
+
get size() {
|
|
112
|
+
return this.store.size;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ../plugin/src/features/magic-context/tool-definition-tokens.ts
|
|
117
|
+
var ACTIVITY_WINDOW_MS = 10 * 60000;
|
|
118
|
+
var MAX_ACTIVITY_GAP_MS = 60000;
|
|
119
|
+
var WINDOWED_SINCE_KEY = "tool_definition_measurements:windowed_since";
|
|
120
|
+
var routes = new Map;
|
|
121
|
+
var sessionFlights = new BoundedSessionMap(1000);
|
|
122
|
+
var persistenceDb = null;
|
|
123
|
+
var windowedSince;
|
|
124
|
+
var boundAt = 0;
|
|
125
|
+
var cachedInsertStmt = null;
|
|
126
|
+
var cachedDeleteStmt = null;
|
|
127
|
+
function agentKey(agentName) {
|
|
128
|
+
return agentName && agentName.length > 0 ? agentName : "default";
|
|
129
|
+
}
|
|
130
|
+
function keyFor(providerID, modelID, agentName) {
|
|
131
|
+
return `${providerID}/${modelID}/${agentKey(agentName)}`;
|
|
132
|
+
}
|
|
133
|
+
function routeFor(providerID, modelID, agentName) {
|
|
134
|
+
const key = keyFor(providerID, modelID, agentName);
|
|
135
|
+
let route = routes.get(key);
|
|
136
|
+
if (!route) {
|
|
137
|
+
route = {
|
|
138
|
+
providerID,
|
|
139
|
+
modelID,
|
|
140
|
+
agentName: agentKey(agentName),
|
|
141
|
+
tools: new Map,
|
|
142
|
+
live: false,
|
|
143
|
+
clock: 0,
|
|
144
|
+
lastWallAt: Date.now(),
|
|
145
|
+
oldestFireAt: Number.POSITIVE_INFINITY,
|
|
146
|
+
retired: new Map,
|
|
147
|
+
legacyRows: new Set
|
|
148
|
+
};
|
|
149
|
+
routes.set(key, route);
|
|
150
|
+
}
|
|
151
|
+
return { key, route };
|
|
152
|
+
}
|
|
153
|
+
function advanceClock(route) {
|
|
154
|
+
const now = Date.now();
|
|
155
|
+
const gap = Math.min(Math.max(now - route.lastWallAt, 0), MAX_ACTIVITY_GAP_MS);
|
|
156
|
+
route.clock += gap;
|
|
157
|
+
route.lastWallAt = Math.max(route.lastWallAt, now);
|
|
158
|
+
return route.clock;
|
|
159
|
+
}
|
|
160
|
+
function readWindowedSince(db) {
|
|
161
|
+
try {
|
|
162
|
+
const row = db.prepare("SELECT value FROM schema_migrations_meta WHERE key = ?").get(WINDOWED_SINCE_KEY);
|
|
163
|
+
if (!row)
|
|
164
|
+
return;
|
|
165
|
+
const value = Number(row.value);
|
|
166
|
+
return Number.isFinite(value) ? value : undefined;
|
|
167
|
+
} catch {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function markWindowed() {
|
|
172
|
+
if (windowedSince !== undefined || !persistenceDb)
|
|
173
|
+
return;
|
|
174
|
+
try {
|
|
175
|
+
persistenceDb.prepare("INSERT OR IGNORE INTO schema_migrations_meta (key, value) VALUES (?, ?)").run(WINDOWED_SINCE_KEY, String(boundAt));
|
|
176
|
+
windowedSince = readWindowedSince(persistenceDb);
|
|
177
|
+
} catch {}
|
|
178
|
+
}
|
|
179
|
+
function setDatabase(db) {
|
|
180
|
+
const rebound = persistenceDb !== null && persistenceDb !== db;
|
|
181
|
+
persistenceDb = db;
|
|
182
|
+
boundAt = Date.now();
|
|
183
|
+
cachedInsertStmt = null;
|
|
184
|
+
cachedDeleteStmt = null;
|
|
185
|
+
if (rebound) {
|
|
186
|
+
for (const route of routes.values()) {
|
|
187
|
+
for (const slot of route.tools.values()) {
|
|
188
|
+
slot.persisted = false;
|
|
189
|
+
slot.writeFailedAt = undefined;
|
|
190
|
+
}
|
|
191
|
+
for (const retired of route.retired.values())
|
|
192
|
+
retired.rowKept = false;
|
|
193
|
+
route.legacyRows.clear();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
windowedSince = readWindowedSince(db);
|
|
197
|
+
if (windowedSince !== undefined)
|
|
198
|
+
return;
|
|
199
|
+
try {
|
|
200
|
+
if (!db.prepare("SELECT 1 FROM tool_definition_measurements LIMIT 1").get())
|
|
201
|
+
markWindowed();
|
|
202
|
+
} catch {}
|
|
203
|
+
}
|
|
204
|
+
function loadToolDefinitionMeasurements(db) {
|
|
205
|
+
let rows = [];
|
|
206
|
+
try {
|
|
207
|
+
rows = db.prepare("SELECT provider_id, model_id, agent_name, tool_id, token_count, recorded_at FROM tool_definition_measurements").all();
|
|
208
|
+
} catch {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const since = readWindowedSince(db);
|
|
212
|
+
const loadedAt = new Map;
|
|
213
|
+
for (const row of rows) {
|
|
214
|
+
const { route } = routeFor(row.provider_id, row.model_id, row.agent_name);
|
|
215
|
+
if (route.live)
|
|
216
|
+
continue;
|
|
217
|
+
let now = loadedAt.get(route);
|
|
218
|
+
if (now === undefined) {
|
|
219
|
+
now = advanceClock(route);
|
|
220
|
+
loadedAt.set(route, now);
|
|
221
|
+
}
|
|
222
|
+
const legacy = since === undefined || !(Number(row.recorded_at) >= since);
|
|
223
|
+
route.tools.set(row.tool_id, {
|
|
224
|
+
tokens: row.token_count,
|
|
225
|
+
fingerprint: undefined,
|
|
226
|
+
lastFireAt: now,
|
|
227
|
+
legacy,
|
|
228
|
+
persisted: !legacy
|
|
229
|
+
});
|
|
230
|
+
route.oldestFireAt = Math.min(route.oldestFireAt, now);
|
|
231
|
+
if (legacy)
|
|
232
|
+
route.legacyRows.add(row.tool_id);
|
|
233
|
+
else
|
|
234
|
+
route.legacyRows.delete(row.tool_id);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
71
238
|
// ../plugin/src/features/magic-context/storage-schema-helpers.ts
|
|
72
239
|
var columnCaches = new WeakMap;
|
|
73
240
|
function readColumnNames(db, table) {
|
|
@@ -525,4 +692,4 @@ function deleteTagIdentityRevisions(db, sessionIds) {
|
|
|
525
692
|
}
|
|
526
693
|
}
|
|
527
694
|
|
|
528
|
-
export { stableStringify, jsonHashSink, getTableColumnNames, ensureColumn, healAllNullColumns, observeTemporalDecisions, freezeTemporalDecisions, installV95PerfSchema, tagOrderConstraintIndex, tagRevisionIncarnationSql, tagRevisionCountSql, tagTombstoneOwnerRange, tagTombstoneOwnerKey, tagRevisionKey, tagIdentityRevisionKey, TAG_INSERT_CONFLICT_ROWS, installTagIdentityRevisionTrigger, deleteTagIdentityRevisions };
|
|
695
|
+
export { stableStringify, jsonHashSink, BoundedSessionMap, setDatabase, loadToolDefinitionMeasurements, getTableColumnNames, ensureColumn, healAllNullColumns, observeTemporalDecisions, freezeTemporalDecisions, installV95PerfSchema, tagOrderConstraintIndex, tagRevisionIncarnationSql, tagRevisionCountSql, tagTombstoneOwnerRange, tagTombstoneOwnerKey, tagRevisionKey, tagIdentityRevisionKey, TAG_INSERT_CONFLICT_ROWS, installTagIdentityRevisionTrigger, deleteTagIdentityRevisions };
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_PROTECTED_TOOLS,
|
|
3
|
-
mergeProtectedTools
|
|
4
|
-
} from "./index-674f6qs2.js";
|
|
5
|
-
|
|
6
1
|
// ../plugin/src/shared/harness-provider-map.ts
|
|
7
2
|
var CANONICAL_TO_PI_PROVIDER = {
|
|
8
3
|
openai: "openai-codex",
|
|
@@ -6384,6 +6379,21 @@ function resolvePromptSurface(config, modelKey) {
|
|
|
6384
6379
|
return { preset: fallback, source: "default" };
|
|
6385
6380
|
}
|
|
6386
6381
|
|
|
6382
|
+
// ../plugin/src/shared/protected-tools-policy.ts
|
|
6383
|
+
var DEFAULT_PROTECTED_TOOLS = {
|
|
6384
|
+
todowrite: 1,
|
|
6385
|
+
ctx_reduce: 3
|
|
6386
|
+
};
|
|
6387
|
+
function normalizeProtectedToolName(name) {
|
|
6388
|
+
return (name ?? "").toLowerCase().replace(/^mcp_/, "");
|
|
6389
|
+
}
|
|
6390
|
+
function mergeProtectedTools(...maps) {
|
|
6391
|
+
return Object.fromEntries([DEFAULT_PROTECTED_TOOLS, ...maps].flatMap((map) => Object.entries(map ?? {}).map(([name, count]) => [
|
|
6392
|
+
normalizeProtectedToolName(name),
|
|
6393
|
+
count
|
|
6394
|
+
])));
|
|
6395
|
+
}
|
|
6396
|
+
|
|
6387
6397
|
// ../plugin/src/config/schema/agent-overrides.ts
|
|
6388
6398
|
var PermissionValueSchema = _enum(["ask", "allow", "deny"]);
|
|
6389
6399
|
var PermissionSchema = object({
|
|
@@ -7010,4 +7020,4 @@ function deriveDefaultProtectedTokens(usableSoft) {
|
|
|
7010
7020
|
return Math.min(64000, Math.max(lowerBound, target));
|
|
7011
7021
|
}
|
|
7012
7022
|
|
|
7013
|
-
export { canonicalModelIdentity, piModelRefToCanonical, resolveModelRefForPi, modelRefLookupOrder, ompModelRefToCanonical, resolveModelRefForOmp, isValidLanguageCode, withContentLanguageDirective, buildPrimaryLanguageDirective, parseCron, nextOccurrence, nextDueAtMs, renderToolTemplate, resolveModelConfigValue, resolvePromptSurface, DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE, DEFAULT_HISTORIAN_TIMEOUT_MS, PROTECTED_TOKENS_MIN, DEFAULT_LOCAL_EMBEDDING_MODEL, PER_HARNESS_MIGRATION_INVENTORY, PER_HARNESS_MODEL_KEYS, ConfigProfilesSchema, DREAM_TASK_PROMOTION_DEFAULTS, MagicContextConfigSchema, LIVE_RELOAD_CONFIG_PATHS, deriveDefaultProtectedTokens };
|
|
7023
|
+
export { canonicalModelIdentity, piModelRefToCanonical, resolveModelRefForPi, modelRefLookupOrder, ompModelRefToCanonical, resolveModelRefForOmp, isValidLanguageCode, withContentLanguageDirective, buildPrimaryLanguageDirective, parseCron, nextOccurrence, nextDueAtMs, renderToolTemplate, resolveModelConfigValue, resolvePromptSurface, DEFAULT_PROTECTED_TOOLS, normalizeProtectedToolName, mergeProtectedTools, DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE, DEFAULT_HISTORIAN_TIMEOUT_MS, PROTECTED_TOKENS_MIN, DEFAULT_LOCAL_EMBEDDING_MODEL, PER_HARNESS_MIGRATION_INVENTORY, PER_HARNESS_MODEL_KEYS, ConfigProfilesSchema, DREAM_TASK_PROMOTION_DEFAULTS, MagicContextConfigSchema, LIVE_RELOAD_CONFIG_PATHS, deriveDefaultProtectedTokens };
|