feat(sdk/node-ts): add createWithProgress for image pull events#589
feat(sdk/node-ts): add createWithProgress for image pull events#589Eronmmer wants to merge 11 commits intosuperradcompany:mainfrom
Conversation
Adds Sandbox.createWithProgress and createDetachedWithProgress, returning a PullSession you can iterate or recv() off for pull events, then call result() for the sandbox.
There was a problem hiding this comment.
Pull request overview
Adds pull-progress streaming support to the Node TypeScript SDK by introducing Sandbox.createWithProgress / Sandbox.createDetachedWithProgress, which return a PullSession async-iterable that yields PullEvents during image pull/materialization and provides result() for the created sandbox. This also clarifies logLevel docs and updates generated TS typings/exports accordingly.
Changes:
- Add
PullSessionasync iterator +PullEventshape, and exposecreateWithProgress/createDetachedWithProgressfrom the Node SDK bindings. - Update SDK type declarations/exports to include the new session/event types and clarify
logLevelsemantics. - Add smoke tests validating pull progress streaming via async iteration and
recv(), plus error/consumption behaviors.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/node-ts/lib/sandbox.rs | Implements PullSession, new create APIs, and Rust→JS PullProgress→PullEvent conversion. |
| sdk/node-ts/lib/types.rs | Adds PullEvent NAPI object and expands log_level documentation. |
| sdk/node-ts/index.mjs | Exports PullSession from the ESM wrapper. |
| sdk/node-ts/index.cjs | Exports PullSession / JsPullSession from the CJS wrapper. |
| sdk/node-ts/index.d.ts | Adds TS declarations for PullSession and PullEvent, plus doc updates. |
| sdk/node-ts/index.d.cts | Mirrors TS declarations for CJS types, including PullSession / PullEvent. |
| sdk/node-ts/tests/smoke.test.ts | Adds integration tests validating pull-progress event streaming and result() behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Closes #565 |
| Narrow with `isinstance`: | ||
|
|
||
| ```python | ||
| from microsandbox import Sandbox, Resolved, LayerDownloadProgress |
There was a problem hiding this comment.
huh. can you confirm that an enum isn't emitted for py? per this line, it reads to me as though each of the variants are dedicated type, which i'd hope not to be so 🤔
There was a problem hiding this comment.
Confirmed. no enum. Each variant is a frozen dataclass; PullProgress at events.py:101 is just Resolving | Resolved | ... (a union alias). that's how the Python SDK already did it
|
@toksdotdev just a heads up that this pr was open before the ts sdk rewrite. there's now a couple of merge conflicts |
|
@Eronmmer could you help resolve the conflicts. thanks. |
Summary
Adds
Sandbox.createWithProgressandSandbox.createDetachedWithProgressto the Node TS SDK. They return aPullSessionthat streams image pull events and resolves to the live sandbox.PullSessionexposesrecv(), result(), andSymbol.asyncIterator. ThePullEventshape covers all 14 variants of the RustPullProgressenum (resolving, resolved, layer_download_, layer_materialize_, stitch_*, complete).Also clarifies the
logLevelJSDoc, since that field was the usual source of confusion: it controls the msb supervisor's own stderr, not anything the SDK surfaces.Docs: added reference entries for
createWithProgress,createDetachedWithProgress,PullSession, andPullEventindocs/sdk/typescript/sandbox.mdx.Closes #565