withruntime 0.37.0 → 0.46.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/DAYTONA.md +1 -1
- package/dist/agents-cli.d.ts +1 -1
- package/dist/agents-cli.js +252 -5
- 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 +5 -1
- package/dist/ci-cli.js +44 -5
- 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 +3 -5
- package/dist/cli.js +268 -59
- 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 +3 -2
- package/dist/errors.js +3 -2
- package/dist/index.d.ts +3 -3
- package/dist/products/agents.d.ts +252 -1
- package/dist/products/agents.js +136 -0
- package/dist/products/api-keys.d.ts +12 -0
- package/dist/products/api-keys.js +9 -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 +2 -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 +2 -1
- package/dist/transport.js +32 -1
- package/dist/types.d.ts +14 -0
- package/package.json +1 -1
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
|
@@ -6,7 +6,11 @@ type Out = {
|
|
|
6
6
|
write: (text: string) => void;
|
|
7
7
|
error: (text: string) => void;
|
|
8
8
|
};
|
|
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]
|
|
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;
|
|
10
14
|
export declare function ciCommand(argv: string[], out: Out, client: () => Promise<Runtime>, kit: CliKit): Promise<number>;
|
|
11
15
|
/** An agent step's verdict in words: each finding with its place and fix,
|
|
12
16
|
* then the notes, then who judged. */
|
package/dist/ci-cli.js
CHANGED
|
@@ -13,7 +13,10 @@ 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.
|
|
@@ -33,7 +36,8 @@ export const CI_HELP = `runtime ci <command>
|
|
|
33
36
|
takes an owner's or admin's full key
|
|
34
37
|
disconnect <repoId | owner/name> Stop checking it; its checks still going are cancelled
|
|
35
38
|
checks [--repository <repoId>] [--branch <name>] [--commit <sha>] [--pr <number>]
|
|
36
|
-
[--state <state>]... [--limit 20]
|
|
39
|
+
[--state <state>]... [--event <event>]... [--limit 20]
|
|
40
|
+
Checks, newest first, with their jobs by state (or ls)
|
|
37
41
|
check <checkId> One check and its jobs in plan order (or get)
|
|
38
42
|
cancel <checkId> Cancel a queued or running check: its jobs end,
|
|
39
43
|
its machines are let go, GitHub is told
|
|
@@ -86,9 +90,31 @@ const machined = (m) => {
|
|
|
86
90
|
};
|
|
87
91
|
const where = (c) => c.pullRequest !== null ? `#${c.pullRequest}` : (c.branch ?? c.event);
|
|
88
92
|
const STATES = ["queued", "running", "passed", "failed", "cancelled"];
|
|
93
|
+
const EVENTS = ["push", "pull_request", "merge_group", "rerun"];
|
|
89
94
|
const ownerOf = (f) => f.owner === null
|
|
90
95
|
? "nobody found"
|
|
91
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
|
+
}
|
|
92
118
|
/** `runtime ci import [dir] [--write] [--force]`: the folder's GitHub Actions
|
|
93
119
|
* workflows and CircleCI config as a `runtime.yml`, printed or written. */
|
|
94
120
|
async function importCommand(argv, out, kit) {
|
|
@@ -107,11 +133,19 @@ async function importCommand(argv, out, kit) {
|
|
|
107
133
|
if (existsSync(circle))
|
|
108
134
|
files.push({ path: ".circleci/config.yml", text: readFileSync(circle, "utf8") });
|
|
109
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
|
+
}
|
|
110
144
|
// Cloud Build and CodeBuild configs run as they are: nothing to import.
|
|
111
145
|
const vendor = ["cloudbuild.yaml", "cloudbuild.yml", "buildspec.yml", "buildspec.yaml"].find((name) => existsSync(join(root, name)));
|
|
112
146
|
if (vendor)
|
|
113
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.`);
|
|
114
|
-
throw kit.usage(`${root} has
|
|
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.`);
|
|
115
149
|
}
|
|
116
150
|
const made = importCi(files);
|
|
117
151
|
if (!made.yaml) {
|
|
@@ -184,7 +218,7 @@ export async function ciCommand(argv, out, client, kit) {
|
|
|
184
218
|
};
|
|
185
219
|
const repo = await api.repositories.connect(input);
|
|
186
220
|
if (!out.json)
|
|
187
|
-
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}`);
|
|
188
222
|
print(repo.id, repo);
|
|
189
223
|
return 0;
|
|
190
224
|
}
|
|
@@ -253,7 +287,7 @@ export async function ciCommand(argv, out, client, kit) {
|
|
|
253
287
|
case "ls":
|
|
254
288
|
case "list":
|
|
255
289
|
case "checks": {
|
|
256
|
-
const args = parse(rest, [], ["repository", "branch", "commit", "pr", "state", "limit"]);
|
|
290
|
+
const args = parse(rest, [], ["repository", "branch", "commit", "pr", "state", "event", "limit"]);
|
|
257
291
|
const commit = flag(args, "commit");
|
|
258
292
|
if (commit !== undefined && !/^([0-9a-f]{40}|[0-9a-f]{64})$/.test(commit))
|
|
259
293
|
throw usage(`--commit takes a full sha in lower case: ${me} ci ls --commit $(git rev-parse HEAD)`);
|
|
@@ -261,6 +295,10 @@ export async function ciCommand(argv, out, client, kit) {
|
|
|
261
295
|
for (const state of states ?? [])
|
|
262
296
|
if (!STATES.includes(state))
|
|
263
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);
|
|
264
302
|
const pullRequest = whole(flag(args, "pr"), "--pr");
|
|
265
303
|
const limit = whole(flag(args, "limit"), "--limit") ?? 20;
|
|
266
304
|
const page = await api.checks.list({
|
|
@@ -270,6 +308,7 @@ export async function ciCommand(argv, out, client, kit) {
|
|
|
270
308
|
...(commit ? { commit } : {}),
|
|
271
309
|
...(pullRequest === undefined ? {} : { pullRequest }),
|
|
272
310
|
...(states ? { state: states } : {}),
|
|
311
|
+
...(events ? { event: events } : {}),
|
|
273
312
|
});
|
|
274
313
|
const all = await page.toArray(limit);
|
|
275
314
|
print(all.length
|
|
@@ -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
|
+
}
|
package/dist/cli-words.js
CHANGED
|
@@ -22,6 +22,7 @@ const OPTIONS = {
|
|
|
22
22
|
idlePauseSeconds: { flag: "--idle-pause" },
|
|
23
23
|
autoWake: { flag: "--no-auto-wake / --auto-wake" },
|
|
24
24
|
user: { flag: "--user" },
|
|
25
|
+
leaseSeconds: { flag: "--lease" },
|
|
25
26
|
persistent: { flag: "--persistent" },
|
|
26
27
|
funding: { flag: "--trial / --paid" },
|
|
27
28
|
image: { flag: "--image" },
|
package/dist/cli.d.ts
CHANGED
|
@@ -57,9 +57,6 @@ export declare function outOfMemoryLines(memory: OutOfMemory | undefined): strin
|
|
|
57
57
|
/** How to move a rival's code across, when one import (or, for Fly's
|
|
58
58
|
* Machines, one address) does it. `from` is the name the caller gave. */
|
|
59
59
|
export declare function dropInLines(provider: SwitchProvider | undefined, from?: string): string[];
|
|
60
|
-
/** A secret's value, from standard input only, so it never sits in shell
|
|
61
|
-
* history or a process list. Piped: everything, less one trailing newline.
|
|
62
|
-
* A terminal: one line, not shown. */
|
|
63
60
|
/** A pasted secret as the header it becomes: no line breaks (a token copied
|
|
64
61
|
* from a terminal arrives wrapped), no bracketed-paste markers, no space at
|
|
65
62
|
* either end. 13 October 2026: a user's pasted Claude token was refused as
|
|
@@ -80,8 +77,9 @@ export declare function parseSecretScope(labels: string[] | undefined, sandboxes
|
|
|
80
77
|
/** Who gets a secret, in a few words. */
|
|
81
78
|
export declare const scopeText: (only: SecretScope | undefined) => string;
|
|
82
79
|
export declare function secretsCommand(argv: string[], env: NodeJS.ProcessEnv, out: Out,
|
|
83
|
-
/** Tests give the value here; the CLI reads standard input
|
|
84
|
-
|
|
80
|
+
/** Tests give the value here; the CLI reads standard input, `verbatim`
|
|
81
|
+
* for a real value (--exposed), cleaned as a header's otherwise. */
|
|
82
|
+
read?: (verbatim: boolean) => Promise<string>): Promise<number>;
|
|
85
83
|
/** A booking's time on the command line: an ISO time, `now`, or HH:MM on this
|
|
86
84
|
* machine's clock. HH:MM is the next such time at or after `after` (the
|
|
87
85
|
* window's start for `--to`, so an end before the start is the next day, and
|