withruntime 0.18.0 → 0.23.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 (49) hide show
  1. package/COMPATIBILITY.md +32 -1
  2. package/README.md +19 -0
  3. package/README.src.md +19 -0
  4. package/dist/agents/index.d.ts +11 -0
  5. package/dist/agents/index.js +12 -0
  6. package/dist/agents-cli.d.ts +10 -0
  7. package/dist/agents-cli.js +362 -0
  8. package/dist/apps-cli.d.ts +2 -0
  9. package/dist/apps-cli.js +173 -0
  10. package/dist/builds/index.d.ts +10 -0
  11. package/dist/builds/index.js +11 -0
  12. package/dist/cli-words.js +1 -0
  13. package/dist/cli.js +176 -21
  14. package/dist/client.d.ts +19 -0
  15. package/dist/client.js +20 -0
  16. package/dist/cloudflare/errors.d.ts +23 -0
  17. package/dist/cloudflare/errors.js +16 -0
  18. package/dist/cloudflare/index.d.ts +82 -9
  19. package/dist/cloudflare/index.js +162 -38
  20. package/dist/cloudflare/interpreter.js +14 -5
  21. package/dist/cloudflare/mime.d.ts +1 -0
  22. package/dist/cloudflare/mime.js +66 -0
  23. package/dist/cloudflare/streams.d.ts +8 -0
  24. package/dist/cloudflare/streams.js +30 -0
  25. package/dist/cloudflare/types.d.ts +338 -0
  26. package/dist/cloudflare/types.js +80 -0
  27. package/dist/cloudflare/worker.d.ts +297 -10
  28. package/dist/cloudflare/worker.js +203 -17
  29. package/dist/containers/index.d.ts +10 -0
  30. package/dist/containers/index.js +11 -0
  31. package/dist/index.d.ts +3 -0
  32. package/dist/index.js +1 -0
  33. package/dist/keys.d.ts +6 -0
  34. package/dist/keys.js +10 -1
  35. package/dist/product-names.js +10 -0
  36. package/dist/products/agents.d.ts +272 -0
  37. package/dist/products/agents.js +251 -0
  38. package/dist/products/containers.d.ts +71 -0
  39. package/dist/products/containers.js +6 -0
  40. package/dist/products/index.d.ts +6 -0
  41. package/dist/products/index.js +7 -0
  42. package/dist/products/secrets.d.ts +19 -0
  43. package/dist/products/secrets.js +30 -0
  44. package/dist/sandbox.d.ts +4 -0
  45. package/dist/transport.d.ts +2 -2
  46. package/dist/transport.js +1 -1
  47. package/dist/tunnel.js +1 -1
  48. package/dist/types.d.ts +11 -0
  49. package/package.json +16 -1
@@ -161,6 +161,16 @@ export function secrets(t) {
161
161
  body: only,
162
162
  ...options,
163
163
  }),
164
+ /** Narrows where a secret goes, without its value: `hosts` a subset of
165
+ * its hosts, `rules` allowing only requests its rules allow now (a secret
166
+ * without rules allows every request). Either absent stays as it is.
167
+ * Anything wider is refused: widening needs the value, through `set`. */
168
+ narrow: (name, to, options) => t.json({
169
+ method: "PUT",
170
+ path: `${path(name)}/rules`,
171
+ body: to,
172
+ ...options,
173
+ }),
164
174
  /** The sandboxes' secrets: names, hosts and placeholders. Never values.
165
175
  * `all()` includes the jobs copies. */
166
176
  list,
@@ -209,6 +219,26 @@ export function secrets(t) {
209
219
  ...options,
210
220
  });
211
221
  },
222
+ /** Choose which of your keys may use the jobs copy besides the one that
223
+ * stored it: agent ids (`principalId` from `me()`), `[]` for only that
224
+ * key, or `"all"` for every key of yours. Replaces the list. Only your
225
+ * person or the key that stored it may call this. */
226
+ share: async (name, agents, options) => {
227
+ const live = await liveCopy(name, options);
228
+ if (!live)
229
+ throw new NotFoundError({
230
+ message: `${name} has no copy for jobs to share.`,
231
+ code: "not_found",
232
+ status: 404,
233
+ hint: "Store one with set(name, { value, jobs: true }).",
234
+ });
235
+ return store({
236
+ method: "POST",
237
+ path: `${jobPath(live.id)}:share`,
238
+ body: { agents },
239
+ ...options,
240
+ });
241
+ },
212
242
  /** Delete a secret everywhere it is kept: the sandboxes' value is erased
213
243
  * and its placeholder stops working, and the jobs copy stops being given
214
244
  * to runs (its name stays taken). */
package/dist/sandbox.d.ts CHANGED
@@ -95,12 +95,15 @@ export declare class Sandbox extends Machine<SandboxInfo, SandboxSettings, Delet
95
95
  * each its own sandbox, answered once they run. A running sandbox is paused
96
96
  * for the moment its snapshot takes, then woken. One without `count`; an
97
97
  * array with it. `funding` is what the copies run on, as for a create;
98
+ * omitted, they keep this sandbox's. `secrets` names the egress secrets the
99
+ * copies may use, and may only narrow this sandbox's list: [] is none;
98
100
  * omitted, they keep this sandbox's. */
99
101
  fork(options?: {
100
102
  name?: string;
101
103
  labels?: Record<string, string>;
102
104
  keepSnapshot?: boolean;
103
105
  funding?: "trial" | "paid";
106
+ secrets?: string[];
104
107
  } & RequestOptions): Promise<Sandbox>;
