@b3os/cli 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +69 -26
  2. package/bin/b3os.js +13 -3
  3. package/dist/commands/_common.d.ts +49 -0
  4. package/dist/commands/_common.js +174 -0
  5. package/dist/commands/_common.js.map +1 -0
  6. package/dist/commands/actions.d.ts +43 -0
  7. package/dist/commands/actions.js +184 -0
  8. package/dist/commands/actions.js.map +1 -0
  9. package/dist/commands/api.d.ts +24 -0
  10. package/dist/commands/api.js +14 -8
  11. package/dist/commands/api.js.map +1 -1
  12. package/dist/commands/auth.d.ts +58 -0
  13. package/dist/commands/auth.js +215 -19
  14. package/dist/commands/auth.js.map +1 -1
  15. package/dist/commands/bench.d.ts +22 -0
  16. package/dist/commands/bench.js +19 -7
  17. package/dist/commands/bench.js.map +1 -1
  18. package/dist/commands/connect.d.ts +52 -0
  19. package/dist/commands/connect.js +221 -0
  20. package/dist/commands/connect.js.map +1 -0
  21. package/dist/commands/infer.d.ts +47 -0
  22. package/dist/commands/infer.js +152 -0
  23. package/dist/commands/infer.js.map +1 -0
  24. package/dist/commands/init.d.ts +45 -0
  25. package/dist/commands/init.js +267 -0
  26. package/dist/commands/init.js.map +1 -0
  27. package/dist/commands/keys.d.ts +42 -0
  28. package/dist/commands/keys.js +70 -38
  29. package/dist/commands/keys.js.map +1 -1
  30. package/dist/commands/manifest.d.ts +13 -0
  31. package/dist/commands/manifest.js +117 -0
  32. package/dist/commands/manifest.js.map +1 -0
  33. package/dist/commands/mcp.d.ts +65 -0
  34. package/dist/commands/mcp.js +167 -50
  35. package/dist/commands/mcp.js.map +1 -1
  36. package/dist/commands/render.d.ts +119 -0
  37. package/dist/commands/render.js +294 -0
  38. package/dist/commands/render.js.map +1 -0
  39. package/dist/commands/requests.d.ts +34 -0
  40. package/dist/commands/requests.js +63 -0
  41. package/dist/commands/requests.js.map +1 -0
  42. package/dist/commands/routine.d.ts +53 -1
  43. package/dist/commands/routine.js +246 -110
  44. package/dist/commands/routine.js.map +1 -1
  45. package/dist/commands/sandbox.d.ts +130 -0
  46. package/dist/commands/sandbox.js +327 -55
  47. package/dist/commands/sandbox.js.map +1 -1
  48. package/dist/commands/vision.d.ts +196 -0
  49. package/dist/commands/vision.js +478 -0
  50. package/dist/commands/vision.js.map +1 -0
  51. package/dist/commands/webhooks.d.ts +20 -0
  52. package/dist/commands/webhooks.js +76 -0
  53. package/dist/commands/webhooks.js.map +1 -0
  54. package/dist/ctx.d.ts +80 -6
  55. package/dist/ctx.js +233 -24
  56. package/dist/ctx.js.map +1 -1
  57. package/dist/main.d.ts +4 -1
  58. package/dist/main.js +72 -40
  59. package/dist/main.js.map +1 -1
  60. package/dist/manifest/load.d.ts +143 -0
  61. package/dist/manifest/load.js +279 -0
  62. package/dist/manifest/load.js.map +1 -0
  63. package/dist/manifest/plan.d.ts +52 -0
  64. package/dist/manifest/plan.js +628 -0
  65. package/dist/manifest/plan.js.map +1 -0
  66. package/dist/registry.d.ts +19 -0
  67. package/dist/registry.js +52 -0
  68. package/dist/registry.js.map +1 -0
  69. package/dist/suggest.d.ts +9 -0
  70. package/dist/suggest.js +51 -0
  71. package/dist/suggest.js.map +1 -0
  72. package/package.json +8 -5
  73. package/schemas/b3os.v0.schema.json +244 -0
  74. package/dist/commands/web.d.ts +0 -4
  75. package/dist/commands/web.js +0 -205
  76. package/dist/commands/web.js.map +0 -1
package/README.md CHANGED
@@ -1,13 +1,17 @@
1
1
  # @b3os/cli
2
2
 
