plugin-agent-orchestrator 1.0.20 → 1.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.
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +6 -6
- package/dist/server/collections/agent-execution-spans.js +24 -0
- package/dist/server/collections/agent-loop-runs.js +36 -0
- package/dist/server/collections/orchestrator-config.js +14 -0
- package/dist/server/migrations/20260601000000-add-token-fields.js +101 -0
- package/dist/server/plugin.js +56 -0
- package/dist/server/resources/agent-loop.js +33 -25
- package/dist/server/resources/tracing.js +5 -8
- package/dist/server/services/AgentHarness.js +56 -90
- package/dist/server/services/AgentLoopController.js +164 -125
- package/dist/server/services/AgentLoopRepository.js +16 -34
- package/dist/server/services/AgentLoopService.js +7 -1
- package/dist/server/services/AgentPlannerService.js +5 -25
- package/dist/server/services/AgentRegistryService.js +34 -24
- package/dist/server/services/CircuitBreaker.js +120 -0
- package/dist/server/services/ContextAggregator.js +201 -0
- package/dist/server/services/ExecutionSpanService.js +2 -5
- package/dist/server/services/RunEventBus.js +73 -0
- package/dist/server/services/TokenTracker.js +173 -0
- package/dist/server/tools/agent-loop.js +30 -63
- package/dist/server/tools/delegate-task.js +14 -72
- package/dist/server/tools/orchestrator-plan.js +10 -47
- package/dist/server/types.js +24 -0
- package/dist/server/utils/ctx-utils.js +152 -0
- package/dist/server/utils/logging.js +86 -0
- package/package.json +44 -44
- package/src/client/AgentRunsTab.tsx +764 -764
- package/src/client/HarnessProfilesTab.tsx +247 -247
- package/src/client/OrchestratorSettings.tsx +106 -106
- package/src/client/RulesTab.tsx +716 -716
- package/src/client/hooks/useRunEventStream.ts +76 -0
- package/src/client/index.tsx +2 -1
- package/src/client/plugin.tsx +27 -27
- package/src/client/skill-hub/components/LoopSettings.tsx +331 -331
- package/src/client/skill-hub/index.tsx +51 -51
- package/src/client/skill-hub/tools/InteractionSchemasProvider.tsx +99 -99
- package/src/client/skill-hub/tools/SkillHubCard.tsx +109 -109
- package/src/client/skill-hub/tools/loopTemplates.ts +52 -52
- package/src/client/skill-hub/tools/registerSkillLoopCards.ts +58 -58
- package/src/client/tools/PlanApprovalCard.tsx +175 -175
- package/src/client/tools/registerOrchestratorCards.ts +7 -7
- package/src/server/__tests__/agent-loop-controller.test.ts +375 -0
- package/src/server/__tests__/circuit-breaker.test.ts +169 -0
- package/src/server/__tests__/context-aggregator.test.ts +222 -0
- package/src/server/__tests__/parallel-execution.test.ts +318 -0
- package/src/server/__tests__/smoke.test.ts +120 -0
- package/src/server/collections/agent-execution-spans.ts +24 -0
- package/src/server/collections/agent-harness-profiles.ts +59 -59
- package/src/server/collections/agent-loop-events.ts +71 -71
- package/src/server/collections/agent-loop-runs.ts +38 -1
- package/src/server/collections/agent-loop-steps.ts +144 -144
- package/src/server/collections/orchestrator-config.ts +14 -0
- package/src/server/collections/skill-executions.ts +106 -106
- package/src/server/collections/skill-loop-configs.ts +65 -65
- package/src/server/migrations/20260524000000-add-agent-loop-fields-to-skill-executions.ts +30 -30
- package/src/server/migrations/20260524001000-add-plan-approval-and-harness-profiles.ts +142 -142
- package/src/server/migrations/20260601000000-add-token-fields.ts +89 -0
- package/src/server/plugin.ts +68 -0
- package/src/server/resources/agent-loop.ts +21 -12
- package/src/server/resources/tracing.ts +3 -7
- package/src/server/services/AgentHarness.ts +78 -116
- package/src/server/services/AgentLoopController.ts +197 -122
- package/src/server/services/AgentLoopRepository.ts +9 -25
- package/src/server/services/AgentLoopService.ts +13 -1
- package/src/server/services/AgentPlanValidator.ts +73 -73
- package/src/server/services/AgentPlannerService.ts +2 -25
- package/src/server/services/AgentRegistryService.ts +40 -31
- package/src/server/services/CircuitBreaker.ts +116 -0
- package/src/server/services/ContextAggregator.ts +239 -0
- package/src/server/services/ExecutionSpanService.ts +2 -4
- package/src/server/services/RunEventBus.ts +45 -0
- package/src/server/services/TokenTracker.ts +209 -0
- package/src/server/skill-hub/plugin.ts +898 -898
- package/src/server/skill-hub/tasks/SkillExecutionTask.ts +460 -460
- package/src/server/tools/agent-loop.ts +18 -57
- package/src/server/tools/delegate-task.ts +11 -93
- package/src/server/tools/orchestrator-plan.ts +26 -50
- package/src/server/tools/skill-execute.ts +160 -160
- package/src/server/types.ts +55 -0
- package/src/server/utils/ctx-utils.ts +118 -0
- package/src/server/utils/logging.ts +63 -0
- package/dist/client/AIEmployeeSelect.d.ts +0 -11
- package/dist/client/AIEmployeesContext.d.ts +0 -30
- package/dist/client/AgentRunsTab.d.ts +0 -2
- package/dist/client/HarnessProfilesTab.d.ts +0 -2
- package/dist/client/OrchestratorSettings.d.ts +0 -3
- package/dist/client/RulesTab.d.ts +0 -2
- package/dist/client/TracingTab.d.ts +0 -2
- package/dist/client/index.d.ts +0 -1
- package/dist/client/plugin.d.ts +0 -6
- package/dist/client/skill-hub/components/ExecutionHistory.d.ts +0 -2
- package/dist/client/skill-hub/components/ExecutionProgress.d.ts +0 -20
- package/dist/client/skill-hub/components/GitSkillImport.d.ts +0 -7
- package/dist/client/skill-hub/components/LoopSettings.d.ts +0 -2
- package/dist/client/skill-hub/components/SkillEditor.d.ts +0 -7
- package/dist/client/skill-hub/components/SkillManager.d.ts +0 -2
- package/dist/client/skill-hub/components/SkillMetrics.d.ts +0 -2
- package/dist/client/skill-hub/components/SkillTestPanel.d.ts +0 -7
- package/dist/client/skill-hub/index.d.ts +0 -11
- package/dist/client/skill-hub/locale.d.ts +0 -3
- package/dist/client/skill-hub/tools/InteractionSchemasProvider.d.ts +0 -6
- package/dist/client/skill-hub/tools/SkillHubCard.d.ts +0 -3
- package/dist/client/skill-hub/tools/loopTemplates.d.ts +0 -22
- package/dist/client/skill-hub/tools/registerSkillLoopCards.d.ts +0 -1
- package/dist/client/skill-hub/utils/jsonFields.d.ts +0 -3
- package/dist/client/tools/PlanApprovalCard.d.ts +0 -3
- package/dist/client/tools/registerOrchestratorCards.d.ts +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/server/collections/agent-execution-spans.d.ts +0 -9
- package/dist/server/collections/agent-harness-profiles.d.ts +0 -2
- package/dist/server/collections/agent-loop-events.d.ts +0 -2
- package/dist/server/collections/agent-loop-runs.d.ts +0 -2
- package/dist/server/collections/agent-loop-steps.d.ts +0 -2
- package/dist/server/collections/orchestrator-config.d.ts +0 -2
- package/dist/server/collections/orchestrator-logs.d.ts +0 -8
- package/dist/server/collections/skill-definitions.d.ts +0 -3
- package/dist/server/collections/skill-executions.d.ts +0 -3
- package/dist/server/collections/skill-loop-configs.d.ts +0 -3
- package/dist/server/collections/skill-worker-configs.d.ts +0 -3
- package/dist/server/index.d.ts +0 -1
- package/dist/server/migrations/20260423000000-add-progress-fields.d.ts +0 -4
- package/dist/server/migrations/20260425000000-add-interaction-schema.d.ts +0 -4
- package/dist/server/migrations/20260427000000-add-tracing-detail-fields.d.ts +0 -7
- package/dist/server/migrations/20260427000000-change-packages-to-text.d.ts +0 -4
- package/dist/server/migrations/20260427000001-change-other-json-to-text.d.ts +0 -4
- package/dist/server/migrations/20260429000000-add-llm-fields.d.ts +0 -7
- package/dist/server/migrations/20260429000000-fix-inputargs-json-to-text.d.ts +0 -16
- package/dist/server/migrations/20260503000000-add-orchestrator-trace-fields.d.ts +0 -7
- package/dist/server/migrations/20260524000000-add-agent-loop-fields-to-skill-executions.d.ts +0 -7
- package/dist/server/migrations/20260524001000-add-plan-approval-and-harness-profiles.d.ts +0 -12
- package/dist/server/plugin.d.ts +0 -16
- package/dist/server/resources/agent-loop.d.ts +0 -3
- package/dist/server/resources/tracing.d.ts +0 -7
- package/dist/server/services/AgentHarness.d.ts +0 -42
- package/dist/server/services/AgentLoopController.d.ts +0 -205
- package/dist/server/services/AgentLoopRepository.d.ts +0 -20
- package/dist/server/services/AgentLoopService.d.ts +0 -149
- package/dist/server/services/AgentPlanValidator.d.ts +0 -4
- package/dist/server/services/AgentPlannerService.d.ts +0 -8
- package/dist/server/services/AgentRegistryService.d.ts +0 -13
- package/dist/server/services/CodeValidator.d.ts +0 -32
- package/dist/server/services/ExecutionSpanService.d.ts +0 -46
- package/dist/server/services/FileManager.d.ts +0 -28
- package/dist/server/services/SandboxRunner.d.ts +0 -41
- package/dist/server/services/SkillManager.d.ts +0 -6
- package/dist/server/services/SkillRepositoryService.d.ts +0 -22
- package/dist/server/services/WorkerEnvManager.d.ts +0 -26
- package/dist/server/skill-hub/actions/git-import.d.ts +0 -21
- package/dist/server/skill-hub/mcp/McpController.d.ts +0 -15
- package/dist/server/skill-hub/plugin.d.ts +0 -61
- package/dist/server/skill-hub/tasks/SkillExecutionTask.d.ts +0 -16
- package/dist/server/skill-hub/utils/json-fields.d.ts +0 -7
- package/dist/server/tools/agent-loop.d.ts +0 -235
- package/dist/server/tools/delegate-task.d.ts +0 -19
- package/dist/server/tools/external-rag-search.d.ts +0 -42
- package/dist/server/tools/orchestrator-plan.d.ts +0 -205
- package/dist/server/tools/skill-execute.d.ts +0 -36
|
@@ -1,764 +1,764 @@
|
|
|
1
|
-
import React, { useMemo, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Alert,
|
|
4
|
-
Button,
|
|
5
|
-
Card,
|
|
6
|
-
Collapse,
|
|
7
|
-
Descriptions,
|
|
8
|
-
Drawer,
|
|
9
|
-
Empty,
|
|
10
|
-
Form,
|
|
11
|
-
message,
|
|
12
|
-
Popconfirm,
|
|
13
|
-
Select,
|
|
14
|
-
Space,
|
|
15
|
-
Spin,
|
|
16
|
-
Table,
|
|
17
|
-
Tag,
|
|
18
|
-
Timeline,
|
|
19
|
-
Typography,
|
|
20
|
-
} from 'antd';
|
|
21
|
-
import {
|
|
22
|
-
BranchesOutlined,
|
|
23
|
-
CheckCircleOutlined,
|
|
24
|
-
ClockCircleOutlined,
|
|
25
|
-
CloseCircleOutlined,
|
|
26
|
-
EyeOutlined,
|
|
27
|
-
PauseCircleOutlined,
|
|
28
|
-
PlayCircleOutlined,
|
|
29
|
-
RedoOutlined,
|
|
30
|
-
ReloadOutlined,
|
|
31
|
-
StopOutlined,
|
|
32
|
-
} from '@ant-design/icons';
|
|
33
|
-
import { useAPIClient, useRequest } from '@nocobase/client';
|
|
34
|
-
import { useAIEmployees } from './AIEmployeesContext';
|
|
35
|
-
import { parseJsonText } from './skill-hub/utils/jsonFields';
|
|
36
|
-
|
|
37
|
-
const { Paragraph, Text } = Typography;
|
|
38
|
-
|
|
39
|
-
type FilterState = {
|
|
40
|
-
leader?: string;
|
|
41
|
-
status?: string;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const terminalRunStatuses = new Set(['succeeded', 'failed', 'rejected', 'canceled']);
|
|
45
|
-
|
|
46
|
-
function statusColor(status?: string) {
|
|
47
|
-
switch (status) {
|
|
48
|
-
case 'succeeded':
|
|
49
|
-
case 'success':
|
|
50
|
-
return 'success';
|
|
51
|
-
case 'failed':
|
|
52
|
-
case 'error':
|
|
53
|
-
return 'error';
|
|
54
|
-
case 'waiting_user':
|
|
55
|
-
case 'waiting_plan_approval':
|
|
56
|
-
case 'needs_replan':
|
|
57
|
-
return 'warning';
|
|
58
|
-
case 'approved':
|
|
59
|
-
case 'running':
|
|
60
|
-
case 'planning':
|
|
61
|
-
return 'processing';
|
|
62
|
-
case 'rejected':
|
|
63
|
-
case 'canceled':
|
|
64
|
-
case 'skipped':
|
|
65
|
-
return 'default';
|
|
66
|
-
default:
|
|
67
|
-
return 'default';
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function statusIcon(status?: string) {
|
|
72
|
-
switch (status) {
|
|
73
|
-
case 'succeeded':
|
|
74
|
-
case 'success':
|
|
75
|
-
return <CheckCircleOutlined />;
|
|
76
|
-
case 'failed':
|
|
77
|
-
case 'error':
|
|
78
|
-
return <CloseCircleOutlined />;
|
|
79
|
-
case 'waiting_user':
|
|
80
|
-
case 'waiting_plan_approval':
|
|
81
|
-
case 'needs_replan':
|
|
82
|
-
return <PauseCircleOutlined />;
|
|
83
|
-
case 'approved':
|
|
84
|
-
case 'running':
|
|
85
|
-
case 'planning':
|
|
86
|
-
return <ClockCircleOutlined />;
|
|
87
|
-
default:
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function timelineColor(status?: string) {
|
|
93
|
-
switch (status) {
|
|
94
|
-
case 'succeeded':
|
|
95
|
-
case 'success':
|
|
96
|
-
return 'green';
|
|
97
|
-
case 'failed':
|
|
98
|
-
case 'error':
|
|
99
|
-
return 'red';
|
|
100
|
-
case 'waiting_user':
|
|
101
|
-
case 'waiting_plan_approval':
|
|
102
|
-
case 'needs_replan':
|
|
103
|
-
return 'orange';
|
|
104
|
-
case 'approved':
|
|
105
|
-
case 'running':
|
|
106
|
-
case 'planning':
|
|
107
|
-
return 'blue';
|
|
108
|
-
default:
|
|
109
|
-
return 'gray';
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function StatusTag({ status }: { status?: string }) {
|
|
114
|
-
return (
|
|
115
|
-
<Tag icon={statusIcon(status)} color={statusColor(status)}>
|
|
116
|
-
{status || '-'}
|
|
117
|
-
</Tag>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function formatDate(value?: string) {
|
|
122
|
-
return value ? new Date(value).toLocaleString() : '-';
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function formatDuration(start?: string, end?: string) {
|
|
126
|
-
if (!start) return '-';
|
|
127
|
-
const startMs = new Date(start).getTime();
|
|
128
|
-
const endMs = end ? new Date(end).getTime() : Date.now();
|
|
129
|
-
const diff = Math.max(0, endMs - startMs);
|
|
130
|
-
if (diff >= 60000) return `${Math.round(diff / 60000)}m`;
|
|
131
|
-
if (diff >= 1000) return `${(diff / 1000).toFixed(1)}s`;
|
|
132
|
-
return `${diff}ms`;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function formatJson(value: any) {
|
|
136
|
-
if (value === undefined || value === null || value === '') return '';
|
|
137
|
-
if (typeof value === 'string') return value;
|
|
138
|
-
try {
|
|
139
|
-
return JSON.stringify(value, null, 2);
|
|
140
|
-
} catch {
|
|
141
|
-
return String(value);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function buildSkillFileUrl(execution: any, file: any) {
|
|
146
|
-
if (file?.downloadUrl) return file.downloadUrl;
|
|
147
|
-
if (!execution?.id || !file?.name) return '';
|
|
148
|
-
return `/api/skillHub:download?execId=${execution.id}&filename=${encodeURIComponent(file.name)}`;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function renderSkillFileLink(execution: any, file: any, index: number) {
|
|
152
|
-
const url = buildSkillFileUrl(execution, file);
|
|
153
|
-
const label = file.name || file.path || `file-${index + 1}`;
|
|
154
|
-
return url ? (
|
|
155
|
-
<a key={index} href={url} target="_blank" rel="noreferrer">
|
|
156
|
-
{label}
|
|
157
|
-
</a>
|
|
158
|
-
) : (
|
|
159
|
-
<Text key={index}>{label}</Text>
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function TextBlock({ value, rows = 10 }: { value: any; rows?: number }) {
|
|
164
|
-
const text = formatJson(value);
|
|
165
|
-
if (!text) return <Text type="secondary">-</Text>;
|
|
166
|
-
return (
|
|
167
|
-
<Paragraph
|
|
168
|
-
style={{ whiteSpace: 'pre-wrap', wordBreak: 'break-word', margin: 0, fontSize: 12 }}
|
|
169
|
-
ellipsis={{ rows, expandable: true }}
|
|
170
|
-
>
|
|
171
|
-
{text}
|
|
172
|
-
</Paragraph>
|
|
173
|
-
);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export const AgentRunsTab: React.FC = () => {
|
|
177
|
-
const api = useAPIClient();
|
|
178
|
-
const { employees, employeeMap } = useAIEmployees();
|
|
179
|
-
const [filters, setFilters] = useState<FilterState>({});
|
|
180
|
-
const [page, setPage] = useState(1);
|
|
181
|
-
const [pageSize, setPageSize] = useState(20);
|
|
182
|
-
const [selectedRun, setSelectedRun] = useState<any>(null);
|
|
183
|
-
const [detail, setDetail] = useState<any>(null);
|
|
184
|
-
const [detailLoading, setDetailLoading] = useState(false);
|
|
185
|
-
const [actionLoading, setActionLoading] = useState(false);
|
|
186
|
-
|
|
187
|
-
const requestParams = useMemo(() => {
|
|
188
|
-
const filter: any = {};
|
|
189
|
-
if (filters.leader) filter.leaderUsername = filters.leader;
|
|
190
|
-
if (filters.status) filter.status = filters.status;
|
|
191
|
-
return {
|
|
192
|
-
sort: ['-createdAt'],
|
|
193
|
-
page,
|
|
194
|
-
pageSize,
|
|
195
|
-
filter,
|
|
196
|
-
};
|
|
197
|
-
}, [filters, page, pageSize]);
|
|
198
|
-
|
|
199
|
-
const { data, loading, refresh } = useRequest(
|
|
200
|
-
{
|
|
201
|
-
url: 'agentLoops:list',
|
|
202
|
-
params: requestParams,
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
refreshDeps: [requestParams],
|
|
206
|
-
},
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
const runs = useMemo(() => {
|
|
210
|
-
const rows = (data as any)?.data;
|
|
211
|
-
return Array.isArray(rows) ? rows : [];
|
|
212
|
-
}, [data]);
|
|
213
|
-
|
|
214
|
-
const total = useMemo(() => {
|
|
215
|
-
const count = (data as any)?.meta?.count;
|
|
216
|
-
return typeof count === 'number' ? count : 0;
|
|
217
|
-
}, [data]);
|
|
218
|
-
|
|
219
|
-
const employeeOptions = useMemo(
|
|
220
|
-
() =>
|
|
221
|
-
employees.map((employee) => ({
|
|
222
|
-
label: employee.nickname || employee.username,
|
|
223
|
-
value: employee.username,
|
|
224
|
-
})),
|
|
225
|
-
[employees],
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
const fetchDetail = async (runId: string | number, seed?: any) => {
|
|
229
|
-
setSelectedRun(seed || selectedRun || { id: runId });
|
|
230
|
-
setDetailLoading(true);
|
|
231
|
-
try {
|
|
232
|
-
const res = await api.request({
|
|
233
|
-
url: 'agentLoops:get',
|
|
234
|
-
params: { filterByTk: runId },
|
|
235
|
-
});
|
|
236
|
-
setDetail((res as any)?.data?.data || (res as any)?.data || null);
|
|
237
|
-
} finally {
|
|
238
|
-
setDetailLoading(false);
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
const updateFilter = (patch: Partial<FilterState>) => {
|
|
243
|
-
setFilters((prev) => ({ ...prev, ...patch }));
|
|
244
|
-
setPage(1);
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
const resetFilters = () => {
|
|
248
|
-
setFilters({});
|
|
249
|
-
setPage(1);
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
const runAction = async (action: 'cancel' | 'resume', runId: string | number) => {
|
|
253
|
-
setActionLoading(true);
|
|
254
|
-
try {
|
|
255
|
-
await api.request({
|
|
256
|
-
url: action === 'cancel' ? 'agentLoops:cancel' : 'agentLoops:resume',
|
|
257
|
-
method: 'POST',
|
|
258
|
-
data: action === 'cancel' ? { runId } : { runId, stepId: detail?.run?.currentStepId, approved: true },
|
|
259
|
-
});
|
|
260
|
-
message.success(action === 'cancel' ? 'Run canceled' : 'Run resumed');
|
|
261
|
-
refresh();
|
|
262
|
-
await fetchDetail(runId);
|
|
263
|
-
} catch (error: any) {
|
|
264
|
-
message.error(error?.message || `Failed to ${action} run`);
|
|
265
|
-
} finally {
|
|
266
|
-
setActionLoading(false);
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
const retryStep = async (stepId: string | number) => {
|
|
271
|
-
const runId = detail?.run?.id || selectedRun?.id;
|
|
272
|
-
setActionLoading(true);
|
|
273
|
-
try {
|
|
274
|
-
await api.request({
|
|
275
|
-
url: 'agentLoops:retryStep',
|
|
276
|
-
method: 'POST',
|
|
277
|
-
data: { stepId },
|
|
278
|
-
});
|
|
279
|
-
message.success('Step queued for retry');
|
|
280
|
-
refresh();
|
|
281
|
-
if (runId) await fetchDetail(runId);
|
|
282
|
-
} catch (error: any) {
|
|
283
|
-
message.error(error?.message || 'Failed to retry step');
|
|
284
|
-
} finally {
|
|
285
|
-
setActionLoading(false);
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
const columns = [
|
|
290
|
-
{
|
|
291
|
-
title: 'Time',
|
|
292
|
-
dataIndex: 'createdAt',
|
|
293
|
-
key: 'createdAt',
|
|
294
|
-
width: 170,
|
|
295
|
-
render: formatDate,
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
title: 'Leader',
|
|
299
|
-
dataIndex: 'leaderUsername',
|
|
300
|
-
key: 'leaderUsername',
|
|
301
|
-
width: 160,
|
|
302
|
-
render: (username: string) => <Tag color="blue">{employeeMap.get(username) || username || '-'}</Tag>,
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
title: 'Goal',
|
|
306
|
-
dataIndex: 'goal',
|
|
307
|
-
key: 'goal',
|
|
308
|
-
render: (goal: string) => (
|
|
309
|
-
<Text ellipsis style={{ maxWidth: 380 }}>
|
|
310
|
-
{goal || '-'}
|
|
311
|
-
</Text>
|
|
312
|
-
),
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
title: 'Status',
|
|
316
|
-
dataIndex: 'status',
|
|
317
|
-
key: 'status',
|
|
318
|
-
width: 130,
|
|
319
|
-
render: (status: string) => <StatusTag status={status} />,
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
title: 'Iterations',
|
|
323
|
-
dataIndex: 'iterationCount',
|
|
324
|
-
key: 'iterationCount',
|
|
325
|
-
width: 90,
|
|
326
|
-
render: (value: number) => value ?? 0,
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
title: 'Duration',
|
|
330
|
-
key: 'duration',
|
|
331
|
-
width: 100,
|
|
332
|
-
render: (_: any, record: any) => formatDuration(record.startedAt || record.createdAt, record.endedAt),
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
title: '',
|
|
336
|
-
key: 'actions',
|
|
337
|
-
width: 90,
|
|
338
|
-
render: (_: any, record: any) => (
|
|
339
|
-
<Button type="link" size="small" icon={<EyeOutlined />} onClick={() => fetchDetail(record.id, record)}>
|
|
340
|
-
Detail
|
|
341
|
-
</Button>
|
|
342
|
-
),
|
|
343
|
-
},
|
|
344
|
-
];
|
|
345
|
-
|
|
346
|
-
const steps = Array.isArray(detail?.steps) ? detail.steps : [];
|
|
347
|
-
const events = Array.isArray(detail?.events) ? detail.events : [];
|
|
348
|
-
const spans = Array.isArray(detail?.spans) ? detail.spans : [];
|
|
349
|
-
const skillExecutions = Array.isArray(detail?.skillExecutions) ? detail.skillExecutions : [];
|
|
350
|
-
const run = detail?.run || selectedRun;
|
|
351
|
-
const hasFilters = Boolean(filters.leader || filters.status);
|
|
352
|
-
|
|
353
|
-
const stepColumns = [
|
|
354
|
-
{
|
|
355
|
-
title: '#',
|
|
356
|
-
dataIndex: 'index',
|
|
357
|
-
key: 'index',
|
|
358
|
-
width: 56,
|
|
359
|
-
render: (value: number) => Number(value ?? 0) + 1,
|
|
360
|
-
},
|
|
361
|
-
{
|
|
362
|
-
title: 'Status',
|
|
363
|
-
dataIndex: 'status',
|
|
364
|
-
key: 'status',
|
|
365
|
-
width: 130,
|
|
366
|
-
render: (status: string) => <StatusTag status={status} />,
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
title: 'Type',
|
|
370
|
-
dataIndex: 'type',
|
|
371
|
-
key: 'type',
|
|
372
|
-
width: 110,
|
|
373
|
-
render: (type: string) => <Tag>{type}</Tag>,
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
title: 'Step',
|
|
377
|
-
key: 'step',
|
|
378
|
-
render: (_: any, record: any) => (
|
|
379
|
-
<Space direction="vertical" size={2} style={{ width: '100%' }}>
|
|
380
|
-
<Text strong>{record.title || record.planKey}</Text>
|
|
381
|
-
{record.description && <Text type="secondary">{record.description}</Text>}
|
|
382
|
-
{record.target && <Text code>{record.target}</Text>}
|
|
383
|
-
</Space>
|
|
384
|
-
),
|
|
385
|
-
},
|
|
386
|
-
{
|
|
387
|
-
title: 'Depends',
|
|
388
|
-
dataIndex: 'dependsOn',
|
|
389
|
-
key: 'dependsOn',
|
|
390
|
-
width: 130,
|
|
391
|
-
render: (dependsOn: string[]) =>
|
|
392
|
-
Array.isArray(dependsOn) && dependsOn.length ? dependsOn.map((key) => <Tag key={key}>{key}</Tag>) : '-',
|
|
393
|
-
},
|
|
394
|
-
{
|
|
395
|
-
title: 'Attempts',
|
|
396
|
-
key: 'attempts',
|
|
397
|
-
width: 90,
|
|
398
|
-
render: (_: any, record: any) => `${record.attempt || 0}/${record.maxAttempts || 0}`,
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
title: '',
|
|
402
|
-
key: 'actions',
|
|
403
|
-
width: 90,
|
|
404
|
-
render: (_: any, record: any) =>
|
|
405
|
-
record.status === 'failed' && Number(record.attempt || 0) < Number(record.maxAttempts || 0) ? (
|
|
406
|
-
<Button
|
|
407
|
-
type="link"
|
|
408
|
-
size="small"
|
|
409
|
-
icon={<RedoOutlined />}
|
|
410
|
-
loading={actionLoading}
|
|
411
|
-
onClick={() => retryStep(record.id)}
|
|
412
|
-
>
|
|
413
|
-
Retry
|
|
414
|
-
</Button>
|
|
415
|
-
) : null,
|
|
416
|
-
},
|
|
417
|
-
];
|
|
418
|
-
|
|
419
|
-
return (
|
|
420
|
-
<div>
|
|
421
|
-
<Alert
|
|
422
|
-
type="info"
|
|
423
|
-
showIcon
|
|
424
|
-
style={{ marginBottom: 16 }}
|
|
425
|
-
message="Agent Runs"
|
|
426
|
-
description={
|
|
427
|
-
<Text type="secondary">
|
|
428
|
-
Persistent loop runs created by the orchestrator tools. Each run stores the goal, plan, step state,
|
|
429
|
-
approvals, and linked Skill Hub or sub-agent traces.
|
|
430
|
-
</Text>
|
|
431
|
-
}
|
|
432
|
-
/>
|
|
433
|
-
|
|
434
|
-
<Card bordered={false}>
|
|
435
|
-
<Form layout="inline" style={{ marginBottom: 16, rowGap: 8, flexWrap: 'wrap' }}>
|
|
436
|
-
<Form.Item label="Leader">
|
|
437
|
-
<Select
|
|
438
|
-
allowClear
|
|
439
|
-
showSearch
|
|
440
|
-
optionFilterProp="label"
|
|
441
|
-
placeholder="Any leader"
|
|
442
|
-
style={{ minWidth: 180 }}
|
|
443
|
-
options={employeeOptions}
|
|
444
|
-
value={filters.leader}
|
|
445
|
-
onChange={(value) => updateFilter({ leader: value })}
|
|
446
|
-
/>
|
|
447
|
-
</Form.Item>
|
|
448
|
-
<Form.Item label="Status">
|
|
449
|
-
<Select
|
|
450
|
-
allowClear
|
|
451
|
-
placeholder="Any status"
|
|
452
|
-
style={{ minWidth: 160 }}
|
|
453
|
-
value={filters.status}
|
|
454
|
-
onChange={(value) => updateFilter({ status: value })}
|
|
455
|
-
options={[
|
|
456
|
-
{ label: 'Planning', value: 'planning' },
|
|
457
|
-
{ label: 'Waiting plan approval', value: 'waiting_plan_approval' },
|
|
458
|
-
{ label: 'Approved', value: 'approved' },
|
|
459
|
-
{ label: 'Running', value: 'running' },
|
|
460
|
-
{ label: 'Waiting user', value: 'waiting_user' },
|
|
461
|
-
{ label: 'Needs replan', value: 'needs_replan' },
|
|
462
|
-
{ label: 'Succeeded', value: 'succeeded' },
|
|
463
|
-
{ label: 'Failed', value: 'failed' },
|
|
464
|
-
{ label: 'Rejected', value: 'rejected' },
|
|
465
|
-
{ label: 'Canceled', value: 'canceled' },
|
|
466
|
-
]}
|
|
467
|
-
/>
|
|
468
|
-
</Form.Item>
|
|
469
|
-
<Form.Item>
|
|
470
|
-
<Space>
|
|
471
|
-
<Button onClick={resetFilters} disabled={!hasFilters}>
|
|
472
|
-
Reset
|
|
473
|
-
</Button>
|
|
474
|
-
<Button icon={<ReloadOutlined />} onClick={refresh}>
|
|
475
|
-
Refresh
|
|
476
|
-
</Button>
|
|
477
|
-
</Space>
|
|
478
|
-
</Form.Item>
|
|
479
|
-
</Form>
|
|
480
|
-
|
|
481
|
-
<Table
|
|
482
|
-
rowKey="id"
|
|
483
|
-
loading={loading}
|
|
484
|
-
dataSource={runs}
|
|
485
|
-
columns={columns}
|
|
486
|
-
pagination={{
|
|
487
|
-
current: page,
|
|
488
|
-
pageSize,
|
|
489
|
-
total,
|
|
490
|
-
showSizeChanger: true,
|
|
491
|
-
pageSizeOptions: [10, 20, 50, 100],
|
|
492
|
-
showTotal: (count) => `${count} run${count === 1 ? '' : 's'}`,
|
|
493
|
-
onChange: (nextPage, nextSize) => {
|
|
494
|
-
setPage(nextPage);
|
|
495
|
-
if (nextSize && nextSize !== pageSize) setPageSize(nextSize);
|
|
496
|
-
},
|
|
497
|
-
}}
|
|
498
|
-
locale={{
|
|
499
|
-
emptyText: <Empty description={hasFilters ? 'No runs match the current filters' : 'No agent runs yet'} />,
|
|
500
|
-
}}
|
|
501
|
-
/>
|
|
502
|
-
</Card>
|
|
503
|
-
|
|
504
|
-
<Drawer
|
|
505
|
-
title="Agent Run Detail"
|
|
506
|
-
width={980}
|
|
507
|
-
onClose={() => {
|
|
508
|
-
setSelectedRun(null);
|
|
509
|
-
setDetail(null);
|
|
510
|
-
}}
|
|
511
|
-
open={!!selectedRun}
|
|
512
|
-
>
|
|
513
|
-
{run && (
|
|
514
|
-
<Spin spinning={detailLoading}>
|
|
515
|
-
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
|
516
|
-
<Space wrap>
|
|
517
|
-
<Button icon={<ReloadOutlined />} onClick={() => fetchDetail(run.id)} loading={detailLoading}>
|
|
518
|
-
Refresh
|
|
519
|
-
</Button>
|
|
520
|
-
{run.status === 'waiting_user' && (
|
|
521
|
-
<Button
|
|
522
|
-
type="primary"
|
|
523
|
-
icon={<PlayCircleOutlined />}
|
|
524
|
-
loading={actionLoading}
|
|
525
|
-
onClick={() => runAction('resume', run.id)}
|
|
526
|
-
>
|
|
527
|
-
Resume
|
|
528
|
-
</Button>
|
|
529
|
-
)}
|
|
530
|
-
{!terminalRunStatuses.has(run.status) && (
|
|
531
|
-
<Popconfirm title="Cancel this run?" onConfirm={() => runAction('cancel', run.id)}>
|
|
532
|
-
<Button danger icon={<StopOutlined />} loading={actionLoading}>
|
|
533
|
-
Cancel run
|
|
534
|
-
</Button>
|
|
535
|
-
</Popconfirm>
|
|
536
|
-
)}
|
|
537
|
-
</Space>
|
|
538
|
-
|
|
539
|
-
<Descriptions bordered size="small" column={2}>
|
|
540
|
-
<Descriptions.Item label="Status">
|
|
541
|
-
<StatusTag status={run.status} />
|
|
542
|
-
</Descriptions.Item>
|
|
543
|
-
<Descriptions.Item label="Leader">
|
|
544
|
-
<Tag color="blue">{employeeMap.get(run.leaderUsername) || run.leaderUsername || '-'}</Tag>
|
|
545
|
-
</Descriptions.Item>
|
|
546
|
-
<Descriptions.Item label="Root run">
|
|
547
|
-
<Text code>{run.rootRunId || '-'}</Text>
|
|
548
|
-
</Descriptions.Item>
|
|
549
|
-
<Descriptions.Item label="Current step">
|
|
550
|
-
<Text code>{run.currentStepId || '-'}</Text>
|
|
551
|
-
</Descriptions.Item>
|
|
552
|
-
<Descriptions.Item label="Iterations">{run.iterationCount || 0}</Descriptions.Item>
|
|
553
|
-
<Descriptions.Item label="Approval">{run.approvalStatus || '-'}</Descriptions.Item>
|
|
554
|
-
<Descriptions.Item label="Plan version">{run.planVersion || '-'}</Descriptions.Item>
|
|
555
|
-
<Descriptions.Item label="Harness">{run.metadata?.harnessTag || '-'}</Descriptions.Item>
|
|
556
|
-
<Descriptions.Item label="Duration">
|
|
557
|
-
{formatDuration(run.startedAt || run.createdAt, run.endedAt)}
|
|
558
|
-
</Descriptions.Item>
|
|
559
|
-
<Descriptions.Item label="Started">{formatDate(run.startedAt || run.createdAt)}</Descriptions.Item>
|
|
560
|
-
<Descriptions.Item label="Ended">{formatDate(run.endedAt)}</Descriptions.Item>
|
|
561
|
-
</Descriptions>
|
|
562
|
-
|
|
563
|
-
<Card title="Goal" size="small">
|
|
564
|
-
<TextBlock value={run.goal} rows={6} />
|
|
565
|
-
</Card>
|
|
566
|
-
|
|
567
|
-
<Card title="Plan" size="small" extra={<BranchesOutlined />}>
|
|
568
|
-
<Table
|
|
569
|
-
rowKey="id"
|
|
570
|
-
size="small"
|
|
571
|
-
dataSource={steps}
|
|
572
|
-
columns={stepColumns}
|
|
573
|
-
pagination={false}
|
|
574
|
-
expandable={{
|
|
575
|
-
expandedRowRender: (record: any) => (
|
|
576
|
-
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
|
577
|
-
<Card size="small" title="Input">
|
|
578
|
-
<TextBlock value={record.input} rows={8} />
|
|
579
|
-
</Card>
|
|
580
|
-
<Card size="small" title="Output">
|
|
581
|
-
<TextBlock value={record.output} rows={8} />
|
|
582
|
-
</Card>
|
|
583
|
-
{record.approval && Object.keys(record.approval).length > 0 && (
|
|
584
|
-
<Card size="small" title="Approval">
|
|
585
|
-
<TextBlock value={record.approval} rows={8} />
|
|
586
|
-
</Card>
|
|
587
|
-
)}
|
|
588
|
-
{record.error && (
|
|
589
|
-
<Card size="small" title="Error" style={{ borderColor: '#ffa39e' }}>
|
|
590
|
-
<TextBlock value={record.error} rows={8} />
|
|
591
|
-
</Card>
|
|
592
|
-
)}
|
|
593
|
-
</Space>
|
|
594
|
-
),
|
|
595
|
-
}}
|
|
596
|
-
locale={{ emptyText: <Empty description="No plan steps" /> }}
|
|
597
|
-
/>
|
|
598
|
-
</Card>
|
|
599
|
-
|
|
600
|
-
<Card title="Event Timeline" size="small">
|
|
601
|
-
{events.length ? (
|
|
602
|
-
<Timeline
|
|
603
|
-
items={events.map((event: any) => ({
|
|
604
|
-
key: event.id,
|
|
605
|
-
color: timelineColor(event.status),
|
|
606
|
-
children: (
|
|
607
|
-
<Space direction="vertical" size={2} style={{ width: '100%' }}>
|
|
608
|
-
<Space wrap>
|
|
609
|
-
<Text strong>{event.title || event.type}</Text>
|
|
610
|
-
<StatusTag status={event.status} />
|
|
611
|
-
{event.stepId && <Text type="secondary">step #{event.stepId}</Text>}
|
|
612
|
-
</Space>
|
|
613
|
-
<Text type="secondary">{formatDate(event.createdAt)}</Text>
|
|
614
|
-
{event.content && <TextBlock value={event.content} rows={4} />}
|
|
615
|
-
</Space>
|
|
616
|
-
),
|
|
617
|
-
}))}
|
|
618
|
-
/>
|
|
619
|
-
) : (
|
|
620
|
-
<Empty description="No events captured" />
|
|
621
|
-
)}
|
|
622
|
-
</Card>
|
|
623
|
-
|
|
624
|
-
<Collapse
|
|
625
|
-
items={[
|
|
626
|
-
{
|
|
627
|
-
key: 'spans',
|
|
628
|
-
label: `Linked spans (${spans.length})`,
|
|
629
|
-
children: spans.length ? (
|
|
630
|
-
<Table
|
|
631
|
-
rowKey="id"
|
|
632
|
-
size="small"
|
|
633
|
-
dataSource={spans}
|
|
634
|
-
pagination={false}
|
|
635
|
-
columns={[
|
|
636
|
-
{
|
|
637
|
-
title: 'Type',
|
|
638
|
-
dataIndex: 'type',
|
|
639
|
-
key: 'type',
|
|
640
|
-
width: 110,
|
|
641
|
-
render: (value: string) => <Tag>{value}</Tag>,
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
title: 'Status',
|
|
645
|
-
dataIndex: 'status',
|
|
646
|
-
key: 'status',
|
|
647
|
-
width: 110,
|
|
648
|
-
render: (value: string) => <StatusTag status={value} />,
|
|
649
|
-
},
|
|
650
|
-
{ title: 'Title', dataIndex: 'title', key: 'title' },
|
|
651
|
-
{
|
|
652
|
-
title: 'Tool',
|
|
653
|
-
dataIndex: 'toolName',
|
|
654
|
-
key: 'toolName',
|
|
655
|
-
render: (value: string) => (value ? <Text code>{value}</Text> : '-'),
|
|
656
|
-
},
|
|
657
|
-
{
|
|
658
|
-
title: 'Duration',
|
|
659
|
-
dataIndex: 'durationMs',
|
|
660
|
-
key: 'durationMs',
|
|
661
|
-
width: 100,
|
|
662
|
-
render: (value: number) => (value ? `${value}ms` : '-'),
|
|
663
|
-
},
|
|
664
|
-
{
|
|
665
|
-
title: 'Skill Exec',
|
|
666
|
-
dataIndex: 'skillExecutionId',
|
|
667
|
-
key: 'skillExecutionId',
|
|
668
|
-
width: 110,
|
|
669
|
-
render: (value: any) => value || '-',
|
|
670
|
-
},
|
|
671
|
-
]}
|
|
672
|
-
/>
|
|
673
|
-
) : (
|
|
674
|
-
<Empty description="No linked spans" />
|
|
675
|
-
),
|
|
676
|
-
},
|
|
677
|
-
{
|
|
678
|
-
key: 'skills',
|
|
679
|
-
label: `Skill executions (${skillExecutions.length})`,
|
|
680
|
-
children: skillExecutions.length ? (
|
|
681
|
-
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
|
682
|
-
{skillExecutions.map((execution: any) => {
|
|
683
|
-
const files = parseJsonText<any[]>(execution.outputFiles, []);
|
|
684
|
-
return (
|
|
685
|
-
<Card
|
|
686
|
-
key={execution.id}
|
|
687
|
-
size="small"
|
|
688
|
-
title={
|
|
689
|
-
<Space wrap>
|
|
690
|
-
<Text>Skill execution #{execution.id}</Text>
|
|
691
|
-
<StatusTag status={execution.status} />
|
|
692
|
-
{execution.agentLoopStepId && (
|
|
693
|
-
<Text type="secondary">step #{execution.agentLoopStepId}</Text>
|
|
694
|
-
)}
|
|
695
|
-
</Space>
|
|
696
|
-
}
|
|
697
|
-
>
|
|
698
|
-
<Space direction="vertical" size={8} style={{ width: '100%' }}>
|
|
699
|
-
<Descriptions size="small" column={2}>
|
|
700
|
-
<Descriptions.Item label="Duration">
|
|
701
|
-
{execution.durationMs ? `${execution.durationMs}ms` : '-'}
|
|
702
|
-
</Descriptions.Item>
|
|
703
|
-
<Descriptions.Item label="Created">
|
|
704
|
-
{formatDate(execution.createdAt)}
|
|
705
|
-
</Descriptions.Item>
|
|
706
|
-
</Descriptions>
|
|
707
|
-
<Collapse
|
|
708
|
-
size="small"
|
|
709
|
-
items={[
|
|
710
|
-
{
|
|
711
|
-
key: 'stdout',
|
|
712
|
-
label: 'stdout',
|
|
713
|
-
children: <TextBlock value={execution.stdout} rows={10} />,
|
|
714
|
-
},
|
|
715
|
-
{
|
|
716
|
-
key: 'stderr',
|
|
717
|
-
label: 'stderr',
|
|
718
|
-
children: <TextBlock value={execution.stderr} rows={10} />,
|
|
719
|
-
},
|
|
720
|
-
{
|
|
721
|
-
key: 'files',
|
|
722
|
-
label: `files (${files.length})`,
|
|
723
|
-
children: files.length ? (
|
|
724
|
-
<Space direction="vertical">
|
|
725
|
-
{files.map((file: any, index: number) =>
|
|
726
|
-
renderSkillFileLink(execution, file, index),
|
|
727
|
-
)}
|
|
728
|
-
</Space>
|
|
729
|
-
) : (
|
|
730
|
-
<Empty description="No files" />
|
|
731
|
-
),
|
|
732
|
-
},
|
|
733
|
-
]}
|
|
734
|
-
/>
|
|
735
|
-
</Space>
|
|
736
|
-
</Card>
|
|
737
|
-
);
|
|
738
|
-
})}
|
|
739
|
-
</Space>
|
|
740
|
-
) : (
|
|
741
|
-
<Empty description="No linked skill executions" />
|
|
742
|
-
),
|
|
743
|
-
},
|
|
744
|
-
]}
|
|
745
|
-
/>
|
|
746
|
-
|
|
747
|
-
{(run.finalAnswer || run.summary) && (
|
|
748
|
-
<Card title="Final Output" size="small">
|
|
749
|
-
{run.summary && (
|
|
750
|
-
<Paragraph style={{ whiteSpace: 'pre-wrap', marginBottom: 12 }}>
|
|
751
|
-
<Text strong>Summary: </Text>
|
|
752
|
-
{run.summary}
|
|
753
|
-
</Paragraph>
|
|
754
|
-
)}
|
|
755
|
-
<TextBlock value={run.finalAnswer} rows={16} />
|
|
756
|
-
</Card>
|
|
757
|
-
)}
|
|
758
|
-
</Space>
|
|
759
|
-
</Spin>
|
|
760
|
-
)}
|
|
761
|
-
</Drawer>
|
|
762
|
-
</div>
|
|
763
|
-
);
|
|
764
|
-
};
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Alert,
|
|
4
|
+
Button,
|
|
5
|
+
Card,
|
|
6
|
+
Collapse,
|
|
7
|
+
Descriptions,
|
|
8
|
+
Drawer,
|
|
9
|
+
Empty,
|
|
10
|
+
Form,
|
|
11
|
+
message,
|
|
12
|
+
Popconfirm,
|
|
13
|
+
Select,
|
|
14
|
+
Space,
|
|
15
|
+
Spin,
|
|
16
|
+
Table,
|
|
17
|
+
Tag,
|
|
18
|
+
Timeline,
|
|
19
|
+
Typography,
|
|
20
|
+
} from 'antd';
|
|
21
|
+
import {
|
|
22
|
+
BranchesOutlined,
|
|
23
|
+
CheckCircleOutlined,
|
|
24
|
+
ClockCircleOutlined,
|
|
25
|
+
CloseCircleOutlined,
|
|
26
|
+
EyeOutlined,
|
|
27
|
+
PauseCircleOutlined,
|
|
28
|
+
PlayCircleOutlined,
|
|
29
|
+
RedoOutlined,
|
|
30
|
+
ReloadOutlined,
|
|
31
|
+
StopOutlined,
|
|
32
|
+
} from '@ant-design/icons';
|
|
33
|
+
import { useAPIClient, useRequest } from '@nocobase/client';
|
|
34
|
+
import { useAIEmployees } from './AIEmployeesContext';
|
|
35
|
+
import { parseJsonText } from './skill-hub/utils/jsonFields';
|
|
36
|
+
|
|
37
|
+
const { Paragraph, Text } = Typography;
|
|
38
|
+
|
|
39
|
+
type FilterState = {
|
|
40
|
+
leader?: string;
|
|
41
|
+
status?: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const terminalRunStatuses = new Set(['succeeded', 'failed', 'rejected', 'canceled']);
|
|
45
|
+
|
|
46
|
+
function statusColor(status?: string) {
|
|
47
|
+
switch (status) {
|
|
48
|
+
case 'succeeded':
|
|
49
|
+
case 'success':
|
|
50
|
+
return 'success';
|
|
51
|
+
case 'failed':
|
|
52
|
+
case 'error':
|
|
53
|
+
return 'error';
|
|
54
|
+
case 'waiting_user':
|
|
55
|
+
case 'waiting_plan_approval':
|
|
56
|
+
case 'needs_replan':
|
|
57
|
+
return 'warning';
|
|
58
|
+
case 'approved':
|
|
59
|
+
case 'running':
|
|
60
|
+
case 'planning':
|
|
61
|
+
return 'processing';
|
|
62
|
+
case 'rejected':
|
|
63
|
+
case 'canceled':
|
|
64
|
+
case 'skipped':
|
|
65
|
+
return 'default';
|
|
66
|
+
default:
|
|
67
|
+
return 'default';
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function statusIcon(status?: string) {
|
|
72
|
+
switch (status) {
|
|
73
|
+
case 'succeeded':
|
|
74
|
+
case 'success':
|
|
75
|
+
return <CheckCircleOutlined />;
|
|
76
|
+
case 'failed':
|
|
77
|
+
case 'error':
|
|
78
|
+
return <CloseCircleOutlined />;
|
|
79
|
+
case 'waiting_user':
|
|
80
|
+
case 'waiting_plan_approval':
|
|
81
|
+
case 'needs_replan':
|
|
82
|
+
return <PauseCircleOutlined />;
|
|
83
|
+
case 'approved':
|
|
84
|
+
case 'running':
|
|
85
|
+
case 'planning':
|
|
86
|
+
return <ClockCircleOutlined />;
|
|
87
|
+
default:
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function timelineColor(status?: string) {
|
|
93
|
+
switch (status) {
|
|
94
|
+
case 'succeeded':
|
|
95
|
+
case 'success':
|
|
96
|
+
return 'green';
|
|
97
|
+
case 'failed':
|
|
98
|
+
case 'error':
|
|
99
|
+
return 'red';
|
|
100
|
+
case 'waiting_user':
|
|
101
|
+
case 'waiting_plan_approval':
|
|
102
|
+
case 'needs_replan':
|
|
103
|
+
return 'orange';
|
|
104
|
+
case 'approved':
|
|
105
|
+
case 'running':
|
|
106
|
+
case 'planning':
|
|
107
|
+
return 'blue';
|
|
108
|
+
default:
|
|
109
|
+
return 'gray';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function StatusTag({ status }: { status?: string }) {
|
|
114
|
+
return (
|
|
115
|
+
<Tag icon={statusIcon(status)} color={statusColor(status)}>
|
|
116
|
+
{status || '-'}
|
|
117
|
+
</Tag>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function formatDate(value?: string) {
|
|
122
|
+
return value ? new Date(value).toLocaleString() : '-';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function formatDuration(start?: string, end?: string) {
|
|
126
|
+
if (!start) return '-';
|
|
127
|
+
const startMs = new Date(start).getTime();
|
|
128
|
+
const endMs = end ? new Date(end).getTime() : Date.now();
|
|
129
|
+
const diff = Math.max(0, endMs - startMs);
|
|
130
|
+
if (diff >= 60000) return `${Math.round(diff / 60000)}m`;
|
|
131
|
+
if (diff >= 1000) return `${(diff / 1000).toFixed(1)}s`;
|
|
132
|
+
return `${diff}ms`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function formatJson(value: any) {
|
|
136
|
+
if (value === undefined || value === null || value === '') return '';
|
|
137
|
+
if (typeof value === 'string') return value;
|
|
138
|
+
try {
|
|
139
|
+
return JSON.stringify(value, null, 2);
|
|
140
|
+
} catch {
|
|
141
|
+
return String(value);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function buildSkillFileUrl(execution: any, file: any) {
|
|
146
|
+
if (file?.downloadUrl) return file.downloadUrl;
|
|
147
|
+
if (!execution?.id || !file?.name) return '';
|
|
148
|
+
return `/api/skillHub:download?execId=${execution.id}&filename=${encodeURIComponent(file.name)}`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function renderSkillFileLink(execution: any, file: any, index: number) {
|
|
152
|
+
const url = buildSkillFileUrl(execution, file);
|
|
153
|
+
const label = file.name || file.path || `file-${index + 1}`;
|
|
154
|
+
return url ? (
|
|
155
|
+
<a key={index} href={url} target="_blank" rel="noreferrer">
|
|
156
|
+
{label}
|
|
157
|
+
</a>
|
|
158
|
+
) : (
|
|
159
|
+
<Text key={index}>{label}</Text>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function TextBlock({ value, rows = 10 }: { value: any; rows?: number }) {
|
|
164
|
+
const text = formatJson(value);
|
|
165
|
+
if (!text) return <Text type="secondary">-</Text>;
|
|
166
|
+
return (
|
|
167
|
+
<Paragraph
|
|
168
|
+
style={{ whiteSpace: 'pre-wrap', wordBreak: 'break-word', margin: 0, fontSize: 12 }}
|
|
169
|
+
ellipsis={{ rows, expandable: true }}
|
|
170
|
+
>
|
|
171
|
+
{text}
|
|
172
|
+
</Paragraph>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export const AgentRunsTab: React.FC = () => {
|
|
177
|
+
const api = useAPIClient();
|
|
178
|
+
const { employees, employeeMap } = useAIEmployees();
|
|
179
|
+
const [filters, setFilters] = useState<FilterState>({});
|
|
180
|
+
const [page, setPage] = useState(1);
|
|
181
|
+
const [pageSize, setPageSize] = useState(20);
|
|
182
|
+
const [selectedRun, setSelectedRun] = useState<any>(null);
|
|
183
|
+
const [detail, setDetail] = useState<any>(null);
|
|
184
|
+
const [detailLoading, setDetailLoading] = useState(false);
|
|
185
|
+
const [actionLoading, setActionLoading] = useState(false);
|
|
186
|
+
|
|
187
|
+
const requestParams = useMemo(() => {
|
|
188
|
+
const filter: any = {};
|
|
189
|
+
if (filters.leader) filter.leaderUsername = filters.leader;
|
|
190
|
+
if (filters.status) filter.status = filters.status;
|
|
191
|
+
return {
|
|
192
|
+
sort: ['-createdAt'],
|
|
193
|
+
page,
|
|
194
|
+
pageSize,
|
|
195
|
+
filter,
|
|
196
|
+
};
|
|
197
|
+
}, [filters, page, pageSize]);
|
|
198
|
+
|
|
199
|
+
const { data, loading, refresh } = useRequest(
|
|
200
|
+
{
|
|
201
|
+
url: 'agentLoops:list',
|
|
202
|
+
params: requestParams,
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
refreshDeps: [requestParams],
|
|
206
|
+
},
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
const runs = useMemo(() => {
|
|
210
|
+
const rows = (data as any)?.data;
|
|
211
|
+
return Array.isArray(rows) ? rows : [];
|
|
212
|
+
}, [data]);
|
|
213
|
+
|
|
214
|
+
const total = useMemo(() => {
|
|
215
|
+
const count = (data as any)?.meta?.count;
|
|
216
|
+
return typeof count === 'number' ? count : 0;
|
|
217
|
+
}, [data]);
|
|
218
|
+
|
|
219
|
+
const employeeOptions = useMemo(
|
|
220
|
+
() =>
|
|
221
|
+
employees.map((employee) => ({
|
|
222
|
+
label: employee.nickname || employee.username,
|
|
223
|
+
value: employee.username,
|
|
224
|
+
})),
|
|
225
|
+
[employees],
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
const fetchDetail = async (runId: string | number, seed?: any) => {
|
|
229
|
+
setSelectedRun(seed || selectedRun || { id: runId });
|
|
230
|
+
setDetailLoading(true);
|
|
231
|
+
try {
|
|
232
|
+
const res = await api.request({
|
|
233
|
+
url: 'agentLoops:get',
|
|
234
|
+
params: { filterByTk: runId },
|
|
235
|
+
});
|
|
236
|
+
setDetail((res as any)?.data?.data || (res as any)?.data || null);
|
|
237
|
+
} finally {
|
|
238
|
+
setDetailLoading(false);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const updateFilter = (patch: Partial<FilterState>) => {
|
|
243
|
+
setFilters((prev) => ({ ...prev, ...patch }));
|
|
244
|
+
setPage(1);
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
const resetFilters = () => {
|
|
248
|
+
setFilters({});
|
|
249
|
+
setPage(1);
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
const runAction = async (action: 'cancel' | 'resume', runId: string | number) => {
|
|
253
|
+
setActionLoading(true);
|
|
254
|
+
try {
|
|
255
|
+
await api.request({
|
|
256
|
+
url: action === 'cancel' ? 'agentLoops:cancel' : 'agentLoops:resume',
|
|
257
|
+
method: 'POST',
|
|
258
|
+
data: action === 'cancel' ? { runId } : { runId, stepId: detail?.run?.currentStepId, approved: true },
|
|
259
|
+
});
|
|
260
|
+
message.success(action === 'cancel' ? 'Run canceled' : 'Run resumed');
|
|
261
|
+
refresh();
|
|
262
|
+
await fetchDetail(runId);
|
|
263
|
+
} catch (error: any) {
|
|
264
|
+
message.error(error?.message || `Failed to ${action} run`);
|
|
265
|
+
} finally {
|
|
266
|
+
setActionLoading(false);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
const retryStep = async (stepId: string | number) => {
|
|
271
|
+
const runId = detail?.run?.id || selectedRun?.id;
|
|
272
|
+
setActionLoading(true);
|
|
273
|
+
try {
|
|
274
|
+
await api.request({
|
|
275
|
+
url: 'agentLoops:retryStep',
|
|
276
|
+
method: 'POST',
|
|
277
|
+
data: { stepId },
|
|
278
|
+
});
|
|
279
|
+
message.success('Step queued for retry');
|
|
280
|
+
refresh();
|
|
281
|
+
if (runId) await fetchDetail(runId);
|
|
282
|
+
} catch (error: any) {
|
|
283
|
+
message.error(error?.message || 'Failed to retry step');
|
|
284
|
+
} finally {
|
|
285
|
+
setActionLoading(false);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const columns = [
|
|
290
|
+
{
|
|
291
|
+
title: 'Time',
|
|
292
|
+
dataIndex: 'createdAt',
|
|
293
|
+
key: 'createdAt',
|
|
294
|
+
width: 170,
|
|
295
|
+
render: formatDate,
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
title: 'Leader',
|
|
299
|
+
dataIndex: 'leaderUsername',
|
|
300
|
+
key: 'leaderUsername',
|
|
301
|
+
width: 160,
|
|
302
|
+
render: (username: string) => <Tag color="blue">{employeeMap.get(username) || username || '-'}</Tag>,
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
title: 'Goal',
|
|
306
|
+
dataIndex: 'goal',
|
|
307
|
+
key: 'goal',
|
|
308
|
+
render: (goal: string) => (
|
|
309
|
+
<Text ellipsis style={{ maxWidth: 380 }}>
|
|
310
|
+
{goal || '-'}
|
|
311
|
+
</Text>
|
|
312
|
+
),
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
title: 'Status',
|
|
316
|
+
dataIndex: 'status',
|
|
317
|
+
key: 'status',
|
|
318
|
+
width: 130,
|
|
319
|
+
render: (status: string) => <StatusTag status={status} />,
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
title: 'Iterations',
|
|
323
|
+
dataIndex: 'iterationCount',
|
|
324
|
+
key: 'iterationCount',
|
|
325
|
+
width: 90,
|
|
326
|
+
render: (value: number) => value ?? 0,
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
title: 'Duration',
|
|
330
|
+
key: 'duration',
|
|
331
|
+
width: 100,
|
|
332
|
+
render: (_: any, record: any) => formatDuration(record.startedAt || record.createdAt, record.endedAt),
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
title: '',
|
|
336
|
+
key: 'actions',
|
|
337
|
+
width: 90,
|
|
338
|
+
render: (_: any, record: any) => (
|
|
339
|
+
<Button type="link" size="small" icon={<EyeOutlined />} onClick={() => fetchDetail(record.id, record)}>
|
|
340
|
+
Detail
|
|
341
|
+
</Button>
|
|
342
|
+
),
|
|
343
|
+
},
|
|
344
|
+
];
|
|
345
|
+
|
|
346
|
+
const steps = Array.isArray(detail?.steps) ? detail.steps : [];
|
|
347
|
+
const events = Array.isArray(detail?.events) ? detail.events : [];
|
|
348
|
+
const spans = Array.isArray(detail?.spans) ? detail.spans : [];
|
|
349
|
+
const skillExecutions = Array.isArray(detail?.skillExecutions) ? detail.skillExecutions : [];
|
|
350
|
+
const run = detail?.run || selectedRun;
|
|
351
|
+
const hasFilters = Boolean(filters.leader || filters.status);
|
|
352
|
+
|
|
353
|
+
const stepColumns = [
|
|
354
|
+
{
|
|
355
|
+
title: '#',
|
|
356
|
+
dataIndex: 'index',
|
|
357
|
+
key: 'index',
|
|
358
|
+
width: 56,
|
|
359
|
+
render: (value: number) => Number(value ?? 0) + 1,
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
title: 'Status',
|
|
363
|
+
dataIndex: 'status',
|
|
364
|
+
key: 'status',
|
|
365
|
+
width: 130,
|
|
366
|
+
render: (status: string) => <StatusTag status={status} />,
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
title: 'Type',
|
|
370
|
+
dataIndex: 'type',
|
|
371
|
+
key: 'type',
|
|
372
|
+
width: 110,
|
|
373
|
+
render: (type: string) => <Tag>{type}</Tag>,
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
title: 'Step',
|
|
377
|
+
key: 'step',
|
|
378
|
+
render: (_: any, record: any) => (
|
|
379
|
+
<Space direction="vertical" size={2} style={{ width: '100%' }}>
|
|
380
|
+
<Text strong>{record.title || record.planKey}</Text>
|
|
381
|
+
{record.description && <Text type="secondary">{record.description}</Text>}
|
|
382
|
+
{record.target && <Text code>{record.target}</Text>}
|
|
383
|
+
</Space>
|
|
384
|
+
),
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
title: 'Depends',
|
|
388
|
+
dataIndex: 'dependsOn',
|
|
389
|
+
key: 'dependsOn',
|
|
390
|
+
width: 130,
|
|
391
|
+
render: (dependsOn: string[]) =>
|
|
392
|
+
Array.isArray(dependsOn) && dependsOn.length ? dependsOn.map((key) => <Tag key={key}>{key}</Tag>) : '-',
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
title: 'Attempts',
|
|
396
|
+
key: 'attempts',
|
|
397
|
+
width: 90,
|
|
398
|
+
render: (_: any, record: any) => `${record.attempt || 0}/${record.maxAttempts || 0}`,
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
title: '',
|
|
402
|
+
key: 'actions',
|
|
403
|
+
width: 90,
|
|
404
|
+
render: (_: any, record: any) =>
|
|
405
|
+
record.status === 'failed' && Number(record.attempt || 0) < Number(record.maxAttempts || 0) ? (
|
|
406
|
+
<Button
|
|
407
|
+
type="link"
|
|
408
|
+
size="small"
|
|
409
|
+
icon={<RedoOutlined />}
|
|
410
|
+
loading={actionLoading}
|
|
411
|
+
onClick={() => retryStep(record.id)}
|
|
412
|
+
>
|
|
413
|
+
Retry
|
|
414
|
+
</Button>
|
|
415
|
+
) : null,
|
|
416
|
+
},
|
|
417
|
+
];
|
|
418
|
+
|
|
419
|
+
return (
|
|
420
|
+
<div>
|
|
421
|
+
<Alert
|
|
422
|
+
type="info"
|
|
423
|
+
showIcon
|
|
424
|
+
style={{ marginBottom: 16 }}
|
|
425
|
+
message="Agent Runs"
|
|
426
|
+
description={
|
|
427
|
+
<Text type="secondary">
|
|
428
|
+
Persistent loop runs created by the orchestrator tools. Each run stores the goal, plan, step state,
|
|
429
|
+
approvals, and linked Skill Hub or sub-agent traces.
|
|
430
|
+
</Text>
|
|
431
|
+
}
|
|
432
|
+
/>
|
|
433
|
+
|
|
434
|
+
<Card bordered={false}>
|
|
435
|
+
<Form layout="inline" style={{ marginBottom: 16, rowGap: 8, flexWrap: 'wrap' }}>
|
|
436
|
+
<Form.Item label="Leader">
|
|
437
|
+
<Select
|
|
438
|
+
allowClear
|
|
439
|
+
showSearch
|
|
440
|
+
optionFilterProp="label"
|
|
441
|
+
placeholder="Any leader"
|
|
442
|
+
style={{ minWidth: 180 }}
|
|
443
|
+
options={employeeOptions}
|
|
444
|
+
value={filters.leader}
|
|
445
|
+
onChange={(value) => updateFilter({ leader: value })}
|
|
446
|
+
/>
|
|
447
|
+
</Form.Item>
|
|
448
|
+
<Form.Item label="Status">
|
|
449
|
+
<Select
|
|
450
|
+
allowClear
|
|
451
|
+
placeholder="Any status"
|
|
452
|
+
style={{ minWidth: 160 }}
|
|
453
|
+
value={filters.status}
|
|
454
|
+
onChange={(value) => updateFilter({ status: value })}
|
|
455
|
+
options={[
|
|
456
|
+
{ label: 'Planning', value: 'planning' },
|
|
457
|
+
{ label: 'Waiting plan approval', value: 'waiting_plan_approval' },
|
|
458
|
+
{ label: 'Approved', value: 'approved' },
|
|
459
|
+
{ label: 'Running', value: 'running' },
|
|
460
|
+
{ label: 'Waiting user', value: 'waiting_user' },
|
|
461
|
+
{ label: 'Needs replan', value: 'needs_replan' },
|
|
462
|
+
{ label: 'Succeeded', value: 'succeeded' },
|
|
463
|
+
{ label: 'Failed', value: 'failed' },
|
|
464
|
+
{ label: 'Rejected', value: 'rejected' },
|
|
465
|
+
{ label: 'Canceled', value: 'canceled' },
|
|
466
|
+
]}
|
|
467
|
+
/>
|
|
468
|
+
</Form.Item>
|
|
469
|
+
<Form.Item>
|
|
470
|
+
<Space>
|
|
471
|
+
<Button onClick={resetFilters} disabled={!hasFilters}>
|
|
472
|
+
Reset
|
|
473
|
+
</Button>
|
|
474
|
+
<Button icon={<ReloadOutlined />} onClick={refresh}>
|
|
475
|
+
Refresh
|
|
476
|
+
</Button>
|
|
477
|
+
</Space>
|
|
478
|
+
</Form.Item>
|
|
479
|
+
</Form>
|
|
480
|
+
|
|
481
|
+
<Table
|
|
482
|
+
rowKey="id"
|
|
483
|
+
loading={loading}
|
|
484
|
+
dataSource={runs}
|
|
485
|
+
columns={columns}
|
|
486
|
+
pagination={{
|
|
487
|
+
current: page,
|
|
488
|
+
pageSize,
|
|
489
|
+
total,
|
|
490
|
+
showSizeChanger: true,
|
|
491
|
+
pageSizeOptions: [10, 20, 50, 100],
|
|
492
|
+
showTotal: (count) => `${count} run${count === 1 ? '' : 's'}`,
|
|
493
|
+
onChange: (nextPage, nextSize) => {
|
|
494
|
+
setPage(nextPage);
|
|
495
|
+
if (nextSize && nextSize !== pageSize) setPageSize(nextSize);
|
|
496
|
+
},
|
|
497
|
+
}}
|
|
498
|
+
locale={{
|
|
499
|
+
emptyText: <Empty description={hasFilters ? 'No runs match the current filters' : 'No agent runs yet'} />,
|
|
500
|
+
}}
|
|
501
|
+
/>
|
|
502
|
+
</Card>
|
|
503
|
+
|
|
504
|
+
<Drawer
|
|
505
|
+
title="Agent Run Detail"
|
|
506
|
+
width={980}
|
|
507
|
+
onClose={() => {
|
|
508
|
+
setSelectedRun(null);
|
|
509
|
+
setDetail(null);
|
|
510
|
+
}}
|
|
511
|
+
open={!!selectedRun}
|
|
512
|
+
>
|
|
513
|
+
{run && (
|
|
514
|
+
<Spin spinning={detailLoading}>
|
|
515
|
+
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
|
516
|
+
<Space wrap>
|
|
517
|
+
<Button icon={<ReloadOutlined />} onClick={() => fetchDetail(run.id)} loading={detailLoading}>
|
|
518
|
+
Refresh
|
|
519
|
+
</Button>
|
|
520
|
+
{run.status === 'waiting_user' && (
|
|
521
|
+
<Button
|
|
522
|
+
type="primary"
|
|
523
|
+
icon={<PlayCircleOutlined />}
|
|
524
|
+
loading={actionLoading}
|
|
525
|
+
onClick={() => runAction('resume', run.id)}
|
|
526
|
+
>
|
|
527
|
+
Resume
|
|
528
|
+
</Button>
|
|
529
|
+
)}
|
|
530
|
+
{!terminalRunStatuses.has(run.status) && (
|
|
531
|
+
<Popconfirm title="Cancel this run?" onConfirm={() => runAction('cancel', run.id)}>
|
|
532
|
+
<Button danger icon={<StopOutlined />} loading={actionLoading}>
|
|
533
|
+
Cancel run
|
|
534
|
+
</Button>
|
|
535
|
+
</Popconfirm>
|
|
536
|
+
)}
|
|
537
|
+
</Space>
|
|
538
|
+
|
|
539
|
+
<Descriptions bordered size="small" column={2}>
|
|
540
|
+
<Descriptions.Item label="Status">
|
|
541
|
+
<StatusTag status={run.status} />
|
|
542
|
+
</Descriptions.Item>
|
|
543
|
+
<Descriptions.Item label="Leader">
|
|
544
|
+
<Tag color="blue">{employeeMap.get(run.leaderUsername) || run.leaderUsername || '-'}</Tag>
|
|
545
|
+
</Descriptions.Item>
|
|
546
|
+
<Descriptions.Item label="Root run">
|
|
547
|
+
<Text code>{run.rootRunId || '-'}</Text>
|
|
548
|
+
</Descriptions.Item>
|
|
549
|
+
<Descriptions.Item label="Current step">
|
|
550
|
+
<Text code>{run.currentStepId || '-'}</Text>
|
|
551
|
+
</Descriptions.Item>
|
|
552
|
+
<Descriptions.Item label="Iterations">{run.iterationCount || 0}</Descriptions.Item>
|
|
553
|
+
<Descriptions.Item label="Approval">{run.approvalStatus || '-'}</Descriptions.Item>
|
|
554
|
+
<Descriptions.Item label="Plan version">{run.planVersion || '-'}</Descriptions.Item>
|
|
555
|
+
<Descriptions.Item label="Harness">{run.metadata?.harnessTag || '-'}</Descriptions.Item>
|
|
556
|
+
<Descriptions.Item label="Duration">
|
|
557
|
+
{formatDuration(run.startedAt || run.createdAt, run.endedAt)}
|
|
558
|
+
</Descriptions.Item>
|
|
559
|
+
<Descriptions.Item label="Started">{formatDate(run.startedAt || run.createdAt)}</Descriptions.Item>
|
|
560
|
+
<Descriptions.Item label="Ended">{formatDate(run.endedAt)}</Descriptions.Item>
|
|
561
|
+
</Descriptions>
|
|
562
|
+
|
|
563
|
+
<Card title="Goal" size="small">
|
|
564
|
+
<TextBlock value={run.goal} rows={6} />
|
|
565
|
+
</Card>
|
|
566
|
+
|
|
567
|
+
<Card title="Plan" size="small" extra={<BranchesOutlined />}>
|
|
568
|
+
<Table
|
|
569
|
+
rowKey="id"
|
|
570
|
+
size="small"
|
|
571
|
+
dataSource={steps}
|
|
572
|
+
columns={stepColumns}
|
|
573
|
+
pagination={false}
|
|
574
|
+
expandable={{
|
|
575
|
+
expandedRowRender: (record: any) => (
|
|
576
|
+
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
|
577
|
+
<Card size="small" title="Input">
|
|
578
|
+
<TextBlock value={record.input} rows={8} />
|
|
579
|
+
</Card>
|
|
580
|
+
<Card size="small" title="Output">
|
|
581
|
+
<TextBlock value={record.output} rows={8} />
|
|
582
|
+
</Card>
|
|
583
|
+
{record.approval && Object.keys(record.approval).length > 0 && (
|
|
584
|
+
<Card size="small" title="Approval">
|
|
585
|
+
<TextBlock value={record.approval} rows={8} />
|
|
586
|
+
</Card>
|
|
587
|
+
)}
|
|
588
|
+
{record.error && (
|
|
589
|
+
<Card size="small" title="Error" style={{ borderColor: '#ffa39e' }}>
|
|
590
|
+
<TextBlock value={record.error} rows={8} />
|
|
591
|
+
</Card>
|
|
592
|
+
)}
|
|
593
|
+
</Space>
|
|
594
|
+
),
|
|
595
|
+
}}
|
|
596
|
+
locale={{ emptyText: <Empty description="No plan steps" /> }}
|
|
597
|
+
/>
|
|
598
|
+
</Card>
|
|
599
|
+
|
|
600
|
+
<Card title="Event Timeline" size="small">
|
|
601
|
+
{events.length ? (
|
|
602
|
+
<Timeline
|
|
603
|
+
items={events.map((event: any) => ({
|
|
604
|
+
key: event.id,
|
|
605
|
+
color: timelineColor(event.status),
|
|
606
|
+
children: (
|
|
607
|
+
<Space direction="vertical" size={2} style={{ width: '100%' }}>
|
|
608
|
+
<Space wrap>
|
|
609
|
+
<Text strong>{event.title || event.type}</Text>
|
|
610
|
+
<StatusTag status={event.status} />
|
|
611
|
+
{event.stepId && <Text type="secondary">step #{event.stepId}</Text>}
|
|
612
|
+
</Space>
|
|
613
|
+
<Text type="secondary">{formatDate(event.createdAt)}</Text>
|
|
614
|
+
{event.content && <TextBlock value={event.content} rows={4} />}
|
|
615
|
+
</Space>
|
|
616
|
+
),
|
|
617
|
+
}))}
|
|
618
|
+
/>
|
|
619
|
+
) : (
|
|
620
|
+
<Empty description="No events captured" />
|
|
621
|
+
)}
|
|
622
|
+
</Card>
|
|
623
|
+
|
|
624
|
+
<Collapse
|
|
625
|
+
items={[
|
|
626
|
+
{
|
|
627
|
+
key: 'spans',
|
|
628
|
+
label: `Linked spans (${spans.length})`,
|
|
629
|
+
children: spans.length ? (
|
|
630
|
+
<Table
|
|
631
|
+
rowKey="id"
|
|
632
|
+
size="small"
|
|
633
|
+
dataSource={spans}
|
|
634
|
+
pagination={false}
|
|
635
|
+
columns={[
|
|
636
|
+
{
|
|
637
|
+
title: 'Type',
|
|
638
|
+
dataIndex: 'type',
|
|
639
|
+
key: 'type',
|
|
640
|
+
width: 110,
|
|
641
|
+
render: (value: string) => <Tag>{value}</Tag>,
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
title: 'Status',
|
|
645
|
+
dataIndex: 'status',
|
|
646
|
+
key: 'status',
|
|
647
|
+
width: 110,
|
|
648
|
+
render: (value: string) => <StatusTag status={value} />,
|
|
649
|
+
},
|
|
650
|
+
{ title: 'Title', dataIndex: 'title', key: 'title' },
|
|
651
|
+
{
|
|
652
|
+
title: 'Tool',
|
|
653
|
+
dataIndex: 'toolName',
|
|
654
|
+
key: 'toolName',
|
|
655
|
+
render: (value: string) => (value ? <Text code>{value}</Text> : '-'),
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
title: 'Duration',
|
|
659
|
+
dataIndex: 'durationMs',
|
|
660
|
+
key: 'durationMs',
|
|
661
|
+
width: 100,
|
|
662
|
+
render: (value: number) => (value ? `${value}ms` : '-'),
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
title: 'Skill Exec',
|
|
666
|
+
dataIndex: 'skillExecutionId',
|
|
667
|
+
key: 'skillExecutionId',
|
|
668
|
+
width: 110,
|
|
669
|
+
render: (value: any) => value || '-',
|
|
670
|
+
},
|
|
671
|
+
]}
|
|
672
|
+
/>
|
|
673
|
+
) : (
|
|
674
|
+
<Empty description="No linked spans" />
|
|
675
|
+
),
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
key: 'skills',
|
|
679
|
+
label: `Skill executions (${skillExecutions.length})`,
|
|
680
|
+
children: skillExecutions.length ? (
|
|
681
|
+
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
|
682
|
+
{skillExecutions.map((execution: any) => {
|
|
683
|
+
const files = parseJsonText<any[]>(execution.outputFiles, []);
|
|
684
|
+
return (
|
|
685
|
+
<Card
|
|
686
|
+
key={execution.id}
|
|
687
|
+
size="small"
|
|
688
|
+
title={
|
|
689
|
+
<Space wrap>
|
|
690
|
+
<Text>Skill execution #{execution.id}</Text>
|
|
691
|
+
<StatusTag status={execution.status} />
|
|
692
|
+
{execution.agentLoopStepId && (
|
|
693
|
+
<Text type="secondary">step #{execution.agentLoopStepId}</Text>
|
|
694
|
+
)}
|
|
695
|
+
</Space>
|
|
696
|
+
}
|
|
697
|
+
>
|
|
698
|
+
<Space direction="vertical" size={8} style={{ width: '100%' }}>
|
|
699
|
+
<Descriptions size="small" column={2}>
|
|
700
|
+
<Descriptions.Item label="Duration">
|
|
701
|
+
{execution.durationMs ? `${execution.durationMs}ms` : '-'}
|
|
702
|
+
</Descriptions.Item>
|
|
703
|
+
<Descriptions.Item label="Created">
|
|
704
|
+
{formatDate(execution.createdAt)}
|
|
705
|
+
</Descriptions.Item>
|
|
706
|
+
</Descriptions>
|
|
707
|
+
<Collapse
|
|
708
|
+
size="small"
|
|
709
|
+
items={[
|
|
710
|
+
{
|
|
711
|
+
key: 'stdout',
|
|
712
|
+
label: 'stdout',
|
|
713
|
+
children: <TextBlock value={execution.stdout} rows={10} />,
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
key: 'stderr',
|
|
717
|
+
label: 'stderr',
|
|
718
|
+
children: <TextBlock value={execution.stderr} rows={10} />,
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
key: 'files',
|
|
722
|
+
label: `files (${files.length})`,
|
|
723
|
+
children: files.length ? (
|
|
724
|
+
<Space direction="vertical">
|
|
725
|
+
{files.map((file: any, index: number) =>
|
|
726
|
+
renderSkillFileLink(execution, file, index),
|
|
727
|
+
)}
|
|
728
|
+
</Space>
|
|
729
|
+
) : (
|
|
730
|
+
<Empty description="No files" />
|
|
731
|
+
),
|
|
732
|
+
},
|
|
733
|
+
]}
|
|
734
|
+
/>
|
|
735
|
+
</Space>
|
|
736
|
+
</Card>
|
|
737
|
+
);
|
|
738
|
+
})}
|
|
739
|
+
</Space>
|
|
740
|
+
) : (
|
|
741
|
+
<Empty description="No linked skill executions" />
|
|
742
|
+
),
|
|
743
|
+
},
|
|
744
|
+
]}
|
|
745
|
+
/>
|
|
746
|
+
|
|
747
|
+
{(run.finalAnswer || run.summary) && (
|
|
748
|
+
<Card title="Final Output" size="small">
|
|
749
|
+
{run.summary && (
|
|
750
|
+
<Paragraph style={{ whiteSpace: 'pre-wrap', marginBottom: 12 }}>
|
|
751
|
+
<Text strong>Summary: </Text>
|
|
752
|
+
{run.summary}
|
|
753
|
+
</Paragraph>
|
|
754
|
+
)}
|
|
755
|
+
<TextBlock value={run.finalAnswer} rows={16} />
|
|
756
|
+
</Card>
|
|
757
|
+
)}
|
|
758
|
+
</Space>
|
|
759
|
+
</Spin>
|
|
760
|
+
)}
|
|
761
|
+
</Drawer>
|
|
762
|
+
</div>
|
|
763
|
+
);
|
|
764
|
+
};
|