@abacus-ai/cli 2.4.2 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -73322,7 +73322,7 @@ No matching component was found for:
|
|
|
73322
73322
|
`).map(e=>pz(e,i)).join(`
|
|
73323
73323
|
`):t===`truncate-start`&&(r=r.split(`
|
|
73324
73324
|
`).map(e=>fz(e,i)).join(`
|
|
73325
|
-
`))}}r=uB(e,r),e.renderCache={lines:[r],width:n,height:0,left:l,top:u},t.write(l,u,r,d)}else e.renderCache=void 0;e.renderDirty=!1;return}let f=!1;if(e.nodeName===`jar-view`){e.style.backgroundColor&&dB(l,u,e,t),e.style.borderStyle&&iB(l,u,e,t);let n=e.style.overflowX===`hidden`||e.style.overflow===`hidden`,r=e.style.overflowY===`hidden`||e.style.overflow===`hidden`;if(n||r){let i=n?l+cB(e.style,`Left`):void 0,a=n?l+c.getComputedWidth()-cB(e.style,`Right`):void 0,o=r?u+cB(e.style,`Top`):void 0,s=r?u+c.getComputedHeight()-cB(e.style,`Bottom`):void 0;t.clip({x1:i,x2:a,y1:o,y2:s}),f=!0}}if(e.nodeName===`jar-root`||e.nodeName===`jar-view`){let n=f?u+cB(e.style,`Top`):o,r=f?u+c.getComputedHeight()-cB(e.style,`Bottom`):s;for(let i of e.childNodes)fB(i,t,{offsetX:l,offsetY:u,transformers:d,clipY1:n,clipY2:r});f&&t.unclip()}e.renderDirty=!1};var pB=class{rootNode;lastWidth=0;cachedLines=null;output=new _z(0,0);constructor(e){this.rootNode=e}notifyCommit(){this.cachedLines=null}render(e){let t=e!==this.lastWidth;if(t&&(this.clearAllRenderCaches(this.rootNode),this.lastWidth=e),this.cachedLines&&!this.rootNode.renderDirty&&!t)return this.cachedLines;this.rootNode.yogaNode.setWidth(e),this.rootNode.yogaNode.calculateLayout(void 0,void 0,1);let n=Math.ceil(this.rootNode.yogaNode.getComputedHeight());if(n<=0)return this.cachedLines=[],this.cachedLines;this.output.reset(e,n),fB(this.rootNode,this.output,{});let r=this.output.get(),i=!1;for(let t of r)if(pI(t)>e){i=!0;break}return this.cachedLines=i?r.map(t=>pI(t)>e?xI(t,e):t):r,this.cachedLines}invalidate(){this.cachedLines=null,this.clearAllRenderCaches(this.rootNode)}clearAllRenderCaches(e){e.renderDirty=!0,e.renderCache=void 0;for(let t of e.childNodes)t.nodeName!==`#text`&&this.clearAllRenderCaches(t)}},mB;(function(e){e[e.BlinkingBlock=0]=`BlinkingBlock`,e[e.BlinkingBlockDefault=1]=`BlinkingBlockDefault`,e[e.SteadyBlock=2]=`SteadyBlock`,e[e.BlinkingUnderline=3]=`BlinkingUnderline`,e[e.SteadyUnderline=4]=`SteadyUnderline`,e[e.BlinkingBar=5]=`BlinkingBar`,e[e.SteadyBar=6]=`SteadyBar`})(mB||={});const hB=`\x1B[?25h`,gB=`\x1B[?25l`;function _B(e,t){let n=``;return t!==``&&(n=typeof Buffer<`u`?Buffer.from(t).toString(`base64`):btoa(t)),`\x1B]52;`+String.fromCharCode(e)+`;`+n+`\x07`}function vB(e){return _B(99,e)}function yB(e){let t=e??Wz(),n=t.TERM_PROGRAM.toLowerCase(),r=t.TERM.toLowerCase(),i=(t.LC_TERMINAL??``).toLowerCase();if(n===`iterm.app`)return`iterm2`;if(n===`wezterm`)return`wezterm`;if(n===`ghostty`)return`ghostty`;if(n===`vscode`)return`vscode`;if(n===`tmux`)return`tmux`;if(t.WT_SESSION)return`windows-terminal`;if(r.includes(`kitty`))return`kitty`;if(r.includes(`alacritty`))return`alacritty`;if(r.includes(`foot`))return`foot`;if(r.includes(`contour`))return`contour`;if(r.includes(`rio`))return`rio`;if(r.includes(`ghostty`))return`ghostty`;if(r.includes(`wezterm`))return`wezterm`;if(r.startsWith(`tmux`))return`tmux`;if(r.startsWith(`screen`))return`screen`;if(r===`xterm`||r.startsWith(`xterm-`))return`xterm`;if(r===`linux`)return`linux`;if(!n&&i){if(i===`iterm2`)return`iterm2`;if(i===`wezterm`)return`wezterm`}return`unknown`}function bB(e){return(e??Wz()).isTTY}function xB(e){let t=yB(e);return t===`windows-terminal`||t===`iterm2`||t===`wezterm`||t===`ghostty`}function SB(e){let t=yB(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`xterm`||t===`tmux`||t===`windows-terminal`||t===`rio`||t===`contour`}function CB(e){let t=yB(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`contour`||t===`rio`||t===`vscode`||t===`windows-terminal`}function wB(e,...t){return`\x1B]8;`+(t.length>0?t.join(`:`):``)+`;`+e+`\x07`}function TB(...e){return wB(``,...e)}function EB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function DB(e){return`\x1B]9;`+EB(e)+`\x07`}function OB(e,...t){return`\x1B]99;`+t.map(EB).join(`:`)+`;`+EB(e)+`\x07`}function kB(e){return`\x1B]777;notify;;`+EB(e)+`\x07`}const AB=`\x1B]9;4;0\x07`;function jB(e){return`\x1B]9;4;1;`+Math.min(Math.max(0,e),100)+`\x07`}function MB(e){return`\x1B]9;4;2;`+Math.min(Math.max(0,e),100)+`\x07`}function NB(e){return`\x1B]9;4;4;`+Math.min(Math.max(0,e),100)+`\x07`}var PB=class{env;profile;terminalType;_isDark;_writer;_progressHideTimer=null;constructor(e){this.env=e?.env??Wz(),this.profile=Kz(this.env),Xz(this.profile),this.terminalType=yB(this.env),this._isDark=e?.isDark??Ez(),this._writer=e?.writer??null,e?.isDark!==void 0&&Dz(e.isDark)}get isDark(){return this._isDark}setDark(e){this._isDark=e,Dz(e)}resolveAdaptiveColor(e){if(typeof e==`string`)return Hz.parse(e);let t=this._isDark?e.dark:e.light;return Hz.parse(t)}colorize(e,t,n){if(!t)return e;let r=this.resolveAdaptiveColor(t);if(!r)return e;let i=Zz(r,this.profile);return i?`\x1B[`+(n===`foreground`?i.fgSequence():i.bgSequence())+`m`+e+`\x1B[0m`:e}styledText(){return tB(this.profile)}write(e){this._writer?this._writer(e):typeof process<`u`&&process.stdout?.isTTY&&process.stdout.write(e)}notify(e){if(!bB(this.env))return;let t=this.terminalType,{title:n,body:r}=e,i=n?`${n}:\n${r}`:r;t===`kitty`&&(n?this.write(OB(r,`d=0:p=title`,n)):this.write(OB(r))),this.write(kB(i)),this.write(DB(i))}showProgress(e){if(!xB(this.env))return;this.clearProgressTimer();let t=e.state??`normal`,n=Math.min(Math.max(0,e.percentage??0),100);switch(t){case`indeterminate`:this.write(`\x1B]9;4;3\x07`);break;case`error`:this.write(MB(n));break;case`warning`:this.write(NB(n));break;default:this.write(jB(n));break}(t===`error`||n>=100)&&this.scheduleProgressHide()}hideProgress(){this.clearProgressTimer(),xB(this.env)&&this.write(AB)}async trackProgress(e){this.showProgress({state:`indeterminate`});try{let t=await e;return this.showProgress({percentage:100}),this.scheduleProgressHide(),t}catch(e){throw this.showProgress({percentage:100,state:`error`}),this.scheduleProgressHide(),e}}copyToClipboard(e){SB(this.env)&&this.write(vB(e))}clearClipboard(){SB(this.env)&&this.write(`\x1B]52;c;\x07`)}hyperlink(e,t){return CB(this.env)?wB(e)+t+TB():t}clearProgressTimer(){this._progressHideTimer&&=(clearTimeout(this._progressHideTimer),null)}scheduleProgressHide(){this.clearProgressTimer(),this._progressHideTimer=setTimeout(()=>{this.write(AB),this._progressHideTimer=null},500)}},FB=class{tui;terminal;terminalOutput;rootNode;bridge;container;exitCallbacks=[];exitPromise;resolveExit;exitOnCtrlC;ownsTui;suspendable;onSuspended;cleanupSuspend;originalWarningListeners;warningInterceptor;constructor(e={}){this.exitOnCtrlC=e.exitOnCtrlC??!0,this.suspendable=e.suspendable??!1,this.onSuspended=e.onSuspended,e.tui?(this.tui=e.tui,this.terminal=e.tui.terminal,this.ownsTui=!1):e.terminal?(this.terminal=e.terminal,this.tui=new aL(this.terminal),this.ownsTui=!0):(this.terminal=new hL,this.tui=new aL(this.terminal),this.ownsTui=!0),this.terminalOutput=new PB({writer:e=>this.terminal.write(e)}),this.rootNode=UR(`jar-root`),this.rootNode.yogaNode.setFlexDirection(0),this.rootNode.yogaNode.setFlexGrow(1),this.rootNode.onRender=()=>{this.bridge.notifyCommit(),this.tui.requestRender(),performance.clearMeasures()},this.bridge=new pB(this.rootNode),this.tui.addChild(this.bridge),this.container=iz.createContainer(this.rootNode,0,null,!1,null,`jar`,()=>{},()=>{},()=>{},()=>{}),this.exitPromise=new Promise(e=>{this.resolveExit=e}),this.exitOnCtrlC&&this.tui.addInputListener(e=>{if(!zI(e)&&KI(e,`ctrl+c`))return this.exit(),{consume:!0}})}render(e){iz.updateContainerSync(e,this.container,null),iz.flushSyncWork()}start(){this.ownsTui&&this.tui.start(),this.setupWarningInterceptor(),this.suspendable&&(this.cleanupSuspend=this.setupSuspendHandler())}exit(e){for(let t of this.exitCallbacks)t(e);this.unmount()}onExit(e){this.exitCallbacks.push(e)}unmount(){if(this.warningInterceptor&&=(U.removeListener(`warning`,this.warningInterceptor),void 0),this.originalWarningListeners){let e=U.listeners(`warning`);for(let t of this.originalWarningListeners)e.includes(t)||U.on(`warning`,t);this.originalWarningListeners=void 0}this.cleanupSuspend?.(),this.ownsTui&&this.disableInputProtocols(),iz.updateContainerSync(null,this.container,null),iz.flushSyncWork(),this.tui.removeChild(this.bridge),this.ownsTui&&this.tui.stop(),this.rootNode.yogaNode?.unsetMeasureFunc(),this.rootNode.yogaNode?.free(),this.rootNode.yogaNode=void 0,this.resolveExit()}cleanupTerminal(){this.ownsTui&&(this.cleanupSuspend?.(),this.disableInputProtocols(),this.tui.stop(),U.stdout.write(hB))}disableInputProtocols(){this.terminal.write(_L),this.terminal.write(`\x1B[?2004l`),this.terminal.kittyProtocolActive&&this.terminal.write(`\x1B[<u`)}setupWarningInterceptor(){this.originalWarningListeners||(this.originalWarningListeners=U.rawListeners(`warning`),U.removeAllListeners(`warning`),this.warningInterceptor=()=>{},U.on(`warning`,this.warningInterceptor))}setupSuspendHandler(){if(U.platform===`win32`||!this.ownsTui)return()=>{};let e=!1,t=()=>{e=this.terminal.kittyProtocolActive,U.stdout.isTTY&&(this.disableInputProtocols(),U.stdout.write(hB)),U.stdin.isTTY&&U.stdin.isRaw&&U.stdin.setRawMode(!1),this.onSuspended?.(),U.removeListener(`SIGTSTP`,t),U.kill(U.pid,`SIGTSTP`)},n=()=>{U.stdin.isTTY&&U.stdin.setRawMode(!0),U.stdout.isTTY&&(U.stdout.write(gB),this.terminal.write(`\x1B[?2004h`),this.terminal.write(gL),e&&this.terminal.write(`\x1B[>7u`)),U.on(`SIGTSTP`,t),this.tui.requestRender(!0)};return U.on(`SIGTSTP`,t),U.on(`SIGCONT`,n),()=>{U.removeListener(`SIGTSTP`,t),U.removeListener(`SIGCONT`,n)}}waitUntilExit(){return this.exitPromise}getRootNode(){return this.rootNode}};function IB(e,t){let n=new FB(t),r=Y.createElement(uz,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),children:e});return n.render(r),n.start(),{rerender(e){let t=Y.createElement(uz,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),children:e});n.render(t)},unmount(){n.unmount()},waitUntilExit(){return n.waitUntilExit()},cleanupTerminal(){n.cleanupTerminal()}}}function X({children:e,...t}){return(0,J.jsx)(`jar-view`,{style:{flexWrap:`nowrap`,flexDirection:`row`,flexGrow:0,flexShrink:1,...t,overflowX:t.overflowX??t.overflow??`visible`,overflowY:t.overflowY??t.overflow??`visible`},children:e})}function Z({color:e,backgroundColor:t,dimColor:n=!1,bold:r=!1,italic:i=!1,underline:a=!1,strikethrough:o=!1,inverse:s=!1,wrap:c=`wrap`,transform:l,children:u}){if(u==null)return null;let d=(0,Y.useCallback)(c=>(n&&(c=tB().dim().render(c)),e&&(c=$z(c,e,`foreground`)),t&&(c=$z(c,t,`background`)),r&&(c=tB().bold().render(c)),i&&(c=tB().italic().render(c)),a&&(c=tB().underline().render(c)),o&&(c=tB().strikethrough().render(c)),s&&(c=tB().reverse().render(c)),l&&(c=l(c)),c),[e,t,n,r,i,a,o,s,l]);return(0,J.jsx)(`jar-text`,{style:{flexGrow:0,flexShrink:0,flexDirection:`row`,textWrap:c},internal_transform:d,children:u})}const LB=/\x1b\[[\d:]*;(\d+)/;function RB(e){let t=LB.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const zB={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:``},BB=(e,t={})=>{let{addInputListener:n}=(0,Y.use)(sz);(0,Y.useEffect)(()=>{if(t.isActive!==!1)return n(t=>{if(zI(t))return;if(t.startsWith(`\x1B[200~`)){let n=t.indexOf(`\x1B[201~`),r=n===-1?t.slice(6):t.slice(6,n);zB.upArrow=!1,zB.downArrow=!1,zB.leftArrow=!1,zB.rightArrow=!1,zB.pageDown=!1,zB.pageUp=!1,zB.home=!1,zB.end=!1,zB.return=!1,zB.escape=!1,zB.ctrl=!1,zB.shift=!1,zB.tab=!1,zB.backspace=!1,zB.delete=!1,zB.meta=!1,zB.super=!1,zB.paste=!0,zB.raw=t,e(r,{...zB});return}let n=qI(t),r=n?n.split(`+`):[],i=r[r.length-1]??``,a=r.includes(`ctrl`),o=r.includes(`shift`),s=r.includes(`alt`);zB.upArrow=i===`up`,zB.downArrow=i===`down`,zB.leftArrow=i===`left`,zB.rightArrow=i===`right`,zB.pageDown=i===`pagedown`,zB.pageUp=i===`pageup`,zB.home=i===`home`,zB.end=i===`end`,zB.return=i===`return`||i===`enter`,zB.escape=i===`escape`,zB.ctrl=a,zB.shift=o,zB.tab=i===`tab`,zB.backspace=i===`backspace`,zB.delete=i===`delete`,zB.meta=s,zB.super=RB(t),zB.paste=!1,zB.raw=t;let c=zB,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 e=XI(t);e===void 0?t.length===1?l=t:i.length===1&&(l=i):l=e}e(l,{...c})})},[t.isActive,e,n])},VB=({isActive:e=!0,autoFocus:t=!1,id:n}={})=>{let{activeId:r,add:i,remove:a,activate:o,deactivate:s,focus:c}=(0,Y.use)(az),l=(0,Y.useMemo)(()=>n??Math.random().toString().slice(2,7),[n]);return(0,Y.useEffect)(()=>(i(l,{autoFocus:t}),()=>{a(l)}),[l,t]),(0,Y.useEffect)(()=>{e?o(l):s(l)},[e,l]),{isFocused:!!l&&r===l,focus:c}};function HB(){return(0,Y.use)(oz)}const UB=()=>{let e=(0,Y.use)(lz);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},WB=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function GB(){return new RegExp(WB.source,`g`)}function KB(e){return e.replace(WB,``)}function qB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function JB(e){return`\x1B]2;`+qB(e)+`\x07`}var YB=W(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.4.2`,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":`^2.0.5`,"@orpc/client":`catalog:`,"@orpc/contract":`catalog:`,"@orpc/server":`catalog:`,"@sentry/node-core":`10.46.0`,"@slack/web-api":`^7.0.0`,"@tanstack/react-query":`^5.90.19`,"@vscode/ripgrep":`1.17.0`,"ansi-styles":`^6.2.3`,"beautiful-mermaid":`^1.1.3`,"cli-boxes":`^4.0.1`,"cli-highlight":`^2.1.11`,conf:`^15.0.2`,diff:`^8.0.3`,fzf:`^0.5.2`,"gradient-string":`^3.0.0`,immer:`^11.1.4`,"isomorphic-git":`^1.36.1`,marked:`^17.0.4`,"patchright-core":`^1.58.2`,react:`^19.2.3`,"react-compiler-runtime":`^1.0.0`,remend:`^1.2.2`,semver:`^7.7.4`,"shell-history":`^2.0.1`,"string-width":`^8.1.0`,"strip-ansi":`^7.2.0`,trash:`^9.0.0`,zod:`catalog:`},devDependencies:{"@codellm/configs":`workspace:*`,"@playwright/mcp":`^0.0.68`,"@types/diff":`^8.0.0`,"@types/node":`catalog:`,"@types/react":`^19.2.9`,"@types/semver":`^7.7.1`,"@typescript/native-preview":`catalog:`,"@vitejs/plugin-react":`^5.1.2`,"@vitest/coverage-v8":`^4.0.18`,"@vitest/ui":`^4.0.18`,"@xterm/addon-serialize":`^0.14.0`,"@xterm/headless":`^6.0.0`,"babel-plugin-react-compiler":`^1.0.0`,"cli-testing-library":`^3.0.1`,jsdom:`^27.4.0`,"node-pty":`^1.1.0`,"react-devtools-core":`^6.1.5`,"svg-term-cli":`^2.1.1`,tsdown:`^0.21.0`,vite:`catalog:`,vitest:`^4.0.18`},engines:{node:`>=18`}}})),XB=Ge(YB(),1);let ZB=null;function QB(e){let t=(0,gF.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function $B(){let e=process.env.npm_command;if(e===`exec`||e===`dlx`)return!0;let t=process.argv[1]??``;return!!/_npx[/\\]|[/\\]dlx[/\\]|\.cache[/\\]/.test(t)}function eV(){if(process.versions.bun===void 0)return!1;let e=process.argv[1]??process.argv[0]??``;return/[/\\]\.abacusai[/\\]bin[/\\]/.test(e)}function tV(){let e=`${sn.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let n=process.argv[1]??``;try{n=v(n)}catch{}if(/[/\\]\.abacusai[/\\]bin[/\\]/.test(n))return!1;let r=/[/\\]node_modules[/\\]/.test(n)||/[/\\]\.npm[/\\]/.test(n)||/[/\\]\.bun[/\\]/.test(n),i=!!process.env.npm_config_user_agent;return!r&&!i}function nV(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}function rV(){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}if(process.versions.bun!==void 0)return`bun`;let t=process.argv[1]??``;return/[/\\]\.?yarn[/\\]/.test(t)?`yarn`:/[/\\]\.?pnpm[/\\]/.test(t)?`pnpm`:/[/\\]\.bun[/\\]/.test(t)?`bun`:`npm`}async function iV(e){let t=Date.now();if(ZB&&t-ZB.timestamp<6e4)return ZB.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 ZB={tags:r,timestamp:t},r}async function aV(e,t,n,r){let i=t??QB(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();return{currentVersion:e,latestVersion:c.result.version,tag:c.result.channel,packageManager:rV(),isEphemeral:$B(),downloadUrl:c.result.url}}async function oV(e){let t=QB(e),n=rV(),r=$B(),i=(await iV(cn.publishName))[t];return!i&&t!==`latest`||!i||i===e?null:{currentVersion:e,latestVersion:i,tag:t,packageManager:n,isEphemeral:r}}async function sV(e,t,n){if(eV())try{return await aV(e,t,nV(),n)}catch{return null}return await oV(e)}function cV(){return`${sn.binName} upgrade`}function lV(e){let t=`${cn.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 uV(e){try{return se(lV(e),{stdio:`pipe`}),!0}catch{return!1}}function dV(e){try{return{ok:!0,output:se(lV(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`}}}async function fV(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let t=T.join(M.tmpdir(),`abacusai-update-${Date.now()}`),n=T.join(M.homedir(),`.${sn.configDirName}`,`bin`),r=process.platform===`win32`,i=r?`${sn.binName}.exe`:sn.binName;try{await ye.mkdir(t,{recursive:!0});let a=T.join(t,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 ye.writeFile(a,s),se(r?`powershell -Command "Expand-Archive -Path '${a}' -DestinationPath '${t}' -Force"`:`tar -xzf "${a}" -C "${t}"`,{stdio:`pipe`});let c=T.join(t,i),l=T.join(n,i);return await ye.copyFile(c,l),r||await ye.chmod(l,493),{ok:!0,output:`Updated to ${e.latestVersion}`}}catch(e){return{ok:!1,output:e instanceof Error?e.message:`Unknown error`}}finally{await ye.rm(t,{recursive:!0,force:!0}).catch(()=>{})}}function pV(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 mV(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
|
|
73325
|
+
`))}}r=uB(e,r),e.renderCache={lines:[r],width:n,height:0,left:l,top:u},t.write(l,u,r,d)}else e.renderCache=void 0;e.renderDirty=!1;return}let f=!1;if(e.nodeName===`jar-view`){e.style.backgroundColor&&dB(l,u,e,t),e.style.borderStyle&&iB(l,u,e,t);let n=e.style.overflowX===`hidden`||e.style.overflow===`hidden`,r=e.style.overflowY===`hidden`||e.style.overflow===`hidden`;if(n||r){let i=n?l+cB(e.style,`Left`):void 0,a=n?l+c.getComputedWidth()-cB(e.style,`Right`):void 0,o=r?u+cB(e.style,`Top`):void 0,s=r?u+c.getComputedHeight()-cB(e.style,`Bottom`):void 0;t.clip({x1:i,x2:a,y1:o,y2:s}),f=!0}}if(e.nodeName===`jar-root`||e.nodeName===`jar-view`){let n=f?u+cB(e.style,`Top`):o,r=f?u+c.getComputedHeight()-cB(e.style,`Bottom`):s;for(let i of e.childNodes)fB(i,t,{offsetX:l,offsetY:u,transformers:d,clipY1:n,clipY2:r});f&&t.unclip()}e.renderDirty=!1};var pB=class{rootNode;lastWidth=0;cachedLines=null;output=new _z(0,0);constructor(e){this.rootNode=e}notifyCommit(){this.cachedLines=null}render(e){let t=e!==this.lastWidth;if(t&&(this.clearAllRenderCaches(this.rootNode),this.lastWidth=e),this.cachedLines&&!this.rootNode.renderDirty&&!t)return this.cachedLines;this.rootNode.yogaNode.setWidth(e),this.rootNode.yogaNode.calculateLayout(void 0,void 0,1);let n=Math.ceil(this.rootNode.yogaNode.getComputedHeight());if(n<=0)return this.cachedLines=[],this.cachedLines;this.output.reset(e,n),fB(this.rootNode,this.output,{});let r=this.output.get(),i=!1;for(let t of r)if(pI(t)>e){i=!0;break}return this.cachedLines=i?r.map(t=>pI(t)>e?xI(t,e):t):r,this.cachedLines}invalidate(){this.cachedLines=null,this.clearAllRenderCaches(this.rootNode)}clearAllRenderCaches(e){e.renderDirty=!0,e.renderCache=void 0;for(let t of e.childNodes)t.nodeName!==`#text`&&this.clearAllRenderCaches(t)}},mB;(function(e){e[e.BlinkingBlock=0]=`BlinkingBlock`,e[e.BlinkingBlockDefault=1]=`BlinkingBlockDefault`,e[e.SteadyBlock=2]=`SteadyBlock`,e[e.BlinkingUnderline=3]=`BlinkingUnderline`,e[e.SteadyUnderline=4]=`SteadyUnderline`,e[e.BlinkingBar=5]=`BlinkingBar`,e[e.SteadyBar=6]=`SteadyBar`})(mB||={});const hB=`\x1B[?25h`,gB=`\x1B[?25l`;function _B(e,t){let n=``;return t!==``&&(n=typeof Buffer<`u`?Buffer.from(t).toString(`base64`):btoa(t)),`\x1B]52;`+String.fromCharCode(e)+`;`+n+`\x07`}function vB(e){return _B(99,e)}function yB(e){let t=e??Wz(),n=t.TERM_PROGRAM.toLowerCase(),r=t.TERM.toLowerCase(),i=(t.LC_TERMINAL??``).toLowerCase();if(n===`iterm.app`)return`iterm2`;if(n===`wezterm`)return`wezterm`;if(n===`ghostty`)return`ghostty`;if(n===`vscode`)return`vscode`;if(n===`tmux`)return`tmux`;if(t.WT_SESSION)return`windows-terminal`;if(r.includes(`kitty`))return`kitty`;if(r.includes(`alacritty`))return`alacritty`;if(r.includes(`foot`))return`foot`;if(r.includes(`contour`))return`contour`;if(r.includes(`rio`))return`rio`;if(r.includes(`ghostty`))return`ghostty`;if(r.includes(`wezterm`))return`wezterm`;if(r.startsWith(`tmux`))return`tmux`;if(r.startsWith(`screen`))return`screen`;if(r===`xterm`||r.startsWith(`xterm-`))return`xterm`;if(r===`linux`)return`linux`;if(!n&&i){if(i===`iterm2`)return`iterm2`;if(i===`wezterm`)return`wezterm`}return`unknown`}function bB(e){return(e??Wz()).isTTY}function xB(e){let t=yB(e);return t===`windows-terminal`||t===`iterm2`||t===`wezterm`||t===`ghostty`}function SB(e){let t=yB(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`xterm`||t===`tmux`||t===`windows-terminal`||t===`rio`||t===`contour`}function CB(e){let t=yB(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`contour`||t===`rio`||t===`vscode`||t===`windows-terminal`}function wB(e,...t){return`\x1B]8;`+(t.length>0?t.join(`:`):``)+`;`+e+`\x07`}function TB(...e){return wB(``,...e)}function EB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function DB(e){return`\x1B]9;`+EB(e)+`\x07`}function OB(e,...t){return`\x1B]99;`+t.map(EB).join(`:`)+`;`+EB(e)+`\x07`}function kB(e){return`\x1B]777;notify;;`+EB(e)+`\x07`}const AB=`\x1B]9;4;0\x07`;function jB(e){return`\x1B]9;4;1;`+Math.min(Math.max(0,e),100)+`\x07`}function MB(e){return`\x1B]9;4;2;`+Math.min(Math.max(0,e),100)+`\x07`}function NB(e){return`\x1B]9;4;4;`+Math.min(Math.max(0,e),100)+`\x07`}var PB=class{env;profile;terminalType;_isDark;_writer;_progressHideTimer=null;constructor(e){this.env=e?.env??Wz(),this.profile=Kz(this.env),Xz(this.profile),this.terminalType=yB(this.env),this._isDark=e?.isDark??Ez(),this._writer=e?.writer??null,e?.isDark!==void 0&&Dz(e.isDark)}get isDark(){return this._isDark}setDark(e){this._isDark=e,Dz(e)}resolveAdaptiveColor(e){if(typeof e==`string`)return Hz.parse(e);let t=this._isDark?e.dark:e.light;return Hz.parse(t)}colorize(e,t,n){if(!t)return e;let r=this.resolveAdaptiveColor(t);if(!r)return e;let i=Zz(r,this.profile);return i?`\x1B[`+(n===`foreground`?i.fgSequence():i.bgSequence())+`m`+e+`\x1B[0m`:e}styledText(){return tB(this.profile)}write(e){this._writer?this._writer(e):typeof process<`u`&&process.stdout?.isTTY&&process.stdout.write(e)}notify(e){if(!bB(this.env))return;let t=this.terminalType,{title:n,body:r}=e,i=n?`${n}:\n${r}`:r;t===`kitty`&&(n?this.write(OB(r,`d=0:p=title`,n)):this.write(OB(r))),this.write(kB(i)),this.write(DB(i))}showProgress(e){if(!xB(this.env))return;this.clearProgressTimer();let t=e.state??`normal`,n=Math.min(Math.max(0,e.percentage??0),100);switch(t){case`indeterminate`:this.write(`\x1B]9;4;3\x07`);break;case`error`:this.write(MB(n));break;case`warning`:this.write(NB(n));break;default:this.write(jB(n));break}(t===`error`||n>=100)&&this.scheduleProgressHide()}hideProgress(){this.clearProgressTimer(),xB(this.env)&&this.write(AB)}async trackProgress(e){this.showProgress({state:`indeterminate`});try{let t=await e;return this.showProgress({percentage:100}),this.scheduleProgressHide(),t}catch(e){throw this.showProgress({percentage:100,state:`error`}),this.scheduleProgressHide(),e}}copyToClipboard(e){SB(this.env)&&this.write(vB(e))}clearClipboard(){SB(this.env)&&this.write(`\x1B]52;c;\x07`)}hyperlink(e,t){return CB(this.env)?wB(e)+t+TB():t}clearProgressTimer(){this._progressHideTimer&&=(clearTimeout(this._progressHideTimer),null)}scheduleProgressHide(){this.clearProgressTimer(),this._progressHideTimer=setTimeout(()=>{this.write(AB),this._progressHideTimer=null},500)}},FB=class{tui;terminal;terminalOutput;rootNode;bridge;container;exitCallbacks=[];exitPromise;resolveExit;exitOnCtrlC;ownsTui;suspendable;onSuspended;cleanupSuspend;originalWarningListeners;warningInterceptor;constructor(e={}){this.exitOnCtrlC=e.exitOnCtrlC??!0,this.suspendable=e.suspendable??!1,this.onSuspended=e.onSuspended,e.tui?(this.tui=e.tui,this.terminal=e.tui.terminal,this.ownsTui=!1):e.terminal?(this.terminal=e.terminal,this.tui=new aL(this.terminal),this.ownsTui=!0):(this.terminal=new hL,this.tui=new aL(this.terminal),this.ownsTui=!0),this.terminalOutput=new PB({writer:e=>this.terminal.write(e)}),this.rootNode=UR(`jar-root`),this.rootNode.yogaNode.setFlexDirection(0),this.rootNode.yogaNode.setFlexGrow(1),this.rootNode.onRender=()=>{this.bridge.notifyCommit(),this.tui.requestRender(),performance.clearMeasures()},this.bridge=new pB(this.rootNode),this.tui.addChild(this.bridge),this.container=iz.createContainer(this.rootNode,0,null,!1,null,`jar`,()=>{},()=>{},()=>{},()=>{}),this.exitPromise=new Promise(e=>{this.resolveExit=e}),this.exitOnCtrlC&&this.tui.addInputListener(e=>{if(!zI(e)&&KI(e,`ctrl+c`))return this.exit(),{consume:!0}})}render(e){iz.updateContainerSync(e,this.container,null),iz.flushSyncWork()}start(){this.ownsTui&&this.tui.start(),this.setupWarningInterceptor(),this.suspendable&&(this.cleanupSuspend=this.setupSuspendHandler())}exit(e){for(let t of this.exitCallbacks)t(e);this.unmount()}onExit(e){this.exitCallbacks.push(e)}unmount(){if(this.warningInterceptor&&=(U.removeListener(`warning`,this.warningInterceptor),void 0),this.originalWarningListeners){let e=U.listeners(`warning`);for(let t of this.originalWarningListeners)e.includes(t)||U.on(`warning`,t);this.originalWarningListeners=void 0}this.cleanupSuspend?.(),this.ownsTui&&this.disableInputProtocols(),iz.updateContainerSync(null,this.container,null),iz.flushSyncWork(),this.tui.removeChild(this.bridge),this.ownsTui&&this.tui.stop(),this.rootNode.yogaNode?.unsetMeasureFunc(),this.rootNode.yogaNode?.free(),this.rootNode.yogaNode=void 0,this.resolveExit()}cleanupTerminal(){this.ownsTui&&(this.cleanupSuspend?.(),this.disableInputProtocols(),this.tui.stop(),U.stdout.write(hB))}disableInputProtocols(){this.terminal.write(_L),this.terminal.write(`\x1B[?2004l`),this.terminal.kittyProtocolActive&&this.terminal.write(`\x1B[<u`)}setupWarningInterceptor(){this.originalWarningListeners||(this.originalWarningListeners=U.rawListeners(`warning`),U.removeAllListeners(`warning`),this.warningInterceptor=()=>{},U.on(`warning`,this.warningInterceptor))}setupSuspendHandler(){if(U.platform===`win32`||!this.ownsTui)return()=>{};let e=!1,t=()=>{e=this.terminal.kittyProtocolActive,U.stdout.isTTY&&(this.disableInputProtocols(),U.stdout.write(hB)),U.stdin.isTTY&&U.stdin.isRaw&&U.stdin.setRawMode(!1),this.onSuspended?.(),U.removeListener(`SIGTSTP`,t),U.kill(U.pid,`SIGTSTP`)},n=()=>{U.stdin.isTTY&&U.stdin.setRawMode(!0),U.stdout.isTTY&&(U.stdout.write(gB),this.terminal.write(`\x1B[?2004h`),this.terminal.write(gL),e&&this.terminal.write(`\x1B[>7u`)),U.on(`SIGTSTP`,t),this.tui.requestRender(!0)};return U.on(`SIGTSTP`,t),U.on(`SIGCONT`,n),()=>{U.removeListener(`SIGTSTP`,t),U.removeListener(`SIGCONT`,n)}}waitUntilExit(){return this.exitPromise}getRootNode(){return this.rootNode}};function IB(e,t){let n=new FB(t),r=Y.createElement(uz,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),children:e});return n.render(r),n.start(),{rerender(e){let t=Y.createElement(uz,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),children:e});n.render(t)},unmount(){n.unmount()},waitUntilExit(){return n.waitUntilExit()},cleanupTerminal(){n.cleanupTerminal()}}}function X({children:e,...t}){return(0,J.jsx)(`jar-view`,{style:{flexWrap:`nowrap`,flexDirection:`row`,flexGrow:0,flexShrink:1,...t,overflowX:t.overflowX??t.overflow??`visible`,overflowY:t.overflowY??t.overflow??`visible`},children:e})}function Z({color:e,backgroundColor:t,dimColor:n=!1,bold:r=!1,italic:i=!1,underline:a=!1,strikethrough:o=!1,inverse:s=!1,wrap:c=`wrap`,transform:l,children:u}){if(u==null)return null;let d=(0,Y.useCallback)(c=>(n&&(c=tB().dim().render(c)),e&&(c=$z(c,e,`foreground`)),t&&(c=$z(c,t,`background`)),r&&(c=tB().bold().render(c)),i&&(c=tB().italic().render(c)),a&&(c=tB().underline().render(c)),o&&(c=tB().strikethrough().render(c)),s&&(c=tB().reverse().render(c)),l&&(c=l(c)),c),[e,t,n,r,i,a,o,s,l]);return(0,J.jsx)(`jar-text`,{style:{flexGrow:0,flexShrink:0,flexDirection:`row`,textWrap:c},internal_transform:d,children:u})}const LB=/\x1b\[[\d:]*;(\d+)/;function RB(e){let t=LB.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const zB={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:``},BB=(e,t={})=>{let{addInputListener:n}=(0,Y.use)(sz);(0,Y.useEffect)(()=>{if(t.isActive!==!1)return n(t=>{if(zI(t))return;if(t.startsWith(`\x1B[200~`)){let n=t.indexOf(`\x1B[201~`),r=n===-1?t.slice(6):t.slice(6,n);zB.upArrow=!1,zB.downArrow=!1,zB.leftArrow=!1,zB.rightArrow=!1,zB.pageDown=!1,zB.pageUp=!1,zB.home=!1,zB.end=!1,zB.return=!1,zB.escape=!1,zB.ctrl=!1,zB.shift=!1,zB.tab=!1,zB.backspace=!1,zB.delete=!1,zB.meta=!1,zB.super=!1,zB.paste=!0,zB.raw=t,e(r,{...zB});return}let n=qI(t),r=n?n.split(`+`):[],i=r[r.length-1]??``,a=r.includes(`ctrl`),o=r.includes(`shift`),s=r.includes(`alt`);zB.upArrow=i===`up`,zB.downArrow=i===`down`,zB.leftArrow=i===`left`,zB.rightArrow=i===`right`,zB.pageDown=i===`pagedown`,zB.pageUp=i===`pageup`,zB.home=i===`home`,zB.end=i===`end`,zB.return=i===`return`||i===`enter`,zB.escape=i===`escape`,zB.ctrl=a,zB.shift=o,zB.tab=i===`tab`,zB.backspace=i===`backspace`,zB.delete=i===`delete`,zB.meta=s,zB.super=RB(t),zB.paste=!1,zB.raw=t;let c=zB,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 e=XI(t);e===void 0?t.length===1?l=t:i.length===1&&(l=i):l=e}e(l,{...c})})},[t.isActive,e,n])},VB=({isActive:e=!0,autoFocus:t=!1,id:n}={})=>{let{activeId:r,add:i,remove:a,activate:o,deactivate:s,focus:c}=(0,Y.use)(az),l=(0,Y.useMemo)(()=>n??Math.random().toString().slice(2,7),[n]);return(0,Y.useEffect)(()=>(i(l,{autoFocus:t}),()=>{a(l)}),[l,t]),(0,Y.useEffect)(()=>{e?o(l):s(l)},[e,l]),{isFocused:!!l&&r===l,focus:c}};function HB(){return(0,Y.use)(oz)}const UB=()=>{let e=(0,Y.use)(lz);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},WB=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function GB(){return new RegExp(WB.source,`g`)}function KB(e){return e.replace(WB,``)}function qB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function JB(e){return`\x1B]2;`+qB(e)+`\x07`}var YB=W(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.4.3`,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":`^2.0.5`,"@orpc/client":`catalog:`,"@orpc/contract":`catalog:`,"@orpc/server":`catalog:`,"@sentry/node-core":`10.46.0`,"@slack/web-api":`^7.0.0`,"@tanstack/react-query":`^5.90.19`,"@vscode/ripgrep":`1.17.0`,"ansi-styles":`^6.2.3`,"beautiful-mermaid":`^1.1.3`,"cli-boxes":`^4.0.1`,"cli-highlight":`^2.1.11`,conf:`^15.0.2`,diff:`^8.0.3`,fzf:`^0.5.2`,"gradient-string":`^3.0.0`,immer:`^11.1.4`,"isomorphic-git":`^1.36.1`,marked:`^17.0.4`,"patchright-core":`^1.58.2`,react:`^19.2.3`,"react-compiler-runtime":`^1.0.0`,remend:`^1.2.2`,semver:`^7.7.4`,"shell-history":`^2.0.1`,"string-width":`^8.1.0`,"strip-ansi":`^7.2.0`,trash:`^9.0.0`,zod:`catalog:`},devDependencies:{"@codellm/configs":`workspace:*`,"@playwright/mcp":`^0.0.68`,"@types/diff":`^8.0.0`,"@types/node":`catalog:`,"@types/react":`^19.2.9`,"@types/semver":`^7.7.1`,"@typescript/native-preview":`catalog:`,"@vitejs/plugin-react":`^5.1.2`,"@vitest/coverage-v8":`^4.0.18`,"@vitest/ui":`^4.0.18`,"@xterm/addon-serialize":`^0.14.0`,"@xterm/headless":`^6.0.0`,"babel-plugin-react-compiler":`^1.0.0`,"cli-testing-library":`^3.0.1`,jsdom:`^27.4.0`,"node-pty":`^1.1.0`,"react-devtools-core":`^6.1.5`,"svg-term-cli":`^2.1.1`,tsdown:`^0.21.0`,vite:`catalog:`,vitest:`^4.0.18`},engines:{node:`>=18`}}})),XB=Ge(YB(),1);let ZB=null;function QB(e){let t=(0,gF.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function $B(){let e=process.env.npm_command;if(e===`exec`||e===`dlx`)return!0;let t=process.argv[1]??``;return!!/_npx[/\\]|[/\\]dlx[/\\]|\.cache[/\\]/.test(t)}function eV(){if(process.versions.bun===void 0)return!1;let e=process.argv[1]??process.argv[0]??``;return/[/\\]\.abacusai[/\\]bin[/\\]/.test(e)}function tV(){let e=`${sn.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let n=process.argv[1]??``;try{n=v(n)}catch{}if(/[/\\]\.abacusai[/\\]bin[/\\]/.test(n))return!1;let r=/[/\\]node_modules[/\\]/.test(n)||/[/\\]\.npm[/\\]/.test(n)||/[/\\]\.bun[/\\]/.test(n),i=!!process.env.npm_config_user_agent;return!r&&!i}function nV(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}function rV(){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}if(process.versions.bun!==void 0)return`bun`;let t=process.argv[1]??``;return/[/\\]\.?yarn[/\\]/.test(t)?`yarn`:/[/\\]\.?pnpm[/\\]/.test(t)?`pnpm`:/[/\\]\.bun[/\\]/.test(t)?`bun`:`npm`}async function iV(e){let t=Date.now();if(ZB&&t-ZB.timestamp<6e4)return ZB.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 ZB={tags:r,timestamp:t},r}async function aV(e,t,n,r){let i=t??QB(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();return{currentVersion:e,latestVersion:c.result.version,tag:c.result.channel,packageManager:rV(),isEphemeral:$B(),downloadUrl:c.result.url}}async function oV(e){let t=QB(e),n=rV(),r=$B(),i=(await iV(cn.publishName))[t];return!i&&t!==`latest`||!i||i===e?null:{currentVersion:e,latestVersion:i,tag:t,packageManager:n,isEphemeral:r}}async function sV(e,t,n){if(eV())try{return await aV(e,t,nV(),n)}catch{return null}return await oV(e)}function cV(){return`${sn.binName} upgrade`}function lV(e){let t=`${cn.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 uV(e){try{return se(lV(e),{stdio:`pipe`}),!0}catch{return!1}}function dV(e){try{return{ok:!0,output:se(lV(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`}}}async function fV(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let t=T.join(M.tmpdir(),`abacusai-update-${Date.now()}`),n=T.join(M.homedir(),`.${sn.configDirName}`,`bin`),r=process.platform===`win32`,i=r?`${sn.binName}.exe`:sn.binName;try{await ye.mkdir(t,{recursive:!0});let a=T.join(t,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 ye.writeFile(a,s),se(r?`powershell -Command "Expand-Archive -Path '${a}' -DestinationPath '${t}' -Force"`:`tar -xzf "${a}" -C "${t}"`,{stdio:`pipe`});let c=T.join(t,i),l=T.join(n,i);return await ye.copyFile(c,l),r||await ye.chmod(l,493),{ok:!0,output:`Updated to ${e.latestVersion}`}}catch(e){return{ok:!1,output:e instanceof Error?e.message:`Unknown error`}}finally{await ye.rm(t,{recursive:!0,force:!0}).catch(()=>{})}}function pV(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 mV(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
|
|
73326
73326
|
`),process.exit(1)),t?pV(n,t.toLowerCase())||(process.stderr.write(`Warning: Model "${t}" not found. Using default: ${n[0].llmName}\n`),n[0].llmName):n[0].llmName}const hV=rt([`codellm`,`cli`,`exit`]),gV=new Set,_V=new Set,vV=new Set;let yV=!1,bV=!1,xV=null,SV;async function CV(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 wV(e,t,n,r){if(yV)return;r?.debug?.(`Executing exit handlers`,{shouldManuallyExit:e,isSynchronous:t,signal:n,asyncCallbacks:gV.size,syncCallbacks:_V.size}),yV=!0,gV.size>0&&t&&hV.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:SV===void 0?(typeof U.exitCode==`number`||typeof U.exitCode==`string`)&&(i=Number(U.exitCode)):i=SV;let a=(t=!1)=>{(t||e)&&(xV?xV.call(U,i):U.exit(i))};for(let e of _V)try{e(i)}catch(e){hV.error`Error in synchronous exit hook: ${e}`}if(t){a();return}let o=[],s=0;for(let[e,t]of gV)s=Math.max(s,t),o.push(Promise.resolve(e(i)).catch(e=>{hV.error`Error in asynchronous exit hook: ${e}`}));let c=Array.from(vV);c.length>0&&o.push(CV(c));let l=setTimeout(()=>{a(!0)},s);try{await Promise.all(o),clearTimeout(l),a()}catch(e){clearTimeout(l),hV.error`Error during exit cleanup: ${e}`,a(!0)}}function TV(){bV||(bV=!0,U.once(`beforeExit`,()=>{wV(!0,!1,-128)}),U.once(`SIGINT`,()=>{wV(!0,!1,2)}),U.once(`SIGTERM`,()=>{wV(!0,!1,15)}),U.once(`exit`,()=>{wV(!1,!0,0)}),U.on(`message`,e=>{e===`shutdown`&&wV(!0,!0,-128)}),xV||(xV=U.exit.bind(U),U.exit=function(e){if(SV===void 0&&(SV=e??0),gV.size===0&&vV.size===0){if(xV){xV(e??0);return}U.exit(e??0)}wV(!0,!1,-128).catch(e=>{hV.error`Error during exit: ${e}`,xV?xV(1):U.exit(1)})}))}function EV(e,t){if(typeof e!=`function`)throw TypeError(`callback must be a function`);if(yV)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}),TV();let n=t?.wait??0,r=t?.streams??[U.stdout,U.stderr];if(n>0){let t=[e,n];gV.add(t);for(let e of r)vV.add(e);return()=>{gV.delete(t);for(let e of r)vV.delete(e)}}return _V.add(e),()=>{_V.delete(e)}}function DV(e){e!==void 0&&(U.exitCode=e),wV(!0,!1,-128)}function OV(e){process.stdout.write(JSON.stringify(e)+`
|
|
73327
73327
|
`)}function kV(e){try{return JSON.parse(e)}catch{return null}}async function AV({agentArgs:e}){yl(`desktop-host started`,`cli`);let t=await PF.create(),n=new kl(t,mn());if(!t.isAuthenticated())try{(await n.getUserInfo())?.result?.email||(process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
|
|
73328
73328
|
`),process.exit(1))}catch{process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
|
|
@@ -73678,7 +73678,7 @@ $$`:`${e}$$`},Ble=e=>X7(e)%2==0?e:zle(e),Vle=(e,t,n)=>{if(e.substring(t+2).inclu
|
|
|
73678
73678
|
`);if(t===-1)return e;let n=e.substring(t+1),r=e.substring(0,t),i=n.trim();if(Ule.test(i)&&!n.match(Wle)){let t=r.split(`
|
|
73679
73679
|
`).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}if(Gle.test(i)&&!n.match(Kle)){let t=r.split(`
|
|
73680
73680
|
`).at(-1);if(t&&t.trim().length>0)return`${e}\u200B`}return e},Jle=e=>{let t=e.match(cle);if(t){let n=t[2];if(!n||R7.test(n))return e;let r=e.lastIndexOf(t[1]);if(I7(e,r)||L7(e,r))return e;if(e.match(B7)?.length%2==1)return`${e}~~`}else{let t=e.match(ple);if(t){let n=e.lastIndexOf(t[0].slice(0,2));if(I7(e,n)||L7(e,n))return e;if(e.match(B7)?.length%2==1)return`${e}~`}}return e},$7=e=>e!==!1,e9={COMPARISON_OPERATORS:-10,HTML_TAGS:-5,SETEXT_HEADINGS:0,LINKS:10,BOLD_ITALIC:20,BOLD:30,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,DEFAULT:100},Yle=[{handler:{name:`comparisonOperators`,handle:tle,priority:e9.COMPARISON_OPERATORS},optionKey:`comparisonOperators`},{handler:{name:`htmlTags`,handle:Ple,priority:e9.HTML_TAGS},optionKey:`htmlTags`},{handler:{name:`setextHeadings`,handle:qle,priority:e9.SETEXT_HEADINGS},optionKey:`setextHeadings`},{handler:{name:`links`,handle:Q7,priority:e9.LINKS},optionKey:`links`,earlyReturn:e=>e.endsWith(`](streamdown:incomplete-link)`)},{handler:{name:`boldItalic`,handle:Mle,priority:e9.BOLD_ITALIC},optionKey:`boldItalic`},{handler:{name:`bold`,handle:Sle,priority:e9.BOLD},optionKey:`bold`},{handler:{name:`italicDoubleUnderscore`,handle:wle,priority:e9.ITALIC_DOUBLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`italicSingleAsterisk`,handle:Ele,priority:e9.ITALIC_SINGLE_ASTERISK},optionKey:`italic`},{handler:{name:`italicSingleUnderscore`,handle:kle,priority:e9.ITALIC_SINGLE_UNDERSCORE},optionKey:`italic`},{handler:{name:`inlineCode`,handle:Lle,priority:e9.INLINE_CODE},optionKey:`inlineCode`},{handler:{name:`strikethrough`,handle:Jle,priority:e9.STRIKETHROUGH},optionKey:`strikethrough`},{handler:{name:`katex`,handle:Ble,priority:e9.KATEX},optionKey:`katex`}],Xle=e=>{let t=e?.linkMode??`protocol`;return Yle.filter(({handler:t,optionKey:n})=>t.name===`links`?$7(e?.links)||$7(e?.images):$7(e?.[n])).map(({handler:e,earlyReturn:n})=>e.name===`links`?{handler:F7(P7({},e),{handle:e=>Q7(e,t)}),earlyReturn:t===`protocol`?n:void 0}:{handler:e,earlyReturn:n})},Zle=(e,t)=>{if(!e||typeof e!=`string`)return e;let n=e.endsWith(` `)&&!e.endsWith(` `)?e.slice(0,-1):e,r=Xle(t),i=(t?.handlers??[]).map(e=>({handler:F7(P7({},e),{priority:e.priority??e9.DEFAULT}),earlyReturn:void 0})),a=[...r,...i].sort((e,t)=>(e.handler.priority??0)-(t.handler.priority??0));for(let{handler:e,earlyReturn:t}of a)if(n=e.handle(n),t!=null&&t(n))return n;return n};function Qle(e){if(!e)return!1;let t=e.toLowerCase().trim();return t===`mermaid`||t===`mmd`}function $le(e){try{return DY(e)}catch{return null}}function t9({children:e,language:t}){let n=(0,Y.useMemo)(()=>U$(),[]);if(Qle(t)){let t=$le(e||``);if(t!==null)return(0,J.jsx)(X,{paddingX:1,flexDirection:`row`,alignSelf:`flex-start`,children:(0,J.jsx)(Z,{children:t})})}let r=e;if(t&&(0,V$.supportsLanguage)(t))try{r=(0,V$.highlight)(e||``,{language:t,theme:n})}catch{}return(0,J.jsx)(X,{paddingX:1,flexDirection:`row`,alignSelf:`flex-start`,children:(0,J.jsx)(Z,{children:r})})}t9.displayName=`CodeBlock`;function n9(e){return`text`in e&&typeof e.text==`string`?e.text:`tokens`in e&&Array.isArray(e.tokens)?e.tokens.map(e=>n9(e)).join(``):``}function eue(e){return`checked`in e&&typeof e.checked==`boolean`}function r9(e,t=!1){return e?e.map((e,n)=>(0,J.jsx)(Y.Fragment,{children:i9(e,t)},n)):null}function i9(e,t=!1){let n=e=>t?(0,J.jsx)(Z,{dimColor:!0,italic:!0,children:e}):e;switch(e.type){case`strong`:return(0,J.jsx)(Z,{bold:!0,children:r9(e.tokens,t)});case`em`:return(0,J.jsx)(Z,{italic:!0,children:r9(e.tokens,t)});case`del`:return(0,J.jsx)(Z,{strikethrough:!0,children:r9(e.tokens,t)});case`codespan`:return n((0,J.jsx)(Z,{color:ZW,dimColor:!0,children:e.text}));case`link`:return n((0,J.jsx)(I8,{href:e.href,children:n9(e)}));case`image`:{let t=e,r=t.text||t.href;return n((0,J.jsxs)(Z,{dimColor:!0,children:[r,` `,t.href!==r&&`(${t.href})`]}))}case`checkbox`:{let t=eue(e)&&e.checked===!0;return n((0,J.jsx)(Z,{color:QW,children:t?`[✓]`:`[ ]`}))}case`text`:return e.tokens?r9(e.tokens,t):n(e.text);case`br`:return`
|
|
73681
|
-
`;default:return n(n9(e))}}function a9(e,t=0,n=!1){switch(e.type){case`heading`:return(0,J.jsx)(X,{flexDirection:`column`,children:(0,J.jsx)(Z,{bold:!0,color:e.depth<=2?ZW:QW,dimColor:e.depth>2,children:r9(e.tokens,n)})},`heading-${e.depth}`);case`paragraph`:return(0,J.jsx)(X,{flexDirection:`column`,children:(0,J.jsx)(Z,{children:r9(e.tokens,n)})},`paragraph`);case`code`:return(0,J.jsx)(t9,{language:e.lang,children:e.text},`code`);case`blockquote`:return(0,J.jsx)(X,{borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`double`,borderColor:rG,paddingLeft:1,flexDirection:`column`,children:e.tokens?.map((e,n)=>(0,J.jsx)(X,{children:a9(e,t,!0)},n))},`blockquote`);case`list`:return(0,J.jsx)(X,{flexDirection:`column`,children:e.items.map((r,i)=>{let a=e.ordered?(Number(e.start)||1)+i:null,o=r.task===!0,s=r.checked===!0,c=r.tokens?.filter(e=>e.type!==`checkbox`)||[];return(0,J.jsxs)(X,{flexDirection:`row`,children:[(0,J.jsx)(Z,{color:QW,dimColor:!0,children:o?s?`[✓] `:`[ ] `:a===null?`• `:`${a}. `}),(0,J.jsx)(X,{flexGrow:1,flexDirection:`column`,children:c.map((e,r)=>(0,J.jsx)(X,{children:a9(e,t+1,n)},r))})]},i)})},`list`);case`table`:{let t=e,r=t.header.map((e,n)=>{let r=n9(e).length;for(let e of t.rows)r=Math.max(r,n9(e[n]).length);return Math.max(r,3)});return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(X,{flexDirection:`row`,borderTop:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,borderColor:rG,alignSelf:`flex-start`,children:t.header.map((e,i)=>{let a=t.align?.[i]||null;return(0,J.jsx)(X,{width:r[i]+2,paddingX:1,justifyContent:a===`center`?`center`:a===`right`?`flex-end`:`flex-start`,children:(0,J.jsx)(Z,{bold:!0,color:ZW,children:r9(e.tokens,n)})},i)})}),t.rows.map((e,i)=>(0,J.jsx)(X,{flexDirection:`row`,children:e.map((e,i)=>{let a=t.align?.[i]||null;return(0,J.jsx)(X,{width:r[i]+2,paddingX:1,justifyContent:a===`center`?`center`:a===`right`?`flex-end`:`flex-start`,children:(0,J.jsx)(Z,{children:r9(e.tokens,n)})},i)})},i))]},`table`)}case`hr`:return(0,J.jsx)(X,{children:(0,J.jsx)(Z,{dimColor:!0,children:`─`.repeat(50)})},`hr`);case`space`:return null;default:return(0,J.jsx)(X,{flexDirection:`column`,children:(0,J.jsx)(Z,{children:i9(e,n)})})}}function o9({children:e}){let t=(0,Y.useMemo)(()=>{try{let t=Zle(e);return j7.lexer(t,{gfm:!0,breaks:!0})}catch{return[]}},[e]);return(0,J.jsx)(X,{flexDirection:`column`,children:(0,Y.useMemo)(()=>{let e=[],n=t.length;return t.forEach((t,r)=>{let i=r===n-1;if(t.type===`space`){e.push((0,J.jsx)(X,{height:1},`space-${r}`));return}e.push((0,J.jsx)(X,{flexDirection:`column`,children:a9(t)},r)),t.type===`heading`&&!i&&e.push((0,J.jsx)(X,{height:1},`heading-space-${r}`))}),e},[t])})}o9.displayName=`Markdown`;const s9=`Pondering...,Thinking...,Processing...,Analyzing...,Exploring...,Crafting...,Building...,Searching...,Connecting...,Reflecting...,Considering...,Examining...,Synthesizing...,Computing...,Reasoning...,Contemplating...,Assembling...,Formulating...,Generating...,Compiling...,Decoding...,Unraveling...,Mapping...,Weaving...,Brewing...,Sculpting...,Distilling...,Parsing...,Digesting...,Conjuring...`.split(`,`);function tue(e){return e.charAt(0).toUpperCase()+e.slice(1)}function nue(){return s9[Math.floor(Math.random()*s9.length)]}const rue=rt([`codellm`,`cli`,`tools`]);function c9(e){let t=h6[e.name];if(t||=(noe(e.name),h6[e.name]),!t)return(0,J.jsx)(X,{flexDirection:`column`,children:(0,J.jsxs)(Z,{color:`red`,children:[`Unknown tool: `,e.name]})});let n;n=e.result?.rejected?(()=>{try{return JSON.parse(e.result.content)}catch{return{}}})().reason===`interrupted`?`interrupted`:`rejected`:e.result?`success`:e.parsedResult?.phase===`error`?`error`:`executing`;let r=e.input??{},i=``;try{i=t.getHeaderParams(r)}catch{}try{return t.renderUI(r,n,e.parsedResult,e.displayData)}catch(n){let r=n instanceof Error?n.message:String(n);return rue.error`Error rendering tool ${e.name}: ${r}`,(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)($,{name:t.displayName,params:i,status:`error`}),(0,J.jsx)(J$,{color:`red`,children:`Error rendering tool`})]})}}const l9=(0,Y.memo)(e=>{let{type:t,segment:n,isSpinny:r=!1,source:i}=e;if(t!==`text`)throw Error(`Can only render text segments, got ${t}`);let a=(0,Y.useMemo)(()=>S6(n),[n]);return a?.trim()?i===`user`?(0,J.jsxs)(X,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(Z,{color:YW,children:`❯`}),(0,J.jsx)(Z,{color:YW,italic:!0,children:a})]}):r?(0,J.jsx)(X,{flexDirection:`row`,alignItems:`center`,gap:1,children:(0,J.jsx)(m8,{text:a})}):(0,J.jsx)(X,{flexDirection:`column`,children:(0,J.jsxs)(X,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(Z,{color:`white`,children:`⏺`}),(0,J.jsx)(o9,{children:a.trimStart()})]})}):null});l9.displayName=`TextSegment`;const u9=(0,Y.memo)(e=>{let{segment:t}=e,n=(0,Y.useMemo)(()=>S6(t),[t]);return(0,J.jsxs)(X,{flexDirection:`row`,gap:1,alignItems:`flex-start`,children:[(0,J.jsx)(Z,{color:XW,children:`✳`}),(0,J.jsx)(X,{flexDirection:`column`,gap:0,children:n&&(0,J.jsx)(Z,{color:XW,wrap:`wrap`,children:n})})]})});u9.displayName=`ExpandedThinkingSegment`;const d9=(0,Y.memo)(e=>(0,Y.useContext)(O1)?(0,J.jsx)(u9,{...e}):null);d9.displayName=`ThinkingSegment`;const f9=(0,Y.memo)(e=>{let{toolUseRequest:t,toolUseResult:n,toolDisplayData:r,parsedResult:i}=e;return t?Array.isArray(t)?(0,J.jsx)(J.Fragment,{children:t.map((e,t)=>(0,J.jsx)(c9,{...e,result:n,displayData:r,parsedResult:i},e.id??t))}):(0,J.jsx)(c9,{...t,result:n,displayData:r,parsedResult:i}):null});f9.displayName=`ToolCallSegment`;const p9=(0,Y.memo)(e=>{let{type:t,segment:n,title:r,isSpinny:i=!1}=e,a=(0,Y.useRef)(nue());if(t!==`collapsible_component`)throw Error(`Can only render collapsible component segments, got ${t}`);let o=(0,Y.useMemo)(()=>S6(n),[n]);if(!o&&!r)throw Error(`Collapsible component segment must have content or title`);let s=r||tue(a.current);return(0,J.jsxs)(X,{borderStyle:o?`single`:void 0,borderColor:rG,flexDirection:`column`,alignItems:`flex-start`,gap:1,children:[s&&(0,J.jsx)(X,{flexDirection:`row`,alignItems:`center`,gap:1,children:i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(m8,{text:`${s}...`}),(0,J.jsx)(Z,{dimColor:!0,children:`(esc to interrupt)`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{children:` `}),(0,J.jsx)(Z,{color:YW,children:s})]})}),o&&(0,J.jsx)(o9,{children:o})]})});p9.displayName=`CollapsibleComponentSegment`;const m9=(0,Y.memo)(e=>{let{type:t,message:n,severity:r=`info`,actions:i,flashKey:a}=e;if(t!==`code_llm_notification`)throw Error(`Can only render notification segments, got ${t}`);let[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(a);if((0,Y.useEffect)(()=>{if(a!==c.current&&a!=null){c.current=a,s(!0);let e=setTimeout(()=>s(!1),600);return()=>clearTimeout(e)}},[a]),!n)throw Error(`Notification segment must have message`);let l=(0,Y.useMemo)(()=>r===`info`||r===`success`||r===`error`||r===`warning`?r:`info`,[r]),u=(0,Y.useMemo)(()=>{switch(l){case`info`:return $W;case`success`:return eG;case`warning`:return nG;case`error`:return tG;default:return $W}},[l]),d=e=>e.replace(/_/g,` `).replace(/([A-Z])/g,` $1`).trim().split(` `).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `),f=(0,Y.useMemo)(()=>(i||[]).filter(e=>e.link),[i]);return(0,J.jsxs)(X,{flexDirection:`column`,gap:0,children:[(0,J.jsxs)(X,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(Z,{color:u,children:o?`◉`:`●`}),(0,J.jsx)(Z,{color:u,bold:o,inverse:o,children:o?` ${n} `:n})]}),f.length>0&&(0,J.jsx)(X,{marginLeft:2,flexDirection:`row`,gap:1,children:f.map((e,t)=>(0,J.jsxs)(Y.Fragment,{children:[t>0&&(0,J.jsx)(Z,{children:` | `}),(0,J.jsx)(Z,{color:`cyan`,underline:!0,children:d(e.type)})]},t))})]})});m9.displayName=`NotificationSegment`;const h9=(0,Y.memo)(e=>{let t=e.creditsUsed??0;return t<=0?null:(0,J.jsx)(X,{justifyContent:`flex-end`,children:(0,J.jsxs)(Z,{dimColor:!0,children:[`Credits used: `,t.toFixed(2)]})})});h9.displayName=`CreditsSegment`;const g9=(0,Y.memo)(({segment:e})=>{switch(e.type){case`text`:return(0,J.jsx)(l9,{...e});case`thinking`:return(0,J.jsx)(d9,{...e});case`code_llm_tool_call`:return(0,J.jsx)(f9,{...e});case`collapsible_component`:return(0,J.jsx)(p9,{...e});case`code_llm_agent_tool_request`:return(0,J.jsx)(f9,{...e});case`code_llm_notification`:return(0,J.jsx)(m9,{...e});case`code_llm_credits`:return(0,J.jsx)(h9,{...e});default:return null}});g9.displayName=`SegmentBase`;function iue(e,t){return(0,J.jsx)(m9,{id:`error-fallback`,status:`completed`,source:`bot`,type:`code_llm_notification`,message:e.message,severity:`error`})}function _9({segment:e}){return(0,J.jsx)(J8,{fallback:iue,children:(0,J.jsx)(g9,{segment:e})})}const v9=`pondering.thinking.processing.analyzing.exploring.crafting.building.searching.connecting.reflecting.considering.examining.synthesizing.computing.reasoning.contemplating.assembling.formulating.generating.compiling.decoding.unraveling.mapping.weaving.brewing.sculpting.distilling.parsing.digesting.conjuring`.split(`.`);function aue(e){return e.charAt(0).toUpperCase()+e.slice(1)}function y9(){return v9[Math.floor(Math.random()*v9.length)]}function oue(e,t){let[n,r]=(0,Y.useState)(0),i=(0,Y.useRef)(null);if((0,Y.useEffect)(()=>{if(!e)return;let t=setInterval(()=>{r(e=>e+1)},500);return()=>clearInterval(t)},[e]),!e)return null;let a=Date.now();if(t){if(i.current===null&&(i.current=t+5e3),a>i.current)return null;let n=t-e;return n<5e3?`thought`:`thought for ${t8(n)}`}i.current=null;let o=a-e;return o<5e3?`thinking`:`thinking for ${t8(o)}`}function sue(e){let[,t]=(0,Y.useState)(0);if((0,Y.useEffect)(()=>{if(!e)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e]),!e)return null;let n=Date.now()-e;return n<5e3?null:t8(n)}const cue=({status:e,thinkingStartTime:t,thinkingEndTime:n,runStartTime:r})=>{let{activity:i}=r6(),[a,o]=(0,Y.useState)(()=>y9()),s=(0,Y.useRef)(Zd.Idle);(0,Y.useEffect)(()=>{s.current===Zd.Idle&&e!==Zd.Idle&&o(y9()),s.current=e},[e]);let c=oue(t,n),l=sue(r);if(!(e!==Zd.Idle&&e!==Zd.WaitingForToolPermission))return null;let u=e===Zd.LoadingConversation?`Resuming`:aue(a);return(0,J.jsxs)(X,{paddingLeft:1,flexDirection:`row`,gap:1,children:[(0,J.jsx)(Z,{color:`cyan`,children:i===`upload`?`↑`:i===`download`?`↓`:`•`}),(0,J.jsx)(m8,{text:`${u}...`}),c&&(0,J.jsxs)(Z,{color:`cyan`,children:[`(`,c,`)`]}),l&&!c&&(0,J.jsx)(Z,{dimColor:!0,children:l}),e!==Zd.LoadingConversation&&(0,J.jsx)(Z,{dimColor:!0,children:`(esc/ctrl+c to interrupt)`})]})};function lue(e){switch(e){case`completed`:return`✔`;case`in_progress`:return`◼`;default:return`◻`}}function uue(e){switch(e){case`completed`:return eG;case`in_progress`:return ZW;default:return YW}}const b9=(0,Y.memo)(({state:e})=>{let t=(0,Y.useContext)(O1);if(e.total===0||t)return null;let{todos:n,total:r,completed:i,inProgress:a,pending:o}=e,s=[];i>0&&s.push(`${i} done`),a>0&&s.push(`${a} in progress`),o>0&&s.push(`${o} open`);let c=s.length>0?`${r} task${r===1?``:`s`} (${s.join(`, `)})`:`${r} task${r===1?``:`s`}`,l=n.slice(0,5),u=r-l.length;return(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,children:[(0,J.jsx)(Z,{dimColor:!0,children:c}),l.map(e=>(0,J.jsxs)(X,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(Z,{color:uue(e.status),children:lue(e.status)}),(0,J.jsx)(Z,{color:e.status===`completed`?YW:void 0,dimColor:e.status===`completed`,strikethrough:e.status===`completed`,children:e.content})]},e.id)),u>0&&(0,J.jsxs)(Z,{dimColor:!0,children:[` `,`+`,u,` more task`,u===1?``:`s`]})]})});b9.displayName=`TodoList`;const x9=new Set([`read`,`grep`,`glob`,`web_search`,`web_fetch`,`get_tab_content`,`bash_output`,`kill_shell`,`get_interactive_elements`,`navigate_to`,`new_tab`,`switch_active_tab`,`close_tab`,`refresh_tab`,`get_diagnostics`]);function S9(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function due(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.input??{}:t.input??{}:{}}function fue(e){let t=S9(e),n=due(e),r=h6[t];if(!r)return``;try{return r.getHeaderParams(n)}catch{return``}}function pue(e){switch(e){case`read`:return`read`;case`grep`:case`glob`:return`search`;case`web_search`:return`web`;case`web_fetch`:return`fetch`;case`navigate_to`:case`new_tab`:case`switch_active_tab`:case`close_tab`:case`refresh_tab`:case`get_tab_content`:case`get_interactive_elements`:return`browser`;case`bash_output`:return`terminal`;case`kill_shell`:return`terminal`;case`get_diagnostics`:return`diag`;default:return`other`}}function mue(e){let t=[];function n(e,n,r){let i=n+r;if(i===0)return;let a;if(r>0)switch(e){case`search`:a=i===1?`searching for 1 pattern`:`searching for ${i} patterns`;break;case`read`:a=i===1?`reading 1 file`:`reading ${i} files`;break;case`list`:a=i===1?`listing 1 directory`:`listing ${i} directories`;break;case`web`:a=i===1?`searching the web`:`searching the web ${i} times`;break;case`fetch`:a=i===1?`fetching 1 URL`:`fetching ${i} URLs`;break;case`browser`:a=i===1?`navigating browser`:`navigating browser ${i} times`;break;case`terminal`:a=`getting terminal output`;break;case`diag`:a=`checking diagnostics`;break;default:a=i===1?`1 operation`:`${i} operations`;break}else switch(e){case`search`:a=n===1?`searched for 1 pattern`:`searched for ${n} patterns`;break;case`read`:a=n===1?`read 1 file`:`read ${n} files`;break;case`list`:a=n===1?`listed 1 directory`:`listed ${n} directories`;break;case`web`:a=n===1?`searched the web`:`searched the web ${n} times`;break;case`fetch`:a=n===1?`fetched 1 URL`:`fetched ${n} URLs`;break;case`browser`:a=n===1?`navigated browser`:`navigated browser ${n} times`;break;case`terminal`:a=`got terminal output`;break;case`diag`:a=`checked diagnostics`;break;default:a=n===1?`1 operation`:`${n} operations`;break}t.push(a)}for(let t of[`search`,`read`,`list`,`web`,`fetch`,`browser`,`terminal`,`diag`,`other`]){let r=e[t];r&&n(t,r.completed,r.executing)}return t.join(`, `)}const C9=(0,Y.memo)(({segments:e})=>{let t={},n=null,r=!1,i=!1;for(let a of e){let e=pue(S9(a)),o=!a.toolUseResult;if(t[e]||(t[e]={completed:0,executing:0}),o)t[e].executing++,n=a,r=!0;else{t[e].completed++;let n=a.toolUseResult;(n?.rejected||n?.content?.startsWith(`Error:`))&&(i=!0)}}let a=mue(t),o=a.charAt(0).toUpperCase()+a.slice(1),s=n?fue(n):null;return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsxs)(X,{flexDirection:`row`,gap:1,alignItems:`center`,children:[r?(0,J.jsx)(q$,{}):(0,J.jsx)(Z,{color:i?`red`:r?`white`:`green`,children:`⏺`}),(0,J.jsxs)(Z,{children:[o,r?`…`:``]}),(0,J.jsx)(Z,{color:YW,dimColor:!0,children:`(ctrl+o to expand)`})]}),s&&(0,J.jsxs)(X,{flexDirection:`row`,paddingLeft:2,children:[(0,J.jsxs)(Z,{color:XW,dimColor:!0,children:[`⎿`,` `]}),(0,J.jsx)(Z,{color:XW,children:s})]})]})});C9.displayName=`ToolGroupSummary`;const w9=(0,Y.memo)(({questions:e,onResolve:t})=>{let[n,r]=(0,Y.useState)(0),[i,a]=(0,Y.useState)(0),[o,s]=(0,Y.useState)(()=>new Map),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(()=>new Map),f=(0,Y.useRef)(null),p=(0,Y.useCallback)(e=>f.current?.getExpandedText(e)??e,[]),m=e[n],h=o.get(n)??new Set,g=(0,Y.useRef)(i);g.current=i;let _=(0,Y.useRef)(n);_.current=n;let v=(0,Y.useRef)(c);v.current=c;let y=(0,Y.useRef)(e);y.current=e;let b=(0,Y.useRef)(o);b.current=o;let x=(0,Y.useRef)(u);x.current=u;let S=(0,Y.useCallback)((e,t)=>{let n={};for(let r=0;r<y.current.length;r++){let i=y.current[r];if(!i)continue;let a=e.get(r);if(!a||a.size===0)continue;let o=[...a].sort((e,t)=>e-t).map(e=>i.options[e]?.label??``).filter(Boolean),s=t.get(r);n[`question_${r}`]=s?`${o.join(`, `)} — ${s}`:o.join(`, `)}return n},[]),C=(0,Y.useCallback)((e,n)=>{t({type:`question_answers`,answers:S(e,n)})},[t,S]),w=(0,Y.useCallback)((e,t,n)=>{e>=y.current.length?C(t,n):(r(e),a(0),l(!1))},[C]),T=(0,Y.useCallback)(()=>{let e=_.current;if(!y.current[e])return;let t=b.current,n=x.current;w(e+1,t,n)},[w]),E=(0,Y.useRef)(T);E.current=T;let D=(0,Y.useCallback)(e=>{if(e.key.return){let t=p(f.current?.text?.trim()??``),n=_.current,r=new Map(x.current);t?r.set(n,t):r.delete(n),d(r),l(!1),f.current?.setText(``),e.preventDefault();return}if(e.key.escape){l(!1),f.current?.setText(``),e.preventDefault();return}if(e.key.tab){l(!1),f.current?.setText(``),e.preventDefault();return}},[p]),O=(0,Y.useCallback)(e=>{let t=_.current,n=new Map(x.current),r=p(e.trim());r?n.set(t,r):n.delete(t),d(n),l(!1),f.current?.setText(``)},[p]);if(BB((0,Y.useCallback)((e,t)=>{if(v.current)return;let n=_.current,i=y.current[n];if(!i)return;let o=i.options.length;if(t.upArrow){a(e=>Math.max(0,e-1));return}if(t.downArrow){a(e=>Math.min(o-1,e+1));return}if(t.leftArrow){n>0&&(r(n-1),a(0),l(!1));return}if(t.rightArrow){n<y.current.length-1&&(r(n+1),a(0),l(!1));return}if(e===` `){let e=g.current,t=new Map(b.current),r=new Set(t.get(n)??[]);i.multiSelect?r.has(e)?r.delete(e):r.add(e):(r.clear(),r.add(e)),t.set(n,r),s(t);return}if(t.return){if((b.current.get(n)??new Set).size===0&&!i.multiSelect){let e=g.current,t=new Map(b.current),r=new Set([e]);t.set(n,r),s(t),w(n+1,t,x.current)}else E.current();return}if(t.tab){l(!0),setTimeout(()=>{let e=x.current.get(n)??``;f.current&&e&&f.current.setText(e)},0);return}if(t.escape){C(b.current,x.current);return}},[w,C]),{isActive:!c}),!m)return null;let k=u.get(n);return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Questions (${n+1}/${e.length}): ${m.header}`}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,J.jsx)(Z,{children:m.question})}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:m.options.map((e,t)=>{let n=t===i,r=h.has(t),a=m.multiSelect?r?`[x] `:`[ ] `:r?`◉ `:`○ `;return(0,J.jsxs)(X,{flexDirection:`row`,children:[(0,J.jsx)(Z,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,J.jsxs)(Z,{color:r?`green`:n?void 0:`brightblack`,children:[a,e.label]}),e.description?(0,J.jsxs)(Z,{dimColor:!0,children:[` — `,e.description]}):null]},t)})}),c?(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:(0,J.jsxs)(X,{flexDirection:`row`,children:[(0,J.jsx)(Z,{color:`cyan`,children:`❯ `}),(0,J.jsx)(Z,{dimColor:!0,children:`Note: `}),(0,J.jsx)($6,{ref:f,flexGrow:1,maxWidth:`90%`,placeholder:`Add context or instructions…`,onSubmit:O,onKeyDown:D})]})}):(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:k&&(0,J.jsxs)(Z,{dimColor:!0,children:[`Note: `,(0,J.jsx)(Z,{italic:!0,children:k})]})}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`row`,paddingLeft:1,paddingBottom:1,gap:2,children:c?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{dimColor:!0,children:`enter save note`}),(0,J.jsx)(Z,{dimColor:!0,children:`esc discard note`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{dimColor:!0,children:`↑↓ option`}),(0,J.jsx)(Z,{dimColor:!0,children:`space select`}),(0,J.jsx)(Z,{dimColor:!0,children:`enter confirm`}),e.length>1&&(0,J.jsx)(Z,{dimColor:!0,children:`←→ navigate`}),(0,J.jsx)(Z,{dimColor:!0,children:`tab add note`}),(0,J.jsx)(Z,{dimColor:!0,children:`esc skip`})]})})]})});w9.displayName=`AskUserQuestionPermissionUI`;const T9=(0,Y.memo)(({option:e,index:t,isSelected:n,showAsInput:r,showAsEdit:i,inputPlaceholder:a,inputPrefix:o,inputBufferRef:s,editBufferRef:c,onInputSubmit:l,onInputKeyDown:u,onEditSubmit:d,onEditKeyDown:f})=>i?(0,J.jsxs)(X,{flexDirection:`row`,children:[(0,J.jsx)(Z,{color:`cyan`,children:`❯ `}),(0,J.jsx)(Z,{children:`${t+1}. `}),(0,J.jsx)($6,{ref:c,flexGrow:1,maxWidth:`90%`,placeholder:`Edit rule...`,onSubmit:d,onKeyDown:f})]}):r?(0,J.jsxs)(X,{flexDirection:`row`,children:[(0,J.jsx)(Z,{color:`cyan`,children:`❯ `}),(0,J.jsx)(Z,{children:`${t+1}. ${o||``}`}),(0,J.jsx)($6,{ref:s,flexGrow:1,maxWidth:`90%`,placeholder:a,onSubmit:l,onKeyDown:u})]}):(0,J.jsxs)(X,{flexDirection:`row`,children:[(0,J.jsx)(Z,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,J.jsxs)(Z,{color:n?void 0:`brightblack`,children:[`${t+1}. ${e.label}`,e.hint&&!e.rules&&(0,J.jsxs)(Z,{dimColor:!0,children:[` (`,e.hint,`)`]})]})]}));T9.displayName=`PermissionOptionItem`;const E9=(0,Y.memo)(({options:e,onSelect:t,inputPlaceholder:n=`and tell AbacusAI`,onModeSwitch:r,modeSwitchHint:i})=>{let[a,o]=(0,Y.useState)(0),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),d=(0,Y.useRef)(null),f=(0,Y.useRef)(null),p=(0,Y.useCallback)(e=>d.current?.getExpandedText(e)??e,[]),m=(0,Y.useCallback)(()=>{},[]),h=(0,Y.useRef)(``),g=(0,Y.useRef)(``),_=(0,Y.useMemo)(()=>e.filter(e=>e.value!==`input`),[e]),v=s,y=(0,Y.useRef)(a);y.current=a;let b=(0,Y.useRef)(_.length);b.current=_.length;let x=(0,Y.useRef)(v);x.current=v;let S=(0,Y.useRef)(l);S.current=l;let C=(0,Y.useRef)(t);C.current=t;let w=(0,Y.useRef)(r);w.current=r;let T=(0,Y.useRef)(_);T.current=_;let E=(0,Y.useCallback)(()=>{let e=T.current[y.current];if(e)if(x.current){let t=d.current?.text?.trim();if(t){let n=p(t),r=e.value===`accept`?`accept`:`reject`;C.current({decision:r,userMessage:n,rules:e.rules}),m()}}else e.value!==`input`&&C.current({decision:e.value,rules:e.rules})},[p,m]),D=(0,Y.useRef)(E);D.current=E;let O=(0,Y.useCallback)(e=>{if(e.trim()){let t=T.current[y.current],n=p(e.trim()),r=t?.value===`accept`?`accept`:`reject`;C.current({decision:r,userMessage:n,rules:t?.rules}),m()}},[p,m]),k=(0,Y.useCallback)(e=>{if(e.key.upArrow||e.key.downArrow){let t=T.current[y.current],n=d.current?.text||``;t?.value===`accept`?h.current=n:t?.value===`reject`&&(g.current=n),c(!1),e.key.upArrow?o(e=>Math.max(0,e-1)):o(e=>Math.min(b.current-1,e+1)),e.preventDefault();return}if(e.key.tab){let t=T.current[y.current];t?.value===`accept`?h.current=``:t?.value===`reject`&&(g.current=``),m(),c(!1),e.preventDefault();return}if(e.key.escape){m(),c(!1),C.current({decision:`reject`}),e.preventDefault();return}},[m]),A=(0,Y.useCallback)(e=>{let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);t.length!==0&&T.current[y.current]&&(t.length===1?C.current({decision:`allowAlwaysWithRule`,rules:t}):C.current({decision:`allowAlwaysWithRules`,rules:t}),u(!1))},[]),j=(0,Y.useCallback)(e=>{if(e.key.escape){u(!1),e.preventDefault();return}},[]);BB((0,Y.useCallback)((e,t)=>{if(!x.current&&!S.current){if(t.upArrow){o(e=>Math.max(0,e-1));return}if(t.downArrow){o(e=>Math.min(b.current-1,e+1));return}if(t.escape){C.current({decision:`reject`});return}if(t.tab&&t.shift){if(w.current){w.current();return}let e=T.current.findIndex(e=>e.value===`allowAlways`);e!==-1&&(o(e),setTimeout(()=>{C.current({decision:`allowAlways`})},0));return}if(t.tab){let e=T.current[y.current];if(e&&(e.value===`accept`||e.value===`reject`)){c(!0);let t=e.value===`accept`?h.current:g.current;setTimeout(()=>{d.current&&t&&d.current.setText(t)},0)}return}if(e===`e`||e===`E`){let e=T.current[y.current];if(e?.rules?.length){u(!0),setTimeout(()=>{f.current?.setText(e.rules.join(`, `))},0);return}}if(t.return){D.current();return}}},[]),{isActive:!0}),(0,Y.useEffect)(()=>{let e=_[a];e&&(e.value!==`accept`&&e.value!==`reject`||(e.value===`accept`?h.current:g.current)&&!s&&c(!0))},[a,_,s]);let M=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{s&&(M.current=!0)},[s]),(0,Y.useEffect)(()=>{if(!s||!M.current)return;let e=_[a];if(!e)return;let t=e.value===`accept`?h.current:e.value===`reject`?g.current:``;t?setTimeout(()=>{d.current&&d.current.text===``&&d.current.setText(t),M.current=!1},0):M.current=!1},[s,a,_]);let N=_[a],P=s&&N,ee=e=>e.value===`accept`?`Yes, `:e.value===`reject`?`No, `:``,F=!s&&!l&&N&&(N.value===`accept`||N.value===`reject`),te=!s&&!l&&!!N?.rules?.length,I=_.some(e=>e.value===`allowAlways`||e.value===`allowAlwaysWithRule`);return(0,J.jsxs)(X,{flexDirection:`column`,children:[_.map((e,t)=>{let r=t===a,i=P&&r,o=e.value===`accept`?h.current:e.value===`reject`?g.current:``;return(0,J.jsx)(T9,{option:!i&&o?{...e,label:`${e.label}, ${o}`}:e,index:t,isSelected:r,showAsInput:i,showAsEdit:l&&r,editBufferRef:f,onEditSubmit:A,onEditKeyDown:j,inputPrefix:ee(e),inputPlaceholder:n,inputBufferRef:d,onInputSubmit:O,onInputKeyDown:k},t)}),(0,J.jsx)(X,{flexDirection:`row`,marginTop:1,gap:2,children:l?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{dimColor:!0,children:`enter confirm`}),(0,J.jsx)(Z,{dimColor:!0,children:`esc cancel`})]}):s?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{dimColor:!0,children:`enter submit`}),(0,J.jsx)(Z,{dimColor:!0,children:`tab discard note`}),(0,J.jsx)(Z,{dimColor:!0,children:`esc reject`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{dimColor:!0,children:`↑↓ navigate`}),(0,J.jsx)(Z,{dimColor:!0,children:`enter select`}),F&&(0,J.jsx)(Z,{dimColor:!0,children:`tab add note`}),te&&(0,J.jsx)(Z,{dimColor:!0,children:`e edit rule`}),i&&(0,J.jsxs)(Z,{dimColor:!0,children:[`shift+tab `,i]}),!i&&I&&(0,J.jsx)(Z,{dimColor:!0,children:`shift+tab don't ask again`}),(0,J.jsx)(Z,{dimColor:!0,children:`esc reject`})]})})]})});E9.displayName=`PermissionOptions`;function D9(e){return e.decision===`accept`&&e.userMessage?{type:`accept_with_message`,message:e.userMessage}:e.decision===`reject`&&e.userMessage?{type:`reject_with_message`,message:e.userMessage}:e.decision===`allowAlwaysWithRule`?e.rules?.length?{type:`allow_always_with_rule`,rule:e.rules[0]}:`accept`:e.decision===`allowAlwaysWithRules`?e.rules?.length?{type:`allow_always_with_rules`,rules:e.rules}:`accept`:e.decision}const O9=(0,Y.memo)(({filePath:e,originalContent:t,newContent:n,diffShownInEditor:r,onResolve:i})=>{let a=!t,{agentMode:o}=y1(),s=[{label:`Yes, apply changes`,value:`accept`},...o===Xd.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}],c=e=>{i(D9(e))};return r?(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`${a?`Create`:`Update`} file ${e}`,subtitle:`Opened changes in the editor`}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:s,onSelect:c,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]}):(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`${a?`Create`:`Update`} file ${e}`}),a?I0(e)?(0,J.jsx)(H0,{content:n,maxLinesPerCell:100}):(0,J.jsx)(Q$,{filePath:e,content:n,maxLines:100}):I0(e)?(0,J.jsx)(z0,{filePath:e,originalContent:t,newContent:n}):(0,J.jsx)(O0,{filePath:e,originalContent:t,newContent:n,paddingLeft:1}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:s,onSelect:c,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});O9.displayName=`EditFilePermissionUI`;const k9=(0,Y.memo)(({filePath:e,originalContent:t,content:n,isNewFile:r,diffShownInEditor:i,onResolve:a})=>{let{agentMode:o}=y1(),s=[{label:`Yes, apply changes`,value:`accept`},...o===Xd.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}],c=e=>{a(D9(e))};return i?(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`${r?`Create`:`Update`} file ${e}`,subtitle:`Opened changes in the editor`}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:s,onSelect:c,onModeSwitch:()=>a(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]}):(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`${r?`Create`:`Update`} file ${e}`}),r?I0(e)?(0,J.jsx)(H0,{content:n,maxLinesPerCell:100}):(0,J.jsx)(Q$,{filePath:e,content:n,maxLines:100}):I0(e)?(0,J.jsx)(z0,{filePath:e,originalContent:t,newContent:n}):(0,J.jsx)(O0,{filePath:e,originalContent:t,newContent:n,paddingLeft:1}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:s,onSelect:c,onModeSwitch:()=>a(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});k9.displayName=`WriteFilePermissionUI`;const A9=(0,Y.memo)(({description:e,url:t,displayName:n,onResolve:r})=>{let i=[{label:`Yes, allow action`,value:`accept`},{label:`Yes, and always allow ${n}`,value:`allowAlwaysWithRule`,rules:[n]},{label:`No, deny action`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Browser action: ${e}`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{children:e}),t&&(0,J.jsxs)(Z,{dimColor:!0,children:[`URL: `,t]})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:i,onSelect:e=>{r(D9(e))}})})]})});A9.displayName=`BrowserActionPermissionUI`;const j9=(0,Y.memo)(({command:e,background:t,unmatchedPatterns:n,onResolve:r})=>{let i=(0,Y.useMemo)(()=>U$(),[]),a=Kw(e),o=(0,Y.useMemo)(()=>{let e=[{label:`Yes, run command`,value:`accept`}];if(n.length>1){e.push({label:`Yes, and always allow all: ${n.map(e=>`Bash(${e})`).join(`, `)}`,value:`allowAlwaysWithRules`,rules:n.map(e=>`Bash(${e})`)});for(let t of n)e.push({label:`Yes, and always allow Bash(${t})`,value:`allowAlwaysWithRule`,rules:[`Bash(${t})`]})}else n.length===1?e.push({label:`Yes, and always allow Bash(${n[0]})`,value:`allowAlwaysWithRule`,rules:[`Bash(${n[0]})`]}):e.push({label:`Yes, and always allow Bash(${a})`,value:`allowAlwaysWithRule`,rules:[`Bash(${a})`]});return e.push({label:`No, skip command`,value:`reject`}),e},[n,a]);return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Bash command`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{children:(0,V$.supportsLanguage)(`bash`)?(()=>{try{return(0,V$.highlight)(e,{language:`bash`,theme:i})}catch{return e}})():e}),t&&(0,J.jsx)(X,{paddingTop:1,children:(0,J.jsx)(Z,{dimColor:!0,children:`(Running in background)`})})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:o,onSelect:e=>{r(D9(e))},inputPlaceholder:`Type here to tell AbacusAI what to do differently`,onModeSwitch:()=>r(`allowAlways`),modeSwitchHint:`allow all tools`})})]})});j9.displayName=`RunTerminalPermissionUI`;const M9=(0,Y.memo)(({title:e,description:t,toolName:n,onResolve:r})=>{let i=(0,Y.useMemo)(()=>U$(),[]),a=[{label:`Yes, allow`,value:`accept`},...n?[{label:`Yes, and always allow ${n}`,value:`allowAlwaysWithRule`,rules:[n]}]:[],{label:`No, deny`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:e}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,J.jsx)(Z,{children:(0,V$.supportsLanguage)(`json`)?(()=>{try{return(0,V$.highlight)(t,{language:`json`,theme:i})}catch{return t}})():t})}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:a,onSelect:e=>{r(D9(e))}})})]})});M9.displayName=`GenericPermissionUI`;const N9=(0,Y.memo)(({planFilePath:e,planContent:t,onResolve:n})=>(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Ready to code? Implement plan: ${e.length>60?`…${e.slice(-60)}`:e}`}),t&&(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{dimColor:!0,children:`Here is Abacus's plan:`}),(0,J.jsx)(o9,{children:t})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:[{label:`Yes, implement the plan (approve each edit)`,value:`accept`},{label:`Yes, implement the plan (auto-accept all edits)`,value:`allowAlways`,hint:`shift+tab`},{label:`No, keep planning`,value:`reject`}],onSelect:e=>{n(D9(e))},inputPlaceholder:`Add instructions for the implementation`})})]}));N9.displayName=`ExitPlanModePermissionUI`;const P9=(0,Y.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow read`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny read`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Read file outside workspace`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{children:e}),(0,J.jsxs)(Z,{dimColor:!0,children:[`Directory: `,t]})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:r,onSelect:e=>{n(D9(e))}})})]})});P9.displayName=`ReadOutsideDirectoryPermissionUI`;const F9=(0,Y.memo)(({filePath:e,deducedDirectory:t,isNewFile:n,onResolve:r})=>{let i=[{label:`Yes, allow write`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny write`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`${n?`Create`:`Write`} file outside workspace`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{children:e}),(0,J.jsxs)(Z,{dimColor:!0,children:[`Directory: `,t]})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:i,onSelect:e=>{r(D9(e))}})})]})});F9.displayName=`WriteOutsideDirectoryPermissionUI`;const I9=(0,Y.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow edit`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny edit`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Edit file outside workspace`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{children:e}),(0,J.jsxs)(Z,{dimColor:!0,children:[`Directory: `,t]})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:r,onSelect:e=>{n(D9(e))}})})]})});I9.displayName=`EditOutsideDirectoryPermissionUI`;const L9=(0,Y.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow notebook edit`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny notebook edit`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Edit notebook outside workspace`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{children:e}),(0,J.jsxs)(Z,{dimColor:!0,children:[`Directory: `,t]})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:r,onSelect:e=>{n(D9(e))}})})]})});L9.displayName=`NotebookEditOutsideDirectoryPermissionUI`;const R9=(0,Y.memo)(({notebookPath:e,cellId:t,editMode:n,cellType:r,originalContent:i,newContent:a,onResolve:o})=>{let s=n??`replace`,c=``;c=s===`delete`?`Delete cell${t?` ${t}`:``}`:s===`insert`?`Insert new cell${t?` after ${t}`:` at beginning`} (${r??`code`})`:`Replace cell contents for cell ${t??`unknown`}`;let{agentMode:l}=y1(),u=[{label:`Yes, apply changes`,value:`accept`},...l===Xd.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Edit notebook`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,children:[(0,J.jsx)(Z,{dimColor:!0,children:e}),(0,J.jsx)(Z,{dimColor:!0,children:c})]}),s===`delete`?(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,J.jsx)(Z,{color:`red`,children:`Cell will be deleted`})}):s===`insert`||!i?(0,J.jsx)(O0,{filePath:P0(r===`markdown`?`markdown`:`python`),originalContent:``,newContent:a,showHeader:!1,paddingLeft:1}):(0,J.jsx)(R0,{cellIndex:0,cellType:r??`code`,cellId:t,language:r===`markdown`?`markdown`:`python`,originalSource:i,newSource:a,status:`modified`}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:u,onSelect:e=>{o(D9(e))},onModeSwitch:()=>o(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});R9.displayName=`NotebookEditPermissionUI`;const z9=(0,Y.memo)(({pendingTool:e})=>{let{request:t,resolve:n}=e;switch(t.type){case`edit_file`:return(0,J.jsx)(O9,{filePath:t.filePath,originalContent:t.originalContent,newContent:t.newContent,diffShownInEditor:t.diffShownInEditor,onResolve:n});case`write_file`:return(0,J.jsx)(k9,{filePath:t.filePath,originalContent:t.originalContent,content:t.content,isNewFile:t.isNewFile,diffShownInEditor:t.diffShownInEditor,onResolve:n});case`run_terminal`:return(0,J.jsx)(j9,{command:t.command,background:t.background,unmatchedPatterns:t.unmatchedPatterns,onResolve:n});case`browser_action`:return(0,J.jsx)(A9,{description:t.description,url:t.url,displayName:t.displayName,onResolve:n});case`generic`:return(0,J.jsx)(M9,{title:`Tool: ${t.toolName}`,description:t.inputSummary,toolName:t.toolName,onResolve:n});case`read_outside_directory`:return(0,J.jsx)(P9,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`write_outside_directory`:return(0,J.jsx)(F9,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,isNewFile:t.isNewFile,onResolve:n});case`edit_outside_directory`:return(0,J.jsx)(I9,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`notebook_edit_outside_directory`:return(0,J.jsx)(L9,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`exit_plan_mode`:return(0,J.jsx)(N9,{planFilePath:t.planFilePath,planContent:t.planContent,onResolve:n});case`ask_user_question`:return(0,J.jsx)(w9,{questions:t.questions,onResolve:n});case`notebook_edit`:return(0,J.jsx)(R9,{notebookPath:t.notebookPath,cellId:t.cellId,editMode:t.editMode,cellType:t.cellType,originalContent:t.originalContent,newContent:t.newContent,onResolve:n});default:return null}});z9.displayName=`ToolPermissionUI`;function hue(e){let t=(0,Y.useRef)(!1),n=(0,Y.useRef)(e);(0,Y.useEffect)(()=>{n.current=e},[e]),(0,Y.useEffect)(()=>{let e=()=>{t.current||(t.current=!0,n.current())};return process.on(`exit`,e),process.on(`SIGINT`,e),process.on(`SIGTERM`,e),()=>{e(),process.off(`exit`,e),process.off(`SIGINT`,e),process.off(`SIGTERM`,e)}},[])}const B9=(0,Y.createContext)(null),V9=()=>{let e=(0,Y.use)(B9);if(!e)throw Error(`${V9.name} must be used within a ${H9.name}`);return e};function H9({children:e}){let t=(0,Y.useCallback)(e=>{let t=e.split(``).filter(e=>{let t=e.codePointAt(0);return!(t<=31||t===127)}).join(``);process.stdout.write(JB(t))},[]);hue(()=>{process.stdout.write(JB(``))});let n=(0,Y.useMemo)(()=>({setTitle:t}),[t]);return(0,J.jsx)(B9.Provider,{value:n,children:e})}const U9=2e3;function W9(e,t,n){return e===Zd.ExecutingTool?`tool-executing`:e===Zd.Submitted||e===Zd.Streaming?`streaming`:e===Zd.WaitingForToolPermission&&t?`permission-ui`:n()?`idle-with-text`:`idle-empty`}function gue(e){let{agentStatus:t,hasPendingPermission:n,isExpandedView:r,composerHasText:i,hasQueuedMessages:a,stopAgent:o,rejectPermission:s,saveAndClearComposer:c,clearComposer:l,dequeueOne:u,clearQueue:d,exitApp:f}=e,[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(null),_=(0,Y.useRef)(null),v=(0,Y.useRef)(null),y=(0,Y.useCallback)(()=>{m(!1),_.current&&=(clearTimeout(_.current),null)},[]),b=(0,Y.useCallback)(()=>{g(null),v.current&&=(clearTimeout(v.current),null)},[]),x=(0,Y.useCallback)(()=>{y(),b()},[y,b]),S=W9(t,n,i),C=(0,Y.useRef)(S);return(0,Y.useEffect)(()=>{let e=C.current;C.current=S,e!==S&&x()},[S,x]),BB((0,Y.useEffectEvent)((e,S)=>{if(S.ctrl&&e===`z`){process.platform!==`win32`&&process.kill(process.pid,`SIGTSTP`);return}let C=S.escape,w=S.ctrl&&e===`c`,T=S.ctrl&&e===`d`;if(!C&&!w&&!T||C&&r)return;let E=W9(t,n,i);if(E===`tool-executing`||E===`streaming`){x(),o();return}if(E===`permission-ui`){x(),s();return}if(E===`idle-with-text`){if(C){p?(l(),x()):(b(),m(!0),_.current=setTimeout(()=>{m(!1),_.current=null},U9));return}let e=w?`c`:`d`;if(h===e){x(),f();return}if(h!==null){b(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},U9);return}y(),c(),a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},U9);return}if(E===`idle-empty`){if(C){a()&&u();return}let e=w?`c`:`d`;if(h===e){x(),f();return}if(h!==null){b(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},U9);return}a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},U9)}}),{isActive:!0}),(0,Y.useEffect)(()=>()=>{_.current&&clearTimeout(_.current),v.current&&clearTimeout(v.current)},[]),{escClear:p,exitKey:h}}const _ue={todos:[],completed:0,inProgress:0,pending:0,total:0};function vue(e){let t=e.toolUseRequest;if(!t)return null;let n;if(Array.isArray(t)){for(let e=t.length-1;e>=0;e--){let r=t[e];if(r&&r.name===`todo_write`){n=r;break}}if(!n)return null}else if(n=t,n.name!==`todo_write`)return null;let r=n.input;if(!r)return null;let i=r.todos;if(typeof i==`string`)try{i=JSON.parse(i)}catch{return null}return Array.isArray(i)?i.filter(e=>typeof e==`object`&&!!e&&typeof e.content==`string`&&typeof e.status==`string`).map((e,t)=>({id:e.id??`todo-${t}`,content:e.content,status:e.status})):null}function yue(e){return(0,Y.useMemo)(()=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`code_llm_tool_call`&&n.type!==`code_llm_agent_tool_request`)continue;let r=vue(n);if(!r)continue;let i=r.filter(e=>e.status!==`cancelled`);return{todos:i,completed:i.filter(e=>e.status===`completed`).length,inProgress:i.filter(e=>e.status===`in_progress`).length,pending:i.filter(e=>e.status===`pending`).length,total:i.length}}return _ue},[e])}function G9(e){return e.type===`code_llm_tool_call`||e.type===`code_llm_agent_tool_request`}function bue(e){let t=e.toolUseResult;return!!(t?.rejected||t?.content?.startsWith(`Error:`))}function xue(e){if(e.type!==`code_llm_notification`)return!1;let t=(e.message??``).toLowerCase();return t.includes(`compacting conversation`)||t.includes(`compacted conversation`)}function Sue(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 Cue(e,t){return{toolUses:e.toolUses+t.toolUses,responses:e.responses+t.responses}}function wue(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(xue(o)){let e=Sue(n);t=Cue(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=Tue(n);return a.push(...o),a}function Tue(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(G9(r)&&x9.has(K9(r))){let i=[r],a=n+1;for(;a<e.length;){let t=e[a];if(t.type===`thinking`){a++;continue}if(bue(i[i.length-1]))break;if(G9(t)&&x9.has(K9(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 K9(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function Eue(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 Due({timing:e}){let{setTitle:t}=V9(),{segments:n,agentStatus:r,pendingToolPermission:i,conversationTitle:a,conversationId:o,addNotification:s,stop:c,rejectPendingPermission:l,removeFirstFromQueue:u,clearQueue:d,totalCredits:f}=d6(),p=(0,Y.useRef)(null),{authExpired:m,clearAuthExpired:h}=o6();(0,Y.useEffect)(()=>{m&&(s(`Session expired — use /login to authenticate again.`,`error`),h())},[m,s,h]);let[g,_]=(0,Y.useState)(!1);BB((e,t)=>{(t.ctrl||t.super)&&e===`o`&&_(e=>!e)});let v=yue(n),{lastItem:y,prevItems:b}=(0,Y.useMemo)(()=>{let e=wue(n.filter(e=>!e.temp&&!e.isSpinny));return{lastItem:e.at(-1)??null,prevItems:e.slice(0,-1)}},[n]),{thinkingStartTime:x,thinkingEndTime:S}=(0,Y.useMemo)(()=>Eue(n),[n]),C=(0,Y.useRef)(Zd.Idle),[w,T]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let e=C.current===Zd.Idle,t=r!==Zd.Idle&&r!==Zd.WaitingForToolPermission;e&&t?T(Date.now()):r===Zd.Idle&&T(null),C.current=r},[r]);let E=r===Zd.WaitingForToolPermission&&i!==null,[D,O]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(`0`),[j,M]=(0,Y.useState)(0);(0,Y.useEffect)(()=>{t(a?`${a} • Abacus.AI CLI`:`Abacus.AI CLI`)},[a,t]),(0,Y.useEffect)(()=>EV(async()=>{let t=e.getFormattedDuration();M(f),A(t),O(!0),await new Promise(e=>setTimeout(e,100))},{wait:2e3,streams:[process.stdout,process.stderr]}),[e,f]);let N=gue({agentStatus:r,hasPendingPermission:i!==null,isExpandedView:g,composerHasText:()=>p.current?.hasText()??!1,hasQueuedMessages:()=>p.current?.hasQueue()??!1,stopAgent:c,rejectPermission:l,saveAndClearComposer:()=>p.current?.saveAndClear(),clearComposer:()=>p.current?.clear(),dequeueOne:u,clearQueue:d,exitApp:()=>DV(0)}),P=r!==Zd.Idle&&r!==Zd.WaitingForToolPermission,ee=i?.request.tool.id??null;return(0,J.jsx)(O1.Provider,{value:g,children:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(X,{flexDirection:`column`,gap:1,paddingBottom:1,width:`95%`,children:[(0,J.jsx)(R5,{}),(0,J.jsxs)(W$.Provider,{value:ee,children:[b.map(e=>e.kind===`compacted`?(0,J.jsx)(g6,{counts:e.counts,segments:e.segments},e.id):e.kind===`segment`?(0,J.jsx)(_9,{segment:e.segment},e.segment.id):g?e.segments.map(e=>(0,J.jsx)(_9,{segment:e},e.id)):(0,J.jsx)(C9,{segments:e.segments},e.id)),y&&(y.kind===`compacted`?(0,J.jsx)(g6,{counts:y.counts,segments:y.segments},y.id):y.kind===`segment`?(0,J.jsx)(_9,{segment:y.segment},y.segment.id):g?y.segments.map(e=>(0,J.jsx)(_9,{segment:e},e.id)):(0,J.jsx)(C9,{segments:y.segments},y.id))]}),(0,J.jsx)(b9,{state:v}),P&&(0,J.jsx)(J8,{onError:e=>{process.stderr.write(`[status-indicator error] ${e.stack??e.message}\n`)},children:(0,J.jsx)(cue,{status:r,thinkingStartTime:x,thinkingEndTime:S,runStartTime:w})})]}),D?(0,J.jsx)(Y8,{duration:k,credits:j,conversationId:o}):(0,J.jsxs)(J.Fragment,{children:[E&&(0,J.jsx)(J8,{onError:e=>{process.stderr.write(`[tool-permission error] ${e.stack??e.message}\n`)},children:(0,J.jsx)(z9,{pendingTool:i})}),(0,J.jsx)(Y.Activity,{mode:E?`hidden`:`visible`,children:(0,J.jsx)(J8,{fallback:e=>(0,J.jsxs)(X,{flexDirection:`column`,paddingX:1,children:[(0,J.jsx)(Z,{color:`red`,bold:!0,children:`Something went wrong in the input area.`}),(0,J.jsx)(Z,{color:`yellow`,children:e.message}),(0,J.jsxs)(Z,{dimColor:!0,children:[`Press Escape to restart the CLI, or resume with: `,sn.binName,` -c`,` `,o]})]}),onError:e=>{process.stderr.write(`[composer error] ${e.stack??e.message}\n`)},children:(0,J.jsx)(q8,{hints:N,composerRef:p})})})]})]})})}async function Oue({apiClient:e,authManager:t,configService:n,agentArgs:r}){let i,a=r?.[`permission-mode`];if(a)switch(a){case`yolo`:i=Xd.Yolo;break;case`accept-edits`:i=Xd.AcceptEdits;break;case`plan`:i=Xd.PlanMode;break;default:i=Xd.Normal;break}else r?.[`dangerously-skip-permissions`]?i=Xd.Yolo:r?.[`auto-accept-edits`]?i=Xd.AcceptEdits:r?.[`plan-mode`]&&(i=Xd.PlanMode);await Tz();let o=process.stdout,s=e=>{o&&o.writable&&o.write(e)},c=()=>s(gB),l=()=>s(hB),u=!1;for(;;){u=!1;let a=new kW,o=new Hoe,s=null,d=()=>{u=!0,s?.unmount()};c();let f=IB((0,J.jsx)(s6,{client:e,authManager:t,onAuthExpired:d,children:(0,J.jsx)(MW,{client:a,children:(0,J.jsx)(b6,{children:(0,J.jsx)(H9,{children:(0,J.jsx)(Pae,{children:(0,J.jsx)(ooe,{configService:n,children:(0,J.jsx)(jae,{children:(0,J.jsx)(S1,{initialMode:i,children:(0,J.jsx)(Mae,{children:(0,J.jsx)(u6,{apiClient:e,configService:n,agentArgs:r,children:(0,J.jsx)(Due,{timing:o})})})})})})})})})})}),{exitOnCtrlC:!1,suspendable:!0,onSuspended:()=>{process.stderr.write(`
|
|
73681
|
+
`;default:return n(n9(e))}}function a9(e,t=0,n=!1){switch(e.type){case`heading`:return(0,J.jsx)(X,{flexDirection:`column`,children:(0,J.jsx)(Z,{bold:!0,color:e.depth<=2?ZW:QW,dimColor:e.depth>2,children:r9(e.tokens,n)})},`heading-${e.depth}`);case`paragraph`:return(0,J.jsx)(X,{flexDirection:`column`,children:(0,J.jsx)(Z,{children:r9(e.tokens,n)})},`paragraph`);case`code`:return(0,J.jsx)(t9,{language:e.lang,children:e.text},`code`);case`blockquote`:return(0,J.jsx)(X,{borderRight:!1,borderTop:!1,borderBottom:!1,borderStyle:`double`,borderColor:rG,paddingLeft:1,flexDirection:`column`,children:e.tokens?.map((e,n)=>(0,J.jsx)(X,{children:a9(e,t,!0)},n))},`blockquote`);case`list`:return(0,J.jsx)(X,{flexDirection:`column`,children:e.items.map((r,i)=>{let a=e.ordered?(Number(e.start)||1)+i:null,o=r.task===!0,s=r.checked===!0,c=r.tokens?.filter(e=>e.type!==`checkbox`)||[];return(0,J.jsxs)(X,{flexDirection:`row`,children:[(0,J.jsx)(Z,{color:QW,dimColor:!0,children:o?s?`[✓] `:`[ ] `:a===null?`• `:`${a}. `}),(0,J.jsx)(X,{flexGrow:1,flexDirection:`column`,children:c.map((e,r)=>(0,J.jsx)(X,{children:a9(e,t+1,n)},r))})]},i)})},`list`);case`table`:{let t=e,r=t.header.map((e,n)=>{let r=n9(e).length;for(let e of t.rows)r=Math.max(r,n9(e[n]).length);return Math.max(r,3)});return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(X,{flexDirection:`row`,borderTop:!1,borderLeft:!1,borderRight:!1,borderStyle:`single`,borderColor:rG,alignSelf:`flex-start`,children:t.header.map((e,i)=>{let a=t.align?.[i]||null;return(0,J.jsx)(X,{width:r[i]+2,paddingX:1,justifyContent:a===`center`?`center`:a===`right`?`flex-end`:`flex-start`,children:(0,J.jsx)(Z,{bold:!0,color:ZW,children:r9(e.tokens,n)})},i)})}),t.rows.map((e,i)=>(0,J.jsx)(X,{flexDirection:`row`,children:e.map((e,i)=>{let a=t.align?.[i]||null;return(0,J.jsx)(X,{width:r[i]+2,paddingX:1,justifyContent:a===`center`?`center`:a===`right`?`flex-end`:`flex-start`,children:(0,J.jsx)(Z,{children:r9(e.tokens,n)})},i)})},i))]},`table`)}case`hr`:return(0,J.jsx)(X,{children:(0,J.jsx)(Z,{dimColor:!0,children:`─`.repeat(50)})},`hr`);case`space`:return null;default:return(0,J.jsx)(X,{flexDirection:`column`,children:(0,J.jsx)(Z,{children:i9(e,n)})})}}function o9({children:e}){let t=(0,Y.useMemo)(()=>{try{let t=Zle(e);return j7.lexer(t,{gfm:!0,breaks:!0})}catch{return[]}},[e]);return(0,J.jsx)(X,{flexDirection:`column`,children:(0,Y.useMemo)(()=>{let e=[],n=t.length;return t.forEach((t,r)=>{let i=r===n-1;if(t.type===`space`){e.push((0,J.jsx)(X,{height:1},`space-${r}`));return}e.push((0,J.jsx)(X,{flexDirection:`column`,children:a9(t)},r)),t.type===`heading`&&!i&&e.push((0,J.jsx)(X,{height:1},`heading-space-${r}`))}),e},[t])})}o9.displayName=`Markdown`;const s9=`Pondering...,Thinking...,Processing...,Analyzing...,Exploring...,Crafting...,Building...,Searching...,Connecting...,Reflecting...,Considering...,Examining...,Synthesizing...,Computing...,Reasoning...,Contemplating...,Assembling...,Formulating...,Generating...,Compiling...,Decoding...,Unraveling...,Mapping...,Weaving...,Brewing...,Sculpting...,Distilling...,Parsing...,Digesting...,Conjuring...`.split(`,`);function tue(e){return e.charAt(0).toUpperCase()+e.slice(1)}function nue(){return s9[Math.floor(Math.random()*s9.length)]}const rue=rt([`codellm`,`cli`,`tools`]);function c9(e){let t=h6[e.name];if(t||=(noe(e.name),h6[e.name]),!t)return(0,J.jsx)(X,{flexDirection:`column`,children:(0,J.jsxs)(Z,{color:`red`,children:[`Unknown tool: `,e.name]})});let n;n=e.result?.rejected?(()=>{try{return JSON.parse(e.result.content)}catch{return{}}})().reason===`interrupted`?`interrupted`:`rejected`:e.result?`success`:e.parsedResult?.phase===`error`?`error`:`executing`;let r=e.input??{},i=``;try{i=t.getHeaderParams(r)}catch{}try{return t.renderUI(r,n,e.parsedResult,e.displayData)}catch(n){let r=n instanceof Error?n.message:String(n);return rue.error`Error rendering tool ${e.name}: ${r}`,(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)($,{name:t.displayName,params:i,status:`error`}),(0,J.jsx)(J$,{color:`red`,children:`Error rendering tool`})]})}}const l9=(0,Y.memo)(e=>{let{type:t,segment:n,isSpinny:r=!1,source:i}=e;if(t!==`text`)throw Error(`Can only render text segments, got ${t}`);let a=(0,Y.useMemo)(()=>S6(n),[n]);return a?.trim()?i===`user`?(0,J.jsxs)(X,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(Z,{color:YW,children:`❯`}),(0,J.jsx)(Z,{color:YW,italic:!0,children:a})]}):r?(0,J.jsx)(X,{flexDirection:`row`,alignItems:`center`,gap:1,children:(0,J.jsx)(m8,{text:a})}):(0,J.jsx)(X,{flexDirection:`column`,children:(0,J.jsxs)(X,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(Z,{color:`white`,children:`⏺`}),(0,J.jsx)(o9,{children:a.trimStart()})]})}):null});l9.displayName=`TextSegment`;const u9=(0,Y.memo)(e=>{let{segment:t}=e,n=(0,Y.useMemo)(()=>S6(t),[t]);return(0,J.jsxs)(X,{flexDirection:`row`,gap:1,alignItems:`flex-start`,children:[(0,J.jsx)(Z,{color:XW,children:`✳`}),(0,J.jsx)(X,{flexDirection:`column`,gap:0,children:n&&(0,J.jsx)(Z,{color:XW,wrap:`wrap`,children:n})})]})});u9.displayName=`ExpandedThinkingSegment`;const d9=(0,Y.memo)(e=>(0,Y.useContext)(O1)?(0,J.jsx)(u9,{...e}):null);d9.displayName=`ThinkingSegment`;const f9=(0,Y.memo)(e=>{let{toolUseRequest:t,toolUseResult:n,toolDisplayData:r,parsedResult:i}=e;return t?Array.isArray(t)?(0,J.jsx)(J.Fragment,{children:t.map((e,t)=>(0,J.jsx)(c9,{...e,result:n,displayData:r,parsedResult:i},e.id??t))}):(0,J.jsx)(c9,{...t,result:n,displayData:r,parsedResult:i}):null});f9.displayName=`ToolCallSegment`;const p9=(0,Y.memo)(e=>{let{type:t,segment:n,title:r,isSpinny:i=!1}=e,a=(0,Y.useRef)(nue());if(t!==`collapsible_component`)throw Error(`Can only render collapsible component segments, got ${t}`);let o=(0,Y.useMemo)(()=>S6(n),[n]);if(!o&&!r)throw Error(`Collapsible component segment must have content or title`);let s=r||tue(a.current);return(0,J.jsxs)(X,{borderStyle:o?`single`:void 0,borderColor:rG,flexDirection:`column`,alignItems:`flex-start`,gap:1,children:[s&&(0,J.jsx)(X,{flexDirection:`row`,alignItems:`center`,gap:1,children:i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(m8,{text:`${s}...`}),(0,J.jsx)(Z,{dimColor:!0,children:`(esc to interrupt)`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{children:` `}),(0,J.jsx)(Z,{color:YW,children:s})]})}),o&&(0,J.jsx)(o9,{children:o})]})});p9.displayName=`CollapsibleComponentSegment`;const m9=(0,Y.memo)(e=>{let{type:t,message:n,severity:r=`info`,actions:i,flashKey:a}=e;if(t!==`code_llm_notification`)throw Error(`Can only render notification segments, got ${t}`);let[o,s]=(0,Y.useState)(!1),c=(0,Y.useRef)(a);if((0,Y.useEffect)(()=>{if(a!==c.current&&a!=null){c.current=a,s(!0);let e=setTimeout(()=>s(!1),600);return()=>clearTimeout(e)}},[a]),!n)throw Error(`Notification segment must have message`);let l=(0,Y.useMemo)(()=>r===`info`||r===`success`||r===`error`||r===`warning`?r:`info`,[r]),u=(0,Y.useMemo)(()=>{switch(l){case`info`:return $W;case`success`:return eG;case`warning`:return nG;case`error`:return tG;default:return $W}},[l]),d=e=>e.replace(/_/g,` `).replace(/([A-Z])/g,` $1`).trim().split(` `).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `),f=(0,Y.useMemo)(()=>(i||[]).filter(e=>e.link),[i]);return(0,J.jsxs)(X,{flexDirection:`column`,gap:0,children:[(0,J.jsxs)(X,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(Z,{color:u,children:o?`◉`:`●`}),(0,J.jsx)(Z,{color:u,bold:o,inverse:o,children:o?` ${n} `:n})]}),f.length>0&&(0,J.jsx)(X,{marginLeft:2,flexDirection:`row`,gap:1,children:f.map((e,t)=>(0,J.jsxs)(Y.Fragment,{children:[t>0&&(0,J.jsx)(Z,{children:` | `}),(0,J.jsx)(Z,{color:`cyan`,underline:!0,children:d(e.type)})]},t))})]})});m9.displayName=`NotificationSegment`;const h9=(0,Y.memo)(e=>{let t=e.creditsUsed??0;return t<=0?null:(0,J.jsx)(X,{justifyContent:`flex-end`,children:(0,J.jsxs)(Z,{dimColor:!0,children:[`Credits used: `,t.toFixed(2)]})})});h9.displayName=`CreditsSegment`;const g9=(0,Y.memo)(({segment:e})=>{switch(e.type){case`text`:return(0,J.jsx)(l9,{...e});case`thinking`:return(0,J.jsx)(d9,{...e});case`code_llm_tool_call`:return(0,J.jsx)(f9,{...e});case`collapsible_component`:return(0,J.jsx)(p9,{...e});case`code_llm_agent_tool_request`:return(0,J.jsx)(f9,{...e});case`code_llm_notification`:return(0,J.jsx)(m9,{...e});case`code_llm_credits`:return(0,J.jsx)(h9,{...e});default:return null}});g9.displayName=`SegmentBase`;function iue(e,t){return(0,J.jsx)(m9,{id:`error-fallback`,status:`completed`,source:`bot`,type:`code_llm_notification`,message:e.message,severity:`error`})}function _9({segment:e}){return(0,J.jsx)(J8,{fallback:iue,children:(0,J.jsx)(g9,{segment:e})})}const v9=`pondering.thinking.processing.analyzing.exploring.crafting.building.searching.connecting.reflecting.considering.examining.synthesizing.computing.reasoning.contemplating.assembling.formulating.generating.compiling.decoding.unraveling.mapping.weaving.brewing.sculpting.distilling.parsing.digesting.conjuring`.split(`.`);function aue(e){return e.charAt(0).toUpperCase()+e.slice(1)}function y9(){return v9[Math.floor(Math.random()*v9.length)]}function oue(e,t){let[n,r]=(0,Y.useState)(0),i=(0,Y.useRef)(null);if((0,Y.useEffect)(()=>{if(!e)return;let t=setInterval(()=>{r(e=>e+1)},500);return()=>clearInterval(t)},[e]),!e)return null;let a=Date.now();if(t){if(i.current===null&&(i.current=t+5e3),a>i.current)return null;let n=t-e;return n<5e3?`thought`:`thought for ${t8(n)}`}i.current=null;let o=a-e;return o<5e3?`thinking`:`thinking for ${t8(o)}`}function sue(e){let[,t]=(0,Y.useState)(0);if((0,Y.useEffect)(()=>{if(!e)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e]),!e)return null;let n=Date.now()-e;return n<5e3?null:t8(n)}const cue=({status:e,thinkingStartTime:t,thinkingEndTime:n,runStartTime:r})=>{let{activity:i}=r6(),[a,o]=(0,Y.useState)(()=>y9()),s=(0,Y.useRef)(Zd.Idle);(0,Y.useEffect)(()=>{s.current===Zd.Idle&&e!==Zd.Idle&&o(y9()),s.current=e},[e]);let c=oue(t,n),l=sue(r);if(!(e!==Zd.Idle&&e!==Zd.WaitingForToolPermission))return null;let u=e===Zd.LoadingConversation?`Resuming`:aue(a);return(0,J.jsxs)(X,{paddingLeft:1,flexDirection:`row`,gap:1,children:[(0,J.jsx)(Z,{color:`cyan`,children:i===`upload`?`↑`:i===`download`?`↓`:`•`}),(0,J.jsx)(m8,{text:`${u}...`}),c&&(0,J.jsxs)(Z,{color:`cyan`,children:[`(`,c,`)`]}),l&&!c&&(0,J.jsx)(Z,{dimColor:!0,children:l}),e!==Zd.LoadingConversation&&(0,J.jsx)(Z,{dimColor:!0,children:`(esc/ctrl+c to interrupt)`})]})};function lue(e){switch(e){case`completed`:return`✔`;case`in_progress`:return`◼`;default:return`◻`}}function uue(e){switch(e){case`completed`:return eG;case`in_progress`:return ZW;default:return YW}}const b9=(0,Y.memo)(({state:e})=>{let t=(0,Y.useContext)(O1);if(e.total===0||t)return null;let{todos:n,total:r,completed:i,inProgress:a,pending:o}=e,s=[];i>0&&s.push(`${i} done`),a>0&&s.push(`${a} in progress`),o>0&&s.push(`${o} open`);let c=s.length>0?`${r} task${r===1?``:`s`} (${s.join(`, `)})`:`${r} task${r===1?``:`s`}`,l=n.slice(0,5),u=r-l.length;return(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,children:[(0,J.jsx)(Z,{dimColor:!0,children:c}),l.map(e=>(0,J.jsxs)(X,{flexDirection:`row`,gap:1,children:[(0,J.jsx)(Z,{color:uue(e.status),children:lue(e.status)}),(0,J.jsx)(Z,{color:e.status===`completed`?YW:void 0,dimColor:e.status===`completed`,strikethrough:e.status===`completed`,children:e.content})]},e.id)),u>0&&(0,J.jsxs)(Z,{dimColor:!0,children:[` `,`+`,u,` more task`,u===1?``:`s`]})]})});b9.displayName=`TodoList`;const x9=new Set([`read`,`grep`,`glob`,`web_search`,`web_fetch`,`get_tab_content`,`bash_output`,`kill_shell`,`get_interactive_elements`,`navigate_to`,`new_tab`,`switch_active_tab`,`close_tab`,`refresh_tab`,`get_diagnostics`]);function S9(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function due(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.input??{}:t.input??{}:{}}function fue(e){let t=S9(e),n=due(e),r=h6[t];if(!r)return``;try{return r.getHeaderParams(n)}catch{return``}}function pue(e){switch(e){case`read`:return`read`;case`grep`:case`glob`:return`search`;case`web_search`:return`web`;case`web_fetch`:return`fetch`;case`navigate_to`:case`new_tab`:case`switch_active_tab`:case`close_tab`:case`refresh_tab`:case`get_tab_content`:case`get_interactive_elements`:return`browser`;case`bash_output`:return`terminal`;case`kill_shell`:return`terminal`;case`get_diagnostics`:return`diag`;default:return`other`}}function mue(e){let t=[];function n(e,n,r){let i=n+r;if(i===0)return;let a;if(r>0)switch(e){case`search`:a=i===1?`searching for 1 pattern`:`searching for ${i} patterns`;break;case`read`:a=i===1?`reading 1 file`:`reading ${i} files`;break;case`list`:a=i===1?`listing 1 directory`:`listing ${i} directories`;break;case`web`:a=i===1?`searching the web`:`searching the web ${i} times`;break;case`fetch`:a=i===1?`fetching 1 URL`:`fetching ${i} URLs`;break;case`browser`:a=i===1?`navigating browser`:`navigating browser ${i} times`;break;case`terminal`:a=`getting terminal output`;break;case`diag`:a=`checking diagnostics`;break;default:a=i===1?`1 operation`:`${i} operations`;break}else switch(e){case`search`:a=n===1?`searched for 1 pattern`:`searched for ${n} patterns`;break;case`read`:a=n===1?`read 1 file`:`read ${n} files`;break;case`list`:a=n===1?`listed 1 directory`:`listed ${n} directories`;break;case`web`:a=n===1?`searched the web`:`searched the web ${n} times`;break;case`fetch`:a=n===1?`fetched 1 URL`:`fetched ${n} URLs`;break;case`browser`:a=n===1?`navigated browser`:`navigated browser ${n} times`;break;case`terminal`:a=`got terminal output`;break;case`diag`:a=`checked diagnostics`;break;default:a=n===1?`1 operation`:`${n} operations`;break}t.push(a)}for(let t of[`search`,`read`,`list`,`web`,`fetch`,`browser`,`terminal`,`diag`,`other`]){let r=e[t];r&&n(t,r.completed,r.executing)}return t.join(`, `)}const C9=(0,Y.memo)(({segments:e})=>{let t={},n=null,r=!1,i=!1;for(let a of e){let e=pue(S9(a)),o=!a.toolUseResult;if(t[e]||(t[e]={completed:0,executing:0}),o)t[e].executing++,n=a,r=!0;else{t[e].completed++;let n=a.toolUseResult;(n?.rejected||n?.content?.startsWith(`Error:`))&&(i=!0)}}let a=mue(t),o=a.charAt(0).toUpperCase()+a.slice(1),s=n?fue(n):null;return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsxs)(X,{flexDirection:`row`,gap:1,alignItems:`center`,children:[r?(0,J.jsx)(q$,{}):(0,J.jsx)(Z,{color:i?`red`:r?`white`:`green`,children:`⏺`}),(0,J.jsxs)(Z,{children:[o,r?`…`:``]}),(0,J.jsx)(Z,{color:YW,dimColor:!0,children:`(ctrl+o to expand)`})]}),s&&(0,J.jsxs)(X,{flexDirection:`row`,paddingLeft:2,children:[(0,J.jsxs)(Z,{color:XW,dimColor:!0,children:[`⎿`,` `]}),(0,J.jsx)(Z,{color:XW,children:s})]})]})});C9.displayName=`ToolGroupSummary`;const w9=(0,Y.memo)(({questions:e,onResolve:t})=>{let[n,r]=(0,Y.useState)(0),[i,a]=(0,Y.useState)(0),[o,s]=(0,Y.useState)(()=>new Map),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(()=>new Map),f=(0,Y.useRef)(null),p=(0,Y.useCallback)(e=>f.current?.getExpandedText(e)??e,[]),m=e[n],h=o.get(n)??new Set,g=(0,Y.useRef)(i);g.current=i;let _=(0,Y.useRef)(n);_.current=n;let v=(0,Y.useRef)(c);v.current=c;let y=(0,Y.useRef)(e);y.current=e;let b=(0,Y.useRef)(o);b.current=o;let x=(0,Y.useRef)(u);x.current=u;let S=(0,Y.useCallback)((e,t)=>{let n={};for(let r=0;r<y.current.length;r++){let i=y.current[r];if(!i)continue;let a=e.get(r);if(!a||a.size===0)continue;let o=[...a].sort((e,t)=>e-t).map(e=>i.options[e]?.label??``).filter(Boolean),s=t.get(r);n[`question_${r}`]=s?`${o.join(`, `)} — ${s}`:o.join(`, `)}return n},[]),C=(0,Y.useCallback)((e,n)=>{t({type:`question_answers`,answers:S(e,n)})},[t,S]),w=(0,Y.useCallback)((e,t,n)=>{e>=y.current.length?C(t,n):(r(e),a(0),l(!1))},[C]),T=(0,Y.useCallback)(()=>{let e=_.current;if(!y.current[e])return;let t=b.current,n=x.current;w(e+1,t,n)},[w]),E=(0,Y.useRef)(T);E.current=T;let D=(0,Y.useCallback)(e=>{if(e.key.return){let t=p(f.current?.text?.trim()??``),n=_.current,r=new Map(x.current);t?r.set(n,t):r.delete(n),d(r),l(!1),f.current?.setText(``),e.preventDefault();return}if(e.key.escape){l(!1),f.current?.setText(``),e.preventDefault();return}if(e.key.tab){l(!1),f.current?.setText(``),e.preventDefault();return}},[p]),O=(0,Y.useCallback)(e=>{let t=_.current,n=new Map(x.current),r=p(e.trim());r?n.set(t,r):n.delete(t),d(n),l(!1),f.current?.setText(``)},[p]);if(BB((0,Y.useCallback)((e,t)=>{if(v.current)return;let n=_.current,i=y.current[n];if(!i)return;let o=i.options.length;if(t.upArrow){a(e=>Math.max(0,e-1));return}if(t.downArrow){a(e=>Math.min(o-1,e+1));return}if(t.leftArrow){n>0&&(r(n-1),a(0),l(!1));return}if(t.rightArrow){n<y.current.length-1&&(r(n+1),a(0),l(!1));return}if(e===` `){let e=g.current,t=new Map(b.current),r=new Set(t.get(n)??[]);i.multiSelect?r.has(e)?r.delete(e):r.add(e):(r.clear(),r.add(e)),t.set(n,r),s(t);return}if(t.return){if((b.current.get(n)??new Set).size===0&&!i.multiSelect){let e=g.current,t=new Map(b.current),r=new Set([e]);t.set(n,r),s(t),w(n+1,t,x.current)}else E.current();return}if(t.tab){l(!0),setTimeout(()=>{let e=x.current.get(n)??``;f.current&&e&&f.current.setText(e)},0);return}if(t.escape){C(b.current,x.current);return}},[w,C]),{isActive:!c}),!m)return null;let k=u.get(n);return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Questions (${n+1}/${e.length}): ${m.header}`}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,J.jsx)(Z,{children:m.question})}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:m.options.map((e,t)=>{let n=t===i,r=h.has(t),a=m.multiSelect?r?`[x] `:`[ ] `:r?`◉ `:`○ `;return(0,J.jsxs)(X,{flexDirection:`row`,children:[(0,J.jsx)(Z,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,J.jsxs)(Z,{color:r?`green`:n?void 0:`brightblack`,children:[a,e.label]}),e.description?(0,J.jsxs)(Z,{dimColor:!0,children:[` — `,e.description]}):null]},t)})}),c?(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:(0,J.jsxs)(X,{flexDirection:`row`,children:[(0,J.jsx)(Z,{color:`cyan`,children:`❯ `}),(0,J.jsx)(Z,{dimColor:!0,children:`Note: `}),(0,J.jsx)($6,{ref:f,flexGrow:1,maxWidth:`90%`,placeholder:`Add context or instructions…`,onSubmit:O,onKeyDown:D})]})}):(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:k&&(0,J.jsxs)(Z,{dimColor:!0,children:[`Note: `,(0,J.jsx)(Z,{italic:!0,children:k})]})}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`row`,paddingLeft:1,paddingBottom:1,gap:2,children:c?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{dimColor:!0,children:`enter save note`}),(0,J.jsx)(Z,{dimColor:!0,children:`esc discard note`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{dimColor:!0,children:`↑↓ option`}),(0,J.jsx)(Z,{dimColor:!0,children:`space select`}),(0,J.jsx)(Z,{dimColor:!0,children:`enter confirm`}),e.length>1&&(0,J.jsx)(Z,{dimColor:!0,children:`←→ navigate`}),(0,J.jsx)(Z,{dimColor:!0,children:`tab add note`}),(0,J.jsx)(Z,{dimColor:!0,children:`esc skip`})]})})]})});w9.displayName=`AskUserQuestionPermissionUI`;const T9=(0,Y.memo)(({option:e,index:t,isSelected:n,showAsInput:r,showAsEdit:i,inputPlaceholder:a,inputPrefix:o,inputBufferRef:s,editBufferRef:c,onInputSubmit:l,onInputKeyDown:u,onEditSubmit:d,onEditKeyDown:f})=>i?(0,J.jsxs)(X,{flexDirection:`row`,children:[(0,J.jsx)(Z,{color:`cyan`,children:`❯ `}),(0,J.jsx)(Z,{children:`${t+1}. `}),(0,J.jsx)($6,{ref:c,flexGrow:1,maxWidth:`90%`,placeholder:`Edit rule...`,onSubmit:d,onKeyDown:f})]}):r?(0,J.jsxs)(X,{flexDirection:`row`,children:[(0,J.jsx)(Z,{color:`cyan`,children:`❯ `}),(0,J.jsx)(Z,{children:`${t+1}. ${o||``}`}),(0,J.jsx)($6,{ref:s,flexGrow:1,maxWidth:`90%`,placeholder:a,onSubmit:l,onKeyDown:u})]}):(0,J.jsxs)(X,{flexDirection:`row`,children:[(0,J.jsx)(Z,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,J.jsxs)(Z,{color:n?void 0:`brightblack`,children:[`${t+1}. ${e.label}`,e.hint&&!e.rules&&(0,J.jsxs)(Z,{dimColor:!0,children:[` (`,e.hint,`)`]})]})]}));T9.displayName=`PermissionOptionItem`;const E9=(0,Y.memo)(({options:e,onSelect:t,inputPlaceholder:n=`and tell AbacusAI`,onModeSwitch:r,modeSwitchHint:i})=>{let[a,o]=(0,Y.useState)(0),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),d=(0,Y.useRef)(null),f=(0,Y.useRef)(null),p=(0,Y.useCallback)(e=>d.current?.getExpandedText(e)??e,[]),m=(0,Y.useCallback)(()=>{},[]),h=(0,Y.useRef)(``),g=(0,Y.useRef)(``),_=(0,Y.useMemo)(()=>e.filter(e=>e.value!==`input`),[e]),v=s,y=(0,Y.useRef)(a);y.current=a;let b=(0,Y.useRef)(_.length);b.current=_.length;let x=(0,Y.useRef)(v);x.current=v;let S=(0,Y.useRef)(l);S.current=l;let C=(0,Y.useRef)(t);C.current=t;let w=(0,Y.useRef)(r);w.current=r;let T=(0,Y.useRef)(_);T.current=_;let E=(0,Y.useCallback)(()=>{let e=T.current[y.current];if(e)if(x.current){let t=d.current?.text?.trim();if(t){let n=p(t),r=e.value===`accept`?`accept`:`reject`;C.current({decision:r,userMessage:n,rules:e.rules}),m()}}else e.value!==`input`&&C.current({decision:e.value,rules:e.rules})},[p,m]),D=(0,Y.useRef)(E);D.current=E;let O=(0,Y.useCallback)(e=>{if(e.trim()){let t=T.current[y.current],n=p(e.trim()),r=t?.value===`accept`?`accept`:`reject`;C.current({decision:r,userMessage:n,rules:t?.rules}),m()}},[p,m]),k=(0,Y.useCallback)(e=>{if(e.key.upArrow||e.key.downArrow){let t=T.current[y.current],n=d.current?.text||``;t?.value===`accept`?h.current=n:t?.value===`reject`&&(g.current=n),c(!1),e.key.upArrow?o(e=>Math.max(0,e-1)):o(e=>Math.min(b.current-1,e+1)),e.preventDefault();return}if(e.key.tab){let t=T.current[y.current];t?.value===`accept`?h.current=``:t?.value===`reject`&&(g.current=``),m(),c(!1),e.preventDefault();return}if(e.key.escape){m(),c(!1),C.current({decision:`reject`}),e.preventDefault();return}},[m]),A=(0,Y.useCallback)(e=>{let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);t.length!==0&&T.current[y.current]&&(t.length===1?C.current({decision:`allowAlwaysWithRule`,rules:t}):C.current({decision:`allowAlwaysWithRules`,rules:t}),u(!1))},[]),j=(0,Y.useCallback)(e=>{if(e.key.escape){u(!1),e.preventDefault();return}},[]);BB((0,Y.useCallback)((e,t)=>{if(!x.current&&!S.current){if(t.upArrow){o(e=>Math.max(0,e-1));return}if(t.downArrow){o(e=>Math.min(b.current-1,e+1));return}if(t.escape){C.current({decision:`reject`});return}if(t.tab&&t.shift){if(w.current){w.current();return}let e=T.current.findIndex(e=>e.value===`allowAlways`);e!==-1&&(o(e),setTimeout(()=>{C.current({decision:`allowAlways`})},0));return}if(t.tab){let e=T.current[y.current];if(e&&(e.value===`accept`||e.value===`reject`)){c(!0);let t=e.value===`accept`?h.current:g.current;setTimeout(()=>{d.current&&t&&d.current.setText(t)},0)}return}if(e===`e`||e===`E`){let e=T.current[y.current];if(e?.rules?.length){u(!0),setTimeout(()=>{f.current?.setText(e.rules.join(`, `))},0);return}}if(t.return){D.current();return}}},[]),{isActive:!0}),(0,Y.useEffect)(()=>{let e=_[a];e&&(e.value!==`accept`&&e.value!==`reject`||(e.value===`accept`?h.current:g.current)&&!s&&c(!0))},[a,_,s]);let M=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{s&&(M.current=!0)},[s]),(0,Y.useEffect)(()=>{if(!s||!M.current)return;let e=_[a];if(!e)return;let t=e.value===`accept`?h.current:e.value===`reject`?g.current:``;t?setTimeout(()=>{d.current&&d.current.text===``&&d.current.setText(t),M.current=!1},0):M.current=!1},[s,a,_]);let N=_[a],P=s&&N,ee=e=>e.value===`accept`?`Yes, `:e.value===`reject`?`No, `:``,F=!s&&!l&&N&&(N.value===`accept`||N.value===`reject`),te=!s&&!l&&!!N?.rules?.length,I=_.some(e=>e.value===`allowAlways`||e.value===`allowAlwaysWithRule`);return(0,J.jsxs)(X,{flexDirection:`column`,children:[_.map((e,t)=>{let r=t===a,i=P&&r,o=e.value===`accept`?h.current:e.value===`reject`?g.current:``;return(0,J.jsx)(T9,{option:!i&&o?{...e,label:`${e.label}, ${o}`}:e,index:t,isSelected:r,showAsInput:i,showAsEdit:l&&r,editBufferRef:f,onEditSubmit:A,onEditKeyDown:j,inputPrefix:ee(e),inputPlaceholder:n,inputBufferRef:d,onInputSubmit:O,onInputKeyDown:k},t)}),(0,J.jsx)(X,{flexDirection:`row`,marginTop:1,gap:2,children:l?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{dimColor:!0,children:`enter confirm`}),(0,J.jsx)(Z,{dimColor:!0,children:`esc cancel`})]}):s?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{dimColor:!0,children:`enter submit`}),(0,J.jsx)(Z,{dimColor:!0,children:`tab discard note`}),(0,J.jsx)(Z,{dimColor:!0,children:`esc reject`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{dimColor:!0,children:`↑↓ navigate`}),(0,J.jsx)(Z,{dimColor:!0,children:`enter select`}),F&&(0,J.jsx)(Z,{dimColor:!0,children:`tab add note`}),te&&(0,J.jsx)(Z,{dimColor:!0,children:`e edit rule`}),i&&(0,J.jsxs)(Z,{dimColor:!0,children:[`shift+tab `,i]}),!i&&I&&(0,J.jsx)(Z,{dimColor:!0,children:`shift+tab don't ask again`}),(0,J.jsx)(Z,{dimColor:!0,children:`esc reject`})]})})]})});E9.displayName=`PermissionOptions`;function D9(e){return e.decision===`accept`&&e.userMessage?{type:`accept_with_message`,message:e.userMessage}:e.decision===`reject`&&e.userMessage?{type:`reject_with_message`,message:e.userMessage}:e.decision===`allowAlwaysWithRule`?e.rules?.length?{type:`allow_always_with_rule`,rule:e.rules[0]}:`accept`:e.decision===`allowAlwaysWithRules`?e.rules?.length?{type:`allow_always_with_rules`,rules:e.rules}:`accept`:e.decision}const O9=(0,Y.memo)(({filePath:e,originalContent:t,newContent:n,diffShownInEditor:r,onResolve:i})=>{let a=!t,{agentMode:o}=y1(),s=[{label:`Yes, apply changes`,value:`accept`},...o===Xd.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}],c=e=>{i(D9(e))};return r?(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`${a?`Create`:`Update`} file ${e}`,subtitle:`Opened changes in the editor`}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:s,onSelect:c,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]}):(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`${a?`Create`:`Update`} file ${e}`}),a?I0(e)?(0,J.jsx)(H0,{content:n,maxLinesPerCell:100}):(0,J.jsx)(Q$,{filePath:e,content:n,maxLines:100}):I0(e)?(0,J.jsx)(z0,{filePath:e,originalContent:t,newContent:n}):(0,J.jsx)(O0,{filePath:e,originalContent:t,newContent:n,paddingLeft:1}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:s,onSelect:c,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});O9.displayName=`EditFilePermissionUI`;const k9=(0,Y.memo)(({filePath:e,originalContent:t,content:n,isNewFile:r,diffShownInEditor:i,onResolve:a})=>{let{agentMode:o}=y1(),s=[{label:`Yes, apply changes`,value:`accept`},...o===Xd.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}],c=e=>{a(D9(e))};return i?(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`${r?`Create`:`Update`} file ${e}`,subtitle:`Opened changes in the editor`}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:s,onSelect:c,onModeSwitch:()=>a(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]}):(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`${r?`Create`:`Update`} file ${e}`}),r?I0(e)?(0,J.jsx)(H0,{content:n,maxLinesPerCell:100}):(0,J.jsx)(Q$,{filePath:e,content:n,maxLines:100}):I0(e)?(0,J.jsx)(z0,{filePath:e,originalContent:t,newContent:n}):(0,J.jsx)(O0,{filePath:e,originalContent:t,newContent:n,paddingLeft:1}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:s,onSelect:c,onModeSwitch:()=>a(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});k9.displayName=`WriteFilePermissionUI`;const A9=(0,Y.memo)(({description:e,url:t,displayName:n,onResolve:r})=>{let i=[{label:`Yes, allow action`,value:`accept`},{label:`Yes, and always allow ${n}`,value:`allowAlwaysWithRule`,rules:[n]},{label:`No, deny action`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Browser action: ${e}`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{children:e}),t&&(0,J.jsxs)(Z,{dimColor:!0,children:[`URL: `,t]})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:i,onSelect:e=>{r(D9(e))}})})]})});A9.displayName=`BrowserActionPermissionUI`;const j9=(0,Y.memo)(({command:e,background:t,unmatchedPatterns:n,onResolve:r})=>{let i=(0,Y.useMemo)(()=>U$(),[]),a=Kw(e),o=(0,Y.useMemo)(()=>{let e=[{label:`Yes, run command`,value:`accept`}];if(n.length>1){e.push({label:`Yes, and always allow all: ${n.map(e=>`Bash(${e})`).join(`, `)}`,value:`allowAlwaysWithRules`,rules:n.map(e=>`Bash(${e})`)});for(let t of n)e.push({label:`Yes, and always allow Bash(${t})`,value:`allowAlwaysWithRule`,rules:[`Bash(${t})`]})}else n.length===1?e.push({label:`Yes, and always allow Bash(${n[0]})`,value:`allowAlwaysWithRule`,rules:[`Bash(${n[0]})`]}):e.push({label:`Yes, and always allow Bash(${a})`,value:`allowAlwaysWithRule`,rules:[`Bash(${a})`]});return e.push({label:`No, skip command`,value:`reject`}),e},[n,a]);return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Bash command`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{children:(0,V$.supportsLanguage)(`bash`)?(()=>{try{return(0,V$.highlight)(e,{language:`bash`,theme:i})}catch{return e}})():e}),t&&(0,J.jsx)(X,{paddingTop:1,children:(0,J.jsx)(Z,{dimColor:!0,children:`(Running in background)`})})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:o,onSelect:e=>{r(D9(e))},inputPlaceholder:`Type here to tell AbacusAI what to do differently`,onModeSwitch:()=>r(`allowAlways`),modeSwitchHint:`allow all tools`})})]})});j9.displayName=`RunTerminalPermissionUI`;const M9=(0,Y.memo)(({title:e,description:t,toolName:n,onResolve:r})=>{let i=(0,Y.useMemo)(()=>U$(),[]),a=[{label:`Yes, allow`,value:`accept`},...n?[{label:`Yes, and always allow ${n}`,value:`allowAlwaysWithRule`,rules:[n]}]:[],{label:`No, deny`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:e}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,J.jsx)(Z,{children:(0,V$.supportsLanguage)(`json`)?(()=>{try{return(0,V$.highlight)(t,{language:`json`,theme:i})}catch{return t}})():t})}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:a,onSelect:e=>{r(D9(e))}})})]})});M9.displayName=`GenericPermissionUI`;const N9=(0,Y.memo)(({planFilePath:e,planContent:t,onResolve:n})=>(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Ready to code? Implement plan: ${e.length>60?`…${e.slice(-60)}`:e}`}),t&&(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{dimColor:!0,children:`Here is Abacus's plan:`}),(0,J.jsx)(o9,{children:t})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:[{label:`Yes, implement the plan (approve each edit)`,value:`accept`},{label:`Yes, implement the plan (auto-accept all edits)`,value:`allowAlways`,hint:`shift+tab`},{label:`No, keep planning`,value:`reject`}],onSelect:e=>{n(D9(e))},inputPlaceholder:`Add instructions for the implementation`})})]}));N9.displayName=`ExitPlanModePermissionUI`;const P9=(0,Y.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow read`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny read`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Read file outside workspace`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{children:e}),(0,J.jsxs)(Z,{dimColor:!0,children:[`Directory: `,t]})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:r,onSelect:e=>{n(D9(e))}})})]})});P9.displayName=`ReadOutsideDirectoryPermissionUI`;const F9=(0,Y.memo)(({filePath:e,deducedDirectory:t,isNewFile:n,onResolve:r})=>{let i=[{label:`Yes, allow write`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny write`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`${n?`Create`:`Write`} file outside workspace`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{children:e}),(0,J.jsxs)(Z,{dimColor:!0,children:[`Directory: `,t]})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:i,onSelect:e=>{r(D9(e))}})})]})});F9.displayName=`WriteOutsideDirectoryPermissionUI`;const I9=(0,Y.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow edit`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny edit`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Edit file outside workspace`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{children:e}),(0,J.jsxs)(Z,{dimColor:!0,children:[`Directory: `,t]})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:r,onSelect:e=>{n(D9(e))}})})]})});I9.displayName=`EditOutsideDirectoryPermissionUI`;const L9=(0,Y.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow notebook edit`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny notebook edit`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Edit notebook outside workspace`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,J.jsx)(Z,{children:e}),(0,J.jsxs)(Z,{dimColor:!0,children:[`Directory: `,t]})]}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:r,onSelect:e=>{n(D9(e))}})})]})});L9.displayName=`NotebookEditOutsideDirectoryPermissionUI`;const R9=(0,Y.memo)(({notebookPath:e,cellId:t,editMode:n,cellType:r,originalContent:i,newContent:a,onResolve:o})=>{let s=n??`replace`,c=``;c=s===`delete`?`Delete cell${t?` ${t}`:``}`:s===`insert`?`Insert new cell${t?` after ${t}`:` at beginning`} (${r??`code`})`:`Replace cell contents for cell ${t??`unknown`}`;let{agentMode:l}=y1(),u=[{label:`Yes, apply changes`,value:`accept`},...l===Xd.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}];return(0,J.jsxs)(X,{flexDirection:`column`,children:[(0,J.jsx)(u8,{title:`Edit notebook`}),(0,J.jsxs)(X,{flexDirection:`column`,paddingLeft:1,children:[(0,J.jsx)(Z,{dimColor:!0,children:e}),(0,J.jsx)(Z,{dimColor:!0,children:c})]}),s===`delete`?(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,J.jsx)(Z,{color:`red`,children:`Cell will be deleted`})}):s===`insert`||!i?(0,J.jsx)(O0,{filePath:P0(r===`markdown`?`markdown`:`python`),originalContent:``,newContent:a,showHeader:!1,paddingLeft:1}):(0,J.jsx)(R0,{cellIndex:0,cellType:r??`code`,cellId:t,language:r===`markdown`?`markdown`:`python`,originalSource:i,newSource:a,status:`modified`}),(0,J.jsx)(X,{borderStyle:l8,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,J.jsx)(X,{flexDirection:`column`,paddingLeft:1,children:(0,J.jsx)(E9,{options:u,onSelect:e=>{o(D9(e))},onModeSwitch:()=>o(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});R9.displayName=`NotebookEditPermissionUI`;const z9=(0,Y.memo)(({pendingTool:e})=>{let{request:t,resolve:n}=e;switch(t.type){case`edit_file`:return(0,J.jsx)(O9,{filePath:t.filePath,originalContent:t.originalContent,newContent:t.newContent,diffShownInEditor:t.diffShownInEditor,onResolve:n});case`write_file`:return(0,J.jsx)(k9,{filePath:t.filePath,originalContent:t.originalContent,content:t.content,isNewFile:t.isNewFile,diffShownInEditor:t.diffShownInEditor,onResolve:n});case`run_terminal`:return(0,J.jsx)(j9,{command:t.command,background:t.background,unmatchedPatterns:t.unmatchedPatterns,onResolve:n});case`browser_action`:return(0,J.jsx)(A9,{description:t.description,url:t.url,displayName:t.displayName,onResolve:n});case`generic`:return(0,J.jsx)(M9,{title:`Tool: ${t.toolName}`,description:t.inputSummary,toolName:t.toolName,onResolve:n});case`read_outside_directory`:return(0,J.jsx)(P9,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`write_outside_directory`:return(0,J.jsx)(F9,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,isNewFile:t.isNewFile,onResolve:n});case`edit_outside_directory`:return(0,J.jsx)(I9,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`notebook_edit_outside_directory`:return(0,J.jsx)(L9,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`exit_plan_mode`:return(0,J.jsx)(N9,{planFilePath:t.planFilePath,planContent:t.planContent,onResolve:n});case`ask_user_question`:return(0,J.jsx)(w9,{questions:t.questions,onResolve:n});case`notebook_edit`:return(0,J.jsx)(R9,{notebookPath:t.notebookPath,cellId:t.cellId,editMode:t.editMode,cellType:t.cellType,originalContent:t.originalContent,newContent:t.newContent,onResolve:n});default:return null}});z9.displayName=`ToolPermissionUI`;function hue(e){let t=(0,Y.useRef)(!1),n=(0,Y.useRef)(e);(0,Y.useEffect)(()=>{n.current=e},[e]),(0,Y.useEffect)(()=>{let e=()=>{t.current||(t.current=!0,n.current())};return process.on(`exit`,e),process.on(`SIGINT`,e),process.on(`SIGTERM`,e),()=>{e(),process.off(`exit`,e),process.off(`SIGINT`,e),process.off(`SIGTERM`,e)}},[])}const B9=(0,Y.createContext)(null),V9=()=>{let e=(0,Y.use)(B9);if(!e)throw Error(`${V9.name} must be used within a ${H9.name}`);return e};function H9({children:e}){let t=(0,Y.useCallback)(e=>{let t=e.split(``).filter(e=>{let t=e.codePointAt(0);return!(t<=31||t===127)}).join(``);process.stdout.write(JB(t))},[]);hue(()=>{process.stdout.write(JB(``))});let n=(0,Y.useMemo)(()=>({setTitle:t}),[t]);return(0,J.jsx)(B9.Provider,{value:n,children:e})}const U9=2e3;function W9(e,t,n){return e===Zd.ExecutingTool?`tool-executing`:e===Zd.Submitted||e===Zd.Streaming?`streaming`:e===Zd.WaitingForToolPermission&&t?`permission-ui`:n()?`idle-with-text`:`idle-empty`}function gue(e){let{agentStatus:t,hasPendingPermission:n,isExpandedView:r,composerHasText:i,hasQueuedMessages:a,stopAgent:o,rejectPermission:s,saveAndClearComposer:c,clearComposer:l,dequeueOne:u,clearQueue:d,exitApp:f}=e,[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(null),_=(0,Y.useRef)(null),v=(0,Y.useRef)(null),y=(0,Y.useCallback)(()=>{m(!1),_.current&&=(clearTimeout(_.current),null)},[]),b=(0,Y.useCallback)(()=>{g(null),v.current&&=(clearTimeout(v.current),null)},[]),x=(0,Y.useCallback)(()=>{y(),b()},[y,b]),S=W9(t,n,i),C=(0,Y.useRef)(S);return(0,Y.useEffect)(()=>{let e=C.current;C.current=S,e!==S&&x()},[S,x]),BB((0,Y.useEffectEvent)((e,S)=>{if(S.ctrl&&e===`z`){process.platform!==`win32`&&process.kill(process.pid,`SIGTSTP`);return}let C=S.escape,w=S.ctrl&&e===`c`,T=S.ctrl&&e===`d`;if(!C&&!w&&!T||C&&r)return;let E=W9(t,n,i);if(E===`tool-executing`||E===`streaming`){x(),o();return}if(E===`permission-ui`){x(),s();return}if(E===`idle-with-text`){if(C){p?(l(),x()):(b(),m(!0),_.current=setTimeout(()=>{m(!1),_.current=null},U9));return}let e=w?`c`:`d`;if(h===e){x(),f();return}if(h!==null){b(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},U9);return}y(),c(),a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},U9);return}if(E===`idle-empty`){if(C){a()&&u();return}let e=w?`c`:`d`;if(h===e){x(),f();return}if(h!==null){b(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},U9);return}a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},U9)}}),{isActive:!0}),(0,Y.useEffect)(()=>()=>{_.current&&clearTimeout(_.current),v.current&&clearTimeout(v.current)},[]),{escClear:p,exitKey:h}}const _ue={todos:[],completed:0,inProgress:0,pending:0,total:0};function vue(e){let t=e.toolUseRequest;if(!t)return null;let n;if(Array.isArray(t)){for(let e=t.length-1;e>=0;e--){let r=t[e];if(r&&r.name===`todo_write`){n=r;break}}if(!n)return null}else if(n=t,n.name!==`todo_write`)return null;let r=n.input;if(!r)return null;let i=r.todos;if(typeof i==`string`)try{i=JSON.parse(i)}catch{return null}return Array.isArray(i)?i.filter(e=>typeof e==`object`&&!!e&&typeof e.content==`string`&&typeof e.status==`string`).map((e,t)=>({id:e.id??`todo-${t}`,content:e.content,status:e.status})):null}function yue(e){return(0,Y.useMemo)(()=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`code_llm_tool_call`&&n.type!==`code_llm_agent_tool_request`)continue;let r=vue(n);if(!r)continue;let i=r.filter(e=>e.status!==`cancelled`);return{todos:i,completed:i.filter(e=>e.status===`completed`).length,inProgress:i.filter(e=>e.status===`in_progress`).length,pending:i.filter(e=>e.status===`pending`).length,total:i.length}}return _ue},[e])}function G9(e){return e.type===`code_llm_tool_call`||e.type===`code_llm_agent_tool_request`}function bue(e){let t=e.toolUseResult;return!!(t?.rejected||t?.content?.startsWith(`Error:`))}function xue(e){if(e.type!==`code_llm_notification`)return!1;let t=(e.message??``).toLowerCase();return t.includes(`compacting conversation`)||t.includes(`compacted conversation`)}function Sue(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 Cue(e,t){return{toolUses:e.toolUses+t.toolUses,responses:e.responses+t.responses}}function wue(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(xue(o)){let e=Sue(n);t=Cue(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=Tue(n);return a.push(...o),a}function Tue(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(G9(r)&&x9.has(K9(r))){let i=[r],a=n+1;for(;a<e.length;){let t=e[a];if(t.type===`thinking`){a++;continue}if(bue(i[i.length-1]))break;if(G9(t)&&x9.has(K9(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 K9(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function Eue(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 Due({timing:e}){let{setTitle:t}=V9(),{segments:n,agentStatus:r,pendingToolPermission:i,conversationTitle:a,conversationId:o,addNotification:s,stop:c,rejectPendingPermission:l,removeFirstFromQueue:u,clearQueue:d,totalCredits:f}=d6(),p=(0,Y.useRef)(null),{authExpired:m,clearAuthExpired:h}=o6();(0,Y.useEffect)(()=>{m&&(s(`Session expired — use /login to authenticate again.`,`error`),h())},[m,s,h]);let[g,_]=(0,Y.useState)(!1);BB((e,t)=>{(t.ctrl||t.super)&&e===`o`&&_(e=>!e)});let v=yue(n),{lastItem:y,prevItems:b}=(0,Y.useMemo)(()=>{let e=wue(n.filter(e=>!e.temp&&!e.isSpinny));return{lastItem:e.at(-1)??null,prevItems:e.slice(0,-1)}},[n]),{thinkingStartTime:x,thinkingEndTime:S}=(0,Y.useMemo)(()=>Eue(n),[n]),C=(0,Y.useRef)(Zd.Idle),[w,T]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let e=C.current===Zd.Idle,t=r!==Zd.Idle&&r!==Zd.WaitingForToolPermission;e&&t?T(Date.now()):r===Zd.Idle&&T(null),C.current=r},[r]);let E=r===Zd.WaitingForToolPermission&&i!==null,[D,O]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(`0`),[j,M]=(0,Y.useState)(0);(0,Y.useEffect)(()=>{t(a?`${a} • Abacus.AI CLI`:`Abacus.AI CLI`)},[a,t]),(0,Y.useEffect)(()=>EV(async()=>{let t=e.getFormattedDuration();M(f),A(t),O(!0),await new Promise(e=>setTimeout(e,100))},{wait:2e3,streams:[process.stdout,process.stderr]}),[e,f]);let N=gue({agentStatus:r,hasPendingPermission:i!==null,isExpandedView:g,composerHasText:()=>p.current?.hasText()??!1,hasQueuedMessages:()=>p.current?.hasQueue()??!1,stopAgent:c,rejectPermission:l,saveAndClearComposer:()=>p.current?.saveAndClear(),clearComposer:()=>p.current?.clear(),dequeueOne:u,clearQueue:d,exitApp:()=>DV(0)}),P=r!==Zd.Idle&&r!==Zd.WaitingForToolPermission,ee=i?.request.tool.id??null;return(0,J.jsx)(O1.Provider,{value:g,children:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(X,{flexDirection:`column`,gap:1,paddingBottom:1,width:`95%`,children:[(0,J.jsx)(R5,{}),(0,J.jsxs)(W$.Provider,{value:ee,children:[b.map(e=>e.kind===`compacted`?(0,J.jsx)(g6,{counts:e.counts,segments:e.segments},e.id):e.kind===`segment`?(0,J.jsx)(_9,{segment:e.segment},e.segment.id):g?e.segments.map(e=>(0,J.jsx)(_9,{segment:e},e.id)):(0,J.jsx)(C9,{segments:e.segments},e.id)),y&&(y.kind===`compacted`?(0,J.jsx)(g6,{counts:y.counts,segments:y.segments},y.id):y.kind===`segment`?(0,J.jsx)(_9,{segment:y.segment},y.segment.id):g?y.segments.map(e=>(0,J.jsx)(_9,{segment:e},e.id)):(0,J.jsx)(C9,{segments:y.segments},y.id))]}),[`1`,`true`,`yes`].includes((process.env[`${sn.internalEnvPrefix}TODO_TOOL_UI`]??``).trim().toLowerCase())&&(0,J.jsx)(b9,{state:v}),P&&(0,J.jsx)(J8,{onError:e=>{process.stderr.write(`[status-indicator error] ${e.stack??e.message}\n`)},children:(0,J.jsx)(cue,{status:r,thinkingStartTime:x,thinkingEndTime:S,runStartTime:w})})]}),D?(0,J.jsx)(Y8,{duration:k,credits:j,conversationId:o}):(0,J.jsxs)(J.Fragment,{children:[E&&(0,J.jsx)(J8,{onError:e=>{process.stderr.write(`[tool-permission error] ${e.stack??e.message}\n`)},children:(0,J.jsx)(z9,{pendingTool:i})}),(0,J.jsx)(Y.Activity,{mode:E?`hidden`:`visible`,children:(0,J.jsx)(J8,{fallback:e=>(0,J.jsxs)(X,{flexDirection:`column`,paddingX:1,children:[(0,J.jsx)(Z,{color:`red`,bold:!0,children:`Something went wrong in the input area.`}),(0,J.jsx)(Z,{color:`yellow`,children:e.message}),(0,J.jsxs)(Z,{dimColor:!0,children:[`Press Escape to restart the CLI, or resume with: `,sn.binName,` -c`,` `,o]})]}),onError:e=>{process.stderr.write(`[composer error] ${e.stack??e.message}\n`)},children:(0,J.jsx)(q8,{hints:N,composerRef:p})})})]})]})})}async function Oue({apiClient:e,authManager:t,configService:n,agentArgs:r}){let i,a=r?.[`permission-mode`];if(a)switch(a){case`yolo`:i=Xd.Yolo;break;case`accept-edits`:i=Xd.AcceptEdits;break;case`plan`:i=Xd.PlanMode;break;default:i=Xd.Normal;break}else r?.[`dangerously-skip-permissions`]?i=Xd.Yolo:r?.[`auto-accept-edits`]?i=Xd.AcceptEdits:r?.[`plan-mode`]&&(i=Xd.PlanMode);await Tz();let o=process.stdout,s=e=>{o&&o.writable&&o.write(e)},c=()=>s(gB),l=()=>s(hB),u=!1;for(;;){u=!1;let a=new kW,o=new Hoe,s=null,d=()=>{u=!0,s?.unmount()};c();let f=IB((0,J.jsx)(s6,{client:e,authManager:t,onAuthExpired:d,children:(0,J.jsx)(MW,{client:a,children:(0,J.jsx)(b6,{children:(0,J.jsx)(H9,{children:(0,J.jsx)(Pae,{children:(0,J.jsx)(ooe,{configService:n,children:(0,J.jsx)(jae,{children:(0,J.jsx)(S1,{initialMode:i,children:(0,J.jsx)(Mae,{children:(0,J.jsx)(u6,{apiClient:e,configService:n,agentArgs:r,children:(0,J.jsx)(Due,{timing:o})})})})})})})})})})}),{exitOnCtrlC:!1,suspendable:!0,onSuspended:()=>{process.stderr.write(`
|
|
73682
73682
|
Abacus.AI has been suspended. Run \`fg\` to bring Abacus back.
|
|
73683
73683
|
`)}});s=f;let p=!1,m=()=>{p||(p=!0,l())},h=()=>{p||(p=!0,f.cleanupTerminal())};if(process.once(`exit`,h),await f.waitUntilExit(),process.off(`exit`,h),m(),!u||!(await mU({authManager:t,apiClient:e,reason:`expired`,version:(await Promise.resolve().then(()=>Ge(YB()))).default.version})).success)break}}const kue=rt([`codellm`,`cli`,`auth`]);async function Aue(e){let t=await PF.create(),n=new kl(t,mn()),r=new fP({cwd:process.cwd(),extraSources:[{read:async()=>({client:`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{kue.error`Invalid base URL: ${i}`,process.exit(1)}let a=!0;switch(e){case`login`:await jue(t,n);break;case`logout`:a=await Mue(t);break;case`status`:await Nue(t,n);break;case`switch`:a=await Pue(t,n);break}process.exit(a?0:1)}async function jue(e,t){if(e.isEnvAuth()){cU.warn(`Currently authenticated via environment variable. Login is not needed.`);return}if(e.isAuthenticated()){let n=(await t.getUserInfo().catch(()=>null))?.result?.email;n&&cU.info(`Already logged in as ${tB().bold().render(n)}`);let r=await nU({message:`Do you want to log in with a different account?`});if(mH(r)||!r)return;await e.logout()}await mU({authManager:e,apiClient:t,reason:`welcome`,version:XB.default.version})}async function Mue(e){return e.isEnvAuth()?(cU.warn(`Currently authenticated via environment variable. Unset the environment variable to log out.`),!0):e.isAuthenticated()?await e.logout()?(cU.success(`Logged out successfully.`),!0):(cU.error(`Failed to log out.`),!1):(cU.info(`Not currently logged in.`),!0)}async function Nue(e,t){let n=e.getAuthKind();if(n.type===`logged_out`){console.log(nB(`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(tB().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(tB().dim().render(` (Could not fetch user details)`))}}async function Pue(e,t){if(!e.isAuthenticated())return cU.error("Not logged in. Run `auth login` first."),!1;let n=dU();n.start(`Fetching organizations...`);let r;try{let e=await t.listOrganizations();if(!e?.success||!e.result)return n.stop(`Failed to fetch organizations`),cU.error(`Could not retrieve organizations.`),!1;r=e.result,n.stop(`Organizations loaded`)}catch{return n.stop(`Failed`),cU.error(`Could not fetch organizations.`),!1}if(r.length===0)return cU.info(`No organizations available.`),!0;let i;try{i=(await t.getUserInfo())?.result?.organization?.organizationId}catch{}let a=await rU({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(mH(a))return aU(`Cancelled`),!0;if(a===i)return cU.info(`Already on this organization.`),!0;let o=dU();o.start(`Switching organization...`);try{if(await t.switchOrganization(a)){let e=r.find(e=>e.organizationId===a)?.name??a;return o.stop(`Done`),cU.success(`Switched to ${tB().bold().render(e)}`),!0}else return o.stop(`Failed`),cU.error(`Failed to switch organization.`),!1}catch{return o.stop(`Failed`),cU.error(`Failed to switch organization.`),!1}}async function q9(e){let{currentVersion:t,explicit:n=!1,autoUpdate:r=!0,updateChannel:i,baseUrl:a}=e;if(!n&&tV()||!n&&$B()||!n&&!r)return{action:`skipped`};let o;try{o=await sV(t,i,a)}catch{return n?(cU.error(`Failed to check for updates. Please check your network connection.`),{action:`exit`}):{action:`skipped`}}if(!o)return n&&cU.success(`Already up to date (${t})`),{action:`skipped`};let s=eV(),c=s?`Download v${o.latestVersion}`:lV(o);oU(`Update available: ${o.currentVersion} → ${o.latestVersion}`),s||iU(c,`Install command`);let l=await nU({message:`Would you like to update now?`,initialValue:!0});if(mH(l))return aU(`Update cancelled`),{action:`exit`};if(l){let e=dU();e.start(`Updating...`);let{ok:t,output:n}=s?await fV(o):dV(o);if(t)return e.stop(`Updated to ${o.latestVersion}`),n&&iU(n,`Install output`),sU(`Restarting...`),{action:`updated`,version:o.latestVersion};{e.stop(`Update failed`),n&&iU(n,`Error output`),cU.error(`Update failed. You can try manually running the command above.`);let t=await nU({message:`Continue using v${o.currentVersion}?`,initialValue:!0});return mH(t)||!t?(aU(`Exiting`),{action:`exit`}):(sU(`Continuing with v${o.currentVersion}`),{action:`continue`})}}let u=await nU({message:`Continue using v${o.currentVersion}?`,initialValue:!0});return mH(u)||!u?(aU(`Exiting`),{action:`exit`}):(sU(`Continuing with v${o.currentVersion}`),{action:`continue`})}function Fue(e,t){switch(e){case`bash`:return Lue(t);case`zsh`:return Rue(t);case`fish`:return zue(t);case`pwsh`:return Bue(t)}}function J9(){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 Iue(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=process.env.USERPROFILE??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 Y9=`# Abacus AI shell integration`;function Lue(e){return`\
|
|
73684
73684
|
${Y9}
|