@vanillagreen/pi-claude-bridge 1.9.0 → 3.2.2
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 +43 -125
- package/bundle/connector-inventory.js +16 -3
- package/bundle/index.js +3743 -1810
- package/package.json +14 -23
- package/src/account-host.ts +112 -0
- package/src/account-router.ts +272 -0
- package/src/agents-md.ts +54 -10
- package/src/assistant-stream.ts +472 -66
- package/src/auth-presence.ts +6 -50
- package/src/bridge-commands.ts +86 -0
- package/src/bridge-state.ts +200 -15
- package/src/config.ts +170 -20
- package/src/connector-audit.ts +203 -0
- package/src/connector-cache.ts +148 -0
- package/src/connector-inventory.ts +66 -7
- package/src/connector-runtime.ts +158 -0
- package/src/connectors.ts +406 -19
- package/src/consume-query.ts +312 -0
- package/src/convert.ts +20 -10
- package/src/debug.ts +64 -6
- package/src/index.ts +901 -676
- package/src/models.ts +0 -7
- package/src/native-provider.ts +94 -0
- package/src/prompt-context.ts +5 -1
- package/src/query-options.ts +183 -0
- package/src/query-state.ts +490 -25
- package/src/query-teardown.ts +45 -0
- package/src/rate-limit.ts +48 -13
- package/src/request-lane.ts +36 -0
- package/src/sdk-query.ts +16 -0
- package/src/session-persistence.ts +370 -50
- package/src/tool-pairing-audit.ts +117 -0
- package/src/typebox-to-zod.ts +9 -3
package/README.md
CHANGED
|
@@ -3,18 +3,20 @@
|
|
|
3
3
|
Works with OAuth subscription, no API key, no errors.
|
|
4
4
|
|
|
5
5
|

|
|
6
|
-

