@mixrpay/agent-sdk 0.11.1 → 0.11.4
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 +37 -6
- package/dist/{agent-wallet-YY6SGBZQ.js → agent-wallet-7CS7WY4F.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-TOPWZWOK.js +26 -0
- package/dist/cli.js +293 -154
- 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 +6 -12
- package/dist/index.d.cts +67 -3
- package/dist/index.d.ts +67 -3
- package/dist/index.js +6 -12
- package/dist/mcp-server.js +9 -15
- package/dist/tool-cli.js +16 -12
- package/package.json +1 -1
- package/dist/chunk-4WCYTILC.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 as d$1,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-TOPWZWOK.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
|
|
@@ -18,7 +18,7 @@ EXAMPLES
|
|
|
18
18
|
mixrpay login --baseUrl https://staging.mixrpay.com
|
|
19
19
|
`);return}let r=e$1.baseUrl||e$1.url||c;console.log(`Starting MixrPay authentication...
|
|
20
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
|
|
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
|
|
@@ -35,10 +35,10 @@ DESCRIPTION
|
|
|
35
35
|
EXAMPLES
|
|
36
36
|
mixrpay whoami
|
|
37
37
|
mixrpay whoami --json
|
|
38
|
-
`);return}let r=e$1.json===true,s=b();s.success||(r?d({authenticated:false,error:s.error}):console.error("Error loading credentials:",s.error),process.exit(1));let{credentials:o}=s;if(!o.sessionKey&&!o.apiToken&&!o.masterKey){r?d({authenticated:false}):(console.log("Not logged in."),console.log("\nRun `mixrpay login` to authenticate."));return}let t={authenticated:true};if(o.sessionKey){let n=o.sessionKey.startsWith("sk_test_")?"testnet":"mainnet";t.sessionKey=
|
|
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
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
|
|
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
|
|
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(`
|
|
42
42
|
mixrpay register - Register a new agent with MixrPay
|
|
43
43
|
|
|
44
44
|
USAGE
|
|
@@ -68,25 +68,103 @@ EXAMPLES
|
|
|
68
68
|
|
|
69
69
|
ENVIRONMENT VARIABLES
|
|
70
70
|
AGENT_WALLET_KEY Agent's wallet private key
|
|
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
|
|
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(`
|
|
72
72
|
Usage: mixrpay register --key 0x... [--name "Agent Name"]`),console.error(`
|
|
73
73
|
Alternatively, set the AGENT_WALLET_KEY environment variable.`),console.error(`
|
|
74
|
-
Or use --mode invite or --mode self for keyless registration.`),process.exit(1)),(!
|
|
75
|
-
`);try{let
|
|
76
|
-
`),console.log(` User ID: ${
|
|
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(
|
|
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(`
|
|
78
78
|
Usage: mixrpay register --mode invite --invite-code mixr-... --name "Agent Name"`),process.exit(1)),o||(console.error("Error: Agent name required."),console.error(`
|
|
79
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
|
|
81
|
-
`),console.log(` Agent ID: ${
|
|
82
|
-
Your agent is now active and ready to make payments!`));}catch(
|
|
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
83
|
Usage: mixrpay register --mode self --name "Agent Name"`),process.exit(1)),r||console.log(`Self-registering agent...
|
|
84
|
-
`);let
|
|
85
|
-
`),console.log(` Agent ID: ${
|
|
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
86
|
Token saved to credentials file.`),console.log(`
|
|
87
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: ${
|
|
89
|
-
The claim code expires in ${
|
|
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(`
|
|
90
168
|
mixrpay status - Show agent balance and session info
|
|
91
169
|
|
|
92
170
|
USAGE
|
|
@@ -107,48 +185,48 @@ EXAMPLES
|
|
|
107
185
|
mixrpay status # Uses cached session key
|
|
108
186
|
mixrpay status --key 0x... # Uses wallet private key
|
|
109
187
|
mixrpay status --json # Output as JSON
|
|
110
|
-
`);return}let r=e.json===true,s=e.key||e.privateKey||process.env.AGENT_WALLET_KEY,o=e.baseUrl||e.url||c,t=b();if(!s&&t.success&&t.credentials.sessionKey)try{let n=new g({sessionKey:t.credentials.sessionKey,baseUrl:t.credentials.baseUrl||o}),
|
|
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)
|
|
111
189
|
`),console.log(`Wallet: ${n.getWalletAddress()}`),console.log(`Network: ${n.getNetwork().name}`),console.log(`
|
|
112
|
-
Spending:`),console.log(` Total spent: $${
|
|
113
|
-
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(`
|
|
114
192
|
Usage: mixrpay status --key 0x...`),console.error(`
|
|
115
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...
|
|
116
|
-
`);try{let n=await g.getStatus({privateKey:s,baseUrl:o});if(r){d({walletAddress:n.depositAddress,balanceUsd:n.balanceUsd,totalSpentUsd:n.totalSpentUsd,sessions:n.activeSessions.map(
|
|
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
|
|
117
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(`
|
|
118
|
-
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(`
|
|
119
197
|
Wallet Balance
|
|
120
198
|
`),console.log(`Address: ${s.getWalletAddress()}`),console.log(`Network: ${s.getNetwork().name}`),console.log(`Balance: $${o.toFixed(2)} USDC`),console.log(`
|
|
121
|
-
Spending:`),console.log(` Total spent: $${t.totalSpentUsd.toFixed(2)}`),console.log(` Transactions: ${t.txCount}`),t.remainingDailyUsd!==null&&console.log(` Daily remaining: $${t.remainingDailyUsd.toFixed(2)}`),t.remainingTotalUsd!==null&&console.log(` Total remaining: $${t.remainingTotalUsd.toFixed(2)}`));}catch(s){console.error("Failed to get balance:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
122
|
-
Self-custody wallet already exists.`),console.log(`Address: ${
|
|
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...
|
|
123
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!
|
|
124
202
|
`),console.log(`Address: ${t}`),console.log(`
|
|
125
203
|
Private Key: ${n}`),console.log(`
|
|
126
|
-
!!! IMPORTANT !!!`),console.log("Save your private key securely. It cannot be recovered."),console.log("The key is stored locally but you should backup elsewhere."));}catch(s){console.error("Failed to create wallet:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
127
|
-
Delegation Wallet Address: ${o}`),console.log(`Network: ${t.name} (Chain ID: ${t.chainId})`));}catch(s){console.error("Failed to get address:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
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(`
|
|
128
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(`
|
|
129
207
|
Self-Custody Wallet Address: ${t}`),console.log(`
|
|
130
|
-
This wallet can send USDC directly on-chain.`),console.log("Use `mixrpay wallet send-direct` for direct transfers."));}catch(s){console.error("Failed to get self-custody info:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
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(`
|
|
131
209
|
Funding Instructions
|
|
132
210
|
`),console.log(`Deposit Address: ${o}`),console.log(`Network: ${t.name} (Chain ID: ${t.chainId})`),console.log("Token: USDC"),console.log(`
|
|
133
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(`
|
|
134
|
-
Note: Only send USDC on Base. Other tokens may be lost.`));}catch(s){console.error("Failed to get funding info:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
135
|
-
Usage: mixrpay wallet afford <amount>`),console.error("Example: mixrpay wallet afford 10.00"),process.exit(1));let t=parseFloat(o);(isNaN(t)||t<=0)&&(console.error("Error: Invalid amount. Must be a positive number."),process.exit(1));try{let
|
|
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(`
|
|
136
214
|
Affordability Check: $${t.toFixed(2)}
|
|
137
|
-
`),console.log(`Balance: $${
|
|
138
|
-
Usage: mixrpay wallet send <to> <amount>`),console.error("Example: mixrpay wallet send 0x1234... 10.00"),process.exit(1)),(!o.startsWith("0x")||o.length!==42)&&(console.error("Error: Invalid recipient address. Must be 0x followed by 40 hex chars."),process.exit(1));let
|
|
139
|
-
Sending $${
|
|
140
|
-
`));let
|
|
141
|
-
`),console.log(`Amount: $${
|
|
142
|
-
Usage: mixrpay wallet send-direct <to> <amount>`),console.error("Example: mixrpay wallet send-direct 0x1234... 10.00"),process.exit(1)),(!o.startsWith("0x")||o.length!==42)&&(console.error("Error: Invalid recipient address. Must be 0x followed by 40 hex chars."),process.exit(1));let n=parseFloat(t);(isNaN(n)||n<=0)&&(console.error("Error: Invalid amount. Must be a positive number."),process.exit(1));try{let
|
|
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(`
|
|
143
221
|
Sending $${n.toFixed(2)} USDC to ${o.slice(0,10)}...${o.slice(-8)}`),console.log(`Using self-custody wallet (on-chain)...
|
|
144
|
-
`));let
|
|
145
|
-
`),console.log(`Amount: $${n.toFixed(2)} USDC`),console.log(`To: ${o}`),console.log(`TX Hash: ${
|
|
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(`
|
|
146
224
|
Transaction History
|
|
147
|
-
`),o.length===0)console.log("No transactions found.");else {for(let t of o.slice(0,20)){let n=new Date(t.created_at).toLocaleDateString(),
|
|
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(`
|
|
148
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(`
|
|
149
227
|
Payment History (Current Session)
|
|
150
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(`
|
|
151
|
-
Note: This shows only current session payments.`),console.log("Full history requires API token auth.");}}}catch(s){console.error("Failed to get history:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
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(`
|
|
152
230
|
mixrpay wallet - Manage your agent wallet
|
|
153
231
|
|
|
154
232
|
USAGE
|
|
@@ -178,9 +256,9 @@ EXAMPLES
|
|
|
178
256
|
mixrpay wallet send 0x123... 10.00 # Send $10 via delegation
|
|
179
257
|
mixrpay wallet send-direct 0x123... 10.00 # Send $10 on-chain
|
|
180
258
|
mixrpay wallet history # View transactions
|
|
181
|
-
`);return}switch(s){case "create":await
|
|
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(`
|
|
182
260
|
Budget Overview
|
|
183
|
-
`),console.log(`Total Budget: $${o.totalBudget.toFixed(2)}`),console.log(`Spent: $${o.spent.toFixed(2)}`),console.log(`Allocated: $${o.allocatedToChildren.toFixed(2)} (to children)`),console.log(`Available: $${o.available.toFixed(2)}`),console.log(""),console.log(`Can Spawn: ${o.canSpawn?"Yes":"No"}`),console.log(`Max Spawn Budget: $${o.maxSpawnBudget.toFixed(2)}`));}catch(s){console.error("Failed to get budget:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
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(`
|
|
184
262
|
mixrpay spawn - Create a child invite for a sub-agent
|
|
185
263
|
|
|
186
264
|
USAGE
|
|
@@ -200,13 +278,13 @@ EXAMPLES
|
|
|
200
278
|
mixrpay spawn -n "API Agent" -b 20.00 --merchants "openai.com,anthropic.com"
|
|
201
279
|
`);return}s||(console.error("Error: Name is required."),console.error(`
|
|
202
280
|
Usage: mixrpay spawn --name <name> --budget <amount>`),process.exit(1)),o||(console.error("Error: Budget is required."),console.error(`
|
|
203
|
-
Usage: mixrpay spawn --name <name> --budget <amount>`),process.exit(1));let
|
|
204
|
-
Creating child invite for "${s}" with $${
|
|
205
|
-
`);let g=await
|
|
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!
|
|
206
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(`
|
|
207
|
-
Share this invite code with the sub-agent:`),console.log(` mixrpay register --mode invite --invite-code ${g.inviteCode} --name "${s}"`));}catch(
|
|
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(`
|
|
208
286
|
Child Sessions
|
|
209
|
-
`),o.length===0)console.log("No child sessions found."),console.log("\nUse `mixrpay spawn` to create a child invite.");else for(let t of o){let n=t.spentUsd??0,
|
|
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(`
|
|
210
288
|
mixrpay budget - Show available budget for spawning
|
|
211
289
|
|
|
212
290
|
USAGE
|
|
@@ -226,7 +304,62 @@ DESCRIPTION
|
|
|
226
304
|
EXAMPLES
|
|
227
305
|
mixrpay budget
|
|
228
306
|
mixrpay budget --json
|
|
229
|
-
`);return}await
|
|
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(`
|
|
230
363
|
mixrpay complete - Get an LLM completion
|
|
231
364
|
|
|
232
365
|
USAGE
|
|
@@ -253,10 +386,10 @@ EXAMPLES
|
|
|
253
386
|
mixrpay complete "Write a haiku" --model gpt-4o
|
|
254
387
|
mixrpay complete "Summarize this" -s "Be concise"
|
|
255
388
|
`);return}o||(console.error("Error: Prompt required."),console.error(`
|
|
256
|
-
Usage: mixrpay complete "<prompt>"`),process.exit(1));try{let
|
|
257
|
-
`);let
|
|
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(`
|
|
258
391
|
---
|
|
259
|
-
Cost: $${
|
|
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(`
|
|
260
393
|
mixrpay run - Run an AI agent with tools
|
|
261
394
|
|
|
262
395
|
USAGE
|
|
@@ -281,15 +414,15 @@ EXAMPLES
|
|
|
281
414
|
mixrpay run "Find AI startups in SF and summarize their products"
|
|
282
415
|
mixrpay run "Research quantum computing" --model gpt-4o --iterations 15
|
|
283
416
|
mixrpay run --status run_abc123
|
|
284
|
-
`);return}try{let
|
|
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(`
|
|
285
418
|
Run Status: ${p.runId}
|
|
286
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(`
|
|
287
420
|
Response:
|
|
288
421
|
${p.response}`),p.error&&console.log(`
|
|
289
422
|
Error: ${p.error}`));return}o||(console.error("Error: Prompt required."),console.error(`
|
|
290
423
|
Usage: mixrpay run "<prompt>"`),console.error(" mixrpay run --status <run_id>"),process.exit(1)),s||console.log(`Running agent${t?` with ${t}`:""}...
|
|
291
|
-
`);let g=
|
|
292
|
-
---`),console.log(`Run ID: ${m.runId||"N/A"}`),console.log(`Iterations: ${m.iterations}`),console.log(`Tools used: ${m.toolsUsed?.join(", ")||"none"}`),console.log(`Cost: $${m.cost.totalUsd.toFixed(4)} (LLM: $${m.cost.llmUsd.toFixed(4)}, Tools: $${m.cost.toolsUsd.toFixed(4)})`),m.txHash&&console.log(`TX: ${m.txHash}`));}catch(
|
|
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(`
|
|
293
426
|
mixrpay diagnostics - Run comprehensive diagnostics
|
|
294
427
|
|
|
295
428
|
USAGE
|
|
@@ -315,7 +448,7 @@ EXAMPLES
|
|
|
315
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(`
|
|
316
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(`
|
|
317
450
|
Issues:`);for(let t of o.issues)console.log(` - ${t}`);}if(o.recommendations.length>0){console.log(`
|
|
318
|
-
Recommendations:`);for(let t of o.recommendations)console.log(` - ${t}`);}}}catch(s){console.error("Diagnostics failed:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
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(`
|
|
319
452
|
mixrpay health - Check MixrPay server health
|
|
320
453
|
|
|
321
454
|
USAGE
|
|
@@ -336,7 +469,7 @@ EXAMPLES
|
|
|
336
469
|
`);return}r||console.log(`Checking server health at ${s}...
|
|
337
470
|
`);let o=await g.checkServerHealth(s);r?d(o):(console.log(`Server Health
|
|
338
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(`
|
|
339
|
-
Error: ${o.error}`));}async function
|
|
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(`
|
|
340
473
|
mixrpay siwe - Generate SIWE (Sign-In with Ethereum) message
|
|
341
474
|
|
|
342
475
|
USAGE
|
|
@@ -358,17 +491,17 @@ EXAMPLES
|
|
|
358
491
|
mixrpay siwe --domain example.com --uri https://example.com/login
|
|
359
492
|
mixrpay siwe -d myapp.com -u https://myapp.com -s "Sign in to My App"
|
|
360
493
|
`);return}(!s||!o)&&(console.error("Error: Domain and URI are required."),console.error(`
|
|
361
|
-
Usage: mixrpay siwe --domain <domain> --uri <uri>`),process.exit(1));try{let
|
|
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(`
|
|
362
495
|
SIWE Message Generated
|
|
363
|
-
`),console.log("Message:"),console.log("---"),console.log(
|
|
364
|
-
Signature: ${
|
|
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(`
|
|
365
498
|
Merchant Sessions
|
|
366
|
-
`),o.length===0)console.log("No active sessions found.");else for(let t of o){let n=t.spentUsd??0,
|
|
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(`
|
|
367
500
|
Session Statistics
|
|
368
|
-
`),console.log(`Active Sessions: ${o.activeCount}`),console.log(`Total Sessions: ${o.totalCount}`),console.log(`Revoked Sessions: ${o.revokedCount}`),console.log(`Total Spent: $${o.totalSpentUsd.toFixed(2)}`),o.totalLimitUsd&&console.log(`Total Limit: $${o.totalLimitUsd.toFixed(2)}`));}catch(s){console.error("Failed to get session stats:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
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(`
|
|
369
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?`
|
|
370
503
|
Session ${o} revoked successfully.`:`
|
|
371
|
-
Session ${o} could not be revoked (may already be revoked).`);}catch(t){console.error("Failed to revoke session:",t instanceof Error?t.message:t),process.exit(1);}}async function
|
|
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(`
|
|
372
505
|
mixrpay sessions - Manage merchant sessions
|
|
373
506
|
|
|
374
507
|
USAGE
|
|
@@ -391,29 +524,29 @@ EXAMPLES
|
|
|
391
524
|
mixrpay sessions
|
|
392
525
|
mixrpay sessions stats
|
|
393
526
|
mixrpay sessions revoke sk_abc123...
|
|
394
|
-
`);return}switch(s){case "stats":await
|
|
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(`
|
|
395
528
|
MCP Tools
|
|
396
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(`
|
|
397
|
-
Total: ${o.length} tools`);}}catch(s){console.error("Failed to list MCP tools:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
398
|
-
Usage: mixrpay mcp call <tool_name> '{"arg":"value"}'`),process.exit(1));let n=
|
|
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(`
|
|
399
532
|
MCP Tool Result
|
|
400
|
-
`),
|
|
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(`
|
|
401
534
|
Usage: mixrpay mcp deploy <glama_id> --namespace <ns> --slug <slug> --name <tool_name>`),console.error(`
|
|
402
|
-
Example:`),console.error(' mixrpay mcp deploy notion-mcp --namespace notion --slug notion-mcp --name "Notion MCP"'),console.error("\nNote: Use `mixrpay skills` for pre-configured app integrations."),process.exit(1));let g;
|
|
403
|
-
Deploying MCP server: ${
|
|
404
|
-
`);let
|
|
405
|
-
`),console.log(`Instance ID: ${y.instanceId}`),console.log(`Tool: ${y.toolName}`),console.log(`Status: ${y.status}`),y.endpointUrl&&console.log(`Endpoint: ${y.endpointUrl}`),y.expiresAt&&console.log(`Expires: ${y.expiresAt.toLocaleString()}`),
|
|
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(`
|
|
406
539
|
JIT MCP Instances
|
|
407
|
-
`),t.length===0)console.log("No instances found."),console.log("\nUse `mixrpay mcp deploy` or `mixrpay skills use` to deploy one.");else for(let n of t)console.log(`${n.toolName}`),console.log(` ID: ${n.id}`),console.log(` Status: ${n.status}`),console.log(` Glama: ${n.glamaNamespace}/${n.glamaSlug}`),n.expiresAt&&console.log(` Expires: ${n.expiresAt.toLocaleString()}`),console.log("");}catch(o){console.error("Failed to list instances:",o instanceof Error?o.message:o),process.exit(1);}}async function
|
|
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(`
|
|
408
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(`
|
|
409
|
-
Instance ${o} stopped.`);}catch(t){console.error("Failed to stop instance:",t instanceof Error?t.message:t),process.exit(1);}}async function
|
|
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(`
|
|
410
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(`
|
|
411
544
|
MCP Instance: ${n.id}
|
|
412
|
-
`),console.log(`Tool: ${n.toolName}`),console.log(`Status: ${n.status}`),console.log(`Glama: ${n.glamaNamespace}/${n.glamaSlug}`),n.endpointUrl&&console.log(`Endpoint: ${
|
|
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(`
|
|
413
546
|
MCP Server Configuration
|
|
414
547
|
`),console.log(`Command: ${o.command} ${o.args?.join(" ")||""}`),console.log(`
|
|
415
548
|
Environment variables (masked):`);for(let[t,n]of Object.entries(o.env||{}))console.log(` ${t}=${n?.slice(0,16)}...`);console.log(`
|
|
416
|
-
Use this config to spawn the MCP server subprocess.`);}}catch(s){console.error("Failed to get MCP config:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
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(`
|
|
417
550
|
mixrpay mcp - Manage MCP (Model Context Protocol) servers
|
|
418
551
|
|
|
419
552
|
USAGE
|
|
@@ -454,22 +587,22 @@ EXAMPLES
|
|
|
454
587
|
|
|
455
588
|
# Deploy custom MCP (advanced - prefer 'skills' for common integrations)
|
|
456
589
|
mixrpay mcp deploy notion-mcp --namespace notion --slug notion-mcp --name "Notion"
|
|
457
|
-
`);return}switch(s){case "call":await
|
|
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(`
|
|
458
591
|
Available Skills
|
|
459
|
-
`),o.length===0)console.log("No skills available."),console.log("\nUse `mixrpay skills apps` to see connected apps.");else for(let t of o){let n=t.status==="configured"?"ready":t.status;console.log(`${t.name} [${n}]`),console.log(` ID: ${t.id}`),console.log(` Category: ${t.categoryName}`),t.description&&console.log(` ${t.description}`),t.available||console.log(" (not available)"),console.log("");}}catch(s){console.error("Failed to list skills:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
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(`
|
|
460
593
|
Usage: mixrpay skills use <skill_id>`),console.error(`
|
|
461
|
-
This deploys a JIT MCP server for the skill.`),process.exit(1));let n=t?parseInt(t,10):void 0;try{let
|
|
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(`
|
|
462
595
|
Deploying skill: ${o}...
|
|
463
|
-
`);let
|
|
464
|
-
`),console.log(`Skill ID: ${
|
|
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(`
|
|
465
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(`
|
|
466
599
|
Skill Status: ${n.skillId}
|
|
467
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(`
|
|
468
|
-
This skill needs configuration.`),console.log("Visit the dashboard to configure it.")));}catch(t){console.error("Failed to get skill status:",t instanceof Error?t.message:t),process.exit(1);}}async function
|
|
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(`
|
|
469
602
|
Connected Apps
|
|
470
603
|
`),o.connected.length===0)console.log("No connected apps."),console.log(`
|
|
471
604
|
Visit your dashboard to connect apps.`);else {console.log(`Connected: ${o.connected.join(", ")}
|
|
472
|
-
`);for(let t of o.connections)console.log(`${t.app_name}`),console.log(` App: ${t.app}`),console.log(` Type: ${t.type}`),console.log(` Status: ${t.status}`),t.account_name&&console.log(` Account: ${t.account_name}`),console.log("");}}catch(s){console.error("Failed to get connected apps:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
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(`
|
|
473
606
|
mixrpay skills - Manage connected app skills
|
|
474
607
|
|
|
475
608
|
USAGE
|
|
@@ -494,26 +627,26 @@ EXAMPLES
|
|
|
494
627
|
mixrpay skills apps
|
|
495
628
|
mixrpay skills use github
|
|
496
629
|
mixrpay skills status github
|
|
497
|
-
`);return}switch(s){case "use":await
|
|
498
|
-
Usage: mixrpay agent deploy --name "Agent" --prompt "Task..." --budget 5.00`),process.exit(1));let m=parseFloat(
|
|
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(`
|
|
499
632
|
Deploying task agent: ${s}...
|
|
500
|
-
`);let
|
|
501
|
-
`),console.log(`Instance ID: ${
|
|
502
|
-
Commands:`),console.log(` mixrpay agent trigger ${
|
|
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(`
|
|
503
636
|
Task Agents
|
|
504
|
-
`);let
|
|
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(`
|
|
505
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(`
|
|
506
639
|
Task Agent: ${n.id}
|
|
507
|
-
`),console.log(`Name: ${n.name}`),console.log(`Model: ${n.model}`),console.log(`Status: ${n.status}`),console.log(`Iterations: ${n.iterations?.current??0}/${n.iterations?.max??"N/A"}`),console.log(`Budget: $${(n.budget?.spentUsd??0).toFixed(2)} / $${(n.budget?.totalUsd??0).toFixed(2)}`),n.tools?.length&&console.log(`Tools: ${n.tools.join(", ")}`));}catch(t){console.error("Failed to get agent status:",t instanceof Error?t.message:t),process.exit(1);}}async function
|
|
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(`
|
|
508
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(`
|
|
509
|
-
Agent ${o} triggered.`),console.log(`Status: ${n.status}`),console.log("\nUse `mixrpay agent wait` to wait for completion."));}catch(t){console.error("Failed to trigger agent:",t instanceof Error?t.message:t),process.exit(1);}}async function
|
|
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(`
|
|
510
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(`
|
|
511
|
-
Agent ${o} cancelled.`),console.log(`Status: ${n.status}`));}catch(t){console.error("Failed to cancel agent:",t instanceof Error?t.message:t),process.exit(1);}}async function
|
|
512
|
-
Usage: mixrpay agent wait <instance_id>`),process.exit(1));let n=t?parseInt(t,10)*1e3:void 0;try{let
|
|
513
|
-
Waiting for agent ${o}...`);let
|
|
514
|
-
Agent completed!`),console.log(`Status: ${
|
|
515
|
-
Result:`),console.log(
|
|
516
|
-
Error:`,
|
|
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(`
|
|
517
650
|
mixrpay agent - Manage task agents
|
|
518
651
|
|
|
519
652
|
USAGE
|
|
@@ -551,14 +684,14 @@ EXAMPLES
|
|
|
551
684
|
mixrpay agent status inst_abc123
|
|
552
685
|
mixrpay agent trigger inst_abc123
|
|
553
686
|
mixrpay agent wait inst_abc123
|
|
554
|
-
`);return}switch(s){case "deploy":await
|
|
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(`
|
|
555
688
|
mixrpay tool - Call MixrPay gateway tools
|
|
556
689
|
|
|
557
690
|
USAGE
|
|
558
691
|
mixrpay tool <provider> <tool_name> '<json_arguments>'
|
|
559
692
|
mixrpay tool list
|
|
560
693
|
|
|
561
|
-
For full documentation, run: npx mixrpay-tool --help
|
|
694
|
+
For full documentation, run: npx --package @mixrpay/agent-sdk mixrpay-tool --help
|
|
562
695
|
|
|
563
696
|
QUICK EXAMPLES
|
|
564
697
|
# Web search
|
|
@@ -569,7 +702,7 @@ QUICK EXAMPLES
|
|
|
569
702
|
|
|
570
703
|
# Send email
|
|
571
704
|
mixrpay tool agentmail agentmail-send '{"inbox_id":"...","to":["..."],"subject":"...","text":"..."}'
|
|
572
|
-
`);return}let{spawn:s}=await import('child_process'),o=r;e.json&&o.push("--json"),e["use-x402"]&&o.push("--use-x402"),e.baseUrl&&o.push("--baseUrl",e.baseUrl),s(process.execPath,[new URL("./tool-cli.js",import.meta.url).pathname,...o],{stdio:"inherit"}).on("exit",n=>{process.exit(n||0);});}async function
|
|
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(`
|
|
573
706
|
mixrpay search - Quick web search
|
|
574
707
|
|
|
575
708
|
USAGE
|
|
@@ -583,26 +716,27 @@ OPTIONS
|
|
|
583
716
|
EXAMPLES
|
|
584
717
|
mixrpay search "AI agent frameworks 2026"
|
|
585
718
|
mixrpay search "best DeFi yields" --provider exa
|
|
586
|
-
`);return}let s=r.join(" "),o=e.provider||e.p||"firecrawl",t=e.json===true,n=await
|
|
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(`
|
|
587
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(`
|
|
588
|
-
To fix this:`),console.error(' mixrpay register --mode invite --invite-code <code> --name "My Agent"'),process.exit(1));let
|
|
589
|
-
`);let
|
|
590
|
-
|
|
591
|
-
|
|
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(`
|
|
592
726
|
Task Created!
|
|
593
|
-
`),console.log(`Task ID: ${g.id}`),console.log(`Title: ${g.title}`),console.log(`Budget: $${g.budgetUsd.toFixed(2)}`),console.log(`Status: ${g.status}`),g.expiresAt&&console.log(`Expires: ${new Date(g.expiresAt).toLocaleDateString()}`));}catch(
|
|
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(`
|
|
594
728
|
Task Board
|
|
595
|
-
`);let
|
|
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(`
|
|
596
730
|
Task: ${n.title}
|
|
597
|
-
`),console.log(`ID: ${n.taskId}`),console.log(`Status: ${n.status}`),console.log(`Budget: $${(n.budgetUsd||0).toFixed(2)}`),console.log(`Description: ${n.description}`),n.deadline&&console.log(`Deadline: ${new Date(n.deadline).toLocaleDateString()}`),n.assignee&&console.log(`Assignee: ${n.assignee}`));}catch(t){console.error("Failed to get task:",t instanceof Error?t.message:t),process.exit(1);}}async function
|
|
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(`
|
|
598
732
|
My Tasks
|
|
599
|
-
`),n.tasks.length===0)console.log("No assigned tasks."),console.log("\nUse `mixrpay task request <id>` to request a task.");else {for(let
|
|
600
|
-
Task ${o} requested.`),console.log(`Request ID: ${
|
|
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(`
|
|
601
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(`
|
|
602
|
-
Task ${o} submitted successfully.`);}catch(
|
|
603
|
-
Task ${o} approved.`),console.log(`Status: ${n.task.status}`),n.payout&&(console.log(`Payout: $${n.payout.amountUsd.toFixed(2)} (${n.payout.status})`),n.payout.txHash&&console.log(`TX: ${n.payout.txHash}`)));}catch(t){console.error("Failed to approve task:",t instanceof Error?t.message:t),process.exit(1);}}async function
|
|
604
|
-
Task ${o} submission rejected.`),t&&console.log(`Feedback: ${t}`));}catch(n){console.error("Failed to reject task:",n instanceof Error?n.message:n),process.exit(1);}}async function
|
|
605
|
-
Task ${o} cancelled.`);}catch(t){console.error("Failed to cancel task:",t instanceof Error?t.message:t),process.exit(1);}}async function
|
|
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(`
|
|
606
740
|
mixrpay task - Manage the task board
|
|
607
741
|
|
|
608
742
|
USAGE
|
|
@@ -645,24 +779,24 @@ EXAMPLES
|
|
|
645
779
|
mixrpay task request task_abc123
|
|
646
780
|
mixrpay task submit task_abc123 --output "Found 10 papers..."
|
|
647
781
|
mixrpay task approve task_abc123
|
|
648
|
-
`);return}switch(s){case "create":await
|
|
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(`
|
|
649
783
|
Token Balances
|
|
650
784
|
`),console.log(`Wallet: ${o.wallet_address}`),console.log(`Chain: ${o.chain} (${o.chain_id})
|
|
651
|
-
`);let t=Object.entries(o.balances);if(t.length===0)console.log("No token balances found.");else for(let[n,
|
|
652
|
-
Delegation Budget:`),console.log(` Total: $${o.delegation.budget_total_usd}`),console.log(` Spent: $${o.delegation.budget_spent_usd}`),console.log(` Remaining: $${o.delegation.budget_remaining_usd}`));}}catch(s){console.error("Failed to get balances:",s instanceof Error?s.message:s),process.exit(1);}}async function
|
|
653
|
-
Usage: mixrpay defi transfer <to> <amount> --token USDC`),process.exit(1));let
|
|
654
|
-
Transferring ${
|
|
655
|
-
`),console.log(`TX Hash: ${
|
|
656
|
-
Usage: mixrpay defi swap --sell ETH --buy USDC --amount 0.1`),process.exit(1));try{let
|
|
657
|
-
Swapping ${t} ${s} \u2192 ${o}...`);let
|
|
658
|
-
`),console.log(`TX Hash: ${
|
|
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(`
|
|
659
793
|
Usage: mixrpay defi bridge --amount 100 --to arbitrum`),console.error(`
|
|
660
|
-
Note: Bridges FROM Base to the destination chain.`),process.exit(1));try{let
|
|
661
|
-
Bridging ${o} ${s} from Base \u2192 ${t}...`);let
|
|
662
|
-
`),console.log(`Order ID: ${
|
|
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(`
|
|
663
797
|
Payment History (Current Session)
|
|
664
798
|
`),o.length===0)console.log("No payments in current session."),console.log(`
|
|
665
|
-
Note: Only session-scoped history is available.`),console.log("For full DeFi history, check your wallet on a block explorer.");else for(let t of o){let n=new Date(t.timestamp).toLocaleDateString(),
|
|
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(`
|
|
666
800
|
mixrpay defi - DeFi operations
|
|
667
801
|
|
|
668
802
|
USAGE
|
|
@@ -702,20 +836,20 @@ EXAMPLES
|
|
|
702
836
|
mixrpay defi transfer 0x123... 10.00 --token USDC
|
|
703
837
|
mixrpay defi swap --sell ETH --buy USDC --amount 0.1
|
|
704
838
|
mixrpay defi bridge --amount 100 --to arbitrum
|
|
705
|
-
`);return}switch(s){case "transfer":await
|
|
706
|
-
Usage: mixrpay plan submit --title "Plan" --steps '[...]'`),process.exit(1));let
|
|
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(`
|
|
707
841
|
Plan Submitted!
|
|
708
|
-
`),console.log(`Plan ID: ${g.planId}`),console.log(`Status: ${g.status}`),g.approvalUrl&&console.log(`Approval URL: ${g.approvalUrl}`));}catch(
|
|
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(`
|
|
709
843
|
Plan: ${n.title||o}
|
|
710
|
-
`),console.log(`Status: ${n.status}`),console.log(`Progress: ${
|
|
711
|
-
Steps:`);for(let
|
|
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(`
|
|
712
846
|
Plans
|
|
713
|
-
`);let n=t.plans||[];if(n.length===0)console.log("No plans found.");else {for(let
|
|
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(`
|
|
714
848
|
Executing plan ${o}...`);let n=await t.executePlan(o);s?d(n,!0):(console.log(`Plan execution started!
|
|
715
|
-
`),console.log(`Status: ${n.status}`),console.log("\nUse `mixrpay plan wait` to wait for completion."));}catch(t){console.error("Failed to execute plan:",t instanceof Error?t.message:t),process.exit(1);}}async function
|
|
716
|
-
Waiting for plan ${o}...`);let
|
|
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(`
|
|
717
851
|
Plan completed!
|
|
718
|
-
`),console.log(`Status: ${
|
|
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(`
|
|
719
853
|
mixrpay plan - Manage multi-step plans
|
|
720
854
|
|
|
721
855
|
USAGE
|
|
@@ -745,19 +879,19 @@ EXAMPLES
|
|
|
745
879
|
mixrpay plan list
|
|
746
880
|
mixrpay plan execute plan_abc123
|
|
747
881
|
mixrpay plan wait plan_abc123
|
|
748
|
-
`);return}switch(s){case "submit":await
|
|
749
|
-
Usage: mixrpay approval request --action "transfer" --context "Send $10 to Bob"`),process.exit(1));let
|
|
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(`
|
|
750
884
|
Auto-approved!
|
|
751
|
-
`),console.log(`Reason: ${
|
|
885
|
+
`),console.log(`Reason: ${l.reason}`)):"id"in l&&(console.log(`
|
|
752
886
|
Approval Request Created!
|
|
753
|
-
`),console.log(`Approval ID: ${
|
|
754
|
-
Waiting for human approval...`),console.log(`Use \`mixrpay approval wait ${
|
|
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(`
|
|
755
889
|
Approval: ${n.requestId}
|
|
756
|
-
`),console.log(`Status: ${n.status}`),n.responseNote&&console.log(`Note: ${n.responseNote}`),n.approvalScope&&console.log(`Scope: ${n.approvalScope}`),n.respondedAt&&console.log(`Responded: ${n.respondedAt.toLocaleString()}`));}catch(t){console.error("Failed to get approval status:",t instanceof Error?t.message:t),process.exit(1);}}async function
|
|
757
|
-
Approval ${o}: ${n.status.toUpperCase()}`);}catch(t){console.error("Failed to check approval:",t instanceof Error?t.message:t),process.exit(1);}}async function
|
|
758
|
-
Waiting for approval ${o}...`);let
|
|
759
|
-
Approval ${
|
|
760
|
-
`),console.log(`Status: ${
|
|
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(`
|
|
761
895
|
mixrpay approval - Human approval workflow
|
|
762
896
|
|
|
763
897
|
USAGE
|
|
@@ -788,22 +922,27 @@ EXAMPLES
|
|
|
788
922
|
mixrpay approval request --action "transfer" --description "Send $100 to Bob" --amount 100
|
|
789
923
|
mixrpay approval status appr_abc123
|
|
790
924
|
mixrpay approval wait appr_abc123 --timeout 300
|
|
791
|
-
`);return}switch(s){case "request":await
|
|
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(`
|
|
792
926
|
MixrPay CLI - Manage AI agent payments
|
|
793
927
|
|
|
794
928
|
USAGE
|
|
795
929
|
mixrpay <command> [options]
|
|
796
930
|
|
|
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
|
+
|
|
797
935
|
AUTHENTICATION
|
|
798
|
-
login Authenticate via browser
|
|
936
|
+
login Authenticate via browser (alternative to init)
|
|
799
937
|
logout Clear saved credentials
|
|
800
938
|
whoami Show current authentication status
|
|
801
|
-
register Register a new agent
|
|
939
|
+
register Register a new agent (advanced - prefer init)
|
|
802
940
|
status Show agent balance and session info
|
|
803
941
|
|
|
804
942
|
WALLET & BUDGET
|
|
805
943
|
wallet Manage your agent wallet (balance, send, create, etc.)
|
|
806
944
|
budget Show available budget for spawning
|
|
945
|
+
creds Manage credential vault (store/retrieve API keys securely)
|
|
807
946
|
spawn Create a child invite for a sub-agent
|
|
808
947
|
children List child sessions
|
|
809
948
|
sessions Manage merchant sessions
|
|
@@ -837,11 +976,11 @@ OPTIONS
|
|
|
837
976
|
--baseUrl Override MixrPay API URL (default: https://www.mixrpay.com)
|
|
838
977
|
|
|
839
978
|
EXAMPLES
|
|
840
|
-
#
|
|
841
|
-
mixrpay
|
|
979
|
+
# Set up your agent (one command)
|
|
980
|
+
mixrpay init --name "MyAgent"
|
|
842
981
|
|
|
843
|
-
#
|
|
844
|
-
mixrpay
|
|
982
|
+
# Set up with invite code (instant access with budget)
|
|
983
|
+
mixrpay init --invite mixr-abc123
|
|
845
984
|
|
|
846
985
|
# Check wallet balance
|
|
847
986
|
mixrpay wallet
|
|
@@ -866,9 +1005,9 @@ EXAMPLES
|
|
|
866
1005
|
|
|
867
1006
|
TOOL CLI
|
|
868
1007
|
For full tool gateway access, use:
|
|
869
|
-
npx mixrpay-tool <provider> <tool_name> '<json>'
|
|
870
|
-
npx mixrpay-tool list
|
|
871
|
-
npx mixrpay-tool help <provider>
|
|
1008
|
+
npx --package @mixrpay/agent-sdk mixrpay-tool <provider> <tool_name> '<json>'
|
|
1009
|
+
npx --package @mixrpay/agent-sdk mixrpay-tool list
|
|
1010
|
+
npx --package @mixrpay/agent-sdk mixrpay-tool help <provider>
|
|
872
1011
|
|
|
873
1012
|
ENVIRONMENT VARIABLES
|
|
874
1013
|
MIXRPAY_SESSION_KEY Session key for authentication
|
|
@@ -878,4 +1017,4 @@ ENVIRONMENT VARIABLES
|
|
|
878
1017
|
AGENT_WALLET_KEY Agent's wallet private key
|
|
879
1018
|
|
|
880
1019
|
For more info, visit: https://docs.mixrpay.com/cli
|
|
881
|
-
`);}function
|
|
1020
|
+
`);}function To(){import('./agent-wallet-7CS7WY4F.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);});
|