@opencode/ai 2.1.2 → 2.1.3

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 (87) hide show
  1. package/dist/cache-policy.js +6 -5
  2. package/dist/experimental/evaluation.d.ts +7 -6
  3. package/dist/experimental/evaluation.js +2 -3
  4. package/dist/experimental/realtime.d.ts +59 -0
  5. package/dist/experimental/realtime.js +21 -13
  6. package/dist/experimental.d.ts +1 -1
  7. package/dist/generation.js +1 -1
  8. package/dist/image-client.d.ts +3 -1
  9. package/dist/image.d.ts +10 -2
  10. package/dist/image.js +2 -2
  11. package/dist/llm.d.ts +2 -4
  12. package/dist/llm.js +2 -2
  13. package/dist/media-model.d.ts +2 -2
  14. package/dist/media-model.js +1 -1
  15. package/dist/promise.d.ts +1 -1
  16. package/dist/promise.js +3 -5
  17. package/dist/protocols/alibaba-chat.d.ts +6 -6
  18. package/dist/protocols/alibaba-chat.js +3 -3
  19. package/dist/protocols/alibaba-messages.d.ts +1 -1
  20. package/dist/protocols/alibaba-messages.js +1 -1
  21. package/dist/protocols/alibaba-responses.d.ts +3 -3
  22. package/dist/protocols/anthropic-messages.js +10 -12
  23. package/dist/protocols/bedrock-converse.d.ts +6 -53
  24. package/dist/protocols/bedrock-converse.js +4 -3
  25. package/dist/protocols/bedrock-event-stream.d.ts +6 -1
  26. package/dist/protocols/bedrock-event-stream.js +9 -8
  27. package/dist/protocols/cohere-chat.d.ts +6 -2
  28. package/dist/protocols/cohere-chat.js +2 -2
  29. package/dist/protocols/gemini.d.ts +12 -2
  30. package/dist/protocols/gemini.js +10 -13
  31. package/dist/protocols/google-interactions.d.ts +2 -1
  32. package/dist/protocols/google-interactions.js +14 -9
  33. package/dist/protocols/meta-responses.d.ts +6 -6
  34. package/dist/protocols/mistral-chat.js +1 -4
  35. package/dist/protocols/open-responses.d.ts +21 -21
  36. package/dist/protocols/open-responses.js +3 -3
  37. package/dist/protocols/openai-chat.d.ts +8 -7
  38. package/dist/protocols/openai-chat.js +4 -5
  39. package/dist/protocols/openai-compatible-responses.d.ts +3 -3
  40. package/dist/protocols/openai-responses.d.ts +18 -18
  41. package/dist/protocols/utils/open-responses-options.d.ts +8 -8
  42. package/dist/protocols/utils/open-responses-options.js +4 -6
  43. package/dist/protocols/utils/partial-json.js +5 -4
  44. package/dist/protocols/utils/tool-schema.d.ts +0 -3
  45. package/dist/protocols/utils/tool-schema.js +0 -4
  46. package/dist/protocols/xai-images.js +3 -4
  47. package/dist/protocols/xai-responses.d.ts +3 -3
  48. package/dist/provider-error.js +3 -4
  49. package/dist/providers/alibaba.d.ts +30 -30
  50. package/dist/providers/amazon-bedrock-mantle.d.ts +3 -3
  51. package/dist/providers/amazon-bedrock.d.ts +11 -8
  52. package/dist/providers/azure.d.ts +6 -6
  53. package/dist/providers/cloudflare-ai-gateway.d.ts +7 -7
  54. package/dist/providers/cloudflare-ai-gateway.js +2 -4
  55. package/dist/providers/cohere.d.ts +6 -2
  56. package/dist/providers/google-vertex-interactions.d.ts +3 -3
  57. package/dist/providers/google-vertex-messages.d.ts +18 -18
  58. package/dist/providers/google-vertex-mistral.d.ts +3 -3
  59. package/dist/providers/google-vertex-responses.d.ts +3 -3
  60. package/dist/providers/google.d.ts +66 -66
  61. package/dist/providers/meta.d.ts +21 -21
  62. package/dist/providers/minimax.d.ts +195 -195
  63. package/dist/providers/moonshot.d.ts +3 -3
  64. package/dist/providers/openai-compatible-responses.d.ts +3 -3
  65. package/dist/providers/openai-options.d.ts +3 -3
  66. package/dist/providers/openai.d.ts +3 -3
  67. package/dist/providers/openrouter.d.ts +135 -76
  68. package/dist/providers/openrouter.js +40 -33
  69. package/dist/providers/zai-coding-plan.d.ts +3 -3
  70. package/dist/route/client.d.ts +0 -216
  71. package/dist/route/client.js +0 -3
  72. package/dist/route/transport/http.js +5 -8
  73. package/dist/schema/errors.d.ts +1 -1
  74. package/dist/schema/errors.js +1 -1
  75. package/dist/schema/messages.js +4 -7
  76. package/dist/speech-client.d.ts +3 -1
  77. package/dist/speech.d.ts +10 -2
  78. package/dist/speech.js +2 -2
  79. package/dist/transcription-client.d.ts +3 -1
  80. package/dist/transcription.d.ts +10 -2
  81. package/dist/transcription.js +2 -2
  82. package/dist/video-client.d.ts +3 -1
  83. package/dist/video.d.ts +10 -2
  84. package/dist/video.js +2 -2
  85. package/package.json +4 -4
  86. package/dist/protocols/utils/openai-options.d.ts +0 -16
  87. package/dist/protocols/utils/openai-options.js +0 -15
