@cortexkit/opencode-magic-context 0.49.2 → 0.49.4
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/README.md +2 -38
- package/dist/auto-search-worker.js +3 -3
- package/dist/compaction-marker-candidates-dd638ypn.js +19 -0
- package/dist/compaction-marker-candidates-worker.js +24 -0
- package/dist/{conflict-warning-hook-asnt6hfc.js → conflict-warning-hook-ae8nmv7c.js} +5 -4
- package/dist/{context-tfyhtdcs.js → context-yg023c5r.js} +64 -30
- package/dist/{embedding-backfill-wyc3ykyf.js → embedding-backfill-aj488s8x.js} +5 -5
- package/dist/features/magic-context/compaction-marker-candidates-worker.d.ts +2 -0
- package/dist/features/magic-context/compaction-marker-candidates-worker.d.ts.map +1 -0
- package/dist/features/magic-context/compaction-marker-candidates.d.ts +47 -0
- package/dist/features/magic-context/compaction-marker-candidates.d.ts.map +1 -0
- package/dist/features/magic-context/compaction-marker.d.ts +12 -0
- package/dist/features/magic-context/compaction-marker.d.ts.map +1 -1
- package/dist/features/magic-context/historian-failure-reason.d.ts +7 -0
- package/dist/features/magic-context/historian-failure-reason.d.ts.map +1 -0
- package/dist/features/magic-context/memory/project-identity.d.ts +5 -1
- package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
- package/dist/features/magic-context/message-index-async.d.ts +3 -0
- package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/storage-clone.d.ts +2 -0
- package/dist/features/magic-context/storage-clone.d.ts.map +1 -1
- package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +1 -1
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +3 -0
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +3 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/history-boundary-repair.d.ts +11 -2
- package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +4 -3
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +10 -0
- package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/{index-p0n5ryq8.js → index-2mqps3c1.js} +19 -9
- package/dist/{index-sfhndpcb.js → index-3wckxwfp.js} +39 -39
- package/dist/{index-gzky5rva.js → index-41gqa557.js} +4 -2
- package/dist/{index-r2zcs71c.js → index-7ndnvw7a.js} +1 -1
- package/dist/{index-sv0bb7vg.js → index-7zg9dvx0.js} +35 -4
- package/dist/{index-xgrwmj82.js → index-bhk710rw.js} +1 -1
- package/dist/{index-fg00p1cg.js → index-c0b01zrc.js} +2 -2
- package/dist/{index-eypn4ba6.js → index-dd18gej8.js} +3 -3
- package/dist/{index-rafsaxac.js → index-fjtgekd4.js} +2 -2
- package/dist/{index-fdtkt5r1.js → index-fst3t0d9.js} +9 -9
- package/dist/{index-h5zfkjyk.js → index-jpm52v9x.js} +6 -24
- package/dist/{index-s7fc0fkn.js → index-m4p77myp.js} +1 -1
- package/dist/{index-6tfxmc4n.js → index-p2hs3rps.js} +4 -4
- package/dist/{index-0pjvpfkf.js → index-qvr78ej6.js} +1 -1
- package/dist/index-v0p37hm2.js +22 -0
- package/dist/{index-zfzdpeq2.js → index-v4bqjy56.js} +4662 -4545
- package/dist/{index-xnanvj3w.js → index-x3y1np1h.js} +604 -576
- package/dist/{index-att4bfan.js → index-xfbfrngb.js} +1 -1
- package/dist/{index-nydv6g8r.js → index-yqps2zsv.js} +44 -6
- package/dist/index-yxawqmdd.js +212 -0
- package/dist/{index-zg8yq4ya.js → index-znzgze2v.js} +3 -3
- package/dist/index.js +38 -35
- package/dist/{message-index-bounded-hqktkhdy.js → message-index-bounded-pv6ct15d.js} +18 -17
- package/dist/message-index-jqa7qd0s.js +60 -0
- package/dist/migration-worker.js +3 -3
- package/dist/{project-embedding-registry-0gv3h6y8.js → project-embedding-registry-fcmszatg.js} +4 -4
- package/dist/raw-ordinal-warmup-worker.js +22 -5
- package/dist/{read-session-chunk-5mh0bh8y.js → read-session-chunk-cwgjwjd0.js} +7 -6
- package/dist/{read-session-raw-8sjbc9h0.js → read-session-raw-z38cn0as.js} +2 -1
- package/dist/{recomp-orchestrator-kpkhkjhq.js → recomp-orchestrator-xw9wt5bm.js} +19 -17
- package/dist/{search-p9w39qv4.js → search-v1t47s2q.js} +14 -13
- package/dist/{send-session-notification-xffh3bbe.js → send-session-notification-yp9m5g4p.js} +4 -3
- package/dist/shared/tag-owner-id.d.ts +1 -0
- package/dist/shared/tag-owner-id.d.ts.map +1 -1
- package/dist/{storage-tags-k0pda32s.js → storage-tags-0ssbmzg9.js} +2 -2
- package/dist/{transform-postprocess-phase-481j5a7z.js → transform-postprocess-phase-ttra554y.js} +19 -17
- package/dist/v2/auto-search-worker.js +3 -3
- package/dist/v2/compaction-marker-candidates-1s21e2fz.js +18 -0
- package/dist/v2/compaction-marker-candidates-worker.js +24 -0
- package/dist/v2/{context-gsdtha5v.js → context-6en6a8ar.js} +121 -50
- package/dist/v2/{embedding-backfill-dbvjbcmm.js → embedding-backfill-9hbkfvnz.js} +5 -5
- package/dist/v2/{message-index-bounded-p6v0n8qh.js → message-index-bounded-c0810p5w.js} +17 -16
- package/dist/v2/message-index-h8ssgq3q.js +59 -0
- package/dist/v2/migration-worker.js +3 -3
- package/dist/v2/{project-embedding-registry-nyq7z8y6.js → project-embedding-registry-42th7k1z.js} +4 -4
- package/dist/v2/raw-ordinal-warmup-worker.js +22 -5
- package/dist/v2/{read-session-chunk-fhyfe4qa.js → read-session-chunk-n86v9xfg.js} +6 -5
- package/dist/v2/{read-session-raw-j8dvp7f4.js → read-session-raw-3b3ehga4.js} +2 -1
- package/dist/v2/{recomp-orchestrator-5xy7w136.js → recomp-orchestrator-krvsbnds.js} +16 -14
- package/dist/v2/{search-j7bakcwa.js → search-048v8y02.js} +13 -12
- package/dist/v2/{send-session-notification-f6v698r5.js → send-session-notification-a4h2azxa.js} +2 -1
- package/dist/v2/{server-bgzy0phk.js → server-3bc6k4k4.js} +62 -33
- package/dist/v2/{server-7h861yms.js → server-3dqjhchy.js} +5 -18
- package/dist/v2/{server-c7n2ftng.js → server-4n2tknpc.js} +34 -3
- package/dist/v2/server-51779zs2.js +19 -0
- package/dist/v2/{server-kh958yj8.js → server-5zrpr764.js} +1 -1
- package/dist/v2/{server-6tcrjfw8.js → server-8pqnnmf9.js} +1 -1
- package/dist/v2/server-9290a1mb.js +212 -0
- package/dist/v2/{server-7vkj6zhb.js → server-9a6v0wth.js} +3 -3
- package/dist/v2/{server-1fszbabv.js → server-cjz51jm2.js} +2 -2
- package/dist/v2/{server-7spkq1y6.js → server-e2v4m8xe.js} +4084 -3967
- package/dist/v2/{server-mqvtz7wz.js → server-hetyb88z.js} +9 -9
- package/dist/v2/{server-4c7jt8gq.js → server-pcygfdbs.js} +44 -6
- package/dist/v2/{server-8xmq9h3f.js → server-q6j5dasr.js} +4 -2
- package/dist/v2/{server-zbxjj2mz.js → server-rygvffsf.js} +2 -2
- package/dist/v2/server.js +4 -4
- package/dist/v2/{storage-tags-5yxrvkaf.js → storage-tags-3a4cavqb.js} +2 -2
- package/dist/v2/{wrapup-orchestrator-yem5422s.js → wrapup-orchestrator-r2v7kgy3.js} +14 -12
- package/dist/{wrapup-orchestrator-xvrr27ws.js → wrapup-orchestrator-z7agncp8.js} +20 -18
- package/package.json +3 -3
- package/src/config/latch-permanence-guard.test.ts +6 -1
- package/src/shared/sqlite-writer-diagnostics.test.ts +21 -10
- package/src/shared/tag-owner-id.ts +13 -0
- package/src/shared/tag-transcript.test.ts +6 -1
- package/src/shared/tag-transcript.ts +2 -1
- package/src/shared/windows-hidden-spawns.test.ts +60 -4
- /package/dist/{index-69vas84q.js → index-e6xnpach.js} +0 -0
- /package/dist/{index-p1hnwfd8.js → index-gcdb3rqw.js} +0 -0
- /package/dist/v2/{index-69vas84q.js → index-e6xnpach.js} +0 -0
- /package/dist/v2/{server-s2st631p.js → server-8wcf79fe.js} +0 -0
|
@@ -129,6 +129,7 @@ function isThinkingPart(part) {
|
|
|
129
129
|
|
|
130
130
|
// src/shared/tag-owner-id.ts
|
|
131
131
|
var TEXT_TAG_IDENTITY_MARKER = ":mc-text-v1:";
|
|
132
|
+
var PI_FALLBACK_PREFIXES_JSON = JSON.stringify([..."pi-msg-"].reduce((prefixes, char) => prefixes.flatMap((prefix) => /[a-z]/.test(char) ? [prefix + char, prefix + char.toUpperCase()] : [prefix + char]), [""]));
|
|
132
133
|
var POSITIONAL_CONTENT_SUFFIX = /:(?:p|file)\d+$/;
|
|
133
134
|
var CONTENT_DERIVED_TEXT_SUFFIX = /:mc-text-v1:[0-9a-f]+:[0-9a-f]+:o\d+$/;
|
|
134
135
|
function contentTagOwnerMessageId(contentId) {
|
|
@@ -2257,8 +2258,41 @@ function getPersistedToolTagAccounting2(db, sessionId, tagNumber) {
|
|
|
2257
2258
|
}
|
|
2258
2259
|
return row;
|
|
2259
2260
|
}
|
|
2260
|
-
function getAllStatusTagTokenTotalsFlat2(db, sessionId, floor = 0, calibration = { proseRatio: 1, toolsRatio: 1 }) {
|
|
2261
|
-
const
|
|
2261
|
+
function getAllStatusTagTokenTotalsFlat2(db, sessionId, floor = 0, calibration = { proseRatio: 1, toolsRatio: 1 }, ownerMessageIds) {
|
|
2262
|
+
const columns = "type, message_id, tool_owner_message_id, token_count, input_token_count, reasoning_token_count";
|
|
2263
|
+
const owners = ownerMessageIds ? new Set(ownerMessageIds) : undefined;
|
|
2264
|
+
let scanOrder = "id";
|
|
2265
|
+
if (owners) {
|
|
2266
|
+
const planStatement = db.prepare(`EXPLAIN QUERY PLAN SELECT ${columns} FROM tags WHERE session_id = ?${floor > 0 ? " AND tag_number >= ?" : ""}`);
|
|
2267
|
+
let plan;
|
|
2268
|
+
try {
|
|
2269
|
+
plan = planStatement.all(sessionId, ...floor > 0 ? [floor] : []);
|
|
2270
|
+
} finally {
|
|
2271
|
+
planStatement.finalize?.();
|
|
2272
|
+
}
|
|
2273
|
+
const index = plan.map((row) => /USING (?:COVERING )?INDEX (\S+)/.exec(row.detail)?.[1]).find(Boolean);
|
|
2274
|
+
if (index) {
|
|
2275
|
+
const keyStatement = db.prepare("SELECT name, coll, desc FROM pragma_index_xinfo(?) WHERE key = 1 ORDER BY seqno");
|
|
2276
|
+
let keys;
|
|
2277
|
+
try {
|
|
2278
|
+
keys = keyStatement.all(index);
|
|
2279
|
+
} finally {
|
|
2280
|
+
keyStatement.finalize?.();
|
|
2281
|
+
}
|
|
2282
|
+
scanOrder = [
|
|
2283
|
+
...keys.map((key) => `"${(key.name ?? "id").replaceAll('"', '""')}" COLLATE "${key.coll.replaceAll('"', '""')}"${key.desc ? " DESC" : ""}`),
|
|
2284
|
+
"id"
|
|
2285
|
+
].join(", ");
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
const rows = owners ? db.prepare(`SELECT ${columns} FROM tags WHERE id IN (
|
|
2289
|
+
SELECT t.id FROM json_each(?) o CROSS JOIN tags t INDEXED BY idx_tags_session_message_id
|
|
2290
|
+
ON t.session_id = ? AND t.message_id >= o.value AND t.message_id < o.value || ';'
|
|
2291
|
+
UNION
|
|
2292
|
+
SELECT t.id FROM json_each(?) o CROSS JOIN tags t INDEXED BY idx_tags_pi_fallback_tool_owner
|
|
2293
|
+
ON t.session_id = ? AND t.tool_owner_message_id = o.value
|
|
2294
|
+
WHERE t.type = 'tool'
|
|
2295
|
+
) AND tag_number >= ? ORDER BY ${scanOrder}`).all(JSON.stringify([...owners]), sessionId, JSON.stringify([...owners]), sessionId, floor) : floor > 0 ? db.prepare(`SELECT type, message_id, tool_owner_message_id, token_count, input_token_count, reasoning_token_count
|
|
2262
2296
|
FROM tags
|
|
2263
2297
|
WHERE session_id = ? AND tag_number >= ?`).all(sessionId, floor) : db.prepare(`SELECT type, message_id, tool_owner_message_id, token_count, input_token_count, reasoning_token_count
|
|
2264
2298
|
FROM tags
|
|
@@ -2269,6 +2303,8 @@ function getAllStatusTagTokenTotalsFlat2(db, sessionId, floor = 0, calibration =
|
|
|
2269
2303
|
if (row.type === "tool" && row.tool_owner_message_id === null)
|
|
2270
2304
|
continue;
|
|
2271
2305
|
const owner = ownerMessageIdForTagRow(row);
|
|
2306
|
+
if (owners && !owners.has(owner))
|
|
2307
|
+
continue;
|
|
2272
2308
|
if (row.token_count === null) {
|
|
2273
2309
|
nullMessageIds.add(owner);
|
|
2274
2310
|
totals.delete(owner);
|
|
@@ -3032,11 +3068,13 @@ function findPiFallbackToolOwnerTags2(db, sessionId) {
|
|
|
3032
3068
|
message_id AS callId,
|
|
3033
3069
|
tool_owner_message_id AS toolOwnerMessageId,
|
|
3034
3070
|
status
|
|
3035
|
-
FROM tags
|
|
3071
|
+
FROM json_each(?) prefix CROSS JOIN tags
|
|
3036
3072
|
WHERE session_id = ?
|
|
3037
|
-
AND type = 'tool'
|
|
3038
|
-
|
|
3039
|
-
|
|
3073
|
+
AND tags.type = 'tool'
|
|
3074
|
+
AND tool_owner_message_id >= prefix.value
|
|
3075
|
+
AND tool_owner_message_id < substr(prefix.value, 1, 6) || '.'
|
|
3076
|
+
AND tool_owner_message_id LIKE 'pi-msg-%'
|
|
3077
|
+
ORDER BY tag_number ASC`).all(PI_FALLBACK_PREFIXES_JSON, sessionId).filter(isPiFallbackToolOwnerTag);
|
|
3040
3078
|
}
|
|
3041
3079
|
|
|
3042
3080
|
class PiTagIdentityConflictError extends Error {
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import {
|
|
2
|
+
registerExitAbort
|
|
3
|
+
} from "./index-v0p37hm2.js";
|
|
4
|
+
import {
|
|
5
|
+
log2
|
|
6
|
+
} from "./index-nsjyysj0.js";
|
|
7
|
+
import {
|
|
8
|
+
getSqliteDatabasePath2
|
|
9
|
+
} from "./index-kb9nn0a0.js";
|
|
10
|
+
|
|
11
|
+
// src/features/magic-context/compaction-marker-candidates.ts
|
|
12
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
14
|
+
import { Worker } from "node:worker_threads";
|
|
15
|
+
var candidates = new WeakMap;
|
|
16
|
+
var pending = new WeakMap;
|
|
17
|
+
var workers = new Set;
|
|
18
|
+
var missingWorkerWarnings = new Set;
|
|
19
|
+
var ownWriteRevisions = new Map;
|
|
20
|
+
var exitRegistered = false;
|
|
21
|
+
function reportWorkerUnavailable(entry, detail) {
|
|
22
|
+
if (missingWorkerWarnings.has(entry.href))
|
|
23
|
+
return;
|
|
24
|
+
missingWorkerWarnings.add(entry.href);
|
|
25
|
+
const path = entry.protocol === "file:" ? fileURLToPath(entry) : entry.href;
|
|
26
|
+
log2(`[magic-context] [ERROR] compaction-marker: candidate worker unavailable ${path}: ${detail}; marker unchanged, advancement deferred`);
|
|
27
|
+
}
|
|
28
|
+
var MARKER_CERTIFICATION_SQL = `SELECT
|
|
29
|
+
(SELECT rowid FROM message WHERE id = ?) AS previousRowid,
|
|
30
|
+
(SELECT rowid FROM message ORDER BY rowid DESC LIMIT 1) AS newestRowid,
|
|
31
|
+
(SELECT id FROM message ORDER BY rowid DESC LIMIT 1) AS newestId,
|
|
32
|
+
EXISTS(SELECT 1 FROM message
|
|
33
|
+
WHERE rowid > ? AND +session_id = ? AND json_valid(data)
|
|
34
|
+
AND COALESCE(json_extract(data, '$.summary'), 0) = 1) AS newSummary`;
|
|
35
|
+
function isMarkerCandidateBasisCurrent2(db, basis) {
|
|
36
|
+
if (basis.connection !== db || ownWriteRevisions.get(basis.revisionKey) !== basis.ownWriteRevision)
|
|
37
|
+
return false;
|
|
38
|
+
try {
|
|
39
|
+
const current = db.prepare(MARKER_CERTIFICATION_SQL).get(basis.frontier?.id ?? null, basis.frontier?.rowid ?? 0, basis.sessionId);
|
|
40
|
+
if (current.newSummary || basis.frontier && (current.previousRowid !== basis.frontier.rowid || current.newestRowid === null || current.newestRowid < basis.frontier.rowid))
|
|
41
|
+
return false;
|
|
42
|
+
if (current.newestRowid !== null && (!Number.isSafeInteger(current.newestRowid) || current.newestId === null))
|
|
43
|
+
return false;
|
|
44
|
+
basis.frontier = current.newestRowid === null || current.newestId === null ? null : { rowid: current.newestRowid, id: current.newestId };
|
|
45
|
+
return true;
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function invalidateMarkerCandidateBasis2(db, sessionId) {
|
|
51
|
+
candidates.get(db)?.delete(sessionId);
|
|
52
|
+
const path = getSqliteDatabasePath2(db);
|
|
53
|
+
if (!path)
|
|
54
|
+
return;
|
|
55
|
+
const key = `${realpathSync(path)}\x00${sessionId}`;
|
|
56
|
+
const revision = ownWriteRevisions.get(key);
|
|
57
|
+
if (revision !== undefined)
|
|
58
|
+
ownWriteRevisions.set(key, revision + 1);
|
|
59
|
+
}
|
|
60
|
+
function readMarkerCandidateBasis2(db, sessionId) {
|
|
61
|
+
const basis = candidates.get(db)?.get(sessionId);
|
|
62
|
+
if (basis && isMarkerCandidateBasisCurrent2(db, basis))
|
|
63
|
+
return basis;
|
|
64
|
+
candidates.get(db)?.delete(sessionId);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
function prepareMarkerCandidateBasis2(db, sessionId, options = {}) {
|
|
68
|
+
if (readMarkerCandidateBasis2(db, sessionId))
|
|
69
|
+
return Promise.resolve(true);
|
|
70
|
+
const path = getSqliteDatabasePath2(db);
|
|
71
|
+
if (!path || db.inTransaction)
|
|
72
|
+
return Promise.resolve(false);
|
|
73
|
+
const active = pending.get(db) ?? new Map;
|
|
74
|
+
const existing = active.get(sessionId);
|
|
75
|
+
if (existing)
|
|
76
|
+
return existing;
|
|
77
|
+
const revisionKey = `${realpathSync(path)}\x00${sessionId}`;
|
|
78
|
+
const ownWriteRevision = ownWriteRevisions.get(revisionKey) ?? 0;
|
|
79
|
+
ownWriteRevisions.set(revisionKey, ownWriteRevision);
|
|
80
|
+
const entry = options.entry ?? markerWorkerEntry();
|
|
81
|
+
if (entry.protocol === "file:" && !existsSync(fileURLToPath(entry))) {
|
|
82
|
+
reportWorkerUnavailable(entry, "file missing");
|
|
83
|
+
return Promise.resolve(false);
|
|
84
|
+
}
|
|
85
|
+
const preparation = runCandidateWorker(path, sessionId, options).then((snapshot) => {
|
|
86
|
+
if (!snapshot)
|
|
87
|
+
return false;
|
|
88
|
+
const basis = {
|
|
89
|
+
...snapshot,
|
|
90
|
+
connection: db,
|
|
91
|
+
sessionId,
|
|
92
|
+
revisionKey,
|
|
93
|
+
ownWriteRevision
|
|
94
|
+
};
|
|
95
|
+
if (!isMarkerCandidateBasisCurrent2(db, basis)) {
|
|
96
|
+
candidates.get(db)?.delete(sessionId);
|
|
97
|
+
log2(`[magic-context] compaction-marker: deferred candidate preparation for ${sessionId}: summary set or frontier changed during discovery; marker unchanged`);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
const sessions = candidates.get(db) ?? new Map;
|
|
101
|
+
sessions.set(sessionId, basis);
|
|
102
|
+
candidates.set(db, sessions);
|
|
103
|
+
return true;
|
|
104
|
+
}).finally(() => {
|
|
105
|
+
if (active.get(sessionId) === preparation)
|
|
106
|
+
active.delete(sessionId);
|
|
107
|
+
});
|
|
108
|
+
active.set(sessionId, preparation);
|
|
109
|
+
pending.set(db, active);
|
|
110
|
+
return preparation;
|
|
111
|
+
}
|
|
112
|
+
function markerWorkerEntry() {
|
|
113
|
+
return new URL(new URL(import.meta.url).pathname.endsWith(".ts") ? "./compaction-marker-candidates-worker.ts" : "./compaction-marker-candidates-worker.js", import.meta.url);
|
|
114
|
+
}
|
|
115
|
+
function runCandidateWorker(path, sessionId, options) {
|
|
116
|
+
if (!exitRegistered) {
|
|
117
|
+
exitRegistered = true;
|
|
118
|
+
const controller = new AbortController;
|
|
119
|
+
controller.signal.addEventListener("abort", () => {
|
|
120
|
+
for (const worker of workers) {
|
|
121
|
+
worker.terminate();
|
|
122
|
+
worker.unref();
|
|
123
|
+
}
|
|
124
|
+
}, { once: true });
|
|
125
|
+
registerExitAbort(controller);
|
|
126
|
+
}
|
|
127
|
+
return new Promise((resolve) => {
|
|
128
|
+
const entry = options.entry ?? markerWorkerEntry();
|
|
129
|
+
let worker;
|
|
130
|
+
let timer;
|
|
131
|
+
let done = false;
|
|
132
|
+
const finish = (snapshot) => {
|
|
133
|
+
if (done)
|
|
134
|
+
return;
|
|
135
|
+
done = true;
|
|
136
|
+
clearTimeout(timer);
|
|
137
|
+
if (!worker) {
|
|
138
|
+
resolve(snapshot);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
workers.delete(worker);
|
|
142
|
+
const stopped = worker.terminate();
|
|
143
|
+
worker.unref();
|
|
144
|
+
stopped.then(() => resolve(snapshot), () => resolve(snapshot));
|
|
145
|
+
};
|
|
146
|
+
const deadline = (ms) => {
|
|
147
|
+
clearTimeout(timer);
|
|
148
|
+
timer = setTimeout(() => {
|
|
149
|
+
reportWorkerUnavailable(entry, "worker deadline exceeded");
|
|
150
|
+
finish();
|
|
151
|
+
}, ms);
|
|
152
|
+
timer.unref?.();
|
|
153
|
+
};
|
|
154
|
+
try {
|
|
155
|
+
worker = new Worker(entry, { workerData: { path, sessionId } });
|
|
156
|
+
workers.add(worker);
|
|
157
|
+
worker.unref();
|
|
158
|
+
deadline(options.acceptMs ?? 2000);
|
|
159
|
+
worker.on("message", (reply) => {
|
|
160
|
+
if (reply.kind === "accepted")
|
|
161
|
+
deadline(options.resultMs ?? 600000);
|
|
162
|
+
else if (reply.kind === "candidates")
|
|
163
|
+
finish(reply.snapshot);
|
|
164
|
+
else {
|
|
165
|
+
reportWorkerUnavailable(entry, reply.error);
|
|
166
|
+
finish();
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
worker.on("error", (error) => {
|
|
170
|
+
reportWorkerUnavailable(entry, error.message);
|
|
171
|
+
finish();
|
|
172
|
+
});
|
|
173
|
+
worker.on("exit", (code) => {
|
|
174
|
+
if (!done)
|
|
175
|
+
reportWorkerUnavailable(entry, `worker exited before replying (${code})`);
|
|
176
|
+
finish();
|
|
177
|
+
});
|
|
178
|
+
} catch (error) {
|
|
179
|
+
reportWorkerUnavailable(entry, error instanceof Error ? error.message : String(error));
|
|
180
|
+
finish();
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function scanMarkerSummaryCandidates(db, sessionId) {
|
|
185
|
+
const ownsSnapshot = !db.inTransaction;
|
|
186
|
+
if (ownsSnapshot)
|
|
187
|
+
db.exec("BEGIN");
|
|
188
|
+
try {
|
|
189
|
+
return db.prepare(`SELECT id FROM message WHERE session_id=? AND
|
|
190
|
+
CASE WHEN json_valid(data) THEN COALESCE(json_extract(data,'$.summary'),0) ELSE 0 END=1`).all(sessionId).map((row) => row.id);
|
|
191
|
+
} finally {
|
|
192
|
+
if (ownsSnapshot)
|
|
193
|
+
db.exec("ROLLBACK");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function scanMarkerCandidateSnapshot2(db, sessionId) {
|
|
197
|
+
const ownsSnapshot = !db.inTransaction;
|
|
198
|
+
if (ownsSnapshot)
|
|
199
|
+
db.exec("BEGIN");
|
|
200
|
+
try {
|
|
201
|
+
const ids = scanMarkerSummaryCandidates(db, sessionId);
|
|
202
|
+
const frontier = db.prepare("SELECT rowid,id FROM message ORDER BY rowid DESC LIMIT 1").get() ?? null;
|
|
203
|
+
if (frontier && !Number.isSafeInteger(frontier.rowid))
|
|
204
|
+
throw new Error("marker frontier rowid is not a safe integer");
|
|
205
|
+
return { ids, frontier };
|
|
206
|
+
} finally {
|
|
207
|
+
if (ownsSnapshot)
|
|
208
|
+
db.exec("ROLLBACK");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export { isMarkerCandidateBasisCurrent2, invalidateMarkerCandidateBasis2, readMarkerCandidateBasis2, prepareMarkerCandidateBasis2, scanMarkerCandidateSnapshot2 };
|
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
hasPendingMigrations,
|
|
48
48
|
getMainThreadMigrationBodyCount,
|
|
49
49
|
runMigrations
|
|
50
|
-
} from "./index-
|
|
50
|
+
} from "./index-xfbfrngb.js";
|
|
51
51
|
import {
|
|
52
52
|
installTagIdentityRevisionTrigger,
|
|
53
53
|
ensureColumn,
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
import {
|
|
61
61
|
bootQuietRemainingMs,
|
|
62
62
|
scheduleAfterBootQuiet
|
|
63
|
-
} from "./index-
|
|
63
|
+
} from "./index-41gqa557.js";
|
|
64
64
|
import {
|
|
65
65
|
setDatabase,
|
|
66
66
|
loadToolDefinitionMeasurements
|
|
@@ -1259,7 +1259,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1259
1259
|
startMessageFtsRowidMapBackfill(db).then(async () => {
|
|
1260
1260
|
if (!readsOpenCodeStore)
|
|
1261
1261
|
return;
|
|
1262
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1262
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-cwgjwjd0.js"));
|
|
1263
1263
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-8x06r9kx.js"));
|
|
1264
1264
|
await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
|
|
1265
1265
|
readPage: readRawSessionMessagePage
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ import {
|
|
|
72
72
|
checkCompactionMarkerConsistency,
|
|
73
73
|
clearInjectionCache,
|
|
74
74
|
clearNoteNudgeTriggerOnly
|
|
75
|
-
} from "./index-
|
|
75
|
+
} from "./index-v4bqjy56.js";
|
|
76
76
|
import"./index-sd3egckz.js";
|
|
77
77
|
import {
|
|
78
78
|
hasTrustedAbsoluteWall,
|
|
@@ -100,6 +100,7 @@ import {
|
|
|
100
100
|
createDreamTaskExecutor,
|
|
101
101
|
runManualDream,
|
|
102
102
|
runDueTasksForProject,
|
|
103
|
+
scheduleClearAndReindex,
|
|
103
104
|
startDreamScheduleTimer,
|
|
104
105
|
ensureProjectRegisteredFromOpenCodeDirectory,
|
|
105
106
|
recordOpenCodeProvenInputFloor,
|
|
@@ -111,7 +112,6 @@ import {
|
|
|
111
112
|
resolveSessionId,
|
|
112
113
|
createScheduler,
|
|
113
114
|
describeStorageUnavailability,
|
|
114
|
-
scheduleClearAndReindex,
|
|
115
115
|
resolveSessionCacheTtl,
|
|
116
116
|
runEmbedHistoryDrain,
|
|
117
117
|
pauseEmbedHistoryDrain,
|
|
@@ -158,7 +158,7 @@ import {
|
|
|
158
158
|
parameterDescriptionsFor,
|
|
159
159
|
MagicContextRpcServer,
|
|
160
160
|
applyHiddenSubagentTemperature
|
|
161
|
-
} from "./index-
|
|
161
|
+
} from "./index-x3y1np1h.js";
|
|
162
162
|
import {
|
|
163
163
|
formatFailClosedBlockingMessage,
|
|
164
164
|
createFailClosedController,
|
|
@@ -173,7 +173,7 @@ import {
|
|
|
173
173
|
openDatabaseAsync,
|
|
174
174
|
isDatabasePersisted,
|
|
175
175
|
getDatabasePersistenceError
|
|
176
|
-
} from "./index-
|
|
176
|
+
} from "./index-znzgze2v.js";
|
|
177
177
|
import {
|
|
178
178
|
setHomeProjectPermission,
|
|
179
179
|
ProjectIdentityError,
|
|
@@ -184,7 +184,7 @@ import {
|
|
|
184
184
|
beginBootQuietPeriod,
|
|
185
185
|
bootQuietRemainingMs,
|
|
186
186
|
scheduleAfterBootQuiet
|
|
187
|
-
} from "./index-
|
|
187
|
+
} from "./index-41gqa557.js";
|
|
188
188
|
import {
|
|
189
189
|
deleteTemporalDecision
|
|
190
190
|
} from "./index-1bt88epp.js";
|
|
@@ -192,18 +192,18 @@ import {
|
|
|
192
192
|
BoundedSessionMap,
|
|
193
193
|
observeSessionActivity,
|
|
194
194
|
backfillSessionActivity,
|
|
195
|
-
|
|
196
|
-
} from "./index-
|
|
195
|
+
deleteIndexedMessage2
|
|
196
|
+
} from "./index-3wckxwfp.js";
|
|
197
197
|
import {
|
|
198
198
|
recordSessionProjectIdentity,
|
|
199
199
|
getProjectEmbeddingSnapshot2,
|
|
200
200
|
getEmbeddingCoverageStatus2,
|
|
201
201
|
getAutoEmbeddingSessionCoverage2
|
|
202
|
-
} from "./index-
|
|
202
|
+
} from "./index-c0b01zrc.js";
|
|
203
203
|
import"./index-6m7rdv7y.js";
|
|
204
204
|
import"./index-fb3zxn06.js";
|
|
205
205
|
import"./index-7w18gg78.js";
|
|
206
|
-
import"./index-
|
|
206
|
+
import"./index-xfbfrngb.js";
|
|
207
207
|
import"./index-fr0wbhdn.js";
|
|
208
208
|
import {
|
|
209
209
|
preloadTokenizer
|
|
@@ -241,30 +241,32 @@ import {
|
|
|
241
241
|
detectOverflow,
|
|
242
242
|
isAnthropicFamilyRoute,
|
|
243
243
|
readRawSessionMessages2
|
|
244
|
-
} from "./index-
|
|
244
|
+
} from "./index-7zg9dvx0.js";
|
|
245
245
|
import"./index-vkbqdnkj.js";
|
|
246
246
|
import {
|
|
247
247
|
getDefaultSubcConnectionFile,
|
|
248
248
|
SubcModuleTransport
|
|
249
|
-
} from "./index-
|
|
249
|
+
} from "./index-fst3t0d9.js";
|
|
250
250
|
import {
|
|
251
251
|
isEmbeddingHostBusy2
|
|
252
252
|
} from "./index-qt1qqasc.js";
|
|
253
253
|
import"./index-tqf7yg27.js";
|
|
254
254
|
import {
|
|
255
255
|
registerExitAbort,
|
|
256
|
-
unregisterExitAbort
|
|
256
|
+
unregisterExitAbort
|
|
257
|
+
} from "./index-v0p37hm2.js";
|
|
258
|
+
import {
|
|
257
259
|
forgetRawSessionOrdinalWatermark2
|
|
258
|
-
} from "./index-
|
|
260
|
+
} from "./index-jpm52v9x.js";
|
|
259
261
|
import {
|
|
260
262
|
observeOpenCodeTurnEvent,
|
|
261
263
|
clearTrackedOpenCodeSession,
|
|
262
264
|
findLastAssistantModelFromOpenCodeDb
|
|
263
|
-
} from "./index-
|
|
265
|
+
} from "./index-qvr78ej6.js";
|
|
264
266
|
import {
|
|
265
267
|
sendCommandResult2,
|
|
266
268
|
sendStatusNotification2
|
|
267
|
-
} from "./index-
|
|
269
|
+
} from "./index-bhk710rw.js";
|
|
268
270
|
import {
|
|
269
271
|
detectConflicts,
|
|
270
272
|
resolveCompactionForBoot
|
|
@@ -272,13 +274,13 @@ import {
|
|
|
272
274
|
import {
|
|
273
275
|
sendConflictWarning2,
|
|
274
276
|
cleanupConflictWarnings2
|
|
275
|
-
} from "./index-
|
|
277
|
+
} from "./index-m4p77myp.js";
|
|
276
278
|
import"./index-1zx87sdm.js";
|
|
277
279
|
import {
|
|
278
280
|
stripPersistedAssistantText,
|
|
279
281
|
deleteTagsByMessageId2,
|
|
280
282
|
getMaxTagNumberBySession2
|
|
281
|
-
} from "./index-
|
|
283
|
+
} from "./index-yqps2zsv.js";
|
|
282
284
|
import {
|
|
283
285
|
resolveHistorianModel2,
|
|
284
286
|
resolveOpenCodeAgentOverrides2,
|
|
@@ -288,25 +290,26 @@ import {
|
|
|
288
290
|
buildDreamTaskRuntimeConfigs2,
|
|
289
291
|
userMemoryCollectionEnabled2
|
|
290
292
|
} from "./index-ghc9f0n7.js";
|
|
291
|
-
import"./index-
|
|
292
|
-
import"./index-
|
|
293
|
+
import"./index-gcdb3rqw.js";
|
|
294
|
+
import"./index-fjtgekd4.js";
|
|
293
295
|
import {
|
|
294
296
|
pushNotification2
|
|
295
297
|
} from "./index-x8a7jmkh.js";
|
|
296
298
|
import"./index-gbmqa9x9.js";
|
|
297
299
|
import"./index-4dhv7mqz.js";
|
|
298
|
-
import"./index-
|
|
300
|
+
import"./index-7ndnvw7a.js";
|
|
299
301
|
import"./index-7jzrrxap.js";
|
|
302
|
+
import"./index-yxawqmdd.js";
|
|
300
303
|
import {
|
|
301
304
|
createTagger,
|
|
302
305
|
cavemanWordRulesForLanguage,
|
|
303
306
|
setCtxReduceRegisteredGlobally,
|
|
304
307
|
clearToolPermissionDenied,
|
|
305
308
|
resetDegradedCacheCount2
|
|
306
|
-
} from "./index-
|
|
309
|
+
} from "./index-2mqps3c1.js";
|
|
307
310
|
import {
|
|
308
311
|
runManagedRecomp2
|
|
309
|
-
} from "./index-
|
|
312
|
+
} from "./index-dd18gej8.js";
|
|
310
313
|
import {
|
|
311
314
|
isValidSemver,
|
|
312
315
|
compareSemverCore
|
|
@@ -314,7 +317,7 @@ import {
|
|
|
314
317
|
import"./index-fmsr7v69.js";
|
|
315
318
|
import {
|
|
316
319
|
runManagedWrapup2
|
|
317
|
-
} from "./index-
|
|
320
|
+
} from "./index-p2hs3rps.js";
|
|
318
321
|
import {
|
|
319
322
|
__toESM,
|
|
320
323
|
__commonJS
|
|
@@ -8176,7 +8179,7 @@ var require_src2 = __commonJS(function(exports, module) {
|
|
|
8176
8179
|
// package.json
|
|
8177
8180
|
var package_default = {
|
|
8178
8181
|
name: "@cortexkit/opencode-magic-context",
|
|
8179
|
-
version: "0.49.
|
|
8182
|
+
version: "0.49.4",
|
|
8180
8183
|
type: "module",
|
|
8181
8184
|
description: "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
8182
8185
|
main: "dist/index.js",
|
|
@@ -8213,8 +8216,8 @@ var package_default = {
|
|
|
8213
8216
|
"README.md"
|
|
8214
8217
|
],
|
|
8215
8218
|
scripts: {
|
|
8216
|
-
build: "bun ../../scripts/check-bun.mjs && tsc -p ../retina-local-fs/tsconfig.build.json && bun run build:tui && bun ../../scripts/clean-dist-chunks.mjs dist index.js transformers-web.js transformers-node-wasm.js && bun build src/features/magic-context/memory/transformers-web-entry.ts --outfile dist/transformers-web.js --target browser --format esm --external onnxruntime-web && bun scripts/build-transformers-node-wasm.ts dist && bun build src/index.ts src/features/magic-context/memory/embedding-worker.ts src/features/magic-context/memory/embedding-worker-process.ts src/features/magic-context/migration-worker.ts src/hooks/magic-context/auto-search-worker.ts src/hooks/magic-context/raw-ordinal-warmup-worker.ts --outdir dist --entry-naming '[name].[ext]' --target node --format esm --splitting --external @opencode-ai/plugin --external onnxruntime-node --external onnxruntime-web --external sharp --external bun:ffi --external bun:sqlite --external node:sqlite && bun run build:v2 && tsc --emitDeclarationOnly",
|
|
8217
|
-
"build:v2": "bun ../../scripts/clean-dist-chunks.mjs dist/v2 server.js embedding-worker.js embedding-worker-process.js migration-worker.js && bun build src/features/magic-context/memory/transformers-web-entry.ts --outfile dist/v2/transformers-web.js --target browser --format esm --external onnxruntime-web && bun scripts/build-transformers-node-wasm.ts dist/v2 && bun build src/v2/server.ts src/features/magic-context/memory/embedding-worker.ts src/features/magic-context/memory/embedding-worker-process.ts src/features/magic-context/migration-worker.ts src/hooks/magic-context/auto-search-worker.ts src/hooks/magic-context/raw-ordinal-warmup-worker.ts --outdir dist/v2 --entry-naming '[name].[ext]' --target node --format esm --splitting --external @opencode/plugin --external onnxruntime-node --external onnxruntime-web --external sharp --external bun:ffi --external bun:sqlite --external node:sqlite",
|
|
8219
|
+
build: "bun ../../scripts/check-bun.mjs && tsc -p ../retina-local-fs/tsconfig.build.json && bun run build:tui && bun ../../scripts/clean-dist-chunks.mjs dist index.js transformers-web.js transformers-node-wasm.js && bun build src/features/magic-context/memory/transformers-web-entry.ts --outfile dist/transformers-web.js --target browser --format esm --external onnxruntime-web && bun scripts/build-transformers-node-wasm.ts dist && bun build src/index.ts src/features/magic-context/memory/embedding-worker.ts src/features/magic-context/memory/embedding-worker-process.ts src/features/magic-context/migration-worker.ts src/hooks/magic-context/auto-search-worker.ts src/hooks/magic-context/raw-ordinal-warmup-worker.ts src/features/magic-context/compaction-marker-candidates-worker.ts --outdir dist --entry-naming '[name].[ext]' --target node --format esm --splitting --external @opencode-ai/plugin --external onnxruntime-node --external onnxruntime-web --external sharp --external bun:ffi --external bun:sqlite --external node:sqlite && bun run build:v2 && tsc --emitDeclarationOnly",
|
|
8220
|
+
"build:v2": "bun ../../scripts/clean-dist-chunks.mjs dist/v2 server.js embedding-worker.js embedding-worker-process.js migration-worker.js && bun build src/features/magic-context/memory/transformers-web-entry.ts --outfile dist/v2/transformers-web.js --target browser --format esm --external onnxruntime-web && bun scripts/build-transformers-node-wasm.ts dist/v2 && bun build src/v2/server.ts src/features/magic-context/memory/embedding-worker.ts src/features/magic-context/memory/embedding-worker-process.ts src/features/magic-context/migration-worker.ts src/hooks/magic-context/auto-search-worker.ts src/hooks/magic-context/raw-ordinal-warmup-worker.ts src/features/magic-context/compaction-marker-candidates-worker.ts --outdir dist/v2 --entry-naming '[name].[ext]' --target node --format esm --splitting --external @opencode/plugin --external onnxruntime-node --external onnxruntime-web --external sharp --external bun:ffi --external bun:sqlite --external node:sqlite",
|
|
8218
8221
|
"build:tui": "bun scripts/build-tui.ts",
|
|
8219
8222
|
"check:tui-compiled": 'git diff --exit-code -- src/tui-compiled && test -z "$(git status --porcelain -- src/tui-compiled)"',
|
|
8220
8223
|
"check:transformers-node-wasm": "bun scripts/verify-transformers-node-wasm.ts",
|
|
@@ -9657,7 +9660,7 @@ function cleanupRemovedMessageState(deps, sessionId, messageId) {
|
|
|
9657
9660
|
} else {
|
|
9658
9661
|
sessionLog2(sessionId, `event message.removed: reasoning watermark unchanged at ${currentWatermark} (max tag ${maxRemainingTag})`);
|
|
9659
9662
|
}
|
|
9660
|
-
const removedIndexedMessages =
|
|
9663
|
+
const removedIndexedMessages = deleteIndexedMessage2(deps.db, sessionId, messageId);
|
|
9661
9664
|
sessionLog2(sessionId, `event message.removed: deleted ${removedIndexedMessages} indexed message row(s) for ${messageId}`);
|
|
9662
9665
|
return {
|
|
9663
9666
|
clearedNoteNudge
|
|
@@ -12054,7 +12057,7 @@ async function setup(context) {
|
|
|
12054
12057
|
log2("v2 setup() called on a host without session.hook; v1 server lane owns this host, v2 lane inert");
|
|
12055
12058
|
return async () => {};
|
|
12056
12059
|
}
|
|
12057
|
-
const { registerContext } = await import("./context-
|
|
12060
|
+
const { registerContext } = await import("./context-yg023c5r.js");
|
|
12058
12061
|
setHarness2("opencode2");
|
|
12059
12062
|
bindStaleBuildNotice({}, import.meta.url, "opencode2");
|
|
12060
12063
|
const duties = await registerContext(context);
|
|
@@ -12125,7 +12128,7 @@ var server = async (ctx) => {
|
|
|
12125
12128
|
if (hasBannerEntries)
|
|
12126
12129
|
setTimeout(async () => {
|
|
12127
12130
|
try {
|
|
12128
|
-
const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-
|
|
12131
|
+
const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-yp9m5g4p.js"));
|
|
12129
12132
|
const clientWithSessions = ctx.client;
|
|
12130
12133
|
const sessions = await Promise.resolve(clientWithSessions.session?.list?.()).catch(() => null);
|
|
12131
12134
|
const sessionList = Array.isArray(sessions) ? sessions : sessions?.data;
|
|
@@ -12142,7 +12145,7 @@ var server = async (ctx) => {
|
|
|
12142
12145
|
log2(`[magic-context] opencode_db_missing path=${openCodeDbResolution.path} source=${openCodeDbResolution.source}`);
|
|
12143
12146
|
setTimeout(async () => {
|
|
12144
12147
|
try {
|
|
12145
|
-
const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-
|
|
12148
|
+
const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-yp9m5g4p.js"));
|
|
12146
12149
|
const clientWithSessions = ctx.client;
|
|
12147
12150
|
const sessions = await Promise.resolve(clientWithSessions.session?.list?.()).catch(() => null);
|
|
12148
12151
|
const sessionList = Array.isArray(sessions) ? sessions : sessions?.data;
|
|
@@ -12418,12 +12421,12 @@ var server = async (ctx) => {
|
|
|
12418
12421
|
{
|
|
12419
12422
|
const fence = getSchemaFenceRejection();
|
|
12420
12423
|
if (fence) {
|
|
12421
|
-
importPluginModule(() => import("./conflict-warning-hook-
|
|
12424
|
+
importPluginModule(() => import("./conflict-warning-hook-ae8nmv7c.js")).then(({ sendSchemaFenceWarning }) => sendSchemaFenceWarning(ctx.client, ctx.directory, fence)).catch((error) => log2("[magic-context] schema-fence warning unavailable:", error));
|
|
12422
12425
|
}
|
|
12423
12426
|
}
|
|
12424
12427
|
const serverUrl = ctx.serverUrl;
|
|
12425
12428
|
const serverUrlStr = serverUrl instanceof URL ? serverUrl.toString().replace(/\/$/, "") : typeof serverUrl === "string" ? serverUrl.replace(/\/$/, "") : undefined;
|
|
12426
|
-
importPluginModule(() => import("./send-session-notification-
|
|
12429
|
+
importPluginModule(() => import("./send-session-notification-yp9m5g4p.js")).then(({ setNotificationServerUrl }) => {
|
|
12427
12430
|
setNotificationServerUrl(serverUrlStr);
|
|
12428
12431
|
}).catch((error) => log2("[magic-context] notification transport unavailable:", error));
|
|
12429
12432
|
if (conflictResult?.hasConflict) {
|
|
@@ -12446,7 +12449,7 @@ var server = async (ctx) => {
|
|
|
12446
12449
|
}) => {
|
|
12447
12450
|
if (!shouldShowAnnouncement())
|
|
12448
12451
|
return;
|
|
12449
|
-
return importPluginModule(() => import("./conflict-warning-hook-
|
|
12452
|
+
return importPluginModule(() => import("./conflict-warning-hook-ae8nmv7c.js")).then(({ sendStartupAnnouncement }) => sendStartupAnnouncement(ctx.client, ctx.directory, ANNOUNCEMENT_VERSION, ANNOUNCEMENT_FEATURES, ANNOUNCEMENT_FOOTER, markAnnouncementSeen));
|
|
12450
12453
|
}).catch(() => {});
|
|
12451
12454
|
}, 8000);
|
|
12452
12455
|
}
|
|
@@ -12520,8 +12523,8 @@ var server = async (ctx) => {
|
|
|
12520
12523
|
tryReopenStorage,
|
|
12521
12524
|
rustReplayParticipant: () => magicContextRuntime.magicContext?.getRustReplayParticipant?.() ?? null,
|
|
12522
12525
|
onStorageBusyRefusal: async (sessionId, message) => {
|
|
12523
|
-
const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-
|
|
12524
|
-
const { abortSessionFailClosed } = await importPluginModule(() => import("./transform-postprocess-phase-
|
|
12526
|
+
const { sendStatusNotification } = await importPluginModule(() => import("./send-session-notification-yp9m5g4p.js"));
|
|
12527
|
+
const { abortSessionFailClosed } = await importPluginModule(() => import("./transform-postprocess-phase-ttra554y.js"));
|
|
12525
12528
|
await sendStatusNotification(ctx.client, sessionId, message, {
|
|
12526
12529
|
toastDurationMs: 15000
|
|
12527
12530
|
});
|
|
@@ -4,30 +4,31 @@ import {
|
|
|
4
4
|
yieldIndexChunk2
|
|
5
5
|
} from "./index-kb9nn0a0.js";
|
|
6
6
|
import"./index-1zx87sdm.js";
|
|
7
|
-
import"./index-
|
|
7
|
+
import"./index-yqps2zsv.js";
|
|
8
8
|
import"./index-qx53vezw.js";
|
|
9
9
|
import"./index-pavzsdc6.js";
|
|
10
10
|
import"./index-0sahzkwr.js";
|
|
11
11
|
import"./index-nsjyysj0.js";
|
|
12
12
|
import"./index-1bt88epp.js";
|
|
13
13
|
import"./index-k6xvbj2e.js";
|
|
14
|
-
import"./index-
|
|
14
|
+
import"./index-v0p37hm2.js";
|
|
15
|
+
import"./index-jpm52v9x.js";
|
|
15
16
|
import"./index-58e3y90n.js";
|
|
16
|
-
import"./index-
|
|
17
|
-
import"./index-
|
|
17
|
+
import"./index-qvr78ej6.js";
|
|
18
|
+
import"./index-7zg9dvx0.js";
|
|
18
19
|
import"./index-h2wc01qk.js";
|
|
19
20
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} from "./index-
|
|
21
|
+
MESSAGE_INDEX_MAX_FTS_BYTES2,
|
|
22
|
+
messageIndexSkipKey2,
|
|
23
|
+
getLastIndexedOrdinal2,
|
|
24
|
+
markMessageIndexDirty2,
|
|
25
|
+
getIndexableContent2,
|
|
26
|
+
indexSingleMessage2
|
|
27
|
+
} from "./index-3wckxwfp.js";
|
|
27
28
|
import"./index-7w18gg78.js";
|
|
28
29
|
import"./index-6m7rdv7y.js";
|
|
29
30
|
import"./index-vkbqdnkj.js";
|
|
30
|
-
import"./index-
|
|
31
|
+
import"./index-gcdb3rqw.js";
|
|
31
32
|
import"./index-4mjhqadz.js";
|
|
32
33
|
|
|
33
34
|
// src/features/magic-context/message-index-bounded.ts
|
|
@@ -78,13 +79,13 @@ async function indexMessageInShortChunks(db, sessionId, message, coordination, i
|
|
|
78
79
|
try {
|
|
79
80
|
if (!isCurrent())
|
|
80
81
|
return { inserted: false, measurements };
|
|
81
|
-
const content =
|
|
82
|
+
const content = getIndexableContent2(message.role, message.parts);
|
|
82
83
|
measurements.sourceBytes = Buffer.byteLength(content);
|
|
83
84
|
const hash = createHash("sha256");
|
|
84
|
-
const oversized = measurements.sourceBytes >
|
|
85
|
+
const oversized = measurements.sourceBytes > MESSAGE_INDEX_MAX_FTS_BYTES2;
|
|
85
86
|
measurements.skipped = oversized;
|
|
86
87
|
if (oversized) {
|
|
87
|
-
await transaction(() =>
|
|
88
|
+
await transaction(() => markMessageIndexDirty2(db, sessionId, Math.min(message.ordinal, getLastIndexedOrdinal2(db, sessionId) + 1)));
|
|
88
89
|
const encoded = Buffer.from(content);
|
|
89
90
|
const progress = db.prepare("INSERT INTO schema_migrations_meta(key,value) VALUES (?,?) ON CONFLICT(key) DO UPDATE SET value=excluded.value");
|
|
90
91
|
for (let offset = 0;offset < encoded.length; offset += IDENTITY_CHUNK_BYTES) {
|
|
@@ -92,7 +93,7 @@ async function indexMessageInShortChunks(db, sessionId, message, coordination, i
|
|
|
92
93
|
return { inserted: false, measurements };
|
|
93
94
|
const end = Math.min(encoded.length, offset + IDENTITY_CHUNK_BYTES);
|
|
94
95
|
hash.update(encoded.subarray(offset, end));
|
|
95
|
-
await transaction(() => progress.run(
|
|
96
|
+
await transaction(() => progress.run(messageIndexSkipKey2(sessionId, message.id), JSON.stringify({
|
|
96
97
|
reason: "oversized",
|
|
97
98
|
bytes: measurements.sourceBytes,
|
|
98
99
|
processedBytes: end,
|
|
@@ -114,7 +115,7 @@ async function indexMessageInShortChunks(db, sessionId, message, coordination, i
|
|
|
114
115
|
content: oversized ? "" : content,
|
|
115
116
|
...oversized ? { ftsSkippedBytes: measurements.sourceBytes } : {}
|
|
116
117
|
};
|
|
117
|
-
const inserted = await withIndexChunk2(coordination, () => withSqliteBackgroundWriter2(() =>
|
|
118
|
+
const inserted = await withIndexChunk2(coordination, () => withSqliteBackgroundWriter2(() => indexSingleMessage2(db, sessionId, message, isCurrent, source)));
|
|
118
119
|
return { inserted, measurements };
|
|
119
120
|
} finally {
|
|
120
121
|
db.exec = execute;
|