Introduce hero_livekit_sdk crate (shared OpenRPC client) #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The Hero multi-crate standard (
hero_crates_best_practices_check) requires every service to expose a dedicated SDK crate containing theopenrpc_client!macro invocation. Todayhero_livekit_uiandhero_livekit_exampleseach instantiate their own typed client against the server'sopenrpc.json, duplicating wiring and preventing external consumers from depending on a stable surface.Goals
crates/hero_livekit_sdk/(library crate).openrpc_client!("../hero_livekit_server/src/livekit/core/openrpc.json")invocation intosrc/lib.rs.hero_livekit_sdkto the workspaceCargo.toml.hero_livekit_uiandhero_livekit_examplesto depend on the SDK rather than generate their own clients.cargo build -p hero_livekit_sdk).Related skills:
hero_crates_best_practices_check,herolib_openrpc.Superset context in #15 — OSchema layout alignment affects the shape of this SDK crate (schemas at workspace root,
.client_crate_dir("../hero_livekit_sdk")codegen flow,openrpc.jsonrelocated next tomain.rs). Implement this issue alongside or after #15.Implementation Spec for Issue #3
Objective
Consolidate the duplicated
openrpc_client!macro invocations scattered across hero_livekit_ui, hero_livekit_examples, and hero_livekit_rhai into the existing hero_livekit_sdk crate, so consumers import from a single shared SDK rather than each generating their own typed client.Current State
The hero_livekit_sdk crate already exists with an OSIS-generated client (osis_client_generated.rs) for WASM/HTTP consumers. However, hero_livekit_ui, hero_livekit_examples, and hero_livekit_rhai each still invoke
openrpc_client!independently, duplicating the typed socket-based client.Approach: Strategy A (additive)
Add an
openrpcfeature to the SDK that houses theopenrpc_client!macro invocation alongside the existing OSIS client. Consumers switch to importing from the SDK. Zero logic changes at call sites.Files to Modify/Create
crates/hero_livekit_sdk/Cargo.toml- Add openrpc feature with optional depscrates/hero_livekit_sdk/src/openrpc.rs- New: openrpc_client! invocationcrates/hero_livekit_sdk/src/lib.rs- Add cfg-gated openrpc modulecrates/hero_livekit_ui/Cargo.toml- Replace hero_rpc_derive/hero_rpc_openrpc with hero_livekit_sdkcrates/hero_livekit_ui/src/main.rs- Replace macro call with SDK importcrates/hero_livekit_examples/Cargo.toml- Same migrationcrates/hero_livekit_examples/examples/basic_usage.rs- Replace macro call with SDK importcrates/hero_livekit_examples/examples/health.rs- Replace macro call with SDK importcrates/hero_livekit_rhai/Cargo.toml- Same migrationcrates/hero_livekit_rhai/src/client.rs- Replace macro call with SDK importImplementation Plan
Step 1: Add openrpc feature to SDK crate
Files:
crates/hero_livekit_sdk/Cargo.toml,crates/hero_livekit_sdk/src/lib.rs,crates/hero_livekit_sdk/src/openrpc.rsDependencies: none
Step 2: Migrate hero_livekit_ui to use SDK
Files:
crates/hero_livekit_ui/Cargo.toml,crates/hero_livekit_ui/src/main.rsuse hero_livekit_sdk::openrpc::*;Dependencies: Step 1
Step 3: Migrate hero_livekit_examples to use SDK
Files:
crates/hero_livekit_examples/Cargo.toml, examples/*.rsDependencies: Step 1
Step 4: Migrate hero_livekit_rhai to use SDK
Files:
crates/hero_livekit_rhai/Cargo.toml,crates/hero_livekit_rhai/src/client.rsDependencies: Step 1
Acceptance Criteria
Notes
Test Results
All workspace tests pass after migrating UI, examples, and rhai crates to use the shared SDK openrpc module.
Implementation Summary
Changes Made
New file:
crates/hero_livekit_sdk/src/openrpc.rs— Centralizedopenrpc_client!macro invocation, generating theLiveKitClientand all associated types fromopenrpc.jsonModified files:
crates/hero_livekit_sdk/src/lib.rs— Addedpub mod openrpc;to expose the new modulecrates/hero_livekit_ui/Cargo.toml— Replacedhero_rpc_derivedependency withhero_livekit_sdkcrates/hero_livekit_ui/src/main.rs— Replaced inlineopenrpc_client!macro withuse hero_livekit_sdk::openrpc::*;crates/hero_livekit_examples/Cargo.toml— Replacedhero_rpc_derivedependency withhero_livekit_sdkcrates/hero_livekit_examples/examples/basic_usage.rs— Replaced inline macro with SDK importcrates/hero_livekit_examples/examples/health.rs— Replaced inline macro with SDK importcrates/hero_livekit_rhai/Cargo.toml— Replacedhero_rpc_derivedependency withhero_livekit_sdkcrates/hero_livekit_rhai/src/client.rs— Replaced inline macro withpub use hero_livekit_sdk::openrpc::*;(pub for re-export to bindings.rs)Result
All 34 tests pass. The
openrpc_client!macro is now invoked in exactly one place (the SDK), and all consumers import fromhero_livekit_sdk::openrpc.Pull request opened: #26
This PR implements the changes discussed in this issue.