withruntime 0.45.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/dist/cli.js CHANGED
@@ -3200,14 +3200,19 @@ const KEYS_HELP = `runtime keys <command>
3200
3200
  account route, no MCP.
3201
3201
  ls This key and the keys it made, with what each spent today
3202
3202
  usage <keyId> What one of them has spent and holds
3203
+ update <keyId> [--daily-limit <usd> | --no-daily-limit] [--account-wide | --own-agent]
3204
+ Change a key's daily limit or reach. A key widens (account-wide, a larger
3205
+ limit, or none) only the keys it made, within its own limit; it narrows
3206
+ any key it sees, and never changes itself.
3203
3207
  revoke <keyId> Revoke one: a worker's key when the worker is done
3204
3208
 
3205
3209
  runtime keys create --name worker-1 --daily-limit 5
3210
+ runtime keys update <keyId> --daily-limit 10
3206
3211
  runtime keys create --name ci --daily-limit 25 --browser | gh secret set RUNTIME_API_KEY
3207
3212
  runtime keys create --name watcher --sandbox sbx_id --actions get,create --daily-limit 2
3208
3213
  runtime keys create --name helper --sandbox sbx_a,sbx_b --actions get,exec,read_file,write_file --browser
3209
3214
 
3210
- Making, listing and revoking keys with a key needs one an owner or admin made.
3215
+ Making, listing, changing and revoking keys with a key needs one an owner or admin made.
3211
3216
  Every key is also at https://withruntime.com/account/keys.
3212
3217
  `;
3213
3218
  /* `runtime keys`: a key made from the terminal, by this machine's key with no
@@ -3595,8 +3600,36 @@ async function keys(argv, env, out) {
3595
3600
  print(`Revoked ${revoked.keyId}. It stops working within ten seconds.`, revoked);
3596
3601
  return 0;
3597
3602
  }
3603
+ if (verb === "update") {
3604
+ const args = parse(rest, ["account-wide", "own-agent", "no-daily-limit"], ["daily-limit"]);
3605
+ const known = new Set(["account-wide", "own-agent", "no-daily-limit", "daily-limit"]);
3606
+ for (const name of args.flags.keys())
3607
+ if (!known.has(name))
3608
+ throw usage(`Unknown option --${name}.`);
3609
+ const id = args.positional[0];
3610
+ const shape = `Usage: ${named("runtime keys update <keyId> [--daily-limit <usd> | --no-daily-limit] [--account-wide | --own-agent]")}`;
3611
+ if (!id || args.positional.length > 1 || args.rest)
3612
+ throw usage(shape);
3613
+ if (has(args, "account-wide") && has(args, "own-agent"))
3614
+ throw usage("Give --account-wide or --own-agent, not both.");
3615
+ const limit = flag(args, "daily-limit");
3616
+ if (limit !== undefined && has(args, "no-daily-limit"))
3617
+ throw usage("Give --daily-limit or --no-daily-limit, not both.");
3618
+ const { dailyLimitMicros } = await import("./keys.js");
3619
+ const change = {
3620
+ ...(has(args, "account-wide") ? { reach: "account" } : {}),
3621
+ ...(has(args, "own-agent") ? { reach: "agent" } : {}),
3622
+ ...(limit !== undefined ? { dailyLimitMicros: dailyLimitMicros(limit) } : {}),
3623
+ ...(has(args, "no-daily-limit") ? { dailyLimitMicros: null } : {}),
3624
+ };
3625
+ if (!Object.keys(change).length)
3626
+ throw usage(shape);
3627
+ const updated = await (await client(env)).keys.update(id, change);
3628
+ print(`${updated.name} (${updated.keyId}): reach ${updated.reach}, daily limit ${updated.dailyLimitMicros === null ? "none" : usdOf(updated.dailyLimitMicros)}.`, updated);
3629
+ return 0;
3630
+ }
3598
3631
  if (verb !== "create")
3599
- throw unknown("keys command", verb, ["create", "ls", "usage", "revoke"]);
3632
+ throw unknown("keys command", verb, ["create", "ls", "usage", "update", "revoke"]);
3600
3633
  const args = parse(rest, ["read-only", "account-wide", "browser"], ["name", "daily-limit", "sandbox", "actions"]);
3601
3634
  const known = new Set([
3602
3635
  "name",
@@ -52,6 +52,14 @@ export type MadeKey = {
52
52
  /** The id of the key that made it. */
