@flaxia/node 0.6.1 → 0.7.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.
Files changed (37) hide show
  1. package/README.md +2 -0
  2. package/dist/assets/ai-inference.js +83 -183
  3. package/dist/assets/ai-model-registry.js +127 -0
  4. package/dist/assets/cc-extract.js +5166 -0
  5. package/dist/assets/decision.js +142 -0
  6. package/dist/assets/embed-gemma.js +97 -0
  7. package/dist/assets/transformers.web.js +2 -2
  8. package/dist/assets/vector-embed.js +136 -26
  9. package/dist/assets/webgpuProbe.js +83 -66
  10. package/dist/client/SignalingClient.d.ts.map +1 -1
  11. package/dist/client/light-preloader.d.ts +6 -1
  12. package/dist/client/light-preloader.d.ts.map +1 -1
  13. package/dist/consent/notice.d.ts +3 -1
  14. package/dist/consent/notice.d.ts.map +1 -1
  15. package/dist/executor/WorkerPool.d.ts +1 -0
  16. package/dist/executor/WorkerPool.d.ts.map +1 -1
  17. package/dist/index.js +371 -364
  18. package/dist/worker.js +129 -120
  19. package/dist/workloads/__tests__/cc-extract.test.d.ts +2 -0
  20. package/dist/workloads/__tests__/cc-extract.test.d.ts.map +1 -0
  21. package/dist/workloads/__tests__/decision.test.d.ts +2 -0
  22. package/dist/workloads/__tests__/decision.test.d.ts.map +1 -0
  23. package/dist/workloads/__tests__/embed-gemma.test.d.ts +2 -0
  24. package/dist/workloads/__tests__/embed-gemma.test.d.ts.map +1 -0
  25. package/dist/workloads/__tests__/wasm-threads.test.d.ts.map +1 -1
  26. package/dist/workloads/ai-inference.d.ts +21 -2
  27. package/dist/workloads/ai-inference.d.ts.map +1 -1
  28. package/dist/workloads/ai-model-registry.d.ts.map +1 -1
  29. package/dist/workloads/cc-extract.d.ts +11 -0
  30. package/dist/workloads/cc-extract.d.ts.map +1 -0
  31. package/dist/workloads/decision.d.ts +21 -0
  32. package/dist/workloads/decision.d.ts.map +1 -0
  33. package/dist/workloads/embed-gemma.d.ts +8 -0
  34. package/dist/workloads/embed-gemma.d.ts.map +1 -0
  35. package/dist/workloads/vector-embed.d.ts +10 -0
  36. package/dist/workloads/vector-embed.d.ts.map +1 -1
  37. package/package.json +4 -3
package/dist/worker.js CHANGED
@@ -1,4 +1,4 @@
1
- import { F as e, O as t, P as n, _ as r, a as i, b as a, d as o, h as s, k as c, l, m as u, o as d, p as f, r as p, s as m, t as h, x as g, y as _ } from "./assets/webgpuProbe.js";
1
+ import { A as e, J as t, V as n, X as r, Y as i, a, b as o, c as s, g as c, h as l, o as u, p as d, r as f, t as p, v as m, x as h, y as g, z as _ } from "./assets/webgpuProbe.js";
2
2
  //#region src/executor/throttle.ts
