@easbot/utils 0.2.34 → 0.2.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +47 -46
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +49 -48
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,89 +1,90 @@
|
|
|
1
|
-
import {c}from'./chunks/chunk-2XMNW35H.mjs';export{c as Filesystem,a as Glob,b as MIME_TYPES}from'./chunks/chunk-2XMNW35H.mjs';export{b as PackageRegistry,a as Semver}from'./chunks/chunk-7XA3MNEJ.mjs';import {a}from'./chunks/chunk-WN6DTIOU.mjs';import {b,a as a$1}from'./chunks/chunk-DAYGB2XR.mjs';export{a as Lock}from'./chunks/chunk-UZ52E7FE.mjs';import {k,c as c$1,i}from'./chunks/chunk-V6YNYGNC.mjs';import se from'fs/promises';import je,{z}from'zod';import {randomBytes,createHash}from'crypto';import
|
|
2
|
-
Full ${p} saved to: ${
|
|
3
|
-
Use Read tool with offset/limit parameters to view specific sections.]`:`[Content truncated. Full ${p} saved to: ${
|
|
4
|
-
Use Read tool with offset/limit parameters to view specific sections.]`}function o(
|
|
1
|
+
import {c}from'./chunks/chunk-2XMNW35H.mjs';export{c as Filesystem,a as Glob,b as MIME_TYPES}from'./chunks/chunk-2XMNW35H.mjs';export{b as PackageRegistry,a as Semver}from'./chunks/chunk-7XA3MNEJ.mjs';import {a}from'./chunks/chunk-WN6DTIOU.mjs';import {b,a as a$1}from'./chunks/chunk-DAYGB2XR.mjs';export{a as Lock}from'./chunks/chunk-UZ52E7FE.mjs';import {k,c as c$1,i}from'./chunks/chunk-V6YNYGNC.mjs';import se from'fs/promises';import je,{z}from'zod';import {randomBytes,createHash}from'crypto';import ge,{dirname,join}from'path';import _e,{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 Zr from'markdown-it';import jn from'yaml';import {ProxyAgent,getGlobalDispatcher,setGlobalDispatcher}from'undici';import {AsyncLocalStorage}from'async_hooks';k();k();function Jn(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 tt;(r=>{function e(n,o,s){let a=0,i=n.length-1;for(;a<=i;){let c=Math.floor((a+i)/2),p=n[c];if(p===void 0)break;let l=s(p);if(l===o)return {found:true,index:c};l<o?a=c+1:i=c-1;}return {found:false,index:a}}r.search=e;function t(n,o,s){let a=s(o),i=0,c=n.length;for(;i<c;){let p=Math.floor((i+c)/2),l=n[p];if(l===void 0)break;s(l)<a?i=p+1:c=p;}return n.splice(i,0,o),n}r.insert=t;})(tt||(tt={}));k();var nt;(s=>{function e(a){let i=new TextEncoder().encode(a),c=Array.from(i,p=>String.fromCharCode(p)).join("");return btoa(c).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}s.base64Encode=e;function t(a){let i=atob(a.replace(/-/g,"+").replace(/_/g,"/")),c=Uint8Array.from(i,p=>p.charCodeAt(0));return new TextDecoder().decode(c)}s.base64Decode=t;async function r(a,i="SHA-256"){let p=new TextEncoder().encode(a),l=await crypto.subtle.digest(i,p);return Array.from(new Uint8Array(l)).map(k=>k.toString(16).padStart(2,"0")).join("")}s.hash=r;function n(a){if(!a)return;let i=2166136261;for(let c=0;c<a.length;c++)i^=a.charCodeAt(c),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 c=4096,l=[0,Math.floor(a.length*.25),Math.floor(a.length*.5),Math.floor(a.length*.75),a.length-c].map(d=>{let g=Math.max(0,Math.min(a.length-c,d-Math.floor(c/2)));return n(a.slice(g,g+c))??""}).join(":");return `${a.length}:${l}`}s.sampledChecksum=o;})(nt||(nt={}));k();k();var ke;(d=>{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(g){return je.string().startsWith(e[g])}d.schema=t;let r=26,n=0,o=0;function s(g,k){return i(g,false,k)}d.ascending=s;function a(g,k){return i(g,true,k)}d.descending=a;function i(g,k,P){if(!P)return p(g,k);if(!P.startsWith(e[g]))throw new Error(`ID ${P} does not start with ${e[g]}`);return P}function c(g){let k="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",P="",D=randomBytes(g);for(let H=0;H<g;H++){let q=D[H];q!==void 0&&(P+=k[q%62]);}return P}function p(g,k,P){let D=P??Date.now();D!==n&&(n=D,o=0),o++;let H=BigInt(D)*BigInt(4096)+BigInt(o);H=k?~H:H;let q=Buffer.alloc(6);for(let N=0;N<6;N++)q[N]=Number(H>>BigInt(40-8*N)&BigInt(255));return e[g]+"_"+q.toString("hex")+c(r-12)}d.create=p;function l(g){let k=g.split("_")[0];if(!k)return 0;let P=g.slice(k.length+1,k.length+13),D=BigInt("0x"+P);return Number(D/BigInt(4096))}d.timestamp=l;})(ke||(ke={}));var rt;(i=>{i.DIR=c.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-truncate"),i.DEFAULT_MAX_CHARS=4e3,i.DIRECTION="head";function n(c,p,l){return l?`[Content truncated. Source: ${l}
|
|
2
|
+
Full ${p} saved to: ${c}
|
|
3
|
+
Use Read tool with offset/limit parameters to view specific sections.]`:`[Content truncated. Full ${p} saved to: ${c}
|
|
4
|
+
Use Read tool with offset/limit parameters to view specific sections.]`}function o(c,p={}){let l=p.maxChars??i.DEFAULT_MAX_CHARS,d=p.direction??i.DIRECTION,g=p.label??"content",k=p.sourcePath;if(c.length<=l)return {content:c,truncated:false};let P=c.length-l,D;d==="head"?D=c.slice(0,l):D=c.slice(-l);let H=n("[save-path]",g,k),q=d==="head"?`
|
|
5
5
|
|
|
6
|
-
...${
|
|
6
|
+
...${P} characters truncated...
|
|
7
7
|
|
|
8
8
|
${H}`:`
|
|
9
9
|
|
|
10
|
-
...${
|
|
10
|
+
...${P} characters truncated...
|
|
11
11
|
|
|
12
|
-
${H}`;return {content:D+q,truncated:true,outputPath:"[save-path]",originalLength:
|
|
12
|
+
${H}`;return {content:D+q,truncated:true,outputPath:"[save-path]",originalLength:c.length,removedLength:P,label:g}}i.truncate=o;async function s(c$1,p={}){let l=p.maxChars??i.DEFAULT_MAX_CHARS,d=p.direction??i.DIRECTION,g=p.label??"content",k=p.dir??i.DIR,P=p.sourcePath;if(c$1.length<=l)return {content:c$1,truncated:false};let D=ke.ascending("context"),H=c.join(k,D);await se.mkdir(k,{recursive:true}).catch(()=>{}),await se.writeFile(H,c$1,"utf-8");let q=c$1.length-l,N;d==="head"?N=c$1.slice(0,l):N=c$1.slice(-l);let ae=n(H,g,P),Se=d==="head"?`
|
|
13
13
|
|
|
14
14
|
...${q} characters truncated...
|
|
15
15
|
|
|
16
|
-
${
|
|
16
|
+
${ae}`:`
|
|
17
17
|
|
|
18
18
|
...${q} characters truncated...
|
|
19
19
|
|
|
20
|
-
${le}`;return {content:N+ke,truncated:true,outputPath:H,originalLength:l.length,removedLength:q,label:g}}i.truncateAndSave=s;function a(l){return l.truncated?n(l.outputPath,l.label):""}i.formatHint=a;})(rt||(rt={}));k();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(),p=String(r.getMonth()+1).padStart(2,"0"),c=String(r.getDate()).padStart(2,"0"),u=String(r.getHours()).padStart(2,"0"),g=String(r.getMinutes()).padStart(2,"0"),S=String(r.getSeconds()).padStart(2,"0"),R=`${l}-${p}-${c}T${u}:${g}:${S}`;if(t){let D=String(r.getMilliseconds()).padStart(3,"0");R+=`.${D}`;}return R+=i,R}function st(e){return ot(e,false)}function Yt(){return Date.now()}function Xn(e=true){return ot(Yt(),e)}function Qn(e){return e.includes("+")||e.includes("-")?new Date(e):new Date(e)}function er(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 tr(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")}`}var it;(i=>{let e="New session - ",t="Child session - ";i.parentTitlePrefix=e,i.childTitlePrefix=t;function o(l=false){return (l?t:e)+st(new Date)}i.createDefault=o;function s(l){return new RegExp(`^(${e}|${t})\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[+-]\\d{2}:\\d{2}$`).test(l)}i.isDefault=s;function a(l){let p=l.match(/^(.+) \(fork #(\d+)\)$/);if(p){let c=p[1]??"",u=parseInt(p[2]??"0",10);return `${c} (fork #${u+1})`}return `${l} (fork #1)`}i.getForked=a;})(it||(it={}));k();k();function Vt(e){let t,r=false,n=()=>(r||(t=e(),r=true),t);return n.reset=()=>{r=false,t=void 0;},n}var Ae=Vt;function Gt(e){let t,r=()=>(t||(t=e()),t);return r.reset=()=>{t=void 0;},r}var nr=Gt,pe;(r=>(r.lazy=Vt,r.lazyAsync=Gt))(pe||(pe={}));k();k();k();var re=a.create({service:"server"});function ae(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)=>(re.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)=>re.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 p=await a.req.json(),c=await l(p,a);return a.json({result:c})}catch(p){return re.error("RPC error",{method:i,error:p.message}),a.json({error:"RPC execution failed",message:p.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(p=>{p?(re.error("Error closing server",{error:p.message}),l(p)):(o=null,re.info(`Server on port ${t} stopped`),i());}),setTimeout(()=>{re.warn(`Server shutdown timeout on port ${t}`),o=null,i();},5e3);}):Promise.resolve()},get raw(){return o||void 0}};return re.debug("createServer: calling serve()",{port:t,hostname:r}),o=serve({fetch:n.fetch,port:t,hostname:r}),re.debug("createServer: serve() returned, server created"),re.info(`Server running on http://${r}:${t}`),s}function at(e){return ae({rpc:e,port:3e3})}function ir(e,t=3e3,r="0.0.0.0"){return ae({fetch:e,port:t,hostname:r})}function lt(e,t={}){return ae({...t,routes:e})}function ct(e,t={}){return ae({...t,websockets:e})}function ut(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 ae({...t,routes:r,streaming:true})}k();var ue=a.create({service:"build-api"});async function ln(){try{return {available:!0,version:(await import('./chunks/main-ZMRSNK7G.mjs')).version||"unknown"}}catch(e){return ue.warn("esbuild not available",{error:e.message}),{available:false}}}async function Le(){let e=await ln();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"&&ue.warn(`esbuild version ${e.version} may have limited features. Consider upgrading to 0.17+`);}function ur(e){if(e!==void 0)return typeof e=="boolean"?{target:void 0}:typeof e=="string"?{target:e}:e}function cn(e){let t=ur(e.compile);t&&ue.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:dr(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=fr(e.target)),e.minify===true&&(r.minifyWhitespace=true,r.minifyIdentifiers=true,r.minifySyntax=true),pr(r)}function dr(e){return !e||e==="none"?false:e}function fr(e){let t={browser:"es2020",node:"node16",bun:"esnext"};return e?t[e]||e:"esnext"}function pr(e){let t={};for(let r of Object.keys(e))e[r]!==void 0&&(t[r]=e[r]);return t}function Be(e){if(e!==void 0)return e.replace(/\\/g,"/")}function rn(e,t,r){let n=[];if(e.outputFiles)for(let s of e.outputFiles)n.push({path:Be(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===Be(s))||n.push({path:Be(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 ft(e){ue.info("Build started",{entrypoints:e.entrypoints,target:e.target,format:e.format,compile:typeof e.compile}),await Le();let t=await import('./chunks/main-ZMRSNK7G.mjs'),r=Date.now();try{let n=cn(e);ue.debug("esbuild options",n);let o=await t.build(n),s=Date.now();return ue.info("Build completed",{duration:s-r,outputs:(o?.outputFiles?.length??0)>0||Object.keys(o.metafile?.outputs||{}).length>0}),rn(o,r,s)}catch(n){let o=Date.now(),s=n.message;return ue.error("Build failed",{error:s,duration:o-r}),n&&typeof n=="object"&&"errors"in n?rn(n):{outputs:[],success:false,logs:[{level:"error",message:s}],metafile:void 0}}}var xr={build:ft},un=xr;k();k();function oe(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 dn(e){return /[|&;<>()$`!#]/.test(e)}function fn(e){let t=oe(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 pt(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 wr=new Set(["&&","||","|",";","&",">","<",">>","<<","2>","2>>","1>","1>>","2>&1","2>&2","1>&1","1>&2",">&","<&",">&1","<&1",">&2","<&2"]);function pn(e,t=process.platform==="win32"?"windows":"unix"){return wr.has(e)?e:pt(e,t)}function mn(){return process.platform==="win32"?"windows":"unix"}function me(e,t,r=process.platform==="win32"?"windows":"unix"){let n=t.map(o=>pn(o,r));return [e,...n].join(" ")}function gn(e){if(e==null)return "";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>gn(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 Sr(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 ge(e,t={}){let r=oe(e);if(r.length===0)throw new Error("Empty shell command");let n=async()=>{let s=await L.run(r,{cwd:t.cwd,env:t.env}),a=Sr(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
|
|
22
|
-
`),A
|
|
23
|
-
`),F=
|
|
24
|
-
`).filter(
|
|
20
|
+
${ae}`;return {content:N+Se,truncated:true,outputPath:H,originalLength:c$1.length,removedLength:q,label:g}}i.truncateAndSave=s;function a(c){return c.truncated?n(c.outputPath,c.label):""}i.formatHint=a;})(rt||(rt={}));k();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")}`,c=r.getFullYear(),p=String(r.getMonth()+1).padStart(2,"0"),l=String(r.getDate()).padStart(2,"0"),d=String(r.getHours()).padStart(2,"0"),g=String(r.getMinutes()).padStart(2,"0"),k=String(r.getSeconds()).padStart(2,"0"),P=`${c}-${p}-${l}T${d}:${g}:${k}`;if(t){let D=String(r.getMilliseconds()).padStart(3,"0");P+=`.${D}`;}return P+=i,P}function st(e){return ot(e,false)}function Yt(){return Date.now()}function Xn(e=true){return ot(Yt(),e)}function Qn(e){return e.includes("+")||e.includes("-")?new Date(e):new Date(e)}function er(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 tr(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")}`}var it;(i=>{let e="New session - ",t="Child session - ";i.parentTitlePrefix=e,i.childTitlePrefix=t;function o(c=false){return (c?t:e)+st(new Date)}i.createDefault=o;function s(c){return new RegExp(`^(${e}|${t})\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[+-]\\d{2}:\\d{2}$`).test(c)}i.isDefault=s;function a(c){let p=c.match(/^(.+) \(fork #(\d+)\)$/);if(p){let l=p[1]??"",d=parseInt(p[2]??"0",10);return `${l} (fork #${d+1})`}return `${c} (fork #1)`}i.getForked=a;})(it||(it={}));k();k();function Vt(e){let t,r=false,n=()=>(r||(t=e(),r=true),t);return n.reset=()=>{r=false,t=void 0;},n}var $e=Vt;function Gt(e){let t,r=()=>(t||(t=e()),t);return r.reset=()=>{t=void 0;},r}var nr=Gt,fe;(r=>(r.lazy=Vt,r.lazyAsync=Gt))(fe||(fe={}));k();k();k();var re=a.create({service:"server"});function ie(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)=>(re.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)=>re.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||[],c=a.method.toUpperCase();a.validation?n.on(c,a.path,zValidator("json",a.validation),...i,a.handler):n.on(c,a.path,...i,a.handler);}e.rpc&&n.post("/rpc/:method",async a=>{let i=a.req.param("method"),c=e.rpc?.[i];if(!c)return a.json({error:"RPC method not found"},404);try{let p=await a.req.json(),l=await c(p,a);return a.json({result:l})}catch(p){return re.error("RPC error",{method:i,error:p.message}),a.json({error:"RPC execution failed",message:p.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,c)=>{a&&o.closeAllConnections?.(),o.close(p=>{p?(re.error("Error closing server",{error:p.message}),c(p)):(o=null,re.info(`Server on port ${t} stopped`),i());}),setTimeout(()=>{re.warn(`Server shutdown timeout on port ${t}`),o=null,i();},5e3);}):Promise.resolve()},get raw(){return o||void 0}};return re.debug("createServer: calling serve()",{port:t,hostname:r}),o=serve({fetch:n.fetch,port:t,hostname:r}),re.debug("createServer: serve() returned, server created"),re.info(`Server running on http://${r}:${t}`),s}function at(e){return ie({rpc:e,port:3e3})}function ir(e,t=3e3,r="0.0.0.0"){return ie({fetch:e,port:t,hostname:r})}function ct(e,t={}){return ie({...t,routes:e})}function lt(e,t={}){return ie({...t,websockets:e})}function ut(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 ie({...t,routes:r,streaming:true})}k();var ce=a.create({service:"build-api"});async function cn(){try{return {available:!0,version:(await import('./chunks/main-ZMRSNK7G.mjs')).version||"unknown"}}catch(e){return ce.warn("esbuild not available",{error:e.message}),{available:false}}}async function Be(){let e=await cn();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"&&ce.warn(`esbuild version ${e.version} may have limited features. Consider upgrading to 0.17+`);}function ur(e){if(e!==void 0)return typeof e=="boolean"?{target:void 0}:typeof e=="string"?{target:e}:e}function ln(e){let t=ur(e.compile);t&&ce.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:dr(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=fr(e.target)),e.minify===true&&(r.minifyWhitespace=true,r.minifyIdentifiers=true,r.minifySyntax=true),pr(r)}function dr(e){return !e||e==="none"?false:e}function fr(e){let t={browser:"es2020",node:"node16",bun:"esnext"};return e?t[e]||e:"esnext"}function pr(e){let t={};for(let r of Object.keys(e))e[r]!==void 0&&(t[r]=e[r]);return t}function Le(e){if(e!==void 0)return e.replace(/\\/g,"/")}function rn(e,t,r){let n=[];if(e.outputFiles)for(let s of e.outputFiles)n.push({path:Le(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(c=>c.path===s||c.path===Le(s))||n.push({path:Le(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 ft(e){ce.info("Build started",{entrypoints:e.entrypoints,target:e.target,format:e.format,compile:typeof e.compile}),await Be();let t=await import('./chunks/main-ZMRSNK7G.mjs'),r=Date.now();try{let n=ln(e);ce.debug("esbuild options",n);let o=await t.build(n),s=Date.now();return ce.info("Build completed",{duration:s-r,outputs:(o?.outputFiles?.length??0)>0||Object.keys(o.metafile?.outputs||{}).length>0}),rn(o,r,s)}catch(n){let o=Date.now(),s=n.message;return ce.error("Build failed",{error:s,duration:o-r}),n&&typeof n=="object"&&"errors"in n?rn(n):{outputs:[],success:false,logs:[{level:"error",message:s}],metafile:void 0}}}var xr={build:ft},un=xr;k();k();function oe(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 dn(e){return /[|&;<>()$`!#]/.test(e)}function fn(e){let t=oe(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 pt(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 wr=new Set(["&&","||","|",";","&",">","<",">>","<<","2>","2>>","1>","1>>","2>&1","2>&2","1>&1","1>&2",">&","<&",">&1","<&1",">&2","<&2"]);function pn(e,t=process.platform==="win32"?"windows":"unix"){return wr.has(e)?e:pt(e,t)}function mn(){return process.platform==="win32"?"windows":"unix"}function pe(e,t,r=process.platform==="win32"?"windows":"unix"){let n=t.map(o=>pn(o,r));return [e,...n].join(" ")}function gn(e){if(e==null)return "";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>gn(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 Sr(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 me(e,t={}){let r=oe(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=Sr(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 me(e,{...t,cwd:s})},o.env=function(s){return me(e,{...t,env:s})},o.quiet=function(){return me(e,{...t,quiet:true})},o.lines=async function*(){let i=(await n()).text().split(/\r?\n/);for(let c of i)c.trim()&&(yield c);},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 me(e,{...t,nothrow:true})},o.throws=function(s){return me(e,{...t,nothrow:!s})},o}var Te=class{constructor(t={}){c$1(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+=gn(r[o]));return me(n,this.options)}braces(t){let r=t.match(/^(.*?)\{([^}]+)\}(.*)$/);if(!r)return [t];let[,n="",o="",s=""]=r,a=o.split(",").map(c=>c.trim()),i=[];for(let c of a){let p=`${n}${c}${s}`;p.includes("{")?i.push(...this.braces(p)):i.push(p);}return i}escape(t){return process.platform==="win32"?t.replace(/([&|<>^"%])/g,"^$1"):t.replace(/(["\s'$`\\!*?#&;()<>|])/g,"\\$1")}env(t){return le({...this.options,env:t})}cwd(t){return le({...this.options,cwd:t})}nothrow(){return le({...this.options,nothrow:true})}throws(t){return le({...this.options,nothrow:!t})}};function le(e={}){let t=new Te(e);return new Proxy(t,{apply(r,n,o){return t.call(o[0],...o.slice(1))}})}var hn=le();function bn(e){return e.replace(/\\/g,"/")}function yn(e){return createHash("md5").update(e).digest("hex").slice(0,8)}var Q=new Map,_;($=>{let e=a.create({service:"pkg"});async function t(w){let m=w?[w]:["npm","pnpm","bun"];for(let f of m){let u=await $.which(f);if(u)return {name:f,path:u}}}$.packageManager=t;async function r(w,m){if(!w)return process.execPath;let f=m?.PATH||process.env.PATH||process.env.Path||"",u=process.env.EASBOT_BIN_PATH,y=u?f+ge.delimiter+u:f,x=yn(y),h=`${w}:${x}`;if(Q.has(h))return Q.get(h);let E=process.platform==="win32"?"where":"which";try{let{spawn:T}=await import('child_process');return new Promise(C=>{let F=T(E,[w],{env:{...process.env,PATH:y},stdio:["pipe","pipe","ignore"],windowsHide:!0}),U="",B="";F.stdout?.on("data",W=>{U+=W.toString();}),F.stderr?.on("data",W=>{B+=W.toString();}),F.on("close",W=>{if(W===0&&U.trim()){let A=U.trim().split(`
|
|
22
|
+
`),L=A.length>0?A[0]?.trim():null;if(L){Q.set(h,L),C(L);return}}Q.set(h,null),C(null);}),setTimeout(()=>{F.kill(),Q.set(h,null),C(null);},5e3);})}catch{return Q.set(h,null),null}}$.which=r;function n(w,m){if(!w)return process.execPath;let f=m?.PATH||process.env.PATH||process.env.Path||"",u=process.env.EASBOT_BIN_PATH,y=u?f+ge.delimiter+u:f,x=yn(y),h=`${w}:${x}`;if(Q.has(h))return Q.get(h);let E=process.platform==="win32"?"where":"which";try{let T=execSync(`${E} ${w}`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"],env:{...process.env,PATH:y},timeout:5e3,windowsHide:!0});if(T.trim()){let C=T.trim().split(`
|
|
23
|
+
`),F=C.length>0?C[0]?.trim():null;if(F)return Q.set(h,F),F}}catch{}return Q.set(h,null),null}$.whichSync=n;function o(){Q.clear();}$.clearWhichCache=o;let s=createRequire(import.meta.url);async function a$2(w,m,f){try{let u=[];if(f?.extraPaths)for(let y of f.extraPaths){let x=ge.join(y,"node_modules");u.push(x);}return m&&u.push(m),u.length>0?s.resolve(w,{paths:u}):s.resolve(w)}catch(u){throw new Error(`Cannot resolve module "${w}"${m?` from "${m}"`:""}: ${u instanceof Error?u.message:String(u)}`)}}$.resolve=a$2;function i(w){return {get name(){return ge.basename(w)},async exists(){try{return await se.access(w),!0}catch{return false}},async getSize(){try{return (await se.stat(w)).size}catch{return}},async text(){return await se.readFile(w,"utf-8")},textSync(){return _e.readFileSync(w,"utf-8")},jsonSync(){let m=_e.readFileSync(w,"utf-8");return JSON.parse(m)},async bytes(){e.debug("[PKG.file.bytes] reading file:",{filePath:w});let m=await se.readFile(w);return e.debug("[PKG.file.bytes] read succeeded, size:",{size:m.length}),new Uint8Array(m.buffer,m.byteOffset,m.byteLength)},async arrayBuffer(){let m=await se.readFile(w);return m.buffer.slice(m.byteOffset,m.byteOffset+m.byteLength)},get type(){let m=ge.extname(w).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"}[m]||"application/octet-stream"},async write(m){let f;if(m instanceof Response){let u=await m.arrayBuffer();f=new Uint8Array(u);}else f=m;await se.writeFile(w,f);},async json(){let m=await se.readFile(w,"utf-8");return JSON.parse(m)},async stat(){return await se.stat(w)}}}$.file=i;async function c(w,m,f){let u;if(m instanceof Response){let y=await m.arrayBuffer();u=new Uint8Array(y);}else u=m;await se.writeFile(w,u,f?{mode:f.mode}:void 0);}$.write=c;function p(w,m,f){_e.writeFileSync(w,m,f?{mode:f.mode}:void 0);}$.writeSync=p;function l(w,m="utf-8"){return _e.readFileSync(w,m)}$.readSync=l;function d(w,m){let f,u;if(typeof w=="object"&&"cmd"in w){let T=w;f=T.cmd,u={cwd:T.cwd,env:T.env,stdout:T.stdout,stderr:T.stderr,stdin:T.stdin,signal:T.signal,windowsHide:T.windowsHide,shell:T.shell};}else f=Array.isArray(w)?w:[w],u=m||{};if(!f||f.length===0||!f[0])throw new Error("Spawn command cannot be empty");let y=[u.stdin==="inherit"?"inherit":u.stdin==="null"?"ignore":"pipe",u.stdout==="inherit"?"inherit":u.stdout==="null"?"ignore":"pipe",u.stderr==="inherit"?"inherit":u.stderr==="null"?"ignore":"pipe"],x={cwd:u.cwd,env:u.env?{...process.env,...u.env}:process.env,stdio:y,timeout:u.timeout};u.shell!==void 0&&(x.shell=u.shell),process.platform==="win32"&&(x.windowsHide=u.windowsHide??true);let h=spawn(f[0],f.slice(1),x),S;if(u.signal){S=()=>{h.kill();},u.signal.addEventListener("abort",S,{once:true});let T=()=>{S&&(u.signal?.removeEventListener("abort",S),S=void 0);};h.on("close",T),h.on("error",T);}let E=new Promise((T,C)=>{let F=false,U=()=>{F||(F=true,h.removeAllListeners());};if(h.on("close",B=>{U(),T(B??0);}),h.on("error",B=>{U(),C(B);}),u.timeout!==false){let B=u.timeout||3e5;setTimeout(()=>{if(!F){e.debug(`Process timeout after ${B}ms, killing process`,{cmd:f.join(" ")}),U();try{h.kill("SIGKILL");}catch{}C(new Error(`Process timeout after ${B}ms: ${f.join(" ")}`));}},B);}});return {stdout:h.stdout,stderr:h.stderr,stdin:h.stdin,pid:h.pid,exited:E,exitCode:h.exitCode,kill:T=>h.kill(T)}}$.spawn=d;async function g(w,m){let f=m?.stdin??"null",u=m?.stdout??"pipe",y=m?.stderr??"pipe",x=d(w,{cwd:m?.cwd,env:m?.env,stdin:f,stdout:u,stderr:y,windowsHide:m?.windowsHide,shell:m?.shell}),h=[],S=[];u==="pipe"&&x.stdout?.on("data",T=>{h.push(T);}),y==="pipe"&&x.stderr?.on("data",T=>{S.push(T);});let E=m?.timeout&&m.timeout>0?setTimeout(()=>{try{x.kill("SIGKILL");}catch{}x.stdout?.destroy(),x.stderr?.destroy(),x.stdin?.end();},m.timeout):void 0;try{let T=await x.exited;return clearTimeout(E),u==="pipe"&&x.stdout?.destroy(),y==="pipe"&&x.stderr?.destroy(),f==="pipe"&&x.stdin?.end(),{code:T,stdout:Buffer.concat(h).toString("utf-8"),stderr:Buffer.concat(S).toString("utf-8")}}catch(T){return clearTimeout(E),u==="pipe"&&x.stdout?.destroy(),y==="pipe"&&x.stderr?.destroy(),f==="pipe"&&x.stdin?.end(),{code:-1,stdout:Buffer.concat(h).toString("utf-8"),stderr:Buffer.concat(S).toString("utf-8")||(T instanceof Error?T.message:String(T))}}}$.run=g;async function k(w,m={},f={}){let u=d(w,{cwd:m.cwd,env:m.env,stdout:"pipe",stderr:"pipe",stdin:"null"}),y="",x="";u.stdout?.on("data",S=>{let E=S.toString("utf-8");y+=E,f.onStdout?.(E);}),u.stderr?.on("data",S=>{let E=S.toString("utf-8");x+=E,f.onStderr?.(E);});let h=m.timeout&&m.timeout>0?setTimeout(()=>{try{u.kill("SIGKILL");}catch{}u.stdout?.destroy(),u.stderr?.destroy();},m.timeout):void 0;try{let S=await u.exited;return clearTimeout(h),f.onExit?.(S),{code:S,stdout:y,stderr:x}}catch(S){clearTimeout(h);let E=S instanceof Error?S.message:String(S);return {code:-1,stdout:y,stderr:x||E}}}$.runWithStream=k;async function P(w){if(typeof w.pipeThrough=="function")try{let y=new TextDecoderStream("utf-8"),h=w.pipeThrough(y).getReader(),S="";try{for(;;){let{done:E,value:T}=await h.read();if(E)break;S+=T;}return S}finally{h.releaseLock();}}catch{}let m=w.getReader(),f=new TextDecoder("utf-8"),u=[];try{for(;;){let{done:y,value:x}=await m.read();if(y)break;u.push(f.decode(x,{stream:!0}));}return u.push(f.decode()),u.join("")}finally{m.releaseLock();}}$.readableStreamToText=P;async function D(w){let m=[];return new Promise((f,u)=>{w.on("data",y=>{typeof y=="string"?m.push(Buffer.from(y)):m.push(y);}),w.on("end",()=>{try{let x=Buffer.concat(m).toString("utf-8");f(x);}catch(y){u(y);}}),w.on("error",y=>{u(y);});})}$.nodeReadableStreamToText=D;function H(w,m=0){let E=new TextEncoder().encode(w),T=E.length,C,F=0;if(T>=16){let A=T-16,L=m+2654435761+2246822519|0,ee=m+2246822519|0,K=m+0|0,X=m-2654435761|0;for(;F<=A;)L=U(L,W(E,F)),F+=4,ee=U(ee,W(E,F)),F+=4,K=U(K,W(E,F)),F+=4,X=U(X,W(E,F)),F+=4;C=B(L,1)+B(ee,7)+B(K,12)+B(X,18)|0;}else C=m+374761393|0;for(C=C+T|0;F+4<=T;)C=C+W(E,F)*3266489917|0,C=B(C,17)*668265263|0,F+=4;for(;F<T;)C=C+E[F]*374761393|0,C=B(C,11)*2654435761|0,F++;return C^=C>>>15,C=C*2246822519|0,C^=C>>>13,C=C*3266489917|0,C^=C>>>16,C>>>0;function U(A,L){return A=A+L*2246822519|0,A=B(A,13),A=A*2654435761|0,A}function B(A,L){return A<<L|A>>>32-L|0}function W(A,L){return (A[L]|A[L+1]<<8|A[L+2]<<16|A[L+3]<<24)>>>0}}$.xxHash32=H;function q(w){let m=0;for(let f of w){let u=f.codePointAt(0)||f.charCodeAt(0);u<127?m+=1:u>=4352&&u<=4447||u>=9001&&u<=9002||u>=11904&&u<=42191&&u!==12351||u>=44032&&u<=55203||u>=63744&&u<=64255||u>=65040&&u<=65049||u>=65072&&u<=65135||u>=65280&&u<=65376||u>=65504&&u<=65510?m+=2:m+=1;}return m}$.stringWidth=q;class N{constructor(m){c$1(this,"pattern");this.pattern=m;}async*scan(m){let f=b.stream(this.pattern,{cwd:m?.cwd,absolute:m?.absolute,follow:m?.followSymlinks,dot:m?.dot,nodir:m?.onlyFiles});for await(let u of f)yield bn(u);}*scanSync(m){let f=a$1(this.pattern,{cwd:m?.cwd,absolute:m?.absolute,follow:m?.followSymlinks,dot:m?.dot,nodir:m?.onlyFiles});for(let u of f)yield bn(u);}match(m){return minimatch(m,this.pattern)}}$.Glob=N,$.stdin=process.stdin,$.stdout=process.stdout,$.stderr=process.stderr,$.sleep=w=>new Promise(m=>setTimeout(m,w)),$.color=(w,m)=>({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"})[w.toLowerCase()]||null,$.hash={xxHash32:$.xxHash32},$.build=un.build,$.server=ie,$.nodeWebSocket=createNodeWebSocket,$.restServer=ct,$.rpcServer=at,$.streamingServer=ut,$.webSocketServer=lt;})(_||(_={}));var Mr=_.readableStreamToText;_.nodeReadableStreamToText;_.which;var Er=_.whichSync;_.spawn;_.run;var wn=200,Sn={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}},ne;(m=>{let e=a.create({service:"shell"});async function t(f,u){let y=f.pid;if(!(!y||u?.exited?.())){if(process.platform==="win32"){await new Promise(x=>{let h=spawn("taskkill",["/pid",String(y),"/f","/t"],{stdio:"ignore",windowsHide:true});h.once("exit",()=>x()),h.once("error",()=>x());});return}try{process.kill(-y,"SIGTERM"),await setTimeout$1(wn),u?.exited?.()||process.kill(-y,"SIGKILL");}catch{f.kill("SIGTERM"),await setTimeout$1(wn),u?.exited?.()||f.kill("SIGKILL");}}}m.killTree=t;function r(f){if(process.platform!=="win32"||!f.includes("/")&&!f.includes("\\")&&!f.includes(":"))return f;let u=c.normalize(f);return P(u)==="bash"&&g()||u}function n(f){return Sn[P(f)]}function o(f){return n(f)?.deny!==true}function s(f){return c.isAbsolute(f)}function a$1(f){let u=r(f);if(s(u))return c.stat(u)?.isFile()?u:void 0;let y=_.whichSync(u);return y?c.normalize(y):void 0}function i(){return Array.from(new Set([_.whichSync("pwsh"),_.whichSync("powershell"),g(),process.env.COMSPEC||"cmd.exe"].filter(f=>!!f).map(r)))}async function c$2(){let f=await c.readText("/etc/shells").catch(()=>"");return f?Array.from(new Set(f.split(`
|
|
24
|
+
`).filter(u=>u.trim()&&!u.startsWith("#")))):["/bin/bash","/bin/zsh","/bin/sh"]}function p(f,u){if(f&&(!u?.acceptable||o(f))){let y=a$1(f);if(y)return y}return process.platform==="win32"?i()[0]:k()}m.defaultPreferred=$e(()=>p(process.env.SHELL)),m.defaultAcceptable=$e(()=>p(process.env.SHELL,{acceptable:true}));function g(){if(process.platform!=="win32")return;if(process.env.EASBOT_GIT_BASH_PATH)return c.normalize(process.env.EASBOT_GIT_BASH_PATH);let f=_.whichSync("git");if(!f)return;let u=c.normalize(ge.join(f,"..","..","bin","bash.exe"));if((c.stat(u)?.size??0)>0)return u}m.gitbash=g;function k(){if(process.platform==="win32"){let u=g();return u||"/bin/sh"}if(process.platform==="darwin")return "/bin/zsh";let f=_.whichSync("bash");return f?c.normalize(f):"/bin/sh"}function P(f){return ge.posix.basename(c.toUnixPath(f)).toLowerCase()}m.name=P;function D(f){return n(f)?.login===true}m.login=D;function H(f){return n(f)?.posix===true}m.posix=H;function q(f){return n(f)?.ps===true}m.ps=q;function N(f){let u=r(f),y=P(u);return {path:u,name:y,acceptable:o(y)}}function ae(f,u,y){let x=P(f),h=oe(u),S=pe(h[0]??u,h.slice(1));return x==="nu"||x==="fish"?["-c",S]:x==="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",
|
|
28
|
+
${S}
|
|
29
|
+
`,"easbot",y]:x==="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",
|
|
35
|
-
`)[0];return e.debug(`Shell \u7248\u672C\u83B7\u53D6\u6210\u529F: ${
|
|
36
|
-
${B.stderr}`);return B.stdout},lines:async()=>(await
|
|
37
|
-
`).filter(
|
|
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
|
|
41
|
-
`?o=i:/\s/.test(
|
|
33
|
+
${S}
|
|
34
|
+
`,"easbot",y]:/^cmd(\.exe)?$/i.test(x)?["/c",`chcp 65001 >nul 2>&1 && ${S}`]:q(x)?["-NoProfile","-Command",`[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; ${S}`]:["-c",S]}m.args=ae;function Se(f){return f?p(f):(0, m.defaultPreferred)()}m.preferred=Se;function Ze(f){return f?p(f,{acceptable:true}):(0, m.defaultAcceptable)()}m.acceptable=Ze;function Nt(){m.defaultPreferred.reset(),m.defaultAcceptable.reset();}m.reset=Nt;async function zt(){return (process.platform==="win32"?i():await c$2()).filter(u=>a$1(u)).map(N)}m.list=zt;function Fe(f){return Sn[P(f)]}m.metaInfo=Fe;function I(f){return /[|&;<>()$`!#]/.test(f)}m.needsShell=I;function O(){return process.platform==="win32"?i():["/bin/bash","/bin/zsh","/bin/sh"]}m.platformShells=O;function j(f){return f?!!a$1(f):false}m.isValid=j;async function G(f){let u=a$1(f);if(!u)return;let y=P(u);if(!/^cmd(\.exe)?$/i.test(y))try{let x;q(y)?x=["-NoProfile","-Command","$PSVersionTable.PSVersion.ToString()"]:x=["--version"],e.debug(`\u83B7\u53D6 Shell \u7248\u672C: ${u}`,{shell:u,args:x});let h=await _.run([u,...x]);if(h.code===0){let S=h.stdout.trim().split(`
|
|
35
|
+
`)[0];return e.debug(`Shell \u7248\u672C\u83B7\u53D6\u6210\u529F: ${S}`),S}e.debug(`Shell \u7248\u672C\u83B7\u53D6\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${h.code}`,{stderr:h.stderr});}catch(x){e.debug(`Shell \u7248\u672C\u83B7\u53D6\u5F02\u5E38: ${x}`);}}m.version=G;class Y extends Error{constructor(y,x,h,S){super(y);c$1(this,"message",y);c$1(this,"pkg",x);c$1(this,"version",h);c$1(this,"originalError",S);this.name="InstallFailedError";}}m.InstallFailedError=Y;async function de(f,u="latest",y){let{Lock:x}=await import('./chunks/lock-EGXJVIO5.mjs'),{Filesystem:h}=await import('./chunks/filesystem-BAT2ZG5X.mjs'),{PackageRegistry:S}=await import('./chunks/registry-O74JPNLS.mjs');y=y??process.env.EASBOT_CACHE_PATH??ge.join(".easbot","cache");let E=await x.write("pkg-install");try{let T=ge.posix.join(y,"node_modules",f),C=ge.posix.join(y,"package.json"),U=(await h.readJson(C).catch(async()=>{let Z={dependencies:{}};return await h.writeJson(C,Z),Z})).dependencies??{},B=await h.exists(T),W=U[f],A=!1;if(!B||!W)A=!0;else {if(u!=="latest"&&W===u)return T;if(u==="latest"){if(!await S.isOutdated(f,W,y))return T;e.info("Cached version is outdated, proceeding with install",{pkg:f,cachedVersion:W}),A=!0;}}if(!A)return T;let L=m.acceptable(process.platform==="win32"?"cmd":void 0)??k(),ee=`${f}@${u}`;e.info("installing package",{pkg:f,version:u,cache:y,shell:L});let K=await _.packageManager();if(!K)throw new Y("No package manager found (npm, pnpm, bun)",f,u,"No package manager available");let X=K.name,Xe=X==="pnpm"?"add":"install",Qe=`${K.name} ${Xe} --save-exact ${ee}`;e.info(`Using ${X} to install package`,{pkg:f,version:u,shell:L,pmPath:K.path});try{let Z=await m.run(L,Qe,{cwd:y,timeout:6e5,windowsHide:!0});if(Z.code!==0)throw new Error(`Package manager exited with code ${Z.code}: ${Z.stderr}`);e.info(`Successfully installed ${f}@${u} with ${X}`);}catch(Z){let Ht=Z instanceof Error?Z:new Error(String(Z));if(!await h.exists(T))throw new Y(`Failed to install ${f}@${u}`,f,u,Ht.message);e.warn("Package install failed but module exists, continuing",{error:Ht.message});}let et=u;u==="latest"&&(et=(await h.readJson(ge.join(T,"package.json")).catch(()=>({})))?.version??"unknown");let Ae=await h.readJson(C);return Ae.dependencies=Ae.dependencies??{},Ae.dependencies[f]=et,await h.writeJson(C,Ae),e.info("Package installation completed",{pkg:f,version:et,path:T}),T}finally{E[Symbol.dispose]();}}m.install=de;async function J(f,u,y){let x=f?m.acceptable(f)??k():m.acceptable()??k(),h=y?.cwd??process.cwd(),S=m.args(x,u,h);e.debug(`run shell process: ${x} ${S.join(" ")}`,{command:u,cwd:h});let{windowsHide:E,env:T,...C}=y??{},F={...process.env,LANG:"en_US.UTF-8",LC_ALL:"en_US.UTF-8",LC_CTYPE:"en_US.UTF-8",...T};process.platform==="win32"&&(F.CHCP="65001");let{stdin:U,stdout:B,stderr:W,timeout:A,signal:L,...ee}=C??{},K={...ee,cwd:h,env:F,windowsHide:process.platform==="win32"?E??true:void 0,shell:ee.shell,timeout:A},X=P(x),Xe=/^cmd(\.exe)?$/i.test(X),Qe=process.platform==="win32"&&Xe?"cmd":x;return _.run([Qe,...S],K)}m.run=J;function $(f,u,y){let x=f?m.acceptable(f)??k():m.acceptable()??k(),h=y?.cwd??process.cwd(),S=m.args(x,u,h);e.debug(`Spawn shell process: ${x} ${S.join(" ")}`,{command:u,cwd:h});let{stdin:E,stdout:T,stderr:C,timeout:F,signal:U,windowsHide:B,env:W,...A}=y??{},L={...process.env,LANG:"en_US.UTF-8",LC_ALL:"en_US.UTF-8",LC_CTYPE:"en_US.UTF-8",...W};process.platform==="win32"&&(L.CHCP="65001");let ee=P(x),K=/^cmd(\.exe)?$/i.test(ee),X={...A,cwd:h,env:L,windowsHide:process.platform==="win32"?B??true:void 0,shell:A.shell,timeout:F};return _.spawn([K?"cmd":x,...S],X)}m.spawn=$;function w(f,...u){let y=f.reduce((h,S,E)=>h+S+(u[E]??""),""),x=(h={})=>({quiet:()=>x({...h,quiet:true}),nothrow:()=>x({...h,nothrow:true}),cwd:S=>x({...h,cwd:S}),env:S=>x({...h,env:S}),stdin:S=>x({...h,stdin:S}),stdout:S=>x({...h,stdout:S}),stderr:S=>x({...h,stderr:S}),text:async()=>{let S=oe(y.trim());if(S.length===0)throw new Error("Empty command");let E=S[0]??"",T=P(E),C=/^cmd(\.exe)?$/i.test(T),F=process.platform==="win32"&&C?"cmd":Fe(E)?E:void 0,U=pe(E,S.slice(1)),B=await m.run(F,U,{cwd:h.cwd,env:h.env,stdin:h.stdin,stdout:h.stdout,stderr:h.stderr,timeout:h.timeout,windowsHide:process.platform==="win32"?h.windowsHide??true:void 0,shell:h.shell});if(B.code!==0&&!h.nothrow)throw new Error(`Command failed with exit code ${B.code}: ${y}
|
|
36
|
+
${B.stderr}`);return B.stdout},lines:async()=>(await x(h).text()).split(`
|
|
37
|
+
`).filter(E=>E.trim()),then:(S,E)=>{let T=oe(y.trim()),C=T[0]??"",F=P(C),U=/^cmd(\.exe)?$/i.test(F),B=process.platform==="win32"&&U?"cmd":Fe(C)?C:void 0,W=pe(C,T.slice(1));return m.run(B,W,{cwd:h.cwd,env:h.env,stdin:h.stdin,stdout:h.stdout,stderr:h.stderr,timeout:h.timeout,windowsHide:process.platform==="win32"?h.windowsHide??true:void 0,shell:h.shell}).then(A=>{if(A.code!==0&&!h.nothrow){let L=new Error(`Command failed with exit code ${A.code}: ${y}
|
|
38
|
+
${A.stderr}`);if(E){E(L);return}throw L}return S({exitCode:A.code,stdout:new TextEncoder().encode(A.stdout),stderr:new TextEncoder().encode(A.stderr),text:()=>A.stdout,lines:()=>A.stdout.split(`
|
|
39
|
+
`).filter(L=>L.trim())})},E)}});return x()}m.$=w;})(ne||(ne={}));var Or=ne.$;k();var Re=class Re extends Error{static create(t,r){var s;let n=je.object({name:je.literal(t),data:r}).meta({ref:t}),o=(s=class extends Re{constructor(i,c){super(t,c);c$1(this,"data",i);c$1(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$1(s,"Schema",n),s);return Object.defineProperty(o,"name",{value:t}),o}};c$1(Re,"Unknown",Re.create("UnknownError",je.object({message:je.string()})));var mt=Re;k();var gt;(t=>{function e(r){return new ht(r)}t.create=e;})(gt||(gt={}));var ht=class{constructor(t){c$1(this,"rules",[]);c$1(this,"ignorecase");c$1(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 c=this.patternToRegex(n);c&&this.rules.push({pattern:n,regex:c,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 p=t[n];if(p==="\\")if(n+1<o){let l=t[n+1];r.push(this.escapeRegexChar(l)),n+=2;continue}else {r.push("\\\\"),n++;continue}if(p==="*")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(p==="?"){r.push("[^/]"),n++;continue}if(p==="["){let l=this.findMatchingBracket(t,n);if(l!==-1){let d=t.slice(n,l+1);(d.startsWith("[!")||d.startsWith("[^"))&&(d="[^"+d.slice(2)),this.ignorecase&&(d=d.toLowerCase()),r.push(d),n=l+1;continue}}if(p==="/"){r.push("/"),n++;continue}if(".+$^{}|()".includes(p)){r.push("\\"+p),n++;continue}if(this.ignorecase&&p>="A"&&p<="Z"){r.push("["+p.toLowerCase()+p+"]"),n++;continue}r.push(p),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 c=this.ignorecase?"i":"";try{return new RegExp("^"+s+"$",c)}catch(p){return this.debug&&console.error(`Failed to create regex for pattern "${t}":`,p),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 kn(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 Fr=kn,bt;(t=>t.fn=kn)(bt||(bt={}));k();function Br(){let r=ge.join(process.cwd(),".env");existsSync(r)&&config({path:r,override:true,debug:false,encoding:"utf-8",quiet:true});}k();async function _r(e,t){if(process.env.EASBOT_CLIENT==="acp")try{let s=process.platform==="win32"?"cmd":void 0,a=ne.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,c,p]=await Promise.all([a.exited,new Response(a.stdout).arrayBuffer(),new Response(a.stderr).arrayBuffer()]),l=Buffer.from(c),d=Buffer.from(p);return {exitCode:i,text:()=>l.toString(),stdout:l,stderr:d}}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=ne.$`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 vn(e){return e?dirname(fileURLToPath(e)):typeof i<"u"?i:process.cwd()}function Tn(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 c=join(o,i);try{let p=statSync(c);if(p.isFile()&&c.endsWith(t))return c;if(p.isDirectory()&&s<r){let l=n(c,s+1);if(l)return l}}catch{}}}catch{}return null}return n(e,0)}function Rn(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 p=Tn(a,n,5);if(p)return p}let i=join(o,"dist","assets","txt");if(existsSync(i)){let p=Tn(i,n,5);if(p)return p}let c=join(o,"..");if(c===o)break;o=c;}return r}function Hr(e,t){return fe.lazy(()=>{try{let r=vn(t),n=Rn(r,e);return _.file(n).textSync()}catch(r){throw console.error(`Failed to load text file: ${e}`,r),r}})}function Wr(e,t){return fe.lazy(async()=>{try{let r=vn(t),n=Rn(r,e);return await _.file(n).text()}catch(r){throw console.error(`Failed to load text file: ${e}`,r),r}})}k();function Ur(e){return e()}k();function qr(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 yt(e,t,r,n=()=>true){let o=-1,s=-1,a=0;for(let i=t;i<r;i++){if(!n(i))continue;let c=e[i];if(c){if(c==="("){a+=1;continue}if(c===")"&&a>0){a-=1;continue}a===0&&(c===`
|
|
41
|
+
`?o=i:/\s/.test(c)&&(s=i));}}return {lastNewline:o,lastWhitespace:s}}function Yr(e,t){if(!e)return [];if(t<=0)return [e];if(e.length<=t)return [e]}function he(e,t,r){try{let n=z.string().parse(e),o=z.number().int().parse(t),s=Yr(n,o);if(s)return s;let a=xt(n,o,i=>{let{lastNewline:c,lastWhitespace:p}=yt(i,0,i.length);return c>0?c:p});return r?.minLength&&r.minLength>0&&(a=Mn(a,r.minLength)),a}catch(n){return console.warn("Invalid input for chunkText:",n),typeof e=="string"&&e.length>0?[e]:[]}}function Mn(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 xt(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,p=o.slice(0,i).trimEnd();p.length>0&&n.push(p);let
|
|
45
|
+
`+n);}else r.push(n);return r}function xt(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,p=o.slice(0,i).trimEnd();p.length>0&&n.push(p);let l=i<o.length&&o[i]!==void 0&&/\s/.test(o[i]),d=Math.min(o.length,i+(l?1:0));o=o.slice(d).trimStart();}return o.length>0&&n.push(o),n}k();var wt=z.enum(["bold","italic","strikethrough","code","code_block","spoiler","blockquote"]),En=z.object({start:z.number().int().min(0),end:z.number().int().min(0),style:wt}).strict().refine(e=>e.end>=e.start,{message:"end must be greater than or equal to start"}),Cn=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"}),Me=z.object({text:z.string(),styles:z.array(En),links:z.array(Cn)}).strict(),Ee=z.enum(["off","bullets","code"]),Ne=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:Ee.default("off")}).partial().default({}),On=z.object({open:z.string(),close:z.string()}).strict(),St=z.object({styleMarkers:z.record(wt,On).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 kt=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(),Tt=z.record(z.string(),z.string()),ze=z.object({open:z.boolean(),ticks:z.number().int().min(0)}).strict();z.object({inlineState:ze,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:Ee.optional()}).strict();function Xr(e){let t=new Zr({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 In(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 vt(e,t){return {...e,type:"text",content:t,children:void 0}}function Qr(e){for(let t of e)t.children&&t.children.length>0&&(t.children=eo(t.children));}function eo(e){let t=0;for(let a of e){if(a.type!=="text")continue;let i=a.content??"",c=0;for(;c<i.length;){let p=i.indexOf("||",c);if(p===-1)break;t+=1,c=p+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 c=0;for(;c<i.length;){let p=i.indexOf("||",c);if(p===-1){c<i.length&&n.push(vt(a,i.slice(c)));break}if(s>=r){n.push(vt(a,i.slice(c)));break}p>c&&n.push(vt(a,i.slice(c,p))),s+=1,o.spoilerOpen=!o.spoilerOpen,n.push({type:o.spoilerOpen?"spoiler_open":"spoiler_close"}),c=p+2;}}return n}function to(){return {text:"",styles:[],openStyles:[],links:[],linkStack:[]}}function ue(e){return e.table?.currentCell??e}function He(e,t){if(!t)return;let r=ue(e);r.text+=t;}function be(e,t){let r=ue(e);r.openStyles.push({style:t,start:r.text.length});}function ye(e,t){let r=ue(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 Fn(e){e.env.listStack.length>0||e.table||(e.text+=`
|
|
46
46
|
|
|
47
|
-
`);}function no(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 ro(e,t){if(!t)return;let r=
|
|
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 uo(e){if(!e.table)return;let t=e.table.headers.map(We),r=e.table.rows.map(
|
|
52
|
-
`;},
|
|
53
|
-
`;};i(t),
|
|
54
|
-
`);break;case "paragraph_close":Fn(t);break;case "heading_open":t.headingStyle==="bold"&&
|
|
47
|
+
`);}function no(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 ro(e,t){if(!t)return;let r=ue(e),n=r.text.length;r.text+=t,r.styles.push({start:n,end:n+t.length,style:"code"});}function oo(e,t){let r=t??"",n=ue(e),o=n.text.length;n.text+=r,n.styles.push({start:o,end:o+r.length,style:"code_block"});}function so(e){let t=ue(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 io(){return {headers:[],rows:[],currentRow:[],currentCell:null,inHeader:false}}function ao(e){return $n(e),{text:e.text,styles:e.styles,links:e.links}}function We(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 c of e.styles){let p=Math.max(0,c.start-r),l=Math.min(s,c.end-r);l>p&&a.push({start:p,end:l,style:c.style});}let i=[];for(let c of e.links){let p=Math.max(0,c.start-r),l=Math.min(s,c.end-r);l>p&&i.push({start:p,end:l,href:c.href});}return {text:o,styles:a,links:i}}function Rt(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 co(e,t){t.text&&(e.text+=t.text);}function An(e,t){let{header:r,value:n,columnIndex:o,includeColumnFallback:s}=t;n?.text&&(e.text+="\u2022 ",r?.text?(Rt(e,r),e.text+=": "):s&&(e.text+=`Column ${o}: `),Rt(e,n),e.text+=`
|
|
48
|
+
`);}function lo(e){if(!e.table)return;let t=e.table.headers.map(We),r=e.table.rows.map(o=>o.map(We));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;Rt(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++)An(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++)An(e,{header:t[s],value:o[s],columnIndex:s,includeColumnFallback:false});e.text+=`
|
|
51
|
+
`;}}function uo(e){if(!e.table)return;let t=e.table.headers.map(We),r=e.table.rows.map(l=>l.map(We)),n=Math.max(t.length,...r.map(l=>l.length));if(n===0)return;let o=Array.from({length:n},()=>0),s=l=>{for(let d=0;d<n;d+=1){let k=l[d]?.text.length??0;(o[d]??0)<k&&(o[d]=k);}};s(t);for(let l of r)s(l);let a=e.text.length,i=l=>{e.text+="|";for(let d=0;d<n;d+=1){e.text+=" ";let g=l[d];g&&co(e,g);let k=g?.text.length??0,D=(o[d]??0)-k;D>0&&(e.text+=" ".repeat(D)),e.text+=" |";}e.text+=`
|
|
52
|
+
`;},c=()=>{e.text+="|";for(let l=0;l<n;l+=1){let d=o[l]??0,g=Math.max(3,d);e.text+=` ${"-".repeat(g)} |`;}e.text+=`
|
|
53
|
+
`;};i(t),c();for(let l of r)i(l);let p=e.text.length;p>a&&e.styles.push({start:a,end:p,style:"code_block"});}function Pt(e,t){for(let r of e)switch(r.type){case "inline":r.children&&Pt(r.children,t);break;case "text":He(t,r.content??"");break;case "em_open":be(t,"italic");break;case "em_close":ye(t,"italic");break;case "strong_open":be(t,"bold");break;case "strong_close":ye(t,"bold");break;case "s_open":be(t,"strikethrough");break;case "s_close":ye(t,"strikethrough");break;case "code_inline":ro(t,r.content??"");break;case "spoiler_open":t.enableSpoilers&&be(t,"spoiler");break;case "spoiler_close":t.enableSpoilers&&ye(t,"spoiler");break;case "link_open":{let n=In(r,"href")??"",o=ue(t);o.linkStack.push({href:n,labelStart:o.text.length});break}case "link_close":so(t);break;case "image":He(t,r.content??"");break;case "softbreak":case "hardbreak":He(t,`
|
|
54
|
+
`);break;case "paragraph_close":Fn(t);break;case "heading_open":t.headingStyle==="bold"&&be(t,"bold");break;case "heading_close":t.headingStyle==="bold"&&ye(t,"bold"),Fn(t);break;case "blockquote_open":t.blockquotePrefix&&(t.text+=t.blockquotePrefix),be(t,"blockquote");break;case "blockquote_close":ye(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
57
|
`);let n=Number(In(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
58
|
`);break;case "list_item_open":no(t);break;case "list_item_close":t.text.endsWith(`
|
|
59
59
|
`)||(t.text+=`
|
|
60
|
-
`);break;case "code_block":case "fence":oo(t,r.content??"");break;case "html_block":case "html_inline":He(t,r.content??"");break;case "table_open":t.tableMode!=="off"&&(t.table=io(),t.hasTables=true);break;case "table_close":t.table&&(t.tableMode==="bullets"?
|
|
60
|
+
`);break;case "code_block":case "fence":oo(t,r.content??"");break;case "html_block":case "html_inline":He(t,r.content??"");break;case "table_open":t.tableMode!=="off"&&(t.table=io(),t.hasTables=true);break;case "table_close":t.table&&(t.tableMode==="bullets"?lo(t):t.tableMode==="code"&&uo(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=to());break;case "th_close":case "td_close":t.table?.currentCell&&(t.table.currentRow.push(ao(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&&Pt(r.children,t);break}}function $n(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 fo(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 po(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 Ln(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 Bn(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 mo(e,t,r){if(e.length===0)return [];let n=[];for(let o of e){let s=Bn(o,t,r);s&&n.push({start:s.start-t,end:s.end-t,style:o.style});}return Ln(n)}function go(e,t,r){if(e.length===0)return [];let n=[];for(let o of e){let s=Bn(o,t,r);s&&n.push({start:s.start-t,end:s.end-t,href:o.href});}return n}function xe(e,t){try{let r=typeof e=="string"?e:"",n=Ne.parse(t??{});return Ce(r,n).ir}catch(r){return console.error("Markdown parse error:",r),{text:"",styles:[],links:[]}}}function Ce(e,t){try{let r=typeof e=="string"?e:"",n=Ne.parse(t),o={listStack:[]},a=Xr(n).parse(r||"",o);n.enableSpoilers&&Qr(a);let i=n.tableMode??"off",c={text:"",styles:[],openStyles:[],links:[],linkStack:[],env:o,headingStyle:n.headingStyle??"none",blockquotePrefix:n.blockquotePrefix??"",enableSpoilers:n.enableSpoilers??!1,tableMode:i,table:null,hasTables:!1};Pt(a,c),$n(c);let l=c.text.trimEnd().length,d=0;for(let P of c.styles)P.style==="code_block"&&P.end>d&&(d=P.end);let g=Math.max(l,d);return {ir:{text:g===c.text.length?c.text:c.text.slice(0,g),styles:Ln(fo(c.styles,g)),links:po(c.links,g)},hasTables:c.hasTables}}catch(r){return console.error("Markdown parse error:",r),{ir:{text:"",styles:[],links:[]},hasTables:false}}}function _n(e,t){try{let r=Me.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=he(r.text,n),s=[],a=0;return o.forEach((i,c)=>{if(!i)return;if(c>0)for(;a<r.text.length&&/\s/.test(r.text[a]??"");)a+=1;let p=a,l=Math.min(r.text.length,p+i.length);s.push({text:i,styles:mo(r.styles,p,l),links:go(r.links,p,l)}),a=l;}),s}catch(r){return console.error("Chunk IR error:",r),[]}}k();var ho={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function Oe(e,t){try{let r=Me.parse(e),n=St.parse(t??{});if(!r.text)return "";let o=n.styleMarkers??ho,s=n.escapeText??(d=>d),a=n.buildLink,i=[];for(let d=0;d<r.styles.length;d++){let g=r.styles[d];g&&(i.push({position:g.start,type:"open",style:g.style,spanIndex:d}),i.push({position:g.end,type:"close",style:g.style,spanIndex:d}));}for(let d=0;d<r.links.length;d++){let g=r.links[d];g&&(i.push({position:g.start,type:"link_open",spanIndex:d,href:g.href}),i.push({position:g.end,type:"link_close",spanIndex:d,href:g.href}));}i.sort((d,g)=>{if(d.position!==g.position)return d.position-g.position;let k=(N,ae)=>N==="link_open"?0:N==="open"?1:N==="close"?2:N==="link_close"?3:4,P=d.type==="close"||d.type==="link_close",D=g.type==="close"||g.type==="link_close",H=k(d.type,P),q=k(g.type,D);return H!==q?H-q:d.type==="open"&&g.type==="open"?d.spanIndex-g.spanIndex:d.type==="close"&&g.type==="close"?g.spanIndex-d.spanIndex:d.spanIndex-g.spanIndex});let c="",p=0,l=[];for(let d of i){if(d.position>p){let g=r.text.slice(p,d.position);c+=s?s(g):g;}if(d.type==="open"||d.type==="close"){let g=o[d.style];if(g)if(d.type==="open")c+=g.open,l.push(d);else {c+=g.close,d.style==="code_block"&&d.position<r.text.length&&(c+=`
|
|
63
|
+
`);let k=l.findIndex(P=>P.spanIndex===d.spanIndex&&P.type==="open");k!==-1&&l.splice(k,1);}}else if(d.type==="link_open")c+="[",l.push(d);else if(d.type==="link_close"){c+="]("+d.href+")";let g=l.findIndex(k=>k.spanIndex===d.spanIndex&&k.type==="link_open");g!==-1&&l.splice(g,1);}p=d.position;}if(p<r.text.length){let d=r.text.slice(p);c+=s?s(d):d;}return c}catch(r){return console.error("Markdown render error:",r),""}}function we(e,t){return Oe(e,t)}k();function bo(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 Ue(e,t){try{let r=typeof e=="string"?e:"",n=kt.parse(t??{});if(!r)return "";let{frontmatter:o,content:s}=bo(r),a=
|
|
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 Ue(e,t){try{let r=typeof e=="string"?e:"",n=kt.parse(t??{});if(!r)return "";let{frontmatter:o,content:s}=bo(r),a=xe(s,{linkify:!0,enableSpoilers:!1,autolink:!0,headingStyle:"none",blockquotePrefix:"",tableMode:"off"}),i=we(a);return i=i.replace(/\n{3,}/g,`
|
|
67
67
|
|
|
68
68
|
`),i=i.trimEnd()+`
|
|
69
69
|
`,n.preserveFrontmatter&&o&&(i=o+`
|
|
70
70
|
`+i),i}catch(r){return console.error("Markdown format error:",r),e}}k();function yo(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function xo(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 wo(e){try{let t=jn.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=xo(o);a&&(r[s]=a);}return r}catch{return null}}function So(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
71
|
`).trim(),linesConsumed:n-t}}function ko(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 p=r[n+1];if(p&&(p.startsWith(" ")||p.startsWith(" "))){let{value:
|
|
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 p=r[n+1];if(p&&(p.startsWith(" ")||p.startsWith(" "))){let{value:l,linesConsumed:d}=So(r,n);l&&(t[a]={value:l,kind:"multiline",rawInline:i}),n+=d;continue}}let c=yo(i);c&&(t[a]={value:c,kind:"inline",rawInline:i}),n+=1;}return t}function To(e){let t={};for(let[r,n]of Object.entries(e))t[r]=n.value;return t}function vo(e){return /^[|>][+-]?(\d+)?[+-]?$/.test(e)}function Ro(e){let{lineEntry:t,yamlValue:r}=e;return r.kind!=="structured"||t.kind!=="inline"||vo(t.rawInline)?false:t.value.includes(":")}function Po(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
|
|
75
|
+
---`,3);if(r!==-1)return t.slice(4,r)}function Ie(e){try{if(typeof e!="string")return {};let t=Po(e);if(!t)return {};let r=ko(t),n=wo(t);if(n===null)return To(r);let o={};for(let[s,a]of Object.entries(n)){o[s]=a.value;let i=r[s];i&&Ro({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 qe(e){try{let t=Tt.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
76
|
${jn.stringify(r,{lineWidth:0,defaultStringType:"QUOTE_DOUBLE"}).trim()}
|
|
77
77
|
---`}catch(t){return console.warn("Failed to serialize frontmatter:",t),""}}function Ye(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:
|
|
81
|
-
`,o),a=s===-1?t.length:s,i=t.slice(o,a),
|
|
82
|
-
Content-Type: ${
|
|
80
|
+
---`,3);if(r===-1)return {frontmatter:{},content:e};let n=t.slice(4,r),o=t.slice(r+4).trimStart();return {frontmatter:Ie(e),content:o}}catch(t){return console.warn("Failed to extract frontmatter:",t),{frontmatter:{},content:e}}}k();k();function Ve(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),c=i.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(c){let p=c[1],l=c[2];if(!p||!l){o=a+1;continue}let d=l[0];if(!d){o=a+1;continue}let g=l.length;if(!n)n={start:o,markerChar:d,markerLen:g,openLine:i,marker:l,indent:p};else if(n.markerChar===d&&g>=n.markerLen){let k=a;r.push({start:n.start,end:k,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 Mt(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 Dn(e,t){return !Mt(e,t)}function Ge(){return {open:false,ticks:0}}function Je(e,t){try{let r=z.string().parse(e),n=t?ze.parse(t):Ge(),o=Ve(r),s={open:n.open,ticks:n.ticks},{spans:a,state:i}=Co(r,o,s);return {inlineState:i,isInside:c=>Io(c,o)||Fo(c,a)}}catch(r){return console.warn("Invalid input for buildCodeSpanIndex:",r),{inlineState:Ge(),isInside:()=>false}}}function Co(e,t,r){let n=[],o=r.open,s=r.ticks,a=o?0:-1,i=0;for(;i<e.length;){let c=Oo(t,i);if(c){i=c.end;continue}if(e[i]!=="`"){i+=1;continue}let p=i,l=0;for(;i<e.length&&e[i]==="`";)l+=1,i+=1;if(!o){o=true,s=l,a=p;continue}l===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 Oo(e,t){return e.find(r=>t>=r.start&&t<r.end)}function Io(e,t){return t.some(r=>e>=r.start&&e<r.end)}function Fo(e,t){return t.some(([r,n])=>e>=r&&e<n)}k();var $o={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=z.string().parse(e),n=Ee.parse(t);if(!r||n==="off")return r;let{ir:o,hasTables:s}=Ce(r,{linkify:!1,enableSpoilers:!1,autolink:!1,headingStyle:"none",blockquotePrefix:"",tableMode:n});return s?Oe(o,{styleMarkers:$o,escapeText:a=>a,buildLink:(a,i)=>{let c=a.href.trim();return !c||!i.slice(a.start,a.end)?null:{start:a.start,end:a.end,open:"[",close:`](${c})`}}}):r}catch(r){return console.warn("Invalid input for convertMarkdownTables:",r),typeof e=="string"?e:""}}var Et;(p=>{function e(l,d){try{return xe(l,d)}catch(g){return console.warn("Markdown.parse error:",g),{text:"",styles:[],links:[]}}}p.parse=e;function t(l,d){try{return we(l,d)}catch(g){return console.warn("Markdown.render error:",g),""}}p.render=t;function r(l,d){try{return Ue(l,d)}catch(g){return console.warn("Markdown.format error:",g),typeof l=="string"?l:""}}p.format=r;function n(l){try{return Ie(l)}catch(d){return console.warn("Markdown.parseFrontmatter error:",d),{}}}p.parseFrontmatter=n;function o(l){try{return qe(l)}catch(d){return console.warn("Markdown.serializeFrontmatter error:",d),""}}p.serializeFrontmatter=o;function s(l){try{return Ye(l)}catch(d){return console.warn("Markdown.extractFrontmatter error:",d),{frontmatter:{},content:typeof l=="string"?l:""}}}p.extractFrontmatter=s;function a(l,d,g){try{return he(l,d,g)}catch(k){return console.warn("Markdown.chunk error:",k),typeof l=="string"&&l.length>0?[l]:[]}}p.chunk=a;function i(l,d){try{return Je(l,d)}catch(g){return console.warn("Markdown.buildCodeIndex error:",g),{inlineState:{open:false,ticks:0},isInside:()=>false}}}p.buildCodeIndex=i;function c(l,d){try{return Ke(l,d)}catch(g){return console.warn("Markdown.convertTables error:",g),typeof l=="string"?l:""}}p.convertTables=c;})(Et||(Et={}));k();function Nn(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r[r.length-1]??""}function Lo(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r.slice(0,r.length-1).join("/")+"/"}function Bo(e){if(!e)return "";let t=e.split(".");return t[t.length-1]}function _o(e,t=20){let r=Nn(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 jo(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 Do=["load failed","network connection was lost","network request failed","failed to fetch","econnreset","econnrefused","etimedout","socket hang up"];function No(e){if(!e)return false;let t=String(e instanceof Error?e.message:e).toLowerCase();return Do.some(r=>t.includes(r))}async function zo(e,t={}){let{attempts:r=3,delay:n=500,factor:o=2,maxDelay:s=1e4,retryIf:a=No}=t,i;for(let c=0;c<r;c++)try{return await e()}catch(p){if(i=p,c===r-1||!a(p))throw p;let l=Math.min(n*o**c,s);await new Promise(d=>setTimeout(d,l));}throw i}k();var Ct;(Fe=>{let e=a.create({service:"fetch"}),t=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"],r=false,n=null;function o(){return t.some(I=>{let O=process.env[I];return typeof O=="string"&&O.trim().length>0})}Fe.hasProxyConfigured=o;function s(){let I=process.env.http_proxy||process.env.HTTP_PROXY;return process.env.https_proxy||process.env.HTTPS_PROXY||I}Fe.getProxyUrl=s;function a$1(I={}){let O=I.httpProxy||I.httpsProxy||s();if(!O){e.warn("[Fetch] \u672A\u914D\u7F6E\u4EE3\u7406\uFF0C\u73AF\u5883\u53D8\u91CF HTTP_PROXY/HTTPS_PROXY \u672A\u8BBE\u7F6E");return}let j=new ProxyAgent({uri:O,connectTimeout:I.connectTimeout||1e4,keepAliveTimeout:I.keepAliveTimeout||3e4});n=getGlobalDispatcher(),setGlobalDispatcher(j),r=true,console.log(`[Fetch] \u5168\u5C40\u4EE3\u7406\u5DF2\u542F\u7528: ${O}`);}Fe.enableProxy=a$1;function i(){!r||!n||(setGlobalDispatcher(n),r=false,n=null,console.log("[Fetch] \u5168\u5C40\u4EE3\u7406\u5DF2\u7981\u7528"));}Fe.disableProxy=i;function c$1(){return r}Fe.isProxyEnabled=c$1;async function p(I,O){let j=O?.timeout||3e4,G=O?.responseType||"json",{timeout:Y,responseType:de,...J}=O||{},$=null,w=null;try{J.signal||($=new AbortController,w=setTimeout(()=>$.abort(),j));let m=await fetch(I,{...J,signal:J.signal||$.signal});w&&clearTimeout(w);let f;switch(G){case "arrayBuffer":f=await m.arrayBuffer();break;case "blob":f=await m.blob();break;case "buffer":{let u=await m.arrayBuffer();f=Buffer.from(u);break}case "text":f=await m.text();break;default:{let u=await m.text();try{f=JSON.parse(u);}catch{f=u;}break}}return {ok:m.ok,status:m.status,statusText:m.statusText,headers:m.headers,data:f,url:m.url}}catch(m){throw w&&clearTimeout(w),m}}async function l(I,O){let j=O?.retries||0,G=O?.retryDelay||1e3,{retries:Y,retryDelay:de,responseType:J,...$}=O||{},w;for(let m=0;m<=j;m++)try{return await p(I,{...$,responseType:O?.responseType})}catch(f){if(w=f,m<j){let u=G*2**m;await new Promise(y=>setTimeout(y,u));}}throw w}async function d(I,O){return l(I,{method:"GET",...O})}Fe.get=d;async function g(I,O,j){return l(I,{method:"POST",headers:{"Content-Type":"application/json",...j?.headers},body:O?JSON.stringify(O):void 0,...j})}Fe.post=g;async function k(I,O,j){return l(I,{method:"PUT",headers:{"Content-Type":"application/json",...j?.headers},body:O?JSON.stringify(O):void 0,...j})}Fe.put=k;async function P(I,O,j){return l(I,{method:"DELETE",headers:{"Content-Type":"application/json",...j?.headers},body:O?JSON.stringify(O):void 0,...j})}Fe.del=P;async function D(I,O,j){return l(I,{method:"PATCH",headers:{"Content-Type":"application/json",...j?.headers},body:O?JSON.stringify(O):void 0,...j})}Fe.patch=D;async function H(I,O){return l(I,O)}Fe.request=H;function q(I={}){return o()?(a$1(I),true):false}Fe.autoProxy=q;function N(I){return new TextEncoder().encode(I)}function ae(I){return c.mimeType(I)}function Se(I){return I.startsWith("file://")}async function Ze(I){let O=fileURLToPath(I);return await _.file(O).bytes()}async function Nt(I,O,j){let G=`----FetchFormBoundary${Date.now()}`,Y=[];for(let u of O){let y=u.filename,x=`Content-Disposition: form-data; name="${u.name}"${y?`; filename="${y}"`:""}`;y&&(x+=`\r
|
|
82
|
+
Content-Type: ${ae(y)}`),x+=`\r
|
|
83
83
|
\r
|
|
84
|
-
`,
|
|
85
|
-
--${
|
|
86
|
-
--${
|
|
87
|
-
`)
|
|
88
|
-
`));for(let
|
|
89
|
-
`)));V.push(ce);let _=V.reduce((f,d)=>f+d.length,0),x=new Uint8Array(_),m=0;for(let f of V)x.set(f,m),m+=f.length;return c$1(O,{method:"POST",headers:{"Content-Type":`multipart/form-data; boundary=${Z}`,...j?.headers},body:x,...j})}zt.postForm=Nt;})(Ct||(Ct={}));k();var Ot;(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;})(Ot||(Ot={}));k();function Hn(e){let t=new AbortController,r=setTimeout(t.abort.bind(t),e);return {controller:t,signal:t.signal,clearTimeout:()=>globalThis.clearTimeout(r)}}function qo(e,...t){let r=Hn(e);return {signal:AbortSignal.any([r.signal,...t]),clearTimeout:r.clearTimeout}}k();var It;(t=>{async function e(r,n){if(process.platform==="win32"){let o=he.resolve(r),s=he.resolve(n),a=`Expand-Archive -Path '${o}' -DestinationPath '${s}' -Force`,i=await ne.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 ne.run(void 0,o);if(s.code!==0)throw new Error(`unzip exited with code ${s.code}: ${s.stderr}`)}}t.extractZip=e;})(It||(It={}));k();var Ft;(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;})(Ft||(Ft={}));k();var $t;(r=>{class e extends Error{constructor(s){super(`No context found for ${s}`);c$1(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;})($t||($t={}));k();function Vo(e){return {[Symbol.dispose](){e();},[Symbol.asyncDispose](){return Promise.resolve(e())}}}k();var At;(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;})(At||(At={}));k();function Go(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 Bt;(a=>{function e(i,l){if(i===l)return true;if(typeof i!="object"||typeof l!="object"||i===null||l===null)return false;let p=Object.keys(i),c=Object.keys(l);if(p.length!==c.length)return false;for(let u of p)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 p=l.join("+");return i.leader&&(p=p?`<leader> ${p}`:"<leader>"),p}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 g of c)switch(g){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=g;break}return u})}a.parse=s;})(Bt||(Bt={}));k();var Lt;(p=>{function e(c){return c.replace(/\b\w/g,u=>u.toUpperCase())}p.titlecase=e;function t(c){return new Date(c).toLocaleTimeString(void 0,{timeStyle:"short"})}p.time=t;function r(c){let u=new Date(c),g=t(c),S=u.toLocaleDateString();return `${g} \xB7 ${S}`}p.datetime=r;function n(c){let u=new Date(c),g=new Date;return u.getFullYear()===g.getFullYear()&&u.getMonth()===g.getMonth()&&u.getDate()===g.getDate()?t(c):r(c)}p.todayTimeOrDateTime=n;function o(c){return c>=1e6?(c/1e6).toFixed(1)+"M":c>=1e3?(c/1e3).toFixed(1)+"K":c.toString()}p.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),R=Math.floor(c%6e4/1e3);return `${S}m ${R}s`}if(c<864e5){let S=Math.floor(c/36e5),R=Math.floor(c%36e5/6e4);return `${S}h ${R}m`}let u=Math.floor(c/36e5);return `${Math.floor(c%36e5/864e5)}d ${u}h`}p.duration=s;function a(c,u){return c.length<=u?c:c.slice(0,u-1)+"\u2026"}p.truncate=a;function i(c,u=35){if(c.length<=u)return c;let g="\u2026",S=Math.ceil((u-g.length)/2),R=Math.floor((u-g.length)/2);return c.slice(0,S)+g+c.slice(-R)}p.truncateMiddle=i;function l(c,u,g){return (c===1?u:g).replace("{}",c.toString())}p.pluralize=l;})(Lt||(Lt={}));k();var Jo=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"];function Ko(){return Jo.some(e=>process.env[e])}function Zo(){return process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy}function Xo(){let e=process.env.HTTP_PROXY||process.env.http_proxy,t=process.env.HTTPS_PROXY||process.env.https_proxy;return {http:e,https:t,enabled:!!(e||t)}}k();var _t=class{constructor(){c$1(this,"queue",[]);c$1(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 es(){let e,t=new Promise(r=>e=r);return {trigger(){return e()},wait(){return t}}}k();function ts(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 jt;(a=>{let r=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function n(i){if(!i)return 0;let l=String(i),p=(l.match(r)||[]).length,c=l.length-p,u=Math.round(p/1.5),g=Math.round(c/4);return Math.max(0,u+g)}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,p=i.output??0,c=i.cache?.read??0,u=i.cache?.write??0;return l+p+c+u}a.total=s;})(jt||(jt={}));k();function rs(e){let t={};for(let[r,n]of Object.entries(e.required().shape))t[r]=n.nullable();return je.object(t)}k();var Dt;(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 p=i[0].length-l[0].length;return p!==0?p:i[0].localeCompare(l[0])})}function r(a,i){let l=Object.entries(i),p=t(l),c;for(let[u,g]of p)e(a,u)&&(c=g);return c}s.all=r;function n(a,i){let l=Object.entries(i),p=t(l),c;for(let[u,g]of p){let S=u.split(/\s+/);e(a.head,S[0])&&(S.length===1||o(a.tail,S.slice(1)))&&(c=g);}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}})(Dt||(Dt={}));async function hc(e){let{Log:t}=await import('./chunks/log-K3P7BT54.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{Or as $,It as Archive,_t as AsyncQueue,tt as Binary,Ft as Color,$t as Context,nt as Encode,At as EventLoop,Ct as Fetch,bt as Fn,Te as Identifier,gt as Ignore,Bt as Keybind,pe as Lazy,Lt as Locale,Et as Markdown,mt as NamedError,L as PKG,ve as PkgShell,it as SessionTitle,ne as Shell,Ot as Slug,jt as Token,rt as TruncateContent,Dt as Wildcard,Hn as abortAfter,qo as abortAfterAny,Je as buildCodeSpanIndex,_n as chunkMarkdownIR,be as chunkText,xt as chunkTextByBreakResolver,Ke as convertMarkdownTables,Ge as createInlineCodeState,de as createPkgShell,lt as createRESTServer,at as createRPCServer,ae as createServer,ut as createStreamingServer,ct as createWebSocketServer,Vo as defer,mn as detectPlatform,pt as escapeCommandArg,pn as escapeCommandArgSafe,Ye as extractFrontmatter,Mt as findFenceSpanAt,Jn as findLast,Fr as fn,Go as formatDuration,ot as formatLocalISO,st as formatLocalISOCompact,er as formatLogTime,Ue as formatMarkdown,Bo as getDirectory,Lo as getFileExtension,Nn as getFilename,_o as getFilenameTruncated,Xo as getProxyConfig,Zo as getProxyUrl,tr as getTimezoneOffset,_r as git,Ur as iife,hc as initLog,Dn as isSafeFenceBreak,me as joinCommandArgs,Ae as lazy,nr as lazyAsync,Lr as loadEnv,Hr as loadTextFile,Wr as loadTextFileAsync,we as markdownToIR,Oe as markdownToIRWithMeta,dn as needsShellExecution,Yt as now,Xn as nowLocalISO,oe as parseCommand,fn as parseCommandWithOptions,Ve as parseFenceSpans,Fe as parseFrontmatterBlock,Qn as parseLocalISO,qr as parseModelId,Ko as proxied,Mr as readableStreamToText,Se as renderMarkdown,Ie as renderMarkdownWithMarkers,zo as retry,yt as scanParenAwareBreakpoints,qe as serializeFrontmatter,hn as shell,es as signal,ir as startServer,jo as truncateMiddle,rs as updateSchema,Er as whichSync,ts as withTimeout,Qo as work};
|
|
84
|
+
`,Y.push(N(x));let h=u.value;if(typeof h=="string")if(Se(h)){let S=await Ze(h);y||(y=h.split("/").pop()||"file"),Y.push(S);}else Y.push(N(h));else Buffer.isBuffer(h)?Y.push(new Uint8Array(h.buffer,h.byteOffset,h.byteLength)):h instanceof Uint8Array&&Y.push(h);}let de=N(`\r
|
|
85
|
+
--${G}--`),J=N(`\r
|
|
86
|
+
--${G}\r
|
|
87
|
+
`),$=[];$.push(N(`--${G}\r
|
|
88
|
+
`));for(let u=0;u<Y.length;u++)$.push(Y[u]),u%2===1&&u<Y.length-1&&($.push(J),$.push(N(`--${G}\r
|
|
89
|
+
`)));$.push(de);let w=$.reduce((u,y)=>u+y.length,0),m=new Uint8Array(w),f=0;for(let u of $)m.set(u,f),f+=u.length;return l(I,{method:"POST",headers:{"Content-Type":`multipart/form-data; boundary=${G}`,...j?.headers},body:m,...j})}Fe.postForm=Nt;function zt(I,O,j){let G=new AbortController,Y=G.signal;return (async()=>{try{let J={Accept:"text/event-stream",...j?.headers||{}},$=await fetch(I,{...j,headers:J,signal:Y});if(!$.ok)throw new Error(`SSE connection failed: ${$.status}`);let w=$.body?.getReader();if(!w)throw new Error("SSE stream not available");let m=new TextDecoder("utf-8"),f="";for(;!Y.aborted;){let{done:u,value:y}=await w.read();if(u)break;let x=m.decode(y,{stream:!0});f+=x;let h=f.split(`
|
|
90
|
+
`);f=h.pop()??"";for(let S of h)if(S.startsWith("data: ")){let E=S.slice(6);if(E==="[DONE]"){O.onComplete?.();return}O.onMessage?.(E);}}O.onComplete?.();}catch(J){J.name!=="AbortError"&&O.onError?.(J);}})(),()=>{G.abort();}}Fe.sse=zt;})(Ct||(Ct={}));k();var Ot;(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;})(Ot||(Ot={}));k();function Hn(e){let t=new AbortController,r=setTimeout(t.abort.bind(t),e);return {controller:t,signal:t.signal,clearTimeout:()=>globalThis.clearTimeout(r)}}function qo(e,...t){let r=Hn(e);return {signal:AbortSignal.any([r.signal,...t]),clearTimeout:r.clearTimeout}}k();var It;(t=>{async function e(r,n){if(process.platform==="win32"){let o=ge.resolve(r),s=ge.resolve(n),a=`Expand-Archive -Path '${o}' -DestinationPath '${s}' -Force`,i=await ne.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 ne.run(void 0,o);if(s.code!==0)throw new Error(`unzip exited with code ${s.code}: ${s.stderr}`)}}t.extractZip=e;})(It||(It={}));k();var Ft;(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;})(Ft||(Ft={}));k();var At;(r=>{class e extends Error{constructor(s){super(`No context found for ${s}`);c$1(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;})(At||(At={}));k();function Vo(e){return {[Symbol.dispose](){e();},[Symbol.asyncDispose](){return Promise.resolve(e())}}}k();var $t;(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;})($t||($t={}));k();function Go(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 Lt;(a=>{function e(i,c){if(i===c)return true;if(typeof i!="object"||typeof c!="object"||i===null||c===null)return false;let p=Object.keys(i),l=Object.keys(c);if(p.length!==l.length)return false;for(let d of p)if(!l.includes(d)||!e(i[d],c[d]))return false;return true}function t(i){return {...i,super:i.super??false}}function r(i,c){return i?e(t(i),t(c)):false}a.match=r;function n(i,c=false){return {name:i.name,ctrl:i.ctrl,meta:i.meta,shift:i.shift,super:i.super??false,leader:c}}a.fromParsedKey=n;function o(i){if(!i)return "";let c=[];i.ctrl&&c.push("ctrl"),i.meta&&c.push("alt"),i.super&&c.push("super"),i.shift&&c.push("shift"),i.name&&(i.name==="delete"?c.push("del"):c.push(i.name));let p=c.join("+");return i.leader&&(p=p?`<leader> ${p}`:"<leader>"),p}a.keyToString=o;function s(i){return i==="none"?[]:i.split(",").map(c=>{let l=c.replace(/<leader>/g,"leader+").toLowerCase().split("+"),d={ctrl:false,meta:false,shift:false,super:false,leader:false,name:""};for(let g of l)switch(g){case "ctrl":d.ctrl=true;break;case "alt":case "meta":case "option":d.meta=true;break;case "super":d.super=true;break;case "shift":d.shift=true;break;case "leader":d.leader=true;break;case "esc":d.name="escape";break;default:d.name=g;break}return d})}a.parse=s;})(Lt||(Lt={}));k();var Bt;(p=>{function e(l){return l.replace(/\b\w/g,d=>d.toUpperCase())}p.titlecase=e;function t(l){return new Date(l).toLocaleTimeString(void 0,{timeStyle:"short"})}p.time=t;function r(l){let d=new Date(l),g=t(l),k=d.toLocaleDateString();return `${g} \xB7 ${k}`}p.datetime=r;function n(l){let d=new Date(l),g=new Date;return d.getFullYear()===g.getFullYear()&&d.getMonth()===g.getMonth()&&d.getDate()===g.getDate()?t(l):r(l)}p.todayTimeOrDateTime=n;function o(l){return l>=1e6?(l/1e6).toFixed(1)+"M":l>=1e3?(l/1e3).toFixed(1)+"K":l.toString()}p.number=o;function s(l){if(l<1e3)return `${l}ms`;if(l<6e4)return `${(l/1e3).toFixed(1)}s`;if(l<36e5){let k=Math.floor(l/6e4),P=Math.floor(l%6e4/1e3);return `${k}m ${P}s`}if(l<864e5){let k=Math.floor(l/36e5),P=Math.floor(l%36e5/6e4);return `${k}h ${P}m`}let d=Math.floor(l/36e5);return `${Math.floor(l%36e5/864e5)}d ${d}h`}p.duration=s;function a(l,d){return l.length<=d?l:l.slice(0,d-1)+"\u2026"}p.truncate=a;function i(l,d=35){if(l.length<=d)return l;let g="\u2026",k=Math.ceil((d-g.length)/2),P=Math.floor((d-g.length)/2);return l.slice(0,k)+g+l.slice(-P)}p.truncateMiddle=i;function c(l,d,g){return (l===1?d:g).replace("{}",l.toString())}p.pluralize=c;})(Bt||(Bt={}));k();var Jo=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"];function Ko(){return Jo.some(e=>process.env[e])}function Zo(){return process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy}function Xo(){let e=process.env.HTTP_PROXY||process.env.http_proxy,t=process.env.HTTPS_PROXY||process.env.https_proxy;return {http:e,https:t,enabled:!!(e||t)}}k();var _t=class{constructor(){c$1(this,"queue",[]);c$1(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 es(){let e,t=new Promise(r=>e=r);return {trigger(){return e()},wait(){return t}}}k();function ts(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 jt;(a=>{let r=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function n(i){if(!i)return 0;let c=String(i),p=(c.match(r)||[]).length,l=c.length-p,d=Math.round(p/1.5),g=Math.round(l/4);return Math.max(0,d+g)}a.estimate=n;function o(i){if(i==null)return 0;try{let c=typeof i=="string"?i:JSON.stringify(i);return n(c)}catch{return 0}}a.estimateObject=o;function s(i){if(i.total!==void 0&&i.total>0)return i.total;let c=i.input??0,p=i.output??0,l=i.cache?.read??0,d=i.cache?.write??0;return c+p+l+d}a.total=s;})(jt||(jt={}));k();function rs(e){let t={};for(let[r,n]of Object.entries(e.required().shape))t[r]=n.nullable();return je.object(t)}k();var Dt;(s=>{function e(a,i){let c=i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return c.endsWith(" .*")&&(c=c.slice(0,-3)+"( .*)?"),new RegExp("^"+c+"$","s").test(a)}s.match=e;function t(a){return a.sort((i,c)=>{let p=i[0].length-c[0].length;return p!==0?p:i[0].localeCompare(c[0])})}function r(a,i){let c=Object.entries(i),p=t(c),l;for(let[d,g]of p)e(a,d)&&(l=g);return l}s.all=r;function n(a,i){let c=Object.entries(i),p=t(c),l;for(let[d,g]of p){let k=d.split(/\s+/);e(a.head,k[0])&&(k.length===1||o(a.tail,k.slice(1)))&&(l=g);}return l}s.allStructured=n;function o(a,i){if(i.length===0)return true;if(a.length<i.length)return false;for(let c=0;c<i.length;c++)if(!e(a[c],i[c]))return false;return true}})(Dt||(Dt={}));async function hl(e){let{Log:t}=await import('./chunks/log-K3P7BT54.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{Or as $,It as Archive,_t as AsyncQueue,tt as Binary,Ft as Color,At as Context,nt as Encode,$t as EventLoop,Ct as Fetch,bt as Fn,ke as Identifier,gt as Ignore,Lt as Keybind,fe as Lazy,Bt as Locale,Et as Markdown,mt as NamedError,_ as PKG,Te as PkgShell,it as SessionTitle,ne as Shell,Ot as Slug,jt as Token,rt as TruncateContent,Dt as Wildcard,Hn as abortAfter,qo as abortAfterAny,Je as buildCodeSpanIndex,_n as chunkMarkdownIR,he as chunkText,xt as chunkTextByBreakResolver,Ke as convertMarkdownTables,Ge as createInlineCodeState,le as createPkgShell,ct as createRESTServer,at as createRPCServer,ie as createServer,ut as createStreamingServer,lt as createWebSocketServer,Vo as defer,mn as detectPlatform,pt as escapeCommandArg,pn as escapeCommandArgSafe,Ye as extractFrontmatter,Mt as findFenceSpanAt,Jn as findLast,Fr as fn,Go as formatDuration,ot as formatLocalISO,st as formatLocalISOCompact,er as formatLogTime,Ue as formatMarkdown,Lo as getDirectory,Bo as getFileExtension,Nn as getFilename,_o as getFilenameTruncated,Xo as getProxyConfig,Zo as getProxyUrl,tr as getTimezoneOffset,_r as git,Ur as iife,hl as initLog,Dn as isSafeFenceBreak,pe as joinCommandArgs,$e as lazy,nr as lazyAsync,Br as loadEnv,Hr as loadTextFile,Wr as loadTextFileAsync,xe as markdownToIR,Ce as markdownToIRWithMeta,dn as needsShellExecution,Yt as now,Xn as nowLocalISO,oe as parseCommand,fn as parseCommandWithOptions,Ve as parseFenceSpans,Ie as parseFrontmatterBlock,Qn as parseLocalISO,qr as parseModelId,Ko as proxied,Mr as readableStreamToText,we as renderMarkdown,Oe as renderMarkdownWithMarkers,zo as retry,yt as scanParenAwareBreakpoints,qe as serializeFrontmatter,hn as shell,es as signal,ir as startServer,jo as truncateMiddle,rs as updateSchema,Er as whichSync,ts as withTimeout,Qo as work};
|