190proof 1.0.108 → 1.0.110

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
@@ -273,9 +273,13 @@ Main function to make requests to any supported AI provider.
273
273
  - `retries`: `number` - Number of retry attempts (default: 5)
274
274
  - `chunkTimeoutMs`: `number` - Timeout for streaming chunks in ms (default: 15000)
275
275
 
276
- Two optional per-request knobs live on `payload` (`GenericPayload`):
276
+ Optional per-request knobs live on `payload` (`GenericPayload`):
277
277
 
278
- - `payload.requestTimeoutMs`: `number` - Per-attempt HTTP timeout in ms (default: 120000), honored by every adapter.
278
+ - `payload.requestTimeoutMs`: `number` - Per-attempt HTTP timeout in ms (default: 120000), honored by every adapter — except streaming OpenRouter attempts, which it deliberately does NOT bound (see below). For OpenRouter's non-streaming transport the default is 180000.
279
+ - `payload.streaming`: `boolean` - OpenRouter-only (default: true). Streams the completion over SSE. A streaming attempt is bounded by two independent timers instead of `requestTimeoutMs`: `streamTimeoutMs` (total wall clock, default 600000) and the per-useful-chunk stall timeout (`chunkTimeoutMs` argument, default 15000). A chunk is "useful" only if it advances content, reasoning, tool-call fragments, finish_reason, or usage — SSE comment keep-alives (`: OPENROUTER PROCESSING`) and role-only deltas don't reset the stall timer, so a hung provider dies within one stall window while a healthy long generation can run to the total budget. Set `streaming: false` for the old single-JSON-body transport.
280
+ - `payload.streamTimeoutMs`: `number` - OpenRouter-only: total wall-clock budget per streaming attempt (default: 600000).
281
+
282
+ OpenRouter retries also perform **moderation eviction**: a provider content-moderation rejection (e.g. "Upstream error from Alibaba: Output data may contain inappropriate content.") is deterministic for a given payload, so on the first one the refusing provider is removed from the request's provider preferences (`ignore` += slug, `order` -= slug) and every remaining attempt reroutes to the next provider. Non-moderation errors retry with unchanged preferences, and `fallbackModel` still applies if the whole pool refuses.
279
283
  - `payload.signal`: `AbortSignal` - Caller-supplied cancellation. When it aborts, the in-flight provider request is cancelled and `callWithRetries` **rejects immediately — it does not retry or fall back** (both the retry loop and the fallback branch bail on `signal.aborted`). Threaded to the underlying fetch/axios/SDK call of each provider.
280
284
 
281
285
  #### Returns
