tensorlake 0.5.131 → 0.5.133
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 +27 -0
- package/dist/applications/index.cjs +492 -708
- package/dist/applications/index.cjs.map +1 -1
- package/dist/applications/index.d.cts +3 -3
- package/dist/applications/index.d.ts +3 -3
- package/dist/applications/index.js +493 -713
- package/dist/applications/index.js.map +1 -1
- package/dist/function-agent/main.cjs +5 -2
- package/dist/function-agent/main.cjs.map +1 -1
- package/dist/function-agent/main.js +6 -3
- package/dist/function-agent/main.js.map +1 -1
- package/dist/function-executor/main.cjs +6 -3
- package/dist/function-executor/main.cjs.map +1 -1
- package/dist/function-executor/main.js +7 -4
- package/dist/function-executor/main.js.map +1 -1
- package/dist/index.cjs +121 -418
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -22
- package/dist/index.d.ts +8 -22
- package/dist/index.js +122 -423
- package/dist/index.js.map +1 -1
- package/dist/native-worker.cjs +1 -0
- package/dist/native-worker.cjs.map +1 -1
- package/dist/native-worker.js +1 -0
- package/dist/native-worker.js.map +1 -1
- package/dist/{remote-DRCCuRth.d.cts → remote-D95Y6Czr.d.cts} +1 -1
- package/dist/{remote-0dzBqScB.d.ts → remote-omwTzbfj.d.ts} +1 -1
- package/dist/{sandbox-image-Bf5bcxtO.d.cts → sandbox-image-ChzWDeZy.d.cts} +2 -0
- package/dist/{sandbox-image-Bf5bcxtO.d.ts → sandbox-image-ChzWDeZy.d.ts} +2 -0
- package/dist/sandbox-image.cjs +476 -453
- package/dist/sandbox-image.cjs.map +1 -1
- package/dist/sandbox-image.d.cts +1 -1
- package/dist/sandbox-image.d.ts +1 -1
- package/dist/sandbox-image.js +475 -456
- package/dist/sandbox-image.js.map +1 -1
- package/package.json +8 -8
- package/runtime/function-executor/manifest.json +14 -14
- package/runtime/function-executor/package/dist/function-executor/main.js +7 -4
- package/runtime/function-executor/package/dist/function-executor/main.js.map +1 -1
- package/runtime/function-executor/package/dist/native-worker.cjs +1 -0
- package/runtime/function-executor/package/dist/native-worker.cjs.map +1 -1
- package/runtime/function-executor/package/npm-shrinkwrap.json +2 -12
- package/runtime/function-executor/package/package.json +1 -2
- package/runtime/typescript-function-runner/manifest.json +13 -13
- package/runtime/typescript-function-runner/package/dist/function-agent/main.js +6 -3
- package/runtime/typescript-function-runner/package/dist/function-agent/main.js.map +1 -1
- package/runtime/typescript-function-runner/package/dist/native-worker.cjs +1 -0
- package/runtime/typescript-function-runner/package/dist/native-worker.cjs.map +1 -1
- package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +20 -29
- package/runtime/typescript-function-runner/package/package.json +7 -7
|
@@ -224,6 +224,7 @@ port.on("message", (message) => {
|
|
|
224
224
|
return;
|
|
225
225
|
}
|
|
226
226
|
if (message.type === "release") {
|
|
227
|
+
handles.get(message.handleId)?.value?.close?.();
|
|
227
228
|
handles.delete(message.handleId);
|
|
228
229
|
for (const stream of streams.values()) {
|
|
229
230
|
if (stream.handleId === message.handleId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../node_modules/tsup/assets/cjs_shims.js","../lib/libc.cjs","../src/native-worker.ts","../src/native-binding.ts"],"sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","// Read the ELF interpreter, rather than generating a process-wide diagnostic\n// report. Both supported Linux architectures use little-endian ELF64. Reads\n// are bounded to the header, program headers, and interpreter pathname.\nfunction detectLinuxLibc(fs, executable = process.execPath) {\n const override = process.env.TENSORLAKE_NODE_LIBC;\n if (override != null) {\n if (override === \"gnu\" || override === \"musl\") return override;\n throw new Error(\"TENSORLAKE_NODE_LIBC must be 'gnu' or 'musl'.\");\n }\n\n let fd;\n try {\n fd = fs.openSync(executable, \"r\");\n function read(size, offset) {\n if (!Number.isSafeInteger(offset) || offset < 0) {\n throw new Error(\"Invalid ELF offset\");\n }\n const buffer = Buffer.alloc(size);\n let count = 0;\n while (count < size) {\n const bytes = fs.readSync(fd, buffer, count, size - count, offset + count);\n if (bytes === 0) throw new Error(\"Truncated ELF executable\");\n count += bytes;\n }\n return buffer;\n }\n\n const header = read(64, 0);\n if (header.readUInt32BE(0) !== 0x7f454c46 || header[4] !== 2 || header[5] !== 1) {\n throw new Error(\"Expected a little-endian ELF64 executable\");\n }\n const entrySize = header.readUInt16LE(54);\n const count = header.readUInt16LE(56);\n if (entrySize !== 56 || count === 0 || count > 128) {\n throw new Error(\"Unsupported ELF program headers\");\n }\n const entries = read(entrySize * count, Number(header.readBigUInt64LE(32)));\n for (let i = 0; i < count; i++) {\n const offset = i * entrySize;\n if (entries.readUInt32LE(offset) !== 3) continue; // PT_INTERP\n const size = Number(entries.readBigUInt64LE(offset + 32));\n if (size < 2 || size > 4096) throw new Error(\"Invalid ELF interpreter size\");\n const interpreter = read(size, Number(entries.readBigUInt64LE(offset + 8)));\n if (interpreter[size - 1] !== 0) throw new Error(\"Unterminated ELF interpreter\");\n const name = interpreter.subarray(0, -1).toString(\"utf8\").split(\"/\").at(-1);\n if (name.startsWith(\"ld-musl-\")) return \"musl\";\n if (name.startsWith(\"ld-linux-\")) return \"gnu\";\n throw new Error(\"Unrecognized ELF interpreter\");\n }\n throw new Error(\"No ELF interpreter (statically linked executable)\");\n } catch (cause) {\n throw new Error(\n \"Unable to detect Linux libc from the Node executable. Set TENSORLAKE_NODE_LIBC to 'gnu' or 'musl' for a nonstandard runtime.\",\n { cause },\n );\n } finally {\n if (fd != null) fs.closeSync(fd);\n }\n}\n\nmodule.exports = { detectLinuxLibc };\n","import { parentPort } from \"node:worker_threads\";\nimport { loadNative } from \"./native-binding.js\";\nimport type {\n WorkerRequest,\n WorkerResponse,\n} from \"./native-worker-protocol.js\";\n\nconst port = parentPort!;\n// This module is only a worker entrypoint. All platform detection, dlopen and\n// native object construction happen in this isolate.\nconst binding = loadNative<Record<string, any>>();\nconst handles = new Map<number, { value?: any; error?: unknown }>();\ninterface StreamState {\n cancel?: () => void;\n handleId?: number;\n ack?: () => void;\n}\nconst streams = new Map<number, StreamState>();\n\nfunction getHandle(id: number): any {\n const entry = handles.get(id);\n if (!entry) throw new Error(\"Tensorlake native handle has been released\");\n if (entry.error) throw entry.error;\n return entry.value;\n}\n\n/** Structured clone turns Buffers into Uint8Arrays; napi expects Buffers. */\nfunction nativeArgs(value: any): any {\n if (value instanceof Uint8Array)\n return Buffer.from(value.buffer, value.byteOffset, value.byteLength);\n if (Array.isArray(value)) return value.map(nativeArgs);\n if (value && typeof value === \"object\")\n return Object.fromEntries(\n Object.entries(value).map(([k, v]) => [k, nativeArgs(v)]),\n );\n return value;\n}\n\nfunction send(message: WorkerResponse): void {\n port.postMessage(message);\n}\n\nport.on(\"message\", (message: WorkerRequest) => {\n if (message.type === \"create\") {\n try {\n const { kind, args, id } = message.handle;\n const ctor = binding[kind];\n if (typeof ctor !== \"function\")\n throw new Error(\n `native binding does not export ${kind}; rebuild with 'npm run build:native'`,\n );\n const value =\n message.parentId === undefined\n ? new ctor(...args)\n : getHandle(message.parentId).connectProxy(...args);\n handles.set(id, { value });\n } catch (error) {\n handles.set(message.handle.id, { error });\n }\n return;\n }\n if (message.type === \"release\") {\n handles.delete(message.handleId);\n for (const stream of streams.values()) {\n if (stream.handleId === message.handleId) {\n stream.cancel?.();\n stream.ack?.();\n }\n }\n return;\n }\n if (message.type === \"cancel\" || message.type === \"ack\") {\n const stream = streams.get(message.id);\n if (message.type === \"cancel\") stream?.cancel?.();\n stream?.ack?.();\n if (stream) stream.ack = undefined;\n return;\n }\n if (message.type === \"call\") void invoke(message);\n});\n\nasync function invoke(\n message: Extract<WorkerRequest, { type: \"call\" }>,\n): Promise<void> {\n try {\n const target =\n message.handleId === undefined ? binding : getHandle(message.handleId);\n const args = nativeArgs(message.args);\n let stream: StreamState | undefined;\n if (message.stream) {\n stream = { handleId: message.handleId };\n const state = stream;\n streams.set(message.id, stream);\n args.push(\n (value: string) =>\n new Promise<void>((resolve) => {\n state.ack = resolve;\n send({ type: \"event\", id: message.id, value });\n }),\n );\n }\n const call = target[message.method](...args);\n if (stream) stream.cancel = call.cancel;\n const value = await (stream ? call.result : call);\n send({ type: \"result\", id: message.id, value });\n } catch (cause) {\n const error = cause instanceof Error ? cause : new Error(String(cause));\n send({\n type: \"error\",\n id: message.id,\n error: { name: error.name, message: error.message, stack: error.stack },\n });\n } finally {\n streams.get(message.id)?.ack?.();\n streams.delete(message.id);\n }\n}\n","import { detectLinuxLibc } from \"../lib/libc.cjs\";\nimport * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\ninterface RuntimeReport {\n header?: {\n glibcVersionRuntime?: string;\n };\n}\n\ninterface TargetOptions {\n libc?: \"gnu\" | \"musl\";\n report?: RuntimeReport;\n}\n\ninterface NativeBindingPathOptions extends TargetOptions {\n packageRoot?: string;\n platform?: NodeJS.Platform;\n arch?: string;\n}\n\nconst NATIVE_PACKAGES: Readonly<Record<string, string>> = {\n \"darwin-arm64\": \"tensorlake-native-darwin-arm64\",\n \"linux-arm64\": \"tensorlake-native-linux-arm64-gnu\",\n \"linux-arm64-musl\": \"tensorlake-native-linux-arm64-musl\",\n \"linux-x64\": \"tensorlake-native-linux-x64-gnu\",\n \"linux-x64-musl\": \"tensorlake-native-linux-x64-musl\",\n \"win32-x64\": \"tensorlake-native-win32-x64\",\n};\n\nfunction packageRoot(): string {\n const parent = fileURLToPath(new URL(\"../\", import.meta.url));\n if (fs.existsSync(path.join(parent, \"package.json\"))) return parent;\n const grandparent = fileURLToPath(new URL(\"../../\", import.meta.url));\n if (fs.existsSync(path.join(grandparent, \"package.json\"))) return grandparent;\n return parent;\n}\n\nlet cachedLinuxLibc: \"gnu\" | \"musl\" | undefined;\n\nfunction linuxLibcFamily(options: TargetOptions): \"gnu\" | \"musl\" {\n if (options.libc != null) return options.libc;\n if (options.report != null) {\n return options.report.header?.glibcVersionRuntime ? \"gnu\" : \"musl\";\n }\n if (cachedLinuxLibc != null) return cachedLinuxLibc;\n\n cachedLinuxLibc = detectLinuxLibc(fs);\n return cachedLinuxLibc;\n}\n\nexport function nativeTargetId(\n platform: NodeJS.Platform = process.platform,\n arch: string = process.arch,\n options: TargetOptions = {},\n): string {\n const target = `${platform}-${arch}`;\n if (platform !== \"linux\") return target;\n if (options.libc == null && options.report == null && platform !== process.platform) {\n return target;\n }\n return linuxLibcFamily(options) === \"musl\" ? `${target}-musl` : target;\n}\n\nexport function nativeBindingPath(options: NativeBindingPathOptions = {}): string {\n const platform = options.platform ?? process.platform;\n const arch = options.arch ?? process.arch;\n return path.join(\n options.packageRoot ?? packageRoot(),\n \"dist\",\n \"native\",\n nativeTargetId(platform, arch, options),\n \"tensorlake-node.node\",\n );\n}\n\nexport function nativePackageName(\n platform: NodeJS.Platform = process.platform,\n arch: string = process.arch,\n options: TargetOptions = {},\n): string | undefined {\n return NATIVE_PACKAGES[nativeTargetId(platform, arch, options)];\n}\n\nexport function loadNative<T>(): T {\n const target = nativeTargetId();\n const bindingPath = nativeBindingPath();\n const require = createRequire(import.meta.url);\n\n // Local source builds stage the addon here. Published packages intentionally\n // omit this directory and resolve the platform-specific optional dependency.\n if (fs.existsSync(bindingPath)) return require(bindingPath) as T;\n\n const packageName = nativePackageName();\n if (!packageName) {\n throw new Error(\n `Tensorlake does not provide a native binding for ${target}.`,\n );\n }\n\n let packageEntry: string;\n try {\n packageEntry = require.resolve(packageName);\n } catch (cause) {\n throw new Error(\n `Missing native binding package ${packageName} for ${target}. Reinstall tensorlake without omitting optional dependencies, and install dependencies on the machine where they will run.`,\n { cause },\n );\n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,QAAQ,IAAI;AACpC,QAAI;AACJ,QAAI,QAAQ,QAAQ;AAClB,eAAS,EAAE,UAAU,QAAQ,SAAS;AACtC,YAAM,QAAQ;AACd,cAAQ,IAAI,QAAQ,IAAI,MAAM;AAC9B,WAAK;AAAA,QACH,CAACC,WACC,IAAI,QAAc,CAAC,YAAY;AAC7B,gBAAM,MAAM;AACZ,eAAK,EAAE,MAAM,SAAS,IAAI,QAAQ,IAAI,OAAAA,OAAM,CAAC;AAAA,QAC/C,CAAC;AAAA,MACL;AAAA,IACF;AACA,UAAM,OAAO,OAAO,QAAQ,MAAM,EAAE,GAAG,IAAI;AAC3C,QAAI,OAAQ,QAAO,SAAS,KAAK;AACjC,UAAM,QAAQ,OAAO,SAAS,KAAK,SAAS;AAC5C,SAAK,EAAE,MAAM,UAAU,IAAI,QAAQ,IAAI,MAAM,CAAC;AAAA,EAChD,SAAS,OAAO;AACd,UAAM,QAAQ,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACtE,SAAK;AAAA,MACH,MAAM;AAAA,MACN,IAAI,QAAQ;AAAA,MACZ,OAAO,EAAE,MAAM,MAAM,MAAM,SAAS,MAAM,SAAS,OAAO,MAAM,MAAM;AAAA,IACxE,CAAC;AAAA,EACH,UAAE;AACA,YAAQ,IAAI,QAAQ,EAAE,GAAG,MAAM;AAC/B,YAAQ,OAAO,QAAQ,EAAE;AAAA,EAC3B;AACF;","names":["exports","module","detectLinuxLibc","fs","read","count","path","require","value"]}
|
|
1
|
+
{"version":3,"sources":["../node_modules/tsup/assets/cjs_shims.js","../lib/libc.cjs","../src/native-worker.ts","../src/native-binding.ts"],"sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","// Read the ELF interpreter, rather than generating a process-wide diagnostic\n// report. Both supported Linux architectures use little-endian ELF64. Reads\n// are bounded to the header, program headers, and interpreter pathname.\nfunction detectLinuxLibc(fs, executable = process.execPath) {\n const override = process.env.TENSORLAKE_NODE_LIBC;\n if (override != null) {\n if (override === \"gnu\" || override === \"musl\") return override;\n throw new Error(\"TENSORLAKE_NODE_LIBC must be 'gnu' or 'musl'.\");\n }\n\n let fd;\n try {\n fd = fs.openSync(executable, \"r\");\n function read(size, offset) {\n if (!Number.isSafeInteger(offset) || offset < 0) {\n throw new Error(\"Invalid ELF offset\");\n }\n const buffer = Buffer.alloc(size);\n let count = 0;\n while (count < size) {\n const bytes = fs.readSync(fd, buffer, count, size - count, offset + count);\n if (bytes === 0) throw new Error(\"Truncated ELF executable\");\n count += bytes;\n }\n return buffer;\n }\n\n const header = read(64, 0);\n if (header.readUInt32BE(0) !== 0x7f454c46 || header[4] !== 2 || header[5] !== 1) {\n throw new Error(\"Expected a little-endian ELF64 executable\");\n }\n const entrySize = header.readUInt16LE(54);\n const count = header.readUInt16LE(56);\n if (entrySize !== 56 || count === 0 || count > 128) {\n throw new Error(\"Unsupported ELF program headers\");\n }\n const entries = read(entrySize * count, Number(header.readBigUInt64LE(32)));\n for (let i = 0; i < count; i++) {\n const offset = i * entrySize;\n if (entries.readUInt32LE(offset) !== 3) continue; // PT_INTERP\n const size = Number(entries.readBigUInt64LE(offset + 32));\n if (size < 2 || size > 4096) throw new Error(\"Invalid ELF interpreter size\");\n const interpreter = read(size, Number(entries.readBigUInt64LE(offset + 8)));\n if (interpreter[size - 1] !== 0) throw new Error(\"Unterminated ELF interpreter\");\n const name = interpreter.subarray(0, -1).toString(\"utf8\").split(\"/\").at(-1);\n if (name.startsWith(\"ld-musl-\")) return \"musl\";\n if (name.startsWith(\"ld-linux-\")) return \"gnu\";\n throw new Error(\"Unrecognized ELF interpreter\");\n }\n throw new Error(\"No ELF interpreter (statically linked executable)\");\n } catch (cause) {\n throw new Error(\n \"Unable to detect Linux libc from the Node executable. Set TENSORLAKE_NODE_LIBC to 'gnu' or 'musl' for a nonstandard runtime.\",\n { cause },\n );\n } finally {\n if (fd != null) fs.closeSync(fd);\n }\n}\n\nmodule.exports = { detectLinuxLibc };\n","import { parentPort } from \"node:worker_threads\";\nimport { loadNative } from \"./native-binding.js\";\nimport type {\n WorkerRequest,\n WorkerResponse,\n} from \"./native-worker-protocol.js\";\n\nconst port = parentPort!;\n// This module is only a worker entrypoint. All platform detection, dlopen and\n// native object construction happen in this isolate.\nconst binding = loadNative<Record<string, any>>();\nconst handles = new Map<number, { value?: any; error?: unknown }>();\ninterface StreamState {\n cancel?: () => void;\n handleId?: number;\n ack?: () => void;\n}\nconst streams = new Map<number, StreamState>();\n\nfunction getHandle(id: number): any {\n const entry = handles.get(id);\n if (!entry) throw new Error(\"Tensorlake native handle has been released\");\n if (entry.error) throw entry.error;\n return entry.value;\n}\n\n/** Structured clone turns Buffers into Uint8Arrays; napi expects Buffers. */\nfunction nativeArgs(value: any): any {\n if (value instanceof Uint8Array)\n return Buffer.from(value.buffer, value.byteOffset, value.byteLength);\n if (Array.isArray(value)) return value.map(nativeArgs);\n if (value && typeof value === \"object\")\n return Object.fromEntries(\n Object.entries(value).map(([k, v]) => [k, nativeArgs(v)]),\n );\n return value;\n}\n\nfunction send(message: WorkerResponse): void {\n port.postMessage(message);\n}\n\nport.on(\"message\", (message: WorkerRequest) => {\n if (message.type === \"create\") {\n try {\n const { kind, args, id } = message.handle;\n const ctor = binding[kind];\n if (typeof ctor !== \"function\")\n throw new Error(\n `native binding does not export ${kind}; rebuild with 'npm run build:native'`,\n );\n const value =\n message.parentId === undefined\n ? new ctor(...args)\n : getHandle(message.parentId).connectProxy(...args);\n handles.set(id, { value });\n } catch (error) {\n handles.set(message.handle.id, { error });\n }\n return;\n }\n if (message.type === \"release\") {\n // Cloud clients own cancellation for buffered requests as well as streams.\n handles.get(message.handleId)?.value?.close?.();\n handles.delete(message.handleId);\n for (const stream of streams.values()) {\n if (stream.handleId === message.handleId) {\n stream.cancel?.();\n stream.ack?.();\n }\n }\n return;\n }\n if (message.type === \"cancel\" || message.type === \"ack\") {\n const stream = streams.get(message.id);\n if (message.type === \"cancel\") stream?.cancel?.();\n stream?.ack?.();\n if (stream) stream.ack = undefined;\n return;\n }\n if (message.type === \"call\") void invoke(message);\n});\n\nasync function invoke(\n message: Extract<WorkerRequest, { type: \"call\" }>,\n): Promise<void> {\n try {\n const target =\n message.handleId === undefined ? binding : getHandle(message.handleId);\n const args = nativeArgs(message.args);\n let stream: StreamState | undefined;\n if (message.stream) {\n stream = { handleId: message.handleId };\n const state = stream;\n streams.set(message.id, stream);\n args.push(\n (value: string) =>\n new Promise<void>((resolve) => {\n state.ack = resolve;\n send({ type: \"event\", id: message.id, value });\n }),\n );\n }\n const call = target[message.method](...args);\n if (stream) stream.cancel = call.cancel;\n const value = await (stream ? call.result : call);\n send({ type: \"result\", id: message.id, value });\n } catch (cause) {\n const error = cause instanceof Error ? cause : new Error(String(cause));\n send({\n type: \"error\",\n id: message.id,\n error: { name: error.name, message: error.message, stack: error.stack },\n });\n } finally {\n streams.get(message.id)?.ack?.();\n streams.delete(message.id);\n }\n}\n","import { detectLinuxLibc } from \"../lib/libc.cjs\";\nimport * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\ninterface RuntimeReport {\n header?: {\n glibcVersionRuntime?: string;\n };\n}\n\ninterface TargetOptions {\n libc?: \"gnu\" | \"musl\";\n report?: RuntimeReport;\n}\n\ninterface NativeBindingPathOptions extends TargetOptions {\n packageRoot?: string;\n platform?: NodeJS.Platform;\n arch?: string;\n}\n\nconst NATIVE_PACKAGES: Readonly<Record<string, string>> = {\n \"darwin-arm64\": \"tensorlake-native-darwin-arm64\",\n \"linux-arm64\": \"tensorlake-native-linux-arm64-gnu\",\n \"linux-arm64-musl\": \"tensorlake-native-linux-arm64-musl\",\n \"linux-x64\": \"tensorlake-native-linux-x64-gnu\",\n \"linux-x64-musl\": \"tensorlake-native-linux-x64-musl\",\n \"win32-x64\": \"tensorlake-native-win32-x64\",\n};\n\nfunction packageRoot(): string {\n const parent = fileURLToPath(new URL(\"../\", import.meta.url));\n if (fs.existsSync(path.join(parent, \"package.json\"))) return parent;\n const grandparent = fileURLToPath(new URL(\"../../\", import.meta.url));\n if (fs.existsSync(path.join(grandparent, \"package.json\"))) return grandparent;\n return parent;\n}\n\nlet cachedLinuxLibc: \"gnu\" | \"musl\" | undefined;\n\nfunction linuxLibcFamily(options: TargetOptions): \"gnu\" | \"musl\" {\n if (options.libc != null) return options.libc;\n if (options.report != null) {\n return options.report.header?.glibcVersionRuntime ? \"gnu\" : \"musl\";\n }\n if (cachedLinuxLibc != null) return cachedLinuxLibc;\n\n cachedLinuxLibc = detectLinuxLibc(fs);\n return cachedLinuxLibc;\n}\n\nexport function nativeTargetId(\n platform: NodeJS.Platform = process.platform,\n arch: string = process.arch,\n options: TargetOptions = {},\n): string {\n const target = `${platform}-${arch}`;\n if (platform !== \"linux\") return target;\n if (options.libc == null && options.report == null && platform !== process.platform) {\n return target;\n }\n return linuxLibcFamily(options) === \"musl\" ? `${target}-musl` : target;\n}\n\nexport function nativeBindingPath(options: NativeBindingPathOptions = {}): string {\n const platform = options.platform ?? process.platform;\n const arch = options.arch ?? process.arch;\n return path.join(\n options.packageRoot ?? packageRoot(),\n \"dist\",\n \"native\",\n nativeTargetId(platform, arch, options),\n \"tensorlake-node.node\",\n );\n}\n\nexport function nativePackageName(\n platform: NodeJS.Platform = process.platform,\n arch: string = process.arch,\n options: TargetOptions = {},\n): string | undefined {\n return NATIVE_PACKAGES[nativeTargetId(platform, arch, options)];\n}\n\nexport function loadNative<T>(): T {\n const target = nativeTargetId();\n const bindingPath = nativeBindingPath();\n const require = createRequire(import.meta.url);\n\n // Local source builds stage the addon here. Published packages intentionally\n // omit this directory and resolve the platform-specific optional dependency.\n if (fs.existsSync(bindingPath)) return require(bindingPath) as T;\n\n const packageName = nativePackageName();\n if (!packageName) {\n throw new Error(\n `Tensorlake does not provide a native binding for ${target}.`,\n );\n }\n\n let packageEntry: string;\n try {\n packageEntry = require.resolve(packageName);\n } catch (cause) {\n throw new Error(\n `Missing native binding package ${packageName} for ${target}. Reinstall tensorlake without omitting optional dependencies, and install dependencies on the machine where they will run.`,\n { cause },\n );\n }\n return require(packageEntry) as T;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAKM,kBAOO;AAZb;AAAA;AAAA;AAKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,QAAQ,YAAY,MAAM,WAC1E,SAAS,cAAc,MACvB,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEtC,IAAM,gBAAgC,iCAAiB;AAAA;AAAA;;;ACZ9D;AAAA,iBAAAA,UAAAC,SAAA;AAAA;AAAA;AAGA,aAASC,iBAAgBC,KAAI,aAAa,QAAQ,UAAU;AAC1D,YAAM,WAAW,QAAQ,IAAI;AAC7B,UAAI,YAAY,MAAM;AACpB,YAAI,aAAa,SAAS,aAAa,OAAQ,QAAO;AACtD,cAAM,IAAI,MAAM,+CAA+C;AAAA,MACjE;AAEA,UAAI;AACJ,UAAI;AAEF,YAASC,QAAT,SAAc,MAAM,QAAQ;AAC1B,cAAI,CAAC,OAAO,cAAc,MAAM,KAAK,SAAS,GAAG;AAC/C,kBAAM,IAAI,MAAM,oBAAoB;AAAA,UACtC;AACA,gBAAM,SAAS,OAAO,MAAM,IAAI;AAChC,cAAIC,SAAQ;AACZ,iBAAOA,SAAQ,MAAM;AACnB,kBAAM,QAAQF,IAAG,SAAS,IAAI,QAAQE,QAAO,OAAOA,QAAO,S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AQ,OAAO,QAAQ,EAAE;AAAA,EAC3B;AACF;","names":["exports","module","detectLinuxLibc","fs","read","count","path","require","value"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tensorlake/function-executor-runtime",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.133",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@tensorlake/function-executor-runtime",
|
|
9
|
-
"version": "0.5.
|
|
9
|
+
"version": "0.5.133",
|
|
10
10
|
"description": "Tensorlake Node.js function executor runtime",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"bin": {
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"fflate": "0.8.3",
|
|
23
23
|
"google-proto-files": "5.0.3",
|
|
24
24
|
"nanoid": "3.3.18",
|
|
25
|
-
"undici": "8.3.0",
|
|
26
25
|
"ws": "8.21.1"
|
|
27
26
|
},
|
|
28
27
|
"license": "Apache-2.0"
|
|
@@ -383,15 +382,6 @@
|
|
|
383
382
|
"node": ">=8"
|
|
384
383
|
}
|
|
385
384
|
},
|
|
386
|
-
"node_modules/undici": {
|
|
387
|
-
"version": "8.3.0",
|
|
388
|
-
"resolved": "https://registry.npmjs.org/undici/-/undici-8.3.0.tgz",
|
|
389
|
-
"integrity": "sha512-TkUDgb6tl7KOGZ+7e8E3d2FYgUQgF6z5YypqjWmixVQSQERFcVrVg0ySADm2LVLRh5ljAaHTCR5Fmz3Q34rB7Q==",
|
|
390
|
-
"license": "MIT",
|
|
391
|
-
"engines": {
|
|
392
|
-
"node": ">=22.19.0"
|
|
393
|
-
}
|
|
394
|
-
},
|
|
395
385
|
"node_modules/undici-types": {
|
|
396
386
|
"version": "7.18.2",
|
|
397
387
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tensorlake/function-executor-runtime",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.133",
|
|
4
4
|
"description": "Tensorlake Node.js function executor runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"fflate": "0.8.3",
|
|
17
17
|
"google-proto-files": "5.0.3",
|
|
18
18
|
"nanoid": "3.3.18",
|
|
19
|
-
"undici": "8.3.0",
|
|
20
19
|
"ws": "8.21.1"
|
|
21
20
|
},
|
|
22
21
|
"license": "Apache-2.0"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"format_version": 1,
|
|
3
|
-
"sdk_version": "0.5.
|
|
3
|
+
"sdk_version": "0.5.133",
|
|
4
4
|
"minimum_node_major": 24,
|
|
5
5
|
"package_name": "@tensorlake/typescript-function-runner-runtime",
|
|
6
|
-
"runtime_id": "sha256:
|
|
6
|
+
"runtime_id": "sha256:9fc586ca602d3fbd743a0f823a02e191c79eb1f16c738833c45c3fce2fcbf935",
|
|
7
7
|
"files": {
|
|
8
8
|
"package/bin/tensorlake-typescript-function-runner.js": {
|
|
9
9
|
"sha256": "7df71ab38dee408293821764623bea199faa1c5ffd2bdc989fd1de947729eea5",
|
|
@@ -11,32 +11,32 @@
|
|
|
11
11
|
"mode": 493
|
|
12
12
|
},
|
|
13
13
|
"package/dist/function-agent/main.js": {
|
|
14
|
-
"sha256": "
|
|
15
|
-
"size":
|
|
14
|
+
"sha256": "00258c84b7c7d953c1f82b9533e7d4d3f9d5a7dd6d72af02bae3337e1529be4d",
|
|
15
|
+
"size": 64923,
|
|
16
16
|
"mode": 420
|
|
17
17
|
},
|
|
18
18
|
"package/dist/function-agent/main.js.map": {
|
|
19
|
-
"sha256": "
|
|
20
|
-
"size":
|
|
19
|
+
"sha256": "5517a5a07582cf8b9c2c52fff6c7f5618469507a7e5ba49902b9b9ae35fda2dc",
|
|
20
|
+
"size": 192353,
|
|
21
21
|
"mode": 420
|
|
22
22
|
},
|
|
23
23
|
"package/dist/native-worker.cjs": {
|
|
24
|
-
"sha256": "
|
|
25
|
-
"size":
|
|
24
|
+
"sha256": "2915ec528014ecfedbefe167c9139f46f390f6c937b92718595afb4347ad0985",
|
|
25
|
+
"size": 10870,
|
|
26
26
|
"mode": 420
|
|
27
27
|
},
|
|
28
28
|
"package/dist/native-worker.cjs.map": {
|
|
29
|
-
"sha256": "
|
|
30
|
-
"size":
|
|
29
|
+
"sha256": "4e5246d7fc4f28c17f795c413f27bfa51d93c738d79bf8a702a44d768511255e",
|
|
30
|
+
"size": 17217,
|
|
31
31
|
"mode": 420
|
|
32
32
|
},
|
|
33
33
|
"package/npm-shrinkwrap.json": {
|
|
34
|
-
"sha256": "
|
|
35
|
-
"size":
|
|
34
|
+
"sha256": "6d457aae08786d82efa48407c42ee257cb8c4609e374153ccb15d1ac21d1392b",
|
|
35
|
+
"size": 20832,
|
|
36
36
|
"mode": 420
|
|
37
37
|
},
|
|
38
38
|
"package/package.json": {
|
|
39
|
-
"sha256": "
|
|
39
|
+
"sha256": "fec46994a27106740bf8a8b6cd9092a30070c2bcb32bf06d85eea48855317c30",
|
|
40
40
|
"size": 784,
|
|
41
41
|
"mode": 420
|
|
42
42
|
}
|
|
@@ -183,7 +183,7 @@ function loadNative() {
|
|
|
183
183
|
// src/native-worker-client.ts
|
|
184
184
|
init_esm_shims();
|
|
185
185
|
import { createRequire as createRequire2 } from "module";
|
|
186
|
-
import {
|
|
186
|
+
import { Worker } from "worker_threads";
|
|
187
187
|
|
|
188
188
|
// src/native-worker-protocol.ts
|
|
189
189
|
init_esm_shims();
|
|
@@ -313,7 +313,10 @@ var NativeWorkerClient = class {
|
|
|
313
313
|
getWorker() {
|
|
314
314
|
if (this.worker) return this.worker;
|
|
315
315
|
const worker = new Worker(this.workerPath(), {
|
|
316
|
-
|
|
316
|
+
// The bundled worker needs no application loaders or telemetry preloads.
|
|
317
|
+
// NODE_OPTIONS is parsed independently of execArgv by Node.
|
|
318
|
+
execArgv: [],
|
|
319
|
+
env: { ...process.env, NODE_OPTIONS: "" },
|
|
317
320
|
name: "tensorlake-native"
|
|
318
321
|
});
|
|
319
322
|
this.worker = worker;
|
|
@@ -387,7 +390,7 @@ var NativeWorkerClient = class {
|
|
|
387
390
|
}
|
|
388
391
|
};
|
|
389
392
|
var runtimeKey = /* @__PURE__ */ Symbol.for(
|
|
390
|
-
`tensorlake.native.worker.${false ? "source" : "0.5.
|
|
393
|
+
`tensorlake.native.worker.${false ? "source" : "0.5.133"}.v1`
|
|
391
394
|
);
|
|
392
395
|
var runtimes = globalThis;
|
|
393
396
|
function configureNativeWorker(workerPath) {
|