3
3
  function v(e) {
4
4
  return new Promise((t) => setTimeout(t, e));
@@ -7,7 +7,7 @@ var y = 3e4, ee = 500, b = class extends Error {
7
7
  constructor(e, t, n) {
8
8
  super(`device is over its CPU budget (load ${e.toFixed(2)} > max ${t.toFixed(2)}) after waiting ${Math.round(n)}ms; task not started`), this.load = e, this.maxLoad = t, this.waitedMs = n, this.retryable = !0, this.name = "ThrottleBusyError";
9
9
  }
10
- }, x = class {
10
+ }, te = class {
11
11
  constructor(e = .15) {
12
12
  this.windowStart = performance.now(), this.windowBusyMs = 0, this.lastLoad = 0, this.dutyStartedAt = null, this.maxLoad = Math.max(.05, Math.min(.3, e));
13
13
  }
@@ -57,13 +57,13 @@ var y = 3e4, ee = 500, b = class extends Error {
57
57
  get maxLoadValue() {
58
58
  return this.maxLoad;
59
59
  }
60
- }, S = 4096;
61
- function te(e) {
60
+ }, x = 4096;
61
+ function ne(e) {
62
62
  let t = e.maxSeq;
63
- return typeof t == "number" && Number.isInteger(t) && t > 0 ? t : S;
63
+ return typeof t == "number" && Number.isInteger(t) && t > 0 ? t : x;
64
64
  }
65
- function C(e, t, n) {
66
- let { pos: r, tokens: i } = e.header, a = te(t);
65
+ function S(e, t, n) {
66
+ let { pos: r, tokens: i } = e.header, a = ne(t);
67
67
  if (!Number.isInteger(i) || i < 1) return {
68
68
  kind: "corrupt",
69
69
  reason: `carried ${i} token columns`
@@ -95,15 +95,15 @@ function C(e, t, n) {
95
95
  hidden: o
96
96
  };
97
97
  }
98
- function ne(e, t, n, r) {
99
- let i = _(e);
100
- return i ? i.header.pos !== t || i.header.requestId !== t ? { kind: "stale" } : C(i, n, r) : {
98
+ function re(e, t, n, r) {
99
+ let a = i(e);
100
+ return a ? a.header.pos !== t || a.header.requestId !== t ? { kind: "stale" } : S(a, n, r) : {
101
101
  kind: "corrupt",
102
102
  reason: "malformed frame header"
103
103
  };
104
104
  }
105
- async function re(t) {
106
- let { engine: i, link: a, semantics: o, promptTokens: s, chainLength: c, maxNewTokens: l } = t;
105
+ async function C(n) {
106
+ let { engine: i, link: a, semantics: o, promptTokens: s, chainLength: c, maxNewTokens: l } = n;
107
107
  if (s.length === 0) throw Error("swarm host requires at least one prompt token");
108
108
  i.reset();
109
109
  let u = null;
@@ -111,7 +111,7 @@ async function re(t) {
111
111
  if (e(t)) return;
112
112
  let n = u;
113
113
  if (!n) return;
114
- let r = ne(t, n.pos, i, o);
114
+ let r = re(t, n.pos, i, o);
115
115
  if (r.kind !== "stale") {
116
116
  if (u = null, r.kind === "corrupt") {
117
117
  n.reject(/* @__PURE__ */ Error(`swarm hop failed: ${r.reason}`));
@@ -120,14 +120,14 @@ async function re(t) {
120
120
  n.resolve(r.hidden);
121
121
  }
122
122
  });
123
- let d = (e, t) => c <= 1 ? Promise.resolve(e) : new Promise((n, i) => {
123
+ let d = (e, n) => c <= 1 ? Promise.resolve(e) : new Promise((r, i) => {
124
124
  u = {
125
- pos: t,
126
- resolve: n,
125
+ pos: n,
126
+ resolve: r,
127
127
  reject: i
128
- }, a.send(r({
129
- requestId: t,
130
- pos: t,
128
+ }, a.send(t({
129
+ requestId: n,
130
+ pos: n,
131
131
  tokens: 1
132
132
  }, o.packHidden(e)));
133
133
  }), f = async (e, t) => d(await i.embedRun(e, t), t), p = null;
@@ -137,36 +137,36 @@ async function re(t) {
137
137
  }
138
138
  if (!p) throw Error("swarm host produced no logits for the prompt");
139
139
  let m = [], h = s.length, g = o.argmax(p);
140
- for (; m.length < l && !(t.eosIds?.has(g) || (m.push(g), await t.onToken?.(g), m.length >= l));) {
140
+ for (; m.length < l && !(n.eosIds?.has(g) || (m.push(g), await n.onToken?.(g), m.length >= l));) {
141
141
  let e = await f(g, h++);
142
142
  p = await i.headFromHidden(e), g = o.argmax(p);
143
143
  }
144
- return c > 1 && a.send(n()), { tokens: m };
144
+ return c > 1 && a.send(r()), { tokens: m };
145
145
  }
146
- function ie(t) {
147
- let { engine: n, link: i, semantics: a } = t;
148
- return n.reset(), new Promise((t, o) => {
149
- let s = Promise.resolve(), c = !1;
150
- i.onFrame((l) => {
151
- if (!c) {
152
- if (e(l)) {
153
- c = !0, i.send(l), s = s.then(() => t());
146
+ function ie(n) {
147
+ let { engine: r, link: a, semantics: o } = n;
148
+ return r.reset(), new Promise((n, s) => {
149
+ let c = Promise.resolve(), l = !1;
150
+ a.onFrame((u) => {
151
+ if (!l) {
152
+ if (e(u)) {
153
+ l = !0, a.send(u), c = c.then(() => n());
154
154
  return;
155
155
  }
156
- s = s.then(async () => {
157
- if (c) return;
158
- let e = _(l);
156
+ c = c.then(async () => {
157
+ if (l) return;
158
+ let e = i(u);
159
159
  if (!e) throw Error("swarm frame has a malformed frame header");
160
- let t = C(e, n, a);
161
- if (t.kind === "corrupt") throw Error(`swarm frame is unusable: ${t.reason}`);
162
- let o = await n.runHidden(t.hidden, e.header.pos);
163
- i.send(r({
160
+ let n = S(e, r, o);
161
+ if (n.kind === "corrupt") throw Error(`swarm frame is unusable: ${n.reason}`);
162
+ let s = await r.runHidden(n.hidden, e.header.pos);
163
+ a.send(t({
164
164
  requestId: e.header.requestId,
165
165
  pos: e.header.pos,
166
166
  tokens: e.header.tokens
167
- }, a.packHidden(o)));
167
+ }, o.packHidden(s)));
168
168
  }).catch((e) => {
169
- c = !0, o(e instanceof Error ? e : Error(String(e)));
169
+ l = !0, s(e instanceof Error ? e : Error(String(e)));
170
170
  });
171
171
  }
172
172
  });
@@ -223,7 +223,7 @@ var ae = class {
223
223
  if (!Number.isInteger(e.chainLength) || e.chainLength < 1 || e.chainLength > 16) throw Error(`swarm slice has an invalid chain length: ${JSON.stringify(e.chainLength)}`);
224
224
  if (!Number.isInteger(e.index) || e.index < 0 || e.index >= e.chainLength) throw Error(`swarm slice has an invalid index: ${JSON.stringify(e.index)}`);
225
225
  if (e.role !== (e.index === 0 ? "host" : "worker")) throw Error(`swarm slice role ${e.role} does not match index ${e.index}`);
226
- if (!u(e.slice)) throw Error(`swarm slice is out of bounds: ${JSON.stringify(e.slice)}`);
226
+ if (!s(e.slice)) throw Error(`swarm slice is out of bounds: ${JSON.stringify(e.slice)}`);
227
227
  let t = e.index === 0;
228
228
  if (e.slice.hasEmbed !== t || e.slice.hasHead !== t) throw Error("swarm slice embed/head ownership does not match the host position");
229
229
  }
@@ -254,7 +254,7 @@ var ae = class {
254
254
  let r = t.encodePrompt(this.prompt), i = e.maxSeq ?? 4096;
255
255
  if (r.length + n > i) throw Error(`swarm request needs ${r.length + n} tokens but the model context holds ${i}`);
256
256
  this.generationStarted = !0;
257
- let a = performance.now(), { tokens: o } = await re({
257
+ let a = performance.now(), { tokens: o } = await C({
258
258
  chainLength: this.chainLength,
259
259
  promptTokens: r,
260
260
  maxNewTokens: n,
@@ -325,8 +325,8 @@ var w = class extends Error {
325
325
  super(e), this.name = "SwarmEngineUnavailableError";
326
326
  }
327
327
  };
328
- async function se(e, t) {
329
- if (!(await h()).webgpu) throw new w("WebGPU is not available in this context");
328
+ async function T(e, t) {
329
+ if (!(await p()).webgpu) throw new w("WebGPU is not available in this context");
330
330
  let n = t ?? ((e) => import(
331
331
  /* @vite-ignore */
332
332
  e
@@ -340,7 +340,7 @@ async function se(e, t) {
340
340
  if (!i || typeof i.create != "function") throw new w(`module at ${e} does not export Qwen35Engine.create`);
341
341
  return r;
342
342
  }
343
- function T(e, t, n, r) {
343
+ function se(e, t, n, r) {
344
344
  let i = !1, a = async (e) => {
345
345
  r?.();
346
346
  let t = await e();
@@ -495,7 +495,7 @@ async function pe() {
495
495
  maxStorageBufferBindingSize: t.limits.maxStorageBufferBindingSize
496
496
  } });
497
497
  }
498
- function me(e, t) {
498
+ function R(e, t) {
499
499
  let n = t.vocab, r = n["<|im_start|>"], i = n["<|im_end|>"], a = n["<think>"], o = n["</think>"], s = (e) => [
500
500
  r,
501
501
  ...t.encode("user\n" + e),
@@ -525,36 +525,36 @@ function me(e, t) {
525
525
  eosIds: new Set(c)
526
526
  };
527
527
  }
528
- function R(e) {
529
- let t = null, n = null, r = () => {
528
+ function z(e) {
529
+ let t = null, r = null, i = () => {
530
530
  if (!t) {
531
531
  let n = new URL("./swarm-engine.js", "" + import.meta.url).href;
532
- t = e ? e() : se(n).then((e) => e);
532
+ t = e ? e() : T(n).then((e) => e);
533
533
  }
534
534
  return t;
535
- }, i = async (e) => {
536
- let t = await r(), i = M(e);
537
- (!n || n.url !== i) && (n = {
538
- url: i,
539
- gguf: await fe(t, i)
535
+ }, a = async (e) => {
536
+ let t = await i(), n = M(e);
537
+ (!r || r.url !== n) && (r = {
538
+ url: n,
539
+ gguf: await fe(t, n)
540
540
  });
541
- let a = Number(n.gguf.meta["qwen35.block_count"]) - Number(n.gguf.meta["qwen35.nextn_predict_layers"] || 0);
541
+ let a = Number(r.gguf.meta["qwen35.block_count"]) - Number(r.gguf.meta["qwen35.nextn_predict_layers"] || 0);
542
542
  if (!Number.isInteger(a) || a < 1) throw new w(`model ${e} has no qwen35 trunk layers`);
543
543
  return {
544
544
  mod: t,
545
- url: i,
546
- gguf: n.gguf,
545
+ url: n,
546
+ gguf: r.gguf,
547
547
  layers: a
548
548
  };
549
549
  };
550
550
  return {
551
551
  async plan(e, t) {
552
- let { layers: n } = await i(t);
553
- return a({
552
+ let { layers: r } = await a(t);
553
+ return n({
554
554
  sessionId: "",
555
555
  taskId: "",
556
556
  model: t,
557
- layers: n,
557
+ layers: r,
558
558
  nodes: e.map((e) => ({
559
559
  nodeId: e.nodeId,
560
560
  capacity: e.capacity
@@ -569,9 +569,9 @@ function R(e) {
569
569
  e.end
570
570
  ]);
571
571
  k(n, A(t, e, "loading", 1));
572
- let r, a = !1;
572
+ let r, i = !1;
573
573
  try {
574
- let { mod: o, url: s, gguf: c } = await i(t);
574
+ let { mod: o, url: s, gguf: c } = await a(t);
575
575
  r = await pe();
576
576
  let l = null, u = r;
577
577
  u.addEventListener?.("uncapturederror", () => {
@@ -581,7 +581,7 @@ function R(e) {
581
581
  });
582
582
  let d = () => {
583
583
  if (l) throw new w(l);
584
- }, f = me(o, o.makeTokenizer(o.tokenizerFromGGUF(c.meta))), p = (e) => I(s, e.byteOffset, e.byteOffset + e.byteLength - 1);
584
+ }, f = R(o, o.makeTokenizer(o.tokenizerFromGGUF(c.meta))), p = (e) => I(s, e.byteOffset, e.byteOffset + e.byteLength - 1);
585
585
  c.streamEntry = (e) => o.streamEntryToGPU(r, e, (e) => L(s, e.byteOffset, e.byteOffset + e.byteLength - 1), { staging: 4 * 1024 * 1024 });
586
586
  let m = await o.qwen35Weights(c, p, {
587
587
  lo: e.start,
@@ -596,69 +596,69 @@ function R(e) {
596
596
  hasEmbed: e.hasEmbed,
597
597
  hasHead: e.hasHead,
598
598
  vocab: h,
599
- maxSeq: Math.min(S, Number(c.meta["qwen35.context_length"]) || 4096),
599
+ maxSeq: Math.min(x, Number(c.meta["qwen35.context_length"]) || 4096),
600
600
  batchCols: 4,
601
601
  weights: m
602
602
  });
603
603
  d();
604
- let _ = T(g, r, () => {
604
+ let _ = se(g, r, () => {
605
605
  k(n, A(t, e, "evicting", 0)), queueMicrotask(() => O.delete(n));
606
606
  }, d);
607
- return a = !0, k(n, A(t, e, "ready", 1)), {
607
+ return i = !0, k(n, A(t, e, "ready", 1)), {
608
608
  engine: _,
609
609
  semantics: f,
610
610
  warm: P > 0 && F === 0
611
611
  };
612
- } catch (i) {
613
- if (k(n, A(t, e, "failed", 0)), !a) try {
612
+ } catch (a) {
613
+ if (k(n, A(t, e, "failed", 0)), !i) try {
614
614
  r?.destroy?.();
615
615
  } catch {}
616
- throw i;
616
+ throw a;
617
617
  }
618
618
  }
619
619
  };
620
620
  }
621
621
  //#endregion
622
622
  //#region src/swarm/messages.ts
623
- function he(e) {
624
- return o(e) || l(e) || f(e) || c(e) || m(e) || t(e);
623
+ function me(e) {
624
+ return _(e) || m(e) || o(e) || h(e) || d(e) || c(e);
625
625
  }
626
- function ge(e) {
626
+ function he(e) {
627
627
  if (!e || typeof e != "object") return !1;
628
628
  let t = e;
629
- return t.type === "swarm-control" && typeof t.id == "string" && he(t.message);
629
+ return t.type === "swarm-control" && typeof t.id == "string" && me(t.message);
630
630
  }
631
631
  //#endregion
632
632
  //#region src/worker/main.worker.ts
633
- var z = null, _e = y, ve = 1, B = 15e3, V = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ new Set(), U = /* @__PURE__ */ new Map();
634
- function W(e) {
635
- H.delete(e);
636
- let t = U.get(e);
633
+ var B = null, ge = y, _e = 1, V = 15e3, H = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), W = /* @__PURE__ */ new Map();
634
+ function G(e) {
635
+ U.delete(e);
636
+ let t = W.get(e);
637
637
  if (t) {
638
- U.delete(e);
638
+ W.delete(e);
639
639
  for (let e of t) e();
640
640
  }
641
641
  }
642
- function ye(e) {
643
- return H.has(e) ? new Promise((t) => {
644
- let n = U.get(e) ?? /* @__PURE__ */ new Set();
645
- n.add(t), U.set(e, n);
642
+ function ve(e) {
643
+ return U.has(e) ? new Promise((t) => {
644
+ let n = W.get(e) ?? /* @__PURE__ */ new Set();
645
+ n.add(t), W.set(e, n);
646
646
  }) : Promise.resolve();
647
647
  }
648
- var G = null, K = null, q = null, be = 6e4;
649
- async function xe() {
648
+ var K = null, q = null, J = null, ye = 6e4;
649
+ async function be() {
650
650
  for (let e = 0;; e++) try {
651
- await z.waitForSlot(_e);
651
+ await B.waitForSlot(ge);
652
652
  return;
653
653
  } catch (t) {
654
654
  if (!(t instanceof b)) throw t;
655
- if (e >= ve) throw Error(`device CPU busy: ${t.message}; task not started, retry on an idle node (retryable)`);
656
- console.warn(`[flaxia-node:worker] ${t.message}; cooling down ${B}ms before retrying`), await new Promise((e) => setTimeout(e, B));
655
+ if (e >= _e) throw Error(`device CPU busy: ${t.message}; task not started, retry on an idle node (retryable)`);
656
+ console.warn(`[flaxia-node:worker] ${t.message}; cooling down ${V}ms before retrying`), await new Promise((e) => setTimeout(e, V));
657
657
  }
658
658
  }
659
- function Se(e) {
659
+ function xe(e) {
660
660
  let t = (t) => {
661
- let n = V.get(e);
661
+ let n = H.get(e);
662
662
  if (n !== void 0) throw Error(n);
663
663
  self.postMessage({
664
664
  id: e,
@@ -667,18 +667,18 @@ function Se(e) {
667
667
  });
668
668
  };
669
669
  return async (n) => {
670
- await ye(e), t(n), await z?.yieldIfOverloaded();
670
+ await ve(e), t(n), await B?.yieldIfOverloaded();
671
671
  };
672
672
  }
673
- var J = d(), Y = J >= p;
674
- console.log(`[flaxia-node:worker] startup memory probe wasmMemoryBytes=${J} capable=${Y}`);
675
- function Ce() {
676
- return i();
673
+ var Y = u();
674
+ console.log(`[flaxia-node:worker] startup memory probe wasmMemoryBytes=${Y} capable=${Y >= f}`);
675
+ function Se() {
676
+ return a();
677
677
  }
678
678
  var X = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map();
679
679
  Z.set("swarm-inference", j);
680
680
  var Q = null;
681
- function we() {
681
+ function Ce() {
682
682
  for (let e of X.values()) try {
683
683
  e();
684
684
  } catch {}
@@ -699,16 +699,19 @@ function $() {
699
699
  entries: t
700
700
  };
701
701
  }
702
- function Te() {
702
+ function we() {
703
703
  Q && clearTimeout(Q), Q = setTimeout(() => {
704
- Q = null, we();
705
- }, be);
704
+ Q = null, Ce();
705
+ }, ye);
706
706
  }
707
- async function Ee(e, t, n, r) {
707
+ async function Te(e, t, n, r, i) {
708
708
  switch (e) {
709
- case "ai-inference":
710
- let i = await import("./assets/ai-inference.js").then((e) => e.s);
711
- return X.set(e, i.releaseCache), Z.set(e, i.getModelCacheSnapshot), await i.handleAiInference(t, n);
709
+ case "ai-inference": {
710
+ let r = await import("./assets/ai-inference.js").then((e) => e.s);
711
+ X.set(e, r.releaseCache), Z.set(e, r.getModelCacheSnapshot);
712
+ let i = await import("./assets/decision.js");
713
+ return X.set("decision", i.releaseCache), await r.handleAiInference(t, n);
714
+ }
712
715
  case "ai-preload": {
713
716
  let e = await import("./assets/ai-inference.js").then((e) => e.s);
714
717
  X.set("ai-inference", e.releaseCache), Z.set("ai-inference", e.getModelCacheSnapshot);
@@ -729,14 +732,18 @@ async function Ee(e, t, n, r) {
729
732
  case "nudenet":
730
733
  let c = await import("./assets/nudenet.js");
731
734
  return X.set(e, c.releaseCache), await c.handleNudeNet(t);
735
+ case "cc-extract": return await (await import("./assets/cc-extract.js")).handleCcExtract(t, r?.ccRangeOrigins ?? []);
736
+ case "embed-gemma":
737
+ let l = await import("./assets/embed-gemma.js");
738
+ return X.set(e, l.releaseCache), await l.handleEmbedGemma(t, i);
732
739
  default: throw Error(`Unknown workload type: ${e}`);
733
740
  }
734
741
  }
735
- function De(e, t, n) {
742
+ function Ee(e, t, n) {
736
743
  return new Promise((r, i) => {
737
744
  let a = new ae({
738
745
  initial: t,
739
- runtime: R(),
746
+ runtime: z(),
740
747
  sendControl: (t) => self.postMessage({
741
748
  id: e,
742
749
  type: "swarm-message",
@@ -749,70 +756,72 @@ function De(e, t, n) {
749
756
  }, [t]),
750
757
  emitToken: n,
751
758
  onDone: (e) => {
752
- G === a && (G = null, K = null), r(e);
759
+ K === a && (K = null, q = null), r(e);
753
760
  },
754
761
  onError: (e) => {
755
- G === a && (G = null, K = null), i(Error(e));
762
+ K === a && (K = null, q = null), i(Error(e));
756
763
  }
757
764
  });
758
- G = a, K = e, a.start();
765
+ K = a, q = e, a.start();
759
766
  });
760
767
  }
761
768
  self.onmessage = async (e) => {
762
769
  let t = e.data;
763
770
  if (t?.type === "token-flow") {
764
771
  let e = typeof t.id == "string" ? t.id : "";
765
- e && q === e && typeof t.paused == "boolean" && (t.paused ? H.add(e) : W(e));
772
+ e && J === e && typeof t.paused == "boolean" && (t.paused ? U.add(e) : G(e));
766
773
  return;
767
774
  }
768
775
  if (t?.type === "swarm-control") {
769
- if (!ge(t)) {
776
+ if (!he(t)) {
770
777
  console.warn("[flaxia-node:worker] dropped malformed swarm-control message");
771
778
  return;
772
779
  }
773
- G && G.handleControl(t.message);
780
+ K && K.handleControl(t.message);
774
781
  return;
775
782
  }
776
783
  if (t?.type === "swarm-frame") {
777
- t.frame instanceof ArrayBuffer ? G?.handleFrame(t.frame) : console.warn("[flaxia-node:worker] dropped malformed swarm-frame message");
784
+ t.frame instanceof ArrayBuffer ? K?.handleFrame(t.frame) : console.warn("[flaxia-node:worker] dropped malformed swarm-frame message");
778
785
  return;
779
786
  }
780
787
  if (t?.type === "abort") {
781
788
  let e = t.id, n = typeof t.reason == "string" && t.reason ? t.reason : "aborted by the coordinator";
782
- W(e), G && K === e ? G.abort(n) : q === e && V.set(e, n);
789
+ G(e), K && q === e ? K.abort(n) : J === e && H.set(e, n);
783
790
  return;
784
791
  }
785
792
  let { id: n, workload: r, payload: i, config: a } = t, o = performance.now();
786
- q = n, W(n);
793
+ J = n, G(n);
787
794
  try {
788
- if (z ||= new x(a?.maxCpuLoad), console.log(`[flaxia-node:worker] task start id=${n} workload=${r}`), !Y) throw Error(`node incapable: insufficient WASM memory (${J} bytes < ${p}); rejecting all tasks`);
789
- if (s.has(r) && !Ce()) throw Error(`${r}: insufficient WASM memory (${J} bytes < ${p})`);
790
- await xe(), z.beginWork();
795
+ if (B ||= new te(a?.maxCpuLoad), console.log(`[flaxia-node:worker] task start id=${n} workload=${r}`), l.has(r) && !Se()) throw Error(`${r}: node incapable: insufficient WASM memory (${Y} bytes < ${f})`);
796
+ await be(), B.beginWork();
791
797
  let e = setInterval(() => {
792
798
  self.postMessage({
793
799
  id: n,
794
800
  type: "heartbeat",
795
- cpuLoad: z?.lastMeasuredLoad ?? 0,
801
+ cpuLoad: B?.lastMeasuredLoad ?? 0,
796
802
  modelCache: $()
797
803
  });
798
804
  }, 1e4), t = performance.now();
799
805
  try {
800
- let e = Se(n), t = Array.isArray(a?.fileSourceOrigins) ? a.fileSourceOrigins.filter((e) => typeof e == "string") : [], s = Array.isArray(a?.containerImageOrigins) ? a.containerImageOrigins.filter((e) => typeof e == "string") : [], c = r === "swarm-inference" ? await De(n, i, e) : await Ee(r, i, e, {
806
+ let e = xe(n), t = Array.isArray(a?.fileSourceOrigins) ? a.fileSourceOrigins.filter((e) => typeof e == "string") : [], s = Array.isArray(a?.containerImageOrigins) ? a.containerImageOrigins.filter((e) => typeof e == "string") : [], c = Array.isArray(a?.ccRangeOrigins) ? a.ccRangeOrigins.filter((e) => typeof e == "string") : [], l = r === "swarm-inference" ? await Ee(n, i, e) : await Te(r, i, e, {
801
807
  fileSourceOrigins: t,
802
- containerImageOrigins: s
808
+ containerImageOrigins: s,
809
+ ccRangeOrigins: c
810
+ }, async () => {
811
+ await B?.yieldIfOverloaded();
803
812
  });
804
813
  self.postMessage({
805
814
  id: n,
806
815
  type: "done",
807
- result: c,
816
+ result: l,
808
817
  modelCache: $()
809
818
  }), console.log(`[flaxia-node:worker] task done id=${n} workload=${r} durationMs=${Math.round(performance.now() - o)}`);
810
819
  } finally {
811
- q = null, V.delete(n), W(n), clearInterval(e), z.markTaskComplete(performance.now() - t), Te();
820
+ J = null, H.delete(n), G(n), clearInterval(e), B.markTaskComplete(performance.now() - t), we();
812
821
  }
813
822
  } catch (e) {
814
823
  let t = e instanceof Error ? e.message : String(e), i = e, a = typeof i?.code == "string" ? i.code : void 0, o = typeof i?.status == "number" ? i.status : void 0, s = typeof i?.detail == "string" ? i.detail : void 0;
815
- console.error(`[flaxia-node:worker] task error id=${n} workload=${r} error=${t}`), q === n && (q = null), W(n), self.postMessage({
824
+ console.error(`[flaxia-node:worker] task error id=${n} workload=${r} error=${t}`), J === n && (J = null), G(n), self.postMessage({
816
825
  id: n,
817
826
  type: "error",
818
827
  error: t,
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cc-extract.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cc-extract.test.d.ts","sourceRoot":"","sources":["../../../src/workloads/__tests__/cc-extract.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=decision.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.test.d.ts","sourceRoot":"","sources":["../../../src/workloads/__tests__/decision.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=embed-gemma.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed-gemma.test.d.ts","sourceRoot":"","sources":["../../../src/workloads/__tests__/embed-gemma.test.ts"],"names":[],"mappings":""}
@@ -1 +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
+ {"version":3,"file":"wasm-threads.test.d.ts","sourceRoot":"","sources":["../../../src/workloads/__tests__/wasm-threads.test.ts"],"names":[],"mappings":"AAkCA,OAAO,iBAAiB,CAAC"}
@@ -1,15 +1,34 @@
1
1
  import type { AiInferencePayload, AiInferenceResult } from '@flaxia/sdk';
2
- import type { NodeModelCacheSnapshot } from '@flaxia/sdk';
2
+ import type { ModelCacheBackend, NodeModelCacheSnapshot } from '@flaxia/sdk';
3
3
  export { DEFAULT_AI_MODEL_MAX_BYTES, MAX_AI_MODEL_MAX_BYTES, MAX_AI_INPUT_CHARS, MAX_AI_INPUT_ITEMS, ALLOWED_AI_DEVICES, ALLOWED_AI_DTYPES, listAiModels, registerAiModels, unregisterAiModel, type AiModelDefinition, } from './ai-model-registry';
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
+ * Full cache identity for one model pipeline. The executable cache is keyed
9
+ * by `task/modelId/revision/dtype/backend` (see `modelPipelineKey`), but the
10
+ * snapshot descriptor carries everything except `task`. Checking only
11
+ * `modelId` lets an `ondeviceOnly` task for the same repo with a different
12
+ * `dtype`/`backend` pass the gate and then miss the cache, downloading a
13
+ * second quantization despite the caller forbidding downloads.
14
+ */
15
+ export interface AiModelCacheIdentity {
16
+ modelId: string;
17
+ revision: string;
18
+ dtype: string;
19
+ backend: ModelCacheBackend;
20
+ }
7
21
  /**
8
22
  * Whether the model already has a `ready` executable pipeline in memory.
9
23
  * Guards `ondeviceOnly` tasks: they must fail before any download when the
10
24
  * model is absent, so the check runs on the snapshot (no side effects).
25
+ *
26
+ * The string form is a model-only check kept for the public
27
+ * `FlaxiaNodeController.isAiModelPreloaded(model)` API and the Light
28
+ * Preloader dedup. The `ondeviceOnly` gate must use the identity form so a
29
+ * different `dtype`/`backend`/`revision` does not pass.
11
30
  */
12
- export declare const isAiModelPreloaded: (model: string) => boolean;
31
+ export declare const isAiModelPreloaded: (model: string | AiModelCacheIdentity) => boolean;
13
32
  /** Model preloaded by the Light Inference idle preloader (small enough for WASM). */
14
33
  export declare const LIGHT_INFERENCE_TRANSLATE_MODEL = "Xenova/m2m100_418M";
15
34
  export declare const LIGHT_INFERENCE_TRANSLATE_TASK = "translation";
@@ -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;AAgB7E,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,kBAAkB,EAClB,k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;GAIG;AACH,eAAO,MAAM,iBAAiB,iDAAkD,CAAC;AACjF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAWhE,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,SAAU,CAAC;AAC1C,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAAG,IAAI,CAkBrF;AAED,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAElD;AAED,sEAAsE;AACtE,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAEvC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAWhE;AAED,8DAA8D;AAC9D,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAQ5E;AAED,6DAA6D;AAC7D,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAQzE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAM3D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,EAAE,CAsB/D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAyBN"}
@@ -0,0 +1,11 @@
1
+ import { type CcExtractPayload, type CcExtractResult } from '@flaxia/sdk';
2
+ /** Hard ceiling for a decompressed WARC record before parsing. */
3
+ export declare const MAX_CC_WARC_DECOMPRESSED_BYTES: number;
4
+ /** Hard ceiling for the HTTP response body inside a WARC record. */
5
+ export declare const MAX_CC_HTTP_BODY_BYTES: number;
6
+ /** Per-record network timeout. The whole task is also bounded by the payload. */
7
+ export declare const CC_RECORD_TIMEOUT_MS = 20000;
8
+ /** Identifies Flaxia Crowd to Common Crawl's data host. */
9
+ export declare const CC_USER_AGENT = "FlaxiaCrowd/0.7 (+https://flaxia.app/crowd)";
10
+ export declare function handleCcExtract(payload: CcExtractPayload, allowedOrigins?: readonly string[]): Promise<CcExtractResult>;
11
+ //# sourceMappingURL=cc-extract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cc-extract.d.ts","sourceRoot":"","sources":["../../src/workloads/cc-extract.ts"],"names":[],"mappings":"AACA,OAAO,EAaL,KAAK,gBAAgB,EAErB,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAErB,kEAAkE;AAClE,eAAO,MAAM,8BAA8B,QAAkB,CAAC;AAC9D,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,QAAkB,CAAC;AACtD,iFAAiF;AACjF,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAC3C,2DAA2D;AAC3D,eAAO,MAAM,aAAa,gDAAgD,CAAC;AA2c3E,wBAAsB,eAAe,CACnC,OAAO,EAAE,gBAAgB,EACzB,cAAc,GAAE,SAAS,MAAM,EAAO,GACrC,OAAO,CAAC,eAAe,CAAC,CAwE1B"}
@@ -0,0 +1,21 @@
1
+ import type { AiInferencePayload, AiInferenceResult, DecisionAnswer } from '@flaxia/sdk';
2
+ /** d1-omni audio contract: 16kHz mono, one clip per call. */
3
+ export declare const DECISION_AUDIO_SAMPLE_RATE = 16000;
4
+ export declare const DECISION_AUDIO_MAX_SECONDS = 30;
5
+ /** Question/option bounds: keep one forward pass cheap and answers stable. */
6
+ export declare const DECISION_MAX_QUESTIONS = 8;
7
+ export declare const DECISION_MAX_OPTIONS = 64;
8
+ export declare const DECISION_MAX_STATE_CHARS = 20000;
9
+ export declare const DECISION_MAX_MEDIA_URLS = 8;
10
+ /** Per-file media caps (compressed bytes). */
11
+ export declare const MAX_DECISION_IMAGE_BYTES: number;
12
+ export declare const MAX_DECISION_AUDIO_BYTES: number;
13
+ export declare const releaseCache: () => void;
14
+ /**
15
+ * Normalise a single d1-omni answer into the SDK `DecisionAnswer` shape.
16
+ * The model's per-question payload is trusted as-is except for the generic
17
+ * {type}-discriminated fields; probabilities are passed through verbatim.
18
+ */
19
+ export declare function normalizeDecisionAnswer(raw: any): DecisionAnswer;
20
+ export declare function handleDecision(payload: AiInferencePayload): Promise<AiInferenceResult>;
21
+ //# sourceMappingURL=decision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.d.ts","sourceRoot":"","sources":["../../src/workloads/decision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EAEf,MAAM,aAAa,CAAC;AAoBrB,6DAA6D;AAC7D,eAAO,MAAM,0BAA0B,QAAS,CAAC;AACjD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAG7C,8EAA8E;AAC9E,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,8CAA8C;AAC9C,eAAO,MAAM,wBAAwB,QAAkB,CAAC;AACxD,eAAO,MAAM,wBAAwB,QAAkB,CAAC;AAOxD,eAAO,MAAM,YAAY,QAAO,IAG/B,CAAC;AA2HF;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,GAAG,cAAc,CA0BhE;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiF5F"}