agent-bridge

mcp
Security Audit
Fail
Health Warn
  • License — License: MIT
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Low visibility — Only 6 GitHub stars
Code Fail
  • process.env — Environment variable access in packages/agy/src/host.ts
  • exec() — Shell command execution in packages/agy/src/mcp-relay.ts
Permissions Pass
  • Permissions — No dangerous permissions requested

No AI report is available for this listing yet.

SUMMARY

Connect external AI coding Agents (Claude Code, Codex, WorkBuddy, Doubao, DSH, Antigravity, Factory Droid) to Nia Teams as two-way group chat participants with signed TaskBar approvals.

README.md

Nia Teams Agent Bridge

English | 简体中文

Connect external Agents running on your computer or server (OpenAI Codex, Claude Code, WorkBuddy (CodeBuddy), Doubao, DeepSeek Harness (DSH), Google Antigravity CLI (agy), Factory Droid, and Pi Coding Agent, or custom Node.js Agents) into Nia Teams as an Agent in Nia Teams with two-way communication.

# 1. Install: choose ONE bridge for your local AI client (do not run all lines)
npm install -g @nia-teams/claude-code-plugin   # Claude Code     -> nia-claude
npm install -g @nia-teams/codex-bridge         # OpenAI Codex    -> nia-codex
npm install -g @nia-teams/agy-bridge           # Antigravity CLI -> nia-agy
npm install -g @nia-teams/workbuddy-plugin    # WorkBuddy       -> nia-workbuddy
npm install -g @nia-teams/doubao-bridge        # Doubao          -> nia-doubao
npm install -g @nia-teams/droid-bridge         # Factory Droid   -> nia-droid
npm install -g @nia-teams/pi-bridge            # Pi Coding Agent -> nia-pi
# DeepSeek Harness (DSH):
dsh plugin --profile web add @nia-teams/dsh-plugin

# 2. Scan with WeChat and start the bridge:
<nia-cli> connect --cwd "/path/to/workspace"
# Alternatively, check or pair an Agent from the browser: replace <nia-cli> with the matching CLI above (omit angle brackets)
# <nia-cli> status
# Only on first setup or when rebinding:
# <nia-cli> pair --name 'My Local Agent'

# 3. If using pair instead of connect, start the background daemon
# Portable background launch (Windows PowerShell/CMD/Git Bash, macOS, Linux):
# <nia-cli> start --cwd "/path/to/workspace" --daemon
# Optional: --log-file "/path/to/bridge.log"; default: <config-dir>/daemon.log
# POSIX-only alternative (not Windows):
# nohup <nia-cli> start --cwd "$PWD" > /tmp/nia-agent.log 2>&1 &

# DSH uses different pairing and startup commands instead (macOS / Linux):
# npx --prefix ~/.dsh/profiles/web nia-dsh connect
# npx --prefix ~/.dsh/profiles/web nia-dsh status
# npx --prefix ~/.dsh/profiles/web nia-dsh pair --label 'My DSH'
# nohup dsh web > /tmp/nia-dsh.log 2>&1 &

<nia-cli> means nia-claude, nia-codex, nia-agy, nia-workbuddy, nia-doubao, nia-droid, or nia-pi. With start, omitting --daemon runs in the foreground; --daemon launches a detached Node process without nohup or /tmp. Check status first if already paired and reuse credentials for the intended Agent. DSH runs inside Harness, not through nia-dsh start.

For WorkBuddy, add --model <model-id> or set CODEBUDDY_MODEL when starting the daemon. Use nia-workbuddy connect --no-start to pair without it.

AI coding agents: find your host in the package table below and load its corresponding SKILL.md for host-specific sign-in checks, pairing, and startup guidance.

For WeChat QR setup and optional GroupChat invites, see WeChat connect.

Packages

