@sylphai/adal-cli-darwin-x64 0.1.3-beta.13 → 0.1.3-beta.14

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/adal-cli.js CHANGED
@@ -933,7 +933,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
933
933
  `)}rowToString(e,r){return this.rasterize(e).forEach((n,o)=>{let s="";n.forEach((i,a)=>{let{width:c}=e[a],l=this.negatePadding(e[a]),u=i;if(l>pg.stringWidth(i)&&(u+=" ".repeat(l-pg.stringWidth(i))),e[a].align&&e[a].align!=="left"&&this.wrap){let _=Teu[e[a].align];u=_(u,l),pg.stringWidth(u)<l&&(u+=" ".repeat((c||0)-pg.stringWidth(u)-1))}let E=e[a].padding||[0,0,0,0];E[cPe]&&(s+=" ".repeat(E[cPe])),s+=$6o(e[a],u,"| "),s+=u,s+=$6o(e[a],u," |"),E[aPe]&&(s+=" ".repeat(E[aPe])),o===0&&r.length>0&&(s=this.renderInline(s,r[r.length-1]))}),r.push({text:s.replace(/ +$/,""),span:e.span})}),r}renderInline(e,r){let n=e.match(/^ */),o=n?n[0].length:0,s=r.text,i=pg.stringWidth(s.trimRight());return r.span?this.wrap?o<i?e:(r.hidden=!0,s.trimRight()+" ".repeat(o-i)+e.trimLeft()):(r.hidden=!0,s+e):e}rasterize(e){let r=[],n=this.columnWidths(e),o;return e.forEach((s,i)=>{s.width=n[i],this.wrap?o=pg.wrap(s.text,this.negatePadding(s),{hard:!0}).split(`
934
934
  `):o=s.text.split(`
935
935
  `),s.border&&(o.unshift("."+"-".repeat(this.negatePadding(s)+2)+"."),o.push("'"+"-".repeat(this.negatePadding(s)+2)+"'")),s.padding&&(o.unshift(...new Array(s.padding[Seu]||0).fill("")),o.push(...new Array(s.padding[heu]||0).fill(""))),o.forEach((a,c)=>{r[c]||r.push([]);let l=r[c];for(let u=0;u<i;u++)l[u]===void 0&&l.push("");l.push(a)})}),r}negatePadding(e){let r=e.width||0;return e.padding&&(r-=(e.padding[cPe]||0)+(e.padding[aPe]||0)),e.border&&(r-=4),r}columnWidths(e){if(!this.wrap)return e.map(i=>i.width||pg.stringWidth(i.text));let r=e.length,n=this.width,o=e.map(i=>{if(i.width)return r--,n-=i.width,i.width}),s=r?Math.floor(n/r):0;return o.map((i,a)=>i===void 0?Math.max(s,meu(e[a])):i)}};function $6o(t,e,r){return t.border?/[.']-+[.']/.test(e)?"":e.trim().length!==0?r:" ":""}function meu(t){let e=t.padding||[],r=1+(e[cPe]||0)+(e[aPe]||0);return t.border?r+4:r}function geu(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function Ceu(t,e){t=t.trim();let r=pg.stringWidth(t);return r<e?" ".repeat(e-r)+t:t}function Reu(t,e){t=t.trim();let r=pg.stringWidth(t);return r>=e?t:" ".repeat(e-r>>1)+t}var pg;function X6o(t,e){return pg=e,new blt({width:t?.width||geu(),wrap:t?.wrap})}var Z6o=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function xlt(t){return t.replace(Z6o,"")}function e8o(t,e){let[r,n]=t.match(Z6o)||["",""];t=xlt(t);let o="";for(let s=0;s<t.length;s++)s!==0&&s%e===0&&(o+=`
