@opencode/ai 2.0.22 → 2.0.24

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 (107) hide show
  1. package/README.md +61 -1
  2. package/dist/cache-policy.js +13 -9
  3. package/dist/protocols/alibaba-chat.d.ts +3 -3
  4. package/dist/protocols/alibaba-messages.d.ts +3 -0
  5. package/dist/protocols/alibaba-responses.d.ts +19 -12
  6. package/dist/protocols/alibaba-responses.js +3 -5
  7. package/dist/protocols/anthropic-messages.d.ts +3 -0
  8. package/dist/protocols/anthropic-messages.js +53 -48
  9. package/dist/protocols/bedrock-converse.js +3 -3
  10. package/dist/protocols/cartesia-speech.js +3 -3
  11. package/dist/protocols/cohere-chat.d.ts +178 -0
  12. package/dist/protocols/cohere-chat.js +299 -0
  13. package/dist/protocols/elevenlabs-speech.js +3 -3
  14. package/dist/protocols/gemini.d.ts +2 -2
  15. package/dist/protocols/gemini.js +3 -3
  16. package/dist/protocols/google-interactions.d.ts +236 -0
  17. package/dist/protocols/google-interactions.js +478 -0
  18. package/dist/protocols/google-speech.js +1 -1
  19. package/dist/protocols/google-transcription.js +1 -1
  20. package/dist/protocols/index.d.ts +2 -0
  21. package/dist/protocols/index.js +2 -0
  22. package/dist/protocols/meta-messages.d.ts +3 -0
  23. package/dist/protocols/meta-responses.d.ts +34 -58
  24. package/dist/protocols/meta-responses.js +8 -27
  25. package/dist/protocols/mistral-chat.d.ts +24 -9
  26. package/dist/protocols/mistral-chat.js +22 -10
  27. package/dist/protocols/open-responses.d.ts +424 -103
  28. package/dist/protocols/open-responses.js +30 -20
  29. package/dist/protocols/openai-chat.d.ts +401 -5
  30. package/dist/protocols/openai-chat.js +18 -21
  31. package/dist/protocols/openai-compatible-chat.d.ts +1 -1
  32. package/dist/protocols/openai-compatible-responses.d.ts +16 -4
  33. package/dist/protocols/openai-images.js +2 -2
  34. package/dist/protocols/openai-responses.d.ts +90 -223
  35. package/dist/protocols/openai-responses.js +6 -13
  36. package/dist/protocols/openai-speech.js +1 -1
  37. package/dist/protocols/openai-transcription.js +1 -1
  38. package/dist/protocols/shared.js +2 -2
  39. package/dist/protocols/stability-images.js +1 -1
  40. package/dist/protocols/utils/bedrock-media.js +2 -2
  41. package/dist/protocols/utils/gateway-protocol.d.ts +17 -0
  42. package/dist/protocols/utils/gateway-protocol.js +57 -0
  43. package/dist/protocols/utils/responses-checkpoint.js +2 -2
  44. package/dist/protocols/utils/responses-hosted-tools.js +1 -1
  45. package/dist/protocols/utils/tool-stream.js +15 -7
  46. package/dist/protocols/venice-chat.d.ts +280 -0
  47. package/dist/protocols/venice-chat.js +283 -0
  48. package/dist/protocols/xai-responses.d.ts +21 -21
  49. package/dist/protocols/xai-responses.js +2 -8
  50. package/dist/protocols/zai-chat.d.ts +3 -3
  51. package/dist/protocols/zai-messages.d.ts +3 -0
  52. package/dist/provider-error.js +7 -1
  53. package/dist/providers/alibaba.d.ts +17 -13
  54. package/dist/providers/amazon-bedrock/mantle/messages.d.ts +2 -0
  55. package/dist/providers/amazon-bedrock/mantle/messages.js +1 -0
  56. package/dist/providers/amazon-bedrock-mantle.d.ts +301 -9
  57. package/dist/providers/amazon-bedrock-mantle.js +28 -3
  58. package/dist/providers/azure.d.ts +13 -61
  59. package/dist/providers/baseten.d.ts +2 -2
  60. package/dist/providers/cerebras.d.ts +2 -2
  61. package/dist/providers/cloudflare-ai-gateway.d.ts +14 -62
  62. package/dist/providers/cloudflare-workers-ai.d.ts +2 -2
  63. package/dist/providers/cohere/chat.d.ts +4 -0
  64. package/dist/providers/cohere/chat.js +8 -0
  65. package/dist/providers/cohere.d.ts +395 -0
  66. package/dist/providers/cohere.js +48 -0
  67. package/dist/providers/deepinfra.d.ts +2 -2
  68. package/dist/providers/deepseek.d.ts +2 -2
  69. package/dist/providers/digitalocean.d.ts +5 -5
  70. package/dist/providers/fireworks.d.ts +2 -2
  71. package/dist/providers/google/interactions.d.ts +7 -0
  72. package/dist/providers/google/interactions.js +8 -0
  73. package/dist/providers/google-vertex-chat.d.ts +1 -1
  74. package/dist/providers/google-vertex-messages.js +1 -0
  75. package/dist/providers/google-vertex-responses.d.ts +16 -4
  76. package/dist/providers/google-vertex.d.ts +1 -1
  77. package/dist/providers/google.d.ts +95 -4
  78. package/dist/providers/google.js +8 -1
  79. package/dist/providers/groq.d.ts +4 -4
  80. package/dist/providers/index.d.ts +2 -0
  81. package/dist/providers/index.js +2 -0
  82. package/dist/providers/meta.d.ts +15 -28
  83. package/dist/providers/minimax.d.ts +17 -5
  84. package/dist/providers/mistral.d.ts +10 -4
  85. package/dist/providers/moonshot.d.ts +17 -5
  86. package/dist/providers/openai-compatible-responses.d.ts +16 -4
  87. package/dist/providers/openai-compatible.d.ts +1 -1
  88. package/dist/providers/openai-options.d.ts +1 -1
  89. package/dist/providers/openai.d.ts +7 -31
  90. package/dist/providers/openrouter.d.ts +5 -5
  91. package/dist/providers/togetherai.d.ts +2 -2
  92. package/dist/providers/venice.d.ts +183 -0
  93. package/dist/providers/venice.js +38 -0
  94. package/dist/providers/vercel-ai-gateway/chat.d.ts +2 -0
  95. package/dist/providers/vercel-ai-gateway/chat.js +1 -0
  96. package/dist/providers/vercel-ai-gateway/messages.d.ts +2 -0
  97. package/dist/providers/vercel-ai-gateway/messages.js +1 -0
  98. package/dist/providers/vercel-ai-gateway/responses.d.ts +2 -0
  99. package/dist/providers/vercel-ai-gateway/responses.js +1 -0
  100. package/dist/providers/vercel-ai-gateway.d.ts +91 -9
  101. package/dist/providers/vercel-ai-gateway.js +161 -21
  102. package/dist/providers/xai.d.ts +1 -1
  103. package/dist/providers/zai-coding-plan.d.ts +17 -5
  104. package/dist/providers/zai.d.ts +1 -1
  105. package/dist/route/client.js +2 -5
  106. package/dist/route/framing.js +23 -23
  107. package/package.json +3 -3
