Skip to content

feat(sdk/node-ts): add createWithProgress for image pull events#589

Open
Eronmmer wants to merge 11 commits intosuperradcompany:mainfrom
Eronmmer:erons/ts-sdk-pull-progress
Open

feat(sdk/node-ts): add createWithProgress for image pull events#589
Eronmmer wants to merge 11 commits intosuperradcompany:mainfrom
Eronmmer:erons/ts-sdk-pull-progress

Conversation

@Eronmmer
Copy link
Copy Markdown
Contributor

@Eronmmer Eronmmer commented Apr 20, 2026

Summary

Adds Sandbox.createWithProgress and Sandbox.createDetachedWithProgress to the Node TS SDK. They return a PullSession that streams image pull events and resolves to the live sandbox.

const session = await Sandbox.createWithProgress({
  name: "my-sb",
  image: "python:3.12-alpine",
  pullPolicy: "always",
});

for await (const ev of session) {
  if (ev.eventType === "layer_download_progress") {
    console.log(`L${ev.layerIndex}: ${ev.downloadedBytes}/${ev.totalBytes ?? "?"}`);
  }
}

const sandbox = await session.result();

PullSession exposes recv(), result(), and Symbol.asyncIterator. The PullEvent shape covers all 14 variants of the Rust PullProgress enum (resolving, resolved, layer_download_, layer_materialize_, stitch_*, complete).

Also clarifies the logLevel JSDoc, 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, and PullEvent in docs/sdk/typescript/sandbox.mdx.

Closes #565

Adds Sandbox.createWithProgress and createDetachedWithProgress, returning
a PullSession you can iterate or recv() off for pull events, then call
result() for the sandbox.
Copilot AI review requested due to automatic review settings April 20, 2026 19:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PullSession async iterator + PullEvent shape, and expose createWithProgress / createDetachedWithProgress from the Node SDK bindings.
  • Update SDK type declarations/exports to include the new session/event types and clarify logLevel semantics.
  • 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 PullProgressPullEvent 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.

Comment thread sdk/node-ts/lib/sandbox.rs Outdated
@Eronmmer
Copy link
Copy Markdown
Contributor Author

Closes #565

Comment thread docs/sdk/typescript/sandbox.mdx Outdated
Comment thread docs/sdk/typescript/sandbox.mdx
Comment thread docs/sdk/typescript/sandbox.mdx
Comment thread docs/sdk/typescript/sandbox.mdx Outdated
Comment thread sdk/node-ts/lib/sandbox.rs Outdated
Narrow with `isinstance`:

```python
from microsandbox import Sandbox, Resolved, LayerDownloadProgress
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Eronmmer
Copy link
Copy Markdown
Contributor Author

@toksdotdev just a heads up that this pr was open before the ts sdk rewrite. there's now a couple of merge conflicts

@Eronmmer Eronmmer requested a review from toksdotdev May 3, 2026 01:44
@toksdotdev
Copy link
Copy Markdown
Member

@Eronmmer could you help resolve the conflicts. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

logLevel in Sandbox.create doesn't log anything

3 participants