codexmate 0.0.19 → 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 (67) hide show
  1. package/README.en.md +8 -4
  2. package/README.md +8 -4
  3. package/cli/config-health.js +338 -0
  4. package/cli.js +1136 -584
  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 +381 -5532
  9. package/web-ui/index.html +15 -2231
  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/partials/index/layout-footer.html +69 -0
  37. package/web-ui/partials/index/layout-header.html +337 -0
  38. package/web-ui/partials/index/modal-config-template-agents.html +125 -0
  39. package/web-ui/partials/index/modal-confirm-toast.html +32 -0
  40. package/web-ui/partials/index/modal-health-check.html +72 -0
  41. package/web-ui/partials/index/modal-openclaw-config.html +275 -0
  42. package/web-ui/partials/index/modal-skills.html +184 -0
  43. package/web-ui/partials/index/modals-basic.html +196 -0
  44. package/web-ui/partials/index/panel-config-claude.html +100 -0
  45. package/web-ui/partials/index/panel-config-codex.html +237 -0
  46. package/web-ui/partials/index/panel-config-openclaw.html +84 -0
  47. package/web-ui/partials/index/panel-market.html +174 -0
  48. package/web-ui/partials/index/panel-sessions.html +387 -0
  49. package/web-ui/partials/index/panel-settings.html +166 -0
  50. package/web-ui/source-bundle.cjs +233 -0
  51. package/web-ui/styles/base-theme.css +373 -0
  52. package/web-ui/styles/controls-forms.css +354 -0
  53. package/web-ui/styles/feedback.css +108 -0
  54. package/web-ui/styles/health-check-dialog.css +144 -0
  55. package/web-ui/styles/layout-shell.css +330 -0
  56. package/web-ui/styles/modals-core.css +449 -0
  57. package/web-ui/styles/navigation-panels.css +381 -0
  58. package/web-ui/styles/openclaw-structured.css +266 -0
  59. package/web-ui/styles/responsive.css +416 -0
  60. package/web-ui/styles/sessions-list.css +414 -0
  61. package/web-ui/styles/sessions-preview.css +405 -0
  62. package/web-ui/styles/sessions-toolbar-trash.css +243 -0
  63. package/web-ui/styles/sessions-usage.css +276 -0
  64. package/web-ui/styles/skills-list.css +298 -0
  65. package/web-ui/styles/skills-market.css +335 -0
  66. package/web-ui/styles/titles-cards.css +407 -0
  67. package/web-ui/styles.css +16 -4668