Package Host and runtime mode CLI Documentation and AI skill
@nia-teams/agent-bridge-core Custom Node.js Agent BridgeClient SDK README · skills/agent-bridge-core/SKILL.md
@nia-teams/codex-bridge OpenAI Codex nia-codex README · skills/nia-teams-codex/SKILL.md
@nia-teams/claude-code-plugin Claude Code: SDK daemon nia-claude README · skills/nia-teams-claude-code/SKILL.md
@nia-teams/workbuddy-plugin WorkBuddy / CodeBuddy nia-workbuddy README · skills/nia-teams-workbuddy/SKILL.md
@nia-teams/doubao-bridge Doubao desktop CDP + HTTP runtime / official CLI nia-doubao README · skills/nia-teams-doubao/SKILL.md
@nia-teams/dsh-plugin DeepSeek Harness nia-dsh pairs; dsh web runs README · skills/nia-teams-dsh/SKILL.md
@nia-teams/agy-bridge Google Antigravity CLI: ACP daemon nia-agy README · skills/nia-teams-agy/SKILL.md
@nia-teams/droid-bridge Factory Droid: native TypeScript SDK nia-droid README · skills/nia-teams-droid/SKILL.md
@nia-teams/pi-bridge Pi Coding Agent: native RPC nia-pi README · skills/nia-teams-pi/SKILL.md

1. Product Overview & Shared Architecture

External Agents that normally run in your local terminal or desktop app become a native Agent member inside Nia Teams (with their own Agent identity, product avatar, Personal Assistant or organization ownership, and live presence) that can join any GroupChat for two-way communication:

  • Nia Teams → External Agent (Inbound): Teammates and other Agents @ mention it to assign tasks, follow up across turns, answer its questions, or approve local tool execution on signed TaskBar cards;
  • External Agent → Nia Teams (Outbound): The Agent can send replies or <mention userId="..." /> teammates, read and search authorized chats, update the GroupChat title, propose creating GroupChats or inviting organization members via TaskBar confirmation cards, schedule one-shot reminders, read public /share/<token> links, invoke authorized routines, and sync live thinking and tool activity.

Model sign-in, workspace access, and local tool permissions stay on your host. The repository contains eight client adapter packages and one core package, nine packages in total; all eight adapters share @nia-teams/agent-bridge-core, and custom Node.js Agents can also use the core SDK directly.

Nia Teams GroupChat, external Agent, and live activity

Shared module Responsibility Consumer responsibility
pairHost and credential store Local Ed25519 keys, browser claim, registration proof, private 0700/0600 storage Select host label, service origin, and separate config directory
BridgeClient Challenge/lease, authenticated WebSocket, heartbeat, delivery ack, reconnect Register push handlers, execute model work, handle cancellation
Client branding protocol pairHost reports metadata in pairing/start; BridgeClient reports it in every lease handshake; no Teams client enum Adapters or custom Node.js Agents supply clientName and PNG avatar for automatic pairing-page and GroupChat icons
PublicationQueue FIFO publications, idempotency keys, transient retries, reply/activity ordering Choose main replies and stable publication identities
Confirmation verifier RS256/JWKS, expected card/tool, canonical-JSON argument SHA-256 digest Apply verified verdicts only to the original pending action
SessionHost / ThreadMapStore SDK-style queues, private sessions, questions, cancellation, approvals Supply an upstream runner; Codex, Antigravity, and DSH retain their own runtime lifecycles

Branding is optional: clientName is trimmed to 1–80 characters; avatar is data:image/png;base64,..., decoded PNG file ≤64 KiB and dimensions ≤1024×1024. Upgrading and starting a client updates an existing Agent through verified leases without re-pairing; custom user avatars win. See the core protocol and asset sources.

Adapter runtime comparison

Adapter Upstream execution GroupChat context Tool permissions
Codex codex app-server JSON-RPC Persistent Codex thread per chat Full-auto by default; opt-in TaskBar approvals
Claude Code daemon Claude Agent SDK streaming query() with live steering Persistent SDK session per chat Full-auto by default; opt-in TaskBar approvals
WorkBuddy / CodeBuddy CodeBuddy Agent SDK Independent SDK session per chat Full-auto by default; opt-in TaskBar approvals
Doubao Desktop cookies + HTTP runtime or official CLI Backend-prefixed persistent sessions Full-auto by default; Doubao permission modes
DSH DeepSeek Harness / Cordis services Independent Harness session per chat Tool and approval-question requests become TaskBar cards
Antigravity agy acp JSON-RPC 2.0 Persistent ACP session per chat Full-auto by default; opt-in TaskBar approvals
Factory Droid Factory TypeScript SDK Independent SDK session per chat Full-auto by default; opt-in TaskBar approvals
Pi Coding Agent pi --mode rpc Independent Pi session per chat Native Pi permissions; extension dialogs are canceled

2. Five-Step Setup: Install to GroupChat Collaboration

Step 1: Prepare the host and install an adapter

Requires Node.js 20+, or Node.js 22+ for Doubao. Install the bridge matching the AI client you use locally; choose one. First install and sign in to that CLI or desktop app under the same OS user that runs the model. See the package table and section 3 for host requirements.

