@ag-bash/agent-bridge
v6.0.4
Published
Terminal UI bridge for Ag-Bash — streams AI-agent output and tool calls to xterm.js-compatible terminals via pluggable adapters (SSE/HTTP fetch, custom WebSocket).
Maintainers
Readme
@ag-bash/agent-bridge
Terminal UI bridge for AI agent communication with ag-bash
Connects AI agents to terminal UIs (xterm.js, etc.) with streaming responses, tool call rendering, and pluggable adapter architecture.
Installation
npm install @ag-bash/agent-bridgeQuick Start
import { createAgentBridge } from "@ag-bash/agent-bridge";
import { Bash } from "@ag-bash/bash";
const bash = new Bash({ agentic: { enabled: true } });
const bridge = createAgentBridge(terminal, {
bash,
apiEndpoint: "/api/agent",
});
// Run agent prompts through the bridge
await bridge.executeAgentPrompt("list all files in /src");
// Or register as a shell command
const bashWithAgent = new Bash({ customCommands: [bridge.agentCmd] });
await bashWithAgent.exec('agent "explain this codebase"');Adapter Pattern
Swap the backend without changing your UI code:
import { FetchAgentAdapter } from "@ag-bash/agent-bridge";
// Built-in: SSE streaming over HTTP
const fetchAdapter = new FetchAgentAdapter("/api/agent");
// Custom: implement the AgentAdapter interface
const customAdapter: AgentAdapter = {
type: "websocket",
async *run(messages) {
// yield streaming events
},
};
createAgentBridge(terminal, { adapter: customAdapter });Features
- Streaming rendering — Text deltas, tool calls, and results stream to the terminal in real time
- Tool call display — Bash commands shown with
$prefix; other tools shown by name - Pluggable adapters —
FetchAgentAdapterincluded; implementAgentAdapterfor custom transports - Orchestrator mode — Pass a
Bashinstance for local tool execution without a remote API - Error sanitization — File paths and Node.js internals stripped from terminal output
- Conversation state — Message history managed automatically with reset support
Links
License
Apache-2.0
