@tangle-network/sandbox-cli 0.12.2-develop.20260726033513.aa4b682 → 0.12.6

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 CHANGED
@@ -30,7 +30,9 @@ npx @tangle-network/sandbox-cli sandbox list
30
30
  npx tangle-sandbox --help
31
31
  ```
32
32
 
33
- Never run bare `npx tangle` (or `npx tangle-cli`) — those npm names belong to unrelated third-party packages and would execute someone else's code. The official names are `@tangle-network/sandbox-cli` and its forwarding alias `tangle-sandbox`.
33
+ Never run bare `npx tangle` (or `npx tangle-cli`).
34
+ Those npm names belong to unrelated third-party packages and would execute someone else's code.
35
+ The official names are `@tangle-network/sandbox-cli` and its forwarding alias `tangle-sandbox`.
34
36
 
35
37
  Install globally to expose the short `tangle` binary on PATH:
36
38
 
@@ -50,21 +52,32 @@ pnpm --filter @tangle-network/sandbox-cli build
50
52
  node products/sandbox/cli/bin/tangle.js --help
51
53
  ```
52
54
 
55
+ ## Supervisor accounting
56
+
57
+ `tangle supervise` reports measured tokens and cost for successful and failed runs.
58
+ A run without a winner can still incur cost.
59
+ Unknown totals display as `Unavailable` and appear as `null` in JSON output.
60
+
53
61
  ## Authentication
54
62
 
55
63
  Three flows are supported:
56
64
 
57
65
  - **Browser login** (default): `tangle auth login` opens a browser to complete OAuth with `github`, `google`, or `microsoft` identity providers.
58
66
  - **Device code**: `tangle auth login --no-browser` for headless environments.
59
- - **API key**: `tangle auth login --api-key sk-tan-...` (or set `TANGLE_API_KEY`; `SANDBOX_API_KEY` accepted as deprecated alias).
67
+ - **API key**: `tangle auth login --api-key sk-tan-...` (or set `TANGLE_API_KEY`).
60
68
 
61
69
  Credential lookup precedence:
62
70
 
63
71
  1. `--api-key` flag
64
- 2. `TANGLE_API_KEY` environment variable (preferred)
65
- 3. `SANDBOX_API_KEY` environment variable (deprecated alias, accepted for backwards compatibility)
72
+ 2. `TANGLE_API_KEY_FILE` managed credential file
73
+ 3. `TANGLE_API_KEY` environment variable
66
74
  4. `~/.tangle/credentials` (populated by `tangle auth login`)
67
75
 
76
+ The sidecar publishes refreshed delegated credentials through `TANGLE_API_KEY_FILE`.
77
+ The CLI reads this file for each request, including requests from an existing client.
78
+ A configured file that is missing, unreadable, or malformed fails without falling back to an older key.
79
+ A verified Sandbox request can install a new source credential; an expired source cannot renew itself unattended.
80
+
68
81
  Common commands:
69
82
 
