@lizard-build/sdk 0.1.36 → 0.1.38
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 +18 -10
- package/dist/index.d.mts +32 -9
- package/dist/index.d.ts +32 -9
- package/dist/index.js +7 -2
- package/dist/index.mjs +7 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,7 +82,7 @@ sandbox.kill()
|
|
|
82
82
|
|
|
83
83
|
## Persisting Work Across Sandboxes
|
|
84
84
|
|
|
85
|
-
Sandboxes are **ephemeral**: killing one, or letting it hit its timeout, discards everything written inside it. State that has to outlive a sandbox goes on a **volume** — a separate disk mounted at `/
|
|
85
|
+
Sandboxes are **ephemeral**: killing one, or letting it hit its timeout, discards everything written inside it. State that has to outlive a sandbox goes on a **volume** — a separate disk mounted at `/workspace` that a later sandbox re-attaches.
|
|
86
86
|
|
|
87
87
|
A volume is node-local, so it fixes the region too. You don't thread a region through both calls: the sandbox is placed wherever its volume already lives.
|
|
88
88
|
|
|
@@ -90,25 +90,25 @@ A volume is node-local, so it fixes the region too. You don't thread a region th
|
|
|
90
90
|
const vol = await lizard.volumes.getOrCreate('agent-scratch', { sizeGb: 10 })
|
|
91
91
|
|
|
92
92
|
const first = await lizard.create('codex', { volumeName: 'agent-scratch' })
|
|
93
|
-
await first.process.exec('pip install numpy pandas && echo "notes" > /
|
|
94
|
-
await first.kill() // sandbox gone, /
|
|
93
|
+
await first.process.exec('pip install numpy pandas && echo "notes" > /workspace/notes.txt')
|
|
94
|
+
await first.kill() // sandbox gone, /workspace survives
|
|
95
95
|
|
|
96
96
|
const second = await lizard.create('codex', { volumeName: 'agent-scratch' })
|
|
97
|
-
console.log(await second.fs.read('/
|
|
97
|
+
console.log(await second.fs.read('/workspace/notes.txt')) // "notes"
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
```python
|
|
101
101
|
vol = lizard.volumes.get_or_create("agent-scratch", size_gb=10)
|
|
102
102
|
|
|
103
103
|
first = lizard.create("codex", volume_name="agent-scratch")
|
|
104
|
-
first.process.exec_('echo "notes" > /
|
|
105
|
-
first.kill() # sandbox gone, /
|
|
104
|
+
first.process.exec_('echo "notes" > /workspace/notes.txt')
|
|
105
|
+
first.kill() # sandbox gone, /workspace survives
|
|
106
106
|
|
|
107
107
|
second = lizard.create("codex", volume_name="agent-scratch")
|
|
108
|
-
print(second.fs.read("/
|
|
108
|
+
print(second.fs.read("/workspace/notes.txt")) # "notes"
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
Note that only `/
|
|
111
|
+
Note that only `/workspace` survives — installed packages and in-memory state do not. Bake tooling into a template instead of reinstalling it per sandbox.
|
|
112
112
|
|
|
113
113
|
> `pause()` / `resume()` exist on the client but are **not implemented** for the current runtime and always fail with HTTP 501. Use a volume.
|
|
114
114
|
|
|
@@ -148,6 +148,14 @@ sandbox.process.exec_("lizard volume list")
|
|
|
148
148
|
|
|
149
149
|
A key with **no** scope has full access to everything the creating account can reach — pass `workspaces` or `projects` unless you mean that.
|
|
150
150
|
|
|
151
|
+
### What a scoped key deliberately cannot see
|
|
152
|
+
|
|
153
|
+
Billing is account-level: one balance, one ledger, one set of saved cards, shared by every workspace. There is no per-workspace view of it, so a scoped key is refused outright (403 `ACCOUNT_SCOPE_REQUIRED`) on `lizard.billing.*` and on account-wide usage, and `whoami()` returns only identity plus the key's own scopes — not the account's email, balance or plan.
|
|
154
|
+
|
|
155
|
+
That matters because of where these keys end up. A key you hand to a user, or inject into a sandbox with `lizardToken`, is readable by anything running there. It should not be a way to read your card details or spend against them.
|
|
156
|
+
|
|
157
|
+
For per-workspace spend, use `lizard.metrics` — that is scoped, and is what you would bill a user from.
|
|
158
|
+
|
|
151
159
|
## API
|
|
152
160
|
|
|
153
161
|
### `new Lizard({ project, apiKey?, apiUrl?, timeoutMs? })`
|
|
@@ -187,8 +195,8 @@ List all running sandboxes for the authenticated account.
|
|
|
187
195
|
| `lizard.apiKeys` | `list()`, `create({ name, workspaces?, projects? })`, `delete(id)` |
|
|
188
196
|
| `lizard.projects` | `list({ workspaceId? })`, `get(id)`, `create({ workspaceId, name })`, `update(id, { name })`, `delete(id)` |
|
|
189
197
|
| `lizard.regions` | `list()` |
|
|
190
|
-
| `lizard.billing` | `balance()`, `transactions({ limit?, cursor?, includeUsage? })`, `summary()`, `live()` |
|
|
191
|
-
| `lizard.whoami()` | The account behind the credential
|
|
198
|
+
| `lizard.billing` | `balance()`, `transactions({ limit?, cursor?, includeUsage? })`, `summary()`, `live()` — **unscoped keys only** |
|
|
199
|
+
| `lizard.whoami()` | The account behind the credential; a scoped key gets identity and its own scopes, not the account's email or balance |
|
|
192
200
|
| `lizard.platform` | The raw HTTP client, for endpoints not wrapped yet |
|
|
193
201
|
|
|
194
202
|
`workspaces.delete()` is empty-only by default; the server refuses while any project, sandbox or volume remains. `{ force: true }` deletes the workspace and everything in it, irreversibly.
|
package/dist/index.d.mts
CHANGED
|
@@ -303,10 +303,10 @@ interface SandboxOpts extends ConnectionOpts {
|
|
|
303
303
|
* Defaults to the platform's default sandbox region.
|
|
304
304
|
*/
|
|
305
305
|
region?: string;
|
|
306
|
-
/** Attach a persistent volume by id, mounted at `/
|
|
306
|
+
/** Attach a persistent volume by id, mounted at `/workspace`. */
|
|
307
307
|
volumeId?: string;
|
|
308
308
|
/**
|
|
309
|
-
* Attach a persistent volume by name, mounted at `/
|
|
309
|
+
* Attach a persistent volume by name, mounted at `/workspace`. A volume's name is its
|
|
310
310
|
* key inside a project, so this is usually what you want — see {@link Volume}.
|
|
311
311
|
* Requires the sandbox's project to be given as an exact `projectId`.
|
|
312
312
|
*/
|
|
@@ -361,7 +361,7 @@ declare class SandboxClient {
|
|
|
361
361
|
*
|
|
362
362
|
* Sandboxes are **ephemeral**: killing one, or letting it hit its timeout, discards
|
|
363
363
|
* everything written inside it. State that has to outlive a sandbox belongs on a
|
|
364
|
-
* {@link Volume}, which is a separate disk you mount at `/
|
|
364
|
+
* {@link Volume}, which is a separate disk you mount at `/workspace` and re-attach to a
|
|
365
365
|
* later sandbox.
|
|
366
366
|
*
|
|
367
367
|
* @example Basic usage:
|
|
@@ -380,13 +380,13 @@ declare class SandboxClient {
|
|
|
380
380
|
* const vol = await Volume.getOrCreate(projectId, 'agent-scratch', { sizeGb: 10 })
|
|
381
381
|
*
|
|
382
382
|
* const first = await Sandbox.create('codex', { projectId, volumeName: 'agent-scratch' })
|
|
383
|
-
* await first.process.exec('echo "notes" > /
|
|
383
|
+
* await first.process.exec('echo "notes" > /workspace/notes.txt')
|
|
384
384
|
* await first.kill()
|
|
385
385
|
*
|
|
386
386
|
* // A different sandbox, the same disk. No region to thread through: the sandbox
|
|
387
387
|
* // is placed wherever the volume already lives.
|
|
388
388
|
* const second = await Sandbox.create('codex', { projectId, volumeName: 'agent-scratch' })
|
|
389
|
-
* console.log(await second.fs.read('/
|
|
389
|
+
* console.log(await second.fs.read('/workspace/notes.txt')) // "notes"
|
|
390
390
|
* ```
|
|
391
391
|
*/
|
|
392
392
|
declare class Sandbox extends SandboxClient {
|
|
@@ -1098,6 +1098,12 @@ interface ListTransactionsOpts {
|
|
|
1098
1098
|
* a user bills to the account that owns the key. That is what makes per-user
|
|
1099
1099
|
* workspaces a safe pattern — your users get isolation, you keep one bill — and also
|
|
1100
1100
|
* what makes {@link Balance.runwayHours} worth watching before you provision more.
|
|
1101
|
+
*
|
|
1102
|
+
* **Requires an unscoped key.** A scoped key is refused with 403
|
|
1103
|
+
* `ACCOUNT_SCOPE_REQUIRED`, because there is no workspace-scoped view of one shared
|
|
1104
|
+
* balance, ledger and set of saved cards — and because a scoped key is meant to be
|
|
1105
|
+
* handed to an end user, who should not be reading your card details or spending
|
|
1106
|
+
* against them. For per-workspace spend, use {@link MetricsAPI.cost} instead.
|
|
1101
1107
|
*/
|
|
1102
1108
|
declare class BillingAPI {
|
|
1103
1109
|
private readonly client;
|
|
@@ -1281,19 +1287,36 @@ declare class Lizard {
|
|
|
1281
1287
|
/**
|
|
1282
1288
|
* The account this credential belongs to — the SDK's `lizard whoami`.
|
|
1283
1289
|
*
|
|
1284
|
-
*
|
|
1285
|
-
*
|
|
1290
|
+
* A **scoped** key gets identity only: `id`, `username`, `avatarUrl`, `scoped: true`
|
|
1291
|
+
* and the key's own `scopes`. The account's email, balance, plan and billing status
|
|
1292
|
+
* are withheld — they belong to the account, not to the key holder, and a scoped key
|
|
1293
|
+
* is meant to be handed to an end user or injected into a sandbox. An unscoped key
|
|
1294
|
+
* or a session sees the full account.
|
|
1295
|
+
*
|
|
1296
|
+
* Reading back `scopes` is the cheapest way to answer "what can this key reach".
|
|
1286
1297
|
*/
|
|
1287
1298
|
whoami(): Promise<Account>;
|
|
1288
1299
|
/** The underlying HTTP client, for endpoints this SDK does not wrap yet. */
|
|
1289
1300
|
get platform(): PlatformClient;
|
|
1290
1301
|
}
|
|
1291
|
-
/**
|
|
1302
|
+
/**
|
|
1303
|
+
* The account behind a credential — see {@link Lizard.whoami}.
|
|
1304
|
+
*
|
|
1305
|
+
* Everything past `avatarUrl` is present only for an unscoped key or a session; a
|
|
1306
|
+
* scoped key gets `scoped: true` and `scopes` in their place.
|
|
1307
|
+
*/
|
|
1292
1308
|
interface Account {
|
|
1293
1309
|
id: string;
|
|
1294
1310
|
username: string;
|
|
1295
|
-
email?: string | null;
|
|
1296
1311
|
avatarUrl?: string | null;
|
|
1312
|
+
/** True when the calling key is scoped, meaning the account fields below are absent. */
|
|
1313
|
+
scoped?: boolean;
|
|
1314
|
+
/** What the calling key may reach. Present when `scoped` is true. */
|
|
1315
|
+
scopes?: Array<{
|
|
1316
|
+
type: 'workspace' | 'project';
|
|
1317
|
+
id: string;
|
|
1318
|
+
}>;
|
|
1319
|
+
email?: string | null;
|
|
1297
1320
|
plan?: string;
|
|
1298
1321
|
billingStatus?: string;
|
|
1299
1322
|
balanceCents?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -303,10 +303,10 @@ interface SandboxOpts extends ConnectionOpts {
|
|
|
303
303
|
* Defaults to the platform's default sandbox region.
|
|
304
304
|
*/
|
|
305
305
|
region?: string;
|
|
306
|
-
/** Attach a persistent volume by id, mounted at `/
|
|
306
|
+
/** Attach a persistent volume by id, mounted at `/workspace`. */
|
|
307
307
|
volumeId?: string;
|
|
308
308
|
/**
|
|
309
|
-
* Attach a persistent volume by name, mounted at `/
|
|
309
|
+
* Attach a persistent volume by name, mounted at `/workspace`. A volume's name is its
|
|
310
310
|
* key inside a project, so this is usually what you want — see {@link Volume}.
|
|
311
311
|
* Requires the sandbox's project to be given as an exact `projectId`.
|
|
312
312
|
*/
|
|
@@ -361,7 +361,7 @@ declare class SandboxClient {
|
|
|
361
361
|
*
|
|
362
362
|
* Sandboxes are **ephemeral**: killing one, or letting it hit its timeout, discards
|
|
363
363
|
* everything written inside it. State that has to outlive a sandbox belongs on a
|
|
364
|
-
* {@link Volume}, which is a separate disk you mount at `/
|
|
364
|
+
* {@link Volume}, which is a separate disk you mount at `/workspace` and re-attach to a
|
|
365
365
|
* later sandbox.
|
|
366
366
|
*
|
|
367
367
|
* @example Basic usage:
|
|
@@ -380,13 +380,13 @@ declare class SandboxClient {
|
|
|
380
380
|
* const vol = await Volume.getOrCreate(projectId, 'agent-scratch', { sizeGb: 10 })
|
|
381
381
|
*
|
|
382
382
|
* const first = await Sandbox.create('codex', { projectId, volumeName: 'agent-scratch' })
|
|
383
|
-
* await first.process.exec('echo "notes" > /
|
|
383
|
+
* await first.process.exec('echo "notes" > /workspace/notes.txt')
|
|
384
384
|
* await first.kill()
|
|
385
385
|
*
|
|
386
386
|
* // A different sandbox, the same disk. No region to thread through: the sandbox
|
|
387
387
|
* // is placed wherever the volume already lives.
|
|
388
388
|
* const second = await Sandbox.create('codex', { projectId, volumeName: 'agent-scratch' })
|
|
389
|
-
* console.log(await second.fs.read('/
|
|
389
|
+
* console.log(await second.fs.read('/workspace/notes.txt')) // "notes"
|
|
390
390
|
* ```
|
|
391
391
|
*/
|
|
392
392
|
declare class Sandbox extends SandboxClient {
|
|
@@ -1098,6 +1098,12 @@ interface ListTransactionsOpts {
|
|
|
1098
1098
|
* a user bills to the account that owns the key. That is what makes per-user
|
|
1099
1099
|
* workspaces a safe pattern — your users get isolation, you keep one bill — and also
|
|
1100
1100
|
* what makes {@link Balance.runwayHours} worth watching before you provision more.
|
|
1101
|
+
*
|
|
1102
|
+
* **Requires an unscoped key.** A scoped key is refused with 403
|
|
1103
|
+
* `ACCOUNT_SCOPE_REQUIRED`, because there is no workspace-scoped view of one shared
|
|
1104
|
+
* balance, ledger and set of saved cards — and because a scoped key is meant to be
|
|
1105
|
+
* handed to an end user, who should not be reading your card details or spending
|
|
1106
|
+
* against them. For per-workspace spend, use {@link MetricsAPI.cost} instead.
|
|
1101
1107
|
*/
|
|
1102
1108
|
declare class BillingAPI {
|
|
1103
1109
|
private readonly client;
|
|
@@ -1281,19 +1287,36 @@ declare class Lizard {
|
|
|
1281
1287
|
/**
|
|
1282
1288
|
* The account this credential belongs to — the SDK's `lizard whoami`.
|
|
1283
1289
|
*
|
|
1284
|
-
*
|
|
1285
|
-
*
|
|
1290
|
+
* A **scoped** key gets identity only: `id`, `username`, `avatarUrl`, `scoped: true`
|
|
1291
|
+
* and the key's own `scopes`. The account's email, balance, plan and billing status
|
|
1292
|
+
* are withheld — they belong to the account, not to the key holder, and a scoped key
|
|
1293
|
+
* is meant to be handed to an end user or injected into a sandbox. An unscoped key
|
|
1294
|
+
* or a session sees the full account.
|
|
1295
|
+
*
|
|
1296
|
+
* Reading back `scopes` is the cheapest way to answer "what can this key reach".
|
|
1286
1297
|
*/
|
|
1287
1298
|
whoami(): Promise<Account>;
|
|
1288
1299
|
/** The underlying HTTP client, for endpoints this SDK does not wrap yet. */
|
|
1289
1300
|
get platform(): PlatformClient;
|
|
1290
1301
|
}
|
|
1291
|
-
/**
|
|
1302
|
+
/**
|
|
1303
|
+
* The account behind a credential — see {@link Lizard.whoami}.
|
|
1304
|
+
*
|
|
1305
|
+
* Everything past `avatarUrl` is present only for an unscoped key or a session; a
|
|
1306
|
+
* scoped key gets `scoped: true` and `scopes` in their place.
|
|
1307
|
+
*/
|
|
1292
1308
|
interface Account {
|
|
1293
1309
|
id: string;
|
|
1294
1310
|
username: string;
|
|
1295
|
-
email?: string | null;
|
|
1296
1311
|
avatarUrl?: string | null;
|
|
1312
|
+
/** True when the calling key is scoped, meaning the account fields below are absent. */
|
|
1313
|
+
scoped?: boolean;
|
|
1314
|
+
/** What the calling key may reach. Present when `scoped` is true. */
|
|
1315
|
+
scopes?: Array<{
|
|
1316
|
+
type: 'workspace' | 'project';
|
|
1317
|
+
id: string;
|
|
1318
|
+
}>;
|
|
1319
|
+
email?: string | null;
|
|
1297
1320
|
plan?: string;
|
|
1298
1321
|
billingStatus?: string;
|
|
1299
1322
|
balanceCents?: number;
|
package/dist/index.js
CHANGED
|
@@ -1354,8 +1354,13 @@ var Lizard = class {
|
|
|
1354
1354
|
/**
|
|
1355
1355
|
* The account this credential belongs to — the SDK's `lizard whoami`.
|
|
1356
1356
|
*
|
|
1357
|
-
*
|
|
1358
|
-
*
|
|
1357
|
+
* A **scoped** key gets identity only: `id`, `username`, `avatarUrl`, `scoped: true`
|
|
1358
|
+
* and the key's own `scopes`. The account's email, balance, plan and billing status
|
|
1359
|
+
* are withheld — they belong to the account, not to the key holder, and a scoped key
|
|
1360
|
+
* is meant to be handed to an end user or injected into a sandbox. An unscoped key
|
|
1361
|
+
* or a session sees the full account.
|
|
1362
|
+
*
|
|
1363
|
+
* Reading back `scopes` is the cheapest way to answer "what can this key reach".
|
|
1359
1364
|
*/
|
|
1360
1365
|
async whoami() {
|
|
1361
1366
|
return this.platform.get("/api/auth/me");
|
package/dist/index.mjs
CHANGED
|
@@ -1307,8 +1307,13 @@ var Lizard = class {
|
|
|
1307
1307
|
/**
|
|
1308
1308
|
* The account this credential belongs to — the SDK's `lizard whoami`.
|
|
1309
1309
|
*
|
|
1310
|
-
*
|
|
1311
|
-
*
|
|
1310
|
+
* A **scoped** key gets identity only: `id`, `username`, `avatarUrl`, `scoped: true`
|
|
1311
|
+
* and the key's own `scopes`. The account's email, balance, plan and billing status
|
|
1312
|
+
* are withheld — they belong to the account, not to the key holder, and a scoped key
|
|
1313
|
+
* is meant to be handed to an end user or injected into a sandbox. An unscoped key
|
|
1314
|
+
* or a session sees the full account.
|
|
1315
|
+
*
|
|
1316
|
+
* Reading back `scopes` is the cheapest way to answer "what can this key reach".
|
|
1312
1317
|
*/
|
|
1313
1318
|
async whoami() {
|
|
1314
1319
|
return this.platform.get("/api/auth/me");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lizard-build/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
4
4
|
"description": "Firecracker microVM sandboxes for AI agents — boot Linux in milliseconds, run code, write files, expose ports over HTTPS, then pause a session with memory intact and resume it later. TypeScript SDK for Lizard Sandboxes (lizard.build).",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|