@cortexkit/pi-magic-context 0.49.15 → 0.49.17
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 +76 -63
- package/dist/chunk-embedding-write-worker.js +11 -9
- package/dist/{compaction-marker-candidates-k4tqg4jb.js → compaction-marker-candidates-wjzqbspm.js} +2 -2
- package/dist/compaction-marker-candidates-worker.js +2 -2
- package/dist/embedding-backfill-vwag34t0.js +23 -0
- package/dist/embedding-worker-process.js +1 -1
- package/dist/embedding-worker.js +5 -5
- package/dist/historian-calibration-extension.js +4 -1
- package/dist/index-1cvyaw9a.js +58 -0
- package/dist/{index-g4jf772p.js → index-1kcfwk9c.js} +22 -2
- package/dist/{index-9jvktm7k.js → index-2mmy81qt.js} +3 -3
- package/dist/{index-ccsscaap.js → index-469ttgzv.js} +38 -17
- package/dist/index-4knyh1kt.js +1387 -0
- package/dist/{index-75ah9413.js → index-5k2mshvq.js} +10 -10
- package/dist/{index-a4pk5yv9.js → index-8r2t8fv2.js} +853 -84
- package/dist/{index-0awvkeb5.js → index-9j809q6f.js} +32 -72
- package/dist/{index-1k729e4f.js → index-bxmf4dhr.js} +6 -6
- package/dist/{index-6dz2ed1v.js → index-d8gc0112.js} +2 -2
- package/dist/{index-1vw4f2pe.js → index-dvbjsh98.js} +6 -8
- package/dist/{index-hy44m6jc.js → index-e1rza8gp.js} +1 -1
- package/dist/{index-j0n09wtp.js → index-ej4eak9d.js} +9 -7
- package/dist/{index-hshd96pt.js → index-es03azap.js} +127 -2093
- package/dist/{index-ajfpyk0x.js → index-fa485mqs.js} +59 -1
- package/dist/{index-6ex901g3.js → index-g7p75667.js} +33 -4
- package/dist/{index-bet4sd3e.js → index-gdjv1nnd.js} +2 -2
- package/dist/{index-46q4e104.js → index-qpq6w67c.js} +1 -1
- package/dist/{index-asrxgdt4.js → index-rrwv9y2k.js} +8 -0
- package/dist/{index-1mrvw9en.js → index-svgkv4g2.js} +1 -1
- package/dist/{index-he9s4qsj.js → index-vktahpdj.js} +23 -3
- package/dist/{index-nwbhe6qv.js → index-vmcgew7x.js} +11 -8
- package/dist/index-wrr9rp9a.js +16 -0
- package/dist/{index-7qc73yk5.js → index-xnch62s6.js} +14 -8
- package/dist/{index-djxc8w8c.js → index-yygsh681.js} +25 -26
- package/dist/{index-7wagp5jp.js → index-z2rkv0mb.js} +4 -4
- package/dist/index-z7kbck29.js +62 -0
- package/dist/index.js +688 -339
- package/dist/message-fts-rowid-map-cvpy2dmb.js +24 -0
- package/dist/{message-index-dw4z9efj.js → message-index-2g23b7fe.js} +13 -13
- package/dist/{message-index-bounded-z4d3x9ty.js → message-index-bounded-d6zj2tn5.js} +15 -15
- package/dist/{message-time-backfill-r2ar1qvk.js → message-time-backfill-ssshbdy8.js} +5 -5
- package/dist/migration-worker.js +8 -6
- package/dist/{project-embedding-registry-52zwmtbn.js → project-embedding-registry-vf1ncptn.js} +12 -10
- package/dist/raw-ordinal-warmup-worker.js +40 -10
- package/dist/{read-session-chunk-0fsgg2k1.js → read-session-chunk-2ky7mbqp.js} +7 -7
- package/dist/{read-session-raw-azkqjgzg.js → read-session-raw-9s3xn7fc.js} +2 -2
- package/dist/search-archive-9akqcr90.js +20 -0
- package/dist/{search-ddbz6v60.js → search-zjyc65g1.js} +20 -19
- package/dist/{sqlite-adjpy399.js → sqlite-fsp0sf3r.js} +1 -1
- package/dist/{storage-memory-axnsk5t1.js → storage-memory-yxxc5v4n.js} +2 -2
- package/dist/{storage-tags-3kb5tvgg.js → storage-tags-cx6ccsv1.js} +3 -3
- package/dist/subagent-entry.js +25 -22
- package/dist/tag-snapshot-worker-pi.js +17 -20
- package/package.json +1 -1
- package/dist/embedding-backfill-7kj16fh9.js +0 -21
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// ../plugin/src/hooks/magic-context/auto-search-worker.ts
|
|
2
2
|
import { parentPort, workerData } from "node:worker_threads";
|
|
3
|
-
|
|
4
|
-
if (!port)
|
|
3
|
+
if (!parentPort)
|
|
5
4
|
throw new Error("auto-search worker requires a parent port");
|
|
5
|
+
var port = parentPort;
|
|
6
6
|
var input = workerData;
|
|
7
|
+
var persistent = input.persistent === true;
|
|
7
8
|
if (input.job === "messages") {
|
|
8
9
|
port.postMessage({ kind: "accepted" });
|
|
9
10
|
}
|
|
@@ -18,19 +19,18 @@ var [
|
|
|
18
19
|
{ Database, registerSqliteDiagnosticSink },
|
|
19
20
|
{ log }
|
|
20
21
|
] = await Promise.all([
|
|
21
|
-
import("./embedding-backfill-
|
|
22
|
+
import("./embedding-backfill-vwag34t0.js"),
|
|
22
23
|
import("./embedding-cache-7rp4gqzr.js"),
|
|
23
|
-
import("./storage-memory-
|
|
24
|
-
import("./project-embedding-registry-
|
|
25
|
-
import("./search-
|
|
24
|
+
import("./storage-memory-yxxc5v4n.js"),
|
|
25
|
+
import("./project-embedding-registry-vf1ncptn.js"),
|
|
26
|
+
import("./search-zjyc65g1.js"),
|
|
26
27
|
import("./embedding-activity-ew6dshfd.js"),
|
|
27
28
|
import("./harness-9872e0ym.js"),
|
|
28
|
-
import("./sqlite-
|
|
29
|
+
import("./sqlite-fsp0sf3r.js"),
|
|
29
30
|
import("./logger-dygt96rn.js")
|
|
30
31
|
]);
|
|
31
32
|
setHarness(input.harness);
|
|
32
33
|
registerSqliteDiagnosticSink(log, getHarness);
|
|
33
|
-
setEmbeddingSessionBusy(input.sessionId, input.embeddingHostBusy === true);
|
|
34
34
|
var nextId = 0;
|
|
35
35
|
var pending = new Map;
|
|
36
36
|
var queryDimensions = null;
|
|
@@ -51,65 +51,78 @@ function request(message) {
|
|
|
51
51
|
port?.postMessage({ ...message, id });
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
if (input.snapshot) {
|
|
55
|
-
installProjectEmbeddingSearchBridge(input.snapshot, {
|
|
56
|
-
modelId: input.snapshot.modelId,
|
|
57
|
-
initialize: async () => true,
|
|
58
|
-
isLoaded: () => true,
|
|
59
|
-
dispose: async () => {},
|
|
60
|
-
embed: async (text) => {
|
|
61
|
-
const result = (await request({ kind: "query", text })).result;
|
|
62
|
-
return result instanceof Float32Array ? result : result?.vector ?? null;
|
|
63
|
-
},
|
|
64
|
-
embedBatch: async (texts, _signal, purpose = "passage") => {
|
|
65
|
-
const passage = (await request({ kind: "batch", texts, purpose })).passage;
|
|
66
|
-
const captured = input.snapshot;
|
|
67
|
-
if (!passage || !captured || passage.generation !== captured.generation || passage.modelId !== captured.modelId || passage.providerIdentity !== captured.providerIdentity || passage.runtimeFingerprint !== captured.runtimeFingerprint || !queryDimensions || passage.dimensions !== queryDimensions || passage.vectors.length !== texts.length)
|
|
68
|
-
return texts.map(() => null);
|
|
69
|
-
return passage.vectors.map((vector) => vector && vector.length === queryDimensions && vector.every(Number.isFinite) ? vector : null);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
54
|
db = new Database(input.path, input.job === "backfill" ? undefined : { readonly: true });
|
|
74
55
|
db.exec("PRAGMA busy_timeout = 250");
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
56
|
+
async function run(jobInput) {
|
|
57
|
+
input = jobInput;
|
|
58
|
+
queryDimensions = null;
|
|
59
|
+
setEmbeddingSessionBusy(input.sessionId, input.embeddingHostBusy === true);
|
|
60
|
+
if (input.snapshot) {
|
|
61
|
+
installProjectEmbeddingSearchBridge(input.snapshot, {
|
|
62
|
+
modelId: input.snapshot.modelId,
|
|
63
|
+
initialize: async () => true,
|
|
64
|
+
isLoaded: () => true,
|
|
65
|
+
dispose: async () => {},
|
|
66
|
+
embed: async (text) => {
|
|
67
|
+
const result = (await request({ kind: "query", text })).result;
|
|
68
|
+
return result instanceof Float32Array ? result : result?.vector ?? null;
|
|
69
|
+
},
|
|
70
|
+
embedBatch: async (texts, _signal, purpose = "passage") => {
|
|
71
|
+
const passage = (await request({ kind: "batch", texts, purpose })).passage;
|
|
72
|
+
const captured = input.snapshot;
|
|
73
|
+
if (!passage || !captured || passage.generation !== captured.generation || passage.modelId !== captured.modelId || passage.providerIdentity !== captured.providerIdentity || passage.runtimeFingerprint !== captured.runtimeFingerprint || !queryDimensions || passage.dimensions !== queryDimensions || passage.vectors.length !== texts.length)
|
|
74
|
+
return texts.map(() => null);
|
|
75
|
+
return passage.vectors.map((vector) => vector && vector.length === queryDimensions && vector.every(Number.isFinite) ? vector : null);
|
|
88
76
|
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
if (input.job === "backfill") {
|
|
81
|
+
if (input.snapshot?.enabled && input.snapshot.features.memoryEnabled) {
|
|
82
|
+
await request({ kind: "query", text: input.query });
|
|
83
|
+
if (queryDimensions) {
|
|
84
|
+
const existingEmbeddings = getProjectEmbeddings(db, input.projectPath, input.snapshot.modelId);
|
|
85
|
+
const memories = getMemoriesByProject(db, input.projectPath).filter((memory) => !existingEmbeddings.has(memory.id)).slice(0, 50);
|
|
86
|
+
await ensureMemoryEmbeddings({
|
|
87
|
+
db,
|
|
88
|
+
projectIdentity: input.projectPath,
|
|
89
|
+
memories,
|
|
90
|
+
existingEmbeddings
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
port.postMessage({ kind: "result", results: [] });
|
|
95
|
+
} else if (input.job === "messages") {
|
|
96
|
+
if (!input.messageRequest)
|
|
97
|
+
throw new Error("message search job carries no request");
|
|
98
|
+
const outcome = searchMessageHistory(db, input.messageRequest);
|
|
99
|
+
port.postMessage({ kind: "messages", outcome });
|
|
100
|
+
} else {
|
|
101
|
+
const results = await unifiedSearch(db, input.sessionId, input.projectPath, input.query, {
|
|
102
|
+
...input.options,
|
|
103
|
+
backfillMemoryEmbeddings: false,
|
|
104
|
+
countRetrievals: false,
|
|
105
|
+
measurementDisabled: true,
|
|
106
|
+
embedQuery: async (text) => (await request({ kind: "query", text })).result ?? null,
|
|
107
|
+
isEmbeddingRuntimeEnabled: () => input.embeddingRuntimeEnabled
|
|
108
|
+
});
|
|
109
|
+
port.postMessage({ kind: "result", results });
|
|
89
110
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const outcome = searchMessageHistory(db, input.messageRequest);
|
|
95
|
-
port.postMessage({ kind: "messages", outcome });
|
|
96
|
-
} else {
|
|
97
|
-
const results = await unifiedSearch(db, input.sessionId, input.projectPath, input.query, {
|
|
98
|
-
...input.options,
|
|
99
|
-
backfillMemoryEmbeddings: false,
|
|
100
|
-
countRetrievals: false,
|
|
101
|
-
measurementDisabled: true,
|
|
102
|
-
embedQuery: async (text) => (await request({ kind: "query", text })).result ?? null,
|
|
103
|
-
isEmbeddingRuntimeEnabled: () => input.embeddingRuntimeEnabled
|
|
111
|
+
} catch (error) {
|
|
112
|
+
port.postMessage({
|
|
113
|
+
kind: "error",
|
|
114
|
+
error: error instanceof Error ? error.message : String(error)
|
|
104
115
|
});
|
|
105
|
-
|
|
116
|
+
} finally {
|
|
117
|
+
setEmbeddingSessionBusy(input.sessionId, false);
|
|
118
|
+
if (!persistent) {
|
|
119
|
+
db.close();
|
|
120
|
+
port?.close();
|
|
121
|
+
}
|
|
106
122
|
}
|
|
107
|
-
} catch (error) {
|
|
108
|
-
port.postMessage({
|
|
109
|
-
kind: "error",
|
|
110
|
-
error: error instanceof Error ? error.message : String(error)
|
|
111
|
-
});
|
|
112
|
-
} finally {
|
|
113
|
-
db.close();
|
|
114
|
-
port.close();
|
|
115
123
|
}
|
|
124
|
+
port.on("message", (message) => {
|
|
125
|
+
if (message.kind === "run" && message.input)
|
|
126
|
+
run(message.input);
|
|
127
|
+
});
|
|
128
|
+
await run(input);
|
|
@@ -3,33 +3,35 @@ import {
|
|
|
3
3
|
} from "./index-0h2mkab2.js";
|
|
4
4
|
import {
|
|
5
5
|
Database2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-rrwv9y2k.js";
|
|
7
7
|
import {
|
|
8
8
|
configureContextDatabasePragmas2
|
|
9
9
|
} from "./index-fapenpch.js";
|
|
10
|
-
import"./index-
|
|
10
|
+
import"./index-1kcfwk9c.js";
|
|
11
11
|
import"./index-7bqrfyny.js";
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
12
|
+
import"./index-d8gc0112.js";
|
|
13
|
+
import"./index-399p688g.js";
|
|
14
|
+
import"./index-vktahpdj.js";
|
|
15
|
+
import"./index-yygsh681.js";
|
|
14
16
|
import {
|
|
15
17
|
replaceCompartmentChunkEmbeddings,
|
|
16
18
|
recordChunkEmbedBackoff,
|
|
17
19
|
loadUnembeddedSessionChunkCandidates,
|
|
18
20
|
countUnembeddedSessionCompartments
|
|
19
|
-
} from "./index-
|
|
21
|
+
} from "./index-xnch62s6.js";
|
|
20
22
|
import {
|
|
21
23
|
recordSessionProjectIdentity,
|
|
22
24
|
acquireGitSweepLease,
|
|
23
25
|
renewGitSweepLease,
|
|
24
26
|
releaseGitSweepLease
|
|
25
|
-
} from "./index-
|
|
26
|
-
import"./index-
|
|
27
|
+
} from "./index-svgkv4g2.js";
|
|
28
|
+
import"./index-g7p75667.js";
|
|
27
29
|
import"./index-apgwdby5.js";
|
|
28
30
|
import {
|
|
29
31
|
LATEST_SUPPORTED_VERSION,
|
|
30
32
|
enforceSchemaFence
|
|
31
|
-
} from "./index-
|
|
32
|
-
import"./index-
|
|
33
|
+
} from "./index-469ttgzv.js";
|
|
34
|
+
import"./index-gdjv1nnd.js";
|
|
33
35
|
import"./index-jrap43gc.js";
|
|
34
36
|
import"./index-135e8hvg.js";
|
|
35
37
|
import"./index-8976mezv.js";
|
package/dist/{compaction-marker-candidates-k4tqg4jb.js → compaction-marker-candidates-wjzqbspm.js}
RENAMED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
readMarkerCandidateBasis2,
|
|
5
5
|
prepareMarkerCandidateBasis2,
|
|
6
6
|
scanMarkerCandidateSnapshot2
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-qpq6w67c.js";
|
|
8
8
|
import"./index-399p688g.js";
|
|
9
|
-
import"./index-
|
|
9
|
+
import"./index-rrwv9y2k.js";
|
|
10
10
|
import"./index-7bqrfyny.js";
|
|
11
11
|
import"./index-0h2mkab2.js";
|
|
12
12
|
export {
|
|
@@ -5,8 +5,8 @@ if (!port)
|
|
|
5
5
|
throw new Error("marker candidate worker requires a parent port");
|
|
6
6
|
port.postMessage({ kind: "accepted" });
|
|
7
7
|
var [{ Database }, { scanMarkerCandidateSnapshot }] = await Promise.all([
|
|
8
|
-
import("./sqlite-
|
|
9
|
-
import("./compaction-marker-candidates-
|
|
8
|
+
import("./sqlite-fsp0sf3r.js"),
|
|
9
|
+
import("./compaction-marker-candidates-wjzqbspm.js")
|
|
10
10
|
]);
|
|
11
11
|
var input = workerData;
|
|
12
12
|
var db;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ensureMemoryEmbeddings2
|
|
3
|
+
} from "./index-z2rkv0mb.js";
|
|
4
|
+
import"./index-vmcgew7x.js";
|
|
5
|
+
import"./index-9p40dgkm.js";
|
|
6
|
+
import"./index-yhzhdp3m.js";
|
|
7
|
+
import"./index-svgkv4g2.js";
|
|
8
|
+
import"./index-xnch62s6.js";
|
|
9
|
+
import"./index-2mmy81qt.js";
|
|
10
|
+
import"./index-d8gc0112.js";
|
|
11
|
+
import"./index-bxmf4dhr.js";
|
|
12
|
+
import"./index-g7p75667.js";
|
|
13
|
+
import"./index-yygsh681.js";
|
|
14
|
+
import"./index-vktahpdj.js";
|
|
15
|
+
import"./index-399p688g.js";
|
|
16
|
+
import"./index-d4dt19md.js";
|
|
17
|
+
import"./index-1kcfwk9c.js";
|
|
18
|
+
import"./index-rrwv9y2k.js";
|
|
19
|
+
import"./index-7bqrfyny.js";
|
|
20
|
+
import"./index-0h2mkab2.js";
|
|
21
|
+
export {
|
|
22
|
+
ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
|
|
23
|
+
};
|
package/dist/embedding-worker.js
CHANGED
|
@@ -4,15 +4,15 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
log2
|
|
6
6
|
} from "./index-7bqrfyny.js";
|
|
7
|
-
import"./index-
|
|
8
|
-
import"./index-
|
|
9
|
-
import"./index-
|
|
10
|
-
import"./index-
|
|
7
|
+
import"./index-bxmf4dhr.js";
|
|
8
|
+
import"./index-d8gc0112.js";
|
|
9
|
+
import"./index-1kcfwk9c.js";
|
|
10
|
+
import"./index-rrwv9y2k.js";
|
|
11
11
|
import {
|
|
12
12
|
resolveLocalEmbeddingWorkerRuntime,
|
|
13
13
|
getLocalEmbeddingNativeMemoryStats,
|
|
14
14
|
LocalEmbeddingProvider
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-2mmy81qt.js";
|
|
16
16
|
import {
|
|
17
17
|
setStoragePrivatePermissionEnforcement
|
|
18
18
|
} from "./index-81nthk8j.js";
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HISTORIAN_TEMPERATURE_ENV2,
|
|
3
|
+
HISTORIAN_CACHE_TAIL_ENV2,
|
|
3
4
|
HISTORIAN_MAX_OUTPUT_TOKENS_ENV2,
|
|
4
5
|
SUBAGENT_OUTPUT_CEILING_ENV2,
|
|
5
6
|
calibrateHistorianProviderPayload2,
|
|
6
7
|
ceilProviderOutputTokens2,
|
|
7
8
|
withoutProviderTemperature2,
|
|
8
9
|
historianCalibrationExtension
|
|
9
|
-
} from "./index-
|
|
10
|
+
} from "./index-fa485mqs.js";
|
|
11
|
+
import"./index-4knyh1kt.js";
|
|
10
12
|
import"./index-6x556c2q.js";
|
|
11
13
|
import"./index-7bqrfyny.js";
|
|
12
14
|
import"./index-0h2mkab2.js";
|
|
13
15
|
export {
|
|
16
|
+
HISTORIAN_CACHE_TAIL_ENV2 as HISTORIAN_CACHE_TAIL_ENV,
|
|
14
17
|
HISTORIAN_MAX_OUTPUT_TOKENS_ENV2 as HISTORIAN_MAX_OUTPUT_TOKENS_ENV,
|
|
15
18
|
HISTORIAN_TEMPERATURE_ENV2 as HISTORIAN_TEMPERATURE_ENV,
|
|
16
19
|
SUBAGENT_OUTPUT_CEILING_ENV2 as SUBAGENT_OUTPUT_CEILING_ENV,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// ../plugin/src/features/magic-context/message-fts-session-filter.ts
|
|
2
|
+
var MESSAGE_FTS_SESSION_FILTER_SQL = `+message_history_fts.rowid IN (
|
|
3
|
+
SELECT fts_rowid FROM message_fts_rowid_map WHERE session_id = ?1
|
|
4
|
+
) AND `;
|
|
5
|
+
var coverageCaches = new WeakMap;
|
|
6
|
+
var coverageScansOnThisThread = 0;
|
|
7
|
+
function getCoverageCache(db) {
|
|
8
|
+
let cache = coverageCaches.get(db);
|
|
9
|
+
if (!cache) {
|
|
10
|
+
cache = {
|
|
11
|
+
pin: db.prepare("SELECT fts_rowid FROM message_fts_rowid_map LIMIT 1"),
|
|
12
|
+
stamp: db.prepare("SELECT total_changes() AS changes, data_version AS version FROM pragma_data_version"),
|
|
13
|
+
missing: db.prepare(`SELECT DISTINCT session_id AS sessionId
|
|
14
|
+
FROM message_history_fts WHERE rowid IN (
|
|
15
|
+
SELECT id FROM message_history_fts_docsize
|
|
16
|
+
EXCEPT SELECT fts_rowid FROM message_fts_rowid_map
|
|
17
|
+
)`)
|
|
18
|
+
};
|
|
19
|
+
coverageCaches.set(db, cache);
|
|
20
|
+
}
|
|
21
|
+
return cache;
|
|
22
|
+
}
|
|
23
|
+
function withMessageFtsSessionFilter(db, sessionId, read) {
|
|
24
|
+
let cacheable = false;
|
|
25
|
+
try {
|
|
26
|
+
const transaction = db;
|
|
27
|
+
cacheable = transaction.inTransaction === false || transaction.isTransaction === false;
|
|
28
|
+
if (!cacheable)
|
|
29
|
+
coverageCaches.delete(db);
|
|
30
|
+
} catch {
|
|
31
|
+
coverageCaches.delete(db);
|
|
32
|
+
}
|
|
33
|
+
return db.transaction(() => {
|
|
34
|
+
let sessionFirst = false;
|
|
35
|
+
try {
|
|
36
|
+
const cache = getCoverageCache(db);
|
|
37
|
+
cache.pin.get();
|
|
38
|
+
const stamp = cache.stamp.get();
|
|
39
|
+
let incomplete = cache.incompleteSessions;
|
|
40
|
+
if (!cacheable || !incomplete || cache.version !== stamp.version || cache.changes !== stamp.changes) {
|
|
41
|
+
coverageScansOnThisThread += 1;
|
|
42
|
+
const rows = cache.missing.all();
|
|
43
|
+
incomplete = new Set(rows.map((row) => row.sessionId));
|
|
44
|
+
if (cacheable) {
|
|
45
|
+
cache.version = stamp.version;
|
|
46
|
+
cache.changes = stamp.changes;
|
|
47
|
+
cache.incompleteSessions = incomplete;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
sessionFirst = !incomplete.has(sessionId);
|
|
51
|
+
} catch {
|
|
52
|
+
coverageCaches.delete(db);
|
|
53
|
+
}
|
|
54
|
+
return read(sessionFirst);
|
|
55
|
+
}).deferred();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { MESSAGE_FTS_SESSION_FILTER_SQL, withMessageFtsSessionFilter };
|
|
@@ -29,7 +29,27 @@ function isSystemDirective(text) {
|
|
|
29
29
|
return text.trimStart().startsWith(SYSTEM_DIRECTIVE_PREFIX);
|
|
30
30
|
}
|
|
31
31
|
function removeSystemReminders(text) {
|
|
32
|
-
return text
|
|
32
|
+
return removeNestedBlocks(text, ["system-reminder"]).trim();
|
|
33
|
+
}
|
|
34
|
+
function removeNestedBlocks(text, names) {
|
|
35
|
+
const tags = new RegExp(`<(/?)(${names.join("|")})(?:\\s[^<>]*?)?\\s*(/?)>`, "gi");
|
|
36
|
+
const stack = [];
|
|
37
|
+
let end = 0;
|
|
38
|
+
let result = "";
|
|
39
|
+
for (const match of text.matchAll(tags)) {
|
|
40
|
+
if (stack.length === 0)
|
|
41
|
+
result += text.slice(end, match.index);
|
|
42
|
+
const name = match[2].toLowerCase();
|
|
43
|
+
if (match[1]) {
|
|
44
|
+
if (stack[stack.length - 1] === name)
|
|
45
|
+
stack.pop();
|
|
46
|
+
} else if (!match[3])
|
|
47
|
+
stack.push(name);
|
|
48
|
+
end = match.index + match[0].length;
|
|
49
|
+
}
|
|
50
|
+
if (stack.length === 0)
|
|
51
|
+
result += text.slice(end);
|
|
52
|
+
return result;
|
|
33
53
|
}
|
|
34
54
|
|
|
35
55
|
// ../plugin/src/hooks/magic-context/token-count-exact.ts
|
|
@@ -688,4 +708,4 @@ function mergeCommitHashes(existing, next) {
|
|
|
688
708
|
return merged;
|
|
689
709
|
}
|
|
690
710
|
|
|
691
|
-
export { textMentionsRecentCommit, OMO_INTERNAL_INITIATOR_MARKER, isSystemDirective, removeSystemReminders, hasMeaningfulUserText2, extractTexts2, extractToolResultBodyTokens, extractToolCallSummaries, preloadTokenizer, getTokenEstimatorFingerprint, hasTokenizerForFit, tokenCountUsesByteBound, estimateTokens, createTokenCountMemo, estimateFixedPromptTokens, normalizeText, compactRole, formatBlock, compactTextForSummary, mergeCommitHashes };
|
|
711
|
+
export { textMentionsRecentCommit, OMO_INTERNAL_INITIATOR_MARKER, isSystemDirective, removeSystemReminders, removeNestedBlocks, hasMeaningfulUserText2, extractTexts2, extractToolResultBodyTokens, extractToolCallSummaries, preloadTokenizer, getTokenEstimatorFingerprint, hasTokenizerForFit, tokenCountUsesByteBound, estimateTokens, createTokenCountMemo, estimateFixedPromptTokens, normalizeText, compactRole, formatBlock, compactTextForSummary, mergeCommitHashes };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_LOCAL_EMBEDDING_MODEL
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-bxmf4dhr.js";
|
|
4
4
|
import {
|
|
5
5
|
getSynapseLaneIdentity
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-d8gc0112.js";
|
|
7
7
|
import {
|
|
8
8
|
getHarness2
|
|
9
9
|
} from "./index-0h2mkab2.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./index-7bqrfyny.js";
|
|
15
15
|
import {
|
|
16
16
|
inRootAsyncContext2
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-rrwv9y2k.js";
|
|
18
18
|
import {
|
|
19
19
|
computeNormalizedHash
|
|
20
20
|
} from "./index-9x1f96r8.js";
|
|
@@ -16,11 +16,10 @@ import {
|
|
|
16
16
|
withoutSqliteTransformPass2,
|
|
17
17
|
isTransientSqliteError2,
|
|
18
18
|
withPrivilegedWriter2
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-rrwv9y2k.js";
|
|
20
20
|
import {
|
|
21
|
-
bootQuietRemainingMs,
|
|
22
21
|
scheduleAfterBootQuiet
|
|
23
|
-
} from "./index-
|
|
22
|
+
} from "./index-g7p75667.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-yygsh681.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-gdjv1nnd.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-2ky7mbqp.js"));
|
|
1309
|
+
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-ssshbdy8.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 };
|