Handles encoding and decoding of JSON-RPC 2.0 messages over Node.js streams. Use this for inter-process communication between AI agents.
// Source: https://github.com/autohandai/code-cli | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
* @license
* Copyright 2025 Autohand AI LLC
* SPDX-License-Identifier: Apache-2.0
*/
import type { Readable, Writable } from 'node:stream';
const MAX_CHANNEL_BYTES = 1024 * 1024;
interface RpcMessage {
jsonrpc?: '2.0';
method: string;
params: Record<string, unknown>;
id?: number;
}
/**
* Handles encoding/decoding JSON-RPC 2.0 messages as newline-delimited JSON
* over Node.js streams. Used by TeammateProcess and TeamManager for
* inter-agent communication via stdio.
*/
export class MessageRouter {
/**
* Encode a message payload into a JSON-RPC 2.0 JSON stri
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key