@shardflux/cli 0.7.0 → 0.8.1

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/CHANGELOG.md CHANGED
@@ -3,6 +3,115 @@
3
3
  Every command and option the README shows is available from the version named here. Breaking changes ship in minor
4
4
  releases and are marked **Breaking**.
5
5
 
6
+ ## 0.9.0 (not yet published)
7
+
8
+ Needs `@shardflux/sdk` 0.14.0 or later.
9
+
10
+ ### Workspaces working at once
11
+
12
+ - A command whose workspace call finds every workspace the plan allows to work at once busy is sent again after
13
+ `Retry-After` (the SDK's retries; the call did not run). A refusal that lasts exits 1 with 429 `quota_exceeded`
14
+ (`details.limit` `concurrent_workspaces`) and the hint `every workspace your plan allows to work at once is busy
15
+ and the call did not run (it was already retried); retry in 2 s, or upgrade: shard billing plans`.
16
+ - The API's 403 `quota_exceeded` with `details.limit` `retained_state` (opening a new key or forking while the
17
+ plan's Retained state is used up) hints `delete workspaces you no longer need (shard ws delete <key> --yes), or
18
+ upgrade: shard billing plans`. Neither suggests `shard feedback`.
19
+ - `--json` errors carry `retry_after_seconds` when the refusal has `Retry-After` (e.g. 429 `quota_exceeded`, 429
20
+ `rate_limited`).
21
+ - `shard usage` says `retained state used up: new workspaces and forks are refused (...)` when the Retained state
22
+ allowance's `cap_state` is `storage_blocked` (`enforcement` `storage_block`).
23
+
24
+ ## 0.8.1 (not yet published)
25
+
26
+ Needs `@shardflux/sdk` 0.13.1 or later.
27
+
28
+ ### Workspaces recover by themselves
29
+
30
+ When the machine a workspace runs on fails, the workspace is suspended, and the next command on it resumes it.
31
+
32
+ - A resume that booted the workspace's own disk (`cold_boot_reason` `host_lost`) prints the cold-boot note with the
33
+ reason in words: `note: workspace <id> resumed from its saved disk; running processes were restarted (the machine it
34
+ ran on failed)`.
35
+ - A resume that restored its newest checkpoint prints `note: workspace <id> resumed from checkpoint <id> (state as of
36
+ <time>) after the machine it ran on failed; changes after that time are not in it` on stderr (also with `--json`,
37
+ `ws resume --wait`, `operations wait` and a command's wake).
38
+ - `--timing --json`: `server.host_lost` (`detected_at`, `restored_from`, `restored_checkpoint_id`, `state_as_of`).
39
+ `--timing` prints the SDK's `restored checkpoint <id> (host_lost; state as of <time>)`.
40
+ - `hostLostNotice()` is exported next to `coldBootNotice()`.
41
+
42
+ ## 0.8.0
43
+
44
+ Needs `@shardflux/sdk` 0.13.0 or later.
45
+
46
+ ### Elastic memory
47
+
48
+ - `shard ws open` and `shard ws fork`: `--allocation-mode fixed|elastic` and `--memory-held <mib>` (elastic only; a
49
+ usage error otherwise), sent with the caps. Caps flags replace the stored caps; no caps flag keeps the stored layout.
50
+ - `shard ws get` (and a ready `ws open`) prints a `memory` line: `fixed 4096 MiB`, or `elastic: promised 8192 MiB,
51
+ held 1024 MiB, plugged +2048 MiB` (`- (not running)` without a live allocation). `caps` shows `allocation_mode` and
52
+ `memory_mib_held`.
53
+ - `shard ws exec -v` prints `memory grow partial 1024 -> 3072 of 4096 MiB in 175 ms` on stderr when the command's
54
+ start waited for a grow; `--json` adds `memory_grow`. Without a grow nothing changes.
55
+
56
+ ### Burst execution
57
+
58
+ - `shard ws exec --burst [--burst-vcpus N] [--burst-memory MIB]` runs the command on a larger, short-lived burst VM
59
+ and applies its file changes back.
60
+ `-v` prints a `burst` line (size, method, applied changes, leftover processes killed, overhead) on stderr; `--json`
61
+ adds `burst`. The sizes without `--burst`, out of range, or `--burst` with `--stdin`, are usage errors (exit 2);
62
+ `--burst` on a file-first workspace too.
63
+ - Ctrl-C does not cancel a burst (it cannot be canceled). A `burst_apply_failed` error names the exec session on
64
+ stderr.
65
+
66
+ ### Background commands
67
+
68
+ - `shard ws exec-start --timeout <duration>`: kill the command after this long (parsed like `shard ws exec --timeout`;
69
+ none unless set). Without `--json` it names the commands that read and stop the session on stderr.
70
+ - `shard ws exec-read <id|key> <session-id> [--follow]`: the session's stdout and stderr from the start. An ended
71
+ session exits with the command's exit code (124 timed out, 128+N killed by signal N), one that still runs exits 5
72
+ with the command that follows it. `--follow` streams until the command exits, resuming from byte offsets after a
73
+ dropped connection; Ctrl-C stops following and the command keeps running. `--json` prints one object (`session_id`,
74
+ `state`, `exit_code`, `term_signal`, `timed_out`, `canceled`, `stdout`, `stderr`, `truncated`, `reconnects`).
75
+ A session that could not start exits 6 with the workspace's reason, as `shard ws exec` does.
76
+ - `shard ws exec-cancel <id|key> <session-id> [--grace <duration>]`: SIGTERM, then SIGKILL after the grace (default
77
+ 5s, at most 60s). Prints `exec session <id>: canceled (signal 15)` (`--json`: the session).
78
+
79
+ ### Suspend by id
80
+
81
+ - `shard ws suspend <id>` sends the suspend straight to the workspace, without first fetching it: one request fewer.
82
+ The line it prints names the id you gave (`Suspending <id>: operation ...`); with a key it is unchanged
83
+ (`Suspending <key> (<id>): ...`). A UUID that is no workspace id is still tried as a key.
84
+
85
+ ### Held fork
86
+
87
+ - `shard ws fork --wait` gets the running copy and its tool token in the fork request itself when the API holds the
88
+ fork (SDK 0.13.0), without the follow-up operation poll and copy refresh. Against an API that does not, it polls as
89
+ before. `shard ws fork` without `--wait` is unchanged.
90
+
91
+ ### Exec start and output in one request
92
+
93
+ - `shard ws exec` starts the command and streams its output in one request on cells that support it (SDK 0.13.0);
94
+ output still resumes from byte offsets after a dropped connection, and the command never runs twice.
95
+
96
+ ### Immutable paths
97
+
98
+ A template may declare directories as `immutable`: every workspace of it mounts them read-only from the template's
99
+ newest published version.
100
+
101
+ - `shard templates get`: an `IMMUTABLE PATHS` column with each version's paths and image size
102
+ (`/opt/acme, /srv/tools (128.0 MiB)`), shown when a version declares any.
103
+ - `shard ws get` (and a ready `ws open`): `immutable paths v2 (mounted read-only)`, the template version whose
104
+ immutable paths the workspace has mounted.
105
+ - `shard templates build` sends template.yaml's `immutable` list; `shard templates builds get` (and a build's output)
106
+ prints `immutable paths`, and for a build that failed on them a `fix` line (`immutable_path_missing`: make the path a
107
+ directory in the build; `immutable_image_too_large`). `shard templates export` writes the list back.
108
+ `shard templates init` describes `immutable` in a comment.
109
+ - Hints for the refusals: `immutable_path_removed` names the paths to add back, `immutable_paths_unsupported_base` the
110
+ base to build on, `invalid_path` the `immutable[<i>]` entry to fix (exit 2), and a write under an immutable path
111
+ (`read_only_path`, 409 from the workspace, exit 1) says where to change it.
112
+ - **Breaking:** `--json` output no longer carries `update_policy`: the API removed the update policy (it was always
113
+ `pinned`).
114
+
6
115
  ## 0.6.2
7
116
 
8
117
  Needs `@shardflux/sdk` 0.11.1 or later.
package/README.md CHANGED
@@ -374,11 +374,12 @@ shows the status; `shard version --check` asks now (`--json`: `{"cli", "sdk", "u
374
374
  | `version [--check]` | Print the CLI and SDK versions and the update status (`--check` asks the API now). |
375
375
  | `usage [--org <id>] [--estimate \| --series \| --workspace <id\|key>] [--from T] [--to T] [--granularity hour\|day] [--meter M]` | Usage summary for the current period: plan, meters and allowances. `--estimate`: the bill so far and projected allowance use; `--series`: usage over time; `--workspace`: one workspace's usage over time (0.5.0+). The summary includes the [overage](#usage-and-overage) block (0.5.1+). |
376
376
  | `feedback [--category C] [--workspace W] [--request-id ID] [--error-code CODE] [--command TEXT] [--from-file F\|-] <message...>` | Send feedback straight to the Shardflux team (0.5.0+). See [Feedback](#feedback-agents-use-this-while-you-work). |
377
- | `workspaces open <key> --template <slug> [--secret NAME]... [--input NAME=value]... [--input-file F] [--lifetime persistent\|session] [--mode processful\|file-first] [--cpu-millis N --memory-mib N --disk-gib N] [--no-wait] [--timeout 5m] [--timing]` | Open by key. Creates the workspace on first use and reconnects or resumes it afterwards, never resetting it. Waits until it is ready (the template's start commands and services included) unless you pass `--no-wait`. `--secret` binds secret names (replacing the binding of an existing workspace). `--input` (0.4.0+) passes the template's text inputs (replacing those of an existing workspace); `--input-file` reads `NAME=value` lines or a JSON object. `--lifetime session`: the workspace is discarded when the session ends (`workspaces close` or the idle timeout), and the key then opens a new workspace. `--mode file-first` (0.5.0+) opens a [file-first workspace](#file-first-workspaces); the default is processful for a new key and the stored mode for an existing one. |
377
+ | `workspaces open <key> --template <slug> [--secret NAME]... [--input NAME=value]... [--input-file F] [--lifetime persistent\|session] [--mode processful\|file-first] [--cpu-millis N --memory-mib N --disk-gib N] [--allocation-mode fixed\|elastic] [--memory-held N] [--no-wait] [--timeout 5m] [--timing]` | Open by key. Creates the workspace on first use and reconnects or resumes it afterwards, never resetting it. Waits until it is ready (the template's start commands and services included) unless you pass `--no-wait`. `--secret` binds secret names (replacing the binding of an existing workspace). `--input` (0.4.0+) passes the template's text inputs (replacing those of an existing workspace); `--input-file` reads `NAME=value` lines or a JSON object. `--lifetime session`: the workspace is discarded when the session ends (`workspaces close` or the idle timeout), and the key then opens a new workspace. `--mode file-first` (0.5.0+) opens a [file-first workspace](#file-first-workspaces); the default is processful for a new key and the stored mode for an existing one. `--allocation-mode elastic` (0.8.0+): [elastic memory](#elastic-memory-080). |
378
378
  | `workspaces list [--state S] [--prefix P] [--lifetime persistent\|session\|any] [--purpose standard\|template_draft\|template_test\|any] [--include-deleted] [--all] [--limit N] [--cursor C]` | One page, or every page with `--all`. The next cursor is printed on stderr. By default only persistent standard workspaces are listed. A file-first workspace's state reads `running (file-first)` (0.5.0+). |
379
- | `workspaces get <id\|key>` | One workspace (deleted ones included), with the startup of its template's start commands and services (0.4.0+): a failed step shows its exit code, reason and output tail. Its mode, and a file-first workspace's tree revision (0.5.0+). |
379
+ | `workspaces get <id\|key>` | One workspace (deleted ones included), with the startup of its template's start commands and services (0.4.0+): a failed step shows its exit code, reason and output tail. Its mode, and a file-first workspace's tree revision (0.5.0+). Its memory (0.8.0+): `fixed 4096 MiB`, or `elastic: promised …, held …, plugged +… MiB`. The template version whose [immutable paths](#immutable-paths-080) it has mounted (0.8.0+): `immutable paths v3 (mounted read-only)`. |
380
380
  | `workspaces inputs <id\|key>` | The workspace's text inputs (0.4.0+). |
381
- | `workspaces exec <id\|key> [--cwd D] [--env K=V]... [--timeout T] [--stdin F\|-] [-v] [--execution-id ID] [--output-limit N] -- <cmd> [args...]` | Runs argv with no shell. Output is streamed and resumes from byte offsets after dropped connections. `shard` exits with the command's exit code. Ctrl-C cancels the command. `-v` (0.5.0+) then prints the session id and exit status on stderr. `--cwd` is an absolute path (default `/home/user`); a relative one is refused (`invalid_cwd`, exit 2). A command that could not start (a `--cwd` that is not a directory, a program not on `PATH`) exits 6 with the workspace's reason and a hint (0.5.1+; before, it exited 1 with no output). On a file-first workspace (0.5.0+) the command runs as an execution instead: see [File-first workspaces](#file-first-workspaces). |
381
+ | `workspaces exec <id\|key> [--cwd D] [--env K=V]... [--timeout T] [--stdin F\|-] [-v] [--execution-id ID] [--output-limit N] [--burst [--burst-vcpus N] [--burst-memory MIB]] -- <cmd> [args...]` | Runs argv with no shell. Output is streamed (in the start request itself, 0.8.0+) and resumes from byte offsets after dropped connections. `shard` exits with the command's exit code. Ctrl-C cancels the command. `-v` (0.5.0+) then prints the session id and exit status on stderr, and the memory grow the command waited for on an elastic workspace (0.8.0+; `--json`: `memory_grow`). `--cwd` is an absolute path (default `/home/user`); a relative one is refused (`invalid_cwd`, exit 2). A command that could not start (a `--cwd` that is not a directory, a program not on `PATH`) exits 6 with the workspace's reason and a hint (0.5.1+; before, it exited 1 with no output). On a file-first workspace (0.5.0+) the command runs as an execution instead: see [File-first workspaces](#file-first-workspaces). `--burst` (0.8.0+): [burst execution](#burst-execution-080). |
382
+ | `workspaces exec-start <id\|key> [--session-id ID] [--cwd D] [--timeout T] [--stdin-open] -- <cmd> [args...]`, `workspaces exec-read <id\|key> <session-id> [--follow]`, `workspaces exec-cancel <id\|key> <session-id> [--grace D]` | Background commands (0.8.0+): start a command and return at once, read its output and state (`--follow` streams it to its exit and exits with its code; while it runs `exec-read` exits 5), stop it. See [Background commands](#background-commands-080). |
382
383
  | `executions get <id\|key> <execution-id> [--wait D]` | The result of a file-first workspace's execution (0.5.0+): its output, then what ran. Exits with the command's code, 6 if the execution failed or was lost, 5 while it still runs. |
383
384
  | `files read <id\|key> <path> [--out F]` | Raw bytes to stdout, or to a local file. |
384
385
  | `files write <id\|key> <path> [--from F\|-] [--append] [--no-parents] [--if-revision N]` | Atomic write. The default source is stdin. `--if-revision` (0.5.0+): file-first workspaces only, see [Tree revisions](#tree-revisions). |
@@ -389,7 +390,7 @@ shows the status; `shard version --check` asks now (`--json`: `{"cli", "sdk", "u
389
390
  | `workspaces suspend\|resume <id\|key> [--wait] [--timeout T] [--timing]` | Lifecycle operation. Returns immediately unless you pass `--wait`. |
390
391
  | `workspaces suspend <id\|key> --durable [--timeout T]` | (0.7.0+) Suspend and wait until the copy is in durable storage. See "Durable storage". |
391
392
  | `workspaces suspend <id\|key> --when-idle D` / `--cancel-when-idle` | (0.5.1+) Suspend once the workspace has been idle for `D` (0 to 1h; `0` = as soon as it is idle, 0.6.1+), or cancel that. See "Suspend when idle". |
392
- | `workspaces fork <id\|key> <new-key> [caps] [--wait]` | Fork into a new key. |
393
+ | `workspaces fork <id\|key> <new-key> [caps] [--allocation-mode fixed\|elastic] [--memory-held N] [--wait]` | Fork into a new key. Without caps the fork keeps the source's caps and memory allocation (0.8.0+). With `--wait` the API holds the fork until the copy runs and returns it ready in the same request (0.8.0+; `--timing` shows one `request` phase marked `(held)`). |
393
394
  | `workspaces delete <id\|key> --yes [--wait]` | Delete the workspace. Tool access ends at once. After deletion finishes, the key can open a new workspace ID. |
394
395
  | `workspaces close <id\|key> [--wait]` | End a session workspace now: it is deleted, and the key then opens a new workspace. A persistent workspace is refused (`not_session`). |
395
396
  | `workspaces reset <id\|key> --yes [--wait]` | Layered workspaces: wipe every change and restart on the template. The previous state stays restorable for 7 days. |
@@ -404,7 +405,7 @@ shows the status; `shard version --check` asks now (`--json`: `{"cli", "sdk", "u
404
405
  | `secrets versions <id\|NAME>`, `secrets delete <id\|NAME> --yes`, `secrets access-log <id\|NAME>` | Versions, deletion (also removes the name from every workspace binding), and the access log. |
405
406
  | `operations list <id\|key> [--state S] [--kind K]`, `operations get <op>`, `operations wait <op> [--timeout T] [--timing]` | Operations. |
406
407
  | `templates list [--owner platform\|organization] [--include-archived] [--all]` | Templates the project can open, with their open version, layouts, file list state and draft. |
407
- | `templates get <slug> [--owner O] [--include-archived]` | One template (0.4.0+): its versions, what open resolves to, and the open version's settings (env, inputs, start commands, services, defaults). |
408
+ | `templates get <slug> [--owner O] [--include-archived]` | One template (0.4.0+): its versions, what open resolves to, and the open version's settings (env, inputs, start commands, services, defaults). Each version's [immutable paths](#immutable-paths-080) and their image size (0.8.0+). |
408
409
  | `templates init --base <slug[@version]> [--out F] [--force]` | Write a starter `template.yaml` on a base (0.4.0+). |
409
410
  | `templates build <file> [--slug S] [--display-name N] [--description T] [--publish] [--acknowledge PATH]... [--wait] [--timeout 30m] [--timing]` | Build a template from `template.yaml` (0.4.0+): local files and folders are uploaded, then the build is created. See [Build a template](#build-a-template-from-templateyaml). |
410
411
  | `templates export <slug>@<version> [--out F] [--force]` | The `template.yaml` a version was built from, ready to build again (0.4.0+). |
@@ -475,6 +476,30 @@ settings:
475
476
  - A file `shard` cannot read or pack (a symlink that leaves the folder, a device) is refused before any request (exit
476
477
  2). The API's refusals (`upload_missing`, `language_unavailable`, `invalid_settings`, ...) exit 2 with the reason.
477
478
 
479
+ ### Immutable paths (0.8.0+)
480
+
481
+ Directories listed under `immutable` follow the template: every workspace of it mounts them read-only from the
482
+ template's newest published version, picked up at its next cold boot or resume. Ship tools, models or data there and
483
+ existing workspaces get each new version; everything else in a workspace stays its own.
484
+
485
+ ```yaml
486
+ immutable: [/opt/acme]
487
+ ```
488
+
489
+ ```sh
490
+ shard templates get acme-dev
491
+ # VERSION STATE SOURCE LAYOUTS IMMUTABLE PATHS CREATED DESCRIPTION
492
+ # v2 * published recipe layered /opt/acme (96.0 MiB) 2026-10-01 03:14:52Z tools 2.4
493
+ shard ws get acme/main
494
+ # template acme-dev v1 (<version id>)
495
+ # immutable paths v2 (mounted read-only)
496
+ ```
497
+
498
+ A template.yaml without `immutable` keeps the list of the template's open version, and a new version keeps every path
499
+ of it (`immutable_path_removed` names the ones to add back). `shard templates builds get` lists a build's immutable
500
+ paths; `shard templates export` writes them back into template.yaml. A write under an immutable path
501
+ (`shard files write`) exits 1 with `read_only_path` and a hint.
502
+
478
503
  ## File-first workspaces
479
504
 
480
505
  (0.5.0+) A file-first workspace has no VM between commands. Its state is a versioned file tree under `/home/user`.
@@ -582,11 +607,11 @@ without waking it (the state at suspension); `files search` then notes it on std
582
607
  refused at once (exit 1, `workspace_not_running`).
583
608
 
584
609
  **Detecting a cold resume (0.6.0+).** A resume restores memory and running processes. After a platform runtime
585
- update, a resume can boot from the saved disk instead of restoring memory (a cold boot), also when a command wakes the
586
- workspace; check `memory_restored`. The command still runs with the files as of the suspend, and processes start
587
- fresh, as after a reboot: start dev servers and background jobs again. `shard` then prints one line on stderr after
588
- the output (also with `--json`, except on a failure, whose stderr is only the error document), whether or not you
589
- pass `--timing`:
610
+ update, or after the machine the workspace ran on failed (0.8.1+), a resume can boot from the saved disk instead of
611
+ restoring memory (a cold boot), also when a command wakes the workspace; check `memory_restored`. The command still runs
612
+ with the files kept, and processes start fresh, as after a reboot: start dev servers and background jobs again. `shard`
613
+ then prints one line on stderr after the output (also with `--json`, except on a failure, whose stderr is only the
614
+ error document), whether or not you pass `--timing`:
590
615
 
591
616
  ```text
592
617
  note: workspace 01a0e5a8-3edd-74ba-b489-d62b8925e342 resumed from its saved disk; running processes were restarted (runtime_changed)
@@ -596,6 +621,12 @@ note: workspace 01a0e5a8-3edd-74ba-b489-d62b8925e342 resumed from its saved disk
596
621
  `cold_boot`, `memory_restored` false, `cold_boot_reason`), and `--timing` shows `resume from cold_boot: processes
597
622
  restarted (runtime_changed)`. The same applies to `operations wait` of such a resume.
598
623
 
624
+ **Workspaces recover by themselves (0.8.1+).** When the machine a workspace runs on fails, the workspace is suspended,
625
+ and the next command on it resumes it; there is nothing extra to run. From its own disk, the note above ends in
626
+ `(the machine it ran on failed)`; from its newest checkpoint, the note names the checkpoint and the time its state is
627
+ from (`state as of <time>`). `--json` carries `result.host_lost` (`detected_at`, `restored_from` `disk` or
628
+ `checkpoint`, `restored_checkpoint_id`, `state_as_of`), and `--timing` adds `host_lost` to `server`.
629
+
599
630
  ## Suspend when idle (0.5.1+)
600
631
 
601
632
  A running workspace is billed while it is awake. When an agent's turn ends, ask for a suspend once the workspace has
@@ -617,6 +648,53 @@ shard ws suspend acme/demo --cancel-when-idle
617
648
  workspace that is not running is refused with `conflict` (`not_running`, exit 1), and a file-first workspace (never
618
649
  suspended) with `not_supported_for_mode` (exit 1).
619
650
 
651
+ ## Elastic memory (0.8.0+)
652
+
653
+ Give a workspace a large memory promise while it holds only what it uses. It idles at `--memory-held` (default
654
+ 1024 MiB) and grows before each command starts, so builds and test runners see the memory they need from their first
655
+ instruction.
656
+
657
+ ```sh
658
+ shard ws open acme/demo --template python-node-browser --memory-mib 8192 --allocation-mode elastic
659
+ shard ws get acme/demo # memory elastic: promised 8192 MiB, held 1024 MiB, plugged +3072 MiB
660
+ shard ws exec acme/demo -v -- npm test # memory grow delivered 1024 -> 4096 MiB in 175 ms
661
+ ```
662
+
663
+ The layout takes effect at the workspace's next start. `--json` output carries `memory` on the workspace and
664
+ `memory_grow` on a command that grew it.
665
+
666
+ ## Burst execution (0.8.0+)
667
+
668
+ Run one heavy command, such as a cold build or a full test suite, on a larger VM without resizing the workspace:
669
+ `--burst` runs it on a short-lived burst VM over a copy of the workspace and applies its file changes back when it
670
+ exits. Output streams as usual and `shard` exits with the command's exit code.
671
+
672
+ ```sh
673
+ shard ws exec acme/demo --burst --burst-vcpus 16 -v -- bash -lc "cd app && go build ./..."
674
+ # burst local 16 vCPU / 8192 MiB (layer); applied 3 files, 1 dirs, 1 removed, 40960 bytes; overhead 641 ms
675
+ ```
676
+
677
+ `--burst-vcpus` and `--burst-memory` size the burst VM (default 8 vCPU and 8192 MiB within the plan's
678
+ per-workspace limits); `--json` adds `burst` to the result.
679
+
680
+ ## Background commands (0.8.0+)
681
+
682
+ A long command (a build, a test suite, a training run, a server) can run in the background of a processful workspace
683
+ while you or your agent do other work:
684
+
685
+ ```sh
686
+ shard ws exec-start acme/demo --session-id build-1 --timeout 2h -- bash -lc "make -C /home/user/app"
687
+ shard ws exec-read acme/demo build-1 # the output so far; exit 5 while it runs
688
+ shard ws exec-read acme/demo build-1 --follow # stream to the end; exits with the command's exit code
689
+ shard ws exec-cancel acme/demo build-1 --grace 10s
690
+ ```
691
+
692
+ - `--timeout` is the longest the command may run; the workspace stays awake until it ends or that time passes.
693
+ - `exec-read` prints stdout and stderr from the start. `--follow` resumes from byte offsets after a dropped
694
+ connection; Ctrl-C stops following and the command keeps running. `--json` prints one object with the state, exit
695
+ code and output.
696
+ - `exec-cancel` sends SIGTERM, then SIGKILL after `--grace` (default 5s, at most 60s).
697
+
620
698
  ## Start deadlines
621
699
 
622
700
  A queued open, resume or fork (`capacity_pending`) has a deadline 15 minutes after it was created.
@@ -706,7 +784,7 @@ With `--json`, stdout carries the timing as a `timing` field of the command's JS
706
784
  `workspace_id`, `operation_id`, `total_ms`, `phases` (`phase`, `reason`, `operation_id`, `start_ms`, `duration_ms`),
707
785
  `retries`, `server` (`queued_ms`, `run_ms`, `total_ms`, `start_path`, `resume_path`, `memory_restored` and
708
786
  `cold_boot_reason` (0.6.0+; `memory_restored` is `false` when a resume booted the saved disk, `null` when the API did
709
- not say), `boot_to_ready_ms`, ...) and `outside_server_ms`. It is `null` when the command made no lifecycle call. On a failure the error document on stderr
787
+ not say), `host_lost` (0.8.1+), `boot_to_ready_ms`, ...) and `outside_server_ms`. It is `null` when the command made no lifecycle call. On a failure the error document on stderr
710
788
  carries it: `{"error": {...}, "timing": {...}}`.
711
789
 
712
790
  For live progress events, use the SDK's `onProgress`.
@@ -788,10 +866,10 @@ printf %s "$NEW_KEY" | shard secrets rotate OPENAI_API_KEY
788
866
  | 2 | usage error: bad arguments, or input the API rejected as `validation_failed` |
789
867
  | 3 | not found: workspace, operation or route |
790
868
  | 4 | authentication or authorization: missing, malformed, revoked or insufficient key or session; `step_up_required` (run `shard auth step-up`), `mfa_required` (a sign-in waiting for its code), `email_unverified`, `invalid_credentials` |
791
- | 5 | timeout: waiting gave up (`--timeout`, or `--wake-timeout` while waking a workspace); the operation continues server side (`shard operations wait <id>`), up to a queued start's 15-minute deadline. `executions get` (0.5.0+): the execution is still queued or running. `billing upgrade --wait` (0.5.0+): nobody paid in time (the checkout stays open) |
869
+ | 5 | timeout: waiting gave up (`--timeout`, or `--wake-timeout` while waking a workspace); the operation continues server side (`shard operations wait <id>`), up to a queued start's 15-minute deadline. `executions get` (0.5.0+): the execution is still queued or running. `ws exec-read` (0.8.0+): the background command still runs. `billing upgrade --wait` (0.5.0+): nobody paid in time (the checkout stays open) |
792
870
  | 6 | the awaited operation ended `failed` or `canceled` (also a resume or open that failed while waking a workspace). `retryable=true` in the error means a retry can succeed (`capacity_unavailable`). Also a file-first execution that ended `failed` or `lost` (0.5.0+): nothing was published. `exec` (0.5.1+): the command could not start (`exec_failed_to_start`). `billing upgrade --wait` (0.5.0+): the checkout expired or was canceled (`checkout_ended`) |
793
871
  | 130 | interrupted (Ctrl-C). Waits stop at once, and exec sends a cancel to the session. A file-first execution runs to completion, and the error names the `shard executions get` command for its result. |
794
- | exec, executions get | the command's own code: 124 if it timed out, 128+N if killed by signal N. Failures before the command ran use the codes above; use `--json` to tell them apart. |
872
+ | exec, executions get, ws exec-read | the command's own code: 124 if it timed out, 128+N if killed by signal N. Failures before the command ran use the codes above; use `--json` to tell them apart. |
795
873
 
796
874
  ## Durable storage (0.7.0+)
797
875
 
package/dist/args.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const CLI_VERSION = "0.7.0";
1
+ export declare const CLI_VERSION = "0.8.1";
2
2
  export interface OptionSpec {
3
3
  type: 'string' | 'boolean';
4
4
  short?: string;
package/dist/args.js CHANGED
@@ -12,7 +12,7 @@
12
12
  import { parseArgs } from 'node:util';
13
13
  import { ACCOUNT_COMMANDS } from "./account-args.js";
14
14
  import { UsageError } from "./errors.js";
15
- export const CLI_VERSION = '0.7.0';
15
+ export const CLI_VERSION = '0.8.1';
16
16
  export const GLOBAL_OPTIONS = {
17
17
  'api-url': { type: 'string', value: '<url>', description: 'API base URL (default $SHARDFLUX_API_URL, else https://api.shardflux.dev).' },
18
18
  json: { type: 'boolean', description: 'Print machine-readable JSON on stdout (errors as JSON on stderr).' },
@@ -27,6 +27,15 @@ const CAPS = {
27
27
  'memory-mib': { type: 'string', value: '<n>', description: 'Memory cap in MiB.' },
28
28
  'disk-gib': { type: 'string', value: '<n>', description: 'Disk cap in GiB.' },
29
29
  };
30
+ /** Elastic memory (0.8.0+): the memory allocation of a workspace's caps (open and fork only). */
31
+ const MEMORY_ALLOCATION = {
32
+ 'allocation-mode': {
33
+ type: 'string',
34
+ value: '<fixed|elastic>',
35
+ description: 'elastic: --memory-mib is a promise; the workspace holds --memory-held while idle and the host grows it when a command needs it (needs the elastic memory entitlement). Takes effect at the next VM start. Caps given without it make the workspace fixed; a command without caps keeps the stored layout.',
36
+ },
37
+ 'memory-held': { type: 'string', value: '<mib>', description: 'With --allocation-mode elastic: memory held while idle, in MiB (at least 512, default 1024, at most --memory-mib).' },
38
+ };
30
39
  /** `--timing` (0.3.0+): the SDK's lifecycle timing of the command's open, wait or wake (README "Timing"). */
31
40
  const TIMING = {
32
41
  timing: {
@@ -209,6 +218,7 @@ const KEY_COMMANDS = [
209
218
  },
210
219
  ...INPUTS,
211
220
  ...CAPS,
221
+ ...MEMORY_ALLOCATION,
212
222
  wait: { type: 'boolean', description: 'Wait until ready (default; --no-wait returns at once). Ready includes the template’s start commands and services.' },
213
223
  timeout: { type: 'string', value: '<duration>', description: 'Give up waiting after this long (default 5m). The start continues server side; one waiting for capacity gives up 15 minutes after it began (capacity_unavailable, retryable).' },
214
224
  ...TIMING,
@@ -221,6 +231,7 @@ const KEY_COMMANDS = [
221
231
  'shard ws open acme/demo --template python-node-browser --no-wait --json',
222
232
  'shard ws open acme/demo --template python-node-browser --timing',
223
233
  'shard ws open acme/agent-7 --template python-node-browser --mode file-first',
234
+ 'shard ws open acme/demo --template python-node-browser --memory-mib 8192 --allocation-mode elastic --memory-held 1024',
224
235
  ],
225
236
  },
226
237
  {
@@ -245,11 +256,38 @@ const KEY_COMMANDS = [
245
256
  policy: { type: 'string', value: '<policy>', description: 'adaptive, never, fixed:<seconds>, or default to clear the override.' },
246
257
  keepalive: { type: 'string', value: '<seconds>', description: 'Declare ongoing work for this many seconds.' },
247
258
  } },
248
- { path: ['workspaces', 'exec-start'], summary: 'Start a background exec session with optional pipe stdin', positionals: [REF, { name: 'command', required: true, variadic: true }], options: {
259
+ {
260
+ path: ['workspaces', 'exec-start'],
261
+ summary: 'Start a background exec session with optional pipe stdin',
262
+ description: 'Runs argv directly (no shell; use `-- bash -lc "..."` for shell syntax) and returns the session at once (JSON on stdout). Read it with "shard ws exec-read", stop it with "shard ws exec-cancel".',
263
+ positionals: [REF, { name: 'command', required: true, variadic: true }],
264
+ options: {
249
265
  'stdin-open': { type: 'boolean', description: 'Keep pipe stdin open for exec-input.' },
250
266
  'session-id': { type: 'string', value: '<id>', description: 'Caller-chosen id to deduplicate starts.' },
251
267
  cwd: { type: 'string', value: '<dir>', description: 'Absolute working directory.' },
252
- } },
268
+ timeout: { type: 'string', value: '<duration>', description: 'Kill the command after this long (e.g. 30m, 2h; none unless set). The workspace stays awake until the command ends or this passes (1 hour when unset).' },
269
+ },
270
+ examples: ['shard ws exec-start acme/demo --session-id build-1 --timeout 2h -- bash -lc "make -C /home/user/app"', 'shard ws exec-read acme/demo build-1 --follow'],
271
+ },
272
+ {
273
+ path: ['workspaces', 'exec-read'],
274
+ summary: 'Print a background exec session’s output and state; --follow streams it until the command exits',
275
+ description: 'Prints the session’s stdout and stderr from the start. When the command has ended, shard exits with its exit code (124 if it timed out, 128+N if killed by signal N); while it still runs, exit 5. --follow keeps streaming until it ends and resumes from byte offsets after dropped connections; Ctrl-C stops following, the command keeps running. --json prints one object at the end.',
276
+ positionals: [REF, { name: 'session-id', required: true }],
277
+ options: {
278
+ follow: { type: 'boolean', short: 'f', description: 'Stream the output until the command exits, then exit with its exit code.' },
279
+ },
280
+ examples: ['shard ws exec-read acme/demo build-1', 'shard ws exec-read acme/demo build-1 --follow', 'shard ws exec-read acme/demo build-1 --json'],
281
+ },
282
+ {
283
+ path: ['workspaces', 'exec-cancel'],
284
+ summary: 'Stop a background exec session: SIGTERM, then SIGKILL after the grace',
285
+ positionals: [REF, { name: 'session-id', required: true }],
286
+ options: {
287
+ grace: { type: 'string', value: '<duration>', description: 'Time between SIGTERM and SIGKILL (e.g. 10s; at most 60s; default 5s).' },
288
+ },
289
+ examples: ['shard ws exec-cancel acme/demo build-1', 'shard ws exec-cancel acme/demo build-1 --grace 30s'],
290
+ },
253
291
  { path: ['workspaces', 'exec-input'], summary: 'Write pipe stdin at its acknowledged byte offset', positionals: [REF, { name: 'session-id', required: true }, { name: 'data' }], options: {
254
292
  offset: { type: 'string', value: '<bytes>', description: 'Required acknowledged offset (0 initially).' },
255
293
  close: { type: 'boolean', description: 'Send EOF after these bytes are accepted.' },
@@ -272,10 +310,16 @@ const KEY_COMMANDS = [
272
310
  description: 'File-first: the execution’s id (8-128 of A-Z a-z 0-9 . _ : -, starting with a letter or digit; default a fresh ex-<uuid>). Running the same command again with the same id returns its recorded result instead of running it twice, so scripts can repeat the call safely.',
273
311
  },
274
312
  'output-limit': { type: 'string', value: '<bytes>', description: 'File-first: keep at most this many bytes of stdout and of stderr each (1-16777216; default 1 MiB).' },
313
+ burst: {
314
+ type: 'boolean',
315
+ description: 'Processful: run this command on a larger, short-lived burst VM on the workspace’s host and apply its file changes back when it exits (needs the burst execution entitlement). Its processes and tmpfs content do not come back; the workspace’s own processes pause meanwhile. Not with --stdin; cannot be canceled.',
316
+ },
317
+ 'burst-vcpus': { type: 'string', value: '<n>', description: 'With --burst: the burst VM’s vCPUs (1-32; default the host’s, 8, or the plan’s ceiling when lower).' },
318
+ 'burst-memory': { type: 'string', value: '<mib>', description: 'With --burst: the burst VM’s memory in MiB (512-65536; default the host’s, 8192, or the plan’s ceiling when lower).' },
275
319
  verbose: {
276
320
  type: 'boolean',
277
321
  short: 'v',
278
- description: 'After the output, print on stderr what ran: file-first: execution id, state, base -> tree revision, replayed, timings and the changed paths (A|M|D path); processful: the session id and exit status.',
322
+ description: 'After the output, print on stderr what ran: file-first: execution id, state, base -> tree revision, replayed, timings and the changed paths (A|M|D path); processful: the session id and exit status (and with --burst the burst: size, method, applied changes, overhead).',
279
323
  },
280
324
  ...WAKE_TIMING,
281
325
  },
@@ -284,6 +328,7 @@ const KEY_COMMANDS = [
284
328
  'shard ws exec acme/demo --cwd /home/user/app --env CI=1 -- bash -lc "npm test"',
285
329
  'shard ws exec acme/agent-7 -v --execution-id build-42 --timeout 10m -- bash -lc "make -C /home/user/app"',
286
330
  'shard ws exec acme/agent-7 --json -- python3 /home/user/report.py > result.json',
331
+ 'shard ws exec acme/demo --burst --burst-vcpus 16 -v -- bash -lc "cd /home/user/app && go build ./..."',
287
332
  ],
288
333
  },
289
334
  {
@@ -304,7 +349,7 @@ const KEY_COMMANDS = [
304
349
  path: ['workspaces', 'fork'],
305
350
  summary: 'Fork a workspace into a new key',
306
351
  positionals: [REF, { name: 'new-key', required: true }],
307
- options: { ...CAPS, ...WAIT },
352
+ options: { ...CAPS, ...MEMORY_ALLOCATION, ...WAIT },
308
353
  },
309
354
  {
310
355
  path: ['workspaces', 'delete'],