@providerkit/core 0.29.1 → 0.31.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.
Files changed (163) hide show
  1. package/README.md +58 -9
  2. package/THIRD_PARTY_NOTICES +144 -0
  3. package/dist/auth/chatgpt-models.js.map +1 -1
  4. package/dist/auth/oauth.d.ts.map +1 -1
  5. package/dist/auth/oauth.js.map +1 -1
  6. package/dist/capability.js.map +1 -1
  7. package/dist/context.d.ts +4 -3
  8. package/dist/context.d.ts.map +1 -1
  9. package/dist/context.js +19 -5
  10. package/dist/context.js.map +1 -1
  11. package/dist/decisions.js.map +1 -1
  12. package/dist/errors.d.ts.map +1 -1
  13. package/dist/errors.js +29 -2
  14. package/dist/errors.js.map +1 -1
  15. package/dist/fallback.d.ts +3 -0
  16. package/dist/fallback.d.ts.map +1 -1
  17. package/dist/fallback.js +9 -5
  18. package/dist/fallback.js.map +1 -1
  19. package/dist/gate.js.map +1 -1
  20. package/dist/hosted/anthropic.d.ts +30 -0
  21. package/dist/hosted/anthropic.d.ts.map +1 -0
  22. package/dist/hosted/anthropic.js +465 -0
  23. package/dist/hosted/anthropic.js.map +1 -0
  24. package/dist/hosted/gemini.d.ts +22 -0
  25. package/dist/hosted/gemini.d.ts.map +1 -0
  26. package/dist/hosted/gemini.js +440 -0
  27. package/dist/hosted/gemini.js.map +1 -0
  28. package/dist/hosted/openai.d.ts +33 -0
  29. package/dist/hosted/openai.d.ts.map +1 -0
  30. package/dist/hosted/openai.js +107 -0
  31. package/dist/hosted/openai.js.map +1 -0
  32. package/dist/hosted/responses.d.ts +28 -0
  33. package/dist/hosted/responses.d.ts.map +1 -0
  34. package/dist/hosted/responses.js +358 -0
  35. package/dist/hosted/responses.js.map +1 -0
  36. package/dist/hosted/shared.d.ts +107 -0
  37. package/dist/hosted/shared.d.ts.map +1 -0
  38. package/dist/hosted/shared.js +264 -0
  39. package/dist/hosted/shared.js.map +1 -0
  40. package/dist/hosted/types.d.ts +191 -0
  41. package/dist/hosted/types.d.ts.map +1 -0
  42. package/dist/hosted/types.js +10 -0
  43. package/dist/hosted/types.js.map +1 -0
  44. package/dist/hosted.d.ts +33 -0
  45. package/dist/hosted.d.ts.map +1 -0
  46. package/dist/hosted.js +61 -0
  47. package/dist/hosted.js.map +1 -0
  48. package/dist/index.d.ts +8 -7
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +8 -7
  51. package/dist/index.js.map +1 -1
  52. package/dist/key-pool.d.ts.map +1 -1
  53. package/dist/key-pool.js.map +1 -1
  54. package/dist/presets.d.ts +36 -5
  55. package/dist/presets.d.ts.map +1 -1
  56. package/dist/presets.js +32 -8
  57. package/dist/presets.js.map +1 -1
  58. package/dist/providers/anthropic.d.ts +75 -1
  59. package/dist/providers/anthropic.d.ts.map +1 -1
  60. package/dist/providers/anthropic.js +207 -135
  61. package/dist/providers/anthropic.js.map +1 -1
  62. package/dist/providers/deepgram-transcription.d.ts +24 -0
  63. package/dist/providers/deepgram-transcription.d.ts.map +1 -0
  64. package/dist/providers/deepgram-transcription.js +84 -0
  65. package/dist/providers/deepgram-transcription.js.map +1 -0
  66. package/dist/providers/factory.d.ts +10 -0
  67. package/dist/providers/factory.d.ts.map +1 -1
  68. package/dist/providers/factory.js +31 -23
  69. package/dist/providers/factory.js.map +1 -1
  70. package/dist/providers/gemini.d.ts +123 -1
  71. package/dist/providers/gemini.d.ts.map +1 -1
  72. package/dist/providers/gemini.js +114 -54
  73. package/dist/providers/gemini.js.map +1 -1
  74. package/dist/providers/hosted-codecs.d.ts +10 -0
  75. package/dist/providers/hosted-codecs.d.ts.map +1 -0
  76. package/dist/providers/hosted-codecs.js +8 -0
  77. package/dist/providers/hosted-codecs.js.map +1 -0
  78. package/dist/providers/openai-transcription.d.ts +21 -0
  79. package/dist/providers/openai-transcription.d.ts.map +1 -0
  80. package/dist/providers/openai-transcription.js +144 -0
  81. package/dist/providers/openai-transcription.js.map +1 -0
  82. package/dist/providers/openai.d.ts +69 -0
  83. package/dist/providers/openai.d.ts.map +1 -1
  84. package/dist/providers/openai.js +38 -14
  85. package/dist/providers/openai.js.map +1 -1
  86. package/dist/providers/responses.d.ts +123 -0
  87. package/dist/providers/responses.d.ts.map +1 -1
  88. package/dist/providers/responses.js +57 -22
  89. package/dist/providers/responses.js.map +1 -1
  90. package/dist/providers/speech-factory.js.map +1 -1
  91. package/dist/providers/transcription-factory.d.ts +30 -0
  92. package/dist/providers/transcription-factory.d.ts.map +1 -0
  93. package/dist/providers/transcription-factory.js +38 -0
  94. package/dist/providers/transcription-factory.js.map +1 -0
  95. package/dist/registry.d.ts +3 -0
  96. package/dist/registry.d.ts.map +1 -1
  97. package/dist/registry.js +8 -4
  98. package/dist/registry.js.map +1 -1
  99. package/dist/retry.js.map +1 -1
  100. package/dist/speech-core.d.ts +2 -17
  101. package/dist/speech-core.d.ts.map +1 -1
  102. package/dist/speech-core.js +10 -50
  103. package/dist/speech-core.js.map +1 -1
  104. package/dist/tools.d.ts.map +1 -1
  105. package/dist/tools.js.map +1 -1
  106. package/dist/transcription-core.d.ts +146 -0
  107. package/dist/transcription-core.d.ts.map +1 -0
  108. package/dist/transcription-core.js +193 -0
  109. package/dist/transcription-core.js.map +1 -0
  110. package/dist/transcription.d.ts +7 -0
  111. package/dist/transcription.d.ts.map +1 -0
  112. package/dist/transcription.js +12 -0
  113. package/dist/transcription.js.map +1 -0
  114. package/dist/transport.d.ts +26 -0
  115. package/dist/transport.d.ts.map +1 -1
  116. package/dist/transport.js +57 -2
  117. package/dist/transport.js.map +1 -1
  118. package/dist/turn.d.ts +10 -1
  119. package/dist/turn.d.ts.map +1 -1
  120. package/dist/turn.js +53 -1
  121. package/dist/turn.js.map +1 -1
  122. package/dist/types.d.ts +51 -0
  123. package/dist/types.d.ts.map +1 -1
  124. package/dist/types.js.map +1 -1
  125. package/dist/usage.d.ts +10 -1
  126. package/dist/usage.d.ts.map +1 -1
  127. package/dist/usage.js +40 -2
  128. package/dist/usage.js.map +1 -1
  129. package/dist/watchdog.d.ts +6 -0
  130. package/dist/watchdog.d.ts.map +1 -1
  131. package/dist/watchdog.js +10 -2
  132. package/dist/watchdog.js.map +1 -1
  133. package/package.json +14 -5
  134. package/src/context.ts +21 -5
  135. package/src/errors.ts +35 -2
  136. package/src/fallback.ts +21 -6
  137. package/src/hosted/anthropic.ts +512 -0
  138. package/src/hosted/gemini.ts +510 -0
  139. package/src/hosted/openai.ts +137 -0
  140. package/src/hosted/responses.ts +420 -0
  141. package/src/hosted/shared.ts +341 -0
  142. package/src/hosted/types.ts +214 -0
  143. package/src/hosted.ts +101 -0
  144. package/src/index.ts +64 -7
  145. package/src/presets.ts +54 -8
  146. package/src/providers/anthropic.ts +252 -143
  147. package/src/providers/deepgram-transcription.ts +109 -0
  148. package/src/providers/factory.ts +127 -82
  149. package/src/providers/gemini.ts +184 -60
  150. package/src/providers/hosted-codecs.ts +29 -0
  151. package/src/providers/openai-transcription.ts +177 -0
  152. package/src/providers/openai.ts +52 -15
  153. package/src/providers/responses.ts +93 -24
  154. package/src/providers/transcription-factory.ts +68 -0
  155. package/src/registry.ts +14 -4
  156. package/src/speech-core.ts +9 -47
  157. package/src/transcription-core.ts +345 -0
  158. package/src/transcription.ts +24 -0
  159. package/src/transport.ts +77 -3
  160. package/src/turn.ts +55 -1
  161. package/src/types.ts +62 -1
  162. package/src/usage.ts +32 -2
  163. package/src/watchdog.ts +12 -2
