@cortexkit/pi-magic-context 0.49.12 → 0.49.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-search-worker.js +3 -3
- package/dist/chunk-embedding-write-worker.js +87 -0
- package/dist/{embedding-backfill-14tqcfrn.js → embedding-backfill-7kj16fh9.js} +5 -4
- package/dist/embedding-worker.js +1 -1
- package/dist/historian-calibration-extension.js +1 -1
- package/dist/{index-gykw2zhn.js → index-0awvkeb5.js} +5 -5
- package/dist/index-1mrvw9en.js +225 -0
- package/dist/index-1vw4f2pe.js +907 -0
- package/dist/{index-zapgkmp7.js → index-65kty5te.js} +37 -48
- package/dist/{index-53xdqb3d.js → index-75ah9413.js} +1 -1
- package/dist/{index-af9nb5db.js → index-7qc73yk5.js} +60 -3
- package/dist/{index-xpsht877.js → index-7wagp5jp.js} +2 -2
- package/dist/{index-6hex51s9.js → index-a4pk5yv9.js} +2 -2
- package/dist/{index-z5ftst3e.js → index-ccsscaap.js} +3 -3
- package/dist/{index-ed9d2ded.js → index-j0n09wtp.js} +4 -1
- package/dist/{index-f6e8jsrh.js → index-nwbhe6qv.js} +188 -241
- package/dist/{index-xmdkde4v.js → index-y29y2j2w.js} +12 -1
- package/dist/index.js +2398 -2068
- package/dist/{message-index-bounded-ws37m1nt.js → message-index-bounded-z4d3x9ty.js} +4 -4
- package/dist/{message-index-dfs6k35a.js → message-index-dw4z9efj.js} +4 -4
- package/dist/migration-worker.js +2 -2
- package/dist/{project-embedding-registry-ymvne11v.js → project-embedding-registry-52zwmtbn.js} +4 -3
- package/dist/raw-ordinal-warmup-worker.js +3 -3
- package/dist/{read-session-chunk-83864b37.js → read-session-chunk-0fsgg2k1.js} +2 -2
- package/dist/{search-85e21wb8.js → search-ddbz6v60.js} +12 -11
- package/dist/{storage-tags-zmf30zqp.js → storage-tags-3kb5tvgg.js} +3 -1
- package/dist/subagent-entry.js +12 -11
- package/dist/tag-snapshot-worker-pi.js +235 -0
- package/package.json +3 -3
- /package/dist/{index-j24916mq.js → index-9jvktm7k.js} +0 -0
- /package/dist/{index-69vas84q.js → index-b7p25tm0.js} +0 -0
- /package/dist/{index-3cnarwf8.js → index-bet4sd3e.js} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
withIndexChunk2,
|
|
4
4
|
yieldIndexChunk2
|
|
5
5
|
} from "./index-asrxgdt4.js";
|
|
6
|
-
import"./index-
|
|
6
|
+
import"./index-j0n09wtp.js";
|
|
7
7
|
import"./index-g4jf772p.js";
|
|
8
8
|
import"./index-0h2mkab2.js";
|
|
9
9
|
import"./index-7bqrfyny.js";
|
|
@@ -12,7 +12,7 @@ import"./index-1k729e4f.js";
|
|
|
12
12
|
import"./index-399p688g.js";
|
|
13
13
|
import"./index-he9s4qsj.js";
|
|
14
14
|
import"./index-8976mezv.js";
|
|
15
|
-
import"./index-
|
|
15
|
+
import"./index-75ah9413.js";
|
|
16
16
|
import"./index-6x556c2q.js";
|
|
17
17
|
import {
|
|
18
18
|
MESSAGE_INDEX_MAX_FTS_BYTES2,
|
|
@@ -21,11 +21,11 @@ import {
|
|
|
21
21
|
markMessageIndexDirty2,
|
|
22
22
|
getIndexableContent2,
|
|
23
23
|
indexSingleMessage2
|
|
24
|
-
} from "./index-
|
|
24
|
+
} from "./index-a4pk5yv9.js";
|
|
25
25
|
import"./index-djxc8w8c.js";
|
|
26
26
|
import"./index-apgwdby5.js";
|
|
27
27
|
import"./index-6dz2ed1v.js";
|
|
28
|
-
import"./index-
|
|
28
|
+
import"./index-7qc73yk5.js";
|
|
29
29
|
import"./index-d4dt19md.js";
|
|
30
30
|
|
|
31
31
|
// ../plugin/src/features/magic-context/message-index-bounded.ts
|
|
@@ -17,12 +17,12 @@ import {
|
|
|
17
17
|
indexMessagesAfterOrdinal2,
|
|
18
18
|
indexSourcesAfterOrdinal2,
|
|
19
19
|
sweepOrphanedOpenCodeMessageIndexes2
|
|
20
|
-
} from "./index-
|
|
21
|
-
import"./index-
|
|
22
|
-
import"./index-
|
|
23
|
-
import"./index-ed9d2ded.js";
|
|
20
|
+
} from "./index-a4pk5yv9.js";
|
|
21
|
+
import"./index-7qc73yk5.js";
|
|
22
|
+
import"./index-75ah9413.js";
|
|
24
23
|
import"./index-he9s4qsj.js";
|
|
25
24
|
import"./index-399p688g.js";
|
|
25
|
+
import"./index-j0n09wtp.js";
|
|
26
26
|
import"./index-6x556c2q.js";
|
|
27
27
|
import"./index-6dz2ed1v.js";
|
|
28
28
|
import"./index-1k729e4f.js";
|
package/dist/migration-worker.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import"./index-135e8hvg.js";
|
|
10
10
|
import {
|
|
11
11
|
runMigrationsWithRetry
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-bet4sd3e.js";
|
|
13
13
|
import {
|
|
14
14
|
closeQuietly
|
|
15
15
|
} from "./index-jrap43gc.js";
|
|
@@ -20,7 +20,7 @@ import"./index-fapenpch.js";
|
|
|
20
20
|
import {
|
|
21
21
|
setSqlitePragmaConfig,
|
|
22
22
|
initializeDatabase
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-ccsscaap.js";
|
|
24
24
|
import"./index-djxc8w8c.js";
|
|
25
25
|
import"./index-g4jf772p.js";
|
|
26
26
|
import"./index-d4dt19md.js";
|
package/dist/{project-embedding-registry-ymvne11v.js → project-embedding-registry-52zwmtbn.js}
RENAMED
|
@@ -33,11 +33,12 @@ import {
|
|
|
33
33
|
sweepAllRegisteredProjects2,
|
|
34
34
|
_setTestProviderFactoryForProject2,
|
|
35
35
|
_resetProjectEmbeddingRegistryForTests2
|
|
36
|
-
} from "./index-
|
|
36
|
+
} from "./index-nwbhe6qv.js";
|
|
37
37
|
import"./index-9p40dgkm.js";
|
|
38
|
-
import"./index-af9nb5db.js";
|
|
39
38
|
import"./index-yhzhdp3m.js";
|
|
40
|
-
import"./index-
|
|
39
|
+
import"./index-1mrvw9en.js";
|
|
40
|
+
import"./index-7qc73yk5.js";
|
|
41
|
+
import"./index-9jvktm7k.js";
|
|
41
42
|
import"./index-6dz2ed1v.js";
|
|
42
43
|
import"./index-1k729e4f.js";
|
|
43
44
|
import"./index-6ex901g3.js";
|
|
@@ -35,7 +35,7 @@ try {
|
|
|
35
35
|
{ configureContextDatabasePragmas }
|
|
36
36
|
] = await Promise.all([
|
|
37
37
|
import("./harness-9872e0ym.js"),
|
|
38
|
-
import("./message-index-
|
|
38
|
+
import("./message-index-dw4z9efj.js"),
|
|
39
39
|
import("./sqlite-context-pragmas-gcgch6qz.js")
|
|
40
40
|
]);
|
|
41
41
|
setHarness(input.harness ?? "opencode");
|
|
@@ -49,7 +49,7 @@ try {
|
|
|
49
49
|
const { setHarness } = await import("./harness-9872e0ym.js");
|
|
50
50
|
setHarness(input.harness ?? "opencode");
|
|
51
51
|
const [{ indexMessageInShortChunks }, { configureContextDatabasePragmas }] = await Promise.all([
|
|
52
|
-
import("./message-index-bounded-
|
|
52
|
+
import("./message-index-bounded-z4d3x9ty.js"),
|
|
53
53
|
import("./sqlite-context-pragmas-gcgch6qz.js")
|
|
54
54
|
]);
|
|
55
55
|
configureContextDatabasePragmas(db);
|
|
@@ -59,7 +59,7 @@ try {
|
|
|
59
59
|
const result = await indexMessageInShortChunks(writer, input.sessionId, message, input, () => !cancellation || Atomics.load(cancellation, 0) === 0);
|
|
60
60
|
reply = { kind: "indexed", inserted: result.inserted, measurements: result.measurements };
|
|
61
61
|
} else if (input.tagRatio !== undefined) {
|
|
62
|
-
const { scanTagOwnerSummary, scanTagOwnerDelta } = await import("./storage-tags-
|
|
62
|
+
const { scanTagOwnerSummary, scanTagOwnerDelta } = await import("./storage-tags-3kb5tvgg.js");
|
|
63
63
|
const delta = input.tagState ? scanTagOwnerDelta(db, input.sessionId, input.tagState) : null;
|
|
64
64
|
if (delta)
|
|
65
65
|
reply = { kind: "tag-delta", delta };
|
|
@@ -35,10 +35,10 @@ import {
|
|
|
35
35
|
readSessionChunk2,
|
|
36
36
|
getRawSessionMessageIdsThrough2,
|
|
37
37
|
readRawSessionSeedTail2
|
|
38
|
-
} from "./index-
|
|
39
|
-
import"./index-ed9d2ded.js";
|
|
38
|
+
} from "./index-75ah9413.js";
|
|
40
39
|
import"./index-he9s4qsj.js";
|
|
41
40
|
import"./index-399p688g.js";
|
|
41
|
+
import"./index-j0n09wtp.js";
|
|
42
42
|
import"./index-6x556c2q.js";
|
|
43
43
|
import"./index-1k729e4f.js";
|
|
44
44
|
import"./index-8976mezv.js";
|
|
@@ -5,27 +5,28 @@ import {
|
|
|
5
5
|
resolveMemoriesByIdsForSearch2,
|
|
6
6
|
unifiedSearch2,
|
|
7
7
|
formatSearchResults2
|
|
8
|
-
} from "./index-
|
|
9
|
-
import"./index-
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
12
|
-
import"./index-f6e8jsrh.js";
|
|
8
|
+
} from "./index-0awvkeb5.js";
|
|
9
|
+
import"./index-a4pk5yv9.js";
|
|
10
|
+
import"./index-7wagp5jp.js";
|
|
11
|
+
import"./index-nwbhe6qv.js";
|
|
13
12
|
import"./index-9p40dgkm.js";
|
|
14
|
-
import"./index-
|
|
13
|
+
import"./index-hy44m6jc.js";
|
|
15
14
|
import"./index-yhzhdp3m.js";
|
|
16
|
-
import"./index-
|
|
17
|
-
import"./index-
|
|
15
|
+
import"./index-1mrvw9en.js";
|
|
16
|
+
import"./index-7qc73yk5.js";
|
|
17
|
+
import"./index-75ah9413.js";
|
|
18
18
|
import"./index-he9s4qsj.js";
|
|
19
19
|
import"./index-399p688g.js";
|
|
20
|
+
import"./index-j0n09wtp.js";
|
|
20
21
|
import"./index-6x556c2q.js";
|
|
21
|
-
import"./index-
|
|
22
|
+
import"./index-9jvktm7k.js";
|
|
22
23
|
import"./index-6dz2ed1v.js";
|
|
23
24
|
import"./index-1k729e4f.js";
|
|
24
|
-
import"./index-
|
|
25
|
+
import"./index-bet4sd3e.js";
|
|
25
26
|
import"./index-apgwdby5.js";
|
|
26
|
-
import"./index-135e8hvg.js";
|
|
27
27
|
import"./index-6ex901g3.js";
|
|
28
28
|
import"./index-djxc8w8c.js";
|
|
29
|
+
import"./index-135e8hvg.js";
|
|
29
30
|
import"./index-8976mezv.js";
|
|
30
31
|
import"./index-jrap43gc.js";
|
|
31
32
|
import"./index-d4dt19md.js";
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
updateTagInputTokenCount2,
|
|
20
20
|
tagTokenCountIsNull2,
|
|
21
21
|
backfillTagTokenCounts2,
|
|
22
|
+
normalizeTagSnapshotRow2,
|
|
22
23
|
insertTag2,
|
|
23
24
|
updateTagStatus2,
|
|
24
25
|
markTagDropped2,
|
|
@@ -59,7 +60,7 @@ import {
|
|
|
59
60
|
adoptNullOwnerToolTag2,
|
|
60
61
|
getCandidateToolOwners2,
|
|
61
62
|
pickNearestPriorOwner2
|
|
62
|
-
} from "./index-
|
|
63
|
+
} from "./index-j0n09wtp.js";
|
|
63
64
|
import"./index-jrap43gc.js";
|
|
64
65
|
import"./index-g4jf772p.js";
|
|
65
66
|
import"./index-asrxgdt4.js";
|
|
@@ -113,6 +114,7 @@ export {
|
|
|
113
114
|
insertTag2 as insertTag,
|
|
114
115
|
markTagDropped2 as markTagDropped,
|
|
115
116
|
markTagsCompactedByMessageIds2 as markTagsCompactedByMessageIds,
|
|
117
|
+
normalizeTagSnapshotRow2 as normalizeTagSnapshotRow,
|
|
116
118
|
pickNearestPriorOwner2 as pickNearestPriorOwner,
|
|
117
119
|
scanTagOwnerDelta2 as scanTagOwnerDelta,
|
|
118
120
|
scanTagOwnerSummary2 as scanTagOwnerSummary,
|
package/dist/subagent-entry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TOKEN_BUDGET_TOOL_REFUSAL
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-75ah9413.js";
|
|
4
4
|
import {
|
|
5
5
|
setHarness2
|
|
6
6
|
} from "./index-0h2mkab2.js";
|
|
@@ -15,9 +15,9 @@ import"./index-apgwdby5.js";
|
|
|
15
15
|
import"./index-fapenpch.js";
|
|
16
16
|
import {
|
|
17
17
|
openDatabase
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-ccsscaap.js";
|
|
19
19
|
import"./index-djxc8w8c.js";
|
|
20
|
-
import"./index-
|
|
20
|
+
import"./index-bet4sd3e.js";
|
|
21
21
|
import"./index-jrap43gc.js";
|
|
22
22
|
import"./index-135e8hvg.js";
|
|
23
23
|
import"./index-8976mezv.js";
|
|
@@ -27,21 +27,22 @@ import {
|
|
|
27
27
|
ensureProjectRegisteredFromPiDirectory,
|
|
28
28
|
resolvePiHarnessKind,
|
|
29
29
|
registerMagicContextTools
|
|
30
|
-
} from "./index-
|
|
30
|
+
} from "./index-65kty5te.js";
|
|
31
31
|
import"./index-1k729e4f.js";
|
|
32
32
|
import"./index-6dz2ed1v.js";
|
|
33
|
-
import"./index-
|
|
34
|
-
import"./index-
|
|
35
|
-
import"./index-
|
|
33
|
+
import"./index-7qc73yk5.js";
|
|
34
|
+
import"./index-9jvktm7k.js";
|
|
35
|
+
import"./index-nwbhe6qv.js";
|
|
36
36
|
import"./index-9p40dgkm.js";
|
|
37
|
+
import"./index-1mrvw9en.js";
|
|
37
38
|
import"./index-yhzhdp3m.js";
|
|
38
|
-
import"./index-
|
|
39
|
-
import"./index-
|
|
40
|
-
import"./index-
|
|
39
|
+
import"./index-7wagp5jp.js";
|
|
40
|
+
import"./index-a4pk5yv9.js";
|
|
41
|
+
import"./index-j0n09wtp.js";
|
|
41
42
|
import"./index-399p688g.js";
|
|
42
43
|
import"./index-he9s4qsj.js";
|
|
43
44
|
import"./index-6x556c2q.js";
|
|
44
|
-
import"./index-
|
|
45
|
+
import"./index-0awvkeb5.js";
|
|
45
46
|
import"./index-hy44m6jc.js";
|
|
46
47
|
import"./index-46q4e104.js";
|
|
47
48
|
import"./index-d4dt19md.js";
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Database2
|
|
3
|
+
} from "./index-asrxgdt4.js";
|
|
4
|
+
import"./index-6ex901g3.js";
|
|
5
|
+
import"./index-0h2mkab2.js";
|
|
6
|
+
import"./index-7bqrfyny.js";
|
|
7
|
+
import"./index-apgwdby5.js";
|
|
8
|
+
import"./index-fapenpch.js";
|
|
9
|
+
import {
|
|
10
|
+
LATEST_SUPPORTED_VERSION,
|
|
11
|
+
getPersistedSchemaVersion
|
|
12
|
+
} from "./index-ccsscaap.js";
|
|
13
|
+
import"./index-djxc8w8c.js";
|
|
14
|
+
import"./index-bet4sd3e.js";
|
|
15
|
+
import {
|
|
16
|
+
tagRevisionKey
|
|
17
|
+
} from "./index-jrap43gc.js";
|
|
18
|
+
import"./index-135e8hvg.js";
|
|
19
|
+
import"./index-8976mezv.js";
|
|
20
|
+
import"./index-g4jf772p.js";
|
|
21
|
+
import {
|
|
22
|
+
normalizeTagSnapshotRow2,
|
|
23
|
+
TAG_SELECT_COLUMNS2
|
|
24
|
+
} from "./index-j0n09wtp.js";
|
|
25
|
+
import {
|
|
26
|
+
encodePiHydrationOperation,
|
|
27
|
+
PI_FALLBACK_ROW_COLUMNS,
|
|
28
|
+
PI_FALLBACK_ROW_PREDICATE
|
|
29
|
+
} from "./index-1vw4f2pe.js";
|
|
30
|
+
import"./index-d4dt19md.js";
|
|
31
|
+
|
|
32
|
+
// src/tag-snapshot-worker-pi.ts
|
|
33
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
34
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
35
|
+
var port = parentPort;
|
|
36
|
+
if (!port)
|
|
37
|
+
throw new Error("Pi tag hydration requires a worker port");
|
|
38
|
+
var request = workerData;
|
|
39
|
+
var db;
|
|
40
|
+
var sequence = 0;
|
|
41
|
+
var generation = { revision: "0", durable: 0 };
|
|
42
|
+
var maxReadTransactionMs = 0;
|
|
43
|
+
var packetCount = 0;
|
|
44
|
+
var packetBytes = 0;
|
|
45
|
+
var workerDataVersion;
|
|
46
|
+
var dataVersionStatement;
|
|
47
|
+
var generationStatement;
|
|
48
|
+
var opened = false;
|
|
49
|
+
var persistedVersion = 0;
|
|
50
|
+
|
|
51
|
+
class StaleGeneration extends Error {
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class UnsupportedSchema extends Error {
|
|
55
|
+
}
|
|
56
|
+
function dataVersion(_connection) {
|
|
57
|
+
return dataVersionStatement.get().data_version;
|
|
58
|
+
}
|
|
59
|
+
function sample(_connection) {
|
|
60
|
+
return generationStatement.get(tagRevisionKey(request.sessionId), request.sessionId);
|
|
61
|
+
}
|
|
62
|
+
function envelope() {
|
|
63
|
+
return {
|
|
64
|
+
jobId: request.jobId,
|
|
65
|
+
sessionId: request.sessionId,
|
|
66
|
+
connectionEpoch: request.connectionEpoch,
|
|
67
|
+
sessionEpoch: request.sessionEpoch,
|
|
68
|
+
sequence: sequence++,
|
|
69
|
+
generation
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async function send(message) {
|
|
73
|
+
const ack = new Promise((resolve, reject) => {
|
|
74
|
+
port?.once("message", (value) => {
|
|
75
|
+
if (value.type !== "ack" || value.sequence !== message.sequence)
|
|
76
|
+
reject(new Error("invalid packet credit"));
|
|
77
|
+
else if (message.type === "packet" && (!(value.bytes instanceof ArrayBuffer) || value.bytes.byteLength !== 65536))
|
|
78
|
+
reject(new Error("invalid returned packet buffer"));
|
|
79
|
+
else
|
|
80
|
+
resolve(value.bytes);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
if (message.type === "packet")
|
|
84
|
+
port?.postMessage(message, [message.bytes]);
|
|
85
|
+
else
|
|
86
|
+
port?.postMessage(message);
|
|
87
|
+
return await ack;
|
|
88
|
+
}
|
|
89
|
+
function* operations(row) {
|
|
90
|
+
if (Object.values(row).every((value) => !(typeof value === "string" && value.length > 2048) && !(value instanceof Uint8Array && value.length > 2048))) {
|
|
91
|
+
yield { type: "row", value: row };
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
for (const [key, value] of Object.entries(row)) {
|
|
95
|
+
if (typeof value === "string" || value instanceof Uint8Array) {
|
|
96
|
+
if (value.length === 0)
|
|
97
|
+
yield { type: "field", key, value, append: false };
|
|
98
|
+
for (let start = 0;start < value.length; start += 2048)
|
|
99
|
+
yield {
|
|
100
|
+
type: "field",
|
|
101
|
+
key,
|
|
102
|
+
value: value.slice(start, start + 2048),
|
|
103
|
+
append: start !== 0,
|
|
104
|
+
totalLength: value instanceof Uint8Array ? value.length : undefined
|
|
105
|
+
};
|
|
106
|
+
} else
|
|
107
|
+
yield { type: "field", key, value, append: false };
|
|
108
|
+
}
|
|
109
|
+
yield { type: "row-end" };
|
|
110
|
+
}
|
|
111
|
+
async function stream(kind) {
|
|
112
|
+
const connection = db;
|
|
113
|
+
if (!connection)
|
|
114
|
+
throw new Error("closed worker connection");
|
|
115
|
+
let cursor;
|
|
116
|
+
let rowsSent = 0;
|
|
117
|
+
const columns = kind === "tags" ? TAG_SELECT_COLUMNS2 : PI_FALLBACK_ROW_COLUMNS;
|
|
118
|
+
const fallback = kind === "fallback" ? `AND ${PI_FALLBACK_ROW_PREDICATE}` : "";
|
|
119
|
+
const query = `SELECT ${columns} FROM tags WHERE session_id = ? ${fallback}`;
|
|
120
|
+
const firstPage = connection.prepare(`${query} ORDER BY tag_number ASC, id ASC LIMIT 256`);
|
|
121
|
+
const nextPage = connection.prepare(`${query} AND ((? IS NULL AND tag_number IS NOT NULL) OR tag_number > ? OR (tag_number IS ? AND id > ?)) ORDER BY tag_number ASC, id ASC LIMIT 256`);
|
|
122
|
+
let buffer = new Uint8Array(65536);
|
|
123
|
+
for (;; ) {
|
|
124
|
+
if (request.test?.pageDelayMs)
|
|
125
|
+
await delay(request.test.pageDelayMs);
|
|
126
|
+
const started = performance.now();
|
|
127
|
+
let rows;
|
|
128
|
+
connection.exec("BEGIN");
|
|
129
|
+
try {
|
|
130
|
+
const stamp = sample(connection);
|
|
131
|
+
if (workerDataVersion === undefined) {
|
|
132
|
+
workerDataVersion = dataVersion(connection);
|
|
133
|
+
generation = stamp;
|
|
134
|
+
} else if (stamp.revision !== generation.revision || stamp.durable !== generation.durable || dataVersion(connection) !== workerDataVersion)
|
|
135
|
+
throw new StaleGeneration("database changed between pages");
|
|
136
|
+
rows = cursor ? nextPage.all(request.sessionId, cursor.tag_number, cursor.tag_number, cursor.tag_number, cursor.id) : firstPage.all(request.sessionId);
|
|
137
|
+
connection.exec("COMMIT");
|
|
138
|
+
} catch (error) {
|
|
139
|
+
connection.exec("ROLLBACK");
|
|
140
|
+
throw error;
|
|
141
|
+
} finally {
|
|
142
|
+
maxReadTransactionMs = Math.max(maxReadTransactionMs, performance.now() - started);
|
|
143
|
+
}
|
|
144
|
+
let used = 0;
|
|
145
|
+
let packetRows = 0;
|
|
146
|
+
const flush = async () => {
|
|
147
|
+
if (used === 0)
|
|
148
|
+
return;
|
|
149
|
+
const bytes = buffer.buffer;
|
|
150
|
+
packetCount++;
|
|
151
|
+
packetBytes += used;
|
|
152
|
+
const returned = await send({
|
|
153
|
+
...envelope(),
|
|
154
|
+
type: "packet",
|
|
155
|
+
stream: kind,
|
|
156
|
+
bytes,
|
|
157
|
+
byteLength: used,
|
|
158
|
+
rows: packetRows
|
|
159
|
+
});
|
|
160
|
+
buffer = new Uint8Array(returned);
|
|
161
|
+
used = 0;
|
|
162
|
+
packetRows = 0;
|
|
163
|
+
};
|
|
164
|
+
for (const raw of rows) {
|
|
165
|
+
cursor = { tag_number: raw.tag_number, id: raw.id };
|
|
166
|
+
const row = kind === "tags" ? normalizeTagSnapshotRow2(raw) : raw;
|
|
167
|
+
if (!row)
|
|
168
|
+
continue;
|
|
169
|
+
for (const operation of operations(row)) {
|
|
170
|
+
const encoded = encodePiHydrationOperation(operation);
|
|
171
|
+
if (encoded.length + 4 > 65536)
|
|
172
|
+
throw new Error("field fragment exceeds packet limit");
|
|
173
|
+
if (used + encoded.length + 4 > buffer.length || packetRows === 256)
|
|
174
|
+
await flush();
|
|
175
|
+
new DataView(buffer.buffer).setUint32(used, encoded.length);
|
|
176
|
+
used += 4;
|
|
177
|
+
buffer.set(encoded, used);
|
|
178
|
+
used += encoded.length;
|
|
179
|
+
if (operation.type === "row" || operation.type === "row-end") {
|
|
180
|
+
packetRows++;
|
|
181
|
+
rowsSent++;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
await flush();
|
|
186
|
+
if (rows.length < 256)
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
await send({ ...envelope(), type: "end", stream: kind, rows: rowsSent });
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
if (request.test?.openDelayMs)
|
|
193
|
+
await delay(request.test.openDelayMs);
|
|
194
|
+
db = new Database2(request.path, { readonly: true });
|
|
195
|
+
opened = true;
|
|
196
|
+
db.exec("PRAGMA query_only = ON; PRAGMA busy_timeout = 50; PRAGMA cache_size = -1024");
|
|
197
|
+
dataVersionStatement = db.prepare("PRAGMA data_version");
|
|
198
|
+
generationStatement = db.prepare(`SELECT
|
|
199
|
+
COALESCE((SELECT value FROM schema_migrations_meta WHERE key = ?), '0') AS revision,
|
|
200
|
+
COALESCE((SELECT tags_version FROM session_meta WHERE session_id = ?), 0) AS durable`);
|
|
201
|
+
const version = getPersistedSchemaVersion(db);
|
|
202
|
+
persistedVersion = version;
|
|
203
|
+
if (version > LATEST_SUPPORTED_VERSION)
|
|
204
|
+
throw new UnsupportedSchema(`shared database schema v${version} is newer than this build supports (v${LATEST_SUPPORTED_VERSION}); update and restart this host`);
|
|
205
|
+
await stream("tags");
|
|
206
|
+
await stream("fallback");
|
|
207
|
+
if (request.test?.crash === "before-end")
|
|
208
|
+
throw new Error("injected worker crash before completion");
|
|
209
|
+
const final = sample(db);
|
|
210
|
+
if (dataVersion(db) !== workerDataVersion || final.revision !== generation.revision || final.durable !== generation.durable)
|
|
211
|
+
throw new StaleGeneration("database changed after final page");
|
|
212
|
+
db.close();
|
|
213
|
+
db = undefined;
|
|
214
|
+
port.postMessage({
|
|
215
|
+
...envelope(),
|
|
216
|
+
type: "done",
|
|
217
|
+
maxReadTransactionMs,
|
|
218
|
+
packetCount,
|
|
219
|
+
packetBytes
|
|
220
|
+
});
|
|
221
|
+
if (request.test?.crash === "after-end")
|
|
222
|
+
process.exitCode = 1;
|
|
223
|
+
} catch (error) {
|
|
224
|
+
port.postMessage({
|
|
225
|
+
...envelope(),
|
|
226
|
+
type: "failed",
|
|
227
|
+
code: error instanceof StaleGeneration ? "stale" : error instanceof UnsupportedSchema ? "schema" : opened ? "failed" : "open",
|
|
228
|
+
persistedVersion,
|
|
229
|
+
supportedVersion: LATEST_SUPPORTED_VERSION,
|
|
230
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
231
|
+
});
|
|
232
|
+
} finally {
|
|
233
|
+
db?.close();
|
|
234
|
+
port.close();
|
|
235
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/pi-magic-context",
|
|
3
|
-
"version": "0.49.
|
|
3
|
+
"version": "0.49.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"//": "The build intentionally bundles typebox (no --external typebox) and keeps it a regular dependency. OMP's extension loader rewrites every bare `typebox` import to its own omptype-based shim, whose schemas are callable objects rather than JSON Schema; they fail structuredClone during tool registration, so an external typebox import stops Magic Context loading on OMP. src/typebox-bundling.test.ts guards this.",
|
|
31
31
|
"scripts": {
|
|
32
|
-
"build": "bun ../../scripts/check-bun.mjs && tsc -p ../retina-local-fs/tsconfig.build.json && bun ../../scripts/clean-dist-chunks.mjs dist index.js subagent-entry.js historian-calibration-extension.js embedding-worker-process.js raw-ordinal-warmup-worker.js transformers-web.js transformers-node-wasm.js && bun build ../plugin/src/features/magic-context/memory/transformers-web-entry.ts --outfile dist/transformers-web.js --target browser --format esm --external onnxruntime-web && bun ../plugin/scripts/build-transformers-node-wasm.ts dist && bun build src/index.ts src/subagent-entry.ts src/historian-calibration-extension.ts ../plugin/src/features/magic-context/memory/embedding-worker.ts ../plugin/src/features/magic-context/memory/embedding-worker-process.ts ../plugin/src/features/magic-context/migration-worker.ts ../plugin/src/hooks/magic-context/auto-search-worker.ts ../plugin/src/hooks/magic-context/raw-ordinal-warmup-worker.ts ../plugin/src/features/magic-context/compaction-marker-candidates-worker.ts --outdir dist --entry-naming '[name].[ext]' --target node --format esm --splitting --external @earendil-works/pi-coding-agent --external @oh-my-pi/pi-coding-agent --external @earendil-works/pi-tui --external onnxruntime-node --external onnxruntime-web --external sharp --external bun:ffi --external node:sqlite",
|
|
32
|
+
"build": "bun ../../scripts/check-bun.mjs && tsc -p ../retina-local-fs/tsconfig.build.json && bun ../../scripts/clean-dist-chunks.mjs dist index.js subagent-entry.js historian-calibration-extension.js embedding-worker-process.js raw-ordinal-warmup-worker.js tag-snapshot-worker-pi.js transformers-web.js transformers-node-wasm.js && bun build ../plugin/src/features/magic-context/memory/transformers-web-entry.ts --outfile dist/transformers-web.js --target browser --format esm --external onnxruntime-web && bun ../plugin/scripts/build-transformers-node-wasm.ts dist && bun build src/index.ts src/tag-snapshot-worker-pi.ts src/subagent-entry.ts src/historian-calibration-extension.ts ../plugin/src/features/magic-context/memory/embedding-worker.ts ../plugin/src/features/magic-context/memory/embedding-worker-process.ts ../plugin/src/features/magic-context/migration-worker.ts ../plugin/src/hooks/magic-context/auto-search-worker.ts ../plugin/src/hooks/magic-context/raw-ordinal-warmup-worker.ts ../plugin/src/features/magic-context/compaction-marker-candidates-worker.ts ../plugin/src/features/magic-context/chunk-embedding-write-worker.ts --outdir dist --entry-naming '[name].[ext]' --target node --format esm --splitting --external @earendil-works/pi-coding-agent --external @oh-my-pi/pi-coding-agent --external @earendil-works/pi-tui --external onnxruntime-node --external onnxruntime-web --external sharp --external bun:ffi --external node:sqlite",
|
|
33
33
|
"build:e2e-argv": "bun ../../scripts/clean-dist-chunks.mjs ../../tests/docker/.generated subagent-runner-e2e.mjs && bun build src/subagent-runner.ts --outdir ../../tests/docker/.generated --entry-naming 'subagent-runner-e2e.mjs' --splitting --target node --format esm --external node:sqlite && node --input-type=module -e 'const { __test } = await import(\"../../tests/docker/.generated/subagent-runner-e2e.mjs\"); if (typeof __test.buildArgs !== \"function\" || typeof __test.resolvePiInvocation !== \"function\") throw new Error(\"argv renderer exports missing\"); console.log(\"Node argv renderer: 2 exports loaded\")'",
|
|
34
34
|
"typecheck": "tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit",
|
|
35
35
|
"test": "bun ../../scripts/check-bun.mjs && bun install --frozen-lockfile && BUN_JSC_useOMGJIT=0 bun test --parallel=4 --timeout 30000",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"lint:fix": "biome check --write src",
|
|
39
39
|
"format": "biome format --write src",
|
|
40
40
|
"format:check": "biome format src",
|
|
41
|
-
"clean": "bun ../../scripts/clean-dist-chunks.mjs dist index.js subagent-entry.js historian-calibration-extension.js embedding-worker.js embedding-worker-process.js migration-worker.js raw-ordinal-warmup-worker.js transformers-web.js transformers-node-wasm.js",
|
|
41
|
+
"clean": "bun ../../scripts/clean-dist-chunks.mjs dist index.js subagent-entry.js historian-calibration-extension.js embedding-worker.js embedding-worker-process.js migration-worker.js raw-ordinal-warmup-worker.js tag-snapshot-worker-pi.js transformers-web.js transformers-node-wasm.js",
|
|
42
42
|
"prepublishOnly": "bun run build"
|
|
43
43
|
},
|
|
44
44
|
"//test": "Test runs cap file-isolated workers at four (one for test:serial) and disable JSC's optimizing WebAssembly tier so per-file isolation does not pay its compilation cost on every file. These are not production settings and do not change host process engine options.",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|