@dedenlabs/claude-code-router-cli 2.0.2 → 2.0.3
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/README.md +34 -11
- package/dist/cli.js +10027 -182
- package/examples/configs/fixed-router-config.json +3 -4
- package/examples/configs/unified-router-example.json +165 -171
- package/package.json +15 -3
|
@@ -130,14 +130,14 @@
|
|
|
130
130
|
"enabled": true
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
|
-
"name": "
|
|
133
|
+
"name": "代号映射规则",
|
|
134
134
|
"condition": {
|
|
135
135
|
"type": "custom",
|
|
136
136
|
"customFunction": "directModelMapping"
|
|
137
137
|
},
|
|
138
138
|
"action": {
|
|
139
139
|
"route": "${mappedModel}",
|
|
140
|
-
"description": "
|
|
140
|
+
"description": "代号映射:将provider作为代号,映射到对应的model模型"
|
|
141
141
|
},
|
|
142
142
|
"priority": 190,
|
|
143
143
|
"enabled": true
|
|
@@ -204,8 +204,7 @@
|
|
|
204
204
|
"condition": {
|
|
205
205
|
"type": "fieldExists",
|
|
206
206
|
"field": "thinking",
|
|
207
|
-
"
|
|
208
|
-
"operator": "eq"
|
|
207
|
+
"operator": "exists"
|
|
209
208
|
},
|
|
210
209
|
"action": {
|
|
211
210
|
"route": "opus",
|
|
@@ -1,171 +1,165 @@
|
|
|
1
|
-
{
|
|
2
|
-
"LOG": true,
|
|
3
|
-
"HOST": "127.0.0.1",
|
|
4
|
-
"PORT":
|
|
5
|
-
"APIKEY": "1",
|
|
6
|
-
"API_TIMEOUT_MS": 600000,
|
|
7
|
-
"Providers": [
|
|
8
|
-
{
|
|
9
|
-
"name": "openrouter",
|
|
10
|
-
"api_base_url": "https://openrouter.ai/api/v1/chat/completions",
|
|
11
|
-
"api_key": "sk-or-v1-",
|
|
12
|
-
"models": [
|
|
13
|
-
"anthropic/claude-3.5-sonnet",
|
|
14
|
-
"anthropic/claude-3.7-sonnet:thinking",
|
|
15
|
-
"deepseek/deepseek-chat-v3-0324",
|
|
16
|
-
"@preset/kimi"
|
|
17
|
-
],
|
|
18
|
-
"transformer": {
|
|
19
|
-
"use": ["openrouter"],
|
|
20
|
-
"deepseek/deepseek-chat-v3-0324": {
|
|
21
|
-
"use": ["tooluse"]
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"name": "deepseek",
|
|
27
|
-
"api_base_url": "https://api.deepseek.com/chat/completions",
|
|
28
|
-
"api_key": "sk-",
|
|
29
|
-
"models": [
|
|
30
|
-
|
|
31
|
-
"deepseek
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
"
|
|
117
|
-
|
|
118
|
-
"
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
"
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
"
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"
|
|
158
|
-
},
|
|
159
|
-
"
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
"default": 1000,
|
|
167
|
-
"longContext": 60000
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
"NON_INTERACTIVE_MODE": false
|
|
171
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"LOG": true,
|
|
3
|
+
"HOST": "127.0.0.1",
|
|
4
|
+
"PORT": 3456,
|
|
5
|
+
"APIKEY": "1",
|
|
6
|
+
"API_TIMEOUT_MS": 600000,
|
|
7
|
+
"Providers": [
|
|
8
|
+
{
|
|
9
|
+
"name": "openrouter",
|
|
10
|
+
"api_base_url": "https://openrouter.ai/api/v1/chat/completions",
|
|
11
|
+
"api_key": "sk-or-v1-",
|
|
12
|
+
"models": [
|
|
13
|
+
"anthropic/claude-3.5-sonnet",
|
|
14
|
+
"anthropic/claude-3.7-sonnet:thinking",
|
|
15
|
+
"deepseek/deepseek-chat-v3-0324",
|
|
16
|
+
"@preset/kimi"
|
|
17
|
+
],
|
|
18
|
+
"transformer": {
|
|
19
|
+
"use": ["openrouter"],
|
|
20
|
+
"deepseek/deepseek-chat-v3-0324": {
|
|
21
|
+
"use": ["tooluse"]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "deepseek",
|
|
27
|
+
"api_base_url": "https://api.deepseek.com/chat/completions",
|
|
28
|
+
"api_key": "sk-",
|
|
29
|
+
"models": ["deepseek-chat", "deepseek-reasoner"],
|
|
30
|
+
"transformer": {
|
|
31
|
+
"use": ["deepseek"],
|
|
32
|
+
"deepseek-chat": {
|
|
33
|
+
"use": ["tooluse"]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "gemini",
|
|
39
|
+
"api_base_url": "https://generativelanguage.googleapis.com/v1beta/models/",
|
|
40
|
+
"api_key": "",
|
|
41
|
+
"models": ["gemini-2.5-flash", "gemini-2.5-pro"],
|
|
42
|
+
"transformer": {
|
|
43
|
+
"use": ["gemini"]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"Router": {
|
|
48
|
+
"engine": "unified",
|
|
49
|
+
"defaultRoute": "openrouter,anthropic/claude-3.5-sonnet",
|
|
50
|
+
"rules": [
|
|
51
|
+
{
|
|
52
|
+
"name": "longContext",
|
|
53
|
+
"priority": 100,
|
|
54
|
+
"enabled": true,
|
|
55
|
+
"condition": {
|
|
56
|
+
"type": "tokenThreshold",
|
|
57
|
+
"value": 60000,
|
|
58
|
+
"operator": "gt"
|
|
59
|
+
},
|
|
60
|
+
"action": {
|
|
61
|
+
"route": "gemini,gemini-2.5-pro",
|
|
62
|
+
"transformers": []
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "subagent",
|
|
67
|
+
"priority": 90,
|
|
68
|
+
"enabled": true,
|
|
69
|
+
"condition": {
|
|
70
|
+
"type": "fieldExists",
|
|
71
|
+
"field": "system.1.text",
|
|
72
|
+
"operator": "exists"
|
|
73
|
+
},
|
|
74
|
+
"action": {
|
|
75
|
+
"route": "${subagent}",
|
|
76
|
+
"transformers": []
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "background",
|
|
81
|
+
"priority": 80,
|
|
82
|
+
"enabled": true,
|
|
83
|
+
"condition": {
|
|
84
|
+
"type": "modelContains",
|
|
85
|
+
"value": "haiku",
|
|
86
|
+
"operator": "contains"
|
|
87
|
+
},
|
|
88
|
+
"action": {
|
|
89
|
+
"route": "openrouter,@preset/kimi",
|
|
90
|
+
"transformers": []
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "webSearch",
|
|
95
|
+
"priority": 70,
|
|
96
|
+
"enabled": true,
|
|
97
|
+
"condition": {
|
|
98
|
+
"type": "toolExists",
|
|
99
|
+
"value": "web_search",
|
|
100
|
+
"operator": "exists"
|
|
101
|
+
},
|
|
102
|
+
"action": {
|
|
103
|
+
"route": "gemini,gemini-2.5-flash",
|
|
104
|
+
"transformers": []
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "thinking",
|
|
109
|
+
"priority": 60,
|
|
110
|
+
"enabled": true,
|
|
111
|
+
"condition": {
|
|
112
|
+
"type": "fieldExists",
|
|
113
|
+
"field": "thinking",
|
|
114
|
+
"operator": "exists"
|
|
115
|
+
},
|
|
116
|
+
"action": {
|
|
117
|
+
"route": "deepseek,deepseek-reasoner",
|
|
118
|
+
"transformers": []
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "directMapping",
|
|
123
|
+
"priority": 50,
|
|
124
|
+
"enabled": true,
|
|
125
|
+
"condition": {
|
|
126
|
+
"type": "custom",
|
|
127
|
+
"customFunction": "directModelMapping"
|
|
128
|
+
},
|
|
129
|
+
"action": {
|
|
130
|
+
"route": "${mappedModel}",
|
|
131
|
+
"transformers": []
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "userSpecified",
|
|
136
|
+
"priority": 40,
|
|
137
|
+
"enabled": true,
|
|
138
|
+
"condition": {
|
|
139
|
+
"type": "custom",
|
|
140
|
+
"customFunction": "modelContainsComma"
|
|
141
|
+
},
|
|
142
|
+
"action": {
|
|
143
|
+
"route": "${userModel}",
|
|
144
|
+
"transformers": []
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"cache": {
|
|
149
|
+
"enabled": true,
|
|
150
|
+
"maxSize": 1000,
|
|
151
|
+
"ttl": 300000
|
|
152
|
+
},
|
|
153
|
+
"debug": {
|
|
154
|
+
"enabled": false,
|
|
155
|
+
"logLevel": "info",
|
|
156
|
+
"logToFile": true,
|
|
157
|
+
"logToConsole": true
|
|
158
|
+
},
|
|
159
|
+
"contextThreshold": {
|
|
160
|
+
"default": 1000,
|
|
161
|
+
"longContext": 60000
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
"NON_INTERACTIVE_MODE": false
|
|
165
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedenlabs/claude-code-router-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "基于@musistudio/claude-code-router的增强版CLI路由工具 - 支持统一路由引擎、外部规则加载、智能日志系统、自动配置迁移和GLM思考模式",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ccr": "dist/cli.js"
|
|
@@ -8,7 +8,14 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "node scripts/build.js",
|
|
10
10
|
"release": "npm run build && npm publish",
|
|
11
|
-
"prepublishOnly": "node scripts/prepublish-check.js"
|
|
11
|
+
"prepublishOnly": "node scripts/prepublish-check.js",
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test:watch": "vitest",
|
|
14
|
+
"test:coverage": "vitest run --coverage",
|
|
15
|
+
"test:ui": "vitest --ui",
|
|
16
|
+
"test:integration": "vitest run --config ./vitest.config.ts tests/integration",
|
|
17
|
+
"test:unit": "vitest run --config ./vitest.config.ts tests/unit",
|
|
18
|
+
"test:ui:unit": "vitest run --config ./vitest.config.ts tests/ui"
|
|
12
19
|
},
|
|
13
20
|
"keywords": [
|
|
14
21
|
"claude",
|
|
@@ -45,11 +52,16 @@
|
|
|
45
52
|
"uuid": "^11.1.0"
|
|
46
53
|
},
|
|
47
54
|
"devDependencies": {
|
|
55
|
+
"@testing-library/react": "^14.3.1",
|
|
48
56
|
"@types/node": "^24.0.15",
|
|
57
|
+
"@vitest/coverage-v8": "^2.1.9",
|
|
58
|
+
"@vitest/ui": "^2.1.9",
|
|
49
59
|
"esbuild": "^0.25.1",
|
|
50
60
|
"fastify": "^5.4.0",
|
|
61
|
+
"jsdom": "^25.0.1",
|
|
51
62
|
"shx": "^0.4.0",
|
|
52
|
-
"typescript": "^5.8.2"
|
|
63
|
+
"typescript": "^5.8.2",
|
|
64
|
+
"vitest": "^2.1.9"
|
|
53
65
|
},
|
|
54
66
|
"files": [
|
|
55
67
|
"dist/",
|