package/dist/index.d.mts CHANGED
@@ -279,6 +279,24 @@ interface GenericPayload {
279
279
  * valid response isn't cut short.
280
280
  */
281
281
  requestTimeoutMs?: number;
282
+ /**
283
+ * OpenRouter-only: stream the completion over SSE instead of waiting for a
284
+ * single JSON body. Defaults to true. Streaming attempts are bounded by
285
+ * `streamTimeoutMs` (total) plus a per-useful-chunk stall timeout — NOT by
286
+ * `requestTimeoutMs`, which only governs non-streaming attempts (default
287
+ * 180s for OpenRouter). Set to false to force the old non-streaming path.
288
+ */
289
+ streaming?: boolean;
290
+ /**
291
+ * OpenRouter-only: total wall-clock budget in ms for one streaming attempt
292
+ * (connect + full generation). Defaults to 600s. Independent of
293
+ * `requestTimeoutMs` by design: a healthy long generation keeps streaming
294
+ * useful chunks and may run far past any sane non-streaming deadline, while
295
+ * a hung one is killed much earlier by the per-useful-chunk stall timeout
296
+ * (`chunkTimeoutMs` argument of `callWithRetries`, default 15s — reset only
297
+ * by chunks that advance the output, never by keep-alive bytes/comments).
298
+ */
299
+ streamTimeoutMs?: number;
282
300
  /**
283
301
  * Optional caller-supplied cancellation signal. When it aborts, the in-flight
284
302
  * provider request is cancelled and `callWithRetries` rejects immediately —
@@ -289,10 +307,12 @@ interface GenericPayload {
289
307
  signal?: AbortSignal;
290
308
  }
291
309
 
310
+ declare const OPENROUTER_STREAM_TIMEOUT_MS = 600000;
311
+ declare const OPENROUTER_NONSTREAM_TIMEOUT_MS = 180000;
292
312
  declare function parseModelString(model: string): {
293
313
  provider: Provider;
294
314
  modelId: string;
295
315
  };
296
316
  declare function callWithRetries(id: string | string[], aiPayload: GenericPayload, aiConfig?: OpenAIConfig | AnthropicAIConfig, retries?: number, chunkTimeoutMs?: number): Promise<ParsedResponseMessage>;
297
317
 
298
- export { type AnyModel, ClaudeModel, type FunctionCall, type FunctionDefinition, GPTModel, GeminiModel, type GenericMessage, type GenericPayload, GroqModel, type OpenAIConfig, OpenRouterModel, type OpenRouterProviderPreferences, type ParsedResponseMessage, type Provider, type ToolResult, callWithRetries, parseModelString };
318
+ export { type AnyModel, ClaudeModel, type FunctionCall, type FunctionDefinition, GPTModel, GeminiModel, type GenericMessage, type GenericPayload, GroqModel, OPENROUTER_NONSTREAM_TIMEOUT_MS, OPENROUTER_STREAM_TIMEOUT_MS, type OpenAIConfig, OpenRouterModel, type OpenRouterProviderPreferences, type ParsedResponseMessage, type Provider, type ToolResult, callWithRetries, parseModelString };
package/dist/index.d.ts CHANGED
@@ -279,6 +279,24 @@ interface GenericPayload {
279
279
  * valid response isn't cut short.
280
280
  */
281
281
  requestTimeoutMs?: number;
282
+ /**
283
+ * OpenRouter-only: stream the completion over SSE instead of waiting for a
284
+ * single JSON body. Defaults to true. Streaming attempts are bounded by
285
+ * `streamTimeoutMs` (total) plus a per-useful-chunk stall timeout — NOT by
286
+ * `requestTimeoutMs`, which only governs non-streaming attempts (default
287
+ * 180s for OpenRouter). Set to false to force the old non-streaming path.
288
+ */
289
+ streaming?: boolean;
290
+ /**
291
+ * OpenRouter-only: total wall-clock budget in ms for one streaming attempt
292
+ * (connect + full generation). Defaults to 600s. Independent of
293
+ * `requestTimeoutMs` by design: a healthy long generation keeps streaming
294
+ * useful chunks and may run far past any sane non-streaming deadline, while
295
+ * a hung one is killed much earlier by the per-useful-chunk stall timeout
296
+ * (`chunkTimeoutMs` argument of `callWithRetries`, default 15s — reset only
297
+ * by chunks that advance the output, never by keep-alive bytes/comments).
298
+ */
299
+ streamTimeoutMs?: number;
282
300
  /**
283
301
  * Optional caller-supplied cancellation signal. When it aborts, the in-flight
284
302
  * provider request is cancelled and `callWithRetries` rejects immediately —
@@ -289,10 +307,12 @@ interface GenericPayload {
289
307
  signal?: AbortSignal;
290
308
  }
291
309
 
310
+ declare const OPENROUTER_STREAM_TIMEOUT_MS = 600000;
311
+ declare const OPENROUTER_NONSTREAM_TIMEOUT_MS = 180000;
292
312
  declare function parseModelString(model: string): {
293
313
  provider: Provider;
294
314
  modelId: string;
295
315
  };
296
316
  declare function callWithRetries(id: string | string[], aiPayload: GenericPayload, aiConfig?: OpenAIConfig | AnthropicAIConfig, retries?: number, chunkTimeoutMs?: number): Promise<ParsedResponseMessage>;
297
317
 
298
- export { type AnyModel, ClaudeModel, type FunctionCall, type FunctionDefinition, GPTModel, GeminiModel, type GenericMessage, type GenericPayload, GroqModel, type OpenAIConfig, OpenRouterModel, type OpenRouterProviderPreferences, type ParsedResponseMessage, type Provider, type ToolResult, callWithRetries, parseModelString };
318
+ export { type AnyModel, ClaudeModel, type FunctionCall, type FunctionDefinition, GPTModel, GeminiModel, type GenericMessage, type GenericPayload, GroqModel, OPENROUTER_NONSTREAM_TIMEOUT_MS, OPENROUTER_STREAM_TIMEOUT_MS, type OpenAIConfig, OpenRouterModel, type OpenRouterProviderPreferences, type ParsedResponseMessage, type Provider, type ToolResult, callWithRetries, parseModelString };