@visa/cli 1.0.7-rc.5 → 1.1.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,38 +1,38 @@
1
- "use strict";var Xt=Object.create;var fe=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var en=Object.getPrototypeOf,tn=Object.prototype.hasOwnProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var nn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),rn=(t,e)=>{for(var n in e)fe(t,n,{get:e[n],enumerable:!0})},on=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Qt(e))!tn.call(t,o)&&o!==n&&fe(t,o,{get:()=>e[o],enumerable:!(r=Zt(e,o))||r.enumerable});return t};var p=(t,e,n)=>(n=t!=null?Xt(en(t)):{},on(e||!t||!t.__esModule?fe(n,"default",{value:t,enumerable:!0}):n,t));async function Ue(){try{let{stdout:t}=await R("security",["find-generic-password","-s",I,"-a",Z,"-w"],{timeout:5e3});return t.trim()||null}catch{return null}}async function je(t){try{try{await R("security",["delete-generic-password","-s",I,"-a",Z],{timeout:5e3})}catch{}return await R("security",["add-generic-password","-s",I,"-a",Z,"-w",t],{timeout:5e3}),!0}catch{return!1}}async function Fe(){try{await R("security",["delete-generic-password","-s",I,"-a",Z],{timeout:5e3})}catch{}}async function sn(){try{let{stdout:t}=await R("security",["find-generic-password","-s",I,"-a",Q,"-w"],{timeout:5e3});return t.trim()||null}catch{return null}}async function an(t){try{try{await R("security",["delete-generic-password","-s",I,"-a",Q],{timeout:5e3})}catch{}await R("security",["add-generic-password","-s",I,"-a",Q,"-w",t],{timeout:5e3})}catch{}}async function cn(){try{await R("security",["delete-generic-password","-s",I,"-a",Q],{timeout:5e3})}catch{}}function ln(t){$.mkdirSync(ye,{recursive:!0,mode:448}),$.writeFileSync(X,t,{mode:384})}function un(){try{return $.readFileSync(X,"utf-8").trim()||null}catch{return null}}var De,qe,$,He,he,R,ye,X,I,Z,Q,g,K=f(()=>{"use strict";De=require("child_process"),qe=require("util"),$=p(require("fs")),He=p(require("os")),he=p(require("path")),R=(0,qe.promisify)(De.execFile),ye=he.join(He.homedir(),".visa-mcp"),X=he.join(ye,"session-token"),I="visa-cli",Z="session-token",Q="rc-access";g=class{static async getSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN==="true")return Promise.resolve("mock-session-token-for-testing");let e=await Ue();if(e)return e;let n=un();return n?(await je(n),n):null}static async saveSessionToken(e){if(process.env.VISA_MOCK_KEYCHAIN==="true")return;if(await je(e)){if(await Ue()===e){try{$.unlinkSync(X)}catch{}return}await Fe()}if(ln(e),await this.getSessionToken()!==e)throw new Error("Failed to persist session token. "+(process.platform==="darwin"?'Check Keychain Access permissions for "visa-cli".':`Ensure ${ye} is writable.`))}static async getRcAccessToken(){return process.env.VISA_MOCK_KEYCHAIN==="true"?"mock-rc-token-for-testing":sn()}static async saveRcAccessToken(e){process.env.VISA_MOCK_KEYCHAIN!=="true"&&await an(e)}static async deleteSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN!=="true"){await Fe();try{$.unlinkSync(X)}catch{}}}static async clearAll(){await this.deleteSessionToken(),await cn()}}});var _e=nn((Bn,dn)=>{dn.exports={name:"@visa/cli",version:"1.0.7-rc.5",description:"AI-powered payments for Claude Code",bin:{"visa-cli":"./bin/visa-cli.js"},scripts:{build:"tsc --noEmit && node esbuild.config.js",dev:"tsc --watch",start:"node dist/mcp-server/index.js",test:"jest --config jest.config.js","test:unit":"jest --config jest.config.js","test:unit:watch":"jest --config jest.config.js --watch","test:unit:coverage":"jest --config jest.config.js --coverage","test:smoke":"VISA_AUTH_URL=https://auth.visacli.sh jest --config jest.smoke.config.js","test:integration":"jest --config jest.integration.config.js","test:e2e":"jest --config jest.e2e.config.js","test:catalog-e2e":"jest --config jest.catalog-e2e.config.js","test:all":"npm run test:unit && npm run test:integration && npm run test:e2e",prepublishOnly:"npm run build && npm test",lint:"eslint src/**/*.ts",format:'prettier --write "src/**/*.ts"',"format:check":'prettier --check "src/**/*.ts"'},keywords:["visa","checkout","mcp","ai-agent","payments","click-to-pay","usdc","stablecoin"],author:"Visa Crypto Labs",license:"SEE LICENSE IN LICENSE",dependencies:{"@modelcontextprotocol/sdk":"^1.0.0",commander:"^12.1.0",zod:"^3.23.0"},devDependencies:{"@visa-cli/tools":"workspace:*","@changesets/changelog-git":"^0.2.1","@changesets/cli":"^2.30.0","@types/jest":"^30.0.0","@types/node":"^22.10.0","@typescript-eslint/eslint-plugin":"^8.56.1","@typescript-eslint/parser":"^8.56.1","@types/express":"^5.0.0",esbuild:"^0.27.4",express:"^4.21.0",eslint:"^10.0.2","eslint-config-prettier":"^10.1.8",jest:"^29.7.0",prettier:"^3.8.1","ts-jest":"^29.2.0",typescript:"^5.7.0"},engines:{node:">=18.0.0"},files:["bin/visa-cli.js","dist/","native/visa-keychain.m","README.md","LICENSE"]}});async function Ge(t,e){let n=e?.timeoutMs??3e4,r=new AbortController,o=setTimeout(()=>r.abort(),n);try{let{timeoutMs:s,...a}=e??{};return await fetch(t,{...a,signal:r.signal})}finally{clearTimeout(o)}}var ze=f(()=>{"use strict"});function Je(t,e){let n=Ye(t),r=Ye(e);if(!n||!r)return!1;for(let o=0;o<3;o++)if(n.main[o]!==r.main[o])return n.main[o]>r.main[o];return n.pre&&!r.pre?!1:!n.pre&&r.pre?!0:!n.pre&&!r.pre?!1:wn(n.pre,r.pre)>0}function Ye(t){if(typeof t!="string")return null;let n=t.trim().replace(/^v/,"").match(_n);return n?{main:[Number(n[1]),Number(n[2]),Number(n[3])],pre:n[4]??null}:null}function wn(t,e){let n=t.split("."),r=e.split("."),o=Math.max(n.length,r.length);for(let s=0;s<o;s++){if(s>=n.length)return-1;if(s>=r.length)return 1;let a=n[s],i=r[s],l=/^\d+$/.test(a),c=/^\d+$/.test(i);if(l&&c){let u=Number(a)-Number(i);if(u!==0)return u}else{if(l)return-1;if(c)return 1;if(a<i)return-1;if(a>i)return 1}}return 0}var _n,Xe=f(()=>{"use strict";_n=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/});function re(){return!!(Ze(process.env.VISA_CLI_NO_UPDATE_CHECK)||Ze(process.env.CI)||process.env.NODE_ENV==="test")}function Ze(t){if(t===void 0)return!1;let e=t.trim().toLowerCase();return!(e===""||e==="0"||e==="false"||e==="no"||e==="off")}var be=f(()=>{"use strict"});var Se,k,oe=f(()=>{"use strict";ze();Xe();be();Se="1.0.7-rc.5",k=class{constructor(e){this.getSessionToken=e;this.baseUrl=process.env.VISA_AUTH_URL||"https://auth.visacli.sh"}getSessionToken;baseUrl;lastSignals={};parseServerSignals(e){if(this.lastSignals={},!re()){let r=e.headers.get("X-Latest-Version"),o=e.headers.get("X-Update-Message");r&&Je(r,Se)&&(this.lastSignals.updateAvailable={version:r,message:o||`Update available: v${r}. Run: npm install -g @visa/cli && visa-cli setup`})}let n=e.headers.get("X-Feedback-Prompt");if(n)try{this.lastSignals.feedbackPrompt=JSON.parse(n)}catch{}}getClientVersion(){return Se}async request(e,n,r,o,s){let a=await this.getSessionToken();if(!a)throw new Error("Not logged in. Sign up at https://visacli.sh or run: visa-cli setup");let i={Authorization:`Bearer ${a}`};s&&(e==="GET"?i["X-User-Context"]=s.replace(/[\r\n\0]/g," ").slice(0,1e3):r={...r||{},user_context:s}),r&&(i["Content-Type"]="application/json");let l;try{l=await Ge(`${this.baseUrl}${n}`,{method:e,headers:{...i,"X-Visa-CLI-Version":Se},body:r?JSON.stringify(r):void 0,timeoutMs:o})}catch(u){throw u.name==="AbortError"||u.message?.includes("aborted")?new Error("The request timed out. The server may be under heavy load. Please try again."):new Error("Cannot reach the Visa CLI server. Check your internet connection and try again.")}if(this.parseServerSignals(l),l.status===401)throw new Error("Your session has expired. Run: visa-cli setup");if(l.status===429){let u=l.headers.get("Retry-After")||"3";throw new Error(`Rate limited \u2014 wait ${u}s. Tip: use the batch tool to combine multiple requests into one.`)}if(l.status===503)throw new Error("Visa CLI is temporarily unavailable. Check https://visacli.sh for status.");let c;try{c=await l.json()}catch{throw l.status===500?new Error(`Server error on ${n}. Try again or check https://visacli.sh for status.`):new Error(`Unexpected response from ${n}. Try again.`)}if(!l.ok)throw l.status===500?new Error(`Server error on ${n}. Try again or check https://visacli.sh for status.`):new Error(c?.error||`Request failed (${l.status}). Try again.`);return c}async pay(e,n){return this.request("POST","/v1/pay",e,void 0,n)}async shortcut(e,n,r,o){return this.request("POST",`/v1/shortcuts/${encodeURIComponent(e)}`,n,r,o)}async batch(e,n,r){return this.request("POST","/v1/batch",e,n,r)}async catalogSearch(e,n){let r=new URLSearchParams;e&&r.set("q",e),n&&r.set("category",n);let o=r.toString();return this.request("GET",`/v1/catalog${o?`?${o}`:""}`)}async catalogTool(e){try{return await this.request("GET",`/v1/catalog/${encodeURIComponent(e)}`)}catch{return null}}async paymentPreview(e,n){return this.request("POST","/v1/payment-preview",e,void 0,n)}async getStatus(e){return this.request("GET","/v1/status",void 0,void 0,e)}async getTransactions(e){return this.request("GET","/v1/transactions",void 0,void 0,e)}async updateSpendingControls(e,n){return this.request("POST","/v1/spending-controls",e,void 0,n)}async removeCard(e,n,r){return this.request("DELETE",`/v1/cards/${encodeURIComponent(String(e))}`,n,void 0,r)}async setDefaultCard(e,n,r){return this.request("POST",`/v1/cards/${encodeURIComponent(String(e))}/default`,n,void 0,r)}async getAttestationChallenge(){return this.request("GET","/v1/attestation-challenge")}async registerAttestationKey(e){return this.request("POST","/v1/attestation-key",{publicKey:e})}async logout(e,n){return this.request("POST","/v1/logout",e,void 0,n)}async feedback(e,n,r){return this.request("POST","/v1/feedback",{message:e,...n&&{transaction_id:n}},void 0,r)}async feedSubmit(e){return this.request("POST","/v1/feed",e)}async feedList(e){let n=new URLSearchParams;e?.tab&&n.set("tab",e.tab),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset));let r=n.toString();return this.request("GET",`/v1/feed${r?"?"+r:""}`)}async feedVote(e,n){return this.request("POST",`/v1/feed/${encodeURIComponent(e)}/vote`,{direction:n})}async feedApprove(e){return this.request("POST",`/v1/feed/${encodeURIComponent(e)}/approve`)}async feedDelete(e){return this.request("DELETE",`/v1/feed/${encodeURIComponent(e)}`)}async feedPending(){return this.request("GET","/v1/feed/pending")}async submitFeedback(e,n,r){return this.request("POST","/v1/feedback",{message:e,...n&&{transaction_id:n}},void 0,r)}async getFeedback(e,n){let r=new URLSearchParams;e&&r.set("limit",String(e));let o=r.toString();return this.request("GET",`/v1/feedback${o?"?"+o:""}`,void 0,void 0,n)}async submitRatedFeedback(e){return this.request("POST","/v1/feedback",e)}}});function Sn(){w.existsSync(Pe)||w.mkdirSync(Pe,{recursive:!0,mode:448})}function vn(){if(!ve){if(Sn(),w.existsSync(B)&&w.statSync(B).size>bn){let e=B+".1";w.existsSync(e)&&w.unlinkSync(e),w.renameSync(B,e)}ve=w.createWriteStream(B,{flags:"a"})}return ve}function se(t,...e){let n=new Date().toISOString(),r=e.map(s=>typeof s=="string"?s:JSON.stringify(s,null,2)).join(" "),o=`[${n}] [${t}] ${r}
2
- `;process.stderr.write(o),vn().write(o)}var w,Ee,Qe,Pe,B,bn,ve,N,xe=f(()=>{"use strict";w=p(require("fs")),Ee=p(require("path")),Qe=p(require("os")),Pe=Ee.join(Qe.homedir(),".visa-mcp"),B=Ee.join(Pe,"mcp-server.log"),bn=5*1024*1024,ve=null;N={debug:(...t)=>se("DEBUG",...t),info:(...t)=>se("INFO",...t),warn:(...t)=>se("WARN",...t),error:(...t)=>se("ERROR",...t)}});function rt(t){let e=h.readFileSync(t);return st.createHash("sha256").update(e).digest("hex")}async function at(){try{if(h.readFileSync(tt,"utf-8").trim()===et&&h.existsSync(L)){let r=h.readFileSync(nt,"utf-8").trim();if(rt(L)!==r)N.warn("binary:hash-mismatch",{message:"Binary hash mismatch \u2014 possible tampering detected. Recompiling from source."}),h.unlinkSync(L);else return L}}catch{}let t=C.join(Pn,"visa-keychain.m");if(h.existsSync(t)||(t=C.resolve(__dirname,"..","..","native","visa-keychain.m")),h.existsSync(t)||(t=C.resolve(__dirname,"..","native","visa-keychain.m")),!h.existsSync(t))throw new Error("visa-keychain.m source not found. Reinstall Visa CLI.");h.mkdirSync(ce,{recursive:!0,mode:448});try{await D("clang",["-framework","Security","-framework","LocalAuthentication","-framework","Foundation","-framework","AppKit","-o",L,t],{timeout:3e4})}catch(n){throw n.code==="ENOENT"?new Error("Xcode Command Line Tools required. Install: xcode-select --install"):n}let e=rt(L);return h.writeFileSync(nt,e,{mode:384}),h.writeFileSync(tt,et,{mode:384}),L}async function ct(t){let e=await at(),n;try{n=(await D(e,t,{timeout:6e4})).stdout}catch(s){n=s.stdout||"";let a=n.trim();throw a.startsWith("ERROR:")?new Error(a.slice(6)):new Error(s.stderr?.trim()||s.message||"Unknown error")}let r=n.trim();if(r.startsWith("OK:"))return r.slice(3);if(r==="OK")return;let o=r.startsWith("ERROR:")?r.slice(6):"Unknown error";throw new Error(o)}function U(){return process.env.VISA_MOCK_TOUCHID==="true"?!0:process.platform!=="darwin"?!1:Ce!==null?Ce:(Ce=!0,!0)}async function En(t){try{await D("security",["delete-generic-password","-s",ie,"-a",ae],{timeout:5e3})}catch{}await D("security",["add-generic-password","-s",ie,"-a",ae,"-w",t],{timeout:5e3})}async function xn(){try{let{stdout:t}=await D("security",["find-generic-password","-s",ie,"-a",ae,"-w"],{timeout:5e3});return t.trim()||null}catch{return null}}async function lt(){let t=await ct(["generate-key"]);if(!t)throw new Error("Key generation returned no output");let e=t.indexOf(":");if(e<0)throw new Error("Unexpected generate-key output format");let n=t.slice(0,e),r=t.slice(e+1);return await En(n),r}async function le(t,e){if(process.env.VISA_MOCK_TOUCHID==="true")return Promise.resolve("mock-ecdsa-signature-for-testing");let n=await xn();if(!n)throw new Error("Attestation key not found. Run setup to generate a new key.");let r=await at(),o=["sign",t];return e&&o.push(e),new Promise((s,a)=>{let i=(0,$e.execFile)(r,o,{timeout:6e4},(l,c)=>{let u=(c||"").trim();if(l){u.startsWith("ERROR:")?a(new Error(u.slice(6))):a(new Error(l.stderr?.trim()||l.message||"Unknown error"));return}u.startsWith("OK:")?s(u.slice(3)):a(new Error(u.startsWith("ERROR:")?u.slice(6):"Unknown error"))});i.stdin.write(n),i.stdin.end()})}async function ke(){try{await D("security",["delete-generic-password","-s",ie,"-a",ae],{timeout:5e3})}catch{}try{await ct(["delete-key"])}catch{}}var $e,ot,st,h,it,C,D,ce,L,Pn,et,tt,nt,Ce,ie,ae,Te=f(()=>{"use strict";$e=require("child_process"),ot=require("util"),st=p(require("crypto")),h=p(require("fs")),it=p(require("os")),C=p(require("path"));xe();D=(0,ot.promisify)($e.execFile),ce=C.join(it.homedir(),".visa-mcp","bin"),L=C.join(ce,"Visa CLI"),Pn=C.join(__dirname,"..","native"),et="5",tt=C.join(ce,"visa-keychain.version"),nt=C.join(ce,"visa-keychain.sha256");Ce=null;ie="visa-cli",ae="attestation-key"});async function ue(t){let{model:e,messages:n,tools:r,maxTokens:o=4096,temperature:s=.7,attestation:a,sessionBudgetId:i}=t;return await kn.shortcut(e,{prompt:"",messages:n,...r?.length?{tools:r}:{},max_tokens:o,temperature:s,...a?{attestation:a}:{},...i?{session_budget_id:i}:{}},12e4)}function bt(t,e){let n={"or-claude-sonnet":{inPerM:3,outPerM:15},"or-gpt-4o":{inPerM:5,outPerM:15},"or-gpt-4o-mini":{inPerM:.15,outPerM:.6},"or-gemini-pro":{inPerM:.25,outPerM:1},"or-llama-70b":{inPerM:.59,outPerM:.79},"or-deepseek-chat":{inPerM:.27,outPerM:1.1},"or-deepseek-r1":{inPerM:.55,outPerM:2.19},"or-mistral-large":{inPerM:2,outPerM:6}},r=n[e]||n["or-gpt-4o-mini"],o=t.prompt_tokens/1e6*r.inPerM*100,s=t.completion_tokens/1e6*r.outPerM*100;return Math.ceil(o+s)}var kn,Ne=f(()=>{"use strict";oe();K();kn=new k(()=>g.getSessionToken())});function vt(t){let e=[];e.push(`You are an AI coding assistant powered by Visa CLI.
1
+ "use strict";var Zt=Object.create;var fe=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var en=Object.getOwnPropertyNames;var tn=Object.getPrototypeOf,nn=Object.prototype.hasOwnProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var rn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),on=(t,e)=>{for(var n in e)fe(t,n,{get:e[n],enumerable:!0})},sn=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of en(e))!nn.call(t,o)&&o!==n&&fe(t,o,{get:()=>e[o],enumerable:!(r=Qt(e,o))||r.enumerable});return t};var p=(t,e,n)=>(n=t!=null?Zt(tn(t)):{},sn(e||!t||!t.__esModule?fe(n,"default",{value:t,enumerable:!0}):n,t));async function je(){try{let{stdout:t}=await R("security",["find-generic-password","-s",A,"-a",Z,"-w"],{timeout:5e3});return t.trim()||null}catch{return null}}async function qe(t){try{try{await R("security",["delete-generic-password","-s",A,"-a",Z],{timeout:5e3})}catch{}return await R("security",["add-generic-password","-s",A,"-a",Z,"-w",t],{timeout:5e3}),!0}catch{return!1}}async function Fe(){try{await R("security",["delete-generic-password","-s",A,"-a",Z],{timeout:5e3})}catch{}}async function an(){try{let{stdout:t}=await R("security",["find-generic-password","-s",A,"-a",Q,"-w"],{timeout:5e3});return t.trim()||null}catch{return null}}async function cn(t){try{try{await R("security",["delete-generic-password","-s",A,"-a",Q],{timeout:5e3})}catch{}await R("security",["add-generic-password","-s",A,"-a",Q,"-w",t],{timeout:5e3})}catch{}}async function ln(){try{await R("security",["delete-generic-password","-s",A,"-a",Q],{timeout:5e3})}catch{}}function un(t){$.mkdirSync(ye,{recursive:!0,mode:448}),$.writeFileSync(X,t,{mode:384})}function dn(){try{return $.readFileSync(X,"utf-8").trim()||null}catch{return null}}var De,Ve,$,He,he,R,ye,X,A,Z,Q,g,K=f(()=>{"use strict";De=require("child_process"),Ve=require("util"),$=p(require("fs")),He=p(require("os")),he=p(require("path")),R=(0,Ve.promisify)(De.execFile),ye=he.join(He.homedir(),".visa-mcp"),X=he.join(ye,"session-token"),A="visa-cli",Z="session-token",Q="rc-access";g=class{static async getSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN==="true")return Promise.resolve("mock-session-token-for-testing");let e=await je();if(e)return e;let n=dn();return n?(await qe(n),n):null}static async saveSessionToken(e){if(process.env.VISA_MOCK_KEYCHAIN==="true")return;if(await qe(e)){if(await je()===e){try{$.unlinkSync(X)}catch{}return}await Fe()}if(un(e),await this.getSessionToken()!==e)throw new Error("Failed to persist session token. "+(process.platform==="darwin"?'Check Keychain Access permissions for "visa-cli".':`Ensure ${ye} is writable.`))}static async getRcAccessToken(){return process.env.VISA_MOCK_KEYCHAIN==="true"?"mock-rc-token-for-testing":an()}static async saveRcAccessToken(e){process.env.VISA_MOCK_KEYCHAIN!=="true"&&await cn(e)}static async deleteSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN!=="true"){await Fe();try{$.unlinkSync(X)}catch{}}}static async clearAll(){await this.deleteSessionToken(),await ln()}}});var _e=rn((Wn,mn)=>{mn.exports={name:"@visa/cli",version:"1.1.0-rc.6",description:"AI-powered payments for Claude Code",bin:{"visa-cli":"./bin/visa-cli.js"},scripts:{build:"tsc --noEmit && node esbuild.config.js",dev:"tsc --watch",start:"node dist/mcp-server/index.js",test:"jest --config jest.config.js","test:unit":"jest --config jest.config.js","test:unit:watch":"jest --config jest.config.js --watch","test:unit:coverage":"jest --config jest.config.js --coverage","test:smoke":"VISA_AUTH_URL=https://auth.visacli.sh jest --config jest.smoke.config.js","test:integration":"jest --config jest.integration.config.js","test:e2e":"jest --config jest.e2e.config.js","test:catalog-e2e":"jest --config jest.catalog-e2e.config.js","test:all":"npm run test:unit && npm run test:integration && npm run test:e2e",prepublishOnly:"npm run build && npm test",lint:"eslint src/**/*.ts",format:'prettier --write "src/**/*.ts"',"format:check":'prettier --check "src/**/*.ts"'},keywords:["visa","checkout","mcp","ai-agent","payments","click-to-pay","usdc","stablecoin"],author:"Visa Crypto Labs",license:"SEE LICENSE IN LICENSE",dependencies:{"@modelcontextprotocol/sdk":"^1.0.0",commander:"^12.1.0",zod:"^3.23.0"},devDependencies:{"@visa-cli/tools":"workspace:*","@changesets/changelog-git":"^0.2.1","@changesets/cli":"^2.30.0","@types/jest":"^30.0.0","@types/node":"^22.10.0","@typescript-eslint/eslint-plugin":"^8.56.1","@typescript-eslint/parser":"^8.56.1","@types/express":"^5.0.0",esbuild:"^0.27.4",express:"^4.21.0",eslint:"^10.0.2","eslint-config-prettier":"^10.1.8",jest:"^29.7.0",prettier:"^3.8.1","ts-jest":"^29.2.0",typescript:"^5.7.0"},engines:{node:">=18.0.0"},files:["bin/visa-cli.js","dist/","native/visa-keychain.m","README.md","LICENSE"]}});async function ze(t,e){let n=e?.timeoutMs??3e4,r=new AbortController,o=setTimeout(()=>r.abort(),n);try{let{timeoutMs:s,...a}=e??{};return await fetch(t,{...a,signal:r.signal})}finally{clearTimeout(o)}}var Ye=f(()=>{"use strict"});function Xe(t,e){let n=Je(t),r=Je(e);if(!n||!r)return!1;for(let o=0;o<3;o++)if(n.main[o]!==r.main[o])return n.main[o]>r.main[o];return n.pre&&!r.pre?!1:!n.pre&&r.pre?!0:!n.pre&&!r.pre?!1:bn(n.pre,r.pre)>0}function Je(t){if(typeof t!="string")return null;let n=t.trim().replace(/^v/,"").match(wn);return n?{main:[Number(n[1]),Number(n[2]),Number(n[3])],pre:n[4]??null}:null}function bn(t,e){let n=t.split("."),r=e.split("."),o=Math.max(n.length,r.length);for(let s=0;s<o;s++){if(s>=n.length)return-1;if(s>=r.length)return 1;let a=n[s],i=r[s],l=/^\d+$/.test(a),c=/^\d+$/.test(i);if(l&&c){let u=Number(a)-Number(i);if(u!==0)return u}else{if(l)return-1;if(c)return 1;if(a<i)return-1;if(a>i)return 1}}return 0}var wn,Ze=f(()=>{"use strict";wn=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/});function re(){return!!(Qe(process.env.VISA_CLI_NO_UPDATE_CHECK)||Qe(process.env.CI)||process.env.NODE_ENV==="test")}function Qe(t){if(t===void 0)return!1;let e=t.trim().toLowerCase();return!(e===""||e==="0"||e==="false"||e==="no"||e==="off")}var be=f(()=>{"use strict"});var Se,T,oe=f(()=>{"use strict";Ye();Ze();be();Se="1.1.0-rc.6",T=class{constructor(e){this.getSessionToken=e;this.baseUrl=process.env.VISA_AUTH_URL||"https://auth.visacli.sh"}getSessionToken;baseUrl;lastSignals={};parseServerSignals(e){if(this.lastSignals={},!re()){let r=e.headers.get("X-Latest-Version"),o=e.headers.get("X-Update-Message");r&&Xe(r,Se)&&(this.lastSignals.updateAvailable={version:r,message:o||`Update available: v${r}. Run: npm install -g @visa/cli && visa-cli setup`})}let n=e.headers.get("X-Feedback-Prompt");if(n)try{this.lastSignals.feedbackPrompt=JSON.parse(n)}catch{}}getClientVersion(){return Se}async request(e,n,r,o,s){let a=await this.getSessionToken();if(!a)throw new Error("Not logged in. Sign up at https://visacli.sh or run: visa-cli setup");let i={Authorization:`Bearer ${a}`};s&&(e==="GET"?i["X-User-Context"]=s.replace(/[\r\n\0]/g," ").slice(0,1e3):r={...r||{},user_context:s}),r&&(i["Content-Type"]="application/json");let l;try{l=await ze(`${this.baseUrl}${n}`,{method:e,headers:{...i,"X-Visa-CLI-Version":Se},body:r?JSON.stringify(r):void 0,timeoutMs:o})}catch(u){throw u.name==="AbortError"||u.message?.includes("aborted")?new Error("The request timed out. The server may be under heavy load. Please try again."):new Error("Cannot reach the Visa CLI server. Check your internet connection and try again.")}if(this.parseServerSignals(l),l.status===401)throw new Error("Your session has expired. Run: visa-cli setup");if(l.status===429){let u=l.headers.get("Retry-After")||"3";throw new Error(`Rate limited \u2014 wait ${u}s. Tip: use the batch tool to combine multiple requests into one.`)}if(l.status===503)throw new Error("Visa CLI is temporarily unavailable. Check https://visacli.sh for status.");let c;try{c=await l.json()}catch{throw l.status===500?new Error(`Server error on ${n}. Try again or check https://visacli.sh for status.`):new Error(`Unexpected response from ${n}. Try again.`)}if(!l.ok)throw l.status===500?new Error(`Server error on ${n}. Try again or check https://visacli.sh for status.`):new Error(c?.error||`Request failed (${l.status}). Try again.`);return c}async pay(e,n){return this.request("POST","/v1/pay",e,void 0,n)}async shortcut(e,n,r,o){return this.request("POST",`/v1/shortcuts/${encodeURIComponent(e)}`,n,r,o)}async batch(e,n,r){return this.request("POST","/v1/batch",e,n,r)}async catalogSearch(e,n){let r=new URLSearchParams;e&&r.set("q",e),n&&r.set("category",n);let o=r.toString();return this.request("GET",`/v1/catalog${o?`?${o}`:""}`)}async catalogTool(e){try{return await this.request("GET",`/v1/catalog/${encodeURIComponent(e)}`)}catch{return null}}async paymentPreview(e,n){return this.request("POST","/v1/payment-preview",e,void 0,n)}async getStatus(e){return this.request("GET","/v1/status",void 0,void 0,e)}async getTransactions(e){return this.request("GET","/v1/transactions",void 0,void 0,e)}async updateSpendingControls(e,n){return this.request("POST","/v1/spending-controls",e,void 0,n)}async removeCard(e,n,r){return this.request("DELETE",`/v1/cards/${encodeURIComponent(String(e))}`,n,void 0,r)}async setDefaultCard(e,n,r){return this.request("POST",`/v1/cards/${encodeURIComponent(String(e))}/default`,n,void 0,r)}async getAttestationChallenge(){return this.request("GET","/v1/attestation-challenge")}async registerAttestationKey(e){return this.request("POST","/v1/attestation-key",{publicKey:e})}async logout(e,n){return this.request("POST","/v1/logout",e,void 0,n)}async feedback(e,n,r){return this.request("POST","/v1/feedback",{message:e,...n&&{transaction_id:n}},void 0,r)}async feedSubmit(e){return this.request("POST","/v1/feed",e)}async feedList(e){let n=new URLSearchParams;e?.tab&&n.set("tab",e.tab),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset));let r=n.toString();return this.request("GET",`/v1/feed${r?"?"+r:""}`)}async feedVote(e,n){return this.request("POST",`/v1/feed/${encodeURIComponent(e)}/vote`,{direction:n})}async feedApprove(e){return this.request("POST",`/v1/feed/${encodeURIComponent(e)}/approve`)}async feedDelete(e){return this.request("DELETE",`/v1/feed/${encodeURIComponent(e)}`)}async feedPending(){return this.request("GET","/v1/feed/pending")}async submitFeedback(e,n,r){return this.request("POST","/v1/feedback",{message:e,...n&&{transaction_id:n}},void 0,r)}async getFeedback(e,n){let r=new URLSearchParams;e&&r.set("limit",String(e));let o=r.toString();return this.request("GET",`/v1/feedback${o?"?"+o:""}`,void 0,void 0,n)}async submitRatedFeedback(e){return this.request("POST","/v1/feedback",e)}}});function vn(){w.existsSync(xe)||w.mkdirSync(xe,{recursive:!0,mode:448})}function xn(){if(!ve){if(vn(),w.existsSync(B)&&w.statSync(B).size>Sn){let e=B+".1";w.existsSync(e)&&w.unlinkSync(e),w.renameSync(B,e)}ve=w.createWriteStream(B,{flags:"a"})}return ve}function se(t,...e){let n=new Date().toISOString(),r=e.map(s=>typeof s=="string"?s:JSON.stringify(s,null,2)).join(" "),o=`[${n}] [${t}] ${r}
2
+ `;process.stderr.write(o),xn().write(o)}var w,Pe,et,xe,B,Sn,ve,M,Ee=f(()=>{"use strict";w=p(require("fs")),Pe=p(require("path")),et=p(require("os")),xe=Pe.join(et.homedir(),".visa-mcp"),B=Pe.join(xe,"mcp-server.log"),Sn=5*1024*1024,ve=null;M={debug:(...t)=>se("DEBUG",...t),info:(...t)=>se("INFO",...t),warn:(...t)=>se("WARN",...t),error:(...t)=>se("ERROR",...t)}});function ot(t){let e=h.readFileSync(t);return it.createHash("sha256").update(e).digest("hex")}async function ct(){try{if(h.readFileSync(nt,"utf-8").trim()===tt&&h.existsSync(L)){let r=h.readFileSync(rt,"utf-8").trim();if(ot(L)!==r)M.warn("binary:hash-mismatch",{message:"Binary hash mismatch \u2014 possible tampering detected. Recompiling from source."}),h.unlinkSync(L);else return L}}catch{}let t=C.join(Pn,"visa-keychain.m");if(h.existsSync(t)||(t=C.resolve(__dirname,"..","..","native","visa-keychain.m")),h.existsSync(t)||(t=C.resolve(__dirname,"..","native","visa-keychain.m")),!h.existsSync(t))throw new Error("visa-keychain.m source not found. Reinstall Visa CLI.");h.mkdirSync(ce,{recursive:!0,mode:448});try{await F("clang",["-framework","Security","-framework","LocalAuthentication","-framework","Foundation","-framework","AppKit","-o",L,t],{timeout:3e4})}catch(n){throw n.code==="ENOENT"?new Error("Xcode Command Line Tools required. Install: xcode-select --install"):n}let e=ot(L);return h.writeFileSync(rt,e,{mode:384}),h.writeFileSync(nt,tt,{mode:384}),L}async function lt(t){let e=await ct(),n;try{n=(await F(e,t,{timeout:6e4})).stdout}catch(s){n=s.stdout||"";let a=n.trim();throw a.startsWith("ERROR:")?new Error(a.slice(6)):new Error(s.stderr?.trim()||s.message||"Unknown error")}let r=n.trim();if(r.startsWith("OK:"))return r.slice(3);if(r==="OK")return;let o=r.startsWith("ERROR:")?r.slice(6):"Unknown error";throw new Error(o)}function U(){return process.env.VISA_MOCK_TOUCHID==="true"?!0:process.platform!=="darwin"?!1:Ce!==null?Ce:(Ce=!0,!0)}async function En(t){try{await F("security",["delete-generic-password","-s",ie,"-a",ae],{timeout:5e3})}catch{}await F("security",["add-generic-password","-s",ie,"-a",ae,"-w",t],{timeout:5e3})}async function Cn(){try{let{stdout:t}=await F("security",["find-generic-password","-s",ie,"-a",ae,"-w"],{timeout:5e3});return t.trim()||null}catch{return null}}async function ut(){let t=await lt(["generate-key"]);if(!t)throw new Error("Key generation returned no output");let e=t.indexOf(":");if(e<0)throw new Error("Unexpected generate-key output format");let n=t.slice(0,e),r=t.slice(e+1);return await En(n),r}async function le(t,e){if(process.env.VISA_MOCK_TOUCHID==="true")return Promise.resolve("mock-ecdsa-signature-for-testing");let n=await Cn();if(!n)throw new Error("Attestation key not found. Run setup to generate a new key.");let r=await ct(),o=["sign",t];return e&&o.push(e),new Promise((s,a)=>{let i=(0,$e.execFile)(r,o,{timeout:6e4},(l,c)=>{let u=(c||"").trim();if(l){u.startsWith("ERROR:")?a(new Error(u.slice(6))):a(new Error(l.stderr?.trim()||l.message||"Unknown error"));return}u.startsWith("OK:")?s(u.slice(3)):a(new Error(u.startsWith("ERROR:")?u.slice(6):"Unknown error"))});i.stdin.write(n),i.stdin.end()})}async function Te(){try{await F("security",["delete-generic-password","-s",ie,"-a",ae],{timeout:5e3})}catch{}try{await lt(["delete-key"])}catch{}}var $e,st,it,h,at,C,F,ce,L,Pn,tt,nt,rt,Ce,ie,ae,ke=f(()=>{"use strict";$e=require("child_process"),st=require("util"),it=p(require("crypto")),h=p(require("fs")),at=p(require("os")),C=p(require("path"));Ee();F=(0,st.promisify)($e.execFile),ce=C.join(at.homedir(),".visa-mcp","bin"),L=C.join(ce,"Visa CLI"),Pn=C.join(__dirname,"..","native"),tt="5",nt=C.join(ce,"visa-keychain.version"),rt=C.join(ce,"visa-keychain.sha256");Ce=null;ie="visa-cli",ae="attestation-key"});async function ue(t){let{model:e,messages:n,tools:r,maxTokens:o=4096,temperature:s=.7,attestation:a,sessionBudgetId:i}=t;return await kn.shortcut(e,{prompt:"",messages:n,...r?.length?{tools:r}:{},max_tokens:o,temperature:s,...a?{attestation:a}:{},...i?{session_budget_id:i}:{}},12e4)}function St(t,e){let n={"or-claude-sonnet":{inPerM:3,outPerM:15},"or-gpt-4o":{inPerM:5,outPerM:15},"or-gpt-4o-mini":{inPerM:.15,outPerM:.6},"or-gemini-pro":{inPerM:.25,outPerM:1},"or-llama-70b":{inPerM:.59,outPerM:.79},"or-deepseek-chat":{inPerM:.27,outPerM:1.1},"or-deepseek-r1":{inPerM:.55,outPerM:2.19},"or-mistral-large":{inPerM:2,outPerM:6}},r=n[e]||n["or-gpt-4o-mini"],o=t.prompt_tokens/1e6*r.inPerM*100,s=t.completion_tokens/1e6*r.outPerM*100;return Math.ceil(o+s)}var kn,Me=f(()=>{"use strict";oe();K();kn=new T(()=>g.getSessionToken())});function xt(t){let e=[];e.push(`You are an AI coding assistant powered by Visa CLI.
3
3
  You can read, write, and edit files. You can run shell commands.
4
4
  You can generate images, music, video, and query data \u2014 each costs money.
5
5
  The user pays per-use via their Visa card. Show costs before expensive operations.
6
6
 
7
- Working directory: ${t}`);let n=Me.join(t,"CLAUDE.md");if(q.existsSync(n)){let o=q.readFileSync(n,"utf-8");e.push(`
7
+ Working directory: ${t}`);let n=Ne.join(t,"CLAUDE.md");if(D.existsSync(n)){let o=D.readFileSync(n,"utf-8");e.push(`
8
8
  --- Project Context (CLAUDE.md) ---
9
- ${o.slice(0,4e3)}`)}let r=Me.join(t,".env");if(q.existsSync(r)){let o=q.readFileSync(r,"utf-8").split(`
9
+ ${o.slice(0,4e3)}`)}let r=Ne.join(t,".env");if(D.existsSync(r)){let o=D.readFileSync(r,"utf-8").split(`
10
10
  `).filter(s=>s.includes("=")&&!s.startsWith("#")).map(s=>s.split("=")[0]);o.length&&e.push(`
11
- Environment variables present: ${o.join(", ")}`)}try{let o=(0,St.execSync)("git branch --show-current",{cwd:t,encoding:"utf-8"}).trim();e.push(`
11
+ Environment variables present: ${o.join(", ")}`)}try{let o=(0,vt.execSync)("git branch --show-current",{cwd:t,encoding:"utf-8"}).trim();e.push(`
12
12
  Git branch: ${o}`)}catch{}return e.join(`
13
13
  `)}async function Pt(t,e){let n=t[0],r=Math.max(1,t.length-6),o=t.slice(r),s=t.slice(1,r);if(s.length===0)return t;let a=s.filter(c=>c.role!=="tool").map(c=>`${c.role}: ${typeof c.content=="string"?c.content?.slice(0,200):"[tool call]"}`).join(`
14
14
  `),l=(await ue({model:e,messages:[{role:"system",content:"Summarize this conversation concisely. Focus on what was done, decisions made, and current state. Under 500 words."},{role:"user",content:a}],maxTokens:1024})).choices[0]?.message?.content||"Previous conversation context unavailable.";return[n,{role:"user",content:`[Previous conversation summary]
15
- ${l}`},{role:"assistant",content:"Understood. I have context from our previous conversation. How can I help?"},...o]}var q,Me,St,Et=f(()=>{"use strict";q=p(require("fs")),Me=p(require("path")),St=require("child_process");Ne()});var v,T,Oe,xt,Ct,$t=f(()=>{"use strict";v=p(require("fs")),T=p(require("path")),Oe=require("child_process"),xt=[{type:"function",function:{name:"read_file",description:"Read a file. Returns contents with line numbers.",parameters:{type:"object",properties:{path:{type:"string",description:"File path (relative to cwd)"},offset:{type:"number",description:"Start line (0-indexed)"},limit:{type:"number",description:"Max lines to read"}},required:["path"]}}},{type:"function",function:{name:"write_file",description:"Write full content to a file (create or overwrite).",parameters:{type:"object",properties:{path:{type:"string",description:"File path (relative to cwd)"},content:{type:"string",description:"Full file content"}},required:["path","content"]}}},{type:"function",function:{name:"edit_file",description:"Replace a string in a file. old_string must be unique in the file.",parameters:{type:"object",properties:{path:{type:"string",description:"File path"},old_string:{type:"string",description:"Exact string to find"},new_string:{type:"string",description:"Replacement string"}},required:["path","old_string","new_string"]}}},{type:"function",function:{name:"glob",description:"Find files matching a glob pattern.",parameters:{type:"object",properties:{pattern:{type:"string",description:'Glob pattern (e.g. "**/*.ts")'},path:{type:"string",description:"Directory to search in"}},required:["pattern"]}}},{type:"function",function:{name:"grep",description:"Search file contents with regex. Returns matching lines.",parameters:{type:"object",properties:{pattern:{type:"string",description:"Regex pattern"},path:{type:"string",description:"Directory or file to search"},include:{type:"string",description:'Glob to filter files (e.g. "*.ts")'}},required:["pattern"]}}},{type:"function",function:{name:"list_dir",description:"List directory contents.",parameters:{type:"object",properties:{path:{type:"string",description:"Directory path"}},required:["path"]}}}],Ct={read_file(t,e){let n=T.resolve(e,t.path),o=v.readFileSync(n,"utf-8").split(`
15
+ ${l}`},{role:"assistant",content:"Understood. I have context from our previous conversation. How can I help?"},...o]}var D,Ne,vt,Et=f(()=>{"use strict";D=p(require("fs")),Ne=p(require("path")),vt=require("child_process");Me()});var v,k,Oe,Ct,$t,Tt=f(()=>{"use strict";v=p(require("fs")),k=p(require("path")),Oe=require("child_process"),Ct=[{type:"function",function:{name:"read_file",description:"Read a file. Returns contents with line numbers.",parameters:{type:"object",properties:{path:{type:"string",description:"File path (relative to cwd)"},offset:{type:"number",description:"Start line (0-indexed)"},limit:{type:"number",description:"Max lines to read"}},required:["path"]}}},{type:"function",function:{name:"write_file",description:"Write full content to a file (create or overwrite).",parameters:{type:"object",properties:{path:{type:"string",description:"File path (relative to cwd)"},content:{type:"string",description:"Full file content"}},required:["path","content"]}}},{type:"function",function:{name:"edit_file",description:"Replace a string in a file. old_string must be unique in the file.",parameters:{type:"object",properties:{path:{type:"string",description:"File path"},old_string:{type:"string",description:"Exact string to find"},new_string:{type:"string",description:"Replacement string"}},required:["path","old_string","new_string"]}}},{type:"function",function:{name:"glob",description:"Find files matching a glob pattern.",parameters:{type:"object",properties:{pattern:{type:"string",description:'Glob pattern (e.g. "**/*.ts")'},path:{type:"string",description:"Directory to search in"}},required:["pattern"]}}},{type:"function",function:{name:"grep",description:"Search file contents with regex. Returns matching lines.",parameters:{type:"object",properties:{pattern:{type:"string",description:"Regex pattern"},path:{type:"string",description:"Directory or file to search"},include:{type:"string",description:'Glob to filter files (e.g. "*.ts")'}},required:["pattern"]}}},{type:"function",function:{name:"list_dir",description:"List directory contents.",parameters:{type:"object",properties:{path:{type:"string",description:"Directory path"}},required:["path"]}}}],$t={read_file(t,e){let n=k.resolve(e,t.path),o=v.readFileSync(n,"utf-8").split(`
16
16
  `),s=t.offset||0,a=t.limit||o.length;return{content:o.slice(s,s+a).map((c,u)=>`${s+u+1} ${c}`).join(`
17
- `),isError:!1}},write_file(t,e){let n=T.resolve(e,t.path),r=T.dirname(n);return v.existsSync(r)||v.mkdirSync(r,{recursive:!0}),v.writeFileSync(n,t.content),{content:`Wrote ${n}`,isError:!1}},edit_file(t,e){let n=T.resolve(e,t.path),r=v.readFileSync(n,"utf-8"),o=t.old_string,s=t.new_string,a=r.indexOf(o);return a===-1?{content:`old_string not found in ${n}`,isError:!0}:r.indexOf(o,a+1)!==-1?{content:`old_string is not unique in ${n}`,isError:!0}:(v.writeFileSync(n,r.replace(o,s)),{content:`Edited ${n}`,isError:!1})},glob(t,e){let n=t.path?T.resolve(e,t.path):e,r=t.pattern;try{return{content:(0,Oe.execFileSync)("find",[n,"-path",`*${r}`,"-not","-path","*/node_modules/*","-not","-path","*/.git/*"],{encoding:"utf-8",timeout:5e3}).split(`
17
+ `),isError:!1}},write_file(t,e){let n=k.resolve(e,t.path),r=k.dirname(n);return v.existsSync(r)||v.mkdirSync(r,{recursive:!0}),v.writeFileSync(n,t.content),{content:`Wrote ${n}`,isError:!1}},edit_file(t,e){let n=k.resolve(e,t.path),r=v.readFileSync(n,"utf-8"),o=t.old_string,s=t.new_string,a=r.indexOf(o);return a===-1?{content:`old_string not found in ${n}`,isError:!0}:r.indexOf(o,a+1)!==-1?{content:`old_string is not unique in ${n}`,isError:!0}:(v.writeFileSync(n,r.replace(o,s)),{content:`Edited ${n}`,isError:!1})},glob(t,e){let n=t.path?k.resolve(e,t.path):e,r=t.pattern;try{return{content:(0,Oe.execFileSync)("find",[n,"-path",`*${r}`,"-not","-path","*/node_modules/*","-not","-path","*/.git/*"],{encoding:"utf-8",timeout:5e3}).split(`
18
18
  `).filter(Boolean).slice(0,100).join(`
19
- `)||"No matches",isError:!1}}catch{return{content:"No matches",isError:!1}}},grep(t,e){let n=t.path?T.resolve(e,t.path):e,r=t.pattern,o=t.include,s=["-rn",...o?["--include",o]:[],r,n];try{return{content:(0,Oe.execFileSync)("grep",s,{encoding:"utf-8",timeout:1e4}).split(`
19
+ `)||"No matches",isError:!1}}catch{return{content:"No matches",isError:!1}}},grep(t,e){let n=t.path?k.resolve(e,t.path):e,r=t.pattern,o=t.include,s=["-rn",...o?["--include",o]:[],r,n];try{return{content:(0,Oe.execFileSync)("grep",s,{encoding:"utf-8",timeout:1e4}).split(`
20
20
  `).filter(Boolean).slice(0,50).join(`
21
- `)||"No matches",isError:!1}}catch{return{content:"No matches",isError:!1}}},list_dir(t,e){let n=T.resolve(e,t.path||".");return{content:v.readdirSync(n,{withFileTypes:!0}).map(s=>`${s.isDirectory()?"d":"f"} ${s.name}`).join(`
22
- `),isError:!1}}}});var kt,Tn,Tt,At,Rt=f(()=>{"use strict";kt=require("child_process"),Tn=[/rm\s+-rf\s+\//,/mkfs/,/dd\s+if=/,/:()\{\s*:\|:&\s*\};:/,/>\s*\/dev\/sd/],Tt=[{type:"function",function:{name:"bash",description:"Run a bash command. Returns stdout + stderr.",parameters:{type:"object",properties:{command:{type:"string",description:"Bash command to execute"}},required:["command"]}}}],At={bash(t,e){let n=t.command;for(let r of Tn)if(r.test(n))return{content:"Blocked: dangerous command pattern",isError:!0};try{return{content:(0,kt.execSync)(n,{cwd:e,encoding:"utf-8",timeout:3e4,maxBuffer:1048576,stdio:["pipe","pipe","pipe"]}).slice(0,1e4),isError:!1}}catch(r){return{content:((r.stdout||"")+(r.stderr||"")).slice(0,1e4)||r.message,isError:!0}}}}});async function Nt(t,e,n){let r=An[t];if(!r)return{content:`Unknown tool: ${t}`,isError:!0};try{return r(e,n)}catch(o){return{content:o.message||String(o),isError:!0}}}var It,An,Mt=f(()=>{"use strict";$t();Rt();It=[...xt,...Tt],An={...Ct,...At}});async function Ot(t,e,n,r,o,s){let a=process.cwd(),i=[{role:"system",content:vt(a)}],l=Nn[t.model]||128e3;for(;t.turns<Rn;){let c=await n();if(c===null)break;if(!c.trim())continue;if(c.startsWith("/")){if(c.startsWith("/model ")){t.model=c.slice(7).trim(),r(`Switched to ${t.model}`);continue}if(c==="/budget"||c==="/cost"){r(`Spent: $${(t.spentCents/100).toFixed(2)} / $${(t.budgetCents/100).toFixed(2)}`);continue}if(c==="/quit"||c==="/exit")break}i.push({role:"user",content:c});let u=0,_=0;for(;;){if(t.turns++,t.spentCents>=t.budgetCents){r("Session budget exhausted. Run /budget to check or start a new session.");return}let x;try{x=await ue({model:t.model,messages:i,tools:It,maxTokens:4096,temperature:.7,...e?{attestation:e}:{}})}catch(S){r(`Error: ${S.message||S}`),i.pop();break}let Y=bt(x.usage,t.model);t.spentCents+=Y,t.inputTokens+=x.usage.prompt_tokens,t.outputTokens+=x.usage.completion_tokens,u+=Y;let V=x.choices[0];if(!V)break;let A=V.message;if(A.content&&r(A.content),i.push(A),!A.tool_calls?.length||V.finish_reason==="stop")break;for(let S of A.tool_calls){let Le=S.function.name,J;try{J=JSON.parse(S.function.arguments)}catch{J={}}o(Le,J);let{content:Jt}=await Nt(Le,J,a);i.push({role:"tool",content:Jt.slice(0,1e4),tool_call_id:S.id})}}if(s(u,_),Mn(i)>l*In){let x=await Pt(i,t.model);i.length=0,i.push(...x)}}}function Mn(t){let e=0;for(let n of t)if(typeof n.content=="string"&&(e+=n.content.length),n.tool_calls)for(let r of n.tool_calls)e+=r.function.arguments.length+r.function.name.length;return Math.ceil(e/3.5)}var Rn,In,Nn,Lt=f(()=>{"use strict";Ne();Et();Mt();Rn=50,In=.7,Nn={"or-claude-sonnet":2e5,"or-gpt-4o":128e3,"or-gpt-4o-mini":128e3,"or-gemini-pro":1e6,"or-deepseek-r1":64e3}});async function Ut(t,e,n,r){if(!U()){N.warn("attestation:unavailable",{context:t});return}N.info("attestation:attempt",{context:t,amount:e,merchant:n});try{let{nonce:o}=await On.getAttestationChallenge(),s=Buffer.from(JSON.stringify({nonce:o,amount:e,merchant:n,context:t})).toString("base64");N.info("touchid:prompt",{context:t,amount:e,merchant:n});let a=await le(s,r);return N.info("attestation:success",{context:t,amount:e,merchant:n}),{signature:a,nonce:o,amount:e,merchant:n}}catch(o){throw N.error("attestation:failure",{context:t,amount:e,merchant:n,error:o.message}),o}}var $r,On,Ln,kr,Tr,Ar,jt=f(()=>{"use strict";oe();Te();K();xe();$r=process.env.VISA_AUTH_URL||"https://auth.visacli.sh",On=new k(()=>g.getSessionToken()),Ln=["generate_image","generate_video","generate_music","generate_audio","generate_3d","upscale_image","transcribe_audio","run_llm"],kr=["","","You're ready to go! Try:","","Core:",'\u2022 "Show my account status" \u2192 get_status','\u2022 "List my enrolled cards" \u2192 get_cards','\u2022 "Show my recent transactions" \u2192 transaction_history','\u2022 "Set my daily limit to $50" \u2192 update_spending_controls','\u2022 "Pay https://example.com/checkout" \u2192 pay','\u2022 "Generate 3 variations in parallel" \u2192 batch',"","Fast shortcuts:",'\u2022 "Generate an image of a sunset over Tokyo" \u2192 generate_image_card (~$0.06)','\u2022 "Make a fast thumbnail: minimalist cat logo" \u2192 generate_image_fast_card (~$0.04)','\u2022 "Make a 4-second video of a penguin juggling" \u2192 generate_video_tempo_card (~$0.30)','\u2022 "Make a song about coding late at night" \u2192 generate_music_tempo_card (~$0.10)','\u2022 "Check the status of my music job" \u2192 check_music_status_tempo_card','\u2022 "What is ETH on Base trading at?" \u2192 query_onchain_prices_card (~$0.02)','\u2022 "Explore stablecoin inflows on Base" \u2192 allium_explorer_card','\u2022 "Open the latest Allium result set" \u2192 allium_explorer_results_card','\u2022 "Show pxlwall campaign insights" \u2192 pxlwall_card',"","Category tools:",...Ln.map(t=>`\u2022 "${t.replace(/_/g," ")}" \u2192 ${t}`),"","Tool catalog:",'\u2022 "Find an image upscaler" \u2192 discover_tools','\u2022 "Run fal-aura-sr on this URL" \u2192 execute_tool'].join(`
23
- `);Tr=16*1024,Ar=50*1024*1024});function Dt(t="or-claude-sonnet"){return{model:t,budgetCents:Ft,spentCents:0,turns:0,inputTokens:0,outputTokens:0}}async function qt(t=Ft){try{return{attestation:await Ut("visa-client-session",t/100,"Visa CLI",`Visa CLI session budget: $${(t/100).toFixed(2)}`)||void 0,budgetCents:t}}catch{return{attestation:void 0,budgetCents:t}}}function de(t){let e=(t.budgetCents-t.spentCents)/100,n=t.spentCents/100;return`$${e.toFixed(2)} remaining ($${n.toFixed(2)} spent, ${t.turns} turns)`}var Ft,Ht=f(()=>{"use strict";jt();Ft=500});var Kt={};rn(Kt,{startClient:()=>Fn});async function Fn(t={}){let e=Dt(t.model);console.log(jn),console.log(`
24
- ${j}Model: ${e.model}${M}`),console.log(` ${j}Authorizing session budget: $${(e.budgetCents/100).toFixed(2)}${M}`);let n=await qt(t.budget||e.budgetCents);e.budgetCents=n.budgetCents,n.attestation?console.log(` ${j}Touch ID authorized. ${de(e)}${M}
25
- `):console.log(` ${j}No attestation (Touch ID unavailable). ${de(e)}${M}
26
- `);let r=Vt.createInterface({input:process.stdin,output:process.stdout,prompt:`${Un}dove>${M} `}),o=()=>new Promise(l=>{r.prompt(),r.once("line",c=>l(c)),r.once("close",()=>l(null))}),s=l=>{console.log(`
21
+ `)||"No matches",isError:!1}}catch{return{content:"No matches",isError:!1}}},list_dir(t,e){let n=k.resolve(e,t.path||".");return{content:v.readdirSync(n,{withFileTypes:!0}).map(s=>`${s.isDirectory()?"d":"f"} ${s.name}`).join(`
22
+ `),isError:!1}}}});var kt,In,It,Rt,At=f(()=>{"use strict";kt=require("child_process"),In=[/rm\s+-rf\s+\//,/mkfs/,/dd\s+if=/,/:()\{\s*:\|:&\s*\};:/,/>\s*\/dev\/sd/],It=[{type:"function",function:{name:"bash",description:"Run a bash command. Returns stdout + stderr.",parameters:{type:"object",properties:{command:{type:"string",description:"Bash command to execute"}},required:["command"]}}}],Rt={bash(t,e){let n=t.command;for(let r of In)if(r.test(n))return{content:"Blocked: dangerous command pattern",isError:!0};try{return{content:(0,kt.execSync)(n,{cwd:e,encoding:"utf-8",timeout:3e4,maxBuffer:1048576,stdio:["pipe","pipe","pipe"]}).slice(0,1e4),isError:!1}}catch(r){return{content:((r.stdout||"")+(r.stderr||"")).slice(0,1e4)||r.message,isError:!0}}}}});async function Nt(t,e,n){let r=Rn[t];if(!r)return{content:`Unknown tool: ${t}`,isError:!0};try{return r(e,n)}catch(o){return{content:o.message||String(o),isError:!0}}}var Mt,Rn,Ot=f(()=>{"use strict";Tt();At();Mt=[...Ct,...It],Rn={...$t,...Rt}});async function Lt(t,e,n,r,o,s){let a=process.cwd(),i=[{role:"system",content:xt(a)}],l=Nn[t.model]||128e3;for(;t.turns<An;){let c=await n();if(c===null)break;if(!c.trim())continue;if(c.startsWith("/")){if(c.startsWith("/model ")){t.model=c.slice(7).trim(),r(`Switched to ${t.model}`);continue}if(c==="/budget"||c==="/cost"){r(`Spent: $${(t.spentCents/100).toFixed(2)} / $${(t.budgetCents/100).toFixed(2)}`);continue}if(c==="/quit"||c==="/exit")break}i.push({role:"user",content:c});let u=0,_=0;for(;;){if(t.turns++,t.spentCents>=t.budgetCents){r("Session budget exhausted. Run /budget to check or start a new session.");return}let E;try{E=await ue({model:t.model,messages:i,tools:Mt,maxTokens:4096,temperature:.7,...e?{attestation:e}:{}})}catch(S){r(`Error: ${S.message||S}`),i.pop();break}let Y=St(E.usage,t.model);t.spentCents+=Y,t.inputTokens+=E.usage.prompt_tokens,t.outputTokens+=E.usage.completion_tokens,u+=Y;let H=E.choices[0];if(!H)break;let I=H.message;if(I.content&&r(I.content),i.push(I),!I.tool_calls?.length||H.finish_reason==="stop")break;for(let S of I.tool_calls){let Ue=S.function.name,J;try{J=JSON.parse(S.function.arguments)}catch{J={}}o(Ue,J);let{content:Xt}=await Nt(Ue,J,a);i.push({role:"tool",content:Xt.slice(0,1e4),tool_call_id:S.id})}}if(s(u,_),On(i)>l*Mn){let E=await Pt(i,t.model);i.length=0,i.push(...E)}}}function On(t){let e=0;for(let n of t)if(typeof n.content=="string"&&(e+=n.content.length),n.tool_calls)for(let r of n.tool_calls)e+=r.function.arguments.length+r.function.name.length;return Math.ceil(e/3.5)}var An,Mn,Nn,Ut=f(()=>{"use strict";Me();Et();Ot();An=50,Mn=.7,Nn={"or-claude-sonnet":2e5,"or-gpt-4o":128e3,"or-gpt-4o-mini":128e3,"or-gemini-pro":1e6,"or-deepseek-r1":64e3}});var Ln,Cr,jt=f(()=>{"use strict";Le();Ln={generate_image:{intro:"Generate an AI image.",tiers:{balanced:{toolId:"fal-flux-pro",priceCents:4,notes:"FLUX Pro v1.1, 1K, ~10s (DEFAULT \u2014 good quality/speed tradeoff)"},fast:{toolId:"fal-flux-schnell",priceCents:1,notes:"FLUX Schnell, 1K, ~3s (drafts, iteration, cheapest)"},pro:{toolId:"fal-flux-pro-ultra",priceCents:6,notes:"FLUX Pro Ultra, 2K, ~30s (hero images, detail)"},text_heavy:{toolId:"fal-ideogram-v2",priceCents:8,notes:"Ideogram V2 \u2014 best when the image contains rendered text/logos"},vector:{toolId:"fal-recraft-v3",priceCents:5,notes:"Recraft V3 \u2014 vector/flat/illustration styles"}},guidance:"If the user didn't specify a tier, pick 'balanced' unless the prompt clearly signals otherwise (text \u2192 text_heavy, logo/icon \u2192 vector, quick test \u2192 fast, hero/print \u2192 pro).",inputProperties:{prompt:{type:"string",description:"Text description of the image to generate."},aspect_ratio:{type:"string",description:'Aspect ratio, e.g. "16:9", "1:1", "9:16".',default:"16:9"}},required:["prompt"]},generate_video:{intro:"Generate an AI video from a text prompt.",tiers:{balanced:{toolId:"fal-minimax-video",priceCents:15,notes:"MiniMax \u2014 good quality/price balance (DEFAULT)"},fast:{toolId:"fal-wan-video",priceCents:10,notes:"Wan \u2014 cheapest, shorter clips"},pro:{toolId:"fal-kling-video",priceCents:20,notes:"Kling \u2014 highest quality, cinematic"}},guidance:"Show the tier menu with prices unless the user specified one. Videos take 60-180s to generate.",inputProperties:{prompt:{type:"string",description:"Text description of the video scene."},aspect_ratio:{type:"string",description:'Aspect ratio, e.g. "16:9" or "9:16".',default:"16:9"}},required:["prompt"]},generate_music:{intro:"Generate an original music track from a prompt.",tiers:{suno:{toolId:"suno-music",priceCents:10,notes:"Suno v4 \u2014 songs with vocals, lyrics, full arrangement"}},guidance:"Takes ~60-90s. Returns an audio URL the user can play.",inputProperties:{prompt:{type:"string",description:"Musical style / mood / lyrics hint."},instrumental:{type:"boolean",description:"True for instrumental (no vocals), false for vocal track.",default:!1}},required:["prompt"]},generate_audio:{intro:"Generate speech or sound effects.",tiers:{tts:{toolId:"fal-metavoice",priceCents:3,notes:"MetaVoice \u2014 high-quality TTS from text"},sfx:{toolId:"fal-stable-audio",priceCents:4,notes:"Stable Audio \u2014 sound effects and ambient from a prompt"}},guidance:'Pick "tts" for spoken words, "sfx" for music-beds/effects/ambient.',inputProperties:{prompt:{type:"string",description:"Text to speak (tts) or description of sound (sfx)."}},required:["prompt"]},generate_3d:{intro:"Generate a 3D model from a text description.",tiers:{trellis:{toolId:"fal-trellis-3d",priceCents:8,notes:"Trellis \u2014 fast text-to-3D, returns a GLB mesh URL"}},guidance:"Takes ~30-60s. Returns a downloadable 3D mesh URL.",inputProperties:{prompt:{type:"string",description:"Description of the 3D object."}},required:["prompt"]},upscale_image:{intro:"Upscale an image to higher resolution.",tiers:{aura:{toolId:"fal-aura-sr",priceCents:3,notes:"Aura SR \u2014 default; preserves detail without hallucination"}},guidance:"Pass the existing image URL. Returns an upscaled version.",inputProperties:{image_url:{type:"string",description:"URL of the image to upscale."}},required:["image_url"]},transcribe_audio:{intro:"Transcribe speech in an audio/video URL to text.",tiers:{whisper:{toolId:"fal-whisper",priceCents:2,notes:"OpenAI Whisper \u2014 fast, multilingual"}},guidance:"Pass the URL. Returns the transcript text.",inputProperties:{audio_url:{type:"string",description:"URL of the audio or video file to transcribe."}},required:["audio_url"]},run_llm:{intro:"Run a text prompt through an LLM (OpenRouter). Token-metered \u2014 prices below are per 1M input/output tokens. Typical 500-in/500-out prompts cost 1\u20139\xA2 depending on model.",tiers:{fast:{toolId:"or-gpt-4o-mini",priceCents:1,notes:"GPT-4o Mini \u2014 $0.15/M in \xB7 $0.60/M out. Fastest, cheapest, good general-purpose (DEFAULT)"},reasoning:{toolId:"or-claude-sonnet",priceCents:9,notes:"Claude 3.5 Sonnet \u2014 $3.00/M in \xB7 $15.00/M out. Strong reasoning, long-context. ~20x pricier than `fast`."},deep_reasoning:{toolId:"or-deepseek-r1",priceCents:2,notes:"DeepSeek R1 \u2014 $0.55/M in \xB7 $2.19/M out. Deep chain-of-thought reasoning, mid-range pricing."},search:{toolId:"or-perplexity-sonar",priceCents:1,notes:"Perplexity Sonar \u2014 $1.00/M in \xB7 $1.00/M out. Search-augmented, web-grounded with citations."},open_source:{toolId:"or-llama-70b",priceCents:1,notes:"Llama 3.3 70B \u2014 $0.30/M in \xB7 $0.40/M out. Open-source large model."},coding:{toolId:"or-deepseek-chat",priceCents:1,notes:"DeepSeek Chat V3 \u2014 $0.30/M in \xB7 $0.88/M out. Strong at code generation."}},guidance:"Pick based on the user's need: fast (most questions, cheapest), reasoning (complex analysis \u2014 WARN user it's ~$0.09/call), search (questions about current events), coding (code generation), deep_reasoning (hard math/logic problems).",inputProperties:{prompt:{type:"string",description:"The user query."},system_prompt:{type:"string",description:"Optional system prompt to set model behavior."},max_tokens:{type:"number",description:"Maximum output tokens.",default:1024,minimum:1,maximum:8192},temperature:{type:"number",description:"Sampling temperature \u2014 0 is deterministic, higher is more creative.",default:.7,minimum:0,maximum:2}},required:["prompt"]}},Cr=Object.keys(Ln)});async function qt(t,e,n,r){if(!U()){M.warn("attestation:unavailable",{context:t});return}M.info("attestation:attempt",{context:t,amount:e,merchant:n});try{let{nonce:o}=await Un.getAttestationChallenge(),s=Buffer.from(JSON.stringify({nonce:o,amount:e,merchant:n,context:t})).toString("base64");M.info("touchid:prompt",{context:t,amount:e,merchant:n});let a=await le(s,r);return M.info("attestation:success",{context:t,amount:e,merchant:n}),{signature:a,nonce:o,amount:e,merchant:n}}catch(o){throw M.error("attestation:failure",{context:t,amount:e,merchant:n,error:o.message}),o}}var Or,Un,jn,Lr,Ur,jr,Le=f(()=>{"use strict";oe();ke();K();Ee();jt();Or=process.env.VISA_AUTH_URL||"https://auth.visacli.sh",Un=new T(()=>g.getSessionToken()),jn=["generate_image","generate_video","generate_music","generate_audio","generate_3d","upscale_image","transcribe_audio","run_llm"],Lr=["","","You're ready to go! Try:","","Core:",'\u2022 "Show my account status" \u2192 get_status','\u2022 "List my enrolled cards" \u2192 get_cards','\u2022 "Show my recent transactions" \u2192 transaction_history','\u2022 "Set my daily limit to $50" \u2192 update_spending_controls','\u2022 "Pay https://example.com/checkout" \u2192 pay','\u2022 "Generate 3 variations in parallel" \u2192 batch',"","Fast shortcuts:",'\u2022 "Generate an image of a sunset over Tokyo" \u2192 generate_image_card (~$0.06)','\u2022 "Make a fast thumbnail: minimalist cat logo" \u2192 generate_image_fast_card (~$0.04)','\u2022 "Make a 4-second video of a penguin juggling" \u2192 generate_video_tempo_card (~$0.30)','\u2022 "Make a song about coding late at night" \u2192 generate_music_tempo_card (~$0.10)','\u2022 "Check the status of my music job" \u2192 check_music_status_tempo_card','\u2022 "What is ETH on Base trading at?" \u2192 query_onchain_prices_card (~$0.02)','\u2022 "Explore stablecoin inflows on Base" \u2192 allium_explorer_card','\u2022 "Open the latest Allium result set" \u2192 allium_explorer_results_card','\u2022 "Show pxlwall campaign insights" \u2192 pxlwall_card',"","Category tools:",...jn.map(t=>`\u2022 "${t.replace(/_/g," ")}" \u2192 ${t}`),"","Tool catalog:",'\u2022 "Find an image upscaler" \u2192 discover_tools','\u2022 "Run fal-aura-sr on this URL" \u2192 execute_tool'].join(`
23
+ `);Ur=16*1024,jr=50*1024*1024});function Dt(t="or-claude-sonnet"){return{model:t,budgetCents:Ft,spentCents:0,turns:0,inputTokens:0,outputTokens:0}}async function Vt(t=Ft){try{return{attestation:await qt("visa-client-session",t/100,"Visa CLI",`Visa CLI session budget: $${(t/100).toFixed(2)}`)||void 0,budgetCents:t}}catch{return{attestation:void 0,budgetCents:t}}}function de(t){let e=(t.budgetCents-t.spentCents)/100,n=t.spentCents/100;return`$${e.toFixed(2)} remaining ($${n.toFixed(2)} spent, ${t.turns} turns)`}var Ft,Ht=f(()=>{"use strict";Le();Ft=500});var Bt={};on(Bt,{startClient:()=>Dn});async function Dn(t={}){let e=Dt(t.model);console.log(Fn),console.log(`
24
+ ${j}Model: ${e.model}${N}`),console.log(` ${j}Authorizing session budget: $${(e.budgetCents/100).toFixed(2)}${N}`);let n=await Vt(t.budget||e.budgetCents);e.budgetCents=n.budgetCents,n.attestation?console.log(` ${j}Touch ID authorized. ${de(e)}${N}
25
+ `):console.log(` ${j}No attestation (Touch ID unavailable). ${de(e)}${N}
26
+ `);let r=Kt.createInterface({input:process.stdin,output:process.stdout,prompt:`${qn}dove>${N} `}),o=()=>new Promise(l=>{r.prompt(),r.once("line",c=>l(c)),r.once("close",()=>l(null))}),s=l=>{console.log(`
27
27
  ${l.split(`
28
28
  `).join(`
29
29
  `)}
30
- `)},a=(l,c)=>{let u=l==="bash"?c.command?.slice(0,60):c.path||"";console.log(` ${j}\u25B8 ${l}${M} ${u}`)},i=(l,c)=>{let u=l+c,_=[`$${(l/100).toFixed(3)} inference`];c>0&&_.push(`$${(c/100).toFixed(3)} tools`),console.log(` ${j}${_.join(" \xB7 ")} \xB7 $${(u/100).toFixed(3)} this turn${M}`)};await Ot(e,n.attestation,o,s,a,i),console.log(`
31
- ${j}Session ended. ${de(e)}${M}`),r.close()}var Vt,M,Un,j,jn,Bt=f(()=>{"use strict";Vt=p(require("readline"));Lt();Ht();M="\x1B[0m",Un="\x1B[38;5;33m",j="\x1B[2m",jn=[" \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28E4\u28C0\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2880\u28FF\u2807\u28B0\u28F6\u28E6\u28E4\u28C0\u2840\u2812\u2802\u2824\u2824\u2884\u28C0\u28C0\u2840\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28B8\u285F\u2880\u28FF\u281F\u283F\u28BF\u28FF\u28FF\u28FF\u28FF\u28F6\u28F6\u28E4\u28C4\u28C9\u2841\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28FE\u2801\u28F8\u28FF\u28F7\u28F6\u28E4\u28E4\u28C8\u2849\u281B\u283B\u283F\u28FF\u28FF\u28FF\u28FF\u28FF\u2876\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2880\u284F\u28A0\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28F6\u28E6\u28E4\u28C4\u28C9\u28B9\u28FF\u2803\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2838\u2800\u28FE\u28FF\u28FF\u28FF\u28CF\u28D9\u281B\u283B\u283F\u28BF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u284F\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2802\u28B8\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28F7\u28F6\u28E6\u28E4\u28F8\u28FF\u28FF\u28FF\u28FF\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2880\u28FF\u28FF\u287F\u280B\u28C1\u28E4\u2804\u2880\u2800\u2809\u283B\u28FF\u28FF\u28FF\u28FF\u28FF\u2807\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u28FC\u28FF\u280F\u28C0\u2818\u281B\u2801\u2830\u28FF\u2847\u28B8\u28E6\u2848\u28BF\u28FF\u28FF\u287F\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u28A0\u28FF\u284F\u28A0\u28FF\u28FF\u2803\u28F4\u28F6\u28E4\u2844\u2880\u28C9\u2803\u28B8\u28FF\u28FF\u2803\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u28FE\u28FF\u28C7\u2800\u28C4\u28C9\u2800\u281B\u283F\u283F\u2801\u28FC\u28FF\u2847\u28B8\u28FF\u284F\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u28B8\u28FF\u28FF\u28FF\u28C4\u2819\u28BF\u2818\u28F7\u2876\u2800\u28E4\u28C8\u2849\u2881\u28FE\u28FF\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2819\u281B\u283F\u283F\u28FF\u28E6\u28C4\u2800\u2809\u2820\u281E\u281B\u28C9\u28F4\u28FF\u28FF\u2807\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2808\u2809\u281B\u2812\u2836\u28BF\u28FF\u28FF\u28FF\u287F\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2808\u2809\u2801\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"].join(`
32
- `)});var Wt=require("commander"),pe=p(require("crypto")),H=p(require("os")),Gt=require("child_process"),zt=require("util");K();var ee=p(require("crypto")),te=p(require("tty")),ne=p(require("fs"));var O="6820f6e91b762e645c9bf020c0d3673bb99d4a25a824880c0d548e10bb9bc7b1";K();function mn(t){return/-rc\.|-beta\./.test(t)}function we(t){return ee.createHash("sha256").update(t.trim()).digest("hex")}function Ve(t){return O==="SKIP"?!0:ee.timingSafeEqual(Buffer.from(we(t)),Buffer.from(O))}function pn(t){return new Promise((e,n)=>{let r=ne.openSync("/dev/tty","r+"),o=new te.ReadStream(r),s=new te.WriteStream(r),a=()=>{try{o.destroy()}catch{}try{s.destroy()}catch{}try{ne.closeSync(r)}catch{}};s.write(t),o.setRawMode(!0),o.resume(),o.setEncoding("utf8");let i="";o.on("data",l=>{l==="\r"||l===`
30
+ `)},a=(l,c)=>{let u=l==="bash"?c.command?.slice(0,60):c.path||"";console.log(` ${j}\u25B8 ${l}${N} ${u}`)},i=(l,c)=>{let u=l+c,_=[`$${(l/100).toFixed(3)} inference`];c>0&&_.push(`$${(c/100).toFixed(3)} tools`),console.log(` ${j}${_.join(" \xB7 ")} \xB7 $${(u/100).toFixed(3)} this turn${N}`)};await Lt(e,n.attestation,o,s,a,i),console.log(`
31
+ ${j}Session ended. ${de(e)}${N}`),r.close()}var Kt,N,qn,j,Fn,Gt=f(()=>{"use strict";Kt=p(require("readline"));Ut();Ht();N="\x1B[0m",qn="\x1B[38;5;33m",j="\x1B[2m",Fn=[" \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28E4\u28C0\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2880\u28FF\u2807\u28B0\u28F6\u28E6\u28E4\u28C0\u2840\u2812\u2802\u2824\u2824\u2884\u28C0\u28C0\u2840\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28B8\u285F\u2880\u28FF\u281F\u283F\u28BF\u28FF\u28FF\u28FF\u28FF\u28F6\u28F6\u28E4\u28C4\u28C9\u2841\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28FE\u2801\u28F8\u28FF\u28F7\u28F6\u28E4\u28E4\u28C8\u2849\u281B\u283B\u283F\u28FF\u28FF\u28FF\u28FF\u28FF\u2876\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2880\u284F\u28A0\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28F6\u28E6\u28E4\u28C4\u28C9\u28B9\u28FF\u2803\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2838\u2800\u28FE\u28FF\u28FF\u28FF\u28CF\u28D9\u281B\u283B\u283F\u28BF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u284F\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2802\u28B8\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28F7\u28F6\u28E6\u28E4\u28F8\u28FF\u28FF\u28FF\u28FF\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2880\u28FF\u28FF\u287F\u280B\u28C1\u28E4\u2804\u2880\u2800\u2809\u283B\u28FF\u28FF\u28FF\u28FF\u28FF\u2807\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u28FC\u28FF\u280F\u28C0\u2818\u281B\u2801\u2830\u28FF\u2847\u28B8\u28E6\u2848\u28BF\u28FF\u28FF\u287F\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u28A0\u28FF\u284F\u28A0\u28FF\u28FF\u2803\u28F4\u28F6\u28E4\u2844\u2880\u28C9\u2803\u28B8\u28FF\u28FF\u2803\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u28FE\u28FF\u28C7\u2800\u28C4\u28C9\u2800\u281B\u283F\u283F\u2801\u28FC\u28FF\u2847\u28B8\u28FF\u284F\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u28B8\u28FF\u28FF\u28FF\u28C4\u2819\u28BF\u2818\u28F7\u2876\u2800\u28E4\u28C8\u2849\u2881\u28FE\u28FF\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2819\u281B\u283F\u283F\u28FF\u28E6\u28C4\u2800\u2809\u2820\u281E\u281B\u28C9\u28F4\u28FF\u28FF\u2807\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2808\u2809\u281B\u2812\u2836\u28BF\u28FF\u28FF\u28FF\u287F\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2808\u2809\u2801\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"].join(`
32
+ `)});var Wt=require("commander"),pe=p(require("crypto")),V=p(require("os")),zt=require("child_process"),Yt=require("util");K();var ee=p(require("crypto")),te=p(require("tty")),ne=p(require("fs"));var O="6820f6e91b762e645c9bf020c0d3673bb99d4a25a824880c0d548e10bb9bc7b1";K();function pn(t){return/-rc\.|-beta\./.test(t)}function we(t){return ee.createHash("sha256").update(t.trim()).digest("hex")}function Ke(t){return O==="SKIP"?!0:ee.timingSafeEqual(Buffer.from(we(t)),Buffer.from(O))}function gn(t){return new Promise((e,n)=>{let r=ne.openSync("/dev/tty","r+"),o=new te.ReadStream(r),s=new te.WriteStream(r),a=()=>{try{o.destroy()}catch{}try{s.destroy()}catch{}try{ne.closeSync(r)}catch{}};s.write(t),o.setRawMode(!0),o.resume(),o.setEncoding("utf8");let i="";o.on("data",l=>{l==="\r"||l===`
33
33
  `?(s.write(`
34
34
  `),a(),e(i)):l===""?(s.write(`
35
- `),a(),n(new Error("Cancelled"))):l==="\x7F"||l==="\b"?i.length>0&&(i=i.slice(0,-1),s.write("\b \b")):(i+=l,s.write("\u2022"))})})}var gn=`
35
+ `),a(),n(new Error("Cancelled"))):l==="\x7F"||l==="\b"?i.length>0&&(i=i.slice(0,-1),s.write("\b \b")):(i+=l,s.write("\u2022"))})})}var fn=`
36
36
  \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557
37
37
  \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
38
38
  \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551
@@ -41,23 +41,23 @@ ${l}`},{role:"assistant",content:"Understood. I have context from our previous c
41
41
  \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D
42
42
 
43
43
  This is a Release Candidate build. Access is restricted to Visa employees.
44
- `;async function Ke(t={}){let e=t.version??_e().version;if(!mn(e))return;let n=process.env.VISA_RC_CODE;if(n&&Ve(n)){await g.saveRcAccessToken(we(n));return}if(t.isMcp??!1){let a=await g.getRcAccessToken();if(a&&(O==="SKIP"||a===O))return;process.stderr.write(`[visa-cli] RC build requires access. Run: visa-cli setup
45
- `),process.exit(1)}let o=await g.getRcAccessToken();if(o&&(O==="SKIP"||o===O))return;console.log(gn);let s=3;for(let a=1;a<=s;a++){let i;try{i=await pn(" Enter RC access code: ")}catch{process.exit(1)}if(Ve(i)){await g.saveRcAccessToken(we(i)),console.log(`
44
+ `;async function Be(t={}){let e=t.version??_e().version;if(!pn(e))return;let n=process.env.VISA_RC_CODE;if(n&&Ke(n)){await g.saveRcAccessToken(we(n));return}if(t.isMcp??!1){let a=await g.getRcAccessToken();if(a&&(O==="SKIP"||a===O))return;process.stderr.write(`[visa-cli] RC build requires access. Run: visa-cli setup
45
+ `),process.exit(1)}let o=await g.getRcAccessToken();if(o&&(O==="SKIP"||o===O))return;console.log(fn);let s=3;for(let a=1;a<=s;a++){let i;try{i=await gn(" Enter RC access code: ")}catch{process.exit(1)}if(Ke(i)){await g.saveRcAccessToken(we(i)),console.log(`
46
46
  Access granted. Welcome.
47
47
  `);return}a<s&&console.log(`
48
48
  Invalid code. ${s-a} attempt(s) remaining.
49
49
  `)}console.log(`
50
50
  Invalid code. Contact your team lead.
51
- `),process.exit(1)}var Be=require("child_process");function fn(t=process.env,e=process.platform){return t.VISA_CLI_NO_BROWSER==="1"||t.VISA_CLI_NO_BROWSER==="true"?{headless:!0,reason:"VISA_CLI_NO_BROWSER is set"}:t.CI==="true"||t.CI==="1"?{headless:!0,reason:"CI environment detected"}:t.SSH_CONNECTION||t.SSH_TTY?{headless:!0,reason:"SSH session detected"}:e==="linux"&&!t.DISPLAY&&!t.WAYLAND_DISPLAY?{headless:!0,reason:"Linux with no $DISPLAY or $WAYLAND_DISPLAY"}:{headless:!1}}function hn(t){let n=t.length+4;return[`\u250C${"\u2500".repeat(n)}\u2510`,`\u2502${" ".repeat(2)}${t}${" ".repeat(2)}\u2502`,`\u2514${"\u2500".repeat(n)}\u2518`].join(`
52
- `)}function yn(t,e=process.platform){return e==="darwin"?{cmd:"open",args:[t]}:e==="win32"?{cmd:"cmd",args:["/c","start","",t]}:e==="linux"?{cmd:"xdg-open",args:[t]}:null}async function We(t,e={}){let n=e.log??(l=>console.log(l)),r=e.env??process.env,o=e.platform??process.platform,s=e.spawn??((l,c,u)=>{(0,Be.execFile)(l,c,_=>u(_))});n(""),n(" Sign in to Visa CLI by opening this URL in your browser:"),n("");for(let l of hn(t).split(`
53
- `))n(` ${l}`);n("");let a=fn(r,o);if(a.headless){n(` (${a.reason} \u2014 skipping browser auto-open.)`),n(" Open the URL above on any device with a browser. The CLI will"),n(" continue waiting for you to complete sign-in."),n("");return}let i=yn(t,o);if(!i){n(` No known browser-open command for platform "${o}".`),n(" Open the URL above manually to continue."),n("");return}await new Promise(l=>{s(i.cmd,i.args,c=>{c?(n(` Could not open browser automatically (${c.message}).`),n(" Open the URL above manually to continue."),n("")):(n(" Opened browser. Waiting for you to sign in..."),n("")),l()})})}oe();Te();be();function dt(t,e=process.stderr){if(re()||!t?.updateAvailable)return!1;let{message:n}=t.updateAvailable;return n?(e.write(`
51
+ `),process.exit(1)}var Ge=require("child_process");function hn(t=process.env,e=process.platform){return t.VISA_CLI_NO_BROWSER==="1"||t.VISA_CLI_NO_BROWSER==="true"?{headless:!0,reason:"VISA_CLI_NO_BROWSER is set"}:t.CI==="true"||t.CI==="1"?{headless:!0,reason:"CI environment detected"}:t.SSH_CONNECTION||t.SSH_TTY?{headless:!0,reason:"SSH session detected"}:e==="linux"&&!t.DISPLAY&&!t.WAYLAND_DISPLAY?{headless:!0,reason:"Linux with no $DISPLAY or $WAYLAND_DISPLAY"}:{headless:!1}}function yn(t){let n=t.length+4;return[`\u250C${"\u2500".repeat(n)}\u2510`,`\u2502${" ".repeat(2)}${t}${" ".repeat(2)}\u2502`,`\u2514${"\u2500".repeat(n)}\u2518`].join(`
52
+ `)}function _n(t,e=process.platform){return e==="darwin"?{cmd:"open",args:[t]}:e==="win32"?{cmd:"cmd",args:["/c","start","",t]}:e==="linux"?{cmd:"xdg-open",args:[t]}:null}async function We(t,e={}){let n=e.log??(l=>console.log(l)),r=e.env??process.env,o=e.platform??process.platform,s=e.spawn??((l,c,u)=>{(0,Ge.execFile)(l,c,_=>u(_))});n(""),n(" Sign in to Visa CLI by opening this URL in your browser:"),n("");for(let l of yn(t).split(`
53
+ `))n(` ${l}`);n("");let a=hn(r,o);if(a.headless){n(` (${a.reason} \u2014 skipping browser auto-open.)`),n(" Open the URL above on any device with a browser. The CLI will"),n(" continue waiting for you to complete sign-in."),n("");return}let i=_n(t,o);if(!i){n(` No known browser-open command for platform "${o}".`),n(" Open the URL above manually to continue."),n("");return}await new Promise(l=>{s(i.cmd,i.args,c=>{c?(n(` Could not open browser automatically (${c.message}).`),n(" Open the URL above manually to continue."),n("")):(n(" Opened browser. Waiting for you to sign in..."),n("")),l()})})}oe();ke();be();function mt(t,e=process.stderr){if(re()||!t?.updateAvailable)return!1;let{message:n}=t.updateAvailable;return n?(e.write(`
54
54
  \x1B[33m\u2191 ${n}\x1B[0m
55
- `),!0):!1}var b=class extends Error{constructor(e){super(e),this.name="PayValidationError"}},mt=["GET","POST"];function pt(t){let e;try{e=new URL(t)}catch{throw new b(`Invalid URL: ${t}. Expected a fully-qualified http(s) URL.`)}if(e.protocol!=="http:"&&e.protocol!=="https:")throw new b(`Unsupported URL scheme "${e.protocol}". Only http and https are allowed.`);return e}function gt(t){let e=(t??"GET").toUpperCase();if(!mt.includes(e))throw new b(`Unsupported HTTP method "${t}". Supported: ${mt.join(", ")}.`);return e}function ft(t){if(t!==void 0){try{JSON.parse(t)}catch(e){throw new b(`--body is not valid JSON: ${e?.message??"parse error"}`)}return t}}function ht(t){if(!t||typeof t!="object")throw new b("Merchant returned no payment preview.");let e=t;if(typeof e.amount!="number"||!Number.isFinite(e.amount)||e.amount<=0)throw new b("Could not determine payment amount from merchant.");if(typeof e.merchantName!="string"||e.merchantName.trim().length===0)throw new b("Merchant returned an empty merchant name.");if(e.merchantName.length>200)throw new b(`Merchant name too long (${e.merchantName.length} chars).`);if(typeof e.currency!="string"||e.currency.trim().length===0)throw new b("Merchant returned an empty currency.");if(e.currency.length>10)throw new b(`Currency code too long (${e.currency.length} chars).`);return{amount:e.amount,currency:e.currency,merchantName:e.merchantName}}var m=p(require("fs")),d=p(require("path")),yt=p(require("os")),y=yt.homedir(),E=[{id:"claude",displayName:"Claude Code",globalConfigPath:d.join(y,".claude.json"),configKey:"mcpServers",detectPaths:[d.join(y,".claude.json")],postInstallHint:"Restart Claude Code or run /mcp to connect."},{id:"claude-desktop",displayName:"Claude Desktop",globalConfigPath:d.join(y,"Library","Application Support","Claude","claude_desktop_config.json"),configKey:"mcpServers",detectPaths:[d.join(y,"Library","Application Support","Claude")],postInstallHint:"Restart the Claude desktop app to connect."},{id:"cursor",displayName:"Cursor",globalConfigPath:d.join(y,".cursor","mcp.json"),configKey:"mcpServers",detectPaths:[d.join(y,".cursor")],postInstallHint:"Restart Cursor to connect."},{id:"windsurf",displayName:"Windsurf",globalConfigPath:d.join(y,".codeium","windsurf","mcp_config.json"),configKey:"mcpServers",detectPaths:[d.join(y,".codeium","windsurf")],postInstallHint:"Restart Windsurf to connect."},{id:"cline",displayName:"Cline",globalConfigPath:d.join(y,".vscode","mcp.json"),configKey:"mcpServers",detectPaths:[d.join(y,".vscode","extensions","saoudrizwan.claude-dev-*")],postInstallHint:"Restart VS Code to connect."},{id:"roo-code",displayName:"Roo Code",globalConfigPath:d.join(y,".config","Roo","mcp_settings.json"),configKey:"mcpServers",detectPaths:[d.join(y,".vscode","extensions","RooVeterinaryInc.roo-cline-*")],postInstallHint:"Restart VS Code to connect."},{id:"copilot",displayName:"VS Code Copilot",globalConfigPath:d.join(y,".vscode","mcp.json"),configKey:"servers",detectPaths:[d.join(y,".vscode")],postInstallHint:"Restart VS Code to connect."},{id:"zed",displayName:"Zed",globalConfigPath:d.join(y,".config","zed","settings.json"),configKey:"context_servers",detectPaths:[d.join(y,".config","zed")],postInstallHint:"Restart Zed to connect.",buildEntry:t=>({source:"custom",...t})}];function Ae(t){return E.find(e=>e.id===t)}function W(t){return t.detectPaths.some(e=>{if(e.includes("*")){let n=d.dirname(e),r=d.basename(e).replaceAll("*","");if(!m.existsSync(n))return!1;try{return m.readdirSync(n).some(o=>o.startsWith(r))}catch{return!1}}return m.existsSync(e)})}function _t(){return{command:"node",args:[d.resolve(__dirname,"mcp-server/index.js")]}}function G(t,e="global"){let n=e==="project"?d.join(process.cwd(),".mcp.json"):t.globalConfigPath,r=d.dirname(n);m.existsSync(r)||m.mkdirSync(r,{recursive:!0});let o={};if(m.existsSync(n))try{o=JSON.parse(m.readFileSync(n,"utf-8"))}catch{o={}}o[t.configKey]=o[t.configKey]||{};let s=_t();return o[t.configKey]["visa-cli"]=t.buildEntry?t.buildEntry(s):s,m.writeFileSync(n,JSON.stringify(o,null,2)+`
55
+ `),!0):!1}var b=class extends Error{constructor(e){super(e),this.name="PayValidationError"}},pt=["GET","POST"];function gt(t){let e;try{e=new URL(t)}catch{throw new b(`Invalid URL: ${t}. Expected a fully-qualified http(s) URL.`)}if(e.protocol!=="http:"&&e.protocol!=="https:")throw new b(`Unsupported URL scheme "${e.protocol}". Only http and https are allowed.`);return e}function ft(t){let e=(t??"GET").toUpperCase();if(!pt.includes(e))throw new b(`Unsupported HTTP method "${t}". Supported: ${pt.join(", ")}.`);return e}function ht(t){if(t!==void 0){try{JSON.parse(t)}catch(e){throw new b(`--body is not valid JSON: ${e?.message??"parse error"}`)}return t}}function yt(t){if(!t||typeof t!="object")throw new b("Merchant returned no payment preview.");let e=t;if(typeof e.amount!="number"||!Number.isFinite(e.amount)||e.amount<=0)throw new b("Could not determine payment amount from merchant.");if(typeof e.merchantName!="string"||e.merchantName.trim().length===0)throw new b("Merchant returned an empty merchant name.");if(e.merchantName.length>200)throw new b(`Merchant name too long (${e.merchantName.length} chars).`);if(typeof e.currency!="string"||e.currency.trim().length===0)throw new b("Merchant returned an empty currency.");if(e.currency.length>10)throw new b(`Currency code too long (${e.currency.length} chars).`);return{amount:e.amount,currency:e.currency,merchantName:e.merchantName}}var m=p(require("fs")),d=p(require("path")),_t=p(require("os")),y=_t.homedir(),P=[{id:"claude",displayName:"Claude Code",globalConfigPath:d.join(y,".claude.json"),configKey:"mcpServers",detectPaths:[d.join(y,".claude.json")],postInstallHint:"Restart Claude Code or run /mcp to connect."},{id:"claude-desktop",displayName:"Claude Desktop",globalConfigPath:d.join(y,"Library","Application Support","Claude","claude_desktop_config.json"),configKey:"mcpServers",detectPaths:[d.join(y,"Library","Application Support","Claude")],postInstallHint:"Restart the Claude desktop app to connect."},{id:"cursor",displayName:"Cursor",globalConfigPath:d.join(y,".cursor","mcp.json"),configKey:"mcpServers",detectPaths:[d.join(y,".cursor")],postInstallHint:"Restart Cursor to connect."},{id:"windsurf",displayName:"Windsurf",globalConfigPath:d.join(y,".codeium","windsurf","mcp_config.json"),configKey:"mcpServers",detectPaths:[d.join(y,".codeium","windsurf")],postInstallHint:"Restart Windsurf to connect."},{id:"cline",displayName:"Cline",globalConfigPath:d.join(y,".vscode","mcp.json"),configKey:"mcpServers",detectPaths:[d.join(y,".vscode","extensions","saoudrizwan.claude-dev-*")],postInstallHint:"Restart VS Code to connect."},{id:"roo-code",displayName:"Roo Code",globalConfigPath:d.join(y,".config","Roo","mcp_settings.json"),configKey:"mcpServers",detectPaths:[d.join(y,".vscode","extensions","RooVeterinaryInc.roo-cline-*")],postInstallHint:"Restart VS Code to connect."},{id:"copilot",displayName:"VS Code Copilot",globalConfigPath:d.join(y,".vscode","mcp.json"),configKey:"servers",detectPaths:[d.join(y,".vscode")],postInstallHint:"Restart VS Code to connect."},{id:"zed",displayName:"Zed",globalConfigPath:d.join(y,".config","zed","settings.json"),configKey:"context_servers",detectPaths:[d.join(y,".config","zed")],postInstallHint:"Restart Zed to connect.",buildEntry:t=>({source:"custom",...t})}];function Ie(t){return P.find(e=>e.id===t)}function G(t){return t.detectPaths.some(e=>{if(e.includes("*")){let n=d.dirname(e),r=d.basename(e).replaceAll("*","");if(!m.existsSync(n))return!1;try{return m.readdirSync(n).some(o=>o.startsWith(r))}catch{return!1}}return m.existsSync(e)})}function wt(){return{command:"node",args:[d.resolve(__dirname,"mcp-server/index.js")]}}function W(t,e="global"){let n=e==="project"?d.join(process.cwd(),".mcp.json"):t.globalConfigPath,r=d.dirname(n);m.existsSync(r)||m.mkdirSync(r,{recursive:!0});let o={};if(m.existsSync(n))try{o=JSON.parse(m.readFileSync(n,"utf-8"))}catch{o={}}o[t.configKey]=o[t.configKey]||{};let s=wt();return o[t.configKey]["visa-cli"]=t.buildEntry?t.buildEntry(s):s,m.writeFileSync(n,JSON.stringify(o,null,2)+`
56
56
  `),{installed:!0,configPath:n,message:t.postInstallHint}}function Re(t,e="global"){let n=e==="project"?d.join(process.cwd(),".mcp.json"):t.globalConfigPath;if(!m.existsSync(n))return{removed:!1,configPath:n};let r;try{r=JSON.parse(m.readFileSync(n,"utf-8"))}catch{return{removed:!1,configPath:n}}let o=r[t.configKey];return!o||!o["visa-cli"]?{removed:!1,configPath:n}:(delete o["visa-cli"],m.writeFileSync(n,JSON.stringify(r,null,2)+`
57
- `),{removed:!0,configPath:n})}function wt(t,e="global"){let n=e==="project"?d.join(process.cwd(),".mcp.json"):t.globalConfigPath;if(!m.existsSync(n))return!1;try{return!!JSON.parse(m.readFileSync(n,"utf-8"))?.[t.configKey]?.["visa-cli"]}catch{return!1}}function Cn(t){if(!t||typeof t!="object")return;let e=t;if(e.command!=="node"||!Array.isArray(e.args)||e.args.length===0)return;let n=e.args[e.args.length-1];if(!(typeof n!="string"||n.length===0))return n}function $n(t,e){if(t===e)return!0;let n=d.resolve(t),r=d.resolve(e);if(n===r)return!0;try{let o=m.realpathSync(n),s=m.realpathSync(r);return o===s}catch{return!1}}function z(){let t=_t(),e=t.args[t.args.length-1],n=[];for(let r of E){let o=r.globalConfigPath;if(!m.existsSync(o))continue;let s;try{s=JSON.parse(m.readFileSync(o,"utf-8"))}catch{continue}let a=s?.[r.configKey]?.["visa-cli"];if(!a)continue;let i=Cn(a);if(!i||$n(i,e))continue;let l=m.existsSync(i)?"mismatch":"missing";n.push({client:r,configPath:o,currentPath:i,expectedPath:e,staleReason:l})}return n}function Ie(t){return{configPath:G(t.client,"global").configPath}}var Dn=(0,zt.promisify)(Gt.execFile);function qn(t){let e=H.homedir(),n=o=>o.replace(e,"~"),r=t.staleReason==="missing"?"path missing on disk":"path mismatch";return` \u2022 ${t.client.displayName} (${n(t.configPath)})
58
- ${r}: ${n(t.currentPath)}`}function Yt(t,e){if(t.length===0){console.log(`${e} \u2713 All MCP client configs are up to date.`);return}console.log(`${e} Found ${t.length} stale MCP config ${t.length===1?"entry":"entries"}:`);for(let n of t)console.log(qn(n))}var P=new Wt.Command,me=null;function ge(){return me=new k(()=>g.getSessionToken()),me}P.name("visa-cli").description("Visa CLI - AI payment orchestration").version(_e().version);P.hook("preAction",async()=>{await Ke()});P.command("setup").description("Register MCP server, authenticate, and generate attestation key").option("--check","Scan MCP client configs for stale visa-cli entries and exit without making changes").action(async t=>{try{if(t.check){let c=z();Yt(c,"MCP config check:"),c.length>0&&(console.log("\nRun `visa-cli setup` (or `visa-cli install --repair`) to rewrite these entries."),process.exit(1));return}console.log("Step 1: Registering MCP server...");let e=z(),n=new Map(e.map(c=>[c.client.id,c])),r=new Set;for(let c of E)if(W(c)){let u=G(c),_=n.get(c.id),F=_?` \u2014 repaired stale ${_.staleReason} entry`:"";console.log(` \u2713 ${c.displayName} (${u.configPath.replace(H.homedir(),"~")})${F}`),_&&r.add(c.id)}let o=e.filter(c=>!r.has(c.client.id));for(let c of o)Ie(c),console.log(` \u2713 ${c.client.displayName} (${c.configPath.replace(H.homedir(),"~")}) \u2014 repaired stale ${c.staleReason} entry`);let s=r.size+o.length;console.log(s===0?" \u2713 MCP config verified \u2014 nothing to repair.":` \u2713 Repaired ${s} stale MCP config ${s===1?"entry":"entries"}.`),console.log(`
59
- Step 2: Checking authentication...`);let a=await g.getSessionToken();if(a?console.log(" Already authenticated."):(console.log(" No session found. Opening browser for GitHub login..."),a=await new Promise(async(c,u)=>{let _=pe.randomBytes(16).toString("hex"),F=`https://auth.visacli.sh/login?state=${_}`;await We(F);let x=3e4,Y=300*1e3,V=Date.now()+Y;for(;Date.now()<V;)try{let A=await globalThis.fetch("https://auth.visacli.sh/v1/auth-status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:_,timeout:x}),signal:AbortSignal.timeout(x+5e3)});if(!A.ok)continue;let S=await A.json();if(S.status==="pending")continue;if(S.status==="expired"){u(new Error("Session expired. Please run setup again."));return}if(S.status==="complete"&&S.sessionToken){console.log(` Signed in as ${S.user}.`),c(S.sessionToken);return}}catch{}u(new Error("Login timed out after 5 minutes. Please run setup again."))}),await g.saveSessionToken(a),console.log(" Session token saved.")),console.log(`
60
- Step 3: Setting up authentication...`),!U())console.log(" Not macOS \u2014 skipping biometric setup.");else{try{await Dn("clang",["--version"])}catch{console.error(" Xcode Command Line Tools are required for payment authentication."),console.error(" Install them by running: xcode-select --install"),console.error(" Then re-run: visa-cli setup"),process.exit(1)}try{let c=await lt();console.log(" Attestation key generated."),await ge().registerAttestationKey(c),console.log(" Attestation key registered with server.")}catch(c){console.log(` Skipped: ${c.message}`)}}let i="\x1B[1m",l="\x1B[0m";console.log(`
57
+ `),{removed:!0,configPath:n})}function bt(t,e="global"){let n=e==="project"?d.join(process.cwd(),".mcp.json"):t.globalConfigPath;if(!m.existsSync(n))return!1;try{return!!JSON.parse(m.readFileSync(n,"utf-8"))?.[t.configKey]?.["visa-cli"]}catch{return!1}}function $n(t){if(!t||typeof t!="object")return;let e=t;if(e.command!=="node"||!Array.isArray(e.args)||e.args.length===0)return;let n=e.args[e.args.length-1];if(!(typeof n!="string"||n.length===0))return n}function Tn(t,e){if(t===e)return!0;let n=d.resolve(t),r=d.resolve(e);if(n===r)return!0;try{let o=m.realpathSync(n),s=m.realpathSync(r);return o===s}catch{return!1}}function z(){let t=wt(),e=t.args[t.args.length-1],n=[];for(let r of P){let o=r.globalConfigPath;if(!m.existsSync(o))continue;let s;try{s=JSON.parse(m.readFileSync(o,"utf-8"))}catch{continue}let a=s?.[r.configKey]?.["visa-cli"];if(!a)continue;let i=$n(a);if(!i||Tn(i,e))continue;let l=m.existsSync(i)?"mismatch":"missing";n.push({client:r,configPath:o,currentPath:i,expectedPath:e,staleReason:l})}return n}function Ae(t){return{configPath:W(t.client,"global").configPath}}var Vn=(0,Yt.promisify)(zt.execFile);function Hn(t){let e=V.homedir(),n=o=>o.replace(e,"~"),r=t.staleReason==="missing"?"path missing on disk":"path mismatch";return` \u2022 ${t.client.displayName} (${n(t.configPath)})
58
+ ${r}: ${n(t.currentPath)}`}function Jt(t,e){if(t.length===0){console.log(`${e} \u2713 All MCP client configs are up to date.`);return}console.log(`${e} Found ${t.length} stale MCP config ${t.length===1?"entry":"entries"}:`);for(let n of t)console.log(Hn(n))}var x=new Wt.Command,me=null;function ge(){return me=new T(()=>g.getSessionToken()),me}x.name("visa-cli").description("Visa CLI - AI payment orchestration").version(_e().version);x.hook("preAction",async()=>{await Be()});x.command("setup").description("Register MCP server, authenticate, and generate attestation key").option("--check","Scan MCP client configs for stale visa-cli entries and exit without making changes").action(async t=>{try{if(t.check){let c=z();Jt(c,"MCP config check:"),c.length>0&&(console.log("\nRun `visa-cli setup` (or `visa-cli install --repair`) to rewrite these entries."),process.exit(1));return}console.log("Step 1: Registering MCP server...");let e=z(),n=new Map(e.map(c=>[c.client.id,c])),r=new Set;for(let c of P)if(G(c)){let u=W(c),_=n.get(c.id),q=_?` \u2014 repaired stale ${_.staleReason} entry`:"";console.log(` \u2713 ${c.displayName} (${u.configPath.replace(V.homedir(),"~")})${q}`),_&&r.add(c.id)}let o=e.filter(c=>!r.has(c.client.id));for(let c of o)Ae(c),console.log(` \u2713 ${c.client.displayName} (${c.configPath.replace(V.homedir(),"~")}) \u2014 repaired stale ${c.staleReason} entry`);let s=r.size+o.length;console.log(s===0?" \u2713 MCP config verified \u2014 nothing to repair.":` \u2713 Repaired ${s} stale MCP config ${s===1?"entry":"entries"}.`),console.log(`
59
+ Step 2: Checking authentication...`);let a=await g.getSessionToken();if(a?console.log(" Already authenticated."):(console.log(" No session found. Opening browser for GitHub login..."),a=await new Promise(async(c,u)=>{let _=pe.randomBytes(16).toString("hex"),q=`https://auth.visacli.sh/login?state=${_}`;await We(q);let E=3e4,Y=300*1e3,H=Date.now()+Y;for(;Date.now()<H;)try{let I=await globalThis.fetch("https://auth.visacli.sh/v1/auth-status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:_,timeout:E}),signal:AbortSignal.timeout(E+5e3)});if(!I.ok)continue;let S=await I.json();if(S.status==="pending")continue;if(S.status==="expired"){u(new Error("Session expired. Please run setup again."));return}if(S.status==="complete"&&S.sessionToken){console.log(` Signed in as ${S.user}.`),c(S.sessionToken);return}}catch{}u(new Error("Login timed out after 5 minutes. Please run setup again."))}),await g.saveSessionToken(a),console.log(" Session token saved.")),console.log(`
60
+ Step 3: Setting up authentication...`),!U())console.log(" Not macOS \u2014 skipping biometric setup.");else{try{await Vn("clang",["--version"])}catch{console.error(" Xcode Command Line Tools are required for payment authentication."),console.error(" Install them by running: xcode-select --install"),console.error(" Then re-run: visa-cli setup"),process.exit(1)}try{let c=await ut();console.log(" Attestation key generated."),await ge().registerAttestationKey(c),console.log(" Attestation key registered with server.")}catch(c){console.log(` Skipped: ${c.message}`)}}let i="\x1B[1m",l="\x1B[0m";console.log(`
61
61
  \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557
62
62
  \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
63
63
  \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551
@@ -74,17 +74,17 @@ Step 3: Setting up authentication...`),!U())console.log(" Not macOS \u2014 ski
74
74
 
75
75
  ${i}Verify:${l} visa-cli status
76
76
  ${i}Docs:${l} https://visacli.sh
77
- `)}catch(e){console.error("Error:",e.message),process.exit(1)}});P.command("install [client]").description("Register MCP server with an AI client (claude, cursor, windsurf, cline, zed, ...)").option("--all","Install for all detected clients").option("--list","Show supported clients and install status").option("--check","Scan MCP client configs for stale visa-cli entries and exit without making changes").option("--repair","Repair stale MCP client configs without re-running the full setup flow").option("--scope <scope>","Install scope: global or project","global").action(async(t,e)=>{try{if(e.check){let s=z();Yt(s,"MCP config check:"),s.length>0&&process.exit(1);return}if(e.repair){let s=z();if(s.length===0){console.log("\u2713 MCP config verified \u2014 nothing to repair.");return}for(let a of s)Ie(a),console.log(` \u2713 ${a.client.displayName} (${a.configPath.replace(H.homedir(),"~")}) \u2014 repaired stale ${a.staleReason} entry`);console.log(`
77
+ `)}catch(e){console.error("Error:",e.message),process.exit(1)}});x.command("install [client]").description("Register MCP server with an AI client (claude, cursor, windsurf, cline, zed, ...)").option("--all","Install for all detected clients").option("--list","Show supported clients and install status").option("--check","Scan MCP client configs for stale visa-cli entries and exit without making changes").option("--repair","Repair stale MCP client configs without re-running the full setup flow").option("--scope <scope>","Install scope: global or project","global").action(async(t,e)=>{try{if(e.check){let s=z();Jt(s,"MCP config check:"),s.length>0&&process.exit(1);return}if(e.repair){let s=z();if(s.length===0){console.log("\u2713 MCP config verified \u2014 nothing to repair.");return}for(let a of s)Ae(a),console.log(` \u2713 ${a.client.displayName} (${a.configPath.replace(V.homedir(),"~")}) \u2014 repaired stale ${a.staleReason} entry`);console.log(`
78
78
  Repaired ${s.length} stale MCP config ${s.length===1?"entry":"entries"}.`);return}if(e.list){console.log(`
79
79
  \x1B[1mSupported MCP Clients\x1B[0m
80
- `),console.log(` ${"Client".padEnd(18)} ${"Detected".padEnd(10)} ${"Installed".padEnd(11)} Config Path`),console.log(` ${"\u2500".repeat(18)} ${"\u2500".repeat(10)} ${"\u2500".repeat(11)} ${"\u2500".repeat(40)}`);for(let i of E){let l=W(i),c=wt(i),u=l?"Yes":"No",_=c?"Yes":"No",F=i.globalConfigPath.replace(H.homedir(),"~");console.log(` ${i.displayName.padEnd(18)} ${u.padEnd(10)} ${_.padEnd(11)} ${F}`)}console.log("");return}let n=e.scope==="project"?"project":"global";if(e.all){let s=[],a=[];for(let i of E){if(!W(i)){a.push(i.displayName);continue}G(i,n),s.push(i.displayName)}s.length>0&&console.log(`Installed for: ${s.join(", ")}.`),a.length>0&&console.log(`Skipped: ${a.map(i=>`${i} (not detected)`).join(", ")}.`),s.length===0&&a.length===0&&console.log("No supported clients found.");return}t||(console.error("Usage: visa-cli install <client>"),console.error(" visa-cli install --all"),console.error(" visa-cli install --list"),console.error(`
81
- Supported clients: ${E.map(s=>s.id).join(", ")}`),process.exit(1));let r=Ae(t);r||(console.error(`Unknown client: ${t}`),console.error(`Supported clients: ${E.map(s=>s.id).join(", ")}`),process.exit(1)),n==="global"&&!W(r)&&(console.error(`${r.displayName} not detected on this machine.`),console.error(`Expected: ${r.detectPaths.join(", ")}`),process.exit(1));let o=G(r,n);console.log(`Registered visa-cli MCP server in ${o.configPath}`),console.log(o.message)}catch(n){console.error("Error:",n.message),process.exit(1)}});P.command("uninstall [client]").description("Remove MCP server from an AI client").option("--all","Remove from all clients").option("--scope <scope>","Uninstall scope: global or project","global").action(async(t,e)=>{try{let n=e.scope==="project"?"project":"global";if(e.all){let s=[];for(let a of E)Re(a,n).removed&&s.push(a.displayName);s.length>0?console.log(`Removed visa-cli from: ${s.join(", ")}.`):console.log("visa-cli was not installed in any client.");return}t||(console.error("Usage: visa-cli uninstall <client>"),console.error(" visa-cli uninstall --all"),console.error(`
82
- Supported clients: ${E.map(s=>s.id).join(", ")}`),process.exit(1));let r=Ae(t);r||(console.error(`Unknown client: ${t}`),console.error(`Supported clients: ${E.map(s=>s.id).join(", ")}`),process.exit(1));let o=Re(r,n);o.removed?console.log(`Removed visa-cli from ${o.configPath}`):console.log(`visa-cli was not installed for ${r.displayName}.`)}catch(n){console.error("Error:",n.message),process.exit(1)}});P.command("pay <url>").description("Pay a merchant URL (amount auto-detected from HTTP 402 response)").option("-m, --method <method>","HTTP method (GET or POST)","GET").option("-b, --body <json>","JSON request body for POST endpoints").action(async(t,e)=>{try{pt(t);let n=gt(e.method),r=ft(e.body),o=new k(()=>g.getSessionToken());console.log(`Checking payment for ${t}...`);let s=ht(await o.paymentPreview({url:t}));console.log(` Merchant: ${s.merchantName}`),console.log(` Amount: $${s.amount.toFixed(2)} ${s.currency}`),console.log(` Rail: auto-detected
80
+ `),console.log(` ${"Client".padEnd(18)} ${"Detected".padEnd(10)} ${"Installed".padEnd(11)} Config Path`),console.log(` ${"\u2500".repeat(18)} ${"\u2500".repeat(10)} ${"\u2500".repeat(11)} ${"\u2500".repeat(40)}`);for(let i of P){let l=G(i),c=bt(i),u=l?"Yes":"No",_=c?"Yes":"No",q=i.globalConfigPath.replace(V.homedir(),"~");console.log(` ${i.displayName.padEnd(18)} ${u.padEnd(10)} ${_.padEnd(11)} ${q}`)}console.log("");return}let n=e.scope==="project"?"project":"global";if(e.all){let s=[],a=[];for(let i of P){if(!G(i)){a.push(i.displayName);continue}W(i,n),s.push(i.displayName)}s.length>0&&console.log(`Installed for: ${s.join(", ")}.`),a.length>0&&console.log(`Skipped: ${a.map(i=>`${i} (not detected)`).join(", ")}.`),s.length===0&&a.length===0&&console.log("No supported clients found.");return}t||(console.error("Usage: visa-cli install <client>"),console.error(" visa-cli install --all"),console.error(" visa-cli install --list"),console.error(`
81
+ Supported clients: ${P.map(s=>s.id).join(", ")}`),process.exit(1));let r=Ie(t);r||(console.error(`Unknown client: ${t}`),console.error(`Supported clients: ${P.map(s=>s.id).join(", ")}`),process.exit(1)),n==="global"&&!G(r)&&(console.error(`${r.displayName} not detected on this machine.`),console.error(`Expected: ${r.detectPaths.join(", ")}`),process.exit(1));let o=W(r,n);console.log(`Registered visa-cli MCP server in ${o.configPath}`),console.log(o.message)}catch(n){console.error("Error:",n.message),process.exit(1)}});x.command("uninstall [client]").description("Remove MCP server from an AI client").option("--all","Remove from all clients").option("--scope <scope>","Uninstall scope: global or project","global").action(async(t,e)=>{try{let n=e.scope==="project"?"project":"global";if(e.all){let s=[];for(let a of P)Re(a,n).removed&&s.push(a.displayName);s.length>0?console.log(`Removed visa-cli from: ${s.join(", ")}.`):console.log("visa-cli was not installed in any client.");return}t||(console.error("Usage: visa-cli uninstall <client>"),console.error(" visa-cli uninstall --all"),console.error(`
82
+ Supported clients: ${P.map(s=>s.id).join(", ")}`),process.exit(1));let r=Ie(t);r||(console.error(`Unknown client: ${t}`),console.error(`Supported clients: ${P.map(s=>s.id).join(", ")}`),process.exit(1));let o=Re(r,n);o.removed?console.log(`Removed visa-cli from ${o.configPath}`):console.log(`visa-cli was not installed for ${r.displayName}.`)}catch(n){console.error("Error:",n.message),process.exit(1)}});x.command("pay <url>").description("Pay a merchant URL (amount auto-detected from HTTP 402 response)").option("-m, --method <method>","HTTP method (GET or POST)","GET").option("-b, --body <json>","JSON request body for POST endpoints").action(async(t,e)=>{try{gt(t);let n=ft(e.method),r=ht(e.body),o=new T(()=>g.getSessionToken());console.log(`Checking payment for ${t}...`);let s=yt(await o.paymentPreview({url:t}));console.log(` Merchant: ${s.merchantName}`),console.log(` Amount: $${s.amount.toFixed(2)} ${s.currency}`),console.log(` Rail: auto-detected
83
83
  `);let a;if(U())try{let{nonce:l}=await o.getAttestationChallenge(),c=Buffer.from(JSON.stringify({nonce:l,amount:s.amount,merchant:s.merchantName,context:t})).toString("base64");a={signature:await le(c,`pay $${s.amount.toFixed(2)} to ${s.merchantName}`),nonce:l,amount:s.amount,merchant:s.merchantName}}catch(l){console.error(`Touch ID confirmation failed: ${l?.message||"user cancelled or biometric error"}`),process.exit(1)}else console.warn("Warning: Touch ID unavailable on this system \u2014 payment will proceed without biometric attestation.");let i=await o.pay({url:t,method:n,body:r,attestation:a,idempotencyKey:pe.randomUUID()});if(i.success){if(console.log(`Payment complete: $${(i.amount??s.amount).toFixed(2)} \u2192 ${i.merchantName??s.merchantName}`),i.receipt?.urls?.length){console.log(`
84
- Result URLs:`);for(let l of i.receipt.urls)console.log(` ${l}`)}}else console.error(`Payment failed: ${i.message||"Unknown error"}`),process.exit(1)}catch(n){n instanceof b?console.error(`Error: ${n.message}`):console.error("Error:",n.message),process.exit(1)}});P.command("status").description("Check enrollment, cards, wallet, and spending controls").action(async()=>{try{let e=await ge().getStatus();if(console.log(`Visa CLI Status
84
+ Result URLs:`);for(let l of i.receipt.urls)console.log(` ${l}`)}}else console.error(`Payment failed: ${i.message||"Unknown error"}`),process.exit(1)}catch(n){n instanceof b?console.error(`Error: ${n.message}`):console.error("Error:",n.message),process.exit(1)}});x.command("status").description("Check enrollment, cards, wallet, and spending controls").action(async()=>{try{let e=await ge().getStatus();if(console.log(`Visa CLI Status
85
85
  `),console.log("Enrollment:"),console.log(` Enrolled: ${e.enrolled?"Yes":"No"}`),e.githubUser&&console.log(` GitHub: ${e.githubUser}`),console.log(` Cards: ${e.cardCount??0}`),e.cards&&e.cards.length>0){console.log(`
86
86
  Cards:`);for(let n of e.cards){let r=n.isDefault?" (default)":"",o=Number.isInteger(n.id)?`#${n.id} `:"";console.log(` ${o}${n.brand?.toUpperCase()||"CARD"} ****${n.last4}${r}`)}}if(e.spendingControls){let n=e.spendingControls;console.log(`
87
87
  Spending Controls:`),console.log(` Max per transaction: $${n.maxTransactionAmount}`),console.log(` Daily limit: $${n.dailyLimit}`),n.dailySpent!==void 0&&console.log(` Spent today: $${Number(n.dailySpent).toFixed(2)} / $${n.dailyLimit}`)}console.log(`
88
- Touch ID:`),console.log(` Available: ${U()?"Yes":"No"}`)}catch(t){console.error("Error:",t.message),process.exit(1)}});P.command("reset").description("Log out and clear all credentials").action(async()=>{try{console.log(`Resetting Visa CLI...
89
- `);try{await ge().logout(),console.log(" Server session invalidated.")}catch{console.log(" Server logout skipped (no active session).")}if(await g.clearAll(),console.log(" Keychain credentials cleared."),U())try{await ke(),console.log(" Secure Enclave key deleted.")}catch{console.log(" No Secure Enclave key to delete.")}console.log(`
90
- Reset complete.`)}catch(t){console.error("Error:",t.message),process.exit(1)}});P.command("feedback").description("Submit feedback about Visa CLI").argument("[message]","Your feedback message").action(async t=>{(!t||t.trim().length===0)&&(console.log('Usage: visa-cli feedback "your message"'),process.exit(1));try{await g.getSessionToken()||(console.error("Not logged in. Run visa-cli setup first."),process.exit(1)),await ge().feedback(t.trim()),console.log("Feedback submitted. Thanks!")}catch(e){console.error("Error:",e.message),process.exit(1)}});P.command("dove").alias("d").description("Launch Visa Dove \u2014 AI coding agent").option("--model <model>","Model to use (e.g. or-claude-sonnet, or-gpt-4o-mini)").action(async t=>{let{startClient:e}=await Promise.resolve().then(()=>(Bt(),Kt));await e({model:t.model})});P.hook("postAction",()=>{me&&dt(me.lastSignals)});P.parse();
88
+ Touch ID:`),console.log(` Available: ${U()?"Yes":"No"}`)}catch(t){console.error("Error:",t.message),process.exit(1)}});x.command("reset").description("Log out and clear all credentials").action(async()=>{try{console.log(`Resetting Visa CLI...
89
+ `);try{await ge().logout(),console.log(" Server session invalidated.")}catch{console.log(" Server logout skipped (no active session).")}if(await g.clearAll(),console.log(" Keychain credentials cleared."),U())try{await Te(),console.log(" Secure Enclave key deleted.")}catch{console.log(" No Secure Enclave key to delete.")}console.log(`
90
+ Reset complete.`)}catch(t){console.error("Error:",t.message),process.exit(1)}});x.command("feedback").description("Submit feedback about Visa CLI").argument("[message]","Your feedback message").action(async t=>{(!t||t.trim().length===0)&&(console.log('Usage: visa-cli feedback "your message"'),process.exit(1));try{await g.getSessionToken()||(console.error("Not logged in. Run visa-cli setup first."),process.exit(1)),await ge().feedback(t.trim()),console.log("Feedback submitted. Thanks!")}catch(e){console.error("Error:",e.message),process.exit(1)}});x.command("dove").alias("d").description("Launch Visa Dove \u2014 AI coding agent").option("--model <model>","Model to use (e.g. or-claude-sonnet, or-gpt-4o-mini)").action(async t=>{let{startClient:e}=await Promise.resolve().then(()=>(Gt(),Bt));await e({model:t.model})});x.hook("postAction",()=>{me&&mt(me.lastSignals)});x.parse();