codexmate 0.0.37 → 0.0.39
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/cli/analytics-export-args.js +68 -0
- package/cli/builtin-proxy.js +626 -207
- package/cli/openai-bridge.js +541 -210
- package/cli/session-usage.js +187 -1
- package/cli.js +84 -2
- package/package.json +1 -1
- package/web-ui/app.js +12 -3
- package/web-ui/modules/app.computed.main-tabs.mjs +37 -30
- package/web-ui/modules/app.methods.claude-config.mjs +111 -9
- package/web-ui/modules/app.methods.openclaw-editing.mjs +48 -0
- package/web-ui/modules/app.methods.openclaw-persist.mjs +13 -7
- package/web-ui/modules/app.methods.providers.mjs +36 -10
- package/web-ui/modules/app.methods.runtime.mjs +76 -1
- package/web-ui/modules/app.methods.startup-claude.mjs +1 -0
- package/web-ui/modules/config-mode.computed.mjs +3 -3
- package/web-ui/modules/i18n.dict.mjs +13 -0
- package/web-ui/modules/i18n.mjs +65 -16
- package/web-ui/modules/skills.methods.mjs +1 -1
- package/web-ui/partials/index/layout-header.html +16 -46
- package/web-ui/partials/index/modal-openclaw-config.html +135 -71
- package/web-ui/partials/index/modal-webhook.html +8 -8
- package/web-ui/partials/index/modals-basic.html +56 -16
- package/web-ui/partials/index/panel-config-claude.html +20 -20
- package/web-ui/partials/index/panel-config-codex.html +5 -5
- package/web-ui/partials/index/panel-config-openclaw.html +70 -64
- package/web-ui/partials/index/panel-dashboard.html +62 -77
- package/web-ui/partials/index/panel-settings.html +28 -7
- package/web-ui/partials/index/panel-trash.html +14 -14
- package/web-ui/res/web-ui-render.precompiled.js +846 -539
- package/web-ui/styles/controls-forms.css +6 -0
- package/web-ui/styles/dashboard.css +46 -14
- package/web-ui/styles/layout-shell.css +45 -0
- package/web-ui/styles/navigation-panels.css +3 -3
- package/web-ui/styles/openclaw-structured.css +383 -33
- package/web-ui/styles/responsive.css +68 -0
- package/web-ui/styles/sessions-usage.css +105 -9
- package/web-ui/styles/settings-panel.css +4 -0
- package/web-ui/partials/index/panel-config-codex.html.bak +0 -337
|
@@ -1,3 +1,67 @@
|
|
|
1
|
+
function normalizeClaudeText(value) {
|
|
2
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function normalizeClaudeBaseUrl(value) {
|
|
6
|
+
return normalizeClaudeText(value).replace(/\/+$/g, '');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function isValidClaudeHttpUrl(value) {
|
|
10
|
+
if (!value) return false;
|
|
11
|
+
try {
|
|
12
|
+
const parsed = new URL(value);
|
|
13
|
+
return parsed.protocol === 'http:' || parsed.protocol === 'https:';
|
|
14
|
+
} catch (_) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getClaudeConfigValidationForContext(vm, mode = 'add') {
|
|
20
|
+
const draft = mode === 'edit' ? vm.editingConfig : vm.newClaudeConfig;
|
|
21
|
+
const name = normalizeClaudeText(draft && draft.name);
|
|
22
|
+
const apiKey = normalizeClaudeText(draft && draft.apiKey);
|
|
23
|
+
const externalCredentialType = normalizeClaudeText(draft && draft.externalCredentialType);
|
|
24
|
+
const baseUrl = normalizeClaudeBaseUrl(draft && draft.baseUrl);
|
|
25
|
+
const model = normalizeClaudeText(draft && draft.model);
|
|
26
|
+
const errors = {
|
|
27
|
+
name: '',
|
|
28
|
+
apiKey: '',
|
|
29
|
+
baseUrl: '',
|
|
30
|
+
model: ''
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
if (!name) {
|
|
34
|
+
errors.name = '配置名称不能为空';
|
|
35
|
+
} else if (mode === 'add' && vm.claudeConfigs && vm.claudeConfigs[name]) {
|
|
36
|
+
errors.name = '名称已存在';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!apiKey && !externalCredentialType) {
|
|
40
|
+
errors.apiKey = 'API Key 必填';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!baseUrl) {
|
|
44
|
+
errors.baseUrl = 'Base URL 必填';
|
|
45
|
+
} else if (!isValidClaudeHttpUrl(baseUrl)) {
|
|
46
|
+
errors.baseUrl = 'Base URL 仅支持 http/https';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!model) {
|
|
50
|
+
errors.model = '模型名称必填';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
mode,
|
|
55
|
+
name,
|
|
56
|
+
apiKey,
|
|
57
|
+
externalCredentialType,
|
|
58
|
+
baseUrl,
|
|
59
|
+
model,
|
|
60
|
+
errors,
|
|
61
|
+
ok: !errors.name && !errors.apiKey && !errors.baseUrl && !errors.model
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
1
65
|
export function createClaudeConfigMethods(options = {}) {
|
|
2
66
|
const { api } = options;
|
|
3
67
|
|
|
@@ -54,14 +118,31 @@ export function createClaudeConfigMethods(options = {}) {
|
|
|
54
118
|
baseUrl: config.baseUrl || '',
|
|
55
119
|
model: config.model || ''
|
|
56
120
|
};
|
|
121
|
+
this.showAddClaudeConfigKey = false;
|
|
57
122
|
this.showClaudeConfigModal = true;
|
|
58
123
|
},
|
|
59
124
|
|
|
125
|
+
getClaudeConfigValidation(mode = 'add') {
|
|
126
|
+
return getClaudeConfigValidationForContext(this, mode);
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
claudeConfigFieldError(mode, fieldName) {
|
|
130
|
+
const validation = getClaudeConfigValidationForContext(this, mode);
|
|
131
|
+
return validation && validation.errors && typeof validation.errors[fieldName] === 'string'
|
|
132
|
+
? validation.errors[fieldName]
|
|
133
|
+
: '';
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
canSubmitClaudeConfig(mode = 'add') {
|
|
137
|
+
return getClaudeConfigValidationForContext(this, mode).ok;
|
|
138
|
+
},
|
|
139
|
+
|
|
60
140
|
openEditConfigModal(name) {
|
|
61
141
|
const config = this.claudeConfigs[name];
|
|
62
142
|
this.editingConfig = {
|
|
63
143
|
name: name,
|
|
64
144
|
apiKey: config.apiKey || '',
|
|
145
|
+
externalCredentialType: config.externalCredentialType || '',
|
|
65
146
|
baseUrl: config.baseUrl || '',
|
|
66
147
|
model: config.model || ''
|
|
67
148
|
};
|
|
@@ -70,7 +151,14 @@ export function createClaudeConfigMethods(options = {}) {
|
|
|
70
151
|
},
|
|
71
152
|
|
|
72
153
|
updateConfig() {
|
|
73
|
-
const
|
|
154
|
+
const validation = getClaudeConfigValidationForContext(this, 'edit');
|
|
155
|
+
if (!validation.ok) {
|
|
156
|
+
return this.showMessage(validation.errors.name || validation.errors.apiKey || validation.errors.baseUrl || validation.errors.model || '请检查 Claude 配置', 'error');
|
|
157
|
+
}
|
|
158
|
+
const name = validation.name;
|
|
159
|
+
this.editingConfig.apiKey = validation.apiKey;
|
|
160
|
+
this.editingConfig.baseUrl = validation.baseUrl;
|
|
161
|
+
this.editingConfig.model = validation.model;
|
|
74
162
|
this.claudeConfigs[name] = this.mergeClaudeConfig(this.claudeConfigs[name], this.editingConfig);
|
|
75
163
|
this.saveClaudeConfigs();
|
|
76
164
|
this.showMessage('操作成功', 'success');
|
|
@@ -83,7 +171,7 @@ export function createClaudeConfigMethods(options = {}) {
|
|
|
83
171
|
closeEditConfigModal() {
|
|
84
172
|
this.showEditConfigModal = false;
|
|
85
173
|
this.showEditClaudeConfigKey = false;
|
|
86
|
-
this.editingConfig = { name: '', apiKey: '', baseUrl: '', model: '' };
|
|
174
|
+
this.editingConfig = { name: '', apiKey: '', externalCredentialType: '', baseUrl: '', model: '' };
|
|
87
175
|
},
|
|
88
176
|
|
|
89
177
|
toggleEditClaudeConfigKey() {
|
|
@@ -91,7 +179,14 @@ export function createClaudeConfigMethods(options = {}) {
|
|
|
91
179
|
},
|
|
92
180
|
|
|
93
181
|
async saveAndApplyConfig() {
|
|
94
|
-
const
|
|
182
|
+
const validation = getClaudeConfigValidationForContext(this, 'edit');
|
|
183
|
+
if (!validation.ok) {
|
|
184
|
+
return this.showMessage(validation.errors.name || validation.errors.apiKey || validation.errors.baseUrl || validation.errors.model || '请检查 Claude 配置', 'error');
|
|
185
|
+
}
|
|
186
|
+
const name = validation.name;
|
|
187
|
+
this.editingConfig.apiKey = validation.apiKey;
|
|
188
|
+
this.editingConfig.baseUrl = validation.baseUrl;
|
|
189
|
+
this.editingConfig.model = validation.model;
|
|
95
190
|
this.claudeConfigs[name] = this.mergeClaudeConfig(this.claudeConfigs[name], this.editingConfig);
|
|
96
191
|
this.saveClaudeConfigs();
|
|
97
192
|
|
|
@@ -125,13 +220,15 @@ export function createClaudeConfigMethods(options = {}) {
|
|
|
125
220
|
},
|
|
126
221
|
|
|
127
222
|
addClaudeConfig() {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const name = this.newClaudeConfig.name.trim();
|
|
132
|
-
if (this.claudeConfigs[name]) {
|
|
133
|
-
return this.showMessage('名称已存在', 'error');
|
|
223
|
+
const validation = getClaudeConfigValidationForContext(this, 'add');
|
|
224
|
+
if (!validation.ok) {
|
|
225
|
+
return this.showMessage(validation.errors.name || validation.errors.apiKey || validation.errors.baseUrl || validation.errors.model || '请检查 Claude 配置', 'error');
|
|
134
226
|
}
|
|
227
|
+
this.newClaudeConfig.name = validation.name;
|
|
228
|
+
this.newClaudeConfig.apiKey = validation.apiKey;
|
|
229
|
+
this.newClaudeConfig.baseUrl = validation.baseUrl;
|
|
230
|
+
this.newClaudeConfig.model = validation.model;
|
|
231
|
+
const name = validation.name;
|
|
135
232
|
const duplicateName = this.findDuplicateClaudeConfigName(this.newClaudeConfig);
|
|
136
233
|
if (duplicateName) {
|
|
137
234
|
return this.showMessage('配置已存在', 'info');
|
|
@@ -199,6 +296,7 @@ export function createClaudeConfigMethods(options = {}) {
|
|
|
199
296
|
|
|
200
297
|
closeClaudeConfigModal() {
|
|
201
298
|
this.showClaudeConfigModal = false;
|
|
299
|
+
this.showAddClaudeConfigKey = false;
|
|
202
300
|
this.newClaudeConfig = {
|
|
203
301
|
name: '',
|
|
204
302
|
apiKey: '',
|
|
@@ -207,6 +305,10 @@ export function createClaudeConfigMethods(options = {}) {
|
|
|
207
305
|
};
|
|
208
306
|
},
|
|
209
307
|
|
|
308
|
+
toggleAddClaudeConfigKey() {
|
|
309
|
+
this.showAddClaudeConfigKey = !this.showAddClaudeConfigKey;
|
|
310
|
+
},
|
|
311
|
+
|
|
210
312
|
async loadClaudeLocalBridgeStatus() {
|
|
211
313
|
try {
|
|
212
314
|
const res = await api('claude-local-bridge-status');
|
|
@@ -367,6 +367,54 @@ export function createOpenclawEditingMethods() {
|
|
|
367
367
|
this.showMessage('保存本地 OpenClaw 配置失败', 'error');
|
|
368
368
|
return false;
|
|
369
369
|
}
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
// Accordion stepper methods
|
|
373
|
+
toggleAccordionStep(step) {
|
|
374
|
+
if (this.openclawAccordionStep === step) {
|
|
375
|
+
// Don't allow collapsing the current step
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
this.openclawAccordionStep = step;
|
|
379
|
+
},
|
|
380
|
+
|
|
381
|
+
nextAccordionStep() {
|
|
382
|
+
if (this.openclawAccordionStep < 3) {
|
|
383
|
+
this.openclawAccordionStep++;
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
|
|
387
|
+
prevAccordionStep() {
|
|
388
|
+
if (this.openclawAccordionStep > 1) {
|
|
389
|
+
this.openclawAccordionStep--;
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
|
|
393
|
+
finishAccordionStep() {
|
|
394
|
+
this.openclawAccordionStep = 4; // Mark as complete
|
|
395
|
+
this.applyOpenclawQuickToText();
|
|
396
|
+
},
|
|
397
|
+
|
|
398
|
+
validateProviderName() {
|
|
399
|
+
const name = (this.openclawQuick.providerName || '').trim();
|
|
400
|
+
if (!name) {
|
|
401
|
+
this.openclawValidation.providerName = { valid: false, message: '必填' };
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (name.includes('/')) {
|
|
405
|
+
this.openclawValidation.providerName = { valid: false, message: '不能包含 "/"' };
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
this.openclawValidation.providerName = { valid: true, message: '' };
|
|
409
|
+
},
|
|
410
|
+
|
|
411
|
+
validateModelId() {
|
|
412
|
+
const id = (this.openclawQuick.modelId || '').trim();
|
|
413
|
+
if (!id) {
|
|
414
|
+
this.openclawValidation.modelId = { valid: false, message: '必填' };
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
this.openclawValidation.modelId = { valid: true, message: '' };
|
|
370
418
|
}
|
|
371
419
|
};
|
|
372
420
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const DEFAULT_OPENCLAW_CONFIG_NAME = '默认配置';
|
|
1
|
+
export const DEFAULT_OPENCLAW_CONFIG_NAME = '默认配置';
|
|
2
2
|
|
|
3
3
|
function buildNormalizedOpenclawConfigs(configs, defaultContent = '') {
|
|
4
4
|
const source = configs && typeof configs === 'object' && !Array.isArray(configs)
|
|
@@ -11,7 +11,8 @@ function buildNormalizedOpenclawConfigs(configs, defaultContent = '') {
|
|
|
11
11
|
: { content: defaultContent };
|
|
12
12
|
const normalized = {
|
|
13
13
|
[DEFAULT_OPENCLAW_CONFIG_NAME]: {
|
|
14
|
-
content: typeof defaultEntry.content === 'string' ? defaultEntry.content : defaultContent
|
|
14
|
+
content: typeof defaultEntry.content === 'string' ? defaultEntry.content : defaultContent,
|
|
15
|
+
isDefault: true
|
|
15
16
|
}
|
|
16
17
|
};
|
|
17
18
|
for (const [name, value] of Object.entries(source)) {
|
|
@@ -25,7 +26,8 @@ function syncDefaultOpenclawConfigState(vm, content, options = {}) {
|
|
|
25
26
|
const nextContent = typeof content === 'string' ? content : '';
|
|
26
27
|
vm.openclawConfigs = buildNormalizedOpenclawConfigs(vm.openclawConfigs, nextContent);
|
|
27
28
|
vm.openclawConfigs[DEFAULT_OPENCLAW_CONFIG_NAME] = {
|
|
28
|
-
content: nextContent
|
|
29
|
+
content: nextContent,
|
|
30
|
+
isDefault: true
|
|
29
31
|
};
|
|
30
32
|
if (typeof options.path === 'string') {
|
|
31
33
|
vm.openclawConfigPath = options.path;
|
|
@@ -51,6 +53,10 @@ export function createOpenclawPersistMethods(options = {}) {
|
|
|
51
53
|
} = options;
|
|
52
54
|
|
|
53
55
|
return {
|
|
56
|
+
isDefaultOpenclawConfig(name, config = null) {
|
|
57
|
+
return !!(config && config.isDefault === true) || name === DEFAULT_OPENCLAW_CONFIG_NAME;
|
|
58
|
+
},
|
|
59
|
+
|
|
54
60
|
syncDefaultOpenclawConfigEntry(options = {}) {
|
|
55
61
|
const silent = !!options.silent;
|
|
56
62
|
return api('get-openclaw-config')
|
|
@@ -104,7 +110,7 @@ export function createOpenclawPersistMethods(options = {}) {
|
|
|
104
110
|
|
|
105
111
|
openOpenclawEditModal(name) {
|
|
106
112
|
const existing = this.openclawConfigs[name];
|
|
107
|
-
const isDefaultConfig = name
|
|
113
|
+
const isDefaultConfig = this.isDefaultOpenclawConfig(name, existing);
|
|
108
114
|
const modalToken = (Number(this.openclawModalLoadToken || 0) + 1);
|
|
109
115
|
this.openclawModalLoadToken = modalToken;
|
|
110
116
|
this.openclawEditorTitle = `编辑 OpenClaw 配置: ${name}`;
|
|
@@ -146,7 +152,7 @@ export function createOpenclawPersistMethods(options = {}) {
|
|
|
146
152
|
const force = !!options.force;
|
|
147
153
|
const fallbackToTemplate = options.fallbackToTemplate !== false;
|
|
148
154
|
const syncDefaultEntry = options.syncDefaultEntry === true
|
|
149
|
-
|| (this.openclawEditing && this.openclawEditing.lockName && this.openclawEditing.name
|
|
155
|
+
|| (this.openclawEditing && this.openclawEditing.lockName && this.isDefaultOpenclawConfig(this.openclawEditing.name));
|
|
150
156
|
const modalToken = Number(options.modalToken || this.openclawModalLoadToken || 0);
|
|
151
157
|
const expectedEditorContent = typeof options.expectedEditorContent === 'string'
|
|
152
158
|
? options.expectedEditorContent
|
|
@@ -260,7 +266,7 @@ export function createOpenclawPersistMethods(options = {}) {
|
|
|
260
266
|
if (this.openclawSaving || this.openclawApplying) {
|
|
261
267
|
return;
|
|
262
268
|
}
|
|
263
|
-
if (this.openclawEditing && this.openclawEditing.lockName && this.openclawEditing.name
|
|
269
|
+
if (this.openclawEditing && this.openclawEditing.lockName && this.isDefaultOpenclawConfig(this.openclawEditing.name)) {
|
|
264
270
|
this.showMessage('默认配置代表当前系统配置,请使用“保存并应用”', 'info');
|
|
265
271
|
return;
|
|
266
272
|
}
|
|
@@ -312,7 +318,7 @@ export function createOpenclawPersistMethods(options = {}) {
|
|
|
312
318
|
},
|
|
313
319
|
|
|
314
320
|
async deleteOpenclawConfig(name) {
|
|
315
|
-
if (name
|
|
321
|
+
if (this.isDefaultOpenclawConfig(name, this.openclawConfigs && this.openclawConfigs[name])) {
|
|
316
322
|
return this.showMessage('默认配置始终映射当前系统配置,不可删除', 'info');
|
|
317
323
|
}
|
|
318
324
|
if (Object.keys(this.openclawConfigs).length <= 1) {
|
|
@@ -47,6 +47,12 @@ function normalizeProviderDraftState(target) {
|
|
|
47
47
|
if (typeof target.url === 'string') {
|
|
48
48
|
target.url = normalizeProviderUrl(target.url);
|
|
49
49
|
}
|
|
50
|
+
if (typeof target.model === 'string') {
|
|
51
|
+
target.model = target.model.trim();
|
|
52
|
+
}
|
|
53
|
+
if (typeof target.key === 'string') {
|
|
54
|
+
target.key = target.key.trim();
|
|
55
|
+
}
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
function maskKeyLocal(key) {
|
|
@@ -66,9 +72,13 @@ function getProviderValidationForContext(vm, mode = 'add') {
|
|
|
66
72
|
const editingName = mode === 'edit' ? normalizeText(draft && draft.name) : '';
|
|
67
73
|
const name = normalizeText(draft && draft.name);
|
|
68
74
|
const url = normalizeProviderUrl(draft && draft.url);
|
|
75
|
+
const model = normalizeText(draft && draft.model);
|
|
76
|
+
const key = normalizeText(draft && draft.key);
|
|
69
77
|
const errors = {
|
|
70
78
|
name: '',
|
|
71
|
-
url: ''
|
|
79
|
+
url: '',
|
|
80
|
+
key: '',
|
|
81
|
+
model: ''
|
|
72
82
|
};
|
|
73
83
|
|
|
74
84
|
if (mode === 'add') {
|
|
@@ -91,12 +101,22 @@ function getProviderValidationForContext(vm, mode = 'add') {
|
|
|
91
101
|
errors.url = 'URL 仅支持 http/https';
|
|
92
102
|
}
|
|
93
103
|
|
|
104
|
+
if (mode === 'add' && !key) {
|
|
105
|
+
errors.key = 'API Key 必填';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (mode === 'add' && !model) {
|
|
109
|
+
errors.model = '模型名称必填';
|
|
110
|
+
}
|
|
111
|
+
|
|
94
112
|
return {
|
|
95
113
|
mode,
|
|
96
114
|
name,
|
|
97
115
|
url,
|
|
116
|
+
key,
|
|
117
|
+
model,
|
|
98
118
|
errors,
|
|
99
|
-
ok: !errors.name && !errors.url
|
|
119
|
+
ok: !errors.name && !errors.url && !errors.key && !errors.model
|
|
100
120
|
};
|
|
101
121
|
}
|
|
102
122
|
|
|
@@ -150,21 +170,20 @@ export function createProvidersMethods(options = {}) {
|
|
|
150
170
|
normalizeProviderDraftState(this.newProvider);
|
|
151
171
|
const validation = getProviderValidationForContext(this, 'add');
|
|
152
172
|
if (!validation.ok) {
|
|
153
|
-
return this.showMessage(validation.errors.name || validation.errors.url || '
|
|
173
|
+
return this.showMessage(validation.errors.name || validation.errors.url || validation.errors.key || validation.errors.model || '名称、URL、API Key 和模型名称必填', 'error');
|
|
154
174
|
}
|
|
155
175
|
|
|
156
176
|
try {
|
|
157
177
|
const payload = {
|
|
158
178
|
name: validation.name,
|
|
159
179
|
url: validation.url,
|
|
160
|
-
key:
|
|
180
|
+
key: validation.key,
|
|
181
|
+
model: validation.model
|
|
161
182
|
};
|
|
162
183
|
if (this.newProvider && this.newProvider.useTransform) {
|
|
163
184
|
payload.useTransform = true;
|
|
164
185
|
}
|
|
165
|
-
const suggestedModel =
|
|
166
|
-
? this.newProvider._suggestedModel.trim()
|
|
167
|
-
: '';
|
|
186
|
+
const suggestedModel = validation.model;
|
|
168
187
|
const res = await api('add-provider', payload);
|
|
169
188
|
if (res.error) {
|
|
170
189
|
this.showMessage(res.error, 'error');
|
|
@@ -179,7 +198,7 @@ export function createProvidersMethods(options = {}) {
|
|
|
179
198
|
codexmate_bridge: payload.useTransform ? 'openai' : '',
|
|
180
199
|
key: maskKeyLocal(payload.key),
|
|
181
200
|
hasKey: !!payload.key,
|
|
182
|
-
models: [],
|
|
201
|
+
models: suggestedModel ? [{ id: suggestedModel, name: suggestedModel, cost: null, contextWindow: undefined, maxTokens: undefined }] : [],
|
|
183
202
|
current: false,
|
|
184
203
|
readOnly: false,
|
|
185
204
|
nonDeletable: false,
|
|
@@ -208,7 +227,7 @@ export function createProvidersMethods(options = {}) {
|
|
|
208
227
|
const configured = !!(provider && provider.hasKey);
|
|
209
228
|
return {
|
|
210
229
|
configured,
|
|
211
|
-
text: configured ? '
|
|
230
|
+
text: configured ? this.t('common.configured') : this.t('common.notConfigured')
|
|
212
231
|
};
|
|
213
232
|
},
|
|
214
233
|
|
|
@@ -300,8 +319,10 @@ export function createProvidersMethods(options = {}) {
|
|
|
300
319
|
name: '',
|
|
301
320
|
url: cloneUrl,
|
|
302
321
|
key: '',
|
|
322
|
+
model: '',
|
|
303
323
|
useTransform: isTransform
|
|
304
324
|
};
|
|
325
|
+
this.showAddProviderKey = false;
|
|
305
326
|
this.showAddModal = true;
|
|
306
327
|
},
|
|
307
328
|
|
|
@@ -513,7 +534,12 @@ export function createProvidersMethods(options = {}) {
|
|
|
513
534
|
|
|
514
535
|
closeAddModal() {
|
|
515
536
|
this.showAddModal = false;
|
|
516
|
-
this.
|
|
537
|
+
this.showAddProviderKey = false;
|
|
538
|
+
this.newProvider = { name: '', url: '', key: '', model: '', useTransform: false };
|
|
539
|
+
},
|
|
540
|
+
|
|
541
|
+
toggleAddProviderKey() {
|
|
542
|
+
this.showAddProviderKey = !this.showAddProviderKey;
|
|
517
543
|
},
|
|
518
544
|
|
|
519
545
|
closeModelModal() {
|
|
@@ -3,6 +3,81 @@ import {
|
|
|
3
3
|
formatLatency
|
|
4
4
|
} from '../logic.mjs';
|
|
5
5
|
|
|
6
|
+
const UI_MESSAGE_KEY_BY_TEXT = Object.freeze({
|
|
7
|
+
'操作成功': 'toast.operationSuccess',
|
|
8
|
+
'操作失败': 'toast.operationFailed',
|
|
9
|
+
'添加失败': 'toast.addFailed',
|
|
10
|
+
'更新失败': 'toast.updateFailed',
|
|
11
|
+
'删除失败': 'toast.deleteFailed',
|
|
12
|
+
'已删除': 'toast.deleted',
|
|
13
|
+
'已复制': 'toast.copied',
|
|
14
|
+
'复制失败': 'toast.copyFailed',
|
|
15
|
+
'剪贴板为空': 'toast.clipboardEmpty',
|
|
16
|
+
'无法读取剪贴板': 'toast.clipboardReadFailed',
|
|
17
|
+
'已粘贴': 'toast.pasted',
|
|
18
|
+
'未检测到改动': 'toast.noChanges',
|
|
19
|
+
'配置已应用': 'toast.configApplied',
|
|
20
|
+
'应用配置失败': 'toast.applyConfigFailed',
|
|
21
|
+
'应用失败': 'toast.applyFailed',
|
|
22
|
+
'配置已加载': 'toast.configLoaded',
|
|
23
|
+
'配置就绪': 'toast.configReady',
|
|
24
|
+
'加载配置失败': 'toast.loadConfigFailed',
|
|
25
|
+
'读取配置失败': 'toast.readConfigFailed',
|
|
26
|
+
'读取配置超时': 'toast.readConfigTimeout',
|
|
27
|
+
'备份失败': 'toast.backupFailed',
|
|
28
|
+
'备份成功,开始下载': 'toast.backupReadyDownload',
|
|
29
|
+
'导入失败': 'toast.importFailed',
|
|
30
|
+
'导入成功': 'toast.importSuccess',
|
|
31
|
+
'导入 skill 失败': 'toast.importSkillFailed',
|
|
32
|
+
'导出失败': 'toast.exportFailed',
|
|
33
|
+
'保存失败': 'toast.saveFailed',
|
|
34
|
+
'加载文件失败': 'toast.loadFileFailed',
|
|
35
|
+
'请填写名称': 'toast.nameRequired',
|
|
36
|
+
'请输入名称': 'toast.nameRequired',
|
|
37
|
+
'名称已存在': 'toast.nameExists',
|
|
38
|
+
'至少保留一项': 'toast.keepOneItem',
|
|
39
|
+
'请输入模型': 'toast.modelRequired',
|
|
40
|
+
'请选择提供商和模型': 'toast.providerModelRequired',
|
|
41
|
+
'请先配置 API Key': 'toast.apiKeyRequired',
|
|
42
|
+
'配置已存在': 'toast.configExists',
|
|
43
|
+
'不支持此操作': 'toast.unsupportedOperation',
|
|
44
|
+
'参数无效': 'toast.invalidParams',
|
|
45
|
+
'不可分享': 'toast.notShareable',
|
|
46
|
+
'已移入回收站': 'toast.movedToTrash',
|
|
47
|
+
'生成命令失败': 'toast.commandGenerationFailed',
|
|
48
|
+
'没有可复制内容': 'toast.nothingToCopy',
|
|
49
|
+
'没有可导出内容': 'toast.nothingToExport',
|
|
50
|
+
'会话已恢复': 'toast.sessionRestored',
|
|
51
|
+
'恢复失败': 'toast.restoreFailed',
|
|
52
|
+
'已彻底删除': 'toast.purged',
|
|
53
|
+
'彻底删除失败': 'toast.purgeFailed',
|
|
54
|
+
'回收站已清空': 'toast.trashCleared',
|
|
55
|
+
'清空回收站失败': 'toast.trashClearFailed',
|
|
56
|
+
'加载回收站失败': 'toast.trashLoadFailed',
|
|
57
|
+
'加载回收站数量失败': 'toast.trashCountLoadFailed',
|
|
58
|
+
'任务计划已更新': 'toast.taskPlanUpdated',
|
|
59
|
+
'任务计划生成失败': 'toast.taskPlanFailed',
|
|
60
|
+
'计划存在问题,请先修复再执行': 'toast.taskPlanHasIssues',
|
|
61
|
+
'已发出取消请求': 'toast.cancelRequested',
|
|
62
|
+
'取消任务失败': 'toast.cancelTaskFailed'
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const UI_MESSAGE_PREFIX_ENTRIES = Object.freeze(
|
|
66
|
+
Object.entries(UI_MESSAGE_KEY_BY_TEXT).sort((a, b) => b[0].length - a[0].length)
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
function translateUiMessage(context, text) {
|
|
70
|
+
if (!context || typeof context.t !== 'function' || typeof text !== 'string') return text;
|
|
71
|
+
const exactKey = UI_MESSAGE_KEY_BY_TEXT[text];
|
|
72
|
+
if (exactKey) return context.t(exactKey);
|
|
73
|
+
const prefixEntry = UI_MESSAGE_PREFIX_ENTRIES.find(([sourceText]) => {
|
|
74
|
+
return text.length > sourceText.length && text.startsWith(sourceText);
|
|
75
|
+
});
|
|
76
|
+
if (!prefixEntry) return text;
|
|
77
|
+
const [sourceText, key] = prefixEntry;
|
|
78
|
+
return `${context.t(key)}${text.slice(sourceText.length)}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
6
81
|
function clearProgressResetTimer(context, timerKey) {
|
|
7
82
|
if (!context || !timerKey || !context[timerKey]) {
|
|
8
83
|
return;
|
|
@@ -334,7 +409,7 @@ export function createRuntimeMethods(options = {}) {
|
|
|
334
409
|
if (this._messageTimer) {
|
|
335
410
|
clearTimeout(this._messageTimer);
|
|
336
411
|
}
|
|
337
|
-
this.message = text;
|
|
412
|
+
this.message = translateUiMessage(this, text);
|
|
338
413
|
this.messageType = type || 'info';
|
|
339
414
|
this._messageTimer = setTimeout(() => {
|
|
340
415
|
this.message = '';
|
|
@@ -35,16 +35,16 @@ export function createConfigModeComputed() {
|
|
|
35
35
|
return this.activeProviderModeMeta.modelPlaceholder;
|
|
36
36
|
},
|
|
37
37
|
activeProviderConfigChipLabel() {
|
|
38
|
-
return this.
|
|
38
|
+
return this.t('field.provider');
|
|
39
39
|
},
|
|
40
40
|
activeProviderModelChipLabel() {
|
|
41
|
-
return this.
|
|
41
|
+
return this.t('field.model');
|
|
42
42
|
},
|
|
43
43
|
activeProviderBridgeHint() {
|
|
44
44
|
if (!this.isProviderConfigMode || this.isCodexConfigMode) {
|
|
45
45
|
return '';
|
|
46
46
|
}
|
|
47
|
-
return
|
|
47
|
+
return this.t('config.providerBridgeHint', { label: this.activeProviderModeLabel });
|
|
48
48
|
},
|
|
49
49
|
inspectorMainTabLabel() {
|
|
50
50
|
if (this.mainTab === 'dashboard') return '概览';
|
|
@@ -154,6 +154,7 @@ const DICT = Object.freeze({
|
|
|
154
154
|
'side.sessions.browser.meta': '浏览 / 导出 / 清理',
|
|
155
155
|
'side.plugins.tools': '提示词工具',
|
|
156
156
|
'side.plugins.tools.meta': '模板 / 变量',
|
|
157
|
+
'side.plugins.templatesCount': '{count} 个模板',
|
|
157
158
|
'side.system.settings': '运行设置',
|
|
158
159
|
'side.system.settings.meta': '数据 / 备份',
|
|
159
160
|
|
|
@@ -912,6 +913,7 @@ const DICT = Object.freeze({
|
|
|
912
913
|
'settings.tab.data': '数据',
|
|
913
914
|
'settings.tabs.aria': '设置分类',
|
|
914
915
|
'settings.quickSettings.title': '快捷设置',
|
|
916
|
+
'settings.language.sideLabel': '语言:{language}',
|
|
915
917
|
'settings.sharePrefix.title': '分享命令前缀',
|
|
916
918
|
'settings.sharePrefix.meta': '影响 Web UI 里“复制分享命令”的前缀',
|
|
917
919
|
'settings.sharePrefix.label': '前缀',
|
|
@@ -1052,6 +1054,8 @@ const DICT = Object.freeze({
|
|
|
1052
1054
|
|
|
1053
1055
|
// OpenClaw config panel
|
|
1054
1056
|
'openclaw.applyHint': '写入 ~/.openclaw/openclaw.json,支持 JSON5。',
|
|
1057
|
+
'openclaw.workspace.title': 'OpenClaw 工作区',
|
|
1058
|
+
'openclaw.configs.hint': '选择常用配置,或进入编辑器维护完整 JSON5。',
|
|
1055
1059
|
'openclaw.agents.hint': '读写 Workspace 的 AGENTS.md,默认路径 ~/.openclaw/workspace/AGENTS.md。',
|
|
1056
1060
|
'openclaw.agents.open': '打开 AGENTS.md',
|
|
1057
1061
|
'openclaw.workspaceFile': '工作区文件',
|
|
@@ -1065,6 +1069,7 @@ const DICT = Object.freeze({
|
|
|
1065
1069
|
'modal.openclaw.quick.subtitle': '按 3 步完成:填 Provider 和模型,写入编辑器,保存并应用。',
|
|
1066
1070
|
'modal.openclaw.quick.step2': '点击写入编辑器',
|
|
1067
1071
|
'modal.openclaw.structured.writeHint': '写入编辑器会重排 JSON,注释可能丢失。',
|
|
1072
|
+
'openclaw.action.applyAria': '应用 OpenClaw 配置:{name}',
|
|
1068
1073
|
'openclaw.action.editAria': '编辑 OpenClaw 配置:{name}',
|
|
1069
1074
|
'openclaw.action.deleteAria': '删除 OpenClaw 配置:{name}'
|
|
1070
1075
|
},
|
|
@@ -1224,6 +1229,7 @@ const DICT = Object.freeze({
|
|
|
1224
1229
|
'side.sessions.browser.meta': '閲覧 / エクスポート / クリーンアップ',
|
|
1225
1230
|
'side.plugins.tools': 'プロンプトツール',
|
|
1226
1231
|
'side.plugins.tools.meta': 'テンプレート / 変数',
|
|
1232
|
+
'side.plugins.templatesCount': '{count} 件のテンプレート',
|
|
1227
1233
|
'side.system.settings': '実行設定',
|
|
1228
1234
|
'side.system.settings.meta': 'データ / バックアップ',
|
|
1229
1235
|
|
|
@@ -1970,6 +1976,7 @@ const DICT = Object.freeze({
|
|
|
1970
1976
|
'settings.tab.data': 'データ',
|
|
1971
1977
|
'settings.tabs.aria': '設定カテゴリ',
|
|
1972
1978
|
'settings.quickSettings.title': 'クイック設定',
|
|
1979
|
+
'settings.language.sideLabel': '言語:{language}',
|
|
1973
1980
|
'settings.sharePrefix.title': '共有コマンドプレフィックス',
|
|
1974
1981
|
'settings.sharePrefix.meta': 'Web UI の「共有コマンドをコピー」のプレフィックスに影響',
|
|
1975
1982
|
'settings.sharePrefix.label': 'プレフィックス',
|
|
@@ -2123,6 +2130,7 @@ const DICT = Object.freeze({
|
|
|
2123
2130
|
'modal.openclaw.quick.subtitle': '3ステップで完了:Provider とモデルを入力、エディタに書き込み、保存して適用。',
|
|
2124
2131
|
'modal.openclaw.quick.step2': 'エディタに書き込みをクリック',
|
|
2125
2132
|
'modal.openclaw.structured.writeHint': 'エディタに書き込むと JSON が再配置され、コメントが失われる可能性があります。',
|
|
2133
|
+
'openclaw.action.applyAria': 'OpenClaw 設定を適用:{name}',
|
|
2126
2134
|
'openclaw.action.editAria': 'OpenClaw 設定を編集:{name}',
|
|
2127
2135
|
'openclaw.action.deleteAria': 'OpenClaw 設定を削除:{name}',
|
|
2128
2136
|
|
|
@@ -2283,6 +2291,7 @@ const DICT = Object.freeze({
|
|
|
2283
2291
|
'side.sessions.browser.meta': 'Browse / Export / Cleanup',
|
|
2284
2292
|
'side.plugins.tools': 'Prompt Tools',
|
|
2285
2293
|
'side.plugins.tools.meta': 'Templates / Variables',
|
|
2294
|
+
'side.plugins.templatesCount': '{count} templates',
|
|
2286
2295
|
'side.system.settings': 'Runtime Settings',
|
|
2287
2296
|
'side.system.settings.meta': 'Data / Backup',
|
|
2288
2297
|
|
|
@@ -3042,6 +3051,7 @@ const DICT = Object.freeze({
|
|
|
3042
3051
|
'settings.tab.data': 'Data',
|
|
3043
3052
|
'settings.tabs.aria': 'Settings categories',
|
|
3044
3053
|
'settings.quickSettings.title': 'Quick Settings',
|
|
3054
|
+
'settings.language.sideLabel': 'Language: {language}',
|
|
3045
3055
|
'settings.sharePrefix.title': 'Share command prefix',
|
|
3046
3056
|
'settings.sharePrefix.meta': 'Used as the prefix for “Copy share command” in the Web UI',
|
|
3047
3057
|
'settings.sharePrefix.label': 'Prefix',
|
|
@@ -3178,6 +3188,8 @@ const DICT = Object.freeze({
|
|
|
3178
3188
|
|
|
3179
3189
|
// OpenClaw config panel
|
|
3180
3190
|
'openclaw.applyHint': 'Writes to ~/.openclaw/openclaw.json (JSON5 supported).',
|
|
3191
|
+
'openclaw.workspace.title': 'OpenClaw workspace',
|
|
3192
|
+
'openclaw.configs.hint': 'Select a saved config, or open the editor to maintain full JSON5.',
|
|
3181
3193
|
'openclaw.agents.hint': 'Read/write Workspace AGENTS.md. Default: ~/.openclaw/workspace/AGENTS.md.',
|
|
3182
3194
|
'openclaw.agents.open': 'Open AGENTS.md',
|
|
3183
3195
|
'openclaw.workspaceFile': 'Workspace file',
|
|
@@ -3191,6 +3203,7 @@ const DICT = Object.freeze({
|
|
|
3191
3203
|
'modal.openclaw.quick.subtitle': '3 steps: fill provider/model, write to editor, save & apply.',
|
|
3192
3204
|
'modal.openclaw.quick.step2': 'Write to editor',
|
|
3193
3205
|
'modal.openclaw.structured.writeHint': 'Writing to editor may reformat JSON and drop comments.',
|
|
3206
|
+
'openclaw.action.applyAria': 'Apply OpenClaw config: {name}',
|
|
3194
3207
|
'openclaw.action.editAria': 'Edit OpenClaw config: {name}',
|
|
3195
3208
|
'openclaw.action.deleteAria': 'Delete OpenClaw config: {name}'
|
|
3196
3209
|
}
|