@opencode/ai 2.0.22 → 2.0.23

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 (92) hide show
  1. package/README.md +61 -1
  2. package/dist/cache-policy.js +1 -0
  3. package/dist/protocols/alibaba-chat.d.ts +3 -3
  4. package/dist/protocols/alibaba-responses.d.ts +16 -12
  5. package/dist/protocols/alibaba-responses.js +3 -5
  6. package/dist/protocols/anthropic-messages.js +44 -39
  7. package/dist/protocols/bedrock-converse.js +3 -3
  8. package/dist/protocols/cartesia-speech.js +3 -3
  9. package/dist/protocols/cohere-chat.d.ts +178 -0
  10. package/dist/protocols/cohere-chat.js +299 -0
  11. package/dist/protocols/elevenlabs-speech.js +3 -3
  12. package/dist/protocols/gemini.d.ts +2 -2
  13. package/dist/protocols/gemini.js +3 -3
  14. package/dist/protocols/google-interactions.d.ts +236 -0
  15. package/dist/protocols/google-interactions.js +478 -0
  16. package/dist/protocols/google-speech.js +1 -1
  17. package/dist/protocols/google-transcription.js +1 -1
  18. package/dist/protocols/index.d.ts +2 -0
  19. package/dist/protocols/index.js +2 -0
  20. package/dist/protocols/meta-responses.d.ts +31 -58
  21. package/dist/protocols/meta-responses.js +8 -27
  22. package/dist/protocols/mistral-chat.d.ts +24 -9
  23. package/dist/protocols/mistral-chat.js +22 -10
  24. package/dist/protocols/open-responses.d.ts +406 -91
  25. package/dist/protocols/open-responses.js +25 -15
  26. package/dist/protocols/openai-chat.d.ts +401 -5
  27. package/dist/protocols/openai-chat.js +18 -21
  28. package/dist/protocols/openai-compatible-chat.d.ts +1 -1
  29. package/dist/protocols/openai-compatible-responses.d.ts +16 -4
  30. package/dist/protocols/openai-images.js +2 -2
  31. package/dist/protocols/openai-responses.d.ts +87 -223
  32. package/dist/protocols/openai-responses.js +6 -13
  33. package/dist/protocols/openai-speech.js +1 -1
  34. package/dist/protocols/openai-transcription.js +1 -1
  35. package/dist/protocols/shared.js +2 -2
  36. package/dist/protocols/stability-images.js +1 -1
  37. package/dist/protocols/utils/bedrock-media.js +2 -2
  38. package/dist/protocols/utils/responses-checkpoint.js +2 -2
  39. package/dist/protocols/utils/responses-hosted-tools.js +1 -1
  40. package/dist/protocols/utils/tool-stream.js +15 -7
  41. package/dist/protocols/venice-chat.d.ts +280 -0
  42. package/dist/protocols/venice-chat.js +283 -0
  43. package/dist/protocols/xai-responses.d.ts +18 -21
  44. package/dist/protocols/xai-responses.js +2 -8
  45. package/dist/protocols/zai-chat.d.ts +3 -3
  46. package/dist/provider-error.js +7 -1
  47. package/dist/providers/alibaba.d.ts +17 -13
  48. package/dist/providers/amazon-bedrock/mantle/messages.d.ts +2 -0
  49. package/dist/providers/amazon-bedrock/mantle/messages.js +1 -0
  50. package/dist/providers/amazon-bedrock-mantle.d.ts +301 -9
  51. package/dist/providers/amazon-bedrock-mantle.js +28 -3
  52. package/dist/providers/azure.d.ts +13 -61
  53. package/dist/providers/baseten.d.ts +2 -2
  54. package/dist/providers/cerebras.d.ts +2 -2
  55. package/dist/providers/cloudflare-ai-gateway.d.ts +14 -62
  56. package/dist/providers/cloudflare-workers-ai.d.ts +2 -2
  57. package/dist/providers/cohere/chat.d.ts +4 -0
  58. package/dist/providers/cohere/chat.js +8 -0
  59. package/dist/providers/cohere.d.ts +395 -0
  60. package/dist/providers/cohere.js +48 -0
  61. package/dist/providers/deepinfra.d.ts +2 -2
  62. package/dist/providers/deepseek.d.ts +2 -2
  63. package/dist/providers/digitalocean.d.ts +5 -5
  64. package/dist/providers/fireworks.d.ts +2 -2
  65. package/dist/providers/google/interactions.d.ts +7 -0
  66. package/dist/providers/google/interactions.js +8 -0
  67. package/dist/providers/google-vertex-chat.d.ts +1 -1
  68. package/dist/providers/google-vertex-responses.d.ts +16 -4
  69. package/dist/providers/google-vertex.d.ts +1 -1
  70. package/dist/providers/google.d.ts +95 -4
  71. package/dist/providers/google.js +8 -1
  72. package/dist/providers/groq.d.ts +4 -4
  73. package/dist/providers/index.d.ts +2 -0
  74. package/dist/providers/index.js +2 -0
  75. package/dist/providers/meta.d.ts +15 -28
  76. package/dist/providers/minimax.d.ts +17 -5
  77. package/dist/providers/mistral.d.ts +10 -4
  78. package/dist/providers/moonshot.d.ts +17 -5
  79. package/dist/providers/openai-compatible-responses.d.ts +16 -4
  80. package/dist/providers/openai-compatible.d.ts +1 -1
  81. package/dist/providers/openai-options.d.ts +1 -1
  82. package/dist/providers/openai.d.ts +7 -31
  83. package/dist/providers/openrouter.d.ts +5 -5
  84. package/dist/providers/togetherai.d.ts +2 -2
  85. package/dist/providers/venice.d.ts +183 -0
  86. package/dist/providers/venice.js +38 -0
  87. package/dist/providers/xai.d.ts +1 -1
  88. package/dist/providers/zai-coding-plan.d.ts +17 -5
  89. package/dist/providers/zai.d.ts +1 -1
  90. package/dist/route/client.js +2 -5
  91. package/dist/route/framing.js +23 -23
  92. package/package.json +3 -3
