@computesdk/cli 2.6.13 → 2.6.15

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
@@ -3,23 +3,141 @@
3
3
  The `compute` CLI for the ComputeSDK platform — Actions CI, the compute market,
4
4
  sandboxes, and the benchmarks toolchain.
5
5
 
6
+ Start with the [CLI quickstart](https://docs.computesdk.com/start-here/quick-start), [project sync](https://docs.computesdk.com/cli/project-sync), or [Platform SDK quickstart](https://docs.computesdk.com/start-here/sdk-quick-start).
7
+
6
8
  ## Install
7
9
 
8
10
  ```bash
9
11
  npm i -g @computesdk/cli # or: pnpm dlx @computesdk/cli <cmd>
10
12
  ```
11
13
 
14
+ CLI 2.6.14 includes the onboarding and sync commands below. For other installation methods, see [installation](https://docs.computesdk.com/start-here/installation). Check `compute --version` and update before using newer commands.
15
+
16
+ ## First sandbox
17
+
18
+ ```bash
19
+ compute sandboxes route # preview placement and price without creating
20
+ compute new # sign in if needed, create and select a sandbox
21
+ compute exec echo hello # run on the selected sandbox
22
+ compute list # see your sandboxes
23
+ compute destroy # destroy the selected sandbox and stop billing
24
+ compute run echo hello # or create, run, and clean up in one command
25
+ compute -v # print the CLI version (--version also works)
26
+ ```
27
+
28
+ Common sandbox commands are available directly under `compute`: `list`, `get`,
29
+ `use`, `exec`, `run`, `serve`, `spawn`, `ps`, `logs`, `kill`, `wait`, `cp`, `url`, and `destroy`.
30
+ Existing `compute instances`, `compute sandboxes`, and `compute sbx` paths keep
31
+ working. Advanced settings, billing and snapshots remain under `compute instances`.
32
+
33
+ Creation selects a sandbox for the current repository/directory and organization.
34
+ An explicit ID wins over `COMPUTE_INSTANCE`, which wins over the stored selection.
35
+ Use `compute use <id>` to change the selection, or `compute new --no-use` to leave
36
+ it alone. A new sandbox bills until its timeout or destruction; `compute run`
37
+ cleans up after its command finishes (unless you use `--keep` or `--detach`).
38
+
39
+ ## Bring your project
40
+
41
+ Keep the provider first, then add a local directory:
42
+
43
+ ```bash
44
+ compute new e2b . # create on e2b and sync this directory into /app
45
+ compute new daytona ./my-app
46
+ compute new . # let your configured router choose
47
+ compute exec --cwd /app npm test
48
+ ```
49
+
50
+ An optional project path must be last and use explicit path syntax (`.`,
51
+ `./my-app`, `../my-app`, or an absolute path). Bare words keep meaning provider
52
+ names. The project contents go directly into `/app`, without a wrapper folder.
53
+ The sandbox becomes selected after sync succeeds (`--no-use` opts out). A failed
54
+ initial sync attempts teardown and leaves the previous selection intact; any
55
+ unconfirmed cleanup reports the sandbox ID for recovery.
56
+
57
+ ## Sync directories
58
+
59
+ ```bash
60
+ compute sync . :/app # local → selected sandbox
61
+ compute sync :/app ./results # selected sandbox → local
62
+ compute sync <sandbox-a>:/app <sandbox-b>:/app # sandbox → sandbox
63
+ compute sync . :/app --dry-run # inspect changes
64
+ compute sync . :/app --delete # remove destination-only entries
65
+ compute sync . :/app --watch # repeat until Ctrl-C
66
+ ```
67
+
68
+ Each invocation syncs directory contents in one direction. New and changed
69
+ files are compared by content and permissions; unchanged files are left alone.
70
+ Local uploads respect nested `.gitignore` files, including repository ancestor
71
+ rules. `.git` data is always excluded. Destination-only files stay unless
72
+ `--delete` is explicit; ignored source paths stay protected from deletion.
73
+ Binary files, executable permissions, and relative symlinks within the project
74
+ are supported. Source hardlinks are copied as separate files.
75
+ File/directory type conflicts and overwriting hard-linked destination files
76
+ require manual resolution.
77
+
78
+ `--dry-run` changes no destination files. `--watch` polls every two seconds and
79
+ finishes its current pass before stopping on Ctrl-C; it cannot combine with
80
+ `--dry-run`. `--json` returns one result with `dryRun`, `copied`, and `deleted`;
81
+ watch mode emits a JSON line for each nonempty pass.
82
+
83
+ Sync reuses the platform OCI checkpoint engine for scanning, diffing, capture,
84
+ and integrity-checked restore. Sandbox endpoints require Node.js and the platform
85
+ transfer API. Only the OCI layers needed for planned writes travel through the
86
+ CLI; a changed file can require its whole top-level directory layer. Sandbox-to-
87
+ sandbox transfers relay through the CLI. Filesystem roots, overlapping directories
88
+ on the same sandbox, symlink traversal, and links outside the project are refused.
89
+ Avoid concurrent edits at the destination while a sync runs.
90
+
12
91
  ## Login
13
92
 
14
93
  ```bash
15
- compute login # OAuth device flow → ~/.benchsdk/credentials.json
94
+ compute login # browser sign-in
95
+ compute login --no-browser # print the URL and code for manual sign-in
16
96
  compute logout # clear stored credentials
17
97
  compute --login / --logout # same, as flags
18
98
  ```
19
99
 
20
- Login uses the same OAuth device flow as `bench auth login` — every first-party
21
- CLI shares one credential store (`~/.benchsdk/credentials.json`) and refresh
22
- tokens renew automatically.
100
+ Login opens your browser and saves your session locally. Access tokens refresh
101
+ automatically. The CLI also prints a URL and code for manual sign-in. Press
102
+ Ctrl-C to cancel; denied or expired codes produce an actionable error.
103
+
104
+ Interactive `compute new`, `compute instances create`, and `compute run` start
105
+ login only when there are no stored credentials or explicit API keys. After
106
+ approval they continue the original command once, with its original options.
107
+ `--no-browser` prints the link without opening it. In CI, without a terminal,
108
+ or with `--json`/`--quiet`, missing credentials fail promptly; run `compute login`
109
+ separately or set `COMPUTE_API_KEY`. Existing expired sessions and invalid keys
110
+ are reported rather than silently replaced with another identity.
111
+
112
+ Pending sign-ins are saved privately on this machine and reused until approval,
113
+ denial, or expiry. Restart `compute login` after an interruption to resume;
114
+ `compute login --new` requests a fresh code. Logout clears pending sign-ins too.
115
+ For scripts and agents, `compute login --json` returns only the verification URL,
116
+ public code, and expiry immediately; `compute login --wait --json` resumes polling
117
+ and saves the session without opening a browser. Normal login still opens the
118
+ browser and waits for approval.
119
+
120
+ ## Status and jobs
121
+
122
+ ```bash
123
+ compute status # auth, effective org, credits, selected sandbox, routing
124
+ compute status --json # structured diagnostics, including partial failures
125
+ compute status --check # exit 1 unless authenticated and routing is ready
126
+ compute exec --detach "npm run dev"
127
+ compute logs <job-id>
128
+ compute wait <job-id> # wait and return the process exit code
129
+ compute kill <job-id> # SIGTERM; override with --signal SIGKILL
130
+ ```
131
+
132
+ Status checks the default sandbox route without creating a sandbox; no selected
133
+ sandbox is required. It accepts the usual `--org`, `--api-key`, and `--base-url`.
134
+ Job commands also accept an explicit sandbox ID before the job ID.
135
+
136
+ `compute run` ends with an stderr summary of exit code, elapsed time, provider,
137
+ and confirmed cleanup or retention. Cost appears only when teardown returns a
138
+ settled amount. `run --json` emits stdout/stderr JSON Lines followed by a summary
139
+ with `sandboxId`, `jobId`, `exitCode`, `elapsedSeconds`, `provider`, `deleted`,
140
+ `kept`, and optional `costUsd`. `run --detach --json` returns a detached job record.
23
141
 
24
142
  ## Commands
25
143
 
@@ -27,7 +145,6 @@ tokens renew automatically.
27
145
  compute actions … # Actions API — repos, workflows, dispatch, runs, schedule, logs, vault (see below)
28
146
  compute market … # buy and sell on the compute market (cap, bids, credits, listings)
29
147
  compute sandboxes … # platform sandbox control plane
30
- compute bench … # benchmarks CLI (run, auth, org, results, …)
31
148
  compute providers # SDK provider credentials in this environment
32
149
  compute byok … # the org's BYOK provider keys and custom rates (see below)
33
150
  compute org list # your organizations (* = active)
@@ -47,17 +164,55 @@ override, pass `--org <slug>` (on the root command or any `sandboxes` /
47
164
  on the request. Precedence: `--org` > `COMPUTE_ORG` > the stored login's org.
48
165
  The platform ignores the header for org API keys.
49
166
 
50
- For `compute sandboxes exec` and `compute sandboxes spawn`, everything after
167
+ For `compute exec` and `compute spawn`, everything after
51
168
  the command's first word goes to the sandbox untouched — flags like `uname
52
169
  -a` or `node -e` are not CLI options. Pass CLI options (`--json`,
53
- `--timeout-ms`, `--cwd`, `-e/--env`, `--stdin`, `--org`) before the command;
170
+ `--timeout`/`--timeout-ms`, `--stream`, `--detach`, `--cwd`, `-e/--env`, `--stdin`, `--org`) before the command;
54
171
  a bare `--` before the command is optional but supported.
55
172
 
56
173
  ```bash
57
- compute sandboxes exec sb1 uname -a
58
- compute sandboxes spawn sb1 --cwd /app -e NODE_ENV=production -- npm run dev
174
+ compute exec <id> uname -a
175
+ compute spawn <id> --cwd /app -e NODE_ENV=production npm run dev
59
176
  ```
60
177
 
178
+ ### Executing commands
179
+
180
+ ```bash
181
+ compute exec "npm test" # one argument: shell command
182
+ compute exec node -v # multiple arguments: preserve argv
183
+ compute exec "echo hello && echo world" # shell operators run remotely
184
+ compute exec --cwd /app --timeout 120 npm test
185
+ compute exec --stream "npm run build" # follow output while it runs
186
+ compute exec --timeout 0 "long-running-command" # no command time limit
187
+ compute exec --detach "npm run dev" # return a background job ID
188
+ compute logs <sandbox-id> <job-id> --follow # follow a detached job
189
+ ```
190
+
191
+ Omit the sandbox ID to use the current selection, or place an explicit ID after
192
+ `exec`. A single command argument is interpreted by the remote shell; two or
193
+ more arguments are individually quoted, preserving spaces, quotes and shell
194
+ metacharacters literally. Use `bash -lc '...'` when you want an explicit shell.
195
+ The same command interpretation applies to `spawn`, which remains available.
196
+
197
+ `--timeout` accepts seconds; `--timeout-ms` remains compatible. Use one spelling
198
+ per invocation. Without either flag, the existing platform command timeout
199
+ applies. A zero timeout removes the command time limit; the sandbox's own
200
+ lifetime still applies. Limits longer than the buffered endpoint's 290-second
201
+ maximum automatically use the process path and follow output, as does zero.
202
+
203
+ `--stream` follows a tracked process and prints new stdout/stderr incrementally.
204
+ The remote exit code becomes the CLI exit code. A streamed command that exceeds
205
+ its time limit is killed and exits 124; Ctrl-C signals the process and exits 130.
206
+ With `--json`, streamed output is JSON Lines with `stdout`, `stderr` and `exit`
207
+ events. Buffered execution keeps its existing single JSON result.
208
+
209
+ `--detach` returns immediately with a job ID (or process metadata with `--json`).
210
+ It cannot be combined with `--stream` or a command timeout: the CLI must remain
211
+ connected to enforce those limits. Existing `logs`, `ps`, and
212
+ `compute instances kill <sandbox-id> <job-id>` manage the background job. If
213
+ following output fails, the CLI reports the job ID for recovery without
214
+ starting the command again.
215
+
61
216
  ## compute actions runs
62
217
 
63
218
  `compute actions runs` lists the newest 100 runs across every repo, or one
@@ -284,7 +439,7 @@ With a user login, run `compute login` again once to pick up the `providers`
284
439
  scopes these commands need. `compute actions providers configure|verify|remove`
285
440
  still work but are deprecated in favour of `compute byok`;
286
441
  `compute actions providers` itself stays the Actions placement inventory
287
- (order, act capability).
442
+ (order, workflow readiness).
288
443
 
289
444
  ## compute org members and invitations
290
445
 
@@ -351,117 +506,8 @@ logged in for that org, run `compute login` again.
351
506
  platform has no email configured (`emailSent: false`), share the link
352
507
  yourself.
353
508
 
354
- ## compute bench
355
-
356
- `compute bench …` runs the benchmarks CLI (`bench`) in-process: the same
357
- commands, flags and output as `bench …`; `compute bench --version` prints the
358
- version of the bench CLI it runs. The last release bundles `@benchsdk/runner`
359
- 0.8.3 with `@benchsdk/cli` 0.9.3, which adds `bench fork`, `bench runs run-again`
360
- and the result filters `--participant`, `--since`, `--until`, `--day`, `--tz`
361
- and `--source-org`.
362
-
363
- This branch also links the benchmarks branch build (see "Developing against a
364
- bench branch build" below), so `compute bench` has the newer bench commands:
365
-
366
- ```bash
367
- compute bench benchmarks archive|restore|describe|mute|unmute|pause|resume <slug>
368
- compute bench benchmarks list --status active|archived|all
369
- compute bench runs archive|unarchive <runId...> -y
370
- compute bench runs feed | runs days | runs day <YYYY-MM-DD> [--all]
371
- compute bench reliability <slug> | reliability cards
372
- compute bench activity [--days N]
373
- compute bench run-again <slug> [--wait] | run-again status <slug> # daily Run again; needs a user login
374
- ```
375
-
376
- compute's settings are forwarded to bench:
377
-
378
- | compute | bench | |
379
- |---|---|---|
380
- | `COMPUTE_PLATFORM_URL` | `BENCHMARKS_PLATFORM_URL` | only when `BENCHMARKS_PLATFORM_URL` is unset |
381
- | `COMPUTE_API_KEY` | `BENCHMARKS_PLATFORM_API_KEY` | only when `BENCHMARKS_PLATFORM_API_KEY` is unset, and only to a computesdk.com or localhost host over HTTPS (bench's `--base-url`, else its URL env, else `COMPUTE_PLATFORM_URL`); anything else is refused |
382
- | `compute --org <slug> bench …`, else `COMPUTE_ORG` | `--org <slug>` | only when the bench command has no `--org` of its own; not added to `run` / `check` |
383
-
384
- ```bash
385
- COMPUTE_API_KEY=bp_… compute bench runs list my-benchmark --json
386
- COMPUTE_ORG=acme compute bench auth status --json # same as: compute bench --org acme auth status
387
- ```
388
-
389
- `compute whoami` and `compute org current` also read `COMPUTE_API_KEY`, under the same host rule. To use a key with a self-hosted platform, set `BENCHMARKS_PLATFORM_API_KEY` for it yourself. An
390
- org API key has no user, so they print the key's organization and
391
- `API key (no user identity)` (with `--json`: `"user": null`,
392
- `"credential": "api_key"`).
393
-
394
- ## Command manifest
509
+ ## Sync retention
395
510
 
396
- `cli-manifest.json` (shipped in the package) lists every `compute` command:
397
- its canonical path, alias spellings, arguments and flags, plus the global
398
- flags and the `@benchsdk/runner` / `@benchsdk/cli` versions behind
399
- `compute bench …`. The bench commands themselves are described by the bench
400
- manifest in `@benchsdk/runner`. The benchmarks platform vendors both files
401
- to check that the commands its API surface map names exist.
402
-
403
- The hidden `compute __manifest` command prints the manifest (`--released`
404
- marks it as describing a published version; `--check <file>` exits 1 when
405
- `<file>` is out of date, ignoring a vendored `source.ref`). After adding,
406
- renaming or removing commands or flags, regenerate the committed file:
407
-
408
- ```bash
409
- pnpm --filter @computesdk/cli run manifest # builds, then writes cli-manifest.json
410
- ```
411
-
412
- `src/__tests__/manifest.test.ts` fails when the committed file differs from
413
- the built CLI's output.
414
-
415
- ### Developing against a bench branch build
416
-
417
- `@benchsdk/cli` and `@benchsdk/runner` can be pointed at a local checkout of
418
- [computesdk/benchmarks](https://github.com/computesdk/benchmarks) with a pnpm
419
- `link:` override in the root `package.json`, so `compute bench` runs bench
420
- commands that are not published yet:
421
-
422
- ```json
423
- "pnpm": {
424
- "overrides": {
425
- "@benchsdk/cli": "link:../benchmarks-surface-parity/packages/benchsdk-cli",
426
- "@benchsdk/runner": "link:../benchmarks-surface-parity/packages/benchsdk-runner"
427
- }
428
- }
429
- ```
511
+ Sync needs the managed sync snapshot API on the target platform. Copies retain their filtered source capture before destination writes; failure to retain stops the pass. JSON output includes `snapshot: {id, expiresAt}` (or `syncSnapshot` on project creation). Use the returned expiry. Dry runs, unchanged and delete-only passes create no capture; failed destination writes leave an existing capture available.
430
512
 
431
- The paths are relative to the repository root, so the benchmarks checkout must
432
- sit next to it (`../benchmarks-surface-parity`, branch `droid/surface-parity`)
433
- and be installed and built first (`pnpm install && pnpm build` there; the
434
- linked packages use that checkout's own `node_modules` and `dist/`). Then run
435
- `pnpm install` here; the override is recorded in `pnpm-lock.yaml`, and
436
- `pnpm install --frozen-lockfile` accepts it. Without the sibling checkout pnpm
437
- still installs, with a "non-existent directory" warning and a dangling
438
- symlink, but typecheck and the CLI tests fail because `@benchsdk/cli` cannot
439
- be resolved. The override also covers `@computesdk/platform`'s optional
440
- `@benchsdk/cli` peer, so the workspace has one bench CLI.
441
-
442
- While the bench packages resolve to a checkout rather than to an npm install,
443
- `cli-manifest.json` marks them `"linked": true, "released": false` under
444
- `passthrough.bench.runner` and `passthrough.bench.cli`: the checkout's version
445
- number (`0.9.4` / `0.8.4`, the last bench release, until the branch is
446
- released as `@benchsdk/cli` 0.9.5) does not tell which commands it has, so consumers of the manifest should treat every bench
447
- command as present but unreleased.
448
-
449
- Before a release, publish the bench packages, remove the `pnpm.overrides`
450
- block, set `@benchsdk/cli` / `@benchsdk/runner` in `packages/cli/package.json`
451
- to the published caret ranges, run `pnpm install`, and regenerate the
452
- manifest (the `linked` / `released` fields disappear).
453
-
454
- ## Migrating from @computesdk/cli 1.x
455
-
456
- v2 removes the legacy console authentication and its commands:
457
-
458
- - **Removed commands**: `compute create`, `compute sandbox`, `compute connect`,
459
- `compute workspace`, `compute run`, and the interactive REPL. Sandbox
460
- management moved to `compute sandboxes`, which drives the platform's
461
- `/api/v1/sandboxes` API.
462
- - **Auth**: `compute login` no longer opens a browser flow against
463
- console.computesdk.com or writes `~/.computesdk/credentials.json` — that
464
- credential store is gone. `compute login` now runs the platform's OAuth
465
- device flow and writes `~/.benchsdk/credentials.json` (the same store `bench
466
- auth login` uses). Run `compute login` once after upgrading.
467
- - `compute providers` is unchanged.
513
+ Maintainers: see [CLI contributor notes](./CONTRIBUTING.md) for bundled engine updates and manifest generation.
@@ -0,0 +1,6 @@
1
+ {
2
+ "repository": "https://github.com/computesdk/benchmarks-platform",
3
+ "revision": "02f7adc9e77ed47a3e7aba1ed9dd0259dae4a1af",
4
+ "path": "lib/sandboxes/snapshot-oci-module.cjs",
5
+ "sha256": "5e7485b27f22b9458c7791da679a9525637c236147d96606dbde72de55a99f1b"
6
+ }
@@ -0,0 +1,14 @@
1
+ // Keep large manifests and ignore lists out of OS/API argv limits.
2
+ const fs = require('node:fs');
3
+ const path = require('node:path');
4
+ const [engine, operation, payload] = process.argv.slice(2);
5
+ // The upstream engine uses PID-based names in os.tmpdir(). Keep every operation
6
+ // inside a private directory, including when invoked in a remote sandbox.
7
+ process.umask(0o077);
8
+ const scratch = fs.mkdtempSync(path.join(path.dirname(payload), 'engine-'));
9
+ process.env.TMPDIR = scratch;
10
+ process.env.TMP = scratch;
11
+ process.env.TEMP = scratch;
12
+ process.on('exit', () => fs.rmSync(scratch, { recursive: true, force: true }));
13
+ process.argv = [process.execPath, engine, operation, fs.readFileSync(payload, 'utf8')];
14
+ require('node:module').runMain(engine);