@elevasis/ui 1.0.0

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 (97) hide show
  1. package/dist/api/index.d.ts +87 -0
  2. package/dist/api/index.js +3 -0
  3. package/dist/auth/context.d.ts +19 -0
  4. package/dist/auth/context.js +1 -0
  5. package/dist/auth/index.d.ts +85 -0
  6. package/dist/auth/index.js +3 -0
  7. package/dist/chunk-3KMDHCAR.js +52 -0
  8. package/dist/chunk-5UWFGBFM.js +129 -0
  9. package/dist/chunk-6BJOYF6E.js +8 -0
  10. package/dist/chunk-6M6OLGQY.js +36 -0
  11. package/dist/chunk-7AI5ZYJ4.js +202 -0
  12. package/dist/chunk-7PLEQFHO.js +18 -0
  13. package/dist/chunk-GDV44UWF.js +138 -0
  14. package/dist/chunk-GEFB5YIR.js +338 -0
  15. package/dist/chunk-HBRMWW6V.js +43 -0
  16. package/dist/chunk-HUWJXLLF.js +681 -0
  17. package/dist/chunk-J3FALDQE.js +176 -0
  18. package/dist/chunk-JKERRYVS.js +109 -0
  19. package/dist/chunk-KA7LO7U5.js +28 -0
  20. package/dist/chunk-LHQTTUL2.js +27 -0
  21. package/dist/chunk-MAAS6CGR.js +1299 -0
  22. package/dist/chunk-NE36BUGQ.js +146 -0
  23. package/dist/chunk-NGXCFBCS.js +398 -0
  24. package/dist/chunk-OEYU5O27.js +235 -0
  25. package/dist/chunk-OUHGHTE7.js +748 -0
  26. package/dist/chunk-OXVOHOP3.js +661 -0
  27. package/dist/chunk-PSLKGOBZ.js +58 -0
  28. package/dist/chunk-PYL4XW6H.js +107 -0
  29. package/dist/chunk-Q47SPRY7.js +1 -0
  30. package/dist/chunk-Q7DJKLEN.js +18 -0
  31. package/dist/chunk-RJCA5672.js +1664 -0
  32. package/dist/chunk-S66I2PYB.js +748 -0
  33. package/dist/chunk-W7ZBF5AA.js +1 -0
  34. package/dist/chunk-WNWKOCGJ.js +1067 -0
  35. package/dist/chunk-XCYKC6OZ.js +1 -0
  36. package/dist/chunk-YULUKCS6.js +56 -0
  37. package/dist/chunk-YZ6GTZXL.js +48 -0
  38. package/dist/chunk-ZGHDPDTF.js +379 -0
  39. package/dist/components/command-queue/index.css +53 -0
  40. package/dist/components/command-queue/index.d.ts +204 -0
  41. package/dist/components/command-queue/index.js +10 -0
  42. package/dist/components/forms/index.d.ts +56 -0
  43. package/dist/components/forms/index.js +2 -0
  44. package/dist/components/index.css +443 -0
  45. package/dist/components/index.d.ts +1354 -0
  46. package/dist/components/index.js +18 -0
  47. package/dist/components/monitoring/index.d.ts +66 -0
  48. package/dist/components/monitoring/index.js +2 -0
  49. package/dist/components/navigation/index.d.ts +54 -0
  50. package/dist/components/navigation/index.js +91 -0
  51. package/dist/components/notifications/index.d.ts +52 -0
  52. package/dist/components/notifications/index.js +4 -0
  53. package/dist/components/resource-definition/index.css +388 -0
  54. package/dist/components/resource-definition/index.d.ts +301 -0
  55. package/dist/components/resource-definition/index.js +3 -0
  56. package/dist/display/index.css +53 -0
  57. package/dist/display/index.d.ts +606 -0
  58. package/dist/display/index.js +6 -0
  59. package/dist/execution/index.css +388 -0
  60. package/dist/execution/index.d.ts +1090 -0
  61. package/dist/execution/index.js +4 -0
  62. package/dist/graph/index.css +388 -0
  63. package/dist/graph/index.d.ts +429 -0
  64. package/dist/graph/index.js +1 -0
  65. package/dist/hooks/index.d.ts +1927 -0
  66. package/dist/hooks/index.js +6 -0
  67. package/dist/hooks/published.d.ts +1653 -0
  68. package/dist/hooks/published.js +4 -0
  69. package/dist/index.css +505 -0
  70. package/dist/index.d.ts +7284 -0
  71. package/dist/index.js +31 -0
  72. package/dist/initialization/index.d.ts +2325 -0
  73. package/dist/initialization/index.js +4 -0
  74. package/dist/organization/index.d.ts +225 -0
  75. package/dist/organization/index.js +4 -0
  76. package/dist/profile/index.d.ts +2265 -0
  77. package/dist/profile/index.js +3 -0
  78. package/dist/provider/index.css +61 -0
  79. package/dist/provider/index.d.ts +291 -0
  80. package/dist/provider/index.js +7 -0
  81. package/dist/provider/published.d.ts +198 -0
  82. package/dist/provider/published.js +6 -0
  83. package/dist/router/context.d.ts +19 -0
  84. package/dist/router/context.js +1 -0
  85. package/dist/router/index.d.ts +31 -0
  86. package/dist/router/index.js +2 -0
  87. package/dist/sse/index.d.ts +83 -0
  88. package/dist/sse/index.js +185 -0
  89. package/dist/supabase/index.d.ts +4289 -0
  90. package/dist/supabase/index.js +47 -0
  91. package/dist/typeform/index.d.ts +458 -0
  92. package/dist/typeform/index.js +1976 -0
  93. package/dist/typeform/schemas.d.ts +67 -0
  94. package/dist/typeform/schemas.js +1 -0
  95. package/dist/utils/index.d.ts +177 -0
  96. package/dist/utils/index.js +1 -0
  97. package/package.json +88 -0
