Skip to main content

agentis_pay/
lib.rs

1//! agentis-pay CLI public entry points.
2
3pub mod commands;
4pub mod display;
5pub mod mcp;
6mod pix_key;
7pub mod session;
8
9use std::path::PathBuf;
10
11use clap::{ArgGroup, Parser, Subcommand};
12
13pub use commands::{HistoryArgs, LoginArgs, PixSendArgs, SignupArgs, VerifyArgs};
14pub use display::{
15    CommandName, OutputFormat, StatusColor, cents_to_brl, current_agent_name, emit_data, emit_line,
16    emit_message, emit_status, set_agent_name,
17};
18
19#[derive(clap::ValueEnum, Clone, Debug, Default)]
20pub enum McpClient {
21    #[default]
22    Claude,
23}
24
25#[derive(clap::Args, Debug, Clone)]
26pub struct McpServeArgs {
27    /// Use stdio transport (default; retained for compatibility with existing MCP configs).
28    #[arg(long)]
29    pub stdio: bool,
30
31    /// Optional device identifier override.
32    #[arg(long)]
33    pub device_id: Option<String>,
34}
35
36#[derive(clap::Args, Debug, Clone)]
37#[command(group(ArgGroup::new("mcp-jwt-source").args(["jwt_file", "jwt_stdin"]).multiple(false)))]
38pub struct McpSetupArgs {
39    /// MCP client target.
40    #[arg(long, value_enum, default_value_t = McpClient::Claude)]
41    pub client: McpClient,
42
43    /// Optional path to a JWT file to embed in the generated MCP snippet.
44    /// Usually unnecessary for local agents because `mcp serve` reuses saved CLI credentials.
45    #[arg(long, value_name = "PATH")]
46    pub jwt_file: Option<PathBuf>,
47
48    /// Read a JWT from stdin and embed it in the generated MCP snippet.
49    #[arg(long)]
50    pub jwt_stdin: bool,
51
52    /// Optional device identifier override to embed in the generated MCP snippet.
53    #[arg(long)]
54    pub device_id: Option<String>,
55
56    /// Optional agent name override to embed in the generated MCP snippet.
57    #[arg(long)]
58    pub agent_name: Option<String>,
59
60    /// Only print the JSON config without writing to the config file.
61    #[arg(long)]
62    pub print_only: bool,
63}
64
65#[derive(Subcommand, Debug)]
66pub enum McpCommand {
67    /// Run the MCP server for local agent integrations.
68    Serve(McpServeArgs),
69
70    /// Install MCP server into Claude Desktop config.
71    #[command(alias = "setup")]
72    Install(McpSetupArgs),
73}
74
75#[derive(Parser, Debug)]
76#[command(name = "agentis-pay")]
77#[command(author, version, about = "CLI client for Bipa's agentis-pay service", long_about = Some("Interact with pix accounts via Bipa gRPC with MCP support for agent workflows."))]
78#[command(
79    subcommand_required = true,
80    infer_subcommands = true,
81    arg_required_else_help = true
82)]
83pub struct Cli {
84    /// Output format for command responses.
85    #[arg(
86        short = 'f',
87        long,
88        global = true,
89        env = "AGENTIS_PAY_OUTPUT",
90        default_value_t = OutputFormat::Text,
91        value_enum
92    )]
93    pub output: OutputFormat,
94
95    /// Optional command line verbosity.
96    #[arg(short, long, global = true)]
97    pub verbose: bool,
98
99    /// Silence all success/info output.
100    #[arg(short = 'q', long, global = true)]
101    pub quiet: bool,
102
103    #[command(subcommand)]
104    pub command: Command,
105}
106
107#[derive(Subcommand, Debug)]
108pub enum PixCommand {
109    /// Send a PIX payment to a Pix key.
110    #[command(alias = "pagar")]
111    Pay(commands::PixSendArgs),
112
113    /// List Pix keys.
114    #[command(alias = "chaves")]
115    Keys,
116
117    /// Decode a Pix BR Code / Copia e Cola payload.
118    #[command(aliases = ["copia&cola", "copiacola"])]
119    Brcode(commands::BrcodeArgs),
120
121    /// View compact and detailed transaction history.
122    #[command(alias = "extrato")]
123    History(commands::HistoryArgs),
124
125    /// Show configured Pix limits.
126    Limits,
127
128    /// Show current BRL balance.
129    #[command(alias = "saldo")]
130    Balance,
131
132    /// Show Pix keys for deposits.
133    #[command(alias = "depositar")]
134    Deposit,
135
136    /// Show account details.
137    #[command(alias = "conta")]
138    Account,
139}
140
141#[derive(Subcommand, Debug)]
142pub enum Command {
143    /// Start the account signup flow. [unimplemented]
144    Signup(commands::SignupArgs),
145
146    /// Authenticate with Agentis Pay (OAuth by default, --pin for legacy).
147    Login(commands::LoginArgs),
148
149    /// Complete PIN-based login by submitting the PIN received via email or phone.
150    Verify(commands::VerifyArgs),
151
152    /// Clear stored credentials.
153    Logout,
154
155    /// Show current credential status.
156    Whoami,
157
158    /// Pix operations (pay, keys, account, balance, deposit, brcode, history, limits).
159    #[command(subcommand)]
160    Pix(PixCommand),
161
162    /// MCP commands for local/remote agent integrations.
163    #[command(subcommand)]
164    Mcp(McpCommand),
165
166    /// Legacy alias for `mcp serve`.
167    #[command(name = "mcp-serve", hide = true)]
168    McpServeLegacy(McpServeArgs),
169
170    /// Legacy alias for `mcp install`.
171    #[command(name = "setup-mcp", hide = true)]
172    SetupMcpLegacy(McpSetupArgs),
173}