跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

Run.observeStream()

The .observeStream() method opens a new ReadableStream to a workflow run that's currently running, allowing you to observe the stream of events if the original stream is no longer available.

Usage example
Usage example的直接链接

const run = await workflow.createRun()

run.stream({
inputData: {
value: 'initial data',
},
})

const stream = await run.observeStream()

for await (const chunk of stream) {
console.log(chunk)
}

Returns
Returns的直接链接

ReadableStream<ChunkType>

Stream events
Stream events的直接链接

The stream emits event types during workflow execution. Each event has a type field and a payload containing relevant data:

  • workflow-start: Workflow execution begins
  • workflow-step-start: A step begins execution
  • workflow-step-output: Custom output from a step
  • workflow-step-result: A step completes with results
  • workflow-finish: Workflow execution completes with usage statistics. For successful runs, payload.finalWorkflowResult carries the workflow's final result
On this page