@opencode/ai 0.0.0-dev-20498 → 0.0.0-dev-20501

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 (53) hide show
  1. package/README.md +25 -0
  2. package/dist/protocols/alibaba-chat.d.ts +3 -3
  3. package/dist/protocols/alibaba-responses.d.ts +16 -12
  4. package/dist/protocols/alibaba-responses.js +3 -5
  5. package/dist/protocols/google-interactions.d.ts +236 -0
  6. package/dist/protocols/google-interactions.js +478 -0
  7. package/dist/protocols/index.d.ts +1 -0
  8. package/dist/protocols/index.js +1 -0
  9. package/dist/protocols/meta-responses.d.ts +31 -58
  10. package/dist/protocols/meta-responses.js +5 -24
  11. package/dist/protocols/mistral-chat.d.ts +1 -1
  12. package/dist/protocols/open-responses.d.ts +406 -91
  13. package/dist/protocols/open-responses.js +12 -6
  14. package/dist/protocols/openai-chat.d.ts +5 -5
  15. package/dist/protocols/openai-compatible-chat.d.ts +1 -1
  16. package/dist/protocols/openai-compatible-responses.d.ts +16 -4
  17. package/dist/protocols/openai-responses.d.ts +87 -223
  18. package/dist/protocols/openai-responses.js +3 -10
  19. package/dist/protocols/xai-responses.d.ts +18 -21
  20. package/dist/protocols/xai-responses.js +2 -8
  21. package/dist/protocols/zai-chat.d.ts +3 -3
  22. package/dist/providers/alibaba.d.ts +17 -13
  23. package/dist/providers/amazon-bedrock-mantle.d.ts +17 -5
  24. package/dist/providers/azure.d.ts +13 -61
  25. package/dist/providers/baseten.d.ts +2 -2
  26. package/dist/providers/cerebras.d.ts +2 -2
  27. package/dist/providers/cloudflare-ai-gateway.d.ts +14 -62
  28. package/dist/providers/cloudflare-workers-ai.d.ts +2 -2
  29. package/dist/providers/cohere.d.ts +2 -2
  30. package/dist/providers/deepinfra.d.ts +2 -2
  31. package/dist/providers/deepseek.d.ts +2 -2
  32. package/dist/providers/digitalocean.d.ts +5 -5
  33. package/dist/providers/fireworks.d.ts +2 -2
  34. package/dist/providers/google/interactions.d.ts +7 -0
  35. package/dist/providers/google/interactions.js +8 -0
  36. package/dist/providers/google-vertex-chat.d.ts +1 -1
  37. package/dist/providers/google-vertex-responses.d.ts +16 -4
  38. package/dist/providers/google.d.ts +94 -3
  39. package/dist/providers/google.js +8 -1
  40. package/dist/providers/groq.d.ts +4 -4
  41. package/dist/providers/meta.d.ts +15 -28
  42. package/dist/providers/minimax.d.ts +17 -5
  43. package/dist/providers/moonshot.d.ts +17 -5
  44. package/dist/providers/openai-compatible-responses.d.ts +16 -4
  45. package/dist/providers/openai-compatible.d.ts +1 -1
  46. package/dist/providers/openai.d.ts +7 -31
  47. package/dist/providers/openrouter.d.ts +5 -5
  48. package/dist/providers/togetherai.d.ts +2 -2
  49. package/dist/providers/xai.d.ts +1 -1
  50. package/dist/providers/zai-coding-plan.d.ts +17 -5
  51. package/dist/providers/zai.d.ts +1 -1
  52. package/dist/route/client.js +2 -5
  53. package/package.json +3 -3
@@ -1,6 +1,5 @@
1
1
  import { Schema } from "effect";
2
2
  import { Protocol } from "../route/protocol.js";
3
- import { HttpTransport } from "../route/transport/index.js";
4
3
  import { OpenResponses } from "./open-responses.js";
