@kb-labs/core-ipc
v1.2.0
Published
IPC transport layer for KB Labs platform (Unix sockets, process IPC)
Readme
@kb-labs/core-ipc
IPC transport layer for KB Labs platform — Unix sockets and Node.js process IPC for parent↔child adapter communication.
Overview
The KB Labs sandbox model runs plugin handlers in child processes. The parent process holds real platform adapters (LLM, vector store, etc.); children call them via IPC. core-ipc provides the server (parent side) and transport (child side) for this RPC channel.
Parent process (real adapters) Child process (plugin handler)
┌─────────────────────────────┐ ┌──────────────────────────────┐
│ IPCServer │ ←────── │ IPCTransport │
│ handles: adapter:call │ ──────→ │ send({ adapter, method }) │
│ routes to platform adapter │ │ await response │
└─────────────────────────────┘ └──────────────────────────────┘Parent Side (CLI/daemon)
import { IPCServer } from '@kb-labs/core-ipc';
// platform has real adapter implementations
const server = new IPCServer(platform);
server.start(); // listens on process IPC channelFor multi-process scenarios (Unix socket):
import { UnixSocketServer } from '@kb-labs/core-ipc';
const server = new UnixSocketServer(platform, { socketPath: '/tmp/kb.sock' });
await server.listen();Child Side (plugin sandbox)
import { IPCTransport } from '@kb-labs/core-ipc';
const transport = new IPCTransport({ timeout: 10_000 });
// Transparent RPC call to parent adapter
const result = await transport.send({
type: 'adapter:call',
adapter: 'vectorStore',
method: 'search',
args: [queryVector, { limit: 10 }],
});Large Message Transfer
For passing large datasets (embeddings, file contents) without blocking the IPC channel:
import { BulkTransferHelper } from '@kb-labs/core-ipc';
const helper = new BulkTransferHelper({ chunkSize: 64 * 1024 });
await helper.send(transport, largeBuffer);
// Automatically chunks, reassembles on receiver sideTimeouts
Per-operation timeouts configurable via selectTimeout():
import { selectTimeout, OPERATION_TIMEOUTS } from '@kb-labs/core-ipc';
const timeout = selectTimeout('vectorStore.search', userConfig);
// Falls back to OPERATION_TIMEOUTS defaults if not configuredErrors
| Error | Description |
|-------|-------------|
| TransportError | IPC channel failure |
| TimeoutError | Operation exceeded configured timeout |
| CircuitOpenError | Circuit breaker tripped after repeated failures |
License
KB Public License v1.1 © KB Labs
