@computesdk/cli 2.6.12 → 2.6.14

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
@@ -9,17 +9,132 @@ sandboxes, and the benchmarks toolchain.
9
9
  npm i -g @computesdk/cli # or: pnpm dlx @computesdk/cli <cmd>
10
10
  ```
11
11
 
12
+ ## First sandbox
13
+
14
+ ```bash
15
+ compute new # sign in if needed, create and select a sandbox
16
+ compute exec echo hello # run on the selected sandbox
17
+ compute list # see your sandboxes
18
+ compute destroy # destroy the selected sandbox and stop billing
19
+ compute run echo hello # or create, run, and clean up in one command
20
+ compute -v # print the CLI version (--version also works)
21
+ ```
22
+
23
+ Common sandbox commands are available directly under `compute`: `list`, `get`,
24
+ `use`, `exec`, `run`, `serve`, `spawn`, `ps`, `logs`, `kill`, `wait`, `cp`, `url`, and `destroy`.
25
+ Existing `compute instances`, `compute sandboxes`, and `compute sbx` paths keep
26
+ working. Advanced settings, billing and snapshots remain under `compute instances`.
27
+
28
+ Creation selects a sandbox for the current repository/directory and organization.
29
+ An explicit ID wins over `COMPUTE_INSTANCE`, which wins over the stored selection.
30
+ Use `compute use <id>` to change the selection, or `compute new --no-use` to leave
31
+ it alone. A new sandbox bills until its timeout or destruction; `compute run`
32
+ cleans up after its command finishes (unless you use `--keep` or `--detach`).
33
+
34
+ ## Bring your project
35
+
36
+ Keep the provider first, then add a local directory:
37
+
38
+ ```bash
39
+ compute new e2b . # create on e2b and sync this directory into /app
40
+ compute new daytona ./my-app
41
+ compute new . # let your configured router choose
42
+ compute exec --cwd /app npm test
43
+ ```
44
+
45
+ An optional project path must be last and use explicit path syntax (`.`,
46
+ `./my-app`, `../my-app`, or an absolute path). Bare words keep meaning provider
47
+ names. The project contents go directly into `/app`, without a wrapper folder.
48
+ The sandbox becomes selected after sync succeeds (`--no-use` opts out). A failed
49
+ initial sync attempts teardown and leaves the previous selection intact; any
50
+ unconfirmed cleanup reports the sandbox ID for recovery.
51
+
52
+ ## Sync directories
53
+
54
+ ```bash
55
+ compute sync . :/app # local → selected sandbox
56
+ compute sync :/app ./results # selected sandbox → local
57
+ compute sync <sandbox-a>:/app <sandbox-b>:/app # sandbox → sandbox
58
+ compute sync . :/app --dry-run # inspect changes
59
+ compute sync . :/app --delete # remove destination-only entries
60
+ compute sync . :/app --watch # repeat until Ctrl-C
61
+ ```
62
+
63
+ Each invocation syncs directory contents in one direction. New and changed
64
+ files are compared by content and permissions; unchanged files are left alone.
65
+ Local uploads respect nested `.gitignore` files, including repository ancestor
66
+ rules. `.git` data is always excluded. Destination-only files stay unless
67
+ `--delete` is explicit; ignored source paths stay protected from deletion.
68
+ Binary files, executable permissions, and relative symlinks within the project
69
+ are supported. Source hardlinks are copied as separate files.
70
+ File/directory type conflicts and overwriting hard-linked destination files
71
+ require manual resolution.
72
+
73
+ `--dry-run` changes no destination files. `--watch` polls every two seconds and
74
+ finishes its current pass before stopping on Ctrl-C; it cannot combine with
75
+ `--dry-run`. `--json` returns one result with `dryRun`, `copied`, and `deleted`;
76
+ watch mode emits a JSON line for each nonempty pass.
77
+
78
+ Sync reuses the platform OCI checkpoint engine for scanning, diffing, capture,
79
+ and integrity-checked restore. Sandbox endpoints require Node.js and the platform
80
+ transfer API. Only the OCI layers needed for planned writes travel through the
81
+ CLI; a changed file can require its whole top-level directory layer. Sandbox-to-
82
+ sandbox transfers relay through the CLI. Filesystem roots, overlapping directories
83
+ on the same sandbox, symlink traversal, and links outside the project are refused.
84
+ Avoid concurrent edits at the destination while a sync runs.
85
+
12
86
  ## Login
13
87
 
14
88
  ```bash
