qwenproxy-cli 1.0.0 → 1.0.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/LICENSE +14 -14
- package/README.md +906 -906
- package/bin/qwenproxy.js +5 -1
- package/package.json +77 -78
- package/src/api/error-classifier.ts +159 -159
- package/src/api/error-helpers.ts +118 -118
- package/src/api/models.ts +261 -261
- package/src/api/server.ts +860 -859
- package/src/cache/memory-cache.ts +385 -385
- package/src/clean-cache.ts +204 -204
- package/src/core/account-concurrency.ts +671 -671
- package/src/core/account-manager.ts +301 -297
- package/src/core/account-priority.ts +163 -163
- package/src/core/accounts.ts +186 -186
- package/src/core/config.ts +383 -383
- package/src/core/crypto-utils.ts +79 -79
- package/src/core/database.ts +276 -276
- package/src/core/errors.ts +118 -118
- package/src/core/logger.ts +269 -269
- package/src/core/memory-usage.ts +84 -84
- package/src/core/metrics.ts +291 -291
- package/src/core/model-alias.ts +77 -77
- package/src/core/model-registry.ts +544 -544
- package/src/core/mutex.ts +119 -119
- package/src/core/paths.ts +199 -199
- package/src/core/prompt-limits.ts +214 -214
- package/src/core/reasoning-effort.ts +102 -102
- package/src/core/stream-registry.ts +96 -96
- package/src/core/waf-isolation.ts +117 -117
- package/src/core/watchdog.ts +195 -195
- package/src/delete-chats.ts +23 -23
- package/src/index.ts +65 -64
- package/src/login.ts +147 -147
- package/src/reset-cooldowns.ts +11 -11
- package/src/routes/anthropic/index.ts +355 -355
- package/src/routes/anthropic/translate.ts +522 -522
- package/src/routes/anthropic/types.ts +154 -154
- package/src/routes/anthropic/validation.ts +144 -144
- package/src/routes/chat/account.ts +1817 -1817
- package/src/routes/chat/context.ts +241 -241
- package/src/routes/chat/errors.ts +85 -85
- package/src/routes/chat/helpers.ts +268 -268
- package/src/routes/chat/index.ts +618 -618
- package/src/routes/chat/media.ts +285 -285
- package/src/routes/chat/retry-policy.ts +754 -754
- package/src/routes/chat/stop.ts +98 -98
- package/src/routes/chat/streaming.ts +2710 -2710
- package/src/routes/chat/validation.ts +526 -526
- package/src/routes/chat.ts +2 -2
- package/src/routes/completions.ts +290 -290
- package/src/routes/images.ts +139 -139
- package/src/routes/responses/adapter.ts +503 -503
- package/src/routes/responses/index.ts +405 -405
- package/src/routes/responses/state.ts +230 -230
- package/src/routes/responses/streaming.ts +528 -528
- package/src/routes/responses/types.ts +285 -285
- package/src/routes/responses/validation.ts +202 -202
- package/src/routes/upload.ts +731 -731
- package/src/routes/videos.ts +214 -214
- package/src/services/auth-playwright.ts +173 -173
- package/src/services/captcha-coordinator.ts +161 -161
- package/src/services/captcha-solver.ts +553 -553
- package/src/services/chat-cleanup.ts +80 -80
- package/src/services/context-meter.ts +317 -317
- package/src/services/fingerprint.ts +242 -242
- package/src/services/human-behavior.ts +173 -173
- package/src/services/media-generation.ts +1748 -1748
- package/src/services/playwright.ts +2878 -2800
- package/src/services/qwen-chat-pool.ts +345 -345
- package/src/services/qwen-errors.ts +133 -133
- package/src/services/qwen-headers.ts +79 -79
- package/src/services/qwen-thread-state.ts +393 -393
- package/src/services/qwen-url.ts +19 -19
- package/src/services/qwen.ts +3126 -3126
- package/src/services/session-keeper.ts +88 -88
- package/src/services/token-estimation-metrics.ts +118 -118
- package/src/sync/claude-code.ts +75 -75
- package/src/sync/codex.ts +123 -123
- package/src/sync/index.ts +362 -362
- package/src/sync/omp.ts +105 -105
- package/src/sync/opencode.ts +214 -214
- package/src/sync/types.ts +53 -53
- package/src/sync/utils.ts +27 -27
- package/src/sync-clients.ts +189 -189
- package/src/tools/instructions.ts +137 -137
- package/src/tools/manifest.ts +81 -81
- package/src/tools/parser.ts +2989 -2989
- package/src/tools/toolcall-tags.ts +142 -142
- package/src/tui/app.ts +259 -264
- package/src/tui/index.ts +61 -61
- package/src/tui/markdown.ts +258 -258
- package/src/tui/proxy-client.ts +331 -326
- package/src/tui/screen.ts +294 -278
- package/src/tui/server-manager.ts +270 -270
- package/src/tui/theme.ts +432 -432
- package/src/tui/types.ts +33 -33
- package/src/tui/views/accounts-view.ts +656 -656
- package/src/tui/views/chat-view.ts +1018 -823
- package/src/tui/views/logs-view.ts +479 -413
- package/src/tui/views/status-view.ts +204 -204
- package/src/tui/views/storage-view.ts +304 -291
- package/src/tui/views/sync-view.ts +409 -409
- package/src/types/ali-oss.d.ts +32 -32
- package/src/update-cli.ts +121 -0
- package/src/utils/context-truncation.ts +84 -84
- package/src/utils/json.ts +380 -380
- package/src/utils/session-id.ts +37 -37
- package/src/utils/tool-call-guard.ts +84 -84
- package/src/utils/types.ts +109 -109
|
@@ -1,285 +1,285 @@
|
|
|
1
|
-
// OpenAI Responses API types (/v1/responses)
|
|
2
|
-
|
|
3
|
-
import type { ContextMeterSnapshot } from "../../services/context-meter.ts";
|
|
4
|
-
|
|
5
|
-
// ============ Request types ============
|
|
6
|
-
|
|
7
|
-
export interface ResponsesRequest {
|
|
8
|
-
model: string;
|
|
9
|
-
input: string | ResponsesInputMessage[];
|
|
10
|
-
instructions?: string | null;
|
|
11
|
-
stream?: boolean;
|
|
12
|
-
previous_response_id?: string | null;
|
|
13
|
-
tools?: ResponsesTool[] | null;
|
|
14
|
-
tool_choice?: ResponsesToolChoice | null;
|
|
15
|
-
temperature?: number;
|
|
16
|
-
top_p?: number;
|
|
17
|
-
max_output_tokens?: number;
|
|
18
|
-
store?: boolean;
|
|
19
|
-
user?: string;
|
|
20
|
-
metadata?: Record<string, string>;
|
|
21
|
-
parallel_tool_calls?: boolean;
|
|
22
|
-
// Reasoning (optional, passthrough — accepts any string, normalized internally)
|
|
23
|
-
reasoning?: {
|
|
24
|
-
effort?: string;
|
|
25
|
-
summary?: "auto" | "concise" | "detailed";
|
|
26
|
-
} | null;
|
|
27
|
-
reasoning_effort?: string;
|
|
28
|
-
text?: {
|
|
29
|
-
format?: {
|
|
30
|
-
type?: "text" | "json_schema" | "json_object";
|
|
31
|
-
name?: string;
|
|
32
|
-
description?: string;
|
|
33
|
-
schema?: Record<string, unknown>;
|
|
34
|
-
strict?: boolean;
|
|
35
|
-
};
|
|
36
|
-
verbosity?: "low" | "medium" | "high";
|
|
37
|
-
} | null;
|
|
38
|
-
truncation?: "auto" | "disabled";
|
|
39
|
-
service_tier?: "auto" | "default" | "flex" | "priority";
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type ResponsesInputMessage =
|
|
43
|
-
| ResponsesMessageInputItem
|
|
44
|
-
| ResponsesFunctionCallInputItem
|
|
45
|
-
| ResponsesFunctionCallOutputInputItem;
|
|
46
|
-
|
|
47
|
-
export interface ResponsesMessageInputItem {
|
|
48
|
-
type?: "message";
|
|
49
|
-
role: "user" | "assistant" | "system" | "developer";
|
|
50
|
-
content: string | ResponsesContentPart[];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface ResponsesFunctionCallInputItem {
|
|
54
|
-
type: "function_call";
|
|
55
|
-
call_id?: string;
|
|
56
|
-
name?: string;
|
|
57
|
-
arguments?: string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface ResponsesFunctionCallOutputInputItem {
|
|
61
|
-
type: "function_call_output";
|
|
62
|
-
call_id?: string;
|
|
63
|
-
output?: string;
|
|
64
|
-
content?: string | ResponsesContentPart[];
|
|
65
|
-
role?: "tool";
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface ResponsesContentPart {
|
|
69
|
-
type: "input_text" | "output_text" | "text" | "input_image" | "input_file";
|
|
70
|
-
text?: string;
|
|
71
|
-
// For images
|
|
72
|
-
image_url?: string;
|
|
73
|
-
detail?: "auto" | "low" | "high";
|
|
74
|
-
// For files
|
|
75
|
-
file?: {
|
|
76
|
-
file_id?: string;
|
|
77
|
-
file_data?: string;
|
|
78
|
-
filename?: string;
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface ResponsesFunctionTool {
|
|
83
|
-
type: "function";
|
|
84
|
-
name: string;
|
|
85
|
-
description?: string;
|
|
86
|
-
parameters?: Record<string, unknown>;
|
|
87
|
-
strict?: boolean;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface ResponsesBuiltinTool {
|
|
91
|
-
type: string; // web_search, file_search, shell, code_interpreter, etc.
|
|
92
|
-
[key: string]: unknown;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export type ResponsesTool = ResponsesFunctionTool | ResponsesBuiltinTool;
|
|
96
|
-
|
|
97
|
-
export type ResponsesToolChoice =
|
|
98
|
-
| "auto"
|
|
99
|
-
| "required"
|
|
100
|
-
| "none"
|
|
101
|
-
| {
|
|
102
|
-
type: "function";
|
|
103
|
-
name?: string;
|
|
104
|
-
function?: { name: string };
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
// ============ Response types ============
|
|
108
|
-
|
|
109
|
-
export interface ResponsesResponse {
|
|
110
|
-
id: string;
|
|
111
|
-
object: "response";
|
|
112
|
-
created_at: number;
|
|
113
|
-
model: string;
|
|
114
|
-
status: "completed" | "failed" | "in_progress" | "cancelled" | "incomplete";
|
|
115
|
-
error?: {
|
|
116
|
-
code: string;
|
|
117
|
-
message: string;
|
|
118
|
-
} | null;
|
|
119
|
-
incomplete_details?: {
|
|
120
|
-
reason: string;
|
|
121
|
-
} | null;
|
|
122
|
-
output: ResponsesOutputItem[];
|
|
123
|
-
parallel_tool_calls?: boolean;
|
|
124
|
-
tool_choice?: ResponsesToolChoice;
|
|
125
|
-
tools?: ResponsesTool[];
|
|
126
|
-
usage?: ResponsesUsage;
|
|
127
|
-
// Metadata
|
|
128
|
-
temperature?: number;
|
|
129
|
-
top_p?: number;
|
|
130
|
-
max_output_tokens?: number;
|
|
131
|
-
previous_response_id?: string | null;
|
|
132
|
-
/** ID of the last response in this conversation chain (for client memory) */
|
|
133
|
-
last_response_id?: string | null;
|
|
134
|
-
metadata?: Record<string, string>;
|
|
135
|
-
text?: { verbosity?: "low" | "medium" | "high"; format?: { type: "text" } };
|
|
136
|
-
reasoning?: {
|
|
137
|
-
effort?: string;
|
|
138
|
-
summary?: "auto" | "concise" | "detailed";
|
|
139
|
-
};
|
|
140
|
-
truncation?: "auto" | "disabled";
|
|
141
|
-
user?: string;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export interface ResponsesUsage {
|
|
145
|
-
input_tokens: number;
|
|
146
|
-
output_tokens: number;
|
|
147
|
-
total_tokens: number;
|
|
148
|
-
input_tokens_details: {
|
|
149
|
-
cached_tokens: number;
|
|
150
|
-
};
|
|
151
|
-
output_tokens_details: {
|
|
152
|
-
reasoning_tokens: number;
|
|
153
|
-
};
|
|
154
|
-
/** Optional QwenProxy diagnostic extension when context metering is enabled. */
|
|
155
|
-
context_meter?: ContextMeterSnapshot;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export interface ResponsesOutputReasoning {
|
|
159
|
-
type: "reasoning";
|
|
160
|
-
id: string;
|
|
161
|
-
summary: Array<{ type: "summary_text"; text: string }>;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export type ResponsesOutputItem =
|
|
165
|
-
| ResponsesOutputMessage
|
|
166
|
-
| ResponsesOutputFunctionCall
|
|
167
|
-
| ResponsesOutputReasoning;
|
|
168
|
-
|
|
169
|
-
export interface ResponsesOutputMessage {
|
|
170
|
-
type: "message";
|
|
171
|
-
id: string;
|
|
172
|
-
role: "assistant";
|
|
173
|
-
status: "completed" | "in_progress";
|
|
174
|
-
content: ResponsesOutputContentPart[];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export interface ResponsesOutputFunctionCall {
|
|
178
|
-
type: "function_call";
|
|
179
|
-
id: string;
|
|
180
|
-
call_id: string;
|
|
181
|
-
name: string;
|
|
182
|
-
arguments: string;
|
|
183
|
-
status: "completed" | "in_progress";
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export interface ResponsesOutputContentPart {
|
|
187
|
-
type: "output_text";
|
|
188
|
-
text: string;
|
|
189
|
-
annotations: unknown[];
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// ============ Streaming event types ============
|
|
193
|
-
|
|
194
|
-
export type ResponsesStreamEvent =
|
|
195
|
-
| { type: "response.created"; response: ResponsesResponse; sequence_number?: number }
|
|
196
|
-
| { type: "response.in_progress"; response: ResponsesResponse; sequence_number?: number }
|
|
197
|
-
| {
|
|
198
|
-
type: "response.output_item.added";
|
|
199
|
-
output_index: number;
|
|
200
|
-
item: ResponsesOutputItem;
|
|
201
|
-
sequence_number?: number;
|
|
202
|
-
}
|
|
203
|
-
| {
|
|
204
|
-
type: "response.content_part.added";
|
|
205
|
-
item_id: string;
|
|
206
|
-
output_index: number;
|
|
207
|
-
content_index: number;
|
|
208
|
-
part: ResponsesOutputContentPart;
|
|
209
|
-
sequence_number?: number;
|
|
210
|
-
}
|
|
211
|
-
| {
|
|
212
|
-
type: "response.output_text.delta";
|
|
213
|
-
item_id: string;
|
|
214
|
-
output_index: number;
|
|
215
|
-
content_index: number;
|
|
216
|
-
delta: string;
|
|
217
|
-
sequence_number?: number;
|
|
218
|
-
}
|
|
219
|
-
| {
|
|
220
|
-
type: "response.output_text.done";
|
|
221
|
-
item_id: string;
|
|
222
|
-
output_index: number;
|
|
223
|
-
content_index: number;
|
|
224
|
-
text: string;
|
|
225
|
-
sequence_number?: number;
|
|
226
|
-
}
|
|
227
|
-
| {
|
|
228
|
-
type: "response.content_part.done";
|
|
229
|
-
item_id: string;
|
|
230
|
-
output_index: number;
|
|
231
|
-
content_index: number;
|
|
232
|
-
part: ResponsesOutputContentPart;
|
|
233
|
-
sequence_number?: number;
|
|
234
|
-
}
|
|
235
|
-
| {
|
|
236
|
-
type: "response.output_item.done";
|
|
237
|
-
output_index: number;
|
|
238
|
-
item: ResponsesOutputItem;
|
|
239
|
-
sequence_number?: number;
|
|
240
|
-
}
|
|
241
|
-
| {
|
|
242
|
-
type: "response.function_call_arguments.delta";
|
|
243
|
-
item_id: string;
|
|
244
|
-
output_index: number;
|
|
245
|
-
delta: string;
|
|
246
|
-
sequence_number?: number;
|
|
247
|
-
}
|
|
248
|
-
| {
|
|
249
|
-
type: "response.function_call_arguments.done";
|
|
250
|
-
item_id: string;
|
|
251
|
-
output_index: number;
|
|
252
|
-
arguments: string;
|
|
253
|
-
sequence_number?: number;
|
|
254
|
-
}
|
|
255
|
-
| {
|
|
256
|
-
type: "response.reasoning_summary_part.added";
|
|
257
|
-
item_id: string;
|
|
258
|
-
output_index: number;
|
|
259
|
-
part: { type: "summary_text"; text: string };
|
|
260
|
-
sequence_number?: number;
|
|
261
|
-
}
|
|
262
|
-
| {
|
|
263
|
-
type: "response.reasoning_summary_text.delta";
|
|
264
|
-
item_id: string;
|
|
265
|
-
output_index: number;
|
|
266
|
-
delta: string;
|
|
267
|
-
sequence_number?: number;
|
|
268
|
-
}
|
|
269
|
-
| {
|
|
270
|
-
type: "response.reasoning_summary_text.done";
|
|
271
|
-
item_id: string;
|
|
272
|
-
output_index: number;
|
|
273
|
-
text: string;
|
|
274
|
-
sequence_number?: number;
|
|
275
|
-
}
|
|
276
|
-
| {
|
|
277
|
-
type: "response.reasoning_summary_part.done";
|
|
278
|
-
item_id: string;
|
|
279
|
-
output_index: number;
|
|
280
|
-
part: { type: "summary_text"; text: string };
|
|
281
|
-
sequence_number?: number;
|
|
282
|
-
}
|
|
283
|
-
| { type: "response.completed"; response: ResponsesResponse; sequence_number?: number }
|
|
284
|
-
| { type: "response.failed"; response: ResponsesResponse; sequence_number?: number }
|
|
285
|
-
| { type: "error"; code: string; message: string; sequence_number?: number };
|
|
1
|
+
// OpenAI Responses API types (/v1/responses)
|
|
2
|
+
|
|
3
|
+
import type { ContextMeterSnapshot } from "../../services/context-meter.ts";
|
|
4
|
+
|
|
5
|
+
// ============ Request types ============
|
|
6
|
+
|
|
7
|
+
export interface ResponsesRequest {
|
|
8
|
+
model: string;
|
|
9
|
+
input: string | ResponsesInputMessage[];
|
|
10
|
+
instructions?: string | null;
|
|
11
|
+
stream?: boolean;
|
|
12
|
+
previous_response_id?: string | null;
|
|
13
|
+
tools?: ResponsesTool[] | null;
|
|
14
|
+
tool_choice?: ResponsesToolChoice | null;
|
|
15
|
+
temperature?: number;
|
|
16
|
+
top_p?: number;
|
|
17
|
+
max_output_tokens?: number;
|
|
18
|
+
store?: boolean;
|
|
19
|
+
user?: string;
|
|
20
|
+
metadata?: Record<string, string>;
|
|
21
|
+
parallel_tool_calls?: boolean;
|
|
22
|
+
// Reasoning (optional, passthrough — accepts any string, normalized internally)
|
|
23
|
+
reasoning?: {
|
|
24
|
+
effort?: string;
|
|
25
|
+
summary?: "auto" | "concise" | "detailed";
|
|
26
|
+
} | null;
|
|
27
|
+
reasoning_effort?: string;
|
|
28
|
+
text?: {
|
|
29
|
+
format?: {
|
|
30
|
+
type?: "text" | "json_schema" | "json_object";
|
|
31
|
+
name?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
schema?: Record<string, unknown>;
|
|
34
|
+
strict?: boolean;
|
|
35
|
+
};
|
|
36
|
+
verbosity?: "low" | "medium" | "high";
|
|
37
|
+
} | null;
|
|
38
|
+
truncation?: "auto" | "disabled";
|
|
39
|
+
service_tier?: "auto" | "default" | "flex" | "priority";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ResponsesInputMessage =
|
|
43
|
+
| ResponsesMessageInputItem
|
|
44
|
+
| ResponsesFunctionCallInputItem
|
|
45
|
+
| ResponsesFunctionCallOutputInputItem;
|
|
46
|
+
|
|
47
|
+
export interface ResponsesMessageInputItem {
|
|
48
|
+
type?: "message";
|
|
49
|
+
role: "user" | "assistant" | "system" | "developer";
|
|
50
|
+
content: string | ResponsesContentPart[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ResponsesFunctionCallInputItem {
|
|
54
|
+
type: "function_call";
|
|
55
|
+
call_id?: string;
|
|
56
|
+
name?: string;
|
|
57
|
+
arguments?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface ResponsesFunctionCallOutputInputItem {
|
|
61
|
+
type: "function_call_output";
|
|
62
|
+
call_id?: string;
|
|
63
|
+
output?: string;
|
|
64
|
+
content?: string | ResponsesContentPart[];
|
|
65
|
+
role?: "tool";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ResponsesContentPart {
|
|
69
|
+
type: "input_text" | "output_text" | "text" | "input_image" | "input_file";
|
|
70
|
+
text?: string;
|
|
71
|
+
// For images
|
|
72
|
+
image_url?: string;
|
|
73
|
+
detail?: "auto" | "low" | "high";
|
|
74
|
+
// For files
|
|
75
|
+
file?: {
|
|
76
|
+
file_id?: string;
|
|
77
|
+
file_data?: string;
|
|
78
|
+
filename?: string;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface ResponsesFunctionTool {
|
|
83
|
+
type: "function";
|
|
84
|
+
name: string;
|
|
85
|
+
description?: string;
|
|
86
|
+
parameters?: Record<string, unknown>;
|
|
87
|
+
strict?: boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface ResponsesBuiltinTool {
|
|
91
|
+
type: string; // web_search, file_search, shell, code_interpreter, etc.
|
|
92
|
+
[key: string]: unknown;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export type ResponsesTool = ResponsesFunctionTool | ResponsesBuiltinTool;
|
|
96
|
+
|
|
97
|
+
export type ResponsesToolChoice =
|
|
98
|
+
| "auto"
|
|
99
|
+
| "required"
|
|
100
|
+
| "none"
|
|
101
|
+
| {
|
|
102
|
+
type: "function";
|
|
103
|
+
name?: string;
|
|
104
|
+
function?: { name: string };
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// ============ Response types ============
|
|
108
|
+
|
|
109
|
+
export interface ResponsesResponse {
|
|
110
|
+
id: string;
|
|
111
|
+
object: "response";
|
|
112
|
+
created_at: number;
|
|
113
|
+
model: string;
|
|
114
|
+
status: "completed" | "failed" | "in_progress" | "cancelled" | "incomplete";
|
|
115
|
+
error?: {
|
|
116
|
+
code: string;
|
|
117
|
+
message: string;
|
|
118
|
+
} | null;
|
|
119
|
+
incomplete_details?: {
|
|
120
|
+
reason: string;
|
|
121
|
+
} | null;
|
|
122
|
+
output: ResponsesOutputItem[];
|
|
123
|
+
parallel_tool_calls?: boolean;
|
|
124
|
+
tool_choice?: ResponsesToolChoice;
|
|
125
|
+
tools?: ResponsesTool[];
|
|
126
|
+
usage?: ResponsesUsage;
|
|
127
|
+
// Metadata
|
|
128
|
+
temperature?: number;
|
|
129
|
+
top_p?: number;
|
|
130
|
+
max_output_tokens?: number;
|
|
131
|
+
previous_response_id?: string | null;
|
|
132
|
+
/** ID of the last response in this conversation chain (for client memory) */
|
|
133
|
+
last_response_id?: string | null;
|
|
134
|
+
metadata?: Record<string, string>;
|
|
135
|
+
text?: { verbosity?: "low" | "medium" | "high"; format?: { type: "text" } };
|
|
136
|
+
reasoning?: {
|
|
137
|
+
effort?: string;
|
|
138
|
+
summary?: "auto" | "concise" | "detailed";
|
|
139
|
+
};
|
|
140
|
+
truncation?: "auto" | "disabled";
|
|
141
|
+
user?: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface ResponsesUsage {
|
|
145
|
+
input_tokens: number;
|
|
146
|
+
output_tokens: number;
|
|
147
|
+
total_tokens: number;
|
|
148
|
+
input_tokens_details: {
|
|
149
|
+
cached_tokens: number;
|
|
150
|
+
};
|
|
151
|
+
output_tokens_details: {
|
|
152
|
+
reasoning_tokens: number;
|
|
153
|
+
};
|
|
154
|
+
/** Optional QwenProxy diagnostic extension when context metering is enabled. */
|
|
155
|
+
context_meter?: ContextMeterSnapshot;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface ResponsesOutputReasoning {
|
|
159
|
+
type: "reasoning";
|
|
160
|
+
id: string;
|
|
161
|
+
summary: Array<{ type: "summary_text"; text: string }>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export type ResponsesOutputItem =
|
|
165
|
+
| ResponsesOutputMessage
|
|
166
|
+
| ResponsesOutputFunctionCall
|
|
167
|
+
| ResponsesOutputReasoning;
|
|
168
|
+
|
|
169
|
+
export interface ResponsesOutputMessage {
|
|
170
|
+
type: "message";
|
|
171
|
+
id: string;
|
|
172
|
+
role: "assistant";
|
|
173
|
+
status: "completed" | "in_progress";
|
|
174
|
+
content: ResponsesOutputContentPart[];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface ResponsesOutputFunctionCall {
|
|
178
|
+
type: "function_call";
|
|
179
|
+
id: string;
|
|
180
|
+
call_id: string;
|
|
181
|
+
name: string;
|
|
182
|
+
arguments: string;
|
|
183
|
+
status: "completed" | "in_progress";
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface ResponsesOutputContentPart {
|
|
187
|
+
type: "output_text";
|
|
188
|
+
text: string;
|
|
189
|
+
annotations: unknown[];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ============ Streaming event types ============
|
|
193
|
+
|
|
194
|
+
export type ResponsesStreamEvent =
|
|
195
|
+
| { type: "response.created"; response: ResponsesResponse; sequence_number?: number }
|
|
196
|
+
| { type: "response.in_progress"; response: ResponsesResponse; sequence_number?: number }
|
|
197
|
+
| {
|
|
198
|
+
type: "response.output_item.added";
|
|
199
|
+
output_index: number;
|
|
200
|
+
item: ResponsesOutputItem;
|
|
201
|
+
sequence_number?: number;
|
|
202
|
+
}
|
|
203
|
+
| {
|
|
204
|
+
type: "response.content_part.added";
|
|
205
|
+
item_id: string;
|
|
206
|
+
output_index: number;
|
|
207
|
+
content_index: number;
|
|
208
|
+
part: ResponsesOutputContentPart;
|
|
209
|
+
sequence_number?: number;
|
|
210
|
+
}
|
|
211
|
+
| {
|
|
212
|
+
type: "response.output_text.delta";
|
|
213
|
+
item_id: string;
|
|
214
|
+
output_index: number;
|
|
215
|
+
content_index: number;
|
|
216
|
+
delta: string;
|
|
217
|
+
sequence_number?: number;
|
|
218
|
+
}
|
|
219
|
+
| {
|
|
220
|
+
type: "response.output_text.done";
|
|
221
|
+
item_id: string;
|
|
222
|
+
output_index: number;
|
|
223
|
+
content_index: number;
|
|
224
|
+
text: string;
|
|
225
|
+
sequence_number?: number;
|
|
226
|
+
}
|
|
227
|
+
| {
|
|
228
|
+
type: "response.content_part.done";
|
|
229
|
+
item_id: string;
|
|
230
|
+
output_index: number;
|
|
231
|
+
content_index: number;
|
|
232
|
+
part: ResponsesOutputContentPart;
|
|
233
|
+
sequence_number?: number;
|
|
234
|
+
}
|
|
235
|
+
| {
|
|
236
|
+
type: "response.output_item.done";
|
|
237
|
+
output_index: number;
|
|
238
|
+
item: ResponsesOutputItem;
|
|
239
|
+
sequence_number?: number;
|
|
240
|
+
}
|
|
241
|
+
| {
|
|
242
|
+
type: "response.function_call_arguments.delta";
|
|
243
|
+
item_id: string;
|
|
244
|
+
output_index: number;
|
|
245
|
+
delta: string;
|
|
246
|
+
sequence_number?: number;
|
|
247
|
+
}
|
|
248
|
+
| {
|
|
249
|
+
type: "response.function_call_arguments.done";
|
|
250
|
+
item_id: string;
|
|
251
|
+
output_index: number;
|
|
252
|
+
arguments: string;
|
|
253
|
+
sequence_number?: number;
|
|
254
|
+
}
|
|
255
|
+
| {
|
|
256
|
+
type: "response.reasoning_summary_part.added";
|
|
257
|
+
item_id: string;
|
|
258
|
+
output_index: number;
|
|
259
|
+
part: { type: "summary_text"; text: string };
|
|
260
|
+
sequence_number?: number;
|
|
261
|
+
}
|
|
262
|
+
| {
|
|
263
|
+
type: "response.reasoning_summary_text.delta";
|
|
264
|
+
item_id: string;
|
|
265
|
+
output_index: number;
|
|
266
|
+
delta: string;
|
|
267
|
+
sequence_number?: number;
|
|
268
|
+
}
|
|
269
|
+
| {
|
|
270
|
+
type: "response.reasoning_summary_text.done";
|
|
271
|
+
item_id: string;
|
|
272
|
+
output_index: number;
|
|
273
|
+
text: string;
|
|
274
|
+
sequence_number?: number;
|
|
275
|
+
}
|
|
276
|
+
| {
|
|
277
|
+
type: "response.reasoning_summary_part.done";
|
|
278
|
+
item_id: string;
|
|
279
|
+
output_index: number;
|
|
280
|
+
part: { type: "summary_text"; text: string };
|
|
281
|
+
sequence_number?: number;
|
|
282
|
+
}
|
|
283
|
+
| { type: "response.completed"; response: ResponsesResponse; sequence_number?: number }
|
|
284
|
+
| { type: "response.failed"; response: ResponsesResponse; sequence_number?: number }
|
|
285
|
+
| { type: "error"; code: string; message: string; sequence_number?: number };
|