@moonpay/cli 1.93.0 → 1.93.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,2 +1,2 @@
1
1
  process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
2
- import{f as qt,g as Ft,j as Bt,m as Ht,n as Ut,o as Et,p as zt}from"./chunk-TE4JNXUJ.js";var n=class extends Error{constructor(r,u,i){super(r);this.status=u;this.toolName=i;this.name="MoonPayError"}},o=class extends n{constructor(t="Authentication required"){super(t,401),this.name="AuthError"}},c=class extends n{constructor(t="Rate limit exceeded"){super(t,429),this.name="RateLimitError"}},a=class extends n{constructor(t,r){super(t,400,r),this.name="ValidationError"}},l=class extends n{constructor(t){super(`Tool not found: ${t}`,404,t),this.name="ToolNotFoundError"}},s=class extends n{constructor(t,r){super(`Tool "${t}" has been renamed to "${r}"`,410,t),this.name="ToolRenamedError",this.newName=r}};var $t="https://agents.moonpay.com",Gt=36e4;function Wt(e){return!!e&&typeof e=="object"}function d(e){if(typeof e=="string")return e.length>0&&e!=="[object Object]"?e:void 0;if(typeof e=="number"||typeof e=="boolean")return String(e);if(!Wt(e))return;let t=d(e.error)??d(e.message)??d(e.errorMessage);if(t)return t;try{return JSON.stringify(e)}catch{return}}function Kt(e,t){if(!Wt(e))return;let r=e[t];return typeof r=="string"?r:void 0}var h=class{constructor(t={}){this.baseUrl=(t.baseUrl??$t).replace(/\/$/,""),this.auth=t.auth??{type:"none"},this.timeout=t.timeout??Gt,this.headers=t.headers??{}}async _call(t,r){let u=`${this.baseUrl}/api/tools/${encodeURIComponent(t)}`,i=await this.buildHeaders(),_=await fetch(u,{method:"POST",headers:i,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout)});if(_.status===401&&this.auth.type==="bearer"&&this.auth.refreshToken)try{let Dt=await this.auth.refreshToken();i.Authorization=`Bearer ${Dt}`,_=await fetch(u,{method:"POST",headers:i,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout)})}catch{throw new o("Token refresh failed")}return this.handleResponse(_,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 u;try{u=await t.json()}catch{u={error:t.statusText}}let i=d(u)??`Request failed with status ${t.status}`;switch(t.status){case 400:throw new a(i,r);case 401:throw new o(i);case 404:throw new l(r);case 410:throw new s(r,Kt(u,"newName")??"unknown");case 429:throw new c(i);default:throw new n(i,t.status,r)}}};var O=class{constructor(t){this.client=t}create(t){return this.client._call("app_activation_create",t)}},v=class{constructor(t){this.client=t}get activation(){return new O(this.client)}},P=class{constructor(t){this.client=t}build(t){return this.client._call("card_delegation_approve_transaction_build",t)}},C=class{constructor(t){this.client=t}get transaction(){return new P(this.client)}},y=class{constructor(t){this.client=t}build(t){return this.client._call("card_delegation_revoke_transaction_build",t)}},I=class{constructor(t){this.client=t}get transaction(){return new y(this.client)}},g=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 C(this.client)}get revoke(){return new I(this.client)}get token(){return new g(this.client)}},A=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)}},f=class{constructor(t){this.client=t}list(t){return this.client._call("card_transaction_list",t)}},R=class{constructor(t){this.client=t}retrieve(t){return this.client._call("card_user_retrieve",t)}},w=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)}},L=class{constructor(t){this.client=t}get delegation(){return new k(this.client)}get onboarding(){return new A(this.client)}get transaction(){return new f(this.client)}get user(){return new R(this.client)}get wallet(){return new w(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)}},M=class{constructor(t){this.client=t}list(t){return this.client._call("chain_list",t)}retrieve(t){return this.client._call("chain_retrieve",t)}},T=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)}},x=class{constructor(t){this.client=t}get activation(){return new T(this.client)}},V=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)}},b=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)}},S=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)}},q=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 V(this.client)}get checkout(){return new b(this.client)}get product(){return new S(this.client)}get store(){return new q(this.client)}search(t){return this.client._call("commerce_search",t)}},H=class{constructor(t){this.client=t}list(t){return this.client._call("deposit_transaction_list",t)}},U=class{constructor(t){this.client=t}get transaction(){return new H(this.client)}create(t){return this.client._call("deposit_create",t)}retrieve(t){return this.client._call("deposit_retrieve",t)}},E=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}retrieve(t){return this.client._call("hyperliquid_balance_retrieve",t)}},F=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_candle_list",t)}},z=class{constructor(t){this.client=t}create(t){return this.client._call("hyperliquid_deposit_create",t)}},$=class{constructor(t){this.client=t}submit(t){return this.client._call("hyperliquid_exchange_submit",t)}},G=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_funding_payment_list",t)}},K=class{constructor(t){this.client=t}get payment(){return new G(this.client)}},j=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_market_list",t)}},J=class{constructor(t){this.client=t}create(t){return this.client._call("hyperliquid_order_create",t)}list(t){return this.client._call("hyperliquid_order_list",t)}},Q=class{constructor(t){this.client=t}retrieve(t){return this.client._call("hyperliquid_orderbook_retrieve",t)}},X=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_position_list",t)}},Y=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_predicted_funding_list",t)}},Z=class{constructor(t){this.client=t}get funding(){return new Y(this.client)}},N=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_price_list",t)}},tt=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_trade_list",t)}},et=class{constructor(t){this.client=t}get balance(){return new D(this.client)}get candle(){return new F(this.client)}get deposit(){return new z(this.client)}get exchange(){return new $(this.client)}get funding(){return new K(this.client)}get market(){return new j(this.client)}get order(){return new J(this.client)}get orderbook(){return new Q(this.client)}get position(){return new X(this.client)}get predicted(){return new Z(this.client)}get price(){return new N(this.client)}get trade(){return new tt(this.client)}},rt=class{constructor(t){this.client=t}redeem(t){return this.client._call("polymarket_position_redeem",t)}sell(t){return this.client._call("polymarket_position_sell",t)}},nt=class{constructor(t){this.client=t}get position(){return new rt(this.client)}},it=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_event_list",t)}retrieve(t){return this.client._call("prediction-market_event_retrieve",t)}search(t){return this.client._call("prediction-market_event_search",t)}},ut=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_market_ohlcv_list",t)}},ot=class{constructor(t){this.client=t}get ohlcv(){return new ut(this.client)}},ct=class{constructor(t){this.client=t}retrieve(t){return this.client._call("prediction-market_order_retrieve",t)}},at=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)}},lt=class{constructor(t){this.client=t}get event(){return new it(this.client)}get market(){return new ot(this.client)}get order(){return new ct(this.client)}get position(){return new at(this.client)}},st=class{constructor(t){this.client=t}check(t){return this.client._call("solana_balance_check",t)}},pt=class{constructor(t){this.client=t}get balance(){return new st(this.client)}},dt=class{constructor(t){this.client=t}retrieve(t){return this.client._call("swaps_quote_retrieve",t)}},ht=class{constructor(t){this.client=t}build(t){return this.client._call("swaps_transaction_build",t)}},mt=class{constructor(t){this.client=t}get quote(){return new dt(this.client)}get transaction(){return new ht(this.client)}},_t=class{constructor(t){this.client=t}list(t){return this.client._call("token_activity_list",t)}},Ot=class{constructor(t){this.client=t}list(t){return this.client._call("token_balance_list",t)}},vt=class{constructor(t){this.client=t}list(t){return this.client._call("token_holder_list",t)}},Pt=class{constructor(t){this.client=t}list(t){return this.client._call("token_ohlcv_list",t)}},Ct=class{constructor(t){this.client=t}list(t){return this.client._call("token_trending_list",t)}},yt=class{constructor(t){this.client=t}get activity(){return new _t(this.client)}get balance(){return new Ot(this.client)}get holder(){return new vt(this.client)}get ohlcv(){return new Pt(this.client)}get trending(){return new Ct(this.client)}check(t){return this.client._call("token_check",t)}list(t){return this.client._call("token_list",t)}retrieve(t){return this.client._call("token_retrieve",t)}search(t){return this.client._call("token_search",t)}},It=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)}},gt=class{constructor(t){this.client=t}retrieve(t){return this.client._call("user_retrieve",t)}},kt=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)}},ft=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)}},Rt=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)}},wt=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)}},Lt=class{constructor(t){this.client=t}get payment(){return new wt(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)}},Mt=class{constructor(t){this.client=t}list(t){return this.client._call("virtual-account_transaction_list",t)}},Tt=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)}},xt=class{constructor(t){this.client=t}get agreement(){return new kt(this.client)}get bankAccount(){return new At(this.client)}get kyc(){return new ft(this.client)}get offramp(){return new Rt(this.client)}get onramp(){return new Lt(this.client)}get transaction(){return new Mt(this.client)}get wallet(){return new Tt(this.client)}create(t){return this.client._call("virtual-account_create",t)}retrieve(t){return this.client._call("virtual-account_retrieve",t)}},Vt=class{constructor(t){this.client=t}list(t){return this.client._call("wallet_activity_list",t)}},bt=class{constructor(t){this.client=t}retrieve(t){return this.client._call("wallet_pnl_retrieve",t)}},St=class{constructor(t){this.client=t}get activity(){return new Vt(this.client)}get pnl(){return new bt(this.client)}discover(t){return this.client._call("wallet_discover",t)}},p=class extends h{constructor(t={}){super(t)}get app(){return new v(this)}get card(){return new L(this)}get chain(){return new M(this)}get cli(){return new x(this)}get commerce(){return new B(this)}get deposit(){return new U(this)}get feedback(){return new E(this)}get gateway(){return new W(this)}get hyperliquid(){return new et(this)}get polymarket(){return new nt(this)}get predictionMarket(){return new lt(this)}get solana(){return new pt(this)}get swaps(){return new mt(this)}get token(){return new yt(this)}get transaction(){return new It(this)}get user(){return new gt(this)}get virtualAccount(){return new xt(this)}get wallet(){return new St(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)}};zt();Ft();var m=null;function jt(){return m||(m=new p({baseUrl:Ht(),auth:{type:"bearer",getToken:Et,refreshToken:async()=>{let e=Bt();if(!e?.refreshToken)throw new Error("No refresh token available");return(await Ut(e)).accessToken}},headers:qt()})),m}var oe=new Proxy({},{get(e,t){return Reflect.get(jt(),t)}});function ce(){m=null}export{p as a,oe as b,ce as c};
2
+ import{f as qt,g as Ft,j as Bt,m as Ht,n as Ut,o as Et,p as zt}from"./chunk-HEJI3KC5.js";var n=class extends Error{constructor(r,u,i){super(r);this.status=u;this.toolName=i;this.name="MoonPayError"}},o=class extends n{constructor(t="Authentication required"){super(t,401),this.name="AuthError"}},c=class extends n{constructor(t="Rate limit exceeded"){super(t,429),this.name="RateLimitError"}},a=class extends n{constructor(t,r){super(t,400,r),this.name="ValidationError"}},l=class extends n{constructor(t){super(`Tool not found: ${t}`,404,t),this.name="ToolNotFoundError"}},s=class extends n{constructor(t,r){super(`Tool "${t}" has been renamed to "${r}"`,410,t),this.name="ToolRenamedError",this.newName=r}};var $t="https://agents.moonpay.com",Gt=36e4;function Wt(e){return!!e&&typeof e=="object"}function d(e){if(typeof e=="string")return e.length>0&&e!=="[object Object]"?e:void 0;if(typeof e=="number"||typeof e=="boolean")return String(e);if(!Wt(e))return;let t=d(e.error)??d(e.message)??d(e.errorMessage);if(t)return t;try{return JSON.stringify(e)}catch{return}}function Kt(e,t){if(!Wt(e))return;let r=e[t];return typeof r=="string"?r:void 0}var h=class{constructor(t={}){this.baseUrl=(t.baseUrl??$t).replace(/\/$/,""),this.auth=t.auth??{type:"none"},this.timeout=t.timeout??Gt,this.headers=t.headers??{}}async _call(t,r){let u=`${this.baseUrl}/api/tools/${encodeURIComponent(t)}`,i=await this.buildHeaders(),_=await fetch(u,{method:"POST",headers:i,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout)});if(_.status===401&&this.auth.type==="bearer"&&this.auth.refreshToken)try{let Dt=await this.auth.refreshToken();i.Authorization=`Bearer ${Dt}`,_=await fetch(u,{method:"POST",headers:i,body:JSON.stringify(r),signal:AbortSignal.timeout(this.timeout)})}catch{throw new o("Token refresh failed")}return this.handleResponse(_,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 u;try{u=await t.json()}catch{u={error:t.statusText}}let i=d(u)??`Request failed with status ${t.status}`;switch(t.status){case 400:throw new a(i,r);case 401:throw new o(i);case 404:throw new l(r);case 410:throw new s(r,Kt(u,"newName")??"unknown");case 429:throw new c(i);default:throw new n(i,t.status,r)}}};var O=class{constructor(t){this.client=t}create(t){return this.client._call("app_activation_create",t)}},v=class{constructor(t){this.client=t}get activation(){return new O(this.client)}},P=class{constructor(t){this.client=t}build(t){return this.client._call("card_delegation_approve_transaction_build",t)}},C=class{constructor(t){this.client=t}get transaction(){return new P(this.client)}},y=class{constructor(t){this.client=t}build(t){return this.client._call("card_delegation_revoke_transaction_build",t)}},I=class{constructor(t){this.client=t}get transaction(){return new y(this.client)}},g=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 C(this.client)}get revoke(){return new I(this.client)}get token(){return new g(this.client)}},A=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)}},f=class{constructor(t){this.client=t}list(t){return this.client._call("card_transaction_list",t)}},R=class{constructor(t){this.client=t}retrieve(t){return this.client._call("card_user_retrieve",t)}},w=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)}},L=class{constructor(t){this.client=t}get delegation(){return new k(this.client)}get onboarding(){return new A(this.client)}get transaction(){return new f(this.client)}get user(){return new R(this.client)}get wallet(){return new w(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)}},M=class{constructor(t){this.client=t}list(t){return this.client._call("chain_list",t)}retrieve(t){return this.client._call("chain_retrieve",t)}},T=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)}},x=class{constructor(t){this.client=t}get activation(){return new T(this.client)}},V=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)}},b=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)}},S=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)}},q=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 V(this.client)}get checkout(){return new b(this.client)}get product(){return new S(this.client)}get store(){return new q(this.client)}search(t){return this.client._call("commerce_search",t)}},H=class{constructor(t){this.client=t}list(t){return this.client._call("deposit_transaction_list",t)}},U=class{constructor(t){this.client=t}get transaction(){return new H(this.client)}create(t){return this.client._call("deposit_create",t)}retrieve(t){return this.client._call("deposit_retrieve",t)}},E=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}retrieve(t){return this.client._call("hyperliquid_balance_retrieve",t)}},F=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_candle_list",t)}},z=class{constructor(t){this.client=t}create(t){return this.client._call("hyperliquid_deposit_create",t)}},$=class{constructor(t){this.client=t}submit(t){return this.client._call("hyperliquid_exchange_submit",t)}},G=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_funding_payment_list",t)}},K=class{constructor(t){this.client=t}get payment(){return new G(this.client)}},j=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_market_list",t)}},J=class{constructor(t){this.client=t}create(t){return this.client._call("hyperliquid_order_create",t)}list(t){return this.client._call("hyperliquid_order_list",t)}},Q=class{constructor(t){this.client=t}retrieve(t){return this.client._call("hyperliquid_orderbook_retrieve",t)}},X=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_position_list",t)}},Y=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_predicted_funding_list",t)}},Z=class{constructor(t){this.client=t}get funding(){return new Y(this.client)}},N=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_price_list",t)}},tt=class{constructor(t){this.client=t}list(t){return this.client._call("hyperliquid_trade_list",t)}},et=class{constructor(t){this.client=t}get balance(){return new D(this.client)}get candle(){return new F(this.client)}get deposit(){return new z(this.client)}get exchange(){return new $(this.client)}get funding(){return new K(this.client)}get market(){return new j(this.client)}get order(){return new J(this.client)}get orderbook(){return new Q(this.client)}get position(){return new X(this.client)}get predicted(){return new Z(this.client)}get price(){return new N(this.client)}get trade(){return new tt(this.client)}},rt=class{constructor(t){this.client=t}redeem(t){return this.client._call("polymarket_position_redeem",t)}sell(t){return this.client._call("polymarket_position_sell",t)}},nt=class{constructor(t){this.client=t}get position(){return new rt(this.client)}},it=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_event_list",t)}retrieve(t){return this.client._call("prediction-market_event_retrieve",t)}search(t){return this.client._call("prediction-market_event_search",t)}},ut=class{constructor(t){this.client=t}list(t){return this.client._call("prediction-market_market_ohlcv_list",t)}},ot=class{constructor(t){this.client=t}get ohlcv(){return new ut(this.client)}},ct=class{constructor(t){this.client=t}retrieve(t){return this.client._call("prediction-market_order_retrieve",t)}},at=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)}},lt=class{constructor(t){this.client=t}get event(){return new it(this.client)}get market(){return new ot(this.client)}get order(){return new ct(this.client)}get position(){return new at(this.client)}},st=class{constructor(t){this.client=t}check(t){return this.client._call("solana_balance_check",t)}},pt=class{constructor(t){this.client=t}get balance(){return new st(this.client)}},dt=class{constructor(t){this.client=t}retrieve(t){return this.client._call("swaps_quote_retrieve",t)}},ht=class{constructor(t){this.client=t}build(t){return this.client._call("swaps_transaction_build",t)}},mt=class{constructor(t){this.client=t}get quote(){return new dt(this.client)}get transaction(){return new ht(this.client)}},_t=class{constructor(t){this.client=t}list(t){return this.client._call("token_activity_list",t)}},Ot=class{constructor(t){this.client=t}list(t){return this.client._call("token_balance_list",t)}},vt=class{constructor(t){this.client=t}list(t){return this.client._call("token_holder_list",t)}},Pt=class{constructor(t){this.client=t}list(t){return this.client._call("token_ohlcv_list",t)}},Ct=class{constructor(t){this.client=t}list(t){return this.client._call("token_trending_list",t)}},yt=class{constructor(t){this.client=t}get activity(){return new _t(this.client)}get balance(){return new Ot(this.client)}get holder(){return new vt(this.client)}get ohlcv(){return new Pt(this.client)}get trending(){return new Ct(this.client)}check(t){return this.client._call("token_check",t)}list(t){return this.client._call("token_list",t)}retrieve(t){return this.client._call("token_retrieve",t)}search(t){return this.client._call("token_search",t)}},It=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)}},gt=class{constructor(t){this.client=t}retrieve(t){return this.client._call("user_retrieve",t)}},kt=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)}},ft=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)}},Rt=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)}},wt=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)}},Lt=class{constructor(t){this.client=t}get payment(){return new wt(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)}},Mt=class{constructor(t){this.client=t}list(t){return this.client._call("virtual-account_transaction_list",t)}},Tt=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)}},xt=class{constructor(t){this.client=t}get agreement(){return new kt(this.client)}get bankAccount(){return new At(this.client)}get kyc(){return new ft(this.client)}get offramp(){return new Rt(this.client)}get onramp(){return new Lt(this.client)}get transaction(){return new Mt(this.client)}get wallet(){return new Tt(this.client)}create(t){return this.client._call("virtual-account_create",t)}retrieve(t){return this.client._call("virtual-account_retrieve",t)}},Vt=class{constructor(t){this.client=t}list(t){return this.client._call("wallet_activity_list",t)}},bt=class{constructor(t){this.client=t}retrieve(t){return this.client._call("wallet_pnl_retrieve",t)}},St=class{constructor(t){this.client=t}get activity(){return new Vt(this.client)}get pnl(){return new bt(this.client)}discover(t){return this.client._call("wallet_discover",t)}},p=class extends h{constructor(t={}){super(t)}get app(){return new v(this)}get card(){return new L(this)}get chain(){return new M(this)}get cli(){return new x(this)}get commerce(){return new B(this)}get deposit(){return new U(this)}get feedback(){return new E(this)}get gateway(){return new W(this)}get hyperliquid(){return new et(this)}get polymarket(){return new nt(this)}get predictionMarket(){return new lt(this)}get solana(){return new pt(this)}get swaps(){return new mt(this)}get token(){return new yt(this)}get transaction(){return new It(this)}get user(){return new gt(this)}get virtualAccount(){return new xt(this)}get wallet(){return new St(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)}};zt();Ft();var m=null;function jt(){return m||(m=new p({baseUrl:Ht(),auth:{type:"bearer",getToken:Et,refreshToken:async()=>{let e=Bt();if(!e?.refreshToken)throw new Error("No refresh token available");return(await Ut(e)).accessToken}},headers:qt()})),m}var oe=new Proxy({},{get(e,t){return Reflect.get(jt(),t)}});function ce(){m=null}export{p as a,oe as b,ce as c};
@@ -1,2 +1,2 @@
1
1
  process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
