@hebo-ai/gateway 0.11.4 → 0.11.5
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/endpoints/chat-completions/converters.js +14 -8
- package/dist/endpoints/chat-completions/schema.d.ts +301 -281
- package/dist/endpoints/chat-completions/schema.js +40 -25
- package/dist/endpoints/conversations/handler.js +9 -2
- package/dist/endpoints/conversations/schema.d.ts +453 -453
- package/dist/endpoints/messages/converters.d.ts +2 -2
- package/dist/endpoints/messages/converters.js +12 -6
- package/dist/endpoints/messages/schema.d.ts +88 -70
- package/dist/endpoints/messages/schema.js +26 -13
- package/dist/endpoints/responses/converters.js +25 -19
- package/dist/endpoints/responses/otel.js +3 -1
- package/dist/endpoints/responses/schema.d.ts +543 -525
- package/dist/endpoints/responses/schema.js +49 -34
- package/dist/endpoints/shared/converters.d.ts +1 -1
- package/dist/endpoints/shared/converters.js +1 -1
- package/dist/endpoints/shared/schema.d.ts +2 -2
- package/dist/endpoints/shared/schema.js +1 -1
- package/package.json +48 -56
|
@@ -4,14 +4,14 @@ import { type TextCallOptions } from "../shared/converters";
|
|
|
4
4
|
import type { ReasoningConfig, CacheControl } from "../shared/schema";
|
|
5
5
|
import type { MessagesInputs, MessagesMessage, MessagesTool, MessagesToolChoice, MessagesThinkingConfig, MessagesOutputConfig, Messages, MessagesStopReason, MessagesUsage, MessagesStream, MessagesStreamEvent } from "./schema";
|
|
6
6
|
export declare function convertToTextCallOptions(inputs: MessagesInputs): TextCallOptions;
|
|
7
|
-
export declare function convertThinkingToReasoning(thinking?: MessagesThinkingConfig, outputConfig?: MessagesOutputConfig): {
|
|
7
|
+
export declare function convertThinkingToReasoning(thinking?: MessagesThinkingConfig | null, outputConfig?: MessagesOutputConfig): {
|
|
8
8
|
reasoning: ReasoningConfig;
|
|
9
9
|
reasoning_effort?: ReasoningConfig["effort"];
|
|
10
10
|
} | undefined;
|
|
11
11
|
export declare function convertToModelMessages(messages: MessagesMessage[], system?: string | Array<{
|
|
12
12
|
type: "text";
|
|
13
13
|
text: string;
|
|
14
|
-
cache_control?: CacheControl;
|
|
14
|
+
cache_control?: CacheControl | null;
|
|
15
15
|
}>): ModelMessage[];
|
|
16
16
|
export declare function convertToToolSet(tools: MessagesTool[] | undefined): ToolSet | undefined;
|
|
17
17
|
export declare function convertToToolChoiceOptions(toolChoice: MessagesToolChoice | undefined): TextCallOptions["toolChoice"] | undefined;
|
|
@@ -225,7 +225,7 @@ function fromUserContentBlock(block) {
|
|
|
225
225
|
}
|
|
226
226
|
function fromToolResultBlock(block, toolNameMap) {
|
|
227
227
|
let output;
|
|
228
|
-
if (block.content === undefined) {
|
|
228
|
+
if (block.content === undefined || block.content === null) {
|
|
229
229
|
output = { type: "text", value: "" };
|
|
230
230
|
}
|
|
231
231
|
else if (typeof block.content === "string") {
|
|
@@ -316,13 +316,19 @@ export function convertToToolSet(tools) {
|
|
|
316
316
|
return undefined;
|
|
317
317
|
const toolSet = {};
|
|
318
318
|
for (const t of tools) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
319
|
+
// Hosted/server tools (e.g. web_search_20250305) are accepted at the edge
|
|
320
|
+
// but not executed by the gateway; drop anything with a non-"custom" type.
|
|
321
|
+
// FUTURE: log dropped hosted tools at warn level (once per request, batched)
|
|
322
|
+
if (t.type !== undefined && t.type !== "custom")
|
|
323
|
+
continue;
|
|
324
|
+
const fn = t;
|
|
325
|
+
toolSet[fn.name] = tool({
|
|
326
|
+
description: fn.description,
|
|
327
|
+
inputSchema: jsonSchema(fn.input_schema),
|
|
328
|
+
strict: fn.strict,
|
|
323
329
|
});
|
|
324
330
|
}
|
|
325
|
-
return toolSet;
|
|
331
|
+
return Object.keys(toolSet).length > 0 ? toolSet : undefined;
|
|
326
332
|
}
|
|
327
333
|
export function convertToToolChoiceOptions(toolChoice) {
|
|
328
334
|
if (!toolChoice)
|
|
@@ -4,14 +4,14 @@ import type { ProviderMetadata } from "../shared/schema";
|
|
|
4
4
|
declare const UserContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
5
5
|
type: z.ZodLiteral<"text">;
|
|
6
6
|
text: z.ZodString;
|
|
7
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
7
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
8
8
|
type: z.ZodLiteral<"ephemeral">;
|
|
9
9
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
10
10
|
"5m": "5m";
|
|
11
11
|
"1h": "1h";
|
|
12
12
|
"24h": "24h";
|
|
13
13
|
}>>;
|
|
14
|
-
}, z.core.$strip
|
|
14
|
+
}, z.core.$strip>>>;
|
|
15
15
|
}, z.core.$strip>, z.ZodObject<{
|
|
16
16
|
type: z.ZodLiteral<"image">;
|
|
17
17
|
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -22,28 +22,28 @@ declare const UserContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
22
22
|
type: z.ZodLiteral<"url">;
|
|
23
23
|
url: z.ZodString;
|
|
24
24
|
}, z.core.$strip>], "type">;
|
|
25
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
26
26
|
type: z.ZodLiteral<"ephemeral">;
|
|
27
27
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
28
28
|
"5m": "5m";
|
|
29
29
|
"1h": "1h";
|
|
30
30
|
"24h": "24h";
|
|
31
31
|
}>>;
|
|
32
|
-
}, z.core.$strip
|
|
32
|
+
}, z.core.$strip>>>;
|
|
33
33
|
}, z.core.$strip>, z.ZodObject<{
|
|
34
34
|
type: z.ZodLiteral<"tool_result">;
|
|
35
35
|
tool_use_id: z.ZodString;
|
|
36
|
-
content: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
36
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
37
37
|
type: z.ZodLiteral<"text">;
|
|
38
38
|
text: z.ZodString;
|
|
39
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
39
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
40
40
|
type: z.ZodLiteral<"ephemeral">;
|
|
41
41
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
42
42
|
"5m": "5m";
|
|
43
43
|
"1h": "1h";
|
|
44
44
|
"24h": "24h";
|
|
45
45
|
}>>;
|
|
46
|
-
}, z.core.$strip
|
|
46
|
+
}, z.core.$strip>>>;
|
|
47
47
|
}, z.core.$strip>, z.ZodObject<{
|
|
48
48
|
type: z.ZodLiteral<"image">;
|
|
49
49
|
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -54,24 +54,24 @@ declare const UserContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
54
54
|
type: z.ZodLiteral<"url">;
|
|
55
55
|
url: z.ZodString;
|
|
56
56
|
}, z.core.$strip>], "type">;
|
|
57
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
57
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
58
58
|
type: z.ZodLiteral<"ephemeral">;
|
|
59
59
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
60
60
|
"5m": "5m";
|
|
61
61
|
"1h": "1h";
|
|
62
62
|
"24h": "24h";
|
|
63
63
|
}>>;
|
|
64
|
-
}, z.core.$strip
|
|
65
|
-
}, z.core.$strip>]>>]
|
|
66
|
-
is_error: z.ZodOptional<z.ZodBoolean
|
|
67
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
64
|
+
}, z.core.$strip>>>;
|
|
65
|
+
}, z.core.$strip>]>>]>>>;
|
|
66
|
+
is_error: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
67
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
68
68
|
type: z.ZodLiteral<"ephemeral">;
|
|
69
69
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
70
70
|
"5m": "5m";
|
|
71
71
|
"1h": "1h";
|
|
72
72
|
"24h": "24h";
|
|
73
73
|
}>>;
|
|
74
|
-
}, z.core.$strip
|
|
74
|
+
}, z.core.$strip>>>;
|
|
75
75
|
}, z.core.$strip>, z.ZodObject<{
|
|
76
76
|
type: z.ZodLiteral<"document">;
|
|
77
77
|
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -86,36 +86,36 @@ declare const UserContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
86
86
|
data: z.ZodString;
|
|
87
87
|
media_type: z.ZodLiteral<"text/plain">;
|
|
88
88
|
}, z.core.$strip>], "type">;
|
|
89
|
-
title: z.ZodOptional<z.ZodString
|
|
90
|
-
context: z.ZodOptional<z.ZodString
|
|
91
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
89
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
90
|
+
context: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
91
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
92
92
|
type: z.ZodLiteral<"ephemeral">;
|
|
93
93
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
94
94
|
"5m": "5m";
|
|
95
95
|
"1h": "1h";
|
|
96
96
|
"24h": "24h";
|
|
97
97
|
}>>;
|
|
98
|
-
}, z.core.$strip
|
|
98
|
+
}, z.core.$strip>>>;
|
|
99
99
|
}, z.core.$strip>], "type">;
|
|
100
100
|
export type UserContentBlock = z.infer<typeof UserContentBlockSchema>;
|
|
101
101
|
declare const AssistantContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
102
102
|
type: z.ZodLiteral<"text">;
|
|
103
103
|
text: z.ZodString;
|
|
104
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
104
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
105
105
|
type: z.ZodLiteral<"ephemeral">;
|
|
106
106
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
107
107
|
"5m": "5m";
|
|
108
108
|
"1h": "1h";
|
|
109
109
|
"24h": "24h";
|
|
110
110
|
}>>;
|
|
111
|
-
}, z.core.$strip
|
|
111
|
+
}, z.core.$strip>>>;
|
|
112
112
|
}, z.core.$strip>, z.ZodObject<{
|
|
113
113
|
type: z.ZodLiteral<"tool_use">;
|
|
114
114
|
id: z.ZodString;
|
|
115
115
|
name: z.ZodString;
|
|
116
116
|
input: z.ZodAny;
|
|
117
|
-
caller: z.ZodOptional<z.ZodString
|
|
118
|
-
extra_content: z.ZodOptional<z.ZodType<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown
|
|
117
|
+
caller: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
118
|
+
extra_content: z.ZodOptional<z.ZodNullable<z.ZodType<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown>>>>;
|
|
119
119
|
}, z.core.$strip>, z.ZodObject<{
|
|
120
120
|
type: z.ZodLiteral<"thinking">;
|
|
121
121
|
thinking: z.ZodString;
|
|
@@ -130,14 +130,14 @@ declare const MessagesMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
130
130
|
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
131
131
|
type: z.ZodLiteral<"text">;
|
|
132
132
|
text: z.ZodString;
|
|
133
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
133
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
134
134
|
type: z.ZodLiteral<"ephemeral">;
|
|
135
135
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
136
136
|
"5m": "5m";
|
|
137
137
|
"1h": "1h";
|
|
138
138
|
"24h": "24h";
|
|
139
139
|
}>>;
|
|
140
|
-
}, z.core.$strip
|
|
140
|
+
}, z.core.$strip>>>;
|
|
141
141
|
}, z.core.$strip>, z.ZodObject<{
|
|
142
142
|
type: z.ZodLiteral<"image">;
|
|
143
143
|
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -148,28 +148,28 @@ declare const MessagesMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
148
148
|
type: z.ZodLiteral<"url">;
|
|
149
149
|
url: z.ZodString;
|
|
150
150
|
}, z.core.$strip>], "type">;
|
|
151
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
151
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
152
152
|
type: z.ZodLiteral<"ephemeral">;
|
|
153
153
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
154
154
|
"5m": "5m";
|
|
155
155
|
"1h": "1h";
|
|
156
156
|
"24h": "24h";
|
|
157
157
|
}>>;
|
|
158
|
-
}, z.core.$strip
|
|
158
|
+
}, z.core.$strip>>>;
|
|
159
159
|
}, z.core.$strip>, z.ZodObject<{
|
|
160
160
|
type: z.ZodLiteral<"tool_result">;
|
|
161
161
|
tool_use_id: z.ZodString;
|
|
162
|
-
content: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
162
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
163
163
|
type: z.ZodLiteral<"text">;
|
|
164
164
|
text: z.ZodString;
|
|
165
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
165
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
166
166
|
type: z.ZodLiteral<"ephemeral">;
|
|
167
167
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
168
168
|
"5m": "5m";
|
|
169
169
|
"1h": "1h";
|
|
170
170
|
"24h": "24h";
|
|
171
171
|
}>>;
|
|
172
|
-
}, z.core.$strip
|
|
172
|
+
}, z.core.$strip>>>;
|
|
173
173
|
}, z.core.$strip>, z.ZodObject<{
|
|
174
174
|
type: z.ZodLiteral<"image">;
|
|
175
175
|
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -180,24 +180,24 @@ declare const MessagesMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
180
180
|
type: z.ZodLiteral<"url">;
|
|
181
181
|
url: z.ZodString;
|
|
182
182
|
}, z.core.$strip>], "type">;
|
|
183
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
183
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
184
184
|
type: z.ZodLiteral<"ephemeral">;
|
|
185
185
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
186
186
|
"5m": "5m";
|
|
187
187
|
"1h": "1h";
|
|
188
188
|
"24h": "24h";
|
|
189
189
|
}>>;
|
|
190
|
-
}, z.core.$strip
|
|
191
|
-
}, z.core.$strip>]>>]
|
|
192
|
-
is_error: z.ZodOptional<z.ZodBoolean
|
|
193
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
190
|
+
}, z.core.$strip>>>;
|
|
191
|
+
}, z.core.$strip>]>>]>>>;
|
|
192
|
+
is_error: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
193
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
194
194
|
type: z.ZodLiteral<"ephemeral">;
|
|
195
195
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
196
196
|
"5m": "5m";
|
|
197
197
|
"1h": "1h";
|
|
198
198
|
"24h": "24h";
|
|
199
199
|
}>>;
|
|
200
|
-
}, z.core.$strip
|
|
200
|
+
}, z.core.$strip>>>;
|
|
201
201
|
}, z.core.$strip>, z.ZodObject<{
|
|
202
202
|
type: z.ZodLiteral<"document">;
|
|
203
203
|
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -212,37 +212,37 @@ declare const MessagesMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
212
212
|
data: z.ZodString;
|
|
213
213
|
media_type: z.ZodLiteral<"text/plain">;
|
|
214
214
|
}, z.core.$strip>], "type">;
|
|
215
|
-
title: z.ZodOptional<z.ZodString
|
|
216
|
-
context: z.ZodOptional<z.ZodString
|
|
217
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
215
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
216
|
+
context: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
217
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
218
218
|
type: z.ZodLiteral<"ephemeral">;
|
|
219
219
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
220
220
|
"5m": "5m";
|
|
221
221
|
"1h": "1h";
|
|
222
222
|
"24h": "24h";
|
|
223
223
|
}>>;
|
|
224
|
-
}, z.core.$strip
|
|
224
|
+
}, z.core.$strip>>>;
|
|
225
225
|
}, z.core.$strip>], "type">>]>;
|
|
226
226
|
}, z.core.$strip>, z.ZodObject<{
|
|
227
227
|
role: z.ZodLiteral<"assistant">;
|
|
228
228
|
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
229
229
|
type: z.ZodLiteral<"text">;
|
|
230
230
|
text: z.ZodString;
|
|
231
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
231
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
232
232
|
type: z.ZodLiteral<"ephemeral">;
|
|
233
233
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
234
234
|
"5m": "5m";
|
|
235
235
|
"1h": "1h";
|
|
236
236
|
"24h": "24h";
|
|
237
237
|
}>>;
|
|
238
|
-
}, z.core.$strip
|
|
238
|
+
}, z.core.$strip>>>;
|
|
239
239
|
}, z.core.$strip>, z.ZodObject<{
|
|
240
240
|
type: z.ZodLiteral<"tool_use">;
|
|
241
241
|
id: z.ZodString;
|
|
242
242
|
name: z.ZodString;
|
|
243
243
|
input: z.ZodAny;
|
|
244
|
-
caller: z.ZodOptional<z.ZodString
|
|
245
|
-
extra_content: z.ZodOptional<z.ZodType<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown
|
|
244
|
+
caller: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
245
|
+
extra_content: z.ZodOptional<z.ZodNullable<z.ZodType<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown>>>>;
|
|
246
246
|
}, z.core.$strip>, z.ZodObject<{
|
|
247
247
|
type: z.ZodLiteral<"thinking">;
|
|
248
248
|
thinking: z.ZodString;
|
|
@@ -253,12 +253,27 @@ declare const MessagesMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
253
253
|
}, z.core.$strip>], "type">>]>;
|
|
254
254
|
}, z.core.$strip>], "role">;
|
|
255
255
|
export type MessagesMessage = z.infer<typeof MessagesMessageSchema>;
|
|
256
|
-
declare const
|
|
256
|
+
declare const MessagesCustomToolSchema: z.ZodObject<{
|
|
257
|
+
type: z.ZodOptional<z.ZodLiteral<"custom">>;
|
|
257
258
|
name: z.ZodString;
|
|
258
259
|
description: z.ZodOptional<z.ZodString>;
|
|
259
260
|
input_schema: z.ZodAny;
|
|
260
261
|
strict: z.ZodOptional<z.ZodBoolean>;
|
|
261
262
|
}, z.core.$strip>;
|
|
263
|
+
export type MessagesCustomTool = z.infer<typeof MessagesCustomToolSchema>;
|
|
264
|
+
declare const MessagesHostedToolSchema: z.ZodObject<{
|
|
265
|
+
type: z.ZodString;
|
|
266
|
+
}, z.core.$loose>;
|
|
267
|
+
export type MessagesHostedTool = z.infer<typeof MessagesHostedToolSchema>;
|
|
268
|
+
declare const MessagesToolSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
269
|
+
type: z.ZodOptional<z.ZodLiteral<"custom">>;
|
|
270
|
+
name: z.ZodString;
|
|
271
|
+
description: z.ZodOptional<z.ZodString>;
|
|
272
|
+
input_schema: z.ZodAny;
|
|
273
|
+
strict: z.ZodOptional<z.ZodBoolean>;
|
|
274
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
275
|
+
type: z.ZodString;
|
|
276
|
+
}, z.core.$loose>]>;
|
|
262
277
|
export type MessagesTool = z.infer<typeof MessagesToolSchema>;
|
|
263
278
|
declare const MessagesToolChoiceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
264
279
|
type: z.ZodLiteral<"auto">;
|
|
@@ -317,14 +332,14 @@ export declare const MessagesBodySchema: z.ZodObject<{
|
|
|
317
332
|
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
318
333
|
type: z.ZodLiteral<"text">;
|
|
319
334
|
text: z.ZodString;
|
|
320
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
335
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
321
336
|
type: z.ZodLiteral<"ephemeral">;
|
|
322
337
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
323
338
|
"5m": "5m";
|
|
324
339
|
"1h": "1h";
|
|
325
340
|
"24h": "24h";
|
|
326
341
|
}>>;
|
|
327
|
-
}, z.core.$strip
|
|
342
|
+
}, z.core.$strip>>>;
|
|
328
343
|
}, z.core.$strip>, z.ZodObject<{
|
|
329
344
|
type: z.ZodLiteral<"image">;
|
|
330
345
|
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -335,28 +350,28 @@ export declare const MessagesBodySchema: z.ZodObject<{
|
|
|
335
350
|
type: z.ZodLiteral<"url">;
|
|
336
351
|
url: z.ZodString;
|
|
337
352
|
}, z.core.$strip>], "type">;
|
|
338
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
353
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
339
354
|
type: z.ZodLiteral<"ephemeral">;
|
|
340
355
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
341
356
|
"5m": "5m";
|
|
342
357
|
"1h": "1h";
|
|
343
358
|
"24h": "24h";
|
|
344
359
|
}>>;
|
|
345
|
-
}, z.core.$strip
|
|
360
|
+
}, z.core.$strip>>>;
|
|
346
361
|
}, z.core.$strip>, z.ZodObject<{
|
|
347
362
|
type: z.ZodLiteral<"tool_result">;
|
|
348
363
|
tool_use_id: z.ZodString;
|
|
349
|
-
content: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
364
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
350
365
|
type: z.ZodLiteral<"text">;
|
|
351
366
|
text: z.ZodString;
|
|
352
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
367
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
353
368
|
type: z.ZodLiteral<"ephemeral">;
|
|
354
369
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
355
370
|
"5m": "5m";
|
|
356
371
|
"1h": "1h";
|
|
357
372
|
"24h": "24h";
|
|
358
373
|
}>>;
|
|
359
|
-
}, z.core.$strip
|
|
374
|
+
}, z.core.$strip>>>;
|
|
360
375
|
}, z.core.$strip>, z.ZodObject<{
|
|
361
376
|
type: z.ZodLiteral<"image">;
|
|
362
377
|
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -367,24 +382,24 @@ export declare const MessagesBodySchema: z.ZodObject<{
|
|
|
367
382
|
type: z.ZodLiteral<"url">;
|
|
368
383
|
url: z.ZodString;
|
|
369
384
|
}, z.core.$strip>], "type">;
|
|
370
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
385
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
371
386
|
type: z.ZodLiteral<"ephemeral">;
|
|
372
387
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
373
388
|
"5m": "5m";
|
|
374
389
|
"1h": "1h";
|
|
375
390
|
"24h": "24h";
|
|
376
391
|
}>>;
|
|
377
|
-
}, z.core.$strip
|
|
378
|
-
}, z.core.$strip>]>>]
|
|
379
|
-
is_error: z.ZodOptional<z.ZodBoolean
|
|
380
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
392
|
+
}, z.core.$strip>>>;
|
|
393
|
+
}, z.core.$strip>]>>]>>>;
|
|
394
|
+
is_error: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
395
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
381
396
|
type: z.ZodLiteral<"ephemeral">;
|
|
382
397
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
383
398
|
"5m": "5m";
|
|
384
399
|
"1h": "1h";
|
|
385
400
|
"24h": "24h";
|
|
386
401
|
}>>;
|
|
387
|
-
}, z.core.$strip
|
|
402
|
+
}, z.core.$strip>>>;
|
|
388
403
|
}, z.core.$strip>, z.ZodObject<{
|
|
389
404
|
type: z.ZodLiteral<"document">;
|
|
390
405
|
source: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -399,37 +414,37 @@ export declare const MessagesBodySchema: z.ZodObject<{
|
|
|
399
414
|
data: z.ZodString;
|
|
400
415
|
media_type: z.ZodLiteral<"text/plain">;
|
|
401
416
|
}, z.core.$strip>], "type">;
|
|
402
|
-
title: z.ZodOptional<z.ZodString
|
|
403
|
-
context: z.ZodOptional<z.ZodString
|
|
404
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
417
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
418
|
+
context: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
419
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
405
420
|
type: z.ZodLiteral<"ephemeral">;
|
|
406
421
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
407
422
|
"5m": "5m";
|
|
408
423
|
"1h": "1h";
|
|
409
424
|
"24h": "24h";
|
|
410
425
|
}>>;
|
|
411
|
-
}, z.core.$strip
|
|
426
|
+
}, z.core.$strip>>>;
|
|
412
427
|
}, z.core.$strip>], "type">>]>;
|
|
413
428
|
}, z.core.$strip>, z.ZodObject<{
|
|
414
429
|
role: z.ZodLiteral<"assistant">;
|
|
415
430
|
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
416
431
|
type: z.ZodLiteral<"text">;
|
|
417
432
|
text: z.ZodString;
|
|
418
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
433
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
419
434
|
type: z.ZodLiteral<"ephemeral">;
|
|
420
435
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
421
436
|
"5m": "5m";
|
|
422
437
|
"1h": "1h";
|
|
423
438
|
"24h": "24h";
|
|
424
439
|
}>>;
|
|
425
|
-
}, z.core.$strip
|
|
440
|
+
}, z.core.$strip>>>;
|
|
426
441
|
}, z.core.$strip>, z.ZodObject<{
|
|
427
442
|
type: z.ZodLiteral<"tool_use">;
|
|
428
443
|
id: z.ZodString;
|
|
429
444
|
name: z.ZodString;
|
|
430
445
|
input: z.ZodAny;
|
|
431
|
-
caller: z.ZodOptional<z.ZodString
|
|
432
|
-
extra_content: z.ZodOptional<z.ZodType<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown
|
|
446
|
+
caller: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
447
|
+
extra_content: z.ZodOptional<z.ZodNullable<z.ZodType<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown>>>>;
|
|
433
448
|
}, z.core.$strip>, z.ZodObject<{
|
|
434
449
|
type: z.ZodLiteral<"thinking">;
|
|
435
450
|
thinking: z.ZodString;
|
|
@@ -442,14 +457,14 @@ export declare const MessagesBodySchema: z.ZodObject<{
|
|
|
442
457
|
system: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
443
458
|
type: z.ZodLiteral<"text">;
|
|
444
459
|
text: z.ZodString;
|
|
445
|
-
cache_control: z.ZodOptional<z.ZodObject<{
|
|
460
|
+
cache_control: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
446
461
|
type: z.ZodLiteral<"ephemeral">;
|
|
447
462
|
ttl: z.ZodOptional<z.ZodEnum<{
|
|
448
463
|
"5m": "5m";
|
|
449
464
|
"1h": "1h";
|
|
450
465
|
"24h": "24h";
|
|
451
466
|
}>>;
|
|
452
|
-
}, z.core.$strip
|
|
467
|
+
}, z.core.$strip>>>;
|
|
453
468
|
}, z.core.$strip>>]>>;
|
|
454
469
|
stream: z.ZodOptional<z.ZodBoolean>;
|
|
455
470
|
trace: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodBoolean, z.ZodTransform<"off" | undefined, boolean>>, z.ZodEnum<{
|
|
@@ -461,12 +476,15 @@ export declare const MessagesBodySchema: z.ZodObject<{
|
|
|
461
476
|
temperature: z.ZodOptional<z.ZodNumber>;
|
|
462
477
|
top_p: z.ZodOptional<z.ZodNumber>;
|
|
463
478
|
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
464
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
479
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
480
|
+
type: z.ZodOptional<z.ZodLiteral<"custom">>;
|
|
465
481
|
name: z.ZodString;
|
|
466
482
|
description: z.ZodOptional<z.ZodString>;
|
|
467
483
|
input_schema: z.ZodAny;
|
|
468
484
|
strict: z.ZodOptional<z.ZodBoolean>;
|
|
469
|
-
}, z.core.$strip
|
|
485
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
486
|
+
type: z.ZodString;
|
|
487
|
+
}, z.core.$loose>]>>>;
|
|
470
488
|
tool_choice: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
471
489
|
type: z.ZodLiteral<"auto">;
|
|
472
490
|
disable_parallel_tool_use: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -480,7 +498,7 @@ export declare const MessagesBodySchema: z.ZodObject<{
|
|
|
480
498
|
name: z.ZodString;
|
|
481
499
|
disable_parallel_tool_use: z.ZodOptional<z.ZodBoolean>;
|
|
482
500
|
}, z.core.$strip>], "type">>;
|
|
483
|
-
thinking: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
501
|
+
thinking: z.ZodOptional<z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
484
502
|
type: z.ZodLiteral<"enabled">;
|
|
485
503
|
budget_tokens: z.ZodNumber;
|
|
486
504
|
display: z.ZodOptional<z.ZodEnum<{
|
|
@@ -495,7 +513,7 @@ export declare const MessagesBodySchema: z.ZodObject<{
|
|
|
495
513
|
summarized: "summarized";
|
|
496
514
|
omitted: "omitted";
|
|
497
515
|
}>>;
|
|
498
|
-
}, z.core.$strip>], "type"
|
|
516
|
+
}, z.core.$strip>], "type">>>;
|
|
499
517
|
metadata: z.ZodOptional<z.ZodObject<{
|
|
500
518
|
user_id: z.ZodOptional<z.ZodString>;
|
|
501
519
|
}, z.core.$strip>>;
|
|
@@ -4,7 +4,7 @@ import { CacheControlSchema, ProviderMetadataSchema, TraceSchema } from "../shar
|
|
|
4
4
|
const TextBlockSchema = z.object({
|
|
5
5
|
type: z.literal("text"),
|
|
6
6
|
text: z.string(),
|
|
7
|
-
cache_control: CacheControlSchema.
|
|
7
|
+
cache_control: CacheControlSchema.nullish(),
|
|
8
8
|
});
|
|
9
9
|
const ImageSourceBase64Schema = z.object({
|
|
10
10
|
type: z.literal("base64"),
|
|
@@ -18,7 +18,7 @@ const ImageSourceUrlSchema = z.object({
|
|
|
18
18
|
const ImageBlockSchema = z.object({
|
|
19
19
|
type: z.literal("image"),
|
|
20
20
|
source: z.discriminatedUnion("type", [ImageSourceBase64Schema, ImageSourceUrlSchema]),
|
|
21
|
-
cache_control: CacheControlSchema.
|
|
21
|
+
cache_control: CacheControlSchema.nullish(),
|
|
22
22
|
});
|
|
23
23
|
const DocumentSourceBase64Schema = z.object({
|
|
24
24
|
type: z.literal("base64"),
|
|
@@ -42,9 +42,9 @@ const DocumentBlockSchema = z.object({
|
|
|
42
42
|
DocumentSourceTextSchema,
|
|
43
43
|
]),
|
|
44
44
|
// FUTURE: pass title/context through to provider (no AI SDK FilePart equivalent yet)
|
|
45
|
-
title: z.string().
|
|
46
|
-
context: z.string().
|
|
47
|
-
cache_control: CacheControlSchema.
|
|
45
|
+
title: z.string().nullish(),
|
|
46
|
+
context: z.string().nullish(),
|
|
47
|
+
cache_control: CacheControlSchema.nullish(),
|
|
48
48
|
});
|
|
49
49
|
const ToolUseBlockSchema = z.object({
|
|
50
50
|
type: z.literal("tool_use"),
|
|
@@ -52,9 +52,9 @@ const ToolUseBlockSchema = z.object({
|
|
|
52
52
|
name: z.string(),
|
|
53
53
|
input: z.any(),
|
|
54
54
|
// FUTURE: pass caller through to provider (no AI SDK equivalent yet)
|
|
55
|
-
caller: z.string().
|
|
55
|
+
caller: z.string().nullish(),
|
|
56
56
|
// Extension origin: Gemini — carries thought_signature and other provider metadata for multi-turn
|
|
57
|
-
extra_content: ProviderMetadataSchema.
|
|
57
|
+
extra_content: ProviderMetadataSchema.nullish().meta({ extension: true }),
|
|
58
58
|
});
|
|
59
59
|
const ToolResultContentBlockSchema = z.union([
|
|
60
60
|
z.string(),
|
|
@@ -63,9 +63,9 @@ const ToolResultContentBlockSchema = z.union([
|
|
|
63
63
|
const ToolResultBlockSchema = z.object({
|
|
64
64
|
type: z.literal("tool_result"),
|
|
65
65
|
tool_use_id: z.string(),
|
|
66
|
-
content: ToolResultContentBlockSchema.
|
|
67
|
-
is_error: z.boolean().
|
|
68
|
-
cache_control: CacheControlSchema.
|
|
66
|
+
content: ToolResultContentBlockSchema.nullish(),
|
|
67
|
+
is_error: z.boolean().nullish(),
|
|
68
|
+
cache_control: CacheControlSchema.nullish(),
|
|
69
69
|
});
|
|
70
70
|
const ThinkingBlockSchema = z.object({
|
|
71
71
|
type: z.literal("thinking"),
|
|
@@ -106,16 +106,29 @@ const MessagesMessageSchema = z.discriminatedUnion("role", [
|
|
|
106
106
|
const SystemBlockSchema = z.object({
|
|
107
107
|
type: z.literal("text"),
|
|
108
108
|
text: z.string(),
|
|
109
|
-
cache_control: CacheControlSchema.
|
|
109
|
+
cache_control: CacheControlSchema.nullish(),
|
|
110
110
|
});
|
|
111
111
|
// --- Tool Schemas ---
|
|
112
|
-
const
|
|
112
|
+
const MessagesCustomToolSchema = z.object({
|
|
113
|
+
type: z.literal("custom").optional(),
|
|
113
114
|
name: z.string(),
|
|
114
115
|
description: z.string().optional(),
|
|
115
116
|
input_schema: z.any(),
|
|
116
117
|
// FUTURE: cache_control support on tools
|
|
117
118
|
strict: z.boolean().optional(),
|
|
118
119
|
});
|
|
120
|
+
// Hosted/server tools (e.g. web_search_20250305, computer_20250124).
|
|
121
|
+
// Accepted at the edge so clients can send their default payload, but not
|
|
122
|
+
// executed by the gateway — they are dropped before the AI SDK call unless the
|
|
123
|
+
// downstream handler explicitly opts them in.
|
|
124
|
+
const MessagesHostedToolSchema = z
|
|
125
|
+
.looseObject({
|
|
126
|
+
type: z.string(),
|
|
127
|
+
})
|
|
128
|
+
.refine((value) => value.type !== "custom", {
|
|
129
|
+
message: 'Custom tools must use the custom tool schema (omit "type" or use type: "custom")',
|
|
130
|
+
});
|
|
131
|
+
const MessagesToolSchema = z.union([MessagesCustomToolSchema, MessagesHostedToolSchema]);
|
|
119
132
|
const MessagesToolChoiceAutoSchema = z.object({
|
|
120
133
|
type: z.literal("auto"),
|
|
121
134
|
disable_parallel_tool_use: z.boolean().optional(),
|
|
@@ -178,7 +191,7 @@ export const MessagesBodySchema = z.object({
|
|
|
178
191
|
stop_sequences: z.array(z.string()).optional(),
|
|
179
192
|
tools: z.array(MessagesToolSchema).optional(),
|
|
180
193
|
tool_choice: MessagesToolChoiceSchema.optional(),
|
|
181
|
-
thinking: MessagesThinkingConfigSchema.
|
|
194
|
+
thinking: MessagesThinkingConfigSchema.nullish(),
|
|
182
195
|
metadata: z.object({ user_id: z.string().optional() }).optional(),
|
|
183
196
|
service_tier: MessagesServiceTierSchema.optional(),
|
|
184
197
|
cache_control: CacheControlSchema.optional(),
|