53
53
  madeBy: string;
54
54
  };
55
+ /** What `keys.update` changes: either or both. */
56
+ export type KeyChange = {
57
+ /** account: everything in the account (only from an account-wide key).
58
+ * agent: back to only what the key's own agent makes. */
59
+ reach?: "agent" | "account";
60
+ /** The most its agent may commit in any 24 hours, or null for none. */
61
+ dailyLimitMicros?: number | null;
62
+ };
55
63
  export type ListedKey = {
56
64
  keyId: string;
57
65
  agentId: string;
@@ -90,6 +98,10 @@ export declare function keys(t: Transport): {
90
98
  /** This key and the keys it made (every key, for an account-wide key),
91
99
  * live first, with what each spent in the last 24 hours. */
92
100
  list: (options?: RequestOptions) => Promise<ListedKey[]>;
101
+ /** Change a key's reach or daily limit (null removes it). A key widens
102
+ * only the keys it made, never past itself; it narrows any key it sees,
103
+ * and never changes itself. Returns the key as `list` shows it. */
104
+ update: (keyId: string, change: KeyChange, options?: RequestOptions) => Promise<ListedKey>;
93
105
  /** Revoke this key or one it made: a worker's, when the worker is done. */
94
106
  revoke: (keyId: string, options?: RequestOptions) => Promise<{
95
107
  keyId: string;
@@ -6,6 +6,15 @@ export function keys(t) {
6
6
  /** This key and the keys it made (every key, for an account-wide key),
7
7
  * live first, with what each spent in the last 24 hours. */
8
8
  list: async (options) => (await t.json({ method: "GET", path: "/v1/keys", ...options })).keys,
9
+ /** Change a key's reach or daily limit (null removes it). A key widens
10
+ * only the keys it made, never past itself; it narrows any key it sees,
11
+ * and never changes itself. Returns the key as `list` shows it. */
12
+ update: (keyId, change, options) => t.json({
13
+ method: "PATCH",
14
+ path: `/v1/keys/${encodeURIComponent(keyId)}`,
15
+ body: change,
16
+ ...options,
17
+ }),
9
18
  /** Revoke this key or one it made: a worker's, when the worker is done. */
10
19
  revoke: (keyId, options) => t.json({
11
20
  method: "DELETE",
@@ -1,5 +1,5 @@
1
1
  import { RuntimeError } from "./errors.js";
2
- export declare const VERSION = "0.45.0";
2
+ export declare const VERSION = "0.46.0";
3
3
  export declare const DEFAULT_BASE_URL = "https://api.withruntime.com";
4
4
  /** Runtime's API as code inside a Runtime sandbox reaches it: the sandbox's
5
5
  * own host sends each request on to DEFAULT_BASE_URL over HTTPS. The API runs
package/dist/transport.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ConnectionError, DELIBERATE, errorFor, NOTHING_RAN, RuntimeError, WAITS_FOR_ROOM, } from "./errors.js";
2
2
  import { describeRoute, envFetch, openWebSocket, untrustedCertificate } from "./proxy.js";
3
3
  import { warningText } from "./product-renames.js";
4
- export const VERSION = "0.45.0";
4
+ export const VERSION = "0.46.0";
5
5
  export const DEFAULT_BASE_URL = "https://api.withruntime.com";
6
6
  /** Runtime's API as code inside a Runtime sandbox reaches it: the sandbox's
7
7
  * own host sends each request on to DEFAULT_BASE_URL over HTTPS. The API runs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "withruntime",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "license": "Apache-2.0",
5
5
  "mcpName": "com.withruntime/runtime",
6
6
  "type": "module",