@opencode/ai 2.1.3 → 2.1.4

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 (106) hide show
  1. package/dist/experimental/evaluation.js +3 -10
  2. package/dist/image-client.d.ts +8 -8
  3. package/dist/image.d.ts +148 -148
  4. package/dist/promise.d.ts +120 -120
  5. package/dist/protocols/alibaba-chat.d.ts +12 -12
  6. package/dist/protocols/alibaba-messages.d.ts +11 -11
  7. package/dist/protocols/alibaba-responses.d.ts +35 -35
  8. package/dist/protocols/anthropic-messages.d.ts +40 -44
  9. package/dist/protocols/anthropic-messages.js +3 -3
  10. package/dist/protocols/bedrock-converse.d.ts +30 -32
  11. package/dist/protocols/bedrock-converse.js +2 -3
  12. package/dist/protocols/cartesia-speech.d.ts +32 -32
  13. package/dist/protocols/cohere-chat.d.ts +7 -8
  14. package/dist/protocols/deepgram-speech.d.ts +32 -32
  15. package/dist/protocols/elevenlabs-speech.d.ts +32 -32
  16. package/dist/protocols/gemini.d.ts +34 -34
  17. package/dist/protocols/gemini.js +2 -2
  18. package/dist/protocols/google-interactions.d.ts +14 -14
  19. package/dist/protocols/google-interactions.js +2 -2
  20. package/dist/protocols/google-speech.d.ts +32 -32
  21. package/dist/protocols/google-transcription.d.ts +32 -32
  22. package/dist/protocols/meta-messages.d.ts +23 -23
  23. package/dist/protocols/meta-responses.d.ts +78 -78
  24. package/dist/protocols/mistral-chat.d.ts +81 -78
  25. package/dist/protocols/mistral-chat.js +2 -1
  26. package/dist/protocols/open-responses-channel.js +47 -46
  27. package/dist/protocols/open-responses-continuation.d.ts +8 -2
  28. package/dist/protocols/open-responses-continuation.js +3 -1
  29. package/dist/protocols/open-responses.d.ts +398 -398
  30. package/dist/protocols/open-responses.js +8 -7
  31. package/dist/protocols/openai-chat.d.ts +60 -60
  32. package/dist/protocols/openai-chat.js +3 -3
  33. package/dist/protocols/openai-compatible-chat.d.ts +13 -14
  34. package/dist/protocols/openai-compatible-responses.d.ts +36 -37
  35. package/dist/protocols/openai-images.d.ts +32 -32
  36. package/dist/protocols/openai-responses.d.ts +235 -235
  37. package/dist/protocols/openai-responses.js +1 -1
  38. package/dist/protocols/openai-speech.d.ts +32 -32
  39. package/dist/protocols/openai-transcription.d.ts +32 -32
  40. package/dist/protocols/openai-transcription.js +12 -7
  41. package/dist/protocols/utils/partial-json-options.d.ts +0 -1
  42. package/dist/protocols/utils/partial-json-options.js +0 -1
  43. package/dist/protocols/utils/tool-stream.d.ts +1 -1
  44. package/dist/protocols/venice-chat.d.ts +52 -53
  45. package/dist/protocols/venice-chat.js +6 -5
  46. package/dist/protocols/xai-responses.d.ts +78 -78
  47. package/dist/protocols/zai-chat.d.ts +33 -30
  48. package/dist/protocols/zai-chat.js +8 -3
  49. package/dist/protocols/zai-messages.d.ts +21 -19
  50. package/dist/protocols/zai-messages.js +3 -2
  51. package/dist/provider-error.js +5 -3
  52. package/dist/providers/alibaba.d.ts +69 -69
  53. package/dist/providers/amazon-bedrock-mantle.d.ts +202 -202
  54. package/dist/providers/amazon-bedrock.d.ts +15 -15
  55. package/dist/providers/anthropic-compatible.d.ts +13 -13
  56. package/dist/providers/anthropic.d.ts +13 -13
  57. package/dist/providers/azure.d.ts +106 -106
  58. package/dist/providers/baseten.d.ts +24 -24
  59. package/dist/providers/cerebras.d.ts +24 -24
  60. package/dist/providers/cloudflare-ai-gateway.d.ts +230 -227
  61. package/dist/providers/cloudflare-ai-gateway.js +1 -2
  62. package/dist/providers/cloudflare-workers-ai.d.ts +24 -24
  63. package/dist/providers/cohere.d.ts +75 -75
  64. package/dist/providers/deepinfra.d.ts +24 -24
  65. package/dist/providers/deepseek.d.ts +24 -24
  66. package/dist/providers/digitalocean.d.ts +36 -36
  67. package/dist/providers/fireworks.d.ts +24 -24
  68. package/dist/providers/google-vertex-chat.d.ts +12 -12
  69. package/dist/providers/google-vertex-messages.d.ts +13 -13
  70. package/dist/providers/google-vertex-mistral.d.ts +17 -17
  71. package/dist/providers/google-vertex-responses.d.ts +35 -35
  72. package/dist/providers/google-vertex.d.ts +17 -17
  73. package/dist/providers/google-vertex.js +2 -2
  74. package/dist/providers/google.d.ts +17 -17
  75. package/dist/providers/groq.d.ts +24 -24
  76. package/dist/providers/meta.d.ts +179 -179
  77. package/dist/providers/minimax.d.ts +71 -71
  78. package/dist/providers/mistral.d.ts +28 -28
  79. package/dist/providers/moonshot.d.ts +202 -202
  80. package/dist/providers/open-responses-options.d.ts +0 -1
  81. package/dist/providers/open-responses-options.js +1 -1
  82. package/dist/providers/openai-compatible-responses.d.ts +35 -35
  83. package/dist/providers/openai-compatible.d.ts +12 -12
  84. package/dist/providers/openai-compatible.js +1 -1
  85. package/dist/providers/openai-options.d.ts +0 -1
  86. package/dist/providers/openai-options.js +0 -1
  87. package/dist/providers/openai.d.ts +100 -100
  88. package/dist/providers/openrouter.d.ts +36 -36
  89. package/dist/providers/togetherai.d.ts +24 -24
  90. package/dist/providers/venice.d.ts +195 -20
  91. package/dist/providers/xai.d.ts +12 -12
  92. package/dist/providers/zai-coding-plan.d.ts +149 -69
  93. package/dist/providers/zai.d.ts +84 -19
  94. package/dist/route/auth-options.d.ts +0 -3
  95. package/dist/route/auth.d.ts +0 -2
  96. package/dist/route/auth.js +0 -2
  97. package/dist/route/client.d.ts +0 -2
  98. package/dist/route/client.js +3 -4
  99. package/dist/route/executor-service.js +1 -1
  100. package/dist/speech-client.d.ts +8 -8
  101. package/dist/speech.d.ts +148 -148
  102. package/dist/transcription-client.d.ts +8 -8
  103. package/dist/transcription.d.ts +148 -148
  104. package/dist/video-client.d.ts +8 -8
  105. package/dist/video.d.ts +114 -114
  106. package/package.json +6 -5
