@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 +36 -0
- package/assets/activity.svg +40 -0
- package/assets/icon.png +0 -0
- package/dist/.setup/artifacts-Du35Uk5d.mjs +156 -0
- package/dist/.setup/catalog-Bgbx4LHv.mjs +173 -0
- package/dist/.setup/cli-Ch_OkcD5.mjs +95 -0
- package/dist/.setup/model-loader-CWJMvEgT.mjs +223 -0
- package/dist/.setup/protocol-lN8zQ8J3.mjs +115 -0
- package/dist/.setup/worker-client-BfBezMH8.mjs +332 -0
- package/dist/index.js +85 -0
- package/dist/scripts/export-gliclass-instruct.py +224 -0
- package/dist/src/inference.worker.js +63 -0
- package/openclaw.plugin.json +98 -0
- package/package.json +70 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { n as findModel } from "./.setup/catalog-Bgbx4LHv.mjs";
|
|
2
|
+
import { n as createOnnxProvider, t as InferenceWorkerClient } from "./.setup/worker-client-BfBezMH8.mjs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
6
|
+
import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
|
|
7
|
+
import { Type } from "typebox";
|
|
8
|
+
//#region extensions/onnx/src/config.ts
|
|
9
|
+
const ConfigSchema = Type.Object({
|
|
10
|
+
modelDir: Type.Optional(Type.String({
|
|
11
|
+
minLength: 1,
|
|
12
|
+
maxLength: 4096
|
|
13
|
+
})),
|
|
14
|
+
threads: Type.Optional(Type.Integer({
|
|
15
|
+
minimum: 1,
|
|
16
|
+
maximum: 8,
|
|
17
|
+
default: 2
|
|
18
|
+
})),
|
|
19
|
+
maxLoadedModels: Type.Optional(Type.Integer({
|
|
20
|
+
minimum: 1,
|
|
21
|
+
maximum: 5,
|
|
22
|
+
default: 2
|
|
23
|
+
}))
|
|
24
|
+
}, { additionalProperties: false });
|
|
25
|
+
function resolveOnnxConfig(config, resolvePath) {
|
|
26
|
+
const modelDir = config?.modelDir ?? path.join(resolveStateDir(), "models", "onnx");
|
|
27
|
+
const threads = config?.threads ?? 2;
|
|
28
|
+
const maxLoadedModels = config?.maxLoadedModels ?? 2;
|
|
29
|
+
if (typeof modelDir !== "string" || !modelDir.trim() || typeof threads !== "number" || !Number.isInteger(threads) || threads < 1 || threads > 8 || typeof maxLoadedModels !== "number" || !Number.isInteger(maxLoadedModels) || maxLoadedModels < 1 || maxLoadedModels > 5) throw new Error("Invalid ONNX configuration; check modelDir, threads, and maxLoadedModels.");
|
|
30
|
+
return {
|
|
31
|
+
modelDir: path.resolve(resolvePath(modelDir)),
|
|
32
|
+
threads,
|
|
33
|
+
maxLoadedModels
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region extensions/onnx/index.ts
|
|
38
|
+
function selectedModels(config) {
|
|
39
|
+
const selectors = [config.agents?.defaults?.decisionModel, ...Object.values(config.agents?.entries ?? {}).map((agent) => agent.decisionModel)];
|
|
40
|
+
return [...new Set(selectors.flatMap((selector) => {
|
|
41
|
+
if (typeof selector !== "string" || !selector.startsWith("onnx/")) return [];
|
|
42
|
+
const id = selector.slice(5);
|
|
43
|
+
return findModel(id) ? [id] : [];
|
|
44
|
+
}))];
|
|
45
|
+
}
|
|
46
|
+
var onnx_default = definePluginEntry({
|
|
47
|
+
id: "onnx",
|
|
48
|
+
name: "ONNX",
|
|
49
|
+
description: "Local typed decisions using ONNX classifiers",
|
|
50
|
+
configSchema: { jsonSchema: { ...ConfigSchema } },
|
|
51
|
+
register(api) {
|
|
52
|
+
if (!api.runtimeSource) throw new Error("ONNX requires runtime entrypoint metadata from its OpenClaw host.");
|
|
53
|
+
const workerUrl = new URL(`./src/inference.worker${path.extname(api.runtimeSource)}`, pathToFileURL(api.runtimeSource));
|
|
54
|
+
const config = resolveOnnxConfig(api.pluginConfig, api.resolvePath);
|
|
55
|
+
const client = new InferenceWorkerClient({
|
|
56
|
+
workerUrl,
|
|
57
|
+
config
|
|
58
|
+
});
|
|
59
|
+
api.registerDecisionProvider(createOnnxProvider(client, (message) => api.logger.warn(message)));
|
|
60
|
+
api.registerService({
|
|
61
|
+
id: "onnx-worker",
|
|
62
|
+
async start(context) {
|
|
63
|
+
const models = selectedModels(context.config).slice(0, config.maxLoadedModels);
|
|
64
|
+
if (models.length === 0) return;
|
|
65
|
+
try {
|
|
66
|
+
await client.warm(models, AbortSignal.any([AbortSignal.timeout(12e4), ...api.lifecycle?.signal ? [api.lifecycle.signal] : []]));
|
|
67
|
+
} catch {
|
|
68
|
+
context.logger.warn("ONNX models are not ready. Run openclaw onnx models and verify/download the selected artifacts.");
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
stop: () => client.stop()
|
|
72
|
+
});
|
|
73
|
+
api.lifecycle?.onDispose?.(() => client.stop());
|
|
74
|
+
api.registerCli(async (context) => {
|
|
75
|
+
const { registerOnnxCli } = await import("./.setup/cli-Ch_OkcD5.mjs");
|
|
76
|
+
registerOnnxCli(context, config, workerUrl, api.resolvePath);
|
|
77
|
+
}, { descriptors: [{
|
|
78
|
+
name: "onnx",
|
|
79
|
+
description: "Manage local ONNX decision models",
|
|
80
|
+
hasSubcommands: true
|
|
81
|
+
}] });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
//#endregion
|
|
85
|
+
export { onnx_default as default };
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Export a pinned local GLiClass Instruct checkpoint for the ONNX plugin.
|
|
3
|
+
|
|
4
|
+
Requires Python 3.11+ and the package versions shown by --help. This script
|
|
5
|
+
does not install packages, download checkpoints, or load remote model code.
|
|
6
|
+
The export supports 2–64 labels and task instructions, without few-shot examples.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
import hashlib
|
|
11
|
+
import importlib.metadata
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
import shutil
|
|
16
|
+
import sys
|
|
17
|
+
import tempfile
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
PACKAGES = {
|
|
21
|
+
"gliclass": "0.1.20",
|
|
22
|
+
"torch": "2.9.1",
|
|
23
|
+
"transformers": "5.3.0",
|
|
24
|
+
"tokenizers": "0.22.2",
|
|
25
|
+
"onnx": "1.19.1",
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
SOURCES = {
|
|
29
|
+
"edge": {
|
|
30
|
+
"revision": "727be8a417f6a7718e591b025e07054c146d8139",
|
|
31
|
+
"sha256": {
|
|
32
|
+
"model.safetensors": "3ea2c091f32877c9db46d2defe4ef23148d3ad21350bfd765a443e026588eeae",
|
|
33
|
+
"config.json": "8c901824b9352754c9722f50830049b4fbb169f62823b6cdc9a4ce51918179f9",
|
|
34
|
+
"tokenizer.json": "879c2bc610c79b03a3fb72e1e80b6d966615b957bdaedf137f1e87270c90935b",
|
|
35
|
+
"tokenizer_config.json": "7dbbb2fc8cfb050a652bffe28db6251439d9b966d8655b7d79ba3d5c17c39b77",
|
|
36
|
+
"special_tokens_map.json": "ea97ecdbcc73713039d8d64dbb05e3689495c96657fbd9a18f5bed381be81049",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
"base": {
|
|
40
|
+
"revision": "4f6a108b08a5537f395521d19b5073e197923dd3",
|
|
41
|
+
"sha256": {
|
|
42
|
+
"model.safetensors": "ab6ce13c9ca472a72bded2f0333534d5631aa52b6eb5b38d5df32b080501e4b6",
|
|
43
|
+
"config.json": "fe28f5df83b9bc62cb975073c0bdcebc8117362eb25664a5618be5fd9f2376f7",
|
|
44
|
+
"tokenizer.json": "d05acaafc9edfc327f2b7c03576100925d7f69c3085b27a62288958246510677",
|
|
45
|
+
"tokenizer_config.json": "32154241472870be1e317105ce4765903515b4291b4add85a8d4322fda53ffe2",
|
|
46
|
+
"special_tokens_map.json": "b2f1b2f15f29a6b6d9d6ea4eca1675d2c231a71477f151d48f79cc83a625ba21",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def sha256(path):
|
|
53
|
+
with path.open("rb") as stream:
|
|
54
|
+
return hashlib.file_digest(stream, "sha256").hexdigest()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def parse_args():
|
|
58
|
+
packages = " ".join(f"{name}=={version}" for name, version in PACKAGES.items())
|
|
59
|
+
revisions = "\n".join(
|
|
60
|
+
f" {kind}: knowledgator/gliclass-instruct-{kind}-v1.0@{source['revision']}"
|
|
61
|
+
for kind, source in SOURCES.items()
|
|
62
|
+
)
|
|
63
|
+
parser = argparse.ArgumentParser(
|
|
64
|
+
description=__doc__,
|
|
65
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
66
|
+
epilog=(
|
|
67
|
+
f"Required installed packages:\n {packages}\n\n"
|
|
68
|
+
f"Required official checkpoint revisions:\n{revisions}\n\n"
|
|
69
|
+
"Prepare those checkpoint files separately. The source hashes are verified "
|
|
70
|
+
"before export.\nThe output contains model.onnx, tokenizer/config files, "
|
|
71
|
+
"and model.json with artifact hashes."
|
|
72
|
+
),
|
|
73
|
+
)
|
|
74
|
+
parser.add_argument("--model", required=True, choices=SOURCES)
|
|
75
|
+
parser.add_argument("--source", required=True, type=Path, help="Local official checkpoint directory")
|
|
76
|
+
parser.add_argument("--output", required=True, type=Path, help="New output directory; must not exist")
|
|
77
|
+
return parser.parse_args()
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def publish(staged, output):
|
|
81
|
+
# POSIX directory rename can replace another writer's empty directory.
|
|
82
|
+
output.mkdir(exist_ok=False)
|
|
83
|
+
reservation = output.lstat()
|
|
84
|
+
linked = []
|
|
85
|
+
try:
|
|
86
|
+
files = sorted(path for path in staged.iterdir() if path.name != "model.json")
|
|
87
|
+
# Readers require the manifest, so it is the publication boundary.
|
|
88
|
+
for source in [*files, staged / "model.json"]:
|
|
89
|
+
target = output / source.name
|
|
90
|
+
identity = source.lstat()
|
|
91
|
+
os.link(source, target)
|
|
92
|
+
linked.append((target, identity))
|
|
93
|
+
except BaseException:
|
|
94
|
+
try:
|
|
95
|
+
for target, identity in linked:
|
|
96
|
+
if not os.path.samestat(output.lstat(), reservation):
|
|
97
|
+
break
|
|
98
|
+
if target.exists() and os.path.samestat(target.lstat(), identity):
|
|
99
|
+
target.unlink()
|
|
100
|
+
# A concurrent rename can replace the reservation during cleanup.
|
|
101
|
+
if os.path.samestat(output.lstat(), reservation):
|
|
102
|
+
# Unexpected files keep the reservation in place rather than being removed.
|
|
103
|
+
output.rmdir()
|
|
104
|
+
except OSError as error:
|
|
105
|
+
print(f"Incomplete output cleanup: {error}", file=sys.stderr)
|
|
106
|
+
raise
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def export(args):
|
|
110
|
+
source = SOURCES[args.model]
|
|
111
|
+
if args.output.exists():
|
|
112
|
+
raise ValueError("Output already exists; choose a new directory.")
|
|
113
|
+
for name, expected in source["sha256"].items():
|
|
114
|
+
path = args.source / name
|
|
115
|
+
if not path.is_file() or sha256(path) != expected:
|
|
116
|
+
raise ValueError(
|
|
117
|
+
f"Source {name} does not match the official {args.model} checkpoint "
|
|
118
|
+
f"at revision {source['revision']}."
|
|
119
|
+
)
|
|
120
|
+
for name, expected in PACKAGES.items():
|
|
121
|
+
installed = importlib.metadata.version(name)
|
|
122
|
+
if installed.split("+", 1)[0] != expected:
|
|
123
|
+
raise ValueError(f"Install {name}=={expected}; found {installed}.")
|
|
124
|
+
|
|
125
|
+
os.environ["HF_HUB_OFFLINE"] = "1"
|
|
126
|
+
os.environ["TRANSFORMERS_OFFLINE"] = "1"
|
|
127
|
+
import onnx
|
|
128
|
+
import torch
|
|
129
|
+
from gliclass import GLiClassModel
|
|
130
|
+
from transformers import AutoTokenizer
|
|
131
|
+
|
|
132
|
+
torch.set_num_threads(2)
|
|
133
|
+
model = GLiClassModel.from_pretrained(
|
|
134
|
+
str(args.source), local_files_only=True, attn_implementation="eager"
|
|
135
|
+
).eval()
|
|
136
|
+
tokenizer = AutoTokenizer.from_pretrained(
|
|
137
|
+
str(args.source), local_files_only=True, trust_remote_code=False
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
class ClassifierExport(torch.nn.Module):
|
|
141
|
+
def __init__(self):
|
|
142
|
+
super().__init__()
|
|
143
|
+
self.core = model.model
|
|
144
|
+
|
|
145
|
+
def forward(self, input_ids, attention_mask):
|
|
146
|
+
positions = torch.arange(input_ids.shape[1], device=input_ids.device).unsqueeze(0)
|
|
147
|
+
separator = (input_ids == self.core.config.text_token_index).long().argmax(
|
|
148
|
+
dim=-1, keepdim=True
|
|
149
|
+
)
|
|
150
|
+
# Upstream .item() indexing freezes the separator during tracing.
|
|
151
|
+
# Without example sections, segment 1 begins at the first separator.
|
|
152
|
+
segments = (positions >= separator).long()
|
|
153
|
+
embedded = self.core.encoder_model.get_input_embeddings()(input_ids)
|
|
154
|
+
embedded = embedded + self.core.segment_embeddings(segments)
|
|
155
|
+
output = self.core.encoder_model(
|
|
156
|
+
inputs_embeds=embedded, attention_mask=attention_mask, return_dict=True
|
|
157
|
+
)
|
|
158
|
+
logits = self.core.process_encoder_output(
|
|
159
|
+
input_ids, attention_mask, output.last_hidden_state, max_num_classes=64
|
|
160
|
+
)[0]
|
|
161
|
+
count = (input_ids == self.core.config.class_token_index).long().sum(dim=-1).max()
|
|
162
|
+
return logits[:, :count]
|
|
163
|
+
|
|
164
|
+
wrapper = ClassifierExport().eval()
|
|
165
|
+
|
|
166
|
+
def encode(labels, text):
|
|
167
|
+
packed = "".join(f"<<LABEL>>{label}" for label in labels)
|
|
168
|
+
packed += "<<SEP>>Classify the text.\n" + text
|
|
169
|
+
return tokenizer(packed, return_tensors="pt", truncation=False, padding=False)
|
|
170
|
+
|
|
171
|
+
with torch.inference_mode():
|
|
172
|
+
for count in (2, 5, 64):
|
|
173
|
+
inputs = encode([f"category{i}" for i in range(count)], "An example document.")
|
|
174
|
+
expected = model(**inputs, max_num_classes=count).logits
|
|
175
|
+
actual = wrapper(inputs["input_ids"], inputs["attention_mask"])
|
|
176
|
+
torch.testing.assert_close(actual, expected, rtol=1e-4, atol=1e-4)
|
|
177
|
+
inputs = encode(["travel", "science", "finance"], "A pleasant trip.")
|
|
178
|
+
args.output.parent.mkdir(parents=True, exist_ok=True)
|
|
179
|
+
with tempfile.TemporaryDirectory(prefix=f".{args.output.name}-", dir=args.output.parent) as directory:
|
|
180
|
+
staged = Path(directory)
|
|
181
|
+
with torch.inference_mode():
|
|
182
|
+
torch.onnx.export(
|
|
183
|
+
wrapper,
|
|
184
|
+
(inputs["input_ids"], inputs["attention_mask"]),
|
|
185
|
+
str(staged / "model.onnx"),
|
|
186
|
+
input_names=["input_ids", "attention_mask"],
|
|
187
|
+
output_names=["logits"],
|
|
188
|
+
dynamic_axes={
|
|
189
|
+
"input_ids": {0: "batch_size", 1: "seq_len"},
|
|
190
|
+
"attention_mask": {0: "batch_size", 1: "seq_len"},
|
|
191
|
+
"logits": {0: "batch_size", 1: "num_labels"},
|
|
192
|
+
},
|
|
193
|
+
opset_version=17,
|
|
194
|
+
dynamo=False,
|
|
195
|
+
)
|
|
196
|
+
onnx.checker.check_model(str(staged / "model.onnx"))
|
|
197
|
+
for name in source["sha256"]:
|
|
198
|
+
if name != "model.safetensors":
|
|
199
|
+
shutil.copyfile(args.source / name, staged / name)
|
|
200
|
+
manifest = {
|
|
201
|
+
"modelId": f"gliclass-instruct-{args.model}-v1.0",
|
|
202
|
+
"sourceRevision": source["revision"],
|
|
203
|
+
"files": [
|
|
204
|
+
{"name": path.name, "sha256": sha256(path), "size": path.stat().st_size}
|
|
205
|
+
for path in sorted(staged.iterdir())
|
|
206
|
+
],
|
|
207
|
+
}
|
|
208
|
+
(staged / "model.json").write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
|
|
209
|
+
publish(staged, args.output)
|
|
210
|
+
print(f"Exported {manifest['modelId']} to {args.output}")
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def main():
|
|
214
|
+
args = parse_args()
|
|
215
|
+
try:
|
|
216
|
+
export(args)
|
|
217
|
+
except (OSError, ValueError, importlib.metadata.PackageNotFoundError) as error:
|
|
218
|
+
print(f"Export failed: {error}", file=sys.stderr)
|
|
219
|
+
return 1
|
|
220
|
+
return 0
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
if __name__ == "__main__":
|
|
224
|
+
sys.exit(main())
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { i as UnsupportedInputError, r as parseWorkerRequest, t as OnnxWorkerError } from "../.setup/protocol-lN8zQ8J3.mjs";
|
|
2
|
+
//#region extensions/onnx/src/inference.worker.ts
|
|
3
|
+
let config;
|
|
4
|
+
let cache;
|
|
5
|
+
let busy = false;
|
|
6
|
+
function send(reply) {
|
|
7
|
+
if (!process.connected || !process.send) process.exit(1);
|
|
8
|
+
process.send(reply, (error) => {
|
|
9
|
+
if (error) process.exit(1);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
process.on("disconnect", () => process.exit(0));
|
|
13
|
+
process.on("message", (value) => {
|
|
14
|
+
handle(value).catch(() => process.exit(1));
|
|
15
|
+
});
|
|
16
|
+
async function handle(value) {
|
|
17
|
+
const request = parseWorkerRequest(value);
|
|
18
|
+
if (request.kind === "init") {
|
|
19
|
+
if (config || busy) throw new Error("Already initialized");
|
|
20
|
+
config = request.config;
|
|
21
|
+
send({ kind: "ready" });
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!config || busy) throw new Error("Invalid worker admission");
|
|
25
|
+
busy = true;
|
|
26
|
+
try {
|
|
27
|
+
if (!cache) {
|
|
28
|
+
let implementation;
|
|
29
|
+
try {
|
|
30
|
+
implementation = await import("../.setup/model-loader-CWJMvEgT.mjs");
|
|
31
|
+
} catch {
|
|
32
|
+
throw new OnnxWorkerError("dependency-unavailable");
|
|
33
|
+
}
|
|
34
|
+
cache = new implementation.ModelCache(config);
|
|
35
|
+
}
|
|
36
|
+
if (request.kind === "warm") {
|
|
37
|
+
for (const model of request.models) await cache.get(model);
|
|
38
|
+
send({
|
|
39
|
+
kind: "warmed",
|
|
40
|
+
id: request.id
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
const model = await cache.get(request.model);
|
|
44
|
+
const results = [];
|
|
45
|
+
for (const input of request.inputs) results.push(await model.classify(input));
|
|
46
|
+
send({
|
|
47
|
+
kind: "results",
|
|
48
|
+
id: request.id,
|
|
49
|
+
results
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
send({
|
|
54
|
+
kind: "error",
|
|
55
|
+
id: request.id,
|
|
56
|
+
code: error instanceof UnsupportedInputError ? "unsupported-input" : error instanceof OnnxWorkerError ? error.code : "runtime"
|
|
57
|
+
});
|
|
58
|
+
} finally {
|
|
59
|
+
busy = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "onnx",
|
|
3
|
+
"name": "ONNX",
|
|
4
|
+
"description": "Local typed decisions using pinned ONNX classifiers.",
|
|
5
|
+
"categories": [
|
|
6
|
+
"developer-tools"
|
|
7
|
+
],
|
|
8
|
+
"enabledByDefault": false,
|
|
9
|
+
"cliCommands": [
|
|
10
|
+
{
|
|
11
|
+
"name": "onnx",
|
|
12
|
+
"description": "Manage local ONNX decision models",
|
|
13
|
+
"hasSubcommands": true
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"activation": {
|
|
17
|
+
"onStartup": true
|
|
18
|
+
},
|
|
19
|
+
"contracts": {
|
|
20
|
+
"decisionProviders": [
|
|
21
|
+
"onnx"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"uiHints": {
|
|
25
|
+
"modelDir": {
|
|
26
|
+
"label": "Model directory",
|
|
27
|
+
"help": "Local model artifacts. Download models explicitly with openclaw onnx download."
|
|
28
|
+
},
|
|
29
|
+
"threads": {
|
|
30
|
+
"label": "CPU inference threads",
|
|
31
|
+
"advanced": true
|
|
32
|
+
},
|
|
33
|
+
"maxLoadedModels": {
|
|
34
|
+
"label": "Resident model limit",
|
|
35
|
+
"advanced": true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"configSchema": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"additionalProperties": false,
|
|
41
|
+
"properties": {
|
|
42
|
+
"modelDir": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"minLength": 1,
|
|
45
|
+
"maxLength": 4096
|
|
46
|
+
},
|
|
47
|
+
"threads": {
|
|
48
|
+
"type": "integer",
|
|
49
|
+
"minimum": 1,
|
|
50
|
+
"maximum": 8,
|
|
51
|
+
"default": 2
|
|
52
|
+
},
|
|
53
|
+
"maxLoadedModels": {
|
|
54
|
+
"type": "integer",
|
|
55
|
+
"minimum": 1,
|
|
56
|
+
"maximum": 5,
|
|
57
|
+
"default": 2
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"decisionModels": [
|
|
62
|
+
{
|
|
63
|
+
"provider": "onnx",
|
|
64
|
+
"id": "gliclass-edge-v3.0",
|
|
65
|
+
"name": "GLiClass Edge v3"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"provider": "onnx",
|
|
69
|
+
"id": "gliclass-base-v3.0",
|
|
70
|
+
"name": "GLiClass Base v3"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"provider": "onnx",
|
|
74
|
+
"id": "gliner2.5-small-v1",
|
|
75
|
+
"name": "GLiNER 2.5 Small"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"provider": "onnx",
|
|
79
|
+
"id": "gliner2.5-base-v1",
|
|
80
|
+
"name": "GLiNER 2.5 Base"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"provider": "onnx",
|
|
84
|
+
"id": "deberta-v3-base-zeroshot-v2.0",
|
|
85
|
+
"name": "DeBERTa Zero-shot v2"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"provider": "onnx",
|
|
89
|
+
"id": "gliclass-instruct-edge-v1.0",
|
|
90
|
+
"name": "GLiClass Instruct Edge (local export)"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"provider": "onnx",
|
|
94
|
+
"id": "gliclass-instruct-base-v1.0",
|
|
95
|
+
"name": "GLiClass Instruct Base (local export)"
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openclaw/onnx",
|
|
3
|
+
"version": "2026.9.6",
|
|
4
|
+
"description": "Local ONNX decision models for OpenClaw",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/openclaw/openclaw"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@huggingface/tokenizers": "0.2.0",
|
|
12
|
+
"typebox": "1.3.30"
|
|
13
|
+
},
|
|
14
|
+
"optionalDependencies": {
|
|
15
|
+
"onnxruntime-node": "1.29.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@openclaw/plugin-sdk": "workspace:*"
|
|
19
|
+
},
|
|
20
|
+
"openclaw": {
|
|
21
|
+
"extensions": [
|
|
22
|
+
"./index.ts"
|
|
23
|
+
],
|
|
24
|
+
"install": {
|
|
25
|
+
"clawhubSpec": "clawhub:@openclaw/onnx",
|
|
26
|
+
"npmSpec": "@openclaw/onnx",
|
|
27
|
+
"defaultChoice": "npm",
|
|
28
|
+
"minHostVersion": ">=2026.9.6"
|
|
29
|
+
},
|
|
30
|
+
"compat": {
|
|
31
|
+
"pluginApi": ">=2026.9.6"
|
|
32
|
+
},
|
|
33
|
+
"build": {
|
|
34
|
+
"bundledDist": false,
|
|
35
|
+
"openclawVersion": "2026.9.6",
|
|
36
|
+
"workerEntries": [
|
|
37
|
+
"./src/inference.worker.ts"
|
|
38
|
+
],
|
|
39
|
+
"staticAssets": [
|
|
40
|
+
{
|
|
41
|
+
"source": "scripts/export-gliclass-instruct.py",
|
|
42
|
+
"output": "scripts/export-gliclass-instruct.py"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"release": {
|
|
47
|
+
"bundleRuntimeDependencies": false,
|
|
48
|
+
"publishToClawHub": true,
|
|
49
|
+
"publishToNpm": true
|
|
50
|
+
},
|
|
51
|
+
"runtimeExtensions": [
|
|
52
|
+
"./dist/index.js"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"dist/**",
|
|
57
|
+
"openclaw.plugin.json",
|
|
58
|
+
"README.md",
|
|
59
|
+
"assets/icon.png",
|
|
60
|
+
"assets/activity.svg"
|
|
61
|
+
],
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"openclaw": ">=2026.9.6"
|
|
64
|
+
},
|
|
65
|
+
"peerDependenciesMeta": {
|
|
66
|
+
"openclaw": {
|
|
67
|
+
"optional": true
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|