tensorlake 0.5.142 → 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 (77) hide show
  1. package/README.md +11 -159
  2. package/applications.cjs +3 -0
  3. package/applications.d.cts +1 -0
  4. package/applications.d.ts +1 -0
  5. package/applications.js +1 -0
  6. package/index.cjs +3 -0
  7. package/index.d.cts +1 -0
  8. package/index.d.ts +1 -0
  9. package/index.js +1 -0
  10. package/package.json +25 -68
  11. package/bin/function-executor.js +0 -8
  12. package/bin/tensorlake-create-sandbox-image.js +0 -9
  13. package/bin/tensorlake-deploy.cjs +0 -8
  14. package/bin/tensorlake-import-sandbox-image.js +0 -9
  15. package/bin/tensorlake-typescript-function-runner.js +0 -8
  16. package/dist/applications/index.cjs +0 -4812
  17. package/dist/applications/index.cjs.map +0 -1
  18. package/dist/applications/index.d.cts +0 -130
  19. package/dist/applications/index.d.ts +0 -130
  20. package/dist/applications/index.js +0 -4773
  21. package/dist/applications/index.js.map +0 -1
  22. package/dist/function-agent/main.cjs +0 -1838
  23. package/dist/function-agent/main.cjs.map +0 -1
  24. package/dist/function-agent/main.d.cts +0 -3
  25. package/dist/function-agent/main.d.ts +0 -3
  26. package/dist/function-agent/main.js +0 -1825
  27. package/dist/function-agent/main.js.map +0 -1
  28. package/dist/function-executor/main.cjs +0 -4944
  29. package/dist/function-executor/main.cjs.map +0 -1
  30. package/dist/function-executor/main.d.cts +0 -4
  31. package/dist/function-executor/main.d.ts +0 -4
  32. package/dist/function-executor/main.js +0 -4902
  33. package/dist/function-executor/main.js.map +0 -1
  34. package/dist/index.cjs +0 -10175
  35. package/dist/index.cjs.map +0 -1
  36. package/dist/index.d.cts +0 -2427
  37. package/dist/index.d.ts +0 -2427
  38. package/dist/index.js +0 -10099
  39. package/dist/index.js.map +0 -1
  40. package/dist/native-worker.cjs +0 -278
  41. package/dist/native-worker.cjs.map +0 -1
  42. package/dist/native-worker.d.cts +0 -2
  43. package/dist/native-worker.d.ts +0 -2
  44. package/dist/native-worker.js +0 -276
  45. package/dist/native-worker.js.map +0 -1
  46. package/dist/remote-D95Y6Czr.d.cts +0 -282
  47. package/dist/remote-omwTzbfj.d.ts +0 -282
  48. package/dist/sandbox-image-ChzWDeZy.d.cts +0 -357
  49. package/dist/sandbox-image-ChzWDeZy.d.ts +0 -357
  50. package/dist/sandbox-image.cjs +0 -1992
  51. package/dist/sandbox-image.cjs.map +0 -1
  52. package/dist/sandbox-image.d.cts +0 -1
  53. package/dist/sandbox-image.d.ts +0 -1
  54. package/dist/sandbox-image.js +0 -1987
  55. package/dist/sandbox-image.js.map +0 -1
  56. package/lib/libc.cjs +0 -61
  57. package/lib/libc.d.cts +0 -1
  58. package/lib/runtime.cjs +0 -155
  59. package/runtime/function-executor/manifest.json +0 -59
  60. package/runtime/function-executor/package/bin/function-executor.js +0 -8
  61. package/runtime/function-executor/package/dist/function-executor/main.js +0 -4902
  62. package/runtime/function-executor/package/dist/function-executor/main.js.map +0 -1
  63. package/runtime/function-executor/package/dist/native-worker.cjs +0 -278
  64. package/runtime/function-executor/package/dist/native-worker.cjs.map +0 -1
  65. package/runtime/function-executor/package/npm-shrinkwrap.json +0 -475
  66. package/runtime/function-executor/package/package.json +0 -22
  67. package/runtime/function-executor/package/proto/README.md +0 -18
  68. package/runtime/function-executor/package/proto/tensorlake/function_executor/proto/function_executor.proto +0 -613
  69. package/runtime/function-executor/package/proto/tensorlake/function_executor/proto/status.proto +0 -42
  70. package/runtime/typescript-function-runner/manifest.json +0 -44
  71. package/runtime/typescript-function-runner/package/bin/tensorlake-typescript-function-runner.js +0 -8
  72. package/runtime/typescript-function-runner/package/dist/function-agent/main.js +0 -1825
  73. package/runtime/typescript-function-runner/package/dist/function-agent/main.js.map +0 -1
  74. package/runtime/typescript-function-runner/package/dist/native-worker.cjs +0 -278
  75. package/runtime/typescript-function-runner/package/dist/native-worker.cjs.map +0 -1
  76. package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +0 -580
  77. package/runtime/typescript-function-runner/package/package.json +0 -25