@@ -27,14 +27,6 @@ interface ParserState extends OpenResponses.ParserState {
27
27
  export declare const protocol: Protocol<{
28
28
  readonly model: string;
29
29
  readonly input: readonly ({
30
- readonly [x: string]: unknown;
31
- readonly type: string;
32
- readonly id: string;
33
- } | {
34
- readonly type: "compaction";
35
- readonly id?: string | null | undefined;
36
- readonly encrypted_content: string;
37
- } | {
38
30
  readonly type: "configuration_update";
39
31
  readonly reasoning: {
40
32
  readonly effort: import("../schema/options.js").ReasoningEffort;
@@ -47,10 +39,45 @@ export declare const protocol: Protocol<{
47
39
  readonly type: "message";
48
40
  readonly role: "developer";
49
41
  readonly content: string;
42
+ } | {
43
+ readonly type: "function_call_output";
44
+ readonly call_id: string;
45
+ readonly output: string | readonly ({
46
+ readonly type: "input_text";
47
+ readonly text: string;
48
+ } | {
49
+ readonly type: "input_video";
50
+ readonly video_url: string;
51
+ } | {
52
+ readonly type: "input_image";
53
+ readonly image_url: string;
54
+ readonly detail?: string | undefined;
55
+ } | {
56
+ readonly type: "input_file";
57
+ readonly filename: string;
58
+ readonly detail?: string | undefined;
59
+ readonly file_data?: string | undefined;
60
+ readonly file_url?: string | undefined;
61
+ })[];
62
+ } | {
63
+ readonly type: "reasoning";
64
+ readonly id?: string | undefined;
65
+ readonly summary: readonly {
66
+ readonly type: "summary_text";
67
+ readonly text: string;
68
+ }[];
69
+ readonly encrypted_content?: string | null | undefined;
70
+ } | {
71
+ readonly type: "compaction";
72
+ readonly id?: string | null | undefined;
73
+ readonly encrypted_content: string;
50
74
  } | {
51
75
  readonly type: "message";
52
76
  readonly role: "user";
53
77
  readonly content: readonly ({
78
+ readonly type: "input_text";
79
+ readonly text: string;
80
+ } | {
54
81
  readonly type: "input_image";
55
82
  readonly image_url: string;
56
83
  readonly detail?: string | undefined;
@@ -60,9 +87,6 @@ export declare const protocol: Protocol<{
60
87
  readonly detail?: string | undefined;
61
88
  readonly file_data?: string | undefined;
62
89
  readonly file_url?: string | undefined;
63
- } | {
64
- readonly type: "input_text";
65
- readonly text: string;
66
90
  })[];
67
91
  readonly id?: string | undefined;
68
92
  readonly status?: string | undefined;
@@ -76,14 +100,6 @@ export declare const protocol: Protocol<{
76
100
  }[];
77
101
  readonly phase?: "commentary" | "final_answer" | null | undefined;
78
102
  readonly status?: string | undefined;
79
- } | {
80
- readonly type: "reasoning";
81
- readonly id?: string | undefined;
82
- readonly summary: readonly {
83
- readonly type: "summary_text";
84
- readonly text: string;
85
- }[];
86
- readonly encrypted_content?: string | null | undefined;
87
103
  } | {
88
104
  readonly type: "function_call";
89
105
  readonly id?: string | undefined;
@@ -91,26 +107,6 @@ export declare const protocol: Protocol<{
91
107
  readonly name: string;
92
108
  readonly namespace?: string | undefined;
93
109
  readonly arguments: string;
94
- } | {
95
- readonly type: "function_call_output";
96
- readonly call_id: string;
97
- readonly output: string | readonly ({
98
- readonly type: "input_image";
99
- readonly image_url: string;
100
- readonly detail?: string | undefined;
101
- } | {
102
- readonly type: "input_file";
103
- readonly filename: string;
104
- readonly detail?: string | undefined;
105
- readonly file_data?: string | undefined;
106
- readonly file_url?: string | undefined;
107
- } | {
108
- readonly type: "input_text";
109
- readonly text: string;
110
- } | {
111
- readonly type: "input_video";
112
- readonly video_url: string;
113
- })[];
114
110
  } | {
115
111
  readonly [x: string]: unknown;
116
112
  readonly type: "web_search_call";
@@ -148,6 +144,10 @@ export declare const protocol: Protocol<{
148
144
  readonly arguments?: string | undefined;
149
145
  readonly output?: string | null | undefined;
150
146
  readonly error?: unknown;
147
+ } | {
148
+ readonly [x: string]: unknown;
149
+ readonly type: string;
150
+ readonly id: string;
151
151
  })[];
152
152
  readonly instructions?: string | undefined;
153
153
  readonly tools?: readonly ({
@@ -263,14 +263,6 @@ export declare const protocol: Protocol<{
263
263
  export declare const httpTransport: import("../route/transport/http.js").HttpJsonTransport<{
264
264
  readonly model: string;
265
265
  readonly input: readonly ({
266
- readonly [x: string]: unknown;
267
- readonly type: string;
268
- readonly id: string;
269
- } | {
270
- readonly type: "compaction";
271
- readonly id?: string | null | undefined;
272
- readonly encrypted_content: string;
273
- } | {
274
266
  readonly type: "configuration_update";
275
267
  readonly reasoning: {
276
268
  readonly effort: import("../schema/options.js").ReasoningEffort;
@@ -283,10 +275,45 @@ export declare const httpTransport: import("../route/transport/http.js").HttpJso
283
275
  readonly type: "message";
284
276
  readonly role: "developer";
285
277
  readonly content: string;
278
+ } | {
279
+ readonly type: "function_call_output";
280
+ readonly call_id: string;
281
+ readonly output: string | readonly ({
282
+ readonly type: "input_text";
283
+ readonly text: string;
284
+ } | {
285
+ readonly type: "input_video";
286
+ readonly video_url: string;
287
+ } | {
288
+ readonly type: "input_image";
289
+ readonly image_url: string;
290
+ readonly detail?: string | undefined;
291
+ } | {
292
+ readonly type: "input_file";
293
+ readonly filename: string;
294
+ readonly detail?: string | undefined;
295
+ readonly file_data?: string | undefined;
296
+ readonly file_url?: string | undefined;
297
+ })[];
298
+ } | {
299
+ readonly type: "reasoning";
300
+ readonly id?: string | undefined;
301
+ readonly summary: readonly {
302
+ readonly type: "summary_text";
303
+ readonly text: string;
304
+ }[];
305
+ readonly encrypted_content?: string | null | undefined;
306
+ } | {
307
+ readonly type: "compaction";
308
+ readonly id?: string | null | undefined;
309
+ readonly encrypted_content: string;
286
310
  } | {
287
311
  readonly type: "message";
288
312
  readonly role: "user";
289
313
  readonly content: readonly ({
314
+ readonly type: "input_text";
315
+ readonly text: string;
316
+ } | {
290
317
  readonly type: "input_image";
291
318
  readonly image_url: string;
292
319
  readonly detail?: string | undefined;
@@ -296,9 +323,6 @@ export declare const httpTransport: import("../route/transport/http.js").HttpJso
296
323
  readonly detail?: string | undefined;
297
324
  readonly file_data?: string | undefined;
298
325
  readonly file_url?: string | undefined;
299
- } | {
300
- readonly type: "input_text";
301
- readonly text: string;
302
326
  })[];
303
327
  readonly id?: string | undefined;
304
328
  readonly status?: string | undefined;
@@ -312,14 +336,6 @@ export declare const httpTransport: import("../route/transport/http.js").HttpJso
312
336
  }[];
313
337
  readonly phase?: "commentary" | "final_answer" | null | undefined;
314
338
  readonly status?: string | undefined;
315
- } | {
316
- readonly type: "reasoning";
317
- readonly id?: string | undefined;
318
- readonly summary: readonly {
319
- readonly type: "summary_text";
320
- readonly text: string;
321
- }[];
322
- readonly encrypted_content?: string | null | undefined;
323
339
  } | {
324
340
  readonly type: "function_call";
325
341
  readonly id?: string | undefined;
@@ -327,26 +343,6 @@ export declare const httpTransport: import("../route/transport/http.js").HttpJso
327
343
  readonly name: string;
328
344
  readonly namespace?: string | undefined;
329
345
  readonly arguments: string;
330
- } | {
331
- readonly type: "function_call_output";
332
- readonly call_id: string;
333
- readonly output: string | readonly ({
334
- readonly type: "input_image";
335
- readonly image_url: string;
336
- readonly detail?: string | undefined;
337
- } | {
338
- readonly type: "input_file";
339
- readonly filename: string;
340
- readonly detail?: string | undefined;
341
- readonly file_data?: string | undefined;
342
- readonly file_url?: string | undefined;
343
- } | {
344
- readonly type: "input_text";
345
- readonly text: string;
346
- } | {
347
- readonly type: "input_video";
348
- readonly video_url: string;
349
- })[];
350
346
  } | {
351
347
  readonly [x: string]: unknown;
352
348
  readonly type: "web_search_call";
@@ -384,6 +380,10 @@ export declare const httpTransport: import("../route/transport/http.js").HttpJso
384
380
  readonly arguments?: string | undefined;
385
381
  readonly output?: string | null | undefined;
386
382
  readonly error?: unknown;
383
+ } | {
384
+ readonly [x: string]: unknown;
385
+ readonly type: string;
386
+ readonly id: string;
387
387
  })[];
388
388
  readonly instructions?: string | undefined;
389
389
  readonly tools?: readonly ({
@@ -21,15 +21,18 @@ declare const MistralThinkingContent: Schema.StructWithRest<Schema.Struct<{
21
21
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>;
22
22
  }>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>;
23
23
  type MistralThinkingContent = Schema.Schema.Type<typeof MistralThinkingContent>;
24
- export type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | (string & {});
25
- export type ProviderOptionsInput = {
26
- readonly safePrompt?: boolean;
27
- readonly documentImageLimit?: number;
28
- readonly documentPageLimit?: number;
29
- readonly parallelToolCalls?: boolean;
30
- readonly reasoningEffort?: ReasoningEffort;
31
- readonly promptMode?: "reasoning";
32
- readonly promptCacheKey?: string;
24
+ declare const ReasoningEffort: Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal" | "none" | "xhigh">, import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal" | "none" | "xhigh">>;
25
+ export type ReasoningEffort = typeof ReasoningEffort.Type;
26
+ declare const MistralOptions: Schema.Struct<{
27
+ readonly safePrompt: Schema.optional<Schema.Boolean>;
28
+ readonly documentImageLimit: Schema.optional<Schema.Number>;
29
+ readonly documentPageLimit: Schema.optional<Schema.Number>;
30
+ readonly parallelToolCalls: Schema.optional<Schema.Boolean>;
31
+ readonly reasoningEffort: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal" | "none" | "xhigh">, import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal" | "none" | "xhigh">>>;
32
+ readonly promptMode: Schema.optional<Schema.Literal<"reasoning">>;
33
+ readonly promptCacheKey: Schema.optional<Schema.String>;
34
+ }>;
35
+ export type ProviderOptionsInput = typeof MistralOptions.Type & {
33
36
  readonly [key: string]: unknown;
34
37
  };
35
38
  export declare const MistralBody: Schema.Struct<{
@@ -142,9 +145,26 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
142
145
  readonly type: "document_url";
143
146
  readonly document_url: string;
144
147
  })[];
148
+ } | {
149
+ readonly role: "tool";
150
+ readonly tool_call_id: string;
151
+ readonly name: string;
152
+ readonly content: string | readonly ({
153
+ readonly type: "text";
154
+ readonly text: string;
155
+ } | {
156
+ readonly type: "image_url";
157
+ readonly image_url: string;
158
+ } | {
159
+ readonly type: "document_url";
160
+ readonly document_url: string;
161
+ })[];
145
162
  } | {
146
163
  readonly role: "assistant";
147
164
  readonly content: string | readonly ({
165
+ readonly type: "text";
166
+ readonly text: string;
167
+ } | {
148
168
  readonly [x: string]: unknown;
149
169
  readonly type: "thinking";
150
170
  readonly thinking: readonly {
@@ -152,9 +172,6 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
152
172
  readonly type?: string | undefined;
153
173
  readonly text?: string | undefined;
154
174
  }[];
155
- } | {
156
- readonly type: "text";
157
- readonly text: string;
158
175
  })[];
159
176
  readonly tool_calls?: readonly {
160
177
  readonly id: string;
@@ -165,20 +182,6 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
165
182
  };
166
183
  }[] | undefined;
167
184
  readonly prefix?: true | undefined;
168
- } | {
169
- readonly role: "tool";
170
- readonly tool_call_id: string;
171
- readonly name: string;
172
- readonly content: string | readonly ({
173
- readonly type: "text";
174
- readonly text: string;
175
- } | {
176
- readonly type: "image_url";
177
- readonly image_url: string;
178
- } | {
179
- readonly type: "document_url";
180
- readonly document_url: string;
181
- })[];
182
185
  })[];
183
186
  tools: {
184
187
  readonly type: "function";
@@ -210,7 +213,7 @@ export declare const fromRequest: (request: LLMRequest<import("../schema/options
210
213
  document_image_limit: number | undefined;
211
214
  document_page_limit: number | undefined;
212
215
  parallel_tool_calls: boolean | undefined;
213
- reasoning_effort: string | undefined;
216
+ reasoning_effort: import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal" | "none" | "xhigh"> | undefined;
214
217
  prompt_mode: "reasoning" | undefined;
215
218
  }, AIError, never>;
216
219
  type ToolKey = string | number;
@@ -259,9 +262,26 @@ export declare const protocol: Protocol<{
259
262
  readonly type: "document_url";
260
263
  readonly document_url: string;
261
264
  })[];
265
+ } | {
266
+ readonly role: "tool";
267
+ readonly tool_call_id: string;
268
+ readonly name: string;
269
+ readonly content: string | readonly ({
270
+ readonly type: "text";
271
+ readonly text: string;
272
+ } | {
273
+ readonly type: "image_url";
274
+ readonly image_url: string;
275
+ } | {
276
+ readonly type: "document_url";
277
+ readonly document_url: string;
278
+ })[];
262
279
  } | {
263
280
  readonly role: "assistant";
264
281
  readonly content: string | readonly ({
282
+ readonly type: "text";
283
+ readonly text: string;
284
+ } | {
265
285
  readonly [x: string]: unknown;
266
286
  readonly type: "thinking";
267
287
  readonly thinking: readonly {
@@ -269,9 +289,6 @@ export declare const protocol: Protocol<{
269
289
  readonly type?: string | undefined;
270
290
  readonly text?: string | undefined;
271
291
  }[];
272
- } | {
273
- readonly type: "text";
274
- readonly text: string;
275
292
  })[];
276
293
  readonly tool_calls?: readonly {
277
294
  readonly id: string;
@@ -282,20 +299,6 @@ export declare const protocol: Protocol<{
282
299
  };
283
300
  }[] | undefined;
284
301
  readonly prefix?: true | undefined;
285
- } | {
286
- readonly role: "tool";
287
- readonly tool_call_id: string;
288
- readonly name: string;
289
- readonly content: string | readonly ({
290
- readonly type: "text";
291
- readonly text: string;
292
- } | {
293
- readonly type: "image_url";
294
- readonly image_url: string;
295
- } | {
296
- readonly type: "document_url";
297
- readonly document_url: string;
298
- })[];
299
302
  })[];
300
303
  readonly tools?: readonly {
301
304
  readonly type: "function";
@@ -396,9 +399,26 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
396
399
  readonly type: "document_url";
397
400
  readonly document_url: string;
398
401
  })[];
402
+ } | {
403
+ readonly role: "tool";
404
+ readonly tool_call_id: string;
405
+ readonly name: string;
406
+ readonly content: string | readonly ({
407
+ readonly type: "text";
408
+ readonly text: string;
409
+ } | {
410
+ readonly type: "image_url";
411
+ readonly image_url: string;
412
+ } | {
413
+ readonly type: "document_url";
414
+ readonly document_url: string;
415
+ })[];
399
416
  } | {
400
417
  readonly role: "assistant";
401
418
  readonly content: string | readonly ({
419
+ readonly type: "text";
420
+ readonly text: string;
421
+ } | {
402
422
  readonly [x: string]: unknown;
403
423
  readonly type: "thinking";
404
424
  readonly thinking: readonly {
@@ -406,9 +426,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
406
426
  readonly type?: string | undefined;
407
427
  readonly text?: string | undefined;
408
428
  }[];
409
- } | {
410
- readonly type: "text";
411
- readonly text: string;
412
429
  })[];
413
430
  readonly tool_calls?: readonly {
414
431
  readonly id: string;
@@ -419,20 +436,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
419
436
  };
420
437
  }[] | undefined;
421
438
  readonly prefix?: true | undefined;
422
- } | {
423
- readonly role: "tool";
424
- readonly tool_call_id: string;
425
- readonly name: string;
426
- readonly content: string | readonly ({
427
- readonly type: "text";
428
- readonly text: string;
429
- } | {
430
- readonly type: "image_url";
431
- readonly image_url: string;
432
- } | {
433
- readonly type: "document_url";
434
- readonly document_url: string;
435
- })[];
436
439
  })[];
437
440
  readonly tools?: readonly {
438
441
  readonly type: "function";
@@ -487,9 +490,26 @@ export declare const route: Route<{
487
490
  readonly type: "document_url";
488
491
  readonly document_url: string;
489
492
  })[];
493
+ } | {
494
+ readonly role: "tool";
495
+ readonly tool_call_id: string;
496
+ readonly name: string;
497
+ readonly content: string | readonly ({
498
+ readonly type: "text";
499
+ readonly text: string;
500
+ } | {
501
+ readonly type: "image_url";
502
+ readonly image_url: string;
503
+ } | {
504
+ readonly type: "document_url";
505
+ readonly document_url: string;
506
+ })[];
490
507
  } | {
491
508
  readonly role: "assistant";
492
509
  readonly content: string | readonly ({
510
+ readonly type: "text";
511
+ readonly text: string;
512
+ } | {
493
513
  readonly [x: string]: unknown;
494
514
  readonly type: "thinking";
495
515
  readonly thinking: readonly {
@@ -497,9 +517,6 @@ export declare const route: Route<{
497
517
  readonly type?: string | undefined;
498
518
  readonly text?: string | undefined;
499
519
  }[];
500
- } | {
501
- readonly type: "text";
502
- readonly text: string;
503
520
  })[];
504
521
  readonly tool_calls?: readonly {
505
522
  readonly id: string;
@@ -510,20 +527,6 @@ export declare const route: Route<{
510
527
  };
511
528
  }[] | undefined;
512
529
  readonly prefix?: true | undefined;
513
- } | {
514
- readonly role: "tool";
515
- readonly tool_call_id: string;
516
- readonly name: string;
517
- readonly content: string | readonly ({
518
- readonly type: "text";
519
- readonly text: string;
520
- } | {
521
- readonly type: "image_url";
522
- readonly image_url: string;
523
- } | {
524
- readonly type: "document_url";
525
- readonly document_url: string;
526
- })[];
527
530
  })[];
528
531
  readonly tools?: readonly {
529
532
  readonly type: "function";
@@ -69,12 +69,13 @@ const MistralTool = Schema.Struct({
69
69
  strict: Schema.Literal(false),
70
70
  }),
71
71
  });
72
+ const ReasoningEffort = ProviderShared.knownString();
72
73
  const MistralOptions = Schema.Struct({
73
74
  safePrompt: Schema.optional(Schema.Boolean),
74
75
  documentImageLimit: Schema.optional(Schema.Number),
75
76
  documentPageLimit: Schema.optional(Schema.Number),
76
77
  parallelToolCalls: Schema.optional(Schema.Boolean),
77
- reasoningEffort: Schema.optional(Schema.String),
78
+ reasoningEffort: Schema.optional(ReasoningEffort),
78
79
  promptMode: Schema.optional(Schema.Literal("reasoning")),
79
80
  promptCacheKey: Schema.optional(Schema.String),
80
81
  });
@@ -20,58 +20,59 @@ const message = (body) => Effect.gen(function* () {
20
20
  const driver = (options, body) => {
21
21
  let responseID;
22
22
  let terminal = false;
23
+ const observeEvent = Effect.fnUntraced(function* (_create, frame, event) {
24
+ if (terminal)
25
+ return yield* ProviderShared.eventError(options.id, `${options.name} emitted ${event.type} after a terminal event`, frame);
26
+ if (event.type === "error") {
27
+ terminal = true;
28
+ return {
29
+ type: "provider-failure",
30
+ error: OpenResponses.providerFailure(event, `${options.name} stream error`, frame),
31
+ };
32
+ }
33
+ if (event.type === "response.failed") {
34
+ terminal = true;
35
+ if (responseID && event.response?.id && event.response.id !== responseID)
36
+ return yield* ProviderShared.eventError(options.id, `${options.name} response ID changed during execution`, frame);
37
+ return {
38
+ type: "provider-failure",
39
+ error: OpenResponses.providerFailure(event, `${options.name} response failed`, frame),
40
+ };
41
+ }
42
+ if (event.type === "response.created") {
43
+ const created = event.response?.id;
44
+ if (responseID)
45
+ return yield* ProviderShared.eventError(options.id, `${options.name} emitted duplicate response.created`, frame);
46
+ if (!created)
47
+ return yield* ProviderShared.eventError(options.id, `${options.name} response.created is missing response.id`, frame);
48
+ responseID = created;
49
+ return { type: "frame", frame };
50
+ }
51
+ // Keepalives and provider notifications carry no response state and may precede response.created.
52
+ if (!event.type.startsWith("response."))
53
+ return { type: "frame", frame };
54
+ if (!responseID)
55
+ return yield* ProviderShared.eventError(options.id, `${options.name} emitted ${event.type} before response.created`, frame);
56
+ if (event.response?.id && event.response.id !== responseID)
57
+ return yield* ProviderShared.eventError(options.id, `${options.name} response ID changed during execution`, frame);
58
+ if (event.type === "response.completed") {
59
+ terminal = true;
60
+ return { type: "completed", frame };
61
+ }
62
+ if (event.type === "response.incomplete") {
63
+ terminal = true;
64
+ return { type: "incomplete", frame };
65
+ }
66
+ return { type: "frame", frame };
67
+ });
23
68
  return {
24
69
  create: () => Effect.sync(() => {
25
70
  responseID = undefined;
26
71
  terminal = false;
27
72
  return { message: body, mode: "full" };
28
73
  }),
29
- observe: (_create, frame) => Effect.gen(function* () {
30
- const event = yield* OpenResponses.decodeChannelEvent(frame).pipe(Effect.mapError((cause) => ProviderShared.eventError(options.id, `Invalid ${options.name} WebSocket event`, frame, cause)));
31
- if (terminal)
32
- return yield* ProviderShared.eventError(options.id, `${options.name} emitted ${event.type} after a terminal event`, frame);
33
- if (event.type === "error") {
34
- terminal = true;
35
- return {
36
- type: "provider-failure",
37
- error: OpenResponses.providerFailure(event, `${options.name} stream error`, frame),
38
- };
39
- }
40
- if (event.type === "response.failed") {
41
- terminal = true;
42
- if (responseID && event.response?.id && event.response.id !== responseID)
43
- return yield* ProviderShared.eventError(options.id, `${options.name} response ID changed during execution`, frame);
44
- return {
45
- type: "provider-failure",
46
- error: OpenResponses.providerFailure(event, `${options.name} response failed`, frame),
47
- };
48
- }
49
- if (event.type === "response.created") {
50
- const created = event.response?.id;
51
- if (responseID)
52
- return yield* ProviderShared.eventError(options.id, `${options.name} emitted duplicate response.created`, frame);
53
- if (!created)
54
- return yield* ProviderShared.eventError(options.id, `${options.name} response.created is missing response.id`, frame);
55
- responseID = created;
56
- return { type: "frame", frame };
57
- }
58
- // Keepalives and provider notifications carry no response state and may precede response.created.
59
- if (!event.type.startsWith("response."))
60
- return { type: "frame", frame };
61
- if (!responseID)
62
- return yield* ProviderShared.eventError(options.id, `${options.name} emitted ${event.type} before response.created`, frame);
63
- if (event.response?.id && event.response.id !== responseID)
64
- return yield* ProviderShared.eventError(options.id, `${options.name} response ID changed during execution`, frame);
65
- if (event.type === "response.completed") {
66
- terminal = true;
67
- return { type: "completed", frame };
68
- }
69
- if (event.type === "response.incomplete") {
70
- terminal = true;
71
- return { type: "incomplete", frame };
72
- }
73
- return { type: "frame", frame };
74
- }),
74
+ observeEvent,
75
+ observe: (create, frame) => OpenResponses.decodeChannelEvent(frame).pipe(Effect.mapError((cause) => ProviderShared.eventError(options.id, `Invalid ${options.name} WebSocket event`, frame, cause)), Effect.flatMap((event) => observeEvent(create, frame, event))),
75
76
  };
76
77
  };
77
78
  export const transport = (options) => {
@@ -1,15 +1,21 @@
1
- import type { WebSocketChannelDriver } from "../route/transport/index.js";
1
+ import { AIError } from "../schema/index.js";
2
+ import type { ChannelCreate, ChannelObservation, WebSocketChannelDriver } from "../route/transport/index.js";
3
+ import { Effect } from "effect";
4
+ import { OpenResponses } from "./open-responses.js";
2
5
  /**
3
6
  * Fields to send next to `previous_response_id` on an incremental step, or undefined to send the step in full.
4
7
  * Whether omitted fields carry over from the continued response is provider behavior the route must know.
5
8
  */
6
9
  export type Shape = (request: Readonly<Record<string, unknown>>) => Readonly<Record<string, unknown>> | undefined;
10
+ export interface BaseDriver extends WebSocketChannelDriver {
11
+ readonly observeEvent?: (create: ChannelCreate, frame: string, event: OpenResponses.Event) => Effect.Effect<ChannelObservation, AIError>;
12
+ }
7
13
  export interface DriverInput {
8
14
  readonly id: string;
9
15
  readonly name: string;
10
16
  readonly request: Readonly<Record<string, unknown>>;
11
17
  readonly message: string;
12
- readonly base: WebSocketChannelDriver;
18
+ readonly base: BaseDriver;
13
19
  readonly continuation?: Shape;
14
20
  }
15
21
  export declare const driver: (input: DriverInput) => WebSocketChannelDriver;
@@ -121,7 +121,9 @@ export const driver = (input) => {
121
121
  }),
122
122
  observe: (create, frame) => Effect.gen(function* () {
123
123
  const event = yield* OpenResponses.decodeChannelEvent(frame).pipe(Effect.mapError((cause) => ProviderShared.eventError(input.id, `Invalid ${input.name} WebSocket event`, frame, cause)));
124
- const observation = yield* input.base.observe(create, frame);
124
+ const observation = yield* input.base.observeEvent
125
+ ? input.base.observeEvent(create, frame, event)
126
+ : input.base.observe(create, frame);
125
127
  if (event.type === "response.output_item.done" && event.item)
126
128
  output.push(event.item);
127
129
  if (observation.type === "provider-failure") {