15
- compute login # OAuth device flow → ~/.benchsdk/credentials.json
89
+ compute login # browser sign-in → ~/.benchsdk/credentials.json
90
+ compute login --no-browser # print the URL and code for manual sign-in
16
91
  compute logout # clear stored credentials
17
92
  compute --login / --logout # same, as flags
18
93
  ```
19
94
 
20
95
  Login uses the same OAuth device flow as `bench auth login` — every first-party
21
96
  CLI shares one credential store (`~/.benchsdk/credentials.json`) and refresh
22
- tokens renew automatically.
97
+ tokens renew automatically. Login opens the verification URL and prints the URL
98
+ and code as a fallback. Press Ctrl-C to cancel; denied or expired codes produce
99
+ an actionable error.
100
+
101
+ Interactive `compute new`, `compute instances create`, and `compute run` start
102
+ login only when there are no stored credentials or explicit API keys. After
103
+ approval they continue the original command once, with its original options.
104
+ `--no-browser` prints the link without opening it. In CI, without a terminal,
105
+ or with `--json`/`--quiet`, missing credentials fail promptly; run `compute login`
106
+ separately or set `COMPUTE_API_KEY`. Existing expired sessions and invalid keys
107
+ are reported rather than silently replaced with another identity.
108
+
109
+ Pending sign-ins are saved privately on this machine and reused until approval,
110
+ denial, or expiry. Restart `compute login` after an interruption to resume;
111
+ `compute login --new` requests a fresh code. Logout clears pending sign-ins too.
112
+ For scripts and agents, `compute login --json` returns only the verification URL,
113
+ public code, and expiry immediately; `compute login --wait --json` resumes polling
114
+ and saves the session without opening a browser. Normal login still opens the
115
+ browser and waits for approval.
116
+
117
+ ## Status and jobs
118
+
119
+ ```bash
120
+ compute status # auth, effective org, credits, selected sandbox, routing
121
+ compute status --json # structured diagnostics, including partial failures
122
+ compute status --check # exit 1 unless authenticated and routing is ready
123
+ compute exec --detach "npm run dev"
124
+ compute logs <job-id>
125
+ compute wait <job-id> # wait and return the process exit code
126
+ compute kill <job-id> # SIGTERM; override with --signal SIGKILL
127
+ ```
128
+
129
+ Status checks the default sandbox route without creating a sandbox; no selected
130
+ sandbox is required. It accepts the usual `--org`, `--api-key`, and `--base-url`.
131
+ Job commands also accept an explicit sandbox ID before the job ID.
132
+
133
+ `compute run` ends with an stderr summary of exit code, elapsed time, provider,
134
+ and confirmed cleanup or retention. Cost appears only when teardown returns a
135
+ settled amount. `run --json` emits stdout/stderr JSON Lines followed by a summary
136
+ with `sandboxId`, `jobId`, `exitCode`, `elapsedSeconds`, `provider`, `deleted`,
137
+ `kept`, and optional `costUsd`. `run --detach --json` returns a detached job record.
23
138
 
24
139
  ## Commands
25
140
 
@@ -47,17 +162,55 @@ override, pass `--org <slug>` (on the root command or any `sandboxes` /
47
162
  on the request. Precedence: `--org` > `COMPUTE_ORG` > the stored login's org.
48
163
  The platform ignores the header for org API keys.
49
164
 
50
- For `compute sandboxes exec` and `compute sandboxes spawn`, everything after
165
+ For `compute exec` and `compute spawn`, everything after
51
166
  the command's first word goes to the sandbox untouched — flags like `uname
52
167
  -a` or `node -e` are not CLI options. Pass CLI options (`--json`,
53
- `--timeout-ms`, `--cwd`, `-e/--env`, `--stdin`, `--org`) before the command;
168
+ `--timeout`/`--timeout-ms`, `--stream`, `--detach`, `--cwd`, `-e/--env`, `--stdin`, `--org`) before the command;
54
169
  a bare `--` before the command is optional but supported.
55
170
 
56
171
  ```bash