@@ -38,6 +38,15 @@ export declare const protocol: Protocol<{
38
38
  readonly error?: unknown;
39
39
  readonly arguments?: string | undefined;
40
40
  readonly server_label?: string | undefined;
41
+ } | {
42
+ readonly type: "configuration_update";
43
+ readonly reasoning: {
44
+ readonly effort: import("../schema/options.js").ReasoningEffort;
45
+ };
46
+ } | {
47
+ readonly [x: string]: unknown;
48
+ readonly type: string;
49
+ readonly id: string;
41
50
  } | {
42
51
  readonly type: "reasoning";
43
52
  readonly summary: readonly {
@@ -114,21 +123,6 @@ export declare const protocol: Protocol<{
114
123
  readonly type: "input_video";
115
124
  readonly video_url: string;
116
125
  })[];
117
- } | {
118
- readonly [x: string]: unknown;
119
- readonly id: string;
120
- readonly type: "x_search_call";
121
- readonly status?: string | undefined;
122
- readonly action?: {
123
- readonly [x: string]: unknown;
124
- } | null | undefined;
125
- } | {
126
- readonly [x: string]: unknown;
127
- readonly id: string;
128
- readonly type: "image_generation_call";
129
- readonly status?: string | undefined;
130
- readonly error?: unknown;
131
- readonly result?: unknown;
132
126
  })[];
133
127
  readonly model: string;
134
128
  readonly stream: true;
@@ -140,7 +134,10 @@ export declare const protocol: Protocol<{
140
134
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
141
135
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
142
136
  } | undefined;
143
- readonly tools?: readonly {
137
+ readonly tools?: readonly ({
138
+ readonly [x: string]: unknown;
139
+ readonly type: string;
140
+ } | {
144
141
  readonly type: "function";
145
142
  readonly description: string;
146
143
  readonly name: string;
@@ -148,7 +145,7 @@ export declare const protocol: Protocol<{
148
145
  readonly [x: string]: unknown;
149
146
  };
150
147
  readonly strict?: boolean | undefined;
151
- }[] | undefined;
148
+ })[] | undefined;
152
149
  readonly text?: {
153
150
  readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
154
151
  } | undefined;