3
- The B3OS command line, built on `@b3os/sdk`. Every command takes `--json` (machine-readable stdout), `--yes`
4
- (skip confirmations), `--quiet`, `--api-key`, `--base-url`, `--timeout MS` and `--help`. Without a terminal it never
5
- prompts: a destructive command without `--yes` exits 2.
3
+ The B3OS command line, built on `@b3os/sdk` (benchmarks and raw data: https://beta.b3os.org/benchmarks). Every
4
+ command takes `--json` (machine-readable stdout), `--yes` (skip confirmations), `--quiet`, `--api-key`, `--base-url`,
5
+ `--request-timeout-ms MS` (how long to wait for each answer) and `--help`. Without a terminal it never prompts: a
6
+ destructive command without `--yes` exits 2. An option takes the name of the request field it sets
7
+ (`sandbox create --timeout-s` sets `timeout_s`, `crawl --max-depth` sets `max_depth`); the older names of options
8
+ and subcommands (`--lifetime`, `routine deploy`, ...) still work.
9
+ `b3os help <command> [<sub>]` (or `b3os <command> <sub> --help`) prints the help of one command or subcommand.
6
10
 
7
- Install `@b3os/cli` to get the `b3os` executable, or run a command with `npx @b3os/cli <command>`.
11
+ Install `@b3os/cli` to get the `b3os` executable, or run a command with `npx -y @b3os/cli@0.1 <command>`.
8
12
 
9
13
  ```sh
10
- npm install --global @b3os/cli
14
+ npm install --global @b3os/cli@0.1
11
15
  b3os login # device login; stores a CLI token
12
16
  b3os scrape https://example.com # Markdown on stdout
13
17
  b3os screenshot https://example.com --out shot.png --frame browser-dark
@@ -21,34 +25,64 @@ b3os mcp install --client claude
21
25
  ## Credentials
22
26
 
23
27
  `--api-key`, else `B3OS_API_KEY`, else the token from `b3os login` (`$XDG_CONFIG_HOME/b3os/credentials.json`, default
24
- `~/.config/b3os/`, mode 0600). `b3os whoami` shows which one is in use, its org, project and scopes, and where node
28
+ `~/.config/b3os/`, mode 0600). The token goes only to the API host it was issued by, as in the SDKs: with
29
+ `--base-url` or `B3OS_BASE_URL` naming another host, the CLI has no credential and says so. `b3os whoami` shows which one is in use, its org, project and scopes, and where node
25
30
  operations go. Inside a B3OS sandbox node operations use `B3OS_API_URL`. On a node they use b3osd's Unix socket
26
31
  when `B3OS_SOCKET` is set, or when no key and no base URL are configured; over the socket the command acts as the
27
32
  principal your uid maps to, not as a key's (see the SDK README for the routing rules).
28
33
 
29
34
  `b3os login` runs the RFC 8628 device flow: it prints the dashboard URL and the code to confirm (and opens a browser
30
- when there is a terminal), then polls until you approve. The token is never printed. `--scope 'vision:run
31
- sandboxes:*'` asks for fewer scopes.
35
+ when there is a terminal), then polls until you approve. A poll that fails on the way (lost connection, timeout,
36
+ 5xx) is repeated, up to five in a row; a denied or expired code ends the login (exit 3). The token is never printed.
37
+ `--scope vision:run,sandboxes:*` asks for fewer scopes. The token lasts 30 days. `b3os logout` revokes it on the
38
+ server and removes the file; if the server cannot be reached, it keeps the file, so you can run it again, and exits
39
+ non-zero. `--local` only removes the file, and the token works until it expires.
40
+
41
+ A routine you publish while signed in runs as the token, and its triggers pause when the token is revoked or
42
+ expires; a key you create while signed in cannot outlive it. Publish routines and make CI keys with an API key from
43
+ the dashboard (`B3OS_API_KEY`). `routine publish` says when a routine runs as the login, and `logout` names the
44
+ routines that run as it and asks before it revokes the token (`--yes` without a terminal).
32
45
 
33
46
  ## Commands
34
47
 
35
48
  | Command | What it does |
36
49
  |---|---|
