@abacus-ai/cli 2.4.9-canary.3 → 2.4.9
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
|
@@ -75140,7 +75140,7 @@ No matching component was found for:
|
|
|
75140
75140
|
`).map(e=>eMe(e,i)).join(`
|
|
75141
75141
|
`):t===`truncate-start`&&(r=r.split(`
|
|
75142
75142
|
`).map(e=>$je(e,i)).join(`
|
|
75143
|
-
`))}}r=wMe(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&&TMe(l,u,e,t),e.style.borderStyle&&bMe(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+dZ(e.style,`Left`):void 0,a=n?l+c.getComputedWidth()-dZ(e.style,`Right`):void 0,o=r?u+dZ(e.style,`Top`):void 0,s=r?u+c.getComputedHeight()-dZ(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+dZ(e.style,`Top`):o,r=f?u+c.getComputedHeight()-dZ(e.style,`Bottom`):s;for(let i of e.childNodes)fZ(i,t,{offsetX:l,offsetY:u,transformers:d,clipY1:n,clipY2:r});f&&t.unclip()}e.renderDirty=!1};var EMe=class{rootNode;lastWidth=0;cachedLines=null;output=new tMe(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),fZ(this.rootNode,this.output,{});let r=this.output.get(),i=!1;for(let t of r)if(JJ(t)>e){i=!0;break}return this.cachedLines=i?r.map(t=>JJ(t)>e?$J(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)}},DMe;(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`})(DMe||={});const pZ=`\x1B[?25h`,mZ=`\x1B[?25l`;function OMe(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 kMe(e){return OMe(99,e)}function hZ(e,...t){return`\x1B]8;`+(t.length>0?t.join(`:`):``)+`;`+e+`\x07`}function gZ(...e){return hZ(``,...e)}function _Z(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function AMe(e){return`\x1B]9;`+_Z(e)+`\x07`}function vZ(e,...t){return`\x1B]99;`+t.map(_Z).join(`:`)+`;`+_Z(e)+`\x07`}function jMe(e){return`\x1B]777;notify;;`+_Z(e)+`\x07`}const yZ=`\x1B]9;4;0\x07`;function MMe(e){return`\x1B]9;4;1;`+Math.min(Math.max(0,e),100)+`\x07`}function NMe(e){return`\x1B]9;4;2;`+Math.min(Math.max(0,e),100)+`\x07`}function PMe(e){return`\x1B]9;4;4;`+Math.min(Math.max(0,e),100)+`\x07`}var FMe=class{env;profile;terminalType;_isDark;_writer;_progressHideTimer=null;constructor(e){this.env=e?.env??DY(),this.profile=nZ(this.env),gMe(this.profile),this.terminalType=OY(this.env),this._isDark=e?.isDark??WX(),this._writer=e?.writer??null,e?.isDark!==void 0&&GX(e.isDark)}get isDark(){return this._isDark}setDark(e){this._isDark=e,GX(e)}resolveAdaptiveColor(e){if(typeof e==`string`)return eZ.parse(e);let t=this._isDark?e.dark:e.light;return eZ.parse(t)}colorize(e,t,n){if(!t)return e;let r=this.resolveAdaptiveColor(t);if(!r)return e;let i=aZ(r,this.profile);return i?`\x1B[`+(n===`foreground`?i.fgSequence():i.bgSequence())+`m`+e+`\x1B[0m`:e}styledText(){return cZ(this.profile)}write(e){this._writer?this._writer(e):typeof process<`u`&&process.stdout?.isTTY&&process.stdout.write(e)}notify(e){if(!cje(this.env))return;let t=this.terminalType,{title:n,body:r}=e,i=n?`${n}:\n${r}`:r;t===`kitty`&&(n?this.write(vZ(r,`d=0:p=title`,n)):this.write(vZ(r))),this.write(jMe(i)),this.write(AMe(i))}showProgress(e){if(!kY(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(NMe(n));break;case`warning`:this.write(PMe(n));break;default:this.write(MMe(n));break}(t===`error`||n>=100)&&this.scheduleProgressHide()}hideProgress(){this.clearProgressTimer(),kY(this.env)&&this.write(yZ)}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){AY(this.env)&&this.write(kMe(e))}clearClipboard(){AY(this.env)&&this.write(`\x1B]52;c;\x07`)}hyperlink(e,t){return lje(this.env)?hZ(e)+t+gZ():t}clearProgressTimer(){this._progressHideTimer&&=(clearTimeout(this._progressHideTimer),null)}scheduleProgressHide(){this.clearProgressTimer(),this._progressHideTimer=setTimeout(()=>{this.write(yZ),this._progressHideTimer=null},500)}},IMe=class{tui;terminal;terminalOutput;rootNode;bridge;container;exitCallbacks=[];exitPromise;resolveExit;exitOnCtrlC;ownsTui;suspendable;onSuspended;cleanupSuspend;originalWarningListeners;warningInterceptor;requestFullRedrawOnNextCommit=!1;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 wY(this.terminal),this.ownsTui=!0):(this.terminal=new sje,this.tui=new wY(this.terminal),this.ownsTui=!0),this.terminalOutput=new FMe({writer:e=>this.terminal.write(e)}),this.rootNode=yX(`jar-root`),this.rootNode.yogaNode.setFlexDirection(0),this.rootNode.yogaNode.setFlexGrow(1),this.rootNode.onRender=()=>{this.bridge.notifyCommit(),this.requestFullRedrawOnNextCommit?(this.requestFullRedrawOnNextCommit=!1,this.tui.requestRender(!0)):this.tui.requestRender(),performance.clearMeasures()},this.bridge=new EMe(this.rootNode),this.tui.addChild(this.bridge),this.container=MX.createContainer(this.rootNode,0,null,!1,null,`jar`,()=>{},()=>{},()=>{},()=>{}),this.exitPromise=new Promise(e=>{this.resolveExit=e}),this.exitOnCtrlC&&this.tui.addInputListener(e=>{if(!pY(e)&&vY(e,`ctrl+c`))return this.exit(),{consume:!0}})}render(e){MX.updateContainerSync(e,this.container,null),MX.flushSyncWork()}requestFullRedraw(){this.requestFullRedrawOnNextCommit=!0,this.bridge.invalidate(),this.tui.requestRender(!0)}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.ownsTui&&this.terminal.kittyProtocolActive?this.terminal.drainInput(200,50).catch(()=>{}).then(()=>this.unmount()):this.unmount()}onExit(e){this.exitCallbacks.push(e)}unmount(){if(this.warningInterceptor&&=(H.removeListener(`warning`,this.warningInterceptor),void 0),this.originalWarningListeners){let e=H.listeners(`warning`);for(let t of this.originalWarningListeners)e.includes(t)||H.on(`warning`,t);this.originalWarningListeners=void 0}this.cleanupSuspend?.(),this.ownsTui&&this.disableInputProtocols(),MX.updateContainerSync(null,this.container,null),MX.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(),H.stdout.write(pZ))}disableInputProtocols(){this.terminal.write(MY),this.terminal.write(`\x1B[?2004l`),this.terminal.kittyProtocolActive&&this.terminal.write(`\x1B[<u`)}setupWarningInterceptor(){this.originalWarningListeners||(this.originalWarningListeners=H.rawListeners(`warning`),H.removeAllListeners(`warning`),this.warningInterceptor=()=>{},H.on(`warning`,this.warningInterceptor))}setupSuspendHandler(){if(H.platform===`win32`||!this.ownsTui)return()=>{};let e=!1,t=()=>{e=this.terminal.kittyProtocolActive,H.stdout.isTTY&&(this.disableInputProtocols(),H.stdout.write(pZ)),H.stdin.isTTY&&H.stdin.isRaw&&H.stdin.setRawMode(!1),this.onSuspended?.(),H.removeListener(`SIGTSTP`,t),H.kill(H.pid,`SIGTSTP`)},n=()=>{H.stdin.isTTY&&H.stdin.setRawMode(!0),H.stdout.isTTY&&(H.stdout.write(mZ),this.terminal.write(`\x1B[?2004h`),this.terminal.write(jY),e&&this.terminal.write(`\x1B[>7u`)),H.on(`SIGTSTP`,t),this.tui.requestRender(!0)};return H.on(`SIGTSTP`,t),H.on(`SIGCONT`,n),()=>{H.removeListener(`SIGTSTP`,t),H.removeListener(`SIGCONT`,n)}}waitUntilExit(){return this.exitPromise}getRootNode(){return this.rootNode}};function LMe(e,t){let n=new IMe(t),r=Z.createElement(RX,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),requestFullRedraw:()=>n.requestFullRedraw(),children:e});return n.render(r),n.start(),{rerender(e){let t=Z.createElement(RX,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),requestFullRedraw:()=>n.requestFullRedraw(),children:e});n.render(t)},unmount(){n.unmount()},waitUntilExit(){return n.waitUntilExit()},requestFullRedraw(){n.requestFullRedraw()},cleanupTerminal(){n.cleanupTerminal()}}}function Q({children:e,...t}){return(0,X.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 $({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,Z.useCallback)(c=>(n&&(c=cZ().dim().render(c)),e&&(c=sZ(c,e,`foreground`)),t&&(c=sZ(c,t,`background`)),r&&(c=cZ().bold().render(c)),i&&(c=cZ().italic().render(c)),a&&(c=cZ().underline().render(c)),o&&(c=cZ().strikethrough().render(c)),s&&(c=cZ().reverse().render(c)),l&&(c=l(c)),c),[e,t,n,r,i,a,o,s,l]);return(0,X.jsx)(`jar-text`,{style:{flexGrow:0,flexShrink:0,flexDirection:`row`,textWrap:c},internal_transform:d,children:u})}const RMe=/\x1b\[[\d:]*;(\d+)/;function zMe(e){let t=RMe.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const bZ={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:``},xZ=(e,t={})=>{let{addInputListener:n}=(0,Z.use)(FX),r=(0,Z.useRef)(e);r.current=e,(0,Z.useEffect)(()=>{if(t.isActive!==!1)return n(e=>{if(pY(e))return;if(e.startsWith(`\x1B[200~`)){let t=e.indexOf(`\x1B[201~`),n=t===-1?e.slice(6):e.slice(6,t);bZ.upArrow=!1,bZ.downArrow=!1,bZ.leftArrow=!1,bZ.rightArrow=!1,bZ.pageDown=!1,bZ.pageUp=!1,bZ.home=!1,bZ.end=!1,bZ.return=!1,bZ.escape=!1,bZ.ctrl=!1,bZ.shift=!1,bZ.tab=!1,bZ.backspace=!1,bZ.delete=!1,bZ.meta=!1,bZ.super=!1,bZ.paste=!0,bZ.raw=e,r.current(n,{...bZ});return}let t=qAe(e),n=t?t.split(`+`):[],i=n[n.length-1]??``,a=n.includes(`ctrl`),o=n.includes(`shift`),s=n.includes(`alt`);bZ.upArrow=i===`up`,bZ.downArrow=i===`down`,bZ.leftArrow=i===`left`,bZ.rightArrow=i===`right`,bZ.pageDown=i===`pagedown`,bZ.pageUp=i===`pageup`,bZ.home=i===`home`,bZ.end=i===`end`,bZ.return=i===`return`||i===`enter`,bZ.escape=i===`escape`,bZ.ctrl=a,bZ.shift=o,bZ.tab=i===`tab`,bZ.backspace=i===`backspace`,bZ.delete=i===`delete`,bZ.meta=s,bZ.super=zMe(e),bZ.paste=!1,bZ.raw=e;let c=bZ,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=XAe(e);t===void 0?e.length===1?l=e:i.length===1&&(l=i):l=t}r.current(l,{...c})})},[t.isActive,n])},BMe=()=>{let e=(0,Z.use)(IX);if(!e)throw Error(`useApp must be used within a jar render context`);return{exit:e.exit,requestFullRedraw:e.requestFullRedraw}},SZ=({isActive:e=!0,autoFocus:t=!1,id:n}={})=>{let{activeId:r,add:i,remove:a,activate:o,deactivate:s,focus:c}=(0,Z.use)(NX),l=(0,Z.useMemo)(()=>n??Math.random().toString().slice(2,7),[n]);return(0,Z.useEffect)(()=>(i(l,{autoFocus:t}),()=>{a(l)}),[l,t]),(0,Z.useEffect)(()=>{e?o(l):s(l)},[e,l]),{isFocused:!!l&&r===l,focus:c}};function CZ(){return(0,Z.use)(PX)}const wZ=()=>{let e=(0,Z.use)(LX);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},TZ=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function VMe(){return new RegExp(TZ.source,`g`)}function HMe(e){return e.replace(TZ,``)}function UMe(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function EZ(e){return`\x1B]2;`+UMe(e)+`\x07`}var DZ=G(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.4.9-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`}}})),OZ=Qe(DZ(),1);let kZ=null;function AZ(e){let t=(0,xJ.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function jZ(e){if(!e)return``;try{return y(e)}catch{return e}}function MZ(){return{invokedPath:jZ(process.argv[1]??``),execPath:jZ(process.execPath??process.argv[0]??``)}}function NZ(e){let t=hn.configDirName.replace(/^\./,``).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`[/\\\\]\\.?${t}[/\\\\]bin[/\\\\]`,`i`).test(e)}function PZ(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 FZ(){let e=(process.env.npm_command??``).toLowerCase();if(e===`exec`||e===`dlx`)return!0;let{invokedPath:t,execPath:n}=MZ();return/[/\\]_npx[/\\]|[/\\]dlx[/\\]|[/\\]\.cache[/\\]/.test(t+`|`+n)}function IZ(){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}=MZ(),r=`${t}|${n}`;return/[/\\]\.?yarn[/\\]/.test(r)?`yarn`:/[/\\]\.?pnpm[/\\]/.test(r)?`pnpm`:/[/\\]\.bun[/\\]/.test(r)||process.versions.bun!==void 0&&!NZ(n)?`bun`:`npm`}function WMe(){let{execPath:e,invokedPath:t}=MZ();return PZ(t)||PZ(e)?!1:NZ(e)||NZ(t)}function LZ(){let e=`${hn.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let{invokedPath:n,execPath:r}=MZ();return!(NZ(r)||NZ(n)||PZ(n)||PZ(r)||process.env.npm_config_user_agent)}function GMe(){let{execPath:e}=MZ(),t=IZ(),n=FZ();return LZ()?{installationType:`development`,packageManager:t,isEphemeral:n,execPath:e}:WMe()?{installationType:`native`,packageManager:t,isEphemeral:n,execPath:e}:{installationType:`package-manager`,packageManager:t,isEphemeral:n,execPath:e}}function KMe(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}async function qMe(e){let t=Date.now();if(kZ&&t-kZ.timestamp<6e4)return kZ.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 kZ={tags:r,timestamp:t},r}async function JMe(e,t,n,r){let i=t??AZ(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:IZ(),isEphemeral:FZ(),installationType:`native`,downloadUrl:l.url}}async function YMe(e,t){let n=t??AZ(e),r=IZ(),i=FZ(),a=(await qMe(gn.publishName))[n];return!a&&n!==`latest`||!a||a===e?null:{currentVersion:e,latestVersion:a,tag:n,packageManager:r,isEphemeral:i,installationType:`package-manager`}}async function RZ(e,t,n,r){let i=GMe();if(i.installationType===`native`)try{return await JMe(e,t,KMe(),n)}catch{return null}return i.installationType===`development`&&!r?.includeDev?null:await YMe(e,t)}function zZ(e){if(e.installationType===`native`)return`${hn.binName} upgrade`;let t=`${gn.publishName}@${e.tag}`;switch(e.packageManager){case`yarn`:return`yarn global add ${t}`;case`pnpm`:return`pnpm add -g ${t}`;case`bun`:return`bun add -g ${t}`;default:return`npm install -g ${t}`}}function BZ(e){try{return{ok:!0,output:le(zZ(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 VZ(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let t=D.join(P.tmpdir(),`abacusai-update-${Date.now()}`),n=D.join(P.homedir(),hn.configDirName,`bin`),r=process.platform===`win32`,i=r?`${hn.binName}.exe`:hn.binName;try{await we.mkdir(t,{recursive:!0}),await we.mkdir(n,{recursive:!0});let a=D.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 we.writeFile(a,s),le(r?`powershell -Command "Expand-Archive -Path '${a}' -DestinationPath '${t}' -Force"`:`tar -xzf "${a}" -C "${t}"`,{stdio:`pipe`});let c=D.join(t,i),l=D.join(n,i);return await we.copyFile(c,l),r||await we.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 we.rm(t,{recursive:!0,force:!0}).catch(()=>{})}}function XMe(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 HZ(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
|
|
75143
|
+
`))}}r=wMe(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&&TMe(l,u,e,t),e.style.borderStyle&&bMe(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+dZ(e.style,`Left`):void 0,a=n?l+c.getComputedWidth()-dZ(e.style,`Right`):void 0,o=r?u+dZ(e.style,`Top`):void 0,s=r?u+c.getComputedHeight()-dZ(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+dZ(e.style,`Top`):o,r=f?u+c.getComputedHeight()-dZ(e.style,`Bottom`):s;for(let i of e.childNodes)fZ(i,t,{offsetX:l,offsetY:u,transformers:d,clipY1:n,clipY2:r});f&&t.unclip()}e.renderDirty=!1};var EMe=class{rootNode;lastWidth=0;cachedLines=null;output=new tMe(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),fZ(this.rootNode,this.output,{});let r=this.output.get(),i=!1;for(let t of r)if(JJ(t)>e){i=!0;break}return this.cachedLines=i?r.map(t=>JJ(t)>e?$J(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)}},DMe;(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`})(DMe||={});const pZ=`\x1B[?25h`,mZ=`\x1B[?25l`;function OMe(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 kMe(e){return OMe(99,e)}function hZ(e,...t){return`\x1B]8;`+(t.length>0?t.join(`:`):``)+`;`+e+`\x07`}function gZ(...e){return hZ(``,...e)}function _Z(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function AMe(e){return`\x1B]9;`+_Z(e)+`\x07`}function vZ(e,...t){return`\x1B]99;`+t.map(_Z).join(`:`)+`;`+_Z(e)+`\x07`}function jMe(e){return`\x1B]777;notify;;`+_Z(e)+`\x07`}const yZ=`\x1B]9;4;0\x07`;function MMe(e){return`\x1B]9;4;1;`+Math.min(Math.max(0,e),100)+`\x07`}function NMe(e){return`\x1B]9;4;2;`+Math.min(Math.max(0,e),100)+`\x07`}function PMe(e){return`\x1B]9;4;4;`+Math.min(Math.max(0,e),100)+`\x07`}var FMe=class{env;profile;terminalType;_isDark;_writer;_progressHideTimer=null;constructor(e){this.env=e?.env??DY(),this.profile=nZ(this.env),gMe(this.profile),this.terminalType=OY(this.env),this._isDark=e?.isDark??WX(),this._writer=e?.writer??null,e?.isDark!==void 0&&GX(e.isDark)}get isDark(){return this._isDark}setDark(e){this._isDark=e,GX(e)}resolveAdaptiveColor(e){if(typeof e==`string`)return eZ.parse(e);let t=this._isDark?e.dark:e.light;return eZ.parse(t)}colorize(e,t,n){if(!t)return e;let r=this.resolveAdaptiveColor(t);if(!r)return e;let i=aZ(r,this.profile);return i?`\x1B[`+(n===`foreground`?i.fgSequence():i.bgSequence())+`m`+e+`\x1B[0m`:e}styledText(){return cZ(this.profile)}write(e){this._writer?this._writer(e):typeof process<`u`&&process.stdout?.isTTY&&process.stdout.write(e)}notify(e){if(!cje(this.env))return;let t=this.terminalType,{title:n,body:r}=e,i=n?`${n}:\n${r}`:r;t===`kitty`&&(n?this.write(vZ(r,`d=0:p=title`,n)):this.write(vZ(r))),this.write(jMe(i)),this.write(AMe(i))}showProgress(e){if(!kY(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(NMe(n));break;case`warning`:this.write(PMe(n));break;default:this.write(MMe(n));break}(t===`error`||n>=100)&&this.scheduleProgressHide()}hideProgress(){this.clearProgressTimer(),kY(this.env)&&this.write(yZ)}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){AY(this.env)&&this.write(kMe(e))}clearClipboard(){AY(this.env)&&this.write(`\x1B]52;c;\x07`)}hyperlink(e,t){return lje(this.env)?hZ(e)+t+gZ():t}clearProgressTimer(){this._progressHideTimer&&=(clearTimeout(this._progressHideTimer),null)}scheduleProgressHide(){this.clearProgressTimer(),this._progressHideTimer=setTimeout(()=>{this.write(yZ),this._progressHideTimer=null},500)}},IMe=class{tui;terminal;terminalOutput;rootNode;bridge;container;exitCallbacks=[];exitPromise;resolveExit;exitOnCtrlC;ownsTui;suspendable;onSuspended;cleanupSuspend;originalWarningListeners;warningInterceptor;requestFullRedrawOnNextCommit=!1;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 wY(this.terminal),this.ownsTui=!0):(this.terminal=new sje,this.tui=new wY(this.terminal),this.ownsTui=!0),this.terminalOutput=new FMe({writer:e=>this.terminal.write(e)}),this.rootNode=yX(`jar-root`),this.rootNode.yogaNode.setFlexDirection(0),this.rootNode.yogaNode.setFlexGrow(1),this.rootNode.onRender=()=>{this.bridge.notifyCommit(),this.requestFullRedrawOnNextCommit?(this.requestFullRedrawOnNextCommit=!1,this.tui.requestRender(!0)):this.tui.requestRender(),performance.clearMeasures()},this.bridge=new EMe(this.rootNode),this.tui.addChild(this.bridge),this.container=MX.createContainer(this.rootNode,0,null,!1,null,`jar`,()=>{},()=>{},()=>{},()=>{}),this.exitPromise=new Promise(e=>{this.resolveExit=e}),this.exitOnCtrlC&&this.tui.addInputListener(e=>{if(!pY(e)&&vY(e,`ctrl+c`))return this.exit(),{consume:!0}})}render(e){MX.updateContainerSync(e,this.container,null),MX.flushSyncWork()}requestFullRedraw(){this.requestFullRedrawOnNextCommit=!0,this.bridge.invalidate(),this.tui.requestRender(!0)}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.ownsTui&&this.terminal.kittyProtocolActive?this.terminal.drainInput(200,50).catch(()=>{}).then(()=>this.unmount()):this.unmount()}onExit(e){this.exitCallbacks.push(e)}unmount(){if(this.warningInterceptor&&=(H.removeListener(`warning`,this.warningInterceptor),void 0),this.originalWarningListeners){let e=H.listeners(`warning`);for(let t of this.originalWarningListeners)e.includes(t)||H.on(`warning`,t);this.originalWarningListeners=void 0}this.cleanupSuspend?.(),this.ownsTui&&this.disableInputProtocols(),MX.updateContainerSync(null,this.container,null),MX.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(),H.stdout.write(pZ))}disableInputProtocols(){this.terminal.write(MY),this.terminal.write(`\x1B[?2004l`),this.terminal.kittyProtocolActive&&this.terminal.write(`\x1B[<u`)}setupWarningInterceptor(){this.originalWarningListeners||(this.originalWarningListeners=H.rawListeners(`warning`),H.removeAllListeners(`warning`),this.warningInterceptor=()=>{},H.on(`warning`,this.warningInterceptor))}setupSuspendHandler(){if(H.platform===`win32`||!this.ownsTui)return()=>{};let e=!1,t=()=>{e=this.terminal.kittyProtocolActive,H.stdout.isTTY&&(this.disableInputProtocols(),H.stdout.write(pZ)),H.stdin.isTTY&&H.stdin.isRaw&&H.stdin.setRawMode(!1),this.onSuspended?.(),H.removeListener(`SIGTSTP`,t),H.kill(H.pid,`SIGTSTP`)},n=()=>{H.stdin.isTTY&&H.stdin.setRawMode(!0),H.stdout.isTTY&&(H.stdout.write(mZ),this.terminal.write(`\x1B[?2004h`),this.terminal.write(jY),e&&this.terminal.write(`\x1B[>7u`)),H.on(`SIGTSTP`,t),this.tui.requestRender(!0)};return H.on(`SIGTSTP`,t),H.on(`SIGCONT`,n),()=>{H.removeListener(`SIGTSTP`,t),H.removeListener(`SIGCONT`,n)}}waitUntilExit(){return this.exitPromise}getRootNode(){return this.rootNode}};function LMe(e,t){let n=new IMe(t),r=Z.createElement(RX,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),requestFullRedraw:()=>n.requestFullRedraw(),children:e});return n.render(r),n.start(),{rerender(e){let t=Z.createElement(RX,{tui:n.tui,terminal:n.terminal,terminalOutput:n.terminalOutput,exit:e=>n.exit(e),requestFullRedraw:()=>n.requestFullRedraw(),children:e});n.render(t)},unmount(){n.unmount()},waitUntilExit(){return n.waitUntilExit()},requestFullRedraw(){n.requestFullRedraw()},cleanupTerminal(){n.cleanupTerminal()}}}function Q({children:e,...t}){return(0,X.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 $({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,Z.useCallback)(c=>(n&&(c=cZ().dim().render(c)),e&&(c=sZ(c,e,`foreground`)),t&&(c=sZ(c,t,`background`)),r&&(c=cZ().bold().render(c)),i&&(c=cZ().italic().render(c)),a&&(c=cZ().underline().render(c)),o&&(c=cZ().strikethrough().render(c)),s&&(c=cZ().reverse().render(c)),l&&(c=l(c)),c),[e,t,n,r,i,a,o,s,l]);return(0,X.jsx)(`jar-text`,{style:{flexGrow:0,flexShrink:0,flexDirection:`row`,textWrap:c},internal_transform:d,children:u})}const RMe=/\x1b\[[\d:]*;(\d+)/;function zMe(e){let t=RMe.exec(e);return t?(parseInt(t[1],10)-1&8)!=0:!1}const bZ={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:``},xZ=(e,t={})=>{let{addInputListener:n}=(0,Z.use)(FX),r=(0,Z.useRef)(e);r.current=e,(0,Z.useEffect)(()=>{if(t.isActive!==!1)return n(e=>{if(pY(e))return;if(e.startsWith(`\x1B[200~`)){let t=e.indexOf(`\x1B[201~`),n=t===-1?e.slice(6):e.slice(6,t);bZ.upArrow=!1,bZ.downArrow=!1,bZ.leftArrow=!1,bZ.rightArrow=!1,bZ.pageDown=!1,bZ.pageUp=!1,bZ.home=!1,bZ.end=!1,bZ.return=!1,bZ.escape=!1,bZ.ctrl=!1,bZ.shift=!1,bZ.tab=!1,bZ.backspace=!1,bZ.delete=!1,bZ.meta=!1,bZ.super=!1,bZ.paste=!0,bZ.raw=e,r.current(n,{...bZ});return}let t=qAe(e),n=t?t.split(`+`):[],i=n[n.length-1]??``,a=n.includes(`ctrl`),o=n.includes(`shift`),s=n.includes(`alt`);bZ.upArrow=i===`up`,bZ.downArrow=i===`down`,bZ.leftArrow=i===`left`,bZ.rightArrow=i===`right`,bZ.pageDown=i===`pagedown`,bZ.pageUp=i===`pageup`,bZ.home=i===`home`,bZ.end=i===`end`,bZ.return=i===`return`||i===`enter`,bZ.escape=i===`escape`,bZ.ctrl=a,bZ.shift=o,bZ.tab=i===`tab`,bZ.backspace=i===`backspace`,bZ.delete=i===`delete`,bZ.meta=s,bZ.super=zMe(e),bZ.paste=!1,bZ.raw=e;let c=bZ,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=XAe(e);t===void 0?e.length===1?l=e:i.length===1&&(l=i):l=t}r.current(l,{...c})})},[t.isActive,n])},BMe=()=>{let e=(0,Z.use)(IX);if(!e)throw Error(`useApp must be used within a jar render context`);return{exit:e.exit,requestFullRedraw:e.requestFullRedraw}},SZ=({isActive:e=!0,autoFocus:t=!1,id:n}={})=>{let{activeId:r,add:i,remove:a,activate:o,deactivate:s,focus:c}=(0,Z.use)(NX),l=(0,Z.useMemo)(()=>n??Math.random().toString().slice(2,7),[n]);return(0,Z.useEffect)(()=>(i(l,{autoFocus:t}),()=>{a(l)}),[l,t]),(0,Z.useEffect)(()=>{e?o(l):s(l)},[e,l]),{isFocused:!!l&&r===l,focus:c}};function CZ(){return(0,Z.use)(PX)}const wZ=()=>{let e=(0,Z.use)(LX);if(!e)throw Error(`useTerminal must be used within a jar render context`);return e.output},TZ=RegExp(`[\\x1b\\x9b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\\x1b\\][\\s\\S]*?(?:\\x07|\\x1b\\\\)`,`g`);function VMe(){return new RegExp(TZ.source,`g`)}function HMe(e){return e.replace(TZ,``)}function UMe(e){return e.replace(/[\x07\x1b\x9c]/g,``)}function EZ(e){return`\x1B]2;`+UMe(e)+`\x07`}var DZ=G(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.4.9`,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`}}})),OZ=Qe(DZ(),1);let kZ=null;function AZ(e){let t=(0,xJ.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function jZ(e){if(!e)return``;try{return y(e)}catch{return e}}function MZ(){return{invokedPath:jZ(process.argv[1]??``),execPath:jZ(process.execPath??process.argv[0]??``)}}function NZ(e){let t=hn.configDirName.replace(/^\./,``).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`[/\\\\]\\.?${t}[/\\\\]bin[/\\\\]`,`i`).test(e)}function PZ(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 FZ(){let e=(process.env.npm_command??``).toLowerCase();if(e===`exec`||e===`dlx`)return!0;let{invokedPath:t,execPath:n}=MZ();return/[/\\]_npx[/\\]|[/\\]dlx[/\\]|[/\\]\.cache[/\\]/.test(t+`|`+n)}function IZ(){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}=MZ(),r=`${t}|${n}`;return/[/\\]\.?yarn[/\\]/.test(r)?`yarn`:/[/\\]\.?pnpm[/\\]/.test(r)?`pnpm`:/[/\\]\.bun[/\\]/.test(r)||process.versions.bun!==void 0&&!NZ(n)?`bun`:`npm`}function WMe(){let{execPath:e,invokedPath:t}=MZ();return PZ(t)||PZ(e)?!1:NZ(e)||NZ(t)}function LZ(){let e=`${hn.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let{invokedPath:n,execPath:r}=MZ();return!(NZ(r)||NZ(n)||PZ(n)||PZ(r)||process.env.npm_config_user_agent)}function GMe(){let{execPath:e}=MZ(),t=IZ(),n=FZ();return LZ()?{installationType:`development`,packageManager:t,isEphemeral:n,execPath:e}:WMe()?{installationType:`native`,packageManager:t,isEphemeral:n,execPath:e}:{installationType:`package-manager`,packageManager:t,isEphemeral:n,execPath:e}}function KMe(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}async function qMe(e){let t=Date.now();if(kZ&&t-kZ.timestamp<6e4)return kZ.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 kZ={tags:r,timestamp:t},r}async function JMe(e,t,n,r){let i=t??AZ(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:IZ(),isEphemeral:FZ(),installationType:`native`,downloadUrl:l.url}}async function YMe(e,t){let n=t??AZ(e),r=IZ(),i=FZ(),a=(await qMe(gn.publishName))[n];return!a&&n!==`latest`||!a||a===e?null:{currentVersion:e,latestVersion:a,tag:n,packageManager:r,isEphemeral:i,installationType:`package-manager`}}async function RZ(e,t,n,r){let i=GMe();if(i.installationType===`native`)try{return await JMe(e,t,KMe(),n)}catch{return null}return i.installationType===`development`&&!r?.includeDev?null:await YMe(e,t)}function zZ(e){if(e.installationType===`native`)return`${hn.binName} upgrade`;let t=`${gn.publishName}@${e.tag}`;switch(e.packageManager){case`yarn`:return`yarn global add ${t}`;case`pnpm`:return`pnpm add -g ${t}`;case`bun`:return`bun add -g ${t}`;default:return`npm install -g ${t}`}}function BZ(e){try{return{ok:!0,output:le(zZ(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 VZ(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let t=D.join(P.tmpdir(),`abacusai-update-${Date.now()}`),n=D.join(P.homedir(),hn.configDirName,`bin`),r=process.platform===`win32`,i=r?`${hn.binName}.exe`:hn.binName;try{await we.mkdir(t,{recursive:!0}),await we.mkdir(n,{recursive:!0});let a=D.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 we.writeFile(a,s),le(r?`powershell -Command "Expand-Archive -Path '${a}' -DestinationPath '${t}' -Force"`:`tar -xzf "${a}" -C "${t}"`,{stdio:`pipe`});let c=D.join(t,i),l=D.join(n,i);return await we.copyFile(c,l),r||await we.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 we.rm(t,{recursive:!0,force:!0}).catch(()=>{})}}function XMe(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 HZ(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
|
|
75144
75144
|
`),process.exit(1)),t?XMe(n,t.toLowerCase())||(process.stderr.write(`Warning: Model "${t}" not found. Using default: ${n[0].llmName}\n`),n[0].llmName):n[0].llmName}const UZ=dt([`codellm`,`cli`,`exit`]),WZ=new Set,GZ=new Set,KZ=new Set;let qZ=!1,JZ=!1,YZ=null,XZ;async function ZMe(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 ZZ(e,t,n,r){if(qZ)return;r?.debug?.(`Executing exit handlers`,{shouldManuallyExit:e,isSynchronous:t,signal:n,asyncCallbacks:WZ.size,syncCallbacks:GZ.size}),qZ=!0,WZ.size>0&&t&&UZ.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:XZ===void 0?(typeof H.exitCode==`number`||typeof H.exitCode==`string`)&&(i=Number(H.exitCode)):i=XZ;let a=(t=!1)=>{(t||e)&&(YZ?YZ.call(H,i):H.exit(i))};for(let e of GZ)try{e(i)}catch(e){UZ.error`Error in synchronous exit hook: ${e}`}if(t){a();return}let o=[],s=0;for(let[e,t]of WZ)s=Math.max(s,t),o.push(Promise.resolve(e(i)).catch(e=>{UZ.error`Error in asynchronous exit hook: ${e}`}));let c=Array.from(KZ);c.length>0&&o.push(ZMe(c));let l=setTimeout(()=>{a(!0)},s);try{await Promise.all(o),clearTimeout(l),a()}catch(e){clearTimeout(l),UZ.error`Error during exit cleanup: ${e}`,a(!0)}}function QMe(){JZ||(JZ=!0,H.once(`beforeExit`,()=>{ZZ(!0,!1,-128)}),H.once(`SIGINT`,()=>{ZZ(!0,!1,2)}),H.once(`SIGTERM`,()=>{ZZ(!0,!1,15)}),H.once(`exit`,()=>{ZZ(!1,!0,0)}),H.on(`message`,e=>{e===`shutdown`&&ZZ(!0,!0,-128)}),YZ||(YZ=H.exit.bind(H),H.exit=function(e){if(XZ===void 0&&(XZ=e??0),WZ.size===0&&KZ.size===0){if(YZ){YZ(e??0);return}H.exit(e??0)}ZZ(!0,!1,-128).catch(e=>{UZ.error`Error during exit: ${e}`,YZ?YZ(1):H.exit(1)})}))}function QZ(e,t){if(typeof e!=`function`)throw TypeError(`callback must be a function`);if(qZ)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}),QMe();let n=t?.wait??0,r=t?.streams??[H.stdout,H.stderr];if(n>0){let t=[e,n];WZ.add(t);for(let e of r)KZ.add(e);return()=>{WZ.delete(t);for(let e of r)KZ.delete(e)}}return GZ.add(e),()=>{GZ.delete(e)}}function $Z(e){e!==void 0&&(H.exitCode=e),ZZ(!0,!1,-128)}const eQ=`${hn.internalEnvPrefix}CLIENT_KIND`;function $Me(){let e=process.env[eQ]?.trim();if(!e)return tt.CLI;try{return nt(e)}catch{throw Error(`Invalid ${eQ} value: ${e}. Expected one of ${Object.values(tt).join(`, `)}.`)}}function tQ(e){process.stdout.write(JSON.stringify(e)+`
|
|
75145
75145
|
`)}function eNe(e){try{return JSON.parse(e)}catch{return null}}async function tNe({agentArgs:e}){Al(`ndjson IPC host started`,`cli`);let t=$Me(),n=await PJ.create(),r=new Ul(n,Sn(),gn.userAgentNames.desktop,OZ.default.version);if(!n.isAuthenticated())try{(await r.getUserInfo())?.result?.email||(process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
|
|
75146
75146
|
`),process.exit(1))}catch{process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
|