Type-Safe Commands
Full TypeScript inference via Valibot, or compile-time-checked Rust types via schemars. Same guarantees across process boundaries.
Building applications that span multiple processes, workers, or services often means dealing with complex message passing, type mismatches, and boilerplate code. cmd-ipc solves this by providing a unified, type-safe command system that works across any boundary — in TypeScript, Rust, or both at once over the same wire protocol.
Type-Safe Commands
Full TypeScript inference via Valibot, or compile-time-checked Rust types via schemars. Same guarantees across process boundaries.
Polyglot
TypeScript and Rust implementations share a byte-identical wire protocol. Call a Rust command from Node.js or vice versa.
Universal Channels
MessagePort, HTTP, MCP, in-memory — same API regardless of transport. Plug in custom channels for anything else.
Event Broadcasting
Fire-and-forget events propagate across all connected processes with automatic deduplication.
import { CommandRegistry, Command, registerCommands } from '@coralstack/cmd-ipc'import * as v from 'valibot'
const CommandSchema = { 'math.add': { request: v.object({ a: v.number(), b: v.number() }), response: v.number(), },} as const
class MathService { @Command('math.add') add({ a, b }: { a: number; b: number }): number { return a + b }}
const registry = new CommandRegistry({ id: 'main', schemas: { commands: CommandSchema },})
registerCommands([new MathService()], registry)
const result = await registry.executeCommand('math.add', { a: 5, b: 3 })// result is typed as number = 8use coralstack_cmd_ipc::prelude::*;
#[payload]struct AddReq { a: i64, b: i64 }
struct MathService;
#[command_service]impl MathService { #[command("math.add", description = "Add two integers")] async fn add(&self, req: AddReq) -> Result<i64, CommandError> { Ok(req.a + req.b) }}
let registry = CommandRegistry::new(Config::default());MathService.register(®istry).await?;
let sum = registry .execute::<math_service::Add>(AddReq { a: 5, b: 3 }) .await?;// sum: i64 = 8Electron Apps
Communicate between main and renderer processes with type safety. No more IPC message mismatches.
Web Workers
Offload heavy computation to workers while maintaining a clean, typed API.
Microservices
Build type-safe HTTP APIs with automatic schema validation via HTTPChannel.
AI Agents
Expose commands as MCP tools for AI agents with automatic schema generation.
Ready to get started? Check out the installation guide or explore the examples. For the Rust crate, see the Rust API.