feat: add structured output support via action result schema#129
Open
feat: add structured output support via action result schema#129
Conversation
3064e66 to
978a00b
Compare
11a4ea3 to
3fbec5d
Compare
Author
|
and some love for the ci as benefits :) |
a0b0d46 to
5ad6d76
Compare
- Disable fail-fast in test matrix so one failing OS doesn't cancel others - Retry Docker ContainerCreate on transient gRPC errors (Windows Desktop) - Pin Windows runner to windows-2022 (windows-latest broke WSL interop) - Mark Windows tests as continue-on-error until WSL fixed upstream
f830504 to
ed7c6dc
Compare
Add structured output support (JSON/YAML) via action result schemas. Actions define a result schema in their YAML and return data via Result(). When --output json or --output yaml is used (-o for short), terminal output is silenced and only the encoded result goes to stdout. - Actions define result schema in action.yaml and implement Result() any - NewFnRuntimeWithResult for actions returning structured data - Terminal silenced in structured mode (text output via term in normal mode) - Single --output/-o flag replaces previous --json/--yaml boolean flags - Builder --output renamed to --out-file to avoid global flag collision - Error on unknown format values Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
ed7c6dc to
56faf20
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #128 - Structured Output via Action Metadata Schema
This PR adds support for declarative result schemas in action metadata, enabling structured JSON/YAML output and automatic text formatting.
Changes
DefResulttype andResultfield toDefActionfor parsing result schemas from YAMLRuntimeResultProviderinterface andWithResultcomposition for runtimes that return structured dataNewFnRuntimeWithResultfor function-based runtimes returning resultsRunInfoto captureResultfromRuntimeResultProvider--jsonand--yamlglobal flags viajsonoutputplugin for structured outputoutputJSON/outputYAML/outputTexthandlers inactionscobrapluginNewCapturingStreamshelper for stdout capturecodefield (e.g.,EXIT_1) when availableUsage
Actions define a result schema in their YAML:
Go-based actions
Use
NewFnRuntimeWithResultto return structured data:Shell-based actions
Simply echo valid JSON to stdout:
Container-based actions
Same as shell - echo valid JSON to stdout from within the container:
Output Formats
Output is handled automatically by launchr:
--json: structured JSON wrapped in{"result": ...}or{"error": ...}--yaml: structured YAML withresult:orerror:keysError Handling
On error with
--json:{ "error": { "message": "action failed with exit code 1", "code": "EXIT_1" } }Exit code is preserved for proper shell scripting.
Example
Backward Compatibility
Actions without result schemas continue to work as before.
Coverage of Issue #128
resultfield from action.yaml--jsonglobal flag--yamlglobal flagCloses #128