70
83
  ```bash
@@ -76,6 +89,50 @@ tangle auth profiles
76
89
 
77
90
  `tangle auth login` validates the supplied credential against `/v1/account/me`, which requires a valid token.
78
91
 
92
+ ### The two surfaces
93
+
94
+ Commands address one of two services, and the two accept different credentials.
95
+
96
+ | Surface | Command families | Credential |
97
+ |---|---|---|
98
+ | Sandbox API | `sandbox`, `exec`, `ssh`, `fs`, `process`, `snapshot`, `secret`, `agent`, `fleet`, `batch`, `usage` | the session `tangle auth login` stores, or an `sk-tan-*` key |
99
+ | Platform control plane (`id.tangle.tools`) | `keys`, `workflows`, `hub` | an `sk-tan-*` key only |
100
+
101
+ The platform does not accept the sandbox session: it belongs to a different
102
+ audience. After a browser login the CLI therefore mints a short-lived platform
103
+ key from that session on the first platform command, caches it in the same
104
+ credential store, and replaces it before it expires. Nothing durable is written
105
+ for a surface you never use, and no long-lived key sits on disk.
106
+
107
+ An `sk-tan-*` key is used exactly as supplied on both surfaces, whether it
108
+ arrives through `--api-key`, `TANGLE_API_KEY`, or `tangle auth login --api-key`,
109
+ so a spawned sandbox and a CI job keep the credential they were given and no
110
+ mint replaces it. `TANGLE_HUB_CAPABILITY_TOKEN` serves the `hub` commands only.
111
+
112
+ ### What the minted credential may do
113
+
114
+ The minted key lives for minutes, so the platform refuses key creation and
115
+ revocation through it: a credential that short must not add or destroy authority
116
+ that outlasts it.
117
+
118
+ - `tangle keys list` works after `tangle auth login`.
119
+ - `tangle keys create` and `tangle keys revoke` need a key you minted yourself:
120
+ set `TANGLE_API_KEY`, run `tangle auth login --api-key sk-tan-…`, or mint the
121
+ key in the web console.
122
+
123
+ Everything else on the control plane — `tangle workflows`, `tangle hub` — works
124
+ from the login alone.
125
+
126
+ `tangle auth status` reports both surfaces. It exits non-zero when either one
127
+ REFUSES the stored credential — a behaviour change for a script that gated on
128
+ the old sandbox-only check, and the point of it: the platform rejecting the
129
+ credential used to be reported as success. An unreachable platform is a
130
+ different answer and exits zero, because an outage says nothing about the
131
+ credential; read `platform.reachable` in `--json` to gate platform work.
132
+ `--base-url` names the sandbox host for BOTH halves: the session is checked
133
+ there, and the platform credential is minted there, so the two lines of the
134
+ answer always describe one deployment.
135
+
79
136
  ## Command Surface
80
137
 
81
138
  Top-level command groups:
@@ -91,6 +148,7 @@ Top-level command groups:
91
148
  - `usage`
92
149
  - `permissions`
93
150
  - `backend`
151
+ - `batch`
94
152
  - `process`
95
153
  - `fs`
96
154
 
@@ -101,7 +159,7 @@ Examples:
101
159
  tangle auth login --api-key sk_...
102
160
 
103
161
  # sandbox lifecycle
104
- tangle sandbox create --name my-box --image node:20 --ssh
162
+ tangle sandbox create --name my-box --environment node:20 --ssh
105
163
  tangle sandbox list
106
164
  tangle sandbox get sbx_123
107
165
  tangle sandbox stop sbx_123
@@ -112,14 +170,14 @@ tangle sandbox delete sbx_123
112
170
  tangle exec sbx_123 "npm test"
113
171
  tangle ssh sbx_123
114
172
  tangle agent prompt sbx_123 "Summarize this repo"
115
- tangle agent task sbx_123 "Fix the failing tests"
173
+ tangle agent prompt sbx_123 "Fix the failing tests"
116
174
  tangle fleet create --count 4 --coordinator
117
175
 
118
176
  # grant hub connections to the agent (see hub-reference.md for the 3 modes).
119
177
  # the connection is an id or a provider name (resolved via `tangle hub connections`).
120
- tangle agent task sbx_123 "triage issues" \
178
+ tangle agent prompt sbx_123 "triage issues" \
121
179
  --connection github:github.issues.search,github.issues.create
122
- tangle agent task sbx_123 "file the report" --connection github:* --allow-writes
180
+ tangle agent prompt sbx_123 "file the report" --connection github:* --allow-writes
123
181
 
124
182
  # temporary GPU for an eval; omitted provider picks the cheapest configured cloud
125
183
  tangle sandbox gpu run sbx_123 \
@@ -138,7 +196,7 @@ tangle fs ls sbx_123 /workspace
138
196
  ```
139
197
 
140
198
  Hub commands (`tangle hub …`) and `tangle agent --connection` auto-mint a
141
- short-lived platform Hub key from your `tangle auth login` session — no separate
199
+ short-lived platform Hub key from your `tangle auth login` session, with no separate
142
200
  key needed. See [`hub-reference.md`](./hub-reference.md) for the `--connection`
143
201
  grant modes, `--allow-writes`, and `permissions revert-writes`.
144
202
 
@@ -188,14 +246,40 @@ tangle sandbox create --name gpu-eval \
188
246
  The final detach output includes billed seconds and customer cost.