@@ -168,9 +165,10 @@ export declare const protocol: Protocol<{
168
165
  readonly top_p?: number | undefined;
169
166
  readonly frequency_penalty?: number | undefined;
170
167
  readonly presence_penalty?: number | undefined;
168
+ readonly store?: boolean | undefined;
169
+ readonly max_output_tokens?: number | undefined;
171
170
  readonly prompt_cache_key?: string | undefined;
172
171
  readonly parallel_tool_calls?: boolean | undefined;
173
- readonly store?: boolean | undefined;
174
172
  readonly include?: readonly import("./utils/open-responses-options.js").ResponseIncludable[] | undefined;
175
173
  readonly truncation?: "auto" | "disabled" | undefined;
176
174
  readonly stream_options?: {
@@ -178,7 +176,6 @@ export declare const protocol: Protocol<{
178
176
  } | undefined;
179
177
  readonly safety_identifier?: string | undefined;
180
178
  readonly top_logprobs?: number | undefined;
181
- readonly max_output_tokens?: number | undefined;
182
179
  readonly max_tool_calls?: number | undefined;
183
180
  }, string, {
184
181
  readonly [x: string]: unknown;
@@ -198,18 +195,21 @@ export declare const protocol: Protocol<{
198
195
  readonly name?: string | undefined;
199
196
  readonly namespace?: string | undefined;
200
197
  readonly arguments?: string | undefined;
201
- readonly encrypted_content?: string | null | undefined;
202
198
  readonly call_id?: string | undefined;
199
+ readonly encrypted_content?: string | null | undefined;
203
200
  }[] | undefined;
204
201
  readonly error?: unknown;
205
202
  readonly usage?: {
203
+ readonly [x: string]: unknown;
206
204
  readonly input_tokens?: number | undefined;
207
205
  readonly output_tokens?: number | undefined;
208
206
  readonly output_tokens_details?: {
207
+ readonly [x: string]: unknown;
209
208
  readonly reasoning_tokens?: number | undefined;
210
209
  } | null | undefined;
211
210
  readonly total_tokens?: number | undefined;
212
211
  readonly input_tokens_details?: {
212
+ readonly [x: string]: unknown;
213
213
  readonly cached_tokens?: number | undefined;
214
214
  readonly cache_write_tokens?: number | undefined;
215
215
  } | null | undefined;
@@ -226,8 +226,8 @@ export declare const protocol: Protocol<{
226
226
  readonly name?: string | undefined;
227
227
  readonly namespace?: string | undefined;
228
228
  readonly arguments?: string | undefined;
229
- readonly encrypted_content?: string | null | undefined;
230
229
  readonly call_id?: string | undefined;
230
+ readonly encrypted_content?: string | null | undefined;
231
231
  } | null | undefined;
232
232
  readonly delta?: string | undefined;
233
233
  readonly arguments?: string | undefined;
@@ -21,17 +21,11 @@ const XAIResponsesHostedToolItem = Schema.Union([
21
21
  error: Schema.optional(Schema.Unknown),
22
22
  }), [JsonObject]),
23
23
  ]);
24
- const XAIResponsesBody = Schema.Struct({
25
- ...OpenResponses.coreFields,
26
- input: Schema.Array(Schema.Union([OpenResponses.InputItem, XAIResponsesHostedToolItem])),
27
- stream: Schema.Literal(true),
28
- });
29
24
  const adapter = {
30
25
  id: ADAPTER,
31
26
  name: NAME,
32
27
  restoreHostedToolItem: (item) => (Schema.is(XAIResponsesHostedToolItem)(item) ? item : undefined),
33
28
  };
