sandcovery 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,7 @@ TypeScript client for the [Sandcovery API](https://www.sandcovery.com): one API
12
12
  npm install sandcovery
13
13
  ```
14
14
 
15
- Node.js 24 or later. The package has no runtime dependencies.
15
+ Node.js 24.14 or later. The package has no runtime dependencies.
16
16
 
17
17
  ## Quick start
18
18
 
@@ -24,16 +24,34 @@ import { Sandcovery } from 'sandcovery'
24
24
  const sandcovery = new Sandcovery()
25
25
 
26
26
  const sandbox = await sandcovery.sandboxes.create({
27
+ disk_mib: null,
28
+ egress: null,
29
+ env: null,
30
+ gpu: null,
31
+ idle_timeout_seconds: null,
32
+ image: null,
33
+ os: null,
34
+ ports: null,
35
+ provider: null,
36
+ region: null,
27
37
  slug: 'sandcovery/2x4:cheapest',
38
+ slugs: null,
39
+ snapshot_id: null,
28
40
  ttl_seconds: 600,
29
41
  })
30
42
 
31
43
  const { exit_code, stdout } = await sandcovery.sandboxes.exec(sandbox.id, {
32
44
  command: 'node --version',
45
+ cwd: null,
46
+ env: null,
47
+ timeout_seconds: null,
33
48
  })
34
49
 
35
50
  for await (const event of sandcovery.sandboxes.execStream(sandbox.id, {
36
51
  command: 'npm test',
52
+ cwd: null,
53
+ env: null,
54
+ timeout_seconds: null,
37
55
  })) {
38
56
  if (event.type === 'stdout') {
39
57
  process.stdout.write(event.data)
@@ -47,32 +65,29 @@ Sandcovery destroys every sandbox at its `ttl_seconds`, even when your process e
47
65
 
48
66
  ## Command line
49
67
 
50
- The package also installs the `sandcovery` command, which calls the API through this client.
68
+ The package also installs the `sandcovery` command. Each operation in the [OpenAPI document](https://www.sandcovery.com/docs) is one command, `sandcovery <group> <operation>`, named as the document names it, and each of its parameters and body fields is a flag of the same name.
51
69
 
52
70
  ```sh
53
71
  npm install --global sandcovery
54
- sandcovery setup
55
72
  export SANDCOVERY_API_KEY=sand_...
56
73
 
57
- id=$(sandcovery sandboxes create --slug sandcovery/2x4:cheapest --ttl 600)
58
- sandcovery sandboxes exec "$id" -- npm test
59
- sandcovery sandboxes destroy "$id" --yes
74
+ id=$(sandcovery sandboxes createSandbox --slug sandcovery/2x4:cheapest --ttl_seconds 600 | jq -r .id)
75
+ sandcovery sandboxes execSandbox --sandbox_id "$id" --command 'npm test'
76
+ sandcovery sandboxes destroySandbox --sandbox_id "$id"
60
77
  ```
61
78
 
62
- - `sandcovery setup` writes a shim for each drop-in the package installs, such as `docker` for `sandcovery-docker` and `kubectl` for `sandcovery-kubectl`, into `~/.config/sandcovery/bin`, and adds one line that puts that folder first on `PATH` to the bash, zsh, and fish startup files, so those commands run on sandboxes in each new terminal. It lists every change and asks first, and needs `--yes` without a terminal. Each line it adds ends in `# added by sandcovery setup`, `sandcovery setup --undo` removes those lines and the shims and nothing else, and your own `docker` or `kubectl` still runs by its full path.
63
- - `sandcovery login` shows a URL and a code to approve in a browser signed in to Sandcovery, then saves a login, readable only by you, that commands send when neither `--token` nor `SANDCOVERY_API_KEY` is set. `sandcovery logout` revokes it and deletes it.
64
- - `sandcovery sandboxes exec` streams the command's output and exits with the command's exit code.
65
- - `sandcovery docker <args>` runs `docker <args>` in a sandbox on a provider that runs Docker, streams its output, and exits with its exit code, so a computer with no Docker can build and run containers. Later `sandcovery docker` commands reuse that sandbox until its TTL ends. Before Docker runs, it copies the local files the command reads into the sandbox at the same absolute paths, up to 100 MiB packed, and runs Docker in the same working directory there: build contexts without what `.dockerignore` leaves out, bind mount sources, env files, the files `cp`, `load -i`, and `import` read, and a Compose project's files, build contexts, and bind mounts. It copies only paths under your home folder or the working directory. When stdin is not a terminal and Docker reads it, as with `login --password-stdin` or `load`, it hands stdin to Docker, and when stdout is not a terminal and Docker writes an archive there, as with `save`, the archive arrives byte for byte. Docker gets a terminal wherever yours is one, so `docker run -it`, `docker exec -it`, and `docker attach` work, and a command runs until it exits.
66
- - `sandcovery-docker <args>` does the same in the same sandbox, takes Docker's arguments alone, and adds nothing to Docker's stdout or stderr, so `alias docker=sandcovery-docker` runs `docker` in the sandbox. It reads the key from `SANDCOVERY_API_KEY` or the saved login. The variables Docker reads come from your computer's environment, such as a name given to `-e` with no value, `DOCKER_DEFAULT_PLATFORM`, and the shell variables a Compose file names, and the command sends the sandbox only those. A TCP port a container publishes answers on the same address and port of your computer.
67
- - `sandcovery kubectl <args>` runs your own `kubectl <args>` against a one-node Kubernetes cluster in a sandbox on Freestyle, or on boxd when Freestyle cannot create it, and exits with its exit code. The first command that reaches the cluster starts it, which takes a few minutes, and later commands reuse it. It stops 15 minutes after the last command that reached it ends, or at its TTL, whichever comes first, and a command that keeps running, such as `port-forward` or `logs -f`, keeps it running. `kubectl` must be on `PATH` and runs on your computer, so local files, `port-forward`, `exec -it`, and `logs -f` work as they do with a local cluster. `completion`, `config`, `version --client`, and `--help` start no cluster.
68
- - `sandcovery-kubectl <args>` does the same on the same cluster, takes `kubectl`'s arguments alone, and adds nothing to `kubectl`'s stdout or stderr, so `alias kubectl=sandcovery-kubectl` runs `kubectl` on the sandbox's cluster. It reads the key from `SANDCOVERY_API_KEY` or the saved login.
69
- - `--json` prints one JSON document on stdout, and every failure prints a JSON error with a stable `reason` on stderr.
70
- - `sandboxes destroy`, `keys revoke`, `credentials delete`, and `x-account unlink` ask first, and need `--yes` without a terminal.
71
- - `sandcovery providers list --routed` lists only the providers Sandcovery routes to, `sandcovery credentials offer` shows the free vCPU-hours your keys have earned, `sandcovery credentials count-x-post <URL>` counts your post on X that tags @Sandcovery as one key, `sandcovery pricing inspect` shows the Pro price and the credit terms with no key, `sandcovery pricing monthly --size 2x4 --hours-per-day 8` prices a size for a month on each provider Sandcovery routes to with no key, `sandcovery billing inspect` and `sandcovery billing buy-credits --amount <USD>` show the plan and start a credit payment, and `sandcovery billing set-auto-top-up --amount <USD> --threshold <USD>` and `sandcovery billing stop-auto-top-up` turn auto top-up on and off.
72
- - `sandcovery x-account inspect` shows the X account linked to you, `sandcovery x-account link` prints the dashboard page where you link one, since X confirms the link in the browser, and `sandcovery x-account unlink` unlinks it.
73
- - `sandcovery problems report <text> --page <path>` tells the Sandcovery team about a problem with no key, as `sandcovery.problems.report({ message, path })` does from code.
74
- - `sandcovery help search <words>` finds a command, and `--help` works on every command.
75
- - The CLI sends anonymous usage data: command paths, option names, failure reasons, and exit codes, never values or remote data. `sandcovery cli telemetry disable` or `SANDCOVERY_TELEMETRY_DISABLED=1` turns it off.
79
+ - A command prints the API's answer body on stdout. An error answer goes to stderr as the API sent it, and the command exits 1.
80
+ - It sends `SANDCOVERY_API_KEY` as the key, and calls `SANDCOVERY_BASE_URL` when it is set, or https://www.sandcovery.com.
81
+ - A flag for a field that is not text, such as a number, a list, or an object, takes JSON. An operation whose body is a file, such as `sandboxes uploadFile`, reads that body from stdin.
82
+ - `--help` works on every command.
83
+
84
+ ## Docker, kubectl, and T3 Code
85
+
86
+ The package installs three more commands that run your tools on sandboxes through this client. Each reads the key from `SANDCOVERY_API_KEY` and the API origin from `SANDCOVERY_BASE_URL`, keeps its state in `~/.config/sandcovery`, and passes an API error through unchanged.
87
+
88
+ - `sandcovery-docker <args>` runs `docker <args>` in a sandbox on a provider that runs Docker, streams its output, adds nothing to Docker's stdout or stderr, and exits with its exit code, so `alias docker=sandcovery-docker` lets a computer with no Docker build and run containers. Later commands reuse that sandbox until its TTL ends. Before Docker runs, it copies the local files the command reads into the sandbox at the same absolute paths, up to 100 MiB packed, and runs Docker in the same working directory there: build contexts without what `.dockerignore` leaves out, bind mount sources, env files, the files `cp`, `load -i`, and `import` read, and a Compose project's files, build contexts, and bind mounts. It copies only paths under your home folder or the working directory. When stdin is not a terminal and Docker reads it, as with `login --password-stdin` or `load`, it hands stdin to Docker, and when stdout is not a terminal and Docker writes an archive there, as with `save`, the archive arrives byte for byte. Docker gets a terminal wherever yours is one, so `docker run -it`, `docker exec -it`, and `docker attach` work, and a command runs until it exits. The variables Docker reads come from your computer's environment, such as a name given to `-e` with no value, `DOCKER_DEFAULT_PLATFORM`, and the shell variables a Compose file names, and the command sends the sandbox only those. A TCP port a container publishes answers on the same address and port of your computer.
89
+ - `sandcovery-kubectl <args>` runs your own `kubectl <args>` against a one-node Kubernetes cluster in a sandbox on Freestyle, or on boxd when Freestyle cannot create it, adds nothing to `kubectl`'s stdout or stderr, and exits with its exit code, so `alias kubectl=sandcovery-kubectl` runs `kubectl` on the sandbox's cluster. The first command that reaches the cluster starts it, which takes a few minutes, and later commands reuse it. It stops 15 minutes after the last command that reached it ends, or at its TTL, whichever comes first, and a command that keeps running, such as `port-forward` or `logs -f`, keeps it running. `kubectl` must be on `PATH` and runs on your computer, so local files, `port-forward`, `exec -it`, and `logs -f` work as they do with a local cluster. `completion`, `config`, `version --client`, and `--help` start no cluster.
90
+ - `sandcovery-t3` creates a sandbox with port 3773, installs the same version of T3 Code there as your local `t3`, and links it to your T3 Code as an environment with `t3 environment link`, so an agent in T3 Code can delegate work to that sandbox. `--access` sets what agents on your computer may do there, each `--env NAME=value` reaches only T3 Code and the agents it runs, `--provider` names a provider to use, and `--ttl` sets the sandbox's TTL in seconds. It prints the sandbox's ID, and destroys the sandbox when any step fails.
76
91
 
77
92
  ## Routing
78
93
 
@@ -92,13 +107,13 @@ const admin = new Sandcovery({ apiKey: process.env.SANDCOVERY_MANAGEMENT_KEY })
92
107
  await admin.credentials.set('e2b', { api_key: process.env.E2B_API_KEY })
93
108
  ```
94
109
 
95
- An organization holds as many credentials as it needs: `credentials.add(provider, fields)` adds another, a create tries a provider's credentials in the order they were added, and `credentials.deleteOne(provider, id)` deletes one. A Free organization routes only its oldest credential, and `paused` is `true` on each other one until it has Pro.
110
+ On Pro or the Enterprise plan, an organization holds as many credentials per provider as it needs: `credentials.add(provider, fields)` adds another, a create tries a provider's credentials in the order they were added, and `credentials.deleteOne(provider, id)` deletes one. A Free organization routes one of its own keys per provider, so adding a second key of the same provider receives 403. When an organization leaves Pro or the Enterprise plan, it keeps every key, routes the oldest key of each provider, and `paused` is `true` on the others until it is on Pro or the Enterprise plan again.
96
111
 
97
112
  The fields each provider takes are its `credential_fields` on `sandcovery.providers.get(provider)`. `sandcovery.providers.catalog()` lists every provider on the [provider board](https://www.sandcovery.com/providers), where `routed` is `false` for a provider that is coming soon. `credentials.offer()` reads the free vCPU-hours your keys have earned, `credentials.countXPost({ url })` counts your post on X that tags @Sandcovery as one key, `billing.get()` reads the plan, the credit balance, and auto top-up, `billing.buyCredits({ amount_micro_usd })` answers the Stripe Checkout page that takes a credit payment, `billing.setAutoTopUp({ amount_micro_usd, threshold_micro_usd })` sets the amount Sandcovery charges the saved card each time the credit balance falls below the threshold and answers the Stripe Checkout page that saves a card when none is saved, and `billing.stopAutoTopUp()` turns auto top-up off.
98
113
 
99
114
  ## X account
100
115
 
101
- `xAccount.get()` reads the X account linked to you and whether Sandcovery links X accounts now, `xAccount.link()` answers the dashboard page where you link one, since X confirms the link in the browser, and `xAccount.unlink()` unlinks it and deletes its ID, handle, and X token. An X account belongs to a person, so these need a management key, which acts for the owner who minted it, and the CLI also takes its login. An API key receives 403 there.
116
+ `xAccount.get()` reads the X account linked to you and whether Sandcovery links X accounts now, `xAccount.link()` answers the dashboard page where you link one, since X confirms the link in the browser, and `xAccount.unlink()` unlinks it and deletes its ID, handle, and X token. An X account belongs to a person, so these need a management key, which acts for the owner who minted it. An API key receives 403 there.
102
117
 
103
118
  ## Interfaces
104
119
 
@@ -106,8 +121,8 @@ This client, the `sandcovery` command, and the Python client each reach every op
106
121
 
107
122
  ## Errors
108
123
 
109
- A failed call throws the API error it received, with its `error` code, such as `unsupported`, `no_provider_available` (with every attempt in `attempts`), `provider_error` (with the provider in `provider`), or `spend_limit_reached`. Types of every request and answer are exported from `sandcovery/types`.
124
+ A failed call throws an `Error` with the API's `message` and, as its `cause`, the API error it received, with its `error` code, such as `unsupported`, `no_provider_available` (with every attempt in `attempts`), `provider_error` (with the provider in `provider`), or `spend_limit_reached`. Types of every request and answer are exported from `sandcovery/types`.
110
125
 
111
126
  ## Reference
112
127
 
113
- The API reference and the OpenAPI document are at https://www.sandcovery.com/docs.
128
+ The API reference and the OpenAPI document are at https://www.sandcovery.com/docs/api.