Skip to content

feat(ts-sdk): add app-first TypeScript SDK and native runtime packaging#98

Merged
Lythaeon merged 25 commits intomainfrom
feat/ts-sdk-runtime-config
Apr 12, 2026
Merged

feat(ts-sdk): add app-first TypeScript SDK and native runtime packaging#98
Lythaeon merged 25 commits intomainfrom
feat/ts-sdk-runtime-config

Conversation

@Lythaeon
Copy link
Copy Markdown
Owner

Description

Adds the first production-shaped TypeScript SOF SDK and the native runtime host flow it depends on.

This PR turns the TS SDK into a real app-facing surface instead of a partial wrapper: users can author apps with new App({...}), new Plugin({...}), and await app.run() while ingress, fan-in, replay, gossip, direct shreds, and the hot runtime path remain in Rust.

It also finalizes npm packaging/release flow, adds CI coverage, and adds GitBook SDK docs so the branch is coherent from runtime to distribution to documentation.

Changes

Detailed list of what changed:

  • sdks/typescript/src/**: added the TypeScript SDK surface for app authoring, runtime config, runtime policy, derived-state config, result/error helpers, package exports, examples, and tests.
  • sdks/typescript/src/app.ts: added the constructor-first App / Plugin API, typed ingress/fan-in/runtime config, native runtime host handoff, installed native package resolution, and internal worker launching.
  • sdks/typescript/src/runtime/runtime-extension-stdio.ts: added the stdio worker bridge and hard-blocked worker stdout misuse so callback logging cannot corrupt the protocol.
  • sdks/typescript/src/index.ts, sdks/typescript/src/runtime.ts, sdks/typescript/src/runtime/app-internal.ts: narrowed the public API so worker/runtime internals and old try* authoring entry points do not leak from the main package surface.
  • sdks/typescript/package.json, pnpm-workspace.yaml, pnpm-lock.yaml, sdks/typescript/native/*/package.json: migrated the SDK to pnpm, oxlint, biome, minified build output, per-platform native packages, and release metadata validation.
  • sdks/typescript/scripts/build-native-host.mjs, sdks/typescript/scripts/check-release-metadata.mjs: added native host packaging and release metadata checks.
  • crates/sof-observer/src/bin/sof_ts_runtime_host.rs: added the native runtime host used by @sof/sdk, including websocket/gRPC provider ingress, mixed provider+raw runtime support, plugin worker bridging, gossip mode, direct shred ingress, and Linux kernel-bypass integration.
  • crates/sof-observer/src/bin/sof_ts_runtime_host/af_xdp.rs: added Linux AF_XDP support for native SDK runtime-host direct-shred ingress.
  • crates/sof-observer/src/runtime.rs: added the combined raw-ingress plus provider-stream runtime path required by the SDK handoff.
  • .github/workflows/ci.yml: added a dedicated TypeScript SDK CI job.
  • .github/workflows/release-typescript-sdk.yml: added npm release automation for native packages first, then @sof/sdk.
  • docs/gitbook/**, docs/README.md, sdks/typescript/README.md, sdks/typescript/RELEASING.md: documented the SDK, runtime host/packaging model, release flow, and added an SDK section to GitBook with navbar support.
  • .gitignore: ignores generated native package vendor/ binaries.

For slice-related changes, include:

  • Affected slices: sdks/typescript, crates/sof-observer runtime/bootstrap path, docs/GitBook, CI/release automation.
  • Cross-slice communication changes (if any) and why: the TS SDK now hands off to the Rust native runtime host through a versioned temp config + worker stdio bridge so Rust keeps runtime-critical ownership while TS owns app composition and callbacks.
  • Migration requirements (if any): TS consumers should use the new constructor-first API and the new public package surface. Old wrapper-style APIs and public worker internals are intentionally no longer exposed from @sof/sdk.

Motivation

Business motivation:

  • make SOF usable from TypeScript without forcing users to think about the Rust implementation details
  • publish a distributable npm package with an explicit native runtime story
  • reduce developer pain for building simple observer/runtime apps

Technical motivation:

  • keep ingest/runtime-critical work in Rust while exposing an easier application surface in TS
  • unify runtime config, policy, and derived-state config behind typed TS APIs
  • remove wrapper-side ingress logic drift and delegate execution to the existing Rust runtime model
  • make packaging, CI, docs, and release flow production-shaped instead of ad hoc

Alternative approaches considered:

  • building Rust during npm install: rejected as the primary path because it makes installs slower and more fragile
  • recreating websocket/provider loops in TS: rejected because it drifts from SOF runtime behavior and loses the thin-wrapper goal
  • exposing worker/runtime internals publicly: rejected because app authors should not think about those details

Scope and impact

  • Affected slices: TypeScript SDK, observer runtime host/bootstrap, docs site, CI, npm release automation
  • Data/API changes: adds @sof/sdk public API and native runtime-host config handoff; narrows old public wrapper/internal exports
  • Backward compatibility: new feature area; some earlier branch-local TS wrapper exports were intentionally removed before release to keep the public surface clean
  • Performance impact: positive/neutral; runtime work stays in Rust and TS no longer runs its own provider loops
  • Security impact: improved by reducing public internals, preventing stdout protocol corruption, and avoiding full parent env serialization into runtime-host config

Testing

  • Unit tests
  • Integration tests
  • Manual verification
  • Performance checks (if applicable)
  • Security checks (if applicable)

Commands/results:

cargo check -p sof --features provider-grpc,provider-websocket,gossip-bootstrap,kernel-bypass --bin sof_ts_runtime_host
cargo clippy -p sof --features provider-grpc,provider-websocket,gossip-bootstrap,kernel-bypass --bin sof_ts_runtime_host --tests -- -D warnings
cargo test -p sof --features provider-grpc,provider-websocket,gossip-bootstrap,kernel-bypass --bin sof_ts_runtime_host
pnpm install --frozen-lockfile
pnpm --dir sdks/typescript run check
npm --prefix docs/gitbook run build
pnpm --dir sdks/typescript/native/linux-x64 publish --dry-run --access public --no-git-checks
pnpm --dir sdks/typescript publish --dry-run --access public --no-git-checks

Manual verification:

  • verified the minimal TypeScript websocket app against a live websocket endpoint in ../sof-arb-minimal
  • confirmed app.run() executes the Rust sof_ts_runtime_host underneath via wrapper capture of the runtime-host handoff

Related issues and documentation

  • Fixes:
  • Related:
  • Architecture docs: docs/architecture/README.md
  • Relevant ARD/ADR: docs/architecture/adr/0011-plugin-config-and-lifecycle-hooks.md, docs/architecture/adr/0013-runtime-delivery-profiles.md, docs/architecture/ard/0010-simplification-without-capability-regression.md
  • Operations/runbook updates: GitBook SDK section added under docs/gitbook/sdk/; npm release process documented in sdks/typescript/RELEASING.md

Reviewer checklist

  • Code follows project standards and architecture constraints
  • Slice boundaries are respected (docs/architecture/ard/0003-slice-dependency-contracts.md)
  • Tests added/updated and passing
  • Documentation updated (README/docs/operations as needed)
  • No undocumented breaking change
  • Performance trade-offs documented where relevant
  • Security considerations addressed where relevant

Additional notes

Final audit result:

  • no blocking findings on the branch
  • remaining cross-platform proof for native package binaries depends on their matching GitHub runners/toolchains, which is expected and is why the release workflow builds per platform instead of trying to cross-build everything from one Linux host

Celestial added 25 commits April 11, 2026 11:52
@Lythaeon Lythaeon merged commit 2cfb6ee into main Apr 12, 2026
3 checks passed
@Lythaeon Lythaeon deleted the feat/ts-sdk-runtime-config branch April 12, 2026 07:04
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