feat(scripting): add nu_service.nu + hero_do_hero_livekit Rhai binary #17

Merged
ashraf merged 2 commits from development_nu_service_rhai into main 2026-04-22 14:35:12 +00:00
Member

Summary

  • scripts/nu_service.nu — two-action Nushell module (hero_livekit_server + hero_livekit_ui) delegating to hero_proc. Subcommands install/start/stop/status with --root/--reset.
  • crates/hero_livekit_rhai — new workspace crate producing the hero_do_hero_livekit binary. Manual Rhai bindings (no macros) expose the full LiveKitService OpenRPC surface plus Room/Participant/AccessToken custom types. Binary injects SCRIPT_DIR/SCRIPT_FILE/ARGS into the Rhai scope per rhai_bindings_cmd_path.
  • Five example .rhai scripts: 01_status, 02_list_rooms, 03_create_delete_room, 04_issue_token, 05_full_lifecycle.
  • Per-crate Makefile + root build-rhai/install-rhai/run-rhai-example passthrough targets.
  • README gains Service lifecycle via hero_proc and Scripting (Rhai) sections.

Closes #12

Changes

Nushell service module

  • scripts/nu_service.nu — follows the nu_service two-action skill template. lk-backend is in SVX_BINARIES (copied by install) but not in SVX_ACTIONS — it is supervised by hero_livekit_server, not run standalone under hero_proc.

New crate crates/hero_livekit_rhai

  • Cargo.toml — library + [[bin]] hero_do_hero_livekit with required-features = ["rhai"]. rhai = { version = "1", features = ["sync"], optional = true }.
  • src/client.rsLiveKitRhaiClient owning a tokio Runtime + Arc<LiveKitClient> so Rhai (sync) can call blocking methods. default_socket_path() cascades $HERO_SOCKET_DIR~/hero/var/sockets/hero_livekit/rpc.sock.
  • src/bindings.rs — manual register_fn/register_type_with_name/register_get for every OpenRPC method (install/configure/start/stop/restart/status/create_room/list_rooms/delete_room/list_participants/remove_participant/issue_token) and for Room/Participant/AccessToken.
  • src/lib.rs — public register(&mut Engine) + create_engine() -> Engine.
  • src/main.rs — CLI entry: <script.rhai> [args...], <directory>, -i stdin, --run <name>, --version, --help. Thread-local SCRIPT_DIR + run("other.rhai") helper.
  • buildenv.shPROJECT_NAME/BINARIES/ALL_FEATURES/VERSION/PATCHLEVEL.

Examples

  • examples/rhai/01_status.rhai
  • examples/rhai/02_list_rooms.rhai
  • examples/rhai/03_create_delete_room.rhai
  • examples/rhai/04_issue_token.rhai
  • examples/rhai/05_full_lifecycle.rhai
  • All are rhai_check-compliant (no try/catch, no decorative headers).

Makefiles

  • crates/hero_livekit_rhai/Makefilebuild, build-do, build-release, install, installdev, check, clippy, test, run-examples, example EXAMPLE=<file>.
  • Root Makefilebuild-rhai, install-rhai, run-rhai-example passthroughs; added to .PHONY.

Docs

  • README.md — new Service lifecycle via hero_proc and Scripting (Rhai) sections.

Test Results

  • cargo check --workspace — PASS
  • cargo test --workspace — 8 passed, 0 failed, 3 ignored (pre-existing rustdoc examples)
  • Runtime validation (not part of cargo test):
    • nu scripts/nu_service.nu status requires a running hero_proc.
    • hero_do_hero_livekit examples/rhai/01_status.rhai requires hero_livekit_server on $HERO_SOCKET_DIR/hero_livekit/rpc.sock.

Out of scope

  • .claude/ + CLAUDE.md deliverables from the original issue were dropped per the maintainer's follow-up comment.
  • Per-entity auto-CRUD (room.set, participant.get, etc.) is not bound — the generated LiveKitClient exposes only the 12 LiveKitService.* methods today. If CRUD surfaces in future codegen, the Rhai layer can be extended in a follow-up.
