@andorra-labs/code 0.1.13 → 0.1.14

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.
Files changed (105) hide show
  1. package/dist/src/account-presentation.js +4 -1
  2. package/dist/src/agent-execution.js +300 -140
  3. package/dist/src/agent-mcp.js +2 -2
  4. package/dist/src/andorra/endpoint.d.ts +7 -0
  5. package/dist/src/andorra/endpoint.js +46 -0
  6. package/dist/src/andorra/entry.d.ts +21 -0
  7. package/dist/src/andorra/entry.js +100 -0
  8. package/dist/src/andorra/errors.d.ts +2 -0
  9. package/dist/src/andorra/errors.js +39 -0
  10. package/dist/src/andorra/hosted.d.ts +52 -0
  11. package/dist/src/andorra/hosted.js +126 -0
  12. package/dist/src/andorra/monitor.d.ts +151 -0
  13. package/dist/src/andorra/monitor.js +393 -0
  14. package/dist/src/andorra/notices.d.ts +7 -0
  15. package/dist/src/andorra/notices.js +15 -0
  16. package/dist/src/andorra/opt-in.d.ts +58 -0
  17. package/dist/src/andorra/opt-in.js +112 -0
  18. package/dist/src/andorra/request-watch.d.ts +6 -0
  19. package/dist/src/andorra/request-watch.js +10 -0
  20. package/dist/src/andorra/state.d.ts +86 -0
  21. package/dist/src/andorra/state.js +238 -0
  22. package/dist/src/andorra/terminal.d.ts +68 -0
  23. package/dist/src/andorra/terminal.js +125 -0
  24. package/dist/src/andorra/usage-format.d.ts +9 -0
  25. package/dist/src/andorra/usage-format.js +19 -0
  26. package/dist/src/anthropic-credentials.js +9 -1
  27. package/dist/src/app-server/protocol.d.ts +6 -2
  28. package/dist/src/app-server/protocol.js +1 -1
  29. package/dist/src/app-server.d.ts +27 -0
  30. package/dist/src/app-server.js +292 -85
  31. package/dist/src/auth/AuthManager.d.ts +9 -0
  32. package/dist/src/auth/AuthManager.js +161 -21
  33. package/dist/src/auth/deployment.d.ts +1 -0
  34. package/dist/src/auth/deployment.js +1 -0
  35. package/dist/src/auth/index.d.ts +1 -1
  36. package/dist/src/auth/index.js +1 -1
  37. package/dist/src/auth/store.d.ts +26 -0
  38. package/dist/src/auth/store.js +34 -1
  39. package/dist/src/browser-runner.js +1 -1
  40. package/dist/src/browser-stealth.d.ts +19 -1
  41. package/dist/src/browser-stealth.js +23 -3
  42. package/dist/src/browser-ui/tokens.css +4 -4
  43. package/dist/src/browser-view.d.ts +65 -0
  44. package/dist/src/browser-view.js +229 -16
  45. package/dist/src/cli.js +43 -26
  46. package/dist/src/command-screens.d.ts +17 -1
  47. package/dist/src/command-screens.js +192 -21
  48. package/dist/src/commands.d.ts +7 -1
  49. package/dist/src/commands.js +78 -27
  50. package/dist/src/config.d.ts +6 -1
  51. package/dist/src/config.js +86 -3
  52. package/dist/src/dashboard-view.d.ts +2 -0
  53. package/dist/src/dashboard-view.js +11 -2
  54. package/dist/src/decision/PreparedSteps.js +1 -1
  55. package/dist/src/decision/applyToolMenu.js +1 -1
  56. package/dist/src/decision/toolFamilies.js +1 -1
  57. package/dist/src/decision/types.d.ts +1 -0
  58. package/dist/src/graph-health.d.ts +11 -0
  59. package/dist/src/graph-health.js +36 -4
  60. package/dist/src/graph-manager-chat.d.ts +33 -0
  61. package/dist/src/graph-manager-chat.js +159 -5
  62. package/dist/src/graph-runner.js +27 -0
  63. package/dist/src/graph-selection.js +2 -1
  64. package/dist/src/graph-ui/app.js +25 -2
  65. package/dist/src/graph-ui/manager.js +40 -5
  66. package/dist/src/graph-ui/style.css +5 -2
  67. package/dist/src/graph-ui/tokens.css +4 -4
  68. package/dist/src/graphs.js +1 -3
  69. package/dist/src/hardened-runtime.js +1 -1
  70. package/dist/src/membership-errors.js +1 -1
  71. package/dist/src/membership.d.ts +10 -2
  72. package/dist/src/membership.js +20 -6
  73. package/dist/src/model-context-windows.d.ts +2 -0
  74. package/dist/src/model-context-windows.js +24 -0
  75. package/dist/src/model-health-cache.js +1 -1
  76. package/dist/src/model-metadata.d.ts +1 -0
  77. package/dist/src/model-metadata.js +40 -3
  78. package/dist/src/palette.d.ts +1 -0
  79. package/dist/src/palette.js +1 -1
  80. package/dist/src/permissions.js +17 -4
  81. package/dist/src/provider-connection.js +15 -0
  82. package/dist/src/provider-settings.d.ts +16 -1
  83. package/dist/src/provider-settings.js +36 -20
  84. package/dist/src/providers.d.ts +14 -2
  85. package/dist/src/providers.js +69 -11
  86. package/dist/src/react-runtime.js +12 -7
  87. package/dist/src/remote/engine-pool.js +5 -4
  88. package/dist/src/run-control.d.ts +2 -2
  89. package/dist/src/run-control.js +9 -6
  90. package/dist/src/runtime.d.ts +2 -0
  91. package/dist/src/runtime.js +2 -1
  92. package/dist/src/sessions.d.ts +1 -0
  93. package/dist/src/sessions.js +4 -2
  94. package/dist/src/skills/bundled/graph-manager/errors.md +1 -1
  95. package/dist/src/skills/bundled/provenance.json +738 -738
  96. package/dist/src/subagent-run.d.ts +2 -0
  97. package/dist/src/subagent-run.js +14 -3
  98. package/dist/src/telemetry/schema.d.ts +1 -1
  99. package/dist/src/telemetry/schema.js +2 -2
  100. package/dist/src/terminal-ui.d.ts +21 -0
  101. package/dist/src/terminal-ui.js +73 -10
  102. package/dist/src/transcript.js +3 -0
  103. package/dist/src/types.d.ts +3 -0
  104. package/dist/src/workspace-instructions.js +1 -1
  105. package/package.json +12 -1
