@vanillagreen/pi-claude-bridge 3.2.2 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -90
- package/bundle/index.js +33818 -25171
- package/package.json +8 -7
- package/src/account-router.ts +5 -5
- package/src/assistant-stream.ts +94 -79
- package/src/auth-presence.ts +1 -2
- package/src/bridge-commands.ts +2 -2
- package/src/bridge-state.ts +7 -8
- package/src/config.ts +20 -12
- package/src/connector-audit.ts +7 -11
- package/src/connector-cache.ts +6 -7
- package/src/connector-inventory.ts +5 -7
- package/src/connector-runtime.ts +8 -8
- package/src/connectors.ts +34 -35
- package/src/consume-query.ts +3 -3
- package/src/convert.ts +1 -1
- package/src/debug.ts +2 -2
- package/src/index.ts +30 -31
- package/src/models.ts +5 -5
- package/src/query-options.ts +4 -4
- package/src/query-state.ts +38 -44
- package/src/query-teardown.ts +3 -3
- package/src/rate-limit.ts +2 -2
- package/src/request-lane.ts +1 -1
- package/src/session-persistence.ts +10 -10
- package/src/tool-mapping.ts +41 -8
- package/src/tool-pairing-audit.ts +5 -6
package/README.md
CHANGED
|
@@ -1,118 +1,65 @@
|
|
|
1
|
-
# pi-claude-bridge
|
|
1
|
+
# @vanillagreen/pi-claude-bridge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Pi provider that uses a logged-in Claude Code account through the Claude Agent SDK. You keep Pi's terminal interface and tools while Claude Code handles model requests.
|
|
4
4
|
|
|
5
|
-

