@abacus-ai/cli 2.4.5-canary.3 → 2.4.5
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 +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -73324,7 +73324,7 @@ No matching component was found for:
|
|
|
73324
73324
|
`).map(e=>_z(e,i)).join(`
|
|
73325
73325
|
`):t===`truncate-start`&&(r=r.split(`
|
|
73326
73326
|
`).map(e=>gz(e,i)).join(`
|
|
73327
|
-
`))}}r=mB(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&&hB(l,u,e,t),e.style.borderStyle&&cB(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+fB(e.style,`Left`):void 0,a=n?l+c.getComputedWidth()-fB(e.style,`Right`):void 0,o=r?u+fB(e.style,`Top`):void 0,s=r?u+c.getComputedHeight()-fB(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+fB(e.style,`Top`):o,r=f?u+c.getComputedHeight()-fB(e.style,`Bottom`):s;for(let i of e.childNodes)gB(i,t,{offsetX:l,offsetY:u,transformers:d,clipY1:n,clipY2:r});f&&t.unclip()}e.renderDirty=!1};var _B=class{rootNode;lastWidth=0;cachedLines=null;output=new xz(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),gB(this.rootNode,this.output,{});let r=this.output.get(),i=!1;for(let t of r)if(_I(t)>e){i=!0;break}return this.cachedLines=i?r.map(t=>_I(t)>e?TI(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)}},vB;(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`})(vB||={});const yB=`\x1B[?25h`,bB=`\x1B[?25l`;function xB(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 SB(e){return xB(99,e)}function CB(e){let t=e??Jz(),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 wB(e){return(e??Jz()).isTTY}function TB(e){let t=CB(e);return t===`windows-terminal`||t===`iterm2`||t===`wezterm`||t===`ghostty`}function EB(e){let t=CB(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=CB(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`contour`||t===`rio`||t===`vscode`||t===`windows-terminal`}function OB(e,...t){return`\x1B]8;`+(t.length>0?t.join(`:`):``)+`;`+e+`\x07`}function kB(...e){return OB(``,...e)}function AB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function jB(e){return`\x1B]9;`+AB(e)+`\x07`}function MB(e,...t){return`\x1B]99;`+t.map(AB).join(`:`)+`;`+AB(e)+`\x07`}function NB(e){return`\x1B]777;notify;;`+AB(e)+`\x07`}const PB=`\x1B]9;4;0\x07`;function FB(e){return`\x1B]9;4;1;`+Math.min(Math.max(0,e),100)+`\x07`}function IB(e){return`\x1B]9;4;2;`+Math.min(Math.max(0,e),100)+`\x07`}function LB(e){return`\x1B]9;4;4;`+Math.min(Math.max(0,e),100)+`\x07`}var RB=class{env;profile;terminalType;_isDark;_writer;_progressHideTimer=null;constructor(e){this.env=e?.env??Jz(),this.profile=Xz(this.env),eB(this.profile),this.terminalType=CB(this.env),this._isDark=e?.isDark??Az(),this._writer=e?.writer??null,e?.isDark!==void 0&&jz(e.isDark)}get isDark(){return this._isDark}setDark(e){this._isDark=e,jz(e)}resolveAdaptiveColor(e){if(typeof e==`string`)return Kz.parse(e);let t=this._isDark?e.dark:e.light;return Kz.parse(t)}colorize(e,t,n){if(!t)return e;let r=this.resolveAdaptiveColor(t);if(!r)return e;let i=tB(r,this.profile);return i?`\x1B[`+(n===`foreground`?i.fgSequence():i.bgSequence())+`m`+e+`\x1B[0m`:e}styledText(){return aB(this.profile)}write(e){this._writer?this._writer(e):typeof process<`u`&&process.stdout?.isTTY&&process.stdout.write(e)}notify(e){if(!wB(this.env))return;let t=this.terminalType,{title:n,body:r}=e,i=n?`${n}:\n${r}`:r;t===`kitty`&&(n?this.write(MB(r,`d=0:p=title`,n)):this.write(MB(r))),this.write(NB(i)),this.write(jB(i))}showProgress(e){if(!TB(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(IB(n));break;case`warning`:this.write(LB(n));break;default:this.write(FB(n));break}(t===`error`||n>=100)&&this.scheduleProgressHide()}hideProgress(){this.clearProgressTimer(),TB(this.env)&&this.write(PB)}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){EB(this.env)&&this.write(SB(e))}clearClipboard(){EB(this.env)&&this.write(`\x1B]52;c;\x07`)}hyperlink(e,t){return DB(this.env)?OB(e)+t+kB():t}clearProgressTimer(){this._progressHideTimer&&=(clearTimeout(this._progressHideTimer),null)}scheduleProgressHide(){this.clearProgressTimer(),this._progressHideTimer=setTimeout(()=>{this.write(PB),this._progressHideTimer=null},500)}},zB=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 lL(this.terminal),this.ownsTui=!0):(this.terminal=new yL,this.tui=new lL(this.terminal),this.ownsTui=!0),this.terminalOutput=new RB({writer:e=>this.terminal.write(e)}),this.rootNode=qR(`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 _B(this.rootNode),this.tui.addChild(this.bridge),this.container=cz.createContainer(this.rootNode,0,null,!1,null,`jar`,()=>{},()=>{},()=>{},()=>{}),this.exitPromise=new Promise(e=>{this.resolveExit=e}),this.exitOnCtrlC&&this.tui.addInputListener(e=>{if(!UI(e)&&XI(e,`ctrl+c`))return this.exit(),{consume:!0}})}render(e){cz.updateContainerSync(e,this.container,null),cz.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(),cz.updateContainerSync(null,this.container,null),cz.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(yB))}disableInputProtocols(){this.terminal.write(xL),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(yB)),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(bB),this.terminal.write(`\x1B[?2004h`),this.terminal.write(bL),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 BB(e,t){let n=new zB(t),r=Y.createElement(mz,{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(mz,{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=aB().dim().render(c)),e&&(c=rB(c,e,`foreground`)),t&&(c=rB(c,t,`background`)),r&&(c=aB().bold().render(c)),i&&(c=aB().italic().render(c)),a&&(c=aB().underline().render(c)),o&&(c=aB().strikethrough().render(c)),s&&(c=aB().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 VB=/\x1b\[[\d:]*;(\d+)/;function HB(e){let t=VB.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const UB={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:``},WB=(e,t={})=>{let{addInputListener:n}=(0,Y.use)(dz),r=(0,Y.useRef)(e);r.current=e,(0,Y.useEffect)(()=>{if(t.isActive!==!1)return n(e=>{if(UI(e))return;if(e.startsWith(`\x1B[200~`)){let t=e.indexOf(`\x1B[201~`),n=t===-1?e.slice(6):e.slice(6,t);UB.upArrow=!1,UB.downArrow=!1,UB.leftArrow=!1,UB.rightArrow=!1,UB.pageDown=!1,UB.pageUp=!1,UB.home=!1,UB.end=!1,UB.return=!1,UB.escape=!1,UB.ctrl=!1,UB.shift=!1,UB.tab=!1,UB.backspace=!1,UB.delete=!1,UB.meta=!1,UB.super=!1,UB.paste=!0,UB.raw=e,r.current(n,{...UB});return}let t=ZI(e),n=t?t.split(`+`):[],i=n[n.length-1]??``,a=n.includes(`ctrl`),o=n.includes(`shift`),s=n.includes(`alt`);UB.upArrow=i===`up`,UB.downArrow=i===`down`,UB.leftArrow=i===`left`,UB.rightArrow=i===`right`,UB.pageDown=i===`pagedown`,UB.pageUp=i===`pageup`,UB.home=i===`home`,UB.end=i===`end`,UB.return=i===`return`||i===`enter`,UB.escape=i===`escape`,UB.ctrl=a,UB.shift=o,UB.tab=i===`tab`,UB.backspace=i===`backspace`,UB.delete=i===`delete`,UB.meta=s,UB.super=HB(e),UB.paste=!1,UB.raw=e;let c=UB,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=eL(e);t===void 0?e.length===1?l=e:i.length===1&&(l=i):l=t}r.current(l,{...c})})},[t.isActive,n])},GB=({isActive:e=!0,autoFocus:t=!1,id:n}={})=>{let{activeId:r,add:i,remove:a,activate:o,deactivate:s,focus:c}=(0,Y.use)(lz),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 KB(){return(0,Y.use)(uz)}const qB=()=>{let e=(0,Y.use)(pz);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},JB=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function YB(){return new RegExp(JB.source,`g`)}function XB(e){return e.replace(JB,``)}function ZB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function QB(e){return`\x1B]2;`+ZB(e)+`\x07`}var $B=W(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.4.5-canary.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`}}})),eV=Ge($B(),1);let tV=null;function nV(e){let t=(0,bF.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function rV(){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 iV(){if(process.versions.bun===void 0)return!1;let e=process.argv[1]??process.argv[0]??``;return/[/\\]\.abacusai[/\\]bin[/\\]/.test(e)}function aV(){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 oV(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}function sV(){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 cV(e){let t=Date.now();if(tV&&t-tV.timestamp<6e4)return tV.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 tV={tags:r,timestamp:t},r}async function lV(e,t,n,r){let i=t??nV(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:sV(),isEphemeral:rV(),downloadUrl:c.result.url}}async function uV(e){let t=nV(e),n=sV(),r=rV(),i=(await cV(cn.publishName))[t];return!i&&t!==`latest`||!i||i===e?null:{currentVersion:e,latestVersion:i,tag:t,packageManager:n,isEphemeral:r}}async function dV(e,t,n){if(iV())try{return await lV(e,t,oV(),n)}catch{return null}return await uV(e)}function fV(){return`${sn.binName} upgrade`}function pV(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 mV(e){try{return se(pV(e),{stdio:`pipe`}),!0}catch{return!1}}function hV(e){try{return{ok:!0,output:se(pV(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 gV(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 _V(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 vV(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
|
|
73327
|
+
`))}}r=mB(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&&hB(l,u,e,t),e.style.borderStyle&&cB(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+fB(e.style,`Left`):void 0,a=n?l+c.getComputedWidth()-fB(e.style,`Right`):void 0,o=r?u+fB(e.style,`Top`):void 0,s=r?u+c.getComputedHeight()-fB(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+fB(e.style,`Top`):o,r=f?u+c.getComputedHeight()-fB(e.style,`Bottom`):s;for(let i of e.childNodes)gB(i,t,{offsetX:l,offsetY:u,transformers:d,clipY1:n,clipY2:r});f&&t.unclip()}e.renderDirty=!1};var _B=class{rootNode;lastWidth=0;cachedLines=null;output=new xz(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),gB(this.rootNode,this.output,{});let r=this.output.get(),i=!1;for(let t of r)if(_I(t)>e){i=!0;break}return this.cachedLines=i?r.map(t=>_I(t)>e?TI(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)}},vB;(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`})(vB||={});const yB=`\x1B[?25h`,bB=`\x1B[?25l`;function xB(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 SB(e){return xB(99,e)}function CB(e){let t=e??Jz(),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 wB(e){return(e??Jz()).isTTY}function TB(e){let t=CB(e);return t===`windows-terminal`||t===`iterm2`||t===`wezterm`||t===`ghostty`}function EB(e){let t=CB(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=CB(e);return t===`iterm2`||t===`kitty`||t===`wezterm`||t===`ghostty`||t===`alacritty`||t===`foot`||t===`contour`||t===`rio`||t===`vscode`||t===`windows-terminal`}function OB(e,...t){return`\x1B]8;`+(t.length>0?t.join(`:`):``)+`;`+e+`\x07`}function kB(...e){return OB(``,...e)}function AB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function jB(e){return`\x1B]9;`+AB(e)+`\x07`}function MB(e,...t){return`\x1B]99;`+t.map(AB).join(`:`)+`;`+AB(e)+`\x07`}function NB(e){return`\x1B]777;notify;;`+AB(e)+`\x07`}const PB=`\x1B]9;4;0\x07`;function FB(e){return`\x1B]9;4;1;`+Math.min(Math.max(0,e),100)+`\x07`}function IB(e){return`\x1B]9;4;2;`+Math.min(Math.max(0,e),100)+`\x07`}function LB(e){return`\x1B]9;4;4;`+Math.min(Math.max(0,e),100)+`\x07`}var RB=class{env;profile;terminalType;_isDark;_writer;_progressHideTimer=null;constructor(e){this.env=e?.env??Jz(),this.profile=Xz(this.env),eB(this.profile),this.terminalType=CB(this.env),this._isDark=e?.isDark??Az(),this._writer=e?.writer??null,e?.isDark!==void 0&&jz(e.isDark)}get isDark(){return this._isDark}setDark(e){this._isDark=e,jz(e)}resolveAdaptiveColor(e){if(typeof e==`string`)return Kz.parse(e);let t=this._isDark?e.dark:e.light;return Kz.parse(t)}colorize(e,t,n){if(!t)return e;let r=this.resolveAdaptiveColor(t);if(!r)return e;let i=tB(r,this.profile);return i?`\x1B[`+(n===`foreground`?i.fgSequence():i.bgSequence())+`m`+e+`\x1B[0m`:e}styledText(){return aB(this.profile)}write(e){this._writer?this._writer(e):typeof process<`u`&&process.stdout?.isTTY&&process.stdout.write(e)}notify(e){if(!wB(this.env))return;let t=this.terminalType,{title:n,body:r}=e,i=n?`${n}:\n${r}`:r;t===`kitty`&&(n?this.write(MB(r,`d=0:p=title`,n)):this.write(MB(r))),this.write(NB(i)),this.write(jB(i))}showProgress(e){if(!TB(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(IB(n));break;case`warning`:this.write(LB(n));break;default:this.write(FB(n));break}(t===`error`||n>=100)&&this.scheduleProgressHide()}hideProgress(){this.clearProgressTimer(),TB(this.env)&&this.write(PB)}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){EB(this.env)&&this.write(SB(e))}clearClipboard(){EB(this.env)&&this.write(`\x1B]52;c;\x07`)}hyperlink(e,t){return DB(this.env)?OB(e)+t+kB():t}clearProgressTimer(){this._progressHideTimer&&=(clearTimeout(this._progressHideTimer),null)}scheduleProgressHide(){this.clearProgressTimer(),this._progressHideTimer=setTimeout(()=>{this.write(PB),this._progressHideTimer=null},500)}},zB=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 lL(this.terminal),this.ownsTui=!0):(this.terminal=new yL,this.tui=new lL(this.terminal),this.ownsTui=!0),this.terminalOutput=new RB({writer:e=>this.terminal.write(e)}),this.rootNode=qR(`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 _B(this.rootNode),this.tui.addChild(this.bridge),this.container=cz.createContainer(this.rootNode,0,null,!1,null,`jar`,()=>{},()=>{},()=>{},()=>{}),this.exitPromise=new Promise(e=>{this.resolveExit=e}),this.exitOnCtrlC&&this.tui.addInputListener(e=>{if(!UI(e)&&XI(e,`ctrl+c`))return this.exit(),{consume:!0}})}render(e){cz.updateContainerSync(e,this.container,null),cz.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(),cz.updateContainerSync(null,this.container,null),cz.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(yB))}disableInputProtocols(){this.terminal.write(xL),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(yB)),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(bB),this.terminal.write(`\x1B[?2004h`),this.terminal.write(bL),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 BB(e,t){let n=new zB(t),r=Y.createElement(mz,{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(mz,{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=aB().dim().render(c)),e&&(c=rB(c,e,`foreground`)),t&&(c=rB(c,t,`background`)),r&&(c=aB().bold().render(c)),i&&(c=aB().italic().render(c)),a&&(c=aB().underline().render(c)),o&&(c=aB().strikethrough().render(c)),s&&(c=aB().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 VB=/\x1b\[[\d:]*;(\d+)/;function HB(e){let t=VB.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const UB={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:``},WB=(e,t={})=>{let{addInputListener:n}=(0,Y.use)(dz),r=(0,Y.useRef)(e);r.current=e,(0,Y.useEffect)(()=>{if(t.isActive!==!1)return n(e=>{if(UI(e))return;if(e.startsWith(`\x1B[200~`)){let t=e.indexOf(`\x1B[201~`),n=t===-1?e.slice(6):e.slice(6,t);UB.upArrow=!1,UB.downArrow=!1,UB.leftArrow=!1,UB.rightArrow=!1,UB.pageDown=!1,UB.pageUp=!1,UB.home=!1,UB.end=!1,UB.return=!1,UB.escape=!1,UB.ctrl=!1,UB.shift=!1,UB.tab=!1,UB.backspace=!1,UB.delete=!1,UB.meta=!1,UB.super=!1,UB.paste=!0,UB.raw=e,r.current(n,{...UB});return}let t=ZI(e),n=t?t.split(`+`):[],i=n[n.length-1]??``,a=n.includes(`ctrl`),o=n.includes(`shift`),s=n.includes(`alt`);UB.upArrow=i===`up`,UB.downArrow=i===`down`,UB.leftArrow=i===`left`,UB.rightArrow=i===`right`,UB.pageDown=i===`pagedown`,UB.pageUp=i===`pageup`,UB.home=i===`home`,UB.end=i===`end`,UB.return=i===`return`||i===`enter`,UB.escape=i===`escape`,UB.ctrl=a,UB.shift=o,UB.tab=i===`tab`,UB.backspace=i===`backspace`,UB.delete=i===`delete`,UB.meta=s,UB.super=HB(e),UB.paste=!1,UB.raw=e;let c=UB,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=eL(e);t===void 0?e.length===1?l=e:i.length===1&&(l=i):l=t}r.current(l,{...c})})},[t.isActive,n])},GB=({isActive:e=!0,autoFocus:t=!1,id:n}={})=>{let{activeId:r,add:i,remove:a,activate:o,deactivate:s,focus:c}=(0,Y.use)(lz),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 KB(){return(0,Y.use)(uz)}const qB=()=>{let e=(0,Y.use)(pz);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},JB=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function YB(){return new RegExp(JB.source,`g`)}function XB(e){return e.replace(JB,``)}function ZB(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function QB(e){return`\x1B]2;`+ZB(e)+`\x07`}var $B=W(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.4.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`}}})),eV=Ge($B(),1);let tV=null;function nV(e){let t=(0,bF.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function rV(){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 iV(){if(process.versions.bun===void 0)return!1;let e=process.argv[1]??process.argv[0]??``;return/[/\\]\.abacusai[/\\]bin[/\\]/.test(e)}function aV(){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 oV(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}function sV(){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 cV(e){let t=Date.now();if(tV&&t-tV.timestamp<6e4)return tV.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 tV={tags:r,timestamp:t},r}async function lV(e,t,n,r){let i=t??nV(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:sV(),isEphemeral:rV(),downloadUrl:c.result.url}}async function uV(e){let t=nV(e),n=sV(),r=rV(),i=(await cV(cn.publishName))[t];return!i&&t!==`latest`||!i||i===e?null:{currentVersion:e,latestVersion:i,tag:t,packageManager:n,isEphemeral:r}}async function dV(e,t,n){if(iV())try{return await lV(e,t,oV(),n)}catch{return null}return await uV(e)}function fV(){return`${sn.binName} upgrade`}function pV(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 mV(e){try{return se(pV(e),{stdio:`pipe`}),!0}catch{return!1}}function hV(e){try{return{ok:!0,output:se(pV(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 gV(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 _V(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 vV(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
|
|
73328
73328
|
`),process.exit(1)),t?_V(n,t.toLowerCase())||(process.stderr.write(`Warning: Model "${t}" not found. Using default: ${n[0].llmName}\n`),n[0].llmName):n[0].llmName}const yV=rt([`codellm`,`cli`,`exit`]),bV=new Set,xV=new Set,SV=new Set;let CV=!1,wV=!1,TV=null,EV;async function DV(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 OV(e,t,n,r){if(CV)return;r?.debug?.(`Executing exit handlers`,{shouldManuallyExit:e,isSynchronous:t,signal:n,asyncCallbacks:bV.size,syncCallbacks:xV.size}),CV=!0,bV.size>0&&t&&yV.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:EV===void 0?(typeof U.exitCode==`number`||typeof U.exitCode==`string`)&&(i=Number(U.exitCode)):i=EV;let a=(t=!1)=>{(t||e)&&(TV?TV.call(U,i):U.exit(i))};for(let e of xV)try{e(i)}catch(e){yV.error`Error in synchronous exit hook: ${e}`}if(t){a();return}let o=[],s=0;for(let[e,t]of bV)s=Math.max(s,t),o.push(Promise.resolve(e(i)).catch(e=>{yV.error`Error in asynchronous exit hook: ${e}`}));let c=Array.from(SV);c.length>0&&o.push(DV(c));let l=setTimeout(()=>{a(!0)},s);try{await Promise.all(o),clearTimeout(l),a()}catch(e){clearTimeout(l),yV.error`Error during exit cleanup: ${e}`,a(!0)}}function kV(){wV||(wV=!0,U.once(`beforeExit`,()=>{OV(!0,!1,-128)}),U.once(`SIGINT`,()=>{OV(!0,!1,2)}),U.once(`SIGTERM`,()=>{OV(!0,!1,15)}),U.once(`exit`,()=>{OV(!1,!0,0)}),U.on(`message`,e=>{e===`shutdown`&&OV(!0,!0,-128)}),TV||(TV=U.exit.bind(U),U.exit=function(e){if(EV===void 0&&(EV=e??0),bV.size===0&&SV.size===0){if(TV){TV(e??0);return}U.exit(e??0)}OV(!0,!1,-128).catch(e=>{yV.error`Error during exit: ${e}`,TV?TV(1):U.exit(1)})}))}function AV(e,t){if(typeof e!=`function`)throw TypeError(`callback must be a function`);if(CV)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}),kV();let n=t?.wait??0,r=t?.streams??[U.stdout,U.stderr];if(n>0){let t=[e,n];bV.add(t);for(let e of r)SV.add(e);return()=>{bV.delete(t);for(let e of r)SV.delete(e)}}return xV.add(e),()=>{xV.delete(e)}}function jV(e){e!==void 0&&(U.exitCode=e),OV(!0,!1,-128)}function MV(e){process.stdout.write(JSON.stringify(e)+`
|
|
73329
73329
|
`)}function NV(e){try{return JSON.parse(e)}catch{return null}}async function PV({agentArgs:e}){xl(`desktop-host started`,`cli`);let t=await RF.create(),n=new Pl(t,mn(),cn.userAgentNames.desktop,eV.default.version);if(!t.isAuthenticated())try{(await n.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.
|