@flaxia/node 0.5.1 → 0.6.0
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/assets/ai-inference.js +129 -83
- package/dist/assets/transformers.web.js +2 -2
- package/dist/assets/vector-embed.js +1 -1
- package/dist/assets/webgpuProbe.js +91 -83
- package/dist/client/SignalingClient.d.ts.map +1 -1
- package/dist/client/__tests__/light-preloader.test.d.ts +2 -0
- package/dist/client/__tests__/light-preloader.test.d.ts.map +1 -0
- package/dist/client/light-preloader.d.ts +47 -0
- package/dist/client/light-preloader.d.ts.map +1 -0
- package/dist/executor/WorkerPool.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +443 -356
- package/dist/worker.js +177 -168
- package/dist/workloads/ai-inference.d.ts +21 -0
- package/dist/workloads/ai-inference.d.ts.map +1 -1
- package/dist/workloads/ai-model-registry.d.ts +6 -0
- package/dist/workloads/ai-model-registry.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -4,6 +4,16 @@ export { DEFAULT_AI_MODEL_MAX_BYTES, MAX_AI_MODEL_MAX_BYTES, MAX_AI_INPUT_CHARS,
|
|
|
4
4
|
/** Bound work queued behind TextStreamer's synchronous callback API. */
|
|
5
5
|
export declare const MAX_PENDING_TOKEN_CALLBACKS = 64;
|
|
6
6
|
export declare const MAX_PENDING_TOKEN_CHARS: number;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the model already has a `ready` executable pipeline in memory.
|
|
9
|
+
* Guards `ondeviceOnly` tasks: they must fail before any download when the
|
|
10
|
+
* model is absent, so the check runs on the snapshot (no side effects).
|
|
11
|
+
*/
|
|
12
|
+
export declare const isAiModelPreloaded: (model: string) => boolean;
|
|
13
|
+
/** Model preloaded by the Light Inference idle preloader (small enough for WASM). */
|
|
14
|
+
export declare const LIGHT_INFERENCE_TRANSLATE_MODEL = "Xenova/m2m100_418M";
|
|
15
|
+
export declare const LIGHT_INFERENCE_TRANSLATE_TASK = "translation";
|
|
16
|
+
export declare const LIGHT_INFERENCE_TRANSLATE_DTYPE = "q4f16";
|
|
7
17
|
/**
|
|
8
18
|
* Drops all cached model pipelines so the (potentially hundreds of MB of)
|
|
9
19
|
* transformers/onnxruntime memory can be garbage-collected. Called by the
|
|
@@ -13,4 +23,15 @@ export declare const releaseCache: () => void;
|
|
|
13
23
|
/** Current executable pipelines; weight files in the Transformers cache are a separate disk-cache layer. */
|
|
14
24
|
export declare const getModelCacheSnapshot: () => NodeModelCacheSnapshot;
|
|
15
25
|
export declare const handleAiInference: (payload: AiInferencePayload, onToken?: (token: string) => void | Promise<void>) => Promise<AiInferenceResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Download + warm a model pipeline for later ondeviceOnly serving. Runs the
|
|
28
|
+
* same registry-fail-closed load as a real task but without generating.
|
|
29
|
+
* Idempotent: callers deduplicate via `isAiModelPreloaded()`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const preloadAiModel: (request: {
|
|
32
|
+
task: string;
|
|
33
|
+
model: string;
|
|
34
|
+
dtype?: string;
|
|
35
|
+
device?: string;
|
|
36
|
+
}) => Promise<void>;
|
|
16
37
|
//# sourceMappingURL=ai-inference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-inference.d.ts","sourceRoot":"","sources":["../../src/workloads/ai-inference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAsB,MAAM,aAAa,CAAC;AAC7F,OAAO,KAAK,EAAqB,sBAAsB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-inference.d.ts","sourceRoot":"","sources":["../../src/workloads/ai-inference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAsB,MAAM,aAAa,CAAC;AAC7F,OAAO,KAAK,EAAqB,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAgB7E,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,iBAAiB,GACvB,MAAM,qBAAqB,CAAC;AAa7B,wEAAwE;AACxE,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,eAAO,MAAM,uBAAuB,QAAa,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,KAAG,OAKlD,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,+BAA+B,uBAAuB,CAAC;AACpE,eAAO,MAAM,8BAA8B,gBAAgB,CAAC;AAC5D,eAAO,MAAM,+BAA+B,UAAU,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;AAEF,4GAA4G;AAC5G,eAAO,MAAM,qBAAqB,QAAO,sBAAqD,CAAC;AAkH/F,eAAO,MAAM,iBAAiB,GAC5B,SAAS,kBAAkB,EAC3B,UAAU,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAChD,OAAO,CAAC,iBAAiB,CAwH3B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAU,SAAS;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,KAAG,OAAO,CAAC,IAAI,CA6Bf,CAAC"}
|
|
@@ -58,6 +58,12 @@ export declare function resolveAiModel(model: unknown): AiModelDefinition;
|
|
|
58
58
|
export declare function resolveAiDevice(device: unknown): AllowedAiDevice | undefined;
|
|
59
59
|
/** Validate `options.dtype` against the node's allowlist. */
|
|
60
60
|
export declare function resolveAiDtype(dtype: unknown): AllowedAiDtype | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Validate `options.ondeviceOnly`. Absent = false (download on demand and
|
|
63
|
+
* allow coordinator delegation). Anything but a boolean is rejected so the
|
|
64
|
+
* flag cannot silently widen the download/delegation surface.
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolveOndeviceOnly(value: unknown): boolean;
|
|
61
67
|
/**
|
|
62
68
|
* Validate the task input: a bounded string or a bounded array of strings.
|
|
63
69
|
* Anything else (objects, numbers, huge arrays) is rejected before the model
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-model-registry.d.ts","sourceRoot":"","sources":["../../src/workloads/ai-model-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,iBAAiB;IAChC,0FAA0F;IAC1F,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,8CAA8C;AAC9C,eAAO,MAAM,0BAA0B,QAAoB,CAAC;AAC5D,kDAAkD;AAClD,eAAO,MAAM,sBAAsB,QAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-model-registry.d.ts","sourceRoot":"","sources":["../../src/workloads/ai-model-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,iBAAiB;IAChC,0FAA0F;IAC1F,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,8CAA8C;AAC9C,eAAO,MAAM,0BAA0B,QAAoB,CAAC;AAC5D,kDAAkD;AAClD,eAAO,MAAM,sBAAsB,QAAgB,CAAC;AAgCpD,sEAAsE;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1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flaxia/node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@bjorn3/browser_wasi_shim": "^0.4.2",
|
|
25
|
-
"@flaxia/sdk": "^0.
|
|
25
|
+
"@flaxia/sdk": "^0.6.0",
|
|
26
26
|
"@huggingface/transformers": "^4.2.0",
|
|
27
27
|
"onnxruntime-web": "1.26.0",
|
|
28
28
|
"rollup": "^4.61.0"
|