@flaxia/node 0.7.0 → 0.7.2

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.
Files changed (52) hide show
  1. package/dist/assets/ai-inference.js +9 -9
  2. package/dist/assets/ai-model-registry.js +0 -5
  3. package/dist/assets/cc-extract.js +20 -20
  4. package/dist/assets/container.js +59 -43
  5. package/dist/assets/decision.js +43 -36
  6. package/dist/assets/embed-gemma.js +28 -20
  7. package/dist/assets/image-process.js +78 -70
  8. package/dist/assets/nudenet.js +2 -2
  9. package/dist/assets/{VectorStoreEngine.js → sharedEngine.js} +67 -41
  10. package/dist/assets/vector-embed.js +49 -36
  11. package/dist/assets/vector-query.js +4 -4
  12. package/dist/assets/vector-store.js +4 -4
  13. package/dist/assets/webgpuProbe.js +87 -47
  14. package/dist/client/SignalingClient.d.ts.map +1 -1
  15. package/dist/client/light-preloader.d.ts +16 -6
  16. package/dist/client/light-preloader.d.ts.map +1 -1
  17. package/dist/executor/WorkerPool.d.ts +6 -0
  18. package/dist/executor/WorkerPool.d.ts.map +1 -1
  19. package/dist/executor/__tests__/resultLimits.test.d.ts +2 -0
  20. package/dist/executor/__tests__/resultLimits.test.d.ts.map +1 -0
  21. package/dist/executor/container-executor.d.ts +15 -0
  22. package/dist/executor/container-executor.d.ts.map +1 -1
  23. package/dist/executor/memoryProbe.d.ts +25 -1
  24. package/dist/executor/memoryProbe.d.ts.map +1 -1
  25. package/dist/executor/resultLimits.d.ts +19 -0
  26. package/dist/executor/resultLimits.d.ts.map +1 -0
  27. package/dist/index.js +416 -396
  28. package/dist/vector-store/HNSWIndex.d.ts +4 -1
  29. package/dist/vector-store/HNSWIndex.d.ts.map +1 -1
  30. package/dist/vector-store/VectorStoreEngine.d.ts +7 -1
  31. package/dist/vector-store/VectorStoreEngine.d.ts.map +1 -1
  32. package/dist/vector-store/__tests__/sharedEngine.test.d.ts +2 -0
  33. package/dist/vector-store/__tests__/sharedEngine.test.d.ts.map +1 -0
  34. package/dist/vector-store/sharedEngine.d.ts +13 -0
  35. package/dist/vector-store/sharedEngine.d.ts.map +1 -0
  36. package/dist/worker.js +163 -160
  37. package/dist/workloads/__tests__/nudenet-session-cache.test.d.ts +2 -0
  38. package/dist/workloads/__tests__/nudenet-session-cache.test.d.ts.map +1 -0
  39. package/dist/workloads/ai-inference.d.ts +8 -7
  40. package/dist/workloads/ai-inference.d.ts.map +1 -1
  41. package/dist/workloads/ai-model-registry.d.ts.map +1 -1
  42. package/dist/workloads/decision.d.ts +2 -0
  43. package/dist/workloads/decision.d.ts.map +1 -1
  44. package/dist/workloads/embed-gemma.d.ts.map +1 -1
  45. package/dist/workloads/image-process.d.ts +8 -0
  46. package/dist/workloads/image-process.d.ts.map +1 -1
  47. package/dist/workloads/nudenet.d.ts.map +1 -1
  48. package/dist/workloads/vector-embed.d.ts +6 -0
  49. package/dist/workloads/vector-embed.d.ts.map +1 -1
  50. package/dist/workloads/vector-query.d.ts.map +1 -1
  51. package/dist/workloads/vector-store.d.ts.map +1 -1
  52. package/package.json +2 -2
