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/agents-deploy.js
CHANGED
|
@@ -31,13 +31,19 @@ const DEFINITION_FIELDS = [
|
|
|
31
31
|
"maxSessionDollars",
|
|
32
32
|
"maxDayDollars",
|
|
33
33
|
"memory",
|
|
34
|
+
"model",
|
|
35
|
+
"sessionOverrides",
|
|
36
|
+
"maxChildren",
|
|
37
|
+
"advisor",
|
|
34
38
|
];
|
|
35
39
|
const FILE_FIELDS = ["template", "use", "instructionsFile", "triggers", ...DEFINITION_FIELDS];
|
|
36
40
|
const TRIGGER_KINDS = ["slack", "github", "schedule", "webhook"];
|
|
37
|
-
const RESERVED = new Set(["sessions", "triggers", "approvals", "templates"]);
|
|
41
|
+
const RESERVED = new Set(["sessions", "triggers", "approvals", "templates", "asks", "workflows"]);
|
|
38
42
|
const NAME = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/;
|
|
39
43
|
const SHELL_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
40
44
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
45
|
+
const MODEL = /^[A-Za-z0-9][A-Za-z0-9._:/@-]{0,127}$/;
|
|
46
|
+
const VCPUS = [1, 2, 4, 8, 16];
|
|
41
47
|
const bytes = (text) => new TextEncoder().encode(text).length;
|
|
42
48
|
/** The file's agents, checked as the API checks them, with every mistake
|
|
43
49
|
* named by file, agent and field (and line, when the source knows it).
|
|
@@ -322,9 +328,64 @@ function checkAgent(name, entry, source, say) {
|
|
|
322
328
|
else
|
|
323
329
|
def.memory = { scope: v.scope };
|
|
324
330
|
}
|
|
331
|
+
if (entry.model !== undefined) {
|
|
332
|
+
if (typeof entry.model !== "string" || !MODEL.test(entry.model))
|
|
333
|
+
note(at("model"), "takes a model as its provider names it, such as claude-opus-5-5.");
|
|
334
|
+
else
|
|
335
|
+
def.model = entry.model;
|
|
336
|
+
}
|
|
337
|
+
if (entry.sessionOverrides !== undefined) {
|
|
338
|
+
const v = entry.sessionOverrides;
|
|
339
|
+
const keys = ["models", "instructions", "maxVcpu", "maxMemoryMiB", "maxSessionDollars"];
|
|
340
|
+
if (!isObject(v) || Object.keys(v).some((k) => !keys.includes(k)))
|
|
341
|
+
note(at("sessionOverrides"), `takes { ${keys.join(", ")} }.`);
|
|
342
|
+
else {
|
|
343
|
+
if (v.models !== undefined &&
|
|
344
|
+
(!Array.isArray(v.models) ||
|
|
345
|
+
v.models.length > 32 ||
|
|
346
|
+
v.models.some((m) => typeof m !== "string" || !MODEL.test(m))))
|
|
347
|
+
note(at("sessionOverrides", "models"), "takes a list of at most 32 models.");
|
|
348
|
+
if (v.instructions !== undefined &&
|
|
349
|
+
!["append", "replace", "none"].includes(v.instructions))
|
|
350
|
+
note(at("sessionOverrides", "instructions"), "takes append, replace or none.");
|
|
351
|
+
if (v.maxVcpu !== undefined && !VCPUS.includes(v.maxVcpu))
|
|
352
|
+
note(at("sessionOverrides", "maxVcpu"), "takes 1, 2, 4, 8 or 16.");
|
|
353
|
+
const mib = v.maxMemoryMiB;
|
|
354
|
+
if (mib !== undefined &&
|
|
355
|
+
(typeof mib !== "number" || mib % 256 !== 0 || mib < 512 || mib > 65536))
|
|
356
|
+
note(at("sessionOverrides", "maxMemoryMiB"), "takes 512 to 65536, a multiple of 256.");
|
|
357
|
+
const most = v.maxSessionDollars;
|
|
358
|
+
if (most !== undefined &&
|
|
359
|
+
(typeof most !== "number" || !Number.isFinite(most) || most < 0.01 || most > 10000))
|
|
360
|
+
note(at("sessionOverrides", "maxSessionDollars"), "takes dollars from 0.01 to 10000.");
|
|
361
|
+
def.sessionOverrides = v;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
325
364
|
integer("idlePauseSeconds", 10, 86400);
|
|
326
365
|
integer("maxSessionSeconds", 60, 604800);
|
|
327
366
|
integer("maxConcurrent", 1, 1000);
|
|
367
|
+
integer("maxChildren", 1, 1000);
|
|
368
|
+
if (entry.advisor !== undefined) {
|
|
369
|
+
const v = entry.advisor;
|
|
370
|
+
const fields = ["model", "provider", "secret", "baseUrl", "maxCalls", "instructions"];
|
|
371
|
+
if (!isObject(v) ||
|
|
372
|
+
Object.keys(v).some((k) => !fields.includes(k)) ||
|
|
373
|
+
typeof v.model !== "string" ||
|
|
374
|
+
!/^[A-Za-z0-9][A-Za-z0-9._:/@-]{0,127}$/.test(v.model) ||
|
|
375
|
+
(v.provider !== undefined &&
|
|
376
|
+
!["anthropic", "openai", "google", "openrouter", "openai-compatible"].includes(v.provider)) ||
|
|
377
|
+
(v.secret !== undefined && (typeof v.secret !== "string" || !SHELL_NAME.test(v.secret))) ||
|
|
378
|
+
(v.baseUrl !== undefined &&
|
|
379
|
+
(typeof v.baseUrl !== "string" || !/^https:\/\/\S+$/.test(v.baseUrl))) ||
|
|
380
|
+
(v.maxCalls !== undefined &&
|
|
381
|
+
(!Number.isInteger(v.maxCalls) ||
|
|
382
|
+
v.maxCalls < 1 ||
|
|
383
|
+
v.maxCalls > 200)) ||
|
|
384
|
+
(v.instructions !== undefined && typeof v.instructions !== "string"))
|
|
385
|
+
note(at("advisor"), "takes { model, provider?, secret?, baseUrl?, maxCalls? (1 to 200), instructions? }: a model's name such as claude-opus-5-5.");
|
|
386
|
+
else
|
|
387
|
+
def.advisor = v;
|
|
388
|
+
}
|
|
328
389
|
dollars("maxSessionDollars", 10000);
|
|
329
390
|
dollars("maxDayDollars", 100000);
|
|
330
391
|
if (def.command === undefined)
|
package/dist/apps-cli.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ type Out = {
|
|
|
5
5
|
write: (text: string) => void;
|
|
6
6
|
error: (text: string) => void;
|
|
7
7
|
};
|
|
8
|
-
export declare const APP_HELP = "runtime apps <command>\n\n An App serves your web server from an image or a build. Copies start when\n requests come and stop when they end, between --min-copies and --max-copies.\n In a private beta: outside it, each command says how to ask to join.\n\n create [<name>] --vcpu <1-16> --memory <128-65536> --max-copies <1-
|
|
9
|
-
export declare const FUNCTION_HELP = "runtime functions <command>\n\n A Function serves your HTTP handler from an image or a build, at its own\n address. Copies start when calls come, up to --max-copies, and sleep when\n they stop: an idle Function has no copy awake.\n In a private beta: outside it, each command says how to ask to join.\n\n create [<name>] --vcpu <1-16> --memory <128-65536> --max-copies <1-
|
|
10
|
-
export declare const BUILD_HELP = "runtime builds <command>\n\n A build turns a commit of a connected repository into a saved server an App\n deploys. A push to the production branch builds and deploys by itself.\n In a private beta: outside it, each command says how to ask to join.\n\n repos connect <owner/name | https URL> --deploy <app name> [--branch main] [--no-previews]\n [--root <folder>] [--install <command>] [--build <command>] [--start <command>]\n [--port 8080] [--health-path /healthz] [--build-env KEY=VALUE]... [--name <name>]\n Connect a repository; prints its id. --deploy takes an\n App's name, or function:<name>. --start runs once the\n build is done, with PORT set: the server the App deploys\n repos ls Connected repositories\n repos change <repoId> [the options of connect but the repository]\n Change its settings; its id and builds stay\n repos disconnect <repoId> Stop building it; its builds stay\n repos install A link to install Runtime's GitHub App, so a private\n repository builds\n create <repoId> [--ref main] [--branch <name>] [--name <name>]\n Build a branch, tag or commit now; prints the build's id\n run <repoId> [--ref main] [--branch <name>] [--name <name>] [--raw]\n The same, then follows its log; exits 0 once it succeeds\n ls [--repository <repoId>] [--commit <sha>] [--state <state>]...\n Builds, oldest first; --commit: a full sha\n get <buildId> One build: state, commit, step times, what it
|
|
8
|
+
export declare const APP_HELP = "runtime apps <command>\n\n An App serves your web server from an image or a build. Copies start when\n requests come and stop when they end, between --min-copies and --max-copies.\n In a private beta: outside it, each command says how to ask to join.\n\n create [<name>] --vcpu <1-16> --memory <128-65536> --max-copies <1-plan limit>\n [--min-copies 0] [--concurrency 100] [--spares 2] [--port 8080]\n [--health-path /healthz] [--health-fail 60] [--stop-grace 30] [--cdn on|off]\n [--release at-once|staged] [--soak 300] [--volume <volumeId>:<path>] [--label key=value]...\n Make an App, waiting for its first deploy; prints its id.\n --health-fail: seconds a live copy may fail its health\n check before it is replaced. --stop-grace: seconds a\n stopped copy has after SIGTERM. --release staged: a new\n version goes live on one copy, then about 10%, 50% and\n all of them, each stage running --soak seconds (60 to\n 3600) and judged on its visitors' errors and speed\n before the next; a stage that does worse goes back and\n the deploy fails, the live version never stopping.\n --volume mounts one\n volume of yours at a path under /data, /mnt, /state,\n /storage or /volumes, in the App's one copy: it needs\n --max-copies 1 (--min-copies is then 1, --spares 0), and\n each deploy stops the old copy before the new one boots\n ls [--all] Your Apps: state, live version, copies; --all, deleted too\n get <app> One App, in full (an id or its name)\n update <app> [--name <name>] [--vcpu n] [--memory n] [--min-copies n] [--max-copies n]\n [--concurrency n] [--spares n] [--port n] [--health-path /path] [--health-fail n]\n [--stop-grace n] [--volume <volumeId>:<path> | none] [--cdn on|off]\n [--release at-once|staged] [--soak n] [--label key=value]...\n Change its settings; --volume none takes the volume\n away, only before its first deploy;\n --cdn off sends visitors straight to Runtime's routers,\n with nothing cached (on: Cloudflare's CDN in front)\n rm <app> Delete it and stop its copies\n deploy <app> (--image <image> | --build <buildId>) [--env KEY=VALUE]... [--keep-env]\n [--port 8080] [--health-path /healthz] [--no-wait]\n A new version. Waits until it is live, or says why it\n failed; --no-wait prints the deploy's id at once.\n --image: an image of yours (id, name, name:tag);\n --build: a build that succeeded (runtime builds).\n --env KEY alone sends KEY's value from your environment.\n --keep-env keeps the last deploy's environment, sealed\n deploys <app> [<deployId>] [--wait] Each version's deploy: state and address; with an id,\n that one (--wait: until it ends)\n versions <app> Its versions; the live and previous ones keep saved copies\n copies <app> Its copies now: version, region, state\n logs <app> [--follow] [--since 1h] [--version n] [--copy <copyId>] [--stream stdout|stderr]\n [--limit 100] [--raw] What its copies printed: the newest lines since --since\n (a time, or 30s, 15m, 2h, 7d; kept 14 days), or with\n --follow every line as it comes, until Ctrl-C. On a\n terminal control characters show as \\uXXXX unless --raw\n exec <app> [--copy <id>] [--root] [--cwd <dir>] [--env K=V]... [--timeout <ms>] [--trace-files <file.json>] -- <command>\n Run a command in its live copy\n cp <file> <app>:/<path> [--copy <id>] Copy a file onto its live copy\n cp <app>:/<path> <file> [--copy <id>] Copy a file off it\n exec and cp go to a serving copy of the live version unless --copy names\n one. A copy holds the App's secrets, so only an owner's or admin's key\n reaches into one. A file written to a copy lasts as long as that copy; a\n deploy replaces its copies.\n rollback <app> [--no-wait] Put the previous version live again\n restart <app> [--no-wait] Start the live version afresh, as a deploy of its own;\n with a volume, the old copy stops first and the\n downtime is said\n\nExamples\n runtime apps create web --vcpu 1 --memory 512 --max-copies 3\n runtime apps deploy web --image web:latest --env NODE_ENV=production\n runtime apps logs web --follow\n runtime apps rollback web\n runtime apps create db --vcpu 1 --memory 1024 --max-copies 1 --volume <volumeId>:/data\n";
|
|
9
|
+
export declare const FUNCTION_HELP = "runtime functions <command>\n\n A Function serves your HTTP handler from an image or a build, at its own\n address. Copies start when calls come, up to --max-copies, and sleep when\n they stop: an idle Function has no copy awake.\n In a private beta: outside it, each command says how to ask to join.\n\n create [<name>] --vcpu <1-16> --memory <128-65536> --max-copies <1-plan limit>\n [--concurrency 100] [--spares 2] [--port 8080]\n [--health-path /healthz] [--health-fail 60] [--label key=value]...\n Make a Function, waiting for its first deploy; prints its id.\n --health-fail: seconds a live copy may fail its health\n check before it is replaced\n ls [--all] Your Functions: state, live version, copies; --all, deleted too\n get <function> One Function, in full (an id or its name)\n update <function> [--name <name>] [--vcpu n] [--memory n] [--max-copies n]\n [--concurrency n] [--spares n] [--port n] [--health-path /path] [--health-fail n]\n [--label key=value]...\n Change its settings\n rm <function> Delete it and stop its copies\n deploy <function> (--image <image> | --build <buildId>) [--env KEY=VALUE]... [--keep-env]\n [--port 8080] [--health-path /healthz] [--no-wait]\n A new version. Waits until it is live, or says why it\n failed; --no-wait prints the deploy's id at once.\n --image: an image of yours (id, name, name:tag);\n --build: a build that succeeded (runtime builds).\n --env KEY alone sends KEY's value from your environment.\n --keep-env keeps the last deploy's environment, sealed\n deploys <function> [<deployId>] [--wait] Each version's deploy: state and address; with an id,\n that one (--wait: until it ends)\n versions <function> Its versions; the live and previous ones keep saved copies\n copies <function> Its copies now: version, region, state\n logs <function> [--follow] [--since 1h] [--version n] [--copy <copyId>] [--stream stdout|stderr]\n [--limit 100] [--raw] What its copies printed: the newest lines since --since\n (a time, or 30s, 15m, 2h, 7d; kept 14 days), or with\n --follow every line as it comes, until Ctrl-C. On a\n terminal control characters show as \\uXXXX unless --raw\n rollback <function> [--no-wait] Put the previous version live again\n restart <function> [--no-wait] Start the live version afresh, as a deploy of its own\n\nExamples\n runtime functions create resize --vcpu 1 --memory 512 --max-copies 10\n runtime functions deploy resize --image resize:latest\n runtime functions logs resize --follow\n runtime functions rollback resize\n";
|
|
10
|
+
export declare const BUILD_HELP = "runtime builds <command>\n\n A build turns a commit of a connected repository into a saved server an App\n deploys. A push to the production branch builds and deploys by itself.\n In a private beta: outside it, each command says how to ask to join.\n\n repos connect <owner/name | https URL> --deploy <app name> [--branch main] [--no-previews]\n [--root <folder>] [--install <command>] [--build <command>] [--start <command>]\n [--port 8080] [--health-path /healthz] [--build-env KEY=VALUE]... [--name <name>]\n Connect a repository; prints its id. --deploy takes an\n App's name, or function:<name>. --start runs once the\n build is done, with PORT set: the server the App deploys.\n A command left out is the detected framework's (Next.js,\n Vite, Remix, Astro, SvelteKit, Nuxt, Express, Hono,\n FastAPI, Django, Flask, Rails, Go, Rust, a Dockerfile)\n repos ls Connected repositories\n repos change <repoId> [the options of connect but the repository]\n Change its settings; its id and builds stay\n repos disconnect <repoId> Stop building it; its builds stay\n repos install A link to install Runtime's GitHub App, so a private\n repository builds\n create <repoId> [--ref main] [--branch <name>] [--name <name>]\n Build a branch, tag or commit now; prints the build's id\n run <repoId> [--ref main] [--branch <name>] [--name <name>] [--raw]\n The same, then follows its log; exits 0 once it succeeds\n ls [--repository <repoId>] [--commit <sha>] [--state <state>]...\n Builds, oldest first; --commit: a full sha\n get <buildId> One build: state, commit, framework, step times, what it\n made\n cancel <buildId> Stop a build that has not ended\n logs <buildId> [--follow] [--raw] Its last 200 lines, or every line as it comes until it\n ends; on a terminal control characters show as \\uXXXX\n unless --raw\n\nExamples\n runtime builds repos connect acme/web --deploy web\n runtime builds repos connect acme/api --deploy api --start \"node dist/server.js\"\n runtime builds run <repoId> --ref main\n runtime builds ls --commit $(git rev-parse HEAD)\n";
|
|
11
11
|
export declare const CONTAINER_HELP = "runtime containers <command>\n\n A container runs one OCI image's process on its own microVM, billed at the\n sandbox rates. It never sleeps unless --sleep; on exit it restarts when it\n serves a port, else it stops (--on-exit sets either).\n In a private beta: outside it, each command says how to ask to join.\n\n create <image> --vcpu <1-16> --memory <128-65536> [--name <name>] [--label key=value]...\n [--env KEY[=VALUE]]... [--entrypoint <program>] [--workdir /app] [--user <user>]\n [--port <1-65535>] [--on-exit restart|stop] [--sleep] [-- <command...>]\n Run it; prints its id. The image's digest is pinned.\n --env KEY alone sends KEY's value from your environment.\n --entrypoint drops the image's command; after --, the\n command replaces the image's\n ls [--all] [--state <state>]... [--label key=value]...\n Your containers: all but deleting and deleted, unless\n --all or --state\n get <container> One container, in full (an id or its name): its\n environment's names, never their values\n update <container> [--name <name>] [--label key=value]...\n Rename it or replace its labels\n rm <container> [--wait] Delete it and stop its process; --wait: until deleted\n\nExamples\n runtime containers create nginx:1.27 --vcpu 1 --memory 512 --name web\n runtime containers create python:3.12 --vcpu 1 --memory 1024 -- python3 -m http.server 8000\n runtime containers rm web --wait\n";
|
|
12
12
|
export declare function appsCommand(argv: string[], env: NodeJS.ProcessEnv, out: Out, client: () => Promise<Runtime>, kit: CliKit): Promise<number>;
|
|
13
13
|
export declare function functionsCommand(argv: string[], env: NodeJS.ProcessEnv, out: Out, client: () => Promise<Runtime>, kit: CliKit): Promise<number>;
|
package/dist/apps-cli.js
CHANGED
|
@@ -10,7 +10,7 @@ export const APP_HELP = `runtime apps <command>
|
|
|
10
10
|
requests come and stop when they end, between --min-copies and --max-copies.
|
|
11
11
|
In a private beta: outside it, each command says how to ask to join.
|
|
12
12
|
|
|
13
|
-
create [<name>] --vcpu <1-16> --memory <128-65536> --max-copies <1-
|
|
13
|
+
create [<name>] --vcpu <1-16> --memory <128-65536> --max-copies <1-plan limit>
|
|
14
14
|
[--min-copies 0] [--concurrency 100] [--spares 2] [--port 8080]
|
|
15
15
|
[--health-path /healthz] [--health-fail 60] [--stop-grace 30] [--cdn on|off]
|
|
16
16
|
[--release at-once|staged] [--soak 300] [--volume <volumeId>:<path>] [--label key=value]...
|
|
@@ -83,7 +83,7 @@ export const FUNCTION_HELP = `runtime functions <command>
|
|
|
83
83
|
they stop: an idle Function has no copy awake.
|
|
84
84
|
In a private beta: outside it, each command says how to ask to join.
|
|
85
85
|
|
|
86
|
-
create [<name>] --vcpu <1-16> --memory <128-65536> --max-copies <1-
|
|
86
|
+
create [<name>] --vcpu <1-16> --memory <128-65536> --max-copies <1-plan limit>
|
|
87
87
|
[--concurrency 100] [--spares 2] [--port 8080]
|
|
88
88
|
[--health-path /healthz] [--health-fail 60] [--label key=value]...
|
|
89
89
|
Make a Function, waiting for its first deploy; prints its id.
|
|
@@ -133,7 +133,10 @@ export const BUILD_HELP = `runtime builds <command>
|
|
|
133
133
|
[--port 8080] [--health-path /healthz] [--build-env KEY=VALUE]... [--name <name>]
|
|
134
134
|
Connect a repository; prints its id. --deploy takes an
|
|
135
135
|
App's name, or function:<name>. --start runs once the
|
|
136
|
-
build is done, with PORT set: the server the App deploys
|
|
136
|
+
build is done, with PORT set: the server the App deploys.
|
|
137
|
+
A command left out is the detected framework's (Next.js,
|
|
138
|
+
Vite, Remix, Astro, SvelteKit, Nuxt, Express, Hono,
|
|
139
|
+
FastAPI, Django, Flask, Rails, Go, Rust, a Dockerfile)
|
|
137
140
|
repos ls Connected repositories
|
|
138
141
|
repos change <repoId> [the options of connect but the repository]
|
|
139
142
|
Change its settings; its id and builds stay
|
|
@@ -146,14 +149,16 @@ export const BUILD_HELP = `runtime builds <command>
|
|
|
146
149
|
The same, then follows its log; exits 0 once it succeeds
|
|
147
150
|
ls [--repository <repoId>] [--commit <sha>] [--state <state>]...
|
|
148
151
|
Builds, oldest first; --commit: a full sha
|
|
149
|
-
get <buildId> One build: state, commit, step times, what it
|
|
152
|
+
get <buildId> One build: state, commit, framework, step times, what it
|
|
153
|
+
made
|
|
150
154
|
cancel <buildId> Stop a build that has not ended
|
|
151
155
|
logs <buildId> [--follow] [--raw] Its last 200 lines, or every line as it comes until it
|
|
152
156
|
ends; on a terminal control characters show as \\uXXXX
|
|
153
157
|
unless --raw
|
|
154
158
|
|
|
155
159
|
Examples
|
|
156
|
-
runtime builds repos connect acme/web --deploy web
|
|
160
|
+
runtime builds repos connect acme/web --deploy web
|
|
161
|
+
runtime builds repos connect acme/api --deploy api --start "node dist/server.js"
|
|
157
162
|
runtime builds run <repoId> --ref main
|
|
158
163
|
runtime builds ls --commit $(git rev-parse HEAD)
|
|
159
164
|
`;
|
package/dist/browsers-cli.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ type Out = {
|
|
|
5
5
|
write: (text: string) => void;
|
|
6
6
|
error: (text: string) => void;
|
|
7
7
|
};
|
|
8
|
-
export declare const BROWSER_HELP = "runtime browsers <command>\n\n A browser is Chromium on its own sandbox, billed at the sandbox rates, with a\n private CDP address for Playwright, Puppeteer, browser-use or Stagehand.\n In a private beta: outside it, each command says how to ask to join.\n\n create [--memory <1024-16384>] [--vcpu <1-16>] [--visible] [--width <px>] [--height <px>]\n [--timeout <seconds>] [--name <name>] [--label key=value]...\n Start one; prints its id, then its cdpUrl\n ls Your browsers\n get <browser> One browser, with a fresh cdpUrl (an id or its name)\n screenshot <browser> [<url>] [--out <file.png>] [--full] [--jpeg] [--wait <ms>]\n Open url in a new tab and save its screenshot\n (without url: what it shows now)\n rm <browser> Delete it and its sandbox\n\nExamples\n runtime browsers create --name scraper\n runtime browsers screenshot scraper https://withruntime.com --out home.png\n runtime browsers rm scraper\n";
|
|
8
|
+
export declare const BROWSER_HELP = "runtime browsers <command>\n\n A browser is Chromium on its own sandbox, billed at the sandbox rates, with a\n private CDP address for Playwright, Puppeteer, browser-use or Stagehand.\n In a private beta: outside it, each command says how to ask to join.\n\n create [--memory <1024-16384>] [--vcpu <1-16>] [--visible] [--width <px>] [--height <px>]\n [--timeout <seconds>] [--name <name>] [--label key=value]...\n Start one; prints its id, then its cdpUrl\n ls Your browsers\n get <browser> One browser, with a fresh cdpUrl (an id or its name)\n screenshot <browser> [<url>] [--out <file.png>] [--full] [--jpeg] [--wait <ms>]\n Open url in a new tab and save its screenshot\n (without url: what it shows now)\n rm <browser> Delete it and its sandbox\n\n run <task> [--url <start url>] [--model <model>] [--max-steps <n>] [--domain <domain>]...\n [--frames <dir>] [--detach] [--label key=value]...\n An agent browses to do the task: prints each step,\n then its answer (--frames saves each step's page;\n --detach prints the run's id at once)\n runs Your runs, newest first\n runs get <run> One run: state, answer or error\n runs steps <run> [--frames <dir>] Its steps, each with the page it saw\n runs stop <run> Stop it\n\nExamples\n runtime browsers create --name scraper\n runtime browsers screenshot scraper https://withruntime.com --out home.png\n runtime browsers rm scraper\n runtime browsers run \"Find the price of the cheapest plan on withruntime.com\" --frames ./run\n";
|
|
9
9
|
export declare const DESKTOP_HELP = "runtime desktops <command>\n\n A desktop is a Linux desktop on its own sandbox, billed at the sandbox rates,\n with a private live view and computer use: screenshot, click, type, open.\n In a private beta: outside it, each command says how to ask to join.\n\n create [--memory <1024-16384>] [--vcpu <1-16>] [--width <px>] [--height <px>]\n [--timeout <seconds>] [--name <name>] [--label key=value]...\n Start one; prints its id, then its live view\n ls Your desktops\n get <desktop> One desktop, with a fresh live view (an id or its name)\n screenshot <desktop> [--out <file.png>] Save its screen\n open <desktop> <url> Open url in its Chromium\n rm <desktop> Delete it and its sandbox\n\nExamples\n runtime desktops create --name qa\n runtime desktops open qa https://withruntime.com\n runtime desktops screenshot qa --out screen.png\n";
|
|
10
10
|
/** `runtime browsers` and `runtime desktops`: the five verbs, a screenshot
|
|
11
11
|
* saved to a file, and a desktop's open. */
|
package/dist/browsers-cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { writeFileSync } from "node:fs";
|
|
1
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
2
3
|
import { me, named } from "./cli-name.js";
|
|
3
|
-
import { browsers } from "./products/browsers.js";
|
|
4
|
+
import { browsers, } from "./products/browsers.js";
|
|
4
5
|
import { desktops } from "./products/desktops.js";
|
|
5
6
|
export const BROWSER_HELP = `runtime browsers <command>
|
|
6
7
|
|
|
@@ -18,10 +19,21 @@ export const BROWSER_HELP = `runtime browsers <command>
|
|
|
18
19
|
(without url: what it shows now)
|
|
19
20
|
rm <browser> Delete it and its sandbox
|
|
20
21
|
|
|
22
|
+
run <task> [--url <start url>] [--model <model>] [--max-steps <n>] [--domain <domain>]...
|
|
23
|
+
[--frames <dir>] [--detach] [--label key=value]...
|
|
24
|
+
An agent browses to do the task: prints each step,
|
|
25
|
+
then its answer (--frames saves each step's page;
|
|
26
|
+
--detach prints the run's id at once)
|
|
27
|
+
runs Your runs, newest first
|
|
28
|
+
runs get <run> One run: state, answer or error
|
|
29
|
+
runs steps <run> [--frames <dir>] Its steps, each with the page it saw
|
|
30
|
+
runs stop <run> Stop it
|
|
31
|
+
|
|
21
32
|
Examples
|
|
22
33
|
runtime browsers create --name scraper
|
|
23
34
|
runtime browsers screenshot scraper https://withruntime.com --out home.png
|
|
24
35
|
runtime browsers rm scraper
|
|
36
|
+
runtime browsers run "Find the price of the cheapest plan on withruntime.com" --frames ./run
|
|
25
37
|
`;
|
|
26
38
|
export const DESKTOP_HELP = `runtime desktops <command>
|
|
27
39
|
|
|
@@ -153,8 +165,115 @@ export async function machineProductCommand(which, argv, out, client, kit) {
|
|
|
153
165
|
print(`${String(rest[0])} deleted.`, gone ?? { deleted: true });
|
|
154
166
|
return 0;
|
|
155
167
|
}
|
|
168
|
+
case "run":
|
|
169
|
+
if (which === "browsers")
|
|
170
|
+
return browserRun(rest, out, browsers(transport), kit);
|
|
171
|
+
break;
|
|
172
|
+
case "runs":
|
|
173
|
+
if (which === "browsers")
|
|
174
|
+
return browserRuns(rest, out, browsers(transport), kit);
|
|
175
|
+
break;
|
|
156
176
|
}
|
|
157
177
|
throw kit.unknown(`${which} command`, verb, which === "browsers"
|
|
158
|
-
? ["create", "ls", "get", "screenshot", "rm"]
|
|
178
|
+
? ["create", "ls", "get", "screenshot", "rm", "run", "runs"]
|
|
159
179
|
: ["create", "ls", "get", "screenshot", "open", "rm"]);
|
|
160
180
|
}
|
|
181
|
+
/** A step's line, and its page saved to `dir` when one is asked for. */
|
|
182
|
+
function shown(step, dir, out) {
|
|
183
|
+
const where = step.url ? ` (${step.url})` : "";
|
|
184
|
+
out.error(`Step ${step.n}: ${step.goal ?? ""}${where}`.trim());
|
|
185
|
+
if (dir && step.frame) {
|
|
186
|
+
mkdirSync(dir, { recursive: true });
|
|
187
|
+
writeFileSync(join(dir, `step-${String(step.n).padStart(3, "0")}.jpg`), Buffer.from(step.frame, "base64"));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** The run's end as the CLI prints it: its answer, or why it failed (exit 1). */
|
|
191
|
+
function ending(run, out) {
|
|
192
|
+
if (out.json)
|
|
193
|
+
out.write(JSON.stringify(run));
|
|
194
|
+
else if (run.state === "done")
|
|
195
|
+
out.write(run.output ?? "");
|
|
196
|
+
else
|
|
197
|
+
out.error(`The run ${run.state}${run.error ? `: ${run.error}` : "."} (${run.id})`);
|
|
198
|
+
return run.state === "done" ? 0 : 1;
|
|
199
|
+
}
|
|
200
|
+
/** `runtime browsers run <task>`: started, each step printed as it comes,
|
|
201
|
+
* then the answer. */
|
|
202
|
+
async function browserRun(argv, out, api, kit) {
|
|
203
|
+
const { parse, flag, has, integer, need, pairs } = kit;
|
|
204
|
+
const args = parse(argv, ["detach"], ["url", "model", "max-steps", "domain", "frames", "label"]);
|
|
205
|
+
const task = need(args.positional.join(" ").trim() || undefined, "a task in plain words");
|
|
206
|
+
const domains = args.flags.get("domain");
|
|
207
|
+
const run = await api.runs.create({
|
|
208
|
+
task,
|
|
209
|
+
...(flag(args, "url") === undefined ? {} : { startUrl: flag(args, "url") }),
|
|
210
|
+
...(flag(args, "model") === undefined ? {} : { model: flag(args, "model") }),
|
|
211
|
+
...(integer(args, "max-steps") === undefined ? {} : { maxSteps: integer(args, "max-steps") }),
|
|
212
|
+
...(domains?.length ? { allowedDomains: [...domains] } : {}),
|
|
213
|
+
...(args.flags.has("label") ? { labels: pairs(args, "label") } : {}),
|
|
214
|
+
});
|
|
215
|
+
if (has(args, "detach")) {
|
|
216
|
+
out.write(out.json ? JSON.stringify(run) : run.id);
|
|
217
|
+
return 0;
|
|
218
|
+
}
|
|
219
|
+
if (!out.json)
|
|
220
|
+
out.error(`Run ${run.id}: ${me} browsers runs get ${run.id}`);
|
|
221
|
+
const dir = flag(args, "frames");
|
|
222
|
+
for await (const step of api.runs.follow(run.id, { frames: dir !== undefined }))
|
|
223
|
+
if (!out.json)
|
|
224
|
+
shown(step, dir, out);
|
|
225
|
+
return ending(await api.runs.get(run.id), out);
|
|
226
|
+
}
|
|
227
|
+
/** `runtime browsers runs [get|steps|stop] <run>`. */
|
|
228
|
+
async function browserRuns(argv, out, api, kit) {
|
|
229
|
+
const { parse, flag, need, table } = kit;
|
|
230
|
+
const [verb, ...rest] = argv;
|
|
231
|
+
switch (verb ?? "ls") {
|
|
232
|
+
case "ls":
|
|
233
|
+
case "list": {
|
|
234
|
+
const all = (await api.runs.list({ limit: 50 })).data;
|
|
235
|
+
out.write(out.json
|
|
236
|
+
? JSON.stringify(all)
|
|
237
|
+
: all.length
|
|
238
|
+
? table([
|
|
239
|
+
["ID", "STATE", "STEPS", "TASK"],
|
|
240
|
+
...all.map((r) => [r.id, r.state, String(r.steps), (r.task ?? "").slice(0, 60)]),
|
|
241
|
+
])
|
|
242
|
+
: `No runs. Start one: ${me} browsers run "<task>"`);
|
|
243
|
+
return 0;
|
|
244
|
+
}
|
|
245
|
+
case "get": {
|
|
246
|
+
const found = await api.runs.get(need(rest[0], "a run's id"));
|
|
247
|
+
out.write(JSON.stringify(found, null, out.json ? undefined : 2));
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
case "steps": {
|
|
251
|
+
const args = parse(rest, [], ["frames"]);
|
|
252
|
+
const id = need(args.positional[0], "a run's id");
|
|
253
|
+
const dir = flag(args, "frames");
|
|
254
|
+
const all = [];
|
|
255
|
+
let after = 0;
|
|
256
|
+
for (;;) {
|
|
257
|
+
const page = await api.runs.steps(id, { after, limit: 100, frames: dir !== undefined });
|
|
258
|
+
all.push(...page.data);
|
|
259
|
+
if (!page.data.length)
|
|
260
|
+
break;
|
|
261
|
+
after = page.after;
|
|
262
|
+
}
|
|
263
|
+
if (out.json)
|
|
264
|
+
out.write(JSON.stringify(all.map((s) => ({ ...s, frame: undefined }))));
|
|
265
|
+
else
|
|
266
|
+
for (const step of all)
|
|
267
|
+
shown(step, dir, out);
|
|
268
|
+
if (dir && !out.json)
|
|
269
|
+
out.write(`Saved ${all.filter((s) => s.frame).length} pages to ${dir}.`);
|
|
270
|
+
return 0;
|
|
271
|
+
}
|
|
272
|
+
case "stop": {
|
|
273
|
+
const stopped = await api.runs.stop(need(rest[0], "a run's id"));
|
|
274
|
+
out.write(out.json ? JSON.stringify(stopped) : `${stopped.id}: ${stopped.state}.`);
|
|
275
|
+
return 0;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
throw kit.unknown("browsers runs command", verb ?? "", ["ls", "get", "steps", "stop"]);
|
|
279
|
+
}
|
package/dist/ci-cli.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
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]
|
|
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. Without a runtime.yml,\n checks run .circleci/config.yml, .gitlab-ci.yml,\n .buildkite/pipeline.yml or a .harness/ pipeline\n unchanged: connecting is the whole move\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>]... [--event <event>]... [--limit 20]\n 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";
|
|
10
|
+
/** The pipeline file of another CI that CI/CD's checks run unchanged when a
|
|
11
|
+
* repository has no runtime.yml (engines checks-runner `pipelines::find`), in
|
|
12
|
+
* the same order; null for none. */
|
|
13
|
+
export declare function runsAsIs(root: string): string | null;
|
|
9
14
|
export declare function ciCommand(argv: string[], out: Out, client: () => Promise<Runtime>, kit: CliKit): Promise<number>;
|
|
15
|
+
/** An agent step's verdict in words: each finding with its place and fix,
|
|
16
|
+
* then the notes, then who judged. */
|
|
17
|
+
/** A job's annotations as `path:line:col: level: title: message`, each
|
|
18
|
+
* message's first line, the way compilers print them. */
|
|
19
|
+
export declare function annotated(lines: CiAnnotation[]): string;
|
|
10
20
|
export {};
|
package/dist/ci-cli.js
CHANGED
|
@@ -13,10 +13,15 @@ export const CI_HELP = `runtime ci <command>
|
|
|
13
13
|
import [dir] [--write] [--force] This folder's GitHub Actions workflows and CircleCI
|
|
14
14
|
config as a runtime.yml: printed, or written with
|
|
15
15
|
--write; what isn't carried over is noted at its top.
|
|
16
|
-
Needs no key and sends nothing
|
|
16
|
+
Needs no key and sends nothing. Without a runtime.yml,
|
|
17
|
+
checks run .circleci/config.yml, .gitlab-ci.yml,
|
|
18
|
+
.buildkite/pipeline.yml or a .harness/ pipeline
|
|
19
|
+
unchanged: connecting is the whole move
|
|
17
20
|
connect <owner/name> [--branch main] [--config runtime.yml] [--installation <id>]
|
|
18
21
|
[--trust <app-slug>[bot]]... [--name <name>]
|
|
19
22
|
Connect a repository; prints its id. Takes a full key.
|
|
23
|
+
--config cloudbuild.yaml or buildspec.yml runs a Google
|
|
24
|
+
Cloud Build or AWS CodeBuild config as it is.
|
|
20
25
|
--trust runs that App's pushes as its own from the start
|
|
21
26
|
repos [ls] [--all] Connected repositories, with the Apps each trusts;
|
|
22
27
|
--all: disconnected ones too
|
|
@@ -31,7 +36,8 @@ export const CI_HELP = `runtime ci <command>
|
|
|
31
36
|
takes an owner's or admin's full key
|
|
32
37
|
disconnect <repoId | owner/name> Stop checking it; its checks still going are cancelled
|
|
33
38
|
checks [--repository <repoId>] [--branch <name>] [--commit <sha>] [--pr <number>]
|
|
34
|
-
[--state <state>]... [--limit 20]
|
|
39
|
+
[--state <state>]... [--event <event>]... [--limit 20]
|
|
40
|
+
Checks, newest first, with their jobs by state (or ls)
|
|
35
41
|
check <checkId> One check and its jobs in plan order (or get)
|
|
36
42
|
cancel <checkId> Cancel a queued or running check: its jobs end,
|
|
37
43
|
its machines are let go, GitHub is told
|
|
@@ -84,9 +90,31 @@ const machined = (m) => {
|
|
|
84
90
|
};
|
|
85
91
|
const where = (c) => c.pullRequest !== null ? `#${c.pullRequest}` : (c.branch ?? c.event);
|
|
86
92
|
const STATES = ["queued", "running", "passed", "failed", "cancelled"];
|
|
93
|
+
const EVENTS = ["push", "pull_request", "merge_group", "rerun"];
|
|
87
94
|
const ownerOf = (f) => f.owner === null
|
|
88
95
|
? "nobody found"
|
|
89
96
|
: `@${f.owner.login}${f.owner.pullRequest === null ? "" : ` (#${f.owner.pullRequest})`}`;
|
|
97
|
+
/** The pipeline file of another CI that CI/CD's checks run unchanged when a
|
|
98
|
+
* repository has no runtime.yml (engines checks-runner `pipelines::find`), in
|
|
99
|
+
* the same order; null for none. */
|
|
100
|
+
export function runsAsIs(root) {
|
|
101
|
+
for (const path of [
|
|
102
|
+
".circleci/config.yml",
|
|
103
|
+
".circleci/config.yaml",
|
|
104
|
+
".gitlab-ci.yml",
|
|
105
|
+
".buildkite/pipeline.yml",
|
|
106
|
+
".buildkite/pipeline.yaml",
|
|
107
|
+
"buildkite.yml",
|
|
108
|
+
])
|
|
109
|
+
if (existsSync(join(root, path)))
|
|
110
|
+
return path;
|
|
111
|
+
const harness = join(root, ".harness");
|
|
112
|
+
if (existsSync(harness))
|
|
113
|
+
for (const name of readdirSync(harness).sort())
|
|
114
|
+
if (/\.ya?ml$/.test(name) && /^\s*stages:/m.test(readFileSync(join(harness, name), "utf8")))
|
|
115
|
+
return `.harness/${name}`;
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
90
118
|
/** `runtime ci import [dir] [--write] [--force]`: the folder's GitHub Actions
|
|
91
119
|
* workflows and CircleCI config as a `runtime.yml`, printed or written. */
|
|
92
120
|
async function importCommand(argv, out, kit) {
|
|
@@ -104,8 +132,21 @@ async function importCommand(argv, out, kit) {
|
|
|
104
132
|
const circle = join(root, ".circleci", "config.yml");
|
|
105
133
|
if (existsSync(circle))
|
|
106
134
|
files.push({ path: ".circleci/config.yml", text: readFileSync(circle, "utf8") });
|
|
107
|
-
if (!files.length)
|
|
108
|
-
|
|
135
|
+
if (!files.length) {
|
|
136
|
+
// A pipeline CI/CD runs as it is needs no runtime.yml.
|
|
137
|
+
const direct = runsAsIs(root);
|
|
138
|
+
if (direct) {
|
|
139
|
+
out.write(out.json
|
|
140
|
+
? JSON.stringify({ steps: [], notes: [], yaml: "", read: [], runsAsIs: direct })
|
|
141
|
+
: `${direct}: CI/CD runs it as it is, so there is nothing to import. Push it, then \`${me} ci connect <owner/name>\`; what can't run on a check is listed as a warning on its job.`);
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
// Cloud Build and CodeBuild configs run as they are: nothing to import.
|
|
145
|
+
const vendor = ["cloudbuild.yaml", "cloudbuild.yml", "buildspec.yml", "buildspec.yaml"].find((name) => existsSync(join(root, name)));
|
|
146
|
+
if (vendor)
|
|
147
|
+
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.`);
|
|
148
|
+
throw kit.usage(`${root} has no .github/workflows/*.yml or .circleci/config.yml to import, and no .gitlab-ci.yml, .buildkite/pipeline.yml or .harness/ pipeline for CI/CD to run as it is.`);
|
|
149
|
+
}
|
|
109
150
|
const made = importCi(files);
|
|
110
151
|
if (!made.yaml) {
|
|
111
152
|
out.error(made.notes.join("\n"));
|
|
@@ -177,7 +218,7 @@ export async function ciCommand(argv, out, client, kit) {
|
|
|
177
218
|
};
|
|
178
219
|
const repo = await api.repositories.connect(input);
|
|
179
220
|
if (!out.json)
|
|
180
|
-
out.error(`Connected ${repo.repository}: each push and pull request is checked as ${repo.configPath} says; ${repo.productionBranch} is its production branch; it trusts ${trusted(repo)}. Its checks: ${me} ci ls --repository ${repo.id}`);
|
|
221
|
+
out.error(`Connected ${repo.repository}: each push and pull request is checked as ${repo.configPath} says, or without it as its CircleCI, GitLab CI, Buildkite or Harness pipeline says, unchanged; ${repo.productionBranch} is its production branch; it trusts ${trusted(repo)}. Its checks: ${me} ci ls --repository ${repo.id}`);
|
|
181
222
|
print(repo.id, repo);
|
|
182
223
|
return 0;
|
|
183
224
|
}
|
|
@@ -246,7 +287,7 @@ export async function ciCommand(argv, out, client, kit) {
|
|
|
246
287
|
case "ls":
|
|
247
288
|
case "list":
|
|
248
289
|
case "checks": {
|
|
249
|
-
const args = parse(rest, [], ["repository", "branch", "commit", "pr", "state", "limit"]);
|
|
290
|
+
const args = parse(rest, [], ["repository", "branch", "commit", "pr", "state", "event", "limit"]);
|
|
250
291
|
const commit = flag(args, "commit");
|
|
251
292
|
if (commit !== undefined && !/^([0-9a-f]{40}|[0-9a-f]{64})$/.test(commit))
|
|
252
293
|
throw usage(`--commit takes a full sha in lower case: ${me} ci ls --commit $(git rev-parse HEAD)`);
|
|
@@ -254,6 +295,10 @@ export async function ciCommand(argv, out, client, kit) {
|
|
|
254
295
|
for (const state of states ?? [])
|
|
255
296
|
if (!STATES.includes(state))
|
|
256
297
|
throw unknown("state", state, STATES);
|
|
298
|
+
const events = args.flags.get("event");
|
|
299
|
+
for (const event of events ?? [])
|
|
300
|
+
if (!EVENTS.includes(event))
|
|
301
|
+
throw unknown("event", event, EVENTS);
|
|
257
302
|
const pullRequest = whole(flag(args, "pr"), "--pr");
|
|
258
303
|
const limit = whole(flag(args, "limit"), "--limit") ?? 20;
|
|
259
304
|
const page = await api.checks.list({
|
|
@@ -263,6 +308,7 @@ export async function ciCommand(argv, out, client, kit) {
|
|
|
263
308
|
...(commit ? { commit } : {}),
|
|
264
309
|
...(pullRequest === undefined ? {} : { pullRequest }),
|
|
265
310
|
...(states ? { state: states } : {}),
|
|
311
|
+
...(events ? { event: events } : {}),
|
|
266
312
|
});
|
|
267
313
|
const all = await page.toArray(limit);
|
|
268
314
|
print(all.length
|
|
@@ -332,6 +378,9 @@ export async function ciCommand(argv, out, client, kit) {
|
|
|
332
378
|
out.write(job.log.endsWith("\n") || !job.log ? job.log : `${job.log}\n`);
|
|
333
379
|
if (job.review)
|
|
334
380
|
out.write(reviewed(job.review));
|
|
381
|
+
// An API before annotations sends none.
|
|
382
|
+
if (job.annotations?.length)
|
|
383
|
+
out.write(annotated(job.annotations));
|
|
335
384
|
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
385
|
if (job.state === "failed" && job.sandboxIds.length)
|
|
337
386
|
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 +511,20 @@ export async function ciCommand(argv, out, client, kit) {
|
|
|
462
511
|
}
|
|
463
512
|
/** An agent step's verdict in words: each finding with its place and fix,
|
|
464
513
|
* then the notes, then who judged. */
|
|
514
|
+
/** A job's annotations as `path:line:col: level: title: message`, each
|
|
515
|
+
* message's first line, the way compilers print them. */
|
|
516
|
+
export function annotated(lines) {
|
|
517
|
+
const failing = lines.filter((a) => a.level === "failure").length;
|
|
518
|
+
return [
|
|
519
|
+
`\n${lines.length} line${lines.length === 1 ? "" : "s"} of the repository's files${failing ? `, ${failing} failing` : ""}:`,
|
|
520
|
+
...lines.map((a) => {
|
|
521
|
+
const at = `${a.path}:${a.startLine}${a.startColumn ? `:${a.startColumn}` : ""}`;
|
|
522
|
+
const first = a.message.split("\n")[0];
|
|
523
|
+
return ` ${at}: ${a.level}: ${a.title ? `${a.title}: ` : ""}${first}`;
|
|
524
|
+
}),
|
|
525
|
+
"",
|
|
526
|
+
].join("\n");
|
|
527
|
+
}
|
|
465
528
|
function reviewed(r) {
|
|
466
529
|
const at = (f) => (f.line > 0 ? `${f.file}:${f.line}` : f.file);
|
|
467
530
|
return [
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const LATEST_URL = "https://registry.npmjs.org/withruntime/latest";
|
|
2
|
+
/** Whether `latest` is a later release than `current`. A pre-release or a
|
|
3
|
+
* version that is not x.y.z is never later. */
|
|
4
|
+
export declare function isNewer(latest: string, current: string): boolean;
|
|
5
|
+
/** The line said under a usage error when npm has a later CLI, or "". */
|
|
6
|
+
export declare function outdatedLine(opts: {
|
|
7
|
+
env: NodeJS.ProcessEnv;
|
|
8
|
+
fetch?: typeof fetch;
|
|
9
|
+
version?: string;
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// An option or command the CLI refuses may be one a newer CLI has: on 26
|
|
2
|
+
// October 2026 `secrets scope --only-label` was refused as an unknown option
|
|
3
|
+
// by a withruntime 0.12.0 installed globally, which `npx withruntime` runs
|
|
4
|
+
// before it fetches the latest (0.37.0 had the option). So a usage error
|
|
5
|
+
// asks npm for the latest version, once and briefly, and says when this CLI
|
|
6
|
+
// is older. Nothing is asked on any other path, in CI, or when
|
|
7
|
+
// RUNTIME_NO_UPDATE_CHECK is set.
|
|
8
|
+
import { envFetch } from "./proxy.js";
|
|
9
|
+
import { VERSION } from "./transport.js";
|
|
10
|
+
export const LATEST_URL = "https://registry.npmjs.org/withruntime/latest";
|
|
11
|
+
const ASK_MS = 1_500;
|
|
12
|
+
const parts = (v) => /^(\d+)\.(\d+)\.(\d+)$/.exec(v.trim())?.slice(1).map(Number);
|
|
13
|
+
/** Whether `latest` is a later release than `current`. A pre-release or a
|
|
14
|
+
* version that is not x.y.z is never later. */
|
|
15
|
+
export function isNewer(latest, current) {
|
|
16
|
+
const a = parts(latest);
|
|
17
|
+
const b = parts(current);
|
|
18
|
+
if (!a || !b)
|
|
19
|
+
return false;
|
|
20
|
+
for (let i = 0; i < 3; i++)
|
|
21
|
+
if (a[i] !== b[i])
|
|
22
|
+
return a[i] > b[i];
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
/** The line said under a usage error when npm has a later CLI, or "". */
|
|
26
|
+
export async function outdatedLine(opts) {
|
|
27
|
+
const { env } = opts;
|
|
28
|
+
if (env.RUNTIME_NO_UPDATE_CHECK || env.CI)
|
|
29
|
+
return "";
|
|
30
|
+
const current = opts.version ?? VERSION;
|
|
31
|
+
try {
|
|
32
|
+
const response = await (opts.fetch ?? envFetch)(LATEST_URL, {
|
|
33
|
+
headers: { accept: "application/json" },
|
|
34
|
+
signal: AbortSignal.timeout(opts.timeoutMs ?? ASK_MS),
|
|
35
|
+
});
|
|
36
|
+
if (!response.ok)
|
|
37
|
+
return "";
|
|
38
|
+
const latest = (await response.json()).version;
|
|
39
|
+
if (typeof latest !== "string" || !isNewer(latest, current))
|
|
40
|
+
return "";
|
|
41
|
+
return `Note: this CLI is withruntime ${current} and the latest is ${latest}, which may support this. Update with \`npm install -g withruntime@latest\`, or run the latest once with \`npx withruntime@latest\` (plain \`npx withruntime\` runs an installed copy first).`;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
}
|