@opencode/ai 2.2.0 → 2.2.2

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 (189) hide show
  1. package/README.md +66 -62
  2. package/dist/effect.d.ts +1 -1
  3. package/dist/effect.js +1 -1
  4. package/dist/image-client.d.ts +45 -0
  5. package/dist/image.d.ts +1 -0
  6. package/dist/index.d.ts +38 -20
  7. package/dist/index.js +14 -2
  8. package/dist/media-client.d.ts +1 -0
  9. package/dist/media-client.js +1 -0
  10. package/dist/protocols/alibaba-chat.d.ts +39 -4
  11. package/dist/protocols/alibaba-responses.d.ts +20 -3
  12. package/dist/protocols/google-images.js +3 -1
  13. package/dist/protocols/meta-responses.d.ts +40 -6
  14. package/dist/protocols/meta-responses.js +1 -1
  15. package/dist/protocols/minimax-images.d.ts +25 -0
  16. package/dist/protocols/minimax-images.js +150 -0
  17. package/dist/protocols/open-responses.d.ts +182 -27
  18. package/dist/protocols/open-responses.js +108 -36
  19. package/dist/protocols/openai-chat.d.ts +438 -46
  20. package/dist/protocols/openai-chat.js +121 -39
  21. package/dist/protocols/openai-compatible-chat.d.ts +35 -4
  22. package/dist/protocols/openai-compatible-responses.d.ts +20 -3
  23. package/dist/protocols/openai-freeform.d.ts +47 -0
  24. package/dist/protocols/openai-freeform.js +54 -0
  25. package/dist/protocols/openai-images.d.ts +16 -1
  26. package/dist/protocols/openai-images.js +49 -17
  27. package/dist/protocols/openai-responses.d.ts +120 -18
  28. package/dist/protocols/openai-responses.js +17 -8
  29. package/dist/protocols/venice-chat.d.ts +39 -4
  30. package/dist/protocols/venice-chat.js +1 -1
  31. package/dist/protocols/xai-images.d.ts +6 -0
  32. package/dist/protocols/xai-images.js +4 -5
  33. package/dist/protocols/xai-responses.d.ts +20 -3
  34. package/dist/protocols/xai-responses.js +2 -1
  35. package/dist/protocols/zai-chat.d.ts +39 -4
  36. package/dist/provider-error.js +5 -4
  37. package/dist/provider-package.d.ts +2 -0
  38. package/dist/providers/alibaba.d.ts +58 -10
  39. package/dist/providers/amazon-bedrock-mantle.d.ts +66 -11
  40. package/dist/providers/amazon-bedrock-mantle.js +1 -1
  41. package/dist/providers/amazon-bedrock.d.ts +1 -1
  42. package/dist/providers/amazon-bedrock.js +1 -1
  43. package/dist/providers/anthropic-compatible.d.ts +1 -1
  44. package/dist/providers/anthropic.d.ts +1 -1
  45. package/dist/providers/anthropic.js +1 -1
  46. package/dist/providers/azure.d.ts +79 -15
  47. package/dist/providers/baseten.d.ts +74 -12
  48. package/dist/providers/baseten.js +1 -1
  49. package/dist/providers/cerebras.d.ts +73 -11
  50. package/dist/providers/cerebras.js +1 -1
  51. package/dist/providers/cloudflare-ai-gateway.d.ts +113 -17
  52. package/dist/providers/cloudflare-workers-ai.d.ts +73 -11
  53. package/dist/providers/cohere/chat.d.ts +1 -1
  54. package/dist/providers/cohere/chat.js +1 -1
  55. package/dist/providers/cohere.d.ts +73 -11
  56. package/dist/providers/cohere.js +1 -1
  57. package/dist/providers/deepinfra.d.ts +73 -11
  58. package/dist/providers/deepinfra.js +1 -1
  59. package/dist/providers/deepseek.d.ts +73 -11
  60. package/dist/providers/deepseek.js +1 -1
  61. package/dist/providers/digitalocean/responses.d.ts +4 -0
  62. package/dist/providers/digitalocean/responses.js +1 -0
  63. package/dist/providers/digitalocean.d.ts +320 -21
  64. package/dist/providers/digitalocean.js +18 -7
  65. package/dist/providers/fireworks.d.ts +73 -11
  66. package/dist/providers/fireworks.js +1 -1
  67. package/dist/providers/google/interactions.d.ts +1 -1
  68. package/dist/providers/google/interactions.js +1 -1
  69. package/dist/providers/google-vertex-chat.d.ts +36 -5
  70. package/dist/providers/google-vertex-chat.js +1 -1
  71. package/dist/providers/google-vertex-interactions.d.ts +1 -1
  72. package/dist/providers/google-vertex-interactions.js +1 -1
  73. package/dist/providers/google-vertex-messages.d.ts +1 -1
  74. package/dist/providers/google-vertex-messages.js +1 -1
  75. package/dist/providers/google-vertex-mistral.d.ts +1 -1
  76. package/dist/providers/google-vertex-mistral.js +1 -1
  77. package/dist/providers/google-vertex-responses.d.ts +21 -4
  78. package/dist/providers/google-vertex-responses.js +1 -1
  79. package/dist/providers/google-vertex.d.ts +2 -2
  80. package/dist/providers/google-vertex.js +1 -1
  81. package/dist/providers/google.d.ts +2 -2
  82. package/dist/providers/google.js +1 -1
  83. package/dist/providers/groq.d.ts +77 -11
  84. package/dist/providers/groq.js +1 -1
  85. package/dist/providers/index.d.ts +0 -4
  86. package/dist/providers/index.js +0 -4
  87. package/dist/providers/meta/images.d.ts +2 -0
  88. package/dist/providers/meta/images.js +1 -0
  89. package/dist/providers/meta.d.ts +61 -12
  90. package/dist/providers/meta.js +2 -1
  91. package/dist/providers/minimax/chat.d.ts +1 -1
  92. package/dist/providers/minimax/chat.js +1 -1
  93. package/dist/providers/minimax/images.d.ts +3 -0
  94. package/dist/providers/minimax/images.js +1 -0
  95. package/dist/providers/minimax/responses.d.ts +1 -1
  96. package/dist/providers/minimax/responses.js +1 -1
  97. package/dist/providers/minimax.d.ts +63 -9
  98. package/dist/providers/minimax.js +22 -9
  99. package/dist/providers/mistral.d.ts +3 -3
  100. package/dist/providers/mistral.js +1 -1
  101. package/dist/providers/moonshot/messages.d.ts +1 -1
  102. package/dist/providers/moonshot/messages.js +1 -1
  103. package/dist/providers/moonshot/responses.d.ts +1 -1
  104. package/dist/providers/moonshot/responses.js +1 -1
  105. package/dist/providers/moonshot.d.ts +56 -8
  106. package/dist/providers/moonshot.js +1 -1
  107. package/dist/providers/openai-compatible-responses.d.ts +21 -4
  108. package/dist/providers/openai-compatible.d.ts +38 -7
  109. package/dist/providers/openai-compatible.js +9 -2
  110. package/dist/providers/openai.d.ts +59 -11
  111. package/dist/providers/openai.js +4 -2
  112. package/dist/providers/opencode.d.ts +3 -3
  113. package/dist/providers/opencode.js +1 -1
  114. package/dist/providers/openrouter/responses.d.ts +4 -0
  115. package/dist/providers/openrouter/responses.js +1 -0
  116. package/dist/providers/openrouter.d.ts +356 -26
  117. package/dist/providers/openrouter.js +42 -13
  118. package/dist/providers/togetherai.d.ts +73 -11
  119. package/dist/providers/togetherai.js +1 -1
  120. package/dist/providers/typesafe-ai.d.ts +3 -3
  121. package/dist/providers/typesafe-ai.js +1 -1
  122. package/dist/providers/venice/responses.d.ts +4 -0
  123. package/dist/providers/venice/responses.js +1 -0
  124. package/dist/providers/venice.d.ts +242 -9
  125. package/dist/providers/venice.js +33 -17
  126. package/dist/providers/vercel-ai-gateway.d.ts +8 -8
  127. package/dist/providers/vercel-ai-gateway.js +12 -2
  128. package/dist/providers/xai.d.ts +39 -8
  129. package/dist/providers/xai.js +1 -1
  130. package/dist/providers/zai-coding-plan/messages.d.ts +1 -1
  131. package/dist/providers/zai-coding-plan/messages.js +1 -1
  132. package/dist/providers/zai-coding-plan/responses.d.ts +1 -1
  133. package/dist/providers/zai-coding-plan/responses.js +1 -1
  134. package/dist/providers/zai-coding-plan.d.ts +56 -8
  135. package/dist/providers/zai-coding-plan.js +1 -1
  136. package/dist/providers/zai.d.ts +37 -6
  137. package/dist/providers/zai.js +1 -1
  138. package/dist/route/auth.d.ts +1 -1
  139. package/dist/route/media-protocol.d.ts +2 -4
  140. package/dist/route/media.d.ts +1 -1
  141. package/dist/route/media.js +2 -4
  142. package/dist/schema/events.d.ts +2 -0
  143. package/dist/schema/messages.d.ts +35 -1
  144. package/dist/schema/messages.js +20 -0
  145. package/dist/speech-client.d.ts +48 -0
  146. package/dist/speech.d.ts +1 -0
  147. package/dist/testing/decision.d.ts +16 -0
  148. package/dist/testing/decision.js +20 -0
  149. package/dist/testing/image.d.ts +14 -0
  150. package/dist/testing/image.js +12 -0
  151. package/dist/testing/media.d.ts +18 -0
  152. package/dist/testing/media.js +36 -0
  153. package/dist/testing/script.d.ts +28 -0
  154. package/dist/testing/script.js +60 -0
  155. package/dist/testing/speech.d.ts +14 -0
  156. package/dist/testing/speech.js +12 -0
  157. package/dist/testing/transcription.d.ts +14 -0
  158. package/dist/testing/transcription.js +12 -0
  159. package/dist/testing/video.d.ts +14 -0
  160. package/dist/testing/video.js +12 -0
  161. package/dist/testing.d.ts +10 -21
  162. package/dist/testing.js +11 -54
  163. package/dist/tool.d.ts +12 -1
  164. package/dist/tool.js +10 -2
  165. package/dist/transcription-client.d.ts +64 -0
  166. package/dist/transcription.d.ts +1 -0
  167. package/dist/video-client.d.ts +41 -0
  168. package/dist/video.d.ts +1 -0
  169. package/package.json +24 -40
  170. package/dist/protocols/bfl-images.d.ts +0 -47
  171. package/dist/protocols/bfl-images.js +0 -155
  172. package/dist/protocols/fal-images.d.ts +0 -34
  173. package/dist/protocols/fal-images.js +0 -95
  174. package/dist/protocols/fal-video.d.ts +0 -29
  175. package/dist/protocols/fal-video.js +0 -73
  176. package/dist/protocols/replicate-images.d.ts +0 -28
  177. package/dist/protocols/replicate-images.js +0 -127
  178. package/dist/protocols/stability-images.d.ts +0 -44
  179. package/dist/protocols/stability-images.js +0 -131
  180. package/dist/protocols/utils/fal-queue.d.ts +0 -26
  181. package/dist/protocols/utils/fal-queue.js +0 -67
  182. package/dist/providers/black-forest-labs.d.ts +0 -21
  183. package/dist/providers/black-forest-labs.js +0 -23
  184. package/dist/providers/fal.d.ts +0 -24
  185. package/dist/providers/fal.js +0 -26
  186. package/dist/providers/replicate.d.ts +0 -21
  187. package/dist/providers/replicate.js +0 -17
  188. package/dist/providers/stability.d.ts +0 -23
  189. package/dist/providers/stability.js +0 -18