189
247
  Use `tangle usage` to inspect account-level GPU seconds and GPU spend.
190
248
 
249
+ ## Batch Runs
250
+
251
+ Run each task against one explicitly named backend:
252
+
253
+ ```bash
254
+ tangle batch run --tasks tasks.json --backend primary=opencode
255
+ ```
256
+
257
+ `tasks.json` is an array of `{ "id": "...", "message": "..." }` objects or an object with a `tasks` array.
258
+ At least one `--backend <id=type>` is required with `--tasks` or `--task`.
259
+
260
+ Repeat `--backend <id=type>` to run every task against multiple backends:
261
+
262
+ ```bash
263
+ tangle batch run --tasks tasks.json \
264
+ --backend writer=opencode \
265
+ --backend reviewer=claude-code \
266
+ --stream
267
+ ```
268
+
269
+ Backend IDs must be unique and use 1 to 128 letters, numbers, dots, underscores, or hyphens.
270
+ Use `--model provider/model` only when one backend is selected.
271
+ Each result is identified by both `taskId` and `backendId`.
272
+ JSON output reports `totalTasks`, `totalBackends`, `totalExecutions`, `totalSuccess`, `totalFailure`, `totalRetries`, and `successRate`.
273
+
274
+ Use `--request <file.json>` when each backend needs its own model, profile, server, or lifecycle configuration.
275
+ The file uses the same complete request shape as the TypeScript SDK and cannot be combined with inline task or backend flags.
276
+
191
277
  ## Provisioning Coverage
192
278
 
193
- `tangle sandbox create` exposes the full SDK provisioning surface, including image/environment, resources (CPU, memory, disk), temporary GPU leases, lifetime and idle timeout, driver and backend selection (`opencode`, `claude-code`, `codex`, `cursor`, `amp`, and other registry backends), SSH and web terminal, env and secret injection, metadata, initial permissions, git clone, tool pre-install, BYOS3 storage, snapshot restore, and outbound network controls. Run `tangle sandbox create --help` for the canonical flag list.
279
+ `tangle sandbox create` supports environments or container images, resources, temporary GPU leases, lifecycle limits, driver and backend selection, SSH and web terminal, environment variables, secrets, metadata, git clone, BYOS3 storage, and snapshot restore.
280
+ Use the `tools`, `permissions`, `network`, and `expose` commands after creation.
281
+ Run `tangle sandbox create --help` for the current flag list.
194
282
 
195
283
  ## Limitations
196
284
 
197
285
  - `snapshot restore` creates a new sandbox from a snapshot; the command signature suggests in-place restore.
198
-
199
- ## Design Follow-Up
200
-
201
- For the architecture review, parity checklist, and auth flow spec, see [CHECKLIST.md](./CHECKLIST.md).
package/SKILL.md CHANGED
@@ -1,34 +1,45 @@
1
1
  ---
2
2
  name: tangle-cli
3
- description: Use when interacting with Tangle sandboxes, executing hub tools, managing agent tasks, operating on sandbox filesystems, building workflows, connecting to external providers, or setting up integrations and automations from a terminal. Triggers include tangle, tangle sandbox, tangle hub, tangle agent, tangle exec, tangle fs, tangle snapshot, tangle secret, tangle workflows, tangle hub connect, github, slack, google, microsoft, external connections, provider integrations, hub tools, or any tangle command.
3
+ description: Use Tangle Sandbox CLI for lifecycle, prompts, files, fleets, Hub tools, and integrations.
4
4
  ---
5
5
 
6
6
  # Tangle CLI
7
7
 
8
8
  ## Overview
9
9
 
10
- `tangle` is the CLI for Tangle Sandbox operations — create sandboxes, run agents, execute hub tools, manage files, secrets, snapshots, git, and more. All commands support `--help` for inline reference.
10
+ `tangle` is the CLI for Tangle Sandbox operations: create sandboxes, run agents, execute hub tools, and manage files, secrets, snapshots, and git.
11
+ All commands support `--help` for inline reference.
11
12
 
12
13
  ## Auth
13
14
 
