@openclaw/onnx 2026.10.5-beta.4 → 2026.10.10-beta.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/.setup/{cli-BF6QsLdC.mjs → cli-lLSGmoHu.mjs} +1 -1
- package/dist/.setup/{model-loader-CWJMvEgT.mjs → model-loader-D-w2BLGm.mjs} +6 -0
- package/dist/.setup/{worker-client-wmsjADm-.mjs → worker-client-DUApeDD4.mjs} +2 -3
- package/dist/index.js +2 -2
- package/dist/src/inference.worker.js +45 -15
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as findModel, t as MODELS } from "./catalog-Bgbx4LHv.mjs";
|
|
2
|
-
import { n as createOnnxProvider, t as InferenceWorkerClient } from "./worker-client-
|
|
2
|
+
import { n as createOnnxProvider, t as InferenceWorkerClient } from "./worker-client-DUApeDD4.mjs";
|
|
3
3
|
import { i as verifyModel, t as downloadModel } from "./artifacts-Du35Uk5d.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
//#region extensions/onnx/src/cli.ts
|
|
@@ -171,6 +171,12 @@ var ModelCache = class {
|
|
|
171
171
|
this.config = config;
|
|
172
172
|
this.models = /* @__PURE__ */ new Map();
|
|
173
173
|
}
|
|
174
|
+
async close() {
|
|
175
|
+
const models = [...this.models.values()];
|
|
176
|
+
this.models.clear();
|
|
177
|
+
const failures = (await Promise.allSettled(models.map(({ session }) => session.release()))).filter((result) => result.status === "rejected");
|
|
178
|
+
if (failures.length > 0) throw new AggregateError(failures.map((result) => result.reason), "ONNX session release failed");
|
|
179
|
+
}
|
|
174
180
|
async get(id) {
|
|
175
181
|
const existing = this.models.get(id);
|
|
176
182
|
if (existing) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { n as findModel } from "./catalog-Bgbx4LHv.mjs";
|
|
2
2
|
import { i as UnsupportedInputError, n as parseWorkerReply, r as parseWorkerRequest, t as OnnxWorkerError } from "./protocol-lN8zQ8J3.mjs";
|
|
3
|
-
import { spawn } from "node:child_process";
|
|
4
3
|
import { createDeferred } from "openclaw/plugin-sdk/concurrency-runtime";
|
|
5
|
-
import { resolveRuntimeWorkerArgv } from "openclaw/plugin-sdk/process-runtime";
|
|
4
|
+
import { resolveRuntimeWorkerArgv, spawnOomScoreAdjusted } from "openclaw/plugin-sdk/process-runtime";
|
|
6
5
|
//#region extensions/onnx/src/decisions.ts
|
|
7
6
|
function render(value) {
|
|
8
7
|
return typeof value === "string" ? value : JSON.stringify(value);
|
|
@@ -232,7 +231,7 @@ var InferenceWorkerClient = class {
|
|
|
232
231
|
}
|
|
233
232
|
}
|
|
234
233
|
start() {
|
|
235
|
-
const child =
|
|
234
|
+
const child = spawnOomScoreAdjusted(process.execPath, resolveRuntimeWorkerArgv(this.workerUrl), {
|
|
236
235
|
env: workerEnv(),
|
|
237
236
|
shell: false,
|
|
238
237
|
windowsHide: true,
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as findModel } from "./.setup/catalog-Bgbx4LHv.mjs";
|
|
2
|
-
import { n as createOnnxProvider, t as InferenceWorkerClient } from "./.setup/worker-client-
|
|
2
|
+
import { n as createOnnxProvider, t as InferenceWorkerClient } from "./.setup/worker-client-DUApeDD4.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
5
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
@@ -72,7 +72,7 @@ var onnx_default = definePluginEntry({
|
|
|
72
72
|
});
|
|
73
73
|
api.lifecycle?.onDispose?.(() => client.stop());
|
|
74
74
|
api.registerCli(async (context) => {
|
|
75
|
-
const { registerOnnxCli } = await import("./.setup/cli-
|
|
75
|
+
const { registerOnnxCli } = await import("./.setup/cli-lLSGmoHu.mjs");
|
|
76
76
|
registerOnnxCli(context, config, workerUrl, api.resolvePath);
|
|
77
77
|
}, { descriptors: [{
|
|
78
78
|
name: "onnx",
|
|
@@ -2,39 +2,68 @@ import { i as UnsupportedInputError, r as parseWorkerRequest, t as OnnxWorkerErr
|
|
|
2
2
|
//#region extensions/onnx/src/inference.worker.ts
|
|
3
3
|
let config;
|
|
4
4
|
let cache;
|
|
5
|
-
let
|
|
5
|
+
let stopping = false;
|
|
6
|
+
let finalExitCode = 0;
|
|
7
|
+
let activeTask;
|
|
8
|
+
function stop(code) {
|
|
9
|
+
if (code !== 0) finalExitCode = code;
|
|
10
|
+
if (stopping) return;
|
|
11
|
+
stopping = true;
|
|
12
|
+
process.off("message", onMessage);
|
|
13
|
+
Promise.resolve(activeTask).catch(() => void 0).then(() => cache?.close()).catch(() => {
|
|
14
|
+
finalExitCode = 1;
|
|
15
|
+
}).finally(() => {
|
|
16
|
+
if (process.connected && typeof process.disconnect === "function") process.disconnect();
|
|
17
|
+
process.exitCode = finalExitCode;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
6
20
|
function send(reply) {
|
|
7
|
-
if (
|
|
21
|
+
if (stopping) return;
|
|
22
|
+
if (!process.connected || !process.send) {
|
|
23
|
+
stop(1);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
8
26
|
process.send(reply, (error) => {
|
|
9
|
-
if (error)
|
|
27
|
+
if (error) stop(1);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function onMessage(value) {
|
|
31
|
+
if (stopping) return;
|
|
32
|
+
if (activeTask) {
|
|
33
|
+
stop(1);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
activeTask = handle(value);
|
|
37
|
+
activeTask.catch(() => stop(1)).finally(() => {
|
|
38
|
+
activeTask = void 0;
|
|
10
39
|
});
|
|
11
40
|
}
|
|
12
|
-
process.on("disconnect", () =>
|
|
13
|
-
process.on("message",
|
|
14
|
-
handle(value).catch(() => process.exit(1));
|
|
15
|
-
});
|
|
41
|
+
process.on("disconnect", () => stop(0));
|
|
42
|
+
process.on("message", onMessage);
|
|
16
43
|
async function handle(value) {
|
|
17
44
|
const request = parseWorkerRequest(value);
|
|
18
45
|
if (request.kind === "init") {
|
|
19
|
-
if (config
|
|
46
|
+
if (config) throw new Error("Already initialized");
|
|
20
47
|
config = request.config;
|
|
21
48
|
send({ kind: "ready" });
|
|
22
49
|
return;
|
|
23
50
|
}
|
|
24
|
-
if (!config
|
|
25
|
-
busy = true;
|
|
51
|
+
if (!config) throw new Error("Invalid worker admission");
|
|
26
52
|
try {
|
|
27
53
|
if (!cache) {
|
|
28
54
|
let implementation;
|
|
29
55
|
try {
|
|
30
|
-
implementation = await import("../.setup/model-loader-
|
|
56
|
+
implementation = await import("../.setup/model-loader-D-w2BLGm.mjs");
|
|
31
57
|
} catch {
|
|
32
58
|
throw new OnnxWorkerError("dependency-unavailable");
|
|
33
59
|
}
|
|
34
60
|
cache = new implementation.ModelCache(config);
|
|
35
61
|
}
|
|
36
62
|
if (request.kind === "warm") {
|
|
37
|
-
for (const model of request.models)
|
|
63
|
+
for (const model of request.models) {
|
|
64
|
+
if (stopping) return;
|
|
65
|
+
await cache.get(model);
|
|
66
|
+
}
|
|
38
67
|
send({
|
|
39
68
|
kind: "warmed",
|
|
40
69
|
id: request.id
|
|
@@ -42,7 +71,10 @@ async function handle(value) {
|
|
|
42
71
|
} else {
|
|
43
72
|
const model = await cache.get(request.model);
|
|
44
73
|
const results = [];
|
|
45
|
-
for (const input of request.inputs)
|
|
74
|
+
for (const input of request.inputs) {
|
|
75
|
+
if (stopping) return;
|
|
76
|
+
results.push(await model.classify(input));
|
|
77
|
+
}
|
|
46
78
|
send({
|
|
47
79
|
kind: "results",
|
|
48
80
|
id: request.id,
|
|
@@ -55,8 +87,6 @@ async function handle(value) {
|
|
|
55
87
|
id: request.id,
|
|
56
88
|
code: error instanceof UnsupportedInputError ? "unsupported-input" : error instanceof OnnxWorkerError ? error.code : "runtime"
|
|
57
89
|
});
|
|
58
|
-
} finally {
|
|
59
|
-
busy = false;
|
|
60
90
|
}
|
|
61
91
|
}
|
|
62
92
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/onnx",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.10-beta.1",
|
|
4
4
|
"description": "Local ONNX decision models for OpenClaw",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@huggingface/tokenizers": "0.2.0",
|
|
12
|
-
"typebox": "1.3.
|
|
12
|
+
"typebox": "1.3.35"
|
|
13
13
|
},
|
|
14
14
|
"optionalDependencies": {
|
|
15
15
|
"onnxruntime-node": "1.30.0"
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"minHostVersion": ">=2026.9.6"
|
|
29
29
|
},
|
|
30
30
|
"compat": {
|
|
31
|
-
"pluginApi": ">=2026.10.
|
|
31
|
+
"pluginApi": ">=2026.10.10-beta.1"
|
|
32
32
|
},
|
|
33
33
|
"build": {
|
|
34
34
|
"bundledDist": false,
|
|
35
|
-
"openclawVersion": "2026.10.
|
|
35
|
+
"openclawVersion": "2026.10.10-beta.1",
|
|
36
36
|
"workerEntries": [
|
|
37
37
|
"./src/inference.worker.ts"
|
|
38
38
|
],
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"assets/activity.svg"
|
|
61
61
|
],
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"openclaw": ">=2026.10.
|
|
63
|
+
"openclaw": ">=2026.10.10-beta.1"
|
|
64
64
|
},
|
|
65
65
|
"peerDependenciesMeta": {
|
|
66
66
|
"openclaw": {
|