@flaxia/node 0.3.1 → 0.3.3
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 +14 -10
- package/dist/assets/nudenet.js +5 -2
- package/dist/assets/vector-embed.js +7 -4
- package/dist/assets/vector-query.js +9 -7
- package/dist/assets/vector-store.js +9 -7
- package/dist/client/SignalingClient.d.ts.map +1 -1
- package/dist/consent/storage.d.ts +13 -0
- package/dist/consent/storage.d.ts.map +1 -1
- package/dist/executor/throttle.d.ts +13 -24
- package/dist/executor/throttle.d.ts.map +1 -1
- package/dist/index.js +119 -74
- package/dist/worker.js +78 -72
- package/dist/workloads/__tests__/wasm-threads.test.d.ts +2 -0
- package/dist/workloads/__tests__/wasm-threads.test.d.ts.map +1 -0
- package/dist/workloads/ai-inference.d.ts +6 -0
- package/dist/workloads/ai-inference.d.ts.map +1 -1
- package/dist/workloads/nudenet.d.ts +2 -0
- package/dist/workloads/nudenet.d.ts.map +1 -1
- package/dist/workloads/vector-embed.d.ts +1 -0
- package/dist/workloads/vector-embed.d.ts.map +1 -1
- package/dist/workloads/vector-query.d.ts +1 -0
- package/dist/workloads/vector-query.d.ts.map +1 -1
- package/dist/workloads/vector-store.d.ts +1 -0
- package/dist/workloads/vector-store.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -26,7 +26,9 @@ var r = [
|
|
|
26
26
|
"depth-estimation",
|
|
27
27
|
"feature-extraction",
|
|
28
28
|
"image-feature-extraction"
|
|
29
|
-
], i = /* @__PURE__ */ new Map(), a =
|
|
29
|
+
], i = /* @__PURE__ */ new Map(), a = 2, o = () => {
|
|
30
|
+
i.clear();
|
|
31
|
+
}, s = (e, t) => {
|
|
30
32
|
if (!t.tokenBuffer) return e;
|
|
31
33
|
let n = "", r = null, i = t.tokenBufferIntervalMs ?? 50, a = () => {
|
|
32
34
|
n &&= (e(n), ""), r = null;
|
|
@@ -34,15 +36,17 @@ var r = [
|
|
|
34
36
|
return (e) => {
|
|
35
37
|
n += e, r ||= setTimeout(a, i);
|
|
36
38
|
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
+
};
|
|
40
|
+
t.backends?.onnx?.wasm && (t.backends.onnx.wasm.numThreads = 1, t.backends.onnx.wasm.proxy = !1);
|
|
41
|
+
var c = async (t, o) => {
|
|
42
|
+
let { task: c, model: l, input: u, options: d = {} } = t;
|
|
39
43
|
if (!r.includes(c)) throw Error(`Invalid or unsupported task: ${c}. Supported tasks are: ${r.join(", ")}`);
|
|
40
|
-
if (self.crossOriginIsolated) {
|
|
41
|
-
let e = d.numThreads ?? navigator.hardwareConcurrency;
|
|
42
|
-
t.backends.onnx?.wasm && (t.backends.onnx.wasm.numThreads = Math.max(1, Math.min(e, navigator.hardwareConcurrency || 4)));
|
|
43
|
-
}
|
|
44
44
|
let f = `${c}:${l}`, p = i.get(f);
|
|
45
45
|
if (!p) {
|
|
46
|
+
if (i.size >= a) {
|
|
47
|
+
let e = i.keys().next().value;
|
|
48
|
+
i.delete(e);
|
|
49
|
+
}
|
|
46
50
|
let e = {
|
|
47
51
|
dtype: d.dtype ?? "q4f16",
|
|
48
52
|
device: d.device
|
|
@@ -60,13 +64,13 @@ var r = [
|
|
|
60
64
|
max_new_tokens: d.max_new_tokens ?? 128,
|
|
61
65
|
do_sample: d.do_sample ?? !1
|
|
62
66
|
};
|
|
63
|
-
d.temperature != null && (m.temperature = d.temperature), d.top_p != null && (m.top_p = d.top_p), d.top_k != null && (m.top_k = d.top_k), d.repetition_penalty != null && (m.repetition_penalty = d.repetition_penalty), d.src_lang != null && (m.src_lang = d.src_lang), d.tgt_lang != null && (m.tgt_lang = d.tgt_lang),
|
|
67
|
+
d.temperature != null && (m.temperature = d.temperature), d.top_p != null && (m.top_p = d.top_p), d.top_k != null && (m.top_k = d.top_k), d.repetition_penalty != null && (m.repetition_penalty = d.repetition_penalty), d.src_lang != null && (m.src_lang = d.src_lang), d.tgt_lang != null && (m.tgt_lang = d.tgt_lang), o && p.tokenizer && (m.streamer = new e(p.tokenizer, {
|
|
64
68
|
skip_prompt: !0,
|
|
65
69
|
skip_special_tokens: !0,
|
|
66
|
-
callback_function:
|
|
70
|
+
callback_function: s(o, d)
|
|
67
71
|
}));
|
|
68
72
|
let h = performance.now(), g = await p(u, m);
|
|
69
73
|
return console.log(`[flaxia-node] ai-inference: done task=${c} model=${l} execMs=${Math.round(performance.now() - h)} inputLen=${String(u).length}`), { output: g };
|
|
70
74
|
};
|
|
71
75
|
//#endregion
|
|
72
|
-
export {
|
|
76
|
+
export { c as handleAiInference, o as releaseCache };
|
package/dist/assets/nudenet.js
CHANGED
|
@@ -13947,7 +13947,7 @@ var yd = 320, bd = "1.26.0", xd = "https://huggingface.co/deepghs/nudenet_onnx/r
|
|
|
13947
13947
|
"BUTTOCKS_COVERED"
|
|
13948
13948
|
], wd = !1;
|
|
13949
13949
|
function Td() {
|
|
13950
|
-
wd ||= (S.wasm.wasmPaths = `https://cdn.jsdelivr.net/npm/onnxruntime-web@${bd}/dist/`, !0);
|
|
13950
|
+
wd ||= (S.wasm.wasmPaths = `https://cdn.jsdelivr.net/npm/onnxruntime-web@${bd}/dist/`, S.wasm.numThreads = 1, S.wasm.proxy = !1, !0);
|
|
13951
13951
|
}
|
|
13952
13952
|
var Ed = /* @__PURE__ */ new Map();
|
|
13953
13953
|
function Dd(e) {
|
|
@@ -14047,5 +14047,8 @@ var jd = async (e) => {
|
|
|
14047
14047
|
a.close();
|
|
14048
14048
|
}
|
|
14049
14049
|
};
|
|
14050
|
+
function Md() {
|
|
14051
|
+
Ed.clear();
|
|
14052
|
+
}
|
|
14050
14053
|
//#endregion
|
|
14051
|
-
export { jd as handleNudeNet };
|
|
14054
|
+
export { jd as handleNudeNet, Md as releaseCache };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
//#region src/workloads/vector-embed.ts
|
|
2
|
-
var e = null
|
|
3
|
-
|
|
2
|
+
var e = null, t = () => {
|
|
3
|
+
e = null;
|
|
4
|
+
};
|
|
5
|
+
async function n(t) {
|
|
4
6
|
let n = performance.now();
|
|
5
7
|
if (!e) {
|
|
6
8
|
let t = performance.now();
|
|
7
9
|
console.log("[flaxia-node] vector-embed: loading pipeline model=onnx-community/Qwen3-Embedding-0.6B-ONNX device=wasm");
|
|
8
|
-
let { pipeline: n } = await import("./transformers.web.js");
|
|
10
|
+
let { pipeline: n, env: r } = await import("./transformers.web.js");
|
|
11
|
+
r?.backends?.onnx?.wasm && (r.backends.onnx.wasm.numThreads = 1, r.backends.onnx.wasm.proxy = !1);
|
|
9
12
|
try {
|
|
10
13
|
e = await n("feature-extraction", "onnx-community/Qwen3-Embedding-0.6B-ONNX", { device: "wasm" });
|
|
11
14
|
} catch (e) {
|
|
@@ -25,4 +28,4 @@ async function t(t) {
|
|
|
25
28
|
};
|
|
26
29
|
}
|
|
27
30
|
//#endregion
|
|
28
|
-
export {
|
|
31
|
+
export { n as handleVectorEmbed, t as releaseCache };
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { t as e } from "./VectorStoreEngine.js";
|
|
2
2
|
//#region src/workloads/vector-query.ts
|
|
3
|
-
var t = null
|
|
4
|
-
|
|
3
|
+
var t = null, n = () => {
|
|
4
|
+
t = null;
|
|
5
|
+
};
|
|
6
|
+
async function r() {
|
|
5
7
|
return t || (t = new e(), await t.initialize()), t;
|
|
6
8
|
}
|
|
7
|
-
async function
|
|
8
|
-
let t = await
|
|
9
|
+
async function i(e) {
|
|
10
|
+
let t = await r(), n = performance.now();
|
|
9
11
|
try {
|
|
10
|
-
let
|
|
11
|
-
return console.log(`[flaxia-node] vector-query: done durationMs=${Math.round(performance.now() -
|
|
12
|
+
let r = await t.query(e);
|
|
13
|
+
return console.log(`[flaxia-node] vector-query: done durationMs=${Math.round(performance.now() - n)}`), r;
|
|
12
14
|
} catch (e) {
|
|
13
15
|
throw console.error(`[flaxia-node] vector-query: failed error=${e instanceof Error ? e.message : String(e)}`), e;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
//#endregion
|
|
17
|
-
export {
|
|
19
|
+
export { i as handleVectorQuery, n as releaseCache };
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { t as e } from "./VectorStoreEngine.js";
|
|
2
2
|
//#region src/workloads/vector-store.ts
|
|
3
|
-
var t = null
|
|
4
|
-
|
|
3
|
+
var t = null, n = () => {
|
|
4
|
+
t = null;
|
|
5
|
+
};
|
|
6
|
+
async function r() {
|
|
5
7
|
return t || (t = new e(), await t.initialize()), t;
|
|
6
8
|
}
|
|
7
|
-
async function
|
|
8
|
-
let t = await
|
|
9
|
+
async function i(e) {
|
|
10
|
+
let t = await r(), n = performance.now();
|
|
9
11
|
try {
|
|
10
|
-
let
|
|
11
|
-
return console.log(`[flaxia-node] vector-store: done durationMs=${Math.round(performance.now() -
|
|
12
|
+
let r = await t.store(e);
|
|
13
|
+
return console.log(`[flaxia-node] vector-store: done durationMs=${Math.round(performance.now() - n)}`), r;
|
|
12
14
|
} catch (e) {
|
|
13
15
|
throw console.error(`[flaxia-node] vector-store: failed error=${e instanceof Error ? e.message : String(e)}`), e;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
//#endregion
|
|
17
|
-
export {
|
|
19
|
+
export { i as handleVectorStore, n as releaseCache };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignalingClient.d.ts","sourceRoot":"","sources":["../../src/client/SignalingClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SignalingClient.d.ts","sourceRoot":"","sources":["../../src/client/SignalingClient.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK5D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA2QD,eAAO,MAAM,cAAc,GAAI,QAAQ,UAAU,SAsBhD,CAAC"}
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
declare function safeGet(key: string): string | null;
|
|
2
|
+
declare function safeSet(key: string, value: string): void;
|
|
3
|
+
declare function safeRemove(key: string): void;
|
|
1
4
|
export declare const hasConsent: () => boolean;
|
|
2
5
|
export declare const saveConsent: () => void;
|
|
6
|
+
export declare const safeLocalStorageGet: typeof safeGet;
|
|
7
|
+
export declare const safeLocalStorageSet: typeof safeSet;
|
|
8
|
+
export declare const safeLocalStorageRemove: typeof safeRemove;
|
|
9
|
+
/**
|
|
10
|
+
* Returns a UUID, falling back to a random v4 when `crypto.randomUUID` is
|
|
11
|
+
* unavailable (older browsers, or non-secure contexts where `crypto.randomUUID`
|
|
12
|
+
* is undefined on mobile Chrome). Never throws.
|
|
13
|
+
*/
|
|
14
|
+
export declare const safeRandomUUID: () => string;
|
|
15
|
+
export {};
|
|
3
16
|
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/consent/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/consent/storage.ts"],"names":[],"mappings":"AAWA,iBAAS,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM3C;AAED,iBAAS,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMjD;AAED,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAMrC;AAED,eAAO,MAAM,UAAU,QAAO,OAgB7B,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,IAG9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,gBAAU,CAAC;AAC3C,eAAO,MAAM,mBAAmB,gBAAU,CAAC;AAC3C,eAAO,MAAM,sBAAsB,mBAAa,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,MAajC,CAAC"}
|
|
@@ -1,31 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Estimates current CPU contention and throttles work accordingly.
|
|
3
|
-
*
|
|
4
|
-
* Runs inside the compute Worker (where the actual workload executes) rather
|
|
5
|
-
* than on the main thread, so the measurement reflects the thread that does
|
|
6
|
-
* the work. Load is estimated with a calibrated busy-loop: a fixed-iteration
|
|
7
|
-
* loop takes longer to finish when the system is busy, and the ratio to the
|
|
8
|
-
* idle baseline is the estimated load.
|
|
9
|
-
*
|
|
10
|
-
* There is no direct API for CPU usage in the browser, so this is a heuristic
|
|
11
|
-
* used to (a) avoid starting work while the machine is already loaded and
|
|
12
|
-
* (b) space out task starts so average CPU stays near `maxLoad`.
|
|
13
|
-
*/
|
|
14
1
|
export declare class CpuThrottle {
|
|
15
|
-
private baselineMs;
|
|
16
|
-
private lastLoad;
|
|
17
2
|
private readonly maxLoad;
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
3
|
+
private windowStart;
|
|
4
|
+
private windowBusyMs;
|
|
5
|
+
private lastLoad;
|
|
6
|
+
constructor(maxLoad?: number);
|
|
7
|
+
/**
|
|
8
|
+
* Charge a completed task's wall-clock duration (in ms) against the CPU budget.
|
|
9
|
+
* Call this from the worker once a workload has finished (incl. errors/timeouts).
|
|
10
|
+
*/
|
|
11
|
+
markTaskComplete(durationMs: number): void;
|
|
12
|
+
private estimate;
|
|
24
13
|
shouldPause(): Promise<boolean>;
|
|
25
14
|
/**
|
|
26
|
-
* Waits until the
|
|
27
|
-
* Bounded by `maxWaitMs` so a
|
|
28
|
-
*
|
|
15
|
+
* Waits until the rolling busy ratio is back under `maxLoad`.
|
|
16
|
+
* Bounded by `maxWaitMs` so a sustained heavy device cannot stall the queue
|
|
17
|
+
* forever.
|
|
29
18
|
*/
|
|
30
19
|
waitForSlot(maxWaitMs?: number): Promise<void>;
|
|
31
20
|
get lastMeasuredLoad(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/executor/throttle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/executor/throttle.ts"],"names":[],"mappings":"AAmBA,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,QAAQ,CAAK;gBAET,OAAO,SAAO;IAI1B;;;OAGG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAU1C,OAAO,CAAC,QAAQ;IAMV,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;;;OAIG;IACG,WAAW,CAAC,SAAS,SAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ9D,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;CACF"}
|
package/dist/index.js
CHANGED
|
@@ -39,17 +39,47 @@ var e = class {
|
|
|
39
39
|
c.remove(), t();
|
|
40
40
|
}), this.shadow.appendChild(s), this.shadow.appendChild(c);
|
|
41
41
|
}
|
|
42
|
-
}, t = "flaxia_consent_granted", n = "flaxia_consent_expiry", r = 720 * 60 * 60 * 1e3, i = ()
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
}, t = "flaxia_consent_granted", n = "flaxia_consent_expiry", r = 720 * 60 * 60 * 1e3, i = /* @__PURE__ */ new Map();
|
|
43
|
+
function a(e) {
|
|
44
|
+
try {
|
|
45
|
+
return localStorage.getItem(e);
|
|
46
|
+
} catch {
|
|
47
|
+
return i.get(e) ?? null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function o(e, t) {
|
|
51
|
+
try {
|
|
52
|
+
localStorage.setItem(e, t);
|
|
53
|
+
} catch {
|
|
54
|
+
i.set(e, t);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function s(e) {
|
|
58
|
+
try {
|
|
59
|
+
localStorage.removeItem(e);
|
|
60
|
+
} catch {
|
|
61
|
+
i.delete(e);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
var c = () => {
|
|
65
|
+
if (a(t) !== "true") return !1;
|
|
66
|
+
let e = a(n);
|
|
45
67
|
if (e) {
|
|
46
68
|
let r = parseInt(e, 10);
|
|
47
|
-
if (Date.now() > r) return
|
|
69
|
+
if (!Number.isFinite(r) || Date.now() > r) return s(t), s(n), !1;
|
|
48
70
|
}
|
|
49
71
|
return !0;
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
},
|
|
72
|
+
}, l = () => {
|
|
73
|
+
o(t, "true"), o(n, String(Date.now() + r));
|
|
74
|
+
}, u = a, d = o, f = () => {
|
|
75
|
+
try {
|
|
76
|
+
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
77
|
+
} catch {}
|
|
78
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
79
|
+
let t = Math.random() * 16 | 0;
|
|
80
|
+
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
81
|
+
});
|
|
82
|
+
}, p = (...e) => console.log("[flaxia-node]", ...e), m = class {
|
|
53
83
|
constructor(e, t = 3e5) {
|
|
54
84
|
this.worker = null, this.queue = [], this.active = null, this._lastCpuLoad = 0, this.workerUrl = e || "/worker.js", this.defaultTimeoutMs = t, this.initWorker();
|
|
55
85
|
}
|
|
@@ -63,66 +93,66 @@ var e = class {
|
|
|
63
93
|
}, this.worker = e;
|
|
64
94
|
}
|
|
65
95
|
run(e, t, n, r, i, a) {
|
|
66
|
-
return new Promise((
|
|
96
|
+
return new Promise((o, s) => {
|
|
67
97
|
if (!this.worker) {
|
|
68
|
-
|
|
98
|
+
s(/* @__PURE__ */ Error("Worker not available"));
|
|
69
99
|
return;
|
|
70
100
|
}
|
|
71
|
-
let
|
|
72
|
-
this.active ? (
|
|
101
|
+
let c = () => this.execute(e, t, n, r, i, a, o, s);
|
|
102
|
+
this.active ? (p(`task queued id=${e} workload=${t} (active task running)`), this.queue.push(c)) : c();
|
|
73
103
|
});
|
|
74
104
|
}
|
|
75
|
-
execute(e, t, n, r, i, a,
|
|
76
|
-
let
|
|
77
|
-
if (!
|
|
78
|
-
|
|
105
|
+
execute(e, t, n, r, i, a, o, s) {
|
|
106
|
+
let c = this.worker;
|
|
107
|
+
if (!c) {
|
|
108
|
+
s(/* @__PURE__ */ Error("Worker not available")), this.dequeue();
|
|
79
109
|
return;
|
|
80
110
|
}
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
let
|
|
84
|
-
if (
|
|
85
|
-
|
|
111
|
+
let l = r ?? this.defaultTimeoutMs, u = !1, d = performance.now();
|
|
112
|
+
p(`task start id=${e} workload=${t} timeoutMs=${l}`);
|
|
113
|
+
let f = (e) => {
|
|
114
|
+
if (u) return;
|
|
115
|
+
u = !0;
|
|
86
116
|
let t = this.active;
|
|
87
117
|
t && (clearTimeout(t.timer), t.removeListener()), this.active = null, e(), this.dequeue();
|
|
88
118
|
}, m = (n) => {
|
|
89
|
-
let { id: r, type: a, result:
|
|
119
|
+
let { id: r, type: a, result: c, error: l, token: u, cpuLoad: m } = n.data;
|
|
90
120
|
if (r === e) {
|
|
91
121
|
if (a === "token") {
|
|
92
|
-
i?.(
|
|
122
|
+
i?.(u);
|
|
93
123
|
return;
|
|
94
124
|
}
|
|
95
125
|
if (a === "heartbeat") {
|
|
96
126
|
typeof m == "number" && Number.isFinite(m) && (this._lastCpuLoad = Math.min(1, Math.max(0, m)));
|
|
97
127
|
return;
|
|
98
128
|
}
|
|
99
|
-
a === "done" ? (
|
|
129
|
+
a === "done" ? (p(`task done id=${e} workload=${t} durationMs=${Math.round(performance.now() - d)}`), f(() => o(c))) : a === "error" ? (p(`task failed id=${e} workload=${t} error=${l}`), f(() => s(Error(l)))) : (p(`task unknown-message id=${e} type=${String(a)}`), f(() => s(/* @__PURE__ */ Error(`Unknown message type: ${String(a)}`))));
|
|
100
130
|
}
|
|
101
|
-
}, h = () =>
|
|
102
|
-
|
|
103
|
-
},
|
|
131
|
+
}, h = () => c.removeEventListener("message", m), g = setTimeout(() => {
|
|
132
|
+
p(`task timeout id=${e} workload=${t} (worker terminated after ${l}ms)`), this.cleanupWorker(), f(() => s(/* @__PURE__ */ Error("TIMEOUT")));
|
|
133
|
+
}, l);
|
|
104
134
|
this.active = {
|
|
105
135
|
id: e,
|
|
106
|
-
resolve:
|
|
107
|
-
reject:
|
|
136
|
+
resolve: o,
|
|
137
|
+
reject: s,
|
|
108
138
|
timer: g,
|
|
109
|
-
worker:
|
|
139
|
+
worker: c,
|
|
110
140
|
removeListener: h
|
|
111
|
-
},
|
|
141
|
+
}, c.addEventListener("message", m);
|
|
112
142
|
try {
|
|
113
|
-
|
|
143
|
+
c.postMessage({
|
|
114
144
|
id: e,
|
|
115
145
|
workload: t,
|
|
116
146
|
payload: n,
|
|
117
|
-
timeoutMs:
|
|
147
|
+
timeoutMs: l,
|
|
118
148
|
config: a
|
|
119
149
|
});
|
|
120
150
|
} catch (e) {
|
|
121
|
-
|
|
151
|
+
f(() => s(e instanceof Error ? e : Error(String(e))));
|
|
122
152
|
}
|
|
123
153
|
}
|
|
124
154
|
handleWorkerError(e) {
|
|
125
|
-
|
|
155
|
+
p(`worker error error=${e.message}`);
|
|
126
156
|
let t = this.active;
|
|
127
157
|
this.cleanupWorker(), t && (clearTimeout(t.timer), this.active = null, t.reject(e), this.dequeue());
|
|
128
158
|
}
|
|
@@ -142,13 +172,13 @@ var e = class {
|
|
|
142
172
|
get lastCpuLoad() {
|
|
143
173
|
return this._lastCpuLoad;
|
|
144
174
|
}
|
|
145
|
-
},
|
|
175
|
+
}, h = (...e) => console.log("[flaxia-node]", ...e), g = (...e) => console.error("[flaxia-node]", ...e), _ = "flaxia_node_id", v = "flaxia_node_token", y = class {
|
|
146
176
|
constructor(e, t, n) {
|
|
147
|
-
this.config = e, this.workerPool = t, this.nodeId = n, this.ws = null, this.reconnectAttempts = 0, this.MAX_RECONNECT_DELAY = 3e4, this.destroyed = !1, this.suspended = !1, this.visibilityHandler = null;
|
|
177
|
+
this.config = e, this.workerPool = t, this.nodeId = n, this.ws = null, this.reconnectAttempts = 0, this.MAX_RECONNECT_DELAY = 3e4, this.destroyed = !1, this.suspended = !1, this.visibilityHandler = null, this.inflightTasks = /* @__PURE__ */ new Set();
|
|
148
178
|
}
|
|
149
179
|
async connect() {
|
|
150
180
|
if (this.destroyed) return;
|
|
151
|
-
if (
|
|
181
|
+
if (h(`connect nodeId=${this.nodeId}`), this.ws) {
|
|
152
182
|
let e = this.ws;
|
|
153
183
|
e.onclose = null;
|
|
154
184
|
try {
|
|
@@ -159,14 +189,14 @@ var e = class {
|
|
|
159
189
|
this.setupVisibilityHandler();
|
|
160
190
|
let e = await this.obtainToken();
|
|
161
191
|
if (!e) {
|
|
162
|
-
|
|
192
|
+
g("token acquisition failed; scheduling reconnect"), this.scheduleReconnect();
|
|
163
193
|
return;
|
|
164
194
|
}
|
|
165
195
|
let t = this.config.orchestratorUrl.replace(/\/+$/, "").replace(/^http/, "ws"), n = new URL(`${t}/crowd/signal`);
|
|
166
196
|
n.searchParams.set("token", e.token);
|
|
167
197
|
let r = new WebSocket(n.toString());
|
|
168
198
|
this.ws = r, r.onopen = () => {
|
|
169
|
-
this.reconnectAttempts = 0,
|
|
199
|
+
this.reconnectAttempts = 0, h(`signal connected ${n.toString()}`);
|
|
170
200
|
}, r.onmessage = async (e) => {
|
|
171
201
|
let t;
|
|
172
202
|
try {
|
|
@@ -183,12 +213,12 @@ var e = class {
|
|
|
183
213
|
}
|
|
184
214
|
if (t.type === "task") {
|
|
185
215
|
let e = t;
|
|
186
|
-
|
|
216
|
+
h(`task received taskId=${e.taskId} workload=${e.workload} timeoutMs=${e.timeoutMs ?? "default"}`);
|
|
187
217
|
try {
|
|
188
218
|
await this.handleTask(e);
|
|
189
219
|
} catch (n) {
|
|
190
220
|
let r = n instanceof Error ? n.message : String(n);
|
|
191
|
-
|
|
221
|
+
g(`task failed taskId=${e.taskId} workload=${e.workload} error=${r}`), this.send({
|
|
192
222
|
type: "error",
|
|
193
223
|
taskId: String(t.taskId ?? ""),
|
|
194
224
|
error: r
|
|
@@ -196,7 +226,7 @@ var e = class {
|
|
|
196
226
|
}
|
|
197
227
|
}
|
|
198
228
|
}, r.onclose = () => {
|
|
199
|
-
r.onclose = null, this.ws === r && (this.ws = null, !this.destroyed && (
|
|
229
|
+
r.onclose = null, this.ws === r && (this.ws = null, !this.destroyed && (h(`signal disconnected; scheduling reconnect attempt=${this.reconnectAttempts + 1}`), this.scheduleReconnect()));
|
|
200
230
|
};
|
|
201
231
|
}
|
|
202
232
|
scheduleReconnect() {
|
|
@@ -206,15 +236,21 @@ var e = class {
|
|
|
206
236
|
}, e);
|
|
207
237
|
}
|
|
208
238
|
disconnect() {
|
|
209
|
-
|
|
239
|
+
h(`disconnect nodeId=${this.nodeId}`), this.destroyed = !0, this.suspended = !1, this.removeVisibilityHandler();
|
|
210
240
|
try {
|
|
211
241
|
this.ws?.close();
|
|
212
242
|
} catch {}
|
|
213
243
|
this.ws = null;
|
|
244
|
+
try {
|
|
245
|
+
delete window[x];
|
|
246
|
+
} catch {}
|
|
247
|
+
try {
|
|
248
|
+
this.workerPool.terminate();
|
|
249
|
+
} catch {}
|
|
214
250
|
}
|
|
215
251
|
suspend() {
|
|
216
252
|
if (!(this.suspended || this.destroyed)) {
|
|
217
|
-
if (
|
|
253
|
+
if (h("suspended (visibility or manual)"), this.suspended = !0, this.ws) {
|
|
218
254
|
let e = this.ws;
|
|
219
255
|
e.onclose = null;
|
|
220
256
|
try {
|
|
@@ -226,14 +262,14 @@ var e = class {
|
|
|
226
262
|
}
|
|
227
263
|
}
|
|
228
264
|
resume() {
|
|
229
|
-
!this.suspended || this.destroyed || (
|
|
265
|
+
!this.suspended || this.destroyed || (h("resumed"), this.suspended = !1, this.workerPool.resume(), this.connect());
|
|
230
266
|
}
|
|
231
267
|
async obtainToken() {
|
|
232
268
|
try {
|
|
233
|
-
let e =
|
|
269
|
+
let e = u(v);
|
|
234
270
|
if (e) try {
|
|
235
271
|
let t = JSON.parse(e);
|
|
236
|
-
if (t.token && t.nodeId && t.expiresAt > Date.now() + 6e4) return
|
|
272
|
+
if (t.token && t.nodeId && t.expiresAt > Date.now() + 6e4) return h(`token cached nodeId=${t.nodeId} expiresIn=${Math.round((t.expiresAt - Date.now()) / 1e3)}s`), t;
|
|
237
273
|
} catch {}
|
|
238
274
|
let t = this.config.orchestratorUrl.replace(/\/+$/, ""), n = await fetch(`${t}/crowd/nodes/register`, {
|
|
239
275
|
method: "POST",
|
|
@@ -241,37 +277,45 @@ var e = class {
|
|
|
241
277
|
body: JSON.stringify({
|
|
242
278
|
siteId: this.config.siteId,
|
|
243
279
|
nodeId: this.nodeId,
|
|
244
|
-
capabilities: this.config.capabilities ?? ["ai-inference", "image-process"]
|
|
280
|
+
capabilities: this.config.capabilities ?? ["ai-inference", "image-process"],
|
|
281
|
+
deviceMemory: typeof navigator.deviceMemory == "number" ? navigator.deviceMemory : null
|
|
245
282
|
})
|
|
246
283
|
});
|
|
247
|
-
if (!n.ok) return
|
|
284
|
+
if (!n.ok) return g(`node register failed HTTP ${n.status} (${t}/crowd/nodes/register)`), null;
|
|
248
285
|
let r = await n.json();
|
|
249
|
-
if (!r.token) return
|
|
250
|
-
|
|
286
|
+
if (!r.token) return g("node register returned no token"), null;
|
|
287
|
+
h(`node registered nodeId=${this.nodeId} expiresIn=${Math.round((r.expiresAt - Date.now()) / 1e3)}s`);
|
|
251
288
|
try {
|
|
252
|
-
|
|
289
|
+
d(v, JSON.stringify(r));
|
|
253
290
|
} catch {}
|
|
254
291
|
return r;
|
|
255
292
|
} catch (e) {
|
|
256
|
-
return
|
|
293
|
+
return g("node register threw", e instanceof Error ? e.message : e), null;
|
|
257
294
|
}
|
|
258
295
|
}
|
|
259
296
|
send(e) {
|
|
260
297
|
this.ws && this.ws.readyState === WebSocket.OPEN && this.ws.send(JSON.stringify(e));
|
|
261
298
|
}
|
|
262
299
|
async handleTask(e) {
|
|
263
|
-
|
|
300
|
+
if (this.inflightTasks.has(e.taskId)) return;
|
|
301
|
+
this.inflightTasks.add(e.taskId);
|
|
302
|
+
let t = performance.now();
|
|
303
|
+
try {
|
|
304
|
+
let n = e.timeoutMs ? e.timeoutMs + 3e4 : void 0, r = await this.workerPool.run(e.taskId, e.workload, e.payload, n, (t) => {
|
|
305
|
+
this.send({
|
|
306
|
+
type: "progress",
|
|
307
|
+
taskId: e.taskId,
|
|
308
|
+
token: t
|
|
309
|
+
});
|
|
310
|
+
}, { maxCpuLoad: this.config.maxCpuLoad });
|
|
264
311
|
this.send({
|
|
265
|
-
type: "
|
|
312
|
+
type: "result",
|
|
266
313
|
taskId: e.taskId,
|
|
267
|
-
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
taskId: e.taskId,
|
|
273
|
-
payload: r
|
|
274
|
-
}), c(`task result sent taskId=${e.taskId} workload=${e.workload} durationMs=${Math.round(performance.now() - n)}`);
|
|
314
|
+
payload: r
|
|
315
|
+
}), h(`task result sent taskId=${e.taskId} workload=${e.workload} durationMs=${Math.round(performance.now() - t)}`);
|
|
316
|
+
} finally {
|
|
317
|
+
this.inflightTasks.delete(e.taskId);
|
|
318
|
+
}
|
|
275
319
|
}
|
|
276
320
|
setupVisibilityHandler() {
|
|
277
321
|
this.removeVisibilityHandler(), this.visibilityHandler = () => {
|
|
@@ -281,22 +325,23 @@ var e = class {
|
|
|
281
325
|
removeVisibilityHandler() {
|
|
282
326
|
this.visibilityHandler &&= (document.removeEventListener("visibilitychange", this.visibilityHandler), null);
|
|
283
327
|
}
|
|
284
|
-
},
|
|
285
|
-
let t = window[
|
|
328
|
+
}, b = "__flaxia_node_signal_client", x = "__flaxia_node_init_started", S = (e) => {
|
|
329
|
+
let t = window[b];
|
|
286
330
|
t && t.disconnect();
|
|
287
|
-
let n = new URL("./worker.js", "" + import.meta.url).href, r = new
|
|
288
|
-
i || (i =
|
|
289
|
-
let a = new
|
|
290
|
-
window[
|
|
291
|
-
},
|
|
292
|
-
if (
|
|
293
|
-
|
|
331
|
+
let n = new URL("./worker.js", "" + import.meta.url).href, r = new m(n), i = u(_);
|
|
332
|
+
i || (i = f(), d(_, i));
|
|
333
|
+
let a = new y(e, r, i);
|
|
334
|
+
window[b] = a, a.connect();
|
|
335
|
+
}, C = (t) => {
|
|
336
|
+
if (window[x]) return;
|
|
337
|
+
if (window[x] = !0, c()) {
|
|
338
|
+
S(t);
|
|
294
339
|
return;
|
|
295
340
|
}
|
|
296
341
|
let n = document.createElement("div");
|
|
297
342
|
n.id = "flaxia-consent-container", document.body.appendChild(n), new e(n, t.consent, () => {
|
|
298
|
-
|
|
343
|
+
l(), n.remove(), S(t);
|
|
299
344
|
});
|
|
300
345
|
};
|
|
301
346
|
//#endregion
|
|
302
|
-
export {
|
|
347
|
+
export { C as initFlaxiaNode };
|
package/dist/worker.js
CHANGED
|
@@ -2,36 +2,24 @@
|
|
|
2
2
|
function e(e) {
|
|
3
3
|
return new Promise((t) => setTimeout(t, e));
|
|
4
4
|
}
|
|
5
|
-
var t = class {
|
|
6
|
-
constructor(e = .15
|
|
7
|
-
this.
|
|
5
|
+
var t = 3e4, n = 3e4, r = class {
|
|
6
|
+
constructor(e = .15) {
|
|
7
|
+
this.windowStart = performance.now(), this.windowBusyMs = 0, this.lastLoad = 0, this.maxLoad = Math.max(.05, Math.min(.3, e));
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
return performance.now() - t;
|
|
13
|
-
}
|
|
14
|
-
sample() {
|
|
15
|
-
return [
|
|
16
|
-
this.busyLoop(),
|
|
17
|
-
this.busyLoop(),
|
|
18
|
-
this.busyLoop()
|
|
19
|
-
].sort((e, t) => e - t)[1];
|
|
20
|
-
}
|
|
21
|
-
async calibrate() {
|
|
22
|
-
this.busyLoop(), this.baselineMs = this.sample(), this.lastLoad = 0;
|
|
9
|
+
markTaskComplete(e) {
|
|
10
|
+
let n = performance.now();
|
|
11
|
+
n - this.windowStart > t && (this.windowStart = n, this.windowBusyMs = 0), this.windowBusyMs += Math.max(0, e), this.lastLoad = this.estimate();
|
|
23
12
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return this.lastLoad = t, t;
|
|
13
|
+
estimate() {
|
|
14
|
+
let e = performance.now() - this.windowStart;
|
|
15
|
+
return e <= 0 ? 0 : Math.min(1, Math.max(0, this.windowBusyMs / e));
|
|
28
16
|
}
|
|
29
17
|
async shouldPause() {
|
|
30
|
-
return
|
|
18
|
+
return this.estimate() > this.maxLoad;
|
|
31
19
|
}
|
|
32
|
-
async waitForSlot(t =
|
|
33
|
-
let
|
|
34
|
-
for (; await this.shouldPause() && !(performance.now() -
|
|
20
|
+
async waitForSlot(t = n) {
|
|
21
|
+
let r = performance.now();
|
|
22
|
+
for (; await this.shouldPause() && !(performance.now() - r > t);) await e(500);
|
|
35
23
|
}
|
|
36
24
|
get lastMeasuredLoad() {
|
|
37
25
|
return this.lastLoad;
|
|
@@ -39,71 +27,89 @@ var t = class {
|
|
|
39
27
|
get maxLoadValue() {
|
|
40
28
|
return this.maxLoad;
|
|
41
29
|
}
|
|
42
|
-
},
|
|
30
|
+
}, i = null, a = new Set([
|
|
31
|
+
"ai-inference",
|
|
32
|
+
"vector-embed",
|
|
33
|
+
"vector-query",
|
|
34
|
+
"nudenet",
|
|
35
|
+
"image-process",
|
|
36
|
+
"container"
|
|
37
|
+
]), o = 6e4;
|
|
38
|
+
function s() {
|
|
39
|
+
let e = navigator.deviceMemory;
|
|
40
|
+
return typeof e == "number" && e >= 4;
|
|
41
|
+
}
|
|
42
|
+
var c = /* @__PURE__ */ new Map(), l = null;
|
|
43
|
+
function u() {
|
|
44
|
+
for (let e of c.values()) try {
|
|
45
|
+
e();
|
|
46
|
+
} catch {}
|
|
47
|
+
c.clear();
|
|
48
|
+
}
|
|
49
|
+
function d() {
|
|
50
|
+
l && clearTimeout(l), l = setTimeout(() => {
|
|
51
|
+
l = null, u();
|
|
52
|
+
}, o);
|
|
53
|
+
}
|
|
54
|
+
async function f(e, t, n) {
|
|
55
|
+
switch (e) {
|
|
56
|
+
case "ai-inference":
|
|
57
|
+
let r = await import("./assets/ai-inference.js");
|
|
58
|
+
return c.set(e, r.releaseCache), await r.handleAiInference(t, n);
|
|
59
|
+
case "image-process": return await (await import("./assets/image-process.js")).handleImageProcess(t);
|
|
60
|
+
case "container": return await (await import("./assets/container.js")).handleContainer(t);
|
|
61
|
+
case "vector-embed":
|
|
62
|
+
let i = await import("./assets/vector-embed.js");
|
|
63
|
+
return c.set(e, i.releaseCache), await i.handleVectorEmbed(t);
|
|
64
|
+
case "vector-store":
|
|
65
|
+
let a = await import("./assets/vector-store.js");
|
|
66
|
+
return c.set(e, a.releaseCache), await a.handleVectorStore(t);
|
|
67
|
+
case "vector-query":
|
|
68
|
+
let o = await import("./assets/vector-query.js");
|
|
69
|
+
return c.set(e, o.releaseCache), await o.handleVectorQuery(t);
|
|
70
|
+
case "nudenet":
|
|
71
|
+
let s = await import("./assets/nudenet.js");
|
|
72
|
+
return c.set(e, s.releaseCache), await s.handleNudeNet(t);
|
|
73
|
+
default: throw Error(`Unknown workload type: ${e}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
43
76
|
self.onmessage = async (e) => {
|
|
44
|
-
let { id:
|
|
77
|
+
let { id: t, workload: n, payload: o, config: c } = e.data, l = performance.now();
|
|
45
78
|
try {
|
|
46
|
-
|
|
79
|
+
if (i ||= new r(c?.maxCpuLoad), console.log(`[flaxia-node:worker] task start id=${t} workload=${n}`), a.has(n) && !s()) {
|
|
80
|
+
let e = navigator.deviceMemory;
|
|
81
|
+
throw Error(`${n}: insufficient device memory (deviceMemory=${e ?? "unknown"})`);
|
|
82
|
+
}
|
|
83
|
+
await i.waitForSlot();
|
|
47
84
|
let e = setInterval(() => {
|
|
48
85
|
self.postMessage({
|
|
49
|
-
id:
|
|
86
|
+
id: t,
|
|
50
87
|
type: "heartbeat",
|
|
51
|
-
cpuLoad:
|
|
88
|
+
cpuLoad: i?.lastMeasuredLoad ?? 0
|
|
52
89
|
});
|
|
53
|
-
}, 1e4);
|
|
90
|
+
}, 1e4), u = performance.now();
|
|
54
91
|
try {
|
|
55
|
-
let e
|
|
92
|
+
let e = await f(n, o, (e) => {
|
|
56
93
|
self.postMessage({
|
|
57
|
-
id:
|
|
94
|
+
id: t,
|
|
58
95
|
type: "token",
|
|
59
96
|
token: e
|
|
60
97
|
});
|
|
61
|
-
};
|
|
62
|
-
switch (i) {
|
|
63
|
-
case "ai-inference":
|
|
64
|
-
let { handleAiInference: n } = await import("./assets/ai-inference.js");
|
|
65
|
-
e = await n(a, t);
|
|
66
|
-
break;
|
|
67
|
-
case "image-process":
|
|
68
|
-
let { handleImageProcess: r } = await import("./assets/image-process.js");
|
|
69
|
-
e = await r(a);
|
|
70
|
-
break;
|
|
71
|
-
case "container":
|
|
72
|
-
let { handleContainer: o } = await import("./assets/container.js");
|
|
73
|
-
e = await o(a);
|
|
74
|
-
break;
|
|
75
|
-
case "vector-embed":
|
|
76
|
-
let { handleVectorEmbed: s } = await import("./assets/vector-embed.js");
|
|
77
|
-
e = await s(a);
|
|
78
|
-
break;
|
|
79
|
-
case "vector-store":
|
|
80
|
-
let { handleVectorStore: c } = await import("./assets/vector-store.js");
|
|
81
|
-
e = await c(a);
|
|
82
|
-
break;
|
|
83
|
-
case "vector-query":
|
|
84
|
-
let { handleVectorQuery: l } = await import("./assets/vector-query.js");
|
|
85
|
-
e = await l(a);
|
|
86
|
-
break;
|
|
87
|
-
case "nudenet":
|
|
88
|
-
let { handleNudeNet: u } = await import("./assets/nudenet.js");
|
|
89
|
-
e = await u(a);
|
|
90
|
-
break;
|
|
91
|
-
default: throw Error(`Unknown workload type: ${i}`);
|
|
92
|
-
}
|
|
98
|
+
});
|
|
93
99
|
self.postMessage({
|
|
94
|
-
id:
|
|
100
|
+
id: t,
|
|
95
101
|
type: "done",
|
|
96
102
|
result: e
|
|
97
|
-
}), console.log(`[flaxia-node:worker] task done id=${
|
|
103
|
+
}), console.log(`[flaxia-node:worker] task done id=${t} workload=${n} durationMs=${Math.round(performance.now() - l)}`);
|
|
98
104
|
} finally {
|
|
99
|
-
clearInterval(e);
|
|
105
|
+
clearInterval(e), i.markTaskComplete(performance.now() - u), d();
|
|
100
106
|
}
|
|
101
107
|
} catch (e) {
|
|
102
|
-
let
|
|
103
|
-
console.error(`[flaxia-node:worker] task error id=${
|
|
104
|
-
id:
|
|
108
|
+
let r = e instanceof Error ? e.message : String(e);
|
|
109
|
+
console.error(`[flaxia-node:worker] task error id=${t} workload=${n} error=${r}`), self.postMessage({
|
|
110
|
+
id: t,
|
|
105
111
|
type: "error",
|
|
106
|
-
error:
|
|
112
|
+
error: r
|
|
107
113
|
});
|
|
108
114
|
}
|
|
109
115
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm-threads.test.d.ts","sourceRoot":"","sources":["../../../src/workloads/__tests__/wasm-threads.test.ts"],"names":[],"mappings":"AAuBA,OAAO,iBAAiB,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { AiInferencePayload, AiInferenceResult } from '@flaxia/sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Drops all cached model pipelines so the (potentially hundreds of MB of)
|
|
4
|
+
* transformers/onnxruntime memory can be garbage-collected. Called by the
|
|
5
|
+
* worker after an idle period so a node does not pin every model it ever saw.
|
|
6
|
+
*/
|
|
7
|
+
export declare const releaseCache: () => void;
|
|
2
8
|
export declare const handleAiInference: (payload: AiInferencePayload, onToken?: (token: string) => void) => Promise<AiInferenceResult>;
|
|
3
9
|
//# 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;
|
|
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;AAe7F;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;AAuCF,eAAO,MAAM,iBAAiB,GAC5B,SAAS,kBAAkB,EAC3B,UAAU,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,KAChC,OAAO,CAAC,iBAAiB,CAoE3B,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { NudeNetPayload, NudeNetResult } from '@flaxia/sdk';
|
|
2
|
+
export declare function configureOrt(): void;
|
|
2
3
|
export declare const handleNudeNet: (payload: NudeNetPayload) => Promise<NudeNetResult>;
|
|
4
|
+
export declare function releaseCache(): void;
|
|
3
5
|
//# sourceMappingURL=nudenet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nudenet.d.ts","sourceRoot":"","sources":["../../src/workloads/nudenet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"nudenet.d.ts","sourceRoot":"","sources":["../../src/workloads/nudenet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAoCnF,wBAAgB,YAAY,IAAI,IAAI,CAUnC;AAuID,eAAO,MAAM,aAAa,GAAU,SAAS,cAAc,KAAG,OAAO,CAAC,aAAa,CA6BlF,CAAC;AAEF,wBAAgB,YAAY,IAAI,IAAI,CAEnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-embed.d.ts","sourceRoot":"","sources":["../../src/workloads/vector-embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIzE,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"vector-embed.d.ts","sourceRoot":"","sources":["../../src/workloads/vector-embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIzE,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;AAEF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiD/F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-query.d.ts","sourceRoot":"","sources":["../../src/workloads/vector-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"vector-query.d.ts","sourceRoot":"","sources":["../../src/workloads/vector-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKzE,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;AAUF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAW/F"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { VectorStorePayload, VectorStoreResult } from '@flaxia/sdk';
|
|
2
|
+
export declare const releaseCache: () => void;
|
|
2
3
|
export declare function handleVectorStore(payload: VectorStorePayload): Promise<VectorStoreResult>;
|
|
3
4
|
export declare function handleVectorStoreAssignShard(rangeStart: number, rangeEnd: number): Promise<void>;
|
|
4
5
|
//# sourceMappingURL=vector-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-store.d.ts","sourceRoot":"","sources":["../../src/workloads/vector-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"vector-store.d.ts","sourceRoot":"","sources":["../../src/workloads/vector-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKzE,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;AAUF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAW/F;AAED,wBAAsB,4BAA4B,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGtG"}
|