Skip to content

feat: Cross-Language SDK — Phases 2-4 + gRPC debt fix + dogfooding#39

Open
bkrabach wants to merge 1 commit intomainfrom
dev/cross-language-sdk-v2
Open

feat: Cross-Language SDK — Phases 2-4 + gRPC debt fix + dogfooding#39
bkrabach wants to merge 1 commit intomainfrom
dev/cross-language-sdk-v2

Conversation

@bkrabach
Copy link
Collaborator

@bkrabach bkrabach commented Mar 7, 2026

Summary

Single squash of all Cross-Language SDK work (Phases 2-4), gRPC Phase 2 debt resolution, and integration dogfooding. 124 files changed, ~32,800 additions.

Phase 2: TypeScript/Napi-RS Bindings

  • bindings/node/ — 4 kernel classes (AmplifierSession, Coordinator, HookRegistry, CancellationToken)
  • JsToolBridge for TypeScript module authoring
  • 6 enums + 5 typed struct interfaces + .d.ts auto-generation
  • 64 Vitest tests across 9 test files
  • CI: separate node-tests job with actions/setup-node@v4
  • Dependency upgrades: pyo3 0.28.1→0.28.2 (HIGH severity fix), wasmtime 29→42 (8 Dependabot alerts cleared)

gRPC Phase 2 Debt Fix

  • 5 proto optional field additions (backward-compatible wire change)
  • Full bidirectional conversions: Role, Message (all 7 ContentBlock variants), ChatRequest, ChatResponse, HookResult
  • All bridge fixes: GrpcContextBridge (full message fidelity + provider_name), GrpcProviderBridge::complete(), GrpcOrchestratorBridge (session_id routing)
  • Session holds Arc<Coordinator> with coordinator_shared() for KernelService
  • All 9 KernelService RPCs implemented (was 1 of 9): capabilities, module query, messages, hooks, provider complete, streaming
  • Zero TODO(grpc-v2) markers remain in source

Phase 3: WASM Module Loading

  • wit/amplifier-modules.wit — WIT interfaces for all 6 module types + kernel-service host imports
  • crates/amplifier-guest/ — Rust guest SDK with traits, types, export_*! macros
  • 6 WASM bridges: WasmToolBridge, WasmHookBridge, WasmContextBridge, WasmApprovalBridge, WasmProviderBridge, WasmOrchestratorBridge
  • Shared WasmEngine with Arc<wasmtime::Engine>
  • 6 compiled .wasm test fixtures (echo-tool, deny-hook, memory-context, auto-approve, echo-provider, passthrough-orchestrator)
  • Transport dispatch: load_wasm_* for all 6 module types

Phase 4: Cross-Language Module Resolver

  • module_resolver.rs (1,036 lines) — auto-detect transport from filesystem path
  • Detection pipeline: amplifier.toml.wasm scan + component metadata → Python package → error
  • WASM component metadata parsing for module type detection (self-describing, zero config)
  • PyO3 binding: resolve_module() + load_wasm_from_path()
  • Napi-RS binding: resolveModule() + loadWasmFromPath()
  • loader_dispatch.py WASM/gRPC branches wired to Rust

Dogfooding / Integration

  • _session_init.py routes through loader_dispatch.load_module() (backward compat preserved)
  • load_and_mount_wasm + PyWasmTool for real coordinator WASM mounting
  • Mixed-transport E2E test: native Rust + WASM modules in same session — coordinator is transport-blind
  • Examples: python-wasm-session.py, node-wasm-session.ts, calculator-tool WASM module

Design docs (in docs/plans/)

  • Phase 2 design + implementation plan
  • gRPC debt fix design + implementation plan
  • Phase 3 WASM design + implementation plan
  • Phase 4 module resolver design + implementation plan
  • Dogfooding integration plan

Test Plan

  • 396 Rust lib tests (non-WASM) — 0 failures
  • 34 WASM + resolver lib tests — 0 failures
  • 8 WASM E2E tests (all 6 module types including orchestrator→kernel→tool callback chain)
  • 14 module resolver E2E tests
  • 2 mixed-transport E2E tests (native + WASM in same session)
  • cargo clippy (core + wasm) — 0 warnings
  • cargo check --features wasm — builds clean
  • CI workflow runs

Notes

  • This is a squash of the dev/cross-language-sdk integration branch onto a clean branch from current main
  • All WASM work is behind #[cfg(feature = "wasm")] — zero impact when feature is off
  • Backward compatible: all existing Python module loading works identically

@bkrabach bkrabach force-pushed the dev/cross-language-sdk-v2 branch 2 times, most recently from a4f0190 to 3d98428 Compare March 7, 2026 18:57
TypeScript/Napi-RS bindings (Phase 2):
- 4 kernel classes: AmplifierSession, Coordinator, HookRegistry, CancellationToken
- JsToolBridge for TypeScript module authoring
- 64 Vitest tests, CI split into separate node-tests job

gRPC Phase 2 debt fix:
- 5 proto optional fields, full bidirectional conversions
- All 9 KernelService RPCs implemented (was 1 of 9)
- Session holds Arc<Coordinator> with coordinator_shared()

WASM module loading (Phase 3):
- 6 WASM bridges via Component Model (Tool, Hook, Context, Approval, Provider, Orchestrator)
- amplifier-guest crate with export macros
- WIT interface definitions for all 6 module types
- 6 test fixture .wasm binaries

Cross-language module resolver (Phase 4):
- Auto-detect transport: .wasm → WASM, amplifier.toml → gRPC, __init__.py → Python
- WASM component metadata parsing for module type detection
- PyO3 + Napi-RS bindings for resolver
- loader_dispatch.py wired to Rust

Dogfooding:
- _session_init.py routes through loader_dispatch
- Mixed-transport E2E: native + WASM modules in same session
- Python and TypeScript WASM session examples

Security fixes:
- pyo3 0.28.1 → 0.28.2 (HIGH severity)
- wasmtime 29 → 42 (8 alerts cleared)

🤖 Generated with Amplifier

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
@bkrabach bkrabach force-pushed the dev/cross-language-sdk-v2 branch from 3d98428 to 38ba778 Compare March 7, 2026 19:44
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