@flaxia/node 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/assets/ai-inference.js +83 -183
- package/dist/assets/ai-model-registry.js +127 -0
- package/dist/assets/cc-extract.js +5166 -0
- package/dist/assets/container.js +59 -43
- package/dist/assets/decision.js +149 -0
- package/dist/assets/embed-gemma.js +105 -0
- package/dist/assets/image-process.js +78 -70
- package/dist/assets/nudenet.js +2 -2
- package/dist/assets/{VectorStoreEngine.js → sharedEngine.js} +67 -41
- package/dist/assets/transformers.web.js +2 -2
- package/dist/assets/vector-embed.js +148 -25
- package/dist/assets/vector-query.js +4 -4
- package/dist/assets/vector-store.js +4 -4
- package/dist/assets/webgpuProbe.js +127 -70
- package/dist/client/SignalingClient.d.ts.map +1 -1
- package/dist/client/light-preloader.d.ts +14 -1
- package/dist/client/light-preloader.d.ts.map +1 -1
- package/dist/consent/notice.d.ts +3 -1
- package/dist/consent/notice.d.ts.map +1 -1
- package/dist/executor/WorkerPool.d.ts +7 -0
- package/dist/executor/WorkerPool.d.ts.map +1 -1
- package/dist/executor/__tests__/resultLimits.test.d.ts +2 -0
- package/dist/executor/__tests__/resultLimits.test.d.ts.map +1 -0
- package/dist/executor/container-executor.d.ts +15 -0
- package/dist/executor/container-executor.d.ts.map +1 -1
- package/dist/executor/memoryProbe.d.ts +25 -1
- package/dist/executor/memoryProbe.d.ts.map +1 -1
- package/dist/executor/resultLimits.d.ts +19 -0
- package/dist/executor/resultLimits.d.ts.map +1 -0
- package/dist/index.js +357 -326
- package/dist/vector-store/HNSWIndex.d.ts +4 -1
- package/dist/vector-store/HNSWIndex.d.ts.map +1 -1
- package/dist/vector-store/VectorStoreEngine.d.ts +7 -1
- package/dist/vector-store/VectorStoreEngine.d.ts.map +1 -1
- package/dist/vector-store/__tests__/sharedEngine.test.d.ts +2 -0
- package/dist/vector-store/__tests__/sharedEngine.test.d.ts.map +1 -0
- package/dist/vector-store/sharedEngine.d.ts +13 -0
- package/dist/vector-store/sharedEngine.d.ts.map +1 -0
- package/dist/worker.js +187 -175
- package/dist/workloads/__tests__/cc-extract.test.d.ts +2 -0
- package/dist/workloads/__tests__/cc-extract.test.d.ts.map +1 -0
- package/dist/workloads/__tests__/decision.test.d.ts +2 -0
- package/dist/workloads/__tests__/decision.test.d.ts.map +1 -0
- package/dist/workloads/__tests__/embed-gemma.test.d.ts +2 -0
- package/dist/workloads/__tests__/embed-gemma.test.d.ts.map +1 -0
- package/dist/workloads/__tests__/nudenet-session-cache.test.d.ts +2 -0
- package/dist/workloads/__tests__/nudenet-session-cache.test.d.ts.map +1 -0
- package/dist/workloads/__tests__/wasm-threads.test.d.ts.map +1 -1
- package/dist/workloads/ai-inference.d.ts +21 -2
- package/dist/workloads/ai-inference.d.ts.map +1 -1
- package/dist/workloads/ai-model-registry.d.ts.map +1 -1
- package/dist/workloads/cc-extract.d.ts +11 -0
- package/dist/workloads/cc-extract.d.ts.map +1 -0
- package/dist/workloads/decision.d.ts +23 -0
- package/dist/workloads/decision.d.ts.map +1 -0
- package/dist/workloads/embed-gemma.d.ts +8 -0
- package/dist/workloads/embed-gemma.d.ts.map +1 -0
- package/dist/workloads/image-process.d.ts +8 -0
- package/dist/workloads/image-process.d.ts.map +1 -1
- package/dist/workloads/nudenet.d.ts.map +1 -1
- package/dist/workloads/vector-embed.d.ts +16 -0
- package/dist/workloads/vector-embed.d.ts.map +1 -1
- package/dist/workloads/vector-query.d.ts.map +1 -1
- package/dist/workloads/vector-store.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -93,26 +93,26 @@ async function h(e, t, n) {
|
|
|
93
93
|
async function ee(e, t, n) {
|
|
94
94
|
return p(t, n, await h(e, t, n));
|
|
95
95
|
}
|
|
96
|
-
async function
|
|
96
|
+
async function te(e, t, n, r) {
|
|
97
97
|
if (r.byteLength !== 16) return !1;
|
|
98
98
|
let i = await h(e, t, n), a = 0;
|
|
99
99
|
for (let e = 0; e < i.byteLength; e++) a |= i[e] ^ r[e];
|
|
100
100
|
return a === 0;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function ne(e, t) {
|
|
103
103
|
let n = new ArrayBuffer(16 + t.byteLength), r = new DataView(n);
|
|
104
104
|
return r.setUint16(0, l, !0), r.setUint8(2, u), r.setUint8(3, 0), r.setUint32(4, e.requestId >>> 0, !0), r.setUint32(8, e.pos >>> 0, !0), r.setUint16(12, e.tokens, !0), r.setUint16(14, 0, !0), new Uint8Array(n, 16).set(t), n;
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function re(e = 0) {
|
|
107
107
|
let t = /* @__PURE__ */ new ArrayBuffer(16), n = new DataView(t);
|
|
108
108
|
return n.setUint16(0, l, !0), n.setUint8(2, d), n.setUint8(3, 0), n.setUint32(4, e >>> 0, !0), t;
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function g(e) {
|
|
111
111
|
if (e.byteLength !== 16) return !1;
|
|
112
112
|
let t = new DataView(e);
|
|
113
113
|
return t.getUint16(0, !0) === 21335 && t.getUint8(2) === d && t.getUint8(3) === 0 && t.getUint32(8, !0) === 0 && t.getUint16(12, !0) === 0 && t.getUint16(14, !0) === 0;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function ie(e) {
|
|
116
116
|
if (e.byteLength < 16) return null;
|
|
117
117
|
let t = new DataView(e);
|
|
118
118
|
return t.getUint16(0, !0) !== 21335 || t.getUint8(2) !== u ? null : {
|
|
@@ -124,20 +124,20 @@ function ne(e) {
|
|
|
124
124
|
payload: new Uint8Array(e, 16)
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
-
function
|
|
128
|
-
if (!
|
|
127
|
+
function ae(e) {
|
|
128
|
+
if (!_(e)) return !1;
|
|
129
129
|
if (e.kind === "description") {
|
|
130
130
|
let t = e.description;
|
|
131
|
-
return
|
|
131
|
+
return _(t) && (t.type === "offer" || t.type === "answer") && typeof t.sdp == "string" && t.sdp.length > 0 && t.sdp.length <= 24576;
|
|
132
132
|
}
|
|
133
133
|
if (e.kind === "candidate") {
|
|
134
134
|
let t = e.candidate;
|
|
135
|
-
return t === null ? !0 :
|
|
135
|
+
return t === null ? !0 : _(t) && typeof t.candidate == "string" && t.candidate.length > 0 && t.candidate.length <= 4096 && (t.sdpMid === void 0 || t.sdpMid === null || typeof t.sdpMid == "string" && t.sdpMid.length <= 128) && (t.sdpMLineIndex === void 0 || t.sdpMLineIndex === null || typeof t.sdpMLineIndex == "number" && Number.isInteger(t.sdpMLineIndex) && t.sdpMLineIndex >= 0 && t.sdpMLineIndex <= 255) && (t.usernameFragment === void 0 || t.usernameFragment === null || typeof t.usernameFragment == "string" && t.usernameFragment.length <= 256);
|
|
136
136
|
}
|
|
137
137
|
return !1;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
if (!
|
|
139
|
+
function oe(e) {
|
|
140
|
+
if (!_(e) || e.type !== "swarm-peer-signal" || !ae(e.signal)) return !1;
|
|
141
141
|
try {
|
|
142
142
|
if (new TextEncoder().encode(JSON.stringify(e.signal)).byteLength > 32768) return !1;
|
|
143
143
|
} catch {
|
|
@@ -145,125 +145,182 @@ function y(e) {
|
|
|
145
145
|
}
|
|
146
146
|
return typeof e.taskId == "string" && e.taskId.length > 0 && e.taskId.length <= 128 && typeof e.sessionId == "string" && e.sessionId.length > 0 && e.sessionId.length <= 128 && typeof e.attemptId == "string" && e.attemptId.length > 0 && e.attemptId.length <= 128 && typeof e.toNodeId == "string" && e.toNodeId.length > 0 && e.toNodeId.length <= 128 && (e.fromNodeId === void 0 || typeof e.fromNodeId == "string" && e.fromNodeId.length > 0 && e.fromNodeId.length <= 128);
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function _(e) {
|
|
149
149
|
return typeof e == "object" && !!e;
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function v(e) {
|
|
152
152
|
return typeof e == "number" && Number.isInteger(e) && e >= 0;
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function y(e, t = {}) {
|
|
155
155
|
let n = t.maxLayers ?? 1024, r = t.maxSliceLayers ?? 256;
|
|
156
|
-
return !(!
|
|
156
|
+
return !(!se(e) || !v(e.start) || !v(e.end) || e.end <= e.start || e.end - e.start > r || e.end > n);
|
|
157
157
|
}
|
|
158
|
-
function
|
|
159
|
-
return
|
|
158
|
+
function se(e) {
|
|
159
|
+
return _(e) ? typeof e.start == "number" && typeof e.end == "number" && typeof e.hasEmbed == "boolean" && typeof e.hasHead == "boolean" : !1;
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
return
|
|
161
|
+
function ce(e) {
|
|
162
|
+
return _(e) ? typeof e.nodeId == "string" && e.nodeId.length > 0 && typeof e.capacity == "number" : !1;
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function b(e) {
|
|
165
165
|
return e === void 0 || typeof e == "string" && e.length > 0 && e.length <= 128;
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
return !
|
|
167
|
+
function le(e) {
|
|
168
|
+
return !_(e) || e.type !== "swarm-init" || typeof e.sessionId != "string" || !e.sessionId || typeof e.taskId != "string" || !e.taskId || typeof e.model != "string" || typeof e.timeoutMs != "number" || !Array.isArray(e.members) || e.members.length === 0 || e.members.length > 16 || typeof e.prompt != "string" && !Array.isArray(e.prompt) ? !1 : e.members.every(ce);
|
|
169
169
|
}
|
|
170
|
-
function
|
|
171
|
-
return !(!
|
|
170
|
+
function ue(e) {
|
|
171
|
+
return !(!_(e) || e.type !== "swarm-slice" || typeof e.sessionId != "string" || !e.sessionId || typeof e.taskId != "string" || !e.taskId || typeof e.model != "string" || !e.model || typeof e.timeoutMs != "number" || !v(e.index) || !v(e.chainLength) || e.chainLength < 1 || e.chainLength > 16 || e.index >= e.chainLength || e.role !== (e.index === 0 ? "host" : "worker") || !y(e.slice) || e.slice.hasEmbed !== (e.index === 0) || e.slice.hasHead !== (e.index === 0) || !b(e.inboundKey) || !b(e.outboundKey) || e.attemptId !== void 0 && (typeof e.attemptId != "string" || !e.attemptId || e.attemptId.length > 128) || e.previousNodeId !== void 0 && (typeof e.previousNodeId != "string" || !e.previousNodeId || e.previousNodeId.length > 128) || e.nextNodeId !== void 0 && (typeof e.nextNodeId != "string" || !e.nextNodeId || e.nextNodeId.length > 128));
|
|
172
172
|
}
|
|
173
|
-
function
|
|
174
|
-
return !
|
|
173
|
+
function de(e) {
|
|
174
|
+
return !_(e) || e.type !== "swarm-start" ? !1 : typeof e.sessionId == "string" && !!e.sessionId && typeof e.taskId == "string" && !!e.taskId;
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
return !
|
|
176
|
+
function fe(e) {
|
|
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
|
|
180
|
-
return !
|
|
179
|
+
function pe(e) {
|
|
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
|
|
183
|
-
return !
|
|
182
|
+
function me(e) {
|
|
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([
|
|
186
186
|
"qwen3.5-2b",
|
|
187
187
|
"qwen3.8-27b",
|
|
188
188
|
"qwen3.6-35b-moe"
|
|
189
189
|
]);
|
|
190
|
-
var
|
|
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
|
-
"swarm-inference"
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
"swarm-inference",
|
|
199
|
+
"embed-gemma"
|
|
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);
|
|
203
|
+
}
|
|
204
|
+
function j(e, t) {
|
|
205
|
+
return typeof t == "string" && O.test(t) && A(e) && e.startsWith(`crawl-data/${t}/`);
|
|
206
|
+
}
|
|
207
|
+
var M = "onnx-community/embeddinggemma-2-ONNX", N = "google/embeddinggemma-2", P = 1e5, F = 4e3, I = [
|
|
208
|
+
768,
|
|
209
|
+
512,
|
|
210
|
+
256,
|
|
211
|
+
128
|
|
212
|
+
];
|
|
213
|
+
function L(e) {
|
|
214
|
+
return typeof e == "number" && I.includes(e);
|
|
215
|
+
}
|
|
216
|
+
var _e = 9e4, ve = 600 * 1e3, ye = 1440 * 60 * 1e3, be = 6e4;
|
|
217
|
+
function R(e) {
|
|
200
218
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
201
219
|
}
|
|
202
|
-
function
|
|
203
|
-
if (!
|
|
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;
|
|
204
222
|
if (e.layerRange === void 0) return !0;
|
|
205
223
|
let t = e.layerRange;
|
|
206
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;
|
|
207
225
|
}
|
|
208
|
-
function
|
|
209
|
-
if (!
|
|
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;
|
|
210
228
|
let n = e.sampledAt, r = e.expiresAt;
|
|
211
229
|
return n <= t + 5e3 && n >= t - 6e4 && r > t && r > n && r - n <= 6e4;
|
|
212
230
|
}
|
|
213
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
|
|
214
255
|
//#region src/executor/memoryProbe.ts
|
|
215
|
-
var
|
|
216
|
-
function
|
|
217
|
-
let
|
|
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);
|
|
218
259
|
try {
|
|
219
|
-
e.grow(
|
|
260
|
+
e.grow(r);
|
|
220
261
|
} catch {
|
|
221
262
|
return !1;
|
|
222
263
|
}
|
|
223
|
-
|
|
224
|
-
|
|
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;
|
|
225
267
|
return !0;
|
|
226
268
|
}
|
|
227
|
-
function W(e =
|
|
228
|
-
if (
|
|
229
|
-
|
|
269
|
+
function W(e = V, t = we) {
|
|
270
|
+
if (U) return U.bytes;
|
|
271
|
+
De++;
|
|
230
272
|
let n = Date.now(), r;
|
|
231
273
|
try {
|
|
232
274
|
r = new WebAssembly.Memory({ initial: 0 });
|
|
233
275
|
} catch {
|
|
234
|
-
return
|
|
276
|
+
return U = {
|
|
235
277
|
bytes: 0,
|
|
236
278
|
sampledAt: n,
|
|
237
279
|
measured: !1
|
|
238
280
|
}, 0;
|
|
239
281
|
}
|
|
240
|
-
let i = Math.max(0, Math.floor(e)), a = Math.max(
|
|
241
|
-
for (; o < i &&
|
|
242
|
-
let e = Math.min(a, i - o);
|
|
243
|
-
if (!
|
|
244
|
-
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++;
|
|
245
287
|
}
|
|
246
|
-
return r = void 0,
|
|
288
|
+
return r = void 0, U = {
|
|
247
289
|
bytes: o,
|
|
248
290
|
sampledAt: n,
|
|
249
291
|
measured: !0
|
|
250
292
|
}, o;
|
|
251
293
|
}
|
|
252
294
|
function G() {
|
|
253
|
-
return
|
|
295
|
+
return U ? U.bytes : W();
|
|
254
296
|
}
|
|
255
|
-
function
|
|
256
|
-
return
|
|
257
|
-
bytes:
|
|
258
|
-
sampledAt:
|
|
297
|
+
function ke() {
|
|
298
|
+
return U || W(), {
|
|
299
|
+
bytes: U?.measured ? U.bytes : null,
|
|
300
|
+
sampledAt: U?.sampledAt ?? null
|
|
259
301
|
};
|
|
260
302
|
}
|
|
261
|
-
function
|
|
262
|
-
|
|
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;
|
|
263
320
|
}
|
|
264
321
|
//#endregion
|
|
265
322
|
//#region src/executor/webgpuProbe.ts
|
|
266
|
-
var
|
|
323
|
+
var Ne = 3, q = 750, J = 1500, Y = 600 * 1e3;
|
|
267
324
|
async function X(e, t) {
|
|
268
325
|
let n, r = new Promise((e) => {
|
|
269
326
|
n = setTimeout(() => e({
|
|
@@ -295,9 +352,9 @@ function Z(e, t = Date.now()) {
|
|
|
295
352
|
function Q() {
|
|
296
353
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
297
354
|
}
|
|
298
|
-
async function
|
|
355
|
+
async function Pe(e) {
|
|
299
356
|
let t, n = new Promise((e) => {
|
|
300
|
-
t = setTimeout(() => e("timeout"),
|
|
357
|
+
t = setTimeout(() => e("timeout"), q);
|
|
301
358
|
}), r = e.queue.onSubmittedWorkDone().then(() => "complete"), i = e.lost.then(() => "lost", () => "lost");
|
|
302
359
|
try {
|
|
303
360
|
return await Promise.race([
|
|
@@ -328,12 +385,12 @@ async function $() {
|
|
|
328
385
|
entryPoint: "main"
|
|
329
386
|
}
|
|
330
387
|
}), f = [];
|
|
331
|
-
for (let e = 0; e <
|
|
388
|
+
for (let e = 0; e < Ne; e++) {
|
|
332
389
|
let e = u.createCommandEncoder(), t = e.beginComputePass();
|
|
333
390
|
t.setPipeline(d), t.dispatchWorkgroups(1), t.end();
|
|
334
391
|
let n = e.finish(), r = Q();
|
|
335
392
|
u.queue.submit([n]);
|
|
336
|
-
let i = await
|
|
393
|
+
let i = await Pe(u);
|
|
337
394
|
if (i === "lost") return Z("device-lost", Date.now());
|
|
338
395
|
if (i === "timeout") return Z("unavailable", Date.now());
|
|
339
396
|
f.push(Math.max(0, Q() - r));
|
|
@@ -358,8 +415,8 @@ async function $() {
|
|
|
358
415
|
} catch {}
|
|
359
416
|
}
|
|
360
417
|
}
|
|
361
|
-
async function
|
|
418
|
+
async function Fe() {
|
|
362
419
|
return (await $()).capabilities;
|
|
363
420
|
}
|
|
364
421
|
//#endregion
|
|
365
|
-
export {
|
|
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":"
|
|
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;AAm+BD,eAAO,MAAM,cAAc,GAAI,QAAQ,UAAU,KAAG,oBAwDnD,CAAC"}
|
|
@@ -11,13 +11,25 @@ export interface LightPreloaderOptions {
|
|
|
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 two translate models on a 4 GB phone commits ~1 GiB of
|
|
17
|
+
* wasm memory that the page then cannot reclaim, so the preloader must stay
|
|
18
|
+
* idle on constrained devices. Omitted = always allowed.
|
|
19
|
+
*/
|
|
20
|
+
hasMemoryHeadroom?: () => boolean;
|
|
14
21
|
}
|
|
15
22
|
export type PreloadFn = (request: {
|
|
16
23
|
task: string;
|
|
17
24
|
model: string;
|
|
18
25
|
dtype: string;
|
|
19
26
|
}) => Promise<void>;
|
|
20
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Check whether one preloader target is already resident. Must compare the
|
|
29
|
+
* full cache identity (model + dtype), not just the model id: the same repo
|
|
30
|
+
* preloaded as int8 does not satisfy a q4f16 ondeviceOnly task.
|
|
31
|
+
*/
|
|
32
|
+
export type IsPreloadedFn = (target: LightPreloaderTarget) => boolean;
|
|
21
33
|
/** Defaults mirror `LIGHT_INFERENCE_TRANSLATE_*` in `ai-inference.ts`. */
|
|
22
34
|
export declare const LIGHT_INFERENCE_TRANSLATE_MODEL = "Xenova/m2m100_418M";
|
|
23
35
|
export declare const LIGHT_INFERENCE_TRANSLATE_TASK = "translation";
|
|
@@ -51,6 +63,7 @@ export declare class LightPreloader {
|
|
|
51
63
|
/** Cancel any scheduled preload (e.g. on suspend / consent denial). */
|
|
52
64
|
stop(): void;
|
|
53
65
|
private isUnconstrained;
|
|
66
|
+
private hasMemoryHeadroom;
|
|
54
67
|
private preloadNow;
|
|
55
68
|
}
|
|
56
69
|
//# 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;
|
|
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,E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AAI,IAAI;IAmBb,uEAAuE;IACvE,IAAI,IAAI,IAAI;IAUZ,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,iBAAiB;YAUX,UAAU;CAsBzB"}
|
package/dist/consent/notice.d.ts
CHANGED
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
* disclosed what actually runs on the device.
|
|
12
12
|
* - v2: the informed-consent copy below (third-party workloads, orchestrator
|
|
13
13
|
* registration, persistent connection, resource usage).
|
|
14
|
+
* - v3: adds public-web-archive fetching and text extraction (`cc-extract`),
|
|
15
|
+
* including that the destination site sees the device's IP address.
|
|
14
16
|
*/
|
|
15
|
-
export declare const CONSENT_NOTICE_VERSION =
|
|
17
|
+
export declare const CONSENT_NOTICE_VERSION = 3;
|
|
16
18
|
/**
|
|
17
19
|
* The disclosure shown in the built-in banner. Deliberately static: hosts may
|
|
18
20
|
* style the banner but must not be able to weaken the wording, otherwise the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notice.d.ts","sourceRoot":"","sources":["../../src/consent/notice.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"notice.d.ts","sourceRoot":"","sources":["../../src/consent/notice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;IAS7B,0EAA0E;;;;CAKlE,CAAC"}
|
|
@@ -24,6 +24,12 @@ export declare class WorkerPool {
|
|
|
24
24
|
/** Control messages that arrived for a task that has not started yet. */
|
|
25
25
|
private pendingControls;
|
|
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;
|
|
@@ -33,6 +39,7 @@ export declare class WorkerPool {
|
|
|
33
39
|
maxCpuLoad?: number;
|
|
34
40
|
fileSourceOrigins?: string[];
|
|
35
41
|
containerImageOrigins?: string[];
|
|
42
|
+
ccRangeOrigins?: string[];
|
|
36
43
|
}, swarm?: SwarmCallbacks): Promise<unknown>;
|
|
37
44
|
private execute;
|
|
38
45
|
/** Hand over the control messages that were waiting for this task to start. */
|
|
@@ -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;
|
|
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;AAsBxE,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;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAM;IAC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AI,sBAAsB,GAAG,IAAI,CAItD;CACF"}
|
|
@@ -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,C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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":"
|
|
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"}
|