package/src/index.ts CHANGED
@@ -1,8 +1,22 @@
1
1
  export * from "./types.ts";
2
+ export * from "./hosted/types.ts";
2
3
  export * from "./turn.ts";
3
4
  export * from "./errors.ts";
4
5
  export * from "./retry.ts";
5
- export * from "./fallback.ts";
6
+ export {
7
+ DEFAULT_FALLBACK_COOLDOWNS,
8
+ FallbackPool,
9
+ NoAvailableProviderError,
10
+ withConfiguredFallbacks,
11
+ withFallbackProviders,
12
+ type FallbackOptions,
13
+ type FallbackSpec,
14
+ type FallbackCandidate,
15
+ type ProviderFallbackConfig,
16
+ type Cooldown,
17
+ type CooldownStore,
18
+ type FallbackProvider,
19
+ } from "./fallback.ts";
6
20
  export * from "./key-pool.ts";
7
21
  export * from "./watchdog.ts";
8
22
  export * from "./gate.ts";
@@ -31,10 +45,53 @@ export * from "./image.ts";
31
45
  export * from "./capability.ts";
32
46
  export * from "./attribution.ts";
33
47
  export * from "./presets.ts";
34
- export * from "./providers/anthropic.ts";
35
- export * from "./providers/openai.ts";
36
- export * from "./providers/responses.ts";
37
- export * from "./providers/gemini.ts";
48
+ export {
49
+ createAnthropicProvider,
50
+ toAnthropicMessages,
51
+ type AnthropicConfig,
52
+ } from "./providers/anthropic.ts";
53
+ export {
54
+ createOpenAIProvider,
55
+ toOpenAIMessages,
56
+ effortParams,
57
+ openRouterCostUsd,
58
+ openRouterHostFor,
59
+ type OpenAIConfig,
60
+ type EffortDialect,
61
+ } from "./providers/openai.ts";
62
+ export {
63
+ createResponsesProvider,
64
+ toResponsesInput,
65
+ type ResponsesConfig,
66
+ } from "./providers/responses.ts";
67
+ export {
68
+ createGeminiProvider,
69
+ toGeminiContents,
70
+ antigravityUserAgent,
71
+ antigravitySessionId,
72
+ resolveAntigravityWireModel,
73
+ type GeminiConfig,
74
+ type GeminiContent,
75
+ } from "./providers/gemini.ts";
38
76
  export * from "./providers/zai.ts";
