codexmate 0.0.9 → 0.0.12

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.
Files changed (63) hide show
  1. package/README.md +25 -6
  2. package/README.zh-CN.md +25 -6
  3. package/package.json +53 -36
  4. package/res/logo.png +0 -0
  5. package/{cli.js → src/cli.js} +822 -327
  6. package/src/lib/cli-file-utils.js +151 -0
  7. package/src/lib/cli-models-utils.js +152 -0
  8. package/src/lib/cli-network-utils.js +148 -0
  9. package/src/lib/cli-session-utils.js +121 -0
  10. package/src/lib/cli-utils.js +139 -0
  11. package/src/res/json5.min.js +1 -0
  12. package/src/res/logo.png +0 -0
  13. package/src/res/screenshot.png +0 -0
  14. package/src/res/vue.global.js +18552 -0
  15. package/src/web-ui/app.js +2970 -0
  16. package/src/web-ui/index.html +1310 -0
  17. package/src/web-ui/logic.mjs +157 -0
  18. package/src/web-ui/styles.css +2868 -0
  19. package/src/web-ui.html +17 -0
  20. package/web-ui/app.js +273 -144
  21. package/web-ui/index.html +1310 -0
  22. package/web-ui/logic.mjs +21 -21
  23. package/web-ui/styles.css +2868 -0
  24. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -27
  25. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
  26. package/.github/workflows/ci.yml +0 -26
  27. package/.github/workflows/release.yml +0 -159
  28. package/.planning/.fix-attempts +0 -1
  29. package/.planning/.lock +0 -6
  30. package/.planning/.verify-cache.json +0 -14
  31. package/.planning/CHECKPOINT.json +0 -46
  32. package/.planning/DESIGN.md +0 -26
  33. package/.planning/HISTORY.json +0 -124
  34. package/.planning/PLAN.md +0 -69
  35. package/.planning/REVIEW.md +0 -41
  36. package/.planning/STATE.md +0 -12
  37. package/.planning/STATS.json +0 -13
  38. package/.planning/VERIFICATION.md +0 -70
  39. package/.planning/daude-code-plan.md +0 -51
  40. package/.planning/research/architecture.md +0 -32
  41. package/.planning/research/conventions.md +0 -36
  42. package/.planning/task_1-REVIEW.md +0 -29
  43. package/.planning/task_1-SUMMARY.md +0 -32
  44. package/.planning/task_2-REVIEW.md +0 -24
  45. package/.planning/task_2-SUMMARY.md +0 -37
  46. package/.planning/task_3-REVIEW.md +0 -25
  47. package/.planning/task_3-SUMMARY.md +0 -31
  48. package/cmd/publish-npm.cmd +0 -65
  49. package/tests/e2e/helpers.js +0 -214
  50. package/tests/e2e/recent-health.e2e.js +0 -142
  51. package/tests/e2e/run.js +0 -154
  52. package/tests/e2e/test-claude.js +0 -21
  53. package/tests/e2e/test-config.js +0 -124
  54. package/tests/e2e/test-health-speed.js +0 -79
  55. package/tests/e2e/test-openclaw.js +0 -47
  56. package/tests/e2e/test-session-search.js +0 -114
  57. package/tests/e2e/test-sessions.js +0 -69
  58. package/tests/e2e/test-setup.js +0 -159
  59. package/tests/unit/run.mjs +0 -29
  60. package/tests/unit/web-ui-logic.test.mjs +0 -186
  61. package/web-ui.html +0 -3977
  62. /package/{CHANGELOG.md → doc/CHANGELOG.md} +0 -0
  63. /package/{CHANGELOG.zh-CN.md → doc/CHANGELOG.zh-CN.md} +0 -0
@@ -0,0 +1,157 @@
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
+ }