@cortexkit/pi-magic-context 0.49.15 → 0.49.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-search-worker.js +3 -3
- package/dist/chunk-embedding-write-worker.js +8 -6
- package/dist/{embedding-backfill-7kj16fh9.js → embedding-backfill-c4bdw8pp.js} +10 -8
- package/dist/embedding-worker.js +2 -2
- package/dist/index-1cvyaw9a.js +58 -0
- package/dist/{index-hshd96pt.js → index-4178cbfw.js} +19 -68
- package/dist/{index-75ah9413.js → index-44h64qza.js} +3 -3
- package/dist/{index-9jvktm7k.js → index-657xh9w4.js} +1 -1
- package/dist/{index-7qc73yk5.js → index-afy3dzf9.js} +3 -3
- package/dist/{index-1k729e4f.js → index-bxmf4dhr.js} +6 -6
- package/dist/{index-j0n09wtp.js → index-dne4ja7a.js} +7 -5
- package/dist/{index-a4pk5yv9.js → index-fhyy4ave.js} +14 -14
- package/dist/index-ja1c33qa.js +62 -0
- package/dist/{index-1mrvw9en.js → index-mx59cve4.js} +1 -1
- package/dist/{index-nwbhe6qv.js → index-n3r2d2pr.js} +5 -5
- package/dist/{index-7wagp5jp.js → index-p3evwech.js} +3 -3
- package/dist/{index-he9s4qsj.js → index-qqxqwqhp.js} +22 -2
- package/dist/{index-djxc8w8c.js → index-s1xn8qfw.js} +21 -25
- package/dist/{index-bet4sd3e.js → index-tympym62.js} +1 -1
- package/dist/{index-ccsscaap.js → index-v8d4vgam.js} +37 -16
- package/dist/index-wrr9rp9a.js +16 -0
- package/dist/{index-1vw4f2pe.js → index-x3k1530z.js} +5 -7
- package/dist/{index-0awvkeb5.js → index-xmzhrht0.js} +10 -61
- package/dist/{index-6ex901g3.js → index-y5c73caa.js} +2 -2
- package/dist/index.js +183 -130
- package/dist/message-fts-rowid-map-mbanfkt1.js +22 -0
- package/dist/{message-index-bounded-z4d3x9ty.js → message-index-bounded-xzerjxmp.js} +7 -7
- package/dist/{message-index-dw4z9efj.js → message-index-easvmz22.js} +8 -8
- package/dist/{message-time-backfill-r2ar1qvk.js → message-time-backfill-3q4kemfc.js} +4 -4
- package/dist/migration-worker.js +6 -4
- package/dist/{project-embedding-registry-52zwmtbn.js → project-embedding-registry-xwnmqmx8.js} +9 -7
- package/dist/raw-ordinal-warmup-worker.js +37 -7
- package/dist/{read-session-chunk-0fsgg2k1.js → read-session-chunk-1sb5n7zs.js} +5 -5
- package/dist/{read-session-raw-azkqjgzg.js → read-session-raw-jz5e9jz0.js} +1 -1
- package/dist/search-archive-3ma5n0wr.js +20 -0
- package/dist/{search-ddbz6v60.js → search-x3fa0561.js} +16 -15
- package/dist/{storage-tags-3kb5tvgg.js → storage-tags-jtessrec.js} +1 -1
- package/dist/subagent-entry.js +19 -17
- package/dist/tag-snapshot-worker-pi.js +15 -18
- package/package.json +1 -1
|
@@ -38,20 +38,20 @@ import {
|
|
|
38
38
|
countSessionCompartmentEmbedCoverage,
|
|
39
39
|
countSessionCompartmentEmbedCoveragePolite,
|
|
40
40
|
countUnembeddedSessionCompartmentsPolite
|
|
41
|
-
} from "./index-
|
|
41
|
+
} from "./index-afy3dzf9.js";
|
|
42
42
|
import {
|
|
43
43
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-bxmf4dhr.js";
|
|
45
45
|
import {
|
|
46
46
|
embeddingModelsMatch,
|
|
47
47
|
resolveEmbeddingTextPrefixes,
|
|
48
48
|
getEmbeddingProviderIdentity,
|
|
49
49
|
dominantEmbeddingFailure,
|
|
50
50
|
LocalEmbeddingProvider
|
|
51
|
-
} from "./index-
|
|
51
|
+
} from "./index-657xh9w4.js";
|
|
52
52
|
import {
|
|
53
53
|
setBootQuietPeriodForTests
|
|
54
|
-
} from "./index-
|
|
54
|
+
} from "./index-y5c73caa.js";
|
|
55
55
|
import {
|
|
56
56
|
isEmbeddingHostBusy2
|
|
57
57
|
} from "./index-9p40dgkm.js";
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
acquireGitSweepLease,
|
|
63
63
|
renewGitSweepLease,
|
|
64
64
|
releaseGitSweepLease
|
|
65
|
-
} from "./index-
|
|
65
|
+
} from "./index-mx59cve4.js";
|
|
66
66
|
import {
|
|
67
67
|
saveEmbeddingIfHashMatches,
|
|
68
68
|
getMemoryEmbedCoverage,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-bxmf4dhr.js";
|
|
4
4
|
import {
|
|
5
5
|
log2
|
|
6
6
|
} from "./index-7bqrfyny.js";
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
} from "./index-6dz2ed1v.js";
|
|
11
11
|
import {
|
|
12
12
|
LocalEmbeddingProvider
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-657xh9w4.js";
|
|
14
14
|
import {
|
|
15
15
|
OpenAICompatibleEmbeddingProvider,
|
|
16
16
|
getProjectEmbeddingSnapshot2,
|
|
17
17
|
embedBatchForProject2
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-n3r2d2pr.js";
|
|
19
19
|
import {
|
|
20
20
|
isEmbeddingHostBusy2
|
|
21
21
|
} from "./index-9p40dgkm.js";
|
|
@@ -43,6 +43,7 @@ function ensureExitHook() {
|
|
|
43
43
|
function runSessionWarmupWorker(input, options) {
|
|
44
44
|
ensureExitHook();
|
|
45
45
|
return new Promise((resolve) => {
|
|
46
|
+
const openCancellation = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
46
47
|
let worker;
|
|
47
48
|
let deadline;
|
|
48
49
|
let settled = false;
|
|
@@ -50,7 +51,9 @@ function runSessionWarmupWorker(input, options) {
|
|
|
50
51
|
if (settled)
|
|
51
52
|
return;
|
|
52
53
|
settled = true;
|
|
54
|
+
Atomics.store(openCancellation, 0, 1);
|
|
53
55
|
clearTimeout(deadline);
|
|
56
|
+
options.signal?.removeEventListener("abort", abort);
|
|
54
57
|
if (worker) {
|
|
55
58
|
activeWorkers.delete(worker);
|
|
56
59
|
const stopped = worker.terminate();
|
|
@@ -69,8 +72,16 @@ function runSessionWarmupWorker(input, options) {
|
|
|
69
72
|
deadline = setTimeout(() => finish({ failure, detail: `no reply within ${ms} ms` }), ms);
|
|
70
73
|
deadline.unref?.();
|
|
71
74
|
};
|
|
75
|
+
const abort = () => finish({ failure: "stopped", detail: "stopped" });
|
|
76
|
+
if (options.signal?.aborted) {
|
|
77
|
+
abort();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
72
81
|
try {
|
|
73
|
-
worker = inRootAsyncContext2(() => new Worker(options.entry ?? defaultEntry(), {
|
|
82
|
+
worker = inRootAsyncContext2(() => new Worker(options.entry ?? defaultEntry(), {
|
|
83
|
+
workerData: { ...input, openCancellation: openCancellation.buffer }
|
|
84
|
+
}));
|
|
74
85
|
} catch (error) {
|
|
75
86
|
finish({ failure: "start-failed", detail: String(error) });
|
|
76
87
|
return;
|
|
@@ -93,8 +104,17 @@ function runSessionWarmupWorker(input, options) {
|
|
|
93
104
|
finish({ orphanSweep: reply.result });
|
|
94
105
|
else if (reply.kind === "exact-ordinal-ids")
|
|
95
106
|
finish({ exactOrdinalIds: reply.ids });
|
|
107
|
+
else if (reply.kind === "search-archive")
|
|
108
|
+
finish({ searchArchive: reply.text });
|
|
109
|
+
else if (reply.kind === "fts-rowid-backfill")
|
|
110
|
+
finish({ ftsRowidBackfill: true });
|
|
96
111
|
else
|
|
97
|
-
finish({
|
|
112
|
+
finish({
|
|
113
|
+
failure: "worker-error",
|
|
114
|
+
detail: reply.error,
|
|
115
|
+
code: reply.code,
|
|
116
|
+
errcode: reply.errcode
|
|
117
|
+
});
|
|
98
118
|
});
|
|
99
119
|
worker.on("error", (error) => finish({ failure: "worker-error", detail: String(error) }));
|
|
100
120
|
worker.on("exit", (code) => finish({ failure: "exited", detail: `exit code ${code}` }));
|
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getSqliteDatabasePath2,
|
|
2
3
|
withSqliteBackgroundWriter2,
|
|
3
4
|
withoutSqliteTransformPass2
|
|
4
5
|
} from "./index-asrxgdt4.js";
|
|
6
|
+
import {
|
|
7
|
+
runSessionWarmupWorker
|
|
8
|
+
} from "./index-qqxqwqhp.js";
|
|
5
9
|
import {
|
|
6
10
|
logSlowWriteTransaction
|
|
7
11
|
} from "./index-d4dt19md.js";
|
|
8
12
|
|
|
9
|
-
// ../plugin/src/shared/project-directory-key.ts
|
|
10
|
-
import path from "node:path";
|
|
11
|
-
function projectDirectoryKey(directory) {
|
|
12
|
-
const slashed = directory.replaceAll("\\", "/").replace(/^\/\/\?\/UNC\//i, "//").replace(/^\/\/\?\//, "");
|
|
13
|
-
if (/^[a-z]:\//i.test(slashed) || slashed.startsWith("//")) {
|
|
14
|
-
return path.win32.normalize(slashed).replaceAll("\\", "/").replace(/\/$/, "").toLowerCase();
|
|
15
|
-
}
|
|
16
|
-
return path.resolve(directory);
|
|
17
|
-
}
|
|
18
|
-
function sameProjectDirectory(a, b) {
|
|
19
|
-
if (a.length === 0 || b.length === 0)
|
|
20
|
-
return false;
|
|
21
|
-
return projectDirectoryKey(a) === projectDirectoryKey(b);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
13
|
// ../plugin/src/features/magic-context/message-fts-rowid-map.ts
|
|
25
14
|
import { createHash } from "node:crypto";
|
|
26
15
|
var MESSAGE_FTS_ROWID_MAP_BACKFILL_BATCH_SIZE = 100;
|
|
@@ -56,7 +45,7 @@ function getBackfillState(db) {
|
|
|
56
45
|
completed: row?.completed === 1
|
|
57
46
|
};
|
|
58
47
|
}
|
|
59
|
-
function
|
|
48
|
+
function recordMessageFtsRowid2(db, sessionId, messageOrdinal, ftsRowid, messageTimeMs = null) {
|
|
60
49
|
const numericRowid = Number(ftsRowid);
|
|
61
50
|
if (!Number.isSafeInteger(numericRowid) || numericRowid <= 0) {
|
|
62
51
|
throw new Error(`invalid message FTS rowid: ${String(ftsRowid)}`);
|
|
@@ -64,7 +53,7 @@ function recordMessageFtsRowid(db, sessionId, messageOrdinal, ftsRowid, messageT
|
|
|
64
53
|
const normalizedTime = typeof messageTimeMs === "number" && Number.isSafeInteger(messageTimeMs) && messageTimeMs >= 0 ? messageTimeMs : null;
|
|
65
54
|
getUpsertMapStatement(db).run(sessionId, messageOrdinal, numericRowid, normalizedTime);
|
|
66
55
|
}
|
|
67
|
-
function
|
|
56
|
+
function recordIndexedMessageTime2(db, sessionId, messageOrdinal, messageTimeMs) {
|
|
68
57
|
if (typeof messageTimeMs !== "number" || !Number.isSafeInteger(messageTimeMs) || messageTimeMs < 0) {
|
|
69
58
|
return;
|
|
70
59
|
}
|
|
@@ -106,7 +95,7 @@ function backfillMessageFtsRowidMapBatch(db, batchSize = MESSAGE_FTS_ROWID_MAP_B
|
|
|
106
95
|
watermarkRowid = ftsRowid;
|
|
107
96
|
}
|
|
108
97
|
if (typeof row.sessionId === "string" && Number.isSafeInteger(messageOrdinal) && messageOrdinal >= 0 && Number.isSafeInteger(ftsRowid) && ftsRowid > 0) {
|
|
109
|
-
|
|
98
|
+
recordMessageFtsRowid2(db, row.sessionId, messageOrdinal, ftsRowid);
|
|
110
99
|
}
|
|
111
100
|
}
|
|
112
101
|
const completed = rows.length < boundedBatchSize;
|
|
@@ -122,26 +111,33 @@ function backfillMessageFtsRowidMapBatch(db, batchSize = MESSAGE_FTS_ROWID_MAP_B
|
|
|
122
111
|
logSlowWriteTransaction("message_fts_rowid_backfill", transactionStartedAt);
|
|
123
112
|
return progress;
|
|
124
113
|
}
|
|
125
|
-
async function
|
|
114
|
+
async function runMessageFtsRowidMapBackfill2(db, signal) {
|
|
126
115
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
127
|
-
|
|
116
|
+
while (!signal?.aborted) {
|
|
128
117
|
const progress = backfillMessageFtsRowidMapBatch(db);
|
|
129
118
|
if (progress.completed)
|
|
130
119
|
return;
|
|
131
120
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
132
121
|
}
|
|
133
122
|
}
|
|
134
|
-
function
|
|
123
|
+
function startMessageFtsRowidMapBackfill2(db, signal) {
|
|
135
124
|
const active = activeBackfills.get(db);
|
|
136
125
|
if (active)
|
|
137
126
|
return active;
|
|
138
|
-
const
|
|
127
|
+
const path = getSqliteDatabasePath2(db);
|
|
128
|
+
const run = (path ? runSessionWarmupWorker({ path, sessionId: "", ftsRowidBackfill: true }, { signal }).then((result) => {
|
|
129
|
+
if (signal?.aborted)
|
|
130
|
+
return;
|
|
131
|
+
if (!("ftsRowidBackfill" in result)) {
|
|
132
|
+
throw Object.assign(new Error(`FTS rowid backfill unavailable: ${"failure" in result ? result.detail : "unexpected reply"}`), "failure" in result ? { code: result.code, errcode: result.errcode } : {});
|
|
133
|
+
}
|
|
134
|
+
}) : withoutSqliteTransformPass2(() => withSqliteBackgroundWriter2(() => runMessageFtsRowidMapBackfill2(db, signal)))).finally(() => {
|
|
139
135
|
activeBackfills.delete(db);
|
|
140
136
|
});
|
|
141
137
|
activeBackfills.set(db, run);
|
|
142
138
|
return run;
|
|
143
139
|
}
|
|
144
|
-
function
|
|
140
|
+
function messageFtsOrdinalRangeIsMapped2(db, sessionId, startOrdinal, endOrdinal) {
|
|
145
141
|
if (endOrdinal < startOrdinal)
|
|
146
142
|
return true;
|
|
147
143
|
if (getBackfillState(db).completed)
|
|
@@ -172,7 +168,7 @@ function messageFtsOrdinalRangeIsMapped(db, sessionId, startOrdinal, endOrdinal)
|
|
|
172
168
|
const ordinalCount = endOrdinal - startOrdinal + 1;
|
|
173
169
|
return row?.sourceOrdinalCount === ordinalCount && row.expectedMapCount === row.mappedCount;
|
|
174
170
|
}
|
|
175
|
-
function
|
|
171
|
+
function deleteUnmappedMessageFtsRows2(db, sessionIds) {
|
|
176
172
|
if (sessionIds.length === 0)
|
|
177
173
|
return;
|
|
178
174
|
const state = getBackfillState(db);
|
|
@@ -183,4 +179,4 @@ function deleteUnmappedMessageFtsRows(db, sessionIds) {
|
|
|
183
179
|
WHERE rowid > ? AND session_id IN (${placeholders})`).run(state.watermarkRowid, ...sessionIds);
|
|
184
180
|
}
|
|
185
181
|
|
|
186
|
-
export {
|
|
182
|
+
export { recordMessageFtsRowid2, recordIndexedMessageTime2, runMessageFtsRowidMapBackfill2, startMessageFtsRowidMapBackfill2, messageFtsOrdinalRangeIsMapped2, deleteUnmappedMessageFtsRows2 };
|
|
@@ -18,9 +18,8 @@ import {
|
|
|
18
18
|
withPrivilegedWriter2
|
|
19
19
|
} from "./index-asrxgdt4.js";
|
|
20
20
|
import {
|
|
21
|
-
bootQuietRemainingMs,
|
|
22
21
|
scheduleAfterBootQuiet
|
|
23
|
-
} from "./index-
|
|
22
|
+
} from "./index-y5c73caa.js";
|
|
24
23
|
import {
|
|
25
24
|
getHarness2,
|
|
26
25
|
harnessOwnsOpenCodeStore2
|
|
@@ -40,8 +39,8 @@ import {
|
|
|
40
39
|
configureContextDatabasePragmas2
|
|
41
40
|
} from "./index-fapenpch.js";
|
|
42
41
|
import {
|
|
43
|
-
|
|
44
|
-
} from "./index-
|
|
42
|
+
startMessageFtsRowidMapBackfill2
|
|
43
|
+
} from "./index-s1xn8qfw.js";
|
|
45
44
|
import {
|
|
46
45
|
LKG_SLOT_CHUNKS_DDL,
|
|
47
46
|
SESSION_REPLAY_DECISIONS_DDL,
|
|
@@ -51,7 +50,7 @@ import {
|
|
|
51
50
|
hasPendingMigrations,
|
|
52
51
|
getMainThreadMigrationBodyCount,
|
|
53
52
|
runMigrations
|
|
54
|
-
} from "./index-
|
|
53
|
+
} from "./index-tympym62.js";
|
|
55
54
|
import {
|
|
56
55
|
closeQuietly,
|
|
57
56
|
ensureColumn,
|
|
@@ -852,6 +851,8 @@ registerSlowWriteReporter2(logSlowWriteTransaction);
|
|
|
852
851
|
registerSqliteDiagnosticSink2((message) => log2(message), getHarness2);
|
|
853
852
|
var databases = new Map;
|
|
854
853
|
var pendingAsyncOpens = new Map;
|
|
854
|
+
var pendingDatabaseCloses = new Set;
|
|
855
|
+
var startupBackfills = new WeakMap;
|
|
855
856
|
var persistenceByDatabase = new WeakMap;
|
|
856
857
|
var persistenceErrorByDatabase = new WeakMap;
|
|
857
858
|
var pathByDatabase = new WeakMap;
|
|
@@ -1286,8 +1287,14 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1286
1287
|
healWedgedChannel2Claims(db);
|
|
1287
1288
|
if (!explicitDbPath) {
|
|
1288
1289
|
const readsOpenCodeStore = harnessOwnsOpenCodeStore2();
|
|
1290
|
+
const state = { controller: new AbortController };
|
|
1291
|
+
startupBackfills.set(db, state);
|
|
1292
|
+
const { signal } = state.controller;
|
|
1289
1293
|
let busyRetryMs = 100;
|
|
1290
1294
|
const runBackfills = () => withoutSqliteTransformPass2(() => withSqliteBackgroundWriter2(() => {
|
|
1295
|
+
state.timer = undefined;
|
|
1296
|
+
if (signal.aborted)
|
|
1297
|
+
return;
|
|
1291
1298
|
if (readsOpenCodeStore) {
|
|
1292
1299
|
try {
|
|
1293
1300
|
runToolOwnerBackfill(db);
|
|
@@ -1295,19 +1302,23 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1295
1302
|
log2(`[magic-context] tool-owner backfill failed (continuing with lazy adoption fallback): ${getErrorMessage(error)}`);
|
|
1296
1303
|
}
|
|
1297
1304
|
}
|
|
1298
|
-
|
|
1299
|
-
if (!readsOpenCodeStore)
|
|
1305
|
+
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1306
|
+
if (signal.aborted || !readsOpenCodeStore)
|
|
1307
|
+
return;
|
|
1308
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-1sb5n7zs.js"));
|
|
1309
|
+
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-3q4kemfc.js"));
|
|
1310
|
+
if (signal.aborted)
|
|
1300
1311
|
return;
|
|
1301
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-0fsgg2k1.js"));
|
|
1302
|
-
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-r2ar1qvk.js"));
|
|
1303
1312
|
await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
|
|
1304
1313
|
readPage: readRawSessionMessagePage
|
|
1305
|
-
}));
|
|
1314
|
+
}), signal);
|
|
1306
1315
|
}).catch((error) => {
|
|
1316
|
+
if (signal.aborted)
|
|
1317
|
+
return;
|
|
1307
1318
|
if (isTransientSqliteError2(error)) {
|
|
1308
1319
|
withoutSqliteTransformPass2(() => {
|
|
1309
|
-
|
|
1310
|
-
timer.unref();
|
|
1320
|
+
state.timer = setTimeout(runBackfills, busyRetryMs);
|
|
1321
|
+
state.timer.unref?.();
|
|
1311
1322
|
});
|
|
1312
1323
|
busyRetryMs = Math.min(30000, busyRetryMs * 2);
|
|
1313
1324
|
return;
|
|
@@ -1315,10 +1326,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1315
1326
|
log2(`[magic-context] message-index backfill failed (will resume next startup): ${getErrorMessage(error)}`);
|
|
1316
1327
|
});
|
|
1317
1328
|
}));
|
|
1318
|
-
|
|
1319
|
-
scheduleAfterBootQuiet(runBackfills);
|
|
1320
|
-
else
|
|
1321
|
-
runBackfills();
|
|
1329
|
+
state.timer = scheduleAfterBootQuiet(runBackfills);
|
|
1322
1330
|
}
|
|
1323
1331
|
setDatabase(db);
|
|
1324
1332
|
loadToolDefinitionMeasurements(db);
|
|
@@ -2782,6 +2790,18 @@ async function openDatabaseAsync(dbPathOrOptions) {
|
|
|
2782
2790
|
function closeDatabase() {
|
|
2783
2791
|
pendingAsyncOpens.clear();
|
|
2784
2792
|
for (const [key, db] of databases) {
|
|
2793
|
+
const state = startupBackfills.get(db);
|
|
2794
|
+
if (state) {
|
|
2795
|
+
clearTimeout(state.timer);
|
|
2796
|
+
state.controller.abort();
|
|
2797
|
+
startupBackfills.delete(db);
|
|
2798
|
+
if (state.running) {
|
|
2799
|
+
const closing = state.running.finally(() => {
|
|
2800
|
+
pendingDatabaseCloses.delete(closing);
|
|
2801
|
+
});
|
|
2802
|
+
pendingDatabaseCloses.add(closing);
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2785
2805
|
try {
|
|
2786
2806
|
closeQuietly(db);
|
|
2787
2807
|
} catch (error) {
|
|
@@ -2790,6 +2810,7 @@ function closeDatabase() {
|
|
|
2790
2810
|
databases.delete(key);
|
|
2791
2811
|
}
|
|
2792
2812
|
}
|
|
2813
|
+
return Promise.all(pendingDatabaseCloses).then(() => {});
|
|
2793
2814
|
}
|
|
2794
2815
|
|
|
2795
2816
|
export { FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, createFailClosedController, getErrorMessage, describeError, startBootDeadline, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, enforceSchemaFence, setSqlitePragmaConfig, applySqliteTuningPragmas, runSqliteOptimize, initializeDatabase, openDatabase, openCurrentDatabase, openDatabaseAsync, closeDatabase };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// ../plugin/src/shared/project-directory-key.ts
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
function projectDirectoryKey(directory) {
|
|
4
|
+
const slashed = directory.replaceAll("\\", "/").replace(/^\/\/\?\/UNC\//i, "//").replace(/^\/\/\?\//, "");
|
|
5
|
+
if (/^[a-z]:\//i.test(slashed) || slashed.startsWith("//")) {
|
|
6
|
+
return path.win32.normalize(slashed).replaceAll("\\", "/").replace(/\/$/, "").toLowerCase();
|
|
7
|
+
}
|
|
8
|
+
return path.resolve(directory);
|
|
9
|
+
}
|
|
10
|
+
function sameProjectDirectory(a, b) {
|
|
11
|
+
if (a.length === 0 || b.length === 0)
|
|
12
|
+
return false;
|
|
13
|
+
return projectDirectoryKey(a) === projectDirectoryKey(b);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { projectDirectoryKey, sameProjectDirectory };
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
getTagsBySession2,
|
|
9
9
|
getTagsByNumbers2
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-dne4ja7a.js";
|
|
11
11
|
import {
|
|
12
12
|
inRootAsyncContext2,
|
|
13
13
|
getSqliteDatabasePath2
|
|
14
14
|
} from "./index-asrxgdt4.js";
|
|
15
15
|
import {
|
|
16
16
|
createFailClosedBlockingError
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-v8d4vgam.js";
|
|
18
18
|
|
|
19
19
|
// src/tag-snapshot-worker-client-pi.ts
|
|
20
20
|
import { setImmediate as yieldImmediate } from "node:timers/promises";
|
|
@@ -410,7 +410,6 @@ function createPiTagSnapshotReader(db) {
|
|
|
410
410
|
let desiredSession;
|
|
411
411
|
let failedUntil = 0;
|
|
412
412
|
let lastFailure;
|
|
413
|
-
const dataVersion = db.prepare("PRAGMA data_version");
|
|
414
413
|
const totalRevision = db.prepare("SELECT COALESCE(value, '0') AS revision, value IS NOT NULL AS present FROM (SELECT 1) LEFT JOIN schema_migrations_meta ON key = ?");
|
|
415
414
|
const assertOutsideTransaction = () => {
|
|
416
415
|
const connection = db;
|
|
@@ -433,7 +432,6 @@ function createPiTagSnapshotReader(db) {
|
|
|
433
432
|
foreignRevision: revision[1],
|
|
434
433
|
durableVersion: stamp.durable,
|
|
435
434
|
ownVersion: stamp.own,
|
|
436
|
-
dataVersion: dataVersion.get().data_version,
|
|
437
435
|
totalRevision: total.revision,
|
|
438
436
|
revisionPresent: total.present
|
|
439
437
|
};
|
|
@@ -684,7 +682,7 @@ function sameRow(left, right, keys) {
|
|
|
684
682
|
return true;
|
|
685
683
|
}
|
|
686
684
|
function samePiTagSnapshotToken(left, right) {
|
|
687
|
-
return left.connectionEpoch === right.connectionEpoch && left.sessionEpoch === right.sessionEpoch && left.jobId === right.jobId && left.sessionId === right.sessionId && left.localRevision === right.localRevision && left.foreignRevision === right.foreignRevision && left.durableVersion === right.durableVersion && left.ownVersion === right.ownVersion
|
|
685
|
+
return left.connectionEpoch === right.connectionEpoch && left.sessionEpoch === right.sessionEpoch && left.jobId === right.jobId && left.sessionId === right.sessionId && left.localRevision === right.localRevision && left.foreignRevision === right.foreignRevision && left.durableVersion === right.durableVersion && left.ownVersion === right.ownVersion;
|
|
688
686
|
}
|
|
689
687
|
function candidateRowBytes(row, overhead) {
|
|
690
688
|
let bytes = overhead;
|
|
@@ -877,7 +875,7 @@ function ensurePiTagSnapshotReady(db, sessionId, budget) {
|
|
|
877
875
|
}
|
|
878
876
|
const end = deadline;
|
|
879
877
|
return (async () => {
|
|
880
|
-
for (
|
|
878
|
+
for (;; ) {
|
|
881
879
|
budget.assert();
|
|
882
880
|
const allowance = Math.min(end - performance.now(), budget.hydrationAllowance());
|
|
883
881
|
if (allowance <= 0)
|
|
@@ -895,7 +893,7 @@ function ensurePiTagSnapshotReady(db, sessionId, budget) {
|
|
|
895
893
|
return;
|
|
896
894
|
} catch (error) {
|
|
897
895
|
budget.assert();
|
|
898
|
-
if (!(error instanceof PiTagHydrationError && error.code === "stale"
|
|
896
|
+
if (!(error instanceof PiTagHydrationError && error.code === "stale"))
|
|
899
897
|
throw error;
|
|
900
898
|
} finally {
|
|
901
899
|
clearTimeout(timer);
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveStoredPathWorkspaceIdentity,
|
|
23
23
|
sourceNameForMemory,
|
|
24
24
|
managedAuthorityNoteRow
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-tympym62.js";
|
|
26
26
|
import {
|
|
27
27
|
isKnownAutocommit
|
|
28
28
|
} from "./index-jrap43gc.js";
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
import {
|
|
33
33
|
buildCanonicalChunkTextFromFts,
|
|
34
34
|
loadCompartmentChunkEmbeddingsForSearch
|
|
35
|
-
} from "./index-
|
|
35
|
+
} from "./index-afy3dzf9.js";
|
|
36
36
|
import {
|
|
37
37
|
recordEmbeddingMeasurement,
|
|
38
38
|
saveCommitEmbedding,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
getProjectEmbeddingSnapshot2,
|
|
51
51
|
embedTextForProject2,
|
|
52
52
|
embedItemsForProject2
|
|
53
|
-
} from "./index-
|
|
53
|
+
} from "./index-n3r2d2pr.js";
|
|
54
54
|
import {
|
|
55
55
|
saveEmbeddingIfHashMatches,
|
|
56
56
|
getProjectEmbeddings2
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
isEmbeddingEnabled,
|
|
61
61
|
embedText,
|
|
62
62
|
ensureMemoryEmbeddings2
|
|
63
|
-
} from "./index-
|
|
63
|
+
} from "./index-p3evwech.js";
|
|
64
64
|
import {
|
|
65
65
|
getMemorySelectColumns2,
|
|
66
66
|
isMemoryRow2,
|
|
@@ -75,9 +75,13 @@ import {
|
|
|
75
75
|
updateMemorySeenCount2,
|
|
76
76
|
updateMemoryRetrievalCount2
|
|
77
77
|
} from "./index-hy44m6jc.js";
|
|
78
|
+
import {
|
|
79
|
+
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
80
|
+
withMessageFtsSessionFilter
|
|
81
|
+
} from "./index-1cvyaw9a.js";
|
|
78
82
|
import {
|
|
79
83
|
getIndexedMessageCorpusSize2
|
|
80
|
-
} from "./index-
|
|
84
|
+
} from "./index-fhyy4ave.js";
|
|
81
85
|
import {
|
|
82
86
|
computeNormalizedHash
|
|
83
87
|
} from "./index-9x1f96r8.js";
|
|
@@ -1793,61 +1797,6 @@ function searchGitCommitsSync(db, projectPath, query, options) {
|
|
|
1793
1797
|
});
|
|
1794
1798
|
return results.slice(0, options.limit);
|
|
1795
1799
|
}
|
|
1796
|
-
// ../plugin/src/features/magic-context/message-fts-session-filter.ts
|
|
1797
|
-
var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
|
|
1798
|
-
SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
|
|
1799
|
-
) AND `;
|
|
1800
|
-
var coverageCaches = new WeakMap;
|
|
1801
|
-
function getCoverageCache(db) {
|
|
1802
|
-
let cache = coverageCaches.get(db);
|
|
1803
|
-
if (!cache) {
|
|
1804
|
-
cache = {
|
|
1805
|
-
pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
|
|
1806
|
-
stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
|
|
1807
|
-
missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
|
|
1808
|
-
FROM message_history_fts WHERE rowid IN (
|
|
1809
|
-
SELECT id FROM message_history_fts_docsize
|
|
1810
|
-
EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
|
|
1811
|
-
)`)
|
|
1812
|
-
};
|
|
1813
|
-
coverageCaches.set(db, cache);
|
|
1814
|
-
}
|
|
1815
|
-
return cache;
|
|
1816
|
-
}
|
|
1817
|
-
function withMessageFtsSessionFilter(db, sessionId, read) {
|
|
1818
|
-
let cacheable = false;
|
|
1819
|
-
try {
|
|
1820
|
-
const transaction = db;
|
|
1821
|
-
cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
|
|
1822
|
-
if (!cacheable)
|
|
1823
|
-
coverageCaches.delete(db);
|
|
1824
|
-
} catch {
|
|
1825
|
-
coverageCaches.delete(db);
|
|
1826
|
-
}
|
|
1827
|
-
return db.transaction(() => {
|
|
1828
|
-
let sessionFirst = false;
|
|
1829
|
-
try {
|
|
1830
|
-
const cache = getCoverageCache(db);
|
|
1831
|
-
cache.pin.get();
|
|
1832
|
-
const stamp = cache.stamp.get();
|
|
1833
|
-
let incomplete = cache.incompleteSessions;
|
|
1834
|
-
if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
|
|
1835
|
-
const rows = cache.missing.all();
|
|
1836
|
-
incomplete = new Set(rows.map((row) => row.sessionId));
|
|
1837
|
-
if (cacheable) {
|
|
1838
|
-
cache.version = stamp.version;
|
|
1839
|
-
cache.changes = stamp.changes;
|
|
1840
|
-
cache.incompleteSessions = incomplete;
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
sessionFirst = !incomplete.has(sessionId);
|
|
1844
|
-
} catch {
|
|
1845
|
-
coverageCaches.delete(db);
|
|
1846
|
-
}
|
|
1847
|
-
return read(sessionFirst);
|
|
1848
|
-
}).deferred();
|
|
1849
|
-
}
|
|
1850
|
-
|
|
1851
1800
|
// ../plugin/src/features/magic-context/literal-probes.ts
|
|
1852
1801
|
var MAX_PROBES = 5;
|
|
1853
1802
|
var MIN_PROBE_LENGTH = 3;
|
|
@@ -3807,4 +3756,4 @@ ${bodyParts.join(`
|
|
|
3807
3756
|
`)}`;
|
|
3808
3757
|
}
|
|
3809
3758
|
|
|
3810
|
-
export { getNoteByIdInScope, getNotes, addNote, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, updateNote, dismissNotes, dismissNote, markNoteReady, markNoteChecked, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, insertPrimerCandidates, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, USER_FACING_FAILURES, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, projectNeedsSingleStoreMigration, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, indexCommitsForProject, embedUnembeddedCommits,
|
|
3759
|
+
export { getNoteByIdInScope, getNotes, addNote, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, updateNote, dismissNotes, dismissNote, markNoteReady, markNoteChecked, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, insertPrimerCandidates, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, USER_FACING_FAILURES, renderUserFacingFailure, userFacingFailureCode, renderCapabilityRefusal, renderDreamFailure, dreamFailureCode, renderEmbeddingFailure, renderSingleStoreMigrationRequiredRefusal, SingleStoreMigrationRequiredError, projectNeedsSingleStoreMigration, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, indexCommitsForProject, embedUnembeddedCommits, createUnifiedSearchDiagnostics2, searchMessageHistory2, parseIdShapedQuery2, resolveMemoriesByIdsForSearch2, unifiedSearch2, formatSearchResults2 };
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./index-asrxgdt4.js";
|
|
8
8
|
import {
|
|
9
9
|
projectDirectoryKey
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-wrr9rp9a.js";
|
|
11
11
|
import {
|
|
12
12
|
writeStorageFileAtomicSync
|
|
13
13
|
} from "./index-81nthk8j.js";
|
|
@@ -667,4 +667,4 @@ function setBootQuietPeriodForTests(startAtMs) {
|
|
|
667
667
|
bootQuietUntilMs = startAtMs === null ? 0 : startAtMs + BOOT_QUIET_MS;
|
|
668
668
|
}
|
|
669
669
|
|
|
670
|
-
export { setHomeProjectPermission, ProjectIdentityError, resolveProjectIdentityStrict, isUserHomeDirectory, resolveProjectIdentity, directoryHasGitMetadata, isUsableProjectIdentity, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, beginBootQuietPeriod,
|
|
670
|
+
export { setHomeProjectPermission, ProjectIdentityError, resolveProjectIdentityStrict, isUserHomeDirectory, resolveProjectIdentity, directoryHasGitMetadata, isUsableProjectIdentity, resolveProjectIdentityForSession, normalizeStoredProjectPath, storedPathBelongsToIdentity, beginBootQuietPeriod, scheduleAfterBootQuiet, setBootQuietPeriodForTests };
|