@easbot/utils 0.2.11 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/chunk-6FROKXK6.mjs +1 -0
- package/dist/chunks/chunk-6WIM3NST.cjs +1 -0
- package/dist/chunks/filesystem-IEDC2UL2.mjs +1 -0
- package/dist/chunks/filesystem-NRWL3JOL.cjs +1 -0
- package/dist/index.cjs +42 -42
- package/dist/index.d.cts +28 -9
- package/dist/index.d.ts +28 -9
- package/dist/index.mjs +42 -42
- package/package.json +8 -3
- package/dist/chunks/chunk-C4GIW5KR.mjs +0 -1
- package/dist/chunks/chunk-FQQBYGFZ.cjs +0 -1
- package/dist/chunks/filesystem-6XGC2Y33.cjs +0 -1
- package/dist/chunks/filesystem-OR762OFU.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {c as c$1}from'./chunks/chunk-6FROKXK6.mjs';export{c as Filesystem,a as Glob,b as MIME_TYPES}from'./chunks/chunk-6FROKXK6.mjs';export{b as PackageRegistry,a as Semver}from'./chunks/chunk-RSXPIS2N.mjs';import {a}from'./chunks/chunk-7TNSRCET.mjs';import {b,a as a$1}from'./chunks/chunk-DAYGB2XR.mjs';export{a as Lock}from'./chunks/chunk-UZ52E7FE.mjs';import {k,c,i}from'./chunks/chunk-V6YNYGNC.mjs';import X from'fs/promises';import ae,{dirname,join}from'path';import Ie,{z}from'zod';import {randomBytes,createHash}from'crypto';import Ce,{existsSync,readdirSync,statSync}from'fs';import {execSync,spawn}from'child_process';import {createRequire}from'module';import {Hono}from'hono';export{Hono}from'hono';import {serve}from'@hono/node-server';import {createNodeWebSocket}from'@hono/node-ws';export{createNodeWebSocket}from'@hono/node-ws';import {streamSSE}from'hono/streaming';import {cors}from'hono/cors';export{cors}from'hono/cors';import {logger}from'hono/logger';export{logger}from'hono/logger';import {compress}from'hono/compress';export{compress}from'hono/compress';import {secureHeaders}from'hono/secure-headers';export{secureHeaders}from'hono/secure-headers';import {timeout}from'hono/timeout';export{timeout}from'hono/timeout';import {HTTPException}from'hono/http-exception';export{HTTPException}from'hono/http-exception';export{validator}from'hono/validator';import {zValidator}from'@hono/zod-validator';export{zValidator}from'@hono/zod-validator';import {minimatch}from'minimatch';import {setTimeout as setTimeout$1}from'timers/promises';import {config}from'dotenv';import {fileURLToPath}from'url';import Jr from'markdown-it';import Pn from'yaml';import {AsyncLocalStorage}from'async_hooks';k();k();function Vn(e,t){for(let r=e.length-1;r>=0;r-=1){let n=e[r];if(n!==void 0&&t(n,r,e))return n}}k();var Ye;(r=>{function e(n,o,s){let a=0,i=n.length-1;for(;a<=i;){let l=Math.floor((a+i)/2),d=n[l];if(d===void 0)break;let c=s(d);if(c===o)return {found:true,index:l};c<o?a=l+1:i=l-1;}return {found:false,index:a}}r.search=e;function t(n,o,s){let a=s(o),i=0,l=n.length;for(;i<l;){let d=Math.floor((i+l)/2),c=n[d];if(c===void 0)break;s(c)<a?i=d+1:l=d;}return n.splice(i,0,o),n}r.insert=t;})(Ye||(Ye={}));k();var Je;(s=>{function e(a){let i=new TextEncoder().encode(a),l=Array.from(i,d=>String.fromCharCode(d)).join("");return btoa(l).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}s.base64Encode=e;function t(a){let i=atob(a.replace(/-/g,"+").replace(/_/g,"/")),l=Uint8Array.from(i,d=>d.charCodeAt(0));return new TextDecoder().decode(l)}s.base64Decode=t;async function r(a,i="SHA-256"){let d=new TextEncoder().encode(a),c=await crypto.subtle.digest(i,d);return Array.from(new Uint8Array(c)).map(S=>S.toString(16).padStart(2,"0")).join("")}s.hash=r;function n(a){if(!a)return;let i=2166136261;for(let l=0;l<a.length;l++)i^=a.charCodeAt(l),i=Math.imul(i,16777619);return (i>>>0).toString(36)}s.checksum=n;function o(a,i=5e5){if(!a)return;if(a.length<=i)return n(a);let l=4096,c=[0,Math.floor(a.length*.25),Math.floor(a.length*.5),Math.floor(a.length*.75),a.length-l].map(u=>{let m=Math.max(0,Math.min(a.length-l,u-Math.floor(l/2)));return n(a.slice(m,m+l))??""}).join(":");return `${a.length}:${c}`}s.sampledChecksum=o;})(Je||(Je={}));k();k();var ge;(u=>{let e={event:"evt",session:"ses",message:"msg",permission:"per",question:"que",user:"usr",part:"prt",pty:"pty",tool:"tool",workspace:"wrk",command:"cmd",task:"task",heartbeat:"hb",subagent:"sub",hook:"hok",compaction:"cmp",context:"ctx"};function t(m){return Ie.string().startsWith(e[m])}u.schema=t;let r=26,n=0,o=0;function s(m,S){return i(m,false,S)}u.ascending=s;function a(m,S){return i(m,true,S)}u.descending=a;function i(m,S,P){if(!P)return d(m,S);if(!P.startsWith(e[m]))throw new Error(`ID ${P} does not start with ${e[m]}`);return P}function l(m){let S="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",P="",L=randomBytes(m);for(let _=0;_<m;_++){let D=L[_];D!==void 0&&(P+=S[D%62]);}return P}function d(m,S,P){let L=P??Date.now();L!==n&&(n=L,o=0),o++;let _=BigInt(L)*BigInt(4096)+BigInt(o);_=S?~_:_;let D=Buffer.alloc(6);for(let z=0;z<6;z++)D[z]=Number(_>>BigInt(40-8*z)&BigInt(255));return e[m]+"_"+D.toString("hex")+l(r-12)}u.create=d;function c(m){let S=m.split("_")[0];if(!S)return 0;let P=m.slice(S.length+1,S.length+13),L=BigInt("0x"+P);return Number(L/BigInt(4096))}u.timestamp=c;})(ge||(ge={}));var Ze;(i=>{i.DIR=ae.join("data","context-truncate"),i.DEFAULT_MAX_CHARS=4e3,i.DIRECTION="head";function n(l,d,c){return c?`[Content truncated. Source: ${c}
|
|
2
2
|
Full ${d} saved to: ${l}
|
|
3
3
|
Use Read tool with offset/limit parameters to view specific sections.]`:`[Content truncated. Full ${d} saved to: ${l}
|
|
4
|
-
Use Read tool with offset/limit parameters to view specific sections.]`}function o(l,d={}){let c=d.maxChars??i.DEFAULT_MAX_CHARS,u=d.direction??i.DIRECTION,m=d.label??"content",
|
|
4
|
+
Use Read tool with offset/limit parameters to view specific sections.]`}function o(l,d={}){let c=d.maxChars??i.DEFAULT_MAX_CHARS,u=d.direction??i.DIRECTION,m=d.label??"content",S=d.sourcePath;if(l.length<=c)return {content:l,truncated:false};let P=l.length-c,L;u==="head"?L=l.slice(0,c):L=l.slice(-c);let _=n("[save-path]",m,S),D=u==="head"?`
|
|
5
5
|
|
|
6
6
|
...${P} characters truncated...
|
|
7
7
|
|
|
@@ -9,73 +9,73 @@ ${_}`:`
|
|
|
9
9
|
|
|
10
10
|
...${P} characters truncated...
|
|
11
11
|
|
|
12
|
-
${_}`;return {content
|
|
12
|
+
${_}`;return {content:L+D,truncated:true,outputPath:"[save-path]",originalLength:l.length,removedLength:P,label:m}}i.truncate=o;async function s(l,d={}){let c=d.maxChars??i.DEFAULT_MAX_CHARS,u=d.direction??i.DIRECTION,m=d.label??"content",S=d.dir??i.DIR,P=d.sourcePath;if(l.length<=c)return {content:l,truncated:false};let L=ge.ascending("context"),_=ae.join(S,L);await X.mkdir(S,{recursive:true}).catch(()=>{}),await X.writeFile(_,l,"utf-8");let D=l.length-c,z;u==="head"?z=l.slice(0,c):z=l.slice(-c);let pe=n(_,m,P),We=u==="head"?`
|
|
13
13
|
|
|
14
|
-
...${
|
|
14
|
+
...${D} characters truncated...
|
|
15
15
|
|
|
16
16
|
${pe}`:`
|
|
17
17
|
|
|
18
|
-
...${
|
|
18
|
+
...${D} characters truncated...
|
|
19
19
|
|
|
20
|
-
${pe}`;return {content:
|
|
21
|
-
${s.stderr}`),{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});return a},o=n();return Object.defineProperty(o,"stdin",{get(){throw new Error("stdin is not yet supported in EasbotShell. Use PKG.spawn for interactive commands.")},enumerable:true}),o.cwd=function(s){return
|
|
22
|
-
`),
|
|
23
|
-
`),I=E.length>0?E[0]?.trim():null;if(I)return
|
|
24
|
-
`).filter(p=>p.trim()&&!p.startsWith("#")))):["/bin/bash","/bin/zsh","/bin/sh"]}function d(f,p){if(f&&(!p?.acceptable||o(f))){let x=a$1(f);if(x)return x}return process.platform==="win32"?i()[0]:
|
|
20
|
+
${pe}`;return {content:z+We,truncated:true,outputPath:_,originalLength:l.length,removedLength:D,label:m}}i.truncateAndSave=s;function a(l){return l.truncated?n(l.outputPath,l.label):""}i.formatHint=a;})(Ze||(Ze={}));k();k();function At(e){let t,r=false,n=()=>(r||(t=e(),r=true),t);return n.reset=()=>{r=false,t=void 0;},n}var Me=At;function Lt(e){let t,r=()=>(t||(t=e()),t);return r.reset=()=>{t=void 0;},r}var Jn=Lt,oe;(r=>(r.lazy=At,r.lazyAsync=Lt))(oe||(oe={}));k();k();k();var Z=a.create({service:"server"});function ee(e={}){let t=e.port??3e3,r=e.hostname??"0.0.0.0",n=new Hono({strict:true,getPath:a=>{try{return new URL(a.url).pathname}catch{return a.url}}});if(e.onError?n.onError(e.onError):n.onError((a,i)=>(Z.error("Server error",{error:a.message,stack:a.stack}),a instanceof HTTPException?a.getResponse():i.json({error:"Internal Server Error",message:a.message},500))),e.onNotFound?n.notFound(e.onNotFound):n.notFound(a=>a.json({error:"Not Found",path:a.req.path},404)),!e.websockets&&e.cors&&n.use(cors(typeof e.cors=="boolean"?{origin:"*"}:e.cors)),n.use(logger((a,...i)=>Z.info(a,i))),!e.websockets&&e.secureHeaders&&n.use(secureHeaders()),!e.websockets&&e.compression&&n.use(compress({encoding:"gzip"})),!e.websockets&&e.timeout&&n.use(timeout(e.timeout)),e.middlewares)for(let a of e.middlewares)a.path?n.use(a.path,a.handler):n.use(a.handler);if(e.routes)for(let a of e.routes){let i=a.middlewares||[],l=a.method.toUpperCase();a.validation?n.on(l,a.path,zValidator("json",a.validation),...i,a.handler):n.on(l,a.path,...i,a.handler);}e.rpc&&n.post("/rpc/:method",async a=>{let i=a.req.param("method"),l=e.rpc?.[i];if(!l)return a.json({error:"RPC method not found"},404);try{let d=await a.req.json(),c=await l(d,a);return a.json({result:c})}catch(d){return Z.error("RPC error",{method:i,error:d.message}),a.json({error:"RPC execution failed",message:d.message},500)}}),e.fetch&&n.all("*",async a=>await e.fetch(a.req.raw));let o=null,s={url:new URL(`http://${r}:${t}`),port:t,hostname:r,hono:n,async stop(a=false){return o?new Promise((i,l)=>{a&&o.closeAllConnections?.(),o.close(d=>{d?(Z.error("Error closing server",{error:d.message}),l(d)):(o=null,Z.info(`Server on port ${t} stopped`),i());}),setTimeout(()=>{Z.warn(`Server shutdown timeout on port ${t}`),o=null,i();},5e3);}):Promise.resolve()},get raw(){return o||void 0}};return Z.debug("createServer: calling serve()",{port:t,hostname:r}),o=serve({fetch:n.fetch,port:t,hostname:r}),Z.debug("createServer: serve() returned, server created"),Z.info(`Server running on http://${r}:${t}`),s}function Ke(e){return ee({rpc:e,port:3e3})}function Qn(e,t=3e3,r="0.0.0.0"){return ee({fetch:e,port:t,hostname:r})}function Xe(e,t={}){return ee({...t,routes:e})}function Qe(e,t={}){return ee({...t,websockets:e})}function et(e,t={}){let r=Object.entries(e).map(([n,o])=>({method:"get",path:`/stream/${n}`,handler:s=>streamSSE(s,async a=>{for await(let i of o(s))await a.writeSSE(i);})}));return ee({...t,routes:r,streaming:true})}k();var te=a.create({service:"build-api"});async function Jt(){try{return {available:!0,version:(await import('./chunks/main-ZMRSNK7G.mjs')).version||"unknown"}}catch(e){return te.warn("esbuild not available",{error:e.message}),{available:false}}}async function Pe(){let e=await Jt();if(!e.available)throw new Error("esbuild is required but not installed. Please install it using: pnpm add -D esbuild");e.version&&e.version<"0.17.0"&&te.warn(`esbuild version ${e.version} may have limited features. Consider upgrading to 0.17+`);}function rr(e){if(e!==void 0)return typeof e=="boolean"?{target:void 0}:typeof e=="string"?{target:e}:e}function Zt(e){let t=rr(e.compile);t&&te.warn("compile option is no longer supported (Bun runtime removed). The option will be ignored.");let r={entryPoints:e.entrypoints,outdir:e.outdir,bundle:e.bundle??true,conditions:e.conditions,external:e.external,format:e.format??"esm",platform:e.platform??(e.target==="browser"?"browser":"node"),minify:e.minify??false,treeShaking:true,splitting:e.splitting,sourcemap:or(e.sourcemap),sourcesContent:true,define:e.define,inject:e.inject,legalComments:"eof",loader:e.loader,entryNames:e.entryNames,chunkNames:e.chunkNames,assetNames:e.assetNames,publicPath:e.publicPath,tsconfig:e.tsconfig,charset:"utf8",color:true,logLevel:"info",logLimit:50,plugins:e.plugins??[],metafile:true,write:e.write??true};return t?.outfile&&!e.outdir&&(r.outfile=t.outfile,delete r.outdir),e.target&&(r.target=sr(e.target)),e.minify===true&&(r.minifyWhitespace=true,r.minifyIdentifiers=true,r.minifySyntax=true),ir(r)}function or(e){return !e||e==="none"?false:e}function sr(e){let t={browser:"es2020",node:"node16",bun:"esnext"};return e?t[e]||e:"esnext"}function ir(e){let t={};for(let r of Object.keys(e))e[r]!==void 0&&(t[r]=e[r]);return t}function Re(e){if(e!==void 0)return e.replace(/\\/g,"/")}function qt(e,t,r){let n=[];if(e.outputFiles)for(let s of e.outputFiles)n.push({path:Re(s.path)||s.path,size:s.contents?.length||0});if(e.metafile?.outputs)for(let[s,a]of Object.entries(e.metafile.outputs)){let i=a;n.some(l=>l.path===s||l.path===Re(s))||n.push({path:Re(s)||s,size:i.bytes||0});}let o=[];if(e.errors?.length>0)for(let s of e.errors)o.push({level:"error",message:s.text||String(s),path:s.location?.file,position:s.location?{line:s.location.line,column:s.location.column}:void 0});if(e.warnings?.length>0)for(let s of e.warnings)o.push({level:"warning",message:s.text||String(s),path:s.location?.file,position:s.location?{line:s.location.line,column:s.location.column}:void 0});return {outputs:n,success:e.errors?.length===0,logs:o,metafile:e.metafile}}async function nt(e){te.info("Build started",{entrypoints:e.entrypoints,target:e.target,format:e.format,compile:typeof e.compile}),await Pe();let t=await import('./chunks/main-ZMRSNK7G.mjs'),r=Date.now();try{let n=Zt(e);te.debug("esbuild options",n);let o=await t.build(n),s=Date.now();return te.info("Build completed",{duration:s-r,outputs:(o?.outputFiles?.length??0)>0||Object.keys(o.metafile?.outputs||{}).length>0}),qt(o,r,s)}catch(n){let o=Date.now(),s=n.message;return te.error("Build failed",{error:s,duration:o-r}),n&&typeof n=="object"&&"errors"in n?qt(n):{outputs:[],success:false,logs:[{level:"error",message:s}],metafile:void 0}}}var fr={build:nt},Kt=fr;k();k();function K(e){let t=[],r="",n=0;for(;n<e.length&&(e[n]===" "||e[n]===" ");)n++;for(;n<e.length;){let o=e[n];if(o===" "||o===" "){for(r.length>0&&(t.push(r),r="");n<e.length&&(e[n]===" "||e[n]===" ");)n++;continue}if(o==='"'){for(n++;n<e.length;){let s=e[n];if(s==="\\"&&n+1<e.length){let a=e[n+1];if(a==='"'||a==="\\"||a==="$"||a==="`"){r+=a,n+=2;continue}}if(s==='"'){n++;break}r+=s,n++;}continue}if(o==="'"){for(n++;n<e.length;){let s=e[n];if(s==="'"){n++;break}r+=s,n++;}continue}r+=o,n++;}return r.length>0&&t.push(r),t}function Xt(e){return /[|&;<>()$`!#]/.test(e)}function Qt(e){let t=K(e);if(t.length===0)return {command:"",args:[]};let r={command:t[0],args:t.slice(1)};if(r.args.length>0){let n=r.args[r.args.length-1];try{let o=JSON.parse(n);typeof o=="object"&&o!==null&&!Array.isArray(o)&&(r.options=o,r.args=r.args.slice(0,-1));}catch{}}return r}function rt(e,t=process.platform==="win32"?"windows":"unix"){return t==="windows"?e.includes(" ")||e.includes("&")||e.includes("|")||e.includes("<>")||e.includes("^")||e.includes('"')||e.includes("%")?`"${e.replace(/%/g,"%%").replace(/"/g,'^"')}"`:e:e.includes(" ")||e.includes("'")||e.includes('"')||e.includes("$")||e.includes("`")||e.includes("\\")||e.includes("!")||e.includes("#")||e.includes("&")||e.includes("*")||e.includes("?")||e.includes("|")||e.includes("<")||e.includes(">")||e.includes("(")||e.includes(")")||e.includes(";")?`'${e.replace(/'/g,"'\\''")}'`:e}var pr=new Set(["&&","||","|",";","&",">","<",">>","<<","2>","2>>","1>","1>>"]);function en(e,t=process.platform==="win32"?"windows":"unix"){return pr.has(e)?e:rt(e,t)}function tn(){return process.platform==="win32"?"windows":"unix"}function se(e,t,r=process.platform==="win32"?"windows":"unix"){let n=t.map(o=>en(o,r));return [e,...n].join(" ")}function nn(e){if(e==null)return "";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>nn(t)).join(" ");if(e&&typeof e=="object"){if("raw"in e)return String(e.raw);if("toString"in e&&typeof e.toString=="function")return e.toString();if(e instanceof ReadableStream)throw new Error("ReadableStream expressions are not yet supported")}return String(e)}function mr(e,t,r){return {stdout:e,stderr:t,exitCode:r,text(n="utf-8"){return e.toString(n)},json(){let n=e.toString("utf-8");return JSON.parse(n)},arrayBuffer(){let n=e.buffer;if(n instanceof ArrayBuffer)return n.slice(e.byteOffset,e.byteOffset+e.byteLength);let o=new ArrayBuffer(e.byteLength),s=new Uint8Array(o),a=new Uint8Array(n,e.byteOffset,e.byteLength);return s.set(a),o},bytes(){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)},blob(){let n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return new Blob([n])}}}function ie(e,t={}){let r=K(e);if(r.length===0)throw new Error("Empty shell command");let n=async()=>{let s=await $.run(r,{cwd:t.cwd,env:t.env}),a=mr(Buffer.from(s.stdout,"utf-8"),Buffer.from(s.stderr,"utf-8"),s.code);if(s.code!==0&&!t.nothrow)throw Object.assign(new Error(`Command failed with exit code ${s.code}: ${e}
|
|
21
|
+
${s.stderr}`),{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});return a},o=n();return Object.defineProperty(o,"stdin",{get(){throw new Error("stdin is not yet supported in EasbotShell. Use PKG.spawn for interactive commands.")},enumerable:true}),o.cwd=function(s){return ie(e,{...t,cwd:s})},o.env=function(s){return ie(e,{...t,env:s})},o.quiet=function(){return ie(e,{...t,quiet:true})},o.lines=async function*(){let i=(await n()).text().split(/\r?\n/);for(let l of i)l.trim()&&(yield l);},o.text=async function(s="utf-8"){return (await n()).text(s)},o.json=async function(){return (await n()).json()},o.arrayBuffer=async function(){return (await n()).arrayBuffer()},o.blob=async function(){return (await n()).blob()},o.nothrow=function(){return ie(e,{...t,nothrow:true})},o.throws=function(s){return ie(e,{...t,nothrow:!s})},o}var he=class{constructor(t={}){c(this,"options");this.options=t;}call(t,...r){let n="";for(let o=0;o<t.length;o++)n+=t[o],o<r.length&&r[o]!==void 0&&(n+=nn(r[o]));return ie(n,this.options)}braces(t){let r=t.match(/^(.*?)\{([^}]+)\}(.*)$/);if(!r)return [t];let[,n="",o="",s=""]=r,a=o.split(",").map(l=>l.trim()),i=[];for(let l of a){let d=`${n}${l}${s}`;d.includes("{")?i.push(...this.braces(d)):i.push(d);}return i}escape(t){return process.platform==="win32"?t.replace(/([&|<>^"%])/g,"^$1"):t.replace(/(["\s'$`\\!*?#&;()<>|])/g,"\\$1")}env(t){return ne({...this.options,env:t})}cwd(t){return ne({...this.options,cwd:t})}nothrow(){return ne({...this.options,nothrow:true})}throws(t){return ne({...this.options,nothrow:!t})}};function ne(e={}){let t=new he(e);return new Proxy(t,{apply(r,n,o){return t.call(o[0],...o.slice(1))}})}var rn=ne();function on(e){return e.replace(/\\/g,"/")}function sn(e){return createHash("md5").update(e).digest("hex").slice(0,8)}var Y=new Map,$;(H=>{a.create({service:"pkg"});async function t(k){let g=k?[k]:["npm","pnpm","bun"];for(let f of g){let p=await H.which(f);if(p)return {name:f,path:p}}}H.packageManager=t;async function r(k,g){if(!k)return process.execPath;let f=g?.PATH||process.env.PATH||process.env.Path||"",p=process.env.EASBOT_BIN_PATH,x=p?f+ae.delimiter+p:f,w=sn(x),b=`${k}:${w}`;if(Y.has(b))return Y.get(b);let C=process.platform==="win32"?"where":"which";try{let{spawn:v}=await import('child_process');return new Promise(E=>{let I=v(C,[k],{env:{...process.env,PATH:x},stdio:["pipe","pipe","ignore"],windowsHide:!0}),j="",F="";I.stdout?.on("data",N=>{j+=N.toString();}),I.stderr?.on("data",N=>{F+=N.toString();}),I.on("close",N=>{if(N===0&&j.trim()){let O=j.trim().split(`
|
|
22
|
+
`),B=O.length>0?O[0]?.trim():null;if(B){Y.set(b,B),E(B);return}}Y.set(b,null),E(null);}),setTimeout(()=>{I.kill(),Y.set(b,null),E(null);},5e3);})}catch{return Y.set(b,null),null}}H.which=r;function n(k,g){if(!k)return process.execPath;let f=g?.PATH||process.env.PATH||process.env.Path||"",p=process.env.EASBOT_BIN_PATH,x=p?f+ae.delimiter+p:f,w=sn(x),b=`${k}:${w}`;if(Y.has(b))return Y.get(b);let C=process.platform==="win32"?"where":"which";try{let v=execSync(`${C} ${k}`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"],env:{...process.env,PATH:x},timeout:5e3,windowsHide:!0});if(v.trim()){let E=v.trim().split(`
|
|
23
|
+
`),I=E.length>0?E[0]?.trim():null;if(I)return Y.set(b,I),I}}catch{}return Y.set(b,null),null}H.whichSync=n;function o(){Y.clear();}H.clearWhichCache=o;let s=createRequire(import.meta.url);async function a$2(k,g){try{return g?s.resolve(k,{paths:[g]}):s.resolve(k)}catch(f){throw new Error(`Cannot resolve module "${k}"${g?` from "${g}"`:""}: ${f instanceof Error?f.message:String(f)}`)}}H.resolve=a$2;function i(k){return {get name(){return ae.basename(k)},async exists(){try{return await X.access(k),!0}catch{return false}},async getSize(){try{return (await X.stat(k)).size}catch{return}},async text(){return await X.readFile(k,"utf-8")},textSync(){return Ce.readFileSync(k,"utf-8")},jsonSync(){let g=Ce.readFileSync(k,"utf-8");return JSON.parse(g)},async bytes(){let g=await X.readFile(k);return new Uint8Array(g.buffer,g.byteOffset,g.byteLength)},async arrayBuffer(){let g=await X.readFile(k);return g.buffer.slice(g.byteOffset,g.byteOffset+g.byteLength)},get type(){let g=ae.extname(k).toLowerCase();return {".txt":"text/plain",".html":"text/html",".htm":"text/html",".css":"text/css",".js":"application/javascript",".json":"application/json",".xml":"application/xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".pdf":"application/pdf",".zip":"application/zip",".wav":"audio/wav",".mp3":"audio/mpeg",".mp4":"video/mp4",".webm":"video/webm"}[g]||"application/octet-stream"},async write(g){let f;if(g instanceof Response){let p=await g.arrayBuffer();f=new Uint8Array(p);}else f=g;await X.writeFile(k,f);},async json(){let g=await X.readFile(k,"utf-8");return JSON.parse(g)},async stat(){return await X.stat(k)}}}H.file=i;async function l(k,g,f){let p;if(g instanceof Response){let x=await g.arrayBuffer();p=new Uint8Array(x);}else p=g;await X.writeFile(k,p,f?{mode:f.mode}:void 0);}H.write=l;function d(k,g,f){Ce.writeFileSync(k,g,f?{mode:f.mode}:void 0);}H.writeSync=d;function c$1(k,g="utf-8"){return Ce.readFileSync(k,g)}H.readSync=c$1;function u(k,g){let f,p;if(typeof k=="object"&&"cmd"in k){let v=k;f=v.cmd,p={cwd:v.cwd,env:v.env,stdout:v.stdout,stderr:v.stderr,stdin:v.stdin,signal:v.signal,windowsHide:v.windowsHide,shell:v.shell};}else f=Array.isArray(k)?k:[k],p=g||{};if(!f||f.length===0||!f[0])throw new Error("Spawn command cannot be empty");let x=[p.stdin==="inherit"?"inherit":p.stdin==="null"?"ignore":"pipe",p.stdout==="inherit"?"inherit":p.stdout==="null"?"ignore":"pipe",p.stderr==="inherit"?"inherit":p.stderr==="null"?"ignore":"pipe"],w={cwd:p.cwd,env:p.env?{...process.env,...p.env}:process.env,stdio:x};p.shell!==void 0&&(w.shell=p.shell),process.platform==="win32"&&(w.windowsHide=p.windowsHide??true);let b=spawn(f[0],f.slice(1),w),y;if(p.signal){y=()=>{b.kill();},p.signal.addEventListener("abort",y,{once:true});let v=()=>{y&&(p.signal?.removeEventListener("abort",y),y=void 0);};b.on("close",v),b.on("error",v);}let C=new Promise((v,E)=>{let I=false,j=()=>{I||(I=true,b.removeAllListeners());};if(b.on("close",F=>{j(),v(F??0);}),b.on("error",F=>{j(),E(F);}),p.timeout!==false){let F=p.timeout||3e5;setTimeout(()=>{I||(j(),b.kill("SIGTERM"),E(new Error(`Process timeout after ${F}ms: ${f.join(" ")}`)));},F);}});return {stdout:b.stdout,stderr:b.stderr,stdin:b.stdin,pid:b.pid,exited:C,exitCode:b.exitCode,kill:v=>b.kill(v)}}H.spawn=u;async function m(k,g){let f=g?.stdin??"null",p=g?.stdout??"pipe",x=g?.stderr??"pipe",w=u(k,{cwd:g?.cwd,env:g?.env,stdin:f,stdout:p,stderr:x,windowsHide:g?.windowsHide,shell:g?.shell}),b=[],y=[];p==="pipe"&&w.stdout?.on("data",v=>{b.push(v);}),x==="pipe"&&w.stderr?.on("data",v=>{y.push(v);});let C=g?.timeout&&g.timeout>0?setTimeout(()=>{w.kill("SIGTERM");},g.timeout):void 0;try{let v=await w.exited;return clearTimeout(C),p==="pipe"&&w.stdout?.destroy(),x==="pipe"&&w.stderr?.destroy(),f==="pipe"&&w.stdin?.end(),{code:v,stdout:Buffer.concat(b).toString("utf-8"),stderr:Buffer.concat(y).toString("utf-8")}}catch(v){return clearTimeout(C),p==="pipe"&&w.stdout?.destroy(),x==="pipe"&&w.stderr?.destroy(),f==="pipe"&&w.stdin?.end(),{code:-1,stdout:Buffer.concat(b).toString("utf-8"),stderr:Buffer.concat(y).toString("utf-8")||(v instanceof Error?v.message:String(v))}}}H.run=m;async function S(k,g={},f={}){let p=u(k,{cwd:g.cwd,env:g.env,stdout:"pipe",stderr:"pipe",stdin:"null"}),x="",w="";p.stdout?.on("data",y=>{let C=y.toString("utf-8");x+=C,f.onStdout?.(C);}),p.stderr?.on("data",y=>{let C=y.toString("utf-8");w+=C,f.onStderr?.(C);});let b=g.timeout&&g.timeout>0?setTimeout(()=>{p.kill("SIGTERM");},g.timeout):void 0;try{let y=await p.exited;return clearTimeout(b),f.onExit?.(y),{code:y,stdout:x,stderr:w}}catch(y){clearTimeout(b);let C=y instanceof Error?y.message:String(y);return {code:-1,stdout:x,stderr:w||C}}}H.runWithStream=S;async function P(k){if(typeof k.pipeThrough=="function")try{let x=new TextDecoderStream("utf-8"),b=k.pipeThrough(x).getReader(),y="";try{for(;;){let{done:C,value:v}=await b.read();if(C)break;y+=v;}return y}finally{b.releaseLock();}}catch{}let g=k.getReader(),f=new TextDecoder("utf-8"),p=[];try{for(;;){let{done:x,value:w}=await g.read();if(x)break;p.push(f.decode(w,{stream:!0}));}return p.push(f.decode()),p.join("")}finally{g.releaseLock();}}H.readableStreamToText=P;async function L(k){let g=[];return new Promise((f,p)=>{k.on("data",x=>{typeof x=="string"?g.push(Buffer.from(x)):g.push(x);}),k.on("end",()=>{try{let w=Buffer.concat(g).toString("utf-8");f(w);}catch(x){p(x);}}),k.on("error",x=>{p(x);});})}H.nodeReadableStreamToText=L;function _(k,g=0){let C=new TextEncoder().encode(k),v=C.length,E,I=0;if(v>=16){let O=v-16,B=g+2654435761+2246822519|0,V=g+2246822519|0,W=g+0|0,G=g-2654435761|0;for(;I<=O;)B=j(B,N(C,I)),I+=4,V=j(V,N(C,I)),I+=4,W=j(W,N(C,I)),I+=4,G=j(G,N(C,I)),I+=4;E=F(B,1)+F(V,7)+F(W,12)+F(G,18)|0;}else E=g+374761393|0;for(E=E+v|0;I+4<=v;)E=E+N(C,I)*3266489917|0,E=F(E,17)*668265263|0,I+=4;for(;I<v;)E=E+C[I]*374761393|0,E=F(E,11)*2654435761|0,I++;return E^=E>>>15,E=E*2246822519|0,E^=E>>>13,E=E*3266489917|0,E^=E>>>16,E>>>0;function j(O,B){return O=O+B*2246822519|0,O=F(O,13),O=O*2654435761|0,O}function F(O,B){return O<<B|O>>>32-B|0}function N(O,B){return (O[B]|O[B+1]<<8|O[B+2]<<16|O[B+3]<<24)>>>0}}H.xxHash32=_;function D(k){let g=0;for(let f of k){let p=f.codePointAt(0)||f.charCodeAt(0);p<127?g+=1:p>=4352&&p<=4447||p>=9001&&p<=9002||p>=11904&&p<=42191&&p!==12351||p>=44032&&p<=55203||p>=63744&&p<=64255||p>=65040&&p<=65049||p>=65072&&p<=65135||p>=65280&&p<=65376||p>=65504&&p<=65510?g+=2:g+=1;}return g}H.stringWidth=D;class z{constructor(g){c(this,"pattern");this.pattern=g;}async*scan(g){let f=b.stream(this.pattern,{cwd:g?.cwd,absolute:g?.absolute,follow:g?.followSymlinks,dot:g?.dot,nodir:g?.onlyFiles});for await(let p of f)yield on(p);}*scanSync(g){let f=a$1(this.pattern,{cwd:g?.cwd,absolute:g?.absolute,follow:g?.followSymlinks,dot:g?.dot,nodir:g?.onlyFiles});for(let p of f)yield on(p);}match(g){return minimatch(g,this.pattern)}}H.Glob=z,H.stdin=process.stdin,H.stdout=process.stdout,H.stderr=process.stderr,H.sleep=k=>new Promise(g=>setTimeout(g,k)),H.color=(k,g)=>({black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",brightBlack:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",blink:"\x1B[5m",inverse:"\x1B[7m",hidden:"\x1B[8m",strikethrough:"\x1B[9m",reset:"\x1B[0m"})[k.toLowerCase()]||null,H.hash={xxHash32:H.xxHash32},H.build=Kt.build,H.server=ee,H.nodeWebSocket=createNodeWebSocket,H.restServer=Xe,H.rpcServer=Ke,H.streamingServer=et,H.webSocketServer=Qe;})($||($={}));var yr=$.readableStreamToText;$.nodeReadableStreamToText;$.which;var Sr=$.whichSync;$.spawn;$.run;var ln=200,cn={bash:{login:true,posix:true},dash:{login:true,posix:true},fish:{deny:true,login:true},ksh:{login:true,posix:true},nu:{deny:true},powershell:{ps:true},pwsh:{ps:true},sh:{login:true,posix:true},zsh:{login:true,posix:true}},J;(g=>{let e=a.create({service:"shell"});async function t(f,p){let x=f.pid;if(!(!x||p?.exited?.())){if(process.platform==="win32"){await new Promise(w=>{let b=spawn("taskkill",["/pid",String(x),"/f","/t"],{stdio:"ignore",windowsHide:true});b.once("exit",()=>w()),b.once("error",()=>w());});return}try{process.kill(-x,"SIGTERM"),await setTimeout$1(ln),p?.exited?.()||process.kill(-x,"SIGKILL");}catch{f.kill("SIGTERM"),await setTimeout$1(ln),p?.exited?.()||f.kill("SIGKILL");}}}g.killTree=t;function r(f){if(process.platform!=="win32"||!f.includes("/")&&!f.includes("\\")&&!f.includes(":"))return f;let p=c$1.normalize(f);return P(p)==="bash"&&m()||p}function n(f){return cn[P(f)]}function o(f){return n(f)?.deny!==true}function s(f){return c$1.isAbsolute(f)}function a$1(f){let p=r(f);if(s(p))return c$1.stat(p)?.isFile()?p:void 0;let x=$.whichSync(p);return x?c$1.normalize(x):void 0}function i(){return Array.from(new Set([$.whichSync("pwsh"),$.whichSync("powershell"),m(),process.env.COMSPEC||"cmd.exe"].filter(f=>!!f).map(r)))}async function l(){let f=await c$1.readText("/etc/shells").catch(()=>"");return f?Array.from(new Set(f.split(`
|
|
24
|
+
`).filter(p=>p.trim()&&!p.startsWith("#")))):["/bin/bash","/bin/zsh","/bin/sh"]}function d(f,p){if(f&&(!p?.acceptable||o(f))){let x=a$1(f);if(x)return x}return process.platform==="win32"?i()[0]:S()}g.defaultPreferred=Me(()=>d(process.env.SHELL)),g.defaultAcceptable=Me(()=>d(process.env.SHELL,{acceptable:true}));function m(){if(process.platform!=="win32")return;if(process.env.EASBOT_GIT_BASH_PATH)return c$1.normalize(process.env.EASBOT_GIT_BASH_PATH);let f=$.whichSync("git");if(!f)return;let p=c$1.normalize(ae.join(f,"..","..","bin","bash.exe"));if((c$1.stat(p)?.size??0)>0)return p}g.gitbash=m;function S(){if(process.platform==="win32"){let p=m();return p||"/bin/sh"}if(process.platform==="darwin")return "/bin/zsh";let f=$.whichSync("bash");return f?c$1.normalize(f):"/bin/sh"}function P(f){return ae.posix.basename(c$1.toUnixPath(f)).toLowerCase()}g.name=P;function L(f){return n(f)?.login===true}g.login=L;function _(f){return n(f)?.posix===true}g.posix=_;function D(f){return n(f)?.ps===true}g.ps=D;function z(f){let p=r(f),x=P(p);return {path:p,name:x,acceptable:o(x)}}function pe(f,p,x){let w=P(f),b=K(p),y=se(b[0]??p,b.slice(1));return w==="nu"||w==="fish"?["-c",y]:w==="zsh"?["-l","-c",`
|
|
25
25
|
[[ -f ~/.zshenv ]] && source ~/.zshenv >/dev/null 2>&1 || true
|
|
26
26
|
[[ -f "\${ZDOTDIR:-$HOME}/.zshrc" ]] && source "\${ZDOTDIR:-$HOME}/.zshrc" >/dev/null 2>&1 || true
|
|
27
27
|
cd -- "$1"
|
|
28
|
-
${
|
|
29
|
-
`,"easbot",x]:
|
|
28
|
+
${y}
|
|
29
|
+
`,"easbot",x]:w==="bash"?["-l","-c",`${process.platform==="win32"?`cmd /c chcp 65001 >nul 2>&1 || true
|
|
30
30
|
`:""}shopt -s expand_aliases
|
|
31
31
|
[[ -f ~/.bashrc ]] && source ~/.bashrc >/dev/null 2>&1 || true
|
|
32
32
|
cd -- "$1"
|
|
33
|
-
${
|
|
34
|
-
`,"easbot",x]:/^cmd(\.exe)?$/i.test(
|
|
35
|
-
`)[0];return e.debug(`Shell \u7248\u672C\u83B7\u53D6\u6210\u529F: ${
|
|
36
|
-
${
|
|
37
|
-
`).filter(C=>C.trim()),then:(
|
|
38
|
-
${
|
|
39
|
-
`).filter(
|
|
40
|
-
`):t;for(let n=0;n<r.length;n++){let o=r[n];this.parseRule(o,n+1);}return this}parseRule(t,r){let n=t;if(n.length===0||n.startsWith("#"))return;let s=n.startsWith("!");if(s&&(n=n.slice(1)),n=n.trimEnd(),n.length===0)return;if(n.startsWith("\\#")){n=n.slice(1);return}if(n.startsWith("#"))return;let i=n.endsWith("/");if(i&&(n=n.slice(0,-1)),n.length===0)return;let l=this.patternToRegex(n);l&&this.rules.push({pattern:n,regex:l,negative:s,isDirectory:i,original:t,lineNumber:r});}ignores(t,r){let n=this.normalizePath(t),o=r??t.endsWith("/"),s=this.checkIgnore(n,o);return this.debug&&console.log(`Ignore.ignores("${t}", isDirectory=${o}) => ${s}`),s}checkIgnore(t,r){let n=false;for(let o of this.rules)o.isDirectory&&!r||o.regex.test(t)&&(o.negative?n=false:n=true);return n}filter(t){return t.filter(r=>!this.ignores(r))}createFilter(){return t=>!this.ignores(t)}patternToRegex(t){let r=[],n=0,o=t.length;for(;n<o;){let d=t[n];if(d==="\\")if(n+1<o){let c=t[n+1];r.push(this.escapeRegexChar(c)),n+=2;continue}else {r.push("\\\\"),n++;continue}if(d==="*")if(n+1<o&&t[n+1]==="*")if(n+2<o&&t[n+2]==="/")if(n===0||t[n-1]==="/")if(n+3>=o){r.push(".*"),n+=3;continue}else {r.push(".*"),n+=3;continue}else {r.push(".*"),n+=3;continue}else if(n===0||t[n-1]==="/")if(n+2>=o){r.push(".*"),n+=2;continue}else {r.push("(?:/.*)*"),n+=2;continue}else {r.push(".*"),n+=2;continue}else {r.push("[^/]*"),n++;continue}if(d==="?"){r.push("[^/]"),n++;continue}if(d==="["){let c=this.findMatchingBracket(t,n);if(c!==-1){let u=t.slice(n,c+1);(u.startsWith("[!")||u.startsWith("[^"))&&(u="[^"+u.slice(2)),this.ignorecase&&(u=u.toLowerCase()),r.push(u),n=c+1;continue}}if(d==="/"){r.push("/"),n++;continue}if(".+$^{}|()".includes(d)){r.push("\\"+d),n++;continue}if(this.ignorecase&&d>="A"&&d<="Z"){r.push("["+d.toLowerCase()+d+"]"),n++;continue}r.push(d),n++;}let s=r.join(""),a=s.startsWith("/"),i=s.endsWith("/")&&!s.endsWith("\\/");a||(s="(?:.*/)?"+s),i&&(s=s.slice(0,-1)),!i&&!s.endsWith("(?:/.*)*")&&(s="(?:"+s+")(?:/.*)?");let l=this.ignorecase?"i":"";try{return new RegExp("^"+s+"$",l)}catch(d){return this.debug&&console.error(`Failed to create regex for pattern "${t}":`,d),null}}escapeRegexChar(t){return "\\[]{}().+^$|".includes(t)?"\\"+t:t}findMatchingBracket(t,r){let n=r+1,o=t.length;for((n>=o||t[n]==="!"||t[n]==="^")&&n++;n<o;){let s=t[n];if(s==="\\"&&n+1<o){n+=2;continue}if(s==="]")return n;if(n+2<o&&t[n+1]==="-"&&t[n+2]!=="]"){n+=3;continue}n++;}return -1}normalizePath(t){let r=t.replace(/\\/g,"/");if(r==="/")return "";for(;r.startsWith("./");)r=r.slice(2);return r}};k();function
|
|
41
|
-
`?o=i:/\s/.test(l)&&(s=i));}}return {lastNewline:o,lastWhitespace:s}}function
|
|
33
|
+
${y}
|
|
34
|
+
`,"easbot",x]:/^cmd(\.exe)?$/i.test(w)?["/c",`chcp 65001 >nul 2>&1 && ${y}`]:D(w)?["-NoProfile","-Command",`[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; ${y}`]:["-c",y]}g.args=pe;function We(f){return f?d(f):(0, g.defaultPreferred)()}g.preferred=We;function Bn(f){return f?d(f,{acceptable:true}):(0, g.defaultAcceptable)()}g.acceptable=Bn;function Fn(){g.defaultPreferred.reset(),g.defaultAcceptable.reset();}g.reset=Fn;async function $n(){return (process.platform==="win32"?i():await l()).filter(p=>a$1(p)).map(z)}g.list=$n;function Ue(f){return cn[P(f)]}g.metaInfo=Ue;function An(f){return /[|&;<>()$`!#]/.test(f)}g.needsShell=An;function Ln(){return process.platform==="win32"?i():["/bin/bash","/bin/zsh","/bin/sh"]}g.platformShells=Ln;function _n(f){return f?!!a$1(f):false}g.isValid=_n;async function jn(f){let p=a$1(f);if(!p)return;let x=P(p);if(!/^cmd(\.exe)?$/i.test(x))try{let w;D(x)?w=["-NoProfile","-Command","$PSVersionTable.PSVersion.ToString()"]:w=["--version"],e.debug(`\u83B7\u53D6 Shell \u7248\u672C: ${p}`,{shell:p,args:w});let b=await $.run([p,...w]);if(b.code===0){let y=b.stdout.trim().split(`
|
|
35
|
+
`)[0];return e.debug(`Shell \u7248\u672C\u83B7\u53D6\u6210\u529F: ${y}`),y}e.debug(`Shell \u7248\u672C\u83B7\u53D6\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${b.code}`,{stderr:b.stderr});}catch(w){e.debug(`Shell \u7248\u672C\u83B7\u53D6\u5F02\u5E38: ${w}`);}}g.version=jn;class qe extends Error{constructor(x,w,b,y){super(x);c(this,"message",x);c(this,"pkg",w);c(this,"version",b);c(this,"originalError",y);this.name="InstallFailedError";}}g.InstallFailedError=qe;async function Nn(f,p="latest",x){let{Lock:w}=await import('./chunks/lock-EGXJVIO5.mjs'),{Filesystem:b}=await import('./chunks/filesystem-IEDC2UL2.mjs'),{PackageRegistry:y}=await import('./chunks/registry-QKUDHNX5.mjs');x=x??process.env.EASBOT_CACHE_PATH??ae.join(".easbot","cache");let C=await w.write("pkg-install");try{let v=ae.posix.join(x,"node_modules",f),E=ae.posix.join(x,"package.json"),j=(await b.readJson(E).catch(async()=>{let U={dependencies:{}};return await b.writeJson(E,U),U})).dependencies??{},F=await b.exists(v),N=j[f],O=!1;if(!F||!N)O=!0;else {if(p!=="latest"&&N===p)return v;if(p==="latest"){if(!await y.isOutdated(f,N,x))return v;e.info("Cached version is outdated, proceeding with install",{pkg:f,cachedVersion:N}),O=!0;}}if(!O)return v;let B=g.acceptable(process.platform==="win32"?"cmd":void 0)??S(),V=`${f}@${p}`;e.info("installing package",{pkg:f,version:p,cache:x,shell:B});let W=await $.packageManager();if(!W)throw new qe("No package manager found (npm, pnpm, bun)",f,p,"No package manager available");let G=W.name,me=G==="pnpm"?"add":"install",Ve=`${W.name} ${me} --save-exact ${V}`;e.info(`Using ${G} to install package`,{pkg:f,version:p,shell:B,pmPath:W.path});try{let U=await g.run(B,Ve,{cwd:x,timeout:6e5,windowsHide:!0});if(U.code!==0)throw new Error(`Package manager exited with code ${U.code}: ${U.stderr}`);e.info(`Successfully installed ${f}@${p} with ${G}`);}catch(U){let It=U instanceof Error?U:new Error(String(U));if(!await b.exists(v))throw new qe(`Failed to install ${f}@${p}`,f,p,It.message);e.warn("Package install failed but module exists, continuing",{error:It.message});}let Ge=p;p==="latest"&&(Ge=(await b.readJson(ae.join(v,"package.json")).catch(()=>({})))?.version??"unknown");let Te=await b.readJson(E);return Te.dependencies=Te.dependencies??{},Te.dependencies[f]=Ge,await b.writeJson(E,Te),e.info("Package installation completed",{pkg:f,version:Ge,path:v}),v}finally{C[Symbol.dispose]();}}g.install=Nn;async function Dn(f,p,x){let w=f?g.acceptable(f)??S():g.acceptable()??S(),b=x?.cwd??process.cwd(),y=g.args(w,p,b);e.debug(`run shell process: ${w} ${y.join(" ")}`,{command:p,cwd:b});let{windowsHide:C,env:v,...E}=x??{},I={...process.env,LANG:"en_US.UTF-8",LC_ALL:"en_US.UTF-8",LC_CTYPE:"en_US.UTF-8",...v};process.platform==="win32"&&(I.CHCP="65001");let{stdin:j,stdout:F,stderr:N,timeout:O,signal:B,...V}=E??{},W={...V,cwd:b,env:I,windowsHide:process.platform==="win32"?C??true:void 0,shell:V.shell},G=P(w),me=/^cmd(\.exe)?$/i.test(G),Ve=process.platform==="win32"&&me?"cmd":w;return $.run([Ve,...y],W)}g.run=Dn;function H(f,p,x){let w=f?g.acceptable(f)??S():g.acceptable()??S(),b=x?.cwd??process.cwd(),y=g.args(w,p,b);e.debug(`Spawn shell process: ${w} ${y.join(" ")}`,{command:p,cwd:b});let{windowsHide:C,env:v,...E}=x??{},I={...process.env,LANG:"en_US.UTF-8",LC_ALL:"en_US.UTF-8",LC_CTYPE:"en_US.UTF-8",...v};process.platform==="win32"&&(I.CHCP="65001");let{stdin:j,stdout:F,stderr:N,timeout:O,signal:B,...V}=E??{},W=P(w),G=/^cmd(\.exe)?$/i.test(W),me={...V,cwd:b,env:I,windowsHide:process.platform==="win32"?C??true:void 0,shell:V.shell};return $.spawn([G?"cmd":w,...y],me)}g.spawn=H;function k(f,...p){let x=f.reduce((b,y,C)=>b+y+(p[C]??""),""),w=(b={})=>({quiet:()=>w({...b,quiet:true}),nothrow:()=>w({...b,nothrow:true}),cwd:y=>w({...b,cwd:y}),env:y=>w({...b,env:y}),stdin:y=>w({...b,stdin:y}),stdout:y=>w({...b,stdout:y}),stderr:y=>w({...b,stderr:y}),text:async()=>{let y=K(x.trim());if(y.length===0)throw new Error("Empty command");let C=y[0]??"",v=P(C),E=/^cmd(\.exe)?$/i.test(v),I=process.platform==="win32"&&E?"cmd":Ue(C)?C:void 0,j=se(C,y.slice(1)),F=await g.run(I,j,{cwd:b.cwd,env:b.env,stdin:b.stdin,stdout:b.stdout,stderr:b.stderr,windowsHide:process.platform==="win32"?b.windowsHide??true:void 0,shell:b.shell});if(F.code!==0&&!b.nothrow)throw new Error(`Command failed with exit code ${F.code}: ${x}
|
|
36
|
+
${F.stderr}`);return F.stdout},lines:async()=>(await w(b).text()).split(`
|
|
37
|
+
`).filter(C=>C.trim()),then:(y,C)=>{let v=K(x.trim()),E=v[0]??"",I=P(E),j=/^cmd(\.exe)?$/i.test(I),F=process.platform==="win32"&&j?"cmd":Ue(E)?E:void 0,N=se(E,v.slice(1));return g.run(F,N,{cwd:b.cwd,env:b.env,stdin:b.stdin,stdout:b.stdout,stderr:b.stderr,windowsHide:process.platform==="win32"?b.windowsHide??true:void 0,shell:b.shell}).then(O=>{if(O.code!==0&&!b.nothrow){let B=new Error(`Command failed with exit code ${O.code}: ${x}
|
|
38
|
+
${O.stderr}`);if(C){C(B);return}throw B}return y({exitCode:O.code,stdout:new TextEncoder().encode(O.stdout),stderr:new TextEncoder().encode(O.stderr),text:()=>O.stdout,lines:()=>O.stdout.split(`
|
|
39
|
+
`).filter(B=>B.trim())})},C)}});return w()}g.$=k;})(J||(J={}));var vr=J.$;k();function ot(e,t=true){let r=typeof e=="number"?new Date(e):e,n=r.getTimezoneOffset(),o=Math.floor(Math.abs(n)/60),s=Math.abs(n)%60,i=`${n<=0?"+":"-"}${String(o).padStart(2,"0")}:${String(s).padStart(2,"0")}`,l=r.getFullYear(),d=String(r.getMonth()+1).padStart(2,"0"),c=String(r.getDate()).padStart(2,"0"),u=String(r.getHours()).padStart(2,"0"),m=String(r.getMinutes()).padStart(2,"0"),S=String(r.getSeconds()).padStart(2,"0"),P=`${l}-${d}-${c}T${u}:${m}:${S}`;if(t){let L=String(r.getMilliseconds()).padStart(3,"0");P+=`.${L}`;}return P+=i,P}function Tr(e){return ot(e,false)}function un(){return Date.now()}function Mr(e=true){return ot(un(),e)}function Rr(e){return e.includes("+")||e.includes("-")?new Date(e):new Date(e)}function Pr(e){let t=typeof e=="number"?new Date(e):e,r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),i=String(t.getSeconds()).padStart(2,"0");return `${r}-${n}-${o}T${s}:${a}:${i}`}function Er(e=new Date){let t=e.getTimezoneOffset(),r=Math.floor(Math.abs(t)/60),n=Math.abs(t)%60;return `${t<=0?"+":"-"}${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`}k();var be=class be extends Error{static create(t,r){var s;let n=Ie.object({name:Ie.literal(t),data:r}).meta({ref:t}),o=(s=class extends be{constructor(i,l){super(t,l);c(this,"data",i);c(this,"name",t);this.name=t;}static isInstance(i){return typeof i=="object"&&"name"in i&&i.name===t}schema(){return n}toObject(){return {name:t,data:this.data}}},c(s,"Schema",n),s);return Object.defineProperty(o,"name",{value:t}),o}};c(be,"Unknown",be.create("UnknownError",Ie.object({message:Ie.string()})));var st=be;k();var it;(t=>{function e(r){return new at(r)}t.create=e;})(it||(it={}));var at=class{constructor(t){c(this,"rules",[]);c(this,"ignorecase");c(this,"debug");this.ignorecase=t?.ignorecase??false,this.debug=t?.debug??false;}add(t){let r=typeof t=="string"?t.split(`
|
|
40
|
+
`):t;for(let n=0;n<r.length;n++){let o=r[n];this.parseRule(o,n+1);}return this}parseRule(t,r){let n=t;if(n.length===0||n.startsWith("#"))return;let s=n.startsWith("!");if(s&&(n=n.slice(1)),n=n.trimEnd(),n.length===0)return;if(n.startsWith("\\#")){n=n.slice(1);return}if(n.startsWith("#"))return;let i=n.endsWith("/");if(i&&(n=n.slice(0,-1)),n.length===0)return;let l=this.patternToRegex(n);l&&this.rules.push({pattern:n,regex:l,negative:s,isDirectory:i,original:t,lineNumber:r});}ignores(t,r){let n=this.normalizePath(t),o=r??t.endsWith("/"),s=this.checkIgnore(n,o);return this.debug&&console.log(`Ignore.ignores("${t}", isDirectory=${o}) => ${s}`),s}checkIgnore(t,r){let n=false;for(let o of this.rules)o.isDirectory&&!r||o.regex.test(t)&&(o.negative?n=false:n=true);return n}filter(t){return t.filter(r=>!this.ignores(r))}createFilter(){return t=>!this.ignores(t)}patternToRegex(t){let r=[],n=0,o=t.length;for(;n<o;){let d=t[n];if(d==="\\")if(n+1<o){let c=t[n+1];r.push(this.escapeRegexChar(c)),n+=2;continue}else {r.push("\\\\"),n++;continue}if(d==="*")if(n+1<o&&t[n+1]==="*")if(n+2<o&&t[n+2]==="/")if(n===0||t[n-1]==="/")if(n+3>=o){r.push(".*"),n+=3;continue}else {r.push(".*"),n+=3;continue}else {r.push(".*"),n+=3;continue}else if(n===0||t[n-1]==="/")if(n+2>=o){r.push(".*"),n+=2;continue}else {r.push("(?:/.*)*"),n+=2;continue}else {r.push(".*"),n+=2;continue}else {r.push("[^/]*"),n++;continue}if(d==="?"){r.push("[^/]"),n++;continue}if(d==="["){let c=this.findMatchingBracket(t,n);if(c!==-1){let u=t.slice(n,c+1);(u.startsWith("[!")||u.startsWith("[^"))&&(u="[^"+u.slice(2)),this.ignorecase&&(u=u.toLowerCase()),r.push(u),n=c+1;continue}}if(d==="/"){r.push("/"),n++;continue}if(".+$^{}|()".includes(d)){r.push("\\"+d),n++;continue}if(this.ignorecase&&d>="A"&&d<="Z"){r.push("["+d.toLowerCase()+d+"]"),n++;continue}r.push(d),n++;}let s=r.join(""),a=s.startsWith("/"),i=s.endsWith("/")&&!s.endsWith("\\/");a||(s="(?:.*/)?"+s),i&&(s=s.slice(0,-1)),!i&&!s.endsWith("(?:/.*)*")&&(s="(?:"+s+")(?:/.*)?");let l=this.ignorecase?"i":"";try{return new RegExp("^"+s+"$",l)}catch(d){return this.debug&&console.error(`Failed to create regex for pattern "${t}":`,d),null}}escapeRegexChar(t){return "\\[]{}().+^$|".includes(t)?"\\"+t:t}findMatchingBracket(t,r){let n=r+1,o=t.length;for((n>=o||t[n]==="!"||t[n]==="^")&&n++;n<o;){let s=t[n];if(s==="\\"&&n+1<o){n+=2;continue}if(s==="]")return n;if(n+2<o&&t[n+1]==="-"&&t[n+2]!=="]"){n+=3;continue}n++;}return -1}normalizePath(t){let r=t.replace(/\\/g,"/");if(r==="/")return "";for(;r.startsWith("./");)r=r.slice(2);return r}};k();function dn(e,t){let r=n=>{let o;try{o=e.parse(n);}catch(s){throw console.trace("schema validation failure stack trace:"),s instanceof z.ZodError&&console.error("schema validation issues:",JSON.stringify(s.issues,null,2)),s}return t(o)};return r.force=n=>t(n),r.schema=e,r}var Ir=dn,lt;(t=>t.fn=dn)(lt||(lt={}));k();function $r(){let r=ae.join(process.cwd(),".env");existsSync(r)&&config({path:r,override:true,debug:false,encoding:"utf-8",quiet:true});}k();async function Ar(e,t){if(process.env.EASBOT_CLIENT==="acp")try{let s=process.platform==="win32"?"cmd":void 0,a=J.spawn(s,`git ${e.join(" ")}`,{stdin:void 0,stdout:"pipe",stderr:"pipe",cwd:t.cwd,env:t.env?{...process.env,...t.env}:process.env}),[i,l,d]=await Promise.all([a.exited,new Response(a.stdout).arrayBuffer(),new Response(a.stderr).arrayBuffer()]),c=Buffer.from(l),u=Buffer.from(d);return {exitCode:i,text:()=>c.toString(),stdout:c,stderr:u}}catch(s){let a=Buffer.from(s instanceof Error?s.message:String(s));return {exitCode:1,text:()=>"",stdout:Buffer.alloc(0),stderr:a}}let r=t.env?{...process.env,...t.env}:void 0,n=J.$`git ${e.join(" ")}`.quiet().nothrow().cwd(t.cwd);r&&(n=n.env(r));let o=await n;return {exitCode:o.exitCode,text:()=>o.text(),stdout:o.stdout,stderr:o.stderr}}k();function pn(e){return e?dirname(fileURLToPath(e)):typeof i<"u"?i:process.cwd()}function fn(e,t,r=3){function n(o,s){if(s>r||!existsSync(o))return null;try{let a=readdirSync(o);for(let i of a){let l=join(o,i);try{let d=statSync(l);if(d.isFile()&&l.endsWith(t))return l;if(d.isDirectory()&&s<r){let c=n(l,s+1);if(c)return c}}catch{}}}catch{}return null}return n(e,0)}function mn(e,t){let r=join(e,t);if(existsSync(r))return r;let n=t.split("/").pop()||t,o=e;for(let s=0;s<5;s++){let a=join(o,"assets","txt");if(existsSync(a)){let d=fn(a,n,5);if(d)return d}let i=join(o,"dist","assets","txt");if(existsSync(i)){let d=fn(i,n,5);if(d)return d}let l=join(o,"..");if(l===o)break;o=l;}return r}function Dr(e,t){return oe.lazy(()=>{try{let r=pn(t),n=mn(r,e);return $.file(n).textSync()}catch(r){throw console.error(`Failed to load text file: ${e}`,r),r}})}function zr(e,t){return oe.lazy(async()=>{try{let r=pn(t),n=mn(r,e);return await $.file(n).text()}catch(r){throw console.error(`Failed to load text file: ${e}`,r),r}})}k();function Hr(e){return e()}k();function Wr(e){if(!e||typeof e!="string")return {provider:"",model:""};let t=e.indexOf("/");return t===-1?{provider:"",model:e}:{provider:e.substring(0,t),model:e.substring(t+1)}}k();k();k();function ct(e,t,r,n=()=>true){let o=-1,s=-1,a=0;for(let i=t;i<r;i++){if(!n(i))continue;let l=e[i];if(l){if(l==="("){a+=1;continue}if(l===")"&&a>0){a-=1;continue}a===0&&(l===`
|
|
41
|
+
`?o=i:/\s/.test(l)&&(s=i));}}return {lastNewline:o,lastWhitespace:s}}function Ur(e,t){if(!e)return [];if(t<=0)return [e];if(e.length<=t)return [e]}function le(e,t,r){try{let n=z.string().parse(e),o=z.number().int().parse(t),s=Ur(n,o);if(s)return s;let a=ut(n,o,i=>{let{lastNewline:l,lastWhitespace:d}=ct(i,0,i.length);return l>0?l:d});return r?.minLength&&r.minLength>0&&(a=hn(a,r.minLength)),a}catch(n){return console.warn("Invalid input for chunkText:",n),typeof e=="string"&&e.length>0?[e]:[]}}function hn(e,t){if(e.length<=1||t<=0)return e;let r=[],n=e[0]??"";for(let o=1;o<e.length;o++){let s=e[o]??"";n.length<t?n=n+`
|
|
42
42
|
|
|
43
43
|
`+s:(r.push(n),n=s);}if(n.length>0)if(n.length<t&&r.length>0){let o=r.pop();r.push(o+`
|
|
44
44
|
|
|
45
|
-
`+n);}else r.push(n);return r}function
|
|
45
|
+
`+n);}else r.push(n);return r}function ut(e,t,r){if(!e)return [];if(t<=0||e.length<=t)return [e];let n=[],o=e;for(;o.length>t;){let s=o.slice(0,t),a=r(s),i=Number.isFinite(a)&&a>0&&a<=t?a:t,d=o.slice(0,i).trimEnd();d.length>0&&n.push(d);let c=i<o.length&&o[i]!==void 0&&/\s/.test(o[i]),u=Math.min(o.length,i+(c?1:0));o=o.slice(u).trimStart();}return o.length>0&&n.push(o),n}k();var dt=z.enum(["bold","italic","strikethrough","code","code_block","spoiler","blockquote"]),bn=z.object({start:z.number().int().min(0),end:z.number().int().min(0),style:dt}).strict().refine(e=>e.end>=e.start,{message:"end must be greater than or equal to start"}),xn=z.object({start:z.number().int().min(0),end:z.number().int().min(0),href:z.string().min(1)}).strict().refine(e=>e.end>=e.start,{message:"end must be greater than or equal to start"}),we=z.object({text:z.string(),styles:z.array(bn),links:z.array(xn)}).strict(),ye=z.enum(["off","bullets","code"]),Be=z.object({linkify:z.boolean().default(true),enableSpoilers:z.boolean().default(false),headingStyle:z.enum(["none","bold"]).default("none"),blockquotePrefix:z.string().default(""),autolink:z.boolean().default(true),tableMode:ye.default("off")}).partial().default({}),wn=z.object({open:z.string(),close:z.string()}).strict(),ft=z.object({styleMarkers:z.record(dt,wn).optional(),escapeText:z.any().optional(),buildLink:z.any().optional()}).strict();z.object({start:z.number().int().min(0),end:z.number().int().min(0),open:z.string(),close:z.string()}).strict();var pt=z.object({indentSize:z.number().int().min(1).default(2),listMarker:z.enum(["\u2022","-","*"]).default("\u2022"),codeBlockMarker:z.enum(["```","~~~"]).default("```"),preserveFrontmatter:z.boolean().default(true)}).strict(),mt=z.record(z.string(),z.string()),Fe=z.object({open:z.boolean(),ticks:z.number().int().min(0)}).strict();z.object({inlineState:Fe,isInside:z.any()}).strict();z.object({start:z.number().int().min(0),end:z.number().int().min(0),openLine:z.string(),marker:z.string(),indent:z.string()}).strict();z.object({tables:ye.optional()}).strict();function Zr(e){let t=new Jr({html:false,linkify:e.linkify??true,breaks:false,typographer:false});return t.enable("strikethrough"),e.tableMode&&e.tableMode!=="off"?t.enable("table"):t.disable("table"),e.autolink===false&&t.disable("autolink"),t}function yn(e,t){if(e.attrGet)return e.attrGet(t);if(e.attrs){for(let[r,n]of e.attrs)if(r===t)return n}return null}function gt(e,t){return {...e,type:"text",content:t,children:void 0}}function Kr(e){for(let t of e)t.children&&t.children.length>0&&(t.children=Xr(t.children));}function Xr(e){let t=0;for(let a of e){if(a.type!=="text")continue;let i=a.content??"",l=0;for(;l<i.length;){let d=i.indexOf("||",l);if(d===-1)break;t+=1,l=d+2;}}if(t<2)return e;let r=t-t%2,n=[],o={spoilerOpen:false},s=0;for(let a of e){if(a.type!=="text"){n.push(a);continue}let i=a.content??"";if(!i.includes("||")){n.push(a);continue}let l=0;for(;l<i.length;){let d=i.indexOf("||",l);if(d===-1){l<i.length&&n.push(gt(a,i.slice(l)));break}if(s>=r){n.push(gt(a,i.slice(l)));break}d>l&&n.push(gt(a,i.slice(l,d))),s+=1,o.spoilerOpen=!o.spoilerOpen,n.push({type:o.spoilerOpen?"spoiler_open":"spoiler_close"}),l=d+2;}}return n}function Qr(){return {text:"",styles:[],openStyles:[],links:[],linkStack:[]}}function re(e){return e.table?.currentCell??e}function $e(e,t){if(!t)return;let r=re(e);r.text+=t;}function ce(e,t){let r=re(e);r.openStyles.push({style:t,start:r.text.length});}function ue(e,t){let r=re(e);for(let n=r.openStyles.length-1;n>=0;n-=1){let o=r.openStyles[n];if(o?.style===t){let s=o.start;r.openStyles.splice(n,1);let a=r.text.length;a>s&&r.styles.push({start:s,end:a,style:t});return}}}function Sn(e){e.env.listStack.length>0||e.table||(e.text+=`
|
|
46
46
|
|
|
47
|
-
`);}function
|
|
48
|
-
`);}function
|
|
49
|
-
`;}for(let a=1;a<o.length;a++)
|
|
50
|
-
`;}else for(let o of r){for(let s=0;s<o.length;s++)
|
|
51
|
-
`;}}function
|
|
47
|
+
`);}function eo(e){let t=e.env.listStack,r=t[t.length-1];if(!r)return;r.index+=1;let n=" ".repeat(Math.max(0,t.length-1)),o=r.type==="ordered"?`${r.index}. `:"\u2022 ";e.text+=`${n}${o}`;}function to(e,t){if(!t)return;let r=re(e),n=r.text.length;r.text+=t,r.styles.push({start:n,end:n+t.length,style:"code"});}function no(e,t){let r=t??"",n=re(e),o=n.text.length;n.text+=r,n.styles.push({start:o,end:o+r.length,style:"code_block"});}function ro(e){let t=re(e),r=t.linkStack.pop();if(!r?.href)return;let n=r.href.trim();if(!n)return;let o=r.labelStart,s=t.text.length;if(s<=o){t.links.push({start:o,end:s,href:n});return}t.links.push({start:o,end:s,href:n});}function oo(){return {headers:[],rows:[],currentRow:[],currentCell:null,inHeader:false}}function so(e){return vn(e),{text:e.text,styles:e.styles,links:e.links}}function Ae(e){let t=e.text,r=0,n=t.length;for(;r<n&&/\s/.test(t[r]??"");)r+=1;for(;n>r&&/\s/.test(t[n-1]??"");)n-=1;if(r===0&&n===t.length)return e;let o=t.slice(r,n),s=o.length,a=[];for(let l of e.styles){let d=Math.max(0,l.start-r),c=Math.min(s,l.end-r);c>d&&a.push({start:d,end:c,style:l.style});}let i=[];for(let l of e.links){let d=Math.max(0,l.start-r),c=Math.min(s,l.end-r);c>d&&i.push({start:d,end:c,href:l.href});}return {text:o,styles:a,links:i}}function ht(e,t){if(!t.text)return;let r=e.text.length;e.text+=t.text;for(let n of t.styles)e.styles.push({start:r+n.start,end:r+n.end,style:n.style});for(let n of t.links)e.links.push({start:r+n.start,end:r+n.end,href:n.href});}function io(e,t){t.text&&(e.text+=t.text);}function kn(e,t){let{header:r,value:n,columnIndex:o,includeColumnFallback:s}=t;n?.text&&(e.text+="\u2022 ",r?.text?(ht(e,r),e.text+=": "):s&&(e.text+=`Column ${o}: `),ht(e,n),e.text+=`
|
|
48
|
+
`);}function ao(e){if(!e.table)return;let t=e.table.headers.map(Ae),r=e.table.rows.map(o=>o.map(Ae));if(t.length===0&&r.length===0)return;if(t.length>1&&r.length>0)for(let o of r){if(o.length===0)continue;let s=o[0];if(s?.text){let a=e.text.length;ht(e,s);let i=e.text.length;i>a&&e.styles.push({start:a,end:i,style:"bold"}),e.text+=`
|
|
49
|
+
`;}for(let a=1;a<o.length;a++)kn(e,{header:t[a],value:o[a],columnIndex:a,includeColumnFallback:true});e.text+=`
|
|
50
|
+
`;}else for(let o of r){for(let s=0;s<o.length;s++)kn(e,{header:t[s],value:o[s],columnIndex:s,includeColumnFallback:false});e.text+=`
|
|
51
|
+
`;}}function lo(e){if(!e.table)return;let t=e.table.headers.map(Ae),r=e.table.rows.map(c=>c.map(Ae)),n=Math.max(t.length,...r.map(c=>c.length));if(n===0)return;let o=Array.from({length:n},()=>0),s=c=>{for(let u=0;u<n;u+=1){let S=c[u]?.text.length??0;(o[u]??0)<S&&(o[u]=S);}};s(t);for(let c of r)s(c);let a=e.text.length,i=c=>{e.text+="|";for(let u=0;u<n;u+=1){e.text+=" ";let m=c[u];m&&io(e,m);let S=m?.text.length??0,L=(o[u]??0)-S;L>0&&(e.text+=" ".repeat(L)),e.text+=" |";}e.text+=`
|
|
52
52
|
`;},l=()=>{e.text+="|";for(let c=0;c<n;c+=1){let u=o[c]??0,m=Math.max(3,u);e.text+=` ${"-".repeat(m)} |`;}e.text+=`
|
|
53
|
-
`;};i(t),l();for(let c of r)i(c);let d=e.text.length;d>a&&e.styles.push({start:a,end:d,style:"code_block"});}function
|
|
54
|
-
`);break;case "paragraph_close":
|
|
53
|
+
`;};i(t),l();for(let c of r)i(c);let d=e.text.length;d>a&&e.styles.push({start:a,end:d,style:"code_block"});}function bt(e,t){for(let r of e)switch(r.type){case "inline":r.children&&bt(r.children,t);break;case "text":$e(t,r.content??"");break;case "em_open":ce(t,"italic");break;case "em_close":ue(t,"italic");break;case "strong_open":ce(t,"bold");break;case "strong_close":ue(t,"bold");break;case "s_open":ce(t,"strikethrough");break;case "s_close":ue(t,"strikethrough");break;case "code_inline":to(t,r.content??"");break;case "spoiler_open":t.enableSpoilers&&ce(t,"spoiler");break;case "spoiler_close":t.enableSpoilers&&ue(t,"spoiler");break;case "link_open":{let n=yn(r,"href")??"",o=re(t);o.linkStack.push({href:n,labelStart:o.text.length});break}case "link_close":ro(t);break;case "image":$e(t,r.content??"");break;case "softbreak":case "hardbreak":$e(t,`
|
|
54
|
+
`);break;case "paragraph_close":Sn(t);break;case "heading_open":t.headingStyle==="bold"&&ce(t,"bold");break;case "heading_close":t.headingStyle==="bold"&&ue(t,"bold"),Sn(t);break;case "blockquote_open":t.blockquotePrefix&&(t.text+=t.blockquotePrefix),ce(t,"blockquote");break;case "blockquote_close":ue(t,"blockquote");break;case "bullet_list_open":t.env.listStack.length>0&&(t.text+=`
|
|
55
55
|
`),t.env.listStack.push({type:"bullet",index:0});break;case "bullet_list_close":t.env.listStack.pop(),t.env.listStack.length===0&&(t.text+=`
|
|
56
56
|
`);break;case "ordered_list_open":{t.env.listStack.length>0&&(t.text+=`
|
|
57
|
-
`);let n=Number(
|
|
58
|
-
`);break;case "list_item_open":
|
|
57
|
+
`);let n=Number(yn(r,"start")??"1");t.env.listStack.push({type:"ordered",index:n-1});break}case "ordered_list_close":t.env.listStack.pop(),t.env.listStack.length===0&&(t.text+=`
|
|
58
|
+
`);break;case "list_item_open":eo(t);break;case "list_item_close":t.text.endsWith(`
|
|
59
59
|
`)||(t.text+=`
|
|
60
|
-
`);break;case "code_block":case "fence":
|
|
60
|
+
`);break;case "code_block":case "fence":no(t,r.content??"");break;case "html_block":case "html_inline":$e(t,r.content??"");break;case "table_open":t.tableMode!=="off"&&(t.table=oo(),t.hasTables=true);break;case "table_close":t.table&&(t.tableMode==="bullets"?ao(t):t.tableMode==="code"&&lo(t)),t.table=null;break;case "thead_open":t.table&&(t.table.inHeader=true);break;case "thead_close":t.table&&(t.table.inHeader=false);break;case "tbody_open":case "tbody_close":break;case "tr_open":t.table&&(t.table.currentRow=[]);break;case "tr_close":t.table&&(t.table.inHeader?t.table.headers=t.table.currentRow:t.table.rows.push(t.table.currentRow),t.table.currentRow=[]);break;case "th_open":case "td_open":t.table&&(t.table.currentCell=Qr());break;case "th_close":case "td_close":t.table?.currentCell&&(t.table.currentRow.push(so(t.table.currentCell)),t.table.currentCell=null);break;case "hr":t.text+=`\u2500\u2500\u2500
|
|
61
61
|
|
|
62
|
-
`;break;default:r.children&&
|
|
63
|
-
`);let
|
|
62
|
+
`;break;default:r.children&&bt(r.children,t);break}}function vn(e){for(let t=e.openStyles.length-1;t>=0;t-=1){let r=e.openStyles[t];if(!r)continue;let n=e.text.length;n>r.start&&e.styles.push({start:r.start,end:n,style:r.style});}e.openStyles=[];}function co(e,t){let r=[];for(let n of e){let o=Math.max(0,Math.min(n.start,t)),s=Math.max(o,Math.min(n.end,t));s>o&&r.push({start:o,end:s,style:n.style});}return r}function uo(e,t){let r=[];for(let n of e){let o=Math.max(0,Math.min(n.start,t)),s=Math.max(o,Math.min(n.end,t));s>o&&r.push({start:o,end:s,href:n.href});}return r}function Tn(e){let t=[...e].toSorted((n,o)=>n.start!==o.start?n.start-o.start:n.end!==o.end?n.end-o.end:n.style.localeCompare(o.style)),r=[];for(let n of t){let o=r[r.length-1];if(o&&o.style===n.style&&(n.start<o.end||n.start===o.end&&n.style!=="blockquote")){o.end=Math.max(o.end,n.end);continue}r.push({...n});}return r}function Mn(e,t,r){let n=Math.max(e.start,t),o=Math.min(e.end,r);return o<=n?null:{start:n,end:o}}function fo(e,t,r){if(e.length===0)return [];let n=[];for(let o of e){let s=Mn(o,t,r);s&&n.push({start:s.start-t,end:s.end-t,style:o.style});}return Tn(n)}function po(e,t,r){if(e.length===0)return [];let n=[];for(let o of e){let s=Mn(o,t,r);s&&n.push({start:s.start-t,end:s.end-t,href:o.href});}return n}function de(e,t){try{let r=typeof e=="string"?e:"",n=Be.parse(t??{});return Se(r,n).ir}catch(r){return console.error("Markdown parse error:",r),{text:"",styles:[],links:[]}}}function Se(e,t){try{let r=typeof e=="string"?e:"",n=Be.parse(t),o={listStack:[]},a=Zr(n).parse(r||"",o);n.enableSpoilers&&Kr(a);let i=n.tableMode??"off",l={text:"",styles:[],openStyles:[],links:[],linkStack:[],env:o,headingStyle:n.headingStyle??"none",blockquotePrefix:n.blockquotePrefix??"",enableSpoilers:n.enableSpoilers??!1,tableMode:i,table:null,hasTables:!1};bt(a,l),vn(l);let c=l.text.trimEnd().length,u=0;for(let P of l.styles)P.style==="code_block"&&P.end>u&&(u=P.end);let m=Math.max(c,u);return {ir:{text:m===l.text.length?l.text:l.text.slice(0,m),styles:Tn(co(l.styles,m)),links:uo(l.links,m)},hasTables:l.hasTables}}catch(r){return console.error("Markdown parse error:",r),{ir:{text:"",styles:[],links:[]},hasTables:false}}}function Rn(e,t){try{let r=we.parse(e),n=typeof t=="number"&&t>0?t:0;if(!r.text)return [];if(n<=0||r.text.length<=n)return [r];let o=le(r.text,n),s=[],a=0;return o.forEach((i,l)=>{if(!i)return;if(l>0)for(;a<r.text.length&&/\s/.test(r.text[a]??"");)a+=1;let d=a,c=Math.min(r.text.length,d+i.length);s.push({text:i,styles:fo(r.styles,d,c),links:po(r.links,d,c)}),a=c;}),s}catch(r){return console.error("Chunk IR error:",r),[]}}k();var mo={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function ke(e,t){try{let r=we.parse(e),n=ft.parse(t??{});if(!r.text)return "";let o=n.styleMarkers??mo,s=n.escapeText??(u=>u),a=n.buildLink,i=[];for(let u=0;u<r.styles.length;u++){let m=r.styles[u];m&&(i.push({position:m.start,type:"open",style:m.style,spanIndex:u}),i.push({position:m.end,type:"close",style:m.style,spanIndex:u}));}for(let u=0;u<r.links.length;u++){let m=r.links[u];m&&(i.push({position:m.start,type:"link_open",spanIndex:u,href:m.href}),i.push({position:m.end,type:"link_close",spanIndex:u,href:m.href}));}i.sort((u,m)=>{if(u.position!==m.position)return u.position-m.position;let S=(z,pe)=>z==="link_open"?0:z==="open"?1:z==="close"?2:z==="link_close"?3:4,P=u.type==="close"||u.type==="link_close",L=m.type==="close"||m.type==="link_close",_=S(u.type,P),D=S(m.type,L);return _!==D?_-D:u.type==="open"&&m.type==="open"?u.spanIndex-m.spanIndex:u.type==="close"&&m.type==="close"?m.spanIndex-u.spanIndex:u.spanIndex-m.spanIndex});let l="",d=0,c=[];for(let u of i){if(u.position>d){let m=r.text.slice(d,u.position);l+=s?s(m):m;}if(u.type==="open"||u.type==="close"){let m=o[u.style];if(m)if(u.type==="open")l+=m.open,c.push(u);else {l+=m.close,u.style==="code_block"&&u.position<r.text.length&&(l+=`
|
|
63
|
+
`);let S=c.findIndex(P=>P.spanIndex===u.spanIndex&&P.type==="open");S!==-1&&c.splice(S,1);}}else if(u.type==="link_open")l+="[",c.push(u);else if(u.type==="link_close"){l+="]("+u.href+")";let m=c.findIndex(S=>S.spanIndex===u.spanIndex&&S.type==="link_open");m!==-1&&c.splice(m,1);}d=u.position;}if(d<r.text.length){let u=r.text.slice(d);l+=s?s(u):u;}return l}catch(r){return console.error("Markdown render error:",r),""}}function fe(e,t){return ke(e,t)}k();function go(e){let t=e.replace(/\r\n/g,`
|
|
64
64
|
`).replace(/\r/g,`
|
|
65
65
|
`);if(!t.startsWith("---"))return {frontmatter:"",content:e};let r=t.indexOf(`
|
|
66
|
-
---`,3);if(r===-1)return {frontmatter:"",content:e};let n=t.slice(0,r+4),o=t.slice(r+4).trimStart();return {frontmatter:n,content:o}}function
|
|
66
|
+
---`,3);if(r===-1)return {frontmatter:"",content:e};let n=t.slice(0,r+4),o=t.slice(r+4).trimStart();return {frontmatter:n,content:o}}function Le(e,t){try{let r=typeof e=="string"?e:"",n=pt.parse(t??{});if(!r)return "";let{frontmatter:o,content:s}=go(r),a=de(s,{linkify:!0,enableSpoilers:!1,autolink:!0,headingStyle:"none",blockquotePrefix:"",tableMode:"off"}),i=fe(a);return i=i.replace(/\n{3,}/g,`
|
|
67
67
|
|
|
68
68
|
`),i=i.trimEnd()+`
|
|
69
69
|
`,n.preserveFrontmatter&&o&&(i=o+`
|
|
70
|
-
`+i),i}catch(r){return console.error("Markdown format error:",r),e}}k();function
|
|
71
|
-
`).trim(),linesConsumed:n-t}}function
|
|
72
|
-
`),n=0;for(;n<r.length;){let o=r[n];if(!o){n+=1;continue}let s=o.match(/^([\w-]+):\s*(.*)$/);if(!s?.[1]||!s[2]){n+=1;continue}let a=s[1],i=s[2].trim();if(!a){n+=1;continue}if(!i&&n+1<r.length){let d=r[n+1];if(d&&(d.startsWith(" ")||d.startsWith(" "))){let{value:c,linesConsumed:u}=
|
|
70
|
+
`+i),i}catch(r){return console.error("Markdown format error:",r),e}}k();function ho(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function bo(e){if(e!=null){if(typeof e=="string")return {value:e.trim(),kind:"scalar"};if(typeof e=="number"||typeof e=="boolean")return {value:String(e),kind:"scalar"};if(typeof e=="object")try{return {value:JSON.stringify(e),kind:"structured"}}catch{return}}}function xo(e){try{let t=Pn.parse(e,{schema:"core"});if(!t||typeof t!="object"||Array.isArray(t))return null;let r={};for(let[n,o]of Object.entries(t)){let s=n.trim();if(!s)continue;let a=bo(o);a&&(r[s]=a);}return r}catch{return null}}function wo(e,t){let r=[],n=t+1;for(;n<e.length;){let s=e[n];if(!s){n+=1;continue}if(s.length>0&&!s.startsWith(" ")&&!s.startsWith(" "))break;r.push(s),n+=1;}return {value:r.join(`
|
|
71
|
+
`).trim(),linesConsumed:n-t}}function yo(e){let t={},r=e.split(`
|
|
72
|
+
`),n=0;for(;n<r.length;){let o=r[n];if(!o){n+=1;continue}let s=o.match(/^([\w-]+):\s*(.*)$/);if(!s?.[1]||!s[2]){n+=1;continue}let a=s[1],i=s[2].trim();if(!a){n+=1;continue}if(!i&&n+1<r.length){let d=r[n+1];if(d&&(d.startsWith(" ")||d.startsWith(" "))){let{value:c,linesConsumed:u}=wo(r,n);c&&(t[a]={value:c,kind:"multiline",rawInline:i}),n+=u;continue}}let l=ho(i);l&&(t[a]={value:l,kind:"inline",rawInline:i}),n+=1;}return t}function So(e){let t={};for(let[r,n]of Object.entries(e))t[r]=n.value;return t}function ko(e){return /^[|>][+-]?(\d+)?[+-]?$/.test(e)}function vo(e){let{lineEntry:t,yamlValue:r}=e;return r.kind!=="structured"||t.kind!=="inline"||ko(t.rawInline)?false:t.value.includes(":")}function To(e){let t=e.replace(/\r\n/g,`
|
|
73
73
|
`).replace(/\r/g,`
|
|
74
74
|
`);if(!t.startsWith("---"))return;let r=t.indexOf(`
|
|
75
|
-
---`,3);if(r!==-1)return t.slice(4,r)}function ve(e){try{if(typeof e!="string")return {};let t=
|
|
76
|
-
${
|
|
75
|
+
---`,3);if(r!==-1)return t.slice(4,r)}function ve(e){try{if(typeof e!="string")return {};let t=To(e);if(!t)return {};let r=yo(t),n=xo(t);if(n===null)return So(r);let o={};for(let[s,a]of Object.entries(n)){o[s]=a.value;let i=r[s];i&&vo({lineEntry:i,yamlValue:a})&&(o[s]=i.value);}for(let[s,a]of Object.entries(r))s in o||(o[s]=a.value);return o}catch(t){return console.warn("Failed to parse frontmatter:",t),{}}}function _e(e){try{let t=mt.parse(e);if(Object.keys(t).length===0)return "";let r={};for(let[o,s]of Object.entries(t))try{let a=JSON.parse(s);r[o]=a;}catch{r[o]=s;}return `---
|
|
76
|
+
${Pn.stringify(r,{lineWidth:0,defaultStringType:"QUOTE_DOUBLE"}).trim()}
|
|
77
77
|
---`}catch(t){return console.warn("Failed to serialize frontmatter:",t),""}}function je(e){try{if(typeof e!="string")return {frontmatter:{},content:""};let t=e.replace(/\r\n/g,`
|
|
78
78
|
`).replace(/\r/g,`
|
|
79
79
|
`);if(!t.startsWith("---"))return {frontmatter:{},content:e};let r=t.indexOf(`
|
|
80
|
-
---`,3);if(r===-1)return {frontmatter:{},content:e};let n=t.slice(4,r),o=t.slice(r+4).trimStart();return {frontmatter:ve(e),content:o}}catch(t){return console.warn("Failed to extract frontmatter:",t),{frontmatter:{},content:e}}}k();k();function
|
|
81
|
-
`,o),a=s===-1?t.length:s,i=t.slice(o,a),l=i.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(l){let d=l[1],c=l[2];if(!d||!c){o=a+1;continue}let u=c[0];if(!u){o=a+1;continue}let m=c.length;if(!n)n={start:o,markerChar:u,markerLen:m,openLine:i,marker:c,indent:d};else if(n.markerChar===u&&m>=n.markerLen){let y=a;r.push({start:n.start,end:y,openLine:n.openLine,marker:n.marker,indent:n.indent}),n=void 0;}}if(s===-1)break;o=s+1;}return n&&r.push({start:n.start,end:t.length,openLine:n.openLine,marker:n.marker,indent:n.indent}),r}catch(t){return console.warn("Invalid input for parseFenceSpans:",t),[]}}function gt(e,t){let r=0,n=e.length-1;for(;r<=n;){let o=Math.floor((r+n)/2),s=e[o];if(!s)break;if(t<=s.start){n=o-1;continue}if(t>=s.end){r=o+1;continue}return s}}function Rn(e,t){return !gt(e,t)}function Ne(){return {open:false,ticks:0}}function ze(e,t){try{let r=z.string().parse(e),n=t?Be.parse(t):Ne(),o=De(r),s={open:n.open,ticks:n.ticks},{spans:a,state:i}=Mo(r,o,s);return {inlineState:i,isInside:l=>Po(l,o)||Eo(l,a)}}catch(r){return console.warn("Invalid input for buildCodeSpanIndex:",r),{inlineState:Ne(),isInside:()=>false}}}function Mo(e,t,r){let n=[],o=r.open,s=r.ticks,a=o?0:-1,i=0;for(;i<e.length;){let l=Ro(t,i);if(l){i=l.end;continue}if(e[i]!=="`"){i+=1;continue}let d=i,c=0;for(;i<e.length&&e[i]==="`";)c+=1,i+=1;if(!o){o=true,s=c,a=d;continue}c===s&&(n.push([a,i]),o=false,s=0,a=-1);}return o&&n.push([a,e.length]),{spans:n,state:{open:o,ticks:s}}}function Ro(e,t){return e.find(r=>t>=r.start&&t<r.end)}function Po(e,t){return t.some(r=>e>=r.start&&e<r.end)}function Eo(e,t){return t.some(([r,n])=>e>=r&&e<n)}k();var Io={bold:{open:"**",close:"**"},italic:{open:"_",close:"_"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function We(e,t){try{let r=z.string().parse(e),n=we.parse(t);if(!r||n==="off")return r;let{ir:o,hasTables:s}=Se(r,{linkify:!1,enableSpoilers:!1,autolink:!1,headingStyle:"none",blockquotePrefix:"",tableMode:n});return s?ke(o,{styleMarkers:Io,escapeText:a=>a,buildLink:(a,i)=>{let l=a.href.trim();return !l||!i.slice(a.start,a.end)?null:{start:a.start,end:a.end,open:"[",close:`](${l})`}}}):r}catch(r){return console.warn("Invalid input for convertMarkdownTables:",r),typeof e=="string"?e:""}}var ht;(d=>{function e(c,u){try{return de(c,u)}catch(m){return console.warn("Markdown.parse error:",m),{text:"",styles:[],links:[]}}}d.parse=e;function t(c,u){try{return fe(c,u)}catch(m){return console.warn("Markdown.render error:",m),""}}d.render=t;function r(c,u){try{return Ae(c,u)}catch(m){return console.warn("Markdown.format error:",m),typeof c=="string"?c:""}}d.format=r;function n(c){try{return ve(c)}catch(u){return console.warn("Markdown.parseFrontmatter error:",u),{}}}d.parseFrontmatter=n;function o(c){try{return _e(c)}catch(u){return console.warn("Markdown.serializeFrontmatter error:",u),""}}d.serializeFrontmatter=o;function s(c){try{return je(c)}catch(u){return console.warn("Markdown.extractFrontmatter error:",u),{frontmatter:{},content:typeof c=="string"?c:""}}}d.extractFrontmatter=s;function a(c,u,m){try{return le(c,u,m)}catch(y){return console.warn("Markdown.chunk error:",y),typeof c=="string"&&c.length>0?[c]:[]}}d.chunk=a;function i(c,u){try{return ze(c,u)}catch(m){return console.warn("Markdown.buildCodeIndex error:",m),{inlineState:{open:false,ticks:0},isInside:()=>false}}}d.buildCodeIndex=i;function l(c,u){try{return We(c,u)}catch(m){return console.warn("Markdown.convertTables error:",m),typeof c=="string"?c:""}}d.convertTables=l;})(ht||(ht={}));k();function Pn(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r[r.length-1]??""}function Oo(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r.slice(0,r.length-1).join("/")+"/"}function Fo(e){if(!e)return "";let t=e.split(".");return t[t.length-1]}function Bo(e,t=20){let r=Pn(e);if(r.length<=t)return r;let n=r.lastIndexOf("."),o=n<=0?"":r.slice(n),s=t-o.length-1;return s<=0?r.slice(0,t-1)+"\u2026":r.slice(0,s)+"\u2026"+o}function $o(e,t=20){if(e.length<=t)return e;let r=t-1,n=Math.ceil(r/2),o=Math.floor(r/2);return e.slice(0,n)+"\u2026"+e.slice(-o)}k();var Lo=["load failed","network connection was lost","network request failed","failed to fetch","econnreset","econnrefused","etimedout","socket hang up"];function Ao(e){if(!e)return false;let t=String(e instanceof Error?e.message:e).toLowerCase();return Lo.some(r=>t.includes(r))}async function _o(e,t={}){let{attempts:r=3,delay:n=500,factor:o=2,maxDelay:s=1e4,retryIf:a=Ao}=t,i;for(let l=0;l<r;l++)try{return await e()}catch(d){if(i=d,l===r-1||!a(d))throw d;let c=Math.min(n*o**l,s);await new Promise(u=>setTimeout(u,c));}throw i}k();var bt;(n=>{let e=["brave","calm","clever","cosmic","crisp","curious","eager","gentle","glowing","happy","hidden","jolly","kind","lucky","mighty","misty","neon","nimble","playful","proud","quick","quiet","shiny","silent","stellar","sunny","swift","tidy","witty"],t=["cabin","cactus","canyon","circuit","comet","eagle","engine","falcon","forest","garden","harbor","island","knight","lagoon","meadow","moon","mountain","nebula","orchid","otter","panda","pixel","planet","river","rocket","sailor","squid","star","tiger","wizard","wolf"];function r(){return [e[Math.floor(Math.random()*e.length)],t[Math.floor(Math.random()*t.length)]].join("-")}n.create=r;})(bt||(bt={}));k();function En(e){let t=new AbortController,r=setTimeout(t.abort.bind(t),e);return {controller:t,signal:t.signal,clearTimeout:()=>globalThis.clearTimeout(r)}}function jo(e,...t){let r=En(e);return {signal:AbortSignal.any([r.signal,...t]),clearTimeout:r.clearTimeout}}k();var xt;(t=>{async function e(r,n){if(process.platform==="win32"){let o=Q.resolve(r),s=Q.resolve(n),a=`Expand-Archive -Path '${o}' -DestinationPath '${s}' -Force`,i=await V.run("powershell",`-NoProfile -NonInteractive -Command "$global:ProgressPreference = 'SilentlyContinue'; ${a}"`);if(i.code!==0)throw new Error(`PowerShell exited with code ${i.code}: ${i.stderr}`)}else {let o=`unzip -o -q ${r} -d ${n}`,s=await V.run(void 0,o);if(s.code!==0)throw new Error(`unzip exited with code ${s.code}: ${s.stderr}`)}}t.extractZip=e;})(xt||(xt={}));k();var yt;(n=>{function e(o){return o?/^#[0-9a-fA-F]{6}$/.test(o):false}n.isValidHex=e;function t(o){let s=parseInt(o.slice(1,3),16),a=parseInt(o.slice(3,5),16),i=parseInt(o.slice(5,7),16);return {r:s,g:a,b:i}}n.hexToRgb=t;function r(o){if(!e(o))return;let{r:s,g:a,b:i}=t(o);return `\x1B[38;2;${s};${a};${i}m\x1B[1m`}n.hexToAnsiBold=r;})(yt||(yt={}));k();var wt;(r=>{class e extends Error{constructor(s){super(`No context found for ${s}`);c(this,"name",s);}}r.NotFound=e;function t(n){let o=new AsyncLocalStorage;return {use(){let s=o.getStore();if(!s)throw new e(n);return s},provide(s,a){return o.run(s,a)}}}r.create=t;})(wt||(wt={}));k();function No(e){return {[Symbol.dispose](){e();},[Symbol.asyncDispose](){return Promise.resolve(e())}}}k();var St;(t=>{async function e(){return new Promise(r=>{let n=()=>{process._getActiveHandles().length===0&&process._getActiveRequests().length===0?r():setImmediate(n);};n();})}t.wait=e;})(St||(St={}));k();function zo(e){if(e<=0)return "";if(e<60)return `${e}s`;if(e<3600){let r=Math.floor(e/60),n=e%60;return n>0?`${r}m ${n}s`:`${r}m`}if(e<86400){let r=Math.floor(e/3600),n=Math.floor(e%3600/60);return n>0?`${r}h ${n}m`:`${r}h`}if(e<604800){let r=Math.floor(e/86400);return r===1?"~1 day":`~${r} days`}let t=Math.floor(e/604800);return t===1?"~1 week":`~${t} weeks`}k();var kt;(a=>{function e(i,l){if(i===l)return true;if(typeof i!="object"||typeof l!="object"||i===null||l===null)return false;let d=Object.keys(i),c=Object.keys(l);if(d.length!==c.length)return false;for(let u of d)if(!c.includes(u)||!e(i[u],l[u]))return false;return true}function t(i){return {...i,super:i.super??false}}function r(i,l){return i?e(t(i),t(l)):false}a.match=r;function n(i,l=false){return {name:i.name,ctrl:i.ctrl,meta:i.meta,shift:i.shift,super:i.super??false,leader:l}}a.fromParsedKey=n;function o(i){if(!i)return "";let l=[];i.ctrl&&l.push("ctrl"),i.meta&&l.push("alt"),i.super&&l.push("super"),i.shift&&l.push("shift"),i.name&&(i.name==="delete"?l.push("del"):l.push(i.name));let d=l.join("+");return i.leader&&(d=d?`<leader> ${d}`:"<leader>"),d}a.keyToString=o;function s(i){return i==="none"?[]:i.split(",").map(l=>{let c=l.replace(/<leader>/g,"leader+").toLowerCase().split("+"),u={ctrl:false,meta:false,shift:false,super:false,leader:false,name:""};for(let m of c)switch(m){case "ctrl":u.ctrl=true;break;case "alt":case "meta":case "option":u.meta=true;break;case "super":u.super=true;break;case "shift":u.shift=true;break;case "leader":u.leader=true;break;case "esc":u.name="escape";break;default:u.name=m;break}return u})}a.parse=s;})(kt||(kt={}));k();var vt;(d=>{function e(c){return c.replace(/\b\w/g,u=>u.toUpperCase())}d.titlecase=e;function t(c){return new Date(c).toLocaleTimeString(void 0,{timeStyle:"short"})}d.time=t;function r(c){let u=new Date(c),m=t(c),y=u.toLocaleDateString();return `${m} \xB7 ${y}`}d.datetime=r;function n(c){let u=new Date(c),m=new Date;return u.getFullYear()===m.getFullYear()&&u.getMonth()===m.getMonth()&&u.getDate()===m.getDate()?t(c):r(c)}d.todayTimeOrDateTime=n;function o(c){return c>=1e6?(c/1e6).toFixed(1)+"M":c>=1e3?(c/1e3).toFixed(1)+"K":c.toString()}d.number=o;function s(c){if(c<1e3)return `${c}ms`;if(c<6e4)return `${(c/1e3).toFixed(1)}s`;if(c<36e5){let y=Math.floor(c/6e4),P=Math.floor(c%6e4/1e3);return `${y}m ${P}s`}if(c<864e5){let y=Math.floor(c/36e5),P=Math.floor(c%36e5/6e4);return `${y}h ${P}m`}let u=Math.floor(c/36e5);return `${Math.floor(c%36e5/864e5)}d ${u}h`}d.duration=s;function a(c,u){return c.length<=u?c:c.slice(0,u-1)+"\u2026"}d.truncate=a;function i(c,u=35){if(c.length<=u)return c;let m="\u2026",y=Math.ceil((u-m.length)/2),P=Math.floor((u-m.length)/2);return c.slice(0,y)+m+c.slice(-P)}d.truncateMiddle=i;function l(c,u,m){return (c===1?u:m).replace("{}",c.toString())}d.pluralize=l;})(vt||(vt={}));k();function Wo(){return !!(process.env.HTTP_PROXY||process.env.HTTPS_PROXY||process.env.http_proxy||process.env.https_proxy)}k();var Tt=class{constructor(){c(this,"queue",[]);c(this,"resolvers",[]);}push(t){let r=this.resolvers.shift();r?r(t):this.queue.push(t);}async next(){return this.queue.length>0?this.queue.shift():new Promise(t=>this.resolvers.push(t))}async*[Symbol.asyncIterator](){for(;;)yield await this.next();}};async function Ho(e,t,r){let n=[...t];await Promise.all(Array.from({length:e},async()=>{for(;;){let o=n.pop();if(o===void 0)return;await r(o);}}));}k();function Uo(){let e,t=new Promise(r=>e=r);return {trigger(){return e()},wait(){return t}}}k();function qo(e,t){let r;return Promise.race([e.then(n=>(clearTimeout(r),n)),new Promise((n,o)=>{r=setTimeout(()=>{o(new Error(`Operation timed out after ${t}ms`));},t);})])}k();var Mt;(a=>{let r=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function n(i){if(!i)return 0;let l=String(i),d=(l.match(r)||[]).length,c=l.length-d,u=Math.round(d/1.5),m=Math.round(c/4);return Math.max(0,u+m)}a.estimate=n;function o(i){if(i==null)return 0;try{let l=typeof i=="string"?i:JSON.stringify(i);return n(l)}catch{return 0}}a.estimateObject=o;function s(i){if(i.total!==void 0&&i.total>0)return i.total;let l=i.input??0,d=i.output??0,c=i.cache?.read??0,u=i.cache?.write??0;return l+d+c+u}a.total=s;})(Mt||(Mt={}));k();function Go(e){let t={};for(let[r,n]of Object.entries(e.required().shape))t[r]=n.nullable();return Ie.object(t)}k();var Rt;(s=>{function e(a,i){let l=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return l.endsWith(" .*")&&(l=l.slice(0,-3)+"( .*)?"),new RegExp("^"+l+"$","s").test(a)}s.match=e;function t(a){return a.sort((i,l)=>{let d=i[0].length-l[0].length;return d!==0?d:i[0].localeCompare(l[0])})}function r(a,i){let l=Object.entries(i),d=t(l),c;for(let[u,m]of d)e(a,u)&&(c=m);return c}s.all=r;function n(a,i){let l=Object.entries(i),d=t(l),c;for(let[u,m]of d){let y=u.split(/\s+/);e(a.head,y[0])&&(y.length===1||o(a.tail,y.slice(1)))&&(c=m);}return c}s.allStructured=n;function o(a,i){if(i.length===0)return true;if(a.length<i.length)return false;for(let l=0;l<i.length;l++)if(!e(a[l],i[l]))return false;return true}})(Rt||(Rt={}));async function Zl(e){let{Log:t}=await import('./chunks/log-Q2AQE2DU.mjs'),r=false;await t.init({logDir:e.logDir??process.env.EASBOT_LOG_PATH??process.cwd(),print:e.print??false,dev:e.dev??r,level:e.level??("INFO")});}export{Sr as $,xt as Archive,Tt as AsyncQueue,qe as Binary,yt as Color,wt as Context,Ve as Encode,St as EventLoop,st as Fn,ge as Identifier,rt as Ignore,kt as Keybind,se as Lazy,vt as Locale,ht as Markdown,nt as NamedError,O as PKG,he as PkgShell,V as Shell,bt as Slug,Mt as Token,Ge as TruncateContent,Rt as Wildcard,En as abortAfter,jo as abortAfterAny,ze as buildCodeSpanIndex,Tn as chunkMarkdownIR,le as chunkText,at as chunkTextByBreakResolver,We as convertMarkdownTables,Ne as createInlineCodeState,ne as createPkgShell,Je as createRESTServer,Ye as createRPCServer,X as createServer,Ke as createStreamingServer,Ze as createWebSocketServer,No as defer,Qt as detectPlatform,et as escapeCommandArg,Xt as escapeCommandArgSafe,je as extractFrontmatter,gt as findFenceSpanAt,Un as findLast,Er as fn,zo as formatDuration,tt as formatLocalISO,kr as formatLocalISOCompact,Mr as formatLogTime,Ae as formatMarkdown,Oo as getDirectory,Fo as getFileExtension,Pn as getFilename,Bo as getFilenameTruncated,Rr as getTimezoneOffset,Br as git,Nr as iife,Zl as initLog,Rn as isSafeFenceBreak,ie as joinCommandArgs,Me as lazy,Gn as lazyAsync,Fr as loadEnv,jr as loadTextFile,Dr as loadTextFileAsync,de as markdownToIR,Se as markdownToIRWithMeta,Zt as needsShellExecution,ln as now,vr as nowLocalISO,Y as parseCommand,Kt as parseCommandWithOptions,De as parseFenceSpans,ve as parseFrontmatterBlock,Tr as parseLocalISO,zr as parseModelId,Wo as proxied,xr as readableStreamToText,fe as renderMarkdown,ke as renderMarkdownWithMarkers,_o as retry,it as scanParenAwareBreakpoints,_e as serializeFrontmatter,tn as shell,Uo as signal,Kn as startServer,$o as truncateMiddle,Go as updateSchema,yr as whichSync,qo as withTimeout,Ho as work};
|
|
80
|
+
---`,3);if(r===-1)return {frontmatter:{},content:e};let n=t.slice(4,r),o=t.slice(r+4).trimStart();return {frontmatter:ve(e),content:o}}catch(t){return console.warn("Failed to extract frontmatter:",t),{frontmatter:{},content:e}}}k();k();function Ne(e){try{let t=z.string().parse(e),r=[],n,o=0;for(;o<=t.length;){let s=t.indexOf(`
|
|
81
|
+
`,o),a=s===-1?t.length:s,i=t.slice(o,a),l=i.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(l){let d=l[1],c=l[2];if(!d||!c){o=a+1;continue}let u=c[0];if(!u){o=a+1;continue}let m=c.length;if(!n)n={start:o,markerChar:u,markerLen:m,openLine:i,marker:c,indent:d};else if(n.markerChar===u&&m>=n.markerLen){let S=a;r.push({start:n.start,end:S,openLine:n.openLine,marker:n.marker,indent:n.indent}),n=void 0;}}if(s===-1)break;o=s+1;}return n&&r.push({start:n.start,end:t.length,openLine:n.openLine,marker:n.marker,indent:n.indent}),r}catch(t){return console.warn("Invalid input for parseFenceSpans:",t),[]}}function xt(e,t){let r=0,n=e.length-1;for(;r<=n;){let o=Math.floor((r+n)/2),s=e[o];if(!s)break;if(t<=s.start){n=o-1;continue}if(t>=s.end){r=o+1;continue}return s}}function En(e,t){return !xt(e,t)}function De(){return {open:false,ticks:0}}function ze(e,t){try{let r=z.string().parse(e),n=t?Fe.parse(t):De(),o=Ne(r),s={open:n.open,ticks:n.ticks},{spans:a,state:i}=Po(r,o,s);return {inlineState:i,isInside:l=>Co(l,o)||Io(l,a)}}catch(r){return console.warn("Invalid input for buildCodeSpanIndex:",r),{inlineState:De(),isInside:()=>false}}}function Po(e,t,r){let n=[],o=r.open,s=r.ticks,a=o?0:-1,i=0;for(;i<e.length;){let l=Eo(t,i);if(l){i=l.end;continue}if(e[i]!=="`"){i+=1;continue}let d=i,c=0;for(;i<e.length&&e[i]==="`";)c+=1,i+=1;if(!o){o=true,s=c,a=d;continue}c===s&&(n.push([a,i]),o=false,s=0,a=-1);}return o&&n.push([a,e.length]),{spans:n,state:{open:o,ticks:s}}}function Eo(e,t){return e.find(r=>t>=r.start&&t<r.end)}function Co(e,t){return t.some(r=>e>=r.start&&e<r.end)}function Io(e,t){return t.some(([r,n])=>e>=r&&e<n)}k();var Bo={bold:{open:"**",close:"**"},italic:{open:"_",close:"_"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function He(e,t){try{let r=z.string().parse(e),n=ye.parse(t);if(!r||n==="off")return r;let{ir:o,hasTables:s}=Se(r,{linkify:!1,enableSpoilers:!1,autolink:!1,headingStyle:"none",blockquotePrefix:"",tableMode:n});return s?ke(o,{styleMarkers:Bo,escapeText:a=>a,buildLink:(a,i)=>{let l=a.href.trim();return !l||!i.slice(a.start,a.end)?null:{start:a.start,end:a.end,open:"[",close:`](${l})`}}}):r}catch(r){return console.warn("Invalid input for convertMarkdownTables:",r),typeof e=="string"?e:""}}var wt;(d=>{function e(c,u){try{return de(c,u)}catch(m){return console.warn("Markdown.parse error:",m),{text:"",styles:[],links:[]}}}d.parse=e;function t(c,u){try{return fe(c,u)}catch(m){return console.warn("Markdown.render error:",m),""}}d.render=t;function r(c,u){try{return Le(c,u)}catch(m){return console.warn("Markdown.format error:",m),typeof c=="string"?c:""}}d.format=r;function n(c){try{return ve(c)}catch(u){return console.warn("Markdown.parseFrontmatter error:",u),{}}}d.parseFrontmatter=n;function o(c){try{return _e(c)}catch(u){return console.warn("Markdown.serializeFrontmatter error:",u),""}}d.serializeFrontmatter=o;function s(c){try{return je(c)}catch(u){return console.warn("Markdown.extractFrontmatter error:",u),{frontmatter:{},content:typeof c=="string"?c:""}}}d.extractFrontmatter=s;function a(c,u,m){try{return le(c,u,m)}catch(S){return console.warn("Markdown.chunk error:",S),typeof c=="string"&&c.length>0?[c]:[]}}d.chunk=a;function i(c,u){try{return ze(c,u)}catch(m){return console.warn("Markdown.buildCodeIndex error:",m),{inlineState:{open:false,ticks:0},isInside:()=>false}}}d.buildCodeIndex=i;function l(c,u){try{return He(c,u)}catch(m){return console.warn("Markdown.convertTables error:",m),typeof c=="string"?c:""}}d.convertTables=l;})(wt||(wt={}));k();function Cn(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r[r.length-1]??""}function Fo(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r.slice(0,r.length-1).join("/")+"/"}function $o(e){if(!e)return "";let t=e.split(".");return t[t.length-1]}function Ao(e,t=20){let r=Cn(e);if(r.length<=t)return r;let n=r.lastIndexOf("."),o=n<=0?"":r.slice(n),s=t-o.length-1;return s<=0?r.slice(0,t-1)+"\u2026":r.slice(0,s)+"\u2026"+o}function Lo(e,t=20){if(e.length<=t)return e;let r=t-1,n=Math.ceil(r/2),o=Math.floor(r/2);return e.slice(0,n)+"\u2026"+e.slice(-o)}k();var _o=["load failed","network connection was lost","network request failed","failed to fetch","econnreset","econnrefused","etimedout","socket hang up"];function jo(e){if(!e)return false;let t=String(e instanceof Error?e.message:e).toLowerCase();return _o.some(r=>t.includes(r))}async function No(e,t={}){let{attempts:r=3,delay:n=500,factor:o=2,maxDelay:s=1e4,retryIf:a=jo}=t,i;for(let l=0;l<r;l++)try{return await e()}catch(d){if(i=d,l===r-1||!a(d))throw d;let c=Math.min(n*o**l,s);await new Promise(u=>setTimeout(u,c));}throw i}k();var yt;(n=>{let e=["brave","calm","clever","cosmic","crisp","curious","eager","gentle","glowing","happy","hidden","jolly","kind","lucky","mighty","misty","neon","nimble","playful","proud","quick","quiet","shiny","silent","stellar","sunny","swift","tidy","witty"],t=["cabin","cactus","canyon","circuit","comet","eagle","engine","falcon","forest","garden","harbor","island","knight","lagoon","meadow","moon","mountain","nebula","orchid","otter","panda","pixel","planet","river","rocket","sailor","squid","star","tiger","wizard","wolf"];function r(){return [e[Math.floor(Math.random()*e.length)],t[Math.floor(Math.random()*t.length)]].join("-")}n.create=r;})(yt||(yt={}));k();function In(e){let t=new AbortController,r=setTimeout(t.abort.bind(t),e);return {controller:t,signal:t.signal,clearTimeout:()=>globalThis.clearTimeout(r)}}function Do(e,...t){let r=In(e);return {signal:AbortSignal.any([r.signal,...t]),clearTimeout:r.clearTimeout}}k();var St;(t=>{async function e(r,n){if(process.platform==="win32"){let o=ae.resolve(r),s=ae.resolve(n),a=`Expand-Archive -Path '${o}' -DestinationPath '${s}' -Force`,i=await J.run("powershell",`-NoProfile -NonInteractive -Command "$global:ProgressPreference = 'SilentlyContinue'; ${a}"`);if(i.code!==0)throw new Error(`PowerShell exited with code ${i.code}: ${i.stderr}`)}else {let o=`unzip -o -q ${r} -d ${n}`,s=await J.run(void 0,o);if(s.code!==0)throw new Error(`unzip exited with code ${s.code}: ${s.stderr}`)}}t.extractZip=e;})(St||(St={}));k();var kt;(n=>{function e(o){return o?/^#[0-9a-fA-F]{6}$/.test(o):false}n.isValidHex=e;function t(o){let s=parseInt(o.slice(1,3),16),a=parseInt(o.slice(3,5),16),i=parseInt(o.slice(5,7),16);return {r:s,g:a,b:i}}n.hexToRgb=t;function r(o){if(!e(o))return;let{r:s,g:a,b:i}=t(o);return `\x1B[38;2;${s};${a};${i}m\x1B[1m`}n.hexToAnsiBold=r;})(kt||(kt={}));k();var vt;(r=>{class e extends Error{constructor(s){super(`No context found for ${s}`);c(this,"name",s);}}r.NotFound=e;function t(n){let o=new AsyncLocalStorage;return {use(){let s=o.getStore();if(!s)throw new e(n);return s},provide(s,a){return o.run(s,a)}}}r.create=t;})(vt||(vt={}));k();function Ho(e){return {[Symbol.dispose](){e();},[Symbol.asyncDispose](){return Promise.resolve(e())}}}k();var Tt;(t=>{async function e(){return new Promise(r=>{let n=()=>{process._getActiveHandles().length===0&&process._getActiveRequests().length===0?r():setImmediate(n);};n();})}t.wait=e;})(Tt||(Tt={}));k();function Wo(e){if(e<=0)return "";if(e<60)return `${e}s`;if(e<3600){let r=Math.floor(e/60),n=e%60;return n>0?`${r}m ${n}s`:`${r}m`}if(e<86400){let r=Math.floor(e/3600),n=Math.floor(e%3600/60);return n>0?`${r}h ${n}m`:`${r}h`}if(e<604800){let r=Math.floor(e/86400);return r===1?"~1 day":`~${r} days`}let t=Math.floor(e/604800);return t===1?"~1 week":`~${t} weeks`}k();var Mt;(a=>{function e(i,l){if(i===l)return true;if(typeof i!="object"||typeof l!="object"||i===null||l===null)return false;let d=Object.keys(i),c=Object.keys(l);if(d.length!==c.length)return false;for(let u of d)if(!c.includes(u)||!e(i[u],l[u]))return false;return true}function t(i){return {...i,super:i.super??false}}function r(i,l){return i?e(t(i),t(l)):false}a.match=r;function n(i,l=false){return {name:i.name,ctrl:i.ctrl,meta:i.meta,shift:i.shift,super:i.super??false,leader:l}}a.fromParsedKey=n;function o(i){if(!i)return "";let l=[];i.ctrl&&l.push("ctrl"),i.meta&&l.push("alt"),i.super&&l.push("super"),i.shift&&l.push("shift"),i.name&&(i.name==="delete"?l.push("del"):l.push(i.name));let d=l.join("+");return i.leader&&(d=d?`<leader> ${d}`:"<leader>"),d}a.keyToString=o;function s(i){return i==="none"?[]:i.split(",").map(l=>{let c=l.replace(/<leader>/g,"leader+").toLowerCase().split("+"),u={ctrl:false,meta:false,shift:false,super:false,leader:false,name:""};for(let m of c)switch(m){case "ctrl":u.ctrl=true;break;case "alt":case "meta":case "option":u.meta=true;break;case "super":u.super=true;break;case "shift":u.shift=true;break;case "leader":u.leader=true;break;case "esc":u.name="escape";break;default:u.name=m;break}return u})}a.parse=s;})(Mt||(Mt={}));k();var Rt;(d=>{function e(c){return c.replace(/\b\w/g,u=>u.toUpperCase())}d.titlecase=e;function t(c){return new Date(c).toLocaleTimeString(void 0,{timeStyle:"short"})}d.time=t;function r(c){let u=new Date(c),m=t(c),S=u.toLocaleDateString();return `${m} \xB7 ${S}`}d.datetime=r;function n(c){let u=new Date(c),m=new Date;return u.getFullYear()===m.getFullYear()&&u.getMonth()===m.getMonth()&&u.getDate()===m.getDate()?t(c):r(c)}d.todayTimeOrDateTime=n;function o(c){return c>=1e6?(c/1e6).toFixed(1)+"M":c>=1e3?(c/1e3).toFixed(1)+"K":c.toString()}d.number=o;function s(c){if(c<1e3)return `${c}ms`;if(c<6e4)return `${(c/1e3).toFixed(1)}s`;if(c<36e5){let S=Math.floor(c/6e4),P=Math.floor(c%6e4/1e3);return `${S}m ${P}s`}if(c<864e5){let S=Math.floor(c/36e5),P=Math.floor(c%36e5/6e4);return `${S}h ${P}m`}let u=Math.floor(c/36e5);return `${Math.floor(c%36e5/864e5)}d ${u}h`}d.duration=s;function a(c,u){return c.length<=u?c:c.slice(0,u-1)+"\u2026"}d.truncate=a;function i(c,u=35){if(c.length<=u)return c;let m="\u2026",S=Math.ceil((u-m.length)/2),P=Math.floor((u-m.length)/2);return c.slice(0,S)+m+c.slice(-P)}d.truncateMiddle=i;function l(c,u,m){return (c===1?u:m).replace("{}",c.toString())}d.pluralize=l;})(Rt||(Rt={}));k();function Uo(){return !!(process.env.HTTP_PROXY||process.env.HTTPS_PROXY||process.env.http_proxy||process.env.https_proxy)}k();var Pt=class{constructor(){c(this,"queue",[]);c(this,"resolvers",[]);}push(t){let r=this.resolvers.shift();r?r(t):this.queue.push(t);}async next(){return this.queue.length>0?this.queue.shift():new Promise(t=>this.resolvers.push(t))}async*[Symbol.asyncIterator](){for(;;)yield await this.next();}};async function qo(e,t,r){let n=[...t];await Promise.all(Array.from({length:e},async()=>{for(;;){let o=n.pop();if(o===void 0)return;await r(o);}}));}k();function Vo(){let e,t=new Promise(r=>e=r);return {trigger(){return e()},wait(){return t}}}k();function Go(e,t){let r;return Promise.race([e.then(n=>(clearTimeout(r),n)),new Promise((n,o)=>{r=setTimeout(()=>{o(new Error(`Operation timed out after ${t}ms`));},t);})])}k();var Et;(a=>{let r=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function n(i){if(!i)return 0;let l=String(i),d=(l.match(r)||[]).length,c=l.length-d,u=Math.round(d/1.5),m=Math.round(c/4);return Math.max(0,u+m)}a.estimate=n;function o(i){if(i==null)return 0;try{let l=typeof i=="string"?i:JSON.stringify(i);return n(l)}catch{return 0}}a.estimateObject=o;function s(i){if(i.total!==void 0&&i.total>0)return i.total;let l=i.input??0,d=i.output??0,c=i.cache?.read??0,u=i.cache?.write??0;return l+d+c+u}a.total=s;})(Et||(Et={}));k();function Jo(e){let t={};for(let[r,n]of Object.entries(e.required().shape))t[r]=n.nullable();return Ie.object(t)}k();var Ct;(s=>{function e(a,i){let l=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return l.endsWith(" .*")&&(l=l.slice(0,-3)+"( .*)?"),new RegExp("^"+l+"$","s").test(a)}s.match=e;function t(a){return a.sort((i,l)=>{let d=i[0].length-l[0].length;return d!==0?d:i[0].localeCompare(l[0])})}function r(a,i){let l=Object.entries(i),d=t(l),c;for(let[u,m]of d)e(a,u)&&(c=m);return c}s.all=r;function n(a,i){let l=Object.entries(i),d=t(l),c;for(let[u,m]of d){let S=u.split(/\s+/);e(a.head,S[0])&&(S.length===1||o(a.tail,S.slice(1)))&&(c=m);}return c}s.allStructured=n;function o(a,i){if(i.length===0)return true;if(a.length<i.length)return false;for(let l=0;l<i.length;l++)if(!e(a[l],i[l]))return false;return true}})(Ct||(Ct={}));async function Xl(e){let{Log:t}=await import('./chunks/log-Q2AQE2DU.mjs'),r=false;await t.init({logDir:e.logDir??process.env.EASBOT_LOG_PATH??process.cwd(),print:e.print??false,dev:e.dev??r,level:e.level??("INFO")});}export{vr as $,St as Archive,Pt as AsyncQueue,Ye as Binary,kt as Color,vt as Context,Je as Encode,Tt as EventLoop,lt as Fn,ge as Identifier,it as Ignore,Mt as Keybind,oe as Lazy,Rt as Locale,wt as Markdown,st as NamedError,$ as PKG,he as PkgShell,J as Shell,yt as Slug,Et as Token,Ze as TruncateContent,Ct as Wildcard,In as abortAfter,Do as abortAfterAny,ze as buildCodeSpanIndex,Rn as chunkMarkdownIR,le as chunkText,ut as chunkTextByBreakResolver,He as convertMarkdownTables,De as createInlineCodeState,ne as createPkgShell,Xe as createRESTServer,Ke as createRPCServer,ee as createServer,et as createStreamingServer,Qe as createWebSocketServer,Ho as defer,tn as detectPlatform,rt as escapeCommandArg,en as escapeCommandArgSafe,je as extractFrontmatter,xt as findFenceSpanAt,Vn as findLast,Ir as fn,Wo as formatDuration,ot as formatLocalISO,Tr as formatLocalISOCompact,Pr as formatLogTime,Le as formatMarkdown,Fo as getDirectory,$o as getFileExtension,Cn as getFilename,Ao as getFilenameTruncated,Er as getTimezoneOffset,Ar as git,Hr as iife,Xl as initLog,En as isSafeFenceBreak,se as joinCommandArgs,Me as lazy,Jn as lazyAsync,$r as loadEnv,Dr as loadTextFile,zr as loadTextFileAsync,de as markdownToIR,Se as markdownToIRWithMeta,Xt as needsShellExecution,un as now,Mr as nowLocalISO,K as parseCommand,Qt as parseCommandWithOptions,Ne as parseFenceSpans,ve as parseFrontmatterBlock,Rr as parseLocalISO,Wr as parseModelId,Uo as proxied,yr as readableStreamToText,fe as renderMarkdown,ke as renderMarkdownWithMarkers,No as retry,ct as scanParenAwareBreakpoints,_e as serializeFrontmatter,rn as shell,Vo as signal,Qn as startServer,Lo as truncateMiddle,Jo as updateSchema,Sr as whichSync,Go as withTimeout,qo as work};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easbot/utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"description": "Shared utilities library for EASBOT ecosystem",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"repository": {
|
|
39
39
|
"type": "git",
|
|
40
|
-
"url": "https://github.com/houjallen/easbot.git",
|
|
40
|
+
"url": "git+https://github.com/houjallen/easbot.git",
|
|
41
41
|
"directory": "packages/utils"
|
|
42
42
|
},
|
|
43
43
|
"homepage": "https://github.com/houjallen/easbot/tree/main/packages/utils#readme",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"markdown-it": "^14.1.1",
|
|
64
64
|
"minimatch": "^10.2.5",
|
|
65
65
|
"yaml": "^2.8.4",
|
|
66
|
-
"@easbot/types": "0.2.
|
|
66
|
+
"@easbot/types": "0.2.13"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@biomejs/biome": "^2.4.14",
|
|
@@ -80,6 +80,11 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
+
"directories": {
|
|
84
|
+
"doc": "docs",
|
|
85
|
+
"example": "examples",
|
|
86
|
+
"test": "tests"
|
|
87
|
+
},
|
|
83
88
|
"scripts": {
|
|
84
89
|
"dev": "tsup --watch --env.NODE_ENV development",
|
|
85
90
|
"build": "tsup --env.NODE_ENV production",
|