qwenproxy-cli 1.0.0
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 -0
- package/README.md +907 -0
- package/bin/qwenproxy.js +141 -0
- package/package.json +78 -0
- package/src/api/error-classifier.ts +159 -0
- package/src/api/error-helpers.ts +118 -0
- package/src/api/models.ts +261 -0
- package/src/api/server.ts +859 -0
- package/src/cache/memory-cache.ts +385 -0
- package/src/clean-cache.ts +204 -0
- package/src/core/account-concurrency.ts +671 -0
- package/src/core/account-manager.ts +297 -0
- package/src/core/account-priority.ts +163 -0
- package/src/core/accounts.ts +186 -0
- package/src/core/config.ts +383 -0
- package/src/core/crypto-utils.ts +79 -0
- package/src/core/database.ts +276 -0
- package/src/core/errors.ts +118 -0
- package/src/core/logger.ts +269 -0
- package/src/core/memory-usage.ts +84 -0
- package/src/core/metrics.ts +291 -0
- package/src/core/model-alias.ts +77 -0
- package/src/core/model-registry.ts +544 -0
- package/src/core/mutex.ts +119 -0
- package/src/core/paths.ts +199 -0
- package/src/core/prompt-limits.ts +214 -0
- package/src/core/reasoning-effort.ts +102 -0
- package/src/core/stream-registry.ts +96 -0
- package/src/core/waf-isolation.ts +117 -0
- package/src/core/watchdog.ts +195 -0
- package/src/delete-chats.ts +23 -0
- package/src/index.ts +64 -0
- package/src/login.ts +147 -0
- package/src/reset-cooldowns.ts +11 -0
- package/src/routes/anthropic/index.ts +355 -0
- package/src/routes/anthropic/translate.ts +522 -0
- package/src/routes/anthropic/types.ts +154 -0
- package/src/routes/anthropic/validation.ts +144 -0
- package/src/routes/chat/account.ts +1817 -0
- package/src/routes/chat/context.ts +241 -0
- package/src/routes/chat/errors.ts +85 -0
- package/src/routes/chat/helpers.ts +268 -0
- package/src/routes/chat/index.ts +618 -0
- package/src/routes/chat/media.ts +285 -0
- package/src/routes/chat/retry-policy.ts +754 -0
- package/src/routes/chat/stop.ts +98 -0
- package/src/routes/chat/streaming.ts +2710 -0
- package/src/routes/chat/validation.ts +526 -0
- package/src/routes/chat.ts +2 -0
- package/src/routes/completions.ts +290 -0
- package/src/routes/images.ts +139 -0
- package/src/routes/responses/adapter.ts +503 -0
- package/src/routes/responses/index.ts +405 -0
- package/src/routes/responses/state.ts +230 -0
- package/src/routes/responses/streaming.ts +528 -0
- package/src/routes/responses/types.ts +285 -0
- package/src/routes/responses/validation.ts +202 -0
- package/src/routes/upload.ts +731 -0
- package/src/routes/videos.ts +214 -0
- package/src/services/auth-playwright.ts +173 -0
- package/src/services/captcha-coordinator.ts +161 -0
- package/src/services/captcha-solver.ts +553 -0
- package/src/services/chat-cleanup.ts +80 -0
- package/src/services/context-meter.ts +317 -0
- package/src/services/fingerprint.ts +242 -0
- package/src/services/human-behavior.ts +173 -0
- package/src/services/media-generation.ts +1748 -0
- package/src/services/playwright.ts +2800 -0
- package/src/services/qwen-chat-pool.ts +345 -0
- package/src/services/qwen-errors.ts +133 -0
- package/src/services/qwen-headers.ts +79 -0
- package/src/services/qwen-thread-state.ts +393 -0
- package/src/services/qwen-url.ts +19 -0
- package/src/services/qwen.ts +3126 -0
- package/src/services/session-keeper.ts +88 -0
- package/src/services/token-estimation-metrics.ts +118 -0
- package/src/sync/claude-code.ts +75 -0
- package/src/sync/codex.ts +123 -0
- package/src/sync/index.ts +362 -0
- package/src/sync/omp.ts +105 -0
- package/src/sync/opencode.ts +214 -0
- package/src/sync/types.ts +53 -0
- package/src/sync/utils.ts +27 -0
- package/src/sync-clients.ts +189 -0
- package/src/tools/instructions.ts +137 -0
- package/src/tools/manifest.ts +81 -0
- package/src/tools/parser.ts +2989 -0
- package/src/tools/toolcall-tags.ts +142 -0
- package/src/tools/types.ts +53 -0
- package/src/tui/app.ts +264 -0
- package/src/tui/index.ts +61 -0
- package/src/tui/markdown.ts +258 -0
- package/src/tui/proxy-client.ts +326 -0
- package/src/tui/screen.ts +278 -0
- package/src/tui/server-manager.ts +270 -0
- package/src/tui/theme.ts +432 -0
- package/src/tui/types.ts +33 -0
- package/src/tui/views/accounts-view.ts +656 -0
- package/src/tui/views/chat-view.ts +823 -0
- package/src/tui/views/logs-view.ts +413 -0
- package/src/tui/views/status-view.ts +204 -0
- package/src/tui/views/storage-view.ts +291 -0
- package/src/tui/views/sync-view.ts +409 -0
- package/src/types/ali-oss.d.ts +32 -0
- package/src/utils/context-truncation.ts +84 -0
- package/src/utils/json.ts +380 -0
- package/src/utils/session-id.ts +37 -0
- package/src/utils/tool-call-guard.ts +85 -0
- package/src/utils/types.ts +109 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { JsonSchema, FunctionToolDefinition } from "../tools/types.ts";
|
|
2
|
+
export type { JsonSchema, FunctionToolDefinition };
|
|
3
|
+
|
|
4
|
+
/** Tool choice options */
|
|
5
|
+
export type ToolChoice =
|
|
6
|
+
| "auto"
|
|
7
|
+
| "none"
|
|
8
|
+
| "required"
|
|
9
|
+
| {
|
|
10
|
+
type: "function";
|
|
11
|
+
function: { name: string };
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// --- Message Types ---
|
|
15
|
+
|
|
16
|
+
export interface ToolCallFunction {
|
|
17
|
+
name: string;
|
|
18
|
+
arguments: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface MessageToolCall {
|
|
22
|
+
id: string;
|
|
23
|
+
type: "function";
|
|
24
|
+
function: ToolCallFunction;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Message {
|
|
28
|
+
role: string;
|
|
29
|
+
content: string | null;
|
|
30
|
+
/** Present on assistant messages that invoked tools */
|
|
31
|
+
tool_calls?: MessageToolCall[];
|
|
32
|
+
/** Present on tool/function response messages to link back to a call */
|
|
33
|
+
tool_call_id?: string;
|
|
34
|
+
/** Present on tool/function response messages */
|
|
35
|
+
name?: string;
|
|
36
|
+
/** Reasoning content for thinking models */
|
|
37
|
+
reasoning_content?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// --- Request Types ---
|
|
41
|
+
|
|
42
|
+
export interface OpenAIRequest {
|
|
43
|
+
model: string;
|
|
44
|
+
messages: Message[];
|
|
45
|
+
stream?: boolean;
|
|
46
|
+
/** QwenProxy media extension used by image/video chat models. */
|
|
47
|
+
size?: string;
|
|
48
|
+
tools?: FunctionToolDefinition[];
|
|
49
|
+
tool_choice?: ToolChoice;
|
|
50
|
+
user?: string;
|
|
51
|
+
session_id?: string;
|
|
52
|
+
conversation_id?: string;
|
|
53
|
+
/** OpenAI chat spec: none|minimal|low|medium|high|xhigh|max (reasoning models). */
|
|
54
|
+
reasoning_effort?: string | null;
|
|
55
|
+
/** camelCase alias overlaid by OpenCode-style configs. */
|
|
56
|
+
reasoningEffort?: string | null;
|
|
57
|
+
stream_options?: {
|
|
58
|
+
include_usage?: boolean;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// --- Response Types ---
|
|
63
|
+
|
|
64
|
+
export interface ToolCall {
|
|
65
|
+
index: number;
|
|
66
|
+
id?: string;
|
|
67
|
+
type: string;
|
|
68
|
+
function: {
|
|
69
|
+
name: string;
|
|
70
|
+
arguments: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface ChoiceDelta {
|
|
75
|
+
role?: string;
|
|
76
|
+
content?: string | null;
|
|
77
|
+
reasoning_content?: string | null;
|
|
78
|
+
tool_calls?: ToolCall[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface Choice {
|
|
82
|
+
index: number;
|
|
83
|
+
delta?: ChoiceDelta;
|
|
84
|
+
message?: ChoiceDelta;
|
|
85
|
+
finish_reason: string | null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface Usage {
|
|
89
|
+
prompt_tokens: number;
|
|
90
|
+
completion_tokens: number;
|
|
91
|
+
total_tokens: number;
|
|
92
|
+
prompt_tokens_details?: {
|
|
93
|
+
cached_tokens: number;
|
|
94
|
+
text_tokens?: number;
|
|
95
|
+
};
|
|
96
|
+
completion_tokens_details?: {
|
|
97
|
+
reasoning_tokens?: number;
|
|
98
|
+
text_tokens?: number;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface ChatCompletionChunk {
|
|
103
|
+
id: string;
|
|
104
|
+
object: string;
|
|
105
|
+
created: number;
|
|
106
|
+
model: string;
|
|
107
|
+
choices: Choice[];
|
|
108
|
+
usage?: Usage;
|
|
109
|
+
}
|