936
- `),o+=t.charAt(s);return r&&n&&(o=`${r}${o}${n}`),o}function Ult(t){return X6o(t,{stringWidth:e=>[...e].length,stripAnsi:xlt,wrap:e8o})}import{dirname as t8o,resolve as r8o}from"path";import{readdirSync as Ieu,statSync as Neu}from"fs";function n8o(t,e){let r=r8o(".",t),n;for(Neu(r).isDirectory()||(r=t8o(r));;){if(n=e(r,Ieu(r)),n)return r8o(r,n);if(r=t8o(n=r),n===r)break}}import{inspect as xeu}from"util";import{readFileSync as Ueu}from"fs";import{fileURLToPath as Beu}from"url";import{basename as weu,dirname as Veu,extname as Geu,relative as Feu,resolve as a8o}from"path";import{readFileSync as Oeu,statSync as Meu,writeFile as Deu}from"fs";import{format as yeu}from"util";import{resolve as Peu}from"path";var o8o={fs:{readFileSync:Oeu,writeFile:Deu},format:yeu,resolve:Peu,exists:t=>{try{return Meu(t).isFile()}catch{return!1}}};var nO,Blt=class{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles=="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage=="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);let r=e.shift(),n=function(){};return typeof e[e.length-1]=="function"&&(n=e.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][r]&&this.updateFiles?(this.cache[this.locale][r]=r,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),nO.format.apply(nO.format,[this.cache[this.locale][r]||r].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),r=e.shift(),n=e.shift(),o=e.shift(),s=function(){};typeof e[e.length-1]=="function"&&(s=e.pop()),this.cache[this.locale]||this._readLocaleFile();let i=o===1?r:n;this.cache[this.locale][r]&&(i=this.cache[this.locale][r][o===1?"one":"other"]),!this.cache[this.locale][r]&&this.updateFiles?(this.cache[this.locale][r]={one:r,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:s})):s();let a=[i];return~i.indexOf("%d")&&a.push(o),nO.format.apply(nO.format,a.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){this.cache[this.locale]||this._readLocaleFile();for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this.cache[this.locale][r]=e[r])}_taggedLiteral(e,...r){let n="";return e.forEach(function(o,s){let i=r[s+1];n+=o,typeof i<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(r,1)))}_enqueueWrite(e){this.writeQueue.push(e),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let e=this,r=this.writeQueue[0],n=r.directory,o=r.locale,s=r.cb,i=this._resolveLocaleFile(n,o),a=JSON.stringify(this.cache[o],null,2);nO.fs.writeFile(i,a,"utf-8",function(c){e.writeQueue.shift(),e.writeQueue.length>0&&e._processWriteQueue(),s(c)})}_readLocaleFile(){let e={},r=this._resolveLocaleFile(this.directory,this.locale);try{nO.fs.readFileSync&&(e=JSON.parse(nO.fs.readFileSync(r,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+r),n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,r){let n=nO.resolve(e,"./",r+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~r.lastIndexOf("_")){let o=nO.resolve(e,"./",r.split("_")[0]+".json");this._fileExistsSync(o)&&(n=o)}return n}_fileExistsSync(e){return nO.exists(e)}};function s8o(t,e){nO=e;let r=new Blt(t);return{__:r.__.bind(r),__n:r.__n.bind(r),setLocale:r.setLocale.bind(r),getLocale:r.getLocale.bind(r),updateLocale:r.updateLocale.bind(r),locale:r.locale}}var veu=t=>s8o(t,o8o),i8o=veu;var Qeu="require is not supported by ESM",c8o="loading a directory of commands is not supported yet for ESM",tre;try{tre=Beu(import.meta.url)}catch{tre=process.cwd()}var Heu=tre.substring(0,tre.lastIndexOf("node_modules")),keu={assert:{notStrictEqual:Leu,strictEqual:beu},cliui:Ult,findUp:n8o,getEnv:t=>process.env[t],inspect:xeu,getCallerFile:()=>{throw new gF(c8o)},getProcessArgvBin:q6o,mainFilename:Heu||process.cwd(),Parser:Llt,path:{basename:weu,dirname:Veu,extname:Geu,relative:Feu,resolve:a8o},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(t,e)=>process.emitWarning(t,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Ueu,require:()=>{throw new gF(Qeu)},requireDirectory:()=>{throw new gF(c8o)},stringWidth:t=>[...t].length,y18n:i8o({directory:a8o(tre,"../../../locales"),updateFiles:!1})};import oO from"node:process";sre();async function hPe(){let t=await IF();return"0.1.3-beta.13"}var e9o=we(Aat(),1);import*as are from"node:fs";import*as Nv from"node:path";import*as lut from"node:os";var ire=we(JYo(),1);sre();import*as $Yo from"node:os";var XYo=["docker","podman","sandbox-exec"];function bru(t){return XYo.includes(t)}function xru(t){if(process.env.SANDBOX)return"";let e=process.env.GEMINI_SANDBOX?.toLowerCase().trim()??"";if(t=e?.length>0?e:t,t==="1"||t==="true"?t=!0:(t==="0"||t==="false"||!t)&&(t=!1),t===!1)return"";if(typeof t=="string"&&t){if(bru(t)||(console.error(`ERROR: invalid sandbox command '${t}'. Must be one of ${XYo.join(", ")}`),process.exit(1)),ire.default.sync(t))return t;console.error(`ERROR: missing sandbox command '${t}' (from GEMINI_SANDBOX)`),process.exit(1)}return $Yo.platform()==="darwin"&&ire.default.sync("sandbox-exec")?"sandbox-exec":ire.default.sync("docker")&&t===!0?"docker":ire.default.sync("podman")&&t===!0?"podman":(t===!0&&(console.error("ERROR: GEMINI_SANDBOX is true but failed to determine command for sandbox; install docker or podman or specify command in GEMINI_SANDBOX"),process.exit(1)),"")}async function ZYo(t,e){let r=e.sandbox??t.sandbox,n=xru(r),o=await IF(),s=e["sandbox-image"]??process.env.GEMINI_SANDBOX_IMAGE??o?.config?.sandboxImageUri;return n&&s?{command:n,image:s}:void 0}var Uru={debug:(...t)=>console.debug("[DEBUG]",...t),warn:(...t)=>console.warn("[WARN]",...t),error:(...t)=>console.error("[ERROR]",...t)};async function Bru(){return await k6o(Mlt(oO.argv)).option("model",{alias:"m",type:"string",description:"Model",default:oO.env.GEMINI_MODEL||fX}).option("prompt",{alias:"p",type:"string",description:"Prompt. Appended to input on stdin (if any)."}).option("sandbox",{alias:"s",type:"boolean",description:"Run in sandbox?"}).option("sandbox-image",{type:"string",description:"Sandbox image URI."}).option("debug",{alias:"d",type:"boolean",description:"Run in debug mode?",default:!1}).option("all_files",{alias:"a",type:"boolean",description:"Include ALL files in context?",default:!1}).option("show_memory_usage",{type:"boolean",description:"Show memory usage in status bar",default:!1}).option("yolo",{alias:"y",type:"boolean",description:"Automatically accept all actions (aka YOLO mode, see https://www.youtube.com/watch?v=xvFZjo5PgG0 for more details)?",default:!1}).option("telemetry",{type:"boolean",description:"Enable telemetry? This flag specifically controls if telemetry is sent. Other --telemetry-* flags set specific values but do not enable telemetry on their own."}).option("telemetry-target",{type:"string",choices:["local","gcp"],description:"Set the telemetry target (local or gcp). Overrides settings files."}).option("telemetry-otlp-endpoint",{type:"string",description:"Set the OTLP endpoint for telemetry. Overrides environment variables and settings files."}).option("telemetry-log-prompts",{type:"boolean",description:"Enable or disable logging of user prompts for telemetry. Overrides settings files."}).option("checkpointing",{alias:"c",type:"boolean",description:"Enables checkpointing of file edits",default:!1}).version(await hPe()).alias("v","version").help().alias("h","help").strict().argv}async function uut(t,e,r){Aut();let n=await Bru(),o=n.debug||!1;t.contextFileName?mX(t.contextFileName):mX(gX());let s=e.flatMap(_=>_.contextFiles),i=new a6(oO.cwd()),a="",c=0,l=wru(t,e),u=Vru(t,e),E=await ZYo(t,n);return new GMe({sessionId:r,embeddingModel:TX,sandbox:E,targetDir:oO.cwd(),debugMode:o,question:n.prompt||"",fullContext:n.all_files||!1,coreTools:t.coreTools||void 0,excludeTools:u,toolDiscoveryCommand:t.toolDiscoveryCommand,toolCallCommand:t.toolCallCommand,mcpServerCommand:t.mcpServerCommand,mcpServers:l,userMemory:a,geminiMdFileCount:c,approvalMode:n.yolo?Aa.YOLO:Aa.DEFAULT,showMemoryUsage:n.show_memory_usage||t.showMemoryUsage||!1,accessibility:t.accessibility,telemetry:{enabled:n.telemetry??t.telemetry?.enabled,target:n.telemetryTarget??t.telemetry?.target,otlpEndpoint:n.telemetryOtlpEndpoint??oO.env.OTEL_EXPORTER_OTLP_ENDPOINT??t.telemetry?.otlpEndpoint,logPrompts:n.telemetryLogPrompts??t.telemetry?.logPrompts},usageStatisticsEnabled:t.usageStatisticsEnabled??!0,fileFiltering:{respectGitIgnore:t.fileFiltering?.respectGitIgnore,enableRecursiveFileSearch:t.fileFiltering?.enableRecursiveFileSearch},checkpointing:n.checkpointing||t.checkpointing?.enabled,proxy:oO.env.HTTPS_PROXY||oO.env.https_proxy||oO.env.HTTP_PROXY||oO.env.http_proxy,cwd:oO.cwd(),fileDiscoveryService:i,bugCommand:t.bugCommand,model:n.model,extensionContextFilePaths:s})}function wru(t,e){let r={...t.mcpServers||{}};for(let n of e)Object.entries(n.config.mcpServers||{}).forEach(([o,s])=>{if(r[o]){Uru.warn(`Skipping extension MCP config for server with key "${o}" as it already exists.`);return}r[o]=s});return r}function Vru(t,e){let r=new Set(t.excludeTools||[]);for(let n of e)for(let o of n.config.excludeTools||[])r.add(o);return[...r]}function Gru(t){let e=Nv.resolve(t);for(;;){let r=Nv.join(e,Gx,".env");if(are.existsSync(r))return r;let n=Nv.join(e,".env");if(are.existsSync(n))return n;let o=Nv.dirname(e);if(o===e||!o){let s=Nv.join(lut.homedir(),Gx,".env");if(are.existsSync(s))return s;let i=Nv.join(lut.homedir(),".env");return are.existsSync(i)?i:null}e=o}}function Aut(){let t=Gru(oO.cwd());t&&e9o.config({path:t,quiet:!0})}var NF=t=>{if(Aut(),t===al.LOGIN_WITH_ADAL)return null;if(t===al.USE_ADAL_KEY)return process.env.GEMINI_API_KEY?null:"GEMINI_API_KEY environment variable not found. Add that to your .env and try again, no reload needed!";if(t===al.USE_VERTEX_AI){let e=!!process.env.GOOGLE_CLOUD_PROJECT&&!!process.env.GOOGLE_CLOUD_LOCATION,r=!!process.env.GOOGLE_API_KEY;return!e&&!r?`Must specify GOOGLE_GENAI_USE_VERTEXAI=true and either:
936
+ `),o+=t.charAt(s);return r&&n&&(o=`${r}${o}${n}`),o}function Ult(t){return X6o(t,{stringWidth:e=>[...e].length,stripAnsi:xlt,wrap:e8o})}import{dirname as t8o,resolve as r8o}from"path";import{readdirSync as Ieu,statSync as Neu}from"fs";function n8o(t,e){let r=r8o(".",t),n;for(Neu(r).isDirectory()||(r=t8o(r));;){if(n=e(r,Ieu(r)),n)return r8o(r,n);if(r=t8o(n=r),n===r)break}}import{inspect as xeu}from"util";import{readFileSync as Ueu}from"fs";import{fileURLToPath as Beu}from"url";import{basename as weu,dirname as Veu,extname as Geu,relative as Feu,resolve as a8o}from"path";import{readFileSync as Oeu,statSync as Meu,writeFile as Deu}from"fs";import{format as yeu}from"util";import{resolve as Peu}from"path";var o8o={fs:{readFileSync:Oeu,writeFile:Deu},format:yeu,resolve:Peu,exists:t=>{try{return Meu(t).isFile()}catch{return!1}}};var nO,Blt=class{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles=="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage=="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);let r=e.shift(),n=function(){};return typeof e[e.length-1]=="function"&&(n=e.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][r]&&this.updateFiles?(this.cache[this.locale][r]=r,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),nO.format.apply(nO.format,[this.cache[this.locale][r]||r].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),r=e.shift(),n=e.shift(),o=e.shift(),s=function(){};typeof e[e.length-1]=="function"&&(s=e.pop()),this.cache[this.locale]||this._readLocaleFile();let i=o===1?r:n;this.cache[this.locale][r]&&(i=this.cache[this.locale][r][o===1?"one":"other"]),!this.cache[this.locale][r]&&this.updateFiles?(this.cache[this.locale][r]={one:r,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:s})):s();let a=[i];return~i.indexOf("%d")&&a.push(o),nO.format.apply(nO.format,a.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){this.cache[this.locale]||this._readLocaleFile();for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(this.cache[this.locale][r]=e[r])}_taggedLiteral(e,...r){let n="";return e.forEach(function(o,s){let i=r[s+1];n+=o,typeof i<"u"&&(n+="%s")}),this.__.apply(this,[n].concat([].slice.call(r,1)))}_enqueueWrite(e){this.writeQueue.push(e),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let e=this,r=this.writeQueue[0],n=r.directory,o=r.locale,s=r.cb,i=this._resolveLocaleFile(n,o),a=JSON.stringify(this.cache[o],null,2);nO.fs.writeFile(i,a,"utf-8",function(c){e.writeQueue.shift(),e.writeQueue.length>0&&e._processWriteQueue(),s(c)})}_readLocaleFile(){let e={},r=this._resolveLocaleFile(this.directory,this.locale);try{nO.fs.readFileSync&&(e=JSON.parse(nO.fs.readFileSync(r,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+r),n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,r){let n=nO.resolve(e,"./",r+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~r.lastIndexOf("_")){let o=nO.resolve(e,"./",r.split("_")[0]+".json");this._fileExistsSync(o)&&(n=o)}return n}_fileExistsSync(e){return nO.exists(e)}};function s8o(t,e){nO=e;let r=new Blt(t);return{__:r.__.bind(r),__n:r.__n.bind(r),setLocale:r.setLocale.bind(r),getLocale:r.getLocale.bind(r),updateLocale:r.updateLocale.bind(r),locale:r.locale}}var veu=t=>s8o(t,o8o),i8o=veu;var Qeu="require is not supported by ESM",c8o="loading a directory of commands is not supported yet for ESM",tre;try{tre=Beu(import.meta.url)}catch{tre=process.cwd()}var Heu=tre.substring(0,tre.lastIndexOf("node_modules")),keu={assert:{notStrictEqual:Leu,strictEqual:beu},cliui:Ult,findUp:n8o,getEnv:t=>process.env[t],inspect:xeu,getCallerFile:()=>{throw new gF(c8o)},getProcessArgvBin:q6o,mainFilename:Heu||process.cwd(),Parser:Llt,path:{basename:weu,dirname:Veu,extname:Geu,relative:Feu,resolve:a8o},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(t,e)=>process.emitWarning(t,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Ueu,require:()=>{throw new gF(Qeu)},requireDirectory:()=>{throw new gF(c8o)},stringWidth:t=>[...t].length,y18n:i8o({directory:a8o(tre,"../../../locales"),updateFiles:!1})};import oO from"node:process";sre();async function hPe(){let t=await IF();return"0.1.3-beta.14"}var e9o=we(Aat(),1);import*as are from"node:fs";import*as Nv from"node:path";import*as lut from"node:os";var ire=we(JYo(),1);sre();import*as $Yo from"node:os";var XYo=["docker","podman","sandbox-exec"];function bru(t){return XYo.includes(t)}function xru(t){if(process.env.SANDBOX)return"";let e=process.env.GEMINI_SANDBOX?.toLowerCase().trim()??"";if(t=e?.length>0?e:t,t==="1"||t==="true"?t=!0:(t==="0"||t==="false"||!t)&&(t=!1),t===!1)return"";if(typeof t=="string"&&t){if(bru(t)||(console.error(`ERROR: invalid sandbox command '${t}'. Must be one of ${XYo.join(", ")}`),process.exit(1)),ire.default.sync(t))return t;console.error(`ERROR: missing sandbox command '${t}' (from GEMINI_SANDBOX)`),process.exit(1)}return $Yo.platform()==="darwin"&&ire.default.sync("sandbox-exec")?"sandbox-exec":ire.default.sync("docker")&&t===!0?"docker":ire.default.sync("podman")&&t===!0?"podman":(t===!0&&(console.error("ERROR: GEMINI_SANDBOX is true but failed to determine command for sandbox; install docker or podman or specify command in GEMINI_SANDBOX"),process.exit(1)),"")}async function ZYo(t,e){let r=e.sandbox??t.sandbox,n=xru(r),o=await IF(),s=e["sandbox-image"]??process.env.GEMINI_SANDBOX_IMAGE??o?.config?.sandboxImageUri;return n&&s?{command:n,image:s}:void 0}var Uru={debug:(...t)=>console.debug("[DEBUG]",...t),warn:(...t)=>console.warn("[WARN]",...t),error:(...t)=>console.error("[ERROR]",...t)};async function Bru(){return await k6o(Mlt(oO.argv)).option("model",{alias:"m",type:"string",description:"Model",default:oO.env.GEMINI_MODEL||fX}).option("prompt",{alias:"p",type:"string",description:"Prompt. Appended to input on stdin (if any)."}).option("sandbox",{alias:"s",type:"boolean",description:"Run in sandbox?"}).option("sandbox-image",{type:"string",description:"Sandbox image URI."}).option("debug",{alias:"d",type:"boolean",description:"Run in debug mode?",default:!1}).option("all_files",{alias:"a",type:"boolean",description:"Include ALL files in context?",default:!1}).option("show_memory_usage",{type:"boolean",description:"Show memory usage in status bar",default:!1}).option("yolo",{alias:"y",type:"boolean",description:"Automatically accept all actions (aka YOLO mode, see https://www.youtube.com/watch?v=xvFZjo5PgG0 for more details)?",default:!1}).option("telemetry",{type:"boolean",description:"Enable telemetry? This flag specifically controls if telemetry is sent. Other --telemetry-* flags set specific values but do not enable telemetry on their own."}).option("telemetry-target",{type:"string",choices:["local","gcp"],description:"Set the telemetry target (local or gcp). Overrides settings files."}).option("telemetry-otlp-endpoint",{type:"string",description:"Set the OTLP endpoint for telemetry. Overrides environment variables and settings files."}).option("telemetry-log-prompts",{type:"boolean",description:"Enable or disable logging of user prompts for telemetry. Overrides settings files."}).option("checkpointing",{alias:"c",type:"boolean",description:"Enables checkpointing of file edits",default:!1}).version(await hPe()).alias("v","version").help().alias("h","help").strict().argv}async function uut(t,e,r){Aut();let n=await Bru(),o=n.debug||!1;t.contextFileName?mX(t.contextFileName):mX(gX());let s=e.flatMap(_=>_.contextFiles),i=new a6(oO.cwd()),a="",c=0,l=wru(t,e),u=Vru(t,e),E=await ZYo(t,n);return new GMe({sessionId:r,embeddingModel:TX,sandbox:E,targetDir:oO.cwd(),debugMode:o,question:n.prompt||"",fullContext:n.all_files||!1,coreTools:t.coreTools||void 0,excludeTools:u,toolDiscoveryCommand:t.toolDiscoveryCommand,toolCallCommand:t.toolCallCommand,mcpServerCommand:t.mcpServerCommand,mcpServers:l,userMemory:a,geminiMdFileCount:c,approvalMode:n.yolo?Aa.YOLO:Aa.DEFAULT,showMemoryUsage:n.show_memory_usage||t.showMemoryUsage||!1,accessibility:t.accessibility,telemetry:{enabled:n.telemetry??t.telemetry?.enabled,target:n.telemetryTarget??t.telemetry?.target,otlpEndpoint:n.telemetryOtlpEndpoint??oO.env.OTEL_EXPORTER_OTLP_ENDPOINT??t.telemetry?.otlpEndpoint,logPrompts:n.telemetryLogPrompts??t.telemetry?.logPrompts},usageStatisticsEnabled:t.usageStatisticsEnabled??!0,fileFiltering:{respectGitIgnore:t.fileFiltering?.respectGitIgnore,enableRecursiveFileSearch:t.fileFiltering?.enableRecursiveFileSearch},checkpointing:n.checkpointing||t.checkpointing?.enabled,proxy:oO.env.HTTPS_PROXY||oO.env.https_proxy||oO.env.HTTP_PROXY||oO.env.http_proxy,cwd:oO.cwd(),fileDiscoveryService:i,bugCommand:t.bugCommand,model:n.model,extensionContextFilePaths:s})}function wru(t,e){let r={...t.mcpServers||{}};for(let n of e)Object.entries(n.config.mcpServers||{}).forEach(([o,s])=>{if(r[o]){Uru.warn(`Skipping extension MCP config for server with key "${o}" as it already exists.`);return}r[o]=s});return r}function Vru(t,e){let r=new Set(t.excludeTools||[]);for(let n of e)for(let o of n.config.excludeTools||[])r.add(o);return[...r]}function Gru(t){let e=Nv.resolve(t);for(;;){let r=Nv.join(e,Gx,".env");if(are.existsSync(r))return r;let n=Nv.join(e,".env");if(are.existsSync(n))return n;let o=Nv.dirname(e);if(o===e||!o){let s=Nv.join(lut.homedir(),Gx,".env");if(are.existsSync(s))return s;let i=Nv.join(lut.homedir(),".env");return are.existsSync(i)?i:null}e=o}}function Aut(){let t=Gru(oO.cwd());t&&e9o.config({path:t,quiet:!0})}var NF=t=>{if(Aut(),t===al.LOGIN_WITH_ADAL)return null;if(t===al.USE_ADAL_KEY)return process.env.GEMINI_API_KEY?null:"GEMINI_API_KEY environment variable not found. Add that to your .env and try again, no reload needed!";if(t===al.USE_VERTEX_AI){let e=!!process.env.GOOGLE_CLOUD_PROJECT&&!!process.env.GOOGLE_CLOUD_LOCATION,r=!!process.env.GOOGLE_API_KEY;return!e&&!r?`Must specify GOOGLE_GENAI_USE_VERTEXAI=true and either:
937
937
  \u2022 GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables.
