Run.stream()
.stream()
メソッドを使用すると、ワークフローの実行を監視し、ステップのステータスに関するリアルタイムの更新を提供できます。
使用方法
const run = myWorkflow.createRun();
// Add a stream to monitor execution
const result = run.stream({ inputData: {...} });
for (const chunk of stream) {
// do something with the chunk
}
メッセージ
start:
object
ワークフローの開始
object
example:
{ type: 'start', payload: { runId: '1' } }
メッセージ構造の例
step-start:
object
ステップの開始
object
example:
{ type: 'step-start', payload: { id: 'fetch-weather' } }
メッセージ構造の例
tool-call:
object
ツールコールが開始されました
object
example:
{ type: 'tool-call', toolCallId: 'weatherAgent', toolName: 'Weather Agent', args: { prompt: 'Based on the following weather forecast for New York, suggest appropriate activities:...' } }
メッセージ構造の例
tool-call-streaming-start:
object
ツールコール/エージェントが開始されました
object
example:
{ type: 'tool-call-streaming-start', toolCallId: 'weatherAgent', toolName: 'Weather Agent', args: { prompt: 'Based on the following weather forecast for New York, suggest appropriate activities:...' } }
メッセージ構造の例
tool-call-delta:
object
ツール出力の差分
object
example:
{ type: 'tool-call-delta', toolCallId: 'weatherAgent', toolName: 'Weather Agent', args: { prompt: 'Based on the following weather forecast for New York, suggest appropriate activities:\n' + ' [\n' + ' {\n' + ' "date": "2025-05-16",\n' + ' "maxTemp": 22.2,\n' + ' "minTemp": 16,\n' + ' "precipitationChance": 5,\n' + ' "condition": "Dense drizzle",\n' + ' "location": "New York"\n' + ' },\n' + ' ' }, argsTextDelta: '📅' }
メッセージ構造の例
step-result:
object
ステップの結果
object
example:
{ type: 'step-result', payload: { id: 'Weather Agent', status: 'success', output: [Object] } }
メッセージ構造の例
step-finish:
object
ステップの終了
object
example:
{ type: 'step-finish', payload: { id: 'Weather Agent', metadata: {} } }
メッセージ構造の例
finish:
object
ワークフローの終了
object
example:
{ type: 'finish', payload: { runId: '1' } }
メッセージ構造の例
パラメーター
params:
object
ワークフロー実行を開始するための設定オブジェクト
z.infer<TInput>
z.infer<TInput>?:
inputData
ワークフローを開始する際に使用するランタイムコンテキストデータ
RuntimeContext
runtimeContext?:
RuntimeContext
ワークフローを開始する際に使用するランタイムコンテキストデータ
戻り値
result:
Promise<WorkflowResult<TOutput, TSteps>>
各ステップをストリームにパイプするストリーム