@lizard-build/sdk 0.1.1 → 0.1.6
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 +195 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Lizard SDK
|
|
2
|
+
|
|
3
|
+
Firecracker microVM sandboxes for AI agents — boot a full Linux environment in milliseconds, run code, write files, and expose ports, all from your agent or CI pipeline.
|
|
4
|
+
|
|
5
|
+
Each sandbox is an isolated microVM with its own filesystem, network, and process namespace. Sandboxes can be snapshotted and resumed instantly, so long-running agent sessions survive restarts without re-running setup.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# JavaScript / TypeScript
|
|
11
|
+
npm install @lizard-build/sdk
|
|
12
|
+
|
|
13
|
+
# Python
|
|
14
|
+
pip install lizard-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quickstart
|
|
18
|
+
|
|
19
|
+
### JavaScript / TypeScript
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { Sandbox } from '@lizard-build/sdk'
|
|
23
|
+
|
|
24
|
+
// Boot a Node.js microVM from the 'node22' template
|
|
25
|
+
const sandbox = await Sandbox.create('node22')
|
|
26
|
+
|
|
27
|
+
// Write a file directly into the microVM filesystem
|
|
28
|
+
await sandbox.fs.write('/app/server.js', `
|
|
29
|
+
const http = require('http')
|
|
30
|
+
http.createServer((_, res) => res.end('hello from Lizard')).listen(3000)
|
|
31
|
+
`)
|
|
32
|
+
|
|
33
|
+
// Execute a process inside the microVM
|
|
34
|
+
await sandbox.process.exec('node /app/server.js &')
|
|
35
|
+
|
|
36
|
+
// Get a public HTTPS URL for port 3000 inside the sandbox
|
|
37
|
+
const url = sandbox.getHost(3000)
|
|
38
|
+
console.log(`Live at https://${url}`)
|
|
39
|
+
|
|
40
|
+
// Tear down the microVM when done
|
|
41
|
+
await sandbox.kill()
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Python
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from lizard import Sandbox
|
|
48
|
+
|
|
49
|
+
# Boot a Python microVM from the 'python312' template
|
|
50
|
+
sandbox = Sandbox.create("python312")
|
|
51
|
+
|
|
52
|
+
# Write a script into the microVM filesystem
|
|
53
|
+
sandbox.fs.write("/app/main.py", """
|
|
54
|
+
import http.server, socketserver
|
|
55
|
+
|
|
56
|
+
class Handler(http.server.SimpleHTTPRequestHandler):
|
|
57
|
+
def do_GET(self):
|
|
58
|
+
self.send_response(200)
|
|
59
|
+
self.end_headers()
|
|
60
|
+
self.wfile.write(b"hello from Lizard")
|
|
61
|
+
|
|
62
|
+
with socketserver.TCPServer(("", 3000), Handler) as httpd:
|
|
63
|
+
httpd.serve_forever()
|
|
64
|
+
""")
|
|
65
|
+
|
|
66
|
+
# Execute a process inside the microVM
|
|
67
|
+
sandbox.process.exec_("python /app/main.py &")
|
|
68
|
+
|
|
69
|
+
print(f"Live at https://{sandbox.get_host(3000)}")
|
|
70
|
+
|
|
71
|
+
sandbox.kill()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Pause and Resume
|
|
75
|
+
|
|
76
|
+
Sandboxes can be snapshotted mid-execution and resumed exactly where they left off — including installed packages, in-memory state, and running processes. This makes Lizard sandboxes well-suited for long-running AI agent workflows where you want to checkpoint and continue across separate invocations.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
// Boot and set up the environment once
|
|
80
|
+
const sandbox = await Sandbox.create('python312')
|
|
81
|
+
await sandbox.process.exec('pip install numpy pandas scikit-learn')
|
|
82
|
+
const id = sandbox.sandboxId
|
|
83
|
+
await sandbox.pause()
|
|
84
|
+
|
|
85
|
+
// Later — resume instantly from the snapshot (no reinstall needed)
|
|
86
|
+
const resumed = await Sandbox.connect(id)
|
|
87
|
+
const result = await resumed.process.exec('python -c "import sklearn; print(sklearn.__version__)"')
|
|
88
|
+
console.log(result.stdout)
|
|
89
|
+
await resumed.kill()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from lizard import Sandbox
|
|
94
|
+
|
|
95
|
+
sandbox = Sandbox.create("python312")
|
|
96
|
+
sandbox.process.exec_("pip install numpy pandas scikit-learn")
|
|
97
|
+
sandbox_id = sandbox.sandbox_id
|
|
98
|
+
sandbox.pause()
|
|
99
|
+
|
|
100
|
+
# Resume later — environment is exactly as left
|
|
101
|
+
resumed = Sandbox.connect(sandbox_id)
|
|
102
|
+
result = resumed.process.exec_("python -c 'import sklearn; print(sklearn.__version__)'")
|
|
103
|
+
print(result.stdout)
|
|
104
|
+
resumed.kill()
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## API
|
|
108
|
+
|
|
109
|
+
### `Sandbox.create(template?, opts?)`
|
|
110
|
+
|
|
111
|
+
Boot a new Lizard microVM. Built-in templates: `base`, `node22`, `python312`. Custom templates can be pushed via `lizard push`.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
const sandbox = await Sandbox.create('node22')
|
|
115
|
+
const sandbox = await Sandbox.create('python312', { timeoutMs: 10 * 60 * 1000 })
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `Sandbox.connect(sandboxId, opts?)`
|
|
119
|
+
|
|
120
|
+
Connect to an existing sandbox by ID. If the sandbox is paused, it is automatically resumed from its last snapshot.
|
|
121
|
+
|
|
122
|
+
### `Sandbox.list(opts?)`
|
|
123
|
+
|
|
124
|
+
List all running sandboxes for the authenticated account.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### `sandbox.fs`
|
|
129
|
+
|
|
130
|
+
Read and write files inside the microVM filesystem.
|
|
131
|
+
|
|
132
|
+
| Method | Description |
|
|
133
|
+
|---|---|
|
|
134
|
+
| `fs.write(path, data)` | Write a file (string or bytes) |
|
|
135
|
+
| `fs.read(path)` | Read a file as a string |
|
|
136
|
+
| `fs.list(path)` | List directory contents |
|
|
137
|
+
| `fs.remove(path)` | Delete a file or directory |
|
|
138
|
+
| `fs.makeDir(path)` | Create a directory and parents |
|
|
139
|
+
|
|
140
|
+
### `sandbox.process`
|
|
141
|
+
|
|
142
|
+
Execute commands inside the microVM.
|
|
143
|
+
|
|
144
|
+
| Method | Description |
|
|
145
|
+
|---|---|
|
|
146
|
+
| `process.exec(cmd, opts?)` | Run a command and wait for it to finish |
|
|
147
|
+
|
|
148
|
+
`exec` returns `{ stdout, stderr, exitCode }` (JS) or `ProcessResult` (Python). In Python the method is named `exec_` because `exec` is a reserved keyword.
|
|
149
|
+
|
|
150
|
+
### `sandbox.getHost(port)`
|
|
151
|
+
|
|
152
|
+
Returns a public HTTPS URL for a port listening inside the microVM — no tunneling required.
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
await sandbox.process.exec('npx -y serve -p 3000 &')
|
|
156
|
+
const url = sandbox.getHost(3000)
|
|
157
|
+
// https://{sandboxId}-3000.sandbox.lizard.run
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### `sandbox.pause()` / `sandbox.resume()`
|
|
161
|
+
|
|
162
|
+
Snapshot and restore the microVM state. Useful for checkpointing long agent sessions.
|
|
163
|
+
|
|
164
|
+
### `sandbox.kill()`
|
|
165
|
+
|
|
166
|
+
Terminate the sandbox and release all resources.
|
|
167
|
+
|
|
168
|
+
### `sandbox.setTimeout(ms)`
|
|
169
|
+
|
|
170
|
+
Extend or reduce the sandbox timeout.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Environment Variables
|
|
175
|
+
|
|
176
|
+
| Variable | Description |
|
|
177
|
+
|---|---|
|
|
178
|
+
| `LIZARD_API_KEY` | API key (required — get one at [lizard.run](https://lizard.run)) |
|
|
179
|
+
| `LIZARD_API_URL` | Override the API base URL (default: `https://api.lizard.run`) |
|
|
180
|
+
|
|
181
|
+
The `X-API-Key` header is used for all authenticated requests.
|
|
182
|
+
|
|
183
|
+
## Deploy What You Build
|
|
184
|
+
|
|
185
|
+
Once your agent has produced a working app inside a sandbox, deploy it as a persistent Lizard service — no Dockerfile needed:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
lizard up
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Your sandbox template becomes the base, your code ships as a layer on top, and Lizard manages the Firecracker microVM fleet from there.
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
Apache-2.0
|