@cortexkit/pi-magic-context 0.41.0 → 0.41.1
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/historian-calibration-extension.js +20 -14
- package/dist/{index-ts6nabp0.js → index-0jgz8yja.js} +553 -278
- package/dist/{index-3k71e196.js → index-q2vgz0j1.js} +87 -2
- package/dist/index.js +292 -59
- package/dist/{safe-notification-target-g8fx80va.js → safe-notification-target-hjcb423r.js} +1 -1
- package/dist/subagent-entry.js +2 -2
- package/dist/transformers-web.js +24570 -0
- package/dist/transformers.node-b1wa0hgx.js +28808 -0
- package/package.json +8 -3
- /package/dist/{index-wnrygn5h.js → index-y63nbvkk.js} +0 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
log,
|
|
7
7
|
sanitizeDiagnosticText,
|
|
8
8
|
sessionLog
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-q2vgz0j1.js";
|
|
10
10
|
import {
|
|
11
11
|
__commonJS,
|
|
12
12
|
__export,
|
|
@@ -8830,6 +8830,9 @@ function gitRootDirectory(canonical) {
|
|
|
8830
8830
|
return null;
|
|
8831
8831
|
}
|
|
8832
8832
|
}
|
|
8833
|
+
function directoryHasGitMetadata(directory) {
|
|
8834
|
+
return gitRootDirectory(path.resolve(directory)) !== null;
|
|
8835
|
+
}
|
|
8833
8836
|
function resolveProjectIdentityForSession(directory, allowHomeProject = false) {
|
|
8834
8837
|
const canonicalHome = canonicalUserHomeDirectory();
|
|
8835
8838
|
const canonicalDirectory = (() => {
|
|
@@ -18261,6 +18264,16 @@ function persistMessageHistoryOrphanSweepState(db, cursor, lastSweptAt) {
|
|
|
18261
18264
|
cursor_session_id = excluded.cursor_session_id,
|
|
18262
18265
|
last_swept_at = excluded.last_swept_at`).run(cursor, lastSweptAt);
|
|
18263
18266
|
}
|
|
18267
|
+
function getOpenCodeSessionScopedCandidateSourceSql() {
|
|
18268
|
+
return SESSION_SCOPED_TABLES.filter((definition) => definition.harnessScoped === true).map((definition) => {
|
|
18269
|
+
const predicates = ["session_id IS NOT NULL", "harness = 'opencode'"];
|
|
18270
|
+
if (definition.extraPredicate)
|
|
18271
|
+
predicates.push(definition.extraPredicate);
|
|
18272
|
+
return `SELECT session_id FROM ${definition.table} WHERE ${predicates.join(" AND ")}`;
|
|
18273
|
+
}).join(`
|
|
18274
|
+
UNION
|
|
18275
|
+
`);
|
|
18276
|
+
}
|
|
18264
18277
|
function sweepOrphanedOpenCodeMessageIndexes(db, openReadableOpenCodeDb, options = {}) {
|
|
18265
18278
|
const now = options.now ?? Date.now();
|
|
18266
18279
|
const batchSize = Math.max(1, Math.floor(options.batchSize ?? MESSAGE_HISTORY_ORPHAN_SWEEP_BATCH_SIZE));
|
|
@@ -18284,13 +18297,19 @@ function sweepOrphanedOpenCodeMessageIndexes(db, openReadableOpenCodeDb, options
|
|
|
18284
18297
|
}
|
|
18285
18298
|
try {
|
|
18286
18299
|
const cutoff = now - safetyAgeMs;
|
|
18300
|
+
const candidateSourceSql = getOpenCodeSessionScopedCandidateSourceSql();
|
|
18287
18301
|
const candidates = db.prepare(`SELECT session_id
|
|
18288
|
-
FROM
|
|
18289
|
-
WHERE
|
|
18290
|
-
AND
|
|
18291
|
-
|
|
18302
|
+
FROM (${candidateSourceSql}) AS session_candidates
|
|
18303
|
+
WHERE session_id > ?
|
|
18304
|
+
AND NOT EXISTS (
|
|
18305
|
+
SELECT 1
|
|
18306
|
+
FROM message_history_index
|
|
18307
|
+
WHERE message_history_index.session_id = session_candidates.session_id
|
|
18308
|
+
AND message_history_index.harness = 'opencode'
|
|
18309
|
+
AND message_history_index.updated_at > ?
|
|
18310
|
+
)
|
|
18292
18311
|
ORDER BY session_id ASC
|
|
18293
|
-
LIMIT ?`).all(
|
|
18312
|
+
LIMIT ?`).all(cursor, cutoff, batchSize);
|
|
18294
18313
|
const sessionExists = openCodeDb.prepare("SELECT 1 FROM session WHERE id = ? LIMIT 1");
|
|
18295
18314
|
const missingSessionIds = candidates.filter((candidate) => !sessionExists.get(candidate.session_id)).map((candidate) => candidate.session_id);
|
|
18296
18315
|
const nextCursor = candidates.length < batchSize ? "" : candidates[candidates.length - 1]?.session_id ?? cursor;
|
|
@@ -18299,7 +18318,17 @@ function sweepOrphanedOpenCodeMessageIndexes(db, openReadableOpenCodeDb, options
|
|
|
18299
18318
|
let committed = false;
|
|
18300
18319
|
let deleted = 0;
|
|
18301
18320
|
try {
|
|
18302
|
-
const stillEligible = db.prepare(
|
|
18321
|
+
const stillEligible = db.prepare(`SELECT 1
|
|
18322
|
+
FROM (${candidateSourceSql}) AS session_candidates
|
|
18323
|
+
WHERE session_id = ?
|
|
18324
|
+
AND NOT EXISTS (
|
|
18325
|
+
SELECT 1
|
|
18326
|
+
FROM message_history_index
|
|
18327
|
+
WHERE message_history_index.session_id = session_candidates.session_id
|
|
18328
|
+
AND message_history_index.harness = 'opencode'
|
|
18329
|
+
AND message_history_index.updated_at > ?
|
|
18330
|
+
)
|
|
18331
|
+
LIMIT 1`);
|
|
18303
18332
|
const eligibleSessionIds = missingSessionIds.filter((sessionId) => stillEligible.get(sessionId, cutoff));
|
|
18304
18333
|
deleteSessionScopedRows(db, eligibleSessionIds, "opencode");
|
|
18305
18334
|
deleted = eligibleSessionIds.length;
|
|
@@ -19165,6 +19194,7 @@ function markNoteChecked(db, noteId) {
|
|
|
19165
19194
|
// ../plugin/src/features/magic-context/storage-ops.ts
|
|
19166
19195
|
var queuePendingOpStatements = new WeakMap;
|
|
19167
19196
|
var getPendingOpsStatements = new WeakMap;
|
|
19197
|
+
var getPendingOpsCountStatements = new WeakMap;
|
|
19168
19198
|
var clearPendingOpsStatements = new WeakMap;
|
|
19169
19199
|
var removePendingOpStatements = new WeakMap;
|
|
19170
19200
|
function getQueuePendingOpStatement(db) {
|
|
@@ -19225,6 +19255,19 @@ function getPendingOps(db, sessionId) {
|
|
|
19225
19255
|
const rows = getPendingOpsStatement(db).all(sessionId).filter(isPendingOpRow);
|
|
19226
19256
|
return rows.map(toPendingOp).filter((op) => op !== null);
|
|
19227
19257
|
}
|
|
19258
|
+
function getPendingOpsCount(db, sessionId) {
|
|
19259
|
+
try {
|
|
19260
|
+
let statement = getPendingOpsCountStatements.get(db);
|
|
19261
|
+
if (!statement) {
|
|
19262
|
+
statement = db.prepare("SELECT COUNT(*) AS count FROM pending_ops WHERE session_id = ?");
|
|
19263
|
+
getPendingOpsCountStatements.set(db, statement);
|
|
19264
|
+
}
|
|
19265
|
+
const row = statement.get(sessionId);
|
|
19266
|
+
return typeof row?.count === "number" && Number.isFinite(row.count) ? row.count : null;
|
|
19267
|
+
} catch {
|
|
19268
|
+
return null;
|
|
19269
|
+
}
|
|
19270
|
+
}
|
|
19228
19271
|
function clearPendingOps(db, sessionId) {
|
|
19229
19272
|
getClearPendingOpsStatement(db).run(sessionId);
|
|
19230
19273
|
}
|
|
@@ -36568,6 +36611,7 @@ var BaseEmbeddingConfigSchema = exports_external.object({
|
|
|
36568
36611
|
query_input_type: exports_external.string().optional().describe("Optional input_type for query (search) embeddings on asymmetric models (e.g. NVIDIA NIM 'query'). When unset, query embeddings use embedding.input_type. Passage/stored content always uses embedding.input_type."),
|
|
36569
36612
|
truncate: exports_external.string().optional().describe("Optional truncate mode sent in the embedding request body (e.g. NVIDIA NIM accepts 'NONE' | 'START' | 'END'). Omitted from the request when unset."),
|
|
36570
36613
|
max_input_tokens: exports_external.number().int().positive().optional().describe("Optional maximum input tokens for chunk embeddings. Defaults conservatively to 512 when omitted."),
|
|
36614
|
+
local_runtime: exports_external.enum(["auto", "native", "wasm"]).default("auto").describe("Local provider only: ONNX runtime selection. 'auto' uses native under Node and uses WASM under Bun versions before 1.4.0, where Bun's NAPI teardown race can panic on quit; native is restored automatically on Bun 1.4.0+. Set 'native' only to prefer speed while accepting that pre-1.4.0 Bun crash risk, or 'wasm' to avoid loading the native addon."),
|
|
36571
36615
|
local_dtype: exports_external.enum([
|
|
36572
36616
|
"auto",
|
|
36573
36617
|
"fp32",
|
|
@@ -36624,6 +36668,7 @@ var EmbeddingConfigSchema = BaseEmbeddingConfigSchema.transform((data) => {
|
|
|
36624
36668
|
return {
|
|
36625
36669
|
provider: "local",
|
|
36626
36670
|
model: data.model?.trim() || DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
36671
|
+
local_runtime: data.local_runtime,
|
|
36627
36672
|
...data.max_input_tokens ? { max_input_tokens: data.max_input_tokens } : {},
|
|
36628
36673
|
...data.local_dtype ? { local_dtype: data.local_dtype } : {}
|
|
36629
36674
|
};
|
|
@@ -36704,7 +36749,8 @@ var MagicContextConfigSchema = exports_external.object({
|
|
|
36704
36749
|
}).default({ enforce_private_permissions: true }).describe("Storage permission policy. The default keeps session content and memories owner-private. Disabling enforcement is for trusted shared-group storage managed externally; every group member able to read the storage can read all stored session content and memories."),
|
|
36705
36750
|
embedding: EmbeddingConfigSchema.default({
|
|
36706
36751
|
provider: "local",
|
|
36707
|
-
model: DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
36752
|
+
model: DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
36753
|
+
local_runtime: "auto"
|
|
36708
36754
|
}).describe("Embedding provider configuration"),
|
|
36709
36755
|
subc: exports_external.object({
|
|
36710
36756
|
connection_file: exports_external.string().trim().min(1).transform(expandConfigPath).describe("Path to the owner-only subc connection file.")
|
|
@@ -40630,39 +40676,76 @@ function mapBackfillCandidateRows(rows) {
|
|
|
40630
40676
|
title: row.title
|
|
40631
40677
|
}));
|
|
40632
40678
|
}
|
|
40633
|
-
|
|
40634
|
-
|
|
40635
|
-
|
|
40636
|
-
|
|
40637
|
-
|
|
40638
|
-
|
|
40639
|
-
|
|
40640
|
-
|
|
40641
|
-
c.title AS title
|
|
40642
|
-
FROM compartments c
|
|
40643
|
-
JOIN session_projects sp
|
|
40644
|
-
ON sp.session_id = c.session_id
|
|
40645
|
-
AND sp.harness = c.harness
|
|
40646
|
-
AND sp.project_path = ?
|
|
40647
|
-
WHERE c.session_id = ?
|
|
40648
|
-
AND c.start_message IS NOT NULL
|
|
40649
|
-
AND c.end_message IS NOT NULL
|
|
40650
|
-
AND c.id NOT IN (${placeholders3})
|
|
40651
|
-
AND NOT EXISTS (
|
|
40652
|
-
SELECT 1
|
|
40653
|
-
FROM compartment_chunk_embeddings current
|
|
40654
|
-
WHERE current.compartment_id = c.id
|
|
40655
|
-
AND current.project_path = ?
|
|
40656
|
-
AND current.model_id = ?
|
|
40657
|
-
)
|
|
40658
|
-
ORDER BY c.start_message ASC, c.id ASC
|
|
40659
|
-
LIMIT ?`);
|
|
40660
|
-
const rows2 = stmt2.all(projectPath, sessionId, ...excludeIds, projectPath, modelId, Math.max(1, limit));
|
|
40661
|
-
return mapBackfillCandidateRows(rows2);
|
|
40679
|
+
function classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens) {
|
|
40680
|
+
const canonicalText = buildCanonicalChunkTextFromFts(db, candidate.sessionId, candidate.startMessage, candidate.endMessage) || buildCompartmentSummaryFallbackText(db, candidate.id);
|
|
40681
|
+
const windows = chunkCanonicalText(canonicalText, candidate.startMessage, candidate.endMessage, maxInputTokens);
|
|
40682
|
+
const existing = getExistingChunkHashes(db, candidate.id, modelId, projectPath);
|
|
40683
|
+
if (windows.some((window) => !existing.has(window.windowIndex)))
|
|
40684
|
+
return "missing";
|
|
40685
|
+
if (existing.size !== windows.length || windows.some((window) => existing.get(window.windowIndex) !== window.chunkHash)) {
|
|
40686
|
+
return "stale";
|
|
40662
40687
|
}
|
|
40663
|
-
|
|
40664
|
-
|
|
40665
|
-
|
|
40688
|
+
return null;
|
|
40689
|
+
}
|
|
40690
|
+
function selectHashIncompleteChunkCandidates(db, projectPath, modelId, candidates, limit, maxInputTokens) {
|
|
40691
|
+
const missing = [];
|
|
40692
|
+
const stale = [];
|
|
40693
|
+
for (const candidate of candidates) {
|
|
40694
|
+
const defect = classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens);
|
|
40695
|
+
if (defect === "missing")
|
|
40696
|
+
missing.push(candidate);
|
|
40697
|
+
else if (defect === "stale")
|
|
40698
|
+
stale.push(candidate);
|
|
40699
|
+
}
|
|
40700
|
+
return [...missing, ...stale].slice(0, limit);
|
|
40701
|
+
}
|
|
40702
|
+
var sessionBackfillCandidateStatements = new WeakMap;
|
|
40703
|
+
function loadUnembeddedSessionChunkCandidates(db, projectPath, sessionId, modelId, limit, excludeIds, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS) {
|
|
40704
|
+
const exclusions = excludeIds && excludeIds.length > 0 ? excludeIds : [];
|
|
40705
|
+
const exclusionSql = exclusions.length > 0 ? `AND c.id NOT IN (${exclusions.map(() => "?").join(", ")})` : "";
|
|
40706
|
+
const stmt = exclusions.length > 0 ? db.prepare(`SELECT c.id AS id,
|
|
40707
|
+
c.session_id AS sessionId,
|
|
40708
|
+
c.start_message AS startMessage,
|
|
40709
|
+
c.end_message AS endMessage,
|
|
40710
|
+
c.title AS title
|
|
40711
|
+
FROM compartments c
|
|
40712
|
+
JOIN session_projects sp
|
|
40713
|
+
ON sp.session_id = c.session_id
|
|
40714
|
+
AND sp.harness = c.harness
|
|
40715
|
+
AND sp.project_path = ?
|
|
40716
|
+
WHERE c.session_id = ?
|
|
40717
|
+
AND c.start_message IS NOT NULL
|
|
40718
|
+
AND c.end_message IS NOT NULL
|
|
40719
|
+
${exclusionSql}
|
|
40720
|
+
ORDER BY c.start_message ASC, c.id ASC`) : (() => {
|
|
40721
|
+
let cached2 = sessionBackfillCandidateStatements.get(db);
|
|
40722
|
+
if (!cached2) {
|
|
40723
|
+
cached2 = db.prepare(`SELECT c.id AS id,
|
|
40724
|
+
c.session_id AS sessionId,
|
|
40725
|
+
c.start_message AS startMessage,
|
|
40726
|
+
c.end_message AS endMessage,
|
|
40727
|
+
c.title AS title
|
|
40728
|
+
FROM compartments c
|
|
40729
|
+
JOIN session_projects sp
|
|
40730
|
+
ON sp.session_id = c.session_id
|
|
40731
|
+
AND sp.harness = c.harness
|
|
40732
|
+
AND sp.project_path = ?
|
|
40733
|
+
WHERE c.session_id = ?
|
|
40734
|
+
AND c.start_message IS NOT NULL
|
|
40735
|
+
AND c.end_message IS NOT NULL
|
|
40736
|
+
ORDER BY c.start_message ASC, c.id ASC`);
|
|
40737
|
+
sessionBackfillCandidateStatements.set(db, cached2);
|
|
40738
|
+
}
|
|
40739
|
+
return cached2;
|
|
40740
|
+
})();
|
|
40741
|
+
const rows = stmt.all(projectPath, sessionId, ...exclusions);
|
|
40742
|
+
return selectHashIncompleteChunkCandidates(db, projectPath, modelId, mapBackfillCandidateRows(rows), Math.max(1, limit), maxInputTokens);
|
|
40743
|
+
}
|
|
40744
|
+
function countUnembeddedSessionCompartments(db, projectPath, sessionId, modelId, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS) {
|
|
40745
|
+
return loadUnembeddedSessionChunkCandidates(db, projectPath, sessionId, modelId, Number.MAX_SAFE_INTEGER, undefined, maxInputTokens).length;
|
|
40746
|
+
}
|
|
40747
|
+
function countSessionCompartmentEmbedCoverage(db, projectPath, sessionId, modelId, maxInputTokens = DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS) {
|
|
40748
|
+
const rows = db.prepare(`SELECT c.id AS id,
|
|
40666
40749
|
c.session_id AS sessionId,
|
|
40667
40750
|
c.start_message AS startMessage,
|
|
40668
40751
|
c.end_message AS endMessage,
|
|
@@ -40675,60 +40758,15 @@ function loadUnembeddedSessionChunkCandidates(db, projectPath, sessionId, modelI
|
|
|
40675
40758
|
WHERE c.session_id = ?
|
|
40676
40759
|
AND c.start_message IS NOT NULL
|
|
40677
40760
|
AND c.end_message IS NOT NULL
|
|
40678
|
-
|
|
40679
|
-
|
|
40680
|
-
|
|
40681
|
-
|
|
40682
|
-
|
|
40683
|
-
|
|
40684
|
-
|
|
40685
|
-
ORDER BY c.start_message ASC, c.id ASC
|
|
40686
|
-
LIMIT ?`);
|
|
40687
|
-
sessionBackfillCandidateStatements.set(db, stmt);
|
|
40761
|
+
ORDER BY c.start_message ASC, c.id ASC`).all(projectPath, sessionId);
|
|
40762
|
+
const candidates = mapBackfillCandidateRows(rows);
|
|
40763
|
+
let embedded = 0;
|
|
40764
|
+
for (const candidate of candidates) {
|
|
40765
|
+
if (classifyChunkCoverageDefect(db, projectPath, modelId, candidate, maxInputTokens) === null) {
|
|
40766
|
+
embedded += 1;
|
|
40767
|
+
}
|
|
40688
40768
|
}
|
|
40689
|
-
|
|
40690
|
-
return mapBackfillCandidateRows(rows);
|
|
40691
|
-
}
|
|
40692
|
-
function countUnembeddedSessionCompartments(db, projectPath, sessionId, modelId) {
|
|
40693
|
-
const row = db.prepare(`SELECT COUNT(*) AS n
|
|
40694
|
-
FROM compartments c
|
|
40695
|
-
JOIN session_projects sp
|
|
40696
|
-
ON sp.session_id = c.session_id
|
|
40697
|
-
AND sp.harness = c.harness
|
|
40698
|
-
AND sp.project_path = ?
|
|
40699
|
-
WHERE c.session_id = ?
|
|
40700
|
-
AND c.start_message IS NOT NULL
|
|
40701
|
-
AND c.end_message IS NOT NULL
|
|
40702
|
-
AND NOT EXISTS (
|
|
40703
|
-
SELECT 1
|
|
40704
|
-
FROM compartment_chunk_embeddings current
|
|
40705
|
-
WHERE current.compartment_id = c.id
|
|
40706
|
-
AND current.project_path = ?
|
|
40707
|
-
AND current.model_id = ?
|
|
40708
|
-
)`).get(projectPath, sessionId, projectPath, modelId);
|
|
40709
|
-
return typeof row?.n === "number" ? row.n : 0;
|
|
40710
|
-
}
|
|
40711
|
-
function countSessionCompartmentEmbedCoverage(db, projectPath, sessionId, modelId) {
|
|
40712
|
-
const row = db.prepare(`SELECT
|
|
40713
|
-
COUNT(*) AS total,
|
|
40714
|
-
SUM(CASE WHEN EXISTS (
|
|
40715
|
-
SELECT 1 FROM compartment_chunk_embeddings e
|
|
40716
|
-
WHERE e.compartment_id = c.id
|
|
40717
|
-
AND e.project_path = ?
|
|
40718
|
-
AND e.model_id = ?
|
|
40719
|
-
) THEN 1 ELSE 0 END) AS embedded
|
|
40720
|
-
FROM compartments c
|
|
40721
|
-
JOIN session_projects sp
|
|
40722
|
-
ON sp.session_id = c.session_id
|
|
40723
|
-
AND sp.harness = c.harness
|
|
40724
|
-
AND sp.project_path = ?
|
|
40725
|
-
WHERE c.session_id = ?
|
|
40726
|
-
AND c.start_message IS NOT NULL
|
|
40727
|
-
AND c.end_message IS NOT NULL`).get(projectPath, modelId, projectPath, sessionId);
|
|
40728
|
-
return {
|
|
40729
|
-
total: typeof row?.total === "number" ? row.total : 0,
|
|
40730
|
-
embedded: typeof row?.embedded === "number" ? row.embedded : 0
|
|
40731
|
-
};
|
|
40769
|
+
return { embedded, total: candidates.length };
|
|
40732
40770
|
}
|
|
40733
40771
|
|
|
40734
40772
|
// ../plugin/src/features/magic-context/memory/cosine-similarity.ts
|
|
@@ -42101,21 +42139,28 @@ var SYNAPSE_DEFAULT_MODEL = "gte-modernbert-base-f16";
|
|
|
42101
42139
|
var SYNAPSE_MAX_INPUT_TOKENS = 8192;
|
|
42102
42140
|
var SYNAPSE_DEFAULT_QUERY_TIMEOUT_MS = 3000;
|
|
42103
42141
|
var SYNAPSE_DEFAULT_BATCH_TIMEOUT_MS = 120000;
|
|
42142
|
+
var SYNAPSE_CERTIFICATION_REFUSAL_REASONS = new Set([
|
|
42143
|
+
"not_certified",
|
|
42144
|
+
"probe_required",
|
|
42145
|
+
"migration_required"
|
|
42146
|
+
]);
|
|
42104
42147
|
|
|
42105
42148
|
class SynapseEmbeddingError extends Error {
|
|
42106
42149
|
code;
|
|
42107
42150
|
retryAfterMs;
|
|
42108
42151
|
permanent;
|
|
42152
|
+
refusalReason;
|
|
42109
42153
|
constructor(code, message, options) {
|
|
42110
42154
|
super(message, options?.cause === undefined ? undefined : { cause: options.cause });
|
|
42111
42155
|
this.name = "SynapseEmbeddingError";
|
|
42112
42156
|
this.code = code;
|
|
42113
42157
|
this.permanent = options?.permanent ?? isPermanentSynapseCode(code);
|
|
42114
42158
|
this.retryAfterMs = options?.retryAfterMs ?? (this.permanent ? undefined : 100);
|
|
42159
|
+
this.refusalReason = options?.refusalReason;
|
|
42115
42160
|
}
|
|
42116
42161
|
}
|
|
42117
42162
|
function isPermanentSynapseCode(code) {
|
|
42118
|
-
return code === "artifact_invalid" || code === "substitution_rejected" || code === "not_certified" || code === "probe_required" || code === "idempotency_conflict" || code === "schema_violation";
|
|
42163
|
+
return code === "artifact_invalid" || code === "substitution_rejected" || code === "not_certified" || code === "probe_required" || code === "idempotency_conflict" || code === "schema_violation" || code === "certification_refused" || code === "needs_reauth";
|
|
42119
42164
|
}
|
|
42120
42165
|
function asRecord(value) {
|
|
42121
42166
|
return value !== null && typeof value === "object" ? value : null;
|
|
@@ -42141,11 +42186,21 @@ function readErrorCode(value) {
|
|
|
42141
42186
|
}
|
|
42142
42187
|
return;
|
|
42143
42188
|
}
|
|
42189
|
+
function readCertificationRefusalReason(value) {
|
|
42190
|
+
if (!(value instanceof SubcCallError))
|
|
42191
|
+
return;
|
|
42192
|
+
const detail = value.detail;
|
|
42193
|
+
if (typeof detail === "string")
|
|
42194
|
+
return detail;
|
|
42195
|
+
const record2 = asRecord(detail);
|
|
42196
|
+
return typeof record2?.reason === "string" ? record2.reason : undefined;
|
|
42197
|
+
}
|
|
42144
42198
|
function classifyError(value) {
|
|
42145
42199
|
if (value instanceof SynapseEmbeddingError)
|
|
42146
42200
|
return value;
|
|
42147
42201
|
const code = readErrorCode(value) ?? (value instanceof Error ? value.name : "transport");
|
|
42148
42202
|
const normalized = code.toLowerCase();
|
|
42203
|
+
const refusalReason = readCertificationRefusalReason(value);
|
|
42149
42204
|
let mapped = "transport";
|
|
42150
42205
|
if (normalized.includes("queue_full"))
|
|
42151
42206
|
mapped = "queue_full";
|
|
@@ -42157,12 +42212,16 @@ function classifyError(value) {
|
|
|
42157
42212
|
mapped = "artifact_invalid";
|
|
42158
42213
|
else if (normalized.includes("substitution"))
|
|
42159
42214
|
mapped = "substitution_rejected";
|
|
42215
|
+
else if (normalized === "certification_refused")
|
|
42216
|
+
mapped = "certification_refused";
|
|
42160
42217
|
else if (normalized.includes("not_certified"))
|
|
42161
42218
|
mapped = "not_certified";
|
|
42162
42219
|
else if (normalized.includes("probe_required"))
|
|
42163
42220
|
mapped = "probe_required";
|
|
42164
42221
|
else if (normalized.includes("idempotency_conflict"))
|
|
42165
42222
|
mapped = "idempotency_conflict";
|
|
42223
|
+
else if (normalized.includes("needs_reauth"))
|
|
42224
|
+
mapped = "needs_reauth";
|
|
42166
42225
|
else if (normalized.includes("schema"))
|
|
42167
42226
|
mapped = "schema_violation";
|
|
42168
42227
|
else if (normalized.includes("module_restarted") || normalized.includes("module restarted"))
|
|
@@ -42170,9 +42229,41 @@ function classifyError(value) {
|
|
|
42170
42229
|
const message = value instanceof Error ? value.message : String(value);
|
|
42171
42230
|
return new SynapseEmbeddingError(mapped, message, {
|
|
42172
42231
|
retryAfterMs: readRetryAfter(value) ?? (isPermanentSynapseCode(mapped) ? undefined : 100),
|
|
42173
|
-
cause: value
|
|
42232
|
+
cause: value,
|
|
42233
|
+
refusalReason
|
|
42174
42234
|
});
|
|
42175
42235
|
}
|
|
42236
|
+
function embeddingFailureFor(error51) {
|
|
42237
|
+
const typedReason = error51.refusalReason;
|
|
42238
|
+
if (typedReason !== undefined && SYNAPSE_CERTIFICATION_REFUSAL_REASONS.has(typedReason) || error51.code === "not_certified" || error51.code === "probe_required") {
|
|
42239
|
+
return {
|
|
42240
|
+
class: "certification_refusal",
|
|
42241
|
+
reason: `SYNAPSE certification refused embedding: ${typedReason ?? error51.code}`,
|
|
42242
|
+
retryable: false
|
|
42243
|
+
};
|
|
42244
|
+
}
|
|
42245
|
+
if (error51.code === "certification_refused") {
|
|
42246
|
+
return {
|
|
42247
|
+
class: "certification_refusal",
|
|
42248
|
+
reason: `SYNAPSE certification refused embedding: ${typedReason ?? "unknown reason"}`,
|
|
42249
|
+
retryable: false
|
|
42250
|
+
};
|
|
42251
|
+
}
|
|
42252
|
+
if (typedReason === "needs_reauth" || typedReason === "needs_reauth_expired") {
|
|
42253
|
+
return {
|
|
42254
|
+
class: "credential_required",
|
|
42255
|
+
reason: "SYNAPSE requires reauthentication",
|
|
42256
|
+
retryable: false
|
|
42257
|
+
};
|
|
42258
|
+
}
|
|
42259
|
+
if (error51.code === "substitution_rejected") {
|
|
42260
|
+
return { class: "substitution_rejected", reason: error51.message, retryable: false };
|
|
42261
|
+
}
|
|
42262
|
+
if (error51.code === "schema_violation" || error51.code === "artifact_invalid") {
|
|
42263
|
+
return { class: "invalid_envelope", reason: error51.message, retryable: false };
|
|
42264
|
+
}
|
|
42265
|
+
return { class: "transport_error", reason: error51.message, retryable: !error51.permanent };
|
|
42266
|
+
}
|
|
42176
42267
|
function wait(ms) {
|
|
42177
42268
|
return new Promise((resolve5) => setTimeout(resolve5, ms));
|
|
42178
42269
|
}
|
|
@@ -42292,6 +42383,7 @@ class SynapseEmbeddingProvider {
|
|
|
42292
42383
|
initialized = false;
|
|
42293
42384
|
initializing = null;
|
|
42294
42385
|
permanentFailure = false;
|
|
42386
|
+
lastFailureReason = null;
|
|
42295
42387
|
batchLimit = 16;
|
|
42296
42388
|
tokenBudget = null;
|
|
42297
42389
|
constructor(options) {
|
|
@@ -42366,9 +42458,11 @@ class SynapseEmbeddingProvider {
|
|
|
42366
42458
|
this.tokenBudget = metadata.recommended_token_budget ?? this.tokenBudget;
|
|
42367
42459
|
}
|
|
42368
42460
|
this.initialized = true;
|
|
42461
|
+
this.recordSuccess();
|
|
42369
42462
|
return true;
|
|
42370
42463
|
} catch (error51) {
|
|
42371
42464
|
const classified = classifyError(error51);
|
|
42465
|
+
this.recordFailure(classified);
|
|
42372
42466
|
if (classified.permanent) {
|
|
42373
42467
|
this.permanentFailure = true;
|
|
42374
42468
|
log(`[magic-context] Synapse lane disabled: ${classified.code}: ${classified.message}`);
|
|
@@ -42395,6 +42489,7 @@ class SynapseEmbeddingProvider {
|
|
|
42395
42489
|
if (!extracted)
|
|
42396
42490
|
throw new SynapseEmbeddingError("schema_violation", "Synapse query returned no vector");
|
|
42397
42491
|
this.validateResponse(extracted.metadata, extracted.vector.length);
|
|
42492
|
+
this.recordSuccess();
|
|
42398
42493
|
return extracted.vector;
|
|
42399
42494
|
} catch (error51) {
|
|
42400
42495
|
this.logCallFailure(error51, "embed.query");
|
|
@@ -42458,6 +42553,7 @@ class SynapseEmbeddingProvider {
|
|
|
42458
42553
|
const vectorArray = Float32Array.from(vector);
|
|
42459
42554
|
this.validateResponse({ ...batchEnvelope, ...item }, vectorArray.length);
|
|
42460
42555
|
output.set(id, vectorArray);
|
|
42556
|
+
this.recordSuccess();
|
|
42461
42557
|
}
|
|
42462
42558
|
} catch (error51) {
|
|
42463
42559
|
const classified = classifyError(error51);
|
|
@@ -42480,6 +42576,9 @@ class SynapseEmbeddingProvider {
|
|
|
42480
42576
|
isLoaded() {
|
|
42481
42577
|
return this.initialized;
|
|
42482
42578
|
}
|
|
42579
|
+
getLastFailureReason() {
|
|
42580
|
+
return this.lastFailureReason;
|
|
42581
|
+
}
|
|
42483
42582
|
requestConstraints(extra) {
|
|
42484
42583
|
const metadata = this.metadata;
|
|
42485
42584
|
if (!metadata)
|
|
@@ -42597,11 +42696,18 @@ class SynapseEmbeddingProvider {
|
|
|
42597
42696
|
}
|
|
42598
42697
|
logCallFailure(error51, operation) {
|
|
42599
42698
|
const classified = classifyError(error51);
|
|
42699
|
+
this.recordFailure(classified);
|
|
42600
42700
|
if (classified.permanent)
|
|
42601
42701
|
this.permanentFailure = true;
|
|
42602
42702
|
const suffix = classified.retryAfterMs === undefined ? "" : ` retry_after_ms=${classified.retryAfterMs}`;
|
|
42603
42703
|
log(`[magic-context] Synapse ${operation} failed: ${classified.code}${suffix}: ${classified.message}`);
|
|
42604
42704
|
}
|
|
42705
|
+
recordFailure(error51) {
|
|
42706
|
+
this.lastFailureReason = embeddingFailureFor(error51);
|
|
42707
|
+
}
|
|
42708
|
+
recordSuccess() {
|
|
42709
|
+
this.lastFailureReason = null;
|
|
42710
|
+
}
|
|
42605
42711
|
}
|
|
42606
42712
|
|
|
42607
42713
|
// ../plugin/src/features/magic-context/memory/normalize-hash.ts
|
|
@@ -42655,6 +42761,32 @@ import { chmodSync as chmodSync2, mkdirSync as mkdirSync4 } from "node:fs";
|
|
|
42655
42761
|
import { open, stat, unlink, writeFile } from "node:fs/promises";
|
|
42656
42762
|
import { dirname as dirname7, join as join9 } from "node:path";
|
|
42657
42763
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
42764
|
+
var BUN_NAPI_TEARDOWN_FIX_VERSION = [1, 4, 0];
|
|
42765
|
+
function currentLocalEmbeddingHost() {
|
|
42766
|
+
const bun = globalThis.Bun;
|
|
42767
|
+
const bunVersion = typeof process !== "undefined" && typeof process.versions?.bun === "string" ? process.versions.bun : undefined;
|
|
42768
|
+
return {
|
|
42769
|
+
isElectron: typeof process !== "undefined" && Boolean(process.versions?.electron),
|
|
42770
|
+
isBun: Boolean(bun) || Boolean(bunVersion),
|
|
42771
|
+
bunVersion
|
|
42772
|
+
};
|
|
42773
|
+
}
|
|
42774
|
+
function bunHasNapiTeardownFix(version2) {
|
|
42775
|
+
const match = version2?.match(/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/);
|
|
42776
|
+
if (!match || match[4])
|
|
42777
|
+
return false;
|
|
42778
|
+
const parsed = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
42779
|
+
return parsed.some((part) => !Number.isSafeInteger(part)) ? false : parsed[0] > BUN_NAPI_TEARDOWN_FIX_VERSION[0] || parsed[0] === BUN_NAPI_TEARDOWN_FIX_VERSION[0] && (parsed[1] > BUN_NAPI_TEARDOWN_FIX_VERSION[1] || parsed[1] === BUN_NAPI_TEARDOWN_FIX_VERSION[1] && parsed[2] >= BUN_NAPI_TEARDOWN_FIX_VERSION[2]);
|
|
42780
|
+
}
|
|
42781
|
+
function resolveLocalEmbeddingRuntime(preference = "auto", host = currentLocalEmbeddingHost()) {
|
|
42782
|
+
if (preference === "native" || preference === "wasm")
|
|
42783
|
+
return preference;
|
|
42784
|
+
if (host.isElectron)
|
|
42785
|
+
return "electron";
|
|
42786
|
+
if (host.isBun && !bunHasNapiTeardownFix(host.bunVersion))
|
|
42787
|
+
return "wasm";
|
|
42788
|
+
return "native";
|
|
42789
|
+
}
|
|
42658
42790
|
var LOCK_POLL_MS = 150;
|
|
42659
42791
|
var STALE_LOCK_MS = 3 * 60000;
|
|
42660
42792
|
var MAX_LOCK_WAIT_MS = 5 * 60000;
|
|
@@ -42708,20 +42840,21 @@ function startLockHeartbeat(lockPath) {
|
|
|
42708
42840
|
}
|
|
42709
42841
|
var localEmbeddingRuntimeMode = "native";
|
|
42710
42842
|
var wasmRuntimeInjected = false;
|
|
42711
|
-
var
|
|
42843
|
+
var localEmbeddingHostForRuntime = currentLocalEmbeddingHost;
|
|
42712
42844
|
var importWasmOrtForRuntime = async () => {
|
|
42713
|
-
const
|
|
42714
|
-
|
|
42845
|
+
const { createRequire: createRequireFn } = await import("node:module");
|
|
42846
|
+
const requireFn = createRequireFn(import.meta.url);
|
|
42847
|
+
const ortEntry = requireFn.resolve("onnxruntime-web");
|
|
42848
|
+
return {
|
|
42849
|
+
module: await import("onnxruntime-web"),
|
|
42850
|
+
entryPath: ortEntry
|
|
42851
|
+
};
|
|
42715
42852
|
};
|
|
42716
42853
|
var importTransformersForRuntime = async () => {
|
|
42717
|
-
|
|
42718
|
-
return await import(transformersSpec);
|
|
42854
|
+
return await import("./transformers.node-b1wa0hgx.js");
|
|
42719
42855
|
};
|
|
42720
42856
|
var importTransformersWasmFallbackForRuntime = async () => {
|
|
42721
|
-
const
|
|
42722
|
-
const requireFn = createRequireFn(import.meta.url);
|
|
42723
|
-
const nodeEntry = requireFn.resolve("@huggingface/transformers");
|
|
42724
|
-
const webEntry = pathToFileURL2(join9(dirname7(nodeEntry), "transformers.web.js")).href;
|
|
42857
|
+
const webEntry = new URL("./transformers-web.js", import.meta.url).href;
|
|
42725
42858
|
return await import(webEntry);
|
|
42726
42859
|
};
|
|
42727
42860
|
var modelCacheDirForRuntime = () => join9(getMagicContextStorageDir(), "models");
|
|
@@ -42739,17 +42872,9 @@ async function injectWasmOrt() {
|
|
|
42739
42872
|
if (wasmRuntimeInjected)
|
|
42740
42873
|
return true;
|
|
42741
42874
|
try {
|
|
42742
|
-
const ortWeb = await importWasmOrtForRuntime();
|
|
42743
|
-
|
|
42744
|
-
|
|
42745
|
-
const requireFn = createRequireFn(import.meta.url);
|
|
42746
|
-
const mainEntry = requireFn.resolve("onnxruntime-web");
|
|
42747
|
-
const distDir = dirname7(mainEntry);
|
|
42748
|
-
if (ortWeb.env?.wasm) {
|
|
42749
|
-
ortWeb.env.wasm.wasmPaths = `${pathToFileURL2(distDir).href}/`;
|
|
42750
|
-
}
|
|
42751
|
-
} catch (pathError) {
|
|
42752
|
-
log("[magic-context] could not resolve local onnxruntime-web/dist, falling back to default WASM paths:", pathError instanceof Error ? pathError.message : String(pathError));
|
|
42875
|
+
const { module: ortWeb, entryPath } = await importWasmOrtForRuntime();
|
|
42876
|
+
if (ortWeb.env?.wasm) {
|
|
42877
|
+
ortWeb.env.wasm.wasmPaths = `${pathToFileURL2(dirname7(entryPath)).href}/`;
|
|
42753
42878
|
}
|
|
42754
42879
|
globalThis[Symbol.for("onnxruntime")] = ortWeb;
|
|
42755
42880
|
wasmRuntimeInjected = true;
|
|
@@ -42776,10 +42901,18 @@ function disableLocalEmbeddingsAfterRuntimeFailure(detail) {
|
|
|
42776
42901
|
localEmbeddingRuntimeMode = "disabled";
|
|
42777
42902
|
logForRuntime(`[magic-context] local embeddings are disabled because both the onnxruntime-node native binding and the onnxruntime-web (WASM) fallback failed to load. Native failure: ${detail}. Run \`npx @cortexkit/magic-context@latest doctor\` for repair guidance (use \`doctor --force\` to reinstall cached plugin packages), or configure an \`openai-compatible\` embedding HTTP endpoint. Existing memories are unaffected.`);
|
|
42778
42903
|
}
|
|
42779
|
-
async function loadTransformersForLocalEmbedding() {
|
|
42904
|
+
async function loadTransformersForLocalEmbedding(runtimePreference) {
|
|
42780
42905
|
if (localEmbeddingRuntimeMode === "disabled") {
|
|
42781
42906
|
throw new Error("local embedding runtime is disabled");
|
|
42782
42907
|
}
|
|
42908
|
+
const resolvedRuntime = resolveLocalEmbeddingRuntime(runtimePreference, localEmbeddingHostForRuntime());
|
|
42909
|
+
if (resolvedRuntime === "wasm") {
|
|
42910
|
+
if (!await ensureWasmOrtInjected()) {
|
|
42911
|
+
disableLocalEmbeddingsAfterRuntimeFailure("the selected WASM runtime is unavailable");
|
|
42912
|
+
throw new Error("onnxruntime-web failed to load");
|
|
42913
|
+
}
|
|
42914
|
+
return { module: await importTransformersForRuntime(), usesWasm: true };
|
|
42915
|
+
}
|
|
42783
42916
|
if (localEmbeddingRuntimeMode === "wasm") {
|
|
42784
42917
|
if (!await ensureWasmOrtInjected()) {
|
|
42785
42918
|
disableLocalEmbeddingsAfterRuntimeFailure("the previously selected WASM runtime is unavailable");
|
|
@@ -42792,7 +42925,7 @@ async function loadTransformersForLocalEmbedding() {
|
|
|
42792
42925
|
throw wasmError;
|
|
42793
42926
|
}
|
|
42794
42927
|
}
|
|
42795
|
-
const electron =
|
|
42928
|
+
const electron = resolvedRuntime === "electron";
|
|
42796
42929
|
if (electron) {
|
|
42797
42930
|
const wasInjected = wasmRuntimeInjected;
|
|
42798
42931
|
if (await ensureWasmOrtInjected()) {
|
|
@@ -42848,6 +42981,8 @@ function isNativeRuntimeMissingError(error51) {
|
|
|
42848
42981
|
if (code === "ERR_DLOPEN_FAILED" && lower.includes("onnxruntime")) {
|
|
42849
42982
|
return true;
|
|
42850
42983
|
}
|
|
42984
|
+
if (lower.includes('could not load the "sharp" module'))
|
|
42985
|
+
return true;
|
|
42851
42986
|
const mentionsNativeRuntime = lower.includes("onnxruntime-node") || lower.includes("onnxruntime_binding");
|
|
42852
42987
|
if (!mentionsNativeRuntime)
|
|
42853
42988
|
return false;
|
|
@@ -42900,19 +43035,22 @@ class LocalEmbeddingProvider {
|
|
|
42900
43035
|
maxInputTokens;
|
|
42901
43036
|
model;
|
|
42902
43037
|
dtype;
|
|
43038
|
+
runtimePreference;
|
|
42903
43039
|
pipeline = null;
|
|
42904
43040
|
initPromise = null;
|
|
42905
43041
|
inFlight = 0;
|
|
42906
43042
|
disposing = false;
|
|
42907
43043
|
disposePromise = null;
|
|
42908
43044
|
inFlightWaiters = [];
|
|
42909
|
-
constructor(model = DEFAULT_LOCAL_EMBEDDING_MODEL, maxInputTokens = 512, dtype = DEFAULT_LOCAL_DTYPE) {
|
|
43045
|
+
constructor(model = DEFAULT_LOCAL_EMBEDDING_MODEL, maxInputTokens = 512, dtype = DEFAULT_LOCAL_DTYPE, runtimePreference = "auto") {
|
|
42910
43046
|
this.model = model;
|
|
42911
43047
|
this.maxInputTokens = maxInputTokens;
|
|
42912
43048
|
this.dtype = dtype || DEFAULT_LOCAL_DTYPE;
|
|
43049
|
+
this.runtimePreference = runtimePreference;
|
|
42913
43050
|
this.modelId = getEmbeddingProviderIdentity({
|
|
42914
43051
|
provider: "local",
|
|
42915
43052
|
model,
|
|
43053
|
+
local_runtime: runtimePreference,
|
|
42916
43054
|
...dtype && dtype !== DEFAULT_LOCAL_DTYPE ? { local_dtype: dtype } : {}
|
|
42917
43055
|
});
|
|
42918
43056
|
}
|
|
@@ -42935,7 +43073,7 @@ class LocalEmbeddingProvider {
|
|
|
42935
43073
|
if (this.disposing) {
|
|
42936
43074
|
return;
|
|
42937
43075
|
}
|
|
42938
|
-
const { module: transformersModule, usesWasm } = await loadTransformersForLocalEmbedding();
|
|
43076
|
+
const { module: transformersModule, usesWasm } = await loadTransformersForLocalEmbedding(this.runtimePreference);
|
|
42939
43077
|
const env = transformersModule.env;
|
|
42940
43078
|
const LogLevel = transformersModule.LogLevel;
|
|
42941
43079
|
if (LogLevel && "ERROR" in LogLevel) {
|
|
@@ -43003,7 +43141,7 @@ class LocalEmbeddingProvider {
|
|
|
43003
43141
|
if (!localEmbeddingRuntimeIsDisabled() && isNativeRuntimeMissingError(error51)) {
|
|
43004
43142
|
disableLocalEmbeddingsAfterRuntimeFailure(error51 instanceof Error ? error51.message : String(error51));
|
|
43005
43143
|
} else if (!localEmbeddingRuntimeIsDisabled()) {
|
|
43006
|
-
|
|
43144
|
+
logForRuntime("[magic-context] embedding model failed to load:", error51);
|
|
43007
43145
|
}
|
|
43008
43146
|
this.pipeline = null;
|
|
43009
43147
|
} finally {
|
|
@@ -44108,6 +44246,7 @@ function resolveEmbeddingConfig(config2) {
|
|
|
44108
44246
|
return {
|
|
44109
44247
|
provider: "local",
|
|
44110
44248
|
model: config2?.model?.trim() || DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
44249
|
+
local_runtime: config2?.local_runtime ?? "auto",
|
|
44111
44250
|
...config2?.max_input_tokens ? {
|
|
44112
44251
|
max_input_tokens: normalizeCompartmentChunkMaxInputTokens(config2.max_input_tokens)
|
|
44113
44252
|
} : {},
|
|
@@ -44173,7 +44312,7 @@ function createProvider(config2, context) {
|
|
|
44173
44312
|
});
|
|
44174
44313
|
}
|
|
44175
44314
|
if (config2.provider === "local") {
|
|
44176
|
-
return new LocalEmbeddingProvider(config2.model, config2.max_input_tokens, config2.local_dtype);
|
|
44315
|
+
return new LocalEmbeddingProvider(config2.model, config2.max_input_tokens, config2.local_dtype, config2.local_runtime);
|
|
44177
44316
|
}
|
|
44178
44317
|
if (config2.provider === "synapse") {
|
|
44179
44318
|
const synapse = config2;
|
|
@@ -44584,15 +44723,25 @@ function shadowBackfillMissingBase(scope, primaryModelId, shadowModelId, project
|
|
|
44584
44723
|
};
|
|
44585
44724
|
}
|
|
44586
44725
|
return {
|
|
44587
|
-
sql: `SELECT
|
|
44726
|
+
sql: `SELECT cp.compartment_id AS id,
|
|
44727
|
+
MIN(CASE WHEN NOT EXISTS (
|
|
44728
|
+
SELECT 1 FROM compartment_chunk_embeddings same_key
|
|
44729
|
+
WHERE same_key.compartment_id = cp.compartment_id
|
|
44730
|
+
AND same_key.window_index = cp.window_index
|
|
44731
|
+
AND same_key.model_id = ?
|
|
44732
|
+
) THEN 0 ELSE 1 END) AS defect_order
|
|
44588
44733
|
FROM compartment_chunk_embeddings cp
|
|
44589
44734
|
WHERE cp.project_path = ? AND cp.model_id = ?
|
|
44590
44735
|
AND NOT EXISTS (
|
|
44591
|
-
SELECT 1 FROM compartment_chunk_embeddings
|
|
44592
|
-
WHERE
|
|
44593
|
-
|
|
44594
|
-
|
|
44595
|
-
|
|
44736
|
+
SELECT 1 FROM compartment_chunk_embeddings current
|
|
44737
|
+
WHERE current.compartment_id = cp.compartment_id
|
|
44738
|
+
AND current.window_index = cp.window_index
|
|
44739
|
+
AND current.chunk_hash = cp.chunk_hash
|
|
44740
|
+
AND current.model_id = ?
|
|
44741
|
+
)
|
|
44742
|
+
GROUP BY cp.compartment_id`,
|
|
44743
|
+
params: [shadowModelId, projectIdentity, primaryModelId, shadowModelId],
|
|
44744
|
+
orderBy: " ORDER BY defect_order ASC, cp.compartment_id ASC"
|
|
44596
44745
|
};
|
|
44597
44746
|
}
|
|
44598
44747
|
function shadowBackfillMissingIds(db, projectIdentity, scope, primaryModelId, shadowModelId, limit) {
|
|
@@ -45186,7 +45335,8 @@ async function embedSessionCompartmentChunks(db, projectIdentity, sessionId, opt
|
|
|
45186
45335
|
return { status: "disabled", embedded: 0, total: 0 };
|
|
45187
45336
|
}
|
|
45188
45337
|
recordSessionProjectIdentity(db, sessionId, projectIdentity);
|
|
45189
|
-
const
|
|
45338
|
+
const maxInputTokens = getProjectEmbeddingMaxInputTokens(projectIdentity);
|
|
45339
|
+
const total = countUnembeddedSessionCompartments(db, projectIdentity, sessionId, snapshot.chunkModelId, maxInputTokens);
|
|
45190
45340
|
if (total === 0)
|
|
45191
45341
|
return { status: "nothing", embedded: 0, total: 0 };
|
|
45192
45342
|
const holderId = `session-embed-${randomUUID2()}`;
|
|
@@ -45224,7 +45374,7 @@ async function embedSessionCompartmentChunks(db, projectIdentity, sessionId, opt
|
|
|
45224
45374
|
aborted2 = true;
|
|
45225
45375
|
break;
|
|
45226
45376
|
}
|
|
45227
|
-
const candidates = loadUnembeddedSessionChunkCandidates(db, projectIdentity, sessionId, snapshot.chunkModelId, batchSize, [...skipIds, ...failedIds]);
|
|
45377
|
+
const candidates = loadUnembeddedSessionChunkCandidates(db, projectIdentity, sessionId, snapshot.chunkModelId, batchSize, [...skipIds, ...failedIds], maxInputTokens);
|
|
45228
45378
|
if (candidates.length === 0)
|
|
45229
45379
|
break;
|
|
45230
45380
|
const {
|
|
@@ -45269,7 +45419,7 @@ async function embedSessionCompartmentChunks(db, projectIdentity, sessionId, opt
|
|
|
45269
45419
|
if (aborted2)
|
|
45270
45420
|
return { status: "aborted", embedded, total, failed: failedIds.length };
|
|
45271
45421
|
if (providerDown || failedIds.length > 0) {
|
|
45272
|
-
const remaining = Math.max(0, countUnembeddedSessionCompartments(db, projectIdentity, sessionId, snapshot.chunkModelId) - skipIds.length);
|
|
45422
|
+
const remaining = Math.max(0, countUnembeddedSessionCompartments(db, projectIdentity, sessionId, snapshot.chunkModelId, maxInputTokens) - skipIds.length);
|
|
45273
45423
|
if (remaining > 0) {
|
|
45274
45424
|
return {
|
|
45275
45425
|
status: "stalled",
|
|
@@ -45295,7 +45445,7 @@ function getEmbeddingCoverageStatus(db, projectIdentity, sessionId) {
|
|
|
45295
45445
|
commits: { embedded: 0, total: 0, gitEnabled: false }
|
|
45296
45446
|
};
|
|
45297
45447
|
}
|
|
45298
|
-
const session = countSessionCompartmentEmbedCoverage(db, projectIdentity, sessionId, snapshot.chunkModelId);
|
|
45448
|
+
const session = countSessionCompartmentEmbedCoverage(db, projectIdentity, sessionId, snapshot.chunkModelId, getProjectEmbeddingMaxInputTokens(projectIdentity));
|
|
45299
45449
|
const memories = getMemoryEmbedCoverage(db, projectIdentity, snapshot.modelId);
|
|
45300
45450
|
const gitEnabled = snapshot.gitCommitEnabled;
|
|
45301
45451
|
const commits = gitEnabled ? {
|
|
@@ -45316,7 +45466,8 @@ function getEmbeddingCoverageStatus(db, projectIdentity, sessionId) {
|
|
|
45316
45466
|
// ../plugin/src/features/magic-context/memory/embedding.ts
|
|
45317
45467
|
var DEFAULT_EMBEDDING_CONFIG = {
|
|
45318
45468
|
provider: "local",
|
|
45319
|
-
model: DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
45469
|
+
model: DEFAULT_LOCAL_EMBEDDING_MODEL,
|
|
45470
|
+
local_runtime: "auto"
|
|
45320
45471
|
};
|
|
45321
45472
|
var embeddingConfig = DEFAULT_EMBEDDING_CONFIG;
|
|
45322
45473
|
var provider = null;
|
|
@@ -45336,7 +45487,7 @@ function createProvider2(config2) {
|
|
|
45336
45487
|
});
|
|
45337
45488
|
}
|
|
45338
45489
|
if (config2.provider === "local") {
|
|
45339
|
-
return new LocalEmbeddingProvider(config2.model, config2.max_input_tokens, config2.local_dtype);
|
|
45490
|
+
return new LocalEmbeddingProvider(config2.model, config2.max_input_tokens, config2.local_dtype, config2.local_runtime);
|
|
45340
45491
|
}
|
|
45341
45492
|
if (config2.provider === "synapse") {
|
|
45342
45493
|
const synapse = config2;
|
|
@@ -45561,10 +45712,6 @@ var STATUS_COLOR = {
|
|
|
45561
45712
|
completed: "success",
|
|
45562
45713
|
cancelled: "error"
|
|
45563
45714
|
};
|
|
45564
|
-
var SPIN_FRAMES = ["◐", "◓", "◑", "◒"];
|
|
45565
|
-
function spinGlyph() {
|
|
45566
|
-
return SPIN_FRAMES[Math.floor(Date.now() / 160) % SPIN_FRAMES.length];
|
|
45567
|
-
}
|
|
45568
45715
|
var snapshotsBySession = new Map;
|
|
45569
45716
|
var MAX_TODOWRITE_RENDER_CACHE_ENTRIES = 50;
|
|
45570
45717
|
var cachedTodowriteTodosByToolCallId = new Map;
|
|
@@ -45705,7 +45852,7 @@ function formatCounts(counts) {
|
|
|
45705
45852
|
return parts.join(" · ");
|
|
45706
45853
|
}
|
|
45707
45854
|
function formatTodoLine(todo, theme, options = {}) {
|
|
45708
|
-
const glyph = theme.fg(STATUS_COLOR[todo.status],
|
|
45855
|
+
const glyph = theme.fg(STATUS_COLOR[todo.status], STATUS_GLYPH[todo.status]);
|
|
45709
45856
|
const id = options.showId && todo.id ? `${theme.fg("accent", `#${todo.id}`)} ` : "";
|
|
45710
45857
|
const color = todo.status === "pending" || todo.status === "in_progress" ? "text" : "dim";
|
|
45711
45858
|
let content = theme.fg(color, todo.content);
|
|
@@ -45724,9 +45871,6 @@ function lineComponent(renderLines) {
|
|
|
45724
45871
|
invalidate() {}
|
|
45725
45872
|
};
|
|
45726
45873
|
}
|
|
45727
|
-
function hasAnimatedRow(rows) {
|
|
45728
|
-
return capTodoRows(rows).visible.some(({ todo }) => todo.status === "in_progress");
|
|
45729
|
-
}
|
|
45730
45874
|
function capTodoRows(rows) {
|
|
45731
45875
|
if (rows.length <= MAX_TODO_CONTENT_ROWS) {
|
|
45732
45876
|
return { visible: [...rows], hiddenCount: 0 };
|
|
@@ -45815,20 +45959,6 @@ function isOverlayLive(todo) {
|
|
|
45815
45959
|
}
|
|
45816
45960
|
|
|
45817
45961
|
class TodoOverlay {
|
|
45818
|
-
spinTimer;
|
|
45819
|
-
syncSpinTimer(hasInProgress) {
|
|
45820
|
-
if (hasInProgress && this.widgetRegistered) {
|
|
45821
|
-
if (this.spinTimer)
|
|
45822
|
-
return;
|
|
45823
|
-
this.spinTimer = setInterval(() => {
|
|
45824
|
-
this.tui?.requestRender();
|
|
45825
|
-
}, 160);
|
|
45826
|
-
this.spinTimer.unref?.();
|
|
45827
|
-
} else if (this.spinTimer) {
|
|
45828
|
-
clearInterval(this.spinTimer);
|
|
45829
|
-
this.spinTimer = undefined;
|
|
45830
|
-
}
|
|
45831
|
-
}
|
|
45832
45962
|
uiCtx;
|
|
45833
45963
|
sessionId;
|
|
45834
45964
|
widgetRegistered = false;
|
|
@@ -45856,10 +45986,6 @@ class TodoOverlay {
|
|
|
45856
45986
|
this.uiCtx.setWidget(WIDGET_KEY, undefined);
|
|
45857
45987
|
this.widgetRegistered = false;
|
|
45858
45988
|
this.tui = undefined;
|
|
45859
|
-
if (this.spinTimer) {
|
|
45860
|
-
clearInterval(this.spinTimer);
|
|
45861
|
-
this.spinTimer = undefined;
|
|
45862
|
-
}
|
|
45863
45989
|
}
|
|
45864
45990
|
return;
|
|
45865
45991
|
}
|
|
@@ -45871,17 +45997,11 @@ class TodoOverlay {
|
|
|
45871
45997
|
invalidate: () => {
|
|
45872
45998
|
this.widgetRegistered = false;
|
|
45873
45999
|
this.tui = undefined;
|
|
45874
|
-
if (this.spinTimer) {
|
|
45875
|
-
clearInterval(this.spinTimer);
|
|
45876
|
-
this.spinTimer = undefined;
|
|
45877
|
-
}
|
|
45878
46000
|
}
|
|
45879
46001
|
};
|
|
45880
46002
|
}, { placement: "aboveEditor" });
|
|
45881
46003
|
this.widgetRegistered = true;
|
|
45882
|
-
this.syncSpinTimer(hasAnimatedRow(visible));
|
|
45883
46004
|
} else {
|
|
45884
|
-
this.syncSpinTimer(hasAnimatedRow(visible));
|
|
45885
46005
|
this.tui?.requestRender();
|
|
45886
46006
|
}
|
|
45887
46007
|
}
|
|
@@ -45905,10 +46025,6 @@ class TodoOverlay {
|
|
|
45905
46025
|
this.dispose();
|
|
45906
46026
|
}
|
|
45907
46027
|
dispose() {
|
|
45908
|
-
if (this.spinTimer) {
|
|
45909
|
-
clearInterval(this.spinTimer);
|
|
45910
|
-
this.spinTimer = undefined;
|
|
45911
|
-
}
|
|
45912
46028
|
if (this.uiCtx)
|
|
45913
46029
|
this.uiCtx.setWidget(WIDGET_KEY, undefined);
|
|
45914
46030
|
this.widgetRegistered = false;
|
|
@@ -53852,8 +53968,16 @@ var GIT_COMMIT_SOURCE_BOOST = 1.2;
|
|
|
53852
53968
|
var PRIMER_SOURCE_BOOST = 1.25;
|
|
53853
53969
|
var messageSearchStatements = new WeakMap;
|
|
53854
53970
|
var messageSearchStatementsWithCutoff = new WeakMap;
|
|
53971
|
+
var messageSearchDiagnosticStatements = new WeakMap;
|
|
53855
53972
|
var batchedMessageSearchStatements = new WeakMap;
|
|
53856
53973
|
var batchedFtsCountStatements = new WeakMap;
|
|
53974
|
+
function createUnifiedSearchDiagnostics() {
|
|
53975
|
+
return {
|
|
53976
|
+
suppressedVisibleMemoryIds: [],
|
|
53977
|
+
suppressedLiveMessageMatches: 0,
|
|
53978
|
+
gitCommitUnavailable: null
|
|
53979
|
+
};
|
|
53980
|
+
}
|
|
53857
53981
|
function normalizeLimit2(limit) {
|
|
53858
53982
|
if (typeof limit !== "number" || !Number.isFinite(limit)) {
|
|
53859
53983
|
return DEFAULT_UNIFIED_SEARCH_LIMIT;
|
|
@@ -53944,6 +54068,51 @@ function getMessageSearchStatementWithCutoff(db) {
|
|
|
53944
54068
|
}
|
|
53945
54069
|
return stmt;
|
|
53946
54070
|
}
|
|
54071
|
+
function getMessageSearchDiagnosticStatement(db) {
|
|
54072
|
+
let stmt = messageSearchDiagnosticStatements.get(db);
|
|
54073
|
+
if (!stmt) {
|
|
54074
|
+
stmt = db.prepare(`
|
|
54075
|
+
WITH matches AS MATERIALIZED (
|
|
54076
|
+
SELECT
|
|
54077
|
+
message_ordinal AS messageOrdinal,
|
|
54078
|
+
message_id AS messageId,
|
|
54079
|
+
role,
|
|
54080
|
+
content,
|
|
54081
|
+
CAST(message_ordinal AS INTEGER) AS ordinalValue,
|
|
54082
|
+
bm25(message_history_fts) AS ftsRank
|
|
54083
|
+
FROM message_history_fts
|
|
54084
|
+
WHERE session_id = ? AND message_history_fts MATCH ?
|
|
54085
|
+
),
|
|
54086
|
+
eligible AS (
|
|
54087
|
+
SELECT * FROM matches
|
|
54088
|
+
WHERE ordinalValue <= ?
|
|
54089
|
+
ORDER BY ftsRank, ordinalValue ASC
|
|
54090
|
+
LIMIT ?
|
|
54091
|
+
),
|
|
54092
|
+
summary AS (
|
|
54093
|
+
SELECT COUNT(*) AS suppressedCount
|
|
54094
|
+
FROM matches
|
|
54095
|
+
WHERE ordinalValue > ?
|
|
54096
|
+
)
|
|
54097
|
+
SELECT
|
|
54098
|
+
eligible.messageOrdinal,
|
|
54099
|
+
eligible.messageId,
|
|
54100
|
+
eligible.role,
|
|
54101
|
+
eligible.content,
|
|
54102
|
+
eligible.ftsRank,
|
|
54103
|
+
summary.suppressedCount,
|
|
54104
|
+
0 AS summaryOnly
|
|
54105
|
+
FROM eligible CROSS JOIN summary
|
|
54106
|
+
UNION ALL
|
|
54107
|
+
SELECT NULL, NULL, NULL, NULL, NULL, summary.suppressedCount, 1
|
|
54108
|
+
FROM summary
|
|
54109
|
+
WHERE NOT EXISTS (SELECT 1 FROM eligible)
|
|
54110
|
+
ORDER BY summaryOnly ASC, ftsRank ASC, messageOrdinal ASC
|
|
54111
|
+
`);
|
|
54112
|
+
messageSearchDiagnosticStatements.set(db, stmt);
|
|
54113
|
+
}
|
|
54114
|
+
return stmt;
|
|
54115
|
+
}
|
|
53947
54116
|
function getBatchedFtsCountStatement(db, queryCount, cutoff) {
|
|
53948
54117
|
let statements = batchedFtsCountStatements.get(db);
|
|
53949
54118
|
if (!statements) {
|
|
@@ -54084,10 +54253,8 @@ function mergeMemoryResults(args) {
|
|
|
54084
54253
|
const memoryById = new Map(args.memories.map((memory2) => [memory2.id, memory2]));
|
|
54085
54254
|
const candidateIds = new Set([...args.semanticScores.keys(), ...args.ftsScores.keys()]);
|
|
54086
54255
|
const results = [];
|
|
54256
|
+
const suppressedVisibleIds = [];
|
|
54087
54257
|
for (const id of candidateIds) {
|
|
54088
|
-
if (args.visibleMemoryIds?.has(id)) {
|
|
54089
|
-
continue;
|
|
54090
|
-
}
|
|
54091
54258
|
const memory2 = memoryById.get(id);
|
|
54092
54259
|
if (!memory2) {
|
|
54093
54260
|
continue;
|
|
@@ -54109,6 +54276,10 @@ function mergeMemoryResults(args) {
|
|
|
54109
54276
|
if (score <= 0) {
|
|
54110
54277
|
continue;
|
|
54111
54278
|
}
|
|
54279
|
+
if (args.visibleMemoryIds?.has(id)) {
|
|
54280
|
+
suppressedVisibleIds.push(id);
|
|
54281
|
+
continue;
|
|
54282
|
+
}
|
|
54112
54283
|
results.push({
|
|
54113
54284
|
source: "memory",
|
|
54114
54285
|
content: previewText(memory2.content),
|
|
@@ -54119,20 +54290,23 @@ function mergeMemoryResults(args) {
|
|
|
54119
54290
|
sourceName: args.sourceNameByMemoryId?.get(memory2.id)
|
|
54120
54291
|
});
|
|
54121
54292
|
}
|
|
54122
|
-
return
|
|
54123
|
-
|
|
54124
|
-
|
|
54125
|
-
|
|
54126
|
-
|
|
54127
|
-
|
|
54293
|
+
return {
|
|
54294
|
+
results: results.sort((left, right) => {
|
|
54295
|
+
if (right.score !== left.score) {
|
|
54296
|
+
return right.score - left.score;
|
|
54297
|
+
}
|
|
54298
|
+
return left.memoryId - right.memoryId;
|
|
54299
|
+
}).slice(0, args.limit),
|
|
54300
|
+
suppressedVisibleIds: suppressedVisibleIds.sort((left, right) => left - right)
|
|
54301
|
+
};
|
|
54128
54302
|
}
|
|
54129
54303
|
async function searchMemories(args) {
|
|
54130
54304
|
if (!args.memoryEnabled) {
|
|
54131
|
-
return [];
|
|
54305
|
+
return { results: [], suppressedVisibleIds: [] };
|
|
54132
54306
|
}
|
|
54133
54307
|
const memories = args.workspace?.isWorkspaced ? getMemoriesByProjects(args.db, args.workspace.expandedIdentities, ["active", "permanent"], Date.now(), args.workspace.ownIdentities, args.workspace.shareCategories) : getMemoriesByProject(args.db, args.projectPath);
|
|
54134
54308
|
if (memories.length === 0) {
|
|
54135
|
-
return [];
|
|
54309
|
+
return { results: [], suppressedVisibleIds: [] };
|
|
54136
54310
|
}
|
|
54137
54311
|
const ftsMatches = getFtsMatches({
|
|
54138
54312
|
db: args.db,
|
|
@@ -54209,6 +54383,21 @@ function runMessageFtsQuery(db, sessionId, ftsQuery, fetchLimit, cutoff) {
|
|
|
54209
54383
|
}
|
|
54210
54384
|
return result;
|
|
54211
54385
|
}
|
|
54386
|
+
function runMessageFtsQueryWithDiagnostics(args) {
|
|
54387
|
+
if (args.ftsQuery.length === 0)
|
|
54388
|
+
return { rows: [], suppressedCount: 0 };
|
|
54389
|
+
const rawRows = getMessageSearchDiagnosticStatement(args.db).all(args.sessionId, args.ftsQuery, args.cutoff, args.fetchLimit, args.cutoff).map((row) => row);
|
|
54390
|
+
const suppressedCount = rawRows[0]?.suppressedCount ?? 0;
|
|
54391
|
+
const rows = [];
|
|
54392
|
+
for (const row of rawRows) {
|
|
54393
|
+
if (row.summaryOnly === 1)
|
|
54394
|
+
continue;
|
|
54395
|
+
const normalized = normalizeMessageSearchRow(row, args.cutoff);
|
|
54396
|
+
if (normalized)
|
|
54397
|
+
rows.push(normalized);
|
|
54398
|
+
}
|
|
54399
|
+
return { rows, suppressedCount };
|
|
54400
|
+
}
|
|
54212
54401
|
function getBatchedMessageSearchStatement(db, queryCount, cutoff) {
|
|
54213
54402
|
let statements = batchedMessageSearchStatements.get(db);
|
|
54214
54403
|
if (!statements) {
|
|
@@ -54275,7 +54464,20 @@ function searchMessages(args) {
|
|
|
54275
54464
|
const baseQuery = sanitizeFtsQuery(args.query.trim());
|
|
54276
54465
|
const probes = args.probes ?? [];
|
|
54277
54466
|
if (probes.length === 0) {
|
|
54278
|
-
const
|
|
54467
|
+
const outcome = args.diagnostics && cutoff !== null ? runMessageFtsQueryWithDiagnostics({
|
|
54468
|
+
db: args.db,
|
|
54469
|
+
sessionId: args.sessionId,
|
|
54470
|
+
ftsQuery: baseQuery,
|
|
54471
|
+
fetchLimit,
|
|
54472
|
+
cutoff
|
|
54473
|
+
}) : {
|
|
54474
|
+
rows: runMessageFtsQuery(args.db, args.sessionId, baseQuery, fetchLimit, cutoff),
|
|
54475
|
+
suppressedCount: 0
|
|
54476
|
+
};
|
|
54477
|
+
if (args.diagnostics) {
|
|
54478
|
+
args.diagnostics.suppressedLiveMessageMatches = outcome.suppressedCount;
|
|
54479
|
+
}
|
|
54480
|
+
const filtered = outcome.rows.slice(0, args.limit);
|
|
54279
54481
|
return filtered.map((row, rank) => ({
|
|
54280
54482
|
source: "message",
|
|
54281
54483
|
content: previewText(row.content),
|
|
@@ -54288,8 +54490,19 @@ function searchMessages(args) {
|
|
|
54288
54490
|
const sanitizedProbes = probes.map((probe) => ({ probe, query: sanitizeFtsQuery(probe) })).filter((entry) => entry.query.length > 0);
|
|
54289
54491
|
const corpusSize = getIndexedMessageCorpusSize(args.db, args.sessionId, cutoff);
|
|
54290
54492
|
const probeCounts = countSessionFtsMatchesBatch(args.db, args.sessionId, sanitizedProbes.map((entry) => entry.query), cutoff);
|
|
54493
|
+
const collectBaseDiagnostics = args.diagnostics !== undefined && cutoff !== null;
|
|
54494
|
+
const baseOutcome = collectBaseDiagnostics && baseQuery.length > 0 ? runMessageFtsQueryWithDiagnostics({
|
|
54495
|
+
db: args.db,
|
|
54496
|
+
sessionId: args.sessionId,
|
|
54497
|
+
ftsQuery: baseQuery,
|
|
54498
|
+
fetchLimit,
|
|
54499
|
+
cutoff
|
|
54500
|
+
}) : null;
|
|
54501
|
+
if (args.diagnostics) {
|
|
54502
|
+
args.diagnostics.suppressedLiveMessageMatches = baseOutcome?.suppressedCount ?? 0;
|
|
54503
|
+
}
|
|
54291
54504
|
const searchQueries = [
|
|
54292
|
-
|
|
54505
|
+
...!collectBaseDiagnostics && baseQuery.length > 0 ? [baseQuery] : [],
|
|
54293
54506
|
...sanitizedProbes.map((entry) => entry.query)
|
|
54294
54507
|
];
|
|
54295
54508
|
const rowsByQuery = runMessageFtsQueriesBatch(args.db, args.sessionId, searchQueries, fetchLimit, cutoff);
|
|
@@ -54297,10 +54510,11 @@ function searchMessages(args) {
|
|
|
54297
54510
|
let queryIndex = 0;
|
|
54298
54511
|
if (baseQuery.length > 0) {
|
|
54299
54512
|
queryLists.push({
|
|
54300
|
-
rows: rowsByQuery[queryIndex] ?? [],
|
|
54513
|
+
rows: baseOutcome?.rows ?? rowsByQuery[queryIndex] ?? [],
|
|
54301
54514
|
weight: 1
|
|
54302
54515
|
});
|
|
54303
|
-
|
|
54516
|
+
if (!collectBaseDiagnostics)
|
|
54517
|
+
queryIndex += 1;
|
|
54304
54518
|
}
|
|
54305
54519
|
const probeWeights = new Map;
|
|
54306
54520
|
sanitizedProbes.forEach((entry, probeIndex) => {
|
|
@@ -54687,6 +54901,9 @@ function memoriesToIdLookupResults(args) {
|
|
|
54687
54901
|
}));
|
|
54688
54902
|
}
|
|
54689
54903
|
function resolveMemoriesByIdsForSearch(args) {
|
|
54904
|
+
if (args.diagnostics) {
|
|
54905
|
+
args.diagnostics.suppressedVisibleMemoryIds = [];
|
|
54906
|
+
}
|
|
54690
54907
|
if (args.ids.length === 0) {
|
|
54691
54908
|
return null;
|
|
54692
54909
|
}
|
|
@@ -54697,16 +54914,22 @@ function resolveMemoriesByIdsForSearch(args) {
|
|
|
54697
54914
|
}
|
|
54698
54915
|
const memoriesById = new Map(fetched.map((memory2) => [memory2.id, memory2]));
|
|
54699
54916
|
const ordered = [];
|
|
54917
|
+
const suppressedVisibleIds = new Set;
|
|
54700
54918
|
for (const id of args.ids) {
|
|
54701
54919
|
const memory2 = memoriesById.get(id);
|
|
54702
54920
|
if (!memory2)
|
|
54703
54921
|
continue;
|
|
54704
|
-
if (args.visibleMemoryIds?.has(id))
|
|
54922
|
+
if (args.visibleMemoryIds?.has(id)) {
|
|
54923
|
+
suppressedVisibleIds.add(id);
|
|
54705
54924
|
continue;
|
|
54925
|
+
}
|
|
54706
54926
|
ordered.push(memory2);
|
|
54707
54927
|
if (ordered.length >= args.limit)
|
|
54708
54928
|
break;
|
|
54709
54929
|
}
|
|
54930
|
+
if (args.diagnostics) {
|
|
54931
|
+
args.diagnostics.suppressedVisibleMemoryIds = [...suppressedVisibleIds].sort((left, right) => left - right);
|
|
54932
|
+
}
|
|
54710
54933
|
if (ordered.length === 0) {
|
|
54711
54934
|
return null;
|
|
54712
54935
|
}
|
|
@@ -54728,6 +54951,11 @@ async function unifiedSearch(db, sessionId, projectPath, query, options = {}) {
|
|
|
54728
54951
|
}
|
|
54729
54952
|
const limit = normalizeLimit2(options.limit);
|
|
54730
54953
|
const tierLimit = Math.max(limit * 3, DEFAULT_UNIFIED_SEARCH_LIMIT);
|
|
54954
|
+
if (options.diagnostics) {
|
|
54955
|
+
options.diagnostics.suppressedVisibleMemoryIds = [];
|
|
54956
|
+
options.diagnostics.suppressedLiveMessageMatches = 0;
|
|
54957
|
+
options.diagnostics.gitCommitUnavailable = null;
|
|
54958
|
+
}
|
|
54731
54959
|
const embeddingEnabled = options.embeddingEnabled ?? true;
|
|
54732
54960
|
const embedQuery = options.embedQuery ?? embedText;
|
|
54733
54961
|
const isEmbeddingRuntimeEnabled = options.isEmbeddingRuntimeEnabled ?? isEmbeddingEnabled;
|
|
@@ -54737,6 +54965,9 @@ async function unifiedSearch(db, sessionId, projectPath, query, options = {}) {
|
|
|
54737
54965
|
const runMemory = activeSources.has("memory") && memoryFeatureEnabled;
|
|
54738
54966
|
const runMessages = activeSources.has("message");
|
|
54739
54967
|
const runGitCommits = activeSources.has("git_commit") && gitCommitsEnabled;
|
|
54968
|
+
if (options.diagnostics && activeSources.has("git_commit") && options.gitRepositoryAvailable === false) {
|
|
54969
|
+
options.diagnostics.gitCommitUnavailable = "no_git_repository";
|
|
54970
|
+
}
|
|
54740
54971
|
const runPrimers = activeSources.has("primer") && memoryFeatureEnabled;
|
|
54741
54972
|
const runNotes = activeSources.has("note");
|
|
54742
54973
|
const runCompartmentChunks = runMessages && memoryFeatureEnabled && embeddingEnabled;
|
|
@@ -54753,7 +54984,8 @@ async function unifiedSearch(db, sessionId, projectPath, query, options = {}) {
|
|
|
54753
54984
|
query: trimmedQuery,
|
|
54754
54985
|
limit: tierLimit,
|
|
54755
54986
|
maxOrdinal: options.maxMessageOrdinal,
|
|
54756
|
-
probes: messageProbes
|
|
54987
|
+
probes: messageProbes,
|
|
54988
|
+
diagnostics: options.diagnostics
|
|
54757
54989
|
}) : [];
|
|
54758
54990
|
const capturedQuery = await queryEmbeddingPromise;
|
|
54759
54991
|
const embeddingSnapshot = getProjectEmbeddingSnapshot(projectPath);
|
|
@@ -54777,7 +55009,7 @@ async function unifiedSearch(db, sessionId, projectPath, query, options = {}) {
|
|
|
54777
55009
|
compartments: compartmentResults,
|
|
54778
55010
|
limit: tierLimit
|
|
54779
55011
|
});
|
|
54780
|
-
const [
|
|
55012
|
+
const [memoryOutcome, gitCommitResults, primerResults, noteResults] = await Promise.all([
|
|
54781
55013
|
runMemory ? searchMemories({
|
|
54782
55014
|
db,
|
|
54783
55015
|
projectPath,
|
|
@@ -54788,7 +55020,10 @@ async function unifiedSearch(db, sessionId, projectPath, query, options = {}) {
|
|
|
54788
55020
|
queryModelId: embeddingModelId && embeddingModelId !== "off" ? embeddingModelId : null,
|
|
54789
55021
|
workspace,
|
|
54790
55022
|
visibleMemoryIds: options.visibleMemoryIds
|
|
54791
|
-
}) : Promise.resolve(
|
|
55023
|
+
}) : Promise.resolve({
|
|
55024
|
+
results: [],
|
|
55025
|
+
suppressedVisibleIds: []
|
|
55026
|
+
}),
|
|
54792
55027
|
runGitCommits ? Promise.resolve(searchGitCommits({
|
|
54793
55028
|
db,
|
|
54794
55029
|
projectPath,
|
|
@@ -54814,8 +55049,11 @@ async function unifiedSearch(db, sessionId, projectPath, query, options = {}) {
|
|
|
54814
55049
|
probes: messageProbes
|
|
54815
55050
|
})) : Promise.resolve([])
|
|
54816
55051
|
]);
|
|
55052
|
+
if (options.diagnostics) {
|
|
55053
|
+
options.diagnostics.suppressedVisibleMemoryIds = memoryOutcome.suppressedVisibleIds;
|
|
55054
|
+
}
|
|
54817
55055
|
const results = [
|
|
54818
|
-
...
|
|
55056
|
+
...memoryOutcome.results,
|
|
54819
55057
|
...primerResults,
|
|
54820
55058
|
...messageLikeResults,
|
|
54821
55059
|
...gitCommitResults,
|
|
@@ -54853,6 +55091,123 @@ async function unifiedSearch(db, sessionId, projectPath, query, options = {}) {
|
|
|
54853
55091
|
}
|
|
54854
55092
|
return results;
|
|
54855
55093
|
}
|
|
55094
|
+
var SEARCH_NOTE_EXPAND_HINT = "Use ctx_expand(start=N-10, end=N) around any note @msg anchor above to read the surrounding conversation context.";
|
|
55095
|
+
function formatSearchAge(timestampMs) {
|
|
55096
|
+
const ageMs = Date.now() - timestampMs;
|
|
55097
|
+
if (ageMs < 0)
|
|
55098
|
+
return "future";
|
|
55099
|
+
const days = Math.floor(ageMs / (24 * 60 * 60 * 1000));
|
|
55100
|
+
if (days <= 0)
|
|
55101
|
+
return "today";
|
|
55102
|
+
if (days === 1)
|
|
55103
|
+
return "1d ago";
|
|
55104
|
+
if (days < 30)
|
|
55105
|
+
return `${days}d ago`;
|
|
55106
|
+
const months = Math.floor(days / 30);
|
|
55107
|
+
if (months === 1)
|
|
55108
|
+
return "1mo ago";
|
|
55109
|
+
if (months < 12)
|
|
55110
|
+
return `${months}mo ago`;
|
|
55111
|
+
const years = Math.floor(days / 365);
|
|
55112
|
+
return years === 1 ? "1y ago" : `${years}y ago`;
|
|
55113
|
+
}
|
|
55114
|
+
function formatUnifiedSearchResult(result, index, currentSessionId) {
|
|
55115
|
+
if (result.source === "memory") {
|
|
55116
|
+
const source = result.sourceName ? ` source=${result.sourceName}` : "";
|
|
55117
|
+
return [
|
|
55118
|
+
`[${index}] [memory] score=${result.score.toFixed(2)} id=${result.memoryId} category=${result.category}${source} match=${result.matchType}`,
|
|
55119
|
+
result.content
|
|
55120
|
+
].join(`
|
|
55121
|
+
`);
|
|
55122
|
+
}
|
|
55123
|
+
if (result.source === "git_commit") {
|
|
55124
|
+
return [
|
|
55125
|
+
`[${index}] [git_commit] score=${result.score.toFixed(2)} sha=${result.shortSha} ${formatSearchAge(result.committedAtMs)} match=${result.matchType}`,
|
|
55126
|
+
result.content
|
|
55127
|
+
].join(`
|
|
55128
|
+
`);
|
|
55129
|
+
}
|
|
55130
|
+
if (result.source === "primer") {
|
|
55131
|
+
return [
|
|
55132
|
+
`[${index}] [primer] score=${result.score.toFixed(2)} id=${result.primerId} support=${result.support} match=${result.matchType}`,
|
|
55133
|
+
result.content
|
|
55134
|
+
].join(`
|
|
55135
|
+
`);
|
|
55136
|
+
}
|
|
55137
|
+
if (result.source === "note") {
|
|
55138
|
+
const anchor = result.anchorOrdinal !== null && result.sourceSessionId === currentSessionId ? ` @msg ${result.anchorOrdinal}` : "";
|
|
55139
|
+
return [
|
|
55140
|
+
`[${index}] [note] score=${result.score.toFixed(2)} id=#${result.noteId} status=${result.status} ${formatSearchAge(result.createdAt)}${anchor}`,
|
|
55141
|
+
result.content
|
|
55142
|
+
].join(`
|
|
55143
|
+
`);
|
|
55144
|
+
}
|
|
55145
|
+
if (result.source === "compartment") {
|
|
55146
|
+
return [
|
|
55147
|
+
`[${index}] [message] score=${result.score.toFixed(2)} compartment_id=${result.compartmentId} range=${result.startOrdinal}-${result.endOrdinal} match=${result.matchType} title=${result.title}`,
|
|
55148
|
+
result.snippet ? `Snippet: ${result.snippet}` : result.content
|
|
55149
|
+
].join(`
|
|
55150
|
+
`);
|
|
55151
|
+
}
|
|
55152
|
+
const expandStart = Math.max(1, result.messageOrdinal - 3);
|
|
55153
|
+
const expandEnd = result.messageOrdinal + 3;
|
|
55154
|
+
return [
|
|
55155
|
+
`[${index}] [message] score=${result.score.toFixed(2)} ordinal=${result.messageOrdinal} range=${expandStart}-${expandEnd} role=${result.role}`,
|
|
55156
|
+
result.content
|
|
55157
|
+
].join(`
|
|
55158
|
+
`);
|
|
55159
|
+
}
|
|
55160
|
+
function formatSearchDiagnosticLines(results, diagnostics) {
|
|
55161
|
+
if (!diagnostics)
|
|
55162
|
+
return [];
|
|
55163
|
+
const lines = [];
|
|
55164
|
+
const visibleIds = [...diagnostics.suppressedVisibleMemoryIds].sort((left, right) => left - right);
|
|
55165
|
+
if (visibleIds.length > 0) {
|
|
55166
|
+
const count = visibleIds.length;
|
|
55167
|
+
const noun = count === 1 ? "match" : "matches";
|
|
55168
|
+
const ids = visibleIds.join(", ");
|
|
55169
|
+
if (results.some((result) => result.source === "memory")) {
|
|
55170
|
+
lines.push(`Memories: ${count} additional ${noun} suppressed because ${count === 1 ? "it is" : "they are"} already visible in your project-memory block (ids ${ids}).`);
|
|
55171
|
+
} else {
|
|
55172
|
+
lines.push(`Memories: ${count} ${noun} found, all already visible in your project-memory block (ids ${ids}).`);
|
|
55173
|
+
}
|
|
55174
|
+
}
|
|
55175
|
+
if (diagnostics.suppressedLiveMessageMatches > 0) {
|
|
55176
|
+
const count = diagnostics.suppressedLiveMessageMatches;
|
|
55177
|
+
lines.push(`Message history: ${count} raw-message ${count === 1 ? "match is" : "matches are"} newer than the last compartment boundary (already in your context).`);
|
|
55178
|
+
}
|
|
55179
|
+
if (diagnostics.gitCommitUnavailable === "no_git_repository") {
|
|
55180
|
+
lines.push("Git commits: no git repository — commit search unavailable for this project.");
|
|
55181
|
+
}
|
|
55182
|
+
return lines;
|
|
55183
|
+
}
|
|
55184
|
+
function formatSearchResults(query, results, currentSessionId, diagnostics) {
|
|
55185
|
+
const diagnosticLines = formatSearchDiagnosticLines(results, diagnostics);
|
|
55186
|
+
if (results.length === 0) {
|
|
55187
|
+
if (diagnosticLines.length > 0) {
|
|
55188
|
+
return `No hidden results found for "${query}".
|
|
55189
|
+
|
|
55190
|
+
${diagnosticLines.join(`
|
|
55191
|
+
`)}`;
|
|
55192
|
+
}
|
|
55193
|
+
return `No results found for "${query}" across notes, memories, primers, git commits, or message history.`;
|
|
55194
|
+
}
|
|
55195
|
+
const bodyParts = results.map((result, index) => formatUnifiedSearchResult(result, index + 1, currentSessionId));
|
|
55196
|
+
if (diagnosticLines.length > 0)
|
|
55197
|
+
bodyParts.push(diagnosticLines.join(`
|
|
55198
|
+
`));
|
|
55199
|
+
if (results.some((result) => result.source === "message" || result.source === "compartment")) {
|
|
55200
|
+
bodyParts.push("Use ctx_expand(start, end) with the range from any message result above to read the full conversation context.");
|
|
55201
|
+
}
|
|
55202
|
+
if (results.some((result) => result.source === "note" && result.anchorOrdinal !== null && result.sourceSessionId === currentSessionId)) {
|
|
55203
|
+
bodyParts.push(SEARCH_NOTE_EXPAND_HINT);
|
|
55204
|
+
}
|
|
55205
|
+
return `Found ${results.length} result${results.length === 1 ? "" : "s"} for "${query}":
|
|
55206
|
+
|
|
55207
|
+
${bodyParts.join(`
|
|
55208
|
+
|
|
55209
|
+
`)}`;
|
|
55210
|
+
}
|
|
54856
55211
|
|
|
54857
55212
|
// ../plugin/src/features/magic-context/mural/render-trigger.ts
|
|
54858
55213
|
import { createHash as createHash15 } from "node:crypto";
|
|
@@ -56617,7 +56972,6 @@ Picking sources:
|
|
|
56617
56972
|
|
|
56618
56973
|
// src/tools/ctx-search.ts
|
|
56619
56974
|
var DEFAULT_LIMIT = 10;
|
|
56620
|
-
var NOTE_EXPAND_HINT = "Use ctx_expand(start=N-10, end=N) around any note @msg anchor above to read the surrounding conversation context.";
|
|
56621
56975
|
var ParamsSchema5 = exports_typebox.Object({
|
|
56622
56976
|
query: exports_typebox.Optional(exports_typebox.String({
|
|
56623
56977
|
description: "Search query. Matches against memory content, Primers, git commit messages, and raw user/assistant message text."
|
|
@@ -56640,89 +56994,6 @@ function normalizeLimit3(limit) {
|
|
|
56640
56994
|
return DEFAULT_LIMIT;
|
|
56641
56995
|
return Math.max(1, Math.floor(limit));
|
|
56642
56996
|
}
|
|
56643
|
-
function formatAge(committedAtMs) {
|
|
56644
|
-
const ageMs = Date.now() - committedAtMs;
|
|
56645
|
-
if (ageMs < 0)
|
|
56646
|
-
return "future";
|
|
56647
|
-
const days = Math.floor(ageMs / (24 * 60 * 60 * 1000));
|
|
56648
|
-
if (days <= 0)
|
|
56649
|
-
return "today";
|
|
56650
|
-
if (days === 1)
|
|
56651
|
-
return "1d ago";
|
|
56652
|
-
if (days < 30)
|
|
56653
|
-
return `${days}d ago`;
|
|
56654
|
-
const months = Math.floor(days / 30);
|
|
56655
|
-
if (months === 1)
|
|
56656
|
-
return "1mo ago";
|
|
56657
|
-
if (months < 12)
|
|
56658
|
-
return `${months}mo ago`;
|
|
56659
|
-
const years = Math.floor(days / 365);
|
|
56660
|
-
return years === 1 ? "1y ago" : `${years}y ago`;
|
|
56661
|
-
}
|
|
56662
|
-
function formatResult(result, index, currentSessionId) {
|
|
56663
|
-
if (result.source === "memory") {
|
|
56664
|
-
const source = result.sourceName ? ` source=${result.sourceName}` : "";
|
|
56665
|
-
return [
|
|
56666
|
-
`[${index}] [memory] score=${result.score.toFixed(2)} id=${result.memoryId} category=${result.category}${source} match=${result.matchType}`,
|
|
56667
|
-
result.content
|
|
56668
|
-
].join(`
|
|
56669
|
-
`);
|
|
56670
|
-
}
|
|
56671
|
-
if (result.source === "git_commit") {
|
|
56672
|
-
return [
|
|
56673
|
-
`[${index}] [git_commit] score=${result.score.toFixed(2)} sha=${result.shortSha} ${formatAge(result.committedAtMs)} match=${result.matchType}`,
|
|
56674
|
-
result.content
|
|
56675
|
-
].join(`
|
|
56676
|
-
`);
|
|
56677
|
-
}
|
|
56678
|
-
if (result.source === "primer") {
|
|
56679
|
-
return [
|
|
56680
|
-
`[${index}] [primer] score=${result.score.toFixed(2)} id=${result.primerId} support=${result.support} match=${result.matchType}`,
|
|
56681
|
-
result.content
|
|
56682
|
-
].join(`
|
|
56683
|
-
`);
|
|
56684
|
-
}
|
|
56685
|
-
if (result.source === "note") {
|
|
56686
|
-
const anchor = result.anchorOrdinal !== null && result.sourceSessionId === currentSessionId ? ` @msg ${result.anchorOrdinal}` : "";
|
|
56687
|
-
return [
|
|
56688
|
-
`[${index}] [note] score=${result.score.toFixed(2)} id=#${result.noteId} status=${result.status} ${formatAge(result.createdAt)}${anchor}`,
|
|
56689
|
-
result.content
|
|
56690
|
-
].join(`
|
|
56691
|
-
`);
|
|
56692
|
-
}
|
|
56693
|
-
if (result.source === "compartment") {
|
|
56694
|
-
return [
|
|
56695
|
-
`[${index}] [message] score=${result.score.toFixed(2)} compartment_id=${result.compartmentId} range=${result.startOrdinal}-${result.endOrdinal} match=${result.matchType} title=${result.title}`,
|
|
56696
|
-
result.snippet ? `Snippet: ${result.snippet}` : result.content
|
|
56697
|
-
].join(`
|
|
56698
|
-
`);
|
|
56699
|
-
}
|
|
56700
|
-
const expandStart = Math.max(1, result.messageOrdinal - 3);
|
|
56701
|
-
const expandEnd = result.messageOrdinal + 3;
|
|
56702
|
-
return [
|
|
56703
|
-
`[${index}] [message] score=${result.score.toFixed(2)} ordinal=${result.messageOrdinal} range=${expandStart}-${expandEnd} role=${result.role}`,
|
|
56704
|
-
result.content
|
|
56705
|
-
].join(`
|
|
56706
|
-
`);
|
|
56707
|
-
}
|
|
56708
|
-
function formatSearchResults(query, results, currentSessionId) {
|
|
56709
|
-
if (results.length === 0) {
|
|
56710
|
-
return `No results found for "${query}" across notes, memories, primers, git commits, or message history.`;
|
|
56711
|
-
}
|
|
56712
|
-
const bodyParts = results.map((result, index) => formatResult(result, index + 1, currentSessionId));
|
|
56713
|
-
if (results.some((result) => result.source === "message" || result.source === "compartment")) {
|
|
56714
|
-
bodyParts.push("Use ctx_expand(start, end) with the range from any message result above to read the full conversation context.");
|
|
56715
|
-
}
|
|
56716
|
-
if (results.some((result) => result.source === "note" && result.anchorOrdinal !== null && result.sourceSessionId === currentSessionId)) {
|
|
56717
|
-
bodyParts.push(NOTE_EXPAND_HINT);
|
|
56718
|
-
}
|
|
56719
|
-
const body = bodyParts.join(`
|
|
56720
|
-
|
|
56721
|
-
`);
|
|
56722
|
-
return `Found ${results.length} result${results.length === 1 ? "" : "s"} for "${query}":
|
|
56723
|
-
|
|
56724
|
-
${body}`;
|
|
56725
|
-
}
|
|
56726
56997
|
function createCtxSearchTool(deps) {
|
|
56727
56998
|
const resolveProject = deps.resolveProjectIdentity ?? resolveProjectIdentityForSession;
|
|
56728
56999
|
return {
|
|
@@ -56771,6 +57042,7 @@ function createCtxSearchTool(deps) {
|
|
|
56771
57042
|
const lastCompartmentEnd = getLastCompartmentEndMessage(deps.db, sessionId);
|
|
56772
57043
|
const messageOrdinalCutoff = lastCompartmentEnd >= 0 ? lastCompartmentEnd : 0;
|
|
56773
57044
|
const visibleMemoryIds = getVisibleMemoryIds(deps.db, sessionId);
|
|
57045
|
+
const diagnostics = createUnifiedSearchDiagnostics();
|
|
56774
57046
|
const idShape = parseIdShapedQuery(query);
|
|
56775
57047
|
if (idShape && memoryEnabled) {
|
|
56776
57048
|
const idResults = resolveMemoriesByIdsForSearch({
|
|
@@ -56778,14 +57050,15 @@ function createCtxSearchTool(deps) {
|
|
|
56778
57050
|
projectPath: projectIdentity,
|
|
56779
57051
|
ids: idShape,
|
|
56780
57052
|
limit: Math.max(normalizeLimit3(params.limit), idShape.length),
|
|
56781
|
-
visibleMemoryIds
|
|
57053
|
+
visibleMemoryIds,
|
|
57054
|
+
diagnostics
|
|
56782
57055
|
});
|
|
56783
|
-
if (idResults !== null) {
|
|
57056
|
+
if (idResults !== null || diagnostics.suppressedVisibleMemoryIds.length > 0) {
|
|
56784
57057
|
return {
|
|
56785
57058
|
content: [
|
|
56786
57059
|
{
|
|
56787
57060
|
type: "text",
|
|
56788
|
-
text: formatSearchResults(query, idResults, sessionId)
|
|
57061
|
+
text: formatSearchResults(query, idResults ?? [], sessionId, diagnostics)
|
|
56789
57062
|
}
|
|
56790
57063
|
],
|
|
56791
57064
|
details: undefined
|
|
@@ -56805,13 +57078,15 @@ function createCtxSearchTool(deps) {
|
|
|
56805
57078
|
gitCommitsEnabled,
|
|
56806
57079
|
sources: params.sources,
|
|
56807
57080
|
visibleMemoryIds,
|
|
57081
|
+
diagnostics,
|
|
57082
|
+
gitRepositoryAvailable: directoryHasGitMetadata(ctx.cwd),
|
|
56808
57083
|
explicitSearch: true
|
|
56809
57084
|
});
|
|
56810
57085
|
return {
|
|
56811
57086
|
content: [
|
|
56812
57087
|
{
|
|
56813
57088
|
type: "text",
|
|
56814
|
-
text: formatSearchResults(query, results, sessionId)
|
|
57089
|
+
text: formatSearchResults(query, results, sessionId, diagnostics)
|
|
56815
57090
|
}
|
|
56816
57091
|
],
|
|
56817
57092
|
details: undefined
|
|
@@ -56927,4 +57202,4 @@ function registerMagicContextTools(pi, opts) {
|
|
|
56927
57202
|
}
|
|
56928
57203
|
}
|
|
56929
57204
|
|
|
56930
|
-
export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, migrateMagicContextConfigLocations, FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, createFailClosedController, ProjectIdentityError, resolveProjectIdentityStrict, resolveProjectIdentity, resolveProjectIdentityForSession, beginBootQuietPeriod, scheduleAfterBootQuiet, Database, closeQuietly, isMidTurn, textMentionsRecentCommit, hasMeaningfulUserText, extractTexts, extractToolCallSummaries, preloadTokenizer, estimateTokens, normalizeText, isRecord, completedToolArcCrossesBoundary, estimateTrueRawMessageTokens, buildToolArcs, fenceBoundaryForCompletedToolArcs, fenceBoundaryForToolArcs, buildTrueRawTokenIndex, computeRawRangeFingerprint, invalidateTrueRawTokenCache, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isEditTool, applyEditMarkerToInput, setRawMessageProvider, withRawMessageProvider, cleanUserText, withRawSessionMessageCache, readRawSessionMessages, primeTailRawMessageCache, getCachedAbsoluteMessageCount, primeInMemoryTailRawMessageCache, getRawSessionMessageCount, getRawSessionTagKeysThrough, getLegacyProtectedTailStartOrdinal, readSessionChunk, clearCompressionDepth, clearCompressionDepthRange, getMessageIndexSourceIdentity, isMessageIndexSourceCurrent, getLastIndexedOrdinal, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, indexSingleMessage, indexMessagesAfterOrdinal, sweepOrphanedOpenCodeMessageIndexes, recordSessionProjectIdentity, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, isCompartmentLeaseHeld, piModelRefToCanonical, resolveModelRefForPi, modelRefLookupOrder, ompModelRefToCanonical, resolveModelRefForOmp, persistCachedM0, clearCachedM0M1, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getModuleNoteEvaluationBridge, getContextStoreUuid, parseCompartmentOutput, logSlowWriteTransaction, resolveWorkspaceShareCategories, resolveWorkspaceIdentitySet, expandWorkspaceIdentitySetWithAliases, sourceNameForMemory, computeWorkspaceEpochFingerprint, bumpEpochsForWorkspaceMembers, readProjectDocsCanonical, copySessionStateForClone, getErrorMessage, describeError, setStoragePrivatePermissionEnforcement, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, applySqliteTuningPragmas, runSqliteOptimize, openDatabase, openDatabaseAsync, queueM0Mutation, getMaxM0MutationId, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, MAX_EXECUTE_THRESHOLD, escalationBands, describeProtectedTailDrainBudgetSkip, loadProtectedTailMeta, markProtectedTailPolicyV3Seeded, recordProtectedTailPublicationFloor, recordProtectedTailNoEligibleHead, getWrapupInProgressState, isWrapupInProgress, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, 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, pruneAutoSearchHintDecisions, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, getNoteLastReadAt, getHistorianFailureState, incrementHistorianFailure, clearHistorianFailureState, getOverflowState, recordOverflowDetected, clearEmergencyRecovery, clearDetectedContextLimit, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, getProcessedImageStrippedIds, addProcessedImageStrippedIds, getPendingCompactionMarkerState, clearPendingCompactionMarkerStateIf, getPendingPiCompactionMarkerState, setPendingPiCompactionMarkerState, clearPendingPiCompactionMarkerStateIf, getSessionsWithPendingPiMarker, peekDeferredExecutePending, setDeferredExecutePendingIfAbsent, clearDeferredExecutePendingIfMatches, setSessionWorkMetrics, getSessionWorkMetrics, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, getNotes, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, markNoteReady, markNoteChecked, queuePendingOp, getPendingOps, clearPendingOps, removePendingOp, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, insertPrimerCandidates, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, CTX_REDUCE_KEEP, estimateImageTokensFromDataUrl, normalizeTodoStateJson, buildSyntheticTodoPart, stripChannel1ReminderSpans, effectiveTailHygiene, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, decideChannel1, evaluateChannel2, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, planEmergencyDrop, updateTagByteSize, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, updateTagInputByteSize, updateTagTokenCount, getPersistedToolTagAccounting, getAllStatusTagTokenTotalsFlat, updateTagInputTokenCount, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, updateTagDropMode, updateCavemanDepth, hasPiFallbackMessageTags, findAdoptableFallbackTags, hasPiFallbackToolOwnerTags, findPiFallbackToolOwnerTags, adoptPiFallbackToolOwnerTag, adoptPiFallbackMessageTag, getMaxTagNumberBySession, getTagNumberByMessageId, deriveTagLoadFloor, getTagsBySession, getActiveTagsBySession, getTagsForPendingOperations, getTagsByNumbers, getDroppedTagsByNumbers, getMaxDroppedTagNumber, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, BoundedSessionMap, getWindowOverlay, resolveWindowOverlayFacts, deriveWindowGeometry, formatWindowDerivationLine, isSaneLimit, resolveOutputReserve, getSdkContextLimit, resolveModelConfigOrDefault, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, isMidTurnPi, readPiSessionSnapshot, readPiSessionMessages, findLastModelKeyFromBranch, convertEntriesToRawMessages, withContentLanguageDirective, withMigrationLanguageDirective, buildPrimaryLanguageDirective, computeCueContentHash, hasMuralCueColumns, getMuralCueState, memoryNeedsCue, setMuralCue, recordMuralCueRejection, invalidateMemory, computeNormalizedHash, hasMemoryShareableColumn, hasMemoryClassifiedAtColumn, getUnclassifiedMemoryIds, insertMemory, getMemoryByHash, getMemoriesByProject, getMemoriesByProjects, getMaxMemoryIdForProjects, getAllActiveMemoriesForMigration, getMemoryById, setMemoryClassification, archiveMemory, deleteMemory, getMemoryCount, getMemoryCountsByStatus, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getOpenCodeDbPath2 as getOpenCodeDbPath, parseCron, nextOccurrence, nextDueAtMs, DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE, DEFAULT_HISTORIAN_TIMEOUT_MS, buildCanonicalChunkTextFromFts, buildCompartmentSummaryFallbackText, canonicalizeInMemoryChunkTextForEmbedding, chunkCanonicalText, chunkEmbeddingWindowsAreCurrent, replaceCompartmentChunkEmbeddings, cosineSimilarity, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease, contentSha256, sweepStaleEmbeddingIdentitiesForProject, enqueueShadowEmbeddingItems, getProjectEmbeddingSnapshot, getProjectChunkEmbeddingModelId, getProjectEmbeddingMaxInputTokens, embedTextForProject, embedBatchForProject, embedItemsForProject, embedUnembeddedMemoriesForProject, drainCommitBacklogForProject, embedSessionCompartmentChunks, getEmbeddingCoverageStatus, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, wakePlaneStatus, indexCommitsForProject, embedUnembeddedCommits, loadPiConfig, ensureProjectRegisteredFromPiDirectory, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, temporalMarkerPrefix, clearInjectionCache, getVisibleMemoryIds, renderMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, unifiedSearch, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, registerMagicContextTools };
|
|
57205
|
+
export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, migrateMagicContextConfigLocations, FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, createFailClosedController, ProjectIdentityError, resolveProjectIdentityStrict, resolveProjectIdentity, resolveProjectIdentityForSession, beginBootQuietPeriod, scheduleAfterBootQuiet, Database, closeQuietly, isMidTurn, textMentionsRecentCommit, hasMeaningfulUserText, extractTexts, extractToolCallSummaries, preloadTokenizer, estimateTokens, normalizeText, isRecord, completedToolArcCrossesBoundary, estimateTrueRawMessageTokens, buildToolArcs, fenceBoundaryForCompletedToolArcs, fenceBoundaryForToolArcs, buildTrueRawTokenIndex, computeRawRangeFingerprint, invalidateTrueRawTokenCache, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isEditTool, applyEditMarkerToInput, setRawMessageProvider, withRawMessageProvider, cleanUserText, withRawSessionMessageCache, readRawSessionMessages, primeTailRawMessageCache, getCachedAbsoluteMessageCount, primeInMemoryTailRawMessageCache, getRawSessionMessageCount, getRawSessionTagKeysThrough, getLegacyProtectedTailStartOrdinal, readSessionChunk, clearCompressionDepth, clearCompressionDepthRange, getMessageIndexSourceIdentity, isMessageIndexSourceCurrent, getLastIndexedOrdinal, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, indexSingleMessage, indexMessagesAfterOrdinal, sweepOrphanedOpenCodeMessageIndexes, recordSessionProjectIdentity, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, isCompartmentLeaseHeld, piModelRefToCanonical, resolveModelRefForPi, modelRefLookupOrder, ompModelRefToCanonical, resolveModelRefForOmp, persistCachedM0, clearCachedM0M1, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getModuleNoteEvaluationBridge, getContextStoreUuid, parseCompartmentOutput, logSlowWriteTransaction, resolveWorkspaceShareCategories, resolveWorkspaceIdentitySet, expandWorkspaceIdentitySetWithAliases, sourceNameForMemory, computeWorkspaceEpochFingerprint, bumpEpochsForWorkspaceMembers, readProjectDocsCanonical, copySessionStateForClone, getErrorMessage, describeError, setStoragePrivatePermissionEnforcement, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, applySqliteTuningPragmas, runSqliteOptimize, openDatabase, openDatabaseAsync, queueM0Mutation, getMaxM0MutationId, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, MAX_EXECUTE_THRESHOLD, escalationBands, describeProtectedTailDrainBudgetSkip, loadProtectedTailMeta, markProtectedTailPolicyV3Seeded, recordProtectedTailPublicationFloor, recordProtectedTailNoEligibleHead, getWrapupInProgressState, isWrapupInProgress, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, 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, pruneAutoSearchHintDecisions, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, getNoteLastReadAt, getHistorianFailureState, incrementHistorianFailure, clearHistorianFailureState, getOverflowState, recordOverflowDetected, clearEmergencyRecovery, clearDetectedContextLimit, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, getProcessedImageStrippedIds, addProcessedImageStrippedIds, getPendingCompactionMarkerState, clearPendingCompactionMarkerStateIf, getPendingPiCompactionMarkerState, setPendingPiCompactionMarkerState, clearPendingPiCompactionMarkerStateIf, getSessionsWithPendingPiMarker, peekDeferredExecutePending, setDeferredExecutePendingIfAbsent, clearDeferredExecutePendingIfMatches, setSessionWorkMetrics, getSessionWorkMetrics, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, getNotes, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, markNoteReady, markNoteChecked, queuePendingOp, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, insertPrimerCandidates, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, replaceSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, CTX_REDUCE_KEEP, estimateImageTokensFromDataUrl, normalizeTodoStateJson, buildSyntheticTodoPart, stripChannel1ReminderSpans, effectiveTailHygiene, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, decideChannel1, evaluateChannel2, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, planEmergencyDrop, updateTagByteSize, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, updateTagInputByteSize, updateTagTokenCount, getPersistedToolTagAccounting, getAllStatusTagTokenTotalsFlat, updateTagInputTokenCount, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, updateTagDropMode, updateCavemanDepth, hasPiFallbackMessageTags, findAdoptableFallbackTags, hasPiFallbackToolOwnerTags, findPiFallbackToolOwnerTags, adoptPiFallbackToolOwnerTag, adoptPiFallbackMessageTag, getMaxTagNumberBySession, getTagNumberByMessageId, deriveTagLoadFloor, getTagsBySession, getActiveTagsBySession, getTagsForPendingOperations, getTagsByNumbers, getDroppedTagsByNumbers, getMaxDroppedTagNumber, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, BoundedSessionMap, getWindowOverlay, resolveWindowOverlayFacts, deriveWindowGeometry, formatWindowDerivationLine, isSaneLimit, resolveOutputReserve, getSdkContextLimit, resolveModelConfigOrDefault, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, isMidTurnPi, readPiSessionSnapshot, readPiSessionMessages, findLastModelKeyFromBranch, convertEntriesToRawMessages, withContentLanguageDirective, withMigrationLanguageDirective, buildPrimaryLanguageDirective, computeCueContentHash, hasMuralCueColumns, getMuralCueState, memoryNeedsCue, setMuralCue, recordMuralCueRejection, invalidateMemory, computeNormalizedHash, hasMemoryShareableColumn, hasMemoryClassifiedAtColumn, getUnclassifiedMemoryIds, insertMemory, getMemoryByHash, getMemoriesByProject, getMemoriesByProjects, getMaxMemoryIdForProjects, getAllActiveMemoriesForMigration, getMemoryById, setMemoryClassification, archiveMemory, deleteMemory, getMemoryCount, getMemoryCountsByStatus, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getOpenCodeDbPath2 as getOpenCodeDbPath, parseCron, nextOccurrence, nextDueAtMs, DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE, DEFAULT_HISTORIAN_TIMEOUT_MS, buildCanonicalChunkTextFromFts, buildCompartmentSummaryFallbackText, canonicalizeInMemoryChunkTextForEmbedding, chunkCanonicalText, chunkEmbeddingWindowsAreCurrent, replaceCompartmentChunkEmbeddings, cosineSimilarity, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease, contentSha256, sweepStaleEmbeddingIdentitiesForProject, enqueueShadowEmbeddingItems, getProjectEmbeddingSnapshot, getProjectChunkEmbeddingModelId, getProjectEmbeddingMaxInputTokens, embedTextForProject, embedBatchForProject, embedItemsForProject, embedUnembeddedMemoriesForProject, drainCommitBacklogForProject, embedSessionCompartmentChunks, getEmbeddingCoverageStatus, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, wakePlaneStatus, indexCommitsForProject, embedUnembeddedCommits, loadPiConfig, ensureProjectRegisteredFromPiDirectory, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, temporalMarkerPrefix, clearInjectionCache, getVisibleMemoryIds, renderMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, unifiedSearch, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, registerMagicContextTools };
|