14
- Generic command auth modes, resolved in order:
15
+ Commands address one of two services. Sandbox commands (`sandbox`, `exec`,
16
+ `ssh`, `fs`, `snapshot`, `secret`, `agent`, …) address the sandbox API. Platform
17
+ commands (`keys`, `workflows`, `hub`) address the control plane at
18
+ `id.tangle.tools`, which accepts only an `sk-tan-*` key.
19
+
20
+ Sandbox command auth modes, resolved in order:
15
21
 
16
22
  | Priority | Source | Set via |
17
23
  |----------|--------|--------|
18
24
  | 1 | CLI flag | `--api-key <key>` |
19
- | 2 | Env var | `TANGLE_API_KEY` or `SANDBOX_API_KEY` |
25
+ | 2 | Env var | `TANGLE_API_KEY` |
20
26
  | 3 | Profile store | `tangle auth login` (keychain or file) |
21
27
 
22
- Hub commands resolve auth in this order:
28
+ Platform commands resolve auth in the same order, with one step added: the
29
+ session that `tangle auth login` stores is not a platform credential, so the CLI
30
+ mints a short-lived platform key from it on first use and refreshes it as
31
+ needed. Hub commands also accept `TANGLE_HUB_CAPABILITY_TOKEN`, ranked directly
32
+ below `--api-key`; other platform commands do not, because that token
33
+ authenticates `/v1/hub/exec` alone.
23
34
 
24
- | Priority | Source | Set via |
25
- |----------|--------|--------|
26
- | 1 | CLI flag | `--api-key <key>` |
27
- | 2 | Hub capability | `TANGLE_HUB_CAPABILITY_TOKEN` |
28
- | 3 | Env var | `TANGLE_API_KEY` or `SANDBOX_API_KEY` |
29
- | 4 | Profile store | `tangle auth login` (keychain or file) |
35
+ The minted key lives for minutes, so the platform refuses key creation and
36
+ revocation through it. `tangle keys list` works from a browser login; `tangle
37
+ keys create` and `tangle keys revoke` need a key you minted yourself
38
+ (`TANGLE_API_KEY`, `tangle auth login --api-key`, or the web console). A stored
39
+ `sk-tan-*` is presented as-is and never minted over.
30
40
 
31
- **Inside a sandbox:** `tangle` is automatically authenticated. No extra auth needed — commands work out of the box.
41
+ **Inside a sandbox:** `tangle` is automatically authenticated.
42
+ No extra authentication is needed.
32
43
 
33
44
  ```bash
34
45
  # Browser login (preferred)
@@ -48,7 +59,7 @@ tangle auth login --profile work
48
59
  tangle auth profiles use work
49
60
  ```
50
61
 
51
- For hub env auth, set **exactly one** of `TANGLE_API_KEY`/`SANDBOX_API_KEY` or `TANGLE_HUB_CAPABILITY_TOKEN`.
62
+ For hub env auth, set **exactly one** of `TANGLE_API_KEY` or `TANGLE_HUB_CAPABILITY_TOKEN`.
52
63
 
53
64
  ## Sandbox Lifecycle
54
65
 
@@ -105,7 +116,7 @@ tangle fleet create --count 4 \
105
116
  --gpu-idle-timeout 120
106
117
  ```
107
118
 
108
- ## Hub — Full Workflow
119
+ ## Full Hub Workflow
109
120
 
110
121
  Hub lets agents use connected provider tools (GitHub, etc.) through Tangle without seeing provider OAuth tokens.
111
122
 
@@ -141,7 +152,7 @@ tangle hub tools describe github.issues.search --json
141
152
 
142
153
  ### Tool Execution
143
154
 
144
- Two equivalent commands — `call` and `exec`:
155
+ Two equivalent commands are available: `call` and `exec`.
145
156
 
146
157
  ```bash
147
158
  # Basic call: <path tokens...> <json-input>
@@ -154,7 +165,8 @@ tangle hub call github issues createIssue '{"owner":"foo","repo":"bar","title":"
154
165
 
155
166
  ### Policy & Approvals
156
167
 
157
- Tools default to `ask` policy — they pause and require approval on first use.
168
+ Tools default to the `ask` policy.
169
+ They pause and require approval on first use.
158
170
 
