codexmate 0.0.12 → 0.0.14
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.en.md +429 -0
- package/README.md +241 -203
- package/cli.js +10210 -0
- package/doc/CHANGELOG.md +14 -1
- package/doc/CHANGELOG.zh-CN.md +13 -0
- package/lib/cli-utils.js +16 -0
- package/lib/mcp-stdio.js +440 -0
- package/lib/workflow-engine.js +340 -0
- package/package.json +63 -53
- package/web-ui/app.js +1417 -14
- package/web-ui/index.html +585 -67
- package/web-ui/logic.mjs +147 -1
- package/web-ui/styles.css +1049 -66
- package/README.zh-CN.md +0 -397
- package/src/cli.js +0 -5464
- package/src/lib/cli-file-utils.js +0 -151
- package/src/lib/cli-models-utils.js +0 -152
- package/src/lib/cli-network-utils.js +0 -148
- package/src/lib/cli-session-utils.js +0 -121
- package/src/lib/cli-utils.js +0 -139
- package/src/res/json5.min.js +0 -1
- package/src/res/logo.png +0 -0
- package/src/res/screenshot.png +0 -0
- package/src/res/vue.global.js +0 -18552
- package/src/web-ui/app.js +0 -2970
- package/src/web-ui/index.html +0 -1310
- package/src/web-ui/logic.mjs +0 -157
- package/src/web-ui/styles.css +0 -2868
- /package/{src/web-ui.html → web-ui.html} +0 -0
package/src/web-ui/logic.mjs
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
// 逻辑纯函数:供 Web UI 与单元测试共享
|
|
2
|
-
export function normalizeClaudeValue(value) {
|
|
3
|
-
return typeof value === 'string' ? value.trim() : '';
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export function normalizeClaudeConfig(config) {
|
|
7
|
-
const safe = config && typeof config === 'object' ? config : {};
|
|
8
|
-
return {
|
|
9
|
-
apiKey: normalizeClaudeValue(safe.apiKey),
|
|
10
|
-
baseUrl: normalizeClaudeValue(safe.baseUrl),
|
|
11
|
-
model: normalizeClaudeValue(safe.model)
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function normalizeClaudeSettingsEnv(env) {
|
|
16
|
-
const safe = env && typeof env === 'object' ? env : {};
|
|
17
|
-
return {
|
|
18
|
-
apiKey: normalizeClaudeValue(safe.ANTHROPIC_API_KEY),
|
|
19
|
-
baseUrl: normalizeClaudeValue(safe.ANTHROPIC_BASE_URL),
|
|
20
|
-
model: normalizeClaudeValue(safe.ANTHROPIC_MODEL)
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function matchClaudeConfigFromSettings(claudeConfigs = {}, env = {}) {
|
|
25
|
-
const normalizedSettings = normalizeClaudeSettingsEnv(env);
|
|
26
|
-
if (!normalizedSettings.apiKey || !normalizedSettings.baseUrl || !normalizedSettings.model) {
|
|
27
|
-
return '';
|
|
28
|
-
}
|
|
29
|
-
const entries = Object.entries(claudeConfigs || {});
|
|
30
|
-
for (const [name, config] of entries) {
|
|
31
|
-
const normalizedConfig = normalizeClaudeConfig(config);
|
|
32
|
-
if (!normalizedConfig.apiKey || !normalizedConfig.baseUrl || !normalizedConfig.model) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (normalizedConfig.apiKey === normalizedSettings.apiKey
|
|
36
|
-
&& normalizedConfig.baseUrl === normalizedSettings.baseUrl
|
|
37
|
-
&& normalizedConfig.model === normalizedSettings.model) {
|
|
38
|
-
return name;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return '';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function findDuplicateClaudeConfigName(claudeConfigs = {}, config) {
|
|
45
|
-
const normalized = normalizeClaudeConfig(config);
|
|
46
|
-
if (!normalized.apiKey || !normalized.baseUrl || !normalized.model) {
|
|
47
|
-
return '';
|
|
48
|
-
}
|
|
49
|
-
const entries = Object.entries(claudeConfigs || {});
|
|
50
|
-
for (const [name, existing] of entries) {
|
|
51
|
-
const normalizedExisting = normalizeClaudeConfig(existing);
|
|
52
|
-
if (!normalizedExisting.apiKey || !normalizedExisting.baseUrl || !normalizedExisting.model) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
if (normalizedExisting.apiKey === normalized.apiKey
|
|
56
|
-
&& normalizedExisting.baseUrl === normalized.baseUrl
|
|
57
|
-
&& normalizedExisting.model === normalized.model) {
|
|
58
|
-
return name;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return '';
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function formatLatency(result) {
|
|
65
|
-
if (!result) return '';
|
|
66
|
-
if (!result.ok) return result.status ? `ERR ${result.status}` : 'ERR';
|
|
67
|
-
const ms = typeof result.durationMs === 'number' ? result.durationMs : 0;
|
|
68
|
-
return `${ms}ms`;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function buildSpeedTestIssue(name, result) {
|
|
72
|
-
if (!name || !result) return null;
|
|
73
|
-
if (result.error) {
|
|
74
|
-
const error = String(result.error || '');
|
|
75
|
-
const errorLower = error.toLowerCase();
|
|
76
|
-
if (error === 'Provider not found') {
|
|
77
|
-
return {
|
|
78
|
-
code: 'remote-speedtest-provider-missing',
|
|
79
|
-
message: `提供商 ${name} 未找到,无法测速`,
|
|
80
|
-
suggestion: '检查配置是否存在该 provider'
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
if (error === 'Provider missing URL' || error === 'Missing name or url') {
|
|
84
|
-
return {
|
|
85
|
-
code: 'remote-speedtest-baseurl-missing',
|
|
86
|
-
message: `提供商 ${name} 缺少 base_url`,
|
|
87
|
-
suggestion: '补全 base_url 后重试'
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
if (errorLower.includes('invalid url')) {
|
|
91
|
-
return {
|
|
92
|
-
code: 'remote-speedtest-invalid-url',
|
|
93
|
-
message: `提供商 ${name} 的 base_url 无效`,
|
|
94
|
-
suggestion: '请设置为 http/https 的完整 URL'
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
if (errorLower.includes('timeout')) {
|
|
98
|
-
return {
|
|
99
|
-
code: 'remote-speedtest-timeout',
|
|
100
|
-
message: `提供商 ${name} 远程测速超时`,
|
|
101
|
-
suggestion: '检查网络或 base_url 是否可达'
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
code: 'remote-speedtest-unreachable',
|
|
106
|
-
message: `提供商 ${name} 远程测速失败:${error || '无法连接'}`,
|
|
107
|
-
suggestion: '检查网络或 base_url 是否可用'
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const status = typeof result.status === 'number' ? result.status : 0;
|
|
112
|
-
if (status === 401 || status === 403) {
|
|
113
|
-
return {
|
|
114
|
-
code: 'remote-speedtest-auth-failed',
|
|
115
|
-
message: `提供商 ${name} 远程测速鉴权失败(401/403)`,
|
|
116
|
-
suggestion: '检查 API Key 或认证方式'
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
if (status >= 400) {
|
|
120
|
-
return {
|
|
121
|
-
code: 'remote-speedtest-http-error',
|
|
122
|
-
message: `提供商 ${name} 远程测速返回异常状态: ${status}`,
|
|
123
|
-
suggestion: '检查 base_url 或服务状态'
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Session filtering helpers
|
|
130
|
-
export function isSessionQueryEnabled(source) {
|
|
131
|
-
const normalized = (source || '').toLowerCase();
|
|
132
|
-
return normalized === 'codex' || normalized === 'claude' || normalized === 'all';
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export function buildSessionListParams(options = {}) {
|
|
136
|
-
const {
|
|
137
|
-
source = 'all',
|
|
138
|
-
pathFilter = '',
|
|
139
|
-
query = '',
|
|
140
|
-
roleFilter = 'all',
|
|
141
|
-
timeRangePreset = 'all',
|
|
142
|
-
limit = 200
|
|
143
|
-
} = options;
|
|
144
|
-
const queryValue = isSessionQueryEnabled(source) ? query : '';
|
|
145
|
-
return {
|
|
146
|
-
source,
|
|
147
|
-
pathFilter,
|
|
148
|
-
query: queryValue,
|
|
149
|
-
queryMode: 'and',
|
|
150
|
-
queryScope: 'content',
|
|
151
|
-
contentScanLimit: 50,
|
|
152
|
-
roleFilter,
|
|
153
|
-
timeRangePreset,
|
|
154
|
-
limit,
|
|
155
|
-
forceRefresh: true
|
|
156
|
-
};
|
|
157
|
-
}
|