codexmate 0.1.9 → 0.1.12
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 +0 -4
- package/README.vi.md +0 -4
- package/README.zh.md +0 -4
- package/cli/agents-files.js +27 -3
- package/cli/prompt-history.js +171 -0
- package/cli/system-prompt-files.js +20 -2
- package/cli.js +83 -2694
- package/package.json +1 -1
- package/web-ui/app.js +39 -56
- package/web-ui/index.html +0 -1
- package/web-ui/modules/app.computed.dashboard.mjs +0 -3
- package/web-ui/modules/app.computed.main-tabs.mjs +0 -474
- package/web-ui/modules/app.methods.agents.mjs +90 -0
- package/web-ui/modules/app.methods.index.mjs +1 -3
- package/web-ui/modules/app.methods.navigation.mjs +8 -3
- package/web-ui/modules/app.methods.session-actions.mjs +57 -25
- package/web-ui/modules/app.methods.system-prompt.mjs +81 -0
- package/web-ui/modules/app.methods.web-ui-preferences.mjs +26 -9
- package/web-ui/modules/i18n/locales/en.mjs +10 -265
- package/web-ui/modules/i18n/locales/ja.mjs +10 -265
- package/web-ui/modules/i18n/locales/vi.mjs +10 -266
- package/web-ui/modules/i18n/locales/zh-tw.mjs +10 -265
- package/web-ui/modules/i18n/locales/zh.mjs +10 -265
- package/web-ui/partials/index/layout-header.html +5 -48
- package/web-ui/partials/index/panel-config-claude.html +3 -3
- package/web-ui/partials/index/panel-config-codex.html +3 -3
- package/web-ui/partials/index/panel-config-kilocode.html +5 -5
- package/web-ui/partials/index/panel-config-openclaw.html +3 -3
- package/web-ui/partials/index/panel-config-opencode.html +5 -5
- package/web-ui/partials/index/panel-dashboard.html +0 -21
- package/web-ui/partials/index/panel-prompts.html +52 -0
- package/web-ui/partials/index/panel-sessions.html +12 -0
- package/web-ui/partials/index/panel-settings.html +35 -0
- package/web-ui/res/web-ui-render.precompiled.js +543 -1376
- package/web-ui/session-helpers.mjs +0 -16
- package/web-ui/styles/modals-core.css +86 -0
- package/web-ui/styles/sessions-preview.css +38 -0
- package/web-ui/styles/titles-cards.css +2 -2
- package/web-ui/styles.css +0 -1
- package/lib/automation.js +0 -404
- package/lib/task-orchestrator.js +0 -938
- package/lib/task-workspace-chat.js +0 -292
- package/web-ui/modules/app.methods.task-orchestration.mjs +0 -895
- package/web-ui/partials/index/panel-orchestration.html +0 -598
- package/web-ui/styles/task-orchestration.css +0 -2979
|
@@ -1,895 +0,0 @@
|
|
|
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
|
-
chatDraft: '',
|
|
11
|
-
title: '',
|
|
12
|
-
notes: '',
|
|
13
|
-
workspacePath: '',
|
|
14
|
-
threadId: '',
|
|
15
|
-
followUpsText: '',
|
|
16
|
-
workflowIdsText: '',
|
|
17
|
-
selectedEngine: 'openai-chat',
|
|
18
|
-
runMode: 'write',
|
|
19
|
-
concurrency: 2,
|
|
20
|
-
autoFixRounds: 1,
|
|
21
|
-
plan: null,
|
|
22
|
-
planFingerprint: '',
|
|
23
|
-
planIssues: [],
|
|
24
|
-
planWarnings: [],
|
|
25
|
-
overviewWarnings: [],
|
|
26
|
-
openAiChatStatus: null,
|
|
27
|
-
workflows: [],
|
|
28
|
-
queue: [],
|
|
29
|
-
runs: [],
|
|
30
|
-
selectedRunId: '',
|
|
31
|
-
workspaceTab: 'queue',
|
|
32
|
-
selectedRunDetail: null,
|
|
33
|
-
selectedRunLoading: false,
|
|
34
|
-
selectedRunError: '',
|
|
35
|
-
detailRequestToken: 0,
|
|
36
|
-
settingsOpen: false,
|
|
37
|
-
lastLoadedAt: '',
|
|
38
|
-
lastError: ''
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function normalizeLines(text) {
|
|
43
|
-
return String(text || '')
|
|
44
|
-
.split(/\r?\n/g)
|
|
45
|
-
.map((item) => item.trim())
|
|
46
|
-
.filter(Boolean);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let taskOrchestrationScrollObserver = null;
|
|
50
|
-
|
|
51
|
-
function scrollTaskOrchestrationThreadToEnd() {
|
|
52
|
-
if (typeof document === 'undefined') {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const alignLatestCard = (remainingAttempts = 20) => {
|
|
56
|
-
const panel = document.querySelector('#panel-orchestration');
|
|
57
|
-
const thread = panel && panel.querySelector('.task-chat-thread');
|
|
58
|
-
if (!panel || !thread) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const latestCard = Array.from(panel.querySelectorAll('.task-thread-plan-request, .task-thread-message-card')).pop()
|
|
62
|
-
|| thread.lastElementChild;
|
|
63
|
-
if (latestCard && Number.isFinite(latestCard.offsetTop)) {
|
|
64
|
-
if (thread.contains(latestCard)) {
|
|
65
|
-
thread.scrollTop = Math.max(0, latestCard.offsetTop - thread.offsetTop - 12);
|
|
66
|
-
}
|
|
67
|
-
const composer = document.querySelector('#panel-orchestration .task-thread-composer');
|
|
68
|
-
const composerRect = composer && typeof composer.getBoundingClientRect === 'function'
|
|
69
|
-
? composer.getBoundingClientRect()
|
|
70
|
-
: null;
|
|
71
|
-
const latestRect = typeof latestCard.getBoundingClientRect === 'function'
|
|
72
|
-
? latestCard.getBoundingClientRect()
|
|
73
|
-
: null;
|
|
74
|
-
if (composerRect && latestRect) {
|
|
75
|
-
const safeBottom = composerRect.top - 20;
|
|
76
|
-
const overlap = latestRect.bottom - safeBottom;
|
|
77
|
-
if (overlap > 0) {
|
|
78
|
-
let scrollElement = latestCard.parentElement;
|
|
79
|
-
while (scrollElement && scrollElement !== document.body) {
|
|
80
|
-
const style = window.getComputedStyle(scrollElement);
|
|
81
|
-
const canScroll = /(auto|scroll)/.test(style.overflowY) && scrollElement.scrollHeight > scrollElement.clientHeight;
|
|
82
|
-
if (canScroll) {
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
scrollElement = scrollElement.parentElement;
|
|
86
|
-
}
|
|
87
|
-
if (!scrollElement || scrollElement === document.body) {
|
|
88
|
-
scrollElement = document.scrollingElement || document.documentElement;
|
|
89
|
-
}
|
|
90
|
-
const maxScrollTop = Math.max(0, scrollElement.scrollHeight - scrollElement.clientHeight);
|
|
91
|
-
const targetScrollTop = Math.min(maxScrollTop, scrollElement.scrollTop + overlap);
|
|
92
|
-
if (targetScrollTop > scrollElement.scrollTop) {
|
|
93
|
-
scrollElement.scrollTo({ top: targetScrollTop, behavior: 'auto' });
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (remainingAttempts > 0) {
|
|
98
|
-
setTimeout(() => alignLatestCard(remainingAttempts - 1), 160);
|
|
99
|
-
}
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
thread.scrollTop = thread.scrollHeight;
|
|
103
|
-
if (remainingAttempts > 0) {
|
|
104
|
-
setTimeout(() => alignLatestCard(remainingAttempts - 1), 160);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
setTimeout(() => alignLatestCard(), 0);
|
|
108
|
-
const panel = document.querySelector('#panel-orchestration');
|
|
109
|
-
if (panel && typeof MutationObserver !== 'undefined') {
|
|
110
|
-
if (taskOrchestrationScrollObserver) {
|
|
111
|
-
taskOrchestrationScrollObserver.disconnect();
|
|
112
|
-
}
|
|
113
|
-
taskOrchestrationScrollObserver = new MutationObserver(() => alignLatestCard(2));
|
|
114
|
-
taskOrchestrationScrollObserver.observe(panel, { childList: true, subtree: true });
|
|
115
|
-
setTimeout(() => {
|
|
116
|
-
if (taskOrchestrationScrollObserver) {
|
|
117
|
-
taskOrchestrationScrollObserver.disconnect();
|
|
118
|
-
taskOrchestrationScrollObserver = null;
|
|
119
|
-
}
|
|
120
|
-
}, 4000);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function normalizePositiveInteger(value, fallback, min = 1, max = 8) {
|
|
125
|
-
const numeric = Number.parseInt(String(value), 10);
|
|
126
|
-
if (!Number.isFinite(numeric)) {
|
|
127
|
-
return fallback;
|
|
128
|
-
}
|
|
129
|
-
return Math.min(max, Math.max(min, Math.floor(numeric)));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function normalizeTaskStatusTone(status) {
|
|
133
|
-
const normalized = String(status || '').trim().toLowerCase();
|
|
134
|
-
if (normalized === 'success' || normalized === 'completed') return 'success';
|
|
135
|
-
if (normalized === 'failed' || normalized === 'blocked' || normalized === 'cancelled') return 'error';
|
|
136
|
-
if (normalized === 'running' || normalized === 'queued') return 'warn';
|
|
137
|
-
return 'neutral';
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
function isActiveStatus(status) {
|
|
141
|
-
const normalized = String(status || '').trim().toLowerCase();
|
|
142
|
-
return normalized === 'running' || normalized === 'queued';
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function normalizeTaskRunMode(value) {
|
|
146
|
-
const normalized = String(value || '').trim().toLowerCase();
|
|
147
|
-
if (normalized === 'read') return 'read';
|
|
148
|
-
if (normalized === 'dry-run' || normalized === 'dryrun' || normalized === 'plan') return 'dry-run';
|
|
149
|
-
return 'write';
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function normalizeTaskSelectedEngine(value) {
|
|
153
|
-
const normalized = String(value || '').trim().toLowerCase().replace(/[\s_]+/g, '-');
|
|
154
|
-
if (normalized === 'workflow') return 'workflow';
|
|
155
|
-
return 'openai-chat';
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function buildRunModeFlags(runMode) {
|
|
159
|
-
const normalized = normalizeTaskRunMode(runMode);
|
|
160
|
-
return {
|
|
161
|
-
runMode: normalized,
|
|
162
|
-
allowWrite: normalized === 'write',
|
|
163
|
-
dryRun: normalized === 'dry-run'
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function clearTaskRunSelectionForDraft(state) {
|
|
168
|
-
if (!state || typeof state !== 'object') {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
state.selectedRunId = '';
|
|
172
|
-
state.selectedRunDetail = null;
|
|
173
|
-
state.selectedRunError = '';
|
|
174
|
-
state.selectedRunLoading = false;
|
|
175
|
-
state.workspaceTab = 'queue';
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function normalizeTaskWorkspaceInputPath(value) {
|
|
179
|
-
return String(value || '').trim().replace(/\\+/g, '/').replace(/\/$/, '');
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export function createTaskOrchestrationMethods(options = {}) {
|
|
183
|
-
const { api } = options;
|
|
184
|
-
|
|
185
|
-
return {
|
|
186
|
-
ensureTaskOrchestrationState() {
|
|
187
|
-
const current = this.taskOrchestration;
|
|
188
|
-
if (current && typeof current === 'object' && !Array.isArray(current)) {
|
|
189
|
-
const defaults = createDefaultTaskOrchestrationState();
|
|
190
|
-
for (const [key, value] of Object.entries(defaults)) {
|
|
191
|
-
if (typeof current[key] === 'undefined') {
|
|
192
|
-
current[key] = value;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
current.runMode = normalizeTaskRunMode(current.runMode);
|
|
196
|
-
current.selectedEngine = normalizeTaskSelectedEngine(current.selectedEngine);
|
|
197
|
-
current.chatDraft = String(current.chatDraft || '');
|
|
198
|
-
return current;
|
|
199
|
-
}
|
|
200
|
-
this.taskOrchestration = createDefaultTaskOrchestrationState();
|
|
201
|
-
return this.taskOrchestration;
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
buildTaskOrchestrationRequest() {
|
|
205
|
-
const state = this.ensureTaskOrchestrationState();
|
|
206
|
-
const flags = buildRunModeFlags(state.runMode);
|
|
207
|
-
const selectedEngine = normalizeTaskSelectedEngine(state.selectedEngine);
|
|
208
|
-
const workflowIds = selectedEngine === 'workflow' ? normalizeLines(state.workflowIdsText) : [];
|
|
209
|
-
if (selectedEngine !== 'workflow' && state.workflowIdsText) {
|
|
210
|
-
state.workflowIdsText = '';
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
title: String(state.title || '').trim(),
|
|
214
|
-
target: String(state.target || '').trim(),
|
|
215
|
-
notes: String(state.notes || '').trim(),
|
|
216
|
-
cwd: String(state.workspacePath || '').trim(),
|
|
217
|
-
threadId: String(state.threadId || '').trim(),
|
|
218
|
-
followUps: normalizeLines(state.followUpsText),
|
|
219
|
-
workflowIds,
|
|
220
|
-
engine: selectedEngine,
|
|
221
|
-
allowWrite: flags.allowWrite,
|
|
222
|
-
dryRun: flags.dryRun,
|
|
223
|
-
concurrency: normalizePositiveInteger(state.concurrency, 2, 1, 8),
|
|
224
|
-
autoFixRounds: normalizePositiveInteger(state.autoFixRounds, 1, 0, 5)
|
|
225
|
-
};
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
buildTaskOrchestrationFingerprint() {
|
|
229
|
-
const req = this.buildTaskOrchestrationRequest();
|
|
230
|
-
return JSON.stringify({
|
|
231
|
-
title: req.title,
|
|
232
|
-
target: req.target,
|
|
233
|
-
notes: req.notes,
|
|
234
|
-
cwd: req.cwd,
|
|
235
|
-
threadId: req.threadId,
|
|
236
|
-
followUps: req.followUps,
|
|
237
|
-
workflowIds: req.workflowIds,
|
|
238
|
-
engine: req.engine,
|
|
239
|
-
allowWrite: req.allowWrite,
|
|
240
|
-
dryRun: req.dryRun,
|
|
241
|
-
concurrency: req.concurrency,
|
|
242
|
-
autoFixRounds: req.autoFixRounds
|
|
243
|
-
});
|
|
244
|
-
},
|
|
245
|
-
|
|
246
|
-
taskRunStatusTone(status) {
|
|
247
|
-
return normalizeTaskStatusTone(status);
|
|
248
|
-
},
|
|
249
|
-
|
|
250
|
-
isTaskRunActive(status) {
|
|
251
|
-
return isActiveStatus(status);
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
formatTaskNodeDependencies(node) {
|
|
255
|
-
const dependsOn = Array.isArray(node && node.dependsOn) ? node.dependsOn : [];
|
|
256
|
-
return dependsOn.length > 0 ? dependsOn.join(', ') : '无';
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
formatTaskNodeLogs(logs) {
|
|
260
|
-
if (!Array.isArray(logs) || logs.length === 0) {
|
|
261
|
-
return '(no logs)';
|
|
262
|
-
}
|
|
263
|
-
return logs.map((item) => `${item && item.at ? item.at : ''} ${item && item.level ? item.level : ''} ${item && item.message ? item.message : ''}`.trim()).join('\n');
|
|
264
|
-
},
|
|
265
|
-
|
|
266
|
-
formatTaskNodeOutputText(node) {
|
|
267
|
-
const output = node && node.output && typeof node.output === 'object' ? node.output : null;
|
|
268
|
-
const text = output && typeof output.text === 'string' ? output.text.trim() : '';
|
|
269
|
-
return text || '(no output)';
|
|
270
|
-
},
|
|
271
|
-
|
|
272
|
-
openTaskOpenAiChatConfig() {
|
|
273
|
-
if (typeof this.switchMainTab === 'function') {
|
|
274
|
-
this.switchMainTab('config');
|
|
275
|
-
} else {
|
|
276
|
-
this.mainTab = 'config';
|
|
277
|
-
}
|
|
278
|
-
this.configMode = 'codex';
|
|
279
|
-
const status = this.taskOrchestration && this.taskOrchestration.openAiChatStatus
|
|
280
|
-
? this.taskOrchestration.openAiChatStatus
|
|
281
|
-
: null;
|
|
282
|
-
const providerName = status && typeof status.providerName === 'string' ? status.providerName.trim() : '';
|
|
283
|
-
const provider = providerName && Array.isArray(this.providersList)
|
|
284
|
-
? this.providersList.find((item) => item && item.name === providerName)
|
|
285
|
-
: null;
|
|
286
|
-
if (provider && typeof this.openEditModal === 'function') {
|
|
287
|
-
this.openEditModal(provider);
|
|
288
|
-
} else if (typeof this.openAddProviderModal === 'function') {
|
|
289
|
-
this.openAddProviderModal();
|
|
290
|
-
}
|
|
291
|
-
},
|
|
292
|
-
|
|
293
|
-
appendTaskWorkflowId(workflowId) {
|
|
294
|
-
const state = this.ensureTaskOrchestrationState();
|
|
295
|
-
const normalizedWorkflowId = typeof workflowId === 'string' ? workflowId.trim() : '';
|
|
296
|
-
if (!normalizedWorkflowId) {
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
const nextWorkflowIds = normalizeLines(state.workflowIdsText);
|
|
300
|
-
if (!nextWorkflowIds.includes(normalizedWorkflowId)) {
|
|
301
|
-
nextWorkflowIds.push(normalizedWorkflowId);
|
|
302
|
-
}
|
|
303
|
-
state.selectedEngine = 'workflow';
|
|
304
|
-
state.workflowIdsText = nextWorkflowIds.join('\n');
|
|
305
|
-
},
|
|
306
|
-
|
|
307
|
-
async loadTaskOrchestrationOverview(options = {}) {
|
|
308
|
-
const state = this.ensureTaskOrchestrationState();
|
|
309
|
-
if (state.loading && !options.forceRefresh) {
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
const silent = !!options.silent;
|
|
313
|
-
state.loading = true;
|
|
314
|
-
state.lastError = '';
|
|
315
|
-
try {
|
|
316
|
-
const res = await api('task-overview', {
|
|
317
|
-
queueLimit: 20,
|
|
318
|
-
runLimit: 20
|
|
319
|
-
});
|
|
320
|
-
if (res && res.error) {
|
|
321
|
-
state.lastError = res.error;
|
|
322
|
-
if (!silent) {
|
|
323
|
-
this.showMessage(res.error, 'error');
|
|
324
|
-
}
|
|
325
|
-
return res;
|
|
326
|
-
}
|
|
327
|
-
state.workflows = Array.isArray(res && res.workflows) ? res.workflows : [];
|
|
328
|
-
state.queue = Array.isArray(res && res.queue) ? res.queue : [];
|
|
329
|
-
state.runs = Array.isArray(res && res.runs) ? res.runs : [];
|
|
330
|
-
state.openAiChatStatus = res && res.openAiChatStatus && typeof res.openAiChatStatus === 'object'
|
|
331
|
-
? res.openAiChatStatus
|
|
332
|
-
: null;
|
|
333
|
-
state.overviewWarnings = Array.isArray(res && res.warnings) ? res.warnings : [];
|
|
334
|
-
state.lastLoadedAt = new Date().toISOString();
|
|
335
|
-
const shouldRefreshSelectedDetail = !!state.selectedRunId
|
|
336
|
-
&& (options.includeDetail !== false
|
|
337
|
-
|| (state.selectedRunDetail && this.isTaskRunActive(state.selectedRunDetail && state.selectedRunDetail.run && state.selectedRunDetail.run.status)));
|
|
338
|
-
if (shouldRefreshSelectedDetail) {
|
|
339
|
-
await this.loadTaskRunDetail(state.selectedRunId, { silent: true });
|
|
340
|
-
}
|
|
341
|
-
this.syncTaskOrchestrationPolling();
|
|
342
|
-
return res;
|
|
343
|
-
} catch (error) {
|
|
344
|
-
const message = error && error.message ? error.message : '任务编排概览加载失败';
|
|
345
|
-
state.lastError = message;
|
|
346
|
-
if (!silent) {
|
|
347
|
-
this.showMessage(message, 'error');
|
|
348
|
-
}
|
|
349
|
-
return { error: message };
|
|
350
|
-
} finally {
|
|
351
|
-
state.loading = false;
|
|
352
|
-
}
|
|
353
|
-
},
|
|
354
|
-
|
|
355
|
-
appendTaskChatMessage() {
|
|
356
|
-
const state = this.ensureTaskOrchestrationState();
|
|
357
|
-
const message = String(state.chatDraft || '').trim();
|
|
358
|
-
if (!message) {
|
|
359
|
-
return false;
|
|
360
|
-
}
|
|
361
|
-
if (!String(state.target || '').trim()) {
|
|
362
|
-
state.target = message;
|
|
363
|
-
} else {
|
|
364
|
-
const existing = normalizeLines(state.followUpsText);
|
|
365
|
-
state.followUpsText = existing.concat(message).join('\n');
|
|
366
|
-
}
|
|
367
|
-
state.chatDraft = '';
|
|
368
|
-
state.plan = null;
|
|
369
|
-
state.planFingerprint = '';
|
|
370
|
-
state.planIssues = [];
|
|
371
|
-
state.planWarnings = [];
|
|
372
|
-
state.lastError = '';
|
|
373
|
-
clearTaskRunSelectionForDraft(state);
|
|
374
|
-
scrollTaskOrchestrationThreadToEnd();
|
|
375
|
-
return true;
|
|
376
|
-
},
|
|
377
|
-
|
|
378
|
-
async submitTaskOrchestrationChatMessage() {
|
|
379
|
-
const state = this.ensureTaskOrchestrationState();
|
|
380
|
-
const rawMessage = String(state.chatDraft || '').trim();
|
|
381
|
-
if (!rawMessage) {
|
|
382
|
-
return false;
|
|
383
|
-
}
|
|
384
|
-
const planCommand = rawMessage.match(/^\/plan(?:\s+([\s\S]*))?$/i);
|
|
385
|
-
if (!planCommand) {
|
|
386
|
-
return this.appendTaskChatMessage();
|
|
387
|
-
}
|
|
388
|
-
const planTarget = String(planCommand[1] || '').trim();
|
|
389
|
-
if (planTarget) {
|
|
390
|
-
state.chatDraft = planTarget;
|
|
391
|
-
if (!this.appendTaskChatMessage()) {
|
|
392
|
-
return false;
|
|
393
|
-
}
|
|
394
|
-
} else if (!String(state.target || '').trim()) {
|
|
395
|
-
this.showMessage('先输入任务需求,再发送 /plan', 'error');
|
|
396
|
-
return false;
|
|
397
|
-
} else {
|
|
398
|
-
state.chatDraft = '';
|
|
399
|
-
}
|
|
400
|
-
return this.previewTaskPlan({ silent: false });
|
|
401
|
-
},
|
|
402
|
-
|
|
403
|
-
async previewTaskPlan(options = {}) {
|
|
404
|
-
const state = this.ensureTaskOrchestrationState();
|
|
405
|
-
if (state.planning) {
|
|
406
|
-
return null;
|
|
407
|
-
}
|
|
408
|
-
clearTaskRunSelectionForDraft(state);
|
|
409
|
-
state.planning = true;
|
|
410
|
-
try {
|
|
411
|
-
const res = await api('task-plan', {
|
|
412
|
-
...this.buildTaskOrchestrationRequest(),
|
|
413
|
-
previewOnly: true
|
|
414
|
-
});
|
|
415
|
-
state.plan = res && res.plan ? res.plan : null;
|
|
416
|
-
if (state.plan && state.plan.threadId && !state.threadId) {
|
|
417
|
-
state.threadId = state.plan.threadId;
|
|
418
|
-
}
|
|
419
|
-
state.planIssues = Array.isArray(res && res.issues) ? res.issues : [];
|
|
420
|
-
state.planWarnings = Array.isArray(res && res.warnings) ? res.warnings : [];
|
|
421
|
-
state.planFingerprint = state.plan ? this.buildTaskOrchestrationFingerprint() : '';
|
|
422
|
-
scrollTaskOrchestrationThreadToEnd();
|
|
423
|
-
if (res && res.error) {
|
|
424
|
-
if (!options.silent) {
|
|
425
|
-
this.showMessage(res.error, 'error');
|
|
426
|
-
}
|
|
427
|
-
return res;
|
|
428
|
-
}
|
|
429
|
-
if (!options.silent) {
|
|
430
|
-
this.showMessage('任务计划已更新', 'success');
|
|
431
|
-
}
|
|
432
|
-
return res;
|
|
433
|
-
} catch (error) {
|
|
434
|
-
const message = error && error.message ? error.message : '任务计划生成失败';
|
|
435
|
-
state.plan = null;
|
|
436
|
-
state.planIssues = [];
|
|
437
|
-
state.planWarnings = [];
|
|
438
|
-
if (!options.silent) {
|
|
439
|
-
this.showMessage(message, 'error');
|
|
440
|
-
}
|
|
441
|
-
return { error: message };
|
|
442
|
-
} finally {
|
|
443
|
-
state.planning = false;
|
|
444
|
-
}
|
|
445
|
-
},
|
|
446
|
-
|
|
447
|
-
async previewTaskPlanFromChat() {
|
|
448
|
-
const state = this.ensureTaskOrchestrationState();
|
|
449
|
-
if (state.planning || state.running) {
|
|
450
|
-
return null;
|
|
451
|
-
}
|
|
452
|
-
if (String(state.chatDraft || '').trim()) {
|
|
453
|
-
const appended = this.appendTaskChatMessage();
|
|
454
|
-
if (!appended) {
|
|
455
|
-
return null;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
if (!String(state.target || '').trim()) {
|
|
459
|
-
this.showMessage('先输入任务需求,再探讨方案', 'error');
|
|
460
|
-
return null;
|
|
461
|
-
}
|
|
462
|
-
return this.previewTaskPlan({ silent: false });
|
|
463
|
-
},
|
|
464
|
-
|
|
465
|
-
async runTaskOrchestration() {
|
|
466
|
-
const state = this.ensureTaskOrchestrationState();
|
|
467
|
-
if (state.running) {
|
|
468
|
-
return null;
|
|
469
|
-
}
|
|
470
|
-
state.running = true;
|
|
471
|
-
try {
|
|
472
|
-
const res = await api('task-run', {
|
|
473
|
-
...this.buildTaskOrchestrationRequest(),
|
|
474
|
-
detach: true
|
|
475
|
-
});
|
|
476
|
-
if (res && res.error) {
|
|
477
|
-
this.showMessage(res.error, 'error');
|
|
478
|
-
return res;
|
|
479
|
-
}
|
|
480
|
-
state.selectedRunId = res.runId || state.selectedRunId;
|
|
481
|
-
if (res && res.threadId) {
|
|
482
|
-
state.threadId = res.threadId;
|
|
483
|
-
}
|
|
484
|
-
await this.loadTaskOrchestrationOverview({ silent: true, includeDetail: false });
|
|
485
|
-
if (state.selectedRunId) {
|
|
486
|
-
await this.loadTaskRunDetail(state.selectedRunId, { silent: true });
|
|
487
|
-
}
|
|
488
|
-
this.syncTaskOrchestrationPolling();
|
|
489
|
-
this.showMessage(`任务已启动: ${res.runId || res.taskId || 'unknown'}`, 'success');
|
|
490
|
-
return res;
|
|
491
|
-
} catch (error) {
|
|
492
|
-
const message = error && error.message ? error.message : '任务启动失败';
|
|
493
|
-
this.showMessage(message, 'error');
|
|
494
|
-
return { error: message };
|
|
495
|
-
} finally {
|
|
496
|
-
state.running = false;
|
|
497
|
-
}
|
|
498
|
-
},
|
|
499
|
-
|
|
500
|
-
async addTaskOrchestrationToQueue(options = {}) {
|
|
501
|
-
const state = this.ensureTaskOrchestrationState();
|
|
502
|
-
if (state.queueAdding) {
|
|
503
|
-
return null;
|
|
504
|
-
}
|
|
505
|
-
state.queueAdding = true;
|
|
506
|
-
try {
|
|
507
|
-
const res = await api('task-queue-add', this.buildTaskOrchestrationRequest());
|
|
508
|
-
if (res && res.error) {
|
|
509
|
-
if (!options.silent) {
|
|
510
|
-
this.showMessage(res.error, 'error');
|
|
511
|
-
}
|
|
512
|
-
return res;
|
|
513
|
-
}
|
|
514
|
-
if (res && res.task && res.task.threadId) {
|
|
515
|
-
state.threadId = res.task.threadId;
|
|
516
|
-
}
|
|
517
|
-
if (!options.deferRefresh) {
|
|
518
|
-
await this.loadTaskOrchestrationOverview({ silent: true, includeDetail: false });
|
|
519
|
-
}
|
|
520
|
-
if (!options.silent) {
|
|
521
|
-
this.showMessage(`已加入队列: ${res && res.task ? res.task.taskId : ''}`.trim(), 'success');
|
|
522
|
-
}
|
|
523
|
-
return res;
|
|
524
|
-
} catch (error) {
|
|
525
|
-
const message = error && error.message ? error.message : '加入队列失败';
|
|
526
|
-
if (!options.silent) {
|
|
527
|
-
this.showMessage(message, 'error');
|
|
528
|
-
}
|
|
529
|
-
return { error: message };
|
|
530
|
-
} finally {
|
|
531
|
-
state.queueAdding = false;
|
|
532
|
-
}
|
|
533
|
-
},
|
|
534
|
-
|
|
535
|
-
async planAndRunTaskOrchestration() {
|
|
536
|
-
const state = this.ensureTaskOrchestrationState();
|
|
537
|
-
if (state.running || state.planning) {
|
|
538
|
-
return null;
|
|
539
|
-
}
|
|
540
|
-
if (!String(state.target || '').trim()) {
|
|
541
|
-
return null;
|
|
542
|
-
}
|
|
543
|
-
if (buildRunModeFlags(state.runMode).dryRun) {
|
|
544
|
-
return this.previewTaskPlan({ silent: false });
|
|
545
|
-
}
|
|
546
|
-
const fingerprint = this.buildTaskOrchestrationFingerprint();
|
|
547
|
-
const shouldPreview = !state.plan || state.planFingerprint !== fingerprint;
|
|
548
|
-
if (shouldPreview) {
|
|
549
|
-
const preview = await this.previewTaskPlan({ silent: true });
|
|
550
|
-
if (preview && preview.error) {
|
|
551
|
-
this.showMessage(preview.error, 'error');
|
|
552
|
-
return preview;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
if (state.planIssues && state.planIssues.length) {
|
|
556
|
-
this.showMessage('计划存在问题,请先修复再执行', 'error');
|
|
557
|
-
return { error: 'Plan has blocking issues' };
|
|
558
|
-
}
|
|
559
|
-
return this.runTaskOrchestration();
|
|
560
|
-
},
|
|
561
|
-
|
|
562
|
-
async planAndRunTaskOrchestrationFromChat() {
|
|
563
|
-
const state = this.ensureTaskOrchestrationState();
|
|
564
|
-
if (state.running || state.planning) {
|
|
565
|
-
return null;
|
|
566
|
-
}
|
|
567
|
-
if (String(state.chatDraft || '').trim()) {
|
|
568
|
-
const appended = this.appendTaskChatMessage();
|
|
569
|
-
if (!appended) {
|
|
570
|
-
return null;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
if (!String(state.target || '').trim()) {
|
|
574
|
-
this.showMessage('先输入任务需求,再开始执行', 'error');
|
|
575
|
-
return null;
|
|
576
|
-
}
|
|
577
|
-
return this.planAndRunTaskOrchestration();
|
|
578
|
-
},
|
|
579
|
-
|
|
580
|
-
async queueTaskOrchestrationAndStart() {
|
|
581
|
-
const state = this.ensureTaskOrchestrationState();
|
|
582
|
-
if (state.queueAdding || state.queueStarting || state.planning || state.running) {
|
|
583
|
-
return null;
|
|
584
|
-
}
|
|
585
|
-
if (!String(state.target || '').trim()) {
|
|
586
|
-
return null;
|
|
587
|
-
}
|
|
588
|
-
const queued = await this.addTaskOrchestrationToQueue({ silent: true, deferRefresh: true });
|
|
589
|
-
if (queued && queued.error) {
|
|
590
|
-
this.showMessage(queued.error, 'error');
|
|
591
|
-
return queued;
|
|
592
|
-
}
|
|
593
|
-
return this.startTaskQueueRunner();
|
|
594
|
-
},
|
|
595
|
-
|
|
596
|
-
async startTaskQueueRunner() {
|
|
597
|
-
const state = this.ensureTaskOrchestrationState();
|
|
598
|
-
if (state.queueStarting) {
|
|
599
|
-
return null;
|
|
600
|
-
}
|
|
601
|
-
state.queueStarting = true;
|
|
602
|
-
try {
|
|
603
|
-
const res = await api('task-queue-start', { detach: true });
|
|
604
|
-
if (res && res.error) {
|
|
605
|
-
this.showMessage(res.error, 'error');
|
|
606
|
-
return res;
|
|
607
|
-
}
|
|
608
|
-
await this.loadTaskOrchestrationOverview({ silent: true, includeDetail: false });
|
|
609
|
-
this.syncTaskOrchestrationPolling();
|
|
610
|
-
this.showMessage(res && res.alreadyRunning ? '队列执行器已在运行' : '队列执行器已启动', 'success');
|
|
611
|
-
return res;
|
|
612
|
-
} catch (error) {
|
|
613
|
-
const message = error && error.message ? error.message : '启动队列失败';
|
|
614
|
-
this.showMessage(message, 'error');
|
|
615
|
-
return { error: message };
|
|
616
|
-
} finally {
|
|
617
|
-
state.queueStarting = false;
|
|
618
|
-
}
|
|
619
|
-
},
|
|
620
|
-
|
|
621
|
-
async loadTaskRunDetail(runId, options = {}) {
|
|
622
|
-
const state = this.ensureTaskOrchestrationState();
|
|
623
|
-
const normalizedRunId = String(runId || '').trim();
|
|
624
|
-
if (!normalizedRunId) {
|
|
625
|
-
state.selectedRunDetail = null;
|
|
626
|
-
state.selectedRunId = '';
|
|
627
|
-
state.selectedRunError = '';
|
|
628
|
-
this.syncTaskOrchestrationPolling();
|
|
629
|
-
return null;
|
|
630
|
-
}
|
|
631
|
-
const requestToken = (state.detailRequestToken || 0) + 1;
|
|
632
|
-
const previousRunId = state.selectedRunId;
|
|
633
|
-
state.detailRequestToken = requestToken;
|
|
634
|
-
state.selectedRunLoading = true;
|
|
635
|
-
state.selectedRunId = normalizedRunId;
|
|
636
|
-
if (options.switchToDetail === true || !options.silent) {
|
|
637
|
-
state.workspaceTab = 'detail';
|
|
638
|
-
}
|
|
639
|
-
state.selectedRunError = '';
|
|
640
|
-
if (previousRunId !== normalizedRunId) {
|
|
641
|
-
state.selectedRunDetail = null;
|
|
642
|
-
}
|
|
643
|
-
try {
|
|
644
|
-
const res = await api('task-run-detail', { runId: normalizedRunId });
|
|
645
|
-
if (state.detailRequestToken !== requestToken) {
|
|
646
|
-
return res;
|
|
647
|
-
}
|
|
648
|
-
if (res && res.error) {
|
|
649
|
-
state.selectedRunDetail = null;
|
|
650
|
-
state.selectedRunError = res.error;
|
|
651
|
-
if (!options.silent) {
|
|
652
|
-
this.showMessage(res.error, 'error');
|
|
653
|
-
}
|
|
654
|
-
return res;
|
|
655
|
-
}
|
|
656
|
-
state.selectedRunDetail = res;
|
|
657
|
-
state.selectedRunError = '';
|
|
658
|
-
scrollTaskOrchestrationThreadToEnd();
|
|
659
|
-
this.syncTaskOrchestrationPolling();
|
|
660
|
-
return res;
|
|
661
|
-
} catch (error) {
|
|
662
|
-
const message = error && error.message ? error.message : '加载任务详情失败';
|
|
663
|
-
if (state.detailRequestToken === requestToken) {
|
|
664
|
-
state.selectedRunDetail = null;
|
|
665
|
-
state.selectedRunError = message;
|
|
666
|
-
}
|
|
667
|
-
if (!options.silent) {
|
|
668
|
-
this.showMessage(message, 'error');
|
|
669
|
-
}
|
|
670
|
-
return { error: message };
|
|
671
|
-
} finally {
|
|
672
|
-
if (state.detailRequestToken === requestToken) {
|
|
673
|
-
state.selectedRunLoading = false;
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
},
|
|
677
|
-
|
|
678
|
-
async selectTaskRun(runId) {
|
|
679
|
-
return this.loadTaskRunDetail(runId, { silent: false, switchToDetail: true });
|
|
680
|
-
},
|
|
681
|
-
|
|
682
|
-
selectTaskWorkspace(workspacePath) {
|
|
683
|
-
const state = this.ensureTaskOrchestrationState();
|
|
684
|
-
const nextWorkspacePath = normalizeTaskWorkspaceInputPath(workspacePath);
|
|
685
|
-
const previousWorkspacePath = normalizeTaskWorkspaceInputPath(state.workspacePath);
|
|
686
|
-
state.workspacePath = nextWorkspacePath;
|
|
687
|
-
state.workspaceTab = 'runs';
|
|
688
|
-
if (nextWorkspacePath !== previousWorkspacePath) {
|
|
689
|
-
state.plan = null;
|
|
690
|
-
state.planFingerprint = '';
|
|
691
|
-
state.planIssues = [];
|
|
692
|
-
state.planWarnings = [];
|
|
693
|
-
const selectedDetailWorkspacePath = normalizeTaskWorkspaceInputPath(state.selectedRunDetail && state.selectedRunDetail.cwd);
|
|
694
|
-
if (selectedDetailWorkspacePath && selectedDetailWorkspacePath !== nextWorkspacePath) {
|
|
695
|
-
state.selectedRunId = '';
|
|
696
|
-
state.selectedRunDetail = null;
|
|
697
|
-
state.selectedRunError = '';
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
this.syncTaskOrchestrationPolling();
|
|
701
|
-
},
|
|
702
|
-
|
|
703
|
-
startNewTaskWorkspaceSession(workspacePath = '') {
|
|
704
|
-
const state = this.ensureTaskOrchestrationState();
|
|
705
|
-
const selectedWorkspacePath = normalizeTaskWorkspaceInputPath(workspacePath || state.workspacePath || (state.selectedRunDetail && state.selectedRunDetail.cwd));
|
|
706
|
-
state.workspacePath = selectedWorkspacePath;
|
|
707
|
-
state.threadId = '';
|
|
708
|
-
state.target = '';
|
|
709
|
-
state.chatDraft = '';
|
|
710
|
-
state.title = '';
|
|
711
|
-
state.notes = '';
|
|
712
|
-
state.followUpsText = '';
|
|
713
|
-
state.plan = null;
|
|
714
|
-
state.planFingerprint = '';
|
|
715
|
-
state.planIssues = [];
|
|
716
|
-
state.planWarnings = [];
|
|
717
|
-
state.selectedRunId = '';
|
|
718
|
-
state.selectedRunDetail = null;
|
|
719
|
-
state.selectedRunError = '';
|
|
720
|
-
state.selectedRunLoading = false;
|
|
721
|
-
state.workspaceTab = 'queue';
|
|
722
|
-
state.lastError = '';
|
|
723
|
-
this.showMessage(selectedWorkspacePath ? '已为当前工作区开始新会话' : '已开始新任务会话', 'success');
|
|
724
|
-
scrollTaskOrchestrationThreadToEnd();
|
|
725
|
-
this.syncTaskOrchestrationPolling();
|
|
726
|
-
},
|
|
727
|
-
|
|
728
|
-
async continueTaskWorkspaceSession(session) {
|
|
729
|
-
const item = session && typeof session === 'object' ? session : {};
|
|
730
|
-
const workspacePath = normalizeTaskWorkspaceInputPath(item.cwd || item.workspacePath || '');
|
|
731
|
-
const threadId = String(item.threadId || '').trim();
|
|
732
|
-
const runId = String(item.runId || '').trim();
|
|
733
|
-
const taskId = String(item.taskId || '').trim();
|
|
734
|
-
const state = this.ensureTaskOrchestrationState();
|
|
735
|
-
if (workspacePath) state.workspacePath = workspacePath;
|
|
736
|
-
if (threadId) state.threadId = threadId;
|
|
737
|
-
if (runId) {
|
|
738
|
-
await this.loadTaskRunDetail(runId, { silent: true, switchToDetail: true });
|
|
739
|
-
this.continueTaskThreadFromUi();
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
state.selectedRunId = '';
|
|
743
|
-
state.selectedRunDetail = null;
|
|
744
|
-
state.selectedRunError = '';
|
|
745
|
-
state.workspaceTab = 'queue';
|
|
746
|
-
state.title = String(item.title || state.title || '').trim();
|
|
747
|
-
this.showMessage(taskId ? `已恢复队列任务上下文: ${taskId}` : '已恢复会话上下文', 'success');
|
|
748
|
-
scrollTaskOrchestrationThreadToEnd();
|
|
749
|
-
this.syncTaskOrchestrationPolling();
|
|
750
|
-
},
|
|
751
|
-
|
|
752
|
-
async retryTaskRunFromUi(runId) {
|
|
753
|
-
const state = this.ensureTaskOrchestrationState();
|
|
754
|
-
const normalizedRunId = String(runId || '').trim();
|
|
755
|
-
if (!normalizedRunId || state.retrying) {
|
|
756
|
-
return null;
|
|
757
|
-
}
|
|
758
|
-
state.retrying = true;
|
|
759
|
-
try {
|
|
760
|
-
const res = await api('task-retry', { runId: normalizedRunId, detach: true });
|
|
761
|
-
if (res && res.error) {
|
|
762
|
-
this.showMessage(res.error, 'error');
|
|
763
|
-
return res;
|
|
764
|
-
}
|
|
765
|
-
state.selectedRunId = res.runId || state.selectedRunId;
|
|
766
|
-
if (res && res.threadId) {
|
|
767
|
-
state.threadId = res.threadId;
|
|
768
|
-
}
|
|
769
|
-
await this.loadTaskOrchestrationOverview({ silent: true, includeDetail: false });
|
|
770
|
-
if (state.selectedRunId) {
|
|
771
|
-
await this.loadTaskRunDetail(state.selectedRunId, { silent: true });
|
|
772
|
-
}
|
|
773
|
-
this.syncTaskOrchestrationPolling();
|
|
774
|
-
this.showMessage(`已开始重试: ${res.runId || normalizedRunId}`, 'success');
|
|
775
|
-
return res;
|
|
776
|
-
} catch (error) {
|
|
777
|
-
const message = error && error.message ? error.message : '重试任务失败';
|
|
778
|
-
this.showMessage(message, 'error');
|
|
779
|
-
return { error: message };
|
|
780
|
-
} finally {
|
|
781
|
-
state.retrying = false;
|
|
782
|
-
}
|
|
783
|
-
},
|
|
784
|
-
|
|
785
|
-
async cancelTaskRunFromUi(target) {
|
|
786
|
-
const normalizedTarget = String(target || '').trim();
|
|
787
|
-
if (!normalizedTarget) {
|
|
788
|
-
return null;
|
|
789
|
-
}
|
|
790
|
-
try {
|
|
791
|
-
const res = await api('task-cancel', { target: normalizedTarget });
|
|
792
|
-
if (res && res.error) {
|
|
793
|
-
this.showMessage(res.error, 'error');
|
|
794
|
-
return res;
|
|
795
|
-
}
|
|
796
|
-
await this.loadTaskOrchestrationOverview({ silent: true, includeDetail: false });
|
|
797
|
-
if (this.taskOrchestration.selectedRunId) {
|
|
798
|
-
await this.loadTaskRunDetail(this.taskOrchestration.selectedRunId, { silent: true });
|
|
799
|
-
}
|
|
800
|
-
this.syncTaskOrchestrationPolling();
|
|
801
|
-
this.showMessage('已发出取消请求', 'success');
|
|
802
|
-
return res;
|
|
803
|
-
} catch (error) {
|
|
804
|
-
const message = error && error.message ? error.message : '取消任务失败';
|
|
805
|
-
this.showMessage(message, 'error');
|
|
806
|
-
return { error: message };
|
|
807
|
-
}
|
|
808
|
-
},
|
|
809
|
-
|
|
810
|
-
continueTaskThreadFromUi() {
|
|
811
|
-
const state = this.ensureTaskOrchestrationState();
|
|
812
|
-
const detail = state.selectedRunDetail && typeof state.selectedRunDetail === 'object' ? state.selectedRunDetail : null;
|
|
813
|
-
if (!detail) {
|
|
814
|
-
return;
|
|
815
|
-
}
|
|
816
|
-
const continuedEngine = normalizeTaskSelectedEngine(detail.engine || state.selectedEngine || 'openai-chat');
|
|
817
|
-
state.threadId = String(detail.threadId || state.threadId || '').trim();
|
|
818
|
-
state.workspacePath = String(detail.cwd || state.workspacePath || '').trim();
|
|
819
|
-
state.title = '';
|
|
820
|
-
state.target = '';
|
|
821
|
-
state.selectedEngine = continuedEngine;
|
|
822
|
-
state.workflowIdsText = continuedEngine === 'workflow'
|
|
823
|
-
? (Array.isArray(detail.plan && detail.plan.workflowIds) ? detail.plan.workflowIds.join('\n') : '')
|
|
824
|
-
: '';
|
|
825
|
-
state.runMode = detail.dryRun ? 'dry-run' : (detail.allowWrite ? 'write' : 'read');
|
|
826
|
-
state.notes = '';
|
|
827
|
-
state.followUpsText = '';
|
|
828
|
-
state.chatDraft = '';
|
|
829
|
-
state.plan = null;
|
|
830
|
-
state.planIssues = [];
|
|
831
|
-
state.planWarnings = [];
|
|
832
|
-
this.showMessage('已继承该任务的会话与工作区,可继续追加要求', 'success');
|
|
833
|
-
},
|
|
834
|
-
|
|
835
|
-
taskOrchestrationHasLiveActivity() {
|
|
836
|
-
const state = this.ensureTaskOrchestrationState();
|
|
837
|
-
const queue = Array.isArray(state.queue) ? state.queue : [];
|
|
838
|
-
if (queue.some((item) => isActiveStatus(item && (item.status || item.runStatus)))) {
|
|
839
|
-
return true;
|
|
840
|
-
}
|
|
841
|
-
const detail = state.selectedRunDetail;
|
|
842
|
-
const selectedStatus = detail && detail.run ? detail.run.status : '';
|
|
843
|
-
if (isActiveStatus(selectedStatus)) {
|
|
844
|
-
return true;
|
|
845
|
-
}
|
|
846
|
-
const runs = Array.isArray(state.runs) ? state.runs : [];
|
|
847
|
-
return runs.some((item) => isActiveStatus(item && item.status));
|
|
848
|
-
},
|
|
849
|
-
|
|
850
|
-
stopTaskOrchestrationPolling() {
|
|
851
|
-
if (this._taskOrchestrationPollTimer) {
|
|
852
|
-
clearTimeout(this._taskOrchestrationPollTimer);
|
|
853
|
-
this._taskOrchestrationPollTimer = 0;
|
|
854
|
-
}
|
|
855
|
-
},
|
|
856
|
-
|
|
857
|
-
syncTaskOrchestrationPolling() {
|
|
858
|
-
this.stopTaskOrchestrationPolling();
|
|
859
|
-
if (this.mainTab !== 'orchestration') {
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
if (!this.taskOrchestrationHasLiveActivity()) {
|
|
863
|
-
return;
|
|
864
|
-
}
|
|
865
|
-
this._taskOrchestrationPollTimer = setTimeout(async () => {
|
|
866
|
-
this._taskOrchestrationPollTimer = 0;
|
|
867
|
-
if (this.mainTab !== 'orchestration') {
|
|
868
|
-
return;
|
|
869
|
-
}
|
|
870
|
-
await this.loadTaskOrchestrationOverview({ silent: true, includeDetail: true });
|
|
871
|
-
}, 4000);
|
|
872
|
-
},
|
|
873
|
-
|
|
874
|
-
resetTaskOrchestrationDraft() {
|
|
875
|
-
const state = this.ensureTaskOrchestrationState();
|
|
876
|
-
state.target = '';
|
|
877
|
-
state.chatDraft = '';
|
|
878
|
-
state.title = '';
|
|
879
|
-
state.notes = '';
|
|
880
|
-
state.workspacePath = '';
|
|
881
|
-
state.threadId = '';
|
|
882
|
-
state.followUpsText = '';
|
|
883
|
-
state.workflowIdsText = '';
|
|
884
|
-
state.selectedEngine = 'openai-chat';
|
|
885
|
-
state.runMode = 'write';
|
|
886
|
-
state.concurrency = 2;
|
|
887
|
-
state.autoFixRounds = 1;
|
|
888
|
-
state.plan = null;
|
|
889
|
-
state.planIssues = [];
|
|
890
|
-
state.planWarnings = [];
|
|
891
|
-
state.lastError = '';
|
|
892
|
-
this.syncTaskOrchestrationPolling();
|
|
893
|
-
}
|
|
894
|
-
};
|
|
895
|
-
}
|