@astralbeam/cli 0.23.7 → 0.24.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.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: astralbeam
3
+ description: Integrate AstralBeam AI chat into web applications using its SDK. Use when adding an AstralBeam sidebar or chat screen, connecting application authentication, tools or widgets, or verifying an integration. Also use for AstralBeam CLI tasks involving Tenants, TenantUsers, JWTs, chat, saved conversations, usage, or organization credentials.
4
+ license: MIT
5
+ ---
6
+
7
+ # AstralBeam
8
+
9
+ AstralBeam embeds AI chat that can answer questions, call application tools, render UI widgets, and work with files. An AstralBeam Organization owns the agent configuration and API key. Tenants represent your application's customer accounts, and TenantUsers are their users.
10
+
11
+ To embed chat, follow **Integrate a web application**. The CLI is not required. For CLI-only tasks, skip to **If the CLI is installed**.
12
+
13
+ ## Integrate a web application
14
+
15
+ 1. Inspect the framework, backend, authentication, customer-account model, and intended chat placement. Reuse existing integration code and the host's package manager. A trusted backend must issue tokens. Clarify missing identity or backend requirements rather than putting an API key in browser code.
16
+ 2. Read [SDK setup](https://astralbeam.ai/docs/sdk/getting-started.md) and [authentication](https://astralbeam.ai/docs/sdk/authentication.md) for installation, token handlers, and SDK examples. Match the installed SDK version. For an app without a bundler, read [script-tag setup](https://astralbeam.ai/docs/sdk/script-tag.md).
17
+ 3. Confirm the intended Organization and deployment, a working model assigned to the agent, and `ASTRALBEAM_API_KEY` in the backend environment. Have the operator complete missing [dashboard setup](https://astralbeam.ai/docs/start/quickstart.md). CLI login does not configure the application's secret. Continue code and static checks when credentials are unavailable, reporting live verification as pending.
18
+ 4. Add or reuse `POST /api/astralbeam/token`, returning `{ token }` with `Cache-Control: no-store`. Authenticate the request and derive stable string user and Tenant IDs from the trusted session and verified account membership. Never trust browser-supplied identities or admin claims. Use `createAstralBeamToken` from `@astralbeam/sdk/server`, or the authentication guide's JWT format for other backend languages. Preserve session and CSRF protections, and keep keys and tokens out of logs, prompts, and evidence.
19
+ 5. Mount `AstralBeamChat` from `@astralbeam/sdk/react` in a client component, or `mountAstralBeamChat` from `@astralbeam/sdk/client` in the browser with teardown via `unmount()`. Give its container a definite height. The default token endpoint is `/api/astralbeam/token`. For a custom endpoint or CSRF headers, follow the authentication guide's `fetchAstralBeamToken` examples. For self-hosting, set `apiUrl` to the issuing deployment's `/api` base.
20
+ 6. Unmount on sign-out and remount after the trusted session's user or Tenant changes. In React, key chat by Tenant and user IDs. Updating a token callback or clearing the transcript alone does not switch identity. The SDK synchronizes identities through `/me`, so normal embedding needs no CLI pre-creation.
21
+ 7. Add tools or widgets only when requested. Read [tools and widgets](https://astralbeam.ai/docs/sdk/tools-and-widgets.md) and [security](https://astralbeam.ai/docs/sdk/security.md) before exposing application actions. Reuse existing mutations, validate agent-chosen input, enforce backend ownership checks, and await persistence before returning JSON-compatible results. Demo identities and browser-owned example data are not a production authorization policy.
22
+ 8. Run the host's relevant checks, sign in, and send a message to confirm the token endpoint and chat work together. If tools or widgets were added, try one representative action and confirm the result in the app. Report any setup or checks still pending.
23
+
24
+ ## If the CLI is installed
25
+
26
+ Read [CLI commands](https://astralbeam.ai/docs/cli/commands.md) when managing Tenants or TenantUsers, minting tokens, testing chat, reading saved conversations, or inspecting organization details and user usage. It documents flags, pagination, JSON output, and exit codes. Use `astralbeam --help` to discover generated commands and `astralbeam <command> --help` for their flags, or [CLI setup](https://astralbeam.ai/docs/cli/getting-started.md) if it is unavailable. Providers, models, agents, and API keys still require the dashboard.
27
+
28
+ Run from the intended project directory and check `organization.id` and `api_url` before mutations, token signing, or chat:
29
+
30
+ ```sh
31
+ astralbeam auth status --json
32
+ astralbeam tenants list --external-id <tenant-external-id> --json
33
+ astralbeam chat --tenant <tenant-external-id> --user <user-external-id> "Say hello in one sentence." --json
34
+ ```
35
+
36
+ - Use `--json` for machine-readable results. Exit codes are 0 for success, 1 for API/generated-input/runtime failure, and 2 for parser usage errors.
37
+ - `ASTRALBEAM_API_KEY` overrides directory bindings. `ASTRALBEAM_API_URL` overrides the saved API URL. Stop on an unintended Organization UUID, deployment, or rejected credentials. Never pass keys as flags or echo them. Interactive `auth login` belongs to the operator. Use existing environment credentials directly, or accept a user-supplied key through stdin.
38
+ - Management paths use returned internal UUIDs. Token and chat identities use your application's external IDs. Creates are not idempotent: a timed-out create may still commit. Reconcile the exact external ID and returned fields before retrying a timeout or conflict. Do not change IDs to bypass conflicts. `--metadata` replaces the whole object.
39
+ - CLI chat synchronizes identities, makes a new submission on each run, and can incur model usage. It cannot execute browser tools/widgets or replace the in-app setup check. CLI-minted tokens are diagnostics, not application session authentication.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astralbeam/cli",
3
- "version": "0.23.7",
3
+ "version": "0.24.0",
4
4
  "description": "Command-line interface for AstralBeam organization admins and their coding agents",
5
5
  "homepage": "https://astralbeam.ai/docs/cli/getting-started",
6
6
  "bugs": "https://github.com/AstralBeamAI/astralbeam/issues",
@@ -14,37 +14,41 @@
14
14
  "astralbeam": "dist/astralbeam.js"
15
15
  },
16
16
  "files": [
17
- "dist",
18
- "skills"
17
+ "dist"
19
18
  ],
20
19
  "type": "module",
20
+ "imports": {
21
+ "#api": "./src/generated/_runtime/path.ts",
22
+ "#lib/*.js": "./src/forge-runtime.ts"
23
+ },
21
24
  "publishConfig": {
22
25
  "access": "public"
23
26
  },
24
27
  "scripts": {
25
28
  "binary:check": "bun run compile && bun dist/astralbeam.js --version && .output/astralbeam --version && .output/astralbeam skill > /dev/null",
26
- "build": "tsdown && bun pm pack --dry-run --quiet",
27
- "check": "bun run format:check && bun run lint && bun run typecheck && bun run knip",
28
- "check:fix": "bun run lint:fix && bun run format && bun run knip:fix",
29
+ "build": "bun run generate:api && tsdown && bun pm pack --dry-run --quiet",
30
+ "check": "bun run generate:api && bun run format:check && bun run lint && bun run typecheck && bun run knip",
31
+ "check:fix": "bun run generate:api && bun run lint:fix && bun run format && bun run knip:fix",
29
32
  "count-lines": "bun run ../scripts/count-lines.ts",
30
- "compile": "bun run build && bun build --compile --no-compile-autoload-dotenv --no-compile-autoload-bunfig --asset skills --outfile .output/astralbeam dist/astralbeam.js",
31
- "dev": "bun run src/main.ts",
33
+ "compile": "bun run build && bun build --compile --no-compile-autoload-dotenv --no-compile-autoload-bunfig --asset dist/skills --outfile .output/astralbeam dist/astralbeam.js",
34
+ "dev": "bun run generate:api && bun run src/main.ts",
32
35
  "format": "oxfmt",
33
36
  "format:check": "oxfmt --check",
34
- "knip": "knip",
35
- "knip:fix": "knip --fix --allow-remove-files && knip --fix --allow-remove-files && bun install --frozen-lockfile",
37
+ "knip": "tsdown && knip --no-gitignore",
38
+ "knip:fix": "tsdown && knip --no-gitignore --fix --allow-remove-files && knip --no-gitignore --fix --allow-remove-files && bun install --frozen-lockfile",
36
39
  "lint": "oxlint",
37
40
  "lint:fix": "oxlint --fix",
38
41
  "ready": "bun run ../scripts/ready.ts check test build count-lines",
39
- "test": "vitest run",
40
- "typecheck": "tsc --noEmit"
42
+ "test": "bun run generate:api && vitest run",
43
+ "typecheck": "tsc --noEmit",
44
+ "generate:api": "bun run scripts/forge/generate.ts"
41
45
  },
42
46
  "devDependencies": {
43
- "@astralbeam/sdk": "0.23.7",
47
+ "@astralbeam/sdk": "0.24.0",
44
48
  "@types/bun": "1.4.4",
45
49
  "@types/node": "^26.2.0",
50
+ "@types/yargs": "17.0.35",
46
51
  "@vitest/eslint-plugin": "^1.6.27",
47
- "commander": "^15.0.0",
48
52
  "eslint-plugin-regexp": "^3.3.1",
49
53
  "knip": "^6.32.2",
50
54
  "oxfmt": "^0.70.0",
@@ -52,7 +56,8 @@
52
56
  "oxlint-tsgolint": "^7.0.2002",
53
57
  "tsdown": "^0.23.1",
54
58
  "typescript": "^6.0.3",
55
- "vitest": "^4.1.12"
59
+ "vitest": "^4.1.12",
60
+ "yargs": "17.7.3"
56
61
  },
57
62
  "engines": {
58
63
  "node": ">=22.12"
@@ -1,70 +0,0 @@
1
- ---
2
- name: astralbeam
3
- description: Manage an AstralBeam organization from the terminal with the `astralbeam` CLI. Use when asked to list, look up, create, or update AstralBeam Tenants or TenantUsers, mint AstralBeam chat or organization JWTs, test an AstralBeam agent by chatting as a tenant user, or check which AstralBeam API key and URL are configured.
4
- ---
5
-
6
- # AstralBeam CLI
7
-
8
- `astralbeam` calls an AstralBeam organization's public API with an organization API key. Tenants are the organization's customers, and TenantUsers are those customers' users who talk to the embedded agent.
9
-
10
- If `astralbeam` is not on the PATH, run it as `bunx --bun @astralbeam/cli` or `npx -y @astralbeam/cli`, as allowed by the current project's runtime policy.
11
-
12
- ## Rules
13
-
14
- - Pass `--json` on operations whose output you will read. Records and pages go to stdout. Without `--debug` or an interactive login prompt, stderr holds one object: `{"context": {...}}` on success or `{"error": {...}, "context": {...}}` on failure. API errors retain their problem details. Runtime and usage errors provide `error.detail`. Context contains `organization` and `bound_directory`, or is null before credentials resolve. Environment credentials report only `organization.id`, except in `auth status`, which also retrieves the name and slug.
15
- - Exit code 0 means success, 1 means the API or runtime failed, and 2 means the command line was invalid. Read `astralbeam <command> --help` before guessing flags. To diagnose an unexpected failure, check the outcome of any write before rerunning it without `--json` and with `--debug`, which logs each HTTP request and the stack trace to stderr.
16
- - Never print, log, or echo an API key. Never pass a key as a command-line argument. Credentials come from `ASTRALBEAM_API_KEY`, or from the nearest directory at or above the working directory where someone ran `astralbeam auth login`. Run commands from the project directory the user means, because a different directory can select a different organization.
17
- - Before any write, run `astralbeam auth status --json` from the same directory and confirm `organization` is the one the user means. Stop if it is not. Without `--json`, keyed commands print the organization first on stderr as `▸ Acme (acme) · org <id> · bound at ~/work/acme`.
18
- - Never run `astralbeam auth login` yourself unless the user supplies the key through stdin. It prompts for a secret. Use `ASTRALBEAM_API_KEY` directly for environment credentials without login.
19
- - Path IDs are internal UUIDs returned by the API. External IDs are the organization's own identifiers and are passed with `--external-id`, `--tenant`, or `--user`.
20
- - Creates are not idempotent. A duplicate external ID returns HTTP 409. After a timeout or a 409, look the record up with `list --external-id <id>` before retrying.
21
- - `--metadata` replaces the whole stored object and must be a JSON object.
22
- - The management API allows 100 requests per 5 minutes per key. Prefer `--external-id` lookups over `--all` listings, and back off on HTTP 429.
23
-
24
- ## Check credentials
25
-
26
- ```sh
27
- astralbeam auth status --json
28
- ```
29
-
30
- This prints the organization, API URL, masked key, and `source` (the bound directory or `ASTRALBEAM_API_KEY`). It exits 1 if credentials are missing or rejected. `astralbeam auth list --json` shows all bindings. `auth logout` removes the nearest binding for every directory it covers, but does not revoke the key or clear environment credentials.
31
-
32
- ## Tenants
33
-
34
- ```sh
35
- astralbeam tenants list --json [--search <text>] [--external-id <id>] [--page-size <n>] [--page-after <cursor>] [--all]
36
- astralbeam tenants get <tenant-id> --json
37
- astralbeam tenants create --external-id <id> [--name <name>] [--metadata '<json>'] --json
38
- astralbeam tenants update <tenant-id> [--name <name> | --clear-name] [--metadata '<json>'] --json
39
- ```
40
-
41
- A list returns `{"items": [...], "page_after": <cursor|null>, "page_before": <cursor|null>}`. Follow `page_after` with `--page-after` until null, or use `--all` to merge the remaining pages. `--all` cannot be combined with `--page-before`.
42
-
43
- ## TenantUsers
44
-
45
- ```sh
46
- astralbeam tenant-users list <tenant-id> --json [--external-id <id>] [--admin | --no-admin] [--all]
47
- astralbeam tenant-users get <tenant-id> <user-id> --json
48
- astralbeam tenant-users create <tenant-id> --external-id <id> [--name <name>] [--admin] [--metadata '<json>'] --json
49
- astralbeam tenant-users update <tenant-id> <user-id> [--name <name> | --clear-name] [--admin | --no-admin] [--metadata '<json>'] --json
50
- ```
51
-
52
- To find a user from external IDs, resolve the Tenant first with `tenants list --external-id <tenant-external-id> --json`, then list its users with `--external-id <user-external-id>`. The stored `admin` flag is data and grants no API authority.
53
-
54
- ## Tokens
55
-
56
- ```sh
57
- astralbeam token chat --tenant <tenant-external-id> --user <user-external-id> [--admin] [--expires-in <60-600>] --json
58
- astralbeam token organization --email <member-email> [--expires-in <60-600>] --json
59
- ```
60
-
61
- Tokens are signed offline and print as `{"token": "...", "expires_at": "..."}` with `--json`. Minting creates no records. A chat token's signed `--admin` claim grants Tenant admin API access, unlike the stored TenantUser flag.
62
-
63
- ## Chat with an agent
64
-
65
- ```sh
66
- astralbeam chat --tenant <tenant-external-id> --user <user-external-id> "<message>" --json
67
- echo "<message>" | astralbeam chat --tenant <id> --user <id> --agent <agent-id> --json
68
- ```
69
-
70
- Chat signs a token for that identity and runs the organization's default agent, or the agent named by `--agent agent_<organizationId>_<id>`. It synchronizes the Tenant and TenantUser records the same way the embedded widget does. With `--json` it prints `{"messages": [...]}`, the turn's user and assistant messages with their `parts`. Text is in parts of type `text`, and tool calls are in parts of type `tool-call`. The CLI implements no client-side tools, so it settles any such call as an error before the next message.