159
171
  ```bash
160
172
  # List pending approvals
@@ -210,20 +222,14 @@ tangle secret update DATABASE_URL "new-value"
210
222
  tangle secret delete DATABASE_URL
211
223
  ```
212
224
 
213
- ## Snapshots & Checkpoints
225
+ ## Snapshots
214
226
 
215
227
  ```bash
216
- # Snapshots (point-in-time for cloning/restoring)
217
228
  tangle snapshot create <sandbox-id>
218
229
  tangle snapshot list <sandbox-id>
219
230
  tangle snapshot restore <sandbox-id> <snapshot-id> # creates new sandbox
220
231
  tangle snapshot revert <sandbox-id> <snapshot-id> # reverts in-place
221
232
  tangle snapshot delete <sandbox-id> <snapshot-id>
222
-
223
- # Checkpoints (lightweight, local)
224
- tangle checkpoint create <id>
225
- tangle checkpoint list|ls <id>
226
- tangle checkpoint delete|rm <id> <checkpoint-id>
227
233
  ```
228
234
 
229
235
  ## Templates
@@ -260,19 +266,40 @@ tangle team invitations [team] # List pending/historical invitations
260
266
  ## Workflows
261
267
 
262
268
  Authenticate with the `sk-tan-*` API key (`TANGLE_API_KEY`), same as the other
263
- platform commands — not a hub capability token.
269
+ platform commands, not a hub capability token. These commands address the
270
+ platform control plane, not the sandbox API. The host resolves from
271
+ `--base-url`, then `TANGLE_HUB_URL` (which a spawned sandbox injects to name
272
+ its own hub, so it wins over an ambient value), then `TANGLE_PLATFORM_URL`,
273
+ then `https://id.tangle.tools`. On `workflows`,
274
+ `--base-url` names the PLATFORM host — unlike `tangle keys`, where `--base-url`
275
+ is the sandbox API and `--platform-url` is the platform.
276
+
277
+ Authoring a workflow (graph topology, guards, joins, KV state, decisions):
278
+ https://sandbox.tangle.tools/docs/workflows
264
279
 
265
280
  ```bash
266
281
  tangle workflows validate workflow.yml
267
282
  tangle workflows schema # print JSON Schema
268
283
  tangle workflows create workflow.yml
284
+ tangle workflows apply workflow.yml # create or update, matched by the definition's name
269
285
  tangle workflows list
286
+ tangle workflows fleet # run tallies over a trailing window, failing first
270
287
  tangle workflows get <id>
271
288
  tangle workflows update <id> workflow.yml
272
289
  tangle workflows enable <id>
273
290
  tangle workflows disable <id>
274
291
  tangle workflows delete <id>
275
292
 
293
+ # Templates
294
+ tangle workflows templates # starter gallery
295
+ tangle workflows init <template-id> # instantiate, print YAML
296
+ tangle workflows init <template-id> --param repo=o/r --file workflow.yml
297
+
298
+ # Revisions
299
+ tangle workflows revisions <id> # definition history
300
+ tangle workflows revision <id> <rev> # one revision's YAML
301
+ tangle workflows rollback <id> <rev> # restore a rev as the new head
302
+
276
303
  # Runs
277
304
  tangle workflows run <id> # trigger a run
278
305
  tangle workflows run <id> --input pull_request.number=123 # with trigger inputs
@@ -280,6 +307,23 @@ tangle workflows run <id> --wait # wait + print resul
280
307
  tangle workflows runs <id> # run history
281
308
  tangle workflows run-detail <id> <runId> # single-run detail
282
309
  tangle workflows events <id> <runId> # tail live progress
310
+ tangle workflows cancel <id> <runId> # cancel a queued/running run
311
+ tangle workflows retry <id> <runId> # re-run a failed run with the same trigger context
312
+
313
+ # Cross-run KV state
314
+ tangle workflows kv list <id>
315
+ tangle workflows kv get <id> <key>
316
+ tangle workflows kv set <id> <key> '{"cursor":123}'
317
+ tangle workflows kv set <id> <key> '{"cursor":123}' --cas 4 # compare-and-swap
318
+ tangle workflows kv delete <id> <key>
319
+
320
+ # Run artifacts
321
+ tangle workflows artifacts <id> <runId>
322
+ tangle workflows artifact-download <id> <runId> <artifactId> --out report.json
323
+
324
+ # Human decisions
325
+ tangle workflows decisions <id> # pending approvals
326
+ tangle workflows decision-resolve <id> <runId> --choice deploy
283
327
  ```
