@tensorlakeai/tensorlake 0.0.0-bootstrap.0 → 0.5.145

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 (69) hide show
  1. package/README.md +166 -2
  2. package/bin/function-executor.js +8 -0
  3. package/bin/tensorlake-create-sandbox-image.js +9 -0
  4. package/bin/tensorlake-deploy.cjs +8 -0
  5. package/bin/tensorlake-import-sandbox-image.js +9 -0
  6. package/bin/tensorlake-typescript-function-runner.js +8 -0
  7. package/dist/applications/index.cjs +4821 -0
  8. package/dist/applications/index.cjs.map +1 -0
  9. package/dist/applications/index.d.cts +130 -0
  10. package/dist/applications/index.d.ts +130 -0
  11. package/dist/applications/index.js +4782 -0
  12. package/dist/applications/index.js.map +1 -0
  13. package/dist/function-agent/main.cjs +1838 -0
  14. package/dist/function-agent/main.cjs.map +1 -0
  15. package/dist/function-agent/main.d.cts +3 -0
  16. package/dist/function-agent/main.d.ts +3 -0
  17. package/dist/function-agent/main.js +1825 -0
  18. package/dist/function-agent/main.js.map +1 -0
  19. package/dist/function-executor/main.cjs +4944 -0
  20. package/dist/function-executor/main.cjs.map +1 -0
  21. package/dist/function-executor/main.d.cts +4 -0
  22. package/dist/function-executor/main.d.ts +4 -0
  23. package/dist/function-executor/main.js +4902 -0
  24. package/dist/function-executor/main.js.map +1 -0
  25. package/dist/index.cjs +10184 -0
  26. package/dist/index.cjs.map +1 -0
  27. package/dist/index.d.cts +2431 -0
  28. package/dist/index.d.ts +2431 -0
  29. package/dist/index.js +10108 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/native-worker.cjs +278 -0
  32. package/dist/native-worker.cjs.map +1 -0
  33. package/dist/native-worker.d.cts +2 -0
  34. package/dist/native-worker.d.ts +2 -0
  35. package/dist/native-worker.js +276 -0
  36. package/dist/native-worker.js.map +1 -0
  37. package/dist/remote-CNJ9TmcQ.d.cts +283 -0
  38. package/dist/remote-dblFxKug.d.ts +283 -0
  39. package/dist/sandbox-image-ChzWDeZy.d.cts +357 -0
  40. package/dist/sandbox-image-ChzWDeZy.d.ts +357 -0
  41. package/dist/sandbox-image.cjs +1992 -0
  42. package/dist/sandbox-image.cjs.map +1 -0
  43. package/dist/sandbox-image.d.cts +1 -0
  44. package/dist/sandbox-image.d.ts +1 -0
  45. package/dist/sandbox-image.js +1987 -0
  46. package/dist/sandbox-image.js.map +1 -0
  47. package/lib/libc.cjs +61 -0
  48. package/lib/libc.d.cts +1 -0
  49. package/lib/runtime.cjs +155 -0
  50. package/package.json +104 -4
  51. package/runtime/function-executor/manifest.json +59 -0
  52. package/runtime/function-executor/package/bin/function-executor.js +8 -0
  53. package/runtime/function-executor/package/dist/function-executor/main.js +4902 -0
  54. package/runtime/function-executor/package/dist/function-executor/main.js.map +1 -0
  55. package/runtime/function-executor/package/dist/native-worker.cjs +278 -0
  56. package/runtime/function-executor/package/dist/native-worker.cjs.map +1 -0
  57. package/runtime/function-executor/package/npm-shrinkwrap.json +475 -0
  58. package/runtime/function-executor/package/package.json +22 -0
  59. package/runtime/function-executor/package/proto/README.md +18 -0
  60. package/runtime/function-executor/package/proto/tensorlake/function_executor/proto/function_executor.proto +613 -0
  61. package/runtime/function-executor/package/proto/tensorlake/function_executor/proto/status.proto +42 -0
  62. package/runtime/typescript-function-runner/manifest.json +44 -0
  63. package/runtime/typescript-function-runner/package/bin/tensorlake-typescript-function-runner.js +8 -0
  64. package/runtime/typescript-function-runner/package/dist/function-agent/main.js +1825 -0
  65. package/runtime/typescript-function-runner/package/dist/function-agent/main.js.map +1 -0
  66. package/runtime/typescript-function-runner/package/dist/native-worker.cjs +278 -0
  67. package/runtime/typescript-function-runner/package/dist/native-worker.cjs.map +1 -0
  68. package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +586 -0
  69. package/runtime/typescript-function-runner/package/package.json +25 -0
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { detectLinuxLibc } = require("./libc.cjs");
4
+ const fs = require("node:fs");
5
+ const path = require("node:path");
6
+ const { spawnSync } = require("node:child_process");
7
+
8
+ const NATIVE_PACKAGES = {
9
+ "darwin-arm64": "@tensorlakeai/native-darwin-arm64",
10
+ "linux-arm64": "@tensorlakeai/native-linux-arm64-gnu",
11
+ "linux-arm64-musl": "@tensorlakeai/native-linux-arm64-musl",
12
+ "linux-x64": "@tensorlakeai/native-linux-x64-gnu",
13
+ "linux-x64-musl": "@tensorlakeai/native-linux-x64-musl",
14
+ "win32-x64": "@tensorlakeai/native-win32-x64",
15
+ };
16
+
17
+ function packageRoot() {
18
+ return path.resolve(__dirname, "..");
19
+ }
20
+
21
+ function baseTargetId(platform = process.platform, arch = process.arch) {
22
+ return `${platform}-${arch}`;
23
+ }
24
+
25
+ let cachedLinuxLibc;
26
+
27
+ function linuxLibcFamily(options = {}) {
28
+ if (options.libc === "gnu" || options.libc === "musl") {
29
+ return options.libc;
30
+ }
31
+ if (options.report != null) {
32
+ return options.report.header?.glibcVersionRuntime ? "gnu" : "musl";
33
+ }
34
+ if (cachedLinuxLibc != null) return cachedLinuxLibc;
35
+
36
+ cachedLinuxLibc = detectLinuxLibc(fs);
37
+ return cachedLinuxLibc;
38
+ }
39
+
40
+ function packageTargetId(platform = process.platform, arch = process.arch, options = {}) {
41
+ const targetId = baseTargetId(platform, arch);
42
+ if (platform !== "linux") {
43
+ return targetId;
44
+ }
45
+ if (!options.libc && !options.report && platform !== process.platform) {
46
+ return targetId;
47
+ }
48
+ return linuxLibcFamily(options) === "musl" ? `${targetId}-musl` : targetId;
49
+ }
50
+
51
+ function nativeTargetId(platform = process.platform, arch = process.arch, options = {}) {
52
+ return packageTargetId(platform, arch, options);
53
+ }
54
+
55
+ function nativeBindingPath(options = {}) {
56
+ const platform = options.platform ?? process.platform;
57
+ const arch = options.arch ?? process.arch;
58
+ const root = options.packageRoot ?? packageRoot();
59
+ return path.join(
60
+ root,
61
+ "dist",
62
+ "native",
63
+ nativeTargetId(platform, arch, options),
64
+ "tensorlake-node.node",
65
+ );
66
+ }
67
+
68
+ function nativePackageName(platform = process.platform, arch = process.arch, options = {}) {
69
+ return NATIVE_PACKAGES[nativeTargetId(platform, arch, options)];
70
+ }
71
+
72
+ function loadNative() {
73
+ const targetId = nativeTargetId();
74
+ const bindingPath = nativeBindingPath();
75
+ if (fs.existsSync(bindingPath)) {
76
+ return require(bindingPath);
77
+ }
78
+
79
+ const packageName = nativePackageName();
80
+ if (!packageName) {
81
+ throw new Error(
82
+ `Tensorlake does not provide a native binding for ${targetId}.`,
83
+ );
84
+ }
85
+
86
+ let packageEntry;
87
+ try {
88
+ packageEntry = require.resolve(packageName);
89
+ } catch (cause) {
90
+ throw new Error(
91
+ `Missing native binding package ${packageName} for ${targetId}. Reinstall @tensorlakeai/tensorlake without omitting optional dependencies, and install dependencies on the machine where they will run.`,
92
+ { cause },
93
+ );
94
+ }
95
+ return require(packageEntry);
96
+ }
97
+
98
+ function exitWithSpawnResult(result) {
99
+ if (result.error) {
100
+ console.error(result.error.message);
101
+ process.exit(1);
102
+ }
103
+ process.exit(result.status ?? 1);
104
+ }
105
+
106
+ function findPython() {
107
+ const candidates =
108
+ process.platform === "win32"
109
+ ? [
110
+ { command: "py", prefix: ["-3"] },
111
+ { command: "python", prefix: [] },
112
+ ]
113
+ : [
114
+ { command: "python3", prefix: [] },
115
+ { command: "python", prefix: [] },
116
+ ];
117
+
118
+ for (const candidate of candidates) {
119
+ const probe = spawnSync(candidate.command, [...candidate.prefix, "--version"], {
120
+ stdio: "ignore",
121
+ env: process.env,
122
+ });
123
+ if (!probe.error && probe.status === 0) {
124
+ return candidate;
125
+ }
126
+ }
127
+
128
+ return null;
129
+ }
130
+
131
+ function runPythonModule(moduleName, helpText) {
132
+ const python = findPython();
133
+ if (!python) {
134
+ console.error(helpText);
135
+ process.exit(1);
136
+ }
137
+
138
+ const result = spawnSync(
139
+ python.command,
140
+ [...python.prefix, "-m", moduleName, ...process.argv.slice(2)],
141
+ {
142
+ stdio: "inherit",
143
+ env: process.env,
144
+ },
145
+ );
146
+ exitWithSpawnResult(result);
147
+ }
148
+
149
+ module.exports = {
150
+ loadNative,
151
+ nativeTargetId,
152
+ nativeBindingPath,
153
+ nativePackageName,
154
+ runPythonModule,
155
+ };
package/package.json CHANGED
@@ -1,7 +1,107 @@
1
1
  {
2
2
  "name": "@tensorlakeai/tensorlake",
3
- "version": "0.0.0-bootstrap.0",
4
- "description": "Name reserved by Tensorlake. Real releases are published from github.com/tensorlakeai/tensorlake.",
5
- "repository": { "type": "git", "url": "git+https://github.com/tensorlakeai/tensorlake.git" },
6
- "license": "Apache-2.0"
3
+ "version": "0.5.145",
4
+ "description": "TensorLake SDK for applications, sandboxes, and cloud services",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "bin": {
10
+ "tensorlake-deploy": "./bin/tensorlake-deploy.cjs",
11
+ "tensorlake-create-sandbox-image": "./bin/tensorlake-create-sandbox-image.js",
12
+ "tensorlake-import-sandbox-image": "./bin/tensorlake-import-sandbox-image.js",
13
+ "function-executor": "./bin/function-executor.js",
14
+ "tensorlake-typescript-function-runner": "./bin/tensorlake-typescript-function-runner.js"
15
+ },
16
+ "exports": {
17
+ "./internal/native-worker": "./dist/native-worker.cjs",
18
+ ".": {
19
+ "import": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "require": {
24
+ "types": "./dist/index.d.cts",
25
+ "default": "./dist/index.cjs"
26
+ }
27
+ },
28
+ "./applications": {
29
+ "import": {
30
+ "types": "./dist/applications/index.d.ts",
31
+ "default": "./dist/applications/index.js"
32
+ },
33
+ "require": {
34
+ "types": "./dist/applications/index.d.cts",
35
+ "default": "./dist/applications/index.cjs"
36
+ }
37
+ }
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "!dist/native",
42
+ "bin",
43
+ "lib",
44
+ "runtime"
45
+ ],
46
+ "scripts": {
47
+ "build:sdk": "tsup",
48
+ "build:runtime": "node ./scripts/build-function-executor-capsule.mjs && node ./scripts/build-typescript-function-runner-capsule.mjs && node ./scripts/check-package-compatibility.mjs",
49
+ "build:native": "node ./scripts/build-native.mjs",
50
+ "build": "npm run build:sdk && npm run build:native && npm run build:runtime",
51
+ "check:proto": "node ./scripts/check-function-executor-proto.mjs",
52
+ "check:install-scripts": "node ./scripts/check-no-install-scripts.mjs",
53
+ "typecheck": "tsc --noEmit",
54
+ "test": "vitest run --exclude tests/integration.test.ts",
55
+ "test:function-executor": "vitest run tests/function-executor.test.ts tests/function-executor-protocol.test.ts",
56
+ "test:function-agent": "vitest run tests/function-agent.test.ts",
57
+ "test:integration": "vitest run tests/integration.test.ts",
58
+ "test:native-sandbox": "node ./scripts/test-native-sandbox.mjs",
59
+ "test:native-cloud": "node ./scripts/test-native-cloud.mjs",
60
+ "test:watch": "vitest",
61
+ "lint": "eslint src/ tests/",
62
+ "prepack": "npm run build"
63
+ },
64
+ "engines": {
65
+ "node": ">=22.0.0"
66
+ },
67
+ "keywords": [
68
+ "tensorlake",
69
+ "sandbox",
70
+ "cloud",
71
+ "sdk",
72
+ "applications"
73
+ ],
74
+ "repository": {
75
+ "type": "git",
76
+ "url": "https://github.com/tensorlakeai/tensorlake",
77
+ "directory": "typescript"
78
+ },
79
+ "license": "Apache-2.0",
80
+ "devDependencies": {
81
+ "@eslint/js": "^9.39.4",
82
+ "@types/node": "^24.0.0",
83
+ "@types/ws": "^8.18.1",
84
+ "eslint": "^9.0.0",
85
+ "tsup": "^8.0.0",
86
+ "typescript": "^5.8.0",
87
+ "typescript-eslint": "^8.65.0",
88
+ "vitest": "^2.0.0"
89
+ },
90
+ "dependencies": {
91
+ "@grpc/grpc-js": "^1.13.0",
92
+ "@grpc/proto-loader": "^0.8.0",
93
+ "ajv": "^8.17.1",
94
+ "fflate": "^0.8.2",
95
+ "google-proto-files": "^5.0.2",
96
+ "nanoid": "^3.3.18",
97
+ "ws": "^8.20.0"
98
+ },
99
+ "optionalDependencies": {
100
+ "@tensorlakeai/native-darwin-arm64": "0.5.145",
101
+ "@tensorlakeai/native-linux-arm64-gnu": "0.5.145",
102
+ "@tensorlakeai/native-linux-arm64-musl": "0.5.145",
103
+ "@tensorlakeai/native-linux-x64-gnu": "0.5.145",
104
+ "@tensorlakeai/native-linux-x64-musl": "0.5.145",
105
+ "@tensorlakeai/native-win32-x64": "0.5.145"
106
+ }
7
107
  }