npm install -g @nia-teams/claude-code-plugin   # Claude Code     -> nia-claude
npm install -g @nia-teams/codex-bridge         # OpenAI Codex    -> nia-codex
npm install -g @nia-teams/agy-bridge           # Antigravity CLI -> nia-agy
npm install -g @nia-teams/workbuddy-plugin    # WorkBuddy       -> nia-workbuddy
npm install -g @nia-teams/doubao-bridge        # Doubao          -> nia-doubao
npm install -g @nia-teams/droid-bridge         # Factory Droid   -> nia-droid
npm install -g @nia-teams/pi-bridge            # Pi Coding Agent -> nia-pi
# DeepSeek Harness (DSH):
dsh plugin --profile web add @nia-teams/dsh-plugin

Upstream sign-in connects the model account; Nia Teams pairing binds an external Agent identity. They are separate steps. The package skills guide local AI through credential checks, monitored pairing, and background startup.

Step 2: Pair the host and create an Agent

Check status with your selected CLI first and verify the Agent, Server, and config directory. Reuse the intended binding; run pair only for first setup or an intentional rebind. Replace the <nia-cli> placeholder with your actual CLI:

# <nia-cli> = nia-claude / nia-codex / nia-agy / nia-workbuddy / nia-doubao / nia-droid / nia-pi
<nia-cli> status
# Only when creating or rebinding an Agent:
<nia-cli> pair --name 'My Local Agent'

DSH uses the CLI in the selected profile (web below) and the --label flag:

npx --prefix ~/.dsh/profiles/web nia-dsh status
# Only when creating or rebinding an Agent:
npx --prefix ~/.dsh/profiles/web nia-dsh pair --label 'My DSH'
Pairing code: A7F39C2B
Open this URL to create or bind your external Agent:
https://nia-teams.com/bridge/agent-pair/A7F39C2B
  1. Open the URL in a browser on any device and sign in. Select Create external Agent, enter a name, and choose Personal Assistant or an organization you belong to. The creator becomes the Agent’s owner.
  2. Click Create & Connect. For migration, an existing Agent’s owner / admin chooses Rebind existing external Agent and confirms. Keep the host pairing process running until exit code 0.

External Agent creation, organization scope, and rebinding

The host generates Ed25519 keys and keeps the private key locally. credentials.json uses POSIX 0700 directory and 0600 file modes. Pairing links last 10 minutes. Run status after completion to check Agent, Server, and config directory.

Step 3: Start the host and keep it online

For manual debugging, run in an interactive foreground terminal after replacing <nia-cli> with your platform's actual CLI:

<nia-cli> start --cwd /path/to/workspace

For detached operation or local AI one-shot tool calls:

# Portable background launch (Windows PowerShell/CMD/Git Bash, macOS, Linux):
<nia-cli> start --cwd "/path/to/workspace" --daemon
# Optional: --log-file "/path/to/bridge.log"; default: <config-dir>/daemon.log

# POSIX-only alternative (not Windows):
nohup <nia-cli> start --cwd /path/to/workspace > /tmp/nia-agent.log 2>&1 &
BRIDGE_PID=$!
sleep 2
cat /tmp/nia-agent.log
ps -p "$BRIDGE_PID" -o pid=,args=

DSH (macOS / Linux) runs dsh web in the foreground instead of the start command above. For background startup and checks:

nohup dsh web > /tmp/nia-dsh.log 2>&1 &
sleep 2
cat /tmp/nia-dsh.log
pgrep -af '[d]sh.*web'

The background process connects to the saved server and reconnects after interruptions. On macOS, caffeinate prevents system sleep while a task runs. One host owns each credentials directory. The daemon's --cwd or the DSH plugin's cwd configuration selects the project; adapters persist session mappings in threads.json or DSH sessions. When running multiple platforms, use separate log files and config directories for each instance. Verify GroupChat presence and a reply in the next step.

If macOS launchd manages the bridge, upgrade in the same installation directory or npm prefix used by its service, then restart that service and check its log.

Step 4: Invite to GroupChat and verify presence

Open Messages in Nia Teams. Click the Agent avatar in the quick strip for a new conversation, or its right-hand + to create a multi-person chat. For an existing GroupChat, click + beside member avatars in the upper-right header, select the Agent in Invite existing members, and click Done.

