@hasna/sandboxes 0.1.18 → 0.1.20
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 +17 -223
- package/dist/cli/index.js +3474 -2918
- package/dist/db/database.d.ts +1 -1
- package/dist/db/database.d.ts.map +1 -1
- package/dist/index.js +3769 -3130
- package/dist/mcp/index.js +9754 -8462
- package/dist/server/index.js +3771 -3134
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,256 +1,50 @@
|
|
|
1
1
|
# @hasna/sandboxes
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://github.com/hasna/sandboxes/blob/main/LICENSE)
|
|
3
|
+
Universal cloud sandbox manager for AI coding agents - supports e2b, Daytona, Modal
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@hasna/sandboxes)
|
|
6
|
+
[](LICENSE)
|
|
7
7
|
|
|
8
|
-
##
|
|
9
|
-
|
|
10
|
-
- **Multi-provider** -- supports e2b, Daytona, and Modal from one interface
|
|
11
|
-
- **CLI** -- 15+ commands for sandbox lifecycle, file ops, config, and agent management
|
|
12
|
-
- **MCP server** -- 17 tools exposable to Claude Code, Codex, and Gemini
|
|
13
|
-
- **HTTP REST API** -- full CRUD server on port 19430 for programmatic access
|
|
14
|
-
- **Live streaming** -- real-time stdout/stderr capture during command execution
|
|
15
|
-
- **Agent-in-sandbox** -- spawn Claude, Codex, or Gemini agents inside sandboxes
|
|
16
|
-
- **File operations** -- read, write, and list files in remote sandboxes
|
|
17
|
-
- **Keep-alive** -- extend sandbox lifetimes on demand
|
|
18
|
-
- **Webhooks** -- register HTTP callbacks for sandbox lifecycle events
|
|
19
|
-
- **SQLite state tracking** -- local database for sandbox, session, agent, and project state
|
|
20
|
-
- **Project scoping** -- group sandboxes by project for multi-repo workflows
|
|
21
|
-
- **Zero config start** -- sensible defaults, configure only what you need
|
|
22
|
-
|
|
23
|
-
## Installation
|
|
8
|
+
## Install
|
|
24
9
|
|
|
25
10
|
```bash
|
|
26
|
-
# bun (recommended)
|
|
27
|
-
bun add -g @hasna/sandboxes
|
|
28
|
-
|
|
29
|
-
# npm
|
|
30
11
|
npm install -g @hasna/sandboxes
|
|
31
12
|
```
|
|
32
13
|
|
|
33
|
-
##
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
# Create a sandbox (uses default provider)
|
|
37
|
-
sandboxes create --name my-dev
|
|
38
|
-
|
|
39
|
-
# List running sandboxes
|
|
40
|
-
sandboxes list
|
|
41
|
-
|
|
42
|
-
# Execute a command
|
|
43
|
-
sandboxes exec <id> ls -la /workspace
|
|
44
|
-
|
|
45
|
-
# View logs
|
|
46
|
-
sandboxes logs <id>
|
|
47
|
-
|
|
48
|
-
# File operations
|
|
49
|
-
sandboxes files ls <id> /workspace
|
|
50
|
-
sandboxes files read <id> /workspace/main.py
|
|
51
|
-
sandboxes files write <id> /workspace/main.py < main.py
|
|
52
|
-
|
|
53
|
-
# Stop and delete
|
|
54
|
-
sandboxes stop <id>
|
|
55
|
-
sandboxes delete <id>
|
|
56
|
-
|
|
57
|
-
# Configure defaults
|
|
58
|
-
sandboxes config set default_provider e2b
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Provider Setup
|
|
62
|
-
|
|
63
|
-
Each provider requires an API key. Set them via the CLI or environment variables.
|
|
64
|
-
|
|
65
|
-
### e2b
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
sandboxes config set providers.e2b.api_key <your-key>
|
|
69
|
-
# or
|
|
70
|
-
export E2B_API_KEY=<your-key>
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Daytona
|
|
14
|
+
## CLI Usage
|
|
74
15
|
|
|
75
16
|
```bash
|
|
76
|
-
sandboxes
|
|
77
|
-
# or
|
|
78
|
-
export DAYTONA_API_KEY=<your-key>
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Modal
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
sandboxes config set providers.modal.api_key <your-key>
|
|
85
|
-
# or
|
|
86
|
-
export MODAL_API_KEY=<your-key>
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Default Provider
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
sandboxes config set default_provider e2b
|
|
93
|
-
sandboxes config set default_timeout 300000
|
|
94
|
-
sandboxes config set default_image python:3.12
|
|
17
|
+
sandboxes --help
|
|
95
18
|
```
|
|
96
19
|
|
|
97
20
|
## MCP Server
|
|
98
21
|
|
|
99
|
-
Install the MCP server so AI agents can manage sandboxes through tool calls.
|
|
100
|
-
|
|
101
|
-
### Claude Code
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
sandboxes mcp --claude
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
This registers the `sandboxes` MCP server via `claude mcp add`. After installation, restart Claude Code and the 17 sandbox tools will be available.
|
|
108
|
-
|
|
109
|
-
### Manual
|
|
110
|
-
|
|
111
22
|
```bash
|
|
112
|
-
# Run the MCP server directly over stdio
|
|
113
23
|
sandboxes-mcp
|
|
114
24
|
```
|
|
115
25
|
|
|
116
|
-
|
|
26
|
+
41 tools available.
|
|
117
27
|
|
|
118
|
-
|
|
119
|
-
|------|-------------|
|
|
120
|
-
| `create_sandbox` | Create a new sandbox |
|
|
121
|
-
| `get_sandbox` | Get sandbox details by ID |
|
|
122
|
-
| `list_sandboxes` | List sandboxes with filters |
|
|
123
|
-
| `delete_sandbox` | Delete a sandbox |
|
|
124
|
-
| `stop_sandbox` | Stop a running sandbox |
|
|
125
|
-
| `keep_alive` | Extend sandbox lifetime |
|
|
126
|
-
| `exec_command` | Execute a command in a sandbox |
|
|
127
|
-
| `read_file` | Read a file from a sandbox |
|
|
128
|
-
| `write_file` | Write a file to a sandbox |
|
|
129
|
-
| `list_files` | List files in a sandbox directory |
|
|
130
|
-
| `get_logs` | Get sandbox/session event logs |
|
|
131
|
-
| `register_agent` | Register an agent |
|
|
132
|
-
| `list_agents` | List all registered agents |
|
|
133
|
-
| `register_project` | Register a project |
|
|
134
|
-
| `list_projects` | List all projects |
|
|
135
|
-
| `describe_tools` | List all available tools |
|
|
136
|
-
| `search_tools` | Search tools by keyword |
|
|
137
|
-
|
|
138
|
-
## CLI Reference
|
|
139
|
-
|
|
140
|
-
### Sandbox Lifecycle
|
|
28
|
+
## REST API
|
|
141
29
|
|
|
142
30
|
```bash
|
|
143
|
-
sandboxes
|
|
144
|
-
--provider <name> # e2b | daytona | modal
|
|
145
|
-
--name <name> # Human-readable name
|
|
146
|
-
--image <image> # Container image
|
|
147
|
-
--timeout <ms> # Timeout in milliseconds
|
|
148
|
-
--env <KEY=VALUE> # Environment variables (repeatable)
|
|
149
|
-
|
|
150
|
-
sandboxes list [options] # List sandboxes
|
|
151
|
-
--status <status> # Filter by status
|
|
152
|
-
--provider <name> # Filter by provider
|
|
153
|
-
|
|
154
|
-
sandboxes show <id> # Show sandbox details
|
|
155
|
-
sandboxes stop <id> # Stop a sandbox
|
|
156
|
-
sandboxes delete <id> # Delete a sandbox
|
|
31
|
+
sandboxes-serve
|
|
157
32
|
```
|
|
158
33
|
|
|
159
|
-
|
|
34
|
+
## Cloud Sync
|
|
160
35
|
|
|
161
|
-
|
|
162
|
-
sandboxes exec <id> <command...> # Execute a command in a sandbox
|
|
163
|
-
--background # Run in background
|
|
164
|
-
--timeout <ms> # Command timeout
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### Logs
|
|
36
|
+
This package supports cloud sync via `@hasna/cloud`:
|
|
168
37
|
|
|
169
38
|
```bash
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
--follow # Stream logs in real time
|
|
39
|
+
cloud setup
|
|
40
|
+
cloud sync push --service sandboxes
|
|
41
|
+
cloud sync pull --service sandboxes
|
|
174
42
|
```
|
|
175
43
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
```bash
|
|
179
|
-
sandboxes files ls <id> <path> # List files in a directory
|
|
180
|
-
sandboxes files read <id> <path> # Read a file
|
|
181
|
-
sandboxes files write <id> <path> # Write stdin to a file
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
### Configuration
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
sandboxes config set <key> <value> # Set a config value
|
|
188
|
-
sandboxes config get <key> # Get a config value
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Agent Management
|
|
192
|
-
|
|
193
|
-
```bash
|
|
194
|
-
sandboxes init # Register an agent
|
|
195
|
-
sandboxes agents # List registered agents
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### MCP Installation
|
|
199
|
-
|
|
200
|
-
```bash
|
|
201
|
-
sandboxes mcp # Install MCP server for AI agents
|
|
202
|
-
--claude # Install for Claude Code
|
|
203
|
-
--codex # Install for Codex
|
|
204
|
-
--gemini # Install for Gemini
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
## HTTP API
|
|
208
|
-
|
|
209
|
-
Start the HTTP server:
|
|
210
|
-
|
|
211
|
-
```bash
|
|
212
|
-
sandboxes-serve # Default port 19430
|
|
213
|
-
sandboxes-serve --port 8080 # Custom port
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### Endpoints
|
|
217
|
-
|
|
218
|
-
| Method | Path | Description |
|
|
219
|
-
|--------|------|-------------|
|
|
220
|
-
| `GET` | `/api/health` | Health check |
|
|
221
|
-
| `GET` | `/api/sandboxes` | List sandboxes (query: `status`, `provider`) |
|
|
222
|
-
| `POST` | `/api/sandboxes` | Create a sandbox |
|
|
223
|
-
| `GET` | `/api/sandboxes/:id` | Get sandbox by ID |
|
|
224
|
-
| `DELETE` | `/api/sandboxes/:id` | Delete a sandbox |
|
|
225
|
-
| `POST` | `/api/sandboxes/:id/stop` | Stop a sandbox |
|
|
226
|
-
| `POST` | `/api/sandboxes/:id/exec` | Execute a command |
|
|
227
|
-
| `POST` | `/api/sandboxes/:id/keep-alive` | Extend lifetime |
|
|
228
|
-
| `GET` | `/api/sandboxes/:id/logs` | Get event logs |
|
|
229
|
-
| `GET` | `/api/sandboxes/:id/sessions` | List sessions |
|
|
230
|
-
| `GET` | `/api/sandboxes/:id/files` | List files (query: `path`) |
|
|
231
|
-
| `GET` | `/api/agents` | List agents |
|
|
232
|
-
| `POST` | `/api/agents` | Register an agent |
|
|
233
|
-
| `GET` | `/api/projects` | List projects |
|
|
234
|
-
| `POST` | `/api/projects` | Register a project |
|
|
235
|
-
| `GET` | `/api/webhooks` | List webhooks |
|
|
236
|
-
| `POST` | `/api/webhooks` | Create a webhook |
|
|
237
|
-
| `DELETE` | `/api/webhooks/:id` | Delete a webhook |
|
|
238
|
-
|
|
239
|
-
## Architecture
|
|
240
|
-
|
|
241
|
-
```
|
|
242
|
-
src/
|
|
243
|
-
cli/ CLI built with Commander + Ink (React for terminals)
|
|
244
|
-
mcp/ MCP server using @modelcontextprotocol/sdk
|
|
245
|
-
server/ HTTP REST API using Bun.serve
|
|
246
|
-
providers/ Provider adapters (e2b, daytona, modal)
|
|
247
|
-
db/ SQLite persistence (sandboxes, sessions, events, agents, projects, webhooks)
|
|
248
|
-
lib/ Shared utilities (config, streaming)
|
|
249
|
-
types/ TypeScript type definitions
|
|
250
|
-
```
|
|
44
|
+
## Data Directory
|
|
251
45
|
|
|
252
|
-
|
|
46
|
+
Data is stored in `~/.hasna/sandboxes/`.
|
|
253
47
|
|
|
254
48
|
## License
|
|
255
49
|
|
|
256
|
-
Apache-2.0
|
|
50
|
+
Apache-2.0 -- see [LICENSE](LICENSE)
|