codefree-proxy 0.1.2 → 0.1.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.
@@ -1,6 +1,60 @@
1
- export const DEFAULT_MODEL = 'GLM-5.1';
2
- export const SUPPORTED_MODELS = ['GLM-5.1', 'GLM-4.7', 'Qwen3.5-122B-A10B'];
1
+ export const DEFAULT_MODEL = 'DeepSeek-V4-Flash-0731';
2
+ // Keep the CodeFree models selected for local clients.
3
+ export const SUPPORTED_MODELS = [
4
+ 'DeepSeek-V4-Flash-0731',
5
+ 'DeepSeek-V4.1-Flash-1017',
6
+ 'GLM-5.2',
7
+ 'GLM-5.3',
8
+ 'Qwen3.8-27B',
9
+ ];
10
+ const MODEL_ALIASES = {
11
+ 'deepseek-v4-flash-0731': 'DeepSeek-V4-Flash-0731',
12
+ 'deepseek-v4-flash': 'DeepSeek-V4-Flash-0731',
13
+ 'deepseekv4flash0731': 'DeepSeek-V4-Flash-0731',
14
+ 'deepseekv4flash': 'DeepSeek-V4-Flash-0731',
15
+ 'deepseek-v4.1-flash-1017': 'DeepSeek-V4.1-Flash-1017',
16
+ 'deepseek-v4.1-flash': 'DeepSeek-V4.1-Flash-1017',
17
+ 'deepseekv41flash1017': 'DeepSeek-V4.1-Flash-1017',
18
+ 'deepseekv41flash': 'DeepSeek-V4.1-Flash-1017',
19
+ 'glm-5.2': 'GLM-5.2',
20
+ 'glm5.2': 'GLM-5.2',
21
+ 'glm-5.3': 'GLM-5.3',
22
+ 'glm5.3': 'GLM-5.3',
23
+ 'qwen3.8-27b': 'Qwen3.8-27B',
24
+ 'qwen3.8': 'Qwen3.8-27B',
25
+ };
26
+ const SUFFIX = '-TokenPlan';
27
+ /**
28
+ * Resolve a client-supplied model name (case-insensitive, optional
29
+ * "-TokenPlan" suffix) to a canonical CodeFree model. Returns null for names
30
+ * that are not supported, so callers can answer 400 instead of silently
31
+ * switching the user's model.
32
+ */
33
+ export function resolveModel(model) {
34
+ if (typeof model !== 'string')
35
+ return null;
36
+ const trimmed = model.trim();
37
+ if (trimmed.length === 0)
38
+ return null;
39
+ const base = trimmed.endsWith(SUFFIX) ? trimmed.slice(0, -SUFFIX.length) : trimmed;
40
+ const direct = SUPPORTED_MODELS.find((candidate) => candidate.toLowerCase() === base.toLowerCase());
41
+ if (direct)
42
+ return direct;
43
+ return MODEL_ALIASES[base.toLowerCase()] ?? null;
44
+ }
45
+ /** Upstream expects the -TokenPlan variant of every model. */
46
+ export function toUpstreamModel(canonical) {
47
+ return canonical.endsWith(SUFFIX) ? canonical : `${canonical}${SUFFIX}`;
48
+ }
49
+ function unsupportedModelMessage(model) {
50
+ const shown = typeof model === 'string' && model.trim().length > 0 ? model : '(未提供)';
51
+ return `不支持的模型:${shown}。可用模型:${SUPPORTED_MODELS.join(', ')}`;
52
+ }
3
53
  export function mapModel(model) {
4
- return SUPPORTED_MODELS.includes(model) ? model : DEFAULT_MODEL;
54
+ const canonical = resolveModel(model) ?? DEFAULT_MODEL;
55
+ return toUpstreamModel(canonical);
56
+ }
57
+ export function isSupportedModel(model) {
58
+ return resolveModel(model) !== null;
5
59
  }
6
- //# sourceMappingURL=model-map.js.map
60
+ export { unsupportedModelMessage };