39
- export * from "./providers/factory.ts";
40
- export * from "./registry.ts";
77
+ export {
78
+ createPresetProvider,
79
+ presetAdapter,
80
+ OPENCODE_CLI_USER_AGENT,
81
+ OPENCODE_PUBLIC_API_KEY,
82
+ isZenFreeModel,
83
+ forgeOpenCodeSessionId,
84
+ type PresetProviderConfig,
85
+ type PresetAdapterConfig,
86
+ } from "./providers/factory.ts";
87
+ export {
88
+ createRegistry,
89
+ type ConnectionCredential,
90
+ type ConnectionConfig,
91
+ type RegistryCooldownInfo,
92
+ type RegistryOptions,
93
+ type ViewOptions,
94
+ type CandidateStatus,
95
+ type ConnectionStatus,
96
+ type Registry,
97
+ } from "./registry.ts";
package/src/presets.ts CHANGED
@@ -20,6 +20,7 @@
20
20
  */
21
21
  import type { ImageLimits } from "./image.ts";
22
22
  import type { SpeechFormat, SpeechShape } from "./speech-core.ts";
23
+ import type { TranscriptionShape } from "./transcription-core.ts";
23
24
 
24
25
  export type PresetShape = "anthropic" | "openai" | "responses" | "gemini";
25
26
 
@@ -79,6 +80,22 @@ export interface PresetSpeech {
79
80
  defaultFormat?: SpeechFormat;
80
81
  }
81
82
 
83
+ /**
84
+ * What a preset's endpoint can do besides chat: turn a recording into text. Absent means it
85
+ * cannot, or that nobody has read its documentation yet. `createTranscriptionProvider` (from
86
+ * `@providerkit/core/transcription`) is what reads this. Like `PresetSpeech`, these are facts
87
+ * about the vendor's own host, and none of them follow a caller who sets `baseUrl`.
88
+ */
89
+ export interface PresetTranscription {
90
+ shape: TranscriptionShape;
91
+ /** Defaults to the preset's own `baseUrl`. */
92
+ baseUrl?: string;
93
+ /** The model the vendor recommends, when it names one. */
94
+ defaultModel?: string;
95
+ /** Representative model ids, as in `ProviderPreset.models`. */
96
+ models?: readonly string[];
97
+ }
98
+
82
99
  export interface ProviderPreset {
83
100
  /** Adapter wire format. */
84
101
  shape: PresetShape;
@@ -136,6 +153,8 @@ export interface ProviderPreset {
136
153
  noSampling?: boolean;
137
154
  /** Text to speech on this endpoint. See `PresetSpeech`. */
138
155
  speech?: PresetSpeech;
156
+ /** Speech to text on this endpoint. See `PresetTranscription`. */
157
+ transcription?: PresetTranscription;
139
158
  }
140
159
 
141
160
  export const PROVIDER_PRESETS = {
@@ -181,6 +200,21 @@ export const PROVIDER_PRESETS = {
181
200
  ],
182
201
  maxInputChars: 4096,
183
202
  },
203
+ // Source: OpenAI's speech-to-text guide and transcription reference, read 2026-11-11. The
204
+ // guide recommends `gpt-transcribe`, and says the other four shut down on 2027-02-26. Only
205
+ // `gpt-4o-transcribe-diarize` labels speakers, and only Whisper gives timed segments without
206
+ // them. Remove the four ids after that date.
207
+ transcription: {
208
+ shape: "openai",
209
+ defaultModel: "gpt-transcribe",
210
+ models: [
211
+ "gpt-transcribe",
212
+ "gpt-4o-transcribe",
213
+ "gpt-4o-mini-transcribe",
214
+ "gpt-4o-transcribe-diarize",
215
+ "whisper-1",
216
+ ],
217
+ },
184
218
  },