|
|
7
|
-
|
|
8
|
-
Run Claude Code as the `pi-claude` Pi provider while keeping Pi's tools and TUI.
|
|
9
|
-
|
|
10
|
-
Forked from [`elidickinson/pi-claude-bridge`](https://github.com/elidickinson/pi-claude-bridge). This fork removes the AskClaude tool and adds opt-in forwarding for Pi prompt context.
|
|
11
|
-
|
|
12
|
-
## Highlights
|
|
13
|
-
|
|
14
|
-
- `pi-claude/claude-fable-5`, Opus 5, Opus 4.8, Opus 4.7, Opus 4.6, Sonnet 5, Sonnet 4.6, and Haiku in `/model`. `/model opus` selects Opus 5; older Opus releases stay selectable by full ID.
|
|
15
|
-
- Pi tool calls run on Pi; Claude Code handles reasoning.
|
|
16
|
-
- Tool-use turns block until Pi-delivered tool results reach Claude Code, including persistent subagent panes.
|
|
17
|
-
- Parallel conversations and subagents keep independent request, abort, tool-loop, and Claude-session state.
|
|
18
|
-
- Session continuity across normal turns, `/compact`, tree navigation, abort recovery, and account-profile changes.
|
|
19
|
-
- Optional companion integration for usage-aware subscription account rotation without copying the bridge engine.
|
|
20
|
-
- Thinking-level forwarding with summarized Opus thinking display.
|
|
21
|
-
- Optional Claude effort overrides (`xhigh` → `max` for Opus 4.8).
|
|
22
|
-
- MCP isolation and Claude cloud-MCP suppression to keep tokens lean.
|
|
23
|
-
- Optional access to your Claude account's connectors — Gmail, Calendar, Drive, Slack, Jira, Confluence — read-only by default.
|
|
24
|
-
- Opt-in forwarding of `APPEND_SYSTEM.md` and recognized Pi prompt hooks.
|
|
5
|
+
 
|
|
25
6
|
|
|
26
7
|
## Install
|
|
27
8
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Via [npm](https://www.npmjs.com/package/@vanillagreen/pi-claude-bridge):
|
|
9
|
+
- npm: `pi install npm:@vanillagreen/pi-claude-bridge`.
|
|
10
|
+
- kendex: add the declaration below to the project's `kendex.toml`, or to `~/.config/kendex/kendex.toml` for user scope. Run `kendex update-pi`.
|
|
31
11
|
|
|
32
|
-
```
|
|
33
|
-
pi
|
|
12
|
+
```toml
|
|
13
|
+
[pi-extensions."@vanillagreen/pi-claude-bridge"]
|
|
14
|
+
source = "kendex"
|
|
34
15
|
```
|
|
35
16
|
|
|
36
|
-
|
|
17
|
+
Restart Pi after installation. Use `kendex update-pi --check` to preview the installation. A Claude Code login is required. Make `claude` available on `PATH` or set its executable path below.
|
|
37
18
|
|
|
38
|
-
|
|
39
|
-
cargo install --git https://github.com/vanillagreencom/vstack.git vstack
|
|
40
|
-
vstack add vanillagreencom/vstack --pi-extension pi-claude-bridge --harness pi -y
|
|
41
|
-
```
|
|
19
|
+
Fable 5.1 requires [Claude Code 2.1.255 or later](https://code.claude.com/docs/en/model-config#work-with-fable). This includes any executable chosen through `pathToClaudeCodeExecutable` or found on `PATH`, which takes precedence over the SDK's bundled CLI. Account access and usage-credit requirements still apply.
|
|
42
20
|
|
|
43
|
-
|
|
21
|
+
## Features
|
|
44
22
|
|
|
45
|
-
|
|
23
|
+
- Select Claude models from Pi's model menu.
|
|
24
|
+
- Run Pi tool calls during Claude conversations.
|
|
25
|
+
- Resume the Claude conversation across Pi turns.
|
|
26
|
+
- Configure model effort and forwarded prompt context.
|
|
27
|
+
- Optionally use the Claude account's connectors.
|
|
46
28
|
|
|
47
|
-
|
|
29
|
+
## How it works
|
|
48
30
|
|
|
49
|
-
|
|
31
|
+
You select a pi-claude model in Pi. Select **Claude Fable 5.1** (`pi-claude/claude-fable-5-1`) for Fable. The bridge starts or resumes Claude Code through the Agent SDK. It sends the prompt and makes Pi's tools available to Claude Code. Tool calls return to Pi for execution, then their results return to Claude Code. Pi displays the response and saves the Claude session identifier.
|
|
50
32
|
|
|
51
33
|
## Settings
|
|
52
34
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
| Group | Setting | What it does |
|
|
56
|
-
| --- | --- | --- |
|
|
57
|
-
| General | Enable Pi Claude provider | Register `pi-claude/*` models. Reload required. |
|
|
58
|
-
| Base prompt | Forward AGENTS.md + skills | Append the nearest context file (`AGENTS.override.md`, `AGENTS.md`, or `AGENTS.MD`) and Pi's skills block. |
|
|
59
|
-
| Pi prompt context | Forward APPEND_SYSTEM.md | Forward project/global `APPEND_SYSTEM.md` content. |
|
|
60
|
-
| Pi prompt hooks | Forward project agents hook | Forward `pi-agents-tmux` Project Agents/Subagents list. |
|
|
61
|
-
| Pi prompt hooks | Forward task panel hook | Forward `pi-task-panel` workflow reminders. |
|
|
62
|
-
| Pi prompt hooks | Forward caveman hook | Forward `pi-caveman` response-style directives. |
|
|
63
|
-
| Claude Code | Strict MCP config | Block filesystem MCP auto-loads; Pi owns tools. |
|
|
64
|
-
| Claude Code | Fast mode | Enable Claude Code fast mode for bridge requests when the selected model and account support it. |
|
|
65
|
-
| Claude Code | Force Claude effort | Override Pi's thinking-level mapping for every Pi Claude request. `none` keeps Pi's selected level; `max` sends Claude Code `--effort max`. |
|
|
66
|
-
| Claude Code | Model effort overrides | JSON object mapping model IDs to Claude Code efforts, e.g. `{"claude-opus-4-8":"max"}`. Per-model entries beat the global force setting. |
|
|
67
|
-
| Claude Code | Claude executable path | Explicit `claude` binary path; empty auto-detects. |
|
|
68
|
-
|
|
69
|
-
Pi 0.80.6 and newer expose native `max` thinking. Fable 5, Opus 5, and Sonnet 5 bridge metadata forward both `xhigh` and `max`; the generic bridge fallback also maps `max` directly. **Force Claude effort** and **Model effort overrides** remain available when one bridge model needs a different fixed effort — for example `{"claude-opus-4-8":"max"}` to force only Opus 4.8. Keys may be bare model IDs (`claude-opus-4-8`), `pi-claude/<id>`, or `*` for all bridge models. Values are `low`, `medium`, `high`, `xhigh`, or `max`.
|
|
70
|
-
|
|
71
|
-
### Connectors
|
|
72
|
-
|
|
73
|
-
Turn this on and the model can use whatever your Claude account already has connected — the same connectors you use in the Claude app, now inside Pi:
|
|
35
|
+
The settings editor writes project values to `.pi/settings.json`. The default user file is `~/.pi/agent/settings.json`. `PI_CODING_AGENT_DIR` changes the user directory. Package values are stored under `kendex.extensionManager.config["@vanillagreen/pi-claude-bridge"]`.
|
|
74
36
|
|
|
75
|
-
**
|
|
37
|
+
Open `/extensions:settings`; settings appear under the **Pi Claude** tab, and `/pi-claude` opens the same tab. Project settings in `.pi/settings.json` apply only after Pi marks the workspace trusted. The bridge also reads `claude-bridge.json` in `~/.pi/agent` and in a trusted project's `.pi/`; a value taken from one of those files is shown with the file that supplies it, and editing it in the panel writes Pi settings, which win.
|
|
76
38
|
|
|
77
|
-
|
|
39
|
+
- `enabled`: register the `pi-claude/*` models; reload required.
|
|
40
|
+
- `appendSystemPrompt`: the context file and skills block described above.
|
|
41
|
+
- `includeAppendSystemPromptMd`, `includeProjectAgentsHook`, `includeTaskPanelHook`, `includeCavemanHook`: forward `APPEND_SYSTEM.md` and the prompt blocks of `pi-agents-tmux`, `pi-task-panel` and `pi-caveman`.
|
|
42
|
+
- `strictMcpConfig`, `fastMode`, `pathToClaudeCodeExecutable`: how the Claude Code subprocess is launched.
|
|
43
|
+
- `forceEffort`, `modelEffortOverrides`: pin a Claude effort for every request or per model. Override keys are bare ids (`claude-opus-4-8`), `pi-claude/<id>` or `*`; values are `low`, `medium`, `high`, `xhigh` or `max`; a per-model entry beats the global force.
|
|
78
44
|
|
|
79
|
-
|
|
45
|
+
Environment variables:
|
|
80
46
|
|
|
81
|
-
|
|
47
|
+
- `CLAUDE_BRIDGE_STREAM_IDLE_TIMEOUT`: how long a turn may stay silent before its first output; bare numbers are seconds, `ms`, `s` and `m` suffixes are accepted, `0` disables.
|
|
48
|
+
- `CLAUDE_BRIDGE_DEBUG=1`: write the bridge log, the integrity diagnostics and per-query Claude Code CLI logs under the Pi agent directory; `CLAUDE_BRIDGE_DEBUG_PATH` and `CLAUDE_BRIDGE_DIAG_PATH` move the two log files. Nothing is written to disk without it.
|
|
49
|
+
- `CLAUDE_BRIDGE_ISOLATED=1`: for embedding hosts that own every config directory; the bridge then reads nothing from the working directory or home. Details in [DEVELOPMENT.md](DEVELOPMENT.md).
|
|
82
50
|
|
|
83
|
-
|
|
51
|
+
Tool-result integrity problems always surface as a Pi error notification plus a metadata-only `claude-bridge-integrity` entry in the Pi session file, so a lost tool result can be analysed from the session alone.
|
|
84
52
|
|
|
85
|
-
|
|
86
|
-
| --- | --- | --- | --- | --- |
|
|
87
|
-
| `enableConnectors` | `CLAUDE_BRIDGE_ENABLE_CONNECTORS` | `true`/`false` | off | Expose the account's connectors to the model (env OR config enables). |
|
|
88
|
-
| `connectorWriteMode` | `CLAUDE_BRIDGE_CONNECTOR_WRITE` | `deny`/`allow` | `deny` | When connectors are enabled, whether their WRITE tools are exposed. |
|
|
53
|
+
Maintainer notes, the embedding and account-router contracts, and the test suites are in [DEVELOPMENT.md](DEVELOPMENT.md).
|
|
89
54
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
> **User scope + env only.** These two keys are resolved from user-scope configuration (`<PI_CODING_AGENT_DIR>/settings.json`, `<PI_CODING_AGENT_DIR>/claude-bridge.json`) and the env vars — never from a project's checked-in `.pi/settings.json` or `.pi/claude-bridge.json`, even when the project is trusted for ordinary options. Connectors expose live account data (mail, calendar, files), so a repo you clone must not be able to switch them on or un-gate their writes just by being the cwd.
|
|
93
|
-
|
|
94
|
-
Connectors mode also makes the child Claude Code resolve its filesystem settings (with them off, the child runs fully isolated). Only **user-scope** settings are loaded; project/local scope (a checkout's `.claude/settings.json`) is deliberately excluded. Setting `provider.settingSources` in bridge config still overrides this verbatim, but listing `"project"`/`"local"` there reopens that surface — only do it for checkouts you trust.
|
|
95
|
-
|
|
96
|
-
### Fable 5 and Opus 5 caveat
|
|
97
|
-
|
|
98
|
-
The bridge registers `pi-claude/claude-fable-5`, `pi-claude/claude-opus-5`, `pi-claude/claude-sonnet-5`, and `pi-claude/claude-opus-4-8` even when Pi's Anthropic model registry has not shipped those entries yet. Fable 5 and Opus 5 both run classifiers that can decline a turn, so for each of them the bridge asks Claude Code to use Opus 4.8 as the availability fallback and preserves Claude Code's content-safety fallback events so Pi labels rerouted turns as Opus 4.8. Content-safety fallback still depends on Claude Code's own Fable 5 support; use Claude Code 2.1.170 or newer, and set `ANTHROPIC_DEFAULT_FABLE_MODEL` / `ANTHROPIC_DEFAULT_OPUS_MODEL` yourself when routing provider-specific model IDs through Bedrock, Vertex, or Foundry.
|
|
99
|
-
|
|
100
|
-
## Multiple subscription profiles
|
|
101
|
-
|
|
102
|
-
An optional companion extension can provide account profiles through the bridge's versioned account-router integration. For each fresh Claude request, the bridge launches the Agent SDK subprocess with the selected profile's `CLAUDE_CONFIG_DIR`; Claude session files, connector inventory, and resume IDs remain account-scoped. When an account reports a rejected rate limit (or another classified pre-output failure), the bridge rebuilds the Claude session from Pi history under the next profile and retries the prompt — but never once text, thinking, a Pi tool call, or a child-executed connector call has begun, so a request cannot duplicate tool side effects on another account. The companion owns profile metadata, utilization ranking, and cooldown persistence; the bridge remains the SDK/stream/session engine.
|
|
103
|
-
|
|
104
|
-
## Account usage and rate limits
|
|
105
|
-
|
|
106
|
-
Extra Usage is owned by Claude's account settings. The bridge neither changes that setting nor blocks Claude Code's native account behavior — if the account has Extra Usage enabled on claude.ai, the child Claude Code uses it normally. If Claude rejects a request because the current allowance is exhausted, a managed account router treats it as a model-scoped limit and can try another account.
|
|
107
|
-
|
|
108
|
-
When Claude Code reports a rate-limit reset time, the bridge shows one clear `[rate-limit]` warning with timezone context and avoids repeating the same error line. If `pi-qol` is installed, it can use the reset time to resume later. Allowed-warning rate-limit events are filtered before user notification: the bridge shows a neutral warning at 80%+ utilization instead of claiming an unverified `% used` value. Check Claude Code `/usage` for exact allowed-warning utilization.
|
|
55
|
+
## Prompt context
|
|
109
56
|
|
|
110
|
-
|
|
57
|
+
The bridge sends the nearest context file and Pi's skills list with the prompt. It checks `AGENTS.override.md`, `AGENTS.md` and `AGENTS.MD` while walking up from the working directory. Claude Code loads its own CLAUDE.md files. Use the prompt settings above to forward other Pi extension instructions.
|
|
111
58
|
|
|
112
|
-
##
|
|
59
|
+
## Connectors
|
|
113
60
|
|
|
114
|
-
|
|
61
|
+
Connectors are disabled by default. Set `enableConnectors` in user settings, user `claude-bridge.json`, or the `CLAUDE_BRIDGE_ENABLE_CONNECTORS` environment variable. Project settings cannot enable them.
|
|
115
62
|
|
|
116
|
-
|
|
63
|
+
Connector access is read-only unless `connectorWriteMode` is exactly `allow`. Set `CLAUDE_BRIDGE_CONNECTOR_WRITE=allow` only for a dedicated process running an approved write. Keep it out of persistent settings. Use `/pi-claude:connectors` to list the account's connectors.
|
|
117
64
|
|
|
118
|
-
|
|
65
|
+
With connectors enabled, Claude Code loads user settings. An explicit `provider.settingSources` list in `claude-bridge.json` changes that selection. Including project or local settings lets those files affect the subprocess.
|