Skip to main content

agent_first_http/cli/
output.rs

1//! Output glue. The single seam through which CLI subcommands write their
2//! one line of JSON to stdout.
3
4use crate::shared::error::Error;
5use serde::Serialize;
6
7/// Emit a payload to stdout as one line of JSON. Wraps
8/// `shared::afdata::emit` and is the single seam through which CLI
9/// subcommands produce output.
10pub fn emit<T: Serialize>(code: &str, payload: &T) -> Result<(), Error> {
11    crate::shared::afdata::emit_process(code, payload)
12}
13
14/// Emit a payload to stdout without AFDATA redaction. This is only for
15/// explicit reveal flags; normal command output must use [`emit`].
16pub fn emit_unredacted<T: Serialize>(code: &str, payload: &T) -> Result<(), Error> {
17    crate::shared::afdata::emit_process_unredacted(code, payload)
18}
19
20/// Emit an otherwise-redacted result while revealing only the short-lived
21/// takeover capability requested by an explicit panel/takeover operation.
22pub fn emit_revealing_takeover<T: Serialize>(code: &str, payload: &T) -> Result<(), Error> {
23    crate::shared::afdata::emit_process_revealing_takeover(code, payload)
24}
25
26/// Emit one non-terminal progress event. Only commands that block on a person
27/// have anything to report before their result.
28pub fn emit_progress<T: Serialize>(code: &str, payload: &T) -> Result<(), Error> {
29    crate::shared::afdata::emit_process_progress(code, payload)
30}