@openclaw/onnx 2026.10.10-beta.5 → 2026.11.5-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.
@@ -1,115 +0,0 @@
1
- import { Type } from "typebox";
2
- import { Value } from "typebox/value";
3
- //#region extensions/onnx/src/models/types.ts
4
- var UnsupportedInputError = class extends Error {};
5
- //#endregion
6
- //#region extensions/onnx/src/protocol.ts
7
- const ModelInputSchema = Type.Object({
8
- text: Type.String({ maxLength: 262144 }),
9
- labels: Type.Array(Type.String({
10
- minLength: 1,
11
- maxLength: 16384
12
- }), {
13
- minItems: 2,
14
- maxItems: 64
15
- }),
16
- task: Type.String({
17
- minLength: 1,
18
- maxLength: 1024
19
- }),
20
- instructions: Type.Optional(Type.String({ maxLength: 16384 })),
21
- descriptions: Type.Optional(Type.Record(Type.String(), Type.String({ maxLength: 16384 })))
22
- }, { additionalProperties: false });
23
- const ConfigSchema = Type.Object({
24
- modelDir: Type.String({
25
- minLength: 1,
26
- maxLength: 4096
27
- }),
28
- threads: Type.Integer({
29
- minimum: 1,
30
- maximum: 8
31
- }),
32
- maxLoadedModels: Type.Integer({
33
- minimum: 1,
34
- maximum: 5
35
- })
36
- }, { additionalProperties: false });
37
- const RequestSchema = Type.Union([
38
- Type.Object({
39
- kind: Type.Literal("init"),
40
- config: ConfigSchema
41
- }, { additionalProperties: false }),
42
- Type.Object({
43
- kind: Type.Literal("classify"),
44
- id: Type.Integer({ minimum: 1 }),
45
- model: Type.String({
46
- minLength: 1,
47
- maxLength: 128
48
- }),
49
- inputs: Type.Array(ModelInputSchema, {
50
- minItems: 1,
51
- maxItems: 32
52
- })
53
- }, { additionalProperties: false }),
54
- Type.Object({
55
- kind: Type.Literal("warm"),
56
- id: Type.Integer({ minimum: 1 }),
57
- models: Type.Array(Type.String({
58
- minLength: 1,
59
- maxLength: 128
60
- }), { maxItems: 5 })
61
- }, { additionalProperties: false })
62
- ]);
63
- const ErrorCodeSchema = Type.Union([
64
- Type.Literal("unsupported-input"),
65
- Type.Literal("model-missing"),
66
- Type.Literal("model-integrity"),
67
- Type.Literal("dependency-unavailable"),
68
- Type.Literal("runtime")
69
- ]);
70
- const ReplySchema = Type.Union([
71
- Type.Object({ kind: Type.Literal("ready") }, { additionalProperties: false }),
72
- Type.Object({
73
- kind: Type.Literal("results"),
74
- id: Type.Integer({ minimum: 1 }),
75
- results: Type.Array(Type.Object({
76
- logits: Type.Array(Type.Number(), {
77
- minItems: 2,
78
- maxItems: 64
79
- }),
80
- inputTokens: Type.Integer({ minimum: 1 })
81
- }, { additionalProperties: false }), { maxItems: 32 })
82
- }, { additionalProperties: false }),
83
- Type.Object({
84
- kind: Type.Literal("warmed"),
85
- id: Type.Integer({ minimum: 1 })
86
- }, { additionalProperties: false }),
87
- Type.Object({
88
- kind: Type.Literal("error"),
89
- id: Type.Integer({ minimum: 1 }),
90
- code: ErrorCodeSchema
91
- }, { additionalProperties: false })
92
- ]);
93
- function parseWorkerRequest(value) {
94
- if (!Value.Check(RequestSchema, value)) throw new Error("Invalid ONNX worker request");
95
- if (value.kind === "classify") {
96
- let bytes = 0;
97
- for (const input of value.inputs) {
98
- bytes += Buffer.byteLength(JSON.stringify(input));
99
- if (bytes > 1048576) throw new Error("ONNX inputs exceed one MiB");
100
- }
101
- }
102
- return value;
103
- }
104
- function parseWorkerReply(value) {
105
- if (!Value.Check(ReplySchema, value)) throw new Error("Invalid ONNX worker reply");
106
- return value;
107
- }
108
- var OnnxWorkerError = class extends Error {
109
- constructor(code) {
110
- super(`ONNX worker: ${code}`);
111
- this.code = code;
112
- }
113
- };
114
- //#endregion
115
- export { UnsupportedInputError as i, parseWorkerReply as n, parseWorkerRequest as r, OnnxWorkerError as t };