@insforge/instabox-sdk 0.6.0 → 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 +63 -19
- package/dist/index.cjs +1141 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +178 -19
- package/dist/index.d.ts +178 -19
- package/dist/index.js +1131 -85
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/skills/instabox/SKILL.md +5 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@insforge/instabox-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "TypeScript SDK for instabox: create sandboxes on Firecracker dev machines, run commands, move files, pause, resume, snapshot and SSH in.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"prepare": "tsup",
|
|
36
36
|
"typecheck": "tsc --noEmit",
|
|
37
37
|
"test": "vitest run",
|
|
38
|
-
"test:live": "INSTABOX_LIVE=1 vitest run test/live.test.ts",
|
|
38
|
+
"test:live": "INSTABOX_LIVE=1 vitest run test/live.test.ts test/live-transfer.test.ts",
|
|
39
39
|
"prepublishOnly": "npm run format:check && npm run lint && npm run typecheck && npm run build && npm test",
|
|
40
40
|
"format:check": "prettier --check src test *.ts package.json .prettierrc.json README.md skills .github",
|
|
41
41
|
"lint": "oxlint --deny-warnings src test"
|
package/skills/instabox/SKILL.md
CHANGED
|
@@ -50,9 +50,9 @@ try {
|
|
|
50
50
|
}
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
A new sandbox pauses itself after 30 idle minutes and resumes on the next command, file read or SSH sign-in.
|
|
53
|
+
A new sandbox pauses itself after 30 idle minutes and resumes on the next command, file read or SSH sign-in. On a paid plan, pass another idle time (5 to 30 minutes) as `autoSuspendMs` (or `setAutoSuspend(ms)` later), and `autoSuspendMs: 0` means the sandbox runs until code calls `pause()`, `stop()` or `kill()`; the free plan keeps 30 minutes and refuses any other value with a 403, so leave it out there. Keep `sandboxId` to pause, stop or kill it later, and reattach with `Sandbox.connect(id, { resume: false })` so attaching does not wake it. `pause()` keeps memory and processes; `stop()` ends processes and keeps disks; `kill()` deletes the sandbox and its disks. A forgotten sandbox pauses itself once idle; kill it in a `finally` as the examples do. There is no lifetime timeout: `timeoutMs`, `onTimeout` and `setTimeout()` (SDK 0.5) throw `InstaboxError` code `retired_option`.
|
|
54
54
|
|
|
55
|
-
Connection options `{ apiKey, apiUrl }` override environment variables. `agent-browser` (universal plus a desktop and browser) is the default template; `universal` on a server without it. The free plan creates from `agent-browser`
|
|
55
|
+
Connection options `{ apiKey, apiUrl }` override environment variables. `agent-browser` (universal plus a desktop and browser) is the default template; `universal` on a server without it. The free plan creates from `agent-browser`, `android` or `ci` only; other templates need a paid plan (`403 template_not_allowed` on free). Create accepts a template ID, a private snapshot name, or a `sn_...` snapshot ID. Template IDs take precedence; duplicate snapshot names require an ID. There are no official snapshots. Template creation and snapshot-ID creation need only machine scopes; snapshot-name lookup also needs `images:read`.
|
|
56
56
|
|
|
57
57
|
Drive the desktop with `box.desktop`: `start()`, `open(url)`, `screenshot()` (PNG bytes), `click(x, y)`, `move`, `drag`, `scroll`, `type(text)`, `press('Enter' | ['ctrl', 'l'])`, `cursorPosition()`. `streamUrl({ viewOnly: true })` returns a link (also embeddable in an iframe) that shows the desktop to people without an account; its expiry stops new connections, and `revokeStreamUrls()` ends every link and disconnects open viewers.
|
|
58
58
|
|
|
@@ -119,8 +119,9 @@ For SSH certificates, use `box.sshCredentials(publicKey)`. Use its returned host
|
|
|
119
119
|
|
|
120
120
|
## Limits and errors
|
|
121
121
|
|
|
122
|
-
- `CommandExitError` carries stdout, stderr, exitCode, timedOut and truncated. With `onStdout` or `onStderr` the output is streamed to them as the command writes it (not capped); without them it is buffered and capped at 1 MiB per stream. stdin
|
|
123
|
-
-
|
|
122
|
+
- `CommandExitError` carries stdout, stderr, exitCode, timedOut and truncated. With `onStdout` or `onStderr` the output is streamed to them as the command writes it (not capped); without them it is buffered and capped at 1 MiB per stream. `stdin` takes a string or a `Uint8Array` and arrives byte for byte (over 1 MiB, or not UTF-8, it is staged as a temporary file first, up to 5 GiB); commands may run for at most 600 seconds, and a timeout throws `CommandExitError` with `timedOut: true` and exit code 124. For longer commands use `background: true`: it returns `{ pid, jobId, kill(), wait({ onStdout }) }`; `wait` streams the job's log (stdout and stderr together) and resolves with its exit code, and `kill()` ends the command and everything it started. Pass `onStdout` to `wait()`, not to a background `run` (that throws `bad_request`). A sandbox without bash, util-linux `setsid` and GNU coreutils throws `background_unsupported`. The CLI's `instabox jobs logs <sandbox> <jobId> -f` follows the same job.
|
|
123
|
+
- `files.write(path, data)` takes a string, bytes, or a stream (a Node `Readable`, a web `ReadableStream`, an async iterable) and streams it in one HTTP request, up to 5 GiB, without holding it in memory. `files.read` loads the file and is capped at 10 MiB unless `maxBytes` raises it; `files.readStream(path)` returns a stream with no cap (`for await`, or `Readable.fromWeb` in Node).
|
|
124
|
+
- `files.upload(localDir, remoteDir)` and `files.download(remoteDir, localDir)` move a whole directory in one call (a gzipped tar, like `instabox push` / `pull`). In a git work tree `upload` sends only tracked files (`{ all: true }` adds untracked unignored ones, `{ git: false }` sends everything). Symlinks stay symlinks; existing files at the destination are replaced, others kept. Node, Bun or Deno only.
|
|
124
125
|
- `files.read(path)` returns text only for valid UTF-8; a binary file (image, archive, compiled output) throws `InstaboxNotUtf8Error` (code `not_utf8`) instead of a string with U+FFFD. Read binaries with `files.read(path, { format: 'bytes' })` (exact `Uint8Array`).
|
|
125
126
|
- `InstaboxAuthError` covers 401/403 credential and access errors (a bad key, missing scope, `permission_denied`); `InstaboxQuotaError` covers quota, plan and billing limits (`template_not_allowed`, `spec_not_allowed`, `credit_exhausted` and the rest of `LIMIT_CODES`, whatever the status, and any 402) and 429, including the limit of 32 requests per user at once across all sandboxes (commands, file reads, desktop, port-forward and vault-push calls share it; a background command counts only while it starts, and its `wait()` while it waits); `InstaboxTimeoutError` covers request/operation deadlines; `InstaboxNotUtf8Error` (`not_utf8`) is a text read of a file that is not UTF-8. `InstaboxError` carries status, code, requestId and operationId.
|
|
126
127
|
- Inspect `GET /v1/usage` for account quotas. Sizes on `api.instabox.sh` are fixed (4 vCPU, 8 GiB, 16 GiB root, 20 GiB `/data`); do not pass `vcpus`, `memMiB`, `diskGiB` or `rootDiskGiB` there (`400 spec_not_allowed`). Sandbox names are lowercase letters, digits and `-`.
|