Organization members can invite organization-affiliated Agents. The creator initially invites a Personal Assistant; afterward other chat members can invoke it. Presence above the composer changes from red Disconnected to Idle / Ready. Send a short task and verify its GroupChat reply.

Step 5: Invoke and manage the Agent

Type @ and select the Agent to send work. Codex, Claude Code, WorkBuddy, Antigravity, and Factory Droid default to full-auto because per-tool approvals would add too many cards to GroupChat during normal coding turns. To review each requested permission, pass --require-approval to connect or start; Agent members can review tool names and arguments in TaskBar and click Allow. Doubao uses its own permission modes without TaskBar tool cards; DSH and Pi retain their existing permission behavior.

TaskBar tool arguments, approval button, and waiting state

  • Temporary offline: Stop the host process; presence becomes disconnected. Restart reuses pairing and sessions.
  • Migrate or unpair: An Agent owner / admin can rebind from the new host’s pairing page or use Apps → Agent Settings → Unpair host. Binding changes disconnect old hosts with 4401; a competing connection supersedes the old one with terminal 4409.
  • Deactivate and archive: With no other contacts and a sole owner, choose deactivate and confirm in Agent settings to revoke online connections.

Workspace files

On Windows, Linux, and macOS, the bridge serves workspace files read-only from the working directory and logs that directory at startup. To share a file in send_message, put it under shared/ or public/ and send /f/<slug>/<relative-path>, for example /f/my-agent/shared/report.md. Links read the file from the online host; sending a link does not upload a copy.

Anyone can open public/ links. Any signed-in Nia Teams user can open shared/ links, even outside the chat. Other workspace paths are for members of the Agent itself, not everyone in its chats. The host confines reads to its working directory, including symlink targets. Incoming attachments and files retrieved with fetch_file are downloaded to the receiving host for local use.

3. Host Features & Launch Reference

1. OpenAI Codex (@nia-teams/codex-bridge)

Codex (≥ 0.167.0) runs through app-server JSON-RPC with a persistent thread per chat and steering for active turns. The default sandbox is workspace-write; --require-approval defaults to read-only. An explicit --sandbox takes precedence.

nia-codex start --cwd "/path/to/workspace" --daemon

2. Claude Code (@nia-teams/claude-code-plugin)

The daemon uses the Claude Agent SDK and persists per-chat sessions. Use --model to select a model or --claude-bin to select a local executable.

nia-claude start --cwd "/path/to/workspace" --daemon

3. WorkBuddy / CodeBuddy (@nia-teams/workbuddy-plugin)

Discovers WorkBuddy.app’s codebuddy-lite-wb.mjs and decrypts existing desktop authentication with ELECTRON_RUN_AS_NODE=1, without starting UI or stealing focus. Standalone CodeBuddy is also supported. SDK sessions resume per chat; approvals and questions route to TaskBar or GroupChat.

nia-workbuddy start --cwd "/path/to/workspace" --daemon --model "<model-id>"

4. Doubao Work / Doubao CLI (@nia-teams/doubao-bridge)

Desktop mode supports DoubaoWork.app / Doubao.app, reads local CDP cookies, and executes through an HTTP local runtime without DOM interaction or task-time focus changes. Official @bytedance/doubao-cli hands missing-login QR to the interactive terminal; complete doubao login before detached startup. Sessions resume by backend prefix; permissions use AskOnRisk/FullAccess or official CLI policies.

nia-doubao start --cwd "/path/to/workspace" --daemon
# Choose official CLI instead of the desktop/auto daemon:
# nia-doubao start --platform cli --cwd "/path/to/workspace" --daemon

5. DeepSeek Harness (@nia-teams/dsh-plugin)

DSH 0.2.x loads the plugin through its Cordis profile on macOS / Linux and supplies models, tools, and persistent sessions. Pair with nia-dsh pair --label; execution belongs to dsh web. Configuration can override cwd, presets, model, and operator tool preauthorization.

dsh plugin --profile web add @nia-teams/dsh-plugin
npx --prefix ~/.dsh/profiles/web nia-dsh pair --label 'My DSH'
nohup dsh web > /tmp/nia-dsh.log 2>&1 &

6. Google Antigravity CLI (@nia-teams/agy-bridge)

A persistent agy acp child reuses a configured ACP session per GroupChat. Incoming messages steer an active session, and messages received during session setup are combined into one prompt. Initialization negotiates protocol version 1; streamed output stays on the host while GroupChat replies and history access use the host's loopback HTTP MCP endpoint. Tool requests use signed TaskBar approvals. Explicit resume errors can create a new session, while transport failures do not replay work. Cancellation that fails to settle in two seconds terminates that child; later turns initialize a new generation.

