Skip to content

packages: sdk reports its own version from the build, not a relative package.json read - #206

Merged
morajabi merged 1 commit into
mainfrom
claude/sdk-version-at-build
Dec 1, 2026
Merged

morajabi merged 1 commit into
mainfrom
claude/sdk-version-at-build

Conversation

@morajabi

Copy link
Copy Markdown
Contributor

This is PLG-04 from the October plugins audit.

packages/sdk/src/sdk/sdk-version.ts read the SDK's version at runtime from ../../package.json. That path is right from src/sdk/, but wrong once the package is built to dist/ or bundled into a plugin, so the reported version could be missing or come from another file.

Change

  • The package builds with plain tsc, which can't inline values, so the build now runs tsc && bun scripts/stamp-version.mjs. The script overwrites dist/sdk/build-version.js with the version from package.json.
  • sdk-version.ts prefers that stamped BUILD_VERSION. Only unbuilt source, used in monorepo dev and by OpenClaw's source-linked tests, falls back to reading package.json.
  • The script uses bun because the MCP Docker image (oven/bun) builds the SDK.

The plugins pick this up only after the next SDK release. They pin @inline-chat/realtime-sdk 0.0.28 from the registry.

Verified

  • bun run test: 348 pass, 100% line coverage on sdk-version.ts. New tests: the version matches package.json; the stamp wins without reading the file; the stamp script's output imports correctly.
  • bun run build: dist/sdk/build-version.js holds "0.0.28". Importing the built sdk-version.js reports 0.0.28, and so does a bun build bundle in a nested folder (inlined as a literal).
  • typecheck and lint pass.

🤖 Generated with Claude Code

…package.json read

The build stamps package.json's version into dist/sdk/build-version.js, so the
published files and bundles made from them (OpenClaw, the Hermes sidecar)
carry it as a literal. Unbuilt source still reads ../../package.json, which is
correct from src/.
@morajabi
morajabi force-pushed the claude/sdk-version-at-build branch from 37bbd1b to 4ea8330 Compare December 1, 2026 10:20
@morajabi
morajabi merged commit 449f9c2 into main Dec 1, 2026
38 of 40 checks passed
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.

1 participant