@@ -1,5 +1,7 @@
1
1
  import { Option, Schema, SchemaGetter } from "effect";
2
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";
3
5
  const patterns = [
4
6
  /prompt is too long/i,
5
7
  /input is too long for requested model/i,
@@ -93,7 +95,7 @@ export const isRetryable = (error) => {
93
95
  }
94
96
  }
95
97
  };
96
- const decodeJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown));
98
+ const decodeJson = Schema.decodeUnknownOption(Json);
97
99
  // OpenCode Zen reports account caps as typed 429/402 errors that are not throttles.
98
100
  const QUOTA_CODES = new Set([
99
101
  "insufficient_quota",
@@ -265,6 +267,3 @@ function providerCodes(value) {
265
267
  exception?.type,
266
268
  ].filter((value) => typeof value === "string");
267
269
  }
268
- function isRecord(value) {
269
- return typeof value === "object" && value !== null;
270
- }
@@ -149,13 +149,13 @@ export declare const routes: (Route<{
149
149
  readonly preserve_thinking?: boolean | undefined;
150
150
  readonly clear_thinking?: boolean | undefined;
151
151
  readonly thinking?: {
152
- readonly type: "adaptive" | "disabled" | (string & {});
152
+ readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled">;
153
153
  } | undefined;
154
154
  readonly parallel_tool_calls?: boolean | undefined;
155
155
  readonly repetition_penalty?: number | undefined;
156
156
  readonly top_k?: number | undefined;
157
157
  readonly response_format?: {
158
- readonly type: "json_object" | "json_schema" | "text" | (string & {});
158
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">;
159
159
  readonly json_schema?: {
160
160
  readonly [x: string]: unknown;
161
161
  } | undefined;
@@ -163,7 +163,7 @@ export declare const routes: (Route<{
163
163
  readonly enable_search?: boolean | undefined;
164
164
  readonly search_options?: {
165
165
  readonly forced_search?: boolean | undefined;
166
- readonly search_strategy?: "agent" | "agent_max" | "max" | "turbo" | (string & {}) | undefined;
166
+ readonly search_strategy?: import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo"> | undefined;
167
167
  readonly enable_search_extension?: boolean | undefined;
168
168
  } | undefined;
169
169
  }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<{
@@ -314,6 +314,24 @@ export declare const routes: (Route<{
314
314
  readonly type: "ephemeral";
315
315
  readonly ttl?: "1h" | "5m" | undefined;
316
316
  } | undefined;
317
+ } | {
318
+ readonly type: "tool_use";
319
+ readonly id: string;
320
+ readonly name: string;
321
+ readonly input: unknown;
322
+ readonly cache_control?: {
323
+ readonly type: "ephemeral";
324
+ readonly ttl?: "1h" | "5m" | undefined;
325
+ } | undefined;
326
+ } | {
327
+ readonly type: "server_tool_use";
328
+ readonly id: string;
329
+ readonly name: string;
330
+ readonly input: unknown;
331
+ readonly cache_control?: {
332
+ readonly type: "ephemeral";
333
+ readonly ttl?: "1h" | "5m" | undefined;
334
+ } | undefined;
317
335
  } | {
318
336
  readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
319
337
  readonly tool_use_id: string;
@@ -340,24 +358,6 @@ export declare const routes: (Route<{
340
358
  readonly type: "ephemeral";
341
359
  readonly ttl?: "1h" | "5m" | undefined;
342
360
  } | undefined;
343
- } | {
344
- readonly type: "tool_use";
345
- readonly id: string;
346
- readonly name: string;
347
- readonly input: unknown;
348
- readonly cache_control?: {
349
- readonly type: "ephemeral";
350
- readonly ttl?: "1h" | "5m" | undefined;
351
- } | undefined;
352
- } | {
353
- readonly type: "server_tool_use";
354
- readonly id: string;
355
- readonly name: string;
356
- readonly input: unknown;
357
- readonly cache_control?: {
358
- readonly type: "ephemeral";
359
- readonly ttl?: "1h" | "5m" | undefined;
360
- } | undefined;
361
361
  })[];
362
362
  } | {
363
363
  readonly role: "system";
@@ -585,15 +585,15 @@ export declare const routes: (Route<{
585
585
  } | undefined;
586
586
  readonly top_logprobs?: number | undefined;
587
587
  readonly truncation?: "auto" | "disabled" | undefined;
588
- readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
588
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
589
589
  readonly prompt_cache_key?: string | undefined;
590
- readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
590
+ readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
591
591
  readonly reasoning?: {
592
592
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
593
593
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
594
594
  } | undefined;
595
595
  readonly text?: {
596
- readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
596
+ readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
597
597
  } | undefined;
598
598
  readonly max_output_tokens?: number | undefined;
599
599
  readonly max_tool_calls?: number | undefined;
@@ -616,13 +616,13 @@ export declare const configure: (input: Config) => {
616
616
  readonly preserveThinking?: boolean | undefined;
617
617
  readonly clearThinking?: boolean | undefined;
618
618
  readonly thinking?: {
619
- readonly type: "adaptive" | "disabled" | (string & {});
619
+ readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled">;
620
620
  } | undefined;
621
621
  readonly toolStream?: boolean | undefined;
622
622
  readonly parallelToolCalls?: boolean | undefined;
623
623
  readonly repetitionPenalty?: number | undefined;
624
624
  readonly responseFormat?: {
625
- readonly type: "json_object" | "json_schema" | "text" | (string & {});
625
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">;
626
626
  readonly json_schema?: {
627
627
  readonly [x: string]: unknown;
628
628
  } | undefined;
@@ -630,7 +630,7 @@ export declare const configure: (input: Config) => {
630
630
  readonly enableSearch?: boolean | undefined;
631
631
  readonly searchOptions?: {
632
632
  readonly forced_search?: boolean | undefined;
633
- readonly search_strategy?: "agent" | "agent_max" | "max" | "turbo" | (string & {}) | undefined;
633
+ readonly search_strategy?: import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo"> | undefined;
634
634
  readonly enable_search_extension?: boolean | undefined;
635
635
  } | undefined;
636
636
  }, import("../route/client.js").CompactionOperations | undefined>;
@@ -641,13 +641,13 @@ export declare const configure: (input: Config) => {
641
641
  readonly preserveThinking?: boolean | undefined;
642
642
  readonly clearThinking?: boolean | undefined;
643
643
  readonly thinking?: {
644
- readonly type: "adaptive" | "disabled" | (string & {});
644
+ readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled">;
645
645
  } | undefined;
646
646
  readonly toolStream?: boolean | undefined;
647
647
  readonly parallelToolCalls?: boolean | undefined;
648
648
  readonly repetitionPenalty?: number | undefined;
649
649
  readonly responseFormat?: {
650
- readonly type: "json_object" | "json_schema" | "text" | (string & {});
650
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">;
651
651
  readonly json_schema?: {
652
652
  readonly [x: string]: unknown;
653
653
  } | undefined;
@@ -655,7 +655,7 @@ export declare const configure: (input: Config) => {
655
655
  readonly enableSearch?: boolean | undefined;
656
656
  readonly searchOptions?: {
657
657
  readonly forced_search?: boolean | undefined;
658
- readonly search_strategy?: "agent" | "agent_max" | "max" | "turbo" | (string & {}) | undefined;
658
+ readonly search_strategy?: import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo"> | undefined;
659
659
  readonly enable_search_extension?: boolean | undefined;
660
660
  } | undefined;
661
661
  }, import("../route/client.js").CompactionOperations | undefined>;
@@ -189,15 +189,15 @@ export declare const routes: (Route<{
189
189
  } | undefined;
190
190
  readonly top_logprobs?: number | undefined;
191
191
  readonly truncation?: "auto" | "disabled" | undefined;
192
- readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
192
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
193
193
  readonly prompt_cache_key?: string | undefined;
194
- readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
194
+ readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
195
195
  readonly reasoning?: {
196
196
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
197
197
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
198
198
  } | undefined;
199
199
  readonly text?: {
200
- readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
200
+ readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
201
201
  } | undefined;
202
202
  readonly max_output_tokens?: number | undefined;
203
203
  readonly max_tool_calls?: number | undefined;
@@ -34,13 +34,6 @@ export declare const routes: import("../route/client.js").Route<{
34
34
  readonly messages: readonly ({
35
35
  readonly role: "user";
36
36
  readonly content: readonly ({
37
- readonly text: string;
38
- } | {
39
- readonly cachePoint: {
40
- readonly type: "default";
41
- readonly ttl?: "1h" | "5m" | undefined;
42
- };
43
- } | {
44
37
  readonly image: {
45
38
  readonly format: "gif" | "jpeg" | "png" | "webp";
46
39
  readonly source: {
@@ -55,6 +48,13 @@ export declare const routes: import("../route/client.js").Route<{
55
48
  readonly bytes: string;
56
49
  };
57
50
  };
51
+ } | {
52
+ readonly text: string;
53
+ } | {
54
+ readonly cachePoint: {
55
+ readonly type: "default";
56
+ readonly ttl?: "1h" | "5m" | undefined;
57
+ };
58
58
  } | {
59
59
  readonly toolResult: {
60
60
  readonly toolUseId: string;
@@ -151,7 +151,10 @@ export declare const routes: import("../route/client.js").Route<{
151
151
  readonly additionalModelRequestFields?: {
152
152
  readonly [x: string]: unknown;
153
153
  } | undefined;
154
- }, import("../route/transport/http.js").HttpPrepared<object>, import("../route/client.js").CompactionOperations | undefined>[];
154
+ }, import("../route/transport/http.js").HttpPrepared<{
155
+ readonly [x: string]: unknown;
156
+ readonly rawBody: string;
157
+ }>, import("../route/client.js").CompactionOperations | undefined>[];
155
158
  export declare const configure: (input?: Config) => {
156
159
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
157
160
  model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
@@ -157,15 +157,15 @@ declare const responsesRoute: Route<{
157
157
  } | undefined;
158
158
  readonly top_logprobs?: number | undefined;
159
159
  readonly truncation?: "auto" | "disabled" | undefined;
160
- readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
160
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
161
161
  readonly prompt_cache_key?: string | undefined;
162
- readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
162
+ readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
163
163
  readonly reasoning?: {
164
164
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
165
165
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
166
166
  } | undefined;
167
167
  readonly text?: {
168
- readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
168
+ readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
169
169
  } | undefined;
170
170
  readonly max_output_tokens?: number | undefined;
171
171
  readonly max_tool_calls?: number | undefined;
@@ -484,15 +484,15 @@ export declare const routes: (Route<{
484
484
  } | undefined;
485
485
  readonly top_logprobs?: number | undefined;
486
486
  readonly truncation?: "auto" | "disabled" | undefined;
487
- readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
487
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
488
488
  readonly prompt_cache_key?: string | undefined;
489
- readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
489
+ readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
490
490
  readonly reasoning?: {
491
491
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
492
492
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
493
493
  } | undefined;
494
494
  readonly text?: {
495
- readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
495
+ readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
496
496
  } | undefined;
497
497
  readonly max_output_tokens?: number | undefined;
498
498
  readonly max_tool_calls?: number | undefined;
@@ -1,4 +1,4 @@
1
- import { type Config, type Redacted } from "effect";
1
+ import type { Config, Redacted } from "effect";
2
2
  import type { ProviderPackage } from "../provider-package.js";
3
3
  import type { AtLeastOne, ProviderAuthOption } from "../route/auth-options.js";
4
4
  import type { RouteDefaultsInput } from "../route/client.js";
@@ -163,15 +163,15 @@ export declare const responsesRoute: import("../route/client.js").Route<{
163
163
  } | undefined;
164
164
  readonly top_logprobs?: number | undefined;
165
165
  readonly truncation?: "auto" | "disabled" | undefined;
166
- readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
166
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
167
167
  readonly prompt_cache_key?: string | undefined;
168
- readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
168
+ readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
169
169
  readonly reasoning?: {
170
170
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
171
171
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
172
172
  } | undefined;
173
173
  readonly text?: {
174
- readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
174
+ readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
175
175
  } | undefined;
176
176
  readonly max_output_tokens?: number | undefined;
177
177
  readonly max_tool_calls?: number | undefined;
@@ -1158,15 +1158,15 @@ export declare const routes: (import("../route/client.js").Route<{
1158
1158
  } | undefined;
1159
1159
  readonly top_logprobs?: number | undefined;
1160
1160
  readonly truncation?: "auto" | "disabled" | undefined;
1161
- readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
1161
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
1162
1162
  readonly prompt_cache_key?: string | undefined;
1163
- readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
1163
+ readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
1164
1164
  readonly reasoning?: {
1165
1165
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
1166
1166
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
1167
1167
  } | undefined;
1168
1168
  readonly text?: {
1169
- readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
1169
+ readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
1170
1170
  } | undefined;
1171
1171
  readonly max_output_tokens?: number | undefined;
1172
1172
  readonly max_tool_calls?: number | undefined;
@@ -1,7 +1,7 @@
1
- import { Schema } from "effect";
2
1
  import { AnthropicMessages, OpenAIChat, OpenAIResponses } from "../protocols/index.js";
3
2
  import { Auth } from "../route/auth.js";
4
3
  import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
4
+ import { encodeJson } from "../utils/json.js";
5
5
  export const id = ProviderID.make("cloudflare-ai-gateway");
6
6
  export const authEnvVars = ["CLOUDFLARE_API_TOKEN", "CF_AIG_TOKEN"];
7
7
  export const baseURL = (input) => {
@@ -41,9 +41,7 @@ const credential = (input) => Auth.optional(input.gatewayApiKey ?? ("apiKey" in
41
41
  .orElse(Auth.config(authEnvVars[0]))
42
42
  .orElse(Auth.config(authEnvVars[1]));
43
43
  const headers = (input) => ({
44
- ...(input.metadata === undefined
45
- ? {}
46
- : { "cf-aig-metadata": Schema.encodeSync(Schema.fromJsonString(Schema.Unknown))(input.metadata) }),
44
+ ...(input.metadata === undefined ? {} : { "cf-aig-metadata": encodeJson(input.metadata) }),
47
45
  ...(input.cacheTtl === undefined ? {} : { "cf-aig-cache-ttl": String(input.cacheTtl) }),
48
46
  ...(input.cacheKey === undefined ? {} : { "cf-aig-cache-key": input.cacheKey }),
49
47
  ...(input.skipCache === undefined ? {} : { "cf-aig-skip-cache": String(input.skipCache) }),
@@ -49,7 +49,9 @@ export declare const route: Route<{
49
49
  readonly function: {
50
50
  readonly name: string;
51
51
  readonly description?: string | undefined;
52
- readonly parameters: unknown;
52
+ readonly parameters: {
53
+ readonly [x: string]: unknown;
54
+ };
53
55
  };
54
56
  }[] | undefined;
55
57
  readonly tool_choice?: "NONE" | "REQUIRED" | undefined;
@@ -342,7 +344,9 @@ export declare const routes: (Route<{
342
344
  readonly function: {
343
345
  readonly name: string;
344
346
  readonly description?: string | undefined;
345
- readonly parameters: unknown;
347
+ readonly parameters: {
348
+ readonly [x: string]: unknown;
349
+ };
346
350
  };
347
351
  }[] | undefined;
348
352
  readonly tool_choice?: "NONE" | "REQUIRED" | undefined;
@@ -27,13 +27,13 @@ export declare const routes: Route<{
27
27
  readonly input: readonly ({
28
28
  readonly type: "model_output" | "user_input";
29
29
  readonly content: readonly ({
30
+ readonly type: "text";
31
+ readonly text: string;
32
+ } | {
30
33
  readonly type: "audio" | "document" | "image" | "video";
31
34
  readonly data?: string | undefined;
32
35
  readonly uri?: string | undefined;
33
36
  readonly mime_type: string;
34
- } | {
35
- readonly type: "text";
36
- readonly text: string;
37
37
  })[];
38
38
  } | {
39
39
  readonly type: "thought";
@@ -167,24 +167,6 @@ export declare const routes: Route<{
167
167
  readonly type: "ephemeral";
168
168
  readonly ttl?: "1h" | "5m" | undefined;
169
169
  } | undefined;
170
- } | {
171
- readonly type: "tool_use";
172
- readonly id: string;
173
- readonly name: string;
174
- readonly input: unknown;
175
- readonly cache_control?: {
176
- readonly type: "ephemeral";
177
- readonly ttl?: "1h" | "5m" | undefined;
178
- } | undefined;
179
- } | {
180
- readonly type: "server_tool_use";
181
- readonly id: string;
182
- readonly name: string;
183
- readonly input: unknown;
184
- readonly cache_control?: {
185
- readonly type: "ephemeral";
186
- readonly ttl?: "1h" | "5m" | undefined;
187
- } | undefined;
188
170
  } | {
189
171
  readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
190
172
  readonly tool_use_id: string;
@@ -211,6 +193,24 @@ export declare const routes: Route<{
211
193
  readonly type: "ephemeral";
212
194
  readonly ttl?: "1h" | "5m" | undefined;
213
195
  } | undefined;
196
+ } | {
197
+ readonly type: "tool_use";
198
+ readonly id: string;
199
+ readonly name: string;
200
+ readonly input: unknown;
201
+ readonly cache_control?: {
202
+ readonly type: "ephemeral";
203
+ readonly ttl?: "1h" | "5m" | undefined;
204
+ } | undefined;
205
+ } | {
206
+ readonly type: "server_tool_use";
207
+ readonly id: string;
208
+ readonly name: string;
209
+ readonly input: unknown;
210
+ readonly cache_control?: {
211
+ readonly type: "ephemeral";
212
+ readonly ttl?: "1h" | "5m" | undefined;
213
+ } | undefined;
214
214
  })[];
215
215
  } | {
216
216
  readonly role: "system";
@@ -41,9 +41,6 @@ export declare const routes: Route<{
41
41
  } | {
42
42
  readonly role: "assistant";
43
43
  readonly content: string | readonly ({
44
- readonly type: "text";
45
- readonly text: string;
46
- } | {
47
44
  readonly [x: string]: unknown;
48
45
  readonly type: "thinking";
49
46
  readonly thinking: readonly {
@@ -51,6 +48,9 @@ export declare const routes: Route<{
51
48
  readonly type?: string | undefined;
52
49
  readonly text?: string | undefined;
53
50
  }[];
51
+ } | {
52
+ readonly type: "text";
53
+ readonly text: string;
54
54
  })[];
55
55
  readonly tool_calls?: readonly {
56
56
  readonly id: string;
@@ -176,15 +176,15 @@ export declare const routes: Route<{
176
176
  } | undefined;
177
177
  readonly top_logprobs?: number | undefined;
178
178
  readonly truncation?: "auto" | "disabled" | undefined;
179
- readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
179
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
180
180
  readonly prompt_cache_key?: string | undefined;
181
- readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
181
+ readonly include?: readonly import("../schema/options.js").OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
182
182
  readonly reasoning?: {
183
183
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
184
184
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
185
185
  } | undefined;
186
186
  readonly text?: {
187
- readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
187
+ readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
188
188
  } | undefined;
189
189
  readonly max_output_tokens?: number | undefined;
190
190
  readonly max_tool_calls?: number | undefined;
@@ -13,80 +13,19 @@ export type GeminiProviderOptionsInput = Gemini.ProviderOptionsInput;
13
13
  export type GoogleInteractionsOptionsInput = GoogleInteractions.OptionsInput;
14
14
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
15
15
  export declare const routes: (import("../route/client.js").Route<{
16
- readonly model: string;
17
- readonly input: readonly ({
18
- readonly type: "model_output" | "user_input";
19
- readonly content: readonly ({
20
- readonly type: "audio" | "document" | "image" | "video";
21
- readonly data?: string | undefined;
22
- readonly uri?: string | undefined;
23
- readonly mime_type: string;
24
- } | {
25
- readonly type: "text";
26
- readonly text: string;
27
- })[];
28
- } | {
29
- readonly type: "thought";
30
- readonly signature?: string | undefined;
31
- readonly summary?: readonly {
32
- readonly type: "text";
33
- readonly text: string;
34
- }[] | undefined;
35
- } | {
36
- readonly type: "function_call";
37
- readonly id: string;
38
- readonly name: string;
39
- readonly arguments: unknown;
40
- readonly signature?: string | undefined;
41
- } | {
42
- readonly type: "function_result";
43
- readonly call_id: string;
44
- readonly name: string;
45
- readonly result: unknown;
46
- readonly is_error?: boolean | undefined;
47
- })[];
48
- readonly stream: true;
49
- readonly store: boolean;
50
- readonly previous_interaction_id?: string | undefined;
51
- readonly system_instruction?: string | undefined;
52
- readonly service_tier?: string | undefined;
53
- readonly tools?: readonly {
54
- readonly type: "function";
55
- readonly name: string;
56
- readonly description: string;
57
- readonly parameters: {
58
- readonly [x: string]: unknown;
59
- };
60
- }[] | undefined;
61
- readonly generation_config: {
62
- readonly max_output_tokens?: number | undefined;
63
- readonly temperature?: number | undefined;
64
- readonly top_p?: number | undefined;
65
- readonly seed?: number | undefined;
66
- readonly stop_sequences?: readonly string[] | undefined;
67
- readonly thinking_level?: import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal"> | undefined;
68
- readonly thinking_summaries?: string | undefined;
69
- readonly tool_choice?: "any" | "auto" | "none" | {
70
- readonly allowed_tools: {
71
- readonly mode: "any";
72
- readonly tools: readonly string[];
73
- };
74
- } | undefined;
75
- };
76
- }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | import("../route/client.js").Route<{
77
16
  readonly cachedContent?: string | undefined;
78
17
  readonly contents: readonly {
79
18
  readonly role?: "model" | "user" | null | undefined;
80
19
  readonly parts?: readonly ({
81
- readonly text: string;
82
- readonly thought?: boolean | null | undefined;
83
- readonly thoughtSignature?: string | null | undefined;
84
- } | {
85
20
  readonly inlineData: {
86
21
  readonly mimeType: string;
87
22
  readonly data: string;
88
23
  };
89
24
  readonly thoughtSignature?: string | null | undefined;
25
+ } | {
26
+ readonly text: string;
27
+ readonly thought?: boolean | null | undefined;
28
+ readonly thoughtSignature?: string | null | undefined;
90
29
  } | {
91
30
  readonly fileData: {
92
31
  readonly mimeType: string;
@@ -158,7 +97,68 @@ export declare const routes: (import("../route/client.js").Route<{
158
97
  } | undefined;
159
98
  } | undefined;
160
99
  readonly continuationToken?: string | undefined;
161
- }, Gemini.Prepared, import("../route/client.js").CompactionOperations | undefined>)[];
100
+ }, Gemini.Prepared, import("../route/client.js").CompactionOperations | undefined> | import("../route/client.js").Route<{
101
+ readonly model: string;
102
+ readonly input: readonly ({
103
+ readonly type: "model_output" | "user_input";
104
+ readonly content: readonly ({
105
+ readonly type: "text";
106
+ readonly text: string;
107
+ } | {
108
+ readonly type: "audio" | "document" | "image" | "video";
109
+ readonly data?: string | undefined;
110
+ readonly uri?: string | undefined;
111
+ readonly mime_type: string;
112
+ })[];
113
+ } | {
114
+ readonly type: "thought";
115
+ readonly signature?: string | undefined;
116
+ readonly summary?: readonly {
117
+ readonly type: "text";
118
+ readonly text: string;
119
+ }[] | undefined;
120
+ } | {
121
+ readonly type: "function_call";
122
+ readonly id: string;
123
+ readonly name: string;
124
+ readonly arguments: unknown;
125
+ readonly signature?: string | undefined;
126
+ } | {
127
+ readonly type: "function_result";
128
+ readonly call_id: string;
129
+ readonly name: string;
130
+ readonly result: unknown;
131
+ readonly is_error?: boolean | undefined;
132
+ })[];
133
+ readonly stream: true;
134
+ readonly store: boolean;
135
+ readonly previous_interaction_id?: string | undefined;
136
+ readonly system_instruction?: string | undefined;
137
+ readonly service_tier?: string | undefined;
138
+ readonly tools?: readonly {
139
+ readonly type: "function";
140
+ readonly name: string;
141
+ readonly description: string;
142
+ readonly parameters: {
143
+ readonly [x: string]: unknown;
144
+ };
145
+ }[] | undefined;
146
+ readonly generation_config: {
147
+ readonly max_output_tokens?: number | undefined;
148
+ readonly temperature?: number | undefined;
149
+ readonly top_p?: number | undefined;
150
+ readonly seed?: number | undefined;
151
+ readonly stop_sequences?: readonly string[] | undefined;
152
+ readonly thinking_level?: import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal"> | undefined;
153
+ readonly thinking_summaries?: string | undefined;
154
+ readonly tool_choice?: "any" | "auto" | "none" | {
155
+ readonly allowed_tools: {
156
+ readonly mode: "any";
157
+ readonly tools: readonly string[];
158
+ };
159
+ } | undefined;
160
+ };
161
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>)[];
162
162
  export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
163
163
  readonly baseURL?: string;
164
164
  readonly providerOptions?: Gemini.ProviderOptionsInput & GoogleInteractions.ProviderOptionsInput;