## Summary - `scripts/nu_service.nu` — two-action Nushell module (`hero_livekit_server` + `hero_livekit_ui`) delegating to `hero_proc`. Subcommands `install`/`start`/`stop`/`status` with `--root`/`--reset`. - `crates/hero_livekit_rhai` — new workspace crate producing the `hero_do_hero_livekit` binary. Manual Rhai bindings (no macros) expose the full `LiveKitService` OpenRPC surface plus `Room`/`Participant`/`AccessToken` custom types. Binary injects `SCRIPT_DIR`/`SCRIPT_FILE`/`ARGS` into the Rhai scope per `rhai_bindings_cmd_path`. - Five example `.rhai` scripts: `01_status`, `02_list_rooms`, `03_create_delete_room`, `04_issue_token`, `05_full_lifecycle`. - Per-crate `Makefile` + root `build-rhai`/`install-rhai`/`run-rhai-example` passthrough targets. - README gains `Service lifecycle via hero_proc` and `Scripting (Rhai)` sections. ## Related Issue Closes https://forge.ourworld.tf/lhumina_code/hero_livekit/issues/12 ## Changes ### Nushell service module - `scripts/nu_service.nu` — follows the `nu_service` two-action skill template. `lk-backend` is in `SVX_BINARIES` (copied by `install`) but not in `SVX_ACTIONS` — it is supervised by `hero_livekit_server`, not run standalone under hero_proc. ### New crate `crates/hero_livekit_rhai` - `Cargo.toml` — library + `[[bin]] hero_do_hero_livekit` with `required-features = ["rhai"]`. `rhai = { version = "1", features = ["sync"], optional = true }`. - `src/client.rs` — `LiveKitRhaiClient` owning a tokio `Runtime` + `Arc<LiveKitClient>` so Rhai (sync) can call blocking methods. `default_socket_path()` cascades `$HERO_SOCKET_DIR` → `~/hero/var/sockets/hero_livekit/rpc.sock`. - `src/bindings.rs` — manual `register_fn`/`register_type_with_name`/`register_get` for every OpenRPC method (install/configure/start/stop/restart/status/create_room/list_rooms/delete_room/list_participants/remove_participant/issue_token) and for `Room`/`Participant`/`AccessToken`. - `src/lib.rs` — public `register(&mut Engine)` + `create_engine() -> Engine`. - `src/main.rs` — CLI entry: `<script.rhai> [args...]`, `<directory>`, `-i` stdin, `--run <name>`, `--version`, `--help`. Thread-local `SCRIPT_DIR` + `run("other.rhai")` helper. - `buildenv.sh` — `PROJECT_NAME`/`BINARIES`/`ALL_FEATURES`/`VERSION`/`PATCHLEVEL`. ### Examples - `examples/rhai/01_status.rhai` - `examples/rhai/02_list_rooms.rhai` - `examples/rhai/03_create_delete_room.rhai` - `examples/rhai/04_issue_token.rhai` - `examples/rhai/05_full_lifecycle.rhai` - All are `rhai_check`-compliant (no `try/catch`, no decorative headers). ### Makefiles - `crates/hero_livekit_rhai/Makefile` — `build`, `build-do`, `build-release`, `install`, `installdev`, `check`, `clippy`, `test`, `run-examples`, `example EXAMPLE=<file>`. - Root `Makefile` — `build-rhai`, `install-rhai`, `run-rhai-example` passthroughs; added to `.PHONY`. ### Docs - `README.md` — new `Service lifecycle via hero_proc` and `Scripting (Rhai)` sections. ## Test Results - `cargo check --workspace` — PASS - `cargo test --workspace` — 8 passed, 0 failed, 3 ignored (pre-existing rustdoc examples) - Runtime validation (not part of `cargo test`): - `nu scripts/nu_service.nu status` requires a running `hero_proc`. - `hero_do_hero_livekit examples/rhai/01_status.rhai` requires `hero_livekit_server` on `$HERO_SOCKET_DIR/hero_livekit/rpc.sock`. ## Out of scope - `.claude/` + `CLAUDE.md` deliverables from the original issue were dropped per the maintainer's follow-up comment. - Per-entity auto-CRUD (`room.set`, `participant.get`, etc.) is not bound — the generated `LiveKitClient` exposes only the 12 `LiveKitService.*` methods today. If CRUD surfaces in future codegen, the Rhai layer can be extended in a follow-up.
feat(scripting): add nu_service.nu + hero_do_hero_livekit Rhai binary
All checks were successful
Build & Test / check (push) Successful in 1m57s
Build & Test / check (pull_request) Successful in 2m1s
043e2f3d19
- scripts/nu_service.nu — two-action Nushell module (hero_livekit_server
  + hero_livekit_ui) delegating to hero_proc. Subcommands install/start/
  stop/status with --root/--reset. lk-backend is installed but supervised
  by the server, not a hero_proc action.
- crates/hero_livekit_rhai — new workspace crate producing the
  hero_do_hero_livekit binary. Manual Rhai bindings (no macros) expose the
  full LiveKitService OpenRPC surface plus Room/Participant/AccessToken
  custom types. The binary injects SCRIPT_DIR/SCRIPT_FILE/ARGS into the
  Rhai scope per the rhai_bindings_cmd_path convention.
- Five example .rhai scripts under crates/hero_livekit_rhai/examples/rhai/:
  status, list_rooms, create_delete_room, issue_token, full_lifecycle.
- Per-crate Makefile plus root build-rhai / install-rhai /
  run-rhai-example passthrough targets.
- README gains Service lifecycle via hero_proc and Scripting sections.

#12
fix(scripting): correct proc.nu import path in nu_service.nu
All checks were successful
Build & Test / check (pull_request) Successful in 2m0s
Build & Test / check (push) Successful in 2m45s
61fcfcf470
proc.nu lives under hero_skills/tools/modules/clients/, not
tools/modules/ — fix the use statement so nu can actually resolve
the module.

#12
ashraf merged commit 817212d205 into main 2026-04-22 14:35:12 +00:00
ashraf deleted branch development_nu_service_rhai 2026-04-22 14:35:12 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_livekit!17
No description provided.