pi-ai-bridge
Pi extension to delegate tasks to external AI CLIs (claude, codex, gemini) as background agents
Package details
Install pi-ai-bridge from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-ai-bridge- Package
pi-ai-bridge- Version
0.2.0- Published
- Jun 14, 2026
- Downloads
- not available
- Author
- barba2k2
- License
- MIT
- Types
- extension
- Size
- 26.4 KB
- Dependencies
- 1 dependency · 2 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-ai-bridge
A Pi extension that lets the Pi agent — and you — delegate work to other AI CLIs (claude, codex, gemini) as background, full-autonomy agents. The Pi model can call them on its own when useful, or you can trigger them with slash commands.
⚠️ Safety warning
Calls run with full autonomy (yolo) and in the background, and the external agent can read and edit files / run commands in the working directory:
claude -p … --dangerously-skip-permissionscodex exec … --dangerously-bypass-approvals-and-sandbox -C <cwd>gemini -p … --yolo
Use it only in repositories you trust. The working directory is always explicit (defaults to the session cwd), so the blast radius is that directory.
Install
pi install npm:pi-ai-bridge
This adds "npm:pi-ai-bridge" to ~/.pi/agent/settings.json packages.
Restart Pi to load it.
Tools (the model calls these)
| Tool | Purpose |
|---|---|
ask_ai({ provider, prompt, wait?, timeoutMs?, cwd?, model? }) |
Start an agent. Background by default (returns a jobId); pass wait: true to block and return the output inline. |
check_ai({ jobId, tailLines? }) |
Status + output tail of a job. |
list_ai() |
Recent / running jobs. |
cancel_ai({ jobId }) |
Kill a running job. |
Slash commands (you trigger these)
/ask <claude|codex|gemini> <prompt> start a background agent
/ask-wait <claude|codex|gemini> <prompt> run and show the output here (blocks)
/ai-jobs list jobs
/ai-result [id] [lines] show status + output (no id = latest job)
/ai-cancel <id> cancel a job
/ai-help list commands and providers
Providers
| Provider | Binary | Invocation |
|---|---|---|
| claude | claude |
claude -p <prompt> --dangerously-skip-permissions [--model <m>] |
| codex | codex |
codex exec <prompt> --dangerously-bypass-approvals-and-sandbox -C <cwd> [-m <m>] |
| gemini | gemini |
gemini -p <prompt> --yolo [-m <m>] |
The matching CLI must be installed and on your PATH.
Display
- Tool results are color-coded by status (green = done, red = failed, yellow = running, dim = canceled), with a bold header, via the runtime theme.
- A "agents running" widget appears below the input while background agents are active, showing provider, job id and elapsed time — similar to background tasks in Claude Code.
Job state
Background jobs are tracked in ~/.pi/agent/ai-bridge/jobs/ as <id>.json
(metadata) and <id>.log (combined stdout+stderr). Because jobs are spawned
detached with state on disk, they survive a Pi restart.
Local development
npm install
npm run check # type-check
npm test # unit tests (providers + jobs)
pi -e ./src/index.ts # load the extension from this checkout
License
MIT