@@ -176,10 +176,10 @@ function de(e) {
176
176
  function fe(e) {
177
177
  return !_(e) || e.type !== "swarm-transport" ? !1 : typeof e.sessionId == "string" && !!e.sessionId && typeof e.taskId == "string" && !!e.taskId && (e.mode === "peer" || e.mode === "relay");
178
178
  }
179
- function x(e) {
179
+ function pe(e) {
180
180
  return !_(e) || e.type !== "swarm-flow" ? !1 : typeof e.sessionId == "string" && !!e.sessionId && typeof e.taskId == "string" && !!e.taskId && typeof e.paused == "boolean" && (e.attemptId === void 0 || typeof e.attemptId == "string" && !!e.attemptId && e.attemptId.length <= 128);
181
181
  }
182
- function S(e) {
182
+ function me(e) {
183
183
  return !_(e) || e.type !== "swarm-error" ? !1 : typeof e.sessionId == "string" && !!e.sessionId && typeof e.taskId == "string" && !!e.taskId && typeof e.error == "string";
184
184
  }
185
185
  new Set([
@@ -187,100 +187,140 @@ new Set([
187
187
  "qwen3.8-27b",
188
188
  "qwen3.6-35b-moe"
189
189
  ]);
190
- var C = new Set([
190
+ var he = new Set([
191
191
  "ai-inference",
192
192
  "image-process",
193
193
  "container",
194
194
  "vector-embed",
195
+ "vector-store",
195
196
  "vector-query",
196
197
  "nudenet",
197
198
  "swarm-inference",
198
199
  "embed-gemma"
199
- ]), w = "data.commoncrawl.org", T = 2 * 1024 * 1024, E = 4 * 1024 * 1024, D = 16e3, O = 3e4, k = 6e4, A = 2048, j = 4096, M = /^CC-MAIN-\d{4}-\d{2}$/, N = /^crawl-data\/CC-MAIN-\d{4}-\d{2}\/segments\/(?!\.{1,2}\/)[A-Za-z0-9._-]+\/warc\/(?!\.{1,2}\/)[A-Za-z0-9._-]+\.warc\.gz$/;
200
- function P(e) {
201
- return typeof e == "string" && N.test(e);
200
+ ]), ge = "data.commoncrawl.org", x = 2 * 1024 * 1024, S = 4 * 1024 * 1024, C = 16e3, w = 3e4, T = 6e4, E = 2048, D = 4096, O = /^CC-MAIN-\d{4}-\d{2}$/, k = /^crawl-data\/CC-MAIN-\d{4}-\d{2}\/segments\/(?!\.{1,2}\/)[A-Za-z0-9._-]+\/warc\/(?!\.{1,2}\/)[A-Za-z0-9._-]+\.warc\.gz$/;
201
+ function A(e) {
202
+ return typeof e == "string" && k.test(e);
202
203
  }
203
- function F(e, t) {
204
- return typeof t == "string" && M.test(t) && P(e) && e.startsWith(`crawl-data/${t}/`);
204
+ function j(e, t) {
205
+ return typeof t == "string" && O.test(t) && A(e) && e.startsWith(`crawl-data/${t}/`);
205
206
  }
206
- var I = "onnx-community/embeddinggemma-2-ONNX", L = "google/embeddinggemma-2", R = 1e5, z = 4e3, B = [
207
+ var M = "onnx-community/embeddinggemma-2-ONNX", N = "google/embeddinggemma-2", P = 1e5, F = 4e3, I = [
207
208
  768,
208
209
  512,
209
210
  256,
210
211
  128
211
212
  ];
212
- function V(e) {
213
- return typeof e == "number" && B.includes(e);
213
+ function L(e) {
214
+ return typeof e == "number" && I.includes(e);
214
215
  }
215
- var pe = 9e4, me = 600 * 1e3, he = 1440 * 60 * 1e3, ge = 6e4;
216
- function H(e) {
216
+ var _e = 9e4, ve = 600 * 1e3, ye = 1440 * 60 * 1e3, be = 6e4;
217
+ function R(e) {
217
218
  return typeof e == "object" && !!e && !Array.isArray(e);
218
219
  }
219
- function _e(e) {
220
- if (!H(e) || typeof e.modelId != "string" || !e.modelId || e.modelId.length > 128 || typeof e.revision != "string" || !e.revision || e.revision.length > 128 || typeof e.dtype != "string" || !e.dtype || e.dtype.length > 32 || e.backend !== "wasm" && e.backend !== "cpu" && e.backend !== "webgpu" || e.state !== "loading" && e.state !== "ready" && e.state !== "evicting" && e.state !== "failed" || !Number.isInteger(e.referenceCount) || e.referenceCount < 0 || e.referenceCount > 64) return !1;
220
+ function xe(e) {
221
+ if (!R(e) || typeof e.modelId != "string" || !e.modelId || e.modelId.length > 128 || typeof e.revision != "string" || !e.revision || e.revision.length > 128 || typeof e.dtype != "string" || !e.dtype || e.dtype.length > 32 || e.backend !== "wasm" && e.backend !== "cpu" && e.backend !== "webgpu" || e.state !== "loading" && e.state !== "ready" && e.state !== "evicting" && e.state !== "failed" || !Number.isInteger(e.referenceCount) || e.referenceCount < 0 || e.referenceCount > 64) return !1;
221
222
  if (e.layerRange === void 0) return !0;
222
223
  let t = e.layerRange;
223
224
  return Array.isArray(t) && t.length === 2 && Number.isInteger(t[0]) && Number.isInteger(t[1]) && t[0] >= 0 && t[1] > t[0] && t[1] <= 1024;
224
225
  }
225
- function ve(e, t = Date.now()) {
226
- if (!H(e) || e.version !== 1 || !Number.isSafeInteger(e.sampledAt) || !Number.isSafeInteger(e.expiresAt) || !Array.isArray(e.entries) || e.entries.length > 8 || !e.entries.every(_e)) return !1;
226
+ function Se(e, t = Date.now()) {
227
+ if (!R(e) || e.version !== 1 || !Number.isSafeInteger(e.sampledAt) || !Number.isSafeInteger(e.expiresAt) || !Array.isArray(e.entries) || e.entries.length > 8 || !e.entries.every(xe)) return !1;
227
228
  let n = e.sampledAt, r = e.expiresAt;
228
229
  return n <= t + 5e3 && n >= t - 6e4 && r > t && r > n && r - n <= 6e4;
229
230
  }
230
231
  //#endregion
232
+ //#region src/executor/resultLimits.ts
233
+ var z = 4 * 1024 * 1024;
234
+ function B(e, t = z) {
235
+ if (e == null) return 0;
236
+ if (typeof e == "string") return e.length * 2;
237
+ if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint") return 16;
238
+ if (typeof e == "function" || typeof e == "symbol") return 0;
239
+ if (Array.isArray(e)) {
240
+ let n = 8;
241
+ for (let r of e) if (n += B(r, t), n > t) return n;
242
+ return n;
243
+ }
244
+ if (typeof e == "object") {
245
+ let n = 8;
246
+ for (let r of Object.values(e)) if (n += B(r, t), n > t) return n;
247
+ return n;
248
+ }
249
+ return 0;
250
+ }
251
+ function Ce(e, t = z) {
252
+ return B(e, t) <= t;
253
+ }
254
+ //#endregion
231
255
  //#region src/executor/memoryProbe.ts
232
- var U = 2 * 1024 ** 3, W = 65536, ye = 16 * 1024 * 1024, be = 4096, G = null, xe = 0;
233
- function Se(e, t) {
234
- let n = Math.ceil(t / W);
256
+ var V = 2 * 1024 ** 3, H = 65536, we = 16 * 1024 * 1024, Te = 4096, Ee = 64 * 1024 * 1024, U = null, De = 0;
257
+ function Oe(e, t, n) {
258
+ let r = Math.ceil(t / H);
235
259
  try {
236
- e.grow(n);
260
+ e.grow(r);
237
261
  } catch {
238
262
  return !1;
239
263
  }
240
- let r = new Uint8Array(e.buffer);
241
- for (let e = 0; e < n; e++) r[e * W] = 0;
264
+ if (n <= 0) return !0;
265
+ let i = new Uint8Array(e.buffer), a = Math.min(i.byteLength, Math.floor(n / H) * H);
266
+ for (let e = 0; e < a; e += H) i[e] = 0;
242
267
  return !0;
243
268
  }
244
- function K(e = U, t = ye) {
245
- if (G) return G.bytes;
246
- xe++;
269
+ function W(e = V, t = we) {
270
+ if (U) return U.bytes;
271
+ De++;
247
272
  let n = Date.now(), r;
248
273
  try {
249
274
  r = new WebAssembly.Memory({ initial: 0 });
250
275
  } catch {
251
- return G = {
276
+ return U = {
252
277
  bytes: 0,
253
278
  sampledAt: n,
254
279
  measured: !1
255
280
  }, 0;
256
281
  }
257
- let i = Math.max(0, Math.floor(e)), a = Math.max(W, Math.floor(t)), o = 0, s = 0;
258
- for (; o < i && s < be;) {
259
- let e = Math.min(a, i - o);
260
- if (!Se(r, e)) break;
261
- o += e, s++;
282
+ let i = Math.max(0, Math.floor(e)), a = Math.max(H, Math.floor(t)), o = 0, s = 0, c = 0;
283
+ for (; o < i && c < Te;) {
284
+ let e = Math.min(a, i - o), t = Math.max(0, Math.min(e, Ee - s));
285
+ if (!Oe(r, e, t)) break;
286
+ o += e, s += t, c++;
262
287
  }
263
- return r = void 0, G = {
288
+ return r = void 0, U = {
264
289
  bytes: o,
265
290
  sampledAt: n,
266
291
  measured: !0
267
292
  }, o;
268
293
  }
269
- function Ce() {
270
- return G ? G.bytes : K();
294
+ function G() {
295
+ return U ? U.bytes : W();
271
296
  }
272
- function we() {
273
- return G || K(), {
274
- bytes: G?.measured ? G.bytes : null,
275
- sampledAt: G?.sampledAt ?? null
297
+ function ke() {
298
+ return U || W(), {
299
+ bytes: U?.measured ? U.bytes : null,
300
+ sampledAt: U?.sampledAt ?? null
276
301
  };
277
302
  }
278
- function Te() {
279
- return Ce() >= U;
303
+ function Ae() {
304
+ try {
305
+ let e = navigator.deviceMemory;
306
+ return typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0;
307
+ } catch {
308
+ return;
309
+ }
310
+ }
311
+ function je() {
312
+ let e = Ae();
313
+ return e === void 0 || e >= 8;
314
+ }
315
+ function K() {
316
+ return G() >= V && je();
317
+ }
318
+ function Me() {
319
+ return K() ? G() : 0;
280
320
  }
281
321
  //#endregion
282
322
  //#region src/executor/webgpuProbe.ts
283
- var Ee = 3, q = 750, J = 1500, Y = 600 * 1e3;
323
+ var Ne = 3, q = 750, J = 1500, Y = 600 * 1e3;
284
324
  async function X(e, t) {
285
325
  let n, r = new Promise((e) => {
286
326
  n = setTimeout(() => e({
@@ -312,7 +352,7 @@ function Z(e, t = Date.now()) {
312
352
  function Q() {
313
353
  return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
314
354
  }
315
- async function De(e) {
355
+ async function Pe(e) {
316
356
  let t, n = new Promise((e) => {
317
357
  t = setTimeout(() => e("timeout"), q);
318
358
  }), r = e.queue.onSubmittedWorkDone().then(() => "complete"), i = e.lost.then(() => "lost", () => "lost");
@@ -345,12 +385,12 @@ async function $() {
345
385
  entryPoint: "main"
346
386
  }
347
387
  }), f = [];
348
- for (let e = 0; e < Ee; e++) {
388
+ for (let e = 0; e < Ne; e++) {
349
389
  let e = u.createCommandEncoder(), t = e.beginComputePass();
350
390
  t.setPipeline(d), t.dispatchWorkgroups(1), t.end();
351
391
  let n = e.finish(), r = Q();
352
392
  u.queue.submit([n]);
353
- let i = await De(u);
393
+ let i = await Pe(u);
354
394
  if (i === "lost") return Z("device-lost", Date.now());
355
395
  if (i === "timeout") return Z("unavailable", Date.now());
356
396
  f.push(Math.max(0, Q() - r));
@@ -375,8 +415,8 @@ async function $() {
375
415
  } catch {}
376
416
  }
377
417
  }
378
- async function Oe() {
418
+ async function Fe() {
379
419
  return (await $()).capabilities;
380
420
  }
381
421
  //#endregion
382
- export { g as A, i as B, f as C, T as D, me as E, ee as F, R as G, V as H, m as I, ne as J, o as K, t as L, e as M, A as N, D as O, a as P, L as R, O as S, E as T, F as U, c as V, I as W, re as X, ie as Y, w as _, Te as a, de as b, y as c, p as d, pe as f, S as g, C as h, we as i, z as j, te as k, P as l, ve as m, $ as n, K as o, x as p, j as q, U as r, k as s, Oe as t, oe as u, ue as v, he as w, fe as x, ge as y, le as z };
422
+ export { re as $, x as A, t as B, de as C, ye as D, f as E, e as F, L as G, le as H, E as I, P as J, j as K, a as L, te as M, g as N, S as O, F as P, ie as Q, ee as R, be as S, w as T, i as U, N as V, c as W, D as X, o as Y, ne as Z, Se as _, ke as a, ge as b, z as c, y as d, A as f, pe as g, _e as h, Me as i, C as j, ve as k, Ce as l, p as m, $ as n, K as o, oe as p, M as q, V as r, W as s, Fe as t, T as u, he as v, fe as w, ue as x, me as y, m as z };
@@ -1 +1 @@
1
- {"version":3,"file":"SignalingClient.d.ts","sourceRoot":"","sources":["../../src/client/SignalingClient.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAgB,oBAAoB,EAAE,UAAU,EAAyB,YAAY,EAAE,MAAM,aAAa,CAAC;AAqBvH,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;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAg+BD,eAAO,MAAM,cAAc,GAAI,QAAQ,UAAU,KAAG,oBAwDnD,CAAC"}
1
+ {"version":3,"file":"SignalingClient.d.ts","sourceRoot":"","sources":["../../src/client/SignalingClient.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAgB,oBAAoB,EAAE,UAAU,EAAyB,YAAY,EAAE,MAAM,aAAa,CAAC;AAqBvH,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;IACnB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA+9BD,eAAO,MAAM,cAAc,GAAI,QAAQ,UAAU,KAAG,oBAwDnD,CAAC"}
@@ -4,13 +4,20 @@ export interface LightPreloaderTarget {
4
4
  dtype: string;
5
5
  }
6
6
  export interface LightPreloaderOptions {
7
- /** Model id to keep warm. Defaults to the M2M100 translate model. */
7
+ /** Model id to keep warm. Defaults to the PLaMO translate model. */
8
8
  model?: string;
9
9
  task?: string;
10
10
  dtype?: string;
11
11
  /** Full list of models to keep warm; wins over `model`/`task`/`dtype`. */
12
12
  targets?: LightPreloaderTarget[];
13
13
  onPreloaded?: () => void;
14
+ /**
15
+ * Whether the device has enough memory headroom for a multi-hundred-MB
16
+ * model. Preloading the translate model on a 4 GB phone commits hundreds of
17
+ * MB of wasm memory that the page then cannot reclaim, so the preloader must
18
+ * stay idle on constrained devices. Omitted = always allowed.
19
+ */
20
+ hasMemoryHeadroom?: () => boolean;
14
21
  }
15
22
  export type PreloadFn = (request: {
16
23
  task: string;
@@ -23,14 +30,16 @@ export type PreloadFn = (request: {
23
30
  * preloaded as int8 does not satisfy a q4f16 ondeviceOnly task.
24
31
  */
25
32
  export type IsPreloadedFn = (target: LightPreloaderTarget) => boolean;
26
- /** Defaults mirror `LIGHT_INFERENCE_TRANSLATE_*` in `ai-inference.ts`. */
27
- export declare const LIGHT_INFERENCE_TRANSLATE_MODEL = "Xenova/m2m100_418M";
28
- export declare const LIGHT_INFERENCE_TRANSLATE_TASK = "translation";
29
- export declare const LIGHT_INFERENCE_TRANSLATE_DTYPE = "q4f16";
30
- /** Flaxia's default translate model, mirroring `LIGHT_INFERENCE_PLAMO_*`. */
33
+ /** Flaxia's translate model, mirroring `LIGHT_INFERENCE_PLAMO_*`. */
31
34
  export declare const LIGHT_INFERENCE_PLAMO_TRANSLATE_MODEL = "TeamFlaxia/plamo-3-translate-0.8b-onnx";
32
35
  export declare const LIGHT_INFERENCE_PLAMO_TRANSLATE_TASK = "text-generation";
33
36
  export declare const LIGHT_INFERENCE_PLAMO_TRANSLATE_DTYPE = "q4f16";
37
+ /** @deprecated Use the PLaMO constants. Kept as aliases for host compatibility. */
38
+ export declare const LIGHT_INFERENCE_TRANSLATE_MODEL = "TeamFlaxia/plamo-3-translate-0.8b-onnx";
39
+ /** @deprecated Use the PLaMO constants. */
40
+ export declare const LIGHT_INFERENCE_TRANSLATE_TASK = "text-generation";
41
+ /** @deprecated Use the PLaMO constants. */
42
+ export declare const LIGHT_INFERENCE_TRANSLATE_DTYPE = "q4f16";
34
43
  /**
35
44
  * Light Inference idle preloader.
36
45
  *
@@ -56,6 +65,7 @@ export declare class LightPreloader {
56
65
  /** Cancel any scheduled preload (e.g. on suspend / consent denial). */
57
66
  stop(): void;
58
67
  private isUnconstrained;
68
+ private hasMemoryHeadroom;
59
69
  private preloadNow;
60
70
  }
61
71
  //# sourceMappingURL=light-preloader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"light-preloader.d.ts","sourceRoot":"","sources":["../../src/client/light-preloader.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AACnG;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC;AAEtE,0EAA0E;AAC1E,eAAO,MAAM,+BAA+B,uBAAuB,CAAC;AACpE,eAAO,MAAM,8BAA8B,gBAAgB,CAAC;AAC5D,eAAO,MAAM,+BAA+B,UAAU,CAAC;AAEvD,6EAA6E;AAC7E,eAAO,MAAM,qCAAqC,2CAA2C,CAAC;AAC9F,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endingControls;
26
26
  private static readonly MAX_PENDING_CONTROLS;
27
+ /**
28
+ * Bound on queued tasks. Each queued entry closes over its payload (up to a
29
+ * 16 MB base64 image), so an unbounded queue is a memory-amplification
30
+ * surface for redelivery storms.
31
+ */
32
+ private static readonly MAX_QUEUE_LENGTH;
27
33
  private _lastCpuLoad;
28
34
  private _hasCpuLoadSample;
29
35
  private _modelCacheSnapshot;
@@ -1 +1 @@
1
- {"version":3,"file":"WorkerPool.d.ts","sourceRoot":"","sources":["../../src/executor/WorkerPool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAqBxE,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC;AAED;;;;;;;;;;GAUG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,MAAM,CAA2B;IACzC,yEAAyE;IACzE,OAAO,CAAC,eAAe,CAAmD;IAC1E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAM;IAClD,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,mBAAmB,CAAuC;gBAEtD,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,SAAS;IAMlD,OAAO,CAAC,UAAU;IAYlB,GAAG,CACD,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,EAChB,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAA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KAAK,EAAE,WAAW,GAAG,OAAO;IAItC,mEAAmE;IACnE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO;IAKtD;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAmB1C,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,aAAa;IASrB,SAAS;IAmBT,MAAM;IAMN,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,gBAAgB,IAAI,OAAO,CAE9B;IAED,IAAI,kBAAkB,IAAI,sBAAsB,GAAG,IAAI,CAItD;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=resultLimits.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resultLimits.test.d.ts","sourceRoot":"","sources":["../../../src/executor/__tests__/resultLimits.test.ts"],"names":[],"mappings":""}
@@ -3,6 +3,21 @@ import type { ContainerPayload, ContainerResult } from "@flaxia/sdk";
3
3
  export declare const MAX_CONTAINER_IMAGE_BYTES: number;
4
4
  /** Aggregate decoded input-file ceiling; keeps reference downloads bounded. */
5
5
  export declare const MAX_CONTAINER_INPUT_BYTES: number;
6
+ /**
7
+ * Per-stream cap on captured container output. A chatty container can print
8
+ * gigabytes; accumulating that as JS strings and then joining it is enough to
9
+ * OOM a phone and to blow past the orchestrator's result-size limit.
10
+ */
11
+ export declare const MAX_CONTAINER_OUTPUT_CHARS = 1000000;
12
+ export interface BoundedOutputCapture {
13
+ write: (data: Uint8Array) => number;
14
+ text: () => string;
15
+ }
16
+ /**
17
+ * Build a stdout/stderr sink that keeps at most `MAX_CONTAINER_OUTPUT_CHARS`
18
+ * characters per stream and marks the result when it was truncated.
19
+ */
20
+ export declare function createBoundedOutputCapture(): BoundedOutputCapture;
6
21
  /** Memory bounds for `memoryLimitMb` (clamped): 32 MiB .. 4 GiB. */
7
22
  export declare const MIN_CONTAINER_MEMORY_MB = 32;
8
23
  export declare const MAX_CONTAINER_MEMORY_MB = 4096;
@@ -1 +1 @@
1
- {"version":3,"file":"container-executor.d.ts","sourceRoot":"","sources":["../../src/executor/container-executor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAc1F,wDAAwD;AACxD,eAAO,MAAM,yBAAyB,QAAoB,CAAC;AAK3D,+EAA+E;AAC/E,eAAO,MAAM,yBAAyB,QAAmB,CAAC;AAG1D,oEAAoE;AACpE,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,iEAAiE;AACjE,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAa/C;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAa/E;AAED,8EAA8E;AAC9E,wBAAgB,+BAA+B,IAAI,SAAS,MAAM,EAAE,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,SAAS,MAAM,EAAwB,GAAG,GAAG,CAyBtG;AAED,MAAM,WAAW,gBAAgB;IAC/B,iFAAiF;IACjF,YAAY,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB,CAmD1E;AAgBD,sDAAsD;AACtD,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAM/D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAiBjG;AA+CD,iFAAiF;AACjF,wBAAsB,qBAAq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,GAAG,GAAG,CAyBtG;AAED,MAAM,WAAW,gBAAgB;IAC/B,iFAAiF;IACjF,YAAY,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB,CAmD1E;AAgBD,sDAAsD;AACtD,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAM/D;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAiBjG;AAkED,iFAAiF;AACjF,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,aAAa,CAAC,EACxD,wBAAwB,GAAE,SAAS,MAAM,EAAO,GAC/C,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CA0DlC;AAED,eAAO,MAAM,YAAY,GACvB,SAAS,gBAAgB,EACzB,2BAA0B,SAAS,MAAM,EAAO,EAChD,wBAAuB,SAAS,MAAM,EAAwB,KAC7D,OAAO,CAAC,eAAe,CAoFzB,CAAC"}
@@ -18,11 +18,35 @@ export declare function getWasmMemoryProbeObservation(): {
18
18
  bytes: number | null;
19
19
  sampledAt: number | null;
20
20
  };
21
+ /**
22
+ * Minimum `navigator.deviceMemory` (GiB) accepted for a heavy workload when the
23
+ * API is available. The value is quantized (0.25/0.5/1/2/4/8), so a 4 GB phone
24
+ * reports `4` and is excluded, while an 8 GB laptop reports `8` and is allowed.
25
+ * The WASM probe alone cannot make this distinction: a 4 GB device can reserve
26
+ * 2 GiB of address space and still die when the model actually commits it.
27
+ */
28
+ export declare const MIN_HEAVY_DEVICE_MEMORY_GIB = 8;
29
+ /** The device's advertised RAM in GiB, or undefined when the API is unavailable. */
30
+ export declare function getDeviceMemoryGib(): number | undefined;
31
+ /**
32
+ * Whether the device's physical RAM leaves headroom for a multi-GB model. When
33
+ * `navigator.deviceMemory` is absent (mobile WebViews) we fall back to trusting
34
+ * the WASM probe rather than excluding the device outright.
35
+ */
36
+ export declare function hasDeviceMemoryHeadroom(): boolean;
21
37
  /**
22
38
  * Whether the device can commit the memory a heavy (multi-GB model) workload
23
- * needs. Uses the cached probe, so it never re-allocates.
39
+ * needs. Uses the cached probe, so it never re-allocates, and additionally
40
+ * requires physical-RAM headroom so a 4 GB phone is never routed a model that
41
+ * would get its tab killed.
24
42
  */
25
43
  export declare function hasEnoughWasmMemoryForHeavy(): boolean;
44
+ /**
45
+ * The memory value to advertise to the orchestrator. Returns 0 on a
46
+ * memory-constrained device so the coordinator's `isLowMemoryNode` gate stays
47
+ * truthful instead of routing heavy workloads from a raw reservation probe.
48
+ */
49
+ export declare function getAdvertisedWasmMemoryBytes(): number;
26
50
  /**
27
51
  * Drop the memoized probe and reset the run counter. Only for tests that
28
52
  * install a fake WebAssembly implementation; production code never needs to
@@ -1 +1 @@
1
- {"version":3,"file":"memoryProbe.d.ts","sourceRoot":"","sources":["../../src/executor/memoryProbe.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,gCAAgC,QAAgB,CAAC;AA8B9D;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,GAAE,MAAyC,EACtD,UAAU,GAAE,MAA0B,GACrC,MAAM,CA6BR;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAG3C;AAED,qGAAqG;AACrG,wBAAgB,6BAA6B,IAAI;IAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAMlG;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAGhD;AAED,+DAA+D;AAC/D,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C"}
1
+ {"version":3,"file":"memoryProbe.d.ts","sourceRoot":"","sources":["../../src/executor/memoryProbe.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,gCAAgC,QAAgB,CAAC;AAwC9D;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,GAAE,MAAyC,EACtD,UAAU,GAAE,MAA0B,GACrC,MAAM,CAgCR;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAG3C;AAED,qGAAqG;AACrG,wBAAgB,6BAA6B,IAAI;IAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAMlG;AAED;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C,oFAAoF;AACpF,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAOvD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAGjD;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,IAAI,MAAM,CAErD;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAGhD;AAED,+DAA+D;AAC/D,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Bound on a task result accepted from the worker.
3
+ *
4
+ * This matches the orchestrator's `MAX_RESULT_BYTES` (4 MiB) so the node fails
5
+ * a task locally instead of structured-cloning and JSON-serializing a result
6
+ * the coordinator would reject anyway.
7
+ */
8
+ export declare const MAX_TASK_RESULT_BYTES: number;
9
+ /**
10
+ * Estimate the serialized size of a result without building the JSON string.
11
+ *
12
+ * `JSON.stringify` on a large result doubles the peak (the result plus its
13
+ * serialized copy). This walks the value and returns as soon as the estimate
14
+ * exceeds `cap`, so an oversized result is rejected cheaply.
15
+ */
16
+ export declare function estimateSerializedBytes(value: unknown, cap?: number): number;
17
+ /** Whether a result is small enough to post back to the main thread. */
18
+ export declare function isResultWithinLimit(value: unknown, cap?: number): boolean;
19
+ //# sourceMappingURL=resultLimits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resultLimits.d.ts","sourceRoot":"","sources":["../../src/executor/resultLimits.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,QAAkB,CAAC;AAErD;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,GAAE,MAA8B,GAAG,MAAM,CAsBnG;AAED,wEAAwE;AACxE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,GAAE,MAA8B,GAAG,OAAO,CAEhG"}