Installation
cmd-ipc ships as both a TypeScript package and a Rust crate. Both speak the same wire protocol.
Requirements
Section titled “Requirements”- Node.js 20.18.2 or higher
- TypeScript 5.0 or higher (recommended)
- Rust 1.75 or higher (edition 2021)
- An async executor of your choice (tokio, async-std, smol,
futures::executor, etc.) — the crate is runtime-agnostic
Package Installation
Section titled “Package Installation”npm install @coralstack/cmd-ipc valibotyarn add @coralstack/cmd-ipc valibotpnpm add @coralstack/cmd-ipc valibotbun add @coralstack/cmd-ipc valibotcargo add coralstack-cmd-ipcOr in Cargo.toml:
[dependencies]coralstack-cmd-ipc = "0.1"schemars = "1"serde = { version = "1", features = ["derive"] }serde_json = "1"The core crate re-exports the #[command] / #[command_service] attribute macros from coralstack-cmd-ipc-macros, so you don’t need to depend on the macros crate directly.
MCP adapter (optional)
Section titled “MCP adapter (optional)”cargo add coralstack-cmd-ipc-mcpAdds McpServerChannel for exposing a registry as an MCP server via stdio.
Language Setup
Section titled “Language Setup”TypeScript Configuration
Section titled “TypeScript Configuration”cmd-ipc uses decorators for the @Command syntax. Enable decorators in your tsconfig.json:
{ "compilerOptions": { "experimentalDecorators": true, "emitDecoratorMetadata": true }}Reflect Metadata
Section titled “Reflect Metadata”The decorator system requires reflect-metadata. Import it once at your application’s entry point:
// main.ts or index.tsimport 'reflect-metadata'
// Rest of your applicationimport { CommandRegistry } from '@coralstack/cmd-ipc'Prelude
Section titled “Prelude”Import the common types in one line:
use coralstack_cmd_ipc::prelude::*;This brings into scope: command, command_service, ChannelError, Command, CommandChannel, CommandDef, CommandError, CommandRegistry, CommandSchema, Config, DynCommand, InMemoryChannel.
Shorter import path (optional)
Section titled “Shorter import path (optional)”If the coralstack_ prefix feels long at use sites, alias it in Cargo.toml:
[dependencies]cmd-ipc = { package = "coralstack-cmd-ipc", version = "0.1" }Then use cmd_ipc::prelude::*; works throughout your crate.
CLI Installation (TypeScript only, optional)
Section titled “CLI Installation (TypeScript only, optional)”cmd-ipc includes a CLI for generating schemas from remote services. It’s included in the main TypeScript package:
# Generate TypeScript schema from a remote HTTP endpointnpx cmd-ipc generate-schema --url http://localhost:8787 --output ./src/api-schema.tsOr add it as a script in your package.json:
{ "scripts": { "generate-schema": "cmd-ipc generate-schema --url http://localhost:8787 --output ./src/generated/api-schema.ts --prefix api" }}Package Exports
Section titled “Package Exports”// Main exports - CommandRegistry, Channels, Decoratorsimport { CommandRegistry, MessagePortChannel, HTTPChannel, Command, registerCommands,} from '@coralstack/cmd-ipc'
// Testing utilitiesimport { TestLogger } from '@coralstack/cmd-ipc/testing'// Prelude — most common typesuse coralstack_cmd_ipc::prelude::*;
// Or import by pathuse coralstack_cmd_ipc::{ CommandRegistry, Config, CommandChannel, InMemoryChannel, Command, CommandError, command, commands,};
// MCP adapter (separate crate)use coralstack_cmd_ipc_mcp::McpServerChannel;