@cortexkit/magic-context 0.40.0 → 0.40.1
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/index.js +103 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39218,8 +39218,6 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
|
|
|
39218
39218
|
updated_at INTEGER NOT NULL,
|
|
39219
39219
|
harness TEXT NOT NULL DEFAULT 'opencode'
|
|
39220
39220
|
);
|
|
39221
|
-
CREATE INDEX IF NOT EXISTS idx_message_history_index_orphan_sweep
|
|
39222
|
-
ON message_history_index(harness, session_id, updated_at);
|
|
39223
39221
|
|
|
39224
39222
|
CREATE TABLE IF NOT EXISTS message_history_source (
|
|
39225
39223
|
session_id TEXT NOT NULL,
|
|
@@ -39806,6 +39804,10 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
|
|
|
39806
39804
|
ensureColumn(db, "recomp_compartments", "harness", "TEXT NOT NULL DEFAULT 'opencode'");
|
|
39807
39805
|
ensureColumn(db, "recomp_facts", "harness", "TEXT NOT NULL DEFAULT 'opencode'");
|
|
39808
39806
|
ensureColumn(db, "message_history_index", "harness", "TEXT NOT NULL DEFAULT 'opencode'");
|
|
39807
|
+
db.exec(`
|
|
39808
|
+
CREATE INDEX IF NOT EXISTS idx_message_history_index_orphan_sweep
|
|
39809
|
+
ON message_history_index(harness, session_id, updated_at);
|
|
39810
|
+
`);
|
|
39809
39811
|
ensureColumn(db, "workspaces", "share_categories", `TEXT NOT NULL DEFAULT '["CONSTRAINTS"]'`);
|
|
39810
39812
|
}
|
|
39811
39813
|
var databases, pendingAsyncOpens, persistenceByDatabase, persistenceErrorByDatabase, pathByDatabase, LATEST_SUPPORTED_VERSION = 81, PERMISSIONS_ENFORCEABLE, RPC_DISCOVERY_PARSE_GRACE_MS, defaultRpcDiscoveryFs, rpcDiscoveryFs, sqlitePragmaConfig, CHANNEL2_CLAIM_TTL_MS;
|
|
@@ -44265,12 +44267,23 @@ function probeOnnxRuntimeNodeLoad(packageDir) {
|
|
|
44265
44267
|
reason: `probe returned no JSON verdict${stdoutSuffix(result)}${stderrSuffix(result)}`
|
|
44266
44268
|
};
|
|
44267
44269
|
}
|
|
44268
|
-
function
|
|
44270
|
+
function isNativeLocalEmbeddingRuntimeFailure(status) {
|
|
44269
44271
|
return status.state === "package-missing" || status.state === "binary-missing" || status.state === "load-failed";
|
|
44270
44272
|
}
|
|
44273
|
+
function describeNativeFailure(status) {
|
|
44274
|
+
return status.state === "package-missing" ? "package is not installed" : status.state === "binary-missing" ? "expected platform binding file is absent" : `binding failed to load: ${status.reason}`;
|
|
44275
|
+
}
|
|
44276
|
+
function isLocalEmbeddingRuntimeBroken(status) {
|
|
44277
|
+
return status.state === "both-broken" || isNativeLocalEmbeddingRuntimeFailure(status);
|
|
44278
|
+
}
|
|
44271
44279
|
function formatLocalEmbeddingRuntimeDoctorWarning(status) {
|
|
44272
|
-
|
|
44273
|
-
|
|
44280
|
+
if (status.state !== "both-broken") {
|
|
44281
|
+
return "Embedding provider: local — onnxruntime-node native binding missing — " + `${describeNativeFailure(status)}; its postinstall likely failed. Embeddings will not work. ` + "Reinstall with network access to the npm registry and GitHub releases, " + "or switch `embedding.provider` to an HTTP endpoint (`openai-compatible`).";
|
|
44282
|
+
}
|
|
44283
|
+
return "Embedding provider: local — native runtime and WASM fallback both unavailable — " + `native: ${describeNativeFailure(status.nativeFailure)}; WASM: ${status.wasmReason}; ` + "their install or postinstall likely failed. Reinstall with network access to the npm registry and GitHub releases, " + "or switch `embedding.provider` to an HTTP endpoint (`openai-compatible`).";
|
|
44284
|
+
}
|
|
44285
|
+
function formatLocalEmbeddingRuntimeWasmFallback(status) {
|
|
44286
|
+
return "Embedding provider: local — onnxruntime-node native binding failed " + `(${describeNativeFailure(status.nativeFailure)}); using onnxruntime-web (WASM) at ${status.wasmPath}. ` + "WASM inference is slower than native; a remote `openai-compatible` provider may be faster.";
|
|
44274
44287
|
}
|
|
44275
44288
|
function expectedBinaryRelPath(platform, arch) {
|
|
44276
44289
|
const supportedPlatform = platform === "linux" || platform === "darwin" || platform === "win32";
|
|
@@ -44279,20 +44292,52 @@ function expectedBinaryRelPath(platform, arch) {
|
|
|
44279
44292
|
return null;
|
|
44280
44293
|
return join24("bin", "napi-v6", platform, arch, "onnxruntime_binding.node");
|
|
44281
44294
|
}
|
|
44295
|
+
function probeWasmRuntimeFromRequire(requireFn) {
|
|
44296
|
+
try {
|
|
44297
|
+
const resolved = requireFn.resolve("onnxruntime-web");
|
|
44298
|
+
const packageDir = packageDirFromResolved(resolved, "onnxruntime-web");
|
|
44299
|
+
const loadFailure = probeOnnxRuntimeNodeLoad(packageDir);
|
|
44300
|
+
if (loadFailure === null)
|
|
44301
|
+
return { state: "ok", wasmPath: packageDir };
|
|
44302
|
+
return { state: "failed", reason: loadFailure.reason };
|
|
44303
|
+
} catch (error51) {
|
|
44304
|
+
return {
|
|
44305
|
+
state: "failed",
|
|
44306
|
+
reason: `onnxruntime-web is not resolvable: ${describeError(error51)}`
|
|
44307
|
+
};
|
|
44308
|
+
}
|
|
44309
|
+
}
|
|
44310
|
+
function withWasmFallback(native, probeWasm) {
|
|
44311
|
+
if (!isNativeLocalEmbeddingRuntimeFailure(native))
|
|
44312
|
+
return native;
|
|
44313
|
+
const wasm = probeWasm();
|
|
44314
|
+
if (wasm.state === "ok") {
|
|
44315
|
+
return { state: "wasm-fallback", nativeFailure: native, wasmPath: wasm.wasmPath };
|
|
44316
|
+
}
|
|
44317
|
+
return { state: "both-broken", nativeFailure: native, wasmReason: wasm.reason };
|
|
44318
|
+
}
|
|
44319
|
+
function probeWasmRuntimeAt(installRoot) {
|
|
44320
|
+
const requireFn = createRequire4(join24(installRoot, "package.json"));
|
|
44321
|
+
return probeWasmRuntimeFromRequire(requireFn);
|
|
44322
|
+
}
|
|
44282
44323
|
function checkLocalEmbeddingRuntimeAt(installRoot, platform = process.platform, arch = process.arch) {
|
|
44283
44324
|
const packageDir = join24(installRoot, "node_modules", "onnxruntime-node");
|
|
44325
|
+
let native;
|
|
44284
44326
|
if (!existsSync28(join24(packageDir, "package.json"))) {
|
|
44285
|
-
|
|
44286
|
-
}
|
|
44287
|
-
|
|
44288
|
-
|
|
44289
|
-
|
|
44290
|
-
|
|
44291
|
-
|
|
44292
|
-
|
|
44293
|
-
|
|
44327
|
+
native = { state: "package-missing", packageDir };
|
|
44328
|
+
} else {
|
|
44329
|
+
const rel = expectedBinaryRelPath(platform, arch);
|
|
44330
|
+
if (rel === null) {
|
|
44331
|
+
native = probeOnnxRuntimeNodeLoad(packageDir) ?? {
|
|
44332
|
+
state: "ok",
|
|
44333
|
+
binaryPath: packageDir
|
|
44334
|
+
};
|
|
44335
|
+
} else {
|
|
44336
|
+
const binaryPath = join24(packageDir, rel);
|
|
44337
|
+
native = existsSync28(binaryPath) ? probeOnnxRuntimeNodeLoad(packageDir) ?? { state: "ok", binaryPath } : { state: "binary-missing", packageDir, expectedBinary: binaryPath };
|
|
44338
|
+
}
|
|
44294
44339
|
}
|
|
44295
|
-
return
|
|
44340
|
+
return withWasmFallback(native, () => probeWasmRuntimeAt(installRoot));
|
|
44296
44341
|
}
|
|
44297
44342
|
function checkLocalEmbeddingRuntime(installRoots, platform = process.platform, arch = process.arch) {
|
|
44298
44343
|
const existing = installRoots.filter((root) => existsSync28(root));
|
|
@@ -44302,21 +44347,44 @@ function checkLocalEmbeddingRuntime(installRoots, platform = process.platform, a
|
|
|
44302
44347
|
reason: "no installed plugin tree found to inspect"
|
|
44303
44348
|
};
|
|
44304
44349
|
}
|
|
44350
|
+
let firstFallback = null;
|
|
44305
44351
|
let firstFailure = null;
|
|
44306
44352
|
for (const root of existing) {
|
|
44307
44353
|
const status = checkLocalEmbeddingRuntimeAt(root, platform, arch);
|
|
44308
44354
|
if (status.state === "ok")
|
|
44309
44355
|
return status;
|
|
44356
|
+
if (status.state === "wasm-fallback") {
|
|
44357
|
+
if (firstFallback === null)
|
|
44358
|
+
firstFallback = status;
|
|
44359
|
+
continue;
|
|
44360
|
+
}
|
|
44310
44361
|
if (firstFailure === null)
|
|
44311
44362
|
firstFailure = status;
|
|
44312
44363
|
}
|
|
44313
|
-
return firstFailure ?? { state: "unknown", reason: "no candidate roots" };
|
|
44364
|
+
return firstFallback ?? firstFailure ?? { state: "unknown", reason: "no candidate roots" };
|
|
44314
44365
|
}
|
|
44315
44366
|
function packageDirFromResolved(resolvedPath, packageName) {
|
|
44316
44367
|
const marker = `node_modules${sep}${packageName.split("/").join(sep)}`;
|
|
44317
44368
|
const idx = resolvedPath.indexOf(marker);
|
|
44318
44369
|
return idx >= 0 ? resolvedPath.slice(0, idx + marker.length) : dirname16(resolvedPath);
|
|
44319
44370
|
}
|
|
44371
|
+
function probeWasmRuntimeByResolution(pluginDir) {
|
|
44372
|
+
try {
|
|
44373
|
+
const reqPlugin = createRequire4(join24(pluginDir, "package.json"));
|
|
44374
|
+
const direct = probeWasmRuntimeFromRequire(reqPlugin);
|
|
44375
|
+
if (direct.state === "ok" || !direct.reason.startsWith("onnxruntime-web is not resolvable")) {
|
|
44376
|
+
return direct;
|
|
44377
|
+
}
|
|
44378
|
+
const tfResolved = reqPlugin.resolve("@huggingface/transformers");
|
|
44379
|
+
const tfDir = packageDirFromResolved(tfResolved, "@huggingface/transformers");
|
|
44380
|
+
return probeWasmRuntimeFromRequire(createRequire4(join24(tfDir, "package.json")));
|
|
44381
|
+
} catch (error51) {
|
|
44382
|
+
return {
|
|
44383
|
+
state: "failed",
|
|
44384
|
+
reason: `could not resolve onnxruntime-web (${describeError(error51)})`
|
|
44385
|
+
};
|
|
44386
|
+
}
|
|
44387
|
+
}
|
|
44320
44388
|
function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.platform, arch = process.arch) {
|
|
44321
44389
|
if (!existsSync28(join24(pluginDir, "package.json"))) {
|
|
44322
44390
|
return { state: "unknown", reason: "plugin package dir not found" };
|
|
@@ -44336,10 +44404,10 @@ function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.pl
|
|
|
44336
44404
|
} catch (error51) {
|
|
44337
44405
|
resolveError = error51?.code;
|
|
44338
44406
|
if (resolveError === "ERR_MODULE_NOT_FOUND" || resolveError === "MODULE_NOT_FOUND") {
|
|
44339
|
-
return {
|
|
44407
|
+
return withWasmFallback({
|
|
44340
44408
|
state: "package-missing",
|
|
44341
44409
|
packageDir: join24(pluginDir, "node_modules", "onnxruntime-node")
|
|
44342
|
-
};
|
|
44410
|
+
}, () => probeWasmRuntimeByResolution(pluginDir));
|
|
44343
44411
|
}
|
|
44344
44412
|
return {
|
|
44345
44413
|
state: "unknown",
|
|
@@ -44350,14 +44418,14 @@ function checkLocalEmbeddingRuntimeByResolution(pluginDir, platform = process.pl
|
|
|
44350
44418
|
return { state: "unknown", reason: "onnxruntime-node resolution produced no path" };
|
|
44351
44419
|
}
|
|
44352
44420
|
const rel = expectedBinaryRelPath(platform, arch);
|
|
44421
|
+
let native;
|
|
44353
44422
|
if (rel === null) {
|
|
44354
|
-
|
|
44355
|
-
}
|
|
44356
|
-
|
|
44357
|
-
|
|
44358
|
-
return { state: "binary-missing", packageDir: onnxDir, expectedBinary: binaryPath };
|
|
44423
|
+
native = probeOnnxRuntimeNodeLoad(onnxDir) ?? { state: "ok", binaryPath: onnxDir };
|
|
44424
|
+
} else {
|
|
44425
|
+
const binaryPath = join24(onnxDir, rel);
|
|
44426
|
+
native = existsSync28(binaryPath) ? probeOnnxRuntimeNodeLoad(onnxDir) ?? { state: "ok", binaryPath } : { state: "binary-missing", packageDir: onnxDir, expectedBinary: binaryPath };
|
|
44359
44427
|
}
|
|
44360
|
-
return
|
|
44428
|
+
return withWasmFallback(native, () => probeWasmRuntimeByResolution(pluginDir));
|
|
44361
44429
|
}
|
|
44362
44430
|
var ONNX_LOAD_PROBE_TIMEOUT_MS = 1e4, ONNX_LOAD_PROBE_OUTPUT_LIMIT = 800, ONNX_LOAD_PROBE_PACKAGE_DIR_ENV = "MAGIC_CONTEXT_ONNX_RUNTIME_NODE_PACKAGE_DIR", ONNX_RUNTIME_NODE_LOAD_PROBE_SCRIPT, runOnnxRuntimeNodeLoadProbeChildForRuntime;
|
|
44363
44431
|
var init_embedding_runtime = __esm(() => {
|
|
@@ -45557,6 +45625,10 @@ async function runIssueFlow2() {
|
|
|
45557
45625
|
}
|
|
45558
45626
|
function checkLocalEmbeddingRuntimeForDoctor() {
|
|
45559
45627
|
const runtime = checkLocalEmbeddingRuntime(getOpenCodePluginCacheRoots());
|
|
45628
|
+
if (runtime.state === "wasm-fallback") {
|
|
45629
|
+
log2.warn(formatLocalEmbeddingRuntimeWasmFallback(runtime));
|
|
45630
|
+
return { issues: 0 };
|
|
45631
|
+
}
|
|
45560
45632
|
if (isLocalEmbeddingRuntimeBroken(runtime)) {
|
|
45561
45633
|
log2.warn(formatLocalEmbeddingRuntimeDoctorWarning(runtime));
|
|
45562
45634
|
return { issues: 1, localRuntimeBroken: true };
|
|
@@ -45565,7 +45637,7 @@ function checkLocalEmbeddingRuntimeForDoctor() {
|
|
|
45565
45637
|
log2.warn(`Local embedding runtime unverified: ${runtime.reason}`);
|
|
45566
45638
|
return { issues: 0, unverified: true };
|
|
45567
45639
|
}
|
|
45568
|
-
log2.success("Embedding provider: local (Xenova/all-MiniLM-L6-v2 bundled)");
|
|
45640
|
+
log2.success("Embedding provider: local (native runtime OK; Xenova/all-MiniLM-L6-v2 bundled)");
|
|
45569
45641
|
return { issues: 0 };
|
|
45570
45642
|
}
|
|
45571
45643
|
async function checkEmbeddingConfig(magicContextConfigPath) {
|
|
@@ -47249,7 +47321,12 @@ ${formatDatabaseRepairGuidance(dbPath)}`);
|
|
|
47249
47321
|
for (const pluginDir of piPluginDirCandidates(packages, options.cwd)) {
|
|
47250
47322
|
const runtime = checkLocalEmbeddingRuntimeByResolution(pluginDir);
|
|
47251
47323
|
if (runtime.state === "ok") {
|
|
47252
|
-
add2(results, "pass", `Embedding provider: ${loadedConfig.config.embedding.provider} (native runtime
|
|
47324
|
+
add2(results, "pass", `Embedding provider: ${loadedConfig.config.embedding.provider} (native runtime OK)`);
|
|
47325
|
+
runtimeReported = true;
|
|
47326
|
+
break;
|
|
47327
|
+
}
|
|
47328
|
+
if (runtime.state === "wasm-fallback") {
|
|
47329
|
+
add2(results, "warn", formatLocalEmbeddingRuntimeWasmFallback(runtime));
|
|
47253
47330
|
runtimeReported = true;
|
|
47254
47331
|
break;
|
|
47255
47332
|
}
|