5
4
  export declare const WebSearch: Schema.Struct<{
6
5
  readonly type: Schema.Literal<"web_search">;
@@ -63,6 +62,15 @@ export declare const protocol: Protocol<{
63
62
  readonly error?: unknown;
64
63
  readonly arguments?: string | undefined;
65
64
  readonly server_label?: string | undefined;
65
+ } | {
66
+ readonly type: "configuration_update";
67
+ readonly reasoning: {
68
+ readonly effort: import("../schema/options.js").ReasoningEffort;
69
+ };
70
+ } | {
71
+ readonly [x: string]: unknown;
72
+ readonly type: string;
73
+ readonly id: string;
66
74
  } | {
67
75
  readonly type: "reasoning";
68
76
  readonly summary: readonly {
@@ -139,13 +147,6 @@ export declare const protocol: Protocol<{
139
147
  readonly type: "input_video";
140
148
  readonly video_url: string;
141
149
  })[];
142
- } | {
143
- readonly id: string;
144
- readonly type: "image_generation_call";
145
- readonly status?: string | undefined;
146
- readonly error?: unknown;
147
- readonly result?: string | null | undefined;
148
- readonly output_format?: string | undefined;
149
150
  })[];
150
151
  readonly model: string;
151
152
  readonly stream: true;
@@ -158,6 +159,9 @@ export declare const protocol: Protocol<{
158
159
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
159
160
  } | undefined;
160
161
  readonly tools?: readonly ({
162
+ readonly [x: string]: unknown;
163
+ readonly type: string;
164
+ } | {
161
165
  readonly type: "function";
162
166
  readonly description: string;
163
167
  readonly name: string;
@@ -165,24 +169,6 @@ export declare const protocol: Protocol<{
165
169
  readonly [x: string]: unknown;
166
170
  };
167
171
  readonly strict?: boolean | undefined;
168
- } | {
169
- readonly type: "web_search";
170
- readonly search_context_size?: string | undefined;
171
- readonly user_location?: {
172
- readonly type: "approximate";
173
- readonly region?: string | undefined;
174
- readonly city?: string | undefined;
175
- readonly country?: string | undefined;
176
- readonly timezone?: string | undefined;
177
- } | undefined;
178
- } | {
179
- readonly type: "image_generation";
180
- readonly size?: string | undefined;
181
- readonly output_format?: string | undefined;
182
- readonly reasoning_strength?: string | undefined;
183
- readonly enable_image_search?: boolean | undefined;
184
- readonly enable_web_search?: boolean | undefined;
185
- readonly enable_shell?: boolean | undefined;
186
172
  })[] | undefined;