105
108
  fork(options: {
106
109
  count: number;
@@ -108,6 +111,7 @@ export declare class Sandbox extends Machine<SandboxInfo, SandboxSettings, Delet
108
111
  labels?: Record<string, string>;
109
112
  keepSnapshot?: boolean;
110
113
  funding?: "trial" | "paid";
114
+ secrets?: string[];
111
115
  } & RequestOptions): Promise<Sandbox[]>;
112
116
  }
113
117
  /** A sandbox session, as the API answers it. `token` is set only in the
@@ -1,5 +1,5 @@
1
1
  import { RuntimeError } from "./errors.js";
2
- export declare const VERSION = "0.18.0";
2
+ export declare const VERSION = "0.23.0";
3
3
  export declare const DEFAULT_BASE_URL = "https://api.withruntime.com";
4
4
  /** Runtime's API as code inside a Runtime sandbox reaches it: the sandbox's
5
5
  * own host sends each request on to DEFAULT_BASE_URL over HTTPS. The API runs
@@ -38,7 +38,7 @@ export type Query = Record<string, string | number | boolean | readonly string[]
38
38
  export type Call = RequestOptions & {
39
39
  /** Internal protocol hook: successful headers arrived, before reading the body. */
40
40
  onResponse?: (response: Response) => void;
41
- method: "GET" | "POST" | "PUT" | "DELETE";
41
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
42
42
  path: string;
43
43
  query?: Query;
44
44
  body?: unknown;
package/dist/transport.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ConnectionError, DELIBERATE, errorFor, NOTHING_RAN, RuntimeError, WAITS_FOR_ROOM, } from "./errors.js";
2
2
  import { describeRoute, envFetch, openWebSocket } from "./proxy.js";
3
3
  import { warningText } from "./product-renames.js";
4
- export const VERSION = "0.18.0";
4
+ export const VERSION = "0.23.0";
5
5
  export const DEFAULT_BASE_URL = "https://api.withruntime.com";
6
6
  /** Runtime's API as code inside a Runtime sandbox reaches it: the sandbox's
7
7
  * own host sends each request on to DEFAULT_BASE_URL over HTTPS. The API runs
package/dist/tunnel.js CHANGED
@@ -235,7 +235,7 @@ export class Tunnel {
235
235
  message: "The sandbox has no OpenSSH server (sshd).",
236
236
  code: "sshd_missing",
237
237
  status: 0,
238
- hint: "Install it once: sudo apt-get install -y openssh-server",
238
+ hint: "Install it once: sudo apt-get update && sudo apt-get install -y openssh-server",
239
239
  })
240
240
  : new RuntimeError({
241
241
  message: `The sandbox refused the connection (${error.message}).`,
package/dist/types.d.ts CHANGED
@@ -62,6 +62,12 @@ export type SandboxInfo = {
62
62
  /** The names of its own environment variables (`env`), on a create, an
63
63
  * update and a read of one sandbox. Values are never shown. */
64
64
  envNames?: string[];
65
+ /** The egress secrets this sandbox may use, by name: only those of your
66
+ * egress secrets that would otherwise reach it. Null is every secret that
67
+ * reaches it. Fixed for the sandbox's life; a fork or a copy of a snapshot
68
+ * may only narrow its source's list. On a create, an update, a fork and a
69
+ * read of one sandbox; absent from list pages and older servers. */
70
+ secrets?: string[] | null;
65
71
  /** On an update with labels by a key that may read secrets, when one of
66
72
  * the account's egress secrets is scoped: true once every server running its sandboxes holds the change,
67
73
  * so the next request uses the new scope; false while one has not
@@ -102,6 +108,11 @@ export type CreateSandbox = {
102
108
  * `env`. At most 32 variables and 32 KiB. Values are never shown again;
103
109
  * answers list only `envNames`. Copies made by fork() keep them. */
104
110
  env?: Record<string, string>;
111
+ /** The egress secrets this sandbox may use, by name: only those of your
112
+ * egress secrets that would otherwise reach it. [] is none; leave it out
113
+ * for every secret that reaches it. Fixed for the sandbox's life; a fork or
114
+ * a copy of a snapshot may only narrow its source's list. At most 64. */
115
+ secrets?: string[];
105
116
  /** Omit to use the free usage while it lasts, then prepaid credit. */
106
117
  funding?: "trial" | "paid";
107
118
  region?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "withruntime",
3
- "version": "0.18.0",
3
+ "version": "0.23.0",
4
4
  "license": "Apache-2.0",
5
5
  "mcpName": "com.withruntime/runtime",
6
6
  "type": "module",
@@ -55,6 +55,21 @@
55
55
  "import": "./dist/networks/index.js",
56
56
  "default": "./dist/networks/index.js"
57
57
  },
58
+ "./agents": {
59
+ "types": "./dist/agents/index.d.ts",
60
+ "import": "./dist/agents/index.js",
61
+ "default": "./dist/agents/index.js"
62
+ },
63
+ "./containers": {
64
+ "types": "./dist/containers/index.d.ts",
65
+ "import": "./dist/containers/index.js",
66
+ "default": "./dist/containers/index.js"
67
+ },
68
+ "./builds": {
69
+ "types": "./dist/builds/index.d.ts",
70
+ "import": "./dist/builds/index.js",
71
+ "default": "./dist/builds/index.js"
72
+ },
58
73
  "./e2b": {
59
74
  "types": "./dist/e2b/index.d.ts",
60
75
  "import": "./dist/e2b/index.js",