938
938
  \u2022 GOOGLE_API_KEY environment variable (if using express mode).
939
939
  Update your .env and try again, no reload needed!`:null}return"Invalid auth method selected."};import*as ly from"fs";import*as E7 from"path";import*as r9o from"os";var Fru=E7.join(".gemini","extensions"),Qru="gemini-extension.json";function n9o(t){let e=[...t9o(t),...t9o(r9o.homedir())],r=[],n=new Set;for(let o of e)n.has(o.config.name)||(console.log(`Loading extension: ${o.config.name} (version: ${o.config.version})`),r.push(o),n.add(o.config.name));return r}function t9o(t){let e=E7.join(t,Fru);if(!ly.existsSync(e))return[];let r=[];for(let n of ly.readdirSync(e)){let o=E7.join(e,n),s=Hru(o);s!=null&&r.push(s)}return r}function Hru(t){if(!ly.statSync(t).isDirectory())return console.error(`Warning: unexpected file ${t} in extensions directory.`),null;let e=E7.join(t,Qru);if(!ly.existsSync(e))return console.error(`Warning: extension directory ${t} does not contain a config file ${e}.`),null;try{let r=ly.readFileSync(e,"utf-8"),n=JSON.parse(r);if(!n.name||!n.version)return console.error(`Invalid extension config in ${e}: missing name or version.`),null;let o=kru(n).map(s=>E7.join(t,s)).filter(s=>ly.existsSync(s));return{config:n,contextFiles:o}}catch(r){return console.error(`Warning: error parsing extension config in ${e}: ${r}`),null}}function kru(t){if(t.contextFileName){if(!Array.isArray(t.contextFileName))return[t.contextFileName]}else return["GEMINI.md"];return t.contextFileName}import*as _g from"fs";import*as f7 from"path";import{homedir as Kru}from"os";var gPe=we(i9o(),1);var Oi={type:"light",Background:"#FAFAFA",Foreground:"#3C3C43",LightBlue:"#89BDCD",AccentBlue:"#3B82F6",AccentPurple:"#8B5CF6",AccentCyan:"#06B6D4",AccentGreen:"#3CA84B",AccentYellow:"#D5A40A",AccentRed:"#DD4C4C",Comment:"#008000",Gray:"#B7BECC",GradientColors:["#4796E4","#847ACE","#C3677F"]},As={type:"dark",Background:"#1E1E2E",Foreground:"#CDD6F4",LightBlue:"#ADD8E6",AccentBlue:"#89B4FA",AccentPurple:"#CBA6F7",AccentCyan:"#89DCEB",AccentGreen:"#A6E3A1",AccentYellow:"#F9E2AF",AccentRed:"#F38BA8",Comment:"#6C7086",Gray:"#6C7086",GradientColors:["#4796E4","#847ACE","#C3677F"]};var $i=class t{constructor(e,r,n,o){this.name=e;this.type=r;this.colors=o;this._colorMap=Object.freeze(this._buildColorMap(n));let s=n.hljs?.color;this.defaultColor=(s?t._resolveColor(s):void 0)??""}defaultColor;_colorMap;static cssNameToHexMap={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",blanchedalmond:"#ffebcd",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgrey:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",whitesmoke:"#f5f5f5",yellowgreen:"#9acd32"};static inkSupportedNames=new Set(["black","red","green","yellow","blue","cyan","magenta","white","gray","grey","blackbright","redbright","greenbright","yellowbright","bluebright","cyanbright","magentabright","whitebright"]);getInkColor(e){return this._colorMap[e]}static _resolveColor(e){let r=e.toLowerCase();if(r.startsWith("#"))return r;if(t.inkSupportedNames.has(r))return r;if(t.cssNameToHexMap[r])return t.cssNameToHexMap[r];console.warn(`[Theme] Could not resolve color "${e}" to an Ink-compatible format.`)}_buildColorMap(e){let r={};for(let n in e){if(!n.startsWith("hljs-")&&n!=="hljs")continue;let o=e[n];if(o?.color){let s=t._resolveColor(o.color);s!==void 0&&(r[n]=s)}}return r}};var cre=new $i("Default Light","light",{hljs:{display:"block",overflowX:"auto",padding:"0.5em",background:Oi.Background,color:Oi.Foreground},"hljs-comment":{color:Oi.Comment},"hljs-quote":{color:Oi.Comment},"hljs-variable":{color:Oi.Foreground},"hljs-keyword":{color:Oi.AccentBlue},"hljs-selector-tag":{color:Oi.AccentBlue},"hljs-built_in":{color:Oi.AccentBlue},"hljs-name":{color:Oi.AccentBlue},"hljs-tag":{color:Oi.AccentBlue},"hljs-string":{color:Oi.AccentRed},"hljs-title":{color:Oi.AccentRed},"hljs-section":{color:Oi.AccentRed},"hljs-attribute":{color:Oi.AccentRed},"hljs-literal":{color:Oi.AccentRed},"hljs-template-tag":{color:Oi.AccentRed},"hljs-template-variable":{color:Oi.AccentRed},"hljs-type":{color:Oi.AccentRed},"hljs-addition":{color:Oi.AccentGreen},"hljs-deletion":{color:Oi.AccentRed},"hljs-selector-attr":{color:Oi.AccentCyan},"hljs-selector-pseudo":{color:Oi.AccentCyan},"hljs-meta":{color:Oi.AccentCyan},"hljs-doctag":{color:Oi.Gray},"hljs-attr":{color:Oi.AccentRed},"hljs-symbol":{color:Oi.AccentCyan},"hljs-bullet":{color:Oi.AccentCyan},"hljs-link":{color:Oi.AccentCyan},"hljs-emphasis":{fontStyle:"italic"},"hljs-strong":{fontWeight:"bold"}},Oi);var p7=new $i("Default","dark",{hljs:{display:"block",overflowX:"auto",padding:"0.5em",background:As.Background,color:As.Foreground},"hljs-keyword":{color:As.AccentBlue},"hljs-literal":{color:As.AccentBlue},"hljs-symbol":{color:As.AccentBlue},"hljs-name":{color:As.AccentBlue},"hljs-link":{color:As.AccentBlue,textDecoration:"underline"},"hljs-built_in":{color:As.AccentCyan},"hljs-type":{color:As.AccentCyan},"hljs-number":{color:As.AccentGreen},"hljs-class":{color:As.AccentGreen},"hljs-string":{color:As.AccentYellow},"hljs-meta-string":{color:As.AccentYellow},"hljs-regexp":{color:As.AccentRed},"hljs-template-tag":{color:As.AccentRed},"hljs-subst":{color:As.Foreground},"hljs-function":{color:As.Foreground},"hljs-title":{color:As.Foreground},"hljs-params":{color:As.Foreground},"hljs-formula":{color:As.Foreground},"hljs-comment":{color:As.Comment,fontStyle:"italic"},"hljs-quote":{color:As.Comment,fontStyle:"italic"},"hljs-doctag":{color:As.Comment},"hljs-meta":{color:As.Gray},"hljs-meta-keyword":{color:As.Gray},"hljs-tag":{color:As.Gray},"hljs-variable":{color:As.AccentPurple},"hljs-template-variable":{color:As.AccentPurple},"hljs-attr":{color:As.LightBlue},"hljs-attribute":{color:As.LightBlue},"hljs-builtin-name":{color:As.LightBlue},"hljs-section":{color:As.AccentYellow},"hljs-emphasis":{fontStyle:"italic"},"hljs-strong":{fontWeight:"bold"},"hljs-bullet":{color:As.AccentYellow},"hljs-selector-tag":{color:As.AccentYellow},"hljs-selector-id":{color:As.AccentYellow},"hljs-selector-class":{color:As.AccentYellow},"hljs-selector-attr":{color:As.AccentYellow},"hljs-selector-pseudo":{color:As.AccentYellow},"hljs-addition":{backgroundColor:"#144212",display:"inline-block",width:"100%"},"hljs-deletion":{backgroundColor:"#600",display:"inline-block",width:"100%"}},As);var Ov=".adal",put=f7.join(Kru(),Ov),_7=f7.join(put,"settings.json");var Eut=class{constructor(e,r,n){this.user=e,this.workspace=r,this.errors=n,this._merged=this.computeMergedSettings()}user;workspace;errors;_merged;get merged(){return this._merged}computeMergedSettings(){return{...this.user.settings,...this.workspace.settings}}forScope(e){switch(e){case"User":return this.user;case"Workspace":return this.workspace;default:throw new Error(`Invalid scope: ${e}`)}}setValue(e,r,n){let o=this.forScope(e);o.settings[r]=n,this._merged=this.computeMergedSettings(),zru(o)}};function jru(t){let e=/\$(?:(\w+)|{([^}]+)})/g;return t.replace(e,(r,n,o)=>{let s=n||o;return process&&process.env&&typeof process.env[s]=="string"?process.env[s]:r})}function CPe(t){if(t==null||typeof t=="boolean"||typeof t=="number")return t;if(typeof t=="string")return jru(t);if(Array.isArray(t))return t.map(e=>CPe(e));if(typeof t=="object"){let e={...t};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=CPe(e[r]));return e}return t}function a9o(t){let e={},r={},n=[];try{if(_g.existsSync(_7)){let s=_g.readFileSync(_7,"utf-8"),i=JSON.parse((0,gPe.default)(s));e=CPe(i),e.theme&&e.theme==="VS"?e.theme=cre.name:e.theme&&e.theme==="VS2015"&&(e.theme=p7.name)}}catch(s){n.push({message:lu(s),path:_7})}let o=f7.join(t,Ov,"settings.json");try{if(_g.existsSync(o)){let s=_g.readFileSync(o,"utf-8"),i=JSON.parse((0,gPe.default)(s));r=CPe(i),r.theme&&r.theme==="VS"?r.theme=cre.name:r.theme&&r.theme==="VS2015"&&(r.theme=p7.name)}}catch(s){n.push({message:lu(s),path:o})}return new Eut({path:_7,settings:e},{path:o,settings:r},n)}function zru(t){try{let e=f7.dirname(t.path);_g.existsSync(e)||_g.mkdirSync(e,{recursive:!0});let r={};if(_g.existsSync(t.path))try{let o=_g.readFileSync(t.path,"utf-8");r=JSON.parse((0,gPe.default)(o))}catch{}let n={...r,...t.settings};_g.writeFileSync(t.path,JSON.stringify(n,null,2),"utf-8")}catch(e){console.error("Error saving user settings file:",e)}}var Jru=`
