codexmate 0.0.41 → 0.0.43
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.md +168 -168
- package/README.zh.md +168 -168
- package/cli/agents-files.js +230 -230
- package/cli/analytics-export-args.js +68 -68
- package/cli/archive-helpers.js +453 -453
- package/cli/auth-profiles.js +375 -375
- package/cli/builtin-proxy.js +2144 -2144
- package/cli/claude-proxy.js +1022 -1022
- package/cli/config-bootstrap.js +407 -407
- package/cli/config-health.js +454 -454
- package/cli/doctor-core.js +903 -903
- package/cli/import-skills-url.js +356 -356
- package/cli/local-bridge.js +556 -556
- package/cli/openai-bridge.js +1984 -1984
- package/cli/openclaw-config.js +629 -629
- package/cli/session-convert-args.js +69 -69
- package/cli/session-convert-io.js +82 -82
- package/cli/session-convert.js +150 -150
- package/cli/session-usage.concurrent.js +28 -28
- package/cli/session-usage.js +304 -304
- package/cli/session-usage.models.js +176 -176
- package/cli/skills.js +1141 -1141
- package/cli/update.js +171 -171
- package/cli/zip-commands.js +510 -510
- package/cli.js +16495 -16458
- package/lib/automation.js +404 -404
- package/lib/cli-file-utils.js +151 -151
- package/lib/cli-models-utils.js +440 -440
- package/lib/cli-network-utils.js +190 -190
- package/lib/cli-path-utils.js +85 -85
- package/lib/cli-session-utils.js +121 -121
- package/lib/cli-sessions.js +427 -427
- package/lib/cli-utils.js +155 -155
- package/lib/cli-webhook.js +154 -154
- package/lib/download-artifacts.js +92 -92
- package/lib/mcp-stdio.js +453 -453
- package/lib/task-orchestrator.js +869 -869
- package/lib/text-diff.js +303 -303
- package/lib/win-tray.js +119 -119
- package/lib/workflow-engine.js +340 -340
- package/package.json +77 -77
- package/plugins/README.md +20 -20
- package/plugins/README.zh-CN.md +20 -20
- package/plugins/prompt-templates/comment-polish/index.mjs +25 -25
- package/plugins/prompt-templates/computed.mjs +311 -311
- package/plugins/prompt-templates/index.mjs +8 -8
- package/plugins/prompt-templates/manifest.mjs +18 -18
- package/plugins/prompt-templates/methods.mjs +553 -553
- package/plugins/prompt-templates/overview.mjs +91 -91
- package/plugins/prompt-templates/ownership.mjs +19 -19
- package/plugins/prompt-templates/rule-ack/index.mjs +21 -21
- package/plugins/prompt-templates/storage.mjs +64 -64
- package/plugins/registry.mjs +16 -16
- package/web-ui/app.js +705 -695
- package/web-ui/index.html +37 -37
- package/web-ui/logic.agents-diff.mjs +386 -386
- package/web-ui/logic.claude.mjs +172 -172
- package/web-ui/logic.codex.mjs +69 -69
- package/web-ui/logic.mjs +5 -5
- package/web-ui/logic.runtime.mjs +128 -128
- package/web-ui/logic.session-convert.mjs +70 -70
- package/web-ui/logic.sessions.mjs +782 -782
- package/web-ui/modules/api.mjs +90 -90
- package/web-ui/modules/app.computed.dashboard.mjs +252 -252
- package/web-ui/modules/app.computed.index.mjs +17 -17
- package/web-ui/modules/app.computed.main-tabs.mjs +214 -214
- package/web-ui/modules/app.computed.session.mjs +876 -876
- package/web-ui/modules/app.constants.mjs +15 -15
- package/web-ui/modules/app.methods.agents.mjs +651 -651
- package/web-ui/modules/app.methods.claude-config.mjs +412 -412
- package/web-ui/modules/app.methods.codex-config.mjs +869 -869
- package/web-ui/modules/app.methods.index.mjs +96 -96
- package/web-ui/modules/app.methods.install.mjs +205 -205
- package/web-ui/modules/app.methods.navigation.mjs +804 -804
- package/web-ui/modules/app.methods.openclaw-core.mjs +814 -814
- package/web-ui/modules/app.methods.openclaw-editing.mjs +420 -420
- package/web-ui/modules/app.methods.openclaw-persist.mjs +375 -375
- package/web-ui/modules/app.methods.providers.mjs +602 -601
- package/web-ui/modules/app.methods.runtime.mjs +426 -420
- package/web-ui/modules/app.methods.session-actions.mjs +617 -591
- package/web-ui/modules/app.methods.session-browser.mjs +1018 -1018
- package/web-ui/modules/app.methods.session-timeline.mjs +479 -479
- package/web-ui/modules/app.methods.session-trash.mjs +468 -468
- package/web-ui/modules/app.methods.startup-claude.mjs +557 -554
- package/web-ui/modules/app.methods.task-orchestration.mjs +556 -556
- package/web-ui/modules/app.methods.tool-config-permissions.mjs +90 -87
- package/web-ui/modules/app.methods.webhook.mjs +87 -87
- package/web-ui/modules/config-mode.computed.mjs +124 -124
- package/web-ui/modules/config-template-confirm-pref.mjs +33 -33
- package/web-ui/modules/i18n/locales/en.mjs +1187 -1140
- package/web-ui/modules/i18n/locales/ja.mjs +1178 -1130
- package/web-ui/modules/i18n/locales/vi.mjs +294 -239
- package/web-ui/modules/i18n/locales/zh.mjs +1190 -1143
- package/web-ui/modules/i18n.dict.mjs +14 -14
- package/web-ui/modules/i18n.mjs +111 -111
- package/web-ui/modules/plugins.computed.mjs +3 -3
- package/web-ui/modules/plugins.methods.mjs +3 -3
- package/web-ui/modules/plugins.storage.mjs +11 -11
- package/web-ui/modules/provider-url-display.mjs +17 -17
- package/web-ui/modules/sessions-filters-url.mjs +138 -138
- package/web-ui/modules/skills.computed.mjs +107 -107
- package/web-ui/modules/skills.methods.mjs +513 -513
- package/web-ui/partials/index/layout-footer.html +13 -13
- package/web-ui/partials/index/layout-header.html +478 -478
- package/web-ui/partials/index/modal-config-template-agents.html +185 -185
- package/web-ui/partials/index/modal-confirm-toast.html +32 -32
- package/web-ui/partials/index/modal-health-check.html +45 -45
- package/web-ui/partials/index/modal-openclaw-config.html +344 -344
- package/web-ui/partials/index/modal-skills.html +200 -200
- package/web-ui/partials/index/modal-webhook.html +42 -42
- package/web-ui/partials/index/modals-basic.html +263 -263
- package/web-ui/partials/index/panel-config-claude.html +187 -187
- package/web-ui/partials/index/panel-config-codex.html +205 -205
- package/web-ui/partials/index/panel-config-openclaw.html +89 -89
- package/web-ui/partials/index/panel-dashboard.html +171 -171
- package/web-ui/partials/index/panel-docs.html +114 -114
- package/web-ui/partials/index/panel-market.html +104 -104
- package/web-ui/partials/index/panel-orchestration.html +391 -391
- package/web-ui/partials/index/panel-plugins.html +253 -253
- package/web-ui/partials/index/panel-sessions.html +325 -319
- package/web-ui/partials/index/panel-settings.html +181 -181
- package/web-ui/partials/index/panel-trash.html +82 -82
- package/web-ui/partials/index/panel-usage.html +181 -181
- package/web-ui/res/json5.min.js +1 -1
- package/web-ui/res/vue.global.prod.js +13 -13
- package/web-ui/res/vue.runtime.global.prod.js +7 -7
- package/web-ui/res/web-ui-render.precompiled.js +7671 -7666
- package/web-ui/session-helpers.mjs +602 -602
- package/web-ui/source-bundle.cjs +305 -305
- package/web-ui/styles/base-theme.css +291 -291
- package/web-ui/styles/bridge-pool.css +266 -266
- package/web-ui/styles/controls-forms.css +532 -532
- package/web-ui/styles/dashboard.css +438 -438
- package/web-ui/styles/docs-panel.css +245 -245
- package/web-ui/styles/feedback.css +108 -108
- package/web-ui/styles/health-check-dialog.css +144 -144
- package/web-ui/styles/layout-shell.css +711 -711
- package/web-ui/styles/modals-core.css +499 -499
- package/web-ui/styles/navigation-panels.css +399 -399
- package/web-ui/styles/openclaw-structured.css +616 -616
- package/web-ui/styles/plugins-panel.css +564 -564
- package/web-ui/styles/responsive.css +501 -501
- package/web-ui/styles/sessions-list.css +683 -683
- package/web-ui/styles/sessions-preview.css +407 -407
- package/web-ui/styles/sessions-toolbar-trash.css +518 -518
- package/web-ui/styles/sessions-usage.css +849 -849
- package/web-ui/styles/settings-panel.css +419 -419
- package/web-ui/styles/skills-list.css +305 -305
- package/web-ui/styles/skills-market.css +723 -723
- package/web-ui/styles/task-orchestration.css +822 -822
- package/web-ui/styles/titles-cards.css +492 -486
- package/web-ui/styles/trash-panel.css +90 -90
- package/web-ui/styles/webhook.css +115 -115
- package/web-ui/styles.css +24 -24
- package/web-ui.html +17 -17
|
@@ -1,420 +1,426 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildSpeedTestIssue,
|
|
3
|
-
formatLatency
|
|
4
|
-
} from '../logic.mjs';
|
|
5
|
-
|
|
6
|
-
const UI_MESSAGE_KEY_BY_TEXT = Object.freeze({
|
|
7
|
-
'操作成功': 'toast.
|
|
8
|
-
'操作失败': 'toast.
|
|
9
|
-
'添加失败': 'toast.
|
|
10
|
-
'更新失败': 'toast.
|
|
11
|
-
'删除失败': 'toast.
|
|
12
|
-
'已删除': 'toast.
|
|
13
|
-
'已复制': 'toast.
|
|
14
|
-
'复制失败': 'toast.
|
|
15
|
-
'剪贴板为空': 'toast.clipboardEmpty',
|
|
16
|
-
'无法读取剪贴板': 'toast.clipboardReadFailed',
|
|
17
|
-
'已粘贴': 'toast.pasted',
|
|
18
|
-
'未检测到改动': 'toast.noChanges',
|
|
19
|
-
'配置已应用': 'toast.
|
|
20
|
-
'应用配置失败': 'toast.
|
|
21
|
-
'应用失败': 'toast.
|
|
22
|
-
'配置已加载': 'toast.configLoaded',
|
|
23
|
-
'配置就绪': 'toast.configReady',
|
|
24
|
-
'加载配置失败': 'toast.loadConfigFailed',
|
|
25
|
-
'读取配置失败': 'toast.readConfigFailed',
|
|
26
|
-
'读取配置超时': 'toast.readConfigTimeout',
|
|
27
|
-
'备份失败': 'toast.backupFailed',
|
|
28
|
-
'备份成功,开始下载': 'toast.backupReadyDownload',
|
|
29
|
-
'导入失败': 'toast.
|
|
30
|
-
'导入成功': 'toast.
|
|
31
|
-
'导入 skill 失败': 'toast.importSkillFailed',
|
|
32
|
-
'导出失败': 'toast.
|
|
33
|
-
'保存失败': 'toast.
|
|
34
|
-
'加载文件失败': 'toast.
|
|
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.
|
|
49
|
-
'没有可导出内容': 'toast.
|
|
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
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
const [sourceText
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (
|
|
203
|
-
this.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
this.
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if (
|
|
244
|
-
this.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
this.
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
this._messageTimer
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
1
|
+
import {
|
|
2
|
+
buildSpeedTestIssue,
|
|
3
|
+
formatLatency
|
|
4
|
+
} from '../logic.mjs';
|
|
5
|
+
|
|
6
|
+
const UI_MESSAGE_KEY_BY_TEXT = Object.freeze({
|
|
7
|
+
'操作成功': 'toast.operation.success',
|
|
8
|
+
'操作失败': 'toast.operation.fail',
|
|
9
|
+
'添加失败': 'toast.provider.addFail',
|
|
10
|
+
'更新失败': 'toast.provider.updateFail',
|
|
11
|
+
'删除失败': 'toast.delete.fail',
|
|
12
|
+
'已删除': 'toast.delete.ok',
|
|
13
|
+
'已复制': 'toast.copy.ok',
|
|
14
|
+
'复制失败': 'toast.copy.fail',
|
|
15
|
+
'剪贴板为空': 'toast.clipboardEmpty',
|
|
16
|
+
'无法读取剪贴板': 'toast.clipboardReadFailed',
|
|
17
|
+
'已粘贴': 'toast.pasted',
|
|
18
|
+
'未检测到改动': 'toast.noChanges',
|
|
19
|
+
'配置已应用': 'toast.apply.success',
|
|
20
|
+
'应用配置失败': 'toast.apply.fail',
|
|
21
|
+
'应用失败': 'toast.apply.fail',
|
|
22
|
+
'配置已加载': 'toast.configLoaded',
|
|
23
|
+
'配置就绪': 'toast.configReady',
|
|
24
|
+
'加载配置失败': 'toast.loadConfigFailed',
|
|
25
|
+
'读取配置失败': 'toast.readConfigFailed',
|
|
26
|
+
'读取配置超时': 'toast.readConfigTimeout',
|
|
27
|
+
'备份失败': 'toast.backupFailed',
|
|
28
|
+
'备份成功,开始下载': 'toast.backupReadyDownload',
|
|
29
|
+
'导入失败': 'toast.import.fail',
|
|
30
|
+
'导入成功': 'toast.import.ok',
|
|
31
|
+
'导入 skill 失败': 'toast.importSkillFailed',
|
|
32
|
+
'导出失败': 'toast.export.fail',
|
|
33
|
+
'保存失败': 'toast.save.fail',
|
|
34
|
+
'加载文件失败': 'toast.load.fail',
|
|
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.copy.empty',
|
|
49
|
+
'没有可导出内容': 'toast.export.empty',
|
|
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
|
+
export function translateUiMessage(context, text) {
|
|
70
|
+
if (!context || typeof context.t !== 'function' || typeof text !== 'string') return text;
|
|
71
|
+
const translateKey = (key) => {
|
|
72
|
+
const translated = context.t(key);
|
|
73
|
+
return typeof translated === 'string' && translated && translated !== key ? translated : '';
|
|
74
|
+
};
|
|
75
|
+
const exactKey = UI_MESSAGE_KEY_BY_TEXT[text];
|
|
76
|
+
if (exactKey) return translateKey(exactKey) || text;
|
|
77
|
+
const prefixEntry = UI_MESSAGE_PREFIX_ENTRIES.find(([sourceText]) => {
|
|
78
|
+
return text.length > sourceText.length && text.startsWith(sourceText);
|
|
79
|
+
});
|
|
80
|
+
if (!prefixEntry) return text;
|
|
81
|
+
const [sourceText, key] = prefixEntry;
|
|
82
|
+
const translatedPrefix = translateKey(key);
|
|
83
|
+
if (!translatedPrefix) return text;
|
|
84
|
+
return `${translatedPrefix}${text.slice(sourceText.length)}`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function clearProgressResetTimer(context, timerKey) {
|
|
88
|
+
if (!context || !timerKey || !context[timerKey]) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
clearTimeout(context[timerKey]);
|
|
92
|
+
context[timerKey] = null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function scheduleProgressResetTimer(context, timerKey, progressKey, delayMs = 800) {
|
|
96
|
+
if (!context || !timerKey || !progressKey) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
clearProgressResetTimer(context, timerKey);
|
|
100
|
+
context[timerKey] = setTimeout(() => {
|
|
101
|
+
context[progressKey] = 0;
|
|
102
|
+
context[timerKey] = null;
|
|
103
|
+
}, delayMs);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function createRuntimeMethods(options = {}) {
|
|
107
|
+
const { api } = options;
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
formatLatency,
|
|
111
|
+
|
|
112
|
+
buildSpeedTestIssue(name, result) {
|
|
113
|
+
return buildSpeedTestIssue(name, result);
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
async runSpeedTest(name, options = {}) {
|
|
117
|
+
if (!name || this.speedLoading[name]) return null;
|
|
118
|
+
const silent = !!options.silent;
|
|
119
|
+
this.speedLoading[name] = true;
|
|
120
|
+
try {
|
|
121
|
+
const timeoutMs = Number.isFinite(options.timeoutMs) ? Math.max(1000, Number(options.timeoutMs)) : 0;
|
|
122
|
+
const payload = { name };
|
|
123
|
+
if (timeoutMs) {
|
|
124
|
+
payload.timeoutMs = timeoutMs;
|
|
125
|
+
}
|
|
126
|
+
const res = await api('speed-test', payload);
|
|
127
|
+
if (res.error) {
|
|
128
|
+
this.speedResults[name] = { ok: false, error: res.error };
|
|
129
|
+
if (!silent) {
|
|
130
|
+
this.showMessage(res.error, 'error');
|
|
131
|
+
}
|
|
132
|
+
return { ok: false, error: res.error };
|
|
133
|
+
}
|
|
134
|
+
this.speedResults[name] = res;
|
|
135
|
+
if (!silent) {
|
|
136
|
+
const status = res.status ? ` (${res.status})` : '';
|
|
137
|
+
this.showMessage(`Speed ${name}: ${this.formatLatency(res)}${status}`, 'success');
|
|
138
|
+
}
|
|
139
|
+
return res;
|
|
140
|
+
} catch (e) {
|
|
141
|
+
const message = e && e.message ? e.message : 'Speed test failed';
|
|
142
|
+
this.speedResults[name] = { ok: false, error: message };
|
|
143
|
+
if (!silent) {
|
|
144
|
+
this.showMessage(message, 'error');
|
|
145
|
+
}
|
|
146
|
+
return { ok: false, error: message };
|
|
147
|
+
} finally {
|
|
148
|
+
this.speedLoading[name] = false;
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
async runClaudeSpeedTest(name, config) {
|
|
153
|
+
if (!name || this.claudeSpeedLoading[name]) return null;
|
|
154
|
+
const baseUrl = config && typeof config.baseUrl === 'string' ? config.baseUrl.trim() : '';
|
|
155
|
+
const apiKey = config && typeof config.apiKey === 'string' ? config.apiKey.trim() : '';
|
|
156
|
+
const model = config && typeof config.model === 'string' ? config.model.trim() : '';
|
|
157
|
+
this.claudeSpeedLoading[name] = true;
|
|
158
|
+
try {
|
|
159
|
+
if (!baseUrl) {
|
|
160
|
+
const res = { ok: false, error: 'Missing base URL' };
|
|
161
|
+
this.claudeSpeedResults[name] = res;
|
|
162
|
+
return res;
|
|
163
|
+
}
|
|
164
|
+
if (!apiKey) {
|
|
165
|
+
const res = { ok: false, error: 'Missing API key' };
|
|
166
|
+
this.claudeSpeedResults[name] = res;
|
|
167
|
+
return res;
|
|
168
|
+
}
|
|
169
|
+
if (!model) {
|
|
170
|
+
const res = { ok: false, error: 'Missing model' };
|
|
171
|
+
this.claudeSpeedResults[name] = res;
|
|
172
|
+
return res;
|
|
173
|
+
}
|
|
174
|
+
const res = await api('speed-test', {
|
|
175
|
+
kind: 'claude',
|
|
176
|
+
url: baseUrl,
|
|
177
|
+
apiKey,
|
|
178
|
+
model
|
|
179
|
+
});
|
|
180
|
+
if (res.error) {
|
|
181
|
+
this.claudeSpeedResults[name] = { ok: false, error: res.error };
|
|
182
|
+
return { ok: false, error: res.error };
|
|
183
|
+
}
|
|
184
|
+
this.claudeSpeedResults[name] = res;
|
|
185
|
+
return res;
|
|
186
|
+
} catch (e) {
|
|
187
|
+
const message = e && e.message ? e.message : 'Speed test failed';
|
|
188
|
+
const res = { ok: false, error: message };
|
|
189
|
+
this.claudeSpeedResults[name] = res;
|
|
190
|
+
return res;
|
|
191
|
+
} finally {
|
|
192
|
+
this.claudeSpeedLoading[name] = false;
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
async downloadClaudeDirectory() {
|
|
197
|
+
if (this.claudeDownloadLoading) return;
|
|
198
|
+
clearProgressResetTimer(this, '__claudeDownloadResetTimer');
|
|
199
|
+
this.claudeDownloadLoading = true;
|
|
200
|
+
this.claudeDownloadProgress = 5;
|
|
201
|
+
this.claudeDownloadTimer = setInterval(() => {
|
|
202
|
+
if (this.claudeDownloadProgress < 90) {
|
|
203
|
+
this.claudeDownloadProgress += 5;
|
|
204
|
+
}
|
|
205
|
+
}, 400);
|
|
206
|
+
try {
|
|
207
|
+
const res = await api('download-claude-dir');
|
|
208
|
+
if (res && res.error) {
|
|
209
|
+
this.showMessage(res.error, 'error');
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (!res || res.success !== true || !res.fileName) {
|
|
213
|
+
this.showMessage('备份失败', 'error');
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
this.claudeDownloadProgress = 100;
|
|
217
|
+
const downloadUrl = `/download/${encodeURIComponent(res.fileName)}`;
|
|
218
|
+
const link = document.createElement('a');
|
|
219
|
+
link.href = downloadUrl;
|
|
220
|
+
link.download = res.fileName;
|
|
221
|
+
document.body.appendChild(link);
|
|
222
|
+
link.click();
|
|
223
|
+
document.body.removeChild(link);
|
|
224
|
+
this.showMessage('备份成功,开始下载', 'success');
|
|
225
|
+
} catch (e) {
|
|
226
|
+
this.showMessage('备份失败:' + (e && e.message ? e.message : '未知错误'), 'error');
|
|
227
|
+
} finally {
|
|
228
|
+
if (this.claudeDownloadTimer) {
|
|
229
|
+
clearInterval(this.claudeDownloadTimer);
|
|
230
|
+
this.claudeDownloadTimer = null;
|
|
231
|
+
}
|
|
232
|
+
this.claudeDownloadLoading = false;
|
|
233
|
+
scheduleProgressResetTimer(this, '__claudeDownloadResetTimer', 'claudeDownloadProgress');
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
async downloadCodexDirectory() {
|
|
238
|
+
if (this.codexDownloadLoading) return;
|
|
239
|
+
clearProgressResetTimer(this, '__codexDownloadResetTimer');
|
|
240
|
+
this.codexDownloadLoading = true;
|
|
241
|
+
this.codexDownloadProgress = 5;
|
|
242
|
+
this.codexDownloadTimer = setInterval(() => {
|
|
243
|
+
if (this.codexDownloadProgress < 90) {
|
|
244
|
+
this.codexDownloadProgress += 5;
|
|
245
|
+
}
|
|
246
|
+
}, 400);
|
|
247
|
+
try {
|
|
248
|
+
const res = await api('download-codex-dir');
|
|
249
|
+
if (res && res.error) {
|
|
250
|
+
this.showMessage(res.error, 'error');
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (!res || res.success !== true || !res.fileName) {
|
|
254
|
+
this.showMessage('备份失败', 'error');
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
this.codexDownloadProgress = 100;
|
|
258
|
+
const downloadUrl = `/download/${encodeURIComponent(res.fileName)}`;
|
|
259
|
+
const link = document.createElement('a');
|
|
260
|
+
link.href = downloadUrl;
|
|
261
|
+
link.download = res.fileName;
|
|
262
|
+
document.body.appendChild(link);
|
|
263
|
+
link.click();
|
|
264
|
+
document.body.removeChild(link);
|
|
265
|
+
this.showMessage('备份成功,开始下载', 'success');
|
|
266
|
+
} catch (e) {
|
|
267
|
+
this.showMessage('备份失败:' + (e && e.message ? e.message : '未知错误'), 'error');
|
|
268
|
+
} finally {
|
|
269
|
+
if (this.codexDownloadTimer) {
|
|
270
|
+
clearInterval(this.codexDownloadTimer);
|
|
271
|
+
this.codexDownloadTimer = null;
|
|
272
|
+
}
|
|
273
|
+
this.codexDownloadLoading = false;
|
|
274
|
+
scheduleProgressResetTimer(this, '__codexDownloadResetTimer', 'codexDownloadProgress');
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
triggerClaudeImport() {
|
|
279
|
+
const input = this.$refs.claudeImportInput;
|
|
280
|
+
if (input) {
|
|
281
|
+
input.value = '';
|
|
282
|
+
input.click();
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
triggerCodexImport() {
|
|
287
|
+
const input = this.$refs.codexImportInput;
|
|
288
|
+
if (input) {
|
|
289
|
+
input.value = '';
|
|
290
|
+
input.click();
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
|
|
294
|
+
handleClaudeImportChange(event) {
|
|
295
|
+
const file = event && event.target && event.target.files ? event.target.files[0] : null;
|
|
296
|
+
if (file) {
|
|
297
|
+
void this.importBackupFile('claude', file);
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
handleCodexImportChange(event) {
|
|
302
|
+
const file = event && event.target && event.target.files ? event.target.files[0] : null;
|
|
303
|
+
if (file) {
|
|
304
|
+
void this.importBackupFile('codex', file);
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
async importBackupFile(type, file) {
|
|
309
|
+
const maxSize = 200 * 1024 * 1024;
|
|
310
|
+
const loadingKey = type === 'claude' ? 'claudeImportLoading' : 'codexImportLoading';
|
|
311
|
+
if (this[loadingKey]) {
|
|
312
|
+
this.resetImportInput(type);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (file.size > maxSize) {
|
|
316
|
+
this.showMessage('备份文件过大,限制 200MB', 'error');
|
|
317
|
+
this.resetImportInput(type);
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
this[loadingKey] = true;
|
|
321
|
+
try {
|
|
322
|
+
const base64 = await this.readFileAsBase64(file);
|
|
323
|
+
const action = type === 'claude' ? 'restore-claude-dir' : 'restore-codex-dir';
|
|
324
|
+
const res = await api(action, {
|
|
325
|
+
fileName: file.name || `${type}-backup.zip`,
|
|
326
|
+
fileBase64: base64
|
|
327
|
+
});
|
|
328
|
+
if (res && res.error) {
|
|
329
|
+
this.showMessage(res.error, 'error');
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const backupTip = res && res.backupPath ? `,原配置已备份到临时文件:${res.backupPath}` : '';
|
|
333
|
+
this.showMessage(`导入成功${backupTip}`, 'success');
|
|
334
|
+
try {
|
|
335
|
+
if (type === 'claude') {
|
|
336
|
+
await this.refreshClaudeSelectionFromSettings({ silent: true });
|
|
337
|
+
} else {
|
|
338
|
+
await this.loadAll();
|
|
339
|
+
}
|
|
340
|
+
} catch (_) {
|
|
341
|
+
this.showMessage('导入已完成,但界面刷新失败,请手动刷新', 'error');
|
|
342
|
+
}
|
|
343
|
+
} catch (e) {
|
|
344
|
+
this.showMessage('导入失败:' + (e && e.message ? e.message : '未知错误'), 'error');
|
|
345
|
+
} finally {
|
|
346
|
+
this[loadingKey] = false;
|
|
347
|
+
this.resetImportInput(type);
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
readFileAsBase64(file) {
|
|
352
|
+
return new Promise((resolve, reject) => {
|
|
353
|
+
const reader = new FileReader();
|
|
354
|
+
reader.onload = () => {
|
|
355
|
+
const result = reader.result;
|
|
356
|
+
if (result instanceof ArrayBuffer) {
|
|
357
|
+
resolve(this.arrayBufferToBase64(result));
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (typeof result === 'string') {
|
|
361
|
+
const idx = result.indexOf('base64,');
|
|
362
|
+
resolve(idx >= 0 ? result.slice(idx + 7) : result);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
reject(new Error('不支持的文件读取结果'));
|
|
366
|
+
};
|
|
367
|
+
reader.onerror = () => reject(new Error('读取文件失败'));
|
|
368
|
+
reader.readAsArrayBuffer(file);
|
|
369
|
+
});
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
arrayBufferToBase64(buffer) {
|
|
373
|
+
const bytes = new Uint8Array(buffer);
|
|
374
|
+
const chunkSize = 0x8000;
|
|
375
|
+
let binary = '';
|
|
376
|
+
for (let i = 0; i < bytes.byteLength; i += chunkSize) {
|
|
377
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize));
|
|
378
|
+
}
|
|
379
|
+
return btoa(binary);
|
|
380
|
+
},
|
|
381
|
+
|
|
382
|
+
resetImportInput(type) {
|
|
383
|
+
const refName = type === 'claude' ? 'claudeImportInput' : 'codexImportInput';
|
|
384
|
+
const el = this.$refs[refName];
|
|
385
|
+
if (el) {
|
|
386
|
+
el.value = '';
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
|
|
390
|
+
async loadCodexAuthProfiles(options = {}) {
|
|
391
|
+
const silent = !!options.silent;
|
|
392
|
+
try {
|
|
393
|
+
const res = await api('list-auth-profiles');
|
|
394
|
+
if (res && res.error) {
|
|
395
|
+
if (!silent) {
|
|
396
|
+
this.showMessage(res.error, 'error');
|
|
397
|
+
}
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const list = Array.isArray(res && res.profiles) ? res.profiles : [];
|
|
401
|
+
this.codexAuthProfiles = list.sort((a, b) => {
|
|
402
|
+
if (!!a.current !== !!b.current) {
|
|
403
|
+
return a.current ? -1 : 1;
|
|
404
|
+
}
|
|
405
|
+
return String(a.name || '').localeCompare(String(b.name || ''));
|
|
406
|
+
});
|
|
407
|
+
} catch (e) {
|
|
408
|
+
if (!silent) {
|
|
409
|
+
this.showMessage('读取认证列表失败', 'error');
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
|
|
414
|
+
showMessage(text, type) {
|
|
415
|
+
if (this._messageTimer) {
|
|
416
|
+
clearTimeout(this._messageTimer);
|
|
417
|
+
}
|
|
418
|
+
this.message = translateUiMessage(this, text);
|
|
419
|
+
this.messageType = type || 'info';
|
|
420
|
+
this._messageTimer = setTimeout(() => {
|
|
421
|
+
this.message = '';
|
|
422
|
+
this._messageTimer = null;
|
|
423
|
+
}, 3000);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
}
|