@@ -0,0 +1,59 @@
1
+ {
2
+ "format_version": 1,
3
+ "sdk_version": "0.5.145",
4
+ "minimum_node_major": 24,
5
+ "package_name": "@tensorlake/function-executor-runtime",
6
+ "runtime_id": "sha256:91f9a51a84d4b5c121bd7d6f9330a561f626e0788acd22a9f7044815fa6937b2",
7
+ "files": {
8
+ "package/bin/function-executor.js": {
9
+ "sha256": "0191f54ac8d3f30ce710cf30f9c58a585710412fcf6b7e3433e9f287b9abf45c",
10
+ "size": 209,
11
+ "mode": 493
12
+ },
13
+ "package/dist/function-executor/main.js": {
14
+ "sha256": "8d4729c476f5d797f5c2b5163eaeac7fd054574683c51ea7f72cd5e76a5747ff",
15
+ "size": 184170,
16
+ "mode": 420
17
+ },
18
+ "package/dist/function-executor/main.js.map": {
19
+ "sha256": "77cc0cbc16ff1582c6e7025f96531e54ad1029b148693c7f76a68f856d9da75f",
20
+ "size": 409040,
21
+ "mode": 420
22
+ },
23
+ "package/dist/native-worker.cjs": {
24
+ "sha256": "3ff258b0e7ff7f3fb949340c7204b25c008b5923ea6b3d7d63dd849adca695ef",
25
+ "size": 10902,
26
+ "mode": 420
27
+ },
28
+ "package/dist/native-worker.cjs.map": {
29
+ "sha256": "4cc3aac0a0d95db88ff170aa6ae28931caa7bbb7f58fe27d37165e19669b556c",
30
+ "size": 17249,
31
+ "mode": 420
32
+ },
33
+ "package/npm-shrinkwrap.json": {
34
+ "sha256": "666c76fc5a7fdb5fd807cf073ae404f4887c0d8ea8e3076d5f5e95806349769b",
35
+ "size": 17965,
36
+ "mode": 420
37
+ },
38
+ "package/package.json": {
39
+ "sha256": "704eeda6d3da988d3c4f16949c8ecd64672c4c63445b3f19c9b9d136c7e972ab",
40
+ "size": 516,
41
+ "mode": 420
42
+ },
43
+ "package/proto/README.md": {
44
+ "sha256": "c2d6da5e218926ea46d5efab56c931ac096a98b0ee695c7d21a26867a11948c7",
45
+ "size": 901,
46
+ "mode": 420
47
+ },
48
+ "package/proto/tensorlake/function_executor/proto/function_executor.proto": {
49
+ "sha256": "d020277a118973ef7f8839752e4d50c74f635b3f6501e64103f47ce6078117fd",
50
+ "size": 23670,
51
+ "mode": 420
52
+ },
53
+ "package/proto/tensorlake/function_executor/proto/status.proto": {
54
+ "sha256": "789cde8a3953307306854d9fbbf48f8661c7534172aa9f4064ac7641755b231b",
55
+ "size": 1927,
56
+ "mode": 420
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { main } from "../dist/function-executor/main.js";
4
+
5
+ main(process.argv.slice(2)).catch((error) => {
6
+ process.stderr.write(`${error?.stack ?? error}\n`);
7
+ process.exitCode = 1;
8
+ });