intermesh
v0.4.5
Published
Universal coordination protocol for AI agents — E2E encrypted, cross-language, federated
Readme
InterMesh — JavaScript / TypeScript SDK
The official Node.js SDK for InterMesh Protocol, the universal open-source coordination protocol for AI agents.
Fully interoperable with the Python SDK: a Node.js agent and a Python agent can exchange end-to-end encrypted messages and tasks through the same hub.
npm install intermeshQuick start
Start the hub (from the Python SDK, or via Docker):
intermesh hubConnect an agent:
import { InterMeshAgent } from 'intermesh';
const agent = new InterMeshAgent({
name: 'node_orchestrator',
capabilities: ['orchestration'],
roles: ['admin'],
hubUrl: 'ws://localhost:8765',
});
await agent.connect();
// Find a Python agent by capability and delegate to it
const found = await agent.discover({ capabilities: ['calculate'] });
const result = await agent.submitTask(
'Add two numbers',
found.agents[0].name,
{ a: 20, b: 22 }
);
// { result: 42 } — encrypted end-to-end across languagesHandle inbound work:
agent.onTask(async (input, task) => {
return { result: input.a + input.b };
});
agent.onRequest(async (content, sender) => {
return { status: 'ONLINE' };
});Adapters: bridge an existing framework agent
Wrap an existing LangChain.js Runnable or LlamaIndex.TS query/chat engine without
changing a line of it — it becomes discoverable and receives delegated tasks like a
native InterMesh agent:
import { InterMeshLangChainAdapter } from 'intermesh/adapters/langchain';
const agent = new InterMeshLangChainAdapter(myRunnable, {
name: 'analyst',
capabilities: ['market_analysis'],
});
await agent.connect();import { InterMeshLlamaIndexAdapter } from 'intermesh/adapters/llamaindex';
const agent = new InterMeshLlamaIndexAdapter(index.asQueryEngine(), {
name: 'knowledge_base',
capabilities: ['document_search', 'rag'],
});
await agent.connect();Any other object exposing invoke, run, call, query, chat, predict — or a
plain function — works with the generic adapt():
import { adapt } from 'intermesh/adapters';
const agent = adapt(myExistingAgent, { name: 'x', capabilities: ['c'] });No framework is imported by these modules: the adapter detects the calling convention at runtime instead of depending on a specific package version. CrewAI and AutoGen have no established JS port, so only LangChain.js and LlamaIndex.TS have a dedicated bridge here.
The Python SDK works differently: it detects the calling convention only for
LangChain (from_langchain). Everything else goes through from_callable, where
you write the adapting function yourself — see
docs/AGENT-INTEGRATION.md.
Orchestration: chain and parallelize agents
InterMeshPipeline chains tasks across agents found by capability — the output of
one step feeds the next:
import { InterMeshPipeline } from 'intermesh';
const pipeline = new InterMeshPipeline(orchestrator)
.step('Translate', { capabilities: ['translate'] })
.step('Calculate', {
capabilities: ['calculate'],
inputFn: (prev) => ({ expression: prev.translated_text }),
});
const result = await pipeline.run({ text: 'compute forty two doubled' });fanOut runs independent branches concurrently and keys the results:
import { fanOut } from 'intermesh';
const results = await fanOut(orchestrator, [
['fr', { region: 'FR' }],
['de', { region: 'DE' }],
], { capabilities: { fr: ['market_analysis'], de: ['market_analysis'] } });See Agent integration for the full picture, including the Python-side equivalents.
Cryptographic interoperability
The SDK implements the same hybrid scheme as the Python SDK, using Node's native
crypto module:
- RSA-2048-OAEP (SHA-256) to wrap a per-message AES key
- AES-256-GCM (12-byte IV, 16-byte auth tag) for the payload
A message encrypted in JavaScript decrypts in Python, and vice versa. The hub sees only ciphertext.
API summary
| Method | Purpose |
|---|---|
| connect() | Open the connection and obtain a JWT |
| submitTask(title, assignee, inputData) | Delegate a task and await its result |
| discover(query) | Find agents by capability, role, or metadata |
| whoIs(name) | Fetch an agent's certified identity and public key |
| onMessage / onRequest / onTask | Register inbound handlers |
Documentation
- Agent integration — adapters and orchestration
- RFC-001 — Core protocol specification
- Security and encryption model
- API reference
