withruntime 0.34.0 → 0.37.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 (47) hide show
  1. package/BLAXEL.md +207 -204
  2. package/COMPATIBILITY.md +367 -337
  3. package/DAYTONA.md +180 -173
  4. package/E2B.md +246 -230
  5. package/README.md +182 -142
  6. package/README.src.md +182 -142
  7. package/VERCEL.md +173 -168
  8. package/agent-platforms-inventory.json +387 -0
  9. package/dist/agents-cli.d.ts +7 -1
  10. package/dist/agents-cli.js +219 -2
  11. package/dist/ci-cli.d.ts +7 -1
  12. package/dist/ci-cli.js +25 -1
  13. package/dist/cli-words.js +1 -0
  14. package/dist/cli.d.ts +1 -1
  15. package/dist/cli.js +25 -3
  16. package/dist/errors.d.ts +1 -1
  17. package/dist/errors.js +4 -1
  18. package/dist/functions/index.d.ts +10 -0
  19. package/dist/functions/index.js +11 -0
  20. package/dist/index.d.ts +3 -3
  21. package/dist/inngest/index.d.ts +96 -0
  22. package/dist/inngest/index.js +183 -0
  23. package/dist/jobs-code/cron.d.ts +12 -0
  24. package/dist/jobs-code/cron.js +93 -0
  25. package/dist/jobs-code/registry.d.ts +31 -0
  26. package/dist/jobs-code/registry.js +30 -0
  27. package/dist/jobs-code/runner.d.ts +1 -0
  28. package/dist/jobs-code/runner.js +74 -0
  29. package/dist/jobs-deploy.d.ts +22 -0
  30. package/dist/jobs-deploy.js +247 -0
  31. package/dist/jobs-import.d.ts +15 -0
  32. package/dist/jobs-import.js +231 -0
  33. package/dist/products/agents.d.ts +161 -1
  34. package/dist/products/agents.js +40 -0
  35. package/dist/products/ci.d.ts +19 -1
  36. package/dist/products/functions.d.ts +2 -0
  37. package/dist/products/functions.js +5 -0
  38. package/dist/products/index.d.ts +2 -0
  39. package/dist/products/index.js +3 -0
  40. package/dist/products/jobs.d.ts +77 -0
  41. package/dist/products/jobs.js +5 -0
  42. package/dist/transport.d.ts +5 -1
  43. package/dist/transport.js +7 -1
  44. package/dist/trigger/index.d.ts +202 -0
  45. package/dist/trigger/index.js +244 -0
  46. package/dist/types.d.ts +15 -3
  47. package/package.json +19 -3
@@ -2,6 +2,7 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join, resolve } from "node:path";
3
3
  import { me, named } from "./cli-name.js";
4
4
  import { AGENT_TEMPLATES, agentTemplate, AGENT_USES, agents, } from "./products/agents.js";
5
+ import { secrets } from "./products/secrets.js";
5
6
  export const AGENT_HELP = `runtime agents <command>
6
7
 
7
8
  An agent runs a harness (Claude Code, Codex, Gemini CLI, or your own code on
@@ -21,7 +22,7 @@ export const AGENT_HELP = `runtime agents <command>
21
22
  create <name> (--template <harness> | --command "<cmd>") [--use support|team]
22
23
  [--instructions <text> | --instructions-file <path>] [--secret NAME]... [--pool NAME]...
23
24
  [--env KEY=VALUE]... [--image <image> | --snapshot <id>] [--vcpu n] [--memory n]
24
- [--max-concurrent n] [--idle-pause n] [--label key=value]...
25
+ [--max-concurrent n] [--idle-pause n] [--permissions '<json>'] [--label key=value]...
25
26
  Make an agent; prints its id. --secret names an egress
26
27
  secret it may use: its model key, of any provider.
27
28
  --pool names a Claude account's secret (each one
@@ -37,17 +38,30 @@ export const AGENT_HELP = `runtime agents <command>
37
38
  until it ends
38
39
  send <session> <words...> Words into a session
39
40
  events <session> [--after <seq>] [--follow] A session's log; --follow until it ends
41
+ trace <session> [--otlp] [--export [--endpoint <url>] [--header key=value]...]
42
+ Every model turn and tool call: timing, tokens and
43
+ cost, totals by model and tool. --otlp prints
44
+ OpenTelemetry traces (OTLP/JSON); --export sends them
45
+ to a collector (--endpoint, or
46
+ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT /
47
+ OTEL_EXPORTER_OTLP_ENDPOINT and _HEADERS)
40
48
  sessions [--agent <agent>] [--state <state>]...
41
49
  Sessions, newest first
42
50
  sessions delete <session> Delete an ended session and its log; its history is
43
51
  storage, kept until you delete it
44
52
  stop <session> Stop a session
53
+ switch anthropic Run Claude Managed Agents code on Runtime: the
54
+ base URL to give Anthropic's SDK, and whether
55
+ the model key (ANTHROPIC_API_KEY) is set
45
56
  asks [--state <state>]... [--agent <agent>] [--label key=value]...
46
57
  The inbox: what your agents' sessions need answered,
47
58
  one row per step however many sessions ask it
48
59
  asks get <ask> One ask: its options, pick and the sessions asking
49
60
  answer <ask> [<option>] [--text <words>] Answer it with an option's label, words, or both:
50
61
  every session asking reads it next and wakes
62
+ approve <ask> Let a tool call the agent's permissions held run
63
+ deny <ask> [--message <words>] Keep a held tool call from running; the message is
64
+ told to the agent
51
65
  triggers <agent> Its triggers
52
66
  triggers add <agent> --kind <slack|github|schedule|webhook> --config '<json>' [--rules '<json>']
53
67
  triggers rules <triggerId> '<json>' Set its rules in place: priority, maxStartsPerHour,
@@ -84,10 +98,16 @@ Examples
84
98
  runtime agents start helper "How do I reset my password?" --key customer:42 --follow
85
99
  runtime agents memory put helper faq/refunds.md refunds.md
86
100
  runtime agents asks && runtime agents answer <ask> "Raise to 20 TB"
101
+ runtime agents update helper --permissions '{"default":"auto","tools":{"shell":"always_ask"}}'
102
+ runtime agents approve <ask>
103
+ runtime agents trace <session> --export --endpoint https://otel.example.com
87
104
  runtime agents init --template claude-code && runtime agents deploy --dry-run
88
105
  runtime agents create ci-review --template review --pool CLAUDE_1 --pool CLAUDE_2
106
+ runtime agents switch anthropic
89
107
  `;
