feat: add structured output support

Add support for Agent SDK structured outputs.

New input: json_schema - JSON schema for validated outputs
Auto-sets GitHub Action outputs for each field

Security:
- Reserved output protection (prevents shadowing)
- 1MB output size limits enforced
- Output key format validation
- Objects/arrays >1MB skipped (not truncated to invalid JSON)

Tests:
- 26 unit tests
- 5 integration tests
- 480 tests passing

Docs: https://docs.claude.com/en/docs/agent-sdk/structured-outputs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
inigo
2025-11-18 10:08:11 -08:00
parent 08f88abe2b
commit e600a516c7
12 changed files with 1076 additions and 4 deletions

View File

@@ -24,6 +24,10 @@ inputs:
description: "Additional arguments to pass directly to Claude CLI (e.g., '--max-turns 3 --mcp-config /path/to/config.json')"
required: false
default: ""
allowed_tools:
description: "Comma-separated list of allowed tools (e.g., 'Read,Write,Bash'). Passed as --allowedTools to Claude CLI"
required: false
default: ""
# Authentication settings
anthropic_api_key:
@@ -67,6 +71,20 @@ inputs:
description: "Newline-separated list of Claude Code plugin marketplace Git URLs to install from (e.g., 'https://github.com/user/marketplace1.git\nhttps://github.com/user/marketplace2.git')"
required: false
default: ""
json_schema:
description: |
JSON schema for structured output validation. Claude must return JSON matching this schema
or the action will fail. Outputs are automatically set for each field.
Access outputs via: steps.<step-id>.outputs.<field_name>
Limitations:
- Field names must start with letter or underscore (A-Z, a-z, _)
- Special characters in field names are replaced with underscores
- Each output is limited to 1MB (values will be truncated)
- Objects and arrays are JSON stringified
required: false
default: ""
outputs:
conclusion:
@@ -111,7 +129,7 @@ runs:
run: |
if [ -z "${{ inputs.path_to_claude_code_executable }}" ]; then
echo "Installing Claude Code..."
curl -fsSL https://claude.ai/install.sh | bash -s 2.0.42
curl -fsSL https://claude.ai/install.sh | bash -s 2.0.45
else
echo "Using custom Claude Code executable: ${{ inputs.path_to_claude_code_executable }}"
# Add the directory containing the custom executable to PATH
@@ -141,6 +159,8 @@ runs:
INPUT_SHOW_FULL_OUTPUT: ${{ inputs.show_full_output }}
INPUT_PLUGINS: ${{ inputs.plugins }}
INPUT_PLUGIN_MARKETPLACES: ${{ inputs.plugin_marketplaces }}
INPUT_ALLOWED_TOOLS: ${{ inputs.allowed_tools }}
JSON_SCHEMA: ${{ inputs.json_schema }}
# Provider configuration
ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}