@abacus-ai/cli 2.5.1-canary.4 → 2.5.1-canary.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.
Files changed (2) hide show
  1. package/dist/index.mjs +7 -7
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -75106,7 +75106,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
75106
75106
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
75107
75107
  `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),tAe=G((e=>{var t=Uq(),n=Pq(),r=Fq(),i=pq(),a=$K(),o=Kq(),s=qq();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),nAe=G((e=>{var t=Uq(),n=Pq(),r=Nq(),i=Fq(),a=oq(),o=$K(),s=gq(),c=sq(),l=vq(),u=bq();Wq();var d=Gq(),f=Kq(),p=qq(),m=tAe(),h=eq();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync}))();function rAe(e){let t=e.trimStart();if(!t.startsWith(`---`))return{data:{},body:e};let n=t.match(/\r?\n---\s*(?:\r?\n|$)/);if(!n||n.index===void 0)return{data:{},body:e};let r=n.index,i=t.slice(3,r).trim(),a=t.slice(r+n[0].length).trim();try{let e=(0,nAe.parse)(i);return e&&typeof e==`object`&&!Array.isArray(e)?{data:e,body:a}:{data:{},body:a}}catch{return{data:{},body:e}}}function iAe(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}const aAe=dt([`codellm`,`agent`,`skills`]),Jq=new class{skills=new Map;async loadSkills(e,t){let r=await Xwe(t??`cli`),i=P.join(n.homedir(),hn.configDirName,`skills`),a=e?P.join(e,hn.localConfigDirName,`skills`):void 0,o=await this.discoverSkills(r,`builtin`),s=await this.discoverSkills(i,`global`),c=a?await this.discoverSkills(a,`project`):[];this.skills.clear();for(let e of o)this.skills.set(e.id,e);for(let e of s)this.skills.set(e.id,e);for(let e of c)this.skills.set(e.id,e);aAe.info`skills loaded: builtin=${o.length} global=${s.length} project=${c.length} clientKind=${t??`cli`}`}async discoverSkills(e,t){let n=[],r;try{r=await Te.readdir(e,{withFileTypes:!0})}catch{return n}r.sort((e,t)=>e.name.localeCompare(t.name));for(let i of r)if(i.isFile()&&i.name.endsWith(`.md`)){let r=P.join(e,i.name),a=await this.parseSkillFile(r,!1,t);a&&n.push(a)}else if(i.isDirectory()){let r=P.join(e,i.name,`SKILL.md`);try{await Te.access(r);let e=await this.parseSkillFile(r,!0,t);e&&n.push(e)}catch{}}return n}async parseSkillFile(e,t,n){try{let{data:r}=rAe(await Te.readFile(e,`utf-8`)),i=iAe(t?P.basename(P.dirname(e)):P.basename(e,`.md`));return i?this.buildSkill(i,r,e,t,n):null}catch{return null}}buildSkill(e,t,n,r,i){let a=t.name,o=t.description,s=typeof a==`string`&&a.trim()?a.trim():e,c=typeof o==`string`&&o.trim()?o.trim():void 0;if(!c)return null;let l={name:s,description:c};typeof t[`argument-hint`]==`string`&&(l[`argument-hint`]=t[`argument-hint`]),typeof t[`disable-model-invocation`]==`boolean`&&(l[`disable-model-invocation`]=t[`disable-model-invocation`]),typeof t[`user-invocable`]==`boolean`&&(l[`user-invocable`]=t[`user-invocable`]),Array.isArray(t[`allowed-tools`])&&(l[`allowed-tools`]=t[`allowed-tools`].filter(e=>typeof e==`string`)),typeof t.license==`string`&&(l.license=t.license),typeof t.compatibility==`string`&&(l.compatibility=t.compatibility);let u=t.metadata;if(u&&typeof u==`object`&&!Array.isArray(u)){let e={};for(let[t,n]of Object.entries(u))typeof n==`string`&&(e[t]=n);Object.keys(e).length>0&&(l.metadata=e)}return{id:e,frontmatter:l,path:n,isDirectory:r,source:i}}get(e){return this.skills.get(e)}getAll(){return Array.from(this.skills.values()).filter(e=>e.frontmatter[`user-invocable`]!==!1)}getAllMetadata(){return this.getAll().map(e=>({id:e.id,name:e.frontmatter.name,description:e.frontmatter.description,location:e.path}))}search(e){let t=e.toLowerCase();return this.getAll().filter(e=>e.id.toLowerCase().includes(t)||e.frontmatter.name.toLowerCase().includes(t)||e.frontmatter.description.toLowerCase().includes(t))}matchSkill(e){if(!e.startsWith(`/`))return null;let t=e.slice(1).split(/\s+/);if(t.length===0)return null;let[n,...r]=t;if(!n)return null;let i=this.skills.get(n);return!i||i.frontmatter[`user-invocable`]===!1?null:{skill:i,args:r.join(` `)}}},Yq=dt([`codellm`,`agent`,`tools`,`diagnostics`]);var oAe=class e extends QV{name=`get_diagnostics`;displayName=`GetDiagnostics`;description=`Get IDE diagnostics (errors, warnings, info) for a file or all open files.`;_provider;static Parameters=PR({uri:Y().optional().describe(`Optional file URI to get diagnostics for. If not provided, gets diagnostics for all files.`)});parameters=e.Parameters;constructor(e){super(),this._provider=e}needsPermission(){return!1}async execute(e,t){let n=e.uri?[e.uri]:void 0;Yq.debug`Getting diagnostics${e.uri?` for ${e.uri}`:` for all files`}`;let r=await this._provider.getDiagnostics(n);return Yq.debug`Found ${r.length} diagnostics`,{type:`get_diagnostics`,diagnostics:r,total:r.length}}format(e,t){return JSON.stringify({...e,status:`success`})}parse(e){let t=az(e);if(t.rejected)return{phase:`rejected`,toolType:`get_diagnostics`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e),n=t.status===`error`?`error`:`success`,r=t.diagnostics?.filter(e=>e.severity===`error`).length??0,i=t.diagnostics?.filter(e=>e.severity===`warning`).length??0,a=[];return r>0&&a.push(`${r} error${r===1?``:`s`}`),i>0&&a.push(`${i} warning${i===1?``:`s`}`),{phase:n,toolType:`get_diagnostics`,data:t,summary:a.length>0?a.join(`, `):`${t.total??0} diagnostics`}}catch{return{phase:`success`,toolType:`get_diagnostics`,data:{},summary:`Completed`}}}},sAe=class extends cz{includeInApiDefinitions=!1};const Xq=dt([`codellm`,`agent`,`tools`,`mcp`]);var cAe=class extends sAe{name;displayName;description;parameters;isReadonly=!1;mcpToolDefinition;constructor(e){super(),this.mcpToolDefinition=e,this.name=e.name,this.displayName=e.name,this.description=e.description||`MCP tool: ${e.name}`,this.parameters=this.createZodSchemaFromMCPSchema(e.inputSchema)}createZodSchemaFromMCPSchema(e){let t=e?.properties||{},n=e?.required||[],r={};for(let[e,i]of Object.entries(t)){let t=i,a=n.includes(e),o=this.jsonSchemaToZod(t);a||(o=o.optional()),r[e]=o}return PR(r)}jsonSchemaToZod(e){switch(e.type){case`string`:return e.enum?WR(e.enum):Y();case`number`:case`integer`:return BSe;case`boolean`:return hz;case`array`:return e.items?MR(this.jsonSchemaToZod(e.items)):MR(AR());case`object`:if(e.properties){let t={},n=e.required||[];for(let[r,i]of Object.entries(e.properties)){let e=this.jsonSchemaToZod(i);n.includes(r)||(e=e.optional()),t[r]=e}return PR(t)}return HR(Y(),AR());case`null`:return kR();default:return e.oneOf?this.jsonSchemaToZod(e.oneOf[0]):AR()}}async execute(e,t){if(Xq.debug`Executing MCP tool: ${this.name} (server=${this.mcpToolDefinition.serverId})`,!t.mcpService)return Xq.warn`MCP service not available for tool: ${this.name}`,{type:`mcp`,serverId:this.mcpToolDefinition.serverId,toolName:this.name,content:`MCP service not available`,isError:!0};try{let n=(await t.mcpService.listAllToolDefinitions()).find(e=>e.name===this.name);if(!n)throw Error(`MCP tool '${this.name}' not found`);let r=await t.mcpService.callTool(n.serverId,n.originalName||this.name,e);return{type:`mcp`,serverId:n.serverId,toolName:this.name,content:r.content||r,isError:r.isError||!1}}catch(e){return fu(e instanceof Error?e:Error(String(e)),{context:`mcp-tool-execution`}),Xq.error`MCP tool execution failed: ${this.name}: ${e instanceof Error?e.message:String(e)}`,{type:`mcp`,serverId:this.mcpToolDefinition.serverId,toolName:this.name,content:`MCP tool execution failed: ${e instanceof Error?e.message:String(e)}`,isError:!0}}}format(e,t){return JSON.stringify({type:`mcp`,status:e.isError?`error`:`success`,serverId:e.serverId,toolName:e.toolName,content:e.content})}parse(e){let t=az(e);if(t.rejected)return{phase:`rejected`,toolType:`mcp`,data:{},summary:t.userNote?`Rejected \u00b7 "${t.userNote}"`:`Rejected`,...t.userNote!==void 0&&{userNote:t.userNote}};try{let t=JSON.parse(e);return t.status===`error`||t.isError?{phase:`error`,toolType:`mcp`,data:t,summary:`Error`,errorMessage:typeof t.content==`string`?t.content:`MCP error`}:{phase:`success`,toolType:`mcp`,data:t,summary:`Executed successfully`}}catch{}return e.startsWith(`Error:`)?{phase:`error`,toolType:`mcp`,data:{},summary:e,errorMessage:e}:{phase:`success`,toolType:`mcp`,data:{},summary:`Executed successfully`}}};function lAe(e){return e.length>1e4?!0:e.split(/\r\n|\r|\n/).length>5e3}var uAe=class{_tmpDir=null;_counter=0;_ensureDir(){if(!this._tmpDir){let e=P.join(n.homedir(),hn.configDirName,`tmp`);m.mkdirSync(e,{recursive:!0}),this._tmpDir=m.mkdtempSync(P.join(e,`codellm-prompt-`))}return this._tmpDir}savePrompt(e){let t=this._ensureDir();this._counter++;let n=P.join(t,`prompt-${this._counter}.txt`);return m.writeFileSync(n,e,`utf-8`),n}cleanup(){if(this._tmpDir){try{m.rmSync(this._tmpDir,{recursive:!0,force:!0})}catch{}this._tmpDir=null,this._counter=0}}};const dAe={run_in_terminal:`bash`,get_terminal_output:`bash_output`,fetch_url:`web_fetch`},fAe={bash:{id:`shellId`,isBackground:`runInBackground`},bash_output:{id:`shellId`}};function Zq(e){let t=dAe[e.name];t&&(e.name=t);let n=fAe[e.name];if(n&&e.input&&typeof e.input==`object`){let t=e.input;for(let[e,r]of Object.entries(n))e in t&&!(r in t)&&(t[r]=t[e],delete t[e])}}function Qq(e){if(e.type===`code_llm_agent_tool_request`&&e.toolUseRequest){let t=Array.isArray(e.toolUseRequest)?e.toolUseRequest:[e.toolUseRequest];for(let e of t)Zq(e)}if(Array.isArray(e.segments))for(let t of e.segments)Qq(t)}function pAe(e){for(let t of e){if(t.toolUseRequest){let e=Array.isArray(t.toolUseRequest)?t.toolUseRequest:[t.toolUseRequest];for(let t of e)Zq(t)}if(Array.isArray(t.segments))for(let e of t.segments)Qq(e)}}var $q=class{sessionId;_logger=dt([`codellm`,`agent`,`session`]);_workspace;_terminalService;_registry;_mcpService;_config;_conversationId=null;_mode;_model;_running=!1;_abortController=null;_initialized=!1;_uploadedDocs=new Set;_rules=[];_markdownContext=``;_agentsMdContent=void 0;_agentsMdSentInConversation=!1;_rulesEngine;_toolEventBuffer=[];_messageQueue=[];_promptFileManager=new uAe;_swapFolder=null;_setFolder=null;onAutoRestart=null;mcp;rules;constructor(e){let t=qF(GF(e.primaryWorkspace)),n=Array.from(new Set([t,...e.allowedDirectories.map(e=>qF(GF(e)))]));this._config={...e,primaryWorkspace:t,allowedDirectories:n},this.sessionId=crypto.randomUUID(),this._mode=e.mode??Rd.Normal,this._model=e.model??``,this._logger.info(`Creating AgentSession (workspace={workspace}, mode={mode})`,{workspace:t,mode:this._mode}),this._workspace=new iEe(t),this._terminalService=new Nke(t),this._terminalService.onBackgroundComplete=(e,t,n)=>{let r=`Background process (id=${e}) running \`${t}\` has ${n===0?`completed successfully`:`exited with code ${n}`}.`;this.nq(r,{hidden:!0}),!this._running&&this.onAutoRestart&&this.onAutoRestart(r)},this._registry=vH(),e.disabledBuiltinTools?.length&&this._registry.setDisabledTools(e.disabledBuiltinTools),e.diagnosticsProvider&&this._registry.register(new oAe(e.diagnosticsProvider)),this._mcpService=new ZK;let r=e.config?.get(`permissions`)??{},i={allow:[...r.allow??[],...e.permissionRules?.allow??[]],deny:[...r.deny??[],...e.permissionRules?.deny??[]],ask:[...r.ask??[],...e.permissionRules?.ask??[]]};this._rulesEngine=new CTe({rules:i,cliAllowed:e.cliAllowedTools,cliDenied:e.cliDisallowedTools}),this.mcp=this._buildMcpManager(),this.rules=this._buildRulesManager()}async _ensureInitialized(){if(!this._initialized){if(this._initialized=!0,this._logger.debug(`Initializing session`),this._config.config){await this._config.config.load(),this._config.clientType??=this._config.config.get(`client`),this._config.sendAgentMd??=this._config.config.get(`autoLoadAgentsMd`),this._config.supportsConnectors??=this._config.config.get(`enableConnectors`);let e=this._config.config.get(`baseUrl`);e&&(this._config.apiClient.setUrl(e),this._config.apiClient.resetEndpoints(),await this._config.apiClient.getApiEndpoint());let t=this._config.config.get(`permissions`);if(t){for(let e of t.allow??[])this._rulesEngine.addAllowRule(e);for(let e of t.deny??[])this._rulesEngine.addDenyRule(e);for(let e of t.ask??[])this._rulesEngine.addAskRule(e)}let n=this._config.config.get(`additionalDirectories`);if(n)for(let e of n){let t=qF(GF(e));if(!this._config.allowedDirectories.includes(t)){this._config.allowedDirectories.push(t);let e=t.endsWith(`/`)?t:t+`/`;this._rulesEngine.addAllowRule(`Bash(cd ${e}*)`),this._rulesEngine.addAllowRule(`Bash(cd ${t})`)}}}await Promise.all([this._mcpService.initialize(this._config.primaryWorkspace,this._config.mcpServers,this._config.onMcpAuthRequired),this._config.enableSkills?Jq.loadSkills(this._config.primaryWorkspace,this._config.clientType?.toLowerCase()):Promise.resolve(),this._config.sendAgentMd?this._loadAgentMd():Promise.resolve()])}}_buildMcpManager(){return{listServers:()=>this._mcpService.getConnectedServers(),addServer:async e=>{let t=this._mcpService.getConnectedServers().map(e=>e.config);return this._mcpService.initialize(this._config.primaryWorkspace,[...t,e],this._config.onMcpAuthRequired)},removeServer:async e=>{let t=this._mcpService.getConnectedServers().map(e=>e.config).filter(t=>t.id!==e);await this._mcpService.initialize(this._config.primaryWorkspace,t,this._config.onMcpAuthRequired)},callTool:(e,t,n)=>this._mcpService.callTool(e,t,n),getTools:()=>this._mcpService.getAbacusMcpTools(),refresh:async e=>{await this._mcpService.initialize(e??this._config.primaryWorkspace,this._config.mcpServers,this._config.onMcpAuthRequired)},authenticateServer:(e,t)=>this._mcpService.authenticateServer(e,t)}}_buildRulesManager(){return{getAll:()=>this._rules,getMarkdownContext:()=>this._markdownContext,reload:async()=>{this._rules=[],this._markdownContext=``}}}async _loadAgentMd(){let e=this._config.primaryWorkspace;try{let t=(await Te.readdir(e)).find(e=>e.toLowerCase()===`agents.md`);t&&(this._agentsMdContent=await Te.readFile(P.join(e,t),`utf-8`))}catch{}}_buildBrowserActionDescription(e){switch(e.name){case`perform_interactive_element_action`:{let{action:t,id:n,text:r}=e.input,i=t??`interact with`,a={click:`Click`,type:`Type`,hover:`Hover`,scroll:`Scroll`,focus:`Focus`,select:`Select`}[i]??i;return i===`type`&&r&&n?`Type "${r}" into element ${n}`:i===`select`&&r&&n?`Select "${r}" in element ${n}`:n?`${a} element ${n}`:a}case`computer`:{let{action:t,coordinate:n,text:r}=e.input,i=t??``;return i===`screenshot`?`Screenshot`:i===`key`&&r?`Key: ${r}`:i===`type`&&r?`Type "${r}"`:n?`${i} at (${String(n[0])}, ${String(n[1])})`:i||`Computer action`}case`navigate_to`:return`Navigate to ${e.input.url??``}`;case`new_tab`:return`Open new tab${e.input.url?`: ${e.input.url}`:``}`;case`switch_active_tab`:return`Switch to tab ${String(e.input.id??``)}`;case`close_tab`:return`Close tab ${String(e.input.id??``)}`;case`refresh_tab`:return`Refresh tab`;case`get_tab_content`:return`Get tab content`;case`get_interactive_elements`:return`Get interactive elements`;default:return e.name}}_buildPermissionRequest(e,t){let n=this._registry.get(e.name)?.displayName??e.name;if(!_H.isBuiltinRequest(e))return{type:`generic`,tool:e,displayName:n,toolName:n,inputSummary:JSON.stringify(e.input).slice(0,200)};switch(e.name){case`read`:{let t=GF(e.input.filePath??``),r=qF(P.isAbsolute(t)?t:P.resolve(this._config.primaryWorkspace,t));return{type:`read_outside_directory`,tool:e,displayName:n,filePath:r,resolvedPath:r,deducedDirectory:P.dirname(r)}}case`edit`:{let r=t._prepareResult;if(r?.outsideWorkspace){let t=qF(r.resolvedPath??e.input.filePath??``);return{type:`edit_outside_directory`,tool:e,displayName:n,filePath:t,resolvedPath:t,deducedDirectory:P.dirname(t)}}if(r?.error)return{type:`edit_file`,tool:e,displayName:n,filePath:e.input.filePath??``,originalContent:``,newContent:``};let i=r?.currentContent??``,a=r?.newContent??``;return{type:`edit_file`,tool:e,displayName:n,filePath:e.input.filePath??``,originalContent:i,newContent:a}}case`write`:{let r=t._prepareResult;if(r?.outsideWorkspace){let t=qF(r.resolvedPath??e.input.filePath??``);return{type:`write_outside_directory`,tool:e,displayName:n,filePath:t,resolvedPath:t,deducedDirectory:P.dirname(t),isNewFile:!r?.fileExists}}return{type:`write_file`,tool:e,displayName:n,filePath:e.input.filePath??``,originalContent:r?.currentContent??``,content:e.input.content??``,isNewFile:!r?.fileExists}}case`bash`:{let t=e.input.command??``;return{type:`run_terminal`,tool:e,displayName:n,command:t,cwd:this._config.primaryWorkspace,background:!!(e.input.runInBackground??!1),unmatchedPatterns:this._rulesEngine.getUnmatchedBashSegments(t,this._config.primaryWorkspace)}}case`exit_plan_mode`:{let r=t._prepareResult;return{type:`exit_plan_mode`,tool:e,displayName:n,planFilePath:e.input.planFilePath??``,planContent:String(r?.planContent??``)}}case`ask_user_question`:return{type:`ask_user_question`,tool:e,displayName:n,questions:Array.isArray(e.input.questions)?e.input.questions:[]};case`navigate_to`:return{type:`browser_action`,tool:e,displayName:n,action:e.name,url:e.input.url,description:this._buildBrowserActionDescription(e)};case`computer`:case`perform_interactive_element_action`:case`switch_active_tab`:case`close_tab`:case`refresh_tab`:case`get_tab_content`:case`get_interactive_elements`:case`new_tab`:return{type:`browser_action`,tool:e,displayName:n,action:e.name,description:this._buildBrowserActionDescription(e)};case`notebook_edit`:{let r=t._prepareResult;if(r?.outsideWorkspace){let t=qF(r.resolvedPath??e.input.notebookPath??``);return{type:`notebook_edit_outside_directory`,tool:e,displayName:n,filePath:t,resolvedPath:t,deducedDirectory:P.dirname(t)}}let i=r?.notebook,a=e.input.cellId,o=e.input.editMode??`replace`,s=``;if(a&&i?.cells){let e=i.cells.find(e=>e.id===a||e.metadata?.id===a);e&&(s=Array.isArray(e.source)?e.source.join(``):String(e.source??``))}return{type:`notebook_edit`,tool:e,displayName:n,notebookPath:e.input.notebookPath??``,cellId:a,editMode:o,cellType:e.input.cellType,originalContent:s,newContent:e.input.newSource??``}}default:return{type:`generic`,tool:e,displayName:n,toolName:n,inputSummary:JSON.stringify(e.input).slice(0,200)}}}_buildExecuteTools(e){return async(t,n,r)=>{let a=new AbortController,o=()=>a.abort(`interrupted`);n&&(n.aborted?a.abort(`interrupted`):n.addEventListener(`abort`,o,{once:!0}));let s=[],c=(e,t,n)=>{let r=n?.storageContent??t;return{id:e.id,content:t,...n?.rejected&&{rejected:!0},parsedResult:r.startsWith(`Error:`)?{phase:`error`,toolType:e.name,data:{},summary:r,errorMessage:r}:this._registry.parse(e.name,r)}};try{let o=async t=>{if(a.signal.aborted)return{resolved:!0,result:c(t,JSON.stringify({reason:rz.INTERRUPTED}),{rejected:!0})};let o={workspace:this._workspace,terminalService:this._terminalService,apiClient:this._config.apiClient,workspacePath:this._config.primaryWorkspace,conversationId:e,agentMode:this._mode,toolCallId:t.id,status:`executing`,uploadedDocs:this._uploadedDocs,allowEditingPaths:this._config.allowedDirectories,abortController:a,permissionProvider:this._config.permissionProvider,rulesEngine:this._rulesEngine,getAgentMode:()=>this._mode,setAgentMode:e=>{this._mode=e},mcpService:{listAllToolDefinitions:async()=>this._mcpService.getAbacusMcpTools(),callTool:(e,t,n)=>this._mcpService.callTool(e,t,n),reloadConnections:async()=>{await this._mcpService.initialize(this._config.primaryWorkspace,this._config.mcpServers,this._config.onMcpAuthRequired)},getServerStatus:e=>{let t=this._mcpService.getConnectedServers().find(t=>t.config.id===e);return t?t.status===`connected`?`running`:`error`:`stopped`}},...this._rules.length>0&&{rules:this._rules},...this._config.planDirectory!==void 0&&{plansDir:this._config.planDirectory},...this._config.clientType&&{clientType:this._config.clientType},...r&&{emitEvent:r},...r&&{onOutputUpdate:(e,t)=>{r({type:`tool_output_update`,toolCallId:e,output:t})}}};try{if(this._registry.isDisabled(t.name))return{resolved:!0,result:c(t,`Error: tool '${t.name}' is disabled in this environment`)};r?.({type:`tool_execution_start`,tool:t});let e=this._registry.createToolInstance(t.name,t.input??{},o);if(await e.prepare(),t.name===`edit`&&_H.isBuiltinRequest(t)&&!e._prepareResult?.error){let n=e._prepareResult,a=o.workspacePath,s=o.plansDir??P.join(i(),hn.configDirName,`plans`),c=YF(P.resolve(a,t.input.filePath??``),P.resolve(a,s)),l={originalContent:n?.currentContent??``,newContent:n?.newContent??``,isPlanFile:c,isNewFile:!(n?.fileExists??!0)},u={type:`tool_display_data`,toolCallId:t.id,data:l};r?.(u),this._toolEventBuffer.push(u)}if(t.name===`notebook_edit`&&_H.isBuiltinRequest(t)&&!e._prepareResult?.error){let n=e._prepareResult?.notebook,i=t.input.cellId,a=``;if(i&&n?.cells){let e=n.cells.find(e=>e.id===i||e.metadata?.id===i);e&&(a=Array.isArray(e.source)?e.source.join(``):String(e.source??``))}let o={originalContent:a,newContent:t.input.newSource??``},s={type:`tool_display_data`,toolCallId:t.id,data:o};r?.(s),this._toolEventBuffer.push(s)}if(t.name===`write`&&_H.isBuiltinRequest(t)&&!e._prepareResult?.error){let n=e._prepareResult,i={originalContent:n?.currentContent??``,newContent:t.input.content??``,isNewFile:!(n?.fileExists??!0)},a={type:`tool_display_data`,toolCallId:t.id,data:i};r?.(a),this._toolEventBuffer.push(a)}let a=this._mode===Rd.Yolo&&t.name!==`ask_user_question`;if(!a&&e.needsPermission()){let i=this._registry.get(t.name)?.displayName??t.name,a=EH(t),s=this._rulesEngine.evaluate(i,a,this._config.primaryWorkspace);if(s===`deny`)return{resolved:!0,result:c(t,JSON.stringify({reason:rz.REJECTED}),{rejected:!0})};if(s!==`allow`){let i=this._buildPermissionRequest(t,e);if(this._config.permissionProvider.needsPermission(i)){let a={type:`status_changed`,status:zd.WaitingForToolPermission};r?.(a),this._toolEventBuffer.push(a);let s;try{let e=this._config.permissionProvider.requestPermission(i);if(n){let t,r=new Promise((e,r)=>{n.aborted?r(Error(`interrupted`)):(t=()=>r(Error(`interrupted`)),n.addEventListener(`abort`,t,{once:!0}))});try{s=await Promise.race([e,r])}finally{t&&n.removeEventListener(`abort`,t)}}else s=await e}catch{return{resolved:!0,result:c(t,JSON.stringify({reason:rz.INTERRUPTED}),{rejected:!0})}}if(r?.({type:`status_changed`,status:zd.ExecutingTool}),this._toolEventBuffer.push({type:`status_changed`,status:zd.ExecutingTool}),s===`reject`)return{resolved:!0,result:c(t,JSON.stringify({reason:rz.REJECTED}),{rejected:!0})};if(typeof s==`object`&&s.type===`reject_with_message`)return{resolved:!0,result:c(t,JSON.stringify({reason:rz.USER_MESSAGE,message:s.message}),{rejected:!0})};if(s===`allowAlways`||s===`allowYolo`||s===`accept`){if(s===`allowAlways`&&(i.type===`read_outside_directory`||i.type===`write_outside_directory`||i.type===`edit_outside_directory`||i.type===`notebook_edit_outside_directory`)){if(this.addAllowedDirectory(i.deducedDirectory),this._config.config){let e=this._config.config.get(`additionalDirectories`)??[];e.includes(i.deducedDirectory)||this._config.config.set(`additionalDirectories`,[...e,i.deducedDirectory],`local`)}}else if(t.name===`exit_plan_mode`){let e=s===`allowYolo`?Rd.Yolo:s===`allowAlways`?Rd.AcceptEdits:Rd.Normal;this._mode=e,o.agentMode=e,r?.({type:`mode_changed`,mode:e}),this._toolEventBuffer.push({type:`mode_changed`,mode:e})}else if(s===`allowAlways`){let e=Wd(i.type);this._mode=e,o.agentMode=e,r?.({type:`mode_changed`,mode:e}),this._toolEventBuffer.push({type:`mode_changed`,mode:e})}}if(typeof s==`object`&&s.type===`accept_with_message`&&this.nq(s.message),typeof s==`object`&&s.type===`question_answers`&&e.mergeParams({answers:s.answers}),typeof s==`object`&&s.type===`allow_always_with_rule`&&(this._rulesEngine.addAllowRule(s.rule),this._config.config)){let e=this._config.config.get(`permissions`)??{},t=[...e.allow??[],s.rule];this._config.config.set(`permissions`,{...e,allow:t},`local`)}if(typeof s==`object`&&s.type===`allow_always_with_rules`){for(let e of s.rules)this._rulesEngine.addAllowRule(e);if(this._config.config){let e=this._config.config.get(`permissions`)??{},t=[...e.allow??[],...s.rules];this._config.config.set(`permissions`,{...e,allow:t},`local`)}}}}}return t.name===`enter_plan_mode`&&(this._mode=Rd.PlanMode,o.agentMode=Rd.PlanMode,r?.({type:`mode_changed`,mode:Rd.PlanMode}),this._toolEventBuffer.push({type:`mode_changed`,mode:Rd.PlanMode})),t.name===`exit_plan_mode`&&a&&(this._mode=Rd.Normal,o.agentMode=Rd.Normal,r?.({type:`mode_changed`,mode:Rd.Normal}),this._toolEventBuffer.push({type:`mode_changed`,mode:Rd.Normal})),{resolved:!1,call:t,instance:e,ctx:o}}catch(e){return a.signal.aborted?{resolved:!0,result:c(t,JSON.stringify({reason:rz.INTERRUPTED}),{rejected:!0})}:{resolved:!0,result:c(t,`Error: ${e instanceof Error?e.message:String(e)}`)}}},l=async e=>{try{if(await e.instance.execute(),a.signal.aborted)return c(e.call,JSON.stringify({reason:rz.INTERRUPTED}),{rejected:!0});let t=e.instance.formatResultForLLM(),n=e.instance.formatResult(),r=typeof t==`string`?t:JSON.stringify(t);return c(e.call,r,{storageContent:n===r?void 0:n})}catch(t){if(a.signal.aborted)return c(e.call,JSON.stringify({reason:rz.INTERRUPTED}),{rejected:!0});let n=t instanceof Error?t.message:String(t);return c(e.call,`Error: ${n}`)}},u=0,d=!1;for(;u<t.length;){let e=e=>this._registry.get(e.name)?.concurrency(e.input,this._config.primaryWorkspace)??!1;if(d){let n=t[u],i=!!e(n),a=this._registry.get(n.name),o=a?!a.isReadonly:!1;if(i||o){let e=c(n,sz);s.push(e),r?.({type:`tool_execution_complete`,tool:n,result:e}),u++;continue}}if(e(t[u])){let n=u+1;for(;n<t.length&&e(t[n]);)n++;if(n-u>1){let i=t.slice(u,n),a=i.map(e);u=n;let f=[[]],p=[new Set];for(let e=0;e<i.length;e++){let t=a[e],n=f[f.length-1],r=p[p.length-1];typeof t==`string`&&r.has(t)&&(f.push([]),p.push(new Set),n=f[f.length-1],r=p[p.length-1]),typeof t==`string`&&r.add(t),n.push(e)}let m=new Map,h=new Map,g=!1;for(let e of f){if(g){for(let t of e){let e=c(i[t],sz);s.push(e),r?.({type:`tool_execution_complete`,tool:i[t],result:e})}continue}for(let t of e)m.set(t,await o(i[t]));for(let t of e){let e=m.get(t);e.resolved&&r?.({type:`tool_execution_complete`,tool:i[t],result:e.result})}let t=e.filter(e=>!m.get(e).resolved).map(async e=>{let t=m.get(e);if(!t.resolved){let n=await l(t);h.set(e,n),r?.({type:`tool_execution_complete`,tool:i[e],result:n})}});for(let e=0;e<t.length;e+=10)await Promise.all(t.slice(e,e+10));for(let t of e){let e=m.get(t),n=e.resolved?e.result:h.get(t);s.push(n),!g&&!n.rejected&&n.content.startsWith(`Error:`)&&(g=!0)}}g&&(d=!0);continue}}let n=t[u];u++;let i=await o(n);if(i.resolved){s.push(i.result),r?.({type:`tool_execution_complete`,tool:n,result:i.result});continue}let a=await l(i);s.push(a),r?.({type:`tool_execution_complete`,tool:n,result:a})}return s}finally{n&&n.removeEventListener(`abort`,o)}}}async createConversation(){let e=await this._config.apiClient.createCodellmDeploymentConversation(this._config.isPrintMode?hn.nonInteractiveAgentType:hn.agentType,this._config.clientType);if(e?.success===!1&&e.error)throw Error(e.error);let t=e?.result?.deploymentConversationId;if(!t)throw Error(`Failed to create conversation: no deployment conversation ID returned`);return this._conversationId=t,t}async loadConversation(e){this._conversationId=e;let t=await this._config.apiClient.getDeploymentConversation({deploymentConversationId:e}),n=t?.result?.history??[],r=t?.result?.name??void 0;pAe(n);let i=this._hydrateHistory(n),a;for(let e=n.length-1;e>=0;e--){let t=n[e]?.inputParams?.llmName;if(t){a=t;break}}return{...r!==void 0&&{title:r},...a!==void 0&&{llmName:a},segments:i}}switchConversation(e){return this._conversationId=e,this._uploadedDocs.clear(),Promise.resolve()}resetConversation(){this._conversationId=null,this._uploadedDocs.clear(),this._agentsMdSentInConversation=!1}async deleteConversation(e){await this._config.apiClient.deleteDeploymentConversation?.({deploymentConversationId:e}),this._conversationId===e&&(this._conversationId=null,this._uploadedDocs.clear(),this._agentsMdSentInConversation=!1)}async listConversations(){return((await this._config.apiClient.getConversationsList(this._config.isPrintMode?hn.nonInteractiveAgentType:hn.agentType))?.result??[]).map(e=>({id:e.deploymentConversationId??``,createdAt:new Date(e.createdAt??Date.now()),updatedAt:new Date(e.lastEventCreatedAt??e.createdAt??Date.now()),...e.name!==void 0&&{title:e.name}}))}_hydrateHistory(e){let t=[],n=[];for(let r of e){if(r.role===`USER`){let e=this._extractParallelToolResponses(r);e.length>0&&this._attachToolResults(n,e),n=[];let i=(r.prompt??r.text??``).trim();i&&t.push({type:`text`,id:crypto.randomUUID(),source:`user`,content:i});continue}n=[];for(let e of r.segments??[]){if(e.isThoughts){let n=typeof e.segment==`string`?e.segment:e.segment?.segment??``;t.push({type:`thinking`,id:crypto.randomUUID(),content:n,isSpinny:!1});continue}if(e.type===`code_llm_agent_tool_request`&&e.toolUseRequest){let r=Array.isArray(e.toolUseRequest)?e.toolUseRequest:[e.toolUseRequest];for(let e of r){let r={type:`tool_call`,id:crypto.randomUUID(),toolUseRequest:e,toolPhase:`unknown`};t.push(r),n.push(r)}continue}if(e.type===`code_llm_notification`){t.push({type:`notification`,id:crypto.randomUUID(),message:e.message??(typeof e.segment==`string`?e.segment:``)??``,severity:e.severity??`info`,...e.actions!==void 0&&{actions:e.actions}});continue}let r=typeof e.segment==`string`?e.segment:e.segment?.segment;r&&t.push({type:`text`,id:crypto.randomUUID(),source:`bot`,content:r})}}return this._detectAbandonedTools(t),t}_extractParallelToolResponses(e){if(Array.isArray(e.parallelToolResponses))return e.parallelToolResponses;for(let t of e.segments??[])if(Array.isArray(t.parallelToolResponses)&&t.parallelToolResponses.length>0)return t.parallelToolResponses;return[]}_attachToolResults(e,t){for(let n=0;n<Math.min(e.length,t.length);n++){let r=e[n],i=t[n],a=r.toolUseRequest.name,o=az(i);r.toolUseResult={id:r.toolUseRequest.id,content:i,...o.rejected&&{rejected:!0}};let s=this._registry.parse(a,i);o.rejected&&(s.phase=`rejected`,o.userNote!==void 0&&(s.userNote=o.userNote)),r.parsedResult=s,r.toolPhase=s.phase}}_detectAbandonedTools(e){let t=new Set([`todo_write`]);for(let n=0;n<e.length;n++){let r=e[n];if(r.type===`tool_call`&&!r.toolUseResult&&!t.has(r.toolUseRequest.name)){let t=e.slice(n+1).some(e=>e.type===`text`||e.type===`tool_call`),i=t?`abandoned`:`abandoned_last`;r.toolPhase=i,r.parsedResult={phase:i,toolType:r.toolUseRequest.name,data:{},summary:t?`Abandoned`:`Abandoned · What should I do next?`}}}}_rewriteIfLargePrompt(e){return lAe(e)?`The large prompt is saved in ${this._promptFileManager.savePrompt(e)} file. Follow the instructions in it.`:e}async*send(e,t){if(await this._ensureInitialized(),this._logger.info(`Sending message (conversationId={conversationId}, mode={mode}, model={model})`,{conversationId:this._conversationId,mode:this._mode,model:this._model}),!this._conversationId)for(let e=0;e<8;e++)try{await this.createConversation();break}catch(t){if(!Eu(t)||e>=7)throw t;let n=Math.min((e+1)*2e3,1e4);yield{type:`retry`,attempt:e+1,maxAttempts:8,delayMs:n,isNetworkError:!0},await Tz(n)}this._running=!0,this._abortController=new AbortController;let n=this._buildExecuteTools(this._conversationId);try{yield{type:`status_changed`,status:zd.Submitted};let r=this._rewriteIfLargePrompt(e),i=!0;for(;;){let e=this._mcpService.getAbacusMcpTools();e.length>0&&this._registry.registerMCPTools(e.map(e=>new cAe(e)));let a=this._registry.getApiToolDefinitions(),o=this._config.isPrintMode?a.filter(e=>e.name!==`ask_user_question`):a,s={apiClient:this._config.apiClient,conversationId:this._conversationId,model:this._model,workspacePath:this._config.primaryWorkspace,...this._swapFolder&&{swapFolder:this._swapFolder},...this._setFolder&&{setFolder:this._setFolder},uploadedDocs:this._uploadedDocs,supportedTools:o,supportedSubAgents:Cz().map(e=>({name:e})),...e.length>0&&{mcpTools:e},...this._rules.length>0&&{rules:this._rules},...this._config.sendAgentMd&&!this._agentsMdSentInConversation&&this._agentsMdContent!==void 0&&{agentsMd:this._agentsMdContent},...this._config.enableSkills&&(()=>{let e=Jq.getAllMetadata();return e.length>0?{availableSkills:e}:{}})(),...this._config.enableSkills&&t?.activeSkills&&t.activeSkills.length>0&&{activeSkills:t.activeSkills},...this._config.isPrintMode!==void 0&&{isPrintMode:this._config.isPrintMode},...this._config.enablePromptRewrite!==void 0&&{enablePromptRewrite:this._config.enablePromptRewrite},...this._config.supportsThoughtStreaming!==void 0&&{supportsThoughtStreaming:this._config.supportsThoughtStreaming},...this._config.supportsConnectors!==void 0&&{supportsConnectors:this._config.supportsConnectors},agentMode:this._mode,...this._config.config?.get(`client`)&&{client:this._config.config.get(`client`)},...this._config.maxTurns!==void 0&&{maxTurns:this._config.maxTurns},...i&&t?.diagnosticIssues!==void 0&&{diagnosticIssues:t.diagnosticIssues},...i&&t?.currentFile!==void 0&&{currentFile:P.isAbsolute(t.currentFile)?t.currentFile:P.resolve(this._config.primaryWorkspace,t.currentFile)},...i&&t?.selectionStartLine!==void 0&&{selectionStartLine:t.selectionStartLine},...i&&t?.selectionEndLine!==void 0&&{selectionEndLine:t.selectionEndLine},executeTools:n,getConcurrency:e=>this._registry.get(e.name)?.concurrency(e.input,this._config.primaryWorkspace)??!1,drainEvents:()=>{let e=this._toolEventBuffer.slice();return this._toolEventBuffer.length=0,e},dequeueAllQueuedMessage:e=>{let t=this.dq(e);return t.length===0?null:{message:this._rewriteIfLargePrompt(t.map(e=>e.message).join(`
75108
75108
  `)),allHidden:t.every(e=>e.hidden)}}};this._swapFolder=null,this._setFolder=null,s.agentsMd!==void 0&&(this._agentsMdSentInConversation=!0);let c=Az(s,r,this._abortController.signal),l=!1,u;for(;!(u=await c.next()).done;){let e=u.value;e.type===`text_delta`&&!l?(l=!0,yield{type:`status_changed`,status:zd.Streaming}):e.type===`tool_requested`&&(yield{type:`status_changed`,status:zd.ExecutingTool}),yield e,e.type===`mode_changed`&&(this._mode=e.mode)}if(i=!1,this._messageQueue.length===0||this._abortController.signal.aborted)break;let d=this.dq({includeHidden:!0});if(d.length===0)break;let f=d.every(e=>e.hidden);r=this._rewriteIfLargePrompt(d.map(e=>e.message).join(`
75109
- `)),f||(yield{type:`user_message_dequeued`,content:r})}}finally{this._running=!1,this._abortController=null,this._toolEventBuffer.length=0,this._uploadedDocs.clear(),this._promptFileManager.cleanup(),this._logger.debug(`Send completed, session idle`),yield{type:`status_changed`,status:zd.Idle}}}stop(){this._abortController?.abort()}dispose(){this._abortController?.abort(),this._promptFileManager.cleanup(),this._terminalService.dispose()}nq(e,t){let n={id:crypto.randomUUID(),message:e,...t?.hidden?{hidden:!0}:{}};return this._messageQueue.push(n),{...n}}getQueue(e){return this.getQueueEntries(e).map(e=>e.message)}getQueueEntries(e){return e?.includeHidden??!1?this._messageQueue.map(e=>({...e})):this._messageQueue.filter(e=>e.hidden!==!0).map(e=>({...e}))}dq(e){let t=e?.includeHidden??!1,n=e?.id;if(n!==void 0){let e=this._messageQueue.findIndex(e=>e.id===n?t||e.hidden!==!0:!1);if(e===-1)return[];let[r]=this._messageQueue.splice(e,1);return r?[{...r}]:[]}if(t){let e=this._messageQueue.map(e=>({...e}));return this._messageQueue.length=0,e}let r=[],i=[];for(let e of this._messageQueue)e.hidden===!0?i.push(e):r.push({...e});return this._messageQueue=i,r}setContent(e,t){let n=typeof e==`string`?e:e.id,r=this._messageQueue.find(e=>e.id===n);return r?(r.message=t,{...r}):null}setText(e,t){return this.setContent(e,t)}remove(e,t){let n=typeof e==`string`?e:e.id,r=t?.includeHidden??!1,i=this._messageQueue.findIndex(e=>e.id===n&&(r||e.hidden!==!0));i!==-1&&this._messageQueue.splice(i,1)}clearQueue(e){if(e?.includeHidden===!0){this._messageQueue.length=0;return}this._messageQueue=this._messageQueue.filter(e=>e.hidden===!0)}addUploadedDoc(e){this._uploadedDocs.add(e)}clearUploadedDocs(){this._uploadedDocs.clear()}isDirectoryAllowed(e){let t=qF(GF(e));for(let e of this._config.allowedDirectories)if(YF(t,e))return{allowed:!0,coveredBy:e};return{allowed:!1}}addAllowedDirectory(e,t){let n=qF(GF(e));for(let e of this._config.allowedDirectories)if(YF(n,e))return{status:`already-allowed`,coveredBy:e};this._config.allowedDirectories.push(n);let r=n.endsWith(`/`)?n:n+`/`;if(this._rulesEngine.addAllowRule(`Bash(cd ${r}*)`),this._rulesEngine.addAllowRule(`Bash(cd ${n})`),t?.persist&&this._config.config){let e=this._config.config.get(`additionalDirectories`)??[];e.includes(n)||this._config.config.set(`additionalDirectories`,[...e,n],`local`)}return{status:`added`}}setMode(e){this._mode=e}refreshPermissionRequest(e){return e.type===`run_terminal`?{...e,cwd:this._config.primaryWorkspace,unmatchedPatterns:this._rulesEngine.getUnmatchedBashSegments(e.command,this._config.primaryWorkspace)}:e}setModel(e){this._model=e}setWorkspace(e){let t=qF(GF(e));if(this._config.primaryWorkspace=t,!this._config.allowedDirectories.includes(t)){this._config.allowedDirectories.push(t);let e=t.endsWith(`/`)?t:t+`/`;this._rulesEngine.addAllowRule(`Bash(cd ${e}*)`),this._rulesEngine.addAllowRule(`Bash(cd ${t})`)}this._swapFolder=t,this._setFolder=t,this._workspace.setCwd(t),this._terminalService.setCwd(t)}getMode(){return this._mode}getConversationId(){return this._conversationId}isRunning(){return this._running}listTerminalSessions(){return this._terminalService.listSessions()}getTerminalSessionOutput(e){let t=this._terminalService.getLiveOutput(e);if(t)return t.output;let n=this._terminalService.getOutput(e);return n.length>0?n[n.length-1].output:``}async stopTerminalSession(e){return this._terminalService.stopCommand(e)}},mAe=class{needsPermission(e){return!1}async requestPermission(e){return`accept`}},eJ=class{handler;_needsPermission;constructor(e,t){this.handler=e,this._needsPermission=t}needsPermission(e){return this._needsPermission?this._needsPermission(e):!0}async requestPermission(e){return this.handler(e)}};const hAe=dt([`codellm`,`agent`,`config`]);var gAe=class{async read(){let e=process.env[`${hn.internalEnvPrefix}ADDITIONAL_CONFIG`];if(!e)return{};try{let t=await b.readFile(e,`utf-8`);return JSON.parse(t)}catch{return hAe.debug`CODELLM_ADDITIONAL_CONFIG ${e} failed to load, ignoring`,{}}}};const _Ae={cli:nt.CLI,extension:nt.EXTENSION,cowork:nt.COWORK,desktop:nt.COWORK,cloud:nt.CLOUD};function vAe(e){return _Ae[e.trim().toLowerCase().replaceAll(/[_\s-]+/g,``)]}var yAe=class{async read(){let e={},t=hn.envPrefix,n=hn.internalEnvPrefix,r=process.env[`${t}BASE_URL`],i=process.env[`${t}MODEL`],a=process.env[`${n}LOG_LEVEL`],o=process.env[`${t}MAX_TURNS`],s=process.env[`${t}AUTO_UPDATE`],c=process.env[`${n}CHANNEL`],l=process.env[`${n}CLIENT_KIND`],u=gz.parse(process.env[`${t}AUTO_LOAD_AGENTS_MD`]),d=gz.parse(process.env[`${n}ENABLE_CONNECTORS`]);if(r&&(e.baseUrl=r),i&&(e.model=i),a&&(e.logLevel=a),o&&(e.maxTurns=parseInt(o,10)),c&&(e.updateChannel=c),u&&(e.autoLoadAgentsMd=u),d&&(e.enableConnectors=d),l){let t=vAe(l);t&&(e.client=t)}if(s!==void 0){let t=gz.safeParse(s);t.success&&t.data!==void 0&&(e.autoUpdate=t.data)}return e}},bAe=class{configPath;constructor(){this.configPath=P.join(i(),hn.configDirName,hn.configFileName)}async read(){try{let e=await b.readFile(this.configPath,`utf-8`);return JSON.parse(e)}catch{return{}}}async write(e){let t=P.dirname(this.configPath);await b.mkdir(t,{recursive:!0}),await b.writeFile(this.configPath,JSON.stringify(e,null,2),`utf-8`)}},xAe=class{configPath;constructor(e){this.configPath=P.join(e,hn.localConfigDirName,hn.configFileName)}async read(){try{let e=await b.readFile(this.configPath,`utf-8`);return JSON.parse(e)}catch{return{}}}async write(e){let t=P.dirname(this.configPath);await b.mkdir(t,{recursive:!0}),await b.writeFile(this.configPath,JSON.stringify(e,null,2),`utf-8`)}};const SAe=dt([`codellm`,`agent`,`config`]);function tJ(e,...t){let n={...e};for(let e of t)for(let t of Object.keys(e)){let r=e[t];r!==void 0&&(typeof r==`object`&&r&&!Array.isArray(r)&&typeof n[t]==`object`&&n[t]!==null?n[t]=tJ(n[t],r):n[t]=r)}return n}const nJ={allowedDirectories:[],primaryWorkspace:``,logLevel:`info`};var rJ=class{sources;cache=null;constructor(e){this.sources=[new bAe,new xAe(e.cwd),new gAe,...e.extraSources??[],new yAe]}async load(){let e={...nJ};for(let t of this.sources){let n=await t.read();e=tJ(e,n)}this.cache=e,SAe.info`config loaded from ${this.sources.length} sources`}get(e){return this.cache?this.cache[e]??nJ[e]:nJ[e]}getAll(){return this.cache??nJ}async set(e,t,n=`global`){let r=n===`global`?this.sources[0]:this.sources[1];if(r?.write){let n=await r.read();await r.write({...n,[e]:t})}this.cache&&(this.cache[e]=t)}};const iJ=dt([`codellm`,`agent`,`native-notifier`]),CAe={complete:`Glass`,"action-required":`Ping`},wAe={complete:`complete`,"action-required":`dialog-warning`};function aJ(e){try{oe(e,{windowsHide:!0},e=>{e&&(iJ.warn`Notification sound command failed: ${e}`,fu(e,{context:`native-notifier`,phase:`play-sound`}))})}catch(e){iJ.warn`Notification sound exec threw synchronously: ${e}`,fu(e instanceof Error?e:Error(String(e)),{context:`native-notifier`,phase:`play-sound-sync`})}}function TAe(e){let t=process.platform;if(t===`darwin`)aJ(`afplay /System/Library/Sounds/${CAe[e]}.aiff`);else if(t===`win32`)aJ(`powershell -NoProfile -c "[console]::beep(${e===`complete`?880:440},400)"`);else{let t=wAe[e];aJ(`paplay /usr/share/sounds/freedesktop/stereo/${t}.oga 2>/dev/null || aplay /usr/share/sounds/freedesktop/stereo/${t}.oga 2>/dev/null || true`)}}function EAe(e,t,n,r){let i={title:e,message:t,sound:!1,...r?.iconPath&&{icon:r.iconPath},...r?.activateBundleId&&{activate:r.activateBundleId}},a=e=>{e&&(iJ.warn`OS notification failed: ${e}`,fu(e instanceof Error?e:Error(String(e)),{context:`native-notifier`,phase:`send-notification`,platform:process.platform,arch:process.arch}))};Promise.resolve().then(()=>{U.notify(i,e=>a(e))}).catch(a)}dt([`codellm`,`agent`,`history`]);var oJ=class{source;maxEntries;filePath;entries=[];navIndex=-1;loaded=!1;writeQueue=Promise.resolve();constructor(e,t){this.source=e,this.maxEntries=t?.maxEntries??1e4,this.filePath=t?.filePath??te(i(),hn.configDirName,`history.jsonl`)}async load(){if(!this.loaded){this.loaded=!0;try{let e=this.maxEntries*2048,t=await De(this.filePath,`r`);try{let{size:n}=await t.stat(),r=Math.max(0,n-e),i=Buffer.allocUnsafe(n-r);await t.read(i,0,i.length,r);let a=i.toString(`utf-8`),o=r===0?0:a.indexOf(`
75109
+ `)),f||(yield{type:`user_message_dequeued`,content:r})}}finally{this._running=!1,this._abortController=null,this._toolEventBuffer.length=0,this._uploadedDocs.clear(),this._promptFileManager.cleanup(),this._logger.debug(`Send completed, session idle`),yield{type:`status_changed`,status:zd.Idle}}}stop(){this._abortController?.abort()}dispose(){this._abortController?.abort(),this._promptFileManager.cleanup(),this._terminalService.dispose()}nq(e,t){let n={id:crypto.randomUUID(),message:e,...t?.hidden?{hidden:!0}:{}};return this._messageQueue.push(n),{...n}}getQueue(e){return this.getQueueEntries(e).map(e=>e.message)}getQueueEntries(e){return e?.includeHidden??!1?this._messageQueue.map(e=>({...e})):this._messageQueue.filter(e=>e.hidden!==!0).map(e=>({...e}))}dq(e){let t=e?.includeHidden??!1,n=e?.id;if(n!==void 0){let e=this._messageQueue.findIndex(e=>e.id===n?t||e.hidden!==!0:!1);if(e===-1)return[];let[r]=this._messageQueue.splice(e,1);return r?[{...r}]:[]}if(t){let e=this._messageQueue.map(e=>({...e}));return this._messageQueue.length=0,e}let r=[],i=[];for(let e of this._messageQueue)e.hidden===!0?i.push(e):r.push({...e});return this._messageQueue=i,r}setContent(e,t){let n=typeof e==`string`?e:e.id,r=this._messageQueue.find(e=>e.id===n);return r?(r.message=t,{...r}):null}setText(e,t){return this.setContent(e,t)}remove(e,t){let n=typeof e==`string`?e:e.id,r=t?.includeHidden??!1,i=this._messageQueue.findIndex(e=>e.id===n&&(r||e.hidden!==!0));i!==-1&&this._messageQueue.splice(i,1)}clearQueue(e){if(e?.includeHidden===!0){this._messageQueue.length=0;return}this._messageQueue=this._messageQueue.filter(e=>e.hidden===!0)}addUploadedDoc(e){this._uploadedDocs.add(e)}clearUploadedDocs(){this._uploadedDocs.clear()}isDirectoryAllowed(e){let t=qF(GF(e));for(let e of this._config.allowedDirectories)if(YF(t,e))return{allowed:!0,coveredBy:e};return{allowed:!1}}addAllowedDirectory(e,t){let n=qF(GF(e));for(let e of this._config.allowedDirectories)if(YF(n,e))return{status:`already-allowed`,coveredBy:e};this._config.allowedDirectories.push(n);let r=n.endsWith(`/`)?n:n+`/`;if(this._rulesEngine.addAllowRule(`Bash(cd ${r}*)`),this._rulesEngine.addAllowRule(`Bash(cd ${n})`),t?.persist&&this._config.config){let e=this._config.config.get(`additionalDirectories`)??[];e.includes(n)||this._config.config.set(`additionalDirectories`,[...e,n],`local`)}return{status:`added`}}setMode(e){this._mode=e}refreshPermissionRequest(e){return e.type===`run_terminal`?{...e,cwd:this._config.primaryWorkspace,unmatchedPatterns:this._rulesEngine.getUnmatchedBashSegments(e.command,this._config.primaryWorkspace)}:e}setModel(e){this._model=e}setWorkspace(e){let t=qF(GF(e));if(this._config.primaryWorkspace=t,!this._config.allowedDirectories.includes(t)){this._config.allowedDirectories.push(t);let e=t.endsWith(`/`)?t:t+`/`;this._rulesEngine.addAllowRule(`Bash(cd ${e}*)`),this._rulesEngine.addAllowRule(`Bash(cd ${t})`)}this._swapFolder=t,this._setFolder=t,this._workspace.setCwd(t),this._terminalService.setCwd(t)}getMode(){return this._mode}getConversationId(){return this._conversationId}isRunning(){return this._running}listTerminalSessions(){return this._terminalService.listSessions()}getTerminalSessionOutput(e){let t=this._terminalService.getLiveOutput(e);if(t)return t.output;let n=this._terminalService.getOutput(e);return n.length>0?n[n.length-1].output:``}async stopTerminalSession(e){return this._terminalService.stopCommand(e)}},mAe=class{needsPermission(e){return!1}async requestPermission(e){return`accept`}},eJ=class{handler;_needsPermission;constructor(e,t){this.handler=e,this._needsPermission=t}needsPermission(e){return this._needsPermission?this._needsPermission(e):!0}async requestPermission(e){return this.handler(e)}};const hAe=dt([`codellm`,`agent`,`config`]);var gAe=class{async read(){let e=process.env[`${hn.internalEnvPrefix}ADDITIONAL_CONFIG`];if(!e)return{};try{let t=await b.readFile(e,`utf-8`);return JSON.parse(t)}catch{return hAe.debug`CODELLM_ADDITIONAL_CONFIG ${e} failed to load, ignoring`,{}}}};const _Ae={cli:nt.CLI,extension:nt.EXTENSION,cowork:nt.COWORK,desktop:nt.COWORK,cloud:nt.CLOUD};function vAe(e){return _Ae[e.trim().toLowerCase().replaceAll(/[_\s-]+/g,``)]}var yAe=class{async read(){let e={},t=hn.envPrefix,n=hn.internalEnvPrefix,r=process.env[`${t}BASE_URL`],i=process.env[`${t}MODEL`],a=process.env[`${n}LOG_LEVEL`],o=process.env[`${t}MAX_TURNS`],s=process.env[`${t}AUTO_UPDATE`],c=process.env[`${n}CHANNEL`],l=process.env[`${n}CLIENT_KIND`],u=gz.parse(process.env[`${t}AUTO_LOAD_AGENTS_MD`]),d=gz.parse(process.env[`${n}ENABLE_CONNECTORS`]);if(r&&(e.baseUrl=r),i&&(e.model=i),a&&(e.logLevel=a),o&&(e.maxTurns=parseInt(o,10)),c&&(e.updateChannel=c),u!==void 0&&(e.autoLoadAgentsMd=u),d&&(e.enableConnectors=d),l){let t=vAe(l);t&&(e.client=t)}if(s!==void 0){let t=gz.safeParse(s);t.success&&t.data!==void 0&&(e.autoUpdate=t.data)}return e}},bAe=class{configPath;constructor(){this.configPath=P.join(i(),hn.configDirName,hn.configFileName)}async read(){try{let e=await b.readFile(this.configPath,`utf-8`);return JSON.parse(e)}catch{return{}}}async write(e){let t=P.dirname(this.configPath);await b.mkdir(t,{recursive:!0}),await b.writeFile(this.configPath,JSON.stringify(e,null,2),`utf-8`)}},xAe=class{configPath;constructor(e){this.configPath=P.join(e,hn.localConfigDirName,hn.configFileName)}async read(){try{let e=await b.readFile(this.configPath,`utf-8`);return JSON.parse(e)}catch{return{}}}async write(e){let t=P.dirname(this.configPath);await b.mkdir(t,{recursive:!0}),await b.writeFile(this.configPath,JSON.stringify(e,null,2),`utf-8`)}};const SAe=dt([`codellm`,`agent`,`config`]);function tJ(e,...t){let n={...e};for(let e of t)for(let t of Object.keys(e)){let r=e[t];r!==void 0&&(typeof r==`object`&&r&&!Array.isArray(r)&&typeof n[t]==`object`&&n[t]!==null?n[t]=tJ(n[t],r):n[t]=r)}return n}const nJ={allowedDirectories:[],primaryWorkspace:``,logLevel:`info`,autoLoadAgentsMd:!0};var rJ=class{sources;cache=null;constructor(e){this.sources=[new bAe,new xAe(e.cwd),new gAe,...e.extraSources??[],new yAe]}async load(){let e={...nJ};for(let t of this.sources){let n=await t.read();e=tJ(e,n)}this.cache=e,SAe.info`config loaded from ${this.sources.length} sources`}get(e){return this.cache?this.cache[e]??nJ[e]:nJ[e]}getAll(){return this.cache??nJ}async set(e,t,n=`global`){let r=n===`global`?this.sources[0]:this.sources[1];if(r?.write){let n=await r.read();await r.write({...n,[e]:t})}this.cache&&(this.cache[e]=t)}};const iJ=dt([`codellm`,`agent`,`native-notifier`]),CAe={complete:`Glass`,"action-required":`Ping`},wAe={complete:`complete`,"action-required":`dialog-warning`};function aJ(e){try{oe(e,{windowsHide:!0},e=>{e&&(iJ.warn`Notification sound command failed: ${e}`,fu(e,{context:`native-notifier`,phase:`play-sound`}))})}catch(e){iJ.warn`Notification sound exec threw synchronously: ${e}`,fu(e instanceof Error?e:Error(String(e)),{context:`native-notifier`,phase:`play-sound-sync`})}}function TAe(e){let t=process.platform;if(t===`darwin`)aJ(`afplay /System/Library/Sounds/${CAe[e]}.aiff`);else if(t===`win32`)aJ(`powershell -NoProfile -c "[console]::beep(${e===`complete`?880:440},400)"`);else{let t=wAe[e];aJ(`paplay /usr/share/sounds/freedesktop/stereo/${t}.oga 2>/dev/null || aplay /usr/share/sounds/freedesktop/stereo/${t}.oga 2>/dev/null || true`)}}function EAe(e,t,n,r){let i={title:e,message:t,sound:!1,...r?.iconPath&&{icon:r.iconPath},...r?.activateBundleId&&{activate:r.activateBundleId}},a=e=>{e&&(iJ.warn`OS notification failed: ${e}`,fu(e instanceof Error?e:Error(String(e)),{context:`native-notifier`,phase:`send-notification`,platform:process.platform,arch:process.arch}))};Promise.resolve().then(()=>{U.notify(i,e=>a(e))}).catch(a)}dt([`codellm`,`agent`,`history`]);var oJ=class{source;maxEntries;filePath;entries=[];navIndex=-1;loaded=!1;writeQueue=Promise.resolve();constructor(e,t){this.source=e,this.maxEntries=t?.maxEntries??1e4,this.filePath=t?.filePath??te(i(),hn.configDirName,`history.jsonl`)}async load(){if(!this.loaded){this.loaded=!0;try{let e=this.maxEntries*2048,t=await De(this.filePath,`r`);try{let{size:n}=await t.stat(),r=Math.max(0,n-e),i=Buffer.allocUnsafe(n-r);await t.read(i,0,i.length,r);let a=i.toString(`utf-8`),o=r===0?0:a.indexOf(`
75110
75110
  `)+1,s=a.slice(o).split(`
75111
75111
  `).filter(Boolean);for(let e of s)try{let t=JSON.parse(e);t.message&&t.source&&this.entries.push(t)}catch{}this.entries.length>this.maxEntries&&(this.entries=this.entries.slice(-this.maxEntries))}finally{await t.close()}}catch{}}}append(e){let t=e.trimStart();if(!t)return;let n={ts:new Date().toISOString(),source:this.source,message:t,multiline:t.includes(`
75112
75112
  `)};this.entries.push(n),this.entries.length>this.maxEntries?(this.entries=this.entries.slice(-this.maxEntries),this.enqueueWrite(()=>this.rewriteFile())):this.enqueueWrite(()=>this.appendLine(n))}isNavigating(){return this.navIndex!==-1}navigateUp(){if(this.entries.length===0)return null;if(this.navIndex===-1)this.navIndex=this.entries.length-1;else if(this.navIndex>0)this.navIndex--;else return null;return this.entries[this.navIndex]??null}navigateDown(){return this.navIndex===-1?null:(this.navIndex++,this.navIndex>=this.entries.length?(this.navIndex=-1,null):this.entries[this.navIndex]??null)}resetNavigation(){this.navIndex=-1}getEntries(){return this.entries}enqueueWrite(e){this.writeQueue=this.writeQueue.then(e).catch(()=>{})}async appendLine(e){try{await Ee(ee(this.filePath),{recursive:!0});let t=await De(this.filePath,`a`);try{await t.write(JSON.stringify(e)+`
@@ -75178,12 +75178,12 @@ No matching component was found for:
75178
75178
  * This source code is licensed under the MIT license found in the
75179
75179
  * LICENSE file in the root directory of this source tree.
75180
75180
  */
75181
- var xPe=G((e=>{var t=wY().__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;e.c=function(e){return t.H.useMemoCache(e)}})),cQ=G(((e,t)=>{t.exports=xPe()}))();function $(e){let t=(0,cQ.c)(14),{color:n,backgroundColor:r,dimColor:i,bold:a,italic:o,underline:s,strikethrough:c,inverse:l,wrap:u,transform:d,children:f}=e,p=i===void 0?!1:i,m=a===void 0?!1:a,h=o===void 0?!1:o,g=s===void 0?!1:s,_=c===void 0?!1:c,v=l===void 0?!1:l,y=u===void 0?`wrap`:u;if(f==null)return null;let b;t[0]!==r||t[1]!==m||t[2]!==n||t[3]!==p||t[4]!==v||t[5]!==h||t[6]!==_||t[7]!==g||t[8]!==d?(b=e=>(p&&(e=XZ().dim().render(e)),n&&(e=YZ(e,n,`foreground`)),r&&(e=YZ(e,r,`background`)),m&&(e=XZ().bold().render(e)),h&&(e=XZ().italic().render(e)),g&&(e=XZ().underline().render(e)),_&&(e=XZ().strikethrough().render(e)),v&&(e=XZ().reverse().render(e)),d&&(e=d(e)),e),t[0]=r,t[1]=m,t[2]=n,t[3]=p,t[4]=v,t[5]=h,t[6]=_,t[7]=g,t[8]=d,t[9]=b):b=t[9];let x=b,S;return t[10]!==f||t[11]!==x||t[12]!==y?(S=(0,Z.jsx)(`jar-text`,{style:{flexGrow:0,flexShrink:0,flexDirection:`row`,textWrap:y},internal_transform:x,children:f}),t[10]=f,t[11]=x,t[12]=y,t[13]=S):S=t[13],S}const SPe=/\x1b\[[\d:]*;(\d+)/;function CPe(e){let t=SPe.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const lQ={upArrow:!1,downArrow:!1,leftArrow:!1,rightArrow:!1,pageDown:!1,pageUp:!1,home:!1,end:!1,return:!1,escape:!1,ctrl:!1,shift:!1,tab:!1,backspace:!1,delete:!1,meta:!1,super:!1,paste:!1,raw:``},uQ=(e,t={})=>{let{addInputListener:n}=(0,X.use)(CZ),r=(0,X.useRef)(e);r.current=e,(0,X.useEffect)(()=>{if(t.isActive!==!1)return n(e=>{if(tX(e))return;if(e.startsWith(`\x1B[200~`)){let t=e.indexOf(`\x1B[201~`),n=t===-1?e.slice(6):e.slice(6,t);lQ.upArrow=!1,lQ.downArrow=!1,lQ.leftArrow=!1,lQ.rightArrow=!1,lQ.pageDown=!1,lQ.pageUp=!1,lQ.home=!1,lQ.end=!1,lQ.return=!1,lQ.escape=!1,lQ.ctrl=!1,lQ.shift=!1,lQ.tab=!1,lQ.backspace=!1,lQ.delete=!1,lQ.meta=!1,lQ.super=!1,lQ.paste=!0,lQ.raw=e,r.current(n,{...lQ});return}let t=AMe(e),n=t?t.split(`+`):[],i=n[n.length-1]??``,a=n.includes(`ctrl`),o=n.includes(`shift`),s=n.includes(`alt`);lQ.upArrow=i===`up`,lQ.downArrow=i===`down`,lQ.leftArrow=i===`left`,lQ.rightArrow=i===`right`,lQ.pageDown=i===`pagedown`,lQ.pageUp=i===`pageup`,lQ.home=i===`home`,lQ.end=i===`end`,lQ.return=i===`return`||i===`enter`,lQ.escape=i===`escape`,lQ.ctrl=a,lQ.shift=o,lQ.tab=i===`tab`,lQ.backspace=i===`backspace`,lQ.delete=i===`delete`,lQ.meta=s,lQ.super=CPe(e),lQ.paste=!1,lQ.raw=e;let c=lQ,l=``;if(a&&i)l=i;else if(!c.upArrow&&!c.downArrow&&!c.leftArrow&&!c.rightArrow&&!c.pageDown&&!c.pageUp&&!c.home&&!c.end&&!c.return&&!c.escape&&!c.tab&&!c.backspace&&!c.delete){let t=NMe(e);t===void 0?e.length===1?l=e:i.length===1&&(l=i):l=t}r.current(l,{...c})})},[t.isActive,n])},wPe=()=>{let e=(0,X.use)(wZ);if(!e)throw Error(`useApp must be used within a jar render context`);return{exit:e.exit,requestFullRedraw:e.requestFullRedraw}},dQ=e=>{let t=(0,cQ.c)(23),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{isActive:r,autoFocus:i,id:a}=n,o=r===void 0?!0:r,s=i===void 0?!1:i,{activeId:c,add:l,remove:u,activate:d,deactivate:f,focus:p}=(0,X.use)(xZ),m;t[2]===a?m=t[3]:(m=a??Math.random().toString().slice(2,7),t[2]=a,t[3]=m);let h=m,g;t[4]!==l||t[5]!==s||t[6]!==h||t[7]!==u?(g=()=>(l(h,{autoFocus:s}),()=>{u(h)}),t[4]=l,t[5]=s,t[6]=h,t[7]=u,t[8]=g):g=t[8];let _;t[9]!==s||t[10]!==h?(_=[h,s],t[9]=s,t[10]=h,t[11]=_):_=t[11],(0,X.useEffect)(g,_);let v;t[12]!==d||t[13]!==f||t[14]!==h||t[15]!==o?(v=()=>{o?d(h):f(h)},t[12]=d,t[13]=f,t[14]=h,t[15]=o,t[16]=v):v=t[16];let y;t[17]!==h||t[18]!==o?(y=[o,h],t[17]=h,t[18]=o,t[19]=y):y=t[19],(0,X.useEffect)(v,y);let b=!!h&&c===h,x;return t[20]!==p||t[21]!==b?(x={isFocused:b,focus:p},t[20]=p,t[21]=b,t[22]=x):x=t[22],x};function fQ(){return(0,X.use)(SZ)}const pQ=()=>{let e=(0,X.use)(TZ);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},mQ=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function TPe(){return new RegExp(mQ.source,`g`)}function EPe(e){return e.replace(mQ,``)}function DPe(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function hQ(e){return`\x1B]2;`+DPe(e)+`\x07`}var gQ=G(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.5.1-canary.4`,private:!0,bin:{abacusai:`dist/index.mjs`},files:[`dist`,`LICENSE.txt`],type:`module`,scripts:{"prepare-publish":`bun ./scripts/prepare-publish.ts`,build:`tsdown`,"check-types":`tsgo -b --noEmit`,test:`FORCE_COLOR=1 vitest run`,"test:watch":`FORCE_COLOR=1 vitest`,"test:ui":`FORCE_COLOR=1 vitest --ui`,"test:coverage":`FORCE_COLOR=1 vitest run --coverage`},dependencies:{"@clack/prompts":`^0.11.0`,"@codellm/agent":`workspace:*`,"@codellm/api":`workspace:*`,"@codellm/auth":`workspace:*`,"@codellm/comms":`workspace:*`,"@codellm/jar":`workspace:*`,"@codellm/logging":`workspace:*`,"@codellm/product":`workspace:*`,"@logtape/logtape":`catalog:`,"@orpc/client":`catalog:`,"@orpc/contract":`catalog:`,"@orpc/server":`catalog:`,"@sentry/node-core":`catalog:`,"@slack/web-api":`^7.0.0`,"@tanstack/react-query":`catalog:`,"@vscode/ripgrep":`catalog:`,"ansi-styles":`catalog:`,"beautiful-mermaid":`^1.1.3`,"cli-boxes":`catalog:`,"cli-highlight":`^2.1.11`,conf:`catalog:`,diff:`catalog:`,fzf:`catalog:`,"gradient-string":`^3.0.0`,immer:`catalog:`,"isomorphic-git":`catalog:`,marked:`^17.0.6`,"node-notifier":`catalog:`,"patchright-core":`catalog:`,react:`catalog:react`,"react-compiler-runtime":`^1.0.0`,remend:`^1.3.0`,semver:`catalog:`,"shell-history":`^2.0.1`,"string-width":`catalog:`,"strip-ansi":`catalog:`,trash:`catalog:`,zod:`catalog:`},devDependencies:{"@babel/core":`catalog:infra`,"@codellm/configs":`workspace:*`,"@playwright/mcp":`^0.0.68`,"@rolldown/plugin-babel":`catalog:infra`,"@types/diff":`^8.0.0`,"@types/node":`catalog:`,"@types/react":`catalog:react`,"@types/semver":`^7.7.1`,"@typescript/native-preview":`catalog:infra`,"@vitejs/plugin-react":`catalog:infra`,"@vitest/coverage-v8":`^4.1.5`,"@vitest/ui":`^4.1.5`,"@xterm/addon-serialize":`^0.14.0`,"@xterm/headless":`^6.0.0`,"babel-plugin-react-compiler":`catalog:infra`,"cli-testing-library":`^3.0.1`,jsdom:`^27.4.0`,"react-devtools-core":`^6.1.5`,"svg-term-cli":`^2.1.1`,tsdown:`catalog:infra`,vite:`catalog:infra`,vitest:`catalog:infra`,zigpty:`^0.1.6`},engines:{node:`>=18`}}})),_Q=$e(gQ(),1);let vQ=null;function yQ(e){let t=(0,lY.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function bQ(e){if(!e)return``;try{return T(e)}catch{return e}}function xQ(){return{invokedPath:bQ(process.argv[1]??``),execPath:bQ(process.execPath??process.argv[0]??``)}}function SQ(e){let t=hn.configDirName.replace(/^\./,``).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`[/\\\\]\\.?${t}[/\\\\]bin[/\\\\]`,`i`).test(e)}function CQ(e){return/[/\\]node_modules[/\\]/.test(e)||/[/\\]\._npx[/\\]/.test(e)||/[/\\]_npx[/\\]/.test(e)||/[/\\]\.?npm[/\\]/.test(e)||/[/\\]\.?pnpm[/\\]/.test(e)||/[/\\]\.?yarn[/\\]/.test(e)||/[/\\]\.bun[/\\]/.test(e)}function wQ(){let e=(process.env.npm_command??``).toLowerCase();if(e===`exec`||e===`dlx`)return!0;let{invokedPath:t,execPath:n}=xQ();return/[/\\]_npx[/\\]|[/\\]dlx[/\\]|[/\\]\.cache[/\\]/.test(t+`|`+n)}function TQ(){let e=process.env.npm_config_user_agent;if(e){let t=e.split(`/`)[0];if(t===`yarn`||t===`pnpm`||t===`bun`||t===`npm`)return t}let{invokedPath:t,execPath:n}=xQ(),r=`${t}|${n}`;return/[/\\]\.?yarn[/\\]/.test(r)?`yarn`:/[/\\]\.?pnpm[/\\]/.test(r)?`pnpm`:/[/\\]\.bun[/\\]/.test(r)||process.versions.bun!==void 0&&!SQ(n)?`bun`:`npm`}function OPe(){let{execPath:e,invokedPath:t}=xQ();return CQ(t)||CQ(e)?!1:SQ(e)||SQ(t)}function EQ(){let e=`${hn.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let{invokedPath:n,execPath:r}=xQ();return!(SQ(r)||SQ(n)||CQ(n)||CQ(r)||process.env.npm_config_user_agent)}function kPe(){let{execPath:e}=xQ(),t=TQ(),n=wQ();return EQ()?{installationType:`development`,packageManager:t,isEphemeral:n,execPath:e}:OPe()?{installationType:`native`,packageManager:t,isEphemeral:n,execPath:e}:{installationType:`package-manager`,packageManager:t,isEphemeral:n,execPath:e}}function APe(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}async function jPe(e){let t=Date.now();if(vQ&&t-vQ.timestamp<6e4)return vQ.tags;let n=await fetch(`https://registry.npmjs.org/${e}`,{signal:AbortSignal.timeout(1e4),headers:{accept:`application/json`}});if(!n.ok)throw Error(`Registry returned ${n.status}`);let r=(await n.json())[`dist-tags`]??{};return vQ={tags:r,timestamp:t},r}async function MPe(e,t,n,r){let i=t??yQ(e),a=(r??`https://apps.abacus.ai`).replace(/\/$/,``),o=new URL(`${a}/api/v0/_getCodellmCliVersion`);o.searchParams.set(`channel`,i),n&&o.searchParams.set(`platform`,n),o.searchParams.set(`cli_version`,e);let s=await fetch(o.toString(),{signal:AbortSignal.timeout(1e4)});if(s.status===204)return null;if(!s.ok)throw Error(`API returned ${s.status}`);let c=await s.json(),l=c&&`result`in c&&c.result?c.result:c??{};if(!l.version||!l.channel)throw Error(`API returned invalid payload`);return{currentVersion:e,latestVersion:l.version,tag:l.channel,packageManager:TQ(),isEphemeral:wQ(),installationType:`native`,downloadUrl:l.url}}async function NPe(e,t){let n=t??yQ(e),r=TQ(),i=wQ(),a=(await jPe(gn.publishName))[n];return!a&&n!==`latest`||!a||a===e?null:{currentVersion:e,latestVersion:a,tag:n,packageManager:r,isEphemeral:i,installationType:`package-manager`}}async function DQ(e,t,n,r){let i=kPe();if(i.installationType===`native`)try{return await MPe(e,t,APe(),n)}catch{return null}return i.installationType===`development`&&!r?.includeDev?null:await NPe(e,t)}function OQ(e){if(e.installationType===`native`)return`${hn.binName} upgrade`;let t=`${gn.publishName}@${e.tag}`;switch(e.packageManager){case`yarn`:return`yarn global add ${t}`;case`pnpm`:return`pnpm add -g ${t}`;case`bun`:return`bun add -g ${t}`;default:return`npm install -g ${t}`}}function kQ(e){try{return{ok:!0,output:le(OQ(e),{stdio:`pipe`,encoding:`utf-8`}).trim()}}catch(e){return{ok:!1,output:e instanceof Error&&`stderr`in e?String(e.stderr).trim():e instanceof Error?e.message:`Unknown error`}}}function PPe(){let e=N.join(t.homedir(),hn.configDirName,`bin`);try{let n=N.dirname(bQ(process.execPath));return!n||n.toLowerCase().startsWith(t.tmpdir().toLowerCase())?e:n}catch{return e}}async function AQ(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let n=N.join(t.tmpdir(),`abacusai-update-${Date.now()}`),r=process.platform===`win32`,i=r?`${hn.binName}.exe`:hn.binName,a=PPe();try{await we.mkdir(n,{recursive:!0}),await we.mkdir(a,{recursive:!0});let t=N.join(n,r?`update.zip`:`update.tar.gz`),o=await fetch(e.downloadUrl);if(!o.ok)throw Error(`Download failed: ${o.status}`);let s=Buffer.from(await o.arrayBuffer());await we.writeFile(t,s),le(r?`powershell -Command "Expand-Archive -Path '${t}' -DestinationPath '${n}' -Force"`:`tar -xzf "${t}" -C "${n}"`,{stdio:`pipe`});let c=N.join(n,i),l=N.join(a,i);if(r){let e=`${l}.old`;await we.rm(e,{force:!0}).catch(()=>{}),await we.rename(l,e).catch(()=>{}),await we.copyFile(c,l),await we.rm(e,{force:!0}).catch(()=>{})}else await we.copyFile(c,l),await we.chmod(l,493);return{ok:!0,output:`Updated to ${e.latestVersion}`}}catch(e){return{ok:!1,output:e instanceof Error?e.message:`Unknown error`}}finally{await we.rm(n,{recursive:!0,force:!0}).catch(()=>{})}}function FPe(e,t){let n=e=>{let n=e.toLowerCase();if(n===t)return 1e3;if(n.startsWith(t))return 900;let r=0,i=-1;for(let e of t){let t=n.indexOf(e,i+1);if(t===-1)return 0;r+=100-(t-i),i=t}return r+=Math.max(0,50-n.length),r},r=null,i=0;for(let t of e){let e=Math.max(n(t.name??``),n(t.llmName));e>i&&(i=e,r=t.llmName)}return i>=100?r:null}async function jQ(e,t,n=nt.CLI){let r=(await e.listLLMModels({coworkV2:n===nt.COWORK}))?.result??[];return r.length||(process.stderr.write(`Error: No models available.
75181
+ var xPe=G((e=>{var t=wY().__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;e.c=function(e){return t.H.useMemoCache(e)}})),cQ=G(((e,t)=>{t.exports=xPe()}))();function $(e){let t=(0,cQ.c)(14),{color:n,backgroundColor:r,dimColor:i,bold:a,italic:o,underline:s,strikethrough:c,inverse:l,wrap:u,transform:d,children:f}=e,p=i===void 0?!1:i,m=a===void 0?!1:a,h=o===void 0?!1:o,g=s===void 0?!1:s,_=c===void 0?!1:c,v=l===void 0?!1:l,y=u===void 0?`wrap`:u;if(f==null)return null;let b;t[0]!==r||t[1]!==m||t[2]!==n||t[3]!==p||t[4]!==v||t[5]!==h||t[6]!==_||t[7]!==g||t[8]!==d?(b=e=>(p&&(e=XZ().dim().render(e)),n&&(e=YZ(e,n,`foreground`)),r&&(e=YZ(e,r,`background`)),m&&(e=XZ().bold().render(e)),h&&(e=XZ().italic().render(e)),g&&(e=XZ().underline().render(e)),_&&(e=XZ().strikethrough().render(e)),v&&(e=XZ().reverse().render(e)),d&&(e=d(e)),e),t[0]=r,t[1]=m,t[2]=n,t[3]=p,t[4]=v,t[5]=h,t[6]=_,t[7]=g,t[8]=d,t[9]=b):b=t[9];let x=b,S;return t[10]!==f||t[11]!==x||t[12]!==y?(S=(0,Z.jsx)(`jar-text`,{style:{flexGrow:0,flexShrink:0,flexDirection:`row`,textWrap:y},internal_transform:x,children:f}),t[10]=f,t[11]=x,t[12]=y,t[13]=S):S=t[13],S}const SPe=/\x1b\[[\d:]*;(\d+)/;function CPe(e){let t=SPe.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const lQ={upArrow:!1,downArrow:!1,leftArrow:!1,rightArrow:!1,pageDown:!1,pageUp:!1,home:!1,end:!1,return:!1,escape:!1,ctrl:!1,shift:!1,tab:!1,backspace:!1,delete:!1,meta:!1,super:!1,paste:!1,raw:``},uQ=(e,t={})=>{let{addInputListener:n}=(0,X.use)(CZ),r=(0,X.useRef)(e);r.current=e,(0,X.useEffect)(()=>{if(t.isActive!==!1)return n(e=>{if(tX(e))return;if(e.startsWith(`\x1B[200~`)){let t=e.indexOf(`\x1B[201~`),n=t===-1?e.slice(6):e.slice(6,t);lQ.upArrow=!1,lQ.downArrow=!1,lQ.leftArrow=!1,lQ.rightArrow=!1,lQ.pageDown=!1,lQ.pageUp=!1,lQ.home=!1,lQ.end=!1,lQ.return=!1,lQ.escape=!1,lQ.ctrl=!1,lQ.shift=!1,lQ.tab=!1,lQ.backspace=!1,lQ.delete=!1,lQ.meta=!1,lQ.super=!1,lQ.paste=!0,lQ.raw=e,r.current(n,{...lQ});return}let t=AMe(e),n=t?t.split(`+`):[],i=n[n.length-1]??``,a=n.includes(`ctrl`),o=n.includes(`shift`),s=n.includes(`alt`);lQ.upArrow=i===`up`,lQ.downArrow=i===`down`,lQ.leftArrow=i===`left`,lQ.rightArrow=i===`right`,lQ.pageDown=i===`pagedown`,lQ.pageUp=i===`pageup`,lQ.home=i===`home`,lQ.end=i===`end`,lQ.return=i===`return`||i===`enter`,lQ.escape=i===`escape`,lQ.ctrl=a,lQ.shift=o,lQ.tab=i===`tab`,lQ.backspace=i===`backspace`,lQ.delete=i===`delete`,lQ.meta=s,lQ.super=CPe(e),lQ.paste=!1,lQ.raw=e;let c=lQ,l=``;if(a&&i)l=i;else if(!c.upArrow&&!c.downArrow&&!c.leftArrow&&!c.rightArrow&&!c.pageDown&&!c.pageUp&&!c.home&&!c.end&&!c.return&&!c.escape&&!c.tab&&!c.backspace&&!c.delete){let t=NMe(e);t===void 0?e.length===1?l=e:i.length===1&&(l=i):l=t}r.current(l,{...c})})},[t.isActive,n])},wPe=()=>{let e=(0,X.use)(wZ);if(!e)throw Error(`useApp must be used within a jar render context`);return{exit:e.exit,requestFullRedraw:e.requestFullRedraw}},dQ=e=>{let t=(0,cQ.c)(23),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{isActive:r,autoFocus:i,id:a}=n,o=r===void 0?!0:r,s=i===void 0?!1:i,{activeId:c,add:l,remove:u,activate:d,deactivate:f,focus:p}=(0,X.use)(xZ),m;t[2]===a?m=t[3]:(m=a??Math.random().toString().slice(2,7),t[2]=a,t[3]=m);let h=m,g;t[4]!==l||t[5]!==s||t[6]!==h||t[7]!==u?(g=()=>(l(h,{autoFocus:s}),()=>{u(h)}),t[4]=l,t[5]=s,t[6]=h,t[7]=u,t[8]=g):g=t[8];let _;t[9]!==s||t[10]!==h?(_=[h,s],t[9]=s,t[10]=h,t[11]=_):_=t[11],(0,X.useEffect)(g,_);let v;t[12]!==d||t[13]!==f||t[14]!==h||t[15]!==o?(v=()=>{o?d(h):f(h)},t[12]=d,t[13]=f,t[14]=h,t[15]=o,t[16]=v):v=t[16];let y;t[17]!==h||t[18]!==o?(y=[o,h],t[17]=h,t[18]=o,t[19]=y):y=t[19],(0,X.useEffect)(v,y);let b=!!h&&c===h,x;return t[20]!==p||t[21]!==b?(x={isFocused:b,focus:p},t[20]=p,t[21]=b,t[22]=x):x=t[22],x};function fQ(){return(0,X.use)(SZ)}const pQ=()=>{let e=(0,X.use)(TZ);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},mQ=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function TPe(){return new RegExp(mQ.source,`g`)}function EPe(e){return e.replace(mQ,``)}function DPe(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function hQ(e){return`\x1B]2;`+DPe(e)+`\x07`}var gQ=G(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.5.1-canary.7`,private:!0,bin:{abacusai:`dist/index.mjs`},files:[`dist`,`LICENSE.txt`],type:`module`,scripts:{"prepare-publish":`bun ./scripts/prepare-publish.ts`,build:`tsdown`,"check-types":`tsgo -b --noEmit`,test:`FORCE_COLOR=1 vitest run`,"test:watch":`FORCE_COLOR=1 vitest`,"test:ui":`FORCE_COLOR=1 vitest --ui`,"test:coverage":`FORCE_COLOR=1 vitest run --coverage`},dependencies:{"@clack/prompts":`^0.11.0`,"@codellm/agent":`workspace:*`,"@codellm/api":`workspace:*`,"@codellm/auth":`workspace:*`,"@codellm/comms":`workspace:*`,"@codellm/jar":`workspace:*`,"@codellm/logging":`workspace:*`,"@codellm/product":`workspace:*`,"@logtape/logtape":`catalog:`,"@orpc/client":`catalog:`,"@orpc/contract":`catalog:`,"@orpc/server":`catalog:`,"@sentry/node-core":`catalog:`,"@slack/web-api":`^7.0.0`,"@tanstack/react-query":`catalog:`,"@vscode/ripgrep":`catalog:`,"ansi-styles":`catalog:`,"beautiful-mermaid":`^1.1.3`,"cli-boxes":`catalog:`,"cli-highlight":`^2.1.11`,conf:`catalog:`,diff:`catalog:`,fzf:`catalog:`,"gradient-string":`^3.0.0`,immer:`catalog:`,"isomorphic-git":`catalog:`,marked:`^17.0.6`,"node-notifier":`catalog:`,"patchright-core":`catalog:`,react:`catalog:react`,"react-compiler-runtime":`^1.0.0`,remend:`^1.3.0`,semver:`catalog:`,"shell-history":`^2.0.1`,"string-width":`catalog:`,"strip-ansi":`catalog:`,trash:`catalog:`,zod:`catalog:`},devDependencies:{"@babel/core":`catalog:infra`,"@codellm/configs":`workspace:*`,"@playwright/mcp":`^0.0.68`,"@rolldown/plugin-babel":`catalog:infra`,"@types/diff":`^8.0.0`,"@types/node":`catalog:`,"@types/react":`catalog:react`,"@types/semver":`^7.7.1`,"@typescript/native-preview":`catalog:infra`,"@vitejs/plugin-react":`catalog:infra`,"@vitest/coverage-v8":`^4.1.5`,"@vitest/ui":`^4.1.5`,"@xterm/addon-serialize":`^0.14.0`,"@xterm/headless":`^6.0.0`,"babel-plugin-react-compiler":`catalog:infra`,"cli-testing-library":`^3.0.1`,jsdom:`^27.4.0`,"react-devtools-core":`^6.1.5`,"svg-term-cli":`^2.1.1`,tsdown:`catalog:infra`,vite:`catalog:infra`,vitest:`catalog:infra`,zigpty:`^0.1.6`},engines:{node:`>=18`}}})),_Q=$e(gQ(),1);let vQ=null;function yQ(e){let t=(0,lY.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function bQ(e){if(!e)return``;try{return T(e)}catch{return e}}function xQ(){return{invokedPath:bQ(process.argv[1]??``),execPath:bQ(process.execPath??process.argv[0]??``)}}function SQ(e){let t=hn.configDirName.replace(/^\./,``).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`[/\\\\]\\.?${t}[/\\\\]bin[/\\\\]`,`i`).test(e)}function CQ(e){return/[/\\]node_modules[/\\]/.test(e)||/[/\\]\._npx[/\\]/.test(e)||/[/\\]_npx[/\\]/.test(e)||/[/\\]\.?npm[/\\]/.test(e)||/[/\\]\.?pnpm[/\\]/.test(e)||/[/\\]\.?yarn[/\\]/.test(e)||/[/\\]\.bun[/\\]/.test(e)}function wQ(){let e=(process.env.npm_command??``).toLowerCase();if(e===`exec`||e===`dlx`)return!0;let{invokedPath:t,execPath:n}=xQ();return/[/\\]_npx[/\\]|[/\\]dlx[/\\]|[/\\]\.cache[/\\]/.test(t+`|`+n)}function TQ(){let e=process.env.npm_config_user_agent;if(e){let t=e.split(`/`)[0];if(t===`yarn`||t===`pnpm`||t===`bun`||t===`npm`)return t}let{invokedPath:t,execPath:n}=xQ(),r=`${t}|${n}`;return/[/\\]\.?yarn[/\\]/.test(r)?`yarn`:/[/\\]\.?pnpm[/\\]/.test(r)?`pnpm`:/[/\\]\.bun[/\\]/.test(r)||process.versions.bun!==void 0&&!SQ(n)?`bun`:`npm`}function OPe(){let{execPath:e,invokedPath:t}=xQ();return CQ(t)||CQ(e)?!1:SQ(e)||SQ(t)}function EQ(){let e=`${hn.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let{invokedPath:n,execPath:r}=xQ();return!(SQ(r)||SQ(n)||CQ(n)||CQ(r)||process.env.npm_config_user_agent)}function kPe(){let{execPath:e}=xQ(),t=TQ(),n=wQ();return EQ()?{installationType:`development`,packageManager:t,isEphemeral:n,execPath:e}:OPe()?{installationType:`native`,packageManager:t,isEphemeral:n,execPath:e}:{installationType:`package-manager`,packageManager:t,isEphemeral:n,execPath:e}}function APe(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}async function jPe(e){let t=Date.now();if(vQ&&t-vQ.timestamp<6e4)return vQ.tags;let n=await fetch(`https://registry.npmjs.org/${e}`,{signal:AbortSignal.timeout(1e4),headers:{accept:`application/json`}});if(!n.ok)throw Error(`Registry returned ${n.status}`);let r=(await n.json())[`dist-tags`]??{};return vQ={tags:r,timestamp:t},r}async function MPe(e,t,n,r){let i=t??yQ(e),a=(r??`https://apps.abacus.ai`).replace(/\/$/,``),o=new URL(`${a}/api/v0/_getCodellmCliVersion`);o.searchParams.set(`channel`,i),n&&o.searchParams.set(`platform`,n),o.searchParams.set(`cli_version`,e);let s=await fetch(o.toString(),{signal:AbortSignal.timeout(1e4)});if(s.status===204)return null;if(!s.ok)throw Error(`API returned ${s.status}`);let c=await s.json(),l=c&&`result`in c&&c.result?c.result:c??{};if(!l.version||!l.channel)throw Error(`API returned invalid payload`);return{currentVersion:e,latestVersion:l.version,tag:l.channel,packageManager:TQ(),isEphemeral:wQ(),installationType:`native`,downloadUrl:l.url}}async function NPe(e,t){let n=t??yQ(e),r=TQ(),i=wQ(),a=(await jPe(gn.publishName))[n];return!a&&n!==`latest`||!a||a===e?null:{currentVersion:e,latestVersion:a,tag:n,packageManager:r,isEphemeral:i,installationType:`package-manager`}}async function DQ(e,t,n,r){let i=kPe();if(i.installationType===`native`)try{return await MPe(e,t,APe(),n)}catch{return null}return i.installationType===`development`&&!r?.includeDev?null:await NPe(e,t)}function OQ(e){if(e.installationType===`native`)return`${hn.binName} upgrade`;let t=`${gn.publishName}@${e.tag}`;switch(e.packageManager){case`yarn`:return`yarn global add ${t}`;case`pnpm`:return`pnpm add -g ${t}`;case`bun`:return`bun add -g ${t}`;default:return`npm install -g ${t}`}}function kQ(e){try{return{ok:!0,output:le(OQ(e),{stdio:`pipe`,encoding:`utf-8`}).trim()}}catch(e){return{ok:!1,output:e instanceof Error&&`stderr`in e?String(e.stderr).trim():e instanceof Error?e.message:`Unknown error`}}}function PPe(){let e=N.join(t.homedir(),hn.configDirName,`bin`);try{let n=N.dirname(bQ(process.execPath));return!n||n.toLowerCase().startsWith(t.tmpdir().toLowerCase())?e:n}catch{return e}}async function AQ(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let n=N.join(t.tmpdir(),`abacusai-update-${Date.now()}`),r=process.platform===`win32`,i=r?`${hn.binName}.exe`:hn.binName,a=PPe();try{await we.mkdir(n,{recursive:!0}),await we.mkdir(a,{recursive:!0});let t=N.join(n,r?`update.zip`:`update.tar.gz`),o=await fetch(e.downloadUrl);if(!o.ok)throw Error(`Download failed: ${o.status}`);let s=Buffer.from(await o.arrayBuffer());await we.writeFile(t,s),le(r?`powershell -Command "Expand-Archive -Path '${t}' -DestinationPath '${n}' -Force"`:`tar -xzf "${t}" -C "${n}"`,{stdio:`pipe`});let c=N.join(n,i),l=N.join(a,i);if(r){let e=`${l}.old`;await we.rm(e,{force:!0}).catch(()=>{}),await we.rename(l,e).catch(()=>{}),await we.copyFile(c,l),await we.rm(e,{force:!0}).catch(()=>{})}else await we.copyFile(c,l),await we.chmod(l,493);return{ok:!0,output:`Updated to ${e.latestVersion}`}}catch(e){return{ok:!1,output:e instanceof Error?e.message:`Unknown error`}}finally{await we.rm(n,{recursive:!0,force:!0}).catch(()=>{})}}function FPe(e,t){let n=e=>{let n=e.toLowerCase();if(n===t)return 1e3;if(n.startsWith(t))return 900;let r=0,i=-1;for(let e of t){let t=n.indexOf(e,i+1);if(t===-1)return 0;r+=100-(t-i),i=t}return r+=Math.max(0,50-n.length),r},r=null,i=0;for(let t of e){let e=Math.max(n(t.name??``),n(t.llmName));e>i&&(i=e,r=t.llmName)}return i>=100?r:null}async function jQ(e,t,n=nt.CLI){let r=(await e.listLLMModels({coworkV2:n===nt.COWORK}))?.result??[];return r.length||(process.stderr.write(`Error: No models available.
75182
75182
  `),process.exit(1)),t?FPe(r,t.toLowerCase())||(process.stderr.write(`Warning: Model "${t}" not found. Using default: ${r[0].llmName}\n`),r[0].llmName):r[0].llmName}const MQ=dt([`codellm`,`cli`,`exit`]),NQ=new Set,PQ=new Set,FQ=new Set;let IQ=!1,LQ=!1,RQ=null,zQ;async function IPe(e){let t=e.map(e=>new Promise(t=>{let n=`writableLength`in e?e.writableLength:0;if((`bufferSize`in e?e.bufferSize:n)===0){t();return}let r=e.write.bind(e),i=!1,a=()=>{let n=`writableLength`in e?e.writableLength:0;(`bufferSize`in e?e.bufferSize:n)===0&&!i&&(i=!0,e.write=r,t())};e.once(`drain`,a),e.write(``,`utf-8`,()=>{a()}),e.write=function(){return!1}}));await Promise.all(t)}async function BQ(e,t,n,r){if(IQ)return;r?.debug?.(`Executing exit handlers`,{shouldManuallyExit:e,isSynchronous:t,signal:n,asyncCallbacks:NQ.size,syncCallbacks:PQ.size}),IQ=!0,NQ.size>0&&t&&MQ.error`SYNCHRONOUS TERMINATION NOTICE: When explicitly exiting the process via process.exit or via a parent process, asynchronous tasks in your exitHooks will not run. Either remove these tasks, use gracefulExit() instead of process.exit(), or ensure your parent process sends a SIGINT to the process running this code.`;let i=0;n>0?i=128+n:zQ===void 0?(typeof H.exitCode==`number`||typeof H.exitCode==`string`)&&(i=Number(H.exitCode)):i=zQ;let a=(t=!1)=>{(t||e)&&(RQ?RQ.call(H,i):H.exit(i))};for(let e of PQ)try{e(i)}catch(e){MQ.error`Error in synchronous exit hook: ${e}`}if(t){a();return}let o=[],s=0;for(let[e,t]of NQ)s=Math.max(s,t),o.push(Promise.resolve(e(i)).catch(e=>{MQ.error`Error in asynchronous exit hook: ${e}`}));let c=Array.from(FQ);c.length>0&&o.push(IPe(c));let l=setTimeout(()=>{a(!0)},s);try{await Promise.all(o),clearTimeout(l),a()}catch(e){clearTimeout(l),MQ.error`Error during exit cleanup: ${e}`,a(!0)}}function LPe(){LQ||(LQ=!0,H.once(`beforeExit`,()=>{BQ(!0,!1,-128)}),H.once(`SIGINT`,()=>{BQ(!0,!1,2)}),H.once(`SIGTERM`,()=>{BQ(!0,!1,15)}),H.once(`exit`,()=>{BQ(!1,!0,0)}),H.on(`message`,e=>{e===`shutdown`&&BQ(!0,!0,-128)}),RQ||(RQ=H.exit.bind(H),H.exit=function(e){if(zQ===void 0&&(zQ=e??0),NQ.size===0&&FQ.size===0){if(RQ){RQ(e??0);return}H.exit(e??0)}BQ(!0,!1,-128).catch(e=>{MQ.error`Error during exit: ${e}`,RQ?RQ(1):H.exit(1)})}))}function VQ(e,t){if(typeof e!=`function`)throw TypeError(`callback must be a function`);if(IQ)throw Error(`Cannot install exit hook while exit handlers are running`);t?.logger?.debug?.(`Registering exit hook`,{wait:t?.wait,hasStreams:t?.streams!==void 0}),LPe();let n=t?.wait??0,r=t?.streams??[H.stdout,H.stderr];if(n>0){let t=[e,n];NQ.add(t);for(let e of r)FQ.add(e);return()=>{NQ.delete(t);for(let e of r)FQ.delete(e)}}return PQ.add(e),()=>{PQ.delete(e)}}function HQ(e){e!==void 0&&(H.exitCode=e),BQ(!0,!1,-128)}function UQ(e){process.stdout.write(JSON.stringify(e)+`
75183
75183
  `)}function RPe(e){try{return JSON.parse(e)}catch{return null}}async function zPe({agentArgs:e}){hu(`ndjson IPC host started`,`cli`);let t=await SY.create(),n=new Ou(t,Sn(),gn.userAgentNames.desktop,_Q.default.version);if(!t.isAuthenticated())try{(await n.getUserInfo())?.result?.email||(process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
75184
75184
  `),process.exit(1))}catch{process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
75185
75185
  `),process.exit(1)}let r=process.cwd(),i=new rJ({cwd:r,extraSources:[{read:async()=>({client:nt.CLI})}]});await i.load();let a=i.get(`baseUrl`);if(a){try{new URL(a)}catch{process.stderr.write(`Invalid baseUrl: ${a}\n`),process.exit(1)}n.setUrl(a),n.resetEndpoints(),await n.getApiEndpoint()}let o=await jQ(n,e?.model,i.get(`client`)),s=new Map,c=0,l=new eJ(async e=>{let t=`perm-${++c}`;return UQ({type:`permission_needed`,permissionId:t,request:e}),new Promise(e=>{s.set(t,{resolve:e})})}),u=Rd.Normal,d=e?.[`permission-mode`];if(d)switch(d){case`normal`:u=Rd.Normal;break;case`accept-edits`:u=Rd.AcceptEdits;break;case`plan`:u=Rd.PlanMode;break;case`yolo`:u=Rd.Yolo;break}let f=new $q({allowedDirectories:[r,...e?.[`add-dir`]?.map(e=>P.isAbsolute(e)?e:P.resolve(r,e))??[]],primaryWorkspace:r,apiClient:n,mode:u,model:o,permissionProvider:l,config:i,isPrintMode:!1,enablePromptRewrite:!1,supportsThoughtStreaming:!0,enableSkills:!0,cliAllowedTools:e?.[`allowed-tools`],cliDisallowedTools:e?.[`disallowed-tools`]});f.onAutoRestart=e=>{WQ(f,e)},VQ(async()=>{f.stop(),await new Promise(e=>setTimeout(e,200))},{wait:1e3}),UQ({type:`ready`,model:o,mode:u});let p=Jq.loadSkills(r).then(()=>{UQ({type:`skills_loaded`,skills:Jq.getAllMetadata()})}).catch(e=>{fu(e),process.stderr.write(`Failed to load skills: ${e}\n`)}),m=i.get(`autoUpdate`)!==!1;EQ()||DQ(_Q.default.version,i.get(`updateChannel`),i.get(`baseUrl`)).then(async e=>{if(!e||(UQ({type:`update_available`,currentVersion:e.currentVersion,latestVersion:e.latestVersion}),!m))return;UQ({type:`update_downloading`,latestVersion:e.latestVersion});let t=e.installationType===`native`?await AQ(e):kQ(e);t.ok?UQ({type:`update_complete`,latestVersion:e.latestVersion}):UQ({type:`update_failed`,latestVersion:e.latestVersion,error:t.output||`Update failed`})}).catch(e=>{fu(e)});let h=B.createInterface({input:process.stdin});h.on(`line`,async e=>{let t=e.trim();if(!t)return;let r=RPe(t);if(r)switch(r.type){case`send`:{let e=r.message??``,t=r.conversationId,n=Array.isArray(r.activeSkills)?r.activeSkills:void 0;t&&f.getConversationId()!==t&&await f.switchConversation(t),WQ(f,e,n);break}case`stop`:f.stop();break;case`list_skills`:p.then(()=>{UQ({type:`skills_loaded`,skills:Jq.getAllMetadata()})});break;case`switch_conversation`:{let e=r.conversationId;e&&(f.switchConversation(e),UQ({type:`event`,event:{type:`status_changed`,status:`idle`}}));break}case`reset_conversation`:f.resetConversation(),UQ({type:`event`,event:{type:`status_changed`,status:`idle`}});break;case`set_mode`:{let e=BPe(r.mode??`DEFAULT`);f.setMode(e);break}case`set_model`:{let e=r.model;if(e){let t=await jQ(n,e,i.get(`client`));f.setModel(t),UQ({type:`event`,event:{type:`model_changed`,model:t}})}break}case`set_folder`:{let e=r.folder;e&&f.setWorkspace(e);break}case`enqueue`:{let e=r.message??``,t=r.hidden??!1;f.nq(e,{hidden:t}),UQ({type:`queue_updated`,messages:f.getQueueEntries()});break}case`dequeue`:{let e=r.includeHidden??!1,t=r.id,n=f.dq({includeHidden:e,...t?{id:t}:{}});UQ({type:`queue_updated`,messages:f.getQueueEntries(),dequeued:n.map(e=>e.message)});break}case`get_queue`:{let e=r.includeHidden??!1;UQ({type:`queue_updated`,messages:f.getQueueEntries({includeHidden:e})});break}case`clear_queue`:{let e=r.includeHidden??!1;f.clearQueue({includeHidden:e}),UQ({type:`queue_updated`,messages:f.getQueueEntries()});break}case`remove_from_queue`:{let e=r.id,t=r.index;if(e)f.remove(e,{includeHidden:!0});else if(typeof t==`number`){let e=f.getQueueEntries()[t];e&&f.remove(e.id)}UQ({type:`queue_updated`,messages:f.getQueueEntries()});break}case`permission_response`:{let e=r.permissionId,t=r.decision,n=s.get(e);n&&(n.resolve(t),s.delete(e));break}}}),h.on(`close`,()=>{process.exit(0)})}async function WQ(e,t,n){try{for await(let r of e.send(t,{activeSkills:n}))UQ({type:`event`,event:r})}catch(e){fu(e),UQ({type:`event`,event:{type:`error`,error:{message:e instanceof Error?e.message:String(e)}}})}}function BPe(e){switch(e){case`DEFAULT`:return Rd.Normal;case`ACCEPTEDITS`:return Rd.AcceptEdits;case`PLAN`:return Rd.PlanMode;case`YOLO`:return Rd.Yolo;default:return Rd.Normal}}const VPe=dt([`codellm`,`cli`,`print-mode`]);async function HPe(){let e=await SY.create();return{apiClient:new Ou(e,Sn(),gn.userAgentNames.print,_Q.default.version),authManager:e}}function GQ(e){process.stdout.write(JSON.stringify(e)+`
75186
- `)}async function UPe(e,t){if(e?.resume)return e.resume;if(e?.continue)try{return((await t.getConversationsList(hn.nonInteractiveAgentType))?.result??[]).sort((e,t)=>{let n=e.lastEventCreatedAt?new Date(e.lastEventCreatedAt).getTime():0;return(t.lastEventCreatedAt?new Date(t.lastEventCreatedAt).getTime():0)-n})[0]?.deploymentConversationId}catch{}return e?.conversationId}async function WPe({agentArgs:e}){hu(`print-mode started`,`cli`);let{apiClient:t,authManager:n}=await HPe(),r=process.cwd(),i=new rJ({cwd:r,extraSources:[{read:async()=>({client:nt.CLI})}]});await i.load(),EQ()||DQ(_Q.default.version,i.get(`updateChannel`),i.get(`baseUrl`)).then(e=>{if(e){let t=e.isEphemeral?`\nUpdate available: ${e.currentVersion} → ${e.latestVersion} (${e.tag})\n`:e.installationType===`native`&&i.get(`autoUpdate`)!==!1?`\nUpdate available: ${e.currentVersion} → ${e.latestVersion} (${e.tag}). Restart to auto-update.\n`:`\nUpdate available: ${e.currentVersion} → ${e.latestVersion} (${e.tag}). Run: ${OQ(e)}\n`;process.stderr.write(t)}}).catch(e=>{fu(e)});let a=i.get(`baseUrl`);if(a){try{new URL(a)}catch{VPe.error`Invalid baseUrl: ${a}`,process.exit(1)}t.setUrl(a),t.resetEndpoints(),await t.getApiEndpoint()}!n.isAuthenticated()&&!n.isEnvAuth()&&(process.stderr.write(`Not authenticated. Set ${hn.envPrefix}API_KEY environment variable or run interactively to log in.\n`),process.exit(1));let o=e?.[`output-format`]??`text`,s=await jQ(t,e?.model),c=Rd.Yolo,l=e?.[`permission-mode`];if(l)switch(l){case`normal`:c=Rd.Normal;break;case`accept-edits`:c=Rd.AcceptEdits;break;case`plan`:c=Rd.PlanMode;break;default:c=Rd.Yolo;break}let u=new $q({allowedDirectories:[r,...e?.[`add-dir`]?.map(e=>P.isAbsolute(e)?e:P.resolve(r,e))??[]],primaryWorkspace:r,apiClient:t,mode:c,model:s,permissionProvider:new mAe,config:i,isPrintMode:!0,enablePromptRewrite:!1,supportsThoughtStreaming:!0,enableSkills:!0,cliAllowedTools:e?.[`allowed-tools`],cliDisallowedTools:e?.[`disallowed-tools`]});VQ(async()=>{u.stop(),await new Promise(e=>setTimeout(e,200))},{wait:1e3});let d=await UPe(e,t);if(d)try{let e=await u.loadConversation(d);e.llmName&&(s=e.llmName,u.setModel(e.llmName))}catch(e){throw fu(e),e}let f=e?.prompt??``;process.env.DEEPAGENT_HIGH_QUALITY===`true`&&(f=`
75186
+ `)}async function UPe(e,t){if(e?.resume)return e.resume;if(e?.continue)try{return((await t.getConversationsList(hn.nonInteractiveAgentType))?.result??[]).sort((e,t)=>{let n=e.lastEventCreatedAt?new Date(e.lastEventCreatedAt).getTime():0;return(t.lastEventCreatedAt?new Date(t.lastEventCreatedAt).getTime():0)-n})[0]?.deploymentConversationId}catch{}return e?.conversationId}async function WPe({agentArgs:e}){hu(`print-mode started`,`cli`);let{apiClient:t,authManager:n}=await HPe(),r=process.cwd(),i=new rJ({cwd:r,extraSources:[{read:async()=>({client:nt.CLI})}]});await i.load(),EQ()||DQ(_Q.default.version,i.get(`updateChannel`),i.get(`baseUrl`)).then(e=>{if(e){let t=e.isEphemeral?`\nUpdate available: ${e.currentVersion} → ${e.latestVersion} (${e.tag})\n`:e.installationType===`native`&&i.get(`autoUpdate`)!==!1?`\nUpdate available: ${e.currentVersion} → ${e.latestVersion} (${e.tag}). Restart to auto-update.\n`:`\nUpdate available: ${e.currentVersion} → ${e.latestVersion} (${e.tag}). Run: ${OQ(e)}\n`;process.stderr.write(t)}}).catch(e=>{fu(e)});let a=i.get(`baseUrl`);if(a){try{new URL(a)}catch{VPe.error`Invalid baseUrl: ${a}`,process.exit(1)}t.setUrl(a),t.resetEndpoints(),await t.getApiEndpoint()}!n.isAuthenticated()&&!n.isEnvAuth()&&(process.stderr.write(`Not authenticated. Set ${hn.envPrefix}API_KEY environment variable or run interactively to log in.\n`),process.exit(1));let o=e?.[`output-format`]??`text`,s=await jQ(t,e?.model,i.get(`client`)),c=Rd.Yolo,l=e?.[`permission-mode`];if(l)switch(l){case`normal`:c=Rd.Normal;break;case`accept-edits`:c=Rd.AcceptEdits;break;case`plan`:c=Rd.PlanMode;break;default:c=Rd.Yolo;break}let u=new $q({allowedDirectories:[r,...e?.[`add-dir`]?.map(e=>P.isAbsolute(e)?e:P.resolve(r,e))??[]],primaryWorkspace:r,apiClient:t,mode:c,model:s,permissionProvider:new mAe,config:i,isPrintMode:!0,enablePromptRewrite:!1,supportsThoughtStreaming:!0,enableSkills:!0,cliAllowedTools:e?.[`allowed-tools`],cliDisallowedTools:e?.[`disallowed-tools`]});VQ(async()=>{u.stop(),await new Promise(e=>setTimeout(e,200))},{wait:1e3});let d=await UPe(e,t);if(d)try{let e=await u.loadConversation(d);e.llmName&&(s=e.llmName,u.setModel(e.llmName))}catch(e){throw fu(e),e}let f=e?.prompt??``;process.env.DEEPAGENT_HIGH_QUALITY===`true`&&(f=`
75187
75187
  IMPORTANT INSTRUCTIONS: Your task is to follow the <task_description> EXACTLY and verify the solution within the FIXED TIME LIMIT.
75188
75188
  A few things to keep in mind (Add Relevant ONES BELOW AS TODOS):
75189
75189
  1. You are in a docker container without user interaction and fixed time limit. Assume HIGHEST permissions are available to the user.
@@ -75281,10 +75281,10 @@ https://github.com/highlightjs/highlight.js/issues/2277`),a=e,i=t);let o={code:i
75281
75281
  `,`utf8`)}function S3(e){let t=[],n=0;for(let r=0;r<e.length;r++)if(e[r]===10){let i=e.subarray(n,r).toString(`utf8`).trim();i&&t.push(i),n=r+1}return[t,e.subarray(n)]}function XUe(e,t){let n=RUe(t,{});try{p.existsSync(e)&&p.unlinkSync(e)}catch{}let r=V.createServer(e=>{let t=new JUe(t=>{!e.destroyed&&e.writable&&e.write(x3(t))}),r=Buffer.alloc(0);e.on(`data`,async e=>{r=Buffer.concat([r,e]);let[i,a]=S3(r);r=a;for(let e of i)try{await t.message(e,n)}catch(e){fu(e,{context:`rpc-deserialization`})}}),e.on(`close`,()=>{t.close()}),e.on(`error`,n=>{fu(n,{context:`socket-server`}),e.destroy(),t.close()})});return new Promise((t,n)=>{r.on(`error`,e=>{fu(e,{context:`socket-server`}),n(e)}),r.listen(e,()=>{r.removeListener(`error`,n),r.on(`error`,e=>{fu(e,{context:`socket-server`})});try{p.chmodSync(e,438)}catch{}t({getSocketPath:()=>e,dispose:()=>{r.close();try{p.existsSync(e)&&p.unlinkSync(e)}catch{}}})})})}var ZUe=class{peer;constructor(e){this.peer=e}async call(e){let t=await this.peer.request(e);return{...t,body:()=>Promise.resolve(t.body)}}},QUe=class extends MUe{constructor(e){super(new ZUe(e),{url:`orpc:/`})}};function $Ue(e,t){let n=t?.timeoutMs??2e3;return new Promise((t,r)=>{let i=V.connect(e),a=setTimeout(()=>{i.destroy(),r(Error(`Connection to ${e} timed out after ${n}ms`))},n);i.on(`connect`,()=>{clearTimeout(a);let e=new KUe(e=>{!i.destroyed&&i.writable&&i.write(x3(e))}),n=Buffer.alloc(0);i.on(`data`,async t=>{n=Buffer.concat([n,t]);let[r,i]=S3(n);n=i;for(let t of r)try{await e.message(t)}catch(e){fu(e,{context:`rpc-deserialization`})}}),i.on(`close`,()=>e.close()),i.on(`error`,t=>{fu(t,{context:`socket-client`}),i.destroy(),e.close()}),t({link:new QUe(e),dispose:()=>{e.close(),i.destroy()}})}),i.on(`error`,e=>{clearTimeout(a),fu(e,{context:`socket-connect`}),r(e)})})}const C3=Symbol(`ORPC_LAZY_SYMBOL`);function w3(e,t={}){return{[C3]:{loader:e,meta:t}}}function T3(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&C3 in e}function E3(e){return e[C3].meta}function D3(e){return T3(e)?e[C3].loader():Promise.resolve({default:e})}function eWe(e,t){if(t.length>e.length)return!1;for(let n=0;n<e.length;n++){if(t[n]===void 0)return!0;if(e[n]!==t[n])return!1}return!0}function tWe(e,t,n){return n.dedupeLeading&&eWe(t,e)?t:[...e,...t]}function O3(e,t){return[...e,t]}var k3=class{"~orpc";constructor(e){this[`~orpc`]=e}};function A3(e){return e instanceof k3?!0:e3(e)&&`middlewares`in e[`~orpc`]&&`inputValidationIndex`in e[`~orpc`]&&`outputValidationIndex`in e[`~orpc`]&&`handler`in e[`~orpc`]}function nWe(e,t){return{...e,...t}}function rWe(e){return new Proxy(e,{get(t,n){return typeof n==`string`?(...t)=>{let r=f4(t),i=e[n];return new I4(n,{defined:!!i,status:i?.status,message:r.message??i?.message,data:r.data,cause:r.cause})}:Reflect.get(t,n)}})}function iWe(e){return{output:e,context:{}}}function j3(e,...t){let n=f4(t);return async(...[t,r])=>{let i=p4(n.path),{default:a}=await D3(e),o=r?.context??{},s=await A4(n.context??{},o),c=rWe(a[`~orpc`].errorMap),l=async e=>e instanceof I4?await TUe(a[`~orpc`].errorMap,e):e;try{let e=await y4({name:`call_procedure`,signal:r?.signal},e=>(e?.setAttribute(`procedure.path`,[...i]),T4(p4(n.interceptors),{context:s,input:t,errors:c,path:i,procedure:a,signal:r?.signal,lastEventId:r?.lastEventId},e=>sWe(e.procedure,e))));return S4(e)?e instanceof K4?e:hUe(e,Y4(w4({name:`consume_event_iterator_output`,signal:r?.signal},e),{value:e=>e,error:e=>l(e)})):e}catch(e){throw await l(e)}}}async function aWe(e,t){let n=e[`~orpc`].inputSchema;return n?y4({name:`validate_input`},async()=>{let e=await n[`~standard`].validate(t);if(e.issues)throw new I4(`BAD_REQUEST`,{message:`Input validation failed`,data:{issues:e.issues},cause:new Z4({message:`Input validation failed`,issues:e.issues,data:t})});return e.value}):t}async function oWe(e,t){let n=e[`~orpc`].outputSchema;return n?y4({name:`validate_output`},async()=>{let e=await n[`~standard`].validate(t);if(e.issues)throw new I4(`INTERNAL_SERVER_ERROR`,{message:`Output validation failed`,cause:new Z4({message:`Output validation failed`,issues:e.issues,data:t})});return e.value}):t}async function sWe(e,t){let n=e[`~orpc`].middlewares,r=Math.min(Math.max(0,e[`~orpc`].inputValidationIndex),n.length),i=Math.min(Math.max(0,e[`~orpc`].outputValidationIndex),n.length),a=async(o,s,c)=>{let l=c;o===r&&(l=await aWe(e,l));let u=n[o],d=u?await y4({name:`middleware.${u.name}`,signal:t.signal},async e=>(e?.setAttribute(`middleware.index`,o),e?.setAttribute(`middleware.name`,u.name),(await u({...t,context:s,next:async(...[e])=>{let t=e?.context??{};return{output:await a(o+1,nWe(s,t),l),context:t}}},l,iWe)).output)):await y4({name:`handler`,signal:t.signal},()=>e[`~orpc`].handler({...t,context:s,input:l}));return o===i?await oWe(e,d):d};return a(0,t.context,t.input)}const M3=Symbol(`ORPC_HIDDEN_ROUTER_CONTRACT`);function N3(e,t){return new Proxy(e,{get(e,n){return n===M3?t:Reflect.get(e,n)}})}function cWe(e){return e[M3]}function P3(e,t){let n=e;for(let e=0;e<t.length;e++){let r=t[e];if(!n||A3(n))return;if(!T3(n)){n=n[r];continue}let i=n,a=t.slice(e);return w3(async()=>D3(P3((await D3(i)).default,a)),E3(i))}return n}function F3(e){return new Proxy(e,{get(t,n){return typeof n==`string`?F3(P3(e,[n])):Reflect.get(t,n)}})}function I3(e,t){if(T3(e)){let n=E3(e),r=n?.prefix?s3(t.prefix,n?.prefix):t.prefix;return F3(w3(async()=>{let{default:n}=await D3(e);return D3(I3(n,t))},{...n,prefix:r}))}if(A3(e)){let n=tWe(t.middlewares,e[`~orpc`].middlewares,{dedupeLeading:t.dedupeLeadingMiddlewares}),r=n.length-e[`~orpc`].middlewares.length;return new k3({...e[`~orpc`],route:l3(e[`~orpc`].route,t),errorMap:Q4(t.errorMap,e[`~orpc`].errorMap),middlewares:n,inputValidationIndex:e[`~orpc`].inputValidationIndex+r,outputValidationIndex:e[`~orpc`].outputValidationIndex+r})}let n={};for(let r in e)n[r]=I3(e[r],t);return n}function L3(e,t,n=[]){let r=e.router,i=cWe(e.router);if(i!==void 0&&(r=i),T3(r))n.push({router:r,path:e.path});else if(e3(r))t({contract:r,path:e.path});else for(let i in r)L3({router:r[i],path:[...e.path,i]},t,n);return n}function lWe(e,t){return new k3({...e[`~orpc`],errorMap:t[`~orpc`].errorMap,route:t[`~orpc`].route,meta:t[`~orpc`].meta})}const uWe={initialInputValidationIndex:0,initialOutputValidationIndex:0,dedupeLeadingMiddlewares:!0};function R3(e,t){return t===void 0?uWe[e]:t}function z3(e){let t=((...t)=>e(...t));return t.mapInput=t=>z3((n,r,...i)=>e(n,t(r),...i)),t.concat=(t,n)=>{let r=n?z3(t).mapInput(n):t;return z3((t,n,i,...a)=>e({...t,next:(...[e])=>r({...t,context:{...t.context,...e?.context},next:(...[n])=>t.next({context:{...e?.context,...n?.context}})},n,i,...a)},n,i,...a))},t}function dWe(e){return async t=>{try{return[null,await e(t)]}catch(e){if(e instanceof Error&&`digest`in e&&typeof e.digest==`string`&&e.digest.startsWith(`NEXT_`)||e instanceof Response&&`options`in e&&D4(e.options)||D4(e)&&e.isNotFound===!0)throw e;return[L4(e).toJSON(),void 0]}}}var fWe=class e extends k3{errors(t){return new e({...this[`~orpc`],errorMap:Q4(this[`~orpc`].errorMap,t)})}meta(t){return new e({...this[`~orpc`],meta:a3(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:o3(this[`~orpc`].route,t)})}use(t,n){let r=n?z3(t).mapInput(n):t;return new e({...this[`~orpc`],middlewares:O3(this[`~orpc`].middlewares,r)})}callable(...e){let t=j3(this,...e);return new Proxy(t,{get:(e,t)=>Reflect.has(this,t)?Reflect.get(this,t):Reflect.get(e,t),has:(e,t)=>Reflect.has(this,t)||Reflect.has(e,t)})}actionable(...e){let t=dWe(j3(this,...e));return new Proxy(t,{get:(e,t)=>Reflect.has(this,t)?Reflect.get(this,t):Reflect.get(e,t),has:(e,t)=>Reflect.has(this,t)||Reflect.has(e,t)})}},B3=class e{"~orpc";constructor(e){this[`~orpc`]=e}$config(t){let n=this[`~orpc`].inputValidationIndex-R3(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex),r=this[`~orpc`].outputValidationIndex-R3(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex);return new e({...this[`~orpc`],config:t,dedupeLeadingMiddlewares:R3(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares),inputValidationIndex:R3(`initialInputValidationIndex`,t.initialInputValidationIndex)+n,outputValidationIndex:R3(`initialOutputValidationIndex`,t.initialOutputValidationIndex)+r})}$context(){return new e({...this[`~orpc`],middlewares:[],inputValidationIndex:R3(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex),outputValidationIndex:R3(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex)})}$meta(t){return new e({...this[`~orpc`],meta:t})}$route(t){return new e({...this[`~orpc`],route:t})}$input(t){return new e({...this[`~orpc`],inputSchema:t})}middleware(e){return z3(e)}errors(t){return new e({...this[`~orpc`],errorMap:Q4(this[`~orpc`].errorMap,t)})}use(t,n){let r=n?z3(t).mapInput(n):t;return new e({...this[`~orpc`],middlewares:O3(this[`~orpc`].middlewares,r)})}meta(t){return new e({...this[`~orpc`],meta:a3(this[`~orpc`].meta,t)})}route(t){return new e({...this[`~orpc`],route:o3(this[`~orpc`].route,t)})}input(t){return new e({...this[`~orpc`],inputSchema:t,inputValidationIndex:R3(`initialInputValidationIndex`,this[`~orpc`].config.initialInputValidationIndex)+this[`~orpc`].middlewares.length})}output(t){return new e({...this[`~orpc`],outputSchema:t,outputValidationIndex:R3(`initialOutputValidationIndex`,this[`~orpc`].config.initialOutputValidationIndex)+this[`~orpc`].middlewares.length})}handler(e){return new fWe({...this[`~orpc`],handler:e})}prefix(t){return new e({...this[`~orpc`],prefix:s3(this[`~orpc`].prefix,t)})}tag(...t){return new e({...this[`~orpc`],tags:c3(this[`~orpc`].tags,t)})}router(e){return I3(e,this[`~orpc`])}lazy(e){return I3(w3(e),this[`~orpc`])}};new B3({config:{},route:{},meta:{},errorMap:{},inputValidationIndex:R3(`initialInputValidationIndex`),outputValidationIndex:R3(`initialOutputValidationIndex`),middlewares:[],dedupeLeadingMiddlewares:!0});function V3(e,t,n){return e3(e)?new B3({...e[`~orpc`],config:t,middlewares:n,inputValidationIndex:R3(`initialInputValidationIndex`,t?.initialInputValidationIndex)+n.length,outputValidationIndex:R3(`initialOutputValidationIndex`,t?.initialOutputValidationIndex)+n.length,dedupeLeadingMiddlewares:R3(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares)}):new Proxy(e,{get:(r,i)=>{if(typeof i!=`string`)return Reflect.get(r,i);let a;i===`middleware`?a=e=>z3(e):i===`use`?a=r=>V3(e,t,O3(n,r)):i===`router`?a=r=>N3(I3(r,{middlewares:n,errorMap:{},prefix:void 0,tags:void 0,dedupeLeadingMiddlewares:R3(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares)}),e):i===`lazy`&&(a=r=>N3(I3(w3(r),{middlewares:n,errorMap:{},prefix:void 0,tags:void 0,dedupeLeadingMiddlewares:R3(`dedupeLeadingMiddlewares`,t.dedupeLeadingMiddlewares)}),e));let o=FUe(r,[i]);if(!o)return a??o;let s=V3(o,t,n);return a?new Proxy(a,{get(e,t){return Reflect.get(s,t)}}):s}})}function H3(e,t={}){let n=V3(e,t,[]),r=new Proxy(n,{get:(t,n)=>{let i;n===`$context`?i=()=>r:n===`$config`&&(i=t=>H3(e,t));let a=Reflect.get(t,n);return!i||!a||typeof a!=`function`&&typeof a!=`object`?i||a:new Proxy(i,{get(e,t){return Reflect.get(a,t)}})}});return r}var pWe=class{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e,t){for(let n of this.plugins)n.init?.(e,t)}},mWe=class{constructor(e,t,n,r){this.matcher=t,this.codec=n,new pWe(r.plugins).init(r,e),this.interceptors=p4(r.interceptors),this.clientInterceptors=p4(r.clientInterceptors),this.rootInterceptors=p4(r.rootInterceptors),this.matcher.init(e)}interceptors;clientInterceptors;rootInterceptors;async handle(e,t){let n=t.prefix?.replace(/\/$/,``)||void 0;return n&&!e.url.pathname.startsWith(`${n}/`)&&e.url.pathname!==n?{matched:!1,response:void 0}:T4(this.rootInterceptors,{...t,request:e,prefix:n},async t=>y4({name:`${e.method} ${e.url.pathname}`},async e=>{let n;try{return await T4(this.interceptors,t,async({request:t,context:r,prefix:i})=>{let a=t.method,o=t.url,s=i?o.pathname.replace(i,``):o.pathname,c=await y4({name:`find_procedure`},()=>this.matcher.match(a,`/${s.replace(/^\/|\/$/g,``)}`));if(!c)return{matched:!1,response:void 0};e?.updateName(`${m4}.${c.path.join(`/`)}`),e?.setAttribute(`rpc.system`,m4),e?.setAttribute(`rpc.method`,c.path.join(`.`)),n=`decode_input`;let l=await y4({name:`decode_input`},()=>this.codec.decode(t,c.params,c.procedure));n=void 0,S4(l)&&(l=w4({name:`consume_event_iterator_input`,signal:t.signal},l));let u=j3(c.procedure,{context:r,path:c.path,interceptors:this.clientInterceptors});n=`call_procedure`;let d=await u(l,{signal:t.signal,lastEventId:q4(t.headers[`last-event-id`])});return n=void 0,{matched:!0,response:this.codec.encode(d,c.procedure)}})}catch(t){n!==`call_procedure`&&v4(e,t);let r=n===`decode_input`&&!(t instanceof I4)?new I4(`BAD_REQUEST`,{message:`Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,cause:t}):L4(t);return{matched:!0,response:this.codec.encodeError(r)}}}))}},hWe=class{constructor(e){this.serializer=e}async decode(e,t,n){let r=e.method===`GET`?uUe(e.url.searchParams.getAll(`data`).at(-1)):await e.body();return this.serializer.deserialize(r)}encode(e,t){return{status:200,headers:{},body:this.serializer.serialize(e)}}encodeError(e){return{status:e.status,headers:{},body:this.serializer.serialize(e.toJSON())}}},gWe=class{filter;tree=new fUe;pendingRouters=[];constructor(e={}){this.filter=e.filter??!0}init(e,t=[]){let n=L3({router:e,path:t},t=>{if(!A4(this.filter,t))return;let{path:n,contract:r}=t,i=r3(n);A3(r)?this.tree[i]={path:n,contract:r,procedure:r,router:e}:this.tree[i]={path:n,contract:r,procedure:void 0,router:e}});this.pendingRouters.push(...n.map(e=>({...e,httpPathPrefix:r3(e.path)})))}async match(e,t){if(this.pendingRouters.length){let e=[];for(let n of this.pendingRouters)if(t.startsWith(n.httpPathPrefix)){let{default:e}=await D3(n.router);this.init(e,n.path)}else e.push(n);this.pendingRouters=e}let n=this.tree[t];if(n){if(!n.procedure){let{default:e}=await D3(P3(n.router,n.path));if(!A3(e))throw Error(`
75282
75282
  [Contract-First] Missing or invalid implementation for procedure at path: ${r3(n.path)}.
75283
75283
  Ensure that the procedure is correctly defined and matches the expected contract.
75284
- `);n.procedure=lWe(e,n.contract)}return{path:n.path,procedure:n.procedure}}}},_We=class extends mWe{constructor(e,t={}){let n=new i3(new n3(t)),r=new gWe(t),i=new hWe(n);super(e,r,i,t)}},vWe=class{socketServer;socketPath;editorState={file:void 0,startLine:void 0,endLine:void 0};onEditorStateCallback=null;pendingDecisions=new Map;constructor(){let e=N.join(t.homedir(),hn.configDirName,`cli`);this.socketPath=N.join(e,`${process.pid}.sock`)}getEditorState(){return{...this.editorState}}onEditorChange(e){this.onEditorStateCallback=e}waitForDecision(e,t){return new Promise((n,r)=>{if(t?.aborted){r(Error(`Aborted`));return}let i=()=>{t?.removeEventListener(`abort`,a),this.pendingDecisions.delete(e)},a=()=>{i(),r(Error(`Aborted`))};t?.addEventListener(`abort`,a,{once:!0}),this.pendingDecisions.set(e,{resolve:e=>{i(),n(e)},cleanup:i})})}async start(){let e=N.dirname(this.socketPath);p.existsSync(e)||p.mkdirSync(e,{recursive:!0});let t=H3(IUe),n=t.router({editorStateChanged:t.editorStateChanged.handler(async({input:e})=>(this.editorState={file:e.file??void 0,startLine:e.startLine,endLine:e.endLine},this.onEditorStateCallback?.(this.editorState),{ok:!0})),toolDecision:t.toolDecision.handler(async({input:e})=>{let t=this.pendingDecisions.get(e.toolId);return t&&t.resolve(e.decision),{ok:!0}})});this.socketServer=await XUe(this.socketPath,new _We(n))}dispose(){for(let[,e]of this.pendingDecisions)e.cleanup();this.pendingDecisions.clear(),this.socketServer?.dispose(),this.socketServer=void 0}},yWe=class{client=null;disposeSocket=null;currentFile=void 0;selectionStartLine=void 0;selectionEndLine=void 0;onFileChangeCallback=null;constructor(e){this.pushServer=e}findSocketPath(){let e=process.env[hn.socketEnvVar];if(e&&m.existsSync(e))return e;try{let e=P.join(n.homedir(),hn.configDirName,hn.ideDirName),t=m.readdirSync(e).filter(e=>e.endsWith(`.sock`)).map(t=>P.join(e,t)).filter(e=>m.existsSync(e));if(t.length===1)return t[0]}catch{}return null}async connect(){try{let e=this.findSocketPath();if(!e)return!1;let t=await $Ue(e,{timeoutMs:2e3});this.client=X4(t.link),this.disposeSocket=()=>t.dispose(),await this.client.register({cliSocketPath:this.pushServer.socketPath,pid:process.pid});let n=this.pushServer.getEditorState();return this.currentFile=n.file,this.selectionStartLine=n.startLine,this.selectionEndLine=n.endLine,this.pushServer.onEditorChange(e=>{this.currentFile=e.file,this.selectionStartLine=e.startLine,this.selectionEndLine=e.endLine,this.onFileChangeCallback?.(e.file,e.startLine,e.endLine)}),!0}catch{return!1}}getCurrentFile(){return this.currentFile}getSelectionRange(){return{startLine:this.selectionStartLine,endLine:this.selectionEndLine}}isConnected(){return this.client!==null}onFileChange(e){this.onFileChangeCallback=e}async showDiff(e){if(!this.client)return!1;try{return(await this.client.showDiff({...e,cliSocketPath:this.pushServer.socketPath})).success}catch{return!1}}async showToolView(e){if(!this.client)return!1;try{return(await this.client.showToolView({...e,cliSocketPath:this.pushServer.socketPath})).success}catch{return!1}}async notifyDiffDecision(e){if(!this.client)throw Error(`Not connected to extension`);await this.client.notifyDiffDecision(e)}async openPlanFile(e){if(!this.client)throw Error(`Not connected to extension`);return{opened:(await this.client.openFile({file:e})).success}}async getDiagnostics(e){if(!this.client)throw Error(`Not connected to extension`);return this.client.getDiagnostics({...e&&{files:e}})}dispose(){this.disposeSocket?.(),this.disposeSocket=null,this.client=null,this.currentFile=void 0,this.selectionStartLine=void 0,this.selectionEndLine=void 0,this.onFileChangeCallback=null}};const U3=(0,X.createContext)(null);function W3(){let e=(0,X.use)(U3);if(!e)throw Error(`useExtensionFile must be used within ExtensionFileProvider`);return e}function bWe(e){let t=(0,cQ.c)(11),{children:n,initialFile:r}=e,[i,a]=(0,X.useState)(r),[o,s]=(0,X.useState)(void 0),[c,l]=(0,X.useState)(void 0),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),m=(0,X.useRef)(null),h=(0,X.useRef)(null),g,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=!1;return(async()=>{let t=new vWe;try{await t.start()}catch{}if(e){t.dispose();return}h.current=t,p(t),t.onEditorChange(e=>{a(e.file),s(e.startLine),l(e.endLine)});for(let n of[0,...[500,1e3,2e3,3e3,4e3]]){if(e||(n>0&&await new Promise(e=>setTimeout(e,n)),e))return;try{let n=new yWe(t);if(await n.connect()){if(e){n.dispose();return}let r=t.getEditorState();a(r.file),s(r.startLine),l(r.endLine),n.onFileChange((e,t,n)=>{a(e),s(t),l(n)}),m.current=n,d(n);return}}catch{}}})(),()=>{e=!0,m.current&&(m.current.dispose(),m.current=null,d(null)),h.current&&(h.current.dispose(),h.current=null,p(null))}},_=[],t[0]=g,t[1]=_):(g=t[0],_=t[1]),(0,X.useEffect)(g,_);let v;t[2]!==u||t[3]!==i||t[4]!==f||t[5]!==c||t[6]!==o?(v={currentFile:i,selectionStartLine:o,selectionEndLine:c,connection:u,pushServer:f},t[2]=u,t[3]=i,t[4]=f,t[5]=c,t[6]=o,t[7]=v):v=t[7];let y;return t[8]!==n||t[9]!==v?(y=(0,Z.jsx)(U3.Provider,{value:v,children:n}),t[8]=n,t[9]=v,t[10]=y):y=t[10],y}const G3=(0,X.createContext)(null);function xWe(e){let t=(0,cQ.c)(8),{children:n}=e,[r,i]=(0,X.useState)(`idle`),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>i(`upload`),t[0]=a):a=t[0];let o=a,s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>i(`download`),t[1]=s):s=t[1];let c=s,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>i(`idle`),t[2]=l):l=t[2];let u=l,d;t[3]===r?d=t[4]:(d={activity:r,setActivity:i,startUpload:o,startDownload:c,stopActivity:u},t[3]=r,t[4]=d);let f=d,p;return t[5]!==n||t[6]!==f?(p=(0,Z.jsx)(G3.Provider,{value:f,children:n}),t[5]=n,t[6]=f,t[7]=p):p=t[7],p}function K3(){let e=(0,X.use)(G3);if(!e)throw Error(`useNetworkActivity must be used within NetworkActivityProvider`);return e}const SWe=new Set([`iterm2`,`kitty`,`wezterm`,`ghostty`]),q3=(0,X.createContext)(null),CWe=()=>{let e=(0,X.use)(q3);if(!e)throw Error(`useNotification must be used within NotificationProvider`);return e};function wWe(){if(process.platform!==`darwin`||process.env.TERM_PROGRAM!==`vscode`)return;let e=(process.env.VSCODE_GIT_IPC_HANDLE??process.env.VSCODE_IPC_HOOK_CLI??``).toLowerCase().includes(`cursor`)?`Cursor`:`Visual Studio Code`;try{return le(`osascript -e 'id of app "${e}"' 2>/dev/null`,{encoding:`utf8`,timeout:2e3}).trim()||void 0}catch{return}}const TWe=({children:e,mode:t=`full`})=>{let{isFocused:n}=fQ(),r=pQ(),i=(0,X.useRef)(n);i.current=n;let a=(0,X.useRef)(t);a.current=t;let o=(0,X.useRef)(SWe.has(gX())),s=(0,X.useRef)(wWe()),c=(0,X.useCallback)((e,t,n)=>{i.current||a.current===`off`||(a.current===`full`&&(o.current?r.notify({body:e,title:t}):EAe(t,e,n,{activateBundleId:s.current})),TAe(n))},[r]),l=(0,X.useCallback)((e,t)=>c(e,t??`Abacus AI`,`complete`),[c]),u=(0,X.useCallback)(e=>c(e,`Action Required`,`action-required`),[c]),d=(0,X.useCallback)(e=>c(e,`Task Complete`,`complete`),[c]),f=(0,X.useMemo)(()=>({notifyIfUnfocused:l,notifyActionRequired:u,notifyTaskComplete:d}),[l,u,d]);return(0,Z.jsx)(q3.Provider,{value:f,children:e})};function J3(e){return new Promise(t=>{process.platform===`darwin`?se(`open`,[e],e=>t(!e)):process.platform===`win32`?se(`explorer.exe`,[e],e=>t(!e)):se(`xdg-open`,[e],e=>t(!e))})}function Y3(e){return new Promise(t=>{let n=process.platform===`darwin`?ue(`pbcopy`):process.platform===`win32`?ue(`clip`):ue(`xclip`,[`-selection`,`clipboard`]);n.on(`error`,()=>t(!1)),n.on(`exit`,e=>t(e===0)),n.stdin?.write(e),n.stdin?.end()})}const X3=(0,X.createContext)(null),Z3=()=>{let e=(0,X.use)(X3);if(!e)throw Error(`useApiClient must be used within ApiClientProvider`);return e},Q3=(0,X.memo)(e=>{let t=(0,cQ.c)(9),{children:n,client:r,authManager:i,onAuthExpired:a}=e,[o,s]=(0,X.useState)(!1),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>s(!1),t[0]=c):c=t[0];let l=c,u;t[1]!==o||t[2]!==i||t[3]!==r||t[4]!==a?(u={apiClient:r,authManager:i,authExpired:o,setAuthExpired:s,clearAuthExpired:l,onAuthExpired:a},t[1]=o,t[2]=i,t[3]=r,t[4]=a,t[5]=u):u=t[5];let d=u,f;return t[6]!==n||t[7]!==d?(f=(0,Z.jsx)(X3.Provider,{value:d,children:n}),t[6]=n,t[7]=d,t[8]=f):f=t[8],f});Q3.displayName=`ApiClientProvider`;const $3=(0,X.createContext)(null);function e6(e,t){let n=t?new Set(t):null;return e.map(e=>{if(e.type!==`code_llm_tool_call`||e.status!==`transient`||e.toolUseResult||n&&!n.has(e.id))return e;let t=Array.isArray(e.toolUseRequest)?e.toolUseRequest[0]?.id??e.id:e.toolUseRequest?.id??e.id;return{...e,status:`completed`,isStreamingArgs:!1,toolUseResult:{id:t,content:JSON.stringify({reason:rz.INTERRUPTED}),rejected:!0}}})}function EWe(e,t){switch(t.type){case`INIT_SEND`:return[...e6(e.filter(e=>e.temp!==!0)),t.userSeg,t.spinnySeg];case`TEXT_DELTA`:{let{segId:n,content:r}=t,i=e6(e).filter(e=>!e.isSpinny);return i.find(e=>e.id===n)?i.map(e=>e.id===n?{...e,segment:(e.segment||``)+r}:e):[...i,{id:n,status:`transient`,source:`bot`,type:`text`,segment:r}]}case`THINKING_DELTA`:{let{segId:n,content:r,startTime:i}=t;return e.find(e=>e.id===n)?e.map(e=>e.id===n?{...e,segment:(e.segment||``)+r}:e):[...e,{id:n,status:`transient`,source:`bot`,type:`thinking`,isSpinny:!0,segment:r,thinkingStartTime:i}]}case`THINKING_COMPLETE`:return e.map(e=>e.id===t.segId?{...e,status:`completed`,isSpinny:!1,thinkingEndTime:t.endTime}:e);case`TOOL_DISPLAY_DATA`:return e.map(e=>e.id===t.toolCallId?{...e,toolDisplayData:{...e.toolDisplayData,...t.data}}:e);case`TOOL_REQUESTED`:{let{textSegId:n,toolSeg:r}=t,i;return i=n?e.filter(e=>!e.isSpinny).map(e=>e.id===n?{...e,status:`completed`}:e):e.filter(e=>!e.isSpinny),[...i,r]}case`TOOL_EXECUTION_COMPLETE`:{let{toolCallId:n,rawResult:r,parsedResult:i,spinnySeg:a}=t,o=e.map(e=>e.id===n?{...e,status:`completed`,toolUseResult:r,...i!==void 0&&{parsedResult:i}}:e);return a?[...o,a]:o}case`TOOL_USER_MESSAGE`:return[...e,t.seg];case`TEXT_COMPLETED`:return e.map(e=>e.id===t.segId?{...e,status:`completed`}:e);case`TURN_COMPLETE`:{let n=e6(e,t.toolCallIds);return t.textSegId&&(n=n.map(e=>e.id===t.textSegId?{...e,status:`completed`}:e)),n}case`FINALIZE`:{let n=e6(e);return t.textSegId&&(n=n.map(e=>e.id===t.textSegId?{...e,status:`completed`}:e)),n.filter(e=>!e.isSpinny)}case`ADD_NOTIFICATION`:{let n=t.seg,r=e[e.length-1];if(r&&r.type===`code_llm_notification`&&r.message===n.message&&r.severity===n.severity){let t=[...e];return t[t.length-1]={...r,flashKey:(r.flashKey??0)+1},t}return[...e,n]}case`ERROR`:return[...e6(e).filter(e=>!e.isSpinny),t.errorSeg];case`REMOVE_USER_SEG`:return e.filter(e=>e.id!==t.userSegId);case`CLEAR`:return[];case`LOAD`:return t.segments;case`REMOVE_TEMP`:return e.some(e=>e.temp===!0)?e.filter(e=>e.temp!==!0):e;case`ADD_CREDITS`:return[...e,t.seg];case`TOOL_CALL_START`:{let{toolCallId:n,toolName:r,textSegId:i}=t,a;return a=i?e.filter(e=>!e.isSpinny).map(e=>e.id===i?{...e,status:`completed`}:e):e.filter(e=>!e.isSpinny),[...a,{id:n,status:`transient`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:{id:n,name:r,input:{}},isStreamingArgs:!0,streamingArguments:``}]}case`TOOL_CALL_DELTA`:{let{toolCallId:n,argumentsDelta:r}=t;return e.map(e=>e.id===n?{...e,streamingArguments:(e.streamingArguments??``)+r}:e)}case`TOOL_CALL_STOP`:{let{toolCallId:n,toolName:r,arguments:i}=t,a={};try{a=JSON.parse(i)}catch{}return e.map(e=>e.id===n?{...e,isStreamingArgs:!1,streamingArguments:i,toolUseRequest:{id:n,name:r,input:a}}:e)}case`ADD_CONNECTOR_AUTH`:return[...e.filter(e=>!e.isSpinny),t.seg];case`UPDATE_CONNECTOR_AUTH`:{let n=[...e].reverse().find(e=>e.type===`code_llm_connector_auth`);return n?e.map(e=>e.id===n.id?{...e,connectorStatuses:{...e.connectorStatuses,...t.connectorStatuses}}:e):e}case`UPDATE_CONNECTOR_AUTH_URL`:{let n=[...e].reverse().find(e=>e.type===`code_llm_connector_auth`);return n?e.map(e=>e.id===n.id?{...e,connectorAuthUrls:{...e.connectorAuthUrls,[t.service]:t.url}}:e):e}default:return e}}function DWe(e){switch(e.type){case`text`:return{id:e.id,status:`completed`,source:e.source,type:`text`,segment:e.content};case`thinking`:return{id:e.id,status:`completed`,source:`bot`,type:`thinking`,segment:e.content,isSpinny:e.isSpinny,...e.title!==void 0&&{title:e.title}};case`tool_call`:return{id:e.id,status:`completed`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:e.toolUseRequest,toolUseResult:e.toolUseResult??{id:e.toolUseRequest.id,content:` `},...e.parsedResult!==void 0&&{parsedResult:e.parsedResult},...e.toolDisplayData!==void 0&&{toolDisplayData:e.toolDisplayData}};case`notification`:return{id:e.id,status:`completed`,source:`bot`,type:`code_llm_notification`,message:e.message,severity:e.severity,...e.actions!==void 0&&{actions:e.actions}};case`tool_group`:return{id:e.id,status:`completed`,source:`bot`,type:`text`,segment:e.summary}}}const t6=(0,X.memo)(({children:e,apiClient:t,configService:n,agentArgs:r})=>{let{agentMode:i,setAgentMode:a}=j2(),o=(0,X.useRef)(i),s=(0,X.useRef)(i),c=(0,X.useRef)(null),{notifyActionRequired:l,notifyTaskComplete:u}=CWe(),{startUpload:d,startDownload:f,stopActivity:p}=K3(),{authManager:m,setAuthExpired:h,onAuthExpired:g}=Z3(),_=pQ(),{connection:v,pushServer:y}=W3(),b=(0,X.useRef)(v),x=(0,X.useRef)(y);(0,X.useEffect)(()=>{b.current=v},[v]),(0,X.useEffect)(()=>{x.current=y},[y]);let[S,C]=(0,X.useState)(zd.Idle),[w,T]=(0,X.useReducer)(EWe,[]),E=(0,X.useRef)(new Map),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(null),j=(0,X.useRef)(null),M=(0,X.useRef)([]),[N,ee]=(0,X.useState)([]),[te,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(null),[ne,R]=(0,X.useState)(!0),[z,re]=(0,X.useState)(!0),[ie,ae]=(0,X.useState)(0),[oe,se]=(0,X.useState)(null),[ce,le]=(0,X.useState)(null),[ue,de]=(0,X.useState)(null),[fe,B]=(0,X.useState)(null),pe=(0,X.useRef)(0),me=(0,X.useRef)(!0),he=(0,X.useRef)(null),ge=(0,X.useRef)(zd.Idle),_e=(0,X.useCallback)(e=>{ge.current=e,C(e)},[]);(0,X.useEffect)(()=>()=>{he.current&&clearTimeout(he.current),c.current&&clearTimeout(c.current)},[]);let[ve,ye]=(0,X.useState)(null),be=qF(process.cwd()),V=(0,X.useCallback)(e=>{j.current=e,A(e)},[]),xe=(0,X.useCallback)(()=>{let e=M.current.shift();if(!e){V(null);return}e.request=Ce.current?.refreshPermissionRequest(e.request)??e.request;let t=!1;(e.editorDiffFilePath||e.editorToolViewShown)&&x.current&&x.current.waitForDecision(e.request.tool.id).then(n=>{t||(t=!0,_e(n===`accept`||n===`allowAlways`||n===`allowYolo`?zd.ExecutingTool:zd.Submitted),e.resolve(n),xe())}).catch(()=>{}),V({request:e.request,resolve:n=>{t||(t=!0,_e(n===`accept`||n===`allowAlways`||n===`allowYolo`||typeof n==`object`&&n.type===`accept_with_message`||typeof n==`object`&&n.type===`question_answers`?zd.ExecutingTool:zd.Submitted),setTimeout(()=>{e.resolve(n),xe()},0).unref())}}),_e(zd.WaitingForToolPermission),l(`Abacus.AI is waiting for your input`)},[l,_e,V]),Se=(0,X.useMemo)(()=>new eJ(async e=>{let t=b.current,n=e,r=null;if(t&&x.current&&e.type===`edit_file`){let i=e.tool.id,a=E.current.get(i),o=(e.tool.input??{}).filePath??e.filePath??``,s=a?.originalContent??e.originalContent??``,c=a?.newContent??e.newContent??``;o&&(s||c)&&await t.showDiff({filePath:o,originalContent:s,modifiedContent:c,toolId:i})&&(n={...e,diffShownInEditor:!0},r=o)}if(t&&x.current&&e.type===`write_file`&&!e.isNewFile){let i=e.tool.id,a=e.filePath??``,o=e.originalContent??``,s=e.content??``;a&&(o||s)&&await t.showDiff({filePath:a,originalContent:o,modifiedContent:s,toolId:i})&&(n={...e,diffShownInEditor:!0},r=a)}let i=!1;t&&e.type===`exit_plan_mode`&&e.planFilePath&&(x.current&&await t.showToolView({filePath:e.planFilePath,toolKey:e.tool.id}).catch(()=>!1)&&(i=!0),i||await t.openPlanFile(e.planFilePath).catch(()=>{}));let a=await new Promise(e=>{let t={request:n,editorDiffFilePath:r,editorToolViewShown:i,resolve:e},a=M.current.length===0&&!j.current;M.current.push(t),a&&xe()});if(r&&t){let e=a===`reject`||typeof a==`object`&&a.type===`reject_with_message`;t.notifyDiffDecision({targetFile:r,decision:e?`reject`:`accept`}).catch(()=>{})}return a}),[xe]),Ce=(0,X.useRef)(null);function we(){return new $q({allowedDirectories:[be,...r?.[`add-dir`]?.map(e=>{let t=GF(e);return qF(P.isAbsolute(t)?t:P.resolve(be,t))})??[]],primaryWorkspace:be,apiClient:t,mode:s.current,permissionProvider:Se,config:n,diagnosticsProvider:{getDiagnostics:async e=>{let t=b.current;return t?t.getDiagnostics(e):[]}},onMcpAuthRequired:void 0,enableSkills:!0,cliAllowedTools:r?.[`allowed-tools`],cliDisallowedTools:r?.[`disallowed-tools`]})}Ce.current||=(s.current=o.current,we());let Te=Ce.current,Ee=(0,X.useCallback)(()=>{ee(Te.getQueueEntries().map(e=>({...e})))},[Te]),De=(0,X.useCallback)(e=>{s.current=e,Te.setMode(e),M.current=M.current.filter(t=>Ud(t.request.type,e)?(t.resolve(`accept`),!1):!0);let t=j.current;t&&Ud(t.request.type,e)&&t.resolve(`accept`)},[Te]);(0,X.useEffect)(()=>(o.current=i,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{De(i),c.current=null},500),c.current.unref(),()=>{c.current&&=(clearTimeout(c.current),null)}),[i,De]),(0,X.useEffect)(()=>{(async()=>{let e=!0;if(r?.conversationId)try{await Pe(r.conversationId)}catch{e=!1}e&&r?.prompt&&await Ie({message:r.prompt})})()},[]),(0,X.useEffect)(()=>{let e=!1,t=0,n=1e3,r=()=>{if(e)return;t+=n;let i=Te.mcp.listServers(),a=i.filter(e=>e.status===`auth-required`);if(a.length>0){let e=a.map(e=>e.config.name??e.config.id).join(`, `);Oe(`${a.length} MCP server(s) require auth (${e}). Use /mcp auth <name> to authenticate.`,`warning`,!0);return}t<1e4&&i.some(e=>e.status!==`connected`&&e.status!==`error`)&&setTimeout(r,n)},i=setTimeout(r,n);return()=>{e=!0,clearTimeout(i)}},[]),(0,X.useEffect)(()=>{switch(S){case zd.Submitted:case zd.Streaming:_.showProgress({state:`indeterminate`});break;case zd.ExecutingTool:_.showProgress({state:`indeterminate`});break;case zd.WaitingForToolPermission:_.hideProgress();break;case zd.Idle:_.hideProgress();break}},[S,_]);let Oe=(0,X.useCallback)((e,t=`info`,n=!1)=>{T({type:`ADD_NOTIFICATION`,seg:{id:crypto.randomUUID(),status:`completed`,source:`bot`,type:`code_llm_notification`,severity:t,message:e,temp:n}})},[]),ke=(0,X.useCallback)(()=>{T({type:`CLEAR`}),O(null),_e(zd.Idle),ye(null),B(null),E.current.clear(),c.current&&=(clearTimeout(c.current),null),s.current=o.current,Ce.current=we()},[t,be,Se]),Ae=(0,X.useCallback)(()=>{T({type:`CLEAR`})},[]),je=(0,X.useCallback)(()=>{T({type:`REMOVE_TEMP`})},[]),Me=(0,X.useCallback)(()=>{let e=Te.dq();Ee(),e.length>0&&F(e.map(e=>e.message).join(`
75284
+ `);n.procedure=lWe(e,n.contract)}return{path:n.path,procedure:n.procedure}}}},_We=class extends mWe{constructor(e,t={}){let n=new i3(new n3(t)),r=new gWe(t),i=new hWe(n);super(e,r,i,t)}},vWe=class{socketServer;socketPath;editorState={file:void 0,startLine:void 0,endLine:void 0};onEditorStateCallback=null;pendingDecisions=new Map;constructor(){let e=N.join(t.homedir(),hn.configDirName,`cli`);this.socketPath=N.join(e,`${process.pid}.sock`)}getEditorState(){return{...this.editorState}}onEditorChange(e){this.onEditorStateCallback=e}waitForDecision(e,t){return new Promise((n,r)=>{if(t?.aborted){r(Error(`Aborted`));return}let i=()=>{t?.removeEventListener(`abort`,a),this.pendingDecisions.delete(e)},a=()=>{i(),r(Error(`Aborted`))};t?.addEventListener(`abort`,a,{once:!0}),this.pendingDecisions.set(e,{resolve:e=>{i(),n(e)},cleanup:i})})}async start(){let e=N.dirname(this.socketPath);p.existsSync(e)||p.mkdirSync(e,{recursive:!0});let t=H3(IUe),n=t.router({editorStateChanged:t.editorStateChanged.handler(async({input:e})=>(this.editorState={file:e.file??void 0,startLine:e.startLine,endLine:e.endLine},this.onEditorStateCallback?.(this.editorState),{ok:!0})),toolDecision:t.toolDecision.handler(async({input:e})=>{let t=this.pendingDecisions.get(e.toolId);return t&&t.resolve(e.decision),{ok:!0}})});this.socketServer=await XUe(this.socketPath,new _We(n))}dispose(){for(let[,e]of this.pendingDecisions)e.cleanup();this.pendingDecisions.clear(),this.socketServer?.dispose(),this.socketServer=void 0}},yWe=class{client=null;disposeSocket=null;currentFile=void 0;selectionStartLine=void 0;selectionEndLine=void 0;onFileChangeCallback=null;constructor(e){this.pushServer=e}findSocketPath(){let e=process.env[hn.socketEnvVar];if(e&&m.existsSync(e))return e;try{let e=P.join(n.homedir(),hn.configDirName,hn.ideDirName),t=m.readdirSync(e).filter(e=>e.endsWith(`.sock`)).map(t=>P.join(e,t)).filter(e=>m.existsSync(e));if(t.length===1)return t[0]}catch{}return null}async connect(){try{let e=this.findSocketPath();if(!e)return!1;let t=await $Ue(e,{timeoutMs:2e3});this.client=X4(t.link),this.disposeSocket=()=>t.dispose(),await this.client.register({cliSocketPath:this.pushServer.socketPath,pid:process.pid});let n=this.pushServer.getEditorState();return this.currentFile=n.file,this.selectionStartLine=n.startLine,this.selectionEndLine=n.endLine,this.pushServer.onEditorChange(e=>{this.currentFile=e.file,this.selectionStartLine=e.startLine,this.selectionEndLine=e.endLine,this.onFileChangeCallback?.(e.file,e.startLine,e.endLine)}),!0}catch{return!1}}getCurrentFile(){return this.currentFile}getSelectionRange(){return{startLine:this.selectionStartLine,endLine:this.selectionEndLine}}isConnected(){return this.client!==null}onFileChange(e){this.onFileChangeCallback=e}async showDiff(e){if(!this.client)return!1;try{return(await this.client.showDiff({...e,cliSocketPath:this.pushServer.socketPath})).success}catch{return!1}}async showToolView(e){if(!this.client)return!1;try{return(await this.client.showToolView({...e,cliSocketPath:this.pushServer.socketPath})).success}catch{return!1}}async notifyDiffDecision(e){if(!this.client)throw Error(`Not connected to extension`);await this.client.notifyDiffDecision(e)}async openPlanFile(e){if(!this.client)throw Error(`Not connected to extension`);return{opened:(await this.client.openFile({file:e})).success}}async getDiagnostics(e){if(!this.client)throw Error(`Not connected to extension`);return this.client.getDiagnostics({...e&&{files:e}})}dispose(){this.disposeSocket?.(),this.disposeSocket=null,this.client=null,this.currentFile=void 0,this.selectionStartLine=void 0,this.selectionEndLine=void 0,this.onFileChangeCallback=null}};const U3=(0,X.createContext)(null);function W3(){let e=(0,X.use)(U3);if(!e)throw Error(`useExtensionFile must be used within ExtensionFileProvider`);return e}function bWe(e){let t=(0,cQ.c)(11),{children:n,initialFile:r}=e,[i,a]=(0,X.useState)(r),[o,s]=(0,X.useState)(void 0),[c,l]=(0,X.useState)(void 0),[u,d]=(0,X.useState)(null),[f,p]=(0,X.useState)(null),m=(0,X.useRef)(null),h=(0,X.useRef)(null),g,_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{let e=!1;return(async()=>{let t=new vWe;try{await t.start()}catch{}if(e){t.dispose();return}h.current=t,p(t),t.onEditorChange(e=>{a(e.file),s(e.startLine),l(e.endLine)});for(let n of[0,...[500,1e3,2e3,3e3,4e3]]){if(e||(n>0&&await new Promise(e=>setTimeout(e,n)),e))return;try{let n=new yWe(t);if(await n.connect()){if(e){n.dispose();return}let r=t.getEditorState();a(r.file),s(r.startLine),l(r.endLine),n.onFileChange((e,t,n)=>{a(e),s(t),l(n)}),m.current=n,d(n);return}}catch{}}})(),()=>{e=!0,m.current&&(m.current.dispose(),m.current=null,d(null)),h.current&&(h.current.dispose(),h.current=null,p(null))}},_=[],t[0]=g,t[1]=_):(g=t[0],_=t[1]),(0,X.useEffect)(g,_);let v;t[2]!==u||t[3]!==i||t[4]!==f||t[5]!==c||t[6]!==o?(v={currentFile:i,selectionStartLine:o,selectionEndLine:c,connection:u,pushServer:f},t[2]=u,t[3]=i,t[4]=f,t[5]=c,t[6]=o,t[7]=v):v=t[7];let y;return t[8]!==n||t[9]!==v?(y=(0,Z.jsx)(U3.Provider,{value:v,children:n}),t[8]=n,t[9]=v,t[10]=y):y=t[10],y}const G3=(0,X.createContext)(null);function xWe(e){let t=(0,cQ.c)(8),{children:n}=e,[r,i]=(0,X.useState)(`idle`),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>i(`upload`),t[0]=a):a=t[0];let o=a,s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>i(`download`),t[1]=s):s=t[1];let c=s,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>i(`idle`),t[2]=l):l=t[2];let u=l,d;t[3]===r?d=t[4]:(d={activity:r,setActivity:i,startUpload:o,startDownload:c,stopActivity:u},t[3]=r,t[4]=d);let f=d,p;return t[5]!==n||t[6]!==f?(p=(0,Z.jsx)(G3.Provider,{value:f,children:n}),t[5]=n,t[6]=f,t[7]=p):p=t[7],p}function K3(){let e=(0,X.use)(G3);if(!e)throw Error(`useNetworkActivity must be used within NetworkActivityProvider`);return e}const SWe=new Set([`iterm2`,`kitty`,`wezterm`,`ghostty`]),q3=(0,X.createContext)(null),CWe=()=>{let e=(0,X.use)(q3);if(!e)throw Error(`useNotification must be used within NotificationProvider`);return e};function wWe(){if(process.platform!==`darwin`||process.env.TERM_PROGRAM!==`vscode`)return;let e=(process.env.VSCODE_GIT_IPC_HANDLE??process.env.VSCODE_IPC_HOOK_CLI??``).toLowerCase().includes(`cursor`)?`Cursor`:`Visual Studio Code`;try{return le(`osascript -e 'id of app "${e}"' 2>/dev/null`,{encoding:`utf8`,timeout:2e3}).trim()||void 0}catch{return}}const TWe=({children:e,mode:t=`full`})=>{let{isFocused:n}=fQ(),r=pQ(),i=(0,X.useRef)(n);i.current=n;let a=(0,X.useRef)(t);a.current=t;let o=(0,X.useRef)(SWe.has(gX())),s=(0,X.useRef)(wWe()),c=(0,X.useCallback)((e,t,n)=>{i.current||a.current===`off`||(a.current===`full`&&(o.current?r.notify({body:e,title:t}):EAe(t,e,n,{activateBundleId:s.current})),TAe(n))},[r]),l=(0,X.useCallback)((e,t)=>c(e,t??`Abacus AI`,`complete`),[c]),u=(0,X.useCallback)(e=>c(e,`Action Required`,`action-required`),[c]),d=(0,X.useCallback)(e=>c(e,`Task Complete`,`complete`),[c]),f=(0,X.useMemo)(()=>({notifyIfUnfocused:l,notifyActionRequired:u,notifyTaskComplete:d}),[l,u,d]);return(0,Z.jsx)(q3.Provider,{value:f,children:e})};function J3(e){return new Promise(t=>{process.platform===`darwin`?se(`open`,[e],e=>t(!e)):process.platform===`win32`?se(`explorer.exe`,[e],e=>t(!e)):se(`xdg-open`,[e],e=>t(!e))})}function Y3(e){return new Promise(t=>{let n=process.platform===`darwin`?ue(`pbcopy`):process.platform===`win32`?ue(`clip`):ue(`xclip`,[`-selection`,`clipboard`]);n.on(`error`,()=>t(!1)),n.on(`exit`,e=>t(e===0)),n.stdin?.write(e),n.stdin?.end()})}const X3=(0,X.createContext)(null),Z3=()=>{let e=(0,X.use)(X3);if(!e)throw Error(`useApiClient must be used within ApiClientProvider`);return e},Q3=(0,X.memo)(e=>{let t=(0,cQ.c)(9),{children:n,client:r,authManager:i,onAuthExpired:a}=e,[o,s]=(0,X.useState)(!1),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>s(!1),t[0]=c):c=t[0];let l=c,u;t[1]!==o||t[2]!==i||t[3]!==r||t[4]!==a?(u={apiClient:r,authManager:i,authExpired:o,setAuthExpired:s,clearAuthExpired:l,onAuthExpired:a},t[1]=o,t[2]=i,t[3]=r,t[4]=a,t[5]=u):u=t[5];let d=u,f;return t[6]!==n||t[7]!==d?(f=(0,Z.jsx)(X3.Provider,{value:d,children:n}),t[6]=n,t[7]=d,t[8]=f):f=t[8],f});Q3.displayName=`ApiClientProvider`;const $3=(0,X.createContext)(null);function e6(e,t){let n=t?new Set(t):null;return e.map(e=>{if(e.type!==`code_llm_tool_call`||e.status!==`transient`||e.toolUseResult||n&&!n.has(e.id))return e;let t=Array.isArray(e.toolUseRequest)?e.toolUseRequest[0]?.id??e.id:e.toolUseRequest?.id??e.id;return{...e,status:`completed`,isStreamingArgs:!1,toolUseResult:{id:t,content:JSON.stringify({reason:rz.INTERRUPTED}),rejected:!0}}})}function EWe(e,t){switch(t.type){case`INIT_SEND`:return[...e6(e.filter(e=>e.temp!==!0)),t.userSeg,t.spinnySeg];case`TEXT_DELTA`:{let{segId:n,content:r}=t,i=e6(e).filter(e=>!e.isSpinny);return i.find(e=>e.id===n)?i.map(e=>e.id===n?{...e,segment:(e.segment||``)+r}:e):[...i,{id:n,status:`transient`,source:`bot`,type:`text`,segment:r}]}case`THINKING_DELTA`:{let{segId:n,content:r,startTime:i}=t;return e.find(e=>e.id===n)?e.map(e=>e.id===n?{...e,segment:(e.segment||``)+r}:e):[...e,{id:n,status:`transient`,source:`bot`,type:`thinking`,isSpinny:!0,segment:r,thinkingStartTime:i}]}case`THINKING_COMPLETE`:return e.map(e=>e.id===t.segId?{...e,status:`completed`,isSpinny:!1,thinkingEndTime:t.endTime}:e);case`TOOL_DISPLAY_DATA`:return e.map(e=>e.id===t.toolCallId?{...e,toolDisplayData:{...e.toolDisplayData,...t.data}}:e);case`TOOL_REQUESTED`:{let{textSegId:n,toolSeg:r}=t,i;return i=n?e.filter(e=>!e.isSpinny).map(e=>e.id===n?{...e,status:`completed`}:e):e.filter(e=>!e.isSpinny),[...i,r]}case`TOOL_EXECUTION_COMPLETE`:{let{toolCallId:n,rawResult:r,parsedResult:i,spinnySeg:a}=t,o=e.map(e=>e.id===n?{...e,status:`completed`,toolUseResult:r,...i!==void 0&&{parsedResult:i}}:e);return a?[...o,a]:o}case`TOOL_USER_MESSAGE`:return[...e,t.seg];case`TEXT_COMPLETED`:return e.map(e=>e.id===t.segId?{...e,status:`completed`}:e);case`TURN_COMPLETE`:{let n=e6(e,t.toolCallIds);return t.textSegId&&(n=n.map(e=>e.id===t.textSegId?{...e,status:`completed`}:e)),n}case`FINALIZE`:{let n=e6(e);return t.textSegId&&(n=n.map(e=>e.id===t.textSegId?{...e,status:`completed`}:e)),n.filter(e=>!e.isSpinny)}case`ADD_NOTIFICATION`:{let n=t.seg,r=e[e.length-1];if(r&&r.type===`code_llm_notification`&&r.message===n.message&&r.severity===n.severity){let t=[...e];return t[t.length-1]={...r,flashKey:(r.flashKey??0)+1},t}return[...e,n]}case`ERROR`:return[...e6(e).filter(e=>!e.isSpinny),t.errorSeg];case`REMOVE_USER_SEG`:return e.filter(e=>e.id!==t.userSegId);case`CLEAR`:return[];case`LOAD`:return t.segments;case`REMOVE_TEMP`:return e.some(e=>e.temp===!0)?e.filter(e=>e.temp!==!0):e;case`ADD_CREDITS`:return[...e,t.seg];case`TOOL_CALL_START`:{let{toolCallId:n,toolName:r,textSegId:i}=t,a;return a=i?e.filter(e=>!e.isSpinny).map(e=>e.id===i?{...e,status:`completed`}:e):e.filter(e=>!e.isSpinny),[...a,{id:n,status:`transient`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:{id:n,name:r,input:{}},isStreamingArgs:!0,streamingArguments:``}]}case`TOOL_CALL_DELTA`:{let{toolCallId:n,argumentsDelta:r}=t;return e.map(e=>e.id===n?{...e,streamingArguments:(e.streamingArguments??``)+r}:e)}case`TOOL_CALL_STOP`:{let{toolCallId:n,toolName:r,arguments:i}=t,a={};try{a=JSON.parse(i)}catch{}return e.map(e=>e.id===n?{...e,isStreamingArgs:!1,streamingArguments:i,toolUseRequest:{id:n,name:r,input:a}}:e)}case`ADD_CONNECTOR_AUTH`:return[...e.filter(e=>!e.isSpinny),t.seg];case`UPDATE_CONNECTOR_AUTH`:{let n=[...e].reverse().find(e=>e.type===`code_llm_connector_auth`);return n?e.map(e=>e.id===n.id?{...e,connectorStatuses:{...e.connectorStatuses,...t.connectorStatuses}}:e):e}case`UPDATE_CONNECTOR_AUTH_URL`:{let n=[...e].reverse().find(e=>e.type===`code_llm_connector_auth`);return n?e.map(e=>e.id===n.id?{...e,connectorAuthUrls:{...e.connectorAuthUrls,[t.service]:t.url}}:e):e}default:return e}}function DWe(e){switch(e.type){case`text`:return{id:e.id,status:`completed`,source:e.source,type:`text`,segment:e.content};case`thinking`:return{id:e.id,status:`completed`,source:`bot`,type:`thinking`,segment:e.content,isSpinny:e.isSpinny,...e.title!==void 0&&{title:e.title}};case`tool_call`:return{id:e.id,status:`completed`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:e.toolUseRequest,toolUseResult:e.toolUseResult??{id:e.toolUseRequest.id,content:` `},...e.parsedResult!==void 0&&{parsedResult:e.parsedResult},...e.toolDisplayData!==void 0&&{toolDisplayData:e.toolDisplayData}};case`notification`:return{id:e.id,status:`completed`,source:`bot`,type:`code_llm_notification`,message:e.message,severity:e.severity,...e.actions!==void 0&&{actions:e.actions}};case`tool_group`:return{id:e.id,status:`completed`,source:`bot`,type:`text`,segment:e.summary}}}const t6=(0,X.memo)(({children:e,apiClient:t,configService:n,agentArgs:r})=>{let{agentMode:i,setAgentMode:a}=j2(),o=(0,X.useRef)(i),s=(0,X.useRef)(i),c=(0,X.useRef)(null),{notifyActionRequired:l,notifyTaskComplete:u}=CWe(),{startUpload:d,startDownload:f,stopActivity:p}=K3(),{authManager:m,setAuthExpired:h,onAuthExpired:g}=Z3(),_=pQ(),{connection:v,pushServer:y}=W3(),b=(0,X.useRef)(v),x=(0,X.useRef)(y);(0,X.useEffect)(()=>{b.current=v},[v]),(0,X.useEffect)(()=>{x.current=y},[y]);let[S,C]=(0,X.useState)(zd.Idle),[w,T]=(0,X.useReducer)(EWe,[]),E=(0,X.useRef)(new Map),[D,O]=(0,X.useState)(null),[k,A]=(0,X.useState)(null),j=(0,X.useRef)(null),M=(0,X.useRef)([]),[N,ee]=(0,X.useState)([]),[te,F]=(0,X.useState)(null),[I,L]=(0,X.useState)(null),[ne,R]=(0,X.useState)(!0),[z,re]=(0,X.useState)(!0),[ie,ae]=(0,X.useState)(0),[oe,se]=(0,X.useState)(null),[ce,le]=(0,X.useState)(null),[ue,de]=(0,X.useState)(null),[fe,B]=(0,X.useState)(null),pe=(0,X.useRef)(0),me=(0,X.useRef)(!0),he=(0,X.useRef)(null),ge=(0,X.useRef)(zd.Idle),_e=(0,X.useCallback)(e=>{ge.current=e,C(e)},[]);(0,X.useEffect)(()=>()=>{he.current&&clearTimeout(he.current),c.current&&clearTimeout(c.current)},[]);let[ve,ye]=(0,X.useState)(null),be=qF(process.cwd()),V=(0,X.useCallback)(e=>{j.current=e,A(e)},[]),xe=(0,X.useCallback)(()=>{let e=M.current.shift();if(!e){V(null);return}e.request=Ce.current?.refreshPermissionRequest(e.request)??e.request;let t=!1;(e.editorDiffFilePath||e.editorToolViewShown)&&x.current&&x.current.waitForDecision(e.request.tool.id).then(n=>{t||(t=!0,_e(n===`accept`||n===`allowAlways`||n===`allowYolo`?zd.ExecutingTool:zd.Submitted),e.resolve(n),xe())}).catch(()=>{}),V({request:e.request,resolve:n=>{t||(t=!0,_e(n===`accept`||n===`allowAlways`||n===`allowYolo`||typeof n==`object`&&n.type===`accept_with_message`||typeof n==`object`&&n.type===`question_answers`?zd.ExecutingTool:zd.Submitted),setTimeout(()=>{e.resolve(n),xe()},0).unref())}}),_e(zd.WaitingForToolPermission),l(`Abacus.AI is waiting for your input`)},[l,_e,V]),Se=(0,X.useMemo)(()=>new eJ(async e=>{let t=b.current,n=e,r=null;if(t&&x.current&&e.type===`edit_file`){let i=e.tool.id,a=E.current.get(i),o=(e.tool.input??{}).filePath??e.filePath??``,s=a?.originalContent??e.originalContent??``,c=a?.newContent??e.newContent??``;o&&(s||c)&&await t.showDiff({filePath:o,originalContent:s,modifiedContent:c,toolId:i})&&(n={...e,diffShownInEditor:!0},r=o)}if(t&&x.current&&e.type===`write_file`&&!e.isNewFile){let i=e.tool.id,a=e.filePath??``,o=e.originalContent??``,s=e.content??``;a&&(o||s)&&await t.showDiff({filePath:a,originalContent:o,modifiedContent:s,toolId:i})&&(n={...e,diffShownInEditor:!0},r=a)}let i=!1;t&&e.type===`exit_plan_mode`&&e.planFilePath&&(x.current&&await t.showToolView({filePath:e.planFilePath,toolKey:e.tool.id}).catch(()=>!1)&&(i=!0),i||await t.openPlanFile(e.planFilePath).catch(()=>{}));let a=await new Promise(e=>{let t={request:n,editorDiffFilePath:r,editorToolViewShown:i,resolve:e},a=M.current.length===0&&!j.current;M.current.push(t),a&&xe()});if(r&&t){let e=a===`reject`||typeof a==`object`&&a.type===`reject_with_message`;t.notifyDiffDecision({targetFile:r,decision:e?`reject`:`accept`}).catch(()=>{})}return a}),[xe]),Ce=(0,X.useRef)(null);function we(){return new $q({allowedDirectories:[be,...r?.[`add-dir`]?.map(e=>{let t=GF(e);return qF(P.isAbsolute(t)?t:P.resolve(be,t))})??[]],primaryWorkspace:be,apiClient:t,mode:s.current,...r?.model&&{model:r.model},permissionProvider:Se,config:n,diagnosticsProvider:{getDiagnostics:async e=>{let t=b.current;return t?t.getDiagnostics(e):[]}},onMcpAuthRequired:void 0,enableSkills:!0,cliAllowedTools:r?.[`allowed-tools`],cliDisallowedTools:r?.[`disallowed-tools`]})}Ce.current||=(s.current=o.current,we());let Te=Ce.current,Ee=(0,X.useCallback)(()=>{ee(Te.getQueueEntries().map(e=>({...e})))},[Te]),De=(0,X.useCallback)(e=>{s.current=e,Te.setMode(e),M.current=M.current.filter(t=>Ud(t.request.type,e)?(t.resolve(`accept`),!1):!0);let t=j.current;t&&Ud(t.request.type,e)&&t.resolve(`accept`)},[Te]);(0,X.useEffect)(()=>(o.current=i,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{De(i),c.current=null},500),c.current.unref(),()=>{c.current&&=(clearTimeout(c.current),null)}),[i,De]),(0,X.useEffect)(()=>{(async()=>{let e=!0;if(r?.conversationId)try{await Pe(r.conversationId)}catch{e=!1}e&&r?.prompt&&await Ie({message:r.prompt})})()},[]),(0,X.useEffect)(()=>{let e=!1,t=0,n=1e3,r=()=>{if(e)return;t+=n;let i=Te.mcp.listServers(),a=i.filter(e=>e.status===`auth-required`);if(a.length>0){let e=a.map(e=>e.config.name??e.config.id).join(`, `);Oe(`${a.length} MCP server(s) require auth (${e}). Use /mcp auth <name> to authenticate.`,`warning`,!0);return}t<1e4&&i.some(e=>e.status!==`connected`&&e.status!==`error`)&&setTimeout(r,n)},i=setTimeout(r,n);return()=>{e=!0,clearTimeout(i)}},[]),(0,X.useEffect)(()=>{switch(S){case zd.Submitted:case zd.Streaming:_.showProgress({state:`indeterminate`});break;case zd.ExecutingTool:_.showProgress({state:`indeterminate`});break;case zd.WaitingForToolPermission:_.hideProgress();break;case zd.Idle:_.hideProgress();break}},[S,_]);let Oe=(0,X.useCallback)((e,t=`info`,n=!1)=>{T({type:`ADD_NOTIFICATION`,seg:{id:crypto.randomUUID(),status:`completed`,source:`bot`,type:`code_llm_notification`,severity:t,message:e,temp:n}})},[]),ke=(0,X.useCallback)(()=>{T({type:`CLEAR`}),O(null),_e(zd.Idle),ye(null),B(null),E.current.clear(),c.current&&=(clearTimeout(c.current),null),s.current=o.current,Ce.current=we()},[t,be,Se]),Ae=(0,X.useCallback)(()=>{T({type:`CLEAR`})},[]),je=(0,X.useCallback)(()=>{T({type:`REMOVE_TEMP`})},[]),Me=(0,X.useCallback)(()=>{let e=Te.dq();Ee(),e.length>0&&F(e.map(e=>e.message).join(`
75285
75285
  `)),Te.stop();let t=j.current;t&&t.resolve(`reject`);for(let e of M.current)e.resolve(`reject`);M.current.length=0,V(null),_e(zd.Idle)},[Te,Ee,_e,V]),Ne=(0,X.useCallback)(()=>{k&&k.resolve(`reject`)},[k]),Pe=(0,X.useCallback)(async e=>{_e(zd.LoadingConversation),T({type:`CLEAR`}),O(null),ye(e);try{let t=await Te.loadConversation(e);return t.title&&O(t.title),t.segments.length>0&&T({type:`LOAD`,segments:t.segments.map(e=>DWe(e))}),B(t.llmName??null),t.llmName&&Te.setModel(t.llmName),{llmName:t.llmName}}catch{return B(null),Oe(`Failed to load conversation`,`error`),{}}finally{_e(zd.Idle)}},[Te,Oe,_e]),Fe=(0,X.useCallback)(async(e,t)=>{await Te.mcp.refresh(),t&&Oe(`MCP tools refreshed`,`info`,!0)},[Te,Oe]),Ie=(0,X.useCallback)(async({message:e,selectedModel:t,fileAttachments:n,activeSkills:r})=>{if(!e||S===zd.LoadingConversation)return;t&&Te.setModel(t);let i=e;if(n&&n.length>0){let e=n.filter(e=>!e.mimeType.startsWith(`image/`));for(let t of e){let e=typeof t.content==`string`?t.content:t.content.toString(`utf-8`);i+=`\n\n<file path="${t.filePath}">\n${e}\n</file>`}}let o=crypto.randomUUID();T({type:`INIT_SEND`,userSeg:{id:o,status:`completed`,source:`user`,type:`text`,segment:e},spinnySeg:{id:crypto.randomUUID(),status:`transient`,source:`bot`,type:`collapsible_component`,title:`Processing request`,temp:!0,isSpinny:!0}}),_e(zd.Submitted),d();let s=null,c=null,l=[],_=new Set,v,y=b.current,x=y?.getCurrentFile(),C=y?.getSelectionRange();if(y&&x)try{let e=(await y.getDiagnostics([x])).filter(e=>e.severity===`error`||e.severity===`warning`);e.length>0&&(v=e.map(e=>`${e.file}:${e.line}:${e.column} [${e.severity}] ${e.message}`).join(`
75286
75286
  `))}catch{}try{for await(let e of Te.send(i,{diagnosticIssues:v,currentFile:x??void 0,selectionStartLine:C?.startLine,selectionEndLine:C?.endLine,activeSkills:r})){let t=()=>{c&&=(T({type:`THINKING_COMPLETE`,segId:c,endTime:Date.now()}),null)};switch(e.type){case`text_delta`:{_e(zd.Streaming),p(),f(),t();let n=e.content;s||=crypto.randomUUID(),T({type:`TEXT_DELTA`,segId:s,content:n});break}case`thinking_delta`:{let t=e.content;c||=crypto.randomUUID(),T({type:`THINKING_DELTA`,segId:c,content:t,startTime:Date.now()});break}case`thinking_complete`:t();break;case`tool_display_data`:{let{toolCallId:t,data:n}=e,r=E.current.get(t)??{};E.current.set(t,{...r,...n}),T({type:`TOOL_DISPLAY_DATA`,toolCallId:t,data:n});break}case`tool_call_start`:t(),_.add(e.toolCallId),T({type:`TOOL_CALL_START`,toolCallId:e.toolCallId,toolName:e.toolName,textSegId:s}),s=null;break;case`tool_call_delta`:T({type:`TOOL_CALL_DELTA`,toolCallId:e.toolCallId,argumentsDelta:e.argumentsDelta});break;case`tool_call_stop`:T({type:`TOOL_CALL_STOP`,toolCallId:e.toolCallId,toolName:e.toolName,arguments:e.arguments});break;case`tool_requested`:{let n=e.tool,r=!!n.server_executed;r||(ge.current!==zd.WaitingForToolPermission&&_e(zd.ExecutingTool),p(),d()),t();let i=e.tool.id;if(r||l.push(i),_.has(i)){T({type:`TOOL_CALL_STOP`,toolCallId:i,toolName:e.tool.name,arguments:JSON.stringify(e.tool.input??{})}),s=null;break}let a={id:i,status:r?`completed`:`transient`,source:`bot`,type:`code_llm_tool_call`,toolUseRequest:{id:i,name:e.tool.name,input:e.tool.input,...r&&{server_executed:!0,result:n.result}},toolDisplayData:E.current.get(i)};T({type:`TOOL_REQUESTED`,toolCallId:i,textSegId:s,toolSeg:a}),s=null;break}case`tool_execution_complete`:{p();let t=e.tool.id,{parsedResult:n,...r}=e.result;if(e.tool.server_executed){T({type:`TOOL_EXECUTION_COMPLETE`,toolCallId:t,rawResult:r,...n!==void 0&&{parsedResult:n}}),s=null;break}f();let i={id:crypto.randomUUID(),status:`transient`,source:`bot`,type:`collapsible_component`,title:`Analyzing result`,temp:!0,isSpinny:!0};T({type:`TOOL_EXECUTION_COMPLETE`,toolCallId:t,rawResult:r,...n!==void 0&&{parsedResult:n},spinnySeg:i}),s=null;break}case`notification`:T({type:`ADD_NOTIFICATION`,seg:{id:crypto.randomUUID(),status:`completed`,source:`bot`,type:`code_llm_notification`,severity:e.severity,message:e.message,...e.actions!==void 0&&{actions:e.actions}}});break;case`error`:T({type:`ERROR`,errorSeg:{id:crypto.randomUUID(),status:`completed`,source:`bot`,type:`code_llm_notification`,severity:`error`,message:e.error.message}});break;case`mode_changed`:a(e.mode);break;case`tool_user_message`:T({type:`TOOL_USER_MESSAGE`,seg:{id:crypto.randomUUID(),status:`completed`,source:`user`,type:`text`,segment:e.message}});break;case`retry`:L({attempt:e.attempt,maxAttempts:e.maxAttempts,delayMs:e.delayMs,isNetworkError:e.isNetworkError});break;case`network_status`:e.online?(he.current&&=(clearTimeout(he.current),null),me.current=!0,R(!0),re(!0),L(null),setTimeout(()=>{if(ge.current===zd.Idle&&Te.getQueueEntries().length>0){let e=Te.dq();if(e.length>0){Ee();let t=e.map(e=>e.message).join(`
75287
- `),n=Jq.matchSkill(t.trim());Ie(n?{message:t,activeSkills:[n.skill.id]}:{message:t})}}},0).unref?.()):(me.current=!1,R(!1),he.current||=setTimeout(()=>{he.current=null,me.current||re(!1)},3e4));break;case`user_message_dequeued`:T({type:`INIT_SEND`,userSeg:{id:crypto.randomUUID(),status:`completed`,source:`user`,type:`text`,segment:e.content},spinnySeg:{id:crypto.randomUUID(),status:`transient`,source:`bot`,type:`collapsible_component`,title:`Processing request`,temp:!0,isSpinny:!0}}),Ee(),s=null,c=null,l.length=0;break;case`credits`:pe.current+=e.creditsUsed,ae(t=>t+e.creditsUsed);break;case`connector_auth`:{let t=e.connectorMetadata?.userLevelConnectors??{},n=e.connectorMetadata?.authUrls??{};if(Object.keys(t).length>0){T({type:`ADD_CONNECTOR_AUTH`,seg:{id:crypto.randomUUID(),status:`transient`,source:`bot`,type:`code_llm_connector_auth`,connectorMetadata:t,connectorStatuses:Object.fromEntries(Object.keys(t).map(e=>[e,`PENDING`])),connectorAuthUrls:n}});for(let e of Object.keys(t)){let t=n[e];t&&J3(t)}}break}case`connector_auth_status`:T({type:`UPDATE_CONNECTOR_AUTH`,connectorStatuses:e.connectorsStatus??{}});break;case`session_info`:se(e.contextPercent),le(e.contextTokensUsed),de(e.contextWindowMax);break;case`turn_complete`:T({type:`TURN_COMPLETE`,textSegId:s,toolCallIds:[...l]}),s=null,l.length=0,Ee();break}}}catch(e){if(e instanceof Su)m.isEnvAuth()||(h(!0),g?.()),T({type:`REMOVE_USER_SEG`,userSegId:o}),Oe(`Session expired — use /login to authenticate again.`,`error`,!0);else{let t=Eu(e)?`Unable to connect to API`:e instanceof Error?e.message:`An error occurred`;T({type:`REMOVE_USER_SEG`,userSegId:o}),Oe(t,`error`,!0)}F(i),Te.dq(),Ee()}finally{p(),L(null);let e=Te.getConversationId();e&&ye(e),T({type:`FINALIZE`,textSegId:s}),pe.current>0&&(T({type:`ADD_CREDITS`,seg:{id:`credits-${Date.now()}`,status:`completed`,source:`bot`,type:`code_llm_credits`,creditsUsed:pe.current}}),pe.current=0),_e(zd.Idle),u(`Abacus.AI completed the task`)}},[Te,S,Oe,u,d,f,p,a,m,h]);(0,X.useEffect)(()=>(Te.onAutoRestart=e=>{ge.current===zd.Idle&&Ie({message:e})},()=>{Te.onAutoRestart=null}),[Te,Ie]);let Le=(0,X.useCallback)((e,t)=>{let n=Te.nq(e,t);return Ee(),n},[Te,Ee]),Re=(0,X.useCallback)(e=>{let t=Te.dq(e);return Ee(),t},[Te,Ee]),ze=(0,X.useCallback)((e,t)=>{Te.remove(e,t),Ee()},[Te,Ee]),Be=(0,X.useCallback)((e,t)=>{let n=Te.setContent(e,t);return Ee(),n},[Te,Ee]),Ve=(0,X.useCallback)(e=>{Te.clearQueue(e),Ee()},[Te,Ee]),H=(0,X.useCallback)(()=>{F(null)},[]),He=(0,X.useCallback)(e=>Te.isDirectoryAllowed(e),[Te]),Ue=(0,X.useCallback)((e,t)=>Te.addAllowedDirectory(e,t),[Te]),U=(0,X.useCallback)(()=>Te.listTerminalSessions(),[Te]),We=(0,X.useCallback)(e=>Te.getTerminalSessionOutput(e),[Te]),Ge=(0,X.useCallback)(e=>Te.stopTerminalSession(e),[Te]),Ke=(0,X.useMemo)(()=>({conversationId:ve,conversationTitle:D,segments:w,segmentsLength:w.length,sendMessage:Ie,stop:Me,rejectPendingPermission:Ne,agentStatus:S,clearSegments:ke,clearSegmentsOnly:Ae,clearTempSegments:je,loadConversation:Pe,addNotification:Oe,mcp:Te.mcp,isDirectoryAllowed:He,addAllowedDirectory:Ue,pendingToolPermission:k,refreshMcpTools:Fe,queuedMessages:N,nq:Le,dq:Re,removeFromQueue:ze,setQueuedMessageContent:Be,clearQueue:Ve,dequeuedOnStop:te,clearDequeuedOnStop:H,retryState:I,networkOnline:ne,debouncedNetworkOnline:z,listTerminalSessions:U,getTerminalSessionOutput:We,stopTerminalSession:Ge,totalCredits:ie,contextPercent:oe,contextTokensUsed:ce,contextWindowMax:ue,resolvedConversationLlmName:fe}),[ve,D,w,Ie,Me,Ne,S,ke,Ae,je,Pe,Oe,Te,He,Ue,k,Fe,N,Le,Re,ze,Be,Ve,te,H,I,ne,z,U,We,Ge,ie,oe,ce,ue,fe]);return(0,Z.jsx)($3.Provider,{value:Ke,children:e})});t6.displayName=`AgentProvider`;function n6(){let e=(0,X.use)($3);if(!e)throw Error(`Agent context not found. Did you forget to wrap your component in <${t6.name}>?`);return e}function r6(e){return e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function OWe(e){let t=(0,cQ.c)(42),{toolName:n,status:r,parsedResult:i}=e,{agentStatus:a}=n6(),o;t[0]===n?o=t[1]:(o=r6(n),t[0]=n,t[1]=o);let s=o;if(r===`interrupted`){let e;t[2]===s?e=t[3]:(e=(0,Z.jsx)(h2,{name:s,status:`interrupted`}),t[2]=s,t[3]=e);let n;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(g2,{color:`yellow`,children:`Interrupted · What should I do instead?`}),t[4]=n):n=t[4];let r;return t[5]===e?r=t[6]:(r=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[e,n]}),t[5]=e,t[6]=r),r}if(r===`rejected`){if(i?.userNote){let e;t[7]===s?e=t[8]:(e=(0,Z.jsx)(h2,{name:s,status:`rejected`}),t[7]=s,t[8]=e);let n;t[9]===i.userNote?n=t[10]:(n=(0,Z.jsxs)(g2,{color:`yellow`,children:[`Rejected · `,(0,Z.jsxs)($,{italic:!0,children:[`"`,i.userNote,`"`]})]}),t[9]=i.userNote,t[10]=n);let r;return t[11]!==e||t[12]!==n?(r=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[e,n]}),t[11]=e,t[12]=n,t[13]=r):r=t[13],r}let e;t[14]===s?e=t[15]:(e=(0,Z.jsx)(h2,{name:s,status:`rejected`}),t[14]=s,t[15]=e);let n;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(g2,{color:`yellow`,children:`Rejected`}),t[16]=n):n=t[16];let r;return t[17]===e?r=t[18]:(r=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[e,n]}),t[17]=e,t[18]=r),r}if(r===`error`){let e;t[19]===s?e=t[20]:(e=(0,Z.jsx)(h2,{name:s,status:`error`}),t[19]=s,t[20]=e);let n=i?.errorMessage??i?.summary??`MCP tool execution failed`,r;t[21]===n?r=t[22]:(r=(0,Z.jsx)(g2,{color:`red`,children:n}),t[21]=n,t[22]=r);let a;return t[23]!==e||t[24]!==r?(a=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[e,r]}),t[23]=e,t[24]=r,t[25]=a):a=t[25],a}let c=a===zd.WaitingForToolPermission&&!i,l=!i&&(a===zd.Streaming||a===zd.ExecutingTool),u=i?.phase===`error`;if(c){let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)($,{color:`yellow`,children:`●`}),t[26]=e):e=t[26];let n;return t[27]===s?n=t[28]:(n=(0,Z.jsxs)(Q,{flexDirection:`row`,gap:1,children:[e,(0,Z.jsx)($,{color:`cyan`,children:s})]}),t[27]=s,t[28]=n),n}if(l){let e;return t[29]===s?e=t[30]:(e=(0,Z.jsx)(h2,{name:s,status:`pending`,showSpinner:!0}),t[29]=s,t[30]=e),e}if(i){let e=u?`error`:`success`,n;t[31]!==s||t[32]!==e?(n=(0,Z.jsx)(h2,{name:s,status:e}),t[31]=s,t[32]=e,t[33]=n):n=t[33];let r=u?`red`:`brightblack`,a=u?`Error: ${i.errorMessage??i.summary??`Tool execution failed`}`:i.summary??`Executed successfully`,o;t[34]!==r||t[35]!==a?(o=(0,Z.jsx)(g2,{color:r,children:a}),t[34]=r,t[35]=a,t[36]=o):o=t[36];let c;return t[37]!==n||t[38]!==o?(c=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[n,o]}),t[37]=n,t[38]=o,t[39]=c):c=t[39],c}let d;return t[40]===s?d=t[41]:(d=(0,Z.jsx)(Q,{flexDirection:`column`,children:(0,Z.jsx)(h2,{name:s,status:`pending`})}),t[40]=s,t[41]=d),d}function kWe(e){return{displayName:r6(e),getHeaderParams(e){return``},renderUI(t,n,r){return(0,Z.jsx)(OWe,{toolName:e,rawInput:t,status:n,parsedResult:r})}}}function i6(e){let t=[];return e.pattern&&t.push(`pattern: "${e.pattern}"`),e.path&&t.push(`path: "${e.path}"`),t.length>0?t.join(`, `):`[no pattern]`}const AWe={displayName:`Search`,getHeaderParams(e){try{return i6(e)}catch{return`[unknown]`}},renderUI(e,t,n){let r=i6(e);return t===`error`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`Search`,params:r,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Error matching files`})]}):t===`executing`?(0,Z.jsx)(h2,{name:`Search`,params:r,status:`executing`,showSpinner:!0}):n?(0,Z.jsx)(jWe,{searchParams:r,parsedResult:n}):(0,Z.jsx)(Q,{flexDirection:`column`,children:(0,Z.jsx)(h2,{name:`Search`,params:r,status:`pending`})})}};function jWe(e){let t=(0,cQ.c)(9),{searchParams:n,parsedResult:r}=e,i=(0,X.useContext)(P2),a;if(t[0]!==i||t[1]!==r.data.files||t[2]!==r.summary||t[3]!==n){let e=r.data.files??[],o=i?30:10,s=e.slice(0,o),c=e.length-s.length,l;t[5]===n?l=t[6]:(l=(0,Z.jsx)(h2,{name:`Search`,params:n,status:`success`}),t[5]=n,t[6]=l);let u;t[7]===r.summary?u=t[8]:(u=(0,Z.jsx)(g2,{children:r.summary}),t[7]=r.summary,t[8]=u),a=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[l,u,e.length>0&&(0,Z.jsxs)(_2,{children:[s.map(MWe),c>0&&(0,Z.jsxs)($,{dimColor:!0,children:[`… +`,c,` more file`,c===1?``:`s`]})]})]}),t[0]=i,t[1]=r.data.files,t[2]=r.summary,t[3]=n,t[4]=a}else a=t[4];return a}function MWe(e,t){return(0,Z.jsx)($,{dimColor:!0,children:e},t)}function a6(e){let t=e,n=[];t.pattern&&n.push(`pattern: "${t.pattern}"`),t.path&&n.push(`path: "${t.path}"`);let r=t.outputMode||e.output_mode;return r&&n.push(`outputMode: "${r}"`),t.glob&&n.push(`glob: "${t.glob}"`),t[`-i`]&&n.push(`case-insensitive`),n.length>0?n.join(`, `):`[no pattern]`}const NWe={displayName:`Search`,getHeaderParams(e){try{return a6(e)}catch{return`[unknown]`}},renderUI(e,t,n){let r=a6(e);return t===`error`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`Search`,params:r,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Error searching content`})]}):t===`executing`?(0,Z.jsx)(h2,{name:`Search`,params:r,status:`executing`,showSpinner:!0}):n?(0,Z.jsx)(PWe,{searchParams:r,parsedResult:n}):(0,Z.jsx)(Q,{flexDirection:`column`,children:(0,Z.jsx)(h2,{name:`Search`,params:r,status:`pending`})})}};function PWe(e){let t=(0,cQ.c)(9),{searchParams:n,parsedResult:r}=e,i=(0,X.useContext)(P2),a;if(t[0]!==i||t[1]!==r.data.matches||t[2]!==r.summary||t[3]!==n){let e=r.data.matches??[],o=i?30:10,s=e.slice(0,o),c=e.length-s.length,l;t[5]===n?l=t[6]:(l=(0,Z.jsx)(h2,{name:`Search`,params:n,status:`success`}),t[5]=n,t[6]=l);let u;t[7]===r.summary?u=t[8]:(u=(0,Z.jsx)(g2,{children:r.summary}),t[7]=r.summary,t[8]=u),a=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[l,u,e.length>0&&(0,Z.jsxs)(_2,{children:[s.map(FWe),c>0&&(0,Z.jsxs)($,{dimColor:!0,children:[`… +`,c,` more match`,c===1?``:`es`]})]})]}),t[0]=i,t[1]=r.data.matches,t[2]=r.summary,t[3]=n,t[4]=a}else a=t[4];return a}function FWe(e,t){return(0,Z.jsx)($,{dimColor:!0,children:e},t)}const IWe=PR({url:Y()}),LWe={displayName:`Web Fetch`,getHeaderParams(e){try{let t=e?.url||``;return t.length>50?t.substring(0,47)+`...`:t}catch{return`[unknown]`}},renderUI(e,t,n){let r=IWe.safeParse(w2(e));if(!r.success)return(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`Fetch`,params:``,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Invalid params`})]});let i=r.data.url||``,a=i.length>50?i.substring(0,47)+`...`:i;return t===`error`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`Fetch`,params:a,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Error fetching URL`})]}):t===`executing`?(0,Z.jsx)(h2,{name:`Fetch`,params:a,status:`executing`,showSpinner:!0}):n?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`Fetch`,params:a,status:`success`}),(0,Z.jsx)(g2,{children:n.summary??`Fetched content`})]}):(0,Z.jsx)(Q,{flexDirection:`column`,children:(0,Z.jsx)(h2,{name:`Fetch`,params:a,status:`pending`})})}},RWe=PR({searchTerm:Y(),query:Y().optional(),explanation:Y().optional(),allowedDomains:MR(Y()).optional(),blockedDomains:MR(Y()).optional()}),zWe={displayName:`WebSearch`,getHeaderParams(e){try{return`"${e?.searchTerm||e?.search_term||e?.query||`[no query]`}"`}catch{return`[unknown]`}},renderUI(e,t,n){let r=RWe.safeParse(w2(e));if(!r.success)return(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`WebSearch`,params:``,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Invalid params`})]});let i=r.data,a=i.searchTerm||i.query||``,o=`"${a.length>40?a.substring(0,37)+`...`:a}"`;return t===`error`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`WebSearch`,params:o,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Error performing web search`})]}):t===`executing`?(0,Z.jsx)(h2,{name:`WebSearch`,params:o,status:`executing`,showSpinner:!0}):(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`WebSearch`,params:o,status:`success`}),(0,Z.jsx)(g2,{children:`Found results`})]})}},BWe=PR({shellId:Y(),filter:Y().optional()}),VWe={displayName:`BashOutput`,getHeaderParams(e){try{let t=e,n=[`id: ${t.shellId||``}`];return t.filter&&n.push(`filter: ${t.filter}`),n.join(`, `)}catch{return`[unknown]`}},renderUI(e,t,n){let r=BWe.safeParse(w2(e));if(!r.success)return(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`BashOutput`,params:``,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Invalid params`})]});let i=`id: ${r.data.shellId}`;return t===`interrupted`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`BashOutput`,params:i,status:`interrupted`}),(0,Z.jsx)(g2,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`BashOutput`,params:i,status:`rejected`}),n?.userNote?(0,Z.jsxs)(g2,{color:`yellow`,children:[`Rejected · `,(0,Z.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Z.jsx)(g2,{color:`yellow`,children:`Rejected`})]}):!n&&(t===`executing`||t===`pending`)?(0,Z.jsx)(h2,{name:`BashOutput`,params:i,status:`pending`,showSpinner:!0}):n?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`BashOutput`,params:i,status:`success`}),(0,Z.jsx)(g2,{children:n.summary})]}):(0,Z.jsx)(Q,{flexDirection:`column`,children:(0,Z.jsx)(h2,{name:`BashOutput`,params:i,status:`pending`})})}};var HWe=class{startTime;constructor(){this.startTime=performance.now()}getElapsedSeconds(){return(performance.now()-this.startTime)/1e3}getElapsedMs(){return performance.now()-this.startTime}getFormattedDuration(){return o6(this.getElapsedMs())}reset(){this.startTime=performance.now()}};function o6(e){let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=[];return n>0&&a.push(`${n}h`),r>0&&a.push(`${r}m`),(i>0||a.length===0)&&a.push(`${i}s`),a.join(` `)}function UWe(e,t,n){let r=n?50:t,i=e.split(`
75287
+ `),n=Jq.matchSkill(t.trim());Ie(n?{message:t,activeSkills:[n.skill.id]}:{message:t})}}},0).unref?.()):(me.current=!1,R(!1),he.current||=setTimeout(()=>{he.current=null,me.current||re(!1)},3e4));break;case`user_message_dequeued`:T({type:`INIT_SEND`,userSeg:{id:crypto.randomUUID(),status:`completed`,source:`user`,type:`text`,segment:e.content},spinnySeg:{id:crypto.randomUUID(),status:`transient`,source:`bot`,type:`collapsible_component`,title:`Processing request`,temp:!0,isSpinny:!0}}),Ee(),s=null,c=null,l.length=0;break;case`credits`:pe.current+=e.creditsUsed,ae(t=>t+e.creditsUsed);break;case`connector_auth`:{let t=e.connectorMetadata?.userLevelConnectors??{},n=e.connectorMetadata?.authUrls??{};if(Object.keys(t).length>0){T({type:`ADD_CONNECTOR_AUTH`,seg:{id:crypto.randomUUID(),status:`transient`,source:`bot`,type:`code_llm_connector_auth`,connectorMetadata:t,connectorStatuses:Object.fromEntries(Object.keys(t).map(e=>[e,`PENDING`])),connectorAuthUrls:n}});for(let e of Object.keys(t)){let t=n[e];t&&J3(t)}}break}case`connector_auth_status`:T({type:`UPDATE_CONNECTOR_AUTH`,connectorStatuses:e.connectorsStatus??{}});break;case`session_info`:se(e.contextPercent),le(e.contextTokensUsed),de(e.contextWindowMax);break;case`turn_complete`:T({type:`TURN_COMPLETE`,textSegId:s,toolCallIds:[...l]}),s=null,l.length=0,Ee();break}}}catch(e){if(e instanceof Su)m.isEnvAuth()||(h(!0),g?.()),T({type:`REMOVE_USER_SEG`,userSegId:o}),Oe(`Session expired — use /login to authenticate again.`,`error`,!0);else{let t=Eu(e)?`Unable to connect to API`:e instanceof Error?e.message:`An error occurred`;T({type:`REMOVE_USER_SEG`,userSegId:o}),Oe(t,`error`,!0)}F(i),Te.dq(),Ee()}finally{p(),L(null);let e=Te.getConversationId();e&&ye(e),T({type:`FINALIZE`,textSegId:s}),pe.current>0&&(T({type:`ADD_CREDITS`,seg:{id:`credits-${Date.now()}`,status:`completed`,source:`bot`,type:`code_llm_credits`,creditsUsed:pe.current}}),pe.current=0),_e(zd.Idle),u(`Abacus.AI completed the task`)}},[Te,S,Oe,u,d,f,p,a,m,h]);(0,X.useEffect)(()=>(Te.onAutoRestart=e=>{ge.current===zd.Idle&&Ie({message:e})},()=>{Te.onAutoRestart=null}),[Te,Ie]);let Le=(0,X.useCallback)((e,t)=>{let n=Te.nq(e,t);return Ee(),n},[Te,Ee]),Re=(0,X.useCallback)(e=>{let t=Te.dq(e);return Ee(),t},[Te,Ee]),ze=(0,X.useCallback)((e,t)=>{Te.remove(e,t),Ee()},[Te,Ee]),Be=(0,X.useCallback)((e,t)=>{let n=Te.setContent(e,t);return Ee(),n},[Te,Ee]),Ve=(0,X.useCallback)(e=>{Te.clearQueue(e),Ee()},[Te,Ee]),H=(0,X.useCallback)(()=>{F(null)},[]),He=(0,X.useCallback)(e=>Te.isDirectoryAllowed(e),[Te]),Ue=(0,X.useCallback)((e,t)=>Te.addAllowedDirectory(e,t),[Te]),U=(0,X.useCallback)(()=>Te.listTerminalSessions(),[Te]),We=(0,X.useCallback)(e=>Te.getTerminalSessionOutput(e),[Te]),Ge=(0,X.useCallback)(e=>Te.stopTerminalSession(e),[Te]),Ke=(0,X.useMemo)(()=>({conversationId:ve,conversationTitle:D,segments:w,segmentsLength:w.length,sendMessage:Ie,stop:Me,rejectPendingPermission:Ne,agentStatus:S,clearSegments:ke,clearSegmentsOnly:Ae,clearTempSegments:je,loadConversation:Pe,addNotification:Oe,mcp:Te.mcp,isDirectoryAllowed:He,addAllowedDirectory:Ue,pendingToolPermission:k,refreshMcpTools:Fe,queuedMessages:N,nq:Le,dq:Re,removeFromQueue:ze,setQueuedMessageContent:Be,clearQueue:Ve,dequeuedOnStop:te,clearDequeuedOnStop:H,retryState:I,networkOnline:ne,debouncedNetworkOnline:z,listTerminalSessions:U,getTerminalSessionOutput:We,stopTerminalSession:Ge,totalCredits:ie,contextPercent:oe,contextTokensUsed:ce,contextWindowMax:ue,resolvedConversationLlmName:fe,initialModel:r?.model??null}),[ve,D,w,Ie,Me,Ne,S,ke,Ae,je,Pe,Oe,Te,He,Ue,k,Fe,N,Le,Re,ze,Be,Ve,te,H,I,ne,z,U,We,Ge,ie,oe,ce,ue,fe,r?.model]);return(0,Z.jsx)($3.Provider,{value:Ke,children:e})});t6.displayName=`AgentProvider`;function n6(){let e=(0,X.use)($3);if(!e)throw Error(`Agent context not found. Did you forget to wrap your component in <${t6.name}>?`);return e}function r6(e){return e.split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function OWe(e){let t=(0,cQ.c)(42),{toolName:n,status:r,parsedResult:i}=e,{agentStatus:a}=n6(),o;t[0]===n?o=t[1]:(o=r6(n),t[0]=n,t[1]=o);let s=o;if(r===`interrupted`){let e;t[2]===s?e=t[3]:(e=(0,Z.jsx)(h2,{name:s,status:`interrupted`}),t[2]=s,t[3]=e);let n;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(g2,{color:`yellow`,children:`Interrupted · What should I do instead?`}),t[4]=n):n=t[4];let r;return t[5]===e?r=t[6]:(r=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[e,n]}),t[5]=e,t[6]=r),r}if(r===`rejected`){if(i?.userNote){let e;t[7]===s?e=t[8]:(e=(0,Z.jsx)(h2,{name:s,status:`rejected`}),t[7]=s,t[8]=e);let n;t[9]===i.userNote?n=t[10]:(n=(0,Z.jsxs)(g2,{color:`yellow`,children:[`Rejected · `,(0,Z.jsxs)($,{italic:!0,children:[`"`,i.userNote,`"`]})]}),t[9]=i.userNote,t[10]=n);let r;return t[11]!==e||t[12]!==n?(r=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[e,n]}),t[11]=e,t[12]=n,t[13]=r):r=t[13],r}let e;t[14]===s?e=t[15]:(e=(0,Z.jsx)(h2,{name:s,status:`rejected`}),t[14]=s,t[15]=e);let n;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(g2,{color:`yellow`,children:`Rejected`}),t[16]=n):n=t[16];let r;return t[17]===e?r=t[18]:(r=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[e,n]}),t[17]=e,t[18]=r),r}if(r===`error`){let e;t[19]===s?e=t[20]:(e=(0,Z.jsx)(h2,{name:s,status:`error`}),t[19]=s,t[20]=e);let n=i?.errorMessage??i?.summary??`MCP tool execution failed`,r;t[21]===n?r=t[22]:(r=(0,Z.jsx)(g2,{color:`red`,children:n}),t[21]=n,t[22]=r);let a;return t[23]!==e||t[24]!==r?(a=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[e,r]}),t[23]=e,t[24]=r,t[25]=a):a=t[25],a}let c=a===zd.WaitingForToolPermission&&!i,l=!i&&(a===zd.Streaming||a===zd.ExecutingTool),u=i?.phase===`error`;if(c){let e;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)($,{color:`yellow`,children:`●`}),t[26]=e):e=t[26];let n;return t[27]===s?n=t[28]:(n=(0,Z.jsxs)(Q,{flexDirection:`row`,gap:1,children:[e,(0,Z.jsx)($,{color:`cyan`,children:s})]}),t[27]=s,t[28]=n),n}if(l){let e;return t[29]===s?e=t[30]:(e=(0,Z.jsx)(h2,{name:s,status:`pending`,showSpinner:!0}),t[29]=s,t[30]=e),e}if(i){let e=u?`error`:`success`,n;t[31]!==s||t[32]!==e?(n=(0,Z.jsx)(h2,{name:s,status:e}),t[31]=s,t[32]=e,t[33]=n):n=t[33];let r=u?`red`:`brightblack`,a=u?`Error: ${i.errorMessage??i.summary??`Tool execution failed`}`:i.summary??`Executed successfully`,o;t[34]!==r||t[35]!==a?(o=(0,Z.jsx)(g2,{color:r,children:a}),t[34]=r,t[35]=a,t[36]=o):o=t[36];let c;return t[37]!==n||t[38]!==o?(c=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[n,o]}),t[37]=n,t[38]=o,t[39]=c):c=t[39],c}let d;return t[40]===s?d=t[41]:(d=(0,Z.jsx)(Q,{flexDirection:`column`,children:(0,Z.jsx)(h2,{name:s,status:`pending`})}),t[40]=s,t[41]=d),d}function kWe(e){return{displayName:r6(e),getHeaderParams(e){return``},renderUI(t,n,r){return(0,Z.jsx)(OWe,{toolName:e,rawInput:t,status:n,parsedResult:r})}}}function i6(e){let t=[];return e.pattern&&t.push(`pattern: "${e.pattern}"`),e.path&&t.push(`path: "${e.path}"`),t.length>0?t.join(`, `):`[no pattern]`}const AWe={displayName:`Search`,getHeaderParams(e){try{return i6(e)}catch{return`[unknown]`}},renderUI(e,t,n){let r=i6(e);return t===`error`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`Search`,params:r,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Error matching files`})]}):t===`executing`?(0,Z.jsx)(h2,{name:`Search`,params:r,status:`executing`,showSpinner:!0}):n?(0,Z.jsx)(jWe,{searchParams:r,parsedResult:n}):(0,Z.jsx)(Q,{flexDirection:`column`,children:(0,Z.jsx)(h2,{name:`Search`,params:r,status:`pending`})})}};function jWe(e){let t=(0,cQ.c)(9),{searchParams:n,parsedResult:r}=e,i=(0,X.useContext)(P2),a;if(t[0]!==i||t[1]!==r.data.files||t[2]!==r.summary||t[3]!==n){let e=r.data.files??[],o=i?30:10,s=e.slice(0,o),c=e.length-s.length,l;t[5]===n?l=t[6]:(l=(0,Z.jsx)(h2,{name:`Search`,params:n,status:`success`}),t[5]=n,t[6]=l);let u;t[7]===r.summary?u=t[8]:(u=(0,Z.jsx)(g2,{children:r.summary}),t[7]=r.summary,t[8]=u),a=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[l,u,e.length>0&&(0,Z.jsxs)(_2,{children:[s.map(MWe),c>0&&(0,Z.jsxs)($,{dimColor:!0,children:[`… +`,c,` more file`,c===1?``:`s`]})]})]}),t[0]=i,t[1]=r.data.files,t[2]=r.summary,t[3]=n,t[4]=a}else a=t[4];return a}function MWe(e,t){return(0,Z.jsx)($,{dimColor:!0,children:e},t)}function a6(e){let t=e,n=[];t.pattern&&n.push(`pattern: "${t.pattern}"`),t.path&&n.push(`path: "${t.path}"`);let r=t.outputMode||e.output_mode;return r&&n.push(`outputMode: "${r}"`),t.glob&&n.push(`glob: "${t.glob}"`),t[`-i`]&&n.push(`case-insensitive`),n.length>0?n.join(`, `):`[no pattern]`}const NWe={displayName:`Search`,getHeaderParams(e){try{return a6(e)}catch{return`[unknown]`}},renderUI(e,t,n){let r=a6(e);return t===`error`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`Search`,params:r,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Error searching content`})]}):t===`executing`?(0,Z.jsx)(h2,{name:`Search`,params:r,status:`executing`,showSpinner:!0}):n?(0,Z.jsx)(PWe,{searchParams:r,parsedResult:n}):(0,Z.jsx)(Q,{flexDirection:`column`,children:(0,Z.jsx)(h2,{name:`Search`,params:r,status:`pending`})})}};function PWe(e){let t=(0,cQ.c)(9),{searchParams:n,parsedResult:r}=e,i=(0,X.useContext)(P2),a;if(t[0]!==i||t[1]!==r.data.matches||t[2]!==r.summary||t[3]!==n){let e=r.data.matches??[],o=i?30:10,s=e.slice(0,o),c=e.length-s.length,l;t[5]===n?l=t[6]:(l=(0,Z.jsx)(h2,{name:`Search`,params:n,status:`success`}),t[5]=n,t[6]=l);let u;t[7]===r.summary?u=t[8]:(u=(0,Z.jsx)(g2,{children:r.summary}),t[7]=r.summary,t[8]=u),a=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[l,u,e.length>0&&(0,Z.jsxs)(_2,{children:[s.map(FWe),c>0&&(0,Z.jsxs)($,{dimColor:!0,children:[`… +`,c,` more match`,c===1?``:`es`]})]})]}),t[0]=i,t[1]=r.data.matches,t[2]=r.summary,t[3]=n,t[4]=a}else a=t[4];return a}function FWe(e,t){return(0,Z.jsx)($,{dimColor:!0,children:e},t)}const IWe=PR({url:Y()}),LWe={displayName:`Web Fetch`,getHeaderParams(e){try{let t=e?.url||``;return t.length>50?t.substring(0,47)+`...`:t}catch{return`[unknown]`}},renderUI(e,t,n){let r=IWe.safeParse(w2(e));if(!r.success)return(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`Fetch`,params:``,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Invalid params`})]});let i=r.data.url||``,a=i.length>50?i.substring(0,47)+`...`:i;return t===`error`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`Fetch`,params:a,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Error fetching URL`})]}):t===`executing`?(0,Z.jsx)(h2,{name:`Fetch`,params:a,status:`executing`,showSpinner:!0}):n?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`Fetch`,params:a,status:`success`}),(0,Z.jsx)(g2,{children:n.summary??`Fetched content`})]}):(0,Z.jsx)(Q,{flexDirection:`column`,children:(0,Z.jsx)(h2,{name:`Fetch`,params:a,status:`pending`})})}},RWe=PR({searchTerm:Y(),query:Y().optional(),explanation:Y().optional(),allowedDomains:MR(Y()).optional(),blockedDomains:MR(Y()).optional()}),zWe={displayName:`WebSearch`,getHeaderParams(e){try{return`"${e?.searchTerm||e?.search_term||e?.query||`[no query]`}"`}catch{return`[unknown]`}},renderUI(e,t,n){let r=RWe.safeParse(w2(e));if(!r.success)return(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`WebSearch`,params:``,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Invalid params`})]});let i=r.data,a=i.searchTerm||i.query||``,o=`"${a.length>40?a.substring(0,37)+`...`:a}"`;return t===`error`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`WebSearch`,params:o,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Error performing web search`})]}):t===`executing`?(0,Z.jsx)(h2,{name:`WebSearch`,params:o,status:`executing`,showSpinner:!0}):(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`WebSearch`,params:o,status:`success`}),(0,Z.jsx)(g2,{children:`Found results`})]})}},BWe=PR({shellId:Y(),filter:Y().optional()}),VWe={displayName:`BashOutput`,getHeaderParams(e){try{let t=e,n=[`id: ${t.shellId||``}`];return t.filter&&n.push(`filter: ${t.filter}`),n.join(`, `)}catch{return`[unknown]`}},renderUI(e,t,n){let r=BWe.safeParse(w2(e));if(!r.success)return(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`BashOutput`,params:``,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Invalid params`})]});let i=`id: ${r.data.shellId}`;return t===`interrupted`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`BashOutput`,params:i,status:`interrupted`}),(0,Z.jsx)(g2,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`BashOutput`,params:i,status:`rejected`}),n?.userNote?(0,Z.jsxs)(g2,{color:`yellow`,children:[`Rejected · `,(0,Z.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Z.jsx)(g2,{color:`yellow`,children:`Rejected`})]}):!n&&(t===`executing`||t===`pending`)?(0,Z.jsx)(h2,{name:`BashOutput`,params:i,status:`pending`,showSpinner:!0}):n?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`BashOutput`,params:i,status:`success`}),(0,Z.jsx)(g2,{children:n.summary})]}):(0,Z.jsx)(Q,{flexDirection:`column`,children:(0,Z.jsx)(h2,{name:`BashOutput`,params:i,status:`pending`})})}};var HWe=class{startTime;constructor(){this.startTime=performance.now()}getElapsedSeconds(){return(performance.now()-this.startTime)/1e3}getElapsedMs(){return performance.now()-this.startTime}getFormattedDuration(){return o6(this.getElapsedMs())}reset(){this.startTime=performance.now()}};function o6(e){let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=[];return n>0&&a.push(`${n}h`),r>0&&a.push(`${r}m`),(i>0||a.length===0)&&a.push(`${i}s`),a.join(` `)}function UWe(e,t,n){let r=n?50:t,i=e.split(`
75288
75288
  `).filter(Boolean);return i.length<=r?{lines:i,isTruncated:!1,hiddenCount:0}:{lines:i.slice(0,r),isTruncated:!0,hiddenCount:i.length-r}}function WWe(e){let t=(0,cQ.c)(5),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=Date.now(),t[0]=n):n=t[0];let[r]=(0,X.useState)(n),[i,a]=(0,X.useState)(0),o,s;return t[1]!==e||t[2]!==r?(o=()=>{if(!e)return;let t=setInterval(()=>{a(Date.now()-r)},1e3);return()=>clearInterval(t)},s=[e,r],t[1]=e,t[2]=r,t[3]=o,t[4]=s):(o=t[3],s=t[4]),(0,X.useEffect)(o,s),i}function GWe(e){let t=(0,cQ.c)(42),{command:n,toolCallId:r,executionResult:i}=e,{agentStatus:a}=n6(),o=(0,X.useContext)(P2),[s,c]=(0,X.useState)(!1),l=s||o,u=!i&&(a===zd.Streaming||a===zd.ExecutingTool),d=WWe(u),f=d>=5e3,p=(0,X.useDeferredValue)(i?.output||``),m;t[0]!==p||t[1]!==l?(m=UWe(p,7,l),t[0]=p,t[1]=l,t[2]=m):m=t[2];let{lines:h,isTruncated:g,hiddenCount:_}=m,v=!o&&!u&&i!==void 0&&(g||s),y=`bash-tool-${r}`,b;t[3]!==v||t[4]!==y?(b={id:y,isActive:v},t[3]=v,t[4]=y,t[5]=b):b=t[5];let{isFocused:x}=dQ(b),S;t[6]===x?S=t[7]:(S=(e,t)=>{x&&t.ctrl&&e===`o`&&c(KWe)},t[6]=x,t[7]=S);let C=x&&v,w;t[8]===C?w=t[9]:(w={isActive:C},t[8]=C,t[9]=w),uQ(S,w);let T=n.length>500?n.slice(0,500)+`…`:n,E=i?.exitCode??0,D=i?.status===`error`||E!==0,O=u?`pending`:D?`error`:`success`;if(u){let e;t[10]!==d||t[11]!==f?(e=f?o6(d):null,t[10]=d,t[11]=f,t[12]=e):e=t[12];let n=e,r;t[13]!==T||t[14]!==O?(r=(0,Z.jsx)(h2,{name:`Bash`,params:T,paramsLanguage:`bash`,status:O,showSpinner:!0}),t[13]=T,t[14]=O,t[15]=r):r=t[15];let i=n?` ${n}`:null,a;t[16]===i?a=t[17]:(a=(0,Z.jsxs)(g2,{color:`brightblack`,children:[`Running…`,i]}),t[16]=i,t[17]=a);let o;return t[18]!==a||t[19]!==r?(o=(0,Z.jsxs)(Q,{flexDirection:`column`,gap:0,children:[r,a]}),t[18]=a,t[19]=r,t[20]=o):o=t[20],o}if(i){let e=h.length>0,n=i.duration??0,r;t[21]===n?r=t[22]:(r=NVe(n),t[21]=n,t[22]=r);let a=`exit ${E} (${r})`,o;t[23]!==T||t[24]!==O?(o=(0,Z.jsx)(h2,{name:`Bash`,params:T,paramsLanguage:`bash`,status:O}),t[23]=T,t[24]=O,t[25]=o):o=t[25];let s;t[26]!==l||t[27]!==e||t[28]!==_||t[29]!==D||t[30]!==g||t[31]!==h?(s=(0,Z.jsx)(_2,{children:e?(0,Z.jsxs)(Z.Fragment,{children:[D&&(0,Z.jsx)($,{color:`red`,dimColor:!0,children:`Error:`}),h.map((e,t)=>(0,Z.jsx)($,{color:D?`red`:void 0,dimColor:!0,children:e},t)),g&&(0,Z.jsxs)($,{dimColor:!0,children:[`… +`,_,` `,l?`more `:``,`line`,_===1?``:`s`,l?``:` (ctrl+o to expand)`]})]}):(0,Z.jsx)($,{dimColor:!0,children:`(no content)`})}),t[26]=l,t[27]=e,t[28]=_,t[29]=D,t[30]=g,t[31]=h,t[32]=s):s=t[32];let c=D?`red`:`brightblack`,u;t[33]!==a||t[34]!==c?(u=(0,Z.jsx)(g2,{color:c,children:a}),t[33]=a,t[34]=c,t[35]=u):u=t[35];let d;return t[36]!==s||t[37]!==u||t[38]!==o?(d=(0,Z.jsxs)(Q,{flexDirection:`column`,gap:0,children:[o,s,u]}),t[36]=s,t[37]=u,t[38]=o,t[39]=d):d=t[39],d}let k;return t[40]===T?k=t[41]:(k=(0,Z.jsx)(Q,{flexDirection:`column`,children:(0,Z.jsx)(h2,{name:`Bash`,params:T,paramsLanguage:`bash`,status:`pending`})}),t[40]=T,t[41]=k),k}function KWe(e){return!e}const qWe=PR({command:Y(),explanation:Y().optional(),runInBackground:k2,shellId:Y().optional(),interactiveMode:k2,timeout:nz().optional()});function JWe(e){let t=(0,cQ.c)(40),{rawInput:n,status:r,parsedResult:i}=e,a,o,s;if(t[0]!==n){s=Symbol.for(`react.early_return_sentinel`);bb0:{let e=qWe.safeParse(w2(n));if(!e.success){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`Bash`,params:``,paramsLanguage:`bash`,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Invalid params`})]}),t[4]=e):e=t[4],s=e;break bb0}a=e.data;let r=a.command||``;o=r.length>500?r.slice(0,500)+`…`:r}t[0]=n,t[1]=a,t[2]=o,t[3]=s}else a=t[1],o=t[2],s=t[3];if(s!==Symbol.for(`react.early_return_sentinel`))return s;let c=o,l;t[5]===a.timeout?l=t[6]:(l=a.timeout?` (timeout: ${(a.timeout/1e3).toFixed(0)}s)`:``,t[5]=a.timeout,t[6]=l);let u=l;if(r===`interrupted`){let e;t[7]===c?e=t[8]:(e=(0,Z.jsx)(h2,{name:`Bash`,params:c,paramsLanguage:`bash`,status:`interrupted`}),t[7]=c,t[8]=e);let n;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(g2,{color:`yellow`,children:`Interrupted · What should I do instead?`}),t[9]=n):n=t[9];let r;return t[10]===e?r=t[11]:(r=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[e,n]}),t[10]=e,t[11]=r),r}if(r===`rejected`){if(i?.userNote){let e;t[12]===c?e=t[13]:(e=(0,Z.jsx)(h2,{name:`Bash`,params:c,paramsLanguage:`bash`,status:`rejected`}),t[12]=c,t[13]=e);let n;t[14]===i.userNote?n=t[15]:(n=(0,Z.jsxs)(g2,{color:`yellow`,children:[`Rejected · `,(0,Z.jsxs)($,{italic:!0,children:[`"`,i.userNote,`"`]})]}),t[14]=i.userNote,t[15]=n);let r;return t[16]!==e||t[17]!==n?(r=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[e,n]}),t[16]=e,t[17]=n,t[18]=r):r=t[18],r}let e;t[19]===c?e=t[20]:(e=(0,Z.jsx)(h2,{name:`Bash`,params:c,paramsLanguage:`bash`,status:`rejected`}),t[19]=c,t[20]=e);let n;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsx)(g2,{color:`yellow`,children:`Rejected`}),t[21]=n):n=t[21];let r;return t[22]===e?r=t[23]:(r=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[e,n]}),t[22]=e,t[23]=r),r}if(i?.data?.timedOut){let e=`${c}${u}`,n;t[24]===e?n=t[25]:(n=(0,Z.jsx)(h2,{name:`Bash`,params:e,paramsLanguage:`bash`,status:`success`}),t[24]=e,t[25]=n);let r;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(g2,{children:`Running in the background`}),t[26]=r):r=t[26];let i;return t[27]===n?i=t[28]:(i=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[n,r]}),t[27]=n,t[28]=i),i}if(i?.runInBackground){let e=`${c}${u}`,n;t[29]===e?n=t[30]:(n=(0,Z.jsx)(h2,{name:`Bash`,params:e,paramsLanguage:`bash`,status:`success`}),t[29]=e,t[30]=n);let r;t[31]===i.summary?r=t[32]:(r=(0,Z.jsx)(g2,{children:i.summary}),t[31]=i.summary,t[32]=r);let a;return t[33]!==n||t[34]!==r?(a=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[n,r]}),t[33]=n,t[34]=r,t[35]=a):a=t[35],a}let d=n?.id||`unknown`,f=i?.data,p=`${c}${u}`,m;return t[36]!==f||t[37]!==p||t[38]!==d?(m=(0,Z.jsx)(GWe,{command:p,toolCallId:d,executionResult:f}),t[36]=f,t[37]=p,t[38]=d,t[39]=m):m=t[39],m}const YWe={displayName:`Bash`,getHeaderParams(e){try{return e?.command||`[no command]`}catch{return`[unknown]`}},renderUI(e,t,n){return(0,Z.jsx)(JWe,{rawInput:e,status:t,parsedResult:n})}},XWe=PR({shellId:Y()}),s6={read:XHe,delete:xHe,write:nUe,edit:FHe,notebook_edit:zHe,grep:NWe,glob:AWe,web_search:zWe,web_fetch:LWe,bash:YWe,bash_output:VWe,kill_shell:{displayName:`KillShell`,getHeaderParams(e){try{return`id: ${e.shellId||``}`}catch{return`[unknown]`}},renderUI(e,t,n){let r=XWe.safeParse(w2(e));if(!r.success)return(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`KillShell`,params:``,status:`error`}),(0,Z.jsx)(g2,{color:`red`,children:`Invalid params`})]});let i=`id: ${r.data.shellId}`;return t===`interrupted`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`KillShell`,params:i,status:`interrupted`}),(0,Z.jsx)(g2,{color:`yellow`,children:`Interrupted · What should I do instead?`})]}):t===`rejected`?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`KillShell`,params:i,status:`rejected`}),n?.userNote?(0,Z.jsxs)(g2,{color:`yellow`,children:[`Rejected · `,(0,Z.jsxs)($,{italic:!0,children:[`"`,n.userNote,`"`]})]}):(0,Z.jsx)(g2,{color:`yellow`,children:`Rejected`})]}):!n&&(t===`executing`||t===`pending`)?(0,Z.jsx)(h2,{name:`KillShell`,params:i,status:`pending`,showSpinner:!0}):n?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(h2,{name:`KillShell`,params:i,status:`success`}),(0,Z.jsx)(g2,{children:n.summary})]}):(0,Z.jsx)(Q,{flexDirection:`column`,children:(0,Z.jsx)(h2,{name:`KillShell`,params:i,status:`pending`})})}},navigate_to:pHe,new_tab:hHe,close_tab:aHe,switch_active_tab:bHe,refresh_tab:vHe,get_tab_content:dHe,computer:sHe,get_interactive_elements:lHe,perform_interactive_element_action:_He,ask_user_question:UVe,enter_plan_mode:WVe,exit_plan_mode:JVe,subagent:XVe,task:QVe,todo_write:rHe,get_diagnostics:iUe};function ZWe(e,t){s6[e]=t??kWe(e)}function QWe(e){let t=e.toolUseRequest;return t?(Array.isArray(t)?t:[t]).map(e=>{let t=e;return{name:t.name??``,input:t.input??{}}}).filter(e=>e.name):[]}function $We(e,t=4){let n=[];for(let r of e){if(n.length>=t)break;for(let e of QWe(r)){if(n.length>=t)break;let r=s6[e.name];if(!r)continue;let i=``;try{i=r.getHeaderParams(e.input)}catch{}if(!i)continue;let a=r.displayName??e.name;n.push({label:a,detail:i})}}return n}const c6=(0,X.memo)(e=>{let t=(0,cQ.c)(16),{counts:n,segments:r}=e,i;bb0:{let e;if(t[0]!==n.responses||t[1]!==n.toolUses?(e=[],n.toolUses>0&&e.push(`${n.toolUses} tool ${n.toolUses===1?`use`:`uses`}`),n.responses>0&&e.push(`${n.responses} ${n.responses===1?`response`:`responses`}`),t[0]=n.responses,t[1]=n.toolUses,t[2]=e):e=t[2],e.length===0){i=`Conversation compacted`;break bb0}i=e.join(`, `)+` compacted`}let a=i,o;t[3]===r?o=t[4]:(o=$We(r),t[3]=r,t[4]=o);let s=o,c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)($,{color:z$,children:`⟐`}),t[5]=c):c=t[5];let l;t[6]===a?l=t[7]:(l=(0,Z.jsx)($,{color:z$,dimColor:!0,children:a}),t[6]=a,t[7]=l);let u;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)($,{color:z$,dimColor:!0,children:`(ctrl+o to expand)`}),t[8]=u):u=t[8];let d;t[9]===l?d=t[10]:(d=(0,Z.jsxs)(Q,{flexDirection:`row`,gap:1,children:[c,l,u]}),t[9]=l,t[10]=d);let f;t[11]===s?f=t[12]:(f=s.map(eGe),t[11]=s,t[12]=f);let p;return t[13]!==d||t[14]!==f?(p=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15],p});c6.displayName=`CompactedPlaceholder`;function eGe(e,t){return(0,Z.jsx)(Q,{flexDirection:`row`,paddingLeft:2,children:(0,Z.jsxs)($,{color:z$,dimColor:!0,children:[`⎿ `,e.label,` `,e.detail]})},t)}const l6=(0,X.createContext)(null);function tGe(){let e=(0,X.use)(l6);if(!e)throw Error(`useUpdate must be used within UpdateProvider`);return e}function nGe(e){let t=(0,cQ.c)(20),{children:n,configService:r}=e,[i,a]=(0,X.useState)(null),o;t[0]===r?o=t[1]:(o=r.get(`autoUpdate`),t[0]=r,t[1]=o);let s=o!==!1,c;t[2]===r?c=t[3]:(c=r.get(`updateChannel`),t[2]=r,t[3]=c);let l;t[4]===r?l=t[5]:(l=r.get(`baseUrl`),t[4]=r,t[5]=l);let u;t[6]!==s||t[7]!==c||t[8]!==l?(u={autoUpdate:s,updateChannel:c,baseUrl:l},t[6]=s,t[7]=c,t[8]=l,t[9]=u):u=t[9];let{autoUpdate:d,updateChannel:f,baseUrl:p}=u,m,h;t[10]!==p||t[11]!==f?(m=()=>{if(EQ())return;let e=!0,t=()=>{DQ(_Q.default.version,f,p).then(t=>{e&&a(e=>e?.latestVersion===t?.latestVersion?e:t)}).catch(rGe)};t();let n=setInterval(t,6e4);return()=>{e=!1,clearInterval(n)}},h=[f,p],t[10]=p,t[11]=f,t[12]=m,t[13]=h):(m=t[12],h=t[13]),(0,X.useEffect)(m,h);let g;t[14]!==d||t[15]!==i?(g={updateInfo:i,autoUpdate:d},t[14]=d,t[15]=i,t[16]=g):g=t[16];let _=g,v;return t[17]!==n||t[18]!==_?(v=(0,Z.jsx)(l6.Provider,{value:_,children:n}),t[17]=n,t[18]=_,t[19]=v):v=t[19],v}function rGe(){}const u6=(0,X.createContext)(null),d6=()=>{let e=(0,X.use)(u6);if(!e)throw Error(`${d6.name} must be used within a ${f6.name}`);return e};function f6(e){let t=(0,cQ.c)(10),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={columns:process.stdout.columns-8,rows:process.stdout.rows},t[0]=r):r=t[0];let[i,a]=(0,X.useState)(r),o;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>{a({columns:process.stdout.columns-8,rows:process.stdout.rows})},t[1]=o):o=t[1];let s=o,c,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>(process.stdout.on(`resize`,s),()=>{process.stdout.off(`resize`,s)}),l=[s],t[2]=c,t[3]=l):(c=t[2],l=t[3]),(0,X.useLayoutEffect)(c,l);let u;t[4]!==i.columns||t[5]!==i.rows?(u={width:i.columns,height:i.rows},t[4]=i.columns,t[5]=i.rows,t[6]=u):u=t[6];let d=u,f;return t[7]!==n||t[8]!==d?(f=(0,Z.jsx)(u6.Provider,{value:d,children:n}),t[7]=n,t[8]=d,t[9]=f):f=t[9],f}function iGe(){let{height:e}=d6();return Math.max(0,e-3)}function aGe(e){return I$({queryKey:[`models`],queryFn:async()=>{try{return(await e.listLLMModels())?.result??[]}catch{return[]}},initialData:[],staleTime:300*1e3,retry:1,refetchOnMount:`always`,refetchOnWindowFocus:!1})}function p6(e){return typeof e==`string`?e:typeof e==`object`&&e&&`segment`in e?e.segment:null}function oGe(){return process.platform===`win32`}async function sGe(e){return new Promise(t=>setTimeout(t,e))}function cGe({onlyFirst:e=!1}={}){return RegExp(`(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`,e?void 0:`g`)}const lGe=cGe();function m6(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes(`\x1B`)&&!e.includes(`›`)?e:e.replace(lGe,``)}const uGe=new Intl.Segmenter,h6=RegExp(`^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Mark}|\\p{Surrogate})+$`,`v`),dGe=RegExp(`^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+`,`v`),fGe=RegExp(`^\\p{RGI_Emoji}$`,`v`),pGe=/^[\d#*]\u20E3$/,mGe=/\p{Extended_Pictographic}/gu;function hGe(e){if(e.length>50)return!1;if(pGe.test(e))return!0;if(e.includes(`‍`)){let t=e.match(mGe);return t!==null&&t.length>=2}return!1}function gGe(e){return e.replace(dGe,``)}function _Ge(e){return h6.test(e)}function g6(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function _6(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function v6(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function vGe(e){return g6(e)||_6(e)||v6(e)}function yGe(e,t){let n=[];for(let t of e)h6.test(t)||n.push(t.codePointAt(0));if(n.length===0)return;let r=0;for(let e=0;e<n.length;e++){let i=n[e];if(!vGe(i)){if(r===0)return;for(let i=e;i<n.length;i++)r+=MY(n[i],t);return r}if(g6(i)&&_6(n[e+1])){r+=2,e+=v6(n[e+2])?2:1;continue}r+=MY(i,t)}return r}function bGe(e,t){let n=0,r=!0;for(let i of e){if(r){r=!1;continue}i>=`＀`&&i<=`￯`&&(n+=MY(i.codePointAt(0),t))}return n}function xGe(e,t={}){if(typeof e!=`string`||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t,i=e;if(!r&&(i.includes(`\x1B`)||i.includes(`›`))&&(i=m6(i)),i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let a=0,o={ambiguousAsWide:!n};for(let{segment:e}of uGe.segment(i)){if(_Ge(e))continue;if(fGe.test(e)||hGe(e)){a+=2;continue}let t=gGe(e),n=yGe(t,o);if(n!==void 0){a+=n;continue}let r=t.codePointAt(0);a+=MY(r,o),a+=bGe(t,o)}return a}const SGe=[RegExp(`\x1B\\[2J`,`g`),RegExp(`\x1B\\[H`,`g`),RegExp(`\x1B\\[\\d+(;\\d+)?H`,`g`),RegExp(`\x1Bc`,`g`),RegExp(`\x1B\\[!p`,`g`),RegExp(`\x1B\\[\\?1049[hl]`,`g`),RegExp(`\x1B\\[\\d*[ABCD]`,`g`),RegExp(`\x1B\\[s`,`g`),RegExp(`\x1B\\[u`,`g`),RegExp(`\x1B\\[\\d*J`,`g`),RegExp(`\x1B\\[\\d*K`,`g`),RegExp(`\x1B\\[\\?25[hl]`,`g`),RegExp(`\x07`,`g`)];function CGe(e){let t=e;for(let e of SGe)t=t.replace(e,``);return t}const y6=new Map,b6=1e3;function x6(e){let t=!0;for(let n=0;n<e.length;n++)if(e.charCodeAt(n)>127){t=!1;break}if(t)return e.split(``);if(e.length<=b6){let t=y6.get(e);if(t)return t}let n=Array.from(e);return e.length<=b6&&y6.set(e,n),n}function S6(e){return x6(e).length}function C6(e,t,n){return x6(e).slice(t,n).join(``)}function w6(e){return x6(f(EPe(e))).filter(e=>{let t=e.codePointAt(0);return t===void 0?!1:t===10||t===13||t===9?!0:!(t>=0&&t<=31||t>=128&&t<=159)}).join(``)}const T6=new Map,E6=e=>{if(/^[\u0020-\u007E]*$/.test(e))return e.length;if(T6.has(e))return T6.get(e);let t=xGe(e);return T6.set(e,t),t};TPe();function wGe(e,t){if(!A6(e[t]))return!1;let n=t+1;for(;n<e.length&&M6(e[n]);)n++;return n>=e.length||!A6(e[n])}function TGe(e,t){let{lines:n,cursorRow:r,cursorCol:i}=e;switch(t.type){case`vim_delete_word_forward`:case`vim_change_word_forward`:{let{count:a}=t.payload,o=r,s=i;for(let e=0;e<a;e++){let e=z6(n,o,s,!0);if(e)o=e.row,s=e.col;else{let e=n[o]||``,t=R6(e,s);s=t===null?S6(e):t+1;break}}return o!==r||s!==i?U6(J6(e),r,i,o,s,``):e}case`vim_delete_word_backward`:case`vim_change_word_backward`:{let{count:a}=t.payload,o=r,s=i;for(let e=0;e<a;e++){let e=B6(n,o,s);if(e)o=e.row,s=e.col;else break}return o!==r||s!==i?U6(J6(e),o,s,r,i,``):e}case`vim_delete_word_end`:case`vim_change_word_end`:{let{count:a}=t.payload,o=r,s=i,c=r,l=i;for(let e=0;e<a;e++){let t=z6(n,o,s,!1);if(t){if(c=t.row,l=t.col+1,e<a-1){let e=z6(n,t.row,t.col+1,!0);if(e)o=e.row,s=e.col;else break}}else break}if(c<n.length){let e=S6(n[c]||``);l=Math.min(l,e)}return c!==r||l!==i?U6(J6(e),r,i,c,l,``):e}case`vim_delete_line`:{let{count:i}=t.payload;if(n.length===0)return e;let a=Math.min(i,n.length-r),o=n.length;if(o===1||a>=o)return{...J6(e),lines:[``],cursorRow:0,cursorCol:0,preferredCol:null};let s=J6(e),c=[...s.lines];c.splice(r,a);let l=Math.min(r,c.length-1);return{...s,lines:c,cursorRow:l,cursorCol:0,preferredCol:null}}case`vim_change_line`:{let{count:i}=t.payload;if(n.length===0)return e;let a=Math.min(i,n.length-r),o=J6(e),{startOffset:s,endOffset:c}=H6(r,a,o.lines),{startRow:l,startCol:u,endRow:d,endCol:f}=V6(s,c,o.lines);return U6(o,l,u,d,f,``)}case`vim_delete_to_end_of_line`:case`vim_change_to_end_of_line`:{let t=n[r]||``;return i<S6(t)?U6(J6(e),r,i,r,S6(t),``):e}case`vim_change_movement`:{let{movement:a,count:o}=t.payload,s=n.length;switch(a){case`h`:{let t=Math.max(0,i-o);return U6(J6(e),r,t,r,i,``)}case`j`:{let t=Math.min(o,s-r);if(t>0)if(s===1){let t=e.lines[0]||``;return U6(J6(e),0,0,0,S6(t),``)}else{let n=J6(e),{startOffset:i,endOffset:a}=H6(r,t,n.lines),{startRow:o,startCol:s,endRow:c,endCol:l}=V6(i,a,n.lines);return U6(n,o,s,c,l,``)}return e}case`k`:if(Math.min(o,r+1)>0)if(e.lines.length===1){let t=e.lines[0]||``;return U6(J6(e),0,0,0,S6(t),``)}else{let t=Math.max(0,r-o+1),n=r-t+1,i=J6(e),{startOffset:a,endOffset:s}=H6(t,n,i.lines),{startRow:c,startCol:l,endRow:u,endCol:d}=V6(a,s,i.lines);return{...U6(i,c,l,u,d,``),cursorRow:t,cursorCol:0}}return e;case`l`:return U6(J6(e),r,i,r,Math.min(S6(n[r]||``),i+o),``);default:return e}}case`vim_move_left`:{let{count:n}=t.payload,{cursorRow:r,cursorCol:i,lines:a}=e,o=r,s=i;for(let e=0;e<n;e++)if(s>0)s--;else if(o>0){o--;let e=S6(a[o]||``);s=e===0?0:e-1}return{...e,cursorRow:o,cursorCol:s,preferredCol:null}}case`vim_move_right`:{let{count:n}=t.payload,{cursorRow:r,cursorCol:i,lines:a}=e,o=r,s=i;for(let e=0;e<n;e++){let e=a[o]||``,t=S6(e);if(t===0)o<a.length-1&&(o++,s=0);else if(s<t-1){s++;let n=x6(e);for(;s<n.length&&M6(n[s])&&s<t-1;)s++}else o<a.length-1&&(o++,s=0)}return{...e,cursorRow:o,cursorCol:s,preferredCol:null}}case`vim_move_up`:{let{count:n}=t.payload,{cursorRow:r,cursorCol:i,lines:a}=e,o=Math.max(0,r-n),s=S6(a[o]||``),c=Math.min(i,s>0?s-1:0);return{...e,cursorRow:o,cursorCol:c,preferredCol:null}}case`vim_move_down`:{let{count:n}=t.payload,{cursorRow:r,cursorCol:i,lines:a}=e,o=Math.min(a.length-1,r+n),s=S6(a[o]||``),c=Math.min(i,s>0?s-1:0);return{...e,cursorRow:o,cursorCol:c,preferredCol:null}}case`vim_move_word_forward`:{let{count:a}=t.payload,o=r,s=i;for(let e=0;e<a;e++){let e=z6(n,o,s,!0);if(e)o=e.row,s=e.col;else break}return{...e,cursorRow:o,cursorCol:s,preferredCol:null}}case`vim_move_word_backward`:{let{count:a}=t.payload,o=r,s=i;for(let e=0;e<a;e++){let e=B6(n,o,s);if(e)o=e.row,s=e.col;else break}return{...e,cursorRow:o,cursorCol:s,preferredCol:null}}case`vim_move_word_end`:{let{count:a}=t.payload,o=r,s=i;for(let e=0;e<a;e++){if(e===0){let e=x6(n[o]||``);if(s<e.length&&A6(e[s])&&(s+1>=e.length||!N6(e[s+1])||A6(e[s])&&wGe(e,s))){let e=z6(n,o,s+1,!1);if(e){o=e.row,s=e.col;continue}}}let t=z6(n,o,s,!1);if(t)o=t.row,s=t.col;else break}return{...e,cursorRow:o,cursorCol:s,preferredCol:null}}case`vim_delete_char`:{let{count:n}=t.payload,{cursorRow:r,cursorCol:i,lines:a}=e,o=S6(a[r]||``);if(i<o){let t=Math.min(n,o-i);return U6(J6(e),r,i,r,i+t,``)}return e}case`vim_insert_at_cursor`:return e;case`vim_append_at_cursor`:{let{cursorRow:t,cursorCol:n,lines:r}=e,i=n<S6(r[t]||``)?n+1:n;return{...e,cursorCol:i,preferredCol:null}}case`vim_open_line_below`:{let{cursorRow:t,lines:n}=e,r=J6(e),i=S6(n[t]||``);return U6(r,t,i,t,i,`
75289
75289
  `)}case`vim_open_line_above`:{let{cursorRow:t}=e;return{...U6(J6(e),t,0,t,0,`
75290
75290
  `),cursorRow:t,cursorCol:0}}case`vim_append_at_line_end`:{let{cursorRow:t,lines:n}=e,r=S6(n[t]||``);return{...e,cursorCol:r,preferredCol:null}}case`vim_insert_at_line_start`:{let{cursorRow:t,lines:n}=e,r=n[t]||``,i=0,a=x6(r);for(;i<a.length&&/\s/.test(a[i]);)i++;return{...e,cursorCol:i,preferredCol:null}}case`vim_move_to_line_start`:return{...e,cursorCol:0,preferredCol:null};case`vim_move_to_line_end`:{let{cursorRow:t,lines:n}=e,r=S6(n[t]||``);return{...e,cursorCol:r>0?r-1:0,preferredCol:null}}case`vim_move_to_first_nonwhitespace`:{let{cursorRow:t,lines:n}=e,r=n[t]||``,i=0,a=x6(r);for(;i<a.length&&/\s/.test(a[i]);)i++;return{...e,cursorCol:i,preferredCol:null}}case`vim_move_to_first_line`:return{...e,cursorRow:0,cursorCol:0,preferredCol:null};case`vim_move_to_last_line`:{let{lines:t}=e,n=t.length-1;return{...e,cursorRow:n,cursorCol:0,preferredCol:null}}case`vim_move_to_line`:{let{lineNumber:n}=t.payload,{lines:r}=e,i=Math.min(Math.max(0,n-1),r.length-1);return{...e,cursorRow:i,cursorCol:0,preferredCol:null}}case`vim_escape_insert_mode`:{let{cursorCol:t}=e,n=t>0?t-1:0;return{...e,cursorCol:n,preferredCol:null}}default:return e}}const D6=dt([`codellm`,`cli`,`text-buffer`]);let O6=0;const EGe=/\[Pasted text (#\d+) \+\d+ lines\]/g;function DGe(e){return e.length>500?!0:e.split(/\r\n|\r|\n/).length>5}function OGe(e){O6++;let t=`#${O6}`;return{placeholder:`[Pasted text ${t} +${e.split(/\r\n|\r|\n/).length} lines]`,id:t}}function k6(e){return e===void 0?!1:!/[\s,.;!?]/.test(e)}const A6=e=>/[\w\p{L}\p{N}]/u.test(e),j6=e=>/\s/.test(e),M6=e=>/\p{M}/u.test(e),N6=e=>A6(e)||M6(e),P6=e=>/[\p{Script=Latin}]/u.test(e)?`latin`:/[\p{Script=Han}]/u.test(e)?`han`:/[\p{Script=Arabic}]/u.test(e)?`arabic`:/[\p{Script=Hiragana}]/u.test(e)?`hiragana`:/[\p{Script=Katakana}]/u.test(e)?`katakana`:/[\p{Script=Cyrillic}]/u.test(e)?`cyrillic`:`other`,F6=(e,t)=>!A6(e)||!A6(t)?!1:P6(e)!==P6(t),I6=(e,t)=>{let n=x6(e),r=t;if(r>=n.length)return null;let i=n[r];if(A6(i))for(;r<n.length&&N6(n[r]);){if(r+1<n.length&&A6(n[r+1])&&F6(n[r],n[r+1])){r++;break}r++}else if(!j6(i))for(;r<n.length&&!A6(n[r])&&!j6(n[r]);)r++;for(;r<n.length&&j6(n[r]);)r++;return r<n.length?r:null},L6=(e,t)=>{let n=x6(e),r=t;if(r<=0)return null;for(r--;r>=0&&j6(n[r]);)r--;if(r<0)return null;if(A6(n[r])){for(;r>=0&&A6(n[r]);){if(r-1>=0&&A6(n[r-1])&&F6(n[r],n[r-1]))return r;r--}return r+1}else{for(;r>=0&&!A6(n[r])&&!j6(n[r]);)r--;return r+1}},R6=(e,t)=>{let n=x6(e),r=t,i=r<n.length&&N6(n[r])&&(r+1>=n.length||!N6(n[r+1])||A6(n[r])&&r+1<n.length&&A6(n[r+1])&&F6(n[r],n[r+1])),a=r<n.length&&!N6(n[r])&&!j6(n[r])&&(r+1>=n.length||j6(n[r+1])||N6(n[r+1]));if(i||a)for(r++;r<n.length&&j6(n[r]);)r++;if(r<n.length&&!N6(n[r]))for(;r<n.length&&j6(n[r]);)r++;let o=!1,s=-1;if(r<n.length&&N6(n[r]))for(;r<n.length&&N6(n[r]);){if(o=!0,A6(n[r])&&(s=r),r+1<n.length&&A6(n[r+1])&&F6(n[r],n[r+1])){r++,A6(n[r-1])&&(s=r-1);break}r++}else if(r<n.length&&!j6(n[r]))for(;r<n.length&&!A6(n[r])&&!j6(n[r]);)o=!0,s=r,r++;return o&&s>=t?s:null},z6=(e,t,n,r)=>{let i=e[t]||``,a=r?I6(i,n):R6(i,n);if(a!==null)return{row:t,col:a};for(let n=t+1;n<e.length;n++){let t=e[n]||``,i=x6(t);if(i.length===0){let t=!1;for(let r=n+1;r<e.length;r++){let n=x6(e[r]||``),i=0;for(;i<n.length&&j6(n[i]);)i++;if(i<n.length){t=!0;break}}if(!t)return{row:n,col:0};continue}let a=0;for(;a<i.length&&j6(i[a]);)a++;if(a<i.length){if(r)return{row:n,col:a};{let e=R6(t,a);if(e!==null)return{row:n,col:e}}}}return null},B6=(e,t,n)=>{let r=L6(e[t]||``,n);if(r!==null)return{row:t,col:r};for(let n=t-1;n>=0;n--){let t=e[n]||``,r=x6(t);if(r.length===0)continue;let i=r.length;for(;i>0&&j6(r[i-1]);)i--;if(i>0){let e=L6(t,i);if(e!==null)return{row:n,col:e}}}return null},V6=(e,t,n)=>{let r=0,i=0,a=0,o=0,s=0;for(let t=0;t<n.length;t++){let o=n[t].length+1;if(r+o>e){i=t,a=e-r;break}r+=o}r=0;for(let e=0;e<n.length;e++){let i=n[e].length+ +(e<n.length-1);if(r+i>=t){o=e,s=t-r;break}r+=i}return{startRow:i,startCol:a,endRow:o,endCol:s}},H6=(e,t,n)=>{let r=0;for(let t=0;t<e;t++)r+=n[t].length+1;let i=r;for(let r=0;r<t;r++){let t=e+r;t<n.length&&(i+=n[t].length,t<n.length-1&&(i+=1))}return{startOffset:r,endOffset:i}},U6=(e,t,n,r,i,a)=>{let o=t=>e.lines[t]||``,s=e=>S6(o(e)),c=(e,t,n)=>Math.min(Math.max(e,t),n);if(t>r||t===r&&n>i||t<0||n<0||r>=e.lines.length||r<e.lines.length&&i>s(r))return e;let l=[...e.lines],u=c(n,0,s(t)),d=c(i,0,s(r)),f=C6(o(t),0,u),p=C6(o(r),d),m=a.replace(/\r\n/g,`
@@ -75371,7 +75371,7 @@ Please restart your terminal for changes to take effect.`),n(t,`info`)}else n(e.
75371
75371
  `),i=[],a=!1;if(o&&e.length>s){let t=Math.max(1,Math.floor(s/2)),n=e.slice(0,t).map(hKe),r=e.slice(-t).map((n,r)=>({line:n,originalIndex:e.length-t+r}));i=[...n,...r],a=!0}else i=e.map(mKe);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=S2(process.cwd()),t[5]=l):l=t[5];let u=`${l}$ ${r}`,d;t[6]===u?d=t[7]:(d=(0,Z.jsx)($,{dimColor:!0,children:u}),t[6]=u,t[7]=d),c=(0,Z.jsxs)(Q,{flexDirection:`column`,paddingX:1,children:[d,n&&i.map((t,n)=>a&&n===Math.floor(i.length/2)?(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsxs)($,{dimColor:!0,children:[`... (`,e.length-s,` lines hidden) ...`]}),(0,Z.jsx)($,{children:t.line})]},`trunc-${t.originalIndex}`):(0,Z.jsx)($,{children:t.line},`line-${t.originalIndex}`))]}),t[0]=r,t[1]=s,t[2]=n,t[3]=o,t[4]=c}else c=t[4];return c}function mKe(e,t){return{line:e,originalIndex:t}}function hKe(e,t){return{line:e,originalIndex:t}}const gKe=[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`];function _Ke(){let e=t.platform(),n={};for(let[e,t]of Object.entries(process.env))t!==void 0&&(n[e]=t);return e===`win32`?{command:process.env.COMSPEC||`cmd.exe`,args:[],env:n}:{command:process.env.SHELL||`/bin/bash`,args:[],env:{...n,BASH_SILENCE_DEPRECATION_WARNING:`1`,PS1:``}}}var vKe=class{shell=null;queue=[];notify=null;isProcessing=!1;destroyed=!1;isWindows;signalHandlers=new Map;constructor(){this.isWindows=t.platform()===`win32`,this.startShell(),this.setupSignalForwarding()}setupSignalForwarding(){for(let e of gKe){let t=()=>{if(this.shell&&!this.shell.killed&&this.shell.exitCode===null)try{this.shell.kill(e)}catch{}};this.signalHandlers.set(e,t),process.on(e,t)}}removeSignalHandlers(){for(let[e,t]of this.signalHandlers)process.removeListener(e,t);this.signalHandlers.clear()}startShell(){if(this.shell||this.destroyed)return;let{command:e,args:t,env:n}=_Ke();this.shell=ue(e,t,{stdio:[`pipe`,`pipe`,`pipe`],env:n,cwd:process.cwd(),shell:!1}),this.shell.stdin&&this.shell.stdin.on(`error`,e=>{if(e.code!==`EPIPE`)throw e}),this.shell.stdout&&this.shell.stdout.on(`data`,e=>{let t=e.toString(`utf8`);if(this.queue.push({type:`stdout`,data:t}),this.notify){let e=this.notify;this.notify=null,e()}}),this.shell.stderr&&this.shell.stderr.on(`data`,e=>{let t=e.toString(`utf8`);if(!(t.includes(`no job control in this shell`)||t.includes(`The default interactive shell is now zsh`)||t.includes(`To update your account to use zsh`)||t.includes("please run `chsh -s /bin/zsh`")||t.includes(`For more details, please visit`))&&(this.queue.push({type:`stderr`,data:t}),this.notify)){let e=this.notify;this.notify=null,e()}}),this.shell.on(`exit`,()=>{this.shell=null,this.startShell()})}async executeCommand(e){if(!this.shell||!this.shell.stdin)throw Error(`Shell not initialized`);this.queue.length=0;let t=`__CMD_END_${Date.now()}_${Math.random().toString(36).substring(7)}__`,n;return n=this.isWindows?`${e}\necho ${t}\n`:`${e}\necho "${t}"\n`,this.shell.stdin.write(n),this.isProcessing=!0,{stream:this.createStream(t),exit:this.createExitPromise(t)}}async*createStream(e){for(;;){for(;this.queue.length>0;){let t=this.queue.shift();if(t){if(t.data.includes(e)){let n=t.data.replace(e,``).replace(/\n$/,``);n&&(yield{type:t.type,data:n}),this.isProcessing=!1;return}yield t}}if(!this.isProcessing)return;await new Promise(e=>{this.notify=e})}}async createExitPromise(e){for(;this.isProcessing;)await new Promise(e=>setTimeout(e,100));return 0}killProcessGracefully(e){try{e.kill(`SIGTERM`);let t=setTimeout(()=>{e&&!e.killed&&e.kill(`SIGKILL`)},5e3);t.unref&&t.unref()}catch{}}destroy(){this.destroyed=!0,this.removeSignalHandlers(),this.shell&&=(this.shell.stdin?.on(`error`,e=>{if(e.code!==`EPIPE`)throw e}),this.killProcessGracefully(this.shell),null)}};let D8=null;function yKe(){return D8||=new vKe,D8}function bKe(e){let t=(0,cQ.c)(36),{state:n,setState:r,onCommandComplete:i,commandHistory:a,currentPrompt:o,availableHeight:s}=e,{submittedCommand:c,runId:l}=n,u;t[0]===c?u=t[1]:(u=c?.trim()||``,t[0]=c,t[1]=u);let d=u,f=(0,X.useRef)(-1),p=(0,X.useRef)(null),m,h;t[2]!==d||t[3]!==i||t[4]!==l||t[5]!==r?(m=()=>{if(!d||l===f.current)return;f.current=l,p.current&&p.current.abort();let e=new AbortController;return p.current=e,r(CKe),wKe({command:d,setOutput:e=>{r(t=>({...t,output:e}))},signal:e.signal}).then(t=>{e.signal.aborted||(r(SKe),t!==void 0&&i(t))}).catch(t=>{e.signal.aborted||(r(xKe),i(``))}),()=>{e.abort(),p.current=null}},h=[d,l,r,i],t[2]=d,t[3]=i,t[4]=l,t[5]=r,t[6]=m,t[7]=h):(m=t[6],h=t[7]),(0,X.useEffect)(m,h);let g;t[8]===o?g=t[9]:(g=o.trim(),t[8]=o,t[9]=g);let _=g.length>0,v=c?2:3,y,b,x,S,C;if(t[10]!==s||t[11]!==a||t[12]!==v||t[13]!==_||t[14]!==c){let e=a.slice(-v),n=Math.max(0,a.length-v),r=e.length+ +!!c,i=Math.max(1,s-r);b=r>0?Math.max(3,Math.floor(i/r)):10,x=_||s<15||r>1,y=Q,S=`column`;let o;t[20]!==n||t[21]!==b||t[22]!==x?(o=(e,t)=>{let r=n+t;return(0,Z.jsx)(E8,{output:e.output,command:e.command,truncate:x,maxLines:b},`history-${r}`)},t[20]=n,t[21]=b,t[22]=x,t[23]=o):o=t[23],C=e.map(o),t[10]=s,t[11]=a,t[12]=v,t[13]=_,t[14]=c,t[15]=y,t[16]=b,t[17]=x,t[18]=S,t[19]=C}else y=t[15],b=t[16],x=t[17],S=t[18],C=t[19];let w;t[24]!==b||t[25]!==d||t[26]!==l||t[27]!==x||t[28]!==n.output||t[29]!==c?(w=c&&(0,Z.jsx)(E8,{output:n.output,command:d||c,truncate:x,maxLines:b},`submitted-${l}`),t[24]=b,t[25]=d,t[26]=l,t[27]=x,t[28]=n.output,t[29]=c,t[30]=w):w=t[30];let T;return t[31]!==y||t[32]!==S||t[33]!==C||t[34]!==w?(T=(0,Z.jsxs)(y,{flexDirection:S,children:[C,w]}),t[31]=y,t[32]=S,t[33]=C,t[34]=w,t[35]=T):T=t[35],T}function xKe(e){return{...e,isRunning:!1}}function SKe(e){return{...e,isRunning:!1}}function CKe(e){return{...e,isRunning:!0,output:``}}async function wKe({command:e,setOutput:t,signal:n}){let{stream:r,exit:i}=await yKe().executeCommand(e),a=``;try{for await(let e of r){if(n.aborted)return;a+=CGe(e.data),n.aborted||t(a)}return n.aborted?void 0:(await i,a)}catch(e){if(n.aborted)return;throw e}}var TKe=Ze({parseShellHistory:()=>k8,shellHistory:()=>DKe,shellHistoryPath:()=>A8});function EKe(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];r===131&&n+1<e.length?(t.push(e[n+1]^32),n++):t.push(r)}return Buffer.from(t)}function O8(e){return k8(EKe(m.readFileSync(e)).toString(`utf8`))}function k8(e){let t=/^: \d+:0;/;return e.trim().split(`
75372
75372
  `).map(e=>t.test(e)?e.split(`;`).slice(1).join(`;`):e)}function A8({extraPaths:e=[]}={}){if(process.env.HISTFILE)return process.env.HISTFILE;let t=n.homedir(),r=new Set([P.join(t,`.bash_history`),P.join(t,`.zsh_history`),P.join(t,`.history`)]);for(let t of e)r.add(t);return(()=>{let e,t=0;for(let n of r)m.existsSync(n)&&m.statSync(n).size>t&&(t=m.statSync(n).size,e=n);return e})()}function DKe(e={}){if(process.platform===`win32`){let t=A8(e);if(t)return O8(t);let{stdout:n}=ae.spawnSync(`doskey`,[`/history`],{encoding:`utf8`});return n.trim().split(`\r
75373
75373
  `)}return O8(A8(e))}var OKe=W((()=>{}));const j8=1e3;function kKe(){let[e,t]=(0,X.useState)({submittedCommand:null,runId:0,output:``,isRunning:!1}),[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(-1),c=(0,X.useRef)(!1);(0,X.useEffect)(()=>{c.current||(c.current=!0,Promise.resolve().then(()=>(OKe(),TKe)).then(e=>{let t=e.shellHistory??e.default;a((typeof t==`function`?t():[]).slice(-j8))}).catch(()=>{}))},[]);let l=(0,X.useCallback)(e=>{let n=e.trim();n&&(a(e=>e.length>0&&e[e.length-1]===n?e:[...e,n].slice(-j8)),s(-1),t(e=>({submittedCommand:n,runId:e.runId+1,output:``,isRunning:!0})))},[]),u=(0,X.useCallback)(e=>{t(t=>(t.submittedCommand&&r(n=>[...n,{command:t.submittedCommand,output:e}].slice(-1e3)),{submittedCommand:null,runId:t.runId,output:``,isRunning:!1}))},[]);return{submitCommand:l,renderer:(0,X.useCallback)(r=>(0,Z.jsx)(bKe,{state:e,setState:t,onCommandComplete:u,commandHistory:n,currentPrompt:r.prompt,availableHeight:r.availableHeight}),[e,u,n]),navigateHistory:(0,X.useCallback)(e=>{if(i.length===0)return null;let t=o;return e===`up`?t=o===-1?i.length-1:Math.max(0,o-1):(t=o===-1?-1:o+1,t>=i.length&&(t=-1)),s(t),t===-1?``:i[t]},[i,o]),getActivity:()=>e.isRunning?`pending`:`idle`}}const AKe=[`no pull requests found`,`no open pull requests`];function jKe(){return new Promise((e,t)=>{se(`gh`,[`pr`,`view`,`--json`,`number,url,reviewDecision,isDraft,state`],{timeout:1e4},(n,r,i)=>{if(n){let r=(i||n.message).toLowerCase();AKe.some(e=>r.includes(e))?e(null):t(n);return}try{let t=JSON.parse(r.trim());if(typeof t.number==`number`&&typeof t.url==`string`&&t.number>0){let n=`pending`;t.state===`MERGED`?n=`merged`:t.state===`CLOSED`?n=`closed`:t.isDraft?n=`draft`:t.reviewDecision===`APPROVED`?n=`approved`:t.reviewDecision===`CHANGES_REQUESTED`&&(n=`changes_requested`),e({number:t.number,url:t.url,reviewState:n});return}}catch{t(Error(`Malformed JSON from gh pr view`))}e(null)})})}const M8=6e4;function MKe(){let e=(0,cQ.c)(1),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={queryKey:[`pr-info`],queryFn:jKe,staleTime:M8,refetchInterval:M8,retry:!1,refetchOnMount:!0,refetchOnWindowFocus:!1},e[0]=t):t=e[0];let{data:n}=I$(t);return n??null}function N8(e){let t=(0,cQ.c)(9),{href:n,children:r,color:i}=e,a;t[0]===n?a=t[1]:(a=rQ(n),t[0]=n,t[1]=a);let o=a,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=iQ(),t[2]=s):s=t[2];let c=s,l=i??OFe,u;t[3]===o?u=t[4]:(u=e=>`${o}${e}${c}`,t[3]=o,t[4]=u);let d;return t[5]!==r||t[6]!==l||t[7]!==u?(d=(0,Z.jsx)($,{color:l,underline:!0,transform:u,children:r}),t[5]=r,t[6]=l,t[7]=u,t[8]=d):d=t[8],d}N8.displayName=`Link`;const NKe={approved:`green`,pending:`yellow`,changes_requested:`red`,draft:`brightblack`,merged:`magenta`,closed:`brightblack`},P8=(0,X.memo)(e=>{let t=(0,cQ.c)(16),{hints:n,availableHeight:r}=e,{agentMode:i,isWaitingForYoloConfirm:a}=j2(),o=MKe();if(r!==void 0&&r<1)return null;let s;if(n?.exitKey){let e=n.exitKey===`c`?`Ctrl+C`:`Ctrl+D`,r;t[0]===e?r=t[1]:(r=(0,Z.jsxs)($,{dimColor:!0,children:[`Press `,e,` again to exit`]}),t[0]=e,t[1]=r),s=r}else if(a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)($,{dimColor:!0,children:[`Press `,(0,Z.jsx)($,{color:`brightred`,children:`shift+tab`}),` again to enable YOLO mode (dangerous)`]}),t[2]=e):e=t[2],s=e}else bb0:switch(i){case Rd.Normal:{let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)($,{dimColor:!0,children:`? for shortcuts • shift+tab to cycle modes`}),t[3]=e):e=t[3],s=e;break bb0}case Rd.AcceptEdits:{let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)($,{dimColor:!0,children:[(0,Z.jsx)($,{color:`brightcyan`,children:`⏵⏵`}),` accept edits on (shift+tab to cycle)`]}),t[4]=e):e=t[4],s=e;break bb0}case Rd.PlanMode:{let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)($,{dimColor:!0,children:[(0,Z.jsx)($,{color:`brightcyan`,children:`⏸`}),` plan mode on (shift+tab to cycle)`]}),t[5]=e):e=t[5],s=e;break bb0}case Rd.Yolo:{let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsxs)($,{dimColor:!0,children:[(0,Z.jsx)($,{color:`brightred`,children:`⚠`}),` YOLO mode - all tools auto-accepted (shift+tab to cycle)`]}),t[6]=e):e=t[6],s=e;break bb0}default:{let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)($,{dimColor:!0,children:`? for shortcuts`}),t[7]=e):e=t[7],s=e}}if(!o)return s;let c=NKe[o.reviewState],l;t[8]!==o.number||t[9]!==o.url||t[10]!==c?(l=(0,Z.jsxs)(N8,{href:o.url,color:c,children:[`PR #`,o.number]}),t[8]=o.number,t[9]=o.url,t[10]=c,t[11]=l):l=t[11];let u;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Z.jsx)($,{dimColor:!0,children:`•`}),t[12]=u):u=t[12];let d;return t[13]!==s||t[14]!==l?(d=(0,Z.jsxs)(Q,{flexDirection:`row`,gap:1,children:[l,u,s]}),t[13]=s,t[14]=l,t[15]=d):d=t[15],d});P8.displayName=`AgentModeIndicator`;const F8=15e3,PKe=/^(node_modules|\.git|dist|build|out|coverage|\.vscode|\.idea|\.DS_Store)$/;let I8=null;function L8(e,t){let n=e.replace(/\\/g,`/`);return{path:n,name:P.posix.basename(n),isDirectory:t}}function FKe(e){return e.name.startsWith(`.`)||e.path.split(`/`).some(e=>e.startsWith(`.`)&&e!==`.`)}async function IKe(e){try{let t=await LKe(`git`,[`rev-parse`,`--show-toplevel`],e);if(!t)return null;let[n,r]=await Promise.all([R8(`git`,[`ls-files`],t),R8(`git`,[`ls-files`,`--others`,`--exclude-standard`],t)]),i=[],a=new Set;for(let e of[...n,...r]){if(!e)continue;let n=P.resolve(t,e);i.push(L8(n,!1));let r=P.posix.dirname(e);for(;r&&r!==`.`;){let e=P.resolve(t,r);if(a.has(e))break;a.add(e),i.push(L8(e,!0)),r=P.posix.dirname(r)}}return i}catch{return null}}function LKe(e,t,n){return new Promise((r,i)=>{let a=ue(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]}),o=``;a.stdout.on(`data`,e=>o+=e.toString()),a.on(`close`,e=>e===0?r(o.trim()):i()),a.on(`error`,i)})}function R8(e,t,n){return new Promise(r=>{let i=[],a=ue(e,t,{cwd:n,stdio:[`ignore`,`pipe`,`pipe`]});pe({input:a.stdout}).on(`line`,e=>i.push(e.trim())),a.on(`close`,()=>r(i)),a.on(`error`,()=>r(i))})}async function RKe(e,t){let n=[`--files`,`--no-messages`,`--max-depth`,`100`];t.includeHidden&&n.push(`--hidden`),t.useGitignore||n.push(`--no-ignore`);for(let e of t.globs)n.push(`-g`,e);for(let e of t.ignoreGlobs)n.push(`-g`,e);return new Promise(t=>{let r=[],i=ue(Ve,n,{cwd:e,stdio:[`ignore`,`pipe`,`pipe`]});pe({input:i.stdout}).on(`line`,t=>{let n=RVe(t.trim());n&&r.push(L8(P.resolve(e,n),!1))}),i.on(`close`,()=>t(r)),i.on(`error`,()=>t(r))})}async function z8(e,t){let n=[],r=async(e,i)=>{if(!(i>12||n.length>=F8))try{let a=await b.readdir(e,{withFileTypes:!0}),o=[];for(let r of a){if(!t&&r.name.startsWith(`.`))continue;let i=P.join(e,r.name);r.isDirectory()?PKe.test(r.name)||(n.push(L8(i,!0)),o.push(i)):r.isFile()&&n.push(L8(i,!1))}await Promise.all(o.map(e=>r(e,i+1)))}catch{}};return await r(e,0),n}function zKe(e){let t=e.includeHidden??!1,n=e.globs??[],r=e.ignoreGlobs??[],i=e.useRipgrep??!0,a=e.useGitignore??!0,o=e.root,s=new Set,c=[],l=e=>{c.length>=F8||s.has(e.path)||(s.add(e.path),!(!t&&FKe(e))&&c.push(e))},u=i&&a&&n.length===0&&r.length===0;return{docs:c,ready:(async()=>{if(u){let e=await IKe(o);if(e){for(let t of e)l(t);return}}if(i){let e=await RKe(o,{includeHidden:t,globs:n,ignoreGlobs:r,useGitignore:a});for(let t of e)l(t);let i=await z8(o,t);for(let e of i)e.isDirectory&&l(e)}else{let e=await z8(o,t);for(let t of e)l(t)}})()}}function BKe(e){let t=P.resolve(e.root);if(I8&&I8.key===t&&Date.now()-I8.at<6e4)return I8.index;let n=zKe(e);return I8={key:t,index:n,at:Date.now()},n}async function VKe(e,t,n){let r=new Map;for(let n=0;n<e.length;n+=64){let i=e.slice(n,n+64);await Promise.all(i.map(async e=>{try{let n=P.isAbsolute(e.path)?e.path:P.resolve(t,e.path),i=await b.stat(n);r.set(e.path,i.mtimeMs)}catch{r.set(e.path,0)}}))}let i=[...e].sort((e,t)=>{let n=(r.get(t.path)??0)-(r.get(e.path)??0);return n===0?e.path.split(`/`).length-t.path.split(`/`).length||e.name.localeCompare(t.name):n}).slice(0,n);return{paths:i.map(e=>e.path),isDirectory:i.map(e=>e.isDirectory)}}async function HKe(e,t){let n=t.root,r=t.maxResults??100;if(!(await b.stat(n).catch(()=>null))?.isDirectory())return{paths:[],isDirectory:[]};let i=BKe(t);await i.ready;let a=e.trim();if(!a)return VKe(i.docs,n,r);let o=new nU(i.docs,{selector:e=>e.path,limit:r}).find(a);return{paths:o.map(e=>e.item.path),isDirectory:o.map(e=>e.item.isDirectory)}}function UKe(e){let t=(0,cQ.c)(8),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=[],t[0]=n):n=t[0];let[r,i]=(0,X.useState)(n),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1];let[o,s]=(0,X.useState)(a),c=(0,X.useRef)(null),l=(0,X.useRef)(null),u=(0,X.useRef)(null),d,f;t[2]===e?(d=t[3],f=t[4]):(d=()=>(l.current&&clearTimeout(l.current),c.current&&c.current.abort(),l.current=setTimeout(()=>{if(e===u.current)return;u.current=e;let t=new AbortController;c.current=t,(async()=>{try{let n=await HKe(e,{root:process.cwd()});if(t.signal.aborted)return;i(n.paths.map(BVe)),s(n.isDirectory)}catch{}})()},100),()=>{l.current&&clearTimeout(l.current),c.current&&c.current.abort()}),f=[e],t[2]=e,t[3]=d,t[4]=f),(0,X.useEffect)(d,f);let p;return t[5]!==o||t[6]!==r?(p={results:r,isDirectory:o},t[5]=o,t[6]=r,t[7]=p):p=t[7],p}const B8=(0,X.memo)(e=>{let t=(0,cQ.c)(26),{onAccept:n,onCancel:r,availableHeight:i}=e,{prompt:a,bufferRef:o}=v8(),[s,c]=(0,X.useState)(``),l;t[0]===o?l=t[1]:(l=()=>{let e=o.current;if(!e){c(``);return}let t=x8(e.text,e.cursor)?.query??``;c(e=>e===t?e:t)},t[0]=o,t[1]=l);let u;t[2]!==o||t[3]!==a?(u=[o,a],t[2]=o,t[3]=a,t[4]=u):u=t[4],(0,X.useEffect)(l,u);let d=(0,X.useDeferredValue)(s),{results:f,isDirectory:p}=UKe(d),m=s!==d,h;if(t[5]!==p||t[6]!==f){let e;t[8]===p?e=t[9]:(e=(e,t)=>p[t]?`${e}/`:e,t[8]=p,t[9]=e),h=f.map(e),t[5]=p,t[6]=f,t[7]=h}else h=t[7];let g=h,_;t[10]!==o||t[11]!==p||t[12]!==n||t[13]!==f?(_=(e,t)=>{let r=o.current;if(!r)return n();let i=x8(r.text,r.cursor);if(i){let e=f[t];r.replaceRange(i.startRow,i.startCol,i.endRow,i.endCol,`@${e}${p[t]?`/`:``} `)}n()},t[10]=o,t[11]=p,t[12]=n,t[13]=f,t[14]=_):_=t[14];let v=_,y=Math.max(1,Math.min(10,i-2)),b;t[15]!==i||t[16]!==g||t[17]!==v||t[18]!==y||t[19]!==r?(b=(0,Z.jsx)(w8,{items:g,limit:y,maxHeight:i,isActive:!0,showIndex:!0,showIndicators:!0,onSubmit:v,onTab:v,onCancel:r}),t[15]=i,t[16]=g,t[17]=v,t[18]=y,t[19]=r,t[20]=b):b=t[20];let x;t[21]===m?x=t[22]:(x=m&&(0,Z.jsx)(Q,{marginTop:0,children:(0,Z.jsx)($,{dimColor:!0,children:`Searching...`})}),t[21]=m,t[22]=x);let S;return t[23]!==b||t[24]!==x?(S=(0,Z.jsxs)(Q,{flexDirection:`column`,children:[b,x]}),t[23]=b,t[24]=x,t[25]=S):S=t[25],S});B8.displayName=`FileMentionPicker`;const V8=[[`! for terminal/bash mode`,`/ for commands`,`@ for file paths`],[`esc esc to clear input`,`shift + tab to cycle agent modes`,`${BGe().toLowerCase()} for newline`],[`ctrl + z to undo`,`ctrl + v to paste images`]],H8=(0,X.memo)(e=>{let t=(0,cQ.c)(14),{availableHeight:n}=e;if(n!==void 0&&n<3)return null;let r,i,a,o,s,c;if(t[0]!==n){let e=n!==void 0&&n<6?V8.slice(0,1):n!==void 0&&n<9?V8.slice(0,2):V8;r=Q,i=`row`,a=5,o=1,s=`wrap`,c=e.map(GKe),t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c}else r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6];let l;return t[7]!==r||t[8]!==i||t[9]!==a||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,Z.jsx)(r,{flexDirection:i,columnGap:a,rowGap:o,flexWrap:s,children:c}),t[7]=r,t[8]=i,t[9]=a,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l});H8.displayName=`Help`;function WKe(e){return(0,Z.jsx)($,{dimColor:!0,children:e},e)}function GKe(e,t){return(0,Z.jsx)(Q,{flexDirection:`column`,children:e.map(WKe)},t)}function KKe(){return{mode:0,render:({prompt:e,hints:t,availableHeight:n})=>(0,Z.jsx)(P8,{hints:t,availableHeight:n})}}function qKe(){return{mode:1,render:({availableHeight:e})=>(0,Z.jsx)(H8,{availableHeight:e})}}function JKe(e){return{mode:4,render:({prompt:t,availableHeight:n})=>(0,Z.jsx)(B8,{onAccept:e,onCancel:e,availableHeight:n}),shouldPreventDefault:(e,t)=>t.upArrow||t.downArrow||t.escape||t.return||t.tab}}function YKe(e,t){let n=(0,cQ.c)(25),r=kKe(),i=dKe(t),a;n[0]!==r.renderer||n[1]!==r.submitCommand?(a={mode:2,render:r.renderer,onSubmit:r.submitCommand},n[0]=r.renderer,n[1]=r.submitCommand,n[2]=a):a=n[2];let o=a,s;n[3]!==i.executeCommand||n[4]!==i.renderer||n[5]!==i.shouldPreventDefault?(s={mode:3,render:i.renderer,onSubmit:i.executeCommand,shouldPreventDefault:i.shouldPreventDefault},n[3]=i.executeCommand,n[4]=i.renderer,n[5]=i.shouldPreventDefault,n[6]=s):s=n[6];let c=s,l;n[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=[0,KKe()],n[7]=l):l=n[7];let u;n[8]===Symbol.for(`react.memo_cache_sentinel`)?(u=[1,qKe()],n[8]=u):u=n[8];let d;n[9]===o?d=n[10]:(d=[2,o],n[9]=o,n[10]=d);let f;n[11]===c?f=n[12]:(f=[3,c],n[11]=c,n[12]=f);let p;n[13]===e?p=n[14]:(p=JKe(e),n[13]=e,n[14]=p);let m;n[15]===p?m=n[16]:(m=[4,p],n[15]=p,n[16]=m);let h;n[17]!==d||n[18]!==f||n[19]!==m?(h=new Map([l,u,d,f,m]),n[17]=d,n[18]=f,n[19]=m,n[20]=h):h=n[20];let g=h,_;return n[21]!==r.getActivity||n[22]!==r.navigateHistory||n[23]!==g?(_={handlers:g,getActivity:r.getActivity,bashNavigateHistory:r.navigateHistory},n[21]=r.getActivity,n[22]=r.navigateHistory,n[23]=g,n[24]=_):_=n[24],_}const XKe={0:{color:void 0,placeholder:`Try "Build a ecommerce website..."`,prefix:`❯`},1:{color:void 0,placeholder:`Try "Build a ecommerce website..."`,prefix:`❯`},2:{color:`brightgreen`,placeholder:oGe()?`Try "dir"`:`Try "ls -la"`,prefix:`!`},3:{color:`brightmagenta`,placeholder:`Try "/resume <chat title>"`,prefix:`❯`},4:{color:`brightcyan`,placeholder:`Try "@help.md"`,prefix:`@`}},ZKe={"!":{mode:2,preventDefault:!0,atStartOnly:!0},"?":{mode:1,preventDefault:!0,atStartOnly:!0},"@":{mode:4,preventDefault:!1,atStartOnly:!1}},U8=(0,X.memo)(({hints:e,composerRef:t})=>{let{prompt:n,setPrompt:r,mode:i,setMode:a,bufferRef:o,activity:s,setActivity:c,queuedMessages:l,nq:u,clearQueue:d,addAttachment:f,clearAttachments:p,ghostText:m,commandOverlay:h}=v8(),g=(0,X.useCallback)(()=>{let e=l.filter(e=>!e.hidden);if(e.length===0)return;let t=e.map(e=>e.message).join(`
75374
- `);o.current?.setText(t),d()},[l,o,d]),{updateInfo:_,autoUpdate:v}=tGe(),y=(0,X.useCallback)(e=>o.current?.getExpandedText(e)??e,[o]),b=(0,X.useCallback)(()=>{},[]),x=(0,X.useRef)({text:``,timer:null}),S=(0,X.useRef)(null);S.current||(S.current=new oJ(`cli-repl`),S.current.load());let C=S.current,w=(0,X.useRef)(``),T=(0,X.useRef)(0),E=(0,X.useRef)(null),D=(0,X.useCallback)(e=>{if(!new Set([0,1]).has(i))return!1;let t=e.trim();if(!t.startsWith(`/`))return!0;let n=t.slice(1).split(/\s/)[0]||``;return!(n===``||!/[/\\.]/.test(n)&&/^[a-zA-Z]/.test(n))},[i]);(0,X.useImperativeHandle)(t,()=>({hasText:()=>n.length>0,hasQueue:()=>l.some(e=>!e.hidden),saveAndClear:()=>{let e=n.trimStart();e&&D(e)&&(C.append(e),C.resetNavigation()),o.current?.setText(``),b(),p()},clear:()=>{o.current?.setText(``),b(),p()},clearQueue:()=>d(),dequeueAllToComposer:()=>g()}));let{currentFile:O,selectionStartLine:k,selectionEndLine:A}=W3(),{sendMessage:j,segments:M,clearSegments:N,clearSegmentsOnly:ee,clearTempSegments:te,stop:F,addNotification:I,mcp:L,isDirectoryAllowed:ne,addAllowedDirectory:R,refreshMcpTools:z,loadConversation:re,agentStatus:ie,segmentsLength:ae,conversationId:oe,dequeuedOnStop:se,clearDequeuedOnStop:ce,listTerminalSessions:le,getTerminalSessionOutput:ue,stopTerminalSession:de,totalCredits:fe,contextPercent:B,contextTokensUsed:pe,contextWindowMax:me,resolvedConversationLlmName:he}=n6(),{apiClient:ge,authManager:_e}=Z3(),{data:ve=[],refetch:ye}=aGe(ge),be=N$(),{cycleAgentMode:V,resetToNormal:xe,isWaitingForYoloConfirm:Se}=j2(),Ce=(0,X.useContext)(P2),we=iGe(),{requestFullRedraw:Ee}=wPe(),{handlers:De,getActivity:Oe,bashNavigateHistory:ke}=YKe(()=>a(0),(0,X.useCallback)(()=>{o.current?.setText(``)},[o])),Ae=De.get(i)||null,[je,Me]=(0,X.useState)([]),Ne=(0,X.useRef)([]),[Pe,Fe]=(0,X.useState)(``),[Ie,Le]=(0,X.useState)(null),[Re,ze]=(0,X.useState)(!1),[Be,Ve]=(0,X.useState)(!1),H=(0,X.useMemo)(()=>({agentStatus:ie,segmentsLength:ae,isLoggedIn:Ie??!1}),[ie,ae,Ie]),He=(0,X.useCallback)(async()=>{try{let e=await ge.getConversationsList(hn.agentType,process.cwd());if(e?.result){let t=e.result.slice(0,25);Me(t),Ne.current=t}}catch{}},[ge]);(0,X.useEffect)(()=>{He()},[He]),(0,X.useEffect)(()=>{ge.getUserInfo().then(e=>Le(!!e?.result?.email)).catch(()=>{Le(_e.isAuthenticated())})},[ge,_e]),(0,X.useEffect)(()=>{se&&(o.current?.setText(se),ce())},[se,ce,o]);let Ue=Pe||ve[0]?.llmName||``;(0,X.useEffect)(()=>{he&&ve.find(e=>e.llmName===he)&&Fe(he)},[he,ve]),(0,X.useEffect)(()=>{if(!Re){Ve(!1);return}let e=setInterval(()=>Ve(e=>!e),500);return()=>clearInterval(e)},[Re]),(0,X.useEffect)(()=>{oKe({onExit:()=>{HQ(0)},onNewChat:()=>{N(),d(),o.current?.setText(``),Fe(``),Ee()},onClearChat:()=>{ee(),o.current?.setText(``),Ee()},onStop:()=>{F()},onModelChange:e=>{let t=ve.find(t=>t.llmName===e);t?(Fe(t.llmName),o.current?.setText(``)):I(`Model not found`,`error`)},onResumeChat:async e=>{let t=Ne.current.find(t=>t.deploymentConversationId===e);if(t||=Ne.current.find(t=>(t.name||t.deploymentConversationId||`Untitled`).toLowerCase().includes(e.toLowerCase())),t||(await He(),t=Ne.current.find(t=>t.deploymentConversationId===e),t||=Ne.current.find(t=>(t.name||t.deploymentConversationId||`Untitled`).toLowerCase().includes(e.toLowerCase()))),!t)try{let n=(await ge.searchConversations(e,hn.agentType))?.result??[];if(n.length>0&&(t=n.find(t=>t.deploymentConversationId===e),!t)){let r=e.toLowerCase();t=n.find(e=>(e.name||e.deploymentConversationId||`Untitled`).toLowerCase().includes(r))}}catch{}if(t?.deploymentConversationId)try{d(),o.current?.setText(``),await re(t.deploymentConversationId),I(`Resumed conversation: ${t.name||t.deploymentConversationId}`,`info`)}catch(e){I(`Failed to load conversation: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}else I(`Conversation "${e}" not found`,`error`)},onLogin:async e=>{try{if(_e.isEnvAuth()){I(`You are authenticated via an environment variable. Unset it to use /login or /logout.`,`error`);return}if(!e){I(`Usage: /login <email> or /login <api_key>`,`error`);return}if(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){let t=e,n=await CY(),r=await ge.authenticateDeviceForCodeLlm(t,n);if(!r?.success||!r?.result){I(r?.error??`Failed to start device code login`,`error`);return}let{verificationUri:i,userCode:a,pollingInterval:o}=r.result;I(`Open the URL and enter the code to authenticate.\n\nURL: ${i}\nCode: ${a}\n\nPolling for completion...`,`info`),(async()=>{let e=(o||5)*1e3,t=Date.now()+600*1e3;for(;Date.now()<t;){await sGe(e);try{let e=await ge.pollDeviceCode(a);if(e?.success&&e.result?.deviceCode){let t=e.result.deviceCode,n=e.result.chatWebUrl;if(await _e.loginWithDeviceCode(t),n){let e=n.replace(/^https?:\/\//,``);ge.setChatWebDomain(e)}I(`Authentication successful!`,`info`),Le(!0),await He(),await ye();return}}catch{}}I(`Authentication timed out. Please try again.`,`error`)})()}else{await _e.loginWithApiKey(e);try{(await ge.getUserInfo())?.result?.email?(I(`API key login successful!`,`info`),Le(!0),await He(),await ye()):(await _e.logout(),I(`Invalid API key — authentication failed`,`error`))}catch(e){await _e.logout(),I(`API key authentication failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}}o.current?.setText(``)}catch(e){I(`Login failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}},onLogout:async()=>{if(_e.isEnvAuth()){I(`You are authenticated via an environment variable. Unset it to use /login or /logout.`,`error`);return}await _e.logout(),Le(!1)},getUserInfo:async()=>{try{let e=await ge.getUserInfo();if(e?.success&&e.result){let{name:t,email:n,organization:r}=e.result,i=r?.name||`No team`,a=_e.getAuthKind(),o=a.type===`env_api_key`?`API key (env)`:a.type===`env_device_code`?`Device code (env)`:a.type===`api_key`?`API key`:a.type===`device_code`?`Device code`:a.type===`oauth_token`?`OAuth token`:`Unknown`;I(`User Status:\n\nName: ${t||`N/A`}\nEmail: ${n||`N/A`}\nTeam: ${i}\nAuth Method: ${o}`,`info`)}else I(`Failed to get user info`,`error`)}catch{I(`Failed to get user info`,`error`)}},getModels:async()=>ve.filter(e=>e.codeAgentSupported).map(e=>({label:e.name||e.llmName,value:e.llmName,model:e})),getChatTitles:async()=>(await He(),Ne.current.map(e=>({id:e.deploymentConversationId||``,title:e.name||e.deploymentConversationId||`Untitled`,messageCount:e.hasHistory,date:e.createdAt}))),searchChatTitles:async e=>{try{let t=await ge.searchConversations(e,hn.agentType);if(t?.result)return t.result.map(e=>({id:e.deploymentConversationId||``,title:e.name||e.deploymentConversationId||`Untitled`,messageCount:e.hasHistory,date:e.createdAt}))}catch{}return[]},addNotification:I,mcp:L,isDirectoryAllowed:ne,addAllowedDirectory:R,refreshMcpTools:z,getAgentStatus:()=>ie,getTotalCredits:fe>0?()=>Promise.resolve(fe):void 0,getContextInfo:()=>({contextPercent:B,contextTokensUsed:pe,contextWindowMax:me}),loginAuth:{initiateDeviceCode:async e=>{let t=await CY(),n=await ge.authenticateDeviceForCodeLlm(e,t);return!n?.success||!n?.result?{success:!1,error:n?.error??`Failed to start device code login`}:{success:!0,verificationUri:n.result.verificationUri,userCode:n.result.userCode,pollingInterval:n.result.pollingInterval}},pollDeviceCode:async e=>{let t=await ge.pollDeviceCode(e);return t?.success&&t.result?.deviceCode?{success:!0,deviceCode:t.result.deviceCode,chatWebUrl:t.result.chatWebUrl}:{success:!1}},completeDeviceCodeLogin:async(e,t)=>{if(await _e.loginWithDeviceCode(e),t){let e=t.replace(/^https?:\/\//,``);ge.setChatWebDomain(e)}Le(!0),await He(),await ye()},loginWithApiKey:async e=>{if(await _e.loginWithApiKey(e),!(await ge.getUserInfo())?.result?.email)throw await _e.logout(),Error(`Invalid API key — authentication failed`);Le(!0),await He(),await ye()},isEnvAuth:()=>_e.isEnvAuth()},checkEnvAuth:()=>({isEnvAuth:_e.isEnvAuth(),shouldHide:_e.isEnvAuth()}),getUpdateInfo:()=>_,listTerminalSessions:le,getTerminalSessionOutput:ue,stopTerminalSession:de,getLastAssistantMessage:()=>{for(let e=M.length-1;e>=0;e--){let t=M[e];if(t.source===`bot`&&t.type===`text`&&t.status===`completed`){let e=p6(t.segment);if(e?.trim())return e}}return null},getCwd:()=>process.cwd(),getSegmentsForExport:()=>M,getOrganizations:async()=>{try{let e=await ge.listOrganizations();return!e?.success||!e.result?[]:e.result.map(e=>({id:e.organizationId,name:e.name,workspace:e.workspace}))}catch{return[]}},onOrgSwitch:async e=>{try{let t=await ge.switchOrganization(e);return t&&(await He(),await ye(),be.invalidateQueries({queryKey:[`userInfo`]})),t}catch{return!1}}})},[ve,M,N,ee,Ee,d,o,ge,ye,F,I,L,ne,R,z,re,je,He,ie,oe,_e,_,le,ue,de,fe,B,pe,me,be]);let U=(0,X.useCallback)(async e=>{try{let t=await Te.stat(e),n=await Te.readFile(e),r={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".webp":`image/webp`,".gif":`image/gif`,".heic":`image/heic`,".heif":`image/heif`}[P.extname(e).toLowerCase()]??`image/png`;f({doc_id:`tui-`+Math.random().toString(36).slice(2,11)+`-`+Date.now().toString(36),filename:e,filePath:P.resolve(e),fileName:P.basename(e),content:n.toString(`base64`),mimeType:r,mime_type:r,size:t.size,metadata:{uploadedAt:new Date().toISOString(),source:`tui-clipboard`,isImage:!0,encoding:`base64`}})}catch{}},[f]),We=(0,X.useCallback)(async()=>{if(await a4()){let e=await o4();if(e){let t=c4(l4(e));o.current?.insert(`@${t} `),await U(e);return}}let e=await HHe();if(!e)return;let t=u4(e.trim());if(t){o.current?.insert(t.mentionText);for(let e of t.persistedImagePaths)U(e);return}t4(e.trim())||o.current?.insert(e,{isPaste:!0})},[o,U]),Ge=(0,X.useCallback)(e=>{let t=e.target.cursor[0]===0&&e.target.cursor[1]===0;if(!e.key.paste){let t=process.platform===`darwin`&&e.key.super&&e.input===`v`,n=process.platform!==`darwin`&&e.key.ctrl&&e.input===`v`||process.platform===`linux`&&e.key.ctrl&&e.key.shift&&e.input===`V`;if(t||n){We(),e.preventDefault();return}}if(e.key.paste){let t=e.input.replace(/[\r\n]+$/,``),n=u4(t.trim());if(n){o.current?.insert(n.mentionText);for(let e of n.persistedImagePaths)U(e);e.preventDefault();return}if(t4(t.trim())){e.preventDefault();return}(async()=>{if(await a4()){let e=await o4();if(e){let t=c4(l4(e));o.current?.insert(`@${t} `),await U(e);return}}o.current?.insert(t,{isPaste:!0})})(),e.preventDefault();return}if(e.input.length>3&&!e.key.ctrl&&!e.key.meta&&!e.key.paste){x.current.text+=e.input,x.current.timer&&clearTimeout(x.current.timer),x.current.timer=setTimeout(()=>{let e=x.current.text;x.current={text:``,timer:null};let t=u4(e.trim());if(t){o.current?.insert(t.mentionText);for(let e of t.persistedImagePaths)U(e);return}t4(e.trim())||o.current?.insert(e,{isPaste:!0})},50),e.preventDefault();return}if(i===0&&e.key.upArrow&&e.target.visualCursor[0]===0&&l.some(e=>!e.hidden)&&n.trim()===``){g(),e.preventDefault();return}if(Ae?.shouldPreventDefault&&Ae.shouldPreventDefault(e.input||``,e.key)){e.preventDefault();return}if((i===0||i===1||i===4)&&(e.key.upArrow||e.key.downArrow)){let t=e.target,r=t.visualCursor[0]===0,i=t.visualCursor[0]>=t.allVisualLines.length-1;if(e.key.upArrow&&r){if(C.getEntries().length>0){C.isNavigating()||(w.current=n);let t=C.navigateUp();if(t){o.current?.setText(t.message),e.preventDefault();return}}}else if(e.key.downArrow&&i){if(!C.isNavigating()){e.preventDefault();return}let t=C.navigateDown();t?o.current?.setText(t.message):o.current?.setText(w.current),e.preventDefault();return}}if(i===2&&ke){let t=e.target,n=e.key.upArrow&&t.visualCursor[0]===0,r=e.key.downArrow&&t.visualCursor[0]>=t.allVisualLines.length-1;if(n||r){let t=ke(e.key.upArrow?`up`:`down`);if(t!==null){o.current?.setText(t),e.preventDefault();return}}}if(t&&e.key.backspace){if(Se){xe(),e.preventDefault();return}i!==0&&(a(0),C.resetNavigation(),w.current=``,e.preventDefault());return}if(i===0&&e.key.shift&&e.key.tab){V(),e.preventDefault();return}let r=ZKe[e.input];if(r&&(!r.atStartOnly||t)){i!==r.mode&&a(r.mode),r.preventDefault&&r.mode!==3&&e.preventDefault();return}},[i,a,Ae,ke,o,We,U,l,n,d,g,Se,xe,V,C]);(0,X.useEffect)(()=>{if(i===0)return;let e=n.trim();if(i===4){let e=o.current;e&&(x8(e.text,e.cursor)||a(0))}else if(i===3)if(e.length===0)a(0);else{let t=e.startsWith(`/`),n=e.slice(1).split(/\s/)[0]||``;t&&(n===``||!/[/\\.]/.test(n)&&/^[a-zA-Z]/.test(n))||a(0)}},[i,n,o,a]),(0,X.useEffect)(()=>{if(i!==1)return;let e=setTimeout(()=>{a(0)},3e4);return()=>clearTimeout(e)},[i,a]);let Ke=(0,X.useCallback)((e,t)=>{let n=T.current;T.current=e.length,r(e);let o=e.trim(),s=o.startsWith(`/`),c=o.slice(1).split(/\s/)[0]||``,l=s&&(c===``||!/[/\\.]/.test(c)&&/^[a-zA-Z]/.test(c)),u=ie===zd.Submitted||ie===zd.Streaming||ie===zd.ExecutingTool||ie===zd.WaitingForToolPermission;e.length>0&&!l&&!u&&te();let d=x8(e,t.cursor);if(o.length===0&&n>0&&(i===3||i===2||i===1)){a(0);return}if(d){i!==4&&a(4);return}if(i===4){d||a(0);return}i===1&&o.length>0&&a(0),E.current&&=(clearTimeout(E.current),null),!l&&i===3&&o.length>0?a(0):l&&i!==3&&(E.current=setTimeout(()=>{E.current=null,a(3)},80))},[i,r,a,te,ie]),qe=(0,X.useCallback)(async e=>{let t=e.trim(),n=p8.match(t,i);if(n&&await p8.execute(n)){o.current?.setText(``),p();return}if(t.startsWith(`/`)){let e=Jq.matchSkill(t);if(e){if(Ie===!1){I(`Not logged in. Use /login email@example.com to login.`,`warning`);return}let n=y(t);if(ie===zd.Submitted||ie===zd.Streaming||ie===zd.ExecutingTool||ie===zd.WaitingForToolPermission){u(n),o.current?.setText(``),b();return}j({message:n,selectedModel:Pe||ve[0]?.llmName||void 0,activeSkills:[e.skill.id]}),o.current?.setText(``),b(),p();return}}if(Ae?.onSubmit){Ae.onSubmit(e),i===2?(o.current?.setText(``),c(Oe())):i===3&&a(0),p();return}switch(i){case 0:if(Ie===!1){let t=e.trimStart();t&&D(t)&&(C.append(t),C.resetNavigation()),I(`Not logged in. Use /login email@example.com to login.`,`warning`);return}if(ie===zd.Submitted||ie===zd.Streaming||ie===zd.ExecutingTool||ie===zd.WaitingForToolPermission){let t=y(e.trimStart());u(t),D(t)&&(C.append(t),C.resetNavigation()),w.current=``,b(),o.current?.setText(``);return}let t=Pe||ve[0]?.llmName||void 0,n=y(e);D(n)&&(C.append(n),C.resetNavigation()),w.current=``,j({message:n,selectedModel:t}),b(),p();return;default:}},[i,Ae,j,Oe,c,Pe,a,o,ie,u,I,p,Ie,y,b,C,ve]),{color:Je,placeholder:Ye,prefix:Xe}=XKe[i],W=ae>0?``:Ye,G=(0,X.useMemo)(()=>sKe(),[]),Ze=(i===2?Oe():s)===`pending`||ie===zd.WaitingForToolPermission,Qe=S2(process.cwd()),$e=(0,X.useMemo)(()=>(0,Z.jsx)(Q,{flexGrow:1,borderStyle:{bottom:`─`},borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderDimColor:!0}),[]);return(0,Z.jsxs)(Z.Fragment,{children:[h,(0,Z.jsx)(X.Activity,{mode:h?`hidden`:`visible`,children:(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(S8,{}),(0,Z.jsxs)(Q,{flexDirection:`row`,alignItems:`flex-end`,children:[Ce&&(0,Z.jsxs)($,{color:`brightmagenta`,bold:!0,children:[`EXPANDED`,` `]}),$e,Ie===!1&&(0,Z.jsx)($,{dimColor:!0,children:` Not logged in`}),Ie===!1&&Ue&&(0,Z.jsx)($,{dimColor:!0,children:` •`}),Ue&&(0,Z.jsxs)($,{children:[` `,ve.find(e=>e.llmName===Ue)?.name||Ue]}),(Ie===!1||Ue)&&(0,Z.jsx)($,{dimColor:!0,children:` •`}),(0,Z.jsxs)($,{color:`brightyellow`,children:[` `,Qe]})]}),(0,Z.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,Z.jsx)($,{color:Je,dimColor:Be,children:Xe}),(0,Z.jsx)(Y6,{ref:o,onChange:Ke,onKeyDown:Ge,onSubmit:qe,placeholder:W,grammar:G,disabled:Ze,ghostText:m??void 0})]}),(0,Z.jsxs)(Q,{flexDirection:`row`,justifyContent:`space-between`,gap:1,children:[(0,Z.jsx)(Q,{flexGrow:1,children:$e}),B!==null&&B>60&&(0,Z.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,Z.jsx)($,{color:B>=80?`red`:`yellow`,children:`●`}),(0,Z.jsxs)($,{color:B>=80?`red`:`yellow`,children:[Math.round(B),`%`]})]})]}),(0,Z.jsxs)(Q,{justifyContent:`space-between`,children:[(0,Z.jsx)(C8,{mode:i,prompt:n,handler:Ae,onExitFilesMode:()=>a(0),onSubmitPrompt:qe,hints:e,availableHeight:we,onLoadingChange:ze,commandContext:H}),(0,Z.jsxs)(Q,{flexDirection:`row`,gap:1,children:[O&&k!==void 0&&A!==void 0?(0,Z.jsxs)($,{dimColor:!0,children:[(0,Z.jsxs)($,{color:`cyan`,children:[A-k+1,` lines selected`]}),` `,`in `,(0,Z.jsx)($,{color:`cyan`,children:P.basename(O)})]}):O&&(0,Z.jsxs)($,{dimColor:!0,children:[`in `,(0,Z.jsx)($,{color:`cyan`,children:P.basename(O)})]}),e?.escClear&&(0,Z.jsx)($,{wrap:`truncate-middle`,dimColor:!0,children:`Press ESC again to clear input`}),e?.escClear&&_&&(0,Z.jsx)($,{dimColor:!0,children:`·`}),_&&(0,Z.jsxs)($,{wrap:`truncate-middle`,dimColor:!0,children:[`Update available (${_.latestVersion})`,!_.isEphemeral&&(_.installationType===`native`&&v?` · Restart to auto-update`:` · Run: ${OQ(_)}`)]})]})]})]})})]})});U8.displayName=`ComposerInner`;const W8=(0,X.memo)(e=>{let t=(0,cQ.c)(3),{hints:n,composerRef:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,Z.jsx)(y8,{children:(0,Z.jsx)(U8,{hints:n,composerRef:r})}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i});W8.displayName=`Composer`;var G8=class extends X.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(e){return{hasError:!0,error:e,errorInfo:null}}componentDidCatch(e,t){fu(e,{componentStack:t.componentStack??void 0}),this.setState({error:e,errorInfo:t}),this.props.onError&&this.props.onError(e,t)}render(){let{hasError:e,error:t,errorInfo:n}=this.state,{fallback:r,children:i}=this.props;return e?r?typeof r==`function`?r(t,n):r:(0,Z.jsxs)(Q,{flexDirection:`column`,padding:1,children:[(0,Z.jsx)($,{color:`red`,bold:!0,children:`Something went wrong.`}),t&&(0,Z.jsxs)(Q,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)($,{color:`yellow`,children:t.toString()}),n?.componentStack&&(0,Z.jsx)($,{color:`brightblack`,children:n.componentStack})]})]}):i}};const K8=(0,X.memo)(e=>{let t=(0,cQ.c)(14),{duration:n,credits:r,conversationId:i}=e,a,o,s,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)($,{color:V$,children:`
75374
+ `);o.current?.setText(t),d()},[l,o,d]),{updateInfo:_,autoUpdate:v}=tGe(),y=(0,X.useCallback)(e=>o.current?.getExpandedText(e)??e,[o]),b=(0,X.useCallback)(()=>{},[]),x=(0,X.useRef)({text:``,timer:null}),S=(0,X.useRef)(null);S.current||(S.current=new oJ(`cli-repl`),S.current.load());let C=S.current,w=(0,X.useRef)(``),T=(0,X.useRef)(0),E=(0,X.useRef)(null),D=(0,X.useCallback)(e=>{if(!new Set([0,1]).has(i))return!1;let t=e.trim();if(!t.startsWith(`/`))return!0;let n=t.slice(1).split(/\s/)[0]||``;return!(n===``||!/[/\\.]/.test(n)&&/^[a-zA-Z]/.test(n))},[i]);(0,X.useImperativeHandle)(t,()=>({hasText:()=>n.length>0,hasQueue:()=>l.some(e=>!e.hidden),saveAndClear:()=>{let e=n.trimStart();e&&D(e)&&(C.append(e),C.resetNavigation()),o.current?.setText(``),b(),p()},clear:()=>{o.current?.setText(``),b(),p()},clearQueue:()=>d(),dequeueAllToComposer:()=>g()}));let{currentFile:O,selectionStartLine:k,selectionEndLine:A}=W3(),{sendMessage:j,segments:M,clearSegments:N,clearSegmentsOnly:ee,clearTempSegments:te,stop:F,addNotification:I,mcp:L,isDirectoryAllowed:ne,addAllowedDirectory:R,refreshMcpTools:z,loadConversation:re,agentStatus:ie,segmentsLength:ae,conversationId:oe,dequeuedOnStop:se,clearDequeuedOnStop:ce,listTerminalSessions:le,getTerminalSessionOutput:ue,stopTerminalSession:de,totalCredits:fe,contextPercent:B,contextTokensUsed:pe,contextWindowMax:me,resolvedConversationLlmName:he,initialModel:ge}=n6(),{apiClient:_e,authManager:ve}=Z3(),{data:ye=[],refetch:be}=aGe(_e),V=N$(),{cycleAgentMode:xe,resetToNormal:Se,isWaitingForYoloConfirm:Ce}=j2(),we=(0,X.useContext)(P2),Ee=iGe(),{requestFullRedraw:De}=wPe(),{handlers:Oe,getActivity:ke,bashNavigateHistory:Ae}=YKe(()=>a(0),(0,X.useCallback)(()=>{o.current?.setText(``)},[o])),je=Oe.get(i)||null,[Me,Ne]=(0,X.useState)([]),Pe=(0,X.useRef)([]),[Fe,Ie]=(0,X.useState)(``),Le=(0,X.useRef)(!1),[Re,ze]=(0,X.useState)(null),[Be,Ve]=(0,X.useState)(!1),[H,He]=(0,X.useState)(!1),Ue=(0,X.useMemo)(()=>({agentStatus:ie,segmentsLength:ae,isLoggedIn:Re??!1}),[ie,ae,Re]),U=(0,X.useCallback)(async()=>{try{let e=await _e.getConversationsList(hn.agentType,process.cwd());if(e?.result){let t=e.result.slice(0,25);Ne(t),Pe.current=t}}catch{}},[_e]);(0,X.useEffect)(()=>{U()},[U]),(0,X.useEffect)(()=>{_e.getUserInfo().then(e=>ze(!!e?.result?.email)).catch(()=>{ze(ve.isAuthenticated())})},[_e,ve]),(0,X.useEffect)(()=>{se&&(o.current?.setText(se),ce())},[se,ce,o]);let We=Fe||ye[0]?.llmName||``;(0,X.useEffect)(()=>{ge&&ye.length>0&&!Le.current&&ye.find(e=>e.llmName===ge)&&(Ie(ge),Le.current=!0)},[ge,ye]),(0,X.useEffect)(()=>{he&&ye.find(e=>e.llmName===he)&&Ie(he)},[he,ye]),(0,X.useEffect)(()=>{if(!Be){He(!1);return}let e=setInterval(()=>He(e=>!e),500);return()=>clearInterval(e)},[Be]),(0,X.useEffect)(()=>{oKe({onExit:()=>{HQ(0)},onNewChat:()=>{N(),d(),o.current?.setText(``),Ie(``),De()},onClearChat:()=>{ee(),o.current?.setText(``),De()},onStop:()=>{F()},onModelChange:e=>{let t=ye.find(t=>t.llmName===e);t?(Ie(t.llmName),o.current?.setText(``)):I(`Model not found`,`error`)},onResumeChat:async e=>{let t=Pe.current.find(t=>t.deploymentConversationId===e);if(t||=Pe.current.find(t=>(t.name||t.deploymentConversationId||`Untitled`).toLowerCase().includes(e.toLowerCase())),t||(await U(),t=Pe.current.find(t=>t.deploymentConversationId===e),t||=Pe.current.find(t=>(t.name||t.deploymentConversationId||`Untitled`).toLowerCase().includes(e.toLowerCase()))),!t)try{let n=(await _e.searchConversations(e,hn.agentType))?.result??[];if(n.length>0&&(t=n.find(t=>t.deploymentConversationId===e),!t)){let r=e.toLowerCase();t=n.find(e=>(e.name||e.deploymentConversationId||`Untitled`).toLowerCase().includes(r))}}catch{}if(t?.deploymentConversationId)try{d(),o.current?.setText(``),await re(t.deploymentConversationId),I(`Resumed conversation: ${t.name||t.deploymentConversationId}`,`info`)}catch(e){I(`Failed to load conversation: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}else I(`Conversation "${e}" not found`,`error`)},onLogin:async e=>{try{if(ve.isEnvAuth()){I(`You are authenticated via an environment variable. Unset it to use /login or /logout.`,`error`);return}if(!e){I(`Usage: /login <email> or /login <api_key>`,`error`);return}if(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){let t=e,n=await CY(),r=await _e.authenticateDeviceForCodeLlm(t,n);if(!r?.success||!r?.result){I(r?.error??`Failed to start device code login`,`error`);return}let{verificationUri:i,userCode:a,pollingInterval:o}=r.result;I(`Open the URL and enter the code to authenticate.\n\nURL: ${i}\nCode: ${a}\n\nPolling for completion...`,`info`),(async()=>{let e=(o||5)*1e3,t=Date.now()+600*1e3;for(;Date.now()<t;){await sGe(e);try{let e=await _e.pollDeviceCode(a);if(e?.success&&e.result?.deviceCode){let t=e.result.deviceCode,n=e.result.chatWebUrl;if(await ve.loginWithDeviceCode(t),n){let e=n.replace(/^https?:\/\//,``);_e.setChatWebDomain(e)}I(`Authentication successful!`,`info`),ze(!0),await U(),await be();return}}catch{}}I(`Authentication timed out. Please try again.`,`error`)})()}else{await ve.loginWithApiKey(e);try{(await _e.getUserInfo())?.result?.email?(I(`API key login successful!`,`info`),ze(!0),await U(),await be()):(await ve.logout(),I(`Invalid API key — authentication failed`,`error`))}catch(e){await ve.logout(),I(`API key authentication failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}}o.current?.setText(``)}catch(e){I(`Login failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}},onLogout:async()=>{if(ve.isEnvAuth()){I(`You are authenticated via an environment variable. Unset it to use /login or /logout.`,`error`);return}await ve.logout(),ze(!1)},getUserInfo:async()=>{try{let e=await _e.getUserInfo();if(e?.success&&e.result){let{name:t,email:n,organization:r}=e.result,i=r?.name||`No team`,a=ve.getAuthKind(),o=a.type===`env_api_key`?`API key (env)`:a.type===`env_device_code`?`Device code (env)`:a.type===`api_key`?`API key`:a.type===`device_code`?`Device code`:a.type===`oauth_token`?`OAuth token`:`Unknown`;I(`User Status:\n\nName: ${t||`N/A`}\nEmail: ${n||`N/A`}\nTeam: ${i}\nAuth Method: ${o}`,`info`)}else I(`Failed to get user info`,`error`)}catch{I(`Failed to get user info`,`error`)}},getModels:async()=>ye.filter(e=>e.codeAgentSupported).map(e=>({label:e.name||e.llmName,value:e.llmName,model:e})),getChatTitles:async()=>(await U(),Pe.current.map(e=>({id:e.deploymentConversationId||``,title:e.name||e.deploymentConversationId||`Untitled`,messageCount:e.hasHistory,date:e.createdAt}))),searchChatTitles:async e=>{try{let t=await _e.searchConversations(e,hn.agentType);if(t?.result)return t.result.map(e=>({id:e.deploymentConversationId||``,title:e.name||e.deploymentConversationId||`Untitled`,messageCount:e.hasHistory,date:e.createdAt}))}catch{}return[]},addNotification:I,mcp:L,isDirectoryAllowed:ne,addAllowedDirectory:R,refreshMcpTools:z,getAgentStatus:()=>ie,getTotalCredits:fe>0?()=>Promise.resolve(fe):void 0,getContextInfo:()=>({contextPercent:B,contextTokensUsed:pe,contextWindowMax:me}),loginAuth:{initiateDeviceCode:async e=>{let t=await CY(),n=await _e.authenticateDeviceForCodeLlm(e,t);return!n?.success||!n?.result?{success:!1,error:n?.error??`Failed to start device code login`}:{success:!0,verificationUri:n.result.verificationUri,userCode:n.result.userCode,pollingInterval:n.result.pollingInterval}},pollDeviceCode:async e=>{let t=await _e.pollDeviceCode(e);return t?.success&&t.result?.deviceCode?{success:!0,deviceCode:t.result.deviceCode,chatWebUrl:t.result.chatWebUrl}:{success:!1}},completeDeviceCodeLogin:async(e,t)=>{if(await ve.loginWithDeviceCode(e),t){let e=t.replace(/^https?:\/\//,``);_e.setChatWebDomain(e)}ze(!0),await U(),await be()},loginWithApiKey:async e=>{if(await ve.loginWithApiKey(e),!(await _e.getUserInfo())?.result?.email)throw await ve.logout(),Error(`Invalid API key — authentication failed`);ze(!0),await U(),await be()},isEnvAuth:()=>ve.isEnvAuth()},checkEnvAuth:()=>({isEnvAuth:ve.isEnvAuth(),shouldHide:ve.isEnvAuth()}),getUpdateInfo:()=>_,listTerminalSessions:le,getTerminalSessionOutput:ue,stopTerminalSession:de,getLastAssistantMessage:()=>{for(let e=M.length-1;e>=0;e--){let t=M[e];if(t.source===`bot`&&t.type===`text`&&t.status===`completed`){let e=p6(t.segment);if(e?.trim())return e}}return null},getCwd:()=>process.cwd(),getSegmentsForExport:()=>M,getOrganizations:async()=>{try{let e=await _e.listOrganizations();return!e?.success||!e.result?[]:e.result.map(e=>({id:e.organizationId,name:e.name,workspace:e.workspace}))}catch{return[]}},onOrgSwitch:async e=>{try{let t=await _e.switchOrganization(e);return t&&(await U(),await be(),V.invalidateQueries({queryKey:[`userInfo`]})),t}catch{return!1}}})},[ye,M,N,ee,De,d,o,_e,be,F,I,L,ne,R,z,re,Me,U,ie,oe,ve,_,le,ue,de,fe,B,pe,me,V]);let Ge=(0,X.useCallback)(async e=>{try{let t=await Te.stat(e),n=await Te.readFile(e),r={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".webp":`image/webp`,".gif":`image/gif`,".heic":`image/heic`,".heif":`image/heif`}[P.extname(e).toLowerCase()]??`image/png`;f({doc_id:`tui-`+Math.random().toString(36).slice(2,11)+`-`+Date.now().toString(36),filename:e,filePath:P.resolve(e),fileName:P.basename(e),content:n.toString(`base64`),mimeType:r,mime_type:r,size:t.size,metadata:{uploadedAt:new Date().toISOString(),source:`tui-clipboard`,isImage:!0,encoding:`base64`}})}catch{}},[f]),Ke=(0,X.useCallback)(async()=>{if(await a4()){let e=await o4();if(e){let t=c4(l4(e));o.current?.insert(`@${t} `),await Ge(e);return}}let e=await HHe();if(!e)return;let t=u4(e.trim());if(t){o.current?.insert(t.mentionText);for(let e of t.persistedImagePaths)Ge(e);return}t4(e.trim())||o.current?.insert(e,{isPaste:!0})},[o,Ge]),qe=(0,X.useCallback)(e=>{let t=e.target.cursor[0]===0&&e.target.cursor[1]===0;if(!e.key.paste){let t=process.platform===`darwin`&&e.key.super&&e.input===`v`,n=process.platform!==`darwin`&&e.key.ctrl&&e.input===`v`||process.platform===`linux`&&e.key.ctrl&&e.key.shift&&e.input===`V`;if(t||n){Ke(),e.preventDefault();return}}if(e.key.paste){let t=e.input.replace(/[\r\n]+$/,``),n=u4(t.trim());if(n){o.current?.insert(n.mentionText);for(let e of n.persistedImagePaths)Ge(e);e.preventDefault();return}if(t4(t.trim())){e.preventDefault();return}(async()=>{if(await a4()){let e=await o4();if(e){let t=c4(l4(e));o.current?.insert(`@${t} `),await Ge(e);return}}o.current?.insert(t,{isPaste:!0})})(),e.preventDefault();return}if(e.input.length>3&&!e.key.ctrl&&!e.key.meta&&!e.key.paste){x.current.text+=e.input,x.current.timer&&clearTimeout(x.current.timer),x.current.timer=setTimeout(()=>{let e=x.current.text;x.current={text:``,timer:null};let t=u4(e.trim());if(t){o.current?.insert(t.mentionText);for(let e of t.persistedImagePaths)Ge(e);return}t4(e.trim())||o.current?.insert(e,{isPaste:!0})},50),e.preventDefault();return}if(i===0&&e.key.upArrow&&e.target.visualCursor[0]===0&&l.some(e=>!e.hidden)&&n.trim()===``){g(),e.preventDefault();return}if(je?.shouldPreventDefault&&je.shouldPreventDefault(e.input||``,e.key)){e.preventDefault();return}if((i===0||i===1||i===4)&&(e.key.upArrow||e.key.downArrow)){let t=e.target,r=t.visualCursor[0]===0,i=t.visualCursor[0]>=t.allVisualLines.length-1;if(e.key.upArrow&&r){if(C.getEntries().length>0){C.isNavigating()||(w.current=n);let t=C.navigateUp();if(t){o.current?.setText(t.message),e.preventDefault();return}}}else if(e.key.downArrow&&i){if(!C.isNavigating()){e.preventDefault();return}let t=C.navigateDown();t?o.current?.setText(t.message):o.current?.setText(w.current),e.preventDefault();return}}if(i===2&&Ae){let t=e.target,n=e.key.upArrow&&t.visualCursor[0]===0,r=e.key.downArrow&&t.visualCursor[0]>=t.allVisualLines.length-1;if(n||r){let t=Ae(e.key.upArrow?`up`:`down`);if(t!==null){o.current?.setText(t),e.preventDefault();return}}}if(t&&e.key.backspace){if(Ce){Se(),e.preventDefault();return}i!==0&&(a(0),C.resetNavigation(),w.current=``,e.preventDefault());return}if(i===0&&e.key.shift&&e.key.tab){xe(),e.preventDefault();return}let r=ZKe[e.input];if(r&&(!r.atStartOnly||t)){i!==r.mode&&a(r.mode),r.preventDefault&&r.mode!==3&&e.preventDefault();return}},[i,a,je,Ae,o,Ke,Ge,l,n,d,g,Ce,Se,xe,C]);(0,X.useEffect)(()=>{if(i===0)return;let e=n.trim();if(i===4){let e=o.current;e&&(x8(e.text,e.cursor)||a(0))}else if(i===3)if(e.length===0)a(0);else{let t=e.startsWith(`/`),n=e.slice(1).split(/\s/)[0]||``;t&&(n===``||!/[/\\.]/.test(n)&&/^[a-zA-Z]/.test(n))||a(0)}},[i,n,o,a]),(0,X.useEffect)(()=>{if(i!==1)return;let e=setTimeout(()=>{a(0)},3e4);return()=>clearTimeout(e)},[i,a]);let Je=(0,X.useCallback)((e,t)=>{let n=T.current;T.current=e.length,r(e);let o=e.trim(),s=o.startsWith(`/`),c=o.slice(1).split(/\s/)[0]||``,l=s&&(c===``||!/[/\\.]/.test(c)&&/^[a-zA-Z]/.test(c)),u=ie===zd.Submitted||ie===zd.Streaming||ie===zd.ExecutingTool||ie===zd.WaitingForToolPermission;e.length>0&&!l&&!u&&te();let d=x8(e,t.cursor);if(o.length===0&&n>0&&(i===3||i===2||i===1)){a(0);return}if(d){i!==4&&a(4);return}if(i===4){d||a(0);return}i===1&&o.length>0&&a(0),E.current&&=(clearTimeout(E.current),null),!l&&i===3&&o.length>0?a(0):l&&i!==3&&(E.current=setTimeout(()=>{E.current=null,a(3)},80))},[i,r,a,te,ie]),Ye=(0,X.useCallback)(async e=>{let t=e.trim(),n=p8.match(t,i);if(n&&await p8.execute(n)){o.current?.setText(``),p();return}if(t.startsWith(`/`)){let e=Jq.matchSkill(t);if(e){if(Re===!1){I(`Not logged in. Use /login email@example.com to login.`,`warning`);return}let n=y(t);if(ie===zd.Submitted||ie===zd.Streaming||ie===zd.ExecutingTool||ie===zd.WaitingForToolPermission){u(n),o.current?.setText(``),b();return}j({message:n,selectedModel:Fe||ye[0]?.llmName||void 0,activeSkills:[e.skill.id]}),o.current?.setText(``),b(),p();return}}if(je?.onSubmit){je.onSubmit(e),i===2?(o.current?.setText(``),c(ke())):i===3&&a(0),p();return}switch(i){case 0:if(Re===!1){let t=e.trimStart();t&&D(t)&&(C.append(t),C.resetNavigation()),I(`Not logged in. Use /login email@example.com to login.`,`warning`);return}if(ie===zd.Submitted||ie===zd.Streaming||ie===zd.ExecutingTool||ie===zd.WaitingForToolPermission){let t=y(e.trimStart());u(t),D(t)&&(C.append(t),C.resetNavigation()),w.current=``,b(),o.current?.setText(``);return}let t=Fe||ye[0]?.llmName||void 0,n=y(e);D(n)&&(C.append(n),C.resetNavigation()),w.current=``,j({message:n,selectedModel:t}),b(),p();return;default:}},[i,je,j,ke,c,Fe,a,o,ie,u,I,p,Re,y,b,C,ye]),{color:Xe,placeholder:W,prefix:G}=XKe[i],Ze=ae>0?``:W,Qe=(0,X.useMemo)(()=>sKe(),[]),$e=(i===2?ke():s)===`pending`||ie===zd.WaitingForToolPermission,et=S2(process.cwd()),tt=(0,X.useMemo)(()=>(0,Z.jsx)(Q,{flexGrow:1,borderStyle:{bottom:`─`},borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderDimColor:!0}),[]);return(0,Z.jsxs)(Z.Fragment,{children:[h,(0,Z.jsx)(X.Activity,{mode:h?`hidden`:`visible`,children:(0,Z.jsxs)(Q,{flexDirection:`column`,children:[(0,Z.jsx)(S8,{}),(0,Z.jsxs)(Q,{flexDirection:`row`,alignItems:`flex-end`,children:[we&&(0,Z.jsxs)($,{color:`brightmagenta`,bold:!0,children:[`EXPANDED`,` `]}),tt,Re===!1&&(0,Z.jsx)($,{dimColor:!0,children:` Not logged in`}),Re===!1&&We&&(0,Z.jsx)($,{dimColor:!0,children:` •`}),We&&(0,Z.jsxs)($,{children:[` `,ye.find(e=>e.llmName===We)?.name||We]}),(Re===!1||We)&&(0,Z.jsx)($,{dimColor:!0,children:` •`}),(0,Z.jsxs)($,{color:`brightyellow`,children:[` `,et]})]}),(0,Z.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,Z.jsx)($,{color:Xe,dimColor:H,children:G}),(0,Z.jsx)(Y6,{ref:o,onChange:Je,onKeyDown:qe,onSubmit:Ye,placeholder:Ze,grammar:Qe,disabled:$e,ghostText:m??void 0})]}),(0,Z.jsxs)(Q,{flexDirection:`row`,justifyContent:`space-between`,gap:1,children:[(0,Z.jsx)(Q,{flexGrow:1,children:tt}),B!==null&&B>60&&(0,Z.jsxs)(Q,{flexDirection:`row`,gap:1,children:[(0,Z.jsx)($,{color:B>=80?`red`:`yellow`,children:`●`}),(0,Z.jsxs)($,{color:B>=80?`red`:`yellow`,children:[Math.round(B),`%`]})]})]}),(0,Z.jsxs)(Q,{justifyContent:`space-between`,children:[(0,Z.jsx)(C8,{mode:i,prompt:n,handler:je,onExitFilesMode:()=>a(0),onSubmitPrompt:Ye,hints:e,availableHeight:Ee,onLoadingChange:Ve,commandContext:Ue}),(0,Z.jsxs)(Q,{flexDirection:`row`,gap:1,children:[O&&k!==void 0&&A!==void 0?(0,Z.jsxs)($,{dimColor:!0,children:[(0,Z.jsxs)($,{color:`cyan`,children:[A-k+1,` lines selected`]}),` `,`in `,(0,Z.jsx)($,{color:`cyan`,children:P.basename(O)})]}):O&&(0,Z.jsxs)($,{dimColor:!0,children:[`in `,(0,Z.jsx)($,{color:`cyan`,children:P.basename(O)})]}),e?.escClear&&(0,Z.jsx)($,{wrap:`truncate-middle`,dimColor:!0,children:`Press ESC again to clear input`}),e?.escClear&&_&&(0,Z.jsx)($,{dimColor:!0,children:`·`}),_&&(0,Z.jsxs)($,{wrap:`truncate-middle`,dimColor:!0,children:[`Update available (${_.latestVersion})`,!_.isEphemeral&&(_.installationType===`native`&&v?` · Restart to auto-update`:` · Run: ${OQ(_)}`)]})]})]})]})})]})});U8.displayName=`ComposerInner`;const W8=(0,X.memo)(e=>{let t=(0,cQ.c)(3),{hints:n,composerRef:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,Z.jsx)(y8,{children:(0,Z.jsx)(U8,{hints:n,composerRef:r})}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i});W8.displayName=`Composer`;var G8=class extends X.Component{state={hasError:!1,error:null,errorInfo:null};static getDerivedStateFromError(e){return{hasError:!0,error:e,errorInfo:null}}componentDidCatch(e,t){fu(e,{componentStack:t.componentStack??void 0}),this.setState({error:e,errorInfo:t}),this.props.onError&&this.props.onError(e,t)}render(){let{hasError:e,error:t,errorInfo:n}=this.state,{fallback:r,children:i}=this.props;return e?r?typeof r==`function`?r(t,n):r:(0,Z.jsxs)(Q,{flexDirection:`column`,padding:1,children:[(0,Z.jsx)($,{color:`red`,bold:!0,children:`Something went wrong.`}),t&&(0,Z.jsxs)(Q,{marginTop:1,flexDirection:`column`,children:[(0,Z.jsx)($,{color:`yellow`,children:t.toString()}),n?.componentStack&&(0,Z.jsx)($,{color:`brightblack`,children:n.componentStack})]})]}):i}};const K8=(0,X.memo)(e=>{let t=(0,cQ.c)(14),{duration:n,credits:r,conversationId:i}=e,a,o,s,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,Z.jsx)($,{color:V$,children:`
75375
75375
  ▞▀▖▌ ▞▀▖▜▘ ▞▀▖▌ ▜▘
75376
75376
  ▙▄▌▛▀▖▝▀▖▞▀▖▌ ▌▞▀▘ ▙▄▌▐ ▌ ▌ ▐
75377
75377
  ▌ ▌▌ ▌▞▀▌▌ ▖▌ ▌▝▀▖▗▖▌ ▌▐ ▌ ▖▌ ▐
@@ -75533,7 +75533,7 @@ ${xZe}${t.trimStart()}`),n=3+f(t.trimStart()).length)}process.stdout.write(`
75533
75533
  `);process.stdout.write(x9.cursor.move(-999,e.length-1)),process.stdout.write(x9.erase.down(e.length))},g=e=>e.replace(/\.+$/,``),_=e=>{let t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},v=(u=``)=>{o=!0,i=UXe(),s=g(u),l=performance.now(),process.stdout.write(`${S9.default.gray(R9)}
75534
75534
  `);let d=0,f=0;p(),a=setInterval(()=>{if(r&&s===c)return;h(),c=s;let n=S9.default.magenta(t[d]);if(r)process.stdout.write(`${n} ${s}...`);else if(e===`timer`)process.stdout.write(`${n} ${s} ${_(l)}`);else{let e=`.`.repeat(Math.floor(f)).slice(0,3);process.stdout.write(`${n} ${s}${e}`)}d=d+1<t.length?d+1:0,f=f<t.length?f+.125:0},n)},y=(t=``,n=0)=>{o=!1,clearInterval(a),h();let r=n===0?S9.default.green(L9):n===1?S9.default.red(iZe):S9.default.red(aZe);s=g(t??s),e===`timer`?process.stdout.write(`${r} ${s} ${_(l)}
75535
75535
  `):process.stdout.write(`${r} ${s}
75536
- `),m(),i()};return{start:v,stop:y,message:(e=``)=>{s=g(e??s)}}};async function X9(e){let{authManager:t,apiClient:n,reason:r,version:i}=e;if(t.isEnvAuth()||r===`welcome`&&t.isAuthenticated())return{success:!0};for(bZe(r===`welcome`?`Welcome to Abacus.AI CLI v${i}`:r===`expired`?`Session expired — please log in again`:`Invalid credentials — please log in again`);;){let e=await yZe({message:`How would you like to log in?`,options:[{value:`email`,label:`Log in with email`},{value:`apikey`,label:`Log in with API key`}]});if(j9(e))return G9(`Login cancelled`),{success:!1};if(e===`email`){let e=await SZe(t,n);if(e===`cancel`)return G9(`Login cancelled`),{success:!1};if(e===`success`)return K9(`You're all set!`),{success:!0}}else{let e=await CZe(t,n);if(e===`cancel`)return G9(`Login cancelled`),{success:!1};if(e===`success`)return K9(`You're all set!`),{success:!0}}}}async function SZe(e,t){let n=await _Ze({message:`Enter your email address`,placeholder:`you@example.com`,validate:e=>{if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))return`Please enter a valid email address`}});if(j9(n))return`cancel`;let r=Y9();r.start(`Initiating device code login...`);let i,a,o;try{let e=await CY(),s=await t.authenticateDeviceForCodeLlm(n,e);if(!s?.success||!s?.result)return r.stop(`Failed to initiate login`),q9.error(s?.error??`Failed to start device code login`),`retry`;i=s.result.verificationUri,a=s.result.userCode,o=s.result.pollingInterval??5,r.stop(`Device code ready`)}catch(e){return r.stop(`Connection failed`),q9.error(e instanceof Error?e.message:`Failed to connect`),`retry`}W9(`URL: ${i}\nCode: ${a}`,`Open the URL and enter the code to log in`);let[s,c]=await Promise.all([J3(i),Y3(a)]);s&&c?q9.info(`Opening browser... (code copied to clipboard)`):s?q9.info(`Opening browser...`):c?q9.info(`Code copied to clipboard. Please open the URL manually.`):q9.info(`Please open the URL above and enter the code to log in.`);let l=Y9();l.start(`Waiting for authentication...`);let u=Date.now()+600*1e3,d=o*1e3;for(;Date.now()<u;){await new Promise(e=>setTimeout(e,d));try{let n=await t.pollDeviceCode(a);if(n?.success&&n.result?.deviceCode){if(await e.loginWithDeviceCode(n.result.deviceCode),n.result.chatWebUrl){let e=n.result.chatWebUrl.replace(/^https?:\/\//,``);t.setChatWebDomain(e)}return l.stop(`Authenticated!`),q9.success(`Logged in successfully`),`success`}}catch{}}return l.stop(`Timed out`),q9.error(`Authentication timed out. Please try again.`),`retry`}async function CZe(e,t){let n=await vZe({message:`Enter your API key · no key? https://abacus.ai/app/abacusai-cli`});if(j9(n))return`cancel`;let r=Y9();r.start(`Validating API key...`);try{await e.loginWithApiKey(n);let i=await t.getUserInfo();return i?.result?.email?(r.stop(`Authenticated!`),q9.success(`Logged in as ${i.result.email}`),`success`):(await e.logout(),r.stop(`Invalid API key`),q9.error(`Invalid API key — authentication failed`),`retry`)}catch(t){return await e.logout(),r.stop(`Login failed`),q9.error(t instanceof Error?t.message:`API key login failed`),`retry`}}function wZe(e){return e.type===`code_llm_tool_call`||e.type===`code_llm_agent_tool_request`}function TZe(e){let t=e.toolUseResult;return!!(t?.rejected||t?.content?.startsWith(`Error:`))}function EZe(e){if(e.type!==`code_llm_notification`)return!1;let t=(e.message??``).toLowerCase();return t.includes(`compacting conversation`)||t.includes(`compacted conversation`)}function DZe(e){let t={toolUses:0,responses:0};for(let n of e)switch(n.type){case`code_llm_tool_call`:case`code_llm_agent_tool_request`:t.toolUses+=Array.isArray(n.toolUseRequest)?n.toolUseRequest.length:1;break;case`text`:n.source===`bot`&&t.responses++;break}return t}function OZe(e,t){return{toolUses:e.toolUses+t.toolUses,responses:e.responses+t.responses}}function kZe(e){let t={toolUses:0,responses:0},n=[],r=[],i=0,a=[];for(let a=0;a<e.length;a++){let o=e[a];if(EZe(o)){let e=DZe(n);t=OZe(t,e),r.push(...n),n=[],i++;continue}n.push(o)}i>0&&a.push({kind:`compacted`,id:`compacted-${i}`,counts:t,segments:r});let o=AZe(n);return a.push(...o),a}function AZe(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.type===`thinking`){t.push({kind:`segment`,segment:r}),n++;continue}if(wZe(r)&&RYe.has(jZe(r))){let i=[r],a=n+1;for(;a<e.length;){let t=e[a];if(t.type===`thinking`){a++;continue}if(TZe(i[i.length-1]))break;if(wZe(t)&&RYe.has(jZe(t)))i.push(t),a++;else break}i.length===1?t.push({kind:`segment`,segment:i[0]}):t.push({kind:`tool-group`,id:i[0].id,segments:i}),n=a;continue}t.push({kind:`segment`,segment:r}),n++}return t}function jZe(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function MZe(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type===`thinking`)return{thinkingStartTime:n.thinkingStartTime??null,thinkingEndTime:n.thinkingEndTime??null}}return{thinkingStartTime:null,thinkingEndTime:null}}function NZe(e){let t=(0,cQ.c)(77),{timing:n}=e,{setTitle:r}=cXe(),{segments:i,agentStatus:a,pendingToolPermission:o,conversationTitle:s,conversationId:c,addNotification:l,stop:u,rejectPendingPermission:d,clearQueue:f,totalCredits:p}=n6(),m=(0,X.useRef)(null),{authExpired:h,clearAuthExpired:g}=Z3(),_,v;t[0]!==l||t[1]!==h||t[2]!==g?(_=()=>{h&&(l(`Session expired — use /login to authenticate again.`,`error`),g())},v=[h,l,g],t[0]=l,t[1]=h,t[2]=g,t[3]=_,t[4]=v):(_=t[3],v=t[4]),(0,X.useEffect)(_,v);let[y,b]=(0,X.useState)(!1),x;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(x=(e,t)=>{(t.ctrl||t.super)&&e===`o`&&b(WZe)},t[5]=x):x=t[5],uQ(x);let S=_Xe(i),C,w;if(t[6]!==i){let e=kZe(i.filter(UZe));C=e.at(-1)??null,w=e.slice(0,-1),t[6]=i,t[7]=C,t[8]=w}else C=t[7],w=t[8];let T;t[9]!==C||t[10]!==w?(T={lastItem:C,prevItems:w},t[9]=C,t[10]=w,t[11]=T):T=t[11];let{lastItem:E,prevItems:D}=T,O;t[12]===i?O=t[13]:(O=MZe(i),t[12]=i,t[13]=O);let{thinkingStartTime:k,thinkingEndTime:A}=O,j=(0,X.useRef)(zd.Idle),[M,N]=(0,X.useState)(null),P,ee;t[14]===a?(P=t[15],ee=t[16]):(P=()=>{let e=j.current===zd.Idle,t=a!==zd.Idle&&a!==zd.WaitingForToolPermission;e&&t?N(Date.now()):a===zd.Idle&&N(null),j.current=a},ee=[a],t[14]=a,t[15]=P,t[16]=ee),(0,X.useEffect)(P,ee);let te=a===zd.WaitingForToolPermission&&o!==null,[F,I]=(0,X.useState)(!1),[L,ne]=(0,X.useState)(`0`),[R,z]=(0,X.useState)(0),re,ie;t[17]!==s||t[18]!==r?(re=()=>{r(s?`${s} • Abacus.AI CLI`:`Abacus.AI CLI`)},ie=[s,r],t[17]=s,t[18]=r,t[19]=re,t[20]=ie):(re=t[19],ie=t[20]),(0,X.useEffect)(re,ie);let ae,oe;t[21]!==n||t[22]!==p?(ae=()=>VQ(async()=>{let e=n.getFormattedDuration();z(p),ne(e),I(!0),await new Promise(HZe)},{wait:2e3,streams:[process.stdout,process.stderr]}),oe=[n,p],t[21]=n,t[22]=p,t[23]=ae,t[24]=oe):(ae=t[23],oe=t[24]),(0,X.useEffect)(ae,oe);let se=o!==null,ce,le;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>m.current?.hasText()??!1,le=()=>m.current?.hasQueue()??!1,t[25]=ce,t[26]=le):(ce=t[25],le=t[26]);let ue,de,fe;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>m.current?.saveAndClear(),de=()=>m.current?.clear(),fe=()=>m.current?.dequeueAllToComposer(),t[27]=ue,t[28]=de,t[29]=fe):(ue=t[27],de=t[28],fe=t[29]);let B;t[30]!==a||t[31]!==f||t[32]!==y||t[33]!==d||t[34]!==u||t[35]!==se?(B={agentStatus:a,hasPendingPermission:se,isExpandedView:y,composerHasText:ce,hasQueuedMessages:le,stopAgent:u,rejectPermission:d,saveAndClearComposer:ue,clearComposer:de,dequeueAllToComposer:fe,clearQueue:f,exitApp:VZe},t[30]=a,t[31]=f,t[32]=y,t[33]=d,t[34]=u,t[35]=se,t[36]=B):B=t[36];let pe=mXe(B),me=a!==zd.Idle&&a!==zd.WaitingForToolPermission,he=o?.request.tool.id??null,ge;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(F5,{}),t[37]=ge):ge=t[37];let _e;if(t[38]!==y||t[39]!==D){let e;t[41]===y?e=t[42]:(e=e=>e.kind===`compacted`?y?e.segments.map(BZe):(0,Z.jsx)(c6,{counts:e.counts,segments:e.segments},e.id):e.kind===`segment`?(0,Z.jsx)(g9,{segment:e.segment},e.segment.id):y?e.segments.map(zZe):(0,Z.jsx)(_9,{segments:e.segments},e.id),t[41]=y,t[42]=e),_e=D.map(e),t[38]=y,t[39]=D,t[40]=_e}else _e=t[40];let ve;t[43]!==y||t[44]!==E?(ve=E&&(E.kind===`compacted`?y?E.segments.map(RZe):(0,Z.jsx)(c6,{counts:E.counts,segments:E.segments},E.id):E.kind===`segment`?(0,Z.jsx)(g9,{segment:E.segment},E.segment.id):y?E.segments.map(LZe):(0,Z.jsx)(_9,{segments:E.segments},E.id)),t[43]=y,t[44]=E,t[45]=ve):ve=t[45];let ye;t[46]!==he||t[47]!==_e||t[48]!==ve?(ye=(0,Z.jsxs)(p2.Provider,{value:he,children:[_e,ve]}),t[46]=he,t[47]=_e,t[48]=ve,t[49]=ye):ye=t[49];let be;t[50]!==y||t[51]!==S?(be=!y&&(0,Z.jsx)(IYe,{state:S}),t[50]=y,t[51]=S,t[52]=be):be=t[52];let V;t[53]!==a||t[54]!==M||t[55]!==me||t[56]!==A||t[57]!==k?(V=me&&(0,Z.jsx)(G8,{onError:IZe,children:(0,Z.jsx)(jYe,{status:a,thinkingStartTime:k,thinkingEndTime:A,runStartTime:M})}),t[53]=a,t[54]=M,t[55]=me,t[56]=A,t[57]=k,t[58]=V):V=t[58];let xe;t[59]!==ye||t[60]!==be||t[61]!==V?(xe=(0,Z.jsxs)(Q,{flexDirection:`column`,gap:1,paddingBottom:1,width:`95%`,children:[ge,ye,be,V]}),t[59]=ye,t[60]=be,t[61]=V,t[62]=xe):xe=t[62];let Se;t[63]!==c||t[64]!==R||t[65]!==L||t[66]!==F||t[67]!==pe||t[68]!==te||t[69]!==o?(Se=F?(0,Z.jsx)(K8,{duration:L,credits:R,conversationId:c}):(0,Z.jsxs)(Z.Fragment,{children:[te&&(0,Z.jsx)(G8,{onError:FZe,children:(0,Z.jsx)(rXe,{pendingTool:o})}),(0,Z.jsx)(X.Activity,{mode:te?`hidden`:`visible`,children:(0,Z.jsx)(G8,{fallback:e=>(0,Z.jsxs)(Q,{flexDirection:`column`,paddingX:1,children:[(0,Z.jsx)($,{color:`red`,bold:!0,children:`Something went wrong in the input area.`}),(0,Z.jsx)($,{color:`yellow`,children:e.message}),(0,Z.jsxs)($,{dimColor:!0,children:[`Press Escape to restart the CLI, or resume with: `,hn.binName,` -c`,` `,c]})]}),onError:PZe,children:(0,Z.jsx)(W8,{hints:pe,composerRef:m})})})]}),t[63]=c,t[64]=R,t[65]=L,t[66]=F,t[67]=pe,t[68]=te,t[69]=o,t[70]=Se):Se=t[70];let Ce;t[71]!==xe||t[72]!==Se?(Ce=(0,Z.jsxs)(Z.Fragment,{children:[xe,Se]}),t[71]=xe,t[72]=Se,t[73]=Ce):Ce=t[73];let we;return t[74]!==y||t[75]!==Ce?(we=(0,Z.jsx)(P2.Provider,{value:y,children:Ce}),t[74]=y,t[75]=Ce,t[76]=we):we=t[76],we}function PZe(e){process.stderr.write(`[composer error] ${e.stack??e.message}\n`)}function FZe(e){process.stderr.write(`[tool-permission error] ${e.stack??e.message}\n`)}function IZe(e){process.stderr.write(`[status-indicator error] ${e.stack??e.message}\n`)}function LZe(e){return(0,Z.jsx)(g9,{segment:e},e.id)}function RZe(e){return(0,Z.jsx)(g9,{segment:e},e.id)}function zZe(e){return(0,Z.jsx)(g9,{segment:e},e.id)}function BZe(e){return(0,Z.jsx)(g9,{segment:e},e.id)}function VZe(){return HQ(0)}function HZe(e){return setTimeout(e,100)}function UZe(e){return!e.temp&&!e.isSpinny}function WZe(e){return!e}async function GZe({apiClient:e,authManager:t,configService:n,agentArgs:r}){let i,a=r?.[`permission-mode`];if(a)switch(a){case`yolo`:i=Rd.Yolo;break;case`accept-edits`:i=Rd.AcceptEdits;break;case`plan`:i=Rd.PlanMode;break;default:i=Rd.Normal;break}else r?.[`dangerously-skip-permissions`]?i=Rd.Yolo:r?.[`auto-accept-edits`]?i=Rd.AcceptEdits:r?.[`plan-mode`]&&(i=Rd.PlanMode);await WNe();let o=process.stdout,s=e=>{o&&o.writable&&o.write(e)},c=()=>s(nQ),l=()=>s(tQ),u=!1,d=n.get(`notifications`)??`full`;for(;;){u=!1;let a=new dFe,o=new HWe,s=null,f=()=>{u=!0,s?.unmount()};c();let p=bPe((0,Z.jsx)(Q3,{client:e,authManager:t,onAuthExpired:f,children:(0,Z.jsx)(fFe,{client:a,children:(0,Z.jsx)(f6,{children:(0,Z.jsx)(lXe,{children:(0,Z.jsx)(TWe,{mode:d,children:(0,Z.jsx)(nGe,{configService:n,children:(0,Z.jsx)(bWe,{children:(0,Z.jsx)(N2,{initialMode:i,children:(0,Z.jsx)(xWe,{children:(0,Z.jsx)(t6,{apiClient:e,configService:n,agentArgs:r,children:(0,Z.jsx)(NZe,{timing:o})})})})})})})})})})}),{exitOnCtrlC:!1,suspendable:!0,onSuspended:()=>{process.stderr.write(`
75536
+ `),m(),i()};return{start:v,stop:y,message:(e=``)=>{s=g(e??s)}}};async function X9(e){let{authManager:t,apiClient:n,reason:r,version:i}=e;if(t.isEnvAuth()||r===`welcome`&&t.isAuthenticated())return{success:!0};for(bZe(r===`welcome`?`Welcome to Abacus.AI CLI v${i}`:r===`expired`?`Session expired — please log in again`:`Invalid credentials — please log in again`);;){let e=await yZe({message:`How would you like to log in?`,options:[{value:`email`,label:`Log in with email`},{value:`apikey`,label:`Log in with API key`}]});if(j9(e))return G9(`Login cancelled`),{success:!1};if(e===`email`){let e=await SZe(t,n);if(e===`cancel`)return G9(`Login cancelled`),{success:!1};if(e===`success`)return K9(`You're all set!`),{success:!0}}else{let e=await CZe(t,n);if(e===`cancel`)return G9(`Login cancelled`),{success:!1};if(e===`success`)return K9(`You're all set!`),{success:!0}}}}async function SZe(e,t){let n=await _Ze({message:`Enter your email address`,placeholder:`you@example.com`,validate:e=>{if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))return`Please enter a valid email address`}});if(j9(n))return`cancel`;let r=Y9();r.start(`Initiating device code login...`);let i,a,o;try{let e=await CY(),s=await t.authenticateDeviceForCodeLlm(n,e);if(!s?.success||!s?.result)return r.stop(`Failed to initiate login`),q9.error(s?.error??`Failed to start device code login`),`retry`;i=s.result.verificationUri,a=s.result.userCode,o=s.result.pollingInterval??5,r.stop(`Device code ready`)}catch(e){return r.stop(`Connection failed`),q9.error(e instanceof Error?e.message:`Failed to connect`),`retry`}W9(`URL: ${i}\nCode: ${a}`,`Open the URL and enter the code to log in`);let[s,c]=await Promise.all([J3(i),Y3(a)]);s&&c?q9.info(`Opening browser... (code copied to clipboard)`):s?q9.info(`Opening browser...`):c?q9.info(`Code copied to clipboard. Please open the URL manually.`):q9.info(`Please open the URL above and enter the code to log in.`);let l=Y9();l.start(`Waiting for authentication...`);let u=Date.now()+600*1e3,d=o*1e3;for(;Date.now()<u;){await new Promise(e=>setTimeout(e,d));try{let n=await t.pollDeviceCode(a);if(n?.success&&n.result?.deviceCode){if(await e.loginWithDeviceCode(n.result.deviceCode),n.result.chatWebUrl){let e=n.result.chatWebUrl.replace(/^https?:\/\//,``);t.setChatWebDomain(e)}return l.stop(`Authenticated!`),q9.success(`Logged in successfully`),`success`}}catch{}}return l.stop(`Timed out`),q9.error(`Authentication timed out. Please try again.`),`retry`}async function CZe(e,t){let n=await vZe({message:`Enter your API key · no key? https://abacus.ai/app/abacusai-cli`});if(j9(n))return`cancel`;let r=Y9();r.start(`Validating API key...`);try{await e.loginWithApiKey(n);let i=await t.getUserInfo();return i?.result?.email?(r.stop(`Authenticated!`),q9.success(`Logged in as ${i.result.email}`),`success`):(await e.logout(),r.stop(`Invalid API key`),q9.error(`Invalid API key — authentication failed`),`retry`)}catch(t){return await e.logout(),r.stop(`Login failed`),q9.error(t instanceof Error?t.message:`API key login failed`),`retry`}}function wZe(e){return e.type===`code_llm_tool_call`||e.type===`code_llm_agent_tool_request`}function TZe(e){let t=e.toolUseResult;return!!(t?.rejected||t?.content?.startsWith(`Error:`))}function EZe(e){if(e.type!==`code_llm_notification`)return!1;let t=(e.message??``).toLowerCase();return t.includes(`compacting conversation`)||t.includes(`compacted conversation`)}function DZe(e){let t={toolUses:0,responses:0};for(let n of e)switch(n.type){case`code_llm_tool_call`:case`code_llm_agent_tool_request`:t.toolUses+=Array.isArray(n.toolUseRequest)?n.toolUseRequest.length:1;break;case`text`:n.source===`bot`&&t.responses++;break}return t}function OZe(e,t){return{toolUses:e.toolUses+t.toolUses,responses:e.responses+t.responses}}function kZe(e){let t={toolUses:0,responses:0},n=[],r=[],i=0,a=[];for(let a=0;a<e.length;a++){let o=e[a];if(EZe(o)){let e=DZe(n);t=OZe(t,e),r.push(...n),n=[],i++;continue}n.push(o)}i>0&&a.push({kind:`compacted`,id:`compacted-${i}`,counts:t,segments:r});let o=AZe(n);return a.push(...o),a}function AZe(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.type===`thinking`){t.push({kind:`segment`,segment:r}),n++;continue}if(wZe(r)&&RYe.has(jZe(r))){let i=[r],a=n+1;for(;a<e.length;){let t=e[a];if(t.type===`thinking`){a++;continue}if(TZe(i[i.length-1]))break;if(wZe(t)&&RYe.has(jZe(t)))i.push(t),a++;else break}i.length===1?t.push({kind:`segment`,segment:i[0]}):t.push({kind:`tool-group`,id:i[0].id,segments:i}),n=a;continue}t.push({kind:`segment`,segment:r}),n++}return t}function jZe(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function MZe(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type===`thinking`)return{thinkingStartTime:n.thinkingStartTime??null,thinkingEndTime:n.thinkingEndTime??null}}return{thinkingStartTime:null,thinkingEndTime:null}}function NZe(e){let t=(0,cQ.c)(77),{timing:n}=e,{setTitle:r}=cXe(),{segments:i,agentStatus:a,pendingToolPermission:o,conversationTitle:s,conversationId:c,addNotification:l,stop:u,rejectPendingPermission:d,clearQueue:f,totalCredits:p}=n6(),m=(0,X.useRef)(null),{authExpired:h,clearAuthExpired:g}=Z3(),_,v;t[0]!==l||t[1]!==h||t[2]!==g?(_=()=>{h&&(l(`Session expired — use /login to authenticate again.`,`error`),g())},v=[h,l,g],t[0]=l,t[1]=h,t[2]=g,t[3]=_,t[4]=v):(_=t[3],v=t[4]),(0,X.useEffect)(_,v);let[y,b]=(0,X.useState)(!1),x;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(x=(e,t)=>{(t.ctrl||t.super)&&e===`o`&&b(WZe)},t[5]=x):x=t[5],uQ(x);let S=_Xe(i),C,w;if(t[6]!==i){let e=kZe(i.filter(UZe));C=e.at(-1)??null,w=e.slice(0,-1),t[6]=i,t[7]=C,t[8]=w}else C=t[7],w=t[8];let T;t[9]!==C||t[10]!==w?(T={lastItem:C,prevItems:w},t[9]=C,t[10]=w,t[11]=T):T=t[11];let{lastItem:E,prevItems:D}=T,O;t[12]===i?O=t[13]:(O=MZe(i),t[12]=i,t[13]=O);let{thinkingStartTime:k,thinkingEndTime:A}=O,j=(0,X.useRef)(zd.Idle),[M,N]=(0,X.useState)(null),P,ee;t[14]===a?(P=t[15],ee=t[16]):(P=()=>{let e=j.current===zd.Idle,t=a!==zd.Idle&&a!==zd.WaitingForToolPermission;e&&t?N(Date.now()):a===zd.Idle&&N(null),j.current=a},ee=[a],t[14]=a,t[15]=P,t[16]=ee),(0,X.useEffect)(P,ee);let te=a===zd.WaitingForToolPermission&&o!==null,[F,I]=(0,X.useState)(!1),[L,ne]=(0,X.useState)(`0`),[R,z]=(0,X.useState)(0),re,ie;t[17]!==s||t[18]!==r?(re=()=>{r(s?`${s} • Abacus.AI CLI`:`Abacus.AI CLI`)},ie=[s,r],t[17]=s,t[18]=r,t[19]=re,t[20]=ie):(re=t[19],ie=t[20]),(0,X.useEffect)(re,ie);let ae,oe;t[21]!==n||t[22]!==p?(ae=()=>VQ(async()=>{let e=n.getFormattedDuration();z(p),ne(e),I(!0),await new Promise(HZe)},{wait:2e3,streams:[process.stdout,process.stderr]}),oe=[n,p],t[21]=n,t[22]=p,t[23]=ae,t[24]=oe):(ae=t[23],oe=t[24]),(0,X.useEffect)(ae,oe);let se=o!==null,ce,le;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ce=()=>m.current?.hasText()??!1,le=()=>m.current?.hasQueue()??!1,t[25]=ce,t[26]=le):(ce=t[25],le=t[26]);let ue,de,fe;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>m.current?.saveAndClear(),de=()=>m.current?.clear(),fe=()=>m.current?.dequeueAllToComposer(),t[27]=ue,t[28]=de,t[29]=fe):(ue=t[27],de=t[28],fe=t[29]);let B;t[30]!==a||t[31]!==f||t[32]!==y||t[33]!==d||t[34]!==u||t[35]!==se?(B={agentStatus:a,hasPendingPermission:se,isExpandedView:y,composerHasText:ce,hasQueuedMessages:le,stopAgent:u,rejectPermission:d,saveAndClearComposer:ue,clearComposer:de,dequeueAllToComposer:fe,clearQueue:f,exitApp:VZe},t[30]=a,t[31]=f,t[32]=y,t[33]=d,t[34]=u,t[35]=se,t[36]=B):B=t[36];let pe=mXe(B),me=a!==zd.Idle&&a!==zd.WaitingForToolPermission,he=o?.request.tool.id??null,ge;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Z.jsx)(F5,{}),t[37]=ge):ge=t[37];let _e;if(t[38]!==y||t[39]!==D){let e;t[41]===y?e=t[42]:(e=e=>e.kind===`compacted`?y?e.segments.map(BZe):(0,Z.jsx)(c6,{counts:e.counts,segments:e.segments},e.id):e.kind===`segment`?(0,Z.jsx)(g9,{segment:e.segment},e.segment.id):y?e.segments.map(zZe):(0,Z.jsx)(_9,{segments:e.segments},e.id),t[41]=y,t[42]=e),_e=D.map(e),t[38]=y,t[39]=D,t[40]=_e}else _e=t[40];let ve;t[43]!==y||t[44]!==E?(ve=E&&(E.kind===`compacted`?y?E.segments.map(RZe):(0,Z.jsx)(c6,{counts:E.counts,segments:E.segments},E.id):E.kind===`segment`?(0,Z.jsx)(g9,{segment:E.segment},E.segment.id):y?E.segments.map(LZe):(0,Z.jsx)(_9,{segments:E.segments},E.id)),t[43]=y,t[44]=E,t[45]=ve):ve=t[45];let ye;t[46]!==he||t[47]!==_e||t[48]!==ve?(ye=(0,Z.jsxs)(p2.Provider,{value:he,children:[_e,ve]}),t[46]=he,t[47]=_e,t[48]=ve,t[49]=ye):ye=t[49];let be;t[50]!==y||t[51]!==S?(be=!y&&(0,Z.jsx)(IYe,{state:S}),t[50]=y,t[51]=S,t[52]=be):be=t[52];let V;t[53]!==a||t[54]!==M||t[55]!==me||t[56]!==A||t[57]!==k?(V=me&&(0,Z.jsx)(G8,{onError:IZe,children:(0,Z.jsx)(jYe,{status:a,thinkingStartTime:k,thinkingEndTime:A,runStartTime:M})}),t[53]=a,t[54]=M,t[55]=me,t[56]=A,t[57]=k,t[58]=V):V=t[58];let xe;t[59]!==ye||t[60]!==be||t[61]!==V?(xe=(0,Z.jsxs)(Q,{flexDirection:`column`,gap:1,paddingBottom:1,width:`95%`,children:[ge,ye,be,V]}),t[59]=ye,t[60]=be,t[61]=V,t[62]=xe):xe=t[62];let Se;t[63]!==c||t[64]!==R||t[65]!==L||t[66]!==F||t[67]!==pe||t[68]!==te||t[69]!==o?(Se=F?(0,Z.jsx)(K8,{duration:L,credits:R,conversationId:c}):(0,Z.jsxs)(Z.Fragment,{children:[te&&(0,Z.jsx)(G8,{onError:FZe,children:(0,Z.jsx)(rXe,{pendingTool:o})}),(0,Z.jsx)(X.Activity,{mode:te?`hidden`:`visible`,children:(0,Z.jsx)(G8,{fallback:e=>(0,Z.jsxs)(Q,{flexDirection:`column`,paddingX:1,children:[(0,Z.jsx)($,{color:`red`,bold:!0,children:`Something went wrong in the input area.`}),(0,Z.jsx)($,{color:`yellow`,children:e.message}),(0,Z.jsxs)($,{dimColor:!0,children:[`Press Escape to restart the CLI, or resume with: `,hn.binName,` -c`,` `,c]})]}),onError:PZe,children:(0,Z.jsx)(W8,{hints:pe,composerRef:m})})})]}),t[63]=c,t[64]=R,t[65]=L,t[66]=F,t[67]=pe,t[68]=te,t[69]=o,t[70]=Se):Se=t[70];let Ce;t[71]!==xe||t[72]!==Se?(Ce=(0,Z.jsxs)(Z.Fragment,{children:[xe,Se]}),t[71]=xe,t[72]=Se,t[73]=Ce):Ce=t[73];let we;return t[74]!==y||t[75]!==Ce?(we=(0,Z.jsx)(P2.Provider,{value:y,children:Ce}),t[74]=y,t[75]=Ce,t[76]=we):we=t[76],we}function PZe(e){process.stderr.write(`[composer error] ${e.stack??e.message}\n`)}function FZe(e){process.stderr.write(`[tool-permission error] ${e.stack??e.message}\n`)}function IZe(e){process.stderr.write(`[status-indicator error] ${e.stack??e.message}\n`)}function LZe(e){return(0,Z.jsx)(g9,{segment:e},e.id)}function RZe(e){return(0,Z.jsx)(g9,{segment:e},e.id)}function zZe(e){return(0,Z.jsx)(g9,{segment:e},e.id)}function BZe(e){return(0,Z.jsx)(g9,{segment:e},e.id)}function VZe(){return HQ(0)}function HZe(e){return setTimeout(e,100)}function UZe(e){return!e.temp&&!e.isSpinny}function WZe(e){return!e}async function GZe({apiClient:e,authManager:t,configService:n,agentArgs:r}){let i,a=r?.[`permission-mode`];if(a)switch(a){case`yolo`:i=Rd.Yolo;break;case`accept-edits`:i=Rd.AcceptEdits;break;case`plan`:i=Rd.PlanMode;break;default:i=Rd.Normal;break}else r?.[`dangerously-skip-permissions`]?i=Rd.Yolo:r?.[`auto-accept-edits`]?i=Rd.AcceptEdits:r?.[`plan-mode`]&&(i=Rd.PlanMode);r?.model&&(r.model=await jQ(e,r.model,n.get(`client`))),await WNe();let o=process.stdout,s=e=>{o&&o.writable&&o.write(e)},c=()=>s(nQ),l=()=>s(tQ),u=!1,d=n.get(`notifications`)??`full`;for(;;){u=!1;let a=new dFe,o=new HWe,s=null,f=()=>{u=!0,s?.unmount()};c();let p=bPe((0,Z.jsx)(Q3,{client:e,authManager:t,onAuthExpired:f,children:(0,Z.jsx)(fFe,{client:a,children:(0,Z.jsx)(f6,{children:(0,Z.jsx)(lXe,{children:(0,Z.jsx)(TWe,{mode:d,children:(0,Z.jsx)(nGe,{configService:n,children:(0,Z.jsx)(bWe,{children:(0,Z.jsx)(N2,{initialMode:i,children:(0,Z.jsx)(xWe,{children:(0,Z.jsx)(t6,{apiClient:e,configService:n,agentArgs:r,children:(0,Z.jsx)(NZe,{timing:o})})})})})})})})})})}),{exitOnCtrlC:!1,suspendable:!0,onSuspended:()=>{process.stderr.write(`
75537
75537
  Abacus.AI has been suspended. Run \`fg\` to bring Abacus back.
75538
75538
  `)}});s=p;let m=!1,h=()=>{m||(m=!0,l())},g=()=>{m||(m=!0,p.cleanupTerminal())};if(process.once(`exit`,g),await p.waitUntilExit(),process.off(`exit`,g),h(),!u||!(await X9({authManager:t,apiClient:e,reason:`expired`,version:(await Promise.resolve().then(()=>$e(gQ()))).default.version})).success)break}}const KZe=dt([`codellm`,`cli`,`auth`]);async function qZe(e){let t=await SY.create(),n=new Ou(t,Sn(),gn.userAgentNames.cli,_Q.default.version),r=new rJ({cwd:process.cwd(),extraSources:[{read:async()=>({client:nt.CLI})}]});await r.load();let i=r.get(`baseUrl`);if(typeof i==`string`&&i)try{new URL(i),n.setUrl(i),n.resetEndpoints(),await n.getApiEndpoint()}catch{KZe.error`Invalid base URL: ${i}`,process.exit(1)}let a=!0;switch(e){case`login`:await JZe(t,n);break;case`logout`:a=await YZe(t);break;case`status`:await XZe(t,n);break;case`switch`:a=await ZZe(t,n);break}process.exit(+!a)}async function JZe(e,t){if(e.isEnvAuth()){q9.warn(`Currently authenticated via environment variable. Login is not needed.`);return}if(e.isAuthenticated()){let n=(await t.getUserInfo().catch(()=>null))?.result?.email;n&&q9.info(`Already logged in as ${XZ().bold().render(n)}`);let r=await U9({message:`Do you want to log in with a different account?`});if(j9(r)||!r)return;await e.logout()}await X9({authManager:e,apiClient:t,reason:`welcome`,version:_Q.default.version})}async function YZe(e){return e.isEnvAuth()?(q9.warn(`Currently authenticated via environment variable. Unset the environment variable to log out.`),!0):e.isAuthenticated()?await e.logout()?(q9.success(`Logged out successfully.`),!0):(q9.error(`Failed to log out.`),!1):(q9.info(`Not currently logged in.`),!0)}async function XZe(e,t){let n=e.getAuthKind();if(n.type===`logged_out`){console.log(ZZ(`yellow`)(`Not logged in`));return}let r=n.type===`env_api_key`||n.type===`env_device_code`?`environment variable`:n.type===`api_key`?`API key`:n.type===`device_code`?`device code`:`OAuth token`;console.log(XZ().bold().render(`Authentication Status`)),console.log(` Method: ${r}`);try{let e=await t.getUserInfo();if(e?.result){let{email:t,name:n,organization:r}=e.result;n&&console.log(` Name: ${n}`),t&&console.log(` Email: ${t}`),r?.name&&console.log(` Org: ${r.name}`)}}catch{console.log(XZ().dim().render(` (Could not fetch user details)`))}}async function ZZe(e,t){if(!e.isAuthenticated())return q9.error("Not logged in. Run `auth login` first."),!1;let n=Y9();n.start(`Fetching organizations...`);let r;try{let e=await t.listOrganizations();if(!e?.success||!e.result)return n.stop(`Failed to fetch organizations`),q9.error(`Could not retrieve organizations.`),!1;r=e.result,n.stop(`Organizations loaded`)}catch{return n.stop(`Failed`),q9.error(`Could not fetch organizations.`),!1}if(r.length===0)return q9.info(`No organizations available.`),!0;let i;try{i=(await t.getUserInfo())?.result?.organization?.organizationId}catch{}let a=await yZe({message:`Select an organization to switch to`,options:r.map(e=>({value:e.organizationId,label:e.name,hint:e.organizationId===i?`current`:e.workspace}))});if(j9(a))return G9(`Cancelled`),!0;if(a===i)return q9.info(`Already on this organization.`),!0;let o=Y9();o.start(`Switching organization...`);try{if(await t.switchOrganization(a)){let e=r.find(e=>e.organizationId===a)?.name??a;return o.stop(`Done`),q9.success(`Switched to ${XZ().bold().render(e)}`),!0}else return o.stop(`Failed`),q9.error(`Failed to switch organization.`),!1}catch{return o.stop(`Failed`),q9.error(`Failed to switch organization.`),!1}}async function QZe(e){let{currentVersion:t,explicit:n=!1,autoUpdate:r=!0,updateChannel:i,baseUrl:a}=e;if(!n&&EQ()||!n&&!r)return{action:`skipped`};let o;try{o=await DQ(t,i,a,{includeDev:n})}catch{return n?(q9.error(`Failed to check for updates. Please check your network connection.`),{action:`exit`}):{action:`skipped`}}if(!o)return n&&q9.success(`Already up to date (${t})`),{action:`skipped`};if(!n&&o.isEphemeral)return{action:`skipped`};let s=o.installationType===`native`,c=s?`Download v${o.latestVersion}`:OQ(o);bZe(`Update available: ${o.currentVersion} → ${o.latestVersion}`),s||W9(c,`Install command`);let l=await U9({message:`Would you like to update now?`,initialValue:!0});if(j9(l))return G9(`Update cancelled`),{action:`exit`};if(l){let e=Y9();e.start(`Updating...`);let{ok:t,output:n}=s?await AQ(o):kQ(o);if(t)return e.stop(`Updated to ${o.latestVersion}`),n&&W9(n,`Install output`),K9(`Restarting...`),{action:`updated`,version:o.latestVersion};{e.stop(`Update failed`),n&&W9(n,`Error output`),q9.error(`Update failed. You can try manually running the command above.`);let t=await U9({message:`Continue using v${o.currentVersion}?`,initialValue:!0});return j9(t)||!t?(G9(`Exiting`),{action:`exit`}):(K9(`Continuing with v${o.currentVersion}`),{action:`continue`})}}let u=await U9({message:`Continue using v${o.currentVersion}?`,initialValue:!0});return j9(u)||!u?(G9(`Exiting`),{action:`exit`}):(K9(`Continuing with v${o.currentVersion}`),{action:`continue`})}function $Ze(e,t){switch(e){case`bash`:return nQe(t);case`zsh`:return rQe(t);case`fish`:return iQe(t);case`pwsh`:return aQe(t)}}function eQe(){if(process.env.PSModulePath!==void 0)return`pwsh`;let e=process.env.SHELL??``;return e.endsWith(`zsh`)?`zsh`:e.endsWith(`bash`)?`bash`:e.endsWith(`fish`)?`fish`:process.platform===`win32`?`pwsh`:null}function tQe(e,t,n){switch(e){case`bash`:return n===`darwin`?[`${t}/.bash_profile`,`${t}/.bashrc`]:[`${t}/.bashrc`,`${t}/.bash_profile`];case`zsh`:return[`${t}/.zshrc`];case`fish`:return[`${t}/.config/fish/config.fish`];case`pwsh`:{let e=n===`win32`?i():t;return n===`win32`?[`${e}\\Documents\\PowerShell\\Microsoft.PowerShell_profile.ps1`,`${e}\\Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1`]:[`${t}/.config/powershell/Microsoft.PowerShell_profile.ps1`,`${t}/.config/powershell/profile.ps1`]}}}const Z9=`# Abacus AI shell integration`;function nQe(e){return`\
75539
75539
  ${Z9}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abacus-ai/cli",
3
- "version": "2.5.1-canary.4",
3
+ "version": "2.5.1-canary.7",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "abacusai": "dist/index.mjs"