37
- | `login`, `logout`, `whoami` | device login, remove the stored token, show the credential in use |
38
- | `keys list\|create\|get\|update\|revoke` | API keys (`create --name ci --scope vision:run,sandboxes:*` prints the secret once) |
39
- | `scrape <url>` | `vision.scrape`; `--format markdown\|html\|raw_html\|text\|links\|json`, `--all-content`, `--engine`, `--no-cache`, `--header K=V`, `--out` |
40
- | `screenshot <url>` | `render.createScreenshot`; saves the image (`--out`, `--format png\|webp\|jpeg`, `--width`/`--height`, `--dpr`, `--full-page`, `--selector`, `--background`, `--frame`, `--theme`, `--hide`, `--html FILE`) |
41
- | `video <script.json>` | `render.createVideo`; streams progress, saves the MP4 (`--kind mp4\|gif\|poster\|vtt`, `--no-wait`) |
42
- | `sandbox create` | `--template`, `--snapshot`, `--vcpu`, `--memory`, `--disk`, `--lifetime S`, `--on-idle`, `--env K=V`, `--port N[:public]`, `--grant SCOPES` |
43
- | `sandbox exec <id> -- <cmd…>` | streams stdout and stderr; exits 0 when the command exits 0, else 10 with the remote code on stderr (`--exit-code` passes the remote code through instead); `--json` prints the buffered result; `--stdin` sends local stdin; `--background` |
50
+ | `login`, `logout`, `whoami` | device login, revoke and remove the stored token, show the credential in use |
51
+ | `keys ls\|create\|get\|update\|revoke` | API keys and CLI tokens (`ls --kind api_key\|cli_token`; `create --name ci --scope vision:run,sandboxes:*` prints the secret once; signed in with `b3os login`, `--expires-at` defaults to the CLI token's expiry and may not be later; `--spend-cap-usd`, `--project-id`) |
52
+ | `scrape <url>` | `vision.scrape`; `--format markdown\|html\|raw_html\|text\|links\|json`, `--all-content`, `--engine`, `--wait-for-ms`, `--max-age-ms` or `--no-cache`, `--header K=V`, `--respect-robots` (check robots.txt first; off by default, decision D10), `--out` |
53
+ | `scrape <url> <url> …` | one batch job with the same options: waits and prints each page as Markdown (`--max-concurrency N`, `--out FILE` JSON lines, `--no-wait` prints the `batch_` id) |
54
+ | `screenshot <url>` | `render.createScreenshot`; saves the image and prints its `shot_` ID on stderr. `--out FILE`'s extension picks the format (`.webp`, `.png`, `.jpg`; WebP by default, `screenshot.webp`), and `--format` must agree with it. Also `--width`/`--height`, `--dpr`, `--full-page`, `--selector`, `--background`, `--frame`, `--theme`, `--hide`, `--html FILE` |
55
+ | `screenshot ls\|rm <shot_…>…` | your screenshots, newest first (kept 7 days); `rm` deletes them (asks unless `--yes`) |
56
+ | `video <script.json>` | `render.createVideo`; prints the `vid_` ID on stderr with the first event, streams progress, saves the MP4. `--formats mp4,gif,poster` sets the request's formats; `--out FILE`'s extension picks the file saved (`.mp4`, `.gif`, `.jpg` for the poster, `.vtt` or `.srt`), or `--kind` names the artifact; `--no-wait` |
57
+ | `video ls\|rm <vid_…>…` | your videos (`ls --status running`); `rm` cancels one still rendering, then deletes it (asks unless `--yes`) |
58
+ | `sandbox create` | `--template`, `--snapshot`, `--vcpu`, `--memory-mib`, `--disk-gib`, `--timeout-s S`, `--on-timeout stop\|pause` (the API's `on_idle`), `--env K=V`, `--port N[:public]`, `--api-scope SCOPES` |
59
+ | `sandbox exec <id> -- <cmd…>` | streams stdout and stderr; exits 0 when the command exits 0, else 10 with the remote code on stderr (`--exit-code` passes the remote code through instead); `--json` prints the buffered result; `--stdin` sends local stdin; `--background` prints the pid on stdout and returns |
44
60
  | `sandbox shell <id>` | a terminal over the ticketed PTY WebSocket (raw mode, resize follows your window) |
45
- | `sandbox ls\|get\|logs\|url\|rm` | list, inspect, follow background logs, get a port URL, delete |
46
- | `routine deploy <file>` | publishes YAML or JSON by its `name` (`PUT /v1/routines/{name}` creates on first deploy) |
47
- | `routine run <routine>` | `--input JSON\|@file`; waits and prints the output; `--follow` streams step events; `--no-wait` prints the run id |
61
+ | `sandbox ls\|get\|logs\|port-url\|rm` | list, inspect, follow background logs, get a URL for a port named at create (`--port N`; `port-url --ttl-s`), delete |
62
+ | `sandbox fork <id> [--count N]` | copies of a running sandbox; prints their ids |
63
+ | `sandbox pause\|resume\|snapshot\|timeout\|cp\|run-code\|wait` | pause and resume; `snapshot <id>` prints the `snap_` id; `timeout <id> <s>`; `cp ./f sbx_…:/path` and back; `run-code <id> -- <code>` in the Jupyter kernel (a sandbox from `--template code-interpreter`); `wait <id> --port N` (or `--http URL`, `--exec CMD`) until a program in it is ready |
64
+ | `sandbox snapshots [ls]\|get <snap_…>\|rm <snap_…>…` | list, inspect and delete snapshots (`rm` asks unless `--yes`) |
65
+ | `sandbox templates [ls]\|get <name>` | the templates `create --template` can start from |
66
+ | `sandbox ps <id>`, `sandbox kill <id> <pid> [--signal TERM\|KILL\|INT\|HUP]` | background processes and their status; signal one and its process group |
67
+ | `routine publish <file>` | publishes YAML or JSON by its `name` (`PUT /v1/routines/{name}` creates it on first publish) |
68
+ | `routine run <routine>` | `--input JSON\|@file`; waits and prints the output, with the run ID on stderr; `--follow` streams step events; `--no-wait` prints the run id |
48
69
  | `routine logs <run_id>` | the run's steps, or `--follow` its events |
49
- | `action search\|describe\|run` | marketplace actions (`run io.b3os/github/create-issue@1 --input @issue.json`) |
70
+ | `routine ls\|get\|runs <routine>` | routines with their next scheduled run; one routine's version, status and triggers; its runs (`--status failed`) |
71
+ | `routine pause\|resume\|rm <routine>` | stop or restart its triggers (API runs work either way); `rm` deletes it, removes its triggers and cancels its active runs (asks unless `--yes`) |
72
+ | `routine versions\|rollback\|signal\|cancel\|import` | versions; `rollback <routine> --version N`; `signal <run_id> <name> --payload JSON`; `import <workflow.json> [--publish]` (a workflow from the original B3OS app) |
73
+ | `map <url>` | a site's URLs, one per line (`--search` ranks them; `--no-include-subdomains`; `--respect-robots` refuses a disallowed start URL) |
74
+ | `crawl <url>` | waits and prints every page as Markdown (`--max-depth`, `--include-paths`, `--exclude-paths`, `--include-subdomains`; `--out FILE` JSON lines, `--no-wait`; `--respect-robots` skips disallowed pages) |
75
+ | `session create\|act\|cdp\|save-profile\|ls\|close` | browser sessions: `act <brs_id> --actions JSON\|@file`, `cdp` prints a CDP URL for Playwright, `save-profile <brs_id> --name NAME` saves its sign-ins now |
76
+ | `profile ls\|get\|rm` | saved browser profiles (sign-ins) that sessions and scrapes reuse with `--profile NAME` (a scrape with a profile gets a browser of its own and counts toward `vision.sessions.concurrent` while it runs) |
77
+ | `presets [--kind K]` | screenshot and video style presets with preview URLs |
78
+ | `connect <pack>` | stores a credential in the vault: the key and type come from the pack, the secret from stdin (hidden on a terminal) or `--secret-env FIELD=VAR`, never from argv; `connect new --type`, `ls`, `get`, `rm` |
79
+ | `infer models\|voices\|chat\|speech` | the node's models, narration voices with samples, one streamed completion; `speech <text> --out FILE [--voice V] [--words FILE]` writes the audio (format from the extension, or `--response-format`) and, with `--words`, each word's start and end in ms |
80
+ | `requests [ls\|get <req_id>]` | your request log with timing (`--status 2xx\|4xx\|5xx`, `--product`, `--operation-id`, `--sandbox-id`, `--since`) |
81
+ | `webhooks secret\|rotate\|test\|deliveries --url URL` | webhook signing secrets (printed once on stdout), rotation with a grace period, a signed test delivery |
82
+ | `action search\|describe\|call` | marketplace actions (`call io.b3os/github/create-issue@1 --input @issue.json`) |
50
83
  | `mcp install --client claude\|cursor\|codex` | adds the B3OS MCP server to the client (below) |
51
- | `mcp serve [--packs a,b]` | the stdio MCP server in this process |
84
+ | `mcp serve [--packs a,b] [--routines a,b\|all] [--toolsets a,b]` | the stdio MCP server in this process |
85
+ | `mcp tools [--toolsets a,b]` | the tools the server lists (the shared table both MCP servers serve) |
52
86
  | `bench [ping\|scrape\|exec]` | a client-side latency probe from where you run it (below) |
53
87
  | `api <METHOD> <path>` | any operation, with `--data JSON\|@file`, `--query k=v`, `--header k=v`, `--edge`/`--node` |
54
88
 
@@ -59,13 +93,13 @@ sandboxes:*'` asks for fewer scopes.
59
93
  | 0 | success |
60
94
  | 1 | an error not listed here |
61
95
  | 2 | usage error, or a confirmation refused without `--yes` |
62
- | 3 | authentication or authorization (401, 403) |
96
+ | 3 | not signed in, authentication or authorization (401, 403), or a `b3os login` that was denied in the dashboard or whose code expired |
63
97
  | 4 | not found (404) |
64
98
  | 5 | invalid request, conflict or state error (other 4xx, including 421 `edge_only`) |
65
99
  | 6 | rate limited, quota or credits (429, 402) |
66
100
  | 7 | server error or unavailable (5xx) |
67
101
  | 8 | timeout |
68
- | 9 | connection error |
102
+ | 9 | connection error (also a `sandbox shell` whose connection closed before the shell exited) |
69
103
  | 10 | a job or routine run failed, or a remote command (`sandbox exec`, `sandbox shell`) exited non-zero or was killed |
70
104
  | 130 | interrupted |
71
105
 
@@ -76,8 +110,9 @@ object.
76
110
 
77
111
  ## MCP install
78
112
 
79
- `b3os mcp install --client claude|cursor|codex [--scope user|project] [--packs github,slack]` adds an entry that runs
80
- `npx -y @b3os/mcp`. The server reads `B3OS_API_KEY` or the `b3os login` token itself, so the client's config holds no
113
+ `b3os mcp install --client claude|cursor|codex [--scope user|project] [--packs github,slack] [--routines daily-digest|all] [--toolsets routines]`
114
+ adds an entry that runs `npx -y @b3os/mcp@0.1`, the CLI's own minor line (the core tools, plus the actions of `--packs` and the opt-in tools of
115
+ `--toolsets`: `sandboxes`, `vision`, `routines`, `infer`, `platform` or `all`; `b3os mcp tools` lists them). The server reads `B3OS_API_KEY` or the `b3os login` token itself, so the client's config holds no
81
116
  secret. Claude Code is configured through `claude mcp add` (or `.mcp.json` with `--scope project` when the `claude`
82
117
  CLI is missing), Cursor through `~/.cursor/mcp.json` (or `.cursor/mcp.json`), Codex through
83
118
  `~/.codex/config.toml` (or `.codex/config.toml`; only the `[mcp_servers.b3os]` table is replaced). `--print` prints
@@ -85,8 +120,16 @@ the entry instead of writing it. `--remote` points Claude or Cursor at the edge'
85
120
  `Authorization: Bearer` header that refers to `B3OS_API_KEY` (`${B3OS_API_KEY}` for Claude Code, `${env:B3OS_API_KEY}`
86
121
  for Cursor; the client expands it when it connects), so no key is written to a config file (project files such as
87
122
  `.mcp.json` are often committed), printed, or put on the `claude mcp add` command line. Start the client with
88
- `B3OS_API_KEY` in its environment. New user-scope config files are created mode 0600. The expansion is the
89
- clients' documented behavior; it has not been tried against a running Claude Code or Cursor here.
123
+ `B3OS_API_KEY` in its environment. New user-scope config files are created mode 0600.
124
+
125
+ Claude Code starts stdio servers with its own environment; Codex and Cursor do not, so their stdio entries forward
126
+ `B3OS_API_KEY`, `B3OS_BASE_URL`, `B3OS_API_URL` and `B3OS_SOCKET` by name (Codex `env_vars`) or by reference
127
+ (Cursor `env` with `${env:NAME}`; Cursor passes the literal reference when a variable is unset, and the server
128
+ ignores such values and falls back to the `b3os login` token). Checked on 2026-10-27 with the clients' own MCP
129
+ code and isolated config directories (`packages/mcp/test/clients/run.sh`): Claude Code 2.1.311 connects to the
130
+ stdio entry and to `--remote` with `${B3OS_API_KEY}` expanded (both over MCP 2026-07-28); Codex 0.164.0 starts the
131
+ stdio entry, lists the 15 tools and calls one with the forwarded key; cursor-agent 2025.09.12 lists the tools of
132
+ the stdio entry but sent no configured header to a `--remote` entry (it tried OAuth), so use stdio with Cursor.
90
133
 
91
134
  ## bench
92
135
 
package/bin/b3os.js CHANGED
@@ -1,6 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  // `b3os` launcher for the built CLI. From a checkout without a build:
3
3
  // node --conditions=b3os-source packages/cli/src/main.ts <args>
4
- import { run } from "../dist/main.js";
5
-
6
- process.exitCode = await run(process.argv.slice(2));
4
+ // The Node check runs before the CLI loads (a dynamic import), so an older Node prints one line and exits 2 instead
5
+ // of failing later with a stack trace. NEEDS matches "engines" in package.json (packages/sdk/test/node-version.test.ts).
6
+ const NEEDS = [22, 3];
7
+ const [major, minor] = process.versions.node.split(".").map(Number);
8
+ if (major < NEEDS[0] || (major === NEEDS[0] && minor < NEEDS[1])) {
9
+ process.stderr.write(
10
+ `b3os needs Node.js ${NEEDS.join(".")} or newer; this is Node.js ${process.versions.node}. Install a current LTS release from https://nodejs.org.\n`,
11
+ );
12
+ process.exitCode = 2;
13
+ } else {
14
+ const { run } = await import("../dist/main.js");
15
+ process.exitCode = await run(process.argv.slice(2));
16
+ }
@@ -0,0 +1,49 @@
1
+ import type { Deleted, JobStatus } from "@b3os/sdk";
2
+ import { type Ctx, UsageError } from "../ctx.ts";
3
+ /**
4
+ * A list of scopes, written one way everywhere (`--scope vision:run,sandboxes:*`): commas, and spaces too for the
5
+ * lines written before (`--scope 'vision:run sandboxes:*'`). Repeating the option adds to the list.
6
+ */
7
+ export declare function scopeList(v: unknown, flag: string): string[] | undefined;
8
+ /** `--input '{"a":1}'` or `--input @input.json`. */
9
+ export declare function inputFlag(v: unknown): Record<string, unknown> | undefined;
10
+ /**
11
+ * Prints the help a command line asks for and returns the exit code, or undefined to run the command: no
12
+ * subcommand prints `text` (exit 2, or 0 with --help); `<sub> --help` prints that subcommand's part of it.
13
+ */
14
+ export declare function usage(ctx: Ctx, text: string, sub: string | undefined, help: unknown): number | undefined;
15
+ /** `if (!sub || a.values.help) return showUsage(...)`: `usage` in a form that leaves `sub` a string after it. */
16
+ export declare function showUsage(ctx: Ctx, text: string, sub: string | undefined, help: unknown): number;
17
+ /** The subcommands a group's usage text documents, in its order. */
18
+ export declare function subcommands(text: string): string[];
19
+ /**
20
+ * The help of one subcommand, cut from its group's usage text: its entry, the notes when they are about it (or
21
+ * about no subcommand in particular), and where the rest is. Any other text comes back whole.
22
+ */
23
+ export declare function usageOf(text: string, sub: string): string;
24
+ /**
25
+ * `unknown sandbox command "creat". Did you mean create?`, with where the list is. `known` is the group's usage
26
+ * text, or the subcommands themselves.
27
+ */
28
+ export declare function unknownSub(group: string, sub: string, known: string | readonly string[]): UsageError;
29
+ export type ImageFormat = "webp" | "png" | "jpeg";
30
+ /**
31
+ * The image format for a file the CLI writes (`screenshot --out`, `scrape --screenshot`): the extension picks it
32
+ * (.webp, .png, .jpg or .jpeg), and a name without one gets WebP, the API's default. `--format`, when given, must
33
+ * agree with the extension, so a .webp file never holds PNG bytes.
34
+ */
35
+ export declare function imageFormat(file: string | undefined, format: unknown, flag: string): ImageFormat;
36
+ /** The extension a file of this format gets when the CLI names it. */
37
+ export declare function imageExtension(format: ImageFormat): string;
38
+ /**
39
+ * `<command> rm <id>...`: asks once (without a terminal only --yes answers), then deletes each in turn and prints
40
+ * "<id> deleted" as it goes, so a failure part way leaves a record of what was already gone. --json prints the
41
+ * list of answers at the end.
42
+ */
43
+ export declare function removeEach(ctx: Ctx, ids: string[], o: {
44
+ need: string;
45
+ question: string;
46
+ remove: (id: string) => Promise<Deleted>;
47
+ }): Promise<number>;
48
+ /** `--status` for a list of jobs (videos, routine runs). */
49
+ export declare function jobStatusFlag(v: unknown): JobStatus | undefined;
@@ -0,0 +1,174 @@
1
+ // Helpers the command modules share (platform-dx). Not a command: main.ts never lists a file whose name starts
2
+ // with an underscore.
3
+ import { readFileSync } from "node:fs";
4
+ import { EXIT, jsonFlag, UsageError } from "../ctx.js";
5
+ import { orList, suggest } from "../suggest.js";
6
+ /**
7
+ * A list of scopes, written one way everywhere (`--scope vision:run,sandboxes:*`): commas, and spaces too for the
8
+ * lines written before (`--scope 'vision:run sandboxes:*'`). Repeating the option adds to the list.
9
+ */
10
+ export function scopeList(v, flag) {
11
+ if (v === undefined)
12
+ return undefined;
13
+ const list = (Array.isArray(v) ? v : [v]).flatMap((s) => String(s).split(/[,\s]+/)).filter(Boolean);
14
+ if (!list.length)
15
+ throw new UsageError(`${flag} needs at least one scope (SCOPE,SCOPE...)`);
16
+ return [...new Set(list)];
17
+ }
18
+ /** `--input '{"a":1}'` or `--input @input.json`. */
19
+ export function inputFlag(v) {
20
+ if (v === undefined)
21
+ return undefined;
22
+ const s = String(v);
23
+ const parsed = jsonFlag(s.startsWith("@") ? readFileSync(s.slice(1), "utf8") : s, "--input");
24
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
25
+ throw new UsageError("--input must be a JSON object");
26
+ }
27
+ return parsed;
28
+ }
29
+ /**
30
+ * Prints the help a command line asks for and returns the exit code, or undefined to run the command: no
31
+ * subcommand prints `text` (exit 2, or 0 with --help); `<sub> --help` prints that subcommand's part of it.
32
+ */
33
+ export function usage(ctx, text, sub, help) {
34
+ return !sub || help ? showUsage(ctx, text, sub, help) : undefined;
35
+ }
36
+ /** `if (!sub || a.values.help) return showUsage(...)`: `usage` in a form that leaves `sub` a string after it. */
37
+ export function showUsage(ctx, text, sub, help) {
38
+ ctx.out(sub ? usageOf(text, sub) : text);
39
+ return help ? EXIT.OK : EXIT.USAGE;
40
+ }
41
+ const SUB_NAME = /^[a-z][a-z0-9-]*$/;
42
+ /** Other words for a subcommand that the commands also take: older names (`run` for `action call`) and their
43
+ * current ones, so `<sub> --help` finds the entry under either. */
44
+ const ALIASES = {
45
+ list: ["ls"],
46
+ ls: ["list"],
47
+ delete: ["rm"],
48
+ remove: ["rm"],
49
+ rm: ["delete", "revoke", "close"],
50
+ call: ["run"],
51
+ run: ["call"],
52
+ deploy: ["publish"],
53
+ publish: ["deploy"],
54
+ url: ["port-url"],
55
+ };
56
+ /** A group's usage text (`usage: b3os sandbox <command>`, then one entry per subcommand indented two spaces). */
57
+ function groupUsage(text) {
58
+ const [head, ...rest] = text.split("\n");
59
+ const group = /^usage: b3os ([a-z][a-z0-9-]*) <command>/.exec(head ?? "")?.[1];
60
+ if (!group)
61
+ return undefined;
62
+ const entries = [];
63
+ const notes = [];
64
+ for (const line of rest) {
65
+ if (notes.length || !line.startsWith(" ")) {
66
+ notes.push(line);
67
+ continue;
68
+ }
69
+ if (line.startsWith(" ") && entries.length) {
70
+ entries.at(-1)?.lines.push(line);
71
+ continue;
72
+ }
73
+ const names = line
74
+ .trim()
75
+ .split(" | ")
76
+ .map((alt) => alt.split(" ")[0] ?? "")
77
+ .filter((w) => SUB_NAME.test(w));
78
+ entries.push({ names: [...new Set(names)], placeholder: line.trim().startsWith("<"), lines: [line] });
79
+ }
80
+ while (notes.length && !notes[0]?.trim())
81
+ notes.shift();
82
+ return { group, entries, notes };
83
+ }
84
+ /** The subcommands a group's usage text documents, in its order. */
85
+ export function subcommands(text) {
86
+ return groupUsage(text)?.entries.flatMap((e) => e.names) ?? [];
87
+ }
88
+ /**
89
+ * The help of one subcommand, cut from its group's usage text: its entry, the notes when they are about it (or
90
+ * about no subcommand in particular), and where the rest is. Any other text comes back whole.
91
+ */
92
+ export function usageOf(text, sub) {
93
+ const g = groupUsage(text);
94
+ if (!g)
95
+ return text;
96
+ const want = [sub, ...(ALIASES[sub] ?? [])];
97
+ const entry = g.entries.find((e) => want.some((w) => e.names.includes(w))) ??
98
+ (SUB_NAME.test(sub) || sub.includes("/") ? g.entries.find((e) => e.placeholder) : undefined);
99
+ if (!entry)
100
+ return text;
101
+ const [first = "", ...more] = entry.lines;
102
+ const out = [`usage: b3os ${g.group} ${first.trim()}`, ...more];
103
+ const about = (w) => new RegExp(`(^|[^a-z-])${w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}([^a-z-]|$)`);
104
+ const notes = g.notes.join("\n");
105
+ const names = g.entries.flatMap((e) => e.names);
106
+ if (notes && (want.some((w) => about(w).test(notes)) || !names.some((n) => about(n).test(notes))))
107
+ out.push(...g.notes);
108
+ out.push(`All ${g.group} commands: b3os ${g.group} --help`);
109
+ return out.join("\n");
110
+ }
111
+ /**
112
+ * `unknown sandbox command "creat". Did you mean create?`, with where the list is. `known` is the group's usage
113
+ * text, or the subcommands themselves.
114
+ */
115
+ export function unknownSub(group, sub, known) {
116
+ const near = suggest(sub, typeof known === "string" ? subcommands(known) : known);
117
+ return new UsageError(`unknown ${group} command "${sub}"${near.length ? `. Did you mean ${orList(near)}?` : ""}`, `b3os ${group} --help lists its commands`);
118
+ }
119
+ const IMAGE_EXTENSIONS = { webp: "webp", png: "png", jpg: "jpeg", jpeg: "jpeg" };
120
+ const IMAGE_NAMES = { webp: "WebP", png: "PNG", jpeg: "JPEG" };
121
+ /**
122
+ * The image format for a file the CLI writes (`screenshot --out`, `scrape --screenshot`): the extension picks it
123
+ * (.webp, .png, .jpg or .jpeg), and a name without one gets WebP, the API's default. `--format`, when given, must
124
+ * agree with the extension, so a .webp file never holds PNG bytes.
125
+ */
126
+ export function imageFormat(file, format, flag) {
127
+ const ext = file ? /\.([^./\\]+)$/.exec(file)?.[1]?.toLowerCase() : undefined;
128
+ const fromExt = ext === undefined ? undefined : IMAGE_EXTENSIONS[ext];
129
+ if (ext !== undefined && fromExt === undefined)
130
+ throw new UsageError(`${flag} ${file}: the image is WebP, PNG or JPEG, so name it .webp, .png or .jpg`);
131
+ if (format === undefined)
132
+ return fromExt ?? "webp";
133
+ const chosen = IMAGE_EXTENSIONS[String(format).toLowerCase()];
134
+ if (!chosen)
135
+ throw new UsageError(`--format is webp, png or jpeg, got "${String(format)}"`);
136
+ if (fromExt && fromExt !== chosen)
137
+ throw new UsageError(`${flag} ${file} names a ${IMAGE_NAMES[fromExt]} file but --format is ${chosen}; drop one`);
138
+ return chosen;
139
+ }
140
+ /** The extension a file of this format gets when the CLI names it. */
141
+ export function imageExtension(format) {
142
+ return format === "jpeg" ? "jpg" : format;
143
+ }
144
+ /**
145
+ * `<command> rm <id>...`: asks once (without a terminal only --yes answers), then deletes each in turn and prints
146
+ * "<id> deleted" as it goes, so a failure part way leaves a record of what was already gone. --json prints the
147
+ * list of answers at the end.
148
+ */
149
+ export async function removeEach(ctx, ids, o) {
150
+ if (ids.length === 0)
151
+ throw new UsageError(o.need);
152
+ if (!(await ctx.confirm(o.question)))
153
+ return EXIT.OK;
154
+ const gone = [];
155
+ for (const id of ids) {
156
+ const d = await o.remove(id);
157
+ gone.push(d);
158
+ if (!ctx.json)
159
+ ctx.out(`${d.id} deleted`);
160
+ }
161
+ if (ctx.json)
162
+ ctx.printJson(gone);
163
+ return EXIT.OK;
164
+ }
165
+ const JOB_STATUSES = ["queued", "running", "succeeded", "failed", "canceled"];
166
+ /** `--status` for a list of jobs (videos, routine runs). */
167
+ export function jobStatusFlag(v) {
168
+ if (v === undefined)
169
+ return undefined;
170
+ if (!JOB_STATUSES.includes(v))
171
+ throw new UsageError(`--status is ${JOB_STATUSES.join(", ")}; got "${String(v)}"`);
172
+ return v;
173
+ }
174
+ //# sourceMappingURL=_common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_common.js","sourceRoot":"","sources":["../../src/commands/_common.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,sBAAsB;AAEtB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAY,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEhD;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,CAAU,EAAE,IAAY;IAChD,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACtC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpG,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,UAAU,CAAC,GAAG,IAAI,4CAA4C,CAAC,CAAC;IAC5F,OAAO,CAA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EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,CAAC,GAAG,CAAC,IAAI;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;IACD,IAAI,GAAG,CAAC,IAAI;QAAE,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,EAAE,CAAC;AACjB,CAAC;AAED,MAAM,YAAY,GAAyB,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AAEpG,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,CAAU;IACtC,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACtC,IAAI,CAAE,YAAmC,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnD,MAAM,IAAI,UAAU,CAAC,eAAe,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACrF,OAAO,CAAc,CAAC;AACxB,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { type Ctx } from "../ctx.ts";
2
+ import type { CliCommand } from "../registry.ts";
3
+ /** `b3os action`'s options. One named after a request field sets that field (ctx.ts CliOption). */
4
+ export declare const ACTION_OPTIONS: {
5
+ readonly pack: {
6
+ readonly type: "string";
7
+ readonly fields: readonly ["actionsSearch:pack"];
8
+ };
9
+ readonly effects: {
10
+ readonly type: "string";
11
+ readonly fields: readonly ["actionsSearch:effects"];
12
+ };
13
+ readonly limit: {
14
+ readonly type: "string";
15
+ readonly fields: readonly ["actionsSearch:limit"];
16
+ };
17
+ readonly input: {
18
+ readonly type: "string";
19
+ readonly fields: readonly ["actionsCall:input"];
20
+ };
21
+ readonly connection: {
22
+ readonly type: "string";
23
+ readonly multiple: true;
24
+ readonly fields: readonly ["actionsCall:connections"];
25
+ };
26
+ readonly "timeout-ms": {
27
+ readonly type: "string";
28
+ readonly fields: readonly ["actionsCall:timeout_ms"];
29
+ };
30
+ };
31
+ export declare function action(ctx: Ctx, argv: string[]): Promise<number>;
32
+ interface FieldRow {
33
+ field: string;
34
+ type: string;
35
+ required: "yes" | "no";
36
+ default: string | null;
37
+ description: string | null;
38
+ }
39
+ /** One row per top-level input field, required ones first; null when the schema is not an object of fields. */
40
+ export declare function inputFields(schema: unknown): FieldRow[] | null;
41
+ /** This module's commands, found by main.ts (src/registry.ts). */
42
+ export declare const commands: CliCommand[];
43
+ export {};