@@ -4,6 +4,7 @@ import { OpenAIChat } from "../protocols/openai-chat.js";
4
4
  import { OpenResponses } from "../protocols/open-responses.js";
5
5
  import { OpenAIDecisions } from "../protocols/openai-decisions.js";
6
6
  import { OpenAIImages } from "../protocols/openai-images.js";
7
+ import { XAIImages } from "../protocols/xai-images.js";
7
8
  import { ProviderShared } from "../protocols/shared.js";
8
9
  import { gatewayProtocol } from "../protocols/utils/gateway-protocol.js";
9
10
  import { AuthOptions } from "../route/auth-options.js";
@@ -106,6 +107,15 @@ const chatRoute = route({
106
107
  framing: OpenAIChat.framing,
107
108
  });
108
109
  export const routes = [messagesRoute, responsesRoute, chatRoute];
110
+ // The Gateway passes `size` through to most image models, but Grok ignores it and renders 1024x1024; it only reads
111
+ // sizing from `providerOptions.xai`.
112
+ const imageSizing = (request) => {
113
+ if (!/^(spacexai|xai)\//.test(request.model.id))
114
+ return OpenAIImages.pixelSize(request);
115
+ if (request.aspect === undefined && request.resolution === undefined)
116
+ return undefined;
117
+ return { providerOptions: { xai: { aspect_ratio: request.aspect, resolution: XAIImages.resolution(request) } } };
118
+ };
109
119
  export const configure = (input = {}) => {
110
120
  const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input;
111
121
  const configured = {
@@ -131,7 +141,7 @@ export const configure = (input = {}) => {
131
141
  return messages(modelID);
132
142
  };
133
143
  const media = MediaRoute.deployment({ ...input, baseURL: configured.endpoint.baseURL }, configured.auth);
134
- const image = (modelID, providerOptions) => OpenAIImages.model({ ...media, id: modelID, provider: id, providerOptions });
144
+ const image = (modelID, providerOptions) => OpenAIImages.model({ ...media, id: modelID, provider: id, providerOptions, sizing: imageSizing });
135
145
  const decisionRoute = OpenAIDecisions.route.with({
136
146
  provider: id,
137
147
  endpoint: { baseURL: configured.endpoint.baseURL },
@@ -160,7 +170,7 @@ export const decisionModel = (modelID, settings) => {
160
170
  const input = config(settings);
161
171
  return configure(input).decision(modelID, input.providerOptions);
162
172
  };
163
- function config({ apiKey, baseURL, headers, body, ...providerOptions }) {
173
+ function config({ apiKey, baseURL, headers, body, ...providerOptions } = {}) {
164
174
  return {
165
175
  apiKey,
166
176
  baseURL,
@@ -8,7 +8,7 @@ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
8
8
  export type XAIProviderOptionsInput = OpenAIOptionsInput & XAIResponses.OptionsInput & {
9
9
  readonly contextManagement?: never;
10
10
  };
11
- export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
11
+ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
12
12
  readonly baseURL?: string;
13
13
  readonly providerOptions?: XAIProviderOptionsInput;
14
14
  };
@@ -99,7 +99,14 @@ export declare const routes: (Route<unknown, import("../protocols/open-responses
99
99
  readonly ttl?: string | undefined;
100
100
  } | undefined;
101
101
  }[] | null;
102
- readonly tool_calls?: readonly {
102
+ readonly tool_calls?: readonly ({
103
+ readonly id: string;
104
+ readonly type: "custom";
105
+ readonly custom: {
106
+ readonly name: string;
107
+ readonly input: string;
108
+ };
109
+ } | {
103
110
  readonly id: string;
104
111
  readonly type: "function";
105
112
  readonly function: {
@@ -111,13 +118,13 @@ export declare const routes: (Route<unknown, import("../protocols/open-responses
111
118
  readonly thought_signature: string;
112
119
  };
113
120
  } | undefined;
114
- }[] | undefined;
121
+ })[] | undefined;
115
122
  readonly reasoning_content?: string | undefined;
116
123
  readonly reasoning?: string | undefined;
117
124
  readonly reasoning_text?: string | undefined;
118
125
  readonly reasoning_details?: unknown;
119
126
  })[];
120
- readonly tools?: readonly {
127
+ readonly tools?: readonly ({
121
128
  readonly type: "function";
122
129
  readonly function: {
123
130
  readonly name: string;
@@ -131,12 +138,36 @@ export declare const routes: (Route<unknown, import("../protocols/open-responses
131
138
  readonly type: "ephemeral";
132
139
  readonly ttl?: string | undefined;
133
140
  } | undefined;
134
- }[] | undefined;
141
+ } | {
142
+ readonly type: "custom";
143
+ readonly custom: {
144
+ readonly name: string;
145
+ readonly description: string;
146
+ readonly format: {
147
+ readonly type: "text";
148
+ } | {
149
+ readonly type: "grammar";
150
+ readonly grammar: {
151
+ readonly syntax: "lark" | "regex";
152
+ readonly definition: string;
153
+ };
154
+ };
155
+ };
156
+ readonly cache_control?: {
157
+ readonly type: "ephemeral";
158
+ readonly ttl?: string | undefined;
159
+ } | undefined;
160
+ })[] | undefined;
135
161
  readonly tool_choice?: "auto" | "none" | "required" | {
136
162
  readonly type: "function";
137
163
  readonly function: {
138
164
  readonly name: string;
139
165
  };
166
+ } | {
167
+ readonly type: "custom";
168
+ readonly custom: {
169
+ readonly name: string;
170
+ };
140
171
  } | undefined;
141
172
  readonly stream: true;
142
173
  readonly stream_options?: {
@@ -166,7 +197,7 @@ export declare const routes: (Route<unknown, import("../protocols/open-responses
166
197
  readonly seed?: number | undefined;
167
198
  readonly stop?: readonly string[] | undefined;
168
199
  }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>)[];
169
- export declare const configure: (input?: LanguageModelOptions) => {
200
+ export declare const configure: (input?: Config) => {
170
201
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
171
202
  model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, {
172
203
  endpoint: import("../route/client.js").CompactOperation;
@@ -192,8 +223,8 @@ export declare const provider: {
192
223
  video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/xai-video.js").XAIVideoOptions>;
193
224
  configure: typeof configure;
194
225
  };
195
- export declare const model: ProviderPackage.Definition<Settings, XAIProviderOptionsInput, typeof responsesRoute.compact>["model"];
196
- export declare const imageModel: (modelID: string, settings: Settings) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
226
+ export declare const model: ProviderPackage.Model<Settings, XAIProviderOptionsInput, typeof responsesRoute.compact>;
227
+ export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
197
228
  export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, {
198
229
  endpoint: import("../route/client.js").CompactOperation;
199
230
  }>;
@@ -78,7 +78,7 @@ export const imageModel = (modelID, settings) => {
78
78
  const input = config(settings);
79
79
  return configure(input).image(modelID, input.providerOptions);
80
80
  };
81
- function config({ apiKey, baseURL, body, headers, ...providerOptions }) {
81
+ function config({ apiKey, baseURL, body, headers, ...providerOptions } = {}) {
82
82
  return {
83
83
  apiKey,
84
84
  baseURL,
@@ -1,4 +1,4 @@
1
1
  import type { ProviderPackage } from "../../provider-package.js";
2
2
  import { ZAICodingPlan } from "../zai-coding-plan.js";
3
3
  export type Settings = ZAICodingPlan.Settings<ZAICodingPlan.MessagesOptionsInput>;
4
- export declare const model: ProviderPackage.Definition<Settings, ZAICodingPlan.MessagesOptionsInput>["model"];
4
+ export declare const model: ProviderPackage.Model<Settings, ZAICodingPlan.MessagesOptionsInput>;
@@ -1,5 +1,5 @@
1
1
  import { ZAICodingPlan } from "../zai-coding-plan.js";
2
- export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => ZAICodingPlan.configure({
2
+ export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions } = {}) => ZAICodingPlan.configure({
3
3
  apiKey,
4
4
  baseURL,
5
5
  headers,
@@ -1,4 +1,4 @@
1
1
  import type { ProviderPackage } from "../../provider-package.js";
2
2
  import { ZAICodingPlan } from "../zai-coding-plan.js";
3
3
  export type Settings = ZAICodingPlan.Settings<ZAICodingPlan.ResponsesOptionsInput>;
4
- export declare const model: ProviderPackage.Definition<Settings, ZAICodingPlan.ResponsesOptionsInput>["model"];
4
+ export declare const model: ProviderPackage.Model<Settings, ZAICodingPlan.ResponsesOptionsInput>;
@@ -1,5 +1,5 @@
1
1
  import { ZAICodingPlan } from "../zai-coding-plan.js";
2
- export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => ZAICodingPlan.configure({
2
+ export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions } = {}) => ZAICodingPlan.configure({
3
3
  apiKey,
4
4
  baseURL,
5
5
  headers,
@@ -35,7 +35,7 @@ export declare const routes: (Route<{
35
35
  readonly role: "developer";
36
36
  readonly content: string;
37
37
  } | {
38
- readonly type: "function_call_output";
38
+ readonly type: "custom_tool_call_output" | "function_call_output";
39
39
  readonly call_id: string;
40
40
  readonly output: string | readonly ({
41
41
  readonly type: "input_text";
@@ -105,6 +105,12 @@ export declare const routes: (Route<{
105
105
  readonly name: string;
106
106
  readonly namespace?: string | undefined;
107
107
  readonly arguments: string;
108
+ } | {
109
+ readonly type: "custom_tool_call";
110
+ readonly id?: string | undefined;
111
+ readonly call_id: string;
112
+ readonly name: string;
113
+ readonly input: string;
108
114
  } | {
109
115
  readonly [x: string]: unknown;
110
116
  readonly type: "web_search_call";
@@ -149,6 +155,17 @@ export declare const routes: (Route<{
149
155
  })[];
150
156
  readonly instructions?: string | undefined;
151
157
  readonly tools?: readonly ({
158
+ readonly type: "custom";
159
+ readonly name: string;
160
+ readonly description: string;
161
+ readonly format: {
162
+ readonly type: "text";
163
+ } | {
164
+ readonly type: "grammar";
165
+ readonly syntax: "lark" | "regex";
166
+ readonly definition: string;
167
+ };
168
+ } | {
152
169
  readonly type: "function";
153
170
  readonly name: string;
154
171
  readonly description: string;
@@ -161,13 +178,13 @@ export declare const routes: (Route<{
161
178
  readonly type: string;
162
179
  })[] | undefined;
163
180
  readonly tool_choice?: "auto" | "none" | "required" | {
164
- readonly type: "function";
181
+ readonly type: "custom" | "function";
165
182
  readonly name: string;
166
183
  } | {
167
184
  readonly type: "allowed_tools";
168
185
  readonly mode: "auto" | "none" | "required";
169
186
  readonly tools: readonly {
170
- readonly type: "function";
187
+ readonly type: "custom" | "function";
171
188
  readonly name: string;
172
189
  }[];
173
190
  } | undefined;
@@ -275,7 +292,14 @@ export declare const routes: (Route<{
275
292
  readonly ttl?: string | undefined;
276
293
  } | undefined;
277
294
  }[] | null;
278
- readonly tool_calls?: readonly {
295
+ readonly tool_calls?: readonly ({
296
+ readonly id: string;
297
+ readonly type: "custom";
298
+ readonly custom: {
299
+ readonly name: string;
300
+ readonly input: string;
301
+ };
302
+ } | {
279
303
  readonly id: string;
280
304
  readonly type: "function";
281
305
  readonly function: {
@@ -287,13 +311,13 @@ export declare const routes: (Route<{
287
311
  readonly thought_signature: string;
288
312
  };
289
313
  } | undefined;
290
- }[] | undefined;
314
+ })[] | undefined;
291
315
  readonly reasoning_content?: string | undefined;
292
316
  readonly reasoning?: string | undefined;
293
317
  readonly reasoning_text?: string | undefined;
294
318
  readonly reasoning_details?: unknown;
295
319
  })[];
296
- readonly tools?: readonly {
320
+ readonly tools?: readonly ({
297
321
  readonly type: "function";
298
322
  readonly function: {
299
323
  readonly name: string;
@@ -307,12 +331,36 @@ export declare const routes: (Route<{
307
331
  readonly type: "ephemeral";
308
332
  readonly ttl?: string | undefined;
309
333
  } | undefined;
310
- }[] | undefined;
334
+ } | {
335
+ readonly type: "custom";
336
+ readonly custom: {
337
+ readonly name: string;
338
+ readonly description: string;
339
+ readonly format: {
340
+ readonly type: "text";
341
+ } | {
342
+ readonly type: "grammar";
343
+ readonly grammar: {
344
+ readonly syntax: "lark" | "regex";
345
+ readonly definition: string;
346
+ };
347
+ };
348
+ };
349
+ readonly cache_control?: {
350
+ readonly type: "ephemeral";
351
+ readonly ttl?: string | undefined;
352
+ } | undefined;
353
+ })[] | undefined;
311
354
  readonly tool_choice?: "auto" | "none" | "required" | {
312
355
  readonly type: "function";
313
356
  readonly function: {
314
357
  readonly name: string;
315
358
  };
359
+ } | {
360
+ readonly type: "custom";
361
+ readonly custom: {
362
+ readonly name: string;
363
+ };
316
364
  } | undefined;
317
365
  readonly stream: true;
318
366
  readonly stream_options?: {
@@ -745,5 +793,5 @@ export declare const messages: (modelID: string | ModelID) => import("../schema/
745
793
  } | undefined;
746
794
  }, import("../route/client.js").CompactionOperations | undefined>;
747
795
  export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
748
- export declare const model: ProviderPackage.Definition<Settings, ChatOptionsInput>["model"];
796
+ export declare const model: ProviderPackage.Model<Settings, ChatOptionsInput>;
749
797
  export * as ZAICodingPlan from "./zai-coding-plan.js";
@@ -53,7 +53,7 @@ export const provider = configure();
53
53
  export const chat = provider.chat;
54
54
  export const messages = provider.messages;
55
55
  export const responses = provider.responses;
56
- export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
56
+ export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions } = {}) => configure({
57
57
  apiKey,
58
58
  baseURL,
59
59
  headers,
@@ -90,7 +90,14 @@ export declare const routes: Route<{
90
90
  readonly ttl?: string | undefined;
91
91
  } | undefined;
92
92
  }[] | null;
93
- readonly tool_calls?: readonly {
93
+ readonly tool_calls?: readonly ({
94
+ readonly id: string;
95
+ readonly type: "custom";
96
+ readonly custom: {
97
+ readonly name: string;
98
+ readonly input: string;
99
+ };
100
+ } | {
94
101
  readonly id: string;
95
102
  readonly type: "function";
96
103
  readonly function: {
@@ -102,13 +109,13 @@ export declare const routes: Route<{
102
109
  readonly thought_signature: string;
103
110
  };
104
111
  } | undefined;
105
- }[] | undefined;
112
+ })[] | undefined;
106
113
  readonly reasoning_content?: string | undefined;
107
114
  readonly reasoning?: string | undefined;
108
115
  readonly reasoning_text?: string | undefined;
109
116
  readonly reasoning_details?: unknown;
110
117
  })[];
111
- readonly tools?: readonly {
118
+ readonly tools?: readonly ({
112
119
  readonly type: "function";
113
120
  readonly function: {
114
121
  readonly name: string;
@@ -122,12 +129,36 @@ export declare const routes: Route<{
122
129
  readonly type: "ephemeral";
123
130
  readonly ttl?: string | undefined;
124
131
  } | undefined;
125
- }[] | undefined;
132
+ } | {
133
+ readonly type: "custom";
134
+ readonly custom: {
135
+ readonly name: string;
136
+ readonly description: string;
137
+ readonly format: {
138
+ readonly type: "text";
139
+ } | {
140
+ readonly type: "grammar";
141
+ readonly grammar: {
142
+ readonly syntax: "lark" | "regex";
143
+ readonly definition: string;
144
+ };
145
+ };
146
+ };
147
+ readonly cache_control?: {
148
+ readonly type: "ephemeral";
149
+ readonly ttl?: string | undefined;
150
+ } | undefined;
151
+ })[] | undefined;
126
152
  readonly tool_choice?: "auto" | "none" | "required" | {
127
153
  readonly type: "function";
128
154
  readonly function: {
129
155
  readonly name: string;
130
156
  };
157
+ } | {
158
+ readonly type: "custom";
159
+ readonly custom: {
160
+ readonly name: string;
161
+ };
131
162
  } | undefined;
132
163
  readonly stream: true;
133
164
  readonly stream_options?: {
@@ -248,6 +279,6 @@ export declare const chat: (modelID: string | ModelID) => import("../schema/opti
248
279
  readonly requestID?: string | undefined;
249
280
  readonly userID?: string | undefined;
250
281
  }, import("../route/client.js").CompactionOperations | undefined>;
251
- export declare const model: ProviderPackage.Definition<Settings, ChatOptionsInput>["model"];
252
- export declare const imageModel: (modelID: string, settings: Settings) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
282
+ export declare const model: ProviderPackage.Model<Settings, ChatOptionsInput>;
283
+ export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("./zai.js").ZAIImageOptions>;
253
284
  export * as ZAI from "./zai.js";
@@ -44,7 +44,7 @@ export const imageModel = (modelID, settings) => {
44
44
  const input = config(settings);
45
45
  return configure(input).image(modelID, input.providerOptions);
46
46
  };
47
- function config({ apiKey, baseURL, body, headers, ...providerOptions }) {
47
+ function config({ apiKey, baseURL, body, headers, ...providerOptions } = {}) {
48
48
  return {
49
49
  apiKey,
50
50
  baseURL,
@@ -45,7 +45,7 @@ export declare function header(name: string): (source: Secret | Credential) => D
45
45
  export declare function header(name: string, source: Secret | Credential): Definition;
46
46
  export declare function bearerHeader(name: string): (source: Secret | Credential) => Definition;
47
47
  export declare function bearerHeader(name: string, source: Secret | Credential): Definition;
48
- /** `Authorization: <scheme> <secret>` for providers whose scheme is not `Bearer`, such as fal's `Key`. */
48
+ /** `Authorization: <scheme> <secret>` for providers whose scheme is not `Bearer`, such as Deepgram's `Token`. */
49
49
  export declare function scheme(name: string): (source: Secret | Credential) => Definition;
50
50
  export declare function scheme(name: string, source: Secret | Credential): Definition;
51
51
  export declare const toEffect: (input: Definition) => (authInput: AuthInput) => Effect.Effect<Headers.Headers, AIError>;
@@ -52,18 +52,16 @@ export interface Started<Token> {
52
52
  }
53
53
  /**
54
54
  * A follow-up call's inputs: the decoded token and the auth headers the route sent, so a protocol can attach them
55
- * to output URLs that require the same credentials to download (Veo). `materialize` downloads an output through the
56
- * route's executor, for URLs that expire too soon to hand back (BFL).
55
+ * to output URLs that require the same credentials to download (Veo).
57
56
  */
58
57
  export interface PollContext<Token> {
59
58
  readonly token: Token;
60
59
  readonly auth: Record<string, string>;
61
- readonly materialize: (asset: Media.Asset) => Effect.Effect<Media.Asset, AIError>;
62
60
  }
63
61
  /**
64
62
  * Submit, then poll. `start` posts the body to the route endpoint; `status`, `result`, and `cancel` are follow-up
65
63
  * calls addressed by the token. Paths are relative to the route base URL unless the provider hands back absolute
66
- * URLs (fal `status_url`), in which case they are used verbatim. `result` is always its own GET: providers that
64
+ * URLs, in which case they are used verbatim. `result` is always its own GET: providers that
67
65
  * return the output inside the status body (Veo, xAI, Runway) point `result.path` at the status path and decode the
68
66
  * same document, so `Generation.await` and `Video.resume(...).await()` behave identically everywhere.
69
67
  */
@@ -1,7 +1,7 @@
1
1
  import { Effect, Stream } from "effect";
2
2
  import { Auth } from "./auth.js";
3
3
  import { Endpoint } from "./endpoint.js";
4
- import { type Interface } from "./executor-service.js";
4
+ import type { Interface } from "./executor-service.js";
5
5
  import { MediaProtocol } from "./media-protocol.js";
6
6
  import { Generation } from "../generation.js";
7
7
  import { AIError, HttpOptions, ProviderID, type ProviderOptions } from "../schema/index.js";
@@ -2,7 +2,6 @@ import { Duration, Effect, Schedule, Schema, Stream } from "effect";
2
2
  import { Headers, HttpClientRequest } from "effect/http";
3
3
  import { Auth } from "./auth.js";
4
4
  import { Endpoint } from "./endpoint.js";
5
- import { RequestExecutorService } from "./executor-service.js";
6
5
  import { RequestExecutor } from "./executor.js";
7
6
  import { MediaProtocol } from "./media-protocol.js";
8
7
  import { Generation, isTerminal } from "../generation.js";
@@ -61,10 +60,9 @@ export const queued = (input) => {
61
60
  // A protocol producing a token its own codec rejects is a programmer defect, not a provider error.
62
61
  const encodeToken = Schema.encodeSync(protocol.token);
63
62
  const generationRoute = (token, http, execute) => {
64
- const materialize = (asset) => asset.materialize().pipe(Effect.provideService(RequestExecutorService, { execute }));
65
63
  // Only the GET exchange retries: a decoded terminal failure (`output.ended`) can be a `ProviderInternal` too, and
66
64
  // re-reading it would spin until the caller's deadline.
67
- const poll = (operation) => transport.call("GET", operation.path(token), http, execute).pipe(Effect.retry({ schedule: READ_RETRY, while: isRetryable }), Effect.flatMap((sent) => operation.decode(sent.response, { token, auth: sent.auth, materialize })));
65
+ const poll = (operation) => transport.call("GET", operation.path(token), http, execute).pipe(Effect.retry({ schedule: READ_RETRY, while: isRetryable }), Effect.flatMap((sent) => operation.decode(sent.response, { token, auth: sent.auth })));
68
66
  const status = poll(protocol.status);
69
67
  const cancel = protocol.cancel;
70
68
  const send = cancel === undefined
@@ -178,7 +176,7 @@ const makeTransport = (input) => {
178
176
  }),
179
177
  /** Bodiless follow-up call (status, result, cancel) with the same auth and headers as `submit`. */
180
178
  call: (method, path, http, execute) => {
181
- // Provider-issued absolute URLs (fal `status_url`) are used as-is; everything else resolves against the base.
179
+ // Provider-issued absolute URLs are used as-is; everything else resolves against the base.
182
180
  const url = withQuery(/^https?:\/\//.test(path) ? new URL(path) : baseURL(path), http?.query);
183
181
  for (const [key, value] of Object.entries(input.endpoint.query ?? {}))
184
182
  url.searchParams.set(key, value);
@@ -912,6 +912,7 @@ export declare const LLMEvent: Schema.Union<readonly [Schema.refine<{
912
912
  readonly type: Schema.tag<"raw">;
913
913
  readonly data: Schema.Unknown;
914
914
  }>]> & {
915
+ readonly tag: "type";
915
916
  readonly discriminants: readonly ["compaction", "step-start", "text-start", "text-delta", "text-end", "reasoning-start", "reasoning-delta", "reasoning-end", "tool-input-start", "tool-input-delta", "tool-input-end", "tool-input-error", "tool-call", "tool-result", "tool-error", "media", "step-finish", "finish", "provider-error", "raw"];
916
917
  readonly cases: {
917
918
  compaction: Schema.refine<{
@@ -4933,6 +4934,7 @@ declare const LLMResponse_base: Schema.Class<LLMResponse, Schema.Struct<{
4933
4934
  readonly type: Schema.tag<"raw">;
4934
4935
  readonly data: Schema.Unknown;
4935
4936
  }>]> & {
4937
+ readonly tag: "type";
4936
4938
  readonly discriminants: readonly ["compaction", "step-start", "text-start", "text-delta", "text-end", "reasoning-start", "reasoning-delta", "reasoning-end", "tool-input-start", "tool-input-delta", "tool-input-end", "tool-input-error", "tool-call", "tool-result", "tool-error", "media", "step-finish", "finish", "provider-error", "raw"];
4937
4939
  readonly cases: {
4938
4940
  compaction: Schema.refine<{
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  import { Tool } from "@opencode/schema/tool";
3
- import { CacheHint, GenerationOptions, HttpOptions, type LanguageModel, ReasoningEffort } from "./options.js";
3
+ import { CacheHint, GenerationOptions, HttpOptions, JsonSchema, type LanguageModel, ReasoningEffort } from "./options.js";
4
4
  import { Media } from "../media.js";
5
5
  export declare const MessageRole: Schema.Literals<readonly ["system", "user", "assistant", "tool"]>;
6
6
  export type MessageRole = Schema.Schema.Type<typeof MessageRole>;
@@ -598,11 +598,34 @@ export declare namespace Message {
598
598
  }) => Message;
599
599
  const tool: (result: ToolResultPart | Parameters<typeof ToolResultPart.make>[0]) => Message;
600
600
  }
601
+ /**
602
+ * Raw-text wire encoding for a tool with exactly one required string parameter. Models that accept the format
603
+ * write that parameter's value directly instead of JSON arguments; calls still decode to the normal object input.
604
+ */
605
+ export declare const Freeform: Schema.Union<readonly [Schema.Struct<{
606
+ readonly type: Schema.Literal<"text">;
607
+ }>, Schema.Struct<{
608
+ readonly type: Schema.Literal<"regex">;
609
+ readonly pattern: Schema.String;
610
+ }>, Schema.Struct<{
611
+ readonly type: Schema.Literal<"lark">;
612
+ readonly grammar: Schema.String;
613
+ }>]>;
614
+ export type Freeform = Schema.Schema.Type<typeof Freeform>;
601
615
  declare const toolDefinitionFields: {
602
616
  name: Schema.String;
603
617
  description: Schema.String;
604
618
  inputSchema: Schema.$Record<Schema.String, Schema.Unknown>;
605
619
  outputSchema: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
620
+ freeform: Schema.optional<Schema.Union<readonly [Schema.Struct<{
621
+ readonly type: Schema.Literal<"text">;
622
+ }>, Schema.Struct<{
623
+ readonly type: Schema.Literal<"regex">;
624
+ readonly pattern: Schema.String;
625
+ }>, Schema.Struct<{
626
+ readonly type: Schema.Literal<"lark">;
627
+ readonly grammar: Schema.String;
628
+ }>]>>;
606
629
  cache: Schema.optional<typeof CacheHint>;
607
630
  metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
608
631
  native: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
@@ -613,6 +636,15 @@ declare const ToolDefinition_base: Schema.Class<ToolDefinition, Schema.Struct<{
613
636
  readonly description: Schema.String;
614
637
  readonly inputSchema: Schema.$Record<Schema.String, Schema.Unknown>;
615
638
  readonly outputSchema: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
639
+ readonly freeform: Schema.optional<Schema.Union<readonly [Schema.Struct<{
640
+ readonly type: Schema.Literal<"text">;
641
+ }>, Schema.Struct<{
642
+ readonly type: Schema.Literal<"regex">;
643
+ readonly pattern: Schema.String;
644
+ }>, Schema.Struct<{
645
+ readonly type: Schema.Literal<"lark">;
646
+ readonly grammar: Schema.String;
647
+ }>]>>;
616
648
  readonly cache: Schema.optional<typeof CacheHint>;
617
649
  readonly metadata: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
618
650
  readonly native: Schema.optional<Schema.$Record<Schema.String, Schema.Unknown>>;
@@ -625,6 +657,8 @@ export declare namespace ToolDefinition {
625
657
  type Input = ToolDefinition | ToolDefinitionInput;
626
658
  /** Normalize tool definition input into the canonical `ToolDefinition` class. */
627
659
  const make: (input: Input) => ToolDefinition;
660
+ /** The parameter a freeform call fills: the input schema's only property, when it is a required string. */
661
+ const freeformField: (schema: JsonSchema) => string | undefined;
628
662
  }
629
663
  export type ToolNamespace = {
630
664
  readonly type: "namespace";
@@ -202,11 +202,21 @@ export class Message extends Schema.Class("LLM.Message")({
202
202
  Message.effort = (input) => Message.make({ role: "system", content: [{ type: "effort", effort: input.effort, previous: input.previous }] });
203
203
  Message.tool = (result) => Message.make({ role: "tool", content: ["type" in result ? result : ToolResultPart.make(result)] });
204
204
  })(Message || (Message = {}));
205
+ /**
206
+ * Raw-text wire encoding for a tool with exactly one required string parameter. Models that accept the format
207
+ * write that parameter's value directly instead of JSON arguments; calls still decode to the normal object input.
208
+ */
209
+ export const Freeform = Schema.Union([
210
+ Schema.Struct({ type: Schema.Literal("text") }),
211
+ Schema.Struct({ type: Schema.Literal("regex"), pattern: Schema.String }),
212
+ Schema.Struct({ type: Schema.Literal("lark"), grammar: Schema.String }),
213
+ ]).annotate({ identifier: "LLM.Freeform" });
205
214
  const toolDefinitionFields = {
206
215
  name: Schema.String,
207
216
  description: Schema.String,
208
217
  inputSchema: JsonSchema,
209
218
  outputSchema: Schema.optional(JsonSchema),
219
+ freeform: Schema.optional(Freeform),
210
220
  cache: Schema.optional(CacheHint),
211
221
  metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
212
222
  native: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
@@ -222,6 +232,16 @@ export class ToolDefinition extends Schema.Class("LLM.ToolDefinition")({
222
232
  (function (ToolDefinition) {
223
233
  /** Normalize tool definition input into the canonical `ToolDefinition` class. */
224
234
  ToolDefinition.make = (input) => (input instanceof ToolDefinition ? input : new ToolDefinition(input));
235
+ /** The parameter a freeform call fills: the input schema's only property, when it is a required string. */
236
+ ToolDefinition.freeformField = (schema) => {
237
+ const properties = Object.entries(Schema.is(JsonSchema)(schema.properties) ? schema.properties : {});
238
+ if (properties.length !== 1)
239
+ return undefined;
240
+ const [name, property] = properties[0];
241
+ if (!Schema.is(JsonSchema)(property) || property.type !== "string")
242
+ return undefined;
243
+ return Array.isArray(schema.required) && schema.required.includes(name) ? name : undefined;
244
+ };
225
245
  })(ToolDefinition || (ToolDefinition = {}));
226
246
  export const ToolNamespace = withStatics(Schema.Struct({
227
247
  type: Schema.Literal("namespace"),