feat(sandbox): resources override on create and snapshot restore - #5
Merged
Conversation
Add `resources` ({cpuCores,memoryMb,diskMb,pids}) to SandboxCreateRequest and
SandboxRestoreRequest so SDK clients can size a sandbox and a snapshot resume.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D9WLaq5Lui1Yrk2NTh7wn3
- sandbox.preview(id): list previewable ports + their proxy URLs. - sandbox.createPreviewLink(id, port, opts?): mint a session-less, expiring share link for a running app. - sandbox.previewUrl(id, port, path?): build the authenticated proxy path. - Types: SandboxPreviewPort/Info/ShareLink; SandboxSummary.preview + resources. - Docs: dev-agent build → preview → push example + method reference. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0181JPYLhTDFsGJzRNbh1ujD
- sandbox.setPreview(id, {enabled?, public?}): toggle preview on/off and
public (share links) vs private (login-only), applied live.
- create() accepts previewEnabled / previewPublic.
- preview() / SandboxPreviewInfo now expose enabled + public.
- Docs: setPreview usage + method reference.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0181JPYLhTDFsGJzRNbh1ujD
| async preview(id: string): Promise<SandboxPreviewInfo> { | ||
| const sbx = await this.get(id); | ||
| return ( | ||
| sbx.preview ?? { enabled: true, public: false, ports: [], sharingEnabled: false, blocked: false } |
Comment on lines
14
to
19
| SandboxSessionCommandLogs, | ||
| SandboxSnapshotSummary, | ||
| SandboxSummary, | ||
| SandboxPreviewInfo, | ||
| SandboxPreviewShareLink, | ||
| } from '../types'; |
Comment on lines
213
to
+220
| async restoreSnapshot( | ||
| snapshotId: string, | ||
| data: { name?: string; persist?: boolean; blockNetwork?: boolean } = {}, | ||
| data: { | ||
| name?: string; | ||
| persist?: boolean; | ||
| blockNetwork?: boolean; | ||
| resources?: { cpuCores?: number; memoryMb?: number; diskMb?: number; pids?: number }; | ||
| } = {}, |
Comment on lines
+2463
to
2468
| /** Port preview enabled for this sandbox (default true). */ | ||
| previewEnabled?: boolean; | ||
| /** Allow public (session-less share-link) preview; default false = private. */ | ||
| previewPublic?: boolean; | ||
| /** Override the template's resource limits. */ | ||
| resources?: { cpuCores?: number; memoryMb?: number; diskMb?: number; pids?: number }; |
| // p.enabled / p.public / p.sharingEnabled | ||
| ``` | ||
|
|
||
| When `public` is off, `createPreviewLink` is refused and existing links are revoked; only the authenticated proxy (`previewUrl` / `Open`) works. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
resources({cpuCores,memoryMb,diskMb,pids}) toSandboxCreateRequestandSandboxRestoreRequestso SDK clients can size a sandbox and a snapshot resume.Test
Typecheck clean; mirrors the console-ee API (Cognipeer/console-ee#38).
🤖 Generated with Claude Code
https://claude.ai/code/session_01D9WLaq5Lui1Yrk2NTh7wn3