187
173
  readonly text?: {
188
174
  readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
@@ -203,9 +189,10 @@ export declare const protocol: Protocol<{
203
189
  readonly top_p?: number | undefined;
204
190
  readonly frequency_penalty?: number | undefined;
205
191
  readonly presence_penalty?: number | undefined;
192
+ readonly store?: boolean | undefined;
193
+ readonly max_output_tokens?: number | undefined;
206
194
  readonly prompt_cache_key?: string | undefined;
207
195
  readonly parallel_tool_calls?: boolean | undefined;
208
- readonly store?: boolean | undefined;
209
196
  readonly include?: readonly import("./utils/open-responses-options.js").ResponseIncludable[] | undefined;
210
197
  readonly truncation?: "auto" | "disabled" | undefined;
211
198
  readonly stream_options?: {
@@ -213,7 +200,6 @@ export declare const protocol: Protocol<{
213
200
  } | undefined;
214
201
  readonly safety_identifier?: string | undefined;
215
202
  readonly top_logprobs?: number | undefined;
216
- readonly max_output_tokens?: number | undefined;
217
203
  readonly max_tool_calls?: number | undefined;
218
204
  }, string, {
219
205
  readonly [x: string]: unknown;
@@ -233,8 +219,8 @@ export declare const protocol: Protocol<{
233
219
  readonly name?: string | undefined;
234
220
  readonly namespace?: string | undefined;
235
221
  readonly arguments?: string | undefined;
236
- readonly encrypted_content?: string | null | undefined;
237
222
  readonly call_id?: string | undefined;
223
+ readonly encrypted_content?: string | null | undefined;
238
224
  }[] | undefined;
239
225
  readonly error?: unknown;
240
226
  readonly usage?: {
@@ -261,8 +247,8 @@ export declare const protocol: Protocol<{
261
247
  readonly name?: string | undefined;
262
248
  readonly namespace?: string | undefined;
263
249
  readonly arguments?: string | undefined;
264
- readonly encrypted_content?: string | null | undefined;
265
250
  readonly call_id?: string | undefined;
251
+ readonly encrypted_content?: string | null | undefined;
266
252
  } | null | undefined;
267
253
  readonly delta?: string | undefined;
268
254
  readonly arguments?: string | undefined;
@@ -271,7 +257,7 @@ export declare const protocol: Protocol<{
271
257
  readonly summary_index?: number | undefined;
272
258
  readonly status_code?: unknown;
273
259
  }, ParserState>;
274
- export declare const httpTransport: HttpTransport.HttpJsonTransport<{
260
+ export declare const httpTransport: import("../route/transport/http.js").HttpJsonTransport<{
275
261
  readonly input: readonly ({
276
262
  readonly [x: string]: unknown;
277
263
  readonly id: string;
@@ -309,6 +295,15 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
309
295
  readonly error?: unknown;
310
296
  readonly arguments?: string | undefined;
311
297
  readonly server_label?: string | undefined;
298
+ } | {
299
+ readonly type: "configuration_update";
300
+ readonly reasoning: {
301
+ readonly effort: import("../schema/options.js").ReasoningEffort;
302
+ };
303
+ } | {
304
+ readonly [x: string]: unknown;
305
+ readonly type: string;
306
+ readonly id: string;
312
307
  } | {
313
308
  readonly type: "reasoning";
314
309
  readonly summary: readonly {
@@ -385,13 +380,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
385
380
  readonly type: "input_video";
386
381
  readonly video_url: string;
387
382
  })[];
388
- } | {
389
- readonly id: string;
390
- readonly type: "image_generation_call";
391
- readonly status?: string | undefined;
392
- readonly error?: unknown;
393
- readonly result?: string | null | undefined;
394
- readonly output_format?: string | undefined;
395
383
  })[];
396
384
  readonly model: string;
397
385
  readonly stream: true;
@@ -404,6 +392,9 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
404
392
  readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
405
393
  } | undefined;
406
394
  readonly tools?: readonly ({
395
+ readonly [x: string]: unknown;
396
+ readonly type: string;
397
+ } | {
407
398
  readonly type: "function";
408
399
  readonly description: string;
409
400
  readonly name: string;
@@ -411,24 +402,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
411
402
  readonly [x: string]: unknown;
412
403
  };
413
404
  readonly strict?: boolean | undefined;
414
- } | {
415
- readonly type: "web_search";
416
- readonly search_context_size?: string | undefined;
417
- readonly user_location?: {
418
- readonly type: "approximate";
419
- readonly region?: string | undefined;
420
- readonly city?: string | undefined;
421
- readonly country?: string | undefined;
422
- readonly timezone?: string | undefined;
423
- } | undefined;
424
- } | {
425
- readonly type: "image_generation";
426
- readonly size?: string | undefined;
427
- readonly output_format?: string | undefined;
428
- readonly reasoning_strength?: string | undefined;
429
- readonly enable_image_search?: boolean | undefined;
430
- readonly enable_web_search?: boolean | undefined;
431
- readonly enable_shell?: boolean | undefined;
432
405
  })[] | undefined;
433
406
  readonly text?: {
434
407
  readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
@@ -449,9 +422,10 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
449
422
  readonly top_p?: number | undefined;
450
423
  readonly frequency_penalty?: number | undefined;
451
424
  readonly presence_penalty?: number | undefined;
425
+ readonly store?: boolean | undefined;
426
+ readonly max_output_tokens?: number | undefined;
452
427
  readonly prompt_cache_key?: string | undefined;
453
428
  readonly parallel_tool_calls?: boolean | undefined;
454
- readonly store?: boolean | undefined;
455
429
  readonly include?: readonly import("./utils/open-responses-options.js").ResponseIncludable[] | undefined;
456
430
  readonly truncation?: "auto" | "disabled" | undefined;
457
431
  readonly stream_options?: {
@@ -459,7 +433,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
459
433
  } | undefined;
460
434
  readonly safety_identifier?: string | undefined;
461
435
  readonly top_logprobs?: number | undefined;
462
- readonly max_output_tokens?: number | undefined;
463
436
  readonly max_tool_calls?: number | undefined;
464
437
  }, string>;
465
438
  export * as MetaResponses from "./meta-responses.js";
@@ -1,6 +1,5 @@
1
1
  import { Effect, Encoding, Schema } from "effect";
2
2
  import { Protocol } from "../route/protocol.js";
3
- import { HttpTransport } from "../route/transport/index.js";
4
3
  import { LLMEvent, LLMRequest, Message, ToolResultPart } from "../schema/index.js";
5
4
  import { OpenResponses } from "./open-responses.js";
6
5
  import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
@@ -37,23 +36,18 @@ const ImageItem = Schema.Struct({
37
36
  output_format: Schema.optional(Schema.String),
38
37
  error: Schema.optional(Schema.Unknown),
39
38
  });
40
- const Body = Schema.Struct({
41
- ...OpenResponses.coreFields,
42
- input: Schema.Array(Schema.Union([OpenResponses.InputItem, ImageItem])),
43
- tools: optionalArray(Schema.Union([OpenResponses.Tool, NativeTool])),
44
- stream: Schema.Literal(true),
45
- });
46
39
  const MessageAnnotations = Schema.Struct({
47
40
  content: Schema.Array(Schema.Struct({ annotations: optionalArray(JsonObject) })),
48
41
  });
49
42
  const adapter = {
50
43
  id: ADAPTER,
51
44
  name: NAME,
45
+ nativeTool: (native) => ProviderShared.validateWith(Schema.decodeUnknownEffect(NativeTool))(native.meta),
52
46
  restoreHostedToolItem: (item) => (Schema.is(ImageItem)(item) ? item : undefined),
53
47
  };
54
48
  const fromRequest = Effect.fn("MetaResponses.fromRequest")(function* (request) {
55
49
  const key = request.model.route.providerMetadataKey ?? String(request.model.provider);
56
- const projected = ProviderShared.flattenToolRequest(LLMRequest.update(request, {
50
+ return yield* OpenResponses.fromRequestWithAdapter(LLMRequest.update(request, {
57
51
  messages: request.messages.map((message) => Message.make({
58
52
  ...message,
59
53
  content: message.content.map((part) => {
@@ -73,20 +67,7 @@ const fromRequest = Effect.fn("MetaResponses.fromRequest")(function* (request) {
73
67
  });
74
68
  }),
75
69
  })),
76
- }));
77
- return yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Body))({
78
- ...(yield* OpenResponses.lowerConversation(projected.request, adapter)),
79
- ...OpenResponses.lowerGeneration(request),
80
- tools: projected.tools.length === 0
81
- ? undefined
82
- : yield* Effect.forEach(projected.tools, (tool) => Effect.gen(function* () {
83
- if (tool.native === undefined)
84
- return yield* OpenResponses.lowerTool(NAME, tool);
85
- return yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(NativeTool))(tool.native.meta);
86
- })),
87
- tool_choice: OpenResponses.allowedToolChoice(request) ??
88
- (request.toolChoice ? yield* OpenResponses.lowerToolChoice(NAME, request.toolChoice) : undefined),
89
- });
70
+ }), adapter);
90
71
  });