284
328
 
285
329
  ## Other Commands
@@ -308,6 +352,7 @@ tangle tools install <id> python 3.12
308
352
 
309
353
  # Batch tasks across sandboxes
310
354
  tangle batch run --tasks tasks.json
355
+ tangle batch run --tasks tasks.json --backend writer=opencode --backend reviewer=claude-code --stream
311
356
 
312
357
  # Intelligence reports
313
358
  tangle intelligence sandbox <id>
@@ -337,22 +382,23 @@ tangle permissions add <sandboxId> --userId <userId> --role editor
337
382
 
338
383
  | Goal | Commands |
339
384
  |------|----------|
340
- | Spin up sandbox, run agent | `tangle sandbox create --name X` → `tangle agent task <id> "..."` |
385
+ | Spin up sandbox, run agent | `tangle sandbox create --name X` → `tangle agent prompt <id> "..."` |
341
386
  | Connect GitHub, read issues | `tangle hub connect github` → `tangle hub tools search "issues" --provider github` → `tangle hub call github issues search '{"q":"repo:X/Y is:issue"}'` |
342
387
  | Push code from sandbox to GitHub | `tangle hub connect github` → `tangle git add <id> files` → `tangle git commit <id> -m "msg"` → `tangle git push <id>` |
343
388
  | Save and restore state | `tangle snapshot create <id>` → ...work... → `tangle snapshot revert <id> <snap-id>` |
344
389
  | Set secret for agent use | `tangle secret create GITHUB_TOKEN "..."` → agent reads via `process.env.GITHUB_TOKEN` |
345
390
  | Set hub permissions | `tangle hub permissions set --connection conn_xxx --action github.issues.createIssue --decision allow` |
346
- | Batch parallel agent tasks | `tangle batch run --tasks tasks.json` (array of `{sandboxId, message}`) |
391
+ | Batch parallel agent prompts | `tangle batch run --tasks tasks.json --backend primary=opencode` (array of `{id, message}`) |
392
+ | Compare backends on the same tasks | `tangle batch run --tasks tasks.json --backend writer=opencode --backend reviewer=claude-code --stream` |
347
393
 
348
394
  ## Common Mistakes
349
395
 
350
- - **Forgetting `--reveal` on `secret show`** — values are hidden by default for safety.
351
- - **Using API-key env and `TANGLE_HUB_CAPABILITY_TOKEN` together for hub** — set exactly one env auth source, or use `--api-key` to override both.
352
- - **Calling hub tools without `--approve` on first use** — use `--approve` or set policy to `allow` first.
353
- - **Missing `--json` flag when piping output** — many commands need explicit `--json` for machine-readable output.
354
- - **`tangle hub exec` vs `tangle exec`** — `hub exec` runs hub tools; `exec` runs shell commands in a sandbox.
355
- - **`hub resume` doesn't replay** — after `hub resume --accept`, rerun original `hub exec` with `--approve`.
396
+ - **Forgetting `--reveal` on `secret show`:** values are hidden by default for safety.
397
+ - **Using API-key env and `TANGLE_HUB_CAPABILITY_TOKEN` together for hub:** set exactly one env auth source, or use `--api-key` to override both.
398
+ - **Calling hub tools without `--approve` on first use:** use `--approve` or set policy to `allow` first.
399
+ - **Missing `--json` when piping output:** many commands need explicit `--json` for machine-readable output.
400
+ - **`tangle hub exec` vs `tangle exec`:** `hub exec` runs hub tools; `exec` runs shell commands in a sandbox.
401
+ - **`hub resume` does not replay:** after `hub resume --accept`, rerun the original `hub exec` with `--approve`.
356
402
 
357
403
  ## Token Safety
358
404