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 for local agents).
28    #[arg(long)]
29    pub stdio: bool,
30
31    /// Use Streamable HTTP transport (for remote/multi-user deployments).
32    #[arg(long)]
33    pub http: bool,
34
35    /// Host to bind the HTTP server to.
36    #[arg(long, default_value = "0.0.0.0", env = "AGENTIS_PAY_HOST")]
37    pub host: String,
38
39    /// Port to bind the HTTP server to.
40    #[arg(long, default_value_t = 8080, env = "AGENTIS_PAY_PORT")]
41    pub port: u16,
42
43    /// Optional device identifier override.
44    #[arg(long)]
45    pub device_id: Option<String>,
46}
47
48#[derive(clap::Args, Debug, Clone)]
49#[command(group(ArgGroup::new("mcp-jwt-source").args(["jwt_file", "jwt_stdin"]).multiple(false)))]
50pub struct McpSetupArgs {
51    /// MCP client target.
52    #[arg(long, value_enum, default_value_t = McpClient::Claude)]
53    pub client: McpClient,
54
55    /// Optional path to a JWT file to embed in the generated MCP snippet.
56    /// Usually unnecessary for local agents because `mcp serve` reuses saved CLI credentials.
57    #[arg(long, value_name = "PATH")]
58    pub jwt_file: Option<PathBuf>,
59
60    /// Read a JWT from stdin and embed it in the generated MCP snippet.
61    #[arg(long)]
62    pub jwt_stdin: bool,
63
64    /// Optional device identifier override to embed in the generated MCP snippet.
65    #[arg(long)]
66    pub device_id: Option<String>,
67
68    /// Optional agent name override to embed in the generated MCP snippet.
69    #[arg(long)]
70    pub agent_name: Option<String>,
71
72    /// Only print the JSON config without writing to the config file.
73    #[arg(long)]
74    pub print_only: bool,
75}
76
77#[derive(Subcommand, Debug)]
78pub enum McpCommand {
79    /// Run the MCP server for local agent integrations.
80    Serve(McpServeArgs),
81
82    /// Install MCP server into Claude Desktop config.
83    #[command(alias = "setup")]
84    Install(McpSetupArgs),
85}
86
87#[derive(Parser, Debug)]
88#[command(name = "agentis-pay")]
89#[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."))]
90#[command(
91    subcommand_required = true,
92    infer_subcommands = true,
93    arg_required_else_help = true
94)]
95pub struct Cli {
96    /// Output format for command responses.
97    #[arg(
98        short = 'f',
99        long,
100        global = true,
101        env = "AGENTIS_PAY_OUTPUT",
102        default_value_t = OutputFormat::Text,
103        value_enum
104    )]
105    pub output: OutputFormat,
106
107    /// Optional command line verbosity.
108    #[arg(short, long, global = true)]
109    pub verbose: bool,
110
111    /// Silence all success/info output.
112    #[arg(short = 'q', long, global = true)]
113    pub quiet: bool,
114
115    #[command(subcommand)]
116    pub command: Command,
117}
118
119#[derive(Subcommand, Debug)]
120pub enum PixCommand {
121    /// Send a PIX payment to a Pix key.
122    #[command(alias = "pagar")]
123    Pay(commands::PixSendArgs),
124
125    /// List Pix keys.
126    #[command(alias = "chaves")]
127    Keys,
128
129    /// Decode a Pix BR Code / Copia e Cola payload.
130    #[command(aliases = ["copia&cola", "copiacola"])]
131    Brcode(commands::BrcodeArgs),
132
133    /// View compact and detailed transaction history.
134    #[command(alias = "extrato")]
135    History(commands::HistoryArgs),
136
137    /// Show configured Pix limits.
138    Limits,
139
140    /// Show current BRL balance.
141    #[command(alias = "saldo")]
142    Balance,
143
144    /// Show Pix keys for deposits.
145    #[command(alias = "depositar")]
146    Deposit,
147
148    /// Show account details.
149    #[command(alias = "conta")]
150    Account,
151}
152
153#[derive(Subcommand, Debug)]
154pub enum Command {
155    /// Start the account signup flow. [unimplemented]
156    Signup(commands::SignupArgs),
157
158    /// Authenticate with Agentis Pay (OAuth by default, --pin for legacy).
159    Login(commands::LoginArgs),
160
161    /// Complete PIN-based login by submitting the PIN received via email or phone.
162    Verify(commands::VerifyArgs),
163
164    /// Clear stored credentials.
165    Logout,
166
167    /// Show current credential status.
168    Whoami,
169
170    /// Pix operations (pay, keys, account, balance, deposit, brcode, history, limits).
171    #[command(subcommand)]
172    Pix(PixCommand),
173
174    /// MCP commands for local/remote agent integrations.
175    #[command(subcommand)]
176    Mcp(McpCommand),
177
178    /// Legacy alias for `mcp serve`.
179    #[command(name = "mcp-serve", hide = true)]
180    McpServeLegacy(McpServeArgs),
181
182    /// Legacy alias for `mcp install`.
183    #[command(name = "setup-mcp", hide = true)]
184    SetupMcpLegacy(McpSetupArgs),
185}