34
- const decodeBody = ProviderShared.validateWith(Schema.decodeUnknownEffect(XAIResponsesBody));
35
29
  const fromRequest = Effect.fn("XAIResponses.fromRequest")(function* (request) {
36
30
  if (request.providerOptions?.contextManagement !== undefined)
37
31
  return yield* ProviderShared.unsupportedOperation({
@@ -40,7 +34,7 @@ const fromRequest = Effect.fn("XAIResponses.fromRequest")(function* (request) {
40
34
  route: request.model.route.id,
41
35
  message: "xAI requires explicit compaction through LLMClient.compact; automatic context management is not supported",
42
36
  });
43
- return yield* decodeBody(yield* OpenResponses.fromRequestWithAdapter(request, adapter));
37
+ return yield* OpenResponses.fromRequestWithAdapter(request, adapter);
44
38
  });
45
39
  const HOSTED_TOOLS = {
46
40
  web_search_call: { name: "web_search", input: (item) => item.action ?? {} },
@@ -67,7 +61,7 @@ const step = (state, input) => {
67
61
  export const protocol = Protocol.make({
68
62
  id: ADAPTER,
69
63
  body: {
70
- schema: XAIResponsesBody,
64
+ schema: OpenResponses.OpenResponsesBody,
71
65
  from: fromRequest,
72
66
  },
73
67
  stream: {
@@ -142,9 +142,9 @@ export declare const protocol: Protocol<{
142
142
  readonly top_p?: number | undefined;
143
143
  readonly frequency_penalty?: number | undefined;
144
144
  readonly presence_penalty?: number | undefined;
145
+ readonly store?: boolean | undefined;
145
146
  readonly prompt_cache_key?: string | undefined;
146
147
  readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
147
- readonly store?: boolean | undefined;
148
148
  readonly stream_options?: {
149
149
  readonly include_usage: boolean;
150
150
  } | undefined;
@@ -165,9 +165,9 @@ export declare const protocol: Protocol<{
165
165
  readonly [x: string]: unknown;
166
166
  readonly cache_read_input_tokens?: number | null | undefined;
167
167
  readonly cached_tokens?: number | null | undefined;
168
+ readonly total_tokens?: number | null | undefined;
168
169
  readonly prompt_tokens?: number | null | undefined;
169
170
  readonly completion_tokens?: number | null | undefined;
170
- readonly total_tokens?: number | null | undefined;
171
171
  readonly prompt_tokens_details?: {
172
172
  readonly [x: string]: unknown;
173
173
  readonly cached_tokens?: number | null | undefined;
@@ -206,9 +206,9 @@ export declare const protocol: Protocol<{
206
206
  readonly [x: string]: unknown;
207
207
  readonly cache_read_input_tokens?: number | null | undefined;
208
208
  readonly cached_tokens?: number | null | undefined;
209
+ readonly total_tokens?: number | null | undefined;
209
210
  readonly prompt_tokens?: number | null | undefined;
210
211
  readonly completion_tokens?: number | null | undefined;
211
- readonly total_tokens?: number | null | undefined;
212
212
  readonly prompt_tokens_details?: {
213
213
  readonly [x: string]: unknown;
214
214
  readonly cached_tokens?: number | null | undefined;
@@ -266,8 +266,10 @@ export declare const protocol: Protocol<{
266
266
  readonly top_k?: number | undefined;
267
267
  readonly stop_sequences?: readonly string[] | undefined;
268
268
  }, string, {
269
+ readonly [x: string]: unknown;
269
270
  readonly type: string;
270
271
  readonly message?: {
272
+ readonly [x: string]: unknown;
271
273
  readonly usage?: {
272
274
  readonly [x: string]: unknown;
273
275
  readonly input_tokens?: number | null | undefined;
@@ -300,6 +302,7 @@ export declare const protocol: Protocol<{
300
302
  } | undefined;
301
303
  } | undefined;
302
304
  readonly error?: {
305
+ readonly [x: string]: unknown;
303
306
  readonly type?: string | undefined;
304
307
  readonly message?: string | undefined;
305
308
  } | undefined;
@@ -40,7 +40,13 @@ const patterns = [
40
40
  /request_too_large/i,
41
41
  ];
42
42
  const payloadPatterns = [/request entity too large/i, /payload too large/i, /request too large/i];
43
- const exclusions = [/^(throttling error|service unavailable):/i, /rate limit/i, /too many requests/i];
43
+ const exclusions = [
44
+ /^(throttling error|service unavailable):/i,
45
+ /rate limit/i,
46
+ /too many requests/i,
47
+ // Cohere reports an output limit above the model maximum as "too many tokens"; compaction cannot fix it.
48
+ /max[_ ]tokens must be less than/i,
49
+ ];
44
50
  export const isContextOverflow = (message) => !exclusions.some((pattern) => pattern.test(message)) &&
45
51
  (patterns.some((pattern) => pattern.test(message)) || /^4(?:00|13)\s*(status code)?\s*\(no body\)/i.test(message));
46
52
  export const isPayloadTooLarge = (message) => payloadPatterns.some((pattern) => pattern.test(message));
@@ -141,10 +141,10 @@ export declare const routes: (Route<{
141
141
  readonly top_k?: number | undefined;
142
142
  readonly frequency_penalty?: number | undefined;
143
143
  readonly presence_penalty?: number | undefined;
144
+ readonly store?: boolean | undefined;
144
145
  readonly prompt_cache_key?: string | undefined;
145
146
  readonly parallel_tool_calls?: boolean | undefined;
146
147
  readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
147
- readonly store?: boolean | undefined;
148
148
  readonly stream_options?: {
149
149
  readonly include_usage: boolean;
150
150
  } | undefined;
@@ -464,6 +464,15 @@ export declare const routes: (Route<{
464
464
  readonly error?: unknown;
465
465
  readonly arguments?: string | undefined;
466
466
  readonly server_label?: string | undefined;
467
+ } | {
468
+ readonly type: "configuration_update";
469
+ readonly reasoning: {
470
+ readonly effort: import("../schema/options.js").ReasoningEffort;
471
+ };
472
+ } | {
473
+ readonly [x: string]: unknown;
474
+ readonly type: string;
475
+ readonly id: string;
467
476
  } | {
468
477
  readonly type: "reasoning";
469
478
  readonly summary: readonly {
@@ -540,12 +549,6 @@ export declare const routes: (Route<{
540
549
  readonly type: "input_video";
541
550
  readonly video_url: string;
542
551
  })[];
543
- } | {
544
- readonly [x: string]: unknown;
545
- readonly id: string;
546
- readonly type: "web_extractor_call";
547
- readonly urls?: readonly string[] | undefined;
548
- readonly goal?: string | undefined;
549
552
  })[];
550
553
  readonly model: string;
551
554
  readonly stream: true;
@@ -558,6 +561,9 @@ export declare const routes: (Route<{
558
561
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
559
562
  } | undefined;
560
563
  readonly tools?: readonly ({
564
+ readonly [x: string]: unknown;
565
+ readonly type: string;
566
+ } | {
561
567
  readonly type: "function";
562
568
  readonly description: string;
563
569
  readonly name: string;
@@ -565,8 +571,6 @@ export declare const routes: (Route<{
565
571
  readonly [x: string]: unknown;
566
572
  };
567
573
  readonly strict?: boolean | undefined;
568
- } | {
569
- readonly type: "web_search" | "code_interpreter" | "web_extractor";
570
574
  })[] | undefined;
571
575
  readonly text?: {
572
576
  readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
@@ -587,9 +591,10 @@ export declare const routes: (Route<{
587
591
  readonly top_p?: number | undefined;
588
592
  readonly frequency_penalty?: number | undefined;
589
593
  readonly presence_penalty?: number | undefined;
594
+ readonly store?: boolean | undefined;
595
+ readonly max_output_tokens?: number | undefined;
590
596
  readonly prompt_cache_key?: string | undefined;
591
597
  readonly parallel_tool_calls?: boolean | undefined;
592
- readonly store?: boolean | undefined;
593
598
  readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
594
599
  readonly truncation?: "auto" | "disabled" | undefined;
595
600
  readonly stream_options?: {
@@ -597,7 +602,6 @@ export declare const routes: (Route<{
597
602
  } | undefined;
598
603
  readonly safety_identifier?: string | undefined;
599
604
  readonly top_logprobs?: number | undefined;
600
- readonly max_output_tokens?: number | undefined;
601
605
  readonly max_tool_calls?: number | undefined;
602
606
  readonly previous_response_id?: string | undefined;
603
607
  readonly conversation?: string | undefined;
@@ -657,8 +661,8 @@ export declare const configure: (input: Config) => {
657
661
  }, import("../route/client.js").CompactionOperations | undefined>;
658
662
  messages: (id: string | ModelID) => import("../schema/options.js").LanguageModel<AlibabaMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
659
663
  responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<{
660
- readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
661
664
  readonly store?: boolean | undefined;
665
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
662
666
  readonly conversation?: string | undefined;
663
667
  readonly enableThinking?: boolean | undefined;
664
668
  readonly previousResponseId?: string | undefined;
@@ -721,8 +725,8 @@ export declare const provider: {
721
725
  }, import("../route/client.js").CompactionOperations | undefined>;
722
726
  messages: (id: string | ModelID) => import("../schema/options.js").LanguageModel<AlibabaMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
723
727
  responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<{
724
- readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
725
728
  readonly store?: boolean | undefined;
729
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
726
730
  readonly conversation?: string | undefined;
727
731
  readonly enableThinking?: boolean | undefined;
728
732
  readonly previousResponseId?: string | undefined;
@@ -0,0 +1,2 @@
1
+ export { messagesModel as model } from "../../amazon-bedrock-mantle.js";
2
+ export type { MessagesSettings as Settings } from "../../amazon-bedrock-mantle.js";
@@ -0,0 +1 @@
1
+ export { messagesModel as model } from "../../amazon-bedrock-mantle.js";