@opencode/ai 0.0.0-dev-172 → 0.0.0-dev-177
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.
- package/README.md +48 -3
- package/dist/effect.d.ts +1 -1
- package/dist/effect.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/protocols/alibaba-chat.d.ts +39 -4
- package/dist/protocols/alibaba-responses.d.ts +20 -3
- package/dist/protocols/fal-images.d.ts +2 -0
- package/dist/protocols/fal-images.js +1 -0
- package/dist/protocols/meta-responses.d.ts +40 -6
- package/dist/protocols/meta-responses.js +1 -1
- package/dist/protocols/minimax-images.d.ts +25 -0
- package/dist/protocols/minimax-images.js +150 -0
- package/dist/protocols/open-responses.d.ts +182 -27
- package/dist/protocols/open-responses.js +108 -36
- package/dist/protocols/openai-chat.d.ts +438 -46
- package/dist/protocols/openai-chat.js +121 -39
- package/dist/protocols/openai-compatible-chat.d.ts +35 -4
- package/dist/protocols/openai-compatible-responses.d.ts +20 -3
- package/dist/protocols/openai-freeform.d.ts +47 -0
- package/dist/protocols/openai-freeform.js +54 -0
- package/dist/protocols/openai-images.js +8 -2
- package/dist/protocols/openai-responses.d.ts +120 -18
- package/dist/protocols/openai-responses.js +17 -8
- package/dist/protocols/venice-chat.d.ts +39 -4
- package/dist/protocols/venice-chat.js +1 -1
- package/dist/protocols/xai-images.d.ts +1 -0
- package/dist/protocols/xai-images.js +2 -4
- package/dist/protocols/xai-responses.d.ts +20 -3
- package/dist/protocols/xai-responses.js +2 -1
- package/dist/protocols/zai-chat.d.ts +39 -4
- package/dist/providers/alibaba.d.ts +55 -7
- package/dist/providers/amazon-bedrock-mantle.d.ts +55 -7
- package/dist/providers/azure.d.ts +75 -10
- package/dist/providers/baseten.d.ts +70 -8
- package/dist/providers/cerebras.d.ts +70 -8
- package/dist/providers/cloudflare-ai-gateway.d.ts +110 -14
- package/dist/providers/cloudflare-workers-ai.d.ts +70 -8
- package/dist/providers/cohere.d.ts +70 -8
- package/dist/providers/deepinfra.d.ts +70 -8
- package/dist/providers/deepseek.d.ts +70 -8
- package/dist/providers/digitalocean.d.ts +109 -12
- package/dist/providers/fireworks.d.ts +70 -8
- package/dist/providers/google-vertex-chat.d.ts +35 -4
- package/dist/providers/google-vertex-responses.d.ts +20 -3
- package/dist/providers/groq.d.ts +74 -8
- package/dist/providers/meta.d.ts +55 -7
- package/dist/providers/minimax/images.d.ts +3 -0
- package/dist/providers/minimax/images.js +1 -0
- package/dist/providers/minimax.d.ts +62 -8
- package/dist/providers/minimax.js +22 -9
- package/dist/providers/moonshot.d.ts +55 -7
- package/dist/providers/openai-compatible-responses.d.ts +20 -3
- package/dist/providers/openai-compatible.d.ts +35 -4
- package/dist/providers/openai-compatible.js +9 -2
- package/dist/providers/openai.d.ts +55 -7
- package/dist/providers/openrouter.d.ts +144 -16
- package/dist/providers/togetherai.d.ts +70 -8
- package/dist/providers/venice.d.ts +35 -4
- package/dist/providers/xai.d.ts +35 -4
- package/dist/providers/zai-coding-plan.d.ts +55 -7
- package/dist/providers/zai.d.ts +35 -4
- package/dist/schema/messages.d.ts +35 -1
- package/dist/schema/messages.js +20 -0
- package/dist/tool.d.ts +12 -1
- package/dist/tool.js +10 -2
- package/package.json +7 -3
|
@@ -82,7 +82,7 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
82
82
|
readonly namespace: Schema.optional<Schema.String>;
|
|
83
83
|
readonly arguments: Schema.String;
|
|
84
84
|
}>, Schema.Struct<{
|
|
85
|
-
readonly type: Schema.
|
|
85
|
+
readonly type: Schema.Literals<readonly ["function_call_output", "custom_tool_call_output"]>;
|
|
86
86
|
readonly call_id: Schema.String;
|
|
87
87
|
readonly output: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
88
88
|
readonly type: Schema.tag<"input_text">;
|
|
@@ -101,6 +101,12 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
101
101
|
readonly type: Schema.tag<"input_video">;
|
|
102
102
|
readonly video_url: Schema.String;
|
|
103
103
|
}>]>>]>;
|
|
104
|
+
}>, Schema.Struct<{
|
|
105
|
+
readonly type: Schema.tag<"custom_tool_call">;
|
|
106
|
+
readonly id: Schema.optionalKey<Schema.String>;
|
|
107
|
+
readonly call_id: Schema.String;
|
|
108
|
+
readonly name: Schema.String;
|
|
109
|
+
readonly input: Schema.String;
|
|
104
110
|
}>, Schema.Union<readonly [Schema.StructWithRest<Schema.Struct<{
|
|
105
111
|
readonly type: Schema.tag<"web_search_call">;
|
|
106
112
|
readonly id: Schema.String;
|
|
@@ -164,6 +170,17 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
164
170
|
readonly description: Schema.String;
|
|
165
171
|
readonly parameters: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
166
172
|
readonly strict: Schema.optional<Schema.Boolean>;
|
|
173
|
+
}>, Schema.Struct<{
|
|
174
|
+
readonly type: Schema.tag<"custom">;
|
|
175
|
+
readonly name: Schema.String;
|
|
176
|
+
readonly description: Schema.String;
|
|
177
|
+
readonly format: Schema.Union<readonly [Schema.Struct<{
|
|
178
|
+
readonly type: Schema.tag<"text">;
|
|
179
|
+
}>, Schema.Struct<{
|
|
180
|
+
readonly type: Schema.tag<"grammar">;
|
|
181
|
+
readonly syntax: Schema.Literals<readonly ["lark", "regex"]>;
|
|
182
|
+
readonly definition: Schema.String;
|
|
183
|
+
}>]>;
|
|
167
184
|
}>, Schema.Struct<{
|
|
168
185
|
readonly type: Schema.tag<"namespace">;
|
|
169
186
|
readonly name: Schema.String;
|
|
@@ -187,13 +204,13 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
187
204
|
readonly size: Schema.optional<Schema.String>;
|
|
188
205
|
}>]>>>;
|
|
189
206
|
readonly tool_choice: Schema.optional<Schema.Union<readonly [Schema.Union<readonly [Schema.Literals<readonly ["auto", "none", "required"]>, Schema.Struct<{
|
|
190
|
-
readonly type: Schema.
|
|
207
|
+
readonly type: Schema.Literals<readonly ["function", "custom"]>;
|
|
191
208
|
readonly name: Schema.String;
|
|
192
209
|
}>, Schema.Struct<{
|
|
193
210
|
readonly type: Schema.tag<"allowed_tools">;
|
|
194
211
|
readonly mode: Schema.Literals<readonly ["auto", "none", "required"]>;
|
|
195
212
|
readonly tools: Schema.$Array<Schema.Struct<{
|
|
196
|
-
readonly type: Schema.
|
|
213
|
+
readonly type: Schema.Literals<readonly ["function", "custom"]>;
|
|
197
214
|
readonly name: Schema.String;
|
|
198
215
|
}>>;
|
|
199
216
|
}>]>, Schema.Struct<{
|
|
@@ -232,7 +249,7 @@ export declare const protocol: Protocol<{
|
|
|
232
249
|
readonly role: "developer";
|
|
233
250
|
readonly content: string;
|
|
234
251
|
} | {
|
|
235
|
-
readonly type: "function_call_output";
|
|
252
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
236
253
|
readonly call_id: string;
|
|
237
254
|
readonly output: string | readonly ({
|
|
238
255
|
readonly type: "input_text";
|
|
@@ -302,6 +319,12 @@ export declare const protocol: Protocol<{
|
|
|
302
319
|
readonly name: string;
|
|
303
320
|
readonly namespace?: string | undefined;
|
|
304
321
|
readonly arguments: string;
|
|
322
|
+
} | {
|
|
323
|
+
readonly type: "custom_tool_call";
|
|
324
|
+
readonly id?: string | undefined;
|
|
325
|
+
readonly call_id: string;
|
|
326
|
+
readonly name: string;
|
|
327
|
+
readonly input: string;
|
|
305
328
|
} | {
|
|
306
329
|
readonly [x: string]: unknown;
|
|
307
330
|
readonly type: "web_search_call";
|
|
@@ -373,6 +396,17 @@ export declare const protocol: Protocol<{
|
|
|
373
396
|
readonly ttl?: string | undefined;
|
|
374
397
|
} | undefined;
|
|
375
398
|
readonly tools?: readonly ({
|
|
399
|
+
readonly type: "custom";
|
|
400
|
+
readonly name: string;
|
|
401
|
+
readonly description: string;
|
|
402
|
+
readonly format: {
|
|
403
|
+
readonly type: "text";
|
|
404
|
+
} | {
|
|
405
|
+
readonly type: "grammar";
|
|
406
|
+
readonly syntax: "lark" | "regex";
|
|
407
|
+
readonly definition: string;
|
|
408
|
+
};
|
|
409
|
+
} | {
|
|
376
410
|
readonly type: "namespace";
|
|
377
411
|
readonly name: string;
|
|
378
412
|
readonly description: string;
|
|
@@ -405,13 +439,13 @@ export declare const protocol: Protocol<{
|
|
|
405
439
|
readonly size?: string | undefined;
|
|
406
440
|
})[] | undefined;
|
|
407
441
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
408
|
-
readonly type: "function";
|
|
442
|
+
readonly type: "custom" | "function";
|
|
409
443
|
readonly name: string;
|
|
410
444
|
} | {
|
|
411
445
|
readonly type: "allowed_tools";
|
|
412
446
|
readonly mode: "auto" | "none" | "required";
|
|
413
447
|
readonly tools: readonly {
|
|
414
|
-
readonly type: "function";
|
|
448
|
+
readonly type: "custom" | "function";
|
|
415
449
|
readonly name: string;
|
|
416
450
|
}[];
|
|
417
451
|
} | {
|
|
@@ -503,7 +537,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
503
537
|
readonly role: "developer";
|
|
504
538
|
readonly content: string;
|
|
505
539
|
} | {
|
|
506
|
-
readonly type: "function_call_output";
|
|
540
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
507
541
|
readonly call_id: string;
|
|
508
542
|
readonly output: string | readonly ({
|
|
509
543
|
readonly type: "input_text";
|
|
@@ -573,6 +607,12 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
573
607
|
readonly name: string;
|
|
574
608
|
readonly namespace?: string | undefined;
|
|
575
609
|
readonly arguments: string;
|
|
610
|
+
} | {
|
|
611
|
+
readonly type: "custom_tool_call";
|
|
612
|
+
readonly id?: string | undefined;
|
|
613
|
+
readonly call_id: string;
|
|
614
|
+
readonly name: string;
|
|
615
|
+
readonly input: string;
|
|
576
616
|
} | {
|
|
577
617
|
readonly [x: string]: unknown;
|
|
578
618
|
readonly type: "web_search_call";
|
|
@@ -644,6 +684,17 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
644
684
|
readonly ttl?: string | undefined;
|
|
645
685
|
} | undefined;
|
|
646
686
|
readonly tools?: readonly ({
|
|
687
|
+
readonly type: "custom";
|
|
688
|
+
readonly name: string;
|
|
689
|
+
readonly description: string;
|
|
690
|
+
readonly format: {
|
|
691
|
+
readonly type: "text";
|
|
692
|
+
} | {
|
|
693
|
+
readonly type: "grammar";
|
|
694
|
+
readonly syntax: "lark" | "regex";
|
|
695
|
+
readonly definition: string;
|
|
696
|
+
};
|
|
697
|
+
} | {
|
|
647
698
|
readonly type: "namespace";
|
|
648
699
|
readonly name: string;
|
|
649
700
|
readonly description: string;
|
|
@@ -676,13 +727,13 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
676
727
|
readonly size?: string | undefined;
|
|
677
728
|
})[] | undefined;
|
|
678
729
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
679
|
-
readonly type: "function";
|
|
730
|
+
readonly type: "custom" | "function";
|
|
680
731
|
readonly name: string;
|
|
681
732
|
} | {
|
|
682
733
|
readonly type: "allowed_tools";
|
|
683
734
|
readonly mode: "auto" | "none" | "required";
|
|
684
735
|
readonly tools: readonly {
|
|
685
|
-
readonly type: "function";
|
|
736
|
+
readonly type: "custom" | "function";
|
|
686
737
|
readonly name: string;
|
|
687
738
|
}[];
|
|
688
739
|
} | {
|
|
@@ -716,7 +767,7 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
716
767
|
readonly role: "developer";
|
|
717
768
|
readonly content: string;
|
|
718
769
|
} | {
|
|
719
|
-
readonly type: "function_call_output";
|
|
770
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
720
771
|
readonly call_id: string;
|
|
721
772
|
readonly output: string | readonly ({
|
|
722
773
|
readonly type: "input_text";
|
|
@@ -786,6 +837,12 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
786
837
|
readonly name: string;
|
|
787
838
|
readonly namespace?: string | undefined;
|
|
788
839
|
readonly arguments: string;
|
|
840
|
+
} | {
|
|
841
|
+
readonly type: "custom_tool_call";
|
|
842
|
+
readonly id?: string | undefined;
|
|
843
|
+
readonly call_id: string;
|
|
844
|
+
readonly name: string;
|
|
845
|
+
readonly input: string;
|
|
789
846
|
} | {
|
|
790
847
|
readonly [x: string]: unknown;
|
|
791
848
|
readonly type: "web_search_call";
|
|
@@ -857,6 +914,17 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
857
914
|
readonly ttl?: string | undefined;
|
|
858
915
|
} | undefined;
|
|
859
916
|
readonly tools?: readonly ({
|
|
917
|
+
readonly type: "custom";
|
|
918
|
+
readonly name: string;
|
|
919
|
+
readonly description: string;
|
|
920
|
+
readonly format: {
|
|
921
|
+
readonly type: "text";
|
|
922
|
+
} | {
|
|
923
|
+
readonly type: "grammar";
|
|
924
|
+
readonly syntax: "lark" | "regex";
|
|
925
|
+
readonly definition: string;
|
|
926
|
+
};
|
|
927
|
+
} | {
|
|
860
928
|
readonly type: "namespace";
|
|
861
929
|
readonly name: string;
|
|
862
930
|
readonly description: string;
|
|
@@ -889,13 +957,13 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
889
957
|
readonly size?: string | undefined;
|
|
890
958
|
})[] | undefined;
|
|
891
959
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
892
|
-
readonly type: "function";
|
|
960
|
+
readonly type: "custom" | "function";
|
|
893
961
|
readonly name: string;
|
|
894
962
|
} | {
|
|
895
963
|
readonly type: "allowed_tools";
|
|
896
964
|
readonly mode: "auto" | "none" | "required";
|
|
897
965
|
readonly tools: readonly {
|
|
898
|
-
readonly type: "function";
|
|
966
|
+
readonly type: "custom" | "function";
|
|
899
967
|
readonly name: string;
|
|
900
968
|
}[];
|
|
901
969
|
} | {
|
|
@@ -929,7 +997,7 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
929
997
|
readonly role: "developer";
|
|
930
998
|
readonly content: string;
|
|
931
999
|
} | {
|
|
932
|
-
readonly type: "function_call_output";
|
|
1000
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
933
1001
|
readonly call_id: string;
|
|
934
1002
|
readonly output: string | readonly ({
|
|
935
1003
|
readonly type: "input_text";
|
|
@@ -999,6 +1067,12 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
999
1067
|
readonly name: string;
|
|
1000
1068
|
readonly namespace?: string | undefined;
|
|
1001
1069
|
readonly arguments: string;
|
|
1070
|
+
} | {
|
|
1071
|
+
readonly type: "custom_tool_call";
|
|
1072
|
+
readonly id?: string | undefined;
|
|
1073
|
+
readonly call_id: string;
|
|
1074
|
+
readonly name: string;
|
|
1075
|
+
readonly input: string;
|
|
1002
1076
|
} | {
|
|
1003
1077
|
readonly [x: string]: unknown;
|
|
1004
1078
|
readonly type: "web_search_call";
|
|
@@ -1070,6 +1144,17 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1070
1144
|
readonly ttl?: string | undefined;
|
|
1071
1145
|
} | undefined;
|
|
1072
1146
|
readonly tools?: readonly ({
|
|
1147
|
+
readonly type: "custom";
|
|
1148
|
+
readonly name: string;
|
|
1149
|
+
readonly description: string;
|
|
1150
|
+
readonly format: {
|
|
1151
|
+
readonly type: "text";
|
|
1152
|
+
} | {
|
|
1153
|
+
readonly type: "grammar";
|
|
1154
|
+
readonly syntax: "lark" | "regex";
|
|
1155
|
+
readonly definition: string;
|
|
1156
|
+
};
|
|
1157
|
+
} | {
|
|
1073
1158
|
readonly type: "namespace";
|
|
1074
1159
|
readonly name: string;
|
|
1075
1160
|
readonly description: string;
|
|
@@ -1102,13 +1187,13 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1102
1187
|
readonly size?: string | undefined;
|
|
1103
1188
|
})[] | undefined;
|
|
1104
1189
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
1105
|
-
readonly type: "function";
|
|
1190
|
+
readonly type: "custom" | "function";
|
|
1106
1191
|
readonly name: string;
|
|
1107
1192
|
} | {
|
|
1108
1193
|
readonly type: "allowed_tools";
|
|
1109
1194
|
readonly mode: "auto" | "none" | "required";
|
|
1110
1195
|
readonly tools: readonly {
|
|
1111
|
-
readonly type: "function";
|
|
1196
|
+
readonly type: "custom" | "function";
|
|
1112
1197
|
readonly name: string;
|
|
1113
1198
|
}[];
|
|
1114
1199
|
} | {
|
|
@@ -1142,7 +1227,7 @@ export declare const route: Route<{
|
|
|
1142
1227
|
readonly role: "developer";
|
|
1143
1228
|
readonly content: string;
|
|
1144
1229
|
} | {
|
|
1145
|
-
readonly type: "function_call_output";
|
|
1230
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
1146
1231
|
readonly call_id: string;
|
|
1147
1232
|
readonly output: string | readonly ({
|
|
1148
1233
|
readonly type: "input_text";
|
|
@@ -1212,6 +1297,12 @@ export declare const route: Route<{
|
|
|
1212
1297
|
readonly name: string;
|
|
1213
1298
|
readonly namespace?: string | undefined;
|
|
1214
1299
|
readonly arguments: string;
|
|
1300
|
+
} | {
|
|
1301
|
+
readonly type: "custom_tool_call";
|
|
1302
|
+
readonly id?: string | undefined;
|
|
1303
|
+
readonly call_id: string;
|
|
1304
|
+
readonly name: string;
|
|
1305
|
+
readonly input: string;
|
|
1215
1306
|
} | {
|
|
1216
1307
|
readonly [x: string]: unknown;
|
|
1217
1308
|
readonly type: "web_search_call";
|
|
@@ -1283,6 +1374,17 @@ export declare const route: Route<{
|
|
|
1283
1374
|
readonly ttl?: string | undefined;
|
|
1284
1375
|
} | undefined;
|
|
1285
1376
|
readonly tools?: readonly ({
|
|
1377
|
+
readonly type: "custom";
|
|
1378
|
+
readonly name: string;
|
|
1379
|
+
readonly description: string;
|
|
1380
|
+
readonly format: {
|
|
1381
|
+
readonly type: "text";
|
|
1382
|
+
} | {
|
|
1383
|
+
readonly type: "grammar";
|
|
1384
|
+
readonly syntax: "lark" | "regex";
|
|
1385
|
+
readonly definition: string;
|
|
1386
|
+
};
|
|
1387
|
+
} | {
|
|
1286
1388
|
readonly type: "namespace";
|
|
1287
1389
|
readonly name: string;
|
|
1288
1390
|
readonly description: string;
|
|
@@ -1315,13 +1417,13 @@ export declare const route: Route<{
|
|
|
1315
1417
|
readonly size?: string | undefined;
|
|
1316
1418
|
})[] | undefined;
|
|
1317
1419
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
1318
|
-
readonly type: "function";
|
|
1420
|
+
readonly type: "custom" | "function";
|
|
1319
1421
|
readonly name: string;
|
|
1320
1422
|
} | {
|
|
1321
1423
|
readonly type: "allowed_tools";
|
|
1322
1424
|
readonly mode: "auto" | "none" | "required";
|
|
1323
1425
|
readonly tools: readonly {
|
|
1324
|
-
readonly type: "function";
|
|
1426
|
+
readonly type: "custom" | "function";
|
|
1325
1427
|
readonly name: string;
|
|
1326
1428
|
}[];
|
|
1327
1429
|
} | {
|
|
@@ -17,6 +17,7 @@ import { OpenResponsesChannel } from "./open-responses-channel.js";
|
|
|
17
17
|
import { ResponsesCompaction } from "./utils/responses-compaction.js";
|
|
18
18
|
import { ResponsesCheckpoint } from "./utils/responses-checkpoint.js";
|
|
19
19
|
import * as Cache from "./utils/cache.js";
|
|
20
|
+
import { OpenAIFreeform } from "./openai-freeform.js";
|
|
20
21
|
const ADAPTER = "openai-responses";
|
|
21
22
|
const NAME = "OpenAI Responses";
|
|
22
23
|
const WEBSOCKET_PROTOCOL_HEADER = "responses_websockets=2026-02-06";
|
|
@@ -83,6 +84,7 @@ const OpenAIResponsesNamespace = Schema.Struct({
|
|
|
83
84
|
});
|
|
84
85
|
const OpenAIResponsesTools = Schema.Union([
|
|
85
86
|
OpenResponses.Tool,
|
|
87
|
+
OpenResponses.CustomTool,
|
|
86
88
|
OpenAIResponsesNamespace,
|
|
87
89
|
OpenAIResponsesImageGenerationTool,
|
|
88
90
|
]);
|
|
@@ -145,20 +147,23 @@ const nativeImageTool = (tool) => {
|
|
|
145
147
|
const native = nativeImageToolInput(tool);
|
|
146
148
|
return Schema.is(OpenAIResponsesImageGenerationTool)(native) ? native : undefined;
|
|
147
149
|
};
|
|
148
|
-
const lowerTool = Effect.fnUntraced(function* (tool) {
|
|
150
|
+
const lowerTool = Effect.fnUntraced(function* (tool, custom) {
|
|
149
151
|
const native = nativeImageToolInput(tool);
|
|
150
152
|
if (native !== undefined) {
|
|
151
153
|
if (Schema.is(OpenAIResponsesImageGenerationTool)(native))
|
|
152
154
|
return native;
|
|
153
155
|
return yield* ProviderShared.invalidRequest("OpenAI Responses image generation tool options are invalid");
|
|
154
156
|
}
|
|
157
|
+
const definition = custom.get(tool.name);
|
|
158
|
+
if (definition)
|
|
159
|
+
return OpenResponses.lowerCustomTool(tool, definition);
|
|
155
160
|
return yield* OpenResponses.lowerTool(NAME, tool);
|
|
156
161
|
});
|
|
157
162
|
// Native namespaces hold only function tools, so deeper levels flatten into
|
|
158
163
|
// the leaf names the same way non-native protocols flatten the whole tree.
|
|
159
|
-
const lowerToolEntry = Effect.fnUntraced(function* (tool) {
|
|
164
|
+
const lowerToolEntry = Effect.fnUntraced(function* (tool, custom) {
|
|
160
165
|
if (tool.type === "tool")
|
|
161
|
-
return yield* lowerTool(tool);
|
|
166
|
+
return yield* lowerTool(tool, custom);
|
|
162
167
|
// OpenAI requires a namespace description; fall back to a generic one so a
|
|
163
168
|
// missing description never blocks the request.
|
|
164
169
|
return {
|
|
@@ -168,14 +173,17 @@ const lowerToolEntry = Effect.fnUntraced(function* (tool) {
|
|
|
168
173
|
tools: yield* Effect.forEach(ProviderShared.flattenTools(tool.tools), (leaf) => OpenResponses.lowerTool(NAME, leaf)),
|
|
169
174
|
};
|
|
170
175
|
});
|
|
171
|
-
const lowerTools = (request) =>
|
|
172
|
-
const
|
|
176
|
+
const lowerTools = (request) => {
|
|
177
|
+
const custom = OpenAIFreeform.tools(request);
|
|
178
|
+
return Effect.forEach(request.tools, (tool) => lowerToolEntry(tool, custom));
|
|
179
|
+
};
|
|
180
|
+
const lowerToolChoice = (toolChoice, tools, custom) => ProviderShared.matchToolChoice(NAME, toolChoice, {
|
|
173
181
|
auto: () => "auto",
|
|
174
182
|
none: () => "none",
|
|
175
183
|
required: () => "required",
|
|
176
184
|
tool: (name) => tools.some((tool) => tool.type === "tool" && tool.name === name && nativeImageTool(tool) !== undefined)
|
|
177
185
|
? { type: "image_generation" }
|
|
178
|
-
:
|
|
186
|
+
: OpenResponses.namedTool(name, custom),
|
|
179
187
|
});
|
|
180
188
|
const fromRequest = Effect.fn("OpenAIResponses.fromRequest")(function* (request) {
|
|
181
189
|
const management = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Schema.UndefinedOr(ContextManagement)))(request.providerOptions?.contextManagement);
|
|
@@ -183,6 +191,7 @@ const fromRequest = Effect.fn("OpenAIResponses.fromRequest")(function* (request)
|
|
|
183
191
|
const reasoning = Schema.decodeUnknownSync(ReasoningOptions)(request.providerOptions ?? {});
|
|
184
192
|
const updates = resolveEffortUpdates(request, options.reasoningEffort);
|
|
185
193
|
const generation = OpenResponses.lowerGeneration(request, { ...options, reasoningEffort: updates.effort });
|
|
194
|
+
const custom = OpenAIFreeform.tools(request);
|
|
186
195
|
return {
|
|
187
196
|
...(yield* OpenResponses.lowerConversation(updates.request, adapter)),
|
|
188
197
|
...generation,
|
|
@@ -200,8 +209,8 @@ const fromRequest = Effect.fn("OpenAIResponses.fromRequest")(function* (request)
|
|
|
200
209
|
tools: request.tools.length === 0 ? undefined : yield* lowerTools(request),
|
|
201
210
|
tool_choice: request.tools.length === 0
|
|
202
211
|
? undefined
|
|
203
|
-
: (OpenResponses.allowedToolChoice(
|
|
204
|
-
(request.toolChoice ? yield* lowerToolChoice(request.toolChoice, request.tools) : undefined)),
|
|
212
|
+
: (OpenResponses.allowedToolChoice(options, custom) ??
|
|
213
|
+
(request.toolChoice ? yield* lowerToolChoice(request.toolChoice, request.tools, custom) : undefined)),
|
|
205
214
|
};
|
|
206
215
|
});
|
|
207
216
|
const checkpointBody = {
|
|
@@ -52,7 +52,7 @@ export declare const compatibility: {
|
|
|
52
52
|
};
|
|
53
53
|
export declare const protocol: Protocol<{
|
|
54
54
|
readonly model: string;
|
|
55
|
-
readonly tools?: readonly {
|
|
55
|
+
readonly tools?: readonly ({
|
|
56
56
|
readonly type: "function";
|
|
57
57
|
readonly function: {
|
|
58
58
|
readonly name: string;
|
|
@@ -66,12 +66,36 @@ export declare const protocol: Protocol<{
|
|
|
66
66
|
readonly type: "ephemeral";
|
|
67
67
|
readonly ttl?: string | undefined;
|
|
68
68
|
} | undefined;
|
|
69
|
-
}
|
|
69
|
+
} | {
|
|
70
|
+
readonly type: "custom";
|
|
71
|
+
readonly custom: {
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly description: string;
|
|
74
|
+
readonly format: {
|
|
75
|
+
readonly type: "text";
|
|
76
|
+
} | {
|
|
77
|
+
readonly type: "grammar";
|
|
78
|
+
readonly grammar: {
|
|
79
|
+
readonly syntax: "lark" | "regex";
|
|
80
|
+
readonly definition: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
readonly cache_control?: {
|
|
85
|
+
readonly type: "ephemeral";
|
|
86
|
+
readonly ttl?: string | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
})[] | undefined;
|
|
70
89
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
71
90
|
readonly type: "function";
|
|
72
91
|
readonly function: {
|
|
73
92
|
readonly name: string;
|
|
74
93
|
};
|
|
94
|
+
} | {
|
|
95
|
+
readonly type: "custom";
|
|
96
|
+
readonly custom: {
|
|
97
|
+
readonly name: string;
|
|
98
|
+
};
|
|
75
99
|
} | undefined;
|
|
76
100
|
readonly stream: true;
|
|
77
101
|
readonly stream_options?: {
|
|
@@ -176,7 +200,14 @@ export declare const protocol: Protocol<{
|
|
|
176
200
|
readonly reasoning?: string | undefined;
|
|
177
201
|
readonly reasoning_text?: string | undefined;
|
|
178
202
|
readonly reasoning_details?: unknown;
|
|
179
|
-
readonly tool_calls?: readonly {
|
|
203
|
+
readonly tool_calls?: readonly ({
|
|
204
|
+
readonly id: string;
|
|
205
|
+
readonly type: "custom";
|
|
206
|
+
readonly custom: {
|
|
207
|
+
readonly name: string;
|
|
208
|
+
readonly input: string;
|
|
209
|
+
};
|
|
210
|
+
} | {
|
|
180
211
|
readonly id: string;
|
|
181
212
|
readonly type: "function";
|
|
182
213
|
readonly function: {
|
|
@@ -189,7 +220,7 @@ export declare const protocol: Protocol<{
|
|
|
189
220
|
};
|
|
190
221
|
} | undefined;
|
|
191
222
|
readonly thought_signature?: string | undefined;
|
|
192
|
-
}[] | undefined;
|
|
223
|
+
})[] | undefined;
|
|
193
224
|
readonly thought_signature?: string | undefined;
|
|
194
225
|
})[];
|
|
195
226
|
readonly reasoning?: {
|
|
@@ -256,6 +287,10 @@ export declare const protocol: Protocol<{
|
|
|
256
287
|
readonly name?: string | null | undefined;
|
|
257
288
|
readonly arguments?: string | null | undefined;
|
|
258
289
|
} | null | undefined;
|
|
290
|
+
readonly custom?: {
|
|
291
|
+
readonly name?: string | null | undefined;
|
|
292
|
+
readonly input?: string | null | undefined;
|
|
293
|
+
} | null | undefined;
|
|
259
294
|
readonly extra_content?: unknown;
|
|
260
295
|
readonly thought_signature?: string | null | undefined;
|
|
261
296
|
}[] | null | undefined;
|
|
@@ -48,7 +48,7 @@ const ToolCall = Schema.Struct({
|
|
|
48
48
|
});
|
|
49
49
|
const Assistant = Schema.StructWithRest(Schema.Struct({
|
|
50
50
|
...OpenAIChat.OpenAIChatMessage.cases.assistant.schema.fields,
|
|
51
|
-
tool_calls: optionalArray(ToolCall),
|
|
51
|
+
tool_calls: optionalArray(Schema.Union([ToolCall, OpenAIChat.OpenAIChatAssistantCustomToolCall])),
|
|
52
52
|
thought_signature: Schema.optional(Schema.String),
|
|
53
53
|
}), [JsonObject]);
|
|
54
54
|
const Messages = Schema.Array(Schema.Union([
|
|
@@ -7,6 +7,7 @@ export declare const PATH = "/images/generations";
|
|
|
7
7
|
export declare const EDIT_PATH = "/images/edits";
|
|
8
8
|
/** Provider-native options. Common fields (`n`, `aspect`, `resolution`, `images`) live on the request. */
|
|
9
9
|
export type XAIImageOptions = {
|
|
10
|
+
/** Defaults to `b64_json`; `url` returns a short-lived hosted URL instead. */
|
|
10
11
|
readonly responseFormat?: OpenString<"url" | "b64_json">;
|
|
11
12
|
readonly response_format?: OpenString<"url" | "b64_json">;
|
|
12
13
|
} & Record<string, unknown>;
|
|
@@ -27,10 +27,8 @@ const XAIImageResponse = Schema.Struct({
|
|
|
27
27
|
// 5. Request body construction
|
|
28
28
|
// ---------------------------------------------------------------------------
|
|
29
29
|
const nativeOptions = (options) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const { responseFormat, ...native } = options;
|
|
33
|
-
return { response_format: responseFormat, ...native };
|
|
30
|
+
const { responseFormat, ...native } = options ?? {};
|
|
31
|
+
return { response_format: responseFormat ?? "b64_json", ...native };
|
|
34
32
|
};
|
|
35
33
|
/** xAI renders `1k` or `2k`; other tiers use the nearest one. */
|
|
36
34
|
const resolution = (request) => {
|
|
@@ -21,7 +21,7 @@ export declare const protocol: Protocol<{
|
|
|
21
21
|
readonly role: "developer";
|
|
22
22
|
readonly content: string;
|
|
23
23
|
} | {
|
|
24
|
-
readonly type: "function_call_output";
|
|
24
|
+
readonly type: "custom_tool_call_output" | "function_call_output";
|
|
25
25
|
readonly call_id: string;
|
|
26
26
|
readonly output: string | readonly ({
|
|
27
27
|
readonly type: "input_text";
|
|
@@ -91,6 +91,12 @@ export declare const protocol: Protocol<{
|
|
|
91
91
|
readonly name: string;
|
|
92
92
|
readonly namespace?: string | undefined;
|
|
93
93
|
readonly arguments: string;
|
|
94
|
+
} | {
|
|
95
|
+
readonly type: "custom_tool_call";
|
|
96
|
+
readonly id?: string | undefined;
|
|
97
|
+
readonly call_id: string;
|
|
98
|
+
readonly name: string;
|
|
99
|
+
readonly input: string;
|
|
94
100
|
} | {
|
|
95
101
|
readonly [x: string]: unknown;
|
|
96
102
|
readonly type: "web_search_call";
|
|
@@ -135,6 +141,17 @@ export declare const protocol: Protocol<{
|
|
|
135
141
|
})[];
|
|
136
142
|
readonly instructions?: string | undefined;
|
|
137
143
|
readonly tools?: readonly ({
|
|
144
|
+
readonly type: "custom";
|
|
145
|
+
readonly name: string;
|
|
146
|
+
readonly description: string;
|
|
147
|
+
readonly format: {
|
|
148
|
+
readonly type: "text";
|
|
149
|
+
} | {
|
|
150
|
+
readonly type: "grammar";
|
|
151
|
+
readonly syntax: "lark" | "regex";
|
|
152
|
+
readonly definition: string;
|
|
153
|
+
};
|
|
154
|
+
} | {
|
|
138
155
|
readonly type: "function";
|
|
139
156
|
readonly name: string;
|
|
140
157
|
readonly description: string;
|
|
@@ -147,13 +164,13 @@ export declare const protocol: Protocol<{
|
|
|
147
164
|
readonly type: string;
|
|
148
165
|
})[] | undefined;
|
|
149
166
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
150
|
-
readonly type: "function";
|
|
167
|
+
readonly type: "custom" | "function";
|
|
151
168
|
readonly name: string;
|
|
152
169
|
} | {
|
|
153
170
|
readonly type: "allowed_tools";
|
|
154
171
|
readonly mode: "auto" | "none" | "required";
|
|
155
172
|
readonly tools: readonly {
|
|
156
|
-
readonly type: "function";
|
|
173
|
+
readonly type: "custom" | "function";
|
|
157
174
|
readonly name: string;
|
|
158
175
|
}[];
|
|
159
176
|
} | undefined;
|
|
@@ -4,6 +4,7 @@ import { OpenResponses } from "./open-responses.js";
|
|
|
4
4
|
import { JsonObject, optionalNull, ProviderShared } from "./shared.js";
|
|
5
5
|
import { ResponsesHostedTools } from "./utils/responses-hosted-tools.js";
|
|
6
6
|
import { ResponsesCompaction } from "./utils/responses-compaction.js";
|
|
7
|
+
import { OpenAIFreeform } from "./openai-freeform.js";
|
|
7
8
|
const ADAPTER = "xai-responses";
|
|
8
9
|
const NAME = "xAI Responses";
|
|
9
10
|
const XAIResponsesHostedToolItem = Schema.Union([
|
|
@@ -97,5 +98,5 @@ export const protocol = Protocol.make({
|
|
|
97
98
|
terminal: OpenResponses.terminal,
|
|
98
99
|
},
|
|
99
100
|
});
|
|
100
|
-
export const compact = ResponsesCompaction.make(adapter, (request) => OpenResponses.lowerTools(ProviderShared.flattenTools(request.tools), adapter));
|
|
101
|
+
export const compact = ResponsesCompaction.make(adapter, (request) => OpenResponses.lowerTools(ProviderShared.flattenTools(request.tools), adapter, OpenAIFreeform.tools(request)));
|
|
101
102
|
export * as XAIResponses from "./xai-responses.js";
|
|
@@ -101,7 +101,14 @@ export declare const protocol: Protocol<{
|
|
|
101
101
|
readonly ttl?: string | undefined;
|
|
102
102
|
} | undefined;
|
|
103
103
|
}[] | null;
|
|
104
|
-
readonly tool_calls?: readonly {
|
|
104
|
+
readonly tool_calls?: readonly ({
|
|
105
|
+
readonly id: string;
|
|
106
|
+
readonly type: "custom";
|
|
107
|
+
readonly custom: {
|
|
108
|
+
readonly name: string;
|
|
109
|
+
readonly input: string;
|
|
110
|
+
};
|
|
111
|
+
} | {
|
|
105
112
|
readonly id: string;
|
|
106
113
|
readonly type: "function";
|
|
107
114
|
readonly function: {
|
|
@@ -113,13 +120,13 @@ export declare const protocol: Protocol<{
|
|
|
113
120
|
readonly thought_signature: string;
|
|
114
121
|
};
|
|
115
122
|
} | undefined;
|
|
116
|
-
}[] | undefined;
|
|
123
|
+
})[] | undefined;
|
|
117
124
|
readonly reasoning_content?: string | undefined;
|
|
118
125
|
readonly reasoning?: string | undefined;
|
|
119
126
|
readonly reasoning_text?: string | undefined;
|
|
120
127
|
readonly reasoning_details?: unknown;
|
|
121
128
|
})[];
|
|
122
|
-
readonly tools?: readonly {
|
|
129
|
+
readonly tools?: readonly ({
|
|
123
130
|
readonly type: "function";
|
|
124
131
|
readonly function: {
|
|
125
132
|
readonly name: string;
|
|
@@ -133,12 +140,36 @@ export declare const protocol: Protocol<{
|
|
|
133
140
|
readonly type: "ephemeral";
|
|
134
141
|
readonly ttl?: string | undefined;
|
|
135
142
|
} | undefined;
|
|
136
|
-
}
|
|
143
|
+
} | {
|
|
144
|
+
readonly type: "custom";
|
|
145
|
+
readonly custom: {
|
|
146
|
+
readonly name: string;
|
|
147
|
+
readonly description: string;
|
|
148
|
+
readonly format: {
|
|
149
|
+
readonly type: "text";
|
|
150
|
+
} | {
|
|
151
|
+
readonly type: "grammar";
|
|
152
|
+
readonly grammar: {
|
|
153
|
+
readonly syntax: "lark" | "regex";
|
|
154
|
+
readonly definition: string;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
readonly cache_control?: {
|
|
159
|
+
readonly type: "ephemeral";
|
|
160
|
+
readonly ttl?: string | undefined;
|
|
161
|
+
} | undefined;
|
|
162
|
+
})[] | undefined;
|
|
137
163
|
readonly tool_choice?: "auto" | "none" | "required" | {
|
|
138
164
|
readonly type: "function";
|
|
139
165
|
readonly function: {
|
|
140
166
|
readonly name: string;
|
|
141
167
|
};
|
|
168
|
+
} | {
|
|
169
|
+
readonly type: "custom";
|
|
170
|
+
readonly custom: {
|
|
171
|
+
readonly name: string;
|
|
172
|
+
};
|
|
142
173
|
} | undefined;
|
|
143
174
|
readonly stream: true;
|
|
144
175
|
readonly stream_options?: {
|
|
@@ -196,6 +227,10 @@ export declare const protocol: Protocol<{
|
|
|
196
227
|
readonly name?: string | null | undefined;
|
|
197
228
|
readonly arguments?: string | null | undefined;
|
|
198
229
|
} | null | undefined;
|
|
230
|
+
readonly custom?: {
|
|
231
|
+
readonly name?: string | null | undefined;
|
|
232
|
+
readonly input?: string | null | undefined;
|
|
233
|
+
} | null | undefined;
|
|
199
234
|
readonly extra_content?: unknown;
|
|
200
235
|
}[] | null | undefined;
|
|
201
236
|
} | null | undefined;
|