@@ -0,0 +1,24 @@
1
+ import { ANTHROPIC_MODELS } from '../vendor/engine/runtime/ai/providers/anthropic.models.js';
2
+ // Claude models newer than the vendored engine catalog. The Claude CLI's model
3
+ // catalog lists ids only, so without these a signed-in Claude provider ran
4
+ // with the engine's 128k fallback even on 1M-token models.
5
+ const CLAUDE_CONTEXT_WINDOWS = {
6
+ 'claude-opus-5-5': 1_000_000,
7
+ 'claude-sonnet-5-5': 1_000_000,
8
+ 'claude-haiku-5-5': 1_000_000,
9
+ 'claude-fable-5-2': 1_000_000,
10
+ };
11
+ /** The context window Andorra knows for a Claude model id, or undefined when it has none on record. */
12
+ export function knownClaudeContextWindow(model) {
13
+ const id = model.trim();
14
+ // The Claude CLI marks its long-context variants with a "[1m]" suffix.
15
+ if (/\[1m\]$/i.test(id))
16
+ return 1_000_000;
17
+ const base = id.replace(/\[[^\]]+\]$/, '');
18
+ if (Object.hasOwn(CLAUDE_CONTEXT_WINDOWS, base))
19
+ return CLAUDE_CONTEXT_WINDOWS[base];
20
+ if (!Object.hasOwn(ANTHROPIC_MODELS, base))
21
+ return undefined;
22
+ const window = ANTHROPIC_MODELS[base]?.contextWindow;
23
+ return typeof window === 'number' && Number.isSafeInteger(window) && window > 0 ? window : undefined;
24
+ }
@@ -4,7 +4,7 @@ import { join } from 'node:path';
4
4
  export const MODEL_HEALTH_TTL_MS = 10 * 60_000;
5
5
  const REFRESH_INTERVAL_MS = 60_000;
6
6
  const FILE = 'model-health.json';
