@viniciosrab/pi-claude-bridge 0.9.0 → 0.9.1-fork.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # pi-claude-bridge
2
2
 
3
- > **Fork note.** `@viniciosrab/pi-claude-bridge` is an automated mirror of [`pi-claude-bridge`](https://www.npmjs.com/package/pi-claude-bridge) by Eli Dickinson ([elidickinson/pi-claude-bridge](https://github.com/elidickinson/pi-claude-bridge)), rebuilt for each upstream release with one addition: the `provider.loadClaudeSettings` option ([upstream PR #142](https://github.com/elidickinson/pi-claude-bridge/pull/142)). Versions match upstream. Licensed MIT; original copyright and credit belong to Eli Dickinson. Fork: [viniciosrab/pi-claude-bridge](https://github.com/viniciosrab/pi-claude-bridge).
3
+ > **Fork note.** `@viniciosrab/pi-claude-bridge` is an automated mirror of [`pi-claude-bridge`](https://www.npmjs.com/package/pi-claude-bridge) by Eli Dickinson ([elidickinson/pi-claude-bridge](https://github.com/elidickinson/pi-claude-bridge)), rebuilt for each upstream release with fork-only additions: the `provider.loadClaudeSettings` option ([upstream PR #142](https://github.com/elidickinson/pi-claude-bridge/pull/142)) and the `provider.rateLimitWarnings` option. Versions match upstream; a `X.Y.(Z+1)-fork.N` version is upstream `X.Y.Z` with newer fork-only changes. Licensed MIT; original copyright and credit belong to Eli Dickinson. Fork: [viniciosrab/pi-claude-bridge](https://github.com/viniciosrab/pi-claude-bridge).
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@viniciosrab/pi-claude-bridge)](https://www.npmjs.com/package/@viniciosrab/pi-claude-bridge)
6
6
 
@@ -92,6 +92,7 @@ Config: `~/.pi/agent/claude-bridge.json` (global) or the project Pi config direc
92
92
  - `strictMcpConfig` — block MCP servers from `~/.claude.json` / `.mcp.json` (default `true`). Cloud MCP (Gmail/Drive via claude.ai OAuth) is always blocked.
93
93
  - `autoMemoryEnabled` — enable Claude Code's auto-memory system (default `false`)
94
94
  - `loadClaudeSettings` — load Claude Code's user/project/local settings in the provider's Claude Code subprocess (default `true`). Set `false` to skip them: settings-sourced hooks and plugins no longer run on every turn, which can noticeably cut tokens and latency when you have many configured. It also drops settings-sourced `env` and `apiKeyHelper`, so keep the default if you rely on those (e.g. Bedrock/Vertex setup in `settings.json`). OAuth login, pi tools and extensions are unaffected. Applies only to the provider path; AskClaude always loads settings.
95
+ - `rateLimitWarnings` — show Claude rate-limit notices in pi (default `true`): a usage warning at each 5% step once Claude Code reports `allowed_warning`, and a "rate limited" notice with the reset time when a request is rejected. Set `false` to hide both. A rejected request's failure is still named as a rate limit (so fallback chains keep working).
95
96
  - `pathToClaudeCodeExecutable` — path to the `claude` binary. Useful if your OS/filesystem has the SDK's bundled musl/glibc binaries in a place where they can't run. For example, with Nix you can set the binary to e.g. `"/home/you/.nix-profile/bin/claude"`.
96
97
 
97
98
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viniciosrab/pi-claude-bridge",
3
- "version": "0.9.0",
3
+ "version": "0.9.1-fork.1",
4
4
  "private": false,
5
5
  "description": "Pi extension that uses Claude Code (via Agent SDK) as a model provider and adds an AskClaude tool.",
6
6
  "keywords": [
package/src/config.ts CHANGED
@@ -28,6 +28,9 @@ export interface Config {
28
28
  // Set to false to stop the provider's Claude Code subprocess from loading
29
29
  // user/project/local settings (hooks, plugins, env, apiKeyHelper).
30
30
  loadClaudeSettings?: boolean;
31
+ // Set to false to hide the Claude rate-limit notices (usage warnings and
32
+ // "rate limited") shown in pi. Failures are still named as rate limits.
33
+ rateLimitWarnings?: boolean;
31
34
  pathToClaudeCodeExecutable?: string;
32
35
  // Subscription plan tier. Setting to "max" enables Opus 4.6 at 1M context
33
36
  plan?: "pro" | "max";
@@ -61,6 +64,12 @@ export function providerSettingSourcesOption(provider: Config["provider"] = {}):
61
64
  return provider.loadClaudeSettings === false ? { settingSources: [] } : {};
62
65
  }
63
66
 
67
+ /** Whether to show the Claude rate-limit notices in pi. Absent keeps them on;
68
+ * `rateLimitWarnings: false` hides them. */
69
+ export function rateLimitNoticesEnabled(provider: Config["provider"] = {}): boolean {
70
+ return provider.rateLimitWarnings !== false;
71
+ }
72
+
64
73
  export function globalConfigPath(): string {
65
74
  return join(getAgentDir(), "claude-bridge.json");
66
75
  }
package/src/index.ts CHANGED
@@ -15,7 +15,7 @@ import { verifyWrittenSession as _verifyWrittenSession } from "./session-verify.
15
15
  import { extractAllToolResults as _extractAllToolResults, type McpResult } from "./extract-tool-results.js";
16
16
  import { QueryContext, ctx } from "./query-state.js";
17
17
  import { makePromptStream, userMessage, type PromptStream } from "./prompt-stream.js";
18
- import { claudeCodeSettings, loadConfig, markStartupNoticeShown, providerSettingSourcesOption, type Config } from "./config.js";
18
+ import { claudeCodeSettings, loadConfig, markStartupNoticeShown, providerSettingSourcesOption, rateLimitNoticesEnabled, type Config } from "./config.js";
19
19
  import {
20
20
  collectPromptSkills,
21
21
  projectPromptCapture,
@@ -1485,6 +1485,8 @@ async function consumeQuery(
1485
1485
  if (message.type === "rate_limit_event") {
1486
1486
  const info = (message as any).rate_limit_info;
1487
1487
  debug("consumeQuery: rate_limit_event", JSON.stringify(info).slice(0, 300));
1488
+ // provider.rateLimitWarnings: false hides the notices; the bookkeeping below still runs.
1489
+ const showNotices = rateLimitNoticesEnabled(providerSettings);
1488
1490
  if (info?.status === "rejected") {
1489
1491
  // Held so the failure Claude Code sends next can be named as a rate limit.
1490
1492
  queryCtx.rateLimitRejection = info;
@@ -1494,7 +1496,9 @@ async function consumeQuery(
1494
1496
  queryCtx.lastRateLimitWarnThreshold = undefined;
1495
1497
  // resetsAt is Unix seconds, not milliseconds.
1496
1498
  const resetsAt = info.resetsAt ? new Date(info.resetsAt * 1000).toLocaleTimeString() : "unknown";
1497
- piUI?.notify(`Claude rate limited (${info.rateLimitType ?? "unknown"}) — resets at ${resetsAt}`, "warning");
1499
+ if (showNotices) {
1500
+ piUI?.notify(`Claude rate limited (${info.rateLimitType ?? "unknown"}) — resets at ${resetsAt}`, "warning");
1501
+ }
1498
1502
  } else if (info?.status === "allowed") {
1499
1503
  // Back under the threshold (window reset) — re-arm the warning dedupe.
1500
1504
  queryCtx.lastRateLimitWarnStep = null;
@@ -1509,7 +1513,9 @@ async function consumeQuery(
1509
1513
  if (rose || info.surpassedThreshold !== queryCtx.lastRateLimitWarnThreshold) {
1510
1514
  queryCtx.lastRateLimitWarnStep = step;
1511
1515
  queryCtx.lastRateLimitWarnThreshold = info.surpassedThreshold;
1512
- piUI?.notify(`Claude rate limit warning: ${percent}% used (${info.rateLimitType ?? ""})`, "warning");
1516
+ if (showNotices) {
1517
+ piUI?.notify(`Claude rate limit warning: ${percent}% used (${info.rateLimitType ?? ""})`, "warning");
1518
+ }
1513
1519
  }
1514
1520
  }
1515
1521
  continue;