@agentbus/agentbus-client
v0.23.0
Published
TypeScript/Node EventEmitter client for AgentBus (MCP + fs.watch poll)
Readme
@agentbus/agentbus-client
TypeScript / Node.js EventEmitter client for AgentBus.
- Resolves
events.dbfromAGENTBUS_WORKSPACE - Debounced
fs.watch+ slow fallback timer to trigger polls - Spawns
agentbus mcp-serveover stdio (or accepts an injected MCP client) publish/pollmap toagentbus_publish/agentbus_poll- Emits
eventand per-topic events (bus.on('okf/handoff', ...))
Prerequisites
Python AgentBus installed and on
PATH(or setAGENTBUS_BIN):pip install 'okf-agentbus[devex]' # or use a repo venv: export AGENTBUS_BIN=/path/to/agentbus/.venv/bin/agentbusWorkspace initialized:
export AGENTBUS_WORKSPACE=/path/to/project agentbus token ensure --workspace "$AGENTBUS_WORKSPACE"
Install
cd packages/js/agentbus-client
npm install
npm testUsage
Auto stdio (recommended)
import { AgentBus } from "@agentbus/agentbus-client";
const bus = new AgentBus({
workspace: process.env.AGENTBUS_WORKSPACE,
topics: ["okf/handoff"], // or ["*"] to expand via agentbus_status
});
bus.on("okf/handoff", (payload, meta) => {
console.log("handoff", payload, meta.event_id);
});
await bus.connect(); // spawns `agentbus mcp-serve`
await bus.publish("okf/handoff", {
from: "node-agent",
to: "swarm",
summary: "hello from TS",
});
// later
await bus.disconnect();Injected MCP client (tests / custom transports)
import { AgentBus, createStdioMcpClient } from "@agentbus/agentbus-client";
const mcp = await createStdioMcpClient({
workspace: process.env.AGENTBUS_WORKSPACE!,
command: process.env.AGENTBUS_BIN, // optional
});
const bus = new AgentBus({ mcp, workspace: process.env.AGENTBUS_WORKSPACE });
await bus.connect();Set AGENTBUS_WORKSPACE to the project root that contains .agentbus/events.db.