91
72
  const HOSTED_TOOLS = {
92
73
  web_search_call: { name: "web_search", input: (item) => item.action ?? {} },
@@ -163,7 +144,7 @@ const step = Effect.fn("MetaResponses.step")(function* (state, input) {
163
144
  });
164
145
  export const protocol = Protocol.make({
165
146
  id: ADAPTER,
166
- body: { schema: Body, from: fromRequest },
147
+ body: { schema: OpenResponses.OpenResponsesBody, from: fromRequest },
167
148
  stream: {
168
149
  event: OpenResponses.protocol.stream.event,
169
150
  initial: (request) => ({ ...OpenResponses.initial(request, adapter), completedItems: new Set() }),
@@ -171,5 +152,5 @@ export const protocol = Protocol.make({
171
152
  terminal: OpenResponses.terminal,
172
153
  },
173
154
  });
174
- export const httpTransport = HttpTransport.sseJson.with();
155
+ export const httpTransport = OpenResponses.httpTransport;
175
156
  export * as MetaResponses from "./meta-responses.js";
@@ -338,9 +338,9 @@ export declare const protocol: Protocol<{
338
338
  } | null | undefined;
339
339
  readonly usage?: {
340
340
  readonly [x: string]: unknown;
341
+ readonly total_tokens?: number | null | undefined;
341
342
  readonly prompt_tokens?: number | null | undefined;
342
343
  readonly completion_tokens?: number | null | undefined;
343
- readonly total_tokens?: number | null | undefined;
344
344
  readonly num_cached_tokens?: number | null | undefined;
345
345
  readonly prompt_token_details?: {
346
346
  readonly [x: string]: unknown;