Output SDK(出力用ツール群)ワークフローを同期的に実行し、結果を待機します。 次のような場合に使用: - ワークフローを実行して即座に結果が必要な場合 - ワークフロー実行をテストする場合 - 出力結果をターミナル(コマンド画面)で直接確認したい場合
Execute an Output SDK workflow synchronously and wait for the result. Use when running a workflow and needing immediate results, testing workflow execution, or getting the output directly in the terminal.
このスキルはワークフローを同期的に実行します。つまり、コマンドはワークフローが完了するまで待機し、結果を直接返します。 テスト、簡易実行、即時フィードバックが必要な場合に最適です。
次のような場合に使用:
次のような場合には npx output workflow start(非同期)の使用を検討してください:
npx output workflow run <workflowName> --input '<json-input>'
npx output workflow run <workflowName> --input <path-to-json-file>
ワークフローが入力データを必要とする場合、--input フラグは必須です。
コマンドラインに直接 JSON を渡します:
npx output workflow run example --input '{"question": "who really is ada lovelace?"}'
入力データを含む JSON ファイルを参照します:
npx output workflow run simple --input src/simple/scenarios/question_ada_lovelace.json
この方法を推奨する理由:
ワークフローには通常、テスト用入力データを格納する scenarios/ フォルダが用意されています:
src/
my_workflow/
workflow.ts
steps.ts
scenarios/
basic_test.json
edge_case_empty.json
large_payload.json
推奨される手順:
シナリオファイルに入力データを作成します:
# scenarios フォルダが存在しない場合は作成
mkdir -p src/my_workflow/scenarios
シナリオファイルに入力内容を記述します:
// src/my_workflow/scenarios/test_user.json
{
"userId": "123",
"options": {
"verbose": true
}
}
シナリオを指定してワークフローを実行します:
npx output workflow run my_workflow --input src/my_workflow/scenarios/test_user.json
# インライン JSON - シンプルなオブジェクト
npx output workflow run my-workflow --input '{"userId": "123"}'
# インライン JSON - 複雑なネストされた入力
npx output workflow run data-pipeline --input '{"source": "api", "options": {"limit": 100}}'
# ファイルパス - シナリオファイルを参照
npx output workflow run simple --input src/simple/scenarios/basic.json
# ファイルパス - カレントディレクトリからの相対パス
npx output workflow run batch-processor --input ./test_inputs/batch1.json
# 入力なし(ワークフローが入力を必要としない場合のみ)
npx output workflow run health-check
コマンドはワークフローの結果を標準出力(stdout)に直接返します。
ワークフローの戻り値が表示されます(通常は JSON 形式)。
ワークフローが失敗した場合、以下の情報が表示されます:
npx output workflow debug で詳細を確認するよう促すメッセージシナリオ: シナリオファイルを使ってワークフローをテストする
# まず既存のシナリオを確認
ls src/simple/scenarios/
# シナリオファイルを使って実行
npx output workflow run simple --input src/simple/scenarios/basic_sum.json
# 出力例:
# { "sum": 6, "count": 3 }
シナリオ: 新しいテストシナリオを作成して実行する
# シナリオファイルを作成
cat > src/my_workflow/scenarios/test_case_1.json << 'EOF'
{
"question": "What is the capital of France?",
"context": "geography"
}
EOF
# ワークフローを実行
npx output workflow run my_workflow --input src/my_workflow/scenarios/test_case_1.json
シナリオ: 開発中に手軽にインラインでテストする
npx output workflow run example --input '{"question": "explain quantum computing"}'
シナリオ: デバッグのため異なる入力でワークフローを再実行する
# まずシナリオファイルで実行
npx output workflow run process-data --input src/process_data/scenarios/user_abc.json
# エラーが発生
# 問題を切り分けるための最小シナリオを作成
cat > src/process_data/scenarios/debug_minimal.json << 'EOF'
{"id": "test", "debug": true}
EOF
npx output workflow run process-data --input src/process_data/scenarios/debug_minimal.json
シナリオ: 出力結果をキャプチャしてさらに処理する
# 結果をファイルに保存
npx output workflow run generate-report --input src/generate_report/scenarios/jan_2024.json > report.json
# jq にパイプして処理
npx output workflow run get-users --input src/get_users/scenarios/active.json | jq '.users[].name'
| エラー | 原因 | 対処法 |
|---|---|---|
| "Workflow not found" | ワークフロー名が正しくない | npx output workflow list で確認する |
| "Invalid input" | JSON がスキーマと一致していない | ワークフローの inputSchema に合わせて入力を確認する |
| "Parse error" | JSON の形式が不正、またはファイルが見つからない | JSON 構文またはファイルパスを確認する |
| "Timeout" | ワークフローの実行時間が長すぎる | 長時間実行には非同期実行を使用する |
ワークフローが失敗すると、出力にワークフロー ID が含まれます。その ID を使って完全なトレースを取得できます:
npx output workflow run my-workflow --input src/my_workflow/scenarios/test.json
# 出力例: Workflow failed. ID: abc123xyz
npx output workflow debug abc123xyz --json
inputSchema を参照するscenarios/ フォルダに再利用可能なテスト入力を作成するtrue/false を使用するnpx output workflow start <name> --input - 非同期で開始するnpx output workflow list - 利用可能なワークフローを確認するnpx output workflow debug <id> - 失敗した実行をデバッグするThis skill executes a workflow synchronously, meaning the command waits for the workflow to complete and returns the result directly. This is ideal for testing, quick executions, and when you need immediate feedback.
Consider using npx output workflow start (async) when:
npx output workflow run <workflowName> --input '<json-input>'
npx output workflow run <workflowName> --input <path-to-json-file>
The --input flag is required when the workflow expects input data.
Pass JSON directly on the command line:
npx output workflow run example --input '{"question": "who really is ada lovelace?"}'
Reference a JSON file containing the input:
npx output workflow run simple --input src/simple/scenarios/question_ada_lovelace.json
This is the recommended approach because:
Workflows typically have a scenarios/ folder containing test inputs:
src/
my_workflow/
workflow.ts
steps.ts
scenarios/
basic_test.json
edge_case_empty.json
large_payload.json
Best practice workflow:
Create a scenario file with your input:
# Create scenarios folder if it doesn't exist
mkdir -p src/my_workflow/scenarios
Write your input to a scenario file:
// src/my_workflow/scenarios/test_user.json
{
"userId": "123",
"options": {
"verbose": true
}
}
Run the workflow referencing the scenario:
npx output workflow run my_workflow --input src/my_workflow/scenarios/test_user.json
# Inline JSON - simple object
npx output workflow run my-workflow --input '{"userId": "123"}'
# Inline JSON - complex nested input
npx output workflow run data-pipeline --input '{"source": "api", "options": {"limit": 100}}'
# File path - reference a scenario file
npx output workflow run simple --input src/simple/scenarios/basic.json
# File path - relative to current directory
npx output workflow run batch-processor --input ./test_inputs/batch1.json
# No input (only if workflow doesn't require it)
npx output workflow run health-check
The command returns the workflow result directly to stdout.
The workflow's return value is displayed, typically as JSON.
If the workflow fails, you'll see:
npx output workflow debug for detailsScenario: Test a workflow with a scenario file
# First, look for existing scenarios
ls src/simple/scenarios/
# Run using a scenario file
npx output workflow run simple --input src/simple/scenarios/basic_sum.json
# Output:
# { "sum": 6, "count": 3 }
Scenario: Create and run a new test scenario
# Create a scenario file
cat > src/my_workflow/scenarios/test_case_1.json << 'EOF'
{
"question": "What is the capital of France?",
"context": "geography"
}
EOF
# Run the workflow
npx output workflow run my_workflow --input src/my_workflow/scenarios/test_case_1.json
Scenario: Quick inline test during development
npx output workflow run example --input '{"question": "explain quantum computing"}'
Scenario: Re-run a workflow with different input for debugging
# First attempt with scenario file
npx output workflow run process-data --input src/process_data/scenarios/user_abc.json
# Error occurs
# Create a new scenario to isolate the issue
cat > src/process_data/scenarios/debug_minimal.json << 'EOF'
{"id": "test", "debug": true}
EOF
npx output workflow run process-data --input src/process_data/scenarios/debug_minimal.json
Scenario: Capture output for further processing
# Save result to a file
npx output workflow run generate-report --input src/generate_report/scenarios/jan_2024.json > report.json
# Pipe to jq for processing
npx output workflow run get-users --input src/get_users/scenarios/active.json | jq '.users[].name'
| Error | Cause | Solution |
|---|---|---|
| "Workflow not found" | Workflow name is incorrect | Check with npx output workflow list |
| "Invalid input" | JSON doesn't match schema | Verify input matches workflow's inputSchema |
| "Parse error" | Malformed JSON or file not found | Check JSON syntax or file path |
| "Timeout" | Workflow took too long | Use async execution for long workflows |
When a workflow fails, the output includes the workflow ID. Use it to get the full trace:
npx output workflow run my-workflow --input src/my_workflow/scenarios/test.json
# Output: Workflow failed. ID: abc123xyz
npx output workflow debug abc123xyz --json
inputSchema in the codescenarios/ foldernpx output workflow start <name> --input - Start asynchronouslynpx output workflow list - See available workflowsnpx output workflow debug <id> - Debug a failed run原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。