@moonpay/cli 1.48.0 → 1.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
2
- import{b as m,d as b}from"./chunk-LMDE72OE.js";var G={};b(G,{decrypt:()=>k,encrypt:()=>T,encryptedFileSchema:()=>O});import{randomBytes as A,scryptSync as v,createCipheriv as X,createDecipheriv as $}from"crypto";import{z as i}from"zod";function T(n,t){let r=A(32),o=v(t,r,D,{N:R,r:L,p:F,maxmem:K}),s=A(12),c=X("aes-256-gcm",o,s),_=Buffer.concat([c.update(n,"utf8"),c.final()]);return{encryption:{cipher:"aes-256-gcm",kdf:"scrypt",kdfparams:{n:R,r:L,p:F},salt:r.toString("base64"),iv:s.toString("base64"),tag:c.getAuthTag().toString("base64")},data:_.toString("base64")}}function k(n,t){let{salt:r,iv:o,tag:s,kdfparams:c}=n.encryption,_=v(t,Buffer.from(r,"base64"),D,{N:c.n,r:c.r,p:c.p,maxmem:K}),x=$("aes-256-gcm",_,Buffer.from(o,"base64"),{authTagLength:16});return x.setAuthTag(Buffer.from(s,"base64")),Buffer.concat([x.update(Buffer.from(n.data,"base64")),x.final()]).toString("utf8")}var R,L,F,D,K,O,P=m(()=>{"use strict";R=2**18,L=8,F=1,D=32,K=512*1024*1024,O=i.object({encryption:i.object({cipher:i.literal("aes-256-gcm"),kdf:i.literal("scrypt"),kdfparams:i.object({n:i.number(),r:i.number(),p:i.number()}),salt:i.string(),iv:i.string(),tag:i.string()}),data:i.string()})});import{readFileSync as W}from"fs";import{join as z}from"path";import{homedir as q}from"os";function en(){if(f!==void 0)return f;try{f=JSON.parse(W(z(q(),".config","moonpay","consent.json"),"utf-8")).agentId??null}catch{f=null}return f??null}function rn(){return process.env.OPENCLAW_SHELL?"openclaw":process.env.CLAUDECODE?"claude-code":process.env.CODEX_CI?"codex":process.env.GEMINI_CLI?"gemini-cli":"human"}function U(){let n={"Content-Type":"application/json",[Z]:Q,[tn]:rn()},t=en();return t&&(n[nn]=t),n}var Q,Z,nn,f,tn,j=m(()=>{"use strict";Q="1.48.0",Z="X-CLI-Version",nn="X-Agent-Id";tn="X-Agent"});import*as e from"fs";import*as Y from"os";import*as g from"path";function d(){e.existsSync(l)||e.mkdirSync(l,{recursive:!0,mode:448})}function H(n,t,r){let o=n+`.tmp.${process.pid}`;e.writeFileSync(o,t,{encoding:"utf-8",mode:r}),e.renameSync(o,n)}function sn(){d();try{let n=e.openSync(u,e.constants.O_CREAT|e.constants.O_EXCL|e.constants.O_WRONLY,384);e.writeSync(n,JSON.stringify({pid:process.pid,ts:Date.now()})),e.closeSync(n)}catch(n){if(n.code!=="EEXIST")throw n;try{let t=JSON.parse(e.readFileSync(u,"utf-8"));if(Date.now()-t.ts<on)return null}catch{}try{e.unlinkSync(u)}catch{}try{let t=e.openSync(u,e.constants.O_CREAT|e.constants.O_EXCL|e.constants.O_WRONLY,384);e.writeSync(t,JSON.stringify({pid:process.pid,ts:Date.now()})),e.closeSync(t)}catch{return null}}return()=>{try{e.unlinkSync(u)}catch{}}}function B(){if(!e.existsSync(w))return null;try{let n=JSON.parse(e.readFileSync(w,"utf-8"));return n.baseUrl?n:null}catch{return null}}function Pn(){let n=B();return n||(an(N),N)}function S(){if(!e.existsSync(p))return null;let n=h();if(!n)return null;try{let t=JSON.parse(e.readFileSync(p,"utf-8")),r=O.parse(t),o=k(r,n),s=JSON.parse(o);return!s.accessToken||!s.baseUrl?null:s}catch{return null}}function cn(n){let t=I(),r=T(JSON.stringify(n),t);d(),H(p,JSON.stringify(r,null,2),384)}function an(n){d(),H(w,JSON.stringify(n,null,2),384)}function Un(){e.existsSync(p)&&e.unlinkSync(p)}function jn(){let n=B(),t=S();return n?.baseUrl??t?.baseUrl??N.baseUrl}async function fn(n,t,r){let o=await fetch(`${n}/api/tools/${encodeURIComponent(t)}`,{method:"POST",signal:AbortSignal.timeout(15e3),headers:U(),body:JSON.stringify(r)}),s=await o.json();if(!o.ok){let c=s;throw new Error(c?.error??`${t} failed (${o.status})`)}return s}async function un(n){if(!n.refreshToken)throw new Error("No refresh token available");let t=sn();if(!t){await new Promise(o=>setTimeout(o,2e3));let r=S();if(r&&r.expiresAt>Date.now())return r;throw new Error("Token refresh failed (concurrent refresh in progress)")}try{let r=S();if(r&&r.expiresAt>Date.now()+6e4)return r;let o=await fn(n.baseUrl,"refresh",{refreshToken:n.refreshToken}),s={accessToken:o.accessToken,refreshToken:o.refreshToken,expiresAt:o.expiresAt*1e3,baseUrl:n.baseUrl};return cn(s),s}finally{t()}}async function Jn(){let n=S();if(!n)return null;if(Date.now()>=n.expiresAt-ln){if(n.refreshToken)try{return(await un(n)).accessToken}catch{return null}return null}return n.accessToken}var l,w,p,u,N,on,ln,V=m(()=>{"use strict";P();J();j();l=g.join(Y.homedir(),".config","moonpay"),w=g.join(l,"config.json"),p=g.join(l,"credentials.json"),u=g.join(l,".credentials.lock"),N={baseUrl:"https://agents.moonpay.com"};on=3e4;ln=300*1e3});var Nn={};b(Nn,{ensureEncryptionKey:()=>I,getEncryptionKey:()=>h});import{execFileSync as C,execSync as pn}from"child_process";import{randomBytes as gn}from"crypto";import{existsSync as dn,readFileSync as yn,writeFileSync as mn}from"fs";import{homedir as Sn,platform as M}from"os";import{join as hn}from"path";function Cn(n){try{C("security",["delete-generic-password","-s",a,"-a",y],{stdio:"ignore"})}catch{}C("security",["add-generic-password","-s",a,"-a",y,"-w",n],{stdio:"ignore"})}function En(){try{return C("security",["find-generic-password","-s",a,"-a",y,"-w"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return null}}function _n(n){pn(`printf '%s' | secret-tool store --label="${a}" service "${a}" account "${y}"`,{input:n,stdio:["pipe","ignore","ignore"]})}function xn(){try{return C("secret-tool",["lookup","service",a,"account",y],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return null}}function On(n){d(),mn(E,n,{encoding:"utf-8",mode:384})}function Tn(){try{return dn(E)&&yn(E,"utf-8").trim()||null}catch{return null}}function kn(n){try{let t=M();return t==="darwin"?(Cn(n),!0):t==="linux"?(_n(n),!0):!1}catch{return!1}}function wn(){let n=M();return n==="darwin"?En():n==="linux"?xn():null}function h(){let n=process.env.MOONPAY_ENCRYPTION_KEY;return n||(wn()??Tn())}function I(){let n=h();if(n)return n;let t=gn(32).toString("hex");return kn(t)||(On(t),process.stderr.write("Note: Keychain unavailable. Encryption key stored in "+E+`
2
+ import{b as m,d as b}from"./chunk-LMDE72OE.js";var G={};b(G,{decrypt:()=>k,encrypt:()=>T,encryptedFileSchema:()=>O});import{randomBytes as A,scryptSync as v,createCipheriv as X,createDecipheriv as $}from"crypto";import{z as i}from"zod";function T(n,t){let r=A(32),o=v(t,r,D,{N:R,r:L,p:F,maxmem:K}),s=A(12),c=X("aes-256-gcm",o,s),_=Buffer.concat([c.update(n,"utf8"),c.final()]);return{encryption:{cipher:"aes-256-gcm",kdf:"scrypt",kdfparams:{n:R,r:L,p:F},salt:r.toString("base64"),iv:s.toString("base64"),tag:c.getAuthTag().toString("base64")},data:_.toString("base64")}}function k(n,t){let{salt:r,iv:o,tag:s,kdfparams:c}=n.encryption,_=v(t,Buffer.from(r,"base64"),D,{N:c.n,r:c.r,p:c.p,maxmem:K}),x=$("aes-256-gcm",_,Buffer.from(o,"base64"),{authTagLength:16});return x.setAuthTag(Buffer.from(s,"base64")),Buffer.concat([x.update(Buffer.from(n.data,"base64")),x.final()]).toString("utf8")}var R,L,F,D,K,O,P=m(()=>{"use strict";R=2**18,L=8,F=1,D=32,K=512*1024*1024,O=i.object({encryption:i.object({cipher:i.literal("aes-256-gcm"),kdf:i.literal("scrypt"),kdfparams:i.object({n:i.number(),r:i.number(),p:i.number()}),salt:i.string(),iv:i.string(),tag:i.string()}),data:i.string()})});import{readFileSync as W}from"fs";import{join as z}from"path";import{homedir as q}from"os";function en(){if(f!==void 0)return f;try{f=JSON.parse(W(z(q(),".config","moonpay","consent.json"),"utf-8")).agentId??null}catch{f=null}return f??null}function rn(){return process.env.OPENCLAW_SHELL?"openclaw":process.env.CLAUDECODE?"claude-code":process.env.CODEX_CI?"codex":process.env.GEMINI_CLI?"gemini-cli":"human"}function U(){let n={"Content-Type":"application/json",[Z]:Q,[tn]:rn()},t=en();return t&&(n[nn]=t),n}var Q,Z,nn,f,tn,j=m(()=>{"use strict";Q="1.49.1",Z="X-CLI-Version",nn="X-Agent-Id";tn="X-Agent"});import*as e from"fs";import*as Y from"os";import*as g from"path";function d(){e.existsSync(l)||e.mkdirSync(l,{recursive:!0,mode:448})}function H(n,t,r){let o=n+`.tmp.${process.pid}`;e.writeFileSync(o,t,{encoding:"utf-8",mode:r}),e.renameSync(o,n)}function sn(){d();try{let n=e.openSync(u,e.constants.O_CREAT|e.constants.O_EXCL|e.constants.O_WRONLY,384);e.writeSync(n,JSON.stringify({pid:process.pid,ts:Date.now()})),e.closeSync(n)}catch(n){if(n.code!=="EEXIST")throw n;try{let t=JSON.parse(e.readFileSync(u,"utf-8"));if(Date.now()-t.ts<on)return null}catch{}try{e.unlinkSync(u)}catch{}try{let t=e.openSync(u,e.constants.O_CREAT|e.constants.O_EXCL|e.constants.O_WRONLY,384);e.writeSync(t,JSON.stringify({pid:process.pid,ts:Date.now()})),e.closeSync(t)}catch{return null}}return()=>{try{e.unlinkSync(u)}catch{}}}function B(){if(!e.existsSync(w))return null;try{let n=JSON.parse(e.readFileSync(w,"utf-8"));return n.baseUrl?n:null}catch{return null}}function Pn(){let n=B();return n||(an(N),N)}function S(){if(!e.existsSync(p))return null;let n=h();if(!n)return null;try{let t=JSON.parse(e.readFileSync(p,"utf-8")),r=O.parse(t),o=k(r,n),s=JSON.parse(o);return!s.accessToken||!s.baseUrl?null:s}catch{return null}}function cn(n){let t=I(),r=T(JSON.stringify(n),t);d(),H(p,JSON.stringify(r,null,2),384)}function an(n){d(),H(w,JSON.stringify(n,null,2),384)}function Un(){e.existsSync(p)&&e.unlinkSync(p)}function jn(){let n=B(),t=S();return n?.baseUrl??t?.baseUrl??N.baseUrl}async function fn(n,t,r){let o=await fetch(`${n}/api/tools/${encodeURIComponent(t)}`,{method:"POST",signal:AbortSignal.timeout(15e3),headers:U(),body:JSON.stringify(r)}),s=await o.json();if(!o.ok){let c=s;throw new Error(c?.error??`${t} failed (${o.status})`)}return s}async function un(n){if(!n.refreshToken)throw new Error("No refresh token available");let t=sn();if(!t){await new Promise(o=>setTimeout(o,2e3));let r=S();if(r&&r.expiresAt>Date.now())return r;throw new Error("Token refresh failed (concurrent refresh in progress)")}try{let r=S();if(r&&r.expiresAt>Date.now()+6e4)return r;let o=await fn(n.baseUrl,"refresh",{refreshToken:n.refreshToken}),s={accessToken:o.accessToken,refreshToken:o.refreshToken,expiresAt:o.expiresAt*1e3,baseUrl:n.baseUrl};return cn(s),s}finally{t()}}async function Jn(){let n=S();if(!n)return null;if(Date.now()>=n.expiresAt-ln){if(n.refreshToken)try{return(await un(n)).accessToken}catch{return null}return null}return n.accessToken}var l,w,p,u,N,on,ln,V=m(()=>{"use strict";P();J();j();l=g.join(Y.homedir(),".config","moonpay"),w=g.join(l,"config.json"),p=g.join(l,"credentials.json"),u=g.join(l,".credentials.lock"),N={baseUrl:"https://agents.moonpay.com"};on=3e4;ln=300*1e3});var Nn={};b(Nn,{ensureEncryptionKey:()=>I,getEncryptionKey:()=>h});import{execFileSync as C,execSync as pn}from"child_process";import{randomBytes as gn}from"crypto";import{existsSync as dn,readFileSync as yn,writeFileSync as mn}from"fs";import{homedir as Sn,platform as M}from"os";import{join as hn}from"path";function Cn(n){try{C("security",["delete-generic-password","-s",a,"-a",y],{stdio:"ignore"})}catch{}C("security",["add-generic-password","-s",a,"-a",y,"-w",n],{stdio:"ignore"})}function En(){try{return C("security",["find-generic-password","-s",a,"-a",y,"-w"],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return null}}function _n(n){pn(`printf '%s' | secret-tool store --label="${a}" service "${a}" account "${y}"`,{input:n,stdio:["pipe","ignore","ignore"]})}function xn(){try{return C("secret-tool",["lookup","service",a,"account",y],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return null}}function On(n){d(),mn(E,n,{encoding:"utf-8",mode:384})}function Tn(){try{return dn(E)&&yn(E,"utf-8").trim()||null}catch{return null}}function kn(n){try{let t=M();return t==="darwin"?(Cn(n),!0):t==="linux"?(_n(n),!0):!1}catch{return!1}}function wn(){let n=M();return n==="darwin"?En():n==="linux"?xn():null}function h(){let n=process.env.MOONPAY_ENCRYPTION_KEY;return n||(wn()??Tn())}function I(){let n=h();if(n)return n;let t=gn(32).toString("hex");return kn(t)||(On(t),process.stderr.write("Note: Keychain unavailable. Encryption key stored in "+E+`
3
3
  `)),t}var a,y,E,J=m(()=>{"use strict";V();a="moonpay-cli",y="encryption-key",E=hn(Sn(),".config","moonpay",".encryption-key")});export{G as a,P as b,Nn as c,J as d,Q as e,U as f,j as g,d as h,Pn as i,S as j,cn as k,Un as l,jn as m,un as n,Jn as o,V as p};
@@ -1,2 +1,2 @@
1
1
  process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
2
- import{f as vt,g as yt,j as Pt,m as Ct,n as kt,o as It,p as At}from"./chunk-36SEVBRS.js";var n=class extends Error{constructor(r,i,u){super(r);this.status=i;this.toolName=u;this.name="MoonPayError"}},c=class extends n{constructor(t="Authentication required"){super(t,401),this.name="AuthError"}},o=class extends n{constructor(t="Rate limit exceeded"){super(t,429),this.name="RateLimitError"}},l=class extends n{constructor(t,r){super(t,400,r),this.name="ValidationError"}},s=class extends n{constructor(t){super(`Tool not found: ${t}`,404,t),this.name="ToolNotFoundError"}},p=class extends n{constructor(t,r){super(`Tool "${t}" has been renamed to "${r}"`,410,t),this.name="ToolRenamedError",this.newName=r}};var Mt="https://agents.moonpay.com",Rt=36e4,h=class{constructor(t={}){this.baseUrl=(t.baseUrl??Mt).replace(/\/$/,""),this.auth=t.auth??{type:"none"},this.timeout=t.timeout??Rt,this.headers=t.headers??{}}async _call(t,r){let i=`${this.baseUrl}/api/tools/${encodeURIComponent(t)}`,u=await this.buildHeaders(),a=await fetch(i,{method:"POST",headers:u,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout)});if(a.status===401&&this.auth.type==="bearer"&&this.auth.refreshToken)try{let gt=await this.auth.refreshToken();u.Authorization=`Bearer ${gt}`,a=await fetch(i,{method:"POST",headers:u,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout)})}catch{throw new c("Token refresh failed")}return this.handleResponse(a,t)}async buildHeaders(){let t={"Content-Type":"application/json",...this.headers};if(this.auth.type==="bearer"){let r=await this.auth.getToken();r&&(t.Authorization=`Bearer ${r}`)}return t}async handleResponse(t,r){if(t.ok)return t.json();let i;try{i=await t.json()}catch{i={error:t.statusText}}let u=i?.error??i?.message,a=typeof u=="string"?u:u?JSON.stringify(u):`Request failed with status ${t.status}`;switch(t.status){case 400:throw new l(a,r);case 401:throw new c(a);case 404:throw new s(r);case 410:throw new p(r,i?.newName??"unknown");case 429:throw new o(a);default:throw new n(a,t.status,r)}}};var _=class{constructor(t){this.client=t}build(t){return this.client._call("card_delegation_approve_transaction_build",t)}},O=class{constructor(t){this.client=t}get transaction(){return new _(this.client)}},v=class{constructor(t){this.client=t}build(t){return this.client._call("card_delegation_revoke_transaction_build",t)}},P=class{constructor(t){this.client=t}get transaction(){return new v(this.client)}},C=class{constructor(t){this.client=t}retrieve(t){return this.client._call("card_delegation_token_retrieve",t)}},k=class{constructor(t){this.client=t}get approve(){return new O(this.client)}get revoke(){return new P(this.client)}get token(){return new C(this.client)}},I=class{constructor(t){this.client=t}check(t){return this.client._call("card_onboarding_check",t)}finish(t){return this.client._call("card_onboarding_finish",t)}start(t){return this.client._call("card_onboarding_start",t)}},g=class{constructor(t){this.client=t}list(t){return this.client._call("card_transaction_list",t)}},y=class{constructor(t){this.client=t}retrieve(t){return this.client._call("card_user_retrieve",t)}},A=class{constructor(t){this.client=t}check(t){return this.client._call("card_wallet_check",t)}link(t){return this.client._call("card_wallet_link",t)}list(t){return this.client._call("card_wallet_list",t)}unlink(t){return this.client._call("card_wallet_unlink",t)}},M=class{constructor(t){this.client=t}get delegation(){return new k(this.client)}get onboarding(){return new I(this.client)}get transaction(){return new g(this.client)}get user(){return new y(this.client)}get wallet(){return new A(this.client)}create(t){return this.client._call("card_create",t)}freeze(t){return this.client._call("card_freeze",t)}retrieve(t){return this.client._call("card_retrieve",t)}reveal(t){return this.client._call("card_reveal",t)}unfreeze(t){return this.client._call("card_unfreeze",t)}},R=class{constructor(t){this.client=t}list(t){return this.client._call("chain_list",t)}retrieve(t){return this.client._call("chain_retrieve",t)}},f=class{constructor(t){this.client=t}create(t){return this.client._call("cli_activation_create",t)}update(t){return this.client._call("cli_activation_update",t)}},w=class{constructor(t){this.client=t}get activation(){return new f(this.client)}},T=class{constructor(t){this.client=t}add(t){return this.client._call("commerce_cart_add",t)}remove(t){return this.client._call("commerce_cart_remove",t)}retrieve(t){return this.client._call("commerce_cart_retrieve",t)}update(t){return this.client._call("commerce_cart_update",t)}},L=class{constructor(t){this.client=t}pay(t){return this.client._call("commerce_checkout_pay",t)}start(t){return this.client._call("commerce_checkout_start",t)}},V=class{constructor(t){this.client=t}retrieve(t){return this.client._call("commerce_product_retrieve",t)}search(t){return this.client._call("commerce_product_search",t)}},x=class{constructor(t){this.client=t}list(t){return this.client._call("commerce_store_list",t)}retrieve(t){return this.client._call("commerce_store_retrieve",t)}},b=class{constructor(t){this.client=t}get cart(){return new T(this.client)}get checkout(){return new L(this.client)}get product(){return new V(this.client)}get store(){return new x(this.client)}search(t){return this.client._call("commerce_search",t)}},S=class{constructor(t){this.client=t}list(t){return this.client._call("deposit_transaction_list",t)}},B=class{constructor(t){this.client=t}get transaction(){return new S(this.client)}create(t){return this.client._call("deposit_create",t)}retrieve(t){return this.client._call("deposit_retrieve",t)}},U=class{constructor(t){this.client=t}create(t){return this.client._call("feedback_create",t)}},W=class{constructor(t){this.client=t}buy(t){return this.client._call("gateway_buy",t)}search(t){return this.client._call("gateway_search",t)}},D=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_activity_list",t)}},E=class{constructor(t){this.client=t}retrieve(t){return this.client._call("prediction-market_market_event_retrieve",t)}},F=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_market_price_history_list",t)}},z=class{constructor(t){this.client=t}get history(){return new F(this.client)}retrieve(t){return this.client._call("prediction-market_market_price_retrieve",t)}},H=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_market_tag_list",t)}},$=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_market_trending_list",t)}},G=class{constructor(t){this.client=t}get event(){return new E(this.client)}get price(){return new z(this.client)}get tag(){return new H(this.client)}get trending(){return new $(this.client)}search(t){return this.client._call("prediction-market_market_search",t)}},K=class{constructor(t){this.client=t}retrieve(t){return this.client._call("prediction-market_pnl_retrieve",t)}},j=class{constructor(t){this.client=t}buy(t){return this.client._call("prediction-market_position_buy",t)}list(t){return this.client._call("prediction-market_position_list",t)}redeem(t){return this.client._call("prediction-market_position_redeem",t)}sell(t){return this.client._call("prediction-market_position_sell",t)}},J=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_trade_list",t)}},q=class{constructor(t){this.client=t}create(t){return this.client._call("prediction-market_user_create",t)}},Q=class{constructor(t){this.client=t}get activity(){return new D(this.client)}get market(){return new G(this.client)}get pnl(){return new K(this.client)}get position(){return new j(this.client)}get trade(){return new J(this.client)}get user(){return new q(this.client)}},X=class{constructor(t){this.client=t}build(t){return this.client._call("swaps_transaction_build",t)}},Y=class{constructor(t){this.client=t}get transaction(){return new X(this.client)}},Z=class{constructor(t){this.client=t}list(t){return this.client._call("token_balance_list",t)}},N=class{constructor(t){this.client=t}list(t){return this.client._call("token_holder_list",t)}},tt=class{constructor(t){this.client=t}list(t){return this.client._call("token_ohlcv_list",t)}},et=class{constructor(t){this.client=t}list(t){return this.client._call("token_trending_list",t)}},rt=class{constructor(t){this.client=t}get balance(){return new Z(this.client)}get holder(){return new N(this.client)}get ohlcv(){return new tt(this.client)}get trending(){return new et(this.client)}check(t){return this.client._call("token_check",t)}retrieve(t){return this.client._call("token_retrieve",t)}search(t){return this.client._call("token_search",t)}},nt=class{constructor(t){this.client=t}list(t){return this.client._call("transaction_list",t)}prepare(t){return this.client._call("transaction_prepare",t)}register(t){return this.client._call("transaction_register",t)}retrieve(t){return this.client._call("transaction_retrieve",t)}send(t){return this.client._call("transaction_send",t)}},it=class{constructor(t){this.client=t}retrieve(t){return this.client._call("user_retrieve",t)}},ut=class{constructor(t){this.client=t}accept(t){return this.client._call("virtual-account_agreement_accept",t)}list(t){return this.client._call("virtual-account_agreement_list",t)}},at=class{constructor(t){this.client=t}delete(t){return this.client._call("virtual-account_bank-account_delete",t)}list(t){return this.client._call("virtual-account_bank-account_list",t)}register(t){return this.client._call("virtual-account_bank-account_register",t)}retrieve(t){return this.client._call("virtual-account_bank-account_retrieve",t)}},ct=class{constructor(t){this.client=t}continue(t){return this.client._call("virtual-account_kyc_continue",t)}restart(t){return this.client._call("virtual-account_kyc_restart",t)}},ot=class{constructor(t){this.client=t}cancel(t){return this.client._call("virtual-account_offramp_cancel",t)}create(t){return this.client._call("virtual-account_offramp_create",t)}initiate(t){return this.client._call("virtual-account_offramp_initiate",t)}list(t){return this.client._call("virtual-account_offramp_list",t)}retrieve(t){return this.client._call("virtual-account_offramp_retrieve",t)}update(t){return this.client._call("virtual-account_offramp_update",t)}},lt=class{constructor(t){this.client=t}create(t){return this.client._call("virtual-account_onramp_payment_create",t)}retrieve(t){return this.client._call("virtual-account_onramp_payment_retrieve",t)}},st=class{constructor(t){this.client=t}get payment(){return new lt(this.client)}cancel(t){return this.client._call("virtual-account_onramp_cancel",t)}create(t){return this.client._call("virtual-account_onramp_create",t)}list(t){return this.client._call("virtual-account_onramp_list",t)}retrieve(t){return this.client._call("virtual-account_onramp_retrieve",t)}update(t){return this.client._call("virtual-account_onramp_update",t)}},pt=class{constructor(t){this.client=t}list(t){return this.client._call("virtual-account_transaction_list",t)}},mt=class{constructor(t){this.client=t}list(t){return this.client._call("virtual-account_wallet_list",t)}register(t){return this.client._call("virtual-account_wallet_register",t)}},ht=class{constructor(t){this.client=t}get agreement(){return new ut(this.client)}get bankAccount(){return new at(this.client)}get kyc(){return new ct(this.client)}get offramp(){return new ot(this.client)}get onramp(){return new st(this.client)}get transaction(){return new pt(this.client)}get wallet(){return new mt(this.client)}create(t){return this.client._call("virtual-account_create",t)}retrieve(t){return this.client._call("virtual-account_retrieve",t)}},dt=class{constructor(t){this.client=t}list(t){return this.client._call("wallet_activity_list",t)}},_t=class{constructor(t){this.client=t}retrieve(t){return this.client._call("wallet_pnl_retrieve",t)}},Ot=class{constructor(t){this.client=t}get activity(){return new dt(this.client)}get pnl(){return new _t(this.client)}discover(t){return this.client._call("wallet_discover",t)}},m=class extends h{constructor(t={}){super(t)}get card(){return new M(this)}get chain(){return new R(this)}get cli(){return new w(this)}get commerce(){return new b(this)}get deposit(){return new B(this)}get feedback(){return new U(this)}get gateway(){return new W(this)}get predictionMarket(){return new Q(this)}get swaps(){return new Y(this)}get token(){return new rt(this)}get transaction(){return new nt(this)}get user(){return new it(this)}get virtualAccount(){return new ht(this)}get wallet(){return new Ot(this)}buy(t){return this._call("buy",t)}login(t){return this._call("login",t)}refresh(t){return this._call("refresh",t)}verify(t){return this._call("verify",t)}};At();yt();var d=null;function ft(){return d||(d=new m({baseUrl:Ct(),auth:{type:"bearer",getToken:It,refreshToken:async()=>{let e=Pt();if(!e?.refreshToken)throw new Error("No refresh token available");return(await kt(e)).accessToken}},headers:vt()})),d}var Ft=new Proxy({},{get(e,t){return Reflect.get(ft(),t)}});function zt(){d=null}export{m as a,Ft as b,zt as c};
2
+ import{f as vt,g as yt,j as Pt,m as Ct,n as kt,o as It,p as At}from"./chunk-7OJWAG57.js";var n=class extends Error{constructor(r,i,u){super(r);this.status=i;this.toolName=u;this.name="MoonPayError"}},c=class extends n{constructor(t="Authentication required"){super(t,401),this.name="AuthError"}},o=class extends n{constructor(t="Rate limit exceeded"){super(t,429),this.name="RateLimitError"}},l=class extends n{constructor(t,r){super(t,400,r),this.name="ValidationError"}},s=class extends n{constructor(t){super(`Tool not found: ${t}`,404,t),this.name="ToolNotFoundError"}},p=class extends n{constructor(t,r){super(`Tool "${t}" has been renamed to "${r}"`,410,t),this.name="ToolRenamedError",this.newName=r}};var Mt="https://agents.moonpay.com",Rt=36e4,h=class{constructor(t={}){this.baseUrl=(t.baseUrl??Mt).replace(/\/$/,""),this.auth=t.auth??{type:"none"},this.timeout=t.timeout??Rt,this.headers=t.headers??{}}async _call(t,r){let i=`${this.baseUrl}/api/tools/${encodeURIComponent(t)}`,u=await this.buildHeaders(),a=await fetch(i,{method:"POST",headers:u,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout)});if(a.status===401&&this.auth.type==="bearer"&&this.auth.refreshToken)try{let gt=await this.auth.refreshToken();u.Authorization=`Bearer ${gt}`,a=await fetch(i,{method:"POST",headers:u,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout)})}catch{throw new c("Token refresh failed")}return this.handleResponse(a,t)}async buildHeaders(){let t={"Content-Type":"application/json",...this.headers};if(this.auth.type==="bearer"){let r=await this.auth.getToken();r&&(t.Authorization=`Bearer ${r}`)}return t}async handleResponse(t,r){if(t.ok)return t.json();let i;try{i=await t.json()}catch{i={error:t.statusText}}let u=i?.error??i?.message,a=typeof u=="string"?u:u?JSON.stringify(u):`Request failed with status ${t.status}`;switch(t.status){case 400:throw new l(a,r);case 401:throw new c(a);case 404:throw new s(r);case 410:throw new p(r,i?.newName??"unknown");case 429:throw new o(a);default:throw new n(a,t.status,r)}}};var _=class{constructor(t){this.client=t}build(t){return this.client._call("card_delegation_approve_transaction_build",t)}},O=class{constructor(t){this.client=t}get transaction(){return new _(this.client)}},v=class{constructor(t){this.client=t}build(t){return this.client._call("card_delegation_revoke_transaction_build",t)}},P=class{constructor(t){this.client=t}get transaction(){return new v(this.client)}},C=class{constructor(t){this.client=t}retrieve(t){return this.client._call("card_delegation_token_retrieve",t)}},k=class{constructor(t){this.client=t}get approve(){return new O(this.client)}get revoke(){return new P(this.client)}get token(){return new C(this.client)}},I=class{constructor(t){this.client=t}check(t){return this.client._call("card_onboarding_check",t)}finish(t){return this.client._call("card_onboarding_finish",t)}start(t){return this.client._call("card_onboarding_start",t)}},g=class{constructor(t){this.client=t}list(t){return this.client._call("card_transaction_list",t)}},y=class{constructor(t){this.client=t}retrieve(t){return this.client._call("card_user_retrieve",t)}},A=class{constructor(t){this.client=t}check(t){return this.client._call("card_wallet_check",t)}link(t){return this.client._call("card_wallet_link",t)}list(t){return this.client._call("card_wallet_list",t)}unlink(t){return this.client._call("card_wallet_unlink",t)}},M=class{constructor(t){this.client=t}get delegation(){return new k(this.client)}get onboarding(){return new I(this.client)}get transaction(){return new g(this.client)}get user(){return new y(this.client)}get wallet(){return new A(this.client)}create(t){return this.client._call("card_create",t)}freeze(t){return this.client._call("card_freeze",t)}retrieve(t){return this.client._call("card_retrieve",t)}reveal(t){return this.client._call("card_reveal",t)}unfreeze(t){return this.client._call("card_unfreeze",t)}},R=class{constructor(t){this.client=t}list(t){return this.client._call("chain_list",t)}retrieve(t){return this.client._call("chain_retrieve",t)}},f=class{constructor(t){this.client=t}create(t){return this.client._call("cli_activation_create",t)}update(t){return this.client._call("cli_activation_update",t)}},w=class{constructor(t){this.client=t}get activation(){return new f(this.client)}},T=class{constructor(t){this.client=t}add(t){return this.client._call("commerce_cart_add",t)}remove(t){return this.client._call("commerce_cart_remove",t)}retrieve(t){return this.client._call("commerce_cart_retrieve",t)}update(t){return this.client._call("commerce_cart_update",t)}},L=class{constructor(t){this.client=t}pay(t){return this.client._call("commerce_checkout_pay",t)}start(t){return this.client._call("commerce_checkout_start",t)}},V=class{constructor(t){this.client=t}retrieve(t){return this.client._call("commerce_product_retrieve",t)}search(t){return this.client._call("commerce_product_search",t)}},x=class{constructor(t){this.client=t}list(t){return this.client._call("commerce_store_list",t)}retrieve(t){return this.client._call("commerce_store_retrieve",t)}},b=class{constructor(t){this.client=t}get cart(){return new T(this.client)}get checkout(){return new L(this.client)}get product(){return new V(this.client)}get store(){return new x(this.client)}search(t){return this.client._call("commerce_search",t)}},S=class{constructor(t){this.client=t}list(t){return this.client._call("deposit_transaction_list",t)}},B=class{constructor(t){this.client=t}get transaction(){return new S(this.client)}create(t){return this.client._call("deposit_create",t)}retrieve(t){return this.client._call("deposit_retrieve",t)}},U=class{constructor(t){this.client=t}create(t){return this.client._call("feedback_create",t)}},W=class{constructor(t){this.client=t}buy(t){return this.client._call("gateway_buy",t)}search(t){return this.client._call("gateway_search",t)}},D=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_activity_list",t)}},E=class{constructor(t){this.client=t}retrieve(t){return this.client._call("prediction-market_market_event_retrieve",t)}},F=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_market_price_history_list",t)}},z=class{constructor(t){this.client=t}get history(){return new F(this.client)}retrieve(t){return this.client._call("prediction-market_market_price_retrieve",t)}},H=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_market_tag_list",t)}},$=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_market_trending_list",t)}},G=class{constructor(t){this.client=t}get event(){return new E(this.client)}get price(){return new z(this.client)}get tag(){return new H(this.client)}get trending(){return new $(this.client)}search(t){return this.client._call("prediction-market_market_search",t)}},K=class{constructor(t){this.client=t}retrieve(t){return this.client._call("prediction-market_pnl_retrieve",t)}},j=class{constructor(t){this.client=t}buy(t){return this.client._call("prediction-market_position_buy",t)}list(t){return this.client._call("prediction-market_position_list",t)}redeem(t){return this.client._call("prediction-market_position_redeem",t)}sell(t){return this.client._call("prediction-market_position_sell",t)}},J=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_trade_list",t)}},q=class{constructor(t){this.client=t}create(t){return this.client._call("prediction-market_user_create",t)}},Q=class{constructor(t){this.client=t}get activity(){return new D(this.client)}get market(){return new G(this.client)}get pnl(){return new K(this.client)}get position(){return new j(this.client)}get trade(){return new J(this.client)}get user(){return new q(this.client)}},X=class{constructor(t){this.client=t}build(t){return this.client._call("swaps_transaction_build",t)}},Y=class{constructor(t){this.client=t}get transaction(){return new X(this.client)}},Z=class{constructor(t){this.client=t}list(t){return this.client._call("token_balance_list",t)}},N=class{constructor(t){this.client=t}list(t){return this.client._call("token_holder_list",t)}},tt=class{constructor(t){this.client=t}list(t){return this.client._call("token_ohlcv_list",t)}},et=class{constructor(t){this.client=t}list(t){return this.client._call("token_trending_list",t)}},rt=class{constructor(t){this.client=t}get balance(){return new Z(this.client)}get holder(){return new N(this.client)}get ohlcv(){return new tt(this.client)}get trending(){return new et(this.client)}check(t){return this.client._call("token_check",t)}retrieve(t){return this.client._call("token_retrieve",t)}search(t){return this.client._call("token_search",t)}},nt=class{constructor(t){this.client=t}list(t){return this.client._call("transaction_list",t)}prepare(t){return this.client._call("transaction_prepare",t)}register(t){return this.client._call("transaction_register",t)}retrieve(t){return this.client._call("transaction_retrieve",t)}send(t){return this.client._call("transaction_send",t)}},it=class{constructor(t){this.client=t}retrieve(t){return this.client._call("user_retrieve",t)}},ut=class{constructor(t){this.client=t}accept(t){return this.client._call("virtual-account_agreement_accept",t)}list(t){return this.client._call("virtual-account_agreement_list",t)}},at=class{constructor(t){this.client=t}delete(t){return this.client._call("virtual-account_bank-account_delete",t)}list(t){return this.client._call("virtual-account_bank-account_list",t)}register(t){return this.client._call("virtual-account_bank-account_register",t)}retrieve(t){return this.client._call("virtual-account_bank-account_retrieve",t)}},ct=class{constructor(t){this.client=t}continue(t){return this.client._call("virtual-account_kyc_continue",t)}restart(t){return this.client._call("virtual-account_kyc_restart",t)}},ot=class{constructor(t){this.client=t}cancel(t){return this.client._call("virtual-account_offramp_cancel",t)}create(t){return this.client._call("virtual-account_offramp_create",t)}initiate(t){return this.client._call("virtual-account_offramp_initiate",t)}list(t){return this.client._call("virtual-account_offramp_list",t)}retrieve(t){return this.client._call("virtual-account_offramp_retrieve",t)}update(t){return this.client._call("virtual-account_offramp_update",t)}},lt=class{constructor(t){this.client=t}create(t){return this.client._call("virtual-account_onramp_payment_create",t)}retrieve(t){return this.client._call("virtual-account_onramp_payment_retrieve",t)}},st=class{constructor(t){this.client=t}get payment(){return new lt(this.client)}cancel(t){return this.client._call("virtual-account_onramp_cancel",t)}create(t){return this.client._call("virtual-account_onramp_create",t)}list(t){return this.client._call("virtual-account_onramp_list",t)}retrieve(t){return this.client._call("virtual-account_onramp_retrieve",t)}update(t){return this.client._call("virtual-account_onramp_update",t)}},pt=class{constructor(t){this.client=t}list(t){return this.client._call("virtual-account_transaction_list",t)}},mt=class{constructor(t){this.client=t}list(t){return this.client._call("virtual-account_wallet_list",t)}register(t){return this.client._call("virtual-account_wallet_register",t)}},ht=class{constructor(t){this.client=t}get agreement(){return new ut(this.client)}get bankAccount(){return new at(this.client)}get kyc(){return new ct(this.client)}get offramp(){return new ot(this.client)}get onramp(){return new st(this.client)}get transaction(){return new pt(this.client)}get wallet(){return new mt(this.client)}create(t){return this.client._call("virtual-account_create",t)}retrieve(t){return this.client._call("virtual-account_retrieve",t)}},dt=class{constructor(t){this.client=t}list(t){return this.client._call("wallet_activity_list",t)}},_t=class{constructor(t){this.client=t}retrieve(t){return this.client._call("wallet_pnl_retrieve",t)}},Ot=class{constructor(t){this.client=t}get activity(){return new dt(this.client)}get pnl(){return new _t(this.client)}discover(t){return this.client._call("wallet_discover",t)}},m=class extends h{constructor(t={}){super(t)}get card(){return new M(this)}get chain(){return new R(this)}get cli(){return new w(this)}get commerce(){return new b(this)}get deposit(){return new B(this)}get feedback(){return new U(this)}get gateway(){return new W(this)}get predictionMarket(){return new Q(this)}get swaps(){return new Y(this)}get token(){return new rt(this)}get transaction(){return new nt(this)}get user(){return new it(this)}get virtualAccount(){return new ht(this)}get wallet(){return new Ot(this)}buy(t){return this._call("buy",t)}login(t){return this._call("login",t)}refresh(t){return this._call("refresh",t)}verify(t){return this._call("verify",t)}};At();yt();var d=null;function ft(){return d||(d=new m({baseUrl:Ct(),auth:{type:"bearer",getToken:It,refreshToken:async()=>{let e=Pt();if(!e?.refreshToken)throw new Error("No refresh token available");return(await kt(e)).accessToken}},headers:vt()})),d}var Ft=new Proxy({},{get(e,t){return Reflect.get(ft(),t)}});function zt(){d=null}export{m as a,Ft as b,zt as c};