withruntime 0.12.0 → 0.16.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 (94) hide show
  1. package/BLAXEL.md +97 -32
  2. package/COMPATIBILITY.md +120 -5
  3. package/DAYTONA.md +34 -3
  4. package/E2B.md +34 -5
  5. package/README.md +36 -3
  6. package/README.src.md +35 -2
  7. package/VERCEL.md +52 -5
  8. package/compatibility-lock.json +71 -111
  9. package/dist/billing-cli.js +8 -4
  10. package/dist/blaxel/client.d.ts +11 -0
  11. package/dist/blaxel/client.js +28 -0
  12. package/dist/blaxel/errors.d.ts +65 -0
  13. package/dist/blaxel/errors.js +114 -0
  14. package/dist/blaxel/index.d.ts +10 -3
  15. package/dist/blaxel/index.js +23 -4
  16. package/dist/blaxel/preview.d.ts +29 -4
  17. package/dist/blaxel/preview.js +79 -5
  18. package/dist/blaxel/sandbox.d.ts +1 -1
  19. package/dist/blaxel/sandbox.js +2 -1
  20. package/dist/blaxel/session.js +4 -2
  21. package/dist/cli-extras.js +2 -1
  22. package/dist/cli-words.js +1 -0
  23. package/dist/cli.d.ts +17 -2
  24. package/dist/cli.js +291 -85
  25. package/dist/client.d.ts +1 -1
  26. package/dist/credentials.d.ts +3 -0
  27. package/dist/credentials.js +15 -0
  28. package/dist/daytona/client.d.ts +4 -0
  29. package/dist/daytona/client.js +8 -3
  30. package/dist/daytona/daytona.d.ts +4 -1
  31. package/dist/daytona/daytona.js +3 -2
  32. package/dist/e2b/sandbox.d.ts +7 -6
  33. package/dist/e2b/sandbox.js +9 -12
  34. package/dist/errors.d.ts +1 -1
  35. package/dist/errors.js +1 -1
  36. package/dist/freestyle/index.d.ts +77 -5
  37. package/dist/freestyle/index.js +380 -48
  38. package/dist/identity.js +36 -18
  39. package/dist/index.d.ts +4 -3
  40. package/dist/machine.d.ts +39 -13
  41. package/dist/machine.js +72 -25
  42. package/dist/mcp.js +157 -20
  43. package/dist/modal/index.d.ts +15 -0
  44. package/dist/modal/index.js +35 -7
  45. package/dist/morph/index.d.ts +255 -0
  46. package/dist/morph/index.js +641 -0
  47. package/dist/network-cli.js +2 -2
  48. package/dist/product-names.d.ts +2 -2
  49. package/dist/product-names.js +2 -2
  50. package/dist/products/api-keys.d.ts +73 -0
  51. package/dist/products/api-keys.js +23 -0
  52. package/dist/products/apps.d.ts +12 -31
  53. package/dist/products/apps.js +8 -113
  54. package/dist/products/balancers.d.ts +87 -0
  55. package/dist/products/balancers.js +8 -0
  56. package/dist/products/builds.d.ts +30 -0
  57. package/dist/products/builds.js +6 -0
  58. package/dist/products/index.d.ts +2 -0
  59. package/dist/products/index.js +2 -0
  60. package/dist/products/jobs.d.ts +2 -2
  61. package/dist/products/jobs.js +1 -1
  62. package/dist/products/limits.d.ts +16 -2
  63. package/dist/products/limits.js +2 -2
  64. package/dist/products/mcp.d.ts +5 -0
  65. package/dist/products/network-products.d.ts +21 -3
  66. package/dist/products/network-products.js +3 -1
  67. package/dist/products/observability.d.ts +7 -2
  68. package/dist/products/previews.d.ts +6 -3
  69. package/dist/products/previews.js +1 -1
  70. package/dist/products/resources.d.ts +54 -0
  71. package/dist/products/resources.js +122 -0
  72. package/dist/products/secrets.d.ts +22 -0
  73. package/dist/products/secrets.js +8 -0
  74. package/dist/products/volumes.d.ts +3 -0
  75. package/dist/sandbox.d.ts +4 -0
  76. package/dist/sandbox.js +27 -2
  77. package/dist/snapshots.d.ts +4 -0
  78. package/dist/ssh.d.ts +35 -0
  79. package/dist/ssh.js +93 -1
  80. package/dist/transport.d.ts +14 -8
  81. package/dist/transport.js +70 -15
  82. package/dist/types.d.ts +33 -5
  83. package/dist/vercel/command.d.ts +48 -1
  84. package/dist/vercel/command.js +237 -6
  85. package/dist/vercel/sandbox-user.js +2 -1
  86. package/dist/vercel/sandbox.d.ts +17 -3
  87. package/dist/vercel/sandbox.js +46 -3
  88. package/dist/wallet.d.ts +4 -1
  89. package/dist/wallet.js +2 -1
  90. package/package.json +7 -14
  91. package/dist/cli/logs.test.d.ts +0 -1
  92. package/dist/cli/logs.test.js +0 -272
  93. package/dist/products/logs.test.d.ts +0 -1
  94. package/dist/products/logs.test.js +0 -343
