@opencode/ai 2.2.5 → 2.2.7

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 (306) hide show
  1. package/README.md +228 -72
  2. package/dist/ai-client.d.ts +2 -2
  3. package/dist/ai-client.js +2 -1
  4. package/dist/cache-policy.d.ts +1 -1
  5. package/dist/cache-policy.js +16 -4
  6. package/dist/decision-client.d.ts +3 -3
  7. package/dist/decision.d.ts +30 -125
  8. package/dist/decision.js +27 -15
  9. package/dist/effect.d.ts +10 -15
  10. package/dist/effect.js +6 -6
  11. package/dist/effort-updates.d.ts +3 -3
  12. package/dist/effort-updates.js +2 -2
  13. package/dist/embedding-client.d.ts +21 -0
  14. package/dist/embedding-client.js +30 -0
  15. package/dist/embedding.d.ts +111 -0
  16. package/dist/embedding.js +75 -0
  17. package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
  18. package/dist/experimental/cloudflare-run-extraction.js +4 -1
  19. package/dist/experimental/extraction.d.ts +10 -40
  20. package/dist/experimental/extraction.js +14 -13
  21. package/dist/experimental.d.ts +8 -8
  22. package/dist/experimental.js +4 -4
  23. package/dist/generation.d.ts +0 -2
  24. package/dist/generation.js +2 -2
  25. package/dist/image-client.d.ts +13 -7
  26. package/dist/image-client.js +1 -1
  27. package/dist/image.d.ts +357 -465
  28. package/dist/image.js +17 -18
  29. package/dist/index.d.ts +35 -467
  30. package/dist/index.js +23 -17
  31. package/dist/llm.d.ts +65 -266
  32. package/dist/llm.js +101 -92
  33. package/dist/loop.d.ts +38 -0
  34. package/dist/loop.js +136 -0
  35. package/dist/media-model.d.ts +1 -1
  36. package/dist/media-model.js +8 -6
  37. package/dist/media.d.ts +9 -0
  38. package/dist/media.js +37 -2
  39. package/dist/protocols/alibaba-chat.d.ts +9 -1
  40. package/dist/protocols/alibaba-chat.js +3 -3
  41. package/dist/protocols/alibaba-images.d.ts +2 -2
  42. package/dist/protocols/alibaba-messages.js +3 -3
  43. package/dist/protocols/alibaba-responses.js +8 -20
  44. package/dist/protocols/anthropic-messages.d.ts +1 -1
  45. package/dist/protocols/anthropic-messages.js +57 -176
  46. package/dist/protocols/assemblyai-transcription.d.ts +2 -2
  47. package/dist/protocols/bedrock-converse.js +10 -16
  48. package/dist/protocols/cartesia-speech.d.ts +2 -2
  49. package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
  50. package/dist/protocols/cohere-chat.js +9 -12
  51. package/dist/protocols/deepgram-speech.d.ts +2 -2
  52. package/dist/protocols/deepgram-transcription.d.ts +2 -2
  53. package/dist/protocols/elevenlabs-speech.d.ts +2 -2
  54. package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
  55. package/dist/protocols/gemini.d.ts +3 -0
  56. package/dist/protocols/gemini.js +54 -72
  57. package/dist/protocols/google-embed-content.d.ts +34 -0
  58. package/dist/protocols/google-embed-content.js +110 -0
  59. package/dist/protocols/google-images.d.ts +2 -2
  60. package/dist/protocols/google-interactions.d.ts +3 -4
  61. package/dist/protocols/google-interactions.js +44 -30
  62. package/dist/protocols/google-speech.d.ts +2 -2
  63. package/dist/protocols/google-transcription.d.ts +2 -2
  64. package/dist/protocols/google-vertex-predict-embeddings.d.ts +18 -0
  65. package/dist/protocols/google-vertex-predict-embeddings.js +74 -0
  66. package/dist/protocols/google-video.d.ts +2 -2
  67. package/dist/protocols/index.d.ts +3 -0
  68. package/dist/protocols/index.js +3 -0
  69. package/dist/protocols/meta-images.d.ts +2 -2
  70. package/dist/protocols/meta-responses.js +26 -23
  71. package/dist/protocols/minimax-images.d.ts +2 -2
  72. package/dist/protocols/mistral-chat.js +7 -10
  73. package/dist/protocols/open-responses-channel.js +6 -19
  74. package/dist/protocols/open-responses-continuation.d.ts +1 -5
  75. package/dist/protocols/open-responses-continuation.js +1 -3
  76. package/dist/protocols/open-responses.d.ts +2 -22
  77. package/dist/protocols/open-responses.js +41 -23
  78. package/dist/protocols/openai-chat.d.ts +27 -23
  79. package/dist/protocols/openai-chat.js +62 -57
  80. package/dist/protocols/openai-compatible-chat.d.ts +2 -1
  81. package/dist/protocols/openai-compatible-responses.d.ts +2 -2
  82. package/dist/protocols/openai-compatible-responses.js +1 -1
  83. package/dist/protocols/openai-decisions.js +15 -2
  84. package/dist/protocols/openai-embeddings.d.ts +16 -0
  85. package/dist/protocols/openai-embeddings.js +76 -0
  86. package/dist/protocols/openai-images.d.ts +2 -2
  87. package/dist/protocols/openai-responses.js +10 -29
  88. package/dist/protocols/openai-speech.d.ts +2 -2
  89. package/dist/protocols/openai-transcription.d.ts +2 -2
  90. package/dist/protocols/runway-video.d.ts +2 -2
  91. package/dist/protocols/shared.d.ts +14 -7
  92. package/dist/protocols/shared.js +40 -15
  93. package/dist/protocols/system-one.d.ts +4 -4
  94. package/dist/protocols/system-one.js +8 -1
  95. package/dist/protocols/utils/bedrock-cache.js +2 -5
  96. package/dist/protocols/utils/bedrock-media.d.ts +0 -3
  97. package/dist/protocols/utils/cache.d.ts +3 -0
  98. package/dist/protocols/utils/cache.js +15 -2
  99. package/dist/protocols/utils/image-sizing.d.ts +1 -1
  100. package/dist/protocols/utils/responses-checkpoint.js +1 -1
  101. package/dist/protocols/utils/responses-compaction.d.ts +1 -1
  102. package/dist/protocols/utils/responses-compaction.js +6 -5
  103. package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
  104. package/dist/protocols/utils/responses-hosted-tools.js +31 -0
  105. package/dist/protocols/utils/tool-stream.d.ts +5 -271
  106. package/dist/protocols/utils/tool-stream.js +3 -13
  107. package/dist/protocols/venice-chat.d.ts +7 -1
  108. package/dist/protocols/venice-chat.js +4 -4
  109. package/dist/protocols/xai-images.d.ts +2 -2
  110. package/dist/protocols/xai-responses.js +5 -25
  111. package/dist/protocols/xai-video.d.ts +2 -2
  112. package/dist/protocols/zai-chat.d.ts +9 -1
  113. package/dist/protocols/zai-chat.js +1 -1
  114. package/dist/protocols/zai-images.d.ts +2 -2
  115. package/dist/protocols/zai-messages.js +3 -3
  116. package/dist/provider-error.d.ts +0 -1
  117. package/dist/provider-error.js +7 -80
  118. package/dist/providers/alibaba/embeddings.d.ts +2 -0
  119. package/dist/providers/alibaba/embeddings.js +1 -0
  120. package/dist/providers/alibaba.d.ts +70 -4
  121. package/dist/providers/alibaba.js +20 -2
  122. package/dist/providers/amazon-bedrock-mantle.d.ts +7 -3
  123. package/dist/providers/amazon-bedrock-mantle.js +6 -3
  124. package/dist/providers/amazon-bedrock.d.ts +6 -7
  125. package/dist/providers/amazon-bedrock.js +1 -1
  126. package/dist/providers/anthropic-compatible.d.ts +7 -8
  127. package/dist/providers/anthropic-compatible.js +2 -5
  128. package/dist/providers/anthropic.d.ts +8 -9
  129. package/dist/providers/anthropic.js +2 -7
  130. package/dist/providers/assemblyai.d.ts +2 -2
  131. package/dist/providers/assemblyai.js +2 -7
  132. package/dist/providers/azure/embeddings.d.ts +2 -0
  133. package/dist/providers/azure/embeddings.js +1 -0
  134. package/dist/providers/azure/messages.d.ts +2 -0
  135. package/dist/providers/azure/messages.js +1 -0
  136. package/dist/providers/azure.d.ts +325 -7
  137. package/dist/providers/azure.js +40 -9
  138. package/dist/providers/baseten.d.ts +7 -5
  139. package/dist/providers/baseten.js +7 -21
  140. package/dist/providers/cartesia.d.ts +1 -1
  141. package/dist/providers/cerebras.d.ts +7 -5
  142. package/dist/providers/cerebras.js +4 -15
  143. package/dist/providers/cloudflare-ai-gateway.d.ts +23 -13
  144. package/dist/providers/cloudflare-ai-gateway.js +28 -40
  145. package/dist/providers/cloudflare-shared.d.ts +9 -0
  146. package/dist/providers/cloudflare-shared.js +25 -0
  147. package/dist/providers/cloudflare-workers-ai.d.ts +6 -4
  148. package/dist/providers/cloudflare-workers-ai.js +4 -20
  149. package/dist/providers/cohere/chat.js +2 -7
  150. package/dist/providers/cohere/embeddings.d.ts +2 -0
  151. package/dist/providers/cohere/embeddings.js +1 -0
  152. package/dist/providers/cohere.d.ts +14 -5
  153. package/dist/providers/cohere.js +23 -13
  154. package/dist/providers/deepgram.d.ts +2 -2
  155. package/dist/providers/deepgram.js +2 -7
  156. package/dist/providers/deepinfra/embeddings.d.ts +2 -0
  157. package/dist/providers/deepinfra/embeddings.js +1 -0
  158. package/dist/providers/deepinfra.d.ts +10 -5
  159. package/dist/providers/deepinfra.js +20 -14
  160. package/dist/providers/deepseek.d.ts +7 -5
  161. package/dist/providers/deepseek.js +3 -14
  162. package/dist/providers/digitalocean/embeddings.d.ts +2 -0
  163. package/dist/providers/digitalocean/embeddings.js +1 -0
  164. package/dist/providers/digitalocean.d.ts +18 -5
  165. package/dist/providers/digitalocean.js +28 -14
  166. package/dist/providers/elevenlabs.d.ts +2 -2
  167. package/dist/providers/elevenlabs.js +2 -7
  168. package/dist/providers/fireworks/embeddings.d.ts +2 -0
  169. package/dist/providers/fireworks/embeddings.js +1 -0
  170. package/dist/providers/fireworks.d.ts +10 -5
  171. package/dist/providers/fireworks.js +17 -14
  172. package/dist/providers/google/embeddings.d.ts +2 -0
  173. package/dist/providers/google/embeddings.js +1 -0
  174. package/dist/providers/google/interactions.d.ts +1 -1
  175. package/dist/providers/google/interactions.js +2 -7
  176. package/dist/providers/google-vertex/embeddings.d.ts +2 -0
  177. package/dist/providers/google-vertex/embeddings.js +1 -0
  178. package/dist/providers/google-vertex-chat.d.ts +4 -3
  179. package/dist/providers/google-vertex-chat.js +3 -29
  180. package/dist/providers/google-vertex-interactions.d.ts +3 -3
  181. package/dist/providers/google-vertex-messages.d.ts +3 -3
  182. package/dist/providers/google-vertex-messages.js +3 -29
  183. package/dist/providers/google-vertex-mistral.d.ts +3 -3
  184. package/dist/providers/google-vertex-mistral.js +3 -29
  185. package/dist/providers/google-vertex-responses.d.ts +3 -3
  186. package/dist/providers/google-vertex-responses.js +4 -30
  187. package/dist/providers/google-vertex-shared.d.ts +31 -0
  188. package/dist/providers/google-vertex-shared.js +25 -0
  189. package/dist/providers/google-vertex.d.ts +10 -3
  190. package/dist/providers/google-vertex.js +52 -0
  191. package/dist/providers/google.d.ts +21 -13
  192. package/dist/providers/google.js +23 -19
  193. package/dist/providers/groq.d.ts +10 -5
  194. package/dist/providers/groq.js +4 -15
  195. package/dist/providers/meta.d.ts +6 -5
  196. package/dist/providers/meta.js +10 -23
  197. package/dist/providers/minimax/chat.js +2 -7
  198. package/dist/providers/minimax/responses.js +2 -7
  199. package/dist/providers/minimax.d.ts +6 -5
  200. package/dist/providers/minimax.js +7 -22
  201. package/dist/providers/mistral.d.ts +10 -11
  202. package/dist/providers/mistral.js +3 -14
  203. package/dist/providers/moonshot/messages.js +2 -7
  204. package/dist/providers/moonshot/responses.js +2 -7
  205. package/dist/providers/moonshot.d.ts +6 -5
  206. package/dist/providers/moonshot.js +4 -16
  207. package/dist/providers/openai/embeddings.d.ts +2 -0
  208. package/dist/providers/openai/embeddings.js +1 -0
  209. package/dist/providers/openai-compatible/embeddings.d.ts +2 -0
  210. package/dist/providers/openai-compatible/embeddings.js +1 -0
  211. package/dist/providers/openai-compatible-responses.d.ts +6 -7
  212. package/dist/providers/openai-compatible-responses.js +2 -8
  213. package/dist/providers/openai-compatible.d.ts +10 -7
  214. package/dist/providers/openai-compatible.js +17 -10
  215. package/dist/providers/openai.d.ts +11 -4
  216. package/dist/providers/openai.js +17 -3
  217. package/dist/providers/opencode.d.ts +4 -4
  218. package/dist/providers/opencode.js +6 -2
  219. package/dist/providers/openrouter/embeddings.d.ts +2 -0
  220. package/dist/providers/openrouter/embeddings.js +1 -0
  221. package/dist/providers/openrouter.d.ts +24 -5
  222. package/dist/providers/openrouter.js +31 -24
  223. package/dist/providers/runway.d.ts +1 -1
  224. package/dist/providers/settings.d.ts +40 -0
  225. package/dist/providers/settings.js +19 -0
  226. package/dist/providers/togetherai.d.ts +7 -5
  227. package/dist/providers/togetherai.js +5 -15
  228. package/dist/providers/typesafe-ai.d.ts +4 -4
  229. package/dist/providers/typesafe-ai.js +6 -2
  230. package/dist/providers/venice.d.ts +5 -4
  231. package/dist/providers/venice.js +6 -2
  232. package/dist/providers/vercel-ai-gateway/embeddings.d.ts +2 -0
  233. package/dist/providers/vercel-ai-gateway/embeddings.js +1 -0
  234. package/dist/providers/vercel-ai-gateway.d.ts +9 -5
  235. package/dist/providers/vercel-ai-gateway.js +30 -29
  236. package/dist/providers/xai.d.ts +5 -4
  237. package/dist/providers/xai.js +4 -12
  238. package/dist/providers/zai-coding-plan/messages.js +2 -7
  239. package/dist/providers/zai-coding-plan/responses.js +2 -7
  240. package/dist/providers/zai-coding-plan.d.ts +6 -5
  241. package/dist/providers/zai-coding-plan.js +8 -15
  242. package/dist/providers/zai.d.ts +6 -5
  243. package/dist/providers/zai.js +10 -22
  244. package/dist/public.d.ts +14 -0
  245. package/dist/public.js +6 -0
  246. package/dist/route/auth-options.d.ts +9 -5
  247. package/dist/route/auth-options.js +10 -7
  248. package/dist/route/client.d.ts +50 -37
  249. package/dist/route/client.js +42 -53
  250. package/dist/route/decision.d.ts +8 -8
  251. package/dist/route/decision.js +3 -3
  252. package/dist/route/embedding.d.ts +61 -0
  253. package/dist/route/embedding.js +88 -0
  254. package/dist/route/executor.d.ts +5 -0
  255. package/dist/route/executor.js +10 -0
  256. package/dist/route/index.d.ts +5 -7
  257. package/dist/route/index.js +1 -1
  258. package/dist/route/media.d.ts +7 -11
  259. package/dist/route/media.js +22 -26
  260. package/dist/route/transport/http.js +6 -5
  261. package/dist/route/transport/websocket.js +7 -1
  262. package/dist/schema/errors.d.ts +16 -17
  263. package/dist/schema/errors.js +63 -12
  264. package/dist/schema/events.d.ts +2563 -2954
  265. package/dist/schema/events.js +54 -109
  266. package/dist/schema/messages.d.ts +194 -137
  267. package/dist/schema/messages.js +66 -83
  268. package/dist/schema/options.d.ts +112 -65
  269. package/dist/schema/options.js +52 -101
  270. package/dist/speech-client.d.ts +7 -7
  271. package/dist/speech.d.ts +306 -316
  272. package/dist/speech.js +16 -14
  273. package/dist/testing.d.ts +31 -175
  274. package/dist/testing.js +60 -5
  275. package/dist/tool-history.d.ts +1 -1
  276. package/dist/tool-history.js +3 -10
  277. package/dist/tool-runtime.d.ts +9 -2
  278. package/dist/tool-runtime.js +17 -31
  279. package/dist/tool.d.ts +39 -43
  280. package/dist/tool.js +16 -26
  281. package/dist/transcription-client.d.ts +7 -7
  282. package/dist/transcription.d.ts +314 -265
  283. package/dist/transcription.js +16 -14
  284. package/dist/utils/provider-codes.d.ts +3 -0
  285. package/dist/utils/provider-codes.js +41 -0
  286. package/dist/video-client.d.ts +7 -7
  287. package/dist/video-client.js +1 -1
  288. package/dist/video.d.ts +269 -287
  289. package/dist/video.js +16 -14
  290. package/package.json +309 -257
  291. package/dist/experimental/testing.d.ts +0 -3
  292. package/dist/experimental/testing.js +0 -3
  293. package/dist/testing/decision.d.ts +0 -16
  294. package/dist/testing/decision.js +0 -20
  295. package/dist/testing/image.d.ts +0 -14
  296. package/dist/testing/image.js +0 -12
  297. package/dist/testing/media.d.ts +0 -18
  298. package/dist/testing/media.js +0 -36
  299. package/dist/testing/script.d.ts +0 -28
  300. package/dist/testing/script.js +0 -60
  301. package/dist/testing/speech.d.ts +0 -14
  302. package/dist/testing/speech.js +0 -12
  303. package/dist/testing/transcription.d.ts +0 -14
  304. package/dist/testing/transcription.js +0 -12
  305. package/dist/testing/video.d.ts +0 -14
  306. package/dist/testing/video.js +0 -12
