codexmate 0.0.18 → 0.0.20

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 (73) hide show
  1. package/README.en.md +34 -17
  2. package/README.md +34 -25
  3. package/cli/config-health.js +338 -0
  4. package/cli.js +1570 -839
  5. package/lib/cli-models-utils.js +186 -27
  6. package/lib/cli-network-utils.js +117 -101
  7. package/package.json +8 -1
  8. package/web-ui/app.js +379 -5754
  9. package/web-ui/index.html +15 -2079
  10. package/web-ui/logic.agents-diff.mjs +386 -0
  11. package/web-ui/logic.claude.mjs +108 -0
  12. package/web-ui/logic.mjs +5 -793
  13. package/web-ui/logic.runtime.mjs +124 -0
  14. package/web-ui/logic.sessions.mjs +263 -0
  15. package/web-ui/modules/api.mjs +69 -0
  16. package/web-ui/modules/app.computed.dashboard.mjs +113 -0
  17. package/web-ui/modules/app.computed.index.mjs +13 -0
  18. package/web-ui/modules/app.computed.session.mjs +141 -0
  19. package/web-ui/modules/app.constants.mjs +15 -0
  20. package/web-ui/modules/app.methods.agents.mjs +493 -0
  21. package/web-ui/modules/app.methods.claude-config.mjs +174 -0
  22. package/web-ui/modules/app.methods.codex-config.mjs +640 -0
  23. package/web-ui/modules/app.methods.index.mjs +86 -0
  24. package/web-ui/modules/app.methods.install.mjs +157 -0
  25. package/web-ui/modules/app.methods.navigation.mjs +478 -0
  26. package/web-ui/modules/app.methods.openclaw-core.mjs +514 -0
  27. package/web-ui/modules/app.methods.openclaw-editing.mjs +337 -0
  28. package/web-ui/modules/app.methods.openclaw-persist.mjs +251 -0
  29. package/web-ui/modules/app.methods.providers.mjs +265 -0
  30. package/web-ui/modules/app.methods.runtime.mjs +323 -0
  31. package/web-ui/modules/app.methods.session-actions.mjs +457 -0
  32. package/web-ui/modules/app.methods.session-browser.mjs +435 -0
  33. package/web-ui/modules/app.methods.session-timeline.mjs +441 -0
  34. package/web-ui/modules/app.methods.session-trash.mjs +419 -0
  35. package/web-ui/modules/app.methods.startup-claude.mjs +406 -0
  36. package/web-ui/modules/config-mode.computed.mjs +1 -0
  37. package/web-ui/modules/skills.computed.mjs +26 -1
  38. package/web-ui/modules/skills.methods.mjs +154 -23
  39. package/web-ui/partials/index/layout-footer.html +69 -0
  40. package/web-ui/partials/index/layout-header.html +337 -0
  41. package/web-ui/partials/index/modal-config-template-agents.html +125 -0
  42. package/web-ui/partials/index/modal-confirm-toast.html +32 -0
  43. package/web-ui/partials/index/modal-health-check.html +72 -0
  44. package/web-ui/partials/index/modal-openclaw-config.html +275 -0
  45. package/web-ui/partials/index/modal-skills.html +184 -0
  46. package/web-ui/partials/index/modals-basic.html +196 -0
  47. package/web-ui/partials/index/panel-config-claude.html +100 -0
  48. package/web-ui/partials/index/panel-config-codex.html +237 -0
  49. package/web-ui/partials/index/panel-config-openclaw.html +84 -0
  50. package/web-ui/partials/index/panel-market.html +174 -0
  51. package/web-ui/partials/index/panel-sessions.html +387 -0
  52. package/web-ui/partials/index/panel-settings.html +166 -0
  53. package/web-ui/session-helpers.mjs +12 -0
  54. package/web-ui/source-bundle.cjs +233 -0
  55. package/web-ui/styles/base-theme.css +373 -0
  56. package/web-ui/styles/controls-forms.css +354 -0
  57. package/web-ui/styles/feedback.css +108 -0
  58. package/web-ui/styles/health-check-dialog.css +144 -0
  59. package/web-ui/styles/layout-shell.css +330 -0
  60. package/web-ui/styles/modals-core.css +449 -0
  61. package/web-ui/styles/navigation-panels.css +381 -0
  62. package/web-ui/styles/openclaw-structured.css +266 -0
  63. package/web-ui/styles/responsive.css +416 -0
  64. package/web-ui/styles/sessions-list.css +414 -0
  65. package/web-ui/styles/sessions-preview.css +405 -0
  66. package/web-ui/styles/sessions-toolbar-trash.css +243 -0
  67. package/web-ui/styles/sessions-usage.css +276 -0
  68. package/web-ui/styles/skills-list.css +298 -0
  69. package/web-ui/styles/skills-market.css +335 -0
  70. package/web-ui/styles/titles-cards.css +407 -0
  71. package/web-ui/styles.css +16 -4499
  72. package/doc/CHANGELOG.md +0 -32
  73. package/doc/CHANGELOG.zh-CN.md +0 -34
