withruntime 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +68 -4
  2. package/dist/cli.d.ts +9 -0
  3. package/dist/cli.js +1262 -0
  4. package/dist/client.d.ts +118 -0
  5. package/dist/client.js +160 -0
  6. package/dist/credentials.d.ts +44 -0
  7. package/dist/credentials.js +180 -0
  8. package/dist/errors.d.ts +58 -0
  9. package/dist/errors.js +106 -0
  10. package/dist/index.d.ts +36 -0
  11. package/dist/index.js +25 -0
  12. package/dist/login.d.ts +119 -0
  13. package/dist/login.js +367 -0
  14. package/dist/mcp.d.ts +15 -0
  15. package/dist/mcp.js +221 -0
  16. package/dist/page.d.ts +13 -0
  17. package/dist/page.js +39 -0
  18. package/dist/products/desktop.d.ts +103 -0
  19. package/dist/products/desktop.js +38 -0
  20. package/dist/products/images.d.ts +121 -0
  21. package/dist/products/images.js +64 -0
  22. package/dist/products/index.d.ts +29 -0
  23. package/dist/products/index.js +36 -0
  24. package/dist/products/interpreter.d.ts +88 -0
  25. package/dist/products/interpreter.js +81 -0
  26. package/dist/products/network.d.ts +47 -0
  27. package/dist/products/network.js +19 -0
  28. package/dist/products/previews.d.ts +51 -0
  29. package/dist/products/previews.js +30 -0
  30. package/dist/products/referrals.d.ts +36 -0
  31. package/dist/products/referrals.js +8 -0
  32. package/dist/products/volumes.d.ts +47 -0
  33. package/dist/products/volumes.js +27 -0
  34. package/dist/sandbox.d.ts +192 -0
  35. package/dist/sandbox.js +628 -0
  36. package/dist/snapshots.d.ts +50 -0
  37. package/dist/snapshots.js +55 -0
  38. package/dist/tar.d.ts +3 -0
  39. package/dist/tar.js +116 -0
  40. package/dist/transport.d.ts +65 -0
  41. package/dist/transport.js +261 -0
  42. package/dist/types.d.ts +175 -0
  43. package/dist/types.js +1 -0
  44. package/package.json +53 -8
  45. package/cli.js +0 -7
package/README.md CHANGED
@@ -1,7 +1,71 @@
1
- # withruntime
1
+ # Runtime Cloud SDK and CLI
2
2
 
3
- This name belongs to [Runtime Cloud](https://withruntime.com) and forwards to the official package, [`@withruntime/cloud`](https://www.npmjs.com/package/@withruntime/cloud).
3
+ One client for every Runtime Cloud product, and the `runtime` CLI. No
4
+ dependencies; Node.js 22 or later, or Bun.
4
5
 
5
- ```sh
6
- npx @withruntime/cloud --help
6
+ ```bash no-run
7
+ npm install withruntime
7
8
  ```
9
+
10
+ The client uses `RUNTIME_API_KEY` when it is set, and otherwise the connection
11
+ this machine saved when the CLI connected it (one browser approval, no key to
12
+ copy). On a server, set `RUNTIME_API_KEY` from your secret manager (create a key
13
+ at https://withruntime.com/account/keys). Never put a key in browser code, a URL
14
+ or a command-line argument.
15
+
16
+ ```ts
17
+ import { Sandbox } from "withruntime";
18
+
19
+ await using sbx = await Sandbox.create();
20
+ const result = await sbx.exec("python3 -c 'print(6 * 7)'");
21
+ console.log(result.exitCode, result.stdout);
22
+ ```
23
+
24
+ `Sandbox.create()` needs no arguments and returns once the sandbox is running;
25
+ `await using` stops it when the block ends (Node 24, Bun or TypeScript; on
26
+ Node 22 call `await sbx.stop()`). With no arguments you get the free
27
+ trial while it lasts (20 hours, up to three sandboxes at once), 2 vCPU, 4 GiB of
28
+ memory and a 4 GiB disk.
29
+
30
+ The sandbox object does the rest:
31
+
32
+ - `exec`, `execStream`, `spawn` and `processes` for commands and background
33
+ work, with `cwd`, `env` (the place for secrets), `stdin` and `timeoutMs`;
34
+ - `terminal()` for an interactive terminal over a WebSocket;
35
+ - `files` to read, write, list, glob, stat, move and remove, and to copy whole
36
+ directories with `upload` and `download`;
37
+ - `pause`, `wake`, `extend`, `fork` and `snapshot`;
38
+ - `interpreter`, `network`, `previews` and `desktop` for the other products.
39
+
40
+ The client has `sandboxes`, `images`, `volumes`, `snapshots`, `feedback` and
41
+ `support`. Every write carries an idempotency key, made for you, so the SDK's
42
+ own retries (timeouts, 429, 503) never do anything twice. Errors are typed and
43
+ carry a `code`, a `hint` and a `requestId`.
44
+
45
+ ## CLI
46
+
47
+ ```bash no-run
48
+ npx withruntime run -- python3 -c 'print(6 * 7)' # connects on first use
49
+ npx withruntime sandbox create
50
+ npx withruntime help
51
+ ```
52
+
53
+ Installed with `npm i -g withruntime`, the command is `runtime`:
54
+ `runtime sandbox exec <id> -- ls`, `runtime sandbox shell <id>`,
55
+ `runtime image build --pip pandas`, and `--json` on every command.
56
+
57
+ ## MCP
58
+
59
+ ```bash no-run
60
+ claude mcp add --scope user runtime -- npx -y withruntime mcp
61
+ codex mcp add runtime -- npx -y withruntime mcp
62
+ ```
63
+
64
+ The bridge serves Runtime's MCP tools on stdio over the saved connection; not
65
+ connected yet, it offers `runtime_connect`, which walks you through the browser
66
+ approval. Remote agents use `https://api.withruntime.com/mcp` with a bearer key.
67
+
68
+ Docs: https://withruntime.com/docs/javascript and https://withruntime.com/docs/cli.
69
+
70
+ The package was called `@withruntime/cloud` until 0.3.0. That name, and
71
+ `runtime-cloud` and `withruntime-cloud`, still install this one.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ type Out = {
3
+ json: boolean;
4
+ write: (text: string) => void;
5
+ error: (text: string) => void;
6
+ };
7
+ export declare function run(argv: string[], env?: NodeJS.ProcessEnv, out?: Out): Promise<number>;
8
+ export declare function describeError(error: unknown, json: boolean): string;
9
+ export {};