57
- compute sandboxes exec sb1 uname -a
58
- compute sandboxes spawn sb1 --cwd /app -e NODE_ENV=production -- npm run dev
172
+ compute exec <id> uname -a
173
+ compute spawn <id> --cwd /app -e NODE_ENV=production npm run dev
59
174
  ```
60
175
 
176
+ ### Executing commands
177
+
178
+ ```bash
179
+ compute exec "npm test" # one argument: shell command
180
+ compute exec node -v # multiple arguments: preserve argv
181
+ compute exec "echo hello && echo world" # shell operators run remotely
182
+ compute exec --cwd /app --timeout 120 npm test
183
+ compute exec --stream "npm run build" # follow output while it runs
184
+ compute exec --timeout 0 "long-running-command" # no command time limit
185
+ compute exec --detach "npm run dev" # return a background job ID
186
+ compute logs <sandbox-id> <job-id> --follow # follow a detached job
187
+ ```
188
+
189
+ Omit the sandbox ID to use the current selection, or place an explicit ID after
190
+ `exec`. A single command argument is interpreted by the remote shell; two or
191
+ more arguments are individually quoted, preserving spaces, quotes and shell
192
+ metacharacters literally. Use `bash -lc '...'` when you want an explicit shell.
193
+ The same command interpretation applies to `spawn`, which remains available.
194
+
195
+ `--timeout` accepts seconds; `--timeout-ms` remains compatible. Use one spelling
196
+ per invocation. Without either flag, the existing platform command timeout
197
+ applies. A zero timeout removes the command time limit; the sandbox's own
198
+ lifetime still applies. Limits longer than the buffered endpoint's 290-second
199
+ maximum automatically use the process path and follow output, as does zero.
200
+
201
+ `--stream` follows a tracked process and prints new stdout/stderr incrementally.
202
+ The remote exit code becomes the CLI exit code. A streamed command that exceeds
203
+ its time limit is killed and exits 124; Ctrl-C signals the process and exits 130.
204
+ With `--json`, streamed output is JSON Lines with `stdout`, `stderr` and `exit`
205
+ events. Buffered execution keeps its existing single JSON result.
206
+
207
+ `--detach` returns immediately with a job ID (or process metadata with `--json`).
208
+ It cannot be combined with `--stream` or a command timeout: the CLI must remain
209
+ connected to enforce those limits. Existing `logs`, `ps`, and
210
+ `compute instances kill <sandbox-id> <job-id>` manage the background job. If
211
+ following output fails, the CLI reports the job ID for recovery without
212
+ starting the command again.
213
+
61
214
  ## compute actions runs
62
215
 
63
216
  `compute actions runs` lists the newest 100 runs across every repo, or one
@@ -465,3 +618,27 @@ v2 removes the legacy console authentication and its commands:
465
618
  device flow and writes `~/.benchsdk/credentials.json` (the same store `bench
466
619
  auth login` uses). Run `compute login` once after upgrading.
467
620
  - `compute providers` is unchanged.
621
+
622
+ ### Maintaining the sync checkpoint engine
623
+
624
+ The CLI bundles an exact copy of the platform checkpoint module;
625
+ `checkpoint-provenance.json` records its upstream commit and SHA-256 digest.
626
+ Refresh it with `node scripts/sync-checkpoint-engine.mjs /path/to/benchmarks-platform [revision]`
627
+ from the repository root, then run the CLI tests. Do not edit the bundled engine
628
+ directly. Every invocation uses a private temporary directory and restrictive
629
+ file permissions for upstream scratch archives. Sync-specific filtering and destination guards live in the adapter.
630
+ Literal `*` and `?` characters in addressed paths are unsupported because checkpoint
631
+ selectors use glob syntax. Watch passes skip capture when nothing changed. Each pass that copies entries
632
+ retains its full filtered source capture in platform-owned Tigris storage for
633
+ 30 days. Snapshot namespaces are isolated, so expiring a sync capture cannot
634
+ delete permanent snapshot layers. Cross-snapshot layer deduplication is not yet
635
+ implemented. Only local and sandbox scratch files are removed after the pass.
636
+
637
+ Retained sync snapshots must finish uploading and pass platform integrity checks
638
+ before destination changes begin. `sync --json` includes `snapshot: {id, expiresAt}`
639
+ when a capture is created; project creation includes `syncSnapshot` in its JSON
640
+ result. Human output shows the same ID and expiry. Dry runs, unchanged passes and
641
+ delete-only passes do not create captures. A failed destination copy leaves the
642
+ retained capture available until expiry. There is no new storage charge in this
643
+ release. Deploy the managed sync snapshot API before releasing this CLI; failure
644
+ to retain a capture stops sync rather than falling back to disposable snapshots.
@@ -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);