2
- import{b as a,c as b}from"./chunk-CYX6WNGA.js";import"./chunk-TE4JNXUJ.js";import"./chunk-LMDE72OE.js";export{a as moonpay,b as resetClient};
2
+ import{b as a,c as b}from"./chunk-XCYYHA62.js";import"./chunk-HEJI3KC5.js";import"./chunk-LMDE72OE.js";export{a as moonpay,b as resetClient};
package/dist/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
3
- import{a as J,b as x,c as A,d as S}from"./chunk-FV6GEO2L.js";import{b as N}from"./chunk-CYX6WNGA.js";import{m as K}from"./chunk-XPVNVJMA.js";import{e as R,g as ee}from"./chunk-TE4JNXUJ.js";import"./chunk-LMDE72OE.js";import{Command as me}from"commander";var ne=!process.env.NO_COLOR&&process.stdout.isTTY===!0;function w(e){return t=>ne?`${e}${t}\x1B[0m`:t}var p={bold:w("\x1B[1m"),dim:w("\x1B[2m"),green:w("\x1B[32m"),yellow:w("\x1B[33m"),cyan:w("\x1B[36m"),red:w("\x1B[31m")};function $(e){if(e==null)return!0;let t=typeof e;return t==="string"||t==="number"||t==="boolean"}function k(e){return e==null?"-":String(e)}function C(e,t=0){let n=" ".repeat(t);return $(e)?`${n}${k(e)}`:Array.isArray(e)?e.length===0?`${n}${p.dim("(empty)")}`:e.every($)?e.map(o=>`${n}- ${k(o)}`).join(`
3
+ import{a as J,b as x,c as A,d as S}from"./chunk-TD26ORN4.js";import{b as N}from"./chunk-XCYYHA62.js";import{m as K}from"./chunk-JYEDCTBB.js";import{e as R,g as ee}from"./chunk-HEJI3KC5.js";import"./chunk-LMDE72OE.js";import{Command as me}from"commander";var ne=!process.env.NO_COLOR&&process.stdout.isTTY===!0;function w(e){return t=>ne?`${e}${t}\x1B[0m`:t}var p={bold:w("\x1B[1m"),dim:w("\x1B[2m"),green:w("\x1B[32m"),yellow:w("\x1B[33m"),cyan:w("\x1B[36m"),red:w("\x1B[31m")};function $(e){if(e==null)return!0;let t=typeof e;return t==="string"||t==="number"||t==="boolean"}function k(e){return e==null?"-":String(e)}function C(e,t=0){let n=" ".repeat(t);return $(e)?`${n}${k(e)}`:Array.isArray(e)?e.length===0?`${n}${p.dim("(empty)")}`:e.every($)?e.map(o=>`${n}- ${k(o)}`).join(`
4
4
  `):e.map(o=>{if(typeof o!="object"||o===null)return`${n}- ${k(o)}`;let s=Object.entries(o),a=[],[c,f]=s[0];$(f)?a.push(`${n}- ${p.bold(c)}: ${k(f)}`):(a.push(`${n}- ${p.bold(c)}:`),a.push(C(f,t+2)));for(let[d,g]of s.slice(1))$(g)?a.push(`${n} ${p.bold(d)}: ${k(g)}`):(a.push(`${n} ${p.bold(d)}:`),a.push(C(g,t+2)));return a.join(`
5
5
  `)}).join(`
6
6
 
7
7
  `):typeof e=="object"&&e!==null?Object.entries(e).map(([s,a])=>$(a)?`${n}${p.bold(s)}: ${k(a)}`:`${n}${p.bold(s)}:
8
8
  ${C(a,t+1)}`).join(`
9
9
  `):""}function te(e){if(typeof e!="object"||e===null)return e;let t=e;return"data"in t?t.data:"items"in t&&Array.isArray(t.items)&&Object.keys(t).filter(o=>o!=="items").length===0?t.items:e}function j(e,t){return t==="json"?JSON.stringify(e,null,2):C(te(e))}import{readFileSync as oe,writeFileSync as re,mkdirSync as se}from"fs";import{join as I}from"path";import{homedir as ie}from"os";var M=I(ie(),".config","moonpay"),z=I(M,"update-check.json"),ae=1440*60*1e3,ce=3e3;function le(){try{let e=oe(z,"utf-8");return JSON.parse(e)}catch{return null}}function ue(e){try{se(M,{recursive:!0}),re(z,JSON.stringify(e))}catch{}}function L(e,t){let n=e.split(".").map(Number),o=t.split(".").map(Number);for(let s=0;s<3;s++){if((n[s]??0)>(o[s]??0))return!0;if((n[s]??0)<(o[s]??0))return!1}return!1}function D(e,t){return["",p.yellow(`Update available: ${e} \u2192 ${t}`),p.dim("Run `npm i -g @moonpay/cli` to update."),""].join(`
10
- `)}function U(e){let t=null,n=le();if(n&&Date.now()-n.checkedAt<ae)return L(n.latest,e)&&(t=D(e,n.latest)),()=>t;let o=new AbortController,s=setTimeout(()=>o.abort(),ce);return fetch("https://registry.npmjs.org/@moonpay%2fcli/latest",{signal:o.signal}).then(a=>a.json()).then(a=>{let c=a.version;c&&(ue({latest:c,checkedAt:Date.now()}),L(c,e)&&(t=D(e,c)))}).catch(()=>{}).finally(()=>clearTimeout(s)),()=>t}ee();async function Z(e){let t=e.wallet,n=e.chain;if(typeof t!="string"||typeof n!="string")return;let o=K(t);if(!o)return;let s;try{s=(await N.chain.retrieve({chain:n})).keyFamily}catch{return}let a=s==="evm"?"ethereum":s,c=o.addresses[a];c&&(e.wallet=c)}function q(e,t){let n=e[t];return typeof n=="string"&&n.length>0?n:void 0}function T(e){let t=e.code??e.status??e.statusCode;return typeof t=="string"||typeof t=="number"?t:void 0}function fe(e){try{return JSON.stringify(e)}catch{return}}function B(e){return e.length>0&&e!=="[object Object]"}function H(e){let t=q(e,"message");if(t&&B(t))return t;let n=e.error??e.cause??e.response;if(n&&typeof n=="object"){let o=P(n);if(B(o.message))return o.message}return q(e,"errorMessage")}function P(e){if(e instanceof Error){let t=e,n=T(t),o=H(t)??e.message;return n===void 0?{message:o}:{message:o,code:n}}if(typeof e=="string")return{message:e};if(e&&typeof e=="object"){let t=e,n=t.error;if(n&&typeof n=="object"){let a=P(n),c=a.code??T(t);return c===void 0?{message:a.message}:{...a,code:c}}let o=H(t)??(typeof n=="string"&&n.length>0?n:void 0)??fe(e)??String(e),s=T(t);return s===void 0?{message:o}:{message:o,code:s}}return{message:String(e)}}function E(e,t){let n=P(e);return t==="json"?j({error:n},"json"):n.code===void 0?n.message:`${n.message} (code: ${n.code})`}var de=U(R),h=new me;h.name("moonpay").description(`MoonPay CLI \u2014 how agents move money
10
+ `)}function U(e){let t=null,n=le();if(n&&Date.now()-n.checkedAt<ae)return L(n.latest,e)&&(t=D(e,n.latest)),()=>t;let o=new AbortController,s=setTimeout(()=>o.abort(),ce);return fetch("https://registry.npmjs.org/@moonpay%2fcli/latest",{signal:o.signal}).then(a=>a.json()).then(a=>{let c=a.version;c&&(ue({latest:c,checkedAt:Date.now()}),L(c,e)&&(t=D(e,c)))}).catch(()=>{}).finally(()=>clearTimeout(s)),()=>t}ee();async function Z(e){let t=e.wallet,n=e.chain;if(typeof t!="string"||typeof n!="string")return;let o=K(t);if(!o)return;let s;try{s=(await N.chain.retrieve({chain:n})).keyFamily}catch{return}let a=s==="evm"?"ethereum":s,c=o.addresses[a];c&&(e.wallet=c)}function q(e,t){let n=e[t];return typeof n=="string"&&n.length>0?n:void 0}function E(e){let t=e.code??e.status??e.statusCode;return typeof t=="string"||typeof t=="number"?t:void 0}function fe(e){try{return JSON.stringify(e)}catch{return}}function B(e){return e.length>0&&e!=="[object Object]"}function Y(e){let t=q(e,"message");if(t&&B(t))return t;let n=e.error??e.cause??e.response;if(n&&typeof n=="object"){let o=F(n);if(B(o.message))return o.message}return q(e,"errorMessage")}function F(e){if(e instanceof Error){let t=e,n=E(t),o=Y(t)??e.message;return n===void 0?{message:o}:{message:o,code:n}}if(typeof e=="string")return{message:e};if(e&&typeof e=="object"){let t=e,n=t.error;if(n&&typeof n=="object"){let a=F(n),c=a.code??E(t);return c===void 0?{message:a.message}:{...a,code:c}}let o=Y(t)??(typeof n=="string"&&n.length>0?n:void 0)??fe(e)??String(e),s=E(t);return s===void 0?{message:o}:{message:o,code:s}}return{message:String(e)}}function P(e,t){let n=F(e);return t==="json"?j({error:n},"json"):n.code===void 0?n.message:`${n.message} (code: ${n.code})`}var de=U(R),h=new me;h.name("moonpay").description(`MoonPay CLI \u2014 how agents move money
11
11
 
12
12
  Your agents need money. MoonPay gives them wallets, funds, and tools
13
13
  to buy, swap, bridge, and transact \u2014 all from the command line.
14
14
 
15
15
  Run \`mp skill install\` to install AI skills for Claude Code.
16
16
 
17
- `+x).version(R).option("--json","Output as JSON instead of YAML");function F(){return h.opts().json?"json":"yaml"}function Y(e){console.log(j(e,F()))}function W(){let e=de();e&&process.stderr.write(e)}h.command("mcp").description("Start MCP server over stdio (for Claude Desktop, Claude Code, etc.)").action(async()=>{let{startMcpServer:e}=await import("./mcp-FFTSHNDA.js");await e()});h.command("serve").description("Start a localhost HTTP daemon for warm tool calls (MoonAgents / UIs). GET /health \xB7 POST /v1/tools/:tool \u2014 loopback only.").option("--port <port>","Port to bind (default 8787)",e=>Number(e),8787).option("--host <host>","Loopback host only (default 127.0.0.1)","127.0.0.1").option("--force","Bind even if something already answers on this port (skip idempotent check)",!1).action(async e=>{let{startServe:t}=await import("./serve-BA33MM5E.js");try{await t({host:e.host,port:e.port,idempotent:!e.force})}catch(n){console.error(n instanceof Error?n.message:String(n)),process.exit(1)}});function G(e,t){let n=e;for(let o of t){let s=n.commands.find(a=>a.name()===o);s||(s=n.command(o)),n=s}return n}function V(e,t=""){let n=[];for(let[o,s]of Object.entries(e)){let a=t?`${t}-${o}`:o,c=s;for(;c._def.typeName==="ZodEffects";)c=c._def.schema;let f=c;f._def.typeName==="ZodNullable"&&(f=f._def.innerType),f._def.typeName==="ZodObject"&&f.shape?n.push(...V(f.shape,a)):n.push({flatKey:a,field:s,path:a.split("-")})}return n}function pe(e,t){let n={};for(let{flatKey:o,path:s}of t){let a=o.replace(/-([a-z])/g,(f,d)=>d.toUpperCase()),c=a in e?e[a]:e[o];if(s.length===1)n[s[0]]=c;else{let f=n;for(let d=0;d<s.length-1;d++)(!f[s[d]]||typeof f[s[d]]!="object")&&(f[s[d]]={}),f=f[s[d]];f[s[s.length-1]]=c}}return n}function ye(e,t){for(let n of t){let o=n.schema.name.split("_"),s=o.pop(),c=G(e,o).command(s).description(n.schema.description),f=n.schema.input.shape??{},d=V(f),g=[],b=[],_=[],O=[];for(let{flatKey:u,field:i}of d){let r=i.description??u,l=i;for(;l._def.typeName==="ZodEffects";)l=l._def.schema;let y=l._def.typeName,m=l;m._def.typeName==="ZodNullable"&&(m=m._def.innerType),m._def.typeName==="ZodNumber"&&b.push(u),m._def.typeName==="ZodRecord"&&_.push(u),m._def.typeName==="ZodBoolean"&&O.push(u),y==="ZodBoolean"?c.option(`--${u} [${u}]`,r,!1):y==="ZodNullable"?(c.option(`--${u} <${u}>`,r),g.push(u)):c.requiredOption(`--${u} <${u}>`,r)}c.action(async u=>{n.schema.name.startsWith("consent_")||await A.handler({});for(let r of g){let l=r.replace(/-([a-z])/g,(y,m)=>m.toUpperCase());u[l]===void 0&&(u[l]=null)}for(let r of b){let l=r.replace(/-([a-z])/g,(y,m)=>m.toUpperCase());u[l]!=null&&typeof u[l]=="string"&&(u[l]=Number(u[l]))}for(let r of O){let l=r.replace(/-([a-z])/g,(m,v)=>v.toUpperCase()),y=u[l];if(typeof y=="string"){let m=y.toLowerCase();m==="true"||m==="1"?u[l]=!0:(m==="false"||m==="0")&&(u[l]=!1)}}for(let r of _){let l=r.replace(/-([a-z])/g,(y,m)=>m.toUpperCase());if(typeof u[l]=="string")try{u[l]=JSON.parse(u[l])}catch{console.error(`Invalid JSON for --${r}`),process.exit(1)}}let i=pe(u,d);try{let r=await n.handler(i);Y(r)}catch(r){console.error(E(r,F())),process.exit(1)}})}}function ge(e){if(e.$ref&&e.definitions){let t=e.$ref.replace("#/definitions/","");return e.definitions[t]}return e}function he(e){return Array.isArray(e.type)?e.type.includes("null"):e.anyOf?e.anyOf.some(t=>t.type==="null"):!1}function be(e){return Array.isArray(e.type)?e.type.includes("object"):e.anyOf?e.anyOf.some(t=>t.type==="object"):e.type==="object"}function we(e){return Array.isArray(e.type)?e.type.some(t=>t==="number"||t==="integer"):e.anyOf?e.anyOf.some(t=>t.type==="number"||t.type==="integer"):e.type==="number"||e.type==="integer"}function ke(e){return Array.isArray(e.type)?e.type.includes("boolean"):e.anyOf?e.anyOf.some(t=>t.type==="boolean"):e.type==="boolean"}var Q=new Set(["swaps_transaction_build","swaps_quote_retrieve","transaction_register","virtual-account_offramp_initiate","prediction-market_position_buy","prediction-market_position_sell","prediction-market_position_redeem","commerce_cart_update","commerce_checkout_start","commerce_checkout_pay","card_delegation_approve_transaction_build","card_delegation_revoke_transaction_build","card_delegation_token_retrieve","card_wallet_link","card_wallet_unlink"]);function _e(e,t){for(let n of t){if(Q.has(n.name))continue;let o=n.name.split("_"),s=o.pop(),a=G(e,o);if(a.commands.find(i=>i.name()===s))continue;let c=a.command(s).description(n.description),f=ge(n.inputSchema),d=f.properties??{},g=new Set(f.required??[]),b=[],_=[],O=[],u=[];for(let[i,r]of Object.entries(d)){let l=r.description??i,y=he(r),m=be(r),v=we(r),X=ke(r);v&&_.push(i),X&&u.push(i),m?(O.push(i),g.has(i)&&!y?c.requiredOption(`--${i} <json>`,`${l} (as JSON)`):(c.option(`--${i} <json>`,`${l} (as JSON)`),b.push(i))):y||!g.has(i)?(c.option(`--${i} <${i}>`,l),b.push(i)):c.requiredOption(`--${i} <${i}>`,l)}c.action(async i=>{await A.handler({});for(let r of b)i[r]===void 0&&(i[r]=null);for(let r of _)i[r]!=null&&typeof i[r]=="string"&&(i[r]=Number(i[r]));for(let r of u)if(typeof i[r]=="string"){let l=i[r].toLowerCase();l==="true"||l==="1"?i[r]=!0:(l==="false"||l==="0")&&(i[r]=!1)}for(let r of O)if(typeof i[r]=="string")try{i[r]=JSON.parse(i[r])}catch{console.error(`Invalid JSON for --${r}`),process.exit(1)}try{await Z(i);let r=await N._call(n.name,i);Y(r),W()}catch(r){console.error(E(r,F())),process.exit(1)}})}}ye(h,S);_e(h,J);h.command("tools").description("List available tools").action(()=>{let e=[...S.map(n=>({name:n.schema.name,description:n.schema.description})),...J.filter(n=>!S.some(o=>o.schema.name===n.name)&&!Q.has(n.name)).map(n=>({name:n.name,description:n.description}))].sort((n,o)=>n.name.localeCompare(o.name)),t=[];for(let n of e){let o=n.name.replace(/_/g," ");t.push(` ${p.green(o.padEnd(28))} ${p.dim(n.description)}`)}t.push(""),t.push(p.dim(`${e.length} tools`)),console.log(t.join(`
17
+ `+x).version(R).option("--json","Output as JSON instead of YAML");function T(){return h.opts().json?"json":"yaml"}function H(e){console.log(j(e,T()))}function W(){let e=de();e&&process.stderr.write(e)}h.command("mcp").description("Start MCP server over stdio (for Claude Desktop, Claude Code, etc.)").action(async()=>{let{startMcpServer:e}=await import("./mcp-ADDZF3OB.js");await e()});h.command("serve").description("Local loopback mirror of agents.moonpay.com/api/tools \u2014 warm process for MoonAgents / UIs. GET /health \xB7 POST /api/tools/:tool").option("--port <port>","Port to bind (default 8787)",e=>Number(e),8787).option("--host <host>","Loopback host only (default 127.0.0.1)","127.0.0.1").option("--force","Bind even if something already answers on this port (skip idempotent check)",!1).action(async e=>{let{startServe:t}=await import("./serve-OW6YKTV2.js");try{await t({host:e.host,port:e.port,idempotent:!e.force})}catch(n){console.error(n instanceof Error?n.message:String(n)),process.exit(1)}});function G(e,t){let n=e;for(let o of t){let s=n.commands.find(a=>a.name()===o);s||(s=n.command(o)),n=s}return n}function V(e,t=""){let n=[];for(let[o,s]of Object.entries(e)){let a=t?`${t}-${o}`:o,c=s;for(;c._def.typeName==="ZodEffects";)c=c._def.schema;let f=c;f._def.typeName==="ZodNullable"&&(f=f._def.innerType),f._def.typeName==="ZodObject"&&f.shape?n.push(...V(f.shape,a)):n.push({flatKey:a,field:s,path:a.split("-")})}return n}function pe(e,t){let n={};for(let{flatKey:o,path:s}of t){let a=o.replace(/-([a-z])/g,(f,d)=>d.toUpperCase()),c=a in e?e[a]:e[o];if(s.length===1)n[s[0]]=c;else{let f=n;for(let d=0;d<s.length-1;d++)(!f[s[d]]||typeof f[s[d]]!="object")&&(f[s[d]]={}),f=f[s[d]];f[s[s.length-1]]=c}}return n}function ye(e,t){for(let n of t){let o=n.schema.name.split("_"),s=o.pop(),c=G(e,o).command(s).description(n.schema.description),f=n.schema.input.shape??{},d=V(f),g=[],b=[],_=[],O=[];for(let{flatKey:u,field:i}of d){let r=i.description??u,l=i;for(;l._def.typeName==="ZodEffects";)l=l._def.schema;let y=l._def.typeName,m=l;m._def.typeName==="ZodNullable"&&(m=m._def.innerType),m._def.typeName==="ZodNumber"&&b.push(u),m._def.typeName==="ZodRecord"&&_.push(u),m._def.typeName==="ZodBoolean"&&O.push(u),y==="ZodBoolean"?c.option(`--${u} [${u}]`,r,!1):y==="ZodNullable"?(c.option(`--${u} <${u}>`,r),g.push(u)):c.requiredOption(`--${u} <${u}>`,r)}c.action(async u=>{n.schema.name.startsWith("consent_")||await A.handler({});for(let r of g){let l=r.replace(/-([a-z])/g,(y,m)=>m.toUpperCase());u[l]===void 0&&(u[l]=null)}for(let r of b){let l=r.replace(/-([a-z])/g,(y,m)=>m.toUpperCase());u[l]!=null&&typeof u[l]=="string"&&(u[l]=Number(u[l]))}for(let r of O){let l=r.replace(/-([a-z])/g,(m,v)=>v.toUpperCase()),y=u[l];if(typeof y=="string"){let m=y.toLowerCase();m==="true"||m==="1"?u[l]=!0:(m==="false"||m==="0")&&(u[l]=!1)}}for(let r of _){let l=r.replace(/-([a-z])/g,(y,m)=>m.toUpperCase());if(typeof u[l]=="string")try{u[l]=JSON.parse(u[l])}catch{console.error(`Invalid JSON for --${r}`),process.exit(1)}}let i=pe(u,d);try{let r=await n.handler(i);H(r)}catch(r){console.error(P(r,T())),process.exit(1)}})}}function ge(e){if(e.$ref&&e.definitions){let t=e.$ref.replace("#/definitions/","");return e.definitions[t]}return e}function he(e){return Array.isArray(e.type)?e.type.includes("null"):e.anyOf?e.anyOf.some(t=>t.type==="null"):!1}function be(e){return Array.isArray(e.type)?e.type.includes("object"):e.anyOf?e.anyOf.some(t=>t.type==="object"):e.type==="object"}function we(e){return Array.isArray(e.type)?e.type.some(t=>t==="number"||t==="integer"):e.anyOf?e.anyOf.some(t=>t.type==="number"||t.type==="integer"):e.type==="number"||e.type==="integer"}function ke(e){return Array.isArray(e.type)?e.type.includes("boolean"):e.anyOf?e.anyOf.some(t=>t.type==="boolean"):e.type==="boolean"}var Q=new Set(["swaps_transaction_build","swaps_quote_retrieve","transaction_register","virtual-account_offramp_initiate","prediction-market_position_buy","prediction-market_position_sell","prediction-market_position_redeem","commerce_cart_update","commerce_checkout_start","commerce_checkout_pay","card_delegation_approve_transaction_build","card_delegation_revoke_transaction_build","card_delegation_token_retrieve","card_wallet_link","card_wallet_unlink"]);function _e(e,t){for(let n of t){if(Q.has(n.name))continue;let o=n.name.split("_"),s=o.pop(),a=G(e,o);if(a.commands.find(i=>i.name()===s))continue;let c=a.command(s).description(n.description),f=ge(n.inputSchema),d=f.properties??{},g=new Set(f.required??[]),b=[],_=[],O=[],u=[];for(let[i,r]of Object.entries(d)){let l=r.description??i,y=he(r),m=be(r),v=we(r),X=ke(r);v&&_.push(i),X&&u.push(i),m?(O.push(i),g.has(i)&&!y?c.requiredOption(`--${i} <json>`,`${l} (as JSON)`):(c.option(`--${i} <json>`,`${l} (as JSON)`),b.push(i))):y||!g.has(i)?(c.option(`--${i} <${i}>`,l),b.push(i)):c.requiredOption(`--${i} <${i}>`,l)}c.action(async i=>{await A.handler({});for(let r of b)i[r]===void 0&&(i[r]=null);for(let r of _)i[r]!=null&&typeof i[r]=="string"&&(i[r]=Number(i[r]));for(let r of u)if(typeof i[r]=="string"){let l=i[r].toLowerCase();l==="true"||l==="1"?i[r]=!0:(l==="false"||l==="0")&&(i[r]=!1)}for(let r of O)if(typeof i[r]=="string")try{i[r]=JSON.parse(i[r])}catch{console.error(`Invalid JSON for --${r}`),process.exit(1)}try{await Z(i);let r=await N._call(n.name,i);H(r),W()}catch(r){console.error(P(r,T())),process.exit(1)}})}}ye(h,S);_e(h,J);h.command("tools").description("List available tools").action(()=>{let e=[...S.map(n=>({name:n.schema.name,description:n.schema.description})),...J.filter(n=>!S.some(o=>o.schema.name===n.name)&&!Q.has(n.name)).map(n=>({name:n.name,description:n.description}))].sort((n,o)=>n.name.localeCompare(o.name)),t=[];for(let n of e){let o=n.name.replace(/_/g," ");t.push(` ${p.green(o.padEnd(28))} ${p.dim(n.description)}`)}t.push(""),t.push(p.dim(`${e.length} tools`)),console.log(t.join(`
18
18
  `)),W()});h.parse();
@@ -7,6 +7,6 @@ Run: npm i -g @moonpay/cli --include=optional`;function y(){try{let e=S("@ledger
7
7
  `),p}async function U(){if(!p)return null;try{let e=y(),i=f().getDeviceSessionState({sessionId:p}),s=await e.firstValueFrom(i.pipe(e.take(1),e.timeout(3e3)));return s.sessionStateType>=1?s.currentApp?.name??null:null}catch{return null}}var M={evm:"Ethereum",solana:"Solana"};function _(e){let n=String(e);return n.includes("6807")||n.includes("6a15")||n.includes("UnknownDeviceExchangeError")}async function C(e){process.stderr.write(`Installing ${e} app on your Ledger...
8
8
  `);let{OpenAppWithDependenciesDeviceAction:n}=y(),i=new n({input:{appName:e}}),t=f().executeDeviceAction({sessionId:E(),deviceAction:i});await m(t,`Install ${e}`,18e4),process.stderr.write(`Installed ${e} app
9
9
  `)}async function R(e){let n=M[e];if(!n||await U()===n)return;process.stderr.write(`Opening ${n} app on your Ledger...
10
- `);let{OpenAppDeviceAction:s}=y(),t=new s({input:{appName:n}}),u=f().executeDeviceAction({sessionId:E(),deviceAction:t});try{await m(u,`Open ${n}`)}catch(c){if(_(c)){await D(),await C(n),await D();return}if(!String(c).includes("isconnect"))throw c}await D()}async function D(){try{await f().disconnect({sessionId:p})}catch{}p=null,await new Promise(e=>setTimeout(e,500)),await P()}function $(e,n=0){switch(e){case"evm":return`44'/60'/${n}'/0/0`;case"solana":return`44'/501'/${n}'/0'`;default:throw new Error(`${e} derivation via Ledger is not supported.`)}}function k(e){return e.startsWith("0x")?e.slice(2):e}function T(e){return e.startsWith("0x")?e:`0x${e}`}async function x(e){let{moonpay:n}=await import("./client-Z2SJZXSE.js"),s=(await n.chain.retrieve({chain:e})).keyFamily;if(s==="bitcoin")throw new Error("Bitcoin address derivation via Ledger is not yet supported.");if(s==="tron")throw new Error("Tron address derivation via Ledger is not supported. The Ethereum signer cannot interact with the Tron Ledger app.");await R(s);let t=$(s),a=E(),u=f();switch(s){case"evm":{let{SignerEthBuilder:c}=I(),l=new c({dmk:u,sessionId:a}).build().getAddress(t,{skipOpenApp:!1});return(await m(l,"Get Ethereum address")).address}case"solana":{let{SignerSolanaBuilder:c}=L(),l=new c({dmk:u,sessionId:a}).build().getAddress(t,{skipOpenApp:!1});return await m(l,"Get Solana address")}default:throw new Error(`Ledger address derivation not supported for ${s}`)}}async function F(){let e={};try{e.ethereum=await x("ethereum")}catch(n){process.stderr.write(`Failed to get Ethereum address: ${n}
10
+ `);let{OpenAppDeviceAction:s}=y(),t=new s({input:{appName:n}}),u=f().executeDeviceAction({sessionId:E(),deviceAction:t});try{await m(u,`Open ${n}`)}catch(c){if(_(c)){await D(),await C(n),await D();return}if(!String(c).includes("isconnect"))throw c}await D()}async function D(){try{await f().disconnect({sessionId:p})}catch{}p=null,await new Promise(e=>setTimeout(e,500)),await P()}function $(e,n=0){switch(e){case"evm":return`44'/60'/${n}'/0/0`;case"solana":return`44'/501'/${n}'/0'`;default:throw new Error(`${e} derivation via Ledger is not supported.`)}}function k(e){return e.startsWith("0x")?e.slice(2):e}function T(e){return e.startsWith("0x")?e:`0x${e}`}async function x(e){let{moonpay:n}=await import("./client-DJSULCSX.js"),s=(await n.chain.retrieve({chain:e})).keyFamily;if(s==="bitcoin")throw new Error("Bitcoin address derivation via Ledger is not yet supported.");if(s==="tron")throw new Error("Tron address derivation via Ledger is not supported. The Ethereum signer cannot interact with the Tron Ledger app.");await R(s);let t=$(s),a=E(),u=f();switch(s){case"evm":{let{SignerEthBuilder:c}=I(),l=new c({dmk:u,sessionId:a}).build().getAddress(t,{skipOpenApp:!1});return(await m(l,"Get Ethereum address")).address}case"solana":{let{SignerSolanaBuilder:c}=L(),l=new c({dmk:u,sessionId:a}).build().getAddress(t,{skipOpenApp:!1});return await m(l,"Get Solana address")}default:throw new Error(`Ledger address derivation not supported for ${s}`)}}async function F(){let e={};try{e.ethereum=await x("ethereum")}catch(n){process.stderr.write(`Failed to get Ethereum address: ${n}
11
11
  `)}try{e.solana=await x("solana")}catch(n){process.stderr.write(`Failed to get Solana address: ${n}
12
- `)}if(!e.ethereum&&!e.solana)throw new Error("Could not derive any addresses from Ledger device");return e}async function H(e,n){let{moonpay:i}=await import("./client-Z2SJZXSE.js"),t=(await i.chain.retrieve({chain:e})).keyFamily;if(t==="bitcoin")throw new Error("Bitcoin transaction signing via Ledger is not yet supported. Use a software wallet for Bitcoin transactions.");if(t==="tron")throw new Error("Tron transaction signing via Ledger is not supported. Use a software wallet for Tron transactions.");await R(t);let a=$(t),u=E(),c=f();switch(t){case"evm":{let{SignerEthBuilder:d}=I(),l=new d({dmk:c,sessionId:u}).build(),w=T(n.startsWith("0x")?n:Buffer.from(n,"base64").toString("hex")),o=Uint8Array.from(Buffer.from(k(w),"hex")),r=l.signTransaction(a,o,{skipOpenApp:!1}),g=await m(r,"Sign transaction"),{parseTransaction:v,serializeTransaction:A}=await import("viem"),B=v(w);return{transaction:A(B,{r:T(k(g.r)),s:T(k(g.s)),v:BigInt(g.v)})}}case"solana":{let{SignerSolanaBuilder:d}=L(),l=new d({dmk:c,sessionId:u}).build(),{VersionedTransaction:w}=await import("@solana/web3.js"),o=Uint8Array.from(Buffer.from(n,"base64")),r=w.deserialize(o),g=r.message.serialize(),v=l.signTransaction(a,g,{skipOpenApp:!1}),A=await m(v,"Sign Solana transaction");return r.signatures[0]=A,{transaction:Buffer.from(r.serialize()).toString("base64")}}default:throw new Error(`Ledger transaction signing not supported for ${t}`)}}async function V(e,n){let{moonpay:i}=await import("./client-Z2SJZXSE.js"),t=(await i.chain.retrieve({chain:e})).keyFamily;if(t==="bitcoin")throw new Error("Bitcoin message signing via Ledger is not yet supported. Use a software wallet for Bitcoin message signing.");if(t==="tron")throw new Error("Tron message signing via Ledger is not supported. Use a software wallet for Tron message signing.");await R(t);let a=$(t),u=E(),c=f();switch(t){case"evm":{let{SignerEthBuilder:d}=I(),w=new d({dmk:c,sessionId:u}).build().signMessage(a,n,{skipOpenApp:!1}),o=await m(w,"Sign message"),r=k(o.r),g=k(o.s),v=o.v.toString(16).padStart(2,"0");return{signature:`0x${r}${g}${v}`}}case"solana":{let{SignerSolanaBuilder:d}=L(),l=new d({dmk:c,sessionId:u}).build(),w=Buffer.from(n,"utf8").toString("hex"),o=l.signMessage(a,w,{skipOpenApp:!1}),r=await m(o,"Sign Solana message");return{signature:(await import("bs58")).default.encode(r)}}default:throw new Error(`Ledger message signing not supported for ${t}`)}}async function q(){if(p){try{await f().disconnect({sessionId:p})}catch{}p=null}if(h){try{h.close()}catch{}h=null}}export{P as connectLedger,q as disconnectLedger,x as ledgerGetAddress,F as ledgerGetAllAddresses,V as ledgerSignMessage,H as ledgerSignTransaction};
12
+ `)}if(!e.ethereum&&!e.solana)throw new Error("Could not derive any addresses from Ledger device");return e}async function H(e,n){let{moonpay:i}=await import("./client-DJSULCSX.js"),t=(await i.chain.retrieve({chain:e})).keyFamily;if(t==="bitcoin")throw new Error("Bitcoin transaction signing via Ledger is not yet supported. Use a software wallet for Bitcoin transactions.");if(t==="tron")throw new Error("Tron transaction signing via Ledger is not supported. Use a software wallet for Tron transactions.");await R(t);let a=$(t),u=E(),c=f();switch(t){case"evm":{let{SignerEthBuilder:d}=I(),l=new d({dmk:c,sessionId:u}).build(),w=T(n.startsWith("0x")?n:Buffer.from(n,"base64").toString("hex")),o=Uint8Array.from(Buffer.from(k(w),"hex")),r=l.signTransaction(a,o,{skipOpenApp:!1}),g=await m(r,"Sign transaction"),{parseTransaction:v,serializeTransaction:A}=await import("viem"),B=v(w);return{transaction:A(B,{r:T(k(g.r)),s:T(k(g.s)),v:BigInt(g.v)})}}case"solana":{let{SignerSolanaBuilder:d}=L(),l=new d({dmk:c,sessionId:u}).build(),{VersionedTransaction:w}=await import("@solana/web3.js"),o=Uint8Array.from(Buffer.from(n,"base64")),r=w.deserialize(o),g=r.message.serialize(),v=l.signTransaction(a,g,{skipOpenApp:!1}),A=await m(v,"Sign Solana transaction");return r.signatures[0]=A,{transaction:Buffer.from(r.serialize()).toString("base64")}}default:throw new Error(`Ledger transaction signing not supported for ${t}`)}}async function V(e,n){let{moonpay:i}=await import("./client-DJSULCSX.js"),t=(await i.chain.retrieve({chain:e})).keyFamily;if(t==="bitcoin")throw new Error("Bitcoin message signing via Ledger is not yet supported. Use a software wallet for Bitcoin message signing.");if(t==="tron")throw new Error("Tron message signing via Ledger is not supported. Use a software wallet for Tron message signing.");await R(t);let a=$(t),u=E(),c=f();switch(t){case"evm":{let{SignerEthBuilder:d}=I(),w=new d({dmk:c,sessionId:u}).build().signMessage(a,n,{skipOpenApp:!1}),o=await m(w,"Sign message"),r=k(o.r),g=k(o.s),v=o.v.toString(16).padStart(2,"0");return{signature:`0x${r}${g}${v}`}}case"solana":{let{SignerSolanaBuilder:d}=L(),l=new d({dmk:c,sessionId:u}).build(),w=Buffer.from(n,"utf8").toString("hex"),o=l.signMessage(a,w,{skipOpenApp:!1}),r=await m(o,"Sign Solana message");return{signature:(await import("bs58")).default.encode(r)}}default:throw new Error(`Ledger message signing not supported for ${t}`)}}async function q(){if(p){try{await f().disconnect({sessionId:p})}catch{}p=null}if(h){try{h.close()}catch{}h=null}}export{P as connectLedger,q as disconnectLedger,x as ledgerGetAddress,F as ledgerGetAllAddresses,V as ledgerSignMessage,H as ledgerSignTransaction};
@@ -1,2 +1,2 @@
1
1
  process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
2
- import{a,c,d as i}from"./chunk-KXIZFGJZ.js";import"./chunk-FV6GEO2L.js";import"./chunk-CYX6WNGA.js";import"./chunk-XPVNVJMA.js";import{e as s,g as u}from"./chunk-TE4JNXUJ.js";import"./chunk-LMDE72OE.js";u();import{Server as f}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as S}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as g,ListToolsRequestSchema as y}from"@modelcontextprotocol/sdk/types.js";async function v(){let o=new f({name:"moonpay",version:s},{capabilities:{tools:{listChanged:!0}}}),r=a(),m=new Map(r.map(t=>[t.name,t]));o.setRequestHandler(y,async()=>({tools:r.map(t=>({name:t.name,description:t.description,inputSchema:t.inputSchema}))})),o.setRequestHandler(g,async t=>{let{name:n,arguments:l={}}=t.params;if(!m.has(n))return{content:[{type:"text",text:`Unknown tool: ${n}`}],isError:!0};try{let e=await i(n,l);return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(e){return{content:[{type:"text",text:e instanceof c||e instanceof Error?e.message:String(e)}],isError:!0}}});let p=new S;await o.connect(p)}export{v as startMcpServer};
2
+ import{a,c,d as i}from"./chunk-5ZGKR6EP.js";import"./chunk-TD26ORN4.js";import"./chunk-XCYYHA62.js";import"./chunk-JYEDCTBB.js";import{e as s,g as u}from"./chunk-HEJI3KC5.js";import"./chunk-LMDE72OE.js";u();import{Server as f}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as S}from"@modelcontextprotocol/sdk/server/stdio.js";import{CallToolRequestSchema as g,ListToolsRequestSchema as y}from"@modelcontextprotocol/sdk/types.js";async function v(){let o=new f({name:"moonpay",version:s},{capabilities:{tools:{listChanged:!0}}}),r=a(),m=new Map(r.map(t=>[t.name,t]));o.setRequestHandler(y,async()=>({tools:r.map(t=>({name:t.name,description:t.description,inputSchema:t.inputSchema}))})),o.setRequestHandler(g,async t=>{let{name:n,arguments:l={}}=t.params;if(!m.has(n))return{content:[{type:"text",text:`Unknown tool: ${n}`}],isError:!0};try{let e=await i(n,l);return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(e){return{content:[{type:"text",text:e instanceof c||e instanceof Error?e.message:String(e)}],isError:!0}}});let p=new S;await o.connect(p)}export{v as startMcpServer};
@@ -1,5 +1,5 @@
1
1
  process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
2
- import{b as S,c as g,d as v}from"./chunk-KXIZFGJZ.js";import"./chunk-FV6GEO2L.js";import"./chunk-CYX6WNGA.js";import"./chunk-XPVNVJMA.js";import{e as d,g as b,h,p as T}from"./chunk-TE4JNXUJ.js";import"./chunk-LMDE72OE.js";b();import{createServer as y}from"http";import{writeFileSync as E,unlinkSync as O,readFileSync as k,existsSync as M}from"fs";import{join as P}from"path";import{homedir as R}from"os";T();var m="127.0.0.1",A=8787,f=P(R(),".config","moonpay","serve.json");function x(o){h(),E(f,JSON.stringify(o,null,2)+`
3
- `,{encoding:"utf-8",mode:384})}function I(){try{M(f)&&O(f)}catch{}}function D(){try{return JSON.parse(k(f,"utf-8"))}catch{return null}}async function N(o){let t=[];for await(let s of o)t.push(typeof s=="string"?Buffer.from(s):s);if(t.length===0)return{};let r=Buffer.concat(t).toString("utf-8").trim();return r?JSON.parse(r):{}}function u(o,t,r){let s=JSON.stringify(r);o.writeHead(t,{"Content-Type":"application/json; charset=utf-8","Content-Length":Buffer.byteLength(s)}),o.end(s)}async function $(o,t,r=500){let s=new AbortController,p=setTimeout(()=>s.abort(),r);try{let c=await fetch(`http://${o}:${t}/health`,{signal:s.signal});if(!c.ok)return null;let a=await c.json();return a.ok?{pid:typeof a.pid=="number"?a.pid:-1,host:o,port:t,startedAt:typeof a.startedAt=="string"?a.startedAt:"",version:typeof a.version=="string"?a.version:""}:null}catch{return null}finally{clearTimeout(p)}}async function w(o,t,r){let s=o.headers.host??`${m}`,p=new URL(o.url||"/",`http://${s}`),c=(o.method||"GET").toUpperCase();if(c==="GET"&&p.pathname==="/health"){u(t,200,{ok:!0,version:d,pid:process.pid,startedAt:r});return}let a=p.pathname.match(/^\/v1\/tools\/([a-z0-9_]+)$/i);if(c==="POST"&&a){let i=a[1];if(!S(i)){u(t,404,{error:`Unknown tool: ${i}`,tool:i});return}let n={};try{let e=await N(o);if(e&&typeof e=="object"&&!Array.isArray(e))n=e;else if(e!=null){u(t,400,{error:"Body must be a JSON object"});return}}catch{u(t,400,{error:"Invalid JSON body"});return}try{let e=await v(i,n);u(t,200,{data:e});return}catch(e){if(e instanceof g){u(t,404,{error:e.message,tool:i});return}let l=e instanceof Error?e.message:String(e);u(t,500,{error:l,tool:i});return}}u(t,404,{error:"Not found",hint:"GET /health or POST /v1/tools/:tool"})}async function F(o={}){let t=o.host??m,r=o.port??A,s=o.idempotent!==!1;if(t!=="127.0.0.1"&&t!=="localhost"&&t!=="::1")throw new Error(`mp serve refuses non-loopback host '${t}' \u2014 bind 127.0.0.1 only`);if(s){let n=await $(t,r);if(n)return process.stdout.write(JSON.stringify({ok:!0,alreadyRunning:!0,host:t,port:r,pid:n.pid,version:n.version},null,2)+`
4
- `),{host:t,port:r}}let p=new Date().toISOString(),c=y((n,e)=>{w(n,e,p).catch(l=>{u(e,500,{error:l instanceof Error?l.message:String(l)})})});await new Promise((n,e)=>{c.once("error",e),c.listen(r,t,()=>n())});let a={pid:process.pid,host:t,port:r,startedAt:p,version:d};x(a);let i=()=>{I(),c.close(()=>process.exit(0))};return process.once("SIGINT",i),process.once("SIGTERM",i),process.stdout.write(JSON.stringify({ok:!0,alreadyRunning:!1,host:t,port:r,pid:process.pid,version:d,endpoints:{health:`http://${t}:${r}/health`,tools:`http://${t}:${r}/v1/tools/:tool`}},null,2)+`
2
+ import{b as S,c as g,d as v}from"./chunk-5ZGKR6EP.js";import"./chunk-TD26ORN4.js";import"./chunk-XCYYHA62.js";import"./chunk-JYEDCTBB.js";import{e as d,g as b,h,p as T}from"./chunk-HEJI3KC5.js";import"./chunk-LMDE72OE.js";b();import{createServer as y}from"http";import{writeFileSync as E,unlinkSync as O,readFileSync as k,existsSync as M}from"fs";import{join as P}from"path";import{homedir as R}from"os";T();var m="127.0.0.1",A=8787,f=P(R(),".config","moonpay","serve.json");function x(o){h(),E(f,JSON.stringify(o,null,2)+`
3
+ `,{encoding:"utf-8",mode:384})}function I(){try{M(f)&&O(f)}catch{}}function D(){try{return JSON.parse(k(f,"utf-8"))}catch{return null}}async function N(o){let t=[];for await(let s of o)t.push(typeof s=="string"?Buffer.from(s):s);if(t.length===0)return{};let r=Buffer.concat(t).toString("utf-8").trim();return r?JSON.parse(r):{}}function u(o,t,r){let s=JSON.stringify(r);o.writeHead(t,{"Content-Type":"application/json; charset=utf-8","Content-Length":Buffer.byteLength(s)}),o.end(s)}async function $(o,t,r=500){let s=new AbortController,p=setTimeout(()=>s.abort(),r);try{let c=await fetch(`http://${o}:${t}/health`,{signal:s.signal});if(!c.ok)return null;let a=await c.json();return a.ok?{pid:typeof a.pid=="number"?a.pid:-1,host:o,port:t,startedAt:typeof a.startedAt=="string"?a.startedAt:"",version:typeof a.version=="string"?a.version:""}:null}catch{return null}finally{clearTimeout(p)}}async function w(o,t,r){let s=o.headers.host??`${m}`,p=new URL(o.url||"/",`http://${s}`),c=(o.method||"GET").toUpperCase();if(c==="GET"&&p.pathname==="/health"){u(t,200,{ok:!0,version:d,pid:process.pid,startedAt:r});return}let a=p.pathname.match(/^\/api\/tools\/([a-z0-9_]+)$/i);if(c==="POST"&&a){let i=a[1];if(!S(i)){u(t,404,{error:`Unknown tool: ${i}`,tool:i});return}let n={};try{let e=await N(o);if(e&&typeof e=="object"&&!Array.isArray(e))n=e;else if(e!=null){u(t,400,{error:"Body must be a JSON object"});return}}catch{u(t,400,{error:"Invalid JSON body"});return}try{let e=await v(i,n);u(t,200,e);return}catch(e){if(e instanceof g){u(t,404,{error:e.message,tool:i});return}let l=e instanceof Error?e.message:String(e);u(t,500,{error:l,tool:i});return}}u(t,404,{error:"Not found",hint:"GET /health or POST /api/tools/:tool"})}async function F(o={}){let t=o.host??m,r=o.port??A,s=o.idempotent!==!1;if(t!=="127.0.0.1"&&t!=="localhost"&&t!=="::1")throw new Error(`mp serve refuses non-loopback host '${t}' \u2014 bind 127.0.0.1 only`);if(s){let n=await $(t,r);if(n)return process.stdout.write(JSON.stringify({ok:!0,alreadyRunning:!0,host:t,port:r,pid:n.pid,version:n.version},null,2)+`
4
+ `),{host:t,port:r}}let p=new Date().toISOString(),c=y((n,e)=>{w(n,e,p).catch(l=>{u(e,500,{error:l instanceof Error?l.message:String(l)})})});await new Promise((n,e)=>{c.once("error",e),c.listen(r,t,()=>n())});let a={pid:process.pid,host:t,port:r,startedAt:p,version:d};x(a);let i=()=>{I(),c.close(()=>process.exit(0))};return process.once("SIGINT",i),process.once("SIGTERM",i),process.stdout.write(JSON.stringify({ok:!0,alreadyRunning:!1,host:t,port:r,pid:process.pid,version:d,endpoints:{health:`http://${t}:${r}/health`,tools:`http://${t}:${r}/api/tools/:tool`}},null,2)+`
5
5
  `),await new Promise(()=>{}),{host:t,port:r}}async function G(o={}){let t=o.host??m,r=o.port??0,s=new Date().toISOString(),p=y((i,n)=>{w(i,n,s).catch(e=>{u(n,500,{error:e instanceof Error?e.message:String(e)})})});await new Promise((i,n)=>{p.once("error",n),p.listen(r,t,()=>i())});let c=p.address(),a=c&&typeof c=="object"?c.port:r;return{host:t,port:a,close:()=>new Promise((i,n)=>{p.close(e=>e?n(e):i())})}}export{m as DEFAULT_SERVE_HOST,A as DEFAULT_SERVE_PORT,$ as probeServeHealth,D as readServeMeta,F as startServe,G as startServeForTests};
@@ -1,2 +1,2 @@
1
1
  process.noDeprecation = true; import { createRequire as __createRequire } from "module"; const require = __createRequire(import.meta.url);
2
- import{A as v,B as w,f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l,r as m,s as n,t as o,u as p,v as q,w as r,x as s,y as t,z as u}from"./chunk-XPVNVJMA.js";import"./chunk-TE4JNXUJ.js";import"./chunk-LMDE72OE.js";export{m as addHardwareWallet,u as addWallet,d as createWallet,j as deleteWallet,l as exportSecret,h as findWallet,i as findWalletOrThrow,a as getVaultPath,e as importMnemonic,f as importPrivateKey,g as listWallets,s as loadWallets,c as migrateWallets,w as mutateWallets,p as owsSignMessage,o as owsSignTransaction,q as owsSignTypedData,n as refreshHardwareAddresses,t as removeWallet,k as renameWallet,b as requireMigrationCheck,r as resolveSigningKey,v as saveWallets};
2
+ import{A as v,B as w,f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l,r as m,s as n,t as o,u as p,v as q,w as r,x as s,y as t,z as u}from"./chunk-JYEDCTBB.js";import"./chunk-HEJI3KC5.js";import"./chunk-LMDE72OE.js";export{m as addHardwareWallet,u as addWallet,d as createWallet,j as deleteWallet,l as exportSecret,h as findWallet,i as findWalletOrThrow,a as getVaultPath,e as importMnemonic,f as importPrivateKey,g as listWallets,s as loadWallets,c as migrateWallets,w as mutateWallets,p as owsSignMessage,o as owsSignTransaction,q as owsSignTypedData,n as refreshHardwareAddresses,t as removeWallet,k as renameWallet,b as requireMigrationCheck,r as resolveSigningKey,v as saveWallets};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moonpay/cli",
3
- "version": "1.93.0",
3
+ "version": "1.93.1",
4
4
  "description": "MoonPay CLI — how agents move money",
5
5
  "homepage": "https://agents.moonpay.com",
6
6
  "publishConfig": {