@@ -0,0 +1,73 @@
1
+ import type { RequestOptions, Transport } from "../transport.js";
2
+ export type NewKey = {
3
+ /** The key's name, and its agent's: up to 80 characters. */
4
+ name: string;
5
+ /** full (the default): every action. read: every read, nothing else. */
6
+ access?: "full" | "read";
7
+ /** agent (the default): the key sees and acts on only what it makes.
8
+ * account: everything in the account; only an account-wide key makes one. */
9
+ reach?: "agent" | "account";
10
+ /** The most its agent may commit in any 24 hours, or null for none. Needed
11
+ * when the making key has a limit: the limits of the keys a key made add
12
+ * up to at most its own. */
13
+ dailyLimitMicros?: number | null;
14
+ };
15
+ export type MadeKey = {
16
+ /** The key itself. Shown once: store it now. */
17
+ key: string;
18
+ keyId: string;
19
+ agentId: string;
20
+ orgId: string;
21
+ name: string;
22
+ access: "full" | "read";
23
+ reach: "agent" | "account";
24
+ dailyLimitMicros: number | null;
25
+ /** The making key's expiry, or null for until revoked. */
26
+ expires: string | null;
27
+ /** The id of the key that made it. */
28
+ madeBy: string;
29
+ };
30
+ export type ListedKey = {
31
+ keyId: string;
32
+ agentId: string;
33
+ name: string;
34
+ access: "full" | "read" | "selected";
35
+ reach: "agent" | "account";
36
+ dailyLimitMicros: number | null;
37
+ /** Committed in the last 24 hours: settled plus held, as the limit counts. */
38
+ dailyUsedMicros: number;
39
+ /** The key that made it, or null for one made on the website. */
40
+ madeBy: string | null;
41
+ createdAt: string;
42
+ expiresAt: string | null;
43
+ revokedAt: string | null;
44
+ };
45
+ /** One key's spend, from `GET /v1/usage?key=`. Microdollars as strings. */
46
+ export type KeyUsage = {
47
+ keyId: string;
48
+ agentId: string;
49
+ name: string;
50
+ madeBy: string | null;
51
+ revokedAt: string | null;
52
+ dailyLimitMicros: string | null;
53
+ dailyUsedMicros: string;
54
+ spentMicros: string;
55
+ heldMicros: string;
56
+ runningSandboxes: number;
57
+ resources: number;
58
+ };
59
+ export declare function keys(t: Transport): {
60
+ /** Make a key with this one. It never has more than this key, and is in
61
+ * the audit log as made by it. At most 100 live in an account. */
62
+ create: (input: NewKey, options?: RequestOptions) => Promise<MadeKey>;
63
+ /** This key and the keys it made (every key, for an account-wide key),
64
+ * live first, with what each spent in the last 24 hours. */
65
+ list: (options?: RequestOptions) => Promise<ListedKey[]>;
66
+ /** Revoke this key or one it made: a worker's, when the worker is done. */
67
+ revoke: (keyId: string, options?: RequestOptions) => Promise<{
68
+ keyId: string;
69
+ revokedAt: string;
70
+ }>;
71
+ /** What one key spent: itself, or a key it made. */
72
+ usage: (keyId: string, options?: RequestOptions) => Promise<KeyUsage>;
73
+ };
@@ -0,0 +1,23 @@
1
+ export function keys(t) {
2
+ return {
3
+ /** Make a key with this one. It never has more than this key, and is in
4
+ * the audit log as made by it. At most 100 live in an account. */
5
+ create: (input, options) => t.json({ method: "POST", path: "/v1/keys", body: input, ...options }),
6
+ /** This key and the keys it made (every key, for an account-wide key),
7
+ * live first, with what each spent in the last 24 hours. */
8
+ list: async (options) => (await t.json({ method: "GET", path: "/v1/keys", ...options })).keys,
9
+ /** Revoke this key or one it made: a worker's, when the worker is done. */
10
+ revoke: (keyId, options) => t.json({
11
+ method: "DELETE",
12
+ path: `/v1/keys/${encodeURIComponent(keyId)}`,
13
+ ...options,
14
+ }),
15
+ /** What one key spent: itself, or a key it made. */
16
+ usage: async (keyId, options) => (await t.json({
17
+ method: "GET",
18
+ path: "/v1/usage",
19
+ query: { key: keyId },
20
+ ...options,
21
+ })).key,
22
+ };
23
+ }
@@ -1,5 +1,5 @@
1
- import { Page } from "../page.js";
2
1
  import type { RequestOptions, Transport } from "../transport.js";
