mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 23:14:13 +08:00
feat: add structured output support
Add support for Agent SDK structured outputs feature. New input: json_schema - accepts JSON schema for validated outputs Auto-sets GitHub Action outputs for each field in the structured result 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:
@@ -149,6 +149,19 @@ export const agentMode: Mode = {
|
||||
claudeArgs = `--mcp-config '${escapedOurConfig}'`;
|
||||
}
|
||||
|
||||
// Add JSON schema if provided
|
||||
const jsonSchema = process.env.JSON_SCHEMA || "";
|
||||
if (jsonSchema) {
|
||||
// Validate it's valid JSON
|
||||
try {
|
||||
JSON.parse(jsonSchema);
|
||||
} catch (e) {
|
||||
throw new Error(`Invalid JSON schema provided: ${e}`);
|
||||
}
|
||||
const escapedSchema = jsonSchema.replace(/'/g, "'\\''");
|
||||
claudeArgs += ` --json-schema '${escapedSchema}'`;
|
||||
}
|
||||
|
||||
// Append user's claude_args (which may have more --mcp-config flags)
|
||||
claudeArgs = `${claudeArgs} ${userClaudeArgs}`.trim();
|
||||
|
||||
|
||||
@@ -177,6 +177,19 @@ export const tagMode: Mode = {
|
||||
// Add required tools for tag mode
|
||||
claudeArgs += ` --allowedTools "${tagModeTools.join(",")}"`;
|
||||
|
||||
// Add JSON schema if provided
|
||||
const jsonSchema = process.env.JSON_SCHEMA || "";
|
||||
if (jsonSchema) {
|
||||
// Validate it's valid JSON
|
||||
try {
|
||||
JSON.parse(jsonSchema);
|
||||
} catch (e) {
|
||||
throw new Error(`Invalid JSON schema provided: ${e}`);
|
||||
}
|
||||
const escapedSchema = jsonSchema.replace(/'/g, "'\\''");
|
||||
claudeArgs += ` --json-schema '${escapedSchema}'`;
|
||||
}
|
||||
|
||||
// Append user's claude_args (which may have more --mcp-config flags)
|
||||
if (userClaudeArgs) {
|
||||
claudeArgs += ` ${userClaudeArgs}`;
|
||||
|
||||
Reference in New Issue
Block a user