# @ag-bash/agent-bridge

> 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).

Latest version **6.0.5** (published 2026-09-24) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @ag-bash/agent-bridge
pnpm add @ag-bash/agent-bridge
yarn add @ag-bash/agent-bridge
bun add @ag-bash/agent-bridge
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.0.5 |
| Published | 2026-09-24 |
| First published | 2026-04-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.6.0 |
| Dependencies | 1 |
| Unpacked size | 78.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | Ag-Bash |
| Maintainers | sairamugge-0000 |
| Keywords | ag-bash, agentic, terminal, bridge |

## Links

- npm: https://www.npmjs.com/package/@ag-bash/agent-bridge
- Repository: https://github.com/sairam0424/ag-bash
- Homepage: https://github.com/sairam0424/ag-bash/tree/main/packages/agent-bridge#readme
- Issues: https://github.com/sairam0424/ag-bash/issues
- npm.io page: https://npm.io/package/@ag-bash/agent-bridge

## Dependencies (1)

- [@ag-bash/bash](https://npm.io/package/@ag-bash/bash.md) 6.0.5

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 6.0.5 (latest) — 2026-09-24
- 3.0.0 (prev) — 2026-05-25
- 6.0.4 — 2026-06-15
- 6.0.3 — 2026-06-15
- 6.0.2 — 2026-05-31
- 6.0.1 — 2026-05-31
- 6.0.0 — 2026-05-30
- 4.1.0 — 2026-05-25
- 2.1.0 — 2026-04-24

## README

# @ag-bash/agent-bridge

> Terminal UI bridge for AI agent communication with ag-bash

[![npm version](https://img.shields.io/npm/v/@ag-bash/agent-bridge?label=npm&color=cb3837)](https://www.npmjs.com/package/@ag-bash/agent-bridge)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

Connects AI agents to terminal UIs (xterm.js, etc.) with streaming responses, tool call rendering, and pluggable adapter architecture.

## Installation

```bash
npm install @ag-bash/agent-bridge
```

## Quick Start

```typescript
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:

```typescript
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** — `FetchAgentAdapter` included; implement `AgentAdapter` for custom transports
- **Orchestrator mode** — Pass a `Bash` instance 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

- [GitHub Repository](https://github.com/AstroBaseCode/ag-bash)
- [Core Engine](https://www.npmjs.com/package/@ag-bash/bash)
- [MCP Server](https://www.npmjs.com/package/@ag-bash/mcp-server)

## License

Apache-2.0

---
_Source: https://npm.io/package/@ag-bash/agent-bridge · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