@@ -958,7 +958,7 @@ If installed via npm, try reinstalling:
958
958
  Running from: ${this.rootPath}
959
959
  Expected deep_research at: ${o}`);return n&&St.debug(`\u2705 Found npm-link backend: ${o}`),o}case"development":{let o=KT.join(process.cwd(),"..","deep_research");if(!QR.existsSync(o))throw new Error(`Development backend not found at: ${o}
960
960
  Current working directory: ${process.cwd()}
961
- Make sure you're running from the adal-cli directory`);return n&&St.debug(`\u2705 Found development backend: ${o}`),o}}}portRetryCount=0;maxPortRetries=30;isWarmupCompleted=!1;async startServer(){if(this.isServerStarted)return;let e=process.env.ADAL_BACKEND_URL;if(e){St.info(`Using external backend: ${e}`),this.baseUrl=e,this.isServerStarted=!0;return}if(this.portRetryCount>=this.maxPortRetries){this.logError(`Failed to start backend after ${this.maxPortRetries} port retry attempts`);return}let r=this.getDeploymentMode(),n;try{n=this.findBackendPath()}catch(a){throw this.logError(`Failed to find backend: ${a}`),a}let o=process.env.ADAL_DEBUG==="true"||process.env.DEBUG_BACKEND==="true";try{this.port=await this.findAvailablePort(),this.baseUrl=`http://127.0.0.1:${this.port}`,this.logTiming("port_found"),(o||this.portRetryCount>0)&&St.info(`\u{1F680} ${this.portRetryCount>0?`Retry ${this.portRetryCount}: `:""}Starting AdaL backend on port ${this.port} in ${r} mode...`),Mv.setApiBaseUrl(this.baseUrl),St.debug(`[ApiBackend] Set ApprovalService URL to: ${this.baseUrl}`)}catch(a){this.logError(`Failed to find available port: ${a}`);return}let s=["--port",this.port.toString(),"--log-level","critical","--working-dir",this.workingDirectory,"--session-id",this.sessionId];if(r==="production"){o&&St.debug(`\u{1F3ED} Starting production backend: ${n}`);let a={stdio:["ignore","pipe","pipe"],env:{...process.env,PYTHONUTF8:"1"}};process.platform==="win32"&&(a.shell=!1,a.windowsHide=!0),St.info(`
961
+ Make sure you're running from the adal-cli directory`);return n&&St.debug(`\u2705 Found development backend: ${o}`),o}}}portRetryCount=0;maxPortRetries=30;isWarmupCompleted=!1;async startServer(){if(this.isServerStarted)return;let e=process.env.ADAL_BACKEND_URL;if(e){St.info(`Using external backend: ${e}`),this.baseUrl=e,this.isServerStarted=!0;return}if(this.portRetryCount>=this.maxPortRetries){this.logError(`Failed to start backend after ${this.maxPortRetries} port retry attempts`);return}let r=this.getDeploymentMode(),n;try{n=this.findBackendPath()}catch(a){throw this.logError(`Failed to find backend: ${a}`),a}let o=process.env.ADAL_DEBUG==="true"||process.env.DEBUG_BACKEND==="true";try{this.port=await this.findAvailablePort(),this.baseUrl=`http://127.0.0.1:${this.port}`,this.logTiming("port_found"),(o||this.portRetryCount>0)&&St.info(`\u{1F680} ${this.portRetryCount>0?`Retry ${this.portRetryCount}: `:""}Starting AdaL backend on port ${this.port} in ${r} mode...`),Mv.setApiBaseUrl(this.baseUrl),St.debug(`[ApiBackend] Set ApprovalService URL to: ${this.baseUrl}`)}catch(a){this.logError(`Failed to find available port: ${a}`);return}let s=["--port",this.port.toString(),"--log-level","critical","--working-dir",this.workingDirectory,"--session-id",this.sessionId];if(r==="production"){o&&St.debug(`\u{1F3ED} Starting production backend: ${n}`);let a={stdio:["ignore","pipe","pipe"]};process.platform==="win32"&&(a.shell=!1,a.windowsHide=!0),St.info(`
962
962
  \u{1F680} Attempting to spawn backend...`),St.info(`\u{1F4C2} Backend path: ${n}`),St.info(`\u{1F4CB} Arguments: ${s.join(" ")}`),St.info(`\u{1F5A5}\uFE0F Platform: ${process.platform}`);try{this.serverProcess=d9o(n,s,a),this.ownProcessPid=this.serverProcess.pid,this.logTiming("backend_process_spawned"),St.info(`\u2705 Process spawned successfully! PID: ${this.ownProcessPid}`),St.info(`\u23F3 Waiting for backend to start on port ${this.port}...`)}catch(c){let l=`Failed to spawn backend process: ${c.message}`;throw process.platform==="win32"&&(l+=` | Windows Troubleshooting: (1) Run PowerShell as Admin: Unblock-File "${n}" (2) Or right-click file \u2192 Properties \u2192 Unblock (3) Add Windows Defender exclusion for adal-cli folder`),this.logError(l),c}this.serverProcess.on("error",c=>{let l=`Backend process error: ${c.message}`;c.code==="ENOENT"?l+=` | Backend executable not found at: ${n}`:c.code==="EACCES"||c.code==="EPERM"?(l+=" | Permission denied to execute the backend",process.platform==="win32"&&(l+=" | Try the Windows troubleshooting steps")):process.platform==="win32"&&c.code==="UNKNOWN"&&(l+=" | Windows security block detected - executable is unsigned from GitHub Actions"),this.logError(l)})}else o&&St.debug(`\u{1F527} Starting development backend from: ${n}`),this.serverProcess=d9o("poetry",["run","python","-m","deep_research.api.main",...s],{cwd:n,stdio:["ignore","pipe","pipe"]}),this.ownProcessPid=this.serverProcess.pid,this.logTiming("backend_process_spawned");o&&St.debug("\u2728 AdaL backend starting..."),this.serverProcess.stdout?.on("data",a=>{let c=a.toString().trim();c&&St.debug(`[Backend STDOUT]: ${c}`),(c.includes("Uvicorn running")||c.includes("Application startup complete"))&&St.info(`\u2705 Backend API server is ready on port ${this.port}`)});let i=!1;this.serverProcess.stderr?.on("data",a=>{let c=a.toString().trim();if(c&&St.debug(`[Backend STDERR]: ${c}`),c.includes("address already in use")&&!i){i=!0,this.portRetryCount++,this.logError(`Port ${this.port} is already in use!`),this.portRetryCount<this.maxPortRetries?(St.info(`\u{1F504} Restarting backend on a different port... (attempt ${this.portRetryCount+1}/${this.maxPortRetries})`),this.serverProcess&&this.serverProcess.kill(),this.isServerStarted=!1,this.port=0,this.baseUrl="",setTimeout(()=>{this.startServer().catch(E=>{this.logError(`Failed to restart server: ${E}`)})},1e3)):this.logError(`Maximum port retry attempts (${this.maxPortRetries}) reached. Backend startup failed.`);return}process.platform==="win32"&&(c.includes("Windows Defender")||c.includes("virus")||c.includes("threat"))&&this.logError("Windows Defender may be blocking the executable! Add an exclusion or temporarily disable real-time protection.");let l=c.includes("Starting AdaL Backend API")||c.includes("Uvicorn running")||c.includes("Started server process"),u=c.includes("Tool with name")||c.includes("is already registered")||c.includes("Prompt kwargs");if(!l){if(u)return;(c.includes("CRITICAL:")||c.includes("ERROR:"))&&this.logError(`API Server Critical: ${c}`)}}),this.serverProcess.on("exit",(a,c)=>{if(this.serverProcess!==null){let l=`Backend process exited unexpectedly with code: ${a}, signal: ${c}`;process.platform==="win32"&&(a===1?l+=" | Exit code 1: Missing dependencies/DLLs, Python runtime issues, or security software blocking":a===3221225781?l+=" | Exit code 3221225781: Missing Visual C++ Redistributable - Download from: https://aka.ms/vs/17/release/vc_redist.x64.exe":a===null&&c==="SIGTERM"&&(l+=" | Process terminated by security software")),this.logError(l)}this.isServerStarted=!1,this.isServerStarting=!1,this.serverProcess=null,this.port=0,this.baseUrl="",Mv.setApiBaseUrl("")}),await this.waitForServer(),this.isServerStarted=!0,this.portRetryCount=0}async waitForServer(){if(this.isServerStarted&&this.baseUrl)return!0;if(!this.baseUrl){for(let s=0;s<10&&!this.baseUrl;s++)await new Promise(i=>setTimeout(i,500));if(!this.baseUrl)return this.logError("Backend URL not set - server may have failed to start"),!1}let e=this.getDeploymentMode(),r=e==="production"?60:20;for(let s=0;s<r;s++){try{e==="production"&&s===0?St.info("Starting backend service... (this may take up to 30 seconds on first run)"):e==="production"&&s===20&&St.info("Backend is taking longer than usual to start... (still waiting)");let i=await fetch(`${this.baseUrl}/health`);if(i.ok){let a=await i.json();if(this.firstHealthCheckLogged||(this.logTiming("first_health_check_success"),this.firstHealthCheckLogged=!0),!a.webthinker_phase1_initialized){s%10===0&&St.debug("\u23F3 Waiting for backend initialization (Phase 1)..."),await new Promise(l=>setTimeout(l,500));continue}this.isServerStarted=!0,this.logTiming("phase1_detected"),St.info("\u2705 Backend Phase 1 complete - ready for authentication");try{await this.setWorkingDirectory(this.workingDirectory),this.logTiming("working_dir_set")}catch(l){throw this.logError(`Failed to set backend working directory: ${l}`),new Error(`Failed to set backend working directory: ${l}`)}if(this.printStartupSummary(a.startup_timing_ms),!this.isWarmupCompleted&&(process.env.NODE_ENV==="production"||this.getDeploymentMode()==="production")){St.debug("\u{1F525} Warming up backend modules...");try{(await fetch(`${this.baseUrl}/health`)).ok&&(St.info("\u2705 Backend modules loaded and ready"),this.isWarmupCompleted=!0)}catch{St.debug("\u26A0\uFE0F Backend warm-up incomplete, but continuing"),this.isWarmupCompleted=!0}}let c=Date.now()-this.startupStartTime;return St.info(`\u2705 Backend started successfully in ${(c/1e3).toFixed(1)}s`),!0}}catch(i){s<3&&St.debug(`Backend not ready yet (attempt ${s+1}/${r}): ${i}`)}await new Promise(i=>setTimeout(i,500))}let o=`Backend failed to start after ${r*500/1e3}s timeout.`;return e==="production"?this.logError(`${o} The backend process may have crashed or been blocked by security software.`):this.logError(`${o} Check the backend logs at ~/.adal/debug_logs/ for details.`),!1}async call(e,r){if(!await this.waitForServer())throw new Error("Backend service is not ready. Please try again in a few seconds.");try{let o=`${this.baseUrl}${e}`,s={method:r?"POST":"GET",headers:{"Content-Type":"application/json"}};r&&(s.body=JSON.stringify(r));let i=await fetch(o,s);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);return await i.json()}catch(o){throw new Error(`API call failed: ${o}`)}}async webthinkerInfo(){return(await this.call("/webthinker/info")).info}async webthinkerQuery(e){return(await this.call("/webthinker/query",{query:e})).result}async testStream(e){if(!await this.waitForServer())throw new Error("Backend service is not ready. Please try again in a few seconds.");return new Promise((n,o)=>{let s=[],i=`${this.baseUrl}/test_stream`;fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({query:e})}).then(a=>{if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);let c=a.body?.getReader();if(!c)throw new Error("No response body reader available");let l=new TextDecoder;function u(){return c.read().then(({done:E,value:_})=>{if(E){n(s);return}let m=l.decode(_,{stream:!0}).split(`
