@aiiware/aii 0.18.7 → 0.18.8
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/bin/aii +9 -9
- package/package.json +1 -1
package/bin/aii
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @aiiware/aii v0.18.
|
|
3
|
+
* @aiiware/aii v0.18.8
|
|
4
4
|
*
|
|
5
5
|
* AI-powered CLI assistant for terminal productivity
|
|
6
6
|
*
|
|
@@ -204,7 +204,7 @@ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.pus
|
|
|
204
204
|
Open this URL to sign in:
|
|
205
205
|
${p.verify_url}
|
|
206
206
|
`),n(p.verify_url),i(" Waiting for authentication... (press Ctrl+C to cancel)");let f=Math.max(1,p.interval||2)*1e3,h=fye(p.expires_at,o());for(;;){try{let g=await c(p.poll_url);if(g.ok){let _=JSON.parse(g.text);if(_.status==="completed"&&_.api_key)return{apiKey:_.api_key};if(_.status==="expired")throw new La("The sign-in code expired. Run the command again to retry.")}}catch(g){if(g instanceof La)throw g}if(o()>=h)throw new La("Timed out waiting for sign-in. Run the command again to retry.");await s(f)}}var La,dye,gd=A(()=>{"use strict";La=class extends Error{constructor(e){super(e),this.name="DeviceAuthError"}},dye=3e5});var C4={};he(C4,{configureLogger:()=>H1,debug:()=>j,error:()=>T4,formatError:()=>j1,info:()=>y4,logger:()=>P,success:()=>b4,warn:()=>S4});function H1(t){ah={...ah,...t}}function lh(t){return ah.emojis?t+" ":""}function sc(t,e){return ah.colors?e(t):t}function j(t,...e){ah.debug&&console.debug(sc(`[DEBUG] ${t}`,m.gray),...e)}function y4(t,...e){console.log(t,...e)}function S4(t,...e){console.warn(sc(`${lh("\u26A0\uFE0F")}${t}`,m.yellow),...e)}function T4(t,...e){console.error(sc(`${lh("\u274C")}${t}`,m.red),...e)}function b4(t,...e){console.log(sc(`${lh("\u2705")}${t}`,m.green),...e)}function j1(t){let e=[];return e.push(sc(`${lh("\u274C")}${t.message}`,m.red)),t.suggestions&&t.suggestions.length>0&&(e.push(""),e.push(sc(`${lh("\u{1F4A1}")}Solutions:`,m.yellow)),t.suggestions.forEach((r,n)=>{e.push(sc(` ${n+1}. ${r}`,m.gray))})),e.join(`
|
|
207
|
-
`)}var hye,ah,P,ct=A(()=>{"use strict";_e();hye={debug:!1,colors:!0,emojis:!0},ah={...hye};P={debug:j,info:y4,warn:S4,error:T4,success:b4,formatError:j1,configure:H1}});function w4(t){return typeof t=="number"&&Number.isInteger(t)&&t>0?t:1}function Y1(t,e){if(typeof t!="object"||t===null)return{kind:"malformed",reason:"frame is not an object"};let r=t.type;return typeof r!="string"?{kind:"malformed",reason:'frame has no string "type"'}:e.has(r)?{kind:"ok",frame:t}:{kind:"unknown",type:r,protocolVersion:w4(t.protocol_version)}}function v4(t){if(typeof t!="object"||t===null||typeof t.type=="string")return null;let e=t.error;return typeof e!="string"||e===""?null:{unknown_model:"That model is not available on Aii Cloud. Pick a model from your cloud dashboard (cloud.aiiware.com) or run with --local.",insufficient_credits:"Out of Aii Cloud credits. Top up to continue, or run with --local.",quota_exceeded:"Daily free-tier limit reached on Aii Cloud. Try again later, upgrade, or run with --local.",quota_check_failed:"Aii Cloud could not verify your quota \u2014 please retry.",worker_unavailable:"Aii Cloud is temporarily unavailable \u2014 please retry, or run with --local."}[e]??`Aii Cloud error: ${e}`}function ZA(t){return t==null||typeof t=="object"}function V1(t){switch(t.type){case"tool_request":return ZA(t.input);case"mcp_tool_request":return ZA(t.params);case"tool_batch_request":{let e=t.tools;return e==null||Array.isArray(e)&&e.every(r=>r==null||typeof r=="object"&&ZA(r.input))}default:return!0}}function K1(t){return w4(t)>2?"hard":"compatible"}function Q1(t){return`This Aii Server speaks protocol v${t}, but your CLI speaks v2. Some responses may not work correctly. Update with: aii upgrade`}var k4,A4,W1,eI=A(()=>{"use strict";k4=new Set(["token","complete","error","mcp_query_tools","mcp_tool_request","reasoning","reasoning_label","web_search_started","web_search_completed","follow_ups","task.step.updated","task.artifact.added"]),A4=new Set(["session_started","turn_ready","token","iteration_tokens_usage","tool_request","tool_batch_request","tool_status","complete","error","mcp_tools_loaded","permission_request","permission_resolution","mcp_query_tools","mcp_tool_request","reasoning","reasoning_label","web_search_started","web_search_completed","follow_ups","task.step.updated","task.artifact.added"]),W1=new Set(["tool_request","tool_batch_request","mcp_tool_request"])});var rI={};he(rI,{MCPConfigManager:()=>er,MCP_CATALOG:()=>oc});import*as hs from"fs";import*as X1 from"path";import*as tI from"os";var oc,er,Fa=A(()=>{"use strict";oc={github:{name:"GitHub",description:"GitHub API integration for repos, issues, PRs, and more",command:"npx",args:["-y","@modelcontextprotocol/server-github"],env:{GITHUB_PERSONAL_ACCESS_TOKEN:"${GITHUB_TOKEN}"},category:"development"},filesystem:{name:"Filesystem",description:"Read/write files on the local filesystem",command:"npx",args:["-y","@modelcontextprotocol/server-filesystem",tI.homedir()],category:"system"},"brave-search":{name:"Brave Search",description:"Web search using Brave Search API",command:"npx",args:["-y","@brave/brave-search-mcp-server"],env:{BRAVE_API_KEY:"${BRAVE_API_KEY}"},category:"search"},sqlite:{name:"SQLite",description:"Query SQLite databases",command:"uvx",args:["mcp-server-sqlite","--db-path","./database.db"],category:"database"},postgres:{name:"PostgreSQL",description:"Query PostgreSQL databases",command:"npx",args:["-y","@anthropic/mcp-server-postgres"],env:{DATABASE_URL:"${DATABASE_URL}"},category:"database"},"chrome-devtools":{name:"Chrome DevTools",description:"Control Chrome browser via DevTools protocol",command:"npx",args:["chrome-devtools-mcp@latest"],category:"browser"},memory:{name:"Memory",description:"Persistent memory storage for conversation context",command:"npx",args:["-y","@modelcontextprotocol/server-memory"],category:"utility"},puppeteer:{name:"Puppeteer",description:"Browser automation with Puppeteer",command:"npx",args:["-y","@anthropic/mcp-server-puppeteer"],category:"browser"}},er=class{configPath;constructor(e){this.configPath=e||X1.join(tI.homedir(),".aii","mcp_servers.json"),this.ensureConfigDir()}ensureConfigDir(){let e=X1.dirname(this.configPath);hs.existsSync(e)||hs.mkdirSync(e,{recursive:!0})}loadConfig(){if(!hs.existsSync(this.configPath))return{mcpServers:{}};try{let e=hs.readFileSync(this.configPath,"utf-8"),r=JSON.parse(e);return typeof r=="object"&&r!==null?r:{mcpServers:{}}}catch{return{mcpServers:{}}}}saveConfig(e){try{return this.ensureConfigDir(),hs.writeFileSync(this.configPath,JSON.stringify(e,null,2),"utf-8"),!0}catch{return!1}}backupConfig(){if(!hs.existsSync(this.configPath))return!0;try{let e=this.configPath+".backup";return hs.copyFileSync(this.configPath,e),!0}catch{return!1}}getConfigPath(){return this.configPath}}});var gye,_ye,Eye,yye,Sye,Tye,bye,ic,J1,$a,nI=A(()=>{"use strict";_e();gye={name:"classic",label:"Classic",description:"Aii jellyfish blue-purple (default)",accentColorName:"#3B82F6",userInputTextColorName:"#93C5FD",colors:{accent:m.hex("#3B82F6"),userInput:m.hex("#3B82F6"),userInputText:m.hex("#93C5FD"),success:m.hex("#22C55E"),warning:m.hex("#EAB308"),error:m.hex("#EF4444"),muted:m.hex("#94A3B8"),dim:m.dim,code:m.hex("#A855F7"),link:m.hex("#3B82F6").underline,heading:m.hex("#A855F7").bold,filePath:m.hex("#3B82F6"),indicator:m.hex("#3B82F6")}},_ye={name:"brand",label:"Brand",description:"aiiware.com official palette",accentColorName:"#4E6BF5",userInputTextColorName:"#A5B4FC",colors:{accent:m.hex("#4E6BF5"),userInput:m.hex("#4E6BF5"),userInputText:m.hex("#A5B4FC"),success:m.hex("#28CA41"),warning:m.hex("#EAB308"),error:m.hex("#EF4444"),muted:m.hex("#94A3B8"),dim:m.dim,code:m.hex("#4E6BF5"),link:m.hex("#4E6BF5").underline,heading:m.hex("#4E6BF5").bold,filePath:m.hex("#4E6BF5"),indicator:m.hex("#4E6BF5")}},Eye={name:"teal",label:"Teal",description:"Original teal accent",accentColorName:"#00BCD4",userInputTextColorName:"#67E8F9",colors:{accent:m.hex("#00BCD4"),userInput:m.hex("#00BCD4"),userInputText:m.hex("#67E8F9"),success:m.hex("#22C55E"),warning:m.hex("#EAB308"),error:m.hex("#EF4444"),muted:m.hex("#94A3B8"),dim:m.dim,code:m.hex("#00BCD4"),link:m.hex("#00BCD4").underline,heading:m.hex("#00BCD4").bold,filePath:m.hex("#00BCD4"),indicator:m.hex("#00BCD4")}},yye={name:"indigo",label:"Indigo",description:"Bright periwinkle-blue",accentColorName:"#6B8AFF",userInputTextColorName:"#A5B4FC",colors:{accent:m.hex("#6B8AFF"),userInput:m.hex("#6B8AFF"),userInputText:m.hex("#A5B4FC"),success:m.hex("#28CA41"),warning:m.hex("#EAB308"),error:m.hex("#EF4444"),muted:m.hex("#94A3B8"),dim:m.dim,code:m.hex("#6B8AFF"),link:m.hex("#6B8AFF").underline,heading:m.hex("#6B8AFF").bold,filePath:m.hex("#6B8AFF"),indicator:m.hex("#6B8AFF")}},Sye={name:"forest",label:"Forest",description:"Natural green",accentColorName:"#22C55E",userInputTextColorName:"#86EFAC",colors:{accent:m.hex("#22C55E"),userInput:m.hex("#22C55E"),userInputText:m.hex("#86EFAC"),success:m.hex("#22C55E"),warning:m.hex("#EAB308"),error:m.hex("#EF4444"),muted:m.hex("#94A3B8"),dim:m.dim,code:m.hex("#22C55E"),link:m.hex("#22C55E").underline,heading:m.hex("#22C55E").bold,filePath:m.hex("#22C55E"),indicator:m.hex("#22C55E")}},Tye={name:"amber",label:"Amber",description:"Warm orange-gold",accentColorName:"#F59E0B",userInputTextColorName:"#FCD34D",colors:{accent:m.hex("#F59E0B"),userInput:m.hex("#F59E0B"),userInputText:m.hex("#FCD34D"),success:m.hex("#22C55E"),warning:m.hex("#EAB308"),error:m.hex("#EF4444"),muted:m.hex("#94A3B8"),dim:m.dim,code:m.hex("#F59E0B"),link:m.hex("#F59E0B").underline,heading:m.hex("#F59E0B").bold,filePath:m.hex("#F59E0B"),indicator:m.hex("#F59E0B")}},bye={name:"grayscale",label:"Grayscale",description:"Accessible, no colors",accentColorName:"white",userInputTextColorName:"#CBD5E1",colors:{accent:m.reset,userInput:m.reset,userInputText:m.hex("#CBD5E1"),success:m.reset,warning:m.reset,error:m.bold,muted:m.dim,dim:m.dim,code:m.reset,link:m.underline,heading:m.bold,filePath:m.reset,indicator:m.bold}},ic={classic:gye,brand:_ye,teal:Eye,indigo:yye,forest:Sye,amber:Tye,grayscale:bye},J1="classic",$a=["classic","brand","teal","indigo","forest","amber","grayscale"]});var ac={};he(ac,{BAND_STYLE_INFO:()=>ch,BAND_STYLE_ORDER:()=>Ua,DEFAULT_BAND_STYLE:()=>oI,ThemeManager:()=>Zs,getAccentColorName:()=>Ae,getThemeColors:()=>q,getUserInputTextColorName:()=>Ed,resolveBandBg:()=>_d});function _d(t,e){let r=ch[t];if(r.blend===null)return Cye;let n=/^#[0-9a-fA-F]{6}$/.test(e)?e:"#8B98A9",s=parseInt(n.replace("#",""),16),o=r.blend,i=(a,l)=>Math.round(a*o+l*(1-o));return"#"+(i(s>>16&255,sI[0])<<16|i(s>>8&255,sI[1])<<8|i(s&255,sI[2])).toString(16).padStart(6,"0")}function q(){return Zs.getInstance().getColors()}function Ae(){return Zs.getInstance().getAccentColorName()}function Ed(){return Zs.getInstance().getUserInputTextColorName()}var Ua,ch,oI,sI,Cye,Zs,Ba=A(()=>{"use strict";nI();ft();Ua=["subtle","themed","neutral","bold"],ch={subtle:{blend:.16,description:"Faint theme tint \u2014 quietest"},themed:{blend:.28,description:"Theme-tinted band (default)"},neutral:{blend:null,description:"Fixed neutral gray (theme-independent)"},bold:{blend:.4,description:"Strong theme tint \u2014 selection-like"}},oI="themed",sI=[20,22,27],Cye="#262C34";Zs=class t{static instance=null;activeTheme;bandStyle=null;constructor(){this.activeTheme=ic[J1]}static getInstance(){return t.instance||(t.instance=new t),t.instance}getTheme(){return this.activeTheme}getColors(){return this.activeTheme.colors}getThemeName(){return this.activeTheme.name}setTheme(e){let r=ic[e];if(!r){let n=$a.join(", ");throw new Error(`Unknown theme: "${e}". Available themes: ${n}`)}this.activeTheme=r}isValidTheme(e){return e in ic}getAvailableThemes(){return $a.map(e=>ic[e])}getAccentColorName(){return this.activeTheme.accentColorName}getUserInputTextColorName(){return this.activeTheme.userInputTextColorName}getBandStyle(){if(this.bandStyle)return this.bandStyle;try{let e=Re().get("theme_band");if(e&&this.isValidBandStyle(e))return this.bandStyle=e,this.bandStyle}catch{}return this.bandStyle=oI,this.bandStyle}setBandStyle(e){if(!this.isValidBandStyle(e))throw new Error(`Unknown band style: "${e}". Available: ${Ua.join(", ")}`);this.bandStyle=e}isValidBandStyle(e){return Ua.includes(e)}reset(){this.activeTheme=ic[J1],this.bandStyle=null}}});var pt=A(()=>{"use strict";nI();Ba()});import{resolve as wye}from"path";function vye(){let t=process.env.TERM??"",e=process.env.TERM_PROGRAM??"",r=process.env.COLORTERM??"",n=process.env.WT_SESSION??"",s=process.env.VSCODE_INJECTION??process.env.TERM_PROGRAM==="vscode";return e==="iTerm.app"||e==="Hyper"||e==="vscode"||e==="WezTerm"||e==="Alacritty"||n||s||t.includes("xterm-256color")||t.includes("screen-256color")||t.includes("tmux")||t==="xterm-kitty"||r==="truecolor"?!0:!(t==="dumb"||!process.stdout.isTTY)}function uh(){return iI===null&&(iI=vye()),iI}function kye(){return process.platform==="darwin"?"Cmd":"Ctrl"}function D4(){return I4||!uh()?"":(I4=!0,` (${kye()}+Click to open)`)}function Aye(t,e){return uh()?`\x1B]8;;${e}\x07${t}\x1B]8;;\x07`:t}function R4(t,e){let r=process.env.HOME??process.env.USERPROFILE??"",n=t;r&&t.startsWith(r)&&(n="~"+t.slice(r.length));let s=e?`${n}:${e}`:n;if(!uh())return q().filePath(s);let o=q().accent(s),a=`file://${wye(t)}`;return e!==void 0&&e>0&&(a+=`#L${e}`),Aye(o,a)}var iI,I4,N4=A(()=>{"use strict";pt();iI=null,I4=!1});var M4={};he(M4,{VERSION:()=>lc,colors:()=>L,formatCode:()=>Lye,formatPath:()=>ph,getActionIndicator:()=>Pye,padEndAnsi:()=>Bye,printAction:()=>Iye,printDivider:()=>x4,printError:()=>xye,printExitSummary:()=>lI,printHeader:()=>Mye,printSuccess:()=>Nye,printToolComplete:()=>Dye,printToolFailed:()=>Rye,printToolResultCompact:()=>Ga,printWarning:()=>Oye,shortenPath:()=>$ye});function dh(t){return t.startsWith("/")||t.startsWith("~/")||t.startsWith("./")||t.startsWith("../")||/^[a-zA-Z]:\\/.test(t)||/\.(ts|tsx|js|jsx|json|md|py|go|rs|java|c|cpp|h|hpp|css|scss|html|xml|yaml|yml|toml|sh|bash|zsh)$/.test(t)||/^src\//.test(t)||/^lib\//.test(t)||/^test[s]?\//.test(t)}function Iye(t,e,r=console.log){let n=dh(e)?ph(e):L.filePath(e);r(L.dim("\u25CB ")+m.bold(t)+" "+n)}function Dye(t,e,r=console.log){let n=dh(e)?ph(e):L.filePath(e);r(L.success("\u2713 ")+m.bold(t)+" "+n)}function Rye(t,e,r,n=console.log){let s=dh(e)?ph(e):L.filePath(e);n(L.error("\u2717 ")+m.bold(t)+" "+s),r&&n(L.dim(" \u2192 ")+L.error(r))}function Ga(t,e,r=!0,n,s=console.log,o=!0){let i=r?L.success("\u25CF"):L.error("\u25CF"),a=60,l=e.length>a?e.slice(0,a-3)+"...":e;if(dh(e)){let d=e.match(/:(\d+)$/),p=d?parseInt(d[1],10):void 0,f=d?e.replace(/:(\d+)$/,""):e;l=ph(f,p)}s(`${i} ${m.bold(t)}(${l})`);let c=o&&dh(e)?L.dim(D4()):"",u=o&&!c&&!O4?L.dim(" (ctrl+o to expand)"):"";if(u&&(O4=!0),n){let d=r?L.dim:L.error;s(d(`\u2514 ${n}`)+c+u)}else{let d=r?"(No content)":"(Error)",p=r?L.dim:L.error;s(p(`\u2514 ${d}`)+c+u)}}function Nye(t){console.log(L.success("\u2713 ")+t)}function Oye(t){console.log(L.warning("\u26A0 ")+t)}function xye(t){console.log(L.error("\u2717 ")+t)}function x4(t=60){console.log(L.dim("\u2500".repeat(t)))}function Mye(t){console.log(L.logo(t)),x4(t.length)}function Pye(t){return L.thinking(`[${t}]`)}function ph(t,e){if(uh())return R4(t,e);let r=process.env.HOME??process.env.USERPROFILE??"",n=t;return r&&t.startsWith(r)&&(n="~"+t.slice(r.length)),e&&(n+=`:${e}`),L.filePath(n)}function Lye(t){return L.code(t)}function Fye(){return process.stdout.columns||80}function $ye(t,e=40){let r=process.env.HOME??process.env.USERPROFILE??"",n=t;if(r&&t.startsWith(r)&&(n="~"+t.slice(r.length)),n.length<=e)return n;let s=n.split("/").filter(i=>i.length>0);if(s.length>=2){let i=s.slice(-2).join("/");if(i.length<=e-4)return".../"+i}return".../"+(s[s.length-1]||s[s.length-2])}function Uye(t){return t.replace(/\x1b\[[0-9;]*m/g,"").length}function Bye(t,e){let r=Uye(t),n=Math.max(0,e-r);return t+" ".repeat(n)}function Gye(t){if(t<60)return`${t}s`;let e=Math.floor(t/60),r=t%60;return r>0?`${e}m ${r}s`:`${e}m`}function aI(t){return t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function lI(t){let e=Fye(),r=Math.min(e-2,76),n=r-4,s=(g,_)=>{let E=g.replace(/\x1b\[[0-9;]*m/g,"").length;return g+" ".repeat(Math.max(0,_-E))},o=g=>L.border("\u2502")+" "+s(g,n)+" "+L.border("\u2502"),i=(g,_,E,y)=>{let T=Math.floor(n/2),C=L.dim(g.padEnd(15))+_,w=L.dim(E.padEnd(15))+y;return o(s(C,T)+w)},a=Gye(t.durationSeconds),l=aI(t.tokensIn),c=aI(t.tokensOut),u=`$${t.totalCost.toFixed(4)}`,d=t.cloud?`\u2601\uFE0F Cloud \xB7 ${t.model}`:`${t.provider}/${t.model.replace("claude-","").replace("-latest","")}`;console.log(""),console.log(L.border("\u250C"+"\u2500".repeat(r-2)+"\u2510")),console.log(o(L.logo("Session complete. \u{1FABC}"))),console.log(L.border("\u251C"+"\u2500".repeat(r-2)+"\u2524")),console.log(o(L.logo("Session Summary"))),console.log(o(L.dim("\u2500".repeat(15)))),console.log(i("Duration",a,"Tool Calls",t.toolCalls.toString())),console.log(i("Turns",t.turns.toString(),"Files Modified",t.filesModified.toString())),console.log(o("")),console.log(o(L.logo("Token Usage"))),console.log(o(L.dim("\u2500".repeat(11)))),console.log(i("Input",l,"Output",c));let p=t.cachedTokens??0;if(p>0){let g=Math.min(100,Math.round(100*p/Math.max(1,t.tokensIn)));console.log(o(L.dim("Cached".padEnd(15))+`${aI(p)} (${g}%)`))}let f=t.cacheSavings??0,h=f>0?L.dim(` \xB7 saved ~$${f.toFixed(4)} by prompt caching`):"";console.log(o(L.dim("Cost".padEnd(15))+u+h)),console.log(o("")),t.goalLine&&console.log(o(L.dim("Goal: ")+t.goalLine.replace(/^Goal:\s*/,""))),console.log(o(L.dim("Model: ")+L.model(d))),console.log(L.border("\u2514"+"\u2500".repeat(r-2)+"\u2518")),console.log("")}var lc,L,O4,lr=A(()=>{"use strict";_e();N4();pt();lc="0.18.7",L={get logo(){return q().accent.bold},get prompt(){return q().accent.bold},get model(){return q().accent},get success(){return q().success},get warning(){return q().warning},get error(){return q().error},get thinking(){return q().dim},get filePath(){return q().filePath},get code(){return q().code},get muted(){return q().muted},get dim(){return q().dim},get safe(){return q().success},get risky(){return q().warning},get destructive(){return q().error},get border(){return q().accent},get bannerBorder(){return q().accent}};O4=!1});function cc({onlyFirst:t=!1}={}){let s="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(s,t?void 0:"g")}var Z1=A(()=>{});function cI(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(zye,"")}var zye,P4=A(()=>{Z1();zye=cc()});function L4(t){return t===161||t===164||t===167||t===168||t===170||t===173||t===174||t>=176&&t<=180||t>=182&&t<=186||t>=188&&t<=191||t===198||t===208||t===215||t===216||t>=222&&t<=225||t===230||t>=232&&t<=234||t===236||t===237||t===240||t===242||t===243||t>=247&&t<=250||t===252||t===254||t===257||t===273||t===275||t===283||t===294||t===295||t===299||t>=305&&t<=307||t===312||t>=319&&t<=322||t===324||t>=328&&t<=331||t===333||t===338||t===339||t===358||t===359||t===363||t===462||t===464||t===466||t===468||t===470||t===472||t===474||t===476||t===593||t===609||t===708||t===711||t>=713&&t<=715||t===717||t===720||t>=728&&t<=731||t===733||t===735||t>=768&&t<=879||t>=913&&t<=929||t>=931&&t<=937||t>=945&&t<=961||t>=963&&t<=969||t===1025||t>=1040&&t<=1103||t===1105||t===8208||t>=8211&&t<=8214||t===8216||t===8217||t===8220||t===8221||t>=8224&&t<=8226||t>=8228&&t<=8231||t===8240||t===8242||t===8243||t===8245||t===8251||t===8254||t===8308||t===8319||t>=8321&&t<=8324||t===8364||t===8451||t===8453||t===8457||t===8467||t===8470||t===8481||t===8482||t===8486||t===8491||t===8531||t===8532||t>=8539&&t<=8542||t>=8544&&t<=8555||t>=8560&&t<=8569||t===8585||t>=8592&&t<=8601||t===8632||t===8633||t===8658||t===8660||t===8679||t===8704||t===8706||t===8707||t===8711||t===8712||t===8715||t===8719||t===8721||t===8725||t===8730||t>=8733&&t<=8736||t===8739||t===8741||t>=8743&&t<=8748||t===8750||t>=8756&&t<=8759||t===8764||t===8765||t===8776||t===8780||t===8786||t===8800||t===8801||t>=8804&&t<=8807||t===8810||t===8811||t===8814||t===8815||t===8834||t===8835||t===8838||t===8839||t===8853||t===8857||t===8869||t===8895||t===8978||t>=9312&&t<=9449||t>=9451&&t<=9547||t>=9552&&t<=9587||t>=9600&&t<=9615||t>=9618&&t<=9621||t===9632||t===9633||t>=9635&&t<=9641||t===9650||t===9651||t===9654||t===9655||t===9660||t===9661||t===9664||t===9665||t>=9670&&t<=9672||t===9675||t>=9678&&t<=9681||t>=9698&&t<=9701||t===9711||t===9733||t===9734||t===9737||t===9742||t===9743||t===9756||t===9758||t===9792||t===9794||t===9824||t===9825||t>=9827&&t<=9829||t>=9831&&t<=9834||t===9836||t===9837||t===9839||t===9886||t===9887||t===9919||t>=9926&&t<=9933||t>=9935&&t<=9939||t>=9941&&t<=9953||t===9955||t===9960||t===9961||t>=9963&&t<=9969||t===9972||t>=9974&&t<=9977||t===9979||t===9980||t===9982||t===9983||t===10045||t>=10102&&t<=10111||t>=11094&&t<=11097||t>=12872&&t<=12879||t>=57344&&t<=63743||t>=65024&&t<=65039||t===65533||t>=127232&&t<=127242||t>=127248&&t<=127277||t>=127280&&t<=127337||t>=127344&&t<=127373||t===127375||t===127376||t>=127387&&t<=127404||t>=917760&&t<=917999||t>=983040&&t<=1048573||t>=1048576&&t<=1114109}function F4(t){return t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510}function $4(t){return t>=4352&&t<=4447||t===8986||t===8987||t===9001||t===9002||t>=9193&&t<=9196||t===9200||t===9203||t===9725||t===9726||t===9748||t===9749||t>=9776&&t<=9783||t>=9800&&t<=9811||t===9855||t>=9866&&t<=9871||t===9875||t===9889||t===9898||t===9899||t===9917||t===9918||t===9924||t===9925||t===9934||t===9940||t===9962||t===9970||t===9971||t===9973||t===9978||t===9981||t===9989||t===9994||t===9995||t===10024||t===10060||t===10062||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t===11035||t===11036||t===11088||t===11093||t>=11904&&t<=11929||t>=11931&&t<=12019||t>=12032&&t<=12245||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12353&&t<=12438||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12773||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=42124||t>=42128&&t<=42182||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=94176&&t<=94180||t>=94192&&t<=94198||t>=94208&&t<=101589||t>=101631&&t<=101662||t>=101760&&t<=101874||t>=110576&&t<=110579||t>=110581&&t<=110587||t===110589||t===110590||t>=110592&&t<=110882||t===110898||t>=110928&&t<=110930||t===110933||t>=110948&&t<=110951||t>=110960&&t<=111355||t>=119552&&t<=119638||t>=119648&&t<=119670||t===126980||t===127183||t===127374||t>=127377&&t<=127386||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t===127568||t===127569||t>=127584&&t<=127589||t>=127744&&t<=127776||t>=127789&&t<=127797||t>=127799&&t<=127868||t>=127870&&t<=127891||t>=127904&&t<=127946||t>=127951&&t<=127955||t>=127968&&t<=127984||t===127988||t>=127992&&t<=128062||t===128064||t>=128066&&t<=128252||t>=128255&&t<=128317||t>=128331&&t<=128334||t>=128336&&t<=128359||t===128378||t===128405||t===128406||t===128420||t>=128507&&t<=128591||t>=128640&&t<=128709||t===128716||t>=128720&&t<=128722||t>=128725&&t<=128728||t>=128732&&t<=128735||t===128747||t===128748||t>=128756&&t<=128764||t>=128992&&t<=129003||t===129008||t>=129292&&t<=129338||t>=129340&&t<=129349||t>=129351&&t<=129535||t>=129648&&t<=129660||t>=129664&&t<=129674||t>=129678&&t<=129734||t===129736||t>=129741&&t<=129756||t>=129759&&t<=129770||t>=129775&&t<=129784||t>=131072&&t<=196605||t>=196608&&t<=262141}var U4=A(()=>{});function qye(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}function B4(t,{ambiguousAsWide:e=!1}={}){return qye(t),F4(t)||$4(t)||e&&L4(t)?2:1}var G4=A(()=>{U4()});var q4=b((_Ve,z4)=>{z4.exports=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g});function yd(t,e={}){if(typeof t!="string"||t.length===0)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:n=!1}=e;if(n||(t=cI(t)),t.length===0)return 0;let s=0,o={ambiguousAsWide:!r};for(let{segment:i}of Hye.segment(t)){let a=i.codePointAt(0);if(!(a<=31||a>=127&&a<=159)&&!(a>=8203&&a<=8207||a===65279)&&!(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)&&!(a>=55296&&a<=57343)&&!(a>=65024&&a<=65039)&&!jye.test(i)){if((0,H4.default)().test(i)){s+=2;continue}s+=B4(a,o)}}return s}var H4,Hye,jye,uI=A(()=>{P4();G4();H4=kt(q4(),1),Hye=new Intl.Segmenter,jye=new RegExp("^\\p{Default_Ignorable_Code_Point}$","u")});var gs,Sd,dI=A(()=>{"use strict";gs={maxConcurrent:5,maxIterations:100,timeout:3e5,autoBackgroundTimeout:12e4,compressionLevel:"medium",permissionMode:"default"},Sd={maxConcurrent:3,timeout:30*60*1e3,permissionMode:"dontAsk"}});var eS,pI=A(()=>{"use strict";eS=`You are an expert codebase explorer. Your task is to efficiently explore and understand codebases.
|
|
207
|
+
`)}var hye,ah,P,ct=A(()=>{"use strict";_e();hye={debug:!1,colors:!0,emojis:!0},ah={...hye};P={debug:j,info:y4,warn:S4,error:T4,success:b4,formatError:j1,configure:H1}});function w4(t){return typeof t=="number"&&Number.isInteger(t)&&t>0?t:1}function Y1(t,e){if(typeof t!="object"||t===null)return{kind:"malformed",reason:"frame is not an object"};let r=t.type;return typeof r!="string"?{kind:"malformed",reason:'frame has no string "type"'}:e.has(r)?{kind:"ok",frame:t}:{kind:"unknown",type:r,protocolVersion:w4(t.protocol_version)}}function v4(t){if(typeof t!="object"||t===null||typeof t.type=="string")return null;let e=t.error;return typeof e!="string"||e===""?null:{unknown_model:"That model is not available on Aii Cloud. Pick a model from your cloud dashboard (cloud.aiiware.com) or run with --local.",insufficient_credits:"Out of Aii Cloud credits. Top up to continue, or run with --local.",quota_exceeded:"Daily free-tier limit reached on Aii Cloud. Try again later, upgrade, or run with --local.",quota_check_failed:"Aii Cloud could not verify your quota \u2014 please retry.",worker_unavailable:"Aii Cloud is temporarily unavailable \u2014 please retry, or run with --local."}[e]??`Aii Cloud error: ${e}`}function ZA(t){return t==null||typeof t=="object"}function V1(t){switch(t.type){case"tool_request":return ZA(t.input);case"mcp_tool_request":return ZA(t.params);case"tool_batch_request":{let e=t.tools;return e==null||Array.isArray(e)&&e.every(r=>r==null||typeof r=="object"&&ZA(r.input))}default:return!0}}function K1(t){return w4(t)>2?"hard":"compatible"}function Q1(t){return`This Aii Server speaks protocol v${t}, but your CLI speaks v2. Some responses may not work correctly. Update with: aii upgrade`}var k4,A4,W1,eI=A(()=>{"use strict";k4=new Set(["token","complete","error","mcp_query_tools","mcp_tool_request","reasoning","reasoning_label","web_search_started","web_search_completed","follow_ups","task.step.updated","task.artifact.added"]),A4=new Set(["session_started","turn_ready","token","iteration_tokens_usage","tool_request","tool_batch_request","tool_status","complete","error","mcp_tools_loaded","permission_request","permission_resolution","mcp_query_tools","mcp_tool_request","reasoning","reasoning_label","web_search_started","web_search_completed","follow_ups","task.step.updated","task.artifact.added"]),W1=new Set(["tool_request","tool_batch_request","mcp_tool_request"])});var rI={};he(rI,{MCPConfigManager:()=>er,MCP_CATALOG:()=>oc});import*as hs from"fs";import*as X1 from"path";import*as tI from"os";var oc,er,Fa=A(()=>{"use strict";oc={github:{name:"GitHub",description:"GitHub API integration for repos, issues, PRs, and more",command:"npx",args:["-y","@modelcontextprotocol/server-github"],env:{GITHUB_PERSONAL_ACCESS_TOKEN:"${GITHUB_TOKEN}"},category:"development"},filesystem:{name:"Filesystem",description:"Read/write files on the local filesystem",command:"npx",args:["-y","@modelcontextprotocol/server-filesystem",tI.homedir()],category:"system"},"brave-search":{name:"Brave Search",description:"Web search using Brave Search API",command:"npx",args:["-y","@brave/brave-search-mcp-server"],env:{BRAVE_API_KEY:"${BRAVE_API_KEY}"},category:"search"},sqlite:{name:"SQLite",description:"Query SQLite databases",command:"uvx",args:["mcp-server-sqlite","--db-path","./database.db"],category:"database"},postgres:{name:"PostgreSQL",description:"Query PostgreSQL databases",command:"npx",args:["-y","@anthropic/mcp-server-postgres"],env:{DATABASE_URL:"${DATABASE_URL}"},category:"database"},"chrome-devtools":{name:"Chrome DevTools",description:"Control Chrome browser via DevTools protocol",command:"npx",args:["chrome-devtools-mcp@latest"],category:"browser"},memory:{name:"Memory",description:"Persistent memory storage for conversation context",command:"npx",args:["-y","@modelcontextprotocol/server-memory"],category:"utility"},puppeteer:{name:"Puppeteer",description:"Browser automation with Puppeteer",command:"npx",args:["-y","@anthropic/mcp-server-puppeteer"],category:"browser"}},er=class{configPath;constructor(e){this.configPath=e||X1.join(tI.homedir(),".aii","mcp_servers.json"),this.ensureConfigDir()}ensureConfigDir(){let e=X1.dirname(this.configPath);hs.existsSync(e)||hs.mkdirSync(e,{recursive:!0})}loadConfig(){if(!hs.existsSync(this.configPath))return{mcpServers:{}};try{let e=hs.readFileSync(this.configPath,"utf-8"),r=JSON.parse(e);return typeof r=="object"&&r!==null?r:{mcpServers:{}}}catch{return{mcpServers:{}}}}saveConfig(e){try{return this.ensureConfigDir(),hs.writeFileSync(this.configPath,JSON.stringify(e,null,2),"utf-8"),!0}catch{return!1}}backupConfig(){if(!hs.existsSync(this.configPath))return!0;try{let e=this.configPath+".backup";return hs.copyFileSync(this.configPath,e),!0}catch{return!1}}getConfigPath(){return this.configPath}}});var gye,_ye,Eye,yye,Sye,Tye,bye,ic,J1,$a,nI=A(()=>{"use strict";_e();gye={name:"classic",label:"Classic",description:"Aii jellyfish blue-purple (default)",accentColorName:"#3B82F6",userInputTextColorName:"#93C5FD",colors:{accent:m.hex("#3B82F6"),userInput:m.hex("#3B82F6"),userInputText:m.hex("#93C5FD"),success:m.hex("#22C55E"),warning:m.hex("#EAB308"),error:m.hex("#EF4444"),muted:m.hex("#94A3B8"),dim:m.dim,code:m.hex("#A855F7"),link:m.hex("#3B82F6").underline,heading:m.hex("#A855F7").bold,filePath:m.hex("#3B82F6"),indicator:m.hex("#3B82F6")}},_ye={name:"brand",label:"Brand",description:"aiiware.com official palette",accentColorName:"#4E6BF5",userInputTextColorName:"#A5B4FC",colors:{accent:m.hex("#4E6BF5"),userInput:m.hex("#4E6BF5"),userInputText:m.hex("#A5B4FC"),success:m.hex("#28CA41"),warning:m.hex("#EAB308"),error:m.hex("#EF4444"),muted:m.hex("#94A3B8"),dim:m.dim,code:m.hex("#4E6BF5"),link:m.hex("#4E6BF5").underline,heading:m.hex("#4E6BF5").bold,filePath:m.hex("#4E6BF5"),indicator:m.hex("#4E6BF5")}},Eye={name:"teal",label:"Teal",description:"Original teal accent",accentColorName:"#00BCD4",userInputTextColorName:"#67E8F9",colors:{accent:m.hex("#00BCD4"),userInput:m.hex("#00BCD4"),userInputText:m.hex("#67E8F9"),success:m.hex("#22C55E"),warning:m.hex("#EAB308"),error:m.hex("#EF4444"),muted:m.hex("#94A3B8"),dim:m.dim,code:m.hex("#00BCD4"),link:m.hex("#00BCD4").underline,heading:m.hex("#00BCD4").bold,filePath:m.hex("#00BCD4"),indicator:m.hex("#00BCD4")}},yye={name:"indigo",label:"Indigo",description:"Bright periwinkle-blue",accentColorName:"#6B8AFF",userInputTextColorName:"#A5B4FC",colors:{accent:m.hex("#6B8AFF"),userInput:m.hex("#6B8AFF"),userInputText:m.hex("#A5B4FC"),success:m.hex("#28CA41"),warning:m.hex("#EAB308"),error:m.hex("#EF4444"),muted:m.hex("#94A3B8"),dim:m.dim,code:m.hex("#6B8AFF"),link:m.hex("#6B8AFF").underline,heading:m.hex("#6B8AFF").bold,filePath:m.hex("#6B8AFF"),indicator:m.hex("#6B8AFF")}},Sye={name:"forest",label:"Forest",description:"Natural green",accentColorName:"#22C55E",userInputTextColorName:"#86EFAC",colors:{accent:m.hex("#22C55E"),userInput:m.hex("#22C55E"),userInputText:m.hex("#86EFAC"),success:m.hex("#22C55E"),warning:m.hex("#EAB308"),error:m.hex("#EF4444"),muted:m.hex("#94A3B8"),dim:m.dim,code:m.hex("#22C55E"),link:m.hex("#22C55E").underline,heading:m.hex("#22C55E").bold,filePath:m.hex("#22C55E"),indicator:m.hex("#22C55E")}},Tye={name:"amber",label:"Amber",description:"Warm orange-gold",accentColorName:"#F59E0B",userInputTextColorName:"#FCD34D",colors:{accent:m.hex("#F59E0B"),userInput:m.hex("#F59E0B"),userInputText:m.hex("#FCD34D"),success:m.hex("#22C55E"),warning:m.hex("#EAB308"),error:m.hex("#EF4444"),muted:m.hex("#94A3B8"),dim:m.dim,code:m.hex("#F59E0B"),link:m.hex("#F59E0B").underline,heading:m.hex("#F59E0B").bold,filePath:m.hex("#F59E0B"),indicator:m.hex("#F59E0B")}},bye={name:"grayscale",label:"Grayscale",description:"Accessible, no colors",accentColorName:"white",userInputTextColorName:"#CBD5E1",colors:{accent:m.reset,userInput:m.reset,userInputText:m.hex("#CBD5E1"),success:m.reset,warning:m.reset,error:m.bold,muted:m.dim,dim:m.dim,code:m.reset,link:m.underline,heading:m.bold,filePath:m.reset,indicator:m.bold}},ic={classic:gye,brand:_ye,teal:Eye,indigo:yye,forest:Sye,amber:Tye,grayscale:bye},J1="classic",$a=["classic","brand","teal","indigo","forest","amber","grayscale"]});var ac={};he(ac,{BAND_STYLE_INFO:()=>ch,BAND_STYLE_ORDER:()=>Ua,DEFAULT_BAND_STYLE:()=>oI,ThemeManager:()=>Zs,getAccentColorName:()=>Ae,getThemeColors:()=>q,getUserInputTextColorName:()=>Ed,resolveBandBg:()=>_d});function _d(t,e){let r=ch[t];if(r.blend===null)return Cye;let n=/^#[0-9a-fA-F]{6}$/.test(e)?e:"#8B98A9",s=parseInt(n.replace("#",""),16),o=r.blend,i=(a,l)=>Math.round(a*o+l*(1-o));return"#"+(i(s>>16&255,sI[0])<<16|i(s>>8&255,sI[1])<<8|i(s&255,sI[2])).toString(16).padStart(6,"0")}function q(){return Zs.getInstance().getColors()}function Ae(){return Zs.getInstance().getAccentColorName()}function Ed(){return Zs.getInstance().getUserInputTextColorName()}var Ua,ch,oI,sI,Cye,Zs,Ba=A(()=>{"use strict";nI();ft();Ua=["subtle","themed","neutral","bold"],ch={subtle:{blend:.16,description:"Faint theme tint \u2014 quietest"},themed:{blend:.28,description:"Theme-tinted band (default)"},neutral:{blend:null,description:"Fixed neutral gray (theme-independent)"},bold:{blend:.4,description:"Strong theme tint \u2014 selection-like"}},oI="themed",sI=[20,22,27],Cye="#262C34";Zs=class t{static instance=null;activeTheme;bandStyle=null;constructor(){this.activeTheme=ic[J1]}static getInstance(){return t.instance||(t.instance=new t),t.instance}getTheme(){return this.activeTheme}getColors(){return this.activeTheme.colors}getThemeName(){return this.activeTheme.name}setTheme(e){let r=ic[e];if(!r){let n=$a.join(", ");throw new Error(`Unknown theme: "${e}". Available themes: ${n}`)}this.activeTheme=r}isValidTheme(e){return e in ic}getAvailableThemes(){return $a.map(e=>ic[e])}getAccentColorName(){return this.activeTheme.accentColorName}getUserInputTextColorName(){return this.activeTheme.userInputTextColorName}getBandStyle(){if(this.bandStyle)return this.bandStyle;try{let e=Re().get("theme_band");if(e&&this.isValidBandStyle(e))return this.bandStyle=e,this.bandStyle}catch{}return this.bandStyle=oI,this.bandStyle}setBandStyle(e){if(!this.isValidBandStyle(e))throw new Error(`Unknown band style: "${e}". Available: ${Ua.join(", ")}`);this.bandStyle=e}isValidBandStyle(e){return Ua.includes(e)}reset(){this.activeTheme=ic[J1],this.bandStyle=null}}});var pt=A(()=>{"use strict";nI();Ba()});import{resolve as wye}from"path";function vye(){let t=process.env.TERM??"",e=process.env.TERM_PROGRAM??"",r=process.env.COLORTERM??"",n=process.env.WT_SESSION??"",s=process.env.VSCODE_INJECTION??process.env.TERM_PROGRAM==="vscode";return e==="iTerm.app"||e==="Hyper"||e==="vscode"||e==="WezTerm"||e==="Alacritty"||n||s||t.includes("xterm-256color")||t.includes("screen-256color")||t.includes("tmux")||t==="xterm-kitty"||r==="truecolor"?!0:!(t==="dumb"||!process.stdout.isTTY)}function uh(){return iI===null&&(iI=vye()),iI}function kye(){return process.platform==="darwin"?"Cmd":"Ctrl"}function D4(){return I4||!uh()?"":(I4=!0,` (${kye()}+Click to open)`)}function Aye(t,e){return uh()?`\x1B]8;;${e}\x07${t}\x1B]8;;\x07`:t}function R4(t,e){let r=process.env.HOME??process.env.USERPROFILE??"",n=t;r&&t.startsWith(r)&&(n="~"+t.slice(r.length));let s=e?`${n}:${e}`:n;if(!uh())return q().filePath(s);let o=q().accent(s),a=`file://${wye(t)}`;return e!==void 0&&e>0&&(a+=`#L${e}`),Aye(o,a)}var iI,I4,N4=A(()=>{"use strict";pt();iI=null,I4=!1});var M4={};he(M4,{VERSION:()=>lc,colors:()=>L,formatCode:()=>Lye,formatPath:()=>ph,getActionIndicator:()=>Pye,padEndAnsi:()=>Bye,printAction:()=>Iye,printDivider:()=>x4,printError:()=>xye,printExitSummary:()=>lI,printHeader:()=>Mye,printSuccess:()=>Nye,printToolComplete:()=>Dye,printToolFailed:()=>Rye,printToolResultCompact:()=>Ga,printWarning:()=>Oye,shortenPath:()=>$ye});function dh(t){return t.startsWith("/")||t.startsWith("~/")||t.startsWith("./")||t.startsWith("../")||/^[a-zA-Z]:\\/.test(t)||/\.(ts|tsx|js|jsx|json|md|py|go|rs|java|c|cpp|h|hpp|css|scss|html|xml|yaml|yml|toml|sh|bash|zsh)$/.test(t)||/^src\//.test(t)||/^lib\//.test(t)||/^test[s]?\//.test(t)}function Iye(t,e,r=console.log){let n=dh(e)?ph(e):L.filePath(e);r(L.dim("\u25CB ")+m.bold(t)+" "+n)}function Dye(t,e,r=console.log){let n=dh(e)?ph(e):L.filePath(e);r(L.success("\u2713 ")+m.bold(t)+" "+n)}function Rye(t,e,r,n=console.log){let s=dh(e)?ph(e):L.filePath(e);n(L.error("\u2717 ")+m.bold(t)+" "+s),r&&n(L.dim(" \u2192 ")+L.error(r))}function Ga(t,e,r=!0,n,s=console.log,o=!0){let i=r?L.success("\u25CF"):L.error("\u25CF"),a=60,l=e.length>a?e.slice(0,a-3)+"...":e;if(dh(e)){let d=e.match(/:(\d+)$/),p=d?parseInt(d[1],10):void 0,f=d?e.replace(/:(\d+)$/,""):e;l=ph(f,p)}s(`${i} ${m.bold(t)}(${l})`);let c=o&&dh(e)?L.dim(D4()):"",u=o&&!c&&!O4?L.dim(" (ctrl+o to expand)"):"";if(u&&(O4=!0),n){let d=r?L.dim:L.error;s(d(`\u2514 ${n}`)+c+u)}else{let d=r?"(No content)":"(Error)",p=r?L.dim:L.error;s(p(`\u2514 ${d}`)+c+u)}}function Nye(t){console.log(L.success("\u2713 ")+t)}function Oye(t){console.log(L.warning("\u26A0 ")+t)}function xye(t){console.log(L.error("\u2717 ")+t)}function x4(t=60){console.log(L.dim("\u2500".repeat(t)))}function Mye(t){console.log(L.logo(t)),x4(t.length)}function Pye(t){return L.thinking(`[${t}]`)}function ph(t,e){if(uh())return R4(t,e);let r=process.env.HOME??process.env.USERPROFILE??"",n=t;return r&&t.startsWith(r)&&(n="~"+t.slice(r.length)),e&&(n+=`:${e}`),L.filePath(n)}function Lye(t){return L.code(t)}function Fye(){return process.stdout.columns||80}function $ye(t,e=40){let r=process.env.HOME??process.env.USERPROFILE??"",n=t;if(r&&t.startsWith(r)&&(n="~"+t.slice(r.length)),n.length<=e)return n;let s=n.split("/").filter(i=>i.length>0);if(s.length>=2){let i=s.slice(-2).join("/");if(i.length<=e-4)return".../"+i}return".../"+(s[s.length-1]||s[s.length-2])}function Uye(t){return t.replace(/\x1b\[[0-9;]*m/g,"").length}function Bye(t,e){let r=Uye(t),n=Math.max(0,e-r);return t+" ".repeat(n)}function Gye(t){if(t<60)return`${t}s`;let e=Math.floor(t/60),r=t%60;return r>0?`${e}m ${r}s`:`${e}m`}function aI(t){return t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function lI(t){let e=Fye(),r=Math.min(e-2,76),n=r-4,s=(g,_)=>{let E=g.replace(/\x1b\[[0-9;]*m/g,"").length;return g+" ".repeat(Math.max(0,_-E))},o=g=>L.border("\u2502")+" "+s(g,n)+" "+L.border("\u2502"),i=(g,_,E,y)=>{let T=Math.floor(n/2),C=L.dim(g.padEnd(15))+_,w=L.dim(E.padEnd(15))+y;return o(s(C,T)+w)},a=Gye(t.durationSeconds),l=aI(t.tokensIn),c=aI(t.tokensOut),u=`$${t.totalCost.toFixed(4)}`,d=t.cloud?`\u2601\uFE0F Cloud \xB7 ${t.model}`:`${t.provider}/${t.model.replace("claude-","").replace("-latest","")}`;console.log(""),console.log(L.border("\u250C"+"\u2500".repeat(r-2)+"\u2510")),console.log(o(L.logo("Session complete. \u{1FABC}"))),console.log(L.border("\u251C"+"\u2500".repeat(r-2)+"\u2524")),console.log(o(L.logo("Session Summary"))),console.log(o(L.dim("\u2500".repeat(15)))),console.log(i("Duration",a,"Tool Calls",t.toolCalls.toString())),console.log(i("Turns",t.turns.toString(),"Files Modified",t.filesModified.toString())),console.log(o("")),console.log(o(L.logo("Token Usage"))),console.log(o(L.dim("\u2500".repeat(11)))),console.log(i("Input",l,"Output",c));let p=t.cachedTokens??0;if(p>0){let g=Math.min(100,Math.round(100*p/Math.max(1,t.tokensIn)));console.log(o(L.dim("Cached".padEnd(15))+`${aI(p)} (${g}%)`))}let f=t.cacheSavings??0,h=f>0?L.dim(` \xB7 saved ~$${f.toFixed(4)} by prompt caching`):"";console.log(o(L.dim("Cost".padEnd(15))+u+h)),console.log(o("")),t.goalLine&&console.log(o(L.dim("Goal: ")+t.goalLine.replace(/^Goal:\s*/,""))),console.log(o(L.dim("Model: ")+L.model(d))),console.log(L.border("\u2514"+"\u2500".repeat(r-2)+"\u2518")),console.log("")}var lc,L,O4,lr=A(()=>{"use strict";_e();N4();pt();lc="0.18.8",L={get logo(){return q().accent.bold},get prompt(){return q().accent.bold},get model(){return q().accent},get success(){return q().success},get warning(){return q().warning},get error(){return q().error},get thinking(){return q().dim},get filePath(){return q().filePath},get code(){return q().code},get muted(){return q().muted},get dim(){return q().dim},get safe(){return q().success},get risky(){return q().warning},get destructive(){return q().error},get border(){return q().accent},get bannerBorder(){return q().accent}};O4=!1});function cc({onlyFirst:t=!1}={}){let s="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(s,t?void 0:"g")}var Z1=A(()=>{});function cI(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(zye,"")}var zye,P4=A(()=>{Z1();zye=cc()});function L4(t){return t===161||t===164||t===167||t===168||t===170||t===173||t===174||t>=176&&t<=180||t>=182&&t<=186||t>=188&&t<=191||t===198||t===208||t===215||t===216||t>=222&&t<=225||t===230||t>=232&&t<=234||t===236||t===237||t===240||t===242||t===243||t>=247&&t<=250||t===252||t===254||t===257||t===273||t===275||t===283||t===294||t===295||t===299||t>=305&&t<=307||t===312||t>=319&&t<=322||t===324||t>=328&&t<=331||t===333||t===338||t===339||t===358||t===359||t===363||t===462||t===464||t===466||t===468||t===470||t===472||t===474||t===476||t===593||t===609||t===708||t===711||t>=713&&t<=715||t===717||t===720||t>=728&&t<=731||t===733||t===735||t>=768&&t<=879||t>=913&&t<=929||t>=931&&t<=937||t>=945&&t<=961||t>=963&&t<=969||t===1025||t>=1040&&t<=1103||t===1105||t===8208||t>=8211&&t<=8214||t===8216||t===8217||t===8220||t===8221||t>=8224&&t<=8226||t>=8228&&t<=8231||t===8240||t===8242||t===8243||t===8245||t===8251||t===8254||t===8308||t===8319||t>=8321&&t<=8324||t===8364||t===8451||t===8453||t===8457||t===8467||t===8470||t===8481||t===8482||t===8486||t===8491||t===8531||t===8532||t>=8539&&t<=8542||t>=8544&&t<=8555||t>=8560&&t<=8569||t===8585||t>=8592&&t<=8601||t===8632||t===8633||t===8658||t===8660||t===8679||t===8704||t===8706||t===8707||t===8711||t===8712||t===8715||t===8719||t===8721||t===8725||t===8730||t>=8733&&t<=8736||t===8739||t===8741||t>=8743&&t<=8748||t===8750||t>=8756&&t<=8759||t===8764||t===8765||t===8776||t===8780||t===8786||t===8800||t===8801||t>=8804&&t<=8807||t===8810||t===8811||t===8814||t===8815||t===8834||t===8835||t===8838||t===8839||t===8853||t===8857||t===8869||t===8895||t===8978||t>=9312&&t<=9449||t>=9451&&t<=9547||t>=9552&&t<=9587||t>=9600&&t<=9615||t>=9618&&t<=9621||t===9632||t===9633||t>=9635&&t<=9641||t===9650||t===9651||t===9654||t===9655||t===9660||t===9661||t===9664||t===9665||t>=9670&&t<=9672||t===9675||t>=9678&&t<=9681||t>=9698&&t<=9701||t===9711||t===9733||t===9734||t===9737||t===9742||t===9743||t===9756||t===9758||t===9792||t===9794||t===9824||t===9825||t>=9827&&t<=9829||t>=9831&&t<=9834||t===9836||t===9837||t===9839||t===9886||t===9887||t===9919||t>=9926&&t<=9933||t>=9935&&t<=9939||t>=9941&&t<=9953||t===9955||t===9960||t===9961||t>=9963&&t<=9969||t===9972||t>=9974&&t<=9977||t===9979||t===9980||t===9982||t===9983||t===10045||t>=10102&&t<=10111||t>=11094&&t<=11097||t>=12872&&t<=12879||t>=57344&&t<=63743||t>=65024&&t<=65039||t===65533||t>=127232&&t<=127242||t>=127248&&t<=127277||t>=127280&&t<=127337||t>=127344&&t<=127373||t===127375||t===127376||t>=127387&&t<=127404||t>=917760&&t<=917999||t>=983040&&t<=1048573||t>=1048576&&t<=1114109}function F4(t){return t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510}function $4(t){return t>=4352&&t<=4447||t===8986||t===8987||t===9001||t===9002||t>=9193&&t<=9196||t===9200||t===9203||t===9725||t===9726||t===9748||t===9749||t>=9776&&t<=9783||t>=9800&&t<=9811||t===9855||t>=9866&&t<=9871||t===9875||t===9889||t===9898||t===9899||t===9917||t===9918||t===9924||t===9925||t===9934||t===9940||t===9962||t===9970||t===9971||t===9973||t===9978||t===9981||t===9989||t===9994||t===9995||t===10024||t===10060||t===10062||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t===11035||t===11036||t===11088||t===11093||t>=11904&&t<=11929||t>=11931&&t<=12019||t>=12032&&t<=12245||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12353&&t<=12438||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12773||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=42124||t>=42128&&t<=42182||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=94176&&t<=94180||t>=94192&&t<=94198||t>=94208&&t<=101589||t>=101631&&t<=101662||t>=101760&&t<=101874||t>=110576&&t<=110579||t>=110581&&t<=110587||t===110589||t===110590||t>=110592&&t<=110882||t===110898||t>=110928&&t<=110930||t===110933||t>=110948&&t<=110951||t>=110960&&t<=111355||t>=119552&&t<=119638||t>=119648&&t<=119670||t===126980||t===127183||t===127374||t>=127377&&t<=127386||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t===127568||t===127569||t>=127584&&t<=127589||t>=127744&&t<=127776||t>=127789&&t<=127797||t>=127799&&t<=127868||t>=127870&&t<=127891||t>=127904&&t<=127946||t>=127951&&t<=127955||t>=127968&&t<=127984||t===127988||t>=127992&&t<=128062||t===128064||t>=128066&&t<=128252||t>=128255&&t<=128317||t>=128331&&t<=128334||t>=128336&&t<=128359||t===128378||t===128405||t===128406||t===128420||t>=128507&&t<=128591||t>=128640&&t<=128709||t===128716||t>=128720&&t<=128722||t>=128725&&t<=128728||t>=128732&&t<=128735||t===128747||t===128748||t>=128756&&t<=128764||t>=128992&&t<=129003||t===129008||t>=129292&&t<=129338||t>=129340&&t<=129349||t>=129351&&t<=129535||t>=129648&&t<=129660||t>=129664&&t<=129674||t>=129678&&t<=129734||t===129736||t>=129741&&t<=129756||t>=129759&&t<=129770||t>=129775&&t<=129784||t>=131072&&t<=196605||t>=196608&&t<=262141}var U4=A(()=>{});function qye(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}function B4(t,{ambiguousAsWide:e=!1}={}){return qye(t),F4(t)||$4(t)||e&&L4(t)?2:1}var G4=A(()=>{U4()});var q4=b((_Ve,z4)=>{z4.exports=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g});function yd(t,e={}){if(typeof t!="string"||t.length===0)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:n=!1}=e;if(n||(t=cI(t)),t.length===0)return 0;let s=0,o={ambiguousAsWide:!r};for(let{segment:i}of Hye.segment(t)){let a=i.codePointAt(0);if(!(a<=31||a>=127&&a<=159)&&!(a>=8203&&a<=8207||a===65279)&&!(a>=768&&a<=879||a>=6832&&a<=6911||a>=7616&&a<=7679||a>=8400&&a<=8447||a>=65056&&a<=65071)&&!(a>=55296&&a<=57343)&&!(a>=65024&&a<=65039)&&!jye.test(i)){if((0,H4.default)().test(i)){s+=2;continue}s+=B4(a,o)}}return s}var H4,Hye,jye,uI=A(()=>{P4();G4();H4=kt(q4(),1),Hye=new Intl.Segmenter,jye=new RegExp("^\\p{Default_Ignorable_Code_Point}$","u")});var gs,Sd,dI=A(()=>{"use strict";gs={maxConcurrent:5,maxIterations:100,timeout:3e5,autoBackgroundTimeout:12e4,compressionLevel:"medium",permissionMode:"default"},Sd={maxConcurrent:3,timeout:30*60*1e3,permissionMode:"dontAsk"}});var eS,pI=A(()=>{"use strict";eS=`You are an expert codebase explorer. Your task is to efficiently explore and understand codebases.
|
|
208
208
|
|
|
209
209
|
## Core Capabilities
|
|
210
210
|
You have access to these tools for codebase exploration:
|
|
@@ -3554,7 +3554,7 @@ To enter: cd ${s.path}`);break}case"list":{let s=await Ol(n);if(s.length===0){co
|
|
|
3554
3554
|
`)),console.log(" aii cloud login Sign in to Aii Cloud (verifies an existing sign-in;"),console.log(" --force re-authenticates)"),console.log(" aii cloud connect Stay online to run tasks dispatched from the Portal"),console.log(" aii cloud status Show connection + credit balance"),console.log(m.gray(`
|
|
3555
3555
|
\`aii cloud connect\` registers this machine so you can start a task from the
|
|
3556
3556
|
web ("Run on \u25BE \xB7 this machine") and approve its tool calls from the Portal.
|
|
3557
|
-
`))}var cde=A(()=>{"use strict";_e();Im();gd();Bue();Hue();Kue();Jue();ode();ade();$w()});var pde={};he(pde,{handleUpgrade:()=>eHe});import{execSync as ude}from"node:child_process";async function eHe(t){let e=t.args[0]||null,r="0.18.
|
|
3557
|
+
`))}var cde=A(()=>{"use strict";_e();Im();gd();Bue();Hue();Kue();Jue();ode();ade();$w()});var pde={};he(pde,{handleUpgrade:()=>eHe});import{execSync as ude}from"node:child_process";async function eHe(t){let e=t.args[0]||null,r="0.18.8",n=e?`${dde}@${e}`:`${dde}@latest`;console.log(""),console.log(e?`Upgrading Aii CLI to v${e}...`:"Upgrading Aii CLI to latest..."),console.log(` Current version: ${r}`),console.log("");try{ude(`npm install -g ${n}`,{stdio:"inherit",timeout:12e4})}catch{console.error(`
|
|
3558
3558
|
Upgrade failed. Try running with sudo or check npm permissions.`),console.error(` Manual: npm install -g ${n}`),process.exit(1)}try{let s=ude("aii --version 2>/dev/null",{encoding:"utf-8",timeout:1e4,stdio:"pipe"}).trim();console.log(""),console.log(s===r?`Already up to date (${r})`:`Upgraded: ${r} -> ${s}`)}catch{console.log(""),console.log("Installed. Restart your terminal to use the new version.")}}var dde,mde=A(()=>{"use strict";dde="@aiiware/aii"});var fde={};he(fde,{handleSkillCmd:()=>rHe});function tHe(t){return t.userInvocable&&t.modelInvocable?"":t.userInvocable?"(CLI only)":t.modelInvocable?"(agent only)":"(disabled)"}async function rHe(t,e){let r=(t.subcommand??t.args[0]??"help").toLowerCase(),n=t.subcommand?t.args[0]:t.args[1]??null;switch(r){case"list":return nHe();case"info":return sHe(n);case"install":return oHe(n);case"help":default:return iHe()}}async function nHe(){let{SkillManager:t}=await Promise.resolve().then(()=>(Mo(),fc)),e;if(t.hasInstance())e=t.getInstance();else{e=t.getInstance(process.cwd());let o;try{let{PersonaManager:i}=await Promise.resolve().then(()=>(wt(),It)),a=i.getInstance(process.cwd());await a.initialize(),a.isActive()&&(o=a.getActive()?.skillPaths)}catch{}await e.discover(o)}let r=e.getRegistry().getAll();if(r.length===0){console.log("No skills installed."),console.log(" Install one: aii skill install <owner/repo/skill>");return}let n=new Map;for(let o of r){let i=n.get(o.source)||[];i.push(o),n.set(o.source,i)}let s=["project-command","project","user","persona-bundled","universal","built-in","plugin","remote"];console.log(""),console.log(" Name Source Invocation Description"),console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");for(let o of s){let i=n.get(o);if(i)for(let a of i){let l=a.name.padEnd(18),c=a.source.padEnd(16),u=tHe(a).padEnd(14),d=(a.description||"").slice(0,34);console.log(` ${l}${c}${u}${d}`)}}console.log("")}async function sHe(t){if(!t){console.log("Usage: aii skill info <name>");return}let{SkillManager:e}=await Promise.resolve().then(()=>(Mo(),fc)),r;if(e.hasInstance())r=e.getInstance();else{r=e.getInstance(process.cwd());let s;try{let{PersonaManager:o}=await Promise.resolve().then(()=>(wt(),It)),i=o.getInstance(process.cwd());await i.initialize(),i.isActive()&&(s=i.getActive()?.skillPaths)}catch{}await r.discover(s)}let n=r.getRegistry().getByName(t);if(!n){let o=r.getRegistry().getAll().map(i=>i.name).join(", ");console.error(`Skill "${t}" not found.`),o&&console.error(`Available skills: ${o}`),process.exit(1)}console.log(""),console.log(` Name: ${n.name}`),console.log(` Source: ${n.source}`),console.log(` Description: ${n.description||"(none)"}`),console.log(` Invocable: ${[n.userInvocable?"user":"",n.modelInvocable?"model":""].filter(Boolean).join(" + ")||"none"}`),n.allowedTools?.length&&console.log(` Tools: ${n.allowedTools.join(" ")}`),console.log(` Path: ${n.path||"(embedded)"}`),console.log("")}async function oHe(t){if(!t){console.log("Usage: aii skill install <owner/repo/skill>");return}let{SkillInstaller:e}=await Promise.resolve().then(()=>($h(),bS)),r=new e({projectRoot:process.cwd()});try{let n=await r.install(t,{scope:"user"});n.success?(console.log(`Installed skill: ${n.skillName}`),n.installPath&&console.log(` Location: ${n.installPath}`)):(console.error(`Failed to install skill: ${n.error||"Unknown error"}`),process.exit(1))}catch(n){let s=n instanceof Error?n.message:String(n);console.error(`Failed to install skill: ${s}`),process.exit(1)}}function iHe(){let t=[""];t.push(m.cyan.bold(" Skill System")),t.push(""),t.push(m.yellow(" USAGE:")),t.push(` ${m.green("aii skill list")} List all available skills`),t.push(` ${m.green("aii skill info <name>")} Show details for a skill`),t.push(` ${m.green("aii skill install <ref>")} Install a skill from GitHub`),t.push(` ${m.green("aii skill help")} Show this help`),t.push(""),t.push(m.yellow(" EXAMPLES:")),t.push(m.dim(" aii skill list")),t.push(m.dim(" aii skill info commit")),t.push(m.dim(" aii skill install aiiware/aii-skills/skills/commit --user")),t.push(""),console.log(t.join(`
|
|
3559
3559
|
`))}var hde=A(()=>{"use strict";_e()});var gde={};he(gde,{handlePluginCmd:()=>aHe});async function aHe(t,e){let r=(t.subcommand??t.args[0]??"help").toLowerCase(),n=t.subcommand?t.args[0]:t.args[1]??null,s=t.subcommand?t.args.slice(1):t.args.slice(2);switch(r){case"install":return lHe(n,s);case"uninstall":case"remove":return cHe(n);case"update":return uHe(n);case"list":case"ls":return dHe();case"help":default:return pHe()}}async function lHe(t,e){if(!t){console.log("Usage: aii plugin install <owner/repo>");return}let{PluginInstaller:r}=await Promise.resolve().then(()=>(Va(),mc)),n=e.includes("--force")||e.includes("-f"),s=t,o;if(t.includes("@")){let a=t.lastIndexOf("@");s=t.slice(0,a),o=t.slice(a+1)}let i=new r({onProgress:a=>console.log(` ${m.dim(a)}`)});try{console.log(""),console.log(` Installing plugin from ${m.cyan(s)}...`),console.log("");let a=await i.install(s,{version:o,force:n});a.success?(console.log(""),console.log(` ${m.green("\u2713")} Plugin ${m.bold(a.pluginName)} v${a.version} installed`),console.log(` ${a.skillCount} skills available (use ${m.cyan("aii skill list")} to see them)`),a.installPath&&console.log(` Stored in ${m.dim(a.installPath)}`),console.log("")):(console.error(` ${m.red("\u2717")} ${a.error||"Unknown error"}`),process.exit(1))}catch(a){let l=a instanceof Error?a.message:String(a);console.error(` ${m.red("\u2717")} Failed to install plugin: ${l}`),process.exit(1)}}async function cHe(t){if(!t){console.log("Usage: aii plugin uninstall <name>");return}let{PluginInstaller:e}=await Promise.resolve().then(()=>(Va(),mc)),r=new e;try{let n=await r.uninstall(t);n.success?(console.log(""),console.log(` ${m.green("\u2713")} Plugin ${m.bold(t)} uninstalled`),n.skillCount&&console.log(` ${n.skillCount} skills removed`),console.log("")):(console.error(` ${m.red("\u2717")} ${n.error||"Unknown error"}`),process.exit(1))}catch(n){let s=n instanceof Error?n.message:String(n);console.error(` ${m.red("\u2717")} Failed to uninstall plugin: ${s}`),process.exit(1)}}async function uHe(t){if(!t){console.log("Usage: aii plugin update <name>");return}let{PluginInstaller:e}=await Promise.resolve().then(()=>(Va(),mc)),r=new e({onProgress:n=>console.log(` ${m.dim(n)}`)});try{console.log(""),console.log(` Checking for updates to ${m.cyan(t)}...`);let n=await r.update(t);n.success?(n.error?.includes("already up to date")?console.log(` ${m.green("\u2713")} ${n.error}`):(console.log(` ${m.green("\u2713")} Plugin ${m.bold(t)} updated to v${n.version}`),n.skillCount&&console.log(` ${n.skillCount} skills available`)),console.log("")):(console.error(` ${m.red("\u2717")} ${n.error||"Unknown error"}`),process.exit(1))}catch(n){let s=n instanceof Error?n.message:String(n);console.error(` ${m.red("\u2717")} Failed to update plugin: ${s}`),process.exit(1)}}async function dHe(){let{PluginManager:t}=await Promise.resolve().then(()=>(xh(),Oh)),r=await new t().listInstalled();if(r.length===0){console.log(""),console.log(" No plugins installed."),console.log(` Install one: ${m.cyan("aii plugin install <owner/repo>")}`),console.log("");return}console.log(""),console.log(m.bold(" INSTALLED PLUGINS")),console.log(""),console.log(" Name Version Skills Installed"),console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");for(let n of r){let s=n.name.padEnd(18),o=`v${n.version}`.padEnd(12),i=String(n.skillCount).padEnd(8),a=new Date(n.installedAt).toLocaleDateString();console.log(` ${s}${o}${i}${a}`)}console.log("")}function pHe(){let t=[""];t.push(m.cyan.bold("Plugin System")),t.push(""),t.push(m.yellow("USAGE:")),t.push(` ${m.green("aii plugin install <source>")} Install a plugin from GitHub`),t.push(` ${m.green("aii plugin uninstall <name>")} Uninstall a plugin`),t.push(` ${m.green("aii plugin update <name>")} Update a plugin to latest`),t.push(` ${m.green("aii plugin list")} List installed plugins`),t.push(` ${m.green("aii plugin help")} Show this help`),t.push(""),t.push(m.yellow("EXAMPLES:")),t.push(m.dim(" aii plugin install aiiware/aii-skills")),t.push(m.dim(" aii plugin install aiiware/aii-skills@v0.1.0")),t.push(m.dim(" aii plugin list")),t.push(m.dim(" aii plugin update aii-skills")),t.push(m.dim(" aii plugin uninstall aii-skills")),t.push(""),console.log(t.join(`
|
|
3560
3560
|
`))}var _de=A(()=>{"use strict";_e()});var Ede={};he(Ede,{handlePersona:()=>fHe});function mHe(t){return process.stdin.isTTY?async({originId:e,event:r,command:n,index:s,total:o})=>{s===1&&(console.log(`
|
|
@@ -3577,7 +3577,7 @@ Upgrade failed. Try running with sudo or check npm permissions.`),console.error(
|
|
|
3577
3577
|
${t}
|
|
3578
3578
|
</context>
|
|
3579
3579
|
|
|
3580
|
-
${e}`:e}var Se;(function(t){t[t.LOCAL=1]="LOCAL",t[t.SERVER=2]="SERVER"})(Se||(Se={}));var Mv={translate:"clean",shell:"clean",shell_generate:"clean",mcp:"standard",explain:"standard",code_generate:"standard",code_review:"standard",summarize:"standard",research:"standard",_default:"standard"};function ko(t,e,r,n){return t.clean?"clean":t.thinking||t.verbose?"thinking":t.standard?"standard":e&&r?.[e]?r[e]:e&&Mv[e]?Mv[e]:n||Mv._default}var py=[{name:"config",tier:Se.LOCAL},{name:"help",tier:Se.LOCAL},{name:"version",tier:Se.LOCAL},{name:"doctor",tier:Se.LOCAL},{name:"mcp",tier:Se.LOCAL},{name:"prompt",tier:Se.LOCAL},{name:"stats",tier:Se.LOCAL},{name:"history",tier:Se.LOCAL},{name:"query",tier:Se.SERVER},{name:"chat",tier:Se.SERVER},{name:"run",tier:Se.SERVER},{name:"agent",tier:Se.SERVER},{name:"loop",tier:Se.SERVER},{name:"telegram",tier:Se.SERVER},{name:"sessions",tier:Se.SERVER},{name:"install",tier:Se.LOCAL},{name:"worktree",tier:Se.LOCAL},{name:"soul",tier:Se.LOCAL},{name:"skill",tier:Se.LOCAL},{name:"plugin",tier:Se.LOCAL},{name:"persona",tier:Se.LOCAL},{name:"cloud",tier:Se.LOCAL},{name:"upgrade",tier:Se.LOCAL}];function Xde(t){let e=new Map;for(let r of t){if(!r.name)throw new Error("CLI command descriptor is missing a name");if(r.tier!==Se.LOCAL&&r.tier!==Se.SERVER)throw new Error(`CLI command "${r.name}" has an invalid tier: ${String(r.tier)}`);for(let n of[r.name,...r.aliases??[]]){if(e.has(n))throw new Error(`Duplicate CLI command name/alias: "${n}"`);e.set(n,r)}}return e}var Jde=Xde(py);function R9(t){return Jde.get(t)?.tier}var pje=Object.fromEntries(py.map(t=>[t.name,t.tier]));var Zde=new Set(py.filter(t=>t.name!=="query").flatMap(t=>[t.name,...t.aliases??[]])),epe="0.18.7",tpe=new Set(["--clean","--standard","--thinking","-v","--verbose","-d","--debug","--model","--openrouter-provider","--host","-y","--yes","--offline","-D","--direct","-i","--interactive","-c","--continue-chat","-n","--new-chat","--auto","--auto-background-timeout","--no-colors","--colors","--no-emojis","--emojis","--no-animations","--animations","--no-streaming","--streaming","--show-tokens","--show-cost","--output-format","--tools","--exclude-tools","--max-turns","--max-budget-usd","--bare","--append-system-prompt","--append-system-prompt-file","--continue","--signature","--no-signature","--no-project-config","--project-config","--local","-h","--help","-V","--version"]),rpe=new Set(["--model","--openrouter-provider","--host","-c","--continue-chat","--auto-background-timeout","--output-format","--tools","--exclude-tools","--max-turns","--max-budget-usd","--append-system-prompt","--append-system-prompt-file","--signature"]);function npe(t){let e=[];for(let r=0;r<t.length;r++){let n=t[r],s=n.indexOf("="),o=s>0?n.slice(0,s):n;if(tpe.has(o)){s===-1&&rpe.has(o)&&r++;continue}e.push(n)}return e}function spe(t){if(t===void 0)return;let e=Number(t);if(!Number.isInteger(e)||e<0)throw new Error(`Invalid --max-turns "${t}": expected a non-negative integer`);return e}function ope(t){if(t===void 0)return;let e=Number(t);if(!Number.isFinite(e)||e<0)throw new Error(`Invalid --max-budget-usd "${t}": expected a non-negative number`);return e}function ipe(){let t=new I9;return t.name("aii").description("AI-powered CLI assistant").version(epe,"-V, --version","Show version number").helpOption(!1).enablePositionalOptions().argument("[query...]","Natural language query").option("--clean","Clean output mode (just the result)").option("--standard","Standard output mode (result + metrics)").option("--thinking","Thinking mode (full reasoning)").option("-v, --verbose","Verbose output (alias for --thinking)").option("-d, --debug","Debug output").option("--model <model>","Override LLM model (e.g., ollama/llama3.1:8b, deepseek/deepseek-chat)").option("--openrouter-provider <slug>","Pin OpenRouter requests to a specific backend provider").option("--host <host>","API server host:port").option("--local","Force the local backend for this run (ignore managed cloud)").option("-y, --yes","Auto-confirm shell commands").option("--offline","Offline mode (no web/MCP)").option("-D, --direct","Direct mode (bypass server intent recognition)").option("-i, --interactive","Interactive chat mode").option("-c, --continue-chat <id>","Continue chat session").option("-n, --new-chat","Force new chat session").option("--auto","Auto mode - auto-approve all actions").option("--auto-background-timeout <seconds>","Auto-convert foreground agents to background after N seconds (0 to disable)","120").option("--no-project-config","Skip project .aii/settings.json + settings.local.json and their deny rules for this session").option("--no-colors","Disable colored output").option("--no-emojis","Disable emoji icons").option("--no-animations","Disable animations").option("--no-streaming","Disable streaming").option("--show-tokens","Show token usage").option("--show-cost","Show cost estimates").option("--output-format <format>","Output format: json or stream-json (one-shot only)").option("--tools <list>",'Allowlist of tools (comma-separated, e.g., "Read,Bash,Edit")').option("--exclude-tools <list>",'Exclude tools (comma-separated, e.g., "WebSearch,WebFetch")').option("--max-turns <n>","Max ReAct iterations within a turn (0/unset = default 500)").option("--max-budget-usd <amount>","Stop before a new turn once cumulative est. cost reaches $amount").option("--bare","Result to stdout only; all status/chrome to stderr (one-shot)").option("--append-system-prompt <text>","Append additive instructions to this run").option("--append-system-prompt-file <path>","Append a workspace file of additive instructions to this run").option("--continue","Resume the most recent local session of this project (conversation + goal)").option("-h, --help","Show help"),t.command("config").description("Configuration management").argument("[action]","Action: init, show, validate, set").argument("[key]","Config key (for set)").argument("[value]","Config value (for set)").allowUnknownOption().helpOption(!1).action(()=>{}),t.command("mcp").description("MCP server management").argument("[action]","Action: list, add, remove, status, etc.").argument("[rest...]","Server name and arguments").passThroughOptions().action(()=>{}),t.command("prompt").description("Prompt library").argument("[action]","Action: list, show, use, create").argument("[rest...]","Prompt name and arguments").allowUnknownOption().action(()=>{}),t.command("stats").description("Usage statistics").argument("[type]","Type: models, cost").action(()=>{}),t.command("history").description("Chat history").argument("[action]","Action: list, search, export, delete").argument("[query]","Search query or ID").action(()=>{}),t.command("doctor").description("System health check").action(()=>{}),t.command("install [target...]").description("Install or update Aii CLI, skills, or MCP servers").allowUnknownOption().helpOption(!1).action(()=>{}),t.command("chat").description("Interactive chat mode").action(()=>{}),t.command("agent").description("Interactive agent mode with tool execution").argument("[query...]","Optional query (non-interactive if provided)").action(()=>{}),t.command("loop").description("Autonomous agent loop (Ralph Wiggum pattern)").argument("[args...]","Loop arguments (prompt, --max, --verify, --budget, etc.)").allowUnknownOption().action(()=>{}),t.command("telegram").description("Telegram bot channel (chat with Aii from Telegram)").argument("[action]","Action: start, pair, status, unpair").argument("[args...]","Additional arguments").allowUnknownOption().action(()=>{}),t.command("sessions").description("Manage server sessions (list, info, resume, rename, delete)").argument("[action]","Action: list, info, resume, rename, delete").argument("[args...]","Additional arguments (session ID, name, etc.)").allowUnknownOption().action(()=>{}),t.command("worktree").description("Manage git worktrees for isolated development").argument("[action]","Action: create, list, remove, clean").argument("[name]","Worktree name (for create/remove)").allowUnknownOption().action(()=>{}),t.command("soul").description("Manage agent soul (personality & identity)").argument("[action]","Action: switch, show").argument("[name]","Soul name (for switch)").allowUnknownOption().action(()=>{}),t.command("cloud").description("Manage the Aii Cloud connection (login, connect, status)").argument("[action]","Action: login, connect, status").allowUnknownOption().action(()=>{}),t.command("skill").description("Manage AI skills").allowUnknownOption().passThroughOptions().action(()=>{}),t.command("plugin").description("Manage skill plugins").allowUnknownOption().passThroughOptions().action(()=>{}),t.command("persona").description("Manage workspace personas").allowUnknownOption().passThroughOptions().action(()=>{}),t.command("upgrade").description("Update Aii CLI to latest version").argument("[version]","Target version (default: latest)").action(()=>{}),t.command("run").description("Run domain-specific operations").argument("<operation>","Operation (e.g., git commit)").argument("[args...]","Additional arguments").allowUnknownOption().action(()=>{}),t.command("help").description("display help for command").argument("[command]","Command to show help for").action(()=>{}),t.command("version").description("Show version number").action(()=>{}),t}async function N9(t){let e=ipe();e.exitOverride(),e.configureOutput({writeErr:()=>{}});let r="query",n,s=[];try{e.parse(t),s=e.args;let c=e.args[0];c&&Zde.has(c)&&(r=c,n=e.args[1],s=e.args.slice(2))}catch(c){c instanceof A9&&(c.code==="commander.version"||c.code==="commander.helpDisplayed")&&process.exit(0),s=npe(t.slice(2))}let o=e.opts(),i={clean:o.clean??!1,standard:o.standard??!1,thinking:o.thinking??!1,verbose:o.verbose??!1,debug:o.debug??!1,model:o.model,host:o.host,local:o.local??!1,openrouterProvider:o.openrouterProvider,yes:o.yes??!1,offline:o.offline??!1,direct:o.direct??!1,interactive:o.interactive??!1,continueChat:o.continueChat,newChat:o.newChat??!1,auto:o.auto??!1,quiet:!1,noProjectConfig:o.projectConfig===!1,autoBackgroundTimeout:(()=>{let c=parseInt(o.autoBackgroundTimeout??"120",10);return isNaN(c)||c===0?0:Math.max(30,Math.min(600,c))*1e3})(),noColors:!o.colors,noEmojis:!o.emojis,noAnimations:!o.animations,noStreaming:!o.streaming,showTokens:o.showTokens??!1,showCost:o.showCost??!1,outputFormat:o.outputFormat,tools:o.tools,excludeTools:o.excludeTools,maxTurns:spe(o.maxTurns),maxBudgetUsd:ope(o.maxBudgetUsd),bare:o.bare??!1,appendSystemPrompt:o.appendSystemPrompt,appendSystemPromptFile:o.appendSystemPromptFile,continue:o.continue??!1,help:o.help??!1,version:o.version??!1},a;xv()&&(a=await D9()),(r==="chat"||i.interactive)&&(r="agent"),r==="query"&&!s.length&&!a&&(r="agent");let l;if(r==="query"&&s.length>0)l=s.join(" ");else if(r==="agent"){let c=[];n&&c.push(n),s.length>0&&c.push(...s),c.length>0&&(l=c.join(" "))}return{command:r,subcommand:n,args:s,flags:i,stdinContent:a,query:l}}function O9(t){let e=R9(t.command)??Se.SERVER;switch(t.command){case"config":return ape(t);case"mcp":return lpe(t);case"prompt":return cpe(t);case"stats":return upe(t);case"history":return dpe(t);case"doctor":return{tier:Se.LOCAL,handler:"doctor",params:{}};case"install":return{tier:Se.LOCAL,handler:"install",params:{}};case"chat":return{tier:Se.SERVER,handler:"chat",params:{continueChat:t.flags.continueChat}};case"run":return mpe(t);case"agent":return{tier:Se.SERVER,handler:"agent",params:{interactive:!t.query}};case"loop":return{tier:Se.SERVER,handler:"loop",params:{}};case"telegram":return{tier:Se.SERVER,handler:"telegram",params:{action:t.subcommand??t.args[0]??"start"}};case"sessions":return{tier:Se.SERVER,handler:"sessions",params:{action:t.subcommand??t.args[0]??"list"}};case"worktree":return{tier:Se.LOCAL,handler:"worktree",params:{action:t.subcommand??t.args[0]??"list",name:t.subcommand?t.args[0]:t.args[1]}};case"soul":return{tier:Se.LOCAL,handler:"soul",params:{action:t.subcommand??t.args[0]??"show",name:t.subcommand?t.args[0]:t.args[1]}};case"cloud":return{tier:Se.LOCAL,handler:"cloud",params:{action:t.subcommand??t.args[0]??"status"}};case"skill":return{tier:Se.LOCAL,handler:"skill",params:{action:t.args[0]||"help",target:t.args[1]||null,extraArgs:t.args.slice(2)}};case"plugin":return{tier:Se.LOCAL,handler:"plugin",params:{action:t.args[0]||"help",target:t.args[1]||null,extraArgs:t.args.slice(2)}};case"persona":return{tier:Se.LOCAL,handler:"persona",params:{action:t.args[0]||"help",target:t.args[1]||null,extraArgs:t.args.slice(2)}};case"upgrade":return{tier:Se.LOCAL,handler:"upgrade",params:{version:t.args[0]||null}};case"help":return{tier:Se.LOCAL,handler:"help",params:{command:t.subcommand}};case"version":return{tier:Se.LOCAL,handler:"version",params:{}};case"query":default:return{tier:e,handler:"query",params:{query:t.query,stdinContent:t.stdinContent}}}}function ape(t){let e=t.subcommand??t.args[0]??"show";return{tier:Se.LOCAL,handler:`config:${e}`,params:{key:t.args[0],value:t.args[1]}}}function lpe(t){let e=t.subcommand??t.args[0]??"list";return{tier:Se.LOCAL,handler:`mcp:${e}`,params:{name:t.args[0],args:t.args.slice(1)}}}function cpe(t){let e=t.subcommand??t.args[0]??"list";return{tier:Se.LOCAL,handler:`prompt:${e}`,params:{name:t.args[0],args:t.args.slice(1)}}}function upe(t){let e=t.subcommand??t.args[0];return{tier:Se.LOCAL,handler:e?`stats:${e}`:"stats",params:{}}}function dpe(t){let e=t.subcommand??t.args[0]??"list";return{tier:Se.LOCAL,handler:`history:${e}`,params:{query:t.args[0],id:t.args[0]}}}var ppe=new Set(["--model","--host","--continue-chat","-c","--signature","--base"]);function mpe(t){let e=[...t.subcommand?[t.subcommand]:[],...t.args],r=[];for(let s=0;s<e.length;s++){let o=e[s];if(ppe.has(o)){e[s+1]!==void 0&&!e[s+1].startsWith("-")&&s++;continue}o.startsWith("-")||r.push(o)}let n=r.join(" ");return{tier:Se.SERVER,handler:"run",params:{operation:n}}}ft();b1();Ro();_e();import{createInterface as Eze}from"readline";import{spawn as yze}from"child_process";q1();Mn();gd();ct();eI();var S6e={timeout:12e4,retries:3,retryDelay:1e3,handshakeTimeout:5e3};function T6e(t,e){let r=new URL(t),n=r.protocol==="https:"?"wss:":"ws:";if(e){if(!(r.protocol==="https:"||r.protocol==="wss:")&&!oh(r.hostname))throw new Error(`Refusing to send the cloud key over an insecure (${r.protocol}) connection to ${r.hostname} \u2014 use https/wss.`);return{url:`${n}//${r.host}/v1/ws/execute`,headers:{Authorization:`Bearer ${e}`}}}return{url:`${n}//${r.host}/ws/execute`}}var Bs=class{options;ws=null;activityTimeout=null;mcpExecutor=null;constructor(e){this.options={...S6e,...e}}async initializeMCP(){if(!this.mcpExecutor){let{ClientMCPExecutor:e}=await Promise.resolve().then(()=>(xd(),Od)),{createHeadlessMcpGate:r}=await Promise.resolve().then(()=>(Lo(),Qa));this.mcpExecutor=new e,this.mcpExecutor.setPermissionGate(r()),await this.mcpExecutor.initialize(),j(`MCP executor initialized with ${this.mcpExecutor.getConnectionCount()} connections`)}}async executeRequest(e,r){let n=null,s=T6e(this.options.url,this.options.cloudApiKey);for(let o=0;o<this.options.retries;o++)try{return await this.executeWithRetry(s,e,r)}catch(i){if(n=i instanceof Error?i:new Error(String(i)),j(`Attempt ${o+1} failed: ${n.message}`),n instanceof Qu||n.message.includes("Authentication"))throw n;if(this.options.cloudApiKey&&n instanceof Ku){let a=new URL(this.options.url);throw new Do(jl(a.hostname),"CLOUD_UNREACHABLE")}if(o<this.options.retries-1){let a=this.options.retryDelay*Math.pow(2,o);j(`Retrying in ${a}ms...`),await this.sleep(a)}}throw n??new Na("Max retries exceeded")}async executeWithRetry(e,r,n){return new Promise((s,o)=>{let i=e.url;j(`Connecting to ${i}`);try{this.ws=new fs(i,{handshakeTimeout:this.options.handshakeTimeout,...e.headers?{headers:e.headers}:{}})}catch{let p=new URL(this.options.url);o(new Ku(p.hostname||"localhost",p.port||void 0));return}let a=!1,l=null,c=null,u=!1,d=p=>{a||(a=!0,this.cleanup(),o(p))};this.resetActivityTimeout(()=>{a||(this.cleanup(),o(new qf("WebSocket activity",this.options.timeout)))}),this.ws.on("open",()=>{j("WebSocket connected, sending request"),this.ws?.send(JSON.stringify({...r,protocol_version:2}))}),this.ws.on("message",p=>{this.resetActivityTimeout(()=>{a||(this.cleanup(),o(new qf("WebSocket activity",this.options.timeout)))});let f;try{f=JSON.parse(p.toString())}catch(_){let E=p?String(p):"<undefined>";j(`Failed to parse message: ${E}`),d(new Error(`Failed to parse server message: ${_.message}`));return}let h=Y1(f,k4);if(h.kind==="malformed"){let _=v4(f);d(_?new Qu("cloud_error",_):new Na(`Malformed server frame: ${h.reason}`));return}if(h.kind==="unknown"){u||(u=!0,j(`Received an unrecognized frame type '${h.type}'; ignoring`));return}let g=h.frame;if(c===null&&g.protocol_version!==void 0&&(c=K1(g.protocol_version),c==="hard")){d(new Na(Q1(g.protocol_version)));return}if(W1.has(g.type)&&!V1(g)){d(new Na(`Malformed ${g.type} payload`));return}this.handleMessage(g,n,_=>{a=!0,l=_,this.cleanup(),s(_)},_=>{a=!0,this.cleanup(),o(_)})}),this.ws.on("error",p=>{if(j(`WebSocket error: ${p.message}`),!a){a=!0,this.cleanup();let f=new URL(this.options.url);o(new Ku(f.hostname||"localhost",f.port||void 0))}}),this.ws.on("close",(p,f)=>{j(`WebSocket closed: ${p} ${f.toString()}`),a||(a=!0,this.cleanup(),l?s(l):o(new Na(`Connection closed unexpectedly: ${p}`)))})})}handleMessage(e,r,n,s){switch(e.type){case"token":{let o=e;r?.onToken?.(o.data);break}case"complete":{let o=e,i=o.metadata||{},a=this.convertServerMetadata(o),l={result:o.result,metadata:a,clientSideExecution:i.client_side_execution===!0,userRequest:i.user_request};r?.onComplete?.(l),n(l);break}case"error":{let o=e,i=new Qu(o.code,o.message);r?.onError?.(i),s(i);break}case"mcp_query_tools":{j("Received mcp_query_tools request"),this.handleMCPQueryTools(e);break}case"mcp_tool_request":{j("Received mcp_tool_request"),this.handleMCPToolRequest(e);break}default:j(`Unknown message type: ${e.type}`)}}convertServerMetadata(e){let r=e.metadata||{},n,s;r.tokens?(n=r.tokens.input,s=r.tokens.output):(n=r.input_tokens,s=r.output_tokens);let o=r.cost??r.cost_usd,i=r.execution_time??r.total_time;return{function_name:e.function_name,tokens_in:n,tokens_out:s,cost:typeof o=="number"?o:void 0,model:typeof r.model=="string"?r.model:void 0,provider:typeof r.provider=="string"?r.provider:void 0,execution_time:typeof i=="number"?i:void 0,task_id:typeof r.task_id=="string"?r.task_id:void 0,chat_url:typeof r.chat_url=="string"?r.chat_url:void 0}}async handleMCPQueryTools(e){try{if(!this.mcpExecutor){let{ClientMCPExecutor:n}=await Promise.resolve().then(()=>(xd(),Od)),{createHeadlessMcpGate:s}=await Promise.resolve().then(()=>(Lo(),Qa));this.mcpExecutor=new n,this.mcpExecutor.setPermissionGate(s()),await this.mcpExecutor.initialize()}let r=await this.mcpExecutor.handleQueryTools(e);this.ws?.send(JSON.stringify(r))}catch(r){let n=r instanceof Error?r.message:String(r),s=r instanceof Error?r.stack:void 0;j(`Error handling mcp_query_tools: ${n}${s?`
|
|
3580
|
+
${e}`:e}var Se;(function(t){t[t.LOCAL=1]="LOCAL",t[t.SERVER=2]="SERVER"})(Se||(Se={}));var Mv={translate:"clean",shell:"clean",shell_generate:"clean",mcp:"standard",explain:"standard",code_generate:"standard",code_review:"standard",summarize:"standard",research:"standard",_default:"standard"};function ko(t,e,r,n){return t.clean?"clean":t.thinking||t.verbose?"thinking":t.standard?"standard":e&&r?.[e]?r[e]:e&&Mv[e]?Mv[e]:n||Mv._default}var py=[{name:"config",tier:Se.LOCAL},{name:"help",tier:Se.LOCAL},{name:"version",tier:Se.LOCAL},{name:"doctor",tier:Se.LOCAL},{name:"mcp",tier:Se.LOCAL},{name:"prompt",tier:Se.LOCAL},{name:"stats",tier:Se.LOCAL},{name:"history",tier:Se.LOCAL},{name:"query",tier:Se.SERVER},{name:"chat",tier:Se.SERVER},{name:"run",tier:Se.SERVER},{name:"agent",tier:Se.SERVER},{name:"loop",tier:Se.SERVER},{name:"telegram",tier:Se.SERVER},{name:"sessions",tier:Se.SERVER},{name:"install",tier:Se.LOCAL},{name:"worktree",tier:Se.LOCAL},{name:"soul",tier:Se.LOCAL},{name:"skill",tier:Se.LOCAL},{name:"plugin",tier:Se.LOCAL},{name:"persona",tier:Se.LOCAL},{name:"cloud",tier:Se.LOCAL},{name:"upgrade",tier:Se.LOCAL}];function Xde(t){let e=new Map;for(let r of t){if(!r.name)throw new Error("CLI command descriptor is missing a name");if(r.tier!==Se.LOCAL&&r.tier!==Se.SERVER)throw new Error(`CLI command "${r.name}" has an invalid tier: ${String(r.tier)}`);for(let n of[r.name,...r.aliases??[]]){if(e.has(n))throw new Error(`Duplicate CLI command name/alias: "${n}"`);e.set(n,r)}}return e}var Jde=Xde(py);function R9(t){return Jde.get(t)?.tier}var pje=Object.fromEntries(py.map(t=>[t.name,t.tier]));var Zde=new Set(py.filter(t=>t.name!=="query").flatMap(t=>[t.name,...t.aliases??[]])),epe="0.18.8",tpe=new Set(["--clean","--standard","--thinking","-v","--verbose","-d","--debug","--model","--openrouter-provider","--host","-y","--yes","--offline","-D","--direct","-i","--interactive","-c","--continue-chat","-n","--new-chat","--auto","--auto-background-timeout","--no-colors","--colors","--no-emojis","--emojis","--no-animations","--animations","--no-streaming","--streaming","--show-tokens","--show-cost","--output-format","--tools","--exclude-tools","--max-turns","--max-budget-usd","--bare","--append-system-prompt","--append-system-prompt-file","--continue","--signature","--no-signature","--no-project-config","--project-config","--local","-h","--help","-V","--version"]),rpe=new Set(["--model","--openrouter-provider","--host","-c","--continue-chat","--auto-background-timeout","--output-format","--tools","--exclude-tools","--max-turns","--max-budget-usd","--append-system-prompt","--append-system-prompt-file","--signature"]);function npe(t){let e=[];for(let r=0;r<t.length;r++){let n=t[r],s=n.indexOf("="),o=s>0?n.slice(0,s):n;if(tpe.has(o)){s===-1&&rpe.has(o)&&r++;continue}e.push(n)}return e}function spe(t){if(t===void 0)return;let e=Number(t);if(!Number.isInteger(e)||e<0)throw new Error(`Invalid --max-turns "${t}": expected a non-negative integer`);return e}function ope(t){if(t===void 0)return;let e=Number(t);if(!Number.isFinite(e)||e<0)throw new Error(`Invalid --max-budget-usd "${t}": expected a non-negative number`);return e}function ipe(){let t=new I9;return t.name("aii").description("AI-powered CLI assistant").version(epe,"-V, --version","Show version number").helpOption(!1).enablePositionalOptions().argument("[query...]","Natural language query").option("--clean","Clean output mode (just the result)").option("--standard","Standard output mode (result + metrics)").option("--thinking","Thinking mode (full reasoning)").option("-v, --verbose","Verbose output (alias for --thinking)").option("-d, --debug","Debug output").option("--model <model>","Override LLM model (e.g., ollama/llama3.1:8b, deepseek/deepseek-chat)").option("--openrouter-provider <slug>","Pin OpenRouter requests to a specific backend provider").option("--host <host>","API server host:port").option("--local","Force the local backend for this run (ignore managed cloud)").option("-y, --yes","Auto-confirm shell commands").option("--offline","Offline mode (no web/MCP)").option("-D, --direct","Direct mode (bypass server intent recognition)").option("-i, --interactive","Interactive chat mode").option("-c, --continue-chat <id>","Continue chat session").option("-n, --new-chat","Force new chat session").option("--auto","Auto mode - auto-approve all actions").option("--auto-background-timeout <seconds>","Auto-convert foreground agents to background after N seconds (0 to disable)","120").option("--no-project-config","Skip project .aii/settings.json + settings.local.json and their deny rules for this session").option("--no-colors","Disable colored output").option("--no-emojis","Disable emoji icons").option("--no-animations","Disable animations").option("--no-streaming","Disable streaming").option("--show-tokens","Show token usage").option("--show-cost","Show cost estimates").option("--output-format <format>","Output format: json or stream-json (one-shot only)").option("--tools <list>",'Allowlist of tools (comma-separated, e.g., "Read,Bash,Edit")').option("--exclude-tools <list>",'Exclude tools (comma-separated, e.g., "WebSearch,WebFetch")').option("--max-turns <n>","Max ReAct iterations within a turn (0/unset = default 500)").option("--max-budget-usd <amount>","Stop before a new turn once cumulative est. cost reaches $amount").option("--bare","Result to stdout only; all status/chrome to stderr (one-shot)").option("--append-system-prompt <text>","Append additive instructions to this run").option("--append-system-prompt-file <path>","Append a workspace file of additive instructions to this run").option("--continue","Resume the most recent local session of this project (conversation + goal)").option("-h, --help","Show help"),t.command("config").description("Configuration management").argument("[action]","Action: init, show, validate, set").argument("[key]","Config key (for set)").argument("[value]","Config value (for set)").allowUnknownOption().helpOption(!1).action(()=>{}),t.command("mcp").description("MCP server management").argument("[action]","Action: list, add, remove, status, etc.").argument("[rest...]","Server name and arguments").passThroughOptions().action(()=>{}),t.command("prompt").description("Prompt library").argument("[action]","Action: list, show, use, create").argument("[rest...]","Prompt name and arguments").allowUnknownOption().action(()=>{}),t.command("stats").description("Usage statistics").argument("[type]","Type: models, cost").action(()=>{}),t.command("history").description("Chat history").argument("[action]","Action: list, search, export, delete").argument("[query]","Search query or ID").action(()=>{}),t.command("doctor").description("System health check").action(()=>{}),t.command("install [target...]").description("Install or update Aii CLI, skills, or MCP servers").allowUnknownOption().helpOption(!1).action(()=>{}),t.command("chat").description("Interactive chat mode").action(()=>{}),t.command("agent").description("Interactive agent mode with tool execution").argument("[query...]","Optional query (non-interactive if provided)").action(()=>{}),t.command("loop").description("Autonomous agent loop (Ralph Wiggum pattern)").argument("[args...]","Loop arguments (prompt, --max, --verify, --budget, etc.)").allowUnknownOption().action(()=>{}),t.command("telegram").description("Telegram bot channel (chat with Aii from Telegram)").argument("[action]","Action: start, pair, status, unpair").argument("[args...]","Additional arguments").allowUnknownOption().action(()=>{}),t.command("sessions").description("Manage server sessions (list, info, resume, rename, delete)").argument("[action]","Action: list, info, resume, rename, delete").argument("[args...]","Additional arguments (session ID, name, etc.)").allowUnknownOption().action(()=>{}),t.command("worktree").description("Manage git worktrees for isolated development").argument("[action]","Action: create, list, remove, clean").argument("[name]","Worktree name (for create/remove)").allowUnknownOption().action(()=>{}),t.command("soul").description("Manage agent soul (personality & identity)").argument("[action]","Action: switch, show").argument("[name]","Soul name (for switch)").allowUnknownOption().action(()=>{}),t.command("cloud").description("Manage the Aii Cloud connection (login, connect, status)").argument("[action]","Action: login, connect, status").allowUnknownOption().action(()=>{}),t.command("skill").description("Manage AI skills").allowUnknownOption().passThroughOptions().action(()=>{}),t.command("plugin").description("Manage skill plugins").allowUnknownOption().passThroughOptions().action(()=>{}),t.command("persona").description("Manage workspace personas").allowUnknownOption().passThroughOptions().action(()=>{}),t.command("upgrade").description("Update Aii CLI to latest version").argument("[version]","Target version (default: latest)").action(()=>{}),t.command("run").description("Run domain-specific operations").argument("<operation>","Operation (e.g., git commit)").argument("[args...]","Additional arguments").allowUnknownOption().action(()=>{}),t.command("help").description("display help for command").argument("[command]","Command to show help for").action(()=>{}),t.command("version").description("Show version number").action(()=>{}),t}async function N9(t){let e=ipe();e.exitOverride(),e.configureOutput({writeErr:()=>{}});let r="query",n,s=[];try{e.parse(t),s=e.args;let c=e.args[0];c&&Zde.has(c)&&(r=c,n=e.args[1],s=e.args.slice(2))}catch(c){c instanceof A9&&(c.code==="commander.version"||c.code==="commander.helpDisplayed")&&process.exit(0),s=npe(t.slice(2))}let o=e.opts(),i={clean:o.clean??!1,standard:o.standard??!1,thinking:o.thinking??!1,verbose:o.verbose??!1,debug:o.debug??!1,model:o.model,host:o.host,local:o.local??!1,openrouterProvider:o.openrouterProvider,yes:o.yes??!1,offline:o.offline??!1,direct:o.direct??!1,interactive:o.interactive??!1,continueChat:o.continueChat,newChat:o.newChat??!1,auto:o.auto??!1,quiet:!1,noProjectConfig:o.projectConfig===!1,autoBackgroundTimeout:(()=>{let c=parseInt(o.autoBackgroundTimeout??"120",10);return isNaN(c)||c===0?0:Math.max(30,Math.min(600,c))*1e3})(),noColors:!o.colors,noEmojis:!o.emojis,noAnimations:!o.animations,noStreaming:!o.streaming,showTokens:o.showTokens??!1,showCost:o.showCost??!1,outputFormat:o.outputFormat,tools:o.tools,excludeTools:o.excludeTools,maxTurns:spe(o.maxTurns),maxBudgetUsd:ope(o.maxBudgetUsd),bare:o.bare??!1,appendSystemPrompt:o.appendSystemPrompt,appendSystemPromptFile:o.appendSystemPromptFile,continue:o.continue??!1,help:o.help??!1,version:o.version??!1},a;xv()&&(a=await D9()),(r==="chat"||i.interactive)&&(r="agent"),r==="query"&&!s.length&&!a&&(r="agent");let l;if(r==="query"&&s.length>0)l=s.join(" ");else if(r==="agent"){let c=[];n&&c.push(n),s.length>0&&c.push(...s),c.length>0&&(l=c.join(" "))}return{command:r,subcommand:n,args:s,flags:i,stdinContent:a,query:l}}function O9(t){let e=R9(t.command)??Se.SERVER;switch(t.command){case"config":return ape(t);case"mcp":return lpe(t);case"prompt":return cpe(t);case"stats":return upe(t);case"history":return dpe(t);case"doctor":return{tier:Se.LOCAL,handler:"doctor",params:{}};case"install":return{tier:Se.LOCAL,handler:"install",params:{}};case"chat":return{tier:Se.SERVER,handler:"chat",params:{continueChat:t.flags.continueChat}};case"run":return mpe(t);case"agent":return{tier:Se.SERVER,handler:"agent",params:{interactive:!t.query}};case"loop":return{tier:Se.SERVER,handler:"loop",params:{}};case"telegram":return{tier:Se.SERVER,handler:"telegram",params:{action:t.subcommand??t.args[0]??"start"}};case"sessions":return{tier:Se.SERVER,handler:"sessions",params:{action:t.subcommand??t.args[0]??"list"}};case"worktree":return{tier:Se.LOCAL,handler:"worktree",params:{action:t.subcommand??t.args[0]??"list",name:t.subcommand?t.args[0]:t.args[1]}};case"soul":return{tier:Se.LOCAL,handler:"soul",params:{action:t.subcommand??t.args[0]??"show",name:t.subcommand?t.args[0]:t.args[1]}};case"cloud":return{tier:Se.LOCAL,handler:"cloud",params:{action:t.subcommand??t.args[0]??"status"}};case"skill":return{tier:Se.LOCAL,handler:"skill",params:{action:t.args[0]||"help",target:t.args[1]||null,extraArgs:t.args.slice(2)}};case"plugin":return{tier:Se.LOCAL,handler:"plugin",params:{action:t.args[0]||"help",target:t.args[1]||null,extraArgs:t.args.slice(2)}};case"persona":return{tier:Se.LOCAL,handler:"persona",params:{action:t.args[0]||"help",target:t.args[1]||null,extraArgs:t.args.slice(2)}};case"upgrade":return{tier:Se.LOCAL,handler:"upgrade",params:{version:t.args[0]||null}};case"help":return{tier:Se.LOCAL,handler:"help",params:{command:t.subcommand}};case"version":return{tier:Se.LOCAL,handler:"version",params:{}};case"query":default:return{tier:e,handler:"query",params:{query:t.query,stdinContent:t.stdinContent}}}}function ape(t){let e=t.subcommand??t.args[0]??"show";return{tier:Se.LOCAL,handler:`config:${e}`,params:{key:t.args[0],value:t.args[1]}}}function lpe(t){let e=t.subcommand??t.args[0]??"list";return{tier:Se.LOCAL,handler:`mcp:${e}`,params:{name:t.args[0],args:t.args.slice(1)}}}function cpe(t){let e=t.subcommand??t.args[0]??"list";return{tier:Se.LOCAL,handler:`prompt:${e}`,params:{name:t.args[0],args:t.args.slice(1)}}}function upe(t){let e=t.subcommand??t.args[0];return{tier:Se.LOCAL,handler:e?`stats:${e}`:"stats",params:{}}}function dpe(t){let e=t.subcommand??t.args[0]??"list";return{tier:Se.LOCAL,handler:`history:${e}`,params:{query:t.args[0],id:t.args[0]}}}var ppe=new Set(["--model","--host","--continue-chat","-c","--signature","--base"]);function mpe(t){let e=[...t.subcommand?[t.subcommand]:[],...t.args],r=[];for(let s=0;s<e.length;s++){let o=e[s];if(ppe.has(o)){e[s+1]!==void 0&&!e[s+1].startsWith("-")&&s++;continue}o.startsWith("-")||r.push(o)}let n=r.join(" ");return{tier:Se.SERVER,handler:"run",params:{operation:n}}}ft();b1();Ro();_e();import{createInterface as Eze}from"readline";import{spawn as yze}from"child_process";q1();Mn();gd();ct();eI();var S6e={timeout:12e4,retries:3,retryDelay:1e3,handshakeTimeout:5e3};function T6e(t,e){let r=new URL(t),n=r.protocol==="https:"?"wss:":"ws:";if(e){if(!(r.protocol==="https:"||r.protocol==="wss:")&&!oh(r.hostname))throw new Error(`Refusing to send the cloud key over an insecure (${r.protocol}) connection to ${r.hostname} \u2014 use https/wss.`);return{url:`${n}//${r.host}/v1/ws/execute`,headers:{Authorization:`Bearer ${e}`}}}return{url:`${n}//${r.host}/ws/execute`}}var Bs=class{options;ws=null;activityTimeout=null;mcpExecutor=null;constructor(e){this.options={...S6e,...e}}async initializeMCP(){if(!this.mcpExecutor){let{ClientMCPExecutor:e}=await Promise.resolve().then(()=>(xd(),Od)),{createHeadlessMcpGate:r}=await Promise.resolve().then(()=>(Lo(),Qa));this.mcpExecutor=new e,this.mcpExecutor.setPermissionGate(r()),await this.mcpExecutor.initialize(),j(`MCP executor initialized with ${this.mcpExecutor.getConnectionCount()} connections`)}}async executeRequest(e,r){let n=null,s=T6e(this.options.url,this.options.cloudApiKey);for(let o=0;o<this.options.retries;o++)try{return await this.executeWithRetry(s,e,r)}catch(i){if(n=i instanceof Error?i:new Error(String(i)),j(`Attempt ${o+1} failed: ${n.message}`),n instanceof Qu||n.message.includes("Authentication"))throw n;if(this.options.cloudApiKey&&n instanceof Ku){let a=new URL(this.options.url);throw new Do(jl(a.hostname),"CLOUD_UNREACHABLE")}if(o<this.options.retries-1){let a=this.options.retryDelay*Math.pow(2,o);j(`Retrying in ${a}ms...`),await this.sleep(a)}}throw n??new Na("Max retries exceeded")}async executeWithRetry(e,r,n){return new Promise((s,o)=>{let i=e.url;j(`Connecting to ${i}`);try{this.ws=new fs(i,{handshakeTimeout:this.options.handshakeTimeout,...e.headers?{headers:e.headers}:{}})}catch{let p=new URL(this.options.url);o(new Ku(p.hostname||"localhost",p.port||void 0));return}let a=!1,l=null,c=null,u=!1,d=p=>{a||(a=!0,this.cleanup(),o(p))};this.resetActivityTimeout(()=>{a||(this.cleanup(),o(new qf("WebSocket activity",this.options.timeout)))}),this.ws.on("open",()=>{j("WebSocket connected, sending request"),this.ws?.send(JSON.stringify({...r,protocol_version:2}))}),this.ws.on("message",p=>{this.resetActivityTimeout(()=>{a||(this.cleanup(),o(new qf("WebSocket activity",this.options.timeout)))});let f;try{f=JSON.parse(p.toString())}catch(_){let E=p?String(p):"<undefined>";j(`Failed to parse message: ${E}`),d(new Error(`Failed to parse server message: ${_.message}`));return}let h=Y1(f,k4);if(h.kind==="malformed"){let _=v4(f);d(_?new Qu("cloud_error",_):new Na(`Malformed server frame: ${h.reason}`));return}if(h.kind==="unknown"){u||(u=!0,j(`Received an unrecognized frame type '${h.type}'; ignoring`));return}let g=h.frame;if(c===null&&g.protocol_version!==void 0&&(c=K1(g.protocol_version),c==="hard")){d(new Na(Q1(g.protocol_version)));return}if(W1.has(g.type)&&!V1(g)){d(new Na(`Malformed ${g.type} payload`));return}this.handleMessage(g,n,_=>{a=!0,l=_,this.cleanup(),s(_)},_=>{a=!0,this.cleanup(),o(_)})}),this.ws.on("error",p=>{if(j(`WebSocket error: ${p.message}`),!a){a=!0,this.cleanup();let f=new URL(this.options.url);o(new Ku(f.hostname||"localhost",f.port||void 0))}}),this.ws.on("close",(p,f)=>{j(`WebSocket closed: ${p} ${f.toString()}`),a||(a=!0,this.cleanup(),l?s(l):o(new Na(`Connection closed unexpectedly: ${p}`)))})})}handleMessage(e,r,n,s){switch(e.type){case"token":{let o=e;r?.onToken?.(o.data);break}case"complete":{let o=e,i=o.metadata||{},a=this.convertServerMetadata(o),l={result:o.result,metadata:a,clientSideExecution:i.client_side_execution===!0,userRequest:i.user_request};r?.onComplete?.(l),n(l);break}case"error":{let o=e,i=new Qu(o.code,o.message);r?.onError?.(i),s(i);break}case"mcp_query_tools":{j("Received mcp_query_tools request"),this.handleMCPQueryTools(e);break}case"mcp_tool_request":{j("Received mcp_tool_request"),this.handleMCPToolRequest(e);break}default:j(`Unknown message type: ${e.type}`)}}convertServerMetadata(e){let r=e.metadata||{},n,s;r.tokens?(n=r.tokens.input,s=r.tokens.output):(n=r.input_tokens,s=r.output_tokens);let o=r.cost??r.cost_usd,i=r.execution_time??r.total_time;return{function_name:e.function_name,tokens_in:n,tokens_out:s,cost:typeof o=="number"?o:void 0,model:typeof r.model=="string"?r.model:void 0,provider:typeof r.provider=="string"?r.provider:void 0,execution_time:typeof i=="number"?i:void 0,task_id:typeof r.task_id=="string"?r.task_id:void 0,chat_url:typeof r.chat_url=="string"?r.chat_url:void 0}}async handleMCPQueryTools(e){try{if(!this.mcpExecutor){let{ClientMCPExecutor:n}=await Promise.resolve().then(()=>(xd(),Od)),{createHeadlessMcpGate:s}=await Promise.resolve().then(()=>(Lo(),Qa));this.mcpExecutor=new n,this.mcpExecutor.setPermissionGate(s()),await this.mcpExecutor.initialize()}let r=await this.mcpExecutor.handleQueryTools(e);this.ws?.send(JSON.stringify(r))}catch(r){let n=r instanceof Error?r.message:String(r),s=r instanceof Error?r.stack:void 0;j(`Error handling mcp_query_tools: ${n}${s?`
|
|
3581
3581
|
${s}`:""}`),this.ws?.send(JSON.stringify({type:"mcp_query_tools_response",request_id:e.request_id||"unknown",success:!1,error:n,tools:[]}))}}async handleMCPToolRequest(e){try{if(!this.mcpExecutor){let{ClientMCPExecutor:n}=await Promise.resolve().then(()=>(xd(),Od)),{createHeadlessMcpGate:s}=await Promise.resolve().then(()=>(Lo(),Qa));this.mcpExecutor=new n,this.mcpExecutor.setPermissionGate(s()),await this.mcpExecutor.initialize()}let r=await this.mcpExecutor.handleToolExecution(e);this.ws?.send(JSON.stringify(r))}catch(r){j(`Error handling mcp_tool_request: ${r}`),this.ws?.send(JSON.stringify({type:"mcp_tool_response",request_id:e.request_id||"unknown",success:!1,error:String(r)}))}}resetActivityTimeout(e){this.activityTimeout&&clearTimeout(this.activityTimeout),this.activityTimeout=setTimeout(e,this.options.timeout)}cleanup(){if(this.activityTimeout&&(clearTimeout(this.activityTimeout),this.activityTimeout=null),this.ws){try{this.ws.close()}catch(e){j(`WebSocket close error: ${e instanceof Error?e.message:String(e)}`)}this.ws=null}}async shutdownMCP(){this.mcpExecutor&&(await this.mcpExecutor.shutdown(),this.mcpExecutor=null)}disconnect(){this.cleanup()}sleep(e){return new Promise(r=>setTimeout(r,e))}};_e();import tw from"node:process";import Ile from"node:process";import JC from"node:process";var b6e=(t,e,r,n)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;let s=Object.getOwnPropertyDescriptor(t,r),o=Object.getOwnPropertyDescriptor(e,r);!C6e(s,o)&&n||Object.defineProperty(t,r,o)},C6e=function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},w6e=(t,e)=>{let r=Object.getPrototypeOf(e);r!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,r)},v6e=(t,e)=>`/* Wrapped ${t}*/
|
|
3582
3582
|
${e}`,k6e=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),A6e=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),I6e=(t,e,r)=>{let n=r===""?"":`with ${r.trim()}() `,s=v6e.bind(null,n,e.toString());Object.defineProperty(s,"name",A6e);let{writable:o,enumerable:i,configurable:a}=k6e;Object.defineProperty(t,"toString",{value:s,writable:o,enumerable:i,configurable:a})};function iF(t,e,{ignoreNonConfigurable:r=!1}={}){let{name:n}=t;for(let s of Reflect.ownKeys(e))b6e(t,e,s,r);return w6e(t,e),I6e(t,e,n),t}var KC=new WeakMap,Cle=(t,e={})=>{if(typeof t!="function")throw new TypeError("Expected a function");let r,n=0,s=t.displayName||t.name||"<anonymous>",o=function(...i){if(KC.set(o,++n),n===1)r=t.apply(this,i),t=void 0;else if(e.throw===!0)throw new Error(`Function \`${s}\` can only be called once`);return r};return iF(o,t),KC.set(o,n),o};Cle.callCount=t=>{if(!KC.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return KC.get(t)};var wle=Cle;var Au=[];Au.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Au.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Au.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var QC=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",aF=Symbol.for("signal-exit emitter"),lF=globalThis,D6e=Object.defineProperty.bind(Object),cF=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(lF[aF])return lF[aF];D6e(lF,aF,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],s=n.indexOf(r);s!==-1&&(s===0&&n.length===1?n.length=0:n.splice(s,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let s=!1;for(let o of this.listeners[e])s=o(r,n)===!0||s;return e==="exit"&&(s=this.emit("afterExit",r,n)||s),s}},XC=class{},R6e=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),uF=class extends XC{onExit(){return()=>{}}load(){}unload(){}},dF=class extends XC{#i=pF.platform==="win32"?"SIGINT":"SIGHUP";#r=new cF;#e;#s;#p;#t={};#o=!1;constructor(e){super(),this.#e=e,this.#t={};for(let r of Au)this.#t[r]=()=>{let n=this.#e.listeners(r),{count:s}=this.#r,o=e;if(typeof o.__signal_exit_emitter__=="object"&&typeof o.__signal_exit_emitter__.count=="number"&&(s+=o.__signal_exit_emitter__.count),n.length===s){this.unload();let i=this.#r.emit("exit",null,r),a=r==="SIGHUP"?this.#i:r;i||e.kill(e.pid,a)}};this.#p=e.reallyExit,this.#s=e.emit}onExit(e,r){if(!QC(this.#e))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#r.on(n,e),()=>{this.#r.removeListener(n,e),this.#r.listeners.exit.length===0&&this.#r.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#r.count+=1;for(let e of Au)try{let r=this.#t[e];r&&this.#e.on(e,r)}catch{}this.#e.emit=(e,...r)=>this.#m(e,...r),this.#e.reallyExit=e=>this.#n(e)}}unload(){this.#o&&(this.#o=!1,Au.forEach(e=>{let r=this.#t[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,r)}catch{}}),this.#e.emit=this.#s,this.#e.reallyExit=this.#p,this.#r.count-=1)}#n(e){return QC(this.#e)?(this.#e.exitCode=e||0,this.#r.emit("exit",this.#e.exitCode,null),this.#p.call(this.#e,this.#e.exitCode)):0}#m(e,...r){let n=this.#s;if(e==="exit"&&QC(this.#e)){typeof r[0]=="number"&&(this.#e.exitCode=r[0]);let s=n.call(this.#e,e,...r);return this.#r.emit("exit",this.#e.exitCode,null),s}else return n.call(this.#e,e,...r)}},pF=globalThis.process,{onExit:vle,load:X_t,unload:J_t}=R6e(QC(pF)?new dF(pF):new uF);var kle=JC.stderr.isTTY?JC.stderr:JC.stdout.isTTY?JC.stdout:void 0,N6e=kle?wle(()=>{vle(()=>{kle.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},Ale=N6e;var ZC=!1,xm={};xm.show=(t=Ile.stderr)=>{t.isTTY&&(ZC=!1,t.write("\x1B[?25h"))};xm.hide=(t=Ile.stderr)=>{t.isTTY&&(Ale(),ZC=!0,t.write("\x1B[?25l"))};xm.toggle=(t,e)=>{t!==void 0&&(ZC=t),ZC?xm.show(e):xm.hide(e)};var mF=xm;var DE=kt(fF(),1);_e();import yo from"node:process";function hF(){return yo.platform!=="win32"?yo.env.TERM!=="linux":!!yo.env.CI||!!yo.env.WT_SESSION||!!yo.env.TERMINUS_SUBLIME||yo.env.ConEmuTask==="{cmd::Cmder}"||yo.env.TERM_PROGRAM==="Terminus-Sublime"||yo.env.TERM_PROGRAM==="vscode"||yo.env.TERM==="xterm-256color"||yo.env.TERM==="alacritty"||yo.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var x6e={info:m.blue("\u2139"),success:m.green("\u2714"),warning:m.yellow("\u26A0"),error:m.red("\u2716")},M6e={info:m.blue("i"),success:m.green("\u221A"),warning:m.yellow("\u203C"),error:m.red("\xD7")},P6e=hF()?x6e:M6e,IE=P6e;Z1();var L6e=cc();function gF(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return t.replace(L6e,"")}uI();function _F({stream:t=process.stdout}={}){return!!(t&&t.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}import Ole from"node:process";function EF(){let{env:t}=Ole,{TERM:e,TERM_PROGRAM:r}=t;return Ole.platform!=="win32"?e!=="linux":!!t.WT_SESSION||!!t.TERMINUS_SUBLIME||t.ConEmuTask==="{cmd::Cmder}"||r==="Terminus-Sublime"||r==="vscode"||e==="xterm-256color"||e==="alacritty"||e==="rxvt-unicode"||e==="rxvt-unicode-256color"||t.TERMINAL_EMULATOR==="JetBrains-JediTerm"}import li from"node:process";var F6e=3,yF=class{#i=0;start(){this.#i++,this.#i===1&&this.#r()}stop(){if(this.#i<=0)throw new Error("`stop` called more times than `start`");this.#i--,this.#i===0&&this.#e()}#r(){li.platform==="win32"||!li.stdin.isTTY||(li.stdin.setRawMode(!0),li.stdin.on("data",this.#s),li.stdin.resume())}#e(){li.stdin.isTTY&&(li.stdin.off("data",this.#s),li.stdin.pause(),li.stdin.setRawMode(!1))}#s(e){e[0]===F6e&&li.emit("SIGINT")}},$6e=new yF,SF=$6e;var U6e=kt(fF(),1),TF=class{#i=0;#r=!1;#e=0;#s=-1;#p=0;#t;#o;#n;#m;#h;#c;#u;#d;#g;#a;#l;color;constructor(e){typeof e=="string"&&(e={text:e}),this.#t={color:"cyan",stream:tw.stderr,discardStdin:!0,hideCursor:!0,...e},this.color=this.#t.color,this.spinner=this.#t.spinner,this.#h=this.#t.interval,this.#n=this.#t.stream,this.#c=typeof this.#t.isEnabled=="boolean"?this.#t.isEnabled:_F({stream:this.#n}),this.#u=typeof this.#t.isSilent=="boolean"?this.#t.isSilent:!1,this.text=this.#t.text,this.prefixText=this.#t.prefixText,this.suffixText=this.#t.suffixText,this.indent=this.#t.indent,tw.env.NODE_ENV==="test"&&(this._stream=this.#n,this._isEnabled=this.#c,Object.defineProperty(this,"_linesToClear",{get(){return this.#i},set(r){this.#i=r}}),Object.defineProperty(this,"_frameIndex",{get(){return this.#s}}),Object.defineProperty(this,"_lineCount",{get(){return this.#e}}))}get indent(){return this.#d}set indent(e=0){if(!(e>=0&&Number.isInteger(e)))throw new Error("The `indent` option must be an integer from 0 and up");this.#d=e,this.#f()}get interval(){return this.#h??this.#o.interval??100}get spinner(){return this.#o}set spinner(e){if(this.#s=-1,this.#h=void 0,typeof e=="object"){if(e.frames===void 0)throw new Error("The given spinner must have a `frames` property");this.#o=e}else if(!EF())this.#o=DE.default.line;else if(e===void 0)this.#o=DE.default.dots;else if(e!=="default"&&DE.default[e])this.#o=DE.default[e];else throw new Error(`There is no built-in spinner named '${e}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#g}set text(e=""){this.#g=e,this.#f()}get prefixText(){return this.#a}set prefixText(e=""){this.#a=e,this.#f()}get suffixText(){return this.#l}set suffixText(e=""){this.#l=e,this.#f()}get isSpinning(){return this.#m!==void 0}#_(e=this.#a,r=" "){return typeof e=="string"&&e!==""?e+r:typeof e=="function"?e()+r:""}#E(e=this.#l,r=" "){return typeof e=="string"&&e!==""?r+e:typeof e=="function"?r+e():""}#f(){let e=this.#n.columns??80,r=this.#_(this.#a,"-"),n=this.#E(this.#l,"-"),s=" ".repeat(this.#d)+r+"--"+this.#g+"--"+n;this.#e=0;for(let o of gF(s).split(`
|
|
3583
3583
|
`))this.#e+=Math.max(1,Math.ceil(yd(o,{countAnsiEscapeCodes:!0})/e))}get isEnabled(){return this.#c&&!this.#u}set isEnabled(e){if(typeof e!="boolean")throw new TypeError("The `isEnabled` option must be a boolean");this.#c=e}get isSilent(){return this.#u}set isSilent(e){if(typeof e!="boolean")throw new TypeError("The `isSilent` option must be a boolean");this.#u=e}frame(){let e=Date.now();(this.#s===-1||e-this.#p>=this.interval)&&(this.#s=++this.#s%this.#o.frames.length,this.#p=e);let{frames:r}=this.#o,n=r[this.#s];this.color&&(n=m[this.color](n));let s=typeof this.#a=="string"&&this.#a!==""?this.#a+" ":"",o=typeof this.text=="string"?" "+this.text:"",i=typeof this.#l=="string"&&this.#l!==""?" "+this.#l:"";return s+n+o+i}clear(){if(!this.#c||!this.#n.isTTY)return this;this.#n.cursorTo(0);for(let e=0;e<this.#i;e++)e>0&&this.#n.moveCursor(0,-1),this.#n.clearLine(1);return(this.#d||this.lastIndent!==this.#d)&&this.#n.cursorTo(this.#d),this.lastIndent=this.#d,this.#i=0,this}render(){return this.#u?this:(this.clear(),this.#n.write(this.frame()),this.#i=this.#e,this)}start(e){return e&&(this.text=e),this.#u?this:this.#c?this.isSpinning?this:(this.#t.hideCursor&&mF.hide(this.#n),this.#t.discardStdin&&tw.stdin.isTTY&&(this.#r=!0,SF.start()),this.render(),this.#m=setInterval(this.render.bind(this),this.interval),this):(this.text&&this.#n.write(`- ${this.text}
|
|
@@ -3588,7 +3588,7 @@ ${e}`,k6e=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),A6e=Obj
|
|
|
3588
3588
|
`+this.color(s,m.dim)}formatError(e){let r=[];return r.push(this.color(`${this.emoji("\u274C ")}${e.message}`,m.red)),e.suggestions&&e.suggestions.length>0&&(r.push(""),r.push(this.color(`${this.emoji("\u{1F4A1} ")}Solutions:`,m.yellow)),e.suggestions.forEach((n,s)=>{r.push(this.color(` ${s+1}. ${n}`,m.gray))})),r.join(`
|
|
3589
3589
|
`)}formatConfig(e){let r=[];r.push(this.color(`${this.emoji("\u{1F4CB} ")}Current AII Configuration:`,L.model)),r.push(`- Config file: ${e.configFile}`),r.push(`- Storage path: ${e.storagePath}`),e.apiUrl&&r.push(`- Aii Server: ${e.apiUrl}`);let n=e.hasApiKey?this.color("\u2713",m.green):this.color("\u2717",m.red),s=e.model.startsWith(e.provider+"/")?e.model.slice(e.provider.length+1):e.model;if(r.push(`- LLM provider: ${e.provider} (${s}) - ${n}`),e.webSearch){let o=e.webSearch.enabled?this.color("\u2713",m.green):this.color("\u2717",m.red);r.push(`- Web search: ${e.webSearch.provider??"none"} - ${o}`)}return e.issues&&e.issues.length>0&&r.push(`- Configuration issues: ${e.issues.length}`),r.join(`
|
|
3590
3590
|
`)}formatHealthCheck(e,r){let n=[],s=r?`Aii Doctor v${r}`:"Aii Doctor";n.push(this.color(s,L.model)),n.push("");let o=22;for(let l of e){let c=o-l.name.length-1,u=".".repeat(Math.max(2,c)),d,p;switch(l.status){case"ok":d="OK",p=m.green;break;case"warn":d="WARN",p=m.yellow;break;case"error":d="FAIL",p=m.red;break}let f=this.color(d,p),h=l.message?` (${l.message})`:"";n.push(` ${l.name} ${this.color(u,m.gray)} ${f}${h}`)}let i=e.filter(l=>l.status==="error").length,a=e.filter(l=>l.status==="warn").length;return n.push(""),i>0?n.push(` ${this.color(`${i} check${i>1?"s":""} failed.`,m.red)}`):a>0?n.push(` ${this.color("All checks passed with warnings.",m.yellow)}`):n.push(` ${this.color("All checks passed.",m.green)}`),n.join(`
|
|
3591
|
-
`)}};function Wn(t={}){return new vF(t)}Mn();So();_e();import*as $le from"readline";Mn();So();import*as Gs from"fs";import*as nw from"path";import*as xle from"os";import*as Pm from"fs";import{randomUUID as z6e}from"crypto";function AF(t,e,r=384){let n=`${t}.${process.pid}.${z6e()}.tmp`;try{Pm.writeFileSync(n,e,{encoding:"utf-8",mode:r,flag:"wx"}),Pm.renameSync(n,t)}catch(s){try{Pm.unlinkSync(n)}catch{}throw s}}var RE=nw.join(xle.homedir(),".aii","conversations"),IF=nw.join(RE,"current.json");function sw(){Gs.existsSync(RE)||Gs.mkdirSync(RE,{recursive:!0,mode:448});try{Gs.chmodSync(RE,448)}catch{}}function q6e(){return`conv_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function H6e(t){let r=t.trim().replace(/\s+/g," ");return r.length>50&&(r=r.substring(0,50).trim()+"..."),r}function Mle(t){return nw.join(RE,`${t}.json`)}function Ple(){sw();try{if(Gs.existsSync(IF)){let t=Gs.readFileSync(IF,"utf-8"),e=JSON.parse(t),r=Mle(e.id);if(Gs.existsSync(r)){let n=Gs.readFileSync(r,"utf-8");return JSON.parse(n)}}}catch{}return Lle()}function Lle(){sw();let t={id:q6e(),title:"New Conversation",messages:[],createdAt:Date.now(),updatedAt:Date.now()};return NE(t),j6e(t.id),t}function NE(t){if(sw(),t.title==="New Conversation"&&t.messages.length>0){let r=t.messages.find(n=>n.role==="user");r&&(t.title=H6e(r.content))}t.updatedAt=Date.now();let e=Mle(t.id);AF(e,JSON.stringify(t,null,2))}function j6e(t){sw(),AF(IF,JSON.stringify({id:t}))}function Fle(){return Lle()}au();var Y6e="0.18.
|
|
3591
|
+
`)}};function Wn(t={}){return new vF(t)}Mn();So();_e();import*as $le from"readline";Mn();So();import*as Gs from"fs";import*as nw from"path";import*as xle from"os";import*as Pm from"fs";import{randomUUID as z6e}from"crypto";function AF(t,e,r=384){let n=`${t}.${process.pid}.${z6e()}.tmp`;try{Pm.writeFileSync(n,e,{encoding:"utf-8",mode:r,flag:"wx"}),Pm.renameSync(n,t)}catch(s){try{Pm.unlinkSync(n)}catch{}throw s}}var RE=nw.join(xle.homedir(),".aii","conversations"),IF=nw.join(RE,"current.json");function sw(){Gs.existsSync(RE)||Gs.mkdirSync(RE,{recursive:!0,mode:448});try{Gs.chmodSync(RE,448)}catch{}}function q6e(){return`conv_${Date.now()}_${Math.random().toString(36).substring(2,9)}`}function H6e(t){let r=t.trim().replace(/\s+/g," ");return r.length>50&&(r=r.substring(0,50).trim()+"..."),r}function Mle(t){return nw.join(RE,`${t}.json`)}function Ple(){sw();try{if(Gs.existsSync(IF)){let t=Gs.readFileSync(IF,"utf-8"),e=JSON.parse(t),r=Mle(e.id);if(Gs.existsSync(r)){let n=Gs.readFileSync(r,"utf-8");return JSON.parse(n)}}}catch{}return Lle()}function Lle(){sw();let t={id:q6e(),title:"New Conversation",messages:[],createdAt:Date.now(),updatedAt:Date.now()};return NE(t),j6e(t.id),t}function NE(t){if(sw(),t.title==="New Conversation"&&t.messages.length>0){let r=t.messages.find(n=>n.role==="user");r&&(t.title=H6e(r.content))}t.updatedAt=Date.now();let e=Mle(t.id);AF(e,JSON.stringify(t,null,2))}function j6e(t){sw(),AF(IF,JSON.stringify({id:t}))}function Fle(){return Lle()}au();var Y6e="0.18.8",DF=class{configManager;parsed;running=!1;conversation;stats;formatter;effectiveProvider="";constructor(e,r){this.parsed=e,this.configManager=r,this.conversation=Ple(),this.stats={startTime:Date.now(),totalRequests:0,cumulativeTokens:0,cumulativeCost:0},this.formatter=Wn({colors:!e.flags.noColors,emojis:!e.flags.noEmojis})}async start(){for(this.running=!0,this.displayWelcome();this.running;)try{let e=await this.getUserInput();if(!e.trim()||await this.handleSpecialCommands(e))continue;this.conversation.messages.push({role:"user",content:e,timestamp:Date.now()}),NE(this.conversation),await this.processWithContext(e)}catch(e){if(e instanceof Error&&e.message==="EXIT")break;if(e instanceof Error&&e.message==="INTERRUPTED"){console.log(`
|
|
3592
3592
|
\u26A0\uFE0F Interrupted. Type /exit to quit or continue chatting.`);continue}console.error(m.red(`
|
|
3593
3593
|
\u274C Error: ${e instanceof Error?e.message:String(e)}`)),this.conversation.messages.length>0&&this.conversation.messages[this.conversation.messages.length-1].role==="user"&&(this.conversation.messages.pop(),NE(this.conversation))}}displayWelcome(){console.log("\u{1FABC} Entering interactive mode."),console.log(""),console.log("Controls:"),console.log(" \u2022 Enter - Send message"),console.log(" \u2022 End with \\ - Multi-line mode"),console.log(" \u2022 /exit - Quit chat"),console.log(" \u2022 /help - Show all commands"),console.log("")}getUserInput(){return new Promise((e,r)=>{let n=$le.createInterface({input:process.stdin,output:process.stdout}),s=[],o=!1,i=()=>{o=!0,n.close()},a=l=>{n.question(l,c=>{if(s.length===0&&c.trim().startsWith("/")){i(),e(c.trim());return}c.endsWith("\\")?(s.push(c.slice(0,-1)),a(" ")):(s.push(c),i(),e(s.join(`
|
|
3594
3594
|
`).trim()))})};n.on("SIGINT",()=>{i(),r(new Error("INTERRUPTED"))}),n.on("close",()=>{o||r(new Error("EXIT"))}),a("> ")})}async handleSpecialCommands(e){let r=e.trim().toLowerCase();if(r.startsWith("/"))r=r.slice(1);else return!1;switch(r){case"exit":case"quit":return await this.handleExit(),!0;case"help":return this.displayHelp(),!0;case"clear":case"new":return this.clearConversation(),!0;case"history":return this.displayConversationHistory(),!0;case"stats":return this.displayStats(),!0;case"version":return this.displayVersion(),!0;default:return console.log(m.yellow(`Unknown command: /${r}. Type /help for available commands.`)),console.log(""),!0}}async processWithContext(e){let r=await this.configManager.load(),n=this.configManager.validate();if(!n.valid)throw new Kr(n.issues.join(", "));let o=this.configManager.getServerApiKey()||"aii_sk_7WyvfQ0PRzufJ1G66Qn8Sm4gW9Tealpo6vOWDDUeiv4",i=Sr(this.parsed.flags.model??""),a=zr(i||void 0,r.llm.provider),l=Tr(i||r.llm.model,a);this.effectiveProvider=a;let c=this.configManager.getApiKey(a);if(!c)throw new Yt(`Missing API key for provider: ${a}`);this.stats.totalRequests++;let u=ci(!this.parsed.flags.noAnimations);u.start("");let d=ui({spinner:u,enabled:!this.parsed.flags.noStreaming}),p=this.conversation.messages.slice(-21,-1).map(y=>({role:y.role,content:y.content})),f={api_key:o,system_prompt:null,user_prompt:e,user_message:e,output_mode:"CLEAN",streaming:!this.parsed.flags.noStreaming,model:l,llm_provider:a,llm_api_key:c,provider_api_key:c,client_type:"cli",offline:this.parsed.flags.offline,conversation_history:p.length>0?p:void 0,soul:dn.getInstance().getSoulName()},h=this.parsed.flags.host?`http://${this.parsed.flags.host}`:r.api.url,g=new Bs({url:h}),_="",E=!1;try{let y=await g.executeRequest(f,{onToken:C=>{_+=C,E=!0,d.onToken(C)}});d.flush();let T=y.result||_;!E&&T&&console.log(T),console.log(""),y.metadata&&this.displayExecutionSummary(y.metadata),T&&(this.conversation.messages.push({role:"assistant",content:T,timestamp:Date.now()}),NE(this.conversation))}catch(y){throw u.stop(!0),y}finally{g.disconnect()}}displayExecutionSummary(e){let r=e.cost||0,n=e.tokens_in||0,s=e.tokens_out||0,o=n+s;this.stats.cumulativeTokens+=o,this.stats.cumulativeCost+=r;let i=e.provider,a=!i;console.log(this.formatter.formatExecutionSummary({provider:i||this.effectiveProvider,providerInferred:a,model:e.model,tokens_in:n,tokens_out:s,cost:r,execution_time:e.execution_time})),console.log("")}clearConversation(){this.conversation=Fle(),console.clear(),this.displayWelcome()}displayConversationHistory(){if(this.conversation.messages.length===0){console.log(`
|
|
@@ -3972,7 +3972,7 @@ Additional rules:
|
|
|
3972
3972
|
`));let r=this.checkCapacityWarnings();return r.length>0&&(e.push("\u2550".repeat(60)),e.push(...r),e.push("SUNSET STAGE: Loop will terminate soon. Focus on wrapping up gracefully:"),e.push("- Save your current work"),e.push("- Update any status files or memory"),e.push("- Ensure external systems are in a stable state"),e.push("\u2550".repeat(60)),e.push("")),e.push("IMPORTANT: Every response MUST include at least one tool call."),e.push("Do not summarize, do not ask questions, do not produce text-only responses."),e.push("If unsure what to do, read your instruction files."),this.state.userNotes.length>0&&(e.push(""),e.push("USER NOTE (typed by the user during loop execution):"),e.push(`- ${this.state.userNotes[0]}`),this.state.userNotes.length>1&&e.push(`(${this.state.userNotes.length-1} more note(s) queued for subsequent iterations)`),e.push("Take this note into account for this iteration.")),e.join(`
|
|
3973
3973
|
`)}checkLimits(){return this.config.durationSeconds>0&&(Date.now()-this.state.startTime)/1e3>=this.config.durationSeconds?"duration_exceeded":za(this.state.totalCost,this.config.budgetUsd)?"budget_exceeded":this.config.inputTokensLimit>0&&this.state.totalInputTokens>=this.config.inputTokensLimit?"input_tokens_exceeded":this.config.outputTokensLimit>0&&this.state.totalOutputTokens>=this.config.outputTokensLimit?"output_tokens_exceeded":null}clearSessionMessages(){this.session.messages=[]}async processQueuedMessages(){if(!this.processingQueue){this.processingQueue=!0;try{let{useInputStore:e}=await Promise.resolve().then(()=>(ul(),Op)),r=e.getState();if(!r.hasQueuedMessages())return;for(;r.hasQueuedMessages();){let n=r.dequeueTypeAhead();if(!n?.trim())continue;let s=n.trim(),o=Bp(s);if(s==="/stop"){for(this.getPhase()==="paused"&&(this.finalizePause(),this.transition("running"),tt().setLoopPaused(!1,null),this.resolvePausePromise()),this.transition("stopping"),this.stoppingToastId=He().nextId,this.printer(L.success("\u25C6 Stopping after current turn completes..."),{toast:!0,persistent:!0}),this.pendingNote&&(this.pendingNote=null,this.noteToastId!==null&&(He().clearToast(this.noteToastId),this.noteToastId=null),this.printer(L.dim("\u25C6 Note discarded \u2014 loop is stopping."),{toast:!0}));r.hasQueuedMessages();){let a=r.dequeueTypeAhead()?.trim()??"",l=a.startsWith("/")&&!a.includes(`
|
|
3974
3974
|
`)&&!Bp(a)?.noteText;a&&!l&&(He().clearFirstPersistent(),this.printer(L.dim("\u25C6 Note discarded \u2014 loop is stopping."),{toast:!0}))}return}else if(s==="/resume")this.getPhase()==="paused"?this.resumeFromPause("manual"):this.getPhase()==="stopping"?this.printer(L.dim("\u25C6 Loop is stopping \u2014 cannot resume"),{toast:!0}):this.printer(L.dim("\u25C6 Loop is not paused"),{toast:!0});else if(s.startsWith("/pause")){if(this.getPhase()==="stopping")this.printer(L.dim("\u25C6 Loop is stopping \u2014 cannot pause"),{toast:!0});else if(this.getPhase()==="paused"){let i=s.slice(6).trim();if(i){let a=YF(i);a===0?this.printer(L.dim(`\u25C6 Invalid duration: ${i} (use e.g. 30s, 5m, 2h)`),{toast:!0}):(this.updatePause(a),this.pauseToastId!==null&&He().clearToast(this.pauseToastId),this.pauseToastId=He().nextId,this.printer(L.success("\u25C6 Pause updated"),{toast:!0,persistent:!0,expiresAt:this.state.pauseUntil}))}else this.updatePause(),this.pauseToastId!==null&&He().clearToast(this.pauseToastId),this.pauseToastId=He().nextId,this.printer(L.success("\u25C6 Pause updated \u2014 indefinite, type /resume to continue"),{toast:!0,persistent:!0})}else if(this.getPhase()==="running"){let i=s.slice(6).trim();if(i){let a=YF(i);a===0?this.printer(L.dim(`\u25C6 Invalid duration: ${i} (use e.g. 30s, 5m, 2h)`),{toast:!0}):(this.enterPause(a),this.pauseToastId=He().nextId,this.printer(L.success("\u25C6 Loop pausing \u2014 will pause after current tool completes"),{toast:!0,persistent:!0}))}else this.enterPause(),this.pauseToastId=He().nextId,this.printer(L.success("\u25C6 Loop pausing \u2014 will pause after current tool completes"),{toast:!0,persistent:!0})}}else if(s==="/stats"||s==="/status")hce(this.state,this.state.totalToolCalls,this.consecutiveFailedIterations,this.printer);else if(o){let i=o.noteText;if(!i)this.printer(L.dim(`\u25C6 ${o.prefix} requires a message (usage: ${o.prefix} <text>)`),{toast:!0});else{this.noteToastId!==null&&He().clearToast(this.noteToastId),this.pendingNote=i;let l=[...He().toasts].reverse().find(c=>c.persistent);this.noteToastId=l?.id??null}}else if(s.startsWith("/")&&!s.includes(`
|
|
3975
|
-
`)){let i=
|
|
3975
|
+
`)){let i=s.split(/\s+/)[0],a=Array.from(i).slice(0,24).join("").replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u200e\u200f\u202a-\u202e\u2066-\u2069]/g,"");i==="/loop"?this.printer(L.dim("\u25C6 A loop is already running \u2014 /stop it first to start a new one."),{toast:!0}):this.printer(L.dim(`\u25C6 "${a}" isn't a loop command \u2014 /note /inject /pause /resume /stop /stats only; /stop to run other commands.`),{toast:!0})}else s&&this.state.userNotes.push(s)}}finally{this.processingQueue=!1}}}getLastAssistantText(){let e=this.session.messages.filter(n=>n.role==="assistant");if(e.length===0)return"";let r=e[e.length-1];return typeof r.content=="string"?r.content:""}async runWithRetry(e){let n=0;for(;;){n++;try{await this.agentController.run(e,this.session);return}catch(s){if(this.getPhase()==="aborted")throw s;if(this.agentController.isPauseRequested()){it("[loop] Context compaction interrupted iteration \u2014 restarting"),this.printer(m.dim(" Context compacted \u2014 restarting iteration...")),this.agentController.resetInterrupt(),this.agentController.markSkipInitialDraw(),this.clearSessionMessages();continue}if(wce(s)){it("[loop] Context overflow detected \u2014 clearing context and retrying"),this.printer(m.yellow(" \u26A0 Context window full \u2014 restarting iteration with fresh context")),this.agentController.resetInterrupt(),this.agentController.markSkipInitialDraw(),this.clearSessionMessages();continue}if(!Cce(s)||this.checkLimits())throw s;if(n>=10)throw this.printer(m.yellow(" \u26A0 Max retries (10) exceeded for this iteration")),s;let o=Math.min(2e3*Math.pow(2,n-1),3e4);if(this.printer(m.yellow(` \u26A0 Connection lost: ${Zm(s)}`)),this.printer(m.dim(` Retrying in ${o/1e3}s (attempt ${n}/10)...`)),it(`[loop] Before backoff sleep: state.phase=${this.getPhase()}`),await new Promise(i=>setTimeout(i,o)),it(`[loop] After backoff sleep: state.phase=${this.getPhase()}`),this.getPhase()==="aborted")throw s;this.agentController.resetInterrupt(),this.agentController.markSkipInitialDraw(),this.clearSessionMessages()}}}checkCompletion(e,r){let n=!!this.config.completionPromise,s=!!this.config.verifyCommand;return n&&s?e&&r?"both_passed":null:n&&e?"completion_promise":s&&r?"verification_passed":null}};GE();Km();function Ace(t){t.register({name:"loop",description:"Start autonomous agent loop (all options optional)",usage:'/loop ["<prompt>"] [--max <N>] [--promise "<string>"] [--verify "<cmd>"] [--budget <$N>] [--duration <N>[s|m|h]]',handler:async(e,r)=>{if(e.trim()==="help"||e.trim()==="--help"||e.trim()==="-h")return{continue:!0,handled:!0,output:[q().accent.bold("Ralph Wiggum Loop - Autonomous Agent Loop"),"",m.yellow("Usage:"),' /loop ["<prompt>"] [options]',"",m.yellow("Options:")," --max <N> Maximum iterations (default: unlimited, hard cap: 1000)",' --promise "<string>" Completion string to detect in agent output',' --verify "<command>" Shell command that must exit 0 for completion'," --budget <$N> Cost budget in USD (estimated)"," --input-tokens-limit <N> Input token limit (exact)"," --output-tokens-limit <N> Output token limit (exact)"," --duration <N>[s|m|h] Maximum duration (seconds/minutes/hours)"," --time <N>[s|m|h] Alias for --duration","",m.yellow("Modes:")," \u2022 With --verify/--promise: Task completion mode (loop until criteria met)"," \u2022 Without: AGENTS.md-driven continuous activity (loop until Ctrl+C)","",m.yellow("Subcommands:")," /loop list Show saved loops in this project with status"," /loop resume <id> Resume a stopped/interrupted loop by its #id"," (add --max/--budget/--duration/... to raise a limit;"," --force to override a live-process lock)","",m.yellow("Examples:")," /loop # Continuous AGENTS.md-driven activity",' /loop "fix the tests" --verify "npm test" # Loop until tests pass'," /loop --budget $5 --max 20 # Limited by cost and iterations"," /loop --duration 5m # Run for 5 minutes"," /loop list # List saved loops (canceled, stopped, completed\u2026)"," /loop resume k3x9 --budget 10 # Resume a saved loop, raising its budget","",m.yellow("Using with Skills:")," To use loop with a skill: invoke the skill first, then start /loop without prompt",m.dim(" (The loop prompt is for task descriptions, not skill invocations)"),"",m.yellow("Limits:")," \u2022 Press Ctrl+C to abort at any time"," \u2022 Sunset warnings at 90% of any capacity limit"," \u2022 All permissions auto-approved during loop"].join(`
|
|
3976
3976
|
`)};if(!t.agentController)return{continue:!0,handled:!0,output:m.red("Loop unavailable: agent controller not initialized")};let n,s,o;{let{routeLoopArgs:d,resolveResumeTarget:p,formatLoopList:f}=await Promise.resolve().then(()=>(p2(),d2)),{resolveLoopsDir:h,listLoops:g,claimLoop:_}=await Promise.resolve().then(()=>(Jm(),vw)),E=e.trim().split(/\s+/).filter(Boolean),y=d(E);if(y?.sub==="list"){let T=f(g(h(r.projectPath)));return{continue:!0,handled:!0,output:["",m.yellow(" Saved loops:"),...T,""].join(`
|
|
3977
3977
|
`)}}if(y?.sub==="resume"){let T=h(r.projectPath),C=p(y.rest,T,r.projectPath);if(C.kind==="usage"){let w=f(g(T),!0);return{continue:!0,handled:!0,output:["",m.yellow(" Resumable loops:"),...w,"",m.dim(" Usage: /loop resume <id> [--max N] [--budget N] [--duration Nm] [--force]"),""].join(`
|
|
3978
3978
|
`)}}if(C.kind==="refuse")return{continue:!0,handled:!0,output:m.yellow(`\u25C6 ${C.message}`)};if(C.kind==="resume"){if(!_(C.record.id,process.pid,T,C.force))return{continue:!0,handled:!0,output:m.yellow("\u25C6 This loop is being resumed by another aii process.")};n=C.record,s=C.config,C.force?o="Resuming with --force (live-pid check overridden).":C.cwdNotice&&(o=C.cwdNotice)}else o=C.notice}}let i="";if(r.goal?.status==="active"){let{goalReducer:d}=await Promise.resolve().then(()=>(uc(),t8)),p=d(r.goal,{type:"pause"});p.changed&&(r.goal=p.goal,t.agentController?.setActiveGoalText(null),i=m.dim("\u25CE Goal auto-paused for the loop \u2014 /goal resume afterwards.")+`
|
|
@@ -4306,10 +4306,10 @@ ${r.yellow("CONFIG FILE:")}
|
|
|
4306
4306
|
.aii/settings.json Project config (committed, restrict-only)
|
|
4307
4307
|
.aii/settings.local.json Your local overrides (gitignored)
|
|
4308
4308
|
${r.gray("Skip both for a session with: aii --no-project-config")}
|
|
4309
|
-
`)}import*as fi from"fs";lr();async function due(t,e){let r=Wn({colors:!t.flags.noColors,emojis:!t.flags.noEmojis}),n=[],s=`${e.getConfigDir()}/config.yaml`;e.configExists()?n.push({name:"Config",status:"ok",message:s.replace(process.env.HOME||"","~")}):n.push({name:"Config",status:"warn",message:"Not found (using defaults)"});let o=await e.load();e.getApiKey()?n.push({name:"API Key",status:"ok",message:`${o.llm.provider}:${o.llm.model.replace(`${o.llm.provider}/`,"")}`}):n.push({name:"API Key",status:"error",message:`Not configured for ${o.llm.provider}`});let a=await Qze(o.api.url);n.push({name:"Aii Server",status:a.ok?"ok":"error",message:a.message});let l=`${e.getConfigDir()}/mcp_servers.json`;if(fi.existsSync(l))try{let f=fi.readFileSync(l,"utf-8"),h=JSON.parse(f),g=Object.keys(h.mcpServers??{}).length;g>0?n.push({name:"MCP Servers",status:"ok",message:`${g} configured`}):n.push({name:"MCP Servers",status:"warn",message:"Not configured"})}catch{n.push({name:"MCP Servers",status:"warn",message:"Invalid config"})}else n.push({name:"MCP Servers",status:"warn",message:"Not configured"});if(aw())try{let{execSync:f}=await import("child_process"),g=f("docker --version",{timeout:5e3,encoding:"utf-8"}).trim().match(/Docker version ([\d.]+)/);n.push({name:"Docker",status:"ok",message:g?`v${g[1]}`:"Installed"})}catch{n.push({name:"Docker",status:"ok",message:"Installed"})}else n.push({name:"Docker",status:"error",message:"Not installed (brew install --cask docker)"});aw()?lw()?n.push({name:"Docker Daemon",status:"ok",message:"Running"}):n.push({name:"Docker Daemon",status:"error",message:"Not running (open -a Docker)"}):n.push({name:"Docker Daemon",status:"warn",message:"N/A (Docker not installed)"});let c=process.version;parseInt(c.slice(1).split(".")[0],10)>=18?n.push({name:"Node.js",status:"ok",message:c}):n.push({name:"Node.js",status:"error",message:`${c} (requires >= 18)`});let d=await Xze();n.push(...d),console.log(r.formatHealthCheck(n,lc)),n.some(f=>f.status==="error")&&process.exit(1)}async function Qze(t){try{let e=new AbortController,r=setTimeout(()=>e.abort(),3e3),n=await fetch(`${t}/api/status`,{signal:e.signal});if(clearTimeout(r),n.ok){let s=new URL(t);return{ok:!0,message:`${s.hostname}:${s.port||26169}`}}else return{ok:!1,message:`Not responding (${n.status})`}}catch(e){return e instanceof Error&&e.name==="AbortError"?{ok:!1,message:"Connection timeout"}:{ok:!1,message:"Not running"}}}async function Xze(){let t=[];try{let{getAiiHome:e}=await Promise.resolve().then(()=>(Xn(),dS)),r=`${e()}/skills`;if(!fi.existsSync(r))return t;let n=fi.readdirSync(r,{withFileTypes:!0});for(let s of n){if(!s.isDirectory()||s.name.startsWith("."))continue;let o=`${r}/${s.name}/SKILL.md`;fi.existsSync(o)||t.push({name:"Skill Shadow",status:"warn",message:`~/.aii/skills/${s.name}/ has no SKILL.md \u2014 may shadow other skills`})}try{let{PersonaManager:s}=await Promise.resolve().then(()=>(wt(),It));if(s.hasInstance()&&s.getInstance().isActive()){let o=s.getInstance().getActive();if(o)for(let i of o.skillPaths){let a=i.split("/").pop()||"",l=`${r}/${a}`;fi.existsSync(l)&&fi.existsSync(`${l}/SKILL.md`)&&t.push({name:"Skill Shadow",status:"ok",message:`"${a}" user-authored shadows persona-bundled (intentional?)`})}}}catch{}}catch{}return t}_e();lr();import{execSync as k2}from"node:child_process";var Hw="@aiiware/aii";async function pue(t){let e=t.args||[],r=t.subcommand||e[0]||"";if(t.flags.help||r==="help"||r==="--help"||e.includes("--help")){let n="0.18.
|
|
4310
|
-
`),await Jze(r)}async function Jze(t){let e="0.18.
|
|
4309
|
+
`)}import*as fi from"fs";lr();async function due(t,e){let r=Wn({colors:!t.flags.noColors,emojis:!t.flags.noEmojis}),n=[],s=`${e.getConfigDir()}/config.yaml`;e.configExists()?n.push({name:"Config",status:"ok",message:s.replace(process.env.HOME||"","~")}):n.push({name:"Config",status:"warn",message:"Not found (using defaults)"});let o=await e.load();e.getApiKey()?n.push({name:"API Key",status:"ok",message:`${o.llm.provider}:${o.llm.model.replace(`${o.llm.provider}/`,"")}`}):n.push({name:"API Key",status:"error",message:`Not configured for ${o.llm.provider}`});let a=await Qze(o.api.url);n.push({name:"Aii Server",status:a.ok?"ok":"error",message:a.message});let l=`${e.getConfigDir()}/mcp_servers.json`;if(fi.existsSync(l))try{let f=fi.readFileSync(l,"utf-8"),h=JSON.parse(f),g=Object.keys(h.mcpServers??{}).length;g>0?n.push({name:"MCP Servers",status:"ok",message:`${g} configured`}):n.push({name:"MCP Servers",status:"warn",message:"Not configured"})}catch{n.push({name:"MCP Servers",status:"warn",message:"Invalid config"})}else n.push({name:"MCP Servers",status:"warn",message:"Not configured"});if(aw())try{let{execSync:f}=await import("child_process"),g=f("docker --version",{timeout:5e3,encoding:"utf-8"}).trim().match(/Docker version ([\d.]+)/);n.push({name:"Docker",status:"ok",message:g?`v${g[1]}`:"Installed"})}catch{n.push({name:"Docker",status:"ok",message:"Installed"})}else n.push({name:"Docker",status:"error",message:"Not installed (brew install --cask docker)"});aw()?lw()?n.push({name:"Docker Daemon",status:"ok",message:"Running"}):n.push({name:"Docker Daemon",status:"error",message:"Not running (open -a Docker)"}):n.push({name:"Docker Daemon",status:"warn",message:"N/A (Docker not installed)"});let c=process.version;parseInt(c.slice(1).split(".")[0],10)>=18?n.push({name:"Node.js",status:"ok",message:c}):n.push({name:"Node.js",status:"error",message:`${c} (requires >= 18)`});let d=await Xze();n.push(...d),console.log(r.formatHealthCheck(n,lc)),n.some(f=>f.status==="error")&&process.exit(1)}async function Qze(t){try{let e=new AbortController,r=setTimeout(()=>e.abort(),3e3),n=await fetch(`${t}/api/status`,{signal:e.signal});if(clearTimeout(r),n.ok){let s=new URL(t);return{ok:!0,message:`${s.hostname}:${s.port||26169}`}}else return{ok:!1,message:`Not responding (${n.status})`}}catch(e){return e instanceof Error&&e.name==="AbortError"?{ok:!1,message:"Connection timeout"}:{ok:!1,message:"Not running"}}}async function Xze(){let t=[];try{let{getAiiHome:e}=await Promise.resolve().then(()=>(Xn(),dS)),r=`${e()}/skills`;if(!fi.existsSync(r))return t;let n=fi.readdirSync(r,{withFileTypes:!0});for(let s of n){if(!s.isDirectory()||s.name.startsWith("."))continue;let o=`${r}/${s.name}/SKILL.md`;fi.existsSync(o)||t.push({name:"Skill Shadow",status:"warn",message:`~/.aii/skills/${s.name}/ has no SKILL.md \u2014 may shadow other skills`})}try{let{PersonaManager:s}=await Promise.resolve().then(()=>(wt(),It));if(s.hasInstance()&&s.getInstance().isActive()){let o=s.getInstance().getActive();if(o)for(let i of o.skillPaths){let a=i.split("/").pop()||"",l=`${r}/${a}`;fi.existsSync(l)&&fi.existsSync(`${l}/SKILL.md`)&&t.push({name:"Skill Shadow",status:"ok",message:`"${a}" user-authored shadows persona-bundled (intentional?)`})}}}catch{}}catch{}return t}_e();lr();import{execSync as k2}from"node:child_process";var Hw="@aiiware/aii";async function pue(t){let e=t.args||[],r=t.subcommand||e[0]||"";if(t.flags.help||r==="help"||r==="--help"||e.includes("--help")){let n="0.18.8";console.log(""),console.log(L.logo(" Install")),console.log(""),console.log(` Current version: ${L.model(n)}`),console.log(""),console.log(m.yellow(" USAGE:")),console.log(` ${m.green("aii install")} Update to latest version`),console.log(` ${m.green("aii install <version>")} Install specific version`),console.log(` ${m.green("aii install skill <src>")} Install a skill package ${m.dim("(coming soon)")}`),console.log(` ${m.green("aii install mcp <name>")} Install an MCP server ${m.dim("(coming soon)")}`),console.log(""),console.log(m.yellow(" EXAMPLES:")),console.log(` ${m.green("aii install")} ${m.dim("# Self-update to latest")}`),console.log(` ${m.green("aii install 0.13.10")} ${m.dim("# Pin to specific version")}`),console.log("");return}if(r==="skill"){console.log("Skill installation coming soon. For now use: /skills install owner/repo");return}if(r==="mcp"){console.log("MCP installation coming soon. For now use: aii mcp install <server>");return}console.log("\x1B[33m\u26A0 `aii install` for self-update is deprecated. Use `aii upgrade` instead.\x1B[0m"),console.log(`\x1B[33m This alias will be removed in v0.16.x.\x1B[0m
|
|
4310
|
+
`),await Jze(r)}async function Jze(t){let e="0.18.8",r=t&&t!=="latest"?t:"";if(console.log(""),r){console.log(`\u{1FABC} Installing Aii CLI v${r}...`),console.log("");try{k2(`npm install -g ${Hw}@${r}`,{stdio:"inherit",timeout:12e4})}catch{console.error(`
|
|
4311
4311
|
\u274C Failed to install v${r}`),console.error(` Try manually: npm install -g ${Hw}@${r}`),process.exit(1)}}else{console.log("\u{1FABC} Updating Aii CLI to latest..."),console.log(` Current version: ${e}`),console.log("");try{k2(`npm install -g ${Hw}@latest`,{stdio:"inherit",timeout:12e4})}catch{console.error(`
|
|
4312
|
-
\u274C Failed to update Aii CLI`),console.error(` Try manually: npm install -g ${Hw}@latest`),process.exit(1)}}try{let n=k2("aii --version 2>/dev/null",{encoding:"utf-8",timeout:1e4,stdio:"pipe"}).trim();console.log(""),console.log(n===e?`\u2713 Aii CLI is already up to date (${e})`:`\u2713 Aii CLI updated: ${e} \u2192 ${n}`)}catch{console.log(""),console.log("\u2713 Aii CLI installed. Restart your terminal to use the new version.")}}_e();var mue="0.18.
|
|
4312
|
+
\u274C Failed to update Aii CLI`),console.error(` Try manually: npm install -g ${Hw}@latest`),process.exit(1)}}try{let n=k2("aii --version 2>/dev/null",{encoding:"utf-8",timeout:1e4,stdio:"pipe"}).trim();console.log(""),console.log(n===e?`\u2713 Aii CLI is already up to date (${e})`:`\u2713 Aii CLI updated: ${e} \u2192 ${n}`)}catch{console.log(""),console.log("\u2713 Aii CLI installed. Restart your terminal to use the new version.")}}_e();var mue="0.18.8";function A2(t){let r=!t.flags.noColors?m:{cyan:n=>n,yellow:n=>n,gray:n=>n,green:n=>n};console.log(`
|
|
4313
4313
|
${r.cyan("AII")} - AI-powered CLI assistant v${mue}
|
|
4314
4314
|
|
|
4315
4315
|
${r.yellow("USAGE:")}
|