codexmate 0.0.20 → 0.0.22

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 (96) hide show
  1. package/README.md +289 -152
  2. package/README.zh.md +321 -0
  3. package/cli/agents-files.js +224 -0
  4. package/cli/archive-helpers.js +446 -0
  5. package/cli/auth-profiles.js +359 -0
  6. package/cli/builtin-proxy.js +1044 -0
  7. package/cli/claude-proxy.js +998 -0
  8. package/cli/config-bootstrap.js +384 -0
  9. package/cli/openai-bridge.js +950 -0
  10. package/cli/openclaw-config.js +629 -0
  11. package/cli/session-usage.concurrent.js +28 -0
  12. package/cli/session-usage.js +112 -0
  13. package/cli/session-usage.models.js +176 -0
  14. package/cli/skills.js +1141 -0
  15. package/cli/zip-commands.js +510 -0
  16. package/cli.js +9408 -9719
  17. package/lib/cli-models-utils.js +109 -1
  18. package/lib/cli-path-utils.js +69 -0
  19. package/lib/cli-sessions.js +386 -0
  20. package/lib/download-artifacts.js +77 -0
  21. package/lib/task-orchestrator.js +869 -0
  22. package/package.json +14 -10
  23. package/res/logo.png +0 -0
  24. package/res/vue.global.prod.js +13 -0
  25. package/web-ui/app.js +193 -15
  26. package/web-ui/index.html +5 -1
  27. package/web-ui/logic.agents-diff.mjs +1 -1
  28. package/web-ui/logic.claude.mjs +60 -0
  29. package/web-ui/logic.runtime.mjs +11 -7
  30. package/web-ui/logic.sessions.mjs +372 -21
  31. package/web-ui/modules/api.mjs +22 -1
  32. package/web-ui/modules/app.computed.dashboard.mjs +23 -10
  33. package/web-ui/modules/app.computed.index.mjs +4 -0
  34. package/web-ui/modules/app.computed.main-tabs.mjs +198 -0
  35. package/web-ui/modules/app.computed.session.mjs +521 -9
  36. package/web-ui/modules/app.methods.agents.mjs +62 -11
  37. package/web-ui/modules/app.methods.codex-config.mjs +189 -34
  38. package/web-ui/modules/app.methods.index.mjs +7 -1
  39. package/web-ui/modules/app.methods.install.mjs +24 -20
  40. package/web-ui/modules/app.methods.navigation.mjs +142 -1
  41. package/web-ui/modules/app.methods.openclaw-core.mjs +339 -39
  42. package/web-ui/modules/app.methods.openclaw-editing.mjs +39 -4
  43. package/web-ui/modules/app.methods.openclaw-persist.mjs +122 -4
  44. package/web-ui/modules/app.methods.providers.mjs +192 -53
  45. package/web-ui/modules/app.methods.session-actions.mjs +99 -19
  46. package/web-ui/modules/app.methods.session-browser.mjs +196 -5
  47. package/web-ui/modules/app.methods.session-timeline.mjs +22 -15
  48. package/web-ui/modules/app.methods.session-trash.mjs +3 -0
  49. package/web-ui/modules/app.methods.startup-claude.mjs +70 -71
  50. package/web-ui/modules/app.methods.task-orchestration.mjs +471 -0
  51. package/web-ui/modules/config-mode.computed.mjs +2 -0
  52. package/web-ui/modules/config-template-confirm-pref.mjs +33 -0
  53. package/web-ui/modules/i18n.mjs +1609 -0
  54. package/web-ui/modules/plugins.computed.mjs +220 -0
  55. package/web-ui/modules/plugins.methods.mjs +620 -0
  56. package/web-ui/modules/plugins.storage.mjs +37 -0
  57. package/web-ui/partials/index/layout-footer.html +1 -57
  58. package/web-ui/partials/index/layout-header.html +299 -175
  59. package/web-ui/partials/index/modal-config-template-agents.html +79 -29
  60. package/web-ui/partials/index/modal-confirm-toast.html +1 -1
  61. package/web-ui/partials/index/modal-health-check.html +14 -14
  62. package/web-ui/partials/index/modal-openclaw-config.html +47 -42
  63. package/web-ui/partials/index/modal-skills.html +130 -114
  64. package/web-ui/partials/index/modals-basic.html +71 -102
  65. package/web-ui/partials/index/panel-config-claude.html +50 -12
  66. package/web-ui/partials/index/panel-config-codex.html +34 -37
  67. package/web-ui/partials/index/panel-config-openclaw.html +10 -16
  68. package/web-ui/partials/index/panel-docs.html +147 -0
  69. package/web-ui/partials/index/panel-market.html +38 -38
  70. package/web-ui/partials/index/panel-orchestration.html +397 -0
  71. package/web-ui/partials/index/panel-plugins.html +243 -0
  72. package/web-ui/partials/index/panel-sessions.html +51 -146
  73. package/web-ui/partials/index/panel-settings.html +188 -96
  74. package/web-ui/partials/index/panel-usage.html +353 -0
  75. package/web-ui/session-helpers.mjs +221 -10
  76. package/web-ui/styles/base-theme.css +120 -229
  77. package/web-ui/styles/controls-forms.css +59 -51
  78. package/web-ui/styles/docs-panel.css +247 -0
  79. package/web-ui/styles/layout-shell.css +394 -128
  80. package/web-ui/styles/modals-core.css +18 -3
  81. package/web-ui/styles/navigation-panels.css +184 -183
  82. package/web-ui/styles/plugins-panel.css +518 -0
  83. package/web-ui/styles/responsive.css +102 -62
  84. package/web-ui/styles/sessions-list.css +13 -27
  85. package/web-ui/styles/sessions-preview.css +13 -7
  86. package/web-ui/styles/sessions-toolbar-trash.css +25 -0
  87. package/web-ui/styles/sessions-usage.css +581 -6
  88. package/web-ui/styles/settings-panel.css +166 -0
  89. package/web-ui/styles/skills-list.css +16 -11
  90. package/web-ui/styles/skills-market.css +63 -2
  91. package/web-ui/styles/task-orchestration.css +776 -0
  92. package/web-ui/styles/titles-cards.css +67 -66
  93. package/web-ui/styles.css +4 -0
  94. package/README.en.md +0 -259
  95. package/res/screenshot.png +0 -0
  96. package/res/vue.global.js +0 -18552
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  findDuplicateClaudeConfigName,
3
+ getClaudeModelCatalogForBaseUrl,
3
4
  matchClaudeConfigFromSettings,
