rpc
Define and serve RPC methods from a MOD service. Other MODs, the engine, and AI agents can call these methods through the engine's RPC proxy.
note
This module uses Node.js APIs (node:http, process) and is not browser-compatible. It is intentionally not re-exported from the main @hmcs/sdk entry point.
Import
import { rpc } from "@hmcs/sdk/rpc";
Functions
| Function | Description |
|---|---|
| serve | Start the RPC server and register methods with the engine |
| method | Define an RPC method with optional Zod validation |
| call | Call an RPC method on another MOD's service |
Type Definitions
| Type | Description |
|---|---|
| RpcServer | Server instance returned by serve() |
| RpcMethodEntry | Method definition used in serve({ methods }) |
| RpcCallOptions | Options for call() |