@purpleschool/gptbot 0.19.27 → 0.20.0-stage-2
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/build/api/controllers/http/b2b-compatible.d.ts +1 -0
- package/build/api/controllers/http/b2b-compatible.js +1 -0
- package/build/commands/b2b-compatible/anthropic-messages.command.d.ts +125 -48
- package/build/commands/b2b-compatible/anthropic-messages.command.js +3 -63
- package/build/commands/b2b-compatible/anthropic-tool-messages.command.d.ts +302 -0
- package/build/commands/b2b-compatible/anthropic-tool-messages.command.js +248 -0
- package/build/commands/b2b-compatible/index.d.ts +3 -0
- package/build/commands/b2b-compatible/index.js +3 -0
- package/build/commands/b2b-compatible/openai-chat-completions.command.d.ts +132 -0
- package/build/commands/b2b-compatible/openai-chat-completions.command.js +128 -0
- package/build/commands/b2b-compatible/openai-responses.command.d.ts +148 -15
- package/build/commands/b2b-compatible/openai-responses.command.js +13 -3
- package/build/commands/b2b-compatible/openai-tool-responses.command.d.ts +155 -0
- package/build/commands/b2b-compatible/openai-tool-responses.command.js +155 -0
- package/build/commands/payment/get-payment-history.command.d.ts +1 -0
- package/build/commands/payment/get-purchase-history.command.d.ts +1 -0
- package/build/commands/team-account/get-team-account-payment-history.command.d.ts +1 -0
- package/build/constants/ai-model/enums/index.d.ts +0 -1
- package/build/constants/ai-model/enums/index.js +0 -1
- package/build/constants/b2b/enums/anthropic-tool.enum.d.ts +70 -0
- package/build/constants/b2b/enums/anthropic-tool.enum.js +87 -0
- package/build/constants/b2b/enums/index.d.ts +2 -0
- package/build/constants/b2b/enums/index.js +2 -0
- package/build/constants/b2b/enums/openai-tool.enum.d.ts +34 -0
- package/build/constants/b2b/enums/openai-tool.enum.js +43 -0
- package/build/models/payment-history-item.schema.d.ts +1 -0
- package/build/models/payment-history-item.schema.js +1 -0
- package/build/models/purchase-history.schema.d.ts +1 -0
- package/build/models/push/push-campaign-segment.schema.js +1 -1
- package/package.json +1 -1
- package/build/constants/ai-model/enums/ai-model-strategy.enum.d.ts +0 -21
- package/build/constants/ai-model/enums/ai-model-strategy.enum.js +0 -25
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnthropicToolMessagesCommand = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const enums_1 = require("../../constants/b2b/enums");
|
|
6
|
+
const cacheControl = zod_1.z
|
|
7
|
+
.object({
|
|
8
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_CACHE_TYPE.EPHEMERAL),
|
|
9
|
+
ttl: zod_1.z.enum(enums_1.ANTHROPIC_CACHE_TTL).optional(),
|
|
10
|
+
})
|
|
11
|
+
.strict();
|
|
12
|
+
const text = zod_1.z
|
|
13
|
+
.object({
|
|
14
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_BLOCK_TYPE.TEXT),
|
|
15
|
+
text: zod_1.z.string(),
|
|
16
|
+
cache_control: cacheControl.optional(),
|
|
17
|
+
})
|
|
18
|
+
.strict();
|
|
19
|
+
const toolUse = zod_1.z
|
|
20
|
+
.object({
|
|
21
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_BLOCK_TYPE.TOOL_USE),
|
|
22
|
+
id: zod_1.z.string().min(1),
|
|
23
|
+
name: zod_1.z.string().min(1),
|
|
24
|
+
input: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()),
|
|
25
|
+
// Нативный ответ возвращает caller; клиент повторяет блок без преобразования.
|
|
26
|
+
caller: zod_1.z
|
|
27
|
+
.object({ type: zod_1.z.literal(enums_1.ANTHROPIC_TOOL_CALLER.DIRECT) })
|
|
28
|
+
.strict()
|
|
29
|
+
.optional(),
|
|
30
|
+
cache_control: cacheControl.optional(),
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
const thinking = zod_1.z
|
|
34
|
+
.object({
|
|
35
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_BLOCK_TYPE.THINKING),
|
|
36
|
+
thinking: zod_1.z.string(),
|
|
37
|
+
signature: zod_1.z.string(),
|
|
38
|
+
})
|
|
39
|
+
.strict();
|
|
40
|
+
const redactedThinking = zod_1.z
|
|
41
|
+
.object({ type: zod_1.z.literal(enums_1.ANTHROPIC_BLOCK_TYPE.REDACTED_THINKING), data: zod_1.z.string() })
|
|
42
|
+
.strict();
|
|
43
|
+
const toolResult = zod_1.z
|
|
44
|
+
.object({
|
|
45
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_BLOCK_TYPE.TOOL_RESULT),
|
|
46
|
+
tool_use_id: zod_1.z.string().min(1),
|
|
47
|
+
content: zod_1.z.union([zod_1.z.string(), zod_1.z.array(text)]).optional(),
|
|
48
|
+
is_error: zod_1.z.boolean().optional(),
|
|
49
|
+
cache_control: cacheControl.optional(),
|
|
50
|
+
})
|
|
51
|
+
.strict();
|
|
52
|
+
var AnthropicToolMessagesCommand;
|
|
53
|
+
(function (AnthropicToolMessagesCommand) {
|
|
54
|
+
/** Только протокольные headers; credentials всегда определяются сервером. */
|
|
55
|
+
AnthropicToolMessagesCommand.ProtocolHeadersSchema = zod_1.z
|
|
56
|
+
.object({
|
|
57
|
+
'anthropic-version': zod_1.z
|
|
58
|
+
.string()
|
|
59
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/)
|
|
60
|
+
.optional(),
|
|
61
|
+
'anthropic-beta': zod_1.z
|
|
62
|
+
.string()
|
|
63
|
+
.max(8192)
|
|
64
|
+
.regex(/^[a-zA-Z0-9_,.: -]+$/)
|
|
65
|
+
.optional(),
|
|
66
|
+
})
|
|
67
|
+
.strict();
|
|
68
|
+
/** Полная история передаётся клиентом; выполняются только пользовательские инструменты. */
|
|
69
|
+
AnthropicToolMessagesCommand.BodySchema = zod_1.z
|
|
70
|
+
.object({
|
|
71
|
+
model: zod_1.z.string().min(1),
|
|
72
|
+
max_tokens: zod_1.z.number().int().positive(),
|
|
73
|
+
messages: zod_1.z
|
|
74
|
+
.array(zod_1.z
|
|
75
|
+
.object({
|
|
76
|
+
role: zod_1.z.enum(enums_1.ANTHROPIC_ROLE),
|
|
77
|
+
content: zod_1.z.union([
|
|
78
|
+
zod_1.z.string(),
|
|
79
|
+
zod_1.z.array(zod_1.z.union([
|
|
80
|
+
text,
|
|
81
|
+
toolUse,
|
|
82
|
+
toolResult,
|
|
83
|
+
thinking,
|
|
84
|
+
redactedThinking,
|
|
85
|
+
])),
|
|
86
|
+
]),
|
|
87
|
+
})
|
|
88
|
+
.strict())
|
|
89
|
+
.min(1),
|
|
90
|
+
system: zod_1.z.union([zod_1.z.string(), zod_1.z.array(text)]).optional(),
|
|
91
|
+
tools: zod_1.z
|
|
92
|
+
.array(zod_1.z
|
|
93
|
+
.object({
|
|
94
|
+
name: zod_1.z.string().regex(/^[a-zA-Z0-9_-]{1,64}$/),
|
|
95
|
+
description: zod_1.z.string().optional(),
|
|
96
|
+
input_schema: zod_1.z.object({ type: zod_1.z.literal('object') }).loose(),
|
|
97
|
+
cache_control: cacheControl.optional(),
|
|
98
|
+
})
|
|
99
|
+
.strict())
|
|
100
|
+
.optional(),
|
|
101
|
+
tool_choice: zod_1.z
|
|
102
|
+
.discriminatedUnion('type', [
|
|
103
|
+
zod_1.z
|
|
104
|
+
.object({
|
|
105
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_TOOL_CHOICE.AUTO),
|
|
106
|
+
disable_parallel_tool_use: zod_1.z.boolean().optional(),
|
|
107
|
+
})
|
|
108
|
+
.strict(),
|
|
109
|
+
zod_1.z
|
|
110
|
+
.object({
|
|
111
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_TOOL_CHOICE.ANY),
|
|
112
|
+
disable_parallel_tool_use: zod_1.z.boolean().optional(),
|
|
113
|
+
})
|
|
114
|
+
.strict(),
|
|
115
|
+
zod_1.z
|
|
116
|
+
.object({
|
|
117
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_TOOL_CHOICE.TOOL),
|
|
118
|
+
name: zod_1.z.string().min(1),
|
|
119
|
+
disable_parallel_tool_use: zod_1.z.boolean().optional(),
|
|
120
|
+
})
|
|
121
|
+
.strict(),
|
|
122
|
+
zod_1.z.object({ type: zod_1.z.literal(enums_1.ANTHROPIC_TOOL_CHOICE.NONE) }).strict(),
|
|
123
|
+
])
|
|
124
|
+
.optional(),
|
|
125
|
+
thinking: zod_1.z
|
|
126
|
+
.discriminatedUnion('type', [
|
|
127
|
+
zod_1.z
|
|
128
|
+
.object({
|
|
129
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_THINKING.ENABLED),
|
|
130
|
+
budget_tokens: zod_1.z.number().int().min(1024),
|
|
131
|
+
display: zod_1.z.enum(enums_1.ANTHROPIC_THINKING_DISPLAY).optional(),
|
|
132
|
+
})
|
|
133
|
+
.strict(),
|
|
134
|
+
zod_1.z.object({ type: zod_1.z.literal(enums_1.ANTHROPIC_THINKING.DISABLED) }).strict(),
|
|
135
|
+
zod_1.z
|
|
136
|
+
.object({
|
|
137
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_THINKING.ADAPTIVE),
|
|
138
|
+
display: zod_1.z.enum(enums_1.ANTHROPIC_THINKING_DISPLAY).optional(),
|
|
139
|
+
})
|
|
140
|
+
.strict(),
|
|
141
|
+
])
|
|
142
|
+
.optional(),
|
|
143
|
+
output_config: zod_1.z
|
|
144
|
+
.object({ effort: zod_1.z.enum(enums_1.ANTHROPIC_EFFORT).optional() })
|
|
145
|
+
.strict()
|
|
146
|
+
.optional(),
|
|
147
|
+
context_management: zod_1.z
|
|
148
|
+
.object({
|
|
149
|
+
edits: zod_1.z.array(zod_1.z
|
|
150
|
+
.object({
|
|
151
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_CONTEXT_EDIT.CLEAR_THINKING),
|
|
152
|
+
keep: zod_1.z.literal(enums_1.ANTHROPIC_THINKING_KEEP.ALL),
|
|
153
|
+
})
|
|
154
|
+
.strict()),
|
|
155
|
+
})
|
|
156
|
+
.strict()
|
|
157
|
+
.optional(),
|
|
158
|
+
stream: zod_1.z.boolean().optional(),
|
|
159
|
+
temperature: zod_1.z.number().min(0).max(1).optional(),
|
|
160
|
+
top_p: zod_1.z.number().min(0).max(1).optional(),
|
|
161
|
+
top_k: zod_1.z.number().int().nonnegative().optional(),
|
|
162
|
+
stop_sequences: zod_1.z.array(zod_1.z.string()).optional(),
|
|
163
|
+
metadata: zod_1.z.object({ user_id: zod_1.z.string().optional() }).strict().optional(),
|
|
164
|
+
})
|
|
165
|
+
.strict();
|
|
166
|
+
AnthropicToolMessagesCommand.ContentBlockSchema = zod_1.z.union([text, toolUse, thinking, redactedThinking]);
|
|
167
|
+
AnthropicToolMessagesCommand.ResponseSchema = zod_1.z
|
|
168
|
+
.object({
|
|
169
|
+
id: zod_1.z.string().min(1),
|
|
170
|
+
type: zod_1.z.literal('message'),
|
|
171
|
+
role: zod_1.z.literal(enums_1.ANTHROPIC_ROLE.ASSISTANT),
|
|
172
|
+
content: zod_1.z.array(AnthropicToolMessagesCommand.ContentBlockSchema),
|
|
173
|
+
model: zod_1.z.string(),
|
|
174
|
+
stop_reason: zod_1.z.string().nullable().default(null),
|
|
175
|
+
stop_sequence: zod_1.z.string().nullable().default(null),
|
|
176
|
+
usage: zod_1.z
|
|
177
|
+
.object({
|
|
178
|
+
input_tokens: zod_1.z.number().int().nonnegative(),
|
|
179
|
+
output_tokens: zod_1.z.number().int().nonnegative(),
|
|
180
|
+
cache_read_input_tokens: zod_1.z.number().int().nonnegative().optional(),
|
|
181
|
+
cache_creation_input_tokens: zod_1.z.number().int().nonnegative().optional(),
|
|
182
|
+
})
|
|
183
|
+
.loose(),
|
|
184
|
+
})
|
|
185
|
+
.loose();
|
|
186
|
+
AnthropicToolMessagesCommand.StreamEventSchema = zod_1.z.discriminatedUnion('type', [
|
|
187
|
+
zod_1.z
|
|
188
|
+
.object({ type: zod_1.z.literal(enums_1.ANTHROPIC_EVENT.MESSAGE_START), message: AnthropicToolMessagesCommand.ResponseSchema })
|
|
189
|
+
.loose(),
|
|
190
|
+
zod_1.z
|
|
191
|
+
.object({
|
|
192
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_EVENT.BLOCK_START),
|
|
193
|
+
index: zod_1.z.number().int().nonnegative(),
|
|
194
|
+
content_block: zod_1.z.union([
|
|
195
|
+
text,
|
|
196
|
+
toolUse,
|
|
197
|
+
thinking.partial({ signature: true }),
|
|
198
|
+
redactedThinking,
|
|
199
|
+
]),
|
|
200
|
+
})
|
|
201
|
+
.loose(),
|
|
202
|
+
zod_1.z
|
|
203
|
+
.object({
|
|
204
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_EVENT.BLOCK_DELTA),
|
|
205
|
+
index: zod_1.z.number().int().nonnegative(),
|
|
206
|
+
delta: zod_1.z.discriminatedUnion('type', [
|
|
207
|
+
zod_1.z.object({ type: zod_1.z.literal(enums_1.ANTHROPIC_DELTA.TEXT), text: zod_1.z.string() }).loose(),
|
|
208
|
+
zod_1.z
|
|
209
|
+
.object({
|
|
210
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_DELTA.INPUT_JSON),
|
|
211
|
+
partial_json: zod_1.z.string(),
|
|
212
|
+
})
|
|
213
|
+
.loose(),
|
|
214
|
+
zod_1.z
|
|
215
|
+
.object({ type: zod_1.z.literal(enums_1.ANTHROPIC_DELTA.THINKING), thinking: zod_1.z.string() })
|
|
216
|
+
.loose(),
|
|
217
|
+
zod_1.z
|
|
218
|
+
.object({
|
|
219
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_DELTA.SIGNATURE),
|
|
220
|
+
signature: zod_1.z.string(),
|
|
221
|
+
})
|
|
222
|
+
.loose(),
|
|
223
|
+
]),
|
|
224
|
+
})
|
|
225
|
+
.loose(),
|
|
226
|
+
zod_1.z
|
|
227
|
+
.object({
|
|
228
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_EVENT.BLOCK_STOP),
|
|
229
|
+
index: zod_1.z.number().int().nonnegative(),
|
|
230
|
+
})
|
|
231
|
+
.loose(),
|
|
232
|
+
zod_1.z
|
|
233
|
+
.object({
|
|
234
|
+
type: zod_1.z.literal(enums_1.ANTHROPIC_EVENT.MESSAGE_DELTA),
|
|
235
|
+
delta: zod_1.z
|
|
236
|
+
.object({
|
|
237
|
+
stop_reason: zod_1.z.string().nullable(),
|
|
238
|
+
stop_sequence: zod_1.z.string().nullable().optional(),
|
|
239
|
+
})
|
|
240
|
+
.loose(),
|
|
241
|
+
usage: AnthropicToolMessagesCommand.ResponseSchema.shape.usage.partial(),
|
|
242
|
+
})
|
|
243
|
+
.loose(),
|
|
244
|
+
zod_1.z.object({ type: zod_1.z.literal(enums_1.ANTHROPIC_EVENT.MESSAGE_STOP) }).loose(),
|
|
245
|
+
zod_1.z.object({ type: zod_1.z.literal(enums_1.ANTHROPIC_EVENT.PING) }).loose(),
|
|
246
|
+
zod_1.z.object({ type: zod_1.z.literal(enums_1.ANTHROPIC_EVENT.ERROR), error: zod_1.z.unknown() }).loose(),
|
|
247
|
+
]);
|
|
248
|
+
})(AnthropicToolMessagesCommand || (exports.AnthropicToolMessagesCommand = AnthropicToolMessagesCommand = {}));
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export * from './anthropic-files.command';
|
|
2
2
|
export * from './anthropic-messages.command';
|
|
3
|
+
export * from './anthropic-tool-messages.command';
|
|
3
4
|
export * from './anthropic-models.command';
|
|
4
5
|
export * from './common.schemas';
|
|
5
6
|
export * from './openai-files.command';
|
|
6
7
|
export * from './openai-models.command';
|
|
7
8
|
export * from './openai-responses.command';
|
|
9
|
+
export * from './openai-tool-responses.command';
|
|
10
|
+
export * from './openai-chat-completions.command';
|
|
@@ -16,8 +16,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./anthropic-files.command"), exports);
|
|
18
18
|
__exportStar(require("./anthropic-messages.command"), exports);
|
|
19
|
+
__exportStar(require("./anthropic-tool-messages.command"), exports);
|
|
19
20
|
__exportStar(require("./anthropic-models.command"), exports);
|
|
20
21
|
__exportStar(require("./common.schemas"), exports);
|
|
21
22
|
__exportStar(require("./openai-files.command"), exports);
|
|
22
23
|
__exportStar(require("./openai-models.command"), exports);
|
|
23
24
|
__exportStar(require("./openai-responses.command"), exports);
|
|
25
|
+
__exportStar(require("./openai-tool-responses.command"), exports);
|
|
26
|
+
__exportStar(require("./openai-chat-completions.command"), exports);
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OPENAI_ROLE, OPENAI_TOOL_TYPE, OPENAI_TOOL_CHOICE } from './openai-tool-responses.command';
|
|
3
|
+
import { TOOL_THINKING_TYPE } from '../../constants';
|
|
4
|
+
export declare const ToolExtraContentSchema: z.ZodObject<{
|
|
5
|
+
google: z.ZodOptional<z.ZodObject<{
|
|
6
|
+
thought_signature: z.ZodString;
|
|
7
|
+
}, z.core.$strict>>;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
export type ToolExtraContent = z.infer<typeof ToolExtraContentSchema>;
|
|
10
|
+
export declare namespace OpenAIChatCompletionsCommand {
|
|
11
|
+
const BodySchema: z.ZodObject<{
|
|
12
|
+
model: z.ZodString;
|
|
13
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
14
|
+
role: z.ZodEnum<typeof OPENAI_ROLE>;
|
|
15
|
+
content: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodArray<z.ZodObject<{
|
|
16
|
+
type: z.ZodLiteral<"text">;
|
|
17
|
+
text: z.ZodString;
|
|
18
|
+
}, z.core.$strict>>]>>;
|
|
19
|
+
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
type: z.ZodLiteral<OPENAI_TOOL_TYPE>;
|
|
22
|
+
function: z.ZodObject<{
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
arguments: z.ZodString;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
extra_content: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
google: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
thought_signature: z.ZodString;
|
|
29
|
+
}, z.core.$strict>>;
|
|
30
|
+
}, z.core.$strict>>;
|
|
31
|
+
}, z.core.$strict>>>;
|
|
32
|
+
tool_call_id: z.ZodOptional<z.ZodString>;
|
|
33
|
+
function_call: z.ZodOptional<z.ZodObject<{
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
arguments: z.ZodString;
|
|
36
|
+
}, z.core.$strict>>;
|
|
37
|
+
name: z.ZodOptional<z.ZodString>;
|
|
38
|
+
reasoning_content: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strict>>;
|
|
40
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
41
|
+
type: z.ZodLiteral<OPENAI_TOOL_TYPE>;
|
|
42
|
+
function: z.ZodObject<{
|
|
43
|
+
name: z.ZodString;
|
|
44
|
+
description: z.ZodOptional<z.ZodString>;
|
|
45
|
+
parameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
46
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
}, z.core.$strict>>>;
|
|
49
|
+
functions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
50
|
+
name: z.ZodString;
|
|
51
|
+
description: z.ZodOptional<z.ZodString>;
|
|
52
|
+
parameters: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
53
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
54
|
+
}, z.core.$strict>>>;
|
|
55
|
+
tool_choice: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<typeof OPENAI_TOOL_CHOICE>, z.ZodObject<{
|
|
56
|
+
type: z.ZodLiteral<OPENAI_TOOL_TYPE>;
|
|
57
|
+
function: z.ZodObject<{
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
}, z.core.$strict>;
|
|
60
|
+
}, z.core.$strict>]>>;
|
|
61
|
+
function_call: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
62
|
+
auto: OPENAI_TOOL_CHOICE.AUTO;
|
|
63
|
+
none: OPENAI_TOOL_CHOICE.NONE;
|
|
64
|
+
}>, z.ZodObject<{
|
|
65
|
+
name: z.ZodString;
|
|
66
|
+
}, z.core.$strict>]>>;
|
|
67
|
+
parallel_tool_calls: z.ZodOptional<z.ZodBoolean>;
|
|
68
|
+
reasoning_effort: z.ZodOptional<z.ZodString>;
|
|
69
|
+
thinking: z.ZodOptional<z.ZodObject<{
|
|
70
|
+
type: z.ZodEnum<typeof TOOL_THINKING_TYPE>;
|
|
71
|
+
}, z.core.$strict>>;
|
|
72
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
74
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
stream: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
stream_options: z.ZodOptional<z.ZodObject<{
|
|
78
|
+
include_usage: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
}, z.core.$strict>>;
|
|
80
|
+
n: z.ZodOptional<z.ZodLiteral<1>>;
|
|
81
|
+
user: z.ZodOptional<z.ZodString>;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
const ResponseSchema: z.ZodObject<{
|
|
84
|
+
id: z.ZodString;
|
|
85
|
+
object: z.ZodLiteral<"chat.completion">;
|
|
86
|
+
created: z.ZodNumber;
|
|
87
|
+
model: z.ZodString;
|
|
88
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
89
|
+
index: z.ZodNumber;
|
|
90
|
+
finish_reason: z.ZodEnum<{
|
|
91
|
+
content_filter: "content_filter";
|
|
92
|
+
function_call: "function_call";
|
|
93
|
+
length: "length";
|
|
94
|
+
stop: "stop";
|
|
95
|
+
tool_calls: "tool_calls";
|
|
96
|
+
}>;
|
|
97
|
+
message: z.ZodObject<{
|
|
98
|
+
role: z.ZodLiteral<OPENAI_ROLE.ASSISTANT>;
|
|
99
|
+
content: z.ZodNullable<z.ZodString>;
|
|
100
|
+
refusal: z.ZodOptional<z.ZodString>;
|
|
101
|
+
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
102
|
+
id: z.ZodString;
|
|
103
|
+
type: z.ZodLiteral<OPENAI_TOOL_TYPE>;
|
|
104
|
+
function: z.ZodObject<{
|
|
105
|
+
name: z.ZodString;
|
|
106
|
+
arguments: z.ZodString;
|
|
107
|
+
}, z.core.$strict>;
|
|
108
|
+
extra_content: z.ZodOptional<z.ZodObject<{
|
|
109
|
+
google: z.ZodOptional<z.ZodObject<{
|
|
110
|
+
thought_signature: z.ZodString;
|
|
111
|
+
}, z.core.$strict>>;
|
|
112
|
+
}, z.core.$strict>>;
|
|
113
|
+
}, z.core.$strict>>>;
|
|
114
|
+
function_call: z.ZodOptional<z.ZodObject<{
|
|
115
|
+
name: z.ZodString;
|
|
116
|
+
arguments: z.ZodString;
|
|
117
|
+
}, z.core.$strict>>;
|
|
118
|
+
reasoning_content: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, z.core.$strict>;
|
|
120
|
+
}, z.core.$strict>>;
|
|
121
|
+
usage: z.ZodObject<{
|
|
122
|
+
prompt_tokens: z.ZodNumber;
|
|
123
|
+
completion_tokens: z.ZodNumber;
|
|
124
|
+
total_tokens: z.ZodNumber;
|
|
125
|
+
prompt_tokens_details: z.ZodOptional<z.ZodObject<{
|
|
126
|
+
cached_tokens: z.ZodNumber;
|
|
127
|
+
}, z.core.$strip>>;
|
|
128
|
+
}, z.core.$strict>;
|
|
129
|
+
}, z.core.$strict>;
|
|
130
|
+
type Body = z.infer<typeof BodySchema>;
|
|
131
|
+
type Response = z.infer<typeof ResponseSchema>;
|
|
132
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenAIChatCompletionsCommand = exports.ToolExtraContentSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const openai_tool_responses_command_1 = require("./openai-tool-responses.command");
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
7
|
+
// Google returns signatures here; they must survive the next client tool turn.
|
|
8
|
+
exports.ToolExtraContentSchema = zod_1.z
|
|
9
|
+
.object({
|
|
10
|
+
google: zod_1.z.object({ thought_signature: zod_1.z.string() }).strict().optional(),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
const functionCall = zod_1.z.object({ name: zod_1.z.string().min(1), arguments: zod_1.z.string() }).strict();
|
|
14
|
+
const toolCall = zod_1.z
|
|
15
|
+
.object({
|
|
16
|
+
id: zod_1.z.string().min(1),
|
|
17
|
+
type: zod_1.z.literal(openai_tool_responses_command_1.OPENAI_TOOL_TYPE.FUNCTION),
|
|
18
|
+
function: functionCall,
|
|
19
|
+
extra_content: exports.ToolExtraContentSchema.optional(),
|
|
20
|
+
})
|
|
21
|
+
.strict();
|
|
22
|
+
var OpenAIChatCompletionsCommand;
|
|
23
|
+
(function (OpenAIChatCompletionsCommand) {
|
|
24
|
+
OpenAIChatCompletionsCommand.BodySchema = zod_1.z
|
|
25
|
+
.object({
|
|
26
|
+
model: zod_1.z.string().min(1),
|
|
27
|
+
messages: zod_1.z
|
|
28
|
+
.array(zod_1.z
|
|
29
|
+
.object({
|
|
30
|
+
role: zod_1.z.enum(openai_tool_responses_command_1.OPENAI_ROLE),
|
|
31
|
+
content: zod_1.z
|
|
32
|
+
.union([
|
|
33
|
+
zod_1.z.string(),
|
|
34
|
+
zod_1.z.null(),
|
|
35
|
+
zod_1.z.array(zod_1.z
|
|
36
|
+
.object({ type: zod_1.z.literal('text'), text: zod_1.z.string() })
|
|
37
|
+
.strict()),
|
|
38
|
+
])
|
|
39
|
+
.optional(),
|
|
40
|
+
tool_calls: zod_1.z.array(toolCall).optional(),
|
|
41
|
+
tool_call_id: zod_1.z.string().min(1).optional(),
|
|
42
|
+
function_call: functionCall.optional(),
|
|
43
|
+
name: zod_1.z.string().optional(),
|
|
44
|
+
reasoning_content: zod_1.z.string().optional(),
|
|
45
|
+
})
|
|
46
|
+
.strict())
|
|
47
|
+
.min(1),
|
|
48
|
+
tools: zod_1.z
|
|
49
|
+
.array(zod_1.z
|
|
50
|
+
.object({
|
|
51
|
+
type: zod_1.z.literal(openai_tool_responses_command_1.OPENAI_TOOL_TYPE.FUNCTION),
|
|
52
|
+
function: openai_tool_responses_command_1.OpenAIFunctionDefinitionSchema,
|
|
53
|
+
})
|
|
54
|
+
.strict())
|
|
55
|
+
.optional(),
|
|
56
|
+
functions: zod_1.z.array(openai_tool_responses_command_1.OpenAIFunctionDefinitionSchema).optional(),
|
|
57
|
+
tool_choice: zod_1.z
|
|
58
|
+
.union([
|
|
59
|
+
zod_1.z.enum(openai_tool_responses_command_1.OPENAI_TOOL_CHOICE),
|
|
60
|
+
zod_1.z
|
|
61
|
+
.object({
|
|
62
|
+
type: zod_1.z.literal(openai_tool_responses_command_1.OPENAI_TOOL_TYPE.FUNCTION),
|
|
63
|
+
function: zod_1.z.object({ name: zod_1.z.string().min(1) }).strict(),
|
|
64
|
+
})
|
|
65
|
+
.strict(),
|
|
66
|
+
])
|
|
67
|
+
.optional(),
|
|
68
|
+
function_call: zod_1.z
|
|
69
|
+
.union([
|
|
70
|
+
zod_1.z.enum([openai_tool_responses_command_1.OPENAI_TOOL_CHOICE.AUTO, openai_tool_responses_command_1.OPENAI_TOOL_CHOICE.NONE]),
|
|
71
|
+
zod_1.z.object({ name: zod_1.z.string().min(1) }).strict(),
|
|
72
|
+
])
|
|
73
|
+
.optional(),
|
|
74
|
+
parallel_tool_calls: zod_1.z.boolean().optional(),
|
|
75
|
+
reasoning_effort: zod_1.z.string().optional(),
|
|
76
|
+
thinking: zod_1.z
|
|
77
|
+
.object({ type: zod_1.z.enum(constants_1.TOOL_THINKING_TYPE) })
|
|
78
|
+
.strict()
|
|
79
|
+
.optional(),
|
|
80
|
+
max_tokens: zod_1.z.number().int().positive().optional(),
|
|
81
|
+
max_completion_tokens: zod_1.z.number().int().positive().optional(),
|
|
82
|
+
temperature: zod_1.z.number().optional(),
|
|
83
|
+
top_p: zod_1.z.number().optional(),
|
|
84
|
+
stream: zod_1.z.boolean().optional(),
|
|
85
|
+
stream_options: zod_1.z.object({ include_usage: zod_1.z.boolean().optional() }).strict().optional(),
|
|
86
|
+
n: zod_1.z.literal(1).optional(),
|
|
87
|
+
user: zod_1.z.string().optional(),
|
|
88
|
+
})
|
|
89
|
+
.strict();
|
|
90
|
+
OpenAIChatCompletionsCommand.ResponseSchema = zod_1.z
|
|
91
|
+
.object({
|
|
92
|
+
id: zod_1.z.string(),
|
|
93
|
+
object: zod_1.z.literal('chat.completion'),
|
|
94
|
+
created: zod_1.z.number(),
|
|
95
|
+
model: zod_1.z.string(),
|
|
96
|
+
choices: zod_1.z.array(zod_1.z
|
|
97
|
+
.object({
|
|
98
|
+
index: zod_1.z.number().int(),
|
|
99
|
+
finish_reason: zod_1.z.enum([
|
|
100
|
+
'stop',
|
|
101
|
+
'length',
|
|
102
|
+
'tool_calls',
|
|
103
|
+
'function_call',
|
|
104
|
+
'content_filter',
|
|
105
|
+
]),
|
|
106
|
+
message: zod_1.z
|
|
107
|
+
.object({
|
|
108
|
+
role: zod_1.z.literal(openai_tool_responses_command_1.OPENAI_ROLE.ASSISTANT),
|
|
109
|
+
content: zod_1.z.string().nullable(),
|
|
110
|
+
refusal: zod_1.z.string().optional(),
|
|
111
|
+
tool_calls: zod_1.z.array(toolCall).optional(),
|
|
112
|
+
function_call: functionCall.optional(),
|
|
113
|
+
reasoning_content: zod_1.z.string().optional(),
|
|
114
|
+
})
|
|
115
|
+
.strict(),
|
|
116
|
+
})
|
|
117
|
+
.strict()),
|
|
118
|
+
usage: zod_1.z
|
|
119
|
+
.object({
|
|
120
|
+
prompt_tokens: zod_1.z.number(),
|
|
121
|
+
completion_tokens: zod_1.z.number(),
|
|
122
|
+
total_tokens: zod_1.z.number(),
|
|
123
|
+
prompt_tokens_details: zod_1.z.object({ cached_tokens: zod_1.z.number() }).optional(),
|
|
124
|
+
})
|
|
125
|
+
.strict(),
|
|
126
|
+
})
|
|
127
|
+
.strict();
|
|
128
|
+
})(OpenAIChatCompletionsCommand || (exports.OpenAIChatCompletionsCommand = OpenAIChatCompletionsCommand = {}));
|