Part of the Improve Agent UX for Wallets epic.
Summary
Harden the machine-facing CLI API so an agent can parse any command's result and chain commands together without scraping human-formatted text. Three facets, tracked as one task: a global structured-output flag, a structured error catalog, and a --describe machine-readable schema.
1. Structured output
New global flag:
- default — today's default (plain text for most commands, a few existing JSON exceptions).
- json — an object with predictable keys representing the same data plus enriched output in some cases (e.g. errors paired with a resolution).
Example (ok):
{ "status": "ok", "result": "9999999500", "error": null }
Example (error):
{
"status": "error",
"result": null,
"error": {
"code": "tx_simulation_failed",
"domain": "tx",
"message": "host invocation failed: Error(Contract, #2)",
"details": {
"contract_id": "C...",
"error_code": 2,
"error_name": "InsufficientBalance",
"diagnostic_events": ["..."]
}
}
}
2. Structured errors
commands return an object with a consistent set of keys.
errors add context along with raw error details to aid users/agents towards remediation of the error.
3. --describe
A projection of the command spec: a machine-readable schema for a command or the tree (args, output schema, errors[], examples). Backed by a command-spec source file feeding the parser / --help / --describe generator.
Build on existing OutputFormat patterns (events.rs, fee_stats.rs, ledger/fetch.rs) and print.rs.
Acceptance criteria
Part of the Improve Agent UX for Wallets epic.
Summary
Harden the machine-facing CLI API so an agent can parse any command's result and chain commands together without scraping human-formatted text. Three facets, tracked as one task: a global structured-output flag, a structured error catalog, and a
--describemachine-readable schema.1. Structured output
New global flag:
Example (ok):
{ "status": "ok", "result": "9999999500", "error": null }Example (error):
{ "status": "error", "result": null, "error": { "code": "tx_simulation_failed", "domain": "tx", "message": "host invocation failed: Error(Contract, #2)", "details": { "contract_id": "C...", "error_code": 2, "error_name": "InsufficientBalance", "diagnostic_events": ["..."] } } }2. Structured errors
commands return an object with a consistent set of keys.
errors add context along with raw error details to aid users/agents towards remediation of the error.
3.
--describeA projection of the command spec: a machine-readable schema for a command or the tree (
args,outputschema,errors[],examples). Backed by a command-spec source file feeding the parser /--help/--describegenerator.Build on existing
OutputFormatpatterns (events.rs,fee_stats.rs,ledger/fetch.rs) andprint.rs.Acceptance criteria
--describeemitsargs/output/errors[]/examples.output=json.