@@ -123,9 +123,9 @@ export declare const routes: (Route<{
123
123
  readonly top_p?: number | undefined;
124
124
  readonly frequency_penalty?: number | undefined;
125
125
  readonly presence_penalty?: number | undefined;
126
+ readonly store?: boolean | undefined;
126
127
  readonly prompt_cache_key?: string | undefined;
127
128
  readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
128
- readonly store?: boolean | undefined;
129
129
  readonly stream_options?: {
130
130
  readonly include_usage: boolean;
131
131
  } | undefined;
@@ -173,6 +173,10 @@ export declare const routes: (Route<{
173
173
  readonly reasoning: {
174
174
  readonly effort: import("../schema/options.js").ReasoningEffort;
175
175
  };
176
+ } | {
177
+ readonly [x: string]: unknown;
178
+ readonly type: string;
179
+ readonly id: string;
176
180
  } | {
177
181
  readonly type: "reasoning";
178
182
  readonly summary: readonly {
@@ -249,34 +253,6 @@ export declare const routes: (Route<{
249
253
  readonly type: "input_video";
250
254
  readonly video_url: string;
251
255
  })[];
252
- } | {
253
- readonly [x: string]: unknown;
254
- readonly id: string;
255
- readonly type: "computer_call";
256
- readonly status?: string | undefined;
257
- readonly action?: {
258
- readonly [x: string]: unknown;
259
- } | null | undefined;
260
- readonly call_id?: string | undefined;
261
- readonly pending_safety_checks?: readonly {
262
- readonly [x: string]: unknown;
263
- }[] | undefined;
264
- } | {
265
- readonly [x: string]: unknown;
266
- readonly id: string;
267
- readonly type: "web_search_preview_call";
268
- readonly status?: string | undefined;
269
- readonly action?: {
270
- readonly [x: string]: unknown;
271
- } | null | undefined;
272
- } | {
273
- readonly [x: string]: unknown;
274
- readonly id: string;
275
- readonly type: "image_generation_call";
276
- readonly status?: string | undefined;
277
- readonly result?: string | null | undefined;
278
- readonly output_format?: "png" | "jpeg" | "webp" | undefined;
279
- readonly revised_prompt?: string | null | undefined;
280
256
  })[];
281
257
  readonly model: string;
282
258
  readonly stream: true;
@@ -345,9 +321,10 @@ export declare const routes: (Route<{
345
321
  readonly top_p?: number | undefined;
346
322
  readonly frequency_penalty?: number | undefined;
347
323
  readonly presence_penalty?: number | undefined;
324
+ readonly store?: boolean | undefined;
325
+ readonly max_output_tokens?: number | undefined;
348
326
  readonly prompt_cache_key?: string | undefined;
349
327
  readonly parallel_tool_calls?: boolean | undefined;
350
- readonly store?: boolean | undefined;
351
328
  readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
352
329
  readonly truncation?: "auto" | "disabled" | undefined;
353
330
  readonly stream_options?: {
@@ -355,7 +332,6 @@ export declare const routes: (Route<{
355
332
  } | undefined;
356
333
  readonly safety_identifier?: string | undefined;
357
334
  readonly top_logprobs?: number | undefined;
358
- readonly max_output_tokens?: number | undefined;
359
335
  readonly max_tool_calls?: number | undefined;
360
336
  }, import("../protocols/open-responses-channel.js").Prepared, {
361
337
  endpoint: import("../route/client.js").CompactOperation;
@@ -322,9 +322,9 @@ export declare const protocol: Protocol<{
322
322
  readonly top_p?: number | undefined;
323
323
  readonly frequency_penalty?: number | undefined;
324
324
  readonly presence_penalty?: number | undefined;
325
+ readonly store?: boolean | undefined;
325
326
  readonly prompt_cache_key?: string | undefined;
326
327
  readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
327
- readonly store?: boolean | undefined;
328
328
  readonly stream_options?: {
329
329
  readonly include_usage: boolean;
330
330
  } | undefined;
@@ -340,9 +340,9 @@ export declare const protocol: Protocol<{
340
340
  readonly [x: string]: unknown;
341
341
  readonly cache_read_input_tokens?: number | null | undefined;
342
342
  readonly cached_tokens?: number | null | undefined;
343
+ readonly total_tokens?: number | null | undefined;
343
344
  readonly prompt_tokens?: number | null | undefined;
344
345
  readonly completion_tokens?: number | null | undefined;
345
- readonly total_tokens?: number | null | undefined;
346
346
  readonly prompt_tokens_details?: {
347
347
  readonly [x: string]: unknown;
348
348
  readonly cached_tokens?: number | null | undefined;
@@ -381,9 +381,9 @@ export declare const protocol: Protocol<{
381
381
  readonly [x: string]: unknown;
382
382
  readonly cache_read_input_tokens?: number | null | undefined;
383
383
  readonly cached_tokens?: number | null | undefined;
384
+ readonly total_tokens?: number | null | undefined;
384
385
  readonly prompt_tokens?: number | null | undefined;
385
386
  readonly completion_tokens?: number | null | undefined;
386
- readonly total_tokens?: number | null | undefined;
387
387
  readonly prompt_tokens_details?: {
388
388
  readonly [x: string]: unknown;
389
389
  readonly cached_tokens?: number | null | undefined;
@@ -517,9 +517,9 @@ export declare const route: Route<{
517
517
  readonly top_p?: number | undefined;
518
518
  readonly frequency_penalty?: number | undefined;
519
519
  readonly presence_penalty?: number | undefined;
520
+ readonly store?: boolean | undefined;
520
521
  readonly prompt_cache_key?: string | undefined;
521
522
  readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
522
- readonly store?: boolean | undefined;
523
523
  readonly stream_options?: {
524
524
  readonly include_usage: boolean;
525
525
  } | undefined;
@@ -640,9 +640,9 @@ export declare const routes: Route<{
640
640
  readonly top_p?: number | undefined;
641
641
  readonly frequency_penalty?: number | undefined;
642
642
  readonly presence_penalty?: number | undefined;
643
+ readonly store?: boolean | undefined;
643
644
  readonly prompt_cache_key?: string | undefined;
644
645
  readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
645
- readonly store?: boolean | undefined;
646
646
  readonly stream_options?: {
647
647
  readonly include_usage: boolean;
648
648
  } | undefined;
@@ -126,9 +126,9 @@ export declare const route: Route<{
126
126
  readonly top_p?: number | undefined;
127
127
  readonly frequency_penalty?: number | undefined;
128
128
  readonly presence_penalty?: number | undefined;
129
+ readonly store?: boolean | undefined;
129
130
  readonly prompt_cache_key?: string | undefined;
130
131
  readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
131
- readonly store?: boolean | undefined;
132
132
  readonly stream_options?: {
133
133
  readonly include_usage: boolean;
134
134
  } | undefined;
@@ -248,9 +248,9 @@ export declare const routes: Route<{
248
248
  readonly top_p?: number | undefined;
249
249
  readonly frequency_penalty?: number | undefined;
250
250
  readonly presence_penalty?: number | undefined;
251
+ readonly store?: boolean | undefined;
251
252
  readonly prompt_cache_key?: string | undefined;
252
253
  readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
253
- readonly store?: boolean | undefined;
254
254
  readonly stream_options?: {
255
255
  readonly include_usage: boolean;
256
256
  } | undefined;
@@ -0,0 +1,183 @@
1
+ import type { ProviderPackage } from "../provider-package.js";
2
+ import { VeniceChat } from "../protocols/venice-chat.js";
3
+ import { type ProviderAuthOption } from "../route/auth-options.js";
4
+ import { Route, type RouteDefaultsInput } from "../route/client.js";
5
+ import { type ModelID } from "../schema/index.js";
6
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
+ export type ChatOptionsInput = VeniceChat.OptionsInput;
8
+ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
9
+ readonly baseURL?: string;
10
+ readonly queryParams?: Readonly<Record<string, string>>;
11
+ readonly providerOptions?: ChatOptionsInput;
12
+ };
13
+ export type Settings = ProviderPackage.Settings & ChatOptionsInput & {
14
+ readonly apiKey?: string;
15
+ readonly baseURL?: string;
16
+ readonly queryParams?: Readonly<Record<string, string>>;
17
+ };
18
+ export declare const routes: Route<{
19
+ readonly model: string;
20
+ readonly messages: readonly ({
21
+ readonly role: "system";
22
+ readonly content: string | readonly ({
23
+ readonly type: "text";
24
+ readonly text: string;
25
+ readonly cache_control?: {
26
+ readonly type: "ephemeral";
27
+ readonly ttl?: string | undefined;
28
+ } | undefined;
29
+ } | {
30
+ readonly type: "image_url";
31
+ readonly image_url: {
32
+ readonly url: string;
33
+ };
34
+ } | {
35
+ readonly type: "file";
36
+ readonly file: {
37
+ readonly filename: string;
38
+ readonly file_data: string;
39
+ };
40
+ })[];
41
+ } | {
42
+ readonly role: "user";
43
+ readonly content: string | readonly ({
44
+ readonly type: "text";
45
+ readonly text: string;
46
+ readonly cache_control?: {
47
+ readonly type: "ephemeral";
48
+ readonly ttl?: string | undefined;
49
+ } | undefined;
50
+ } | {
51
+ readonly type: "image_url";
52
+ readonly image_url: {
53
+ readonly url: string;
54
+ };
55
+ } | {
56
+ readonly type: "file";
57
+ readonly file: {
58
+ readonly filename: string;
59
+ readonly file_data: string;
60
+ };
61
+ })[];
62
+ } | {
63
+ readonly role: "tool";
64
+ readonly tool_call_id: string;
65
+ readonly content: string | readonly {
66
+ readonly type: "text";
67
+ readonly text: string;
68
+ readonly cache_control?: {
69
+ readonly type: "ephemeral";
70
+ readonly ttl?: string | undefined;
71
+ } | undefined;
72
+ }[];
73
+ } | {
74
+ readonly [x: string]: unknown;
75
+ readonly content: string | readonly {
76
+ readonly type: "text";
77
+ readonly text: string;
78
+ readonly cache_control?: {
79
+ readonly type: "ephemeral";
80
+ readonly ttl?: string | undefined;
81
+ } | undefined;
82
+ }[] | null;
83
+ readonly role: "assistant";
84
+ readonly reasoning?: string | undefined;
85
+ readonly reasoning_content?: string | undefined;
86
+ readonly reasoning_text?: string | undefined;
87
+ readonly tool_calls?: readonly {
88
+ readonly function: {
89
+ readonly name: string;
90
+ readonly arguments: string;
91
+ };
92
+ readonly id: string;
93
+ readonly type: "function";
94
+ readonly thought_signature?: string | undefined;
95
+ readonly extra_content?: {
96
+ readonly google: {
97
+ readonly thought_signature: string;
98
+ };
99
+ } | undefined;
100
+ }[] | undefined;
101
+ readonly thought_signature?: string | undefined;
102
+ readonly reasoning_details?: unknown;
103
+ })[];
104
+ readonly stream: true;
105
+ readonly venice_parameters: {
106
+ readonly [x: string]: string | boolean;
107
+ };
108
+ readonly reasoning?: {
109
+ readonly enabled?: boolean | undefined;
110
+ readonly summary?: string | undefined;
111
+ readonly effort?: string | undefined;
112
+ } | undefined;
113
+ readonly max_completion_tokens?: number | undefined;
114
+ readonly max_tokens?: number | undefined;
115
+ readonly tools?: readonly {
116
+ readonly function: {
117
+ readonly description: string;
118
+ readonly name: string;
119
+ readonly parameters: {
120
+ readonly [x: string]: unknown;
121
+ };
122
+ readonly strict?: boolean | undefined;
123
+ };
124
+ readonly type: "function";
125
+ readonly cache_control?: {
126
+ readonly type: "ephemeral";
127
+ readonly ttl?: string | undefined;
128
+ } | undefined;
129
+ }[] | undefined;
130
+ readonly stop?: readonly string[] | undefined;
131
+ readonly user?: string | undefined;
132
+ readonly temperature?: number | undefined;
133
+ readonly seed?: number | undefined;
134
+ readonly tool_choice?: "required" | "auto" | "none" | {
135
+ readonly type: "function";
136
+ readonly function: {
137
+ readonly name: string;
138
+ };
139
+ } | undefined;
140
+ readonly top_p?: number | undefined;
141
+ readonly top_k?: number | undefined;
142
+ readonly frequency_penalty?: number | undefined;
143
+ readonly presence_penalty?: number | undefined;
144
+ readonly store?: boolean | undefined;
145
+ readonly prompt_cache_key?: string | undefined;
146
+ readonly parallel_tool_calls?: boolean | undefined;
147
+ readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
148
+ readonly stream_options?: {
149
+ readonly include_usage: boolean;
150
+ } | undefined;
151
+ readonly tool_stream?: boolean | undefined;
152
+ readonly top_logprobs?: number | undefined;
153
+ readonly prompt_cache_retention?: string | undefined;
154
+ readonly repetition_penalty?: number | undefined;
155
+ readonly response_format?: {
156
+ readonly [x: string]: unknown;
157
+ } | undefined;
158
+ readonly logprobs?: boolean | undefined;
159
+ readonly min_p?: number | undefined;
160
+ readonly stop_token_ids?: readonly number[] | undefined;
161
+ readonly max_temp?: number | undefined;
162
+ readonly min_temp?: number | undefined;
163
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
164
+ export declare const configure: (input?: Config) => {
165
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
166
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
167
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
168
+ configure: (input?: Config) => /*elided*/ any;
169
+ };
170
+ export declare const provider: {
171
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
172
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
173
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
174
+ configure: (input?: Config) => {
175
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
176
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
177
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
178
+ configure: /*elided*/ any;
179
+ };
180
+ };
181
+ export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
182
+ export declare const model: ProviderPackage.Definition<Settings, ChatOptionsInput>["model"];
183
+ export * as Venice from "./venice.js";
@@ -0,0 +1,38 @@
1
+ import { VeniceChat } from "../protocols/venice-chat.js";
2
+ import { OpenAIChat } from "../protocols/openai-chat.js";
3
+ import { AuthOptions } from "../route/auth-options.js";
4
+ import { Route } from "../route/client.js";
5
+ import { Endpoint } from "../route/endpoint.js";
6
+ import { ProviderID } from "../schema/index.js";
7
+ export const id = ProviderID.make("venice");
8
+ const route = Route.make({
9
+ id: "venice-chat",
10
+ provider: id,
11
+ providerMetadataKey: "venice",
12
+ protocol: VeniceChat.protocol,
13
+ endpoint: Endpoint.path("/chat/completions", { baseURL: "https://api.venice.ai/api/v1" }),
14
+ framing: OpenAIChat.framing,
15
+ });
16
+ export const routes = [route];
17
+ export const configure = (input = {}) => {
18
+ const { apiKey: _apiKey, auth: _auth, baseURL, queryParams, ...rest } = input;
19
+ const chat = (modelID) => route
20
+ .with({
21
+ ...rest,
22
+ endpoint: { baseURL: baseURL ?? route.endpoint.baseURL, query: queryParams },
23
+ auth: AuthOptions.bearer(input, "VENICE_API_KEY"),
24
+ })
25
+ .model({ id: modelID, compatibility: VeniceChat.compatibility });
26
+ return { id, model: chat, chat, configure };
27
+ };
28
+ export const provider = configure();
29
+ export const chat = provider.chat;
30
+ export const model = (modelID, { apiKey, baseURL, queryParams, body, headers, ...providerOptions }) => configure({
31
+ apiKey,
32
+ baseURL,
33
+ queryParams,
34
+ headers,
35
+ http: body === undefined ? undefined : { body: { ...body } },
36
+ providerOptions,
37
+ }).model(modelID);
38
+ export * as Venice from "./venice.js";
@@ -134,9 +134,9 @@ export declare const routes: (Route<{
134
134
  readonly top_p?: number | undefined;
135
135
  readonly frequency_penalty?: number | undefined;
136
136
  readonly presence_penalty?: number | undefined;
137
+ readonly store?: boolean | undefined;
137
138
  readonly prompt_cache_key?: string | undefined;
138
139
  readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
139
- readonly store?: boolean | undefined;
140
140
  readonly stream_options?: {
141
141
  readonly include_usage: boolean;
142
142
  } | undefined;
@@ -57,6 +57,15 @@ export declare const routes: (Route<{
57
57
  readonly error?: unknown;
58
58
  readonly arguments?: string | undefined;
59
59
  readonly server_label?: string | undefined;
60
+ } | {
61
+ readonly type: "configuration_update";
62
+ readonly reasoning: {
63
+ readonly effort: import("../schema/options.js").ReasoningEffort;
64
+ };
65
+ } | {
66
+ readonly [x: string]: unknown;
67
+ readonly type: string;
68
+ readonly id: string;
60
69
  } | {
61
70
  readonly type: "reasoning";
62
71
  readonly summary: readonly {
@@ -144,7 +153,10 @@ export declare const routes: (Route<{
144
153
  readonly summary?: "auto" | "concise" | "detailed" | undefined;
145
154
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
146
155
  } | undefined;
147
- readonly tools?: readonly {
156
+ readonly tools?: readonly ({
157
+ readonly [x: string]: unknown;
158
+ readonly type: string;
159
+ } | {
148
160
  readonly type: "function";
149
161
  readonly description: string;
150
162
  readonly name: string;
@@ -152,7 +164,7 @@ export declare const routes: (Route<{
152
164
  readonly [x: string]: unknown;
153
165
  };
154
166
  readonly strict?: boolean | undefined;
155
- }[] | undefined;
167
+ })[] | undefined;
156
168
  readonly text?: {
157
169
  readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
158
170
  } | undefined;
@@ -172,9 +184,10 @@ export declare const routes: (Route<{
172
184
  readonly top_p?: number | undefined;
173
185
  readonly frequency_penalty?: number | undefined;
174
186
  readonly presence_penalty?: number | undefined;
187
+ readonly store?: boolean | undefined;
188
+ readonly max_output_tokens?: number | undefined;
175
189
  readonly prompt_cache_key?: string | undefined;
176
190
  readonly parallel_tool_calls?: boolean | undefined;
177
- readonly store?: boolean | undefined;
178
191
  readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
179
192
  readonly truncation?: "auto" | "disabled" | undefined;
180
193
  readonly stream_options?: {
@@ -182,7 +195,6 @@ export declare const routes: (Route<{
182
195
  } | undefined;
183
196
  readonly safety_identifier?: string | undefined;
184
197
  readonly top_logprobs?: number | undefined;
185
- readonly max_output_tokens?: number | undefined;
186
198
  readonly max_tool_calls?: number | undefined;
187
199
  }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<{
188
200
  readonly model: string;
@@ -303,9 +315,9 @@ export declare const routes: (Route<{
303
315
  readonly top_p?: number | undefined;
304
316
  readonly frequency_penalty?: number | undefined;
305
317
  readonly presence_penalty?: number | undefined;
318
+ readonly store?: boolean | undefined;
306
319
  readonly prompt_cache_key?: string | undefined;
307
320
  readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
308
- readonly store?: boolean | undefined;
309
321
  readonly stream_options?: {
310
322
  readonly include_usage: boolean;
311
323
  } | undefined;
@@ -133,9 +133,9 @@ export declare const routes: Route<{
133
133
  readonly top_p?: number | undefined;
134
134
  readonly frequency_penalty?: number | undefined;
135
135
  readonly presence_penalty?: number | undefined;
136
+ readonly store?: boolean | undefined;
136
137
  readonly prompt_cache_key?: string | undefined;
137
138
  readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
138
- readonly store?: boolean | undefined;
139
139
  readonly stream_options?: {
140
140
  readonly include_usage: boolean;
141
141
  } | undefined;
@@ -102,7 +102,6 @@ const requireTerminalEvent = (route) => (events) => Stream.suspend(() => {
102
102
  });
103
103
  function makeFromTransport(input) {
104
104
  const protocol = input.protocol;
105
- const encodeBody = Schema.encodeSync(Schema.fromJsonString(protocol.body.schema));
106
105
  const decodeEventEffect = Schema.decodeUnknownEffect(protocol.stream.event);
107
106
  const decodeEvent = (route) => (frame) => decodeEventEffect(frame).pipe(Effect.mapError((cause) => ProviderShared.eventError(input.id, `Invalid ${route} stream event`, typeof frame === "string" ? frame : ProviderShared.encodeJson(frame), cause)));
108
107
  const build = (routeInput) => {
@@ -143,7 +142,7 @@ function makeFromTransport(input) {
143
142
  request,
144
143
  endpoint: routeInput.endpoint,
145
144
  auth: routeInput.auth ?? Auth.none,
146
- encodeBody,
145
+ encodeBody: ProviderShared.encodeJson,
147
146
  middleware: options?.http,
148
147
  webSocket: options?.webSocket,
149
148
  }),
@@ -221,9 +220,7 @@ const prepareRequest = (request) => {
221
220
  const compile = Effect.fn("LLM.compile")(function* (request, options) {
222
221
  const resolved = prepareRequest(request);
223
222
  const route = resolved.model.route;
224
- const body = yield* route.body
225
- .from(resolved)
226
- .pipe(Effect.flatMap(ProviderShared.validateWith(Schema.decodeUnknownEffect(route.body.schema))));
223
+ const body = yield* route.body.from(resolved);
227
224
  const prepared = yield* route.prepareTransport(body, resolved, options);
228
225
  return {
229
226
  request: resolved,
@@ -14,32 +14,32 @@ export const sseFraming = (bytes, events, includeDone = false) => bytes.pipe(Str
14
14
  return {
15
15
  output,
16
16
  parser: makeParser((event) => {
17
- if (event._tag === "Event")
18
- output.push(event);
17
+ if (event._tag === "Event" &&
18
+ (events === undefined || events.has(event.event)) &&
19
+ event.data.length > 0 &&
20
+ // Some OpenAI-compatible proxies serialize an empty flush as a bare
21
+ // `data: null`, between events or after `[DONE]`. No protocol has a
22
+ // null event, so it carries nothing and must not abort the stream.
23
+ event.data !== "null" &&
24
+ // Vertex AI partner models (e.g. `xai/grok-4.6`) send their SSE
25
+ // keepalive comment as `data: : keepalive` while reasoning.
26
+ event.data !== ": keepalive" &&
27
+ (event.data !== "[DONE]" || includeDone || (events !== undefined && event.event !== "message")))
28
+ output.push(event.data);
19
29
  }),
20
30
  };
21
- }, (state, chunk) => Effect.gen(function* () {
31
+ }, (state, chunk) => {
22
32
  const error = state.parser.feed(chunk);
23
- if (error)
24
- return yield* new AIError({
25
- reason: new InvalidProviderOutputError({
26
- route: "sse",
27
- message: error.message,
28
- body: chunk,
29
- cause: error,
30
- }),
31
- });
32
- return [state, state.output.splice(0)];
33
- })), Stream.filter((event) => (events === undefined || events.has(event.event)) &&
34
- event.data.length > 0 &&
35
- // Some OpenAI-compatible proxies serialize an empty flush as a bare
36
- // `data: null`, between events or after `[DONE]`. No protocol has a
37
- // null event, so it carries nothing and must not abort the stream.
38
- event.data !== "null" &&
39
- // Vertex AI partner models (e.g. `xai/grok-4.6`) send their SSE
40
- // keepalive comment as `data: : keepalive` while reasoning.
41
- event.data !== ": keepalive" &&
42
- (event.data !== "[DONE]" || includeDone || (events !== undefined && event.event !== "message"))), Stream.map((event) => event.data));
33
+ if (!error)
34
+ return Effect.succeed([state, state.output.splice(0)]);
35
+ const reason = new InvalidProviderOutputError({
36
+ route: "sse",
37
+ message: error.message,
38
+ body: chunk,
39
+ cause: error,
40
+ });
41
+ return Effect.fail(new AIError({ reason }));
42
+ }));
43
43
  /** Server-Sent Events framing. Used by every JSON-streaming HTTP provider. */
44
44
  export const sse = { id: "sse", frame: sseFraming };
45
45
  /** Server-Sent Events framing that retains the conventional `[DONE]` sentinel. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "2.0.22",
3
+ "version": "2.0.23",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@clack/prompts": "1.0.0-alpha.1",
36
36
  "@effect/platform-node": "4.0.0-rc.112",
37
- "@opencode/http-recorder": "2.0.22",
37
+ "@opencode/http-recorder": "2.0.23",
38
38
  "@tsconfig/bun": "1.0.9",
39
39
  "@types/bun": "1.4.0",
40
40
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -44,7 +44,7 @@
44
44
  "@aws-sdk/credential-providers": "3.1057.0",
45
45
  "@smithy/eventstream-codec": "4.2.14",
46
46
  "@smithy/util-utf8": "4.2.2",
47
- "@opencode/schema": "2.0.22",
47
+ "@opencode/schema": "2.0.23",
48
48
  "aws4fetch": "1.0.20",
49
49
  "effect": "4.0.0-rc.112",
50
50
  "google-auth-library": "10.5.0"