Skip to content

Commit ff344dc

Browse files
feat(packages/sandbox): sandbox sdk poc
1 parent 1ec4b00 commit ff344dc

20 files changed

Lines changed: 1273 additions & 260 deletions

.changeset/sandbox-sdk.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@bunny.net/sandbox": minor
3+
"@bunny.net/cli": minor
4+
---
5+
6+
Add @bunny.net/sandbox SDK for programmatic sandbox create, file buffering, command execution, and port exposure; wire sandbox CLI commands onto it

AGENTS.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ This is a Bun workspace monorepo with four packages:
7474
- **`@bunny.net/openapi-client`** (`packages/openapi-client/`) — Standalone, type-safe OpenAPI client for bunny.net, generated from OpenAPI specs. Zero CLI dependencies. Publishable to npm.
7575
- **`@bunny.net/app-config`** (`packages/app-config/`) — Shared app configuration schemas (Zod), inferred types, JSON Schema generation, and API conversion functions. Used by the CLI and potentially other tools.
7676
- **`@bunny.net/database-shell`** (`packages/database-shell/`) — Standalone interactive SQL shell for libSQL databases. Framework-agnostic REPL, dot-commands, formatting, masking, and history. Also usable as a standalone CLI (binary: `bsql`).
77-
- **`@bunny.net/cli`** (`packages/cli/`) — The CLI. Depends on `@bunny.net/openapi-client`, `@bunny.net/app-config`, and `@bunny.net/database-shell`.
77+
- **`@bunny.net/sandbox`** (`packages/sandbox/`) — Standalone sandbox SDK. Code-first DX (`Sandbox.create`, `writeFiles`, `runCommand`, `exposePort`) over Magic Containers provisioning plus an `ssh2` SSH/SFTP transport. Zero CLI dependencies.
78+
- **`@bunny.net/cli`** (`packages/cli/`) — The CLI. Depends on `@bunny.net/openapi-client`, `@bunny.net/app-config`, `@bunny.net/database-shell`, and `@bunny.net/sandbox`.
7879

7980
```
8081
bunny-cli/
@@ -144,6 +145,19 @@ bunny-cli/
144145
│ │ ├── types.ts # ShellLogger, ShellOptions, PrintMode
145146
│ │ └── shell.test.ts # Tests for shell utilities
146147
│ │
148+
│ ├── sandbox/ # @bunny.net/sandbox package
149+
│ │ ├── package.json
150+
│ │ ├── tsconfig.json
151+
│ │ └── src/
152+
│ │ ├── index.ts # Barrel export: Sandbox, Command, types
153+
│ │ ├── sandbox.ts # Sandbox class: create/get/fromHandle, runCommand, writeFiles, readFile, mkDir, exposePort, domain, delete
154+
│ │ ├── provision.ts # Magic Containers app create/poll/endpoints + auth helpers
155+
│ │ ├── transport.ts # ssh2 SSH/SFTP transport (exec, file IO, reachability)
156+
│ │ ├── command.ts # Command (detached, logs()) and CommandFinished
157+
│ │ ├── types.ts # Option and handle types
158+
│ │ ├── errors.ts # SandboxError
159+
│ │ └── sandbox.test.ts # Tests for pure logic (command building, app extraction)
160+
│ │
147161
│ └── cli/ # @bunny.net/cli package
148162
│ ├── package.json
149163
│ ├── tsconfig.json
@@ -349,7 +363,7 @@ bunny-cli/
349363

350364
### Conventions
351365

352-
- **Monorepo with Bun workspaces.** `packages/openapi-client/` is the standalone API client SDK; `packages/app-config/` provides shared Zod schemas, types, and API conversion functions for `bunny.jsonc`; `packages/database-shell/` is the standalone SQL shell engine; `packages/cli/` is the CLI.
366+
- **Monorepo with Bun workspaces.** `packages/openapi-client/` is the standalone API client SDK; `packages/app-config/` provides shared Zod schemas, types, and API conversion functions for `bunny.jsonc`; `packages/database-shell/` is the standalone SQL shell engine; `packages/sandbox/` is the standalone sandbox SDK (provisioning + SSH transport); `packages/cli/` is the CLI.
353367
- **API clients use `ClientOptions`** — an options object with `apiKey`, `baseUrl`, `verbose`, `userAgent`, and `onDebug`. The CLI provides a `clientOptions(config, verbose)` helper to build this from `ResolvedConfig`.
354368
- **One command per file.** Each file in `commands/` exports a single command or namespace.
355369
- **Commands are grouped by domain** in subdirectories (`config/`, `db/`, `scripts/`).

CLAUDE.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ test("example", () => {
2626

2727
## Monorepo structure
2828

29-
This is a Bun workspace monorepo with four packages:
29+
This is a Bun workspace monorepo with five packages:
3030

3131
- `packages/openapi-client/` (`@bunny.net/openapi-client`) — standalone, type-safe OpenAPI client, zero CLI deps
3232
- `packages/app-config/` (`@bunny.net/app-config`) — shared Zod schemas, types, and JSON Schema for `bunny.jsonc`
3333
- `packages/database-shell/` (`@bunny.net/database-shell`) — standalone SQL shell engine (REPL, formatting, masking)
34-
- `packages/cli/` (`@bunny.net/cli`) — the CLI, depends on all three
34+
- `packages/sandbox/` (`@bunny.net/sandbox`) — standalone sandbox SDK (create, file buffering, command exec, port exposure) over Magic Containers + SSH
35+
- `packages/cli/` (`@bunny.net/cli`) — the CLI, depends on the other four
3536

3637
## Project conventions
3738

bun.lock

Lines changed: 39 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@bunny.net/openapi-client": "workspace:*",
1414
"@bunny.net/app-config": "workspace:*",
1515
"@bunny.net/database-shell": "workspace:*",
16+
"@bunny.net/sandbox": "workspace:*",
1617
"@bunny.net/database-studio": "workspace:*",
1718
"@libsql/client": "^0.17.0",
1819
"@types/prompts": "^2.4.9",

0 commit comments

Comments
 (0)