@broberg/ai-sdk 0.71.0 → 0.71.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/dist/index.d.ts CHANGED
@@ -29,6 +29,11 @@ interface SecondOpinionInput {
29
29
  * answered "No" to a Mistral summary; the report carries the five reviews as-is. */
30
30
  synthesize?: boolean;
31
31
  maxTokens?: number;
32
+ /** F088.5 — per-model time limit. A model that has not answered by then gets an
33
+ * error row ("timeout") and the others are delivered. Default 5 min. The provider
34
+ * request is not cancelled, so a late answer may still be billed — it is just not
35
+ * waited for. */
36
+ timeoutMs?: number;
32
37
  /** USD→DKK rate for the price line. Omitted: the ECB reference rate is fetched. */
33
38
  usdToDkk?: number;
34
39
  /** Language of every review and the summary. Default "Danish" — the owner reads them. */
@@ -62,6 +67,8 @@ interface SecondOpinionResult {
62
67
  cost: ReportCost;
63
68
  markdown: string;
64
69
  }
70
+ /** F088.5 — measured 2026-11-05: the slowest of five answered in ~100 s on a 7,000-word plan. */
71
+ declare const SECOND_OPINION_DEFAULT_TIMEOUT_MS = 300000;
65
72
 
66
73
  /** `tavily` is CMS-legacy only (F078.5): reachable by explicit provider, never routed to. */
67
74
  type SearchProviderId = "brave" | "cloudflare:ceramic" | "cloudflare:linkup" | "cloudflare:exa" | "tavily";
@@ -1562,8 +1569,8 @@ declare const falStubAdapter: ProviderAdapter;
1562
1569
  * wires the live adapters. */
1563
1570
  declare const stubProviders: Record<string, ProviderAdapter>;
1564
1571
 
1565
- declare const VERSION: "0.71.0";
1566
- declare const SDK_TAG: "@broberg/ai-sdk@0.71.0";
1572
+ declare const VERSION: "0.71.1";
1573
+ declare const SDK_TAG: "@broberg/ai-sdk@0.71.1";
1567
1574
 
1568
1575
  /** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
1569
1576
  * per-call override.
@@ -2130,4 +2137,4 @@ declare function memorySearchCache(max?: number): SearchCache;
2130
2137
 
2131
2138
  declare function search(req: SearchRequest, opts?: SearchOptions): Promise<SearchResult>;
2132
2139
 
2133
- export { AZURE_DANISH_VOICES, AZURE_DANISH_VOICE_LIST, type AiClient, type AiConfig, type AzureVoiceInfo, BatchJob, BatchRequestItem, BatchResultItem, type BflAdapterConfig, type BflCredits, BudgetConfig, BudgetExceededError, BudgetGuard, BudgetStore, CONFIG_DERIVED_HOSTS, Capability, type ChatInput, ChatResult, ChatStreamEvent, type CheckVoiceOptions, type ClassifyInput, type ClassifyResult, type Contracts, type CostQuery, CostSink, type CostSummary, type CostSummaryQuery, type CostTimeseriesQuery, DEFAULT_BASE_URLS, DEFAULT_SEARCH_ROUTES, DEFAULT_TIER_MAP, type DesignInput, type DesignResult, type DiscordSinkConfig, ELEVENLABS_DANISH_VOICES, type EmbeddingInput, EmbeddingResult, type ExtractInput, type ExtractResult, type FalAdapterConfig, type FixedHostProvider, type HttpResponse, INPUT_LIMITS, type ImageInput, ImageResult, type JudgeInput, JudgeResult, LOCALLY_PINNED_HOSTS, MICROSOFT_DECISION_DEFAULT_DEPLOYMENT, type MockupInput, type MockupResult, type ModerationInput, ModerationResult, type OcrInput, OcrResult, type OpenAICompatibleConfig, type Opinion, type PanelMember, type PodcastInput, PodcastResult, type PriceDriftResult, type PriceDriftRow, type PricingEntry, ProviderAdapter, type RefreshOptions, type RefreshResult, Region, type RerankInput, type RerankResult, type RouteForecast, SDK_TAG, SEARCH_CACHE_TTL_MS, SEARCH_PRICE_USD, SECOND_OPINION_INSTRUCTION, SECOND_OPINION_PANEL, SECOND_OPINION_SYNTH, SECOND_OPINION_SYNTH_INSTRUCTION, SearchBudgetExceededError, type SearchCache, type SearchCapStore, type SearchCredentials, type SearchItem, SearchKeyMissingError, type SearchOptions, type SearchProviderId, type SearchPurpose, type SearchRequest, type SearchResult, type SearchRoute, type SecondOpinionInput, type SecondOpinionResult, type SqliteBudgetStoreConfig, type SqliteSinkConfig, StreamHttpError, type SubprocessResponse, Tier, TierSpec, Tool, ToolCall, type TrainStyleInput, TrainStyleResult, type TranscribeInput, TranscribeResult, type TranslateInput, TranslateResult, Transport, type TransportRequest, type TransportResponse, type TtsInput, type UpmetricsCostClientConfig, UpmetricsCostError, type UpmetricsCostRow, type UpmetricsCostSummary, type UpmetricsCostTimeseries, type UpmetricsSink, type UpmetricsSinkConfig, type UpmetricsSinkStats, Usage, VERSION, type VideoInput, type VisionInput, type VoiceInfo, type VoiceProvider, type VoiceResolveResult, type VoiceStatus, VoiceUnavailableError, type WebSearchContext, type WebSearchToolResult, ZDR_PROVIDERS, aiConfigSchema, anthropicAdapter, anthropicApiAdapter, anthropicSubprocessAdapter, azureAdapter, bflAdapter, bflCredits, byokAdapter, chatInputSchema, checkPriceDrift, checkVoice, computeCost, createAI, deepinfraAdapter, deeplAdapter, deepseekAdapter, defaultBaseUrl, defaultProviders, discordSink, elevenlabsAdapter, embeddingInputSchema, falAdapter, falStubAdapter, freshUsage, fromProviderToolCall, geminiAdapter, getCostSummary, getPrice, httpTransport, imageInputSchema, isByokKeyed, listAzureDanishVoices, listVoices, makeContracts, makeOpenAICompatibleAdapter, matchLabel, memorySearchCache, messageSchema, microsoftDecisionAdapter, mistralAdapter, mistralStubAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, recraftAdapter, refreshAvailability, requestyAdapter, resetRefreshState, resetRegistry, resolveAzureVoice, resolveTier, resolveVoice, routeSearch, runWebSearch, search, sqliteBudgetStore, sqliteSink, streamTransport, stubProviders, subprocessTransport, tierSpecSchema, toProviderTools, toolSchema, translateInputSchema, typesafeAdapter, upmetricsCostClient, upmetricsSink, usdFromMicro, vertexAdapter, visionInputSchema, webSearchTool, wouldProviderRouteTo, wouldRouteTo };
2140
+ export { AZURE_DANISH_VOICES, AZURE_DANISH_VOICE_LIST, type AiClient, type AiConfig, type AzureVoiceInfo, BatchJob, BatchRequestItem, BatchResultItem, type BflAdapterConfig, type BflCredits, BudgetConfig, BudgetExceededError, BudgetGuard, BudgetStore, CONFIG_DERIVED_HOSTS, Capability, type ChatInput, ChatResult, ChatStreamEvent, type CheckVoiceOptions, type ClassifyInput, type ClassifyResult, type Contracts, type CostQuery, CostSink, type CostSummary, type CostSummaryQuery, type CostTimeseriesQuery, DEFAULT_BASE_URLS, DEFAULT_SEARCH_ROUTES, DEFAULT_TIER_MAP, type DesignInput, type DesignResult, type DiscordSinkConfig, ELEVENLABS_DANISH_VOICES, type EmbeddingInput, EmbeddingResult, type ExtractInput, type ExtractResult, type FalAdapterConfig, type FixedHostProvider, type HttpResponse, INPUT_LIMITS, type ImageInput, ImageResult, type JudgeInput, JudgeResult, LOCALLY_PINNED_HOSTS, MICROSOFT_DECISION_DEFAULT_DEPLOYMENT, type MockupInput, type MockupResult, type ModerationInput, ModerationResult, type OcrInput, OcrResult, type OpenAICompatibleConfig, type Opinion, type PanelMember, type PodcastInput, PodcastResult, type PriceDriftResult, type PriceDriftRow, type PricingEntry, ProviderAdapter, type RefreshOptions, type RefreshResult, Region, type RerankInput, type RerankResult, type RouteForecast, SDK_TAG, SEARCH_CACHE_TTL_MS, SEARCH_PRICE_USD, SECOND_OPINION_DEFAULT_TIMEOUT_MS, SECOND_OPINION_INSTRUCTION, SECOND_OPINION_PANEL, SECOND_OPINION_SYNTH, SECOND_OPINION_SYNTH_INSTRUCTION, SearchBudgetExceededError, type SearchCache, type SearchCapStore, type SearchCredentials, type SearchItem, SearchKeyMissingError, type SearchOptions, type SearchProviderId, type SearchPurpose, type SearchRequest, type SearchResult, type SearchRoute, type SecondOpinionInput, type SecondOpinionResult, type SqliteBudgetStoreConfig, type SqliteSinkConfig, StreamHttpError, type SubprocessResponse, Tier, TierSpec, Tool, ToolCall, type TrainStyleInput, TrainStyleResult, type TranscribeInput, TranscribeResult, type TranslateInput, TranslateResult, Transport, type TransportRequest, type TransportResponse, type TtsInput, type UpmetricsCostClientConfig, UpmetricsCostError, type UpmetricsCostRow, type UpmetricsCostSummary, type UpmetricsCostTimeseries, type UpmetricsSink, type UpmetricsSinkConfig, type UpmetricsSinkStats, Usage, VERSION, type VideoInput, type VisionInput, type VoiceInfo, type VoiceProvider, type VoiceResolveResult, type VoiceStatus, VoiceUnavailableError, type WebSearchContext, type WebSearchToolResult, ZDR_PROVIDERS, aiConfigSchema, anthropicAdapter, anthropicApiAdapter, anthropicSubprocessAdapter, azureAdapter, bflAdapter, bflCredits, byokAdapter, chatInputSchema, checkPriceDrift, checkVoice, computeCost, createAI, deepinfraAdapter, deeplAdapter, deepseekAdapter, defaultBaseUrl, defaultProviders, discordSink, elevenlabsAdapter, embeddingInputSchema, falAdapter, falStubAdapter, freshUsage, fromProviderToolCall, geminiAdapter, getCostSummary, getPrice, httpTransport, imageInputSchema, isByokKeyed, listAzureDanishVoices, listVoices, makeContracts, makeOpenAICompatibleAdapter, matchLabel, memorySearchCache, messageSchema, microsoftDecisionAdapter, mistralAdapter, mistralStubAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, recraftAdapter, refreshAvailability, requestyAdapter, resetRefreshState, resetRegistry, resolveAzureVoice, resolveTier, resolveVoice, routeSearch, runWebSearch, search, sqliteBudgetStore, sqliteSink, streamTransport, stubProviders, subprocessTransport, tierSpecSchema, toProviderTools, toolSchema, translateInputSchema, typesafeAdapter, upmetricsCostClient, upmetricsSink, usdFromMicro, vertexAdapter, visionInputSchema, webSearchTool, wouldProviderRouteTo, wouldRouteTo };
package/dist/index.js CHANGED
@@ -3848,6 +3848,14 @@ async function getUsdToDkk(fetchImpl = fetch) {
3848
3848
  }
3849
3849
  }
3850
3850
  var DEFAULT_MAX_TOKENS = 12e3;
3851
+ var SECOND_OPINION_DEFAULT_TIMEOUT_MS = 3e5;
3852
+ function withTimeout(p, ms, label) {
3853
+ let timer;
3854
+ const t = new Promise((_, reject) => {
3855
+ timer = setTimeout(() => reject(new Error(`${label}: timeout after ${Math.round(ms / 1e3)} s`)), ms);
3856
+ });
3857
+ return Promise.race([p, t]).finally(() => clearTimeout(timer));
3858
+ }
3851
3859
  function override(m) {
3852
3860
  return { provider: m.provider, model: m.model, transport: "http" };
3853
3861
  }
@@ -3882,6 +3890,7 @@ Write your entire answer in ${input.language ?? "Danish"}.`;
3882
3890
  const panel = input.panel ?? SECOND_OPINION_PANEL;
3883
3891
  if (panel.length === 0) throw new Error("ai.secondOpinion: panel is empty");
3884
3892
  const maxTokens = input.maxTokens ?? DEFAULT_MAX_TOKENS;
3893
+ const timeoutMs = input.timeoutMs ?? SECOND_OPINION_DEFAULT_TIMEOUT_MS;
3885
3894
  const prompt = [
3886
3895
  input.title ? `Title: ${input.title}` : "",
3887
3896
  input.focus ? `Reviewer focus requested: ${input.focus}` : "",
@@ -3893,13 +3902,17 @@ Write your entire answer in ${input.language ?? "Danish"}.`;
3893
3902
  const opinions = await Promise.all(
3894
3903
  panel.map(async (m) => {
3895
3904
  try {
3896
- const r = await ai.chat({
3897
- system: SECOND_OPINION_INSTRUCTION + lang,
3898
- prompt,
3899
- maxTokens,
3900
- override: override(m),
3901
- purpose: "second-opinion"
3902
- });
3905
+ const r = await withTimeout(
3906
+ ai.chat({
3907
+ system: SECOND_OPINION_INSTRUCTION + lang,
3908
+ prompt,
3909
+ maxTokens,
3910
+ override: override(m),
3911
+ purpose: "second-opinion"
3912
+ }),
3913
+ timeoutMs,
3914
+ m.label
3915
+ );
3903
3916
  return { ...m, text: r.text, usage: r.usage };
3904
3917
  } catch (e) {
3905
3918
  return { ...m, error: errText(e) };
@@ -3913,13 +3926,17 @@ Write your entire answer in ${input.language ?? "Danish"}.`;
3913
3926
  ${o.text}
3914
3927
  </review>`).join("\n\n");
3915
3928
  try {
3916
- const r = await ai.chat({
3917
- system: SECOND_OPINION_SYNTH_INSTRUCTION + lang,
3918
- prompt: reviews,
3919
- maxTokens: 6e3,
3920
- override: override(SECOND_OPINION_SYNTH),
3921
- purpose: "second-opinion-synthesis"
3922
- });
3929
+ const r = await withTimeout(
3930
+ ai.chat({
3931
+ system: SECOND_OPINION_SYNTH_INSTRUCTION + lang,
3932
+ prompt: reviews,
3933
+ maxTokens: 6e3,
3934
+ override: override(SECOND_OPINION_SYNTH),
3935
+ purpose: "second-opinion-synthesis"
3936
+ }),
3937
+ timeoutMs,
3938
+ SECOND_OPINION_SYNTH.label
3939
+ );
3923
3940
  synthesis = { text: r.text, usage: r.usage };
3924
3941
  } catch (e) {
3925
3942
  synthesis = { error: errText(e) };
@@ -4431,8 +4448,8 @@ var aiConfigSchema = z.object({
4431
4448
  import { randomUUID } from "crypto";
4432
4449
 
4433
4450
  // src/version.ts
4434
- var VERSION = "0.71.0";
4435
- var SDK_TAG = "@broberg/ai-sdk@0.71.0";
4451
+ var VERSION = "0.71.1";
4452
+ var SDK_TAG = "@broberg/ai-sdk@0.71.1";
4436
4453
 
4437
4454
  // src/cost/sinks/upmetrics.ts
4438
4455
  function isRetryableStatus(status) {
@@ -6047,6 +6064,7 @@ export {
6047
6064
  SDK_TAG,
6048
6065
  SEARCH_CACHE_TTL_MS,
6049
6066
  SEARCH_PRICE_USD,
6067
+ SECOND_OPINION_DEFAULT_TIMEOUT_MS,
6050
6068
  SECOND_OPINION_INSTRUCTION,
6051
6069
  SECOND_OPINION_PANEL,
6052
6070
  SECOND_OPINION_SYNTH,