> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ko/llms.txt # Run.timeTravelStream() 그만큼`.timeTravelStream()`메서드는 스트리밍 이벤트를 사용하여 특정 단계부터 시작하는 Workflow를 다시 실행합니다. 각 단계의 진행 상황에 대한 완전한 가시성을 유지하면서 시간 여행 실행 중에 실시간 업데이트를 받을 수 있습니다. ## 사용예 ```typescript const run = await workflow.createRun() const output = run.timeTravelStream({ step: 'step2', inputData: { value: 10 }, }) // Process events as they arrive for await (const event of output.fullStream) { console.log(event.type, event.payload) } // Get the final result const result = await output.result ``` ## 매개변수 모든 매개변수는 [`Run.timeTravel()`](https://mastra.zisheng.pro/ko/reference/workflows/run-methods/timeTravel)과 동일합니다. 자세한 매개변수 문서는 [timeTravel 레퍼런스](https://mastra.zisheng.pro/ko/reference/workflows/run-methods/timeTravel)를 참조하세요. ## 보고 **output** (`WorkflowRunOutput>`): 스트림과 결과 Promise를 모두 포함하는 객체입니다. **output.fullStream** (`ReadableStream`): 실행 진행에 따라 Workflow 이벤트를 방출하는 읽기 가능한 스트림입니다. **output.result** (`Promise>`): 최종 Workflow 실행 결과로 이행되는 Promise입니다. **output.traceId** (`string`): Tracing이 활성화된 경우 이 실행과 연결된 Trace ID입니다. ## 이벤트 스트리밍 스트림은 실행 중에 Workflow 이벤트를 내보냅니다. - `workflow-step-start`: 단계가 실행을 시작할 때 발생합니다. - `workflow-step-finish`: 단계가 성공적으로 완료되면 발생합니다. - `workflow-step-error`: 단계에서 오류가 발생하면 발생합니다. - `workflow-step-suspended`: 단계가 일시중단될 때 발생합니다. - 단계 유형(Agent, Tool 등)에 따른 추가 이벤트 ## 확장된 사용 예 ### 시간 여행 중 이벤트 처리 ```typescript const run = await workflow.createRun() const output = run.timeTravelStream({ step: 'step2', inputData: { value: 10 }, }) for await (const event of output.fullStream) { switch (event.type) { case 'workflow-step-start': console.log(`Starting step: ${event.payload.stepName}`) break case 'workflow-step-finish': console.log(`Completed step: ${event.payload.stepName}`) break case 'workflow-step-error': console.error(`Error in step: ${event.payload.stepName}`, event.payload.error) break } } const result = await output.result console.log('Time travel completed:', result) ``` ### 맥락이 있는 시간 여행 스트림 ```typescript const output = run.timeTravelStream({ step: 'step2', context: { step1: { status: 'success', payload: { value: 0 }, output: { step1Result: 2 }, startedAt: Date.now(), endedAt: Date.now(), }, }, }) for await (const event of output.fullStream) { // Handle events console.log(event) } const result = await output.result ``` ### 중첩된 Workflow를 사용한 시간 여행 스트림 ```typescript const output = run.timeTravelStream({ step: ['nestedWorkflow', 'step3'], inputData: { value: 10 }, nestedStepsContext: { nestedWorkflow: { step2: { status: 'success', payload: { step1Result: 2 }, output: { step2Result: 3 }, startedAt: Date.now(), endedAt: Date.now(), }, }, }, }) for await (const event of output.fullStream) { console.log(event.type, event.payload) } const result = await output.result ``` ## 메모 - 시간 이동 실행이 완료되거나 오류가 발생하면 스트림이 자동으로 닫힙니다. - Workflow가 계속 실행되는 동안 스트림의 이벤트를 처리할 수 있습니다. - `result` Promise는 모든 단계가 완료된 후에만 이행됩니다. - 스트림 이벤트는 일반 Workflow 스트리밍과 동일한 형식을 따릅니다. - 시간 이동 스트리밍은 영구 Workflow 스냅샷에 의존하므로 스토리지를 구성해야 합니다. ## 관련된 - [실행.시간여행()](https://mastra.zisheng.pro/ko/reference/workflows/run-methods/timeTravel) - [시간여행](https://mastra.zisheng.pro/ko/docs/workflows/time-travel) - [Workflow 스트리밍](https://mastra.zisheng.pro/ko/docs/workflows/overview) - [실행.스트림()](https://mastra.zisheng.pro/ko/reference/streaming/workflows/stream) - [실행.이력스트림()](https://mastra.zisheng.pro/ko/reference/streaming/workflows/resumeStream)