@abacus-ai/cli 2.2.12 → 2.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +2 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -85589,9 +85589,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
|
|
|
85589
85589
|
`:`
|
|
85590
85590
|
`)+n,i=r+1,r=e.indexOf(`
|
|
85591
85591
|
`,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:GP,stderr:KP}=HP,qP=Symbol(`GENERATOR`),JP=Symbol(`STYLER`),YP=Symbol(`IS_EMPTY`),XP=[`ansi`,`ansi`,`ansi256`,`ansi16m`],ZP=Object.create(null),QP=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=GP?GP.level:0;e.level=t.level===void 0?n:t.level},$P=e=>{let t=(...e)=>e.join(` `);return QP(t,e),Object.setPrototypeOf(t,eF.prototype),t};function eF(e){return $P(e)}Object.setPrototypeOf(eF.prototype,Function.prototype);for(let[e,t]of Object.entries(FP))ZP[e]={get(){let n=iF(this,rF(t.open,t.close,this[JP]),this[YP]);return Object.defineProperty(this,e,{value:n}),n}};ZP.visible={get(){let e=iF(this,this[JP],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};const tF=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?FP[n].ansi16m(...r):t===`ansi256`?FP[n].ansi256(FP.rgbToAnsi256(...r)):FP[n].ansi(FP.rgbToAnsi(...r)):e===`hex`?tF(`rgb`,t,n,...FP.hexToRgb(...r)):FP[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){ZP[e]={get(){let{level:t}=this;return function(...n){let r=rF(tF(e,XP[t],`color`,...n),FP.color.close,this[JP]);return iF(this,r,this[YP])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);ZP[t]={get(){let{level:t}=this;return function(...n){let r=rF(tF(e,XP[t],`bgColor`,...n),FP.bgColor.close,this[JP]);return iF(this,r,this[YP])}}}}const nF=Object.defineProperties(()=>{},{...ZP,level:{enumerable:!0,get(){return this[qP].level},set(e){this[qP].level=e}}}),rF=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},iF=(e,t,n)=>{let r=(...e)=>aF(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,nF),r[qP]=e,r[JP]=t,r[YP]=n,r},aF=(e,t)=>{if(e.level<=0||!t)return e[YP]?``:t;let n=e[JP];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=UP(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
85592
|
-
`);return a!==-1&&(t=WP(t,i,r,a)),r+t+i};Object.defineProperties(eF.prototype,ZP);const oF=eF();eF({level:KP?KP.level:0});var sF=W(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.2.
|
|
85593
|
-
`)){let n=e.trim();n&&(a.push(n),t(n))}};n.stdout?.on(`data`,o),n.stderr?.on(`data`,o);let s=null;n.on(`error`,t=>{e({ok:!1,output:t.message})}),n.on(`exit`,e=>{s=e}),n.on(`close`,()=>{e({ok:s===0,output:a.join(`
|
|
85594
|
-
`)})})})}async function wF(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let n=w.join(t.tmpdir(),`abacusai-update-${Date.now()}`),r=w.join(t.homedir(),`.${Re.configDirName}`,`bin`),i=process.platform===`win32`,a=i?`${Re.binName}.exe`:Re.binName;try{await z.mkdir(n,{recursive:!0});let t=w.join(n,i?`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 z.writeFile(t,s),d(i?`powershell -Command "Expand-Archive -Path '${t}' -DestinationPath '${n}' -Force"`:`tar -xzf "${t}" -C "${n}"`,{stdio:`pipe`});let c=w.join(n,a),l=w.join(r,a);return await z.copyFile(c,l),i||await z.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 z.rm(n,{recursive:!0,force:!0}).catch(()=>{})}}function TF(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 EF(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
|
|
85592
|
+
`);return a!==-1&&(t=WP(t,i,r,a)),r+t+i};Object.defineProperties(eF.prototype,ZP);const oF=eF();eF({level:KP?KP.level:0});var sF=W(((e,t)=>{t.exports={name:`@codellm/cli`,version:`2.2.13`,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/product":`workspace:*`,"@orpc/client":`catalog:`,"@orpc/contract":`catalog:`,"@orpc/server":`catalog:`,"@sentry/node-core":`^10.42.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`,chalk:`^5.6.2`,"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`}}})),cF=Oe(sF(),1);let lF=null;function uF(e){let t=(0,dP.prerelease)(e);return t&&t.length>0&&typeof t[0]==`string`?t[0]:`latest`}function dF(){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 fF(){if(process.versions.bun===void 0)return!1;let e=process.argv[1]??process.argv[0]??``;return/[/\\]\.abacusai[/\\]bin[/\\]/.test(e)}function pF(){let e=`${Re.internalEnvPrefix}DEV`,t=process.env[e];if(t===`1`||t===`true`)return!0;let n=process.argv[1]??``;try{n=x(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 mF(){return`${process.platform===`win32`?`win32`:process.platform===`darwin`?`darwin`:`linux`}-${process.arch===`arm64`?`arm64`:`x64`}`}function hF(){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 t=process.argv[1]??``;return t.includes(`yarn`)?`yarn`:t.includes(`pnpm`)?`pnpm`:t.includes(`bun`)?`bun`:`npm`}async function gF(e){let t=Date.now();if(lF&&t-lF.timestamp<6e4)return lF.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 lF={tags:r,timestamp:t},r}async function _F(e,t,n,r){let i=t??uF(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:hF(),isEphemeral:dF(),downloadUrl:c.result.url}}async function vF(e){let t=uF(e),n=hF(),r=dF(),i=(await gF(ze.publishName))[t];return!i&&t!==`latest`||!i||i===e?null:{currentVersion:e,latestVersion:i,tag:t,packageManager:n,isEphemeral:r}}async function yF(e,t,n){if(fF())try{return await _F(e,t,mF(),n)}catch{return null}return await vF(e)}function bF(){return`${Re.binName} upgrade`}function xF(e){let t=`${ze.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 SF(e){try{return d(xF(e),{stdio:`pipe`}),!0}catch{return!1}}function CF(e){try{return{ok:!0,output:d(xF(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 wF(e){if(!e.downloadUrl)return{ok:!1,output:`No download URL`};let n=w.join(t.tmpdir(),`abacusai-update-${Date.now()}`),r=w.join(t.homedir(),`.${Re.configDirName}`,`bin`),i=process.platform===`win32`,a=i?`${Re.binName}.exe`:Re.binName;try{await z.mkdir(n,{recursive:!0});let t=w.join(n,i?`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 z.writeFile(t,s),d(i?`powershell -Command "Expand-Archive -Path '${t}' -DestinationPath '${n}' -Force"`:`tar -xzf "${t}" -C "${n}"`,{stdio:`pipe`});let c=w.join(n,a),l=w.join(r,a);return await z.copyFile(c,l),i||await z.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 z.rm(n,{recursive:!0,force:!0}).catch(()=>{})}}function TF(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 EF(e,t){let n=(await e.listLLMModels())?.result??[];return n.length||(process.stderr.write(`Error: No models available.
|
|
85595
85593
|
`),process.exit(1)),t?TF(n,t.toLowerCase())||(process.stderr.write(`Warning: Model "${t}" not found. Using default: ${n[0].llmName}\n`),n[0].llmName):n[0].llmName}const DF=T.join(i(),Re.configDirName,Re.logsDirName),OF=T.join(DF,`cli.log`);let kF=!1;function AF(){if(!kF)try{v(DF)||y(DF,{recursive:!0}),kF=!0}catch{}}function jF(e){return e.length===0?``:` `+e.map(e=>{if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `)}function MF(e,t,n){AF();let r=`[${new Date().toISOString()}] [${e}] ${t instanceof Error?`${t.message}${t.stack?`
|
|
85596
85594
|
`+t.stack:``}`:String(t)}${jF(n)}\n`;try{g(OF,r)}catch{}}const NF={error(e,...t){MF(`ERROR`,e,t)},warn(e,...t){MF(`WARN`,e,t)},info(e,...t){MF(`INFO`,e,t)},debug(...e){MF(`DEBUG`,e[0]??``,e.slice(1))},trace(e,...t){MF(`TRACE`,e,t)}},PF=new Set,FF=new Set,IF=new Set;let LF=!1,RF=!1,zF=null,BF;async function VF(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 HF(e,t,n,r){if(LF)return;r?.debug?.(`Executing exit handlers`,{shouldManuallyExit:e,isSynchronous:t,signal:n,asyncCallbacks:PF.size,syncCallbacks:FF.size}),LF=!0,PF.size>0&&t&&console.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.`].join(` `));let i=0;n>0?i=128+n:BF===void 0?(typeof U.exitCode==`number`||typeof U.exitCode==`string`)&&(i=Number(U.exitCode)):i=BF;let a=(t=!1)=>{(t||e)&&(zF?zF.call(U,i):U.exit(i))};for(let e of FF)try{e(i)}catch(e){console.error(`Error in synchronous exit hook:`,e)}if(t){a();return}let o=[],s=0;for(let[e,t]of PF)s=Math.max(s,t),o.push(Promise.resolve(e(i)).catch(e=>{console.error(`Error in asynchronous exit hook:`,e)}));let c=Array.from(IF);c.length>0&&o.push(VF(c));let l=setTimeout(()=>{a(!0)},s);try{await Promise.all(o),clearTimeout(l),a()}catch(e){clearTimeout(l),console.error(`Error during exit cleanup:`,e),a(!0)}}function UF(){RF||(RF=!0,U.once(`beforeExit`,()=>{HF(!0,!1,-128)}),U.once(`SIGINT`,()=>{HF(!0,!1,2)}),U.once(`SIGTERM`,()=>{HF(!0,!1,15)}),U.once(`exit`,()=>{HF(!1,!0,0)}),U.on(`message`,e=>{e===`shutdown`&&HF(!0,!0,-128)}),zF||(zF=U.exit.bind(U),U.exit=function(e){if(BF===void 0&&(BF=e??0),PF.size===0&&IF.size===0){if(zF){zF(e??0);return}U.exit(e??0)}HF(!0,!1,-128).catch(e=>{console.error(`Error during exit:`,e),zF?zF(1):U.exit(1)})}))}function WF(e,t){if(typeof e!=`function`)throw TypeError(`callback must be a function`);if(LF)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}),UF();let n=t?.wait??0,r=t?.streams??[U.stdout,U.stderr];if(n>0){let t=[e,n];PF.add(t);for(let e of r)IF.add(e);return()=>{PF.delete(t);for(let e of r)IF.delete(e)}}return FF.add(e),()=>{FF.delete(e)}}function GF(e){e!==void 0&&(U.exitCode=e),HF(!0,!1,-128)}function KF(e){process.stdout.write(JSON.stringify(e)+`
|
|
85597
85595
|
`)}function qF(e){try{return JSON.parse(e)}catch{return null}}async function JF({agentArgs:e}){let t=await kP.create(),n=new Le(t,{error:(e,...t)=>NF.error(e,...t),debug:(...e)=>NF.debug(...e),warn:(e,...t)=>NF.warn(e,...t)});if(!t.isAuthenticated())try{(await n.getUserInfo())?.result?.email||(process.stderr.write(`Error: Not authenticated. Set ABACUS_DEVICE_CODE environment variable.
|
|
@@ -86000,7 +85998,7 @@ $$`:`${e}$$`},yne=e=>_ne(e)%2==0?e:vne(e),bne=(e,t,n)=>{if(e.substring(t+2).incl
|
|
|
86000
85998
|
▐▛▀▜▌▐▛▀▚▖▐▛▀▜▌▐▌ ▐▌ ▐▌ ▝▀▚▖ ▐▛▀▜▌ █ ▐▌ ▐▌ █
|
|
86001
85999
|
▐▌ ▐▌▐▙▄▞▘▐▌ ▐▌▝▚▄▄▖▝▚▄▞▘▗▄▄▞▘▗▖▐▌ ▐▌▗▄█▄▖ ▝▚▄▄▖▐▙▄▄▖▗▄█▄▖ `})}),(0,X.jsxs)($,{color:t.textMuted,children:[`v`,cF.default.version]})]})});T9.displayName=`Header`;const E9=`baking.beaming.booping.bouncing.brewing.bubbling.chasing.churning.coalescing.conjuring.cooking.crafting.crunching.cuddling.dancing.dazzling.discovering.doodling.dreaming.drifting.enchanting.exploring.finding.floating.fluttering.foraging.forging.frolicking.gathering.giggling.gliding.greeting.growing.hatching.herding.honking.hopping.hugging.humming.imagining.inventing.jingling.juggling.jumping.kindling.knitting.launching.leaping.mapping.marinating.meandering.mixing.moseying.munching.napping.nibbling.noodling.orbiting.painting.percolating.petting.plotting.pondering.popping.prancing.purring.puzzling.questing.riding.roaming.rolling.sauteeing.scribbling.seeking.shimmying.singing.skipping.sleeping.snacking.sniffing.snuggling.soaring.sparking.spinning.splashing.sprouting.squishing.stargazing.stirring.strolling.swimming.swinging.tickling.tinkering.toasting.tumbling.twirling.waddling.wandering.watching.weaving.whistling.wibbling.wiggling.wishing.wobbling.wondering.yawning.zooming`.split(`.`);function Vne(e){return e.charAt(0).toUpperCase()+e.slice(1)}function D9(){return E9[Math.floor(Math.random()*E9.length)]}function Hne(e,t){let[n,r]=(0,Z.useState)(0),i=(0,Z.useRef)(null);if((0,Z.useEffect)(()=>{if(!e)return;let t=setInterval(()=>{r(e=>e+1)},500);return()=>clearInterval(t)},[e]),!e)return null;let a=Date.now();if(t){if(i.current===null&&(i.current=t+5e3),a>i.current)return null;let n=t-e;return n<5e3?`thought`:`thought for ${B3(n)}`}i.current=null;let o=a-e;return o<5e3?`thinking`:`thinking for ${B3(o)}`}function Une(e){let[,t]=(0,Z.useState)(0);if((0,Z.useEffect)(()=>{if(!e)return;let n=setInterval(()=>t(e=>e+1),1e3);return()=>clearInterval(n)},[e]),!e)return null;let n=Date.now()-e;return n<5e3?null:B3(n)}const Wne=({status:e,thinkingStartTime:t,thinkingEndTime:n,runStartTime:r})=>{let{activity:i}=n2(),[a,o]=(0,Z.useState)(()=>D9()),s=(0,Z.useRef)(kl.Idle);(0,Z.useEffect)(()=>{s.current===kl.Idle&&e!==kl.Idle&&o(D9()),s.current=e},[e]);let c=Hne(t,n),l=Une(r);if(!(e!==kl.Idle&&e!==kl.WaitingForToolPermission))return null;let u=e===kl.LoadingConversation?`Resuming`:Vne(a);return(0,X.jsxs)(Q,{paddingLeft:1,flexDirection:`row`,gap:1,children:[(0,X.jsx)($,{color:`cyan`,children:i===`upload`?`↑`:i===`download`?`↓`:`•`}),(0,X.jsx)(p6,{text:`${u}...`}),c&&(0,X.jsxs)($,{color:`cyan`,children:[`(`,c,`)`]}),l&&!c&&(0,X.jsx)($,{dimColor:!0,children:l}),e!==kl.LoadingConversation&&(0,X.jsx)($,{dimColor:!0,children:`(esc/ctrl+c to interrupt)`})]})},O9=new Set([`read`,`grep`,`web_search`,`web_fetch`,`get_tab_content`,`bash_output`,`kill_shell`,`get_interactive_elements`,`navigate_to`,`new_tab`,`switch_active_tab`,`close_tab`,`refresh_tab`,`get_diagnostics`]);function k9(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function Gne(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.input??{}:t.input??{}:{}}function Kne(e){let t=k9(e),n=Gne(e),r=f4[t];if(!r)return``;try{return r.getHeaderParams(n)}catch{return``}}function qne(e){switch(e){case`read`:return`read`;case`grep`:return`search`;case`web_search`:return`web`;case`web_fetch`:return`fetch`;case`navigate_to`:case`new_tab`:case`switch_active_tab`:case`close_tab`:case`refresh_tab`:case`get_tab_content`:case`get_interactive_elements`:return`browser`;case`bash_output`:return`terminal`;case`kill_shell`:return`terminal`;case`get_diagnostics`:return`diag`;default:return`other`}}function Jne(e){let t=[];function n(e,n,r){let i=n+r;if(i===0)return;let a;if(r>0)switch(e){case`search`:a=i===1?`searching for 1 pattern`:`searching for ${i} patterns`;break;case`read`:a=i===1?`reading 1 file`:`reading ${i} files`;break;case`list`:a=i===1?`listing 1 directory`:`listing ${i} directories`;break;case`web`:a=i===1?`searching the web`:`searching the web ${i} times`;break;case`fetch`:a=i===1?`fetching 1 URL`:`fetching ${i} URLs`;break;case`browser`:a=i===1?`navigating browser`:`navigating browser ${i} times`;break;case`terminal`:a=`getting terminal output`;break;case`diag`:a=`checking diagnostics`;break;default:a=i===1?`1 operation`:`${i} operations`;break}else switch(e){case`search`:a=n===1?`searched for 1 pattern`:`searched for ${n} patterns`;break;case`read`:a=n===1?`read 1 file`:`read ${n} files`;break;case`list`:a=n===1?`listed 1 directory`:`listed ${n} directories`;break;case`web`:a=n===1?`searched the web`:`searched the web ${n} times`;break;case`fetch`:a=n===1?`fetched 1 URL`:`fetched ${n} URLs`;break;case`browser`:a=n===1?`navigated browser`:`navigated browser ${n} times`;break;case`terminal`:a=`got terminal output`;break;case`diag`:a=`checked diagnostics`;break;default:a=n===1?`1 operation`:`${n} operations`;break}t.push(a)}for(let t of[`search`,`read`,`list`,`web`,`fetch`,`browser`,`terminal`,`diag`,`other`]){let r=e[t];r&&n(t,r.completed,r.executing)}return t.join(`, `)}const A9=(0,Z.memo)(({segments:e})=>{let{colors:t}=eU(),n={},r=null,i=!1,a=!1;for(let t of e){let e=qne(k9(t)),o=!t.toolUseResult;if(n[e]||(n[e]={completed:0,executing:0}),o)n[e].executing++,r=t,i=!0;else{n[e].completed++;let r=t.toolUseResult;(r?.rejected||r?.content?.startsWith(`Error:`))&&(a=!0)}}let o=Jne(n),s=o.charAt(0).toUpperCase()+o.slice(1),c=r?Kne(r):null;return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsxs)(Q,{flexDirection:`row`,gap:1,alignItems:`center`,children:[i?(0,X.jsx)(TX,{}):(0,X.jsx)($,{color:a?`red`:i?`white`:`green`,children:`⏺`}),(0,X.jsxs)($,{children:[s,i?`…`:``]}),(0,X.jsx)($,{color:t.textMuted,dimColor:!0,children:`(ctrl+o to expand)`})]}),c&&(0,X.jsxs)(Q,{flexDirection:`row`,paddingLeft:2,children:[(0,X.jsxs)($,{color:t.textSubtle,dimColor:!0,children:[`⎿`,` `]}),(0,X.jsx)($,{color:t.textSubtle,children:c})]})]})});A9.displayName=`ToolGroupSummary`;const j9=(0,Z.memo)(({questions:e,onResolve:t})=>{let[n,r]=(0,Z.useState)(0),[i,a]=(0,Z.useState)(0),[o,s]=(0,Z.useState)(()=>new Map),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(()=>new Map),f=(0,Z.useRef)(null),p=(0,Z.useCallback)(e=>f.current?.getExpandedText(e)??e,[]),m=e[n],h=o.get(n)??new Set,g=(0,Z.useRef)(i);g.current=i;let _=(0,Z.useRef)(n);_.current=n;let v=(0,Z.useRef)(c);v.current=c;let y=(0,Z.useRef)(e);y.current=e;let b=(0,Z.useRef)(o);b.current=o;let x=(0,Z.useRef)(u);x.current=u;let S=(0,Z.useCallback)((e,t)=>{let n={};for(let r=0;r<y.current.length;r++){let i=y.current[r];if(!i)continue;let a=e.get(r);if(!a||a.size===0)continue;let o=[...a].sort((e,t)=>e-t).map(e=>i.options[e]?.label??``).filter(Boolean),s=t.get(r);n[`question_${r}`]=s?`${o.join(`, `)} — ${s}`:o.join(`, `)}return n},[]),C=(0,Z.useCallback)((e,n)=>{t({type:`question_answers`,answers:S(e,n)})},[t,S]),w=(0,Z.useCallback)((e,t,n)=>{e>=y.current.length?C(t,n):(r(e),a(0),l(!1))},[C]),T=(0,Z.useCallback)(()=>{let e=_.current;if(!y.current[e])return;let t=b.current,n=x.current;w(e+1,t,n)},[w]),E=(0,Z.useRef)(T);E.current=T;let D=(0,Z.useCallback)(e=>{if(e.key.return){let t=p(f.current?.text?.trim()??``),n=_.current,r=new Map(x.current);t?r.set(n,t):r.delete(n),d(r),l(!1),f.current?.setText(``),e.preventDefault();return}if(e.key.escape){l(!1),f.current?.setText(``),e.preventDefault();return}if(e.key.tab){l(!1),f.current?.setText(``),e.preventDefault();return}},[p]),O=(0,Z.useCallback)(e=>{let t=_.current,n=new Map(x.current),r=p(e.trim());r?n.set(t,r):n.delete(t),d(n),l(!1),f.current?.setText(``)},[p]);if(BV((0,Z.useCallback)((e,t)=>{if(v.current)return;let n=_.current,i=y.current[n];if(!i)return;let o=i.options.length;if(t.upArrow){a(e=>Math.max(0,e-1));return}if(t.downArrow){a(e=>Math.min(o-1,e+1));return}if(t.leftArrow){n>0&&(r(n-1),a(0),l(!1));return}if(t.rightArrow){n<y.current.length-1&&(r(n+1),a(0),l(!1));return}if(e===` `){let e=g.current,t=new Map(b.current),r=new Set(t.get(n)??[]);i.multiSelect?r.has(e)?r.delete(e):r.add(e):(r.clear(),r.add(e)),t.set(n,r),s(t);return}if(t.return){if((b.current.get(n)??new Set).size===0&&!i.multiSelect){let e=g.current,t=new Map(b.current),r=new Set([e]);t.set(n,r),s(t),w(n+1,t,x.current)}else E.current();return}if(t.tab){l(!0),setTimeout(()=>{let e=x.current.get(n)??``;f.current&&e&&f.current.setText(e)},0);return}if(t.escape){C(b.current,x.current);return}},[w,C]),{isActive:!c}),!m)return null;let k=u.get(n);return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(i6,{title:`Questions (${n+1}/${e.length}): ${m.header}`}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,X.jsx)($,{children:m.question})}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:m.options.map((e,t)=>{let n=t===i,r=h.has(t),a=m.multiSelect?r?`[x] `:`[ ] `:r?`◉ `:`○ `;return(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,X.jsxs)($,{color:r?`green`:n?void 0:`gray`,children:[a,e.label]}),e.description?(0,X.jsxs)($,{dimColor:!0,children:[` — `,e.description]}):null]},t)})}),c?(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:`cyan`,children:`❯ `}),(0,X.jsx)($,{dimColor:!0,children:`Note: `}),(0,X.jsx)(N3,{ref:f,flexGrow:1,maxWidth:`90%`,placeholder:`Add context or instructions…`,onSubmit:O,onKeyDown:D})]})}):(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingTop:1,children:k&&(0,X.jsxs)($,{dimColor:!0,children:[`Note: `,(0,X.jsx)($,{italic:!0,children:k})]})}),(0,X.jsx)(Q,{borderStyle:r6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`row`,paddingLeft:1,paddingBottom:1,gap:2,children:c?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`enter save note`}),(0,X.jsx)($,{dimColor:!0,children:`esc discard note`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`↑↓ option`}),(0,X.jsx)($,{dimColor:!0,children:`space select`}),(0,X.jsx)($,{dimColor:!0,children:`enter confirm`}),e.length>1&&(0,X.jsx)($,{dimColor:!0,children:`←→ navigate`}),(0,X.jsx)($,{dimColor:!0,children:`tab add note`}),(0,X.jsx)($,{dimColor:!0,children:`esc skip`})]})})]})});j9.displayName=`AskUserQuestionPermissionUI`;const M9=(0,Z.memo)(({option:e,index:t,isSelected:n,showAsInput:r,showAsEdit:i,inputPlaceholder:a,inputPrefix:o,inputBufferRef:s,editBufferRef:c,onInputSubmit:l,onInputKeyDown:u,onEditSubmit:d,onEditKeyDown:f})=>i?(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:`cyan`,children:`❯ `}),(0,X.jsx)($,{children:`${t+1}. `}),(0,X.jsx)(N3,{ref:c,flexGrow:1,maxWidth:`90%`,placeholder:`Edit rule...`,onSubmit:d,onKeyDown:f})]}):r?(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:`cyan`,children:`❯ `}),(0,X.jsx)($,{children:`${t+1}. ${o||``}`}),(0,X.jsx)(N3,{ref:s,flexGrow:1,maxWidth:`90%`,placeholder:a,onSubmit:l,onKeyDown:u})]}):(0,X.jsxs)(Q,{flexDirection:`row`,children:[(0,X.jsx)($,{color:n?`cyan`:void 0,children:n?`❯ `:` `}),(0,X.jsxs)($,{color:n?void 0:`gray`,children:[`${t+1}. ${e.label}`,e.hint&&!e.rules&&(0,X.jsxs)($,{dimColor:!0,children:[` (`,e.hint,`)`]})]})]}));M9.displayName=`PermissionOptionItem`;const N9=(0,Z.memo)(({options:e,onSelect:t,inputPlaceholder:n=`and tell AbacusAI`,onModeSwitch:r,modeSwitchHint:i})=>{let[a,o]=(0,Z.useState)(0),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useRef)(null),f=(0,Z.useRef)(null),p=(0,Z.useCallback)(e=>d.current?.getExpandedText(e)??e,[]),m=(0,Z.useCallback)(()=>{},[]),h=(0,Z.useRef)(``),g=(0,Z.useRef)(``),_=(0,Z.useMemo)(()=>e.filter(e=>e.value!==`input`),[e]),v=s,y=(0,Z.useRef)(a);y.current=a;let b=(0,Z.useRef)(_.length);b.current=_.length;let x=(0,Z.useRef)(v);x.current=v;let S=(0,Z.useRef)(l);S.current=l;let C=(0,Z.useRef)(t);C.current=t;let w=(0,Z.useRef)(r);w.current=r;let T=(0,Z.useRef)(_);T.current=_;let E=(0,Z.useCallback)(()=>{let e=T.current[y.current];if(e)if(x.current){let t=d.current?.text?.trim();if(t){let n=p(t),r=e.value===`accept`?`accept`:`reject`;C.current({decision:r,userMessage:n,rules:e.rules}),m()}}else e.value!==`input`&&C.current({decision:e.value,rules:e.rules})},[p,m]),D=(0,Z.useRef)(E);D.current=E;let O=(0,Z.useCallback)(e=>{if(e.trim()){let t=T.current[y.current],n=p(e.trim()),r=t?.value===`accept`?`accept`:`reject`;C.current({decision:r,userMessage:n,rules:t?.rules}),m()}},[p,m]),k=(0,Z.useCallback)(e=>{if(e.key.upArrow||e.key.downArrow){let t=T.current[y.current],n=d.current?.text||``;t?.value===`accept`?h.current=n:t?.value===`reject`&&(g.current=n),c(!1),e.key.upArrow?o(e=>Math.max(0,e-1)):o(e=>Math.min(b.current-1,e+1)),e.preventDefault();return}if(e.key.tab){let t=T.current[y.current];t?.value===`accept`?h.current=``:t?.value===`reject`&&(g.current=``),m(),c(!1),e.preventDefault();return}if(e.key.escape){m(),c(!1),C.current({decision:`reject`}),e.preventDefault();return}},[m]),A=(0,Z.useCallback)(e=>{let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);t.length!==0&&T.current[y.current]&&(t.length===1?C.current({decision:`allowAlwaysWithRule`,rules:t}):C.current({decision:`allowAlwaysWithRules`,rules:t}),u(!1))},[]),j=(0,Z.useCallback)(e=>{if(e.key.escape){u(!1),e.preventDefault();return}},[]);BV((0,Z.useCallback)((e,t)=>{if(!x.current&&!S.current){if(t.upArrow){o(e=>Math.max(0,e-1));return}if(t.downArrow){o(e=>Math.min(b.current-1,e+1));return}if(t.escape){C.current({decision:`reject`});return}if(t.tab&&t.shift){if(w.current){w.current();return}let e=T.current.findIndex(e=>e.value===`allowAlways`);e!==-1&&(o(e),setTimeout(()=>{C.current({decision:`allowAlways`})},0));return}if(t.tab){let e=T.current[y.current];if(e&&(e.value===`accept`||e.value===`reject`)){c(!0);let t=e.value===`accept`?h.current:g.current;setTimeout(()=>{d.current&&t&&d.current.setText(t)},0)}return}if(e===`e`||e===`E`){let e=T.current[y.current];if(e?.rules?.length){u(!0),setTimeout(()=>{f.current?.setText(e.rules.join(`, `))},0);return}}if(t.return){D.current();return}}},[]),{isActive:!0}),(0,Z.useEffect)(()=>{let e=_[a];e&&(e.value!==`accept`&&e.value!==`reject`||(e.value===`accept`?h.current:g.current)&&!s&&c(!0))},[a,_,s]);let M=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{s&&(M.current=!0)},[s]),(0,Z.useEffect)(()=>{if(!s||!M.current)return;let e=_[a];if(!e)return;let t=e.value===`accept`?h.current:e.value===`reject`?g.current:``;t?setTimeout(()=>{d.current&&d.current.text===``&&d.current.setText(t),M.current=!1},0):M.current=!1},[s,a,_]);let N=_[a],P=s&&N,F=e=>e.value===`accept`?`Yes, `:e.value===`reject`?`No, `:``,I=!s&&!l&&N&&(N.value===`accept`||N.value===`reject`),ee=!s&&!l&&!!N?.rules?.length,L=_.some(e=>e.value===`allowAlways`||e.value===`allowAlwaysWithRule`);return(0,X.jsxs)(Q,{flexDirection:`column`,children:[_.map((e,t)=>{let r=t===a,i=P&&r,o=e.value===`accept`?h.current:e.value===`reject`?g.current:``;return(0,X.jsx)(M9,{option:!i&&o?{...e,label:`${e.label}, ${o}`}:e,index:t,isSelected:r,showAsInput:i,showAsEdit:l&&r,editBufferRef:f,onEditSubmit:A,onEditKeyDown:j,inputPrefix:F(e),inputPlaceholder:n,inputBufferRef:d,onInputSubmit:O,onInputKeyDown:k},t)}),(0,X.jsx)(Q,{flexDirection:`row`,marginTop:1,gap:2,children:l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`enter confirm`}),(0,X.jsx)($,{dimColor:!0,children:`esc cancel`})]}):s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`enter submit`}),(0,X.jsx)($,{dimColor:!0,children:`tab discard note`}),(0,X.jsx)($,{dimColor:!0,children:`esc reject`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{dimColor:!0,children:`↑↓ navigate`}),(0,X.jsx)($,{dimColor:!0,children:`enter select`}),I&&(0,X.jsx)($,{dimColor:!0,children:`tab add note`}),ee&&(0,X.jsx)($,{dimColor:!0,children:`e edit rule`}),i&&(0,X.jsxs)($,{dimColor:!0,children:[`shift+tab `,i]}),!i&&L&&(0,X.jsx)($,{dimColor:!0,children:`shift+tab don't ask again`}),(0,X.jsx)($,{dimColor:!0,children:`esc reject`})]})})]})});N9.displayName=`PermissionOptions`;function P9(e){return e.decision===`accept`&&e.userMessage?{type:`accept_with_message`,message:e.userMessage}:e.decision===`reject`&&e.userMessage?{type:`reject_with_message`,message:e.userMessage}:e.decision===`allowAlwaysWithRule`?e.rules?.length?{type:`allow_always_with_rule`,rule:e.rules[0]}:`accept`:e.decision===`allowAlwaysWithRules`?e.rules?.length?{type:`allow_always_with_rules`,rules:e.rules}:`accept`:e.decision}const F9=(0,Z.memo)(({filePath:e,originalContent:t,newContent:n,diffShownInEditor:r,onResolve:i})=>{let a=!t,{agentMode:o}=GX(),s=[{label:`Yes, apply changes`,value:`accept`},...o===Ol.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}],c=e=>{i(P9(e))};return r?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(i6,{title:`${a?`Create`:`Update`} file ${e}`,subtitle:`Opened changes in the editor`}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(N9,{options:s,onSelect:c,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(i6,{title:`${a?`Create`:`Update`} file ${e}`}),a?lQ(e)?(0,X.jsx)(hQ,{content:n,maxLinesPerCell:100}):(0,X.jsx)(jX,{filePath:e,content:n,maxLines:100}):lQ(e)?(0,X.jsx)(fQ,{filePath:e,originalContent:t,newContent:n}):(0,X.jsx)(tQ,{filePath:e,originalContent:t,newContent:n,paddingLeft:1}),(0,X.jsx)(Q,{borderStyle:r6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(N9,{options:s,onSelect:c,onModeSwitch:()=>i(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});F9.displayName=`EditFilePermissionUI`;const I9=(0,Z.memo)(({filePath:e,originalContent:t,content:n,isNewFile:r,diffShownInEditor:i,onResolve:a})=>{let{agentMode:o}=GX(),s=[{label:`Yes, apply changes`,value:`accept`},...o===Ol.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}],c=e=>{a(P9(e))};return i?(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(i6,{title:`${r?`Create`:`Update`} file ${e}`,subtitle:`Opened changes in the editor`}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(N9,{options:s,onSelect:c,onModeSwitch:()=>a(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]}):(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(i6,{title:`${r?`Create`:`Update`} file ${e}`}),r?lQ(e)?(0,X.jsx)(hQ,{content:n,maxLinesPerCell:100}):(0,X.jsx)(jX,{filePath:e,content:n,maxLines:100}):lQ(e)?(0,X.jsx)(fQ,{filePath:e,originalContent:t,newContent:n}):(0,X.jsx)(tQ,{filePath:e,originalContent:t,newContent:n,paddingLeft:1}),(0,X.jsx)(Q,{borderStyle:r6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(N9,{options:s,onSelect:c,onModeSwitch:()=>a(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});I9.displayName=`WriteFilePermissionUI`;const L9=(0,Z.memo)(({description:e,url:t,displayName:n,onResolve:r})=>{let i=[{label:`Yes, allow action`,value:`accept`},{label:`Yes, and always allow ${n}`,value:`allowAlwaysWithRule`,rules:[n]},{label:`No, deny action`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(i6,{title:`Browser action: ${e}`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:e}),t&&(0,X.jsxs)($,{dimColor:!0,children:[`URL: `,t]})]}),(0,X.jsx)(Q,{borderStyle:r6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(N9,{options:i,onSelect:e=>{r(P9(e))}})})]})});L9.displayName=`BrowserActionPermissionUI`;const R9=(0,Z.memo)(({command:e,background:t,unmatchedPatterns:n,onResolve:r})=>{let{colors:i}=eU(),a=(0,Z.useMemo)(()=>pK(i),[i]),o=fh(e),s=(0,Z.useMemo)(()=>{let e=[{label:`Yes, run command`,value:`accept`}];if(n.length>1){e.push({label:`Yes, and always allow all: ${n.map(e=>`Bash(${e})`).join(`, `)}`,value:`allowAlwaysWithRules`,rules:n.map(e=>`Bash(${e})`)});for(let t of n)e.push({label:`Yes, and always allow Bash(${t})`,value:`allowAlwaysWithRule`,rules:[`Bash(${t})`]})}else n.length===1?e.push({label:`Yes, and always allow Bash(${n[0]})`,value:`allowAlwaysWithRule`,rules:[`Bash(${n[0]})`]}):e.push({label:`Yes, and always allow Bash(${o})`,value:`allowAlwaysWithRule`,rules:[`Bash(${o})`]});return e.push({label:`No, skip command`,value:`reject`}),e},[n,o]);return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(i6,{title:`Bash command`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:(0,dK.supportsLanguage)(`bash`)?(()=>{try{return(0,dK.highlight)(e,{language:`bash`,theme:a})}catch{return e}})():e}),t&&(0,X.jsx)(Q,{paddingTop:1,children:(0,X.jsx)($,{dimColor:!0,children:`(Running in background)`})})]}),(0,X.jsx)(Q,{borderStyle:r6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(N9,{options:s,onSelect:e=>{r(P9(e))},inputPlaceholder:`Type here to tell AbacusAI what to do differently`,onModeSwitch:()=>r(`allowAlways`),modeSwitchHint:`allow all tools`})})]})});R9.displayName=`RunTerminalPermissionUI`;const z9=(0,Z.memo)(({title:e,description:t,toolName:n,onResolve:r})=>{let{colors:i}=eU(),a=(0,Z.useMemo)(()=>pK(i),[i]),o=[{label:`Yes, allow`,value:`accept`},...n?[{label:`Yes, and always allow ${n}`,value:`allowAlwaysWithRule`,rules:[n]}]:[],{label:`No, deny`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(i6,{title:e}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,X.jsx)($,{children:(0,dK.supportsLanguage)(`json`)?(()=>{try{return(0,dK.highlight)(t,{language:`json`,theme:a})}catch{return t}})():t})}),(0,X.jsx)(Q,{borderStyle:r6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(N9,{options:o,onSelect:e=>{r(P9(e))}})})]})});z9.displayName=`GenericPermissionUI`;const B9=(0,Z.memo)(({planFilePath:e,planContent:t,onResolve:n})=>(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(i6,{title:`Ready to code? Implement plan: ${e.length>60?`…${e.slice(-60)}`:e}`}),t&&(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{dimColor:!0,children:`Here is Abacus's plan:`}),(0,X.jsx)(G7,{children:t})]}),(0,X.jsx)(Q,{borderStyle:r6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(N9,{options:[{label:`Yes, implement the plan (approve each edit)`,value:`accept`},{label:`Yes, implement the plan (auto-accept all edits)`,value:`allowAlways`,hint:`shift+tab`},{label:`No, keep planning`,value:`reject`}],onSelect:e=>{n(P9(e))},inputPlaceholder:`Add instructions for the implementation`})})]}));B9.displayName=`ExitPlanModePermissionUI`;const V9=(0,Z.memo)(({filePath:e,deducedDirectory:t,onResolve:n})=>{let r=[{label:`Yes, allow read`,value:`accept`},{label:`Yes, and always allow ${t}`,value:`allowAlways`},{label:`No, deny read`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(i6,{title:`Read file outside workspace`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:[(0,X.jsx)($,{children:e}),(0,X.jsxs)($,{dimColor:!0,children:[`Directory: `,t]})]}),(0,X.jsx)(Q,{borderStyle:r6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(N9,{options:r,onSelect:e=>{n(P9(e))}})})]})});V9.displayName=`ReadOutsideDirectoryPermissionUI`;const H9=(0,Z.memo)(({notebookPath:e,cellId:t,editMode:n,cellType:r,originalContent:i,newContent:a,onResolve:o})=>{let s=n??`replace`,c=``;c=s===`delete`?`Delete cell${t?` ${t}`:``}`:s===`insert`?`Insert new cell${t?` after ${t}`:` at beginning`} (${r??`code`})`:`Replace cell contents for cell ${t??`unknown`}`;let{agentMode:l}=GX(),u=[{label:`Yes, apply changes`,value:`accept`},...l===Ol.Normal?[{label:`Allow all edits during this session`,value:`allowAlways`}]:[],{label:`No, reject changes`,value:`reject`}];return(0,X.jsxs)(Q,{flexDirection:`column`,children:[(0,X.jsx)(i6,{title:`Edit notebook`}),(0,X.jsxs)(Q,{flexDirection:`column`,paddingLeft:1,children:[(0,X.jsx)($,{dimColor:!0,children:e}),(0,X.jsx)($,{dimColor:!0,children:c})]}),s===`delete`?(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,paddingY:1,children:(0,X.jsx)($,{color:`red`,children:`Cell will be deleted`})}):s===`insert`||!i?(0,X.jsx)(tQ,{filePath:sQ(r===`markdown`?`markdown`:`python`),originalContent:``,newContent:a,showHeader:!1,paddingLeft:1}):(0,X.jsx)(dQ,{cellIndex:0,cellType:r??`code`,cellId:t,language:r===`markdown`?`markdown`:`python`,originalSource:i,newSource:a,status:`modified`}),(0,X.jsx)(Q,{borderStyle:r6,borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1}),(0,X.jsx)(Q,{flexDirection:`column`,paddingLeft:1,children:(0,X.jsx)(N9,{options:u,onSelect:e=>{o(P9(e))},onModeSwitch:()=>o(`allowAlways`),modeSwitchHint:`auto-accept all edits`})})]})});H9.displayName=`NotebookEditPermissionUI`;const U9=(0,Z.memo)(({pendingTool:e})=>{let{request:t,resolve:n}=e;switch(t.type){case`edit_file`:return(0,X.jsx)(F9,{filePath:t.filePath,originalContent:t.originalContent,newContent:t.newContent,diffShownInEditor:t.diffShownInEditor,onResolve:n});case`write_file`:return(0,X.jsx)(I9,{filePath:t.filePath,originalContent:t.originalContent,content:t.content,isNewFile:t.isNewFile,diffShownInEditor:t.diffShownInEditor,onResolve:n});case`run_terminal`:return(0,X.jsx)(R9,{command:t.command,background:t.background,unmatchedPatterns:t.unmatchedPatterns,onResolve:n});case`browser_action`:return(0,X.jsx)(L9,{description:t.description,url:t.url,displayName:t.displayName,onResolve:n});case`generic`:return(0,X.jsx)(z9,{title:`Tool: ${t.toolName}`,description:t.inputSummary,toolName:t.toolName,onResolve:n});case`read_outside_directory`:return(0,X.jsx)(V9,{filePath:t.filePath,deducedDirectory:t.deducedDirectory,onResolve:n});case`exit_plan_mode`:return(0,X.jsx)(B9,{planFilePath:t.planFilePath,planContent:t.planContent,onResolve:n});case`ask_user_question`:return(0,X.jsx)(j9,{questions:t.questions,onResolve:n});case`notebook_edit`:return(0,X.jsx)(H9,{notebookPath:t.notebookPath,cellId:t.cellId,editMode:t.editMode,cellType:t.cellType,originalContent:t.originalContent,newContent:t.newContent,onResolve:n});default:return null}});U9.displayName=`ToolPermissionUI`;function Yne(e){let t=(0,Z.useRef)(!1),n=(0,Z.useRef)(e);(0,Z.useEffect)(()=>{n.current=e},[e]),(0,Z.useEffect)(()=>{let e=()=>{t.current||(t.current=!0,n.current())};return process.on(`exit`,e),process.on(`SIGINT`,e),process.on(`SIGTERM`,e),()=>{e(),process.off(`exit`,e),process.off(`SIGINT`,e),process.off(`SIGTERM`,e)}},[])}const W9=(0,Z.createContext)(null),G9=()=>{let e=(0,Z.use)(W9);if(!e)throw Error(`${G9.name} must be used within a ${K9.name}`);return e};function K9({children:e}){let t=(0,Z.useCallback)(e=>{let t=e.split(``).filter(e=>{let t=e.codePointAt(0);return!(t<=31||t===127)}).join(``);process.stdout.write(`${r2.SET_TITLE}${t}${r2.BEL}`)},[]);Yne(()=>{process.stdout.write(`${r2.SET_TITLE}${r2.BEL}`)});let n=(0,Z.useMemo)(()=>({setTitle:t}),[t]);return(0,X.jsx)(W9.Provider,{value:n,children:e})}const q9=2e3;function J9(e,t,n){return e===kl.ExecutingTool?`tool-executing`:e===kl.Submitted||e===kl.Streaming?`streaming`:e===kl.WaitingForToolPermission&&t?`permission-ui`:n()?`idle-with-text`:`idle-empty`}function Xne(e){let{agentStatus:t,hasPendingPermission:n,isExpandedView:r,composerHasText:i,hasQueuedMessages:a,stopAgent:o,rejectPermission:s,saveAndClearComposer:c,clearComposer:l,dequeueOne:u,clearQueue:d,exitApp:f}=e,[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(null),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useCallback)(()=>{m(!1),_.current&&=(clearTimeout(_.current),null)},[]),b=(0,Z.useCallback)(()=>{g(null),v.current&&=(clearTimeout(v.current),null)},[]),x=(0,Z.useCallback)(()=>{y(),b()},[y,b]),S=J9(t,n,i),C=(0,Z.useRef)(S);return(0,Z.useEffect)(()=>{let e=C.current;C.current=S,e!==S&&x()},[S,x]),BV((0,Z.useEffectEvent)((e,S)=>{if(S.ctrl&&e===`z`){process.platform!==`win32`&&process.kill(process.pid,`SIGTSTP`);return}let C=S.escape,w=S.ctrl&&e===`c`,T=S.ctrl&&e===`d`;if(!C&&!w&&!T||C&&r)return;let E=J9(t,n,i);if(E===`tool-executing`||E===`streaming`){x(),o();return}if(E===`permission-ui`){x(),s();return}if(E===`idle-with-text`){if(C){p?(l(),x()):(b(),m(!0),_.current=setTimeout(()=>{m(!1),_.current=null},q9));return}let e=w?`c`:`d`;if(h===e){x(),f();return}if(h!==null){b(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},q9);return}y(),c(),a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},q9);return}if(E===`idle-empty`){if(C){a()&&u();return}let e=w?`c`:`d`;if(h===e){x(),f();return}if(h!==null){b(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},q9);return}a()&&d(),g(e),v.current=setTimeout(()=>{g(null),v.current=null},q9)}}),{isActive:!0}),(0,Z.useEffect)(()=>()=>{_.current&&clearTimeout(_.current),v.current&&clearTimeout(v.current)},[]),{escClear:p,exitKey:h}}function Y9(e){return e.type===`code_llm_tool_call`||e.type===`code_llm_agent_tool_request`}function Zne(e){let t=e.toolUseResult;return!!(t?.rejected||t?.content?.startsWith(`Error:`))}function Qne(e){if(e.type!==`code_llm_notification`)return!1;let t=(e.message??``).toLowerCase();return t.includes(`compacting conversation`)||t.includes(`compacted conversation`)}function $ne(e){let t={toolUses:0,responses:0};for(let n of e)switch(n.type){case`code_llm_tool_call`:case`code_llm_agent_tool_request`:t.toolUses+=Array.isArray(n.toolUseRequest)?n.toolUseRequest.length:1;break;case`text`:n.source===`bot`&&t.responses++;break}return t}function ere(e,t){return{toolUses:e.toolUses+t.toolUses,responses:e.responses+t.responses}}function tre(e){let t={toolUses:0,responses:0},n=[],r=[],i=0,a=[];for(let a=0;a<e.length;a++){let o=e[a];if(Qne(o)){let e=$ne(n);t=ere(t,e),r.push(...n),n=[],i++;continue}n.push(o)}i>0&&a.push({kind:`compacted`,id:`compacted-${i}`,counts:t,segments:r});let o=nre(n);return a.push(...o),a}function nre(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.type===`thinking`){t.push({kind:`segment`,segment:r}),n++;continue}if(Y9(r)&&O9.has(X9(r))){let i=[r],a=n+1;for(;a<e.length;){let t=e[a];if(t.type===`thinking`){a++;continue}if(Zne(i[i.length-1]))break;if(Y9(t)&&O9.has(X9(t)))i.push(t),a++;else break}i.length===1?t.push({kind:`segment`,segment:i[0]}):t.push({kind:`tool-group`,id:i[0].id,segments:i}),n=a;continue}t.push({kind:`segment`,segment:r}),n++}return t}function X9(e){let t=e.toolUseRequest;return t?Array.isArray(t)?t[0]?.name??``:t.name??``:``}function rre(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type===`thinking`)return{thinkingStartTime:n.thinkingStartTime??null,thinkingEndTime:n.thinkingEndTime??null}}return{thinkingStartTime:null,thinkingEndTime:null}}function ire({timing:e}){let{setTitle:t}=G9(),{segments:n,agentStatus:r,pendingToolPermission:i,conversationTitle:a,conversationId:o,addNotification:s,stop:c,rejectPendingPermission:l,removeFirstFromQueue:u,clearQueue:d}=J2(),f=(0,Z.useRef)(null),{authExpired:p,clearAuthExpired:m,apiClient:h}=j2();(0,Z.useEffect)(()=>{p&&(s(`Session expired — use /login to authenticate again.`,`error`),m())},[p,s,m]);let[g,_]=(0,Z.useState)(null),v=(0,Z.useCallback)(()=>{_(e=>e===null?n.filter(e=>!e.temp&&!e.isSpinny):null)},[n]);BV((0,Z.useCallback)((e,t)=>{(t.ctrl||t.super)&&e===`o`&&v()},[v]),{isActive:g===null});let{lastItem:y,prevItems:b}=(0,Z.useMemo)(()=>{let e=tre(n.filter(e=>!e.temp&&!e.isSpinny));return{lastItem:e.at(-1)??null,prevItems:e.slice(0,-1)}},[n]),{thinkingStartTime:x,thinkingEndTime:S}=(0,Z.useMemo)(()=>rre(n),[n]),C=(0,Z.useRef)(kl.Idle),[w,T]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{let e=C.current===kl.Idle,t=r!==kl.Idle&&r!==kl.WaitingForToolPermission;e&&t?T(Date.now()):r===kl.Idle&&T(null),C.current=r},[r]);let E=r===kl.WaitingForToolPermission&&i!==null,[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(`0`),[j,M]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{t(a?`${a} • Abacus.AI CLI`:`Abacus.AI CLI`)},[a,t]),(0,Z.useEffect)(()=>WF(async()=>{let t=e.getFormattedDuration(),n=0;if(o)try{n=await T4(h,o)}catch{}M(n),A(t),O(!0),await new Promise(e=>setTimeout(e,100))},{wait:2e3,streams:[process.stdout,process.stderr]}),[e,o,h]);let N=Xne({agentStatus:r,hasPendingPermission:i!==null,isExpandedView:g!==null,composerHasText:()=>f.current?.hasText()??!1,hasQueuedMessages:()=>f.current?.hasQueue()??!1,stopAgent:c,rejectPermission:l,saveAndClearComposer:()=>f.current?.saveAndClear(),clearComposer:()=>f.current?.clear(),dequeueOne:u,clearQueue:d,exitApp:()=>GF(0)}),P=r!==kl.Idle&&r!==kl.WaitingForToolPermission,F=i?.request.tool.id??null;return g===null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Q,{flexDirection:`column`,gap:1,paddingBottom:1,width:`95%`,children:[(0,X.jsx)(T9,{}),(0,X.jsxs)(xX.Provider,{value:F,children:[b.map(e=>e.kind===`compacted`?(0,X.jsx)(h4,{counts:e.counts,segments:e.segments},e.id):e.kind===`segment`?(0,X.jsx)(t9,{segment:e.segment},e.segment.id):(0,X.jsx)(A9,{segments:e.segments},e.id)),y&&(y.kind===`compacted`?(0,X.jsx)(h4,{counts:y.counts,segments:y.segments},y.id):y.kind===`segment`?(0,X.jsx)(t9,{segment:y.segment},y.segment.id):(0,X.jsx)(A9,{segments:y.segments},y.id))]}),P&&(0,X.jsx)(A8,{onError:e=>{process.stderr.write(`[status-indicator error] ${e.stack??e.message}\n`)},children:(0,X.jsx)(Wne,{status:r,thinkingStartTime:x,thinkingEndTime:S,runStartTime:w})})]}),D?(0,X.jsx)(j8,{duration:k,credits:j,conversationId:o}):(0,X.jsxs)(X.Fragment,{children:[E&&(0,X.jsx)(A8,{onError:e=>{process.stderr.write(`[tool-permission error] ${e.stack??e.message}\n`)},children:(0,X.jsx)(U9,{pendingTool:i})}),(0,X.jsx)(Z.Activity,{mode:E?`hidden`:`visible`,children:(0,X.jsx)(A8,{fallback:e=>(0,X.jsxs)(Q,{flexDirection:`column`,paddingX:1,children:[(0,X.jsx)($,{color:`red`,bold:!0,children:`Something went wrong in the input area.`}),(0,X.jsx)($,{color:`yellow`,children:e.message}),(0,X.jsxs)($,{dimColor:!0,children:[`Press Escape to restart the CLI, or resume with: `,Re.binName,` -c`,` `,o]})]}),onError:e=>{process.stderr.write(`[composer error] ${e.stack??e.message}\n`)},children:(0,X.jsx)(k8,{hints:N,composerRef:f})})})]})]}):(0,X.jsx)(n9,{snapshot:g,onClose:()=>_(null)})}async function are({apiClient:e,authManager:t,configService:n,agentArgs:r}){let i,a=r?.[`permission-mode`];if(a)switch(a){case`yolo`:i=Ol.Yolo;break;case`accept-edits`:i=Ol.AcceptEdits;break;case`plan`:i=Ol.PlanMode;break;default:i=Ol.Normal;break}else r?.[`dangerously-skip-permissions`]?i=Ol.Yolo:r?.[`auto-accept-edits`]?i=Ol.AcceptEdits:r?.[`plan-mode`]&&(i=Ol.PlanMode);let o=process.stdout,s=e=>{o&&o.writable&&o.write(e)},c=()=>s(r2.HIDE_CURSOR),l=()=>s(r2.SHOW_CURSOR),u=!1;for(;;){u=!1;let a=new dee,o=new z3,s=null,d=()=>{u=!0,s?.unmount()};c();let f=IV((0,X.jsx)(Dee,{children:(0,X.jsx)(M2,{client:e,authManager:t,onAuthExpired:d,children:(0,X.jsx)(pee,{client:a,children:(0,X.jsx)(x4,{children:(0,X.jsx)(K9,{children:(0,X.jsx)(k2,{children:(0,X.jsx)(v4,{configService:n,children:(0,X.jsx)($0,{children:(0,X.jsx)(JX,{initialMode:i,children:(0,X.jsx)(t2,{children:(0,X.jsx)(q2,{apiClient:e,configService:n,agentArgs:r,children:(0,X.jsx)(ire,{timing:o})})})})})})})})})})})}),{exitOnCtrlC:!1,suspendable:!0,onSuspended:()=>{process.stderr.write(`
|
|
86002
86000
|
Abacus.AI has been suspended. Run \`fg\` to bring Abacus back.
|
|
86003
|
-
`)}});s=f;let p=!1,m=()=>{p||(p=!0,l())},h=()=>{p||(p=!0,f.cleanupTerminal())};if(process.once(`exit`,h),await f.waitUntilExit(),process.off(`exit`,h),m(),!u||!(await ML({authManager:t,apiClient:e,reason:`expired`,version:(await Promise.resolve().then(()=>Oe(sF()))).default.version})).success)break}}async function Z9(e){let{currentVersion:t,explicit:n=!1,autoUpdate:r=!0,updateChannel:i,baseUrl:a}=e;if(!n&&pF()||!n&&dF()||!n&&!r)return{action:`skipped`};let o;try{o=await yF(t,i,a)}catch{return n?(EL.error(`Failed to check for updates. Please check your network connection.`),{action:`exit`}):{action:`skipped`}}if(!o)return n&&EL.success(`Already up to date (${t})`),{action:`skipped`};let s=fF(),c=s?`Download v${o.latestVersion}`:xF(o);wL(`Update available: ${o.currentVersion} → ${o.latestVersion}`),s||SL(c,`Install command`);let l=await bL({message:`Would you like to update now?`,initialValue:!0});if(MI(l))return CL(`Update cancelled`),{action:`exit`};if(l){let e=kL();e.start(`Updating...`);let{ok:t,output:n}=s?await wF(o):
|
|
86001
|
+
`)}});s=f;let p=!1,m=()=>{p||(p=!0,l())},h=()=>{p||(p=!0,f.cleanupTerminal())};if(process.once(`exit`,h),await f.waitUntilExit(),process.off(`exit`,h),m(),!u||!(await ML({authManager:t,apiClient:e,reason:`expired`,version:(await Promise.resolve().then(()=>Oe(sF()))).default.version})).success)break}}async function Z9(e){let{currentVersion:t,explicit:n=!1,autoUpdate:r=!0,updateChannel:i,baseUrl:a}=e;if(!n&&pF()||!n&&dF()||!n&&!r)return{action:`skipped`};let o;try{o=await yF(t,i,a)}catch{return n?(EL.error(`Failed to check for updates. Please check your network connection.`),{action:`exit`}):{action:`skipped`}}if(!o)return n&&EL.success(`Already up to date (${t})`),{action:`skipped`};let s=fF(),c=s?`Download v${o.latestVersion}`:xF(o);wL(`Update available: ${o.currentVersion} → ${o.latestVersion}`),s||SL(c,`Install command`);let l=await bL({message:`Would you like to update now?`,initialValue:!0});if(MI(l))return CL(`Update cancelled`),{action:`exit`};if(l){let e=kL();e.start(`Updating...`);let{ok:t,output:n}=s?await wF(o):CF(o);if(t)return e.stop(`Updated to ${o.latestVersion}`),n&&SL(n,`Install output`),TL(`Restarting...`),{action:`updated`,version:o.latestVersion};{e.stop(`Update failed`),n&&SL(n,`Error output`),EL.error(`Update failed. You can try manually running the command above.`);let t=await bL({message:`Continue using v${o.currentVersion}?`,initialValue:!0});return MI(t)||!t?(CL(`Exiting`),{action:`exit`}):(TL(`Continuing with v${o.currentVersion}`),{action:`continue`})}}let u=await bL({message:`Continue using v${o.currentVersion}?`,initialValue:!0});return MI(u)||!u?(CL(`Exiting`),{action:`exit`}):(TL(`Continuing with v${o.currentVersion}`),{action:`continue`})}function Q9(e,t=1){throw console.error(oF.red(e)),GF(t),Error(e)}function ore(e){try{return new URL(e)}catch{Q9(`Invalid ${Re.envPrefix}BASE_URL: ${e}`)}}function sre(e){(e?.[`output-format`]||e?.[`input-format`])&&!e?.print&&Q9(`--output-format and --input-format flags can only be used with --print mode`)}async function cre(){let e=process.stdin;e.isTTY&&Q9(`No prompt provided and no piped input detected. Either provide a prompt or pipe input.`);let t=``;for await(let n of e)t+=n;let n=t.trim();return n||Q9(`No input provided`),n}async function lre(e){return e?.prompt?e.prompt:cre()}async function ure(e,t){let n=t.get(`baseUrl`);n&&(ore(n),e.setUrl(n),e.resetEndpoints(),await e.getApiEndpoint())}async function dre(e,t){if(e?.resume)return e.resume;if(e?.continue)try{return((await t.getConversationsList(Re.agentType))?.result??[]).sort((e,t)=>{let n=e.lastEventCreatedAt?new Date(e.lastEventCreatedAt).getTime():0;return(t.lastEventCreatedAt?new Date(t.lastEventCreatedAt).getTime():0)-n})[0]?.deploymentConversationId}catch{}}async function fre(e,t){if(t?.version){console.log(`Abacus.AI CLI version ${cF.default.version}`),GF(0);return}if(sre(t),t?.[`desktop-host`]){await JF({agentArgs:t});return}else if(t?.print){let e=await lre(t);await zL({agentArgs:{...t,prompt:e}})}else{let n=await kP.create(),r=new Le(n,{error:(e,...t)=>NF.error(e,...t),debug:(...e)=>NF.debug(...e),warn:(e,...t)=>NF.warn(e,...t)});if(await ure(r,e),!n.isAuthenticated()&&!n.isEnvAuth()&&((!process.stdin.isTTY||!process.stdout.isTTY)&&Q9(`Not authenticated. Set ${Re.envPrefix}API_KEY environment variable or run interactively to log in.`),!(await ML({authManager:n,apiClient:r,reason:`welcome`,version:cF.default.version})).success)){GF(0);return}let i=await dre(t,r);await are({apiClient:r,authManager:n,configService:e,agentArgs:{...t,...i&&{conversationId:i}}})}}function pre(){try{let e=d(`${process.platform===`win32`?`where`:`which`} ${Re.binName}`,{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim().split(`
|
|
86004
86002
|
`)[0]?.trim();if(e)return e}catch{}return Re.binName}function $9(e){let t=pre();return new Promise(n=>{let r=f(t,e,{stdio:`inherit`,env:{...process.env}});r.on(`error`,e=>{process.stderr.write(`Failed to relaunch CLI: ${e.message}\n`),process.stderr.write(`Please run "${Re.binName}" manually.\n`),n(1)}),r.on(`exit`,e=>n(e??0))})}async function mre(){let e=new Rj({cwd:process.cwd(),extraSources:[{read:async()=>({client:`cli`})}]});await e.load();let t=await Z9({currentVersion:cF.default.version,explicit:!0,updateChannel:e.get(`updateChannel`),baseUrl:e.get(`baseUrl`)});if(t.action===`updated`){let e=await $9(process.argv.slice(3));process.exit(e)}process.exit(t.action===`exit`?1:0)}async function hre(e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let t=await Z9({currentVersion:cF.default.version,autoUpdate:e.get(`autoUpdate`)!==!1,updateChannel:e.get(`updateChannel`),baseUrl:e.get(`baseUrl`)});if(t.action===`updated`){let e=await $9(process.argv.slice(2));process.exit(e)}t.action===`exit`&&process.exit(0)}if(process.argv[2]===`upgrade`)await mre();else{let{values:e,positionals:t}=A({options:{help:{type:`boolean`,short:`h`},version:{type:`boolean`,short:`v`},model:{type:`string`,short:`m`},print:{type:`boolean`,short:`p`},resume:{type:`string`},continue:{type:`boolean`,short:`c`},"output-format":{type:`string`},"input-format":{type:`string`},"allow-editing":{type:`string`},"auto-accept-edits":{type:`boolean`},"dangerously-skip-permissions":{type:`boolean`},"plan-mode":{type:`boolean`},"permission-mode":{type:`string`},"allowed-tools":{type:`string`,multiple:!0},"disallowed-tools":{type:`string`,multiple:!0},"add-dir":{type:`string`,multiple:!0},"desktop-host":{type:`boolean`}},allowPositionals:!0,strict:!0});e.help&&(console.log(`Usage: abacus [options] [prompt]
|
|
86005
86003
|
|
|
86006
86004
|
Commands:
|