2
+ import { type ResourceDeleteOptions, type ResourceGetOptions, type ResourceListQuery, type ResourceWaitOptions } from "./resources.js";
3
3
  /** Private until launch. A deployment's completion follows its own record,
4
4
  * not the app's state. */
5
5
  export type AppState = "waiting" | "live" | "failed" | "deleting" | "deleted";
@@ -112,36 +112,17 @@ export type DeployGetOptions = RequestOptions & {
112
112
  waitFor?: DeployState;
113
113
  timeoutSeconds?: number;
114
114
  };
115
- export type AppListQuery = {
116
- name?: string;
117
- /** Repeated key:value filters; all must match. */
118
- label?: readonly string[];
119
- /** Defaults to waiting, live and failed. */
120
- state?: readonly AppState[];
121
- /** 1 to 100; defaults to 50. */
122
- limit?: number;
123
- cursor?: string;
124
- };
125
- export type AppGetOptions = RequestOptions & {
126
- waitFor?: AppState;
127
- /** Server wait, 1 to 60 seconds; defaults to 30. Check the returned state. */
128
- timeoutSeconds?: number;
129
- };
130
- export type AppWaitOptions = RequestOptions & {
131
- /** Whole wait, including retries; defaults to 300000 ms. 0 disables it. */
132
- timeoutMs?: number;
133
- /** Delay between reads; defaults to 250 ms. */
134
- pollMs?: number;
135
- };
136
- export type AppDeleteOptions = AppWaitOptions & {
137
- wait?: boolean;
138
- };
115
+ /** Defaults to waiting, live and failed. */
116
+ export type AppListQuery = ResourceListQuery<AppState>;
117
+ export type AppGetOptions = ResourceGetOptions<AppState>;
118
+ export type AppWaitOptions = ResourceWaitOptions;
119
+ export type AppDeleteOptions = ResourceDeleteOptions;
139
120
  export declare function apps(t: Transport): {
140
121
  /** Create a resource waiting for its first version. Defaults belong to
141
122
  * the API, so the SDK does not override them. */
142
123
  create: (input: CreateApp, options?: RequestOptions) => Promise<App>;
143
- get: (id: string, options?: AppGetOptions) => Promise<App>;
144
- list: (query?: AppListQuery, options?: RequestOptions) => Promise<Page<App>>;
124
+ get: (id: string, options?: ResourceGetOptions<AppState>) => Promise<App>;
125
+ list: (query?: ResourceListQuery<AppState>, options?: RequestOptions) => Promise<import("../page.js").Page<App>>;
145
126
  deploy: (id: string, input: DeployApp, options?: AppWaitOptions) => Promise<AppDeploy>;
146
127
  getDeploy: (id: string, deployId: string, options?: DeployGetOptions) => Promise<AppDeploy>;
147
128
  /** Resume by deploy id after a process restart, without creating another version. */
@@ -153,14 +134,14 @@ export declare function apps(t: Transport): {
153
134
  /** Follow resource state, not a deployment: an
154
135
  * older live version can survive a failed rollout of a newer version. */
155
136
  wait: (id: string, target: "live" | "deleted", options?: AppWaitOptions) => Promise<App>;
156
- delete: (id: string, options?: AppDeleteOptions) => Promise<App>;
137
+ delete: (id: string, options?: ResourceDeleteOptions) => Promise<App>;
157
138
  };
158
139
  export declare function functions(t: Transport): {
159
140
  /** Create a resource waiting for its first version. Defaults belong to
160
141
  * the API, so the SDK does not override them. */
161
142
  create: (input: CreateFunction, options?: RequestOptions) => Promise<RuntimeFunction>;
162
- get: (id: string, options?: AppGetOptions) => Promise<RuntimeFunction>;
163
- list: (query?: AppListQuery, options?: RequestOptions) => Promise<Page<RuntimeFunction>>;
143
+ get: (id: string, options?: ResourceGetOptions<AppState>) => Promise<RuntimeFunction>;
144
+ list: (query?: ResourceListQuery<AppState>, options?: RequestOptions) => Promise<import("../page.js").Page<RuntimeFunction>>;
164
145
  deploy: (id: string, input: DeployApp, options?: AppWaitOptions) => Promise<AppDeploy>;
165
146
  getDeploy: (id: string, deployId: string, options?: DeployGetOptions) => Promise<AppDeploy>;
166
147
  /** Resume by deploy id after a process restart, without creating another version. */
@@ -172,5 +153,5 @@ export declare function functions(t: Transport): {
172
153
  /** Follow resource state, not a deployment: an
173
154
  * older live version can survive a failed rollout of a newer version. */
174
155
  wait: (id: string, target: "live" | "deleted", options?: AppWaitOptions) => Promise<RuntimeFunction>;
175
- delete: (id: string, options?: AppDeleteOptions) => Promise<RuntimeFunction>;
156
+ delete: (id: string, options?: ResourceDeleteOptions) => Promise<RuntimeFunction>;
176
157
  };
@@ -1,106 +1,7 @@
1
- import { RuntimeError } from "../errors.js";
2
- import { Page } from "../page.js";
3
- import { pause } from "../wait.js";
4
- const enc = encodeURIComponent;
5
- function invalid(field) {
6
- return new RuntimeError({
7
- code: "invalid_request",
8
- status: 0,
9
- message: `${field} must be a finite, nonnegative number.`,
10
- hint: "Fix the option and call again; nothing was sent.",
11
- details: { field },
12
- });
13
- }
14
- /** One deadline covers the write, retries and every read. A timed-out delete
15
- * can be retried after a process restart with this same key. */
16
- async function following(options, work) {
17
- const { pollMs = 250, timeoutMs = 300_000, signal, ...rest } = options;
18
- if (!Number.isFinite(pollMs) || pollMs < 0)
19
- throw invalid("pollMs");
20
- if (!Number.isFinite(timeoutMs) || timeoutMs < 0)
21
- throw invalid("timeoutMs");
22
- const deadline = new AbortController();
23
- const combined = signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal;
24
- const timer = timeoutMs > 0 ? setTimeout(() => deadline.abort(), timeoutMs) : undefined;
25
- const request = { ...rest, timeoutMs: 0, signal: combined };
26
- const poll = () => pause(pollMs, combined);
27
- try {
28
- combined.throwIfAborted();
29
- const result = await work(request, poll);
30
- combined.throwIfAborted();
31
- return result;
32
- }
33
- catch (cause) {
34
- if (!combined.aborted) {
35
- // A read failure still belongs to the write that started this wait.
36
- // Keep its key so a caller can recover after losing the reply.
37
- if (cause instanceof RuntimeError && rest.idempotencyKey && !cause.idempotencyKey)
38
- throw new RuntimeError({
39
- message: cause.message,
40
- code: cause.code,
41
- status: cause.status,
42
- requestId: cause.requestId,
43
- hint: cause.hint,
44
- details: cause.details,
45
- retryAfterMs: cause.retryAfterMs,
46
- idempotencyKey: rest.idempotencyKey,
47
- cause,
48
- });
49
- throw cause;
50
- }
51
- throw new RuntimeError({
52
- code: "timeout",
53
- status: 0,
54
- message: "Waiting was cancelled or reached its deadline; the resource may still change.",
55
- hint: "Read the resource to resume waiting. Retry a write with the same idempotencyKey.",
56
- ...(rest.idempotencyKey === undefined ? {} : { idempotencyKey: rest.idempotencyKey }),
57
- cause,
58
- });
59
- }
60
- finally {
61
- clearTimeout(timer);
62
- }
63
- }
1
+ import { enc, following, resource, } from "./resources.js";
64
2
  function copies(t, plural) {
65
- const base = `/v1/${plural}`;
66
- const get = (id, options = {}) => {
67
- const { waitFor, timeoutSeconds, ...request } = options;
68
- return t.json({
69
- method: "GET",
70
- path: `${base}/${enc(id)}`,
71
- query: { waitFor, timeoutSeconds },
72
- ...request,
73
- });
74
- };
75
- const list = async (query = {}, options) => {
76
- const page = await t.json({
77
- method: "GET",
78
- path: base,
79
- query,
80
- ...options,
81
- });
82
- return new Page(page.data, page.nextCursor, (cursor) => list({ ...query, cursor }, options));
83
- };
84
- const follow = async (id, target, request, pause, initial) => {
85
- let record = initial ?? (await get(id, request));
86
- for (;;) {
87
- if (record.state === target)
88
- return record;
89
- if (["failed", "deleted", "live"].includes(record.state))
90
- throw new RuntimeError({
91
- code: record.error?.code ?? "unexpected_state",
92
- status: 0,
93
- message: record.error?.message ?? `Expected ${target}, but ${id} reached ${record.state}.`,
94
- hint: "Read the resource and inspect its error before starting another change.",
95
- details: { id, state: record.state, target, resource: record },
96
- ...(request.idempotencyKey === undefined
97
- ? {}
98
- : { idempotencyKey: request.idempotencyKey }),
99
- });
100
- await pause();
101
- record = await get(id, request);
102
- }
103
- };
3
+ const shape = resource(t, plural, ["failed", "deleted", "live"]);
4
+ const { base, get } = shape;
104
5
  const getDeploy = (id, deployId, options = {}) => {
105
6
  const { waitFor, timeoutSeconds, ...request } = options;
106
7
  return t.json({
@@ -128,9 +29,9 @@ function copies(t, plural) {
128
29
  return {
129
30
  /** Create a resource waiting for its first version. Defaults belong to
130
31
  * the API, so the SDK does not override them. */
131
- create: (input, options) => t.json({ method: "POST", path: base, body: input, ...options }),
32
+ create: shape.create,
132
33
  get,
133
- list,
34
+ list: shape.list,
134
35
  deploy: (id, input, options = {}) => {
135
36
  const { wait = false, ...body } = input;
136
37
  return writeDeploy(id, "deploys", body, wait, options);
@@ -144,17 +45,11 @@ function copies(t, plural) {
144
45
  },
145
46
  versions: (id, options) => t.json({ method: "GET", path: `${base}/${enc(id)}/versions`, ...options }),
146
47
  copies: (id, options) => t.json({ method: "GET", path: `${base}/${enc(id)}/copies`, ...options }),
147
- update: (id, input, options) => t.json({ method: "POST", path: `${base}/${enc(id)}:update`, body: input, ...options }),
48
+ update: shape.update,
148
49
  /** Follow resource state, not a deployment: an
149
50
  * older live version can survive a failed rollout of a newer version. */
150
- wait: (id, target, options = {}) => following(options, (request, pause) => follow(id, target, request, pause)),
151
- delete: (id, options = {}) => {
152
- const { wait = false, pollMs, ...request } = options;
153
- const remove = (rest) => t.json({ method: "DELETE", path: `${base}/${enc(id)}`, ...rest });
154
- if (!wait)
155
- return remove(request);
156
- return following({ ...request, pollMs, idempotencyKey: request.idempotencyKey ?? crypto.randomUUID() }, async (rest, pause) => follow(id, "deleted", rest, pause, await remove(rest)));
157
- },
51
+ wait: (id, target, options = {}) => shape.wait(id, target, options),
52
+ delete: shape.delete,
158
53
  };
159
54
  }
160
55
  export function apps(t) {
@@ -0,0 +1,87 @@
1
+ import type { Transport } from "../transport.js";
2
+ import { type ResourceRecord } from "./resources.js";
3
+ /** Private until launch: load balancers and the inbound firewall
4
+ * (packages/cloud/src/api/products/balancers.ts). A change answers
5
+ * `applying`; it is `active` once every router serves it, and `waitingOn`
6
+ * names any router that does not yet. */
7
+ export type AddressState = "applying" | "active" | "failed" | "deleting" | "deleted";
8
+ type Common = ResourceRecord & {
9
+ name: string | null;
10
+ labels: Record<string, string>;
11
+ state: AddressState;
12
+ createdAt: number;
13
+ updatedAt: number;
14
+ deletedAt: number | null;
15
+ /** Routers that do not yet serve the newest change. */
16
+ waitingOn: string[];
17
+ };
18
+ /** A sandbox with the port it serves on, or an App or Function by id. */
19
+ export type BalancerTarget = {
20
+ id: string;
21
+ port?: number;
22
+ };
23
+ export type Balancer = Common & {
24
+ hostname: string;
25
+ targets: BalancerTarget[];
26
+ };
27
+ export type CreateBalancer = {
28
+ name?: string;
29
+ labels?: Record<string, string>;
30
+ /** Up to 1000, all the organization's own. */
31
+ targets?: BalancerTarget[];
32
+ };
33
+ export type UpdateBalancer = {
34
+ name?: string | null;
35
+ labels?: Record<string, string>;
36
+ /** Replaces the whole list. */
37
+ targets?: BalancerTarget[];
38
+ };
39
+ export type FirewallRule = Common & {
40
+ address: string;
41
+ effect: "allow" | "deny" | "limit";
42
+ source?: string;
43
+ ports?: string;
44
+ requests?: number;
45
+ seconds?: number;
46
+ burst?: number;
47
+ priority: number;
48
+ };
49
+ export type CreateFirewallRule = {
50
+ name?: string;
51
+ labels?: Record<string, string>;
52
+ /** The load balancer it guards. */
53
+ address: string;
54
+ priority?: number;
55
+ } & ({
56
+ effect: "allow" | "deny";
57
+ source?: string;
58
+ ports?: string;
59
+ } | {
60
+ effect: "limit";
61
+ requests: number;
62
+ seconds: number;
63
+ burst?: number;
64
+ });
65
+ export type UpdateFirewallRule = {
66
+ name?: string | null;
67
+ labels?: Record<string, string>;
68
+ };
69
+ export declare function balancers(t: Transport): {
70
+ base: string;
71
+ create: (input: CreateBalancer, options?: import("../transport.js").RequestOptions) => Promise<Balancer>;
72
+ get: (id: string, options?: import("./resources.js").ResourceGetOptions<"active" | "deleted" | "failed" | "deleting" | "applying">) => Promise<Balancer>;
73
+ list: (query?: import("./resources.js").ResourceListQuery<"active" | "deleted" | "failed" | "deleting" | "applying">, options?: import("../transport.js").RequestOptions) => Promise<import("../page.js").Page<Balancer>>;
74
+ update: (id: string, input: UpdateBalancer, options?: import("../transport.js").RequestOptions) => Promise<Balancer>;
75
+ wait: (id: string, target: "active" | "deleted" | "failed" | "deleting" | "applying", options?: import("./resources.js").ResourceWaitOptions) => Promise<Balancer>;
76
+ delete: (id: string, options?: import("./resources.js").ResourceDeleteOptions) => Promise<Balancer>;
77
+ };
78
+ export declare function firewall(t: Transport): {
79
+ base: string;
80
+ create: (input: CreateFirewallRule, options?: import("../transport.js").RequestOptions) => Promise<FirewallRule>;
81
+ get: (id: string, options?: import("./resources.js").ResourceGetOptions<"active" | "deleted" | "failed" | "deleting" | "applying">) => Promise<FirewallRule>;
82
+ list: (query?: import("./resources.js").ResourceListQuery<"active" | "deleted" | "failed" | "deleting" | "applying">, options?: import("../transport.js").RequestOptions) => Promise<import("../page.js").Page<FirewallRule>>;
83
+ update: (id: string, input: UpdateFirewallRule, options?: import("../transport.js").RequestOptions) => Promise<FirewallRule>;
84
+ wait: (id: string, target: "active" | "deleted" | "failed" | "deleting" | "applying", options?: import("./resources.js").ResourceWaitOptions) => Promise<FirewallRule>;
85
+ delete: (id: string, options?: import("./resources.js").ResourceDeleteOptions) => Promise<FirewallRule>;
86
+ };
87
+ export {};
@@ -0,0 +1,8 @@
1
+ import { resource } from "./resources.js";
2
+ const SETTLED = ["failed", "deleted"];
3
+ export function balancers(t) {
4
+ return resource(t, "balancers", SETTLED);
5
+ }
6
+ export function firewall(t) {
7
+ return resource(t, "firewall/rules", SETTLED);
8
+ }
@@ -16,16 +16,33 @@ type Resource = {
16
16
  export type Build = Resource & {
17
17
  repositoryId: string;
18
18
  ref: string;
19
+ /** The branch whose move asked for it, when the caller said. */
20
+ branch: string | null;
19
21
  commit: string | null;
20
22
  state: BuildState;
21
23
  reason: string | null;
24
+ /** Milliseconds per step once the runner is done (install, build, mirror,
25
+ * fork, snapshot, total, ...); null until then. */
26
+ timings: Record<string, number> | null;
27
+ /** The saved server an App deploys, once a build of a repository with a
28
+ * start command succeeded; null otherwise. */
29
+ outputSnapshotId: string | null;
22
30
  };
23
31
  export type CreateBuild = {
24
32
  repositoryId: string;
25
33
  ref: string;
34
+ /** The same branch and commit is one build; a newer build of the branch
35
+ * supersedes older ones not yet ended. */
36
+ branch?: string;
26
37
  name?: string;
27
38
  labels?: Record<string, string>;
28
39
  };
40
+ /** A connected repository's settings changed in place; its id and builds
41
+ * stay. A field left out stays as it is; a null name clears it. */
42
+ export type ChangeRepository = Partial<Omit<ConnectRepository, "provider" | "name" | "labels">> & {
43
+ name?: string | null;
44
+ labels?: Record<string, string>;
45
+ };
29
46
  export type ConnectRepository = {
30
47
  provider: "github" | "git";
31
48
  repository: string;
@@ -37,6 +54,14 @@ export type ConnectRepository = {
37
54
  /** Leave out to choose by the lockfile (bun, pnpm, Yarn or npm). */
38
55
  installCommand?: string | null;
39
56
  buildCommand?: string | null;
57
+ /** Run after the build with PORT set; the build ends as this server,
58
+ * answering healthPath with 200 and saved with its memory. */
59
+ startCommand?: string | null;
60
+ port?: number;
61
+ healthPath?: string | null;
62
+ /** Settings install and build are given. Never a secret: anyone who reads
63
+ * the repository sees them. */
64
+ buildEnv?: Record<string, string>;
40
65
  name?: string;
41
66
  labels?: Record<string, string>;
42
67
  };
@@ -49,6 +74,10 @@ export type Repository = Resource & {
49
74
  rootDirectory: string;
50
75
  installCommand: string | null;
51
76
  buildCommand: string | null;
77
+ startCommand: string | null;
78
+ port: number;
79
+ healthPath: string | null;
80
+ buildEnv: Record<string, string>;
52
81
  state: "connected" | "disconnected";
53
82
  };
54
83
  export type ListBuilds = {
@@ -120,6 +149,7 @@ export declare function builds(t: Transport): {
120
149
  repositories: {
121
150
  connect: (input: ConnectRepository, options?: RequestOptions) => Promise<Repository>;
122
151
  list: (query?: ListRepositories, options?: RequestOptions) => Promise<Page<Repository>>;
152
+ update: (id: string, change: ChangeRepository, options?: RequestOptions) => Promise<Repository>;
123
153
  disconnect: (id: string, options?: RequestOptions) => Promise<Repository>;
124
154
  };
125
155
  };
@@ -211,6 +211,12 @@ export function builds(t) {
211
211
  repositories: {
212
212
  connect: (input, options) => t.json({ method: "POST", path: "/v1/repositories", body: input, ...options }),
213
213
  list: listRepositories,
214
+ update: (id, change, options) => t.json({
215
+ method: "POST",
216
+ path: `/v1/repositories/${encodeURIComponent(id)}:update`,
217
+ body: change,
218
+ ...options,
219
+ }),
214
220
  disconnect: (id, options) => t.json({
215
221
  method: "DELETE",
216
222
  path: `/v1/repositories/${encodeURIComponent(id)}`,
@@ -13,6 +13,7 @@ import { audit } from "./audit.js";
13
13
  import { sso } from "./sso.js";
14
14
  import { switching } from "./switching.js";
15
15
  import { limits } from "./limits.js";
16
+ import { keys } from "./api-keys.js";
16
17
  import { volumes } from "./volumes.js";
17
18
  import { jobs } from "./jobs.js";
18
19
  import { sandboxMounts } from "./mounts.js";
@@ -27,6 +28,7 @@ export declare const clientExtensions: {
27
28
  referrals: typeof referrals;
28
29
  billing: typeof billing;
29
30
  limits: typeof limits;
31
+ keys: typeof keys;
30
32
  switching: typeof switching;
31
33
  secrets: typeof secrets;
32
34
  webhooks: typeof webhooks;
@@ -11,6 +11,7 @@ import { audit } from "./audit.js";
11
11
  import { sso } from "./sso.js";
12
12
  import { switching } from "./switching.js";
13
13
  import { limits } from "./limits.js";
14
+ import { keys } from "./api-keys.js";
14
15
  import { volumes } from "./volumes.js";
15
16
  import { jobs } from "./jobs.js";
16
17
  import { sandboxMounts } from "./mounts.js";
@@ -40,6 +41,7 @@ export const clientExtensions = {
40
41
  referrals,
41
42
  billing,
42
43
  limits,
44
+ keys,
43
45
  switching,
44
46
  secrets,
45
47
  webhooks,
@@ -1,7 +1,7 @@
1
1
  import { Page } from "../page.js";
2
2
  import type { RequestOptions, Transport } from "../transport.js";
3
3
  /** A run's sandbox. Every field has a default; a run is a sandbox of this
4
- * size, on the included usage first and then on credit at the sandbox rates. */
4
+ * size, on the free usage first and then on credit at the sandbox rates. */
5
5
  export type JobCompute = {
6
6
  region: string;
7
7
  vcpu: number;
@@ -176,7 +176,7 @@ export declare function jobBody(input: CreateJob): Record<string, unknown>;
176
176
  * request id, and says no retry will change it. */
177
177
  export declare function switchedOff(product: string): (error: unknown) => never;
178
178
  /** Scheduled jobs: a command run in a fresh sandbox, once or on a cron
179
- * schedule. Each run is a sandbox, paid for as one: from the included usage first while the run fits the limits without credit, then from credit
179
+ * schedule. Each run is a sandbox, paid for as one: from the free usage first while the run fits the limits without credit, then from credit
180
180
  * at the sandbox rates, through the same holds and spending limits.
181
181
  *
182
182
  * const job = await runtime.jobs.create({
@@ -131,7 +131,7 @@ export function switchedOff(product) {
131
131
  };
132
132
  }
133
133
  /** Scheduled jobs: a command run in a fresh sandbox, once or on a cron
134
- * schedule. Each run is a sandbox, paid for as one: from the included usage first while the run fits the limits without credit, then from credit
134
+ * schedule. Each run is a sandbox, paid for as one: from the free usage first while the run fits the limits without credit, then from credit
135
135
  * at the sandbox rates, through the same holds and spending limits.
136
136
  *
137
137
  * const job = await runtime.jobs.create({
@@ -18,9 +18,23 @@ export type KeyLimits = {
18
18
  /** Machine time the account can still run without credit, the same
19
19
  * figures as `usage.get()`'s `trial`, or null when it has none. */
20
20
  trial: Usage["trial"];
21
+ /** Every limit the account is held to, with what it uses of each now: the
22
+ * numbers a create past one is refused `quota_exceeded` by (its
23
+ * `details.limit` names the row). Null when they can't be read. */
24
+ account: AccountLimit[] | null;
21
25
  };
22
- /** `runtime.limits.get()`: whether this key is read-only, and what its agent
23
- * may still spend today. An owner sets the limit at
26
+ /** One of the account's limits, as https://withruntime.com/account/limits shows it. */
27
+ export type AccountLimit = {
28
+ /** `<kind>.<dimension>`: sandbox.count, sandbox.vcpu, sandbox.memory_mib, volume.count… */
29
+ limit: string;
30
+ label: string;
31
+ /** What `max` and `used` count: things, or MiB. */
32
+ unit: "count" | "mib";
33
+ max: number;
34
+ used: number;
35
+ };
36
+ /** `runtime.limits.get()`: whether this key is read-only, what its agent
37
+ * may still spend today, and the account's limits with what it uses of each. An owner sets the limit at
24
38
  * https://withruntime.com/account/keys; a key can read it, never change it.
25
39
  * Past it, a create, wake, extension or renewal fails with
26
40
  * `spending_limit_reached` (HTTP 402). */
@@ -1,5 +1,5 @@
1
- /** `runtime.limits.get()`: whether this key is read-only, and what its agent
2
- * may still spend today. An owner sets the limit at
1
+ /** `runtime.limits.get()`: whether this key is read-only, what its agent
2
+ * may still spend today, and the account's limits with what it uses of each. An owner sets the limit at
3
3
  * https://withruntime.com/account/keys; a key can read it, never change it.
4
4
  * Past it, a create, wake, extension or renewal fails with
5
5
  * `spending_limit_reached` (HTTP 402). */
@@ -38,6 +38,8 @@ export type McpServerRequest = {
38
38
  export type McpGateway = {
39
39
  running: boolean;
40
40
  port: number | null;
41
+ /** The URLs are a public preview: no link token, no expiry. */
42
+ public?: boolean;
41
43
  /** Send it as `Authorization: Bearer <token>`. */
42
44
  token?: string | null;
43
45
  headers?: Record<string, string>;
@@ -65,6 +67,9 @@ export declare function sandboxMcp(t: Transport, sandbox: Sandbox): {
65
67
  start: (servers: McpServerRequest[], input?: {
66
68
  port?: number;
67
69
  replace?: boolean;
70
+ /** URLs that never expire, guarded by the header alone, which is kept
71
+ * across starts until `stop()`. Paid accounts only. */
72
+ public?: boolean;
68
73
  }, options?: RequestOptions) => Promise<McpGateway>;
69
74
  /** Their state, and fresh URLs. */
70
75
  get: (options?: RequestOptions) => Promise<McpGateway>;