withruntime 0.17.2 → 0.21.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/COMPATIBILITY.md +32 -1
- package/README.md +19 -0
- package/README.src.md +19 -0
- package/dist/agents/index.d.ts +11 -0
- package/dist/agents/index.js +12 -0
- package/dist/agents-cli.d.ts +10 -0
- package/dist/agents-cli.js +362 -0
- package/dist/apps-cli.d.ts +14 -0
- package/dist/apps-cli.js +737 -0
- package/dist/builds/index.d.ts +10 -0
- package/dist/builds/index.js +11 -0
- package/dist/cli-words.js +11 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +104 -6
- package/dist/client.d.ts +19 -0
- package/dist/client.js +20 -0
- package/dist/cloudflare/errors.d.ts +23 -0
- package/dist/cloudflare/errors.js +16 -0
- package/dist/cloudflare/index.d.ts +82 -9
- package/dist/cloudflare/index.js +162 -38
- package/dist/cloudflare/interpreter.js +14 -5
- package/dist/cloudflare/mime.d.ts +1 -0
- package/dist/cloudflare/mime.js +66 -0
- package/dist/cloudflare/streams.d.ts +8 -0
- package/dist/cloudflare/streams.js +30 -0
- package/dist/cloudflare/types.d.ts +338 -0
- package/dist/cloudflare/types.js +80 -0
- package/dist/cloudflare/worker.d.ts +297 -10
- package/dist/cloudflare/worker.js +203 -17
- package/dist/containers/index.d.ts +10 -0
- package/dist/containers/index.js +11 -0
- package/dist/daytona/sandbox.d.ts +2 -1
- package/dist/daytona/sandbox.js +2 -1
- package/dist/identity.js +18 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/product-names.js +3 -0
- package/dist/products/agents.d.ts +272 -0
- package/dist/products/agents.js +251 -0
- package/dist/products/builds.d.ts +11 -1
- package/dist/products/builds.js +7 -0
- package/dist/products/containers.d.ts +71 -0
- package/dist/products/containers.js +6 -0
- package/dist/products/index.d.ts +6 -0
- package/dist/products/index.js +7 -0
- package/dist/sandbox.d.ts +4 -0
- package/dist/transport.d.ts +2 -2
- package/dist/transport.js +1 -1
- package/dist/tunnel.js +1 -1
- package/dist/types.d.ts +11 -0
- package/dist/vercel/errors.d.ts +1 -1
- package/package.json +16 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** `withruntime/builds`: Builds alone. An image built from a repository's
|
|
2
|
+
* commit, at the sandbox rates. In a private beta.
|
|
3
|
+
*
|
|
4
|
+
* import { builds } from "withruntime/builds";
|
|
5
|
+
* const client = builds(); // RUNTIME_API_KEY, or this machine's saved connection
|
|
6
|
+
*/
|
|
7
|
+
import { Runtime, type RuntimeOptions } from "../client.js";
|
|
8
|
+
export type * from "../products/builds.js";
|
|
9
|
+
/** `runtime.builds` of a client made with `options`. */
|
|
10
|
+
export declare function builds(options?: RuntimeOptions): Runtime["builds"];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** `withruntime/builds`: Builds alone. An image built from a repository's
|
|
2
|
+
* commit, at the sandbox rates. In a private beta.
|
|
3
|
+
*
|
|
4
|
+
* import { builds } from "withruntime/builds";
|
|
5
|
+
* const client = builds(); // RUNTIME_API_KEY, or this machine's saved connection
|
|
6
|
+
*/
|
|
7
|
+
import { Runtime } from "../client.js";
|
|
8
|
+
/** `runtime.builds` of a client made with `options`. */
|
|
9
|
+
export function builds(options) {
|
|
10
|
+
return new Runtime(options).builds;
|
|
11
|
+
}
|
package/dist/cli-words.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { me } from "./cli-name.js";
|
|
1
2
|
import { RuntimeError } from "./errors.js";
|
|
2
3
|
import { cliWords } from "./product-renames.js";
|
|
3
4
|
/* What the CLI says in its own words where the API's would mislead: the
|
|
@@ -25,6 +26,7 @@ const OPTIONS = {
|
|
|
25
26
|
image: { flag: "--image" },
|
|
26
27
|
snapshot: { flag: "--snapshot" },
|
|
27
28
|
spreadFrom: { flag: "--spread-from" },
|
|
29
|
+
secrets: { flag: "--secret / --no-secrets" },
|
|
28
30
|
volumes: { flag: "--volume" },
|
|
29
31
|
network: { flag: "--allow / --deny / --connect / --no-internet" },
|
|
30
32
|
maxCostMicros: { flag: "--max-cost", micros: true },
|
|
@@ -48,6 +50,15 @@ function issueWords(path, message) {
|
|
|
48
50
|
* a hint that names the options rather than the request's fields. Anything
|
|
49
51
|
* else is left as the API said it. */
|
|
50
52
|
export function cliRefusal(error) {
|
|
53
|
+
// A beta's refusal names the support tool an agent calls; here, the command.
|
|
54
|
+
if (error.code === "product_in_beta") {
|
|
55
|
+
const product = typeof error.details?.product === "string" ? error.details.product : "";
|
|
56
|
+
const open = (error.hint ?? "").replace(/;?\s*ask Runtime support \(runtime_support\) to join it\.?$/, ".");
|
|
57
|
+
return {
|
|
58
|
+
message: error.message,
|
|
59
|
+
hint: `${open ? `${open} ` : ""}Ask to join: ${me} support "Please add us to the ${product || "product"} beta"`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
51
62
|
const issues = error.details?.issues;
|
|
52
63
|
if (error.code === "invalid_request" && Array.isArray(issues) && issues.length) {
|
|
53
64
|
const lines = issues
|
package/dist/cli.d.ts
CHANGED
|
@@ -24,9 +24,13 @@ declare const kit: {
|
|
|
24
24
|
pairs: (args: Args, name: string) => {
|
|
25
25
|
[k: string]: string;
|
|
26
26
|
};
|
|
27
|
+
envPairs: (args: Args, from: NodeJS.ProcessEnv) => {
|
|
28
|
+
[k: string]: string;
|
|
29
|
+
};
|
|
27
30
|
need: (value: string | undefined, what: string) => string;
|
|
28
31
|
table: (rows: string[][]) => string;
|
|
29
32
|
usage: (message: string) => RuntimeError;
|
|
33
|
+
unknown: (what: string, word: string, choices: readonly string[]) => RuntimeError;
|
|
30
34
|
};
|
|
31
35
|
export type CliKit = typeof kit;
|
|
32
36
|
export declare function run(argv: string[], env?: NodeJS.ProcessEnv, out?: Out): Promise<number>;
|
package/dist/cli.js
CHANGED
|
@@ -38,6 +38,7 @@ Account
|
|
|
38
38
|
account switch <name|id> Use another of them for every command after
|
|
39
39
|
account add Connect another account (choose it in the browser)
|
|
40
40
|
account close --confirm "<account name>" Close the account for good (owner, key for every product)
|
|
41
|
+
account emails [<category> on|off] Your optional emails from Runtime: own-deletions, billing, usage, tips
|
|
41
42
|
audit [--action member.] [--limit 50] [--before <next>]
|
|
42
43
|
The account's audit log (owner or admin keys)
|
|
43
44
|
sso Single sign-on and SCIM directory sync (owner or
|
|
@@ -109,6 +110,10 @@ Products
|
|
|
109
110
|
images Custom images from a Dockerfile, any public or private image, or a package list
|
|
110
111
|
volumes Persistent disks to attach to sandboxes
|
|
111
112
|
jobs A command in a fresh sandbox, once or on a cron schedule, with its logs
|
|
113
|
+
apps Your web server from an image or a build, copies started by requests (beta)
|
|
114
|
+
builds A connected repository's commits built into what an App deploys (beta)
|
|
115
|
+
containers One OCI image's process on its own microVM, at the sandbox rates (beta)
|
|
116
|
+
agents Claude Code, Codex, Gemini CLI or your own agent in a sandbox per session (beta)
|
|
112
117
|
domains Your own hostname for a sandbox's port, with HTTPS
|
|
113
118
|
ports A public TCP port to a sandbox: databases, game servers
|
|
114
119
|
ips A dedicated outbound address, for allow-lists
|
|
@@ -134,7 +139,7 @@ const SANDBOX_HELP = `runtime sandboxes <command>
|
|
|
134
139
|
[--timeout <60-86400>] [--on-timeout pause|stop|delete] [--no-wait]
|
|
135
140
|
[--no-internet] [--allow <host>]... [--deny <host>]... [--connect <host:port>]...
|
|
136
141
|
[--image <name:tag|imageId> | --snapshot <snapshotId>] [--volume <volumeId>:/data[:snapshot]]...
|
|
137
|
-
[--spread-from <id>]...
|
|
142
|
+
[--spread-from <id>]... [--secret NAME]... [--no-secrets]
|
|
138
143
|
[--idle-pause <seconds>] [--no-auto-wake] [--persistent] [--get-or-create]
|
|
139
144
|
Create one; prints its id
|
|
140
145
|
ls [--all] [--label k=v]... [--state running] List (live ones unless --all)
|
|
@@ -181,7 +186,7 @@ const SANDBOX_HELP = `runtime sandboxes <command>
|
|
|
181
186
|
tailscale up <id> --auth-key-secret NAME [--hostname h] [--tag tag:x]...
|
|
182
187
|
Join your tailnet (paid); the key is a secret set with --jobs
|
|
183
188
|
tailscale status <id> | tailscale down <id> Its tailnet address; take it off the tailnet
|
|
184
|
-
fork <id> [--count 3] [--name n] [--keep-snapshot]
|
|
189
|
+
fork <id> [--count 3] [--name n] [--keep-snapshot] [--secret NAME]... [--no-secrets]
|
|
185
190
|
Copies of it as it is now, running; prints their ids
|
|
186
191
|
run-code <id> <file|-> [--lang python|javascript|typescript|r|java|bash|go] [--context c] [--out-dir .]
|
|
187
192
|
Run a notebook-style cell; charts saved as PNG
|
|
@@ -357,9 +362,11 @@ const kit = {
|
|
|
357
362
|
has,
|
|
358
363
|
integer,
|
|
359
364
|
pairs,
|
|
365
|
+
envPairs,
|
|
360
366
|
need: (value, what) => need(value, what),
|
|
361
367
|
table: (rows) => table(rows),
|
|
362
368
|
usage: (message) => usage(message),
|
|
369
|
+
unknown: (what, word, choices) => unknown(what, word, choices),
|
|
363
370
|
};
|
|
364
371
|
/** The product being run, so a mistake points at its own help. */
|
|
365
372
|
let product = "";
|
|
@@ -421,6 +428,10 @@ const COMMANDS = [
|
|
|
421
428
|
"images",
|
|
422
429
|
"volumes",
|
|
423
430
|
"jobs",
|
|
431
|
+
"apps",
|
|
432
|
+
"builds",
|
|
433
|
+
"containers",
|
|
434
|
+
"agents",
|
|
424
435
|
"domains",
|
|
425
436
|
"ports",
|
|
426
437
|
"ips",
|
|
@@ -439,6 +450,10 @@ const OWN_HELP = [
|
|
|
439
450
|
"images",
|
|
440
451
|
"volumes",
|
|
441
452
|
"jobs",
|
|
453
|
+
"apps",
|
|
454
|
+
"builds",
|
|
455
|
+
"containers",
|
|
456
|
+
"agents",
|
|
442
457
|
"keys",
|
|
443
458
|
"webhooks",
|
|
444
459
|
"webhook",
|
|
@@ -592,6 +607,20 @@ function describe(info) {
|
|
|
592
607
|
.map(([k, v]) => `${k}=${v}`)
|
|
593
608
|
.join(", ") || "-",
|
|
594
609
|
],
|
|
610
|
+
// Null is every egress secret that reaches it; [] is none. Absent from
|
|
611
|
+
// older servers, so no line then rather than a guess.
|
|
612
|
+
...(info.secrets === undefined
|
|
613
|
+
? []
|
|
614
|
+
: [
|
|
615
|
+
[
|
|
616
|
+
"secrets",
|
|
617
|
+
info.secrets === null
|
|
618
|
+
? "every one that reaches it"
|
|
619
|
+
: info.secrets.length
|
|
620
|
+
? info.secrets.join(", ")
|
|
621
|
+
: "none",
|
|
622
|
+
],
|
|
623
|
+
]),
|
|
595
624
|
["charged", dollars(BigInt(Math.round(Number(info.chargedMicros) || 0)))],
|
|
596
625
|
]);
|
|
597
626
|
}
|
|
@@ -1095,6 +1124,22 @@ export async function run(argv, env = process.env, out = defaultOut(argv)) {
|
|
|
1095
1124
|
product = "job";
|
|
1096
1125
|
return jobCommand(rest, env, out);
|
|
1097
1126
|
}
|
|
1127
|
+
if (command === "app" || command === "apps") {
|
|
1128
|
+
product = "apps";
|
|
1129
|
+
return (await import("./apps-cli.js")).appsCommand(rest, env, out, () => client(env), kit);
|
|
1130
|
+
}
|
|
1131
|
+
if (command === "build" || command === "builds") {
|
|
1132
|
+
product = "builds";
|
|
1133
|
+
return (await import("./apps-cli.js")).buildsCommand(rest, out, () => client(env), kit);
|
|
1134
|
+
}
|
|
1135
|
+
if (command === "container" || command === "containers") {
|
|
1136
|
+
product = "containers";
|
|
1137
|
+
return (await import("./apps-cli.js")).containersCommand(rest, env, out, () => client(env), kit);
|
|
1138
|
+
}
|
|
1139
|
+
if (command === "agent" || command === "agents") {
|
|
1140
|
+
product = "agents";
|
|
1141
|
+
return (await import("./agents-cli.js")).agentsCommand(rest, env, out, () => client(env), kit);
|
|
1142
|
+
}
|
|
1098
1143
|
// WireGuard is inside networks: `runtime networks wireguard peer add`.
|
|
1099
1144
|
const wireguard = command === "networks" && rest[0] === "wireguard";
|
|
1100
1145
|
const networkProduct = wireguard ? "wireguard" : command;
|
|
@@ -1421,6 +1466,11 @@ const DROP_IN = {
|
|
|
1421
1466
|
js: 'import { SandboxInstance } from "withruntime/blaxel"; // was: from "@blaxel/core"',
|
|
1422
1467
|
py: "from withruntime.blaxel import SandboxInstance # was: from blaxel.core import SandboxInstance",
|
|
1423
1468
|
},
|
|
1469
|
+
// A Worker-only SDK: no Python. More than the import changes, so say what.
|
|
1470
|
+
cloudflare: {
|
|
1471
|
+
js: 'import { getSandbox } from "withruntime/cloudflare"; // was: from "@cloudflare/sandbox"',
|
|
1472
|
+
also: "Change the `export { Sandbox }` line the same way, delete the `containers` block from the Wrangler config and run `npx wrangler secret put RUNTIME_API_KEY`.",
|
|
1473
|
+
},
|
|
1424
1474
|
};
|
|
1425
1475
|
/** How to move a rival's code across, when one import does it. */
|
|
1426
1476
|
export function dropInLines(provider) {
|
|
@@ -1428,9 +1478,10 @@ export function dropInLines(provider) {
|
|
|
1428
1478
|
if (!drop)
|
|
1429
1479
|
return [];
|
|
1430
1480
|
return [
|
|
1431
|
-
`Your ${RIVAL_NAMES[provider]} code runs on Runtime with one import changed:`,
|
|
1481
|
+
`Your ${RIVAL_NAMES[provider]} code runs on Runtime with ${drop.also ? "this import changed" : "one import changed"}:`,
|
|
1432
1482
|
` ${drop.js}`,
|
|
1433
|
-
` ${drop.py}
|
|
1483
|
+
...(drop.py ? [` ${drop.py}`] : []),
|
|
1484
|
+
...(drop.also ? [drop.also] : []),
|
|
1434
1485
|
];
|
|
1435
1486
|
}
|
|
1436
1487
|
/** A date as the CLI writes one: 23 September 2026. */
|
|
@@ -1872,12 +1923,14 @@ async function sandbox(argv, env, out) {
|
|
|
1872
1923
|
return 0;
|
|
1873
1924
|
}
|
|
1874
1925
|
case "fork": {
|
|
1875
|
-
const args = parse(rest, ["keep-snapshot", "trial", "paid"], ["count", "name"]);
|
|
1926
|
+
const args = parse(rest, ["keep-snapshot", "trial", "paid", "no-secrets"], ["count", "name", "secret"]);
|
|
1927
|
+
const secrets = secretsInput(args);
|
|
1876
1928
|
const sbx = await get(args.positional[0]);
|
|
1877
1929
|
const forks = await sbx.fork({
|
|
1878
1930
|
count: integer(args, "count") ?? 1,
|
|
1879
1931
|
...(flag(args, "name") ? { name: flag(args, "name") } : {}),
|
|
1880
1932
|
...(has(args, "keep-snapshot") ? { keepSnapshot: true } : {}),
|
|
1933
|
+
...secrets,
|
|
1881
1934
|
...(has(args, "trial")
|
|
1882
1935
|
? { funding: "trial" }
|
|
1883
1936
|
: has(args, "paid")
|
|
@@ -2729,8 +2782,28 @@ async function accountCommand(argv, env, out) {
|
|
|
2729
2782
|
].join("\n"), closed);
|
|
2730
2783
|
return 0;
|
|
2731
2784
|
}
|
|
2785
|
+
if (verb === "emails") {
|
|
2786
|
+
/* 0921: which of Runtime's optional emails this key's person gets.
|
|
2787
|
+
Bare, it lists them; `<category> on|off` changes one, for that person
|
|
2788
|
+
only. */
|
|
2789
|
+
const [category, state, ...extra] = rest;
|
|
2790
|
+
const categories = ["own-deletions", "billing", "usage", "tips"];
|
|
2791
|
+
if (extra.length || (category && !state) || (state && state !== "on" && state !== "off"))
|
|
2792
|
+
throw usage(`${me} account emails [<${categories.join("|")}> on|off]`);
|
|
2793
|
+
if (category && !categories.includes(category))
|
|
2794
|
+
throw unknown("email", category, [...categories]);
|
|
2795
|
+
const runtime = await client(env);
|
|
2796
|
+
const settings = await runtime.account.emails(category
|
|
2797
|
+
? { category: category, enabled: state === "on" }
|
|
2798
|
+
: undefined);
|
|
2799
|
+
print([
|
|
2800
|
+
...settings.map((each) => `${each.category.padEnd(14)}${each.enabled ? "on" : "off"}`),
|
|
2801
|
+
"Always sent: sign-in, invitations, revoked keys, support replies, credit expiry, service credits, and deletions Runtime decides.",
|
|
2802
|
+
].join("\n"), { settings });
|
|
2803
|
+
return 0;
|
|
2804
|
+
}
|
|
2732
2805
|
if (verb !== "ls" && verb !== "list")
|
|
2733
|
-
throw unknown("account command", verb, ["ls", "switch", "add", "close"]);
|
|
2806
|
+
throw unknown("account command", verb, ["ls", "switch", "add", "close", "emails"]);
|
|
2734
2807
|
await nameSaved(env).catch(() => undefined);
|
|
2735
2808
|
const current = await store.read().catch(() => null);
|
|
2736
2809
|
const saved = [
|
|
@@ -3733,6 +3806,7 @@ const CREATE_FLAGS = [
|
|
|
3733
3806
|
"no-auto-wake",
|
|
3734
3807
|
"persistent",
|
|
3735
3808
|
"get-or-create",
|
|
3809
|
+
"no-secrets",
|
|
3736
3810
|
];
|
|
3737
3811
|
/** Says on standard error, once for each reason, why a create has not
|
|
3738
3812
|
* answered yet: it is waiting for a slot without credit or room, which can take up to
|
|
@@ -3802,6 +3876,7 @@ const CREATE_VALUES = [
|
|
|
3802
3876
|
"image",
|
|
3803
3877
|
"snapshot",
|
|
3804
3878
|
"spread-from",
|
|
3879
|
+
"secret",
|
|
3805
3880
|
"volume",
|
|
3806
3881
|
"env",
|
|
3807
3882
|
];
|
|
@@ -3820,6 +3895,28 @@ function usdMicros(args, name) {
|
|
|
3820
3895
|
throw usage(`--${name} is too large to represent exactly in microdollars.`);
|
|
3821
3896
|
return Number(micros);
|
|
3822
3897
|
}
|
|
3898
|
+
/** The egress secrets a new sandbox may use: each --secret adds a name
|
|
3899
|
+
* (commas also separate them), --no-secrets is none, and neither leaves it
|
|
3900
|
+
* out, for every secret that reaches it. Fixed for the sandbox's life. */
|
|
3901
|
+
function secretsInput(args) {
|
|
3902
|
+
const names = args.flags.get("secret");
|
|
3903
|
+
if (has(args, "no-secrets")) {
|
|
3904
|
+
if (names)
|
|
3905
|
+
throw usage("Give --secret or --no-secrets, not both.");
|
|
3906
|
+
return { secrets: [] };
|
|
3907
|
+
}
|
|
3908
|
+
if (!names)
|
|
3909
|
+
return {};
|
|
3910
|
+
return {
|
|
3911
|
+
secrets: names
|
|
3912
|
+
.flatMap((value) => value.split(","))
|
|
3913
|
+
.map((name) => {
|
|
3914
|
+
if (!name.trim())
|
|
3915
|
+
throw usage("--secret needs a non-empty value.");
|
|
3916
|
+
return name.trim();
|
|
3917
|
+
}),
|
|
3918
|
+
};
|
|
3919
|
+
}
|
|
3823
3920
|
/** A create body from the command line's flags. */
|
|
3824
3921
|
function createInput(args, env) {
|
|
3825
3922
|
for (const name of ["image", "snapshot", "volume", "name", "region", "connect"])
|
|
@@ -3841,6 +3938,7 @@ function createInput(args, env) {
|
|
|
3841
3938
|
}),
|
|
3842
3939
|
}
|
|
3843
3940
|
: {}),
|
|
3941
|
+
...secretsInput(args),
|
|
3844
3942
|
...(args.flags.has("volume") ? { volumes: args.flags.get("volume").map(attachment) } : {}),
|
|
3845
3943
|
...(has(args, "no-internet") || rules.length
|
|
3846
3944
|
? {
|
package/dist/client.d.ts
CHANGED
|
@@ -153,6 +153,16 @@ export type ClosedAccount = {
|
|
|
153
153
|
/** False while what was running is still stopping; it is gone within minutes. */
|
|
154
154
|
released: boolean;
|
|
155
155
|
};
|
|
156
|
+
/** One of Runtime's optional emails: `own-deletions` (warnings for dates
|
|
157
|
+
* the account's own retention set), `billing` (credit low or out), `usage`
|
|
158
|
+
* (the month's free usage at 80% and all) or `tips` (getting started). */
|
|
159
|
+
export type EmailCategory = "own-deletions" | "billing" | "usage" | "tips";
|
|
160
|
+
/** Whether this key's person gets one optional email, in this account. */
|
|
161
|
+
export type EmailSetting = {
|
|
162
|
+
category: EmailCategory;
|
|
163
|
+
enabled: boolean;
|
|
164
|
+
updatedAt: string | null;
|
|
165
|
+
};
|
|
156
166
|
/** The account this key belongs to: `runtime.account`. */
|
|
157
167
|
export declare class AccountApi {
|
|
158
168
|
private readonly t;
|
|
@@ -162,6 +172,15 @@ export declare class AccountApi {
|
|
|
162
172
|
* name exactly (`me().orgName`). Needs a key for every product made by an
|
|
163
173
|
* owner. Moves no money: what is unspent of a purchase made in the last 15
|
|
164
174
|
* days is refunded on request; other credit is forfeited. */
|
|
175
|
+
/** Which of Runtime's optional emails this key's person gets for this
|
|
176
|
+
* account. Without `set`, reads them; with `{ category, enabled }`, turns
|
|
177
|
+
* one on or off for that person only, and answers all of them. Sign-in,
|
|
178
|
+
* support replies, credit expiry and deletions Runtime decides are always
|
|
179
|
+
* sent and are not listed. */
|
|
180
|
+
emails(set?: {
|
|
181
|
+
category: EmailCategory;
|
|
182
|
+
enabled: boolean;
|
|
183
|
+
}, options?: RequestOptions): Promise<EmailSetting[]>;
|
|
165
184
|
close(input: {
|
|
166
185
|
confirm: string;
|
|
167
186
|
}, options?: RequestOptions): Promise<ClosedAccount>;
|
package/dist/client.js
CHANGED
|
@@ -167,6 +167,26 @@ export class AccountApi {
|
|
|
167
167
|
* name exactly (`me().orgName`). Needs a key for every product made by an
|
|
168
168
|
* owner. Moves no money: what is unspent of a purchase made in the last 15
|
|
169
169
|
* days is refunded on request; other credit is forfeited. */
|
|
170
|
+
/** Which of Runtime's optional emails this key's person gets for this
|
|
171
|
+
* account. Without `set`, reads them; with `{ category, enabled }`, turns
|
|
172
|
+
* one on or off for that person only, and answers all of them. Sign-in,
|
|
173
|
+
* support replies, credit expiry and deletions Runtime decides are always
|
|
174
|
+
* sent and are not listed. */
|
|
175
|
+
async emails(set, options = {}) {
|
|
176
|
+
const answer = set
|
|
177
|
+
? await this.t.json({
|
|
178
|
+
method: "POST",
|
|
179
|
+
path: "/v1/account/emails:update",
|
|
180
|
+
body: { category: set.category, enabled: set.enabled },
|
|
181
|
+
...options,
|
|
182
|
+
})
|
|
183
|
+
: await this.t.json({
|
|
184
|
+
method: "GET",
|
|
185
|
+
path: "/v1/account/emails",
|
|
186
|
+
...options,
|
|
187
|
+
});
|
|
188
|
+
return answer.settings;
|
|
189
|
+
}
|
|
170
190
|
close(input, options = {}) {
|
|
171
191
|
return this.t.json({
|
|
172
192
|
method: "POST",
|
|
@@ -119,6 +119,29 @@ export declare class OperationInterruptedError extends SandboxError<{
|
|
|
119
119
|
}> {
|
|
120
120
|
get reason(): string;
|
|
121
121
|
}
|
|
122
|
+
/** Cloudflare's transport error for its WebSocket sessions; Runtime's API
|
|
123
|
+
* has no such session, so the adapter never throws it. */
|
|
124
|
+
export declare class RPCTransportError extends SandboxError<{
|
|
125
|
+
kind: string;
|
|
126
|
+
originalMessage: string;
|
|
127
|
+
}> {
|
|
128
|
+
get kind(): string;
|
|
129
|
+
get originalMessage(): string;
|
|
130
|
+
}
|
|
131
|
+
/** Input the container refuses, such as content that is not base64. */
|
|
132
|
+
export declare class ValidationFailedError extends SandboxError<{
|
|
133
|
+
validationErrors: {
|
|
134
|
+
field: string;
|
|
135
|
+
message: string;
|
|
136
|
+
code: string;
|
|
137
|
+
}[];
|
|
138
|
+
}> {
|
|
139
|
+
get validationErrors(): {
|
|
140
|
+
field: string;
|
|
141
|
+
message: string;
|
|
142
|
+
code: string;
|
|
143
|
+
}[];
|
|
144
|
+
}
|
|
122
145
|
export declare class BucketMountError extends Error {
|
|
123
146
|
readonly code: string;
|
|
124
147
|
constructor(message: string, code?: string);
|
|
@@ -125,6 +125,22 @@ export class OperationInterruptedError extends SandboxError {
|
|
|
125
125
|
return this.context.reason;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
+
/** Cloudflare's transport error for its WebSocket sessions; Runtime's API
|
|
129
|
+
* has no such session, so the adapter never throws it. */
|
|
130
|
+
export class RPCTransportError extends SandboxError {
|
|
131
|
+
get kind() {
|
|
132
|
+
return this.context.kind;
|
|
133
|
+
}
|
|
134
|
+
get originalMessage() {
|
|
135
|
+
return this.context.originalMessage;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** Input the container refuses, such as content that is not base64. */
|
|
139
|
+
export class ValidationFailedError extends SandboxError {
|
|
140
|
+
get validationErrors() {
|
|
141
|
+
return this.context.validationErrors;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
128
144
|
export class BucketMountError extends Error {
|
|
129
145
|
code;
|
|
130
146
|
constructor(message, code = "BUCKET_MOUNT_ERROR") {
|
|
@@ -6,8 +6,11 @@ export { CompatibilityError };
|
|
|
6
6
|
export * from "./errors.js";
|
|
7
7
|
export { CodeInterpreter } from "./interpreter.js";
|
|
8
8
|
export type { CodeContext, CreateContextOptions, ExecutionError, OutputMessage, RunCodeOptions, } from "./interpreter.js";
|
|
9
|
-
export { collectFile, isExecResult, isProcess, isProcessStatus, parseSSEStream, streamFile, } from "./streams.js";
|
|
9
|
+
export { collectFile, isExecResult, isProcess, isProcessStatus, parseSSEStream, streamFile, asyncIterableToSSEStream, responseToAsyncIterable, } from "./streams.js";
|
|
10
10
|
export type { FileChunk, FileMetadata, FileStreamEvent } from "./streams.js";
|
|
11
|
+
export * from "./types.js";
|
|
12
|
+
/** Cloudflare's interface for its Sandbox class. */
|
|
13
|
+
export type ISandbox = Sandbox;
|
|
11
14
|
export declare class SandboxSecurityError extends Error {
|
|
12
15
|
readonly code: string;
|
|
13
16
|
constructor(message: string, code: string);
|
|
@@ -58,6 +61,13 @@ export type CheckChangesResult = {
|
|
|
58
61
|
version: string;
|
|
59
62
|
timestamp: string;
|
|
60
63
|
};
|
|
64
|
+
export interface GitCheckoutOptions {
|
|
65
|
+
branch?: string;
|
|
66
|
+
targetDir?: string;
|
|
67
|
+
sessionId?: string;
|
|
68
|
+
depth?: number;
|
|
69
|
+
cloneTimeoutMs?: number;
|
|
70
|
+
}
|
|
61
71
|
export interface GitCheckoutResult {
|
|
62
72
|
success: boolean;
|
|
63
73
|
repoUrl: string;
|
|
@@ -96,6 +106,7 @@ export interface ReadFileResult {
|
|
|
96
106
|
content: string;
|
|
97
107
|
encoding: "utf-8" | "base64";
|
|
98
108
|
isBinary: boolean;
|
|
109
|
+
mimeType: string;
|
|
99
110
|
size: number;
|
|
100
111
|
timestamp: string;
|
|
101
112
|
}
|
|
@@ -115,6 +126,16 @@ export interface SessionOptions {
|
|
|
115
126
|
isolation?: boolean;
|
|
116
127
|
commandTimeoutMs?: number;
|
|
117
128
|
}
|
|
129
|
+
export interface WaitForPortOptions {
|
|
130
|
+
mode?: "http" | "tcp";
|
|
131
|
+
path?: string;
|
|
132
|
+
status?: number | {
|
|
133
|
+
min: number;
|
|
134
|
+
max: number;
|
|
135
|
+
};
|
|
136
|
+
timeout?: number;
|
|
137
|
+
interval?: number;
|
|
138
|
+
}
|
|
118
139
|
export interface ProcessOptions {
|
|
119
140
|
timeout?: number;
|
|
120
141
|
env?: Record<string, string | undefined>;
|
|
@@ -312,13 +333,7 @@ export declare class Sandbox {
|
|
|
312
333
|
signal?: AbortSignal;
|
|
313
334
|
}): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
|
|
314
335
|
/** Clones with git in the sandbox, as Cloudflare's container does. */
|
|
315
|
-
gitCheckout(repoUrl: string, options?:
|
|
316
|
-
branch?: string;
|
|
317
|
-
targetDir?: string;
|
|
318
|
-
sessionId?: string;
|
|
319
|
-
depth?: number;
|
|
320
|
-
cloneTimeoutMs?: number;
|
|
321
|
-
}): Promise<GitCheckoutResult>;
|
|
336
|
+
gitCheckout(repoUrl: string, options?: GitCheckoutOptions): Promise<GitCheckoutResult>;
|
|
322
337
|
/** Changes under a directory as `data:` lines of Cloudflare's watch events,
|
|
323
338
|
* once the watch is established, until the stream is cancelled. */
|
|
324
339
|
watch(path: string, options?: WatchOptions): Promise<ReadableStream<Uint8Array>>;
|
|
@@ -442,6 +457,57 @@ export declare class ExecutionSession {
|
|
|
442
457
|
timestamp: string;
|
|
443
458
|
}>;
|
|
444
459
|
setEnvVars(env: Record<string, string | undefined>): Promise<void>;
|
|
460
|
+
moveFile(path: string, newPath: string): Promise<{
|
|
461
|
+
success: boolean;
|
|
462
|
+
path: string;
|
|
463
|
+
newPath: string;
|
|
464
|
+
timestamp: string;
|
|
465
|
+
}>;
|
|
466
|
+
readFileStream(path: string): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
|
|
467
|
+
gitCheckout(repoUrl: string, options?: Omit<GitCheckoutOptions, "sessionId">): Promise<GitCheckoutResult>;
|
|
468
|
+
watch(path: string, options?: Omit<WatchOptions, "sessionId">): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
|
|
469
|
+
checkChanges(path: string, options?: Omit<CheckChangesOptions, "sessionId">): Promise<CheckChangesResult>;
|
|
470
|
+
listProcesses(): Promise<Process[]>;
|
|
471
|
+
getProcess(id: string): Promise<Process | null>;
|
|
472
|
+
killProcess(id: string, signal?: string): Promise<void>;
|
|
473
|
+
killAllProcesses(): Promise<number>;
|
|
474
|
+
cleanupCompletedProcesses(): Promise<number>;
|
|
475
|
+
getProcessLogs(id: string): Promise<{
|
|
476
|
+
stdout: string;
|
|
477
|
+
stderr: string;
|
|
478
|
+
processId: string;
|
|
479
|
+
}>;
|
|
480
|
+
streamProcessLogs(id: string, options?: {
|
|
481
|
+
signal?: AbortSignal;
|
|
482
|
+
}): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
|
|
483
|
+
createCodeContext(options?: CreateContextOptions): Promise<CodeContext>;
|
|
484
|
+
runCode(code: string, options?: RunCodeOptions): Promise<{
|
|
485
|
+
code: string;
|
|
486
|
+
logs: {
|
|
487
|
+
stdout: string[];
|
|
488
|
+
stderr: string[];
|
|
489
|
+
};
|
|
490
|
+
error: import("./interpreter.js").ExecutionError | undefined;
|
|
491
|
+
executionCount: number | undefined;
|
|
492
|
+
results: {
|
|
493
|
+
text: string | undefined;
|
|
494
|
+
html: string | undefined;
|
|
495
|
+
png: string | undefined;
|
|
496
|
+
jpeg: string | undefined;
|
|
497
|
+
svg: string | undefined;
|
|
498
|
+
latex: string | undefined;
|
|
499
|
+
markdown: string | undefined;
|
|
500
|
+
javascript: string | undefined;
|
|
501
|
+
json: unknown;
|
|
502
|
+
chart: undefined;
|
|
503
|
+
data: Record<string, unknown> | undefined;
|
|
504
|
+
}[];
|
|
505
|
+
}>;
|
|
506
|
+
runCodeStream(code: string, options?: RunCodeOptions): Promise<ReadableStream<any>>;
|
|
507
|
+
listCodeContexts(): Promise<CodeContext[]>;
|
|
508
|
+
deleteCodeContext(contextId: string): Promise<void>;
|
|
509
|
+
mountBucket(bucket: string, mountPath: string, options: MountBucketOptions): Promise<void>;
|
|
510
|
+
unmountBucket(mountPath: string): Promise<void>;
|
|
445
511
|
}
|
|
446
512
|
export declare class Process {
|
|
447
513
|
#private;
|
|
@@ -466,7 +532,14 @@ export declare class Process {
|
|
|
466
532
|
exitCode: number;
|
|
467
533
|
}>;
|
|
468
534
|
waitForLog(pattern: string | RegExp, timeout?: number): Promise<{
|
|
469
|
-
match?: true | RegExpMatchArray | undefined;
|
|
470
535
|
line: string;
|
|
536
|
+
match?: undefined;
|
|
537
|
+
} | {
|
|
538
|
+
line: string;
|
|
539
|
+
match: RegExpMatchArray;
|
|
471
540
|
}>;
|
|
541
|
+
/** Resolves once the port answers: an HTTP status in range (200-399 by
|
|
542
|
+
* default) at `path`, or a TCP connection in `tcp` mode. Throws if the
|
|
543
|
+
* process ends first, or after `timeout` milliseconds when one is given. */
|
|
544
|
+
waitForPort(port: number, options?: WaitForPortOptions): Promise<void>;
|
|
472
545
|
}
|