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