@@ -0,0 +1,265 @@
1
+ export function createProvidersMethods(options = {}) {
2
+ const { api } = options;
3
+
4
+ return {
5
+ async addProvider() {
6
+ const rawName = typeof this.newProvider.name === 'string' ? this.newProvider.name : '';
7
+ const rawUrl = typeof this.newProvider.url === 'string' ? this.newProvider.url.trim() : '';
8
+ if (!rawName || !rawUrl) {
9
+ return this.showMessage('名称和URL必填', 'error');
10
+ }
11
+ const name = rawName.trim();
12
+ if (!name) {
13
+ return this.showMessage('名称不能为空', 'error');
14
+ }
15
+ if (name.toLowerCase() === 'local') {
16
+ return this.showMessage('local provider 为系统保留名称,不可新增', 'error');
17
+ }
18
+ if (this.providersList.some(item => item.name === name)) {
19
+ return this.showMessage('名称已存在', 'error');
20
+ }
21
+
22
+ try {
23
+ const res = await api('add-provider', {
24
+ name,
25
+ url: rawUrl,
26
+ key: this.newProvider.key || ''
27
+ });
28
+ if (res.error) {
29
+ this.showMessage(res.error, 'error');
30
+ return;
31
+ }
32
+
33
+ this.showMessage('操作成功', 'success');
34
+ this.closeAddModal();
35
+ await this.loadAll();
36
+ } catch (e) {
37
+ this.showMessage('添加失败', 'error');
38
+ }
39
+ },
40
+
41
+ getCurrentCodexAuthProfile() {
42
+ const list = Array.isArray(this.codexAuthProfiles) ? this.codexAuthProfiles : [];
43
+ return list.find((item) => !!(item && item.current)) || null;
44
+ },
45
+
46
+ isLocalLikeProvider(providerOrName) {
47
+ if (!providerOrName) return false;
48
+ const rawName = typeof providerOrName === 'object'
49
+ ? String(providerOrName.name || '')
50
+ : String(providerOrName);
51
+ const normalized = rawName.trim().toLowerCase();
52
+ return normalized === 'local';
53
+ },
54
+
55
+ providerPillState(provider) {
56
+ if (this.isLocalLikeProvider(provider)) {
57
+ const currentProfile = this.getCurrentCodexAuthProfile();
58
+ return currentProfile
59
+ ? { configured: true, text: '已登录' }
60
+ : { configured: false, text: '未登录' };
61
+ }
62
+ const configured = !!(provider && provider.hasKey);
63
+ return {
64
+ configured,
65
+ text: configured ? '已配置' : '未配置'
66
+ };
67
+ },
68
+
69
+ providerPillConfigured(provider) {
70
+ return this.providerPillState(provider).configured;
71
+ },
72
+
73
+ providerPillText(provider) {
74
+ return this.providerPillState(provider).text;
75
+ },
76
+
77
+ isReadOnlyProvider(providerOrName) {
78
+ if (!providerOrName) return false;
79
+ if (typeof providerOrName === 'object') {
80
+ return !!providerOrName.readOnly;
81
+ }
82
+ const name = String(providerOrName).trim();
83
+ if (!name) return false;
84
+ const target = (this.providersList || []).find((item) => item && item.name === name);
85
+ return !!(target && target.readOnly);
86
+ },
87
+
88
+ isNonDeletableProvider(providerOrName) {
89
+ if (!providerOrName) return false;
90
+ if (typeof providerOrName === 'object') {
91
+ const directName = String(providerOrName.name || '').trim().toLowerCase();
92
+ if (directName === 'local') {
93
+ return true;
94
+ }
95
+ return !!providerOrName.nonDeletable;
96
+ }
97
+ const name = String(providerOrName).trim();
98
+ if (!name) return false;
99
+ const normalized = name.toLowerCase();
100
+ if (normalized === 'local') {
101
+ return true;
102
+ }
103
+ const target = (this.providersList || []).find((item) => item && item.name === name);
104
+ return !!(target && target.nonDeletable);
105
+ },
106
+
107
+ shouldShowProviderDelete(provider) {
108
+ return !this.isReadOnlyProvider(provider) && !this.isNonDeletableProvider(provider);
109
+ },
110
+
111
+ shouldShowProviderEdit(provider) {
112
+ return !this.isReadOnlyProvider(provider) && !this.isNonDeletableProvider(provider);
113
+ },
114
+
115
+ shouldAllowProviderShare(provider) {
116
+ return !this.isReadOnlyProvider(provider) && !this.isLocalLikeProvider(provider);
117
+ },
118
+
119
+ async deleteProvider(name) {
120
+ if (this.isNonDeletableProvider(name)) {
121
+ this.showMessage('该 provider 为保留项,不可删除', 'info');
122
+ return;
123
+ }
124
+ try {
125
+ const res = await api('delete-provider', { name });
126
+ if (res.error) {
127
+ this.showMessage(res.error, 'error');
128
+ return;
129
+ }
130
+ if (res.switched && res.provider) {
131
+ this.showMessage(`已删除提供商,自动切换到 ${res.provider}${res.model ? ` / ${res.model}` : ''}`, 'success');
132
+ } else {
133
+ this.showMessage('操作成功', 'success');
134
+ }
135
+ await this.loadAll();
136
+ } catch (_) {
137
+ this.showMessage('删除失败', 'error');
138
+ }
139
+ },
140
+
141
+ openEditModal(provider) {
142
+ if (!this.shouldShowProviderEdit(provider)) {
143
+ this.showMessage('该 provider 为保留项,不可编辑', 'info');
144
+ return;
145
+ }
146
+ this.editingProvider = {
147
+ name: provider.name,
148
+ url: provider.url || '',
149
+ key: '',
150
+ readOnly: !!provider.readOnly,
151
+ nonEditable: this.isNonDeletableProvider(provider)
152
+ };
153
+ this.showEditModal = true;
154
+ },
155
+
156
+ async updateProvider() {
157
+ if (this.editingProvider.readOnly || this.editingProvider.nonEditable) {
158
+ this.showMessage('该 provider 为保留项,不可编辑', 'error');
159
+ this.closeEditModal();
160
+ return;
161
+ }
162
+ const url = typeof this.editingProvider.url === 'string' ? this.editingProvider.url.trim() : '';
163
+ if (!url) {
164
+ return this.showMessage('URL 必填', 'error');
165
+ }
166
+
167
+ const name = this.editingProvider.name;
168
+ const params = { name, url };
169
+ if (typeof this.editingProvider.key === 'string' && this.editingProvider.key.trim()) {
170
+ params.key = this.editingProvider.key;
171
+ }
172
+ try {
173
+ const res = await api('update-provider', params);
174
+ if (res.error) {
175
+ this.showMessage(res.error, 'error');
176
+ return;
177
+ }
178
+ this.closeEditModal();
179
+ this.showMessage('操作成功', 'success');
180
+ await this.loadAll();
181
+ } catch (e) {
182
+ this.showMessage('更新失败', 'error');
183
+ }
184
+ },
185
+
186
+ closeEditModal() {
187
+ this.showEditModal = false;
188
+ this.editingProvider = { name: '', url: '', key: '', readOnly: false, nonEditable: false };
189
+ },
190
+
191
+ async resetConfig() {
192
+ if (this.resetConfigLoading) return;
193
+ this.resetConfigLoading = true;
194
+ try {
195
+ const res = await api('reset-config');
196
+ if (res.error) {
197
+ this.showMessage(res.error, 'error');
198
+ return;
199
+ }
200
+ const backup = res.backupFile ? `(已备份: ${res.backupFile})` : '';
201
+ this.showMessage(`配置已重装${backup}`, 'success');
202
+ await this.loadAll();
203
+ } catch (e) {
204
+ this.showMessage('重装失败', 'error');
205
+ } finally {
206
+ this.resetConfigLoading = false;
207
+ }
208
+ },
209
+
210
+ async addModel() {
211
+ if (!this.newModelName || !this.newModelName.trim()) {
212
+ return this.showMessage('请输入模型', 'error');
213
+ }
214
+ try {
215
+ const res = await api('add-model', { model: this.newModelName.trim() });
216
+ if (res.error) {
217
+ this.showMessage(res.error, 'error');
218
+ } else {
219
+ this.showMessage('操作成功', 'success');
220
+ this.closeModelModal();
221
+ await this.loadAll();
222
+ }
223
+ } catch (_) {
224
+ this.showMessage('新增模型失败', 'error');
225
+ }
226
+ },
227
+
228
+ async removeModel(model) {
229
+ try {
230
+ const res = await api('delete-model', { model });
231
+ if (res.error) {
232
+ this.showMessage(res.error, 'error');
233
+ } else {
234
+ this.showMessage('操作成功', 'success');
235
+ await this.loadAll();
236
+ }
237
+ } catch (_) {
238
+ this.showMessage('删除模型失败', 'error');
239
+ }
240
+ },
241
+
242
+ closeAddModal() {
243
+ this.showAddModal = false;
244
+ this.newProvider = { name: '', url: '', key: '' };
245
+ },
246
+
247
+ closeModelModal() {
248
+ this.showModelModal = false;
249
+ this.newModelName = '';
250
+ },
251
+
252
+ formatKey(key) {
253
+ if (!key) return '(未设置)';
254
+ if (key.length > 10) {
255
+ return key.substring(0, 3) + '****' + key.substring(key.length - 3);
256
+ }
257
+ return '****';
258
+ },
259
+
260
+ displayApiKey(configName) {
261
+ const key = this.claudeConfigs[configName]?.apiKey;
262
+ return this.formatKey(key);
263
+ }
264
+ };
265
+ }
@@ -0,0 +1,323 @@
1
+ import {
2
+ buildSpeedTestIssue,
3
+ formatLatency
4
+ } from '../logic.mjs';
5
+
6
+ function clearProgressResetTimer(context, timerKey) {
7
+ if (!context || !timerKey || !context[timerKey]) {
8
+ return;
9
+ }
10
+ clearTimeout(context[timerKey]);
11
+ context[timerKey] = null;
12
+ }
13
+
14
+ function scheduleProgressResetTimer(context, timerKey, progressKey, delayMs = 800) {
15
+ if (!context || !timerKey || !progressKey) {
16
+ return;
17
+ }
18
+ clearProgressResetTimer(context, timerKey);
19
+ context[timerKey] = setTimeout(() => {
20
+ context[progressKey] = 0;
21
+ context[timerKey] = null;
22
+ }, delayMs);
23
+ }
24
+
25
+ export function createRuntimeMethods(options = {}) {
26
+ const { api } = options;
27
+
28
+ return {
29
+ formatLatency,
30
+
31
+ buildSpeedTestIssue(name, result) {
32
+ return buildSpeedTestIssue(name, result);
33
+ },
34
+
35
+ async runSpeedTest(name, options = {}) {
36
+ if (!name || this.speedLoading[name]) return null;
37
+ const silent = !!options.silent;
38
+ this.speedLoading[name] = true;
39
+ try {
40
+ const res = await api('speed-test', { name });
41
+ if (res.error) {
42
+ this.speedResults[name] = { ok: false, error: res.error };
43
+ if (!silent) {
44
+ this.showMessage(res.error, 'error');
45
+ }
46
+ return { ok: false, error: res.error };
47
+ }
48
+ this.speedResults[name] = res;
49
+ if (!silent) {
50
+ const status = res.status ? ` (${res.status})` : '';
51
+ this.showMessage(`Speed ${name}: ${this.formatLatency(res)}${status}`, 'success');
52
+ }
53
+ return res;
54
+ } catch (e) {
55
+ const message = e && e.message ? e.message : 'Speed test failed';
56
+ this.speedResults[name] = { ok: false, error: message };
57
+ if (!silent) {
58
+ this.showMessage(message, 'error');
59
+ }
60
+ return { ok: false, error: message };
61
+ } finally {
62
+ this.speedLoading[name] = false;
63
+ }
64
+ },
65
+
66
+ async runClaudeSpeedTest(name, config) {
67
+ if (!name || this.claudeSpeedLoading[name]) return null;
68
+ const baseUrl = config && typeof config.baseUrl === 'string' ? config.baseUrl.trim() : '';
69
+ this.claudeSpeedLoading[name] = true;
70
+ try {
71
+ if (!baseUrl) {
72
+ const res = { ok: false, error: 'Missing base URL' };
73
+ this.claudeSpeedResults[name] = res;
74
+ return res;
75
+ }
76
+ const res = await api('speed-test', { url: baseUrl });
77
+ if (res.error) {
78
+ this.claudeSpeedResults[name] = { ok: false, error: res.error };
79
+ return { ok: false, error: res.error };
80
+ }
81
+ this.claudeSpeedResults[name] = res;
82
+ return res;
83
+ } catch (e) {
84
+ const message = e && e.message ? e.message : 'Speed test failed';
85
+ const res = { ok: false, error: message };
86
+ this.claudeSpeedResults[name] = res;
87
+ return res;
88
+ } finally {
89
+ this.claudeSpeedLoading[name] = false;
90
+ }
91
+ },
92
+
93
+ async downloadClaudeDirectory() {
94
+ if (this.claudeDownloadLoading) return;
95
+ clearProgressResetTimer(this, '__claudeDownloadResetTimer');
96
+ this.claudeDownloadLoading = true;
97
+ this.claudeDownloadProgress = 5;
98
+ this.claudeDownloadTimer = setInterval(() => {
99
+ if (this.claudeDownloadProgress < 90) {
100
+ this.claudeDownloadProgress += 5;
101
+ }
102
+ }, 400);
103
+ try {
104
+ const res = await api('download-claude-dir');
105
+ if (res && res.error) {
106
+ this.showMessage(res.error, 'error');
107
+ return;
108
+ }
109
+ if (!res || res.success !== true || !res.fileName) {
110
+ this.showMessage('备份失败', 'error');
111
+ return;
112
+ }
113
+ this.claudeDownloadProgress = 100;
114
+ const downloadUrl = `/download/${encodeURIComponent(res.fileName)}`;
115
+ const link = document.createElement('a');
116
+ link.href = downloadUrl;
117
+ link.download = res.fileName;
118
+ document.body.appendChild(link);
119
+ link.click();
120
+ document.body.removeChild(link);
121
+ this.showMessage('备份成功,开始下载', 'success');
122
+ } catch (e) {
123
+ this.showMessage('备份失败:' + (e && e.message ? e.message : '未知错误'), 'error');
124
+ } finally {
125
+ if (this.claudeDownloadTimer) {
126
+ clearInterval(this.claudeDownloadTimer);
127
+ this.claudeDownloadTimer = null;
128
+ }
129
+ this.claudeDownloadLoading = false;
130
+ scheduleProgressResetTimer(this, '__claudeDownloadResetTimer', 'claudeDownloadProgress');
131
+ }
132
+ },
133
+
134
+ async downloadCodexDirectory() {
135
+ if (this.codexDownloadLoading) return;
136
+ clearProgressResetTimer(this, '__codexDownloadResetTimer');
137
+ this.codexDownloadLoading = true;
138
+ this.codexDownloadProgress = 5;
139
+ this.codexDownloadTimer = setInterval(() => {
140
+ if (this.codexDownloadProgress < 90) {
141
+ this.codexDownloadProgress += 5;
142
+ }
143
+ }, 400);
144
+ try {
145
+ const res = await api('download-codex-dir');
146
+ if (res && res.error) {
147
+ this.showMessage(res.error, 'error');
148
+ return;
149
+ }
150
+ if (!res || res.success !== true || !res.fileName) {
151
+ this.showMessage('备份失败', 'error');
152
+ return;
153
+ }
154
+ this.codexDownloadProgress = 100;
155
+ const downloadUrl = `/download/${encodeURIComponent(res.fileName)}`;
156
+ const link = document.createElement('a');
157
+ link.href = downloadUrl;
158
+ link.download = res.fileName;
159
+ document.body.appendChild(link);
160
+ link.click();
161
+ document.body.removeChild(link);
162
+ this.showMessage('备份成功,开始下载', 'success');
163
+ } catch (e) {
164
+ this.showMessage('备份失败:' + (e && e.message ? e.message : '未知错误'), 'error');
165
+ } finally {
166
+ if (this.codexDownloadTimer) {
167
+ clearInterval(this.codexDownloadTimer);
168
+ this.codexDownloadTimer = null;
169
+ }
170
+ this.codexDownloadLoading = false;
171
+ scheduleProgressResetTimer(this, '__codexDownloadResetTimer', 'codexDownloadProgress');
172
+ }
173
+ },
174
+
175
+ triggerClaudeImport() {
176
+ const input = this.$refs.claudeImportInput;
177
+ if (input) {
178
+ input.value = '';
179
+ input.click();
180
+ }
181
+ },
182
+
183
+ triggerCodexImport() {
184
+ const input = this.$refs.codexImportInput;
185
+ if (input) {
186
+ input.value = '';
187
+ input.click();
188
+ }
189
+ },
190
+
191
+ handleClaudeImportChange(event) {
192
+ const file = event && event.target && event.target.files ? event.target.files[0] : null;
193
+ if (file) {
194
+ void this.importBackupFile('claude', file);
195
+ }
196
+ },
197
+
198
+ handleCodexImportChange(event) {
199
+ const file = event && event.target && event.target.files ? event.target.files[0] : null;
200
+ if (file) {
201
+ void this.importBackupFile('codex', file);
202
+ }
203
+ },
204
+
205
+ async importBackupFile(type, file) {
206
+ const maxSize = 200 * 1024 * 1024;
207
+ const loadingKey = type === 'claude' ? 'claudeImportLoading' : 'codexImportLoading';
208
+ if (this[loadingKey]) {
209
+ this.resetImportInput(type);
210
+ return;
211
+ }
212
+ if (file.size > maxSize) {
213
+ this.showMessage('备份文件过大,限制 200MB', 'error');
214
+ this.resetImportInput(type);
215
+ return;
216
+ }
217
+ this[loadingKey] = true;
218
+ try {
219
+ const base64 = await this.readFileAsBase64(file);
220
+ const action = type === 'claude' ? 'restore-claude-dir' : 'restore-codex-dir';
221
+ const res = await api(action, {
222
+ fileName: file.name || `${type}-backup.zip`,
223
+ fileBase64: base64
224
+ });
225
+ if (res && res.error) {
226
+ this.showMessage(res.error, 'error');
227
+ return;
228
+ }
229
+ const backupTip = res && res.backupPath ? `,原配置已备份到临时文件:${res.backupPath}` : '';
230
+ this.showMessage(`导入成功${backupTip}`, 'success');
231
+ try {
232
+ if (type === 'claude') {
233
+ await this.refreshClaudeSelectionFromSettings({ silent: true });
234
+ } else {
235
+ await this.loadAll();
236
+ }
237
+ } catch (_) {
238
+ this.showMessage('导入已完成,但界面刷新失败,请手动刷新', 'error');
239
+ }
240
+ } catch (e) {
241
+ this.showMessage('导入失败:' + (e && e.message ? e.message : '未知错误'), 'error');
242
+ } finally {
243
+ this[loadingKey] = false;
244
+ this.resetImportInput(type);
245
+ }
246
+ },
247
+
248
+ readFileAsBase64(file) {
249
+ return new Promise((resolve, reject) => {
250
+ const reader = new FileReader();
251
+ reader.onload = () => {
252
+ const result = reader.result;
253
+ if (result instanceof ArrayBuffer) {
254
+ resolve(this.arrayBufferToBase64(result));
255
+ return;
256
+ }
257
+ if (typeof result === 'string') {
258
+ const idx = result.indexOf('base64,');
259
+ resolve(idx >= 0 ? result.slice(idx + 7) : result);
260
+ return;
261
+ }
262
+ reject(new Error('不支持的文件读取结果'));
263
+ };
264
+ reader.onerror = () => reject(new Error('读取文件失败'));
265
+ reader.readAsArrayBuffer(file);
266
+ });
267
+ },
268
+
269
+ arrayBufferToBase64(buffer) {
270
+ const bytes = new Uint8Array(buffer);
271
+ const chunkSize = 0x8000;
272
+ let binary = '';
273
+ for (let i = 0; i < bytes.byteLength; i += chunkSize) {
274
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize));
275
+ }
276
+ return btoa(binary);
277
+ },
278
+
279
+ resetImportInput(type) {
280
+ const refName = type === 'claude' ? 'claudeImportInput' : 'codexImportInput';
281
+ const el = this.$refs[refName];
282
+ if (el) {
283
+ el.value = '';
284
+ }
285
+ },
286
+
287
+ async loadCodexAuthProfiles(options = {}) {
288
+ const silent = !!options.silent;
289
+ try {
290
+ const res = await api('list-auth-profiles');
291
+ if (res && res.error) {
292
+ if (!silent) {
293
+ this.showMessage(res.error, 'error');
294
+ }
295
+ return;
296
+ }
297
+ const list = Array.isArray(res && res.profiles) ? res.profiles : [];
298
+ this.codexAuthProfiles = list.sort((a, b) => {
299
+ if (!!a.current !== !!b.current) {
300
+ return a.current ? -1 : 1;
301
+ }
302
+ return String(a.name || '').localeCompare(String(b.name || ''));
303
+ });
304
+ } catch (e) {
305
+ if (!silent) {
306
+ this.showMessage('读取认证列表失败', 'error');
307
+ }
308
+ }
309
+ },
310
+
311
+ showMessage(text, type) {
312
+ if (this._messageTimer) {
313
+ clearTimeout(this._messageTimer);
314
+ }
315
+ this.message = text;
316
+ this.messageType = type || 'info';
317
+ this._messageTimer = setTimeout(() => {
318
+ this.message = '';
319
+ this._messageTimer = null;
320
+ }, 3000);
321
+ }
322
+ };
323
+ }