7
- const DESCRIPTIVE_FIELDS = new Set(['model', 'models', 'modelContextWindows', 'contextWindow', 'reasoningEffort']);
7
+ const DESCRIPTIVE_FIELDS = new Set(['model', 'models', 'modelContextWindows', 'modelNames', 'contextWindow', 'reasoningEffort']);
8
8
  export function modelHealthKey(provider, model) {
9
9
  const reach = Object.fromEntries(Object.entries(provider)
10
10
  .filter(([name]) => !DESCRIPTIVE_FIELDS.has(name))
@@ -7,4 +7,5 @@ export declare function resolveModelContext(provider: ProviderConfig, model: str
7
7
  export declare function configuredModelSnapshot(provider: ProviderConfig, model: string | undefined): ProviderConfig;
8
8
  export declare function withEvaluationReasoningEffort(snapshot: ProviderConfig, effort: string | undefined): ProviderConfig;
9
9
  export declare function refreshModelContext(provider: ProviderConfig, signal: AbortSignal): Promise<ProviderConfig>;
10
+ /** What the provider lists, with Andorra-known Claude windows filled in where the listing gives none. */
10
11
  export declare function discoverModelMetadata(provider: ProviderConfig, signal: AbortSignal): Promise<ModelMetadata[]>;
@@ -5,8 +5,11 @@ import { readOpenCodeModels } from './opencode-catalog.js';
5
5
  import { readCodexCatalog } from './codex-provider.js';
6
6
  import { codexConnectFor } from './codex-rpc.js';
7
7
  import { readClaudeCatalog } from './claude-provider.js';
8
+ import { knownClaudeContextWindow } from './model-context-windows.js';
8
9
  import { readGrokCatalog } from './grok-provider.js';
9
10
  import { readOpenCodeCatalog } from './opencode-cli-provider.js';
11
+ import { ANDORRA_SIGN_IN_MESSAGE, ANDORRA_UNAVAILABLE_MESSAGE } from './andorra/endpoint.js';
12
+ import { createHostedClient } from './andorra/hosted.js';
10
13
  export async function resolveModelContext(provider, model, signal) {
11
14
  return refreshModelContext(configuredModelSnapshot(provider, model), signal);
12
15
  }
@@ -32,10 +35,21 @@ export function withEvaluationReasoningEffort(snapshot, effort) {
32
35
  export async function refreshModelContext(provider, signal) {
33
36
  const snapshot = configuredModelSnapshot(provider, undefined);
34
37
  signal.throwIfAborted();
35
- if (snapshot.type === 'codex' || snapshot.type === 'claude' || snapshot.type === 'grok')
38
+ if (snapshot.type === 'claude') {
39
+ // The Claude CLI's catalog carries no windows; asking it would only cost a process spawn.
40
+ if (snapshot.contextWindow === undefined) {
41
+ const known = knownClaudeContextWindow(snapshot.model);
42
+ if (known !== undefined)
43
+ snapshot.contextWindow = known;
44
+ }
45
+ return snapshot;
46
+ }
47
+ // Andorra entries carry the router's windows already (saved from GET /v1/hosted).
48
+ if (snapshot.type === 'codex' || snapshot.type === 'grok' || snapshot.type === 'andorra')
36
49
  return snapshot;
37
50
  try {
38
- const models = await discoverModelMetadata(snapshot, signal);
51
+ // The raw listing: a catalog default must not displace a window the user saved.
52
+ const models = await listModelMetadata(snapshot, signal);
39
53
  signal.throwIfAborted();
40
54
  const reported = models.find(model => model.id === snapshot.model)?.contextWindow;
41
55
  if (reported !== undefined)
@@ -44,6 +58,11 @@ export async function refreshModelContext(provider, signal) {
44
58
  catch {
45
59
  signal.throwIfAborted();
46
60
  }
61
+ if (snapshot.type === 'anthropic' && snapshot.contextWindow === undefined) {
62
+ const known = knownClaudeContextWindow(snapshot.model);
63
+ if (known !== undefined)
64
+ snapshot.contextWindow = known;
65
+ }
47
66
  return snapshot;
48
67
  }
49
68
  function object(value) {
@@ -77,12 +96,17 @@ function lmStudioMetadata(data) {
77
96
  }
78
97
  return result;
79
98
  }
99
+ /** What the provider lists, with Andorra-known Claude windows filled in where the listing gives none. */
80
100
  export async function discoverModelMetadata(provider, signal) {
101
+ const models = await listModelMetadata(provider, signal);
102
+ return provider.type === 'anthropic' ? models.map(model => model.contextWindow === undefined ? withKnownClaudeWindow(model.id) : model) : models;
103
+ }
104
+ async function listModelMetadata(provider, signal) {
81
105
  validateConfig({ version: 1, provider: provider.id, providers: [provider] });
82
106
  if (provider.type === 'codex')
83
107
  return (await readCodexCatalog(signal, codexConnectFor(provider))).models.map(id => ({ id }));
84
108
  if (provider.type === 'claude')
85
- return (await readClaudeCatalog(signal)).models.map(id => ({ id }));
109
+ return (await readClaudeCatalog(signal)).models.map(withKnownClaudeWindow);
86
110
  if (provider.type === 'grok') {
87
111
  const catalog = await readGrokCatalog(signal);
88
112
  if (!catalog.signedIn)
@@ -93,6 +117,15 @@ export async function discoverModelMetadata(provider, signal) {
93
117
  return (await readOpenCodeCatalog(signal)).models.map(model => ({ id: model.id, ...(model.contextWindow ? { contextWindow: model.contextWindow } : {}) }));
94
118
  if (provider.type === 'opencode-go')
95
119
  return readOpenCodeModels(signal, fetch, provider.requestTimeoutMs);
120
+ if (provider.type === 'andorra') {
121
+ const check = await createHostedClient()(signal);
122
+ signal.throwIfAborted();
123
+ if (check.kind === 'signed-out')
124
+ throw new Error(ANDORRA_SIGN_IN_MESSAGE);
125
+ if (check.kind === 'failed')
126
+ throw new Error(ANDORRA_UNAVAILABLE_MESSAGE);
127
+ return check.answer.models.map(model => ({ id: model.id, contextWindow: model.contextWindow }));
128
+ }
96
129
  const deadlineMs = provider.requestTimeoutMs !== undefined && provider.requestTimeoutMs > 0
97
130
  ? Math.min(provider.requestTimeoutMs, MODEL_LISTING_TIMEOUT_MS)
98
131
  : MODEL_LISTING_TIMEOUT_MS;
@@ -244,3 +277,7 @@ export async function discoverModelMetadata(provider, signal) {
244
277
  }
245
278
  return models;
246
279
  }
280
+ function withKnownClaudeWindow(id) {
281
+ const contextWindow = knownClaudeContextWindow(id);
282
+ return contextWindow === undefined ? { id } : { id, contextWindow };
283
+ }
@@ -9,6 +9,7 @@ export declare const STATUS: {
9
9
  readonly ok: 114;
10
10
  readonly error: 203;
11
11
  readonly added: 114;
12
+ readonly warn: 214;
12
13
  };
13
14
  export declare const ATTENTION = "1;39";
14
15
  export declare const ATTACHMENT_TOKEN = "1;39";
@@ -5,7 +5,7 @@ export const SUBTLE = 250;
5
5
  export const WHITE = 231;
6
6
  export const ACCENT_INDEX = WHITE;
7
7
  export const SKILL_CHIP = 147;
8
- export const STATUS = { ok: 114, error: 203, added: 114 };
8
+ export const STATUS = { ok: 114, error: 203, added: 114, warn: 214 };
9
9
  export const ATTENTION = '1;39';
10
10
  export const ATTACHMENT_TOKEN = '1;39';
11
11
  export function supportsTruecolor(env = process.env) {
@@ -24,11 +24,24 @@ export function serializeApprovals(approve, mode) {
24
24
  let tail = Promise.resolve();
25
25
  return (name, args, signal) => {
26
26
  const decidedUnder = mode();
27
- const pending = tail.then(() => {
28
- signal.throwIfAborted();
29
- return mode() === decidedUnder ? approve(name, args, signal) : 'policy-changed';
27
+ const previous = tail;
28
+ // A caller cancelled while it waits its turn is refused at once, not when the question ahead of it is
29
+ // answered. The queue itself still waits for that question, so prompts never overlap.
30
+ const pending = new Promise((resolveTurn, rejectTurn) => {
31
+ const abort = () => rejectTurn(signal.reason);
32
+ if (signal.aborted) {
33
+ abort();
34
+ return;
35
+ }
36
+ signal.addEventListener('abort', abort, { once: true });
37
+ void previous.then(() => {
38
+ signal.removeEventListener('abort', abort);
39
+ if (signal.aborted)
40
+ return;
41
+ resolveTurn(mode() === decidedUnder ? approve(name, args, signal) : 'policy-changed');
42
+ });
30
43
  });
31
- tail = pending.catch(() => { });
44
+ tail = previous.then(() => pending.catch(() => { }));
32
45
  return pending;
33
46
  };
34
47
  }
@@ -6,6 +6,8 @@ import { readOpenCodeCatalog } from './opencode-cli-provider.js';
6
6
  import { CliUnavailableError } from './cli-executable.js';
7
7
  import { deadlinePhrase } from './providers.js';
8
8
  import { providerAuthHeaders } from './anthropic-credentials.js';
9
+ import { ANDORRA_SIGN_IN_MESSAGE, ANDORRA_UNAVAILABLE_MESSAGE } from './andorra/endpoint.js';
10
+ import { createHostedClient } from './andorra/hosted.js';
9
11
  const TEST_TIMEOUT_MS = 15_000;
10
12
  const MAX_TEST_BODY_BYTES = 1024 * 1024;
11
13
  const MAX_LISTING_PAGES = 100;
@@ -76,6 +78,19 @@ export async function testProviderConnection(provider, signal, deps = {}) {
76
78
  return failed(bounded.aborted ? 'The OpenCode check timed out.' : 'OpenCode is unavailable. Check the OpenCode CLI and try again.');
77
79
  }
78
80
  }
81
+ if (provider.type === 'andorra') {
82
+ // The same router and account token the adapter uses: the saved URL is informational, and the
83
+ // token never goes anywhere the adapter would not send it.
84
+ const result = await createHostedClient(deps.fetch ? { fetch: deps.fetch } : {})(bounded);
85
+ signal.throwIfAborted();
86
+ if (result.kind === 'signed-out')
87
+ return failed(ANDORRA_SIGN_IN_MESSAGE);
88
+ if (result.kind === 'failed' || !result.answer.enabled)
89
+ return failed(ANDORRA_UNAVAILABLE_MESSAGE);
90
+ const ids = result.answer.models.map(model => model.id);
91
+ return { ok: true, latencyMs: Date.now() - startedAt, modelCount: ids.length,
92
+ ...(provider.model.trim() ? { modelAvailable: ids.includes(provider.model) } : {}) };
93
+ }
79
94
  if (provider.type === 'codex') {
80
95
  try {
81
96
  const catalog = await (deps.codexCatalog ?? ((codexSignal) => readCodexCatalog(codexSignal, codexConnectFor(provider))))(bounded);
@@ -5,5 +5,20 @@ import { retireUnsavedCodexAccounts } from './codex-auth.js';
5
5
  import type { AnthropicConsoleAuth } from './anthropic-console-auth.js';
6
6
  type ConsoleAuth = Pick<AnthropicConsoleAuth, 'start' | 'status' | 'cancel'>;
7
7
  type ModelLister = (provider: ProviderConfig, signal: AbortSignal) => Promise<string[] | undefined>;
8
- export declare function editProviderSettings(config: Config, id: string | undefined, ui: CommandScreenUI, signal: AbortSignal, login?: typeof import('./codex-auth.js').loginCodex, retire?: typeof retireUnsavedCodexAccounts, consoleAuth?: () => Promise<ConsoleAuth>, discover?: ModelLister): Promise<Config | undefined>;
8
+ type PresetRow = {
9
+ id: string;
10
+ label: string;
11
+ description?: string;
12
+ };
13
+ /**
14
+ * Andorra in the Add provider list. `description()` is the hosted model names while Andorra can be added right
15
+ * now, undefined otherwise (asked each time the list is drawn); `add` adds it; `refresh` is the select's refresh
16
+ * option for rows that follow Andorra's state while the list is open.
17
+ */
18
+ export interface AndorraOffer {
19
+ description(): string | undefined;
20
+ add(): Promise<void>;
21
+ refresh?(rows: () => PresetRow[]): ((redraw: (items: PresetRow[]) => void) => () => void) | undefined;
22
+ }
23
+ export declare function editProviderSettings(config: Config, id: string | undefined, ui: CommandScreenUI, signal: AbortSignal, login?: typeof import('./codex-auth.js').loginCodex, retire?: typeof retireUnsavedCodexAccounts, consoleAuth?: () => Promise<ConsoleAuth>, discover?: ModelLister, andorra?: AndorraOffer): Promise<Config | undefined>;
9
24
  export {};
@@ -1,5 +1,6 @@
1
1
  import { validateConfig } from './config.js';
2
- import { applyModelContextWindow, createAdapter, freeDraftCodexAccountSlot, providerModels, recordProviderModel, REASONING_EFFORTS } from './providers.js';
2
+ import { fallbackProviderId } from './andorra/entry.js';
3
+ import { applyModelContextWindow, createAdapter, freeDraftCodexAccountSlot, modelDisplayName, providerModels, recordProviderModel, REASONING_EFFORTS } from './providers.js';
3
4
  import { retireUnsavedCodexAccounts } from './codex-auth.js';
4
5
  import { codexAccountHome } from './codex-rpc.js';
5
6
  import { randomUUID } from 'node:crypto';
@@ -9,17 +10,18 @@ import { GROK_BASE_URL } from './grok-provider.js';
9
10
  import { OPENCODE_BASE_URL } from './opencode-cli-provider.js';
10
11
  const defaultConsoleAuth = async () => new (await import('./anthropic-console-auth.js')).AnthropicConsoleAuth();
11
12
  const defaultModelLister = async (provider, signal) => createAdapter(provider).listModels?.(signal);
12
- export async function editProviderSettings(config, id, ui, signal, login = async (options) => (await import('./codex-auth.js')).loginCodex(options), retire = retireUnsavedCodexAccounts, consoleAuth = defaultConsoleAuth, discover = defaultModelLister) {
13
+ const ANDORRA_PRESET = ':andorra';
14
+ export async function editProviderSettings(config, id, ui, signal, login = async (options) => (await import('./codex-auth.js')).loginCodex(options), retire = retireUnsavedCodexAccounts, consoleAuth = defaultConsoleAuth, discover = defaultModelLister, andorra) {
13
15
  const abandon = {};
14
16
  try {
15
- return await editDraft(config, id, ui, signal, login, retire, consoleAuth, abandon, discover);
17
+ return await editDraft(config, id, ui, signal, login, retire, consoleAuth, abandon, discover, andorra);
16
18
  }
17
19
  catch (error) {
18
20
  await abandon.discard?.().catch(() => { });
19
21
  throw error;
20
22
  }
21
23
  }
22
- async function editDraft(config, id, ui, signal, login, retire, consoleAuth, abandon, discover) {
24
+ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, abandon, discover, andorra) {
23
25
  if (!ui.question)
24
26
  throw new Error('Provider settings require interactive input.');
25
27
  const draft = structuredClone(config);
@@ -42,18 +44,30 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
42
44
  const ask = async (label, secret = false) => (await ui.question(label, { title: label, signal, cancelOnEscape: true, history: false, secret })).trim();
43
45
  const invalid = () => ui.showScreen('Invalid setting', ['That value is not valid. Your saved configuration has not changed.'], { signal });
44
46
  if (!provider) {
45
- const preset = await choose('Add provider', [
46
- { id: 'deepseek', label: 'DeepSeek' }, { id: 'kimi', label: 'Kimi / Moonshot' },
47
- { id: 'kimi-coding', label: 'Kimi For Coding (Global)' }, { id: 'kimi-coding-cn', label: 'Kimi For Coding (China)' },
48
- { id: 'glm', label: 'GLM Coding Plan (Z.ai)' },
49
- { id: 'openai', label: 'OpenAI' }, { id: 'anthropic', label: 'Anthropic' },
50
- { id: 'local', label: 'Local server' }, { id: 'codex', label: 'ChatGPT / Codex' },
51
- { id: 'claude', label: 'Claude subscription' }, { id: 'grok', label: 'Grok subscription (Grok CLI)' },
52
- { id: 'opencode', label: 'OpenCode (CLI sign-in)' }, { id: 'opencode-go', label: 'OpenCode Go' },
53
- { id: 'custom', label: 'Custom provider' },
54
- ]);
47
+ const presetRows = () => {
48
+ // Andorra has nothing to fill in (no key, no address): choosing it adds it and returns to the list. Its row
49
+ // is there while it can be added, and comes or goes in place when a check answers while the list is open.
50
+ const offered = andorra?.description();
51
+ return [
52
+ ...(offered ? [{ id: ANDORRA_PRESET, label: 'Andorra', description: offered }] : []),
53
+ { id: 'deepseek', label: 'DeepSeek' }, { id: 'kimi', label: 'Kimi / Moonshot' },
54
+ { id: 'kimi-coding', label: 'Kimi For Coding (Global)' }, { id: 'kimi-coding-cn', label: 'Kimi For Coding (China)' },
55
+ { id: 'glm', label: 'GLM Coding Plan (Z.ai)' },
56
+ { id: 'openai', label: 'OpenAI' }, { id: 'anthropic', label: 'Anthropic' },
57
+ { id: 'local', label: 'Local server' }, { id: 'codex', label: 'ChatGPT / Codex' },
58
+ { id: 'claude', label: 'Claude subscription' }, { id: 'grok', label: 'Grok subscription (Grok CLI)' },
59
+ { id: 'opencode', label: 'OpenCode (CLI sign-in)' }, { id: 'opencode-go', label: 'OpenCode Go' },
60
+ { id: 'custom', label: 'Custom provider' },
61
+ ];
62
+ };
63
+ const refresh = andorra?.refresh?.(presetRows);
64
+ const preset = await ui.select('Add provider', presetRows(), { signal, ...(refresh ? { refresh } : {}) });
55
65
  if (!preset || signal.aborted)
56
66
  return;
67
+ if (preset === ANDORRA_PRESET) {
68
+ await andorra?.add();
69
+ return;
70
+ }
57
71
  const presets = {
58
72
  deepseek: { type: 'openai-compatible', baseUrl: 'https://api.deepseek.com', model: '' },
59
73
  kimi: { type: 'openai-compatible', baseUrl: 'https://api.moonshot.ai/v1', model: '' },
@@ -117,12 +131,14 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
117
131
  const isGrok = provider.type === 'grok';
118
132
  const isOpenCode = provider.type === 'opencode';
119
133
  const managed = isCodex || isClaude || isGrok || isOpenCode;
134
+ // Andorra's entry has a fixed endpoint, no key and a model list the service keeps current.
135
+ const isAndorra = provider.type === 'andorra';
120
136
  const isConsole = provider.type === 'anthropic' && provider.anthropicAuth === 'console';
121
137
  const field = await choose(`Providers > ${provider.id}`, [
122
138
  ...(isConsole ? [
123
139
  { id: 'anthropicAuth', label: 'Credential: Claude Console sign-in' },
124
140
  { id: 'consoleLogin', label: 'Sign in with Claude Console' },
125
- ] : !managed ? [
141
+ ] : isAndorra ? [] : !managed ? [
126
142
  ...(provider.type === 'opencode-go' ? [] : [
127
143
  { id: 'type', label: `Protocol: ${provider.type}` },
128
144
  { id: 'baseUrl', label: `Endpoint: ${provider.baseUrl}` },
@@ -133,8 +149,8 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
133
149
  ...(provider.apiKey || provider.apiKeyEnv ? [{ id: 'clearAuth', label: 'Remove authentication' }] : []),
134
150
  ] : [{ id: 'login', label: isClaude ? 'Check Claude Code sign-in' : isGrok ? 'Check Grok sign-in' : isOpenCode ? 'Check OpenCode connection' : 'Sign in with ChatGPT / Codex' }]),
135
151
  { id: 'name', label: `Display name: ${provider.name || 'not set'}` },
136
- { id: 'model', label: `Active model: ${provider.model || 'not set'}` },
137
- { id: 'models', label: `Models: ${providerModels(provider).length || 'none'} configured` },
152
+ { id: 'model', label: `Active model: ${provider.model ? modelDisplayName(provider, provider.model) : 'not set'}` },
153
+ ...(isAndorra ? [] : [{ id: 'models', label: `Models: ${providerModels(provider).length || 'none'} configured` }]),
138
154
  { id: 'discover', label: 'Browse available models' },
139
155
  { id: 'contextWindow', label: `Context window: ${provider.contextWindow ?? 'automatic'}` },
140
156
  ...(!managed ? [
@@ -162,7 +178,7 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
162
178
  }
163
179
  if (field === 'delete') {
164
180
  const remaining = draft.providers.filter(item => item.id !== provider.id);
165
- const next = draft.provider === provider.id ? remaining[0]?.id ?? '' : draft.provider;
181
+ const next = draft.provider === provider.id ? fallbackProviderId(remaining) : draft.provider;
166
182
  const confirmed = await choose('Delete provider?', [{ id: 'cancel', label: 'Keep provider' }, { id: 'confirm', label: `Delete ${provider.id}${next ? `; active provider: ${next}` : '; no active provider'}` }], 'cancel');
167
183
  if (confirmed !== 'confirm')
168
184
  continue;
@@ -239,7 +255,7 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
239
255
  unavailable = true;
240
256
  }
241
257
  const rows = new Map();
242
- const row = (model, recommended) => ({ id: `:use:${model}`, label: `${model}${model === candidate.model ? ' · active' : ''}${recommended ? ' (recommended)' : ''}` });
258
+ const row = (model, recommended) => ({ id: `:use:${model}`, label: `${modelDisplayName(candidate, model)}${model === candidate.model ? ' · active' : ''}${recommended ? ' (recommended)' : ''}` });
243
259
  for (const model of providerModels(candidate))
244
260
  rows.set(model, row(model));
245
261
  for (const model of listed)
@@ -442,7 +458,7 @@ async function editDraft(config, id, ui, signal, login, retire, consoleAuth, aba
442
458
  const preferred = models.find(model => model.id === candidate.model)?.id
443
459
  ?? models.find(model => model.isDefault)?.id ?? models[0].id;
444
460
  const model = await choose('Choose model', [...new Map(models.map(model => [model.id, model])).values()]
445
- .map(model => ({ id: model.id, label: `${model.id}${model.isDefault ? ' (recommended)' : ''}` })), preferred);
461
+ .map(model => ({ id: model.id, label: `${modelDisplayName(candidate, model.id)}${model.isDefault ? ' (recommended)' : ''}` })), preferred);
446
462
  if (!model)
447
463
  continue;
448
464
  if (model !== candidate.model)
@@ -1,7 +1,7 @@
1
1
  import type { ModelAdapter } from './types.js';
2
2
  export declare const REASONING_EFFORTS: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
3
3
  export type ReasoningEffort = typeof REASONING_EFFORTS[number];
4
- export declare const PROVIDER_TYPES: readonly ["openai-compatible", "anthropic", "codex", "claude", "opencode-go", "grok", "opencode"];
4
+ export declare const PROVIDER_TYPES: readonly ["openai-compatible", "anthropic", "codex", "claude", "opencode-go", "grok", "opencode", "andorra"];
5
5
  export type ProviderType = typeof PROVIDER_TYPES[number];
6
6
  export declare const SIGN_IN_PROVIDER_TYPES: readonly ["codex", "claude", "grok", "opencode"];
7
7
  export declare function isSignInProviderType(type: unknown): type is typeof SIGN_IN_PROVIDER_TYPES[number];
@@ -20,6 +20,8 @@ export interface ProviderConfig {
20
20
  model: string;
21
21
  models?: string[];
22
22
  modelContextWindows?: Record<string, number>;
23
+ /** Andorra only: the router's display name for each model id. Shown to people; never used to look a model up. */
24
+ modelNames?: Record<string, string>;
23
25
  contextWindow?: number;
24
26
  reasoningEffort?: ReasoningEffort;
25
27
  requestTimeoutMs?: number;
@@ -30,8 +32,15 @@ export interface ProviderConfig {
30
32
  name?: string;
31
33
  }
32
34
  export declare function providerLabel(provider: Pick<ProviderConfig, 'id' | 'type' | 'codexEmail' | 'name'>, providers: readonly Pick<ProviderConfig, 'type'>[]): string;
35
+ /** What a person reads for `model`: an Andorra entry's stored display name, otherwise the id itself. */
36
+ export declare function modelDisplayName(provider: Pick<ProviderConfig, 'type' | 'modelNames'> | undefined, model: string): string;
37
+ /** The model id an exact display name (any case) names on an Andorra entry; undefined for an id, another provider, or a name two models share. */
38
+ export declare function modelIdForDisplayName(provider: Pick<ProviderConfig, 'type' | 'model' | 'models' | 'modelNames'>, text: string): string | undefined;
39
+ /** Provider id → model id → display name, for the providers that have names (Andorra). */
40
+ export declare function providerModelNames(providers: readonly Pick<ProviderConfig, 'id' | 'type' | 'modelNames'>[]): Record<string, Record<string, string>>;
33
41
  export declare const MAX_CODEX_ACCOUNT_KEY_LENGTH = 100;
34
42
  export declare const MAX_PROVIDER_NAME_LENGTH = 64;
43
+ export declare const MAX_MODEL_DISPLAY_NAME_LENGTH = 80;
35
44
  export declare function freeCodexAccountSlot(base: string, providers: readonly Pick<ProviderConfig, 'id' | 'codexAccount'>[]): string;
36
45
  export declare function freeDraftCodexAccountSlot(base: string, draft: readonly Pick<ProviderConfig, 'id' | 'codexAccount'>[], saved: readonly Pick<ProviderConfig, 'id' | 'codexAccount'>[]): string;
37
46
  export declare function allocateCodexAccountSlots(stored: readonly ProviderConfig[], next: readonly ProviderConfig[]): ProviderConfig[];
@@ -43,6 +52,7 @@ export declare function recordProviderModel(provider: ProviderConfig, model: str
43
52
  export declare function assertProviderCredentials(provider: Pick<ProviderConfig, 'type' | 'apiKey' | 'apiKeyEnv' | 'anthropicAuth'>): void;
44
53
  export declare function resolveProviderApiKey(provider: Pick<ProviderConfig, 'type' | 'apiKey' | 'apiKeyEnv' | 'anthropicAuth'>): string | undefined;
45
54
  export declare function defaultProviders(): ProviderConfig[];
55
+ export declare const MALFORMED_RESPONSE_RETRIES = 5;
46
56
  export declare class ProviderRequestError extends Error {
47
57
  readonly contextOverflow: boolean;
48
58
  constructor(message: string, contextOverflow?: boolean);
@@ -56,4 +66,6 @@ export declare function createDecodeWindow(now?: () => number): {
56
66
  stamp(text: string): void;
57
67
  measure(): number | undefined;
58
68
  };
59
- export declare function createAdapter(config: ProviderConfig): ModelAdapter;
69
+ export declare function createAdapter(config: ProviderConfig, options?: {
70
+ sessionId?: string;
71
+ }): ModelAdapter;
@@ -6,10 +6,12 @@ import { createOpenCodeAdapter } from './opencode-provider.js';
6
6
  import { createGrokAdapter } from './grok-provider.js';
7
7
  import { createOpenCodeCliAdapter } from './opencode-cli-provider.js';
8
8
  import { providerAuthHeaders } from './anthropic-credentials.js';
9
+ import { ANDORRA_UNAVAILABLE_MESSAGE, andorraBaseUrl } from './andorra/endpoint.js';
10
+ import { andorraRefusal } from './andorra/errors.js';
9
11
  import { generateEngineResponse, isEngineContextOverflow } from './provider-engine.js';
10
12
  import { estimateStreamedTokens } from './token-rate.js';
11
13
  export const REASONING_EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
12
- export const PROVIDER_TYPES = ['openai-compatible', 'anthropic', 'codex', 'claude', 'opencode-go', 'grok', 'opencode'];
14
+ export const PROVIDER_TYPES = ['openai-compatible', 'anthropic', 'codex', 'claude', 'opencode-go', 'grok', 'opencode', 'andorra'];
13
15
  export const SIGN_IN_PROVIDER_TYPES = ['codex', 'claude', 'grok', 'opencode'];
14
16
  export function isSignInProviderType(type) {
15
17
  return SIGN_IN_PROVIDER_TYPES.includes(type);
@@ -54,8 +56,31 @@ export function providerLabel(provider, providers) {
54
56
  const local = provider.codexEmail?.split('@')[0] || provider.id;
55
57
  return `codex - ${local.length > 32 ? `${local.slice(0, 31)}…` : local}`;
56
58
  }
59
+ /** What a person reads for `model`: an Andorra entry's stored display name, otherwise the id itself. */
60
+ export function modelDisplayName(provider, model) {
61
+ const names = provider?.type === 'andorra' ? provider.modelNames : undefined;
62
+ const name = names && Object.hasOwn(names, model) ? names[model] : undefined;
63
+ return typeof name === 'string' && name ? name : model;
64
+ }
65
+ /** The model id an exact display name (any case) names on an Andorra entry; undefined for an id, another provider, or a name two models share. */
66
+ export function modelIdForDisplayName(provider, text) {
67
+ if (provider.type !== 'andorra' || !provider.modelNames)
68
+ return undefined;
69
+ const ids = providerModels(provider);
70
+ if (ids.includes(text))
71
+ return undefined;
72
+ const wanted = text.replace(/\s+/g, ' ').trim().toLowerCase();
73
+ const matches = ids.filter(id => modelDisplayName(provider, id) !== id && modelDisplayName(provider, id).toLowerCase() === wanted);
74
+ return matches.length === 1 ? matches[0] : undefined;
75
+ }
76
+ /** Provider id → model id → display name, for the providers that have names (Andorra). */
77
+ export function providerModelNames(providers) {
78
+ return Object.fromEntries(providers.flatMap(provider => provider.type === 'andorra' && provider.modelNames && Object.keys(provider.modelNames).length
79
+ ? [[provider.id, { ...provider.modelNames }]] : []));
80
+ }
57
81
  export const MAX_CODEX_ACCOUNT_KEY_LENGTH = 100;
58
82
  export const MAX_PROVIDER_NAME_LENGTH = 64;
83
+ export const MAX_MODEL_DISPLAY_NAME_LENGTH = 80;
59
84
  export function freeCodexAccountSlot(base, providers) {
60
85
  const taken = new Set(providers.flatMap(provider => provider.codexAccount === undefined ? [] : [provider.codexAccount.toLowerCase()]));
61
86
  const key = (suffix) => `${base.slice(0, MAX_CODEX_ACCOUNT_KEY_LENGTH - suffix.length)}${suffix}`;
@@ -130,6 +155,9 @@ export function assertProviderCredentials(provider) {
130
155
  if ((provider.type === 'grok' || provider.type === 'opencode') && (provider.apiKey !== undefined || provider.apiKeyEnv !== undefined)) {
131
156
  throw new Error(`${SIGN_IN_PRODUCT[provider.type]} providers use their CLI sign-in; API key overrides are not supported.`);
132
157
  }
158
+ if (provider.type === 'andorra' && (provider.apiKey !== undefined || provider.apiKeyEnv !== undefined)) {
159
+ throw new Error('Andorra providers use your Andorra account sign-in; API keys are not supported.');
160
+ }
133
161
  if (provider.apiKey !== undefined && (typeof provider.apiKey !== 'string' || !/^[\x21-\x7e]+$/.test(provider.apiKey))) {
134
162
  throw new Error('API key must be nonempty and contain no whitespace or control characters.');
135
163
  }
@@ -160,6 +188,11 @@ export function defaultProviders() {
160
188
  const MAX_REQUEST_RETRIES = 3;
161
189
  const REQUEST_RETRY_DELAYS_MS = [1_000, 30_000, 120_000];
162
190
  const MALFORMED_STREAM_RETRY_DELAYS_MS = [1_000, 3_000, 10_000];
191
+ // A malformed response is usually the model's own slip (tool-call arguments that are not valid JSON), so asking
192
+ // again gets a fresh sample. It needs no long backoff and is retried quietly, more often than a transport fault.
193
+ export const MALFORMED_RESPONSE_RETRIES = 5;
194
+ const MALFORMED_RESPONSE_RETRY_DELAYS_MS = [250, 250, 500, 1_000, 2_000];
195
+ const MALFORMED_RESPONSE_MESSAGE = 'Provider returned a malformed response.';
163
196
  const MAX_AUTOMATIC_RETRY_AFTER_MS = REQUEST_RETRY_DELAYS_MS.at(-1);
164
197
  export class ProviderRequestError extends Error {
165
198
  contextOverflow;
@@ -172,15 +205,21 @@ export class ProviderRequestError extends Error {
172
205
  class RetryableProviderError extends ProviderRequestError {
173
206
  retryAfterMs;
174
207
  retryDelaysMs;
175
- constructor(message, retryAfterMs = 0, retryDelaysMs = REQUEST_RETRY_DELAYS_MS) {
208
+ maxRetries;
209
+ quiet;
210
+ constructor(message, retryAfterMs = 0, retryDelaysMs = REQUEST_RETRY_DELAYS_MS, maxRetries = MAX_REQUEST_RETRIES, quiet = false) {
176
211
  super(message);
177
212
  this.retryAfterMs = retryAfterMs;
178
213
  this.retryDelaysMs = retryDelaysMs;
214
+ this.maxRetries = maxRetries;
215
+ this.quiet = quiet;
179
216
  this.name = 'Error';
180
217
  }
181
218
  }
182
- class MalformedStreamProviderError extends RetryableProviderError {
183
- constructor() { super('Provider returned a malformed response.', 0, MALFORMED_STREAM_RETRY_DELAYS_MS); }
219
+ class MalformedResponseProviderError extends RetryableProviderError {
220
+ constructor() { super(MALFORMED_RESPONSE_MESSAGE, 0, MALFORMED_RESPONSE_RETRY_DELAYS_MS, MALFORMED_RESPONSE_RETRIES, true); }
221
+ }
222
+ class MalformedStreamProviderError extends MalformedResponseProviderError {
184
223
  }
185
224
  export const BLANK_TOOL_CALL_LIMIT = 4096;
186
225
  class BlankToolCallProviderError extends RetryableProviderError {
@@ -233,7 +272,7 @@ function connectionFailureDetail(error) {
233
272
  return code && /^[A-Z][A-Z0-9_]*$/.test(code) ? code : undefined;
234
273
  }
235
274
  function cancelled() { throw new Error('Provider request cancelled.'); }
236
- function malformed() { throw new Error('Provider returned a malformed response.'); }
275
+ function malformed() { throw new Error(MALFORMED_RESPONSE_MESSAGE); }
237
276
  class ResponseTooLargeError extends Error {
238
277
  constructor() { super('Provider response exceeds the 4 MiB limit.'); }
239
278
  }
@@ -664,7 +703,9 @@ function createAnthropicStreamAccumulator(now = Date.now) {
664
703
  },
665
704
  };
666
705
  }
667
- export function createAdapter(config) {
706
+ /** The router reads `x-andorra-session` only in this form and ignores anything else, so nothing else is sent. */
707
+ const ANDORRA_SESSION_ID = /^[A-Za-z0-9._:-]{1,128}$/;
708
+ export function createAdapter(config, options = {}) {
668
709
  if (config.reasoningEffort !== undefined && (!['openai-compatible', 'opencode-go', 'anthropic'].includes(config.type) || !REASONING_EFFORTS.includes(config.reasoningEffort)))
669
710
  throw new Error('Reasoning effort overrides require an OpenAI-compatible, OpenCode Go or Anthropic provider and a supported effort value.');
670
711
  assertRequestTimeout(config);
@@ -680,9 +721,11 @@ export function createAdapter(config) {
680
721
  return createOpenCodeCliAdapter(config);
681
722
  if (config.type === 'opencode-go')
682
723
  return createOpenCodeAdapter(config);
724
+ const andorra = config.type === 'andorra';
683
725
  let base;
726
+ // An Andorra entry's saved URL is informational: requests always go to the router (or its loopback override).
684
727
  try {
685
- base = new URL(config.baseUrl);
728
+ base = new URL(andorra ? andorraBaseUrl() : config.baseUrl);
686
729
  }
687
730
  catch {
688
731
  throw new Error('Provider base URL is invalid.');
@@ -690,8 +733,10 @@ export function createAdapter(config) {
690
733
  if (!['https:', 'http:'].includes(base.protocol) || base.username || base.password || base.search || base.hash) {
691
734
  throw new Error('Provider base URL must be HTTP(S) without credentials, query, or fragment.');
692
735
  }
693
- if (config.type !== 'openai-compatible' && config.type !== 'anthropic')
736
+ if (config.type !== 'openai-compatible' && config.type !== 'anthropic' && !andorra)
694
737
  throw new Error('Unsupported provider type.');
738
+ const sessionHeader = andorra && options.sessionId !== undefined && ANDORRA_SESSION_ID.test(options.sessionId)
739
+ ? { 'x-andorra-session': options.sessionId } : {};
695
740
  const anthropic = config.type === 'anthropic';
696
741
  const requestTimeoutMs = config.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
697
742
  const listingTimeoutMs = requestTimeoutMs > 0 ? Math.min(requestTimeoutMs, MODEL_LISTING_TIMEOUT_MS) : MODEL_LISTING_TIMEOUT_MS;
@@ -711,7 +756,7 @@ export function createAdapter(config) {
711
756
  throw new RetryableProviderError('Provider request timed out.');
712
757
  throw error;
713
758
  }
714
- const headers = { 'content-type': 'application/json', ...credential };
759
+ const headers = { 'content-type': 'application/json', ...sessionHeader, ...credential };
715
760
  const key = headers['x-api-key'] ?? headers.authorization?.replace(/^Bearer /, '');
716
761
  const idle = inference && timeoutMs > 0 ? new AbortController() : undefined;
717
762
  let timer;
@@ -739,6 +784,13 @@ export function createAdapter(config) {
739
784
  throw new Error('Provider request cancelled.');
740
785
  if (deadline?.aborted)
741
786
  throw new RetryableProviderError('Provider request timed out.');
787
+ // A connection that could not be made is not one of the router's refusals: it gets the usual bounded
788
+ // retries, and the plain sentence (no address, no error code) while retrying and when they run out.
789
+ if (andorra) {
790
+ if (permanentConnectionFailure(error))
791
+ throw new ProviderRequestError(ANDORRA_UNAVAILABLE_MESSAGE);
792
+ throw new RetryableProviderError(ANDORRA_UNAVAILABLE_MESSAGE);
793
+ }
742
794
  const cause = connectionFailureDetail(error);
743
795
  const message = `Provider connection failed${cause ? ` (${cause})` : ''}. Check its URL and network connection.`;
744
796
  if (permanentConnectionFailure(error))
@@ -761,6 +813,10 @@ export function createAdapter(config) {
761
813
  throw new ProviderRequestError('Provider input exceeds the context window.', true);
762
814
  }
763
815
  await response.body?.cancel().catch(() => { });
816
+ // The router's own refusals are sent once and shown as written here, never retried.
817
+ const refusal = andorra ? andorraRefusal(response.status, errorData, response.headers.get('retry-after')) : undefined;
818
+ if (refusal)
819
+ throw new ProviderRequestError(refusal);
764
820
  const detail = providerErrorDetail(errorData);
765
821
  const shown = detail === undefined ? undefined : redactCredential(detail, key);
766
822
  const message = `Provider request failed (HTTP ${response.status})${shown ? `: ${shown}` : ''}. Check credentials, model, and provider availability.`;
@@ -872,7 +928,7 @@ export function createAdapter(config) {
872
928
  if (!(error instanceof RetryableProviderError))
873
929
  throw error;
874
930
  prepareRetry?.(error);
875
- if (retry >= MAX_REQUEST_RETRIES)
931
+ if (retry >= error.maxRetries)
876
932
  throw error;
877
933
  if (error.retryAfterMs > MAX_AUTOMATIC_RETRY_AFTER_MS)
878
934
  throw new ProviderRequestError(`${error.message} Retry-After exceeds the 120-second automatic retry limit.`);
@@ -880,7 +936,7 @@ export function createAdapter(config) {
880
936
  const reason = error instanceof MalformedStreamProviderError
881
937
  ? 'Provider returned a malformed streamed response; retrying without streaming.'
882
938
  : error.message;
883
- await onRetry?.({ retry: retry + 1, maxRetries: MAX_REQUEST_RETRIES, delayMs, reason });
939
+ await onRetry?.({ retry: retry + 1, maxRetries: error.maxRetries, delayMs, reason, ...(error.quiet ? { quiet: true } : {}) });
884
940
  try {
885
941
  await delay(delayMs, undefined, { signal });
886
942
  }
@@ -990,6 +1046,8 @@ export function createAdapter(config) {
990
1046
  cancelled();
991
1047
  if (deadline?.aborted)
992
1048
  throw new RetryableProviderError('Provider request timed out.');
1049
+ if (error instanceof Error && !(error instanceof RetryableProviderError) && error.message === MALFORMED_RESPONSE_MESSAGE)
1050
+ throw new MalformedResponseProviderError();
993
1051
  throw error;
994
1052
  }).finally(() => { dispose?.(); dispose = undefined; }), signal, onRetry, error => {
995
1053
  if (error instanceof MalformedStreamProviderError) {