@openclaw/onnx 2026.9.6

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 ADDED
@@ -0,0 +1,36 @@
1
+ # @openclaw/onnx
2
+
3
+ Official local ONNX decision-model plugin for OpenClaw. It evaluates Choice,
4
+ Score, and Boolean rubrics with GLiClass, GLiNER2.5, and DeBERTa classifiers in a
5
+ persistent CPU inference process.
6
+
7
+ ## Setup
8
+
9
+ Released OpenClaw `2026.9.5` lacks the decision-provider API. Packaged installs
10
+ require a host and plugin API of at least `2026.9.6`.
11
+
12
+ For development, use an OpenClaw checkout containing both the decision-provider
13
+ API and this plugin. Run `pnpm install --frozen-lockfile` and `pnpm build`, enable
14
+ `plugins.entries.onnx`, and run these commands from the checkout:
15
+
16
+ ```sh
17
+ pnpm openclaw onnx models
18
+ pnpm openclaw onnx download gliclass-edge-v3.0
19
+ pnpm openclaw onnx probe gliclass-edge-v3.0
20
+ ```
21
+
22
+ Select `onnx/gliclass-edge-v3.0` as `agents.defaults.decisionModel` or as an
23
+ agent's override. Inference stays local; model downloads use pinned revisions,
24
+ sizes, and SHA256 hashes. Large models may need preloading to meet the host's
25
+ 30-second decision deadline.
26
+
27
+ On a compatible packaged host, install the local candidate with
28
+ `openclaw plugins install npm-pack:/path/to/openclaw-onnx.tgz`. A development
29
+ checkout's co-versioned source loading does not grant compatibility to an older
30
+ packaged host.
31
+
32
+ See [Local ONNX decision models](https://docs.openclaw.ai/plugins/onnx) for the
33
+ model catalog, configuration, local exports, and runtime limits. The
34
+ [Decision models guide](https://docs.openclaw.ai/concepts/decision-models)
35
+ explains rubric definitions, score semantics, and the plugin API shared with
36
+ TypeSafe AI.
@@ -0,0 +1,40 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
+ <!--
3
+ Source: simple-icons@16.31.0, icons/onnx.svg
4
+ https://www.npmjs.com/package/simple-icons/v/16.31.0
5
+ https://github.com/simple-icons/simple-icons
6
+
7
+ # CC0 1.0 Universal
8
+
9
+ ## Statement of Purpose
10
+
11
+ The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an “owner”) of an original work of authorship and/or a database (each, a “Work”).
12
+
13
+ Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works (“Commons”) that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others.
14
+
15
+ For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the “Affirmer”), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights.
16
+
17
+ 1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights (“Copyright and Related Rights”). Copyright and Related Rights include, but are not limited to, the following:
18
+ 1. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work;
19
+ 2. moral rights retained by the original author(s) and/or performer(s);
20
+ 3. publicity and privacy rights pertaining to a person’s image or likeness depicted in a Work;
21
+ 4. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(i), below;
22
+ 5. rights protecting the extraction, dissemination, use and reuse of data in a Work;
23
+ 6. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and
24
+ 7. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof.
25
+
26
+ 2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer’s Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the “Waiver”). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer’s heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer’s express Statement of Purpose.
27
+
28
+ 3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer’s express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer’s Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the “License”). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer’s express Statement of Purpose.
29
+
30
+ 4. Limitations and Disclaimers.
31
+ 1. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document.
32
+ 2. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law.
33
+ 3. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person’s Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work.
34
+ 4. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work.
35
+
36
+ For more information, please see <https://creativecommons.org/publicdomain/zero/1.0>.
37
+ Names and marks remain the property of their respective owners.
38
+ -->
39
+ <path fill="currentColor" stroke="none" d="M23.0325 11.2963c-.0503 0-.1006 0-.1508.0126l-4.021-7.4387c.0754-.1383.1131-.289.1131-.4524 0-.5403-.4398-.9675-.9675-.9675-.2765 0-.5278.113-.7037.3015L9.286 1.156C9.2357.6785 8.821.3016 8.3184.3016c-.5277 0-.9675.4398-.9675.9675 0 .1634.0377.3141.113.4524l-6.245 8.9591c-.0753-.0251-.1633-.0377-.2513-.0377-.5403 0-.9675.4398-.9675.9676 0 .5403.4398.9675.9675.9675h.0377l3.3676 8.3309c-.0503.1257-.088.2639-.088.402 0 .5404.4398.9676.9676.9676.2764 0 .5277-.113.7036-.3015l10.1152.9926c.1005.4273.49.7288.9424.7288.5403 0 .9676-.4398.9676-.9675 0-.2388-.088-.465-.2262-.6283l5.1141-8.8712c.0503.0126.1005.0126.1634.0126.5403 0 .9675-.4398.9675-.9676 0-.5403-.4272-.98-.9675-.98zM17.2272 4.021c.1131.1508.2765.264.4524.3267l-1.533 11.5728c-.1005.0252-.1885.0503-.2764.1005L7.4513 8.708c.0251-.0754.0377-.1634.0377-.2514 0-.0628-.0126-.1256-.0126-.1884zm4.8754 8.5068l-5.177 3.556a1.105 1.105 0 0 0-.1256-.0753L18.3455 4.335h.0126l3.9456 7.288c-.1508.1759-.2388.3895-.2388.6408 0 .1005.0126.1885.0377.2638zM6.3832 7.5016c-.4649.0754-.8293.4775-.8293.955v.0628l-3.4555 2.0481 5.378-7.7026zm.3519 1.91c.1256-.0252.2513-.088.3518-.1634l8.356 7.2628c-.0377.113-.0628.2262-.0628.3518v.0503l-9.311 3.845c-.1382-.201-.3518-.3518-.6031-.402zm8.8963 8.1172c.1257.1382.3016.2513.5026.289l.465 4.046c-.201.1006-.3519.264-.4524.4524l-9.8136-.955zm1.1435.2136c.3267-.1633.5403-.49.5403-.867 0-.088-.0126-.1634-.0377-.2513l4.7372-3.2545-4.8 8.331zm.2513-14.3497l-9.889 4.31-.1131-.0755 1.2565-5.3906h.0377c.3393 0 .6409-.1759.8168-.4397l7.891 1.5706zM1.935 11.6105c0-.0629-.0126-.1257-.0126-.1885l3.9079-2.2995c.0754.0754.1633.1508.2638.201L4.8252 20.243l-3.2043-7.9036c.1885-.176.3142-.4398.3142-.7288Z" />
40
+ </svg>
Binary file
@@ -0,0 +1,156 @@
1
+ import { t as OnnxWorkerError } from "./protocol-lN8zQ8J3.mjs";
2
+ import path from "node:path";
3
+ import { Type } from "typebox";
4
+ import { Value } from "typebox/value";
5
+ import { createHash, randomUUID } from "node:crypto";
6
+ import fs from "node:fs/promises";
7
+ import { readFileWindowFully, root, sha256File } from "openclaw/plugin-sdk/file-access-runtime";
8
+ //#region extensions/onnx/src/artifacts.ts
9
+ const ExportSchema = Type.Object({
10
+ modelId: Type.String(),
11
+ sourceRevision: Type.String({ pattern: "^[a-f0-9]{40}$" }),
12
+ files: Type.Array(Type.Object({
13
+ name: Type.Union([
14
+ Type.Literal("model.onnx"),
15
+ Type.Literal("tokenizer.json"),
16
+ Type.Literal("tokenizer_config.json"),
17
+ Type.Literal("config.json"),
18
+ Type.Literal("special_tokens_map.json")
19
+ ]),
20
+ size: Type.Integer({
21
+ minimum: 1,
22
+ maximum: 15e8
23
+ }),
24
+ sha256: Type.String({ pattern: "^[a-f0-9]{64}$" })
25
+ }, { additionalProperties: false }), {
26
+ minItems: 2,
27
+ maxItems: 5
28
+ })
29
+ }, { additionalProperties: false });
30
+ async function withModelFile(file, maxBytes, consume) {
31
+ let handle;
32
+ try {
33
+ handle = await fs.open(file, "r");
34
+ const stat = await handle.stat();
35
+ if (!stat.isFile() || stat.size < 1 || stat.size > maxBytes) throw new OnnxWorkerError("model-integrity");
36
+ return await consume(handle, stat.size);
37
+ } catch (error) {
38
+ if (error instanceof OnnxWorkerError) throw error;
39
+ throw new OnnxWorkerError(error instanceof Error && "code" in error && error.code === "too-large" ? "model-integrity" : "model-missing");
40
+ } finally {
41
+ await handle?.close();
42
+ }
43
+ }
44
+ async function readBounded(file, maxBytes) {
45
+ return await withModelFile(file, maxBytes, async (handle, size) => {
46
+ const data = Buffer.alloc(size);
47
+ if (await readFileWindowFully(handle, data, 0) !== data.length) throw new OnnxWorkerError("model-integrity");
48
+ return data;
49
+ });
50
+ }
51
+ async function resolveModelFiles(root, model) {
52
+ if (model.source.kind === "hub") return model.source.files;
53
+ let value;
54
+ try {
55
+ value = JSON.parse((await readBounded(path.join(root, model.id, "model.json"), 32768)).toString("utf8"));
56
+ } catch (error) {
57
+ if (error instanceof OnnxWorkerError) throw error;
58
+ throw new OnnxWorkerError("model-integrity");
59
+ }
60
+ if (!Value.Check(ExportSchema, value) || value.modelId !== model.id || value.sourceRevision !== model.source.revision) throw new OnnxWorkerError("model-integrity");
61
+ const names = value.files.map((file) => file.name);
62
+ if (new Set(names).size !== names.length || !names.includes("model.onnx") || !names.includes("tokenizer.json")) throw new OnnxWorkerError("model-integrity");
63
+ return value.files.map((file) => ({
64
+ name: file.name,
65
+ bytes: file.size,
66
+ sha256: file.sha256
67
+ }));
68
+ }
69
+ function modelArtifactByteLimit(file) {
70
+ const limit = file.name === "model.onnx" ? 15e8 : 16777216;
71
+ if (file.bytes > limit) throw new OnnxWorkerError("model-integrity");
72
+ return file.bytes;
73
+ }
74
+ async function readModelArtifact(root, model, file) {
75
+ const data = await readBounded(path.join(root, model.id, file.name), modelArtifactByteLimit(file));
76
+ if (data.length !== file.bytes || createHash("sha256").update(data).digest("hex") !== file.sha256) throw new OnnxWorkerError("model-integrity");
77
+ return data;
78
+ }
79
+ async function verifyModelArtifact(root, model, file) {
80
+ const maxBytes = modelArtifactByteLimit(file);
81
+ await withModelFile(path.join(root, model.id, file.name), maxBytes, async (handle, size) => {
82
+ if (size !== file.bytes) throw new OnnxWorkerError("model-integrity");
83
+ const hash = await sha256File(handle, { maxBytes });
84
+ if (hash.bytes !== file.bytes || hash.digest !== file.sha256) throw new OnnxWorkerError("model-integrity");
85
+ });
86
+ }
87
+ async function verifyModel(root, model) {
88
+ for (const file of await resolveModelFiles(root, model)) await verifyModelArtifact(root, model, file);
89
+ }
90
+ async function downloadModel(root$1, model, signal) {
91
+ if (model.source.kind !== "hub") throw new Error(`${model.id} requires a local export. Use the plugin's export-gliclass-instruct.py helper.`);
92
+ const destination = path.join(root$1, model.id);
93
+ await fs.mkdir(destination, { recursive: true });
94
+ const directory = await root(destination);
95
+ for (const file of model.source.files) {
96
+ signal.throwIfAborted();
97
+ const target = path.join(destination, file.name);
98
+ if (await fs.lstat(target).catch((error) => {
99
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return;
100
+ throw error;
101
+ })) {
102
+ await verifyModelArtifact(root$1, model, file);
103
+ continue;
104
+ }
105
+ const temp = `.${file.name}.${randomUUID()}.partial`;
106
+ const url = `https://huggingface.co/${model.source.repository}/resolve/${model.source.revision}/${file.path}`;
107
+ async function* downloadChunks() {
108
+ const { fetchWithSsrFGuard } = await import("openclaw/plugin-sdk/ssrf-runtime");
109
+ const guarded = await fetchWithSsrFGuard({
110
+ url,
111
+ requireHttps: true,
112
+ maxRedirects: 5,
113
+ signal
114
+ });
115
+ try {
116
+ if (!guarded.response.ok || !guarded.response.body) throw new Error(`Model download failed: HTTP ${guarded.response.status}.`);
117
+ const hash = createHash("sha256");
118
+ let size = 0;
119
+ signal.throwIfAborted();
120
+ for await (const chunk of guarded.response.body) {
121
+ size += chunk.byteLength;
122
+ if (size > file.bytes) throw new Error("Model download exceeds its pinned size.");
123
+ hash.update(chunk);
124
+ yield chunk;
125
+ }
126
+ if (size !== file.bytes || hash.digest("hex") !== file.sha256) throw new Error("Model download failed its pinned integrity check.");
127
+ } finally {
128
+ try {
129
+ await guarded.response.body?.cancel();
130
+ } finally {
131
+ await guarded.release();
132
+ }
133
+ }
134
+ }
135
+ await directory.create(`./${temp}`, downloadChunks(), {
136
+ mode: 384 & ~process.umask(),
137
+ durable: false,
138
+ mkdir: false,
139
+ maxBytes: file.bytes,
140
+ signal
141
+ });
142
+ try {
143
+ signal.throwIfAborted();
144
+ try {
145
+ await fs.link(path.join(directory.rootReal, temp), target);
146
+ } catch (error) {
147
+ if (!(error instanceof Error && "code" in error && error.code === "EEXIST")) throw error;
148
+ await verifyModelArtifact(root$1, model, file);
149
+ }
150
+ } finally {
151
+ await directory.remove(`./${temp}`, { force: true });
152
+ }
153
+ }
154
+ }
155
+ //#endregion
156
+ export { verifyModel as i, readModelArtifact as n, resolveModelFiles as r, downloadModel as t };
@@ -0,0 +1,173 @@
1
+ //#region extensions/onnx/src/catalog.ts
2
+ const MODELS = [
3
+ {
4
+ id: "gliclass-edge-v3.0",
5
+ name: "GLiClass Edge v3",
6
+ family: "gliclass",
7
+ maxTokens: 512,
8
+ source: {
9
+ kind: "hub",
10
+ repository: "cnmoro/gliclass-edge-v3.0-onnx",
11
+ revision: "1167c26c90183f20165120292dc5c7684af406ae",
12
+ files: [{
13
+ name: "model.onnx",
14
+ path: "model.onnx",
15
+ bytes: 131130181,
16
+ sha256: "5289497ae11bb612806e56eefa168c6338e3e5d9f548e8012f1e10560e19fa8f"
17
+ }, {
18
+ name: "tokenizer.json",
19
+ path: "tokenizer.json",
20
+ bytes: 3583864,
21
+ sha256: "b6e09abceac75851eae141e7d51224a9da835c0c03684282fe2d5c42c745754f"
22
+ }]
23
+ }
24
+ },
25
+ {
26
+ id: "gliclass-base-v3.0",
27
+ name: "GLiClass Base v3",
28
+ family: "gliclass",
29
+ maxTokens: 512,
30
+ source: {
31
+ kind: "hub",
32
+ repository: "cnmoro/gliclass-base-v3.0-onnx",
33
+ revision: "8acca975fd47e89e15f13a4f5446f2ccd1dcf7bb",
34
+ files: [{
35
+ name: "model.onnx",
36
+ path: "model.onnx",
37
+ bytes: 747316021,
38
+ sha256: "1395fde4ae8de8e41f51080c18a09c48c704b5a1dd34d78950b6c9a11efddd7b"
39
+ }, {
40
+ name: "tokenizer.json",
41
+ path: "tokenizer.json",
42
+ bytes: 8649499,
43
+ sha256: "9db2e87fbab9819100edd8d6dc7a54f82167045d04bfb752039dae4efb9cd85c"
44
+ }]
45
+ }
46
+ },
47
+ {
48
+ id: "gliner2.5-small-v1",
49
+ name: "GLiNER 2.5 Small",
50
+ family: "gliner",
51
+ maxTokens: 512,
52
+ source: {
53
+ kind: "hub",
54
+ repository: "nicolasembleton/gliner2.5-small-v1-onnx",
55
+ revision: "5e2e3f51adfb0eeb7c1f83464400b4d498d41659",
56
+ files: [
57
+ {
58
+ name: "model.onnx",
59
+ path: "onnx/model.onnx",
60
+ bytes: 288521577,
61
+ sha256: "12dda5cf4b0e9ed3af17596cef1cdbd22185a32fcc230af4f476353b5e4ade1f"
62
+ },
63
+ {
64
+ name: "tokenizer.json",
65
+ path: "tokenizer.json",
66
+ bytes: 8341713,
67
+ sha256: "cbc8ae6037812709c9c26f2a160f8dc48b0440bcb79c8141804259ae2d6adac3"
68
+ },
69
+ {
70
+ name: "tokenizer_config.json",
71
+ path: "tokenizer_config.json",
72
+ bytes: 646,
73
+ sha256: "fd4a31dc2f1f17e31638c5f0e783b81cdb2fbe6bddd116a8d9e5d50d78148cf1"
74
+ }
75
+ ]
76
+ }
77
+ },
78
+ {
79
+ id: "gliner2.5-base-v1",
80
+ name: "GLiNER 2.5 Base",
81
+ family: "gliner",
82
+ maxTokens: 512,
83
+ source: {
84
+ kind: "hub",
85
+ repository: "nicolasembleton/gliner2.5-base-v1-onnx",
86
+ revision: "b29dcb3c273644e833837933533ac37274fe585e",
87
+ files: [
88
+ {
89
+ name: "model.onnx",
90
+ path: "onnx/model.onnx",
91
+ bytes: 746400205,
92
+ sha256: "db56fe723c14e856ab5618a5bceb66b55a1e8d2cf5f3026202c45e6ff4b86f42"
93
+ },
94
+ {
95
+ name: "tokenizer.json",
96
+ path: "tokenizer.json",
97
+ bytes: 8341713,
98
+ sha256: "cbc8ae6037812709c9c26f2a160f8dc48b0440bcb79c8141804259ae2d6adac3"
99
+ },
100
+ {
101
+ name: "tokenizer_config.json",
102
+ path: "tokenizer_config.json",
103
+ bytes: 646,
104
+ sha256: "fd4a31dc2f1f17e31638c5f0e783b81cdb2fbe6bddd116a8d9e5d50d78148cf1"
105
+ }
106
+ ]
107
+ }
108
+ },
109
+ {
110
+ id: "deberta-v3-base-zeroshot-v2.0",
111
+ name: "DeBERTa Zero-shot v2",
112
+ family: "deberta",
113
+ maxTokens: 512,
114
+ source: {
115
+ kind: "hub",
116
+ repository: "MoritzLaurer/deberta-v3-base-zeroshot-v2.0",
117
+ revision: "8e7e5af5983a0ddb1a5b45a38b129ab69e2258e8",
118
+ files: [
119
+ {
120
+ name: "model.onnx",
121
+ path: "onnx/model.onnx",
122
+ bytes: 738563249,
123
+ sha256: "d46fa6c1addc598abd34af8651120291f51417ddfce45b9d5f70bc32d3efa81c"
124
+ },
125
+ {
126
+ name: "config.json",
127
+ path: "config.json",
128
+ bytes: 1016,
129
+ sha256: "a1c8011b852ae46d6ac26160d358fa595861d261352885f8f7bfcd2811030d9f"
130
+ },
131
+ {
132
+ name: "tokenizer.json",
133
+ path: "tokenizer.json",
134
+ bytes: 8656646,
135
+ sha256: "05402ffae6dd382a8491b1d29bfc139bec5d332662e86a026f433ce54c25c202"
136
+ },
137
+ {
138
+ name: "tokenizer_config.json",
139
+ path: "tokenizer_config.json",
140
+ bytes: 1256,
141
+ sha256: "f5a1a74a632c0e9225e09a21ddf60c2e70ef5d3bfc1f261a24fd8ddab27254d2"
142
+ }
143
+ ]
144
+ }
145
+ },
146
+ {
147
+ id: "gliclass-instruct-edge-v1.0",
148
+ name: "GLiClass Instruct Edge (local export)",
149
+ family: "gliclass",
150
+ maxTokens: 512,
151
+ source: {
152
+ kind: "local-export",
153
+ repository: "knowledgator/gliclass-instruct-edge-v1.0",
154
+ revision: "727be8a417f6a7718e591b025e07054c146d8139"
155
+ }
156
+ },
157
+ {
158
+ id: "gliclass-instruct-base-v1.0",
159
+ name: "GLiClass Instruct Base (local export)",
160
+ family: "gliclass",
161
+ maxTokens: 512,
162
+ source: {
163
+ kind: "local-export",
164
+ repository: "knowledgator/gliclass-instruct-base-v1.0",
165
+ revision: "4f6a108b08a5537f395521d19b5073e197923dd3"
166
+ }
167
+ }
168
+ ];
169
+ function findModel(id) {
170
+ return MODELS.find((model) => model.id === id);
171
+ }
172
+ //#endregion
173
+ export { findModel as n, MODELS as t };
@@ -0,0 +1,95 @@
1
+ import { n as findModel, t as MODELS } from "./catalog-Bgbx4LHv.mjs";
2
+ import { n as createOnnxProvider, t as InferenceWorkerClient } from "./worker-client-BfBezMH8.mjs";
3
+ import { i as verifyModel, t as downloadModel } from "./artifacts-Du35Uk5d.mjs";
4
+ import path from "node:path";
5
+ //#region extensions/onnx/src/cli.ts
6
+ function registerOnnxCli({ program }, settings, workerUrl, resolvePath) {
7
+ const root = program.command("onnx").description("Download, verify, and probe local ONNX decision models");
8
+ const config = (options) => ({
9
+ ...settings,
10
+ ...options.modelDir === void 0 ? {} : { modelDir: path.resolve(resolvePath(options.modelDir)) }
11
+ });
12
+ const model = (id) => {
13
+ const found = findModel(id);
14
+ if (!found) throw new Error(`Unknown ONNX model '${id}'. Run openclaw onnx models.`);
15
+ return found;
16
+ };
17
+ root.command("models").description("List supported classifiers and artifact sources").action(() => {
18
+ console.log(JSON.stringify(MODELS.map((entry) => ({
19
+ id: entry.id,
20
+ name: entry.name,
21
+ source: entry.source.kind,
22
+ repository: entry.source.repository,
23
+ revision: entry.source.revision,
24
+ maxTokens: entry.maxTokens,
25
+ downloadBytes: entry.source.kind === "hub" ? entry.source.files.reduce((sum, file) => sum + file.bytes, 0) : void 0
26
+ })), null, 2));
27
+ });
28
+ root.command("download").argument("<model>").option("--model-dir <path>", "Override the model artifact directory").description("Download revision-pinned artifacts and verify their SHA256 hashes").action(async (id, options) => {
29
+ const selected = model(id);
30
+ const modelSettings = config(options);
31
+ await downloadModel(modelSettings.modelDir, selected, AbortSignal.timeout(18e5));
32
+ console.log(`Verified ${selected.id} in ${path.join(modelSettings.modelDir, selected.id)}`);
33
+ });
34
+ root.command("verify").argument("<model>").option("--model-dir <path>", "Override the model artifact directory").description("Verify model artifacts without loading native inference").action(async (id, options) => {
35
+ await verifyModel(config(options).modelDir, model(id));
36
+ console.log(`Verified ${id}`);
37
+ });
38
+ root.command("probe").argument("<model>").option("--model-dir <path>", "Override the model artifact directory").description("Run a fixed local Choice, Score, and Boolean smoke evaluation").action(async (id, options) => {
39
+ model(id);
40
+ const client = new InferenceWorkerClient({
41
+ workerUrl,
42
+ config: config(options)
43
+ });
44
+ try {
45
+ const start = performance.now();
46
+ await client.warm([id], AbortSignal.timeout(12e4));
47
+ const warmed = performance.now();
48
+ const timeoutMs = 3e4;
49
+ const signal = AbortSignal.timeout(timeoutMs);
50
+ const outcome = await createOnnxProvider(client, (message) => console.error(message)).evaluate({
51
+ state: "I loved the quiet beach holiday and would happily go back.",
52
+ questions: {
53
+ topic: {
54
+ type: "choice",
55
+ criteria: {
56
+ travel: "travel and holidays",
57
+ finance: "finance and banking",
58
+ science: "scientific research"
59
+ }
60
+ },
61
+ sentiment: {
62
+ type: "score",
63
+ criteria: [
64
+ "negative sentiment",
65
+ "neutral sentiment",
66
+ "positive sentiment"
67
+ ]
68
+ },
69
+ holiday: {
70
+ type: "boolean",
71
+ criteria: {
72
+ true: "The text describes a holiday",
73
+ false: "The text is unrelated to holidays"
74
+ }
75
+ }
76
+ }
77
+ }, {
78
+ model: id,
79
+ signal,
80
+ deadlineMonotonicMs: warmed + timeoutMs
81
+ });
82
+ console.log(JSON.stringify({
83
+ model: id,
84
+ warmupMs: warmed - start,
85
+ inferenceMs: performance.now() - warmed,
86
+ outcome
87
+ }, null, 2));
88
+ if (outcome.status !== "ok") throw new Error(`ONNX probe failed: ${outcome.reason}`);
89
+ } finally {
90
+ await client.stop();
91
+ }
92
+ });
93
+ }
94
+ //#endregion
95
+ export { registerOnnxCli };