npm install -g @nia-teams/agy-bridge
nia-agy pair --name 'My Antigravity'
nia-agy start --cwd "/path/to/workspace" --daemon

Select a signed-in executable with --agy-bin / AGY_BIN. --mode accepts default, accept-edits, auto, or plan; --model selects an available model and --sandbox forwards the boolean flag. See the Antigravity guide.

7. Factory Droid (@nia-teams/droid-bridge)

Factory's native @factory/droid-sdk retains a local session per GroupChat. Run droid and finish browser login first, or set FACTORY_API_KEY. Runtime permission requests become signed TaskBar cards; AskUser waits for a GroupChat answer. Assistant text stays private; MCP tools publish replies.

npm install -g @nia-teams/droid-bridge
nia-droid pair --name 'My Droid'
nia-droid start --cwd "/path/to/workspace" --daemon

Select the executable with --droid-bin / DROID_BIN; configure sessions with --model, --effort, and --autonomy. Full-auto uses high autonomy unless --autonomy is set. See the Factory Droid guide.

8. Pi Coding Agent (@nia-teams/pi-bridge)

The bridge uses your installed pi --mode rpc and its provider login. Each GroupChat retains its own local session. Collaboration tools publish replies; assistant output stays on the host.

npm install -g @nia-teams/pi-bridge
nia-pi connect --cwd "/path/to/workspace"

Select Pi with --pi-bin / PI_BIN. Use --model, --provider, and --thinking to override Pi defaults. See the Pi guide.

4. Message Format, Native Mentions & Security

A GroupChat trigger carries title, URL, members, invoker, and messages. Raw messages[].authorId identifies the sender; groupChat.members[].id identifies members. The formatted model prompt includes:

# GroupChat: Project Review
URL: https://nia-teams.com/chat/example
Members: Alice (<userId>), local-agent (<agentId>)

Alice (<userId>) [<messageId>] <timestamp>:
Please review the current changes.

Generic messages may use [chat:<chatId>] Alice (<userId>): ..., or a structured channel may expose senderId. Publish <mention userId="24-hex-id" /> for a real notification, filling it from a received sender/member ID rather than guessing by display name. Use send_message for GroupChat replies.

For TaskBar approval, Nia Teams checks Agent membership before signing an RS256 nia/confirmationToken. The host uses @nia-teams/mcp-sdk/auth and ${issuer}/oauth2/jwks to verify signature, issuer, audience, lifetime, service identity, human confirmation, card ID, tool, and canonical-JSON argument SHA-256 digest. Each card binds one pending operation; chat text saying “allow” or a role field does not replace signature validation.

The host config directory stores Ed25519 private keys and paired identity with 0700/0600 directory/file permissions. Origin changes, rebinding, and unpairing affect that identity and are not controlled by chat bodies. Model login, desktop cookies, and bridge keys belong to their respective runtime boundaries. Per-chat context isolation is not workspace or OS isolation; select tool permission mode on the host.

5. Repository Layout & Local Development

packages/
  core/          Agent Bridge transport, credentials, publications, SessionHost
  codex/         Codex app-server adapter
  claude-code/   Claude SDK daemon
  workbuddy/     CodeBuddy SDK and desktop authentication
  doubao/        Desktop-authenticated HTTP runtime and official CLI
  dsh/           DeepSeek Harness / Cordis plugin
  agy/           Antigravity ACP sessions, scoped MCP tools, and approvals
  droid/         Factory native SDK sessions, MCP tools, and approvals
  pi/            Pi RPC sessions and MCP collaboration tools
docs/            Shared protocol map and product screenshots
tests/           Shared runtime integration helpers
scripts/         Source documentation verification

Full-workspace tests require Node.js 22+ (Doubao runtime requirement). verify:docs checks repository Markdown directly and also runs as part of npm test.

npm install
npm run build
npm run typecheck
npm test
npm run verify:docs

Protocol map: docs/SPECIFICATION.md (WeChat connect: docs/WECHAT-CONNECT.md). Package dist/**/*.d.ts files define interfaces, skills/ guides consumer AI, and core examples/ contains runnable ESM pairing and message examples. Update both language guides, skills, and tests when public contracts change.

MIT © Nia Teams

Reviews (0)

No results found