@mixrpay/agent-sdk 0.11.0 → 0.11.3
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 +32 -4
- package/dist/{agent-wallet-QEL6J4X2.js → agent-wallet-DD4EL57B.js} +1 -1
- package/dist/{chunk-IBXQMJ7G.js → chunk-EFAKSIRR.js} +1 -1
- package/dist/{chunk-SWK4Q2A3.js → chunk-KXMATINK.js} +1 -1
- package/dist/chunk-SEL55NG5.js +32 -0
- package/dist/cli.js +917 -44
- package/dist/{credentials-QUSJGKLZ.js → credentials-2PX5YXGV.js} +1 -1
- package/dist/{credentials-Z4HQDXFU.js → credentials-64ZBZ5AS.js} +1 -1
- package/dist/{credentials-XJV2ESBQ.js → credentials-ILS4YAGF.js} +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +76 -12
- package/dist/index.d.ts +76 -12
- package/dist/index.js +7 -7
- package/dist/mcp-server.js +10 -10
- package/dist/tool-cli.js +58 -0
- package/package.json +17 -2
- package/dist/chunk-UED36HQN.js +0 -32
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-
|
|
2
|
+
import {b as b$1,a as a$1,e,d as d$1,c as c$1}from'./chunk-KXMATINK.js';import {c,g,a}from'./chunk-SEL55NG5.js';import {privateKeyToAccount,generatePrivateKey}from'viem/accounts';import {createWalletClient,http,createPublicClient,parseUnits,encodeFunctionData}from'viem';import {base}from'viem/chains';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 b(e){return e.length<=16?e.slice(0,8)+"...":e.slice(0,12)+"..."+e.slice(-4)}function R(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 H(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 Y(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 V(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 z(){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 Q(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$1();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=b(o.sessionKey),t.keyType=n;try{let i=o.baseUrl||c,a=new g({sessionKey:o.sessionKey,baseUrl:i}),l=await a.getSessionKeyInfo();if(t.walletAddress=a.getWalletAddress(),t.network=a.getNetwork().name,l.expiresAt){t.expiresAt=l.expiresAt.toISOString();let c=new Date,g=(l.expiresAt.getTime()-c.getTime())/(1e3*60*60);t.expired=g<0,t.hoursRemaining=Math.max(0,g);}if(l.limits.totalUsd){let c=l.limits.totalUsd-(l.usage?.totalUsd||0);t.budget={totalUsd:l.limits.totalUsd,usedUsd:l.usage?.totalUsd||0,remainingUsd:c};}}catch{t.serverInfoError="Could not fetch additional info from server";}}if(o.apiToken&&(t.apiToken=b(o.apiToken)),o.masterKey&&(t.masterKey=b(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 i=t.hoursRemaining,a=new Date(t.expiresAt);t.expired?console.log(`Status: EXPIRED (${a.toLocaleDateString()})`):i<24?console.log(`Status: Active (expires in ${i.toFixed(1)} hours)`):console.log(`Status: Active (expires ${a.toLocaleDateString()})`);}if(t.budget){let i=t.budget;console.log(`Budget: $${i.remainingUsd.toFixed(2)} remaining of $${i.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 Z(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,108 @@ 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 i=e.key||e.privateKey||process.env.AGENT_WALLET_KEY;i||(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)),(!i.startsWith("0x")||i.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 a=await g.register({privateKey:i,name:o,baseUrl:t});r?d({mode:"wallet",userId:a.userId,depositAddress:a.depositAddress},!0):(console.log(`Agent registered successfully!
|
|
76
|
+
`),console.log(` User ID: ${a.userId}`),console.log(` Deposit Address: ${a.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(a$1){a$1 instanceof a?console.error(`Registration failed: ${a$1.message}`):console.error("Registration failed:",a$1),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 i=new AbortController,a=setTimeout(()=>i.abort(),3e4);try{let l=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:i.signal});clearTimeout(a);let c=await l.json().catch(()=>({error:"Invalid response from server"}));if(!l.ok)throw new Error(c.error||"Registration failed");(c.session?.session_key||c.token)&&a$1({sessionKey:c.session?.session_key,apiToken:c.token,baseUrl:t}),r?d({mode:"invite",agentId:c.agent_id,instanceId:c.instance_id,status:c.status,budgetUsd:c.budget_usd,inviterName:c.inviter_name,sessionKey:c.session?.session_key?b(c.session.session_key):void 0,agentToken:c.token?b(c.token):void 0},!0):(console.log(`Agent registered successfully!
|
|
81
|
+
`),console.log(` Agent ID: ${c.agent_id}`),c.instance_id&&console.log(` Instance ID: ${c.instance_id}`),console.log(` Status: ${c.status}`),console.log(` Budget: $${c.budget_usd}`),console.log(` Inviter: ${c.inviter_name}`),c.session?.session_key||c.token?(c.session?.session_key&&console.log(` Session Key: ${c.session.session_key.slice(0,16)}...`),c.token&&console.log(` Token: ${c.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(l){clearTimeout(a),l instanceof Error&&l.name==="AbortError"?console.error("Registration timed out after 30 seconds."):console.error(`Registration failed: ${l instanceof Error?l.message:l}`),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 i=new AbortController,a=setTimeout(()=>i.abort(),3e4);try{let l=await fetch(`${t}/api/v2/agent/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"self",name:o}),signal:i.signal});clearTimeout(a);let c=await l.json().catch(()=>({error:"Invalid response from server"}));if(!l.ok)throw new Error(c.error||"Registration failed");a$1({apiToken:c.token,baseUrl:t}),r?d({mode:"self",agentId:c.agent_id,agentToken:b(c.token),status:c.status,claimCode:c.claim_code,claimUrl:c.claim_url,expiresInDays:c.expires_in_days},!0):(console.log(`Agent created successfully!
|
|
85
|
+
`),console.log(` Agent ID: ${c.agent_id}`),console.log(` Token: ${c.token.slice(0,20)}...`),console.log(` Status: ${c.status}`),console.log(` Claim Code: ${c.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: ${c.claim_url}`),console.log(`
|
|
89
|
+
The claim code expires in ${c.expires_in_days} days.`),console.log("\n After claiming, run `mixrpay status` to verify activation."));}catch(l){clearTimeout(a),l instanceof Error&&l.name==="AbortError"?console.error("Registration timed out after 30 seconds."):console.error(`Registration failed: ${l instanceof Error?l.message:l}`),process.exit(1);}}}async function ee(e){if(e.help||e.h){console.log(`
|
|
90
|
+
mixrpay install - Verify MIXRPAY_AGENT_TOKEN (web /cli/setup flow; no registration)
|
|
91
|
+
|
|
92
|
+
USAGE
|
|
93
|
+
mixrpay install [options]
|
|
94
|
+
|
|
95
|
+
OPTIONS
|
|
96
|
+
--baseUrl, --url Override MixrPay API URL (else MIXRPAY_BASE_URL or default)
|
|
97
|
+
--json Output as JSON
|
|
98
|
+
--help, -h Show this help message
|
|
99
|
+
|
|
100
|
+
REQUIRES
|
|
101
|
+
MIXRPAY_AGENT_TOKEN From https://www.mixrpay.com/cli/setup (or your deployment)
|
|
102
|
+
|
|
103
|
+
EXAMPLES
|
|
104
|
+
export MIXRPAY_AGENT_TOKEN='agt_live_...'
|
|
105
|
+
export MIXRPAY_BASE_URL='https://www.mixrpay.com'
|
|
106
|
+
mixrpay install
|
|
107
|
+
`);return}let r=e.json===true,s=e.baseUrl||e.url||process.env.MIXRPAY_BASE_URL||c,o=process.env.MIXRPAY_AGENT_TOKEN;if(!o||!o.startsWith("agt_live_")){let t=s.replace(/\/$/,"");console.error("Error: MIXRPAY_AGENT_TOKEN must be set to an agt_live_\u2026 token."),console.error(`
|
|
108
|
+
Create one in the browser:`),console.error(` ${t}/cli/setup`),console.error(`
|
|
109
|
+
Then:`),console.error(" export MIXRPAY_AGENT_TOKEN='\u2026'"),process.exit(1);}try{let t=await fetch(`${s}/api/v2/agent/status`,{headers:{Authorization:`Bearer ${o}`}}),n=await t.json().catch(()=>({}));t.ok||(r?d({ok:!1,status:t.status,error:n.error},!0):console.error(`Verification failed (${t.status}): ${n.error||"unknown error"}`),process.exit(1)),r?d({ok:!0,baseUrl:s,status:n},!0):(console.log(`You're all set \u2014 token verified against the API.
|
|
110
|
+
`),console.log(` Base URL: ${s}`),n.agent_name&&console.log(` Agent: ${n.agent_name}`),console.log(`
|
|
111
|
+
Try:`),console.log(" mixrpay status"),console.log(' mixrpay run "Summarize https://example.com in one sentence"'));}catch(t){console.error("Verification failed:",t instanceof Error?t.message:t),process.exit(1);}}async function oe(e$1){if(e$1.help||e$1.h){console.log(`
|
|
112
|
+
mixrpay init - Set up your agent in one command
|
|
113
|
+
|
|
114
|
+
USAGE
|
|
115
|
+
mixrpay init [options]
|
|
116
|
+
|
|
117
|
+
OPTIONS
|
|
118
|
+
--name, -n Agent name (default: auto-generated)
|
|
119
|
+
--invite Invite code for sponsored setup
|
|
120
|
+
--show-key Display private key in output (self-funded only)
|
|
121
|
+
--baseUrl, --url Override MixrPay API URL
|
|
122
|
+
--json Output as JSON
|
|
123
|
+
--help, -h Show this help message
|
|
124
|
+
|
|
125
|
+
PATHS
|
|
126
|
+
Self-funded (default)
|
|
127
|
+
You control the wallet. Generate a new wallet, register with MixrPay,
|
|
128
|
+
and get session credentials. Fund your wallet to start using tools.
|
|
129
|
+
|
|
130
|
+
Sponsored (--invite)
|
|
131
|
+
Use an invite code from a sponsor. Budget is pre-allocated, so you
|
|
132
|
+
can start using tools immediately.
|
|
133
|
+
|
|
134
|
+
EXAMPLES
|
|
135
|
+
# Self-funded (you control the wallet)
|
|
136
|
+
mixrpay init --name "MyAgent"
|
|
137
|
+
|
|
138
|
+
# Self-funded with key displayed
|
|
139
|
+
mixrpay init --name "MyAgent" --show-key
|
|
140
|
+
|
|
141
|
+
# Sponsored (instant access with budget)
|
|
142
|
+
mixrpay init --invite mixr-abc123
|
|
143
|
+
|
|
144
|
+
WHAT GETS CREATED
|
|
145
|
+
- Wallet address (self-funded) or session (sponsored)
|
|
146
|
+
- Credentials saved to ~/.config/mixrpay/
|
|
147
|
+
- Ready to call tools (after funding for self-funded)
|
|
148
|
+
|
|
149
|
+
SECURITY
|
|
150
|
+
Private keys are saved to credentials but NOT displayed by default.
|
|
151
|
+
Use --show-key to display the key (for manual backup).
|
|
152
|
+
`);return}let r=e$1.json===true,s=e$1["show-key"]===true||e$1.showKey===true,o=e$1.name||e$1.n||`agent-${Date.now()}`,t=e$1.invite||e$1["invite-code"],n=e$1.baseUrl||e$1.url||c;if(t){r||console.log(`Claiming invite code...
|
|
153
|
+
`);let i=new AbortController,a=setTimeout(()=>i.abort(),3e4);try{let l=await fetch(`${n}/api/v2/agent/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"invite",name:o,invite_code:t}),signal:i.signal});clearTimeout(a);let c=await l.json().catch(()=>({error:"Invalid response from server"}));if(!l.ok)throw new Error(c.error||"Registration failed");(c.session?.session_key||c.token)&&a$1({sessionKey:c.session?.session_key,apiToken:c.token,baseUrl:n}),r?d({success:!0,mode:"sponsored",agentId:c.agent_id,status:c.status,budgetUsd:c.budget_usd,sponsor:c.inviter_name,sessionKey:c.session?.session_key?b(c.session.session_key):void 0,credentialsPath:e()},!0):(console.log(`Agent initialized!
|
|
154
|
+
`),console.log("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),console.log(` Name: ${o}`),console.log(` Agent ID: ${c.agent_id}`),console.log(` Status: ${c.status}`),console.log(` Budget: $${c.budget_usd}`),console.log(` Sponsor: ${c.inviter_name}`),console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
155
|
+
`),console.log(`Credentials saved. Start using tools now:
|
|
156
|
+
`),console.log(' mixrpay search "AI agent frameworks"'),console.log(` mixrpay tool firecrawl firecrawl-search '{"query":"..."}'`));}catch(l){clearTimeout(a),l instanceof Error&&l.name==="AbortError"?console.error("Request timed out after 30 seconds."):console.error(`Init failed: ${l instanceof Error?l.message:l}`),process.exit(1);}}else {r||console.log(`Setting up self-funded agent...
|
|
157
|
+
`);let i=new AbortController,a$2=setTimeout(()=>i.abort(),3e4);try{r||console.log(" Registering agent...");let l=await fetch(`${n}/api/v2/agent/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"self",name:o}),signal:i.signal});clearTimeout(a$2);let c=await l.json().catch(()=>({error:"Invalid response from server"}));if(!l.ok)throw new Error(c.error||"Registration failed");let g=c.token,m=c.agent_instance_id||c.agent_id;if(!g)throw new Error("No agent token received from registration");a$1({apiToken:g,baseUrl:n}),r||console.log(" Creating self-custody wallet...");let p=generatePrivateKey(),h=privateKeyToAccount(p),y=h.address,x=Date.now(),v=`MixrPay Wallet Registration
|
|
158
|
+
Address: ${y}
|
|
159
|
+
Timestamp: ${x}`,f=await h.signMessage({message:v}),T=new AbortController,O=setTimeout(()=>T.abort(),3e4),U=await fetch(`${n}/api/v2/agent/wallet/register`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${g}`},body:JSON.stringify({address:y,signature:f,timestamp:x}),signal:T.signal});if(clearTimeout(O),!U.ok){let $=await U.json().catch(()=>({}));throw new Error($.error||"Failed to register wallet")}if(a$1({apiToken:g,privateKey:p,walletAddress:y,depositAddress:y,baseUrl:n}),r){let $={success:!0,mode:"self-funded",name:o,agentId:c.agent_id,walletAddress:y,depositAddress:y,agentToken:b(g),credentialsPath:e()};s&&($.privateKey=p,$.warning="Save your private key securely. It cannot be recovered."),d($,!0);}else console.log(`
|
|
160
|
+
Agent initialized!
|
|
161
|
+
`),console.log("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),console.log(` Name: ${o}`),console.log(` Agent: ${c.agent_id}`),console.log(` Wallet: ${y}`),s&&console.log(` Key: ${p}`),console.log(`\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
162
|
+
`),s&&(console.log("!!! IMPORTANT !!!"),console.log(`Save your private key securely. It cannot be recovered.
|
|
163
|
+
`)),console.log(`To start using tools, fund your wallet:
|
|
164
|
+
`),console.log(` Send USDC (Base) to: ${y}
|
|
165
|
+
`),console.log(`Once funded, tools work immediately:
|
|
166
|
+
`),console.log(' mixrpay search "AI agent frameworks"'),console.log(` mixrpay tool firecrawl firecrawl-search '{"query":"..."}'`),console.log(`
|
|
167
|
+
Credentials saved to:`,e());}catch(l){clearTimeout(a$2),l instanceof Error&&l.name==="AbortError"?console.error("Request timed out after 30 seconds."):l instanceof a?console.error(`Init failed: ${l.message}`):console.error(`Init failed: ${l instanceof Error?l.message:l}`),process.exit(1);}}}async function te(e){if(e.help||e.h){console.log(`
|
|
82
168
|
mixrpay status - Show agent balance and session info
|
|
83
169
|
|
|
84
170
|
USAGE
|
|
@@ -87,6 +173,7 @@ USAGE
|
|
|
87
173
|
OPTIONS
|
|
88
174
|
--key, --privateKey Agent's wallet private key (optional if logged in)
|
|
89
175
|
--baseUrl, --url Override MixrPay API URL
|
|
176
|
+
--json Output as JSON
|
|
90
177
|
--help, -h Show this help message
|
|
91
178
|
|
|
92
179
|
DESCRIPTION
|
|
@@ -97,51 +184,837 @@ DESCRIPTION
|
|
|
97
184
|
EXAMPLES
|
|
98
185
|
mixrpay status # Uses cached session key
|
|
99
186
|
mixrpay status --key 0x... # Uses wallet private key
|
|
100
|
-
|
|
187
|
+
mixrpay status --json # Output as JSON
|
|
188
|
+
`);return}let r=e.json===true,s=e.key||e.privateKey||process.env.AGENT_WALLET_KEY,o=e.baseUrl||e.url||c,t=b$1();if(!s&&t.success&&t.credentials.sessionKey)try{let n=new g({sessionKey:t.credentials.sessionKey,baseUrl:t.credentials.baseUrl||o}),i=await n.getSpendingStats(),a=await n.getSessionKeyInfo();if(r){d({walletAddress:n.getWalletAddress(),network:n.getNetwork().name,totalSpentUsd:i.totalSpentUsd,txCount:i.txCount,remainingDailyUsd:i.remainingDailyUsd,remainingTotalUsd:i.remainingTotalUsd,sessionExpiresAt:a.expiresAt?.toISOString(),authMethod:"session_key"},!0);return}console.log(`Agent Status (via session key)
|
|
101
189
|
`),console.log(`Wallet: ${n.getWalletAddress()}`),console.log(`Network: ${n.getNetwork().name}`),console.log(`
|
|
102
|
-
Spending:`),console.log(` Total spent: $${
|
|
103
|
-
Session expires: ${
|
|
190
|
+
Spending:`),console.log(` Total spent: $${i.totalSpentUsd.toFixed(2)}`),console.log(` Transaction count: ${i.txCount}`),i.remainingDailyUsd!==null&&console.log(` Daily remaining: $${i.remainingDailyUsd.toFixed(2)}`),i.remainingTotalUsd!==null&&console.log(` Total remaining: $${i.remainingTotalUsd.toFixed(2)}`),a.expiresAt&&console.log(`
|
|
191
|
+
Session expires: ${a.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
192
|
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:
|
|
193
|
+
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...
|
|
194
|
+
`);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(i=>({id:i.id,remainingUsd:i.remainingUsd,expiresAt:i.expiresAt.toISOString()})),authMethod:"wallet_key"},!0);return}console.log(`Agent Status
|
|
107
195
|
`),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
|
|
196
|
+
Active Sessions: ${n.activeSessions.length}`);for(let i of n.activeSessions){let a=i.remainingUsd!==null?`$${i.remainingUsd.toFixed(2)} remaining`:"unlimited";console.log(` - ${i.id.slice(0,8)}... ${a}, expires ${i.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 se(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(`
|
|
197
|
+
Wallet Balance
|
|
198
|
+
`),console.log(`Address: ${s.getWalletAddress()}`),console.log(`Network: ${s.getNetwork().name}`),console.log(`Balance: $${o.toFixed(2)} USDC`),console.log(`
|
|
199
|
+
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 ne(e){let r=e.json===true;try{let s=await u(e);if(await s.hasSelfCustodyWallet()){await s.loadSelfCustodyWallet();let i=s.getSelfCustodyAddress();r?d({address:i,already_exists:!0},!0):(console.log(`
|
|
200
|
+
Self-custody wallet already exists.`),console.log(`Address: ${i}`),console.log("\nUse `mixrpay wallet self-custody` to view details."));return}console.log(`Creating self-custody wallet...
|
|
201
|
+
`);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!
|
|
202
|
+
`),console.log(`Address: ${t}`),console.log(`
|
|
203
|
+
Private Key: ${n}`),console.log(`
|
|
204
|
+
!!! 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 re(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(`
|
|
205
|
+
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 ie(e){let r=e.json===true;try{let s=await u(e);if(!await s.hasSelfCustodyWallet()){r?d({exists:!1},!0):(console.log(`
|
|
206
|
+
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(`
|
|
207
|
+
Self-Custody Wallet Address: ${t}`),console.log(`
|
|
208
|
+
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 ae(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(`
|
|
209
|
+
Funding Instructions
|
|
210
|
+
`),console.log(`Deposit Address: ${o}`),console.log(`Network: ${t.name} (Chain ID: ${t.chainId})`),console.log("Token: USDC"),console.log(`
|
|
211
|
+
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(`
|
|
212
|
+
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 le(e,r){let s=e.json===true,o=r[0]||e.amount;o||(console.error("Error: Amount required."),console.error(`
|
|
213
|
+
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 i=await(await u(e)).canAfford(t);s?d({amount_requested:t,can_afford:i.canAfford,balance:i.balance,shortfall:i.shortfall,remaining_after:i.remainingAfter},!0):(console.log(`
|
|
214
|
+
Affordability Check: $${t.toFixed(2)}
|
|
215
|
+
`),console.log(`Balance: $${i.balance.toFixed(2)}`),i.canAfford?(console.log("Status: CAN AFFORD"),console.log(`Remaining after: $${i.remainingAfter.toFixed(2)}`)):(console.log("Status: CANNOT AFFORD"),console.log(`Shortfall: $${i.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 ce(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(`
|
|
216
|
+
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 i=parseFloat(t);(isNaN(i)||i<=0)&&(console.error("Error: Invalid amount. Must be a positive number."),process.exit(1));try{let a=await u(e);s||(console.log(`
|
|
217
|
+
Sending $${i.toFixed(2)} USDC to ${o.slice(0,10)}...${o.slice(-8)}`),console.log(`Using delegation budget...
|
|
218
|
+
`));let l=await a.transfer(o,i.toFixed(2),"USDC",n?{idempotencyKey:n}:void 0);s?d(l,!0):(console.log(`Transfer successful!
|
|
219
|
+
`),console.log(`Amount: $${l.amount_usd}`),console.log(`To: ${o}`),console.log(`TX Hash: ${l.tx_hash}`),console.log(`Remaining budget: $${l.remaining_budget_usd?.toFixed(2)||"N/A"}`));}catch(a){console.error("Transfer failed:",a instanceof Error?a.message:a),process.exit(1);}}async function de(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(`
|
|
220
|
+
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 i=await u(e);await i.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 i.loadSelfCustodyWallet(),s||(console.log(`
|
|
221
|
+
Sending $${n.toFixed(2)} USDC to ${o.slice(0,10)}...${o.slice(-8)}`),console.log(`Using self-custody wallet (on-chain)...
|
|
222
|
+
`));let l=await i.transferUSDC({to:o,amountUsdc:n});s?d({tx_hash:l,to:o,amount_usdc:n},!0):(console.log(`Transfer successful!
|
|
223
|
+
`),console.log(`Amount: $${n.toFixed(2)} USDC`),console.log(`To: ${o}`),console.log(`TX Hash: ${l}`));}catch(i){console.error("Transfer failed:",i instanceof Error?i.message:i),process.exit(1);}}async function ue(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(`
|
|
224
|
+
Transaction History
|
|
225
|
+
`),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(),i=t.type||"payment",a=t.amount_usd?`$${t.amount_usd.toFixed(2)}`:"N/A";console.log(` ${n} | ${i.padEnd(12)} | ${a.padStart(10)} | ${t.status}`);}o.length>20&&console.log(`
|
|
226
|
+
... 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(`
|
|
227
|
+
Payment History (Current Session)
|
|
228
|
+
`),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(`
|
|
229
|
+
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 ge(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
230
|
+
mixrpay wallet - Manage your agent wallet
|
|
231
|
+
|
|
232
|
+
USAGE
|
|
233
|
+
mixrpay wallet [subcommand] [options]
|
|
234
|
+
|
|
235
|
+
SUBCOMMANDS
|
|
236
|
+
balance Show USDC balance (default)
|
|
237
|
+
create Create self-custody wallet
|
|
238
|
+
address Show delegation wallet address
|
|
239
|
+
self-custody Show self-custody wallet address
|
|
240
|
+
fund Show deposit address and funding instructions
|
|
241
|
+
afford <amt> Check if you can afford an amount
|
|
242
|
+
send <to> <amt> Send USDC via delegation budget
|
|
243
|
+
send-direct <to> <amt> Send USDC from self-custody wallet
|
|
244
|
+
history Show payment/transaction history
|
|
245
|
+
|
|
246
|
+
OPTIONS
|
|
247
|
+
--json Output as JSON
|
|
248
|
+
--baseUrl, --url Override MixrPay API URL
|
|
249
|
+
--help, -h Show this help message
|
|
250
|
+
|
|
251
|
+
EXAMPLES
|
|
252
|
+
mixrpay wallet # Show balance
|
|
253
|
+
mixrpay wallet balance --json # Balance as JSON
|
|
254
|
+
mixrpay wallet create # Create self-custody wallet
|
|
255
|
+
mixrpay wallet afford 50.00 # Check if can afford $50
|
|
256
|
+
mixrpay wallet send 0x123... 10.00 # Send $10 via delegation
|
|
257
|
+
mixrpay wallet send-direct 0x123... 10.00 # Send $10 on-chain
|
|
258
|
+
mixrpay wallet history # View transactions
|
|
259
|
+
`);return}switch(s){case "create":await ne(e);break;case "address":await re(e);break;case "self-custody":await ie(e);break;case "fund":await ae(e);break;case "afford":await le(e,r.slice(1));break;case "send":await ce(e,r.slice(1));break;case "send-direct":await de(e,r.slice(1));break;case "history":await ue(e);break;case "balance":case void 0:default:await se(e);break}}async function pe(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(`
|
|
260
|
+
Budget Overview
|
|
261
|
+
`),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 me(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(`
|
|
262
|
+
mixrpay spawn - Create a child invite for a sub-agent
|
|
263
|
+
|
|
264
|
+
USAGE
|
|
265
|
+
mixrpay spawn --name <name> --budget <amount> [options]
|
|
266
|
+
|
|
267
|
+
OPTIONS
|
|
268
|
+
--name, -n Name for the child agent (required)
|
|
269
|
+
--budget, -b Budget in USD to allocate (required)
|
|
270
|
+
--expires, -e Days until expiry (default: parent's remaining time)
|
|
271
|
+
--merchants, -m Comma-separated allowed merchants (must be subset of parent)
|
|
272
|
+
--json Output as JSON
|
|
273
|
+
--help, -h Show this help message
|
|
274
|
+
|
|
275
|
+
EXAMPLES
|
|
276
|
+
mixrpay spawn --name "Research Agent" --budget 10.00
|
|
277
|
+
mixrpay spawn -n "Writer" -b 5.00 --expires 7
|
|
278
|
+
mixrpay spawn -n "API Agent" -b 20.00 --merchants "openai.com,anthropic.com"
|
|
279
|
+
`);return}s||(console.error("Error: Name is required."),console.error(`
|
|
280
|
+
Usage: mixrpay spawn --name <name> --budget <amount>`),process.exit(1)),o||(console.error("Error: Budget is required."),console.error(`
|
|
281
|
+
Usage: mixrpay spawn --name <name> --budget <amount>`),process.exit(1));let i=parseFloat(o);(isNaN(i)||i<=0)&&(console.error("Error: Invalid budget. Must be a positive number."),process.exit(1));let a=t?parseInt(t,10):void 0,l=n?n.split(",").map(c=>c.trim()):void 0;try{let c=await u(e);r||console.log(`
|
|
282
|
+
Creating child invite for "${s}" with $${i.toFixed(2)} budget...
|
|
283
|
+
`);let g=await c.spawnChildInvite({budgetUsd:i,name:s,allowedMerchants:l,expiresInDays:a});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!
|
|
284
|
+
`),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(`
|
|
285
|
+
Share this invite code with the sub-agent:`),console.log(` mixrpay register --mode invite --invite-code ${g.inviteCode} --name "${s}"`));}catch(c){console.error("Failed to spawn child:",c instanceof Error?c.message:c),process.exit(1);}}async function ye(e){let r=e.json===true;try{let o=await(await u(e)).getChildSessions();if(r)d({children:o},!0);else if(console.log(`
|
|
286
|
+
Child Sessions
|
|
287
|
+
`),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,i=t.budgetUsd??0,a=i>0?(n/i*100).toFixed(0):"0";console.log(`${t.name||"Unnamed"}`),console.log(` Budget: $${n.toFixed(2)} / $${i.toFixed(2)} (${a}% 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 fe(e){if(e.help||e.h){console.log(`
|
|
288
|
+
mixrpay budget - Show available budget for spawning
|
|
289
|
+
|
|
290
|
+
USAGE
|
|
291
|
+
mixrpay budget [options]
|
|
292
|
+
|
|
293
|
+
OPTIONS
|
|
294
|
+
--json Output as JSON
|
|
295
|
+
--help, -h Show this help message
|
|
296
|
+
|
|
297
|
+
DESCRIPTION
|
|
298
|
+
Shows your current budget allocation including:
|
|
299
|
+
- Total budget assigned to your session
|
|
300
|
+
- Amount spent on tools/services
|
|
301
|
+
- Amount allocated to child agents
|
|
302
|
+
- Available budget for spawning new children
|
|
303
|
+
|
|
304
|
+
EXAMPLES
|
|
305
|
+
mixrpay budget
|
|
306
|
+
mixrpay budget --json
|
|
307
|
+
`);return}await pe(e);}async function he(e){let r=e.json===true;try{let s=b$1();(!s.success||!s.credentials.apiToken)&&(console.error("Not logged in. Run `mixrpay init` or `mixrpay login` first."),process.exit(1));let o=s.credentials.baseUrl||c,t=new g({sessionKey:s.credentials.sessionKey||"sk_live_placeholder",baseUrl:o});t.setApiKey(s.credentials.apiToken);let n=await t.credsList();if(r)d({credentials:n},!0);else if(n.length===0)console.log(`
|
|
308
|
+
No credentials stored.
|
|
309
|
+
`),console.log("Store a credential:"),console.log(` mixrpay creds set --service openai --key api_key
|
|
310
|
+
`);else {console.log(`
|
|
311
|
+
Stored Credentials
|
|
312
|
+
`),console.log("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");for(let i of n)console.log(` ${i.service}/${i.key}`),i.description&&console.log(` Description: ${i.description}`),console.log(` Access count: ${i.accessCount}`),i.lastAccessedAt&&console.log(` Last accessed: ${new Date(i.lastAccessedAt).toLocaleString()}`),console.log("");console.log("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");}}catch(s){console.error("Failed to list credentials:",s instanceof Error?s.message:s),process.exit(1);}}async function we(e){let r=e.service||e.s,s=e.key||e.k,o=e.value,t=e.description;(!r||!s)&&(console.error("Error: --service and --key are required."),console.error(`
|
|
313
|
+
Usage: mixrpay creds set --service <name> --key <key> [--value <val>]`),process.exit(1));let n=o;if(!n){let a=(await import('readline')).createInterface({input:process.stdin,output:process.stdout});n=await new Promise(l=>{process.stdout.write(`Enter value for ${r}/${s}: `),process.stdin.isTTY&&process.stdin.setRawMode?.(true);let c="";process.stdin.on("data",g=>{let m=g.toString();m===`
|
|
314
|
+
`||m==="\r"?(process.stdin.isTTY&&process.stdin.setRawMode?.(false),console.log(""),a.close(),l(c)):m===""?process.exit(1):m==="\x7F"?c=c.slice(0,-1):c+=m;});}),n||(console.error("Error: Value is required."),process.exit(1));}try{let i=b$1();(!i.success||!i.credentials.apiToken)&&(console.error("Not logged in. Run `mixrpay init` or `mixrpay login` first."),process.exit(1));let a=i.credentials.baseUrl||c,l=new g({sessionKey:i.credentials.sessionKey||"sk_live_placeholder",baseUrl:a});l.setApiKey(i.credentials.apiToken),await l.credsSet(r,s,n,t),e.json===!0?d({success:!0,service:r,key:s},!0):console.log(`
|
|
315
|
+
Credential stored: ${r}/${s}`);}catch(i){console.error("Failed to store credential:",i instanceof Error?i.message:i),process.exit(1);}}async function xe(e){let r=e.json===true,s=e.service||e.s,o=e.key||e.k;(!s||!o)&&(console.error("Error: --service and --key are required."),console.error(`
|
|
316
|
+
Usage: mixrpay creds get --service <name> --key <key>`),process.exit(1));try{let t=b$1();(!t.success||!t.credentials.apiToken)&&(console.error("Not logged in. Run `mixrpay init` or `mixrpay login` first."),process.exit(1));let n=t.credentials.baseUrl||c,i=new g({sessionKey:t.credentials.sessionKey||"sk_live_placeholder",baseUrl:n});i.setApiKey(t.credentials.apiToken);let a=await i.credsGet(s,o);a===null&&(r?d({found:!1,service:s,key:o},!0):console.error(`Credential not found: ${s}/${o}`),process.exit(1)),r?d({found:!0,service:s,key:o,value:a},!0):console.log(a);}catch(t){console.error("Failed to get credential:",t instanceof Error?t.message:t),process.exit(1);}}async function Se(e){let r=e.json===true,s=e.service||e.s,o=e.key||e.k;(!s||!o)&&(console.error("Error: --service and --key are required."),console.error(`
|
|
317
|
+
Usage: mixrpay creds delete --service <name> --key <key>`),process.exit(1));try{let t=b$1();(!t.success||!t.credentials.apiToken)&&(console.error("Not logged in. Run `mixrpay init` or `mixrpay login` first."),process.exit(1));let n=t.credentials.baseUrl||c,i=new g({sessionKey:t.credentials.sessionKey||"sk_live_placeholder",baseUrl:n});i.setApiKey(t.credentials.apiToken);let a=await i.credsDelete(s,o);r?d({deleted:a,service:s,key:o},!0):console.log(a?`Credential deleted: ${s}/${o}`:`Credential not found: ${s}/${o}`);}catch(t){console.error("Failed to delete credential:",t instanceof Error?t.message:t),process.exit(1);}}async function be(e,r){if(e.help||e.h){console.log(`
|
|
318
|
+
mixrpay creds - Manage agent credential vault
|
|
319
|
+
|
|
320
|
+
USAGE
|
|
321
|
+
mixrpay creds [command] [options]
|
|
322
|
+
|
|
323
|
+
COMMANDS
|
|
324
|
+
list List all stored credentials (names only)
|
|
325
|
+
set Store a credential
|
|
326
|
+
get Retrieve a credential value
|
|
327
|
+
delete Delete a credential
|
|
328
|
+
|
|
329
|
+
SET OPTIONS
|
|
330
|
+
--service, -s Service name (e.g., "openai", "github")
|
|
331
|
+
--key, -k Key name (e.g., "api_key", "token")
|
|
332
|
+
--value Credential value (omit to enter securely)
|
|
333
|
+
--description Optional description
|
|
334
|
+
|
|
335
|
+
GET/DELETE OPTIONS
|
|
336
|
+
--service, -s Service name
|
|
337
|
+
--key, -k Key name
|
|
338
|
+
|
|
339
|
+
OPTIONS
|
|
340
|
+
--json Output as JSON
|
|
341
|
+
--help, -h Show this help message
|
|
342
|
+
|
|
343
|
+
EXAMPLES
|
|
344
|
+
# List all credentials
|
|
345
|
+
mixrpay creds list
|
|
346
|
+
|
|
347
|
+
# Store a credential (prompts for value securely)
|
|
348
|
+
mixrpay creds set --service openai --key api_key
|
|
349
|
+
|
|
350
|
+
# Store with value inline
|
|
351
|
+
mixrpay creds set --service github --key token --value ghp_xxx
|
|
352
|
+
|
|
353
|
+
# Retrieve a credential
|
|
354
|
+
mixrpay creds get --service openai --key api_key
|
|
355
|
+
|
|
356
|
+
# Delete a credential
|
|
357
|
+
mixrpay creds delete --service openai --key api_key
|
|
358
|
+
|
|
359
|
+
SECURITY
|
|
360
|
+
Credentials are encrypted at rest using AES-256-GCM.
|
|
361
|
+
Values are never logged or displayed except via 'creds get'.
|
|
362
|
+
`);return}switch(r[0]){case "set":await we(e);break;case "get":await xe(e);break;case "delete":case "del":case "rm":await Se(e);break;case "list":case void 0:default:await he(e);break}}async function ke(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(`
|
|
363
|
+
mixrpay complete - Get an LLM completion
|
|
364
|
+
|
|
365
|
+
USAGE
|
|
366
|
+
mixrpay complete "<prompt>"
|
|
367
|
+
mixrpay complete --prompt "<prompt>"
|
|
368
|
+
|
|
369
|
+
OPTIONS
|
|
370
|
+
--model, -m Model to use (default: gpt-4o-mini)
|
|
371
|
+
--system, -s System prompt
|
|
372
|
+
--json Output as JSON
|
|
373
|
+
--help, -h Show this help message
|
|
374
|
+
|
|
375
|
+
DESCRIPTION
|
|
376
|
+
Simple LLM completion without tools. For agentic workflows with
|
|
377
|
+
tool use, see 'mixrpay run'.
|
|
378
|
+
|
|
379
|
+
MODELS
|
|
380
|
+
gpt-4o-mini Fast and cheap (default)
|
|
381
|
+
gpt-4o More capable
|
|
382
|
+
claude-3-5-sonnet Most capable for reasoning
|
|
383
|
+
|
|
384
|
+
EXAMPLES
|
|
385
|
+
mixrpay complete "Explain quantum computing in 3 sentences"
|
|
386
|
+
mixrpay complete "Write a haiku" --model gpt-4o
|
|
387
|
+
mixrpay complete "Summarize this" -s "Be concise"
|
|
388
|
+
`);return}o||(console.error("Error: Prompt required."),console.error(`
|
|
389
|
+
Usage: mixrpay complete "<prompt>"`),process.exit(1));try{let i=await u(e);s||console.log(`Generating completion${t?` with ${t}`:""}...
|
|
390
|
+
`);let a=await i.complete(o,{model:t,systemPrompt:n});s?d({text:a.text,cost_usd:a.costUsd,model:a.model,tokens:a.tokens},!0):(console.log(a.text),console.log(`
|
|
391
|
+
---
|
|
392
|
+
Cost: $${a.costUsd.toFixed(4)} | Model: ${a.model}`));}catch(i){console.error("Completion failed:",i instanceof Error?i.message:i),process.exit(1);}}async function ve(e,r){let s=e.json===true,o=r.join(" ")||e.prompt,t=e.model||e.m,n=e.system||e.s,i=e.iterations?parseInt(e.iterations,10):void 0,a=e.tools||e.t,l=e.status;if(e.help||e.h){console.log(`
|
|
393
|
+
mixrpay run - Run an AI agent with tools
|
|
394
|
+
|
|
395
|
+
USAGE
|
|
396
|
+
mixrpay run "<prompt>"
|
|
397
|
+
mixrpay run --status <run_id>
|
|
398
|
+
|
|
399
|
+
OPTIONS
|
|
400
|
+
--model, -m Model to use (default: gpt-4o)
|
|
401
|
+
--system, -s System prompt
|
|
402
|
+
--iterations Max iterations (default: 10)
|
|
403
|
+
--tools, -t Comma-separated tools (e.g., "firecrawl-search,exa-search")
|
|
404
|
+
--status <id> Check status of a previous run
|
|
405
|
+
--json Output as JSON
|
|
406
|
+
--help, -h Show this help message
|
|
407
|
+
|
|
408
|
+
DESCRIPTION
|
|
409
|
+
Run a full agentic loop with LLM reasoning and tool execution.
|
|
410
|
+
The agent will automatically call tools as needed to complete
|
|
411
|
+
the task.
|
|
412
|
+
|
|
413
|
+
EXAMPLES
|
|
414
|
+
mixrpay run "Find AI startups in SF and summarize their products"
|
|
415
|
+
mixrpay run "Research quantum computing" --model gpt-4o --iterations 15
|
|
416
|
+
mixrpay run --status run_abc123
|
|
417
|
+
`);return}try{let c=await u(e);if(l){let p=await c.getAgentRunStatus(l);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(`
|
|
418
|
+
Run Status: ${p.runId}
|
|
419
|
+
`),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(`
|
|
420
|
+
Response:
|
|
421
|
+
${p.response}`),p.error&&console.log(`
|
|
422
|
+
Error: ${p.error}`));return}o||(console.error("Error: Prompt required."),console.error(`
|
|
423
|
+
Usage: mixrpay run "<prompt>"`),console.error(" mixrpay run --status <run_id>"),process.exit(1)),s||console.log(`Running agent${t?` with ${t}`:""}...
|
|
424
|
+
`);let g=a?a.split(",").map(p=>p.trim()):void 0,m=await c.runAgent({messages:[{role:"user",content:o}],config:{model:t,maxIterations:i,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(`
|
|
425
|
+
---`),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(c){console.error("Agent run failed:",c instanceof Error?c.message:c),process.exit(1);}}async function $e(e){let r=e.json===true;if(e.help||e.h){console.log(`
|
|
426
|
+
mixrpay diagnostics - Run comprehensive diagnostics
|
|
427
|
+
|
|
428
|
+
USAGE
|
|
429
|
+
mixrpay diagnostics [options]
|
|
430
|
+
|
|
431
|
+
OPTIONS
|
|
432
|
+
--json Output as JSON
|
|
433
|
+
--help, -h Show this help message
|
|
434
|
+
|
|
435
|
+
DESCRIPTION
|
|
436
|
+
Runs a comprehensive check of your wallet configuration:
|
|
437
|
+
- Session key validity and expiration
|
|
438
|
+
- API connectivity and latency
|
|
439
|
+
- Balance availability
|
|
440
|
+
- Spending limits
|
|
441
|
+
|
|
442
|
+
EXAMPLES
|
|
443
|
+
mixrpay diagnostics
|
|
444
|
+
mixrpay diagnostics --json
|
|
445
|
+
`);return}try{let s=await u(e);r||console.log(`Running diagnostics...
|
|
446
|
+
`);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"}
|
|
447
|
+
`),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(`
|
|
448
|
+
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(`
|
|
449
|
+
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(`
|
|
450
|
+
Issues:`);for(let t of o.issues)console.log(` - ${t}`);}if(o.recommendations.length>0){console.log(`
|
|
451
|
+
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 Ae(e){let r=e.json===true,s=e.baseUrl||e.url||c;if(e.help||e.h){console.log(`
|
|
452
|
+
mixrpay health - Check MixrPay server health
|
|
453
|
+
|
|
454
|
+
USAGE
|
|
455
|
+
mixrpay health [options]
|
|
456
|
+
|
|
457
|
+
OPTIONS
|
|
458
|
+
--baseUrl, --url Override MixrPay API URL
|
|
459
|
+
--json Output as JSON
|
|
460
|
+
--help, -h Show this help message
|
|
461
|
+
|
|
462
|
+
DESCRIPTION
|
|
463
|
+
Checks the health of the MixrPay server without requiring authentication.
|
|
464
|
+
Useful for debugging connectivity issues.
|
|
465
|
+
|
|
466
|
+
EXAMPLES
|
|
467
|
+
mixrpay health
|
|
468
|
+
mixrpay health --baseUrl https://staging.mixrpay.com
|
|
469
|
+
`);return}r||console.log(`Checking server health at ${s}...
|
|
470
|
+
`);let o=await g.checkServerHealth(s);r?d(o):(console.log(`Server Health
|
|
471
|
+
`),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(`
|
|
472
|
+
Error: ${o.error}`));}async function Ee(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(`
|
|
473
|
+
mixrpay siwe - Generate SIWE (Sign-In with Ethereum) message
|
|
474
|
+
|
|
475
|
+
USAGE
|
|
476
|
+
mixrpay siwe --domain <domain> --uri <uri> [options]
|
|
477
|
+
|
|
478
|
+
OPTIONS
|
|
479
|
+
--domain, -d Domain for SIWE (required)
|
|
480
|
+
--uri, -u URI for SIWE (required)
|
|
481
|
+
--statement, -s Statement to include in message
|
|
482
|
+
--nonce Custom nonce (random if not provided)
|
|
483
|
+
--json Output as JSON
|
|
484
|
+
--help, -h Show this help message
|
|
485
|
+
|
|
486
|
+
DESCRIPTION
|
|
487
|
+
Generates an EIP-4361 compliant SIWE message and signature.
|
|
488
|
+
Use this to authenticate with services that support Sign-In with Ethereum.
|
|
489
|
+
|
|
490
|
+
EXAMPLES
|
|
491
|
+
mixrpay siwe --domain example.com --uri https://example.com/login
|
|
492
|
+
mixrpay siwe -d myapp.com -u https://myapp.com -s "Sign in to My App"
|
|
493
|
+
`);return}(!s||!o)&&(console.error("Error: Domain and URI are required."),console.error(`
|
|
494
|
+
Usage: mixrpay siwe --domain <domain> --uri <uri>`),process.exit(1));try{let a=await(await u(e)).generateSiwe({domain:s,uri:o,statement:t,nonce:n});r?d({message:a.message,signature:a.signature,address:a.address,domain:a.domain,nonce:a.nonce,issued_at:a.issuedAt.toISOString(),expiration_time:a.expirationTime?.toISOString()},!0):(console.log(`
|
|
495
|
+
SIWE Message Generated
|
|
496
|
+
`),console.log("Message:"),console.log("---"),console.log(a.message),console.log("---"),console.log(`
|
|
497
|
+
Signature: ${a.signature}`),console.log(`Address: ${a.address}`),console.log(`Nonce: ${a.nonce}`));}catch(i){console.error("Failed to generate SIWE:",i instanceof Error?i.message:i),process.exit(1);}}async function Ie(e){let r=e.json===true;try{let o=await(await u(e)).listSessions();if(r)d({sessions:o},!0);else if(console.log(`
|
|
498
|
+
Merchant Sessions
|
|
499
|
+
`),o.length===0)console.log("No active sessions found.");else for(let t of o){let n=t.spentUsd??0,i=t.limitUsd??1/0,a=i===1/0?"unlimited":`$${i.toFixed(2)}`,l=t.status||"active";console.log(`${t.merchantName||t.id.slice(0,12)}`),console.log(` ID: ${t.id}`),console.log(` Status: ${l}`),console.log(` Spent: $${n.toFixed(2)} / ${a}`),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 Te(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(`
|
|
500
|
+
Session Statistics
|
|
501
|
+
`),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 Ue(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Session ID required."),console.error(`
|
|
502
|
+
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?`
|
|
503
|
+
Session ${o} revoked successfully.`:`
|
|
504
|
+
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 Oe(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
505
|
+
mixrpay sessions - Manage merchant sessions
|
|
506
|
+
|
|
507
|
+
USAGE
|
|
508
|
+
mixrpay sessions [subcommand] [options]
|
|
509
|
+
|
|
510
|
+
SUBCOMMANDS
|
|
511
|
+
list List active sessions (default)
|
|
512
|
+
stats Show session statistics
|
|
513
|
+
revoke <id> Revoke a session
|
|
514
|
+
|
|
515
|
+
OPTIONS
|
|
516
|
+
--json Output as JSON
|
|
517
|
+
--help, -h Show this help message
|
|
518
|
+
|
|
519
|
+
DESCRIPTION
|
|
520
|
+
Sessions are used when interacting with merchants that support
|
|
521
|
+
session-based billing (like x402 merchants).
|
|
522
|
+
|
|
523
|
+
EXAMPLES
|
|
524
|
+
mixrpay sessions
|
|
525
|
+
mixrpay sessions stats
|
|
526
|
+
mixrpay sessions revoke sk_abc123...
|
|
527
|
+
`);return}switch(s){case "stats":await Te(e);break;case "revoke":await Ue(e,r.slice(1));break;case "list":case void 0:default:await Ie(e);break}}async function Pe(e){let r=e.json===true;try{let o=await(await u(e)).listMCPTools();if(r)d({tools:o},!0);else if(console.log(`
|
|
528
|
+
MCP Tools
|
|
529
|
+
`),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(`
|
|
530
|
+
Total: ${o.length} tools`);}}catch(s){console.error("Failed to list MCP tools:",s instanceof Error?s.message:s),process.exit(1);}}async function Re(e,r){let s=e.json===true,o=r[0],t=r[1]||"{}";o||(console.error("Error: Tool name required."),console.error(`
|
|
531
|
+
Usage: mixrpay mcp call <tool_name> '{"arg":"value"}'`),process.exit(1));let n=R(t,"Invalid JSON arguments");try{let a=await(await u(e)).callMCPTool(o,n);s?d(a,!0):(console.log(`
|
|
532
|
+
MCP Tool Result
|
|
533
|
+
`),a.chargedUsd&&console.log(`Cost: $${a.chargedUsd.toFixed(4)}`),console.log("Result:"),console.log(JSON.stringify(a.content,null,2)));}catch(i){console.error("MCP tool call failed:",i instanceof Error?i.message:i),process.exit(1);}}async function _e(e,r){let s=e.json===true,o=r[0]||e.id||e.glamaId,t=e.namespace||e.ns,n=e.slug,i=e.name||e.n,a=e.description,l=e.ttl,c=e.env;(!o||!t||!n||!i)&&(console.error("Error: Glama ID, namespace, slug, and tool name are required."),console.error(`
|
|
534
|
+
Usage: mixrpay mcp deploy <glama_id> --namespace <ns> --slug <slug> --name <tool_name>`),console.error(`
|
|
535
|
+
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;c&&(g=R(c,"Invalid JSON for --env"));let m=l?parseInt(l,10):void 0;try{let p=await u(e);s||console.log(`
|
|
536
|
+
Deploying MCP server: ${i}...
|
|
537
|
+
`);let h=await p.deployJitMcp({glamaId:o,glamaNamespace:t,glamaSlug:n,toolName:i,toolDescription:a,envVars:g,ttlHours:m}),y=h.instance;s?d({instance_id:y.instanceId,tool_name:y.toolName,status:y.status,endpoint_url:y.endpointUrl,expires_at:y.expiresAt?.toISOString(),payment:h.payment},!0):(console.log(`MCP Server Deployed!
|
|
538
|
+
`),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()}`),h.payment?.amountUsd&&console.log(`Cost: $${h.payment.amountUsd.toFixed(2)}`));}catch(p){console.error("Failed to deploy MCP server:",p instanceof Error?p.message:p),process.exit(1);}}async function Ne(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(`
|
|
539
|
+
JIT MCP Instances
|
|
540
|
+
`),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 Ce(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Instance ID required."),console.error(`
|
|
541
|
+
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(`
|
|
542
|
+
Instance ${o} stopped.`);}catch(t){console.error("Failed to stop instance:",t instanceof Error?t.message:t),process.exit(1);}}async function je(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Instance ID required."),console.error(`
|
|
543
|
+
Usage: mixrpay mcp status <instance_id>`),process.exit(1));try{let n=await(await u(e)).getJitInstance(o);s?d(n,!0):(console.log(`
|
|
544
|
+
MCP Instance: ${n.id}
|
|
545
|
+
`),console.log(`Tool: ${n.toolName}`),console.log(`Status: ${n.status}`),console.log(`Glama: ${n.glamaNamespace}/${n.glamaSlug}`),n.endpointUrl&&console.log(`Endpoint: ${b(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 De(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(`
|
|
546
|
+
MCP Server Configuration
|
|
547
|
+
`),console.log(`Command: ${o.command} ${o.args?.join(" ")||""}`),console.log(`
|
|
548
|
+
Environment variables (masked):`);for(let[t,n]of Object.entries(o.env||{}))console.log(` ${t}=${n?.slice(0,16)}...`);console.log(`
|
|
549
|
+
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(`
|
|
550
|
+
mixrpay mcp - Manage MCP (Model Context Protocol) servers
|
|
551
|
+
|
|
552
|
+
USAGE
|
|
553
|
+
mixrpay mcp [subcommand] [options]
|
|
554
|
+
|
|
555
|
+
SUBCOMMANDS
|
|
556
|
+
list List available MCP tools
|
|
557
|
+
call <tool> '{}' Call an MCP tool
|
|
558
|
+
deploy <id> Deploy a JIT MCP server (advanced)
|
|
559
|
+
instances List deployed instances
|
|
560
|
+
stop <id> Stop an instance
|
|
561
|
+
status <id> Get instance status
|
|
562
|
+
config Show MCP subprocess config
|
|
563
|
+
|
|
564
|
+
DEPLOY OPTIONS
|
|
565
|
+
--namespace, --ns Glama namespace (required)
|
|
566
|
+
--slug Glama slug (required)
|
|
567
|
+
--name, -n Tool name (required)
|
|
568
|
+
--description Tool description
|
|
569
|
+
--ttl TTL in hours (default: 24)
|
|
570
|
+
--env Environment vars as JSON
|
|
571
|
+
|
|
572
|
+
OTHER OPTIONS
|
|
573
|
+
--status Filter instances by status
|
|
574
|
+
--json Output as JSON
|
|
575
|
+
--help, -h Show this help message
|
|
576
|
+
|
|
577
|
+
DESCRIPTION
|
|
578
|
+
MCP allows you to deploy and use Model Context Protocol servers
|
|
579
|
+
on-demand. For pre-configured integrations, use 'mixrpay skills' instead.
|
|
580
|
+
|
|
581
|
+
EXAMPLES
|
|
582
|
+
mixrpay mcp list
|
|
583
|
+
mixrpay mcp call firecrawl-search '{"query":"AI news"}'
|
|
584
|
+
mixrpay mcp instances
|
|
585
|
+
mixrpay mcp status inst_abc123
|
|
586
|
+
mixrpay mcp stop inst_abc123
|
|
587
|
+
|
|
588
|
+
# Deploy custom MCP (advanced - prefer 'skills' for common integrations)
|
|
589
|
+
mixrpay mcp deploy notion-mcp --namespace notion --slug notion-mcp --name "Notion"
|
|
590
|
+
`);return}switch(s){case "call":await Re(e,r.slice(1));break;case "deploy":await _e(e,r.slice(1));break;case "instances":await Ne(e);break;case "stop":await Ce(e,r.slice(1));break;case "status":await je(e,r.slice(1));break;case "config":await De(e);break;case "list":case void 0:default:await Pe(e);break}}async function Fe(e){let r=e.json===true;try{let o=await(await u(e)).listSkills();if(r)d({skills:o},!0);else if(console.log(`
|
|
591
|
+
Available Skills
|
|
592
|
+
`),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 Le(e,r){let s=e.json===true,o=r[0]||e.id,t=e.ttl;o||(console.error("Error: Skill ID required."),console.error(`
|
|
593
|
+
Usage: mixrpay skills use <skill_id>`),console.error(`
|
|
594
|
+
This deploys a JIT MCP server for the skill.`),process.exit(1));let n=t?parseInt(t,10):void 0;try{let i=await u(e);s||console.log(`
|
|
595
|
+
Deploying skill: ${o}...
|
|
596
|
+
`);let a=await i.useSkill(o,{ttlHours:n});s?d(a,!0):(console.log(`Skill Deployed!
|
|
597
|
+
`),console.log(`Skill ID: ${a.skillId}`),console.log(`Instance ID: ${a.instanceId}`),console.log(`Endpoint: ${b(a.endpoint)}`),console.log(`Tools: ${a.tools.join(", ")}`),console.log(`Expires: ${a.expiresAt.toLocaleString()}`));}catch(i){console.error("Failed to use skill:",i instanceof Error?i.message:i),process.exit(1);}}async function qe(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Skill ID required."),console.error(`
|
|
598
|
+
Usage: mixrpay skills status <skill_id>`),process.exit(1));try{let n=await(await u(e)).getSkillStatus(o);s?d(n,!0):(console.log(`
|
|
599
|
+
Skill Status: ${n.skillId}
|
|
600
|
+
`),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(`
|
|
601
|
+
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 Ke(e){let r=e.json===true;try{let o=await(await u(e)).getConnectedApps();if(r)d(o,!0);else if(console.log(`
|
|
602
|
+
Connected Apps
|
|
603
|
+
`),o.connected.length===0)console.log("No connected apps."),console.log(`
|
|
604
|
+
Visit your dashboard to connect apps.`);else {console.log(`Connected: ${o.connected.join(", ")}
|
|
605
|
+
`);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 Be(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
606
|
+
mixrpay skills - Manage connected app skills
|
|
607
|
+
|
|
608
|
+
USAGE
|
|
609
|
+
mixrpay skills [subcommand] [options]
|
|
610
|
+
|
|
611
|
+
SUBCOMMANDS
|
|
612
|
+
list List available skills (default)
|
|
613
|
+
use <id> Use a skill (deploy JIT MCP)
|
|
614
|
+
status <id> Get skill status
|
|
615
|
+
apps List connected apps
|
|
616
|
+
|
|
617
|
+
OPTIONS
|
|
618
|
+
--json Output as JSON
|
|
619
|
+
--help, -h Show this help message
|
|
620
|
+
|
|
621
|
+
DESCRIPTION
|
|
622
|
+
Skills are pre-configured MCP servers for connected apps like
|
|
623
|
+
GitHub, Slack, and Notion. They require OAuth setup in your dashboard.
|
|
624
|
+
|
|
625
|
+
EXAMPLES
|
|
626
|
+
mixrpay skills
|
|
627
|
+
mixrpay skills apps
|
|
628
|
+
mixrpay skills use github
|
|
629
|
+
mixrpay skills status github
|
|
630
|
+
`);return}switch(s){case "use":await Le(e,r.slice(1));break;case "status":await qe(e,r.slice(1));break;case "apps":await Ke(e);break;case "list":case void 0:default:await Fe(e);break}}async function We(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,i=e.budget||e.b,a=e.ttl,l=e.iterations,c=e.tools||e.t,g=e.auto===true;(!s||!o||!i)&&(console.error("Error: Name, prompt, and budget are required."),console.error(`
|
|
631
|
+
Usage: mixrpay agent deploy --name "Agent" --prompt "Task..." --budget 5.00`),process.exit(1));let m=parseFloat(i);(isNaN(m)||m<=0)&&(console.error("Error: Invalid budget. Must be a positive number."),process.exit(1));let p=a?parseInt(a,10):void 0,h=l?parseInt(l,10):void 0,y=c?c.split(",").map(x=>x.trim()):void 0;try{let x=await u(e);r||console.log(`
|
|
632
|
+
Deploying task agent: ${s}...
|
|
633
|
+
`);let v=await x.deployTaskAgent({name:s,prompt:o,systemPrompt:t,model:n,budgetUsd:m,ttlHours:p,maxIterations:h,tools:y,autoRun:g}),f=v.instance;r?d({instance_id:f.id,name:f.name,status:f.status,budget_usd:f.budgetUsd,idempotent:v.idempotent},!0):(console.log(`Task Agent Deployed!
|
|
634
|
+
`),console.log(`Instance ID: ${f.id}`),console.log(`Name: ${f.name}`),console.log(`Status: ${f.status}`),console.log(`Budget: $${f.budgetUsd.toFixed(2)}`),v.idempotent&&console.log("(Idempotent return - existing instance)"),console.log(`
|
|
635
|
+
Commands:`),console.log(` mixrpay agent trigger ${f.id} # Start the agent`),console.log(` mixrpay agent status ${f.id} # Check status`),console.log(` mixrpay agent wait ${f.id} # Wait for completion`));}catch(x){console.error("Failed to deploy agent:",x instanceof Error?x.message:x),process.exit(1);}}async function Ge(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(`
|
|
636
|
+
Task Agents
|
|
637
|
+
`);let i=n.taskAgents||[];if(i.length===0)console.log("No task agents found."),console.log("\nUse `mixrpay agent deploy` to create one.");else {for(let a of i){let l=a.budget?.spentUsd??0,c=a.budget?.totalUsd??0,g=a.iterations?.current??0;console.log(`${a.name||a.id}`),console.log(` ID: ${a.id}`),console.log(` Status: ${a.status}`),console.log(` Budget: $${l.toFixed(2)} / $${c.toFixed(2)}`),console.log(` Iterations: ${g}/${a.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 Je(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Instance ID required."),console.error(`
|
|
638
|
+
Usage: mixrpay agent status <instance_id>`),process.exit(1));try{let n=await(await u(e)).getTaskAgentStatus(o);s?d(n,!0):(console.log(`
|
|
639
|
+
Task Agent: ${n.id}
|
|
640
|
+
`),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 Xe(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Instance ID required."),console.error(`
|
|
641
|
+
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(`
|
|
642
|
+
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 He(e,r){let s=e.json===true,o=r[0]||e.id;o||(console.error("Error: Instance ID required."),console.error(`
|
|
643
|
+
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(`
|
|
644
|
+
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 Ye(e,r){let s=e.json===true,o=r[0]||e.id,t=e.timeout;o||(console.error("Error: Instance ID required."),console.error(`
|
|
645
|
+
Usage: mixrpay agent wait <instance_id>`),process.exit(1));let n=t?parseInt(t,10)*1e3:void 0;try{let i=await u(e);s||console.log(`
|
|
646
|
+
Waiting for agent ${o}...`);let a=await i.waitForTaskAgent(o,{timeoutMs:n});s?d(a,!0):(console.log(`
|
|
647
|
+
Agent completed!`),console.log(`Status: ${a.status}`),console.log(`Iterations: ${a.iterations}`),console.log(`Tool calls: ${a.toolCalls}`),console.log(`Cost: $${(a.spentUsd||0).toFixed(4)}`),a.result&&(console.log(`
|
|
648
|
+
Result:`),console.log(a.result)),a.error&&console.log(`
|
|
649
|
+
Error:`,a.error));}catch(i){console.error("Wait failed:",i instanceof Error?i.message:i),process.exit(1);}}async function Ve(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
650
|
+
mixrpay agent - Manage task agents
|
|
651
|
+
|
|
652
|
+
USAGE
|
|
653
|
+
mixrpay agent [subcommand] [options]
|
|
654
|
+
|
|
655
|
+
SUBCOMMANDS
|
|
656
|
+
deploy Deploy a new task agent
|
|
657
|
+
list List task agents (default)
|
|
658
|
+
status <id> Get agent status
|
|
659
|
+
trigger <id> Trigger agent execution
|
|
660
|
+
cancel <id> Cancel agent
|
|
661
|
+
wait <id> Wait for agent completion
|
|
662
|
+
|
|
663
|
+
DEPLOY OPTIONS
|
|
664
|
+
--name, -n Agent name (required)
|
|
665
|
+
--prompt, -p Task prompt (required)
|
|
666
|
+
--budget, -b Budget in USD (required)
|
|
667
|
+
--system, -s System prompt
|
|
668
|
+
--model, -m Model (default: claude-sonnet-4-5)
|
|
669
|
+
--ttl TTL in hours (default: 24)
|
|
670
|
+
--iterations Max iterations (default: 10)
|
|
671
|
+
--tools, -t Comma-separated tool list
|
|
672
|
+
--auto Auto-run after deploy
|
|
673
|
+
|
|
674
|
+
OPTIONS
|
|
675
|
+
--status Filter by status (for list)
|
|
676
|
+
--limit Limit results (for list)
|
|
677
|
+
--timeout Wait timeout in seconds
|
|
678
|
+
--json Output as JSON
|
|
679
|
+
--help, -h Show this help message
|
|
680
|
+
|
|
681
|
+
EXAMPLES
|
|
682
|
+
mixrpay agent deploy --name "Researcher" --prompt "Find AI papers" --budget 5.00
|
|
683
|
+
mixrpay agent list
|
|
684
|
+
mixrpay agent status inst_abc123
|
|
685
|
+
mixrpay agent trigger inst_abc123
|
|
686
|
+
mixrpay agent wait inst_abc123
|
|
687
|
+
`);return}switch(s){case "deploy":await We(e);break;case "status":await Je(e,r.slice(1));break;case "trigger":await Xe(e,r.slice(1));break;case "cancel":await He(e,r.slice(1));break;case "wait":await Ye(e,r.slice(1));break;case "list":case void 0:default:await Ge(e);break}}async function ze(e,r){if(e.help||e.h||r.length===0){console.log(`
|
|
688
|
+
mixrpay tool - Call MixrPay gateway tools
|
|
689
|
+
|
|
690
|
+
USAGE
|
|
691
|
+
mixrpay tool <provider> <tool_name> '<json_arguments>'
|
|
692
|
+
mixrpay tool list
|
|
693
|
+
|
|
694
|
+
For full documentation, run: npx mixrpay-tool --help
|
|
695
|
+
|
|
696
|
+
QUICK EXAMPLES
|
|
697
|
+
# Web search
|
|
698
|
+
mixrpay tool firecrawl firecrawl-search '{"query":"AI agents"}'
|
|
699
|
+
|
|
700
|
+
# Brave search
|
|
701
|
+
mixrpay tool brave brave-search '{"q":"latest news"}'
|
|
702
|
+
|
|
703
|
+
# Send email
|
|
704
|
+
mixrpay tool agentmail agentmail-send '{"inbox_id":"...","to":["..."],"subject":"...","text":"..."}'
|
|
705
|
+
`);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 Qe(e,r){if(e.help||e.h||r.length===0){console.log(`
|
|
706
|
+
mixrpay search - Quick web search
|
|
707
|
+
|
|
708
|
+
USAGE
|
|
709
|
+
mixrpay search "<query>"
|
|
710
|
+
|
|
711
|
+
OPTIONS
|
|
712
|
+
--provider, -p Search provider: firecrawl, exa, tavily (default: firecrawl)
|
|
713
|
+
--json Output raw JSON
|
|
714
|
+
--help, -h Show this help message
|
|
715
|
+
|
|
716
|
+
EXAMPLES
|
|
717
|
+
mixrpay search "AI agent frameworks 2026"
|
|
718
|
+
mixrpay search "best DeFi yields" --provider exa
|
|
719
|
+
`);return}let s=r.join(" "),o=e.provider||e.p||"firecrawl",t=e.json===true,n=await Ze();n||(console.error("Error: No valid agent token found."),console.error(`
|
|
720
|
+
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(`
|
|
721
|
+
To fix this:`),console.error(' mixrpay register --mode invite --invite-code <code> --name "My Agent"'),process.exit(1));let i=o==="exa"?"exa-search":o==="tavily"?"tavily-search":"firecrawl-search";t||console.log(`Searching with ${o}...`);try{let a={provider:o,tool_name:i,arguments:{query:s}},l;if(n.isSelfFunded){let h=b$1();(!h.success||!h.credentials?.privateKey)&&(console.error("Error: Private key not found in credentials."),console.error("Run `mixrpay init` to set up a self-funded wallet."),process.exit(1));let y=h.credentials.privateKey;t||console.log(" Getting price quote...");let x=await fetch(`${n.baseUrl}/api/v2/agent/tool-quote?tool=${i}`);if(!x.ok){let K=await x.json().catch(()=>({}));throw new Error(K.error||"Failed to get tool quote")}let v=await x.json(),f=v.price_usd,T=v.platform_address;t||(console.log(` Tool cost: $${f.toFixed(4)}`),console.log(" Sending payment..."));let O=privateKeyToAccount(y),U=createWalletClient({account:O,chain:base,transport:http()}),$=createPublicClient({chain:base,transport:http()}),F="0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",L=parseUnits(f.toString(),6),q=encodeFunctionData({abi:[{name:"transfer",type:"function",inputs:[{name:"to",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],functionName:"transfer",args:[T,L]}),P=await U.sendTransaction({to:F,data:q});if(t||(console.log(` Payment sent: ${P.slice(0,10)}...`),console.log(" Waiting for confirmation...")),(await $.waitForTransactionReceipt({hash:P,timeout:6e4})).status!=="success")throw new Error("Payment transaction failed");l=P,a.pay_from="own",a.payment_tx_hash=l,t||(console.log(" Payment confirmed!"),console.log(` Executing search...
|
|
722
|
+
`));}let c=new AbortController,g=setTimeout(()=>c.abort(),3e4),m=await fetch(`${n.baseUrl}/api/v2/agent/call-tool`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.token}`},body:JSON.stringify(a),signal:c.signal});clearTimeout(g);let p=await m.json().catch(()=>({error:"Invalid response from server"}));if(m.ok||(console.error(`Search failed: ${p.error||"Unknown error"}`),l&&(console.error(`
|
|
723
|
+
Note: Payment was sent (tx: ${l})`),console.error("Contact support if you need a refund.")),process.exit(1)),t){let h={...p,...l?{payment_tx_hash:l}:{}};console.log(JSON.stringify(h,null,2));}else p.charged_usd&&console.log(`Cost: $${p.charged_usd.toFixed(4)}`),l&&console.log(`Payment: ${l}`),console.log(`Latency: ${p.latency_ms}ms
|
|
724
|
+
`),console.log("Results:"),console.log(JSON.stringify(p.data,null,2));}catch(a){a instanceof Error&&a.name==="AbortError"?console.error("Search timed out after 30 seconds."):console.error("Search failed:",a instanceof Error?a.message:a),process.exit(1);}}async function Ze(){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)){let o=!!process.env.AGENT_WALLET_KEY||!!process.env.MIXRPAY_WALLET_KEY;return {token:s,baseUrl:process.env.MIXRPAY_BASE_URL||c,isSelfFunded:o}}}let r=b$1();if(r.success&&r.credentials){let s=r.credentials;if(s.apiToken&&e(s.apiToken)){let o=!!s.privateKey;return {token:s.apiToken,baseUrl:s.baseUrl||c,isSelfFunded:o}}}return null}async function eo(e){let r=e.json===true,s=e.title||e.t,o=e.description||e.d,t=e.budget||e.b,n=e.expires,i=e.category,a=e.deliverables?.split(",").map(c=>c.trim());(!s||!o||!t)&&(console.error("Error: Title, description, and budget are required."),console.error(`
|
|
725
|
+
Usage: mixrpay task create --title "Task" --description "..." --budget 10.00`),process.exit(1));let l=parseFloat(t);(isNaN(l)||l<=0)&&(console.error("Error: Invalid budget."),process.exit(1));try{let g=await(await u(e)).createTask({title:s,description:o,budgetUsd:l,expiresInDays:n?parseInt(n,10):void 0,category:i,deliverables:a});r?d(g,!0):(console.log(`
|
|
726
|
+
Task Created!
|
|
727
|
+
`),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(c){console.error("Failed to create task:",c instanceof Error?c.message:c),process.exit(1);}}async function oo(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(`
|
|
728
|
+
Task Board
|
|
729
|
+
`);let i=n.tasks||[];if(i.length===0)console.log("No tasks found.");else {for(let a of i)console.log(`${a.title}`),console.log(` ID: ${a.taskId}`),console.log(` Status: ${a.status}`),console.log(` Budget: $${(a.budgetUsd||0).toFixed(2)}`),console.log("");console.log(`Total: ${n.total||i.length}`);}}}catch(t){console.error("Failed to list tasks:",t instanceof Error?t.message:t),process.exit(1);}}async function to(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(`
|
|
730
|
+
Task: ${n.title}
|
|
731
|
+
`),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 so(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(`
|
|
732
|
+
My Tasks
|
|
733
|
+
`),n.tasks.length===0)console.log("No assigned tasks."),console.log("\nUse `mixrpay task request <id>` to request a task.");else {for(let i of n.tasks)console.log(`${i.title}`),console.log(` ID: ${i.id}`),console.log(` Status: ${i.status}`),console.log(` Budget: $${(i.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 no(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 i=await(await u(e)).requestTask(o,t);s?d(i,!0):(console.log(`
|
|
734
|
+
Task ${o} requested.`),console.log(`Request ID: ${i.id}`),console.log(`Status: ${i.status}`));}catch(n){console.error("Failed to request task:",n instanceof Error?n.message:n),process.exit(1);}}async function ro(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(`
|
|
735
|
+
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(`
|
|
736
|
+
Task ${o} submitted successfully.`);}catch(i){console.error("Failed to submit task:",i instanceof Error?i.message:i),process.exit(1);}}async function io(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(`
|
|
737
|
+
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 ao(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(`
|
|
738
|
+
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 lo(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(`
|
|
739
|
+
Task ${o} cancelled.`);}catch(t){console.error("Failed to cancel task:",t instanceof Error?t.message:t),process.exit(1);}}async function co(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
740
|
+
mixrpay task - Manage the task board
|
|
741
|
+
|
|
742
|
+
USAGE
|
|
743
|
+
mixrpay task [subcommand] [options]
|
|
744
|
+
|
|
745
|
+
SUBCOMMANDS
|
|
746
|
+
create Create a new task
|
|
747
|
+
list List tasks (default)
|
|
748
|
+
get <id> Get task details
|
|
749
|
+
mine Show my assigned tasks
|
|
750
|
+
request <id> Request to work on a task
|
|
751
|
+
submit <id> Submit task output
|
|
752
|
+
approve <id> Approve task submission
|
|
753
|
+
reject <id> Reject task submission
|
|
754
|
+
cancel <id> Cancel a task
|
|
755
|
+
|
|
756
|
+
CREATE OPTIONS
|
|
757
|
+
--title, -t Task title (required)
|
|
758
|
+
--description, -d Task description (required)
|
|
759
|
+
--budget, -b Budget in USD (required)
|
|
760
|
+
--deadline Deadline (ISO date)
|
|
761
|
+
--skills Required skills (comma-separated)
|
|
762
|
+
|
|
763
|
+
SUBMIT OPTIONS
|
|
764
|
+
--output, -o Output/result (required)
|
|
765
|
+
--artifacts Artifact URLs (comma-separated)
|
|
766
|
+
|
|
767
|
+
OPTIONS
|
|
768
|
+
--status Filter by status
|
|
769
|
+
--limit Limit results
|
|
770
|
+
--message Optional message (for request)
|
|
771
|
+
--feedback Optional feedback (for approve/reject)
|
|
772
|
+
--reason, -r Rejection reason (required for reject)
|
|
773
|
+
--json Output as JSON
|
|
774
|
+
--help, -h Show this help message
|
|
775
|
+
|
|
776
|
+
EXAMPLES
|
|
777
|
+
mixrpay task create --title "Research" --description "Find papers" --budget 5.00
|
|
778
|
+
mixrpay task list --status open
|
|
779
|
+
mixrpay task request task_abc123
|
|
780
|
+
mixrpay task submit task_abc123 --output "Found 10 papers..."
|
|
781
|
+
mixrpay task approve task_abc123
|
|
782
|
+
`);return}switch(s){case "create":await eo(e);break;case "get":await to(e,r.slice(1));break;case "mine":await so(e);break;case "request":await no(e,r.slice(1));break;case "submit":await ro(e,r.slice(1));break;case "approve":await io(e,r.slice(1));break;case "reject":await ao(e,r.slice(1));break;case "cancel":await lo(e,r.slice(1));break;case "list":case void 0:default:await oo(e);break}}async function uo(e){let r=e.json===true;try{let o=await(await u(e)).getBalances();if(r)d(o,!0);else {console.log(`
|
|
783
|
+
Token Balances
|
|
784
|
+
`),console.log(`Wallet: ${o.wallet_address}`),console.log(`Chain: ${o.chain} (${o.chain_id})
|
|
785
|
+
`);let t=Object.entries(o.balances);if(t.length===0)console.log("No token balances found.");else for(let[n,i]of t)console.log(`${n}: ${i.balance}`);o.delegation&&(console.log(`
|
|
786
|
+
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 go(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(`
|
|
787
|
+
Usage: mixrpay defi transfer <to> <amount> --token USDC`),process.exit(1));let i=parseFloat(t);(isNaN(i)||i<=0)&&(console.error("Error: Invalid amount."),process.exit(1));try{let a=await u(e);s||console.log(`
|
|
788
|
+
Transferring ${i} ${n} to ${o.slice(0,10)}...`);let l=await a.transfer(o,i.toString(),n);s?d(l,!0):(console.log(`Transfer complete!
|
|
789
|
+
`),console.log(`TX Hash: ${l.tx_hash}`),console.log(`Amount: ${i} ${n}`));}catch(a){console.error("Transfer failed:",a instanceof Error?a.message:a),process.exit(1);}}async function po(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(`
|
|
790
|
+
Usage: mixrpay defi swap --sell ETH --buy USDC --amount 0.1`),process.exit(1));try{let i=await u(e);r||console.log(`
|
|
791
|
+
Swapping ${t} ${s} \u2192 ${o}...`);let a=n?parseInt(n,10):void 0,l=await i.swap(s,o,t,a);r?d(l,!0):(console.log(`Swap complete!
|
|
792
|
+
`),console.log(`TX Hash: ${l.tx_hash}`),console.log(`Sold: ${l.sell_amount} ${s}`),console.log(`Received: ${l.buy_amount} ${o}`));}catch(i){console.error("Swap failed:",i instanceof Error?i.message:i),process.exit(1);}}async function mo(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(`
|
|
793
|
+
Usage: mixrpay defi bridge --amount 100 --to arbitrum`),console.error(`
|
|
794
|
+
Note: Bridges FROM Base to the destination chain.`),process.exit(1));try{let i=await u(e);r||console.log(`
|
|
795
|
+
Bridging ${o} ${s} from Base \u2192 ${t}...`);let a=await i.bridge(s,o,t,n?{destAddress:n}:void 0);r?d(a,!0):(console.log(`Bridge initiated!
|
|
796
|
+
`),console.log(`Order ID: ${a.order_id}`),console.log(`TX Hash: ${a.tx_hash}`),console.log(`Estimated receive: ${a.estimated_receive}`),console.log("\nUse `mixrpay defi bridge-status <order_id>` to check status."));}catch(i){console.error("Bridge failed:",i instanceof Error?i.message:i),process.exit(1);}}async function yo(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(`
|
|
797
|
+
Payment History (Current Session)
|
|
798
|
+
`),o.length===0)console.log("No payments in current session."),console.log(`
|
|
799
|
+
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(),i=t.type||"payment";console.log(`${n} | ${i.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 fo(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
800
|
+
mixrpay defi - DeFi operations
|
|
801
|
+
|
|
802
|
+
USAGE
|
|
803
|
+
mixrpay defi [subcommand] [options]
|
|
804
|
+
|
|
805
|
+
SUBCOMMANDS
|
|
806
|
+
balances Show token balances (default)
|
|
807
|
+
transfer <to> <amount> Transfer tokens
|
|
808
|
+
swap Swap tokens
|
|
809
|
+
bridge Bridge tokens between chains
|
|
810
|
+
history Transaction history
|
|
811
|
+
|
|
812
|
+
TRANSFER OPTIONS
|
|
813
|
+
--token Token symbol (default: USDC)
|
|
814
|
+
|
|
815
|
+
SWAP OPTIONS
|
|
816
|
+
--sell Token to sell (required)
|
|
817
|
+
--buy Token to buy (required)
|
|
818
|
+
--amount, -a Amount to sell (required)
|
|
819
|
+
--slippage Slippage in bps (default: 100)
|
|
820
|
+
|
|
821
|
+
BRIDGE OPTIONS
|
|
822
|
+
--token Token symbol (default: USDC)
|
|
823
|
+
--amount, -a Amount to bridge (required)
|
|
824
|
+
--to, --dest Destination chain (required, e.g., arbitrum, ethereum)
|
|
825
|
+
--address Custom destination address (optional)
|
|
826
|
+
|
|
827
|
+
OPTIONS
|
|
828
|
+
--json Output as JSON
|
|
829
|
+
--help, -h Show this help message
|
|
830
|
+
|
|
831
|
+
NOTE
|
|
832
|
+
Bridge always moves tokens FROM Base to the destination chain.
|
|
833
|
+
|
|
834
|
+
EXAMPLES
|
|
835
|
+
mixrpay defi balances
|
|
836
|
+
mixrpay defi transfer 0x123... 10.00 --token USDC
|
|
837
|
+
mixrpay defi swap --sell ETH --buy USDC --amount 0.1
|
|
838
|
+
mixrpay defi bridge --amount 100 --to arbitrum
|
|
839
|
+
`);return}switch(s){case "transfer":await go(e,r.slice(1));break;case "swap":await po(e);break;case "bridge":await mo(e);break;case "history":await yo(e);break;case "balances":case void 0:default:await uo(e);break}}async function ho(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,i=e.approval===true;(!s||!o)&&(console.error("Error: Title and steps are required."),console.error(`
|
|
840
|
+
Usage: mixrpay plan submit --title "Plan" --steps '[...]'`),process.exit(1));let a=H(o,"Invalid JSON for steps"),l=t?parseFloat(t):void 0;try{let g=await(await u(e)).submitPlan({title:s,description:n,steps:a,totalEstimatedCostUsd:l,requiresApproval:i});r?d(g,!0):(console.log(`
|
|
841
|
+
Plan Submitted!
|
|
842
|
+
`),console.log(`Plan ID: ${g.planId}`),console.log(`Status: ${g.status}`),g.approvalUrl&&console.log(`Approval URL: ${g.approvalUrl}`));}catch(c){console.error("Failed to submit plan:",c instanceof Error?c.message:c),process.exit(1);}}async function wo(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 i=n.steps?.filter(l=>l.status==="completed").length||0,a=n.steps?.length||0;if(console.log(`
|
|
843
|
+
Plan: ${n.title||o}
|
|
844
|
+
`),console.log(`Status: ${n.status}`),console.log(`Progress: ${i}/${a} steps`),n.totalEstimatedCostUsd&&console.log(`Estimated cost: $${n.totalEstimatedCostUsd.toFixed(2)}`),n.steps&&n.steps.length>0){console.log(`
|
|
845
|
+
Steps:`);for(let l of n.steps){let c=l.status==="completed"?"\u2713":l.status==="running"?"\u2192":"\u25CB";console.log(` ${c} ${l.action} (${l.status})`);}}}}catch(t){console.error("Failed to get plan status:",t instanceof Error?t.message:t),process.exit(1);}}async function xo(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(`
|
|
846
|
+
Plans
|
|
847
|
+
`);let n=t.plans||[];if(n.length===0)console.log("No plans found.");else {for(let i of n)console.log(`${i.title}`),console.log(` ID: ${i.planId}`),console.log(` Status: ${i.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 So(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(`
|
|
848
|
+
Executing plan ${o}...`);let n=await t.executePlan(o);s?d(n,!0):(console.log(`Plan execution started!
|
|
849
|
+
`),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 bo(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 i=await u(e);s||console.log(`
|
|
850
|
+
Waiting for plan ${o}...`);let a=await i.waitForPlanCompletion(o,{timeoutMs:n});if(s)d(a,!0);else {let l=a.steps?.filter(g=>g.status==="completed").length||0,c=a.steps?.length||0;console.log(`
|
|
851
|
+
Plan completed!
|
|
852
|
+
`),console.log(`Status: ${a.status}`),console.log(`Steps: ${l}/${c}`);}}catch(i){console.error("Wait failed:",i instanceof Error?i.message:i),process.exit(1);}}async function ko(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
853
|
+
mixrpay plan - Manage multi-step plans
|
|
854
|
+
|
|
855
|
+
USAGE
|
|
856
|
+
mixrpay plan [subcommand] [options]
|
|
857
|
+
|
|
858
|
+
SUBCOMMANDS
|
|
859
|
+
submit Submit a new plan
|
|
860
|
+
list List plans (default)
|
|
861
|
+
status <id> Get plan status
|
|
862
|
+
execute <id> Execute a plan
|
|
863
|
+
wait <id> Wait for plan completion
|
|
864
|
+
|
|
865
|
+
SUBMIT OPTIONS
|
|
866
|
+
--name, -n Plan name (required)
|
|
867
|
+
--steps, -s Steps as JSON array (required)
|
|
868
|
+
--budget, -b Budget in USD
|
|
869
|
+
--description Plan description
|
|
870
|
+
|
|
871
|
+
OPTIONS
|
|
872
|
+
--status Filter by status
|
|
873
|
+
--timeout Wait timeout in seconds
|
|
874
|
+
--json Output as JSON
|
|
875
|
+
--help, -h Show this help message
|
|
876
|
+
|
|
877
|
+
EXAMPLES
|
|
878
|
+
mixrpay plan submit --name "Research" --steps '[{"action":"search","params":{"q":"AI"}}]'
|
|
879
|
+
mixrpay plan list
|
|
880
|
+
mixrpay plan execute plan_abc123
|
|
881
|
+
mixrpay plan wait plan_abc123
|
|
882
|
+
`);return}switch(s){case "submit":await ho(e);break;case "status":await wo(e,r.slice(1));break;case "execute":await So(e,r.slice(1));break;case "wait":await bo(e,r.slice(1));break;case "list":case void 0:default:await xo(e);break}}async function vo(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(`
|
|
883
|
+
Usage: mixrpay approval request --action "transfer" --context "Send $10 to Bob"`),process.exit(1));let i={};t&&(i=R(t,"Invalid JSON for payload"));try{let l=await(await u(e)).requestApproval({actionType:s,actionPayload:i,context:o,expiresInHours:n?parseInt(n,10):void 0});r?d(l,!0):"autoApproved"in l&&l.autoApproved?(console.log(`
|
|
884
|
+
Auto-approved!
|
|
885
|
+
`),console.log(`Reason: ${l.reason}`)):"id"in l&&(console.log(`
|
|
886
|
+
Approval Request Created!
|
|
887
|
+
`),console.log(`Approval ID: ${l.id}`),console.log(`Status: ${l.status}`),l.expiresAt&&console.log(`Expires: ${l.expiresAt.toLocaleString()}`),console.log(`
|
|
888
|
+
Waiting for human approval...`),console.log(`Use \`mixrpay approval wait ${l.id}\` to wait.`));}catch(a){console.error("Failed to request approval:",a instanceof Error?a.message:a),process.exit(1);}}async function $o(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(`
|
|
889
|
+
Approval: ${n.requestId}
|
|
890
|
+
`),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 Ao(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),i=n.status==="approved";s?d({approval_id:o,status:n.status,approved:i},!0):console.log(`
|
|
891
|
+
Approval ${o}: ${n.status.toUpperCase()}`);}catch(t){console.error("Failed to check approval:",t instanceof Error?t.message:t),process.exit(1);}}async function Eo(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 i=await u(e);s||console.log(`
|
|
892
|
+
Waiting for approval ${o}...`);let a=await i.waitForApproval(o,{timeoutMs:n}),l=a.status==="approved";s?d({...a,approved:l},!0):(console.log(`
|
|
893
|
+
Approval ${l?"GRANTED":a.status.toUpperCase()}!
|
|
894
|
+
`),console.log(`Status: ${a.status}`),a.responseNote&&console.log(`Note: ${a.responseNote}`),a.approvalScope&&console.log(`Scope: ${a.approvalScope}`));}catch(i){console.error("Wait failed:",i instanceof Error?i.message:i),process.exit(1);}}async function Io(e,r){let s=r[0];if(e.help||e.h){console.log(`
|
|
895
|
+
mixrpay approval - Human approval workflow
|
|
896
|
+
|
|
897
|
+
USAGE
|
|
898
|
+
mixrpay approval [subcommand] [options]
|
|
899
|
+
|
|
900
|
+
SUBCOMMANDS
|
|
901
|
+
request Request human approval
|
|
902
|
+
status <id> Get approval status
|
|
903
|
+
check <id> Quick check if approved (returns bool)
|
|
904
|
+
wait <id> Wait for approval decision
|
|
905
|
+
|
|
906
|
+
REQUEST OPTIONS
|
|
907
|
+
--action, -a Action name (required)
|
|
908
|
+
--description, -d Description (required)
|
|
909
|
+
--amount Amount in USD (optional)
|
|
910
|
+
--expires Expiry in minutes (default: 60)
|
|
911
|
+
|
|
912
|
+
OPTIONS
|
|
913
|
+
--timeout Wait timeout in seconds
|
|
914
|
+
--json Output as JSON
|
|
915
|
+
--help, -h Show this help message
|
|
916
|
+
|
|
917
|
+
DESCRIPTION
|
|
918
|
+
Request human approval before performing sensitive actions.
|
|
919
|
+
Useful for high-value transfers or destructive operations.
|
|
920
|
+
|
|
921
|
+
EXAMPLES
|
|
922
|
+
mixrpay approval request --action "transfer" --description "Send $100 to Bob" --amount 100
|
|
923
|
+
mixrpay approval status appr_abc123
|
|
924
|
+
mixrpay approval wait appr_abc123 --timeout 300
|
|
925
|
+
`);return}switch(s){case "request":await vo(e);break;case "status":await $o(e,r.slice(1));break;case "check":await Ao(e,r.slice(1));break;case "wait":await Eo(e,r.slice(1));break;default:console.error("Unknown subcommand. Run `mixrpay approval --help` for usage."),process.exit(1);}}function D(){console.log(`
|
|
109
926
|
MixrPay CLI - Manage AI agent payments
|
|
110
927
|
|
|
111
928
|
USAGE
|
|
112
929
|
mixrpay <command> [options]
|
|
113
930
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
931
|
+
GETTING STARTED
|
|
932
|
+
init Set up your agent in one command (recommended)
|
|
933
|
+
install Verify MIXRPAY_AGENT_TOKEN from /cli/setup (no registration)
|
|
934
|
+
|
|
935
|
+
AUTHENTICATION
|
|
936
|
+
login Authenticate via browser (alternative to init)
|
|
937
|
+
logout Clear saved credentials
|
|
938
|
+
whoami Show current authentication status
|
|
939
|
+
register Register a new agent (advanced - prefer init)
|
|
940
|
+
status Show agent balance and session info
|
|
941
|
+
|
|
942
|
+
WALLET & BUDGET
|
|
943
|
+
wallet Manage your agent wallet (balance, send, create, etc.)
|
|
944
|
+
budget Show available budget for spawning
|
|
945
|
+
creds Manage credential vault (store/retrieve API keys securely)
|
|
946
|
+
spawn Create a child invite for a sub-agent
|
|
947
|
+
children List child sessions
|
|
948
|
+
sessions Manage merchant sessions
|
|
949
|
+
|
|
950
|
+
AI & TOOLS
|
|
951
|
+
complete Get an LLM completion (no tools)
|
|
952
|
+
run Run an AI agent with tools
|
|
953
|
+
tool Call MixrPay gateway tools (see: mixrpay-tool)
|
|
954
|
+
search Quick web search shortcut
|
|
955
|
+
mcp Manage MCP servers (deploy, list, call)
|
|
956
|
+
skills Manage connected app skills
|
|
957
|
+
|
|
958
|
+
TASK MANAGEMENT
|
|
959
|
+
agent Manage task agents (deploy, trigger, wait)
|
|
960
|
+
task Task board (create, request, submit, approve)
|
|
961
|
+
plan Multi-step plans (submit, execute, wait)
|
|
962
|
+
approval Human approval workflow
|
|
963
|
+
|
|
964
|
+
DEFI
|
|
965
|
+
defi DeFi operations (balances, transfer, swap, bridge)
|
|
966
|
+
|
|
967
|
+
DIAGNOSTICS
|
|
968
|
+
diagnostics Run wallet diagnostics
|
|
969
|
+
health Check MixrPay server health
|
|
970
|
+
siwe Generate SIWE (Sign-In with Ethereum) message
|
|
120
971
|
|
|
121
972
|
OPTIONS
|
|
122
973
|
--help, -h Show this help message
|
|
123
974
|
--version, -v Show version number
|
|
975
|
+
--json Output as JSON (most commands)
|
|
124
976
|
--baseUrl Override MixrPay API URL (default: https://www.mixrpay.com)
|
|
125
977
|
|
|
126
978
|
EXAMPLES
|
|
127
|
-
#
|
|
128
|
-
mixrpay
|
|
979
|
+
# Set up your agent (one command)
|
|
980
|
+
mixrpay init --name "MyAgent"
|
|
129
981
|
|
|
130
|
-
#
|
|
131
|
-
mixrpay
|
|
982
|
+
# Set up with invite code (instant access with budget)
|
|
983
|
+
mixrpay init --invite mixr-abc123
|
|
132
984
|
|
|
133
|
-
#
|
|
134
|
-
mixrpay
|
|
985
|
+
# Check wallet balance
|
|
986
|
+
mixrpay wallet
|
|
987
|
+
|
|
988
|
+
# Quick web search
|
|
989
|
+
mixrpay search "AI agent frameworks"
|
|
990
|
+
|
|
991
|
+
# Run an agent task
|
|
992
|
+
mixrpay run "Research the latest AI papers and summarize"
|
|
993
|
+
|
|
994
|
+
# Deploy a task agent
|
|
995
|
+
mixrpay agent deploy --name "Researcher" --prompt "Find papers" --budget 5.00
|
|
996
|
+
|
|
997
|
+
# Call gateway tool
|
|
998
|
+
mixrpay tool firecrawl firecrawl-search '{"query":"..."}'
|
|
999
|
+
|
|
1000
|
+
# Deploy JIT MCP server
|
|
1001
|
+
mixrpay mcp deploy github
|
|
1002
|
+
|
|
1003
|
+
# Request human approval
|
|
1004
|
+
mixrpay approval request --action "transfer" --description "Send $100"
|
|
135
1005
|
|
|
136
|
-
|
|
137
|
-
|
|
1006
|
+
TOOL CLI
|
|
1007
|
+
For full tool gateway access, use:
|
|
1008
|
+
npx mixrpay-tool <provider> <tool_name> '<json>'
|
|
1009
|
+
npx mixrpay-tool list
|
|
1010
|
+
npx mixrpay-tool help <provider>
|
|
138
1011
|
|
|
139
1012
|
ENVIRONMENT VARIABLES
|
|
140
1013
|
MIXRPAY_SESSION_KEY Session key for authentication
|
|
141
|
-
|
|
1014
|
+
MIXRPAY_AGENT_TOKEN Agent token for API calls
|
|
142
1015
|
MIXRPAY_MASTER_KEY Master key for multi-agent deployments
|
|
143
1016
|
MIXRPAY_BASE_URL Custom API base URL
|
|
144
1017
|
AGENT_WALLET_KEY Agent's wallet private key
|
|
145
1018
|
|
|
146
1019
|
For more info, visit: https://docs.mixrpay.com/cli
|
|
147
|
-
`);}function
|
|
1020
|
+
`);}function To(){import('./agent-wallet-DD4EL57B.js').then(({SDK_VERSION:e})=>{console.log(`mixrpay v${e}`);});}async function Uo(){let e=Y(process.argv.slice(2));if(!e.command&&(e.flags.help||e.flags.h)){D();return}if(e.flags.version||e.flags.v){To();return}switch(e.command){case "init":await oe(e.flags);break;case "install":await ee(e.flags);break;case "login":await V(e.flags);break;case "logout":await z();break;case "whoami":await Q(e.flags);break;case "register":await Z(e.flags);break;case "status":await te(e.flags);break;case "wallet":await ge(e.flags,e.positionals);break;case "budget":await fe(e.flags);break;case "creds":case "credentials":case "vault":await be(e.flags,e.positionals);break;case "spawn":await me(e.flags);break;case "children":await ye(e.flags);break;case "sessions":await Oe(e.flags,e.positionals);break;case "complete":await ke(e.flags,e.positionals);break;case "run":await ve(e.flags,e.positionals);break;case "tool":await ze(e.flags,e.positionals);break;case "search":await Qe(e.flags,e.positionals);break;case "mcp":await Me(e.flags,e.positionals);break;case "skills":await Be(e.flags,e.positionals);break;case "agent":await Ve(e.flags,e.positionals);break;case "task":await co(e.flags,e.positionals);break;case "defi":await fo(e.flags,e.positionals);break;case "plan":await ko(e.flags,e.positionals);break;case "approval":await Io(e.flags,e.positionals);break;case "diagnostics":await $e(e.flags);break;case "health":await Ae(e.flags);break;case "siwe":await Ee(e.flags);break;case "":case "help":D();break;default:console.error(`Unknown command: ${e.command}`),console.error("\nRun `mixrpay --help` for usage information."),process.exit(1);}}Uo().catch(e=>{console.error("Fatal error:",e),process.exit(1);});
|