完了したワークフロー(一連の自動処理)の実行結果を取得します。 次のような場合に使用: - 完了したワークフローの出力内容を確認したい - ワークフローの戻り値を取得したい - 非同期処理(バックグラウンドで実行)後にワークフローが生成した内容を確認したい
Get the result of an Output SDK workflow execution. Use when retrieving the output of a completed workflow, getting the return value, or checking what a workflow produced after async execution.
このスキルは、完了したワークフロー実行の結果(戻り値)を取得します。npx output workflow start で開始したワークフローが完了した後、または過去の実行結果を取得する場合に使用してください。
npx output workflow debug を使用してくださいnpx output workflow result <workflowId>
結果はワークフロー関数の戻り値であり、通常はJSON形式です。
結果を取得する前に、ワークフローが完了していることを確認してください:
npx output workflow status <workflowId>
# 出力: COMPLETED
npx output workflow result <workflowId>
ワークフローが成功すると、fn 関数の戻り値が返されます:
// ワークフローコード
export default workflow( {
fn: async input => {
return { processed: true, count: 42 };
}
} );
# 結果の出力
npx output workflow result abc123
# { "processed": true, "count": 42 }
失敗したワークフローの結果を取得しようとした場合:
npx output workflow debug を使用してください値を返さないワークフローもあります:
npx output workflow result abc123
# null
例1: 非同期開始後に結果を取得する
# ワークフローを開始
npx output workflow start calculate --input '{"values": [1, 2, 3]}'
# 出力: Workflow ID: calc-abc123
# 完了を待つ
npx output workflow status calc-abc123
# Status: COMPLETED
# 結果を取得
npx output workflow result calc-abc123
# { "sum": 6, "average": 2 }
例2: jq(JSONデータ抽出ツール)で結果を処理する
# 特定のフィールドを抽出
npx output workflow result abc123 | jq '.total'
# 見やすくフォーマット
npx output workflow result abc123 | jq '.'
# ファイルに保存
npx output workflow result abc123 > result.json
例3: 複数の実行結果を比較する
# 2つの実行結果を取得
npx output workflow result run-1-abc > result1.json
npx output workflow result run-2-xyz > result2.json
# 比較
diff result1.json result2.json
例4: スクリプト内で使用する
WORKFLOW_ID="abc123"
# 完了を待つ
while [[ $(npx output workflow status $WORKFLOW_ID) == *"RUNNING"* ]]; do
sleep 5
done
# 正常に完了したかを確認
if [[ $(npx output workflow status $WORKFLOW_ID) == *"COMPLETED"* ]]; then
RESULT=$(npx output workflow result $WORKFLOW_ID)
echo "ワークフロー結果: $RESULT"
else
echo "ワークフローが正常に完了しませんでした"
npx output workflow debug $WORKFLOW_ID
fi
npx output workflow result abc123
# { "key": "value", "nested": { "data": true } }
npx output workflow result abc123
# [1, 2, 3, 4, 5]
npx output workflow result abc123
# 42
npx output workflow result abc123
# "success"
npx output workflow result abc123
# true
大きな結果の場合は、ファイルにリダイレクトしてください:
npx output workflow result abc123 > large-result.json
npx output workflow runs list で有効なIDを探してくださいnpx output workflow status <id>npx output workflow debug を使用してくださいnpx output workflow status <id> - ワークフローが完了したか確認npx output workflow debug <id> - 失敗したワークフローをデバッグnpx output workflow run <name> - ワークフローを実行して結果を一度に取得npx output workflow runs list - ワークフローIDを検索This skill retrieves the result (return value) of a completed workflow execution. Use it after a workflow started with npx output workflow start has completed, or to retrieve results from historical runs.
npx output workflow debug insteadnpx output workflow result <workflowId>
The result is the return value of the workflow function, typically JSON.
Before getting results, verify the workflow completed:
npx output workflow status <workflowId>
# Should show: COMPLETED
npx output workflow result <workflowId>
A successful workflow returns the value from its fn function:
// Workflow code
export default workflow( {
fn: async input => {
return { processed: true, count: 42 };
}
} );
# Result output
npx output workflow result abc123
# { "processed": true, "count": 42 }
If you try to get the result of a failed workflow:
npx output workflow debug instead to see what went wrongSome workflows don't return a value:
npx output workflow result abc123
# null
Scenario: Get result after async start
# Start workflow
npx output workflow start calculate --input '{"values": [1, 2, 3]}'
# Output: Workflow ID: calc-abc123
# Wait for completion
npx output workflow status calc-abc123
# Status: COMPLETED
# Get the result
npx output workflow result calc-abc123
# { "sum": 6, "average": 2 }
Scenario: Process result with jq
# Extract specific field
npx output workflow result abc123 | jq '.total'
# Format for display
npx output workflow result abc123 | jq '.'
# Save to file
npx output workflow result abc123 > result.json
Scenario: Compare results between runs
# Get results from two runs
npx output workflow result run-1-abc > result1.json
npx output workflow result run-2-xyz > result2.json
# Compare
diff result1.json result2.json
Scenario: Use in a script
WORKFLOW_ID="abc123"
# Wait for completion
while [[ $(npx output workflow status $WORKFLOW_ID) == *"RUNNING"* ]]; do
sleep 5
done
# Check if completed successfully
if [[ $(npx output workflow status $WORKFLOW_ID) == *"COMPLETED"* ]]; then
RESULT=$(npx output workflow result $WORKFLOW_ID)
echo "Workflow result: $RESULT"
else
echo "Workflow did not complete successfully"
npx output workflow debug $WORKFLOW_ID
fi
npx output workflow result abc123
# { "key": "value", "nested": { "data": true } }
npx output workflow result abc123
# [1, 2, 3, 4, 5]
npx output workflow result abc123
# 42
npx output workflow result abc123
# "success"
npx output workflow result abc123
# true
For large results, redirect to a file:
npx output workflow result abc123 > large-result.json
npx output workflow runs list to find valid IDsnpx output workflow status <id>npx output workflow debugnpx output workflow status <id> - Check if workflow completednpx output workflow debug <id> - Debug failed workflowsnpx output workflow run <name> - Run and get result in one stepnpx output workflow runs list - Find workflow IDs原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。