4
5
  normalizeClaudeConfig,
5
6
  normalizeClaudeSettingsEnv,
@@ -22,59 +23,63 @@ export function createStartupClaudeMethods(options = {}) {
22
23
  }
23
24
  this.initError = '';
24
25
  try {
25
- const [statusRes, listRes] = await Promise.all([api('status'), api('list')]);
26
-
27
- if (statusRes.error || (listRes && listRes.error)) {
28
- this.initError = statusRes.error || listRes.error;
26
+ const statusRes = await api('status');
27
+ if (statusRes && statusRes.error) {
28
+ this.initError = statusRes.error;
29
29
  } else {
30
- startupOk = true;
31
- this.currentProvider = statusRes.provider;
32
- this.currentModel = statusRes.model;
33
- {
34
- const tier = typeof statusRes.serviceTier === 'string'
35
- ? statusRes.serviceTier.trim().toLowerCase()
36
- : '';
37
- this.serviceTier = tier === 'fast' ? 'fast' : (tier ? 'standard' : 'fast');
38
- }
39
- {
40
- const effort = typeof statusRes.modelReasoningEffort === 'string'
41
- ? statusRes.modelReasoningEffort.trim().toLowerCase()
42
- : '';
43
- const allowedReasoningEfforts = new Set(['low', 'medium', 'high', 'xhigh']);
44
- this.modelReasoningEffort = allowedReasoningEfforts.has(effort) ? effort : 'medium';
45
- }
46
- {
47
- const contextWindow = this.normalizePositiveIntegerInput(
48
- statusRes.modelContextWindow,
49
- 'model_context_window',
50
- defaultModelContextWindow
51
- );
52
- if (this.editingCodexBudgetField !== 'modelContextWindowInput') {
53
- this.modelContextWindowInput = contextWindow.ok && contextWindow.text
54
- ? contextWindow.text
55
- : String(defaultModelContextWindow);
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');
56
42
  }
57
- }
58
- {
59
- const autoCompactTokenLimit = this.normalizePositiveIntegerInput(
60
- statusRes.modelAutoCompactTokenLimit,
61
- 'model_auto_compact_token_limit',
62
- defaultModelAutoCompactTokenLimit
63
- );
64
- if (this.editingCodexBudgetField !== 'modelAutoCompactTokenLimitInput') {
65
- this.modelAutoCompactTokenLimitInput = autoCompactTokenLimit.ok && autoCompactTokenLimit.text
66
- ? autoCompactTokenLimit.text
67
- : String(defaultModelAutoCompactTokenLimit);
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';
68
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();
69
82
  }
70
- this.providersList = listRes.providers;
71
- if (statusRes.configReady === false) {
72
- this.showMessage('配置已加载', 'info');
73
- }
74
- if (statusRes.initNotice) {
75
- this.showMessage('配置就绪', 'info');
76
- }
77
- this.maybeShowStarPrompt();
78
83
  }
79
84
  } catch (e) {
80
85
  this.initError = '连接失败: ' + e.message;
@@ -88,15 +93,15 @@ export function createStartupClaudeMethods(options = {}) {
88
93
  try {
89
94
  await this.loadModelsForProvider(this.currentProvider);
90
95
  } catch (_) {}
96
+ try {
97
+ await this.loadCodexAuthProfiles();
98
+ } catch (_) {}
91
99
  }
92
100
 
93
- try {
94
- await this.loadCodexAuthProfiles();
95
- } catch (_) {}
101
+ return startupOk;
96
102
  },
97
103
 
98
104
  async loadModelsForProvider(providerName, options = {}) {
99
- const silentError = !!options.silentError;
100
105
  const targetProvider = typeof providerName === 'string' ? providerName.trim() : '';
101
106
  const requestSeq = (Number(this.codexModelsRequestSeq) || 0) + 1;
102
107
  this.codexModelsRequestSeq = requestSeq;
@@ -125,9 +130,6 @@ export function createStartupClaudeMethods(options = {}) {
125
130
  return;
126
131
  }
127
132
  if (res.error) {
128
- if (!silentError) {
129
- this.showMessage('获取模型列表失败', 'error');
130
- }
131
133
  this.models = [];
132
134
  this.modelsSource = 'error';
133
135
  this.modelsHasCurrent = true;
@@ -141,9 +143,6 @@ export function createStartupClaudeMethods(options = {}) {
141
143
  if (!isLatestRequest()) {
142
144
  return;
143
145
  }
144
- if (!silentError) {
145
- this.showMessage('获取模型列表失败', 'error');
146
- }
147
146
  this.models = [];
148
147
  this.modelsSource = 'error';
149
148
  this.modelsHasCurrent = true;
@@ -316,10 +315,15 @@ export function createStartupClaudeMethods(options = {}) {
316
315
  this.resetClaudeModelsState();
317
316
  return;
318
317
  }
318
+ const localCatalog = getClaudeModelCatalogForBaseUrl(baseUrl);
319
319
  if (!apiKey && externalCredentialType) {
320
- this.claudeModels = [];
321
- this.claudeModelsSource = 'unlimited';
322
- this.claudeModelsHasCurrent = true;
320
+ this.claudeModels = localCatalog;
321
+ this.claudeModelsSource = localCatalog.length ? 'catalog' : 'unlimited';
322
+ if (localCatalog.length) {
323
+ this.updateClaudeModelsCurrent();
324
+ } else {
325
+ this.claudeModelsHasCurrent = true;
326
+ }
323
327
  this.claudeModelsLoading = false;
324
328
  return;
325
329
  }
@@ -388,18 +392,13 @@ export function createStartupClaudeMethods(options = {}) {
388
392
 
389
393
  maybeShowStarPrompt() {
390
394
  const storageKey = 'codexmateStarPrompted';
391
- let shown = false;
392
395
  try {
393
- if (localStorage.getItem(storageKey)) {
394
- return;
396
+ if (!localStorage.getItem(storageKey)) {
397
+ localStorage.setItem(storageKey, '1');
395
398
  }
396
- this.showMessage('欢迎到 GitHub 点 Star', 'info');
397
- shown = true;
398
- localStorage.setItem(storageKey, '1');
399
399
  } catch (_) {
400
- if (!shown) {
401
- this.showMessage('欢迎到 GitHub Star', 'info');
402
- }
400
+ // Ignore storage failures silently. The startup UI should not show
401
+ // promotional prompts or block normal configuration work.
403
402
  }
404
403
  }
405
404
  };
@@ -0,0 +1,471 @@
1
+ function createDefaultTaskOrchestrationState() {
2
+ return {
3
+ loading: false,
4
+ planning: false,
5
+ running: false,
6
+ queueAdding: false,
7
+ queueStarting: false,
8
+ retrying: false,
9
+ target: '',
10
+ title: '',
11
+ notes: '',
12
+ followUpsText: '',
13
+ workflowIdsText: '',
14
+ selectedEngine: 'codex',
15
+ allowWrite: false,
16
+ dryRun: false,
17
+ concurrency: 2,
18
+ autoFixRounds: 1,
19
+ plan: null,
20
+ planIssues: [],
21
+ planWarnings: [],
22
+ overviewWarnings: [],
23
+ workflows: [],
24
+ queue: [],
25
+ runs: [],
26
+ selectedRunId: '',
27
+ workspaceTab: 'queue',
28
+ selectedRunDetail: null,
29
+ selectedRunLoading: false,
30
+ selectedRunError: '',
31
+ detailRequestToken: 0,
32
+ lastLoadedAt: '',
33
+ lastError: ''
34
+ };
35
+ }
36
+
37
+ function normalizeLines(text) {
38
+ return String(text || '')
39
+ .split(/\r?\n/g)
40
+ .map((item) => item.trim())
41
+ .filter(Boolean);
42
+ }
43
+
44
+ function normalizePositiveInteger(value, fallback, min = 1, max = 8) {
45
+ const numeric = Number.parseInt(String(value), 10);
46
+ if (!Number.isFinite(numeric)) {
47
+ return fallback;
48
+ }
49
+ return Math.min(max, Math.max(min, Math.floor(numeric)));
50
+ }
51
+
52
+ function normalizeTaskStatusTone(status) {
53
+ const normalized = String(status || '').trim().toLowerCase();
54
+ if (normalized === 'success' || normalized === 'completed') return 'success';
55
+ if (normalized === 'failed' || normalized === 'blocked' || normalized === 'cancelled') return 'error';
56
+ if (normalized === 'running' || normalized === 'queued') return 'warn';
57
+ return 'neutral';
58
+ }
59
+
60
+ function isActiveStatus(status) {
61
+ const normalized = String(status || '').trim().toLowerCase();
62
+ return normalized === 'running' || normalized === 'queued';
63
+ }
64
+
65
+ export function createTaskOrchestrationMethods(options = {}) {
66
+ const { api } = options;
67
+
68
+ return {
69
+ ensureTaskOrchestrationState() {
70
+ const current = this.taskOrchestration;
71
+ if (current && typeof current === 'object' && !Array.isArray(current)) {
72
+ const defaults = createDefaultTaskOrchestrationState();
73
+ for (const [key, value] of Object.entries(defaults)) {
74
+ if (typeof current[key] === 'undefined') {
75
+ current[key] = value;
76
+ }
77
+ }
78
+ return current;
79
+ }
80
+ this.taskOrchestration = createDefaultTaskOrchestrationState();
81
+ return this.taskOrchestration;
82
+ },
83
+
84
+ buildTaskOrchestrationRequest() {
85
+ const state = this.ensureTaskOrchestrationState();
86
+ return {
87
+ title: String(state.title || '').trim(),
88
+ target: String(state.target || '').trim(),
89
+ notes: String(state.notes || '').trim(),
90
+ followUps: normalizeLines(state.followUpsText),
91
+ workflowIds: normalizeLines(state.workflowIdsText),
92
+ engine: String(state.selectedEngine || 'codex').trim().toLowerCase() === 'workflow' ? 'workflow' : 'codex',
93
+ allowWrite: state.allowWrite === true,
94
+ dryRun: state.dryRun === true,
95
+ concurrency: normalizePositiveInteger(state.concurrency, 2, 1, 8),
96
+ autoFixRounds: normalizePositiveInteger(state.autoFixRounds, 1, 0, 5)
97
+ };
98
+ },
99
+
100
+ taskRunStatusTone(status) {
101
+ return normalizeTaskStatusTone(status);
102
+ },
103
+
104
+ isTaskRunActive(status) {
105
+ return isActiveStatus(status);
106
+ },
107
+
108
+ formatTaskNodeDependencies(node) {
109
+ const dependsOn = Array.isArray(node && node.dependsOn) ? node.dependsOn : [];
110
+ return dependsOn.length > 0 ? dependsOn.join(', ') : '无';
111
+ },
112
+
113
+ formatTaskNodeLogs(logs) {
114
+ if (!Array.isArray(logs) || logs.length === 0) {
115
+ return '(no logs)';
116
+ }
117
+ return logs.map((item) => `${item && item.at ? item.at : ''} ${item && item.level ? item.level : ''} ${item && item.message ? item.message : ''}`.trim()).join('\n');
118
+ },
119
+
120
+ appendTaskWorkflowId(workflowId) {
121
+ const state = this.ensureTaskOrchestrationState();
122
+ const normalizedWorkflowId = typeof workflowId === 'string' ? workflowId.trim() : '';
123
+ if (!normalizedWorkflowId) {
124
+ return;
125
+ }
126
+ const nextWorkflowIds = normalizeLines(state.workflowIdsText);
127
+ if (!nextWorkflowIds.includes(normalizedWorkflowId)) {
128
+ nextWorkflowIds.push(normalizedWorkflowId);
129
+ }
130
+ state.selectedEngine = 'workflow';
131
+ state.workflowIdsText = nextWorkflowIds.join('\n');
132
+ },
133
+
134
+ async loadTaskOrchestrationOverview(options = {}) {
135
+ const state = this.ensureTaskOrchestrationState();
136
+ if (state.loading && !options.forceRefresh) {
137
+ return null;
138
+ }
139
+ const silent = !!options.silent;
140
+ state.loading = true;
141
+ state.lastError = '';
142
+ try {
143
+ const res = await api('task-overview', {
144
+ queueLimit: 20,
145
+ runLimit: 20
146
+ });
147
+ if (res && res.error) {
148
+ state.lastError = res.error;
149
+ if (!silent) {
150
+ this.showMessage(res.error, 'error');
151
+ }
152
+ return res;
153
+ }
154
+ state.workflows = Array.isArray(res && res.workflows) ? res.workflows : [];
155
+ state.queue = Array.isArray(res && res.queue) ? res.queue : [];
156
+ state.runs = Array.isArray(res && res.runs) ? res.runs : [];
157
+ state.overviewWarnings = Array.isArray(res && res.warnings) ? res.warnings : [];
158
+ state.lastLoadedAt = new Date().toISOString();
159
+ if (!state.selectedRunId && state.runs.length > 0) {
160
+ state.selectedRunId = state.runs[0].runId || '';
161
+ }
162
+ const shouldRefreshSelectedDetail = !!state.selectedRunId
163
+ && (options.includeDetail !== false
164
+ || (state.selectedRunDetail && this.isTaskRunActive(state.selectedRunDetail && state.selectedRunDetail.run && state.selectedRunDetail.run.status)));
165
+ if (shouldRefreshSelectedDetail) {
166
+ await this.loadTaskRunDetail(state.selectedRunId, { silent: true });
167
+ }
168
+ this.syncTaskOrchestrationPolling();
169
+ return res;
170
+ } catch (error) {
171
+ const message = error && error.message ? error.message : '任务编排概览加载失败';
172
+ state.lastError = message;
173
+ if (!silent) {
174
+ this.showMessage(message, 'error');
175
+ }
176
+ return { error: message };
177
+ } finally {
178
+ state.loading = false;
179
+ }
180
+ },
181
+
182
+ async previewTaskPlan(options = {}) {
183
+ const state = this.ensureTaskOrchestrationState();
184
+ if (state.planning) {
185
+ return null;
186
+ }
187
+ state.planning = true;
188
+ try {
189
+ const res = await api('task-plan', this.buildTaskOrchestrationRequest());
190
+ state.plan = res && res.plan ? res.plan : null;
191
+ state.planIssues = Array.isArray(res && res.issues) ? res.issues : [];
192
+ state.planWarnings = Array.isArray(res && res.warnings) ? res.warnings : [];
193
+ if (res && res.error) {
194
+ if (!options.silent) {
195
+ this.showMessage(res.error, 'error');
196
+ }
197
+ return res;
198
+ }
199
+ if (!options.silent) {
200
+ this.showMessage('任务计划已更新', 'success');
201
+ }
202
+ return res;
203
+ } catch (error) {
204
+ const message = error && error.message ? error.message : '任务计划生成失败';
205
+ state.plan = null;
206
+ state.planIssues = [];
207
+ state.planWarnings = [];
208
+ if (!options.silent) {
209
+ this.showMessage(message, 'error');
210
+ }
211
+ return { error: message };
212
+ } finally {
213
+ state.planning = false;
214
+ }
215
+ },
216
+
217
+ async runTaskOrchestration() {
218
+ const state = this.ensureTaskOrchestrationState();
219
+ if (state.running) {
220
+ return null;
221
+ }
222
+ state.running = true;
223
+ try {
224
+ const res = await api('task-run', {
225
+ ...this.buildTaskOrchestrationRequest(),
226
+ detach: true
227
+ });
228
+ if (res && res.error) {
229
+ this.showMessage(res.error, 'error');
230
+ return res;
231
+ }
232
+ state.selectedRunId = res.runId || state.selectedRunId;
233
+ await this.loadTaskOrchestrationOverview({ silent: true, includeDetail: false });
234
+ if (state.selectedRunId) {
235
+ await this.loadTaskRunDetail(state.selectedRunId, { silent: true });
236
+ }
237
+ this.syncTaskOrchestrationPolling();
238
+ this.showMessage(`任务已启动: ${res.runId || res.taskId || 'unknown'}`, 'success');
239
+ return res;
240
+ } catch (error) {
241
+ const message = error && error.message ? error.message : '任务启动失败';
242
+ this.showMessage(message, 'error');
243
+ return { error: message };
244
+ } finally {
245
+ state.running = false;
246
+ }
247
+ },
248
+
249
+ async addTaskOrchestrationToQueue() {
250
+ const state = this.ensureTaskOrchestrationState();
251
+ if (state.queueAdding) {
252
+ return null;
253
+ }
254
+ state.queueAdding = true;
255
+ try {
256
+ const res = await api('task-queue-add', this.buildTaskOrchestrationRequest());
257
+ if (res && res.error) {
258
+ this.showMessage(res.error, 'error');
259
+ return res;
260
+ }
261
+ await this.loadTaskOrchestrationOverview({ silent: true, includeDetail: false });
262
+ this.showMessage(`已加入队列: ${res && res.task ? res.task.taskId : ''}`.trim(), 'success');
263
+ return res;
264
+ } catch (error) {
265
+ const message = error && error.message ? error.message : '加入队列失败';
266
+ this.showMessage(message, 'error');
267
+ return { error: message };
268
+ } finally {
269
+ state.queueAdding = false;
270
+ }
271
+ },
272
+
273
+ async startTaskQueueRunner() {
274
+ const state = this.ensureTaskOrchestrationState();
275
+ if (state.queueStarting) {
276
+ return null;
277
+ }
278
+ state.queueStarting = true;
279
+ try {
280
+ const res = await api('task-queue-start', { detach: true });
281
+ if (res && res.error) {
282
+ this.showMessage(res.error, 'error');
283
+ return res;
284
+ }
285
+ await this.loadTaskOrchestrationOverview({ silent: true, includeDetail: false });
286
+ this.syncTaskOrchestrationPolling();
287
+ this.showMessage(res && res.alreadyRunning ? '队列执行器已在运行' : '队列执行器已启动', 'success');
288
+ return res;
289
+ } catch (error) {
290
+ const message = error && error.message ? error.message : '启动队列失败';
291
+ this.showMessage(message, 'error');
292
+ return { error: message };
293
+ } finally {
294
+ state.queueStarting = false;
295
+ }
296
+ },
297
+
298
+ async loadTaskRunDetail(runId, options = {}) {
299
+ const state = this.ensureTaskOrchestrationState();
300
+ const normalizedRunId = String(runId || '').trim();
301
+ if (!normalizedRunId) {
302
+ state.selectedRunDetail = null;
303
+ state.selectedRunId = '';
304
+ state.selectedRunError = '';
305
+ this.syncTaskOrchestrationPolling();
306
+ return null;
307
+ }
308
+ const requestToken = (state.detailRequestToken || 0) + 1;
309
+ const previousRunId = state.selectedRunId;
310
+ state.detailRequestToken = requestToken;
311
+ state.selectedRunLoading = true;
312
+ state.selectedRunId = normalizedRunId;
313
+ if (options.switchToDetail === true || !options.silent) {
314
+ state.workspaceTab = 'detail';
315
+ }
316
+ state.selectedRunError = '';
317
+ if (previousRunId !== normalizedRunId) {
318
+ state.selectedRunDetail = null;
319
+ }
320
+ try {
321
+ const res = await api('task-run-detail', { runId: normalizedRunId });
322
+ if (state.detailRequestToken !== requestToken) {
323
+ return res;
324
+ }
325
+ if (res && res.error) {
326
+ state.selectedRunDetail = null;
327
+ state.selectedRunError = res.error;
328
+ if (!options.silent) {
329
+ this.showMessage(res.error, 'error');
330
+ }
331
+ return res;
332
+ }
333
+ state.selectedRunDetail = res;
334
+ state.selectedRunError = '';
335
+ this.syncTaskOrchestrationPolling();
336
+ return res;
337
+ } catch (error) {
338
+ const message = error && error.message ? error.message : '加载任务详情失败';
339
+ if (state.detailRequestToken === requestToken) {
340
+ state.selectedRunDetail = null;
341
+ state.selectedRunError = message;
342
+ }
343
+ if (!options.silent) {
344
+ this.showMessage(message, 'error');
345
+ }
346
+ return { error: message };
347
+ } finally {
348
+ if (state.detailRequestToken === requestToken) {
349
+ state.selectedRunLoading = false;
350
+ }
351
+ }
352
+ },
353
+
354
+ async selectTaskRun(runId) {
355
+ return this.loadTaskRunDetail(runId, { silent: false, switchToDetail: true });
356
+ },
357
+
358
+ async retryTaskRunFromUi(runId) {
359
+ const state = this.ensureTaskOrchestrationState();
360
+ const normalizedRunId = String(runId || '').trim();
361
+ if (!normalizedRunId || state.retrying) {
362
+ return null;
363
+ }
364
+ state.retrying = true;
365
+ try {
366
+ const res = await api('task-retry', { runId: normalizedRunId, detach: true });
367
+ if (res && res.error) {
368
+ this.showMessage(res.error, 'error');
369
+ return res;
370
+ }
371
+ state.selectedRunId = res.runId || state.selectedRunId;
372
+ await this.loadTaskOrchestrationOverview({ silent: true, includeDetail: false });
373
+ if (state.selectedRunId) {
374
+ await this.loadTaskRunDetail(state.selectedRunId, { silent: true });
375
+ }
376
+ this.syncTaskOrchestrationPolling();
377
+ this.showMessage(`已开始重试: ${res.runId || normalizedRunId}`, 'success');
378
+ return res;
379
+ } catch (error) {
380
+ const message = error && error.message ? error.message : '重试任务失败';
381
+ this.showMessage(message, 'error');
382
+ return { error: message };
383
+ } finally {
384
+ state.retrying = false;
385
+ }
386
+ },
387
+
388
+ async cancelTaskRunFromUi(target) {
389
+ const normalizedTarget = String(target || '').trim();
390
+ if (!normalizedTarget) {
391
+ return null;
392
+ }
393
+ try {
394
+ const res = await api('task-cancel', { target: normalizedTarget });
395
+ if (res && res.error) {
396
+ this.showMessage(res.error, 'error');
397
+ return res;
398
+ }
399
+ await this.loadTaskOrchestrationOverview({ silent: true, includeDetail: false });
400
+ if (this.taskOrchestration.selectedRunId) {
401
+ await this.loadTaskRunDetail(this.taskOrchestration.selectedRunId, { silent: true });
402
+ }
403
+ this.syncTaskOrchestrationPolling();
404
+ this.showMessage('已发出取消请求', 'success');
405
+ return res;
406
+ } catch (error) {
407
+ const message = error && error.message ? error.message : '取消任务失败';
408
+ this.showMessage(message, 'error');
409
+ return { error: message };
410
+ }
411
+ },
412
+
413
+ taskOrchestrationHasLiveActivity() {
414
+ const state = this.ensureTaskOrchestrationState();
415
+ const queue = Array.isArray(state.queue) ? state.queue : [];
416
+ if (queue.some((item) => isActiveStatus(item && (item.status || item.runStatus)))) {
417
+ return true;
418
+ }
419
+ const detail = state.selectedRunDetail;
420
+ const selectedStatus = detail && detail.run ? detail.run.status : '';
421
+ if (isActiveStatus(selectedStatus)) {
422
+ return true;
423
+ }
424
+ const runs = Array.isArray(state.runs) ? state.runs : [];
425
+ return runs.some((item) => isActiveStatus(item && item.status));
426
+ },
427
+
428
+ stopTaskOrchestrationPolling() {
429
+ if (this._taskOrchestrationPollTimer) {
430
+ clearTimeout(this._taskOrchestrationPollTimer);
431
+ this._taskOrchestrationPollTimer = 0;
432
+ }
433
+ },
434
+
435
+ syncTaskOrchestrationPolling() {
436
+ this.stopTaskOrchestrationPolling();
437
+ if (this.mainTab !== 'orchestration') {
438
+ return;
439
+ }
440
+ if (!this.taskOrchestrationHasLiveActivity()) {
441
+ return;
442
+ }
443
+ this._taskOrchestrationPollTimer = setTimeout(async () => {
444
+ this._taskOrchestrationPollTimer = 0;
445
+ if (this.mainTab !== 'orchestration') {
446
+ return;
447
+ }
448
+ await this.loadTaskOrchestrationOverview({ silent: true, includeDetail: true });
449
+ }, 4000);
450
+ },
451
+
452
+ resetTaskOrchestrationDraft() {
453
+ const state = this.ensureTaskOrchestrationState();
454
+ state.target = '';
455
+ state.title = '';
456
+ state.notes = '';
457
+ state.followUpsText = '';
458
+ state.workflowIdsText = '';
459
+ state.selectedEngine = 'codex';
460
+ state.allowWrite = false;
461
+ state.dryRun = false;
462
+ state.concurrency = 2;
463
+ state.autoFixRounds = 1;
464
+ state.plan = null;
465
+ state.planIssues = [];
466
+ state.planWarnings = [];
467
+ state.lastError = '';
468
+ this.syncTaskOrchestrationPolling();
469
+ }
470
+ };
471
+ }
@@ -49,7 +49,9 @@ export function createConfigModeComputed() {
49
49
  inspectorMainTabLabel() {
50
50
  if (this.mainTab === 'config') return '配置中心';
51
51
  if (this.mainTab === 'sessions') return '会话浏览';
52
+ if (this.mainTab === 'usage') return 'Usage';
52
53
  if (this.mainTab === 'market') return '技能市场';
54
+ if (this.mainTab === 'docs') return '文档';
53
55
  if (this.mainTab === 'settings') return '设置';
54
56
  return '未知';
55
57
  },