Skip to content

refactor: bump nodes-sdk-alpha and refactor image commands#262

Merged
sigmachirality merged 11 commits into
mainfrom
indent-2026-05-15-bump-nodes-sdk-alpha-29
May 21, 2026
Merged

refactor: bump nodes-sdk-alpha and refactor image commands#262
sigmachirality merged 11 commits into
mainfrom
indent-2026-05-15-bump-nodes-sdk-alpha-29

Conversation

@sigmachirality
Copy link
Copy Markdown
Member

@sigmachirality sigmachirality commented May 20, 2026

Summary

Get the image commands off the now-blocked /v1/vms/images and /v2/images routes onto /preview/v2/images, and refactor along the way so sf images, sf nodes images, and sf vm images share one implementation.

Commits

  1. Bump @sfcompute/nodes-sdk-alpha 0.1.0-alpha.270.1.0-alpha.31 and migrate the sf nodes images upload/list/show calls onto /preview/v2/images. The new SDK already targets that prefix; list now requires { workspace } and list rows expose id instead of image_id.
  2. Migrate the remaining image commands (sf images list/upload/get) from /v2/images to /preview/v2/images via the typed apiClient. Field renamed sha256_hashsha256 to match the new response shape.
  3. Refactor:
    • src/lib/images/* — expose createGet / createList / createUpload / createImagesCommand factories.
    • sf nodes images and sf vm images now instantiate the shared factory instead of carrying duplicate implementations (deletes ~780 lines).
    • sf nodes create converted to a createCreateCommand() factory for consistency.

Breaking changes for --json consumers

  • sf [nodes] images list --json rows now use id (was image_id).
  • sf nodes images list is now scoped to the caller's default workspace, like sf images list already was. Public images under sfc:workspace:sfcompute:public no longer appear in the default listing.

Out of scope

src/schema.ts (openapi-typescript output) is regenerated as part of commit 1 since the typed apiClient calls in sf images need the new /preview/v2/images paths. The regen surfaces a handful of pre-existing TS errors in scale/, contracts/, and posthog.ts that are unrelated to this PR — left for a follow-up.

Testing

  • bun install — clean lockfile.
  • bun run lint — passes (same 9 pre-existing warnings).
  • bun run check — pre-existing failures unrelated to this PR (see "Out of scope").

sigmachirality and others added 2 commits May 20, 2026 20:58
The new SDK's `client.vms.images.list({ workspace })` hits
/preview/v2/images and now requires the workspace parameter; the list
response also renamed `image_id` to `id`.

Switches `sf nodes images upload` from the legacy /v1/vms/images
endpoints (vmorch) to /preview/v2/images (market-api), matching the
pattern used in src/lib/images/upload.ts.

`sf nodes images list` now uses the SDK directly (which targets
/preview/v2/images). `sf nodes images show` is migrated in the
follow-up commit alongside the other v2/images callers.

CLI surface (commands, flags, output) is unchanged.

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
HAProxy blocks external /v2/* in production (sfcompute/sfcompute#5494),
so any caller hitting /v2/images gets a 404. Migrates the remaining
image commands off /v2/images:

- `sf images list`: use Stainless SDK `client.vms.images.list({ workspace })`
  (hits /preview/v2/images automatically).
- `sf images upload`: swap raw fetch URLs from /v2/images,
  /v2/images/{id}/parts, /v2/images/{id}/complete to /preview/v2/images*.
- `sf images get` and `sf nodes images show`: use SDK
  `client.vms.images.get(id)` for the lookup; download URL fetch goes
  to /preview/v2/images/{id}/download via raw fetch since the SDK has
  no download method. SDK field rename sha256_hash -> sha256.

CLI surface (commands, flags, output) is unchanged.

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented May 20, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  src/lib/scale/create.tsx  98% smaller
  src/lib/images/upload.ts  95% smaller
  src/lib/images/list.ts  88% smaller
  src/lib/images/get.tsx  78% smaller
  src/lib/images/utils.ts  39% smaller
  src/index.ts  39% smaller
  src/lib/vm/index.ts  30% smaller
  src/lib/images/index.ts  29% smaller
  src/lib/posthog.ts  6% smaller
  bun.lock Unsupported file format
  package.json  0% smaller
  src/lib/contracts/index.tsx  0% smaller
  src/lib/nodes/image/index.ts  0% smaller
  src/lib/nodes/image/list.tsx  0% smaller
  src/lib/nodes/image/show.tsx  0% smaller
  src/lib/nodes/image/upload.ts  0% smaller
  src/lib/nodes/index.ts  0% smaller
  src/lib/scale/list.tsx  0% smaller
  src/lib/scale/update.tsx  0% smaller
  src/lib/scale/utils.ts  0% smaller
  src/schema.ts Unsupported file format

@indent
Copy link
Copy Markdown
Contributor

indent Bot commented May 20, 2026

PR Summary

Bumps @sfcompute/nodes-sdk-alpha from 0.1.0-alpha.27 to 0.1.0-alpha.31, migrates every image command off /v1/vms/images* and /v2/images* onto /preview/v2/images* (HAProxy now blocks external /v2/* in production), and refactors sf images, sf nodes images, and sf vm images to share a single zero-arg command-factory implementation. The InfiniBand --enable-infiniband work is scoped out to its own branch (indent-2026-05-15-enable-infiniband-flag) and is no longer part of this PR. The shared factory contains an intentional breaking change: sf nodes images list --json and sf vm images list --json now print the envelope object ({ data, has_more, object, cursor }) instead of a bare array — scripts using ... --json | jq '.[]' must switch to ... | jq '.data[]'.

  • Upgrade @sfcompute/nodes-sdk-alpha to 0.1.0-alpha.31 in package.json / bun.lock.
  • Migrate sf images list/get/upload, sf nodes images list/show/upload, and sf nodes images upload onto /preview/v2/images*; propagate SDK field renames image_idid and sha256_hashsha256.
  • Convert src/lib/images/{get,list,upload,index}.ts to factory functions (createGet, createList, createUpload, createImagesCommand) backed by the typed apiClient against /preview/v2/*; delete the duplicate src/lib/nodes/image/{list,show,upload,index}.ts implementations.
  • createImagesCommand() is zero-arg: it always registers the os and image aliases, always references sf images … in help text and "Next steps", and always prints the envelope shape for list --json. sf nodes and sf vm mount the same factory directly.
  • Regenerate src/schema.ts (adds revoked upload_status, new preview endpoints, restructured { error: { type, message } } envelope) and update all call sites: /v0/me/v1/account/me (src/index.ts, src/lib/images/utils.ts, src/lib/posthog.ts), switch the feature-flag check to raw fetch against /v2/feature_flags/{id} (still served externally per HAProxy config), and read error?.error?.message in src/lib/contracts/index.tsx and src/lib/scale/{create,list,update,utils}.

Issues

1 potential issue found:

  • Latent: sf nodes images list now scopes to the caller's default workspace, so public sfcompute-provided images (workspace sfc:workspace:sfcompute:public) no longer appear in the default listing — discoverability regression for users who relied on it. → Autofix
5 issues already resolved
  • sf nodes images list --json is now a double-breaking JSON output change: previously the output was JSON.stringify(images, null, 2) (a bare array), but the shared factory in this PR prints the full envelope { data: [...], has_more, object, cursor }, AND each item exposes id instead of image_id. Scripts piping ... --json | jq '.[].image_id' will silently return null or fail. (fixed by commit 78f3d98)
  • Nit: under sf nodes images --help and sf vm images --help, the help text/examples (from the shared factory) all reference sf images list/get/upload instead of the parent command path the user actually invoked, which is confusing for users discovering the commands under the nodes/vm trees. (fixed by commit 78f3d98)
  • Functional regression: the os alias on sf nodes images (and sf vm images) was dropped when the command was switched to the shared createImagesCommand() factory — users who scripted sf nodes os list or sf vm os list now hit "unknown command". (fixed by commit 78f3d98)
  • Critical: Schema regen in e35a88c dropped /v0/me (replaced by /v1/account/me) and /v2/feature_flags/{feature_flag_id} (no longer in schema), but src/index.ts:92, src/lib/images/utils.ts:9, and src/lib/posthog.ts:43,89 still call them — tsc --noEmit now reports 20 errors and CI's bun run check will fail. (fixed by commit 78f3d98)
  • Nit: sf nodes --help subcommand order changed — create was previously listed third (after list, get) and is now last (after image) because registerCreate(nodes) is awaited after the addCommand chain. Worth restoring the original order since create is one of the most-used subcommands. (fixed by commit 24a37c2)

CI Checks

All CI checks passed on db73844.


⚡ Autofix All Issues

Comment thread src/lib/nodes/image/list.tsx Outdated

const spinner = ora("Fetching images...").start();
const { data: images } = await client.vms.images.list();
const { data: images } = await client.vms.images.list({ workspace });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Latent: public images no longer listed by default. The alpha.31 SDK requires a workspace, and the new call scopes results to the caller's default workspace only. The SDK docs note that to see sfc-provided public images you must pass sfc:workspace:sfcompute:public explicitly. Before this PR, client.vms.images.list() had no workspace arg — worth confirming whether the previous behavior surfaced public images; if it did, this is a UX regression. Consider adding a --public flag (or a second list call against the public workspace) so users can still discover the prebuilt images. Trigger: any user invoking sf nodes images list without their own uploads, or trying to find a public image id to pass to sf nodes create --image.

@indent indent Bot force-pushed the indent-2026-05-15-bump-nodes-sdk-alpha-29 branch from 8a6043d to 0c33025 Compare May 20, 2026 21:11
Comment thread src/lib/nodes/index.ts Outdated
@indent indent Bot force-pushed the indent-2026-05-15-bump-nodes-sdk-alpha-29 branch from 0c33025 to 4c1dd5f Compare May 20, 2026 22:02
indent[bot]

This comment was marked as resolved.

@indent indent Bot force-pushed the indent-2026-05-15-bump-nodes-sdk-alpha-29 branch from 4c1dd5f to 24a37c2 Compare May 20, 2026 22:04
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

Convert the get/list/upload subcommands into createGet/createList/
createUpload factories and add a top-level createImagesCommand so the
same images CLI surface can be reused under sf nodes images and sf vm
images. Swap the remaining nodesClient and raw fetch calls for the
typed apiClient against preview/v2, and regenerate schema types
(adds revoked upload_status, etc.).
@sigmachirality sigmachirality force-pushed the indent-2026-05-15-bump-nodes-sdk-alpha-29 branch from 24a37c2 to f60fb3e Compare May 20, 2026 23:03
@sigmachirality sigmachirality changed the title Bump nodes-sdk-alpha to 0.1.0-alpha.31 and migrate image commands to /preview/v2/images refactor: bump nodes-sdk-alpha and refactor image commands May 20, 2026
Comment thread src/lib/images/index.ts
Comment thread src/lib/images/list.ts
sigmachirality and others added 2 commits May 20, 2026 16:35
Remove the duplicate image command implementations under nodes/image/
and instead instantiate the shared createImagesCommand factory from
sf images. sf nodes images and sf vm images now stay in sync with
sf images automatically.
Generated file drifted from biome's formatting output after the openapi
regen in 2c94afc; running `biome format --write` brings it back in line
and lets `biome ci .` pass on CI.

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
@sigmachirality sigmachirality force-pushed the indent-2026-05-15-bump-nodes-sdk-alpha-29 branch from 78f3d98 to 81109ce Compare May 20, 2026 23:35
Three regressions reported by the AI reviewer on the shared
image-command factory:
- Re-add the `os` alias on `sf nodes images` and `sf vm images` so
  scripts using `sf nodes os list` / `sf vm os list` keep working.
- `sf nodes images list --json` / `sf vm images list --json` print
  the bare image array again (new `sf images list --json` keeps the
  envelope shape); controlled by a new `legacyJsonShape` factory
  option.
- Help text, "next steps", and overflow messages reference the actual
  parent invocation path (`sf nodes images …` / `sf vm images …`) via
  a new `parentPath` factory option.
Schema regen in e35a88c dropped /v0/me. The typed equivalent is
getAccountMe at /v1/account/me, with the same `id` field.
The regenerated error response types wrap the payload as
`{ error: { type, message } }`, so callers need `error?.error?.message`.
The endpoint is live in market-api (v2_routes.rs:593) but its handler
lacks a `#[utoipa::path]` macro, so it's absent from the regenerated
OpenAPI schema. Drop the typed client for this call and use fetch
directly — matches the pattern in sfcompute.com's feature-flags
provider.
@sigmachirality sigmachirality force-pushed the indent-2026-05-15-bump-nodes-sdk-alpha-29 branch from 81109ce to 2e1124c Compare May 20, 2026 23:37
Collapse the shared images factory back to a zero-arg function:

- always alias `os` and reference `sf images` in help/next-steps text
- always print the envelope shape for `list --json`
- delete the unused `sf nodes image` wrapper

BREAKING CHANGE: `sf nodes images list --json` and `sf vm images list --json`
now print the envelope object instead of a bare array. Scripts using
`... --json | jq '.[]'` need to switch to `... | jq '.data[]'`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sigmachirality
Copy link
Copy Markdown
Member Author

@indent fix biome and commit style: fix biome

Generated with [Indent](https://indent.com)
Co-Authored-By: Indent <noreply@indent.com>
@indent indent Bot force-pushed the indent-2026-05-15-bump-nodes-sdk-alpha-29 branch from d7ebf2b to db73844 Compare May 20, 2026 23:59
@indent
Copy link
Copy Markdown
Contributor

indent Bot commented May 20, 2026

Amended d7ebf2bdb73844 with the fix: biome message style.

Generated by Indent - session link

@sigmachirality sigmachirality self-assigned this May 21, 2026
@sigmachirality sigmachirality merged commit a489d66 into main May 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant