Skip to content

What is cmd-ipc?

cmd-ipc is a polyglot library for Inter-Process Communication (IPC) that provides a unified, type-safe command system for applications spanning multiple processes, workers, or services. It ships as both a TypeScript package (@coralstack/cmd-ipc) and a Rust crate (coralstack-cmd-ipc) that speak a byte-identical wire protocol.

Modern applications often need to communicate across boundaries:

  • Electron apps send messages between main and renderer processes
  • Web apps offload work to Web Workers for better performance
  • Microservices communicate via HTTP or message queues
  • AI agents call tools exposed by your application

Traditional approaches lead to type mismatches, boilerplate code for message serialization and routing, inconsistent patterns across different channels, and difficult debugging when messages get lost or malformed.

cmd-ipc provides a Command Registry pattern that abstracts away the underlying transport while maintaining full type safety:

// Same API whether calling a local function, a Web Worker, or a remote service
const result = await registry.executeCommand('user.create', {
name: 'John',
email: 'john@example.com',
})
  • Type Safety — TypeScript inference via Valibot, or compile-time-checked Rust types via schemars. Runtime validation in both.
  • Polyglot — Identical wire protocol in TypeScript and Rust. Call a Rust command from Node.js or vice versa once a shared transport is configured.
  • Transport Agnostic — Same API for MessagePort, HTTP, MCP, in-memory, or custom channels.
  • Automatic Routing — Commands route to the correct registry without manual wiring, via the Hybrid Tree-Mesh architecture.
  • Schema Discovery — Remote services expose their command schemas for type generation (TypeScript CLI today).
  • Event Broadcasting — Fire-and-forget events propagate to all connected processes.