90
108
  const when = (iso) => iso ?? "-";
109
+ /** The guide to running Claude Managed Agents code on Runtime. */
110
+ const SWITCH_DOCS = "https://withruntime.com/docs/switch-from-claude-managed-agents";
91
111
  /** A trigger's rules as the CLI takes them: one JSON object. */
92
112
  function rulesOf(text, kit) {
93
113
  let rules;
@@ -116,6 +136,7 @@ const OPTIONS = [
116
136
  "memory",
117
137
  "max-concurrent",
118
138
  "idle-pause",
139
+ "permissions",
119
140
  "label",
120
141
  ];
121
142
  const ASK_STATES = ["open", "answered", "expired", "withdrawn", "closed"];
@@ -125,6 +146,7 @@ const askLine = (a) => {
125
146
  `${a.id} ${a.state}${a.step ? ` step ${a.step}` : ""}, ${a.sessions.length} session${a.sessions.length === 1 ? "" : "s"} asking`,
126
147
  ` ${a.question}`,
127
148
  ...(a.why ? [` why: ${a.why}`] : []),
149
+ ...(a.toolCall ? [` tool call: ${a.toolCall.tool} ${JSON.stringify(a.toolCall.input)}`] : []),
128
150
  ...(options.length ? [` options: ${options.join(" | ")}`] : []),
129
151
  ...(a.expiresAt ? [` expires ${a.expiresAt}`] : []),
130
152
  ...(a.answer
@@ -188,9 +210,70 @@ function definitionOf(args, kit, env, base) {
188
210
  set("memoryMiB", integer(args, "memory"));
189
211
  set("maxConcurrent", integer(args, "max-concurrent"));
190
212
  set("idlePauseSeconds", integer(args, "idle-pause"));
213
+ const permissions = flag(args, "permissions");
214
+ if (permissions !== undefined) {
215
+ try {
216
+ set("permissions", JSON.parse(permissions));
217
+ }
218
+ catch {
219
+ throw usage(`--permissions takes JSON: '{"default":"auto","tools":{"shell":"always_ask"}}'.`);
220
+ }
221
+ }
191
222
  return definition;
192
223
  }
193
- const line = (e) => `${String(e.seq).padStart(4)} ${e.kind.padEnd(6)} ${e.actor}: ${typeof e.body.text === "string" ? e.body.text : JSON.stringify(e.body)}`;
224
+ const line = (e) => `${String(e.seq).padStart(4)} ${e.kind.padEnd(6)} ${e.actor}: ${e.kind === "turn"
225
+ ? turnLine(e.body)
226
+ : e.kind === "tool"
227
+ ? toolLine(e.body)
228
+ : typeof e.body.text === "string"
229
+ ? e.body.text
230
+ : JSON.stringify(e.body)}`;
231
+ const count = (n) => n.toLocaleString("en-US");
232
+ const seconds = (ms) => `${(ms / 1000).toFixed(1)} s`;
233
+ const dollars = (usd) => usd === null ? "unpriced" : `$${usd < 1 ? usd.toFixed(4) : usd.toFixed(2)}`;
234
+ function turnLine(t) {
235
+ const calls = t.toolCalls.length ? ` -> ${t.toolCalls.map((c) => c.name).join(", ")}` : "";
236
+ const failed = t.error ? ` FAILED ${t.error}` : "";
237
+ return `${t.model} ${seconds(t.durationMs)}, ${count(t.inputTokens)} in, ${count(t.outputTokens)} out, ${count(t.cacheReadTokens)} cached, ${dollars(t.costUsd)}${calls}${failed}`;
238
+ }
239
+ function toolLine(t) {
240
+ return `${t.name} ${seconds(t.durationMs)}${t.error ? " FAILED" : ""}${t.input ? ` ${t.input.slice(0, 100)}` : ""}`;
241
+ }
242
+ /** Spans a trace command reads a request: the API's most. */
243
+ const TRACE_PAGE = 500;
244
+ /** The span list of an OTLP page, as the API writes it: one resource, one scope. */
245
+ function otlpSpans(otlp) {
246
+ const scope = otlp.resourceSpans[0]
247
+ ?.scopeSpans?.[0];
248
+ if (!scope)
249
+ return [];
250
+ scope.spans ??= [];
251
+ return scope.spans;
252
+ }
253
+ /** Where --export sends OTLP: --endpoint, else the OpenTelemetry SDK's own
254
+ * variables; a base URL gets /v1/traces, as an OTLP/HTTP exporter adds it. */
255
+ export function otlpTarget(endpoint, env, headers) {
256
+ const full = endpoint ?? env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT;
257
+ const base = endpoint ? undefined : env.OTEL_EXPORTER_OTLP_ENDPOINT;
258
+ const url = full
259
+ ? endpoint && !/\/v1\/traces\/?$/.test(endpoint)
260
+ ? `${endpoint.replace(/\/+$/, "")}/v1/traces`
261
+ : full
262
+ : base
263
+ ? `${base.replace(/\/+$/, "")}/v1/traces`
264
+ : null;
265
+ if (!url)
266
+ return null;
267
+ const fromEnv = {};
268
+ for (const pair of (env.OTEL_EXPORTER_OTLP_TRACES_HEADERS ??
269
+ env.OTEL_EXPORTER_OTLP_HEADERS ??
270
+ "").split(",")) {
271
+ const at = pair.indexOf("=");
272
+ if (at > 0)
273
+ fromEnv[decodeURIComponent(pair.slice(0, at).trim())] = decodeURIComponent(pair.slice(at + 1).trim());
274
+ }
275
+ return { url, headers: { ...fromEnv, ...headers } };
276
+ }
194
277
  export async function agentsCommand(argv, env, out, client, kit) {
195
278
  const { parse, flag, has, need, pairs, table, usage, unknown } = kit;
196
279
  const [verb, ...rest] = argv;
@@ -337,6 +420,98 @@ export async function agentsCommand(argv, env, out, client, kit) {
337
420
  print(read.data.map(line).join("\n") || "No events yet.", read);
338
421
  return 0;
339
422
  }
423
+ case "trace": {
424
+ const args = parse(rest, ["otlp", "export"], ["endpoint", "header"]);
425
+ const id = need(args.positional[0], "a session's id");
426
+ if (has(args, "export")) {
427
+ const target = otlpTarget(flag(args, "endpoint"), env, args.flags.has("header") ? pairs(args, "header") : {});
428
+ if (!target)
429
+ throw usage("Give --endpoint, or set OTEL_EXPORTER_OTLP_ENDPOINT: where your collector takes OTLP/HTTP.");
430
+ // One export request a page: the collector joins them by trace id.
431
+ let spans = 0;
432
+ for (let after = 0; after !== null;) {
433
+ const { nextAfter, ...otlp } = await api.sessions.trace(id, {
434
+ format: "otlp",
435
+ after,
436
+ limit: TRACE_PAGE,
437
+ });
438
+ const sent = await fetch(target.url, {
439
+ method: "POST",
440
+ headers: { "content-type": "application/json", ...target.headers },
441
+ body: JSON.stringify(otlp),
442
+ });
443
+ if (!sent.ok) {
444
+ out.error(`${target.url} returned ${sent.status}: ${(await sent.text()).slice(0, 500)}`);
445
+ return 1;
446
+ }
447
+ spans += otlpSpans(otlp).length;
448
+ after = nextAfter;
449
+ }
450
+ print(`Sent ${spans} spans to ${target.url}.`, { sent: spans, url: target.url });
451
+ return 0;
452
+ }
453
+ if (has(args, "otlp")) {
454
+ // Every page's spans in one ExportTraceServiceRequest.
455
+ let whole;
456
+ for (let after = 0; after !== null;) {
457
+ const page = await api.sessions.trace(id, {
458
+ format: "otlp",
459
+ after,
460
+ limit: TRACE_PAGE,
461
+ });
462
+ if (whole)
463
+ otlpSpans(whole).push(...otlpSpans(page));
464
+ else
465
+ whole = page;
466
+ after = page.nextAfter;
467
+ }
468
+ const { nextAfter: _, ...otlp } = whole;
469
+ out.write(JSON.stringify(otlp));
470
+ return 0;
471
+ }
472
+ const trace = await api.sessions.trace(id, { limit: TRACE_PAGE });
473
+ for (let after = trace.nextAfter; after !== null;) {
474
+ const page = await api.sessions.trace(id, { after, limit: TRACE_PAGE });
475
+ trace.spans.push(...page.spans);
476
+ after = trace.nextAfter = page.nextAfter;
477
+ }
478
+ const t = trace.totals;
479
+ print([
480
+ `${count(t.turns)} turns, ${count(t.toolCalls)} tool calls, ${dollars(t.costUsd)}${t.unpricedTurns ? ` (${t.unpricedTurns} turns unpriced)` : ""}`,
481
+ `${count(t.inputTokens)} in, ${count(t.outputTokens)} out, ${count(t.cacheReadTokens)} cache read, ${count(t.cacheWriteTokens)} cache write; ${seconds(t.modelMs)} in the model, ${seconds(t.toolMs)} in tools`,
482
+ "",
483
+ trace.models.length
484
+ ? table([
485
+ ["MODEL", "TURNS", "IN", "OUT", "CACHE READ", "COST"],
486
+ ...trace.models.map((m) => [
487
+ m.model,
488
+ count(m.turns),
489
+ count(m.inputTokens),
490
+ count(m.outputTokens),
491
+ count(m.cacheReadTokens),
492
+ m.unpricedTurns === m.turns ? "unpriced" : dollars(m.costUsd),
493
+ ]),
494
+ ])
495
+ : "No turns yet.",
496
+ ...(trace.tools.length
497
+ ? [
498
+ "",
499
+ table([
500
+ ["TOOL", "CALLS", "FAILED", "TIME"],
501
+ ...trace.tools.map((k) => [
502
+ k.name,
503
+ count(k.calls),
504
+ count(k.failed),
505
+ seconds(k.durationMs),
506
+ ]),
507
+ ]),
508
+ ]
509
+ : []),
510
+ "",
511
+ ...trace.spans.map((x) => `${String(x.seq).padStart(4)} ${x.startedAt} ${x.kind.padEnd(4)} ${x.kind === "turn" ? turnLine(x) : toolLine(x)}`),
512
+ ].join("\n"), trace);
513
+ return 0;
514
+ }
340
515
  case "sessions": {
341
516
  if (rest[0] === "delete" || rest[0] === "rm") {
342
517
  const target = need(rest[1], "a session's id");
@@ -406,11 +581,50 @@ export async function agentsCommand(argv, env, out, client, kit) {
406
581
  print(`${answered.id} answered; ${answered.sessions.filter((x) => x.state === "answered").length} session(s) woken.`, answered);
407
582
  return 0;
408
583
  }
584
+ case "approve":
585
+ case "deny": {
586
+ const args = parse(rest, [], verb === "deny" ? ["message"] : []);
587
+ const id = need(args.positional[0], "an ask's id");
588
+ const message = verb === "deny" ? flag(args, "message") : undefined;
589
+ const answered = verb === "approve" ? await api.asks.approve(id) : await api.asks.deny(id, message);
590
+ print(`${answered.id}: ${answered.toolCall?.tool ?? "the call"} ${verb === "approve" ? "allowed" : "denied"}.`, answered);
591
+ return 0;
592
+ }
409
593
  case "stop": {
410
594
  const session = await (await api.session(need(rest[0], "a session's id"))).stop();
411
595
  print(`${session.id} ${session.state}.`, session);
412
596
  return 0;
413
597
  }
598
+ case "switch": {
599
+ const platform = need(rest[0], "the platform to switch from: anthropic");
600
+ if (platform !== "anthropic")
601
+ throw usage(`runtime agents switch takes anthropic (Claude Managed Agents); ${platform} is not available yet.`);
602
+ const { baseURL } = await api.anthropic();
603
+ const modelKey = (await secrets(transport).list()).find((s) => s.name === "ANTHROPIC_API_KEY");
604
+ const value = {
605
+ platform,
606
+ baseURL,
607
+ modelKey: modelKey ? { name: modelKey.name, hosts: modelKey.hosts } : null,
608
+ docs: SWITCH_DOCS,
609
+ };
610
+ print([
611
+ "Claude Managed Agents code runs on Runtime with its client's base URL and key changed:",
612
+ "",
613
+ ` new Anthropic({ baseURL: "${baseURL}", apiKey: process.env.RUNTIME_API_KEY })`,
614
+ ` anthropic.Anthropic(base_url="${baseURL}", api_key=os.environ["RUNTIME_API_KEY"])`,
615
+ "",
616
+ modelKey
617
+ ? `Model key: ANTHROPIC_API_KEY is set (${modelKey.hosts.join(", ")}); sessions use it.`
618
+ : [
619
+ "Model key: ANTHROPIC_API_KEY is not set. Agents run on your own Anthropic key;",
620
+ "store it once, and the sandbox never sees it:",
621
+ ' printf %s "$ANTHROPIC_API_KEY" | runtime secrets set ANTHROPIC_API_KEY --host api.anthropic.com',
622
+ ].join("\n"),
623
+ `What maps and what does not: ${SWITCH_DOCS}`,
624
+ "",
625
+ ].join("\n"), value);
626
+ return 0;
627
+ }
414
628
  case "triggers": {
415
629
  const [sub, ...more] = rest;
416
630
  if (sub === "add") {
@@ -546,10 +760,13 @@ export async function agentsCommand(argv, env, out, client, kit) {
546
760
  "start",
547
761
  "send",
548
762
  "events",
763
+ "trace",
549
764
  "sessions",
550
765
  "stop",
551
766
  "asks",
552
767
  "answer",
768
+ "approve",
769
+ "deny",
553
770
  "triggers",
554
771
  "memory",
555
772
  ]);
package/dist/ci-cli.d.ts CHANGED
@@ -1,10 +1,16 @@
1
1
  import type { CliKit } from "./cli.js";
2
2
  import type { Runtime } from "./client.js";
3
+ import { type CiAnnotation } from "./products/ci.js";
3
4
  type Out = {
4
5
  json: boolean;
5
6
  write: (text: string) => void;
6
7
  error: (text: string) => void;
7
8
  };
8
- export declare const CI_HELP = "runtime ci <command>\n\n CI/CD checks each push and pull request of a connected GitHub repository in\n sandboxes, as the steps its config file names. A fork's pull request runs\n nothing; a writer can open it again from a branch of the repository. In a\n private beta: outside it, each command says how to ask to join.\n\n import [dir] [--write] [--force] This folder's GitHub Actions workflows and CircleCI\n config as a runtime.yml: printed, or written with\n --write; what isn't carried over is noted at its top.\n Needs no key and sends nothing\n connect <owner/name> [--branch main] [--config runtime.yml] [--installation <id>]\n [--trust <app-slug>[bot]]... [--name <name>]\n Connect a repository; prints its id. Takes a full key.\n --trust runs that App's pushes as its own from the start\n repos [ls] [--all] Connected repositories, with the Apps each trusts;\n --all: disconnected ones too\n repos trust <repoId | owner/name> <app-slug>[bot]...\n Run that App's pushes as the repository's own code,\n keeping the Apps it trusts already\n repos untrust <repoId | owner/name> <app-slug>[bot]...\n Stop trusting those Apps, keeping the rest\n repos undo <repoId | owner/name> on|off When main's check fails, find the first commit that\n fails it and open a pull request reverting it, which\n lands once its check passes. Off until turned on;\n takes an owner's or admin's full key\n disconnect <repoId | owner/name> Stop checking it; its checks still going are cancelled\n checks [--repository <repoId>] [--branch <name>] [--commit <sha>] [--pr <number>]\n [--state <state>]... [--limit 20] Checks, newest first, with their jobs by state (or ls)\n check <checkId> One check and its jobs in plan order (or get)\n cancel <checkId> Cancel a queued or running check: its jobs end,\n its machines are let go, GitHub is told\n rerun <checkId> Run a check again: a new check of its commit, a\n pull request's as it would land now\n logs <jobId> A job's output, its last 256 KiB, and its sandboxes\n tests <repoId> [--quarantined] Its test files: time, recent outcomes, quarantine\n flakes [--repository <repoId>] [--all] Flaky tests: each quarantined (or still gating), its\n owner and 48-hour deadline; --all: ended ones too\n flake <flakeId> One flaky test: its proof, owner, and recent runs\n flake prove <flakeId> Its 100 proof runs again at main's next commit\n flake hand <flakeId> <login | org/team> Hand it to someone else\n flake delete <flakeId> --reason <why> Say why its test is deleted; it ends once main\n no longer holds the file\n releases [--repository <repoId>] [--commit <sha>] [--limit 50]\n A release's steps as they were taken, oldest\n first: migrations, deploys, servers, waits\n\n A failed job's sandbox may be kept paused: `runtime sandboxes wake <id>`, then\n `runtime sandboxes shell <id>` to look around where it failed. A key reads the\n checks of repositories its own agent connected; an account-wide key reads and\n cancels every check of the account (switch one at withruntime.com/account/keys).\n\nExamples\n runtime ci import --write\n runtime ci connect acme/web --config .runtime/ci.yml\n runtime ci repos trust acme/web acme-bot[bot]\n runtime ci repos undo acme/web on\n runtime ci checks --commit $(git rev-parse HEAD)\n runtime ci cancel <checkId>\n runtime ci logs <jobId>\n";
9
+ export declare const CI_HELP = "runtime ci <command>\n\n CI/CD checks each push and pull request of a connected GitHub repository in\n sandboxes, as the steps its config file names. A fork's pull request runs\n nothing; a writer can open it again from a branch of the repository. In a\n private beta: outside it, each command says how to ask to join.\n\n import [dir] [--write] [--force] This folder's GitHub Actions workflows and CircleCI\n config as a runtime.yml: printed, or written with\n --write; what isn't carried over is noted at its top.\n Needs no key and sends nothing\n connect <owner/name> [--branch main] [--config runtime.yml] [--installation <id>]\n [--trust <app-slug>[bot]]... [--name <name>]\n Connect a repository; prints its id. Takes a full key.\n --config cloudbuild.yaml or buildspec.yml runs a Google\n Cloud Build or AWS CodeBuild config as it is.\n --trust runs that App's pushes as its own from the start\n repos [ls] [--all] Connected repositories, with the Apps each trusts;\n --all: disconnected ones too\n repos trust <repoId | owner/name> <app-slug>[bot]...\n Run that App's pushes as the repository's own code,\n keeping the Apps it trusts already\n repos untrust <repoId | owner/name> <app-slug>[bot]...\n Stop trusting those Apps, keeping the rest\n repos undo <repoId | owner/name> on|off When main's check fails, find the first commit that\n fails it and open a pull request reverting it, which\n lands once its check passes. Off until turned on;\n takes an owner's or admin's full key\n disconnect <repoId | owner/name> Stop checking it; its checks still going are cancelled\n checks [--repository <repoId>] [--branch <name>] [--commit <sha>] [--pr <number>]\n [--state <state>]... [--limit 20] Checks, newest first, with their jobs by state (or ls)\n check <checkId> One check and its jobs in plan order (or get)\n cancel <checkId> Cancel a queued or running check: its jobs end,\n its machines are let go, GitHub is told\n rerun <checkId> Run a check again: a new check of its commit, a\n pull request's as it would land now\n logs <jobId> A job's output, its last 256 KiB, and its sandboxes\n tests <repoId> [--quarantined] Its test files: time, recent outcomes, quarantine\n flakes [--repository <repoId>] [--all] Flaky tests: each quarantined (or still gating), its\n owner and 48-hour deadline; --all: ended ones too\n flake <flakeId> One flaky test: its proof, owner, and recent runs\n flake prove <flakeId> Its 100 proof runs again at main's next commit\n flake hand <flakeId> <login | org/team> Hand it to someone else\n flake delete <flakeId> --reason <why> Say why its test is deleted; it ends once main\n no longer holds the file\n releases [--repository <repoId>] [--commit <sha>] [--limit 50]\n A release's steps as they were taken, oldest\n first: migrations, deploys, servers, waits\n\n A failed job's sandbox may be kept paused: `runtime sandboxes wake <id>`, then\n `runtime sandboxes shell <id>` to look around where it failed. A key reads the\n checks of repositories its own agent connected; an account-wide key reads and\n cancels every check of the account (switch one at withruntime.com/account/keys).\n\nExamples\n runtime ci import --write\n runtime ci connect acme/web --config .runtime/ci.yml\n runtime ci repos trust acme/web acme-bot[bot]\n runtime ci repos undo acme/web on\n runtime ci checks --commit $(git rev-parse HEAD)\n runtime ci cancel <checkId>\n runtime ci logs <jobId>\n";
9
10
  export declare function ciCommand(argv: string[], out: Out, client: () => Promise<Runtime>, kit: CliKit): Promise<number>;
11
+ /** An agent step's verdict in words: each finding with its place and fix,
12
+ * then the notes, then who judged. */
13
+ /** A job's annotations as `path:line:col: level: title: message`, each
14
+ * message's first line, the way compilers print them. */
15
+ export declare function annotated(lines: CiAnnotation[]): string;
10
16
  export {};
package/dist/ci-cli.js CHANGED
@@ -17,6 +17,8 @@ export const CI_HELP = `runtime ci <command>
17
17
  connect <owner/name> [--branch main] [--config runtime.yml] [--installation <id>]
18
18
  [--trust <app-slug>[bot]]... [--name <name>]
19
19
  Connect a repository; prints its id. Takes a full key.
20
+ --config cloudbuild.yaml or buildspec.yml runs a Google
21
+ Cloud Build or AWS CodeBuild config as it is.
20
22
  --trust runs that App's pushes as its own from the start
21
23
  repos [ls] [--all] Connected repositories, with the Apps each trusts;
22
24
  --all: disconnected ones too
@@ -104,8 +106,13 @@ async function importCommand(argv, out, kit) {
104
106
  const circle = join(root, ".circleci", "config.yml");
105
107
  if (existsSync(circle))
106
108
  files.push({ path: ".circleci/config.yml", text: readFileSync(circle, "utf8") });
107
- if (!files.length)
109
+ if (!files.length) {
110
+ // Cloud Build and CodeBuild configs run as they are: nothing to import.
111
+ const vendor = ["cloudbuild.yaml", "cloudbuild.yml", "buildspec.yml", "buildspec.yaml"].find((name) => existsSync(join(root, name)));
112
+ if (vendor)
113
+ throw kit.usage(`${vendor} needs no import: CI/CD runs it as it is. Connect with ${me} ci connect <owner/name> --config ${vendor}, or add "- ${vendor.startsWith("cloudbuild") ? "cloudbuild" : "buildspec"}: ${vendor}" to runtime.yml's steps.`);
108
114
  throw kit.usage(`${root} has neither .github/workflows/*.yml nor .circleci/config.yml to import.`);
115
+ }
109
116
  const made = importCi(files);
110
117
  if (!made.yaml) {
111
118
  out.error(made.notes.join("\n"));
@@ -332,6 +339,9 @@ export async function ciCommand(argv, out, client, kit) {
332
339
  out.write(job.log.endsWith("\n") || !job.log ? job.log : `${job.log}\n`);
333
340
  if (job.review)
334
341
  out.write(reviewed(job.review));
342
+ // An API before annotations sends none.
343
+ if (job.annotations?.length)
344
+ out.write(annotated(job.annotations));
335
345
  out.error(`[${job.name}${job.parts > 1 ? ` ${job.part}/${job.parts}` : ""} ${job.state}${job.exitCode === null ? "" : `, exit code ${job.exitCode}`}${job.reason ? `, ${job.reason}` : ""}]`);
336
346
  if (job.state === "failed" && job.sandboxIds.length)
337
347
  out.error(`Its sandbox may be kept paused, to look into: ${me} sandboxes wake ${job.sandboxIds[0]}, then ${me} sandboxes shell ${job.sandboxIds[0]}`);
@@ -462,6 +472,20 @@ export async function ciCommand(argv, out, client, kit) {
462
472
  }
463
473
  /** An agent step's verdict in words: each finding with its place and fix,
464
474
  * then the notes, then who judged. */
475
+ /** A job's annotations as `path:line:col: level: title: message`, each
476
+ * message's first line, the way compilers print them. */
477
+ export function annotated(lines) {
478
+ const failing = lines.filter((a) => a.level === "failure").length;
479
+ return [
480
+ `\n${lines.length} line${lines.length === 1 ? "" : "s"} of the repository's files${failing ? `, ${failing} failing` : ""}:`,
481
+ ...lines.map((a) => {
482
+ const at = `${a.path}:${a.startLine}${a.startColumn ? `:${a.startColumn}` : ""}`;
483
+ const first = a.message.split("\n")[0];
484
+ return ` ${at}: ${a.level}: ${a.title ? `${a.title}: ` : ""}${first}`;
485
+ }),
486
+ "",
487
+ ].join("\n");
488
+ }
465
489
  function reviewed(r) {
466
490
  const at = (f) => (f.line > 0 ? `${f.file}:${f.line}` : f.file);
467
491
  return [
package/dist/cli-words.js CHANGED
@@ -21,6 +21,7 @@ const OPTIONS = {
21
21
  onLeaseEnd: { flag: "--on-timeout" },
22
22
  idlePauseSeconds: { flag: "--idle-pause" },
23
23
  autoWake: { flag: "--no-auto-wake / --auto-wake" },
24
+ user: { flag: "--user" },
24
25
  persistent: { flag: "--persistent" },
25
26
  funding: { flag: "--trial / --paid" },
26
27
  image: { flag: "--image" },
package/dist/cli.d.ts CHANGED
@@ -18,7 +18,7 @@ type Args = {
18
18
  rest: string[] | undefined;
19
19
  };
20
20
  /** What the commands in cli-extras.ts use of this file. */
21
- declare const kit: {
21
+ export declare const kit: {
22
22
  parse: (argv: string[], booleans: readonly string[], values: readonly string[]) => Args;
23
23
  flag: (args: Args, name: string) => string | undefined;
24
24
  has: (args: Args, name: string) => boolean;
package/dist/cli.js CHANGED
@@ -168,6 +168,8 @@ const SANDBOX_HELP = `runtime sandboxes <command>
168
168
  [--image <name:tag|imageId> | --snapshot <snapshotId>] [--volume <volumeId>:/data[:snapshot]]...
169
169
  [--spread-from <id>]... [--secret NAME]... [--no-secrets]
170
170
  [--idle-pause <seconds>] [--no-auto-wake] [--persistent] [--get-or-create]
171
+ [--user root|sandbox] --user root: its commands, processes and
172
+ shells run as root unless one says otherwise
171
173
  Create one; prints its id
172
174
  ls [--all] [--label k=v]... [--state running] List (live ones unless --all)
173
175
  get <id> One sandbox, in full
@@ -202,7 +204,7 @@ const SANDBOX_HELP = `runtime sandboxes <command>
202
204
  resize <id> --disk 20480 Grow a running sandbox's disk live, programs running
203
205
  extend <id> <seconds> Move a time limit on (one with none needs nothing)
204
206
  update <id> [--name n] [--label k=v]... [--env K[=V]]... [--unset-env K]... [--idle-pause <seconds>] [--auto-wake on|off]
205
- [--persistent on|off] [--max-total-cost <usd>|none]
207
+ [--persistent on|off] [--max-total-cost <usd>|none] [--user root|sandbox]
206
208
  [--timeout <60-86400 from now>|0] [--on-timeout pause|stop|delete]
207
209
  Change its settings; persistent keeps it running until stopped;
208
210
  --env K alone sends K's value from your own environment,
@@ -390,7 +392,7 @@ const envPairs = (args, from) => Object.fromEntries((args.flags.get("env") ?? []
390
392
  return [pair, value];
391
393
  }));
392
394
  /** What the commands in cli-extras.ts use of this file. */
393
- const kit = {
395
+ export const kit = {
394
396
  parse: (argv, booleans, values) => parse(argv, booleans, values),
395
397
  flag,
396
398
  has,
@@ -651,6 +653,7 @@ function describe(info) {
651
653
  ...(info.endedAt ? [["ended", info.endedAt]] : []),
652
654
  ...(info.stopReason ? [["stop reason", info.stopReason]] : []),
653
655
  ["auto wake", info.autoWake === false ? "off" : "on"],
656
+ ["runs as", info.user === "root" ? "root" : "sandbox user"],
654
657
  [
655
658
  "idle pause",
656
659
  info.idlePauseSeconds
@@ -2218,6 +2221,7 @@ async function sandbox(argv, env, out) {
2218
2221
  "max-total-cost",
2219
2222
  "timeout",
2220
2223
  "on-timeout",
2224
+ "user",
2221
2225
  ]);
2222
2226
  const sbx = await get(args.positional[0]);
2223
2227
  const onOff = (name) => {
@@ -2247,6 +2251,7 @@ async function sandbox(argv, env, out) {
2247
2251
  : {}),
2248
2252
  ...(onOff("auto-wake") === undefined ? {} : { autoWake: onOff("auto-wake") }),
2249
2253
  ...(onOff("persistent") === undefined ? {} : { persistent: onOff("persistent") }),
2254
+ ...(flag(args, "user") ? { user: oneOf(args, "user", ["sandbox", "root"]) } : {}),
2250
2255
  ...(cost === undefined
2251
2256
  ? {}
2252
2257
  : {
@@ -2258,7 +2263,7 @@ async function sandbox(argv, env, out) {
2258
2263
  ...(onTimeout === undefined ? {} : { onTimeout }),
2259
2264
  };
2260
2265
  if (!Object.keys(settings).length)
2261
- throw usage("Say what to change: --name, --label, --env, --unset-env, --idle-pause, --auto-wake, --persistent, --max-total-cost, --timeout or --on-timeout.");
2266
+ throw usage("Say what to change: --name, --label, --env, --unset-env, --idle-pause, --auto-wake, --persistent, --user, --max-total-cost, --timeout or --on-timeout.");
2262
2267
  await sbx.update(settings);
2263
2268
  print(describe(sbx.info), sbx.info);
2264
2269
  return 0;
@@ -3993,6 +3998,15 @@ const JOB_HELP = `runtime jobs <command>
3993
3998
  [--alert-webhook <url> [--alert-secret NAME]] [--alert-email] [--alert-after <runs>] [--no-alert]
3994
3999
  [-- <command...>] Change it in place: the next run uses it; history stays.
3995
4000
  --secret and --volume replace the whole list
4001
+ deploy [<dir>] [--name <project>] [--dry-run]
4002
+ Run Trigger.dev tasks and Inngest functions written
4003
+ against withruntime/trigger or withruntime/inngest as
4004
+ jobs: crons on their schedule, the rest on demand
4005
+ import <file>... [--parameter NAME=VALUE]... [--cron ..] [--dry-run]
4006
+ Move jobs from Google Cloud Run (job YAML and its Cloud
4007
+ Scheduler job) or AWS Batch (job definition and its
4008
+ EventBridge schedule): same image, command, size and
4009
+ schedule. \`jobs import help\` says more
3996
4010
  ls Your jobs: state, schedule and next run
3997
4011
  get <id> One job, in full
3998
4012
  runs <id> [--all] Its newest 100 runs (--all: every one, oldest first)
@@ -4013,6 +4027,8 @@ Examples
4013
4027
  runtime jobs trigger <jobId> && runtime jobs logs <jobId> -f
4014
4028
  runtime jobs reschedule <jobId> --cron "30 4 * * 1-5" --timezone Europe/Berlin
4015
4029
  runtime jobs update <jobId> --image hub:latest --alert-webhook https://example.com/hook --alert-after 3
4030
+ runtime jobs import job.yaml scheduler.yaml
4031
+ runtime jobs import template.yaml --parameter AWS::Region=us-east-1 --dry-run
4016
4032
  `;
4017
4033
  /** The `--alert-*` flags of create and update, as a job's alert; undefined
4018
4034
  * when none is given. The secret is a jobs secret, by name. */
@@ -4079,6 +4095,10 @@ async function jobCommand(argv, env, out) {
4079
4095
  print(named(JOB_HELP), { usage: named(JOB_HELP) });
4080
4096
  return 0;
4081
4097
  }
4098
+ if (verb === "import")
4099
+ return (await import("./jobs-import.js")).jobsImportCommand(rest, out, () => client(env), kit);
4100
+ if (verb === "deploy")
4101
+ return (await import("./jobs-deploy.js")).jobsDeployCommand(rest, out, () => client(env), kit);
4082
4102
  const runtime = await client(env);
4083
4103
  const api = runtime.jobs;
4084
4104
  switch (verb) {
@@ -4708,6 +4728,7 @@ const CREATE_VALUES = [
4708
4728
  "secret",
4709
4729
  "volume",
4710
4730
  "env",
4731
+ "user",
4711
4732
  ];
4712
4733
  /** Dollars from the command line as integer microdollars: 25, 2.50 or 0.000001. */
4713
4734
  function usdMicros(args, name) {
@@ -4804,6 +4825,7 @@ function createInput(args, env) {
4804
4825
  ? { idlePauseSeconds: integer(args, "idle-pause") }
4805
4826
  : {}),
4806
4827
  ...(has(args, "no-auto-wake") ? { autoWake: false } : {}),
4828
+ ...(flag(args, "user") ? { user: oneOf(args, "user", ["sandbox", "root"]) } : {}),
4807
4829
  ...(has(args, "persistent") ? { persistent: true } : {}),
4808
4830
  ...(has(args, "get-or-create") ? { getOrCreate: true } : {}),
4809
4831
  ...(has(args, "trial")
package/dist/errors.d.ts CHANGED
@@ -15,7 +15,7 @@ export declare const DELIBERATE: ReadonlySet<string>;
15
15
  export declare const NOTHING_RAN: ReadonlySet<string>;
16
16
  /** Refusals of a create that clear when a sandbox stops or pauses, or a host
17
17
  * frees room: an account without credit's four at once and its total, an
18
- * email domain's, the account's quota and the region's capacity. `sandboxes.create` waits them out, retrying
18
+ * email domain's, the account's quota, its share of the region's servers and the region's capacity. `sandboxes.create` waits them out, retrying
19
19
  * with the same key and input, for up to `waitForCapacityMs`. */
20
20
  export declare const WAITS_FOR_ROOM: ReadonlySet<string>;
21
21
  export declare class RuntimeError extends Error {
package/dist/errors.js CHANGED
@@ -36,7 +36,7 @@ export const NOTHING_RAN = new Set(["guest_busy", "busy", "rate_limited"]);
36
36
  const PASSING = new Set(["no_capacity", "no_credit_running_limit", "no_credit_total_limit"]);
37
37
  /** Refusals of a create that clear when a sandbox stops or pauses, or a host
38
38
  * frees room: an account without credit's four at once and its total, an
39
- * email domain's, the account's quota and the region's capacity. `sandboxes.create` waits them out, retrying
39
+ * email domain's, the account's quota, its share of the region's servers and the region's capacity. `sandboxes.create` waits them out, retrying
40
40
  * with the same key and input, for up to `waitForCapacityMs`. */
41
41
  export const WAITS_FOR_ROOM = new Set([
42
42
  "no_credit_running_limit",
@@ -44,6 +44,9 @@ export const WAITS_FOR_ROOM = new Set([
44
44
  "no_credit_domain_limit",
45
45
  "no_credit_capacity_full",
46
46
  "quota_exceeded",
47
+ // The account holds its share of every server that could run it: clears
48
+ // as its own sandboxes end.
49
+ "account_share_full",
47
50
  "no_capacity",
48
51
  // A volume whose last sandbox is stopping: free once the stop lets go of
49
52
  // its disk, up to about a minute (measured 50 to 60 s, 6 October 2026).
@@ -0,0 +1,10 @@
1
+ /** `withruntime/functions`: Functions alone. An HTTP handler on copies that
2
+ * start when calls come and sleep a second after the last. In a private beta.
3
+ *
4
+ * import { functions } from "withruntime/functions";
5
+ * const client = functions(); // RUNTIME_API_KEY, or this machine's saved connection
6
+ */
7
+ import { Runtime, type RuntimeOptions } from "../client.js";
8
+ export type * from "../products/functions.js";
9
+ /** `runtime.functions` of a client made with `options`. */
10
+ export declare function functions(options?: RuntimeOptions): Runtime["functions"];
@@ -0,0 +1,11 @@
1
+ /** `withruntime/functions`: Functions alone. An HTTP handler on copies that
2
+ * start when calls come and sleep a second after the last. In a private beta.
3
+ *
4
+ * import { functions } from "withruntime/functions";
5
+ * const client = functions(); // RUNTIME_API_KEY, or this machine's saved connection
6
+ */
7
+ import { Runtime } from "../client.js";
8
+ /** `runtime.functions` of a client made with `options`. */
9
+ export function functions(options) {
10
+ return new Runtime(options).functions;
11
+ }
package/dist/index.d.ts CHANGED
@@ -25,7 +25,7 @@ export type { FileEvent, FileEventType, WatchHandle, WatchNotice, WatchOptions,
25
25
  export type { Mount, MountBucket } from "./products/mounts.js";
26
26
  export type { TailscaleJoin, TailscaleJoined, TailscaleNode, TailscaleStatus, } from "./products/tailscale.js";
27
27
  export type { Volume, VolumeBackup, VolumeBackupKeep, VolumeBackupSchedule, CreateVolume, VolumeAttachment, } from "./products/volumes.js";
28
- export type { CreateJob, Job, JobAlert, JobAlertDelivery, JobCompute, JobDefinition, JobLogs, JobRun, JobRunState, JobSchedule, UpdateJob, } from "./products/jobs.js";
28
+ export type { CreateJob, Job, JobAlert, JobAlertDelivery, JobCompute, JobDefinition, JobImportJob, JobImportPlan, JobImportRequest, JobImportSchedule, JobLogs, JobRun, JobRunState, JobSchedule, UpdateJob, } from "./products/jobs.js";
29
29
  export type { CheckedDomain, DnsRecord, Domain, EgressAddress, TcpPort, Tunnel as PrivateTunnel, TunnelPeer, TunnelPeerCreated, SetUpstreamProxy, UpstreamProxy, } from "./products/network-products.js";
30
30
  export type { PrivateNetwork } from "./products/private-network.js";
31
31
  export type { SignedRequests } from "./products/signed-requests.js";
@@ -78,10 +78,10 @@ export { openWalletAccount, claimWalletAccount, rekeyWalletAccount, type OpenedW
78
78
  export type { Topup } from "./products/billing.js";
79
79
  export type { NewKey, LimitedKey, LimitedKeyAction, MadeKey, ListedKey, KeyUsage, } from "./products/api-keys.js";
80
80
  export type { SsoConnection, SsoStatus } from "./products/sso.js";
81
- export type { Agent, AgentAsk, AgentAskState, AgentDefinition, AgentEvent, AgentHeldCall, AgentMemoryEntry, AgentMemoryFile, AgentMemoryHit, AgentMemoryPage, AgentMemoryUsage, AgentMemoryWritten, AgentSession, AgentSessionHandle, AgentSessionState, AgentTemplate, AgentTemplateKey, AgentTrigger, AgentTriggerCall, AgentTriggerCallOutcome, AgentTriggerKind, AgentTriggerRules, AgentUse, AnswerAgentAsk, CreateAgent, CreateAgentTrigger, ListAgentAsks, StartAgentSession, } from "./products/agents.js";
81
+ export type { Agent, AgentAsk, AgentAskState, AgentDefinition, AgentEvent, AgentHeldCall, AgentMemoryEntry, AgentMemoryFile, AgentMemoryHit, AgentMemoryPage, AgentMemoryUsage, AgentMemoryWritten, AgentPermissionPolicy, AgentPermissions, AgentSession, AgentSessionHandle, AgentSessionState, AgentTemplate, AgentTemplateKey, AgentAskToolCall, AgentTokens, AgentToolCall, AgentTrace, AgentTraceOtlp, AgentTracePage, AgentTrigger, AgentTriggerCall, AgentTriggerCallOutcome, AgentTriggerKind, AgentTriggerRules, AgentTurn, AgentUse, AnswerAgentAsk, CreateAgent, CreateAgentTrigger, ListAgentAsks, StartAgentSession, } from "./products/agents.js";
82
82
  export { AGENT_TEMPLATES, AGENT_USES } from "./products/agents.js";
83
83
  export type { AgentsDeployChange, AgentsDeployOptions, AgentsDeployResult, AgentsFile, AgentsFileAgent, AgentsFileTrigger, AgentsSource, } from "./agents-deploy.js";
84
84
  export type { Container, ContainerState, CreateContainer, UpdateContainer, } from "./products/containers.js";
85
85
  export type { Browser, BrowserConnectOptions, BrowserInfo, BrowserScreenshot, BrowserScreenshotResult, CreateBrowser, UpdateBrowser, } from "./products/browsers.js";
86
86
  export type { CreateDesktop, Desktop, DesktopAct, DesktopState, UpdateDesktop, } from "./products/desktops.js";
87
- export type { CiFlake, CiFlakeDetail, CiReleaseStep, CiRepository, CiTestResult, ConnectCiRepository, ListCiFlakes, ListCiReleaseSteps, ListCiRepositories, UpdateCiFlake, } from "./products/ci.js";
87
+ export type { CiAnnotation, CiFlake, CiFlakeDetail, CiReleaseStep, CiRepository, CiTestResult, ConnectCiRepository, ListCiFlakes, ListCiReleaseSteps, ListCiRepositories, UpdateCiFlake, } from "./products/ci.js";