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