@entrydesk/cli 1.30.0 → 1.32.0-beta
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/README.md +19 -0
- package/dist/agents-6VHSTGVU.js +43 -0
- package/dist/{billing-MGDBCV6I.js → billing-WA7WGH7U.js} +1 -1
- package/dist/{budget-YYGSDB4J.js → budget-PC4EAZLV.js} +1 -1
- package/dist/chunk-5QJUAR4K.js +120 -0
- package/dist/chunk-77D346VR.js +2 -0
- package/dist/chunk-JMYSCKCF.js +2 -0
- package/dist/config-ED6PZQ7J.js +4 -0
- package/dist/{config-help-RTQDCM2A.js → config-help-CTZHKILN.js} +1 -1
- package/dist/{connectors-EEPEIQ76.js → connectors-O4K2ZFDM.js} +8 -8
- package/dist/help-KDHCFJNF.js +4 -0
- package/dist/index.js +1 -1
- package/dist/login-LX3ISJEI.js +2 -0
- package/dist/logout-YNCDJ5ST.js +2 -0
- package/dist/{marketplace-5QZCY7QH.js → marketplace-FHSTOAWV.js} +8 -8
- package/dist/mcp-2G4B3BVK.js +4 -0
- package/dist/{meeting-5RUQYMWF.js → meeting-UBBSEEHT.js} +5 -5
- package/dist/models-PGGTDNI4.js +3 -0
- package/dist/{notifications-ZCJVVQIC.js → notifications-DHPLCJFY.js} +3 -3
- package/dist/{profile-RIAXCLXG.js → profile-K4V2Y63H.js} +1 -1
- package/dist/{recordings-FMD3YL7B.js → recordings-OXG66QN2.js} +3 -3
- package/dist/{schedules-JFVHBBM3.js → schedules-R4U37II4.js} +9 -9
- package/dist/{skills-L4AGJVTQ.js → skills-JVSRQSKA.js} +3 -3
- package/dist/status-S37SXIYD.js +2 -0
- package/dist/task-H2COR6Z4.js +180 -0
- package/dist/{tasks-7SK2EZZS.js → tasks-7NS4UOBP.js} +9 -9
- package/dist/tool-VLJFDXQ4.js +35 -0
- package/dist/update-5GLLNVRU.js +4 -0
- package/dist/{usage-6PXKAMOY.js → usage-PAL5KJ5C.js} +5 -5
- package/dist/version-ROABNJFL.js +2 -0
- package/dist/workflow-XERZYR3S.js +62 -0
- package/dist/{workspaces-EQSJKVVV.js → workspaces-PLJMIDJR.js} +3 -3
- package/package.json +6 -7
- package/dist/agents-JG6OXKYV.js +0 -43
- package/dist/chunk-LHRI5YM6.js +0 -2
- package/dist/chunk-NC63CPWW.js +0 -118
- package/dist/chunk-RJGB52EF.js +0 -4
- package/dist/chunk-ZIAOI7B2.js +0 -2
- package/dist/config-PBKYHI2B.js +0 -4
- package/dist/help-FBKSAMA7.js +0 -4
- package/dist/login-HL5KEHEN.js +0 -2
- package/dist/logout-QI7X4M4E.js +0 -2
- package/dist/mcp-5764U6QO.js +0 -4
- package/dist/models-PFIG6ACY.js +0 -3
- package/dist/status-DBKKDZAF.js +0 -2
- package/dist/task-PBX6HRS3.js +0 -194
- package/dist/token-5JSZTSX7.js +0 -2
- package/dist/token-util-U6DGFQDY.js +0 -2
- package/dist/tool-YOUXWQ76.js +0 -35
- package/dist/update-3SS5DWV3.js +0 -4
- package/dist/version-RYL2AKE2.js +0 -2
- package/dist/workflow-6MU3A6LB.js +0 -62
package/dist/task-PBX6HRS3.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as dr,b as mi,c as pr,d as fr,h as Ee,i as $s,j as $e,k as Me}from"./chunk-NC63CPWW.js";import{a as gt,b as mt,c as wi,f as Ae,g as kt,p as _e,s as gr,t as ye,v as mr}from"./chunk-RJGB52EF.js";import{b as cl,d as hl}from"./chunk-ZIAOI7B2.js";var Sr=cl((Xh,Ps)=>{"use strict";function br(t){return Array.isArray(t)?t:[t]}var ul=void 0,bi="",wr=" ",yi="\\",dl=/^\s+$/,pl=/(?:[^\\]|^)\\$/,fl=/^\\!/,gl=/^\\#/,ml=/\r?\n/g,wl=/^\.{0,2}\/|^\.{1,2}$/,yl=/\/$/,Be="/",xr="node-ignore";typeof Symbol<"u"&&(xr=Symbol.for("node-ignore"));var vr=xr,je=(t,e,s)=>(Object.defineProperty(t,e,{value:s}),s),bl=/([0-z])-([0-z])/g,Tr=()=>!1,xl=t=>t.replace(bl,(e,s,i)=>s.charCodeAt(0)<=i.charCodeAt(0)?e:bi),vl=t=>{let{length:e}=t;return t.slice(0,e-e%2)},Tl=[[/^\uFEFF/,()=>bi],[/((?:\\\\)*?)(\\?\s+)$/,(t,e,s)=>e+(s.indexOf("\\")===0?wr:bi)],[/(\\+?)\s/g,(t,e)=>{let{length:s}=e;return e.slice(0,s-s%2)+wr}],[/[\\$.|*+(){^]/g,t=>`\\${t}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(t,e,s)=>e+6<s.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(t,e,s)=>{let i=s.replace(/\\\*/g,"[^\\/]*");return e+i}],[/\\\\\\(?=[$.|*+(){^])/g,()=>yi],[/\\\\/g,()=>yi],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,i,r)=>e===yi?`\\[${s}${vl(i)}${r}`:r==="]"&&i.length%2===0?`[${xl(s)}${i}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`]],Cl=/(^|\\\/)?\\\*$/,Je="regex",As="checkRegex",yr="_",kl={[Je](t,e){return`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`},[As](t,e){return`${e?`${e}[^/]*`:"[^/]*"}(?=$|\\/$)`}},Sl=t=>Tl.reduce((e,[s,i])=>e.replace(s,i.bind(t)),t),_s=t=>typeof t=="string",El=t=>t&&_s(t)&&!dl.test(t)&&!pl.test(t)&&t.indexOf("#")!==0,$l=t=>t.split(ml).filter(Boolean),xi=class{constructor(e,s,i,r,n,o){this.pattern=e,this.mark=s,this.negative=n,je(this,"body",i),je(this,"ignoreCase",r),je(this,"regexPrefix",o)}get regex(){let e=yr+Je;return this[e]?this[e]:this._make(Je,e)}get checkRegex(){let e=yr+As;return this[e]?this[e]:this._make(As,e)}_make(e,s){let i=this.regexPrefix.replace(Cl,kl[e]),r=this.ignoreCase?new RegExp(i,"i"):new RegExp(i);return je(this,s,r)}},Al=({pattern:t,mark:e},s)=>{let i=!1,r=t;r.indexOf("!")===0&&(i=!0,r=r.substr(1)),r=r.replace(fl,"!").replace(gl,"#");let n=Sl(r);return new xi(t,e,r,s,i,n)},vi=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[vr]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(_s(e)&&(e={pattern:e}),El(e.pattern)){let s=Al(e,this._ignoreCase);this._added=!0,this._rules.push(s)}}add(e){return this._added=!1,br(_s(e)?$l(e):e).forEach(this._add,this),this._added}test(e,s,i){let r=!1,n=!1,o;this._rules.forEach(a=>{let{negative:c}=a;n===c&&r!==n||c&&!r&&!n&&!s||!a[i].test(e)||(r=!c,n=c,o=c?ul:a)});let l={ignored:r,unignored:n};return o&&(l.rule=o),l}},_l=(t,e)=>{throw new e(t)},ue=(t,e,s)=>_s(t)?t?ue.isNotRelative(t)?s(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:s("path must not be empty",TypeError):s(`path must be a string, but got \`${e}\``,TypeError),Cr=t=>wl.test(t);ue.isNotRelative=Cr;ue.convert=t=>t;var Ti=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:i=!1}={}){je(this,vr,!0),this._rules=new vi(s),this._strictPathCheck=!i,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,s,i,r){let n=e&&ue.convert(e);return ue(n,e,this._strictPathCheck?_l:Tr),this._t(n,s,i,r)}checkIgnore(e){if(!yl.test(e))return this.test(e);let s=e.split(Be).filter(Boolean);if(s.pop(),s.length){let i=this._t(s.join(Be)+Be,this._testCache,!0,s);if(i.ignored)return i}return this._rules.test(e,!1,As)}_t(e,s,i,r){if(e in s)return s[e];if(r||(r=e.split(Be).filter(Boolean)),r.pop(),!r.length)return s[e]=this._rules.test(e,i,Je);let n=this._t(r.join(Be)+Be,s,i,r);return s[e]=n.ignored?n:this._rules.test(e,i,Je)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return br(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},Ci=t=>new Ti(t),Pl=t=>ue(t&&ue.convert(t),t,Tr),kr=()=>{let t=s=>/^\\\\\?\\/.test(s)||/["<>|\u0000-\u001F]+/u.test(s)?s:s.replace(/\\/g,"/");ue.convert=t;let e=/^[a-z]:\//i;ue.isNotRelative=s=>e.test(s)||Cr(s)};typeof process<"u"&&process.platform==="win32"&&kr();Ps.exports=Ci;Ci.default=Ci;Ps.exports.isPathValid=Pl;je(Ps.exports,Symbol.for("setupWindows"),kr)});import{render as jh}from"ink";import{v4 as nl}from"uuid";import{exec as Xc}from"child_process";import Vc from"os";import Rl from"fs/promises";var _r=hl(Sr(),1);import Ke from"fs/promises";import Er from"os";import Ut from"path";function zt(t){let e=t.startsWith("~/")||t.startsWith("~\\")?Ut.join(Er.homedir(),t.slice(2)):t==="~"?Er.homedir():t;return Ut.resolve(e)}function $r(t){return t.normalize("NFC").replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/gu," ")}async function Xt(t){let e=zt(t);try{return await Ke.access(e),e}catch(s){if((s&&typeof s=="object"&&"code"in s?String(s.code):void 0)!=="ENOENT")throw s;let r=Ut.dirname(e),n=Ut.basename(e),o;try{o=await Ke.readdir(r)}catch{throw s}let l=$r(n),a=o.filter(d=>$r(d)===l),[c]=a;if(a.length===1&&c)return Ut.join(r,c);if(a.length>1){let d=new Error(`Multiple files match "${n}" after whitespace normalization: ${a.join(", ")}. Use filesystem__list_directory and pass an exact name.`);throw d.code="EAMBIG",d}throw s}}var ki=100*1024,Pr=50*1024,Ze=10*1024*1024,Ir=10,Si=100,Rr=10,We=10*1024*1024,Qe=3e4,Nr=3e5;function de(t,e=ki){return t.length>e?t.slice(0,e)+`
|
|
3
|
-
... [truncated, ${t.length-e} more characters]`:t}var Ar={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".pdf":"application/pdf"},Il=new Set([".txt",".md",".json",".js",".ts",".jsx",".tsx",".css",".scss",".html",".xml",".yaml",".yml",".toml",".ini",".cfg",".conf",".sh",".bash",".zsh",".fish",".py",".rb",".go",".rs",".java",".c",".cpp",".h",".hpp",".cs",".php",".sql",".graphql",".vue",".svelte",".astro",".env",".gitignore",".dockerignore",".editorconfig",".prettierrc",".eslintrc"]);async function Is(t){let e=Ut.extname(t).toLowerCase();if(Ar[e])return{type:"binary",mimeType:Ar[e]};if(Il.has(e))return{type:"text"};try{let s=await Ke.open(t,"r"),i=Buffer.alloc(8);if(await s.read(i,0,8,0),await s.close(),i[0]===137&&i[1]===80&&i[2]===78&&i[3]===71)return{type:"binary",mimeType:"image/png"};if(i[0]===255&&i[1]===216&&i[2]===255)return{type:"binary",mimeType:"image/jpeg"};if(i[0]===71&&i[1]===73&&i[2]===70&&i[3]===56)return{type:"binary",mimeType:"image/gif"};if(i[0]===37&&i[1]===80&&i[2]===68&&i[3]===70)return{type:"binary",mimeType:"application/pdf"};if(i[0]===82&&i[1]===73&&i[2]===70&&i[3]===70)return{type:"binary",mimeType:"image/webp"};for(let r of i)if(r===0)return{type:"binary"}}catch{}return{type:"text"}}async function Rs(t){let e=(0,_r.default)();e.add([".git","node_modules",".DS_Store"]);let s=t,i=[];for(;s!==Ut.dirname(s);){let r=Ut.join(s,".gitignore");try{await Ke.access(r),i.unshift(r)}catch{}s=Ut.dirname(s)}for(let r of i)try{let n=await Ke.readFile(r,"utf-8");e.add(n)}catch{}return e}function Ns(t,e,s){return t.filter(i=>{let r=Ut.relative(e,i);return!s.ignores(r.split(Ut.sep).join("/"))})}function Fr(t,e,s){let i=e.split(`
|
|
4
|
-
`),r=s.split(`
|
|
5
|
-
`),n=[`--- a/${Ut.basename(t)}`,`+++ b/${Ut.basename(t)}`],o=0,l=0;for(;o<i.length||l<r.length;){if(o<i.length&&l<r.length&&i[o]===r[l]){o++,l++;continue}let a=o,c=l,d=!1;for(let u=1;u<10&&!d;u++)for(let f=a;f<=a+u;f++){for(let w=c;w<=c+u;w++)if(f<i.length&&w<r.length&&i[f]===r[w]){let m=Math.max(0,a-3),y=Math.min(i.length,f+3),x=Math.max(0,c-3),C=Math.min(r.length,w+3);n.push(`@@ -${m+1},${y-m} +${x+1},${C-x} @@`);for(let k=m;k<a;k++)n.push(` ${i[k]}`);for(let k=a;k<f;k++)n.push(`-${i[k]}`);for(let k=c;k<w;k++)n.push(`+${r[k]}`);for(let k=f;k<Math.min(f+3,i.length);k++)k<y&&n.push(` ${i[k]}`);o=f,l=w,d=!0;break}if(d)break}if(!d){for(n.push(`@@ -${a+1},${i.length-a} +${c+1},${r.length-c} @@`);o<i.length;)n.push(`-${i[o]}`),o++;for(;l<r.length;)n.push(`+${r[l]}`),l++}}return n.join(`
|
|
6
|
-
`)}var Dr=async t=>{try{return await Rl.mkdir(zt(t.path),{recursive:!0}),{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to create directory"}}};import Or from"fs/promises";var Lr=async t=>{try{let e=await Xt(t.path),s=await Or.readFile(e,"utf-8"),i=s,r=[];for(let[o,l]of t.edits.entries()){let a=i.split(l.old_text).length-1;a===0?r.push({index:o,old_text:l.old_text.length>100?l.old_text.slice(0,100)+"...":l.old_text,reason:"Text not found in file. Ensure the old_text matches exactly, including whitespace and indentation."}):a>1&&r.push({index:o,old_text:l.old_text.length>100?l.old_text.slice(0,100)+"...":l.old_text,reason:`Found ${a} occurrences. The old_text must be unique. Include more surrounding context to make it unique.`})}if(r.length>0)return{success:!1,error:"Edit validation failed",errors:r};for(let o of t.edits)i=i.replace(o.old_text,o.new_text);let n=Fr(e,s,i);return t.dry_run?{success:!0,applied:0,dry_run:!0,diff:n}:(await Or.writeFile(e,i,"utf-8"),{success:!0,applied:t.edits.length,diff:n})}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to edit file"}}};import{exec as Nl}from"child_process";import{existsSync as Fl}from"fs";import Dl from"os";import{promisify as Ol}from"util";var Ll=Ol(Nl),Mr=async t=>{try{let e=zt(t.cwd||Dl.homedir());if(!Fl(e))return{success:!1,error:`Working directory does not exist: ${e}`};let s=Math.min(t.timeout??Qe,Nr),{stdout:i,stderr:r}=await Ll(t.command,{cwd:e,timeout:s,maxBuffer:Ze,shell:process.platform==="win32"?"cmd.exe":"/bin/bash"});return{success:!0,stdout:de(i),stderr:de(r)}}catch(e){let s=e;return{success:!1,exitCode:s.code,killed:s.killed,signal:s.signal,stdout:de(s.stdout||""),stderr:de(s.stderr||""),error:s.message||"Command execution failed"}}};import Ml from"fs/promises";var Br=async t=>{try{let e=await Ml.stat(await Xt(t.path));return{success:!0,info:{size:e.size,type:e.isDirectory()?"directory":e.isFile()?"file":e.isSymbolicLink()?"symlink":"unknown",created:e.birthtime.toISOString(),modified:e.mtime.toISOString(),accessed:e.atime.toISOString(),permissions:e.mode.toString(8)}}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to get file info"}}};import{execFile as Dc}from"child_process";import Oc from"fs/promises";import Yn from"path";import{promisify as Lc}from"util";import{fileURLToPath as Wa}from"url";import{posix as Ha,win32 as Di}from"path";import{fileURLToPath as Xa}from"url";import{lstatSync as Va,readdir as qa,readdirSync as Ya,readlinkSync as Ja,realpathSync as Ka}from"fs";import*as Za from"fs";import{lstat as Qa,readdir as tc,readlink as ec,realpath as sc}from"fs/promises";import{EventEmitter as Mi}from"events";import Sn from"stream";import{StringDecoder as ic}from"string_decoder";var cn=(t,e,s)=>{let i=t instanceof RegExp?jr(t,s):t,r=e instanceof RegExp?jr(e,s):e,n=i!==null&&r!=null&&Bl(i,r,s);return n&&{start:n[0],end:n[1],pre:s.slice(0,n[0]),body:s.slice(n[0]+i.length,n[1]),post:s.slice(n[1]+r.length)}},jr=(t,e)=>{let s=e.match(t);return s?s[0]:null},Bl=(t,e,s)=>{let i,r,n,o,l,a=s.indexOf(t),c=s.indexOf(e,a+1),d=a;if(a>=0&&c>0){if(t===e)return[a,c];for(i=[],n=s.length;d>=0&&!l;){if(d===a)i.push(d),a=s.indexOf(t,d+1);else if(i.length===1){let u=i.pop();u!==void 0&&(l=[u,c])}else r=i.pop(),r!==void 0&&r<n&&(n=r,o=c),c=s.indexOf(e,d+1);d=a<c&&a>=0?a:c}i.length&&o!==void 0&&(l=[n,o])}return l},hn="\0SLASH"+Math.random()+"\0",un="\0OPEN"+Math.random()+"\0",Oi="\0CLOSE"+Math.random()+"\0",dn="\0COMMA"+Math.random()+"\0",pn="\0PERIOD"+Math.random()+"\0",jl=new RegExp(hn,"g"),Wl=new RegExp(un,"g"),Ul=new RegExp(Oi,"g"),zl=new RegExp(dn,"g"),Gl=new RegExp(pn,"g"),Hl=/\\\\/g,Xl=/\\{/g,Vl=/\\}/g,ql=/\\,/g,Yl=/\\./g,Jl=1e5;function Ei(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function Kl(t){return t.replace(Hl,hn).replace(Xl,un).replace(Vl,Oi).replace(ql,dn).replace(Yl,pn)}function Zl(t){return t.replace(jl,"\\").replace(Wl,"{").replace(Ul,"}").replace(zl,",").replace(Gl,".")}function fn(t){if(!t)return[""];let e=[],s=cn("{","}",t);if(!s)return t.split(",");let{pre:i,body:r,post:n}=s,o=i.split(",");o[o.length-1]+="{"+r+"}";let l=fn(n);return n.length&&(o[o.length-1]+=l.shift(),o.push.apply(o,l)),e.push.apply(e,o),e}function Ql(t,e={}){if(!t)return[];let{max:s=Jl}=e;return t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),os(Kl(t),s,!0).map(Zl)}function ta(t){return"{"+t+"}"}function ea(t){return/^-?0\d/.test(t)}function sa(t,e){return t<=e}function ia(t,e){return t>=e}function os(t,e,s){let i=[],r=cn("{","}",t);if(!r)return[t];let n=r.pre,o=r.post.length?os(r.post,e,!1):[""];if(/\$$/.test(r.pre))for(let l=0;l<o.length&&l<e;l++){let a=n+"{"+r.body+"}"+o[l];i.push(a)}else{let l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),c=l||a,d=r.body.indexOf(",")>=0;if(!c&&!d)return r.post.match(/,(?!,).*\}/)?(t=r.pre+"{"+r.body+Oi+r.post,os(t,e,!0)):[t];let u;if(c)u=r.body.split(/\.\./);else if(u=fn(r.body),u.length===1&&u[0]!==void 0&&(u=os(u[0],e,!1).map(ta),u.length===1))return o.map(w=>r.pre+u[0]+w);let f;if(c&&u[0]!==void 0&&u[1]!==void 0){let w=Ei(u[0]),m=Ei(u[1]),y=Math.max(u[0].length,u[1].length),x=u.length===3&&u[2]!==void 0?Math.abs(Ei(u[2])):1,C=sa;m<w&&(x*=-1,C=ia);let k=u.some(ea);f=[];for(let S=w;C(S,m);S+=x){let $;if(a)$=String.fromCharCode(S),$==="\\"&&($="");else if($=String(S),k){let R=y-$.length;if(R>0){let Z=new Array(R+1).join("0");S<0?$="-"+Z+$.slice(1):$=Z+$}}f.push($)}}else{f=[];for(let w=0;w<u.length;w++)f.push.apply(f,os(u[w],e,!1))}for(let w=0;w<f.length;w++)for(let m=0;m<o.length&&i.length<e;m++){let y=n+f[w]+o[m];(!s||c||y)&&i.push(y)}}return i}var Gs=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")},ra={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},ts=t=>t.replace(/[[\]\\-]/g,"\\$&"),na=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Wr=t=>t.join(""),oa=(t,e)=>{let s=e;if(t.charAt(s)!=="[")throw new Error("not in a brace expression");let i=[],r=[],n=s+1,o=!1,l=!1,a=!1,c=!1,d=s,u="";t:for(;n<t.length;){let m=t.charAt(n);if((m==="!"||m==="^")&&n===s+1){c=!0,n++;continue}if(m==="]"&&o&&!a){d=n+1;break}if(o=!0,m==="\\"&&!a){a=!0,n++;continue}if(m==="["&&!a){for(let[y,[x,C,k]]of Object.entries(ra))if(t.startsWith(y,n)){if(u)return["$.",!1,t.length-s,!0];n+=y.length,k?r.push(x):i.push(x),l=l||C;continue t}}if(a=!1,u){m>u?i.push(ts(u)+"-"+ts(m)):m===u&&i.push(ts(m)),u="",n++;continue}if(t.startsWith("-]",n+1)){i.push(ts(m+"-")),n+=2;continue}if(t.startsWith("-",n+1)){u=m,n+=2;continue}i.push(ts(m)),n++}if(d<n)return["",!1,0,!1];if(!i.length&&!r.length)return["$.",!1,t.length-s,!0];if(r.length===0&&i.length===1&&/^\\?.$/.test(i[0])&&!c){let m=i[0].length===2?i[0].slice(-1):i[0];return[na(m),!1,d-s,!1]}let f="["+(c?"^":"")+Wr(i)+"]",w="["+(c?"":"^")+Wr(r)+"]";return[i.length&&r.length?"("+f+"|"+w+")":i.length?f:w,l,d-s,!0]},Ge=(t,{windowsPathsNoEscape:e=!1,magicalBraces:s=!0}={})=>s?e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):e?t.replace(/\[([^\/\\{}])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),la=new Set(["!","?","+","*","@"]),Ur=t=>la.has(t),aa="(?!(?:^|/)\\.\\.?(?:$|/))",Fs="(?!\\.)",ca=new Set(["[","."]),ha=new Set(["..","."]),ua=new Set("().*{}+?[]^$\\!"),da=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Li="[^/]",zr=Li+"*?",Gr=Li+"+?",gn=class Ht{type;#t;#s;#n=!1;#r=[];#o;#x;#w;#h=!1;#l;#d;#u=!1;constructor(e,s,i={}){this.type=e,e&&(this.#s=!0),this.#o=s,this.#t=this.#o?this.#o.#t:this,this.#l=this.#t===this?i:this.#t.#l,this.#w=this.#t===this?[]:this.#t.#w,e==="!"&&!this.#t.#h&&this.#w.push(this),this.#x=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#s!==void 0)return this.#s;for(let e of this.#r)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#s=!0;return this.#s}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#r.map(e=>String(e)).join("|")+")":this.#d=this.#r.map(e=>String(e)).join("")}#a(){if(this!==this.#t)throw new Error("should only call on root");if(this.#h)return this;this.toString(),this.#h=!0;let e;for(;e=this.#w.pop();){if(e.type!=="!")continue;let s=e,i=s.#o;for(;i;){for(let r=s.#x+1;!i.type&&r<i.#r.length;r++)for(let n of e.#r){if(typeof n=="string")throw new Error("string part in extglob AST??");n.copyIn(i.#r[r])}s=i,i=s.#o}}return this}push(...e){for(let s of e)if(s!==""){if(typeof s!="string"&&!(s instanceof Ht&&s.#o===this))throw new Error("invalid part: "+s);this.#r.push(s)}}toJSON(){let e=this.type===null?this.#r.slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...this.#r.map(s=>s.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#h&&this.#o?.type==="!")&&e.push({}),e}isStart(){if(this.#t===this)return!0;if(!this.#o?.isStart())return!1;if(this.#x===0)return!0;let e=this.#o;for(let s=0;s<this.#x;s++){let i=e.#r[s];if(!(i instanceof Ht&&i.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let e=this.#o?this.#o.#r.length:0;return this.#x===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let s=new Ht(this.type,e);for(let i of this.#r)s.copyIn(i);return s}static#i(e,s,i,r){let n=!1,o=!1,l=-1,a=!1;if(s.type===null){let w=i,m="";for(;w<e.length;){let y=e.charAt(w++);if(n||y==="\\"){n=!n,m+=y;continue}if(o){w===l+1?(y==="^"||y==="!")&&(a=!0):y==="]"&&!(w===l+2&&a)&&(o=!1),m+=y;continue}else if(y==="["){o=!0,l=w,a=!1,m+=y;continue}if(!r.noext&&Ur(y)&&e.charAt(w)==="("){s.push(m),m="";let x=new Ht(y,s);w=Ht.#i(e,x,w,r),s.push(x);continue}m+=y}return s.push(m),w}let c=i+1,d=new Ht(null,s),u=[],f="";for(;c<e.length;){let w=e.charAt(c++);if(n||w==="\\"){n=!n,f+=w;continue}if(o){c===l+1?(w==="^"||w==="!")&&(a=!0):w==="]"&&!(c===l+2&&a)&&(o=!1),f+=w;continue}else if(w==="["){o=!0,l=c,a=!1,f+=w;continue}if(Ur(w)&&e.charAt(c)==="("){d.push(f),f="";let m=new Ht(w,d);d.push(m),c=Ht.#i(e,m,c,r);continue}if(w==="|"){d.push(f),f="",u.push(d),d=new Ht(null,s);continue}if(w===")")return f===""&&s.#r.length===0&&(s.#u=!0),d.push(f),f="",s.push(...u,d),c;f+=w}return s.type=null,s.#s=void 0,s.#r=[e.substring(i-1)],c}static fromGlob(e,s={}){let i=new Ht(null,void 0,s);return Ht.#i(e,i,0,s),i}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let e=this.toString(),[s,i,r,n]=this.toRegExpSource();if(!(r||this.#s||this.#l.nocase&&!this.#l.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return i;let o=(this.#l.nocase?"i":"")+(n?"u":"");return Object.assign(new RegExp(`^${s}$`,o),{_src:s,_glob:e})}get options(){return this.#l}toRegExpSource(e){let s=e??!!this.#l.dot;if(this.#t===this&&this.#a(),!this.type){let a=this.isStart()&&this.isEnd()&&!this.#r.some(f=>typeof f!="string"),c=this.#r.map(f=>{let[w,m,y,x]=typeof f=="string"?Ht.#v(f,this.#s,a):f.toRegExpSource(e);return this.#s=this.#s||y,this.#n=this.#n||x,w}).join(""),d="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&ha.has(this.#r[0]))){let f=ca,w=s&&f.has(c.charAt(0))||c.startsWith("\\.")&&f.has(c.charAt(2))||c.startsWith("\\.\\.")&&f.has(c.charAt(4)),m=!s&&!e&&f.has(c.charAt(0));d=w?aa:m?Fs:""}let u="";return this.isEnd()&&this.#t.#h&&this.#o?.type==="!"&&(u="(?:$|\\/)"),[d+c+u,Ge(c),this.#s=!!this.#s,this.#n]}let i=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",n=this.#p(s);if(this.isStart()&&this.isEnd()&&!n&&this.type!=="!"){let a=this.toString();return this.#r=[a],this.type=null,this.#s=void 0,[a,Ge(this.toString()),!1,!1]}let o=!i||e||s||!Fs?"":this.#p(!0);o===n&&(o=""),o&&(n=`(?:${n})(?:${o})*?`);let l="";if(this.type==="!"&&this.#u)l=(this.isStart()&&!s?Fs:"")+Gr;else{let a=this.type==="!"?"))"+(this.isStart()&&!s&&!e?Fs:"")+zr+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;l=r+n+a}return[l,Ge(n),this.#s=!!this.#s,this.#n]}#p(e){return this.#r.map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[i,r,n,o]=s.toRegExpSource(e);return this.#n=this.#n||o,i}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")}static#v(e,s,i=!1){let r=!1,n="",o=!1,l=!1;for(let a=0;a<e.length;a++){let c=e.charAt(a);if(r){r=!1,n+=(ua.has(c)?"\\":"")+c;continue}if(c==="*"){if(l)continue;l=!0,n+=i&&/^[*]+$/.test(e)?Gr:zr,s=!0;continue}else l=!1;if(c==="\\"){a===e.length-1?n+="\\\\":r=!0;continue}if(c==="["){let[d,u,f,w]=oa(e,a);if(f){n+=d,o=o||u,a+=f-1,s=s||w;continue}}if(c==="?"){n+=Li,s=!0;continue}n+=da(c)}return[n,Ge(e),!!s,o]}},mn=(t,{windowsPathsNoEscape:e=!1,magicalBraces:s=!1}={})=>s?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&"),Bt=(t,e,s={})=>(Gs(e),!s.nocomment&&e.charAt(0)==="#"?!1:new ve(e,s).match(t)),pa=/^\*+([^+@!?\*\[\(]*)$/,fa=t=>e=>!e.startsWith(".")&&e.endsWith(t),ga=t=>e=>e.endsWith(t),ma=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),wa=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),ya=/^\*+\.\*+$/,ba=t=>!t.startsWith(".")&&t.includes("."),xa=t=>t!=="."&&t!==".."&&t.includes("."),va=/^\.\*+$/,Ta=t=>t!=="."&&t!==".."&&t.startsWith("."),Ca=/^\*+$/,ka=t=>t.length!==0&&!t.startsWith("."),Sa=t=>t.length!==0&&t!=="."&&t!=="..",Ea=/^\?+([^+@!?\*\[\(]*)?$/,$a=([t,e=""])=>{let s=wn([t]);return e?(e=e.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(e)):s},Aa=([t,e=""])=>{let s=yn([t]);return e?(e=e.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(e)):s},_a=([t,e=""])=>{let s=yn([t]);return e?i=>s(i)&&i.endsWith(e):s},Pa=([t,e=""])=>{let s=wn([t]);return e?i=>s(i)&&i.endsWith(e):s},wn=([t])=>{let e=t.length;return s=>s.length===e&&!s.startsWith(".")},yn=([t])=>{let e=t.length;return s=>s.length===e&&s!=="."&&s!==".."},bn=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Hr={win32:{sep:"\\"},posix:{sep:"/"}},Ia=bn==="win32"?Hr.win32.sep:Hr.posix.sep;Bt.sep=Ia;var Mt=Symbol("globstar **");Bt.GLOBSTAR=Mt;var Ra="[^/]",Na=Ra+"*?",Fa="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Da="(?:(?!(?:\\/|^)\\.).)*?",Oa=(t,e={})=>s=>Bt(s,t,e);Bt.filter=Oa;var Vt=(t,e={})=>Object.assign({},t,e),La=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return Bt;let e=Bt;return Object.assign((s,i,r={})=>e(s,i,Vt(t,r)),{Minimatch:class extends e.Minimatch{constructor(s,i={}){super(s,Vt(t,i))}static defaults(s){return e.defaults(Vt(t,s)).Minimatch}},AST:class extends e.AST{constructor(s,i,r={}){super(s,i,Vt(t,r))}static fromGlob(s,i={}){return e.AST.fromGlob(s,Vt(t,i))}},unescape:(s,i={})=>e.unescape(s,Vt(t,i)),escape:(s,i={})=>e.escape(s,Vt(t,i)),filter:(s,i={})=>e.filter(s,Vt(t,i)),defaults:s=>e.defaults(Vt(t,s)),makeRe:(s,i={})=>e.makeRe(s,Vt(t,i)),braceExpand:(s,i={})=>e.braceExpand(s,Vt(t,i)),match:(s,i,r={})=>e.match(s,i,Vt(t,r)),sep:e.sep,GLOBSTAR:Mt})};Bt.defaults=La;var xn=(t,e={})=>(Gs(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:Ql(t,{max:e.braceExpandMax}));Bt.braceExpand=xn;var Ma=(t,e={})=>new ve(t,e).makeRe();Bt.makeRe=Ma;var Ba=(t,e,s={})=>{let i=new ve(e,s);return t=t.filter(r=>i.match(r)),i.options.nonull&&!t.length&&t.push(e),t};Bt.match=Ba;var Xr=/[?*]|[+@!]\(.*?\)|\[|\]/,ja=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ve=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){Gs(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||bn,this.isWindows=this.platform==="win32";let s="allowWindowsEscape";this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e[s]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=e.windowsNoMagicRoot!==void 0?e.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let e of t)if(typeof e!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,e=this.options;if(!e.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let s=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,n,o)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=r[0]===""&&r[1]===""&&(r[2]==="?"||!Xr.test(r[2]))&&!Xr.test(r[3]),a=/^[a-z]:/i.test(r[0]);if(l)return[...r.slice(0,4),...r.slice(4).map(c=>this.parse(c))];if(a)return[r[0],...r.slice(1).map(c=>this.parse(c))]}return r.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let n=this.set[r];n[0]===""&&n[1]===""&&this.globParts[r][2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3])&&(n[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let s=0;s<t.length;s++)for(let i=0;i<t[s].length;i++)t[s][i]==="**"&&(t[s][i]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):e>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(e=>{let s=-1;for(;(s=e.indexOf("**",s+1))!==-1;){let i=s;for(;e[i+1]==="**";)i++;i!==s&&e.splice(s,i-s)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((s,i)=>{let r=s[s.length-1];return i==="**"&&r==="**"?s:i===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(s.pop(),s):(s.push(i),s)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let r=t[i];i===1&&r===""&&t[0]===""||(r==="."||r==="")&&(e=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let s=0;for(;(s=t.indexOf("..",s+1))!==-1;){let i=t[s-1];i&&i!=="."&&i!==".."&&i!=="**"&&(e=!0,t.splice(s-1,2),s-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let s of t){let i=-1;for(;(i=s.indexOf("**",i+1))!==-1;){let n=i;for(;s[n+1]==="**";)n++;n>i&&s.splice(i+1,n-i);let o=s[i+1],l=s[i+2],a=s[i+3];if(o!==".."||!l||l==="."||l===".."||!a||a==="."||a==="..")continue;e=!0,s.splice(i,1);let c=s.slice(0);c[i]="**",t.push(c),i--}if(!this.preserveMultipleSlashes){for(let n=1;n<s.length-1;n++){let o=s[n];n===1&&o===""&&s[0]===""||(o==="."||o==="")&&(e=!0,s.splice(n,1),n--)}s[0]==="."&&s.length===2&&(s[1]==="."||s[1]==="")&&(e=!0,s.pop())}let r=0;for(;(r=s.indexOf("..",r+1))!==-1;){let n=s[r-1];if(n&&n!=="."&&n!==".."&&n!=="**"){e=!0;let o=r===1&&s[r+1]==="**"?["."]:[];s.splice(r-1,2,...o),s.length===0&&s.push(""),r-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let s=e+1;s<t.length;s++){let i=this.partsMatch(t[e],t[s],!this.preserveMultipleSlashes);if(i){t[e]=[],t[s]=i;break}}return t.filter(e=>e.length)}partsMatch(t,e,s=!1){let i=0,r=0,n=[],o="";for(;i<t.length&&r<e.length;)if(t[i]===e[r])n.push(o==="b"?e[r]:t[i]),i++,r++;else if(s&&t[i]==="**"&&e[r]===t[i+1])n.push(t[i]),i++;else if(s&&e[r]==="**"&&t[i]===e[r+1])n.push(e[r]),r++;else if(t[i]==="*"&&e[r]&&(this.options.dot||!e[r].startsWith("."))&&e[r]!=="**"){if(o==="b")return!1;o="a",n.push(t[i]),i++,r++}else if(e[r]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(o==="a")return!1;o="b",n.push(e[r]),i++,r++}else return!1;return t.length===e.length&&n}parseNegate(){if(this.nonegate)return;let t=this.pattern,e=!1,s=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)e=!e,s++;s&&(this.pattern=t.slice(s)),this.negate=e}matchOne(t,e,s=!1){let i=this.options;if(this.isWindows){let m=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),y=!m&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),x=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),C=!x&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),k=y?3:m?0:void 0,S=C?3:x?0:void 0;if(typeof k=="number"&&typeof S=="number"){let[$,R]=[t[k],e[S]];$.toLowerCase()===R.toLowerCase()&&(e[S]=$,S>k?e=e.slice(S):k>S&&(t=t.slice(k)))}}let{optimizationLevel:r=1}=this.options;r>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var n=0,o=0,l=t.length,a=e.length;n<l&&o<a;n++,o++){this.debug("matchOne loop");var c=e[o],d=t[n];if(this.debug(e,c,d),c===!1)return!1;if(c===Mt){this.debug("GLOBSTAR",[e,c,d]);var u=n,f=o+1;if(f===a){for(this.debug("** at the end");n<l;n++)if(t[n]==="."||t[n]===".."||!i.dot&&t[n].charAt(0)===".")return!1;return!0}for(;u<l;){var w=t[u];if(this.debug(`
|
|
7
|
-
globstar while`,t,u,e,f,w),this.matchOne(t.slice(u),e.slice(f),s))return this.debug("globstar found match!",u,l,w),!0;if(w==="."||w===".."||!i.dot&&w.charAt(0)==="."){this.debug("dot detected!",t,u,e,f);break}this.debug("globstar swallow a segment, and continue"),u++}return!!(s&&(this.debug(`
|
|
8
|
-
>>> no match, partial?`,t,u,e,f),u===l))}let m;if(typeof c=="string"?(m=d===c,this.debug("string match",c,d,m)):(m=c.test(d),this.debug("pattern match",c,d,m)),!m)return!1}if(n===l&&o===a)return!0;if(n===l)return s;if(o===a)return n===l-1&&t[n]==="";throw new Error("wtf?")}braceExpand(){return xn(this.pattern,this.options)}parse(t){Gs(t);let e=this.options;if(t==="**")return Mt;if(t==="")return"";let s,i=null;(s=t.match(Ca))?i=e.dot?Sa:ka:(s=t.match(pa))?i=(e.nocase?e.dot?wa:ma:e.dot?ga:fa)(s[1]):(s=t.match(Ea))?i=(e.nocase?e.dot?Aa:$a:e.dot?_a:Pa)(s):(s=t.match(ya))?i=e.dot?xa:ba:(s=t.match(va))&&(i=Ta);let r=gn.fromGlob(t,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let e=this.options,s=e.noglobstar?Na:e.dot?Fa:Da,i=new Set(e.nocase?["i"]:[]),r=t.map(l=>{let a=l.map(d=>{if(d instanceof RegExp)for(let u of d.flags.split(""))i.add(u);return typeof d=="string"?ja(d):d===Mt?Mt:d._src});a.forEach((d,u)=>{let f=a[u+1],w=a[u-1];d!==Mt||w===Mt||(w===void 0?f!==void 0&&f!==Mt?a[u+1]="(?:\\/|"+s+"\\/)?"+f:a[u]=s:f===void 0?a[u-1]=w+"(?:\\/|\\/"+s+")?":f!==Mt&&(a[u-1]=w+"(?:\\/|\\/"+s+"\\/)"+f,a[u+1]=Mt))});let c=a.filter(d=>d!==Mt);if(this.partial&&c.length>=1){let d=[];for(let u=1;u<=c.length;u++)d.push(c.slice(0,u).join("/"));return"(?:"+d.join("|")+")"}return c.join("/")}).join("|"),[n,o]=t.length>1?["(?:",")"]:["",""];r="^"+n+r+o+"$",this.partial&&(r="^(?:\\/|"+n+r.slice(1,-1)+o+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&e)return!0;let s=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let r=this.set;this.debug(this.pattern,"set",r);let n=i[i.length-1];if(!n)for(let o=i.length-2;!n&&o>=0;o--)n=i[o];for(let o=0;o<r.length;o++){let l=r[o],a=i;if(s.matchBase&&l.length===1&&(a=[n]),this.matchOne(a,l,e))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(t){return Bt.defaults(t).Minimatch}};Bt.AST=gn;Bt.Minimatch=ve;Bt.escape=mn;Bt.unescape=Ge;var Ua=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,vn=new Set,Fi=typeof process=="object"&&process?process:{},Tn=(t,e,s,i)=>{typeof Fi.emitWarning=="function"?Fi.emitWarning(t,e,s,i):console.error(`[${s}] ${e}: ${t}`)},Hs=globalThis.AbortController,Vr=globalThis.AbortSignal;if(typeof Hs>"u"){Vr=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,i){this._onabort.push(i)}},Hs=class{constructor(){e()}signal=new Vr;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=!0;for(let i of this.signal._onabort)i(s);this.signal.onabort?.(s)}}};let t=Fi.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,Tn("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var za=t=>!vn.has(t),xe=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Cn=t=>xe(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Us:null:null,Us=class extends Array{constructor(t){super(t),this.fill(0)}},Ga=class ls{heap;length;static#t=!1;static create(e){let s=Cn(e);if(!s)return[];ls.#t=!0;let i=new ls(e,s);return ls.#t=!1,i}constructor(e,s){if(!ls.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new s(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Vs=class kn{#t;#s;#n;#r;#o;#x;#w;#h;get perf(){return this.#h}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#d;#u;#a;#i;#p;#v;#b;#f;#A;#g;#k;#S;#m;#y;#T;#E;#e;#F;static unsafeExposeInternals(e){return{starts:e.#S,ttls:e.#m,autopurgeTimers:e.#y,sizes:e.#k,keyMap:e.#u,keyList:e.#a,valList:e.#i,next:e.#p,prev:e.#v,get head(){return e.#b},get tail(){return e.#f},free:e.#A,isBackgroundFetch:s=>e.#c(s),backgroundFetch:(s,i,r,n)=>e.#U(s,i,r,n),moveToTail:s=>e.#O(s),indexes:s=>e.#P(s),rindexes:s=>e.#I(s),isStale:s=>e.#C(s)}}get max(){return this.#t}get maxSize(){return this.#s}get calculatedSize(){return this.#d}get size(){return this.#l}get fetchMethod(){return this.#x}get memoMethod(){return this.#w}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#o}constructor(e){let{max:s=0,ttl:i,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:l,allowStale:a,dispose:c,onInsert:d,disposeAfter:u,noDisposeOnSet:f,noUpdateTTL:w,maxSize:m=0,maxEntrySize:y=0,sizeCalculation:x,fetchMethod:C,memoMethod:k,noDeleteOnFetchRejection:S,noDeleteOnStaleGet:$,allowStaleOnFetchRejection:R,allowStaleOnFetchAbort:Z,ignoreFetchAbort:B,perf:I}=e;if(I!==void 0&&typeof I?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#h=I??Ua,s!==0&&!xe(s))throw new TypeError("max option must be a nonnegative integer");let g=s?Cn(s):Array;if(!g)throw new Error("invalid max value: "+s);if(this.#t=s,this.#s=m,this.maxEntrySize=y||this.#s,this.sizeCalculation=x,this.sizeCalculation){if(!this.#s&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(k!==void 0&&typeof k!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#w=k,C!==void 0&&typeof C!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#x=C,this.#E=!!C,this.#u=new Map,this.#a=new Array(s).fill(void 0),this.#i=new Array(s).fill(void 0),this.#p=new g(s),this.#v=new g(s),this.#b=0,this.#f=0,this.#A=Ga.create(s),this.#l=0,this.#d=0,typeof c=="function"&&(this.#n=c),typeof d=="function"&&(this.#r=d),typeof u=="function"?(this.#o=u,this.#g=[]):(this.#o=void 0,this.#g=void 0),this.#T=!!this.#n,this.#F=!!this.#r,this.#e=!!this.#o,this.noDisposeOnSet=!!f,this.noUpdateTTL=!!w,this.noDeleteOnFetchRejection=!!S,this.allowStaleOnFetchRejection=!!R,this.allowStaleOnFetchAbort=!!Z,this.ignoreFetchAbort=!!B,this.maxEntrySize!==0){if(this.#s!==0&&!xe(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!xe(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#G()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!$,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!l,this.ttlResolution=xe(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!xe(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#R()}if(this.#t===0&&this.ttl===0&&this.#s===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#s){let E="LRU_CACHE_UNBOUNDED";za(E)&&(vn.add(E),Tn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",E,kn))}}getRemainingTTL(e){return this.#u.has(e)?1/0:0}#R(){let e=new Us(this.#t),s=new Us(this.#t);this.#m=e,this.#S=s;let i=this.ttlAutopurge?new Array(this.#t):void 0;this.#y=i,this.#M=(o,l,a=this.#h.now())=>{if(s[o]=l!==0?a:0,e[o]=l,i?.[o]&&(clearTimeout(i[o]),i[o]=void 0),l!==0&&i){let c=setTimeout(()=>{this.#C(o)&&this.#_(this.#a[o],"expire")},l+1);c.unref&&c.unref(),i[o]=c}},this.#$=o=>{s[o]=e[o]!==0?this.#h.now():0},this.#N=(o,l)=>{if(e[l]){let a=e[l],c=s[l];if(!a||!c)return;o.ttl=a,o.start=c,o.now=r||n();let d=o.now-c;o.remainingTTL=a-d}};let r=0,n=()=>{let o=this.#h.now();if(this.ttlResolution>0){r=o;let l=setTimeout(()=>r=0,this.ttlResolution);l.unref&&l.unref()}return o};this.getRemainingTTL=o=>{let l=this.#u.get(o);if(l===void 0)return 0;let a=e[l],c=s[l];if(!a||!c)return 1/0;let d=(r||n())-c;return a-d},this.#C=o=>{let l=s[o],a=e[o];return!!a&&!!l&&(r||n())-l>a}}#$=()=>{};#N=()=>{};#M=()=>{};#C=()=>!1;#G(){let e=new Us(this.#t);this.#d=0,this.#k=e,this.#L=s=>{this.#d-=e[s],e[s]=0},this.#B=(s,i,r,n)=>{if(this.#c(i))return 0;if(!xe(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(i,s),!xe(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r},this.#D=(s,i,r)=>{if(e[s]=i,this.#s){let n=this.#s-e[s];for(;this.#d>n;)this.#W(!0)}this.#d+=e[s],r&&(r.entrySize=i,r.totalCalculatedSize=this.#d)}}#L=e=>{};#D=(e,s,i)=>{};#B=(e,s,i,r)=>{if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#P({allowStale:e=this.allowStale}={}){if(this.#l)for(let s=this.#f;!(!this.#j(s)||((e||!this.#C(s))&&(yield s),s===this.#b));)s=this.#v[s]}*#I({allowStale:e=this.allowStale}={}){if(this.#l)for(let s=this.#b;!(!this.#j(s)||((e||!this.#C(s))&&(yield s),s===this.#f));)s=this.#p[s]}#j(e){return e!==void 0&&this.#u.get(this.#a[e])===e}*entries(){for(let e of this.#P())this.#i[e]!==void 0&&this.#a[e]!==void 0&&!this.#c(this.#i[e])&&(yield[this.#a[e],this.#i[e]])}*rentries(){for(let e of this.#I())this.#i[e]!==void 0&&this.#a[e]!==void 0&&!this.#c(this.#i[e])&&(yield[this.#a[e],this.#i[e]])}*keys(){for(let e of this.#P()){let s=this.#a[e];s!==void 0&&!this.#c(this.#i[e])&&(yield s)}}*rkeys(){for(let e of this.#I()){let s=this.#a[e];s!==void 0&&!this.#c(this.#i[e])&&(yield s)}}*values(){for(let e of this.#P())this.#i[e]!==void 0&&!this.#c(this.#i[e])&&(yield this.#i[e])}*rvalues(){for(let e of this.#I())this.#i[e]!==void 0&&!this.#c(this.#i[e])&&(yield this.#i[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,s={}){for(let i of this.#P()){let r=this.#i[i],n=this.#c(r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,this.#a[i],this))return this.get(this.#a[i],s)}}forEach(e,s=this){for(let i of this.#P()){let r=this.#i[i],n=this.#c(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(s,n,this.#a[i],this)}}rforEach(e,s=this){for(let i of this.#I()){let r=this.#i[i],n=this.#c(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(s,n,this.#a[i],this)}}purgeStale(){let e=!1;for(let s of this.#I({allowStale:!0}))this.#C(s)&&(this.#_(this.#a[s],"expire"),e=!0);return e}info(e){let s=this.#u.get(e);if(s===void 0)return;let i=this.#i[s],r=this.#c(i)?i.__staleWhileFetching:i;if(r===void 0)return;let n={value:r};if(this.#m&&this.#S){let o=this.#m[s],l=this.#S[s];if(o&&l){let a=o-(this.#h.now()-l);n.ttl=a,n.start=Date.now()}}return this.#k&&(n.size=this.#k[s]),n}dump(){let e=[];for(let s of this.#P({allowStale:!0})){let i=this.#a[s],r=this.#i[s],n=this.#c(r)?r.__staleWhileFetching:r;if(n===void 0||i===void 0)continue;let o={value:n};if(this.#m&&this.#S){o.ttl=this.#m[s];let l=this.#h.now()-this.#S[s];o.start=Math.floor(Date.now()-l)}this.#k&&(o.size=this.#k[s]),e.unshift([i,o])}return e}load(e){this.clear();for(let[s,i]of e){if(i.start){let r=Date.now()-i.start;i.start=this.#h.now()-r}this.set(s,i.value,i)}}set(e,s,i={}){if(s===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:a}=i,{noUpdateTTL:c=this.noUpdateTTL}=i,d=this.#B(e,s,i.size||0,l);if(this.maxEntrySize&&d>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#_(e,"set"),this;let u=this.#l===0?void 0:this.#u.get(e);if(u===void 0)u=this.#l===0?this.#f:this.#A.length!==0?this.#A.pop():this.#l===this.#t?this.#W(!1):this.#l,this.#a[u]=e,this.#i[u]=s,this.#u.set(e,u),this.#p[this.#f]=u,this.#v[u]=this.#f,this.#f=u,this.#l++,this.#D(u,d,a),a&&(a.set="add"),c=!1,this.#F&&this.#r?.(s,e,"add");else{this.#O(u);let f=this.#i[u];if(s!==f){if(this.#E&&this.#c(f)){f.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=f;w!==void 0&&!o&&(this.#T&&this.#n?.(w,e,"set"),this.#e&&this.#g?.push([w,e,"set"]))}else o||(this.#T&&this.#n?.(f,e,"set"),this.#e&&this.#g?.push([f,e,"set"]));if(this.#L(u),this.#D(u,d,a),this.#i[u]=s,a){a.set="replace";let w=f&&this.#c(f)?f.__staleWhileFetching:f;w!==void 0&&(a.oldValue=w)}}else a&&(a.set="update");this.#F&&this.onInsert?.(s,e,s===f?"update":"replace")}if(r!==0&&!this.#m&&this.#R(),this.#m&&(c||this.#M(u,r,n),a&&this.#N(a,u)),!o&&this.#e&&this.#g){let f=this.#g,w;for(;w=f?.shift();)this.#o?.(...w)}return this}pop(){try{for(;this.#l;){let e=this.#i[this.#b];if(this.#W(!0),this.#c(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#e&&this.#g){let e=this.#g,s;for(;s=e?.shift();)this.#o?.(...s)}}}#W(e){let s=this.#b,i=this.#a[s],r=this.#i[s];return this.#E&&this.#c(r)?r.__abortController.abort(new Error("evicted")):(this.#T||this.#e)&&(this.#T&&this.#n?.(r,i,"evict"),this.#e&&this.#g?.push([r,i,"evict"])),this.#L(s),this.#y?.[s]&&(clearTimeout(this.#y[s]),this.#y[s]=void 0),e&&(this.#a[s]=void 0,this.#i[s]=void 0,this.#A.push(s)),this.#l===1?(this.#b=this.#f=0,this.#A.length=0):this.#b=this.#p[s],this.#u.delete(i),this.#l--,s}has(e,s={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:r}=s,n=this.#u.get(e);if(n!==void 0){let o=this.#i[n];if(this.#c(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#C(n))r&&(r.has="stale",this.#N(r,n));else return i&&this.#$(n),r&&(r.has="hit",this.#N(r,n)),!0}else r&&(r.has="miss");return!1}peek(e,s={}){let{allowStale:i=this.allowStale}=s,r=this.#u.get(e);if(r===void 0||!i&&this.#C(r))return;let n=this.#i[r];return this.#c(n)?n.__staleWhileFetching:n}#U(e,s,i,r){let n=s===void 0?void 0:this.#i[s];if(this.#c(n))return n;let o=new Hs,{signal:l}=i;l?.addEventListener("abort",()=>o.abort(l.reason),{signal:o.signal});let a={signal:o.signal,options:i,context:r},c=(y,x=!1)=>{let{aborted:C}=o.signal,k=i.ignoreFetchAbort&&y!==void 0,S=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&y!==void 0);if(i.status&&(C&&!x?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,k&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),C&&!k&&!x)return u(o.signal.reason,S);let $=w,R=this.#i[s];return(R===w||k&&x&&R===void 0)&&(y===void 0?$.__staleWhileFetching!==void 0?this.#i[s]=$.__staleWhileFetching:this.#_(e,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(e,y,a.options))),y},d=y=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=y),u(y,!1)),u=(y,x)=>{let{aborted:C}=o.signal,k=C&&i.allowStaleOnFetchAbort,S=k||i.allowStaleOnFetchRejection,$=S||i.noDeleteOnFetchRejection,R=w;if(this.#i[s]===w&&(!$||!x&&R.__staleWhileFetching===void 0?this.#_(e,"fetch"):k||(this.#i[s]=R.__staleWhileFetching)),S)return i.status&&R.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),R.__staleWhileFetching;if(R.__returned===R)throw y},f=(y,x)=>{let C=this.#x?.(e,n,a);C&&C instanceof Promise&&C.then(k=>y(k===void 0?void 0:k),x),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(y(void 0),i.allowStaleOnFetchAbort&&(y=k=>c(k,!0)))})};i.status&&(i.status.fetchDispatched=!0);let w=new Promise(f).then(c,d),m=Object.assign(w,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return s===void 0?(this.set(e,m,{...a.options,status:void 0}),s=this.#u.get(e)):this.#i[s]=m,m}#c(e){if(!this.#E)return!1;let s=e;return!!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Hs}async fetch(e,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:w=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:y,forceRefresh:x=!1,status:C,signal:k}=s;if(!this.#E)return C&&(C.fetch="get"),this.get(e,{allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:C});let S={allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:l,size:a,sizeCalculation:c,noUpdateTTL:d,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:m,ignoreFetchAbort:w,status:C,signal:k},$=this.#u.get(e);if($===void 0){C&&(C.fetch="miss");let R=this.#U(e,$,S,y);return R.__returned=R}else{let R=this.#i[$];if(this.#c(R)){let g=i&&R.__staleWhileFetching!==void 0;return C&&(C.fetch="inflight",g&&(C.returnedStale=!0)),g?R.__staleWhileFetching:R.__returned=R}let Z=this.#C($);if(!x&&!Z)return C&&(C.fetch="hit"),this.#O($),r&&this.#$($),C&&this.#N(C,$),R;let B=this.#U(e,$,S,y),I=B.__staleWhileFetching!==void 0&&i;return C&&(C.fetch=Z?"stale":"refresh",I&&Z&&(C.returnedStale=!0)),I?B.__staleWhileFetching:B.__returned=B}}async forceFetch(e,s={}){let i=await this.fetch(e,s);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(e,s={}){let i=this.#w;if(!i)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=s,l=this.get(e,o);if(!n&&l!==void 0)return l;let a=i(e,l,{options:o,context:r});return this.set(e,a,o),a}get(e,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=s,l=this.#u.get(e);if(l!==void 0){let a=this.#i[l],c=this.#c(a);return o&&this.#N(o,l),this.#C(l)?(o&&(o.get="stale"),c?(o&&i&&a.__staleWhileFetching!==void 0&&(o.returnedStale=!0),i?a.__staleWhileFetching:void 0):(n||this.#_(e,"expire"),o&&i&&(o.returnedStale=!0),i?a:void 0)):(o&&(o.get="hit"),c?a.__staleWhileFetching:(this.#O(l),r&&this.#$(l),a))}else o&&(o.get="miss")}#z(e,s){this.#v[s]=e,this.#p[e]=s}#O(e){e!==this.#f&&(e===this.#b?this.#b=this.#p[e]:this.#z(this.#v[e],this.#p[e]),this.#z(this.#f,e),this.#f=e)}delete(e){return this.#_(e,"delete")}#_(e,s){let i=!1;if(this.#l!==0){let r=this.#u.get(e);if(r!==void 0)if(this.#y?.[r]&&(clearTimeout(this.#y?.[r]),this.#y[r]=void 0),i=!0,this.#l===1)this.#H(s);else{this.#L(r);let n=this.#i[r];if(this.#c(n)?n.__abortController.abort(new Error("deleted")):(this.#T||this.#e)&&(this.#T&&this.#n?.(n,e,s),this.#e&&this.#g?.push([n,e,s])),this.#u.delete(e),this.#a[r]=void 0,this.#i[r]=void 0,r===this.#f)this.#f=this.#v[r];else if(r===this.#b)this.#b=this.#p[r];else{let o=this.#v[r];this.#p[o]=this.#p[r];let l=this.#p[r];this.#v[l]=this.#v[r]}this.#l--,this.#A.push(r)}}if(this.#e&&this.#g?.length){let r=this.#g,n;for(;n=r?.shift();)this.#o?.(...n)}return i}clear(){return this.#H("delete")}#H(e){for(let s of this.#I({allowStale:!0})){let i=this.#i[s];if(this.#c(i))i.__abortController.abort(new Error("deleted"));else{let r=this.#a[s];this.#T&&this.#n?.(i,r,e),this.#e&&this.#g?.push([i,r,e])}}if(this.#u.clear(),this.#i.fill(void 0),this.#a.fill(void 0),this.#m&&this.#S){this.#m.fill(0),this.#S.fill(0);for(let s of this.#y??[])s!==void 0&&clearTimeout(s);this.#y?.fill(void 0)}if(this.#k&&this.#k.fill(0),this.#b=0,this.#f=0,this.#A.length=0,this.#d=0,this.#l=0,this.#e&&this.#g){let s=this.#g,i;for(;i=s?.shift();)this.#o?.(...i)}}},qr=typeof process=="object"&&process?process:{stdout:null,stderr:null},rc=t=>!!t&&typeof t=="object"&&(t instanceof Xs||t instanceof Sn||nc(t)||oc(t)),nc=t=>!!t&&typeof t=="object"&&t instanceof Mi&&typeof t.pipe=="function"&&t.pipe!==Sn.Writable.prototype.pipe,oc=t=>!!t&&typeof t=="object"&&t instanceof Mi&&typeof t.write=="function"&&typeof t.end=="function",pe=Symbol("EOF"),fe=Symbol("maybeEmitEnd"),be=Symbol("emittedEnd"),Ds=Symbol("emittingEnd"),es=Symbol("emittedError"),Os=Symbol("closed"),Yr=Symbol("read"),Ls=Symbol("flush"),Jr=Symbol("flushChunk"),te=Symbol("encoding"),Ue=Symbol("decoder"),_t=Symbol("flowing"),ss=Symbol("paused"),ze=Symbol("resume"),Pt=Symbol("buffer"),Lt=Symbol("pipes"),It=Symbol("bufferLength"),$i=Symbol("bufferPush"),Ms=Symbol("bufferShift"),Dt=Symbol("objectMode"),Ct=Symbol("destroyed"),Ai=Symbol("error"),_i=Symbol("emitData"),Kr=Symbol("emitEnd"),Pi=Symbol("emitEnd2"),re=Symbol("async"),Ii=Symbol("abort"),Bs=Symbol("aborted"),is=Symbol("signal"),Pe=Symbol("dataListeners"),Gt=Symbol("discarded"),rs=t=>Promise.resolve().then(t),lc=t=>t(),ac=t=>t==="end"||t==="finish"||t==="prefinish",cc=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,hc=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),En=class{src;dest;opts;ondrain;constructor(t,e,s){this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[ze](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},uc=class extends En{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,s){super(t,e,s),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},dc=t=>!!t.objectMode,pc=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Xs=class extends Mi{[_t]=!1;[ss]=!1;[Lt]=[];[Pt]=[];[Dt];[te];[re];[Ue];[pe]=!1;[be]=!1;[Ds]=!1;[Os]=!1;[es]=null;[It]=0;[Ct]=!1;[is];[Bs]=!1;[Pe]=0;[Gt]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");dc(e)?(this[Dt]=!0,this[te]=null):pc(e)?(this[te]=e.encoding,this[Dt]=!1):(this[Dt]=!1,this[te]=null),this[re]=!!e.async,this[Ue]=this[te]?new ic(this[te]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Pt]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Lt]});let{signal:s}=e;s&&(this[is]=s,s.aborted?this[Ii]():s.addEventListener("abort",()=>this[Ii]()))}get bufferLength(){return this[It]}get encoding(){return this[te]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Dt]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[re]}set async(t){this[re]=this[re]||!!t}[Ii](){this[Bs]=!0,this.emit("abort",this[is]?.reason),this.destroy(this[is]?.reason)}get aborted(){return this[Bs]}set aborted(t){}write(t,e,s){if(this[Bs])return!1;if(this[pe])throw new Error("write after end");if(this[Ct])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(s=e,e="utf8"),e||(e="utf8");let i=this[re]?rs:lc;if(!this[Dt]&&!Buffer.isBuffer(t)){if(hc(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(cc(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Dt]?(this[_t]&&this[It]!==0&&this[Ls](!0),this[_t]?this.emit("data",t):this[$i](t),this[It]!==0&&this.emit("readable"),s&&i(s),this[_t]):t.length?(typeof t=="string"&&!(e===this[te]&&!this[Ue]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[te]&&(t=this[Ue].write(t)),this[_t]&&this[It]!==0&&this[Ls](!0),this[_t]?this.emit("data",t):this[$i](t),this[It]!==0&&this.emit("readable"),s&&i(s),this[_t]):(this[It]!==0&&this.emit("readable"),s&&i(s),this[_t])}read(t){if(this[Ct])return null;if(this[Gt]=!1,this[It]===0||t===0||t&&t>this[It])return this[fe](),null;this[Dt]&&(t=null),this[Pt].length>1&&!this[Dt]&&(this[Pt]=[this[te]?this[Pt].join(""):Buffer.concat(this[Pt],this[It])]);let e=this[Yr](t||null,this[Pt][0]);return this[fe](),e}[Yr](t,e){if(this[Dt])this[Ms]();else{let s=e;t===s.length||t===null?this[Ms]():typeof s=="string"?(this[Pt][0]=s.slice(t),e=s.slice(0,t),this[It]-=t):(this[Pt][0]=s.subarray(t),e=s.subarray(0,t),this[It]-=t)}return this.emit("data",e),!this[Pt].length&&!this[pe]&&this.emit("drain"),e}end(t,e,s){return typeof t=="function"&&(s=t,t=void 0),typeof e=="function"&&(s=e,e="utf8"),t!==void 0&&this.write(t,e),s&&this.once("end",s),this[pe]=!0,this.writable=!1,(this[_t]||!this[ss])&&this[fe](),this}[ze](){this[Ct]||(!this[Pe]&&!this[Lt].length&&(this[Gt]=!0),this[ss]=!1,this[_t]=!0,this.emit("resume"),this[Pt].length?this[Ls]():this[pe]?this[fe]():this.emit("drain"))}resume(){return this[ze]()}pause(){this[_t]=!1,this[ss]=!0,this[Gt]=!1}get destroyed(){return this[Ct]}get flowing(){return this[_t]}get paused(){return this[ss]}[$i](t){this[Dt]?this[It]+=1:this[It]+=t.length,this[Pt].push(t)}[Ms](){return this[Dt]?this[It]-=1:this[It]-=this[Pt][0].length,this[Pt].shift()}[Ls](t=!1){do;while(this[Jr](this[Ms]())&&this[Pt].length);!t&&!this[Pt].length&&!this[pe]&&this.emit("drain")}[Jr](t){return this.emit("data",t),this[_t]}pipe(t,e){if(this[Ct])return t;this[Gt]=!1;let s=this[be];return e=e||{},t===qr.stdout||t===qr.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[Lt].push(e.proxyErrors?new uc(this,t,e):new En(this,t,e)),this[re]?rs(()=>this[ze]()):this[ze]()),t}unpipe(t){let e=this[Lt].find(s=>s.dest===t);e&&(this[Lt].length===1?(this[_t]&&this[Pe]===0&&(this[_t]=!1),this[Lt]=[]):this[Lt].splice(this[Lt].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let s=super.on(t,e);if(t==="data")this[Gt]=!1,this[Pe]++,!this[Lt].length&&!this[_t]&&this[ze]();else if(t==="readable"&&this[It]!==0)super.emit("readable");else if(ac(t)&&this[be])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[es]){let i=e;this[re]?rs(()=>i.call(this,this[es])):i.call(this,this[es])}return s}removeListener(t,e){return this.off(t,e)}off(t,e){let s=super.off(t,e);return t==="data"&&(this[Pe]=this.listeners("data").length,this[Pe]===0&&!this[Gt]&&!this[Lt].length&&(this[_t]=!1)),s}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Pe]=0,!this[Gt]&&!this[Lt].length&&(this[_t]=!1)),e}get emittedEnd(){return this[be]}[fe](){!this[Ds]&&!this[be]&&!this[Ct]&&this[Pt].length===0&&this[pe]&&(this[Ds]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Os]&&this.emit("close"),this[Ds]=!1)}emit(t,...e){let s=e[0];if(t!=="error"&&t!=="close"&&t!==Ct&&this[Ct])return!1;if(t==="data")return!this[Dt]&&!s?!1:this[re]?(rs(()=>this[_i](s)),!0):this[_i](s);if(t==="end")return this[Kr]();if(t==="close"){if(this[Os]=!0,!this[be]&&!this[Ct])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[es]=s,super.emit(Ai,s);let r=!this[is]||this.listeners("error").length?super.emit("error",s):!1;return this[fe](),r}else if(t==="resume"){let r=super.emit("resume");return this[fe](),r}else if(t==="finish"||t==="prefinish"){let r=super.emit(t);return this.removeAllListeners(t),r}let i=super.emit(t,...e);return this[fe](),i}[_i](t){for(let s of this[Lt])s.dest.write(t)===!1&&this.pause();let e=this[Gt]?!1:super.emit("data",t);return this[fe](),e}[Kr](){return this[be]?!1:(this[be]=!0,this.readable=!1,this[re]?(rs(()=>this[Pi]()),!0):this[Pi]())}[Pi](){if(this[Ue]){let e=this[Ue].end();if(e){for(let s of this[Lt])s.dest.write(e);this[Gt]||super.emit("data",e)}}for(let e of this[Lt])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Dt]||(t.dataLength=0);let e=this.promise();return this.on("data",s=>{t.push(s),this[Dt]||(t.dataLength+=s.length)}),await e,t}async concat(){if(this[Dt])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[te]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Ct,()=>e(new Error("stream destroyed"))),this.on("error",s=>e(s)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[Gt]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let s=this.read();if(s!==null)return Promise.resolve({done:!1,value:s});if(this[pe])return e();let i,r,n=c=>{this.off("data",o),this.off("end",l),this.off(Ct,a),e(),r(c)},o=c=>{this.off("error",n),this.off("end",l),this.off(Ct,a),this.pause(),i({value:c,done:!!this[pe]})},l=()=>{this.off("error",n),this.off("data",o),this.off(Ct,a),e(),i({done:!0,value:void 0})},a=()=>n(new Error("stream destroyed"));return new Promise((c,d)=>{r=d,i=c,this.once(Ct,a),this.once("error",n),this.once("end",l),this.once("data",o)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Gt]=!1;let t=!1,e=()=>(this.pause(),this.off(Ai,e),this.off(Ct,e),this.off("end",e),t=!0,{done:!0,value:void 0}),s=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(Ai,e),this.once(Ct,e),{next:s,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Ct])return t?this.emit("error",t):this.emit(Ct),this;this[Ct]=!0,this[Gt]=!0,this[Pt].length=0,this[It]=0;let e=this;return typeof e.close=="function"&&!this[Os]&&e.close(),t?this.emit("error",t):this.emit(Ct),this}static get isStream(){return rc}},fc=Ka.native,as={lstatSync:Va,readdir:qa,readdirSync:Ya,readlinkSync:Ja,realpathSync:fc,promises:{lstat:Qa,readdir:tc,readlink:ec,realpath:sc}},$n=t=>!t||t===as||t===Za?as:{...as,...t,promises:{...as.promises,...t.promises||{}}},An=/^\\\\\?\\([a-z]:)\\?$/i,gc=t=>t.replace(/\//g,"\\").replace(An,"$1\\"),mc=/[\\\/]/,Yt=0,_n=1,Pn=2,ne=4,In=6,Rn=8,Ie=10,Nn=12,qt=15,ns=~qt,Ri=16,Zr=32,cs=64,ee=128,js=256,zs=512,Qr=cs|ee|zs,wc=1023,Ni=t=>t.isFile()?Rn:t.isDirectory()?ne:t.isSymbolicLink()?Ie:t.isCharacterDevice()?Pn:t.isBlockDevice()?In:t.isSocket()?Nn:t.isFIFO()?_n:Yt,tn=new Vs({max:2**12}),hs=t=>{let e=tn.get(t);if(e)return e;let s=t.normalize("NFKD");return tn.set(t,s),s},en=new Vs({max:2**12}),Ws=t=>{let e=en.get(t);if(e)return e;let s=hs(t.toLowerCase());return en.set(t,s),s},sn=class extends Vs{constructor(){super({max:256})}},yc=class extends Vs{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},Fn=Symbol("PathScurry setAsCwd"),Wt=class{name;root;roots;parent;nocase;isCWD=!1;#t;#s;get dev(){return this.#s}#n;get mode(){return this.#n}#r;get nlink(){return this.#r}#o;get uid(){return this.#o}#x;get gid(){return this.#x}#w;get rdev(){return this.#w}#h;get blksize(){return this.#h}#l;get ino(){return this.#l}#d;get size(){return this.#d}#u;get blocks(){return this.#u}#a;get atimeMs(){return this.#a}#i;get mtimeMs(){return this.#i}#p;get ctimeMs(){return this.#p}#v;get birthtimeMs(){return this.#v}#b;get atime(){return this.#b}#f;get mtime(){return this.#f}#A;get ctime(){return this.#A}#g;get birthtime(){return this.#g}#k;#S;#m;#y;#T;#E;#e;#F;#R;#$;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,e=Yt,s,i,r,n,o){this.name=t,this.#k=r?Ws(t):hs(t),this.#e=e&wc,this.nocase=r,this.roots=i,this.root=s||this,this.#F=n,this.#m=o.fullpath,this.#T=o.relative,this.#E=o.relativePosix,this.parent=o.parent,this.parent?this.#t=this.parent.#t:this.#t=$n(o.fs)}depth(){return this.#S!==void 0?this.#S:this.parent?this.#S=this.parent.depth()+1:this.#S=0}childrenCache(){return this.#F}resolve(t){if(!t)return this;let e=this.getRootString(t),s=t.substring(e.length).split(this.splitSep);return e?this.getRoot(e).#N(s):this.#N(s)}#N(t){let e=this;for(let s of t)e=e.child(s);return e}children(){let t=this.#F.get(this);if(t)return t;let e=Object.assign([],{provisional:0});return this.#F.set(this,e),this.#e&=~Ri,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let s=this.children(),i=this.nocase?Ws(t):hs(t);for(let l of s)if(l.#k===i)return l;let r=this.parent?this.sep:"",n=this.#m?this.#m+r+t:void 0,o=this.newChild(t,Yt,{...e,parent:this,fullpath:n});return this.canReaddir()||(o.#e|=ee),s.push(o),o}relative(){if(this.isCWD)return"";if(this.#T!==void 0)return this.#T;let t=this.name,e=this.parent;if(!e)return this.#T=this.name;let s=e.relative();return s+(!s||!e.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#E!==void 0)return this.#E;let t=this.name,e=this.parent;if(!e)return this.#E=this.fullpathPosix();let s=e.relativePosix();return s+(!s||!e.parent?"":"/")+t}fullpath(){if(this.#m!==void 0)return this.#m;let t=this.name,e=this.parent;if(!e)return this.#m=this.name;let s=e.fullpath()+(e.parent?this.sep:"")+t;return this.#m=s}fullpathPosix(){if(this.#y!==void 0)return this.#y;if(this.sep==="/")return this.#y=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#y=`//?/${i}`:this.#y=i}let t=this.parent,e=t.fullpathPosix(),s=e+(!e||!t.parent?"":"/")+this.name;return this.#y=s}isUnknown(){return(this.#e&qt)===Yt}isType(t){return this[`is${t}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#e&qt)===Rn}isDirectory(){return(this.#e&qt)===ne}isCharacterDevice(){return(this.#e&qt)===Pn}isBlockDevice(){return(this.#e&qt)===In}isFIFO(){return(this.#e&qt)===_n}isSocket(){return(this.#e&qt)===Nn}isSymbolicLink(){return(this.#e&Ie)===Ie}lstatCached(){return this.#e&Zr?this:void 0}readlinkCached(){return this.#R}realpathCached(){return this.#$}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#R)return!0;if(!this.parent)return!1;let t=this.#e&qt;return!(t!==Yt&&t!==Ie||this.#e&js||this.#e&ee)}calledReaddir(){return!!(this.#e&Ri)}isENOENT(){return!!(this.#e&ee)}isNamed(t){return this.nocase?this.#k===Ws(t):this.#k===hs(t)}async readlink(){let t=this.#R;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=await this.#t.promises.readlink(this.fullpath()),s=(await this.parent.realpath())?.resolve(e);if(s)return this.#R=s}catch(e){this.#I(e.code);return}}readlinkSync(){let t=this.#R;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=this.#t.readlinkSync(this.fullpath()),s=this.parent.realpathSync()?.resolve(e);if(s)return this.#R=s}catch(e){this.#I(e.code);return}}#M(t){this.#e|=Ri;for(let e=t.provisional;e<t.length;e++){let s=t[e];s&&s.#C()}}#C(){this.#e&ee||(this.#e=(this.#e|ee)&ns,this.#G())}#G(){let t=this.children();t.provisional=0;for(let e of t)e.#C()}#L(){this.#e|=zs,this.#D()}#D(){if(this.#e&cs)return;let t=this.#e;(t&qt)===ne&&(t&=ns),this.#e=t|cs,this.#G()}#B(t=""){t==="ENOTDIR"||t==="EPERM"?this.#D():t==="ENOENT"?this.#C():this.children().provisional=0}#P(t=""){t==="ENOTDIR"?this.parent.#D():t==="ENOENT"&&this.#C()}#I(t=""){let e=this.#e;e|=js,t==="ENOENT"&&(e|=ee),(t==="EINVAL"||t==="UNKNOWN")&&(e&=ns),this.#e=e,t==="ENOTDIR"&&this.parent&&this.parent.#D()}#j(t,e){return this.#U(t,e)||this.#W(t,e)}#W(t,e){let s=Ni(t),i=this.newChild(t.name,s,{parent:this}),r=i.#e&qt;return r!==ne&&r!==Ie&&r!==Yt&&(i.#e|=cs),e.unshift(i),e.provisional++,i}#U(t,e){for(let s=e.provisional;s<e.length;s++){let i=e[s];if((this.nocase?Ws(t.name):hs(t.name))===i.#k)return this.#c(t,i,s,e)}}#c(t,e,s,i){let r=e.name;return e.#e=e.#e&ns|Ni(t),r!==t.name&&(e.name=t.name),s!==i.provisional&&(s===i.length-1?i.pop():i.splice(s,1),i.unshift(e)),i.provisional++,e}async lstat(){if((this.#e&ee)===0)try{return this.#z(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#P(t.code)}}lstatSync(){if((this.#e&ee)===0)try{return this.#z(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#P(t.code)}}#z(t){let{atime:e,atimeMs:s,birthtime:i,birthtimeMs:r,blksize:n,blocks:o,ctime:l,ctimeMs:a,dev:c,gid:d,ino:u,mode:f,mtime:w,mtimeMs:m,nlink:y,rdev:x,size:C,uid:k}=t;this.#b=e,this.#a=s,this.#g=i,this.#v=r,this.#h=n,this.#u=o,this.#A=l,this.#p=a,this.#s=c,this.#x=d,this.#l=u,this.#n=f,this.#f=w,this.#i=m,this.#r=y,this.#w=x,this.#d=C,this.#o=k;let S=Ni(t);this.#e=this.#e&ns|S|Zr,S!==Yt&&S!==ne&&S!==Ie&&(this.#e|=cs)}#O=[];#_=!1;#H(t){this.#_=!1;let e=this.#O.slice();this.#O.length=0,e.forEach(s=>s(null,t))}readdirCB(t,e=!1){if(!this.canReaddir()){e?t(null,[]):queueMicrotask(()=>t(null,[]));return}let s=this.children();if(this.calledReaddir()){let r=s.slice(0,s.provisional);e?t(null,r):queueMicrotask(()=>t(null,r));return}if(this.#O.push(t),this.#_)return;this.#_=!0;let i=this.fullpath();this.#t.readdir(i,{withFileTypes:!0},(r,n)=>{if(r)this.#B(r.code),s.provisional=0;else{for(let o of n)this.#j(o,s);this.#M(s)}this.#H(s.slice(0,s.provisional))})}#X;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();if(this.#X)await this.#X;else{let s=()=>{};this.#X=new Promise(i=>s=i);try{for(let i of await this.#t.promises.readdir(e,{withFileTypes:!0}))this.#j(i,t);this.#M(t)}catch(i){this.#B(i.code),t.provisional=0}this.#X=void 0,s()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();try{for(let s of this.#t.readdirSync(e,{withFileTypes:!0}))this.#j(s,t);this.#M(t)}catch(s){this.#B(s.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#e&Qr)return!1;let t=qt&this.#e;return t===Yt||t===ne||t===Ie}shouldWalk(t,e){return(this.#e&ne)===ne&&!(this.#e&Qr)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#$)return this.#$;if(!((zs|js|ee)&this.#e))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#$=this.resolve(t)}catch{this.#L()}}realpathSync(){if(this.#$)return this.#$;if(!((zs|js|ee)&this.#e))try{let t=this.#t.realpathSync(this.fullpath());return this.#$=this.resolve(t)}catch{this.#L()}}[Fn](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let e=new Set([]),s=[],i=this;for(;i&&i.parent;)e.add(i),i.#T=s.join(this.sep),i.#E=s.join("/"),i=i.parent,s.push("..");for(i=t;i&&i.parent&&!e.has(i);)i.#T=void 0,i.#E=void 0,i=i.parent}},Dn=class On extends Wt{sep="\\";splitSep=mc;constructor(e,s=Yt,i,r,n,o,l){super(e,s,i,r,n,o,l)}newChild(e,s=Yt,i={}){return new On(e,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}getRootString(e){return Di.parse(e).root}getRoot(e){if(e=gc(e.toUpperCase()),e===this.root.name)return this.root;for(let[s,i]of Object.entries(this.roots))if(this.sameRoot(e,s))return this.roots[e]=i;return this.roots[e]=new Bi(e,this).root}sameRoot(e,s=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(An,"$1\\"),e===s}},Ln=class Mn extends Wt{splitSep="/";sep="/";constructor(e,s=Yt,i,r,n,o,l){super(e,s,i,r,n,o,l)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,s=Yt,i={}){return new Mn(e,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}},Bn=class{root;rootPath;roots;cwd;#t;#s;#n;nocase;#r;constructor(t=process.cwd(),e,s,{nocase:i,childrenCacheSize:r=16*1024,fs:n=as}={}){this.#r=$n(n),(t instanceof URL||t.startsWith("file://"))&&(t=Xa(t));let o=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(o),this.#t=new sn,this.#s=new sn,this.#n=new yc(r);let l=o.substring(this.rootPath.length).split(s);if(l.length===1&&!l[0]&&l.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let a=this.root,c=l.length-1,d=e.sep,u=this.rootPath,f=!1;for(let w of l){let m=c--;a=a.child(w,{relative:new Array(m).fill("..").join(d),relativePosix:new Array(m).fill("..").join("/"),fullpath:u+=(f?"":d)+w}),f=!0}this.cwd=a}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#n}resolve(...t){let e="";for(let r=t.length-1;r>=0;r--){let n=t[r];if(!(!n||n===".")&&(e=e?`${n}/${e}`:n,this.isAbsolute(n)))break}let s=this.#t.get(e);if(s!==void 0)return s;let i=this.cwd.resolve(e).fullpath();return this.#t.set(e,i),i}resolvePosix(...t){let e="";for(let r=t.length-1;r>=0;r--){let n=t[r];if(!(!n||n===".")&&(e=e?`${n}/${e}`:n,this.isAbsolute(n)))break}let s=this.#s.get(e);if(s!==void 0)return s;let i=this.cwd.resolve(e).fullpathPosix();return this.#s.set(e,i),i}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Wt||(e=t,t=this.cwd);let{withFileTypes:s}=e;if(t.canReaddir()){let i=await t.readdir();return s?i:i.map(r=>r.name)}else return[]}readdirSync(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Wt||(e=t,t=this.cwd);let{withFileTypes:s=!0}=e;return t.canReaddir()?s?t.readdirSync():t.readdirSync().map(i=>i.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Wt||(e=t.withFileTypes,t=this.cwd);let s=await t.readlink();return e?s:s?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Wt||(e=t.withFileTypes,t=this.cwd);let s=t.readlinkSync();return e?s:s?.fullpath()}async realpath(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Wt||(e=t.withFileTypes,t=this.cwd);let s=await t.realpath();return e?s:s?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Wt||(e=t.withFileTypes,t=this.cwd);let s=t.realpathSync();return e?s:s?.fullpath()}async walk(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Wt||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:n}=e,o=[];(!r||r(t))&&o.push(s?t:t.fullpath());let l=new Set,a=(d,u)=>{l.add(d),d.readdirCB((f,w)=>{if(f)return u(f);let m=w.length;if(!m)return u();let y=()=>{--m===0&&u()};for(let x of w)(!r||r(x))&&o.push(s?x:x.fullpath()),i&&x.isSymbolicLink()?x.realpath().then(C=>C?.isUnknown()?C.lstat():C).then(C=>C?.shouldWalk(l,n)?a(C,y):y()):x.shouldWalk(l,n)?a(x,y):y()},!0)},c=t;return new Promise((d,u)=>{a(c,f=>{if(f)return u(f);d(o)})})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Wt||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:n}=e,o=[];(!r||r(t))&&o.push(s?t:t.fullpath());let l=new Set([t]);for(let a of l){let c=a.readdirSync();for(let d of c){(!r||r(d))&&o.push(s?d:d.fullpath());let u=d;if(d.isSymbolicLink()){if(!(i&&(u=d.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(l,n)&&l.add(u)}}return o}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,e={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof Wt||(e=t,t=this.cwd),this.stream(t,e)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Wt||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:n}=e;(!r||r(t))&&(yield s?t:t.fullpath());let o=new Set([t]);for(let l of o){let a=l.readdirSync();for(let c of a){(!r||r(c))&&(yield s?c:c.fullpath());let d=c;if(c.isSymbolicLink()){if(!(i&&(d=c.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(o,n)&&o.add(d)}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Wt||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:n}=e,o=new Xs({objectMode:!0});(!r||r(t))&&o.write(s?t:t.fullpath());let l=new Set,a=[t],c=0,d=()=>{let u=!1;for(;!u;){let f=a.shift();if(!f){c===0&&o.end();return}c++,l.add(f);let w=(y,x,C=!1)=>{if(y)return o.emit("error",y);if(i&&!C){let k=[];for(let S of x)S.isSymbolicLink()&&k.push(S.realpath().then($=>$?.isUnknown()?$.lstat():$));if(k.length){Promise.all(k).then(()=>w(null,x,!0));return}}for(let k of x)k&&(!r||r(k))&&(o.write(s?k:k.fullpath())||(u=!0));c--;for(let k of x){let S=k.realpathCached()||k;S.shouldWalk(l,n)&&a.push(S)}u&&!o.flowing?o.once("drain",d):m||d()},m=!0;f.readdirCB(w,!0),m=!1}};return d(),o}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Wt||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:n}=e,o=new Xs({objectMode:!0}),l=new Set;(!r||r(t))&&o.write(s?t:t.fullpath());let a=[t],c=0,d=()=>{let u=!1;for(;!u;){let f=a.shift();if(!f){c===0&&o.end();return}c++,l.add(f);let w=f.readdirSync();for(let m of w)(!r||r(m))&&(o.write(s?m:m.fullpath())||(u=!0));c--;for(let m of w){let y=m;if(m.isSymbolicLink()){if(!(i&&(y=m.realpathSync())))continue;y.isUnknown()&&y.lstatSync()}y.shouldWalk(l,n)&&a.push(y)}}u&&!o.flowing&&o.once("drain",d)};return d(),o}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[Fn](e)}},Bi=class extends Bn{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,Di,"\\",{...e,nocase:s}),this.nocase=s;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(t){return Di.parse(t).root.toUpperCase()}newRoot(t){return new Dn(this.rootPath,ne,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},ji=class extends Bn{sep="/";constructor(t=process.cwd(),e={}){let{nocase:s=!1}=e;super(t,Ha,"/",{...e,nocase:s}),this.nocase=s}parseRootPath(t){return"/"}newRoot(t){return new Ln(this.rootPath,ne,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},jn=class extends ji{constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,{...e,nocase:s})}},xu=process.platform==="win32"?Dn:Ln,bc=process.platform==="win32"?Bi:process.platform==="darwin"?jn:ji,xc=t=>t.length>=1,vc=t=>t.length>=1,Tc=Symbol.for("nodejs.util.inspect.custom"),Wn=class Un{#t;#s;#n;length;#r;#o;#x;#w;#h;#l;#d=!0;constructor(e,s,i,r){if(!xc(e))throw new TypeError("empty pattern list");if(!vc(s))throw new TypeError("empty glob list");if(s.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,i<0||i>=this.length)throw new TypeError("index out of range");if(this.#t=e,this.#s=s,this.#n=i,this.#r=r,this.#n===0){if(this.isUNC()){let[n,o,l,a,...c]=this.#t,[d,u,f,w,...m]=this.#s;c[0]===""&&(c.shift(),m.shift());let y=[n,o,l,a,""].join("/"),x=[d,u,f,w,""].join("/");this.#t=[y,...c],this.#s=[x,...m],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[n,...o]=this.#t,[l,...a]=this.#s;o[0]===""&&(o.shift(),a.shift());let c=n+"/",d=l+"/";this.#t=[c,...o],this.#s=[d,...a],this.length=this.#t.length}}}[Tc](){return"Pattern <"+this.#s.slice(this.#n).join("/")+">"}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===Mt}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#x=this.#x||(this.#n===0?this.isAbsolute()?this.#s[0]+this.#s.slice(1).join("/"):this.#s.join("/"):this.#s.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#o!==void 0?this.#o:this.hasMore()?(this.#o=new Un(this.#t,this.#s,this.#n+1,this.#r),this.#o.#l=this.#l,this.#o.#h=this.#h,this.#o.#w=this.#w,this.#o):this.#o=null}isUNC(){let e=this.#t;return this.#h!==void 0?this.#h:this.#h=this.#r==="win32"&&this.#n===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#t;return this.#w!==void 0?this.#w:this.#w=this.#r==="win32"&&this.#n===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#t;return this.#l!==void 0?this.#l:this.#l=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#t[0];return typeof e=="string"&&this.isAbsolute()&&this.#n===0?e:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#d)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#d?!1:(this.#d=!1,!0)}},Cc=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",rn=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:e,nocase:s,noext:i,noglobstar:r,platform:n=Cc}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=n,this.mmopts={dot:!0,nobrace:e,nocase:s,noext:i,noglobstar:r,optimizationLevel:2,platform:n,nocomment:!0,nonegate:!0};for(let o of t)this.add(o)}add(t){let e=new ve(t,this.mmopts);for(let s=0;s<e.set.length;s++){let i=e.set[s],r=e.globParts[s];if(!i||!r)throw new Error("invalid pattern object");for(;i[0]==="."&&r[0]===".";)i.shift(),r.shift();let n=new Wn(i,r,0,this.platform),o=new ve(n.globString(),this.mmopts),l=r[r.length-1]==="**",a=n.isAbsolute();a?this.absolute.push(o):this.relative.push(o),l&&(a?this.absoluteChildren.push(o):this.relativeChildren.push(o))}}ignored(t){let e=t.fullpath(),s=`${e}/`,i=t.relative()||".",r=`${i}/`;for(let n of this.relative)if(n.match(i)||n.match(r))return!0;for(let n of this.absolute)if(n.match(e)||n.match(s))return!0;return!1}childrenIgnored(t){let e=t.fullpath()+"/",s=(t.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(s))return!0;for(let i of this.absoluteChildren)if(i.match(e))return!0;return!1}},kc=class zn{store;constructor(e=new Map){this.store=e}copy(){return new zn(new Map(this.store))}hasWalked(e,s){return this.store.get(e.fullpath())?.has(s.globString())}storeWalked(e,s){let i=e.fullpath(),r=this.store.get(i);r?r.add(s.globString()):this.store.set(i,new Set([s.globString()]))}},Sc=class{store=new Map;add(t,e,s){let i=(e?2:0)|(s?1:0),r=this.store.get(t);this.store.set(t,r===void 0?i:i&r)}entries(){return[...this.store.entries()].map(([t,e])=>[t,!!(e&2),!!(e&1)])}},Ec=class{store=new Map;add(t,e){if(!t.canReaddir())return;let s=this.store.get(t);s?s.find(i=>i.globString()===e.globString())||s.push(e):this.store.set(t,[e])}get(t){let e=this.store.get(t);if(!e)throw new Error("attempting to walk unknown path");return e}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},nn=class Gn{hasWalkedCache;matches=new Sc;subwalks=new Ec;patterns;follow;dot;opts;constructor(e,s){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=s?s.copy():new kc}processPatterns(e,s){this.patterns=s;let i=s.map(r=>[e,r]);for(let[r,n]of i){this.hasWalkedCache.storeWalked(r,n);let o=n.root(),l=n.isAbsolute()&&this.opts.absolute!==!1;if(o){r=r.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let u=n.rest();if(u)n=u;else{this.matches.add(r,!0,!1);continue}}if(r.isENOENT())continue;let a,c,d=!1;for(;typeof(a=n.pattern())=="string"&&(c=n.rest());)r=r.resolve(a),n=c,d=!0;if(a=n.pattern(),c=n.rest(),d){if(this.hasWalkedCache.hasWalked(r,n))continue;this.hasWalkedCache.storeWalked(r,n)}if(typeof a=="string"){let u=a===".."||a===""||a===".";this.matches.add(r.resolve(a),l,u);continue}else if(a===Mt){(!r.isSymbolicLink()||this.follow||n.checkFollowGlobstar())&&this.subwalks.add(r,n);let u=c?.pattern(),f=c?.rest();if(!c||(u===""||u===".")&&!f)this.matches.add(r,l,u===""||u===".");else if(u===".."){let w=r.parent||r;f?this.hasWalkedCache.hasWalked(w,f)||this.subwalks.add(w,f):this.matches.add(w,l,!0)}}else a instanceof RegExp&&this.subwalks.add(r,n)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new Gn(this.opts,this.hasWalkedCache)}filterEntries(e,s){let i=this.subwalks.get(e),r=this.child();for(let n of s)for(let o of i){let l=o.isAbsolute(),a=o.pattern(),c=o.rest();a===Mt?r.testGlobstar(n,o,c,l):a instanceof RegExp?r.testRegExp(n,a,c,l):r.testString(n,a,c,l)}return r}testGlobstar(e,s,i,r){if((this.dot||!e.name.startsWith("."))&&(s.hasMore()||this.matches.add(e,r,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,s):e.isSymbolicLink()&&(i&&s.checkFollowGlobstar()?this.subwalks.add(e,i):s.markFollowGlobstar()&&this.subwalks.add(e,s)))),i){let n=i.pattern();if(typeof n=="string"&&n!==".."&&n!==""&&n!==".")this.testString(e,n,i.rest(),r);else if(n===".."){let o=e.parent||e;this.subwalks.add(o,i)}else n instanceof RegExp&&this.testRegExp(e,n,i.rest(),r)}}testRegExp(e,s,i,r){s.test(e.name)&&(i?this.subwalks.add(e,i):this.matches.add(e,r,!1))}testString(e,s,i,r){e.isNamed(s)&&(i?this.subwalks.add(e,i):this.matches.add(e,r,!1))}},$c=(t,e)=>typeof t=="string"?new rn([t],e):Array.isArray(t)?new rn(t,e):t,Hn=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#s;#n;signal;maxDepth;includeChildMatches;constructor(t,e,s){if(this.patterns=t,this.path=e,this.opts=s,this.#n=!s.posix&&s.platform==="win32"?"\\":"/",this.includeChildMatches=s.includeChildMatches!==!1,(s.ignore||!this.includeChildMatches)&&(this.#s=$c(s.ignore??[],s),!this.includeChildMatches&&typeof this.#s.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=s.maxDepth||1/0,s.signal&&(this.signal=s.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#r(t){return this.seen.has(t)||!!this.#s?.ignored?.(t)}#o(t){return!!this.#s?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||await t.realpath(),!s)return;t=s}let i=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let r=await i.realpath();r&&(r.isUnknown()||this.opts.stat)&&await r.lstat()}return this.matchCheckTest(i,e)}matchCheckTest(t,e){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!e||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#r(t)?t:void 0}matchCheckSync(t,e){if(e&&this.opts.nodir)return;let s;if(this.opts.realpath){if(s=t.realpathCached()||t.realpathSync(),!s)return;t=s}let i=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&i?.isSymbolicLink()){let r=i.realpathSync();r&&(r?.isUnknown()||this.opts.stat)&&r.lstatSync()}return this.matchCheckTest(i,e)}matchFinish(t,e){if(this.#r(t))return;if(!this.includeChildMatches&&this.#s?.add){let r=`${t.relativePosix()}/**`;this.#s.add(r)}let s=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(t);let i=this.opts.mark&&t.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(s){let r=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(r+i)}else{let r=this.opts.posix?t.relativePosix():t.relative(),n=this.opts.dotRelative&&!r.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(r?n+r+i:"."+i)}}async match(t,e,s){let i=await this.matchCheck(t,s);i&&this.matchFinish(i,e)}matchSync(t,e,s){let i=this.matchCheckSync(t,s);i&&this.matchFinish(i,e)}walkCB(t,e,s){this.signal?.aborted&&s(),this.walkCB2(t,e,new nn(this.opts),s)}walkCB2(t,e,s,i){if(this.#o(t))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(t,e,s,i));return}s.processPatterns(t,e);let r=1,n=()=>{--r===0&&i()};for(let[o,l,a]of s.matches.entries())this.#r(o)||(r++,this.match(o,l,a).then(()=>n()));for(let o of s.subwalkTargets()){if(this.maxDepth!==1/0&&o.depth()>=this.maxDepth)continue;r++;let l=o.readdirCached();o.calledReaddir()?this.walkCB3(o,l,s,n):o.readdirCB((a,c)=>this.walkCB3(o,c,s,n),!0)}n()}walkCB3(t,e,s,i){s=s.filterEntries(t,e);let r=1,n=()=>{--r===0&&i()};for(let[o,l,a]of s.matches.entries())this.#r(o)||(r++,this.match(o,l,a).then(()=>n()));for(let[o,l]of s.subwalks.entries())r++,this.walkCB2(o,l,s.child(),n);n()}walkCBSync(t,e,s){this.signal?.aborted&&s(),this.walkCB2Sync(t,e,new nn(this.opts),s)}walkCB2Sync(t,e,s,i){if(this.#o(t))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(t,e,s,i));return}s.processPatterns(t,e);let r=1,n=()=>{--r===0&&i()};for(let[o,l,a]of s.matches.entries())this.#r(o)||this.matchSync(o,l,a);for(let o of s.subwalkTargets()){if(this.maxDepth!==1/0&&o.depth()>=this.maxDepth)continue;r++;let l=o.readdirSync();this.walkCB3Sync(o,l,s,n)}n()}walkCB3Sync(t,e,s,i){s=s.filterEntries(t,e);let r=1,n=()=>{--r===0&&i()};for(let[o,l,a]of s.matches.entries())this.#r(o)||this.matchSync(o,l,a);for(let[o,l]of s.subwalks.entries())r++,this.walkCB2Sync(o,l,s.child(),n);n()}},on=class extends Hn{matches=new Set;constructor(t,e,s){super(t,e,s)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,e)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?e(this.signal.reason):t(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},ln=class extends Hn{results;constructor(t,e,s){super(t,e,s),this.results=new Xs({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},Ac=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Re=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(t,e){if(!e)throw new TypeError("glob options required");if(this.withFileTypes=!!e.withFileTypes,this.signal=e.signal,this.follow=!!e.follow,this.dot=!!e.dot,this.dotRelative=!!e.dotRelative,this.nodir=!!e.nodir,this.mark=!!e.mark,e.cwd?(e.cwd instanceof URL||e.cwd.startsWith("file://"))&&(e.cwd=Wa(e.cwd)):this.cwd="",this.cwd=e.cwd||"",this.root=e.root,this.magicalBraces=!!e.magicalBraces,this.nobrace=!!e.nobrace,this.noext=!!e.noext,this.realpath=!!e.realpath,this.absolute=e.absolute,this.includeChildMatches=e.includeChildMatches!==!1,this.noglobstar=!!e.noglobstar,this.matchBase=!!e.matchBase,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:1/0,this.stat=!!e.stat,this.ignore=e.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(l=>l.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(l=>l.includes("/")?l:`./**/${l}`)}if(this.pattern=t,this.platform=e.platform||Ac,this.opts={...e,platform:this.platform},e.scurry){if(this.scurry=e.scurry,e.nocase!==void 0&&e.nocase!==e.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let l=e.platform==="win32"?Bi:e.platform==="darwin"?jn:e.platform?ji:bc;this.scurry=new l(this.cwd,{nocase:e.nocase,fs:e.fs})}this.nocase=this.scurry.nocase;let s=this.platform==="darwin"||this.platform==="win32",i={braceExpandMax:1e4,...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:s,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},r=this.pattern.map(l=>new ve(l,i)),[n,o]=r.reduce((l,a)=>(l[0].push(...a.set),l[1].push(...a.globParts),l),[[],[]]);this.patterns=n.map((l,a)=>{let c=o[a];if(!c)throw new Error("invalid pattern object");return new Wn(l,c,0,this.platform)})}async walk(){return[...await new on(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new on(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new ln(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new ln(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}},_c=(t,e={})=>{Array.isArray(t)||(t=[t]);for(let s of t)if(new ve(s,e).hasMagic())return!0;return!1};function qs(t,e={}){return new Re(t,e).streamSync()}function Xn(t,e={}){return new Re(t,e).stream()}function Vn(t,e={}){return new Re(t,e).walkSync()}async function an(t,e={}){return new Re(t,e).walk()}function Ys(t,e={}){return new Re(t,e).iterateSync()}function qn(t,e={}){return new Re(t,e).iterate()}var Pc=qs,Ic=Object.assign(Xn,{sync:qs}),Rc=Ys,Nc=Object.assign(qn,{sync:Ys}),Fc=Object.assign(Vn,{stream:qs,iterate:Ys}),He=Object.assign(an,{glob:an,globSync:Vn,sync:Fc,globStream:Xn,stream:Ic,globStreamSync:qs,streamSync:Pc,globIterate:qn,iterate:Nc,globIterateSync:Ys,iterateSync:Rc,Glob:Re,hasMagic:_c,escape:mn,unescape:Ge});He.glob=He;var Js=Lc(Dc);async function Mc(t){try{return await Js(t,["--version"],{timeout:5e3}),!0}catch{return!1}}async function Bc(t){try{return await Js("git",["rev-parse","--git-dir"],{cwd:t,timeout:5e3}),!0}catch{return!1}}function jc(t,e){let s=[],i=t.split(`
|
|
9
|
-
`).filter(Boolean);for(let r of i){let n=r.match(/^(.+?)[:-](\d+)[:-](.*)$/),[,o,l,a]=n??[];o&&l&&a!==void 0&&s.push({file:Yn.isAbsolute(o)?o:Yn.join(e,o),line:Number.parseInt(l,10),content:a.slice(0,500)})}return s}var Jn=async t=>{let e=t.path?zt(t.path):process.cwd(),s=Math.min(t.limit??100,500),i=t.context_lines??0;try{let r="",n="native";if(await Mc("rg")){n="ripgrep";let l=["--line-number","--no-heading","--color=never",`--max-count=${s}`];i>0&&l.push(`-C${i}`),t.include&&l.push(`--glob=${t.include}`),l.push("--",t.pattern,e);try{r=(await Js("rg",l,{timeout:Qe,maxBuffer:Ze})).stdout}catch(a){let c=a;if(c.code===1&&!c.stdout)r="";else if(c.stdout)r=c.stdout;else throw a}}else if(await Bc(e)){n="git-grep";let l=["grep","-n","--no-color",`-m${s}`];i>0&&l.push(`-C${i}`),l.push("-e",t.pattern);try{r=(await Js("git",l,{cwd:e,timeout:Qe,maxBuffer:Ze})).stdout}catch(a){if(a.code===1)r="";else throw a}}else{n="native";let l=[],a=new RegExp(t.pattern,"gi"),c=t.include||"**/*",d=await He(c,{cwd:e,nodir:!0,absolute:!0}),u=await Rs(e);d=Ns(d,e,u);for(let f of d){if(l.length>=s)break;try{let m=(await Oc.readFile(f,"utf-8")).split(`
|
|
10
|
-
`);for(let[y,x]of m.entries()){if(l.length>=s)break;a.test(x)&&(l.push({file:f,line:y+1,content:x.slice(0,500)}),a.lastIndex=0)}}catch{}}return{success:!0,matches:l,tool:n,total:l.length}}let o=jc(r,e).slice(0,s);return{success:!0,matches:o,tool:n,total:o.length}}catch(r){return{success:!1,error:r instanceof Error?r.message:"Failed to search file contents"}}};import Wc from"fs/promises";var Kn=async t=>{try{let e=await Xt(t.path);return{success:!0,entries:(await Wc.readdir(e,{withFileTypes:!0})).map(r=>({name:r.name,type:r.isDirectory()?"directory":r.isFile()?"file":r.isSymbolicLink()?"symlink":"unknown"}))}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to list directory"}}};import Ks from"fs/promises";import Uc from"path";var Zn=async t=>{try{let e=await Xt(t.source),s=zt(t.destination);await Ks.mkdir(Uc.dirname(s),{recursive:!0});try{await Ks.rename(e,s)}catch(i){if(i.code!=="EXDEV")throw i;await Ks.cp(e,s,{recursive:!0}),await Ks.rm(e,{recursive:!0})}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to move file"}}};import Wi from"fs/promises";var Qn=async t=>{try{let e=await Xt(t.path),s=await Is(e);if(s.type==="binary"){let d=await Wi.stat(e);if(d.size>We){let w=Math.round(d.size/1024/1024),m=Math.round(We/1024/1024);return{success:!1,error:`Binary file too large (${w}MB). Maximum size is ${m}MB.`}}let f=(await Wi.readFile(e)).toString("base64");return{success:!0,type:"binary",mimeType:s.mimeType,content:f,size:d.size,encoding:"base64"}}let r=(await Wi.readFile(e,"utf-8")).split(`
|
|
11
|
-
`),n=r.length,o=Math.max(1,t.start_line??1),l=Math.min(n,t.end_line??o+499),c=r.slice(o-1,l).join(`
|
|
12
|
-
`);return{success:!0,type:"text",content:de(c),lines:{total:n,start:o,end:Math.min(l,n)},truncated:c.length>ki}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to read file"}}};import zi from"fs/promises";function to(t){if(t&&typeof t=="object"&&"code"in t)return String(t.code);let e=t instanceof Error?t.message:String(t);return/^([A-Z]+):/u.exec(e)?.[1]}function zc(t){let e=to(t);return e==="EPERM"||e==="EACCES"}function Ui(t){let e=t instanceof Error?t.message:String(t);switch(to(t)){case"EACCES":case"EPERM":return`${e}
|
|
13
|
-
Permission denied by the operating system. On macOS this is usually a privacy restriction \u2014 access can be granted under System Settings \u2192 Privacy & Security \u2192 Files and Folders (or Full Disk Access).`;case"ENOENT":return`${e}
|
|
14
|
-
The path does not exist.`;case"ENOTDIR":return`${e}
|
|
15
|
-
A component of the path is not a directory.`;case"EISDIR":return`${e}
|
|
16
|
-
The path is a directory, not a file.`;default:return e}}function eo(t,e){return async s=>{let i=await t(s);return!i.success&&typeof i.error=="string"?(zc(i.error)&&e?.(i.error),{...i,error:Ui(i.error)}):i}}async function Gc(t){let e=await Xt(t),s=await Is(e);if(s.type!=="binary")return de(await zi.readFile(e,"utf-8"),Pr);let i=await zi.stat(e);if(i.size>We){let n=Math.round(i.size/1024/1024),o=Math.round(We/1024/1024);return{error:`Binary file too large (${n}MB). Maximum size is ${o}MB.`}}let r=await zi.readFile(e);return{type:"binary",mimeType:s.mimeType,content:r.toString("base64"),size:i.size,encoding:"base64"}}var so=async t=>{try{let e=t.paths.slice(0,Rr),s={};return await Promise.all(e.map(async i=>{try{s[i]=await Gc(i)}catch(r){let n=r instanceof Error?r.message:"Failed to read file";s[i]={error:Ui(n)}}})),{success:!0,files:s}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to read files"}}};var io=async t=>{try{let e=t.path?zt(t.path):process.cwd(),s=t.respect_gitignore??!0,i=await He(t.pattern,{cwd:e,nodir:!0,absolute:!0,maxDepth:Ir});if(s){let r=await Rs(e);i=Ns(i,e,r)}return{success:!0,files:i.slice(0,Si),total:i.length,truncated:i.length>Si}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to search files"}}};import Gi from"fs/promises";import Hc from"path";var ro=async t=>{try{let e=zt(t.path),s=Hc.dirname(e);if(await Gi.mkdir(s,{recursive:!0}),t.encoding==="base64"){let i=Buffer.from(t.content,"base64");await Gi.writeFile(e,i)}else if(!t.encoding||t.encoding==="utf-8")await Gi.writeFile(e,t.content,"utf-8");else{let i=t.encoding;throw new Error(`Unsupported encoding: ${String(i)}`)}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to write file"}}};import Cd from"fs/promises";import Sd from"path";var no={filesystem__read_file:Qn,filesystem__read_multiple_files:so,filesystem__write_file:ro,filesystem__edit_file:Lr,filesystem__create_directory:Dr,filesystem__list_directory:Kn,filesystem__search_files:io,filesystem__grep_files:Jn,filesystem__get_file_info:Br,filesystem__move_file:Zn,filesystem__execute_command:Mr};function lo(){return{name:"filesystem",systemPrompt:pr({toolNames:mi.map(t=>t.name),env:{home:Vc.homedir(),cwd:process.cwd()}}),tools:[...mi]}}var oo=!1;function qc(){process.platform==="darwin"&&(oo||process.stdout.isTTY&&(oo=!0,Xc('open "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles"',()=>{})))}async function ao(t,e){let s=no[t];if(!s)return{success:!1,error:`Unknown tool: ${t}`};let i=t==="filesystem__execute_command"&&!e.cwd?{...e,cwd:process.cwd()}:e,r=await eo(s,qc)(i);if(!r.success){let{success:l,error:a,...c}=r,d=Object.keys(c).length>0;return{success:!1,error:a,result:d?c:void 0}}let{success:n,...o}=r;return{success:!0,result:o}}function Hi(t){return t.startsWith("filesystem__")}function co(){return[lo()]}function Zs(){return co().flatMap(t=>t.tools)}function Qs(){return co().map(t=>t.systemPrompt).filter(Boolean).join(`
|
|
17
|
-
|
|
18
|
-
`)}function oe(t){return Hi(t)}async function ti(t,e){return Hi(t)?ao(t,e):{success:!1,error:`Unknown client tool: ${t}`}}function ei(t){if(!t.success){let n=[{type:"text",text:t.error||"Unknown error"}];return t.result&&n.push({type:"text",text:JSON.stringify(t.result)}),n}let{payload:e,images:s,notes:i}=fr(t.result),r=[{type:"text",text:JSON.stringify(e)},...i.map(n=>({type:"text",text:n}))];for(let n of s)n.path&&r.push({type:"text",text:`File: ${n.path}`}),r.push({type:"image",data:n.data,mimeType:n.mimeType});return r}import{Box as Et,Text as j,useInput as xs}from"ink";import cr from"ink-spinner";import{useCallback as hi,useEffect as ui,useRef as vs,useState as hr}from"react";import{Box as si,Text as us}from"ink";import{jsx as ii,jsxs as ds}from"react/jsx-runtime";function ho(t,e){return t.length<=e?t:e<=3?".".repeat(e):t.slice(0,e-3)+"..."}function uo({items:t,activeIndex:e,selectedIds:s,multiSelect:i=!1,visible:r,title:n,pageSize:o=10}){if(!r||t.length===0)return null;let l=process.stdout.columns??80,a=i?4:0,c=Math.max(20,l-2-2-a),d=Math.max(1,o),u=Math.floor(e/d)*d,f=Math.min(t.length,u+d),w=t.slice(u,f);return ds(si,{flexDirection:"column",marginBottom:1,children:[ii(us,{bold:!0,color:"cyan",children:n}),ii(si,{borderStyle:"single",borderColor:"gray",flexDirection:"column",children:w.map((m,y)=>{let C=u+y===e,k=s?.has(m.id),S=ho(m.name,c),$=m.description?ho(m.description,Math.max(0,c-a)):"",R=i?" ".repeat(a):"";return ds(si,{paddingX:1,flexDirection:"column",children:[ds(si,{children:[i&&ii(us,{color:k?"green":"gray",children:k?"[\u2713] ":"[ ] "}),ii(us,{backgroundColor:C?"cyan":void 0,color:C?"black":k?"green":"white",bold:!0,children:S})]}),$&&ds(us,{dimColor:!0,children:[R,"\xB7 ",$]})]},m.id)})}),ds(us,{dimColor:!0,children:[i?"\u2191\u2193 Navigate \xB7 Space Toggle \xB7 a All \xB7 n None \xB7 Enter Confirm \xB7 Esc Cancel":"\u2191\u2193 Navigate \xB7 Enter Select \xB7 Esc Cancel",t.length>d?` \xB7 Showing ${u+1}-${f} of ${t.length}`:""]})]})}import{Box as Xi,Text as ps}from"ink";import{jsx as fs,jsxs as Vi}from"react/jsx-runtime";function po({suggestions:t,activeIndex:e,visible:s}){return!s||t.length===0?null:Vi(Xi,{flexDirection:"column",marginBottom:1,children:[fs(Xi,{borderStyle:"single",borderColor:"gray",flexDirection:"column",children:t.map((i,r)=>{let n=r===e,o=i.aliases.length>0?` (${i.aliases.join(", ")})`:"";return Vi(Xi,{paddingX:1,children:[Vi(ps,{backgroundColor:n?"cyan":void 0,color:n?"black":"cyan",bold:n,children:["/",i.name]}),fs(ps,{dimColor:!0,children:o}),fs(ps,{children:" - "}),fs(ps,{color:n?"white":"gray",children:i.description})]},i.name)})}),fs(ps,{dimColor:!0,children:"\u2191\u2193 Navigate \xB7 Tab/Enter Select \xB7 Esc Cancel"})]})}import{Box as Yc,Text as fo,useInput as Jc,useStdout as Kc}from"ink";import{useCallback as go,useEffect as mo,useMemo as qi,useRef as wo,useState as yo}from"react";import{jsx as Ki}from"react/jsx-runtime";function ri(t,e){return t<0?0:t>e?e:t}function Yi(t){return[...t]}function ni(t){return/\s/.test(t)}function Ji(t,e){let s=e;for(;s>0&&ni(t[s-1]??"");)s-=1;for(;s>0&&!ni(t[s-1]??"");)s-=1;return s}function bo(t,e){let s=e;for(;s<t.length&&ni(t[s]??"");)s+=1;for(;s<t.length&&!ni(t[s]??"");)s+=1;return s}function Zc(t){let e=[],s=[],i=[],r=0;s.push(0),t.forEach((o,l)=>{if(o===`
|
|
19
|
-
`){e.push(i),i=[],r=l+1,s.push(r);return}i.push(o)}),e.push(i);let n=e.map(o=>o.length);return{lines:e,lineStarts:s,lineLengths:n}}function xo(t,e,s){for(let r=0;r<e.length;r+=1){let n=e[r]??0,o=s[r]??0,l=n+o;if(t<=l)return{row:r,col:t-n}}let i=Math.max(0,e.length-1);return{row:i,col:s[i]??0}}var Qc=2;function vo({value:t,onChange:e,onSubmit:s,onPaste:i,focus:r=!0,leadingOffset:n=0,multiline:o=!1}){let[l,a]=yo(()=>Yi(t).length),c=wo(null),[d,u]=yo(0),f=wo(null),{stdout:w}=Kc(),m=qi(()=>Yi(t),[t]),{lines:y,lineStarts:x,lineLengths:C}=qi(()=>Zc(m),[m]),{row:k,col:S}=qi(()=>xo(l,x,C),[l,x,C]),$=Math.max(1,(w?.columns??80)-n);mo(()=>{c.current===t?a(B=>ri(B,m.length)):(a(m.length),f.current=null),c.current=t},[t,m.length]),mo(()=>{u(B=>{let I=B;S<I?I=S:S>=I+$&&(I=S-$+1);let g=C[k]??0,E=S===g?g+1:g,et=Math.max(0,E-$);return I>et&&(I=et),I<0&&(I=0),I})},[$,S,k,C]);let R=go((B,I)=>{c.current=B,e(B),a(I),f.current=null},[e]),Z=go(async(B,I)=>{if(!r)return;let{row:g,col:E}=xo(l,x,C),et=y[g]??[],xt=C[g]??0,F=y.length>1;if(o&&(I.meta&&I.return||I.ctrl&&B==="j"||I.shift&&I.return)){let U=[...m.slice(0,l),`
|
|
20
|
-
`,...m.slice(l)].join("");R(U,l+1);return}if(I.return){s(t);return}if(I.leftArrow){I.ctrl||I.meta?(E===0&&g>0?a(x[g]-1):a(x[g]+Ji(et,E)),f.current=null):(E===0&&g>0?a(x[g]-1):a(U=>ri(U-1,m.length)),f.current=null);return}if(I.rightArrow){I.ctrl||I.meta?(E>=xt&&g<y.length-1?a(x[g+1]):a(x[g]+bo(et,E)),f.current=null):(E>=xt&&g<y.length-1?a(x[g+1]):a(U=>ri(U+1,m.length)),f.current=null);return}if(o&&F&&I.upArrow){let U=f.current??E,z=Math.max(0,g-1),L=Math.min(U,C[z]??0);a((x[z]??0)+L),f.current=U;return}if(o&&F&&I.downArrow){let U=f.current??E,z=Math.min(y.length-1,g+1),L=Math.min(U,C[z]??0);a((x[z]??0)+L),f.current=U;return}if(I.ctrl){if(B==="a"){a(x[g]??0),f.current=null;return}if(B==="e"){a((x[g]??0)+xt),f.current=null;return}if(B==="u"){if(E>0){let U=x[g]??0,z=[...m.slice(0,U),...m.slice(l)].join("");R(z,U)}return}if(B==="k"){if(E<xt){let U=(x[g]??0)+xt,z=[...m.slice(0,l),...m.slice(U)].join("");R(z,l)}return}if(B==="w"){if(E===0&&g>0){let z=[...m.slice(0,l-1),...m.slice(l)].join("");R(z,l-1);return}let U=Ji(et,E);if(U!==E){let z=(x[g]??0)+U,L=[...m.slice(0,z),...m.slice(l)].join("");R(L,z)}return}if(B==="d"){if(l<m.length){let U=[...m.slice(0,l),...m.slice(l+1)].join("");R(U,l)}return}return}if(I.meta){B==="b"?(E===0&&g>0?a(x[g]-1):a(x[g]+Ji(et,E)),f.current=null):B==="f"&&(E>=xt&&g<y.length-1?a(x[g+1]):a(x[g]+bo(et,E)),f.current=null);return}if(I.backspace||I.delete){if(l<=0)return;let U=[...m.slice(0,l-1),...m.slice(l)].join("");R(U,l-1);return}if(!(I.tab||I.escape)&&B.length>0){let U=o?B.replace(/\r\n/g,`
|
|
21
|
-
`).replace(/\r/g,`
|
|
22
|
-
`):B.replace(/\r?\n/g,"");if(!U||(U=U.replace(/^\u001B?\[200~/,"").replace(/\u001B?\[201~$/,""),!U))return;if((U.length>=Qc||U.includes(`
|
|
23
|
-
`))&&i){let J=!1,H={text:U,preventDefault:()=>{J=!0}};if(await Promise.resolve(i(H)),J)return}let L=Yi(U),dt=[...m.slice(0,l),...L,...m.slice(l)].join("");R(dt,l+L.length)}},[m,l,r,C,x,y,o,i,s,R,t]);return Jc(Z,{isActive:r}),Ki(Yc,{flexDirection:"column",children:y.map((B,I)=>{let g=I===k,et=(g&&S===B.length?[...B," "]:B).slice(d,d+$),xt=et.join("");if(!g)return Ki(fo,{children:xt||" "},I);let F=ri(S-d,Math.max(0,et.length-1)),U=et.slice(0,F).join(""),z=et[F]??" ",L=et.slice(F+1).join(""),H=`${U}\x1B[7m${z}\x1B[27m${L}`;return Ki(fo,{children:H},I)})})}import{Box as le,Text as Te}from"ink";import er from"react";import{Text as Jt}from"ink";import th from"react";import{Fragment as ih,jsx as se,jsxs as ko}from"react/jsx-runtime";var Zi=2,Qi=1,tr=2,eh=1,To=3,Co=4,sh=({text:t,defaultColor:e,linkColor:s,codeColor:i})=>{let r=e;if(!/[*_~`<[https?:]/.test(t))return se(Jt,{color:r,children:t});let n=[],o=0,l=/(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>|https?:\/\/\S+)/g,a;for(;(a=l.exec(t))!==null;){a.index>o&&n.push(se(Jt,{color:r,children:t.slice(o,a.index)},`t-${o}`));let c=a[0],d=null,u=`m-${a.index}`;try{if(c.startsWith("**")&&c.endsWith("**")&&c.length>Zi*2)d=se(Jt,{bold:!0,color:r,children:c.slice(Zi,-Zi)},u);else if(c.length>Qi*2&&(c.startsWith("*")&&c.endsWith("*")||c.startsWith("_")&&c.endsWith("_"))&&!/\w/.test(t.slice(Math.max(0,a.index-1),a.index))&&!/\w/.test(t.slice(l.lastIndex,l.lastIndex+1))&&!/\S[./\\]/.test(t.slice(Math.max(0,a.index-2),a.index))&&!/[./\\]\S/.test(t.slice(l.lastIndex,l.lastIndex+2)))d=se(Jt,{italic:!0,color:r,children:c.slice(Qi,-Qi)},u);else if(c.startsWith("~~")&&c.endsWith("~~")&&c.length>tr*2)d=se(Jt,{strikethrough:!0,color:r,children:c.slice(tr,-tr)},u);else if(c.startsWith("`")&&c.endsWith("`")&&c.length>eh){let f=c.match(/^(`+)(.+?)\1$/s);f&&f[2]&&(d=se(Jt,{color:i,children:f[2]},u))}else if(c.startsWith("[")&&c.includes("](")&&c.endsWith(")")){let f=c.match(/\[(.*?)\]\((.*?)\)/);if(f){let w=f[1],m=f[2];d=ko(Jt,{color:r,children:[w,ko(Jt,{color:s,children:[" (",m,")"]})]},u)}}else c.startsWith("<u>")&&c.endsWith("</u>")&&c.length>To+Co-1?d=se(Jt,{underline:!0,color:r,children:c.slice(To,-Co)},u):/^https?:\/\//.test(c)&&(d=se(Jt,{color:s,children:c},u))}catch{d=null}n.push(d??se(Jt,{color:r,children:c},u)),o=l.lastIndex}return o<t.length&&n.push(se(Jt,{color:r,children:t.slice(o)},`t-${o}`)),se(ih,{children:n.filter(c=>c!==null)})},gs=th.memo(sh);import{Fragment as hh,jsx as wt,jsxs as Ao}from"react/jsx-runtime";var rh=1,$o=1,nh=1,oh=1,lh=({content:t})=>{let e=t.join(`
|
|
24
|
-
`);return wt(le,{paddingLeft:$o,flexDirection:"column",children:wt(Te,{color:"yellow",children:e})})},So=er.memo(lh),ah=({itemText:t,type:e,marker:s,leadingWhitespace:i=""})=>{let r=e==="ol"?`${s}. `:`${s} `,n=r.length,o=i.length;return Ao(le,{paddingLeft:o+nh,flexDirection:"row",children:[wt(le,{width:n,children:wt(Te,{children:r})}),wt(le,{flexGrow:oh,children:wt(Te,{wrap:"wrap",children:wt(gs,{text:t,defaultColor:void 0,linkColor:"cyan",codeColor:"yellow"})})})]})},Eo=er.memo(ah),ch=({text:t,renderMarkdown:e=!0})=>{if(!t)return null;if(!e)return wt(le,{paddingLeft:$o,flexDirection:"column",children:wt(Te,{wrap:"wrap",children:t})});let s=t.split(/\r?\n/),i=/^ *(#{1,4}) +(.*)/,r=/^ *(`{3,}|~{3,}) *(\w*?) *$/,n=/^([ \t]*)([-*+]) +(.*)/,o=/^([ \t]*)(\d+)\. +(.*)/,l=/^ *([-*_] *){3,} *$/,a=/^ *> ?(.*)/,c=[],d=!1,u=!0,f=[],w="";function m(y){y&&(c.push(y),u=!1)}return s.forEach((y,x)=>{let C=`line-${x}`;if(d){let I=y.match(r);I&&I[1].startsWith(w[0])&&I[1].length>=w.length?(m(wt(So,{content:f},C)),d=!1,f=[],w=""):f.push(y);return}let k=y.match(r),S=y.match(i),$=y.match(n),R=y.match(o),Z=y.match(l),B=y.match(a);if(k)d=!0,w=k[1];else if(Z)m(wt(le,{children:wt(Te,{dimColor:!0,children:"---"})},C));else if(S){let I=S[1].length,g=S[2],E=I<=2?"cyan":"blue";m(wt(le,{children:wt(Te,{color:E,...(I===4?"italic":"bold")==="italic"?{italic:!0}:{bold:!0},children:wt(gs,{text:g,defaultColor:E,linkColor:"cyan",codeColor:"yellow"})})},C))}else if(B){let I=B[1];m(wt(le,{paddingLeft:1,children:Ao(Te,{dimColor:!0,children:["> ",wt(gs,{text:I,defaultColor:"gray",linkColor:"cyan",codeColor:"yellow"})]})},C))}else if($){let I=$[1],g=$[2],E=$[3];m(wt(Eo,{itemText:E,type:"ul",marker:g,leadingWhitespace:I},C))}else if(R){let I=R[1],g=R[2],E=R[3];m(wt(Eo,{itemText:E,type:"ol",marker:g,leadingWhitespace:I},C))}else y.trim().length===0?u||(c.push(wt(le,{height:rh},`spacer-${x}`)),u=!0):m(wt(le,{children:wt(Te,{wrap:"wrap",children:wt(gs,{text:y,defaultColor:void 0,linkColor:"cyan",codeColor:"yellow"})})},C))}),d&&m(wt(So,{content:f},"line-eof")),wt(hh,{children:c})},sr=er.memo(ch);import{execFile as uh}from"child_process";import dh from"fs";import Xe from"fs/promises";import _o from"os";import li from"path";import{promisify as ph}from"util";var oi=ph(uh);async function fh(){let t=li.join(_o.tmpdir(),`entrydesk-clipboard-${Date.now()}.png`);try{let e=`
|
|
25
|
-
set imageData to the clipboard as "PNGf"
|
|
26
|
-
set fileRef to open for access POSIX file "${t}" with write permission
|
|
27
|
-
set eof fileRef to 0
|
|
28
|
-
write imageData to fileRef
|
|
29
|
-
close access fileRef
|
|
30
|
-
`;return await oi("osascript",["-e",e]),(await Xe.stat(t)).size===0?void 0:{buffer:await Xe.readFile(t),mime:"image/png"}}catch{return}finally{try{dh.existsSync(t)&&await Xe.unlink(t)}catch{}}}async function gh(){try{let t=`
|
|
31
|
-
Add-Type -AssemblyName System.Windows.Forms
|
|
32
|
-
$img = [System.Windows.Forms.Clipboard]::GetImage()
|
|
33
|
-
if ($img) {
|
|
34
|
-
$ms = New-Object System.IO.MemoryStream
|
|
35
|
-
$img.Save($ms, [System.Drawing.Imaging.ImageFormat]::Png)
|
|
36
|
-
[System.Convert]::ToBase64String($ms.ToArray())
|
|
37
|
-
}
|
|
38
|
-
`,{stdout:e}=await oi("powershell.exe",["-command",t]),s=e.trim();if(!s)return;let i=Buffer.from(s,"base64");return i.length===0?void 0:{buffer:i,mime:"image/png"}}catch{return}}async function mh(){try{let{stdout:t}=await oi("wl-paste",["-t","image/png"],{encoding:"buffer",maxBuffer:52428800});if(t&&t.length>0)return{buffer:t,mime:"image/png"}}catch{}try{let{stdout:t}=await oi("xclip",["-selection","clipboard","-t","image/png","-o"],{encoding:"buffer",maxBuffer:52428800});if(t&&t.length>0)return{buffer:t,mime:"image/png"}}catch{}}async function Po(){let t=_o.platform();if(t==="darwin")return fh();if(t==="win32")return gh();if(t==="linux")return mh()}var wh=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico",".heic",".heif",".pdf",".txt",".md",".rtf",".csv",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".key",".pages",".numbers",".odt",".ods",".odp",".json",".xml",".yaml",".yml"]);function Io(t){let e=li.extname(t).toLowerCase();return wh.has(e)}function yh(t){let e=li.extname(t).toLowerCase();return{".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".txt":"text/plain",".md":"text/markdown",".pdf":"application/pdf",".csv":"text/csv",".rtf":"application/rtf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".key":"application/vnd.apple.keynote",".pages":"application/vnd.apple.pages",".numbers":"application/vnd.apple.numbers",".odt":"application/vnd.oasis.opendocument.text",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odp":"application/vnd.oasis.opendocument.presentation",".json":"application/json",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml"}[e]||"application/octet-stream"}function ai(t){let e=t.trim();return e.startsWith("file://")&&(e=decodeURIComponent(e.slice(7))),(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))&&(e=e.slice(1,-1)),e=e.replace(/\\(.)/g,"$1"),e}async function Ro(t){let e=ai(t);if(/^https?:\/\//.test(e))return!1;try{return await Xe.access(e),!0}catch{return!1}}async function No(t){let e=ai(t);try{if(!(await Xe.stat(e)).isFile())return;let i=await Xe.readFile(e),r=yh(e),n=li.basename(e);return{buffer:i,mimeType:r,filename:n}}catch{return}}var Kt="\x1B[2m",tt="\x1B[0m",Rt="\x1B[36m",Ve="\x1B[32m",Fo="\x1B[31m",Ne="\x1B[38;2;59;91;204m",ir="\x1B[38;2;126;200;248m",rr="\x1B[38;2;244;196;78m";function nr(t){return t.replace(/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)/gu,"").replace(/\u001B\[[0-?]*[ -/]*[@-~]/gu,"").replace(/[\u0000-\u001F\u007F-\u009F]/gu,"")}function or({approvalId:t,toolCallId:e,seenToolCalls:s,pendingClientTools:i,pendingApprovals:r}){if(typeof t!="string"||typeof e!="string")return!1;let n=i.findIndex(l=>l.toolCallId===e);n!==-1&&i.splice(n,1);let o=s.get(e);return r.push({approvalId:t,toolCallId:e,toolName:o?.toolName??"unknown_tool",input:o?.input??{}}),!0}function Do(t,e){return t.map(s=>{let i=e.get(s.approvalId)===!0;return{type:`tool-${s.toolName}`,toolCallId:s.toolCallId,state:"approval-responded",input:s.input,approval:{id:s.approvalId,approved:i,...i?{}:{reason:"Rejected by user."}}}})}function Oo(t,e,s){return t.filter(i=>e.get(i.approvalId)!==!0&&s(i.toolName)).map(i=>({type:`tool-${i.toolName}`,toolCallId:i.toolCallId,state:"output-error",errorText:"Tool execution rejected by user."}))}function Lo(t,e,s){return t.filter(i=>e.get(i.approvalId)===!0&&s(i.toolName)).map(i=>({toolCallId:i.toolCallId,toolName:i.toolName,args:i.input}))}import{useState as ge}from"react";import{v4 as Mo}from"uuid";function Bo(t,e){let[s,i]=ge({status:"loading"}),[r,n]=ge([]),[o,l]=ge(""),[a,c]=ge(()=>t||Mo()),[d,u]=ge(e),[f,w]=ge(!!t),[m,y]=ge(null),[x,C]=ge(""),[k,S]=ge(!1),$=Z=>{n(B=>[...B,{role:"system",content:Z}])};return{state:s,setState:i,messages:r,setMessages:n,input:o,setInput:l,taskId:a,setTaskId:c,currentTaskTitle:d,setCurrentTaskTitle:u,hasPersistedTask:f,setHasPersistedTask:w,credentials:m,setCredentials:y,currentResponse:x,setCurrentResponse:C,fullOutput:k,setFullOutput:S,addSystemMessage:$,startNewTask:Z=>{let B=Mo();c(B),u(void 0),w(!1),n([]),Z&&$(Z)}}}import{useEffect as bh,useState as jo}from"react";function Wo(t){let[e,s]=jo(null),[i,r]=jo(!0);return bh(()=>{let n=!1;async function o(){try{let l=await ye();if(n)return;s({accessToken:l.accessToken,workspaceId:l.workspaceId}),r(!1)}catch(l){if(n)return;if(l instanceof _e){if(l.code==="not-logged-in"){t({status:"not-logged-in"}),r(!1);return}if(l.code==="no-workspace"){t({status:"no-workspace"}),r(!1);return}}let a=l instanceof Error?l.message:"Failed to authenticate";t({status:"error",message:a}),r(!1)}}return o(),()=>{n=!0}},[t]),{credentials:e,loading:i}}import{useEffect as xh,useState as ms}from"react";function Uo(t){let[e,s]=ms([]),[i,r]=ms([]),[n,o]=ms([]),[l,a]=ms([]),[c,d]=ms(!1);return xh(()=>{if(!t)return;let u=!1;d(!0);async function f(){if(t)try{let w=new kt,[m,y,x,C]=await Promise.all([w.getConnectors(t.accessToken,t.workspaceId),w.listSelectableModels(t.accessToken,t.workspaceId),w.getAgents(t.accessToken,t.workspaceId),w.getModelProviders(t.accessToken,t.workspaceId)]);if(u)return;s(m.connectors),r(y.models),o(x.agents),a(C.providers??[])}catch{}finally{u||d(!1)}}return f(),()=>{u=!0}},[t]),{availableConnectors:e,availableModels:i,availableAgents:n,modelProviders:l,loading:c}}import qe from"fs";import Go from"path";import{useCallback as vh}from"react";import{v4 as Th}from"uuid";function zo(t,e){if(!t)return"(no result)";if(typeof t!="object"){let r=String(t);return e||r.length<=200?r:r.slice(0,200)+"..."}let s=t;if("structuredContent"in s&&s.structuredContent){let r=s.structuredContent;if(r.stdout&&typeof r.stdout=="string"){let n=r.stdout.trim();return e||n.length<=200?n:n.slice(0,200)+"..."}}if("content"in s&&Array.isArray(s.content)){let r=s.content.filter(n=>n.type==="text"&&n.text).map(n=>n.text).join(`
|
|
39
|
-
`);return r?e||r.length<=200?r:r.slice(0,200)+"...":"(result)"}if(s.type==="text"&&typeof s.content=="string"){let r=s.content;return e||r.length<=200?r:r.slice(0,200)+"..."}let i=JSON.stringify(t,null,e?2:void 0);return e||i.length<=200?i:i.slice(0,200)+"..."}function Fe(t,e=!1){let s=[];for(let i of t)if(i.type==="text"&&i.text)s.push(i.text);else if(i.type==="reasoning"&&i.text)e?s.push(`${Kt}[Thinking]
|
|
40
|
-
${i.text}${tt}`):s.push(`${Kt}[Thinking...]${tt}`);else if(i.type==="tool-call"&&i.toolName){let r=[`${Rt}\u250C\u2500 Tool: ${i.toolName}${tt}`];if(i.args){let n=JSON.stringify(i.args,null,e?2:void 0),o=e||n.length<=100?n:n.slice(0,100)+"...";r.push(`${Kt}\u2502 Args: ${o}${tt}`)}i.result===void 0?r.push(`${Rt}\u2514\u2500${tt}`):(r.push(`${Ve}\u2502 Result: ${zo(i.result,e)}${tt}`),r.push(`${Rt}\u2514\u2500 completed${tt}`)),s.push(r.join(`
|
|
41
|
-
`))}else if(i.type.startsWith("tool-")&&i.type!=="tool-call"){let r=i.title||i.type.slice(5).replace(/__/g," "),n=[`${Rt}\u250C\u2500 Tool: ${r}${tt}`];if(i.input){let o=JSON.stringify(i.input,null,e?2:void 0),l=e||o.length<=100?o:o.slice(0,100)+"...";n.push(`${Kt}\u2502 Input: ${l}${tt}`)}i.output!==void 0&&i.state==="output-available"?(n.push(`${Ve}\u2502 Output: ${zo(i.output,e)}${tt}`),n.push(`${Rt}\u2514\u2500 completed${tt}`)):i.state==="error"?n.push(`${Rt}\u2514\u2500 failed${tt}`):n.push(`${Rt}\u2514\u2500${tt}`),s.push(n.join(`
|
|
42
|
-
`))}return s.join(`
|
|
43
|
-
|
|
44
|
-
`).trim()}var ci=class{pendingToolCalls=new Map;hasPending(){return this.pendingToolCalls.size>0}hasExecuting(){for(let e of this.pendingToolCalls.values())if(e.status==="executing")return!0;return!1}clear(e){this.pendingToolCalls.delete(e)}buildToolDisplay(){if(this.pendingToolCalls.size===0)return"";let e=[];for(let[,s]of this.pendingToolCalls){let i=s.toolName.replace(/__/g," "),r=`
|
|
45
|
-
|
|
46
|
-
${Rt}\u250C\u2500 Tool: ${i}${tt}`;if(s.args){let n=s.args.length>100?s.args.slice(0,100)+"...":s.args;r+=`
|
|
47
|
-
${Kt}\u2502 Input: ${n}${tt}`}if(s.output){let n=s.output.length>150?s.output.slice(0,150)+"...":s.output;r+=`
|
|
48
|
-
${Ve}\u2502 Output: ${n}${tt}`}else if(s.status==="executing"){let n=s.startedAt??Date.now(),o=Math.floor((Date.now()-n)/1e3);r+=`
|
|
49
|
-
${Rt}\u2502${tt} (executing... ${o}s)`}else s.status==="preparing"&&(r+=`
|
|
50
|
-
${Rt}\u2502${tt} (preparing...)`);e.push(r)}return e.join("")}flushPending(e){if(this.pendingToolCalls.size===0)return e;for(let[s,i]of this.pendingToolCalls){let r=i.toolName.replace(/__/g," "),n=typeof i.args=="string"&&i.args.length>100?i.args.slice(0,100)+"...":i.args||"";e+=`
|
|
51
|
-
|
|
52
|
-
${Rt}\u250C\u2500 Tool: ${r}${tt}`,n&&(e+=`
|
|
53
|
-
${Kt}\u2502 Input: ${n}${tt}`),e+=`
|
|
54
|
-
${Rt}\u2514\u2500 completed${tt}
|
|
55
|
-
`,this.pendingToolCalls.delete(s)}return e}handleToolInputStart(e){return e.toolCallId&&e.toolName?(this.pendingToolCalls.set(e.toolCallId,{toolName:e.toolName,args:"",status:"preparing"}),this.buildToolDisplay()):null}handleToolInputDelta(e){if(e.toolCallId&&e.inputTextDelta){let s=this.pendingToolCalls.get(e.toolCallId);if(s)return s.args=(s.args||"")+e.inputTextDelta,s.status="executing",s.startedAt??=Date.now(),this.buildToolDisplay()}return null}handleToolOutputStart(e){if(e.toolCallId){let s=this.pendingToolCalls.get(e.toolCallId);if(s)return s.output="",s.status="output",this.buildToolDisplay()}return null}handleToolOutputDelta(e){if(e.toolCallId&&e.outputTextDelta){let s=this.pendingToolCalls.get(e.toolCallId);if(s)return s.output=(s.output||"")+e.outputTextDelta,this.buildToolDisplay()}return null}handleToolOutputEnd(e,s){if(!e.toolCallId)return null;let i=this.pendingToolCalls.get(e.toolCallId);if(!i)return null;let r=i.toolName.replace(/__/g," "),n=typeof i.args=="string"&&i.args.length>100?i.args.slice(0,100)+"...":i.args||"",o=(i.output||"").length>200?(i.output||"").slice(0,200)+"...":i.output||"";return s+=`
|
|
56
|
-
|
|
57
|
-
${Rt}\u250C\u2500 Tool: ${r}${tt}`,n&&(s+=`
|
|
58
|
-
${Kt}\u2502 Input: ${n}${tt}`),s+=`
|
|
59
|
-
${Ve}\u2502 Output: ${o}${tt}`,s+=`
|
|
60
|
-
${Rt}\u2514\u2500 completed${tt}
|
|
61
|
-
`,this.pendingToolCalls.delete(e.toolCallId),{fullResponse:s,toolDisplay:this.buildToolDisplay()}}handleToolError(e,s){if(!e.toolCallId)return null;let r=(this.pendingToolCalls.get(e.toolCallId)?.toolName||e.toolName||"Tool").replace(/__/g," "),n=e.errorText||"Unknown error",o=n.length>200?n.slice(0,200)+"...":n;return s+=`
|
|
62
|
-
|
|
63
|
-
${Rt}\u250C\u2500 Tool: ${r}${tt}`,s+=`
|
|
64
|
-
${Fo}\u2502 Error: ${o}${tt}`,s+=`
|
|
65
|
-
${Rt}\u2514\u2500 failed${tt}
|
|
66
|
-
`,this.pendingToolCalls.delete(e.toolCallId),{fullResponse:s,toolDisplay:this.buildToolDisplay()}}};var ys=Go.join(process.env.HOME||"/tmp",".entrydesk","stream-debug.log");function nt(t,e){if(!process.env.DEBUG)return;let i=`[${new Date().toISOString()}] ${t}`;e!==void 0&&(i+=`
|
|
67
|
-
DATA: ${JSON.stringify(e,null,2)}`),i+=`
|
|
68
|
-
`;try{qe.appendFileSync(ys,i)}catch{}}function Ch(){try{if(qe.existsSync(ys)&&qe.unlinkSync(ys),process.env.DEBUG){let t=Go.dirname(ys);qe.existsSync(t)||qe.mkdirSync(t,{recursive:!0}),qe.writeFileSync(ys,`=== Debug session started at ${new Date().toISOString()} ===
|
|
69
|
-
`)}}catch{}}function ws(t){if(!t)return{};if(typeof t=="string")try{return JSON.parse(t)}catch{return{}}return typeof t=="object"?t:{}}function Ho({taskId:t,credentials:e,currentAgentId:s,currentModel:i,activeConnectorIds:r,localTools:n,toolApprovalMode:o,onApprovalRequest:l,fullOutput:a,setMessages:c,setState:d,setCurrentResponse:u,setCredentials:f,setHasPersistedTask:w,getFileIds:m,clearFiles:y}){let x=n?Zs():void 0,C=n?Qs():void 0;return{sendMessage:vh(async(S,$,R)=>{Ch(),nt("=== sendMessage called ===",{text:S,localTools:n,clientToolsCount:x?.length});let Z=$||e?.accessToken,B=R||e?.workspaceId;if(!Z||!B)try{let E=await ye();Z=E.accessToken,B=E.workspaceId,f(E)}catch(E){if(E instanceof _e){if(E.code==="not-logged-in"){d({status:"not-logged-in"});return}if(E.code==="no-workspace"){d({status:"no-workspace"});return}}let et=E instanceof Error?E.message:"Authentication failed";d({status:"error",message:et});return}else try{let E=await gr();E!==Z&&(Z=E,f({accessToken:E,workspaceId:B}))}catch(E){if(E instanceof _e&&E.code==="not-logged-in"){d({status:"not-logged-in"});return}let et=E instanceof Error?E.message:"Authentication failed";d({status:"error",message:et});return}c(E=>[...E,{role:"user",content:S}]),d({status:"sending"}),u("");let I=null,g=null;try{let E=new kt,et=m?.()??[],xt={id:t,message:{id:Th(),createdAt:new Date,role:"user",parts:[{type:"text",text:S}]},toolApprovalMode:o};et.length>0&&(xt.fileIds=et),s?xt.agentId=s:(i&&(xt.model=i),xt.connectorIds=r??[]),x&&(xt.clientTools=x),C&&(xt.clientToolSystemPrompt=C);let F=await E.task(Z,B,xt);if(!F.ok){let v=await F.text();throw new Error(`API error ${F.status}: ${v}`)}if(!F.body)throw new Error("No response body from server");I=F.body.getReader();let U=new TextDecoder,z="",L="",dt="",J="",H="",pt="",st="",Q=new ci,ut=[],St=[],Tt=new Map,O=[],ct=[],q=()=>{let v=Q.hasExecuting();v&&!g?g=setInterval(()=>{if(!Q.hasExecuting()){g&&(clearInterval(g),g=null);return}u(L+Q.buildToolDisplay())},1e3):!v&&g&&(clearInterval(g),g=null)};for(;;){let{done:v,value:Y}=await I.read();if(v)break;z+=U.decode(Y,{stream:!0});let D=z.split(`
|
|
70
|
-
`);z=D.pop()||"";for(let it of D)if(it.trim()!=="data: [DONE]"&&it.startsWith("data: "))try{let _=JSON.parse(it.slice(6));switch(nt(`SSE event received: ${_.type}`,_),_.type){case"reasoning-start":J=_.id||"0",dt="";break;case"reasoning-delta":_.delta&&(dt+=_.delta,u(`${Kt}[Thinking...]${tt}
|
|
71
|
-
${dt}`)),_.providerMetadata?.anthropic?.signature&&(H=_.providerMetadata.anthropic.signature);break;case"reasoning-end":if(dt){let V={type:"reasoning",id:J,text:dt,state:"done"};H&&(V.providerMetadata={anthropic:{signature:H}}),O.push(V),nt("Added reasoning to messageParts",{reasoningLength:dt.length,hasSignature:!!H,messagePartsCount:O.length})}dt="",H="",u("");break;case"text-delta":_.delta&&(Q.hasPending()&&(L=Q.flushPending(L)),L+=_.delta,pt+=_.delta,u(L));break;case"tool-input-start":{let V=Q.handleToolInputStart(_);V&&u(L+V),q();break}case"tool-input-delta":{let V=Q.handleToolInputDelta(_);V&&u(L+V),q();break}case"tool-call":case"tool-input-available":if(nt(`=== Tool event: ${_.type} ===`,{toolCallId:_.toolCallId,toolName:_.toolName,localTools:n,isClientToolResult:_.toolName?oe(_.toolName):"no toolName",args:_.args,input:_.input}),_.toolCallId&&_.toolName){let V=ws(_.args??_.input);O.push({type:_.type,toolCallId:_.toolCallId,toolName:_.toolName,args:V}),nt("Added tool to messageParts",{messagePartsCount:O.length})}if(_.toolCallId&&_.toolName&&Tt.set(_.toolCallId,{toolName:_.toolName,input:ws(_.args??_.input)}),n&&_.toolCallId&&_.toolName&&oe(_.toolName)){let V=ws(_.args??_.input);ut.push({toolCallId:_.toolCallId,toolName:_.toolName,args:V}),nt("Added to pendingClientTools",{pendingCount:ut.length,pendingClientTools:ut}),u(L+Q.buildToolDisplay()+`
|
|
72
|
-
[Executing ${_.toolName} locally...]`)}else nt("NOT added to pendingClientTools - conditions not met",{localTools:n,hasToolCallId:!!_.toolCallId,hasToolName:!!_.toolName,isClientTool:_.toolName?oe(_.toolName):!1});break;case"tool-approval-request":or({approvalId:_.approvalId,toolCallId:_.toolCallId,seenToolCalls:Tt,pendingClientTools:ut,pendingApprovals:St}),nt("=== Approval requested ===",_);break;case"tool-output-start":{let V=Q.handleToolOutputStart(_);V&&u(L+V),q();break}case"tool-output-delta":{let V=Q.handleToolOutputDelta(_);V&&u(L+V),q();break}case"tool-output-end":{let V=Q.handleToolOutputEnd(_,L);V&&(L=V.fullResponse,u(L+V.toolDisplay)),q();break}case"tool-input-error":case"tool-output-error":{let V=Q.handleToolError(_,L);V&&(L=V.fullResponse,u(L+V.toolDisplay)),q();break}case"start":_.messageId&&(st=_.messageId,nt("Captured messageId from start event",{messageId:st}));break;case"start-step":case"text-start":case"text-end":case"finish-step":case"message-metadata":case"finish":break;case"error":_.errorText&&console.error("Stream error:",_.errorText);break}}catch{}}if(pt){let v=O.findIndex(D=>D.type!=="reasoning"),Y=v===-1?O.length:v;O.splice(Y,0,{type:"text",text:pt}),nt("Added accumulated text to messageParts",{textLength:pt.length,insertIndex:Y})}nt("=== Initial stream ended ===",{pendingClientToolsCount:ut.length,pendingClientTools:ut,messagePartsCount:O.length,messageParts:O.map(v=>({type:v.type,toolCallId:v.toolCallId,toolName:v.toolName}))});let lt=async v=>{if(!st)throw new Error("Cannot continue: missing assistant message id for tool results.");let Y={id:t,message:{id:st,role:"assistant",parts:v},toolApprovalMode:o};s?Y.agentId=s:(i&&(Y.model=i),Y.connectorIds=r??[]),x&&(Y.clientTools=x),C&&(Y.clientToolSystemPrompt=C),nt("=== Sending continuation request ===",{taskId:t,hasAgentId:!!Y.agentId,hasModel:!!Y.model,partCount:v.length});let D=await E.task(Z,B,Y);if(nt("=== Continuation response received ===",{ok:D.ok,status:D.status}),!D.ok){let it=await D.text();throw new Error(`Continuation failed: ${D.status}: ${it}`)}if(!D.body)return!1;for(nt("=== Processing continuation stream ==="),I=D.body.getReader(),O.length=0,pt="",dt="",J="",H="";;){let{done:it,value:_}=await I.read();if(it){nt("=== Continuation stream done ===");break}z+=U.decode(_,{stream:!0});let V=z.split(`
|
|
73
|
-
`);z=V.pop()||"";for(let Zt of V)if(Zt.trim()!=="data: [DONE]"&&Zt.startsWith("data: "))try{let X=JSON.parse(Zt.slice(6));switch(nt(`Continuation SSE: ${X.type}`,X),X.type){case"start":X.messageId&&(st=X.messageId);break;case"reasoning-start":J=X.id||"0",dt="";break;case"reasoning-delta":X.delta&&(dt+=X.delta,u(`${Kt}[Thinking...]${tt}
|
|
74
|
-
${dt}`)),X.providerMetadata?.anthropic?.signature&&(H=X.providerMetadata.anthropic.signature);break;case"reasoning-end":if(dt){let M={type:"reasoning",id:J,text:dt,state:"done"};H&&(M.providerMetadata={anthropic:{signature:H}}),O.push(M),nt("Continuation: Added reasoning to messageParts",{reasoningLength:dt.length,hasSignature:!!H,messagePartsCount:O.length})}dt="",H="",u(L);break;case"text-delta":X.delta&&(L+=X.delta,pt+=X.delta,u(L));break;case"tool-call":case"tool-input-available":if(X.toolCallId&&X.toolName){let M=ws(X.args??X.input);O.push({type:X.type,toolCallId:X.toolCallId,toolName:X.toolName,args:M}),Tt.set(X.toolCallId,{toolName:X.toolName,input:M})}if(n&&X.toolCallId&&X.toolName&&oe(X.toolName)){let M=ws(X.args??X.input);ut.push({toolCallId:X.toolCallId,toolName:X.toolName,args:M}),nt("Continuation: Added to pendingClientTools",{pendingCount:ut.length})}break;case"tool-approval-request":or({approvalId:X.approvalId,toolCallId:X.toolCallId,seenToolCalls:Tt,pendingClientTools:ut,pendingApprovals:St}),nt("Continuation: approval requested",X);break;case"finish":nt("Continuation finish event",X);break}}catch{}}if(pt){let it=O.findIndex(V=>V.type!=="reasoning"),_=it===-1?O.length:it;O.splice(_,0,{type:"text",text:pt})}return nt("=== Continuation stream processing complete ===",{pendingClientToolsCount:ut.length,messagePartsCount:O.length,fullResponseLength:L.length}),!0},ht=[];for(;St.length>0||ut.length>0||ht.length>0;){nt("=== Starting pending tools execution loop ===",{pendingCount:ut.length,pendingApprovals:St.length,pendingRejections:ht.length});let v=[],Y=[],D=[];if(St.length>0){let M=St.splice(0),at=l?await l(M):new Map,$t=vt=>!!n&&oe(vt);v.push(...Do(M,at)),D=Oo(M,at,$t);for(let vt of M)at.get(vt.approvalId)!==!0&&$t(vt.toolName)&&ct.push({type:`tool-${vt.toolName}`,toolName:vt.toolName,toolCallId:vt.toolCallId,input:vt.input,output:"Rejected by user.",isError:!0});Y.push(...Lo(M,at,$t))}let it=[],_=new Map(ut.map(M=>[M.toolCallId,M.args]));for(let M of ut){nt(`Executing tool: ${M.toolName}`,{toolCallId:M.toolCallId,args:M.args}),Q.handleToolInputStart({toolCallId:M.toolCallId,toolName:M.toolName}),Q.handleToolInputDelta({toolCallId:M.toolCallId,inputTextDelta:JSON.stringify(M.args)}),u(L+Q.buildToolDisplay()),q();let at=await ti(M.toolName,M.args);if(nt(`Tool execution result: ${M.toolName}`,{success:at.success,resultPreview:at.success?JSON.stringify(at.result).slice(0,200):at.error}),it.push({toolCallId:M.toolCallId,toolName:M.toolName,content:ei(at),isError:!at.success}),at.success){Q.handleToolOutputStart({toolCallId:M.toolCallId}),Q.handleToolOutputDelta({toolCallId:M.toolCallId,outputTextDelta:JSON.stringify(at.result).slice(0,200)});let $t=Q.handleToolOutputEnd({toolCallId:M.toolCallId},L);$t&&(L=$t.fullResponse)}else{let $t=Q.handleToolError({toolCallId:M.toolCallId,errorText:at.error},L);$t&&(L=$t.fullResponse)}u(L+Q.buildToolDisplay()),q()}ut.length=0;for(let M of it){let at=[];for(let vt of M.content)vt.type==="text"?at.push(vt.text):vt.type==="image"?at.push("[Image]"):vt.type==="audio"?at.push("[Audio]"):(vt.type==="resource"||vt.type==="resource_link")&&at.push("[Resource]");let $t=at.join(`
|
|
75
|
-
`);ct.push({type:`tool-${M.toolName}`,toolName:M.toolName,toolCallId:M.toolCallId,input:_.get(M.toolCallId)??{},output:$t,isError:M.isError})}if(nt("=== Sending clientToolResults for continuation ===",{toolResultsCount:it.length,toolResults:it.map(M=>({toolCallId:M.toolCallId,toolName:M.toolName,isError:M.isError}))}),I)try{I.releaseLock()}catch{}let V=it.map(M=>({type:`tool-${M.toolName}`,toolCallId:M.toolCallId,state:"output-available",output:{content:M.content,isError:M.isError}}));ut.push(...Y);let Zt=[...v,...ht,...V];if(ht=D,!await lt(Zt))break}if(n&&x&&x.length>0){let v=[];for(let D of ct)v.push({type:String(D.type),title:String(D.toolName).replace(/__/g," "),input:D.input,output:D.output,state:D.isError?"error":"output-available"});for(let D of O)D.type==="text"&&D.text&&v.push({type:"text",text:D.text});let Y=Fe(v,a);nt("=== Using formatted parts for local tools ===",{executedToolsCount:ct.length,textPartsCount:O.filter(D=>D.type==="text").length,contentLength:Y.length}),c(D=>[...D,{role:"assistant",content:Y,parts:v}])}else{nt("=== Fetching message from API ===",{fullResponseLength:L.length,fullResponsePreview:L.slice(0,200)});try{let{messages:v}=await E.getMessages(Z,B,t,10);nt("=== API messages received ===",{count:v.length,roles:v.map(D=>D.role)});let Y=v.find(D=>D.role==="assistant");if(Y){let D=Y.parts,it=Fe(D,a);nt("=== Setting message from API ===",{partsCount:D.length,partTypes:D.map(_=>_.type),contentLength:it.length,contentPreview:it.slice(0,200)}),c(_=>[..._,{role:"assistant",content:it,parts:D}])}else nt("=== No assistant message found, using fallback ==="),c(D=>[...D,{role:"assistant",content:L}])}catch(v){nt("=== API fetch failed, using fallback ===",{error:v instanceof Error?v.message:String(v)}),c(Y=>[...Y,{role:"assistant",content:L}])}}nt("=== Message handling complete ==="),u(""),d({status:"ready"}),w(!0),et.length>0&&y?.()}catch(E){nt("=== ERROR ===",{message:E instanceof Error?E.message:String(E),stack:E instanceof Error?E.stack:void 0});let et=E instanceof Error?E.message:"Failed to send message";d({status:"error",message:et})}finally{if(g&&(clearInterval(g),g=null),I)try{I.releaseLock()}catch{}}},[e,t,s,i,r,n,o,l,x,C,a,c,d,u,f,w,m,y])}}import{useState as kh}from"react";var Xo=new Map([["sandbox","Sandbox"],["web_search","Web Search"],["image_generation","Image Generation"],["chart","Chart"],["file_system","FileSystem"]]);function Vo(t){let[e,s]=kh(t);return{fileSystem:e,setFileSystem:s,capabilityLabelMap:Xo}}import{useEffect as Sh,useState as Eh}from"react";function qo(t,e){let[s,i]=Eh(null);return Sh(()=>{let r=!1;async function n(){if(!t||!e){i(null);return}try{let l=await new kt().getAgent(e.accessToken,e.workspaceId,t);r||i(l)}catch{r||i(null)}}return n(),()=>{r=!0}},[t,e]),{currentAgentDetails:s}}import{useState as lr}from"react";function Yo(t,e,s){let[i,r]=lr(t),[n,o]=lr(e),[l,a]=lr(s);return{currentModel:i,setCurrentModel:r,currentAgentId:n,setCurrentAgentId:o,activeConnectorIds:l,setActiveConnectorIds:a}}import{useApp as Ah,useInput as _h}from"ink";import{useCallback as me,useRef as Ph,useState as jt}from"react";import{spawn as $h}from"child_process";function Jo(t){return new Promise((e,s)=>{let i,r;process.platform==="darwin"?(i="open",r=[t]):process.platform==="win32"?(i="cmd",r=["/c","start","",t]):(i="xdg-open",r=[t]);let n=$h(i,r,{stdio:"ignore",detached:!0});n.once("error",o=>{s(o)}),n.once("spawn",()=>{n.unref(),e()})})}var Ko=[{name:"help",aliases:["h","?"],description:"Show available commands"},{name:"clear",aliases:["cls","new"],description:"Start a new task"},{name:"model",aliases:["m"],description:"Show/switch model",hasArgs:!0},{name:"agent",aliases:["a"],description:"Show/switch agent",hasArgs:!0},{name:"skills",aliases:["sk"],description:"List skills",hasArgs:!0},{name:"schedules",aliases:["sch"],description:"List schedules",hasArgs:!0},{name:"connectors",aliases:["conn"],description:"Select connectors"},{name:"capabilities",aliases:["cap"],description:"Toggle client capabilities"},{name:"approval",aliases:[],description:"Choose when tool calls need your approval"},{name:"tasks",aliases:["c"],description:"Switch to another task"},{name:"workspace",aliases:["ws"],description:"List/switch workspace",hasArgs:!0},{name:"budget",aliases:["bg"],description:"View/set workspace budget",hasArgs:!0},{name:"usage",aliases:["u"],description:"View current month usage"},{name:"status",aliases:["s"],description:"Show session status"},{name:"profile",aliases:["p"],description:"Manage profiles",hasArgs:!0},{name:"open-in-browser",aliases:[],description:"Open current task in browser"},{name:"share",aliases:[],description:"Get share link for current task"},{name:"delete",aliases:["del"],description:"Delete current task"},{name:"quit",aliases:["exit","q"],description:"Exit task"}];function Zo(t){if(!t.startsWith("/"))return[];let e=t.slice(1).toLowerCase();return e?Ko.filter(s=>s.name.startsWith(e)||s.aliases.some(i=>i.startsWith(e))):Ko}function Qo(t){let e=t.trim();if(!e.startsWith("/"))return null;let s=e.slice(1).split(/\s+/),i=s[0]?.toLowerCase(),r=s.slice(1).join(" ");switch(i){case"help":case"h":case"?":return{type:"help"};case"clear":case"cls":case"new":return{type:"clear"};case"model":case"m":return{type:"model",value:r||void 0};case"agent":case"a":return{type:"agent",value:r||void 0};case"skills":case"sk":return{type:"skills",value:r||void 0};case"schedules":case"sch":return{type:"schedules",value:r||void 0};case"connectors":case"conn":return{type:"connectors"};case"capabilities":case"cap":return{type:"capabilities"};case"approval":return{type:"approval"};case"tasks":case"c":return{type:"tasks"};case"workspace":case"ws":return{type:"workspace",value:r||void 0};case"budget":case"bg":return{type:"budget",value:r||void 0};case"usage":case"u":return{type:"usage"};case"status":case"s":return{type:"status"};case"profile":case"p":return{type:"profile",value:r||void 0};case"open-in-browser":return{type:"open-in-browser"};case"share":return{type:"share"};case"delete":case"del":return{type:"delete"};case"quit":case"exit":case"q":return{type:"quit"};default:return{type:"unknown",input:e}}}var tl=`Available commands:
|
|
76
|
-
/help, /h, /? Show this help message
|
|
77
|
-
/clear, /cls, /new Start a new task
|
|
78
|
-
/model [name], /m Show current model or switch to [name]
|
|
79
|
-
/agent [name], /a Show current agent or switch to [name]
|
|
80
|
-
/skills [name], /sk List skills or show details for [name]
|
|
81
|
-
/schedules [id], /sch List schedules or show details for [id]
|
|
82
|
-
/connectors, /conn Select active connectors
|
|
83
|
-
/capabilities, /cap Toggle client capabilities (FileSystem)
|
|
84
|
-
/approval Choose when tool calls need your approval
|
|
85
|
-
/tasks, /c Switch to another task
|
|
86
|
-
/workspace [id], /ws List or switch workspace
|
|
87
|
-
/budget [amount], /bg View or set workspace budget
|
|
88
|
-
/usage, /u View current month usage (top 10 by cost)
|
|
89
|
-
/status, /s Show current session status
|
|
90
|
-
/profile [args], /p Manage profiles (list/show/use/create/delete/rename/clone)
|
|
91
|
-
/open-in-browser Open current task in browser
|
|
92
|
-
/share Get share link for current task
|
|
93
|
-
/delete, /del Delete current task
|
|
94
|
-
/quit, /exit, /q Exit interactive mode
|
|
95
|
-
|
|
96
|
-
Note: For detailed usage with sorting/limits, use: entrydesk usage --help
|
|
97
|
-
|
|
98
|
-
Keyboard shortcuts:
|
|
99
|
-
Ctrl+O Toggle full output mode
|
|
100
|
-
Ctrl+C Exit`;function ar(t){if(t.type==="no-repeat")return"No repeat";let{interval:e}=t;switch(e.unit){case"minutes":return`Every ${e.every} min`;case"hours":return`Every ${e.every} hr`;case"days":return`Every ${e.every} day at ${String(e.time.hour).padStart(2,"0")}:${String(e.time.minute).padStart(2,"0")}`;case"weeks":return`Every ${e.every} week`;case"months":return`Every ${e.every} month`;default:return"Unknown"}}function el({input:t,setInput:e,taskId:s,setTaskId:i,currentTaskTitle:r,setCurrentTaskTitle:n,currentModel:o,setCurrentModel:l,currentAgentId:a,setCurrentAgentId:c,currentAgentDetails:d,setCurrentAgentDetails:u,activeConnectorIds:f,setActiveConnectorIds:w,fileSystem:m,setFileSystem:y,toolApprovalMode:x,setToolApprovalMode:C,availableModels:k,availableAgents:S,availableConnectors:$,messages:R,hasPersistedTask:Z,setHasPersistedTask:B,setMessages:I,addSystemMessage:g,startNewTask:E,sendMessage:et,setFullOutput:xt,credentials:F,setCredentials:U,setState:z,defaultCapabilities:L,capabilityLabelMap:dt,hasUploadingFiles:J=!1}){let{exit:H}=Ah(),[pt,st]=jt([]),[Q,ut]=jt(0),[St,Tt]=jt(!1),[O,ct]=jt(null),[q,lt]=jt([]),[ht,v]=jt(0),[Y,D]=jt(new Set),[it,_]=jt(new Set),[V,Zt]=jt([]),[X,M]=jt([]),[at,$t]=jt([]),[vt,Cs]=jt([]),[ae,we]=jt(null),[ks,Ce]=jt(""),ke=Ph(!1),[ce,Se]=jt(!1),Oe=me(async()=>{if(!F)return[];let P=new kt,T=[],h;do{let p=await P.listAvailableSkills(F.accessToken,F.workspaceId,{limit:100,nextKey:h});T.push(...p.skills),h=p.nextKey}while(h);return M(T),T},[F]),Le=me(async()=>{if(!F)return[];let P=new kt,T=[],h;do{let p=await P.getSchedules(F.accessToken,F.workspaceId,{limit:100,nextKey:h});T.push(...p.schedules),h=p.nextKey}while(h);return $t(T),T},[F]),Ft=me(async P=>{if(P==="model"){if(k.length===0){g("No models available.");return}let T=k.map(p=>({id:p.id,name:p.name,description:p.description}));lt(T);let h=o?T.findIndex(p=>p.id===o):-1;v(Math.max(h,0)),ct("model")}else if(P==="agent"){if(S.length===0){g("No agents available.");return}let T=S.map(p=>({id:p.id,name:p.name,description:p.description}));lt(T);let h=a?T.findIndex(p=>p.id===a):-1;v(Math.max(h,0)),ct("agent")}else if(P==="skills"){let T=X;if(T.length===0)try{T=await Oe()}catch{g("Failed to load skills.");return}if(T.length===0){g("No skills available.");return}let h=T.map(p=>({id:p.id,name:p.name,description:p.description}));lt(h),v(0),ct("skills")}else if(P==="schedules"){let T=at;if(T.length===0)try{T=await Le()}catch{g("Failed to load schedules.");return}if(T.length===0){g("No schedules found.");return}let h=T.map(p=>({id:p.id,name:p.name,description:`${p.agent.name} - ${p.isActive?"Active":"Paused"}`}));lt(h),v(0),ct("schedules")}else if(P==="connectors"){if($.length===0){g("No connectors available.");return}let T=$.map(h=>({id:h.id,name:h.name}));lt(T),v(0),D(new Set(f)),ct("connectors")}else if(P==="capabilities"){lt([{id:"fileSystem",name:"FileSystem",description:"Local file operations"}]),v(0);let h=new Set;m&&h.add("fileSystem"),_(h),ct("capabilities")}else if(P==="approval"){let T=Object.values($s);lt(T.map(h=>({id:h,name:$e[h],description:h===x?`${Me[h]} (current)`:Me[h]}))),v(Math.max(0,T.indexOf(x))),ct("approval")}else if(P==="tasks"){if(!F){g("Not authenticated.");return}try{let T=new kt,{tasks:h}=await T.getTasks(F.accessToken,F.workspaceId,20);if(h.length===0){g("No tasks available.");return}Zt(h);let p=h.map(N=>({id:N.id,name:N.title||"Untitled",description:new Date(N.createdAt).toLocaleDateString()}));lt(p);let b=p.findIndex(N=>N.id===s);v(Math.max(b,0)),ct("tasks")}catch{g("Failed to load tasks.")}}else if(P==="profile"){let T=gt.getProfileNames(),h=gt.getCurrentProfileName(),p=T.map(N=>({id:N,name:N,description:N===h?"(current)":void 0}));lt(p);let b=p.findIndex(N=>N.id===h);v(Math.max(b,0)),ct("profile")}Tt(!1),st([])},[k,S,X,at,$,f,o,a,m,x,Oe,Le,F,s,g]),Qt=me(P=>{let T=mt.getAll(P);l(T.model?.default),c(void 0),u(null);let h=T.connectors?.defaults;w(h&&h.length>0?h:void 0);let p=T.localTools;y(p?.fileSystem??L.fileSystem),C(T.toolApprovalMode??Ee)},[l,c,u,w,y,C,L]),ie=me(async()=>{try{let P=await ye();U({accessToken:P.accessToken,workspaceId:P.workspaceId}),z({status:"ready"})}catch(P){if(U(null),P instanceof _e){if(P.code==="not-logged-in"){z({status:"not-logged-in"});return}if(P.code==="no-workspace"){z({status:"no-workspace"});return}}let T=P instanceof Error?P.message:"Failed to authenticate";z({status:"error",message:T})}},[U,z]),At=me(async P=>{switch(P.type){case"help":return g(tl),!0;case"clear":return E("Started a new task."),!0;case"model":if(P.value){let T=P.value.toLowerCase(),h=k.find(p=>p.id.toLowerCase()===T||p.name.toLowerCase().includes(T));if(h)a?E(`Switched to model: ${h.name} (new task)`):g(`Switched to model: ${h.name}`),l(h.id),c(void 0),u(null),mt.setDefaultModel(h.id);else{let p=k.map(b=>b.name).join(", ");g(`Model "${P.value}" not found.
|
|
101
|
-
Available: ${p||"none"}`)}}else{let T=k.find(h=>h.id===o)?.name||o;g(o?`Current model: ${T}`:"No model selected. Using agent mode.")}return!0;case"agent":{if(!P.value)return S.length===0?(g("No agents available."),!0):(Ft("agent"),!0);let T=P.value.toLowerCase(),h=S.find(p=>p.id.toLowerCase()===T||p.name.toLowerCase().includes(T));if(h)h.id===a?g(`Switched to agent: ${h.name}`):E(`Switched to agent: ${h.name} (new task)`),c(h.id),l(void 0);else{let p=S.map(b=>b.name).join(", ");g(`Agent "${P.value}" not found.
|
|
102
|
-
Available: ${p||"none"}`)}return!0}case"skills":{if(!P.value)return Ft("skills"),!0;let T=P.value.toLowerCase();return(X.length>0?Promise.resolve(X):Oe().catch(()=>[])).then(p=>{let b=p.find(N=>N.id.toLowerCase()===T||N.name.toLowerCase().includes(T));g(b?`Skill: ${b.name}
|
|
103
|
-
${b.description}
|
|
104
|
-
Provider: ${b.provider}
|
|
105
|
-
Author: ${b.author.name}
|
|
106
|
-
ID: ${b.id}`:`Skill "${P.value}" not found.`)}),!0}case"schedules":{if(!P.value)return Ft("schedules"),!0;let T=P.value.toLowerCase();return(at.length>0?Promise.resolve(at):Le().catch(()=>[])).then(p=>{let b=p.find(N=>N.id.toLowerCase()===T||N.name.toLowerCase().includes(T));if(b){let N=b.nextRunAt?new Date(b.nextRunAt).toLocaleString():"-";g(`Schedule: ${b.name}
|
|
107
|
-
Agent: ${b.agent.name}
|
|
108
|
-
Status: ${b.isActive?"Active":"Paused"}
|
|
109
|
-
Repeat: ${ar(b.config)}
|
|
110
|
-
Next Run: ${N}
|
|
111
|
-
ID: ${b.id}`)}else g(`Schedule "${P.value}" not found.`)}),!0}case"connectors":{if(a){let h=d?.connectors??[];if(h.length===0)g("No agent connectors.");else{let p=h.map(b=>` - ${b.name}`).join(`
|
|
112
|
-
`);g(`Agent connectors:
|
|
113
|
-
${p}`)}return!0}let T=$.filter(h=>f?.includes(h.id));if(T.length===0)g("No active connectors.");else{let h=T.map(p=>` - ${p.name}`).join(`
|
|
114
|
-
`);g(`Active connectors:
|
|
115
|
-
${h}`)}return!0}case"capabilities":{if(a){let p=(d?.capabilities??[]).map(b=>dt.get(b)??b);return g(p.length>0?`Agent capabilities:
|
|
116
|
-
${p.map(b=>` - ${b}`).join(`
|
|
117
|
-
`)}`:"No agent capabilities."),!0}let T=[];return m&&T.push("FileSystem"),g(T.length>0?`Active capabilities:
|
|
118
|
-
${T.map(h=>` - ${h}`).join(`
|
|
119
|
-
`)}`:"No capabilities enabled."),!0}case"approval":return g(`Tool approval: ${$e[x]} \u2014 ${Me[x]}`),!0;case"tasks":return g(r?`Current task: ${r}`:`Current task: ${s.slice(0,8)}...`),!0;case"workspace":{if(!F)return g("Not authenticated."),!0;let T=new kt;if(!P.value){try{let{workspaces:p}=await T.getWorkspaces(F.accessToken);if(p.length===0)g("No workspaces found.");else{let b=p.map(N=>` ${N.id===F.workspaceId?"* ":" "}${N.name}
|
|
120
|
-
ID: ${N.id}`);g(`Workspaces:
|
|
121
|
-
${b.join(`
|
|
122
|
-
`)}`)}}catch(p){g(`Failed to load workspaces: ${p instanceof Error?p.message:"Unknown error"}`)}return!0}let h=P.value;try{let{workspaces:p}=await T.getWorkspaces(F.accessToken),b=p.find(N=>N.id===h);if(!b)return g(`Workspace not found: ${h}`),!0;await Ae.saveWorkspaceId(h),g(`Switched to workspace: ${b.name}`),g("Please restart the task to apply changes.")}catch(p){g(`Failed to switch workspace: ${p instanceof Error?p.message:"Unknown error"}`)}return!0}case"budget":{if(!F)return g("Not authenticated."),!0;let T=new kt;if(!P.value){try{let b=await T.getBudget(F.accessToken,F.workspaceId);b.budget===null?g("No budget set for this workspace."):g(`Current budget: $${b.budget}`)}catch(b){g(`Failed to get budget: ${b instanceof Error?b.message:"Unknown error"}`)}return!0}let h=P.value.toLowerCase();if(h==="clear"||h==="null"){try{await T.updateBudget(F.accessToken,F.workspaceId,null),g("Budget cleared.")}catch(b){g(`Failed to clear budget: ${b instanceof Error?b.message:"Unknown error"}`)}return!0}let p=Number.parseFloat(h);if(Number.isNaN(p)||p<0)return g("Invalid budget amount. Must be a positive number."),!0;try{await T.updateBudget(F.accessToken,F.workspaceId,h),g(`Budget set to: $${h}`)}catch(b){g(`Failed to set budget: ${b instanceof Error?b.message:"Unknown error"}`)}return!0}case"usage":{if(!F)return g("Not authenticated."),!0;let T=new kt;try{let h=[],p,b=0,N=10;do{let W=await T.getMonthlyUsages(F.accessToken,F.workspaceId,{nextKey:p,limit:20});if(h.push(...W.monthlyUsages),p=W.nextKey,b++,b>=N){g(`Warning: Showing first ${h.length} entries (pagination limit reached)`);break}}while(p);if(h.length===0)return g("No usage data found for this workspace."),!0;let rt=0,yt=0;for(let W of h)rt+=Number.parseFloat(W.totalCost),yt+=W.operationCount;let he=[...h].toSorted((W,ft)=>Number.parseFloat(ft.totalCost)-Number.parseFloat(W.totalCost)),K=10,bt=he.slice(0,K),A=[`Total Cost: $${rt.toFixed(2)}`,`Total Operations: ${yt.toLocaleString()}`,`Users: ${h.length}`,"",`Top ${bt.length} Users by Cost:`,...bt.map(W=>` ${W.user.name}: $${Number.parseFloat(W.totalCost).toFixed(2)} (${W.operationCount.toLocaleString()} ops)`)];h.length>K&&(A.push("",`... and ${h.length-K} more users`),A.push("Use CLI command for full list: entrydesk usage --limit <n> --sort-by <cost|operations>")),g(A.join(`
|
|
123
|
-
`))}catch(h){g(`Failed to get usage: ${h instanceof Error?h.message:"Unknown error"}`)}return!0}case"status":{let T=gt.getCurrentProfileName(),h=o?k.find(rt=>rt.id===o)?.name||o:null,p=a?S.find(rt=>rt.id===a)?.name||a:null,b=f?$.filter(rt=>f.includes(rt.id)).map(rt=>rt.name):[],N=[];return m&&N.push("FileSystem"),Ae.getEmail().then(rt=>{let yt=[`Profile: ${T}${T==="default"?"":" (non-default)"}`,rt?`Logged in as: ${rt}`:"Not logged in",F?.workspaceId?`Workspace: ${F.workspaceId}`:null,Z?`Task ID: ${s}`:null,h?`Model: ${h}`:null,p?`Agent: ${p}`:null,`Connectors: ${b.length>0?b.join(", "):"none"}`,`Capabilities: ${N.length>0?N.join(", "):"none"}`].filter(Boolean);g(yt.join(`
|
|
124
|
-
`))}).catch(()=>{let rt=[`Profile: ${T}`,"Not logged in",Z?`Task ID: ${s}`:null,h?`Model: ${h}`:null,p?`Agent: ${p}`:null,`Connectors: ${b.length>0?b.join(", "):"none"}`,`Capabilities: ${N.length>0?N.join(", "):"none"}`].filter(Boolean);g(rt.join(`
|
|
125
|
-
`))}),!0}case"profile":{let T=P.value?P.value.split(/\s+/).filter(Boolean):[];if(T.length===0)return Ft("profile"),!0;let h=T[0]?.toLowerCase()||"list",p=T[1],b=T[2],N=gt.getProfileNames(),rt=gt.getCurrentProfileName(),yt=gt.getOverrideProfile(),he=(K,bt=!1)=>{if(K)return K;if(bt&&N.length===1)return N[0];throw new Error("Profile name is required when multiple profiles exist.")};try{if(h==="list"){let K=[`Profiles (${N.length}):`];for(let bt of N){let A=bt===rt?" (current)":"";K.push(` ${bt}${A}`)}return g(K.join(`
|
|
126
|
-
`)),!0}if(h==="current")return g(`Current profile: ${rt}`),!0;if(h==="show"){let K=he(p,!0),bt=mt.getAll(K),A=await Ae.getAll(K),W=!!A?.accessToken,ft=bt.connectors?.defaults&&bt.connectors.defaults.length>0?bt.connectors.defaults.join(", "):"unset",Ot=[`Profile: ${K}${K===rt?" (current)":""}`,`API URL: ${bt.apiUrl??"default"}`,`Hub URL: ${bt.hubUrl??"default"}`,`Model: ${bt.model?.default??"unset"}`,`Connectors: ${ft}`,W?`Logged in as: ${A?.email??"unknown"}`:"Not logged in",W&&A?.workspaceId?`Workspace ID: ${A.workspaceId}`:null].filter(Boolean);return g(Ot.join(`
|
|
127
|
-
`)),!0}if(h==="create"){let K=p||gt.DEFAULT_PROFILE;return gt.createProfile(K),g(`Profile created: ${K}`),!0}if(h==="use"||h==="switch"){let K=he(p,!0);return gt.setOverrideProfile(K),gt.setCurrentProfile(K),Qt(K),await ie(),E(`Switched to profile: ${K} (new task)`),!0}if(h==="delete"||h==="remove"||h==="rm"){let K=he(p,!0),bt=K===rt,A=gt.deleteProfile(K);await Ae.deleteProfileCredentials(K);let W=`Profile deleted: ${K}`;if(bt)gt.setOverrideProfile(A.currentProfile),Qt(A.currentProfile),await ie(),E(`${W}
|
|
128
|
-
Switched to profile: ${A.currentProfile} (new task)`);else if(yt===K){let ft=gt.getCurrentProfileName();gt.setOverrideProfile(ft),Qt(ft),await ie(),E(`${W}
|
|
129
|
-
Switched to profile: ${ft} (new task)`)}else g(W);return!0}if(h==="rename"||h==="move"||h==="mv"){let K=he(p,!0);if(!b)throw new Error("New profile name is required.");let bt=gt.renameProfile(K,b);return await Ae.moveProfileCredentials(K,b),g(`Profile renamed: ${K} -> ${b}`),yt===K?(gt.setOverrideProfile(b),Qt(b)):bt.currentProfile===b&&Qt(b),!0}if(h==="clone"||h==="copy"){let K=he(p,!0);if(!b)throw new Error("Target profile name is required.");let bt=mt.getAll(K);return gt.createProfile(b),mt.setAll(bt,b),await Ae.clear(b),g(`Profile cloned: ${K} -> ${b}`),!0}g(`Unknown profile command: ${h}`)}catch(K){let bt=K instanceof Error?K.message:"Unknown error";g(`Profile error: ${bt}`)}return!0}case"open-in-browser":{let T=wi().hubUrl.replace(/\/$/,""),h=Z||R.some(yt=>yt.role!=="system"),p=F?`/${F.workspaceId}`:"",b=h?`${p}/task/${s}`:`${p}/task/new`,N=a?`?agentId=${encodeURIComponent(a)}`:"",rt=`${T}${b}${N}`;try{await Jo(rt),g(`Opened in browser: ${rt}`)}catch(yt){g(`Failed to open browser: ${yt instanceof Error?yt.message:"Unknown error"}
|
|
130
|
-
URL: ${rt}`)}return!0}case"share":{if(!F)return g("Not authenticated."),!0;if(!(Z||R.some(h=>h.role!=="system")))return g("No conversation to share. Start a task first."),!0;try{let p=await new kt().createTaskShare(F.accessToken,F.workspaceId,s,"public"),N=`${wi().hubUrl.replace(/\/$/,"")}/share/${p.id}`;g(`Share link: ${N}`)}catch(h){g(`Failed to create share link: ${h instanceof Error?h.message:"Unknown error"}`)}return!0}case"delete":return F?Z?(Se(!0),g("Delete this task? (y/N)"),!0):(g("No task to delete."),!0):(g("Not authenticated."),!0);case"quit":return H(),!0;case"unknown":return g(`Unknown command: ${P.input}
|
|
131
|
-
Type /help for available commands.`),!0;default:return!1}},[g,k,S,$,X,at,o,a,f,m,s,r,H,Ft,E,dt,d,Z,R,Oe,Le,I,l,c,u,l,Qt,ie]),Ss=me(P=>{if(ke.current=!1,ce){(P===""||P.startsWith("/"))&&(e(P),P.startsWith("/")&&Se(!1));return}if(e(P),Ce(P),ae!==null&&we(null),O&&(ct(null),lt([])),P.startsWith("/")&&!P.includes(" ")){let T=Zo(P);st(T),ut(0),Tt(T.length>0)}else Tt(!1),st([])},[O,ae,ce,e]),Ye=me((P,T=!1)=>{if(P>=0&&P<pt.length){let h=pt[P];Tt(!1),st([]),h.name==="model"?(e("/model "),Ft("model")):h.name==="agent"?(e("/agent "),Ft("agent")):h.name==="skills"?(e("/skills "),Ft("skills")):h.name==="schedules"?(e("/schedules "),Ft("schedules")):h.name==="connectors"?(e("/connectors "),Ft("connectors")):h.name==="capabilities"?(e("/capabilities "),Ft("capabilities")):h.name==="approval"?(e("/approval "),Ft("approval")):h.name==="tasks"?(e("/tasks "),Ft("tasks")):h.name==="profile"?(e("/profile "),Ft("profile")):T?(e(""),At({type:h.name})):e(`/${h.name}`)}},[pt,Ft,e,At]),gi=me(async P=>{ke.current=!1;let T=P.trim();if(!T||ce)return;if(O==="model"&&q.length>0){let p=q[ht];p&&(a?E(`Switched to model: ${p.name} (new task)`):g(`Switched to model: ${p.name}`),l(p.id),c(void 0),u(null)),ct(null),lt([]),e("");return}if(O==="agent"&&q.length>0){let p=q[ht];p&&(p.id===a?g(`Switched to agent: ${p.name}`):E(`Switched to agent: ${p.name} (new task)`),c(p.id),l(void 0)),ct(null),lt([]),e("");return}if(O==="skills"&&q.length>0){let p=q[ht];if(p){let b=X.find(N=>N.id===p.id);b&&g(`Skill: ${b.name}
|
|
132
|
-
${b.description}
|
|
133
|
-
Provider: ${b.provider}
|
|
134
|
-
Author: ${b.author.name}
|
|
135
|
-
ID: ${b.id}`)}ct(null),lt([]),e("");return}if(O==="schedules"&&q.length>0){let p=q[ht];if(p){let b=at.find(N=>N.id===p.id);if(b){let N=b.nextRunAt?new Date(b.nextRunAt).toLocaleString():"-";g(`Schedule: ${b.name}
|
|
136
|
-
Agent: ${b.agent.name}
|
|
137
|
-
Status: ${b.isActive?"Active":"Paused"}
|
|
138
|
-
Repeat: ${ar(b.config)}
|
|
139
|
-
Next Run: ${N}
|
|
140
|
-
ID: ${b.id}`)}}ct(null),lt([]),e("");return}if(O==="connectors"){let p=[...Y];w(p.length>0?p:void 0),mt.setDefaultConnectorIds(p);let b=$.filter(N=>Y.has(N.id)).map(N=>N.name);g(b.length>0?`Active connectors: ${b.join(", ")}`:"All connectors disabled."),ct(null),lt([]),e("");return}if(O==="capabilities"){let p=it.has("fileSystem");y(p),mt.setLocalTools({fileSystem:p});let b=[];p&&b.push("FileSystem"),g(b.length>0?`Active capabilities: ${b.join(", ")}`:"All capabilities disabled."),ct(null),lt([]),e("");return}if(O==="approval"&&q.length>0){let p=q[ht];if(p){let b=p.id;C(b),mt.setToolApprovalMode(b),g(`Tool approval: ${$e[b]} \u2014 ${Me[b]}`)}ct(null),lt([]),e("");return}if(O==="profile"&&q.length>0){let p=q[ht];if(p){let b=gt.getCurrentProfileName();p.id===b?g(`Already using profile: ${p.name}`):(gt.setOverrideProfile(p.id),gt.setCurrentProfile(p.id),Qt(p.id),ie(),E(`Switched to profile: ${p.name}`))}ct(null),lt([]),e("");return}if(St&&pt.length>0){Ye(Q,!0);return}we(null),Ce(""),Cs(p=>p.length>0&&p.at(-1)===T?p:[...p,T]);let h=Qo(T);if(h){await At(h),e(""),Tt(!1);return}if(J){g("Please wait for file uploads to complete.");return}e(""),Tt(!1),et(T)},[et,At,St,pt,Q,Ye,O,q,ht,Y,it,$,X,at,g,e,a,E,l,c,u,w,y,J,Qt,ie,ce,F,Z,s]);return _h((P,T)=>{if(T.ctrl&&P==="c"){if(t.length>0){Ss(""),ke.current=!0,g("Press Ctrl+C again to exit.");return}if(ke.current){H();return}H();return}if(T.ctrl&&P==="o"){xt(h=>!h);return}if(ce){if(T.escape||T.return||P==="n"||P==="N"){Se(!1),e(""),g("Task deletion cancelled.");return}if(P==="y"||P==="Y"){Se(!1),e(""),F&&Z&&new kt().deleteTask(F.accessToken,F.workspaceId,s).then(()=>{E("Task deleted. Started a new task.")}).catch(p=>{g(`Failed to delete task: ${p.message||"Unknown error"}`)});return}return}if(O&&q.length>0){if(T.upArrow){v(h=>h<=0?q.length-1:h-1);return}if(T.downArrow){v(h=>h>=q.length-1?0:h+1);return}if(T.escape){ct(null),lt([]),e("");return}if(T.return){if(O==="model"){let h=q[ht];h&&(a?E(`Switched to model: ${h.name} (new task)`):g(`Switched to model: ${h.name}`),l(h.id),c(void 0),u(null),mt.setDefaultModel(h.id))}else if(O==="agent"){let h=q[ht];h&&(h.id===a?g(`Switched to agent: ${h.name}`):E(`Switched to agent: ${h.name} (new task)`),c(h.id),l(void 0))}else if(O==="skills"){let h=q[ht];if(h){let p=X.find(b=>b.id===h.id);p&&g(`Skill: ${p.name}
|
|
141
|
-
${p.description}
|
|
142
|
-
Provider: ${p.provider}
|
|
143
|
-
Author: ${p.author.name}
|
|
144
|
-
ID: ${p.id}`)}}else if(O==="schedules"){let h=q[ht];if(h){let p=at.find(b=>b.id===h.id);if(p){let b=p.nextRunAt?new Date(p.nextRunAt).toLocaleString():"-";g(`Schedule: ${p.name}
|
|
145
|
-
Agent: ${p.agent.name}
|
|
146
|
-
Status: ${p.isActive?"Active":"Paused"}
|
|
147
|
-
Repeat: ${ar(p.config)}
|
|
148
|
-
Next Run: ${b}
|
|
149
|
-
ID: ${p.id}`)}}}else if(O==="connectors"){let h=[...Y];w(h.length>0?h:void 0),mt.setDefaultConnectorIds(h);let p=$.filter(b=>Y.has(b.id)).map(b=>b.name);g(p.length>0?`Active connectors: ${p.join(", ")}`:"All connectors disabled.")}else if(O==="capabilities"){let h=it.has("fileSystem");y(h),mt.setLocalTools({fileSystem:h});let p=[];h&&p.push("FileSystem"),g(p.length>0?`Active capabilities: ${p.join(", ")}`:"All capabilities disabled.")}else if(O==="approval"){let h=q[ht];if(h){let p=h.id;C(p),mt.setToolApprovalMode(p),g(`Tool approval: ${$e[p]} \u2014 ${Me[p]}`)}}else if(O==="tasks"){let h=q[ht];if(h){let p=V.find(b=>b.id===h.id);p&&F&&(i(p.id),n(p.title||void 0),B(!0),new kt().getMessages(F.accessToken,F.workspaceId,p.id,20).then(({messages:N})=>{let rt=N.filter(yt=>yt.role==="user"||yt.role==="assistant").map(yt=>({role:yt.role,content:Fe(yt.parts,!1),parts:yt.parts})).filter(yt=>yt.content).toReversed();I(rt),g(`Switched to: ${p.title||"Untitled"}`)}).catch(()=>{g("Failed to load task messages.")}))}}else if(O==="profile"){let h=q[ht];if(h){let p=gt.getCurrentProfileName();h.id===p?g(`Already using profile: ${h.name}`):(gt.setOverrideProfile(h.id),gt.setCurrentProfile(h.id),Qt(h.id),ie(),E(`Switched to profile: ${h.name}`))}}ct(null),lt([]),e("");return}if(P===" "&&(O==="connectors"||O==="capabilities")){let h=q[ht];h&&(O==="connectors"?D:_)(b=>{let N=new Set(b);return N.has(h.id)?N.delete(h.id):N.add(h.id),N});return}if(P==="a"&&(O==="connectors"||O==="capabilities")){(O==="connectors"?D:_)(new Set(q.map(p=>p.id)));return}if(P==="n"&&(O==="connectors"||O==="capabilities")){(O==="connectors"?D:_)(new Set);return}return}if(St&&pt.length>0){if(T.upArrow){ut(h=>h<=0?pt.length-1:h-1);return}if(T.downArrow){ut(h=>h>=pt.length-1?0:h+1);return}if(T.escape){Tt(!1),st([]);return}if(T.tab){Ye(Q);return}}if(T.upArrow){if(t.includes(`
|
|
150
|
-
`)||vt.length===0)return;if(ae===null){Ce(t);let p=vt.length-1;we(p),e(vt[p]);return}let h=Math.max(0,ae-1);we(h),e(vt[h]);return}if(T.downArrow){if(t.includes(`
|
|
151
|
-
`)||ae===null)return;if(ae>=vt.length-1){we(null),e(ks);return}let h=ae+1;we(h),e(vt[h])}}),{suggestions:pt,suggestionIndex:Q,showSuggestions:St,argMode:O,argItems:q,argIndex:ht,selectedConnectorIds:Y,selectedCapabilities:it,deleteConfirmMode:ce,handleInputChange:Ss,handleSubmit:gi}}import{useCallback as bs,useRef as Ih,useState as Rh}from"react";function sl({credentials:t,currentModel:e,modelProviders:s,onUploadSuccess:i,onUploadError:r}){let[n,o]=Rh([]),l=Ih(0),a=bs(y=>{if(!(!Array.isArray(s)||s.length===0)){for(let x of s)if(x.models.some(k=>k.id===y))return x.id;return s[0]?.id}},[s]),c=bs(async y=>{if(!t){r?.(y.filename,"Not logged in");return}if(!Array.isArray(s)||s.length===0){r?.(y.filename,"Model providers not loaded yet. Please wait and try again.");return}let x=e?a(e):s[0]?.id;if(!x){r?.(y.filename,"No model provider available");return}let C=`file-${++l.current}`;o(k=>[...k,{id:C,filename:y.filename,mimeType:y.mimeType,status:"uploading"}]);try{let S=await new kt().uploadFile(t.accessToken,t.workspaceId,y,x);o($=>$.map(R=>R.id===C?{...R,status:"uploaded",fileId:S.id}:R)),i?.(y.filename)}catch(k){let S=k instanceof Error?k.message:"Upload failed";o($=>$.map(R=>R.id===C?{...R,status:"error",error:S}:R)),r?.(y.filename,S)}},[t,e,a,s,i,r]),d=bs(y=>{o(x=>x.filter(C=>C.id!==y))},[]),u=bs(()=>{o([])},[]),f=bs(()=>n.filter(y=>y.status==="uploaded").map(y=>y.fileId).filter(dr),[n]),w=n.some(y=>y.status==="uploading"),m=n.length>0;return{pendingFiles:n,addFile:c,removeFile:d,clearFiles:u,getUploadedFileIds:f,hasUploadingFiles:w,hasFiles:m}}import{jsx as G,jsxs as ot}from"react/jsx-runtime";var Nh=[" ______ _ ____ _","| ____| | | | _ \\ | |","| |__ _ __ | |_ _ __ _ _ | | | | ___ ___| | __","| __| | '_ \\| __| '__| | | || | | |/ _ \\/ __| |/ /","| |____| | | | |_| | | |_| || |_| | __/\\__ \\ <","|______|_| |_|\\__|_| \\__, ||____/ \\___||___/_|\\_\\"," __/ |"," |___/"],Fh=[rr,rr,ir,ir,Ne,Ne,Ne,Ne],il=Nh.map((t,e)=>`${Fh[e]??Ne}${t}${tt}`).join(`
|
|
152
|
-
`),Dh=`${Ne}EntryDesk${tt}`,Oh=500;function Lh(t){let e="",s=0;for(;s<t.length;){if(t.charCodeAt(s)===27&&t[s+1]==="["){for(s+=2;s<t.length;){let i=t.charCodeAt(s);if(i>=64&&i<=126){s+=1;break}s+=1}continue}e+=t[s],s+=1}return e}function Mh(t){let e=Lh(t);return Math.max(...e.split(`
|
|
153
|
-
`).map(s=>s.length))}function Bh(t){let e=Mh(il);return t>=e?il:Dh}function rl({agentId:t,model:e,message:s,taskId:i,taskTitle:r,connectorIds:n,enableFileSystem:o=!0,toolApprovalMode:l=Ee}){let[a,c]=hr(l),[d,u]=hr([]),f=vs(null),w=vs(new Map),m=hi(A=>(w.current=new Map,u(A),new Promise(W=>{f.current=W})),[]),y=process.stdout.columns??80,x=Bh(y),C=vs(null),k=Bo(i,r),{state:S,setState:$,messages:R,setMessages:Z,input:B,setInput:I,taskId:g,setTaskId:E,currentTaskTitle:et,setCurrentTaskTitle:xt,hasPersistedTask:F,setHasPersistedTask:U,credentials:z,setCredentials:L,currentResponse:dt,setCurrentResponse:J,fullOutput:H,setFullOutput:pt,addSystemMessage:st,startNewTask:Q}=k,{credentials:ut}=Wo($);ui(()=>{ut&&!z&&L(ut)},[ut,z,L]);let{availableConnectors:St,availableModels:Tt,availableAgents:O,modelProviders:ct,loading:q}=Uo(z),{currentModel:lt,setCurrentModel:ht,currentAgentId:v,setCurrentAgentId:Y,activeConnectorIds:D,setActiveConnectorIds:it}=Yo(e,t,n),_=vs(!1);ui(()=>{if(!_.current){if(_.current=!0,!e&&!t){let A=mt.getDefaultModel();A&&ht(A)}if(!n&&!t){let A=mt.getDefaultConnectorIds();A&&it(A.length>0?A:void 0)}}},[e,t,n,ht,it]);let{currentAgentDetails:V}=qo(v,z),{fileSystem:Zt,setFileSystem:X,capabilityLabelMap:M}=Vo(o),{pendingFiles:at,addFile:$t,removeFile:vt,clearFiles:Cs,getUploadedFileIds:ae,hasUploadingFiles:we,hasFiles:ks}=sl({credentials:z,currentModel:lt,modelProviders:ct,onUploadSuccess:A=>{st(`\u2713 Attached: ${A}`)},onUploadError:(A,W)=>{st(`\u2717 Failed to upload ${A}: ${W}`)}}),{sendMessage:Ce}=Ho({taskId:g,credentials:z,currentAgentId:v,currentModel:lt,activeConnectorIds:D,localTools:Zt,toolApprovalMode:a,onApprovalRequest:m,fullOutput:H,setMessages:Z,setState:$,setCurrentResponse:J,setCredentials:L,setHasPersistedTask:U,getFileIds:ae,clearFiles:Cs}),ke=hi(A=>{Q(A),J("")},[Q]),[ce,Se]=hr(!1),Oe=hi(async A=>{let W=A.text.trim(),ft=ai(W);if(/^https?:\/\//.test(ft))return;if(await Ro(W)&&Io(ft)){let Es=await No(W);Es&&(A.preventDefault(),await $t(Es))}},[$t]),Le=hi(async()=>{if(!(ce||S.status!=="ready")){if(q||ct.length===0){st("Please wait for resources to load before pasting images.");return}st("Reading clipboard..."),Se(!0);try{let A=await Po();if(A){let W=`clipboard-${Date.now()}.png`;st(`Uploading: ${W} (${Math.round(A.buffer.length/1024)}KB)`),await $t({buffer:A.buffer,filename:W,mimeType:A.mime})}else st("No image found in clipboard. Copy an image first.")}catch(A){let W=A instanceof Error?A.message:"Failed to read clipboard";st(`Clipboard error: ${W}`)}finally{Se(!1)}}},[$t,st,ce,S.status,q,ct.length]),{suggestions:Ft,suggestionIndex:Qt,showSuggestions:ie,argMode:At,argItems:Ss,argIndex:Ye,selectedConnectorIds:gi,selectedCapabilities:P,deleteConfirmMode:T,handleInputChange:h,handleSubmit:p}=el({input:B,setInput:I,taskId:g,setTaskId:E,currentTaskTitle:et,setCurrentTaskTitle:xt,currentModel:lt,setCurrentModel:ht,currentAgentId:v,setCurrentAgentId:Y,currentAgentDetails:V,setCurrentAgentDetails:()=>{},activeConnectorIds:D,setActiveConnectorIds:it,fileSystem:Zt,setFileSystem:X,toolApprovalMode:a,setToolApprovalMode:c,availableModels:Tt,availableAgents:O,availableConnectors:St,messages:R,hasPersistedTask:F,setHasPersistedTask:U,setMessages:Z,addSystemMessage:st,startNewTask:ke,sendMessage:Ce,setFullOutput:pt,credentials:z,setCredentials:L,setState:$,defaultCapabilities:{fileSystem:o},capabilityLabelMap:M,hasUploadingFiles:we});xs((A,W)=>{(W.ctrl||W.meta)&&A==="v"&&Le()},{isActive:S.status==="ready"&&!At}),xs((A,W)=>{if(!W.escape)return;let ft=Date.now(),Ot=C.current;C.current=ft,!(!Ot||ft-Ot>Oh)&&(At||ie||(C.current=null,ks&&Cs(),B.length>0&&h("")))},{isActive:S.status==="ready"}),xs((A,W)=>{W.return&&(ke("Started a new task."),$({status:"ready"}))},{isActive:S.status==="error"}),xs((A,W)=>{if(!W.tab||!W.shift)return;let ft=Object.values($s),Ot=ft[(ft.indexOf(a)+1)%ft.length]??Ee;c(Ot),mt.setToolApprovalMode(Ot)},{isActive:S.status==="ready"&&!At}),xs(A=>{let W=d[0];if(!W)return;let ft=A.toLowerCase();if(ft!=="y"&&ft!=="n")return;w.current.set(W.approvalId,ft==="y");let Ot=d.slice(1);u(Ot),Ot.length===0&&(f.current?.(w.current),f.current=null)},{isActive:d.length>0}),ui(()=>{if(z&&!q&&S.status==="loading")if(!lt&&!v){let A=mt.getDefaultModel(),W=A&&Tt.some(Ot=>Ot.id===A),ft=W?A:Tt[0]?.id;ft?(W||mt.setDefaultModel(ft),ht(ft),$({status:"ready"})):O.length===0?$({status:"no-model"}):$({status:"ready"})}else $({status:"ready"})},[z,q,lt,v,Tt,O,S.status,ht,$]);let b=vs(!1);if(ui(()=>{b.current||s&&z&&S.status==="ready"&&(b.current=!0,Ce(s))},[z,s,S.status,Ce]),S.status==="loading")return ot(Et,{flexDirection:"column",children:[G(j,{children:x}),ot(Et,{children:[G(j,{color:"cyan",children:G(cr,{type:"dots"})}),G(j,{children:" Initializing task..."})]})]});if(S.status==="not-logged-in")return ot(Et,{flexDirection:"column",children:[G(j,{children:x}),G(j,{color:"yellow",children:"Not logged in"}),G(j,{dimColor:!0,children:"Run `entrydesk login` to authenticate first."})]});if(S.status==="no-workspace")return ot(Et,{flexDirection:"column",children:[G(j,{children:x}),G(j,{color:"yellow",children:"No workspace selected"}),G(j,{dimColor:!0,children:"Run `entrydesk workspaces` to select a workspace first."})]});if(S.status==="no-model")return ot(Et,{flexDirection:"column",children:[G(j,{children:x}),G(j,{color:"yellow",children:"No model or agent specified"}),i&&G(j,{dimColor:!0,children:"Could not determine the model used in this task."}),G(j,{dimColor:!0,children:"Please specify a model with --model or use an agent with -a."}),G(j,{dimColor:!0,children:"Example: entrydesk task -c 1 -i --model gemini-2.5-flash-lite"})]});if(S.status==="error")return ot(Et,{flexDirection:"column",children:[G(j,{children:x}),ot(j,{color:"red",children:["Error: ",S.message]}),G(j,{dimColor:!0,children:"Press Enter to start a new task, or Ctrl+C to exit"})]});let N=v?V?V.connectors&&V.connectors.length>0?V.connectors.map(A=>A.name).join(", "):"none":"loading...":D&&D.length>0?St.filter(A=>D.includes(A.id)).map(A=>A.name).join(", ")||`${D.length} connector(s)`:"none",rt=[];if(v)if(V?.capabilities)for(let A of V.capabilities)rt.push(M.get(A)??A);else rt.push("loading...");Zt&&rt.push("FileSystem");let yt=gt.getCurrentProfileName(),he=yt!=="default",K=(()=>{switch(At){case"model":return"Select model:";case"agent":return"Select agent:";case"skills":return"Select skill:";case"connectors":return"Select connectors:";case"capabilities":return"Select capabilities:";case"approval":return"Select approval mode:";default:return"Select task:"}})(),bt=(()=>{if(At==="connectors")return gi;if(At==="capabilities")return P})();return ot(Et,{flexDirection:"column",children:[ot(Et,{marginBottom:1,flexDirection:"column",children:[G(j,{children:x}),ot(Et,{children:[G(j,{bold:!0,color:"cyan",children:et?`Continuing: ${et}`:"EntryDesk CLI"}),ot(j,{dimColor:!0,children:[" v","1.30.0"]}),he&&ot(j,{color:"magenta",children:[" [",yt,"]"]}),G(j,{dimColor:!0,children:" (type /help for commands)"})]})]}),R.map((A,W)=>{let ft=A.parts&&H?Fe(A.parts,!0):A.content,Ot=A.role==="user"?"green":A.role==="system"?"yellow":"blue",Es=A.role==="user"?"You":A.role==="system"?"System":"Assistant";return ot(Et,{flexDirection:"column",marginBottom:1,children:[ot(j,{bold:!0,color:Ot,children:[Es,":"]}),G(sr,{text:ft})]},W)}),dt&&ot(Et,{flexDirection:"column",marginBottom:1,children:[G(j,{bold:!0,color:"blue",children:"Assistant:"}),G(sr,{text:dt})]}),S.status==="ready"&&G(po,{suggestions:Ft,activeIndex:Qt,visible:ie}),S.status==="ready"&&At&&G(uo,{items:Ss,activeIndex:Ye,pageSize:At==="agent"||At==="skills"||At==="model"?5:10,selectedIds:bt,multiSelect:At==="connectors"||At==="capabilities",visible:!0,title:K}),d.length>0&&d[0]&&ot(Et,{flexDirection:"column",marginY:1,borderStyle:"round",borderColor:"yellow",paddingX:1,children:[ot(j,{color:"yellow",bold:!0,children:["Approve tool call?",d.length>1&&ot(j,{dimColor:!0,children:[" (1 of ",d.length,")"]})]}),G(j,{children:nr(d[0].toolName)}),G(j,{dimColor:!0,wrap:"truncate-end",children:nr(JSON.stringify(d[0].input))}),G(j,{dimColor:!0,children:"[y] approve [n] reject"})]}),S.status==="sending"&&!dt?ot(Et,{children:[G(j,{color:"cyan",children:G(cr,{type:"dots"})}),G(j,{children:" Thinking..."})]}):S.status==="ready"&&!At?ot(Et,{flexDirection:"column",children:[T&&G(Et,{marginBottom:1,children:G(j,{color:"yellow",children:"\u26A0\uFE0F Delete this task? (y/N) "})}),ks&&!T&&ot(Et,{marginBottom:1,flexDirection:"row",gap:1,children:[G(j,{dimColor:!0,children:"Attachments:"}),at.map((A,W)=>ot(j,{children:[A.status==="uploading"?ot(j,{color:"yellow",children:[G(cr,{type:"dots"})," ",A.filename]}):A.status==="error"?ot(j,{color:"red",children:["\u2717 ",A.filename]}):ot(j,{color:"green",children:["\u2713 ",A.filename]}),W<at.length-1&&G(j,{children:", "})]},A.id))]}),ot(Et,{children:[G(j,{color:"green",children:"> "}),G(vo,{value:B,onChange:h,onSubmit:p,onPaste:Oe,leadingOffset:2,multiline:!0})]})]}):null,ot(Et,{marginTop:1,flexDirection:"column",children:[ot(Et,{gap:2,children:[ot(j,{children:[G(j,{dimColor:!0,children:"Model: "}),G(j,{color:"magenta",children:v?V?.model?.name||"loading...":Tt.find(A=>A.id===lt)?.name||lt||"none"})]}),ot(j,{children:[G(j,{dimColor:!0,children:"Connectors: "}),G(j,{color:"cyan",children:N})]}),ot(j,{children:[G(j,{dimColor:!0,children:"Capabilities: "}),G(j,{color:"green",children:rt.length>0?rt.join(", "):"none"})]}),ot(j,{children:[G(j,{dimColor:!0,children:"Approval: "}),G(j,{color:"yellow",children:$e[a]})]})]}),ot(j,{dimColor:!0,children:["Esc Esc: Clear input & attachments | Ctrl+V: Paste image | Ctrl+O: Toggle full output ",H?"(ON)":"(OFF)"," | Shift+Tab: Approval mode | Ctrl+C: Exit"]})]})]})}import{jsx as Hh}from"react/jsx-runtime";function ag(){console.log(`
|
|
154
|
-
Usage: entrydesk task [options]
|
|
155
|
-
|
|
156
|
-
Send a message to a model or agent, or start an interactive session.
|
|
157
|
-
|
|
158
|
-
Options:
|
|
159
|
-
-m, --message <text> Message to send (or pipe via stdin)
|
|
160
|
-
--model <modelId> Model to use
|
|
161
|
-
-a, --agent <agentId> Agent to use (instead of --model)
|
|
162
|
-
-c, --continue <n> Continue recent task #n
|
|
163
|
-
-i, --interactive Interactive mode (continuous chat)
|
|
164
|
-
--connectors id1,id2 Use specific connectors
|
|
165
|
-
--plain Plain text output
|
|
166
|
-
--output stream-json Stream events as JSON
|
|
167
|
-
--full-output Show full tool outputs
|
|
168
|
-
--no-file-system Disable local file operations
|
|
169
|
-
--json Output JSON
|
|
170
|
-
|
|
171
|
-
Examples:
|
|
172
|
-
entrydesk task -m "Hello" --model <model>
|
|
173
|
-
entrydesk task -m "Hello" -a <agentId>
|
|
174
|
-
entrydesk task -c 1 -m "Follow up" # Continue recent task
|
|
175
|
-
entrydesk task -i # Interactive mode
|
|
176
|
-
echo "Explain this" | entrydesk task --model <model> # Pipe stdin
|
|
177
|
-
entrydesk task -m "Hi" --model <m> --output stream-json
|
|
178
|
-
`)}async function Wh(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8").trim()}async function Uh(t,e,s,i){if(i<1)return console.error("Task number must be 1 or greater"),null;let{tasks:r}=await t.getTasks(e,s,20);if(r.length===0)return console.error("No tasks found. Start a new task first."),null;if(i>r.length)return console.error(`Task number ${i} not found. You have ${r.length} recent tasks.`),console.error("Use `entrydesk tasks` to see available tasks."),null;let n=r[i-1],o;if(!n.agentId){let{messages:l}=await t.getMessages(e,s,n.id,10);o=l.find(c=>c.role==="assistant"&&c.modelId)?.modelId}return{task:n,modelId:o}}var De="\x1B[2m",Nt="\x1B[0m",ur="\x1B[36m",fi="\x1B[33m",di="\x1B[32m",ol="stream-json";function zh(t,e,s,i){t&&e&&(console.error(`Error: Cannot use both ${s} and ${i}`),process.exit(1))}function pi(t,e){let s=e===void 0?{event:t}:{event:t,data:e};process.stdout.write(`${JSON.stringify(s)}
|
|
179
|
-
`)}function Ts(t,e){if(e)return t;let s=t.split(`
|
|
180
|
-
`);if(s.length<=20)return t;let i=s.slice(0,5),r=s.slice(-5),n=s.length-10;return[...i,`${De}... (${n} lines omitted, use --full-output to see all) ...${Nt}`,...r].join(`
|
|
181
|
-
`)}function Gh(t){try{return JSON.stringify(t,null,2)}catch{return String(t)}}function ll(t,e){if(!t)return"(no result)";if(typeof t!="object")return Ts(String(t),e);let s=t;if("structuredContent"in s&&s.structuredContent){let i=s.structuredContent,r=[];if(i.stdout&&typeof i.stdout=="string"&&i.stdout.trim()&&r.push(i.stdout.trim()),i.stderr&&typeof i.stderr=="string"&&i.stderr.trim()&&r.push(`${fi}[stderr]${Nt} ${i.stderr.trim()}`),i.urls&&Array.isArray(i.urls)){let n=i.urls;for(let o of n)o.path&&o.url&&r.push(`${o.path}: ${o.url}`)}return r.length===0&&r.push(JSON.stringify(i,null,2)),Ts(r.join(`
|
|
182
|
-
`),e)}if("content"in s&&Array.isArray(s.content)){let r=s.content.filter(n=>n.type==="text"&&n.text).map(n=>n.text).join(`
|
|
183
|
-
`);return Ts(r||JSON.stringify(t,null,2),e)}return s.type==="text"&&typeof s.content=="string"?Ts(s.content,e):Ts(JSON.stringify(t,null,2),e)}function al(t){try{let s=(typeof t.data=="string"?JSON.parse(t.data):t.data)?.parts;return Array.isArray(s)?s.filter(i=>typeof i=="object"&&i!==null&&i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(""):""}catch{return""}}async function cg(t){t.interactive&&!process.stdin.isTTY&&(console.error("Interactive mode requires a terminal (stdin is not a TTY) \u2014 falling back to non-interactive output. Pass -m/--message or pipe a message via stdin."),t.interactive=!1);let e,s;try{let J=await ye();e=J.accessToken,s=J.workspaceId}catch(J){mr(J)}let i=t.output===ol;t.output&&!i&&(console.error(`Invalid --output value. Supported: ${ol}`),process.exit(1));let r=!i&&(t.plain||!process.stdout.isTTY),n=mt.getDefaultModel(),o=t.message;!o&&!process.stdin.isTTY&&(o=await Wh());let l=new kt,a,c=!1;async function d(){if(c)return a;c=!0;try{({models:a}=await l.listSelectableModels(e,s))}catch{a=void 0}return a}async function u(){let J=await d();if(!J||n&&J.some(pt=>pt.id===n))return;let H=J[0]?.id;H&&(mt.setDefaultModel(H),n=H)}let f,w,m,y;if(t.continue){let J=await Uh(l,e,s,t.continue);if(J||process.exit(1),f=J.task.id,w=J.task.title??void 0,m=J.task.agentId??void 0,y=J.modelId,y&&!m&&!t.model){let pt=await d();pt&&!pt.some(st=>st.id===y)&&(y=void 0)}let H=t.agentId||t.model||m||y||n;!H&&!t.interactive&&(await u(),H=t.agentId||t.model||m||y||n),!H&&!t.interactive&&(r||console.log(`Continuing task: ${J.task.title||"Untitled"}`),console.error(`
|
|
184
|
-
Could not determine model for this task. Please specify --model or -a.`),console.error('Example: entrydesk task -c 1 -m "message" --model gemini-2.5-flash-lite'),process.exit(1)),!r&&!t.interactive&&console.log(`Continuing task: ${J.task.title||"Untitled"}
|
|
185
|
-
`)}let x=t.agentId||m,C=t.model||y||void 0;!x&&!C&&(await u(),C=t.model||y||n||void 0),zh(t.fileSystem,t.noFileSystem,"--file-system","--no-file-system");let k=mt.getDefaultConnectorIds(),S=t.connectors??k??void 0,$=mt.getLocalTools(),R=t.noFileSystem?!1:t.fileSystem?!0:$?.fileSystem??!0;if(t.interactive){jh(Hh(rl,{agentId:x,model:C,message:t.message,taskId:f,taskTitle:w??void 0,connectorIds:S,enableFileSystem:R,toolApprovalMode:mt.getToolApprovalMode()??Ee}),{exitOnCtrlC:!1});return}let Z=!t.continue&&!C&&!x;(!o||Z)&&(console.error("Usage: entrydesk task -m <message> --model <model>"),console.error(" entrydesk task -m <message> -a <agent>"),console.error(" entrydesk task -c <number> -m <message>"),console.error(' echo "message" | entrydesk task --model <model>'),console.error(" entrydesk task -i (interactive mode)"),console.error(""),console.error("Options:"),console.error(" -m, --message Message to send (or pipe via stdin)"),console.error(" --model Model ID to use (required if no agent and no default)"),console.error(" -a, --agent Agent ID to use (required if no model)"),console.error(" -c, --continue Continue recent task by number (1 = most recent)"),console.error(" -i Interactive mode"),console.error(" --plain Plain text output (no colors/formatting)"),console.error(" --output stream-json Stream JSON events (for scripting)"),console.error(" --full-output Show full tool results without truncation"),console.error(" --dangerously-auto-approve-tools"),console.error(" Auto-approve all server-side tool calls (required for"),console.error(" non-interactive use with connectors/MCP tools)"),console.error(""),console.error("List available models: entrydesk models"),console.error("List available agents: entrydesk agents"),console.error("List recent tasks: entrydesk tasks"),process.exit(1));let B=t.fullOutput??!1,I=t.dangerouslyAutoApproveTools??!1,g=f||nl(),E=R?Zs():void 0,et=R?Qs():void 0,xt=J=>{let H={id:g,...I&&{toolApprovalMode:"always_allow"}};return J&&(H.message=J),x?H.agentId=x:(C&&(H.model=C),H.connectorIds=S??[]),E&&(H.clientTools=E),et&&(H.clientToolSystemPrompt=et),H},F=async J=>{if(!J.body)throw new Error("No response body");let H=J.body.getReader(),pt=new TextDecoder,st="",Q=new Map,ut=[],St=!1,Tt="";for(;;){let{done:O,value:ct}=await H.read();if(O)break;st+=pt.decode(ct,{stream:!0});let q=st.split(`
|
|
186
|
-
`);st=q.pop()||"";for(let lt of q){let ht=lt.trimEnd();if(ht==="data: [DONE]"){i&&pi("done");continue}if(ht.startsWith("data: "))try{let v=JSON.parse(ht.slice(6));if((v.type==="text-delta"||v.type==="reasoning-delta"||v.type==="tool-call"||v.type==="tool-input-available"||v.type==="tool-result"||v.type==="data-appendMessage")&&(St=!0),v.type==="start"&&typeof v.messageId=="string"&&(Tt=v.messageId),i){v.type==="text-delta"&&v.delta!==void 0?pi("text-delta",v.delta):v.type==="reasoning-delta"&&v.delta!==void 0?pi("reasoning-delta",v.delta):pi(v.type||"event",v);continue}if(r){if(v.type==="text-delta"&&v.delta&&process.stdout.write(v.delta),v.type==="data-appendMessage"&&process.stdout.write(al(v)),R&&(v.type==="tool-input-available"||v.type==="tool-call")&&v.toolCallId&&v.toolName&&oe(v.toolName)){let Y=v.args||v.input||{};ut.push({toolCallId:v.toolCallId,toolName:v.toolName,args:Y})}continue}switch(v.type){case"reasoning-delta":v.delta&&process.stdout.write(`${De}${v.delta}${Nt}`);break;case"reasoning-end":process.stdout.write(`
|
|
187
|
-
|
|
188
|
-
`);break;case"text-delta":v.delta&&process.stdout.write(v.delta);break;case"data-appendMessage":process.stdout.write(al(v));break;case"tool-call-streaming-start":case"tool-input-start":if(v.toolCallId&&v.toolName){Q.set(v.toolCallId,{toolName:v.toolName});let D=R&&oe(v.toolName)?`${di}[LOCAL]${Nt} `:"";console.log(`
|
|
189
|
-
${ur}\u250C\u2500 ${D}Tool Call: ${v.toolName}${Nt}`)}break;case"tool-call":case"tool-input-available":if(v.toolCallId&&v.toolName){let Y=v.args||v.input||{},D=Gh(Y);console.log(`${fi}\u2502 Arguments:${Nt}`);for(let it of D.split(`
|
|
190
|
-
`))console.log(`${De}\u2502 ${it}${Nt}`);R&&oe(v.toolName)&&(Q.set(v.toolCallId,{toolName:v.toolName,args:Y}),ut.push({toolCallId:v.toolCallId,toolName:v.toolName,args:Y}))}break;case"tool-result":if(v.toolCallId){let Y=Q.get(v.toolCallId),D=ll(v.result,B);console.log(`${di}\u2502 Result:${Nt}`);for(let it of D.split(`
|
|
191
|
-
`))console.log(`${De}\u2502 ${it}${Nt}`);console.log(`${ur}\u2514\u2500 ${Y?.toolName||"Tool"} completed${Nt}
|
|
192
|
-
`),Q.delete(v.toolCallId)}break;case"error":v.errorText&&console.error(`${De}Error: ${v.errorText}${Nt}`);break}}catch{}}}return{pendingClientTools:ut,hadContent:St,messageId:Tt}},U=xt({id:nl(),createdAt:new Date,role:"user",parts:[{type:"text",text:o}]}),z=await l.task(e,s,U),L=await F(z),dt=L.hadContent;for(;L.pendingClientTools.length>0;){let J=L.messageId,H=[];for(let st of L.pendingClientTools){!r&&!i&&console.log(`${di}\u2502 Executing locally...${Nt}`);let Q=await ti(st.toolName,st.args);if(H.push({type:`tool-${st.toolName}`,toolCallId:st.toolCallId,state:"output-available",output:{content:ei(Q),isError:!Q.success}}),!r&&!i){let ut=ll(Q.success?Q.result:{error:Q.error},B);console.log(`${di}\u2502 Result:${Nt}`);for(let St of ut.split(`
|
|
193
|
-
`))console.log(`${De}\u2502 ${St}${Nt}`);console.log(`${ur}\u2514\u2500 ${st.toolName} completed${Nt}
|
|
194
|
-
`)}}J||(console.error(`${fi}Cannot continue: missing assistant message id for tool results.${Nt}`),process.exit(1));let pt=xt({id:J,role:"assistant",parts:H});z=await l.task(e,s,pt),L=await F(z),dt=dt||L.hadContent}dt||(console.error(`${fi}No response received from the server (empty stream).${Nt}`),console.error(`${De}The task may have failed server-side. Re-run with DEBUG=1 for details.${Nt}`),process.exit(1)),i||console.log("")}export{ag as printTaskHelp,cg as runTask};
|