185
219
  google: {
186
220
  // Native Generative Language REST — the adapter authenticates with
@@ -477,8 +511,14 @@ export const PROVIDER_PRESETS = {
477
511
  *
478
512
  * Measured 2026-09-27 on /chat/completions: a call without
479
513
  * `x-opencode-session` is refused. `mimo-v2.6-flash` passes plain text,
480
- * `reasoning_effort: "none"`, tool calls and json_schema; `glm-5.3-flash`
481
- * 400s on a tool without a description and on a `thinking` field.
514
+ * `reasoning_effort: "none"` and tool calls; `glm-5.3-flash` 400s on a tool
515
+ * without a description and on a `thinking` field.
516
+ *
517
+ * Measured 2026-11-11 with a live key: `mimo-v2.5` is retired (every call
518
+ * answers 410 `ModelDeprecated`), and `mimo-v2.6-flash` ignores a strict
519
+ * json_schema `response_format` and answers with the schema itself, on Go and
520
+ * on OpenRouter. `glm-5.3-flash`, `qwen3.8-flash` and `longcat-2.0` fill the
521
+ * schema in, with an image input too.
482
522
  *
483
523
  * Go serves three wires, and `routes` picks one from the model id (cc-proxy's
484
524
  * table, from Go's own docs): `minimax-` and `qwen` on Anthropic /messages
@@ -505,7 +545,6 @@ export const PROVIDER_PRESETS = {
505
545
  defaultModel: "mimo-v2.6-flash",
506
546
  models: [
507
547
  "mimo-v2.6-flash",
508
- "mimo-v2.5",
509
548
  "glm-5.3-flash",
510
549
  "qwen3.8-flash",
511
550
  "longcat-2.0",
@@ -535,11 +574,13 @@ export const PROVIDER_PRESETS = {
535
574
  },
536
575
  ],
537
576
  // Cheapest first, each with its own monthly limit ($60, qwen3.8-flash $30).
538
- // All five passed plain text, a described tool call and json_schema on
539
- // 2026-09-27; longcat-2.0 ignores reasoning "none", so it goes last.
540
- // DeepSeek is left out: on Go it needs the workspace's Global regions
541
- // privacy setting, and answers 500 without it.
542
- rotation: ["mimo-v2.6-flash", "mimo-v2.5", "glm-5.3-flash", "qwen3.8-flash", "longcat-2.0"],
577
+ // All four passed plain text, a described tool call and json_schema on
578
+ // 2026-09-27; longcat-2.0 ignores reasoning "none", so it goes last. On
579
+ // 2026-11-11 mimo-v2.6-flash no longer filled a strict json_schema (see
580
+ // above), so a caller that needs one names its own `models`. DeepSeek is
581
+ // left out: on Go it needs the workspace's Global regions privacy setting,
582
+ // and answers 500 without it.
583
+ rotation: ["mimo-v2.6-flash", "glm-5.3-flash", "qwen3.8-flash", "longcat-2.0"],
543
584
  },
544
585
  /**
545
586
  * OpenCode Zen: free and pay-as-you-go models on `https://opencode.ai/zen/v1`,
@@ -836,3 +877,8 @@ export const PRESET_IDS = Object.keys(PROVIDER_PRESETS) as ProviderPresetId[];
836
877
 
837
878
  /** The presets that can speak, for a screen that offers exactly those. */
838
879
  export const SPEECH_PRESET_IDS = PRESET_IDS.filter((id) => "speech" in PROVIDER_PRESETS[id]);
880
+
881
+ /** The presets that can transcribe, for a screen that offers exactly those. */
882
+ export const TRANSCRIPTION_PRESET_IDS = PRESET_IDS.filter(
883
+ (id) => "transcription" in PROVIDER_PRESETS[id],
884
+ );