@sylphai/adal-cli-darwin-x64 0.1.3-beta.6 → 0.1.3-beta.7
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>dg.stringWidth(i)&&(u+=" ".repeat(l-dg.stringWidth(i))),e[a].align&&e[a].align!=="left"&&this.wrap){let _=peu[e[a].align];u=_(u,l),dg.stringWidth(u)<l&&(u+=" ".repeat((c||0)-dg.stringWidth(u)-1))}let E=e[a].padding||[0,0,0,0];E[iPe]&&(s+=" ".repeat(E[iPe])),s+=J6o(e[a],u,"| "),s+=u,s+=J6o(e[a],u," |"),E[sPe]&&(s+=" ".repeat(E[sPe])),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=dg.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=dg.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[_eu]||0).fill("")),o.push(...new Array(s.padding[feu]||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[iPe]||0)+(e.padding[sPe]||0)),e.border&&(r-=4),r}columnWidths(e){if(!this.wrap)return e.map(i=>i.width||dg.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,Teu(e[a])):i)}};function J6o(t,e,r){return t.border?/[.']-+[.']/.test(e)?"":e.trim().length!==0?r:" ":""}function Teu(t){let e=t.padding||[],r=1+(e[iPe]||0)+(e[sPe]||0);return t.border?r+4:r}function Seu(){return typeof process=="object"&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function heu(t,e){t=t.trim();let r=dg.stringWidth(t);return r<e?" ".repeat(e-r)+t:t}function meu(t,e){t=t.trim();let r=dg.stringWidth(t);return r>=e?t:" ".repeat(e-r>>1)+t}var dg;function $6o(t,e){return dg=e,new vlt({width:t?.width||Seu(),wrap:t?.wrap})}var X6o=new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function Llt(t){return t.replace(X6o,"")}function Z6o(t,e){let[r,n]=t.match(X6o)||["",""];t=Llt(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 blt(t){return $6o(t,{stringWidth:e=>[...e].length,stripAnsi:Llt,wrap:Z6o})}import{dirname as e8o,resolve as t8o}from"path";import{readdirSync as geu,statSync as Ceu}from"fs";function r8o(t,e){let r=t8o(".",t),n;for(Ceu(r).isDirectory()||(r=e8o(r));;){if(n=e(r,geu(r)),n)return t8o(r,n);if(r=e8o(n=r),n===r)break}}import{inspect as veu}from"util";import{readFileSync as Leu}from"fs";import{fileURLToPath as beu}from"url";import{basename as xeu,dirname as Ueu,extname as Beu,relative as weu,resolve as i8o}from"path";import{readFileSync as Reu,statSync as Ieu,writeFile as Neu}from"fs";import{format as Oeu}from"util";import{resolve as Meu}from"path";var n8o={fs:{readFileSync:Reu,writeFile:Neu},format:Oeu,resolve:Meu,exists:t=>{try{return Ieu(t).isFile()}catch{return!1}}};var eO,xlt=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(),eO.format.apply(eO.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),eO.format.apply(eO.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);eO.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{eO.fs.readFileSync&&(e=JSON.parse(eO.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=eO.resolve(e,"./",r+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~r.lastIndexOf("_")){let o=eO.resolve(e,"./",r.split("_")[0]+".json");this._fileExistsSync(o)&&(n=o)}return n}_fileExistsSync(e){return eO.exists(e)}};function o8o(t,e){eO=e;let r=new xlt(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 Deu=t=>o8o(t,n8o),s8o=Deu;var Veu="require is not supported by ESM",a8o="loading a directory of commands is not supported yet for ESM",ere;try{ere=beu(import.meta.url)}catch{ere=process.cwd()}var Geu=ere.substring(0,ere.lastIndexOf("node_modules")),Feu={assert:{notStrictEqual:yeu,strictEqual:Peu},cliui:blt,findUp:r8o,getEnv:t=>process.env[t],inspect:veu,getCallerFile:()=>{throw new mF(a8o)},getProcessArgvBin:Y6o,mainFilename:Geu||process.cwd(),Parser:Plt,path:{basename:xeu,dirname:Ueu,extname:Beu,relative:weu,resolve:i8o},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:Leu,require:()=>{throw new mF(Veu)},requireDirectory:()=>{throw new mF(a8o)},stringWidth:t=>[...t].length,y18n:s8o({directory:i8o(ere,"../../../locales"),updateFiles:!1})};import tO from"node:process";ore();async function TPe(){let t=await RF();return"0.1.3-beta.06"}var ZYo=we(lat(),1);import*as ire from"node:fs";import*as Cv from"node:path";import*as aut from"node:os";var sre=we(zYo(),1);ore();import*as JYo from"node:os";var $Yo=["docker","podman","sandbox-exec"];function Pru(t){return $Yo.includes(t)}function vru(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(Pru(t)||(console.error(`ERROR: invalid sandbox command '${t}'. Must be one of ${$Yo.join(", ")}`),process.exit(1)),sre.default.sync(t))return t;console.error(`ERROR: missing sandbox command '${t}' (from GEMINI_SANDBOX)`),process.exit(1)}return JYo.platform()==="darwin"&&sre.default.sync("sandbox-exec")?"sandbox-exec":sre.default.sync("docker")&&t===!0?"docker":sre.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 XYo(t,e){let r=e.sandbox??t.sandbox,n=vru(r),o=await RF(),s=e["sandbox-image"]??process.env.GEMINI_SANDBOX_IMAGE??o?.config?.sandboxImageUri;return n&&s?{command:n,image:s}:void 0}var Lru={debug:(...t)=>console.debug("[DEBUG]",...t),warn:(...t)=>console.warn("[WARN]",...t),error:(...t)=>console.error("[ERROR]",...t)};async function bru(){return await H6o(Nlt(tO.argv)).option("model",{alias:"m",type:"string",description:"Model",default:tO.env.GEMINI_MODEL||_X}).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 TPe()).alias("v","version").help().alias("h","help").strict().argv}async function cut(t,e,r){lut();let n=await bru(),o=n.debug||!1;t.contextFileName?hX(t.contextFileName):hX(mX());let s=e.flatMap(_=>_.contextFiles),i=new i6(tO.cwd()),a="",c=0,l=xru(t,e),u=Uru(t,e),E=await XYo(t,n);return new VMe({sessionId:r,embeddingModel:fX,sandbox:E,targetDir:tO.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?da.YOLO:da.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??tO.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:tO.env.HTTPS_PROXY||tO.env.https_proxy||tO.env.HTTP_PROXY||tO.env.http_proxy,cwd:tO.cwd(),fileDiscoveryService:i,bugCommand:t.bugCommand,model:n.model,extensionContextFilePaths:s})}function xru(t,e){let r={...t.mcpServers||{}};for(let n of e)Object.entries(n.config.mcpServers||{}).forEach(([o,s])=>{if(r[o]){Lru.warn(`Skipping extension MCP config for server with key "${o}" as it already exists.`);return}r[o]=s});return r}function Uru(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 Bru(t){let e=Cv.resolve(t);for(;;){let r=Cv.join(e,wx,".env");if(ire.existsSync(r))return r;let n=Cv.join(e,".env");if(ire.existsSync(n))return n;let o=Cv.dirname(e);if(o===e||!o){let s=Cv.join(aut.homedir(),wx,".env");if(ire.existsSync(s))return s;let i=Cv.join(aut.homedir(),".env");return ire.existsSync(i)?i:null}e=o}}function lut(){let t=Bru(tO.cwd());t&&ZYo.config({path:t,quiet:!0})}var IF=t=>{if(lut(),t===sl.LOGIN_WITH_ADAL)return null;if(t===sl.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===sl.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 blt(t){return $6o(t,{stringWidth:e=>[...e].length,stripAnsi:Llt,wrap:Z6o})}import{dirname as e8o,resolve as t8o}from"path";import{readdirSync as geu,statSync as Ceu}from"fs";function r8o(t,e){let r=t8o(".",t),n;for(Ceu(r).isDirectory()||(r=e8o(r));;){if(n=e(r,geu(r)),n)return t8o(r,n);if(r=e8o(n=r),n===r)break}}import{inspect as veu}from"util";import{readFileSync as Leu}from"fs";import{fileURLToPath as beu}from"url";import{basename as xeu,dirname as Ueu,extname as Beu,relative as weu,resolve as i8o}from"path";import{readFileSync as Reu,statSync as Ieu,writeFile as Neu}from"fs";import{format as Oeu}from"util";import{resolve as Meu}from"path";var n8o={fs:{readFileSync:Reu,writeFile:Neu},format:Oeu,resolve:Meu,exists:t=>{try{return Ieu(t).isFile()}catch{return!1}}};var eO,xlt=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(),eO.format.apply(eO.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),eO.format.apply(eO.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);eO.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{eO.fs.readFileSync&&(e=JSON.parse(eO.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=eO.resolve(e,"./",r+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~r.lastIndexOf("_")){let o=eO.resolve(e,"./",r.split("_")[0]+".json");this._fileExistsSync(o)&&(n=o)}return n}_fileExistsSync(e){return eO.exists(e)}};function o8o(t,e){eO=e;let r=new xlt(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 Deu=t=>o8o(t,n8o),s8o=Deu;var Veu="require is not supported by ESM",a8o="loading a directory of commands is not supported yet for ESM",ere;try{ere=beu(import.meta.url)}catch{ere=process.cwd()}var Geu=ere.substring(0,ere.lastIndexOf("node_modules")),Feu={assert:{notStrictEqual:yeu,strictEqual:Peu},cliui:blt,findUp:r8o,getEnv:t=>process.env[t],inspect:veu,getCallerFile:()=>{throw new mF(a8o)},getProcessArgvBin:Y6o,mainFilename:Geu||process.cwd(),Parser:Plt,path:{basename:xeu,dirname:Ueu,extname:Beu,relative:weu,resolve:i8o},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:Leu,require:()=>{throw new mF(Veu)},requireDirectory:()=>{throw new mF(a8o)},stringWidth:t=>[...t].length,y18n:s8o({directory:i8o(ere,"../../../locales"),updateFiles:!1})};import tO from"node:process";ore();async function TPe(){let t=await RF();return"0.1.3-beta.07"}var ZYo=we(lat(),1);import*as ire from"node:fs";import*as Cv from"node:path";import*as aut from"node:os";var sre=we(zYo(),1);ore();import*as JYo from"node:os";var $Yo=["docker","podman","sandbox-exec"];function Pru(t){return $Yo.includes(t)}function vru(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(Pru(t)||(console.error(`ERROR: invalid sandbox command '${t}'. Must be one of ${$Yo.join(", ")}`),process.exit(1)),sre.default.sync(t))return t;console.error(`ERROR: missing sandbox command '${t}' (from GEMINI_SANDBOX)`),process.exit(1)}return JYo.platform()==="darwin"&&sre.default.sync("sandbox-exec")?"sandbox-exec":sre.default.sync("docker")&&t===!0?"docker":sre.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 XYo(t,e){let r=e.sandbox??t.sandbox,n=vru(r),o=await RF(),s=e["sandbox-image"]??process.env.GEMINI_SANDBOX_IMAGE??o?.config?.sandboxImageUri;return n&&s?{command:n,image:s}:void 0}var Lru={debug:(...t)=>console.debug("[DEBUG]",...t),warn:(...t)=>console.warn("[WARN]",...t),error:(...t)=>console.error("[ERROR]",...t)};async function bru(){return await H6o(Nlt(tO.argv)).option("model",{alias:"m",type:"string",description:"Model",default:tO.env.GEMINI_MODEL||_X}).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 TPe()).alias("v","version").help().alias("h","help").strict().argv}async function cut(t,e,r){lut();let n=await bru(),o=n.debug||!1;t.contextFileName?hX(t.contextFileName):hX(mX());let s=e.flatMap(_=>_.contextFiles),i=new i6(tO.cwd()),a="",c=0,l=xru(t,e),u=Uru(t,e),E=await XYo(t,n);return new VMe({sessionId:r,embeddingModel:fX,sandbox:E,targetDir:tO.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?da.YOLO:da.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??tO.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:tO.env.HTTPS_PROXY||tO.env.https_proxy||tO.env.HTTP_PROXY||tO.env.http_proxy,cwd:tO.cwd(),fileDiscoveryService:i,bugCommand:t.bugCommand,model:n.model,extensionContextFilePaths:s})}function xru(t,e){let r={...t.mcpServers||{}};for(let n of e)Object.entries(n.config.mcpServers||{}).forEach(([o,s])=>{if(r[o]){Lru.warn(`Skipping extension MCP config for server with key "${o}" as it already exists.`);return}r[o]=s});return r}function Uru(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 Bru(t){let e=Cv.resolve(t);for(;;){let r=Cv.join(e,wx,".env");if(ire.existsSync(r))return r;let n=Cv.join(e,".env");if(ire.existsSync(n))return n;let o=Cv.dirname(e);if(o===e||!o){let s=Cv.join(aut.homedir(),wx,".env");if(ire.existsSync(s))return s;let i=Cv.join(aut.homedir(),".env");return ire.existsSync(i)?i:null}e=o}}function lut(){let t=Bru(tO.cwd());t&&ZYo.config({path:t,quiet:!0})}var IF=t=>{if(lut(),t===sl.LOGIN_WITH_ADAL)return null;if(t===sl.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===sl.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 cy from"fs";import*as d7 from"path";import*as t9o from"os";var wru=d7.join(".gemini","extensions"),Vru="gemini-extension.json";function r9o(t){let e=[...e9o(t),...e9o(t9o.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 e9o(t){let e=d7.join(t,wru);if(!cy.existsSync(e))return[];let r=[];for(let n of cy.readdirSync(e)){let o=d7.join(e,n),s=Gru(o);s!=null&&r.push(s)}return r}function Gru(t){if(!cy.statSync(t).isDirectory())return console.error(`Warning: unexpected file ${t} in extensions directory.`),null;let e=d7.join(t,Vru);if(!cy.existsSync(e))return console.error(`Warning: extension directory ${t} does not contain a config file ${e}.`),null;try{let r=cy.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=Fru(n).map(s=>d7.join(t,s)).filter(s=>cy.existsSync(s));return{config:n,contextFiles:o}}catch(r){return console.error(`Warning: error parsing extension config in ${e}: ${r}`),null}}function Fru(t){if(t.contextFileName){if(!Array.isArray(t.contextFileName))return[t.contextFileName]}else return["GEMINI.md"];return t.contextFileName}import*as Eg from"fs";import*as _7 from"path";import{homedir as Yru}from"os";var hPe=we(s9o(),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"]},ds={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 Zi=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 are=new Zi("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 E7=new Zi("Default","dark",{hljs:{display:"block",overflowX:"auto",padding:"0.5em",background:ds.Background,color:ds.Foreground},"hljs-keyword":{color:ds.AccentBlue},"hljs-literal":{color:ds.AccentBlue},"hljs-symbol":{color:ds.AccentBlue},"hljs-name":{color:ds.AccentBlue},"hljs-link":{color:ds.AccentBlue,textDecoration:"underline"},"hljs-built_in":{color:ds.AccentCyan},"hljs-type":{color:ds.AccentCyan},"hljs-number":{color:ds.AccentGreen},"hljs-class":{color:ds.AccentGreen},"hljs-string":{color:ds.AccentYellow},"hljs-meta-string":{color:ds.AccentYellow},"hljs-regexp":{color:ds.AccentRed},"hljs-template-tag":{color:ds.AccentRed},"hljs-subst":{color:ds.Foreground},"hljs-function":{color:ds.Foreground},"hljs-title":{color:ds.Foreground},"hljs-params":{color:ds.Foreground},"hljs-formula":{color:ds.Foreground},"hljs-comment":{color:ds.Comment,fontStyle:"italic"},"hljs-quote":{color:ds.Comment,fontStyle:"italic"},"hljs-doctag":{color:ds.Comment},"hljs-meta":{color:ds.Gray},"hljs-meta-keyword":{color:ds.Gray},"hljs-tag":{color:ds.Gray},"hljs-variable":{color:ds.AccentPurple},"hljs-template-variable":{color:ds.AccentPurple},"hljs-attr":{color:ds.LightBlue},"hljs-attribute":{color:ds.LightBlue},"hljs-builtin-name":{color:ds.LightBlue},"hljs-section":{color:ds.AccentYellow},"hljs-emphasis":{fontStyle:"italic"},"hljs-strong":{fontWeight:"bold"},"hljs-bullet":{color:ds.AccentYellow},"hljs-selector-tag":{color:ds.AccentYellow},"hljs-selector-id":{color:ds.AccentYellow},"hljs-selector-class":{color:ds.AccentYellow},"hljs-selector-attr":{color:ds.AccentYellow},"hljs-selector-pseudo":{color:ds.AccentYellow},"hljs-addition":{backgroundColor:"#144212",display:"inline-block",width:"100%"},"hljs-deletion":{backgroundColor:"#600",display:"inline-block",width:"100%"}},ds);var Rv=".adal",dut=_7.join(Yru(),Rv),p7=_7.join(dut,"settings.json");var Aut=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(),Wru(o)}};function qru(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 mPe(t){if(t==null||typeof t=="boolean"||typeof t=="number")return t;if(typeof t=="string")return qru(t);if(Array.isArray(t))return t.map(e=>mPe(e));if(typeof t=="object"){let e={...t};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=mPe(e[r]));return e}return t}function i9o(t){let e={},r={},n=[];try{if(Eg.existsSync(p7)){let s=Eg.readFileSync(p7,"utf-8"),i=JSON.parse((0,hPe.default)(s));e=mPe(i),e.theme&&e.theme==="VS"?e.theme=are.name:e.theme&&e.theme==="VS2015"&&(e.theme=E7.name)}}catch(s){n.push({message:iu(s),path:p7})}let o=_7.join(t,Rv,"settings.json");try{if(Eg.existsSync(o)){let s=Eg.readFileSync(o,"utf-8"),i=JSON.parse((0,hPe.default)(s));r=mPe(i),r.theme&&r.theme==="VS"?r.theme=are.name:r.theme&&r.theme==="VS2015"&&(r.theme=E7.name)}}catch(s){n.push({message:iu(s),path:o})}return new Aut({path:p7,settings:e},{path:o,settings:r},n)}function Wru(t){try{let e=_7.dirname(t.path);Eg.existsSync(e)||Eg.mkdirSync(e,{recursive:!0});let r={};if(Eg.existsSync(t.path))try{let o=Eg.readFileSync(t.path,"utf-8");r=JSON.parse((0,hPe.default)(o))}catch{}let n={...r,...t.settings};Eg.writeFileSync(t.path,JSON.stringify(n,null,2),"utf-8")}catch(e){console.error("Error saving user settings file:",e)}}var Kru=`
|
|
@@ -942,7 +942,7 @@ Please wait and try again later. To increase your limits, request a quota increa
|
|
|
942
942
|
Please wait and try again later. To increase your limits, request a quota increase through Vertex, or switch to another /auth method`,Jru="Your request has been rate limited. Please wait and try again later.";function a9o(t){return typeof t=="object"&&t!==null&&"error"in t&&typeof t.error=="object"&&"message"in t.error}function $ru(t){return typeof t=="object"&&t!==null&&"message"in t&&typeof t.message=="string"}function c9o(t){switch(t){case sl.LOGIN_WITH_ADAL:return Kru;case sl.USE_ADAL_KEY:return jru;case sl.USE_VERTEX_AI:return zru;default:return Jru}}function Xru(t){if(!t)return!1;let e=t.toUpperCase();return e.includes("RESOURCE_EXHAUSTED")||e.includes("TOO MANY REQUESTS")||e.includes("TOO_MANY_REQUESTS")||e.includes("429")}function cre(t,e){if($ru(t)){let r=`[API Error: ${t.message}]`,n=t.status;return(n===429||String(n).includes("429")||String(n).toUpperCase().includes("TOO MANY REQUESTS"))&&(r+=c9o(e)),r}if(typeof t=="string"){let r=t.indexOf("{");if(r===-1)return`[API Error: ${t}]`;let n=t.substring(r);try{let o=JSON.parse(n);if(a9o(o)){let s=o.error.message,i;try{let u=JSON.parse(s);a9o(u)&&(s=u.error.message,i=u.error.status)}catch{}let a=o.error.status||i,c=`[API Error: ${s} (Status: ${a??"Unknown"})]`;return(o.error.code===429||Xru(a))&&(c+=c9o(e)),c}}catch{}return`[API Error: ${t}]`}return"[API Error: An unknown error occurred.]"}function Zru(t){if(t.candidates&&t.candidates.length>0){let e=t.candidates[0];if(e.content&&e.content.parts&&e.content.parts.length>0)return e.content.parts[0]?.thought?null:e.content.parts.filter(n=>n.text).map(n=>n.text).join("")}return null}async function l9o(t,e){process.stdout.on("error",a=>{a.code==="EPIPE"&&process.exit(0)});let r=t.getGeminiClient(),n=await t.getToolRegistry(),o=await r.getChat(),s=new AbortController,i=[{role:"user",parts:[{text:e}]}];try{for(;;){let a=[],c=await o.sendMessageStream({message:i[0]?.parts||[],config:{abortSignal:s.signal,tools:[{functionDeclarations:n.getFunctionDeclarations()}]}});for await(let l of c){if(s.signal.aborted){console.error("Operation cancelled.");return}let u=Zru(l);u&&process.stdout.write(u),l.functionCalls&&a.push(...l.functionCalls)}if(a.length>0){let l=[];for(let u of a){let _={callId:u.id??`${u.name}-${Date.now()}`,name:u.name,args:u.args??{},isClientInitiated:!1},T=await WQo(t,_,n,s.signal);if(T.error){let m=T.error.message.includes("not found in registry");console.error(`Error executing tool ${u.name}: ${T.resultDisplay||T.error.message}`),m||process.exit(1)}if(T.responseParts){let m=Array.isArray(T.responseParts)?T.responseParts:[T.responseParts];for(let g of m)typeof g=="string"?l.push({text:g}):g&&l.push(g)}}i=[{role:"user",parts:l}]}else{process.stdout.write(`
|
|
943
943
|
`);return}}}catch(a){console.error(cre(a,t.getContentGeneratorConfig().authType)),process.exit(1)}finally{rY()&&await v$()}}var Rr=we(ur(),1);import*as KR from"fs";import*as Hre from"path";import*as Ajo from"os";var gPe=we(ur(),1);var u9o=8;function CPe(){let[t,e]=(0,gPe.useState)({columns:(process.stdout.columns||60)-u9o,rows:process.stdout.rows||20});return(0,gPe.useEffect)(()=>{function r(){e({columns:(process.stdout.columns||60)-u9o,rows:process.stdout.rows||20})}return process.stdout.on("resize",r),()=>{process.stdout.off("resize",r)}},[]),t}var Eut=t=>({error:"Error",cancelled:"Canceled",cancel:"Canceled",success:"Success",executing:"Executing",pending:"Pending",confirming:"Confirming"})[t||"success"]||"Success";import vh from"node:process";import{spawn as A9o}from"child_process";import*as Nv from"fs";import*as kf from"path";import{fileURLToPath as enu}from"url";import{randomUUID as tnu}from"crypto";var Iv=class t{static apiBaseUrl="";static setApiBaseUrl(e){process.platform==="win32"&&e.includes("localhost")&&(e=e.replace("localhost","127.0.0.1")),e?St.debug("[ApprovalService] Setting API base URL to:",e):St.debug("[ApprovalService] Clearing API base URL"),t.apiBaseUrl=e}static async getPendingApprovals(){if(!t.apiBaseUrl)throw new Error("[ApprovalService] API base URL not set. Backend may not be initialized yet.");try{let e=await fetch(`${t.apiBaseUrl}/api/v1/approvals/pending`);if(!e.ok)throw new Error(`Failed to fetch pending approvals: ${e.statusText}`);return await e.json()}catch(e){throw e.code==="ECONNREFUSED"&&process.platform==="win32"&&(St.error("[ApprovalService] Connection refused on Windows. Backend URL:",t.apiBaseUrl),St.error("[ApprovalService] This might be an IPv6/IPv4 issue. Ensure the backend is running.")),St.error("[ApprovalService] Error fetching pending approvals:",e),e}}static async submitApproval(e,r,n){if(!t.apiBaseUrl)throw new Error("[ApprovalService] API base URL not set. Backend may not be initialized yet.");St.debug(`[ApprovalService] submitApproval called at ${new Date().toISOString()}`),St.debug(`[ApprovalService] Request ID: ${e}, Outcome: ${r}`);let s={[fs.ProceedOnce]:"proceed_once",[fs.ProceedAlways]:"proceed_always",[fs.Cancel]:"cancel",[fs.ModifyWithEditor]:"cancel",[fs.ProceedAlwaysServer]:"proceed_always",[fs.ProceedAlwaysTool]:"proceed_always"}[r],i={request_id:e,outcome:s,...n&&{response_data:n}},a=[t.apiBaseUrl];if(process.platform==="win32"){let u=t.apiBaseUrl.match(/:([0-9]+)/);if(u){let E=u[1];a.includes(`http://127.0.0.1:${E}`)||a.push(`http://127.0.0.1:${E}`),a.includes(`http://localhost:${E}`)||a.push(`http://localhost:${E}`)}}let c=null;for(let l of a){let u=0;try{St.debug(`[ApprovalService] Attempting to submit approval to: ${l}/api/v1/approvals/${e}/approve`),u=Date.now();let E=await fetch(`${l}/api/v1/approvals/${e}/approve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),_=Date.now()-u;if(St.debug(`[ApprovalService] Approval response received after ${_}ms`),!E.ok){let m=await E.text();c=new Error(`Failed to submit approval: ${E.status} - ${m}`);continue}let T=await E.json();St.debug("[ApprovalService] Approval submitted successfully:",T);return}catch(E){let _=Date.now()-(u||Date.now());St.error(`[ApprovalService] Error with ${l} after ${_}ms:`,E.message),E.name==="AbortError"&&_>1e5&&_<13e4&&(St.error("[ApprovalService] \u26A0\uFE0F BROWSER TIMEOUT DETECTED (~2 minutes)"),St.error("[ApprovalService] This is a browser limitation that cannot be overridden")),c=E}}throw St.error("[ApprovalService] All approval submission attempts failed"),c||new Error("Failed to submit approval to backend")}static async cancelApproval(e){try{let r=await fetch(`${t.apiBaseUrl}/api/v1/approvals/${e}`,{method:"DELETE"});if(!r.ok)throw new Error(`Failed to cancel approval: ${r.statusText}`)}catch(r){throw console.error("Error cancelling approval:",r),r}}static createGuardedApprovalCallback(e,r,n){let o=!1;return async s=>{if(o){console.log(`[ApprovalService] Already submitting approval for ${e}`);return}o=!0;try{await t.submitApproval(e,s),s===fs.Cancel?(r("cancel"),n("responding")):(r("executing"),n("responding"))}catch(i){i?.message?.includes("no longer pending")||i?.message?.includes("already approved")?(console.log(`[ApprovalService] Request ${e} already processed`),r("executing"),n("responding")):(console.error("[ApprovalService] Failed to submit approval:",i),r("error"),n("waiting_for_confirmation"),o=!1)}}}};var put=class t{sessionId;serverProcess=null;isServerStarted=!1;isServerStarting=!1;serverStartTime=0;baseUrl="";port=0;static BASE_PORT=41230;static MAX_PORT=41250;static MAX_PORT_ATTEMPTS=20;workingDirectory;rootPath=enu(import.meta.url);activeAbortController=null;activeReader=null;ownProcessPid=void 0;errorCallback=null;startupTimings={};startupStartTime=0;startupSummaryPrinted=!1;firstHealthCheckLogged=!1;constructor(e){this.sessionId=tnu(),this.workingDirectory=e||process.cwd(),this.startupStartTime=Date.now(),(process.env.ADAL_DEBUG||process.env.DEBUG_BACKEND)&&setTimeout(()=>this.printDebugInfo(),100),this.startServer()}setErrorCallback(e){this.errorCallback=e}logError(e){St.error(e),this.errorCallback&&this.errorCallback(e)}logTiming(e){let r=Date.now()-this.startupStartTime;this.startupTimings[e]=r,St.debug(`\u23F1\uFE0F [${r.toString().padStart(7," ")}ms] ${e}`)}printStartupSummary(e){this.startupSummaryPrinted||(this.startupSummaryPrinted=!0,St.info(`
|
|
944
944
|
\u{1F4CA} Startup Performance Summary:`),St.info("Frontend timings:"),Object.entries(this.startupTimings).forEach(([r,n])=>{St.info(` ${r}: ${n}ms`)}),e&&Object.keys(e).length>0&&(St.info(`
|
|
945
|
-
Backend timings:`),Object.entries(e).forEach(([r,n])=>{St.info(` ${r}: ${n}ms`)})),St.info(""))}async isPortAvailable(e){try{let r=await fetch(`http://127.0.0.1:${e}/health`,{method:"GET",signal:AbortSignal.timeout(1e3)});return!1}catch{return!0}}async findAvailablePort(){let e=t.MAX_PORT-t.BASE_PORT,r=[];for(let a=0;a<=e;a++)r.push(t.BASE_PORT+a);let n=Date.now()+process.pid;for(let a=r.length-1;a>0;a--){let c=Math.floor((Math.random()+n%1e3/1e3)*(a+1))%(a+1);[r[a],r[c]]=[r[c],r[a]]}let o=Math.min(t.MAX_PORT_ATTEMPTS,r.length),s=[];for(let a=0;a<o;a++){let c=r[a];if(await this.isPortAvailable(c))return St.info(`\u2705 Found available port: ${c}`),c;s.push(c),St.debug(`Port ${c} is in use (likely another AdaL instance), trying another port...`)}let i=`No available ports found after ${o} attempts. Tried ports: ${s.slice(0,5).join(", ")}... Possible solutions: (1) Close some AdaL instances, (2) Wait for ports to be released, (3) Check if other processes are using ports ${t.BASE_PORT}-${t.MAX_PORT}`;throw this.logError(i),new Error(`No available ports found in range ${t.BASE_PORT}-${t.MAX_PORT}. Too many AdaL instances may be running.`)}getDeploymentMode(){return this.rootPath.includes("/node_modules/")||this.rootPath.includes("\\node_modules\\")?"production":this.rootPath.endsWith("/adal-cli/bundle/adal-cli.js")||this.rootPath.endsWith("\\adal-cli\\bundle\\adal-cli.js")?"npm-link":"development"}findBackendPath(){let e=this.getDeploymentMode(),r=process.platform==="win32"?"adal-backend.exe":"adal-backend",n=process.env.ADAL_DEBUG==="true"||process.env.DEBUG_BACKEND==="true";switch(n&&(St.debug(`\u{1F50D} Deployment mode: ${e}`),St.debug(`\u{1F4CD} Current path: ${this.rootPath}`)),e){case"production":{let o=kf.dirname(this.rootPath),s=`${process.platform}-${process.arch}`,a={"darwin-arm64":"@sylphai/adal-cli-darwin-arm64","darwin-x64":"@sylphai/adal-cli-darwin-x64","linux-x64":"@sylphai/adal-cli-linux-x64","linux-arm64":"@sylphai/adal-cli-linux-arm64","win32-x64":"@sylphai/adal-cli-win32-x64","win32-ia32":"@sylphai/adal-cli-win32-x64"}[s];if(!a)throw new Error(`Unsupported platform: ${s}`);let c,l=kf.join(o,"package.json");Nv.existsSync(l)?JSON.parse(Nv.readFileSync(l,"utf8")).name===a?c=o:c=kf.join(o,"node_modules",a):c=kf.join(o,"..","node_modules",a),n&&(St.debug(`\u{1F50D} Platform: ${s}`),St.debug(`\u{1F4E6} Platform package: ${a}`),St.debug(`\u{1F4C2} Looking in: ${c}`));let u=kf.join(c,"backend",r);if(Nv.existsSync(u))return n&&St.debug(`\u2705 Found backend (flat structure): ${u}`),u;let E=kf.join(c,"backend",
|
|
945
|
+
Backend timings:`),Object.entries(e).forEach(([r,n])=>{St.info(` ${r}: ${n}ms`)})),St.info(""))}async isPortAvailable(e){try{let r=await fetch(`http://127.0.0.1:${e}/health`,{method:"GET",signal:AbortSignal.timeout(1e3)});return!1}catch{return!0}}async findAvailablePort(){let e=t.MAX_PORT-t.BASE_PORT,r=[];for(let a=0;a<=e;a++)r.push(t.BASE_PORT+a);let n=Date.now()+process.pid;for(let a=r.length-1;a>0;a--){let c=Math.floor((Math.random()+n%1e3/1e3)*(a+1))%(a+1);[r[a],r[c]]=[r[c],r[a]]}let o=Math.min(t.MAX_PORT_ATTEMPTS,r.length),s=[];for(let a=0;a<o;a++){let c=r[a];if(await this.isPortAvailable(c))return St.info(`\u2705 Found available port: ${c}`),c;s.push(c),St.debug(`Port ${c} is in use (likely another AdaL instance), trying another port...`)}let i=`No available ports found after ${o} attempts. Tried ports: ${s.slice(0,5).join(", ")}... Possible solutions: (1) Close some AdaL instances, (2) Wait for ports to be released, (3) Check if other processes are using ports ${t.BASE_PORT}-${t.MAX_PORT}`;throw this.logError(i),new Error(`No available ports found in range ${t.BASE_PORT}-${t.MAX_PORT}. Too many AdaL instances may be running.`)}getDeploymentMode(){return this.rootPath.includes("/node_modules/")||this.rootPath.includes("\\node_modules\\")?"production":this.rootPath.endsWith("/adal-cli/bundle/adal-cli.js")||this.rootPath.endsWith("\\adal-cli\\bundle\\adal-cli.js")?"npm-link":"development"}findBackendPath(){let e=this.getDeploymentMode(),r=process.platform==="win32"?"adal-backend.exe":"adal-backend",n=process.env.ADAL_DEBUG==="true"||process.env.DEBUG_BACKEND==="true";switch(n&&(St.debug(`\u{1F50D} Deployment mode: ${e}`),St.debug(`\u{1F4CD} Current path: ${this.rootPath}`)),e){case"production":{let o=kf.dirname(this.rootPath),s=`${process.platform}-${process.arch}`,a={"darwin-arm64":"@sylphai/adal-cli-darwin-arm64","darwin-x64":"@sylphai/adal-cli-darwin-x64","linux-x64":"@sylphai/adal-cli-linux-x64","linux-arm64":"@sylphai/adal-cli-linux-arm64","win32-x64":"@sylphai/adal-cli-win32-x64","win32-ia32":"@sylphai/adal-cli-win32-x64"}[s];if(!a)throw new Error(`Unsupported platform: ${s}`);let c,l=kf.join(o,"package.json");Nv.existsSync(l)?JSON.parse(Nv.readFileSync(l,"utf8")).name===a?c=o:c=kf.join(o,"node_modules",a):c=kf.join(o,"..","node_modules",a),n&&(St.debug(`\u{1F50D} Platform: ${s}`),St.debug(`\u{1F4E6} Platform package: ${a}`),St.debug(`\u{1F4C2} Looking in: ${c}`));let u=kf.join(c,"backend",r);if(Nv.existsSync(u))return n&&St.debug(`\u2705 Found backend (flat structure): ${u}`),u;let E=kf.join(c,"backend","adal-backend",r);if(Nv.existsSync(E))return n&&St.debug(`\u2705 Found backend (nested structure): ${E}`),E;throw new Error(`Production backend not found!
|
|
946
946
|
Platform: ${s}
|
|
947
947
|
Package: ${a}
|
|
948
948
|
Expected at:
|
|
Binary file
|
|
Binary file
|