@abacus-ai/cli 2.4.6-canary.5 → 2.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +1 -1
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -73324,7 +73324,7 @@ No matching component was found for:
73324
73324
  `).map(e=>tz(e,i)).join(`
73325
73325
  `):t===`truncate-start`&&(r=r.split(`
73326
73326
  `).map(e=>ez(e,i)).join(`
73327
- `))}}r=Qz(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&&$z(l,u,e,t),e.style.borderStyle&&Kz(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+Xz(e.style,`Left`):void 0,a=n?l+c.getComputedWidth()-Xz(e.style,`Right`):void 0,o=r?u+Xz(e.style,`Top`):void 0,s=r?u+c.getComputedHeight()-Xz(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+Xz(e.style,`Top`):o,r=f?u+c.getComputedHeight()-Xz(e.style,`Bottom`):s;for(let i of e.childNodes)eB(i,t,{offsetX:l,offsetY:u,transformers:d,clipY1:n,clipY2:r});f&&t.unclip()}e.renderDirty=!1};var tB=class{rootNode;lastWidth=0;cachedLines=null;output=new az(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),eB(this.rootNode,this.output,{});let r=this.output.get(),i=!1;for(let t of r)if(tI(t)>e){i=!0;break}return this.cachedLines=i?r.map(t=>tI(t)>e?lI(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)}},nB;(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`})(nB||={});const rB=`\x1B[?25h`,iB=`\x1B[?25l`;function aB(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 oB(e){return aB(99,e)}function sB(e){let t=e??Mz(),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 cB(e){return(e??Mz()).isTTY}function lB(e){let t=sB(e);return t===`windows-terminal`||t===`iterm2`||t===`wezterm`||t===`ghostty`}function uB(e){let t=sB(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 dB(e){let t=sB(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`contour`||t===`rio`||t===`vscode`||t===`windows-terminal`}function fB(e,...t){return`\x1B]8;`+(t.length>0?t.join(`:`):``)+`;`+e+`\x07`}function pB(...e){return fB(``,...e)}function mB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function hB(e){return`\x1B]9;`+mB(e)+`\x07`}function gB(e,...t){return`\x1B]99;`+t.map(mB).join(`:`)+`;`+mB(e)+`\x07`}function _B(e){return`\x1B]777;notify;;`+mB(e)+`\x07`}const vB=`\x1B]9;4;0\x07`;function yB(e){return`\x1B]9;4;1;`+Math.min(Math.max(0,e),100)+`\x07`}function bB(e){return`\x1B]9;4;2;`+Math.min(Math.max(0,e),100)+`\x07`}function xB(e){return`\x1B]9;4;4;`+Math.min(Math.max(0,e),100)+`\x07`}var SB=class{env;profile;terminalType;_isDark;_writer;_progressHideTimer=null;constructor(e){this.env=e?.env??Mz(),this.profile=Pz(this.env),Rz(this.profile),this.terminalType=sB(this.env),this._isDark=e?.isDark??mz(),this._writer=e?.writer??null,e?.isDark!==void 0&&hz(e.isDark)}get isDark(){return this._isDark}setDark(e){this._isDark=e,hz(e)}resolveAdaptiveColor(e){if(typeof e==`string`)return Az.parse(e);let t=this._isDark?e.dark:e.light;return Az.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 Uz(this.profile)}write(e){this._writer?this._writer(e):typeof process<`u`&&process.stdout?.isTTY&&process.stdout.write(e)}notify(e){if(!cB(this.env))return;let t=this.terminalType,{title:n,body:r}=e,i=n?`${n}:\n${r}`:r;t===`kitty`&&(n?this.write(gB(r,`d=0:p=title`,n)):this.write(gB(r))),this.write(_B(i)),this.write(hB(i))}showProgress(e){if(!lB(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(bB(n));break;case`warning`:this.write(xB(n));break;default:this.write(yB(n));break}(t===`error`||n>=100)&&this.scheduleProgressHide()}hideProgress(){this.clearProgressTimer(),lB(this.env)&&this.write(vB)}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){uB(this.env)&&this.write(oB(e))}clearClipboard(){uB(this.env)&&this.write(`\x1B]52;c;\x07`)}hyperlink(e,t){return dB(this.env)?fB(e)+t+pB():t}clearProgressTimer(){this._progressHideTimer&&=(clearTimeout(this._progressHideTimer),null)}scheduleProgressHide(){this.clearProgressTimer(),this._progressHideTimer=setTimeout(()=>{this.write(vB),this._progressHideTimer=null},500)}},CB=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 qI(this.terminal),this.ownsTui=!0):(this.terminal=new rL,this.tui=new qI(this.terminal),this.ownsTui=!0),this.terminalOutput=new SB({writer:e=>this.terminal.write(e)}),this.rootNode=jR(`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 tB(this.rootNode),this.tui.addChild(this.bridge),this.container=KR.createContainer(this.rootNode,0,null,!1,null,`jar`,()=>{},()=>{},()=>{},()=>{}),this.exitPromise=new Promise(e=>{this.resolveExit=e}),this.exitOnCtrlC&&this.tui.addInputListener(e=>{if(!DI(e)&&PI(e,`ctrl+c`))return this.exit(),{consume:!0}})}render(e){KR.updateContainerSync(e,this.container,null),KR.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&&=(W.removeListener(`warning`,this.warningInterceptor),void 0),this.originalWarningListeners){let e=W.listeners(`warning`);for(let t of this.originalWarningListeners)e.includes(t)||W.on(`warning`,t);this.originalWarningListeners=void 0}this.cleanupSuspend?.(),this.ownsTui&&this.disableInputProtocols(),KR.updateContainerSync(null,this.container,null),KR.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(),W.stdout.write(rB))}disableInputProtocols(){this.terminal.write(aL),this.terminal.write(`\x1B[?2004l`),this.terminal.kittyProtocolActive&&this.terminal.write(`\x1B[<u`)}setupWarningInterceptor(){this.originalWarningListeners||(this.originalWarningListeners=W.rawListeners(`warning`),W.removeAllListeners(`warning`),this.warningInterceptor=()=>{},W.on(`warning`,this.warningInterceptor))}setupSuspendHandler(){if(W.platform===`win32`||!this.ownsTui)return()=>{};let e=!1,t=()=>{e=this.terminal.kittyProtocolActive,W.stdout.isTTY&&(this.disableInputProtocols(),W.stdout.write(rB)),W.stdin.isTTY&&W.stdin.isRaw&&W.stdin.setRawMode(!1),this.onSuspended?.(),W.removeListener(`SIGTSTP`,t),W.kill(W.pid,`SIGTSTP`)},n=()=>{W.stdin.isTTY&&W.stdin.setRawMode(!0),W.stdout.isTTY&&(W.stdout.write(iB),this.terminal.write(`\x1B[?2004h`),this.terminal.write(iL),e&&this.terminal.write(`\x1B[>7u`)),W.on(`SIGTSTP`,t),this.tui.requestRender(!0)};return W.on(`SIGTSTP`,t),W.on(`SIGCONT`,n),()=>{W.removeListener(`SIGTSTP`,t),W.removeListener(`SIGCONT`,n)}}waitUntilExit(){return this.exitPromise}getRootNode(){return this.rootNode}};function wB(e,t){let n=new CB(t),r=Y.createElement(QR,{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(QR,{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=Uz().dim().render(c)),e&&(c=Vz(c,e,`foreground`)),t&&(c=Vz(c,t,`background`)),r&&(c=Uz().bold().render(c)),i&&(c=Uz().italic().render(c)),a&&(c=Uz().underline().render(c)),o&&(c=Uz().strikethrough().render(c)),s&&(c=Uz().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 TB=/\x1b\[[\d:]*;(\d+)/;function EB(e){let t=TB.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const DB={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:``},OB=(e,t={})=>{let{addInputListener:n}=(0,Y.use)(YR),r=(0,Y.useRef)(e);r.current=e,(0,Y.useEffect)(()=>{if(t.isActive!==!1)return n(e=>{if(DI(e))return;if(e.startsWith(`\x1B[200~`)){let t=e.indexOf(`\x1B[201~`),n=t===-1?e.slice(6):e.slice(6,t);DB.upArrow=!1,DB.downArrow=!1,DB.leftArrow=!1,DB.rightArrow=!1,DB.pageDown=!1,DB.pageUp=!1,DB.home=!1,DB.end=!1,DB.return=!1,DB.escape=!1,DB.ctrl=!1,DB.shift=!1,DB.tab=!1,DB.backspace=!1,DB.delete=!1,DB.meta=!1,DB.super=!1,DB.paste=!0,DB.raw=e,r.current(n,{...DB});return}let t=FI(e),n=t?t.split(`+`):[],i=n[n.length-1]??``,a=n.includes(`ctrl`),o=n.includes(`shift`),s=n.includes(`alt`);DB.upArrow=i===`up`,DB.downArrow=i===`down`,DB.leftArrow=i===`left`,DB.rightArrow=i===`right`,DB.pageDown=i===`pagedown`,DB.pageUp=i===`pageup`,DB.home=i===`home`,DB.end=i===`end`,DB.return=i===`return`||i===`enter`,DB.escape=i===`escape`,DB.ctrl=a,DB.shift=o,DB.tab=i===`tab`,DB.backspace=i===`backspace`,DB.delete=i===`delete`,DB.meta=s,DB.super=EB(e),DB.paste=!1,DB.raw=e;let c=DB,l=``;if(a&&i)l=i;else if(!c.upArrow&&!c.downArrow&&!c.leftArrow&&!c.rightArrow&&!c.pageDown&&!c.pageUp&&!c.home&&!c.end&&!c.return&&!c.escape&&!c.tab&&!c.backspace&&!c.delete){let t=RI(e);t===void 0?e.length===1?l=e:i.length===1&&(l=i):l=t}r.current(l,{...c})})},[t.isActive,n])},kB=({isActive:e=!0,autoFocus:t=!1,id:n}={})=>{let{activeId:r,add:i,remove:a,activate:o,deactivate:s,focus:c}=(0,Y.use)(qR),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 AB(){return(0,Y.use)(JR)}const jB=()=>{let e=(0,Y.use)(ZR);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},MB=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function NB(){return new RegExp(MB.source,`g`)}function PB(e){return e.replace(MB,``)}function FB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function IB(e){return`\x1B]2;`+FB(e)+`\x07`}var LB=G(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.4.6-canary.5`,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`}}})),RB=We(LB(),1);let zB=null;function BB(e){let t=(0,iF.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function VB(e){if(!e)return``;try{return v(e)}catch{return e}}function HB(){return{invokedPath:VB(process.argv[1]??``),execPath:VB(process.execPath??process.argv[0]??``)}}function UB(e){let t=sn.configDirName.replace(/^\./,``).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`[/\\\\]\\.?${t}[/\\\\]bin[/\\\\]`,`i`).test(e)}function WB(e){return/[/\\]node_modules[/\\]/.test(e)||/[/\\]\._npx[/\\]/.test(e)||/[/\\]_npx[/\\]/.test(e)||/[/\\]\.?npm[/\\]/.test(e)||/[/\\]\.?pnpm[/\\]/.test(e)||/[/\\]\.?yarn[/\\]/.test(e)||/[/\\]\.bun[/\\]/.test(e)}function GB(){let e=(process.env.npm_command??``).toLowerCase();if(e===`exec`||e===`dlx`)return!0;let{invokedPath:t,execPath:n}=HB();return/[/\\]_npx[/\\]|[/\\]dlx[/\\]|[/\\]\.cache[/\\]/.test(t+`|`+n)}function KB(){let e=process.env.npm_config_user_agent;if(e){let t=e.split(`/`)[0];if(t===`yarn`||t===`pnpm`||t===`bun`||t===`npm`)return t}let{invokedPath:t,execPath:n}=HB(),r=`${t}|${n}`;return/[/\\]\.?yarn[/\\]/.test(r)?`yarn`:/[/\\]\.?pnpm[/\\]/.test(r)?`pnpm`:/[/\\]\.bun[/\\]/.test(r)||process.versions.bun!==void 0&&!UB(n)?`bun`:`npm`}function qB(){let{execPath:e,invokedPath:t}=HB();return WB(t)||WB(e)?!1:UB(e)||UB(t)}function JB(){let e=`${sn.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let{invokedPath:n,execPath:r}=HB();return!(UB(r)||UB(n)||WB(n)||WB(r)||process.env.npm_config_user_agent)}function YB(){let{execPath:e}=HB(),t=KB(),n=GB();return JB()?{installationType:`development`,packageManager:t,isEphemeral:n,execPath:e}:qB()?{installationType:`native`,packageManager:t,isEphemeral:n,execPath:e}:{installationType:`package-manager`,packageManager:t,isEphemeral:n,execPath:e}}function XB(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}async function ZB(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 QB(e,t,n,r){let i=t??BB(e),a=(r??`https://apps.abacus.ai`).replace(/\/$/,``),o=new URL(`${a}/api/v0/_getCodellmCliVersion`);o.searchParams.set(`channel`,i),n&&o.searchParams.set(`platform`,n),o.searchParams.set(`cli_version`,e);let s=await fetch(o.toString(),{signal:AbortSignal.timeout(1e4)});if(s.status===204)return null;if(!s.ok)throw Error(`API returned ${s.status}`);let c=await s.json(),l=c&&`result`in c&&c.result?c.result:c??{};if(!l.version||!l.channel)throw Error(`API returned invalid payload`);return{currentVersion:e,latestVersion:l.version,tag:l.channel,packageManager:KB(),isEphemeral:GB(),installationType:`native`,downloadUrl:l.url}}async function $B(e,t){let n=t??BB(e),r=KB(),i=GB(),a=(await ZB(cn.publishName))[n];return!a&&n!==`latest`||!a||a===e?null:{currentVersion:e,latestVersion:a,tag:n,packageManager:r,isEphemeral:i,installationType:`package-manager`}}async function eV(e,t,n,r){let i=YB();if(i.installationType===`native`)try{return await QB(e,t,XB(),n)}catch{return null}return i.installationType===`development`&&!r?.includeDev?null:await $B(e,t)}function tV(e){if(e.installationType===`native`)return`${sn.binName} upgrade`;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 nV(e){try{return{ok:!0,output:se(tV(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 rV(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 ve.mkdir(t,{recursive:!0}),await ve.mkdir(n,{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 ve.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 ve.copyFile(c,l),r||await ve.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 ve.rm(t,{recursive:!0,force:!0}).catch(()=>{})}}function iV(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 aV(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
73327
+ `))}}r=Qz(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&&$z(l,u,e,t),e.style.borderStyle&&Kz(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+Xz(e.style,`Left`):void 0,a=n?l+c.getComputedWidth()-Xz(e.style,`Right`):void 0,o=r?u+Xz(e.style,`Top`):void 0,s=r?u+c.getComputedHeight()-Xz(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+Xz(e.style,`Top`):o,r=f?u+c.getComputedHeight()-Xz(e.style,`Bottom`):s;for(let i of e.childNodes)eB(i,t,{offsetX:l,offsetY:u,transformers:d,clipY1:n,clipY2:r});f&&t.unclip()}e.renderDirty=!1};var tB=class{rootNode;lastWidth=0;cachedLines=null;output=new az(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),eB(this.rootNode,this.output,{});let r=this.output.get(),i=!1;for(let t of r)if(tI(t)>e){i=!0;break}return this.cachedLines=i?r.map(t=>tI(t)>e?lI(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)}},nB;(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`})(nB||={});const rB=`\x1B[?25h`,iB=`\x1B[?25l`;function aB(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 oB(e){return aB(99,e)}function sB(e){let t=e??Mz(),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 cB(e){return(e??Mz()).isTTY}function lB(e){let t=sB(e);return t===`windows-terminal`||t===`iterm2`||t===`wezterm`||t===`ghostty`}function uB(e){let t=sB(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 dB(e){let t=sB(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`contour`||t===`rio`||t===`vscode`||t===`windows-terminal`}function fB(e,...t){return`\x1B]8;`+(t.length>0?t.join(`:`):``)+`;`+e+`\x07`}function pB(...e){return fB(``,...e)}function mB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function hB(e){return`\x1B]9;`+mB(e)+`\x07`}function gB(e,...t){return`\x1B]99;`+t.map(mB).join(`:`)+`;`+mB(e)+`\x07`}function _B(e){return`\x1B]777;notify;;`+mB(e)+`\x07`}const vB=`\x1B]9;4;0\x07`;function yB(e){return`\x1B]9;4;1;`+Math.min(Math.max(0,e),100)+`\x07`}function bB(e){return`\x1B]9;4;2;`+Math.min(Math.max(0,e),100)+`\x07`}function xB(e){return`\x1B]9;4;4;`+Math.min(Math.max(0,e),100)+`\x07`}var SB=class{env;profile;terminalType;_isDark;_writer;_progressHideTimer=null;constructor(e){this.env=e?.env??Mz(),this.profile=Pz(this.env),Rz(this.profile),this.terminalType=sB(this.env),this._isDark=e?.isDark??mz(),this._writer=e?.writer??null,e?.isDark!==void 0&&hz(e.isDark)}get isDark(){return this._isDark}setDark(e){this._isDark=e,hz(e)}resolveAdaptiveColor(e){if(typeof e==`string`)return Az.parse(e);let t=this._isDark?e.dark:e.light;return Az.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 Uz(this.profile)}write(e){this._writer?this._writer(e):typeof process<`u`&&process.stdout?.isTTY&&process.stdout.write(e)}notify(e){if(!cB(this.env))return;let t=this.terminalType,{title:n,body:r}=e,i=n?`${n}:\n${r}`:r;t===`kitty`&&(n?this.write(gB(r,`d=0:p=title`,n)):this.write(gB(r))),this.write(_B(i)),this.write(hB(i))}showProgress(e){if(!lB(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(bB(n));break;case`warning`:this.write(xB(n));break;default:this.write(yB(n));break}(t===`error`||n>=100)&&this.scheduleProgressHide()}hideProgress(){this.clearProgressTimer(),lB(this.env)&&this.write(vB)}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){uB(this.env)&&this.write(oB(e))}clearClipboard(){uB(this.env)&&this.write(`\x1B]52;c;\x07`)}hyperlink(e,t){return dB(this.env)?fB(e)+t+pB():t}clearProgressTimer(){this._progressHideTimer&&=(clearTimeout(this._progressHideTimer),null)}scheduleProgressHide(){this.clearProgressTimer(),this._progressHideTimer=setTimeout(()=>{this.write(vB),this._progressHideTimer=null},500)}},CB=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 qI(this.terminal),this.ownsTui=!0):(this.terminal=new rL,this.tui=new qI(this.terminal),this.ownsTui=!0),this.terminalOutput=new SB({writer:e=>this.terminal.write(e)}),this.rootNode=jR(`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 tB(this.rootNode),this.tui.addChild(this.bridge),this.container=KR.createContainer(this.rootNode,0,null,!1,null,`jar`,()=>{},()=>{},()=>{},()=>{}),this.exitPromise=new Promise(e=>{this.resolveExit=e}),this.exitOnCtrlC&&this.tui.addInputListener(e=>{if(!DI(e)&&PI(e,`ctrl+c`))return this.exit(),{consume:!0}})}render(e){KR.updateContainerSync(e,this.container,null),KR.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&&=(W.removeListener(`warning`,this.warningInterceptor),void 0),this.originalWarningListeners){let e=W.listeners(`warning`);for(let t of this.originalWarningListeners)e.includes(t)||W.on(`warning`,t);this.originalWarningListeners=void 0}this.cleanupSuspend?.(),this.ownsTui&&this.disableInputProtocols(),KR.updateContainerSync(null,this.container,null),KR.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(),W.stdout.write(rB))}disableInputProtocols(){this.terminal.write(aL),this.terminal.write(`\x1B[?2004l`),this.terminal.kittyProtocolActive&&this.terminal.write(`\x1B[<u`)}setupWarningInterceptor(){this.originalWarningListeners||(this.originalWarningListeners=W.rawListeners(`warning`),W.removeAllListeners(`warning`),this.warningInterceptor=()=>{},W.on(`warning`,this.warningInterceptor))}setupSuspendHandler(){if(W.platform===`win32`||!this.ownsTui)return()=>{};let e=!1,t=()=>{e=this.terminal.kittyProtocolActive,W.stdout.isTTY&&(this.disableInputProtocols(),W.stdout.write(rB)),W.stdin.isTTY&&W.stdin.isRaw&&W.stdin.setRawMode(!1),this.onSuspended?.(),W.removeListener(`SIGTSTP`,t),W.kill(W.pid,`SIGTSTP`)},n=()=>{W.stdin.isTTY&&W.stdin.setRawMode(!0),W.stdout.isTTY&&(W.stdout.write(iB),this.terminal.write(`\x1B[?2004h`),this.terminal.write(iL),e&&this.terminal.write(`\x1B[>7u`)),W.on(`SIGTSTP`,t),this.tui.requestRender(!0)};return W.on(`SIGTSTP`,t),W.on(`SIGCONT`,n),()=>{W.removeListener(`SIGTSTP`,t),W.removeListener(`SIGCONT`,n)}}waitUntilExit(){return this.exitPromise}getRootNode(){return this.rootNode}};function wB(e,t){let n=new CB(t),r=Y.createElement(QR,{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(QR,{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=Uz().dim().render(c)),e&&(c=Vz(c,e,`foreground`)),t&&(c=Vz(c,t,`background`)),r&&(c=Uz().bold().render(c)),i&&(c=Uz().italic().render(c)),a&&(c=Uz().underline().render(c)),o&&(c=Uz().strikethrough().render(c)),s&&(c=Uz().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 TB=/\x1b\[[\d:]*;(\d+)/;function EB(e){let t=TB.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const DB={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:``},OB=(e,t={})=>{let{addInputListener:n}=(0,Y.use)(YR),r=(0,Y.useRef)(e);r.current=e,(0,Y.useEffect)(()=>{if(t.isActive!==!1)return n(e=>{if(DI(e))return;if(e.startsWith(`\x1B[200~`)){let t=e.indexOf(`\x1B[201~`),n=t===-1?e.slice(6):e.slice(6,t);DB.upArrow=!1,DB.downArrow=!1,DB.leftArrow=!1,DB.rightArrow=!1,DB.pageDown=!1,DB.pageUp=!1,DB.home=!1,DB.end=!1,DB.return=!1,DB.escape=!1,DB.ctrl=!1,DB.shift=!1,DB.tab=!1,DB.backspace=!1,DB.delete=!1,DB.meta=!1,DB.super=!1,DB.paste=!0,DB.raw=e,r.current(n,{...DB});return}let t=FI(e),n=t?t.split(`+`):[],i=n[n.length-1]??``,a=n.includes(`ctrl`),o=n.includes(`shift`),s=n.includes(`alt`);DB.upArrow=i===`up`,DB.downArrow=i===`down`,DB.leftArrow=i===`left`,DB.rightArrow=i===`right`,DB.pageDown=i===`pagedown`,DB.pageUp=i===`pageup`,DB.home=i===`home`,DB.end=i===`end`,DB.return=i===`return`||i===`enter`,DB.escape=i===`escape`,DB.ctrl=a,DB.shift=o,DB.tab=i===`tab`,DB.backspace=i===`backspace`,DB.delete=i===`delete`,DB.meta=s,DB.super=EB(e),DB.paste=!1,DB.raw=e;let c=DB,l=``;if(a&&i)l=i;else if(!c.upArrow&&!c.downArrow&&!c.leftArrow&&!c.rightArrow&&!c.pageDown&&!c.pageUp&&!c.home&&!c.end&&!c.return&&!c.escape&&!c.tab&&!c.backspace&&!c.delete){let t=RI(e);t===void 0?e.length===1?l=e:i.length===1&&(l=i):l=t}r.current(l,{...c})})},[t.isActive,n])},kB=({isActive:e=!0,autoFocus:t=!1,id:n}={})=>{let{activeId:r,add:i,remove:a,activate:o,deactivate:s,focus:c}=(0,Y.use)(qR),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 AB(){return(0,Y.use)(JR)}const jB=()=>{let e=(0,Y.use)(ZR);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},MB=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function NB(){return new RegExp(MB.source,`g`)}function PB(e){return e.replace(MB,``)}function FB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function IB(e){return`\x1B]2;`+FB(e)+`\x07`}var LB=G(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.4.7`,private:!0,bin:{abacusai:`dist/index.mjs`},files:[`dist`,`LICENSE.txt`],type:`module`,scripts:{"prepare-publish":`bun ./scripts/prepare-publish.ts`,build:`tsdown`,"check-types":`tsgo -b --noEmit`,test:`FORCE_COLOR=1 vitest run`,"test:watch":`FORCE_COLOR=1 vitest`,"test:ui":`FORCE_COLOR=1 vitest --ui`,"test:coverage":`FORCE_COLOR=1 vitest run --coverage`},dependencies:{"@clack/prompts":`^0.11.0`,"@codellm/agent":`workspace:*`,"@codellm/api":`workspace:*`,"@codellm/auth":`workspace:*`,"@codellm/comms":`workspace:*`,"@codellm/jar":`workspace:*`,"@codellm/logging":`workspace:*`,"@codellm/product":`workspace:*`,"@logtape/logtape":`^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`}}})),RB=We(LB(),1);let zB=null;function BB(e){let t=(0,iF.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function VB(e){if(!e)return``;try{return v(e)}catch{return e}}function HB(){return{invokedPath:VB(process.argv[1]??``),execPath:VB(process.execPath??process.argv[0]??``)}}function UB(e){let t=sn.configDirName.replace(/^\./,``).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`[/\\\\]\\.?${t}[/\\\\]bin[/\\\\]`,`i`).test(e)}function WB(e){return/[/\\]node_modules[/\\]/.test(e)||/[/\\]\._npx[/\\]/.test(e)||/[/\\]_npx[/\\]/.test(e)||/[/\\]\.?npm[/\\]/.test(e)||/[/\\]\.?pnpm[/\\]/.test(e)||/[/\\]\.?yarn[/\\]/.test(e)||/[/\\]\.bun[/\\]/.test(e)}function GB(){let e=(process.env.npm_command??``).toLowerCase();if(e===`exec`||e===`dlx`)return!0;let{invokedPath:t,execPath:n}=HB();return/[/\\]_npx[/\\]|[/\\]dlx[/\\]|[/\\]\.cache[/\\]/.test(t+`|`+n)}function KB(){let e=process.env.npm_config_user_agent;if(e){let t=e.split(`/`)[0];if(t===`yarn`||t===`pnpm`||t===`bun`||t===`npm`)return t}let{invokedPath:t,execPath:n}=HB(),r=`${t}|${n}`;return/[/\\]\.?yarn[/\\]/.test(r)?`yarn`:/[/\\]\.?pnpm[/\\]/.test(r)?`pnpm`:/[/\\]\.bun[/\\]/.test(r)||process.versions.bun!==void 0&&!UB(n)?`bun`:`npm`}function qB(){let{execPath:e,invokedPath:t}=HB();return WB(t)||WB(e)?!1:UB(e)||UB(t)}function JB(){let e=`${sn.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let{invokedPath:n,execPath:r}=HB();return!(UB(r)||UB(n)||WB(n)||WB(r)||process.env.npm_config_user_agent)}function YB(){let{execPath:e}=HB(),t=KB(),n=GB();return JB()?{installationType:`development`,packageManager:t,isEphemeral:n,execPath:e}:qB()?{installationType:`native`,packageManager:t,isEphemeral:n,execPath:e}:{installationType:`package-manager`,packageManager:t,isEphemeral:n,execPath:e}}function XB(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}async function ZB(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 QB(e,t,n,r){let i=t??BB(e),a=(r??`https://apps.abacus.ai`).replace(/\/$/,``),o=new URL(`${a}/api/v0/_getCodellmCliVersion`);o.searchParams.set(`channel`,i),n&&o.searchParams.set(`platform`,n),o.searchParams.set(`cli_version`,e);let s=await fetch(o.toString(),{signal:AbortSignal.timeout(1e4)});if(s.status===204)return null;if(!s.ok)throw Error(`API returned ${s.status}`);let c=await s.json(),l=c&&`result`in c&&c.result?c.result:c??{};if(!l.version||!l.channel)throw Error(`API returned invalid payload`);return{currentVersion:e,latestVersion:l.version,tag:l.channel,packageManager:KB(),isEphemeral:GB(),installationType:`native`,downloadUrl:l.url}}async function $B(e,t){let n=t??BB(e),r=KB(),i=GB(),a=(await ZB(cn.publishName))[n];return!a&&n!==`latest`||!a||a===e?null:{currentVersion:e,latestVersion:a,tag:n,packageManager:r,isEphemeral:i,installationType:`package-manager`}}async function eV(e,t,n,r){let i=YB();if(i.installationType===`native`)try{return await QB(e,t,XB(),n)}catch{return null}return i.installationType===`development`&&!r?.includeDev?null:await $B(e,t)}function tV(e){if(e.installationType===`native`)return`${sn.binName} upgrade`;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 nV(e){try{return{ok:!0,output:se(tV(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 rV(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 ve.mkdir(t,{recursive:!0}),await ve.mkdir(n,{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 ve.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 ve.copyFile(c,l),r||await ve.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 ve.rm(t,{recursive:!0,force:!0}).catch(()=>{})}}function iV(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 aV(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
73328
73328
  `),process.exit(1)),t?iV(n,t.toLowerCase())||(process.stderr.write(`Warning: Model "${t}" not found. Using default: ${n[0].llmName}\n`),n[0].llmName):n[0].llmName}const oV=rt([`codellm`,`cli`,`exit`]),sV=new Set,cV=new Set,lV=new Set;let uV=!1,dV=!1,fV=null,pV;async function mV(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 hV(e,t,n,r){if(uV)return;r?.debug?.(`Executing exit handlers`,{shouldManuallyExit:e,isSynchronous:t,signal:n,asyncCallbacks:sV.size,syncCallbacks:cV.size}),uV=!0,sV.size>0&&t&&oV.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:pV===void 0?(typeof W.exitCode==`number`||typeof W.exitCode==`string`)&&(i=Number(W.exitCode)):i=pV;let a=(t=!1)=>{(t||e)&&(fV?fV.call(W,i):W.exit(i))};for(let e of cV)try{e(i)}catch(e){oV.error`Error in synchronous exit hook: ${e}`}if(t){a();return}let o=[],s=0;for(let[e,t]of sV)s=Math.max(s,t),o.push(Promise.resolve(e(i)).catch(e=>{oV.error`Error in asynchronous exit hook: ${e}`}));let c=Array.from(lV);c.length>0&&o.push(mV(c));let l=setTimeout(()=>{a(!0)},s);try{await Promise.all(o),clearTimeout(l),a()}catch(e){clearTimeout(l),oV.error`Error during exit cleanup: ${e}`,a(!0)}}function gV(){dV||(dV=!0,W.once(`beforeExit`,()=>{hV(!0,!1,-128)}),W.once(`SIGINT`,()=>{hV(!0,!1,2)}),W.once(`SIGTERM`,()=>{hV(!0,!1,15)}),W.once(`exit`,()=>{hV(!1,!0,0)}),W.on(`message`,e=>{e===`shutdown`&&hV(!0,!0,-128)}),fV||(fV=W.exit.bind(W),W.exit=function(e){if(pV===void 0&&(pV=e??0),sV.size===0&&lV.size===0){if(fV){fV(e??0);return}W.exit(e??0)}hV(!0,!1,-128).catch(e=>{oV.error`Error during exit: ${e}`,fV?fV(1):W.exit(1)})}))}function _V(e,t){if(typeof e!=`function`)throw TypeError(`callback must be a function`);if(uV)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}),gV();let n=t?.wait??0,r=t?.streams??[W.stdout,W.stderr];if(n>0){let t=[e,n];sV.add(t);for(let e of r)lV.add(e);return()=>{sV.delete(t);for(let e of r)lV.delete(e)}}return cV.add(e),()=>{cV.delete(e)}}function vV(e){e!==void 0&&(W.exitCode=e),hV(!0,!1,-128)}const yV=`${sn.internalEnvPrefix}CLIENT_KIND`;function bV(){let e=process.env[yV]?.trim();if(!e)return qe.CLI;try{return Je(e)}catch{throw Error(`Invalid ${yV} value: ${e}. Expected one of ${Object.values(qe).join(`, `)}.`)}}function xV(e){process.stdout.write(JSON.stringify(e)+`
73329
73329
  `)}function SV(e){try{return JSON.parse(e)}catch{return null}}async function CV({agentArgs:e}){Sl(`ndjson IPC host started`,`cli`);let t=bV(),n=await SF.create(),r=new Fl(n,mn(),cn.userAgentNames.desktop,RB.default.version);if(!n.isAuthenticated())try{(await r.getUserInfo())?.result?.email||(process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
73330
73330
  `),process.exit(1))}catch{process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abacus-ai/cli",
3
- "version": "2.4.6-canary.5",
3
+ "version": "2.4.7",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "abacusai": "dist/index.mjs"