feat(packages/sandbox): sandbox sdk poc#101
Conversation
🦋 Changeset detectedLatest commit: 68a89ea The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@greptile-apps review |
Greptile SummaryThis PR introduces
Confidence Score: 4/5Safe to merge after adding a duplicate-name guard in sandbox create; all other previously flagged issues have been addressed. The sandbox create CLI command has no check for whether the requested name is already registered in the config. Running it twice with the same name provisions a new MC app, overwrites the config entry, and leaves the old app running with no CLI handle. Because sandboxes are billable infrastructure, this is a concrete defect on the changed code path rather than a theoretical risk. packages/cli/src/commands/sandbox/create.ts — needs a pre-flight check against the config before calling Sandbox.create(). Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant CLI as bunny sandbox create
participant SDK as Sandbox.create()
participant MC as Magic Containers API
participant SSH as SshTransport
CLI->>SDK: "create({ name, region, apiKey })"
SDK->>MC: POST /apps (createApp)
MC-->>SDK: appId
SDK->>MC: "poll GET /apps/{appId} (waitForSshHost)"
MC-->>SDK: anycast SSH host
SDK->>SSH: waitUntilReachable(120s)
SSH-->>SDK: connected
loop options.ports
SDK->>MC: "POST /apps/{appId}/containers/{id}/endpoints"
MC-->>SDK: endpointId
SDK->>MC: "poll GET /apps/{appId}/endpoints (waitForPublicHost)"
MC-->>SDK: publicHost
end
SDK-->>CLI: Sandbox instance
CLI->>CLI: toHandle() + disconnect()
CLI->>CLI: setSandbox(name, handle) to config file
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant CLI as bunny sandbox create
participant SDK as Sandbox.create()
participant MC as Magic Containers API
participant SSH as SshTransport
CLI->>SDK: "create({ name, region, apiKey })"
SDK->>MC: POST /apps (createApp)
MC-->>SDK: appId
SDK->>MC: "poll GET /apps/{appId} (waitForSshHost)"
MC-->>SDK: anycast SSH host
SDK->>SSH: waitUntilReachable(120s)
SSH-->>SDK: connected
loop options.ports
SDK->>MC: "POST /apps/{appId}/containers/{id}/endpoints"
MC-->>SDK: endpointId
SDK->>MC: "poll GET /apps/{appId}/endpoints (waitForPublicHost)"
MC-->>SDK: publicHost
end
SDK-->>CLI: Sandbox instance
CLI->>CLI: toHandle() + disconnect()
CLI->>CLI: setSandbox(name, handle) to config file
Reviews (4): Last reviewed commit: "fmt" | Re-trigger Greptile |
- validate env var names before shell interpolation (block injection) - reuse a single SFTP channel instead of opening one per file op - delete the app if exposePort fails during create() to avoid orphans - fast-fail waitForPublicHost on terminal app states - drop the unreachable throw lastErr in withRegistryRetry
68067da to
bfb149c
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bfb149c111
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- readFile returns null on SFTP NO_SUCH_FILE (numeric 2), not just ENOENT - resolve the MC client lazily so fromHandle reconnects need no API key - make port exposure idempotent and treat a slow host assignment as pending, not a failed create - thread the abort signal through the SSH reachability wait - ship @types/ssh2 as a runtime dependency for downstream consumers - settle detached commands on stream error instead of leaving wait() hanging
No description provided.