@cortexkit/opencode-magic-context 0.49.102 → 0.49.104
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 +5 -5
- package/dist/chunk-embedding-write-worker.js +1 -1
- package/dist/{context-4fjwzqqa.js → context-7hbmnpe8.js} +21 -21
- package/dist/{embedding-backfill-79br4kk6.js → embedding-backfill-aratv25b.js} +4 -4
- package/dist/{v2/embedding-cache-zn4r1c31.js → embedding-cache-fhdkn9nc.js} +3 -1
- package/dist/embedding-worker.js +1 -1
- package/dist/features/magic-context/memory/embedding-cache.d.ts +1 -0
- package/dist/features/magic-context/memory/embedding-cache.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-worker-loop.d.ts +9 -1
- package/dist/features/magic-context/memory/embedding-worker-loop.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts +2 -1
- package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +5 -2
- package/dist/features/magic-context/project-embedding-registry.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/{index-sgsaf60r.js → index-3nxhxeeg.js} +3 -3
- package/dist/{index-k7yytqrd.js → index-3rp2b482.js} +66 -31
- package/dist/{index-y33x200y.js → index-4536jdzj.js} +1 -1
- package/dist/{index-mhdavdd4.js → index-4ba3zp54.js} +12 -9
- package/dist/{index-63kp05sy.js → index-4v50y0jr.js} +1 -1
- package/dist/{index-zg5r2syy.js → index-6gd9akdt.js} +1 -1
- package/dist/{v2/server-qjwpqvnf.js → index-6xg55350.js} +18 -13
- package/dist/{index-e6s2jpr8.js → index-8eke8yh2.js} +2 -2
- package/dist/{index-tbhbxb09.js → index-8gzmeyae.js} +5 -5
- package/dist/{index-esym6cw4.js → index-8yj4vd7k.js} +4 -4
- package/dist/{index-kjhgxkdx.js → index-9jqaha1g.js} +1 -1
- package/dist/{index-fbg61b3d.js → index-a9wn0d9h.js} +4 -4
- package/dist/{index-3cgh0ght.js → index-f455a0g3.js} +1 -1
- package/dist/{index-k4c0majv.js → index-jjxpmypb.js} +3 -3
- package/dist/{index-634cww4x.js → index-mwjvjn0p.js} +9 -9
- package/dist/{index-nyjztqyj.js → index-p5ey52j9.js} +32 -5
- package/dist/{index-jjy4shhy.js → index-p8nc9axh.js} +1 -1
- package/dist/{index-rjxg7a7m.js → index-qzfz2tvk.js} +5 -1
- package/dist/{index-2b7g81z7.js → index-sqvkh5d0.js} +35 -8
- package/dist/{index-9emdjcb5.js → index-srpghrje.js} +1 -1
- package/dist/{index-mx4j316q.js → index-tvh3y650.js} +8 -8
- package/dist/{index-rakm1eay.js → index-zh683xh2.js} +2 -2
- package/dist/index.js +25 -25
- package/dist/{message-index-bounded-289186ah.js → message-index-bounded-8s8sx40x.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/{project-embedding-registry-xy8dcdys.js → project-embedding-registry-1n4cexsv.js} +3 -3
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-frnwxnjg.js → read-session-chunk-wwg20mte.js} +2 -2
- package/dist/{recomp-orchestrator-cvsfmctf.js → recomp-orchestrator-16rs8aty.js} +13 -13
- package/dist/{render-2a83mgrp.js → render-f32trg2t.js} +6 -6
- package/dist/{search-archive-f5dzec0e.js → search-archive-yh6xtvrx.js} +5 -5
- package/dist/{search-fxtb4844.js → search-v9ywqb4f.js} +12 -12
- package/dist/{storage-memory-hhrvfw0x.js → storage-memory-24hsvzy8.js} +2 -2
- package/dist/{storage-tags-2d2ba8e9.js → storage-tags-5nke1bdt.js} +1 -1
- package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-fyw30790.js → transform-postprocess-phase-yef4mxk3.js} +14 -14
- package/dist/v2/auto-search-worker.js +5 -5
- package/dist/v2/chunk-embedding-write-worker.js +1 -1
- package/dist/v2/{context-08pwkj6g.js → context-mk2h2ven.js} +65 -30
- package/dist/v2/{embedding-backfill-nhgp8znm.js → embedding-backfill-kyn5sv0f.js} +4 -4
- package/dist/{embedding-cache-zn4r1c31.js → v2/embedding-cache-fhdkn9nc.js} +3 -1
- package/dist/v2/embedding-worker.js +1 -1
- package/dist/v2/{message-index-bounded-p69v4wpy.js → message-index-bounded-j1sxtefe.js} +3 -3
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-qz9x79kn.js → project-embedding-registry-1jv2rxhb.js} +3 -3
- package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
- package/dist/v2/{read-session-chunk-qzw3vedr.js → read-session-chunk-p6z3kmdj.js} +2 -2
- package/dist/v2/{recomp-orchestrator-4mrvs5yc.js → recomp-orchestrator-5t2csd46.js} +12 -12
- package/dist/v2/{render-r2djh67k.js → render-jpj43axy.js} +6 -6
- package/dist/v2/{search-archive-4bq4ff8q.js → search-archive-wbhxp0p1.js} +5 -5
- package/dist/v2/{search-51qr14ed.js → search-w9m2fd5c.js} +11 -11
- package/dist/v2/{server-f49pxtwf.js → server-3gnpqjez.js} +35 -8
- package/dist/v2/{server-2ek9exbe.js → server-47ajg9xc.js} +4 -4
- package/dist/{index-qjwpqvnf.js → v2/server-6xg55350.js} +18 -13
- package/dist/v2/{server-nbdfv1wx.js → server-8f92sd2r.js} +1 -1
- package/dist/v2/{server-zzwje0mz.js → server-8m5wk6aq.js} +3 -3
- package/dist/v2/{server-606mnrv4.js → server-9ms9b75c.js} +5 -1
- package/dist/v2/{server-d2a639dg.js → server-af51b1zg.js} +8 -8
- package/dist/v2/{server-s3m2y97h.js → server-b01a7dhj.js} +1 -1
- package/dist/v2/{server-b25nvm9c.js → server-ga6y57vh.js} +1 -1
- package/dist/v2/{server-pqgnjf38.js → server-gkb0y83n.js} +32 -5
- package/dist/v2/{server-c1vcbszm.js → server-qdpd8h27.js} +1 -1
- package/dist/v2/{server-9emdjcb5.js → server-srpghrje.js} +1 -1
- package/dist/v2/{server-p2wxmjc3.js → server-t45hgcsg.js} +2 -2
- package/dist/v2/{server-7wpw3wc6.js → server-wmpgvvc4.js} +12 -9
- package/dist/v2/{server-awth2wsg.js → server-x22jtpna.js} +1 -1
- package/dist/v2/{server-b25kh28g.js → server-xpy46ddq.js} +3 -3
- package/dist/v2/{server-bhr92yb4.js → server-zsbc0n4v.js} +2 -2
- package/dist/v2/server.js +2 -2
- package/dist/v2/{storage-memory-hhrvfw0x.js → storage-memory-24hsvzy8.js} +2 -2
- package/dist/v2/{storage-tags-4t9fb4ch.js → storage-tags-s7nvvyg8.js} +1 -1
- package/dist/v2/{v2-archive-reader-avcf7a5n.js → v2-archive-reader-5njmg3a3.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-zwpjqymz.js → wrapup-orchestrator-ykgx8hw8.js} +12 -12
- package/dist/{v2-archive-reader-cnhvhggz.js → v2-archive-reader-y38khjax.js} +1 -1
- package/dist/{wrapup-orchestrator-g1gnymt3.js → wrapup-orchestrator-a9tshrp4.js} +14 -14
- package/package.json +1 -1
|
@@ -53,6 +53,8 @@ function loadAllEmbeddings(db, projectPath, modelId) {
|
|
|
53
53
|
}
|
|
54
54
|
return embeddings;
|
|
55
55
|
}
|
|
56
|
+
var EMBEDDABLE_MEMORIES_FOR_PROJECT = `FROM memories m
|
|
57
|
+
WHERE m.project_path = ? AND m.status IN ('active', 'permanent')`;
|
|
56
58
|
function getMemoryEmbedCoverage(db, projectPath, modelId) {
|
|
57
59
|
const row = db.prepare(`SELECT
|
|
58
60
|
COUNT(*) AS total,
|
|
@@ -60,8 +62,7 @@ function getMemoryEmbedCoverage(db, projectPath, modelId) {
|
|
|
60
62
|
SELECT 1 FROM memory_embeddings e
|
|
61
63
|
WHERE e.memory_id = m.id AND e.model_id = ?
|
|
62
64
|
) THEN 1 ELSE 0 END) AS embedded
|
|
63
|
-
|
|
64
|
-
WHERE m.project_path = ? AND m.status = 'active'`).get(modelId, projectPath);
|
|
65
|
+
${EMBEDDABLE_MEMORIES_FOR_PROJECT}`).get(modelId, projectPath);
|
|
65
66
|
return {
|
|
66
67
|
total: typeof row?.total === "number" ? row.total : 0,
|
|
67
68
|
embedded: typeof row?.embedded === "number" ? row.embedded : 0
|
|
@@ -110,16 +111,15 @@ function maintainKeptWorkerMemoryEmbeddings2(db) {
|
|
|
110
111
|
function cacheKey(projectPath, modelId) {
|
|
111
112
|
return `${projectPath}\x00${modelId}`;
|
|
112
113
|
}
|
|
113
|
-
function
|
|
114
|
-
const entry
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
if (entry.expiresAt <= Date.now()) {
|
|
119
|
-
projectEmbeddingCache.delete(cacheKey(projectPath, modelId));
|
|
120
|
-
return null;
|
|
114
|
+
function pruneExpiredProjectEmbeddings(now) {
|
|
115
|
+
for (const [key, entry] of projectEmbeddingCache) {
|
|
116
|
+
if (entry.expiresAt <= now)
|
|
117
|
+
projectEmbeddingCache.delete(key);
|
|
121
118
|
}
|
|
122
|
-
|
|
119
|
+
}
|
|
120
|
+
function getValidCacheEntry(projectPath, modelId) {
|
|
121
|
+
pruneExpiredProjectEmbeddings(Date.now());
|
|
122
|
+
return projectEmbeddingCache.get(cacheKey(projectPath, modelId)) ?? null;
|
|
123
123
|
}
|
|
124
124
|
function getProjectEmbeddings2(db, projectPath, modelId) {
|
|
125
125
|
const kept = keptWorkerCaches.get(db);
|
|
@@ -139,9 +139,11 @@ function getProjectEmbeddings2(db, projectPath, modelId) {
|
|
|
139
139
|
return cached.embeddings;
|
|
140
140
|
}
|
|
141
141
|
const embeddings = loadAllEmbeddings(db, projectPath, modelId);
|
|
142
|
+
const now = Date.now();
|
|
143
|
+
pruneExpiredProjectEmbeddings(now);
|
|
142
144
|
projectEmbeddingCache.set(cacheKey(projectPath, modelId), {
|
|
143
145
|
embeddings,
|
|
144
|
-
expiresAt:
|
|
146
|
+
expiresAt: now + embeddingCacheTtlMs
|
|
145
147
|
});
|
|
146
148
|
return embeddings;
|
|
147
149
|
}
|
|
@@ -171,8 +173,11 @@ function resetEmbeddingCacheForTests2() {
|
|
|
171
173
|
projectEmbeddingCache.clear();
|
|
172
174
|
embeddingCacheTtlMs = DEFAULT_EMBEDDING_CACHE_TTL_MS;
|
|
173
175
|
}
|
|
176
|
+
function getEmbeddingCacheSizeForTests2() {
|
|
177
|
+
return projectEmbeddingCache.size;
|
|
178
|
+
}
|
|
174
179
|
function setEmbeddingCacheTtlForTests2(ttlMs) {
|
|
175
180
|
embeddingCacheTtlMs = Math.max(0, Math.floor(ttlMs));
|
|
176
181
|
}
|
|
177
182
|
|
|
178
|
-
export { saveEmbeddingIfHashMatches, getMemoryEmbedCoverage, keepWorkerMemoryEmbeddings2, maintainKeptWorkerMemoryEmbeddings2, getProjectEmbeddings2, peekProjectEmbeddings2, invalidateProject2, invalidateMemory2, resetEmbeddingCacheForTests2, setEmbeddingCacheTtlForTests2 };
|
|
183
|
+
export { saveEmbeddingIfHashMatches, EMBEDDABLE_MEMORIES_FOR_PROJECT, getMemoryEmbedCoverage, keepWorkerMemoryEmbeddings2, maintainKeptWorkerMemoryEmbeddings2, getProjectEmbeddings2, peekProjectEmbeddings2, invalidateProject2, invalidateMemory2, resetEmbeddingCacheForTests2, getEmbeddingCacheSizeForTests2, setEmbeddingCacheTtlForTests2 };
|
|
@@ -139,9 +139,9 @@ async function serveV2ArchiveReads2(port, openConnections) {
|
|
|
139
139
|
import("./sqlite-zdgm52sv.js"),
|
|
140
140
|
import("./store-reader-w7w8vfsy.js"),
|
|
141
141
|
import("./store-mba47sxn.js"),
|
|
142
|
-
import("./read-session-chunk-
|
|
143
|
-
import("./render-
|
|
144
|
-
import("./search-archive-
|
|
142
|
+
import("./read-session-chunk-p6z3kmdj.js"),
|
|
143
|
+
import("./render-jpj43axy.js"),
|
|
144
|
+
import("./search-archive-wbhxp0p1.js"),
|
|
145
145
|
import("./expand-attachments-h33jbgyz.js")
|
|
146
146
|
]);
|
|
147
147
|
const pool = new V2StoreReaderPool;
|
|
@@ -5335,9 +5335,13 @@ function isFable51ThinkingBindingModel(providerID, modelID) {
|
|
|
5335
5335
|
return false;
|
|
5336
5336
|
return /(?:^|[-_.])fable[-_.]?5[-_.]1(?:$|[-_.])/i.test(modelID);
|
|
5337
5337
|
}
|
|
5338
|
+
var PATH_LIKE_ERROR_RUN = /^(?:(?![a-z][a-z\d+.-]*:\/\/)[a-z\d_.-]+[=:])?(?:[.~]?\\?\/|\.\.\/|\\\\|[a-z]:[\\/]|[a-z][a-z\d+.-]*:\/\/.)/i;
|
|
5339
|
+
function has413OverflowWord(message) {
|
|
5340
|
+
return message.split(/[\s"'`,;()[\]{}<>]+/).some((run) => !PATH_LIKE_ERROR_RUN.test(run) && /(entity|payload|context|prompt)/i.test(run));
|
|
5341
|
+
}
|
|
5338
5342
|
function detectOverflow(error) {
|
|
5339
5343
|
const message = extractErrorMessage(error);
|
|
5340
|
-
const hasStatus413 = /\b413\b/.test(message) &&
|
|
5344
|
+
const hasStatus413 = /\b413\b/.test(message) && has413OverflowWord(message);
|
|
5341
5345
|
const matched = OVERFLOW_PATTERNS.find((pattern) => pattern.test(message));
|
|
5342
5346
|
if (!matched && !hasStatus413 && !hasColdRequestCode(error)) {
|
|
5343
5347
|
return unitlessLiteLLMOverflow(error, message) ?? { isOverflow: false };
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./server-jrs4gny6.js";
|
|
16
16
|
import {
|
|
17
17
|
isRecord
|
|
18
|
-
} from "./server-
|
|
18
|
+
} from "./server-9ms9b75c.js";
|
|
19
19
|
import {
|
|
20
20
|
cleanSearchText,
|
|
21
21
|
hintKeywordRelevance,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
isMessageIndexReconciledThrough,
|
|
26
26
|
clearIndexedMessages,
|
|
27
27
|
indexMessagesAfterOrdinal
|
|
28
|
-
} from "./server-
|
|
28
|
+
} from "./server-qdpd8h27.js";
|
|
29
29
|
import {
|
|
30
30
|
Priority,
|
|
31
31
|
AdmissionClass,
|
|
@@ -57,13 +57,13 @@ import {
|
|
|
57
57
|
enqueueShadowEmbeddingItems2,
|
|
58
58
|
getProjectEmbeddingSnapshot2,
|
|
59
59
|
embedItemsForProject2
|
|
60
|
-
} from "./server-
|
|
60
|
+
} from "./server-wmpgvvc4.js";
|
|
61
61
|
import {
|
|
62
62
|
recordEmbeddingMeasurement
|
|
63
63
|
} from "./server-2amn2s73.js";
|
|
64
64
|
import {
|
|
65
65
|
getProjectEmbeddings2
|
|
66
|
-
} from "./server-
|
|
66
|
+
} from "./server-6xg55350.js";
|
|
67
67
|
import {
|
|
68
68
|
USER_FACING_FAILURES,
|
|
69
69
|
cosineSimilarity,
|
|
@@ -73,21 +73,21 @@ import {
|
|
|
73
73
|
sanitizeFtsQuery,
|
|
74
74
|
searchMemoriesFTS,
|
|
75
75
|
searchMemoriesFTSUnion
|
|
76
|
-
} from "./server-
|
|
76
|
+
} from "./server-47ajg9xc.js";
|
|
77
77
|
import {
|
|
78
78
|
ModuleMemoryAuthorityError2,
|
|
79
79
|
getMemoriesByProject2,
|
|
80
80
|
getMemoriesByProjects2,
|
|
81
81
|
updateMemoryRetrievalCount2
|
|
82
|
-
} from "./server-
|
|
82
|
+
} from "./server-srpghrje.js";
|
|
83
83
|
import {
|
|
84
84
|
ensureMemoryEmbeddings2
|
|
85
|
-
} from "./server-
|
|
85
|
+
} from "./server-zsbc0n4v.js";
|
|
86
86
|
import {
|
|
87
87
|
MESSAGE_FTS_SESSION_FILTER_SQL,
|
|
88
88
|
withMessageFtsSessionFilter,
|
|
89
89
|
messageTextVisibleInRequestSql
|
|
90
|
-
} from "./server-
|
|
90
|
+
} from "./server-b01a7dhj.js";
|
|
91
91
|
import {
|
|
92
92
|
resolveWorkspaceShareCategories,
|
|
93
93
|
resolveWorkspaceIdentitySet,
|
|
@@ -1084,7 +1084,7 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
|
|
|
1084
1084
|
state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
|
|
1085
1085
|
if (signal.aborted || !readsOpenCodeStore)
|
|
1086
1086
|
return;
|
|
1087
|
-
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-
|
|
1087
|
+
const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-p6z3kmdj.js"));
|
|
1088
1088
|
const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-5p4vwd79.js"));
|
|
1089
1089
|
if (signal.aborted)
|
|
1090
1090
|
return;
|
|
@@ -684,14 +684,20 @@ function isEmbeddingWorkerStopNotice(message) {
|
|
|
684
684
|
function serveEmbeddingWorker(port, model, options) {
|
|
685
685
|
const now = options.now ?? (() => performance.now());
|
|
686
686
|
let queue = Promise.resolve();
|
|
687
|
+
const requests = new Map;
|
|
687
688
|
let stopping = false;
|
|
688
689
|
let busySince = null;
|
|
689
690
|
const refuse = (id) => port.postMessage({ id, loaded: false, error: EMBEDDING_WORKER_STOPPING_ERROR });
|
|
691
|
+
const acknowledgeCancel = (id) => port.postMessage({ id, loaded: false });
|
|
690
692
|
const handle = async (request) => {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
busySince = now();
|
|
693
|
+
const { id } = request;
|
|
694
|
+
const cancelled = () => requests.get(id) === true;
|
|
694
695
|
try {
|
|
696
|
+
if (stopping)
|
|
697
|
+
return refuse(id);
|
|
698
|
+
if (cancelled())
|
|
699
|
+
return acknowledgeCancel(id);
|
|
700
|
+
busySince = now();
|
|
695
701
|
const loaded = await model.initialize();
|
|
696
702
|
let vectors;
|
|
697
703
|
if (loaded && request.texts) {
|
|
@@ -701,19 +707,26 @@ function serveEmbeddingWorker(port, model, options) {
|
|
|
701
707
|
await new Promise((resolve) => setImmediate(resolve));
|
|
702
708
|
if (stopping)
|
|
703
709
|
throw new Error(EMBEDDING_WORKER_STOPPING_ERROR);
|
|
710
|
+
if (cancelled())
|
|
711
|
+
return acknowledgeCancel(id);
|
|
704
712
|
vectors.push(...await model.embedBatch(request.texts.slice(offset, offset + options.batchSize)));
|
|
705
713
|
}
|
|
706
714
|
}
|
|
715
|
+
if (cancelled())
|
|
716
|
+
return acknowledgeCancel(id);
|
|
707
717
|
port.postMessage({
|
|
708
|
-
id
|
|
718
|
+
id,
|
|
709
719
|
loaded,
|
|
710
720
|
vectors,
|
|
711
721
|
failure: model.getLastFailureReason(),
|
|
712
722
|
stats: options.stats?.()
|
|
713
723
|
}, vectors?.flatMap((vector) => vector ? [vector.buffer] : []) ?? []);
|
|
714
724
|
} catch (error) {
|
|
715
|
-
|
|
725
|
+
if (cancelled())
|
|
726
|
+
return acknowledgeCancel(id);
|
|
727
|
+
port.postMessage({ id, loaded: false, error: String(error) });
|
|
716
728
|
} finally {
|
|
729
|
+
requests.delete(id);
|
|
717
730
|
busySince = null;
|
|
718
731
|
}
|
|
719
732
|
};
|
|
@@ -743,9 +756,16 @@ function serveEmbeddingWorker(port, model, options) {
|
|
|
743
756
|
stop();
|
|
744
757
|
return;
|
|
745
758
|
}
|
|
759
|
+
const cancel = message?.cancel;
|
|
760
|
+
if (typeof cancel === "number") {
|
|
761
|
+
if (requests.has(cancel))
|
|
762
|
+
requests.set(cancel, true);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
746
765
|
const request = message;
|
|
747
766
|
if (stopping)
|
|
748
767
|
return refuse(request.id);
|
|
768
|
+
requests.set(request.id, false);
|
|
749
769
|
queue = queue.then(() => handle(request));
|
|
750
770
|
});
|
|
751
771
|
}
|
|
@@ -1014,6 +1034,13 @@ class EmbeddingWorkerClient {
|
|
|
1014
1034
|
this.pending.delete(id);
|
|
1015
1035
|
signal?.removeEventListener("abort", abort);
|
|
1016
1036
|
reject(new EmbeddingRequestAbortedError);
|
|
1037
|
+
const request = { cancel: id };
|
|
1038
|
+
try {
|
|
1039
|
+
if (worker instanceof Worker)
|
|
1040
|
+
worker.postMessage(request);
|
|
1041
|
+
else if (worker.connected)
|
|
1042
|
+
worker.send(request, () => {});
|
|
1043
|
+
} catch {}
|
|
1017
1044
|
if (this.pending.size === 0) {
|
|
1018
1045
|
worker.unref();
|
|
1019
1046
|
if (!(worker instanceof Worker))
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
} from "./server-d46xewmt.js";
|
|
4
4
|
import {
|
|
5
5
|
getTagById2
|
|
6
|
-
} from "./server-
|
|
6
|
+
} from "./server-9ms9b75c.js";
|
|
7
7
|
import {
|
|
8
8
|
expandToolPart,
|
|
9
9
|
visitRawSessionMessages2,
|
|
10
10
|
readRawSessionMessageById2
|
|
11
|
-
} from "./server-
|
|
11
|
+
} from "./server-x22jtpna.js";
|
|
12
12
|
|
|
13
13
|
// src/tools/ctx-expand/render.ts
|
|
14
14
|
import { createHash } from "node:crypto";
|
|
@@ -69,9 +69,10 @@ import {
|
|
|
69
69
|
} from "./server-7c5p0bh1.js";
|
|
70
70
|
import {
|
|
71
71
|
saveEmbeddingIfHashMatches,
|
|
72
|
+
EMBEDDABLE_MEMORIES_FOR_PROJECT,
|
|
72
73
|
getMemoryEmbedCoverage,
|
|
73
74
|
invalidateProject2
|
|
74
|
-
} from "./server-
|
|
75
|
+
} from "./server-6xg55350.js";
|
|
75
76
|
import {
|
|
76
77
|
dominantEmbeddingFailure,
|
|
77
78
|
embeddingModelsMatch,
|
|
@@ -81,7 +82,7 @@ import {
|
|
|
81
82
|
logLocalEmbeddingPoolingUnavailableOnce,
|
|
82
83
|
getEmbeddingProviderIdentity,
|
|
83
84
|
LocalEmbeddingProvider
|
|
84
|
-
} from "./server-
|
|
85
|
+
} from "./server-gkb0y83n.js";
|
|
85
86
|
import {
|
|
86
87
|
isKnownAutocommit
|
|
87
88
|
} from "./server-8ajstryz.js";
|
|
@@ -2627,8 +2628,7 @@ function isUnembeddedMemoryRow(row) {
|
|
|
2627
2628
|
const candidate = row;
|
|
2628
2629
|
return typeof candidate.id === "number" && typeof candidate.content === "string" && typeof candidate.normalized_hash === "string";
|
|
2629
2630
|
}
|
|
2630
|
-
var UNEMBEDDED_MEMORIES_FOR_PROJECT =
|
|
2631
|
-
WHERE m.project_path = ? AND m.status IN ('active', 'permanent')
|
|
2631
|
+
var UNEMBEDDED_MEMORIES_FOR_PROJECT = `${EMBEDDABLE_MEMORIES_FOR_PROJECT}
|
|
2632
2632
|
AND NOT EXISTS (
|
|
2633
2633
|
SELECT 1 FROM memory_embeddings me WHERE me.memory_id = m.id AND me.model_id = ?
|
|
2634
2634
|
)`;
|
|
@@ -2653,14 +2653,16 @@ async function embedUnembeddedMemoriesForProject2(db, projectIdentity, batchSize
|
|
|
2653
2653
|
}
|
|
2654
2654
|
async function embedUnembeddedMemoriesForProjectOutcome2(db, projectIdentity, batchSize = 10) {
|
|
2655
2655
|
if (isEmbeddingHostBusy2())
|
|
2656
|
-
return { kind: "unavailable" };
|
|
2656
|
+
return { kind: "unavailable", reason: "busy" };
|
|
2657
2657
|
const snapshot = getProjectEmbeddingSnapshot2(projectIdentity);
|
|
2658
2658
|
if (!snapshot?.enabled)
|
|
2659
2659
|
return { kind: "disabled" };
|
|
2660
2660
|
const normalizedBatchSize = Math.max(1, Math.floor(batchSize));
|
|
2661
|
-
const
|
|
2661
|
+
const rows = getLoadUnembeddedMemoriesStatement(db).all(projectIdentity, snapshot.modelId, normalizedBatchSize);
|
|
2662
|
+
const memories = rows.filter(isUnembeddedMemoryRow);
|
|
2662
2663
|
if (memories.length === 0)
|
|
2663
2664
|
return { kind: "done" };
|
|
2665
|
+
const backlog = rows.length < normalizedBatchSize ? { missingCount: rows.length } : {};
|
|
2664
2666
|
try {
|
|
2665
2667
|
const result = await embedItemsForProject2(projectIdentity, memories.map((memory) => ({
|
|
2666
2668
|
id: `memory:${memory.id}`,
|
|
@@ -2668,7 +2670,7 @@ async function embedUnembeddedMemoriesForProjectOutcome2(db, projectIdentity, ba
|
|
|
2668
2670
|
contentSha256: contentSha2562(memory.content)
|
|
2669
2671
|
})), undefined, db, projectIdentity);
|
|
2670
2672
|
if (!result)
|
|
2671
|
-
return { kind: "unavailable" };
|
|
2673
|
+
return { kind: "unavailable", reason: "provider", ...backlog };
|
|
2672
2674
|
let embeddedCount = 0;
|
|
2673
2675
|
db.transaction(() => {
|
|
2674
2676
|
for (const memory of memories) {
|
|
@@ -2681,9 +2683,10 @@ async function embedUnembeddedMemoriesForProjectOutcome2(db, projectIdentity, ba
|
|
|
2681
2683
|
}
|
|
2682
2684
|
}).immediate();
|
|
2683
2685
|
enqueueShadowEmbeddingItems2(projectIdentity, "memory", memories.filter((memory) => result.vectors.has(`memory:${memory.id}`)).map((memory) => String(memory.id)));
|
|
2684
|
-
return { kind: "embedded", count: embeddedCount };
|
|
2686
|
+
return { kind: "embedded", count: embeddedCount, ...embeddedCount === 0 ? backlog : {} };
|
|
2685
2687
|
} catch (error) {
|
|
2686
|
-
|
|
2688
|
+
const missing = backlog.missingCount === undefined ? "" : ` (${backlog.missingCount} missing at check)`;
|
|
2689
|
+
log2(`[magic-context] proactive memory embedding failed for project ${projectIdentity}${missing}:`, error);
|
|
2687
2690
|
return { kind: "failed", error };
|
|
2688
2691
|
}
|
|
2689
2692
|
}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
withMessageFtsSessionFilter,
|
|
3
3
|
liveTailRangeTouchesUnresolvedCoverage,
|
|
4
4
|
rangeHasHiddenMessages
|
|
5
|
-
} from "./server-
|
|
5
|
+
} from "./server-b01a7dhj.js";
|
|
6
6
|
import {
|
|
7
7
|
getSqliteDatabasePath2
|
|
8
8
|
} from "./server-gzy5w8ya.js";
|
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
rawMessageWorkerSource2,
|
|
22
22
|
rawMessageOffThreadRangeReader2,
|
|
23
23
|
readRawSessionMessageIdOrdinalsForRange2
|
|
24
|
-
} from "./server-
|
|
24
|
+
} from "./server-x22jtpna.js";
|
|
25
25
|
import {
|
|
26
26
|
readV2ArchiveOffThread2
|
|
27
|
-
} from "./server-
|
|
27
|
+
} from "./server-8m5wk6aq.js";
|
|
28
28
|
|
|
29
29
|
// src/tools/ctx-expand/search-archive.ts
|
|
30
30
|
var archiveReadsOnThisThread = 0;
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
readSearchBackfillCursor2,
|
|
11
11
|
writeSearchBackfillCursor2,
|
|
12
12
|
embedItemsWindowBounded2
|
|
13
|
-
} from "./server-
|
|
13
|
+
} from "./server-wmpgvvc4.js";
|
|
14
14
|
import {
|
|
15
15
|
saveEmbeddingIfHashMatches
|
|
16
|
-
} from "./server-
|
|
16
|
+
} from "./server-6xg55350.js";
|
|
17
17
|
|
|
18
18
|
// src/features/magic-context/memory/embedding-backfill.ts
|
|
19
19
|
var SEARCH_BACKFILL_LIMIT = 50;
|
package/dist/v2/server.js
CHANGED
|
@@ -7877,7 +7877,7 @@ var require_src2 = __commonJS(function(exports, module) {
|
|
|
7877
7877
|
// package.json
|
|
7878
7878
|
var package_default = {
|
|
7879
7879
|
name: "@cortexkit/opencode-magic-context",
|
|
7880
|
-
version: "0.49.
|
|
7880
|
+
version: "0.49.104",
|
|
7881
7881
|
type: "module",
|
|
7882
7882
|
description: "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
7883
7883
|
main: "dist/index.js",
|
|
@@ -8198,7 +8198,7 @@ async function setup(context) {
|
|
|
8198
8198
|
if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
|
|
8199
8199
|
log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
|
|
8200
8200
|
}
|
|
8201
|
-
const { registerContext } = await import("./context-
|
|
8201
|
+
const { registerContext } = await import("./context-mk2h2ven.js");
|
|
8202
8202
|
setHarness2("opencode2");
|
|
8203
8203
|
bindStaleBuildNotice({}, import.meta.url, "opencode2");
|
|
8204
8204
|
const duties = await registerContext(context);
|
|
@@ -31,8 +31,8 @@ import {
|
|
|
31
31
|
deleteMemory2,
|
|
32
32
|
getMemoryCount2,
|
|
33
33
|
getMemoryCountsByStatus2
|
|
34
|
-
} from "./server-
|
|
35
|
-
import"./server-
|
|
34
|
+
} from "./server-srpghrje.js";
|
|
35
|
+
import"./server-6xg55350.js";
|
|
36
36
|
import"./server-fr0wbhdn.js";
|
|
37
37
|
import"./server-gzy5w8ya.js";
|
|
38
38
|
export {
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getCompartments,
|
|
12
12
|
getLastCompartmentEndMessage,
|
|
13
13
|
requestPendingMaterialization
|
|
14
|
-
} from "./server-
|
|
14
|
+
} from "./server-8f92sd2r.js";
|
|
15
15
|
import"./server-2amn2s73.js";
|
|
16
16
|
import"./server-d46xewmt.js";
|
|
17
17
|
import"./server-b5eg9ct6.js";
|
|
@@ -24,7 +24,7 @@ import"./server-1d042x6w.js";
|
|
|
24
24
|
import"./server-54nc921b.js";
|
|
25
25
|
import"./server-98xd6j4r.js";
|
|
26
26
|
import"./server-ghk96d57.js";
|
|
27
|
-
import"./server-
|
|
27
|
+
import"./server-qdpd8h27.js";
|
|
28
28
|
import {
|
|
29
29
|
getWrapupInProgressState,
|
|
30
30
|
acquireWrapupInProgress,
|
|
@@ -32,16 +32,16 @@ import {
|
|
|
32
32
|
releaseWrapupInProgress,
|
|
33
33
|
getHistorianFailureState,
|
|
34
34
|
clearEmergencyRecovery
|
|
35
|
-
} from "./server-
|
|
35
|
+
} from "./server-9ms9b75c.js";
|
|
36
36
|
import"./server-bzebqckc.js";
|
|
37
|
-
import"./server-
|
|
37
|
+
import"./server-ga6y57vh.js";
|
|
38
38
|
import"./server-1zx87sdm.js";
|
|
39
39
|
import"./server-arfzfxe8.js";
|
|
40
40
|
import"./server-2ra6pwf3.js";
|
|
41
41
|
import"./server-vgy98kcd.js";
|
|
42
42
|
import {
|
|
43
43
|
prepareRawSessionOrdinals2
|
|
44
|
-
} from "./server-
|
|
44
|
+
} from "./server-x22jtpna.js";
|
|
45
45
|
import"./server-fr0wbhdn.js";
|
|
46
46
|
import"./server-3mb205v9.js";
|
|
47
47
|
import"./server-3qeqa3b6.js";
|
|
@@ -64,15 +64,15 @@ import {
|
|
|
64
64
|
registerActiveCompartmentRun,
|
|
65
65
|
setRecompStarting2,
|
|
66
66
|
setRecompTerminal2
|
|
67
|
-
} from "./server-
|
|
67
|
+
} from "./server-3gnpqjez.js";
|
|
68
68
|
import"./server-qt1qqasc.js";
|
|
69
|
-
import"./server-
|
|
69
|
+
import"./server-wmpgvvc4.js";
|
|
70
70
|
import"./server-7c5p0bh1.js";
|
|
71
|
-
import"./server-
|
|
72
|
-
import"./server-
|
|
73
|
-
import"./server-
|
|
74
|
-
import"./server-
|
|
75
|
-
import"./server-
|
|
71
|
+
import"./server-6xg55350.js";
|
|
72
|
+
import"./server-gkb0y83n.js";
|
|
73
|
+
import"./server-47ajg9xc.js";
|
|
74
|
+
import"./server-zsbc0n4v.js";
|
|
75
|
+
import"./server-srpghrje.js";
|
|
76
76
|
import"./server-0b3ms151.js";
|
|
77
77
|
import"./server-d4h86y7v.js";
|
|
78
78
|
import"./server-n5wn7d9b.js";
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runManagedWrapup2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
3
|
+
} from "./index-8gzmeyae.js";
|
|
4
|
+
import"./index-a9wn0d9h.js";
|
|
5
|
+
import"./index-sqvkh5d0.js";
|
|
6
6
|
import"./index-qxzk5s30.js";
|
|
7
7
|
import"./index-sd3egckz.js";
|
|
8
|
-
import"./index-
|
|
9
|
-
import"./index-
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
8
|
+
import"./index-8yj4vd7k.js";
|
|
9
|
+
import"./index-8eke8yh2.js";
|
|
10
|
+
import"./index-srpghrje.js";
|
|
11
|
+
import"./index-4ba3zp54.js";
|
|
12
|
+
import"./index-6xg55350.js";
|
|
13
|
+
import"./index-4536jdzj.js";
|
|
14
14
|
import"./index-ab86c21b.js";
|
|
15
|
-
import"./index-
|
|
15
|
+
import"./index-p8nc9axh.js";
|
|
16
16
|
import"./index-2amn2s73.js";
|
|
17
17
|
import"./index-ke0mkz7g.js";
|
|
18
18
|
import"./index-h1qh9n8b.js";
|
|
19
19
|
import"./index-fqth7850.js";
|
|
20
20
|
import"./index-61a853ky.js";
|
|
21
21
|
import"./index-qt1qqasc.js";
|
|
22
|
-
import"./index-
|
|
23
|
-
import"./index-
|
|
22
|
+
import"./index-9jqaha1g.js";
|
|
23
|
+
import"./index-qzfz2tvk.js";
|
|
24
24
|
import"./index-1zx87sdm.js";
|
|
25
25
|
import"./index-vdzd98ry.js";
|
|
26
26
|
import"./index-y14pawe1.js";
|
|
27
27
|
import"./index-y5f5yg5a.js";
|
|
28
|
-
import"./index-
|
|
28
|
+
import"./index-p5ey52j9.js";
|
|
29
29
|
import"./index-r3f85n7y.js";
|
|
30
30
|
import"./index-fd3hkyk1.js";
|
|
31
31
|
import"./index-1vv1ka4a.js";
|
|
32
32
|
import"./index-gcf2x04k.js";
|
|
33
|
-
import"./index-
|
|
33
|
+
import"./index-f455a0g3.js";
|
|
34
34
|
import"./index-fb3zxn06.js";
|
|
35
35
|
import"./index-hyvxmz3e.js";
|
|
36
36
|
import"./index-fr0wbhdn.js";
|
package/package.json
CHANGED