@mixrpay/agent-sdk 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/{agent-wallet-QEL6J4X2.js → agent-wallet-YY6SGBZQ.js} +1 -1
- package/dist/{chunk-UED36HQN.js → chunk-4WCYTILC.js} +1 -1
- package/dist/cli.js +776 -42
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -1
- package/dist/mcp-server.js +3 -3
- package/dist/tool-cli.js +54 -0
- package/package.json +17 -2
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {b,a as a$1,e,d,c as c$1}from'./chunk-SWK4Q2A3.js';import {c,g,a}from'./chunk-
|
|
2
|
+
import {b,a as a$1,e,d as d$1,c as c$1}from'./chunk-SWK4Q2A3.js';import {c,g,a}from'./chunk-4WCYTILC.js';async function u(e){let r=e.baseUrl||e.url||c;try{return await g.connect({baseUrl:r})}catch(s){throw s instanceof a&&(console.error("Authentication required."),console.error("\nRun `mixrpay login` or set MIXRPAY_SESSION_KEY environment variable.")),s}}function d(e,r){console.log(JSON.stringify(e,null,2));}function x(e){return e.length<=16?e.slice(0,8)+"...":e.slice(0,12)+"..."+e.slice(-4)}function I(e,r){let s;try{s=JSON.parse(e);}catch{console.error(`Error: ${r}`),process.exit(1);}(typeof s!="object"||s===null||Array.isArray(s))&&(console.error(`Error: ${r} - expected a JSON object`),process.exit(1));let o=s;return ("__proto__"in o||"constructor"in o||"prototype"in o)&&(console.error("Error: Invalid JSON - contains forbidden keys"),process.exit(1)),o}function P(e,r){let s;try{s=JSON.parse(e);}catch{console.error(`Error: ${r}`),process.exit(1);}Array.isArray(s)||(console.error(`Error: ${r} - expected a JSON array`),process.exit(1));for(let o of s){(typeof o!="object"||o===null||Array.isArray(o))&&(console.error(`Error: ${r} - array elements must be objects`),process.exit(1));let t=o;("__proto__"in t||"constructor"in t||"prototype"in t)&&(console.error("Error: Invalid JSON - contains forbidden keys"),process.exit(1));}return s}function C(e){let r={command:"",flags:{},positionals:[]},s=0;for(;s<e.length;){let o=e[s];if(o.startsWith("--")){let[t,n]=o.slice(2).split("=");n!==void 0?r.flags[t]=n:s+1<e.length&&!e[s+1].startsWith("-")?r.flags[t]=e[++s]:r.flags[t]=true;}else if(o.startsWith("-")){let t=o.slice(1);s+1<e.length&&!e[s+1].startsWith("-")?r.flags[t]=e[++s]:r.flags[t]=true;}else r.command?r.positionals.push(o):r.command=o;s++;}return r}async function N(e$1){if(e$1.help||e$1.h){console.log(`
|
|
3
3
|
mixrpay login - Authenticate via browser
|
|
4
4
|
|
|
5
5
|
USAGE
|
|
@@ -16,15 +16,16 @@ DESCRIPTION
|
|
|
16
16
|
EXAMPLES
|
|
17
17
|
mixrpay login
|
|
18
18
|
mixrpay login --baseUrl https://staging.mixrpay.com
|
|
19
|
-
`);return}let
|
|
20
|
-
`);try{let
|
|
21
|
-
Credentials saved to: ${e()}`);}catch(
|
|
19
|
+
`);return}let r=e$1.baseUrl||e$1.url||c;console.log(`Starting MixrPay authentication...
|
|
20
|
+
`);try{let s=await g.deviceFlowLogin({baseUrl:r}),o=await s.getSessionKeyInfo();console.log("Logged in successfully!"),console.log(` Wallet: ${s.getWalletAddress()}`),console.log(` Network: ${s.getNetwork().name}`),o.expiresAt&&console.log(` Expires: ${o.expiresAt.toLocaleDateString()}`),console.log(`
|
|
21
|
+
Credentials saved to: ${e()}`);}catch(s){s instanceof a?console.error(`Login failed: ${s.message}`):console.error("Login failed:",s),process.exit(1);}}async function R(){if(!d$1()){console.log("No credentials found. Already logged out.");return}c$1()?(console.log("Logged out successfully."),console.log(`Credentials removed from: ${e()}`)):(console.error("Failed to remove credentials."),process.exit(1));}async function _(e$1){if(e$1.help||e$1.h){console.log(`
|
|
22
22
|
mixrpay whoami - Show current authentication status
|
|
23
23
|
|
|
24
24
|
USAGE
|
|
25
25
|
mixrpay whoami [options]
|
|
26
26
|
|
|
27
27
|
OPTIONS
|
|
28
|
+
--json Output as JSON
|
|
28
29
|
--help, -h Show this help message
|
|
29
30
|
|
|
30
31
|
DESCRIPTION
|
|
@@ -33,10 +34,11 @@ DESCRIPTION
|
|
|
33
34
|
|
|
34
35
|
EXAMPLES
|
|
35
36
|
mixrpay whoami
|
|
36
|
-
|
|
37
|
-
`),console.
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
mixrpay whoami --json
|
|
38
|
+
`);return}let r=e$1.json===true,s=b();s.success||(r?d({authenticated:false,error:s.error}):console.error("Error loading credentials:",s.error),process.exit(1));let{credentials:o}=s;if(!o.sessionKey&&!o.apiToken&&!o.masterKey){r?d({authenticated:false}):(console.log("Not logged in."),console.log("\nRun `mixrpay login` to authenticate."));return}let t={authenticated:true};if(o.sessionKey){let n=o.sessionKey.startsWith("sk_test_")?"testnet":"mainnet";t.sessionKey=x(o.sessionKey),t.keyType=n;try{let a=o.baseUrl||c,i=new g({sessionKey:o.sessionKey,baseUrl:a}),c$1=await i.getSessionKeyInfo();if(t.walletAddress=i.getWalletAddress(),t.network=i.getNetwork().name,c$1.expiresAt){t.expiresAt=c$1.expiresAt.toISOString();let l=new Date,g=(c$1.expiresAt.getTime()-l.getTime())/(1e3*60*60);t.expired=g<0,t.hoursRemaining=Math.max(0,g);}if(c$1.limits.totalUsd){let l=c$1.limits.totalUsd-(c$1.usage?.totalUsd||0);t.budget={totalUsd:c$1.limits.totalUsd,usedUsd:c$1.usage?.totalUsd||0,remainingUsd:l};}}catch{t.serverInfoError="Could not fetch additional info from server";}}if(o.apiToken&&(t.apiToken=x(o.apiToken)),o.masterKey&&(t.masterKey=x(o.masterKey),o.defaultAgentName&&(t.defaultAgentName=o.defaultAgentName)),o.baseUrl&&(t.baseUrl=o.baseUrl),o.updatedAt&&(t.updatedAt=o.updatedAt),r){d(t);return}if(console.log(`MixrPay Authentication Status
|
|
39
|
+
`),console.log(`Credentials file: ${e()}`),o.sessionKey){let n=o.sessionKey.startsWith("sk_test_")?"testnet":"mainnet";if(console.log(`Session key: ${o.sessionKey.slice(0,16)}...${o.sessionKey.slice(-8)} (${n})`),t.walletAddress){if(console.log(`
|
|
40
|
+
Wallet: ${t.walletAddress}`),console.log(`Network: ${t.network}`),t.expiresAt){let a=t.hoursRemaining,i=new Date(t.expiresAt);t.expired?console.log(`Status: EXPIRED (${i.toLocaleDateString()})`):a<24?console.log(`Status: Active (expires in ${a.toFixed(1)} hours)`):console.log(`Status: Active (expires ${i.toLocaleDateString()})`);}if(t.budget){let a=t.budget;console.log(`Budget: $${a.remainingUsd.toFixed(2)} remaining of $${a.totalUsd.toFixed(2)}`);}}else t.serverInfoError&&console.log(`
|
|
41
|
+
Note: Could not fetch additional info from server.`);}o.apiToken&&console.log(`API token: ${o.apiToken.slice(0,16)}...`),o.masterKey&&(console.log(`Master key: ${o.masterKey.slice(0,16)}...`),o.defaultAgentName&&console.log(`Default agent: ${o.defaultAgentName}`)),o.baseUrl&&console.log(`Base URL: ${o.baseUrl}`),o.updatedAt&&console.log(`Last updated: ${new Date(o.updatedAt).toLocaleString()}`);}async function j(e){if(e.help||e.h){console.log(`
|
|
40
42
|
mixrpay register - Register a new agent with MixrPay
|
|
41
43
|
|
|
42
44
|
USAGE
|
|
@@ -48,6 +50,7 @@ OPTIONS
|
|
|
48
50
|
--mode Registration mode: wallet, invite, or self (default: wallet)
|
|
49
51
|
--invite-code Invite code for 'invite' mode
|
|
50
52
|
--baseUrl, --url Override MixrPay API URL
|
|
53
|
+
--json Output as JSON
|
|
51
54
|
--help, -h Show this help message
|
|
52
55
|
|
|
53
56
|
EXAMPLES
|
|
@@ -60,25 +63,30 @@ EXAMPLES
|
|
|
60
63
|
# Self-registration (gets claim code for human to fund)
|
|
61
64
|
mixrpay register --mode self --name "My Agent"
|
|
62
65
|
|
|
66
|
+
# JSON output
|
|
67
|
+
mixrpay register --mode self --name "My Agent" --json
|
|
68
|
+
|
|
63
69
|
ENVIRONMENT VARIABLES
|
|
64
70
|
AGENT_WALLET_KEY Agent's wallet private key
|
|
65
|
-
`);return}let
|
|
71
|
+
`);return}let r=e.json===true,s=e.mode||"wallet",o=e.name||e.n,t=e.baseUrl||e.url||c,n=e["invite-code"]||e.inviteCode;if(["wallet","invite","self"].includes(s)||(console.error(`Error: Invalid mode '${s}'. Must be 'wallet', 'invite', or 'self'.`),process.exit(1)),s==="wallet"){let a$1=e.key||e.privateKey||process.env.AGENT_WALLET_KEY;a$1||(console.error("Error: Private key required for wallet mode."),console.error(`
|
|
66
72
|
Usage: mixrpay register --key 0x... [--name "Agent Name"]`),console.error(`
|
|
67
73
|
Alternatively, set the AGENT_WALLET_KEY environment variable.`),console.error(`
|
|
68
|
-
Or use --mode invite or --mode self for keyless registration.`),process.exit(1)),(!
|
|
69
|
-
`);try{let
|
|
70
|
-
`),console.log(` User ID: ${
|
|
71
|
-
Next steps:`),console.log(" 1. Fund the deposit address with USDC on Base"),console.log(" 2. Run `mixrpay login` to authenticate via browser");}catch(
|
|
74
|
+
Or use --mode invite or --mode self for keyless registration.`),process.exit(1)),(!a$1.startsWith("0x")||a$1.length!==66)&&(console.error("Error: Invalid private key format."),console.error("Expected: 0x followed by 64 hex characters."),process.exit(1)),r||console.log(`Registering agent with wallet...
|
|
75
|
+
`);try{let i=await g.register({privateKey:a$1,name:o,baseUrl:t});r?d({mode:"wallet",userId:i.userId,depositAddress:i.depositAddress},!0):(console.log(`Agent registered successfully!
|
|
76
|
+
`),console.log(` User ID: ${i.userId}`),console.log(` Deposit Address: ${i.depositAddress}`),console.log(`
|
|
77
|
+
Next steps:`),console.log(" 1. Fund the deposit address with USDC on Base"),console.log(" 2. Run `mixrpay login` to authenticate via browser"));}catch(i){i instanceof a?console.error(`Registration failed: ${i.message}`):console.error("Registration failed:",i),process.exit(1);}}else if(s==="invite"){n||(console.error("Error: Invite code required for invite mode."),console.error(`
|
|
72
78
|
Usage: mixrpay register --mode invite --invite-code mixr-... --name "Agent Name"`),process.exit(1)),o||(console.error("Error: Agent name required."),console.error(`
|
|
73
|
-
Usage: mixrpay register --mode invite --invite-code mixr-... --name "Agent Name"`),process.exit(1)),console.log(`Registering agent via invite code...
|
|
74
|
-
`);try{let
|
|
75
|
-
`),console.log(` Agent ID: ${
|
|
76
|
-
Your agent is now active and ready to make payments!`);}catch(
|
|
77
|
-
Usage: mixrpay register --mode self --name "Agent Name"`),process.exit(1)),console.log(`Self-registering agent...
|
|
78
|
-
`);try{let
|
|
79
|
-
`),console.log(` Agent ID: ${
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
Usage: mixrpay register --mode invite --invite-code mixr-... --name "Agent Name"`),process.exit(1)),r||console.log(`Registering agent via invite code...
|
|
80
|
+
`);let a=new AbortController,i=setTimeout(()=>a.abort(),3e4);try{let c=await fetch(`${t}/api/v2/agent/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"invite",name:o,invite_code:n}),signal:a.signal});clearTimeout(i);let l=await c.json().catch(()=>({error:"Invalid response from server"}));if(!c.ok)throw new Error(l.error||"Registration failed");(l.session?.session_key||l.token)&&a$1({sessionKey:l.session?.session_key,apiToken:l.token,baseUrl:t}),r?d({mode:"invite",agentId:l.agent_id,instanceId:l.instance_id,status:l.status,budgetUsd:l.budget_usd,inviterName:l.inviter_name,sessionKey:l.session?.session_key?x(l.session.session_key):void 0,agentToken:l.token?x(l.token):void 0},!0):(console.log(`Agent registered successfully!
|
|
81
|
+
`),console.log(` Agent ID: ${l.agent_id}`),l.instance_id&&console.log(` Instance ID: ${l.instance_id}`),console.log(` Status: ${l.status}`),console.log(` Budget: $${l.budget_usd}`),console.log(` Inviter: ${l.inviter_name}`),l.session?.session_key||l.token?(l.session?.session_key&&console.log(` Session Key: ${l.session.session_key.slice(0,16)}...`),l.token&&console.log(` Token: ${l.token.slice(0,16)}...`),console.log("\nCredentials saved. Run `mixrpay status` to check your agent.")):console.log(`
|
|
82
|
+
Your agent is now active and ready to make payments!`));}catch(c){clearTimeout(i),c instanceof Error&&c.name==="AbortError"?console.error("Registration timed out after 30 seconds."):console.error(`Registration failed: ${c instanceof Error?c.message:c}`),process.exit(1);}}else if(s==="self"){o||(console.error("Error: Agent name required."),console.error(`
|
|
83
|
+
Usage: mixrpay register --mode self --name "Agent Name"`),process.exit(1)),r||console.log(`Self-registering agent...
|
|
84
|
+
`);let a=new AbortController,i=setTimeout(()=>a.abort(),3e4);try{let c=await fetch(`${t}/api/v2/agent/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"self",name:o}),signal:a.signal});clearTimeout(i);let l=await c.json().catch(()=>({error:"Invalid response from server"}));if(!c.ok)throw new Error(l.error||"Registration failed");a$1({apiToken:l.token,baseUrl:t}),r?d({mode:"self",agentId:l.agent_id,agentToken:x(l.token),status:l.status,claimCode:l.claim_code,claimUrl:l.claim_url,expiresInDays:l.expires_in_days},!0):(console.log(`Agent created successfully!
|
|
85
|
+
`),console.log(` Agent ID: ${l.agent_id}`),console.log(` Token: ${l.token.slice(0,20)}...`),console.log(` Status: ${l.status}`),console.log(` Claim Code: ${l.claim_code}`),console.log(`
|
|
86
|
+
Token saved to credentials file.`),console.log(`
|
|
87
|
+
+---------------------------------------------------------+`),console.log("| IMPORTANT: Tools are disabled until claimed! |"),console.log("| |"),console.log("| A human must claim this agent to enable tool access: |"),console.log("+---------------------------------------------------------+"),console.log(`
|
|
88
|
+
Claim URL: ${l.claim_url}`),console.log(`
|
|
89
|
+
The claim code expires in ${l.expires_in_days} days.`),console.log("\n After claiming, run `mixrpay status` to verify activation."));}catch(c){clearTimeout(i),c instanceof Error&&c.name==="AbortError"?console.error("Registration timed out after 30 seconds."):console.error(`Registration failed: ${c instanceof Error?c.message:c}`),process.exit(1);}}}async function D(e){if(e.help||e.h){console.log(`
|
|
82
90
|
mixrpay status - Show agent balance and session info
|
|
83
91
|
|
|
84
92
|
USAGE
|
|
@@ -87,6 +95,7 @@ USAGE
|
|
|
87
95
|
OPTIONS
|
|
88
96
|
--key, --privateKey Agent's wallet private key (optional if logged in)
|
|
89
97
|
--baseUrl, --url Override MixrPay API URL
|
|
98
|
+
--json Output as JSON
|
|
90
99
|
--help, -h Show this help message
|
|
91
100
|
|
|
92
101
|
DESCRIPTION
|
|
@@ -97,51 +106,776 @@ DESCRIPTION
|
|
|
97
106
|
EXAMPLES
|
|
98
107
|
mixrpay status # Uses cached session key
|
|
99
108
|
mixrpay status --key 0x... # Uses wallet private key
|
|
100
|
-
|
|
109
|
+
mixrpay status --json # Output as JSON
|
|
110
|
+
`);return}let r=e.json===true,s=e.key||e.privateKey||process.env.AGENT_WALLET_KEY,o=e.baseUrl||e.url||c,t=b();if(!s&&t.success&&t.credentials.sessionKey)try{let n=new g({sessionKey:t.credentials.sessionKey,baseUrl:t.credentials.baseUrl||o}),a=await n.getSpendingStats(),i=await n.getSessionKeyInfo();if(r){d({walletAddress:n.getWalletAddress(),network:n.getNetwork().name,totalSpentUsd:a.totalSpentUsd,txCount:a.txCount,remainingDailyUsd:a.remainingDailyUsd,remainingTotalUsd:a.remainingTotalUsd,sessionExpiresAt:i.expiresAt?.toISOString(),authMethod:"session_key"},!0);return}console.log(`Agent Status (via session key)
|
|
101
111
|
`),console.log(`Wallet: ${n.getWalletAddress()}`),console.log(`Network: ${n.getNetwork().name}`),console.log(`
|
|
102
|
-
Spending:`),console.log(` Total spent: $${
|
|
103
|
-
Session expires: ${
|
|
112
|
+
Spending:`),console.log(` Total spent: $${a.totalSpentUsd.toFixed(2)}`),console.log(` Transaction count: ${a.txCount}`),a.remainingDailyUsd!==null&&console.log(` Daily remaining: $${a.remainingDailyUsd.toFixed(2)}`),a.remainingTotalUsd!==null&&console.log(` Total remaining: $${a.remainingTotalUsd.toFixed(2)}`),i.expiresAt&&console.log(`
|
|
113
|
+
Session expires: ${i.expiresAt.toLocaleString()}`);return}catch{console.error("Failed to get status via session key."),s||(console.error("Provide --key to use wallet signature auth instead."),process.exit(1));}s||(console.error("Error: Private key required (no cached session key found)."),console.error(`
|
|
104
114
|
Usage: mixrpay status --key 0x...`),console.error(`
|
|
105
|
-
Alternatively:`),console.error(" - Run `mixrpay login` to cache credentials"),console.error(" - Set the AGENT_WALLET_KEY environment variable"),process.exit(1)),console.log(`Fetching agent status...
|
|
106
|
-
`);try{let n=await g.getStatus({privateKey:
|
|
115
|
+
Alternatively:`),console.error(" - Run `mixrpay login` to cache credentials"),console.error(" - Set the AGENT_WALLET_KEY environment variable"),process.exit(1)),r||console.log(`Fetching agent status...
|
|
116
|
+
`);try{let n=await g.getStatus({privateKey:s,baseUrl:o});if(r){d({walletAddress:n.depositAddress,balanceUsd:n.balanceUsd,totalSpentUsd:n.totalSpentUsd,sessions:n.activeSessions.map(a=>({id:a.id,remainingUsd:a.remainingUsd,expiresAt:a.expiresAt.toISOString()})),authMethod:"wallet_key"},!0);return}console.log(`Agent Status
|
|
107
117
|
`),console.log(`Deposit Address: ${n.depositAddress}`),console.log(`Balance: $${n.balanceUsd.toFixed(2)} USDC`),console.log(`Total Spent: $${n.totalSpentUsd.toFixed(2)}`),console.log(`
|
|
108
|
-
Active Sessions: ${n.activeSessions.length}`);for(let
|
|
118
|
+
Active Sessions: ${n.activeSessions.length}`);for(let a of n.activeSessions){let i=a.remainingUsd!==null?`$${a.remainingUsd.toFixed(2)} remaining`:"unlimited";console.log(` - ${a.id.slice(0,8)}... ${i}, expires ${a.expiresAt.toLocaleDateString()}`);}}catch(n){n instanceof a?console.error(`Failed to get status: ${n.message}`):console.error("Failed to get status:",n),process.exit(1);}}async function F(e){let r=e.json===true;try{let s=await u(e),o=await s.getBalance(),t=await s.getSpendingStats();r?d({address:s.getWalletAddress(),network:s.getNetwork().name,balance_usd:o,total_spent_usd:t.totalSpentUsd,tx_count:t.txCount,remaining_daily_usd:t.remainingDailyUsd,remaining_total_usd:t.remainingTotalUsd},!0):(console.log(`
|
|
119
|
+
Wallet Balance
|
|
120
|
+
`),console.log(`Address: ${s.getWalletAddress()}`),console.log(`Network: ${s.getNetwork().name}`),console.log(`Balance: $${o.toFixed(2)} USDC`),console.log(`
|
|
121
|
+
Spending:`),console.log(` Total spent: $${t.totalSpentUsd.toFixed(2)}`),console.log(` Transactions: ${t.txCount}`),t.remainingDailyUsd!==null&&console.log(` Daily remaining: $${t.remainingDailyUsd.toFixed(2)}`),t.remainingTotalUsd!==null&&console.log(` Total remaining: $${t.remainingTotalUsd.toFixed(2)}`));}catch(s){console.error("Failed to get balance:",s instanceof Error?s.message:s),process.exit(1);}}async function M(e){let r=e.json===true;try{let s=await u(e);if(await s.hasSelfCustodyWallet()){await s.loadSelfCustodyWallet();let a=s.getSelfCustodyAddress();r?d({address:a,already_exists:!0},!0):(console.log(`
|
|
122
|
+
Self-custody wallet already exists.`),console.log(`Address: ${a}`),console.log("\nUse `mixrpay wallet self-custody` to view details."));return}console.log(`Creating self-custody wallet...
|
|
123
|
+
`);let{address:t,privateKey:n}=await s.createSelfCustodyWallet();r?d({address:t,private_key:n,warning:"Save your private key securely. It cannot be recovered."},!0):(console.log(`Self-custody wallet created!
|
|
124
|
+
`),console.log(`Address: ${t}`),console.log(`
|
|
125
|
+
Private Key: ${n}`),console.log(`
|
|
126
|
+
!!! IMPORTANT !!!`),console.log("Save your private key securely. It cannot be recovered."),console.log("The key is stored locally but you should backup elsewhere."));}catch(s){console.error("Failed to create wallet:",s instanceof Error?s.message:s),process.exit(1);}}async function L(e){let r=e.json===true;try{let s=await u(e),o=s.getWalletAddress(),t=s.getNetwork();r?d({address:o,network:t.name,chain_id:t.chainId},!0):(console.log(`
|
|
127
|
+
Delegation Wallet Address: ${o}`),console.log(`Network: ${t.name} (Chain ID: ${t.chainId})`));}catch(s){console.error("Failed to get address:",s instanceof Error?s.message:s),process.exit(1);}}async function q(e){let r=e.json===true;try{let s=await u(e);if(!await s.hasSelfCustodyWallet()){r?d({exists:!1},!0):(console.log(`
|
|
128
|
+
No self-custody wallet found.`),console.log("Run `mixrpay wallet create` to create one."));return}await s.loadSelfCustodyWallet();let t=s.getSelfCustodyAddress();r?d({exists:!0,address:t},!0):(console.log(`
|
|
129
|
+
Self-Custody Wallet Address: ${t}`),console.log(`
|
|
130
|
+
This wallet can send USDC directly on-chain.`),console.log("Use `mixrpay wallet send-direct` for direct transfers."));}catch(s){console.error("Failed to get self-custody info:",s instanceof Error?s.message:s),process.exit(1);}}async function B(e){let r=e.json===true;try{let s=await u(e),o=s.getWalletAddress(),t=s.getNetwork();r?d({deposit_address:o,network:t.name,chain_id:t.chainId,token:"USDC",instructions:"Send USDC on Base network to the deposit address."},!0):(console.log(`
|
|
131
|
+
Funding Instructions
|
|
132
|
+
`),console.log(`Deposit Address: ${o}`),console.log(`Network: ${t.name} (Chain ID: ${t.chainId})`),console.log("Token: USDC"),console.log(`
|
|
133
|
+
Instructions:`),console.log(" 1. Send USDC on Base network to the deposit address above"),console.log(" 2. Funds appear within 1-2 minutes after confirmation"),console.log(" 3. Run `mixrpay wallet balance` to check your balance"),console.log(`
|
|
134
|
+
Note: Only send USDC on Base. Other tokens may be lost.`));}catch(s){console.error("Failed to get funding info:",s instanceof Error?s.message:s),process.exit(1);}}async function W(e,r){let s=e.json===true,o=r[0]||e.amount;o||(console.error("Error: Amount required."),console.error(`
|
|
135
|
+
Usage: mixrpay wallet afford <amount>`),console.error("Example: mixrpay wallet afford 10.00"),process.exit(1));let t=parseFloat(o);(isNaN(t)||t<=0)&&(console.error("Error: Invalid amount. Must be a positive number."),process.exit(1));try{let a=await(await u(e)).canAfford(t);s?d({amount_requested:t,can_afford:a.canAfford,balance:a.balance,shortfall:a.shortfall,remaining_after:a.remainingAfter},!0):(console.log(`
|
|
136
|
+
Affordability Check: $${t.toFixed(2)}
|
|
137
|
+
`),console.log(`Balance: $${a.balance.toFixed(2)}`),a.canAfford?(console.log("Status: CAN AFFORD"),console.log(`Remaining after: $${a.remainingAfter.toFixed(2)}`)):(console.log("Status: CANNOT AFFORD"),console.log(`Shortfall: $${a.shortfall.toFixed(2)}`),console.log("\nRun `mixrpay wallet fund` to add funds.")));}catch(n){console.error("Failed to check affordability:",n instanceof Error?n.message:n),process.exit(1);}}async function K(e,r){let s=e.json===true,o=r[0]||e.to,t=r[1]||e.amount,n=e.idempotencyKey;(!o||!t)&&(console.error("Error: Recipient address and amount required."),console.error(`
|
|
138
|
+
Usage: mixrpay wallet send <to> <amount>`),console.error("Example: mixrpay wallet send 0x1234... 10.00"),process.exit(1)),(!o.startsWith("0x")||o.length!==42)&&(console.error("Error: Invalid recipient address. Must be 0x followed by 40 hex chars."),process.exit(1));let a=parseFloat(t);(isNaN(a)||a<=0)&&(console.error("Error: Invalid amount. Must be a positive number."),process.exit(1));try{let i=await u(e);s||(console.log(`
|
|
139
|
+
Sending $${a.toFixed(2)} USDC to ${o.slice(0,10)}...${o.slice(-8)}`),console.log(`Using delegation budget...
|
|
140
|
+
`));let c=await i.transfer(o,a.toFixed(2),"USDC",n?{idempotencyKey:n}:void 0);s?d(c,!0):(console.log(`Transfer successful!
|
|
141
|
+
`),console.log(`Amount: $${c.amount_usd}`),console.log(`To: ${o}`),console.log(`TX Hash: ${c.tx_hash}`),console.log(`Remaining budget: $${c.remaining_budget_usd?.toFixed(2)||"N/A"}`));}catch(i){console.error("Transfer failed:",i instanceof Error?i.message:i),process.exit(1);}}async function J(e,r){let s=e.json===true,o=r[0]||e.to,t=r[1]||e.amount;(!o||!t)&&(console.error("Error: Recipient address and amount required."),console.error(`
|
|
142
|
+
Usage: mixrpay wallet send-direct <to> <amount>`),console.error("Example: mixrpay wallet send-direct 0x1234... 10.00"),process.exit(1)),(!o.startsWith("0x")||o.length!==42)&&(console.error("Error: Invalid recipient address. Must be 0x followed by 40 hex chars."),process.exit(1));let n=parseFloat(t);(isNaN(n)||n<=0)&&(console.error("Error: Invalid amount. Must be a positive number."),process.exit(1));try{let a=await u(e);await a.hasSelfCustodyWallet()||(console.error("Error: No self-custody wallet found."),console.error("\nRun `mixrpay wallet create` first to create a self-custody wallet."),console.error("Or use `mixrpay wallet send` to use delegation budget instead."),process.exit(1)),await a.loadSelfCustodyWallet(),s||(console.log(`
|
|
143
|
+
Sending $${n.toFixed(2)} USDC to ${o.slice(0,10)}...${o.slice(-8)}`),console.log(`Using self-custody wallet (on-chain)...
|
|
144
|
+
`));let c=await a.transferUSDC({to:o,amountUsdc:n});s?d({tx_hash:c,to:o,amount_usdc:n},!0):(console.log(`Transfer successful!
|
|
145
|
+
`),console.log(`Amount: $${n.toFixed(2)} USDC`),console.log(`To: ${o}`),console.log(`TX Hash: ${c}`));}catch(a){console.error("Transfer failed:",a instanceof Error?a.message:a),process.exit(1);}}async function G(e){let r=e.json===true;try{let s=await u(e);try{let o=await s.getTransactions();if(r)d({transactions:o},!0);else if(console.log(`
|
|
146
|
+
Transaction History
|
|
147
|
+
`),o.length===0)console.log("No transactions found.");else {for(let t of o.slice(0,20)){let n=new Date(t.created_at).toLocaleDateString(),a=t.type||"payment",i=t.amount_usd?`$${t.amount_usd.toFixed(2)}`:"N/A";console.log(` ${n} | ${a.padEnd(12)} | ${i.padStart(10)} | ${t.status}`);}o.length>20&&console.log(`
|
|
148
|
+
... and ${o.length-20} more transactions`);}}catch{let o=s.getPaymentHistory();if(r)d({payments:o,note:"In-memory history only (session-scoped)"},!0);else {if(console.log(`
|
|
149
|
+
Payment History (Current Session)
|
|
150
|
+
`),o.length===0)console.log("No payments in current session.");else for(let t of o){let n=new Date(t.timestamp).toLocaleTimeString();console.log(` ${n} | $${t.amountUsd.toFixed(4)} | ${t.provider||"unknown"}`);}console.log(`
|
|
151
|
+
Note: This shows only current session payments.`),console.log("Full history requires API token auth.");}}}catch(s){console.error("Failed to get history:",s instanceof Error?s.message:s),process.exit(1);}}async function X(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
152
|
+
mixrpay wallet - Manage your agent wallet
|
|
153
|
+
|
|
154
|
+
USAGE
|
|
155
|
+
mixrpay wallet [subcommand] [options]
|
|
156
|
+
|
|
157
|
+
SUBCOMMANDS
|
|
158
|
+
balance Show USDC balance (default)
|
|
159
|
+
create Create self-custody wallet
|
|
160
|
+
address Show delegation wallet address
|
|
161
|
+
self-custody Show self-custody wallet address
|
|
162
|
+
fund Show deposit address and funding instructions
|
|
163
|
+
afford <amt> Check if you can afford an amount
|
|
164
|
+
send <to> <amt> Send USDC via delegation budget
|
|
165
|
+
send-direct <to> <amt> Send USDC from self-custody wallet
|
|
166
|
+
history Show payment/transaction history
|
|
167
|
+
|
|
168
|
+
OPTIONS
|
|
169
|
+
--json Output as JSON
|
|
170
|
+
--baseUrl, --url Override MixrPay API URL
|
|
171
|
+
--help, -h Show this help message
|
|
172
|
+
|
|
173
|
+
EXAMPLES
|
|
174
|
+
mixrpay wallet # Show balance
|
|
175
|
+
mixrpay wallet balance --json # Balance as JSON
|
|
176
|
+
mixrpay wallet create # Create self-custody wallet
|
|
177
|
+
mixrpay wallet afford 50.00 # Check if can afford $50
|
|
178
|
+
mixrpay wallet send 0x123... 10.00 # Send $10 via delegation
|
|
179
|
+
mixrpay wallet send-direct 0x123... 10.00 # Send $10 on-chain
|
|
180
|
+
mixrpay wallet history # View transactions
|
|
181
|
+
`);return}switch(s){case "create":await M(e);break;case "address":await L(e);break;case "self-custody":await q(e);break;case "fund":await B(e);break;case "afford":await W(e,r.slice(1));break;case "send":await K(e,r.slice(1));break;case "send-direct":await J(e,r.slice(1));break;case "history":await G(e);break;case "balance":case void 0:default:await F(e);break}}async function H(e){let r=e.json===true;try{let o=await(await u(e)).getAvailableBudget();r?d({total_budget_usd:o.totalBudget,spent_usd:o.spent,allocated_to_children_usd:o.allocatedToChildren,available_usd:o.available,max_spawn_budget_usd:o.maxSpawnBudget,can_spawn:o.canSpawn},!0):(console.log(`
|
|
182
|
+
Budget Overview
|
|
183
|
+
`),console.log(`Total Budget: $${o.totalBudget.toFixed(2)}`),console.log(`Spent: $${o.spent.toFixed(2)}`),console.log(`Allocated: $${o.allocatedToChildren.toFixed(2)} (to children)`),console.log(`Available: $${o.available.toFixed(2)}`),console.log(""),console.log(`Can Spawn: ${o.canSpawn?"Yes":"No"}`),console.log(`Max Spawn Budget: $${o.maxSpawnBudget.toFixed(2)}`));}catch(s){console.error("Failed to get budget:",s instanceof Error?s.message:s),process.exit(1);}}async function Y(e){let r=e.json===true,s=e.name||e.n,o=e.budget||e.b,t=e.expires||e.e,n=e.merchants||e.m;if(e.help||e.h){console.log(`
|
|
184
|
+
mixrpay spawn - Create a child invite for a sub-agent
|
|
185
|
+
|
|
186
|
+
USAGE
|
|
187
|
+
mixrpay spawn --name <name> --budget <amount> [options]
|
|
188
|
+
|
|
189
|
+
OPTIONS
|
|
190
|
+
--name, -n Name for the child agent (required)
|
|
191
|
+
--budget, -b Budget in USD to allocate (required)
|
|
192
|
+
--expires, -e Days until expiry (default: parent's remaining time)
|
|
193
|
+
--merchants, -m Comma-separated allowed merchants (must be subset of parent)
|
|
194
|
+
--json Output as JSON
|
|
195
|
+
--help, -h Show this help message
|
|
196
|
+
|
|
197
|
+
EXAMPLES
|
|
198
|
+
mixrpay spawn --name "Research Agent" --budget 10.00
|
|
199
|
+
mixrpay spawn -n "Writer" -b 5.00 --expires 7
|
|
200
|
+
mixrpay spawn -n "API Agent" -b 20.00 --merchants "openai.com,anthropic.com"
|
|
201
|
+
`);return}s||(console.error("Error: Name is required."),console.error(`
|
|
202
|
+
Usage: mixrpay spawn --name <name> --budget <amount>`),process.exit(1)),o||(console.error("Error: Budget is required."),console.error(`
|
|
203
|
+
Usage: mixrpay spawn --name <name> --budget <amount>`),process.exit(1));let a=parseFloat(o);(isNaN(a)||a<=0)&&(console.error("Error: Invalid budget. Must be a positive number."),process.exit(1));let i=t?parseInt(t,10):void 0,c=n?n.split(",").map(l=>l.trim()):void 0;try{let l=await u(e);r||console.log(`
|
|
204
|
+
Creating child invite for "${s}" with $${a.toFixed(2)} budget...
|
|
205
|
+
`);let g=await l.spawnChildInvite({budgetUsd:a,name:s,allowedMerchants:c,expiresInDays:i});r?d({invite_code:g.inviteCode,invite_id:g.inviteId,budget_usd:g.budgetUsd,expires_at:g.expiresAt.toISOString(),depth:g.depth,max_spawn_budget:g.maxSpawnBudget,allowed_merchants:g.allowedMerchants},!0):(console.log(`Child invite created!
|
|
206
|
+
`),console.log(`Invite Code: ${g.inviteCode}`),console.log(`Budget: $${g.budgetUsd.toFixed(2)}`),console.log(`Expires: ${g.expiresAt.toLocaleDateString()}`),console.log(`Depth: ${g.depth}`),console.log(`Max Spawn Budget: $${g.maxSpawnBudget.toFixed(2)}`),g.allowedMerchants?.length>0&&console.log(`Allowed Merchants: ${g.allowedMerchants.join(", ")}`),console.log(`
|
|
207
|
+
Share this invite code with the sub-agent:`),console.log(` mixrpay register --mode invite --invite-code ${g.inviteCode} --name "${s}"`));}catch(l){console.error("Failed to spawn child:",l instanceof Error?l.message:l),process.exit(1);}}async function V(e){let r=e.json===true;try{let o=await(await u(e)).getChildSessions();if(r)d({children:o},!0);else if(console.log(`
|
|
208
|
+
Child Sessions
|
|
209
|
+
`),o.length===0)console.log("No child sessions found."),console.log("\nUse `mixrpay spawn` to create a child invite.");else for(let t of o){let n=t.spentUsd??0,a=t.budgetUsd??0,i=a>0?(n/a*100).toFixed(0):"0";console.log(`${t.name||"Unnamed"}`),console.log(` Budget: $${n.toFixed(2)} / $${a.toFixed(2)} (${i}% used)`),console.log(` Status: ${t.status||"unknown"}`),console.log(` Depth: ${t.depth||1}`),t.children&&t.children.length>0&&console.log(` Children: ${t.children.length}`),console.log("");}}catch(s){console.error("Failed to get children:",s instanceof Error?s.message:s),process.exit(1);}}async function Q(e){if(e.help||e.h){console.log(`
|
|
210
|
+
mixrpay budget - Show available budget for spawning
|
|
211
|
+
|
|
212
|
+
USAGE
|
|
213
|
+
mixrpay budget [options]
|
|
214
|
+
|
|
215
|
+
OPTIONS
|
|
216
|
+
--json Output as JSON
|
|
217
|
+
--help, -h Show this help message
|
|
218
|
+
|
|
219
|
+
DESCRIPTION
|
|
220
|
+
Shows your current budget allocation including:
|
|
221
|
+
- Total budget assigned to your session
|
|
222
|
+
- Amount spent on tools/services
|
|
223
|
+
- Amount allocated to child agents
|
|
224
|
+
- Available budget for spawning new children
|
|
225
|
+
|
|
226
|
+
EXAMPLES
|
|
227
|
+
mixrpay budget
|
|
228
|
+
mixrpay budget --json
|
|
229
|
+
`);return}await H(e);}async function z(e,r){let s=e.json===true,o=r.join(" ")||e.prompt,t=e.model||e.m,n=e.system||e.s;if(e.help||e.h){console.log(`
|
|
230
|
+
mixrpay complete - Get an LLM completion
|
|
231
|
+
|
|
232
|
+
USAGE
|
|
233
|
+
mixrpay complete "<prompt>"
|
|
234
|
+
mixrpay complete --prompt "<prompt>"
|
|
235
|
+
|
|
236
|
+
OPTIONS
|
|
237
|
+
--model, -m Model to use (default: gpt-4o-mini)
|
|
238
|
+
--system, -s System prompt
|
|
239
|
+
--json Output as JSON
|
|
240
|
+
--help, -h Show this help message
|
|
241
|
+
|
|
242
|
+
DESCRIPTION
|
|
243
|
+
Simple LLM completion without tools. For agentic workflows with
|
|
244
|
+
tool use, see 'mixrpay run'.
|
|
245
|
+
|
|
246
|
+
MODELS
|
|
247
|
+
gpt-4o-mini Fast and cheap (default)
|
|
248
|
+
gpt-4o More capable
|
|
249
|
+
claude-3-5-sonnet Most capable for reasoning
|
|
250
|
+
|
|
251
|
+
EXAMPLES
|
|
252
|
+
mixrpay complete "Explain quantum computing in 3 sentences"
|
|
253
|
+
mixrpay complete "Write a haiku" --model gpt-4o
|
|
254
|
+
mixrpay complete "Summarize this" -s "Be concise"
|
|
255
|
+
`);return}o||(console.error("Error: Prompt required."),console.error(`
|
|
256
|
+
Usage: mixrpay complete "<prompt>"`),process.exit(1));try{let a=await u(e);s||console.log(`Generating completion${t?` with ${t}`:""}...
|
|
257
|
+
`);let i=await a.complete(o,{model:t,systemPrompt:n});s?d({text:i.text,cost_usd:i.costUsd,model:i.model,tokens:i.tokens},!0):(console.log(i.text),console.log(`
|
|
258
|
+
---
|
|
259
|
+
Cost: $${i.costUsd.toFixed(4)} | Model: ${i.model}`));}catch(a){console.error("Completion failed:",a instanceof Error?a.message:a),process.exit(1);}}async function Z(e,r){let s=e.json===true,o=r.join(" ")||e.prompt,t=e.model||e.m,n=e.system||e.s,a=e.iterations?parseInt(e.iterations,10):void 0,i=e.tools||e.t,c=e.status;if(e.help||e.h){console.log(`
|
|
260
|
+
mixrpay run - Run an AI agent with tools
|
|
261
|
+
|
|
262
|
+
USAGE
|
|
263
|
+
mixrpay run "<prompt>"
|
|
264
|
+
mixrpay run --status <run_id>
|
|
265
|
+
|
|
266
|
+
OPTIONS
|
|
267
|
+
--model, -m Model to use (default: gpt-4o)
|
|
268
|
+
--system, -s System prompt
|
|
269
|
+
--iterations Max iterations (default: 10)
|
|
270
|
+
--tools, -t Comma-separated tools (e.g., "firecrawl-search,exa-search")
|
|
271
|
+
--status <id> Check status of a previous run
|
|
272
|
+
--json Output as JSON
|
|
273
|
+
--help, -h Show this help message
|
|
274
|
+
|
|
275
|
+
DESCRIPTION
|
|
276
|
+
Run a full agentic loop with LLM reasoning and tool execution.
|
|
277
|
+
The agent will automatically call tools as needed to complete
|
|
278
|
+
the task.
|
|
279
|
+
|
|
280
|
+
EXAMPLES
|
|
281
|
+
mixrpay run "Find AI startups in SF and summarize their products"
|
|
282
|
+
mixrpay run "Research quantum computing" --model gpt-4o --iterations 15
|
|
283
|
+
mixrpay run --status run_abc123
|
|
284
|
+
`);return}try{let l=await u(e);if(c){let p=await l.getAgentRunStatus(c);s?d({run_id:p.runId,status:p.status,response:p.response,iterations:p.iterations,tools_used:p.toolsUsed,cost:p.cost,tokens:p.tokens,error:p.error},!0):(console.log(`
|
|
285
|
+
Run Status: ${p.runId}
|
|
286
|
+
`),console.log(`Status: ${p.status}`),console.log(`Iterations: ${p.iterations}`),console.log(`Tools used: ${p.toolsUsed?.join(", ")||"none"}`),console.log(`Cost: $${p.cost.totalUsd.toFixed(4)}`),p.status==="completed"&&p.response&&console.log(`
|
|
287
|
+
Response:
|
|
288
|
+
${p.response}`),p.error&&console.log(`
|
|
289
|
+
Error: ${p.error}`));return}o||(console.error("Error: Prompt required."),console.error(`
|
|
290
|
+
Usage: mixrpay run "<prompt>"`),console.error(" mixrpay run --status <run_id>"),process.exit(1)),s||console.log(`Running agent${t?` with ${t}`:""}...
|
|
291
|
+
`);let g=i?i.split(",").map(p=>p.trim()):void 0,m=await l.runAgent({messages:[{role:"user",content:o}],config:{model:t,maxIterations:a,tools:g,systemPrompt:n}});s?d({run_id:m.runId,response:m.response,iterations:m.iterations,tools_used:m.toolsUsed,cost:m.cost,tokens:m.tokens,tx_hash:m.txHash},!0):(console.log(m.response),console.log(`
|
|
292
|
+
---`),console.log(`Run ID: ${m.runId||"N/A"}`),console.log(`Iterations: ${m.iterations}`),console.log(`Tools used: ${m.toolsUsed?.join(", ")||"none"}`),console.log(`Cost: $${m.cost.totalUsd.toFixed(4)} (LLM: $${m.cost.llmUsd.toFixed(4)}, Tools: $${m.cost.toolsUsd.toFixed(4)})`),m.txHash&&console.log(`TX: ${m.txHash}`));}catch(l){console.error("Agent run failed:",l instanceof Error?l.message:l),process.exit(1);}}async function ee(e){let r=e.json===true;if(e.help||e.h){console.log(`
|
|
293
|
+
mixrpay diagnostics - Run comprehensive diagnostics
|
|
294
|
+
|
|
295
|
+
USAGE
|
|
296
|
+
mixrpay diagnostics [options]
|
|
297
|
+
|
|
298
|
+
OPTIONS
|
|
299
|
+
--json Output as JSON
|
|
300
|
+
--help, -h Show this help message
|
|
301
|
+
|
|
302
|
+
DESCRIPTION
|
|
303
|
+
Runs a comprehensive check of your wallet configuration:
|
|
304
|
+
- Session key validity and expiration
|
|
305
|
+
- API connectivity and latency
|
|
306
|
+
- Balance availability
|
|
307
|
+
- Spending limits
|
|
308
|
+
|
|
309
|
+
EXAMPLES
|
|
310
|
+
mixrpay diagnostics
|
|
311
|
+
mixrpay diagnostics --json
|
|
312
|
+
`);return}try{let s=await u(e);r||console.log(`Running diagnostics...
|
|
313
|
+
`);let o=await s.runDiagnostics();if(r)d({healthy:o.healthy,issues:o.issues,recommendations:o.recommendations,checks:o.checks,sdk_version:o.sdkVersion,network:o.network,wallet_address:o.walletAddress,session_limits:o.sessionLimits,latency_ms:o.latencyMs},!0);else {if(console.log(`Overall: ${o.healthy?"HEALTHY":"ISSUES FOUND"}
|
|
314
|
+
`),console.log("Checks:"),console.log(` Session key format: ${o.checks.sessionKeyFormat?"OK":"FAIL"}`),console.log(` API connectivity: ${o.checks.apiConnectivity?"OK":"FAIL"}`),console.log(` Session key valid: ${o.checks.sessionKeyValid?"OK":"FAIL"}`),console.log(` Has balance: ${o.checks.hasBalance?"OK":"FAIL"}`),console.log(`
|
|
315
|
+
Environment:`),console.log(` SDK Version: ${o.sdkVersion}`),console.log(` Network: ${o.network}`),console.log(` Wallet: ${o.walletAddress}`),o.latencyMs&&console.log(` API Latency: ${o.latencyMs}ms`),o.sessionLimits&&(console.log(`
|
|
316
|
+
Limits:`),o.sessionLimits.remainingDailyUsd!==null&&console.log(` Daily remaining: $${o.sessionLimits.remainingDailyUsd.toFixed(2)}`),o.sessionLimits.remainingTotalUsd!==null&&console.log(` Total remaining: $${o.sessionLimits.remainingTotalUsd.toFixed(2)}`),o.sessionLimits.expiresAt&&console.log(` Expires: ${o.sessionLimits.expiresAt.toLocaleString()}`)),o.issues.length>0){console.log(`
|
|
317
|
+
Issues:`);for(let t of o.issues)console.log(` - ${t}`);}if(o.recommendations.length>0){console.log(`
|
|
318
|
+
Recommendations:`);for(let t of o.recommendations)console.log(` - ${t}`);}}}catch(s){console.error("Diagnostics failed:",s instanceof Error?s.message:s),process.exit(1);}}async function oe(e){let r=e.json===true,s=e.baseUrl||e.url||c;if(e.help||e.h){console.log(`
|
|
319
|
+
mixrpay health - Check MixrPay server health
|
|
320
|
+
|
|
321
|
+
USAGE
|
|
322
|
+
mixrpay health [options]
|
|
323
|
+
|
|
324
|
+
OPTIONS
|
|
325
|
+
--baseUrl, --url Override MixrPay API URL
|
|
326
|
+
--json Output as JSON
|
|
327
|
+
--help, -h Show this help message
|
|
328
|
+
|
|
329
|
+
DESCRIPTION
|
|
330
|
+
Checks the health of the MixrPay server without requiring authentication.
|
|
331
|
+
Useful for debugging connectivity issues.
|
|
332
|
+
|
|
333
|
+
EXAMPLES
|
|
334
|
+
mixrpay health
|
|
335
|
+
mixrpay health --baseUrl https://staging.mixrpay.com
|
|
336
|
+
`);return}r||console.log(`Checking server health at ${s}...
|
|
337
|
+
`);let o=await g.checkServerHealth(s);r?d(o):(console.log(`Server Health
|
|
338
|
+
`),console.log(` Healthy: ${o.healthy?"Yes":"No"}`),console.log(` Database: ${o.database}`),console.log(` Agent Registration: ${o.agentRegistrationAvailable?"Available":"Unavailable"}`),console.log(` Wallet Service: ${o.walletServiceConfigured?"Configured":"Not configured"}`),o.error&&console.log(`
|
|
339
|
+
Error: ${o.error}`));}async function te(e){let r=e.json===true,s=e.domain||e.d,o=e.uri||e.u,t=e.statement||e.s,n=e.nonce;if(e.help||e.h){console.log(`
|
|
340
|
+
mixrpay siwe - Generate SIWE (Sign-In with Ethereum) message
|
|
341
|
+
|
|
342
|
+
USAGE
|
|
343
|
+
mixrpay siwe --domain <domain> --uri <uri> [options]
|
|
344
|
+
|
|
345
|
+
OPTIONS
|
|
346
|
+
--domain, -d Domain for SIWE (required)
|
|
347
|
+
--uri, -u URI for SIWE (required)
|
|
348
|
+
--statement, -s Statement to include in message
|
|
349
|
+
--nonce Custom nonce (random if not provided)
|
|
350
|
+
--json Output as JSON
|
|
351
|
+
--help, -h Show this help message
|
|
352
|
+
|
|
353
|
+
DESCRIPTION
|
|
354
|
+
Generates an EIP-4361 compliant SIWE message and signature.
|
|
355
|
+
Use this to authenticate with services that support Sign-In with Ethereum.
|
|
356
|
+
|
|
357
|
+
EXAMPLES
|
|
358
|
+
mixrpay siwe --domain example.com --uri https://example.com/login
|
|
359
|
+
mixrpay siwe -d myapp.com -u https://myapp.com -s "Sign in to My App"
|
|
360
|
+
`);return}(!s||!o)&&(console.error("Error: Domain and URI are required."),console.error(`
|
|
361
|
+
Usage: mixrpay siwe --domain <domain> --uri <uri>`),process.exit(1));try{let i=await(await u(e)).generateSiwe({domain:s,uri:o,statement:t,nonce:n});r?d({message:i.message,signature:i.signature,address:i.address,domain:i.domain,nonce:i.nonce,issued_at:i.issuedAt.toISOString(),expiration_time:i.expirationTime?.toISOString()},!0):(console.log(`
|
|
362
|
+
SIWE Message Generated
|
|
363
|
+
`),console.log("Message:"),console.log("---"),console.log(i.message),console.log("---"),console.log(`
|
|
364
|
+
Signature: ${i.signature}`),console.log(`Address: ${i.address}`),console.log(`Nonce: ${i.nonce}`));}catch(a){console.error("Failed to generate SIWE:",a instanceof Error?a.message:a),process.exit(1);}}async function se(e){let r=e.json===true;try{let o=await(await u(e)).listSessions();if(r)d({sessions:o},!0);else if(console.log(`
|
|
365
|
+
Merchant Sessions
|
|
366
|
+
`),o.length===0)console.log("No active sessions found.");else for(let t of o){let n=t.spentUsd??0,a=t.limitUsd??1/0,i=a===1/0?"unlimited":`$${a.toFixed(2)}`,c=t.status||"active";console.log(`${t.merchantName||t.id.slice(0,12)}`),console.log(` ID: ${t.id}`),console.log(` Status: ${c}`),console.log(` Spent: $${n.toFixed(2)} / ${i}`),t.expiresAt&&console.log(` Expires: ${new Date(t.expiresAt).toLocaleDateString()}`),console.log("");}}catch(s){console.error("Failed to list sessions:",s instanceof Error?s.message:s),process.exit(1);}}async function ne(e){let r=e.json===true;try{let o=await(await u(e)).getSessionStats();r?d({active_count:o.activeCount,total_count:o.totalCount,total_spent_usd:o.totalSpentUsd,total_limit_usd:o.totalLimitUsd,revoked_count:o.revokedCount},!0):(console.log(`
|
|
367
|
+
Session Statistics
|
|
368
|
+
`),console.log(`Active Sessions: ${o.activeCount}`),console.log(`Total Sessions: ${o.totalCount}`),console.log(`Revoked Sessions: ${o.revokedCount}`),console.log(`Total Spent: $${o.totalSpentUsd.toFixed(2)}`),o.totalLimitUsd&&console.log(`Total Limit: $${o.totalLimitUsd.toFixed(2)}`));}catch(s){console.error("Failed to get session stats:",s instanceof Error?s.message:s),process.exit(1);}}async function re(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Session ID required."),console.error(`
|
|
369
|
+
Usage: mixrpay sessions revoke <session_id>`),process.exit(1));try{let n=await(await u(e)).revokeSession(o);s?d({session_id:o,revoked:n},!0):console.log(n?`
|
|
370
|
+
Session ${o} revoked successfully.`:`
|
|
371
|
+
Session ${o} could not be revoked (may already be revoked).`);}catch(t){console.error("Failed to revoke session:",t instanceof Error?t.message:t),process.exit(1);}}async function ae(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
372
|
+
mixrpay sessions - Manage merchant sessions
|
|
373
|
+
|
|
374
|
+
USAGE
|
|
375
|
+
mixrpay sessions [subcommand] [options]
|
|
376
|
+
|
|
377
|
+
SUBCOMMANDS
|
|
378
|
+
list List active sessions (default)
|
|
379
|
+
stats Show session statistics
|
|
380
|
+
revoke <id> Revoke a session
|
|
381
|
+
|
|
382
|
+
OPTIONS
|
|
383
|
+
--json Output as JSON
|
|
384
|
+
--help, -h Show this help message
|
|
385
|
+
|
|
386
|
+
DESCRIPTION
|
|
387
|
+
Sessions are used when interacting with merchants that support
|
|
388
|
+
session-based billing (like x402 merchants).
|
|
389
|
+
|
|
390
|
+
EXAMPLES
|
|
391
|
+
mixrpay sessions
|
|
392
|
+
mixrpay sessions stats
|
|
393
|
+
mixrpay sessions revoke sk_abc123...
|
|
394
|
+
`);return}switch(s){case "stats":await ne(e);break;case "revoke":await re(e,r.slice(1));break;case "list":case void 0:default:await se(e);break}}async function ie(e){let r=e.json===true;try{let o=await(await u(e)).listMCPTools();if(r)d({tools:o},!0);else if(console.log(`
|
|
395
|
+
MCP Tools
|
|
396
|
+
`),o.length===0)console.log("No MCP tools available.");else {for(let t of o)console.log(`${t.name}`),t.description&&console.log(` ${t.description}`);console.log(`
|
|
397
|
+
Total: ${o.length} tools`);}}catch(s){console.error("Failed to list MCP tools:",s instanceof Error?s.message:s),process.exit(1);}}async function le(e,r){let s=e.json===true,o=r[0],t=r[1]||"{}";o||(console.error("Error: Tool name required."),console.error(`
|
|
398
|
+
Usage: mixrpay mcp call <tool_name> '{"arg":"value"}'`),process.exit(1));let n=I(t,"Invalid JSON arguments");try{let i=await(await u(e)).callMCPTool(o,n);s?d(i,!0):(console.log(`
|
|
399
|
+
MCP Tool Result
|
|
400
|
+
`),i.chargedUsd&&console.log(`Cost: $${i.chargedUsd.toFixed(4)}`),console.log("Result:"),console.log(JSON.stringify(i.content,null,2)));}catch(a){console.error("MCP tool call failed:",a instanceof Error?a.message:a),process.exit(1);}}async function ce(e,r){let s=e.json===true,o=r[0]||e.id||e.glamaId,t=e.namespace||e.ns,n=e.slug,a=e.name||e.n,i=e.description,c=e.ttl,l=e.env;(!o||!t||!n||!a)&&(console.error("Error: Glama ID, namespace, slug, and tool name are required."),console.error(`
|
|
401
|
+
Usage: mixrpay mcp deploy <glama_id> --namespace <ns> --slug <slug> --name <tool_name>`),console.error(`
|
|
402
|
+
Example:`),console.error(' mixrpay mcp deploy notion-mcp --namespace notion --slug notion-mcp --name "Notion MCP"'),console.error("\nNote: Use `mixrpay skills` for pre-configured app integrations."),process.exit(1));let g;l&&(g=I(l,"Invalid JSON for --env"));let m=c?parseInt(c,10):void 0;try{let p=await u(e);s||console.log(`
|
|
403
|
+
Deploying MCP server: ${a}...
|
|
404
|
+
`);let b=await p.deployJitMcp({glamaId:o,glamaNamespace:t,glamaSlug:n,toolName:a,toolDescription:i,envVars:g,ttlHours:m}),y=b.instance;s?d({instance_id:y.instanceId,tool_name:y.toolName,status:y.status,endpoint_url:y.endpointUrl,expires_at:y.expiresAt?.toISOString(),payment:b.payment},!0):(console.log(`MCP Server Deployed!
|
|
405
|
+
`),console.log(`Instance ID: ${y.instanceId}`),console.log(`Tool: ${y.toolName}`),console.log(`Status: ${y.status}`),y.endpointUrl&&console.log(`Endpoint: ${y.endpointUrl}`),y.expiresAt&&console.log(`Expires: ${y.expiresAt.toLocaleString()}`),b.payment?.amountUsd&&console.log(`Cost: $${b.payment.amountUsd.toFixed(2)}`));}catch(p){console.error("Failed to deploy MCP server:",p instanceof Error?p.message:p),process.exit(1);}}async function de(e){let r=e.json===true,s=e.status;try{let t=await(await u(e)).listJitInstances({status:s});if(r)d({instances:t},!0);else if(console.log(`
|
|
406
|
+
JIT MCP Instances
|
|
407
|
+
`),t.length===0)console.log("No instances found."),console.log("\nUse `mixrpay mcp deploy` or `mixrpay skills use` to deploy one.");else for(let n of t)console.log(`${n.toolName}`),console.log(` ID: ${n.id}`),console.log(` Status: ${n.status}`),console.log(` Glama: ${n.glamaNamespace}/${n.glamaSlug}`),n.expiresAt&&console.log(` Expires: ${n.expiresAt.toLocaleString()}`),console.log("");}catch(o){console.error("Failed to list instances:",o instanceof Error?o.message:o),process.exit(1);}}async function ue(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Instance ID required."),console.error(`
|
|
408
|
+
Usage: mixrpay mcp stop <instance_id>`),process.exit(1));try{await(await u(e)).stopJitInstance(o),s?d({instance_id:o,stopped:!0},!0):console.log(`
|
|
409
|
+
Instance ${o} stopped.`);}catch(t){console.error("Failed to stop instance:",t instanceof Error?t.message:t),process.exit(1);}}async function ge(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Instance ID required."),console.error(`
|
|
410
|
+
Usage: mixrpay mcp status <instance_id>`),process.exit(1));try{let n=await(await u(e)).getJitInstance(o);s?d(n,!0):(console.log(`
|
|
411
|
+
MCP Instance: ${n.id}
|
|
412
|
+
`),console.log(`Tool: ${n.toolName}`),console.log(`Status: ${n.status}`),console.log(`Glama: ${n.glamaNamespace}/${n.glamaSlug}`),n.endpointUrl&&console.log(`Endpoint: ${x(n.endpointUrl)}`),n.expiresAt&&console.log(`Expires: ${n.expiresAt.toLocaleString()}`));}catch(t){console.error("Failed to get instance status:",t instanceof Error?t.message:t),process.exit(1);}}async function pe(e){let r=e.json===true;try{let o=(await u(e)).mcp();if(r)d({command:o.command,args:o.args,env:Object.fromEntries(Object.entries(o.env||{}).map(([t,n])=>[t,n?.slice(0,20)+"..."]))},!0);else {console.log(`
|
|
413
|
+
MCP Server Configuration
|
|
414
|
+
`),console.log(`Command: ${o.command} ${o.args?.join(" ")||""}`),console.log(`
|
|
415
|
+
Environment variables (masked):`);for(let[t,n]of Object.entries(o.env||{}))console.log(` ${t}=${n?.slice(0,16)}...`);console.log(`
|
|
416
|
+
Use this config to spawn the MCP server subprocess.`);}}catch(s){console.error("Failed to get MCP config:",s instanceof Error?s.message:s),process.exit(1);}}async function me(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
417
|
+
mixrpay mcp - Manage MCP (Model Context Protocol) servers
|
|
418
|
+
|
|
419
|
+
USAGE
|
|
420
|
+
mixrpay mcp [subcommand] [options]
|
|
421
|
+
|
|
422
|
+
SUBCOMMANDS
|
|
423
|
+
list List available MCP tools
|
|
424
|
+
call <tool> '{}' Call an MCP tool
|
|
425
|
+
deploy <id> Deploy a JIT MCP server (advanced)
|
|
426
|
+
instances List deployed instances
|
|
427
|
+
stop <id> Stop an instance
|
|
428
|
+
status <id> Get instance status
|
|
429
|
+
config Show MCP subprocess config
|
|
430
|
+
|
|
431
|
+
DEPLOY OPTIONS
|
|
432
|
+
--namespace, --ns Glama namespace (required)
|
|
433
|
+
--slug Glama slug (required)
|
|
434
|
+
--name, -n Tool name (required)
|
|
435
|
+
--description Tool description
|
|
436
|
+
--ttl TTL in hours (default: 24)
|
|
437
|
+
--env Environment vars as JSON
|
|
438
|
+
|
|
439
|
+
OTHER OPTIONS
|
|
440
|
+
--status Filter instances by status
|
|
441
|
+
--json Output as JSON
|
|
442
|
+
--help, -h Show this help message
|
|
443
|
+
|
|
444
|
+
DESCRIPTION
|
|
445
|
+
MCP allows you to deploy and use Model Context Protocol servers
|
|
446
|
+
on-demand. For pre-configured integrations, use 'mixrpay skills' instead.
|
|
447
|
+
|
|
448
|
+
EXAMPLES
|
|
449
|
+
mixrpay mcp list
|
|
450
|
+
mixrpay mcp call firecrawl-search '{"query":"AI news"}'
|
|
451
|
+
mixrpay mcp instances
|
|
452
|
+
mixrpay mcp status inst_abc123
|
|
453
|
+
mixrpay mcp stop inst_abc123
|
|
454
|
+
|
|
455
|
+
# Deploy custom MCP (advanced - prefer 'skills' for common integrations)
|
|
456
|
+
mixrpay mcp deploy notion-mcp --namespace notion --slug notion-mcp --name "Notion"
|
|
457
|
+
`);return}switch(s){case "call":await le(e,r.slice(1));break;case "deploy":await ce(e,r.slice(1));break;case "instances":await de(e);break;case "stop":await ue(e,r.slice(1));break;case "status":await ge(e,r.slice(1));break;case "config":await pe(e);break;case "list":case void 0:default:await ie(e);break}}async function ye(e){let r=e.json===true;try{let o=await(await u(e)).listSkills();if(r)d({skills:o},!0);else if(console.log(`
|
|
458
|
+
Available Skills
|
|
459
|
+
`),o.length===0)console.log("No skills available."),console.log("\nUse `mixrpay skills apps` to see connected apps.");else for(let t of o){let n=t.status==="configured"?"ready":t.status;console.log(`${t.name} [${n}]`),console.log(` ID: ${t.id}`),console.log(` Category: ${t.categoryName}`),t.description&&console.log(` ${t.description}`),t.available||console.log(" (not available)"),console.log("");}}catch(s){console.error("Failed to list skills:",s instanceof Error?s.message:s),process.exit(1);}}async function he(e,r){let s=e.json===true,o=r[0]||e.id,t=e.ttl;o||(console.error("Error: Skill ID required."),console.error(`
|
|
460
|
+
Usage: mixrpay skills use <skill_id>`),console.error(`
|
|
461
|
+
This deploys a JIT MCP server for the skill.`),process.exit(1));let n=t?parseInt(t,10):void 0;try{let a=await u(e);s||console.log(`
|
|
462
|
+
Deploying skill: ${o}...
|
|
463
|
+
`);let i=await a.useSkill(o,{ttlHours:n});s?d(i,!0):(console.log(`Skill Deployed!
|
|
464
|
+
`),console.log(`Skill ID: ${i.skillId}`),console.log(`Instance ID: ${i.instanceId}`),console.log(`Endpoint: ${x(i.endpoint)}`),console.log(`Tools: ${i.tools.join(", ")}`),console.log(`Expires: ${i.expiresAt.toLocaleString()}`));}catch(a){console.error("Failed to use skill:",a instanceof Error?a.message:a),process.exit(1);}}async function fe(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Skill ID required."),console.error(`
|
|
465
|
+
Usage: mixrpay skills status <skill_id>`),process.exit(1));try{let n=await(await u(e)).getSkillStatus(o);s?d(n,!0):(console.log(`
|
|
466
|
+
Skill Status: ${n.skillId}
|
|
467
|
+
`),console.log(`Status: ${n.status}`),n.configuredVars.length>0&&console.log(`Configured vars: ${n.configuredVars.join(", ")}`),n.lastUsedAt&&console.log(`Last used: ${n.lastUsedAt.toLocaleString()}`),n.errorMessage&&console.log(`Error: ${n.errorMessage}`),n.status==="not_configured"&&(console.log(`
|
|
468
|
+
This skill needs configuration.`),console.log("Visit the dashboard to configure it.")));}catch(t){console.error("Failed to get skill status:",t instanceof Error?t.message:t),process.exit(1);}}async function we(e){let r=e.json===true;try{let o=await(await u(e)).getConnectedApps();if(r)d(o,!0);else if(console.log(`
|
|
469
|
+
Connected Apps
|
|
470
|
+
`),o.connected.length===0)console.log("No connected apps."),console.log(`
|
|
471
|
+
Visit your dashboard to connect apps.`);else {console.log(`Connected: ${o.connected.join(", ")}
|
|
472
|
+
`);for(let t of o.connections)console.log(`${t.app_name}`),console.log(` App: ${t.app}`),console.log(` Type: ${t.type}`),console.log(` Status: ${t.status}`),t.account_name&&console.log(` Account: ${t.account_name}`),console.log("");}}catch(s){console.error("Failed to get connected apps:",s instanceof Error?s.message:s),process.exit(1);}}async function xe(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
473
|
+
mixrpay skills - Manage connected app skills
|
|
474
|
+
|
|
475
|
+
USAGE
|
|
476
|
+
mixrpay skills [subcommand] [options]
|
|
477
|
+
|
|
478
|
+
SUBCOMMANDS
|
|
479
|
+
list List available skills (default)
|
|
480
|
+
use <id> Use a skill (deploy JIT MCP)
|
|
481
|
+
status <id> Get skill status
|
|
482
|
+
apps List connected apps
|
|
483
|
+
|
|
484
|
+
OPTIONS
|
|
485
|
+
--json Output as JSON
|
|
486
|
+
--help, -h Show this help message
|
|
487
|
+
|
|
488
|
+
DESCRIPTION
|
|
489
|
+
Skills are pre-configured MCP servers for connected apps like
|
|
490
|
+
GitHub, Slack, and Notion. They require OAuth setup in your dashboard.
|
|
491
|
+
|
|
492
|
+
EXAMPLES
|
|
493
|
+
mixrpay skills
|
|
494
|
+
mixrpay skills apps
|
|
495
|
+
mixrpay skills use github
|
|
496
|
+
mixrpay skills status github
|
|
497
|
+
`);return}switch(s){case "use":await he(e,r.slice(1));break;case "status":await fe(e,r.slice(1));break;case "apps":await we(e);break;case "list":case void 0:default:await ye(e);break}}async function Se(e){let r=e.json===true,s=e.name||e.n,o=e.prompt||e.p,t=e.system||e.s,n=e.model||e.m,a=e.budget||e.b,i=e.ttl,c=e.iterations,l=e.tools||e.t,g=e.auto===true;(!s||!o||!a)&&(console.error("Error: Name, prompt, and budget are required."),console.error(`
|
|
498
|
+
Usage: mixrpay agent deploy --name "Agent" --prompt "Task..." --budget 5.00`),process.exit(1));let m=parseFloat(a);(isNaN(m)||m<=0)&&(console.error("Error: Invalid budget. Must be a positive number."),process.exit(1));let p=i?parseInt(i,10):void 0,b=c?parseInt(c,10):void 0,y=l?l.split(",").map(S=>S.trim()):void 0;try{let S=await u(e);r||console.log(`
|
|
499
|
+
Deploying task agent: ${s}...
|
|
500
|
+
`);let A=await S.deployTaskAgent({name:s,prompt:o,systemPrompt:t,model:n,budgetUsd:m,ttlHours:p,maxIterations:b,tools:y,autoRun:g}),h=A.instance;r?d({instance_id:h.id,name:h.name,status:h.status,budget_usd:h.budgetUsd,idempotent:A.idempotent},!0):(console.log(`Task Agent Deployed!
|
|
501
|
+
`),console.log(`Instance ID: ${h.id}`),console.log(`Name: ${h.name}`),console.log(`Status: ${h.status}`),console.log(`Budget: $${h.budgetUsd.toFixed(2)}`),A.idempotent&&console.log("(Idempotent return - existing instance)"),console.log(`
|
|
502
|
+
Commands:`),console.log(` mixrpay agent trigger ${h.id} # Start the agent`),console.log(` mixrpay agent status ${h.id} # Check status`),console.log(` mixrpay agent wait ${h.id} # Wait for completion`));}catch(S){console.error("Failed to deploy agent:",S instanceof Error?S.message:S),process.exit(1);}}async function be(e){let r=e.json===true,s=e.status,o=e.limit;try{let n=await(await u(e)).listTaskAgents({status:s,limit:o?parseInt(o,10):void 0});if(r)d(n,!0);else {console.log(`
|
|
503
|
+
Task Agents
|
|
504
|
+
`);let a=n.taskAgents||[];if(a.length===0)console.log("No task agents found."),console.log("\nUse `mixrpay agent deploy` to create one.");else {for(let i of a){let c=i.budget?.spentUsd??0,l=i.budget?.totalUsd??0,g=i.iterations?.current??0;console.log(`${i.name||i.id}`),console.log(` ID: ${i.id}`),console.log(` Status: ${i.status}`),console.log(` Budget: $${c.toFixed(2)} / $${l.toFixed(2)}`),console.log(` Iterations: ${g}/${i.iterations?.max??"N/A"}`),console.log("");}console.log(`Total: ${n.pagination.total}`),n.stats&&console.log(`Active: ${n.stats.active}, Completed: ${n.stats.completed}, Failed: ${n.stats.failed}`);}}}catch(t){console.error("Failed to list agents:",t instanceof Error?t.message:t),process.exit(1);}}async function ke(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Instance ID required."),console.error(`
|
|
505
|
+
Usage: mixrpay agent status <instance_id>`),process.exit(1));try{let n=await(await u(e)).getTaskAgentStatus(o);s?d(n,!0):(console.log(`
|
|
506
|
+
Task Agent: ${n.id}
|
|
507
|
+
`),console.log(`Name: ${n.name}`),console.log(`Model: ${n.model}`),console.log(`Status: ${n.status}`),console.log(`Iterations: ${n.iterations?.current??0}/${n.iterations?.max??"N/A"}`),console.log(`Budget: $${(n.budget?.spentUsd??0).toFixed(2)} / $${(n.budget?.totalUsd??0).toFixed(2)}`),n.tools?.length&&console.log(`Tools: ${n.tools.join(", ")}`));}catch(t){console.error("Failed to get agent status:",t instanceof Error?t.message:t),process.exit(1);}}async function ve(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Instance ID required."),console.error(`
|
|
508
|
+
Usage: mixrpay agent trigger <instance_id>`),process.exit(1));try{let n=await(await u(e)).triggerTaskAgent(o);s?d({instance_id:o,...n},!0):(console.log(`
|
|
509
|
+
Agent ${o} triggered.`),console.log(`Status: ${n.status}`),console.log("\nUse `mixrpay agent wait` to wait for completion."));}catch(t){console.error("Failed to trigger agent:",t instanceof Error?t.message:t),process.exit(1);}}async function $e(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Instance ID required."),console.error(`
|
|
510
|
+
Usage: mixrpay agent cancel <instance_id>`),process.exit(1));try{let n=await(await u(e)).cancelTaskAgent(o);s?d({instance_id:o,...n},!0):(console.log(`
|
|
511
|
+
Agent ${o} cancelled.`),console.log(`Status: ${n.status}`));}catch(t){console.error("Failed to cancel agent:",t instanceof Error?t.message:t),process.exit(1);}}async function Ae(e,r){let s=e.json===true,o=r[0]||e.id,t=e.timeout;o||(console.error("Error: Instance ID required."),console.error(`
|
|
512
|
+
Usage: mixrpay agent wait <instance_id>`),process.exit(1));let n=t?parseInt(t,10)*1e3:void 0;try{let a=await u(e);s||console.log(`
|
|
513
|
+
Waiting for agent ${o}...`);let i=await a.waitForTaskAgent(o,{timeoutMs:n});s?d(i,!0):(console.log(`
|
|
514
|
+
Agent completed!`),console.log(`Status: ${i.status}`),console.log(`Iterations: ${i.iterations}`),console.log(`Tool calls: ${i.toolCalls}`),console.log(`Cost: $${(i.spentUsd||0).toFixed(4)}`),i.result&&(console.log(`
|
|
515
|
+
Result:`),console.log(i.result)),i.error&&console.log(`
|
|
516
|
+
Error:`,i.error));}catch(a){console.error("Wait failed:",a instanceof Error?a.message:a),process.exit(1);}}async function Ee(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
517
|
+
mixrpay agent - Manage task agents
|
|
518
|
+
|
|
519
|
+
USAGE
|
|
520
|
+
mixrpay agent [subcommand] [options]
|
|
521
|
+
|
|
522
|
+
SUBCOMMANDS
|
|
523
|
+
deploy Deploy a new task agent
|
|
524
|
+
list List task agents (default)
|
|
525
|
+
status <id> Get agent status
|
|
526
|
+
trigger <id> Trigger agent execution
|
|
527
|
+
cancel <id> Cancel agent
|
|
528
|
+
wait <id> Wait for agent completion
|
|
529
|
+
|
|
530
|
+
DEPLOY OPTIONS
|
|
531
|
+
--name, -n Agent name (required)
|
|
532
|
+
--prompt, -p Task prompt (required)
|
|
533
|
+
--budget, -b Budget in USD (required)
|
|
534
|
+
--system, -s System prompt
|
|
535
|
+
--model, -m Model (default: claude-sonnet-4-5)
|
|
536
|
+
--ttl TTL in hours (default: 24)
|
|
537
|
+
--iterations Max iterations (default: 10)
|
|
538
|
+
--tools, -t Comma-separated tool list
|
|
539
|
+
--auto Auto-run after deploy
|
|
540
|
+
|
|
541
|
+
OPTIONS
|
|
542
|
+
--status Filter by status (for list)
|
|
543
|
+
--limit Limit results (for list)
|
|
544
|
+
--timeout Wait timeout in seconds
|
|
545
|
+
--json Output as JSON
|
|
546
|
+
--help, -h Show this help message
|
|
547
|
+
|
|
548
|
+
EXAMPLES
|
|
549
|
+
mixrpay agent deploy --name "Researcher" --prompt "Find AI papers" --budget 5.00
|
|
550
|
+
mixrpay agent list
|
|
551
|
+
mixrpay agent status inst_abc123
|
|
552
|
+
mixrpay agent trigger inst_abc123
|
|
553
|
+
mixrpay agent wait inst_abc123
|
|
554
|
+
`);return}switch(s){case "deploy":await Se(e);break;case "status":await ke(e,r.slice(1));break;case "trigger":await ve(e,r.slice(1));break;case "cancel":await $e(e,r.slice(1));break;case "wait":await Ae(e,r.slice(1));break;case "list":case void 0:default:await be(e);break}}async function Ie(e,r){if(e.help||e.h||r.length===0){console.log(`
|
|
555
|
+
mixrpay tool - Call MixrPay gateway tools
|
|
556
|
+
|
|
557
|
+
USAGE
|
|
558
|
+
mixrpay tool <provider> <tool_name> '<json_arguments>'
|
|
559
|
+
mixrpay tool list
|
|
560
|
+
|
|
561
|
+
For full documentation, run: npx mixrpay-tool --help
|
|
562
|
+
|
|
563
|
+
QUICK EXAMPLES
|
|
564
|
+
# Web search
|
|
565
|
+
mixrpay tool firecrawl firecrawl-search '{"query":"AI agents"}'
|
|
566
|
+
|
|
567
|
+
# Brave search
|
|
568
|
+
mixrpay tool brave brave-search '{"q":"latest news"}'
|
|
569
|
+
|
|
570
|
+
# Send email
|
|
571
|
+
mixrpay tool agentmail agentmail-send '{"inbox_id":"...","to":["..."],"subject":"...","text":"..."}'
|
|
572
|
+
`);return}let{spawn:s}=await import('child_process'),o=r;e.json&&o.push("--json"),e["use-x402"]&&o.push("--use-x402"),e.baseUrl&&o.push("--baseUrl",e.baseUrl),s(process.execPath,[new URL("./tool-cli.js",import.meta.url).pathname,...o],{stdio:"inherit"}).on("exit",n=>{process.exit(n||0);});}async function Ue(e,r){if(e.help||e.h||r.length===0){console.log(`
|
|
573
|
+
mixrpay search - Quick web search
|
|
574
|
+
|
|
575
|
+
USAGE
|
|
576
|
+
mixrpay search "<query>"
|
|
577
|
+
|
|
578
|
+
OPTIONS
|
|
579
|
+
--provider, -p Search provider: firecrawl, exa, tavily (default: firecrawl)
|
|
580
|
+
--json Output raw JSON
|
|
581
|
+
--help, -h Show this help message
|
|
582
|
+
|
|
583
|
+
EXAMPLES
|
|
584
|
+
mixrpay search "AI agent frameworks 2026"
|
|
585
|
+
mixrpay search "best DeFi yields" --provider exa
|
|
586
|
+
`);return}let s=r.join(" "),o=e.provider||e.p||"firecrawl",t=e.json===true,n=await Oe();n||(console.error("Error: No valid agent token found."),console.error(`
|
|
587
|
+
The search command requires an agent token (agt_live_* or ac_live_*).`),console.error("Session keys (sk_live_*) from `mixrpay login` are not supported for tool calls."),console.error(`
|
|
588
|
+
To fix this:`),console.error(' mixrpay register --mode invite --invite-code <code> --name "My Agent"'),process.exit(1));let a=o==="exa"?"exa-search":o==="tavily"?"tavily-search":"firecrawl-search";console.log(`Searching with ${o}...
|
|
589
|
+
`);let i=new AbortController,c=setTimeout(()=>i.abort(),3e4);try{let l=await fetch(`${n.baseUrl}/api/v2/agent/call-tool`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.token}`},body:JSON.stringify({provider:o,tool_name:a,arguments:{query:s}}),signal:i.signal});clearTimeout(c);let g=await l.json().catch(()=>({error:"Invalid response from server"}));l.ok||(console.error(`Search failed: ${g.error||"Unknown error"}`),process.exit(1)),t||(g.charged_usd&&console.log(`Cost: $${g.charged_usd.toFixed(4)}`),console.log(`Latency: ${g.latency_ms}ms
|
|
590
|
+
`),console.log("Results:")),console.log(JSON.stringify(g.data,null,2));}catch(l){clearTimeout(c),l instanceof Error&&l.name==="AbortError"?console.error("Search timed out after 30 seconds."):console.error("Search failed:",l instanceof Error?l.message:l),process.exit(1);}}async function Oe(){let e=s=>s.startsWith("agt_live_")||s.startsWith("ac_live_")||s.startsWith("agt_test_")||s.startsWith("ac_test_");if(process.env.MIXRPAY_AGENT_TOKEN){let s=process.env.MIXRPAY_AGENT_TOKEN;if(e(s))return {token:s,baseUrl:process.env.MIXRPAY_BASE_URL||c}}let r=b();if(r.success&&r.credentials){let s=r.credentials;if(s.apiToken&&e(s.apiToken))return {token:s.apiToken,baseUrl:s.baseUrl||c}}return null}async function Te(e){let r=e.json===true,s=e.title||e.t,o=e.description||e.d,t=e.budget||e.b,n=e.expires,a=e.category,i=e.deliverables?.split(",").map(l=>l.trim());(!s||!o||!t)&&(console.error("Error: Title, description, and budget are required."),console.error(`
|
|
591
|
+
Usage: mixrpay task create --title "Task" --description "..." --budget 10.00`),process.exit(1));let c=parseFloat(t);(isNaN(c)||c<=0)&&(console.error("Error: Invalid budget."),process.exit(1));try{let g=await(await u(e)).createTask({title:s,description:o,budgetUsd:c,expiresInDays:n?parseInt(n,10):void 0,category:a,deliverables:i});r?d(g,!0):(console.log(`
|
|
592
|
+
Task Created!
|
|
593
|
+
`),console.log(`Task ID: ${g.id}`),console.log(`Title: ${g.title}`),console.log(`Budget: $${g.budgetUsd.toFixed(2)}`),console.log(`Status: ${g.status}`),g.expiresAt&&console.log(`Expires: ${new Date(g.expiresAt).toLocaleDateString()}`));}catch(l){console.error("Failed to create task:",l instanceof Error?l.message:l),process.exit(1);}}async function Pe(e){let r=e.json===true,s=e.status,o=e.limit;try{let n=await(await u(e)).listTasks({status:s,limit:o?parseInt(o,10):void 0});if(r)d(n,!0);else {console.log(`
|
|
594
|
+
Task Board
|
|
595
|
+
`);let a=n.tasks||[];if(a.length===0)console.log("No tasks found.");else {for(let i of a)console.log(`${i.title}`),console.log(` ID: ${i.taskId}`),console.log(` Status: ${i.status}`),console.log(` Budget: $${(i.budgetUsd||0).toFixed(2)}`),console.log("");console.log(`Total: ${n.total||a.length}`);}}}catch(t){console.error("Failed to list tasks:",t instanceof Error?t.message:t),process.exit(1);}}async function Ce(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Task ID required."),process.exit(1));try{let n=await(await u(e)).getTask(o);s?d(n,!0):(console.log(`
|
|
596
|
+
Task: ${n.title}
|
|
597
|
+
`),console.log(`ID: ${n.taskId}`),console.log(`Status: ${n.status}`),console.log(`Budget: $${(n.budgetUsd||0).toFixed(2)}`),console.log(`Description: ${n.description}`),n.deadline&&console.log(`Deadline: ${new Date(n.deadline).toLocaleDateString()}`),n.assignee&&console.log(`Assignee: ${n.assignee}`));}catch(t){console.error("Failed to get task:",t instanceof Error?t.message:t),process.exit(1);}}async function Ne(e){let r=e.json===true,s=e.role,o=e.status;try{let n=await(await u(e)).getMyTasks({role:s,status:o});if(r)d(n,!0);else if(console.log(`
|
|
598
|
+
My Tasks
|
|
599
|
+
`),n.tasks.length===0)console.log("No assigned tasks."),console.log("\nUse `mixrpay task request <id>` to request a task.");else {for(let a of n.tasks)console.log(`${a.title}`),console.log(` ID: ${a.id}`),console.log(` Status: ${a.status}`),console.log(` Budget: $${(a.budgetUsd||0).toFixed(2)}`),console.log("");console.log(`Total: ${n.pagination.total}`);}}catch(t){console.error("Failed to get my tasks:",t instanceof Error?t.message:t),process.exit(1);}}async function Re(e,r){let s=e.json===true,o=r[0]||e.id,t=e.message;o||(console.error("Error: Task ID required."),process.exit(1));try{let a=await(await u(e)).requestTask(o,t);s?d(a,!0):(console.log(`
|
|
600
|
+
Task ${o} requested.`),console.log(`Request ID: ${a.id}`),console.log(`Status: ${a.status}`));}catch(n){console.error("Failed to request task:",n instanceof Error?n.message:n),process.exit(1);}}async function _e(e,r){let s=e.json===true,o=r[0]||e.id,t=e.text||e.output||e.o,n=e.url;(!o||!t&&!n)&&(console.error("Error: Task ID and output (--text or --url) are required."),console.error(`
|
|
601
|
+
Usage: mixrpay task submit <id> --text "Result..."`),console.error(' mixrpay task submit <id> --url "https://..."'),process.exit(1));try{await(await u(e)).submitTask(o,{text:t,url:n}),s?d({task_id:o,submitted:!0},!0):console.log(`
|
|
602
|
+
Task ${o} submitted successfully.`);}catch(a){console.error("Failed to submit task:",a instanceof Error?a.message:a),process.exit(1);}}async function je(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Task ID required."),process.exit(1));try{let n=await(await u(e)).approveTask(o);s?d(n,!0):(console.log(`
|
|
603
|
+
Task ${o} approved.`),console.log(`Status: ${n.task.status}`),n.payout&&(console.log(`Payout: $${n.payout.amountUsd.toFixed(2)} (${n.payout.status})`),n.payout.txHash&&console.log(`TX: ${n.payout.txHash}`)));}catch(t){console.error("Failed to approve task:",t instanceof Error?t.message:t),process.exit(1);}}async function De(e,r){let s=e.json===true,o=r[0]||e.id,t=e.feedback||e.reason||e.r;o||(console.error("Error: Task ID required."),process.exit(1));try{await(await u(e)).rejectTaskSubmission(o,t),s?d({task_id:o,rejected:!0},!0):(console.log(`
|
|
604
|
+
Task ${o} submission rejected.`),t&&console.log(`Feedback: ${t}`));}catch(n){console.error("Failed to reject task:",n instanceof Error?n.message:n),process.exit(1);}}async function Fe(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Task ID required."),process.exit(1));try{let n=await(await u(e)).cancelTask(o);s?d(n,!0):console.log(`
|
|
605
|
+
Task ${o} cancelled.`);}catch(t){console.error("Failed to cancel task:",t instanceof Error?t.message:t),process.exit(1);}}async function Me(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
606
|
+
mixrpay task - Manage the task board
|
|
607
|
+
|
|
608
|
+
USAGE
|
|
609
|
+
mixrpay task [subcommand] [options]
|
|
610
|
+
|
|
611
|
+
SUBCOMMANDS
|
|
612
|
+
create Create a new task
|
|
613
|
+
list List tasks (default)
|
|
614
|
+
get <id> Get task details
|
|
615
|
+
mine Show my assigned tasks
|
|
616
|
+
request <id> Request to work on a task
|
|
617
|
+
submit <id> Submit task output
|
|
618
|
+
approve <id> Approve task submission
|
|
619
|
+
reject <id> Reject task submission
|
|
620
|
+
cancel <id> Cancel a task
|
|
621
|
+
|
|
622
|
+
CREATE OPTIONS
|
|
623
|
+
--title, -t Task title (required)
|
|
624
|
+
--description, -d Task description (required)
|
|
625
|
+
--budget, -b Budget in USD (required)
|
|
626
|
+
--deadline Deadline (ISO date)
|
|
627
|
+
--skills Required skills (comma-separated)
|
|
628
|
+
|
|
629
|
+
SUBMIT OPTIONS
|
|
630
|
+
--output, -o Output/result (required)
|
|
631
|
+
--artifacts Artifact URLs (comma-separated)
|
|
632
|
+
|
|
633
|
+
OPTIONS
|
|
634
|
+
--status Filter by status
|
|
635
|
+
--limit Limit results
|
|
636
|
+
--message Optional message (for request)
|
|
637
|
+
--feedback Optional feedback (for approve/reject)
|
|
638
|
+
--reason, -r Rejection reason (required for reject)
|
|
639
|
+
--json Output as JSON
|
|
640
|
+
--help, -h Show this help message
|
|
641
|
+
|
|
642
|
+
EXAMPLES
|
|
643
|
+
mixrpay task create --title "Research" --description "Find papers" --budget 5.00
|
|
644
|
+
mixrpay task list --status open
|
|
645
|
+
mixrpay task request task_abc123
|
|
646
|
+
mixrpay task submit task_abc123 --output "Found 10 papers..."
|
|
647
|
+
mixrpay task approve task_abc123
|
|
648
|
+
`);return}switch(s){case "create":await Te(e);break;case "get":await Ce(e,r.slice(1));break;case "mine":await Ne(e);break;case "request":await Re(e,r.slice(1));break;case "submit":await _e(e,r.slice(1));break;case "approve":await je(e,r.slice(1));break;case "reject":await De(e,r.slice(1));break;case "cancel":await Fe(e,r.slice(1));break;case "list":case void 0:default:await Pe(e);break}}async function Le(e){let r=e.json===true;try{let o=await(await u(e)).getBalances();if(r)d(o,!0);else {console.log(`
|
|
649
|
+
Token Balances
|
|
650
|
+
`),console.log(`Wallet: ${o.wallet_address}`),console.log(`Chain: ${o.chain} (${o.chain_id})
|
|
651
|
+
`);let t=Object.entries(o.balances);if(t.length===0)console.log("No token balances found.");else for(let[n,a]of t)console.log(`${n}: ${a.balance}`);o.delegation&&(console.log(`
|
|
652
|
+
Delegation Budget:`),console.log(` Total: $${o.delegation.budget_total_usd}`),console.log(` Spent: $${o.delegation.budget_spent_usd}`),console.log(` Remaining: $${o.delegation.budget_remaining_usd}`));}}catch(s){console.error("Failed to get balances:",s instanceof Error?s.message:s),process.exit(1);}}async function qe(e,r){let s=e.json===true,o=r[0]||e.to,t=r[1]||e.amount,n=e.token||"USDC";(!o||!t)&&(console.error("Error: Recipient and amount required."),console.error(`
|
|
653
|
+
Usage: mixrpay defi transfer <to> <amount> --token USDC`),process.exit(1));let a=parseFloat(t);(isNaN(a)||a<=0)&&(console.error("Error: Invalid amount."),process.exit(1));try{let i=await u(e);s||console.log(`
|
|
654
|
+
Transferring ${a} ${n} to ${o.slice(0,10)}...`);let c=await i.transfer(o,a.toString(),n);s?d(c,!0):(console.log(`Transfer complete!
|
|
655
|
+
`),console.log(`TX Hash: ${c.tx_hash}`),console.log(`Amount: ${a} ${n}`));}catch(i){console.error("Transfer failed:",i instanceof Error?i.message:i),process.exit(1);}}async function Be(e){let r=e.json===true,s=e.sell||e.from||e.f,o=e.buy||e.to||e.t,t=e.amount||e.a,n=e.slippage;(!s||!o||!t)&&(console.error("Error: Sell token, buy token, and amount required."),console.error(`
|
|
656
|
+
Usage: mixrpay defi swap --sell ETH --buy USDC --amount 0.1`),process.exit(1));try{let a=await u(e);r||console.log(`
|
|
657
|
+
Swapping ${t} ${s} \u2192 ${o}...`);let i=n?parseInt(n,10):void 0,c=await a.swap(s,o,t,i);r?d(c,!0):(console.log(`Swap complete!
|
|
658
|
+
`),console.log(`TX Hash: ${c.tx_hash}`),console.log(`Sold: ${c.sell_amount} ${s}`),console.log(`Received: ${c.buy_amount} ${o}`));}catch(a){console.error("Swap failed:",a instanceof Error?a.message:a),process.exit(1);}}async function We(e){let r=e.json===true,s=e.token||"USDC",o=e.amount||e.a,t=e.to||e.dest||e.t,n=e.address;(!o||!t)&&(console.error("Error: Amount and destination chain required."),console.error(`
|
|
659
|
+
Usage: mixrpay defi bridge --amount 100 --to arbitrum`),console.error(`
|
|
660
|
+
Note: Bridges FROM Base to the destination chain.`),process.exit(1));try{let a=await u(e);r||console.log(`
|
|
661
|
+
Bridging ${o} ${s} from Base \u2192 ${t}...`);let i=await a.bridge(s,o,t,n?{destAddress:n}:void 0);r?d(i,!0):(console.log(`Bridge initiated!
|
|
662
|
+
`),console.log(`Order ID: ${i.order_id}`),console.log(`TX Hash: ${i.tx_hash}`),console.log(`Estimated receive: ${i.estimated_receive}`),console.log("\nUse `mixrpay defi bridge-status <order_id>` to check status."));}catch(a){console.error("Bridge failed:",a instanceof Error?a.message:a),process.exit(1);}}async function Ke(e){let r=e.json===true;try{let o=(await u(e)).getPaymentHistory();if(r)d({payments:o,note:"In-memory history only (session-scoped)"},!0);else if(console.log(`
|
|
663
|
+
Payment History (Current Session)
|
|
664
|
+
`),o.length===0)console.log("No payments in current session."),console.log(`
|
|
665
|
+
Note: Only session-scoped history is available.`),console.log("For full DeFi history, check your wallet on a block explorer.");else for(let t of o){let n=new Date(t.timestamp).toLocaleDateString(),a=t.type||"payment";console.log(`${n} | ${a.padEnd(10)} | $${t.amountUsd.toFixed(4)}`),t.provider&&console.log(` Provider: ${t.provider}`);}}catch(s){console.error("Failed to get history:",s instanceof Error?s.message:s),process.exit(1);}}async function Je(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
666
|
+
mixrpay defi - DeFi operations
|
|
667
|
+
|
|
668
|
+
USAGE
|
|
669
|
+
mixrpay defi [subcommand] [options]
|
|
670
|
+
|
|
671
|
+
SUBCOMMANDS
|
|
672
|
+
balances Show token balances (default)
|
|
673
|
+
transfer <to> <amount> Transfer tokens
|
|
674
|
+
swap Swap tokens
|
|
675
|
+
bridge Bridge tokens between chains
|
|
676
|
+
history Transaction history
|
|
677
|
+
|
|
678
|
+
TRANSFER OPTIONS
|
|
679
|
+
--token Token symbol (default: USDC)
|
|
680
|
+
|
|
681
|
+
SWAP OPTIONS
|
|
682
|
+
--sell Token to sell (required)
|
|
683
|
+
--buy Token to buy (required)
|
|
684
|
+
--amount, -a Amount to sell (required)
|
|
685
|
+
--slippage Slippage in bps (default: 100)
|
|
686
|
+
|
|
687
|
+
BRIDGE OPTIONS
|
|
688
|
+
--token Token symbol (default: USDC)
|
|
689
|
+
--amount, -a Amount to bridge (required)
|
|
690
|
+
--to, --dest Destination chain (required, e.g., arbitrum, ethereum)
|
|
691
|
+
--address Custom destination address (optional)
|
|
692
|
+
|
|
693
|
+
OPTIONS
|
|
694
|
+
--json Output as JSON
|
|
695
|
+
--help, -h Show this help message
|
|
696
|
+
|
|
697
|
+
NOTE
|
|
698
|
+
Bridge always moves tokens FROM Base to the destination chain.
|
|
699
|
+
|
|
700
|
+
EXAMPLES
|
|
701
|
+
mixrpay defi balances
|
|
702
|
+
mixrpay defi transfer 0x123... 10.00 --token USDC
|
|
703
|
+
mixrpay defi swap --sell ETH --buy USDC --amount 0.1
|
|
704
|
+
mixrpay defi bridge --amount 100 --to arbitrum
|
|
705
|
+
`);return}switch(s){case "transfer":await qe(e,r.slice(1));break;case "swap":await Be(e);break;case "bridge":await We(e);break;case "history":await Ke(e);break;case "balances":case void 0:default:await Le(e);break}}async function Ge(e){let r=e.json===true,s=e.title||e.name||e.n,o=e.steps||e.s,t=e.budget||e.b,n=e.description,a=e.approval===true;(!s||!o)&&(console.error("Error: Title and steps are required."),console.error(`
|
|
706
|
+
Usage: mixrpay plan submit --title "Plan" --steps '[...]'`),process.exit(1));let i=P(o,"Invalid JSON for steps"),c=t?parseFloat(t):void 0;try{let g=await(await u(e)).submitPlan({title:s,description:n,steps:i,totalEstimatedCostUsd:c,requiresApproval:a});r?d(g,!0):(console.log(`
|
|
707
|
+
Plan Submitted!
|
|
708
|
+
`),console.log(`Plan ID: ${g.planId}`),console.log(`Status: ${g.status}`),g.approvalUrl&&console.log(`Approval URL: ${g.approvalUrl}`));}catch(l){console.error("Failed to submit plan:",l instanceof Error?l.message:l),process.exit(1);}}async function Xe(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Plan ID required."),process.exit(1));try{let n=await(await u(e)).getPlanStatus(o);if(s)d(n,!0);else {let a=n.steps?.filter(c=>c.status==="completed").length||0,i=n.steps?.length||0;if(console.log(`
|
|
709
|
+
Plan: ${n.title||o}
|
|
710
|
+
`),console.log(`Status: ${n.status}`),console.log(`Progress: ${a}/${i} steps`),n.totalEstimatedCostUsd&&console.log(`Estimated cost: $${n.totalEstimatedCostUsd.toFixed(2)}`),n.steps&&n.steps.length>0){console.log(`
|
|
711
|
+
Steps:`);for(let c of n.steps){let l=c.status==="completed"?"\u2713":c.status==="running"?"\u2192":"\u25CB";console.log(` ${l} ${c.action} (${c.status})`);}}}}catch(t){console.error("Failed to get plan status:",t instanceof Error?t.message:t),process.exit(1);}}async function He(e){let r=e.json===true,s=e.status;try{let t=await(await u(e)).listPlans({status:s});if(r)d(t,!0);else {console.log(`
|
|
712
|
+
Plans
|
|
713
|
+
`);let n=t.plans||[];if(n.length===0)console.log("No plans found.");else {for(let a of n)console.log(`${a.title}`),console.log(` ID: ${a.planId}`),console.log(` Status: ${a.status}`),console.log("");console.log(`Total: ${t.total||n.length}`);}}}catch(o){console.error("Failed to list plans:",o instanceof Error?o.message:o),process.exit(1);}}async function Ye(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Plan ID required."),process.exit(1));try{let t=await u(e);s||console.log(`
|
|
714
|
+
Executing plan ${o}...`);let n=await t.executePlan(o);s?d(n,!0):(console.log(`Plan execution started!
|
|
715
|
+
`),console.log(`Status: ${n.status}`),console.log("\nUse `mixrpay plan wait` to wait for completion."));}catch(t){console.error("Failed to execute plan:",t instanceof Error?t.message:t),process.exit(1);}}async function Ve(e,r){let s=e.json===true,o=r[0]||e.id,t=e.timeout;o||(console.error("Error: Plan ID required."),process.exit(1));let n=t?parseInt(t,10)*1e3:void 0;try{let a=await u(e);s||console.log(`
|
|
716
|
+
Waiting for plan ${o}...`);let i=await a.waitForPlanCompletion(o,{timeoutMs:n});if(s)d(i,!0);else {let c=i.steps?.filter(g=>g.status==="completed").length||0,l=i.steps?.length||0;console.log(`
|
|
717
|
+
Plan completed!
|
|
718
|
+
`),console.log(`Status: ${i.status}`),console.log(`Steps: ${c}/${l}`);}}catch(a){console.error("Wait failed:",a instanceof Error?a.message:a),process.exit(1);}}async function Qe(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
719
|
+
mixrpay plan - Manage multi-step plans
|
|
720
|
+
|
|
721
|
+
USAGE
|
|
722
|
+
mixrpay plan [subcommand] [options]
|
|
723
|
+
|
|
724
|
+
SUBCOMMANDS
|
|
725
|
+
submit Submit a new plan
|
|
726
|
+
list List plans (default)
|
|
727
|
+
status <id> Get plan status
|
|
728
|
+
execute <id> Execute a plan
|
|
729
|
+
wait <id> Wait for plan completion
|
|
730
|
+
|
|
731
|
+
SUBMIT OPTIONS
|
|
732
|
+
--name, -n Plan name (required)
|
|
733
|
+
--steps, -s Steps as JSON array (required)
|
|
734
|
+
--budget, -b Budget in USD
|
|
735
|
+
--description Plan description
|
|
736
|
+
|
|
737
|
+
OPTIONS
|
|
738
|
+
--status Filter by status
|
|
739
|
+
--timeout Wait timeout in seconds
|
|
740
|
+
--json Output as JSON
|
|
741
|
+
--help, -h Show this help message
|
|
742
|
+
|
|
743
|
+
EXAMPLES
|
|
744
|
+
mixrpay plan submit --name "Research" --steps '[{"action":"search","params":{"q":"AI"}}]'
|
|
745
|
+
mixrpay plan list
|
|
746
|
+
mixrpay plan execute plan_abc123
|
|
747
|
+
mixrpay plan wait plan_abc123
|
|
748
|
+
`);return}switch(s){case "submit":await Ge(e);break;case "status":await Xe(e,r.slice(1));break;case "execute":await Ye(e,r.slice(1));break;case "wait":await Ve(e,r.slice(1));break;case "list":case void 0:default:await He(e);break}}async function ze(e){let r=e.json===true,s=e.action||e.a,o=e.context||e.description||e.d,t=e.payload,n=e.expires;s||(console.error("Error: Action type is required."),console.error(`
|
|
749
|
+
Usage: mixrpay approval request --action "transfer" --context "Send $10 to Bob"`),process.exit(1));let a={};t&&(a=I(t,"Invalid JSON for payload"));try{let c=await(await u(e)).requestApproval({actionType:s,actionPayload:a,context:o,expiresInHours:n?parseInt(n,10):void 0});r?d(c,!0):"autoApproved"in c&&c.autoApproved?(console.log(`
|
|
750
|
+
Auto-approved!
|
|
751
|
+
`),console.log(`Reason: ${c.reason}`)):"id"in c&&(console.log(`
|
|
752
|
+
Approval Request Created!
|
|
753
|
+
`),console.log(`Approval ID: ${c.id}`),console.log(`Status: ${c.status}`),c.expiresAt&&console.log(`Expires: ${c.expiresAt.toLocaleString()}`),console.log(`
|
|
754
|
+
Waiting for human approval...`),console.log(`Use \`mixrpay approval wait ${c.id}\` to wait.`));}catch(i){console.error("Failed to request approval:",i instanceof Error?i.message:i),process.exit(1);}}async function Ze(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Approval ID required."),process.exit(1));try{let n=await(await u(e)).checkApprovalStatus(o);s?d(n,!0):(console.log(`
|
|
755
|
+
Approval: ${n.requestId}
|
|
756
|
+
`),console.log(`Status: ${n.status}`),n.responseNote&&console.log(`Note: ${n.responseNote}`),n.approvalScope&&console.log(`Scope: ${n.approvalScope}`),n.respondedAt&&console.log(`Responded: ${n.respondedAt.toLocaleString()}`));}catch(t){console.error("Failed to get approval status:",t instanceof Error?t.message:t),process.exit(1);}}async function eo(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Approval ID required."),process.exit(1));try{let n=await(await u(e)).checkApprovalStatus(o),a=n.status==="approved";s?d({approval_id:o,status:n.status,approved:a},!0):console.log(`
|
|
757
|
+
Approval ${o}: ${n.status.toUpperCase()}`);}catch(t){console.error("Failed to check approval:",t instanceof Error?t.message:t),process.exit(1);}}async function oo(e,r){let s=e.json===true,o=r[0]||e.id,t=e.timeout;o||(console.error("Error: Approval ID required."),process.exit(1));let n=t?parseInt(t,10)*1e3:void 0;try{let a=await u(e);s||console.log(`
|
|
758
|
+
Waiting for approval ${o}...`);let i=await a.waitForApproval(o,{timeoutMs:n}),c=i.status==="approved";s?d({...i,approved:c},!0):(console.log(`
|
|
759
|
+
Approval ${c?"GRANTED":i.status.toUpperCase()}!
|
|
760
|
+
`),console.log(`Status: ${i.status}`),i.responseNote&&console.log(`Note: ${i.responseNote}`),i.approvalScope&&console.log(`Scope: ${i.approvalScope}`));}catch(a){console.error("Wait failed:",a instanceof Error?a.message:a),process.exit(1);}}async function to(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
761
|
+
mixrpay approval - Human approval workflow
|
|
762
|
+
|
|
763
|
+
USAGE
|
|
764
|
+
mixrpay approval [subcommand] [options]
|
|
765
|
+
|
|
766
|
+
SUBCOMMANDS
|
|
767
|
+
request Request human approval
|
|
768
|
+
status <id> Get approval status
|
|
769
|
+
check <id> Quick check if approved (returns bool)
|
|
770
|
+
wait <id> Wait for approval decision
|
|
771
|
+
|
|
772
|
+
REQUEST OPTIONS
|
|
773
|
+
--action, -a Action name (required)
|
|
774
|
+
--description, -d Description (required)
|
|
775
|
+
--amount Amount in USD (optional)
|
|
776
|
+
--expires Expiry in minutes (default: 60)
|
|
777
|
+
|
|
778
|
+
OPTIONS
|
|
779
|
+
--timeout Wait timeout in seconds
|
|
780
|
+
--json Output as JSON
|
|
781
|
+
--help, -h Show this help message
|
|
782
|
+
|
|
783
|
+
DESCRIPTION
|
|
784
|
+
Request human approval before performing sensitive actions.
|
|
785
|
+
Useful for high-value transfers or destructive operations.
|
|
786
|
+
|
|
787
|
+
EXAMPLES
|
|
788
|
+
mixrpay approval request --action "transfer" --description "Send $100 to Bob" --amount 100
|
|
789
|
+
mixrpay approval status appr_abc123
|
|
790
|
+
mixrpay approval wait appr_abc123 --timeout 300
|
|
791
|
+
`);return}switch(s){case "request":await ze(e);break;case "status":await Ze(e,r.slice(1));break;case "check":await eo(e,r.slice(1));break;case "wait":await oo(e,r.slice(1));break;default:console.error("Unknown subcommand. Run `mixrpay approval --help` for usage."),process.exit(1);}}function T(){console.log(`
|
|
109
792
|
MixrPay CLI - Manage AI agent payments
|
|
110
793
|
|
|
111
794
|
USAGE
|
|
112
795
|
mixrpay <command> [options]
|
|
113
796
|
|
|
114
|
-
|
|
115
|
-
login
|
|
116
|
-
logout
|
|
117
|
-
whoami
|
|
118
|
-
register
|
|
119
|
-
status
|
|
797
|
+
AUTHENTICATION
|
|
798
|
+
login Authenticate via browser and save credentials
|
|
799
|
+
logout Clear saved credentials
|
|
800
|
+
whoami Show current authentication status
|
|
801
|
+
register Register a new agent with MixrPay
|
|
802
|
+
status Show agent balance and session info
|
|
803
|
+
|
|
804
|
+
WALLET & BUDGET
|
|
805
|
+
wallet Manage your agent wallet (balance, send, create, etc.)
|
|
806
|
+
budget Show available budget for spawning
|
|
807
|
+
spawn Create a child invite for a sub-agent
|
|
808
|
+
children List child sessions
|
|
809
|
+
sessions Manage merchant sessions
|
|
810
|
+
|
|
811
|
+
AI & TOOLS
|
|
812
|
+
complete Get an LLM completion (no tools)
|
|
813
|
+
run Run an AI agent with tools
|
|
814
|
+
tool Call MixrPay gateway tools (see: mixrpay-tool)
|
|
815
|
+
search Quick web search shortcut
|
|
816
|
+
mcp Manage MCP servers (deploy, list, call)
|
|
817
|
+
skills Manage connected app skills
|
|
818
|
+
|
|
819
|
+
TASK MANAGEMENT
|
|
820
|
+
agent Manage task agents (deploy, trigger, wait)
|
|
821
|
+
task Task board (create, request, submit, approve)
|
|
822
|
+
plan Multi-step plans (submit, execute, wait)
|
|
823
|
+
approval Human approval workflow
|
|
824
|
+
|
|
825
|
+
DEFI
|
|
826
|
+
defi DeFi operations (balances, transfer, swap, bridge)
|
|
827
|
+
|
|
828
|
+
DIAGNOSTICS
|
|
829
|
+
diagnostics Run wallet diagnostics
|
|
830
|
+
health Check MixrPay server health
|
|
831
|
+
siwe Generate SIWE (Sign-In with Ethereum) message
|
|
120
832
|
|
|
121
833
|
OPTIONS
|
|
122
834
|
--help, -h Show this help message
|
|
123
835
|
--version, -v Show version number
|
|
836
|
+
--json Output as JSON (most commands)
|
|
124
837
|
--baseUrl Override MixrPay API URL (default: https://www.mixrpay.com)
|
|
125
838
|
|
|
126
839
|
EXAMPLES
|
|
127
840
|
# Interactive login (opens browser)
|
|
128
841
|
mixrpay login
|
|
129
842
|
|
|
130
|
-
#
|
|
131
|
-
mixrpay
|
|
843
|
+
# Register with invite code (instant access)
|
|
844
|
+
mixrpay register --mode invite --invite-code mixr-abc123 --name "My Agent"
|
|
132
845
|
|
|
133
|
-
#
|
|
134
|
-
mixrpay
|
|
846
|
+
# Check wallet balance
|
|
847
|
+
mixrpay wallet
|
|
848
|
+
|
|
849
|
+
# Quick web search
|
|
850
|
+
mixrpay search "AI agent frameworks"
|
|
851
|
+
|
|
852
|
+
# Run an agent task
|
|
853
|
+
mixrpay run "Research the latest AI papers and summarize"
|
|
854
|
+
|
|
855
|
+
# Deploy a task agent
|
|
856
|
+
mixrpay agent deploy --name "Researcher" --prompt "Find papers" --budget 5.00
|
|
857
|
+
|
|
858
|
+
# Call gateway tool
|
|
859
|
+
mixrpay tool firecrawl firecrawl-search '{"query":"..."}'
|
|
860
|
+
|
|
861
|
+
# Deploy JIT MCP server
|
|
862
|
+
mixrpay mcp deploy github
|
|
863
|
+
|
|
864
|
+
# Request human approval
|
|
865
|
+
mixrpay approval request --action "transfer" --description "Send $100"
|
|
135
866
|
|
|
136
|
-
|
|
137
|
-
|
|
867
|
+
TOOL CLI
|
|
868
|
+
For full tool gateway access, use:
|
|
869
|
+
npx mixrpay-tool <provider> <tool_name> '<json>'
|
|
870
|
+
npx mixrpay-tool list
|
|
871
|
+
npx mixrpay-tool help <provider>
|
|
138
872
|
|
|
139
873
|
ENVIRONMENT VARIABLES
|
|
140
874
|
MIXRPAY_SESSION_KEY Session key for authentication
|
|
141
|
-
|
|
875
|
+
MIXRPAY_AGENT_TOKEN Agent token for API calls
|
|
142
876
|
MIXRPAY_MASTER_KEY Master key for multi-agent deployments
|
|
143
877
|
MIXRPAY_BASE_URL Custom API base URL
|
|
144
878
|
AGENT_WALLET_KEY Agent's wallet private key
|
|
145
879
|
|
|
146
880
|
For more info, visit: https://docs.mixrpay.com/cli
|
|
147
|
-
`);}function
|
|
881
|
+
`);}function so(){import('./agent-wallet-YY6SGBZQ.js').then(({SDK_VERSION:e})=>{console.log(`mixrpay v${e}`);});}async function no(){let e=C(process.argv.slice(2));if(e.flags.help||e.flags.h){T();return}if(e.flags.version||e.flags.v){so();return}switch(e.command){case "login":await N(e.flags);break;case "logout":await R();break;case "whoami":await _(e.flags);break;case "register":await j(e.flags);break;case "status":await D(e.flags);break;case "wallet":await X(e.flags,e.positionals);break;case "budget":await Q(e.flags);break;case "spawn":await Y(e.flags);break;case "children":await V(e.flags);break;case "sessions":await ae(e.flags,e.positionals);break;case "complete":await z(e.flags,e.positionals);break;case "run":await Z(e.flags,e.positionals);break;case "tool":await Ie(e.flags,e.positionals);break;case "search":await Ue(e.flags,e.positionals);break;case "mcp":await me(e.flags,e.positionals);break;case "skills":await xe(e.flags,e.positionals);break;case "agent":await Ee(e.flags,e.positionals);break;case "task":await Me(e.flags,e.positionals);break;case "defi":await Je(e.flags,e.positionals);break;case "plan":await Qe(e.flags,e.positionals);break;case "approval":await to(e.flags,e.positionals);break;case "diagnostics":await ee(e.flags);break;case "health":await oe(e.flags);break;case "siwe":await te(e.flags);break;case "":case "help":T();break;default:console.error(`Unknown command: ${e.command}`),console.error("\nRun `mixrpay --help` for usage information."),process.exit(1);}}no().catch(e=>{console.error("Fatal error:",e),process.exit(1);});
|