plugin-agent-orchestrator 1.0.28 → 1.0.33

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