package/README.md CHANGED
@@ -1,167 +1,19 @@
1
- # Tensorlake TypeScript SDK
1
+ # tensorlake
2
2
 
3
- The TypeScript SDK supports Tensorlake sandboxes on Node.js 22 or newer. Deploying and running durable TypeScript applications requires Node.js 24 or newer. Application handlers are async-only and values crossing a function boundary must be JSON values or a direct `File`. Application entrypoints can also receive an exact raw request body with `HttpBody`.
3
+ This package has moved to [`@tensorlakeai/tensorlake`](https://www.npmjs.com/package/@tensorlakeai/tensorlake).
4
4
 
5
- Sandbox, repository and filesystem handles retain configuration on the calling thread.
6
- The first native operation starts a persistent Node worker that loads the addon and
7
- owns the native clients. Concurrent calls use the same worker; sandbox proxies share
8
- their lifecycle client's connection pool. Addon loading and TLS initialization keep
9
- the application's event loop responsive, including on the first call. Initialization
10
- failures reject the operation. A later operation can retry transport initialization;
11
- creating a new client picks up changes to the system's trusted certificates.
5
+ `tensorlake` is kept as a compatibility package: it depends on the same version
6
+ of `@tensorlakeai/tensorlake` and re-exports it, so existing imports such as
7
+ `import { SandboxClient } from "tensorlake"` and
8
+ `import { registerApplication } from "tensorlake/applications"` keep working.
12
9
 
13
- Streaming consumers acknowledge each event before Rust reads the next one. Breaking
14
- iteration, aborting its signal, or closing the sandbox connection cancels the native
15
- HTTP stream. Closing one handle leaves sibling handles usable. Garbage collection
16
- also releases native handles, and an idle worker does not keep Node running. If a
17
- worker fails, outstanding calls reject without automatic replay; subsequent calls
18
- can start a fresh worker. Byte arguments are copied across the worker boundary;
19
- caller-owned buffers are never detached. File-path upload APIs avoid that copy.
10
+ New projects should install the scoped package and import from it directly:
20
11
 
21
- Both ESM and CommonJS packages include the worker entrypoint. Applications using a
22
- bundler should keep `tensorlake` external so its worker and optional native packages
23
- remain available at runtime. Tensorlake's function runtime capsules carry the worker
24
- for deployed application bundles. Image-building and Function Agent runtime bindings
25
- have their own native entrypoints and are outside this sandbox worker boundary.
26
-
27
- On Linux, native binding selection reads the Node executable's ELF interpreter
28
- without generating diagnostic reports. For a nonstandard or statically linked Node
29
- executable, set `TENSORLAKE_NODE_LIBC=gnu` or `TENSORLAKE_NODE_LIBC=musl` before using
30
- the SDK.
31
-
32
- ```ts
33
- import { registerApplication, registerFunction } from "tensorlake/applications";
34
-
35
- const square = registerFunction(
36
- "square",
37
- async (value: number) => value * value,
38
- );
39
-
40
- export const squares = registerApplication(
41
- "squares",
42
- async (values: number[]) => square.map(values),
43
- );
12
+ ```sh
13
+ npm install @tensorlakeai/tensorlake
44
14
  ```
45
15
 
46
- This concise form infers the TypeScript call signature and uses permissive JSON
47
- schemas. JavaScript default parameters are inferred as optional, and the
48
- explicit name is stable across bundling. Use the schema-rich form when you need
49
- runtime validation, API metadata, optional parameters without a JavaScript
50
- default, rest parameters, `File` inputs and outputs, or an `HttpBody` input:
51
-
52
16
  ```ts
53
- import { registerApplication, schema } from "tensorlake/applications";
54
-
55
- export const validatedSquare = registerApplication(
56
- async (value: number) => value * value,
57
- {
58
- name: "validated_square",
59
- parameters: [schema.parameter("value", schema.number())] as const,
60
- returns: schema.number(),
61
- },
62
- );
63
- ```
64
-
65
- Run locally or deploy the same file:
66
-
67
- ```ts
68
- import { runLocal } from "tensorlake/applications";
69
-
70
- const request = await runLocal(squares, [1, 2, 3]);
71
- console.log(await request.output());
72
- ```
73
-
74
- Use `runRemote` for a deployed application. Plain client options remain the
75
- last argument when every application argument is supplied. Wrap options with
76
- `remoteOptions` when omitting JavaScript default arguments so an object input
77
- can never be mistaken for client configuration:
78
-
79
- ```ts
80
- import { registerApplication, remoteOptions, runRemote } from "tensorlake/applications";
81
-
82
- const greeting = registerApplication(
83
- "greeting",
84
- async (name = "world") => `Hello, ${name}!`,
85
- );
86
-
87
- const request = await runRemote(
88
- greeting,
89
- remoteOptions({ apiKey: process.env.TENSORLAKE_API_KEY }),
90
- );
91
- console.log(await request.output());
92
- ```
93
-
94
- ```bash
95
- npm install tensorlake
96
- tl deploy app.ts
17
+ import { SandboxClient } from "@tensorlakeai/tensorlake";
18
+ import { registerApplication } from "@tensorlakeai/tensorlake/applications";
97
19
  ```
98
-
99
- `tl` recognizes ESM `.ts`, `.mts`, `.js`, and `.mjs` entrypoints. The Rust CLI bundles the application for Node 24 with Rolldown, initializes the resulting ESM bundle once with Node to discover its registered functions, builds the function images, and uploads the deployment. CommonJS application modules and bundler configuration files are not supported.
100
-
101
- The SDK build also produces a hashed executor capsule containing the Node 24 ESM executor, its protobufs, and an npm shrinkwrap derived from the checked-in SDK lockfile. During deployment, `tl` uses the capsule from the exact SDK package Rolldown resolved and adds it directly to the image-build context. This supports local dependencies such as `"tensorlake": "file:../tensorlake/typescript"`; build that SDK checkout with `npm run build:sdk` before deploying. The local Tensorlake package does not need to be published.
102
-
103
- Functions expose `future`, `map`, `reduce`, and `tailCall`. `map` and `reduce`
104
- accept either an iterable or a Promise/Future that produces one, and their
105
- iterables may contain Promise/Future values. A reduce initial value is optional;
106
- without one, the first item becomes the accumulator and an empty collection is
107
- an error. Awaiting a registered function inside a running application creates a
108
- durable remote function call. `RequestContext.get()` provides async request
109
- state, metrics, progress, and an abort signal. Local requests expose `cancel()`,
110
- which aborts that signal and rejects `output()`.
111
-
112
- TypeScript and Python definitions cannot be mixed in one deployed application bundle. Class-based function semantics are not supported in the TypeScript runtime.
113
-
114
- For a raw request body, declare a direct application parameter with
115
- `schema.httpBody()`. `HttpBody.content` contains the unchanged bytes,
116
- `contentType` preserves the request MIME type, and `text()` / `json()` provide
117
- explicit decoding helpers. `RequestContext.get().headers` exposes sanitized,
118
- case-insensitive invocation headers and preserves duplicate values through
119
- `getAll()`. `HttpBody` is not supported in nested schemas, durable function
120
- parameters, or return values. See the
121
- [raw webhook example](examples/http-body/README.md).
122
-
123
- Applications that accept public HTTP requests can set
124
- `allow: ["unauthenticated_requests"]` in their registration options. The
125
- capability is emitted in the deployment manifest, and deployments preserve the
126
- application's stable public endpoint identifier across updates.
127
-
128
- ## Function executor correctness
129
-
130
- Run the executor transport and protocol-state regression suites with:
131
-
132
- ```bash
133
- npm run test:function-executor
134
- ```
135
-
136
- These tests use bounded fake-server event sequences to cover terminal-result cardinality, retry exhaustion, deterministic concurrent fan-out and strict replay, function-call reduce chains, malformed user input, non-advancing event pages, tail calls, cross-bundle request errors, state reconciliation, and ranged BLOB transport. `npm run build:sdk` additionally builds the exact executor capsule used during deployment.
137
-
138
- ## Live server verification
139
-
140
- The [server-verification example](examples/server-verification/README.md) uses the normal `tl deploy <PATH>` workflow to deploy eight reference applications and verify durable calls, retries and retry exhaustion, concurrent fan-out, server-orchestrated reduce, nested calls, request context, tail calls, files, and request errors against an already-running server.
141
-
142
- ## Native transport and application preloads
143
-
144
- Cloud, sandbox, repository, and filesystem HTTP operations use the Rust SDK
145
- through an internal worker. Keep the platform-specific optional native package
146
- installed. Importing Tensorlake does not replace the application's HTTP dispatcher.
147
-
148
- The worker starts with an empty `execArgv` and a copied environment with
149
- `NODE_OPTIONS` cleared, so application `--require`, `--import`, and loader hooks
150
- do not run inside it. Other environment variables are copied when it starts.
151
- The application's own startup flags and environment remain intact. Native HTTPS
152
- uses the Rust SDK's bundled Mozilla certificate roots.
153
-
154
- `CloudClient.close()` cancels its active requests and streams and prevents further
155
- requests. Buffered cloud requests have a 300-second deadline covering retries and
156
- body reads. Progress and build-log streams have a connection deadline and can
157
- remain open until completion or cancellation. `maxRetries` and `retryBackoffMs`
158
- control transient retries for safe reads; mutations are replayed only when the
159
- Rust retry policy establishes that they were not delivered, within its 30-second
160
- replay budget. A lost response after delivery does not replay an application invocation.
161
- Mutation redirects are returned as errors instead of being followed, because a
162
- failure fetching the redirected result cannot prove that the mutation was not
163
- delivered. Safe reads still follow redirects and retry failed response transfers.
164
- Cloud requests advertise gzip support and decode gzip responses, including live SSE.
165
-
166
- After building the SDK and native addon, run `npm run test:native-cloud` to check
167
- the cloud transport against a local HTTP server.
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ module.exports = require("@tensorlakeai/tensorlake/applications");
@@ -0,0 +1 @@
1
+ export * from "@tensorlakeai/tensorlake/applications";
@@ -0,0 +1 @@
1
+ export * from "@tensorlakeai/tensorlake/applications";
@@ -0,0 +1 @@
1
+ export * from "@tensorlakeai/tensorlake/applications";
package/index.cjs ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ module.exports = require("@tensorlakeai/tensorlake");
package/index.d.cts ADDED
@@ -0,0 +1 @@
1
+ export * from "@tensorlakeai/tensorlake";
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "@tensorlakeai/tensorlake";
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "@tensorlakeai/tensorlake";
package/package.json CHANGED
@@ -1,65 +1,43 @@
1
1
  {
2
2
  "name": "tensorlake",
3
- "version": "0.5.142",
4
- "description": "TensorLake SDK for applications, sandboxes, and cloud services",
3
+ "version": "0.5.145",
4
+ "description": "Compatibility package that re-exports @tensorlakeai/tensorlake. New projects should depend on @tensorlakeai/tensorlake directly.",
5
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
- },
6
+ "main": "./index.cjs",
7
+ "module": "./index.js",
8
+ "types": "./index.d.ts",
16
9
  "exports": {
17
- "./internal/native-worker": "./dist/native-worker.cjs",
18
10
  ".": {
19
11
  "import": {
20
- "types": "./dist/index.d.ts",
21
- "default": "./dist/index.js"
12
+ "types": "./index.d.ts",
13
+ "default": "./index.js"
22
14
  },
23
15
  "require": {
24
- "types": "./dist/index.d.cts",
25
- "default": "./dist/index.cjs"
16
+ "types": "./index.d.cts",
17
+ "default": "./index.cjs"
26
18
  }
27
19
  },
28
20
  "./applications": {
29
21
  "import": {
30
- "types": "./dist/applications/index.d.ts",
31
- "default": "./dist/applications/index.js"
22
+ "types": "./applications.d.ts",
23
+ "default": "./applications.js"
32
24
  },
33
25
  "require": {
34
- "types": "./dist/applications/index.d.cts",
35
- "default": "./dist/applications/index.cjs"
26
+ "types": "./applications.d.cts",
27
+ "default": "./applications.cjs"
36
28
  }
37
29
  }
38
30
  },
39
31
  "files": [
40
- "dist",
41
- "!dist/native",
42
- "bin",
43
- "lib",
44
- "runtime"
32
+ "index.js",
33
+ "index.cjs",
34
+ "index.d.ts",
35
+ "index.d.cts",
36
+ "applications.js",
37
+ "applications.cjs",
38
+ "applications.d.ts",
39
+ "applications.d.cts"
45
40
  ],
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
- "typecheck": "tsc --noEmit",
53
- "test": "vitest run --exclude tests/integration.test.ts",
54
- "test:function-executor": "vitest run tests/function-executor.test.ts tests/function-executor-protocol.test.ts",
55
- "test:function-agent": "vitest run tests/function-agent.test.ts",
56
- "test:integration": "vitest run tests/integration.test.ts",
57
- "test:native-sandbox": "node ./scripts/test-native-sandbox.mjs",
58
- "test:native-cloud": "node ./scripts/test-native-cloud.mjs",
59
- "test:watch": "vitest",
60
- "lint": "eslint src/ tests/",
61
- "prepack": "npm run build"
62
- },
63
41
  "engines": {
64
42
  "node": ">=22.0.0"
65
43
  },
@@ -73,34 +51,13 @@
73
51
  "repository": {
74
52
  "type": "git",
75
53
  "url": "https://github.com/tensorlakeai/tensorlake",
76
- "directory": "typescript"
54
+ "directory": "typescript/tensorlake-wrapper"
77
55
  },
78
56
  "license": "Apache-2.0",
79
- "devDependencies": {
80
- "@eslint/js": "^9.39.4",
81
- "@types/node": "^24.0.0",
82
- "@types/ws": "^8.18.1",
83
- "eslint": "^9.0.0",
84
- "tsup": "^8.0.0",
85
- "typescript": "^5.8.0",
86
- "typescript-eslint": "^8.65.0",
87
- "vitest": "^2.0.0"
88
- },
89
57
  "dependencies": {
90
- "@grpc/grpc-js": "^1.13.0",
91
- "@grpc/proto-loader": "^0.8.0",
92
- "ajv": "^8.17.1",
93
- "fflate": "^0.8.2",
94
- "google-proto-files": "^5.0.2",
95
- "nanoid": "^3.3.18",
96
- "ws": "^8.20.0"
58
+ "@tensorlakeai/tensorlake": "0.5.145"
97
59
  },
98
- "optionalDependencies": {
99
- "tensorlake-native-darwin-arm64": "0.5.142",
100
- "tensorlake-native-linux-arm64-gnu": "0.5.142",
101
- "tensorlake-native-linux-arm64-musl": "0.5.142",
102
- "tensorlake-native-linux-x64-gnu": "0.5.142",
103
- "tensorlake-native-linux-x64-musl": "0.5.142",
104
- "tensorlake-native-win32-x64": "0.5.142"
60
+ "publishConfig": {
61
+ "access": "public"
105
62
  }
106
63
  }
@@ -1,8 +0,0 @@
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
- });
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { runCreateSandboxImageCli } from "../dist/sandbox-image.js";
4
-
5
- runCreateSandboxImageCli().catch((error) => {
6
- const message = error instanceof Error ? error.stack : String(error);
7
- process.stderr.write(`${message}\n`);
8
- process.exit(1);
9
- });
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { runPythonModule } = require("../lib/runtime.cjs");
4
-
5
- runPythonModule(
6
- "tensorlake.cli.deploy",
7
- "Python 3 with the 'tensorlake' package installed is required for tensorlake-deploy.",
8
- );
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { runImportSandboxImageCli } from "../dist/sandbox-image.js";
4
-
5
- runImportSandboxImageCli().catch((error) => {
6
- const message = error instanceof Error ? error.stack : String(error);
7
- process.stderr.write(`${message}\n`);
8
- process.exit(1);
9
- });
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { main } from "../dist/function-agent/main.js";
4
-
5
- main(process.argv.slice(2)).catch((error) => {
6
- process.stderr.write(`${error instanceof Error ? error.stack : String(error)}\n`);
7
- process.exitCode = 1;
8
- });