@fusedio/agentbridge-hub
v0.1.3
Published
High-level host-facing API for running agentbridge adapters with event streaming and session continuity.
Readme
@fusedio/agentbridge-hub
High-level host-facing API for agentbridge: run local coding-agent CLIs with normalized event streaming and session continuity, from one small interface.
Install
npm install @fusedio/agentbridge-hub @fusedio/agentbridge-adapter-claude-codeUsage
import { createAgentHub } from "@fusedio/agentbridge-hub";
import { createAdapter as claudeCode } from "@fusedio/agentbridge-adapter-claude-code/server";
const hub = createAgentHub({ adapters: [claudeCode()] });
const run = hub.run({
adapter: "claude_code",
prompt: "Summarize the files in this directory.",
cwd: process.cwd(),
taskKey: "my-task", // runs sharing a key resume the same agent session
});
for await (const ev of run.events()) {
// ev.type: "log" | "transcript" | "meta" | "status"
}
const result = await run.result; // ExecutionResult { usage, costUsd, summary, ... }run.events()replays from the start and is SSE-friendly — pipe it straight to anEventSourceendpoint.- The terminal
statusevent and the resolvedresultcarry tokenusage(input / output / cached) andcostUsd. - Sessions persist through a pluggable
SessionStore(a JSON-file store by default), so a follow-up run with the sametaskKeycontinues the prior conversation. Cancellation ishub.cancel(runId). - Pass
runIdto own run identity end-to-end: when set it becomesrun.runId, thecancel()key, and therunIdon every emitted event — so a host can correlate and cancel using its own durable id. Omit it and the hub mints a UUID. It is per-execution (1:1 with therun()call), not a session key — that stays ontaskKey. A supplied id that collides with a still-active run throwsDuplicateRunIdError; re-use is allowed once a run finishes.
ESM-only, Node >= 20.
License
MIT © Fused
