@entrydesk/cli 1.29.0 → 1.31.0
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-PRK5LQNG.js +43 -0
- package/dist/{billing-LXGGM4BO.js → billing-L6QQXRZW.js} +1 -1
- package/dist/{budget-3KJ75AIF.js → budget-NSNB4TFT.js} +1 -1
- package/dist/chunk-FKRIIPBA.js +2 -0
- package/dist/chunk-JMYSCKCF.js +2 -0
- package/dist/chunk-UVF7TGFB.js +120 -0
- package/dist/config-2JH7KXGU.js +4 -0
- package/dist/{config-help-2YHNIPHU.js → config-help-ND4I4Y4D.js} +1 -1
- package/dist/{connectors-YUVHSMJD.js → connectors-26E6RK7B.js} +8 -8
- package/dist/help-KDHCFJNF.js +4 -0
- package/dist/index.js +1 -1
- package/dist/login-WXXDXOHI.js +2 -0
- package/dist/logout-6S6KRPMB.js +2 -0
- package/dist/{marketplace-4NZ4R2RK.js → marketplace-WV4PKSWS.js} +8 -8
- package/dist/mcp-2Q5DRF4P.js +4 -0
- package/dist/{meeting-NAS2QHFI.js → meeting-ZI2UOSO6.js} +5 -5
- package/dist/models-TXYNHCLD.js +3 -0
- package/dist/{notifications-CSXLCFK2.js → notifications-5CD6KFTP.js} +3 -3
- package/dist/{profile-4GVYKBJP.js → profile-OMP7YDYA.js} +1 -1
- package/dist/{recordings-GJIO55FV.js → recordings-MLYXHDWH.js} +3 -3
- package/dist/{schedules-7CGTNN5S.js → schedules-GIAYSDUE.js} +9 -9
- package/dist/{skills-OOY3DP3O.js → skills-IK7KZZ45.js} +3 -3
- package/dist/status-OKGY6H3C.js +2 -0
- package/dist/task-XXJ5PAJF.js +179 -0
- package/dist/{tasks-SJWOHL6F.js → tasks-2TMKPOTB.js} +9 -9
- package/dist/tool-HMD5ROEP.js +35 -0
- package/dist/{update-B3LT5ALF.js → update-DM47OUD3.js} +2 -2
- package/dist/{usage-IQW77ZHI.js → usage-TLLEU4K7.js} +5 -5
- package/dist/version-USTE3KNX.js +2 -0
- package/dist/workflow-PRS2UCQT.js +62 -0
- package/dist/{workspaces-KDZIJPII.js → workspaces-HML7DEAL.js} +3 -3
- package/package.json +9 -7
- package/dist/agents-HRFKKSCB.js +0 -43
- package/dist/chunk-GN6HSCLY.js +0 -4
- package/dist/chunk-LHRI5YM6.js +0 -2
- package/dist/chunk-NOSHH4TO.js +0 -8
- package/dist/chunk-YAWZE3PA.js +0 -91
- package/dist/chunk-ZIAOI7B2.js +0 -2
- package/dist/config-53QOLH2T.js +0 -4
- package/dist/help-FBKSAMA7.js +0 -4
- package/dist/login-BKSNJT4R.js +0 -2
- package/dist/logout-U64RQTQO.js +0 -2
- package/dist/mcp-EON5KZPT.js +0 -4
- package/dist/models-E3O6GOH5.js +0 -3
- package/dist/status-KK6P75DT.js +0 -2
- package/dist/task-ET6X7N52.js +0 -211
- package/dist/token-5JSZTSX7.js +0 -2
- package/dist/token-util-U6DGFQDY.js +0 -2
- package/dist/tool-TW7BI2LH.js +0 -35
- package/dist/version-TG5WFL3B.js +0 -2
- package/dist/workflow-J6RX65V7.js +0 -62
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{B as Ae,C as ht,L as _e,P as qt,T as Li,a as Fr,b as Mi,c as Dr,d as Or,e as Fs,f as Lr,g as Qe,h as Nr,i as Ds,j as Fi,m as Ee,n as Be,p as je,q as ts,s as Re,t as Di,u as Br,v as ot,w as at,x as Oi}from"./chunk-UVF7TGFB.js";import{a as Ha,c as qa}from"./chunk-JMYSCKCF.js";var Vr=Ha((Zh,Ns)=>{"use strict";function Wr(t){return Array.isArray(t)?t:[t]}var Xa=void 0,Bi="",jr=" ",Ni="\\",Va=/^\s+$/,Ya=/(?:[^\\]|^)\\$/,Ka=/^\\!/,Ja=/^\\#/,Za=/\r?\n/g,Qa=/^\.{0,2}\/|^\.{1,2}$/,tl=/\/$/,Ue="/",zr="node-ignore";typeof Symbol<"u"&&(zr=Symbol.for("node-ignore"));var Gr=zr,We=(t,e,s)=>(Object.defineProperty(t,e,{value:s}),s),el=/([0-z])-([0-z])/g,Hr=()=>!1,sl=t=>t.replace(el,(e,s,i)=>s.charCodeAt(0)<=i.charCodeAt(0)?e:Bi),il=t=>{let{length:e}=t;return t.slice(0,e-e%2)},rl=[[/^\uFEFF/,()=>Bi],[/((?:\\\\)*?)(\\?\s+)$/,(t,e,s)=>e+(s.indexOf("\\")===0?jr:Bi)],[/(\\+?)\s/g,(t,e)=>{let{length:s}=e;return e.slice(0,s-s%2)+jr}],[/[\\$.|*+(){^]/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,()=>Ni],[/\\\\/g,()=>Ni],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(t,e,s,i,r)=>e===Ni?`\\[${s}${il(i)}${r}`:r==="]"&&i.length%2===0?`[${sl(s)}${i}]`:"[]"],[/(?:[^*])$/,t=>/\/$/.test(t)?`${t}$`:`${t}(?=$|\\/$)`]],nl=/(^|\\\/)?\\\*$/,es="regex",Os="checkRegex",Ur="_",ol={[es](t,e){return`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`},[Os](t,e){return`${e?`${e}[^/]*`:"[^/]*"}(?=$|\\/$)`}},al=t=>rl.reduce((e,[s,i])=>e.replace(s,i.bind(t)),t),Ls=t=>typeof t=="string",ll=t=>t&&Ls(t)&&!Va.test(t)&&!Ya.test(t)&&t.indexOf("#")!==0,cl=t=>t.split(Za).filter(Boolean),ji=class{constructor(e,s,i,r,n,o){this.pattern=e,this.mark=s,this.negative=n,We(this,"body",i),We(this,"ignoreCase",r),We(this,"regexPrefix",o)}get regex(){let e=Ur+es;return this[e]?this[e]:this._make(es,e)}get checkRegex(){let e=Ur+Os;return this[e]?this[e]:this._make(Os,e)}_make(e,s){let i=this.regexPrefix.replace(nl,ol[e]),r=this.ignoreCase?new RegExp(i,"i"):new RegExp(i);return We(this,s,r)}},ul=({pattern:t,mark:e},s)=>{let i=!1,r=t;r.indexOf("!")===0&&(i=!0,r=r.substr(1)),r=r.replace(Ka,"!").replace(Ja,"#");let n=al(r);return new ji(t,e,r,s,i,n)},Ui=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[Gr]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(Ls(e)&&(e={pattern:e}),ll(e.pattern)){let s=ul(e,this._ignoreCase);this._added=!0,this._rules.push(s)}}add(e){return this._added=!1,Wr(Ls(e)?cl(e):e).forEach(this._add,this),this._added}test(e,s,i){let r=!1,n=!1,o;this._rules.forEach(l=>{let{negative:c}=l;n===c&&r!==n||c&&!r&&!n&&!s||!l[i].test(e)||(r=!c,n=c,o=c?Xa:l)});let a={ignored:r,unignored:n};return o&&(a.rule=o),a}},hl=(t,e)=>{throw new e(t)},se=(t,e,s)=>Ls(t)?t?se.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),qr=t=>Qa.test(t);se.isNotRelative=qr;se.convert=t=>t;var Wi=class{constructor({ignorecase:e=!0,ignoreCase:s=e,allowRelativePaths:i=!1}={}){We(this,Gr,!0),this._rules=new Ui(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&&se.convert(e);return se(n,e,this._strictPathCheck?hl:Hr),this._t(n,s,i,r)}checkIgnore(e){if(!tl.test(e))return this.test(e);let s=e.split(Ue).filter(Boolean);if(s.pop(),s.length){let i=this._t(s.join(Ue)+Ue,this._testCache,!0,s);if(i.ignored)return i}return this._rules.test(e,!1,Os)}_t(e,s,i,r){if(e in s)return s[e];if(r||(r=e.split(Ue).filter(Boolean)),r.pop(),!r.length)return s[e]=this._rules.test(e,i,es);let n=this._t(r.join(Ue)+Ue,s,i,r);return s[e]=n.ignored?n:this._rules.test(e,i,es)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return Wr(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},zi=t=>new Wi(t),dl=t=>se(t&&se.convert(t),t,Hr),Xr=()=>{let t=s=>/^\\\\\?\\/.test(s)||/["<>|\u0000-\u001F]+/u.test(s)?s:s.replace(/\\/g,"/");se.convert=t;let e=/^[a-z]:\//i;se.isNotRelative=s=>e.test(s)||qr(s)};typeof process<"u"&&process.platform==="win32"&&Xr();Ns.exports=zi;zi.default=zi;Ns.exports.isPathValid=dl;We(Ns.exports,Symbol.for("setupWindows"),Xr)});import{getToolName as Gh}from"ai";import{render as Hh}from"ink";import{v4 as qh}from"uuid";import{exec as Au}from"child_process";import _u from"os";import fl from"fs/promises";var Zr=qa(Vr(),1);import ss from"fs/promises";import Yr from"os";import Ft from"path";function Dt(t){let e=t.startsWith("~/")||t.startsWith("~\\")?Ft.join(Yr.homedir(),t.slice(2)):t==="~"?Yr.homedir():t;return Ft.resolve(e)}function Kr(t){return t.normalize("NFC").replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/gu," ")}async function Nt(t){let e=Dt(t);try{return await ss.access(e),e}catch(s){if((s&&typeof s=="object"&&"code"in s?String(s.code):void 0)!=="ENOENT")throw s;let r=Ft.dirname(e),n=Ft.basename(e),o;try{o=await ss.readdir(r)}catch{throw s}let a=Kr(n),l=o.filter(p=>Kr(p)===a),[c]=l;if(l.length===1&&c)return Ft.join(r,c);if(l.length>1){let p=new Error(`Multiple files match "${n}" after whitespace normalization: ${l.join(", ")}. Use filesystem__list_directory and pass an exact name.`);throw p.code="EAMBIG",p}throw s}}var Gi=100*1024,Qr=50*1024,is=10*1024*1024,tn=10,Hi=100,en=10,ze=10*1024*1024,rs=3e4,sn=3e5;function ie(t,e=Gi){return t.length>e?t.slice(0,e)+`
|
|
3
|
+
... [truncated, ${t.length-e} more characters]`:t}var Jr={".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"},pl=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 Bs(t){let e=Ft.extname(t).toLowerCase();if(Jr[e])return{type:"binary",mimeType:Jr[e]};if(pl.has(e))return{type:"text"};try{let s=await ss.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 js(t){let e=(0,Zr.default)();e.add([".git","node_modules",".DS_Store"]);let s=t,i=[];for(;s!==Ft.dirname(s);){let r=Ft.join(s,".gitignore");try{await ss.access(r),i.unshift(r)}catch{}s=Ft.dirname(s)}for(let r of i)try{let n=await ss.readFile(r,"utf-8");e.add(n)}catch{}return e}function Us(t,e,s){return t.filter(i=>{let r=Ft.relative(e,i);return!s.ignores(r.split(Ft.sep).join("/"))})}function rn(t,e,s){let i=e.split(`
|
|
4
|
+
`),r=s.split(`
|
|
5
|
+
`),n=[`--- a/${Ft.basename(t)}`,`+++ b/${Ft.basename(t)}`],o=0,a=0;for(;o<i.length||a<r.length;){if(o<i.length&&a<r.length&&i[o]===r[a]){o++,a++;continue}let l=o,c=a,p=!1;for(let u=1;u<10&&!p;u++)for(let d=l;d<=l+u;d++){for(let g=c;g<=c+u;g++)if(d<i.length&&g<r.length&&i[d]===r[g]){let f=Math.max(0,l-3),y=Math.min(i.length,d+3),b=Math.max(0,c-3),v=Math.min(r.length,g+3);n.push(`@@ -${f+1},${y-f} +${b+1},${v-b} @@`);for(let S=f;S<l;S++)n.push(` ${i[S]}`);for(let S=l;S<d;S++)n.push(`-${i[S]}`);for(let S=c;S<g;S++)n.push(`+${r[S]}`);for(let S=d;S<Math.min(d+3,i.length);S++)S<y&&n.push(` ${i[S]}`);o=d,a=g,p=!0;break}if(p)break}if(!p){for(n.push(`@@ -${l+1},${i.length-l} +${c+1},${r.length-c} @@`);o<i.length;)n.push(`-${i[o]}`),o++;for(;a<r.length;)n.push(`+${r[a]}`),a++}}return n.join(`
|
|
6
|
+
`)}var nn=async t=>{try{return await fl.mkdir(Dt(t.path),{recursive:!0}),{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to create directory"}}};import on from"fs/promises";var an=async t=>{try{let e=await Nt(t.path),s=await on.readFile(e,"utf-8"),i=s,r=[];for(let[o,a]of t.edits.entries()){let l=i.split(a.old_text).length-1;l===0?r.push({index:o,old_text:a.old_text.length>100?a.old_text.slice(0,100)+"...":a.old_text,reason:"Text not found in file. Ensure the old_text matches exactly, including whitespace and indentation."}):l>1&&r.push({index:o,old_text:a.old_text.length>100?a.old_text.slice(0,100)+"...":a.old_text,reason:`Found ${l} 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=rn(e,s,i);return t.dry_run?{success:!0,applied:0,dry_run:!0,diff:n}:(await on.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 gl}from"child_process";import{existsSync as ml}from"fs";import wl from"os";import{promisify as yl}from"util";var bl=yl(gl),ln=async t=>{try{let e=Dt(t.cwd||wl.homedir());if(!ml(e))return{success:!1,error:`Working directory does not exist: ${e}`};let s=Math.min(t.timeout??rs,sn),{stdout:i,stderr:r}=await bl(t.command,{cwd:e,timeout:s,maxBuffer:is,shell:process.platform==="win32"?"cmd.exe":"/bin/bash"});return{success:!0,stdout:ie(i),stderr:ie(r)}}catch(e){let s=e;return{success:!1,exitCode:s.code,killed:s.killed,signal:s.signal,stdout:ie(s.stdout||""),stderr:ie(s.stderr||""),error:s.message||"Command execution failed"}}};import Sl from"fs/promises";var cn=async t=>{try{let e=await Sl.stat(await Nt(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 wu}from"child_process";import yu from"fs/promises";import bo from"path";import{promisify as bu}from"util";import{fileURLToPath as kc}from"url";import{posix as Rc,win32 as er}from"path";import{fileURLToPath as Ac}from"url";import{lstatSync as _c,readdir as Pc,readdirSync as $c,readlinkSync as Ic,realpathSync as Mc}from"fs";import*as Fc from"fs";import{lstat as Dc,readdir as Oc,readlink as Lc,realpath as Nc}from"fs/promises";import{EventEmitter as rr}from"events";import Vn from"stream";import{StringDecoder as Bc}from"string_decoder";var In=(t,e,s)=>{let i=t instanceof RegExp?un(t,s):t,r=e instanceof RegExp?un(e,s):e,n=i!==null&&r!=null&&vl(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)}},un=(t,e)=>{let s=e.match(t);return s?s[0]:null},vl=(t,e,s)=>{let i,r,n,o,a,l=s.indexOf(t),c=s.indexOf(e,l+1),p=l;if(l>=0&&c>0){if(t===e)return[l,c];for(i=[],n=s.length;p>=0&&!a;){if(p===l)i.push(p),l=s.indexOf(t,p+1);else if(i.length===1){let u=i.pop();u!==void 0&&(a=[u,c])}else r=i.pop(),r!==void 0&&r<n&&(n=r,o=c),c=s.indexOf(e,p+1);p=l<c&&l>=0?l:c}i.length&&o!==void 0&&(a=[n,o])}return a},Mn="\0SLASH"+Math.random()+"\0",Fn="\0OPEN"+Math.random()+"\0",sr="\0CLOSE"+Math.random()+"\0",Dn="\0COMMA"+Math.random()+"\0",On="\0PERIOD"+Math.random()+"\0",xl=new RegExp(Mn,"g"),kl=new RegExp(Fn,"g"),Tl=new RegExp(sr,"g"),Cl=new RegExp(Dn,"g"),El=new RegExp(On,"g"),Rl=/\\\\/g,Al=/\\{/g,_l=/\\}/g,Pl=/\\,/g,$l=/\\./g,Il=1e5;function qi(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function Ml(t){return t.replace(Rl,Mn).replace(Al,Fn).replace(_l,sr).replace(Pl,Dn).replace($l,On)}function Fl(t){return t.replace(xl,"\\").replace(kl,"{").replace(Tl,"}").replace(Cl,",").replace(El,".")}function Ln(t){if(!t)return[""];let e=[],s=In("{","}",t);if(!s)return t.split(",");let{pre:i,body:r,post:n}=s,o=i.split(",");o[o.length-1]+="{"+r+"}";let a=Ln(n);return n.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),e.push.apply(e,o),e}function Dl(t,e={}){if(!t)return[];let{max:s=Il}=e;return t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),hs(Ml(t),s,!0).map(Fl)}function Ol(t){return"{"+t+"}"}function Ll(t){return/^-?0\d/.test(t)}function Nl(t,e){return t<=e}function Bl(t,e){return t>=e}function hs(t,e,s){let i=[],r=In("{","}",t);if(!r)return[t];let n=r.pre,o=r.post.length?hs(r.post,e,!1):[""];if(/\$$/.test(r.pre))for(let a=0;a<o.length&&a<e;a++){let l=n+"{"+r.body+"}"+o[a];i.push(l)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),c=a||l,p=r.body.indexOf(",")>=0;if(!c&&!p)return r.post.match(/,(?!,).*\}/)?(t=r.pre+"{"+r.body+sr+r.post,hs(t,e,!0)):[t];let u;if(c)u=r.body.split(/\.\./);else if(u=Ln(r.body),u.length===1&&u[0]!==void 0&&(u=hs(u[0],e,!1).map(Ol),u.length===1))return o.map(g=>r.pre+u[0]+g);let d;if(c&&u[0]!==void 0&&u[1]!==void 0){let g=qi(u[0]),f=qi(u[1]),y=Math.max(u[0].length,u[1].length),b=u.length===3&&u[2]!==void 0?Math.abs(qi(u[2])):1,v=Nl;f<g&&(b*=-1,v=Bl);let S=u.some(Ll);d=[];for(let k=g;v(k,f);k+=b){let E;if(l)E=String.fromCharCode(k),E==="\\"&&(E="");else if(E=String(k),S){let P=y-E.length;if(P>0){let H=new Array(P+1).join("0");k<0?E="-"+H+E.slice(1):E=H+E}}d.push(E)}}else{d=[];for(let g=0;g<u.length;g++)d.push.apply(d,hs(u[g],e,!1))}for(let g=0;g<d.length;g++)for(let f=0;f<o.length&&i.length<e;f++){let y=n+d[g]+o[f];(!s||c||y)&&i.push(y)}}return i}var Zs=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")},jl={"[: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]},ns=t=>t.replace(/[[\]\\-]/g,"\\$&"),Ul=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),hn=t=>t.join(""),Wl=(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,a=!1,l=!1,c=!1,p=s,u="";t:for(;n<t.length;){let f=t.charAt(n);if((f==="!"||f==="^")&&n===s+1){c=!0,n++;continue}if(f==="]"&&o&&!l){p=n+1;break}if(o=!0,f==="\\"&&!l){l=!0,n++;continue}if(f==="["&&!l){for(let[y,[b,v,S]]of Object.entries(jl))if(t.startsWith(y,n)){if(u)return["$.",!1,t.length-s,!0];n+=y.length,S?r.push(b):i.push(b),a=a||v;continue t}}if(l=!1,u){f>u?i.push(ns(u)+"-"+ns(f)):f===u&&i.push(ns(f)),u="",n++;continue}if(t.startsWith("-]",n+1)){i.push(ns(f+"-")),n+=2;continue}if(t.startsWith("-",n+1)){u=f,n+=2;continue}i.push(ns(f)),n++}if(p<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 f=i[0].length===2?i[0].slice(-1):i[0];return[Ul(f),!1,p-s,!1]}let d="["+(c?"^":"")+hn(i)+"]",g="["+(c?"":"^")+hn(r)+"]";return[i.length&&r.length?"("+d+"|"+g+")":i.length?d:g,a,p-s,!0]},qe=(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"),zl=new Set(["!","?","+","*","@"]),dn=t=>zl.has(t),Gl="(?!(?:^|/)\\.\\.?(?:$|/))",Ws="(?!\\.)",Hl=new Set(["[","."]),ql=new Set(["..","."]),Xl=new Set("().*{}+?[]^$\\!"),Vl=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ir="[^/]",pn=ir+"*?",fn=ir+"+?",Nn=class Lt{type;#t;#s;#n=!1;#r=[];#o;#S;#w;#u=!1;#a;#d;#h=!1;constructor(e,s,i={}){this.type=e,e&&(this.#s=!0),this.#o=s,this.#t=this.#o?this.#o.#t:this,this.#a=this.#t===this?i:this.#t.#a,this.#w=this.#t===this?[]:this.#t.#w,e==="!"&&!this.#t.#u&&this.#w.push(this),this.#S=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("")}#l(){if(this!==this.#t)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let e;for(;e=this.#w.pop();){if(e.type!=="!")continue;let s=e,i=s.#o;for(;i;){for(let r=s.#S+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 Lt&&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.#u&&this.#o?.type==="!")&&e.push({}),e}isStart(){if(this.#t===this)return!0;if(!this.#o?.isStart())return!1;if(this.#S===0)return!0;let e=this.#o;for(let s=0;s<this.#S;s++){let i=e.#r[s];if(!(i instanceof Lt&&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.#S===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let s=new Lt(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,a=-1,l=!1;if(s.type===null){let g=i,f="";for(;g<e.length;){let y=e.charAt(g++);if(n||y==="\\"){n=!n,f+=y;continue}if(o){g===a+1?(y==="^"||y==="!")&&(l=!0):y==="]"&&!(g===a+2&&l)&&(o=!1),f+=y;continue}else if(y==="["){o=!0,a=g,l=!1,f+=y;continue}if(!r.noext&&dn(y)&&e.charAt(g)==="("){s.push(f),f="";let b=new Lt(y,s);g=Lt.#i(e,b,g,r),s.push(b);continue}f+=y}return s.push(f),g}let c=i+1,p=new Lt(null,s),u=[],d="";for(;c<e.length;){let g=e.charAt(c++);if(n||g==="\\"){n=!n,d+=g;continue}if(o){c===a+1?(g==="^"||g==="!")&&(l=!0):g==="]"&&!(c===a+2&&l)&&(o=!1),d+=g;continue}else if(g==="["){o=!0,a=c,l=!1,d+=g;continue}if(dn(g)&&e.charAt(c)==="("){p.push(d),d="";let f=new Lt(g,p);p.push(f),c=Lt.#i(e,f,c,r);continue}if(g==="|"){p.push(d),d="",u.push(p),p=new Lt(null,s);continue}if(g===")")return d===""&&s.#r.length===0&&(s.#h=!0),p.push(d),d="",s.push(...u,p),c;d+=g}return s.type=null,s.#s=void 0,s.#r=[e.substring(i-1)],c}static fromGlob(e,s={}){let i=new Lt(null,void 0,s);return Lt.#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.#a.nocase&&!this.#a.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return i;let o=(this.#a.nocase?"i":"")+(n?"u":"");return Object.assign(new RegExp(`^${s}$`,o),{_src:s,_glob:e})}get options(){return this.#a}toRegExpSource(e){let s=e??!!this.#a.dot;if(this.#t===this&&this.#l(),!this.type){let l=this.isStart()&&this.isEnd()&&!this.#r.some(d=>typeof d!="string"),c=this.#r.map(d=>{let[g,f,y,b]=typeof d=="string"?Lt.#v(d,this.#s,l):d.toRegExpSource(e);return this.#s=this.#s||y,this.#n=this.#n||b,g}).join(""),p="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&ql.has(this.#r[0]))){let d=Hl,g=s&&d.has(c.charAt(0))||c.startsWith("\\.")&&d.has(c.charAt(2))||c.startsWith("\\.\\.")&&d.has(c.charAt(4)),f=!s&&!e&&d.has(c.charAt(0));p=g?Gl:f?Ws:""}let u="";return this.isEnd()&&this.#t.#u&&this.#o?.type==="!"&&(u="(?:$|\\/)"),[p+c+u,qe(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 l=this.toString();return this.#r=[l],this.type=null,this.#s=void 0,[l,qe(this.toString()),!1,!1]}let o=!i||e||s||!Ws?"":this.#p(!0);o===n&&(o=""),o&&(n=`(?:${n})(?:${o})*?`);let a="";if(this.type==="!"&&this.#h)a=(this.isStart()&&!s?Ws:"")+fn;else{let l=this.type==="!"?"))"+(this.isStart()&&!s&&!e?Ws:"")+pn+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=r+n+l}return[a,qe(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,a=!1;for(let l=0;l<e.length;l++){let c=e.charAt(l);if(r){r=!1,n+=(Xl.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,n+=i&&/^[*]+$/.test(e)?fn:pn,s=!0;continue}else a=!1;if(c==="\\"){l===e.length-1?n+="\\\\":r=!0;continue}if(c==="["){let[p,u,d,g]=Wl(e,l);if(d){n+=p,o=o||u,l+=d-1,s=s||g;continue}}if(c==="?"){n+=ir,s=!0;continue}n+=Vl(c)}return[n,qe(e),!!s,o]}},Bn=(t,{windowsPathsNoEscape:e=!1,magicalBraces:s=!1}={})=>s?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&"),Rt=(t,e,s={})=>(Zs(e),!s.nocomment&&e.charAt(0)==="#"?!1:new fe(e,s).match(t)),Yl=/^\*+([^+@!?\*\[\(]*)$/,Kl=t=>e=>!e.startsWith(".")&&e.endsWith(t),Jl=t=>e=>e.endsWith(t),Zl=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),Ql=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),tc=/^\*+\.\*+$/,ec=t=>!t.startsWith(".")&&t.includes("."),sc=t=>t!=="."&&t!==".."&&t.includes("."),ic=/^\.\*+$/,rc=t=>t!=="."&&t!==".."&&t.startsWith("."),nc=/^\*+$/,oc=t=>t.length!==0&&!t.startsWith("."),ac=t=>t.length!==0&&t!=="."&&t!=="..",lc=/^\?+([^+@!?\*\[\(]*)?$/,cc=([t,e=""])=>{let s=jn([t]);return e?(e=e.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(e)):s},uc=([t,e=""])=>{let s=Un([t]);return e?(e=e.toLowerCase(),i=>s(i)&&i.toLowerCase().endsWith(e)):s},hc=([t,e=""])=>{let s=Un([t]);return e?i=>s(i)&&i.endsWith(e):s},dc=([t,e=""])=>{let s=jn([t]);return e?i=>s(i)&&i.endsWith(e):s},jn=([t])=>{let e=t.length;return s=>s.length===e&&!s.startsWith(".")},Un=([t])=>{let e=t.length;return s=>s.length===e&&s!=="."&&s!==".."},Wn=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",gn={win32:{sep:"\\"},posix:{sep:"/"}},pc=Wn==="win32"?gn.win32.sep:gn.posix.sep;Rt.sep=pc;var Et=Symbol("globstar **");Rt.GLOBSTAR=Et;var fc="[^/]",gc=fc+"*?",mc="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",wc="(?:(?!(?:\\/|^)\\.).)*?",yc=(t,e={})=>s=>Rt(s,t,e);Rt.filter=yc;var Bt=(t,e={})=>Object.assign({},t,e),bc=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return Rt;let e=Rt;return Object.assign((s,i,r={})=>e(s,i,Bt(t,r)),{Minimatch:class extends e.Minimatch{constructor(s,i={}){super(s,Bt(t,i))}static defaults(s){return e.defaults(Bt(t,s)).Minimatch}},AST:class extends e.AST{constructor(s,i,r={}){super(s,i,Bt(t,r))}static fromGlob(s,i={}){return e.AST.fromGlob(s,Bt(t,i))}},unescape:(s,i={})=>e.unescape(s,Bt(t,i)),escape:(s,i={})=>e.escape(s,Bt(t,i)),filter:(s,i={})=>e.filter(s,Bt(t,i)),defaults:s=>e.defaults(Bt(t,s)),makeRe:(s,i={})=>e.makeRe(s,Bt(t,i)),braceExpand:(s,i={})=>e.braceExpand(s,Bt(t,i)),match:(s,i,r={})=>e.match(s,i,Bt(t,r)),sep:e.sep,GLOBSTAR:Et})};Rt.defaults=bc;var zn=(t,e={})=>(Zs(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:Dl(t,{max:e.braceExpandMax}));Rt.braceExpand=zn;var Sc=(t,e={})=>new fe(t,e).makeRe();Rt.makeRe=Sc;var vc=(t,e,s={})=>{let i=new fe(e,s);return t=t.filter(r=>i.match(r)),i.options.nonull&&!t.length&&t.push(e),t};Rt.match=vc;var mn=/[?*]|[+@!]\(.*?\)|\[|\]/,xc=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),fe=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){Zs(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||Wn,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 a=r[0]===""&&r[1]===""&&(r[2]==="?"||!mn.test(r[2]))&&!mn.test(r[3]),l=/^[a-z]:/i.test(r[0]);if(a)return[...r.slice(0,4),...r.slice(4).map(c=>this.parse(c))];if(l)return[r[0],...r.slice(1).map(c=>this.parse(c))]}return r.map(a=>this.parse(a))});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],a=s[i+2],l=s[i+3];if(o!==".."||!a||a==="."||a===".."||!l||l==="."||l==="..")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 f=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),y=!f&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),b=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),v=!b&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),S=y?3:f?0:void 0,k=v?3:b?0:void 0;if(typeof S=="number"&&typeof k=="number"){let[E,P]=[t[S],e[k]];E.toLowerCase()===P.toLowerCase()&&(e[k]=E,k>S?e=e.slice(k):S>k&&(t=t.slice(S)))}}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,a=t.length,l=e.length;n<a&&o<l;n++,o++){this.debug("matchOne loop");var c=e[o],p=t[n];if(this.debug(e,c,p),c===!1)return!1;if(c===Et){this.debug("GLOBSTAR",[e,c,p]);var u=n,d=o+1;if(d===l){for(this.debug("** at the end");n<a;n++)if(t[n]==="."||t[n]===".."||!i.dot&&t[n].charAt(0)===".")return!1;return!0}for(;u<a;){var g=t[u];if(this.debug(`
|
|
7
|
+
globstar while`,t,u,e,d,g),this.matchOne(t.slice(u),e.slice(d),s))return this.debug("globstar found match!",u,a,g),!0;if(g==="."||g===".."||!i.dot&&g.charAt(0)==="."){this.debug("dot detected!",t,u,e,d);break}this.debug("globstar swallow a segment, and continue"),u++}return!!(s&&(this.debug(`
|
|
8
|
+
>>> no match, partial?`,t,u,e,d),u===a))}let f;if(typeof c=="string"?(f=p===c,this.debug("string match",c,p,f)):(f=c.test(p),this.debug("pattern match",c,p,f)),!f)return!1}if(n===a&&o===l)return!0;if(n===a)return s;if(o===l)return n===a-1&&t[n]==="";throw new Error("wtf?")}braceExpand(){return zn(this.pattern,this.options)}parse(t){Zs(t);let e=this.options;if(t==="**")return Et;if(t==="")return"";let s,i=null;(s=t.match(nc))?i=e.dot?ac:oc:(s=t.match(Yl))?i=(e.nocase?e.dot?Ql:Zl:e.dot?Jl:Kl)(s[1]):(s=t.match(lc))?i=(e.nocase?e.dot?uc:cc:e.dot?hc:dc)(s):(s=t.match(tc))?i=e.dot?sc:ec:(s=t.match(ic))&&(i=rc);let r=Nn.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?gc:e.dot?mc:wc,i=new Set(e.nocase?["i"]:[]),r=t.map(a=>{let l=a.map(p=>{if(p instanceof RegExp)for(let u of p.flags.split(""))i.add(u);return typeof p=="string"?xc(p):p===Et?Et:p._src});l.forEach((p,u)=>{let d=l[u+1],g=l[u-1];p!==Et||g===Et||(g===void 0?d!==void 0&&d!==Et?l[u+1]="(?:\\/|"+s+"\\/)?"+d:l[u]=s:d===void 0?l[u-1]=g+"(?:\\/|\\/"+s+")?":d!==Et&&(l[u-1]=g+"(?:\\/|\\/"+s+"\\/)"+d,l[u+1]=Et))});let c=l.filter(p=>p!==Et);if(this.partial&&c.length>=1){let p=[];for(let u=1;u<=c.length;u++)p.push(c.slice(0,u).join("/"));return"(?:"+p.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 a=r[o],l=i;if(s.matchBase&&a.length===1&&(l=[n]),this.matchOne(l,a,e))return s.flipNegate?!0:!this.negate}return s.flipNegate?!1:this.negate}static defaults(t){return Rt.defaults(t).Minimatch}};Rt.AST=Nn;Rt.Minimatch=fe;Rt.escape=Bn;Rt.unescape=qe;var Tc=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Gn=new Set,tr=typeof process=="object"&&process?process:{},Hn=(t,e,s,i)=>{typeof tr.emitWarning=="function"?tr.emitWarning(t,e,s,i):console.error(`[${s}] ${e}: ${t}`)},Qs=globalThis.AbortController,wn=globalThis.AbortSignal;if(typeof Qs>"u"){wn=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(s,i){this._onabort.push(i)}},Qs=class{constructor(){e()}signal=new wn;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=tr.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,Hn("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 Cc=t=>!Gn.has(t),pe=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),qn=t=>pe(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Ks:null:null,Ks=class extends Array{constructor(t){super(t),this.fill(0)}},Ec=class ds{heap;length;static#t=!1;static create(e){let s=qn(e);if(!s)return[];ds.#t=!0;let i=new ds(e,s);return ds.#t=!1,i}constructor(e,s){if(!ds.#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]}},ei=class Xn{#t;#s;#n;#r;#o;#S;#w;#u;get perf(){return this.#u}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#d;#h;#l;#i;#p;#v;#b;#f;#A;#g;#T;#C;#m;#y;#x;#E;#e;#F;static unsafeExposeInternals(e){return{starts:e.#C,ttls:e.#m,autopurgeTimers:e.#y,sizes:e.#T,keyMap:e.#h,keyList:e.#l,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.#W(s,i,r,n),moveToTail:s=>e.#O(s),indexes:s=>e.#P(s),rindexes:s=>e.#$(s),isStale:s=>e.#k(s)}}get max(){return this.#t}get maxSize(){return this.#s}get calculatedSize(){return this.#d}get size(){return this.#a}get fetchMethod(){return this.#S}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:a,allowStale:l,dispose:c,onInsert:p,disposeAfter:u,noDisposeOnSet:d,noUpdateTTL:g,maxSize:f=0,maxEntrySize:y=0,sizeCalculation:b,fetchMethod:v,memoMethod:S,noDeleteOnFetchRejection:k,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:P,allowStaleOnFetchAbort:H,ignoreFetchAbort:$,perf:A}=e;if(A!==void 0&&typeof A?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#u=A??Tc,s!==0&&!pe(s))throw new TypeError("max option must be a nonnegative integer");let m=s?qn(s):Array;if(!m)throw new Error("invalid max value: "+s);if(this.#t=s,this.#s=f,this.maxEntrySize=y||this.#s,this.sizeCalculation=b,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(S!==void 0&&typeof S!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#w=S,v!==void 0&&typeof v!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#S=v,this.#E=!!v,this.#h=new Map,this.#l=new Array(s).fill(void 0),this.#i=new Array(s).fill(void 0),this.#p=new m(s),this.#v=new m(s),this.#b=0,this.#f=0,this.#A=Ec.create(s),this.#a=0,this.#d=0,typeof c=="function"&&(this.#n=c),typeof p=="function"&&(this.#r=p),typeof u=="function"?(this.#o=u,this.#g=[]):(this.#o=void 0,this.#g=void 0),this.#x=!!this.#n,this.#F=!!this.#r,this.#e=!!this.#o,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!g,this.noDeleteOnFetchRejection=!!k,this.allowStaleOnFetchRejection=!!P,this.allowStaleOnFetchAbort=!!H,this.ignoreFetchAbort=!!$,this.maxEntrySize!==0){if(this.#s!==0&&!pe(this.#s))throw new TypeError("maxSize must be a positive integer if specified");if(!pe(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#G()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!a,this.ttlResolution=pe(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!pe(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#I()}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 N="LRU_CACHE_UNBOUNDED";Cc(N)&&(Gn.add(N),Hn("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",N,Xn))}}getRemainingTTL(e){return this.#h.has(e)?1/0:0}#I(){let e=new Ks(this.#t),s=new Ks(this.#t);this.#m=e,this.#C=s;let i=this.ttlAutopurge?new Array(this.#t):void 0;this.#y=i,this.#N=(o,a,l=this.#u.now())=>{if(s[o]=a!==0?l:0,e[o]=a,i?.[o]&&(clearTimeout(i[o]),i[o]=void 0),a!==0&&i){let c=setTimeout(()=>{this.#k(o)&&this.#_(this.#l[o],"expire")},a+1);c.unref&&c.unref(),i[o]=c}},this.#R=o=>{s[o]=e[o]!==0?this.#u.now():0},this.#M=(o,a)=>{if(e[a]){let l=e[a],c=s[a];if(!l||!c)return;o.ttl=l,o.start=c,o.now=r||n();let p=o.now-c;o.remainingTTL=l-p}};let r=0,n=()=>{let o=this.#u.now();if(this.ttlResolution>0){r=o;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref()}return o};this.getRemainingTTL=o=>{let a=this.#h.get(o);if(a===void 0)return 0;let l=e[a],c=s[a];if(!l||!c)return 1/0;let p=(r||n())-c;return l-p},this.#k=o=>{let a=s[o],l=e[o];return!!l&&!!a&&(r||n())-a>l}}#R=()=>{};#M=()=>{};#N=()=>{};#k=()=>!1;#G(){let e=new Ks(this.#t);this.#d=0,this.#T=e,this.#L=s=>{this.#d-=e[s],e[s]=0},this.#B=(s,i,r,n)=>{if(this.#c(i))return 0;if(!pe(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(i,s),!pe(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.#U(!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.#a)for(let s=this.#f;!(!this.#j(s)||((e||!this.#k(s))&&(yield s),s===this.#b));)s=this.#v[s]}*#$({allowStale:e=this.allowStale}={}){if(this.#a)for(let s=this.#b;!(!this.#j(s)||((e||!this.#k(s))&&(yield s),s===this.#f));)s=this.#p[s]}#j(e){return e!==void 0&&this.#h.get(this.#l[e])===e}*entries(){for(let e of this.#P())this.#i[e]!==void 0&&this.#l[e]!==void 0&&!this.#c(this.#i[e])&&(yield[this.#l[e],this.#i[e]])}*rentries(){for(let e of this.#$())this.#i[e]!==void 0&&this.#l[e]!==void 0&&!this.#c(this.#i[e])&&(yield[this.#l[e],this.#i[e]])}*keys(){for(let e of this.#P()){let s=this.#l[e];s!==void 0&&!this.#c(this.#i[e])&&(yield s)}}*rkeys(){for(let e of this.#$()){let s=this.#l[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.#$())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.#l[i],this))return this.get(this.#l[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.#l[i],this)}}rforEach(e,s=this){for(let i of this.#$()){let r=this.#i[i],n=this.#c(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(s,n,this.#l[i],this)}}purgeStale(){let e=!1;for(let s of this.#$({allowStale:!0}))this.#k(s)&&(this.#_(this.#l[s],"expire"),e=!0);return e}info(e){let s=this.#h.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.#C){let o=this.#m[s],a=this.#C[s];if(o&&a){let l=o-(this.#u.now()-a);n.ttl=l,n.start=Date.now()}}return this.#T&&(n.size=this.#T[s]),n}dump(){let e=[];for(let s of this.#P({allowStale:!0})){let i=this.#l[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.#C){o.ttl=this.#m[s];let a=this.#u.now()-this.#C[s];o.start=Math.floor(Date.now()-a)}this.#T&&(o.size=this.#T[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.#u.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:a=this.sizeCalculation,status:l}=i,{noUpdateTTL:c=this.noUpdateTTL}=i,p=this.#B(e,s,i.size||0,a);if(this.maxEntrySize&&p>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#_(e,"set"),this;let u=this.#a===0?void 0:this.#h.get(e);if(u===void 0)u=this.#a===0?this.#f:this.#A.length!==0?this.#A.pop():this.#a===this.#t?this.#U(!1):this.#a,this.#l[u]=e,this.#i[u]=s,this.#h.set(e,u),this.#p[this.#f]=u,this.#v[u]=this.#f,this.#f=u,this.#a++,this.#D(u,p,l),l&&(l.set="add"),c=!1,this.#F&&this.#r?.(s,e,"add");else{this.#O(u);let d=this.#i[u];if(s!==d){if(this.#E&&this.#c(d)){d.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=d;g!==void 0&&!o&&(this.#x&&this.#n?.(g,e,"set"),this.#e&&this.#g?.push([g,e,"set"]))}else o||(this.#x&&this.#n?.(d,e,"set"),this.#e&&this.#g?.push([d,e,"set"]));if(this.#L(u),this.#D(u,p,l),this.#i[u]=s,l){l.set="replace";let g=d&&this.#c(d)?d.__staleWhileFetching:d;g!==void 0&&(l.oldValue=g)}}else l&&(l.set="update");this.#F&&this.onInsert?.(s,e,s===d?"update":"replace")}if(r!==0&&!this.#m&&this.#I(),this.#m&&(c||this.#N(u,r,n),l&&this.#M(l,u)),!o&&this.#e&&this.#g){let d=this.#g,g;for(;g=d?.shift();)this.#o?.(...g)}return this}pop(){try{for(;this.#a;){let e=this.#i[this.#b];if(this.#U(!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)}}}#U(e){let s=this.#b,i=this.#l[s],r=this.#i[s];return this.#E&&this.#c(r)?r.__abortController.abort(new Error("evicted")):(this.#x||this.#e)&&(this.#x&&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.#l[s]=void 0,this.#i[s]=void 0,this.#A.push(s)),this.#a===1?(this.#b=this.#f=0,this.#A.length=0):this.#b=this.#p[s],this.#h.delete(i),this.#a--,s}has(e,s={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:r}=s,n=this.#h.get(e);if(n!==void 0){let o=this.#i[n];if(this.#c(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#k(n))r&&(r.has="stale",this.#M(r,n));else return i&&this.#R(n),r&&(r.has="hit",this.#M(r,n)),!0}else r&&(r.has="miss");return!1}peek(e,s={}){let{allowStale:i=this.allowStale}=s,r=this.#h.get(e);if(r===void 0||!i&&this.#k(r))return;let n=this.#i[r];return this.#c(n)?n.__staleWhileFetching:n}#W(e,s,i,r){let n=s===void 0?void 0:this.#i[s];if(this.#c(n))return n;let o=new Qs,{signal:a}=i;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});let l={signal:o.signal,options:i,context:r},c=(y,b=!1)=>{let{aborted:v}=o.signal,S=i.ignoreFetchAbort&&y!==void 0,k=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&y!==void 0);if(i.status&&(v&&!b?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,S&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),v&&!S&&!b)return u(o.signal.reason,k);let E=g,P=this.#i[s];return(P===g||S&&b&&P===void 0)&&(y===void 0?E.__staleWhileFetching!==void 0?this.#i[s]=E.__staleWhileFetching:this.#_(e,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(e,y,l.options))),y},p=y=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=y),u(y,!1)),u=(y,b)=>{let{aborted:v}=o.signal,S=v&&i.allowStaleOnFetchAbort,k=S||i.allowStaleOnFetchRejection,E=k||i.noDeleteOnFetchRejection,P=g;if(this.#i[s]===g&&(!E||!b&&P.__staleWhileFetching===void 0?this.#_(e,"fetch"):S||(this.#i[s]=P.__staleWhileFetching)),k)return i.status&&P.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),P.__staleWhileFetching;if(P.__returned===P)throw y},d=(y,b)=>{let v=this.#S?.(e,n,l);v&&v instanceof Promise&&v.then(S=>y(S===void 0?void 0:S),b),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(y(void 0),i.allowStaleOnFetchAbort&&(y=S=>c(S,!0)))})};i.status&&(i.status.fetchDispatched=!0);let g=new Promise(d).then(c,p),f=Object.assign(g,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return s===void 0?(this.set(e,f,{...l.options,status:void 0}),s=this.#h.get(e)):this.#i[s]=f,f}#c(e){if(!this.#E)return!1;let s=e;return!!s&&s instanceof Promise&&s.hasOwnProperty("__staleWhileFetching")&&s.__abortController instanceof Qs}async fetch(e,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:p=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:g=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,context:y,forceRefresh:b=!1,status:v,signal:S}=s;if(!this.#E)return v&&(v.fetch="get"),this.get(e,{allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:v});let k={allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:a,size:l,sizeCalculation:c,noUpdateTTL:p,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:f,ignoreFetchAbort:g,status:v,signal:S},E=this.#h.get(e);if(E===void 0){v&&(v.fetch="miss");let P=this.#W(e,E,k,y);return P.__returned=P}else{let P=this.#i[E];if(this.#c(P)){let m=i&&P.__staleWhileFetching!==void 0;return v&&(v.fetch="inflight",m&&(v.returnedStale=!0)),m?P.__staleWhileFetching:P.__returned=P}let H=this.#k(E);if(!b&&!H)return v&&(v.fetch="hit"),this.#O(E),r&&this.#R(E),v&&this.#M(v,E),P;let $=this.#W(e,E,k,y),A=$.__staleWhileFetching!==void 0&&i;return v&&(v.fetch=H?"stale":"refresh",A&&H&&(v.returnedStale=!0)),A?$.__staleWhileFetching:$.__returned=$}}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,a=this.get(e,o);if(!n&&a!==void 0)return a;let l=i(e,a,{options:o,context:r});return this.set(e,l,o),l}get(e,s={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=s,a=this.#h.get(e);if(a!==void 0){let l=this.#i[a],c=this.#c(l);return o&&this.#M(o,a),this.#k(a)?(o&&(o.get="stale"),c?(o&&i&&l.__staleWhileFetching!==void 0&&(o.returnedStale=!0),i?l.__staleWhileFetching:void 0):(n||this.#_(e,"expire"),o&&i&&(o.returnedStale=!0),i?l:void 0)):(o&&(o.get="hit"),c?l.__staleWhileFetching:(this.#O(a),r&&this.#R(a),l))}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.#a!==0){let r=this.#h.get(e);if(r!==void 0)if(this.#y?.[r]&&(clearTimeout(this.#y?.[r]),this.#y[r]=void 0),i=!0,this.#a===1)this.#H(s);else{this.#L(r);let n=this.#i[r];if(this.#c(n)?n.__abortController.abort(new Error("deleted")):(this.#x||this.#e)&&(this.#x&&this.#n?.(n,e,s),this.#e&&this.#g?.push([n,e,s])),this.#h.delete(e),this.#l[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 a=this.#p[r];this.#v[a]=this.#v[r]}this.#a--,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.#$({allowStale:!0})){let i=this.#i[s];if(this.#c(i))i.__abortController.abort(new Error("deleted"));else{let r=this.#l[s];this.#x&&this.#n?.(i,r,e),this.#e&&this.#g?.push([i,r,e])}}if(this.#h.clear(),this.#i.fill(void 0),this.#l.fill(void 0),this.#m&&this.#C){this.#m.fill(0),this.#C.fill(0);for(let s of this.#y??[])s!==void 0&&clearTimeout(s);this.#y?.fill(void 0)}if(this.#T&&this.#T.fill(0),this.#b=0,this.#f=0,this.#A.length=0,this.#d=0,this.#a=0,this.#e&&this.#g){let s=this.#g,i;for(;i=s?.shift();)this.#o?.(...i)}}},yn=typeof process=="object"&&process?process:{stdout:null,stderr:null},jc=t=>!!t&&typeof t=="object"&&(t instanceof ti||t instanceof Vn||Uc(t)||Wc(t)),Uc=t=>!!t&&typeof t=="object"&&t instanceof rr&&typeof t.pipe=="function"&&t.pipe!==Vn.Writable.prototype.pipe,Wc=t=>!!t&&typeof t=="object"&&t instanceof rr&&typeof t.write=="function"&&typeof t.end=="function",re=Symbol("EOF"),ne=Symbol("maybeEmitEnd"),de=Symbol("emittedEnd"),zs=Symbol("emittingEnd"),os=Symbol("emittedError"),Gs=Symbol("closed"),bn=Symbol("read"),Hs=Symbol("flush"),Sn=Symbol("flushChunk"),zt=Symbol("encoding"),Ge=Symbol("decoder"),gt=Symbol("flowing"),as=Symbol("paused"),He=Symbol("resume"),mt=Symbol("buffer"),Ct=Symbol("pipes"),wt=Symbol("bufferLength"),Xi=Symbol("bufferPush"),qs=Symbol("bufferShift"),kt=Symbol("objectMode"),ct=Symbol("destroyed"),Vi=Symbol("error"),Yi=Symbol("emitData"),vn=Symbol("emitEnd"),Ki=Symbol("emitEnd2"),Xt=Symbol("async"),Ji=Symbol("abort"),Xs=Symbol("aborted"),ls=Symbol("signal"),Pe=Symbol("dataListeners"),Ot=Symbol("discarded"),cs=t=>Promise.resolve().then(t),zc=t=>t(),Gc=t=>t==="end"||t==="finish"||t==="prefinish",Hc=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,qc=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Yn=class{src;dest;opts;ondrain;constructor(t,e,s){this.src=t,this.dest=e,this.opts=s,this.ondrain=()=>t[He](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Xc=class extends Yn{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)}},Vc=t=>!!t.objectMode,Yc=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",ti=class extends rr{[gt]=!1;[as]=!1;[Ct]=[];[mt]=[];[kt];[zt];[Xt];[Ge];[re]=!1;[de]=!1;[zs]=!1;[Gs]=!1;[os]=null;[wt]=0;[ct]=!1;[ls];[Xs]=!1;[Pe]=0;[Ot]=!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");Vc(e)?(this[kt]=!0,this[zt]=null):Yc(e)?(this[zt]=e.encoding,this[kt]=!1):(this[kt]=!1,this[zt]=null),this[Xt]=!!e.async,this[Ge]=this[zt]?new Bc(this[zt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[mt]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ct]});let{signal:s}=e;s&&(this[ls]=s,s.aborted?this[Ji]():s.addEventListener("abort",()=>this[Ji]()))}get bufferLength(){return this[wt]}get encoding(){return this[zt]}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[kt]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Xt]}set async(t){this[Xt]=this[Xt]||!!t}[Ji](){this[Xs]=!0,this.emit("abort",this[ls]?.reason),this.destroy(this[ls]?.reason)}get aborted(){return this[Xs]}set aborted(t){}write(t,e,s){if(this[Xs])return!1;if(this[re])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[Xt]?cs:zc;if(!this[kt]&&!Buffer.isBuffer(t)){if(qc(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Hc(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[kt]?(this[gt]&&this[wt]!==0&&this[Hs](!0),this[gt]?this.emit("data",t):this[Xi](t),this[wt]!==0&&this.emit("readable"),s&&i(s),this[gt]):t.length?(typeof t=="string"&&!(e===this[zt]&&!this[Ge]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[zt]&&(t=this[Ge].write(t)),this[gt]&&this[wt]!==0&&this[Hs](!0),this[gt]?this.emit("data",t):this[Xi](t),this[wt]!==0&&this.emit("readable"),s&&i(s),this[gt]):(this[wt]!==0&&this.emit("readable"),s&&i(s),this[gt])}read(t){if(this[ct])return null;if(this[Ot]=!1,this[wt]===0||t===0||t&&t>this[wt])return this[ne](),null;this[kt]&&(t=null),this[mt].length>1&&!this[kt]&&(this[mt]=[this[zt]?this[mt].join(""):Buffer.concat(this[mt],this[wt])]);let e=this[bn](t||null,this[mt][0]);return this[ne](),e}[bn](t,e){if(this[kt])this[qs]();else{let s=e;t===s.length||t===null?this[qs]():typeof s=="string"?(this[mt][0]=s.slice(t),e=s.slice(0,t),this[wt]-=t):(this[mt][0]=s.subarray(t),e=s.subarray(0,t),this[wt]-=t)}return this.emit("data",e),!this[mt].length&&!this[re]&&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[re]=!0,this.writable=!1,(this[gt]||!this[as])&&this[ne](),this}[He](){this[ct]||(!this[Pe]&&!this[Ct].length&&(this[Ot]=!0),this[as]=!1,this[gt]=!0,this.emit("resume"),this[mt].length?this[Hs]():this[re]?this[ne]():this.emit("drain"))}resume(){return this[He]()}pause(){this[gt]=!1,this[as]=!0,this[Ot]=!1}get destroyed(){return this[ct]}get flowing(){return this[gt]}get paused(){return this[as]}[Xi](t){this[kt]?this[wt]+=1:this[wt]+=t.length,this[mt].push(t)}[qs](){return this[kt]?this[wt]-=1:this[wt]-=this[mt][0].length,this[mt].shift()}[Hs](t=!1){do;while(this[Sn](this[qs]())&&this[mt].length);!t&&!this[mt].length&&!this[re]&&this.emit("drain")}[Sn](t){return this.emit("data",t),this[gt]}pipe(t,e){if(this[ct])return t;this[Ot]=!1;let s=this[de];return e=e||{},t===yn.stdout||t===yn.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,s?e.end&&t.end():(this[Ct].push(e.proxyErrors?new Xc(this,t,e):new Yn(this,t,e)),this[Xt]?cs(()=>this[He]()):this[He]()),t}unpipe(t){let e=this[Ct].find(s=>s.dest===t);e&&(this[Ct].length===1?(this[gt]&&this[Pe]===0&&(this[gt]=!1),this[Ct]=[]):this[Ct].splice(this[Ct].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[Ot]=!1,this[Pe]++,!this[Ct].length&&!this[gt]&&this[He]();else if(t==="readable"&&this[wt]!==0)super.emit("readable");else if(Gc(t)&&this[de])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[os]){let i=e;this[Xt]?cs(()=>i.call(this,this[os])):i.call(this,this[os])}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[Ot]&&!this[Ct].length&&(this[gt]=!1)),s}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Pe]=0,!this[Ot]&&!this[Ct].length&&(this[gt]=!1)),e}get emittedEnd(){return this[de]}[ne](){!this[zs]&&!this[de]&&!this[ct]&&this[mt].length===0&&this[re]&&(this[zs]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Gs]&&this.emit("close"),this[zs]=!1)}emit(t,...e){let s=e[0];if(t!=="error"&&t!=="close"&&t!==ct&&this[ct])return!1;if(t==="data")return!this[kt]&&!s?!1:this[Xt]?(cs(()=>this[Yi](s)),!0):this[Yi](s);if(t==="end")return this[vn]();if(t==="close"){if(this[Gs]=!0,!this[de]&&!this[ct])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[os]=s,super.emit(Vi,s);let r=!this[ls]||this.listeners("error").length?super.emit("error",s):!1;return this[ne](),r}else if(t==="resume"){let r=super.emit("resume");return this[ne](),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[ne](),i}[Yi](t){for(let s of this[Ct])s.dest.write(t)===!1&&this.pause();let e=this[Ot]?!1:super.emit("data",t);return this[ne](),e}[vn](){return this[de]?!1:(this[de]=!0,this.readable=!1,this[Xt]?(cs(()=>this[Ki]()),!0):this[Ki]())}[Ki](){if(this[Ge]){let e=this[Ge].end();if(e){for(let s of this[Ct])s.dest.write(e);this[Ot]||super.emit("data",e)}}for(let e of this[Ct])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[kt]||(t.dataLength=0);let e=this.promise();return this.on("data",s=>{t.push(s),this[kt]||(t.dataLength+=s.length)}),await e,t}async concat(){if(this[kt])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[zt]?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[Ot]=!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[re])return e();let i,r,n=c=>{this.off("data",o),this.off("end",a),this.off(ct,l),e(),r(c)},o=c=>{this.off("error",n),this.off("end",a),this.off(ct,l),this.pause(),i({value:c,done:!!this[re]})},a=()=>{this.off("error",n),this.off("data",o),this.off(ct,l),e(),i({done:!0,value:void 0})},l=()=>n(new Error("stream destroyed"));return new Promise((c,p)=>{r=p,i=c,this.once(ct,l),this.once("error",n),this.once("end",a),this.once("data",o)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Ot]=!1;let t=!1,e=()=>(this.pause(),this.off(Vi,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(Vi,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[Ot]=!0,this[mt].length=0,this[wt]=0;let e=this;return typeof e.close=="function"&&!this[Gs]&&e.close(),t?this.emit("error",t):this.emit(ct),this}static get isStream(){return jc}},Kc=Mc.native,ps={lstatSync:_c,readdir:Pc,readdirSync:$c,readlinkSync:Ic,realpathSync:Kc,promises:{lstat:Dc,readdir:Oc,readlink:Lc,realpath:Nc}},Kn=t=>!t||t===ps||t===Fc?ps:{...ps,...t,promises:{...ps.promises,...t.promises||{}}},Jn=/^\\\\\?\\([a-z]:)\\?$/i,Jc=t=>t.replace(/\//g,"\\").replace(Jn,"$1\\"),Zc=/[\\\/]/,Ut=0,Zn=1,Qn=2,Vt=4,to=6,eo=8,$e=10,so=12,jt=15,us=~jt,Zi=16,xn=32,fs=64,Gt=128,Vs=256,Js=512,kn=fs|Gt|Js,Qc=1023,Qi=t=>t.isFile()?eo:t.isDirectory()?Vt:t.isSymbolicLink()?$e:t.isCharacterDevice()?Qn:t.isBlockDevice()?to:t.isSocket()?so:t.isFIFO()?Zn:Ut,Tn=new ei({max:2**12}),gs=t=>{let e=Tn.get(t);if(e)return e;let s=t.normalize("NFKD");return Tn.set(t,s),s},Cn=new ei({max:2**12}),Ys=t=>{let e=Cn.get(t);if(e)return e;let s=gs(t.toLowerCase());return Cn.set(t,s),s},En=class extends ei{constructor(){super({max:256})}},tu=class extends ei{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},io=Symbol("PathScurry setAsCwd"),$t=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}#S;get gid(){return this.#S}#w;get rdev(){return this.#w}#u;get blksize(){return this.#u}#a;get ino(){return this.#a}#d;get size(){return this.#d}#h;get blocks(){return this.#h}#l;get atimeMs(){return this.#l}#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}#T;#C;#m;#y;#x;#E;#e;#F;#I;#R;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,e=Ut,s,i,r,n,o){this.name=t,this.#T=r?Ys(t):gs(t),this.#e=e&Qc,this.nocase=r,this.roots=i,this.root=s||this,this.#F=n,this.#m=o.fullpath,this.#x=o.relative,this.#E=o.relativePosix,this.parent=o.parent,this.parent?this.#t=this.parent.#t:this.#t=Kn(o.fs)}depth(){return this.#C!==void 0?this.#C:this.parent?this.#C=this.parent.depth()+1:this.#C=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).#M(s):this.#M(s)}#M(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&=~Zi,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let s=this.children(),i=this.nocase?Ys(t):gs(t);for(let a of s)if(a.#T===i)return a;let r=this.parent?this.sep:"",n=this.#m?this.#m+r+t:void 0,o=this.newChild(t,Ut,{...e,parent:this,fullpath:n});return this.canReaddir()||(o.#e|=Gt),s.push(o),o}relative(){if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let t=this.name,e=this.parent;if(!e)return this.#x=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&jt)===Ut}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&jt)===eo}isDirectory(){return(this.#e&jt)===Vt}isCharacterDevice(){return(this.#e&jt)===Qn}isBlockDevice(){return(this.#e&jt)===to}isFIFO(){return(this.#e&jt)===Zn}isSocket(){return(this.#e&jt)===so}isSymbolicLink(){return(this.#e&$e)===$e}lstatCached(){return this.#e&xn?this:void 0}readlinkCached(){return this.#I}realpathCached(){return this.#R}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#I)return!0;if(!this.parent)return!1;let t=this.#e&jt;return!(t!==Ut&&t!==$e||this.#e&Vs||this.#e&Gt)}calledReaddir(){return!!(this.#e&Zi)}isENOENT(){return!!(this.#e&Gt)}isNamed(t){return this.nocase?this.#T===Ys(t):this.#T===gs(t)}async readlink(){let t=this.#I;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.#I=s}catch(e){this.#$(e.code);return}}readlinkSync(){let t=this.#I;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.#I=s}catch(e){this.#$(e.code);return}}#N(t){this.#e|=Zi;for(let e=t.provisional;e<t.length;e++){let s=t[e];s&&s.#k()}}#k(){this.#e&Gt||(this.#e=(this.#e|Gt)&us,this.#G())}#G(){let t=this.children();t.provisional=0;for(let e of t)e.#k()}#L(){this.#e|=Js,this.#D()}#D(){if(this.#e&fs)return;let t=this.#e;(t&jt)===Vt&&(t&=us),this.#e=t|fs,this.#G()}#B(t=""){t==="ENOTDIR"||t==="EPERM"?this.#D():t==="ENOENT"?this.#k():this.children().provisional=0}#P(t=""){t==="ENOTDIR"?this.parent.#D():t==="ENOENT"&&this.#k()}#$(t=""){let e=this.#e;e|=Vs,t==="ENOENT"&&(e|=Gt),(t==="EINVAL"||t==="UNKNOWN")&&(e&=us),this.#e=e,t==="ENOTDIR"&&this.parent&&this.parent.#D()}#j(t,e){return this.#W(t,e)||this.#U(t,e)}#U(t,e){let s=Qi(t),i=this.newChild(t.name,s,{parent:this}),r=i.#e&jt;return r!==Vt&&r!==$e&&r!==Ut&&(i.#e|=fs),e.unshift(i),e.provisional++,i}#W(t,e){for(let s=e.provisional;s<e.length;s++){let i=e[s];if((this.nocase?Ys(t.name):gs(t.name))===i.#T)return this.#c(t,i,s,e)}}#c(t,e,s,i){let r=e.name;return e.#e=e.#e&us|Qi(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&Gt)===0)try{return this.#z(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#P(t.code)}}lstatSync(){if((this.#e&Gt)===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:a,ctimeMs:l,dev:c,gid:p,ino:u,mode:d,mtime:g,mtimeMs:f,nlink:y,rdev:b,size:v,uid:S}=t;this.#b=e,this.#l=s,this.#g=i,this.#v=r,this.#u=n,this.#h=o,this.#A=a,this.#p=l,this.#s=c,this.#S=p,this.#a=u,this.#n=d,this.#f=g,this.#i=f,this.#r=y,this.#w=b,this.#d=v,this.#o=S;let k=Qi(t);this.#e=this.#e&us|k|xn,k!==Ut&&k!==Vt&&k!==$e&&(this.#e|=fs)}#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.#N(s)}this.#H(s.slice(0,s.provisional))})}#q;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.#q)await this.#q;else{let s=()=>{};this.#q=new Promise(i=>s=i);try{for(let i of await this.#t.promises.readdir(e,{withFileTypes:!0}))this.#j(i,t);this.#N(t)}catch(i){this.#B(i.code),t.provisional=0}this.#q=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.#N(t)}catch(s){this.#B(s.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#e&kn)return!1;let t=jt&this.#e;return t===Ut||t===Vt||t===$e}shouldWalk(t,e){return(this.#e&Vt)===Vt&&!(this.#e&kn)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#R)return this.#R;if(!((Js|Vs|Gt)&this.#e))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#R=this.resolve(t)}catch{this.#L()}}realpathSync(){if(this.#R)return this.#R;if(!((Js|Vs|Gt)&this.#e))try{let t=this.#t.realpathSync(this.fullpath());return this.#R=this.resolve(t)}catch{this.#L()}}[io](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.#x=s.join(this.sep),i.#E=s.join("/"),i=i.parent,s.push("..");for(i=t;i&&i.parent&&!e.has(i);)i.#x=void 0,i.#E=void 0,i=i.parent}},ro=class no extends $t{sep="\\";splitSep=Zc;constructor(e,s=Ut,i,r,n,o,a){super(e,s,i,r,n,o,a)}newChild(e,s=Ut,i={}){return new no(e,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}getRootString(e){return er.parse(e).root}getRoot(e){if(e=Jc(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 nr(e,this).root}sameRoot(e,s=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(Jn,"$1\\"),e===s}},oo=class ao extends $t{splitSep="/";sep="/";constructor(e,s=Ut,i,r,n,o,a){super(e,s,i,r,n,o,a)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,s=Ut,i={}){return new ao(e,s,this.root,this.roots,this.nocase,this.childrenCache(),i)}},lo=class{root;rootPath;roots;cwd;#t;#s;#n;nocase;#r;constructor(t=process.cwd(),e,s,{nocase:i,childrenCacheSize:r=16*1024,fs:n=ps}={}){this.#r=Kn(n),(t instanceof URL||t.startsWith("file://"))&&(t=Ac(t));let o=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(o),this.#t=new En,this.#s=new En,this.#n=new tu(r);let a=o.substring(this.rootPath.length).split(s);if(a.length===1&&!a[0]&&a.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 l=this.root,c=a.length-1,p=e.sep,u=this.rootPath,d=!1;for(let g of a){let f=c--;l=l.child(g,{relative:new Array(f).fill("..").join(p),relativePosix:new Array(f).fill("..").join("/"),fullpath:u+=(d?"":p)+g}),d=!0}this.cwd=l}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 $t||(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 $t||(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 $t||(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 $t||(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 $t||(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 $t||(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 $t||(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 a=new Set,l=(p,u)=>{a.add(p),p.readdirCB((d,g)=>{if(d)return u(d);let f=g.length;if(!f)return u();let y=()=>{--f===0&&u()};for(let b of g)(!r||r(b))&&o.push(s?b:b.fullpath()),i&&b.isSymbolicLink()?b.realpath().then(v=>v?.isUnknown()?v.lstat():v).then(v=>v?.shouldWalk(a,n)?l(v,y):y()):b.shouldWalk(a,n)?l(b,y):y()},!0)},c=t;return new Promise((p,u)=>{l(c,d=>{if(d)return u(d);p(o)})})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof $t||(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 a=new Set([t]);for(let l of a){let c=l.readdirSync();for(let p of c){(!r||r(p))&&o.push(s?p:p.fullpath());let u=p;if(p.isSymbolicLink()){if(!(i&&(u=p.realpathSync())))continue;u.isUnknown()&&u.lstatSync()}u.shouldWalk(a,n)&&a.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 $t||(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 $t||(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 a of o){let l=a.readdirSync();for(let c of l){(!r||r(c))&&(yield s?c:c.fullpath());let p=c;if(c.isSymbolicLink()){if(!(i&&(p=c.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(o,n)&&o.add(p)}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof $t||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:n}=e,o=new ti({objectMode:!0});(!r||r(t))&&o.write(s?t:t.fullpath());let a=new Set,l=[t],c=0,p=()=>{let u=!1;for(;!u;){let d=l.shift();if(!d){c===0&&o.end();return}c++,a.add(d);let g=(y,b,v=!1)=>{if(y)return o.emit("error",y);if(i&&!v){let S=[];for(let k of b)k.isSymbolicLink()&&S.push(k.realpath().then(E=>E?.isUnknown()?E.lstat():E));if(S.length){Promise.all(S).then(()=>g(null,b,!0));return}}for(let S of b)S&&(!r||r(S))&&(o.write(s?S:S.fullpath())||(u=!0));c--;for(let S of b){let k=S.realpathCached()||S;k.shouldWalk(a,n)&&l.push(k)}u&&!o.flowing?o.once("drain",p):f||p()},f=!0;d.readdirCB(g,!0),f=!1}};return p(),o}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof $t||(e=t,t=this.cwd);let{withFileTypes:s=!0,follow:i=!1,filter:r,walkFilter:n}=e,o=new ti({objectMode:!0}),a=new Set;(!r||r(t))&&o.write(s?t:t.fullpath());let l=[t],c=0,p=()=>{let u=!1;for(;!u;){let d=l.shift();if(!d){c===0&&o.end();return}c++,a.add(d);let g=d.readdirSync();for(let f of g)(!r||r(f))&&(o.write(s?f:f.fullpath())||(u=!0));c--;for(let f of g){let y=f;if(f.isSymbolicLink()){if(!(i&&(y=f.realpathSync())))continue;y.isUnknown()&&y.lstatSync()}y.shouldWalk(a,n)&&l.push(y)}}u&&!o.flowing&&o.once("drain",p)};return p(),o}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[io](e)}},nr=class extends lo{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,er,"\\",{...e,nocase:s}),this.nocase=s;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(t){return er.parse(t).root.toUpperCase()}newRoot(t){return new ro(this.rootPath,Vt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},or=class extends lo{sep="/";constructor(t=process.cwd(),e={}){let{nocase:s=!1}=e;super(t,Rc,"/",{...e,nocase:s}),this.nocase=s}parseRootPath(t){return"/"}newRoot(t){return new oo(this.rootPath,Vt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},co=class extends or{constructor(t=process.cwd(),e={}){let{nocase:s=!0}=e;super(t,{...e,nocase:s})}},Ed=process.platform==="win32"?ro:oo,eu=process.platform==="win32"?nr:process.platform==="darwin"?co:or,su=t=>t.length>=1,iu=t=>t.length>=1,ru=Symbol.for("nodejs.util.inspect.custom"),uo=class ho{#t;#s;#n;length;#r;#o;#S;#w;#u;#a;#d=!0;constructor(e,s,i,r){if(!su(e))throw new TypeError("empty pattern list");if(!iu(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,a,l,...c]=this.#t,[p,u,d,g,...f]=this.#s;c[0]===""&&(c.shift(),f.shift());let y=[n,o,a,l,""].join("/"),b=[p,u,d,g,""].join("/");this.#t=[y,...c],this.#s=[b,...f],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[n,...o]=this.#t,[a,...l]=this.#s;o[0]===""&&(o.shift(),l.shift());let c=n+"/",p=a+"/";this.#t=[c,...o],this.#s=[p,...l],this.length=this.#t.length}}}[ru](){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]===Et}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#S=this.#S||(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 ho(this.#t,this.#s,this.#n+1,this.#r),this.#o.#a=this.#a,this.#o.#u=this.#u,this.#o.#w=this.#w,this.#o):this.#o=null}isUNC(){let e=this.#t;return this.#u!==void 0?this.#u:this.#u=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.#a!==void 0?this.#a:this.#a=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)}},nu=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=nu}){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 fe(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 uo(i,r,0,this.platform),o=new fe(n.globString(),this.mmopts),a=r[r.length-1]==="**",l=n.isAbsolute();l?this.absolute.push(o):this.relative.push(o),a&&(l?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}},ou=class po{store;constructor(e=new Map){this.store=e}copy(){return new po(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()]))}},au=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)])}},lu=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())}},An=class fo{hasWalkedCache;matches=new au;subwalks=new lu;patterns;follow;dot;opts;constructor(e,s){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=s?s.copy():new ou}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(),a=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 l,c,p=!1;for(;typeof(l=n.pattern())=="string"&&(c=n.rest());)r=r.resolve(l),n=c,p=!0;if(l=n.pattern(),c=n.rest(),p){if(this.hasWalkedCache.hasWalked(r,n))continue;this.hasWalkedCache.storeWalked(r,n)}if(typeof l=="string"){let u=l===".."||l===""||l===".";this.matches.add(r.resolve(l),a,u);continue}else if(l===Et){(!r.isSymbolicLink()||this.follow||n.checkFollowGlobstar())&&this.subwalks.add(r,n);let u=c?.pattern(),d=c?.rest();if(!c||(u===""||u===".")&&!d)this.matches.add(r,a,u===""||u===".");else if(u===".."){let g=r.parent||r;d?this.hasWalkedCache.hasWalked(g,d)||this.subwalks.add(g,d):this.matches.add(g,a,!0)}}else l instanceof RegExp&&this.subwalks.add(r,n)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new fo(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 a=o.isAbsolute(),l=o.pattern(),c=o.rest();l===Et?r.testGlobstar(n,o,c,a):l instanceof RegExp?r.testRegExp(n,l,c,a):r.testString(n,l,c,a)}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))}},cu=(t,e)=>typeof t=="string"?new Rn([t],e):Array.isArray(t)?new Rn(t,e):t,go=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=cu(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 An(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,a,l]of s.matches.entries())this.#r(o)||(r++,this.match(o,a,l).then(()=>n()));for(let o of s.subwalkTargets()){if(this.maxDepth!==1/0&&o.depth()>=this.maxDepth)continue;r++;let a=o.readdirCached();o.calledReaddir()?this.walkCB3(o,a,s,n):o.readdirCB((l,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,a,l]of s.matches.entries())this.#r(o)||(r++,this.match(o,a,l).then(()=>n()));for(let[o,a]of s.subwalks.entries())r++,this.walkCB2(o,a,s.child(),n);n()}walkCBSync(t,e,s){this.signal?.aborted&&s(),this.walkCB2Sync(t,e,new An(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,a,l]of s.matches.entries())this.#r(o)||this.matchSync(o,a,l);for(let o of s.subwalkTargets()){if(this.maxDepth!==1/0&&o.depth()>=this.maxDepth)continue;r++;let a=o.readdirSync();this.walkCB3Sync(o,a,s,n)}n()}walkCB3Sync(t,e,s,i){s=s.filterEntries(t,e);let r=1,n=()=>{--r===0&&i()};for(let[o,a,l]of s.matches.entries())this.#r(o)||this.matchSync(o,a,l);for(let[o,a]of s.subwalks.entries())r++,this.walkCB2Sync(o,a,s.child(),n);n()}},_n=class extends go{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}},Pn=class extends go{results;constructor(t,e,s){super(t,e,s),this.results=new ti({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}},uu=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ie=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=kc(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(a=>a.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(a=>a.includes("/")?a:`./**/${a}`)}if(this.pattern=t,this.platform=e.platform||uu,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 a=e.platform==="win32"?nr:e.platform==="darwin"?co:e.platform?or:eu;this.scurry=new a(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(a=>new fe(a,i)),[n,o]=r.reduce((a,l)=>(a[0].push(...l.set),a[1].push(...l.globParts),a),[[],[]]);this.patterns=n.map((a,l)=>{let c=o[l];if(!c)throw new Error("invalid pattern object");return new uo(a,c,0,this.platform)})}async walk(){return[...await new _n(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 _n(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 Pn(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 Pn(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()}},hu=(t,e={})=>{Array.isArray(t)||(t=[t]);for(let s of t)if(new fe(s,e).hasMagic())return!0;return!1};function si(t,e={}){return new Ie(t,e).streamSync()}function mo(t,e={}){return new Ie(t,e).stream()}function wo(t,e={}){return new Ie(t,e).walkSync()}async function $n(t,e={}){return new Ie(t,e).walk()}function ii(t,e={}){return new Ie(t,e).iterateSync()}function yo(t,e={}){return new Ie(t,e).iterate()}var du=si,pu=Object.assign(mo,{sync:si}),fu=ii,gu=Object.assign(yo,{sync:ii}),mu=Object.assign(wo,{stream:si,iterate:ii}),Xe=Object.assign($n,{glob:$n,globSync:wo,sync:mu,globStream:mo,stream:pu,globStreamSync:si,streamSync:du,globIterate:yo,iterate:gu,globIterateSync:ii,iterateSync:fu,Glob:Ie,hasMagic:hu,escape:Bn,unescape:qe});Xe.glob=Xe;var ri=bu(wu);async function Su(t){try{return await ri(t,["--version"],{timeout:5e3}),!0}catch{return!1}}async function vu(t){try{return await ri("git",["rev-parse","--git-dir"],{cwd:t,timeout:5e3}),!0}catch{return!1}}function xu(t,e){let s=[],i=t.split(`
|
|
9
|
+
`).filter(Boolean);for(let r of i){let n=r.match(/^(.+?)[:-](\d+)[:-](.*)$/),[,o,a,l]=n??[];o&&a&&l!==void 0&&s.push({file:bo.isAbsolute(o)?o:bo.join(e,o),line:Number.parseInt(a,10),content:l.slice(0,500)})}return s}var So=async t=>{let e=t.path?Dt(t.path):process.cwd(),s=Math.min(t.limit??100,500),i=t.context_lines??0;try{let r="",n="native";if(await Su("rg")){n="ripgrep";let a=["--line-number","--no-heading","--color=never",`--max-count=${s}`];i>0&&a.push(`-C${i}`),t.include&&a.push(`--glob=${t.include}`),a.push("--",t.pattern,e);try{r=(await ri("rg",a,{timeout:rs,maxBuffer:is})).stdout}catch(l){let c=l;if(c.code===1&&!c.stdout)r="";else if(c.stdout)r=c.stdout;else throw l}}else if(await vu(e)){n="git-grep";let a=["grep","-n","--no-color",`-m${s}`];i>0&&a.push(`-C${i}`),a.push("-e",t.pattern);try{r=(await ri("git",a,{cwd:e,timeout:rs,maxBuffer:is})).stdout}catch(l){if(l.code===1)r="";else throw l}}else{n="native";let a=[],l=new RegExp(t.pattern,"gi"),c=t.include||"**/*",p=await Xe(c,{cwd:e,nodir:!0,absolute:!0}),u=await js(e);p=Us(p,e,u);for(let d of p){if(a.length>=s)break;try{let f=(await yu.readFile(d,"utf-8")).split(`
|
|
10
|
+
`);for(let[y,b]of f.entries()){if(a.length>=s)break;l.test(b)&&(a.push({file:d,line:y+1,content:b.slice(0,500)}),l.lastIndex=0)}}catch{}}return{success:!0,matches:a,tool:n,total:a.length}}let o=xu(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 ku from"fs/promises";var vo=async t=>{try{let e=await Nt(t.path);return{success:!0,entries:(await ku.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 ni from"fs/promises";import Tu from"path";var xo=async t=>{try{let e=await Nt(t.source),s=Dt(t.destination);await ni.mkdir(Tu.dirname(s),{recursive:!0});try{await ni.rename(e,s)}catch(i){if(i.code!=="EXDEV")throw i;await ni.cp(e,s,{recursive:!0}),await ni.rm(e,{recursive:!0})}return{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to move file"}}};import ar from"fs/promises";var ko=async t=>{try{let e=await Nt(t.path),s=await Bs(e);if(s.type==="binary"){let p=await ar.stat(e);if(p.size>ze){let g=Math.round(p.size/1024/1024),f=Math.round(ze/1024/1024);return{success:!1,error:`Binary file too large (${g}MB). Maximum size is ${f}MB.`}}let d=(await ar.readFile(e)).toString("base64");return{success:!0,type:"binary",mimeType:s.mimeType,content:d,size:p.size,encoding:"base64"}}let r=(await ar.readFile(e,"utf-8")).split(`
|
|
11
|
+
`),n=r.length,o=Math.max(1,t.start_line??1),a=Math.min(n,t.end_line??o+499),c=r.slice(o-1,a).join(`
|
|
12
|
+
`);return{success:!0,type:"text",content:ie(c),lines:{total:n,start:o,end:Math.min(a,n)},truncated:c.length>Gi}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to read file"}}};import cr 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 Cu(t){let e=To(t);return e==="EPERM"||e==="EACCES"}function lr(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 Co(t,e){return async s=>{let i=await t(s);return!i.success&&typeof i.error=="string"?(Cu(i.error)&&e?.(i.error),{...i,error:lr(i.error)}):i}}async function Eu(t){let e=await Nt(t),s=await Bs(e);if(s.type!=="binary")return ie(await cr.readFile(e,"utf-8"),Qr);let i=await cr.stat(e);if(i.size>ze){let n=Math.round(i.size/1024/1024),o=Math.round(ze/1024/1024);return{error:`Binary file too large (${n}MB). Maximum size is ${o}MB.`}}let r=await cr.readFile(e);return{type:"binary",mimeType:s.mimeType,content:r.toString("base64"),size:i.size,encoding:"base64"}}var Eo=async t=>{try{let e=t.paths.slice(0,en),s={};return await Promise.all(e.map(async i=>{try{s[i]=await Eu(i)}catch(r){let n=r instanceof Error?r.message:"Failed to read file";s[i]={error:lr(n)}}})),{success:!0,files:s}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to read files"}}};var Ro=async t=>{try{let e=t.path?Dt(t.path):process.cwd(),s=t.respect_gitignore??!0,i=await Xe(t.pattern,{cwd:e,nodir:!0,absolute:!0,maxDepth:tn});if(s){let r=await js(e);i=Us(i,e,r)}return{success:!0,files:i.slice(0,Hi),total:i.length,truncated:i.length>Hi}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Failed to search files"}}};import ur from"fs/promises";import Ru from"path";var Ao=async t=>{try{let e=Dt(t.path),s=Ru.dirname(e);if(await ur.mkdir(s,{recursive:!0}),t.encoding==="base64"){let i=Buffer.from(t.content,"base64");await ur.writeFile(e,i)}else if(!t.encoding||t.encoding==="utf-8")await ur.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 _p from"fs/promises";import $p from"path";var _o={filesystem__read_file:ko,filesystem__read_multiple_files:Eo,filesystem__write_file:Ao,filesystem__edit_file:an,filesystem__create_directory:nn,filesystem__list_directory:vo,filesystem__search_files:Ro,filesystem__grep_files:So,filesystem__get_file_info:cn,filesystem__move_file:xo,filesystem__execute_command:ln};function $o(){return{name:"filesystem",systemPrompt:Dr({toolNames:Mi.map(t=>t.name),env:{home:_u.homedir(),cwd:process.cwd()}}),tools:[...Mi]}}var Po=!1;function Pu(){process.platform==="darwin"&&(Po||process.stdout.isTTY&&(Po=!0,Au('open "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles"',()=>{})))}async function Io(t,e){let s=_o[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 Co(s,Pu)(i);if(!r.success){let{success:a,error:l,...c}=r,p=Object.keys(c).length>0;return{success:!1,error:l,result:p?c:void 0}}let{success:n,...o}=r;return{success:!0,result:o}}function hr(t){return t.startsWith("filesystem__")}function Mo(){return[$o()]}function oi(){return Mo().flatMap(t=>t.tools)}function ai(){return Mo().map(t=>t.systemPrompt).filter(Boolean).join(`
|
|
17
|
+
|
|
18
|
+
`)}function ms(t){return hr(t)}async function li(t,e){return hr(t)?Io(t,e):{success:!1,error:`Unknown client tool: ${t}`}}function ci(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}=Or(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 dt,Text as O,useInput as Rs}from"ink";import Pr from"ink-spinner";import{useCallback as Ri,useEffect as Ai,useRef as As,useState as $r}from"react";import{Box as ui,Text as ws}from"ink";import{jsx as hi,jsxs as ys}from"react/jsx-runtime";function Fo(t,e){return t.length<=e?t:e<=3?".".repeat(e):t.slice(0,e-3)+"..."}function Do({items:t,activeIndex:e,selectedIds:s,multiSelect:i=!1,visible:r,title:n,pageSize:o=10}){if(!r||t.length===0)return null;let a=process.stdout.columns??80,l=i?4:0,c=Math.max(20,a-2-2-l),p=Math.max(1,o),u=Math.floor(e/p)*p,d=Math.min(t.length,u+p),g=t.slice(u,d);return ys(ui,{flexDirection:"column",marginBottom:1,children:[hi(ws,{bold:!0,color:"cyan",children:n}),hi(ui,{borderStyle:"single",borderColor:"gray",flexDirection:"column",children:g.map((f,y)=>{let v=u+y===e,S=s?.has(f.id),k=Fo(f.name,c),E=f.description?Fo(f.description,Math.max(0,c-l)):"",P=i?" ".repeat(l):"";return ys(ui,{paddingX:1,flexDirection:"column",children:[ys(ui,{children:[i&&hi(ws,{color:S?"green":"gray",children:S?"[\u2713] ":"[ ] "}),hi(ws,{backgroundColor:v?"cyan":void 0,color:v?"black":S?"green":"white",bold:!0,children:k})]}),E&&ys(ws,{dimColor:!0,children:[P,"\xB7 ",E]})]},f.id)})}),ys(ws,{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>p?` \xB7 Showing ${u+1}-${d} of ${t.length}`:""]})]})}import{Box as dr,Text as bs}from"ink";import{jsx as Ss,jsxs as pr}from"react/jsx-runtime";function Oo({suggestions:t,activeIndex:e,visible:s}){return!s||t.length===0?null:pr(dr,{flexDirection:"column",marginBottom:1,children:[Ss(dr,{borderStyle:"single",borderColor:"gray",flexDirection:"column",children:t.map((i,r)=>{let n=r===e,o=i.aliases.length>0?` (${i.aliases.join(", ")})`:"";return pr(dr,{paddingX:1,children:[pr(bs,{backgroundColor:n?"cyan":void 0,color:n?"black":"cyan",bold:n,children:["/",i.name]}),Ss(bs,{dimColor:!0,children:o}),Ss(bs,{children:" - "}),Ss(bs,{color:n?"white":"gray",children:i.description})]},i.name)})}),Ss(bs,{dimColor:!0,children:"\u2191\u2193 Navigate \xB7 Tab/Enter Select \xB7 Esc Cancel"})]})}import{Box as $u,Text as Lo,useInput as Iu,useStdout as Mu}from"ink";import{useCallback as No,useEffect as Bo,useMemo as fr,useRef as jo,useState as Uo}from"react";import{jsx as wr}from"react/jsx-runtime";function di(t,e){return t<0?0:t>e?e:t}function gr(t){return[...t]}function pi(t){return/\s/.test(t)}function mr(t,e){let s=e;for(;s>0&&pi(t[s-1]??"");)s-=1;for(;s>0&&!pi(t[s-1]??"");)s-=1;return s}function Wo(t,e){let s=e;for(;s<t.length&&pi(t[s]??"");)s+=1;for(;s<t.length&&!pi(t[s]??"");)s+=1;return s}function Fu(t){let e=[],s=[],i=[],r=0;s.push(0),t.forEach((o,a)=>{if(o===`
|
|
19
|
+
`){e.push(i),i=[],r=a+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 zo(t,e,s){for(let r=0;r<e.length;r+=1){let n=e[r]??0,o=s[r]??0,a=n+o;if(t<=a)return{row:r,col:t-n}}let i=Math.max(0,e.length-1);return{row:i,col:s[i]??0}}var Du=2;function Go({value:t,onChange:e,onSubmit:s,onPaste:i,focus:r=!0,leadingOffset:n=0,multiline:o=!1}){let[a,l]=Uo(()=>gr(t).length),c=jo(null),[p,u]=Uo(0),d=jo(null),{stdout:g}=Mu(),f=fr(()=>gr(t),[t]),{lines:y,lineStarts:b,lineLengths:v}=fr(()=>Fu(f),[f]),{row:S,col:k}=fr(()=>zo(a,b,v),[a,b,v]),E=Math.max(1,(g?.columns??80)-n);Bo(()=>{c.current===t?l($=>di($,f.length)):(l(f.length),d.current=null),c.current=t},[t,f.length]),Bo(()=>{u($=>{let A=$;k<A?A=k:k>=A+E&&(A=k-E+1);let m=v[S]??0,N=k===m?m+1:m,tt=Math.max(0,N-E);return A>tt&&(A=tt),A<0&&(A=0),A})},[E,k,S,v]);let P=No(($,A)=>{c.current=$,e($),l(A),d.current=null},[e]),H=No(async($,A)=>{if(!r)return;let{row:m,col:N}=zo(a,b,v),tt=y[m]??[],vt=v[m]??0,M=y.length>1;if(o&&(A.meta&&A.return||A.ctrl&&$==="j"||A.shift&&A.return)){let B=[...f.slice(0,a),`
|
|
20
|
+
`,...f.slice(a)].join("");P(B,a+1);return}if(A.return){s(t);return}if(A.leftArrow){A.ctrl||A.meta?(N===0&&m>0?l(b[m]-1):l(b[m]+mr(tt,N)),d.current=null):(N===0&&m>0?l(b[m]-1):l(B=>di(B-1,f.length)),d.current=null);return}if(A.rightArrow){A.ctrl||A.meta?(N>=vt&&m<y.length-1?l(b[m+1]):l(b[m]+Wo(tt,N)),d.current=null):(N>=vt&&m<y.length-1?l(b[m+1]):l(B=>di(B+1,f.length)),d.current=null);return}if(o&&M&&A.upArrow){let B=d.current??N,G=Math.max(0,m-1),Z=Math.min(B,v[G]??0);l((b[G]??0)+Z),d.current=B;return}if(o&&M&&A.downArrow){let B=d.current??N,G=Math.min(y.length-1,m+1),Z=Math.min(B,v[G]??0);l((b[G]??0)+Z),d.current=B;return}if(A.ctrl){if($==="a"){l(b[m]??0),d.current=null;return}if($==="e"){l((b[m]??0)+vt),d.current=null;return}if($==="u"){if(N>0){let B=b[m]??0,G=[...f.slice(0,B),...f.slice(a)].join("");P(G,B)}return}if($==="k"){if(N<vt){let B=(b[m]??0)+vt,G=[...f.slice(0,a),...f.slice(B)].join("");P(G,a)}return}if($==="w"){if(N===0&&m>0){let G=[...f.slice(0,a-1),...f.slice(a)].join("");P(G,a-1);return}let B=mr(tt,N);if(B!==N){let G=(b[m]??0)+B,Z=[...f.slice(0,G),...f.slice(a)].join("");P(Z,G)}return}if($==="d"){if(a<f.length){let B=[...f.slice(0,a),...f.slice(a+1)].join("");P(B,a)}return}return}if(A.meta){$==="b"?(N===0&&m>0?l(b[m]-1):l(b[m]+mr(tt,N)),d.current=null):$==="f"&&(N>=vt&&m<y.length-1?l(b[m+1]):l(b[m]+Wo(tt,N)),d.current=null);return}if(A.backspace||A.delete){if(a<=0)return;let B=[...f.slice(0,a-1),...f.slice(a)].join("");P(B,a-1);return}if(!(A.tab||A.escape)&&$.length>0){let B=o?$.replace(/\r\n/g,`
|
|
21
|
+
`).replace(/\r/g,`
|
|
22
|
+
`):$.replace(/\r?\n/g,"");if(!B||(B=B.replace(/^\u001B?\[200~/,"").replace(/\u001B?\[201~$/,""),!B))return;if((B.length>=Du||B.includes(`
|
|
23
|
+
`))&&i){let F=!1,U={text:B,preventDefault:()=>{F=!0}};if(await Promise.resolve(i(U)),F)return}let Z=gr(B),_=[...f.slice(0,a),...Z,...f.slice(a)].join("");P(_,a+Z.length)}},[f,a,r,v,b,y,o,i,s,P,t]);return Iu(H,{isActive:r}),wr($u,{flexDirection:"column",children:y.map(($,A)=>{let m=A===S,tt=(m&&k===$.length?[...$," "]:$).slice(p,p+E),vt=tt.join("");if(!m)return wr(Lo,{children:vt||" "},A);let M=di(k-p,Math.max(0,tt.length-1)),B=tt.slice(0,M).join(""),G=tt[M]??" ",Z=tt.slice(M+1).join(""),U=`${B}\x1B[7m${G}\x1B[27m${Z}`;return wr(Lo,{children:U},A)})})}import{Box as Yt,Text as ge}from"ink";import vr from"react";import{Text as Wt}from"ink";import Ou from"react";import{Fragment as Bu,jsx as Ht,jsxs as Xo}from"react/jsx-runtime";var yr=2,br=1,Sr=2,Lu=1,Ho=3,qo=4,Nu=({text:t,defaultColor:e,linkColor:s,codeColor:i})=>{let r=e;if(!/[*_~`<[https?:]/.test(t))return Ht(Wt,{color:r,children:t});let n=[],o=0,a=/(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>|https?:\/\/\S+)/g,l;for(;(l=a.exec(t))!==null;){l.index>o&&n.push(Ht(Wt,{color:r,children:t.slice(o,l.index)},`t-${o}`));let c=l[0],p=null,u=`m-${l.index}`;try{if(c.startsWith("**")&&c.endsWith("**")&&c.length>yr*2)p=Ht(Wt,{bold:!0,color:r,children:c.slice(yr,-yr)},u);else if(c.length>br*2&&(c.startsWith("*")&&c.endsWith("*")||c.startsWith("_")&&c.endsWith("_"))&&!/\w/.test(t.slice(Math.max(0,l.index-1),l.index))&&!/\w/.test(t.slice(a.lastIndex,a.lastIndex+1))&&!/\S[./\\]/.test(t.slice(Math.max(0,l.index-2),l.index))&&!/[./\\]\S/.test(t.slice(a.lastIndex,a.lastIndex+2)))p=Ht(Wt,{italic:!0,color:r,children:c.slice(br,-br)},u);else if(c.startsWith("~~")&&c.endsWith("~~")&&c.length>Sr*2)p=Ht(Wt,{strikethrough:!0,color:r,children:c.slice(Sr,-Sr)},u);else if(c.startsWith("`")&&c.endsWith("`")&&c.length>Lu){let d=c.match(/^(`+)(.+?)\1$/s);d&&d[2]&&(p=Ht(Wt,{color:i,children:d[2]},u))}else if(c.startsWith("[")&&c.includes("](")&&c.endsWith(")")){let d=c.match(/\[(.*?)\]\((.*?)\)/);if(d){let g=d[1],f=d[2];p=Xo(Wt,{color:r,children:[g,Xo(Wt,{color:s,children:[" (",f,")"]})]},u)}}else c.startsWith("<u>")&&c.endsWith("</u>")&&c.length>Ho+qo-1?p=Ht(Wt,{underline:!0,color:r,children:c.slice(Ho,-qo)},u):/^https?:\/\//.test(c)&&(p=Ht(Wt,{color:s,children:c},u))}catch{p=null}n.push(p??Ht(Wt,{color:r,children:c},u)),o=a.lastIndex}return o<t.length&&n.push(Ht(Wt,{color:r,children:t.slice(o)},`t-${o}`)),Ht(Bu,{children:n.filter(c=>c!==null)})},vs=Ou.memo(Nu);import{Fragment as qu,jsx as st,jsxs as Jo}from"react/jsx-runtime";var ju=1,Ko=1,Uu=1,Wu=1,zu=({content:t})=>{let e=t.join(`
|
|
24
|
+
`);return st(Yt,{paddingLeft:Ko,flexDirection:"column",children:st(ge,{color:"yellow",children:e})})},Vo=vr.memo(zu),Gu=({itemText:t,type:e,marker:s,leadingWhitespace:i=""})=>{let r=e==="ol"?`${s}. `:`${s} `,n=r.length,o=i.length;return Jo(Yt,{paddingLeft:o+Uu,flexDirection:"row",children:[st(Yt,{width:n,children:st(ge,{children:r})}),st(Yt,{flexGrow:Wu,children:st(ge,{wrap:"wrap",children:st(vs,{text:t,defaultColor:void 0,linkColor:"cyan",codeColor:"yellow"})})})]})},Yo=vr.memo(Gu),Hu=({text:t,renderMarkdown:e=!0})=>{if(!t)return null;if(!e)return st(Yt,{paddingLeft:Ko,flexDirection:"column",children:st(ge,{wrap:"wrap",children:t})});let s=t.split(/\r?\n/),i=/^ *(#{1,4}) +(.*)/,r=/^ *(`{3,}|~{3,}) *(\w*?) *$/,n=/^([ \t]*)([-*+]) +(.*)/,o=/^([ \t]*)(\d+)\. +(.*)/,a=/^ *([-*_] *){3,} *$/,l=/^ *> ?(.*)/,c=[],p=!1,u=!0,d=[],g="";function f(y){y&&(c.push(y),u=!1)}return s.forEach((y,b)=>{let v=`line-${b}`;if(p){let A=y.match(r);A&&A[1].startsWith(g[0])&&A[1].length>=g.length?(f(st(Vo,{content:d},v)),p=!1,d=[],g=""):d.push(y);return}let S=y.match(r),k=y.match(i),E=y.match(n),P=y.match(o),H=y.match(a),$=y.match(l);if(S)p=!0,g=S[1];else if(H)f(st(Yt,{children:st(ge,{dimColor:!0,children:"---"})},v));else if(k){let A=k[1].length,m=k[2],N=A<=2?"cyan":"blue";f(st(Yt,{children:st(ge,{color:N,...(A===4?"italic":"bold")==="italic"?{italic:!0}:{bold:!0},children:st(vs,{text:m,defaultColor:N,linkColor:"cyan",codeColor:"yellow"})})},v))}else if($){let A=$[1];f(st(Yt,{paddingLeft:1,children:Jo(ge,{dimColor:!0,children:["> ",st(vs,{text:A,defaultColor:"gray",linkColor:"cyan",codeColor:"yellow"})]})},v))}else if(E){let A=E[1],m=E[2],N=E[3];f(st(Yo,{itemText:N,type:"ul",marker:m,leadingWhitespace:A},v))}else if(P){let A=P[1],m=P[2],N=P[3];f(st(Yo,{itemText:N,type:"ol",marker:m,leadingWhitespace:A},v))}else y.trim().length===0?u||(c.push(st(Yt,{height:ju},`spacer-${b}`)),u=!0):f(st(Yt,{children:st(ge,{wrap:"wrap",children:st(vs,{text:y,defaultColor:void 0,linkColor:"cyan",codeColor:"yellow"})})},v))}),p&&f(st(Vo,{content:d},"line-eof")),st(qu,{children:c})},xr=vr.memo(Hu);import{execFile as Xu}from"child_process";import Vu from"fs";import Ve from"fs/promises";import Zo from"os";import gi from"path";import{promisify as Yu}from"util";var fi=Yu(Xu);async function Ku(){let t=gi.join(Zo.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 fi("osascript",["-e",e]),(await Ve.stat(t)).size===0?void 0:{buffer:await Ve.readFile(t),mime:"image/png"}}catch{return}finally{try{Vu.existsSync(t)&&await Ve.unlink(t)}catch{}}}async function Ju(){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 fi("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 Zu(){try{let{stdout:t}=await fi("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 fi("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 Qo(){let t=Zo.platform();if(t==="darwin")return Ku();if(t==="win32")return Ju();if(t==="linux")return Zu()}var Qu=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 ta(t){let e=gi.extname(t).toLowerCase();return Qu.has(e)}function th(t){let e=gi.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 mi(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 ea(t){let e=mi(t);if(/^https?:\/\//.test(e))return!1;try{return await Ve.access(e),!0}catch{return!1}}async function sa(t){let e=mi(t);try{if(!(await Ve.stat(e)).isFile())return;let i=await Ve.readFile(e),r=th(e),n=gi.basename(e);return{buffer:i,mimeType:r,filename:n}}catch{return}}var me="\x1B[2m",Q="\x1B[0m",At="\x1B[36m",kr="\x1B[32m",ia="\x1B[31m",Me="\x1B[38;2;59;91;204m",Tr="\x1B[38;2;126;200;248m",Cr="\x1B[38;2;244;196;78m";function xs(t){return t.replace(/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)/gu,"").replace(/\u001B\[[0-?]*[ -/]*[@-~]/gu,"").replace(/[\u0000-\u001F\u007F-\u009F]/gu,"")}function wi({agentId:t,agentDetails:e,activeConnectorIds:s,availableConnectors:i}){if(t)return e?e.connectors?.length?e.connectors.map(n=>n.name).join(", "):"none":"loading\u2026";if(!s?.length)return"all";let r=i.filter(n=>s.includes(n.id)).map(n=>n.name);return r.length>0?r.join(", "):`${s.length} connector(s)`}import{useState as oe}from"react";import{v4 as ra}from"uuid";function na(t,e){let[s,i]=oe({status:"loading"}),[r,n]=oe([]),[o,a]=oe(""),[l,c]=oe(()=>t||ra()),[p,u]=oe(e),[d,g]=oe(!!t),[f,y]=oe(null),[b,v]=oe(""),[S,k]=oe(!1),E=H=>{n($=>[...$,{role:"system",content:H}])};return{state:s,setState:i,messages:r,setMessages:n,input:o,setInput:a,taskId:l,setTaskId:c,currentTaskTitle:p,setCurrentTaskTitle:u,hasPersistedTask:d,setHasPersistedTask:g,credentials:f,setCredentials:y,currentResponse:b,setCurrentResponse:v,fullOutput:S,setFullOutput:k,addSystemMessage:E,startNewTask:H=>{let $=ra();c($),u(void 0),g(!1),n([]),H&&E(H)}}}import{useEffect as eh,useState as oa}from"react";function aa(t){let[e,s]=oa(null),[i,r]=oa(!0);return eh(()=>{let n=!1;async function o(){try{let a=await qt();if(n)return;s({accessToken:a.accessToken,workspaceId:a.workspaceId}),r(!1)}catch(a){if(n)return;if(a instanceof _e){if(a.code==="not-logged-in"){t({status:"not-logged-in"}),r(!1);return}if(a.code==="no-workspace"){t({status:"no-workspace"}),r(!1);return}}let l=a instanceof Error?a.message:"Authentication failed";t({status:"error",message:l}),r(!1)}}return o(),()=>{n=!0}},[t]),{credentials:e,loading:i}}import{useEffect as sh,useState as ks}from"react";function la(t){let[e,s]=ks([]),[i,r]=ks([]),[n,o]=ks([]),[a,l]=ks([]),[c,p]=ks(!1);return sh(()=>{if(!t)return;let u=!1;p(!0);async function d(){if(t)try{let g=new ht,[f,y,b,v]=await Promise.all([g.getConnectors(t.accessToken,t.workspaceId),g.listSelectableModels(t.accessToken,t.workspaceId),g.getAgents(t.accessToken,t.workspaceId),g.getModelProviders(t.accessToken,t.workspaceId)]);if(u)return;s(f.connectors),r(y.models),o(b.agents),l(v.providers??[])}catch{}finally{u||p(!1)}}return d(),()=>{u=!0}},[t]),{availableConnectors:e,availableModels:i,availableAgents:n,modelProviders:a,loading:c}}import{useChat as xh}from"@ai-sdk/react";import{getToolName as Ar,isToolUIPart as kh}from"ai";import{useCallback as Ke,useEffect as Fe,useRef as Kt,useState as Ei}from"react";import{v4 as Th}from"uuid";var ca="data: ";async function ih({response:t,onEvent:e,signal:s}){if(s.aborted||!t.body)return;let i=t.body.pipeThrough(new TextDecoderStream).getReader(),r=()=>{i.cancel().catch(()=>{})};s.addEventListener("abort",r,{once:!0});let n="";try{for(;!s.aborted;){let{done:o,value:a}=await i.read();if(o)return;n+=a;let l=n.indexOf(`
|
|
39
|
+
|
|
40
|
+
`);for(;l!==-1;){let c=n.slice(0,l);n=n.slice(l+2);for(let p of c.split(`
|
|
41
|
+
`))p.startsWith(ca)&&e(p.slice(ca.length));l=n.indexOf(`
|
|
42
|
+
|
|
43
|
+
`)}}}finally{s.removeEventListener("abort",r)}}function rh(t){return Math.min(3e4,500*2**Math.min(t,6))}function nh(t,e){return new Promise(s=>{let i,r=()=>{clearTimeout(i),e.removeEventListener("abort",r),s()};i=setTimeout(r,t),e.addEventListener("abort",r,{once:!0})})}function ua({open:t,onEvent:e,backoffMs:s=rh}){let i=new AbortController;return(async()=>{let n=0;for(;!i.signal.aborted;){try{let o=await t(i.signal);if(i.signal.aborted){o.body?.cancel().catch(()=>{});return}let a=!1;await ih({response:o,onEvent:l=>{a=!0,e(l)},signal:i.signal}),n=a?0:n+1}catch{n+=1}if(i.signal.aborted)return;await nh(s(n),i.signal)}})(),{dispose:()=>i.abort()}}var yi={status:"queued",activity:void 0,steps:[],stepCount:0};function oh(t){return"data"in t}function ha(t,e){switch(e.type){case"snapshot":{let s=e.data.progress;return{...t,status:e.data.status,activity:s?.activity??t.activity,steps:s?.steps??t.steps,stepCount:s?.stepCount??t.stepCount,usage:s?.usage??t.usage}}case"data-subagent-activity":return{...t,status:t.status==="queued"?"running":t.status,activity:{activity:e.activity,...e.toolName===void 0?{}:{toolName:e.toolName},...e.toolTitle===void 0?{}:{toolTitle:e.toolTitle}}};case"data-subagent-step":{let s=[...t.steps,{stepIndex:e.stepIndex,toolCallCount:e.toolCallCount,reasoningTokens:e.reasoningTokens,...e.toolCalls===void 0?{}:{toolCalls:e.toolCalls}}];return{...t,status:t.status==="queued"?"running":t.status,steps:s,stepCount:s.length,usage:e.usage}}case"data-subagent-done":return oh(e)?{...t,status:e.data.status}:{...t,status:e.status==="success"?"completed":"failed",...e.error===void 0?{}:{doneError:e.error}};default:return t}}var ah=2e3;function lh(t){if(typeof t!="object"||t===null)return;let{type:e,data:s}=t;if(e!=="data-subagent-start"||typeof s!="object"||s===null)return;let i=s;if(!(typeof i.runId!="string"||typeof i.toolCallId!="string"))return i}function bi({openRunEvents:t,getRun:e,pollIntervalMs:s=ah}){let i=new Map,r=new Map,n=new Set,o={runs:[],activeCount:0},a=!1,l=()=>{let u=[...i.values()];o={runs:u,activeCount:u.filter(d=>!Re(d.stream.status)).length};for(let d of n)d()},c=(u,d)=>{if(a)return;let g=i.get(u);g&&(i.set(u,{...g,stream:d}),Re(d.status)&&r.get(u)?.(),l())},p=u=>{let d=ua({open:b=>t(u,b),onEvent:b=>{let v;try{v=JSON.parse(b)}catch{return}let S=i.get(u)?.stream??yi;c(u,ha(S,v))}}),g=new AbortController,f,y=()=>{f=setTimeout(()=>{e(u,g.signal).then(b=>{let v=i.get(u)?.stream??yi;Re(v.status)||!Re(b.status)&&v.steps.length>0||c(u,{...v,status:b.status,steps:b.progress?.steps??v.steps,stepCount:b.progress?.stepCount??v.stepCount,activity:b.progress?.activity??v.activity,...b.progress?.usage?{usage:b.progress.usage}:{}})}).catch(()=>{}).finally(()=>{g.signal.aborted||y()})},s)};y(),r.set(u,()=>{d.dispose(),g.abort(),clearTimeout(f)})};return{ingestChunk:u=>{if(a)return;let d=lh(u);!d||i.has(d.runId)||(i.set(d.runId,{runId:d.runId,toolCallId:d.toolCallId,description:d.description,stream:yi}),p(d.runId),l())},getSnapshot:()=>o,subscribe:u=>(n.add(u),()=>n.delete(u)),dispose:()=>{a=!0;for(let u of r.values())u();r.clear(),n.clear()}}}function Si({agentId:t,model:e,connectorIds:s,clientTools:i,clientToolSystemPrompt:r,toolApprovalMode:n}){return{...t?{agentId:t}:{...e?{model:e}:{},...s?.length?{connectorIds:s}:{}},...i?{clientTools:i}:{},...r?{clientToolSystemPrompt:r}:{},...n?{toolApprovalMode:n}:{}}}import{DefaultChatTransport as ch,isToolUIPart as uh}from"ai";import Ts from"fs";import da from"path";var Cs=da.join(Br(),"stream-debug.log");function pa(){try{Ts.existsSync(Cs)&&Ts.unlinkSync(Cs),process.env.DEBUG&&(Ts.mkdirSync(da.dirname(Cs),{recursive:!0}),Ts.writeFileSync(Cs,`=== Debug session started at ${new Date().toISOString()} ===
|
|
44
|
+
`))}catch{}}function Er(t,e){if(!process.env.DEBUG)return;let s=`[${new Date().toISOString()}] ${t}`;e!==void 0&&(s+=`
|
|
45
|
+
DATA: ${JSON.stringify(e,null,2)}`);try{Ts.appendFileSync(Cs,s+`
|
|
46
|
+
`)}catch{}}function hh(t,e,s){let i=!!process.env.DEBUG;return!i&&!e&&!s?t:t.pipeThrough(new TransformStream({transform(r,n){i&&Er(`SSE chunk: ${r.type}`,r),e?.(r),n.enqueue(r)},flush(){s?.()}}))}var Ye=class extends ch{resolveCredentials;resolveTaskConfig;sendTask;onToolPartsSubmitted;onChunk;onStreamEnd;constructor(e){super(),this.resolveCredentials=e.resolveCredentials,this.resolveTaskConfig=e.resolveTaskConfig,this.sendTask=e.sendTask,this.onToolPartsSubmitted=e.onToolPartsSubmitted,this.onChunk=e.onChunk,this.onStreamEnd=e.onStreamEnd}async sendMessages(e){let s=await this.resolveCredentials(),i=Lr(e.messages.at(-1)),r=i&&i.role!=="system"?{id:i.id,role:i.role,parts:i.parts}:void 0;r?.role!=="assistant"&&pa(),Er("=== Sending task request ===",{taskId:e.chatId,messageRole:r?.role,partCount:r?.parts.length});let n=await this.sendTask(s,{...this.resolveTaskConfig(),...e.body,id:e.chatId,message:r});if(i?.role==="assistant"&&this.onToolPartsSubmitted?.(i.parts.filter(uh).map(o=>o.toolCallId)),!n.body)throw new Error("Task stream response has no body.");return Nr(hh(this.processResponseStream(n.body),this.onChunk,this.onStreamEnd),e.abortSignal)}reconnectToStream(){return Promise.resolve(null)}};function fa(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)+"\u2026"}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)+"\u2026"}}if("content"in s&&Array.isArray(s.content)){let r=s.content.filter(n=>n.type==="text"&&n.text).map(n=>n.text).join(`
|
|
47
|
+
`);return r?e||r.length<=200?r:r.slice(0,200)+"\u2026":"(result)"}if(s.type==="text"&&typeof s.content=="string"){let r=s.content;return e||r.length<=200?r:r.slice(0,200)+"\u2026"}let i=JSON.stringify(t,null,e?2:void 0);return e||i.length<=200?i:i.slice(0,200)+"\u2026"}function we(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(`${me}[Thinking]
|
|
48
|
+
${i.text}${Q}`):s.push(`${me}[Thinking\u2026]${Q}`);else if(i.type==="tool-call"&&i.toolName){let r=[`${At}\u250C\u2500 Tool: ${i.toolName}${Q}`];if(i.args){let n=JSON.stringify(i.args,null,e?2:void 0),o=e||n.length<=100?n:n.slice(0,100)+"\u2026";r.push(`${me}\u2502 Input: ${o}${Q}`)}i.result===void 0?r.push(`${At}\u2514\u2500${Q}`):(r.push(`${kr}\u2502 Output: ${fa(i.result,e)}${Q}`),r.push(`${At}\u2514\u2500 completed${Q}`)),s.push(r.join(`
|
|
49
|
+
`))}else if(i.type.startsWith("tool-")&&i.type!=="tool-call"){let r=i.title||i.type.slice(5).replace(/__/g," "),n=[`${At}\u250C\u2500 Tool: ${r}${Q}`];if(i.input){let o=JSON.stringify(i.input,null,e?2:void 0),a=e||o.length<=100?o:o.slice(0,100)+"\u2026";n.push(`${me}\u2502 Input: ${a}${Q}`)}i.output!==void 0&&i.state==="output-available"?(n.push(`${kr}\u2502 Output: ${fa(i.output,e)}${Q}`),n.push(`${At}\u2514\u2500 completed${Q}`)):i.state==="error"?n.push(`${At}\u2514\u2500 failed${Q}`):n.push(`${At}\u2514\u2500${Q}`),s.push(n.join(`
|
|
50
|
+
`))}return s.join(`
|
|
51
|
+
|
|
52
|
+
`).trim()}import{getToolName as Ti,isReasoningUIPart as Sa,isTextUIPart as va,isToolUIPart as xa}from"ai";var dh=new Set(["data-subagent-activity","data-subagent-step","data-subagent-done"]);function ph(t){return t.type!==void 0&&dh.has(t.type)}function fh(t,e){let s=t.data;if(!(typeof s!="object"||s===null))return s.toolCallId===e?s:void 0}function ga(t,e){let s=[],i,r;for(let n of t){let o=fh(n,e);o&&(n.type==="data-subagent-step"&&s.push(o),n.type==="data-subagent-activity"&&(i=o),n.type==="data-subagent-done"&&(r=o))}return{activity:i,steps:s,latestStep:s.at(-1),done:r}}function ma(t,e){return`${t} ${e}${t===1?"":"s"}`}function vi(t){return t>0?[ma(t,"tool call")]:[]}function xi(t){return t>=999500?`${(t/1e6).toFixed(1)}M tokens`:t>=1e3?`${(t/1e3).toFixed(1)}k tokens`:`${t} tokens`}function gh(t){let e=Math.round(t/1e3);if(e<60)return`${e}s`;let s=Math.floor(e/60),i=e%60;return`${s}m ${i}s`}function wa(t){return[ma(t.stepCount,"step"),...vi(t.totalToolCalls),xi(t.usage.totalTokens),...t.durationMs===void 0?[]:[gh(t.durationMs)]]}function ya(t,e){let{activity:s,latestStep:i,done:r}=t;if(r)return r.status==="error"?`failed \xB7 ${r.error??"no detail"}`:["completed",...wa(r)].join(" \xB7 ");let n=t.steps.length>0?Di(t.steps):0,o=[...s?[s.activity]:[],...vi(n),...i?[xi(i.usage.totalTokens)]:[]];return o.length===0?"":[...o,...e===void 0?[]:[`${e}s`]].join(" \xB7 ")}function ki(t,e){if(t.status==="failed")return`failed \xB7 ${t.doneError??"no detail"}`;let s=[...vi(Di(t.steps)),...t.usage?[xi(t.usage.totalTokens)]:[],...e===void 0?[]:[`${e}s`]];return[Re(t.status)?t.status:t.activity?.activity??t.status,...s].join(" \xB7 ")}function mh(t,e){return e?.trim()||t.split(Ds).join(" ")}function wh(t){return t.activity==="tool-calling"&&t.toolName?`Calling ${mh(t.toolName,t.toolTitle)}`:t.activity}function yh(t,e){if(t.type==="data-subagent-activity")return wh(e);if(t.type==="data-subagent-step"){let i=e;return[`step ${i.stepIndex+1}`,...vi(i.toolCallCount),xi(i.usage.totalTokens)].join(" \xB7 ")}let s=e;return s.status==="error"?`failed \xB7 ${s.error??"no detail"}`:["completed",...wa(s)].join(" \xB7 ")}function ba(t,e){if(!ph(t))return;let s=t.data;if(typeof s!="object"||s===null)return;let i=yh(t,s),r=s.toolCallId,n=typeof r=="string"?r:"";if(e.get(n)!==i)return e.set(n,i),`sub-agent: ${i}`}function bh(t,e){return t.length<=e?t:t.slice(0,e)+"\u2026"}function Sh(t){return t.split(Ds).join(" ")}function Rr(t){let e=[];for(let s of t.parts){if(va(s)){s.text&&e.push({type:"text",text:s.text});continue}if(Sa(s)){s.text&&e.push({type:"reasoning",text:s.text});continue}xa(s)&&e.push({type:`tool-${Ti(s)}`,input:s.input,output:s.state==="output-error"?s.errorText:s.output,state:s.state==="output-error"?"error":s.state})}return e}function ka(t,e){if(t?.role!=="assistant")return"";let s=t.parts,i=[];for(let r of t.parts){if(va(r)){r.text&&i.push(r.text);continue}if(Sa(r)){r.state==="streaming"&&r.text&&i.push(`${me}[Thinking\u2026]${Q}
|
|
53
|
+
${r.text}`);continue}if(!xa(r))continue;let n=Ti(r)===Fi.SPAWN?e.backgroundRuns?.runs.find(a=>a.toolCallId===r.toolCallId):void 0;if(!n&&(r.state==="output-available"||r.state==="output-error")){i.push(we(Rr({parts:[r]})));continue}let o=[`${At}\u250C\u2500 Tool: ${Sh(Ti(r))}${Q}`];if(r.input!==void 0&&o.push(`${me}\u2502 Input: ${bh(xs(JSON.stringify(r.input)),100)}${Q}`),n){let a=e.startTimes.get(r.toolCallId)??e.now;e.startTimes.set(r.toolCallId,a);let l=Math.floor((e.now-a)/1e3);o.push(`${At}\u2502${Q} (${ki(n.stream,l)})`)}else if(r.state==="input-streaming")o.push(`${At}\u2502${Q} (preparing\u2026)`);else if(r.state==="approval-requested")o.push(`${At}\u2502${Q} (awaiting approval\u2026)`);else if(r.state==="approval-responded"&&!r.approval.approved)o.push(`${ia}\u2502 rejected${Q}`);else{let a=e.startTimes.get(r.toolCallId)??e.now;e.startTimes.set(r.toolCallId,a);let l=Math.floor((e.now-a)/1e3),c=Ti(r)===Fi.SPAWN?ya(ga(s,r.toolCallId),l):"";o.push(c?`${At}\u2502${Q} (${c})`:`${At}\u2502${Q} (executing\u2026 ${l}s)`)}i.push(o.join(`
|
|
54
|
+
`))}return i.join(`
|
|
55
|
+
|
|
56
|
+
`)}import{useSyncExternalStore as vh}from"react";function Ci(t){return vh(t.subscribe,t.getSnapshot)}async function Ch(t,e,s,i,r){let n=new Map;if(e)try{let{messages:o}=await r.getMessages(e.accessToken,e.workspaceId,s,t.length+2);n=new Map(o.map(a=>[a.id,a.parts]))}catch{}return t.map(o=>{let a=n.get(o.id)??Rr(o);return{role:"assistant",content:we(a,i),parts:a}})}function Ta(t){let{taskId:e,setMessages:s,setState:i,setCurrentResponse:r,setHasPersistedTask:n}=t,o=Kt(t);o.current=t;let a=Kt(new Set),l=Kt(new Set),c=Kt(new Set),p=Kt(new Set),u=Kt(new Map);Fe(()=>{a.current=new Set,l.current=new Set,c.current=new Set,p.current=new Set,u.current=new Map},[e]);let[d,g]=Ei(!1),f=Ke(_=>o.current.localTools&&ms(Ar(_)),[]),y=Kt(null),[{transport:b,apiClient:v}]=Ei(()=>{let _=new ht;return{apiClient:_,transport:new Ye({resolveCredentials:async()=>{let F=await qt(),U=o.current.credentials;if(!U)return o.current.setCredentials(F),F;let K={accessToken:F.accessToken,workspaceId:U.workspaceId};return F.accessToken!==U.accessToken&&o.current.setCredentials(K),K},resolveTaskConfig:()=>{let F=o.current;return Si({agentId:F.currentAgentId,model:F.currentModel,connectorIds:F.activeConnectorIds,clientTools:F.localTools?oi():void 0,clientToolSystemPrompt:F.localTools?ai():void 0,toolApprovalMode:F.toolApprovalMode})},sendTask:(F,U)=>_.task(F.accessToken,F.workspaceId,U),onToolPartsSubmitted:F=>{for(let U of F)p.current.add(U)},onChunk:F=>y.current?.ingestChunk(F)})}}),S=Ke(()=>bi({openRunEvents:async(_,F)=>{let U=await qt();return v.openSubagentRunEvents(U.accessToken,U.workspaceId,_,F)},getRun:async(_,F)=>{let U=await qt();return v.getSubagentRun(U.accessToken,U.workspaceId,_,F)}}),[v]),[k,E]=Ei(S),P=Kt(e);y.current=k,Fe(()=>{P.current!==e&&(P.current=e,E(S()))},[e,S]),Fe(()=>()=>k.dispose(),[k]);let H=Ci(k),$=xh({id:e,transport:b,generateId:Th,experimental_throttle:100,sendAutomaticallyWhen:_=>Qe({messages:_.messages,isClientTool:f,submittedToolCallIds:p.current}),onError:_=>{if(g(!1),_ instanceof _e&&_.code==="not-logged-in"){o.current.setState({status:"not-logged-in"});return}if(_ instanceof _e&&_.code==="no-workspace"){o.current.setState({status:"no-workspace"});return}o.current.setState({status:"error",message:_.message||"Failed to send message"})}}),A=Kt($);A.current=$;let m=Kt(!1);Fe(()=>{($.status==="submitted"||$.status==="streaming")&&(m.current=!0)},[$.status]);let N=$.messages.some(_=>_.role==="assistant"&&!c.current.has(_.id)&&_.parts.some(F=>kh(F)&&(F.state==="input-available"||F.state==="approval-responded"&&F.approval.approved))),[tt,vt]=Ei(0);Fe(()=>{if(!d||!N)return;let _=setInterval(()=>vt(F=>F+1),1e3);return()=>clearInterval(_)},[d,N]),Fe(()=>{if(!d)return;let _=$.messages.filter(K=>K.role==="assistant"&&!c.current.has(K.id));if(_.length===0)return;let F=Date.now(),U=_.map(K=>ka(K,{now:F,startTimes:u.current,backgroundRuns:H})).filter(Boolean).join(`
|
|
57
|
+
|
|
58
|
+
`);r(U)},[$.messages,tt,d,r,H]);let M=Ke(_=>{g(!1),o.current.setState({status:"error",message:_ instanceof Error?_.message:String(_)})},[]),B=Ke(async _=>{let{onApprovalRequest:F}=o.current,U=F?await F(_):new Map;for(let K of _){let rt=U.get(K.approvalId)===!0;await A.current.addToolApprovalResponse({id:K.approvalId,approved:rt,...rt?{}:{reason:"Rejected by user."}})}},[]),G=Ke(async(_,F)=>{let U;try{U=await li(_,F.input??{})}catch(K){await A.current.addToolOutput({tool:_,toolCallId:F.toolCallId,state:"output-error",errorText:K instanceof Error?K.message:String(K)});return}await A.current.addToolOutput({tool:_,toolCallId:F.toolCallId,state:"output-available",output:{content:ci(U),isError:!U.success}})},[]);return Fe(()=>{if(!d||$.status!=="ready"||!m.current)return;let _=$.messages.at(-1);if(_?.role!=="assistant")return;let F=Fs(_),U=[];for(let W of F)W.state==="approval-requested"&&(l.current.has(W.approval.id)||(l.current.add(W.approval.id),U.push({approvalId:W.approval.id,toolCallId:W.toolCallId,toolName:Ar(W),input:W.input??{}})));U.length>0&&B(U).catch(M);for(let W of F){if(!f(W))continue;let Pt=W.state==="approval-responded"&&!W.approval.approved,yt=W.state==="input-available"||W.state==="approval-responded"&&W.approval.approved;if(!Pt&&!yt||a.current.has(W.toolCallId))continue;a.current.add(W.toolCallId);let V=Ar(W);if(Pt){Promise.resolve(A.current.addToolOutput({tool:V,toolCallId:W.toolCallId,state:"output-error",errorText:"Tool execution rejected by user."})).catch(M);continue}G(V,W).catch(M)}let K=F.some(W=>W.state==="approval-requested"),rt=F.some(W=>f(W)&&(W.state==="input-available"||W.state==="approval-responded"));if(K||rt||Qe({messages:$.messages,isClientTool:f,submittedToolCallIds:p.current}))return;g(!1),m.current=!1;let Tt=$.messages.filter(W=>W.role==="assistant"&&!c.current.has(W.id));for(let W of Tt)c.current.add(W.id);(async()=>{if(Tt.length>0){let W=await Ch(Tt,o.current.credentials,o.current.taskId,o.current.fullOutput,v);s(Pt=>[...Pt,...W])}r(""),i({status:"ready"}),n(!0)})().catch(M)},[$.messages,$.status,d,f,B,G,M,v,s,r,i,n]),{sendMessage:Ke(async _=>{s(U=>[...U,{role:"user",content:_}]),i({status:"sending"}),r(""),m.current=!1,g(!0);let F=o.current.getFileIds?.()??[];A.current.sendMessage({text:_},F.length>0?{body:{fileIds:F}}:void 0).then(()=>{F.length>0&&o.current.clearFiles?.()}).catch(M)},[s,i,r,M]),backgroundRuns:k}}import{useState as Eh}from"react";var Ca=new Map([["sandbox","Sandbox"],["web_search","Web Search"],["image_generation","Image Generation"],["chart","Chart"],["file_system","FileSystem"]]);function Ea(t){let[e,s]=Eh(t);return{fileSystem:e,setFileSystem:s,capabilityLabelMap:Ca}}import{useEffect as Rh,useState as Ah}from"react";function Ra(t,e){let[s,i]=Ah(null);return Rh(()=>{let r=!1;async function n(){if(!t||!e){i(null);return}try{let a=await new ht().getAgent(e.accessToken,e.workspaceId,t);r||i(a)}catch{r||i(null)}}return n(),()=>{r=!0}},[t,e]),{currentAgentDetails:s}}import{useState as _r}from"react";function Aa(t,e,s){let[i,r]=_r(t),[n,o]=_r(e),[a,l]=_r(s);return{currentModel:i,setCurrentModel:r,currentAgentId:n,setCurrentAgentId:o,activeConnectorIds:a,setActiveConnectorIds:l}}import{useApp as Ph,useInput as $h}from"ink";import{useCallback as ae,useRef as Ih,useState as _t}from"react";import{spawn as _h}from"child_process";function _a(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 Pa=[{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 $a(t){if(!t.startsWith("/"))return[];let e=t.slice(1).toLowerCase();return e?Pa.filter(s=>s.name.startsWith(e)||s.aliases.some(i=>i.startsWith(e))):Pa}function Ia(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 Ma=`Available commands:
|
|
59
|
+
/help, /h, /? Show this help message
|
|
60
|
+
/clear, /cls, /new Start a new task
|
|
61
|
+
/model [name], /m Show current model or switch to [name]
|
|
62
|
+
/agent [name], /a Show current agent or switch to [name]
|
|
63
|
+
/skills [name], /sk List skills or show details for [name]
|
|
64
|
+
/schedules [id], /sch List schedules or show details for [id]
|
|
65
|
+
/connectors, /conn Select active connectors
|
|
66
|
+
/capabilities, /cap Toggle client capabilities (FileSystem)
|
|
67
|
+
/approval Choose when tool calls need your approval
|
|
68
|
+
/tasks, /c Switch to another task
|
|
69
|
+
/workspace [id], /ws List or switch workspace
|
|
70
|
+
/budget [amount], /bg View or set workspace budget
|
|
71
|
+
/usage, /u View current month usage (top 10 by cost)
|
|
72
|
+
/status, /s Show current session status
|
|
73
|
+
/profile [args], /p Manage profiles (list/show/use/create/delete/rename/clone)
|
|
74
|
+
/open-in-browser Open current task in browser
|
|
75
|
+
/share Get share link for current task
|
|
76
|
+
/delete, /del Delete current task
|
|
77
|
+
/quit, /exit, /q Exit interactive mode
|
|
78
|
+
|
|
79
|
+
Note: For detailed usage with sorting/limits, use: entrydesk usage --help
|
|
80
|
+
|
|
81
|
+
Keyboard shortcuts:
|
|
82
|
+
Ctrl+O Toggle full output mode
|
|
83
|
+
Ctrl+C Exit`;function Fa(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 Da({input:t,setInput:e,taskId:s,setTaskId:i,currentTaskTitle:r,setCurrentTaskTitle:n,currentModel:o,setCurrentModel:a,currentAgentId:l,setCurrentAgentId:c,currentAgentDetails:p,setCurrentAgentDetails:u,activeConnectorIds:d,setActiveConnectorIds:g,fileSystem:f,setFileSystem:y,toolApprovalMode:b,setToolApprovalMode:v,availableModels:S,availableAgents:k,availableConnectors:E,messages:P,hasPersistedTask:H,setHasPersistedTask:$,setMessages:A,addSystemMessage:m,startNewTask:N,sendMessage:tt,setFullOutput:vt,credentials:M,setCredentials:B,setState:G,defaultCapabilities:Z,capabilityLabelMap:_,hasUploadingFiles:F=!1}){let{exit:U}=Ph(),[K,rt]=_t([]),[Tt,W]=_t(0),[Pt,yt]=_t(!1),[V,lt]=_t(null),[C,D]=_t([]),[Y,J]=_t(0),[Jt,ce]=_t(new Set),[De,ye]=_t(new Set),[be,Je]=_t([]),[ue,Ps]=_t([]),[Zt,Oe]=_t([]),[Se,$s]=_t([]),[Qt,he]=_t(null),[Is,ve]=_t(""),Le=Ih(!1),[te,xe]=_t(!1),ke=ae(async()=>{if(!M)return[];let R=new ht,x=[],h;do{let w=await R.listAvailableSkills(M.accessToken,M.workspaceId,{limit:100,nextKey:h});x.push(...w.skills),h=w.nextKey}while(h);return Ps(x),x},[M]),Te=ae(async()=>{if(!M)return[];let R=new ht,x=[],h;do{let w=await R.getSchedules(M.accessToken,M.workspaceId,{limit:100,nextKey:h});x.push(...w.schedules),h=w.nextKey}while(h);return Oe(x),x},[M]),bt=ae(async R=>{if(R==="model"){if(S.length===0){m("No models available.");return}let x=S.map(w=>({id:w.id,name:w.name,description:w.description}));D(x);let h=o?x.findIndex(w=>w.id===o):-1;J(Math.max(h,0)),lt("model")}else if(R==="agent"){if(k.length===0){m("No agents available.");return}let x=k.map(w=>({id:w.id,name:w.name,description:w.description}));D(x);let h=l?x.findIndex(w=>w.id===l):-1;J(Math.max(h,0)),lt("agent")}else if(R==="skills"){let x=ue;if(x.length===0)try{x=await ke()}catch{m("Failed to load skills.");return}if(x.length===0){m("No skills available.");return}let h=x.map(w=>({id:w.id,name:w.name,description:w.description}));D(h),J(0),lt("skills")}else if(R==="schedules"){let x=Zt;if(x.length===0)try{x=await Te()}catch{m("Failed to load schedules.");return}if(x.length===0){m("No schedules found.");return}let h=x.map(w=>({id:w.id,name:w.name,description:`${w.agent.name} - ${w.isActive?"Active":"Paused"}`}));D(h),J(0),lt("schedules")}else if(R==="connectors"){if(E.length===0){m("No connectors available.");return}let x=E.map(h=>({id:h.id,name:h.name}));D(x),J(0),ce(new Set(d)),lt("connectors")}else if(R==="capabilities"){D([{id:"fileSystem",name:"FileSystem",description:"Local file operations"}]),J(0);let h=new Set;f&&h.add("fileSystem"),ye(h),lt("capabilities")}else if(R==="approval"){let x=Object.values(Be);D(x.map(h=>({id:h,name:je[h],description:h===b?`${ts[h]} (current)`:ts[h]}))),J(Math.max(0,x.indexOf(b))),lt("approval")}else if(R==="tasks"){if(!M){m("Not logged in.");return}try{let x=new ht,{tasks:h}=await x.getTasks(M.accessToken,M.workspaceId,20);if(h.length===0){m("No tasks available.");return}Je(h);let w=h.map(L=>({id:L.id,name:L.title||"Untitled",description:new Date(L.createdAt).toLocaleDateString()}));D(w);let T=w.findIndex(L=>L.id===s);J(Math.max(T,0)),lt("tasks")}catch{m("Failed to load tasks.")}}else if(R==="profile"){let x=ot.getProfileNames(),h=ot.getCurrentProfileName(),w=x.map(L=>({id:L,name:L,description:L===h?"(current)":void 0}));D(w);let T=w.findIndex(L=>L.id===h);J(Math.max(T,0)),lt("profile")}yt(!1),rt([])},[S,k,ue,Zt,E,d,o,l,f,b,ke,Te,M,s,m]),ee=ae(R=>{let x=at.getAll(R);a(x.model?.default),c(void 0),u(null);let h=x.connectors?.defaults;g(h&&h.length>0?h:void 0);let w=x.localTools;y(w?.fileSystem??Z.fileSystem),v(x.toolApprovalMode??Ee)},[a,c,u,g,y,v,Z]),Ce=ae(async()=>{try{let R=await qt();B({accessToken:R.accessToken,workspaceId:R.workspaceId}),G({status:"ready"})}catch(R){if(B(null),R instanceof _e){if(R.code==="not-logged-in"){G({status:"not-logged-in"});return}if(R.code==="no-workspace"){G({status:"no-workspace"});return}}let x=R instanceof Error?R.message:"Authentication failed";G({status:"error",message:x})}},[B,G]),Ne=ae(async R=>{switch(R.type){case"help":return m(Ma),!0;case"clear":return N("Started a new task."),!0;case"model":if(R.value){let x=R.value.toLowerCase(),h=S.find(w=>w.id.toLowerCase()===x||w.name.toLowerCase().includes(x));if(h)l?N(`Switched to model: ${h.name} (new task)`):m(`Switched to model: ${h.name}`),a(h.id),c(void 0),u(null),at.setDefaultModel(h.id);else{let w=S.map(T=>T.name).join(", ");m(`Model "${R.value}" not found.
|
|
84
|
+
Available: ${w||"none"}`)}}else{let x=S.find(h=>h.id===o)?.name||o;m(o?`Current model: ${x}`:"No model selected. Using agent mode.")}return!0;case"agent":{if(!R.value)return k.length===0?(m("No agents available."),!0):(bt("agent"),!0);let x=R.value.toLowerCase(),h=k.find(w=>w.id.toLowerCase()===x||w.name.toLowerCase().includes(x));if(h)h.id===l?m(`Switched to agent: ${h.name}`):N(`Switched to agent: ${h.name} (new task)`),c(h.id),a(void 0);else{let w=k.map(T=>T.name).join(", ");m(`Agent "${R.value}" not found.
|
|
85
|
+
Available: ${w||"none"}`)}return!0}case"skills":{if(!R.value)return bt("skills"),!0;let x=R.value.toLowerCase();return(ue.length>0?Promise.resolve(ue):ke().catch(()=>[])).then(w=>{let T=w.find(L=>L.id.toLowerCase()===x||L.name.toLowerCase().includes(x));m(T?`Skill: ${T.name}
|
|
86
|
+
${T.description}
|
|
87
|
+
Provider: ${T.provider}
|
|
88
|
+
Author: ${T.author.name}
|
|
89
|
+
ID: ${T.id}`:`Skill "${R.value}" not found.`)}),!0}case"schedules":{if(!R.value)return bt("schedules"),!0;let x=R.value.toLowerCase();return(Zt.length>0?Promise.resolve(Zt):Te().catch(()=>[])).then(w=>{let T=w.find(L=>L.id.toLowerCase()===x||L.name.toLowerCase().includes(x));if(T){let L=T.nextRunAt?new Date(T.nextRunAt).toLocaleString():"-";m(`Schedule: ${T.name}
|
|
90
|
+
Agent: ${T.agent.name}
|
|
91
|
+
Status: ${T.isActive?"Active":"Paused"}
|
|
92
|
+
Repeat: ${Fa(T.config)}
|
|
93
|
+
Next run: ${L}
|
|
94
|
+
ID: ${T.id}`)}else m(`Schedule "${R.value}" not found.`)}),!0}case"connectors":{if(l){let h=p?.connectors??[];if(h.length===0)m("No agent connectors.");else{let w=h.map(T=>` - ${T.name}`).join(`
|
|
95
|
+
`);m(`Agent connectors:
|
|
96
|
+
${w}`)}return!0}let x=E.filter(h=>d?.includes(h.id));if(x.length===0)m("No active connectors.");else{let h=x.map(w=>` - ${w.name}`).join(`
|
|
97
|
+
`);m(`Active connectors:
|
|
98
|
+
${h}`)}return!0}case"capabilities":{if(l){let w=(p?.capabilities??[]).map(T=>_.get(T)??T);return m(w.length>0?`Agent capabilities:
|
|
99
|
+
${w.map(T=>` - ${T}`).join(`
|
|
100
|
+
`)}`:"No agent capabilities."),!0}let x=[];return f&&x.push("FileSystem"),m(x.length>0?`Active capabilities:
|
|
101
|
+
${x.map(h=>` - ${h}`).join(`
|
|
102
|
+
`)}`:"No capabilities enabled."),!0}case"approval":return m(`Tool approval: ${je[b]} \u2014 ${ts[b]}`),!0;case"tasks":return m(r?`Current task: ${r}`:`Current task: ${s.slice(0,8)}\u2026`),!0;case"workspace":{if(!M)return m("Not logged in."),!0;let x=new ht;if(!R.value){try{let{workspaces:w}=await x.getWorkspaces(M.accessToken);if(w.length===0)m("No workspaces found.");else{let T=w.map(L=>` ${L.id===M.workspaceId?"* ":" "}${L.name}
|
|
103
|
+
ID: ${L.id}`);m(`Workspaces:
|
|
104
|
+
${T.join(`
|
|
105
|
+
`)}`)}}catch(w){m(`Failed to load workspaces: ${w instanceof Error?w.message:"Unknown error"}`)}return!0}let h=R.value;try{let{workspaces:w}=await x.getWorkspaces(M.accessToken),T=w.find(L=>L.id===h);if(!T)return m(`Workspace not found: ${h}`),!0;await Ae.saveWorkspaceId(h),m(`Switched to workspace: ${T.name}`),m("Restart the task to apply the change.")}catch(w){m(`Failed to switch workspace: ${w instanceof Error?w.message:"Unknown error"}`)}return!0}case"budget":{if(!M)return m("Not logged in."),!0;let x=new ht;if(!R.value){try{let T=await x.getBudget(M.accessToken,M.workspaceId);T.budget===null?m("No budget set for this workspace."):m(`Current budget: $${T.budget}`)}catch(T){m(`Failed to get budget: ${T instanceof Error?T.message:"Unknown error"}`)}return!0}let h=R.value.toLowerCase();if(h==="clear"||h==="null"){try{await x.updateBudget(M.accessToken,M.workspaceId,null),m("Budget cleared.")}catch(T){m(`Failed to clear budget: ${T instanceof Error?T.message:"Unknown error"}`)}return!0}let w=Number.parseFloat(h);if(Number.isNaN(w)||w<0)return m("Invalid budget amount. Must be a positive number."),!0;try{await x.updateBudget(M.accessToken,M.workspaceId,h),m(`Budget set to: $${h}`)}catch(T){m(`Failed to set budget: ${T instanceof Error?T.message:"Unknown error"}`)}return!0}case"usage":{if(!M)return m("Not logged in."),!0;let x=new ht;try{let h=[],w,T=0,L=10;do{let ut=await x.getMonthlyUsages(M.accessToken,M.workspaceId,{nextKey:w,limit:20});if(h.push(...ut.monthlyUsages),w=ut.nextKey,T++,T>=L){m(`Warning: Showing first ${h.length} entries (pagination limit reached)`);break}}while(w);if(h.length===0)return m("No usage data found for this workspace."),!0;let et=0,nt=0;for(let ut of h)et+=Number.parseFloat(ut.totalCost),nt+=ut.operationCount;let It=[...h].toSorted((ut,I)=>Number.parseFloat(I.totalCost)-Number.parseFloat(ut.totalCost)),z=10,it=It.slice(0,z),xt=[`Total cost: $${et.toFixed(2)}`,`Total operations: ${nt.toLocaleString()}`,`Users: ${h.length}`,"",`Top ${it.length} users by cost:`,...it.map(ut=>` ${ut.user.name}: $${Number.parseFloat(ut.totalCost).toFixed(2)} (${ut.operationCount.toLocaleString()} ops)`)];h.length>z&&(xt.push("",`\u2026 and ${h.length-z} more users`),xt.push("For the full list: entrydesk usage --limit <n> --sort-by <cost|operations>")),m(xt.join(`
|
|
106
|
+
`))}catch(h){m(`Failed to get usage: ${h instanceof Error?h.message:"Unknown error"}`)}return!0}case"status":{let x=ot.getCurrentProfileName(),h=o?S.find(et=>et.id===o)?.name||o:null,w=l?k.find(et=>et.id===l)?.name||l:null,T=wi({agentId:l,agentDetails:p,activeConnectorIds:d,availableConnectors:E}),L=[];return f&&L.push("FileSystem"),Ae.getEmail().then(et=>{let nt=[`Profile: ${x}${x==="default"?"":" (non-default)"}`,et?`Logged in as: ${et}`:"Not logged in",M?.workspaceId?`Workspace: ${M.workspaceId}`:null,H?`Task ID: ${s}`:null,h?`Model: ${h}`:null,w?`Agent: ${w}`:null,`Connectors: ${T}`,`Capabilities: ${L.length>0?L.join(", "):"none"}`].filter(Boolean);m(nt.join(`
|
|
107
|
+
`))}).catch(()=>{let et=[`Profile: ${x}`,"Not logged in",H?`Task ID: ${s}`:null,h?`Model: ${h}`:null,w?`Agent: ${w}`:null,`Connectors: ${T}`,`Capabilities: ${L.length>0?L.join(", "):"none"}`].filter(Boolean);m(et.join(`
|
|
108
|
+
`))}),!0}case"profile":{let x=R.value?R.value.split(/\s+/).filter(Boolean):[];if(x.length===0)return bt("profile"),!0;let h=x[0]?.toLowerCase()||"list",w=x[1],T=x[2],L=ot.getProfileNames(),et=ot.getCurrentProfileName(),nt=ot.getOverrideProfile(),It=(z,it=!1)=>{if(z)return z;if(it&&L.length===1)return L[0];throw new Error("Profile name is required when multiple profiles exist.")};try{if(h==="list"){let z=[`Profiles (${L.length}):`];for(let it of L){let xt=it===et?" (current)":"";z.push(` ${it}${xt}`)}return m(z.join(`
|
|
109
|
+
`)),!0}if(h==="current")return m(`Current profile: ${et}`),!0;if(h==="show"){let z=It(w,!0),it=at.getAll(z),xt=await Ae.getAll(z),ut=!!xt?.accessToken,I=it.connectors?.defaults&&it.connectors.defaults.length>0?it.connectors.defaults.join(", "):"unset",q=[`Profile: ${z}${z===et?" (current)":""}`,`API URL: ${it.apiUrl??"default"}`,`Hub URL: ${it.hubUrl??"default"}`,`Model: ${it.model?.default??"unset"}`,`Connectors: ${I}`,ut?`Logged in as: ${xt?.email??"unknown"}`:"Not logged in",ut&&xt?.workspaceId?`Workspace ID: ${xt.workspaceId}`:null].filter(Boolean);return m(q.join(`
|
|
110
|
+
`)),!0}if(h==="create"){let z=w||ot.DEFAULT_PROFILE;return ot.createProfile(z),m(`Profile created: ${z}`),!0}if(h==="use"||h==="switch"){let z=It(w,!0);return ot.setOverrideProfile(z),ot.setCurrentProfile(z),ee(z),await Ce(),N(`Switched to profile: ${z} (new task)`),!0}if(h==="delete"||h==="remove"||h==="rm"){let z=It(w,!0),it=z===et,xt=ot.deleteProfile(z);await Ae.deleteProfileCredentials(z);let ut=`Profile deleted: ${z}`;if(it)ot.setOverrideProfile(xt.currentProfile),ee(xt.currentProfile),await Ce(),N(`${ut}
|
|
111
|
+
Switched to profile: ${xt.currentProfile} (new task)`);else if(nt===z){let I=ot.getCurrentProfileName();ot.setOverrideProfile(I),ee(I),await Ce(),N(`${ut}
|
|
112
|
+
Switched to profile: ${I} (new task)`)}else m(ut);return!0}if(h==="rename"||h==="move"||h==="mv"){let z=It(w,!0);if(!T)throw new Error("New profile name is required.");let it=ot.renameProfile(z,T);return await Ae.moveProfileCredentials(z,T),m(`Profile renamed: ${z} -> ${T}`),nt===z?(ot.setOverrideProfile(T),ee(T)):it.currentProfile===T&&ee(T),!0}if(h==="clone"||h==="copy"){let z=It(w,!0);if(!T)throw new Error("Target profile name is required.");let it=at.getAll(z);return ot.createProfile(T),at.setAll(it,T),await Ae.clear(T),m(`Profile cloned: ${z} -> ${T}`),!0}m(`Unknown profile command: ${h}`)}catch(z){let it=z instanceof Error?z.message:"Unknown error";m(`Profile error: ${it}`)}return!0}case"open-in-browser":{let x=Oi().hubUrl.replace(/\/$/,""),h=H||P.some(nt=>nt.role!=="system"),w=M?`/${M.workspaceId}`:"",T=h?`${w}/task/${s}`:`${w}/task/new`,L=l?`?agentId=${encodeURIComponent(l)}`:"",et=`${x}${T}${L}`;try{await _a(et),m(`Opened in browser: ${et}`)}catch(nt){m(`Failed to open browser: ${nt instanceof Error?nt.message:"Unknown error"}
|
|
113
|
+
URL: ${et}`)}return!0}case"share":{if(!M)return m("Not logged in."),!0;if(!(H||P.some(h=>h.role!=="system")))return m("No task to share. Start a task first."),!0;try{let w=await new ht().createTaskShare(M.accessToken,M.workspaceId,s,"public"),L=`${Oi().hubUrl.replace(/\/$/,"")}/share/${w.id}`;m(`Share link: ${L}`)}catch(h){m(`Failed to create share link: ${h instanceof Error?h.message:"Unknown error"}`)}return!0}case"delete":return M?H?(xe(!0),m("Delete this task? [y/N]"),!0):(m("No task to delete."),!0):(m("Not logged in."),!0);case"quit":return U(),!0;case"unknown":return m(`Unknown command: ${R.input}
|
|
114
|
+
Type /help for available commands.`),!0;default:return!1}},[m,S,k,E,ue,Zt,o,l,d,f,s,r,U,bt,N,_,p,H,P,ke,Te,A,a,c,u,a,ee,Ce]),Ze=ae(R=>{if(Le.current=!1,te){(R===""||R.startsWith("/"))&&(e(R),R.startsWith("/")&&xe(!1));return}if(e(R),ve(R),Qt!==null&&he(null),V&&(lt(null),D([])),R.startsWith("/")&&!R.includes(" ")){let x=$a(R);rt(x),W(0),yt(x.length>0)}else yt(!1),rt([])},[V,Qt,te,e]),St=ae((R,x=!1)=>{if(R>=0&&R<K.length){let h=K[R];yt(!1),rt([]),h.name==="model"?(e("/model "),bt("model")):h.name==="agent"?(e("/agent "),bt("agent")):h.name==="skills"?(e("/skills "),bt("skills")):h.name==="schedules"?(e("/schedules "),bt("schedules")):h.name==="connectors"?(e("/connectors "),bt("connectors")):h.name==="capabilities"?(e("/capabilities "),bt("capabilities")):h.name==="approval"?(e("/approval "),bt("approval")):h.name==="tasks"?(e("/tasks "),bt("tasks")):h.name==="profile"?(e("/profile "),bt("profile")):x?(e(""),Ne({type:h.name})):e(`/${h.name}`)}},[K,bt,e,Ne]),Ii=ae(async R=>{Le.current=!1;let x=R.trim();if(!x||te)return;if(Pt&&K.length>0){St(Tt,!0);return}he(null),ve(""),$s(w=>w.length>0&&w.at(-1)===x?w:[...w,x]);let h=Ia(x);if(h){await Ne(h),e(""),yt(!1);return}if(F){m("Wait for the uploads to finish.");return}e(""),yt(!1),tt(x)},[tt,Ne,Pt,K,Tt,St,m,e,F,te,M,H,s]);return $h((R,x)=>{if(x.ctrl&&R==="c"){if(t.length>0){Ze(""),Le.current=!0,m("Press Ctrl+C again to exit.");return}if(Le.current){U();return}U();return}if(x.ctrl&&R==="o"){vt(h=>!h);return}if(te){if(x.escape||x.return||R==="n"||R==="N"){xe(!1),e(""),m("Task deletion canceled.");return}if(R==="y"||R==="Y"){xe(!1),e(""),M&&H&&new ht().deleteTask(M.accessToken,M.workspaceId,s).then(()=>{N("Task deleted. Started a new task.")}).catch(w=>{m(`Failed to delete task: ${w.message||"Unknown error"}`)});return}return}if(V&&C.length>0){if(x.upArrow){J(h=>h<=0?C.length-1:h-1);return}if(x.downArrow){J(h=>h>=C.length-1?0:h+1);return}if(x.escape){lt(null),D([]),e("");return}if(x.return){if(V==="model"){let h=C[Y];h&&(l?N(`Switched to model: ${h.name} (new task)`):m(`Switched to model: ${h.name}`),a(h.id),c(void 0),u(null),at.setDefaultModel(h.id))}else if(V==="agent"){let h=C[Y];h&&(h.id===l?m(`Switched to agent: ${h.name}`):N(`Switched to agent: ${h.name} (new task)`),c(h.id),a(void 0))}else if(V==="skills"){let h=C[Y];if(h){let w=ue.find(T=>T.id===h.id);w&&m(`Skill: ${w.name}
|
|
115
|
+
${w.description}
|
|
116
|
+
Provider: ${w.provider}
|
|
117
|
+
Author: ${w.author.name}
|
|
118
|
+
ID: ${w.id}`)}}else if(V==="schedules"){let h=C[Y];if(h){let w=Zt.find(T=>T.id===h.id);if(w){let T=w.nextRunAt?new Date(w.nextRunAt).toLocaleString():"-";m(`Schedule: ${w.name}
|
|
119
|
+
Agent: ${w.agent.name}
|
|
120
|
+
Status: ${w.isActive?"Active":"Paused"}
|
|
121
|
+
Repeat: ${Fa(w.config)}
|
|
122
|
+
Next run: ${T}
|
|
123
|
+
ID: ${w.id}`)}}}else if(V==="connectors"){let h=[...Jt];g(h.length>0?h:void 0),at.setDefaultConnectorIds(h);let w=E.filter(T=>Jt.has(T.id)).map(T=>T.name);m(w.length>0?`Active connectors: ${w.join(", ")}`:"No connector selected \u2014 every connected connector is available.")}else if(V==="capabilities"){let h=De.has("fileSystem");y(h),at.setLocalTools({fileSystem:h});let w=[];h&&w.push("FileSystem"),m(w.length>0?`Active capabilities: ${w.join(", ")}`:"All capabilities disabled.")}else if(V==="approval"){let h=C[Y];if(h){let w=h.id;v(w),at.setToolApprovalMode(w),m(`Tool approval: ${je[w]} \u2014 ${ts[w]}`)}}else if(V==="tasks"){let h=C[Y];if(h){let w=be.find(T=>T.id===h.id);w&&M&&(i(w.id),n(w.title||void 0),$(!0),new ht().getMessages(M.accessToken,M.workspaceId,w.id,20).then(({messages:L})=>{let et=L.filter(nt=>nt.role==="user"||nt.role==="assistant").map(nt=>({role:nt.role,content:we(nt.parts,!1),parts:nt.parts})).filter(nt=>nt.content).toReversed();A(et),m(`Switched to: ${w.title||"Untitled"}`)}).catch(()=>{m("Failed to load task messages.")}))}}else if(V==="profile"){let h=C[Y];if(h){let w=ot.getCurrentProfileName();h.id===w?m(`Already using profile: ${h.name}`):(ot.setOverrideProfile(h.id),ot.setCurrentProfile(h.id),ee(h.id),Ce(),N(`Switched to profile: ${h.name}`))}}lt(null),D([]),e("");return}if(R===" "&&(V==="connectors"||V==="capabilities")){let h=C[Y];h&&(V==="connectors"?ce:ye)(T=>{let L=new Set(T);return L.has(h.id)?L.delete(h.id):L.add(h.id),L});return}if(R==="a"&&(V==="connectors"||V==="capabilities")){(V==="connectors"?ce:ye)(new Set(C.map(w=>w.id)));return}if(R==="n"&&(V==="connectors"||V==="capabilities")){(V==="connectors"?ce:ye)(new Set);return}return}if(Pt&&K.length>0){if(x.upArrow){W(h=>h<=0?K.length-1:h-1);return}if(x.downArrow){W(h=>h>=K.length-1?0:h+1);return}if(x.escape){yt(!1),rt([]);return}if(x.tab){St(Tt);return}}if(x.upArrow){if(t.includes(`
|
|
124
|
+
`)||Se.length===0)return;if(Qt===null){ve(t);let w=Se.length-1;he(w),e(Se[w]);return}let h=Math.max(0,Qt-1);he(h),e(Se[h]);return}if(x.downArrow){if(t.includes(`
|
|
125
|
+
`)||Qt===null)return;if(Qt>=Se.length-1){he(null),e(Is);return}let h=Qt+1;he(h),e(Se[h])}}),{suggestions:K,suggestionIndex:Tt,showSuggestions:Pt,argMode:V,argItems:C,argIndex:Y,selectedConnectorIds:Jt,selectedCapabilities:De,deleteConfirmMode:te,handleInputChange:Ze,handleSubmit:Ii}}import{useCallback as Es,useRef as Mh,useState as Fh}from"react";function Oa({credentials:t,currentModel:e,modelProviders:s,onUploadSuccess:i,onUploadError:r}){let[n,o]=Fh([]),a=Mh(0),l=Es(y=>{if(!(!Array.isArray(s)||s.length===0)){for(let b of s)if(b.models.some(S=>S.id===y))return b.id;return s[0]?.id}},[s]),c=Es(async y=>{if(!t){r?.(y.filename,"Not logged in");return}if(!Array.isArray(s)||s.length===0){r?.(y.filename,"Model providers are still loading. Try again in a moment.");return}let b=e?l(e):s[0]?.id;if(!b){r?.(y.filename,"No model provider available");return}let v=`file-${++a.current}`;o(S=>[...S,{id:v,filename:y.filename,mimeType:y.mimeType,status:"uploading"}]);try{let k=await new ht().uploadFile(t.accessToken,t.workspaceId,y,b);o(E=>E.map(P=>P.id===v?{...P,status:"uploaded",fileId:k.id}:P)),i?.(y.filename)}catch(S){let k=S instanceof Error?S.message:"Upload failed";o(E=>E.map(P=>P.id===v?{...P,status:"error",error:k}:P)),r?.(y.filename,k)}},[t,e,l,s,i,r]),p=Es(y=>{o(b=>b.filter(v=>v.id!==y))},[]),u=Es(()=>{o([])},[]),d=Es(()=>n.filter(y=>y.status==="uploaded").map(y=>y.fileId).filter(Fr),[n]),g=n.some(y=>y.status==="uploading"),f=n.length>0;return{pendingFiles:n,addFile:c,removeFile:p,clearFiles:u,getUploadedFileIds:d,hasUploadingFiles:g,hasFiles:f}}import{jsx as j,jsxs as X}from"react/jsx-runtime";var Dh=[" ______ _ ____ _","| ____| | | | _ \\ | |","| |__ _ __ | |_ _ __ _ _ | | | | ___ ___| | __","| __| | '_ \\| __| '__| | | || | | |/ _ \\/ __| |/ /","| |____| | | | |_| | | |_| || |_| | __/\\__ \\ <","|______|_| |_|\\__|_| \\__, ||____/ \\___||___/_|\\_\\"," __/ |"," |___/"],Oh=[Cr,Cr,Tr,Tr,Me,Me,Me,Me],La=Dh.map((t,e)=>`${Oh[e]??Me}${t}${Q}`).join(`
|
|
126
|
+
`),Lh=`${Me}EntryDesk${Q}`,Nh=500;function Bh(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 jh(t){let e=Bh(t);return Math.max(...e.split(`
|
|
127
|
+
`).map(s=>s.length))}function Uh(t){let e=jh(La);return t>=e?La:Lh}function Na({agentId:t,model:e,message:s,taskId:i,taskTitle:r,connectorIds:n,enableFileSystem:o=!0,toolApprovalMode:a=Ee}){let[l,c]=$r(a),[p,u]=$r([]),d=As(null),g=As(new Map),f=Ri(I=>(g.current=new Map,u(I),new Promise(q=>{d.current=q})),[]),y=process.stdout.columns??80,b=Uh(y),v=As(null),S=na(i,r),{state:k,setState:E,messages:P,setMessages:H,input:$,setInput:A,taskId:m,setTaskId:N,currentTaskTitle:tt,setCurrentTaskTitle:vt,hasPersistedTask:M,setHasPersistedTask:B,credentials:G,setCredentials:Z,currentResponse:_,setCurrentResponse:F,fullOutput:U,setFullOutput:K,addSystemMessage:rt,startNewTask:Tt}=S,{credentials:W}=aa(E);Ai(()=>{W&&!G&&Z(W)},[W,G,Z]);let{availableConnectors:Pt,availableModels:yt,availableAgents:V,modelProviders:lt,loading:C}=la(G),{currentModel:D,setCurrentModel:Y,currentAgentId:J,setCurrentAgentId:Jt,activeConnectorIds:ce,setActiveConnectorIds:De}=Aa(e,t,n),ye=As(!1);Ai(()=>{if(!ye.current){if(ye.current=!0,!e&&!t){let I=at.getDefaultModel();I&&Y(I)}if(!n&&!t){let I=at.getDefaultConnectorIds();I&&De(I.length>0?I:void 0)}}},[e,t,n,Y,De]);let{currentAgentDetails:be}=Ra(J,G),{fileSystem:Je,setFileSystem:ue,capabilityLabelMap:Ps}=Ea(o),{pendingFiles:Zt,addFile:Oe,removeFile:Se,clearFiles:$s,getUploadedFileIds:Qt,hasUploadingFiles:he,hasFiles:Is}=Oa({credentials:G,currentModel:D,modelProviders:lt,onUploadSuccess:I=>{rt(`\u2713 Attached: ${I}`)},onUploadError:(I,q)=>{rt(`\u2717 Failed to upload ${I}: ${q}`)}}),{sendMessage:ve,backgroundRuns:Le}=Ta({taskId:m,credentials:G,currentAgentId:J,currentModel:D,activeConnectorIds:ce,localTools:Je,toolApprovalMode:l,onApprovalRequest:f,fullOutput:U,setMessages:H,setState:E,setCurrentResponse:F,setCredentials:Z,setHasPersistedTask:B,getFileIds:Qt,clearFiles:$s}),te=Ci(Le),xe=Ri(I=>{Tt(I),F("")},[Tt]),[ke,Te]=$r(!1),bt=Ri(async I=>{let q=I.text.trim(),ft=mi(q);if(/^https?:\/\//.test(ft))return;if(await ea(q)&&ta(ft)){let Ms=await sa(q);Ms&&(I.preventDefault(),await Oe(Ms))}},[Oe]),ee=Ri(async()=>{if(!(ke||k.status!=="ready")){if(C||lt.length===0){rt("Wait for resources to load before pasting images.");return}rt("Reading clipboard\u2026"),Te(!0);try{let I=await Qo();if(I){let q=`clipboard-${Date.now()}.png`;rt(`Uploading: ${q} (${Math.round(I.buffer.length/1024)}KB)`),await Oe({buffer:I.buffer,filename:q,mimeType:I.mime})}else rt("No image found in clipboard. Copy an image first.")}catch(I){let q=I instanceof Error?I.message:"Failed to read clipboard";rt(`Clipboard error: ${q}`)}finally{Te(!1)}}},[Oe,rt,ke,k.status,C,lt.length]),{suggestions:Ce,suggestionIndex:Ne,showSuggestions:Ze,argMode:St,argItems:Ii,argIndex:R,selectedConnectorIds:x,selectedCapabilities:h,deleteConfirmMode:w,handleInputChange:T,handleSubmit:L}=Da({input:$,setInput:A,taskId:m,setTaskId:N,currentTaskTitle:tt,setCurrentTaskTitle:vt,currentModel:D,setCurrentModel:Y,currentAgentId:J,setCurrentAgentId:Jt,currentAgentDetails:be,setCurrentAgentDetails:()=>{},activeConnectorIds:ce,setActiveConnectorIds:De,fileSystem:Je,setFileSystem:ue,toolApprovalMode:l,setToolApprovalMode:c,availableModels:yt,availableAgents:V,availableConnectors:Pt,messages:P,hasPersistedTask:M,setHasPersistedTask:B,setMessages:H,addSystemMessage:rt,startNewTask:xe,sendMessage:ve,setFullOutput:K,credentials:G,setCredentials:Z,setState:E,defaultCapabilities:{fileSystem:o},capabilityLabelMap:Ps,hasUploadingFiles:he});Rs((I,q)=>{(q.ctrl||q.meta)&&I==="v"&&ee()},{isActive:k.status==="ready"&&!St}),Rs((I,q)=>{if(!q.escape)return;let ft=Date.now(),Mt=v.current;v.current=ft,!(!Mt||ft-Mt>Nh)&&(St||Ze||(v.current=null,Is&&$s(),$.length>0&&T("")))},{isActive:k.status==="ready"}),Rs((I,q)=>{q.return&&(xe("Started a new task."),E({status:"ready"}))},{isActive:k.status==="error"}),Rs((I,q)=>{if(!q.tab||!q.shift)return;let ft=Object.values(Be),Mt=ft[(ft.indexOf(l)+1)%ft.length]??Ee;c(Mt),at.setToolApprovalMode(Mt)},{isActive:k.status==="ready"&&!St}),Rs(I=>{let q=p[0];if(!q)return;let ft=I.toLowerCase();if(ft!=="y"&&ft!=="n")return;g.current.set(q.approvalId,ft==="y");let Mt=p.slice(1);u(Mt),Mt.length===0&&(d.current?.(g.current),d.current=null)},{isActive:p.length>0}),Ai(()=>{if(G&&!C&&k.status==="loading")if(!D&&!J){let I=at.getDefaultModel(),q=I&&yt.some(Mt=>Mt.id===I),ft=q?I:yt[0]?.id;ft?(q||at.setDefaultModel(ft),Y(ft),E({status:"ready"})):V.length===0?E({status:"no-model"}):E({status:"ready"})}else E({status:"ready"})},[G,C,D,J,yt,V,k.status,Y,E]);let et=As(!1);if(Ai(()=>{et.current||s&&G&&k.status==="ready"&&(et.current=!0,ve(s))},[G,s,k.status,ve]),k.status==="loading")return X(dt,{flexDirection:"column",children:[j(O,{children:b}),X(dt,{children:[j(O,{color:"cyan",children:j(Pr,{type:"dots"})}),j(O,{children:" Initializing task\u2026"})]})]});if(k.status==="not-logged-in")return X(dt,{flexDirection:"column",children:[j(O,{children:b}),j(O,{color:"yellow",children:"Not logged in"}),j(O,{dimColor:!0,children:"Run `entrydesk login` first."})]});if(k.status==="no-workspace")return X(dt,{flexDirection:"column",children:[j(O,{children:b}),j(O,{color:"yellow",children:"No workspace selected"}),j(O,{dimColor:!0,children:"Run `entrydesk workspaces` to select a workspace first."})]});if(k.status==="no-model")return X(dt,{flexDirection:"column",children:[j(O,{children:b}),j(O,{color:"yellow",children:"No model or agent specified"}),i&&j(O,{dimColor:!0,children:"Could not determine the model used in this task."}),j(O,{dimColor:!0,children:"Specify a model with --model, or an agent with -a."}),j(O,{dimColor:!0,children:"Example: entrydesk task -c 1 -i --model gemini-2.5-flash-lite"})]});if(k.status==="error")return X(dt,{flexDirection:"column",children:[j(O,{children:b}),X(O,{color:"red",children:["Error: ",k.message]}),j(O,{dimColor:!0,children:"Press Enter to start a new task, or Ctrl+C to exit"})]});let nt=wi({agentId:J,agentDetails:be,activeConnectorIds:ce,availableConnectors:Pt}),It=[];if(J)if(be?.capabilities)for(let I of be.capabilities)It.push(Ps.get(I)??I);else It.push("loading\u2026");Je&&It.push("FileSystem");let z=ot.getCurrentProfileName(),it=z!=="default",xt=(()=>{switch(St){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:"}})(),ut=(()=>{if(St==="connectors")return x;if(St==="capabilities")return h})();return X(dt,{flexDirection:"column",children:[X(dt,{marginBottom:1,flexDirection:"column",children:[j(O,{children:b}),X(dt,{children:[j(O,{bold:!0,color:"cyan",children:tt?`Continuing: ${tt}`:"EntryDesk CLI"}),X(O,{dimColor:!0,children:[" v","1.31.0"]}),it&&X(O,{color:"magenta",children:[" [",z,"]"]}),j(O,{dimColor:!0,children:" (type /help for commands)"})]})]}),P.map((I,q)=>{let ft=I.parts&&U?we(I.parts,!0):I.content,Mt=I.role==="user"?"green":I.role==="system"?"yellow":"blue",Ms=I.role==="user"?"You":I.role==="system"?"System":"Assistant";return X(dt,{flexDirection:"column",marginBottom:1,children:[X(O,{bold:!0,color:Mt,children:[Ms,":"]}),j(xr,{text:ft})]},q)}),_&&X(dt,{flexDirection:"column",marginBottom:1,children:[j(O,{bold:!0,color:"blue",children:"Assistant:"}),j(xr,{text:_})]}),k.status==="ready"&&j(Oo,{suggestions:Ce,activeIndex:Ne,visible:Ze}),k.status==="ready"&&St&&j(Do,{items:Ii,activeIndex:R,pageSize:St==="agent"||St==="skills"||St==="model"?5:10,selectedIds:ut,multiSelect:St==="connectors"||St==="capabilities",visible:!0,title:xt}),p.length>0&&p[0]&&X(dt,{flexDirection:"column",marginY:1,borderStyle:"round",borderColor:"yellow",paddingX:1,children:[X(O,{color:"yellow",bold:!0,children:["Approve tool call?",p.length>1&&X(O,{dimColor:!0,children:[" (1 of ",p.length,")"]})]}),j(O,{children:xs(p[0].toolName)}),j(O,{dimColor:!0,wrap:"truncate-end",children:xs(JSON.stringify(p[0].input))}),j(O,{dimColor:!0,children:"[y] approve [n] reject"})]}),k.status==="sending"&&!_?X(dt,{children:[j(O,{color:"cyan",children:j(Pr,{type:"dots"})}),j(O,{children:" Thinking\u2026"})]}):k.status==="ready"&&!St?X(dt,{flexDirection:"column",children:[w&&j(dt,{marginBottom:1,children:j(O,{color:"yellow",children:"\u26A0\uFE0F Delete this task? [y/N] "})}),Is&&!w&&X(dt,{marginBottom:1,flexDirection:"row",gap:1,children:[j(O,{dimColor:!0,children:"Attachments:"}),Zt.map((I,q)=>X(O,{children:[I.status==="uploading"?X(O,{color:"yellow",children:[j(Pr,{type:"dots"})," ",I.filename]}):I.status==="error"?X(O,{color:"red",children:["\u2717 ",I.filename]}):X(O,{color:"green",children:["\u2713 ",I.filename]}),q<Zt.length-1&&j(O,{children:", "})]},I.id))]}),X(dt,{children:[j(O,{color:"green",children:"> "}),j(Go,{value:$,onChange:T,onSubmit:L,onPaste:bt,leadingOffset:2,multiline:!0})]})]}):null,te.activeCount>0&&j(dt,{children:X(O,{dimColor:!0,children:["background: ",te.activeCount," running"]})}),X(dt,{marginTop:1,flexDirection:"column",children:[X(dt,{gap:2,children:[X(O,{children:[j(O,{dimColor:!0,children:"Model: "}),j(O,{color:"magenta",children:J?be?.model?.name||"loading\u2026":yt.find(I=>I.id===D)?.name||D||"none"})]}),X(O,{children:[j(O,{dimColor:!0,children:"Connectors: "}),j(O,{color:"cyan",children:nt})]}),X(O,{children:[j(O,{dimColor:!0,children:"Capabilities: "}),j(O,{color:"green",children:It.length>0?It.join(", "):"none"})]}),X(O,{children:[j(O,{dimColor:!0,children:"Approval: "}),j(O,{color:"yellow",children:je[l]})]})]}),X(O,{dimColor:!0,children:["Esc Esc: Clear input & attachments | Ctrl+V: Paste image | Ctrl+O: Toggle full output ",U?"(ON)":"(OFF)"," | Shift+Tab: Approval mode | Ctrl+C: Exit"]})]})]})}import{Chat as Wh}from"@ai-sdk/react";import{getToolName as Ir}from"ai";import{v4 as zh}from"uuid";var Ba="Non-interactive run: no one is available to approve.";function ja(t){return t.status==="ready"||t.status==="error"?Promise.resolve():new Promise(e=>{let s=t["~registerStatusCallback"](()=>{(t.status==="ready"||t.status==="error")&&(s(),e())})})}async function Ua({taskId:t,text:e,resolveCredentials:s,resolveTaskConfig:i,sendTask:r,isClientTool:n,runClientTool:o,onChunk:a,onStreamEnd:l,onApprovalDenied:c}){let p=new Set,u=new Ye({resolveCredentials:s,resolveTaskConfig:i,sendTask:r,onToolPartsSubmitted:f=>{for(let y of f)p.add(y)},...a?{onChunk:a}:{},...l?{onStreamEnd:l}:{}}),d=new Wh({id:t,transport:u,generateId:zh,sendAutomaticallyWhen:f=>Qe({messages:f.messages,isClientTool:n,submittedToolCallIds:p})});async function g(){let f=Fs(d.messages.at(-1)),y=f.filter(S=>S.state==="approval-requested");for(let S of y)await d.addToolApprovalResponse({id:S.approval.id,approved:!1,reason:Ba}),c?.(Ir(S));if(y.length>0)return!0;let b=f.filter(S=>n(S)&&S.state==="approval-responded"&&!S.approval.approved);for(let S of b)await d.addToolOutput({tool:Ir(S),toolCallId:S.toolCallId,state:"output-error",errorText:Ba});let v=f.filter(S=>n(S)&&S.state==="input-available");for(let S of v){let k=Ir(S),E=await o(k,S.input??{});await d.addToolOutput({tool:k,toolCallId:S.toolCallId,state:"output-available",output:E})}return b.length+v.length>0}for(await d.sendMessage({text:e}),await ja(d);d.status!=="error"&&await g();)await ja(d);return d}import{jsx as Jh}from"react/jsx-runtime";function sw(){console.log(`
|
|
128
|
+
Usage: entrydesk task [options]
|
|
129
|
+
|
|
130
|
+
Send a message to a model or agent, or start an interactive session.
|
|
131
|
+
|
|
132
|
+
Options:
|
|
133
|
+
-m, --message <text> Message to send (or pipe via stdin)
|
|
134
|
+
--model <modelId> Model to use (required if no agent and no default)
|
|
135
|
+
-a, --agent <agentId> Agent to use (instead of --model)
|
|
136
|
+
-c, --continue <n> Continue recent task #n
|
|
137
|
+
-i, --interactive Interactive mode (continuous chat)
|
|
138
|
+
--connectors id1,id2 Limit to specific connectors (default: all connected)
|
|
139
|
+
--plain Plain text output
|
|
140
|
+
--output stream-json Stream events as JSON
|
|
141
|
+
--full-output Show full tool outputs
|
|
142
|
+
--no-file-system Disable local file operations
|
|
143
|
+
--tool-approval-mode <mode>
|
|
144
|
+
always_ask | auto | always_allow. Defaults to the
|
|
145
|
+
mode /approval saved. Non-interactive runs deny
|
|
146
|
+
every approval they are asked for
|
|
147
|
+
--dangerously-auto-approve-tools
|
|
148
|
+
Deprecated alias for --tool-approval-mode always_allow
|
|
149
|
+
--json Output JSON
|
|
150
|
+
|
|
151
|
+
Examples:
|
|
152
|
+
entrydesk task -m "Hello" --model <model>
|
|
153
|
+
entrydesk task -m "Hello" -a <agentId>
|
|
154
|
+
entrydesk task -c 1 -m "Follow up" # Continue recent task
|
|
155
|
+
entrydesk task -i # Interactive mode
|
|
156
|
+
echo "Explain this" | entrydesk task --model <model> # Pipe stdin
|
|
157
|
+
entrydesk task -m "Hi" --model <m> --output stream-json
|
|
158
|
+
|
|
159
|
+
List available models: entrydesk models
|
|
160
|
+
List available agents: entrydesk agents
|
|
161
|
+
List recent tasks: entrydesk tasks
|
|
162
|
+
`)}async function Xh(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8").trim()}async function Vh(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:a}=await t.getMessages(e,s,n.id,10);o=a.find(c=>c.role==="assistant"&&c.modelId)?.modelId}return{task:n,modelId:o}}var le="\x1B[2m",pt="\x1B[0m",Mr="\x1B[36m",$i="\x1B[33m",_i="\x1B[32m",Wa="stream-json";function Yh(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)}
|
|
163
|
+
`)}function _s(t,e){if(e)return t;let s=t.split(`
|
|
164
|
+
`);if(s.length<=20)return t;let i=s.slice(0,5),r=s.slice(-5),n=s.length-10;return[...i,`${le}\u2026 (${n} lines omitted, use --full-output to see all) \u2026${pt}`,...r].join(`
|
|
165
|
+
`)}function Kh(t){try{return JSON.stringify(t,null,2)}catch{return String(t)}}function za(t,e){if(!t)return"(no result)";if(typeof t!="object")return _s(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(`${$i}[stderr]${pt} ${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)),_s(r.join(`
|
|
166
|
+
`),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(`
|
|
167
|
+
`);return _s(r||JSON.stringify(t,null,2),e)}return s.type==="text"&&typeof s.content=="string"?_s(s.content,e):_s(JSON.stringify(t,null,2),e)}function Ga(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 iw(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 C=await qt();e=C.accessToken,s=C.workspaceId}catch(C){Li(C)}let i=t.output===Wa;t.output&&!i&&(console.error(`Invalid --output value. Supported: ${Wa}`),process.exit(1)),t.dangerouslyAutoApproveTools&&console.error("--dangerously-auto-approve-tools is deprecated. Use --tool-approval-mode instead.");let n=t.toolApprovalMode??(t.dangerouslyAutoApproveTools?Be.ALWAYS_ALLOW:void 0)??at.getToolApprovalMode()??void 0,o=!i&&(t.plain||!process.stdout.isTTY),a=at.getDefaultModel(),l=t.message;!l&&!process.stdin.isTTY&&(l=await Xh());let c=new ht,p,u=!1;async function d(){if(u)return p;u=!0;try{({models:p}=await c.listSelectableModels(e,s))}catch{p=void 0}return p}async function g(){let C=await d();if(!C||a&&C.some(Y=>Y.id===a))return;let D=C[0]?.id;D&&(at.setDefaultModel(D),a=D)}let f,y,b,v;if(t.continue){let C=await Vh(c,e,s,t.continue);if(C||process.exit(1),f=C.task.id,y=C.task.title??void 0,b=C.task.agentId??void 0,v=C.modelId,v&&!b&&!t.model){let Y=await d();Y&&!Y.some(J=>J.id===v)&&(v=void 0)}let D=t.agentId||t.model||b||v||a;!D&&!t.interactive&&(await g(),D=t.agentId||t.model||b||v||a),!D&&!t.interactive&&(o||console.log(`Continuing task: ${C.task.title||"Untitled"}`),console.error(`
|
|
168
|
+
Could not determine the model for this task. Specify --model or -a.`),console.error('Example: entrydesk task -c 1 -m "message" --model gemini-2.5-flash-lite'),process.exit(1)),!o&&!t.interactive&&console.log(`Continuing task: ${C.task.title||"Untitled"}
|
|
169
|
+
`)}let S=t.agentId||b,k=t.model||v||void 0;!S&&!k&&(await g(),k=t.model||v||a||void 0),Yh(t.fileSystem,t.noFileSystem,"--file-system","--no-file-system");let E=at.getDefaultConnectorIds(),P=t.connectors??E??void 0,H=at.getLocalTools(),$=t.noFileSystem?!1:t.fileSystem?!0:H?.fileSystem??!0;if(t.interactive){Hh(Jh(Na,{agentId:S,model:k,message:t.message,taskId:f,taskTitle:y??void 0,connectorIds:P,enableFileSystem:$,toolApprovalMode:n??Ee}),{exitOnCtrlC:!1});return}let A=!t.continue&&!k&&!S;(!l||A)&&(console.error("Provide a message, plus either a model or an agent. For example:"),console.error(" 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("Run `entrydesk task --help` for all options."),process.exit(1));let m=t.fullOutput??!1,N=f||qh(),tt=$?oi():void 0,vt=$?ai():void 0,M=()=>Si({agentId:S,model:k,connectorIds:P,clientTools:tt,clientToolSystemPrompt:vt,toolApprovalMode:n}),B=bi({openRunEvents:(C,D)=>c.openSubagentRunEvents(e,s,C,D),getRun:(C,D)=>c.getSubagentRun(e,s,C,D)}),G=!0,Z=C=>{process.stdout.write(C),G=C.endsWith(`
|
|
170
|
+
`)},_=C=>Z(`${C}
|
|
171
|
+
`),F=new Map,U=()=>{if(G)for(let C of B.getSnapshot().runs){let D=`${C.description}: ${ki(C.stream)}`;D!==F.get(C.runId)&&(F.set(C.runId,D),_(`${le}\u2502 ${D}${pt}`))}};B.subscribe(U);let K=new Set(["text-delta","reasoning-delta","tool-call","tool-input-available","tool-result","data-appendMessage"]),rt=!1,Tt=new Set,W=new Map,Pt=new Map,yt=C=>{let D=ba(C,Pt);if(D){_(`${le}\u2502 ${D}${pt}`);return}switch(C.type){case"reasoning-delta":C.delta&&Z(`${le}${C.delta}${pt}`);break;case"reasoning-end":Z(`
|
|
172
|
+
|
|
173
|
+
`);break;case"text-delta":C.delta&&Z(C.delta);break;case"data-appendMessage":Z(Ga(C));break;case"tool-call-streaming-start":case"tool-input-start":if(C.toolCallId&&C.toolName){W.set(C.toolCallId,C.toolName);let J=$&&ms(C.toolName)?`${_i}[LOCAL]${pt} `:"";_(`
|
|
174
|
+
${Mr}\u250C\u2500 ${J}Tool: ${C.toolName}${pt}`)}break;case"tool-call":case"tool-input-available":if(C.toolCallId&&C.toolName){let Y=Kh(C.args||C.input||{});_(`${$i}\u2502 Input:${pt}`);for(let J of Y.split(`
|
|
175
|
+
`))_(`${le}\u2502 ${J}${pt}`)}break;case"tool-result":if(C.toolCallId){let Y=W.get(C.toolCallId),J=za(C.result,m);_(`${_i}\u2502 Output:${pt}`);for(let Jt of J.split(`
|
|
176
|
+
`))_(`${le}\u2502 ${Jt}${pt}`);_(`${Mr}\u2514\u2500 ${Y||"Tool"} completed${pt}
|
|
177
|
+
`),W.delete(C.toolCallId)}break;case"error":C.errorText&&console.error(`${le}Error: ${C.errorText}${pt}`);break;default:break}},V=C=>{let D=C;if(D.type&&K.has(D.type)&&(rt=!0),i){D.type==="text-delta"&&D.delta!==void 0?Pi("text-delta",D.delta):D.type==="reasoning-delta"&&D.delta!==void 0?Pi("reasoning-delta",D.delta):Pi(D.type||"event",D);return}if(o){D.type==="text-delta"&&D.delta&&Z(D.delta),D.type==="data-appendMessage"&&Z(Ga(D));return}B.ingestChunk(C),yt(D),U()},lt;try{lt=await Ua({taskId:N,text:l,resolveCredentials:()=>Promise.resolve({accessToken:e,workspaceId:s}),resolveTaskConfig:M,sendTask:(C,D)=>c.task(C.accessToken,C.workspaceId,D),isClientTool:C=>$&&ms(Gh(C)),runClientTool:async(C,D)=>{!o&&!i&&_(`${_i}\u2502 Executing locally\u2026${pt}`);let Y=await li(C,D);if(!o&&!i){let J=za(Y.success?Y.result:{error:Y.error},m);_(`${_i}\u2502 Output:${pt}`);for(let Jt of J.split(`
|
|
178
|
+
`))_(`${le}\u2502 ${Jt}${pt}`);_(`${Mr}\u2514\u2500 ${C} completed${pt}
|
|
179
|
+
`)}return{content:ci(Y),isError:!Y.success}},onChunk:V,onStreamEnd:()=>{i&&Pi("done")},onApprovalDenied:C=>Tt.add(C)})}finally{B.dispose()}Tt.size>0&&console.error(`${$i}Tool approval denied (non-interactive run has no approver): ${[...Tt].toSorted().join(", ")}${pt}`),lt.status==="error"&<.error&&Li(lt.error),rt||(console.error(`${$i}No response received from the server (empty stream).${pt}`),console.error(`${le}The task may have failed server-side. Re-run with DEBUG=1 for details.${pt}`),process.exit(1)),i||(_(""),U())}export{sw as printTaskHelp,iw as runTask};
|