|
|
7
7
|
|
|
8
|
-
Run Claude Code as
|
|
8
|
+
Run Claude Code as the `pi-claude` Pi provider while keeping Pi's tools and TUI.
|
|
9
9
|
|
|
10
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
11
|
|
|
12
12
|
## Highlights
|
|
13
13
|
|
|
14
|
-
- `claude
|
|
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
15
|
- Pi tool calls run on Pi; Claude Code handles reasoning.
|
|
16
16
|
- Tool-use turns block until Pi-delivered tool results reach Claude Code, including persistent subagent panes.
|
|
17
|
-
-
|
|
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.
|
|
18
20
|
- Thinking-level forwarding with summarized Opus thinking display.
|
|
19
21
|
- Optional Claude effort overrides (`xhigh` → `max` for Opus 4.8).
|
|
20
22
|
- MCP isolation and Claude cloud-MCP suppression to keep tokens lean.
|
|
@@ -23,6 +25,8 @@ Forked from [`elidickinson/pi-claude-bridge`](https://github.com/elidickinson/pi
|
|
|
23
25
|
|
|
24
26
|
## Install
|
|
25
27
|
|
|
28
|
+
Requires pi ≥ 0.81 (bridge 2.x registers through pi's native provider API, so pi shows the Claude models only while a Claude account is actually connected). On older pi, install `@vanillagreen/pi-claude-bridge@1.x` instead.
|
|
29
|
+
|
|
26
30
|
Via [npm](https://www.npmjs.com/package/@vanillagreen/pi-claude-bridge):
|
|
27
31
|
|
|
28
32
|
```bash
|
|
@@ -40,161 +44,75 @@ Restart Pi after installation.
|
|
|
40
44
|
|
|
41
45
|
## Prompt context
|
|
42
46
|
|
|
43
|
-
Default behavior matches upstream: append
|
|
47
|
+
Default behavior matches upstream: append your context file plus Pi's skills block to Claude Code's `claude_code` preset prompt. The context file is the nearest one found walking up from the working directory, falling back to `<PI_CODING_AGENT_DIR>/AGENTS.md`. Within each directory the bridge follows Pi's own order — `AGENTS.override.md`, then `AGENTS.md`, then `AGENTS.MD` — so an `AGENTS.override.md` replaces `AGENTS.md` in the same directory, exactly as it does for Pi itself. `CLAUDE.md` is deliberately not forwarded: Claude Code already loads it natively, so forwarding it would apply the same context twice.
|
|
44
48
|
|
|
45
49
|
Extra Pi context is off by default. Enable per item in the extension manager when you want Claude Code to see prompt blocks that other Pi extensions add to your session. Forwarded blocks are wrapped in explicit XML tags so Pi 0.75+ project-context boundaries do not bleed into adjacent sections.
|
|
46
50
|
|
|
47
51
|
## Settings
|
|
48
52
|
|
|
49
|
-
Open `/extensions:settings`; settings appear under the **Claude
|
|
50
|
-
|
|
51
|
-
Project settings in `.pi/settings.json` apply only after Pi marks the workspace trusted; before trust, vstack Pi extensions read user/global settings only.
|
|
52
|
-
|
|
53
|
-
### General
|
|
54
|
-
|
|
55
|
-
| Setting | What it does |
|
|
56
|
-
| --- | --- |
|
|
57
|
-
| Enable Claude bridge provider | Register `claude-bridge/*` models. Reload required. |
|
|
58
|
-
|
|
59
|
-
### Base prompt
|
|
60
|
-
|
|
61
|
-
| Setting | What it does |
|
|
62
|
-
| --- | --- |
|
|
63
|
-
| Forward AGENTS.md + skills | Append AGENTS.md and Pi's skills block. |
|
|
64
|
-
|
|
65
|
-
### Pi prompt context
|
|
66
|
-
|
|
67
|
-
| Setting | What it does |
|
|
68
|
-
| --- | --- |
|
|
69
|
-
| Forward APPEND_SYSTEM.md | Forward project/global `APPEND_SYSTEM.md` content. |
|
|
53
|
+
Open `/extensions:settings`; settings appear under the **Pi Claude** tab. Project settings in `.pi/settings.json` apply only after Pi marks the workspace trusted; before trust, vstack Pi extensions read user/global settings only. The bridge also reads `claude-bridge.json` (`~/.pi/agent/claude-bridge.json`, and `.pi/claude-bridge.json` in a trusted project). Settings the bridge takes from one of those files are shown with the file that supplies them, so the editor reports the value the bridge resolves rather than the default. Changing the setting in the editor writes Pi settings, which take precedence over `claude-bridge.json`.
|
|
70
54
|
|
|
71
|
-
|
|
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. |
|
|
72
68
|
|
|
73
|
-
|
|
74
|
-
| --- | --- |
|
|
75
|
-
| Forward project agents hook | Forward `pi-agents-tmux` Project Agents/Subagents list. |
|
|
76
|
-
| Forward task panel hook | Forward `pi-task-panel` workflow reminders. |
|
|
77
|
-
| Forward caveman hook | Forward `pi-caveman` response-style directives. |
|
|
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`.
|
|
78
70
|
|
|
79
|
-
###
|
|
80
|
-
|
|
81
|
-
| Setting | What it does |
|
|
82
|
-
| --- | --- |
|
|
83
|
-
| Strict MCP config | Block filesystem MCP auto-loads; Pi owns tools. |
|
|
84
|
-
| Allow extra usage helper | Let the bridge launch Claude Code's `/extra-usage` flow when extra usage is required. Billing/admin approval still happens in Claude's browser page. |
|
|
85
|
-
| Fast mode | Enable Claude Code fast mode for bridge requests when the selected model supports it. |
|
|
86
|
-
| Force Claude effort | Override Pi's thinking-level mapping for every claude-bridge request. `none` keeps Pi's selected level; `max` sends Claude Code `--effort max`. |
|
|
87
|
-
| 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. |
|
|
88
|
-
| Claude executable path | Explicit `claude` binary path; empty auto-detects. |
|
|
89
|
-
|
|
90
|
-
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, to force only Opus 4.8 to `max`:
|
|
71
|
+
### Connectors
|
|
91
72
|
|
|
92
|
-
|
|
93
|
-
{"claude-opus-4-8":"max"}
|
|
94
|
-
```
|
|
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:
|
|
95
74
|
|
|
96
|
-
|
|
75
|
+
**Gmail** (search mail, read threads and messages), **Google Calendar** (check calendars and events), **Google Drive** (find and read files), **Slack** (search and read channels, threads, canvases, and people), **Jira and Confluence** (search and read issues, pages, and spaces). Anything else on the account (Figma, org-specific connectors) works the same way — nothing to configure per connector.
|
|
97
76
|
|
|
98
|
-
|
|
77
|
+
Sessions are **read-only** by default: the model can look things up, but cannot send, post, or change anything unless you explicitly turn writes on. Search/read/fetch/list tools stay available while mutating tools are denied, fail-closed across every connector on the account.
|
|
99
78
|
|
|
100
|
-
|
|
79
|
+
Connector tools run inside Claude Code rather than in Pi, so Pi shows the model's answer but no tool card for the lookup itself. Each lookup is still recorded in the session file as a `claude-bridge-connector-call` entry — the tool name, whether it succeeded, and how many bytes came back, never the contents. So "did it really look that up?" has an answer even though nothing is drawn in the transcript.
|
|
101
80
|
|
|
102
|
-
-
|
|
103
|
-
- **Google Calendar** — check calendars and events.
|
|
104
|
-
- **Google Drive** — find and read files.
|
|
105
|
-
- **Slack** — search and read channels, threads, canvases, and people.
|
|
106
|
-
- **Jira and Confluence** — search and read issues, pages, and spaces.
|
|
107
|
-
- Anything else on the account (Figma, org-specific connectors) works the same way — nothing to configure per connector.
|
|
108
|
-
|
|
109
|
-
Sessions are **read-only** by default: the model can look things up, but cannot send, post, or change anything unless you explicitly turn writes on below.
|
|
110
|
-
|
|
111
|
-
Extension-manager settings use flat package-scoped keys:
|
|
112
|
-
|
|
113
|
-
```json
|
|
114
|
-
{
|
|
115
|
-
"vstack": {
|
|
116
|
-
"extensionManager": {
|
|
117
|
-
"config": {
|
|
118
|
-
"@vanillagreen/pi-claude-bridge": {
|
|
119
|
-
"enableConnectors": true,
|
|
120
|
-
"connectorWriteMode": "deny"
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
```
|
|
81
|
+
`/pi-claude:connectors` lists the Claude account's installed claude.ai connectors by asking the account, not the model, so the answer is complete by construction.
|
|
127
82
|
|
|
128
|
-
|
|
83
|
+
Extension-manager settings use flat package-scoped keys under `vstack.extensionManager.config["@vanillagreen/pi-claude-bridge"]` in `settings.json`. Legacy `claude-bridge.json` configuration nests these options under `provider` (prompt-context flags under `promptContext`); the flat keys are accepted there too. Environment variables work with either format. Connectors remain off by default so Pi owns tool execution.
|
|
129
84
|
|
|
130
85
|
| Extension-manager key | Env var | Values | Default | What it does |
|
|
131
86
|
| --- | --- | --- | --- | --- |
|
|
132
87
|
| `enableConnectors` | `CLAUDE_BRIDGE_ENABLE_CONNECTORS` | `true`/`false` | off | Expose the account's connectors to the model (env OR config enables). |
|
|
133
88
|
| `connectorWriteMode` | `CLAUDE_BRIDGE_CONNECTOR_WRITE` | `deny`/`allow` | `deny` | When connectors are enabled, whether their WRITE tools are exposed. |
|
|
134
89
|
|
|
135
|
-
For both, the env var wins over config. `connectorWriteMode` only matters when connectors are enabled. Any value other than exactly `allow` is treated as `deny` (fail-closed).
|
|
90
|
+
For both, the env var wins over config. `connectorWriteMode` only matters when connectors are enabled. Any value other than exactly `allow` is treated as `deny` (fail-closed); set `allow` only for a one-shot write-executor session that has already obtained explicit user approval — never for an interactive connector chat.
|
|
136
91
|
|
|
137
|
-
|
|
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.
|
|
138
93
|
|
|
139
|
-
|
|
140
|
-
- **Runtime:** a `PreToolUse` hook blocks any connector tool classified as a write at call time, regardless of permission mode. Classification is **fail-closed** and covers the whole `mcp__claude_ai_<Server>__` space — a tool there is a write unless its name *begins* with a known read verb (`list`, `search`, `get`, `read`, `fetch`, …). The verb is matched as a word across naming styles, since connector servers differ: `search_threads` (Gmail), `slack_read_channel` (Slack, server-prefixed), `getJiraIssue` (Atlassian, camelCase) are all reads; a leading word that merely repeats the server name is skipped first. A name that opens with a read verb but also names a mutation (`getOrCreateChannel`) is a write, and so is a name that does not parse as `<server>__<tool>`. This covers both not-yet-known write tools (e.g. a future Gmail `send_message` or Drive `delete_file`) and connectors beyond the Google trio: claude.ai connectors attach account-wide, so a Slack/Atlassian/org-custom connector is visible in a connector session, and its writes are denied by the same rule.
|
|
141
|
-
|
|
142
|
-
Set `allow` only for a one-shot write-executor session that has already obtained explicit user approval — never for an interactive connector chat.
|
|
143
|
-
|
|
144
|
-
> **`allow` is per-process, not global.** Memsira's approved-write executor enables writes by setting `CLAUDE_BRIDGE_CONNECTOR_WRITE=allow` in the **child env of a dedicated one-shot process** that runs the single approved write and exits. Do not set `connectorWriteMode: "allow"` in persistent `settings.json` (or `allow` process-globally) for a shared/long-lived sidecar — that would make every connector session in that process write-capable, defeating the approval gate.
|
|
145
|
-
|
|
146
|
-
### Isolated mode (embedding hosts)
|
|
147
|
-
|
|
148
|
-
Host apps that embed the bridge and own every config dir explicitly can set `CLAUDE_BRIDGE_ISOLATED=1` in the bridge process env. Isolated mode disables every cwd/home discovery fallback so nothing outside the host-owned dirs is read:
|
|
149
|
-
|
|
150
|
-
- no `AGENTS.md` discovery, including cwd ancestors and the shared `<PI_CODING_AGENT_DIR>/AGENTS.md`;
|
|
151
|
-
- no extension-manager overlay from `<PI_CODING_AGENT_DIR>/settings.json`;
|
|
152
|
-
- no project `.pi/settings.json` / `.pi/claude-bridge.json` reads (even for trusted projects);
|
|
153
|
-
- no project `.pi/APPEND_SYSTEM.md`;
|
|
154
|
-
- no `$PATH` search for the `claude` executable — the host either pins `pathToClaudeCodeExecutable` or gets the Claude Agent SDK's bundled default.
|
|
155
|
-
|
|
156
|
-
Bridge settings come only from the authoritative `<PI_CODING_AGENT_DIR>/claude-bridge.json`; logs still resolve under `PI_CODING_AGENT_DIR`. Normal Pi CLI usage (flag unset) is unchanged.
|
|
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.
|
|
157
95
|
|
|
158
96
|
### Fable 5 and Opus 5 caveat
|
|
159
97
|
|
|
160
|
-
The bridge registers `claude
|
|
161
|
-
|
|
162
|
-
## Connector inventory
|
|
163
|
-
|
|
164
|
-
`/claude-bridge:connectors` lists the Claude account's installed claude.ai connectors by asking the account, not the model.
|
|
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.
|
|
165
99
|
|
|
166
|
-
|
|
100
|
+
## Multiple subscription profiles
|
|
167
101
|
|
|
168
|
-
|
|
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.
|
|
169
103
|
|
|
170
|
-
|
|
171
|
-
import { listAccountConnectors, resolveClaudeOAuth } from "@vanillagreen/pi-claude-bridge/connector-inventory";
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
Consuming apps that regenerate their vendored `package.json` with a closed exports map (`{".": "./bundle/index.js"}`) cannot reach that subpath — Node rejects every unlisted subpath *and* deep path under such a map. The same functions are therefore re-exported from the package root, which is the path those manifests allow:
|
|
175
|
-
|
|
176
|
-
```ts
|
|
177
|
-
import { listAccountConnectors } from "@vanillagreen/pi-claude-bridge";
|
|
178
|
-
```
|
|
104
|
+
## Account usage and rate limits
|
|
179
105
|
|
|
180
|
-
|
|
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.
|
|
181
107
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
Claude Code's `/extra-usage` local command works through the Claude Agent SDK. In Pi, use `/claude-bridge:extra` to run that flow from claude-bridge. Persist automatic launch on extra-usage errors with **Allow extra usage helper** in `/extensions:settings`.
|
|
185
|
-
|
|
186
|
-
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.
|
|
187
|
-
|
|
188
|
-
Allowed-warning rate-limit events are filtered before user notification. The bridge normalizes unambiguous numeric utilization (`0 < value < 1` as fractional, `1 < value <= 100` as percent), suppresses low or unit-ambiguous values such as exact `1`, and only shows a neutral warning at 80%+ instead of claiming an unverified `% used` value. Check Claude Code `/usage` for exact allowed-warning utilization.
|
|
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.
|
|
189
109
|
|
|
190
110
|
If Claude Code accepts a turn but produces no visible output, the bridge returns a retryable assistant error with a backoff hint instead of leaving Pi stuck waiting. Tune the first-output timeout with `CLAUDE_BRIDGE_STREAM_IDLE_TIMEOUT` (bare numbers are seconds; suffixes `ms`, `s`, and `m` are accepted). Default: `90s`; set `0` to disable.
|
|
191
111
|
|
|
192
112
|
## Debugging
|
|
193
113
|
|
|
194
|
-
Set `CLAUDE_BRIDGE_DEBUG=1` to write bridge logs to `<agent dir>/claude-bridge.log` and per-query Claude Code CLI logs under `<agent dir>/cc-cli-logs/`, where `<agent dir>` is `PI_CODING_AGENT_DIR` when set, else `~/.pi/agent`. Override the exact files with `CLAUDE_BRIDGE_DEBUG_PATH` / `CLAUDE_BRIDGE_DIAG_PATH`.
|
|
195
|
-
|
|
196
|
-
Tool-result integrity problems are surfaced even when debug logging is off. Pi shows an error notification and writes a diagnostic file to `<agent dir>/claude-bridge-diag.log` so lost or mismatched tool output is visible.
|
|
114
|
+
Set `CLAUDE_BRIDGE_DEBUG=1` to write bridge logs to `<agent dir>/claude-bridge.log` and per-query Claude Code CLI logs under `<agent dir>/cc-cli-logs/`, where `<agent dir>` is `PI_CODING_AGENT_DIR` when set, else `~/.pi/agent`. Override the exact files with `CLAUDE_BRIDGE_DEBUG_PATH` / `CLAUDE_BRIDGE_DIAG_PATH`. Startup failures include the resolved Claude executable and working directory, which makes missing binaries and wrong launch directories easier to fix.
|
|
197
115
|
|
|
198
|
-
|
|
116
|
+
Tool-result integrity problems always surface as a Pi error notification plus a `claude-bridge-integrity` custom entry in the pi session transcript (compact metadata only — never tool output), so lost or mismatched tool output stays analyzable from the session file alone. The on-disk diagnostic file (`<agent dir>/claude-bridge-diag.log`) is written only with `CLAUDE_BRIDGE_DEBUG=1` — like every other bridge disk log, it is opt-in.
|
|
199
117
|
|
|
200
|
-
|
|
118
|
+
Embedding hosts, contributor-facing stream/tool-result/startup diagnostics, and the host-side connector APIs are documented in [`DEVELOPMENT.md`](./DEVELOPMENT.md).
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
// src/connector-inventory.ts
|
|
2
2
|
var CONNECTOR_NS_PREFIX = "mcp__claude_ai_";
|
|
3
3
|
var DEFAULT_API_BASE = "https://api.anthropic.com";
|
|
4
|
+
var DEFAULT_PROXY_BASE = "https://mcp-proxy.anthropic.com/v1/mcp";
|
|
4
5
|
var OAUTH_BETA_HEADER = "oauth-2025-04-20";
|
|
6
|
+
function connectorServerName(connectorName) {
|
|
7
|
+
return `claude.ai ${connectorName.trim()}`;
|
|
8
|
+
}
|
|
9
|
+
function connectorProxyUrl(installedServerId, proxyBase = DEFAULT_PROXY_BASE) {
|
|
10
|
+
return `${trimTrailingSlashes(proxyBase)}/${encodeURIComponent(installedServerId)}`;
|
|
11
|
+
}
|
|
5
12
|
function connectorServerNamespace(connectorName) {
|
|
6
13
|
return `${CONNECTOR_NS_PREFIX}${connectorName.trim().replace(/\s+/g, "_")}__`;
|
|
7
14
|
}
|
|
8
15
|
function credentialCandidatePaths(env = process.env) {
|
|
9
16
|
const roots = [];
|
|
10
17
|
const configDir = env.CLAUDE_CONFIG_DIR?.trim();
|
|
11
|
-
if (configDir)
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
if (configDir) {
|
|
19
|
+
roots.push(configDir);
|
|
20
|
+
} else {
|
|
21
|
+
const home = env.HOME?.trim();
|
|
22
|
+
if (home) roots.push(`${home}/.claude`, home);
|
|
23
|
+
}
|
|
14
24
|
const seen = /* @__PURE__ */ new Set();
|
|
15
25
|
const paths = [];
|
|
16
26
|
for (const root of roots) {
|
|
@@ -103,6 +113,7 @@ async function listAccountConnectors(deps) {
|
|
|
103
113
|
name,
|
|
104
114
|
installedServerId: nonEmptyString(entry?.installedServerId),
|
|
105
115
|
directoryUuid: nonEmptyString(entry?.directoryUuid),
|
|
116
|
+
installState: nonEmptyString(entry?.installState),
|
|
106
117
|
description: nonEmptyString(entry?.description),
|
|
107
118
|
isAuthless: typeof entry?.isAuthless === "boolean" ? entry.isAuthless : void 0
|
|
108
119
|
});
|
|
@@ -129,6 +140,8 @@ function errorText(error) {
|
|
|
129
140
|
return error instanceof Error ? error.message : String(error);
|
|
130
141
|
}
|
|
131
142
|
export {
|
|
143
|
+
connectorProxyUrl,
|
|
144
|
+
connectorServerName,
|
|
132
145
|
connectorServerNamespace,
|
|
133
146
|
connectorsListUrl,
|
|
134
147
|
credentialCandidatePaths,
|