|
1 | 1 | import { useCallback, useRef } from 'react' |
2 | 2 | import { createLogger } from '@sim/logger' |
3 | | -import type { ExecutionEvent } from '@/lib/workflows/executor/execution-events' |
| 3 | +import type { |
| 4 | + BlockCompletedData, |
| 5 | + BlockErrorData, |
| 6 | + BlockStartedData, |
| 7 | + ExecutionCancelledData, |
| 8 | + ExecutionCompletedData, |
| 9 | + ExecutionErrorData, |
| 10 | + ExecutionEvent, |
| 11 | + ExecutionStartedData, |
| 12 | + StreamChunkData, |
| 13 | + StreamDoneData, |
| 14 | +} from '@/lib/workflows/executor/execution-events' |
4 | 15 | import type { SerializableExecutionState } from '@/executor/execution/types' |
5 | | -import type { SubflowType } from '@/stores/workflows/workflow/types' |
6 | 16 |
|
7 | 17 | const logger = createLogger('useExecutionStream') |
8 | 18 |
|
@@ -81,48 +91,15 @@ async function processSSEStream( |
81 | 91 | } |
82 | 92 |
|
83 | 93 | export interface ExecutionStreamCallbacks { |
84 | | - onExecutionStarted?: (data: { startTime: string }) => void |
85 | | - onExecutionCompleted?: (data: { |
86 | | - success: boolean |
87 | | - output: any |
88 | | - duration: number |
89 | | - startTime: string |
90 | | - endTime: string |
91 | | - }) => void |
92 | | - onExecutionError?: (data: { error: string; duration: number }) => void |
93 | | - onExecutionCancelled?: (data: { duration: number }) => void |
94 | | - onBlockStarted?: (data: { |
95 | | - blockId: string |
96 | | - blockName: string |
97 | | - blockType: string |
98 | | - iterationCurrent?: number |
99 | | - iterationTotal?: number |
100 | | - iterationType?: SubflowType |
101 | | - }) => void |
102 | | - onBlockCompleted?: (data: { |
103 | | - blockId: string |
104 | | - blockName: string |
105 | | - blockType: string |
106 | | - input?: any |
107 | | - output: any |
108 | | - durationMs: number |
109 | | - iterationCurrent?: number |
110 | | - iterationTotal?: number |
111 | | - iterationType?: SubflowType |
112 | | - }) => void |
113 | | - onBlockError?: (data: { |
114 | | - blockId: string |
115 | | - blockName: string |
116 | | - blockType: string |
117 | | - input?: any |
118 | | - error: string |
119 | | - durationMs: number |
120 | | - iterationCurrent?: number |
121 | | - iterationTotal?: number |
122 | | - iterationType?: SubflowType |
123 | | - }) => void |
124 | | - onStreamChunk?: (data: { blockId: string; chunk: string }) => void |
125 | | - onStreamDone?: (data: { blockId: string }) => void |
| 94 | + onExecutionStarted?: (data: ExecutionStartedData) => void |
| 95 | + onExecutionCompleted?: (data: ExecutionCompletedData) => void |
| 96 | + onExecutionError?: (data: ExecutionErrorData) => void |
| 97 | + onExecutionCancelled?: (data: ExecutionCancelledData) => void |
| 98 | + onBlockStarted?: (data: BlockStartedData) => void |
| 99 | + onBlockCompleted?: (data: BlockCompletedData) => void |
| 100 | + onBlockError?: (data: BlockErrorData) => void |
| 101 | + onStreamChunk?: (data: StreamChunkData) => void |
| 102 | + onStreamDone?: (data: StreamDoneData) => void |
126 | 103 | } |
127 | 104 |
|
128 | 105 | export interface ExecuteStreamOptions { |
|
0 commit comments