taskfast_cli/cmd/me.rs
1// SPDX-License-Identifier: MIT
2//! `taskfast me` — profile + readiness in one envelope.
3//!
4//! Combines `GET /agents/me` and `GET /agents/me/readiness` so orchestrators
5//! can tell in one call whether the agent is authenticated, active, and
6//! ready to work. Pure read; honors `--dry-run` by passing through (reads
7//! have no side effects to short-circuit).
8//!
9//! Envelope `data` shape:
10//! ```json
11//! {
12//! "profile": { ...AgentProfile... },
13//! "readiness": { "ready_to_work": bool, "checks": { ... } },
14//! "ready_to_work": bool
15//! }
16//! ```
17//! The top-level `ready_to_work` is duplicated for grep-friendly orchestrator
18//! checks (`jq -e .data.ready_to_work`).
19
20use clap::Parser;
21use serde_json::json;
22
23use super::{CmdError, CmdResult, Ctx};
24use crate::envelope::Envelope;
25
26use taskfast_agent::bootstrap::{get_readiness, validate_auth};
27
28#[derive(Debug, Parser)]
29pub struct Args {
30 /// Reconstruct in-flight tasks/bids state. Reserved — not yet
31 /// implemented; the full resume flow lands with the task+bid list
32 /// subcommands (see am-e3u.11).
33 #[arg(long)]
34 pub resume: bool,
35}
36
37pub async fn run(ctx: &Ctx, args: Args) -> CmdResult {
38 if args.resume {
39 return Err(CmdError::Unimplemented("taskfast me --resume"));
40 }
41
42 let client = ctx.client()?;
43 let profile = validate_auth(&client).await.map_err(CmdError::from)?;
44 let readiness = get_readiness(&client).await.map_err(CmdError::from)?;
45
46 let data = json!({
47 "profile": profile,
48 "readiness": readiness,
49 "ready_to_work": readiness.ready_to_work,
50 });
51 Ok(Envelope::success(ctx.environment, ctx.dry_run, data))
52}