withruntime 0.35.0 → 0.45.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.
- package/BLAXEL.md +207 -204
- package/COMPATIBILITY.md +367 -337
- package/DAYTONA.md +180 -173
- package/E2B.md +246 -230
- package/README.md +182 -142
- package/README.src.md +182 -142
- package/VERCEL.md +173 -168
- package/agent-platforms-inventory.json +387 -0
- package/dist/agents-cli.d.ts +7 -1
- package/dist/agents-cli.js +470 -6
- package/dist/agents-deploy.d.ts +1 -1
- package/dist/agents-deploy.js +62 -1
- package/dist/apps-cli.d.ts +3 -3
- package/dist/apps-cli.js +10 -5
- package/dist/browsers-cli.d.ts +1 -1
- package/dist/browsers-cli.js +122 -3
- package/dist/ci-cli.d.ts +11 -1
- package/dist/ci-cli.js +69 -6
- package/dist/cli-update.d.ts +11 -0
- package/dist/cli-update.js +46 -0
- package/dist/cli-words.js +1 -0
- package/dist/cli.d.ts +4 -6
- package/dist/cli.js +249 -58
- package/dist/daytona/daytona.js +1 -1
- package/dist/e2b/sandbox.d.ts +6 -5
- package/dist/e2b/sandbox.js +6 -5
- package/dist/errors.d.ts +4 -3
- package/dist/errors.js +7 -3
- package/dist/index.d.ts +5 -5
- package/dist/inngest/index.d.ts +96 -0
- package/dist/inngest/index.js +183 -0
- package/dist/jobs-code/cron.d.ts +12 -0
- package/dist/jobs-code/cron.js +93 -0
- package/dist/jobs-code/registry.d.ts +31 -0
- package/dist/jobs-code/registry.js +30 -0
- package/dist/jobs-code/runner.d.ts +1 -0
- package/dist/jobs-code/runner.js +74 -0
- package/dist/jobs-deploy.d.ts +22 -0
- package/dist/jobs-deploy.js +247 -0
- package/dist/jobs-import.d.ts +15 -0
- package/dist/jobs-import.js +231 -0
- package/dist/products/agents.d.ts +413 -2
- package/dist/products/agents.js +176 -0
- package/dist/products/apps.d.ts +2 -1
- package/dist/products/browsers.d.ts +87 -0
- package/dist/products/browsers.js +67 -0
- package/dist/products/builds.d.ts +11 -2
- package/dist/products/ci.d.ts +21 -1
- package/dist/products/jobs.d.ts +77 -0
- package/dist/products/jobs.js +5 -0
- package/dist/products/observability.d.ts +31 -3
- package/dist/products/plans.d.ts +5 -3
- package/dist/products/secrets.d.ts +67 -14
- package/dist/products/secrets.js +41 -12
- package/dist/transport.d.ts +6 -1
- package/dist/transport.js +38 -1
- package/dist/trigger/index.d.ts +202 -0
- package/dist/trigger/index.js +244 -0
- package/dist/types.d.ts +14 -0
- package/package.json +14 -3
package/dist/products/agents.js
CHANGED
|
@@ -24,6 +24,9 @@ const CODEX = 'npx -y @openai/codex exec --dangerously-bypass-approvals-and-sand
|
|
|
24
24
|
const GEMINI = 'npx -y @google/gemini-cli --yolo -p "$(cat ~/.runtime-agent/start.md)"';
|
|
25
25
|
const REVIEW = "python3 ~/.runtime-agent/runtime-agent review";
|
|
26
26
|
const JUDGE = "python3 ~/.runtime-agent/runtime-agent judge";
|
|
27
|
+
/** A browser run's harness (browser-use on the sandbox's Chromium); its
|
|
28
|
+
* sessions are started by POST /v1/browsers/runs. */
|
|
29
|
+
const BROWSE = "python3 ~/.runtime-agent/runtime-agent browse";
|
|
27
30
|
/** The harnesses (agents-contract.md); tests/agents.test.ts holds them
|
|
28
31
|
* to packages/cloud-guide/agent-templates.json. */
|
|
29
32
|
export const AGENT_TEMPLATES = {
|
|
@@ -102,6 +105,21 @@ export const AGENT_TEMPLATES = {
|
|
|
102
105
|
maxSessionSeconds: 1800,
|
|
103
106
|
},
|
|
104
107
|
},
|
|
108
|
+
browser: {
|
|
109
|
+
key: "browser",
|
|
110
|
+
title: "Browser task",
|
|
111
|
+
command: BROWSE,
|
|
112
|
+
apiKeySecret: "ANTHROPIC_API_KEY",
|
|
113
|
+
apiKeyHost: "api.anthropic.com",
|
|
114
|
+
subscription: null,
|
|
115
|
+
definition: {
|
|
116
|
+
command: BROWSE,
|
|
117
|
+
secrets: ["ANTHROPIC_API_KEY"],
|
|
118
|
+
vcpu: 2,
|
|
119
|
+
memoryMiB: 4096,
|
|
120
|
+
maxSessionSeconds: 1800,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
105
123
|
};
|
|
106
124
|
/** A harness by a key read from a file or a flag, or undefined. */
|
|
107
125
|
export function agentTemplate(key) {
|
|
@@ -133,6 +151,19 @@ const enc = encodeURIComponent;
|
|
|
133
151
|
const ENDED = ["done", "failed", "stopped"];
|
|
134
152
|
export function agents(t) {
|
|
135
153
|
const getSession = (id, options) => t.json({ method: "GET", path: `/v1/agents/sessions/${enc(id)}`, ...options });
|
|
154
|
+
function trace(id, options = {}) {
|
|
155
|
+
const { format = "json", after, limit, ...rest } = options;
|
|
156
|
+
return t.json({
|
|
157
|
+
method: "GET",
|
|
158
|
+
path: `/v1/agents/sessions/${enc(id)}/trace`,
|
|
159
|
+
query: {
|
|
160
|
+
format,
|
|
161
|
+
...(after !== undefined ? { after } : {}),
|
|
162
|
+
...(limit !== undefined ? { limit } : {}),
|
|
163
|
+
},
|
|
164
|
+
...rest,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
136
167
|
async function* events(id, options = {}) {
|
|
137
168
|
let after = options.after ?? 0;
|
|
138
169
|
for (;;) {
|
|
@@ -164,6 +195,7 @@ export function agents(t) {
|
|
|
164
195
|
...options,
|
|
165
196
|
}),
|
|
166
197
|
events: (options) => events(session.id, options),
|
|
198
|
+
trace: ((options) => trace(session.id, options)),
|
|
167
199
|
stop: (options) => t.json({
|
|
168
200
|
method: "POST",
|
|
169
201
|
path: `/v1/agents/sessions/${enc(session.id)}/stop`,
|
|
@@ -198,6 +230,66 @@ export function agents(t) {
|
|
|
198
230
|
});
|
|
199
231
|
return new Page(page.data, page.nextCursor, (cursor) => listSessions({ ...query, cursor }, options));
|
|
200
232
|
};
|
|
233
|
+
const getWorkflow = (id, options) => t.json({ method: "GET", path: `/v1/agents/workflows/${enc(id)}`, ...options });
|
|
234
|
+
async function* followWorkflow(id, options = {}) {
|
|
235
|
+
let after = options.after ?? 0;
|
|
236
|
+
for (;;) {
|
|
237
|
+
options.signal?.throwIfAborted();
|
|
238
|
+
const now = await t.json({
|
|
239
|
+
method: "GET",
|
|
240
|
+
path: `/v1/agents/workflows/${enc(id)}`,
|
|
241
|
+
query: { after, wait: 30 },
|
|
242
|
+
...(options.signal ? { signal: options.signal } : {}),
|
|
243
|
+
timeoutMs: 0,
|
|
244
|
+
});
|
|
245
|
+
if (now.version > after) {
|
|
246
|
+
after = now.version;
|
|
247
|
+
yield now;
|
|
248
|
+
}
|
|
249
|
+
if (now.state !== "running")
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const listWorkflows = async (query = {}, options) => {
|
|
254
|
+
const page = await t.json({
|
|
255
|
+
method: "GET",
|
|
256
|
+
path: "/v1/agents/workflows",
|
|
257
|
+
query,
|
|
258
|
+
...options,
|
|
259
|
+
});
|
|
260
|
+
return new Page(page.data, page.nextCursor, (cursor) => listWorkflows({ ...query, cursor }, options));
|
|
261
|
+
};
|
|
262
|
+
const listSteps = async (id, query = {}, options) => {
|
|
263
|
+
const page = await t.json({
|
|
264
|
+
method: "GET",
|
|
265
|
+
path: `/v1/agents/workflows/${enc(id)}/steps`,
|
|
266
|
+
query,
|
|
267
|
+
...options,
|
|
268
|
+
});
|
|
269
|
+
return new Page(page.data, page.nextCursor, (cursor) => listSteps(id, { ...query, cursor }, options));
|
|
270
|
+
};
|
|
271
|
+
const stopWorkflow = (id, options) => t.json({
|
|
272
|
+
method: "POST",
|
|
273
|
+
path: `/v1/agents/workflows/${enc(id)}/stop`,
|
|
274
|
+
body: {},
|
|
275
|
+
...options,
|
|
276
|
+
});
|
|
277
|
+
const workflowHandle = (workflow) => ({
|
|
278
|
+
id: workflow.id,
|
|
279
|
+
workflow,
|
|
280
|
+
follow: (options) => followWorkflow(workflow.id, options),
|
|
281
|
+
async wait(options = {}) {
|
|
282
|
+
let last = await getWorkflow(workflow.id, options);
|
|
283
|
+
if (last.state !== "running")
|
|
284
|
+
return last;
|
|
285
|
+
for await (const now of followWorkflow(workflow.id, { after: last.version, ...options }))
|
|
286
|
+
last = now;
|
|
287
|
+
return last;
|
|
288
|
+
},
|
|
289
|
+
steps: (query, options) => listSteps(workflow.id, query, options),
|
|
290
|
+
stop: (options) => stopWorkflow(workflow.id, options),
|
|
291
|
+
get: (options) => getWorkflow(workflow.id, options),
|
|
292
|
+
});
|
|
201
293
|
const listAsks = async (query = {}, options) => {
|
|
202
294
|
const { labels, ...rest } = query;
|
|
203
295
|
const page = await t.json({
|
|
@@ -235,6 +327,13 @@ export function agents(t) {
|
|
|
235
327
|
query: { scope, path },
|
|
236
328
|
});
|
|
237
329
|
return {
|
|
330
|
+
/** Claude Managed Agents' API on Runtime: the options Anthropic's SDK
|
|
331
|
+
* takes, so code written for it runs here unchanged:
|
|
332
|
+
* `new Anthropic(await runtime.agents.anthropic())`. */
|
|
333
|
+
anthropic: async () => ({
|
|
334
|
+
baseURL: `${t.baseUrl}/anthropic`,
|
|
335
|
+
apiKey: await t.apiKey(),
|
|
336
|
+
}),
|
|
238
337
|
/** An agent: a name and a definition its sessions start from. */
|
|
239
338
|
create: (input, options) => t.json({ method: "POST", path: "/v1/agents", body: input, ...options }),
|
|
240
339
|
/** By its id or its name. */
|
|
@@ -268,6 +367,10 @@ export function agents(t) {
|
|
|
268
367
|
},
|
|
269
368
|
sessions: {
|
|
270
369
|
get: getSession,
|
|
370
|
+
/** A session's trace: every model turn and tool call with its timing,
|
|
371
|
+
* tokens and cost, totals by model and tool; `{ format: "otlp" }` for
|
|
372
|
+
* OpenTelemetry traces in the GenAI semantic conventions. */
|
|
373
|
+
trace,
|
|
271
374
|
/** Newest first; of one agent, or in some states. */
|
|
272
375
|
list: listSessions,
|
|
273
376
|
/** An ended session and its log go. Its history is storage like any
|
|
@@ -281,6 +384,35 @@ export function agents(t) {
|
|
|
281
384
|
});
|
|
282
385
|
},
|
|
283
386
|
},
|
|
387
|
+
/** Many sessions in phases as one piece of work: fanned out over lists
|
|
388
|
+
* or earlier results, in parallel and in pipelines, under maxSessions,
|
|
389
|
+
* maxConcurrent and maxDollars, ending with one result. The database
|
|
390
|
+
* starts each step the moment what it waits on ends; nothing else runs
|
|
391
|
+
* between steps, so a workflow costs only its sessions. */
|
|
392
|
+
workflows: {
|
|
393
|
+
/** Runs it now; answers a handle to follow, wait for and stop. */
|
|
394
|
+
async run(input, options) {
|
|
395
|
+
return workflowHandle(await t.json({
|
|
396
|
+
method: "POST",
|
|
397
|
+
path: "/v1/agents/workflows",
|
|
398
|
+
body: input,
|
|
399
|
+
...options,
|
|
400
|
+
}));
|
|
401
|
+
},
|
|
402
|
+
/** One you already have, by its id. */
|
|
403
|
+
async workflow(id, options) {
|
|
404
|
+
return workflowHandle(await getWorkflow(id, options));
|
|
405
|
+
},
|
|
406
|
+
get: getWorkflow,
|
|
407
|
+
/** The workflow at each change past `after`, as it happens, until it
|
|
408
|
+
* has ended: each read waits up to 30 seconds for the next change. */
|
|
409
|
+
follow: followWorkflow,
|
|
410
|
+
/** Newest first, each with its phases' progress and cost. */
|
|
411
|
+
list: listWorkflows,
|
|
412
|
+
steps: listSteps,
|
|
413
|
+
/** Nothing more of it starts, and its open sessions stop. */
|
|
414
|
+
stop: stopWorkflow,
|
|
415
|
+
},
|
|
284
416
|
/** The account's inbox: the questions its agents' sessions need answered
|
|
285
417
|
* to go on, one row per step however many sessions ask it. */
|
|
286
418
|
asks: {
|
|
@@ -295,6 +427,50 @@ export function agents(t) {
|
|
|
295
427
|
body: answer,
|
|
296
428
|
...options,
|
|
297
429
|
}),
|
|
430
|
+
/** Lets a tool call the agent's permissions held run (its ask's Allow). */
|
|
431
|
+
approve: (id, options) => t.json({
|
|
432
|
+
method: "POST",
|
|
433
|
+
path: `/v1/agents/asks/${enc(id)}/answer`,
|
|
434
|
+
body: { option: "Allow" },
|
|
435
|
+
...options,
|
|
436
|
+
}),
|
|
437
|
+
/** Keeps a held tool call from running (its ask's Deny); `message` is
|
|
438
|
+
* told to the agent as the reason. */
|
|
439
|
+
deny: (id, message, options) => t.json({
|
|
440
|
+
method: "POST",
|
|
441
|
+
path: `/v1/agents/asks/${enc(id)}/answer`,
|
|
442
|
+
body: { option: "Deny", ...(message ? { text: message } : {}) },
|
|
443
|
+
...options,
|
|
444
|
+
}),
|
|
445
|
+
},
|
|
446
|
+
/** Runtime's Slack app in your workspaces, for `slack` triggers. */
|
|
447
|
+
slack: {
|
|
448
|
+
/** A link that adds Runtime's Slack app to a workspace, good for 15
|
|
449
|
+
* minutes. Open it in a browser signed in to this account, then
|
|
450
|
+
* approve the app in Slack; Slack sends the browser back to the
|
|
451
|
+
* console once it is added. Opened by anyone outside the account, it
|
|
452
|
+
* adds nothing. */
|
|
453
|
+
install: (options) => t.json({
|
|
454
|
+
method: "POST",
|
|
455
|
+
path: "/v1/agents/slack/installs",
|
|
456
|
+
body: {},
|
|
457
|
+
...options,
|
|
458
|
+
}),
|
|
459
|
+
/** The workspaces added to this account. */
|
|
460
|
+
teams: async (options) => (await t.json({
|
|
461
|
+
method: "GET",
|
|
462
|
+
path: "/v1/agents/slack/teams",
|
|
463
|
+
...options,
|
|
464
|
+
})).data,
|
|
465
|
+
/** Removes a workspace: its token is revoked, and its triggers refuse
|
|
466
|
+
* events until it is added again. */
|
|
467
|
+
remove: async (team, options) => {
|
|
468
|
+
await t.json({
|
|
469
|
+
method: "DELETE",
|
|
470
|
+
path: `/v1/agents/slack/teams/${enc(team)}`,
|
|
471
|
+
...options,
|
|
472
|
+
});
|
|
473
|
+
},
|
|
298
474
|
},
|
|
299
475
|
triggers: {
|
|
300
476
|
create: (agent, input, options) => t.json({
|
package/dist/products/apps.d.ts
CHANGED
|
@@ -116,7 +116,8 @@ export type CreateFunction = {
|
|
|
116
116
|
name?: string;
|
|
117
117
|
/** At most 32 entries, each value at most 256 characters. */
|
|
118
118
|
labels?: Record<string, string>;
|
|
119
|
-
/** Required, 1 to
|
|
119
|
+
/** Required, 1 to the account's App copies at once (its plan's sandboxes at
|
|
120
|
+
* once, GET /v1/limits `instance.count`). Bounds the number of awake copies. */
|
|
120
121
|
maxCopies: number;
|
|
121
122
|
/** Required, 1 to 16. */
|
|
122
123
|
vcpu: number;
|
|
@@ -62,6 +62,61 @@ export type BrowserScreenshotResult = {
|
|
|
62
62
|
/** The image. */
|
|
63
63
|
base64: string;
|
|
64
64
|
};
|
|
65
|
+
/** A task in plain words, done by an agent that browses (POST /v1/browsers/runs). */
|
|
66
|
+
export type BrowserRunInput = {
|
|
67
|
+
/** What to do, in plain words; at most 16 KiB. */
|
|
68
|
+
task: string;
|
|
69
|
+
/** Opened before the agent's first step. */
|
|
70
|
+
startUrl?: string;
|
|
71
|
+
/** A claude-, gpt-, o1, o3, o4 or gemini- model; the server defaults to
|
|
72
|
+
* claude-sonnet-5-5. Its key is your egress secret ANTHROPIC_API_KEY,
|
|
73
|
+
* OPENAI_API_KEY or GEMINI_API_KEY. */
|
|
74
|
+
model?: string;
|
|
75
|
+
/** 1 to 200; the server defaults to 30. */
|
|
76
|
+
maxSteps?: number;
|
|
77
|
+
/** Only these domains are opened (example.com, *.example.com). */
|
|
78
|
+
allowedDomains?: string[];
|
|
79
|
+
labels?: Record<string, string>;
|
|
80
|
+
};
|
|
81
|
+
export type BrowserRunState = "queued" | "running" | "done" | "failed" | "stopped";
|
|
82
|
+
export type BrowserRun = {
|
|
83
|
+
id: string;
|
|
84
|
+
state: BrowserRunState;
|
|
85
|
+
task: string | null;
|
|
86
|
+
model: string | null;
|
|
87
|
+
startUrl: string | null;
|
|
88
|
+
/** The agent's answer, once done. */
|
|
89
|
+
output: string | null;
|
|
90
|
+
/** Why it failed, and what to do. */
|
|
91
|
+
error: string | null;
|
|
92
|
+
steps: number;
|
|
93
|
+
/** The page the browser ended on. */
|
|
94
|
+
url: string | null;
|
|
95
|
+
sandboxId: string | null;
|
|
96
|
+
labels: Record<string, string>;
|
|
97
|
+
createdAt: string;
|
|
98
|
+
startedAt: string | null;
|
|
99
|
+
endedAt: string | null;
|
|
100
|
+
};
|
|
101
|
+
/** One step of a run: the page the agent saw and what it did. */
|
|
102
|
+
export type BrowserRunStep = {
|
|
103
|
+
/** 0 is the page before the first step; the last is the page at the end. */
|
|
104
|
+
n: number;
|
|
105
|
+
url: string | null;
|
|
106
|
+
title: string | null;
|
|
107
|
+
goal: string | null;
|
|
108
|
+
actions: unknown[];
|
|
109
|
+
/** The page as a JPEG, base64; null when asked without frames. */
|
|
110
|
+
frame: string | null;
|
|
111
|
+
at: string;
|
|
112
|
+
/** Its place in the run's log: pass as `after`. */
|
|
113
|
+
seq: number;
|
|
114
|
+
};
|
|
115
|
+
export type BrowserRunSteps = {
|
|
116
|
+
data: BrowserRunStep[];
|
|
117
|
+
after: number;
|
|
118
|
+
ended: boolean;
|
|
119
|
+
};
|
|
65
120
|
export type BrowserConnectOptions = {
|
|
66
121
|
playwright: [endpointURL: string, options: {
|
|
67
122
|
headers: Record<string, string>;
|
|
@@ -94,4 +149,36 @@ export declare function browsers(t: Transport): {
|
|
|
94
149
|
screenshot(id: string, input?: BrowserScreenshot, options?: RequestOptions): Promise<BrowserScreenshotResult>;
|
|
95
150
|
/** End a browser by id; pass RequestOptions to bound or deduplicate the request. */
|
|
96
151
|
delete: (id: string, options?: RequestOptions) => Promise<void>;
|
|
152
|
+
/** Do a task in a browser, described in plain words, and wait for its
|
|
153
|
+
* end: `output` once done, `error` once failed. A string is the task.
|
|
154
|
+
* Its steps, each with the page it saw, are `runs.steps(run.id)`. */
|
|
155
|
+
run(input: string | BrowserRunInput, options?: RequestOptions): Promise<BrowserRun>;
|
|
156
|
+
runs: {
|
|
157
|
+
/** Start a run and return it at once (state queued). */
|
|
158
|
+
create: (input: BrowserRunInput, options?: RequestOptions) => Promise<BrowserRun>;
|
|
159
|
+
get: (id: string, options?: RequestOptions) => Promise<BrowserRun>;
|
|
160
|
+
list: (query?: {
|
|
161
|
+
cursor?: string;
|
|
162
|
+
limit?: number;
|
|
163
|
+
}, options?: RequestOptions) => Promise<Page<BrowserRun>>;
|
|
164
|
+
/** One page of a run's steps; `wait` (seconds, up to 30) waits for one. */
|
|
165
|
+
steps: (id: string, query?: {
|
|
166
|
+
after?: number;
|
|
167
|
+
limit?: number;
|
|
168
|
+
frames?: boolean;
|
|
169
|
+
wait?: number;
|
|
170
|
+
}, options?: RequestOptions) => Promise<BrowserRunSteps>;
|
|
171
|
+
/** Every step, as it comes, until the run ends: its recording. */
|
|
172
|
+
follow: (id: string, options?: {
|
|
173
|
+
after?: number;
|
|
174
|
+
frames?: boolean;
|
|
175
|
+
signal?: AbortSignal;
|
|
176
|
+
}) => AsyncGenerator<BrowserRunStep>;
|
|
177
|
+
/** Stop a run; its sandbox is deleted and its steps are kept. */
|
|
178
|
+
stop: (id: string, options?: RequestOptions) => Promise<BrowserRun>;
|
|
179
|
+
/** Until the run has ended; answers it then. */
|
|
180
|
+
wait(id: string, options?: {
|
|
181
|
+
signal?: AbortSignal;
|
|
182
|
+
}): Promise<BrowserRun>;
|
|
183
|
+
};
|
|
97
184
|
};
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { RuntimeError } from "../errors.js";
|
|
11
11
|
import { Page } from "../page.js";
|
|
12
|
+
const RUN_ENDED = ["done", "failed", "stopped"];
|
|
12
13
|
/** Browsers follow the shared resource interface: id, name, labels, state. */
|
|
13
14
|
export function browsers(t) {
|
|
15
|
+
const runs = browserRuns(t);
|
|
14
16
|
const path = (id) => `/v1/browsers/${encodeURIComponent(id)}`;
|
|
15
17
|
/** End a browser by id; API errors retain their code and recovery hint. */
|
|
16
18
|
const remove = async (id, options) => {
|
|
@@ -109,5 +111,70 @@ export function browsers(t) {
|
|
|
109
111
|
},
|
|
110
112
|
/** End a browser by id; pass RequestOptions to bound or deduplicate the request. */
|
|
111
113
|
delete: remove,
|
|
114
|
+
/** Do a task in a browser, described in plain words, and wait for its
|
|
115
|
+
* end: `output` once done, `error` once failed. A string is the task.
|
|
116
|
+
* Its steps, each with the page it saw, are `runs.steps(run.id)`. */
|
|
117
|
+
async run(input, options) {
|
|
118
|
+
const started = await runs.create(typeof input === "string" ? { task: input } : input, options);
|
|
119
|
+
return runs.wait(started.id, options?.signal ? { signal: options.signal } : {});
|
|
120
|
+
},
|
|
121
|
+
runs,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/** Browser runs: start one, follow its steps, wait for its end. */
|
|
125
|
+
function browserRuns(t) {
|
|
126
|
+
const runPath = (id) => `/v1/browsers/runs/${encodeURIComponent(id)}`;
|
|
127
|
+
const get = (id, options) => t.json({ method: "GET", path: runPath(id), ...options });
|
|
128
|
+
const steps = (id, query = {}, options) => t.json({
|
|
129
|
+
method: "GET",
|
|
130
|
+
path: `${runPath(id)}/steps`,
|
|
131
|
+
query,
|
|
132
|
+
...options,
|
|
133
|
+
...(query.wait ? { timeoutMs: 0 } : {}),
|
|
134
|
+
});
|
|
135
|
+
/** Every step after `after`, as each comes, waiting up to 30 seconds a
|
|
136
|
+
* call; ends when the run has ended. */
|
|
137
|
+
async function* follow(id, options = {}) {
|
|
138
|
+
let after = options.after ?? 0;
|
|
139
|
+
for (;;) {
|
|
140
|
+
options.signal?.throwIfAborted();
|
|
141
|
+
const read = await steps(id, { after, wait: 30, ...(options.frames === false ? { frames: false } : {}) }, options.signal ? { signal: options.signal } : {});
|
|
142
|
+
for (const step of read.data)
|
|
143
|
+
yield step;
|
|
144
|
+
after = read.after;
|
|
145
|
+
if (read.ended && read.data.length === 0)
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const list = async (query = {}, options) => {
|
|
150
|
+
const page = await t.json({
|
|
151
|
+
method: "GET",
|
|
152
|
+
path: "/v1/browsers/runs",
|
|
153
|
+
query,
|
|
154
|
+
...options,
|
|
155
|
+
});
|
|
156
|
+
return new Page(page.data, page.nextCursor, (cursor) => list({ ...query, cursor }, options));
|
|
157
|
+
};
|
|
158
|
+
const runs = {
|
|
159
|
+
/** Start a run and return it at once (state queued). */
|
|
160
|
+
create: (input, options) => t.json({ method: "POST", path: "/v1/browsers/runs", body: input, ...options }),
|
|
161
|
+
get,
|
|
162
|
+
list,
|
|
163
|
+
/** One page of a run's steps; `wait` (seconds, up to 30) waits for one. */
|
|
164
|
+
steps,
|
|
165
|
+
/** Every step, as it comes, until the run ends: its recording. */
|
|
166
|
+
follow,
|
|
167
|
+
/** Stop a run; its sandbox is deleted and its steps are kept. */
|
|
168
|
+
stop: (id, options) => t.json({ method: "POST", path: `${runPath(id)}:stop`, body: {}, ...options }),
|
|
169
|
+
/** Until the run has ended; answers it then. */
|
|
170
|
+
async wait(id, options = {}) {
|
|
171
|
+
const now = await get(id, options);
|
|
172
|
+
if (RUN_ENDED.includes(now.state))
|
|
173
|
+
return now;
|
|
174
|
+
for await (const _ of follow(id, { frames: false, ...options }))
|
|
175
|
+
;
|
|
176
|
+
return get(id, options);
|
|
177
|
+
},
|
|
112
178
|
};
|
|
179
|
+
return runs;
|
|
113
180
|
}
|
|
@@ -27,6 +27,10 @@ export type Build = Resource & {
|
|
|
27
27
|
/** The saved server an App deploys, once a build of a repository with a
|
|
28
28
|
* start command succeeded; null otherwise. */
|
|
29
29
|
outputSnapshotId: string | null;
|
|
30
|
+
/** The framework detected in the build folder for the commands its
|
|
31
|
+
* repository leaves unset (nextjs, vite, fastapi, django, rails, go,
|
|
32
|
+
* docker, ...); null when none was or every command is set. */
|
|
33
|
+
framework: string | null;
|
|
30
34
|
};
|
|
31
35
|
export type CreateBuild = {
|
|
32
36
|
repositoryId: string;
|
|
@@ -51,11 +55,16 @@ export type ConnectRepository = {
|
|
|
51
55
|
previews?: boolean;
|
|
52
56
|
/** The folder the build runs in; the repository's root by default. */
|
|
53
57
|
rootDirectory?: string;
|
|
54
|
-
/** Leave out to
|
|
58
|
+
/** Leave out to use the detected framework's install (when startCommand
|
|
59
|
+
* is left out too), or the lockfile's
|
|
60
|
+
* (bun, pnpm, Yarn or npm). */
|
|
55
61
|
installCommand?: string | null;
|
|
62
|
+
/** Leave out to use the detected framework's build (when startCommand is
|
|
63
|
+
* left out too), or the lockfile's. */
|
|
56
64
|
buildCommand?: string | null;
|
|
57
65
|
/** Run after the build with PORT set; the build ends as this server,
|
|
58
|
-
* answering healthPath with 200 and saved with its memory.
|
|
66
|
+
* answering healthPath with 200 and saved with its memory. Leave out to
|
|
67
|
+
* use the detected framework's server (the build's `framework`). */
|
|
59
68
|
startCommand?: string | null;
|
|
60
69
|
port?: number;
|
|
61
70
|
healthPath?: string | null;
|
package/dist/products/ci.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type CiRepository = {
|
|
|
18
18
|
repository: string;
|
|
19
19
|
/** The branch whose pushes are checked as landed. */
|
|
20
20
|
productionBranch: string;
|
|
21
|
-
/** Where in the repository its checks are written. */
|
|
21
|
+
/** Where in the repository its checks are written: a `runtime.yml`, or a `cloudbuild.yaml` or `buildspec.yml`, run as Cloud Build or CodeBuild runs it. */
|
|
22
22
|
configPath: string;
|
|
23
23
|
/** The organization's installation of Runtime's GitHub App it is read through. */
|
|
24
24
|
installation: number;
|
|
@@ -122,7 +122,14 @@ export type CiJob = {
|
|
|
122
122
|
/** The sandboxes it ran in. A failure's may be kept paused: wake it, or
|
|
123
123
|
* exec in it, with runtime.sandboxes. */
|
|
124
124
|
sandboxIds: string[];
|
|
125
|
+
/** The ID of the job's own GitHub check run (`runtime / <name>`), created
|
|
126
|
+
* completed when the job ends; null while it runs, for a reused pass, or
|
|
127
|
+
* when GitHub did not accept the run. */
|
|
125
128
|
githubCheckRun: number | null;
|
|
129
|
+
/** Lines of the repository's files that the job's log reports as failing,
|
|
130
|
+
* or as warnings and notices, as its GitHub check run shows them. At most
|
|
131
|
+
* 50, failures first. */
|
|
132
|
+
annotations: CiAnnotation[];
|
|
126
133
|
/** A review step's verdict on the commit; null for a command's job. */
|
|
127
134
|
review: CiReview | null;
|
|
128
135
|
ms: number | null;
|
|
@@ -131,6 +138,17 @@ export type CiJob = {
|
|
|
131
138
|
startedAt: number | null;
|
|
132
139
|
endedAt: number | null;
|
|
133
140
|
};
|
|
141
|
+
/** A line of a file that a job's log reports. */
|
|
142
|
+
export type CiAnnotation = {
|
|
143
|
+
path: string;
|
|
144
|
+
startLine: number;
|
|
145
|
+
endLine: number;
|
|
146
|
+
/** Present only for a single line. */
|
|
147
|
+
startColumn?: number;
|
|
148
|
+
level: "notice" | "warning" | "failure";
|
|
149
|
+
message: string;
|
|
150
|
+
title?: string;
|
|
151
|
+
};
|
|
134
152
|
/** What one finding of a review is about. */
|
|
135
153
|
export type CiReviewKind = "bug" | "missed-case" | "data-at-risk" | "money-at-risk" | "auth-bypass" | "privilege-escalation" | "secret-exposed" | "made-public" | "command-injection" | "manipulation" | "other";
|
|
136
154
|
/** One thing a review found in the change. */
|
|
@@ -183,6 +201,8 @@ export type CiJobDetail = CiJob & {
|
|
|
183
201
|
export type ListCiChecks = {
|
|
184
202
|
repositoryId?: string;
|
|
185
203
|
state?: CiCheckState[];
|
|
204
|
+
/** Only checks started by these events: `merge_group` lists GitHub's merge queue's. */
|
|
205
|
+
event?: CiCheck["event"][];
|
|
186
206
|
branch?: string;
|
|
187
207
|
/** A full commit SHA. */
|
|
188
208
|
commit?: string;
|
package/dist/products/jobs.d.ts
CHANGED
|
@@ -264,6 +264,78 @@ export declare function jobUpdateBody(input: UpdateJob): Record<string, unknown>
|
|
|
264
264
|
* on this deployment."). This names the product, keeps the code, status and
|
|
265
265
|
* request id, and says no retry will change it. */
|
|
266
266
|
export declare function switchedOff(product: string): (error: unknown) => never;
|
|
267
|
+
/** Another platform's job files, read into Runtime jobs (`jobs.importPlan`). */
|
|
268
|
+
export type JobImportRequest = {
|
|
269
|
+
/** The files, each with its name: a Cloud Run job's YAML and the Cloud
|
|
270
|
+
* Scheduler job that runs it, or an AWS Batch job definition (API JSON,
|
|
271
|
+
* describe-job-definitions output or a CloudFormation template) and the
|
|
272
|
+
* EventBridge schedule or rule that submits it. At most 1 MiB in all. */
|
|
273
|
+
files: {
|
|
274
|
+
path: string;
|
|
275
|
+
text: string;
|
|
276
|
+
}[];
|
|
277
|
+
/** Read them as this platform's; detected from the files when omitted. */
|
|
278
|
+
from?: "cloud-run" | "aws-batch";
|
|
279
|
+
/** A CloudFormation template's parameters and pseudo parameters, such as
|
|
280
|
+
* `{ "AWS::Region": "us-east-1" }`. */
|
|
281
|
+
parameters?: Record<string, string>;
|
|
282
|
+
};
|
|
283
|
+
export type JobImportSchedule = {
|
|
284
|
+
kind: "cron";
|
|
285
|
+
expression: string;
|
|
286
|
+
timezone: string;
|
|
287
|
+
} | {
|
|
288
|
+
kind: "once";
|
|
289
|
+
at: string;
|
|
290
|
+
timezone: string;
|
|
291
|
+
};
|
|
292
|
+
/** One job of a plan. Its image is built from `dockerfile`, and it runs the
|
|
293
|
+
* built image's start command. */
|
|
294
|
+
export type JobImportJob = {
|
|
295
|
+
name: string;
|
|
296
|
+
file: string;
|
|
297
|
+
/** The container image it ran on the other platform. */
|
|
298
|
+
sourceImage: string;
|
|
299
|
+
dockerfile: string;
|
|
300
|
+
/** The whole command when the file names it; null when part of it is the
|
|
301
|
+
* container image's own ENTRYPOINT or CMD. */
|
|
302
|
+
command: string[] | null;
|
|
303
|
+
env: Record<string, string>;
|
|
304
|
+
/** Values it read from a secret store; each is bound from the jobs secret
|
|
305
|
+
* of that name. */
|
|
306
|
+
secrets: {
|
|
307
|
+
name: string;
|
|
308
|
+
from: string;
|
|
309
|
+
}[];
|
|
310
|
+
compute: {
|
|
311
|
+
vcpu: number;
|
|
312
|
+
memoryMib: number;
|
|
313
|
+
diskMib: number | null;
|
|
314
|
+
};
|
|
315
|
+
timeoutSeconds: number;
|
|
316
|
+
retry: {
|
|
317
|
+
maxAttempts: number;
|
|
318
|
+
backoffSeconds: number;
|
|
319
|
+
};
|
|
320
|
+
/** Null: no schedule ran it there; it runs when triggered. */
|
|
321
|
+
schedule: JobImportSchedule | null;
|
|
322
|
+
/** Why it cannot be created as planned; null when it can. */
|
|
323
|
+
blocked: string | null;
|
|
324
|
+
};
|
|
325
|
+
export type JobImportPlan = {
|
|
326
|
+
from: "cloud-run" | "aws-batch";
|
|
327
|
+
read: string[];
|
|
328
|
+
jobs: JobImportJob[];
|
|
329
|
+
/** unmapped: left out. changed: carried over differently. info: how. */
|
|
330
|
+
notes: {
|
|
331
|
+
level: "unmapped" | "changed" | "info";
|
|
332
|
+
file: string;
|
|
333
|
+
key: string;
|
|
334
|
+
job?: string;
|
|
335
|
+
message: string;
|
|
336
|
+
}[];
|
|
337
|
+
importable: boolean;
|
|
338
|
+
};
|
|
267
339
|
/** Scheduled jobs: a command run in a fresh sandbox, once or on a cron
|
|
268
340
|
* 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
|
|
269
341
|
* at the sandbox rates, through the same holds and spending limits.
|
|
@@ -287,6 +359,11 @@ export declare function jobs(transport: Transport): {
|
|
|
287
359
|
limit?: number;
|
|
288
360
|
cursor?: string;
|
|
289
361
|
}, options?: RequestOptions) => Promise<Page<Job>>;
|
|
362
|
+
/** Read a Cloud Run job or an AWS Batch job definition, with its
|
|
363
|
+
* schedule, into the jobs that run the same container here, and what
|
|
364
|
+
* could not be carried over. Changes nothing; `runtime jobs import`
|
|
365
|
+
* builds and creates the plan. */
|
|
366
|
+
importPlan: (input: JobImportRequest, options?: RequestOptions) => Promise<JobImportPlan>;
|
|
290
367
|
get: (id: string, options?: RequestOptions) => Promise<Job>;
|
|
291
368
|
/** A job's runs, oldest first: each attempt of each occurrence.
|
|
292
369
|
* `{ order: "newest" }`: newest first, so the last run is one call.
|
package/dist/products/jobs.js
CHANGED
|
@@ -198,6 +198,11 @@ export function jobs(transport) {
|
|
|
198
198
|
create: (input, options) => t.json({ method: "POST", path: "/v1/jobs", body: jobBody(input), ...options }),
|
|
199
199
|
/** Your jobs, oldest first. Await for a page, or `for await` for all. */
|
|
200
200
|
list,
|
|
201
|
+
/** Read a Cloud Run job or an AWS Batch job definition, with its
|
|
202
|
+
* schedule, into the jobs that run the same container here, and what
|
|
203
|
+
* could not be carried over. Changes nothing; `runtime jobs import`
|
|
204
|
+
* builds and creates the plan. */
|
|
205
|
+
importPlan: (input, options) => t.json({ method: "POST", path: "/v1/job-imports", body: input, ...options }),
|
|
201
206
|
get: (id, options) => t.json({ method: "GET", path: `/v1/jobs/${enc(id)}`, ...options }),
|
|
202
207
|
/** A job's runs, oldest first: each attempt of each occurrence.
|
|
203
208
|
* `{ order: "newest" }`: newest first, so the last run is one call.
|