@candledottv/cli 0.4.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +139 -0
  3. package/dist/index.js +4741 -0
  4. package/package.json +46 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Candle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # @candledottv/cli
2
+
3
+ The Candle CLI: authorize a device from your browser, then manage API keys, wallets, and setup
4
+ health from the terminal. Zero runtime dependencies; the whole thing is one self-contained
5
+ `dist/index.js` that runs under plain Node.
6
+
7
+ ## Quick start
8
+
9
+ ```
10
+ npx @candledottv/cli auth login
11
+ ```
12
+
13
+ This runs `auth login`, which opens your browser to approve this device. Install it permanently
14
+ with `npm install -g @candledottv/cli` and the command is just `candle`.
15
+
16
+ ### No-npm fallback
17
+
18
+ The same CLI can run straight from the public repo:
19
+
20
+ ```
21
+ bunx github:candledottv/agentic candle auth login
22
+ ```
23
+
24
+ That fetches the `agentic` repo, resolves the `candle` bin at its root (`packages/cli/dist/index.js`,
25
+ a committed build), and runs it. If bun's git-dependency handling fails on your machine, clone and
26
+ build directly:
27
+
28
+ ```
29
+ git clone https://github.com/candledottv/agentic.git
30
+ cd agentic
31
+ bun install
32
+ bun run --cwd packages/cli build
33
+ node packages/cli/dist/index.js auth login
34
+ ```
35
+
36
+ ## Commands
37
+
38
+ | Command | What it does |
39
+ | --- | --- |
40
+ | `candle setup [--no-browser]` | The onboarding wizard: authorizes this device (skipped when already authorized), prints the agent wallets as funding destinations plus the paste-into-your-agent brief, shows the skill/MCP install lines, runs the full doctor check (setup's exit code is doctor's), and links the web console. Safe to re-run. |
41
+ | `candle auth login [--scopes <a,b,c>] [--label <name>] [--no-browser]` | Authorizes this device: prints a code, opens (or prints) an approval URL, polls until approved, then stores the resulting device token and API key. |
42
+ | `candle auth status` | Shows which storage backend is in use, both credential prefixes, the config file path, and a live validity check for each credential. |
43
+ | `candle auth logout [--keep-key]` | Revokes the stored API key (skipped with `--keep-key`), clears local credentials and config, and prints the portal URL for revoking the device itself. |
44
+ | `candle keys list` | Lists this account's API keys: prefix, scopes, environment, timestamps, and which device minted each one. |
45
+ | `candle keys create [--scopes <a,b,c>] [--label <name>] [--expires-in <days>] [--tx-limit <usd> [--reset daily\|weekly\|monthly\|never]]` | Creates a new API key and prints the plaintext exactly once, with the same optional name, expiration, and USD transaction limit the portal's create form takes. Stored locally only if the CLI does not already hold a working key. |
46
+ | `candle keys revoke <prefix>` | Revokes an API key by prefix. Revoking the CLI's own stored key also clears it locally. |
47
+ | `candle wallets` | Shows the account's embedded (launch) wallets and any linked wallets, using the API key. |
48
+ | `candle mcp [--tools <a,b,c>] [--read-only] [--print-config]` | Runs the Candle MCP server (`npx @candledottv/mcp`) with this CLI's stored API key and API URL in its environment, so an MCP client config is just `{"command": "candle", "args": ["mcp"]}`. `--read-only` starts it with no key and only the three keyless read tools; `--tools` pins an explicit allowlist; `--print-config` prints the ready-to-paste client block instead of launching. |
49
+ | `candle doctor` | Runs a full health check (runtime, backend, credentials, API reachability, credential validity, wallet delegation) as a PASS/FAIL/SKIP table. Exits nonzero on any FAIL. |
50
+
51
+ Every command accepts these global options:
52
+
53
+ | Flag | Effect |
54
+ | --- | --- |
55
+ | `--api-url <url>` | Overrides the API base URL for this invocation, beating `CANDLE_API_URL` and the stored config value. |
56
+ | `--json` | Machine-readable output instead of a formatted table or summary, generally the underlying API response. One exception: `auth login`'s JSON output still omits the plaintext device token and API key, matching its human-readable summary, since login never displays either value in any mode. |
57
+ | `--help`, `-h` | Prints usage. |
58
+ | `--version`, `-v` | Prints the CLI version. |
59
+
60
+ ## The `--json` contract
61
+
62
+ For agents and scripts, `--json` guarantees: **stdout carries exactly one JSON value** -- the
63
+ result on success, or a failure envelope -- and stderr carries diagnostics only. Exit codes:
64
+ `0` success, `1` failure (the envelope says why), `2` usage error (the arguments themselves were
65
+ wrong; nothing ran).
66
+
67
+ The failure envelope is stable:
68
+
69
+ ```json
70
+ {
71
+ "ok": false,
72
+ "code": "TIER_REQUIRED",
73
+ "status": 403,
74
+ "message": "Pro tier required",
75
+ "suggestion": "Stake CNDL to reach Pro.",
76
+ "docsUrl": "https://docs.candle.tv/developers/agent-access"
77
+ }
78
+ ```
79
+
80
+ `code` is always present (the API's error code, an RFC 6749 error for the device flow,
81
+ `NETWORK_UNREACHABLE` when the server was never reached, `USAGE` for argument errors, or a
82
+ local precondition code like `NO_DEVICE_TOKEN`). `suggestion` is the fix as a command or
83
+ setting when one is known; `docsUrl` appears when the API names a docs page for this error.
84
+ Parse stdout, switch on `code`, run the `suggestion`.
85
+
86
+ ## Credential storage
87
+
88
+ Two credentials are stored: a device token (`cndl_dvc_...`, scoped to key management) and an API
89
+ key (`cndl_live_...` or `cndl_test_...`, scoped to whatever your device authorized). Neither is ever
90
+ written to the config file, logged, or printed, with one exception: `keys create` shows the
91
+ plaintext API key exactly once, at the moment it's issued. `auth login` never prints either
92
+ plaintext value, in any mode (including `--json`) -- both credentials go straight into storage,
93
+ since the whole point of the CLI managing them is that you never have to see or copy them.
94
+
95
+ The CLI picks the best available backend for your machine, in this order:
96
+
97
+ 1. **macOS Keychain**, via the `security` CLI, when available.
98
+ 2. **Linux Secret Service**, via `secret-tool`, when the binary is present and a real store/lookup
99
+ round trip succeeds (a headless box can have the binary installed with no Secret Service
100
+ actually running; the CLI checks for that rather than trusting the binary's presence alone).
101
+ 3. **An encrypted file** (`~/.config/candle/credentials.enc`, AES-256-GCM, PBKDF2-derived key),
102
+ everywhere else, Windows included. This is a first-class fallback, not an error: headless Linux
103
+ agents are exactly where this matters most.
104
+
105
+ `candle auth status` and `candle doctor` both report which backend is active.
106
+
107
+ ## Environment variables
108
+
109
+ | Variable | Effect |
110
+ | --- | --- |
111
+ | `CANDLE_DEVICE_TOKEN` | Overrides the stored device token for this process. Every command that needs the device token checks this first, before the store. |
112
+ | `CANDLE_API_KEY` | Overrides the stored API key for this process, same precedence as above. |
113
+ | `CANDLE_API_URL` | Overrides the API base URL, beating the stored config value (but not an explicit `--api-url` flag). |
114
+ | `CANDLE_KEYRING_PASSPHRASE` | The passphrase for the encrypted-file backend. Without it, a non-interactive process (no TTY) fails with a clear error rather than falling back to writing plaintext; an interactive session is prompted instead. |
115
+ | `CANDLE_CONFIG_DIR` | Overrides where the CLI keeps its config and encrypted-file credentials (default `~/.config/candle`). Mainly a testing seam. |
116
+
117
+ `CANDLE_DEVICE_TOKEN` and `CANDLE_API_KEY` together mean CI needs no storage backend at all: set
118
+ both and every command works without ever touching a keychain or the encrypted file.
119
+
120
+ ## What this CLI deliberately does not do
121
+
122
+ **Launch, trade, and order commands.** Executing trades and launches belongs to the SDK and MCP
123
+ server, not this CLI. This CLI's whole job is credential management plus a handful of read-only or
124
+ administrative operations; anything that moves an agent's actual workload stays with the packages
125
+ built to run one.
126
+
127
+ **`keys limits`.** There is no command for setting per-key spend limits, because the API route
128
+ that sets them (`PUT /keys/:prefix/limits`) structurally rejects a device token. It only accepts
129
+ an agent key or a live session, since a spend limit is fund-movement authority, and this CLI's
130
+ device token is scoped narrowly to key management. Manage limits from the portal.
131
+
132
+ **`devices list` / `devices revoke`.** The device-token endpoints (`GET`/`DELETE
133
+ /device/tokens`) are session-only by design: this is the self-renewal guard that keeps a stolen
134
+ device token from reading your device metadata (labels, timestamps, revocation state) or revoking
135
+ a sibling device. A device token cannot list or revoke devices, including itself, which is why
136
+ `auth logout` can revoke the API key it manages but has to send you to the portal to revoke the
137
+ device token. Sibling device prefixes are not themselves secret: they appear in `keys list`'s
138
+ "minted by" column, which is attribution and grants no capability. Device management is the
139
+ portal's job, not this CLI's.