@@ -21,10 +21,14 @@ declare const Options: Schema.Struct<{
21
21
  export type OptionsInput = typeof Options.Type;
22
22
  export declare const compatibility: {
23
23
  maxTokensField: "max_tokens";
24
- supportsStrictMode: false;
25
24
  reasoningField: string;
26
25
  zaiToolStream: false;
27
26
  };
27
+ export declare const capabilities: {
28
+ tools: {
29
+ strict: false;
30
+ };
31
+ };
28
32
  export declare const protocol: Protocol<{
29
33
  readonly model: string;
30
34
  readonly messages: readonly ({
@@ -125,6 +129,7 @@ export declare const protocol: Protocol<{
125
129
  readonly reasoning?: string | undefined;
126
130
  readonly reasoning_text?: string | undefined;
127
131
  readonly reasoning_details?: unknown;
132
+ readonly reasoning_opaque?: string | undefined;
128
133
  })[];
129
134
  readonly tools?: readonly ({
130
135
  readonly type: "function";
@@ -220,6 +225,7 @@ export declare const protocol: Protocol<{
220
225
  readonly reasoning?: string | null | undefined;
221
226
  readonly reasoning_text?: string | null | undefined;
222
227
  readonly reasoning_details?: unknown;
228
+ readonly reasoning_opaque?: string | null | undefined;
223
229
  readonly tool_calls?: readonly {
224
230
  readonly index?: number | null | undefined;
225
231
  readonly id?: string | null | undefined;
@@ -245,6 +251,7 @@ export declare const protocol: Protocol<{
245
251
  readonly prompt_cache_hit_tokens?: number | null | undefined;
246
252
  readonly cache_read_input_tokens?: number | null | undefined;
247
253
  readonly cache_created_input_tokens?: number | null | undefined;
254
+ readonly reasoning_tokens?: number | null | undefined;
248
255
  readonly prompt_tokens_details?: {
249
256
  readonly [x: string]: unknown;
250
257
  readonly cached_tokens?: number | null | undefined;
@@ -267,6 +274,7 @@ export declare const protocol: Protocol<{
267
274
  readonly prompt_cache_hit_tokens?: number | null | undefined;
268
275
  readonly cache_read_input_tokens?: number | null | undefined;
269
276
  readonly cache_created_input_tokens?: number | null | undefined;
277
+ readonly reasoning_tokens?: number | null | undefined;
270
278
  readonly prompt_tokens_details?: {
271
279
  readonly [x: string]: unknown;
272
280
  readonly cached_tokens?: number | null | undefined;
@@ -44,10 +44,10 @@ const fromRequest = Effect.fn("ZAIChat.fromRequest")(function* (request) {
44
44
  });
45
45
  export const compatibility = {
46
46
  maxTokensField: "max_tokens",
47
- supportsStrictMode: false,
48
47
  reasoningField: "reasoning_content",
49
48
  zaiToolStream: false,
50
49
  };
50
+ export const capabilities = { tools: { strict: false } };
51
51
  export const protocol = Protocol.make({
52
52
  id: "zai-chat",
53
53
  body: { schema: Body, from: fromRequest },
@@ -1,4 +1,4 @@
1
- import { ImageModel, ImageResponse, type ImageRequestFor } from "../image.js";
1
+ import { ImageModel, ImageResponse, type ImageRequest } from "../image.js";
2
2
  import { MediaProtocol } from "../route/media-protocol.js";
3
3
  import { MediaRoute } from "../route/media.js";
4
4
  import { type OpenString } from "../schema/index.js";
@@ -11,7 +11,7 @@ export type ZAIImageOptions = {
11
11
  readonly quality?: OpenString<"hd" | "standard">;
12
12
  readonly userID?: string;
13
13
  } & Record<string, unknown>;
14
- export type Request = ImageRequestFor<ZAIImageOptions>;
14
+ export type Request = ImageRequest<ImageModel<ZAIImageOptions>>;
15
15
  export declare const protocol: MediaProtocol.Inline<Request, ImageResponse>;
16
16
  export declare const model: (input: MediaRoute.ModelInput) => ImageModel<ZAIImageOptions>;
17
17
  export declare const ZAIImages: {
@@ -1,6 +1,5 @@
1
1
  import { Effect, Schema } from "effect";
2
2
  import { Protocol } from "../route/protocol.js";
3
- import { LLMRequest } from "../schema/index.js";
4
3
  import { AnthropicMessages } from "./anthropic-messages.js";
5
4
  import { ProviderShared } from "./shared.js";
6
5
  import { OpenResponsesOptions } from "./utils/open-responses-options.js";
@@ -15,9 +14,10 @@ const Body = Schema.Struct({
15
14
  const fromRequest = Effect.fn("ZAIMessages.fromRequest")(function* (request) {
16
15
  const options = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Options))(request.providerOptions ?? {});
17
16
  // Z.AI accepts enabled thinking without Anthropic's mandatory token budget.
18
- const body = yield* AnthropicMessages.protocol.body.from(LLMRequest.update(request, {
17
+ const body = yield* AnthropicMessages.protocol.body.from({
18
+ ...request,
19
19
  providerOptions: { ...request.providerOptions, thinking: undefined },
20
- }));
20
+ });
21
21
  return { ...body, thinking: options.thinking };
22
22
  });
23
23
  export const protocol = Protocol.make({
@@ -1,6 +1,5 @@
1
1
  import { AIError, type HttpContext, type HttpRateLimitDetails } from "./schema/index.js";
2
2
  export declare const isContextOverflow: (message: string) => boolean;
3
- export declare const isPayloadTooLarge: (message: string) => boolean;
4
3
  export declare const isContextOverflowFailure: (failure: unknown) => boolean;
5
4
  /**
6
5
  * Whether a failed call may succeed when sent again: rate limits, provider-side failures, transport failures that did
@@ -1,7 +1,6 @@
1
1
  import { Option, Schema, SchemaGetter } from "effect";
2
- import { AuthenticationError, ContentPolicyError, InvalidRequestError, AIError, ProviderErrorEvent, ProviderInternalError, QuotaExceededError, RateLimitError, UnknownProviderError, } from "./schema/index.js";
3
- import { Json } from "./utils/json.js";
4
- import { isRecord } from "./utils/record.js";
2
+ import { AuthenticationError, ContentPolicyError, InvalidRequestError, AIError, ProviderInternalError, QuotaExceededError, RateLimitError, UnknownProviderError, } from "./schema/index.js";
3
+ import { awsErrorType, providerCodes } from "./utils/provider-codes.js";
5
4
  const patterns = [
6
5
  /prompt is too long/i,
7
6
  /input is too long for (?:the )?(?:requested|selected) model/i,
@@ -57,51 +56,15 @@ const exclusions = [
57
56
  ];
58
57
  export const isContextOverflow = (message) => !exclusions.some((pattern) => pattern.test(message)) &&
59
58
  (patterns.some((pattern) => pattern.test(message)) || /^4(?:00|13)\s*(status code)?\s*\(no body\)/i.test(message));
60
- export const isPayloadTooLarge = (message) => payloadPatterns.some((pattern) => pattern.test(message));
61
- export const isContextOverflowFailure = (failure) => failure instanceof AIError
62
- ? failure.reason._tag === "InvalidRequest" && failure.reason.classification === "context-overflow"
63
- : Schema.is(ProviderErrorEvent)(failure) && failure.classification === "context-overflow";
59
+ const isPayloadTooLarge = (message) => payloadPatterns.some((pattern) => pattern.test(message));
60
+ export const isContextOverflowFailure = (failure) => failure instanceof AIError &&
61
+ failure.reason._tag === "InvalidRequest" &&
62
+ failure.reason.classification === "context-overflow";
64
63
  /**
65
64
  * Whether a failed call may succeed when sent again: rate limits, provider-side failures, transport failures that did
66
65
  * not deliver an accepted write, and unrecognized failures. Callers decide which calls are safe to repeat.
67
66
  */
68
- export const isRetryable = (error) => {
69
- const override = error.reason.http?.headers["x-should-retry"];
70
- if (override === "true")
71
- return true;
72
- if (override === "false")
73
- return false;
74
- switch (error.reason._tag) {
75
- case "RateLimit":
76
- case "ProviderInternal":
77
- return true;
78
- // A WebSocket acknowledgment marks delivery accepted before model output may exist.
79
- // Read failures can still recover; the caller chooses retry versus continuation from durable output.
80
- case "Transport":
81
- return (error.reason.delivery !== "rejected" &&
82
- (error.reason.delivery !== "accepted" || error.reason.operation === "read"));
83
- case "InvalidProviderOutput":
84
- return error.reason.classification === "incomplete-stream";
85
- // Unrecognized failures retry: classification records affirmative
86
- // deterministic evidence, and transient failures are exactly the ones
87
- // that arrive in shapes no classifier anticipates.
88
- case "UnknownProvider":
89
- return true;
90
- case "Authentication":
91
- case "QuotaExceeded":
92
- case "ContentPolicy":
93
- case "InvalidRequest":
94
- case "UnsupportedOperation":
95
- case "NoRoute":
96
- case "Timeout":
97
- return false;
98
- default: {
99
- const exhaustive = error.reason;
100
- return exhaustive;
101
- }
102
- }
103
- };
104
- const decodeJson = Schema.decodeUnknownOption(Json);
67
+ export const isRetryable = (error) => error.isRetryable;
105
68
  // OpenCode Zen reports account caps as typed 429/402 errors that are not throttles.
106
69
  const QUOTA_CODES = new Set([
107
70
  "insufficient_quota",
@@ -251,39 +214,3 @@ export function classifyProviderFailure(input) {
251
214
  return new InvalidRequestError(details);
252
215
  return new UnknownProviderError(details);
253
216
  }
254
- function providerCodes(value) {
255
- const decoded = typeof value === "string" ? Option.getOrUndefined(decodeJson(value)) : value;
256
- if (!isRecord(decoded))
257
- return [];
258
- const error = isRecord(decoded.error) ? decoded.error : undefined;
259
- const inner = error && isRecord(error.innererror) ? error.innererror : undefined;
260
- const metadata = error && isRecord(error.metadata) ? error.metadata : undefined;
261
- const response = isRecord(decoded.response) ? decoded.response : undefined;
262
- const responseError = response && isRecord(response.error) ? response.error : undefined;
263
- const exception = isRecord(decoded.exception) ? decoded.exception : undefined;
264
- return [
265
- decoded.code,
266
- ...awsErrorType(decoded.__type),
267
- ...awsErrorType(decoded.code),
268
- decoded.error_type,
269
- error?.code,
270
- error?.type,
271
- error?.status,
272
- error?.error_type,
273
- // Google `google.rpc.ErrorInfo` details carry the specific reason.
274
- ...(Array.isArray(error?.details)
275
- ? error.details.map((detail) => (isRecord(detail) ? detail.reason : undefined))
276
- : []),
277
- inner?.code,
278
- metadata?.error_type,
279
- responseError?.code,
280
- response?.error_type,
281
- exception?.type,
282
- ].filter((value) => typeof value === "string");
283
- }
284
- // AWS restJson1 reports the modeled error in `X-Amzn-Errortype`, `__type` or `code`, possibly
285
- // namespaced (`ns#Name`) or suffixed (`Name:uri`). Keep the shape name only.
286
- // https://smithy.io/2.0/aws/protocols/aws-restjson1-protocol.html#operation-error-serialization
287
- function awsErrorType(value) {
288
- return typeof value === "string" ? [value.replace(/:.*/s, "").replace(/^[^#]*#/, "")] : [];
289
- }
@@ -0,0 +1,2 @@
1
+ export { embeddingModel as model } from "../alibaba.js";
2
+ export type { Settings } from "../alibaba.js";
@@ -0,0 +1 @@
1
+ export { embeddingModel as model } from "../alibaba.js";
@@ -3,8 +3,8 @@ import { AlibabaChat } from "../protocols/alibaba-chat.js";
3
3
  import { AlibabaMessages } from "../protocols/alibaba-messages.js";
4
4
  import { AlibabaResponses } from "../protocols/alibaba-responses.js";
5
5
  import { type AtLeastOne, type ProviderAuthOption } from "../route/auth-options.js";
6
- import { Route, type RouteDefaultsInput } from "../route/client.js";
7
- import { ToolDefinition, type ModelID, type ProviderOptions } from "../schema/index.js";
6
+ import { Route } from "../route/client.js";
7
+ import { ToolDefinition, type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
8
8
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
9
9
  export type Region = "ap-southeast-1" | "cn-beijing" | "cn-hongkong" | "us-east-1" | "eu-central-1" | "ap-northeast-1" | (string & {});
10
10
  export type ChatOptionsInput = AlibabaChat.OptionsInput;
@@ -18,11 +18,11 @@ type Location = AtLeastOne<{
18
18
  }> & {
19
19
  readonly workspaceID?: string;
20
20
  };
21
- export type Config = Location & Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
21
+ export type Config = Location & Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
22
22
  readonly providerOptions?: ChatOptionsInput | MessagesOptionsInput | ResponsesOptionsInput;
23
23
  };
24
24
  export type Settings<Options = ChatOptionsInput> = Location & ProviderPackage.Settings & Options & {
25
- readonly apiKey?: string;
25
+ readonly apiKey?: string | false;
26
26
  };
27
27
  export declare const routes: (Route<{
28
28
  readonly model: string;
@@ -124,6 +124,7 @@ export declare const routes: (Route<{
124
124
  readonly reasoning?: string | undefined;
125
125
  readonly reasoning_text?: string | undefined;
126
126
  readonly reasoning_details?: unknown;
127
+ readonly reasoning_opaque?: string | undefined;
127
128
  })[];
128
129
  readonly tools?: readonly ({
129
130
  readonly type: "function";
@@ -775,6 +776,7 @@ export declare const configure: (input: Config) => {
775
776
  readonly conversation?: string | undefined;
776
777
  }, import("../route/client.js").CompactionOperations | undefined>;
777
778
  image: (id: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("./alibaba.js").AlibabaImageOptions>;
779
+ embedding: (id: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<import("../embedding.js").EmbeddingOptions>;
778
780
  configure: typeof configure;
779
781
  };
780
782
  export declare const provider: {
@@ -784,7 +786,71 @@ export declare const provider: {
784
786
  export declare const model: ProviderPackage.Model<Settings, ChatOptionsInput>;
785
787
  export declare const messagesModel: ProviderPackage.Model<Settings<MessagesOptionsInput>, MessagesOptionsInput>;
786
788
  export declare const responsesModel: ProviderPackage.Model<Settings<ResponsesOptionsInput>, ResponsesOptionsInput>;
789
+ export declare const chat: ProviderPackage.Model<Settings<{
790
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
791
+ readonly enableThinking?: boolean | undefined;
792
+ readonly thinkingBudget?: number | undefined;
793
+ readonly preserveThinking?: boolean | undefined;
794
+ readonly clearThinking?: boolean | undefined;
795
+ readonly thinking?: {
796
+ readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled">;
797
+ } | undefined;
798
+ readonly toolStream?: boolean | undefined;
799
+ readonly parallelToolCalls?: boolean | undefined;
800
+ readonly repetitionPenalty?: number | undefined;
801
+ readonly responseFormat?: {
802
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">;
803
+ readonly json_schema?: {
804
+ readonly [x: string]: unknown;
805
+ } | undefined;
806
+ } | undefined;
807
+ readonly enableSearch?: boolean | undefined;
808
+ readonly searchOptions?: {
809
+ readonly forced_search?: boolean | undefined;
810
+ readonly search_strategy?: import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo"> | undefined;
811
+ readonly enable_search_extension?: boolean | undefined;
812
+ } | undefined;
813
+ }>, {
814
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
815
+ readonly enableThinking?: boolean | undefined;
816
+ readonly thinkingBudget?: number | undefined;
817
+ readonly preserveThinking?: boolean | undefined;
818
+ readonly clearThinking?: boolean | undefined;
819
+ readonly thinking?: {
820
+ readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled">;
821
+ } | undefined;
822
+ readonly toolStream?: boolean | undefined;
823
+ readonly parallelToolCalls?: boolean | undefined;
824
+ readonly repetitionPenalty?: number | undefined;
825
+ readonly responseFormat?: {
826
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">;
827
+ readonly json_schema?: {
828
+ readonly [x: string]: unknown;
829
+ } | undefined;
830
+ } | undefined;
831
+ readonly enableSearch?: boolean | undefined;
832
+ readonly searchOptions?: {
833
+ readonly forced_search?: boolean | undefined;
834
+ readonly search_strategy?: import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo"> | undefined;
835
+ readonly enable_search_extension?: boolean | undefined;
836
+ } | undefined;
837
+ }, import("../route/client.js").CompactionOperations | undefined>;
838
+ export declare const messages: ProviderPackage.Model<Settings<AlibabaMessages.OptionsInput>, AlibabaMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
839
+ export declare const responses: ProviderPackage.Model<Settings<{
840
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
841
+ readonly enableThinking?: boolean | undefined;
842
+ readonly store?: boolean | undefined;
843
+ readonly previousResponseId?: string | undefined;
844
+ readonly conversation?: string | undefined;
845
+ }>, {
846
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
847
+ readonly enableThinking?: boolean | undefined;
848
+ readonly store?: boolean | undefined;
849
+ readonly previousResponseId?: string | undefined;
850
+ readonly conversation?: string | undefined;
851
+ }, import("../route/client.js").CompactionOperations | undefined>;
787
852
  export declare const imageModel: (id: string, settings: Settings) => import("../image.js").ImageModel<import("./alibaba.js").AlibabaImageOptions>;
853
+ export declare const embeddingModel: (id: string, settings: Settings) => import("../embedding.js").EmbeddingModel<import("../embedding.js").EmbeddingOptions>;
788
854
  export declare const webSearch: () => ToolDefinition;
789
855
  export declare const webExtractor: () => ToolDefinition;
790
856
  export declare const codeInterpreter: () => ToolDefinition;
@@ -1,6 +1,7 @@
1
1
  import { Struct } from "effect";
2
2
  import { AlibabaChat } from "../protocols/alibaba-chat.js";
3
3
  import { AlibabaImages } from "../protocols/alibaba-images.js";
4
+ import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
4
5
  import { AlibabaMessages } from "../protocols/alibaba-messages.js";
5
6
  import { AlibabaResponses } from "../protocols/alibaba-responses.js";
6
7
  import { AuthOptions } from "../route/auth-options.js";
@@ -60,7 +61,9 @@ export const configure = (input) => {
60
61
  }
61
62
  const opts = { ...rest, auth: AuthOptions.bearer(input, ["DASHSCOPE_API_KEY", "ALIBABA_API_KEY"]) };
62
63
  const common = { ...opts, endpoint: { baseURL: baseURL ?? `https://${host}/compatible-mode/v1` } };
63
- const chat = (id) => chatRoute.with(common).model({ id, compatibility: AlibabaChat.compatibility });
64
+ const chat = (id) => chatRoute
65
+ .with(common)
66
+ .model({ id, compatibility: AlibabaChat.compatibility, capabilities: AlibabaChat.capabilities });
64
67
  const messages = (id) => messagesRoute
65
68
  .with({
66
69
  ...opts,
@@ -70,16 +73,31 @@ export const configure = (input) => {
70
73
  const responses = (id) => responsesRoute.with(common).model({ id });
71
74
  const media = MediaRoute.deployment({ ...input, baseURL: baseURL ?? `https://${host}/api/v1` }, opts.auth);
72
75
  const image = (id, providerOptions) => AlibabaImages.model({ ...media, id, providerOptions });
73
- return { id, model: chat, chat, messages, responses, image, configure };
76
+ const embeddingRoute = OpenAIEmbeddings.route.with({
77
+ provider: id,
78
+ endpoint: common.endpoint,
79
+ auth: opts.auth,
80
+ headers: input.headers,
81
+ http: input.http,
82
+ });
83
+ const embedding = (id, providerOptions) => embeddingRoute.model({ id, providerOptions });
84
+ return { id, model: chat, chat, messages, responses, image, embedding, configure };
74
85
  };
75
86
  export const provider = { id, configure };
76
87
  export const model = (id, input) => configure(config(input)).chat(id);
77
88
  export const messagesModel = (id, input) => configure(config(input)).messages(id);
78
89
  export const responsesModel = (id, input) => configure(config(input)).responses(id);
90
+ export const chat = model;
91
+ export const messages = messagesModel;
92
+ export const responses = responsesModel;
79
93
  export const imageModel = (id, settings) => {
80
94
  const input = config(settings);
81
95
  return configure(input).image(id, input.providerOptions);
82
96
  };
97
+ export const embeddingModel = (id, settings) => {
98
+ const input = config(settings);
99
+ return configure(input).embedding(id, input.providerOptions);
100
+ };
83
101
  function config(input) {
84
102
  const { body, ...rest } = input;
85
103
  return {
@@ -1,13 +1,13 @@
1
- import { Route, type RouteDefaultsInput } from "../route/client.js";
1
+ import { Route } from "../route/client.js";
2
2
  import type { ProviderPackage } from "../provider-package.js";
3
3
  import { AnthropicMessages } from "../protocols/anthropic-messages.js";
4
4
  import { type Credentials } from "../protocols/utils/bedrock-auth.js";
5
- import { type ModelID } from "../schema/index.js";
5
+ import { type ModelID, type RequestOptions } from "../schema/index.js";
6
6
  import { type OpenAIProviderOptionsInput } from "./openai-options.js";
7
7
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
8
8
  export type OpenAIOptionsInput = OpenAIProviderOptionsInput;
9
9
  export type MessagesOptionsInput = AnthropicMessages.ProviderOptionsInput;
10
- export type Config = Omit<RouteDefaultsInput, "providerOptions"> & {
10
+ export type Config = Omit<RequestOptions, "providerOptions"> & {
11
11
  /** Bedrock API key. Falls back to `AWS_BEARER_TOKEN_BEDROCK`; bearer auth takes precedence over SigV4. */
12
12
  readonly apiKey?: string;
13
13
  /** `sigv4` ignores `apiKey` fallbacks from the environment; `bearer` requires a token. */
@@ -641,6 +641,7 @@ export declare const routes: (Route<{
641
641
  readonly reasoning?: string | undefined;
642
642
  readonly reasoning_text?: string | undefined;
643
643
  readonly reasoning_details?: unknown;
644
+ readonly reasoning_opaque?: string | undefined;
644
645
  })[];
645
646
  readonly tools?: readonly ({
646
647
  readonly type: "function";
@@ -731,6 +732,9 @@ export declare const provider: {
731
732
  responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
732
733
  configure: typeof configure;
733
734
  };
735
+ export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
736
+ export declare const messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
737
+ export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
734
738
  export declare const chatModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
735
739
  export declare const messagesModel: ProviderPackage.Model<MessagesSettings, AnthropicMessages.ProviderOptionsInput>;
736
740
  export declare const responsesModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
@@ -15,7 +15,7 @@ const responsesRoute = Route.make({
15
15
  protocol: OpenResponses.protocol,
16
16
  endpoint: Endpoint.path(OpenResponses.PATH),
17
17
  transport: OpenResponses.httpTransport,
18
- defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
18
+ options: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
19
19
  });
20
20
  const chatRoute = OpenAIChat.route.with({
21
21
  id: "bedrock-mantle-chat",
@@ -32,7 +32,7 @@ const messagesRoute = Route.make({
32
32
  supportsEffortUpdates: (request) => {
33
33
  if (!(AnthropicMessages.protocol.supportsEffortUpdates?.(request) ?? false))
34
34
  return false;
35
- if (request.model.compatibility?.supportsEffortUpdates !== undefined)
35
+ if (request.model.capabilities?.reasoning?.updates !== undefined)
36
36
  return true;
37
37
  const version = claudeVersion(request.model.id);
38
38
  return version !== undefined && (version.major > 5 || (version.major === 5 && version.minor >= 1));
@@ -87,12 +87,15 @@ export const configure = (input = {}) => {
87
87
  };
88
88
  };
89
89
  export const provider = configure();
90
+ export const chat = provider.chat;
91
+ export const messages = provider.messages;
92
+ export const responses = provider.responses;
90
93
  const fromSettings = ({ apiKey, auth, baseURL, body, credentials, headers, profile, region, topP, ...providerOptions } = {}) => configure({
91
94
  apiKey,
92
95
  auth,
93
96
  baseURL,
94
97
  credentials,
95
- generation: topP === undefined ? undefined : { topP },
98
+ topP,
96
99
  headers,
97
100
  http: body === undefined ? undefined : { body },
98
101
  profile,
@@ -1,10 +1,9 @@
1
- import type { RouteDefaultsInput } from "../route/client.js";
2
1
  import type { ProviderPackage } from "../provider-package.js";
3
- import { type ModelID } from "../schema/index.js";
2
+ import { type ModelID, type RequestOptions } from "../schema/index.js";
4
3
  import * as BedrockConverse from "../protocols/bedrock-converse.js";
5
4
  import type { BedrockCredentials } from "../protocols/bedrock-converse.js";
6
5
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
- export type Config = RouteDefaultsInput & {
6
+ export type Config = RequestOptions & {
8
7
  /** Bedrock API key. Falls back to `AWS_BEARER_TOKEN_BEDROCK`; bearer auth takes precedence over SigV4. */
9
8
  readonly apiKey?: string;
10
9
  /** `sigv4` ignores `apiKey` fallbacks from the environment; `bearer` requires a token. */
@@ -29,7 +28,7 @@ export type Settings = ProviderPackage.Settings & BedrockConverse.OptionsInput &
29
28
  readonly region?: string;
30
29
  readonly topP?: number;
31
30
  };
32
- export declare const routes: import("../route/client.js").Route<{
31
+ export declare const routes: import("../route.js").Route<{
33
32
  readonly modelId: string;
34
33
  readonly messages: readonly ({
35
34
  readonly role: "user";
@@ -178,15 +177,15 @@ export declare const routes: import("../route/client.js").Route<{
178
177
  }, import("../route/transport/http.js").HttpPrepared<{
179
178
  readonly [x: string]: unknown;
180
179
  readonly rawBody: string;
181
- }>, import("../route/client.js").CompactionOperations | undefined>[];
180
+ }>, import("../route.js").CompactionOperations | undefined>[];
182
181
  export declare const configure: (input?: Config) => {
183
182
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
184
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<BedrockConverse.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
183
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<BedrockConverse.OptionsInput, import("../route.js").CompactionOperations | undefined>;
185
184
  configure: typeof configure;
186
185
  };
187
186
  export declare const provider: {
188
187
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
189
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<BedrockConverse.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
188
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<BedrockConverse.OptionsInput, import("../route.js").CompactionOperations | undefined>;
190
189
  configure: typeof configure;
191
190
  };
192
191
  export declare const model: ProviderPackage.Model<Settings, BedrockConverse.OptionsInput>;
@@ -33,7 +33,7 @@ export const model = (modelID, { apiKey, auth, baseURL, credentials, profile, re
33
33
  auth,
34
34
  baseURL,
35
35
  credentials,
36
- generation: topP === undefined ? undefined : { topP },
36
+ topP,
37
37
  headers: headers === undefined ? undefined : { ...headers },
38
38
  http: body === undefined ? undefined : { body: { ...body } },
39
39
  providerOptions,
@@ -1,19 +1,18 @@
1
1
  import type { ProviderPackage } from "../provider-package.js";
2
2
  import { AnthropicMessages } from "../protocols/anthropic-messages.js";
3
- import type { ProviderAuthOption } from "../route/auth-options.js";
4
- import type { RouteDefaultsInput } from "../route/client.js";
5
- import { type ModelID } from "../schema/index.js";
3
+ import { type ProviderAuthOption } from "../route/auth-options.js";
4
+ import { type ModelID, type RequestOptions } from "../schema/index.js";
6
5
  export type AnthropicOptionsInput = AnthropicMessages.OptionsInput;
7
6
  export type AnthropicProviderOptionsInput = AnthropicMessages.ProviderOptionsInput;
8
7
  export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput;
9
8
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
10
- export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
9
+ export type Config = RequestOptions & ProviderAuthOption<"optional"> & {
11
10
  readonly provider?: string;
12
11
  readonly baseURL: string;
13
12
  readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
14
13
  };
15
14
  export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOptionsInput & ({
16
- readonly apiKey?: string;
15
+ readonly apiKey?: string | false;
17
16
  readonly authToken?: never;
18
17
  } | {
19
18
  readonly apiKey?: never;
@@ -22,7 +21,7 @@ export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOpti
22
21
  readonly baseURL: string;
23
22
  readonly provider?: string;
24
23
  };
25
- export declare const routes: import("../route/client.js").Route<{
24
+ export declare const routes: import("../route.js").Route<{
26
25
  readonly context_management?: {
27
26
  readonly edits: readonly {
28
27
  readonly type: "compact_20260112";
@@ -329,10 +328,10 @@ export declare const routes: import("../route/client.js").Route<{
329
328
  } | undefined;
330
329
  readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
331
330
  readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
332
- }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
331
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route.js").CompactionOperations | undefined>[];
333
332
  export declare const configure: (input: Config) => {
334
333
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
335
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
334
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route.js").CompactionOperations | undefined>;
336
335
  configure: typeof configure;
337
336
  };
338
337
  export declare const provider: {
@@ -1,14 +1,11 @@
1
1
  import { AnthropicMessages } from "../protocols/anthropic-messages.js";
2
2
  import { Auth } from "../route/auth.js";
3
+ import { AuthOptions } from "../route/auth-options.js";
3
4
  import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
4
5
  export const id = ProviderID.make("anthropic-compatible");
5
6
  const compatibleRoute = AnthropicMessages.route.with({ id: "anthropic-compatible-messages", provider: id });
6
7
  export const routes = [compatibleRoute];
7
- const auth = (input) => {
8
- if ("auth" in input && input.auth)
9
- return input.auth;
10
- return Auth.optional("apiKey" in input ? input.apiKey : undefined, "apiKey").pipe(Auth.header("x-api-key"));
11
- };
8
+ const auth = (input) => AuthOptions.apiKey(input, [], Auth.header("x-api-key"));
12
9
  export const configure = (input) => {
13
10
  const provider = input.provider ?? "anthropic-compatible";
14
11
  if (!input.baseURL)
@@ -1,13 +1,12 @@
1
- import type { RouteDefaultsInput } from "../route/client.js";
2
- import type { ProviderAuthOption } from "../route/auth-options.js";
1
+ import { type ProviderAuthOption } from "../route/auth-options.js";
3
2
  import type { ProviderPackage } from "../provider-package.js";
4
- import { type ModelID } from "../schema/index.js";
3
+ import { type ModelID, type RequestOptions } from "../schema/index.js";
5
4
  import { AnthropicMessages } from "../protocols/anthropic-messages.js";
6
5
  export type AnthropicOptionsInput = AnthropicMessages.OptionsInput;
7
6
  export type AnthropicProviderOptionsInput = AnthropicMessages.ProviderOptionsInput;
8
7
  export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput;
9
8
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
10
- export declare const routes: import("../route/client.js").Route<{
9
+ export declare const routes: import("../route.js").Route<{
11
10
  readonly context_management?: {
12
11
  readonly edits: readonly {
13
12
  readonly type: "compact_20260112";
@@ -314,13 +313,13 @@ export declare const routes: import("../route/client.js").Route<{
314
313
  } | undefined;
315
314
  readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
316
315
  readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
317
- }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
318
- export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
316
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route.js").CompactionOperations | undefined>[];
317
+ export type Config = RequestOptions & ProviderAuthOption<"optional"> & {
319
318
  readonly baseURL?: string;
320
319
  readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
321
320
  };
322
321
  export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOptionsInput & ({
323
- readonly apiKey?: string;
322
+ readonly apiKey?: string | false;
324
323
  readonly authToken?: never;
325
324
  } | {
326
325
  readonly apiKey?: never;
@@ -330,12 +329,12 @@ export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOpti
330
329
  };
331
330
  export declare const configure: (input?: Config) => {
332
331
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
333
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
332
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route.js").CompactionOperations | undefined>;
334
333
  configure: typeof configure;
335
334
  };
336
335
  export declare const provider: {
337
336
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
338
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
337
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route.js").CompactionOperations | undefined>;
339
338
  configure: typeof configure;
340
339
  };
341
340
  export declare const model: ProviderPackage.Model<Settings, AnthropicMessages.ProviderOptionsInput>;