@broberg/ai-sdk 0.66.0 → 0.66.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
@@ -253,6 +253,27 @@ interface Contracts {
253
253
  rerank(input: RerankInput): Promise<RerankResult>;
254
254
  }
255
255
 
256
+ /** Upper bounds on every array the SDK accepts (F082.2, GHSA-mrhx-c7xc-m3w5). zod
257
+ * 4.6.7 stops at the first issue only when an array has a `.max()`; without one,
258
+ * 200k bad elements still produce 200k issues (buddy + cms measured, 24 Oct 2026).
259
+ * Set far above real use on purpose — the owner asked for cautious limits, so a
260
+ * bound that rejects a legitimate call is the failure to avoid, not a loose one. */
261
+ declare const INPUT_LIMITS: {
262
+ readonly messages: 10000;
263
+ readonly contentParts: 1000;
264
+ readonly toolCalls: 1000;
265
+ readonly tools: 1000;
266
+ readonly fallback: 32;
267
+ readonly loras: 32;
268
+ readonly trainImages: 1000;
269
+ readonly texts: 10000;
270
+ readonly phrases: 10000;
271
+ readonly granularities: 10;
272
+ readonly judgeEntryItems: 1000;
273
+ readonly stateItems: 10000;
274
+ readonly scriptLines: 10000;
275
+ readonly pronunciations: 10000;
276
+ };
256
277
  declare const tierSpecSchema: z.ZodObject<{
257
278
  provider: z.ZodString;
258
279
  model: z.ZodString;
@@ -1408,8 +1429,8 @@ declare const falStubAdapter: ProviderAdapter;
1408
1429
  * wires the live adapters. */
1409
1430
  declare const stubProviders: Record<string, ProviderAdapter>;
1410
1431
 
1411
- declare const VERSION: "0.66.0";
1412
- declare const SDK_TAG: "@broberg/ai-sdk@0.66.0";
1432
+ declare const VERSION: "0.66.1";
1433
+ declare const SDK_TAG: "@broberg/ai-sdk@0.66.1";
1413
1434
 
1414
1435
  /** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
1415
1436
  * per-call override.
@@ -1975,4 +1996,4 @@ declare function memorySearchCache(max?: number): SearchCache;
1975
1996
 
1976
1997
  declare function search(req: SearchRequest, opts?: SearchOptions): Promise<SearchResult>;
1977
1998
 
1978
- 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, type ImageInput, ImageResult, type JudgeInput, JudgeResult, LOCALLY_PINNED_HOSTS, type MockupInput, type MockupResult, type ModerationInput, ModerationResult, type OcrInput, OcrResult, type OpenAICompatibleConfig, 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, SearchBudgetExceededError, type SearchCache, type SearchCapStore, type SearchCredentials, type SearchItem, SearchKeyMissingError, type SearchOptions, type SearchProviderId, type SearchPurpose, type SearchRequest, type SearchResult, type SearchRoute, 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, mistralAdapter, mistralStubAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, 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 };
1999
+ 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, type MockupInput, type MockupResult, type ModerationInput, ModerationResult, type OcrInput, OcrResult, type OpenAICompatibleConfig, 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, SearchBudgetExceededError, type SearchCache, type SearchCapStore, type SearchCredentials, type SearchItem, SearchKeyMissingError, type SearchOptions, type SearchProviderId, type SearchPurpose, type SearchRequest, type SearchResult, type SearchRoute, 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, mistralAdapter, mistralStubAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, 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
@@ -3716,6 +3716,23 @@ function checkVoice(requested, opts = {}) {
3716
3716
 
3717
3717
  // src/schema/inputs.ts
3718
3718
  import { z } from "zod";
3719
+ var INPUT_LIMITS = {
3720
+ messages: 1e4,
3721
+ contentParts: 1e3,
3722
+ toolCalls: 1e3,
3723
+ tools: 1e3,
3724
+ fallback: 32,
3725
+ loras: 32,
3726
+ trainImages: 1e3,
3727
+ texts: 1e4,
3728
+ phrases: 1e4,
3729
+ granularities: 10,
3730
+ judgeEntryItems: 1e3,
3731
+ stateItems: 1e4,
3732
+ scriptLines: 1e4,
3733
+ pronunciations: 1e4
3734
+ };
3735
+ var L = INPUT_LIMITS;
3719
3736
  var transportSchema = z.enum(["http", "subprocess"]);
3720
3737
  var tierSchema = z.enum([
3721
3738
  "fast",
@@ -3755,8 +3772,8 @@ var contentPartSchema = z.union([
3755
3772
  ]);
3756
3773
  var messageSchema = z.object({
3757
3774
  role: z.enum(["system", "user", "assistant", "tool"]),
3758
- content: z.union([z.string(), z.array(contentPartSchema)]),
3759
- toolCalls: z.array(toolCallSchema).optional(),
3775
+ content: z.union([z.string(), z.array(contentPartSchema).max(L.contentParts)]),
3776
+ toolCalls: z.array(toolCallSchema).max(L.toolCalls).optional(),
3760
3777
  toolCallId: z.string().optional(),
3761
3778
  /** F049 — see Message.prefix. Position/role validity is enforced in the adapter,
3762
3779
  * not here: the rule is about a message's place in the ARRAY, which a per-message
@@ -3766,7 +3783,7 @@ var messageSchema = z.object({
3766
3783
  var callOptions = {
3767
3784
  tier: tierSchema.optional(),
3768
3785
  override: tierSpecSchema.partial().optional(),
3769
- fallback: z.array(z.union([tierSchema, tierSpecSchema])).optional(),
3786
+ fallback: z.array(z.union([tierSchema, tierSpecSchema])).max(L.fallback).optional(),
3770
3787
  purpose: z.string().optional(),
3771
3788
  /** F077.3 — you MEAN to call a floating "-latest" id (no warning, no strictPinning error). */
3772
3789
  allowFloating: z.boolean().optional(),
@@ -3784,9 +3801,9 @@ var chatInputSchema = z.object({
3784
3801
  * false opts out; an explicit promptCacheKey always wins. */
3785
3802
  promptCache: z.boolean().optional(),
3786
3803
  prompt: z.string().optional(),
3787
- messages: z.array(messageSchema).optional(),
3804
+ messages: z.array(messageSchema).max(L.messages).optional(),
3788
3805
  system: z.string().optional(),
3789
- tools: z.array(toolSchema).optional(),
3806
+ tools: z.array(toolSchema).max(L.tools).optional(),
3790
3807
  maxTokens: z.number().int().positive().optional(),
3791
3808
  temperature: z.number().min(0).max(2).optional(),
3792
3809
  /** F074.3 — Mistral reasoning ("thinking") before the answer. Large 4 thinks by
@@ -3828,7 +3845,7 @@ var imageInputSchema = z.object({
3828
3845
  width: z.number().int().positive().optional(),
3829
3846
  height: z.number().int().positive().optional(),
3830
3847
  /** LoRAs to merge at inference (F021). */
3831
- loras: z.array(loraWeightSchema).optional(),
3848
+ loras: z.array(loraWeightSchema).max(L.loras).optional(),
3832
3849
  /** Shorthand for a single LoRA — normalized to loras:[{path, scale:1}]. */
3833
3850
  lora: z.string().optional(),
3834
3851
  /** F023 — a BFL finetune id (subject trained in the BFL dashboard). Routes to the
@@ -3866,7 +3883,7 @@ var animateInputSchema = z.object({
3866
3883
  });
3867
3884
  var trainStyleInputSchema = z.object({
3868
3885
  /** A hosted archive URL, or an array of image URLs the SDK zips in-memory. */
3869
- images: z.union([z.string(), z.array(z.string())]),
3886
+ images: z.union([z.string(), z.array(z.string()).max(L.trainImages)]),
3870
3887
  /** Style LoRA (disables captioning/masks). Default true. */
3871
3888
  isStyle: z.boolean().optional(),
3872
3889
  triggerWord: z.string().optional(),
@@ -3875,7 +3892,7 @@ var trainStyleInputSchema = z.object({
3875
3892
  ...callOptions
3876
3893
  });
3877
3894
  var embeddingInputSchema = z.object({
3878
- text: z.union([z.string(), z.array(z.string())]),
3895
+ text: z.union([z.string(), z.array(z.string()).max(L.texts)]),
3879
3896
  ...callOptions
3880
3897
  });
3881
3898
  var transcribeInputSchema = z.object({
@@ -3885,12 +3902,12 @@ var transcribeInputSchema = z.object({
3885
3902
  /** Audio length in seconds — enables Whisper per-minute cost. */
3886
3903
  durationSec: z.number().positive().optional(),
3887
3904
  /** Bias toward brand/jargon terms (Azure phraseList, F029.3); others ignore it. */
3888
- phrases: z.array(z.string()).optional(),
3905
+ phrases: z.array(z.string()).max(L.phrases).optional(),
3889
3906
  /** Opt-in timestamps (F036) — a single granularity or an array. Omit → the
3890
3907
  * current { text, usage } shape, unchanged. Pass ["word","segment"] for both.
3891
3908
  * Supported by Whisper (openai) + Azure fast-transcription (F036.1); other
3892
3909
  * adapters (Voxtral/mistral) ignore it and return text only. */
3893
- timestamps: z.union([z.enum(["word", "segment"]), z.array(z.enum(["word", "segment"]))]).optional(),
3910
+ timestamps: z.union([z.enum(["word", "segment"]), z.array(z.enum(["word", "segment"])).max(L.granularities)]).optional(),
3894
3911
  ...callOptions
3895
3912
  });
3896
3913
  var ocrInputSchema = z.object({
@@ -3901,10 +3918,10 @@ var ocrInputSchema = z.object({
3901
3918
  ...callOptions
3902
3919
  });
3903
3920
  var moderationInputSchema = z.object({
3904
- input: z.union([z.string(), z.array(z.string())]),
3921
+ input: z.union([z.string(), z.array(z.string()).max(L.texts)]),
3905
3922
  ...callOptions
3906
3923
  });
3907
- var judgeEntrySchema = z.union([z.string().min(1), z.null(), z.array(z.unknown()), z.record(z.string(), z.unknown())]);
3924
+ var judgeEntrySchema = z.union([z.string().min(1), z.null(), z.array(z.unknown()).max(L.judgeEntryItems), z.record(z.string(), z.unknown())]);
3908
3925
  var judgeQuestionSchema = z.discriminatedUnion("type", [
3909
3926
  z.object({
3910
3927
  type: z.literal("noul"),
@@ -3929,7 +3946,7 @@ var judgeQuestionSchema = z.discriminatedUnion("type", [
3929
3946
  })
3930
3947
  ]);
3931
3948
  var judgeInputSchema = z.object({
3932
- state: z.union([z.string().min(1), z.array(z.string()), z.record(z.string(), z.unknown())]),
3949
+ state: z.union([z.string().min(1), z.array(z.string()).max(L.stateItems), z.record(z.string(), z.unknown())]),
3933
3950
  questions: z.record(z.string(), judgeQuestionSchema).refine((q) => Object.keys(q).length > 0, {
3934
3951
  message: "judge needs at least one question"
3935
3952
  }),
@@ -3944,13 +3961,13 @@ var pronunciationSchema = z.object({
3944
3961
  matchInCompounds: z.boolean().optional()
3945
3962
  });
3946
3963
  var podcastInputSchema = z.object({
3947
- script: z.array(z.object({ speaker: z.string(), text: z.string() })).min(1),
3964
+ script: z.array(z.object({ speaker: z.string(), text: z.string() })).min(1).max(L.scriptLines),
3948
3965
  voices: z.record(z.string(), z.string()),
3949
3966
  format: z.string().optional(),
3950
3967
  /** F051.4 — same field, same semantics as tts. Applied PER LINE: ElevenLabs'
3951
3968
  * /text-to-dialogue takes inputs[].text separately, so there is no composed string
3952
3969
  * a replacement could run across a speaker boundary in. */
3953
- pronunciations: z.array(pronunciationSchema).optional(),
3970
+ pronunciations: z.array(pronunciationSchema).max(L.pronunciations).optional(),
3954
3971
  ...callOptions
3955
3972
  });
3956
3973
  var ttsInputSchema = z.object({
@@ -3958,7 +3975,7 @@ var ttsInputSchema = z.object({
3958
3975
  voice: z.string(),
3959
3976
  /** F051 — see TtsRequest.pronunciations. The alias/ipa exclusivity is enforced in
3960
3977
  * the adapter, not here: the message must name the provider that cannot do it. */
3961
- pronunciations: z.array(pronunciationSchema).optional(),
3978
+ pronunciations: z.array(pronunciationSchema).max(L.pronunciations).optional(),
3962
3979
  /** F055 — per-word timings (Azure only). Changes the route to batch synthesis. */
3963
3980
  wordTimings: z.boolean().optional(),
3964
3981
  /** F037: voice to use if `voice` is one we know the provider has retired. Without
@@ -3983,7 +4000,7 @@ var budgetSchema = z.object({
3983
4000
  });
3984
4001
  var availabilitySchema = z.object({
3985
4002
  autoResolve: z.boolean().optional(),
3986
- fallback: z.union([z.string(), z.array(z.string())]).optional()
4003
+ fallback: z.union([z.string(), z.array(z.string()).max(L.fallback)]).optional()
3987
4004
  });
3988
4005
  var aiConfigSchema = z.object({
3989
4006
  /** F069.1 — customer-key mode. Every provider must be built with byokAdapter(), so no
@@ -4016,8 +4033,8 @@ var aiConfigSchema = z.object({
4016
4033
  import { randomUUID } from "crypto";
4017
4034
 
4018
4035
  // src/version.ts
4019
- var VERSION = "0.66.0";
4020
- var SDK_TAG = "@broberg/ai-sdk@0.66.0";
4036
+ var VERSION = "0.66.1";
4037
+ var SDK_TAG = "@broberg/ai-sdk@0.66.1";
4021
4038
 
4022
4039
  // src/cost/sinks/upmetrics.ts
4023
4040
  function isRetryableStatus(status) {
@@ -5572,6 +5589,7 @@ export {
5572
5589
  DEFAULT_SEARCH_ROUTES,
5573
5590
  DEFAULT_TIER_MAP,
5574
5591
  ELEVENLABS_DANISH_VOICES,
5592
+ INPUT_LIMITS,
5575
5593
  LOCALLY_PINNED_HOSTS,
5576
5594
  MEDIA_PRICING_CHECKED_AT,
5577
5595
  ModelUnavailableError,