@1presence/bridge 0.56.0 → 0.58.0

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/dist/claude.js CHANGED
@@ -206,6 +206,20 @@ function formatRateLimitNotice(status, resetsAt) {
206
206
  ? `Approaching your usage limit — window resets around ${when}.`
207
207
  : 'Approaching your usage limit for this period.';
208
208
  }
209
+ /**
210
+ * Copy for an in-flight retry notice. The SDK retries retryable upstream
211
+ * failures (529 overloaded / 5xx / some 429s) with exponential backoff, which
212
+ * can leave a turn apparently frozen for tens of seconds. We surface a concise,
213
+ * ephemeral status line so the user knows the turn is alive and waiting — never
214
+ * the raw provider error body. A 529 is upstream *overload*, not the user's own
215
+ * quota, so we phrase it as "busy", not "rate limited".
216
+ */
217
+ function formatRetryNotice(attempt, maxRetries, delayMs) {
218
+ const secs = typeof delayMs === 'number' && delayMs > 0 ? Math.round(delayMs / 1000) : null;
219
+ const tail = secs ? ` Retrying in ~${secs}s` : ' Retrying';
220
+ const of = maxRetries > 0 ? ` (attempt ${attempt}/${maxRetries})` : '';
221
+ return `Claude's servers are busy.${tail}${of}…`;
222
+ }
209
223
  // ─── Prompt construction ─────────────────────────────────────────────────────────
210
224
  //
211
225
  // The gateway pushes the FULL conversation (sanitised via @presence/shared
@@ -639,11 +653,20 @@ export function spawnClaude(params) {
639
653
  }
640
654
  else if (subtype === 'api_retry') {
641
655
  // The SDK retries retryable API failures (5xx / overloaded / some
642
- // 429s) before giving up. Log each attempt with its status + bucket
643
- // so a turn that eventually dies after retries leaves a full trail
644
- // in all modes, not just verbose. Diagnostic only; never forwarded.
656
+ // 429s) before giving up, with exponential backoff that can leave a
657
+ // turn apparently frozen for tens of seconds. Log each attempt with
658
+ // its status + bucket so a turn that eventually dies after retries
659
+ // leaves a full trail — in all modes, not just verbose.
645
660
  const r = m;
646
661
  process.stderr.write(paint(SECTION_COLORS.result, `[bridge] api retry ${r.attempt ?? '?'}/${r.max_retries ?? '?'}${r.error_status != null ? ` (${r.error_status})` : ''}: ${r.error ?? 'unknown'}${r.retry_delay_ms != null ? `, next in ${r.retry_delay_ms}ms` : ''}`) + '\n');
662
+ // Surface an ephemeral status line to the chat so the user sees the
663
+ // turn is alive and waiting, not frozen. Gated to attempt ≥ 2 (and a
664
+ // perceptible delay) so a single sub-second transient self-heals
665
+ // silently; only a sustained upstream overload reaches the user.
666
+ const attempt = r.attempt ?? 0;
667
+ if (attempt >= 2 || (r.retry_delay_ms ?? 0) >= 2000) {
668
+ onNotice?.(formatRetryNotice(attempt, r.max_retries ?? 0, r.retry_delay_ms));
669
+ }
647
670
  }
648
671
  break;
649
672
  }
package/dist/config.js CHANGED
@@ -76,23 +76,25 @@ function detectClaudeDefaultModel() {
76
76
  // The fixed menu — keep the option count small so the timeout default is easy
77
77
  // to glance at. Option 1's `model: null` means "let Claude Code pick" (no
78
78
  // `--model` flag passed to the subprocess).
79
- // NB: no 1M-context (`[1m]`) variant here. The bridge always runs on the user's
80
- // claude.ai subscription it strips ANTHROPIC_API_KEY (see claude.ts) so there
81
- // is no API-key path. The 1M context window is a tier-gated API beta and is NOT
82
- // available on subscription auth, so selecting it makes EVERY turn fail with an
83
- // unclassifiable `400 / "unknown"` before the model responds. It used to be the
84
- // menu default, which broke every default session. Keep this list to models a
85
- // subscription can actually serve. `num` must stay contiguous 1..N in array
86
- // order — the jump-key handler maps a typed digit `n` to `idx = n - 1`.
79
+ // NB on `[1m]` (1M-context Opus): the bridge always runs on the user's claude.ai
80
+ // subscription (it strips ANTHROPIC_API_KEY see claude.ts), and it is UNCONFIRMED
81
+ // whether the 1M context window (a tier-gated API beta) is servable on subscription
82
+ // auth. It is offered but is NOT the default auto-selecting a maybe-unsupported
83
+ // variant is the risk we avoid; deliberately picking it to test is fine. (An earlier
84
+ // every-turn `400 / "unknown"` was first blamed on this but was actually a tool-schema
85
+ // bug that hit every model — see vault/Bugs.md.) `num` must stay contiguous 1..N in
86
+ // array order — the jump-key handler maps a typed digit `n` to `idx = n - 1`.
87
87
  const MODEL_OPTIONS = [
88
88
  { num: 1, model: null, label: 'Use Claude Code default' },
89
89
  { num: 2, model: 'claude-opus-4-8', label: 'claude-opus-4-8' },
90
- { num: 3, model: 'claude-opus-4-7', label: 'claude-opus-4-7' },
91
- { num: 4, model: 'claude-sonnet-4-6', label: 'claude-sonnet-4-6' },
92
- { num: 5, model: 'claude-haiku-4-5', label: 'claude-haiku-4-5' },
90
+ { num: 3, model: 'claude-opus-4-8[1m]', label: 'claude-opus-4-8[1m] (1M context — experimental on subscription)' },
91
+ { num: 4, model: 'claude-opus-4-7', label: 'claude-opus-4-7' },
92
+ { num: 5, model: 'claude-sonnet-4-6', label: 'claude-sonnet-4-6' },
93
+ { num: 6, model: 'claude-haiku-4-5', label: 'claude-haiku-4-5' },
93
94
  ];
94
95
  const PROMPT_TIMEOUT_MS = 10_000;
95
- // Default to claude-opus-4-8 (the strongest model a subscription can serve).
96
+ // Default to plain claude-opus-4-8 (definitely servable on a subscription), not
97
+ // the experimental `[1m]` variant.
96
98
  const DEFAULT_OPTION_NUM = 2;
97
99
  function promptForModel(defaultModel) {
98
100
  return new Promise((resolve) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1presence/bridge",
3
- "version": "0.56.0",
3
+ "version": "0.58.0",
4
4
  "description": "Run 1Presence on your Mac and use your Claude.ai Pro subscription from any device",
5
5
  "type": "module",
6
6
  "bin": {