@tonbo/cli 0.4.0 → 0.6.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/README.md +66 -189
- package/dist/bin/tonbo.js +1617 -2962
- package/package.json +9 -15
package/README.md
CHANGED
|
@@ -1,241 +1,118 @@
|
|
|
1
1
|
# Tonbo CLI
|
|
2
2
|
|
|
3
|
-
Install the public package with Node.js 22 or newer:
|
|
3
|
+
The Tonbo CLI signs you in to Tonbo and manages account resources from the command line. Install the public package with Node.js 22 or newer:
|
|
4
4
|
|
|
5
5
|
```console
|
|
6
6
|
npm install --global @tonbo/cli
|
|
7
7
|
tonbo --version
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Sign in
|
|
11
11
|
|
|
12
12
|
```console
|
|
13
|
-
tonbo login
|
|
14
|
-
tonbo
|
|
15
|
-
No Harness-specific configuration was found in this agent.
|
|
16
|
-
? Which supported Harness should Tonbo use?
|
|
17
|
-
❯ PI (`pi`) Run this agent with the pi command.
|
|
18
|
-
? How should this Agent connect to Tonbo?
|
|
19
|
-
❯ Create a new agent Create it only after you confirm the complete configuration.
|
|
20
|
-
Use an existing agent
|
|
21
|
-
Set up later
|
|
22
|
-
? Agent name [my-agent]:
|
|
23
|
-
|
|
24
|
-
Tonbo Agent configuration:
|
|
25
|
-
Agent: Create my-agent in my-account (permanent address assigned after creation)
|
|
26
|
-
Harness: PI
|
|
27
|
-
Execution: PI CLI (`pi`)
|
|
28
|
-
Model: claude-sonnet-4-5
|
|
29
|
-
? Create agent and .tonbo with this configuration?
|
|
30
|
-
❯ Create agent and .tonbo
|
|
31
|
-
Edit configuration Change the agent, Harness, execution mode, model, or SDK entrypoint.
|
|
32
|
-
Cancel
|
|
33
|
-
Created agent my-agent and .tonbo.
|
|
34
|
-
Agent: my-agent (my-agent-my-account.tonbo.sh)
|
|
35
|
-
Organization: my-account
|
|
36
|
-
Application: https://my-agent-my-account.tonbo.sh
|
|
37
|
-
Harness: PI
|
|
38
|
-
Mode: PI CLI
|
|
39
|
-
Next: tonbo deploy
|
|
13
|
+
tonbo login [--account <name>]
|
|
14
|
+
tonbo logout
|
|
40
15
|
```
|
|
41
16
|
|
|
42
|
-
|
|
17
|
+
`login` opens the browser at `https://tonbo.dev/cli/login`, where you pick the account (your personal account unless `--account` names another) and approve a personal API key named `CLI on <hostname>`. The browser returns a one-time code to a local callback on `127.0.0.1`, and the CLI redeems it with its PKCE verifier for the key. The key acts as you with your role in that account, expires after six months and replaces the key an earlier login on the same host created; there is no refresh, so an expired or revoked key asks you to run `tonbo login` again. One login holds one account: log in again to switch accounts.
|
|
43
18
|
|
|
44
|
-
The
|
|
19
|
+
The login and the credentials file are shared with [`yield`](../yield) through `@tonbo/cli-core`: either CLI's `login` signs both in, and either `logout` signs both out. The login is saved at `${XDG_CONFIG_HOME:-$HOME/.config}/tonbo/credentials.json` as `{version, account_id, key_id, key, expires_at}`. The CLI atomically replaces that file with owner-only permissions and refuses a symlink or a file other users can read. A file written by an earlier CLI release is not migrated; run `tonbo login`.
|
|
45
20
|
|
|
46
|
-
|
|
47
|
-
# Tonbo Agent configuration.
|
|
48
|
-
# Edit this file directly or run `tonbo init` to reconfigure.
|
|
49
|
-
version = 2
|
|
50
|
-
agent = "my-agent-my-account.tonbo.sh"
|
|
21
|
+
`logout` revokes the saved key through the Management API and removes the file. If the revocation fails, the file is still removed and the CLI reports the key id, so you can revoke it under API keys in the console.
|
|
51
22
|
|
|
52
|
-
|
|
53
|
-
runtime = "pi"
|
|
23
|
+
### Environment
|
|
54
24
|
|
|
55
|
-
|
|
56
|
-
|
|
25
|
+
- `TONBO_API_KEY`: a personal key (`tbo_…`) used instead of the saved login, for non-interactive use such as CI. `logout` acts only on the saved login.
|
|
26
|
+
- `TONBO_API_ORIGIN`: the Management API origin, `https://api.tonbo.dev` by default; it must be https (or http on a loopback address). The login page is served from the same origin without its `api.` label.
|
|
57
27
|
|
|
58
|
-
|
|
59
|
-
model = "claude-sonnet-4-5"
|
|
60
|
-
```
|
|
28
|
+
## Commands and the Management API
|
|
61
29
|
|
|
62
|
-
|
|
30
|
+
Every command other than `login` and `logout` calls one operation of the [Management API](../../contracts/management/openapi-v1.yaml) and is named by that operation's `x-tonbo-cli`; the command set and the operations tagged with a command are the same set, which `test/commands.test.ts` checks in both directions. The CLI resolves each request from the operation table of the internal package [`@tonbo/cli-core`](../../packages/tonbo-cli-core) (`src/generated/contracts.ts`, which `pnpm --filter @tonbo/cli-core generate:contracts` derives from the contract). `login` and `logout` are the named exception: they obtain and discard the key the other commands present as their Bearer credential. What a command may do is what your role in the logged-in account allows; the CLI never decides it.
|
|
63
31
|
|
|
64
|
-
|
|
32
|
+
| Command | Operation | Request |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| `tonbo account show` | `getAccount` | `GET /v1/account` |
|
|
35
|
+
| `tonbo region list` | `listRegions` | `GET /v1/regions` |
|
|
36
|
+
| `tonbo member list [--limit <n>] [--cursor <c>]` | `listMembers` | `GET /v1/members` |
|
|
37
|
+
| `tonbo member update <member> [--role <role>] [--name <name>]` | `updateMember` | `PATCH /v1/members/{subject}` |
|
|
38
|
+
| `tonbo agent create <name> [--role <role>] [--region <region>] [--idempotency-key <key>]` | `createAgent` | `POST /v1/agents` |
|
|
39
|
+
| `tonbo api-key list [--limit <n>] [--cursor <c>]` | `listApiKeys` | `GET /v1/api-keys` |
|
|
40
|
+
| `tonbo api-key create <name> [--member <member>] [--read-only] [--bucket <name>]… [--database <name>]… [--database-prefix <prefix>]… [--expires-in <period>]` | `createApiKey` | `POST /v1/api-keys` |
|
|
41
|
+
| `tonbo api-key show <key-id>` | `getApiKey` | `GET /v1/api-keys/{key_id}` |
|
|
42
|
+
| `tonbo api-key revoke <key-id> [--yes]` | `revokeApiKey` | `DELETE /v1/api-keys/{key_id}` |
|
|
43
|
+
| `tonbo bucket list [--limit <n>] [--cursor <c>]` | `listBuckets` | `GET /v1/buckets` |
|
|
44
|
+
| `tonbo bucket create <name> [--region <region>] [--idempotency-key <key>]` | `createBucket` | `POST /v1/buckets` |
|
|
45
|
+
| `tonbo bucket show <name>` | `getBucket` | `GET /v1/buckets/{name}` |
|
|
46
|
+
| `tonbo bucket update <name> (--public \| --private)` | `updateBucket` | `PATCH /v1/buckets/{name}` |
|
|
47
|
+
| `tonbo bucket delete <name> [--yes]` | `deleteBucket` | `DELETE /v1/buckets/{name}` |
|
|
48
|
+
| `tonbo database list [--prefix <prefix>] [--limit <n>] [--cursor <c>]` | `listDatabases` | `GET /v1/databases` |
|
|
49
|
+
| `tonbo database create <name> [--region <region>] [--idempotency-key <key>]` | `createDatabase` | `POST /v1/databases` |
|
|
50
|
+
| `tonbo database show <name>` | `getDatabase` | `GET /v1/databases/{name}` |
|
|
51
|
+
| `tonbo database update <name> (--public \| --private)` | `updateDatabase` | `PATCH /v1/databases/{name}` |
|
|
52
|
+
| `tonbo database delete <name> [--yes]` | `deleteDatabase` | `DELETE /v1/databases/{name}` |
|
|
53
|
+
| `tonbo database usage [--period <YYYY-MM>] [--sort list_value\|name] [--prefix <prefix>] [--limit <n>] [--cursor <c>]` | `listDatabaseUsage` | `GET /v1/usage/databases` |
|
|
54
|
+
| `tonbo usage show [--period <YYYY-MM>]` | `getUsage` | `GET /v1/usage` |
|
|
65
55
|
|
|
66
|
-
|
|
67
|
-
tonbo init --harness pi --driver native
|
|
68
|
-
tonbo init --harness pi --driver command --agent-entry dist/agent.mjs
|
|
69
|
-
tonbo agent use my-agent-my-account.tonbo.sh
|
|
70
|
-
```
|
|
56
|
+
### Output and errors
|
|
71
57
|
|
|
72
|
-
|
|
58
|
+
Every command prints an aligned table or a list of fields for people. With `--json` it prints the answer's `data` exactly as the API returned it, one JSON value on stdout and nothing else there. A list prints one page; when there is another, the CLI writes `More results: run again with --cursor <cursor>` to stderr, so `--json` output stays the API's `data`. `database usage --json` prints the whole answer, since its `other` row, checkpoint and prices belong with the rows. `--limit` asks for up to that many items (the API's default is 50, its maximum 200).
|
|
73
59
|
|
|
74
|
-
|
|
75
|
-
tonbo deploy
|
|
76
|
-
tonbo run "Reply with exactly READY."
|
|
77
|
-
```
|
|
60
|
+
A refusal prints the problem's detail, the fields a validation error names, and the request's `X-Request-Id` to stderr, and the command exits with status 1. An invalid or expired key adds `Run tonbo login`.
|
|
78
61
|
|
|
79
|
-
|
|
62
|
+
### Retried creations
|
|
80
63
|
|
|
81
|
-
|
|
64
|
+
`agent create`, `bucket create` and `database create` send an `Idempotency-Key`, a new UUID unless `--idempotency-key` names one. When a creation is not confirmed (the network failed or the server answered 5xx), the CLI prints its key; retrying with that key and the same arguments returns what the first request created instead of creating a second one. `api-key create` has no idempotency key, because a key's secret is never stored and a replay could not return it; a live key's name is unique, so a blind retry is refused with 409 rather than creating a second key.
|
|
82
65
|
|
|
83
|
-
|
|
84
|
-
tonbo region list
|
|
85
|
-
tonbo agent create my-agent --region us-east-1
|
|
86
|
-
tonbo init --region us-east-1
|
|
87
|
-
```
|
|
66
|
+
### Destructive commands
|
|
88
67
|
|
|
89
|
-
`
|
|
68
|
+
`api-key revoke`, `bucket delete` and `database delete` ask before they act when stdin and stderr are a terminal: a revocation is confirmed by typing `yes`, a deletion by typing the bucket's or database's name, as in the console. Without a terminal they refuse unless `--yes` is given.
|
|
90
69
|
|
|
91
|
-
|
|
92
|
-
tonbo run --session 4d8e9501-... "Continue the previous task."
|
|
93
|
-
```
|
|
70
|
+
## Account
|
|
94
71
|
|
|
95
|
-
|
|
72
|
+
`account show` prints the logged-in account: its id, name and kind, your member subject and role in it, and its limits.
|
|
96
73
|
|
|
97
|
-
|
|
98
|
-
tonbo run --no-wait "Refactor the build and run the full test suite."
|
|
99
|
-
tonbo turn wait 7a000000-... --session 4d8e9501-...
|
|
100
|
-
```
|
|
74
|
+
## Regions
|
|
101
75
|
|
|
102
|
-
|
|
76
|
+
`region list` shows the regions new resources can be created in, with each region's data-plane origin.
|
|
103
77
|
|
|
104
|
-
|
|
78
|
+
## Members and Agents
|
|
105
79
|
|
|
106
80
|
```console
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Source: 0123456 · main
|
|
112
|
-
Production: promoting (generation 4)
|
|
113
|
-
Application: https://my-agent-my-account.tonbo.sh
|
|
114
|
-
|
|
115
|
-
Agent process: starts with the first turn and stays warm while the runtime is active.
|
|
116
|
-
|
|
117
|
-
Start the Agent:
|
|
118
|
-
tonbo run "<prompt>"
|
|
119
|
-
|
|
120
|
-
Connect with SSH:
|
|
121
|
-
ssh my-agent.my-account@tonbo.sh
|
|
81
|
+
tonbo member list
|
|
82
|
+
tonbo member update pi-live --role admin
|
|
83
|
+
tonbo member update agent.80000000-0000-4000-8000-000000000003 --name pi-next
|
|
84
|
+
tonbo agent create my-agent --region us-east-1
|
|
122
85
|
```
|
|
123
86
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
```console
|
|
127
|
-
tonbo deploy --no-promote
|
|
128
|
-
tonbo deployments # ID NAME STATUS PRODUCTION SOURCE CREATED BY
|
|
129
|
-
tonbo deployments show 0f3a7c21 # datasheet and Rollouts for one Deployment
|
|
130
|
-
tonbo deployments promote 0f3a7c21 # move Production to a Deployment
|
|
131
|
-
tonbo deployments rollback # move Production back to the previous Production Deployment
|
|
132
|
-
tonbo deployments rollback 9b8c1d22 # or to a named one
|
|
133
|
-
```
|
|
87
|
+
`member list` lists the account's people and Agents with their kind, name and role. `member update` gives a member another role (`owner`, `admin` or `member`; only an owner grants `owner`) or renames an Agent with `--name`, or both at once. `<member>` is a member subject: a person's user id, or `agent.<agent id>` for an Agent. An Agent's bare id or its name works too: the CLI looks it up in `member list` and uses it only when exactly one member matches.
|
|
134
88
|
|
|
135
|
-
`
|
|
89
|
+
`agent create` creates an Agent identity with a role (`member` unless `--role` names another). Every Agent has a home region, chosen when it is created and never changed afterwards. Without `--region`, Tonbo uses the only region that accepts new Agents; when several do, an interactive `agent create` asks which one to use, and a non-interactive request without `--region` is refused.
|
|
136
90
|
|
|
137
|
-
|
|
91
|
+
## API keys
|
|
138
92
|
|
|
139
93
|
```console
|
|
140
|
-
|
|
94
|
+
tonbo api-key list
|
|
95
|
+
tonbo api-key create ci-reader --member pi-live --read-only --bucket events --expires-in 6_months
|
|
96
|
+
tonbo api-key revoke 70000000-0000-4000-8000-000000000007
|
|
141
97
|
```
|
|
142
98
|
|
|
143
|
-
|
|
99
|
+
`api-key list` shows your keys, or every key of the account for an owner or admin, with the last four characters of each secret. `api-key create` creates a personal key for you, or with `--member` a key of an Agent (its subject, id or name; owners and admins only). `--read-only`, and either `--bucket` or `--database` and `--database-prefix` (repeat each for several), narrow the key for its whole life; `--expires-in` is one of `15_days`, `1_month`, `6_months`, `1_year` or `never` (the default). The secret is printed once, in that answer only, with a warning on stderr: store it then, because no command can show it again. `api-key show` prints one key, and `api-key revoke` revokes it and every token minted from it.
|
|
144
100
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
The platform injects scoped inference access and owns PI Session capture. Do not put a model-provider API key or a Tonbo credential in `.tonbo`.
|
|
148
|
-
|
|
149
|
-
Deploy snapshots regular files under `.tonbo`, excluding `.git`, `node_modules`, PI package caches, local environment files and patterns in `.tonboignore`. Coding tools start in the persistent Artifacts workspace, while `AGENTS.md` and trusted `.pi` extensions, skills, prompts and settings load from the Deployment's uploaded source.
|
|
150
|
-
|
|
151
|
-
## Supported PI agent shapes
|
|
152
|
-
|
|
153
|
-
### 1. Agent-local Agent
|
|
154
|
-
|
|
155
|
-
Keep the normal PI agent layout. Tonbo runs the same `AGENTS.md`, `.pi/APPEND_SYSTEM.md`, `.pi/settings.json`, `.pi/extensions`, `.pi/skills` and `.pi/prompts` that local `pi` loads:
|
|
101
|
+
## Buckets
|
|
156
102
|
|
|
157
103
|
```console
|
|
158
|
-
|
|
159
|
-
tonbo
|
|
160
|
-
tonbo
|
|
161
|
-
tonbo run "Start the task."
|
|
104
|
+
tonbo bucket create events --region us-east-1
|
|
105
|
+
tonbo bucket update events --public
|
|
106
|
+
tonbo bucket delete events
|
|
162
107
|
```
|
|
163
108
|
|
|
164
|
-
|
|
109
|
+
`bucket list` and `bucket show` print each bucket's region, state, read access and URL; a stream lives at `{url}/{stream}`. `bucket create` creates a bucket in `--region`, or in the account's default region. `bucket update` publishes a bucket for anonymous reads with `--public` or takes it private with `--private`. `bucket delete` deletes a bucket and every stream in it; the bucket's name is never used again.
|
|
165
110
|
|
|
166
|
-
|
|
111
|
+
## Usage
|
|
167
112
|
|
|
168
|
-
|
|
169
|
-
pi install -l npm:@acme/my-pi-agent@1.2.3
|
|
170
|
-
pi
|
|
171
|
-
tonbo init
|
|
172
|
-
tonbo deploy
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
Remote npm packages must use an exact version. Git packages must use a full 40-character commit, for example `git:github.com/acme/my-pi-agent@0123456789abcdef0123456789abcdef01234567`. Movable tags, branches, ranges and `latest` fail deployment.
|
|
176
|
-
|
|
177
|
-
### 3. PI SDK app
|
|
178
|
-
|
|
179
|
-
Choose `Edit configuration`, change `Execution mode` to `PI SDK app`, and confirm the resulting summary. In automation, use `--driver command --agent-entry <file>`, or declare a command driver directly:
|
|
180
|
-
|
|
181
|
-
```toml
|
|
182
|
-
version = 2
|
|
183
|
-
|
|
184
|
-
[harness]
|
|
185
|
-
runtime = "pi"
|
|
186
|
-
secrets = ["GITHUB_TOKEN"]
|
|
187
|
-
|
|
188
|
-
[harness.driver]
|
|
189
|
-
kind = "command"
|
|
190
|
-
protocol = "pi-rpc-v1"
|
|
191
|
-
command = ["node", "dist/agent.mjs"]
|
|
192
|
-
|
|
193
|
-
[build]
|
|
194
|
-
command = ["npm", "run", "build"]
|
|
195
|
-
|
|
196
|
-
[inference]
|
|
197
|
-
model = "claude-sonnet-4-5"
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
`tonbo deploy` runs the build command before creating the source snapshot. The entrypoint must keep stdout exclusively for PI RPC and send logs to stderr. It receives `PI_CODING_AGENT_MODULE`, `PI_CODING_AGENT_DIR`, `PI_CODING_AGENT_SESSION_DIR`, `TONBO_PI_SESSION_FILE`, `TONBO_PI_SESSION_ID`, `TONBO_PI_PROVIDER`, `TONBO_PI_MODEL` and `TONBO_PI_RPC_PROTOCOL`. Load the platform PI SDK from `PI_CODING_AGENT_MODULE`, open `TONBO_PI_SESSION_FILE`, create an `AgentSessionRuntime`, and pass it to `runRpcMode()`. This lets the app customize tools and runtime services without forking PI while preserving Tonbo's durable Session and Turn protocol.
|
|
201
|
-
|
|
202
|
-
For a non-interactive invocation, provide a current Tonbo CLI OAuth access token; the committed `.tonbo` supplies the only Agent context:
|
|
203
|
-
|
|
204
|
-
```console
|
|
205
|
-
TONBO_ACCESS_TOKEN=... tonbo --json deploy
|
|
206
|
-
TONBO_ACCESS_TOKEN=... tonbo --json run "health check"
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
Node.js 22 or newer is required. Human OAuth tokens are stored at `${XDG_CONFIG_HOME:-$HOME/.config}/tonbo/credentials.json`; the CLI atomically replaces that file with owner-only permissions and never writes it into an Agent directory.
|
|
113
|
+
`usage show` prints the account's rated usage of one calendar month in UTC, the current one unless `--period YYYY-MM` names another: one line per product, region, dimension and model with its quantity and amount, and the total, in US dollars.
|
|
210
114
|
|
|
211
115
|
## Related design
|
|
212
116
|
|
|
213
|
-
- [Design documentation map](../../docs/design/README.md)
|
|
214
|
-
- [Agent source inspection and onboarding](../../docs/design/agent-source-onboarding.md)
|
|
215
|
-
- [Shared source inspector](../../packages/agent-source-inspector/README.md)
|
|
216
|
-
- [Agent resource model](../../docs/design/agent-resource-model.md)
|
|
217
|
-
- [Agent Deployments, Production and Rollouts](../../docs/design/agent-deployments.md)
|
|
218
117
|
- [ADR-0008: Tonbo CLI onboarding and credential boundaries](../../apps/user-center/docs/decisions/adr-0008-tonbo-cli-onboarding.md)
|
|
219
|
-
- [
|
|
220
|
-
|
|
221
|
-
## Machines
|
|
222
|
-
|
|
223
|
-
Machines belong to an Account independently of Agents. Allocate in `us-east-1`, bind an available Machine from Agent detail or the CLI, inspect measured metrics, and release it when no longer needed. Allocation starts no compute. The platform handles idle pause/resume automatically; there are no customer power controls or arbitrary Machine command/upload APIs.
|
|
224
|
-
|
|
225
|
-
```console
|
|
226
|
-
tonbo --json region list
|
|
227
|
-
tonbo --json machine allocate --account <account-uuid> --region us-east-1 --request-id <request-uuid>
|
|
228
|
-
tonbo --json machine allocation <request-uuid> --account <account-uuid>
|
|
229
|
-
tonbo --json machine list --account <account-uuid>
|
|
230
|
-
tonbo --json machine bind <machine-uuid> --agent <agent-uuid>
|
|
231
|
-
tonbo --json machine show <machine-uuid>
|
|
232
|
-
tonbo --json machine metrics <machine-uuid>
|
|
233
|
-
tonbo --json machine unbind <machine-uuid>
|
|
234
|
-
tonbo --json machine release <machine-uuid>
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
Only one active Agent binding per Machine and one Machine per Agent are currently supported. Unbinding drains execution and completes physical deletion, final usage settlement and storage credential revocation before the Machine becomes available. Wait for `available: true` in `machine show` before rebinding. Cross-Agent reassignment resets rootfs; the destination mounts its own Agent Workspace and Sessions. Hidden pause/resume within the same Agent retains rootfs and process state. Release also drains an existing binding automatically; it does not delete Agent files or Sessions. A Machine binds only to an Agent in the same region. `machine list` names any region it could not reach in `unavailable_regions`; its Machines are missing from that answer.
|
|
238
|
-
|
|
239
|
-
`tonbo agent list` lists accessible Agents without requiring a local `.tonbo` file. JSON command output uses `agent` for one Agent and `agents` for the list; there is no duplicate `agent` output alias.
|
|
240
|
-
|
|
241
|
-
Persist the allocation request UUID before sending when automating. Reuse it with the same account and region after a lost response; lookup returns the original Machine even after release. Omitting `--request-id` generates one, included in the success output or retry error.
|
|
118
|
+
- [Tonbo CLI release](../../docs/operations/tonbo-cli-release.md)
|