@@ -0,0 +1,406 @@
1
+ import {
2
+ findDuplicateClaudeConfigName,
3
+ matchClaudeConfigFromSettings,
4
+ normalizeClaudeConfig,
5
+ normalizeClaudeSettingsEnv,
6
+ normalizeClaudeValue
7
+ } from '../logic.mjs';
8
+
9
+ export function createStartupClaudeMethods(options = {}) {
10
+ const {
11
+ api,
12
+ defaultModelContextWindow = 190000,
13
+ defaultModelAutoCompactTokenLimit = 185000
14
+ } = options;
15
+
16
+ return {
17
+ async loadAll(options = {}) {
18
+ const preserveLoading = !!options.preserveLoading;
19
+ let startupOk = false;
20
+ if (!preserveLoading) {
21
+ this.loading = true;
22
+ }
23
+ this.initError = '';
24
+ try {
25
+ const [statusRes, listRes] = await Promise.all([api('status'), api('list')]);
26
+
27
+ if (statusRes.error || (listRes && listRes.error)) {
28
+ this.initError = statusRes.error || listRes.error;
29
+ } else {
30
+ startupOk = true;
31
+ this.currentProvider = statusRes.provider;
32
+ this.currentModel = statusRes.model;
33
+ {
34
+ const tier = typeof statusRes.serviceTier === 'string'
35
+ ? statusRes.serviceTier.trim().toLowerCase()
36
+ : '';
37
+ this.serviceTier = tier === 'fast' ? 'fast' : (tier ? 'standard' : 'fast');
38
+ }
39
+ {
40
+ const effort = typeof statusRes.modelReasoningEffort === 'string'
41
+ ? statusRes.modelReasoningEffort.trim().toLowerCase()
42
+ : '';
43
+ const allowedReasoningEfforts = new Set(['low', 'medium', 'high', 'xhigh']);
44
+ this.modelReasoningEffort = allowedReasoningEfforts.has(effort) ? effort : 'medium';
45
+ }
46
+ {
47
+ const contextWindow = this.normalizePositiveIntegerInput(
48
+ statusRes.modelContextWindow,
49
+ 'model_context_window',
50
+ defaultModelContextWindow
51
+ );
52
+ if (this.editingCodexBudgetField !== 'modelContextWindowInput') {
53
+ this.modelContextWindowInput = contextWindow.ok && contextWindow.text
54
+ ? contextWindow.text
55
+ : String(defaultModelContextWindow);
56
+ }
57
+ }
58
+ {
59
+ const autoCompactTokenLimit = this.normalizePositiveIntegerInput(
60
+ statusRes.modelAutoCompactTokenLimit,
61
+ 'model_auto_compact_token_limit',
62
+ defaultModelAutoCompactTokenLimit
63
+ );
64
+ if (this.editingCodexBudgetField !== 'modelAutoCompactTokenLimitInput') {
65
+ this.modelAutoCompactTokenLimitInput = autoCompactTokenLimit.ok && autoCompactTokenLimit.text
66
+ ? autoCompactTokenLimit.text
67
+ : String(defaultModelAutoCompactTokenLimit);
68
+ }
69
+ }
70
+ this.providersList = listRes.providers;
71
+ if (statusRes.configReady === false) {
72
+ this.showMessage('配置已加载', 'info');
73
+ }
74
+ if (statusRes.initNotice) {
75
+ this.showMessage('配置就绪', 'info');
76
+ }
77
+ this.maybeShowStarPrompt();
78
+ }
79
+ } catch (e) {
80
+ this.initError = '连接失败: ' + e.message;
81
+ } finally {
82
+ if (!preserveLoading) {
83
+ this.loading = false;
84
+ }
85
+ }
86
+
87
+ if (startupOk) {
88
+ try {
89
+ await this.loadModelsForProvider(this.currentProvider);
90
+ } catch (_) {}
91
+ }
92
+
93
+ try {
94
+ await this.loadCodexAuthProfiles();
95
+ } catch (_) {}
96
+ },
97
+
98
+ async loadModelsForProvider(providerName, options = {}) {
99
+ const silentError = !!options.silentError;
100
+ const targetProvider = typeof providerName === 'string' ? providerName.trim() : '';
101
+ const requestSeq = (Number(this.codexModelsRequestSeq) || 0) + 1;
102
+ this.codexModelsRequestSeq = requestSeq;
103
+ this.codexModelsLoading = true;
104
+ if (!targetProvider) {
105
+ this.models = [];
106
+ this.modelsSource = 'unlimited';
107
+ this.modelsHasCurrent = true;
108
+ this.codexModelsLoading = false;
109
+ return;
110
+ }
111
+ const isLatestRequest = () => {
112
+ const currentProvider = typeof this.currentProvider === 'string' ? this.currentProvider.trim() : '';
113
+ return requestSeq === Number(this.codexModelsRequestSeq || 0)
114
+ && (!currentProvider || currentProvider === targetProvider);
115
+ };
116
+ try {
117
+ const res = await api('models', { provider: targetProvider });
118
+ if (!isLatestRequest()) {
119
+ return;
120
+ }
121
+ if (res.unlimited) {
122
+ this.models = [];
123
+ this.modelsSource = 'unlimited';
124
+ this.modelsHasCurrent = true;
125
+ return;
126
+ }
127
+ if (res.error) {
128
+ if (!silentError) {
129
+ this.showMessage('获取模型列表失败', 'error');
130
+ }
131
+ this.models = [];
132
+ this.modelsSource = 'error';
133
+ this.modelsHasCurrent = true;
134
+ return;
135
+ }
136
+ const list = Array.isArray(res.models) ? res.models : [];
137
+ this.models = list;
138
+ this.modelsSource = res.source || 'remote';
139
+ this.modelsHasCurrent = !!this.currentModel && list.includes(this.currentModel);
140
+ } catch (_) {
141
+ if (!isLatestRequest()) {
142
+ return;
143
+ }
144
+ if (!silentError) {
145
+ this.showMessage('获取模型列表失败', 'error');
146
+ }
147
+ this.models = [];
148
+ this.modelsSource = 'error';
149
+ this.modelsHasCurrent = true;
150
+ } finally {
151
+ if (requestSeq === Number(this.codexModelsRequestSeq || 0)) {
152
+ this.codexModelsLoading = false;
153
+ }
154
+ }
155
+ },
156
+
157
+ getCurrentClaudeConfig() {
158
+ if (!this.currentClaudeConfig) return null;
159
+ return this.claudeConfigs[this.currentClaudeConfig] || null;
160
+ },
161
+
162
+ normalizeClaudeValue,
163
+
164
+ normalizeClaudeConfig(config) {
165
+ return normalizeClaudeConfig(config);
166
+ },
167
+
168
+ normalizeClaudeSettingsEnv(env) {
169
+ return normalizeClaudeSettingsEnv(env);
170
+ },
171
+
172
+ matchClaudeConfigFromSettings(env) {
173
+ return matchClaudeConfigFromSettings(this.claudeConfigs, env);
174
+ },
175
+
176
+ findDuplicateClaudeConfigName(config) {
177
+ return findDuplicateClaudeConfigName(this.claudeConfigs, config);
178
+ },
179
+
180
+ mergeClaudeConfig(existing = {}, updates = {}) {
181
+ const previous = this.normalizeClaudeConfig(existing);
182
+ const next = this.normalizeClaudeConfig({ ...existing, ...updates });
183
+ const externalCredentialType = next.apiKey
184
+ ? ''
185
+ : (next.externalCredentialType || previous.externalCredentialType || '');
186
+ return {
187
+ apiKey: next.apiKey,
188
+ baseUrl: next.baseUrl,
189
+ model: next.model || previous.model || 'glm-4.7',
190
+ hasKey: !!(next.apiKey || externalCredentialType),
191
+ externalCredentialType
192
+ };
193
+ },
194
+
195
+ buildClaudeImportedConfigName(baseUrl) {
196
+ const normalizedUrl = typeof baseUrl === 'string' ? baseUrl.trim() : '';
197
+ if (!normalizedUrl) return '导入配置';
198
+ try {
199
+ const parsed = new URL(normalizedUrl);
200
+ const host = typeof parsed.host === 'string' ? parsed.host.trim() : '';
201
+ if (host) return `导入-${host}`;
202
+ } catch (_) {}
203
+ return '导入配置';
204
+ },
205
+
206
+ ensureClaudeConfigFromSettings(env = {}) {
207
+ const normalized = this.normalizeClaudeSettingsEnv(env);
208
+ const hasCredential = !!(normalized.apiKey || normalized.authToken || normalized.useKey);
209
+ if (!normalized.baseUrl || !hasCredential) return '';
210
+
211
+ const duplicateName = this.findDuplicateClaudeConfigName(normalized);
212
+ if (duplicateName) return duplicateName;
213
+
214
+ const preferredName = this.buildClaudeImportedConfigName(normalized.baseUrl);
215
+ let candidateName = preferredName;
216
+ let suffix = 2;
217
+ const maxAttempts = 1000;
218
+ while (this.claudeConfigs[candidateName] && suffix <= maxAttempts) {
219
+ candidateName = `${preferredName}-${suffix}`;
220
+ suffix += 1;
221
+ }
222
+ if (this.claudeConfigs[candidateName]) {
223
+ return '';
224
+ }
225
+
226
+ this.claudeConfigs[candidateName] = this.mergeClaudeConfig({}, normalized);
227
+ this.saveClaudeConfigs();
228
+ return candidateName;
229
+ },
230
+
231
+ async refreshClaudeSelectionFromSettings(options = {}) {
232
+ const silent = !!options.silent;
233
+ const silentModelError = !!options.silentModelError || silent;
234
+ try {
235
+ const res = await api('get-claude-settings');
236
+ if (res && res.error) {
237
+ if (!silent) {
238
+ this.showMessage('读取配置失败', 'error');
239
+ }
240
+ return;
241
+ }
242
+ const matchName = this.matchClaudeConfigFromSettings((res && res.env) || {});
243
+ if (matchName) {
244
+ if (this.currentClaudeConfig !== matchName) {
245
+ this.currentClaudeConfig = matchName;
246
+ }
247
+ this.refreshClaudeModelContext({ silentError: silentModelError });
248
+ return;
249
+ }
250
+ const importedName = this.ensureClaudeConfigFromSettings((res && res.env) || {});
251
+ if (importedName) {
252
+ if (this.currentClaudeConfig !== importedName) {
253
+ this.currentClaudeConfig = importedName;
254
+ }
255
+ this.refreshClaudeModelContext({ silentError: silentModelError });
256
+ if (!silent) {
257
+ this.showMessage(`检测到外部 Claude 配置,已自动导入:${importedName}`, 'success');
258
+ }
259
+ return;
260
+ }
261
+ this.currentClaudeConfig = '';
262
+ this.currentClaudeModel = '';
263
+ this.resetClaudeModelsState();
264
+ if (!silent) {
265
+ const tip = res && res.exists
266
+ ? '当前 Claude settings.json 与本地配置不匹配,已取消选中'
267
+ : '未检测到 Claude settings.json,已取消选中';
268
+ this.showMessage(tip, 'info');
269
+ }
270
+ } catch (_) {
271
+ if (!silent) {
272
+ this.showMessage('读取配置失败', 'error');
273
+ }
274
+ }
275
+ },
276
+
277
+ syncClaudeModelFromConfig() {
278
+ const config = this.getCurrentClaudeConfig();
279
+ this.currentClaudeModel = config && config.model ? config.model : '';
280
+ },
281
+
282
+ refreshClaudeModelContext(options = {}) {
283
+ this.syncClaudeModelFromConfig();
284
+ return this.loadClaudeModels(options);
285
+ },
286
+
287
+ resetClaudeModelsState() {
288
+ this.claudeModels = [];
289
+ this.claudeModelsSource = 'idle';
290
+ this.claudeModelsHasCurrent = true;
291
+ this.claudeModelsLoading = false;
292
+ },
293
+
294
+ updateClaudeModelsCurrent() {
295
+ const currentModel = (this.currentClaudeModel || '').trim();
296
+ this.claudeModelsHasCurrent = !!currentModel && this.claudeModels.includes(currentModel);
297
+ },
298
+
299
+ async loadClaudeModels(options = {}) {
300
+ const silentError = !!options.silentError;
301
+ const config = this.getCurrentClaudeConfig();
302
+ const requestSeq = (Number(this.claudeModelsRequestSeq) || 0) + 1;
303
+ this.claudeModelsRequestSeq = requestSeq;
304
+ if (!config) {
305
+ this.resetClaudeModelsState();
306
+ return;
307
+ }
308
+ const currentConfigName = typeof this.currentClaudeConfig === 'string' ? this.currentClaudeConfig.trim() : '';
309
+ const baseUrl = (config.baseUrl || '').trim();
310
+ const apiKey = (config.apiKey || '').trim();
311
+ const externalCredentialType = typeof config.externalCredentialType === 'string'
312
+ ? config.externalCredentialType.trim()
313
+ : '';
314
+
315
+ if (!baseUrl) {
316
+ this.resetClaudeModelsState();
317
+ return;
318
+ }
319
+ if (!apiKey && externalCredentialType) {
320
+ this.claudeModels = [];
321
+ this.claudeModelsSource = 'unlimited';
322
+ this.claudeModelsHasCurrent = true;
323
+ this.claudeModelsLoading = false;
324
+ return;
325
+ }
326
+
327
+ this.claudeModelsLoading = true;
328
+ const isLatestRequest = () => {
329
+ if (requestSeq !== Number(this.claudeModelsRequestSeq || 0)) {
330
+ return false;
331
+ }
332
+ const liveConfigName = typeof this.currentClaudeConfig === 'string' ? this.currentClaudeConfig.trim() : '';
333
+ if (currentConfigName && liveConfigName && liveConfigName !== currentConfigName) {
334
+ return false;
335
+ }
336
+ const latestConfig = this.getCurrentClaudeConfig();
337
+ if (!latestConfig) {
338
+ return false;
339
+ }
340
+ return (latestConfig.baseUrl || '').trim() === baseUrl
341
+ && (latestConfig.apiKey || '').trim() === apiKey
342
+ && (typeof latestConfig.externalCredentialType === 'string' ? latestConfig.externalCredentialType.trim() : '') === externalCredentialType;
343
+ };
344
+ try {
345
+ const res = await api('models-by-url', { baseUrl, apiKey });
346
+ if (!isLatestRequest()) {
347
+ return;
348
+ }
349
+ if (res.unlimited) {
350
+ this.claudeModels = [];
351
+ this.claudeModelsSource = 'unlimited';
352
+ this.claudeModelsHasCurrent = true;
353
+ return;
354
+ }
355
+ if (res.error) {
356
+ if (!silentError) {
357
+ this.showMessage('获取模型列表失败', 'error');
358
+ }
359
+ this.claudeModels = [];
360
+ this.claudeModelsSource = 'error';
361
+ this.claudeModelsHasCurrent = true;
362
+ return;
363
+ }
364
+ const list = Array.isArray(res.models) ? res.models : [];
365
+ this.claudeModels = list;
366
+ this.claudeModelsSource = res.source || 'remote';
367
+ this.updateClaudeModelsCurrent();
368
+ } catch (_) {
369
+ if (!isLatestRequest()) {
370
+ return;
371
+ }
372
+ if (!silentError) {
373
+ this.showMessage('获取模型列表失败', 'error');
374
+ }
375
+ this.claudeModels = [];
376
+ this.claudeModelsSource = 'error';
377
+ this.claudeModelsHasCurrent = true;
378
+ } finally {
379
+ if (requestSeq === Number(this.claudeModelsRequestSeq || 0)) {
380
+ this.claudeModelsLoading = false;
381
+ }
382
+ }
383
+ },
384
+
385
+ openClaudeConfigModal() {
386
+ this.showClaudeConfigModal = true;
387
+ },
388
+
389
+ maybeShowStarPrompt() {
390
+ const storageKey = 'codexmateStarPrompted';
391
+ let shown = false;
392
+ try {
393
+ if (localStorage.getItem(storageKey)) {
394
+ return;
395
+ }
396
+ this.showMessage('欢迎到 GitHub 点 Star', 'info');
397
+ shown = true;
398
+ localStorage.setItem(storageKey, '1');
399
+ } catch (_) {
400
+ if (!shown) {
401
+ this.showMessage('欢迎到 GitHub 点 Star', 'info');
402
+ }
403
+ }
404
+ }
405
+ };
406
+ }
@@ -49,6 +49,7 @@ export function createConfigModeComputed() {
49
49
  inspectorMainTabLabel() {
50
50
  if (this.mainTab === 'config') return '配置中心';
51
51
  if (this.mainTab === 'sessions') return '会话浏览';
52
+ if (this.mainTab === 'market') return '技能市场';
52
53
  if (this.mainTab === 'settings') return '设置';
53
54
  return '未知';
54
55
  },
@@ -1,5 +1,11 @@
1
1
  export function createSkillsComputed() {
2
2
  return {
3
+ skillsTargetLabel() {
4
+ return this.skillsTargetApp === 'claude' ? 'Claude Code' : 'Codex';
5
+ },
6
+ skillsDefaultRootPath() {
7
+ return this.skillsTargetApp === 'claude' ? '~/.claude/skills' : '~/.codex/skills';
8
+ },
3
9
  filteredSkillsList() {
4
10
  const list = Array.isArray(this.skillsList) ? this.skillsList : [];
5
11
  const keyword = typeof this.skillsKeyword === 'string' ? this.skillsKeyword.trim().toLowerCase() : '';
@@ -77,6 +83,25 @@
77
83
  skillsImportMissingSkillFileCount() {
78
84
  const list = Array.isArray(this.skillsImportList) ? this.skillsImportList : [];
79
85
  return list.filter((item) => !(item && item.hasSkillFile)).length;
86
+ },
87
+ skillsMarketBusy() {
88
+ return !!(
89
+ this.skillsMarketLoading
90
+ || this.skillsLoading
91
+ || this.skillsDeleting
92
+ || this.skillsScanningImports
93
+ || this.skillsImporting
94
+ || this.skillsZipImporting
95
+ || this.skillsExporting
96
+ );
97
+ },
98
+ skillsMarketInstalledPreview() {
99
+ const list = Array.isArray(this.skillsList) ? this.skillsList : [];
100
+ return list.slice(0, 6);
101
+ },
102
+ skillsMarketImportPreview() {
103
+ const list = Array.isArray(this.skillsImportList) ? this.skillsImportList : [];
104
+ return list.slice(0, 6);
80
105
  }
81
106
  };
82
- }
107
+ }