@@ -0,0 +1,1664 @@
1
+ import { formatDuration } from './chunk-6BJOYF6E.js';
2
+ import { BaseNode, useGraphTheme, BaseEdge, Graph_default, useDirectedChainHighlighting, useNodeSelection, GraphBackground, GraphLegend, GraphFitViewButton, GraphFitViewHandler, useFitViewTrigger } from './chunk-HUWJXLLF.js';
3
+ import { isStepStartedContext, isConditionalRouteContext, isStepCompletedContext, isStepFailedContext, isLifecycleEvent, isIterationEvent, isToolCallEvent, toWorkflowLogMessage } from './chunk-YZ6GTZXL.js';
4
+ import { memo, useMemo, useState, useEffect, useCallback, Fragment as Fragment$1 } from 'react';
5
+ import dagre from '@dagrejs/dagre';
6
+ import { Stack, Text, Group, Badge, Box, Loader, SegmentedControl } from '@mantine/core';
7
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
+ import { Position, ReactFlowProvider, ReactFlow, Panel } from '@xyflow/react';
9
+ import '@xyflow/react/dist/style.css';
10
+ import { IconPlayerPlay, IconPlayerStop, IconArrowsSplit, IconSquare, IconCircleDot, IconLoader, IconAlertTriangle, IconX, IconCheck } from '@tabler/icons-react';
11
+
12
+ function useMergedExecution(fetchedExecution, streamingLogs) {
13
+ return useMemo(() => {
14
+ if (!fetchedExecution) return void 0;
15
+ if (!streamingLogs || streamingLogs.length === 0) return fetchedExecution;
16
+ const existingKeys = new Set(fetchedExecution.executionLogs.map((log) => `${log.timestamp}:${log.message}`));
17
+ const newLogs = streamingLogs.filter((log) => !existingKeys.has(`${log.timestamp}:${log.message}`));
18
+ if (newLogs.length === 0) return fetchedExecution;
19
+ return {
20
+ ...fetchedExecution,
21
+ executionLogs: [...fetchedExecution.executionLogs, ...newLogs].sort((a, b) => a.timestamp - b.timestamp)
22
+ };
23
+ }, [fetchedExecution, streamingLogs]);
24
+ }
25
+ function useExecutionPath(executionLogs, workflowDefinition) {
26
+ return useMemo(() => {
27
+ if (!executionLogs || executionLogs.length === 0) {
28
+ return void 0;
29
+ }
30
+ if (!workflowDefinition) {
31
+ return void 0;
32
+ }
33
+ const executedSteps = /* @__PURE__ */ new Set();
34
+ const executedStepsOrdered = [];
35
+ const takenEdges = /* @__PURE__ */ new Set();
36
+ const stepStatusMap = /* @__PURE__ */ new Map();
37
+ const stepDataMap = /* @__PURE__ */ new Map();
38
+ let currentStepId;
39
+ for (const log of executionLogs) {
40
+ const context = log.context;
41
+ if (!context || context.type !== "workflow") continue;
42
+ if (isStepStartedContext(context)) {
43
+ executedSteps.add(context.stepId);
44
+ executedStepsOrdered.push(context.stepId);
45
+ currentStepId = context.stepId;
46
+ stepStatusMap.set(context.stepId, "running");
47
+ stepDataMap.set(context.stepId, {
48
+ status: "running",
49
+ input: context.input
50
+ });
51
+ }
52
+ if (isConditionalRouteContext(context)) {
53
+ const edgeId = `edge-${context.stepId}-${context.target}`;
54
+ takenEdges.add(edgeId);
55
+ }
56
+ if (isStepCompletedContext(context)) {
57
+ stepStatusMap.set(context.stepId, "completed");
58
+ const existingData = stepDataMap.get(context.stepId);
59
+ stepDataMap.set(context.stepId, {
60
+ ...existingData,
61
+ status: "completed",
62
+ duration: context.duration,
63
+ output: context.output
64
+ });
65
+ if (context.stepId === currentStepId) {
66
+ currentStepId = void 0;
67
+ }
68
+ }
69
+ if (isStepFailedContext(context)) {
70
+ stepStatusMap.set(context.stepId, "failed");
71
+ const existingData = stepDataMap.get(context.stepId);
72
+ stepDataMap.set(context.stepId, {
73
+ ...existingData,
74
+ status: "failed",
75
+ duration: context.duration,
76
+ error: context.error
77
+ });
78
+ if (context.stepId === currentStepId) {
79
+ currentStepId = void 0;
80
+ }
81
+ }
82
+ }
83
+ for (let i = 0; i < executedStepsOrdered.length - 1; i++) {
84
+ const sourceId = executedStepsOrdered[i];
85
+ const targetId = executedStepsOrdered[i + 1];
86
+ const step = workflowDefinition.steps.find((s) => s.id === sourceId);
87
+ if (step?.next?.type === "linear") {
88
+ const edgeId = `edge-${sourceId}-${targetId}`;
89
+ takenEdges.add(edgeId);
90
+ }
91
+ }
92
+ return {
93
+ executedSteps,
94
+ executedStepsOrdered,
95
+ takenEdges,
96
+ currentStepId,
97
+ stepStatusMap,
98
+ stepDataMap
99
+ };
100
+ }, [executionLogs, workflowDefinition]);
101
+ }
102
+ function useTimelineData(execution, resourceDefinition) {
103
+ return useMemo(() => {
104
+ const workflowSteps = resourceDefinition.steps;
105
+ if (!execution || !resourceDefinition) {
106
+ return void 0;
107
+ }
108
+ const stepMap = /* @__PURE__ */ new Map();
109
+ const stepNameLookup = /* @__PURE__ */ new Map();
110
+ workflowSteps.forEach((step) => {
111
+ stepNameLookup.set(step.id, step.name);
112
+ });
113
+ let workflowStartTime;
114
+ let workflowEndTime;
115
+ let activeStepId = null;
116
+ execution.executionLogs.forEach((log) => {
117
+ const context = log.context;
118
+ const ensureStepAndAddLog = (stepId) => {
119
+ if (!stepMap.has(stepId)) {
120
+ const stepName = stepNameLookup.get(stepId) || stepId;
121
+ stepMap.set(stepId, {
122
+ stepId,
123
+ stepName,
124
+ status: "pending",
125
+ logs: []
126
+ });
127
+ }
128
+ const step = stepMap.get(stepId);
129
+ const workflowLog = toWorkflowLogMessage(log);
130
+ if (workflowLog) {
131
+ step.logs.push(workflowLog);
132
+ }
133
+ return step;
134
+ };
135
+ if (!context || context.type !== "workflow") {
136
+ if (activeStepId) {
137
+ ensureStepAndAddLog(activeStepId);
138
+ }
139
+ return;
140
+ }
141
+ if (isStepStartedContext(context)) {
142
+ activeStepId = context.stepId;
143
+ const step = ensureStepAndAddLog(context.stepId);
144
+ step.status = "running";
145
+ step.startTime = context.startTime;
146
+ step.input = context.input;
147
+ if (!workflowStartTime) workflowStartTime = context.startTime;
148
+ } else if (isStepCompletedContext(context)) {
149
+ const step = ensureStepAndAddLog(context.stepId);
150
+ step.status = "completed";
151
+ step.startTime = context.startTime;
152
+ step.endTime = context.endTime;
153
+ step.duration = context.duration;
154
+ step.output = context.output;
155
+ workflowEndTime = context.endTime;
156
+ activeStepId = null;
157
+ } else if (isStepFailedContext(context)) {
158
+ const step = ensureStepAndAddLog(context.stepId);
159
+ step.status = "failed";
160
+ step.startTime = context.startTime;
161
+ step.endTime = context.endTime;
162
+ step.duration = context.duration;
163
+ step.error = context.error;
164
+ workflowEndTime = context.endTime;
165
+ activeStepId = null;
166
+ } else if (isConditionalRouteContext(context)) {
167
+ ensureStepAndAddLog(context.stepId);
168
+ }
169
+ });
170
+ const steps = Array.from(stepMap.values());
171
+ const isRunning = execution.status === "running";
172
+ const totalDuration = workflowStartTime && workflowEndTime ? workflowEndTime - workflowStartTime : 0;
173
+ return {
174
+ steps,
175
+ totalDuration,
176
+ isRunning
177
+ };
178
+ }, [execution, resourceDefinition]);
179
+ }
180
+ function useAgentIterationData(execution, resourceDefinition) {
181
+ return useMemo(() => {
182
+ if (!execution || !execution.executionLogs) {
183
+ return null;
184
+ }
185
+ const iterations = /* @__PURE__ */ new Map();
186
+ let currentIteration = null;
187
+ let totalDuration;
188
+ let status = execution.status;
189
+ const initialization = {
190
+ type: "initialization",
191
+ status: "pending"
192
+ };
193
+ const completion = {
194
+ type: "completion",
195
+ status: "pending"
196
+ };
197
+ for (const log of execution.executionLogs) {
198
+ const context = log.context;
199
+ if (context?.type !== "agent" || !("lifecycle" in context)) continue;
200
+ if (isLifecycleEvent(context)) {
201
+ const { lifecycle, stage } = context;
202
+ if (lifecycle === "initialization") {
203
+ initialization.timestamp = log.timestamp;
204
+ if (stage === "started") {
205
+ initialization.status = "running";
206
+ initialization.startTime = context.startTime;
207
+ } else if (stage === "completed") {
208
+ initialization.status = "completed";
209
+ initialization.endTime = context.endTime;
210
+ initialization.duration = context.duration;
211
+ } else if (stage === "failed") {
212
+ initialization.status = "failed";
213
+ initialization.endTime = context.endTime;
214
+ initialization.duration = context.duration;
215
+ }
216
+ }
217
+ if (lifecycle === "iteration" && "iteration" in context) {
218
+ const iterationNum = context.iteration;
219
+ if (stage === "started") {
220
+ if (!iterations.has(iterationNum)) {
221
+ iterations.set(iterationNum, {
222
+ iterationNumber: iterationNum,
223
+ status: "running",
224
+ iterationEvents: [],
225
+ subActivities: [],
226
+ timestamp: context.startTime,
227
+ startTime: context.startTime
228
+ });
229
+ }
230
+ currentIteration = iterationNum;
231
+ } else if (stage === "completed") {
232
+ const iteration = iterations.get(iterationNum);
233
+ if (iteration) {
234
+ iteration.status = "completed";
235
+ iteration.endTime = context.endTime;
236
+ iteration.duration = context.duration;
237
+ }
238
+ } else if (stage === "failed") {
239
+ const iteration = iterations.get(iterationNum);
240
+ if (iteration) {
241
+ iteration.status = "failed";
242
+ iteration.endTime = context.endTime;
243
+ if (context.duration) {
244
+ iteration.duration = context.duration;
245
+ }
246
+ }
247
+ }
248
+ }
249
+ if (lifecycle === "completion") {
250
+ completion.timestamp = log.timestamp;
251
+ if (stage === "started") {
252
+ completion.status = "running";
253
+ completion.startTime = context.startTime;
254
+ } else if (stage === "completed") {
255
+ completion.status = "completed";
256
+ completion.endTime = context.endTime;
257
+ completion.duration = context.duration;
258
+ } else if (stage === "failed") {
259
+ completion.status = "failed";
260
+ completion.endTime = context.endTime;
261
+ completion.duration = context.duration;
262
+ status = "failed";
263
+ }
264
+ }
265
+ }
266
+ if (isIterationEvent(context)) {
267
+ const iterationNum = context.iteration;
268
+ if (iterationNum === 0) {
269
+ continue;
270
+ }
271
+ const iteration = iterations.get(iterationNum);
272
+ if (iteration) {
273
+ iteration.iterationEvents.push(context);
274
+ if ("startTime" in context && "endTime" in context && "duration" in context) {
275
+ iteration.subActivities.push({
276
+ type: context.eventType,
277
+ startTime: context.startTime,
278
+ endTime: context.endTime,
279
+ duration: context.duration,
280
+ details: context
281
+ });
282
+ }
283
+ }
284
+ }
285
+ if (isToolCallEvent(context)) {
286
+ const iterationNum = context.iteration;
287
+ if (iterationNum === 0) {
288
+ continue;
289
+ }
290
+ const iteration = iterations.get(iterationNum);
291
+ if (iteration) {
292
+ iteration.subActivities.push({
293
+ type: "tool-call",
294
+ startTime: context.startTime,
295
+ endTime: context.endTime,
296
+ duration: context.duration,
297
+ details: context
298
+ });
299
+ }
300
+ }
301
+ }
302
+ const iterationArray = Array.from(iterations.values()).sort((a, b) => a.iterationNumber - b.iterationNumber).map((iteration) => ({
303
+ ...iteration,
304
+ subActivities: iteration.subActivities.sort((a, b) => a.startTime - b.startTime)
305
+ }));
306
+ if (initialization.duration && completion.duration) {
307
+ const iterationsDuration = iterationArray.reduce((sum, iter) => sum + (iter.duration || 0), 0);
308
+ totalDuration = initialization.duration + iterationsDuration + completion.duration;
309
+ }
310
+ return {
311
+ initialization,
312
+ iterations: iterationArray,
313
+ completion,
314
+ currentIteration: status === "running" ? currentIteration : null,
315
+ totalIterations: iterationArray.length,
316
+ totalDuration,
317
+ status
318
+ };
319
+ }, [execution, resourceDefinition]);
320
+ }
321
+ var NODE_WIDTH = 220;
322
+ var NODE_HEIGHT = 140;
323
+ var RANK_SEP = 100;
324
+ var NODE_SEP = 40;
325
+ function buildEdges(steps) {
326
+ const edges = [];
327
+ for (const step of steps) {
328
+ if (step.next === null) continue;
329
+ if (step.next.type === "linear" && step.next.target) {
330
+ edges.push({
331
+ id: `edge-${step.id}-${step.next.target}`,
332
+ source: step.id,
333
+ target: step.next.target,
334
+ type: "workflowStep",
335
+ data: {
336
+ edgeType: "linear",
337
+ label: "next"
338
+ }
339
+ });
340
+ } else if (step.next.type === "conditional") {
341
+ const routes = step.next.routes || [];
342
+ const defaultTarget = step.next.default;
343
+ for (const route of routes) {
344
+ edges.push({
345
+ id: `edge-${step.id}-${route.target}`,
346
+ source: step.id,
347
+ target: route.target,
348
+ type: "workflowStep",
349
+ data: {
350
+ edgeType: "conditional",
351
+ label: "route"
352
+ }
353
+ });
354
+ }
355
+ if (defaultTarget) {
356
+ edges.push({
357
+ id: `edge-${step.id}-${defaultTarget}-default`,
358
+ source: step.id,
359
+ target: defaultTarget,
360
+ type: "workflowStep",
361
+ data: {
362
+ edgeType: "default",
363
+ label: "default"
364
+ }
365
+ });
366
+ }
367
+ }
368
+ }
369
+ return edges;
370
+ }
371
+ var MIN_GRAPH_HEIGHT = 400;
372
+ var MAX_GRAPH_HEIGHT = 600;
373
+ var GRAPH_PADDING = 80;
374
+ function useWorkflowStepsLayout(workflow) {
375
+ return useMemo(() => {
376
+ if (!workflow || workflow.steps.length === 0) {
377
+ return { nodes: [], edges: [], graphHeight: MIN_GRAPH_HEIGHT };
378
+ }
379
+ const edges = buildEdges(workflow.steps);
380
+ const hasOutgoing = /* @__PURE__ */ new Set();
381
+ for (const edge of edges) {
382
+ hasOutgoing.add(edge.source);
383
+ }
384
+ const dagreGraph = new dagre.graphlib.Graph();
385
+ dagreGraph.setDefaultEdgeLabel(() => ({}));
386
+ dagreGraph.setGraph({
387
+ rankdir: "LR",
388
+ ranksep: RANK_SEP,
389
+ nodesep: NODE_SEP,
390
+ marginx: 50,
391
+ marginy: 50
392
+ });
393
+ workflow.steps.forEach((step) => {
394
+ dagreGraph.setNode(step.id, {
395
+ width: NODE_WIDTH,
396
+ height: NODE_HEIGHT
397
+ });
398
+ });
399
+ edges.forEach((edge) => {
400
+ dagreGraph.setEdge(edge.source, edge.target);
401
+ });
402
+ dagre.layout(dagreGraph);
403
+ const nodes = workflow.steps.map((step) => {
404
+ const dagreNode = dagreGraph.node(step.id);
405
+ const isConditional = step.next?.type === "conditional";
406
+ const routeCount = isConditional ? (step.next?.routes?.length || 0) + (step.next?.default ? 1 : 0) : 0;
407
+ return {
408
+ id: step.id,
409
+ type: "workflowStep",
410
+ position: {
411
+ x: dagreNode.x - NODE_WIDTH / 2,
412
+ y: dagreNode.y - NODE_HEIGHT / 2
413
+ },
414
+ data: {
415
+ id: step.id,
416
+ name: step.name,
417
+ description: step.description,
418
+ isEntryPoint: step.id === workflow.entryPoint,
419
+ isEndNode: !hasOutgoing.has(step.id),
420
+ isConditional,
421
+ routeCount
422
+ }
423
+ };
424
+ });
425
+ let minY = Infinity;
426
+ let maxY = -Infinity;
427
+ for (const node of nodes) {
428
+ minY = Math.min(minY, node.position.y);
429
+ maxY = Math.max(maxY, node.position.y + NODE_HEIGHT);
430
+ }
431
+ const rawHeight = maxY - minY + GRAPH_PADDING;
432
+ const graphHeight = Math.max(MIN_GRAPH_HEIGHT, Math.min(MAX_GRAPH_HEIGHT, rawHeight));
433
+ return { nodes, edges, graphHeight };
434
+ }, [workflow]);
435
+ }
436
+
437
+ // src/execution/utils/statusColors.ts
438
+ var STATUS_COLORS = {
439
+ completed: {
440
+ color: "var(--color-success)",
441
+ badge: "green"
442
+ },
443
+ failed: {
444
+ color: "var(--color-error)",
445
+ badge: "red"
446
+ },
447
+ running: {
448
+ color: "var(--color-primary)",
449
+ badge: "blue"
450
+ },
451
+ pending: {
452
+ color: "var(--color-text-dimmed)",
453
+ badge: "gray"
454
+ },
455
+ warning: {
456
+ color: "var(--color-warning)",
457
+ badge: "yellow"
458
+ }
459
+ };
460
+ function getStatusColors(status) {
461
+ return STATUS_COLORS[status];
462
+ }
463
+
464
+ // src/execution/utils/edgeUtils.ts
465
+ function getEdgeColor({ selected, sourceStatus }) {
466
+ if (selected) {
467
+ return "var(--color-primary)";
468
+ }
469
+ return STATUS_COLORS[sourceStatus].color;
470
+ }
471
+ function getEdgeOpacity({ sourceStatus }) {
472
+ switch (sourceStatus) {
473
+ case "completed":
474
+ return 0.8;
475
+ case "warning":
476
+ return 0.8;
477
+ case "running":
478
+ return 1;
479
+ case "failed":
480
+ return 0.6;
481
+ case "pending":
482
+ default:
483
+ return 0.3;
484
+ }
485
+ }
486
+ function shouldAnimateEdge(sourceStatus, targetStatus) {
487
+ return sourceStatus === "running" || targetStatus === "running";
488
+ }
489
+
490
+ // src/execution/hooks/useUnifiedWorkflowLayout.ts
491
+ function getStepStatus(stepId, executionPath) {
492
+ if (!executionPath) return void 0;
493
+ if (executionPath.currentStepId === stepId) {
494
+ return "running";
495
+ }
496
+ if (executionPath.executedSteps.has(stepId)) {
497
+ const status = executionPath.stepStatusMap?.get(stepId);
498
+ return status || "completed";
499
+ }
500
+ return "pending";
501
+ }
502
+ function calculateDimState(stepId, executionPath, entryPointId, hasExecutionData, mode) {
503
+ if (mode === "definition") {
504
+ return false;
505
+ }
506
+ if (!hasExecutionData) {
507
+ return stepId !== entryPointId;
508
+ }
509
+ return !executionPath?.executedSteps.has(stepId);
510
+ }
511
+ function useUnifiedWorkflowLayout(workflow, executionPath, selectedStepId, mode = "execution") {
512
+ const { nodes: baseNodes, edges: baseEdges, graphHeight } = useWorkflowStepsLayout(workflow);
513
+ return useMemo(() => {
514
+ if (!workflow || baseNodes.length === 0) {
515
+ return { nodes: [], edges: [], graphHeight };
516
+ }
517
+ const entryPointId = workflow.entryPoint;
518
+ const hasExecutionData = !!executionPath && executionPath.executedSteps.size > 0;
519
+ const nodes = baseNodes.map((node) => {
520
+ const stepId = node.data.id;
521
+ const executionStatus = getStepStatus(stepId, executionPath);
522
+ const isExecuted = executionPath?.executedSteps.has(stepId) ?? false;
523
+ const isDimmed = calculateDimState(stepId, executionPath, entryPointId, hasExecutionData, mode);
524
+ const isSelected = selectedStepId === stepId;
525
+ const stepData = executionPath?.stepDataMap?.get(stepId);
526
+ return {
527
+ ...node,
528
+ type: "unifiedWorkflowNode",
529
+ data: {
530
+ // Structure data
531
+ id: node.data.id,
532
+ name: node.data.name,
533
+ description: node.data.description,
534
+ isEntryPoint: node.data.isEntryPoint,
535
+ isEndNode: node.data.isEndNode,
536
+ isConditional: node.data.isConditional,
537
+ routeCount: node.data.routeCount,
538
+ // Execution state
539
+ executionStatus,
540
+ duration: stepData?.duration,
541
+ input: stepData?.input,
542
+ output: stepData?.output,
543
+ error: stepData?.error,
544
+ logs: stepData?.logs,
545
+ // Computed UI state
546
+ isExecuted,
547
+ isDimmed,
548
+ isSelected
549
+ }
550
+ };
551
+ });
552
+ const edges = baseEdges.map((edge) => {
553
+ const wasTaken = executionPath?.takenEdges.has(edge.id) ?? false;
554
+ const sourceStatus = getStepStatus(edge.source, executionPath);
555
+ const targetStatus = getStepStatus(edge.target, executionPath);
556
+ const isDimmed = mode === "execution" && hasExecutionData && !wasTaken;
557
+ const isAnimated = wasTaken && sourceStatus && targetStatus ? shouldAnimateEdge(sourceStatus, targetStatus) : false;
558
+ return {
559
+ ...edge,
560
+ type: "unifiedWorkflowEdge",
561
+ data: {
562
+ // Structure data
563
+ edgeType: edge.data?.edgeType ?? "linear",
564
+ label: edge.data?.label,
565
+ // Execution state
566
+ wasTaken,
567
+ sourceStatus,
568
+ targetStatus,
569
+ // Computed UI state
570
+ isDimmed,
571
+ isAnimated
572
+ },
573
+ animated: isAnimated
574
+ };
575
+ });
576
+ return { nodes, edges, graphHeight };
577
+ }, [baseNodes, baseEdges, workflow, executionPath, selectedStepId, graphHeight, mode]);
578
+ }
579
+
580
+ // src/execution/components/constants.ts
581
+ var TIMELINE_CONSTANTS = {
582
+ // Bar dimensions
583
+ BAR_HEIGHT: 24,
584
+ ROW_GAP: 8,
585
+ MIN_BAR_WIDTH_PERCENT: 0.5,
586
+ // Minimum bar width as percentage (0.5% = ~8px on typical screen)
587
+ // Label column
588
+ LABEL_WIDTH: 200,
589
+ // Indentation for nested rows
590
+ INDENT_SIZE: 16,
591
+ // Container padding
592
+ CONTAINER_PADDING: 16,
593
+ CONTAINER_BORDER_RADIUS: 8
594
+ };
595
+ var SHARED_VIZ_CONSTANTS = {
596
+ // Node dimensions
597
+ NODE_WIDTH: 160,
598
+ NODE_SPACING: 220,
599
+ HANDLE_SIZE: 8,
600
+ // Zoom settings
601
+ MIN_ZOOM: 0.5,
602
+ MAX_ZOOM: 2
603
+ };
604
+ var CONTAINER_CONSTANTS = {
605
+ CONTAINER_HEIGHT: 400
606
+ };
607
+ var AGENT_CONSTANTS = {
608
+ // Inherited from shared constants
609
+ ...SHARED_VIZ_CONSTANTS,
610
+ // Agent-specific layout
611
+ NODE_HEIGHT: 140,
612
+ CONTAINER_HEIGHT: 430,
613
+ FIT_VIEW_PADDING: 0.2,
614
+ // Icon and circle sizes
615
+ ICON_SIZE: 16,
616
+ STATUS_ICON_SIZE: 16,
617
+ CIRCLE_SIZE: 40,
618
+ // Animation
619
+ PULSE_DURATION: "2s",
620
+ TRANSITION_DURATION: "0.2s"
621
+ };
622
+ var WORKFLOW_CONSTANTS = {
623
+ // Inherited from shared constants
624
+ ...SHARED_VIZ_CONSTANTS,
625
+ // Workflow-specific layout
626
+ FIT_VIEW_PADDING: 0.4,
627
+ // Workflow-specific dimensions
628
+ ICON_SIZE: 20,
629
+ CIRCLE_SIZE: 40,
630
+ // Animation
631
+ SPIN_DURATION: "1s"
632
+ };
633
+
634
+ // src/execution/hooks/useReactFlowAgent.ts
635
+ function useReactFlowAgent(iterationData, _resourceDefinition, selectedIterationId, liveExecutions, selectedExecutionId) {
636
+ return useMemo(() => {
637
+ if (!iterationData) {
638
+ return { nodes: [], edges: [] };
639
+ }
640
+ const isLive = selectedExecutionId ? liveExecutions.has(selectedExecutionId) : false;
641
+ const nodes = [];
642
+ const edges = [];
643
+ let xPosition = 0;
644
+ const yPosition = AGENT_CONSTANTS.CONTAINER_HEIGHT / 2;
645
+ nodes.push({
646
+ id: "initialization",
647
+ type: "agentIteration",
648
+ position: { x: xPosition, y: yPosition },
649
+ data: {
650
+ label: "Initialization",
651
+ nodeType: "initialization",
652
+ status: iterationData.initialization.status,
653
+ duration: iterationData.initialization.duration,
654
+ isLive: isLive && iterationData.initialization.status === "running"
655
+ },
656
+ selected: selectedIterationId === "initialization",
657
+ origin: [0.5, 0.5]
658
+ });
659
+ xPosition += AGENT_CONSTANTS.NODE_SPACING;
660
+ for (let i = 0; i < iterationData.iterations.length; i++) {
661
+ const iteration = iterationData.iterations[i];
662
+ const isSelected = selectedIterationId === iteration.iterationNumber;
663
+ const isCurrentIteration = iterationData.currentIteration === iteration.iterationNumber;
664
+ nodes.push({
665
+ id: `iteration-${iteration.iterationNumber}`,
666
+ type: "agentIteration",
667
+ position: { x: xPosition, y: yPosition },
668
+ data: {
669
+ iterationNumber: iteration.iterationNumber,
670
+ nodeType: "iteration",
671
+ status: iteration.status,
672
+ reasoningCount: iteration.iterationEvents.filter((e) => e.eventType === "reasoning").length,
673
+ actionCount: iteration.iterationEvents.filter((e) => e.eventType === "action").length,
674
+ duration: iteration.duration,
675
+ isLive: isLive && isCurrentIteration
676
+ },
677
+ selected: isSelected,
678
+ origin: [0.5, 0.5]
679
+ });
680
+ xPosition += AGENT_CONSTANTS.NODE_SPACING;
681
+ }
682
+ const completionStarted = iterationData.completion.status !== "pending";
683
+ if (completionStarted) {
684
+ nodes.push({
685
+ id: "completion",
686
+ type: "agentIteration",
687
+ position: { x: xPosition, y: yPosition },
688
+ data: {
689
+ label: "Completion",
690
+ nodeType: "completion",
691
+ status: iterationData.completion.status,
692
+ duration: iterationData.completion.duration,
693
+ isLive: isLive && iterationData.completion.status === "running"
694
+ },
695
+ selected: selectedIterationId === "completion",
696
+ origin: [0.5, 0.5]
697
+ });
698
+ }
699
+ if (iterationData.iterations.length > 0 && iterationData.initialization.status !== "failed") {
700
+ edges.push({
701
+ id: "edge-init-iter1",
702
+ source: "initialization",
703
+ target: `iteration-${iterationData.iterations[0].iterationNumber}`,
704
+ type: "agentIteration",
705
+ data: {
706
+ sourceStatus: iterationData.initialization.status,
707
+ targetStatus: iterationData.iterations[0].status
708
+ }
709
+ });
710
+ } else if (iterationData.iterations.length === 0 && completionStarted) {
711
+ edges.push({
712
+ id: "edge-init-completion",
713
+ source: "initialization",
714
+ target: "completion",
715
+ type: "agentIteration",
716
+ data: {
717
+ sourceStatus: iterationData.initialization.status,
718
+ targetStatus: iterationData.completion.status
719
+ }
720
+ });
721
+ }
722
+ for (let i = 0; i < iterationData.iterations.length - 1; i++) {
723
+ const sourceIteration = iterationData.iterations[i];
724
+ const targetIteration = iterationData.iterations[i + 1];
725
+ edges.push({
726
+ id: `edge-${sourceIteration.iterationNumber}-${targetIteration.iterationNumber}`,
727
+ source: `iteration-${sourceIteration.iterationNumber}`,
728
+ target: `iteration-${targetIteration.iterationNumber}`,
729
+ type: "agentIteration",
730
+ data: {
731
+ sourceStatus: sourceIteration.status,
732
+ targetStatus: targetIteration.status
733
+ }
734
+ });
735
+ }
736
+ if (iterationData.iterations.length > 0 && completionStarted) {
737
+ const lastIteration = iterationData.iterations[iterationData.iterations.length - 1];
738
+ edges.push({
739
+ id: "edge-last-completion",
740
+ source: `iteration-${lastIteration.iterationNumber}`,
741
+ target: "completion",
742
+ type: "agentIteration",
743
+ data: {
744
+ sourceStatus: lastIteration.status,
745
+ targetStatus: iterationData.completion.status
746
+ }
747
+ });
748
+ }
749
+ return { nodes, edges };
750
+ }, [iterationData, selectedIterationId, liveExecutions, selectedExecutionId]);
751
+ }
752
+ function ExecutionStatusBadge({
753
+ status,
754
+ size = "sm",
755
+ variant = "light",
756
+ showLoader = true
757
+ }) {
758
+ const statusColors = STATUS_COLORS[status];
759
+ const isRunning = status === "running" && showLoader;
760
+ return /* @__PURE__ */ jsx(
761
+ Badge,
762
+ {
763
+ color: statusColors.badge,
764
+ size,
765
+ variant,
766
+ leftSection: isRunning ? /* @__PURE__ */ jsx(Loader, { size: 10, color: statusColors.badge }) : void 0,
767
+ children: status.charAt(0).toUpperCase() + status.slice(1)
768
+ }
769
+ );
770
+ }
771
+ function getRateColor(rate) {
772
+ if (rate >= 95) return "var(--color-success)";
773
+ if (rate >= 80) return "var(--color-warning)";
774
+ return "var(--color-error)";
775
+ }
776
+ function getMantineRateColor(rate) {
777
+ if (rate >= 95) return "green";
778
+ if (rate >= 80) return "yellow";
779
+ return "red";
780
+ }
781
+ function ExecutionStats({
782
+ totalExecutions,
783
+ successCount,
784
+ failureCount,
785
+ warningCount,
786
+ successRate,
787
+ align = "flex-end",
788
+ compact = false
789
+ }) {
790
+ if (totalExecutions === 0 && !compact) {
791
+ return null;
792
+ }
793
+ if (compact && totalExecutions === 0) {
794
+ return /* @__PURE__ */ jsxs(Group, { gap: 10, wrap: "nowrap", style: { width: "100%" }, children: [
795
+ /* @__PURE__ */ jsx(Text, { size: "md", fw: 700, ff: "monospace", c: "dimmed", style: { minWidth: 42 }, children: "\u2014" }),
796
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", style: { whiteSpace: "nowrap" }, children: "No recent executions" })
797
+ ] });
798
+ }
799
+ if (compact) {
800
+ return /* @__PURE__ */ jsxs(Group, { gap: 10, wrap: "nowrap", style: { width: "100%" }, children: [
801
+ /* @__PURE__ */ jsxs(Group, { gap: 8, wrap: "nowrap", children: [
802
+ /* @__PURE__ */ jsxs(Text, { size: "md", fw: 700, ff: "monospace", style: { color: getRateColor(successRate), minWidth: 42 }, children: [
803
+ successRate,
804
+ "%"
805
+ ] }),
806
+ /* @__PURE__ */ jsxs(Group, { gap: 5, wrap: "nowrap", children: [
807
+ /* @__PURE__ */ jsx("div", { style: { width: 7, height: 7, borderRadius: "50%", background: "var(--color-success)" } }),
808
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, c: "green", children: successCount })
809
+ ] }),
810
+ failureCount > 0 && /* @__PURE__ */ jsxs(Group, { gap: 5, wrap: "nowrap", children: [
811
+ /* @__PURE__ */ jsx("div", { style: { width: 7, height: 7, borderRadius: "50%", background: "var(--color-error)" } }),
812
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, c: "red", children: failureCount })
813
+ ] })
814
+ ] }),
815
+ /* @__PURE__ */ jsxs(Text, { size: "sm", c: "dimmed", style: { whiteSpace: "nowrap" }, children: [
816
+ totalExecutions,
817
+ " ",
818
+ totalExecutions === 1 ? "run" : "runs"
819
+ ] })
820
+ ] });
821
+ }
822
+ return /* @__PURE__ */ jsxs(Stack, { gap: 2, align, style: { whiteSpace: "nowrap" }, children: [
823
+ /* @__PURE__ */ jsxs(Text, { size: "xs", c: "blue", children: [
824
+ totalExecutions,
825
+ " ",
826
+ totalExecutions === 1 ? "execution" : "executions"
827
+ ] }),
828
+ /* @__PURE__ */ jsxs(Text, { size: "xs", c: "green", children: [
829
+ successCount,
830
+ " success"
831
+ ] }),
832
+ warningCount != null && warningCount > 0 && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "yellow", children: [
833
+ warningCount,
834
+ " warning"
835
+ ] }),
836
+ failureCount > 0 && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "red", children: [
837
+ failureCount,
838
+ " failed"
839
+ ] }),
840
+ /* @__PURE__ */ jsxs(Text, { size: "xs", fw: 600, c: getMantineRateColor(successRate), children: [
841
+ successRate,
842
+ "% Success Rate"
843
+ ] })
844
+ ] });
845
+ }
846
+ function TimelineAxis({ totalDuration }) {
847
+ const markers = [
848
+ { position: 0, time: 0 },
849
+ { position: 25, time: totalDuration * 0.25 },
850
+ { position: 50, time: totalDuration * 0.5 },
851
+ { position: 75, time: totalDuration * 0.75 },
852
+ { position: 100, time: totalDuration }
853
+ ];
854
+ return /* @__PURE__ */ jsx(
855
+ Box,
856
+ {
857
+ style: {
858
+ position: "relative",
859
+ height: 20
860
+ },
861
+ children: markers.map((marker, idx) => /* @__PURE__ */ jsx(
862
+ Box,
863
+ {
864
+ style: {
865
+ position: "absolute",
866
+ left: `${marker.position}%`,
867
+ transform: marker.position === 100 ? "translateX(-100%)" : marker.position === 0 ? "none" : "translateX(-50%)",
868
+ top: 4
869
+ },
870
+ children: /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatDuration(marker.time) })
871
+ },
872
+ idx
873
+ ))
874
+ }
875
+ );
876
+ }
877
+ function TimelineContainer({ executionStart, executionEnd, children }) {
878
+ const totalDuration = executionEnd - executionStart;
879
+ return /* @__PURE__ */ jsxs(
880
+ Box,
881
+ {
882
+ style: {
883
+ borderBottom: "1px solid var(--color-border)",
884
+ borderRadius: "var(--mantine-radius-default)",
885
+ backgroundColor: "var(--color-background)",
886
+ padding: "var(--mantine-spacing-xs)"
887
+ },
888
+ children: [
889
+ /* @__PURE__ */ jsx(
890
+ Box,
891
+ {
892
+ style: {
893
+ position: "relative"
894
+ },
895
+ children: /* @__PURE__ */ jsx(Box, { style: { position: "relative", zIndex: 1 }, children })
896
+ }
897
+ ),
898
+ /* @__PURE__ */ jsx(Box, { style: { paddingLeft: TIMELINE_CONSTANTS.LABEL_WIDTH + 12, paddingRight: 16 }, children: /* @__PURE__ */ jsx(TimelineAxis, { totalDuration }) })
899
+ ]
900
+ }
901
+ );
902
+ }
903
+
904
+ // src/execution/utils/calculateBarPosition.ts
905
+ function calculateBarPosition(startTime, endTime, executionStart, executionEnd) {
906
+ const totalDuration = executionEnd - executionStart;
907
+ if (totalDuration <= 0) {
908
+ return { left: 0, width: 100 };
909
+ }
910
+ const relativeStart = startTime - executionStart;
911
+ const duration = endTime - startTime;
912
+ if (relativeStart < 0) {
913
+ console.warn("Activity start time is before execution start time");
914
+ const calculatedWidth = Math.max(0, duration / totalDuration * 100);
915
+ return { left: 0, width: Math.max(TIMELINE_CONSTANTS.MIN_BAR_WIDTH_PERCENT, calculatedWidth) };
916
+ }
917
+ if (startTime + duration > executionEnd) {
918
+ console.warn("Activity end time exceeds execution end time");
919
+ const cappedDuration = Math.max(0, executionEnd - startTime);
920
+ const calculatedWidth = cappedDuration / totalDuration * 100;
921
+ return {
922
+ left: relativeStart / totalDuration * 100,
923
+ width: Math.max(TIMELINE_CONSTANTS.MIN_BAR_WIDTH_PERCENT, calculatedWidth)
924
+ };
925
+ }
926
+ const left = relativeStart / totalDuration * 100;
927
+ const width = duration / totalDuration * 100;
928
+ return {
929
+ left: Math.max(0, Math.min(100, left)),
930
+ width: Math.max(TIMELINE_CONSTANTS.MIN_BAR_WIDTH_PERCENT, Math.min(100, width))
931
+ };
932
+ }
933
+ function TimelineBar({
934
+ startTime,
935
+ endTime,
936
+ executionStart,
937
+ executionEnd,
938
+ status,
939
+ label,
940
+ onClick,
941
+ isSelected = false,
942
+ hasSelection = false
943
+ }) {
944
+ const colors = getStatusColors(status);
945
+ const { left, width } = calculateBarPosition(startTime, endTime, executionStart, executionEnd);
946
+ const opacity = hasSelection && !isSelected ? 0.5 : 1;
947
+ return /* @__PURE__ */ jsx(
948
+ Box,
949
+ {
950
+ style: {
951
+ position: "absolute",
952
+ left: `${left}%`,
953
+ width: `${width}%`,
954
+ top: 4,
955
+ height: TIMELINE_CONSTANTS.BAR_HEIGHT / 2,
956
+ backgroundColor: colors.color,
957
+ opacity,
958
+ borderRadius: 4,
959
+ cursor: onClick ? "pointer" : "default",
960
+ display: "flex",
961
+ alignItems: "center",
962
+ justifyContent: "center",
963
+ overflow: "hidden"
964
+ },
965
+ onClick,
966
+ children: label && /* @__PURE__ */ jsx(Text, { size: "xs", c: "white", style: { whiteSpace: "nowrap" }, children: label })
967
+ }
968
+ );
969
+ }
970
+ function TimelineRow({ label, bars, executionStart, executionEnd, indent = 0, selectedNodeId }) {
971
+ const labelMatch = label.match(/^(.+?)\s*\((.+?)\)$/);
972
+ const labelName = labelMatch ? labelMatch[1] : label;
973
+ const labelDuration = labelMatch ? labelMatch[2] : null;
974
+ const statusColor = bars.length > 0 ? getStatusColors(bars[0].status).color : "var(--color-text-dimmed)";
975
+ const hasSelection = selectedNodeId !== null && selectedNodeId !== void 0;
976
+ return /* @__PURE__ */ jsxs(
977
+ Box,
978
+ {
979
+ style: {
980
+ display: "flex",
981
+ gap: 0,
982
+ height: TIMELINE_CONSTANTS.BAR_HEIGHT
983
+ // paddingLeft: indent * TIMELINE_CONSTANTS.INDENT_SIZE
984
+ },
985
+ children: [
986
+ /* @__PURE__ */ jsxs(
987
+ Box,
988
+ {
989
+ style: {
990
+ height: TIMELINE_CONSTANTS.BAR_HEIGHT,
991
+ width: TIMELINE_CONSTANTS.LABEL_WIDTH,
992
+ flexShrink: 0,
993
+ display: "flex",
994
+ alignItems: "center",
995
+ gap: 6,
996
+ paddingRight: 12,
997
+ paddingLeft: 8 + indent * TIMELINE_CONSTANTS.INDENT_SIZE,
998
+ // Indent only the label, not the timeline bars
999
+ overflow: "hidden"
1000
+ },
1001
+ children: [
1002
+ /* @__PURE__ */ jsx(
1003
+ Box,
1004
+ {
1005
+ style: {
1006
+ width: 6,
1007
+ height: 6,
1008
+ borderRadius: "50%",
1009
+ backgroundColor: statusColor,
1010
+ flexShrink: 0
1011
+ }
1012
+ }
1013
+ ),
1014
+ /* @__PURE__ */ jsx(Text, { size: "sm", truncate: true, style: { flexShrink: 1, minWidth: 0 }, children: labelName }),
1015
+ labelDuration && /* @__PURE__ */ jsxs(Text, { size: "sm", c: "dimmed", ff: "monospace", style: { flexShrink: 0 }, children: [
1016
+ "(",
1017
+ labelDuration,
1018
+ ")"
1019
+ ] })
1020
+ ]
1021
+ }
1022
+ ),
1023
+ /* @__PURE__ */ jsx(
1024
+ Box,
1025
+ {
1026
+ style: {
1027
+ position: "relative",
1028
+ flex: 1,
1029
+ height: TIMELINE_CONSTANTS.BAR_HEIGHT,
1030
+ marginLeft: 12,
1031
+ marginRight: 16
1032
+ // Right margin to match grid padding
1033
+ },
1034
+ children: bars.map((bar, idx) => {
1035
+ const isSelected = bar.nodeId !== void 0 && bar.nodeId === selectedNodeId;
1036
+ return /* @__PURE__ */ jsx(
1037
+ TimelineBar,
1038
+ {
1039
+ ...bar,
1040
+ executionStart,
1041
+ executionEnd,
1042
+ isSelected,
1043
+ hasSelection
1044
+ },
1045
+ idx
1046
+ );
1047
+ })
1048
+ }
1049
+ )
1050
+ ]
1051
+ }
1052
+ );
1053
+ }
1054
+ var VisualizerContainer = ({ children, handleContainerClick, height }) => {
1055
+ const containerHeight = height ?? CONTAINER_CONSTANTS.CONTAINER_HEIGHT;
1056
+ return /* @__PURE__ */ jsx(
1057
+ Box,
1058
+ {
1059
+ bg: "var(--color-background)",
1060
+ onClick: handleContainerClick,
1061
+ style: {
1062
+ borderBottom: "1px solid var(--color-border)",
1063
+ borderRadius: "var(--mantine-radius-default)"
1064
+ },
1065
+ children: /* @__PURE__ */ jsx(
1066
+ "div",
1067
+ {
1068
+ style: {
1069
+ width: "100%",
1070
+ height: `${containerHeight}px`,
1071
+ overflow: "hidden"
1072
+ },
1073
+ children
1074
+ }
1075
+ )
1076
+ }
1077
+ );
1078
+ };
1079
+ var EmptyVisualizer = ({ message = "Select an execution to view timeline" }) => {
1080
+ return /* @__PURE__ */ jsx(
1081
+ Box,
1082
+ {
1083
+ h: CONTAINER_CONSTANTS.CONTAINER_HEIGHT,
1084
+ bg: "var(--color-background)",
1085
+ style: {
1086
+ borderBottom: "1px solid var(--color-border)",
1087
+ borderRadius: "var(--mantine-radius-default)",
1088
+ display: "flex",
1089
+ alignItems: "center",
1090
+ justifyContent: "center"
1091
+ },
1092
+ children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: message })
1093
+ }
1094
+ );
1095
+ };
1096
+ var SPIN_ANIMATION = `
1097
+ @keyframes spin {
1098
+ from { transform: rotate(0deg); }
1099
+ to { transform: rotate(360deg); }
1100
+ }
1101
+ `;
1102
+ function getStatusIcon({ status, colors, iconSize, spinDuration = "1s" }) {
1103
+ switch (status) {
1104
+ case "completed":
1105
+ return /* @__PURE__ */ jsx(IconCheck, { size: iconSize, color: colors.icon });
1106
+ case "failed":
1107
+ return /* @__PURE__ */ jsx(IconX, { size: iconSize, color: colors.icon });
1108
+ case "warning":
1109
+ return /* @__PURE__ */ jsx(IconAlertTriangle, { size: iconSize, color: colors.icon });
1110
+ case "running":
1111
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1112
+ /* @__PURE__ */ jsx("style", { children: SPIN_ANIMATION }),
1113
+ /* @__PURE__ */ jsx(
1114
+ IconLoader,
1115
+ {
1116
+ size: iconSize,
1117
+ color: colors.icon,
1118
+ style: { animation: `spin ${spinDuration} linear infinite` }
1119
+ }
1120
+ )
1121
+ ] });
1122
+ case "pending":
1123
+ default:
1124
+ return /* @__PURE__ */ jsx(IconCircleDot, { size: iconSize, color: colors.icon });
1125
+ }
1126
+ }
1127
+ var UnifiedWorkflowNode = memo(function UnifiedWorkflowNode2({ data }) {
1128
+ const selected = data.isSelected ?? false;
1129
+ const primaryColor = data.isEntryPoint ? "teal" : data.isEndNode ? "violet" : data.isConditional ? "orange" : "blue";
1130
+ const statusColors = data.executionStatus ? STATUS_COLORS[data.executionStatus] : void 0;
1131
+ const showExecutionStatus = data.isExecuted && data.executionStatus;
1132
+ return /* @__PURE__ */ jsx(
1133
+ BaseNode,
1134
+ {
1135
+ color: primaryColor,
1136
+ selected,
1137
+ highlighted: Boolean(data.highlighted),
1138
+ width: 220,
1139
+ className: data.isDimmed ? "dimmed-node" : "",
1140
+ showSourceHandle: !data.isEndNode,
1141
+ children: /* @__PURE__ */ jsx("div", { style: { opacity: data.isDimmed ? 0.3 : 1 }, children: /* @__PURE__ */ jsxs(Stack, { gap: 6, children: [
1142
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, lineClamp: 1, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: data.name }),
1143
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
1144
+ data.isEntryPoint && /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "teal", leftSection: /* @__PURE__ */ jsx(IconPlayerPlay, { size: 10 }), children: "Entry" }),
1145
+ data.isEndNode && /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "violet", leftSection: /* @__PURE__ */ jsx(IconPlayerStop, { size: 10 }), children: "End" }),
1146
+ data.isConditional && /* @__PURE__ */ jsxs(Badge, { size: "xs", variant: "light", color: "orange", leftSection: /* @__PURE__ */ jsx(IconArrowsSplit, { size: 10 }), children: [
1147
+ data.routeCount,
1148
+ " routes"
1149
+ ] }),
1150
+ !data.isEntryPoint && !data.isEndNode && !data.isConditional && /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", leftSection: /* @__PURE__ */ jsx(IconSquare, { size: 10 }), children: "Step" }),
1151
+ /* @__PURE__ */ jsx(Text, { size: "xs", ff: "monospace", c: "dimmed", truncate: true, children: data.id })
1152
+ ] }),
1153
+ !data.isDimmed && data.description && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", lineClamp: 2, children: data.description }),
1154
+ showExecutionStatus && statusColors && /* @__PURE__ */ jsx(Box, { mt: 4, children: /* @__PURE__ */ jsxs(Group, { gap: 8, align: "center", children: [
1155
+ /* @__PURE__ */ jsx(Box, { children: getStatusIcon({
1156
+ status: data.executionStatus,
1157
+ colors: { icon: statusColors.color },
1158
+ iconSize: 16,
1159
+ spinDuration: "1s"
1160
+ }) }),
1161
+ /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: statusColors.badge, children: data.executionStatus }),
1162
+ data.duration !== void 0 && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatDuration(data.duration) })
1163
+ ] }) })
1164
+ ] }) })
1165
+ }
1166
+ );
1167
+ });
1168
+ var UnifiedWorkflowEdge = memo(function UnifiedWorkflowEdge2({
1169
+ id,
1170
+ sourceX,
1171
+ sourceY,
1172
+ targetX,
1173
+ targetY,
1174
+ selected,
1175
+ data
1176
+ }) {
1177
+ const colors = useGraphTheme();
1178
+ const edgeType = data?.edgeType || "linear";
1179
+ const isDimmed = data?.isDimmed ?? false;
1180
+ const isAnimated = data?.isAnimated ?? false;
1181
+ let edgeColor;
1182
+ let glowColor;
1183
+ let label;
1184
+ switch (edgeType) {
1185
+ case "conditional":
1186
+ edgeColor = colors.trigger;
1187
+ glowColor = colors.triggerGlow;
1188
+ label = data?.label || "route";
1189
+ break;
1190
+ case "default":
1191
+ edgeColor = colors.integration;
1192
+ glowColor = colors.integrationGlow;
1193
+ label = data?.label || "default";
1194
+ break;
1195
+ case "linear":
1196
+ default:
1197
+ edgeColor = colors.workflow;
1198
+ glowColor = colors.workflowGlow;
1199
+ label = void 0;
1200
+ break;
1201
+ }
1202
+ return /* @__PURE__ */ jsx(
1203
+ BaseEdge,
1204
+ {
1205
+ id,
1206
+ sourceX,
1207
+ sourceY,
1208
+ targetX,
1209
+ targetY,
1210
+ sourcePosition: Position.Right,
1211
+ targetPosition: Position.Left,
1212
+ color: edgeColor,
1213
+ glowColor,
1214
+ label,
1215
+ selected,
1216
+ animated: isAnimated,
1217
+ dimmed: isDimmed
1218
+ }
1219
+ );
1220
+ });
1221
+ var nodeTypes = {
1222
+ unifiedWorkflowNode: UnifiedWorkflowNode
1223
+ };
1224
+ var edgeTypes = {
1225
+ unifiedWorkflowEdge: UnifiedWorkflowEdge
1226
+ };
1227
+ var NODE_LEGEND_ITEMS = [
1228
+ { color: "teal", label: "Entry" },
1229
+ { color: "blue", label: "Step" },
1230
+ { color: "orange", label: "Conditional" },
1231
+ { color: "violet", label: "End" }
1232
+ ];
1233
+ var EDGE_LEGEND_ITEMS = [
1234
+ { color: "blue", label: "Next", type: "line" },
1235
+ { color: "orange", label: "Route", type: "line" },
1236
+ { color: "teal", label: "Default", type: "line" }
1237
+ ];
1238
+ function UnifiedWorkflowGraph({
1239
+ resourceDefinition,
1240
+ executionLogs,
1241
+ selectedStepId,
1242
+ onStepSelect,
1243
+ fitViewTrigger: externalFitViewTrigger
1244
+ }) {
1245
+ const hasExecutionData = executionLogs && executionLogs.length > 0;
1246
+ const [mode, setMode] = useState(hasExecutionData ? "execution" : "definition");
1247
+ useEffect(() => {
1248
+ setMode(hasExecutionData ? "execution" : "definition");
1249
+ }, [hasExecutionData]);
1250
+ const isDefinitionMode = mode === "definition";
1251
+ const executionPath = useExecutionPath(
1252
+ isDefinitionMode ? void 0 : executionLogs,
1253
+ isDefinitionMode ? void 0 : resourceDefinition
1254
+ );
1255
+ const workflowInput = useMemo(
1256
+ () => resourceDefinition ? { entryPoint: resourceDefinition.entryPoint, steps: resourceDefinition.steps } : void 0,
1257
+ [resourceDefinition]
1258
+ );
1259
+ const { nodes: layoutNodes, edges: layoutEdges, graphHeight } = useUnifiedWorkflowLayout(
1260
+ workflowInput,
1261
+ executionPath,
1262
+ isDefinitionMode ? null : selectedStepId,
1263
+ mode
1264
+ );
1265
+ const {
1266
+ nodes: highlightedNodes,
1267
+ edges: highlightedEdges,
1268
+ handleNodeMouseEnter,
1269
+ handleNodeMouseLeave
1270
+ } = useDirectedChainHighlighting(layoutNodes, layoutEdges);
1271
+ const nodes = isDefinitionMode ? highlightedNodes : layoutNodes;
1272
+ const edges = isDefinitionMode ? highlightedEdges : layoutEdges;
1273
+ const [internalFitViewTrigger, setInternalFitViewTrigger] = useState(0);
1274
+ const executedStepsCount = executionPath?.executedSteps.size ?? 0;
1275
+ const nodesCount = nodes.length;
1276
+ useEffect(() => {
1277
+ if (nodesCount > 0) {
1278
+ setInternalFitViewTrigger((prev) => prev + 1);
1279
+ }
1280
+ }, [nodesCount, executedStepsCount]);
1281
+ const fitViewTrigger = (externalFitViewTrigger ?? 0) + internalFitViewTrigger;
1282
+ const { handleNodeClick, handlePaneClick, handleContainerClick } = useNodeSelection(
1283
+ selectedStepId || null,
1284
+ onStepSelect || (() => {
1285
+ })
1286
+ );
1287
+ if (!resourceDefinition || !resourceDefinition.steps.length) {
1288
+ return /* @__PURE__ */ jsx(EmptyVisualizer, {});
1289
+ }
1290
+ return /* @__PURE__ */ jsx(
1291
+ VisualizerContainer,
1292
+ {
1293
+ handleContainerClick: isDefinitionMode ? void 0 : handleContainerClick,
1294
+ height: graphHeight,
1295
+ children: /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsxs(
1296
+ ReactFlow,
1297
+ {
1298
+ nodes,
1299
+ edges,
1300
+ nodeTypes,
1301
+ edgeTypes,
1302
+ onNodeClick: isDefinitionMode ? void 0 : handleNodeClick,
1303
+ onPaneClick: isDefinitionMode ? void 0 : handlePaneClick,
1304
+ onNodeMouseEnter: isDefinitionMode ? handleNodeMouseEnter : void 0,
1305
+ onNodeMouseLeave: isDefinitionMode ? handleNodeMouseLeave : void 0,
1306
+ fitView: true,
1307
+ fitViewOptions: {
1308
+ padding: WORKFLOW_CONSTANTS.FIT_VIEW_PADDING
1309
+ },
1310
+ proOptions: { hideAttribution: true },
1311
+ minZoom: WORKFLOW_CONSTANTS.MIN_ZOOM,
1312
+ maxZoom: WORKFLOW_CONSTANTS.MAX_ZOOM,
1313
+ defaultViewport: { x: 0, y: 0, zoom: 1 },
1314
+ nodesDraggable: false,
1315
+ nodesConnectable: false,
1316
+ elementsSelectable: !isDefinitionMode,
1317
+ selectNodesOnDrag: false,
1318
+ zoomOnScroll: true,
1319
+ panOnDrag: true,
1320
+ className: Graph_default.graphContainer,
1321
+ children: [
1322
+ /* @__PURE__ */ jsx(GraphBackground, {}),
1323
+ /* @__PURE__ */ jsx(Panel, { position: "top-right", style: { marginTop: 12, marginRight: 12 }, children: /* @__PURE__ */ jsx(
1324
+ SegmentedControl,
1325
+ {
1326
+ size: "xs",
1327
+ value: mode,
1328
+ onChange: (value) => setMode(value),
1329
+ data: [
1330
+ { label: "Definition", value: "definition" },
1331
+ { label: "Execution", value: "execution" }
1332
+ ],
1333
+ styles: {
1334
+ root: {
1335
+ backgroundColor: "var(--color-surface)",
1336
+ border: "1px solid var(--color-border)"
1337
+ }
1338
+ }
1339
+ }
1340
+ ) }),
1341
+ /* @__PURE__ */ jsx(GraphLegend, { title: "Legend", items: NODE_LEGEND_ITEMS, position: "bottom-right" }),
1342
+ /* @__PURE__ */ jsx(GraphLegend, { title: "Flow", items: EDGE_LEGEND_ITEMS, position: "bottom-left" }),
1343
+ /* @__PURE__ */ jsx(GraphFitViewButton, { padding: WORKFLOW_CONSTANTS.FIT_VIEW_PADDING, variant: "mantine" }),
1344
+ /* @__PURE__ */ jsx(GraphFitViewHandler, { trigger: fitViewTrigger, padding: WORKFLOW_CONSTANTS.FIT_VIEW_PADDING })
1345
+ ]
1346
+ }
1347
+ ) })
1348
+ }
1349
+ );
1350
+ }
1351
+ function WorkflowExecutionTimeline({ timelineData, selectedStepId }) {
1352
+ const { steps } = timelineData;
1353
+ const executionStart = steps[0]?.startTime || 0;
1354
+ const executionEnd = steps[steps.length - 1]?.endTime || executionStart;
1355
+ return /* @__PURE__ */ jsx(TimelineContainer, { executionStart, executionEnd, children: steps.map(
1356
+ (step) => step.startTime && step.endTime && /* @__PURE__ */ jsx(
1357
+ TimelineRow,
1358
+ {
1359
+ label: step.stepName,
1360
+ bars: [
1361
+ {
1362
+ startTime: step.startTime,
1363
+ endTime: step.endTime,
1364
+ status: step.status,
1365
+ nodeId: step.stepId
1366
+ }
1367
+ ],
1368
+ executionStart,
1369
+ executionEnd,
1370
+ selectedNodeId: selectedStepId
1371
+ },
1372
+ step.stepId
1373
+ )
1374
+ ) });
1375
+ }
1376
+ var statusColorMap = {
1377
+ running: "blue",
1378
+ completed: "teal",
1379
+ failed: "orange",
1380
+ pending: "violet",
1381
+ warning: "yellow"
1382
+ };
1383
+ var AgentIterationNode = memo(function AgentIterationNode2({ data, selected }) {
1384
+ const { nodeType, label, iterationNumber, status, reasoningCount, actionCount, duration, isLive } = data;
1385
+ const colors = getStatusColors(status);
1386
+ const nodeColor = statusColorMap[status];
1387
+ return /* @__PURE__ */ jsxs(BaseNode, { color: nodeColor, selected, width: AGENT_CONSTANTS.NODE_WIDTH, children: [
1388
+ /* @__PURE__ */ jsxs(Box, { style: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
1389
+ /* @__PURE__ */ jsx(
1390
+ Box,
1391
+ {
1392
+ style: {
1393
+ width: AGENT_CONSTANTS.CIRCLE_SIZE,
1394
+ height: AGENT_CONSTANTS.CIRCLE_SIZE,
1395
+ borderRadius: "50%",
1396
+ backgroundColor: "var(--color-surface)",
1397
+ border: `2px solid ${colors.color}`,
1398
+ display: "flex",
1399
+ alignItems: "center",
1400
+ justifyContent: "center"
1401
+ },
1402
+ children: getStatusIcon({
1403
+ status,
1404
+ colors: { icon: colors.color },
1405
+ iconSize: AGENT_CONSTANTS.STATUS_ICON_SIZE,
1406
+ spinDuration: "1s"
1407
+ })
1408
+ }
1409
+ ),
1410
+ /* @__PURE__ */ jsx(
1411
+ Text,
1412
+ {
1413
+ size: "sm",
1414
+ fw: status === "running" ? 500 : 400,
1415
+ ta: "center",
1416
+ mt: 4,
1417
+ style: { maxWidth: 150, fontFamily: "var(--mantine-font-family-headings)" },
1418
+ children: nodeType === "iteration" ? `Iteration ${iterationNumber}` : label
1419
+ }
1420
+ ),
1421
+ /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: colors.badge, mt: 4, children: status.toUpperCase() }),
1422
+ /* @__PURE__ */ jsxs(Stack, { gap: 2, mt: 2, align: "center", children: [
1423
+ nodeType === "iteration" && reasoningCount !== void 0 && reasoningCount > 0 && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
1424
+ reasoningCount,
1425
+ " reasoning"
1426
+ ] }),
1427
+ nodeType === "iteration" && actionCount !== void 0 && actionCount > 0 && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
1428
+ actionCount,
1429
+ " ",
1430
+ actionCount === 1 ? "action" : "actions"
1431
+ ] }),
1432
+ duration !== void 0 && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatDuration(duration) })
1433
+ ] })
1434
+ ] }),
1435
+ isLive && /* @__PURE__ */ jsx(
1436
+ Badge,
1437
+ {
1438
+ size: "xs",
1439
+ variant: "filled",
1440
+ style: {
1441
+ position: "absolute",
1442
+ top: 4,
1443
+ right: 4
1444
+ },
1445
+ children: /* @__PURE__ */ jsx("span", { className: Graph_default.livePulse, children: "LIVE" })
1446
+ }
1447
+ )
1448
+ ] });
1449
+ });
1450
+ var statusEdgeColors = {
1451
+ running: {
1452
+ color: "var(--mantine-color-blue-5)",
1453
+ glow: "rgba(59, 130, 246, 0.5)"
1454
+ },
1455
+ completed: {
1456
+ color: "var(--mantine-color-teal-5)",
1457
+ glow: "rgba(20, 184, 166, 0.5)"
1458
+ },
1459
+ failed: {
1460
+ color: "var(--mantine-color-orange-5)",
1461
+ glow: "rgba(249, 115, 22, 0.5)"
1462
+ },
1463
+ pending: {
1464
+ color: "var(--mantine-color-gray-5)",
1465
+ glow: "rgba(156, 163, 175, 0.3)"
1466
+ },
1467
+ warning: {
1468
+ color: "var(--mantine-color-yellow-5)",
1469
+ glow: "rgba(234, 179, 8, 0.5)"
1470
+ }
1471
+ };
1472
+ var AgentIterationEdge = memo(function AgentIterationEdge2({
1473
+ id,
1474
+ sourceX,
1475
+ sourceY,
1476
+ targetX,
1477
+ targetY,
1478
+ data,
1479
+ selected
1480
+ }) {
1481
+ const edgeData = data;
1482
+ const sourceStatus = edgeData?.sourceStatus || "pending";
1483
+ const targetStatus = edgeData?.targetStatus || "pending";
1484
+ const edgeColors = statusEdgeColors[sourceStatus];
1485
+ const isAnimated = shouldAnimateEdge(sourceStatus, targetStatus);
1486
+ return /* @__PURE__ */ jsx(
1487
+ BaseEdge,
1488
+ {
1489
+ id,
1490
+ sourceX,
1491
+ sourceY,
1492
+ targetX,
1493
+ targetY,
1494
+ sourcePosition: Position.Right,
1495
+ targetPosition: Position.Left,
1496
+ color: edgeColors.color,
1497
+ glowColor: edgeColors.glow,
1498
+ animated: isAnimated,
1499
+ selected
1500
+ }
1501
+ );
1502
+ });
1503
+ var nodeTypes2 = {
1504
+ agentIteration: AgentIterationNode
1505
+ };
1506
+ var edgeTypes2 = {
1507
+ agentIteration: AgentIterationEdge
1508
+ };
1509
+ function AgentExecutionVisualizer({
1510
+ resourceDefinition,
1511
+ iterationData,
1512
+ selectedExecutionId,
1513
+ liveExecutions,
1514
+ selectedIterationId,
1515
+ onIterationSelect
1516
+ }) {
1517
+ const { nodes, edges } = useReactFlowAgent(
1518
+ iterationData,
1519
+ resourceDefinition,
1520
+ selectedIterationId,
1521
+ liveExecutions,
1522
+ selectedExecutionId
1523
+ );
1524
+ const fitViewTrigger = useFitViewTrigger(iterationData, nodes);
1525
+ const handleIterationSelect = useCallback(
1526
+ (id) => {
1527
+ onIterationSelect(id);
1528
+ },
1529
+ [onIterationSelect]
1530
+ );
1531
+ const { handlePaneClick, handleContainerClick } = useNodeSelection(selectedIterationId, handleIterationSelect);
1532
+ const handleNodeClick = useCallback(
1533
+ (_event, node) => {
1534
+ if (node.id === "initialization" || node.id === "completion") {
1535
+ handleIterationSelect(selectedIterationId === node.id ? null : node.id);
1536
+ return;
1537
+ }
1538
+ const iterationNumber = Number.parseInt(node.id.replace("iteration-", ""), 10);
1539
+ if (!Number.isNaN(iterationNumber)) {
1540
+ handleIterationSelect(iterationNumber === selectedIterationId ? null : iterationNumber);
1541
+ }
1542
+ },
1543
+ [selectedIterationId, handleIterationSelect]
1544
+ );
1545
+ if (!iterationData || nodes.length === 0) {
1546
+ return /* @__PURE__ */ jsx(EmptyVisualizer, {});
1547
+ }
1548
+ return /* @__PURE__ */ jsx(VisualizerContainer, { handleContainerClick, children: /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsxs(
1549
+ ReactFlow,
1550
+ {
1551
+ nodes,
1552
+ edges,
1553
+ nodeTypes: nodeTypes2,
1554
+ edgeTypes: edgeTypes2,
1555
+ onNodeClick: handleNodeClick,
1556
+ onPaneClick: handlePaneClick,
1557
+ fitView: true,
1558
+ fitViewOptions: {
1559
+ padding: AGENT_CONSTANTS.FIT_VIEW_PADDING
1560
+ },
1561
+ proOptions: { hideAttribution: true },
1562
+ minZoom: AGENT_CONSTANTS.MIN_ZOOM,
1563
+ maxZoom: AGENT_CONSTANTS.MAX_ZOOM,
1564
+ nodesDraggable: false,
1565
+ nodesConnectable: false,
1566
+ elementsSelectable: true,
1567
+ selectNodesOnDrag: false,
1568
+ zoomOnScroll: false,
1569
+ panOnDrag: false,
1570
+ className: Graph_default.graphContainer,
1571
+ children: [
1572
+ /* @__PURE__ */ jsx(GraphBackground, {}),
1573
+ /* @__PURE__ */ jsx(GraphFitViewButton, { padding: AGENT_CONSTANTS.FIT_VIEW_PADDING, variant: "mantine", duration: 300 }),
1574
+ /* @__PURE__ */ jsx(GraphFitViewHandler, { trigger: fitViewTrigger, padding: AGENT_CONSTANTS.FIT_VIEW_PADDING })
1575
+ ]
1576
+ }
1577
+ ) }) });
1578
+ }
1579
+ function AgentExecutionTimeline({ iterationData, selectedIterationId }) {
1580
+ const { initialization, iterations, completion } = iterationData;
1581
+ const executionStart = initialization.startTime;
1582
+ const executionEnd = completion.endTime;
1583
+ return /* @__PURE__ */ jsxs(TimelineContainer, { executionStart, executionEnd, children: [
1584
+ initialization.startTime && initialization.endTime && /* @__PURE__ */ jsx(
1585
+ TimelineRow,
1586
+ {
1587
+ label: `Initialization (${formatDuration(initialization.duration || 0)})`,
1588
+ bars: [
1589
+ {
1590
+ startTime: initialization.startTime,
1591
+ endTime: initialization.endTime,
1592
+ status: initialization.status,
1593
+ nodeId: "initialization"
1594
+ }
1595
+ ],
1596
+ executionStart,
1597
+ executionEnd,
1598
+ selectedNodeId: selectedIterationId
1599
+ }
1600
+ ),
1601
+ iterations.map((iteration) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
1602
+ iteration.startTime && iteration.endTime && /* @__PURE__ */ jsx(
1603
+ TimelineRow,
1604
+ {
1605
+ label: `Iteration ${iteration.iterationNumber} (${formatDuration(iteration.duration || 0)})`,
1606
+ bars: [
1607
+ {
1608
+ startTime: iteration.startTime,
1609
+ endTime: iteration.endTime,
1610
+ status: iteration.status,
1611
+ nodeId: iteration.iterationNumber
1612
+ }
1613
+ ],
1614
+ executionStart,
1615
+ executionEnd,
1616
+ selectedNodeId: selectedIterationId
1617
+ }
1618
+ ),
1619
+ iteration.subActivities.map((activity, activityIndex) => /* @__PURE__ */ jsx(
1620
+ TimelineRow,
1621
+ {
1622
+ label: `${activity.type} (${formatDuration(activity.duration)})`,
1623
+ bars: [
1624
+ {
1625
+ startTime: activity.startTime,
1626
+ endTime: activity.endTime,
1627
+ status: "completed",
1628
+ nodeId: iteration.iterationNumber
1629
+ }
1630
+ ],
1631
+ executionStart,
1632
+ executionEnd,
1633
+ indent: 1,
1634
+ selectedNodeId: selectedIterationId
1635
+ },
1636
+ `${iteration.iterationNumber}-${activity.type}-${activity.startTime}-${activityIndex}`
1637
+ ))
1638
+ ] }, iteration.iterationNumber)),
1639
+ completion.startTime && completion.endTime && /* @__PURE__ */ jsx(
1640
+ TimelineRow,
1641
+ {
1642
+ label: `Completion (${formatDuration(completion.duration || 0)})`,
1643
+ bars: [
1644
+ {
1645
+ startTime: completion.startTime,
1646
+ endTime: completion.endTime,
1647
+ status: completion.status,
1648
+ nodeId: "completion"
1649
+ }
1650
+ ],
1651
+ executionStart,
1652
+ executionEnd,
1653
+ selectedNodeId: selectedIterationId
1654
+ }
1655
+ )
1656
+ ] });
1657
+ }
1658
+
1659
+ // src/execution/utils/getResourceStatusColor.ts
1660
+ function getResourceStatusColor(resourceStatus) {
1661
+ return resourceStatus === "dev" ? "var(--color-primary)" : "var(--color-success)";
1662
+ }
1663
+
1664
+ export { AGENT_CONSTANTS, AgentExecutionTimeline, AgentExecutionVisualizer, AgentIterationEdge, AgentIterationNode, CONTAINER_CONSTANTS, EmptyVisualizer, ExecutionStats, ExecutionStatusBadge, SHARED_VIZ_CONSTANTS, STATUS_COLORS, TIMELINE_CONSTANTS, TimelineAxis, TimelineBar, TimelineContainer, TimelineRow, UnifiedWorkflowEdge, UnifiedWorkflowGraph, UnifiedWorkflowNode, VisualizerContainer, WORKFLOW_CONSTANTS, WorkflowExecutionTimeline, calculateBarPosition, getEdgeColor, getEdgeOpacity, getResourceStatusColor, getStatusColors, getStatusIcon, shouldAnimateEdge, useAgentIterationData, useExecutionPath, useMergedExecution, useReactFlowAgent, useTimelineData, useUnifiedWorkflowLayout, useWorkflowStepsLayout };