@opencode/ai 2.0.3 → 2.0.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.
- package/dist/cache-policy.js +10 -2
- package/dist/effort-updates.d.ts +12 -0
- package/dist/effort-updates.js +23 -0
- package/dist/protocols/alibaba-messages.d.ts +4 -1
- package/dist/protocols/alibaba-responses.d.ts +3 -1
- package/dist/protocols/anthropic-messages.d.ts +11 -2
- package/dist/protocols/anthropic-messages.js +48 -17
- package/dist/protocols/bedrock-converse.js +17 -12
- package/dist/protocols/meta-messages.d.ts +4 -1
- package/dist/protocols/meta-responses.d.ts +8 -4
- package/dist/protocols/mistral-chat.js +5 -33
- package/dist/protocols/open-responses-channel.js +4 -0
- package/dist/protocols/open-responses.d.ts +27 -9
- package/dist/protocols/open-responses.js +24 -8
- package/dist/protocols/openai-chat.d.ts +7 -7
- package/dist/protocols/openai-chat.js +10 -4
- package/dist/protocols/openai-compatible-chat.d.ts +1 -1
- package/dist/protocols/openai-compatible-responses.d.ts +4 -2
- package/dist/protocols/openai-responses.d.ts +74 -31
- package/dist/protocols/openai-responses.js +27 -6
- package/dist/protocols/utils/bedrock-media.d.ts +10 -8
- package/dist/protocols/utils/bedrock-media.js +29 -5
- package/dist/protocols/utils/mistral-tool-id.d.ts +5 -0
- package/dist/protocols/utils/mistral-tool-id.js +31 -0
- package/dist/protocols/utils/open-responses-options.d.ts +2 -4
- package/dist/protocols/utils/open-responses-options.js +2 -2
- package/dist/protocols/utils/responses-compaction.js +3 -1
- package/dist/protocols/xai-responses.d.ts +4 -2
- package/dist/protocols/zai-chat.d.ts +1 -1
- package/dist/protocols/zai-messages.d.ts +4 -1
- package/dist/provider-error.js +40 -4
- package/dist/providers/alibaba.d.ts +15 -10
- package/dist/providers/amazon-bedrock-mantle.d.ts +5 -3
- package/dist/providers/anthropic-compatible.d.ts +4 -1
- package/dist/providers/anthropic.d.ts +4 -1
- package/dist/providers/azure.d.ts +19 -5
- package/dist/providers/azure.js +1 -8
- package/dist/providers/baseten.d.ts +2 -2
- package/dist/providers/cerebras.d.ts +2 -2
- package/dist/providers/cerebras.js +1 -1
- package/dist/providers/cloudflare-ai-gateway.d.ts +1024 -13
- package/dist/providers/cloudflare-ai-gateway.js +64 -27
- package/dist/providers/cloudflare-workers-ai.d.ts +3 -3
- package/dist/providers/cloudflare-workers-ai.js +1 -1
- package/dist/providers/deepinfra.d.ts +2 -2
- package/dist/providers/deepinfra.js +1 -1
- package/dist/providers/deepseek.d.ts +2 -2
- package/dist/providers/fireworks.d.ts +2 -2
- package/dist/providers/fireworks.js +1 -1
- package/dist/providers/google-vertex-chat.d.ts +1 -1
- package/dist/providers/google-vertex-messages.d.ts +4 -1
- package/dist/providers/google-vertex-responses.d.ts +4 -2
- package/dist/providers/google-vertex.js +5 -1
- package/dist/providers/groq.d.ts +2 -2
- package/dist/providers/meta.d.ts +9 -4
- package/dist/providers/meta.js +1 -1
- package/dist/providers/minimax.d.ts +9 -4
- package/dist/providers/moonshot.d.ts +9 -4
- package/dist/providers/moonshot.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +4 -2
- package/dist/providers/openai-compatible.d.ts +1 -1
- package/dist/providers/openai.d.ts +10 -3
- package/dist/providers/openai.js +4 -1
- package/dist/providers/openrouter.d.ts +4 -4
- package/dist/providers/openrouter.js +1 -1
- package/dist/providers/togetherai.d.ts +2 -2
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/zai-coding-plan.d.ts +9 -4
- package/dist/providers/zai.d.ts +1 -1
- package/dist/route/client.d.ts +1 -0
- package/dist/route/client.js +3 -1
- package/dist/route/protocol.d.ts +2 -0
- package/dist/schema/messages.d.ts +22 -3
- package/dist/schema/messages.js +9 -1
- package/dist/schema/options.d.ts +6 -0
- package/dist/schema/options.js +7 -0
- package/package.json +3 -3
|
@@ -3,6 +3,7 @@ import { Route } from "../route/client.js";
|
|
|
3
3
|
import { Protocol } from "../route/protocol.js";
|
|
4
4
|
import { HttpTransport } from "../route/transport/index.js";
|
|
5
5
|
import { OpenResponses } from "./open-responses.js";
|
|
6
|
+
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
6
7
|
export declare const DEFAULT_BASE_URL = "https://api.openai.com/v1";
|
|
7
8
|
export declare const PATH = "/responses";
|
|
8
9
|
export declare const ContextManagement: Schema.$Array<Schema.Struct<{
|
|
@@ -17,12 +18,15 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
17
18
|
readonly id: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
18
19
|
readonly encrypted_content: Schema.String;
|
|
19
20
|
}>, Schema.Struct<{
|
|
21
|
+
readonly type: Schema.tag<"message">;
|
|
20
22
|
readonly role: Schema.tag<"system">;
|
|
21
23
|
readonly content: Schema.String;
|
|
22
24
|
}>, Schema.Struct<{
|
|
25
|
+
readonly type: Schema.tag<"message">;
|
|
23
26
|
readonly role: Schema.tag<"developer">;
|
|
24
27
|
readonly content: Schema.String;
|
|
25
28
|
}>, Schema.Struct<{
|
|
29
|
+
readonly type: Schema.tag<"message">;
|
|
26
30
|
readonly role: Schema.tag<"user">;
|
|
27
31
|
readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
28
32
|
readonly type: Schema.tag<"input_text">;
|
|
@@ -38,7 +42,6 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
38
42
|
readonly file_data: Schema.optional<Schema.String>;
|
|
39
43
|
readonly file_url: Schema.optional<Schema.String>;
|
|
40
44
|
}>]>]>>;
|
|
41
|
-
readonly type: Schema.optional<Schema.Literal<"message">>;
|
|
42
45
|
readonly id: Schema.optional<Schema.String>;
|
|
43
46
|
readonly status: Schema.optional<Schema.String>;
|
|
44
47
|
}>, Schema.Struct<{
|
|
@@ -132,7 +135,12 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
132
135
|
readonly result: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
133
136
|
readonly output_format: Schema.optional<Schema.Literals<readonly ["png", "jpeg", "webp"]>>;
|
|
134
137
|
readonly revised_prompt: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
135
|
-
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>]
|
|
138
|
+
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>]>, Schema.Struct<{
|
|
139
|
+
readonly type: Schema.Literal<"configuration_update">;
|
|
140
|
+
readonly reasoning: Schema.Struct<{
|
|
141
|
+
readonly effort: Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>;
|
|
142
|
+
}>;
|
|
143
|
+
}>]>>;
|
|
136
144
|
readonly tools: Schema.optional<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
137
145
|
readonly type: Schema.tag<"function">;
|
|
138
146
|
readonly name: Schema.String;
|
|
@@ -188,15 +196,15 @@ declare const OpenAIResponsesBody: Schema.Struct<{
|
|
|
188
196
|
}>>;
|
|
189
197
|
readonly top_logprobs: Schema.optional<Schema.Int>;
|
|
190
198
|
readonly truncation: Schema.optional<Schema.Literals<readonly ["auto", "disabled"]>>;
|
|
191
|
-
readonly service_tier: Schema.optional<Schema.declare<
|
|
199
|
+
readonly service_tier: Schema.optional<Schema.declare<OpenResponsesOptions.ServiceTier, OpenResponsesOptions.ServiceTier>>;
|
|
192
200
|
readonly prompt_cache_key: Schema.optional<Schema.String>;
|
|
193
|
-
readonly include: Schema.optional<Schema.$Array<Schema.declare<
|
|
201
|
+
readonly include: Schema.optional<Schema.$Array<Schema.declare<OpenResponsesOptions.ResponseIncludable, OpenResponsesOptions.ResponseIncludable>>>;
|
|
194
202
|
readonly reasoning: Schema.optional<Schema.Struct<{
|
|
195
|
-
readonly effort: Schema.optional<Schema.declare<
|
|
203
|
+
readonly effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
196
204
|
readonly summary: Schema.optional<Schema.Literals<readonly ["auto", "concise", "detailed"]>>;
|
|
197
205
|
}>>;
|
|
198
206
|
readonly text: Schema.optional<Schema.Struct<{
|
|
199
|
-
readonly verbosity: Schema.optional<Schema.declare<
|
|
207
|
+
readonly verbosity: Schema.optional<Schema.declare<OpenResponsesOptions.TextVerbosity, OpenResponsesOptions.TextVerbosity>>;
|
|
200
208
|
}>>;
|
|
201
209
|
readonly max_output_tokens: Schema.optional<Schema.Number>;
|
|
202
210
|
readonly max_tool_calls: Schema.optional<Schema.Int>;
|
|
@@ -249,6 +257,11 @@ export declare const protocol: Protocol<{
|
|
|
249
257
|
readonly error?: unknown;
|
|
250
258
|
readonly arguments?: string | undefined;
|
|
251
259
|
readonly server_label?: string | undefined;
|
|
260
|
+
} | {
|
|
261
|
+
readonly type: "configuration_update";
|
|
262
|
+
readonly reasoning: {
|
|
263
|
+
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
264
|
+
};
|
|
252
265
|
} | {
|
|
253
266
|
readonly type: "reasoning";
|
|
254
267
|
readonly summary: readonly {
|
|
@@ -262,12 +275,15 @@ export declare const protocol: Protocol<{
|
|
|
262
275
|
readonly encrypted_content: string;
|
|
263
276
|
readonly id?: string | null | undefined;
|
|
264
277
|
} | {
|
|
278
|
+
readonly type: "message";
|
|
265
279
|
readonly role: "system";
|
|
266
280
|
readonly content: string;
|
|
267
281
|
} | {
|
|
282
|
+
readonly type: "message";
|
|
268
283
|
readonly role: "developer";
|
|
269
284
|
readonly content: string;
|
|
270
285
|
} | {
|
|
286
|
+
readonly type: "message";
|
|
271
287
|
readonly content: readonly ({
|
|
272
288
|
readonly type: "input_image";
|
|
273
289
|
readonly image_url: string;
|
|
@@ -284,7 +300,6 @@ export declare const protocol: Protocol<{
|
|
|
284
300
|
})[];
|
|
285
301
|
readonly role: "user";
|
|
286
302
|
readonly id?: string | undefined;
|
|
287
|
-
readonly type?: "message" | undefined;
|
|
288
303
|
readonly status?: string | undefined;
|
|
289
304
|
} | {
|
|
290
305
|
readonly type: "message";
|
|
@@ -360,7 +375,7 @@ export declare const protocol: Protocol<{
|
|
|
360
375
|
readonly instructions?: string | undefined;
|
|
361
376
|
readonly reasoning?: {
|
|
362
377
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
363
|
-
readonly effort?:
|
|
378
|
+
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
364
379
|
} | undefined;
|
|
365
380
|
readonly tools?: readonly ({
|
|
366
381
|
readonly type: "function";
|
|
@@ -395,10 +410,10 @@ export declare const protocol: Protocol<{
|
|
|
395
410
|
}[];
|
|
396
411
|
})[] | undefined;
|
|
397
412
|
readonly text?: {
|
|
398
|
-
readonly verbosity?:
|
|
413
|
+
readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
|
|
399
414
|
} | undefined;
|
|
400
415
|
readonly temperature?: number | undefined;
|
|
401
|
-
readonly service_tier?:
|
|
416
|
+
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
|
|
402
417
|
readonly context_management?: readonly {
|
|
403
418
|
readonly type: "compaction";
|
|
404
419
|
readonly compact_threshold?: number | undefined;
|
|
@@ -422,7 +437,7 @@ export declare const protocol: Protocol<{
|
|
|
422
437
|
readonly prompt_cache_key?: string | undefined;
|
|
423
438
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
424
439
|
readonly store?: boolean | undefined;
|
|
425
|
-
readonly include?: readonly
|
|
440
|
+
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
426
441
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
427
442
|
readonly stream_options?: {
|
|
428
443
|
readonly include_obfuscation?: boolean | undefined;
|
|
@@ -537,6 +552,11 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
537
552
|
readonly error?: unknown;
|
|
538
553
|
readonly arguments?: string | undefined;
|
|
539
554
|
readonly server_label?: string | undefined;
|
|
555
|
+
} | {
|
|
556
|
+
readonly type: "configuration_update";
|
|
557
|
+
readonly reasoning: {
|
|
558
|
+
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
559
|
+
};
|
|
540
560
|
} | {
|
|
541
561
|
readonly type: "reasoning";
|
|
542
562
|
readonly summary: readonly {
|
|
@@ -550,12 +570,15 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
550
570
|
readonly encrypted_content: string;
|
|
551
571
|
readonly id?: string | null | undefined;
|
|
552
572
|
} | {
|
|
573
|
+
readonly type: "message";
|
|
553
574
|
readonly role: "system";
|
|
554
575
|
readonly content: string;
|
|
555
576
|
} | {
|
|
577
|
+
readonly type: "message";
|
|
556
578
|
readonly role: "developer";
|
|
557
579
|
readonly content: string;
|
|
558
580
|
} | {
|
|
581
|
+
readonly type: "message";
|
|
559
582
|
readonly content: readonly ({
|
|
560
583
|
readonly type: "input_image";
|
|
561
584
|
readonly image_url: string;
|
|
@@ -572,7 +595,6 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
572
595
|
})[];
|
|
573
596
|
readonly role: "user";
|
|
574
597
|
readonly id?: string | undefined;
|
|
575
|
-
readonly type?: "message" | undefined;
|
|
576
598
|
readonly status?: string | undefined;
|
|
577
599
|
} | {
|
|
578
600
|
readonly type: "message";
|
|
@@ -648,7 +670,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
648
670
|
readonly instructions?: string | undefined;
|
|
649
671
|
readonly reasoning?: {
|
|
650
672
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
651
|
-
readonly effort?:
|
|
673
|
+
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
652
674
|
} | undefined;
|
|
653
675
|
readonly tools?: readonly ({
|
|
654
676
|
readonly type: "function";
|
|
@@ -683,10 +705,10 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
683
705
|
}[];
|
|
684
706
|
})[] | undefined;
|
|
685
707
|
readonly text?: {
|
|
686
|
-
readonly verbosity?:
|
|
708
|
+
readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
|
|
687
709
|
} | undefined;
|
|
688
710
|
readonly temperature?: number | undefined;
|
|
689
|
-
readonly service_tier?:
|
|
711
|
+
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
|
|
690
712
|
readonly context_management?: readonly {
|
|
691
713
|
readonly type: "compaction";
|
|
692
714
|
readonly compact_threshold?: number | undefined;
|
|
@@ -710,7 +732,7 @@ export declare const httpTransport: HttpTransport.HttpJsonTransport<{
|
|
|
710
732
|
readonly prompt_cache_key?: string | undefined;
|
|
711
733
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
712
734
|
readonly store?: boolean | undefined;
|
|
713
|
-
readonly include?: readonly
|
|
735
|
+
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
714
736
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
715
737
|
readonly stream_options?: {
|
|
716
738
|
readonly include_obfuscation?: boolean | undefined;
|
|
@@ -758,6 +780,11 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
758
780
|
readonly error?: unknown;
|
|
759
781
|
readonly arguments?: string | undefined;
|
|
760
782
|
readonly server_label?: string | undefined;
|
|
783
|
+
} | {
|
|
784
|
+
readonly type: "configuration_update";
|
|
785
|
+
readonly reasoning: {
|
|
786
|
+
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
787
|
+
};
|
|
761
788
|
} | {
|
|
762
789
|
readonly type: "reasoning";
|
|
763
790
|
readonly summary: readonly {
|
|
@@ -771,12 +798,15 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
771
798
|
readonly encrypted_content: string;
|
|
772
799
|
readonly id?: string | null | undefined;
|
|
773
800
|
} | {
|
|
801
|
+
readonly type: "message";
|
|
774
802
|
readonly role: "system";
|
|
775
803
|
readonly content: string;
|
|
776
804
|
} | {
|
|
805
|
+
readonly type: "message";
|
|
777
806
|
readonly role: "developer";
|
|
778
807
|
readonly content: string;
|
|
779
808
|
} | {
|
|
809
|
+
readonly type: "message";
|
|
780
810
|
readonly content: readonly ({
|
|
781
811
|
readonly type: "input_image";
|
|
782
812
|
readonly image_url: string;
|
|
@@ -793,7 +823,6 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
793
823
|
})[];
|
|
794
824
|
readonly role: "user";
|
|
795
825
|
readonly id?: string | undefined;
|
|
796
|
-
readonly type?: "message" | undefined;
|
|
797
826
|
readonly status?: string | undefined;
|
|
798
827
|
} | {
|
|
799
828
|
readonly type: "message";
|
|
@@ -869,7 +898,7 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
869
898
|
readonly instructions?: string | undefined;
|
|
870
899
|
readonly reasoning?: {
|
|
871
900
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
872
|
-
readonly effort?:
|
|
901
|
+
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
873
902
|
} | undefined;
|
|
874
903
|
readonly tools?: readonly ({
|
|
875
904
|
readonly type: "function";
|
|
@@ -904,10 +933,10 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
904
933
|
}[];
|
|
905
934
|
})[] | undefined;
|
|
906
935
|
readonly text?: {
|
|
907
|
-
readonly verbosity?:
|
|
936
|
+
readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
|
|
908
937
|
} | undefined;
|
|
909
938
|
readonly temperature?: number | undefined;
|
|
910
|
-
readonly service_tier?:
|
|
939
|
+
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
|
|
911
940
|
readonly context_management?: readonly {
|
|
912
941
|
readonly type: "compaction";
|
|
913
942
|
readonly compact_threshold?: number | undefined;
|
|
@@ -931,7 +960,7 @@ export declare const channelTransport: (options: import("./open-responses-channe
|
|
|
931
960
|
readonly prompt_cache_key?: string | undefined;
|
|
932
961
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
933
962
|
readonly store?: boolean | undefined;
|
|
934
|
-
readonly include?: readonly
|
|
963
|
+
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
935
964
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
936
965
|
readonly stream_options?: {
|
|
937
966
|
readonly include_obfuscation?: boolean | undefined;
|
|
@@ -979,6 +1008,11 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
979
1008
|
readonly error?: unknown;
|
|
980
1009
|
readonly arguments?: string | undefined;
|
|
981
1010
|
readonly server_label?: string | undefined;
|
|
1011
|
+
} | {
|
|
1012
|
+
readonly type: "configuration_update";
|
|
1013
|
+
readonly reasoning: {
|
|
1014
|
+
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
1015
|
+
};
|
|
982
1016
|
} | {
|
|
983
1017
|
readonly type: "reasoning";
|
|
984
1018
|
readonly summary: readonly {
|
|
@@ -992,12 +1026,15 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
992
1026
|
readonly encrypted_content: string;
|
|
993
1027
|
readonly id?: string | null | undefined;
|
|
994
1028
|
} | {
|
|
1029
|
+
readonly type: "message";
|
|
995
1030
|
readonly role: "system";
|
|
996
1031
|
readonly content: string;
|
|
997
1032
|
} | {
|
|
1033
|
+
readonly type: "message";
|
|
998
1034
|
readonly role: "developer";
|
|
999
1035
|
readonly content: string;
|
|
1000
1036
|
} | {
|
|
1037
|
+
readonly type: "message";
|
|
1001
1038
|
readonly content: readonly ({
|
|
1002
1039
|
readonly type: "input_image";
|
|
1003
1040
|
readonly image_url: string;
|
|
@@ -1014,7 +1051,6 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1014
1051
|
})[];
|
|
1015
1052
|
readonly role: "user";
|
|
1016
1053
|
readonly id?: string | undefined;
|
|
1017
|
-
readonly type?: "message" | undefined;
|
|
1018
1054
|
readonly status?: string | undefined;
|
|
1019
1055
|
} | {
|
|
1020
1056
|
readonly type: "message";
|
|
@@ -1090,7 +1126,7 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1090
1126
|
readonly instructions?: string | undefined;
|
|
1091
1127
|
readonly reasoning?: {
|
|
1092
1128
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
1093
|
-
readonly effort?:
|
|
1129
|
+
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1094
1130
|
} | undefined;
|
|
1095
1131
|
readonly tools?: readonly ({
|
|
1096
1132
|
readonly type: "function";
|
|
@@ -1125,10 +1161,10 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1125
1161
|
}[];
|
|
1126
1162
|
})[] | undefined;
|
|
1127
1163
|
readonly text?: {
|
|
1128
|
-
readonly verbosity?:
|
|
1164
|
+
readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
|
|
1129
1165
|
} | undefined;
|
|
1130
1166
|
readonly temperature?: number | undefined;
|
|
1131
|
-
readonly service_tier?:
|
|
1167
|
+
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
|
|
1132
1168
|
readonly context_management?: readonly {
|
|
1133
1169
|
readonly type: "compaction";
|
|
1134
1170
|
readonly compact_threshold?: number | undefined;
|
|
@@ -1152,7 +1188,7 @@ export declare const transport: import("../route/transport/index.js").Transport<
|
|
|
1152
1188
|
readonly prompt_cache_key?: string | undefined;
|
|
1153
1189
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
1154
1190
|
readonly store?: boolean | undefined;
|
|
1155
|
-
readonly include?: readonly
|
|
1191
|
+
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
1156
1192
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
1157
1193
|
readonly stream_options?: {
|
|
1158
1194
|
readonly include_obfuscation?: boolean | undefined;
|
|
@@ -1200,6 +1236,11 @@ export declare const route: Route<{
|
|
|
1200
1236
|
readonly error?: unknown;
|
|
1201
1237
|
readonly arguments?: string | undefined;
|
|
1202
1238
|
readonly server_label?: string | undefined;
|
|
1239
|
+
} | {
|
|
1240
|
+
readonly type: "configuration_update";
|
|
1241
|
+
readonly reasoning: {
|
|
1242
|
+
readonly effort: OpenResponsesOptions.ReasoningEffort;
|
|
1243
|
+
};
|
|
1203
1244
|
} | {
|
|
1204
1245
|
readonly type: "reasoning";
|
|
1205
1246
|
readonly summary: readonly {
|
|
@@ -1213,12 +1254,15 @@ export declare const route: Route<{
|
|
|
1213
1254
|
readonly encrypted_content: string;
|
|
1214
1255
|
readonly id?: string | null | undefined;
|
|
1215
1256
|
} | {
|
|
1257
|
+
readonly type: "message";
|
|
1216
1258
|
readonly role: "system";
|
|
1217
1259
|
readonly content: string;
|
|
1218
1260
|
} | {
|
|
1261
|
+
readonly type: "message";
|
|
1219
1262
|
readonly role: "developer";
|
|
1220
1263
|
readonly content: string;
|
|
1221
1264
|
} | {
|
|
1265
|
+
readonly type: "message";
|
|
1222
1266
|
readonly content: readonly ({
|
|
1223
1267
|
readonly type: "input_image";
|
|
1224
1268
|
readonly image_url: string;
|
|
@@ -1235,7 +1279,6 @@ export declare const route: Route<{
|
|
|
1235
1279
|
})[];
|
|
1236
1280
|
readonly role: "user";
|
|
1237
1281
|
readonly id?: string | undefined;
|
|
1238
|
-
readonly type?: "message" | undefined;
|
|
1239
1282
|
readonly status?: string | undefined;
|
|
1240
1283
|
} | {
|
|
1241
1284
|
readonly type: "message";
|
|
@@ -1311,7 +1354,7 @@ export declare const route: Route<{
|
|
|
1311
1354
|
readonly instructions?: string | undefined;
|
|
1312
1355
|
readonly reasoning?: {
|
|
1313
1356
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
1314
|
-
readonly effort?:
|
|
1357
|
+
readonly effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
1315
1358
|
} | undefined;
|
|
1316
1359
|
readonly tools?: readonly ({
|
|
1317
1360
|
readonly type: "function";
|
|
@@ -1346,10 +1389,10 @@ export declare const route: Route<{
|
|
|
1346
1389
|
}[];
|
|
1347
1390
|
})[] | undefined;
|
|
1348
1391
|
readonly text?: {
|
|
1349
|
-
readonly verbosity?:
|
|
1392
|
+
readonly verbosity?: OpenResponsesOptions.TextVerbosity | undefined;
|
|
1350
1393
|
} | undefined;
|
|
1351
1394
|
readonly temperature?: number | undefined;
|
|
1352
|
-
readonly service_tier?:
|
|
1395
|
+
readonly service_tier?: OpenResponsesOptions.ServiceTier | undefined;
|
|
1353
1396
|
readonly context_management?: readonly {
|
|
1354
1397
|
readonly type: "compaction";
|
|
1355
1398
|
readonly compact_threshold?: number | undefined;
|
|
@@ -1373,7 +1416,7 @@ export declare const route: Route<{
|
|
|
1373
1416
|
readonly prompt_cache_key?: string | undefined;
|
|
1374
1417
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
1375
1418
|
readonly store?: boolean | undefined;
|
|
1376
|
-
readonly include?: readonly
|
|
1419
|
+
readonly include?: readonly OpenResponsesOptions.ResponseIncludable[] | undefined;
|
|
1377
1420
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
1378
1421
|
readonly stream_options?: {
|
|
1379
1422
|
readonly include_obfuscation?: boolean | undefined;
|
|
@@ -6,7 +6,9 @@ import { Endpoint } from "../route/endpoint.js";
|
|
|
6
6
|
import { Protocol } from "../route/protocol.js";
|
|
7
7
|
import { HttpTransport } from "../route/transport/index.js";
|
|
8
8
|
import { LLMRequest, mergeJsonRecords } from "../schema/index.js";
|
|
9
|
+
import { resolveEffortUpdates } from "../effort-updates.js";
|
|
9
10
|
import { OpenResponses } from "./open-responses.js";
|
|
11
|
+
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
10
12
|
import { JsonObject, optionalArray, optionalNull, ProviderShared } from "./shared.js";
|
|
11
13
|
import { OpenAIImage } from "./utils/openai-image.js";
|
|
12
14
|
import { ResponsesHostedTools } from "./utils/responses-hosted-tools.js";
|
|
@@ -74,9 +76,14 @@ const OpenAIResponsesToolChoice = Schema.Union([
|
|
|
74
76
|
OpenResponses.ToolChoice,
|
|
75
77
|
Schema.Struct({ type: Schema.tag("image_generation") }),
|
|
76
78
|
]);
|
|
79
|
+
const OpenAIResponsesInputItem = Schema.Union([
|
|
80
|
+
OpenResponses.InputItem,
|
|
81
|
+
OpenAIResponsesHostedToolItem,
|
|
82
|
+
OpenResponses.ConfigurationUpdate,
|
|
83
|
+
]);
|
|
77
84
|
const OpenAIResponsesCoreFields = {
|
|
78
85
|
...OpenResponses.coreFields,
|
|
79
|
-
input: Schema.Array(
|
|
86
|
+
input: Schema.Array(OpenAIResponsesInputItem),
|
|
80
87
|
tools: optionalArray(OpenAIResponsesTools),
|
|
81
88
|
tool_choice: Schema.optional(OpenAIResponsesToolChoice),
|
|
82
89
|
context_management: Schema.optional(Schema.Array(Schema.Struct({
|
|
@@ -92,7 +99,7 @@ const OpenAIResponsesBody = Schema.Struct({
|
|
|
92
99
|
export const CompactionTrigger = Schema.Struct({ type: Schema.Literal("compaction_trigger") });
|
|
93
100
|
const CheckpointBody = Schema.Struct({
|
|
94
101
|
...OpenAIResponsesBody.fields,
|
|
95
|
-
input: Schema.Array(Schema.Union([
|
|
102
|
+
input: Schema.Array(Schema.Union([OpenAIResponsesInputItem, CompactionTrigger])),
|
|
96
103
|
store: Schema.Literal(false),
|
|
97
104
|
prompt_cache_retention: optionalNull(Schema.String),
|
|
98
105
|
prompt_cache_options: optionalNull(Schema.Struct({ mode: Schema.optional(Schema.String), ttl: Schema.optional(Schema.String) })),
|
|
@@ -102,6 +109,15 @@ const adapter = {
|
|
|
102
109
|
name: NAME,
|
|
103
110
|
restoreHostedToolItem: (item) => (Schema.is(OpenAIResponsesHostedToolItem)(item) ? item : undefined),
|
|
104
111
|
};
|
|
112
|
+
// Only GPT-6 Astra accepts `configuration_update`, and never alongside automatic `context_management` compaction.
|
|
113
|
+
const supportsEffortUpdates = (request) => {
|
|
114
|
+
if (request.providerOptions?.contextManagement !== undefined)
|
|
115
|
+
return false;
|
|
116
|
+
const override = request.model.compatibility?.supportsEffortUpdates;
|
|
117
|
+
if (override !== undefined)
|
|
118
|
+
return override;
|
|
119
|
+
return /(?:^|\/)gpt-6-astra$/i.test(request.model.id);
|
|
120
|
+
};
|
|
105
121
|
const nativeImageToolInput = (tool) => {
|
|
106
122
|
const native = tool.native?.openai;
|
|
107
123
|
return ProviderShared.isRecord(native) && native.type === "image_generation" ? native : undefined;
|
|
@@ -144,16 +160,20 @@ const lowerToolChoice = (toolChoice, tools) => ProviderShared.matchToolChoice(NA
|
|
|
144
160
|
const decodeBody = ProviderShared.validateWith(Schema.decodeUnknownEffect(OpenAIResponsesBody));
|
|
145
161
|
const fromRequest = Effect.fn("OpenAIResponses.fromRequest")(function* (request) {
|
|
146
162
|
const management = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Schema.UndefinedOr(ContextManagement)))(request.providerOptions?.contextManagement);
|
|
163
|
+
const options = OpenResponsesOptions.resolve(request);
|
|
164
|
+
const updates = resolveEffortUpdates(request, options.reasoningEffort);
|
|
147
165
|
const toolSchemaCompatibility = request.model.compatibility?.toolSchema;
|
|
148
166
|
return yield* decodeBody({
|
|
149
|
-
...(yield* OpenResponses.lowerConversation(request, adapter)),
|
|
150
|
-
...OpenResponses.lowerGeneration(request),
|
|
167
|
+
...(yield* OpenResponses.lowerConversation(updates.request, adapter)),
|
|
168
|
+
...OpenResponses.lowerGeneration(request, { ...options, reasoningEffort: updates.effort }),
|
|
151
169
|
context_management: management?.map((edit) => ({ type: edit.type, compact_threshold: edit.compactThreshold })),
|
|
152
170
|
tools: request.tools.length === 0
|
|
153
171
|
? undefined
|
|
154
172
|
: yield* Effect.forEach(request.tools, (tool) => lowerToolEntry(tool, toolSchemaCompatibility)),
|
|
155
|
-
tool_choice:
|
|
156
|
-
|
|
173
|
+
tool_choice: request.tools.length === 0
|
|
174
|
+
? undefined
|
|
175
|
+
: (OpenResponses.allowedToolChoice(request) ??
|
|
176
|
+
(request.toolChoice ? yield* lowerToolChoice(request.toolChoice, request.tools) : undefined)),
|
|
157
177
|
});
|
|
158
178
|
});
|
|
159
179
|
const checkpointBody = {
|
|
@@ -235,6 +255,7 @@ export const protocol = Protocol.make({
|
|
|
235
255
|
step,
|
|
236
256
|
terminal: OpenResponses.terminal,
|
|
237
257
|
},
|
|
258
|
+
supportsEffortUpdates,
|
|
238
259
|
});
|
|
239
260
|
const endpoint = Endpoint.path(PATH, { baseURL: DEFAULT_BASE_URL });
|
|
240
261
|
const auth = Auth.none;
|
|
@@ -36,7 +36,14 @@ export declare const lower: (part: {
|
|
|
36
36
|
};
|
|
37
37
|
} | undefined;
|
|
38
38
|
readonly filename?: string | undefined;
|
|
39
|
-
}) => Effect.Effect<{
|
|
39
|
+
}, documentNames: Set<string>) => Effect.Effect<{
|
|
40
|
+
image: {
|
|
41
|
+
format: "png" | "jpeg" | "gif" | "webp";
|
|
42
|
+
source: {
|
|
43
|
+
bytes: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}[] | ({
|
|
40
47
|
readonly document: {
|
|
41
48
|
readonly format: "pdf" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html" | "txt" | "md";
|
|
42
49
|
readonly name: string;
|
|
@@ -45,11 +52,6 @@ export declare const lower: (part: {
|
|
|
45
52
|
};
|
|
46
53
|
};
|
|
47
54
|
} | {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
source: {
|
|
51
|
-
bytes: string;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
}, import("../../schema/errors.js").AIError, never>;
|
|
55
|
+
text: string;
|
|
56
|
+
})[], import("../../schema/errors.js").AIError, never>;
|
|
55
57
|
export * as BedrockMedia from "./bedrock-media.js";
|
|
@@ -44,6 +44,23 @@ const documentBlock = (name, format, bytes) => ({
|
|
|
44
44
|
source: { bytes },
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
|
+
function documentName(filename, names) {
|
|
48
|
+
const base = (filename ?? "")
|
|
49
|
+
.replace(/\.[^.]*$/, "")
|
|
50
|
+
.replace(/[^a-zA-Z0-9 ()[\]-]/g, " ")
|
|
51
|
+
.replace(/\s+/g, " ")
|
|
52
|
+
.trim()
|
|
53
|
+
.slice(0, 200)
|
|
54
|
+
.trim() || "document";
|
|
55
|
+
let name = base;
|
|
56
|
+
// Converse requires labels to be unique across the entire request, including tool results.
|
|
57
|
+
for (let index = 2; names.has(name); index++) {
|
|
58
|
+
const suffix = ` ${index}`;
|
|
59
|
+
name = `${base.slice(0, 200 - suffix.length).trimEnd()}${suffix}`;
|
|
60
|
+
}
|
|
61
|
+
names.add(name);
|
|
62
|
+
return name;
|
|
63
|
+
}
|
|
47
64
|
const mediaBase64 = Effect.fn("BedrockMedia.mediaBase64")(function* (part) {
|
|
48
65
|
const media = ProviderShared.normalizeMedia(part);
|
|
49
66
|
const bytes = yield* Effect.fromResult(Encoding.decodeBase64(media.base64)).pipe(Effect.mapError((cause) => ProviderShared.invalidRequest("Bedrock Converse media data must be valid base64", cause)));
|
|
@@ -54,19 +71,26 @@ const mediaBase64 = Effect.fn("BedrockMedia.mediaBase64")(function* (part) {
|
|
|
54
71
|
// document block. Image MIME types not in `IMAGE_FORMATS` (e.g. `image/svg+xml`)
|
|
55
72
|
// get an image-specific error so the caller knows it's a format-support issue,
|
|
56
73
|
// not a kind-detection issue.
|
|
57
|
-
export const lower = Effect.fn("BedrockMedia.lower")(function* (part) {
|
|
74
|
+
export const lower = Effect.fn("BedrockMedia.lower")(function* (part, documentNames) {
|
|
58
75
|
const mime = part.mediaType.toLowerCase();
|
|
59
76
|
const imageFormat = IMAGE_FORMATS[mime];
|
|
60
77
|
if (imageFormat) {
|
|
61
|
-
return { image: { format: imageFormat, source: { bytes: yield* mediaBase64(part) } } };
|
|
78
|
+
return [{ image: { format: imageFormat, source: { bytes: yield* mediaBase64(part) } } }];
|
|
62
79
|
}
|
|
63
80
|
if (mime.startsWith("image/"))
|
|
64
81
|
return yield* ProviderShared.invalidRequest(`Bedrock Converse does not support image media type ${part.mediaType}`);
|
|
65
82
|
const documentFormat = DOCUMENT_FORMATS[mime];
|
|
66
83
|
if (documentFormat) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return
|
|
84
|
+
const name = documentName(part.filename, documentNames);
|
|
85
|
+
const block = documentBlock(name, documentFormat, yield* mediaBase64(part));
|
|
86
|
+
return part.filename !== undefined && part.filename !== name
|
|
87
|
+
? [
|
|
88
|
+
{
|
|
89
|
+
text: `Attached file ${ProviderShared.encodeJson(part.filename)} has document label ${ProviderShared.encodeJson(name)}.`,
|
|
90
|
+
},
|
|
91
|
+
block,
|
|
92
|
+
]
|
|
93
|
+
: [block];
|
|
70
94
|
}
|
|
71
95
|
return yield* ProviderShared.invalidRequest(`Bedrock Converse does not support media type ${part.mediaType}`);
|
|
72
96
|
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { LLMRequest } from "../../schema/index.js";
|
|
2
|
+
export declare const valid: RegExp;
|
|
3
|
+
export declare const hash: (value: string) => string;
|
|
4
|
+
export declare const normalizer: (request: LLMRequest) => (id: string) => string;
|
|
5
|
+
export * as MistralToolID from "./mistral-tool-id.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const valid = /^[A-Za-z0-9]{9}$/;
|
|
2
|
+
export const hash = (value) => {
|
|
3
|
+
const hash = (seed) => {
|
|
4
|
+
let result = seed;
|
|
5
|
+
for (const char of value)
|
|
6
|
+
result = Math.imul(result ^ char.charCodeAt(0), 16777619);
|
|
7
|
+
return (result >>> 0).toString(36);
|
|
8
|
+
};
|
|
9
|
+
return `${hash(2166136261).padStart(7, "0")}${hash(2246822519).padStart(7, "0")}`.slice(-9);
|
|
10
|
+
};
|
|
11
|
+
export const normalizer = (request) => {
|
|
12
|
+
const ids = request.messages.flatMap((message) => message.content.flatMap((part) => (part.type === "tool-call" || part.type === "tool-result" ? [part.id] : [])));
|
|
13
|
+
// Reserve valid IDs before projecting any history, including IDs encountered later.
|
|
14
|
+
const used = new Set(ids.filter((id) => valid.test(id)));
|
|
15
|
+
const normalized = new Map();
|
|
16
|
+
return (id) => {
|
|
17
|
+
if (valid.test(id))
|
|
18
|
+
return id;
|
|
19
|
+
const previous = normalized.get(id);
|
|
20
|
+
if (previous)
|
|
21
|
+
return previous;
|
|
22
|
+
let attempt = 0;
|
|
23
|
+
let candidate = hash(id);
|
|
24
|
+
while (used.has(candidate))
|
|
25
|
+
candidate = hash(`${id}:${++attempt}`);
|
|
26
|
+
used.add(candidate);
|
|
27
|
+
normalized.set(id, candidate);
|
|
28
|
+
return candidate;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export * as MistralToolID from "./mistral-tool-id.js";
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import type
|
|
3
|
-
export
|
|
4
|
-
export type ReasoningEffort = (typeof ReasoningEfforts)[number] | (string & {});
|
|
5
|
-
export declare const ReasoningEffort: Schema.declare<ReasoningEffort, ReasoningEffort>;
|
|
2
|
+
import { ReasoningEffort, ReasoningEfforts, type LLMRequest } from "../../schema/index.js";
|
|
3
|
+
export { ReasoningEffort, ReasoningEfforts };
|
|
6
4
|
export declare const TextVerbosities: readonly ["low", "medium", "high"];
|
|
7
5
|
export type TextVerbosity = (typeof TextVerbosities)[number] | (string & {});
|
|
8
6
|
export declare const TextVerbosity: Schema.declare<TextVerbosity, TextVerbosity>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Option, Schema } from "effect";
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
import { ReasoningEffort, ReasoningEfforts } from "../../schema/index.js";
|
|
3
|
+
export { ReasoningEffort, ReasoningEfforts };
|
|
4
4
|
export const TextVerbosities = ["low", "medium", "high"];
|
|
5
5
|
export const TextVerbosity = Schema.declare((value) => typeof value === "string", { title: "TextVerbosity" });
|
|
6
6
|
export const ResponseIncludables = [
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Effect, Schema, Stream } from "effect";
|
|
2
2
|
import { AIError, InvalidProviderOutputError, CompactionPart, CompactionResponse, HttpOptions, LLMRequest, Message, mergeJsonRecords, } from "../../schema/index.js";
|
|
3
|
+
import { stripEffortUpdates } from "../../effort-updates.js";
|
|
3
4
|
import { Endpoint } from "../../route/endpoint.js";
|
|
4
5
|
import { RequestExecutor } from "../../route/executor.js";
|
|
5
6
|
import { HttpTransport } from "../../route/transport/index.js";
|
|
@@ -54,7 +55,8 @@ const Response = Schema.Struct({
|
|
|
54
55
|
});
|
|
55
56
|
export const make = (adapter) => Effect.fn("ResponsesCompaction.execute")(function* (request, executor, options) {
|
|
56
57
|
const route = request.model.route;
|
|
57
|
-
|
|
58
|
+
// The standalone compaction endpoint rejects histories containing configuration updates.
|
|
59
|
+
const native = yield* OpenResponses.lowerConversation(stripEffortUpdates(request), adapter);
|
|
58
60
|
const body = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Body))(mergeJsonRecords({
|
|
59
61
|
...native,
|
|
60
62
|
service_tier: request.providerOptions?.serviceTier,
|