@cortexkit/opencode-magic-context 0.41.1 → 0.41.3
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 +9 -3
- package/dist/announcement-3c1vertn.js +14 -0
- package/dist/config/project-security.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +756 -4
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/conflict-warning-hook-z5sd697e.js +16 -0
- package/dist/derive-budgets-901a0pk0.js +11 -0
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts +4 -1
- package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-embedding.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-lease.d.ts +6 -0
- package/dist/features/magic-context/compartment-lease.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts +21 -0
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -0
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +1 -6
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-failure.d.ts +10 -2
- package/dist/features/magic-context/memory/embedding-failure.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-local.d.ts +7 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/onnxruntime-node-wasm-shim.d.ts +3 -0
- package/dist/features/magic-context/memory/onnxruntime-node-wasm-shim.d.ts.map +1 -0
- package/dist/features/magic-context/memory/sharp-wasm-shim.d.ts +2 -0
- package/dist/features/magic-context/memory/sharp-wasm-shim.d.ts.map +1 -0
- package/dist/features/magic-context/memory/transformers-node-wasm-entry.d.ts +3 -0
- package/dist/features/magic-context/memory/transformers-node-wasm-entry.d.ts.map +1 -0
- package/dist/features/magic-context/message-fts-rowid-map.d.ts +28 -0
- package/dist/features/magic-context/message-fts-rowid-map.d.ts.map +1 -0
- package/dist/features/magic-context/message-index.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +15 -2
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts +20 -2
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +30 -14
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts +3 -2
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +2 -2
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage-schema-helpers.d.ts.map +1 -1
- package/dist/features/magic-context/storage-session-tables.d.ts +9 -1
- package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
- package/dist/features/magic-context/storage-subagent-invocations.d.ts +3 -2
- package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +19 -0
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +2 -2
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/features/magic-context/subagent-token-capture.d.ts +2 -1
- package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +6 -1
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts +2 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts +4 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/format-embed-failure.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts +3 -0
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +4 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +6 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/live-session-state.d.ts +3 -1
- package/dist/hooks/magic-context/live-session-state.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts +2 -1
- package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-transport.d.ts +11 -4
- package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-wire.d.ts +6 -1
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-db.d.ts +15 -0
- package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts +19 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/send-session-notification.d.ts +6 -0
- package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
- package/dist/hooks/magic-context/sentinel.d.ts +18 -53
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts +12 -5
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-id-fallback.d.ts +3 -1
- package/dist/hooks/magic-context/tag-id-fallback.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +57 -2
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-z893kjyt.js → index-0bycg0np.js} +90 -26
- package/dist/{index-1yh8g550.js → index-22jkk6wg.js} +2 -15
- package/dist/{index-dmvy29z0.js → index-3wzdwt6p.js} +11 -15
- package/dist/{index-d1mxrd3p.js → index-7k55qm8a.js} +17 -12
- package/dist/{index-4x691bz5.js → index-dkv2dn46.js} +5 -2
- package/dist/{index-2d4kf2ve.js → index-dn1rwpd8.js} +16 -11
- package/dist/{index-rgdqj8nj.js → index-e7vx3byk.js} +1 -1
- package/dist/{index-szf8w1p5.js → index-fmsr7v69.js} +2 -2
- package/dist/{index-d62ypazr.js → index-jdxxq8cz.js} +6 -11
- package/dist/{index-9j3tx8hy.js → index-may8skc8.js} +6 -25
- package/dist/{index-eq9wr75c.js → index-npx8vhmy.js} +57 -108
- package/dist/{index-zwjhba2r.js → index-q264erdp.js} +122 -41
- package/dist/{index-b9j85d29.js → index-raatkvw5.js} +49 -11
- package/dist/{index-9xexf8s7.js → index-rn7gafjr.js} +1 -9
- package/dist/index-v6t0tg85.js +13 -0
- package/dist/{index-dh0vfghk.js → index-vmmjdpc0.js} +2594 -11271
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3414 -2620
- package/dist/model-resolution-dxatzjde.js +12 -0
- package/dist/{index-dynqfgx1.js → module-asyncify-2EFITU5U-rkqjhjxd.js} +69 -8
- package/dist/plugin/boot-deadline.d.ts +47 -0
- package/dist/plugin/boot-deadline.d.ts.map +1 -0
- package/dist/plugin/conflict-warning-hook.d.ts +10 -0
- package/dist/plugin/conflict-warning-hook.d.ts.map +1 -1
- package/dist/plugin/dream-timer.d.ts +4 -0
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +4 -2
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/prompt-context-5y5ms8f9.js +6 -0
- package/dist/recomp-orchestrator-f5m2wk74.js +19 -0
- package/dist/rpc-notifications-4amf6mf4.js +14 -0
- package/dist/{index-vnz6jvdc.js → safe-notification-target-q9z81zt3.js} +4 -3
- package/dist/send-session-notification-hdh02wy9.js +16 -0
- package/dist/shared/conflict-detector.d.ts +3 -1
- package/dist/shared/conflict-detector.d.ts.map +1 -1
- package/dist/shared/harness.d.ts +3 -3
- package/dist/shared/harness.d.ts.map +1 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/model-resolution.d.ts +3 -3
- package/dist/shared/model-resolution.d.ts.map +1 -1
- package/dist/shared/prompt-surface-runtime.d.ts +2 -2
- package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
- package/dist/shared/rpc-utils.d.ts +3 -1
- package/dist/shared/rpc-utils.d.ts.map +1 -1
- package/dist/shared/summarize-child-stderr.d.ts +2 -0
- package/dist/shared/summarize-child-stderr.d.ts.map +1 -0
- package/dist/shared/tag-transcript.d.ts.map +1 -1
- package/dist/shared/transcript.d.ts +2 -1
- package/dist/shared/transcript.d.ts.map +1 -1
- package/dist/shared/window-geometry.d.ts +2 -0
- package/dist/shared/window-geometry.d.ts.map +1 -1
- package/dist/storage-meta-session-3rxx9ekm.js +20 -0
- package/dist/task-config-hnv93r7p.js +9 -0
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-memory/types.d.ts +2 -0
- package/dist/tools/ctx-memory/types.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
- package/dist/transformers-node-wasm.js +25676 -0
- package/dist/transformers-web.js +72 -72
- package/dist/{transformers.node-b1wa0hgx.js → transformers.node-dpmf3wpx.js} +74 -74
- package/package.json +4 -3
- package/src/config/index.test.ts +69 -0
- package/src/config/latch-permanence-guard.test.ts +5 -0
- package/src/config/project-security.hostile-matrix.test.ts +78 -9
- package/src/config/project-security.ts +4 -3
- package/src/config/schema/magic-context.test.ts +64 -0
- package/src/config/schema/magic-context.ts +100 -6
- package/src/shared/conflict-detector.test.ts +24 -0
- package/src/shared/conflict-detector.ts +25 -7
- package/src/shared/harness.ts +3 -3
- package/src/shared/index.ts +1 -0
- package/src/shared/model-resolution.test.ts +78 -13
- package/src/shared/model-resolution.ts +14 -5
- package/src/shared/prompt-surface-runtime.ts +3 -3
- package/src/shared/rpc-utils.test.ts +246 -5
- package/src/shared/rpc-utils.ts +340 -49
- package/src/shared/summarize-child-stderr.test.ts +55 -0
- package/src/shared/summarize-child-stderr.ts +33 -0
- package/src/shared/tag-transcript.ts +11 -0
- package/src/shared/transcript.ts +3 -1
- package/src/shared/window-geometry.ts +9 -0
- package/dist/announcement-3g9xg433.js +0 -18
- package/dist/conflict-warning-hook-rf17b6et.js +0 -17
- package/dist/derive-budgets-bb7mrpzs.js +0 -14
- package/dist/emscripten-module-49k43zfy.js +0 -507
- package/dist/emscripten-module-ex4v0x4z.js +0 -606
- package/dist/emscripten-module-jfs3d1dq.js +0 -1536
- package/dist/emscripten-module-ss4g4spn.js +0 -4563
- package/dist/ffi-bbm9vkfa.js +0 -92
- package/dist/ffi-kb5r0x1j.js +0 -92
- package/dist/ffi-qnrt0y78.js +0 -80
- package/dist/ffi-yx2hpf4p.js +0 -80
- package/dist/index-8sseka65.js +0 -251
- package/dist/index-ss632za9.js +0 -77
- package/dist/model-resolution-6w6wzw18.js +0 -17
- package/dist/module-ES6BEMUI-1yjdz59c.js +0 -14
- package/dist/module-asyncify-2EFITU5U-fdkx4fhy.js +0 -9
- package/dist/prompt-context-29qkb28f.js +0 -7
- package/dist/recomp-orchestrator-w7xg48e3.js +0 -34
- package/dist/rpc-notifications-1ffm755w.js +0 -17
- package/dist/safe-notification-target-2a8py95v.js +0 -11
- package/dist/send-session-notification-bw7eex6w.js +0 -20
- package/dist/storage-meta-session-gr4zn7sq.js +0 -21
- package/dist/task-config-gv6s04fp.js +0 -18
- /package/dist/{index-37yzyeca.js → index-3fe78beq.js} +0 -0
- /package/dist/{index-8mtsfhyg.js → index-jfpk81yt.js} +0 -0
- /package/dist/{index-2wchnyk6.js → index-kby1sng5.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__require
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-22jkk6wg.js";
|
|
4
4
|
|
|
5
5
|
// ../../node_modules/.bun/@huggingface+transformers@4.2.0/node_modules/@huggingface/transformers/dist/transformers.node.mjs
|
|
6
6
|
import fs from "fs";
|
|
@@ -4257,18 +4257,18 @@ var Environment = class {
|
|
|
4257
4257
|
}
|
|
4258
4258
|
}
|
|
4259
4259
|
};
|
|
4260
|
-
function setupGlobals(
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4260
|
+
function setupGlobals(env2) {
|
|
4261
|
+
env2.set("false", false);
|
|
4262
|
+
env2.set("true", true);
|
|
4263
|
+
env2.set("none", null);
|
|
4264
|
+
env2.set("raise_exception", (args) => {
|
|
4265
4265
|
throw new Error(args);
|
|
4266
4266
|
});
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4267
|
+
env2.set("range", range);
|
|
4268
|
+
env2.set("strftime_now", strftime_now);
|
|
4269
|
+
env2.set("True", true);
|
|
4270
|
+
env2.set("False", false);
|
|
4271
|
+
env2.set("None", null);
|
|
4272
4272
|
}
|
|
4273
4273
|
function getAttributeValue(item, attributePath) {
|
|
4274
4274
|
const parts = attributePath.split(".");
|
|
@@ -4333,8 +4333,8 @@ function compareRuntimeValues(a, b, caseSensitive = false) {
|
|
|
4333
4333
|
}
|
|
4334
4334
|
var Interpreter = class {
|
|
4335
4335
|
global;
|
|
4336
|
-
constructor(
|
|
4337
|
-
this.global =
|
|
4336
|
+
constructor(env2) {
|
|
4337
|
+
this.global = env2 ?? new Environment;
|
|
4338
4338
|
}
|
|
4339
4339
|
run(program) {
|
|
4340
4340
|
return this.evaluate(program, this.global);
|
|
@@ -5417,14 +5417,14 @@ var Template = class {
|
|
|
5417
5417
|
this.parsed = parse(tokens);
|
|
5418
5418
|
}
|
|
5419
5419
|
render(items) {
|
|
5420
|
-
const
|
|
5421
|
-
setupGlobals(
|
|
5420
|
+
const env2 = new Environment;
|
|
5421
|
+
setupGlobals(env2);
|
|
5422
5422
|
if (items) {
|
|
5423
5423
|
for (const [key, value] of Object.entries(items)) {
|
|
5424
|
-
|
|
5424
|
+
env2.set(key, value);
|
|
5425
5425
|
}
|
|
5426
5426
|
}
|
|
5427
|
-
const interpreter = new Interpreter(
|
|
5427
|
+
const interpreter = new Interpreter(env2);
|
|
5428
5428
|
const result = interpreter.run(this.parsed);
|
|
5429
5429
|
return result.value;
|
|
5430
5430
|
}
|
|
@@ -6071,8 +6071,8 @@ function getFetchHeaders(urlOrPath) {
|
|
|
6071
6071
|
const headers = new Headers;
|
|
6072
6072
|
if (isNode) {
|
|
6073
6073
|
const IS_CI = !!process.env?.TESTING_REMOTELY;
|
|
6074
|
-
const
|
|
6075
|
-
headers.set("User-Agent", `transformers.js/${
|
|
6074
|
+
const version = env3.version;
|
|
6075
|
+
headers.set("User-Agent", `transformers.js/${version}; is_ci/${IS_CI};`);
|
|
6076
6076
|
const isHFURL = isValidUrl(urlOrPath, ["http:", "https:"], ["huggingface.co", "hf.co"]);
|
|
6077
6077
|
if (isHFURL) {
|
|
6078
6078
|
const token = process.env?.HF_TOKEN ?? process.env?.HF_ACCESS_TOKEN;
|
|
@@ -6835,7 +6835,7 @@ function dynamic_time_warping(matrix) {
|
|
|
6835
6835
|
const outputShape = [output_length + 1, input_length + 1];
|
|
6836
6836
|
const cost = Array.from({ length: outputShape[0] }, () => Array(outputShape[1]).fill(Infinity));
|
|
6837
6837
|
cost[0][0] = 0;
|
|
6838
|
-
const
|
|
6838
|
+
const trace = Array.from({ length: outputShape[0] }, () => Array(outputShape[1]).fill(-1));
|
|
6839
6839
|
for (let j2 = 1;j2 < outputShape[1]; ++j2) {
|
|
6840
6840
|
for (let i2 = 1;i2 < outputShape[0]; ++i2) {
|
|
6841
6841
|
const c0 = cost[i2 - 1][j2 - 1];
|
|
@@ -6853,14 +6853,14 @@ function dynamic_time_warping(matrix) {
|
|
|
6853
6853
|
t = 2;
|
|
6854
6854
|
}
|
|
6855
6855
|
cost[i2][j2] = matrix[i2 - 1][j2 - 1] + c;
|
|
6856
|
-
|
|
6856
|
+
trace[i2][j2] = t;
|
|
6857
6857
|
}
|
|
6858
6858
|
}
|
|
6859
6859
|
for (let i2 = 0;i2 < outputShape[1]; ++i2) {
|
|
6860
|
-
|
|
6860
|
+
trace[0][i2] = 2;
|
|
6861
6861
|
}
|
|
6862
6862
|
for (let i2 = 0;i2 < outputShape[0]; ++i2) {
|
|
6863
|
-
|
|
6863
|
+
trace[i2][0] = 1;
|
|
6864
6864
|
}
|
|
6865
6865
|
let i = output_length;
|
|
6866
6866
|
let j = input_length;
|
|
@@ -6869,7 +6869,7 @@ function dynamic_time_warping(matrix) {
|
|
|
6869
6869
|
while (i > 0 || j > 0) {
|
|
6870
6870
|
text_indices.push(i - 1);
|
|
6871
6871
|
time_indices.push(j - 1);
|
|
6872
|
-
switch (
|
|
6872
|
+
switch (trace[i][j]) {
|
|
6873
6873
|
case 0:
|
|
6874
6874
|
--i;
|
|
6875
6875
|
--j;
|
|
@@ -9513,7 +9513,7 @@ async function es(a = {}) {
|
|
|
9513
9513
|
};
|
|
9514
9514
|
}, r.ad = (b, E) => {
|
|
9515
9515
|
var I = E.buffer;
|
|
9516
|
-
let
|
|
9516
|
+
let F = E.byteOffset, j = E.byteLength;
|
|
9517
9517
|
if (E = 16 * Math.ceil(Number(j) / 16), b = L(b), !n) {
|
|
9518
9518
|
var te = Dr(o);
|
|
9519
9519
|
n = L(te);
|
|
@@ -13018,9 +13018,9 @@ function reshape(data, dimensions) {
|
|
|
13018
13018
|
}
|
|
13019
13019
|
return reshapedArray[0];
|
|
13020
13020
|
}
|
|
13021
|
-
function permute(
|
|
13022
|
-
const [permutedData, shape] = permute_data(
|
|
13023
|
-
return new Tensor22(
|
|
13021
|
+
function permute(tensor, axes) {
|
|
13022
|
+
const [permutedData, shape] = permute_data(tensor.data, tensor.dims, axes);
|
|
13023
|
+
return new Tensor22(tensor.type, permutedData, shape);
|
|
13024
13024
|
}
|
|
13025
13025
|
function interpolate(input, [out_height, out_width], mode = "bilinear", align_corners = false) {
|
|
13026
13026
|
const in_channels = input.dims.at(-3) ?? 1;
|
|
@@ -13180,8 +13180,8 @@ function cat(tensors, dim = 0) {
|
|
|
13180
13180
|
const resultType = tensors[0].type;
|
|
13181
13181
|
if (dim === 0) {
|
|
13182
13182
|
let offset = 0;
|
|
13183
|
-
for (const
|
|
13184
|
-
const tensorData =
|
|
13183
|
+
for (const tensor of tensors) {
|
|
13184
|
+
const tensorData = tensor.data;
|
|
13185
13185
|
result.set(tensorData, offset);
|
|
13186
13186
|
offset += tensorData.length;
|
|
13187
13187
|
}
|
|
@@ -13304,20 +13304,20 @@ function full(size, fill_value) {
|
|
|
13304
13304
|
}
|
|
13305
13305
|
return fullHelper(size, fill_value, dtype, typedArrayCls);
|
|
13306
13306
|
}
|
|
13307
|
-
function full_like(
|
|
13308
|
-
return full(
|
|
13307
|
+
function full_like(tensor, fill_value) {
|
|
13308
|
+
return full(tensor.dims, fill_value);
|
|
13309
13309
|
}
|
|
13310
13310
|
function ones(size) {
|
|
13311
13311
|
return fullHelper(size, 1n, "int64", BigInt64Array);
|
|
13312
13312
|
}
|
|
13313
|
-
function ones_like(
|
|
13314
|
-
return ones(
|
|
13313
|
+
function ones_like(tensor) {
|
|
13314
|
+
return ones(tensor.dims);
|
|
13315
13315
|
}
|
|
13316
13316
|
function zeros(size) {
|
|
13317
13317
|
return fullHelper(size, 0n, "int64", BigInt64Array);
|
|
13318
13318
|
}
|
|
13319
|
-
function zeros_like(
|
|
13320
|
-
return zeros(
|
|
13319
|
+
function zeros_like(tensor) {
|
|
13320
|
+
return zeros(tensor.dims);
|
|
13321
13321
|
}
|
|
13322
13322
|
function rand(size) {
|
|
13323
13323
|
const length = size.reduce((a, b) => a * b, 1);
|
|
@@ -13327,11 +13327,11 @@ function randn(size) {
|
|
|
13327
13327
|
const length = size.reduce((a, b) => a * b, 1);
|
|
13328
13328
|
return new Tensor22("float32", Float32Array.from({ length }, () => random.gauss()), size);
|
|
13329
13329
|
}
|
|
13330
|
-
function quantize_embeddings(
|
|
13331
|
-
if (
|
|
13330
|
+
function quantize_embeddings(tensor, precision) {
|
|
13331
|
+
if (tensor.dims.length !== 2) {
|
|
13332
13332
|
throw new Error("The tensor must have 2 dimensions");
|
|
13333
13333
|
}
|
|
13334
|
-
if (
|
|
13334
|
+
if (tensor.dims.at(-1) % 8 !== 0) {
|
|
13335
13335
|
throw new Error("The last dimension of the tensor must be a multiple of 8");
|
|
13336
13336
|
}
|
|
13337
13337
|
if (!["binary", "ubinary"].includes(precision)) {
|
|
@@ -13340,7 +13340,7 @@ function quantize_embeddings(tensor2, precision) {
|
|
|
13340
13340
|
const signed = precision === "binary";
|
|
13341
13341
|
const dtype = signed ? "int8" : "uint8";
|
|
13342
13342
|
const cls = signed ? Int8Array : Uint8Array;
|
|
13343
|
-
const inputData =
|
|
13343
|
+
const inputData = tensor.data;
|
|
13344
13344
|
const outputData = new cls(inputData.length / 8);
|
|
13345
13345
|
for (let i = 0;i < inputData.length; ++i) {
|
|
13346
13346
|
const bit = inputData[i] > 0 ? 1 : 0;
|
|
@@ -13351,7 +13351,7 @@ function quantize_embeddings(tensor2, precision) {
|
|
|
13351
13351
|
outputData[arrayIndex] -= 128;
|
|
13352
13352
|
}
|
|
13353
13353
|
}
|
|
13354
|
-
return new Tensor22(dtype, outputData, [
|
|
13354
|
+
return new Tensor22(dtype, outputData, [tensor.dims[0], tensor.dims[1] / 8]);
|
|
13355
13355
|
}
|
|
13356
13356
|
async function get_tokenizer_files(modelId) {
|
|
13357
13357
|
if (!modelId) {
|
|
@@ -13367,16 +13367,16 @@ async function loadTokenizer(pretrained_model_name_or_path, options) {
|
|
|
13367
13367
|
const tokenizerFiles = await get_tokenizer_files(pretrained_model_name_or_path);
|
|
13368
13368
|
return await Promise.all(tokenizerFiles.map((file) => getModelJSON(pretrained_model_name_or_path, file, true, options)));
|
|
13369
13369
|
}
|
|
13370
|
-
function prepareTensorForDecode(
|
|
13371
|
-
const dims =
|
|
13370
|
+
function prepareTensorForDecode(tensor) {
|
|
13371
|
+
const dims = tensor.dims;
|
|
13372
13372
|
switch (dims.length) {
|
|
13373
13373
|
case 1:
|
|
13374
|
-
return
|
|
13374
|
+
return tensor.tolist();
|
|
13375
13375
|
case 2:
|
|
13376
13376
|
if (dims[0] !== 1) {
|
|
13377
13377
|
throw new Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");
|
|
13378
13378
|
}
|
|
13379
|
-
return
|
|
13379
|
+
return tensor.tolist()[0];
|
|
13380
13380
|
default:
|
|
13381
13381
|
throw new Error(`Expected tensor to have 1-2 dimensions, got ${dims.length}.`);
|
|
13382
13382
|
}
|
|
@@ -15934,26 +15934,26 @@ var RawImage = class _RawImage {
|
|
|
15934
15934
|
return await loadImageFunction(img);
|
|
15935
15935
|
}
|
|
15936
15936
|
}
|
|
15937
|
-
static fromTensor(
|
|
15938
|
-
if (
|
|
15939
|
-
throw new Error(`Tensor should have 3 dimensions, but has ${
|
|
15937
|
+
static fromTensor(tensor, channel_format = "CHW") {
|
|
15938
|
+
if (tensor.dims.length !== 3) {
|
|
15939
|
+
throw new Error(`Tensor should have 3 dimensions, but has ${tensor.dims.length} dimensions.`);
|
|
15940
15940
|
}
|
|
15941
15941
|
if (channel_format === "CHW") {
|
|
15942
|
-
|
|
15942
|
+
tensor = tensor.transpose(1, 2, 0);
|
|
15943
15943
|
} else if (channel_format === "HWC") {} else {
|
|
15944
15944
|
throw new Error(`Unsupported channel format: ${channel_format}`);
|
|
15945
15945
|
}
|
|
15946
|
-
if (!(
|
|
15947
|
-
throw new Error(`Unsupported tensor type: ${
|
|
15946
|
+
if (!(tensor.data instanceof Uint8ClampedArray || tensor.data instanceof Uint8Array)) {
|
|
15947
|
+
throw new Error(`Unsupported tensor type: ${tensor.type}`);
|
|
15948
15948
|
}
|
|
15949
|
-
switch (
|
|
15949
|
+
switch (tensor.dims[2]) {
|
|
15950
15950
|
case 1:
|
|
15951
15951
|
case 2:
|
|
15952
15952
|
case 3:
|
|
15953
15953
|
case 4:
|
|
15954
|
-
return new _RawImage(
|
|
15954
|
+
return new _RawImage(tensor.data, tensor.dims[1], tensor.dims[0], tensor.dims[2]);
|
|
15955
15955
|
default:
|
|
15956
|
-
throw new Error(`Unsupported number of channels: ${
|
|
15956
|
+
throw new Error(`Unsupported number of channels: ${tensor.dims[2]}`);
|
|
15957
15957
|
}
|
|
15958
15958
|
}
|
|
15959
15959
|
grayscale() {
|
|
@@ -16240,13 +16240,13 @@ var RawImage = class _RawImage {
|
|
|
16240
16240
|
return await canvas.convertToBlob({ type, quality });
|
|
16241
16241
|
}
|
|
16242
16242
|
toTensor(channel_format = "CHW") {
|
|
16243
|
-
let
|
|
16243
|
+
let tensor = new Tensor22("uint8", new Uint8Array(this.data), [this.height, this.width, this.channels]);
|
|
16244
16244
|
if (channel_format === "HWC") {} else if (channel_format === "CHW") {
|
|
16245
|
-
|
|
16245
|
+
tensor = tensor.permute(2, 0, 1);
|
|
16246
16246
|
} else {
|
|
16247
16247
|
throw new Error(`Unsupported channel format: ${channel_format}`);
|
|
16248
16248
|
}
|
|
16249
|
-
return
|
|
16249
|
+
return tensor;
|
|
16250
16250
|
}
|
|
16251
16251
|
toCanvas() {
|
|
16252
16252
|
if (!apis.IS_WEB_ENV) {
|
|
@@ -19530,25 +19530,25 @@ async function sessionRun(session, inputs) {
|
|
|
19530
19530
|
const checkedInputs = validateInputs(session, inputs);
|
|
19531
19531
|
try {
|
|
19532
19532
|
const ortFeed = Object.fromEntries(Object.entries(checkedInputs).map(([k2, v]) => {
|
|
19533
|
-
const
|
|
19533
|
+
const tensor = v.ort_tensor;
|
|
19534
19534
|
if (apis.IS_NODE_ENV) {
|
|
19535
|
-
if (typeof Float16Array !== "undefined" &&
|
|
19536
|
-
|
|
19535
|
+
if (typeof Float16Array !== "undefined" && tensor.cpuData instanceof Float16Array) {
|
|
19536
|
+
tensor.cpuData = new Uint16Array(tensor.cpuData.buffer);
|
|
19537
19537
|
}
|
|
19538
19538
|
}
|
|
19539
|
-
return [k2,
|
|
19539
|
+
return [k2, tensor];
|
|
19540
19540
|
}));
|
|
19541
19541
|
const output = await runInferenceSession(session, ortFeed);
|
|
19542
19542
|
return replaceTensors(output);
|
|
19543
19543
|
} catch (e) {
|
|
19544
|
-
const formatted = Object.fromEntries(Object.entries(checkedInputs).map(([k2,
|
|
19544
|
+
const formatted = Object.fromEntries(Object.entries(checkedInputs).map(([k2, tensor]) => {
|
|
19545
19545
|
const unpacked = {
|
|
19546
|
-
type:
|
|
19547
|
-
dims:
|
|
19548
|
-
location:
|
|
19546
|
+
type: tensor.type,
|
|
19547
|
+
dims: tensor.dims,
|
|
19548
|
+
location: tensor.location
|
|
19549
19549
|
};
|
|
19550
19550
|
if (unpacked.location !== "gpu-buffer") {
|
|
19551
|
-
unpacked.data =
|
|
19551
|
+
unpacked.data = tensor.data;
|
|
19552
19552
|
}
|
|
19553
19553
|
return [k2, unpacked];
|
|
19554
19554
|
}));
|
|
@@ -19561,12 +19561,12 @@ function validateInputs(session, inputs) {
|
|
|
19561
19561
|
const checkedInputs = /* @__PURE__ */ Object.create(null);
|
|
19562
19562
|
const missingInputs = [];
|
|
19563
19563
|
for (const inputName of session.inputNames) {
|
|
19564
|
-
const
|
|
19565
|
-
if (!(
|
|
19564
|
+
const tensor = inputs[inputName];
|
|
19565
|
+
if (!(tensor instanceof Tensor22)) {
|
|
19566
19566
|
missingInputs.push(inputName);
|
|
19567
19567
|
continue;
|
|
19568
19568
|
}
|
|
19569
|
-
checkedInputs[inputName] = isONNXProxy() ?
|
|
19569
|
+
checkedInputs[inputName] = isONNXProxy() ? tensor.clone() : tensor;
|
|
19570
19570
|
}
|
|
19571
19571
|
if (missingInputs.length > 0) {
|
|
19572
19572
|
throw new Error(`An error occurred during model execution: "Missing the following inputs: ${missingInputs.join(", ")}.`);
|
|
@@ -20965,9 +20965,9 @@ var PreTrainedModel = class extends Callable {
|
|
|
20965
20965
|
const sequences = new Tensor22("int64", all_input_ids.flat(), [all_input_ids.length, all_input_ids[0].length]);
|
|
20966
20966
|
const past_key_values = getPastKeyValues(outputs, model_inputs.past_key_values);
|
|
20967
20967
|
const cachedTensors = new Set(Object.values(past_key_values));
|
|
20968
|
-
for (const
|
|
20969
|
-
if (
|
|
20970
|
-
|
|
20968
|
+
for (const tensor of Object.values(outputs)) {
|
|
20969
|
+
if (tensor.location === "gpu-buffer" && !cachedTensors.has(tensor)) {
|
|
20970
|
+
tensor.dispose();
|
|
20971
20971
|
}
|
|
20972
20972
|
}
|
|
20973
20973
|
const keepCacheAlive = "past_key_values" in kwargs || generation_config.return_dict_in_generate;
|
|
@@ -23824,8 +23824,8 @@ var MultiModalityCausalLM = class extends MultiModalityPreTrainedModel {
|
|
|
23824
23824
|
});
|
|
23825
23825
|
const clamped = decoded_image.add_(1).mul_(255 / 2).clamp_(0, 255).to("uint8");
|
|
23826
23826
|
const images = [];
|
|
23827
|
-
for (const
|
|
23828
|
-
const img = RawImage.fromTensor(
|
|
23827
|
+
for (const tensor of clamped) {
|
|
23828
|
+
const img = RawImage.fromTensor(tensor);
|
|
23829
23829
|
images.push(img);
|
|
23830
23830
|
}
|
|
23831
23831
|
return images;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/opencode-magic-context",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenCode plugin for Magic Context — cross-session memory and context management",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,9 +35,10 @@
|
|
|
35
35
|
"README.md"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"build": "tsc -p ../retina-local-fs/tsconfig.build.json && bun run build:tui && rm -f dist/index.js dist/transformers-web.js dist/*-*.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 build src/index.ts --outdir dist --target node --format esm --splitting --external @opencode-ai/plugin --external onnxruntime-node --external onnxruntime-web --external sharp --external bun:sqlite --external node:sqlite && tsc --emitDeclarationOnly",
|
|
38
|
+
"build": "tsc -p ../retina-local-fs/tsconfig.build.json && bun run build:tui && rm -f dist/index.js dist/transformers-web.js dist/transformers-node-wasm.js dist/*-*.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 --outdir dist --target node --format esm --splitting --external @opencode-ai/plugin --external onnxruntime-node --external onnxruntime-web --external sharp --external bun:sqlite --external node:sqlite && tsc --emitDeclarationOnly",
|
|
39
39
|
"build:tui": "bun scripts/build-tui.ts",
|
|
40
40
|
"check:tui-compiled": "bun run build:tui && git diff --exit-code -- src/tui-compiled && test -z \"$(git status --porcelain -- src/tui-compiled)\"",
|
|
41
|
+
"check:transformers-node-wasm": "bun scripts/verify-transformers-node-wasm.ts",
|
|
41
42
|
"typecheck": "tsc -p ../retina-local-fs/tsconfig.build.json && tsc --noEmit && tsc -p tsconfig.scripts.json",
|
|
42
43
|
"test": "bun install --frozen-lockfile && bun test --parallel --timeout 30000",
|
|
43
44
|
"test:serial": "bun install --frozen-lockfile && bun test --timeout 30000",
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
},
|
|
67
68
|
"optionalDependencies": {
|
|
68
69
|
"onnxruntime-node": "1.24.3",
|
|
69
|
-
"sharp": "^0.
|
|
70
|
+
"sharp": "^0.35.0"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
73
|
"@ai-sdk/anthropic": "3.0.82",
|
package/src/config/index.test.ts
CHANGED
|
@@ -5,6 +5,11 @@ import { join } from "node:path";
|
|
|
5
5
|
|
|
6
6
|
import { resolveHistorianModel } from "../shared/model-resolution";
|
|
7
7
|
import { createTestTempDir } from "../shared/test-temp-dir";
|
|
8
|
+
import {
|
|
9
|
+
getWindowOverlay,
|
|
10
|
+
reloadWindowOverlay,
|
|
11
|
+
setWindowOverlayPath,
|
|
12
|
+
} from "../shared/window-geometry";
|
|
8
13
|
import { loadPluginConfig, loadPluginConfigDetailed } from "./index";
|
|
9
14
|
import { resolveConfigProfile } from "./profiles";
|
|
10
15
|
import { DEFAULT_LOCAL_EMBEDDING_MODEL } from "./schema/magic-context";
|
|
@@ -113,6 +118,42 @@ function loadWithUserAndProjectConfig(
|
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
|
|
121
|
+
describe("loadPluginConfig — Fusiform overlay reload", () => {
|
|
122
|
+
it("does not invalidate a same-path overlay during routine config reads", () => {
|
|
123
|
+
const overlayDir = mkdtempSync(join(tmpdir(), "mc-config-overlay-"));
|
|
124
|
+
const overlayPath = join(overlayDir, "window-overlay.json");
|
|
125
|
+
const configText = JSON.stringify({ models: { window_overlay_path: overlayPath } });
|
|
126
|
+
const writeOverlay = (modelId: string) =>
|
|
127
|
+
writeFileSync(
|
|
128
|
+
overlayPath,
|
|
129
|
+
JSON.stringify({
|
|
130
|
+
schema: "fusiform-window-overlay/v1",
|
|
131
|
+
generated_at: "2026-09-01T00:00:00Z",
|
|
132
|
+
minted_provider_ids: [],
|
|
133
|
+
cells: [{ provider_id: "hunt-provider", model_id: modelId, facts: {} }],
|
|
134
|
+
}),
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
try {
|
|
138
|
+
writeOverlay("before-rewrite");
|
|
139
|
+
loadWithUserConfig(configText);
|
|
140
|
+
expect(getWindowOverlay()?.cells[0]?.model_id).toBe("before-rewrite");
|
|
141
|
+
|
|
142
|
+
writeOverlay("after-rewrite");
|
|
143
|
+
expect(getWindowOverlay()?.cells[0]?.model_id).toBe("before-rewrite");
|
|
144
|
+
|
|
145
|
+
loadWithUserConfig(configText);
|
|
146
|
+
expect(getWindowOverlay()?.cells[0]?.model_id).toBe("before-rewrite");
|
|
147
|
+
|
|
148
|
+
reloadWindowOverlay(overlayPath);
|
|
149
|
+
expect(getWindowOverlay()?.cells[0]?.model_id).toBe("after-rewrite");
|
|
150
|
+
} finally {
|
|
151
|
+
setWindowOverlayPath(undefined);
|
|
152
|
+
rmSync(overlayDir, { recursive: true, force: true });
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
116
157
|
describe("loadPluginConfig — preload user-config isolation", () => {
|
|
117
158
|
it("resolves schema-default embedding config for a fixture with no config (#388)", () => {
|
|
118
159
|
const projectDir = mkdtempSync(join(tmpdir(), "mc-config-preload-fixture-"));
|
|
@@ -1468,3 +1509,31 @@ describe("loadPluginConfigDetailed — prompt-surface registration owner", () =>
|
|
|
1468
1509
|
}
|
|
1469
1510
|
});
|
|
1470
1511
|
});
|
|
1512
|
+
|
|
1513
|
+
describe("shared per-harness config loading", () => {
|
|
1514
|
+
it("lets OpenCode load Pi and OMP agent blocks without schema recovery warnings", () => {
|
|
1515
|
+
const config = loadWithUserConfig(
|
|
1516
|
+
JSON.stringify({
|
|
1517
|
+
historian: {
|
|
1518
|
+
opencode: { model: "anthropic/opencode-historian" },
|
|
1519
|
+
pi: { model: "anthropic/pi-historian", thinking_level: "high" },
|
|
1520
|
+
omp: { model: "anthropic/omp-historian", thinking_level: "auto" },
|
|
1521
|
+
},
|
|
1522
|
+
dreamer: {
|
|
1523
|
+
opencode: { model: "anthropic/opencode-dreamer" },
|
|
1524
|
+
pi: { model: "anthropic/pi-dreamer", thinking_level: "medium" },
|
|
1525
|
+
omp: { model: "anthropic/omp-dreamer", thinking_level: "inherit" },
|
|
1526
|
+
},
|
|
1527
|
+
}),
|
|
1528
|
+
);
|
|
1529
|
+
|
|
1530
|
+
expect(config.configWarnings).toBeUndefined();
|
|
1531
|
+
expect(config.historian?.omp).toEqual({
|
|
1532
|
+
model: "anthropic/omp-historian",
|
|
1533
|
+
thinking_level: "auto",
|
|
1534
|
+
});
|
|
1535
|
+
expect(resolveHistorianModel(config, "opencode").primary?.model).toBe(
|
|
1536
|
+
"anthropic/opencode-historian",
|
|
1537
|
+
);
|
|
1538
|
+
});
|
|
1539
|
+
});
|
|
@@ -27,6 +27,11 @@ const KNOWN_SLOTS: Record<string, KnownSlot> = {
|
|
|
27
27
|
classification: "VERDICT",
|
|
28
28
|
reason: "Correct: a missing or unloadable native binding needs an install repair, which this process cannot observe.",
|
|
29
29
|
},
|
|
30
|
+
"packages/plugin/src/features/magic-context/memory/embedding-local.ts:localEmbeddingProcessFailure":
|
|
31
|
+
{
|
|
32
|
+
classification: "DIAGNOSTIC",
|
|
33
|
+
reason: "Most-recent local runtime diagnostic: successful initialization and test reset both clear it; the separate runtime-mode slot owns the process verdict.",
|
|
34
|
+
},
|
|
30
35
|
"packages/plugin/src/features/magic-context/memory/embedding-synapse.ts:sharedClientPromise": {
|
|
31
36
|
classification: "VERDICT",
|
|
32
37
|
reason: "DEFECT: a rejected connection promise remains shared after the daemon recovers.",
|