963
963
  `);for(let g of m)if(g.startsWith("data: "))try{let C=JSON.parse(g.slice(6));if(s.push(C),St.debug("Test stream event:",C),C.type==="complete"||C.type==="error"){c.cancel(),n(s);return}}catch{}return u()})}return u()}).catch(a=>{o(new Error(`Stream failed: ${a}`))})})}async webthinkerStream(e){if(!await this.waitForServer())throw new Error("Backend service is not ready. Please try again in a few seconds.");return new Promise((n,o)=>{let s=[],i=`${this.baseUrl}/webthinker/stream`;fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({query:e})}).then(a=>{if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);let c=a.body?.getReader();if(!c)throw new Error("No response body reader available");let l=new TextDecoder;function u(){return c.read().then(({done:E,value:_})=>{if(E){n(s);return}let m=l.decode(_,{stream:!0}).split(`
964
964
  `);for(let g of m)if(g.startsWith("data: "))try{let C=JSON.parse(g.slice(6));if(s.push(C),St.debug("Stream event:",C),C.type==="complete"||C.type==="error"){c.cancel(),n(s);return}}catch{}return u()})}return u()}).catch(a=>{o(new Error(`Stream failed: ${a}`))})})}async webthinkerStreamWithCallback(e,r){if(!await this.waitForServer())throw new Error("Backend service is not ready. Please try again in a few seconds.");return new Promise((o,s)=>{let i=`${this.baseUrl}/webthinker/stream`;fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({query:e})}).then(a=>{if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);let c=a.body?.getReader();if(!c)throw new Error("No response body reader available");let l=new TextDecoder;function u(){return c.read().then(({done:E,value:_})=>{if(E){o();return}let m=l.decode(_,{stream:!0}).split(`
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sylphai/adal-cli-darwin-x64",
3
- "version": "0.1.3-beta.13",
3
+ "version": "0.1.3-beta.14",
4
4
  "description": "AI-powered CLI for development and research - darwin-x64",
5
5
  "type": "module",
6
6
  "bin": {