@visa/cli 1.2.0-rc.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -185,4 +185,4 @@ Delete `~/.visa-mcp/catalog-cache.json` and restart the MCP server to force a fr
185
185
 
186
186
  ## Monorepo context
187
187
 
188
- Request routing (MCP vs MPP vs Studio): [docs/agents/ARCHITECTURE.md](../../docs/agents/ARCHITECTURE.md). Contributor workflow: [AGENTS.md](../../AGENTS.md), doc index: [docs/agents/README.md](../../docs/agents/README.md).
188
+ Request routing (MCP vs MPP vs Studio): [docs/agents/ARCHITECTURE.md](../../docs/agents/ARCHITECTURE.md). Branches and deploy: [docs/agents/PIPELINE.md](../../docs/agents/PIPELINE.md). Contributor workflow: [AGENTS.md](../../AGENTS.md), doc index: [docs/agents/README.md](../../docs/agents/README.md).
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var zn=Object.create;var Ue=Object.defineProperty;var Yn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var Xn=Object.getPrototypeOf,Zn=Object.prototype.hasOwnProperty;var y=(e,t)=>()=>(e&&(t=e(e=0)),t);var Qn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),er=(e,t)=>{for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})},tr=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Jn(t))!Zn.call(e,o)&&o!==n&&Ue(e,o,{get:()=>t[o],enumerable:!(r=Yn(t,o))||r.enumerable});return e};var p=(e,t,n)=>(n=e!=null?zn(Xn(e)):{},tr(t||!e||!e.__esModule?Ue(n,"default",{value:e,enumerable:!0}):n,e));async function rr(){try{let{stdout:e}=await M("security",["find-generic-password","-s",C,"-a",U,"-w"],{timeout:5e3});return e.trim()||null}catch{return null}}async function or(e){try{try{await M("security",["delete-generic-password","-s",C,"-a",U],{timeout:5e3})}catch{}return await M("security",["add-generic-password","-s",C,"-a",U,"-w",e],{timeout:5e3}),!0}catch{return!1}}async function sr(){try{await M("security",["delete-generic-password","-s",C,"-a",U],{timeout:5e3})}catch{}}async function ir(){if(!Ve())return null;try{let{stdout:e}=await M("secret-tool",["lookup","service",C,"account",U],{timeout:5e3});return e.trim()||null}catch{return null}}async function ar(e){if(!Ve())return!1;try{let t=(0,ge.execFile)("secret-tool",["store","--label",`${C} ${U}`,"service",C,"account",U]);return t.stdin?(t.stdin.write(e),t.stdin.end(),await Promise.race([new Promise((n,r)=>{t.on("exit",o=>o===0?n():r(new Error(`secret-tool exited ${o}`))),t.on("error",r)}),new Promise((n,r)=>setTimeout(()=>{t.kill(),r(new Error("secret-tool timed out"))},nr))]),!0):!1}catch{return!1}}async function cr(){if(Ve())try{await M("secret-tool",["clear","service",C,"account",U],{timeout:5e3})}catch{}}function Ve(){return!!process.env.DBUS_SESSION_BUS_ADDRESS}async function lr(){try{let{stdout:e}=await M("security",["find-generic-password","-s",C,"-a",pe,"-w"],{timeout:5e3});return e.trim()||null}catch{return null}}async function ur(e){try{try{await M("security",["delete-generic-password","-s",C,"-a",pe],{timeout:5e3})}catch{}await M("security",["add-generic-password","-s",C,"-a",pe,"-w",e],{timeout:5e3})}catch{}}async function dr(){try{await M("security",["delete-generic-password","-s",C,"-a",pe],{timeout:5e3})}catch{}}function je(){try{return D.readFileSync(me,"utf-8").trim()||null}catch{return null}}function ft(e){D.mkdirSync(qe,{recursive:!0,mode:448}),D.writeFileSync(me,e,{mode:384}),process.platform==="win32"&&mr(me)}function He(){try{D.unlinkSync(me)}catch{}}function mr(e){try{let t=fe.userInfo().username;(0,ge.execFile)("icacls",[e,"/inheritance:r","/grant:r",`${t}:F`],{timeout:5e3},n=>{n&&console.error(`[visa-cli] icacls ACL restriction failed: ${n.message}`)})}catch(t){console.error(`[visa-cli] Failed to invoke icacls: ${t instanceof Error?t.message:String(t)}`)}}function De(){switch(process.platform){case"darwin":return{get:rr,store:or,delete:sr};case"linux":return{get:ir,store:ar,delete:cr};default:return{get:async()=>je(),store:async e=>{try{return ft(e),!0}catch{return!1}},delete:async()=>He()}}}var ge,gt,D,fe,Fe,M,qe,me,C,U,pe,nr,_,ne=y(()=>{"use strict";ge=require("child_process"),gt=require("util"),D=p(require("fs")),fe=p(require("os")),Fe=p(require("path")),M=(0,gt.promisify)(ge.execFile),qe=Fe.join(fe.homedir(),".visa-mcp"),me=Fe.join(qe,"session-token"),C="visa-cli",U="session-token",pe="rc-access",nr=5e3;_=class{static async getSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN==="true")return Promise.resolve("mock-session-token-for-testing");let t=De(),n=await t.get();if(n)return n;let r=je();return r?(await t.store(r),r):null}static async saveSessionToken(t){if(process.env.VISA_MOCK_KEYCHAIN==="true")return;let n=De();if(await n.store(t)){if(await n.get()===t){He();return}await n.delete()}if(ft(t),je()!==t)throw new Error("Failed to persist session token. "+(process.platform==="darwin"?'Check Keychain Access permissions for "visa-cli".':`Ensure ${qe} is writable.`))}static async getRcAccessToken(){return process.env.VISA_MOCK_KEYCHAIN==="true"?"mock-rc-token-for-testing":lr()}static async saveRcAccessToken(t){process.env.VISA_MOCK_KEYCHAIN!=="true"&&await ur(t)}static async deleteSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN==="true")return;await De().delete(),He()}static async clearAll(){await this.deleteSessionToken(),await dr()}}});var Be=Qn((po,pr)=>{pr.exports={name:"@visa/cli",version:"1.2.0-rc.1",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":"^25.6.0","@typescript-eslint/eslint-plugin":"^8.59.0","@typescript-eslint/parser":"^8.59.0","@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.3","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"]}});function St(e=process.env,t=process.platform){return e.VISA_CLI_NO_BROWSER==="1"||e.VISA_CLI_NO_BROWSER==="true"?{headless:!0,reason:"VISA_CLI_NO_BROWSER is set"}:e.CI==="true"||e.CI==="1"?{headless:!0,reason:"CI environment detected"}:e.SSH_CONNECTION||e.SSH_TTY?{headless:!0,reason:"SSH session detected"}:t==="linux"&&!e.DISPLAY&&!e.WAYLAND_DISPLAY?{headless:!0,reason:"Linux with no $DISPLAY or $WAYLAND_DISPLAY"}:{headless:!1}}function yr(e){let n=e.length+4;return[`\u250C${"\u2500".repeat(n)}\u2510`,`\u2502${" ".repeat(2)}${e}${" ".repeat(2)}\u2502`,`\u2514${"\u2500".repeat(n)}\u2518`].join(`
1
+ "use strict";var zn=Object.create;var Ue=Object.defineProperty;var Yn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var Xn=Object.getPrototypeOf,Zn=Object.prototype.hasOwnProperty;var y=(e,t)=>()=>(e&&(t=e(e=0)),t);var Qn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),er=(e,t)=>{for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})},tr=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Jn(t))!Zn.call(e,o)&&o!==n&&Ue(e,o,{get:()=>t[o],enumerable:!(r=Yn(t,o))||r.enumerable});return e};var p=(e,t,n)=>(n=e!=null?zn(Xn(e)):{},tr(t||!e||!e.__esModule?Ue(n,"default",{value:e,enumerable:!0}):n,e));async function rr(){try{let{stdout:e}=await M("security",["find-generic-password","-s",C,"-a",U,"-w"],{timeout:5e3});return e.trim()||null}catch{return null}}async function or(e){try{try{await M("security",["delete-generic-password","-s",C,"-a",U],{timeout:5e3})}catch{}return await M("security",["add-generic-password","-s",C,"-a",U,"-w",e],{timeout:5e3}),!0}catch{return!1}}async function sr(){try{await M("security",["delete-generic-password","-s",C,"-a",U],{timeout:5e3})}catch{}}async function ir(){if(!Ve())return null;try{let{stdout:e}=await M("secret-tool",["lookup","service",C,"account",U],{timeout:5e3});return e.trim()||null}catch{return null}}async function ar(e){if(!Ve())return!1;try{let t=(0,ge.execFile)("secret-tool",["store","--label",`${C} ${U}`,"service",C,"account",U]);return t.stdin?(t.stdin.write(e),t.stdin.end(),await Promise.race([new Promise((n,r)=>{t.on("exit",o=>o===0?n():r(new Error(`secret-tool exited ${o}`))),t.on("error",r)}),new Promise((n,r)=>setTimeout(()=>{t.kill(),r(new Error("secret-tool timed out"))},nr))]),!0):!1}catch{return!1}}async function cr(){if(Ve())try{await M("secret-tool",["clear","service",C,"account",U],{timeout:5e3})}catch{}}function Ve(){return!!process.env.DBUS_SESSION_BUS_ADDRESS}async function lr(){try{let{stdout:e}=await M("security",["find-generic-password","-s",C,"-a",pe,"-w"],{timeout:5e3});return e.trim()||null}catch{return null}}async function ur(e){try{try{await M("security",["delete-generic-password","-s",C,"-a",pe],{timeout:5e3})}catch{}await M("security",["add-generic-password","-s",C,"-a",pe,"-w",e],{timeout:5e3})}catch{}}async function dr(){try{await M("security",["delete-generic-password","-s",C,"-a",pe],{timeout:5e3})}catch{}}function je(){try{return D.readFileSync(me,"utf-8").trim()||null}catch{return null}}function ft(e){D.mkdirSync(qe,{recursive:!0,mode:448}),D.writeFileSync(me,e,{mode:384}),process.platform==="win32"&&mr(me)}function He(){try{D.unlinkSync(me)}catch{}}function mr(e){try{let t=fe.userInfo().username;(0,ge.execFile)("icacls",[e,"/inheritance:r","/grant:r",`${t}:F`],{timeout:5e3},n=>{n&&console.error(`[visa-cli] icacls ACL restriction failed: ${n.message}`)})}catch(t){console.error(`[visa-cli] Failed to invoke icacls: ${t instanceof Error?t.message:String(t)}`)}}function De(){switch(process.platform){case"darwin":return{get:rr,store:or,delete:sr};case"linux":return{get:ir,store:ar,delete:cr};default:return{get:async()=>je(),store:async e=>{try{return ft(e),!0}catch{return!1}},delete:async()=>He()}}}var ge,gt,D,fe,Fe,M,qe,me,C,U,pe,nr,_,ne=y(()=>{"use strict";ge=require("child_process"),gt=require("util"),D=p(require("fs")),fe=p(require("os")),Fe=p(require("path")),M=(0,gt.promisify)(ge.execFile),qe=Fe.join(fe.homedir(),".visa-mcp"),me=Fe.join(qe,"session-token"),C="visa-cli",U="session-token",pe="rc-access",nr=5e3;_=class{static async getSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN==="true")return Promise.resolve("mock-session-token-for-testing");let t=De(),n=await t.get();if(n)return n;let r=je();return r?(await t.store(r),r):null}static async saveSessionToken(t){if(process.env.VISA_MOCK_KEYCHAIN==="true")return;let n=De();if(await n.store(t)){if(await n.get()===t){He();return}await n.delete()}if(ft(t),je()!==t)throw new Error("Failed to persist session token. "+(process.platform==="darwin"?'Check Keychain Access permissions for "visa-cli".':`Ensure ${qe} is writable.`))}static async getRcAccessToken(){return process.env.VISA_MOCK_KEYCHAIN==="true"?"mock-rc-token-for-testing":lr()}static async saveRcAccessToken(t){process.env.VISA_MOCK_KEYCHAIN!=="true"&&await ur(t)}static async deleteSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN==="true")return;await De().delete(),He()}static async clearAll(){await this.deleteSessionToken(),await dr()}}});var Be=Qn((po,pr)=>{pr.exports={name:"@visa/cli",version:"1.2.0",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":"^25.6.0","@typescript-eslint/eslint-plugin":"^8.59.0","@typescript-eslint/parser":"^8.59.0","@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.3","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"]}});function St(e=process.env,t=process.platform){return e.VISA_CLI_NO_BROWSER==="1"||e.VISA_CLI_NO_BROWSER==="true"?{headless:!0,reason:"VISA_CLI_NO_BROWSER is set"}:e.CI==="true"||e.CI==="1"?{headless:!0,reason:"CI environment detected"}:e.SSH_CONNECTION||e.SSH_TTY?{headless:!0,reason:"SSH session detected"}:t==="linux"&&!e.DISPLAY&&!e.WAYLAND_DISPLAY?{headless:!0,reason:"Linux with no $DISPLAY or $WAYLAND_DISPLAY"}:{headless:!1}}function yr(e){let n=e.length+4;return[`\u250C${"\u2500".repeat(n)}\u2510`,`\u2502${" ".repeat(2)}${e}${" ".repeat(2)}\u2502`,`\u2514${"\u2500".repeat(n)}\u2518`].join(`
2
2
  `)}function wt(e,t=process.platform){return t==="darwin"?{cmd:"open",args:[e]}:t==="win32"?{cmd:"cmd",args:["/c","start","",e]}:t==="linux"?{cmd:"xdg-open",args:[e]}:null}async function bt(e,t={}){let n=t.log??(c=>console.log(c)),r=t.env??process.env,o=t.platform??process.platform,s=t.spawn??((c,l,u)=>{(0,_t.execFile)(c,l,h=>u(h))});n(""),n(" Sign in to Visa CLI by opening this URL in your browser:"),n("");for(let c of yr(e).split(`
3
- `))n(` ${c}`);n("");let i=St(r,o);if(i.headless){n(` (${i.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 a=wt(e,o);if(!a){n(` No known browser-open command for platform "${o}".`),n(" Open the URL above manually to continue."),n("");return}await new Promise(c=>{s(a.cmd,a.args,l=>{l?(n(` Could not open browser automatically (${l.message}).`),n(" Open the URL above manually to continue."),n("")):(n(" Opened browser. Waiting for you to sign in..."),n("")),c()})})}var _t,Ge=y(()=>{"use strict";_t=require("child_process")});async function vt(e,t){let n=t?.timeoutMs??3e4,r=new AbortController,o=setTimeout(()=>r.abort(),n);try{let{timeoutMs:s,...i}=t??{};return await fetch(e,{...i,signal:r.signal})}finally{clearTimeout(o)}}var $t=y(()=>{"use strict"});function xt(e,t){let n=Pt(e),r=Pt(t);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:Sr(n.pre,r.pre)>0}function Pt(e){if(typeof e!="string")return null;let n=e.trim().replace(/^v/,"").match(_r);return n?{main:[Number(n[1]),Number(n[2]),Number(n[3])],pre:n[4]??null}:null}function Sr(e,t){let n=e.split("."),r=t.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 i=n[s],a=r[s],c=/^\d+$/.test(i),l=/^\d+$/.test(a);if(c&&l){let u=Number(i)-Number(a);if(u!==0)return u}else{if(c)return-1;if(l)return 1;if(i<a)return-1;if(i>a)return 1}}return 0}var _r,Ct=y(()=>{"use strict";_r=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/});function W(){return!!(Tt(process.env.VISA_CLI_NO_UPDATE_CHECK)||Tt(process.env.CI)||process.env.NODE_ENV==="test")}function Tt(e){if(e===void 0)return!1;let t=e.trim().toLowerCase();return!(t===""||t==="0"||t==="false"||t==="no"||t==="off")}var Se=y(()=>{"use strict"});var We,N,we=y(()=>{"use strict";$t();Ct();Se();We="1.2.0-rc.1",N=class{constructor(t){this.getSessionToken=t;this.baseUrl=process.env.VISA_AUTH_URL||"https://auth.visacli.sh"}getSessionToken;baseUrl;lastSignals={};parseServerSignals(t){if(this.lastSignals={},!W()){let r=t.headers.get("X-Latest-Version"),o=t.headers.get("X-Update-Message");r&&xt(r,We)&&(this.lastSignals.updateAvailable={version:r,message:o||`Update available: v${r}. Run: npm install -g @visa/cli && visa-cli setup`})}let n=t.headers.get("X-Feedback-Prompt");if(n)try{this.lastSignals.feedbackPrompt=JSON.parse(n)}catch{}}getClientVersion(){return We}async request(t,n,r,o,s){let i=await this.getSessionToken();if(!i)throw new Error("Not logged in. Sign up at https://visacli.sh or run: visa-cli setup");let a={Authorization:`Bearer ${i}`};s&&(t==="GET"?a["X-User-Context"]=s.replace(/[\r\n\0]/g," ").slice(0,1e3):r={...r||{},user_context:s}),r&&(a["Content-Type"]="application/json");let c;try{c=await vt(`${this.baseUrl}${n}`,{method:t,headers:{...a,"X-Visa-CLI-Version":We},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(c),c.status===401)throw new Error("Your session has expired. Run: visa-cli setup");if(c.status===429){let u=c.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(c.status===503)throw new Error("Visa CLI is temporarily unavailable. Check https://visacli.sh for status.");let l;try{l=await c.json()}catch{throw c.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(!c.ok)throw c.status===500?new Error(`Server error on ${n}. Try again or check https://visacli.sh for status.`):new Error(l?.error||`Request failed (${c.status}). Try again.`);return l}async pay(t,n){return this.request("POST","/v1/pay",t,void 0,n)}async shortcut(t,n,r,o){return this.request("POST",`/v1/shortcuts/${encodeURIComponent(t)}`,n,r,o)}async batch(t,n,r){return this.request("POST","/v1/batch",t,n,r)}async catalogSearch(t,n){let r=new URLSearchParams;t&&r.set("q",t),n&&r.set("category",n);let o=r.toString();return this.request("GET",`/v1/catalog${o?`?${o}`:""}`)}async catalogTool(t){try{return await this.request("GET",`/v1/catalog/${encodeURIComponent(t)}`)}catch{return null}}async paymentPreview(t,n){return this.request("POST","/v1/payment-preview",t,void 0,n)}async getStatus(t){return this.request("GET","/v1/status",void 0,void 0,t)}async getTransactions(t){return this.request("GET","/v1/transactions",void 0,void 0,t)}async updateSpendingControls(t,n){return this.request("POST","/v1/spending-controls",t,void 0,n)}async removeCard(t,n,r){return this.request("DELETE",`/v1/cards/${encodeURIComponent(String(t))}`,n,void 0,r)}async setDefaultCard(t,n,r){return this.request("POST",`/v1/cards/${encodeURIComponent(String(t))}/default`,n,void 0,r)}async getAttestationChallenge(){return this.request("GET","/v1/attestation-challenge")}async registerAttestationKey(t){return this.request("POST","/v1/attestation-key",{publicKey:t})}async logout(t,n){return this.request("POST","/v1/logout",t,void 0,n)}async feedback(t,n,r){return this.request("POST","/v1/feedback",{message:t,...n&&{transaction_id:n}},void 0,r)}async feedSubmit(t){return this.request("POST","/v1/feed",t)}async feedList(t){let n=new URLSearchParams;t?.tab&&n.set("tab",t.tab),t?.limit&&n.set("limit",String(t.limit)),t?.offset&&n.set("offset",String(t.offset));let r=n.toString();return this.request("GET",`/v1/feed${r?"?"+r:""}`)}async feedVote(t,n){return this.request("POST",`/v1/feed/${encodeURIComponent(t)}/vote`,{direction:n})}async feedApprove(t){return this.request("POST",`/v1/feed/${encodeURIComponent(t)}/approve`)}async feedDelete(t){return this.request("DELETE",`/v1/feed/${encodeURIComponent(t)}`)}async feedPending(){return this.request("GET","/v1/feed/pending")}async submitFeedback(t,n,r){return this.request("POST","/v1/feedback",{message:t,...n&&{transaction_id:n}},void 0,r)}async getFeedback(t,n){let r=new URLSearchParams;t&&r.set("limit",String(t));let o=r.toString();return this.request("GET",`/v1/feedback${o?"?"+o:""}`,void 0,void 0,n)}async submitRatedFeedback(t){return this.request("POST","/v1/feedback",t)}}});function br(){v.existsSync(Ye)||v.mkdirSync(Ye,{recursive:!0,mode:448})}function vr(){if(!ze){if(br(),v.existsSync(re)&&v.statSync(re).size>wr){let t=re+".1";v.existsSync(t)&&v.unlinkSync(t),v.renameSync(re,t)}ze=v.createWriteStream(re,{flags:"a"})}return ze}function be(e,...t){let n=new Date().toISOString(),r=t.map(s=>typeof s=="string"?s:JSON.stringify(s,null,2)).join(" "),o=`[${n}] [${e}] ${r}
4
- `;process.stderr.write(o),vr().write(o)}var v,Je,Et,Ye,re,wr,ze,j,Xe=y(()=>{"use strict";v=p(require("fs")),Je=p(require("path")),Et=p(require("os")),Ye=Je.join(Et.homedir(),".visa-mcp"),re=Je.join(Ye,"mcp-server.log"),wr=5*1024*1024,ze=null;j={debug:(...e)=>be("DEBUG",...e),info:(...e)=>be("INFO",...e),warn:(...e)=>be("WARN",...e),error:(...e)=>be("ERROR",...e)}});function It(e){let t=S.readFileSync(e);return Lt.createHash("sha256").update(t).digest("hex")}async function Ot(){try{if(S.readFileSync(Rt,"utf-8").trim()===kt&&S.existsSync(z)){let r=S.readFileSync(At,"utf-8").trim();if(It(z)!==r)j.warn("binary:hash-mismatch",{message:"Binary hash mismatch \u2014 possible tampering detected. Recompiling from source."}),S.unlinkSync(z);else return z}}catch{}let e=L.join($r,"visa-keychain.m");if(S.existsSync(e)||(e=L.resolve(__dirname,"..","..","native","visa-keychain.m")),S.existsSync(e)||(e=L.resolve(__dirname,"..","native","visa-keychain.m")),!S.existsSync(e))throw new Error("visa-keychain.m source not found. Reinstall Visa CLI.");S.mkdirSync(Pe,{recursive:!0,mode:448});try{await X("clang",["-framework","Security","-framework","LocalAuthentication","-framework","Foundation","-framework","AppKit","-o",z,e],{timeout:3e4})}catch(n){throw n.code==="ENOENT"?new Error("Xcode Command Line Tools required. Install: xcode-select --install"):n}let t=It(z);return S.writeFileSync(At,t,{mode:384}),S.writeFileSync(Rt,kt,{mode:384}),z}async function Ut(e){let t=await Ot(),n;try{n=(await X(t,e,{timeout:6e4})).stdout}catch(s){n=s.stdout||"";let i=n.trim();throw i.startsWith("ERROR:")?new Error(i.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 Y(){return process.env.VISA_MOCK_TOUCHID==="true"?!0:process.platform!=="darwin"?!1:Ze!==null?Ze:(Ze=!0,!0)}async function Pr(e){try{await X("security",["delete-generic-password","-s",ve,"-a",$e],{timeout:5e3})}catch{}await X("security",["add-generic-password","-s",ve,"-a",$e,"-w",e],{timeout:5e3})}async function xr(){try{let{stdout:e}=await X("security",["find-generic-password","-s",ve,"-a",$e,"-w"],{timeout:5e3});return e.trim()||null}catch{return null}}async function Dt(){let e=await Ut(["generate-key"]);if(!e)throw new Error("Key generation returned no output");let t=e.indexOf(":");if(t<0)throw new Error("Unexpected generate-key output format");let n=e.slice(0,t),r=e.slice(t+1);return await Pr(n),r}async function xe(e,t){if(process.env.VISA_MOCK_TOUCHID==="true")return Promise.resolve("mock-ecdsa-signature-for-testing");let n=await xr();if(!n)throw new Error("Attestation key not found. Run setup to generate a new key.");let r=await Ot(),o=["sign",e];return t&&o.push(t),new Promise((s,i)=>{let a=(0,Qe.execFile)(r,o,{timeout:6e4},(c,l)=>{let u=(l||"").trim();if(c){u.startsWith("ERROR:")?i(new Error(u.slice(6))):i(new Error(c.stderr?.trim()||c.message||"Unknown error"));return}u.startsWith("OK:")?s(u.slice(3)):i(new Error(u.startsWith("ERROR:")?u.slice(6):"Unknown error"))});a.stdin.write(n),a.stdin.end()})}async function et(){try{await X("security",["delete-generic-password","-s",ve,"-a",$e],{timeout:5e3})}catch{}try{await Ut(["delete-key"])}catch{}}var Qe,Mt,Lt,S,Nt,L,X,Pe,z,$r,kt,Rt,At,Ze,ve,$e,tt=y(()=>{"use strict";Qe=require("child_process"),Mt=require("util"),Lt=p(require("crypto")),S=p(require("fs")),Nt=p(require("os")),L=p(require("path"));Xe();X=(0,Mt.promisify)(Qe.execFile),Pe=L.join(Nt.homedir(),".visa-mcp","bin"),z=L.join(Pe,"Visa CLI"),$r=L.join(__dirname,"..","native"),kt="5",Rt=L.join(Pe,"visa-keychain.version"),At=L.join(Pe,"visa-keychain.sha256");Ze=null;ve="visa-cli",$e="attestation-key"});async function Ie(e){let{model:t,messages:n,tools:r,maxTokens:o=4096,temperature:s=.7,attestation:i,sessionBudgetId:a}=e;return await zr.shortcut(t,{prompt:"",messages:n,...r?.length?{tools:r}:{},max_tokens:o,temperature:s,...i?{attestation:i}:{},...a?{session_budget_id:a}:{}},12e4)}function fn(e,t){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[t]||n["or-gpt-4o-mini"],o=e.prompt_tokens/1e6*r.inPerM*100,s=e.completion_tokens/1e6*r.outPerM*100;return Math.ceil(o+s)}var zr,ut=y(()=>{"use strict";we();ne();zr=new N(()=>_.getSessionToken())});function yn(e){let t=[];t.push(`You are an AI coding assistant powered by Visa CLI.
3
+ `))n(` ${c}`);n("");let i=St(r,o);if(i.headless){n(` (${i.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 a=wt(e,o);if(!a){n(` No known browser-open command for platform "${o}".`),n(" Open the URL above manually to continue."),n("");return}await new Promise(c=>{s(a.cmd,a.args,l=>{l?(n(` Could not open browser automatically (${l.message}).`),n(" Open the URL above manually to continue."),n("")):(n(" Opened browser. Waiting for you to sign in..."),n("")),c()})})}var _t,Ge=y(()=>{"use strict";_t=require("child_process")});async function vt(e,t){let n=t?.timeoutMs??3e4,r=new AbortController,o=setTimeout(()=>r.abort(),n);try{let{timeoutMs:s,...i}=t??{};return await fetch(e,{...i,signal:r.signal})}finally{clearTimeout(o)}}var $t=y(()=>{"use strict"});function Pt(e,t){let n=xt(e),r=xt(t);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:Sr(n.pre,r.pre)>0}function xt(e){if(typeof e!="string")return null;let n=e.trim().replace(/^v/,"").match(_r);return n?{main:[Number(n[1]),Number(n[2]),Number(n[3])],pre:n[4]??null}:null}function Sr(e,t){let n=e.split("."),r=t.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 i=n[s],a=r[s],c=/^\d+$/.test(i),l=/^\d+$/.test(a);if(c&&l){let u=Number(i)-Number(a);if(u!==0)return u}else{if(c)return-1;if(l)return 1;if(i<a)return-1;if(i>a)return 1}}return 0}var _r,Ct=y(()=>{"use strict";_r=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/});function W(){return!!(Tt(process.env.VISA_CLI_NO_UPDATE_CHECK)||Tt(process.env.CI)||process.env.NODE_ENV==="test")}function Tt(e){if(e===void 0)return!1;let t=e.trim().toLowerCase();return!(t===""||t==="0"||t==="false"||t==="no"||t==="off")}var Se=y(()=>{"use strict"});var We,N,we=y(()=>{"use strict";$t();Ct();Se();We="1.2.0",N=class{constructor(t){this.getSessionToken=t;this.baseUrl=process.env.VISA_AUTH_URL||"https://auth.visacli.sh"}getSessionToken;baseUrl;lastSignals={};parseServerSignals(t){if(this.lastSignals={},!W()){let r=t.headers.get("X-Latest-Version"),o=t.headers.get("X-Update-Message");r&&Pt(r,We)&&(this.lastSignals.updateAvailable={version:r,message:o||`Update available: v${r}. Run: npm install -g @visa/cli && visa-cli setup`})}let n=t.headers.get("X-Feedback-Prompt");if(n)try{this.lastSignals.feedbackPrompt=JSON.parse(n)}catch{}}getClientVersion(){return We}async request(t,n,r,o,s){let i=await this.getSessionToken();if(!i)throw new Error("Not logged in. Sign up at https://visacli.sh or run: visa-cli setup");let a={Authorization:`Bearer ${i}`};s&&(t==="GET"?a["X-User-Context"]=s.replace(/[\r\n\0]/g," ").slice(0,1e3):r={...r||{},user_context:s}),r&&(a["Content-Type"]="application/json");let c;try{c=await vt(`${this.baseUrl}${n}`,{method:t,headers:{...a,"X-Visa-CLI-Version":We},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(c),c.status===401)throw new Error("Your session has expired. Run: visa-cli setup");if(c.status===429){let u=c.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(c.status===503)throw new Error("Visa CLI is temporarily unavailable. Check https://visacli.sh for status.");let l;try{l=await c.json()}catch{throw c.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(!c.ok)throw c.status===500?new Error(`Server error on ${n}. Try again or check https://visacli.sh for status.`):new Error(l?.error||`Request failed (${c.status}). Try again.`);return l}async pay(t,n){return this.request("POST","/v1/pay",t,void 0,n)}async shortcut(t,n,r,o){return this.request("POST",`/v1/shortcuts/${encodeURIComponent(t)}`,n,r,o)}async batch(t,n,r){return this.request("POST","/v1/batch",t,n,r)}async catalogSearch(t,n){let r=new URLSearchParams;t&&r.set("q",t),n&&r.set("category",n);let o=r.toString();return this.request("GET",`/v1/catalog${o?`?${o}`:""}`)}async catalogTool(t){try{return await this.request("GET",`/v1/catalog/${encodeURIComponent(t)}`)}catch{return null}}async paymentPreview(t,n){return this.request("POST","/v1/payment-preview",t,void 0,n)}async getStatus(t){return this.request("GET","/v1/status",void 0,void 0,t)}async getTransactions(t){return this.request("GET","/v1/transactions",void 0,void 0,t)}async updateSpendingControls(t,n){return this.request("POST","/v1/spending-controls",t,void 0,n)}async removeCard(t,n,r){return this.request("DELETE",`/v1/cards/${encodeURIComponent(String(t))}`,n,void 0,r)}async setDefaultCard(t,n,r){return this.request("POST",`/v1/cards/${encodeURIComponent(String(t))}/default`,n,void 0,r)}async getAttestationChallenge(){return this.request("GET","/v1/attestation-challenge")}async registerAttestationKey(t){return this.request("POST","/v1/attestation-key",{publicKey:t})}async logout(t,n){return this.request("POST","/v1/logout",t,void 0,n)}async feedback(t,n,r){return this.request("POST","/v1/feedback",{message:t,...n&&{transaction_id:n}},void 0,r)}async feedSubmit(t){return this.request("POST","/v1/feed",t)}async feedList(t){let n=new URLSearchParams;t?.tab&&n.set("tab",t.tab),t?.limit&&n.set("limit",String(t.limit)),t?.offset&&n.set("offset",String(t.offset));let r=n.toString();return this.request("GET",`/v1/feed${r?"?"+r:""}`)}async feedVote(t,n){return this.request("POST",`/v1/feed/${encodeURIComponent(t)}/vote`,{direction:n})}async feedApprove(t){return this.request("POST",`/v1/feed/${encodeURIComponent(t)}/approve`)}async feedDelete(t){return this.request("DELETE",`/v1/feed/${encodeURIComponent(t)}`)}async feedPending(){return this.request("GET","/v1/feed/pending")}async submitFeedback(t,n,r){return this.request("POST","/v1/feedback",{message:t,...n&&{transaction_id:n}},void 0,r)}async getFeedback(t,n){let r=new URLSearchParams;t&&r.set("limit",String(t));let o=r.toString();return this.request("GET",`/v1/feedback${o?"?"+o:""}`,void 0,void 0,n)}async submitRatedFeedback(t){return this.request("POST","/v1/feedback",t)}}});function br(){v.existsSync(Ye)||v.mkdirSync(Ye,{recursive:!0,mode:448})}function vr(){if(!ze){if(br(),v.existsSync(re)&&v.statSync(re).size>wr){let t=re+".1";v.existsSync(t)&&v.unlinkSync(t),v.renameSync(re,t)}ze=v.createWriteStream(re,{flags:"a"})}return ze}function be(e,...t){let n=new Date().toISOString(),r=t.map(s=>typeof s=="string"?s:JSON.stringify(s,null,2)).join(" "),o=`[${n}] [${e}] ${r}
4
+ `;process.stderr.write(o),vr().write(o)}var v,Je,Et,Ye,re,wr,ze,j,Xe=y(()=>{"use strict";v=p(require("fs")),Je=p(require("path")),Et=p(require("os")),Ye=Je.join(Et.homedir(),".visa-mcp"),re=Je.join(Ye,"mcp-server.log"),wr=5*1024*1024,ze=null;j={debug:(...e)=>be("DEBUG",...e),info:(...e)=>be("INFO",...e),warn:(...e)=>be("WARN",...e),error:(...e)=>be("ERROR",...e)}});function It(e){let t=S.readFileSync(e);return Lt.createHash("sha256").update(t).digest("hex")}async function Ot(){try{if(S.readFileSync(Rt,"utf-8").trim()===kt&&S.existsSync(z)){let r=S.readFileSync(At,"utf-8").trim();if(It(z)!==r)j.warn("binary:hash-mismatch",{message:"Binary hash mismatch \u2014 possible tampering detected. Recompiling from source."}),S.unlinkSync(z);else return z}}catch{}let e=L.join($r,"visa-keychain.m");if(S.existsSync(e)||(e=L.resolve(__dirname,"..","..","native","visa-keychain.m")),S.existsSync(e)||(e=L.resolve(__dirname,"..","native","visa-keychain.m")),!S.existsSync(e))throw new Error("visa-keychain.m source not found. Reinstall Visa CLI.");S.mkdirSync(xe,{recursive:!0,mode:448});try{await X("clang",["-framework","Security","-framework","LocalAuthentication","-framework","Foundation","-framework","AppKit","-o",z,e],{timeout:3e4})}catch(n){throw n.code==="ENOENT"?new Error("Xcode Command Line Tools required. Install: xcode-select --install"):n}let t=It(z);return S.writeFileSync(At,t,{mode:384}),S.writeFileSync(Rt,kt,{mode:384}),z}async function Ut(e){let t=await Ot(),n;try{n=(await X(t,e,{timeout:6e4})).stdout}catch(s){n=s.stdout||"";let i=n.trim();throw i.startsWith("ERROR:")?new Error(i.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 Y(){return process.env.VISA_MOCK_TOUCHID==="true"?!0:process.platform!=="darwin"?!1:Ze!==null?Ze:(Ze=!0,!0)}async function xr(e){try{await X("security",["delete-generic-password","-s",ve,"-a",$e],{timeout:5e3})}catch{}await X("security",["add-generic-password","-s",ve,"-a",$e,"-w",e],{timeout:5e3})}async function Pr(){try{let{stdout:e}=await X("security",["find-generic-password","-s",ve,"-a",$e,"-w"],{timeout:5e3});return e.trim()||null}catch{return null}}async function Dt(){let e=await Ut(["generate-key"]);if(!e)throw new Error("Key generation returned no output");let t=e.indexOf(":");if(t<0)throw new Error("Unexpected generate-key output format");let n=e.slice(0,t),r=e.slice(t+1);return await xr(n),r}async function Pe(e,t){if(process.env.VISA_MOCK_TOUCHID==="true")return Promise.resolve("mock-ecdsa-signature-for-testing");let n=await Pr();if(!n)throw new Error("Attestation key not found. Run setup to generate a new key.");let r=await Ot(),o=["sign",e];return t&&o.push(t),new Promise((s,i)=>{let a=(0,Qe.execFile)(r,o,{timeout:6e4},(c,l)=>{let u=(l||"").trim();if(c){u.startsWith("ERROR:")?i(new Error(u.slice(6))):i(new Error(c.stderr?.trim()||c.message||"Unknown error"));return}u.startsWith("OK:")?s(u.slice(3)):i(new Error(u.startsWith("ERROR:")?u.slice(6):"Unknown error"))});a.stdin.write(n),a.stdin.end()})}async function et(){try{await X("security",["delete-generic-password","-s",ve,"-a",$e],{timeout:5e3})}catch{}try{await Ut(["delete-key"])}catch{}}var Qe,Mt,Lt,S,Nt,L,X,xe,z,$r,kt,Rt,At,Ze,ve,$e,tt=y(()=>{"use strict";Qe=require("child_process"),Mt=require("util"),Lt=p(require("crypto")),S=p(require("fs")),Nt=p(require("os")),L=p(require("path"));Xe();X=(0,Mt.promisify)(Qe.execFile),xe=L.join(Nt.homedir(),".visa-mcp","bin"),z=L.join(xe,"Visa CLI"),$r=L.join(__dirname,"..","native"),kt="5",Rt=L.join(xe,"visa-keychain.version"),At=L.join(xe,"visa-keychain.sha256");Ze=null;ve="visa-cli",$e="attestation-key"});async function Ie(e){let{model:t,messages:n,tools:r,maxTokens:o=4096,temperature:s=.7,attestation:i,sessionBudgetId:a}=e;return await zr.shortcut(t,{prompt:"",messages:n,...r?.length?{tools:r}:{},max_tokens:o,temperature:s,...i?{attestation:i}:{},...a?{session_budget_id:a}:{}},12e4)}function fn(e,t){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[t]||n["or-gpt-4o-mini"],o=e.prompt_tokens/1e6*r.inPerM*100,s=e.completion_tokens/1e6*r.outPerM*100;return Math.ceil(o+s)}var zr,ut=y(()=>{"use strict";we();ne();zr=new N(()=>_.getSessionToken())});function yn(e){let t=[];t.push(`You are an AI coding assistant powered by Visa CLI.
5
5
  You can read, write, and edit files. You can run shell commands.
6
6
  You can generate images, music, video, and query data \u2014 each costs money.
7
7
  The user pays per-use via their Visa card. Show costs before expensive operations.
@@ -21,7 +21,7 @@ ${c}`},{role:"assistant",content:"Understood. I have context from our previous c
21
21
  `)||"No matches",isError:!1}}catch{return{content:"No matches",isError:!1}}},grep(e,t){let n=e.path?O.resolve(t,e.path):t,r=e.pattern,o=e.include,s=["-rn",...o?["--include",o]:[],r,n];try{return{content:(0,mt.execFileSync)("grep",s,{encoding:"utf-8",timeout:1e4}).split(`
22
22
  `).filter(Boolean).slice(0,50).join(`
23
23
  `)||"No matches",isError:!1}}catch{return{content:"No matches",isError:!1}}},list_dir(e,t){let n=O.resolve(t,e.path||".");return{content:E.readdirSync(n,{withFileTypes:!0}).map(s=>`${s.isDirectory()?"d":"f"} ${s.name}`).join(`
24
- `),isError:!1}}}});var $n,Yr,Pn,xn,Cn=y(()=>{"use strict";$n=require("child_process"),Yr=[/rm\s+-rf\s+\//,/mkfs/,/dd\s+if=/,/:()\{\s*:\|:&\s*\};:/,/>\s*\/dev\/sd/],Pn=[{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"]}}}],xn={bash(e,t){let n=e.command;for(let r of Yr)if(r.test(n))return{content:"Blocked: dangerous command pattern",isError:!0};try{return{content:(0,$n.execSync)(n,{cwd:t,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 En(e,t,n){let r=Jr[e];if(!r)return{content:`Unknown tool: ${e}`,isError:!0};try{return r(t,n)}catch(o){return{content:o.message||String(o),isError:!0}}}var Tn,Jr,kn=y(()=>{"use strict";vn();Cn();Tn=[...wn,...Pn],Jr={...bn,...xn}});async function Rn(e,t,n,r,o,s){let i=process.cwd(),a=[{role:"system",content:yn(i)}],c=Qr[e.model]||128e3;for(;e.turns<Xr;){let l=await n();if(l===null)break;if(!l.trim())continue;if(l.startsWith("/")){if(l.startsWith("/model ")){e.model=l.slice(7).trim(),r(`Switched to ${e.model}`);continue}if(l==="/budget"||l==="/cost"){r(`Spent: $${(e.spentCents/100).toFixed(2)} / $${(e.budgetCents/100).toFixed(2)}`);continue}if(l==="/quit"||l==="/exit")break}a.push({role:"user",content:l});let u=0,h=0;for(;;){if(e.turns++,e.spentCents>=e.budgetCents){r("Session budget exhausted. Run /budget to check or start a new session.");return}let P;try{P=await Ie({model:e.model,messages:a,tools:Tn,maxTokens:4096,temperature:.7,...t?{attestation:t}:{}})}catch(b){r(`Error: ${b.message||b}`),a.pop();break}let q=fn(P.usage,e.model);e.spentCents+=q,e.inputTokens+=P.usage.prompt_tokens,e.outputTokens+=P.usage.completion_tokens,u+=q;let V=P.choices[0];if(!V)break;let R=V.message;if(R.content&&r(R.content),a.push(R),!R.tool_calls?.length||V.finish_reason==="stop")break;for(let b of R.tool_calls){let Oe=b.function.name,B;try{B=JSON.parse(b.function.arguments)}catch{B={}}o(Oe,B);let{content:K}=await En(Oe,B,i);a.push({role:"tool",content:K.slice(0,1e4),tool_call_id:b.id})}}if(s(u,h),eo(a)>c*Zr){let P=await _n(a,e.model);a.length=0,a.push(...P)}}}function eo(e){let t=0;for(let n of e)if(typeof n.content=="string"&&(t+=n.content.length),n.tool_calls)for(let r of n.tool_calls)t+=r.function.arguments.length+r.function.name.length;return Math.ceil(t/3.5)}var Xr,Zr,Qr,An=y(()=>{"use strict";ut();Sn();kn();Xr=50,Zr=.7,Qr={"or-claude-sonnet":2e5,"or-gpt-4o":128e3,"or-gpt-4o-mini":128e3,"or-gemini-pro":1e6,"or-deepseek-r1":64e3}});var to,zo,In=y(()=>{"use strict";pt();to={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"]}},zo=Object.keys(to)});async function Mn(e,t,n,r){if(!Y()){j.warn("attestation:unavailable",{context:e});return}j.info("attestation:attempt",{context:e,amount:t,merchant:n});try{let{nonce:o}=await no.getAttestationChallenge(),s=Buffer.from(JSON.stringify({nonce:o,amount:t,merchant:n,context:e})).toString("base64");j.info("touchid:prompt",{context:e,amount:t,merchant:n});let i=await xe(s,r);return j.info("attestation:success",{context:e,amount:t,merchant:n}),{signature:i,nonce:o,amount:t,merchant:n}}catch(o){throw j.error("attestation:failure",{context:e,amount:t,merchant:n,error:o.message}),o}}var os,no,ro,ss,is,as,pt=y(()=>{"use strict";we();tt();ne();Xe();In();Ge();os=process.env.VISA_AUTH_URL||"https://auth.visacli.sh",no=new N(()=>_.getSessionToken()),ro=["generate_image","generate_video","generate_music","generate_audio","generate_3d","upscale_image","transcribe_audio","run_llm"],ss=["","","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:",...ro.map(e=>`\u2022 "${e.replace(/_/g," ")}" \u2192 ${e}`),"","Tool catalog:",'\u2022 "Find an image upscaler" \u2192 discover_tools','\u2022 "Run fal-aura-sr on this URL" \u2192 execute_tool'].join(`
24
+ `),isError:!1}}}});var $n,Yr,xn,Pn,Cn=y(()=>{"use strict";$n=require("child_process"),Yr=[/rm\s+-rf\s+\//,/mkfs/,/dd\s+if=/,/:()\{\s*:\|:&\s*\};:/,/>\s*\/dev\/sd/],xn=[{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"]}}}],Pn={bash(e,t){let n=e.command;for(let r of Yr)if(r.test(n))return{content:"Blocked: dangerous command pattern",isError:!0};try{return{content:(0,$n.execSync)(n,{cwd:t,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 En(e,t,n){let r=Jr[e];if(!r)return{content:`Unknown tool: ${e}`,isError:!0};try{return r(t,n)}catch(o){return{content:o.message||String(o),isError:!0}}}var Tn,Jr,kn=y(()=>{"use strict";vn();Cn();Tn=[...wn,...xn],Jr={...bn,...Pn}});async function Rn(e,t,n,r,o,s){let i=process.cwd(),a=[{role:"system",content:yn(i)}],c=Qr[e.model]||128e3;for(;e.turns<Xr;){let l=await n();if(l===null)break;if(!l.trim())continue;if(l.startsWith("/")){if(l.startsWith("/model ")){e.model=l.slice(7).trim(),r(`Switched to ${e.model}`);continue}if(l==="/budget"||l==="/cost"){r(`Spent: $${(e.spentCents/100).toFixed(2)} / $${(e.budgetCents/100).toFixed(2)}`);continue}if(l==="/quit"||l==="/exit")break}a.push({role:"user",content:l});let u=0,h=0;for(;;){if(e.turns++,e.spentCents>=e.budgetCents){r("Session budget exhausted. Run /budget to check or start a new session.");return}let x;try{x=await Ie({model:e.model,messages:a,tools:Tn,maxTokens:4096,temperature:.7,...t?{attestation:t}:{}})}catch(b){r(`Error: ${b.message||b}`),a.pop();break}let q=fn(x.usage,e.model);e.spentCents+=q,e.inputTokens+=x.usage.prompt_tokens,e.outputTokens+=x.usage.completion_tokens,u+=q;let V=x.choices[0];if(!V)break;let R=V.message;if(R.content&&r(R.content),a.push(R),!R.tool_calls?.length||V.finish_reason==="stop")break;for(let b of R.tool_calls){let Oe=b.function.name,B;try{B=JSON.parse(b.function.arguments)}catch{B={}}o(Oe,B);let{content:K}=await En(Oe,B,i);a.push({role:"tool",content:K.slice(0,1e4),tool_call_id:b.id})}}if(s(u,h),eo(a)>c*Zr){let x=await _n(a,e.model);a.length=0,a.push(...x)}}}function eo(e){let t=0;for(let n of e)if(typeof n.content=="string"&&(t+=n.content.length),n.tool_calls)for(let r of n.tool_calls)t+=r.function.arguments.length+r.function.name.length;return Math.ceil(t/3.5)}var Xr,Zr,Qr,An=y(()=>{"use strict";ut();Sn();kn();Xr=50,Zr=.7,Qr={"or-claude-sonnet":2e5,"or-gpt-4o":128e3,"or-gpt-4o-mini":128e3,"or-gemini-pro":1e6,"or-deepseek-r1":64e3}});var to,zo,In=y(()=>{"use strict";pt();to={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"]}},zo=Object.keys(to)});async function Mn(e,t,n,r){if(!Y()){j.warn("attestation:unavailable",{context:e});return}j.info("attestation:attempt",{context:e,amount:t,merchant:n});try{let{nonce:o}=await no.getAttestationChallenge(),s=Buffer.from(JSON.stringify({nonce:o,amount:t,merchant:n,context:e})).toString("base64");j.info("touchid:prompt",{context:e,amount:t,merchant:n});let i=await Pe(s,r);return j.info("attestation:success",{context:e,amount:t,merchant:n}),{signature:i,nonce:o,amount:t,merchant:n}}catch(o){throw j.error("attestation:failure",{context:e,amount:t,merchant:n,error:o.message}),o}}var os,no,ro,ss,is,as,pt=y(()=>{"use strict";we();tt();ne();Xe();In();Ge();os=process.env.VISA_AUTH_URL||"https://auth.visacli.sh",no=new N(()=>_.getSessionToken()),ro=["generate_image","generate_video","generate_music","generate_audio","generate_3d","upscale_image","transcribe_audio","run_llm"],ss=["","","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:",...ro.map(e=>`\u2022 "${e.replace(/_/g," ")}" \u2192 ${e}`),"","Tool catalog:",'\u2022 "Find an image upscaler" \u2192 discover_tools','\u2022 "Run fal-aura-sr on this URL" \u2192 execute_tool'].join(`
25
25
  `);is=16*1024,as=50*1024*1024});function Nn(e="or-claude-sonnet"){return{model:e,budgetCents:Ln,spentCents:0,turns:0,inputTokens:0,outputTokens:0}}async function On(e=Ln){try{return{attestation:await Mn("visa-client-session",e/100,"Visa CLI",`Visa CLI session budget: $${(e/100).toFixed(2)}`)||void 0,budgetCents:e}}catch{return{attestation:void 0,budgetCents:e}}}function Me(e){let t=(e.budgetCents-e.spentCents)/100,n=e.spentCents/100;return`$${t.toFixed(2)} remaining ($${n.toFixed(2)} spent, ${e.turns} turns)`}var Ln,Un=y(()=>{"use strict";pt();Ln=500});var jn={};er(jn,{startClient:()=>io});async function io(e={}){let t=Nn(e.model);console.log(so),console.log(`
26
26
  ${J}Model: ${t.model}${F}`),console.log(` ${J}Authorizing session budget: $${(t.budgetCents/100).toFixed(2)}${F}`);let n=await On(e.budget||t.budgetCents);t.budgetCents=n.budgetCents,n.attestation?console.log(` ${J}Touch ID authorized. ${Me(t)}${F}
27
27
  `):console.log(` ${J}No attestation (Touch ID unavailable). ${Me(t)}${F}
@@ -31,7 +31,7 @@ ${c}`},{role:"assistant",content:"Understood. I have context from our previous c
31
31
  `)}
32
32
  `)},i=(c,l)=>{let u=c==="bash"?l.command?.slice(0,60):l.path||"";console.log(` ${J}\u25B8 ${c}${F} ${u}`)},a=(c,l)=>{let u=c+l,h=[`$${(c/100).toFixed(3)} inference`];l>0&&h.push(`$${(l/100).toFixed(3)} tools`),console.log(` ${J}${h.join(" \xB7 ")} \xB7 $${(u/100).toFixed(3)} this turn${F}`)};await Rn(t,n.attestation,o,s,i,a),console.log(`
33
33
  ${J}Session ended. ${Me(t)}${F}`),r.close()}var Dn,F,oo,J,so,Hn=y(()=>{"use strict";Dn=p(require("readline"));An();Un();F="\x1B[0m",oo="\x1B[38;5;33m",J="\x1B[2m",so=[" \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(`
34
- `)});var Fn=require("commander"),Ne=p(require("crypto")),ee=p(require("os")),qn=require("child_process"),Vn=require("util");ne();var he=p(require("crypto")),ye=p(require("tty")),_e=p(require("fs"));var G="6820f6e91b762e645c9bf020c0d3673bb99d4a25a824880c0d548e10bb9bc7b1";ne();function gr(e){return/-rc\.|-beta\./.test(e)}function Ke(e){return he.createHash("sha256").update(e.trim()).digest("hex")}function ht(e){return G==="SKIP"?!0:he.timingSafeEqual(Buffer.from(Ke(e)),Buffer.from(G))}function fr(e){return new Promise((t,n)=>{let r=_e.openSync("/dev/tty","r+"),o=new ye.ReadStream(r),s=new ye.WriteStream(r),i=()=>{try{o.destroy()}catch{}try{s.destroy()}catch{}try{_e.closeSync(r)}catch{}};s.write(e),o.setRawMode(!0),o.resume(),o.setEncoding("utf8");let a="";o.on("data",c=>{c==="\r"||c===`
34
+ `)});var Fn=require("commander"),Ne=p(require("crypto")),ee=p(require("os")),qn=require("child_process"),Vn=require("util");ne();var he=p(require("crypto")),ye=p(require("tty")),_e=p(require("fs"));var G="0000000000000000000000000000000000000000000000000000000000000000";ne();function gr(e){return/-rc\.|-beta\./.test(e)}function Ke(e){return he.createHash("sha256").update(e.trim()).digest("hex")}function ht(e){return G==="SKIP"?!0:he.timingSafeEqual(Buffer.from(Ke(e)),Buffer.from(G))}function fr(e){return new Promise((t,n)=>{let r=_e.openSync("/dev/tty","r+"),o=new ye.ReadStream(r),s=new ye.WriteStream(r),i=()=>{try{o.destroy()}catch{}try{s.destroy()}catch{}try{_e.closeSync(r)}catch{}};s.write(e),o.setRawMode(!0),o.resume(),o.setEncoding("utf8");let a="";o.on("data",c=>{c==="\r"||c===`
35
35
  `?(s.write(`
36
36
  `),i(),t(a)):c===""?(s.write(`
37
37
  `),i(),n(new Error("Cancelled"))):c==="\x7F"||c==="\b"?a.length>0&&(a=a.slice(0,-1),s.write("\b \b")):(a+=c,s.write("\u2022"))})})}var hr=`
@@ -52,7 +52,7 @@ ${c}`},{role:"assistant",content:"Understood. I have context from our previous c
52
52
  Invalid code. Contact your team lead.
53
53
  `),process.exit(1)}Ge();we();tt();Se();function Ht(e,t=process.stderr){if(W()||!e?.updateAvailable)return!1;let{message:n}=e.updateAvailable;return n?(t.write(`
54
54
  \x1B[33m\u2191 ${n}\x1B[0m
55
- `),!0):!1}function qt(e,t,n,r){let s=Ir(e.spendingControls).dailyLimit,i=Math.max(0,oe(e.dailySpent)),a=s>0?Math.min(s,Math.max(0,oe(e.dailyRemaining??s-i))):0,c=s>0?Math.min(1,i/s):0,u=(Array.isArray(t)?t:[]).filter(Er),h=u.slice(0,3),k=kr(u,3),P=(e.cards??[]).slice(0,3),q=r.latestVersion?nt(r.latestVersion):"",V=r.updateCheckDisabled?"update checks disabled":q?`update available: v${q}`:"up to date",R=Math.round(c*100),b=H(e.status,e.enrolled?"approved":"not enrolled"),B=["VISA CLI HUD",`Status: ${e.enrolled?"Visa ready":"Visa setup needed"} | account: ${b} | touch id: ${n?"ready":"unavailable"}`,`Version: v${r.currentVersion} | ${V}`,`Spend meter: ${Ft(c)} ${String(R).padStart(3," ")}% | remaining ${Z(a)} | cap ${Z(s)}`,"","Spend",` Remaining ${Z(a)} / ${Z(s)}`,` Usage ${Ft(c)} ${R}%`,` Spent today ${Z(i)}`,` Attestation key ${e.hasAttestationKey?"registered":"missing"}`,"","Cards",...P.length>0?P.map(K=>` ${Ar(K)}`):[" No cards enrolled"],"","Last 3 services",...k.length>0?k.map((K,Wn)=>` ${Wn+1}. ${K}`):[" No paid services yet"],"","Recent receipts",...h.length>0?h.map(K=>` ${Rr(K)}`):[" No receipts yet"]];return r.updateMessage&&B.push("",`Update: ${nt(r.updateMessage)}`),`${B.join(`
55
+ `),!0):!1}function qt(e,t,n,r){let s=Ir(e.spendingControls).dailyLimit,i=Math.max(0,oe(e.dailySpent)),a=s>0?Math.min(s,Math.max(0,oe(e.dailyRemaining??s-i))):0,c=s>0?Math.min(1,i/s):0,u=(Array.isArray(t)?t:[]).filter(Er),h=u.slice(0,3),k=kr(u,3),x=(e.cards??[]).slice(0,3),q=r.latestVersion?nt(r.latestVersion):"",V=r.updateCheckDisabled?"update checks disabled":q?`update available: v${q}`:"up to date",R=Math.round(c*100),b=H(e.status,e.enrolled?"approved":"not enrolled"),B=["VISA CLI HUD",`Status: ${e.enrolled?"Visa ready":"Visa setup needed"} | account: ${b} | touch id: ${n?"ready":"unavailable"}`,`Version: v${r.currentVersion} | ${V}`,`Spend meter: ${Ft(c)} ${String(R).padStart(3," ")}% | remaining ${Z(a)} | cap ${Z(s)}`,"","Spend",` Remaining ${Z(a)} / ${Z(s)}`,` Usage ${Ft(c)} ${R}%`,` Spent today ${Z(i)}`,` Attestation key ${e.hasAttestationKey?"registered":"missing"}`,"","Cards",...x.length>0?x.map(K=>` ${Ar(K)}`):[" No cards enrolled"],"","Last 3 services",...k.length>0?k.map((K,Wn)=>` ${Wn+1}. ${K}`):[" No paid services yet"],"","Recent receipts",...h.length>0?h.map(K=>` ${Rr(K)}`):[" No receipts yet"]];return r.updateMessage&&B.push("",`Update: ${nt(r.updateMessage)}`),`${B.join(`
56
56
  `)}
57
57
  `}function Cr(e){return e.tool_name!=null}function Tr(e){return oe(e.amount)===0&&e.status==="failed"}function Er(e){return Cr(e)&&!Tr(e)}function kr(e,t=1/0){let n=new Set,r=[];for(let o of e){if(r.length>=t)break;let s=H(o.merchant_name,"Unknown merchant"),i=H(o.tool_name,"unknown_tool"),a=`${s} :: ${i}`;n.has(a)||(n.add(a),r.push(`${s} [${i}]`))}return r}function Rr(e){let t=H(e.merchant_name,"Unknown merchant"),n=H(e.tool_name,"unknown_tool"),r=Z(oe(e.amount)),o=H(e.status,"unknown"),s=Mr(e.created_at);return`${r} ${o.padEnd(9)} ${t} [${n}] ${s}`}function Ar(e){let t=H(e.brand?.toUpperCase(),"CARD"),n=e.isDefault?" default":"";return`${Number.isInteger(e.id)?`#${e.id} `:""}${t} ****${e.last4}${n}`}function Ir(e){return{dailyLimit:oe(e?.daily_limit??e?.dailyLimit??0)}}function oe(e){let t=Number(typeof e=="string"?e:e??0);return Number.isFinite(t)?t:0}function Z(e){return`$${e.toFixed(2)}`}function Ft(e,t=20){let n=Math.max(0,Math.min(1,e)),r=Math.round(n*t);return`[${"\u2588".repeat(r)}${"\u2591".repeat(t-r)}]`}function H(e,t){let n=nt(e??"").trim();return n.length>0?n:t}function Mr(e){if(!e)return"unknown time";let t=new Date(e);return Number.isNaN(t.getTime())?H(e,"unknown time"):t.toISOString().slice(0,16).replace("T"," ")}function nt(e){return e.replace(/\u001B\][^\u0007]*(?:\u0007|\u001B\\)/g,"").replace(/\u001B\[[0-?]*[ -/]*[@-~]/g,"").replace(/[\u0000-\u0008\u000B-\u001F\u007F-\u009F]/g,"").replace(/\s+/g," ")}var m=p(require("fs")),Ae=p(require("os")),f=p(require("path")),Bt=require("child_process"),Lr=2,Ce="# >>> visa-cli shell hud v2 >>>",Te="# <<< visa-cli shell hud v2 <<<",Nr="# >>> visa-cli shell hud >>>",Or="# <<< visa-cli shell hud <<<",Kt=3e4,Ur=3e4;function it(){try{return f.join(on(),".visa-cli")}catch{return f.join(Ae.tmpdir(),".visa-cli")}}function st(){return f.join(it(),"shell-hud.json")}function Gt(){return f.join(it(),"shell-hud.line")}function Wt(){return f.join(it(),"shell-hud.lock")}function zt(e){let t=e??process.env.SHELL;if(!t)return null;let n=f.basename(t.replace(/\\/g,"/")).toLowerCase();return n==="zsh"?"zsh":n==="bash"?"bash":n==="pwsh"||n==="pwsh.exe"||n==="powershell"||n==="powershell.exe"?"powershell":null}function Yt(e){let t=on();if(e==="zsh")return f.join(t,".zshrc");if(e==="bash")return f.join(t,".bashrc");let n=(process.platform==="win32","PowerShell");return f.join(t,"Documents",n,"Microsoft.PowerShell_profile.ps1")}function Dr(e){let t="$HOME/.visa-cli/shell-hud.line",n=Vr(e),r=Br(e);if(e==="zsh")return`${Ce}
58
58
  _visa_cli_shell_hud_precmd() {
@@ -107,8 +107,8 @@ ${k}`}function en(){let e=rn();return!!e&&Date.now()-e.renderedAt<=Kt}function t
107
107
  `)}catch{}}function se(){try{m.unlinkSync(Wt())}catch{}}function rn(){let e=st();if(!m.existsSync(e))return null;try{return JSON.parse(m.readFileSync(e,"utf-8"))}catch{return null}}function Hr(){let e=Wt();try{if(m.mkdirSync(f.dirname(e),{recursive:!0}),!Kr(e))return;let t=process.argv[1]?f.resolve(process.argv[1]):"";if(!t){se();return}let n=(0,Bt.spawn)(process.execPath,[t,"shell-hud","refresh"],{detached:!0,stdio:"ignore",env:{...process.env,VISA_CLI_SHELL_HUD_BACKGROUND:"1"}});n.once("error",se),n.unref()}catch{se()}}function rt(e){let t=Number(typeof e=="string"?e:e??0);return Number.isFinite(t)?t:0}function ie(e){return e.replace(/\u001B\][^\u0007]*(?:\u0007|\u001B\\)/g,"").replace(/\u001B\[[0-?]*[ -/]*[@-~]/g,"").replace(/[\u0000-\u0008\u000B-\u001F\u007F-\u009F]/g,"").replace(/\s+/g," ").trim()}function Fr(e){let n=Math.round(Math.max(0,Math.min(1,e))*10),r="\u2588".repeat(n),o="\u2591".repeat(10-n);return`${A(r||"",T.green)}${A(o||"",T.dim)}`}function ot(e){return`$${e.toFixed(2)}`}function qr(e){let t=e.cards?.find(s=>s.isDefault)??e.cards?.[0];if(!t)return"card none";let n=ie((t.brand??"card").toUpperCase()),r=ie(t.last4);return`${t.isDefault?"default":"active"} ${n} ****${r}`}var T={reset:"\x1B[0m",blue:"\x1B[38;5;39m",cyan:"\x1B[38;5;117m",green:"\x1B[38;5;48m",yellow:"\x1B[38;5;221m",dim:"\x1B[2m"};function A(e,t){return e.length===0||process.env.NO_COLOR?e:`${t}${e}${T.reset}`}function Vt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function on(){let e=Ae.homedir();if(!e||!f.isAbsolute(e))throw new Error("unable to determine a valid home directory");return f.resolve(e)}function Vr(e){let t=process.argv[1]?f.resolve(process.argv[1]):"";return t?e==="powershell"?`& ${ke(process.execPath)} ${ke(t)} shell-hud refresh`:`${Ee(process.execPath)} ${Ee(t)} shell-hud refresh`:"visa-cli shell-hud refresh"}function Br(e){let t=process.argv[1]?f.resolve(process.argv[1]):"";return t?e==="powershell"?`((Test-Path ${ke(process.execPath)}) -and (Test-Path ${ke(t)}))`:`[ -x ${Ee(process.execPath)} ] && [ -f ${Ee(t)} ]`:e==="powershell"?"Get-Command visa-cli -ErrorAction SilentlyContinue -CommandType Application":"command -v visa-cli >/dev/null 2>&1"}function Ee(e){return`'${e.replace(/'/g,"'\\''")}'`}function ke(e){return`'${e.replace(/'/g,"''")}'`}function Kr(e){for(let t=0;t<2;t+=1){let n;try{return n=m.openSync(e,"wx"),m.writeFileSync(n,String(Date.now())),!0}catch(r){if(r?.code!=="EEXIST")return!1;try{let o=m.statSync(e);if(Date.now()-o.mtimeMs<=Ur)return!1;m.unlinkSync(e)}catch{}}finally{n!==void 0&&m.closeSync(n)}}return!1}function sn(e){return e instanceof Error?e.message:"unknown file system error"}function Re(e,t){m.mkdirSync(f.dirname(e),{recursive:!0});let n=`${e}.${process.pid}.${Date.now()}.tmp`;m.writeFileSync(n,t),m.renameSync(n,e)}Se();var $=class extends Error{constructor(t){super(t),this.name="PayValidationError"}},an=["GET","POST"];function cn(e){let t;try{t=new URL(e)}catch{throw new $(`Invalid URL: ${e}. Expected a fully-qualified http(s) URL.`)}if(t.protocol!=="http:"&&t.protocol!=="https:")throw new $(`Unsupported URL scheme "${t.protocol}". Only http and https are allowed.`);return t}function ln(e){let t=(e??"GET").toUpperCase();if(!an.includes(t))throw new $(`Unsupported HTTP method "${e}". Supported: ${an.join(", ")}.`);return t}function un(e){if(e!==void 0){try{JSON.parse(e)}catch(t){throw new $(`--body is not valid JSON: ${t?.message??"parse error"}`)}return e}}function dn(e){if(!e||typeof e!="object")throw new $("Merchant returned no payment preview.");let t=e;if(typeof t.amount!="number"||!Number.isFinite(t.amount)||t.amount<=0)throw new $("Could not determine payment amount from merchant.");if(typeof t.merchantName!="string"||t.merchantName.trim().length===0)throw new $("Merchant returned an empty merchant name.");if(t.merchantName.length>200)throw new $(`Merchant name too long (${t.merchantName.length} chars).`);if(typeof t.currency!="string"||t.currency.trim().length===0)throw new $("Merchant returned an empty currency.");if(t.currency.length>10)throw new $(`Currency code too long (${t.currency.length} chars).`);return{amount:t.amount,currency:t.currency,merchantName:t.merchantName}}var g=p(require("fs")),d=p(require("path")),mn=p(require("os")),w=mn.homedir(),I=[{id:"claude",displayName:"Claude Code",globalConfigPath:d.join(w,".claude.json"),configKey:"mcpServers",detectPaths:[d.join(w,".claude.json")],postInstallHint:"Restart Claude Code or run /mcp to connect."},{id:"claude-desktop",displayName:"Claude Desktop",globalConfigPath:d.join(w,"Library","Application Support","Claude","claude_desktop_config.json"),configKey:"mcpServers",detectPaths:[d.join(w,"Library","Application Support","Claude")],postInstallHint:"Restart the Claude desktop app to connect."},{id:"cursor",displayName:"Cursor",globalConfigPath:d.join(w,".cursor","mcp.json"),configKey:"mcpServers",detectPaths:[d.join(w,".cursor")],postInstallHint:"Restart Cursor to connect."},{id:"windsurf",displayName:"Windsurf",globalConfigPath:d.join(w,".codeium","windsurf","mcp_config.json"),configKey:"mcpServers",detectPaths:[d.join(w,".codeium","windsurf")],postInstallHint:"Restart Windsurf to connect."},{id:"cline",displayName:"Cline",globalConfigPath:d.join(w,".vscode","mcp.json"),configKey:"mcpServers",detectPaths:[d.join(w,".vscode","extensions","saoudrizwan.claude-dev-*")],postInstallHint:"Restart VS Code to connect."},{id:"roo-code",displayName:"Roo Code",globalConfigPath:d.join(w,".config","Roo","mcp_settings.json"),configKey:"mcpServers",detectPaths:[d.join(w,".vscode","extensions","RooVeterinaryInc.roo-cline-*")],postInstallHint:"Restart VS Code to connect."},{id:"copilot",displayName:"VS Code Copilot",globalConfigPath:d.join(w,".vscode","mcp.json"),configKey:"servers",detectPaths:[d.join(w,".vscode")],postInstallHint:"Restart VS Code to connect."},{id:"zed",displayName:"Zed",globalConfigPath:d.join(w,".config","zed","settings.json"),configKey:"context_servers",detectPaths:[d.join(w,".config","zed")],postInstallHint:"Restart Zed to connect.",buildEntry:e=>({source:"custom",...e})}];function at(e){return I.find(t=>t.id===e)}function ae(e){return e.detectPaths.some(t=>{if(t.includes("*")){let n=d.dirname(t),r=d.basename(t).replaceAll("*","");if(!g.existsSync(n))return!1;try{return g.readdirSync(n).some(o=>o.startsWith(r))}catch{return!1}}return g.existsSync(t)})}function pn(){return{command:"node",args:[d.resolve(__dirname,"mcp-server/index.js")]}}function ce(e,t="global"){let n=t==="project"?d.join(process.cwd(),".mcp.json"):e.globalConfigPath,r=d.dirname(n);g.existsSync(r)||g.mkdirSync(r,{recursive:!0});let o={};if(g.existsSync(n))try{o=JSON.parse(g.readFileSync(n,"utf-8"))}catch{o={}}o[e.configKey]=o[e.configKey]||{};let s=pn();return o[e.configKey]["visa-cli"]=e.buildEntry?e.buildEntry(s):s,g.writeFileSync(n,JSON.stringify(o,null,2)+`
108
108
  `),{installed:!0,configPath:n,message:e.postInstallHint}}function ct(e,t="global"){let n=t==="project"?d.join(process.cwd(),".mcp.json"):e.globalConfigPath;if(!g.existsSync(n))return{removed:!1,configPath:n};let r;try{r=JSON.parse(g.readFileSync(n,"utf-8"))}catch{return{removed:!1,configPath:n}}let o=r[e.configKey];return!o||!o["visa-cli"]?{removed:!1,configPath:n}:(delete o["visa-cli"],g.writeFileSync(n,JSON.stringify(r,null,2)+`
109
109
  `),{removed:!0,configPath:n})}function gn(e,t="global"){let n=t==="project"?d.join(process.cwd(),".mcp.json"):e.globalConfigPath;if(!g.existsSync(n))return!1;try{return!!JSON.parse(g.readFileSync(n,"utf-8"))?.[e.configKey]?.["visa-cli"]}catch{return!1}}function Gr(e){if(!e||typeof e!="object")return;let t=e;if(t.command!=="node"||!Array.isArray(t.args)||t.args.length===0)return;let n=t.args[t.args.length-1];if(!(typeof n!="string"||n.length===0))return n}function Wr(e,t){if(e===t)return!0;let n=d.resolve(e),r=d.resolve(t);if(n===r)return!0;try{let o=g.realpathSync(n),s=g.realpathSync(r);return o===s}catch{return!1}}function le(){let e=pn(),t=e.args[e.args.length-1],n=[];for(let r of I){let o=r.globalConfigPath;if(!g.existsSync(o))continue;let s;try{s=JSON.parse(g.readFileSync(o,"utf-8"))}catch{continue}let i=s?.[r.configKey]?.["visa-cli"];if(!i)continue;let a=Gr(i);if(!a||Wr(a,t))continue;let c=g.existsSync(a)?"mismatch":"missing";n.push({client:r,configPath:o,currentPath:a,expectedPath:t,staleReason:c})}return n}function lt(e){return{configPath:ce(e.client,"global").configPath}}var ao=(0,Vn.promisify)(qn.execFile);function co(e){let t=ee.homedir(),n=o=>o.replace(t,"~"),r=e.staleReason==="missing"?"path missing on disk":"path mismatch";return` \u2022 ${e.client.displayName} (${n(e.configPath)})
110
- ${r}: ${n(e.currentPath)}`}function Bn(e,t){if(e.length===0){console.log(`${t} \u2713 All MCP client configs are up to date.`);return}console.log(`${t} Found ${e.length} stale MCP config ${e.length===1?"entry":"entries"}:`);for(let n of e)console.log(co(n))}var x=new Fn.Command,Le=null,ue=!1;function de(){return Le=new N(()=>_.getSessionToken()),Le}x.name("visa-cli").description("Visa CLI - AI payment orchestration").version(Be().version);x.hook("preAction",async()=>{await yt()});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 e=>{try{if(e.check){let l=le();Bn(l,"MCP config check:"),l.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 t=le(),n=new Map(t.map(l=>[l.client.id,l])),r=new Set;for(let l of I)if(ae(l)){let u=ce(l),h=n.get(l.id),k=h?` \u2014 repaired stale ${h.staleReason} entry`:"";console.log(` \u2713 ${l.displayName} (${u.configPath.replace(ee.homedir(),"~")})${k}`),h&&r.add(l.id)}let o=t.filter(l=>!r.has(l.client.id));for(let l of o)lt(l),console.log(` \u2713 ${l.client.displayName} (${l.configPath.replace(ee.homedir(),"~")}) \u2014 repaired stale ${l.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(`
111
- Step 2: Checking authentication...`);let i=await _.getSessionToken();if(i?console.log(" Already authenticated."):(console.log(" No session found. Opening browser for GitHub login..."),i=await new Promise(async(l,u)=>{let h=Ne.randomBytes(16).toString("hex"),k=`https://auth.visacli.sh/login?state=${h}`;await bt(k);let P=3e4,q=300*1e3,V=Date.now()+q;for(;Date.now()<V;)try{let R=await globalThis.fetch("https://auth.visacli.sh/v1/auth-status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:h,timeout:P}),signal:AbortSignal.timeout(P+5e3)});if(!R.ok)continue;let b=await R.json();if(b.status==="pending")continue;if(b.status==="expired"){u(new Error("Session expired. Please run setup again."));return}if(b.status==="complete"&&b.sessionToken){console.log(` Signed in as ${b.user}.`),l(b.sessionToken);return}}catch{}u(new Error("Login timed out after 5 minutes. Please run setup again."))}),await _.saveSessionToken(i),console.log(" Session token saved.")),console.log(`
110
+ ${r}: ${n(e.currentPath)}`}function Bn(e,t){if(e.length===0){console.log(`${t} \u2713 All MCP client configs are up to date.`);return}console.log(`${t} Found ${e.length} stale MCP config ${e.length===1?"entry":"entries"}:`);for(let n of e)console.log(co(n))}var P=new Fn.Command,Le=null,ue=!1;function de(){return Le=new N(()=>_.getSessionToken()),Le}P.name("visa-cli").description("Visa CLI - AI payment orchestration").version(Be().version);P.hook("preAction",async()=>{await yt()});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 e=>{try{if(e.check){let l=le();Bn(l,"MCP config check:"),l.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 t=le(),n=new Map(t.map(l=>[l.client.id,l])),r=new Set;for(let l of I)if(ae(l)){let u=ce(l),h=n.get(l.id),k=h?` \u2014 repaired stale ${h.staleReason} entry`:"";console.log(` \u2713 ${l.displayName} (${u.configPath.replace(ee.homedir(),"~")})${k}`),h&&r.add(l.id)}let o=t.filter(l=>!r.has(l.client.id));for(let l of o)lt(l),console.log(` \u2713 ${l.client.displayName} (${l.configPath.replace(ee.homedir(),"~")}) \u2014 repaired stale ${l.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(`
111
+ Step 2: Checking authentication...`);let i=await _.getSessionToken();if(i?console.log(" Already authenticated."):(console.log(" No session found. Opening browser for GitHub login..."),i=await new Promise(async(l,u)=>{let h=Ne.randomBytes(16).toString("hex"),k=`https://auth.visacli.sh/login?state=${h}`;await bt(k);let x=3e4,q=300*1e3,V=Date.now()+q;for(;Date.now()<V;)try{let R=await globalThis.fetch("https://auth.visacli.sh/v1/auth-status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:h,timeout:x}),signal:AbortSignal.timeout(x+5e3)});if(!R.ok)continue;let b=await R.json();if(b.status==="pending")continue;if(b.status==="expired"){u(new Error("Session expired. Please run setup again."));return}if(b.status==="complete"&&b.sessionToken){console.log(` Signed in as ${b.user}.`),l(b.sessionToken);return}}catch{}u(new Error("Login timed out after 5 minutes. Please run setup again."))}),await _.saveSessionToken(i),console.log(" Session token saved.")),console.log(`
112
112
  Step 3: Setting up authentication...`),!Y())console.log(" Not macOS \u2014 skipping biometric setup.");else{try{await ao("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 l=await Dt();console.log(" Attestation key generated."),await de().registerAttestationKey(l),console.log(" Attestation key registered with server.")}catch(l){console.log(` Skipped: ${l.message}`)}}let a="\x1B[1m",c="\x1B[0m";console.log(`
113
113
  \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557
114
114
  \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
@@ -126,15 +126,15 @@ Step 3: Setting up authentication...`),!Y())console.log(" Not macOS \u2014 ski
126
126
 
127
127
  ${a}Verify:${c} visa-cli status
128
128
  ${a}Docs:${c} https://visacli.sh
129
- `)}catch(t){console.error("Error:",t.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(e,t)=>{try{if(t.check){let s=le();Bn(s,"MCP config check:"),s.length>0&&process.exit(1);return}if(t.repair){let s=le();if(s.length===0){console.log("\u2713 MCP config verified \u2014 nothing to repair.");return}for(let i of s)lt(i),console.log(` \u2713 ${i.client.displayName} (${i.configPath.replace(ee.homedir(),"~")}) \u2014 repaired stale ${i.staleReason} entry`);console.log(`
129
+ `)}catch(t){console.error("Error:",t.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(e,t)=>{try{if(t.check){let s=le();Bn(s,"MCP config check:"),s.length>0&&process.exit(1);return}if(t.repair){let s=le();if(s.length===0){console.log("\u2713 MCP config verified \u2014 nothing to repair.");return}for(let i of s)lt(i),console.log(` \u2713 ${i.client.displayName} (${i.configPath.replace(ee.homedir(),"~")}) \u2014 repaired stale ${i.staleReason} entry`);console.log(`
130
130
  Repaired ${s.length} stale MCP config ${s.length===1?"entry":"entries"}.`);return}if(t.list){console.log(`
131
131
  \x1B[1mSupported MCP Clients\x1B[0m
132
132
  `),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 a of I){let c=ae(a),l=gn(a),u=c?"Yes":"No",h=l?"Yes":"No",k=a.globalConfigPath.replace(ee.homedir(),"~");console.log(` ${a.displayName.padEnd(18)} ${u.padEnd(10)} ${h.padEnd(11)} ${k}`)}console.log("");return}let n=t.scope==="project"?"project":"global";if(t.all){let s=[],i=[];for(let a of I){if(!ae(a)){i.push(a.displayName);continue}ce(a,n),s.push(a.displayName)}s.length>0&&console.log(`Installed for: ${s.join(", ")}.`),i.length>0&&console.log(`Skipped: ${i.map(a=>`${a} (not detected)`).join(", ")}.`),s.length===0&&i.length===0&&console.log("No supported clients found.");return}e||(console.error("Usage: visa-cli install <client>"),console.error(" visa-cli install --all"),console.error(" visa-cli install --list"),console.error(`
133
- Supported clients: ${I.map(s=>s.id).join(", ")}`),process.exit(1));let r=at(e);r||(console.error(`Unknown client: ${e}`),console.error(`Supported clients: ${I.map(s=>s.id).join(", ")}`),process.exit(1)),n==="global"&&!ae(r)&&(console.error(`${r.displayName} not detected on this machine.`),console.error(`Expected: ${r.detectPaths.join(", ")}`),process.exit(1));let o=ce(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(e,t)=>{try{let n=t.scope==="project"?"project":"global";if(t.all){let s=[];for(let i of I)ct(i,n).removed&&s.push(i.displayName);s.length>0?console.log(`Removed visa-cli from: ${s.join(", ")}.`):console.log("visa-cli was not installed in any client.");return}e||(console.error("Usage: visa-cli uninstall <client>"),console.error(" visa-cli uninstall --all"),console.error(`
134
- Supported clients: ${I.map(s=>s.id).join(", ")}`),process.exit(1));let r=at(e);r||(console.error(`Unknown client: ${e}`),console.error(`Supported clients: ${I.map(s=>s.id).join(", ")}`),process.exit(1));let o=ct(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(e,t)=>{try{cn(e);let n=ln(t.method),r=un(t.body),o=new N(()=>_.getSessionToken());console.log(`Checking payment for ${e}...`);let s=dn(await o.paymentPreview({url:e}));console.log(` Merchant: ${s.merchantName}`),console.log(` Amount: $${s.amount.toFixed(2)} ${s.currency}`),console.log(` Rail: auto-detected
135
- `);let i;if(Y())try{let{nonce:c}=await o.getAttestationChallenge(),l=Buffer.from(JSON.stringify({nonce:c,amount:s.amount,merchant:s.merchantName,context:e})).toString("base64");i={signature:await xe(l,`pay $${s.amount.toFixed(2)} to ${s.merchantName}`),nonce:c,amount:s.amount,merchant:s.merchantName}}catch(c){console.error(`Touch ID confirmation failed: ${c?.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 a=await o.pay({url:e,method:n,body:r,attestation:i,idempotencyKey:Ne.randomUUID()});if(a.success){if(console.log(`Payment complete: $${(a.amount??s.amount).toFixed(2)} \u2192 ${a.merchantName??s.merchantName}`),a.receipt?.urls?.length){console.log(`
136
- Result URLs:`);for(let c of a.receipt.urls)console.log(` ${c}`)}}else console.error(`Payment failed: ${a.message||"Unknown error"}`),process.exit(1)}catch(n){n instanceof $?console.error(`Error: ${n.message}`):console.error("Error:",n.message),process.exit(1)}});x.command("status").alias("hud").description("Check enrollment, cards, wallet, and spending controls").action(async()=>{ue=!1;try{let e=de(),t=await e.getStatus(),n={currentVersion:e.getClientVersion(),latestVersion:e.lastSignals.updateAvailable?.version,updateMessage:e.lastSignals.updateAvailable?.message,updateCheckDisabled:W()},r=await e.getTransactions().catch(o=>{if(process.env.VISA_CLI_DEBUG){let s=o instanceof Error?o.message:String(o);process.stderr.write(`[visa-cli] getTransactions failed (HUD will omit): ${s}
137
- `)}return{transactions:[]}});process.stdout.write(qt(t,Array.isArray(r?.transactions)?r.transactions:[],Y(),n)),ue=!0}catch(e){ue=!1,console.error("Error:",e.message),process.exit(1)}});x.command("reset").description("Log out and clear all credentials").action(async()=>{try{console.log(`Resetting Visa CLI...
133
+ Supported clients: ${I.map(s=>s.id).join(", ")}`),process.exit(1));let r=at(e);r||(console.error(`Unknown client: ${e}`),console.error(`Supported clients: ${I.map(s=>s.id).join(", ")}`),process.exit(1)),n==="global"&&!ae(r)&&(console.error(`${r.displayName} not detected on this machine.`),console.error(`Expected: ${r.detectPaths.join(", ")}`),process.exit(1));let o=ce(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(e,t)=>{try{let n=t.scope==="project"?"project":"global";if(t.all){let s=[];for(let i of I)ct(i,n).removed&&s.push(i.displayName);s.length>0?console.log(`Removed visa-cli from: ${s.join(", ")}.`):console.log("visa-cli was not installed in any client.");return}e||(console.error("Usage: visa-cli uninstall <client>"),console.error(" visa-cli uninstall --all"),console.error(`
134
+ Supported clients: ${I.map(s=>s.id).join(", ")}`),process.exit(1));let r=at(e);r||(console.error(`Unknown client: ${e}`),console.error(`Supported clients: ${I.map(s=>s.id).join(", ")}`),process.exit(1));let o=ct(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(e,t)=>{try{cn(e);let n=ln(t.method),r=un(t.body),o=new N(()=>_.getSessionToken());console.log(`Checking payment for ${e}...`);let s=dn(await o.paymentPreview({url:e}));console.log(` Merchant: ${s.merchantName}`),console.log(` Amount: $${s.amount.toFixed(2)} ${s.currency}`),console.log(` Rail: auto-detected
135
+ `);let i;if(Y())try{let{nonce:c}=await o.getAttestationChallenge(),l=Buffer.from(JSON.stringify({nonce:c,amount:s.amount,merchant:s.merchantName,context:e})).toString("base64");i={signature:await Pe(l,`pay $${s.amount.toFixed(2)} to ${s.merchantName}`),nonce:c,amount:s.amount,merchant:s.merchantName}}catch(c){console.error(`Touch ID confirmation failed: ${c?.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 a=await o.pay({url:e,method:n,body:r,attestation:i,idempotencyKey:Ne.randomUUID()});if(a.success){if(console.log(`Payment complete: $${(a.amount??s.amount).toFixed(2)} \u2192 ${a.merchantName??s.merchantName}`),a.receipt?.urls?.length){console.log(`
136
+ Result URLs:`);for(let c of a.receipt.urls)console.log(` ${c}`)}}else console.error(`Payment failed: ${a.message||"Unknown error"}`),process.exit(1)}catch(n){n instanceof $?console.error(`Error: ${n.message}`):console.error("Error:",n.message),process.exit(1)}});P.command("status").alias("hud").description("Check enrollment, cards, wallet, and spending controls").action(async()=>{ue=!1;try{let e=de(),t=await e.getStatus(),n={currentVersion:e.getClientVersion(),latestVersion:e.lastSignals.updateAvailable?.version,updateMessage:e.lastSignals.updateAvailable?.message,updateCheckDisabled:W()},r=await e.getTransactions().catch(o=>{if(process.env.VISA_CLI_DEBUG){let s=o instanceof Error?o.message:String(o);process.stderr.write(`[visa-cli] getTransactions failed (HUD will omit): ${s}
137
+ `)}return{transactions:[]}});process.stdout.write(qt(t,Array.isArray(r?.transactions)?r.transactions:[],Y(),n)),ue=!0}catch(e){ue=!1,console.error("Error:",e.message),process.exit(1)}});P.command("reset").description("Log out and clear all credentials").action(async()=>{try{console.log(`Resetting Visa CLI...
138
138
  `);try{await de().logout(),console.log(" Server session invalidated.")}catch{console.log(" Server logout skipped (no active session).")}if(await _.clearAll(),console.log(" Keychain credentials cleared."),Y())try{await et(),console.log(" Secure Enclave key deleted.")}catch{console.log(" No Secure Enclave key to delete.")}console.log(`
139
- Reset complete.`)}catch(e){console.error("Error:",e.message),process.exit(1)}});x.command("feedback").description("Submit feedback about Visa CLI").argument("[message]","Your feedback message").action(async e=>{(!e||e.trim().length===0)&&(console.log('Usage: visa-cli feedback "your message"'),process.exit(1));try{await _.getSessionToken()||(console.error("Not logged in. Run visa-cli setup first."),process.exit(1)),await de().feedback(e.trim()),console.log("Feedback submitted. Thanks!")}catch(t){console.error("Error:",t.message),process.exit(1)}});var te=x.command("shell-hud").description("Manage the persistent Visa HUD shown in your shell prompt");function Kn(){let e=Xt();e.installed||(console.error(e.message),process.exit(1)),console.log(e.message)}function Gn(){let e=Zt();e.removed||(console.error(e.message),process.exit(1)),console.log(e.message)}te.command("install").description("Install the persistent shell HUD into your zsh or bash rc file").action(Kn);te.command("enable").description("Enable the persistent shell HUD").action(Kn);te.command("uninstall").description("Remove the persistent shell HUD from your shell rc file").action(Gn);te.command("disable").description("Disable the persistent shell HUD").action(Gn);te.command("segment").description("Print the cached shell HUD segment").action(()=>{process.stdout.write(`${tn()}
140
- `)});te.command("refresh").description("Refresh the shell HUD cache (no-op if cache is fresh unless --force)").option("--force","Bypass the cache freshness gate and always refresh").action(async e=>{if(!(!e.force&&en()))try{let t=de(),n=await t.getStatus(),r={currentVersion:t.getClientVersion(),latestVersion:t.lastSignals.updateAvailable?.version,updateMessage:t.lastSignals.updateAvailable?.message,updateCheckDisabled:W()},o=Qt(n,r);nn(o)}catch{}finally{se()}});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 e=>{let{startClient:t}=await Promise.resolve().then(()=>(Hn(),jn));await t({model:e.model})});x.hook("postAction",()=>{if(ue){ue=!1;return}Le&&Ht(Le.lastSignals)});x.parse();
139
+ Reset complete.`)}catch(e){console.error("Error:",e.message),process.exit(1)}});P.command("feedback").description("Submit feedback about Visa CLI").argument("[message]","Your feedback message").action(async e=>{(!e||e.trim().length===0)&&(console.log('Usage: visa-cli feedback "your message"'),process.exit(1));try{await _.getSessionToken()||(console.error("Not logged in. Run visa-cli setup first."),process.exit(1)),await de().feedback(e.trim()),console.log("Feedback submitted. Thanks!")}catch(t){console.error("Error:",t.message),process.exit(1)}});var te=P.command("shell-hud").description("Manage the persistent Visa HUD shown in your shell prompt");function Kn(){let e=Xt();e.installed||(console.error(e.message),process.exit(1)),console.log(e.message)}function Gn(){let e=Zt();e.removed||(console.error(e.message),process.exit(1)),console.log(e.message)}te.command("install").description("Install the persistent shell HUD into your zsh or bash rc file").action(Kn);te.command("enable").description("Enable the persistent shell HUD").action(Kn);te.command("uninstall").description("Remove the persistent shell HUD from your shell rc file").action(Gn);te.command("disable").description("Disable the persistent shell HUD").action(Gn);te.command("segment").description("Print the cached shell HUD segment").action(()=>{process.stdout.write(`${tn()}
140
+ `)});te.command("refresh").description("Refresh the shell HUD cache (no-op if cache is fresh unless --force)").option("--force","Bypass the cache freshness gate and always refresh").action(async e=>{if(!(!e.force&&en()))try{let t=de(),n=await t.getStatus(),r={currentVersion:t.getClientVersion(),latestVersion:t.lastSignals.updateAvailable?.version,updateMessage:t.lastSignals.updateAvailable?.message,updateCheckDisabled:W()},o=Qt(n,r);nn(o)}catch{}finally{se()}});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 e=>{let{startClient:t}=await Promise.resolve().then(()=>(Hn(),jn));await t({model:e.model})});P.hook("postAction",()=>{if(ue){ue=!1;return}Le&&Ht(Le.lastSignals)});P.parse();