@easbot/utils 0.3.4 → 0.3.5
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 +48 -46
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.mjs +46 -44
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use strict';var chunkYPKMFQLR_cjs=require('./chunks/chunk-YPKMFQLR.cjs'),chunkZHSHEAQD_cjs=require('./chunks/chunk-ZHSHEAQD.cjs'),chunkAHO55TRS_cjs=require('./chunks/chunk-AHO55TRS.cjs'),chunkYC4AEMOP_cjs=require('./chunks/chunk-YC4AEMOP.cjs'),chunkVRQQ33YH_cjs=require('./chunks/chunk-VRQQ33YH.cjs'),oe=require('fs/promises'),
|
|
2
|
-
Full ${
|
|
3
|
-
Use Read tool with offset/limit parameters to view specific sections.]`:`[Content truncated. Full ${
|
|
4
|
-
Use Read tool with offset/limit parameters to view specific sections.]`}async function a(c,
|
|
1
|
+
'use strict';var chunkYPKMFQLR_cjs=require('./chunks/chunk-YPKMFQLR.cjs'),chunkZHSHEAQD_cjs=require('./chunks/chunk-ZHSHEAQD.cjs'),chunkAHO55TRS_cjs=require('./chunks/chunk-AHO55TRS.cjs'),chunkYC4AEMOP_cjs=require('./chunks/chunk-YC4AEMOP.cjs'),chunkVRQQ33YH_cjs=require('./chunks/chunk-VRQQ33YH.cjs'),oe=require('fs/promises'),De=require('zod'),crypto$1=require('crypto'),he=require('path'),Ne=require('fs'),child_process=require('child_process'),module$1=require('module'),hono=require('hono'),nodeServer=require('@hono/node-server'),nodeWs=require('@hono/node-ws'),streaming=require('hono/streaming'),cors=require('hono/cors'),logger=require('hono/logger'),compress=require('hono/compress'),secureHeaders=require('hono/secure-headers'),timeout=require('hono/timeout'),httpException=require('hono/http-exception'),validator=require('hono/validator'),zodValidator=require('@hono/zod-validator'),minimatch=require('minimatch'),promises=require('timers/promises'),dotenv=require('dotenv'),xdgBasedir=require('xdg-basedir'),url=require('url'),ro=require('markdown-it'),jn=require('yaml'),undici=require('undici'),async_hooks=require('async_hooks');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var oe__default=/*#__PURE__*/_interopDefault(oe);var De__default=/*#__PURE__*/_interopDefault(De);var he__default=/*#__PURE__*/_interopDefault(he);var Ne__default=/*#__PURE__*/_interopDefault(Ne);var ro__default=/*#__PURE__*/_interopDefault(ro);var jn__default=/*#__PURE__*/_interopDefault(jn);chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function ir(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}}chunkVRQQ33YH_cjs.j();exports.Binary=void 0;(r=>{function e(n,o,s){let a=0,i=n.length-1;for(;a<=i;){let l=Math.floor((a+i)/2),p=n[l];if(p===void 0)break;let c=s(p);if(c===o)return {found:true,index:l};c<o?a=l+1:i=l-1;}return {found:false,index:a}}r.search=e;function t(n,o,s){let a=s(o),i=0,l=n.length;for(;i<l;){let p=Math.floor((i+l)/2),c=n[p];if(c===void 0)break;s(c)<a?i=p+1:l=p;}return n.splice(i,0,o),n}r.insert=t;})(exports.Binary||(exports.Binary={}));chunkVRQQ33YH_cjs.j();exports.Encode=void 0;(s=>{function e(a){let i=new TextEncoder().encode(a),l=Array.from(i,p=>String.fromCharCode(p)).join("");return btoa(l).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}s.base64Encode=e;function t(a){let i=atob(a.replace(/-/g,"+").replace(/_/g,"/")),l=Uint8Array.from(i,p=>p.charCodeAt(0));return new TextDecoder().decode(l)}s.base64Decode=t;async function r(a,i="SHA-256"){let p=new TextEncoder().encode(a),c=await crypto.subtle.digest(i,p);return Array.from(new Uint8Array(c)).map(k=>k.toString(16).padStart(2,"0")).join("")}s.hash=r;function n(a){if(!a)return;let i=2166136261;for(let l=0;l<a.length;l++)i^=a.charCodeAt(l),i=Math.imul(i,16777619);return (i>>>0).toString(36)}s.checksum=n;function o(a,i=5e5){if(!a)return;if(a.length<=i)return n(a);let l=4096,c=[0,Math.floor(a.length*.25),Math.floor(a.length*.5),Math.floor(a.length*.75),a.length-l].map(u=>{let g=Math.max(0,Math.min(a.length-l,u-Math.floor(l/2)));return n(a.slice(g,g+l))??""}).join(":");return `${a.length}:${c}`}s.sampledChecksum=o;})(exports.Encode||(exports.Encode={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();exports.Identifier=void 0;(u=>{let e={event:"evt",session:"ses",message:"msg",permission:"per",question:"que",user:"usr",part:"prt",pty:"pty",tool:"tool",workspace:"wrk",command:"cmd",task:"task",heartbeat:"hb",agent:"ag",subagent:"sub",hook:"hok",compaction:"cmp",context:"ctx",experience:"exp",pattern:"pat",knowledge:"knw",evolution:"evo",result:"res"};function t(g){return De__default.default.string().startsWith(e[g])}u.schema=t;let r=26,n=0,o=0;function s(g,k){return i(g,false,k)}u.ascending=s;function a(g,k){return i(g,true,k)}u.descending=a;function i(g,k,E){if(!E)return p(g,k);if(!E.startsWith(e[g]))throw new Error(`ID ${E} does not start with ${e[g]}`);return E}function l(g){let k="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",E="",H=crypto$1.randomBytes(g);for(let U=0;U<g;U++){let q=H[U];q!==void 0&&(E+=k[q%62]);}return E}function p(g,k,E){let H=E??Date.now();H!==n&&(n=H,o=0),o++;let U=BigInt(H)*BigInt(4096)+BigInt(o);U=k?~U:U;let q=Buffer.alloc(6);for(let G=0;G<6;G++)q[G]=Number(U>>BigInt(40-8*G)&BigInt(255));return e[g]+"_"+q.toString("hex")+l(r-12)}u.create=p;function c(g){let k=g.split("_")[0];if(!k)return 0;let E=g.slice(k.length+1,k.length+13),H=BigInt("0x"+E);return Number(H/BigInt(4096))}u.timestamp=c;})(exports.Identifier||(exports.Identifier={}));exports.TruncateContent=void 0;(p=>{p.DEFAULT_MAX_CHARS=4e3,p.DIRECTION="head",p.DIR=chunkYPKMFQLR_cjs.c.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),p.GLOB=chunkYPKMFQLR_cjs.c.join(p.DIR,"*");let o=10080*60*1e3;function s(c,u,g){return g?`[Content truncated. Source: ${g}
|
|
2
|
+
Full ${u} saved to: ${c}
|
|
3
|
+
Use Read tool with offset/limit parameters to view specific sections.]`:`[Content truncated. Full ${u} saved to: ${c}
|
|
4
|
+
Use Read tool with offset/limit parameters to view specific sections.]`}async function a(c,u={}){let g=u.maxChars??4e3,k=u.direction??p.DIRECTION,E=u.label??"content",H=u.sourcePath,U=chunkYPKMFQLR_cjs.c.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),q=u.dir??U;if(c.length<=g)return {content:c,truncated:false};let G=exports.Identifier.ascending("context"),V=chunkYPKMFQLR_cjs.c.join(q,G);await oe__default.default.mkdir(q,{recursive:true}).catch(()=>{}),await oe__default.default.writeFile(V,c,"utf-8");let de=c.length-g,se;k==="head"?se=c.slice(0,g):se=c.slice(-g);let fe=s(V,E,H),ke=`${de} characters truncated`;return {content:k==="head"?`${se}
|
|
5
5
|
|
|
6
6
|
...${ke}...
|
|
7
7
|
|
|
@@ -9,11 +9,11 @@ ${fe}`:`...${ke}...
|
|
|
9
9
|
|
|
10
10
|
${fe}
|
|
11
11
|
|
|
12
|
-
${se}`,truncated:true,outputPath:G,originalLength:c.length,removedLength:de,label:E}}p.truncate=a;function i(c){return c.truncated?s(c.outputPath,c.label):""}p.formatHint=i;async function l(){let c=exports.Identifier.timestamp(exports.Identifier.create("context",false,Date.now()-o)),g=(await oe__default.default.readdir(p.DIR).catch(()=>[])).filter(k=>k.startsWith("context_"));for(let k of g)exports.Identifier.timestamp(k)>=c||await oe__default.default.unlink(chunkYPKMFQLR_cjs.c.join(p.DIR,k)).catch(()=>{});}p.cleanup=l;})(exports.TruncateContent||(exports.TruncateContent={}));chunkVRQQ33YH_cjs.j();exports.SessionTitle=void 0;(i=>{let e="New session - ",t="Child session - ";i.parentTitlePrefix=e,i.childTitlePrefix=t;function o(l=false){return (l?t:e)+chunkZHSHEAQD_cjs.b(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]??"",d=parseInt(p[2]??"0",10);return `${c} (fork #${d+1})`}return `${l} (fork #1)`}i.getForked=a;})(exports.SessionTitle||(exports.SessionTitle={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function qt(e){let t,r=false,n=()=>(r||(t=e(),r=true),t);return n.reset=()=>{r=false,t=void 0;},n}var $e=qt;function Yt(e){let t,r=()=>(t||(t=e()),t);return r.reset=()=>{t=void 0;},r}var ar=Yt;exports.Lazy=void 0;(r=>(r.lazy=qt,r.lazyAsync=Yt))(exports.Lazy||(exports.Lazy={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();var ne=chunkZHSHEAQD_cjs.m.create({service:"server"});function ae(e={}){let t=e.port??3e3,r=e.hostname??"0.0.0.0",n=new hono.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)=>(ne.error("Server error",{error:a.message,stack:a.stack}),a instanceof httpException.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.cors(typeof e.cors=="boolean"?{origin:"*"}:e.cors)),n.use(logger.logger((a,...i)=>ne.info(a,i))),!e.websockets&&e.secureHeaders&&n.use(secureHeaders.secureHeaders()),!e.websockets&&e.compression&&n.use(compress.compress({encoding:"gzip"})),!e.websockets&&e.timeout&&n.use(timeout.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,zodValidator.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 ne.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?(ne.error("Error closing server",{error:p.message}),l(p)):(o=null,ne.info(`Server on port ${t} stopped`),i());}),setTimeout(()=>{ne.warn(`Server shutdown timeout on port ${t}`),o=null,i();},5e3);}):Promise.resolve()},get raw(){return o||void 0}};return ne.debug("createServer: calling serve()",{port:t,hostname:r}),o=nodeServer.serve({fetch:n.fetch,port:t,hostname:r}),ne.debug("createServer: serve() returned, server created"),ne.info(`Server running on http://${r}:${t}`),s}function at(e){return ae({rpc:e,port:3e3})}function dr(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=>streaming.streamSSE(s,async a=>{for await(let i of o(s))await a.writeSSE(i);})}));return ae({...t,routes:r,streaming:true})}chunkVRQQ33YH_cjs.j();var le=chunkZHSHEAQD_cjs.m.create({service:"build-api"});async function sn(){try{return {available:!0,version:(await import('./chunks/main-RIJAJS2R.cjs')).version||"unknown"}}catch(e){return le.warn("esbuild not available",{error:e.message}),{available:false}}}async function je(){let e=await sn();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"&&le.warn(`esbuild version ${e.version} may have limited features. Consider upgrading to 0.17+`);}function gr(e){if(e!==void 0)return typeof e=="boolean"?{target:void 0}:typeof e=="string"?{target:e}:e}function an(e){let t=gr(e.compile);t&&le.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:hr(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=br(e.target)),e.minify===true&&(r.minifyWhitespace=true,r.minifyIdentifiers=true,r.minifySyntax=true),yr(r)}function hr(e){return !e||e==="none"?false:e}function br(e){let t={browser:"es2020",node:"node16",bun:"esnext"};return e?t[e]||e:"esnext"}function yr(e){let t={};for(let r of Object.keys(e))e[r]!==void 0&&(t[r]=e[r]);return t}function _e(e){if(e!==void 0)return e.replace(/\\/g,"/")}function tn(e,t,r){let n=[];if(e.outputFiles)for(let s of e.outputFiles)n.push({path:_e(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===_e(s))||n.push({path:_e(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){le.info("Build started",{entrypoints:e.entrypoints,target:e.target,format:e.format,compile:typeof e.compile}),await je();let t=await import('./chunks/main-RIJAJS2R.cjs'),r=Date.now();try{let n=an(e);le.debug("esbuild options",n);let o=await t.build(n),s=Date.now();return le.info("Build completed",{duration:s-r,outputs:(o?.outputFiles?.length??0)>0||Object.keys(o.metafile?.outputs||{}).length>0}),tn(o,r,s)}catch(n){let o=Date.now(),s=n.message;return le.error("Build failed",{error:s,duration:o-r}),n&&typeof n=="object"&&"errors"in n?tn(n):{outputs:[],success:false,logs:[{level:"error",message:s}],metafile:void 0}}}var vr={build:ft},ln=vr;chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function re(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 cn(e){return /[|&;<>()$`!#]/.test(e)}function un(e){let t=re(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 Rr=new Set(["&&","||","|",";","&",">","<",">>","<<","2>","2>>","1>","1>>","2>&1","2>&2","1>&1","1>&2",">&","<&",">&1","<&1",">&2","<&2"]);function dn(e,t=process.platform==="win32"?"windows":"unix"){return Rr.has(e)?e:pt(e,t)}function fn(){return process.platform==="win32"?"windows":"unix"}function me(e,t,r=process.platform==="win32"?"windows":"unix"){let n=t.map(o=>dn(o,r));return [e,...n].join(" ")}function pn(e){if(e==null)return "";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>pn(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 Pr(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=re(e);if(r.length===0)throw new Error("Empty shell command");let n=async()=>{let s=await exports.PKG.run(r,{cwd:t.cwd,env:t.env}),a=Pr(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}
|
|
13
|
-
${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 ge(e,{...t,cwd:s})},o.env=function(s){return ge(e,{...t,env:s})},o.quiet=function(){return ge(e,{...t,quiet:true})},o.lines=async function*(){let i=(await n()).text().split(/\r?\n/);for(let l of i)l.trim()&&(yield l);},o.text=async function(s="utf-8"){return (await n()).text(s)},o.json=async function(){return (await n()).json()},o.arrayBuffer=async function(){return (await n()).arrayBuffer()},o.blob=async function(){return (await n()).blob()},o.nothrow=function(){return ge(e,{...t,nothrow:true})},o.throws=function(s){return ge(e,{...t,nothrow:!s})},o}var
|
|
14
|
-
`),A
|
|
15
|
-
`),I=T.length>0?T[0]?.trim():null;if(I)return Q.set(h,I),I}}catch{}return Q.set(h,null),null}_.whichSync=n;function o(){Q.clear();}_.clearWhichCache=o;let s=module$1.createRequire(chunkVRQQ33YH_cjs.i);async function a(S,m,f){try{let u=[];if(f?.extraPaths)for(let y of f.extraPaths){let x=he__default.default.join(y,"node_modules");u.push(x);}return m&&u.push(m),u.length>0?s.resolve(S,{paths:u}):s.resolve(S)}catch(u){throw new Error(`Cannot resolve module "${S}"${m?` from "${m}"`:""}: ${u instanceof Error?u.message:String(u)}`)}}_.resolve=a;function i(S){return {get name(){return he__default.default.basename(S)},async exists(){try{return await oe__default.default.access(S),!0}catch{return false}},async getSize(){try{return (await oe__default.default.stat(S)).size}catch{return}},async text(){return await oe__default.default.readFile(S,"utf-8")},textSync(){return Ne__default.default.readFileSync(S,"utf-8")},jsonSync(){let m=Ne__default.default.readFileSync(S,"utf-8");return JSON.parse(m)},async bytes(){e.debug("[PKG.file.bytes] reading file:",{filePath:S});let m=await oe__default.default.readFile(S);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 oe__default.default.readFile(S);return m.buffer.slice(m.byteOffset,m.byteOffset+m.byteLength)},get type(){let m=he__default.default.extname(S).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 oe__default.default.writeFile(S,f);},async json(){let m=await oe__default.default.readFile(S,"utf-8");return JSON.parse(m)},async stat(){return await oe__default.default.stat(S)}}}_.file=i;async function l(S,m,f){let u;if(m instanceof Response){let y=await m.arrayBuffer();u=new Uint8Array(y);}else u=m;await oe__default.default.writeFile(S,u,f?{mode:f.mode}:void 0);}_.write=l;function p(S,m,f){Ne__default.default.writeFileSync(S,m,f?{mode:f.mode}:void 0);}_.writeSync=p;function c(S,m="utf-8"){return Ne__default.default.readFileSync(S,m)}_.readSync=c;function d(S,m){let f,u;if(typeof S=="object"&&"cmd"in S){let v=S;f=v.cmd,u={cwd:v.cwd,env:v.env,stdout:v.stdout,stderr:v.stderr,stdin:v.stdin,signal:v.signal,windowsHide:v.windowsHide,shell:v.shell};}else f=Array.isArray(S)?S:[S],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=child_process.spawn(f[0],f.slice(1),x),w;if(u.signal){w=()=>{h.kill();},u.signal.addEventListener("abort",w,{once:true});let v=()=>{w&&(u.signal?.removeEventListener("abort",w),w=void 0);};h.on("close",v),h.on("error",v);}let R=new Promise((v,T)=>{let I=false,z=()=>{I||(I=true,h.removeAllListeners());};if(h.on("close",B=>{z(),v(B??0);}),h.on("error",B=>{z(),T(B);}),u.timeout!==false){let B=u.timeout||3e5;setTimeout(()=>{if(!I){e.debug(`Process timeout after ${B}ms, killing process`,{cmd:f.join(" ")}),z();try{h.kill("SIGKILL");}catch{}T(new Error(`Process timeout after ${B}ms: ${f.join(" ")}`));}},B);}});return {stdout:h.stdout,stderr:h.stderr,stdin:h.stdin,pid:h.pid,exited:R,exitCode:h.exitCode,kill:v=>h.kill(v)}}_.spawn=d;async function g(S,m){let f=m?.stdin??"null",u=m?.stdout??"pipe",y=m?.stderr??"pipe",x=d(S,{cwd:m?.cwd,env:m?.env,stdin:f,stdout:u,stderr:y,windowsHide:m?.windowsHide,shell:m?.shell,timeout:m?.timeout}),h=[],w=[];u==="pipe"&&x.stdout?.on("data",v=>{h.push(v);}),y==="pipe"&&x.stderr?.on("data",v=>{w.push(v);});let R=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 v=await x.exited;return clearTimeout(R),u==="pipe"&&x.stdout?.destroy(),y==="pipe"&&x.stderr?.destroy(),f==="pipe"&&x.stdin?.end(),{code:v,stdout:Buffer.concat(h).toString("utf-8"),stderr:Buffer.concat(w).toString("utf-8")}}catch(v){return clearTimeout(R),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(w).toString("utf-8")||(v instanceof Error?v.message:String(v))}}}_.run=g;async function k(S,m={},f={}){let u=d(S,{cwd:m.cwd,env:m.env,stdout:"pipe",stderr:"pipe",stdin:"null"}),y="",x="";u.stdout?.on("data",w=>{let R=w.toString("utf-8");y+=R,f.onStdout?.(R);}),u.stderr?.on("data",w=>{let R=w.toString("utf-8");x+=R,f.onStderr?.(R);});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 w=await u.exited;return clearTimeout(h),f.onExit?.(w),{code:w,stdout:y,stderr:x}}catch(w){clearTimeout(h);let R=w instanceof Error?w.message:String(w);return {code:-1,stdout:y,stderr:x||R}}}_.runWithStream=k;async function E(S){if(typeof S.pipeThrough=="function")try{let y=new TextDecoderStream("utf-8"),h=S.pipeThrough(y).getReader(),w="";try{for(;;){let{done:R,value:v}=await h.read();if(R)break;w+=v;}return w}finally{h.releaseLock();}}catch{}let m=S.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=E;async function H(S){let m=[];return new Promise((f,u)=>{S.on("data",y=>{typeof y=="string"?m.push(Buffer.from(y)):m.push(y);}),S.on("end",()=>{try{let x=Buffer.concat(m).toString("utf-8");f(x);}catch(y){u(y);}}),S.on("error",y=>{u(y);});})}_.nodeReadableStreamToText=H;function U(S,m=0){let R=new TextEncoder().encode(S),v=R.length,T,I=0;if(v>=16){let F=v-16,A=m+2654435761+2246822519|0,ee=m+2246822519|0,J=m+0|0,Z=m-2654435761|0;for(;I<=F;)A=z(A,N(R,I)),I+=4,ee=z(ee,N(R,I)),I+=4,J=z(J,N(R,I)),I+=4,Z=z(Z,N(R,I)),I+=4;T=B(A,1)+B(ee,7)+B(J,12)+B(Z,18)|0;}else T=m+374761393|0;for(T=T+v|0;I+4<=v;)T=T+N(R,I)*3266489917|0,T=B(T,17)*668265263|0,I+=4;for(;I<v;)T=T+R[I]*374761393|0,T=B(T,11)*2654435761|0,I++;return T^=T>>>15,T=T*2246822519|0,T^=T>>>13,T=T*3266489917|0,T^=T>>>16,T>>>0;function z(F,A){return F=F+A*2246822519|0,F=B(F,13),F=F*2654435761|0,F}function B(F,A){return F<<A|F>>>32-A|0}function N(F,A){return (F[A]|F[A+1]<<8|F[A+2]<<16|F[A+3]<<24)>>>0}}_.xxHash32=U;function q(S){let m=0;for(let f of S){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 Y{constructor(m){chunkVRQQ33YH_cjs.c(this,"pattern");this.pattern=m;}async*scan(m){let f=chunkAHO55TRS_cjs.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 gn(u);}*scanSync(m){let f=chunkAHO55TRS_cjs.a(this.pattern,{cwd:m?.cwd,absolute:m?.absolute,follow:m?.followSymlinks,dot:m?.dot,nodir:m?.onlyFiles});for(let u of f)yield gn(u);}match(m){return minimatch.minimatch(m,this.pattern)}}_.Glob=Y,_.stdin=process.stdin,_.stdout=process.stdout,_.stderr=process.stderr,_.sleep=S=>new Promise(m=>setTimeout(m,S)),_.color=(S,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"})[S.toLowerCase()]||null,_.hash={xxHash32:_.xxHash32},_.build=ln.build,_.server=ae,_.nodeWebSocket=nodeWs.createNodeWebSocket,_.restServer=lt,_.rpcServer=at,_.streamingServer=ut,_.webSocketServer=ct;})(exports.PKG||(exports.PKG={}));var Fr=exports.PKG.readableStreamToText;exports.PKG.nodeReadableStreamToText;exports.PKG.which;var Ar=exports.PKG.whichSync;exports.PKG.spawn;exports.PKG.run;var yn=200,xn={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}};exports.Shell=void 0;(m=>{let e=chunkZHSHEAQD_cjs.m.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=child_process.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 promises.setTimeout(yn),u?.exited?.()||process.kill(-y,"SIGKILL");}catch{f.kill("SIGTERM"),await promises.setTimeout(yn),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=chunkYPKMFQLR_cjs.c.normalize(f);return E(u)==="bash"&&g()||u}function n(f){return xn[E(f)]}function o(f){return n(f)?.deny!==true}function s(f){return chunkYPKMFQLR_cjs.c.isAbsolute(f)}function a(f){let u=r(f);if(s(u))return chunkYPKMFQLR_cjs.c.stat(u)?.isFile()?u:void 0;let y=exports.PKG.whichSync(u);return y?chunkYPKMFQLR_cjs.c.normalize(y):void 0}function i(){return Array.from(new Set([exports.PKG.whichSync("pwsh"),exports.PKG.whichSync("powershell"),g(),process.env.COMSPEC||"cmd.exe"].filter(f=>!!f).map(r)))}async function l(){let f=await chunkYPKMFQLR_cjs.c.readText("/etc/shells").catch(()=>"");return f?Array.from(new Set(f.split(`
|
|
16
|
-
`).filter(
|
|
12
|
+
${se}`,truncated:true,outputPath:V,originalLength:c.length,removedLength:de,label:E}}p.truncate=a;function i(c){return c.truncated?s(c.outputPath,c.label):""}p.formatHint=i;async function l(){let c=exports.Identifier.timestamp(exports.Identifier.create("context",false,Date.now()-o)),g=(await oe__default.default.readdir(p.DIR).catch(()=>[])).filter(k=>k.startsWith("context_"));for(let k of g)exports.Identifier.timestamp(k)>=c||await oe__default.default.unlink(chunkYPKMFQLR_cjs.c.join(p.DIR,k)).catch(()=>{});}p.cleanup=l;})(exports.TruncateContent||(exports.TruncateContent={}));chunkVRQQ33YH_cjs.j();exports.SessionTitle=void 0;(i=>{let e="New session - ",t="Child session - ";i.parentTitlePrefix=e,i.childTitlePrefix=t;function o(l=false){return (l?t:e)+chunkZHSHEAQD_cjs.b(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;})(exports.SessionTitle||(exports.SessionTitle={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function Gt(e){let t,r=false,n=()=>(r||(t=e(),r=true),t);return n.reset=()=>{r=false,t=void 0;},n}var Le=Gt;function Yt(e){let t,r=()=>(t||(t=e()),t);return r.reset=()=>{t=void 0;},r}var cr=Yt;exports.Lazy=void 0;(r=>(r.lazy=Gt,r.lazyAsync=Yt))(exports.Lazy||(exports.Lazy={}));chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();var ne=chunkZHSHEAQD_cjs.m.create({service:"server"});function ae(e={}){let t=e.port??3e3,r=e.hostname??"0.0.0.0",n=new hono.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)=>(ne.error("Server error",{error:a.message,stack:a.stack}),a instanceof httpException.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.cors(typeof e.cors=="boolean"?{origin:"*"}:e.cors)),n.use(logger.logger((a,...i)=>ne.info(a,i))),!e.websockets&&e.secureHeaders&&n.use(secureHeaders.secureHeaders()),!e.websockets&&e.compression&&n.use(compress.compress({encoding:"gzip"})),!e.websockets&&e.timeout&&n.use(timeout.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,zodValidator.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 ne.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?(ne.error("Error closing server",{error:p.message}),l(p)):(o=null,ne.info(`Server on port ${t} stopped`),i());}),setTimeout(()=>{ne.warn(`Server shutdown timeout on port ${t}`),o=null,i();},5e3);}):Promise.resolve()},get raw(){return o||void 0}};return ne.debug("createServer: calling serve()",{port:t,hostname:r}),o=nodeServer.serve({fetch:n.fetch,port:t,hostname:r}),ne.debug("createServer: serve() returned, server created"),ne.info(`Server running on http://${r}:${t}`),s}function at(e){return ae({rpc:e,port:3e3})}function pr(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=>streaming.streamSSE(s,async a=>{for await(let i of o(s))await a.writeSSE(i);})}));return ae({...t,routes:r,streaming:true})}chunkVRQQ33YH_cjs.j();var le=chunkZHSHEAQD_cjs.m.create({service:"build-api"});async function an(){try{return {available:!0,version:(await import('./chunks/main-RIJAJS2R.cjs')).version||"unknown"}}catch(e){return le.warn("esbuild not available",{error:e.message}),{available:false}}}async function je(){let e=await an();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"&&le.warn(`esbuild version ${e.version} may have limited features. Consider upgrading to 0.17+`);}function br(e){if(e!==void 0)return typeof e=="boolean"?{target:void 0}:typeof e=="string"?{target:e}:e}function ln(e){let t=br(e.compile);t&&le.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:yr(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=xr(e.target)),e.minify===true&&(r.minifyWhitespace=true,r.minifyIdentifiers=true,r.minifySyntax=true),wr(r)}function yr(e){return !e||e==="none"?false:e}function xr(e){let t={browser:"es2020",node:"node16",bun:"esnext"};return e?t[e]||e:"esnext"}function wr(e){let t={};for(let r of Object.keys(e))e[r]!==void 0&&(t[r]=e[r]);return t}function $e(e){if(e!==void 0)return e.replace(/\\/g,"/")}function nn(e,t,r){let n=[];if(e.outputFiles)for(let s of e.outputFiles)n.push({path:$e(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===$e(s))||n.push({path:$e(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){le.info("Build started",{entrypoints:e.entrypoints,target:e.target,format:e.format,compile:typeof e.compile}),await je();let t=await import('./chunks/main-RIJAJS2R.cjs'),r=Date.now();try{let n=ln(e);le.debug("esbuild options",n);let o=await t.build(n),s=Date.now();return le.info("Build completed",{duration:s-r,outputs:(o?.outputFiles?.length??0)>0||Object.keys(o.metafile?.outputs||{}).length>0}),nn(o,r,s)}catch(n){let o=Date.now(),s=n.message;return le.error("Build failed",{error:s,duration:o-r}),n&&typeof n=="object"&&"errors"in n?nn(n):{outputs:[],success:false,logs:[{level:"error",message:s}],metafile:void 0}}}var Rr={build:ft},cn=Rr;chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function re(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 un(e){return /[|&;<>()$`!#]/.test(e)}function dn(e){let t=re(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 Mr=new Set(["&&","||","|",";","&",">","<",">>","<<","2>","2>>","1>","1>>","2>&1","2>&2","1>&1","1>&2",">&","<&",">&1","<&1",">&2","<&2"]);function fn(e,t=process.platform==="win32"?"windows":"unix"){return Mr.has(e)?e:pt(e,t)}function pn(){return process.platform==="win32"?"windows":"unix"}function me(e,t,r=process.platform==="win32"?"windows":"unix"){let n=t.map(o=>fn(o,r));return [e,...n].join(" ")}function mn(e){if(e==null)return "";if(typeof e=="string")return e;if(Array.isArray(e))return e.map(t=>mn(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 Er(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=re(e);if(r.length===0)throw new Error("Empty shell command");let n=async()=>{let s=await exports.PKG.run(r,{cwd:t.cwd,env:t.env}),a=Er(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}
|
|
13
|
+
${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 ge(e,{...t,cwd:s})},o.env=function(s){return ge(e,{...t,env:s})},o.quiet=function(){return ge(e,{...t,quiet:true})},o.lines=async function*(){let i=(await n()).text().split(/\r?\n/);for(let l of i)l.trim()&&(yield l);},o.text=async function(s="utf-8"){return (await n()).text(s)},o.json=async function(){return (await n()).json()},o.arrayBuffer=async function(){return (await n()).arrayBuffer()},o.blob=async function(){return (await n()).blob()},o.nothrow=function(){return ge(e,{...t,nothrow:true})},o.throws=function(s){return ge(e,{...t,nothrow:!s})},o}var Pe=class{constructor(t={}){chunkVRQQ33YH_cjs.c(this,"options");this.options=t;}call(t,...r){let n="";for(let o=0;o<t.length;o++)n+=t[o],o<r.length&&r[o]!==void 0&&(n+=mn(r[o]));return ge(n,this.options)}braces(t){let r=t.match(/^(.*?)\{([^}]+)\}(.*)$/);if(!r)return [t];let[,n="",o="",s=""]=r,a=o.split(",").map(l=>l.trim()),i=[];for(let l of a){let p=`${n}${l}${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 ce({...this.options,env:t})}cwd(t){return ce({...this.options,cwd:t})}nothrow(){return ce({...this.options,nothrow:true})}throws(t){return ce({...this.options,nothrow:!t})}};function ce(e={}){let t=new Pe(e);return new Proxy(t,{apply(r,n,o){return t.call(o[0],...o.slice(1))}})}var gn=ce();function hn(e){return e.replace(/\\/g,"/")}function bn(e){return crypto$1.createHash("md5").update(e).digest("hex").slice(0,8)}var Q=new Map;exports.PKG=void 0;($=>{let e=chunkZHSHEAQD_cjs.m.create({service:"pkg"});async function t(S){let m=S?[S]:["npm","pnpm","bun"];for(let f of m){let d=await $.which(f);if(d)return {name:f,path:d}}}$.packageManager=t;async function r(S,m){if(!S)return process.execPath;let f=m?.PATH||process.env.PATH||process.env.Path||"",d=process.env.EASBOT_BIN_PATH,y=d?f+he__default.default.delimiter+d:f,x=bn(y),h=`${S}:${x}`;if(Q.has(h))return Q.get(h);let P=process.platform==="win32"?"where":"which";try{let{spawn:v}=await import('child_process');return new Promise(T=>{let O=v(P,[S],{env:{...process.env,PATH:y},stdio:["pipe","pipe","ignore"],windowsHide:!0}),D="",B="";O.stdout?.on("data",N=>{D+=N.toString();}),O.stderr?.on("data",N=>{B+=N.toString();}),O.on("close",N=>{if(N===0&&D.trim()){let A=D.trim().split(`
|
|
14
|
+
`),F=A.length>0?A[0]?.trim():null;if(F){Q.set(h,F),T(F);return}}Q.set(h,null),T(null);}),setTimeout(()=>{O.kill(),Q.set(h,null),T(null);},5e3);})}catch{return Q.set(h,null),null}}$.which=r;function n(S,m){if(!S)return process.execPath;let f=m?.PATH||process.env.PATH||process.env.Path||"",d=process.env.EASBOT_BIN_PATH,y=d?f+he__default.default.delimiter+d:f,x=bn(y),h=`${S}:${x}`;if(Q.has(h))return Q.get(h);let P=process.platform==="win32"?"where":"which";try{let v=child_process.execSync(`${P} ${S}`,{encoding:"utf-8",stdio:["pipe","pipe","ignore"],env:{...process.env,PATH:y},timeout:5e3,windowsHide:!0});if(v.trim()){let T=v.trim().split(`
|
|
15
|
+
`),O=T.length>0?T[0]?.trim():null;if(O)return Q.set(h,O),O}}catch{}return Q.set(h,null),null}$.whichSync=n;function o(){Q.clear();}$.clearWhichCache=o;let s=module$1.createRequire(chunkVRQQ33YH_cjs.i);async function a(S,m,f){try{let d=[];if(f?.extraPaths)for(let y of f.extraPaths){let x=he__default.default.join(y,"node_modules");d.push(x);}return m&&d.push(m),d.length>0?s.resolve(S,{paths:d}):s.resolve(S)}catch(d){throw new Error(`Cannot resolve module "${S}"${m?` from "${m}"`:""}: ${d instanceof Error?d.message:String(d)}`)}}$.resolve=a;function i(S){return {get name(){return he__default.default.basename(S)},async exists(){try{return await oe__default.default.access(S),!0}catch{return false}},async getSize(){try{return (await oe__default.default.stat(S)).size}catch{return}},async text(){return await oe__default.default.readFile(S,"utf-8")},textSync(){return Ne__default.default.readFileSync(S,"utf-8")},jsonSync(){let m=Ne__default.default.readFileSync(S,"utf-8");return JSON.parse(m)},async bytes(){e.debug("[PKG.file.bytes] reading file:",{filePath:S});let m=await oe__default.default.readFile(S);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 oe__default.default.readFile(S);return m.buffer.slice(m.byteOffset,m.byteOffset+m.byteLength)},get type(){let m=he__default.default.extname(S).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 d=await m.arrayBuffer();f=new Uint8Array(d);}else f=m;await oe__default.default.writeFile(S,f);},async json(){let m=await oe__default.default.readFile(S,"utf-8");return JSON.parse(m)},async stat(){return await oe__default.default.stat(S)}}}$.file=i;async function l(S,m,f){let d;if(m instanceof Response){let y=await m.arrayBuffer();d=new Uint8Array(y);}else d=m;await oe__default.default.writeFile(S,d,f?{mode:f.mode}:void 0);}$.write=l;function p(S,m,f){Ne__default.default.writeFileSync(S,m,f?{mode:f.mode}:void 0);}$.writeSync=p;function c(S,m="utf-8"){return Ne__default.default.readFileSync(S,m)}$.readSync=c;function u(S,m){let f,d;if(typeof S=="object"&&"cmd"in S){let v=S;f=v.cmd,d={cwd:v.cwd,env:v.env,stdout:v.stdout,stderr:v.stderr,stdin:v.stdin,signal:v.signal,windowsHide:v.windowsHide,shell:v.shell};}else f=Array.isArray(S)?S:[S],d=m||{};if(!f||f.length===0||!f[0])throw new Error("Spawn command cannot be empty");let y=[d.stdin==="inherit"?"inherit":d.stdin==="null"?"ignore":"pipe",d.stdout==="inherit"?"inherit":d.stdout==="null"?"ignore":"pipe",d.stderr==="inherit"?"inherit":d.stderr==="null"?"ignore":"pipe"],x={cwd:d.cwd,env:d.env?{...process.env,...d.env}:process.env,stdio:y,timeout:d.timeout};d.shell!==void 0&&(x.shell=d.shell),process.platform==="win32"&&(x.windowsHide=d.windowsHide??true);let h=child_process.spawn(f[0],f.slice(1),x),w;if(d.signal){w=()=>{h.kill();},d.signal.addEventListener("abort",w,{once:true});let v=()=>{w&&(d.signal?.removeEventListener("abort",w),w=void 0);};h.on("close",v),h.on("error",v);}let P=new Promise((v,T)=>{let O=false,D=()=>{O||(O=true,h.removeAllListeners());};if(h.on("close",B=>{D(),v(B??0);}),h.on("error",B=>{D(),T(B);}),d.timeout!==false){let B=d.timeout||3e5;setTimeout(()=>{if(!O){e.debug(`Process timeout after ${B}ms, killing process`,{cmd:f.join(" ")}),D();try{h.kill("SIGKILL");}catch{}T(new Error(`Process timeout after ${B}ms: ${f.join(" ")}`));}},B);}});return {stdout:h.stdout,stderr:h.stderr,stdin:h.stdin,pid:h.pid,exited:P,exitCode:h.exitCode,kill:v=>h.kill(v)}}$.spawn=u;async function g(S,m){let f=m?.stdin??"null",d=m?.stdout??"pipe",y=m?.stderr??"pipe",x=u(S,{cwd:m?.cwd,env:m?.env,stdin:f,stdout:d,stderr:y,windowsHide:m?.windowsHide,shell:m?.shell,timeout:m?.timeout}),h=[],w=[];d==="pipe"&&x.stdout?.on("data",v=>{h.push(v);}),y==="pipe"&&x.stderr?.on("data",v=>{w.push(v);});let P=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 v=await x.exited;return clearTimeout(P),d==="pipe"&&x.stdout?.destroy(),y==="pipe"&&x.stderr?.destroy(),f==="pipe"&&x.stdin?.end(),{code:v,stdout:Buffer.concat(h).toString("utf-8"),stderr:Buffer.concat(w).toString("utf-8")}}catch(v){return clearTimeout(P),d==="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(w).toString("utf-8")||(v instanceof Error?v.message:String(v))}}}$.run=g;async function k(S,m={},f={}){let d=u(S,{cwd:m.cwd,env:m.env,stdout:"pipe",stderr:"pipe",stdin:"null"}),y="",x="";d.stdout?.on("data",w=>{let P=w.toString("utf-8");y+=P,f.onStdout?.(P);}),d.stderr?.on("data",w=>{let P=w.toString("utf-8");x+=P,f.onStderr?.(P);});let h=m.timeout&&m.timeout>0?setTimeout(()=>{try{d.kill("SIGKILL");}catch{}d.stdout?.destroy(),d.stderr?.destroy();},m.timeout):void 0;try{let w=await d.exited;return clearTimeout(h),f.onExit?.(w),{code:w,stdout:y,stderr:x}}catch(w){clearTimeout(h);let P=w instanceof Error?w.message:String(w);return {code:-1,stdout:y,stderr:x||P}}}$.runWithStream=k;async function E(S){if(typeof S.pipeThrough=="function")try{let y=new TextDecoderStream("utf-8"),h=S.pipeThrough(y).getReader(),w="";try{for(;;){let{done:P,value:v}=await h.read();if(P)break;w+=v;}return w}finally{h.releaseLock();}}catch{}let m=S.getReader(),f=new TextDecoder("utf-8"),d=[];try{for(;;){let{done:y,value:x}=await m.read();if(y)break;d.push(f.decode(x,{stream:!0}));}return d.push(f.decode()),d.join("")}finally{m.releaseLock();}}$.readableStreamToText=E;async function H(S){let m=[];return new Promise((f,d)=>{S.on("data",y=>{typeof y=="string"?m.push(Buffer.from(y)):m.push(y);}),S.on("end",()=>{try{let x=Buffer.concat(m).toString("utf-8");f(x);}catch(y){d(y);}}),S.on("error",y=>{d(y);});})}$.nodeReadableStreamToText=H;function U(S,m=0){let P=new TextEncoder().encode(S),v=P.length,T,O=0;if(v>=16){let A=v-16,F=m+2654435761+2246822519|0,ee=m+2246822519|0,J=m+0|0,K=m-2654435761|0;for(;O<=A;)F=D(F,N(P,O)),O+=4,ee=D(ee,N(P,O)),O+=4,J=D(J,N(P,O)),O+=4,K=D(K,N(P,O)),O+=4;T=B(F,1)+B(ee,7)+B(J,12)+B(K,18)|0;}else T=m+374761393|0;for(T=T+v|0;O+4<=v;)T=T+N(P,O)*3266489917|0,T=B(T,17)*668265263|0,O+=4;for(;O<v;)T=T+P[O]*374761393|0,T=B(T,11)*2654435761|0,O++;return T^=T>>>15,T=T*2246822519|0,T^=T>>>13,T=T*3266489917|0,T^=T>>>16,T>>>0;function D(A,F){return A=A+F*2246822519|0,A=B(A,13),A=A*2654435761|0,A}function B(A,F){return A<<F|A>>>32-F|0}function N(A,F){return (A[F]|A[F+1]<<8|A[F+2]<<16|A[F+3]<<24)>>>0}}$.xxHash32=U;function q(S){let m=0;for(let f of S){let d=f.codePointAt(0)||f.charCodeAt(0);d<127?m+=1:d>=4352&&d<=4447||d>=9001&&d<=9002||d>=11904&&d<=42191&&d!==12351||d>=44032&&d<=55203||d>=63744&&d<=64255||d>=65040&&d<=65049||d>=65072&&d<=65135||d>=65280&&d<=65376||d>=65504&&d<=65510?m+=2:m+=1;}return m}$.stringWidth=q;class G{constructor(m){chunkVRQQ33YH_cjs.c(this,"pattern");this.pattern=m;}async*scan(m){let f=chunkAHO55TRS_cjs.b.stream(this.pattern,{cwd:m?.cwd,absolute:m?.absolute,follow:m?.followSymlinks,dot:m?.dot,nodir:m?.onlyFiles});for await(let d of f)yield hn(d);}*scanSync(m){let f=chunkAHO55TRS_cjs.a(this.pattern,{cwd:m?.cwd,absolute:m?.absolute,follow:m?.followSymlinks,dot:m?.dot,nodir:m?.onlyFiles});for(let d of f)yield hn(d);}match(m){return minimatch.minimatch(m,this.pattern)}}$.Glob=G,$.stdin=process.stdin,$.stdout=process.stdout,$.stderr=process.stderr,$.sleep=S=>new Promise(m=>setTimeout(m,S)),$.color=(S,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"})[S.toLowerCase()]||null,$.hash={xxHash32:$.xxHash32},$.build=cn.build,$.server=ae,$.nodeWebSocket=nodeWs.createNodeWebSocket,$.restServer=lt,$.rpcServer=at,$.streamingServer=ut,$.webSocketServer=ct;})(exports.PKG||(exports.PKG={}));var _r=exports.PKG.readableStreamToText;exports.PKG.nodeReadableStreamToText;exports.PKG.which;var Br=exports.PKG.whichSync;exports.PKG.spawn;exports.PKG.run;var xn=200,wn={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}};exports.Shell=void 0;(m=>{let e=chunkZHSHEAQD_cjs.m.create({service:"shell"});async function t(f,d){let y=f.pid;if(!(!y||d?.exited?.())){if(process.platform==="win32"){await new Promise(x=>{let h=child_process.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 promises.setTimeout(xn),d?.exited?.()||process.kill(-y,"SIGKILL");}catch{f.kill("SIGTERM"),await promises.setTimeout(xn),d?.exited?.()||f.kill("SIGKILL");}}}m.killTree=t;function r(f){if(process.platform!=="win32"||!f.includes("/")&&!f.includes("\\")&&!f.includes(":"))return f;let d=chunkYPKMFQLR_cjs.c.normalize(f);return E(d)==="bash"&&g()||d}function n(f){return wn[E(f)]}function o(f){return n(f)?.deny!==true}function s(f){return chunkYPKMFQLR_cjs.c.isAbsolute(f)}function a(f){let d=r(f);if(s(d))return chunkYPKMFQLR_cjs.c.stat(d)?.isFile()?d:void 0;let y=exports.PKG.whichSync(d);return y?chunkYPKMFQLR_cjs.c.normalize(y):void 0}function i(){return Array.from(new Set([exports.PKG.whichSync("pwsh"),exports.PKG.whichSync("powershell"),g(),process.env.COMSPEC||"cmd.exe"].filter(f=>!!f).map(r)))}async function l(){let f=await chunkYPKMFQLR_cjs.c.readText("/etc/shells").catch(()=>"");return f?Array.from(new Set(f.split(`
|
|
16
|
+
`).filter(d=>d.trim()&&!d.startsWith("#")))):["/bin/bash","/bin/zsh","/bin/sh"]}function p(f,d){if(f&&(!d?.acceptable||o(f))){let y=a(f);if(y)return y}return process.platform==="win32"?i()[0]:k()}m.defaultPreferred=Le(()=>p(process.env.SHELL)),m.defaultAcceptable=Le(()=>p(process.env.SHELL,{acceptable:true}));function g(){if(process.platform!=="win32")return;if(process.env.EASBOT_GIT_BASH_PATH)return chunkYPKMFQLR_cjs.c.normalize(process.env.EASBOT_GIT_BASH_PATH);let f=exports.PKG.whichSync("git");if(!f)return;let d=chunkYPKMFQLR_cjs.c.normalize(he__default.default.join(f,"..","..","bin","bash.exe"));if((chunkYPKMFQLR_cjs.c.stat(d)?.size??0)>0)return d}m.gitbash=g;function k(){if(process.platform==="win32"){let d=g();return d||"/bin/sh"}if(process.platform==="darwin")return "/bin/zsh";let f=exports.PKG.whichSync("bash");return f?chunkYPKMFQLR_cjs.c.normalize(f):"/bin/sh"}function E(f){return he__default.default.posix.basename(chunkYPKMFQLR_cjs.c.toUnixPath(f)).toLowerCase()}m.name=E;function H(f){return n(f)?.login===true}m.login=H;function U(f){return n(f)?.posix===true}m.posix=U;function q(f){return n(f)?.ps===true}m.ps=q;function G(f){let d=r(f),y=E(d);return {path:d,name:y,acceptable:o(y)}}function V(f,d,y){let x=E(f),h=re(d),w=me(h[0]??d,h.slice(1));return x==="nu"||x==="fish"?["-c",w]:x==="zsh"?["-l","-c",`
|
|
17
17
|
[[ -f ~/.zshenv ]] && source ~/.zshenv >/dev/null 2>&1 || true
|
|
18
18
|
[[ -f "\${ZDOTDIR:-$HOME}/.zshrc" ]] && source "\${ZDOTDIR:-$HOME}/.zshrc" >/dev/null 2>&1 || true
|
|
19
19
|
cd -- "$1"
|
|
@@ -23,60 +23,62 @@ ${s.stderr}`),{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode});return a},o
|
|
|
23
23
|
[[ -f ~/.bashrc ]] && source ~/.bashrc >/dev/null 2>&1 || true
|
|
24
24
|
cd -- "$1"
|
|
25
25
|
${w}
|
|
26
|
-
`,"easbot",y]:/^cmd(\.exe)?$/i.test(x)?["/c",`chcp 65001 >nul 2>&1 && ${w}`]:q(x)?["-NoProfile","-Command",`[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; ${w}`]:["-c",w]}m.args=
|
|
27
|
-
`)[0];return e.debug(`Shell \u7248\u672C\u83B7\u53D6\u6210\u529F: ${w}`),w}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=
|
|
26
|
+
`,"easbot",y]:/^cmd(\.exe)?$/i.test(x)?["/c",`chcp 65001 >nul 2>&1 && ${w}`]:q(x)?["-NoProfile","-Command",`[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; ${w}`]:["-c",w]}m.args=V;function de(f){return f?p(f):(0, m.defaultPreferred)()}m.preferred=de;function se(f){return f?p(f,{acceptable:true}):(0, m.defaultAcceptable)()}m.acceptable=se;function fe(){m.defaultPreferred.reset(),m.defaultAcceptable.reset();}m.reset=fe;async function ke(){return (process.platform==="win32"?i():await l()).filter(d=>a(d)).map(G)}m.list=ke;function Te(f){return wn[E(f)]}m.metaInfo=Te;function Ht(f){return /[|&;<>()$`!#]/.test(f)}m.needsShell=Ht;function I(){return process.platform==="win32"?i():["/bin/bash","/bin/zsh","/bin/sh"]}m.platformShells=I;function C(f){return f?!!a(f):false}m.isValid=C;async function _(f){let d=a(f);if(!d)return;let y=E(d);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: ${d}`,{shell:d,args:x});let h=await exports.PKG.run([d,...x]);if(h.code===0){let w=h.stdout.trim().split(`
|
|
27
|
+
`)[0];return e.debug(`Shell \u7248\u672C\u83B7\u53D6\u6210\u529F: ${w}`),w}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=_;class W extends Error{constructor(y,x,h,w){super(y);chunkVRQQ33YH_cjs.c(this,"message",y);chunkVRQQ33YH_cjs.c(this,"pkg",x);chunkVRQQ33YH_cjs.c(this,"version",h);chunkVRQQ33YH_cjs.c(this,"originalError",w);this.name="InstallFailedError";}}m.InstallFailedError=W;async function Y(f,d="latest",y){let{Lock:x}=await import('./chunks/lock-LMCPTUNU.cjs'),{Filesystem:h}=await import('./chunks/filesystem-OYOMZ7F3.cjs'),{PackageRegistry:w}=await import('./chunks/registry-DPBQYUUX.cjs');y=y??process.env.EASBOT_CACHE_PATH??he__default.default.join(".easbot","cache");let P=await x.write("pkg-install");try{let v=he__default.default.posix.join(y,"node_modules",f),T=he__default.default.posix.join(y,"package.json"),D=(await h.readJson(T).catch(async()=>{let X={dependencies:{}};return await h.writeJson(T,X),X})).dependencies??{},B=await h.exists(v),N=D[f],A=!1;if(!B||!N)A=!0;else {if(d!=="latest"&&N===d)return v;if(d==="latest"){if(!await w.isOutdated(f,N,y))return v;e.info("Cached version is outdated, proceeding with install",{pkg:f,cachedVersion:N}),A=!0;}}if(!A)return v;let F=m.acceptable(process.platform==="win32"?"cmd":void 0)??k(),ee=`${f}@${d}`;e.info("installing package",{pkg:f,version:d,cache:y,shell:F});let J=await exports.PKG.packageManager();if(!J)throw new W("No package manager found (npm, pnpm, bun)",f,d,"No package manager available");let K=J.name,Qe=K==="pnpm"?"add":"install",et=`${J.name} ${Qe} --save-exact ${ee}`;e.info(`Using ${K} to install package`,{pkg:f,version:d,shell:F,pmPath:J.path});try{let X=await m.run(F,et,{cwd:y,timeout:6e5,windowsHide:!0});if(X.code!==0)throw new Error(`Package manager exited with code ${X.code}: ${X.stderr}`);e.info(`Successfully installed ${f}@${d} with ${K}`);}catch(X){let Wt=X instanceof Error?X:new Error(String(X));if(!await h.exists(v))throw new W(`Failed to install ${f}@${d}`,f,d,Wt.message);e.warn("Package install failed but module exists, continuing",{error:Wt.message});}let tt=d;d==="latest"&&(tt=(await h.readJson(he__default.default.join(v,"package.json")).catch(()=>({})))?.version??"unknown");let _e=await h.readJson(T);return _e.dependencies=_e.dependencies??{},_e.dependencies[f]=tt,await h.writeJson(T,_e),e.info("Package installation completed",{pkg:f,version:tt,path:v}),v}finally{P[Symbol.dispose]();}}m.install=Y;async function ve(f,d,y){let x=f?m.acceptable(f)??k():m.acceptable()??k(),h=y?.cwd??process.cwd(),w=m.args(x,d,h);e.debug(`run shell process: ${x} ${w.join(" ")}`,{command:d,cwd:h});let{windowsHide:P,env:v,...T}=y??{},O={...process.env,LANG:"en_US.UTF-8",LC_ALL:"en_US.UTF-8",LC_CTYPE:"en_US.UTF-8",...v};process.platform==="win32"&&(O.CHCP="65001");let{stdin:D,stdout:B,stderr:N,timeout:A,signal:F,...ee}=T??{},J={...ee,cwd:h,env:O,windowsHide:process.platform==="win32"?P??true:void 0,shell:ee.shell,timeout:A},K=E(x),Qe=/^cmd(\.exe)?$/i.test(K),et=process.platform==="win32"&&Qe?"cmd":x;return exports.PKG.run([et,...w],J)}m.run=ve;function $(f,d,y){let x=f?m.acceptable(f)??k():m.acceptable()??k(),h=y?.cwd??process.cwd(),w=m.args(x,d,h);e.debug(`Spawn shell process: ${x} ${w.join(" ")}`,{command:d,cwd:h});let{stdin:P,stdout:v,stderr:T,timeout:O,signal:D,windowsHide:B,env:N,...A}=y??{},F={...process.env,LANG:"en_US.UTF-8",LC_ALL:"en_US.UTF-8",LC_CTYPE:"en_US.UTF-8",...N};process.platform==="win32"&&(F.CHCP="65001");let ee=E(x),J=/^cmd(\.exe)?$/i.test(ee),K={...A,cwd:h,env:F,windowsHide:process.platform==="win32"?B??true:void 0,shell:A.shell,timeout:O};return exports.PKG.spawn([J?"cmd":x,...w],K)}m.spawn=$;function S(f,...d){let y=f.reduce((h,w,P)=>h+w+(d[P]??""),""),x=(h={})=>({quiet:()=>x({...h,quiet:true}),nothrow:()=>x({...h,nothrow:true}),cwd:w=>x({...h,cwd:w}),env:w=>x({...h,env:w}),stdin:w=>x({...h,stdin:w}),stdout:w=>x({...h,stdout:w}),stderr:w=>x({...h,stderr:w}),text:async()=>{let w=re(y.trim());if(w.length===0)throw new Error("Empty command");let P=w[0]??"",v=E(P),T=/^cmd(\.exe)?$/i.test(v),O=process.platform==="win32"&&T?"cmd":Te(P)?P:void 0,D=me(P,w.slice(1)),B=await m.run(O,D,{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}
|
|
28
28
|
${B.stderr}`);return B.stdout},lines:async()=>(await x(h).text()).split(`
|
|
29
|
-
`).filter(
|
|
30
|
-
${
|
|
31
|
-
`).filter(
|
|
32
|
-
`):t;for(let n=0;n<r.length;n++){let o=r[n];this.parseRule(o,n+1);}return this}parseRule(t,r){let n=t;if(n.length===0||n.startsWith("#"))return;let s=n.startsWith("!");if(s&&(n=n.slice(1)),n=n.trimEnd(),n.length===0)return;if(n.startsWith("\\#")){n=n.slice(1);return}if(n.startsWith("#"))return;let i=n.endsWith("/");if(i&&(n=n.slice(0,-1)),n.length===0)return;let l=this.patternToRegex(n);l&&this.rules.push({pattern:n,regex:l,negative:s,isDirectory:i,original:t,lineNumber:r});}ignores(t,r){let n=this.normalizePath(t),o=r??t.endsWith("/"),s=this.checkIgnore(n,o);return this.debug&&console.log(`Ignore.ignores("${t}", isDirectory=${o}) => ${s}`),s}checkIgnore(t,r){let n=false;for(let o of this.rules)o.isDirectory&&!r||o.regex.test(t)&&(o.negative?n=false:n=true);return n}filter(t){return t.filter(r=>!this.ignores(r))}createFilter(){return t=>!this.ignores(t)}patternToRegex(t){let r=[],n=0,o=t.length;for(;n<o;){let p=t[n];if(p==="\\")if(n+1<o){let c=t[n+1];r.push(this.escapeRegexChar(c)),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 c=this.findMatchingBracket(t,n);if(c!==-1){let
|
|
33
|
-
|
|
29
|
+
`).filter(P=>P.trim()),then:(w,P)=>{let v=re(y.trim()),T=v[0]??"",O=E(T),D=/^cmd(\.exe)?$/i.test(O),B=process.platform==="win32"&&D?"cmd":Te(T)?T:void 0,N=me(T,v.slice(1));return m.run(B,N,{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 F=new Error(`Command failed with exit code ${A.code}: ${y}
|
|
30
|
+
${A.stderr}`);if(P){P(F);return}throw F}return w({exitCode:A.code,stdout:new TextEncoder().encode(A.stdout),stderr:new TextEncoder().encode(A.stderr),text:()=>A.stdout,lines:()=>A.stdout.split(`
|
|
31
|
+
`).filter(F=>F.trim())})},P)}});return x()}m.$=S;})(exports.Shell||(exports.Shell={}));var $r=exports.Shell.$;chunkVRQQ33YH_cjs.j();var Me=class Me extends Error{static create(t,r){var s;let n=De__default.default.object({name:De__default.default.literal(t),data:r}).meta({ref:t}),o=(s=class extends Me{constructor(i,l){super(t,l);chunkVRQQ33YH_cjs.c(this,"data",i);chunkVRQQ33YH_cjs.c(this,"name",t);this.name=t;}static isInstance(i){return typeof i=="object"&&"name"in i&&i.name===t}schema(){return n}toObject(){return {name:t,data:this.data}}},chunkVRQQ33YH_cjs.c(s,"Schema",n),s);return Object.defineProperty(o,"name",{value:t}),o}};chunkVRQQ33YH_cjs.c(Me,"Unknown",Me.create("UnknownError",De__default.default.object({message:De__default.default.string()})));var mt=Me;chunkVRQQ33YH_cjs.j();exports.Ignore=void 0;(t=>{function e(r){return new ht(r)}t.create=e;})(exports.Ignore||(exports.Ignore={}));var ht=class{constructor(t){chunkVRQQ33YH_cjs.c(this,"rules",[]);chunkVRQQ33YH_cjs.c(this,"ignorecase");chunkVRQQ33YH_cjs.c(this,"debug");this.ignorecase=t?.ignorecase??false,this.debug=t?.debug??false;}add(t){let r=typeof t=="string"?t.split(`
|
|
32
|
+
`):t;for(let n=0;n<r.length;n++){let o=r[n];this.parseRule(o,n+1);}return this}parseRule(t,r){let n=t;if(n.length===0||n.startsWith("#"))return;let s=n.startsWith("!");if(s&&(n=n.slice(1)),n=n.trimEnd(),n.length===0)return;if(n.startsWith("\\#")){n=n.slice(1);return}if(n.startsWith("#"))return;let i=n.endsWith("/");if(i&&(n=n.slice(0,-1)),n.length===0)return;let l=this.patternToRegex(n);l&&this.rules.push({pattern:n,regex:l,negative:s,isDirectory:i,original:t,lineNumber:r});}ignores(t,r){let n=this.normalizePath(t),o=r??t.endsWith("/"),s=this.checkIgnore(n,o);return this.debug&&console.log(`Ignore.ignores("${t}", isDirectory=${o}) => ${s}`),s}checkIgnore(t,r){let n=false;for(let o of this.rules)o.isDirectory&&!r||o.regex.test(t)&&(o.negative?n=false:n=true);return n}filter(t){return t.filter(r=>!this.ignores(r))}createFilter(){return t=>!this.ignores(t)}patternToRegex(t){let r=[],n=0,o=t.length;for(;n<o;){let p=t[n];if(p==="\\")if(n+1<o){let c=t[n+1];r.push(this.escapeRegexChar(c)),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 c=this.findMatchingBracket(t,n);if(c!==-1){let u=t.slice(n,c+1);(u.startsWith("[!")||u.startsWith("[^"))&&(u="[^"+u.slice(2)),this.ignorecase&&(u=u.toLowerCase()),r.push(u),n=c+1;continue}}if(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 l=this.ignorecase?"i":"";try{return new RegExp("^"+s+"$",l)}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}};chunkVRQQ33YH_cjs.j();function Sn(e,t){let r=n=>{let o;try{o=e.parse(n);}catch(s){throw console.trace("schema validation failure stack trace:"),s instanceof De.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 Nr=Sn;exports.Fn=void 0;(t=>t.fn=Sn)(exports.Fn||(exports.Fn={}));chunkVRQQ33YH_cjs.j();function Hr(e={}){let t=e.isDevelopment??false,r=t?".env.dev":".env",n=e.globalConfigPath??(xdgBasedir.xdgConfig?he__default.default.join(xdgBasedir.xdgConfig,"easbot"):void 0),o=e.projectRoot??process.cwd(),s=o?he__default.default.join(o,".easbot"):void 0,a=[{root:n,label:"global"},{root:o,label:"project"},{root:s,label:"workspace"}];for(let{root:i}of a){if(!i)continue;let l=he__default.default.join(i,r);if(!Ne.existsSync(l))continue;let p=dotenv.config({path:l,override:true,debug:t,encoding:"utf-8",quiet:!t});if(t&&p.parsed){let u=["XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_CACHE_HOME","XDG_STATE_HOME","XDG_RUNTIME_DIR","EASBOT_CONFIG_PATH","EASBOT_DATA_PATH","EASBOT_CACHE_PATH","EASBOT_STATE_PATH","EASBOT_LOG_PATH","EASBOT_BIN_PATH"].filter(g=>g in p.parsed);u.length>0&&console.warn(`[loadEnv] ${l} contains keys that have no effect: ${u.join(", ")}.
|
|
33
|
+
Reason: xdg-basedir caches XDG_* on import, so this .env file loads too late.
|
|
34
|
+
How to override: export them in the shell before loadEnv() runs, or set process.env directly.`);}}}chunkVRQQ33YH_cjs.j();async function Wr(e,t){if(process.env.EASBOT_CLIENT==="acp")try{let s=process.platform==="win32"?"cmd":void 0,a=exports.Shell.spawn(s,`git ${e.join(" ")}`,{stdin:void 0,stdout:"pipe",stderr:"pipe",cwd:t.cwd,env:t.env?{...process.env,...t.env}:process.env}),[i,l,p]=await Promise.all([a.exited,new Response(a.stdout).arrayBuffer(),new Response(a.stderr).arrayBuffer()]),c=Buffer.from(l),u=Buffer.from(p);return {exitCode:i,text:()=>c.toString(),stdout:c,stderr:u}}catch(s){let a=Buffer.from(s instanceof Error?s.message:String(s));return {exitCode:1,text:()=>"",stdout:Buffer.alloc(0),stderr:a}}let r=t.env?{...process.env,...t.env}:void 0,n=exports.Shell.$`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}}chunkVRQQ33YH_cjs.j();function vn(e){return e?he.dirname(url.fileURLToPath(e)):typeof __dirname<"u"?__dirname:process.cwd()}function Tn(e,t,r=3){function n(o,s){if(s>r||!Ne.existsSync(o))return null;try{let a=Ne.readdirSync(o);for(let i of a){let l=he.join(o,i);try{let p=Ne.statSync(l);if(p.isFile()&&l.endsWith(t))return l;if(p.isDirectory()&&s<r){let c=n(l,s+1);if(c)return c}}catch{}}}catch{}return null}return n(e,0)}function Pn(e,t){let r=he.join(e,t);if(Ne.existsSync(r))return r;let n=t.split("/").pop()||t,o=e;for(let s=0;s<5;s++){let a=he.join(o,"assets","txt");if(Ne.existsSync(a)){let p=Tn(a,n,5);if(p)return p}let i=he.join(o,"dist","assets","txt");if(Ne.existsSync(i)){let p=Tn(i,n,5);if(p)return p}let l=he.join(o,"..");if(l===o)break;o=l;}return r}function Vr(e,t){return exports.Lazy.lazy(()=>{try{let r=vn(t),n=Pn(r,e);return exports.PKG.file(n).textSync()}catch(r){throw console.error(`Failed to load text file: ${e}`,r),r}})}function Jr(e,t){return exports.Lazy.lazy(async()=>{try{let r=vn(t),n=Pn(r,e);return await exports.PKG.file(n).text()}catch(r){throw console.error(`Failed to load text file: ${e}`,r),r}})}chunkVRQQ33YH_cjs.j();function Xr(e){return e()}chunkVRQQ33YH_cjs.j();function Kr(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)}}chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function xt(e,t,r,n=()=>true){let o=-1,s=-1,a=0;for(let i=t;i<r;i++){if(!n(i))continue;let l=e[i];if(l){if(l==="("){a+=1;continue}if(l===")"&&a>0){a-=1;continue}a===0&&(l===`
|
|
35
|
+
`?o=i:/\s/.test(l)&&(s=i));}}return {lastNewline:o,lastWhitespace:s}}function Zr(e,t){if(!e)return [];if(t<=0)return [e];if(e.length<=t)return [e]}function be(e,t,r){try{let n=De.z.string().parse(e),o=De.z.number().int().parse(t),s=Zr(n,o);if(s)return s;let a=wt(n,o,i=>{let{lastNewline:l,lastWhitespace:p}=xt(i,0,i.length);return l>0?l: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+`
|
|
34
36
|
|
|
35
37
|
`+s:(r.push(n),n=s);}if(n.length>0)if(n.length<t&&r.length>0){let o=r.pop();r.push(o+`
|
|
36
38
|
|
|
37
|
-
`+n);}else r.push(n);return r}function
|
|
39
|
+
`+n);}else r.push(n);return r}function wt(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 c=i<o.length&&o[i]!==void 0&&/\s/.test(o[i]),u=Math.min(o.length,i+(c?1:0));o=o.slice(u).trimStart();}return o.length>0&&n.push(o),n}chunkVRQQ33YH_cjs.j();var St=De.z.enum(["bold","italic","strikethrough","code","code_block","spoiler","blockquote"]),En=De.z.object({start:De.z.number().int().min(0),end:De.z.number().int().min(0),style:St}).strict().refine(e=>e.end>=e.start,{message:"end must be greater than or equal to start"}),Cn=De.z.object({start:De.z.number().int().min(0),end:De.z.number().int().min(0),href:De.z.string().min(1)}).strict().refine(e=>e.end>=e.start,{message:"end must be greater than or equal to start"}),Ce=De.z.object({text:De.z.string(),styles:De.z.array(En),links:De.z.array(Cn)}).strict(),Oe=De.z.enum(["off","bullets","code"]),He=De.z.object({linkify:De.z.boolean().default(true),enableSpoilers:De.z.boolean().default(false),headingStyle:De.z.enum(["none","bold"]).default("none"),blockquotePrefix:De.z.string().default(""),autolink:De.z.boolean().default(true),tableMode:Oe.default("off")}).partial().default({}),On=De.z.object({open:De.z.string(),close:De.z.string()}).strict(),kt=De.z.object({styleMarkers:De.z.record(St,On).optional(),escapeText:De.z.any().optional(),buildLink:De.z.any().optional()}).strict();De.z.object({start:De.z.number().int().min(0),end:De.z.number().int().min(0),open:De.z.string(),close:De.z.string()}).strict();var Tt=De.z.object({indentSize:De.z.number().int().min(1).default(2),listMarker:De.z.enum(["\u2022","-","*"]).default("\u2022"),codeBlockMarker:De.z.enum(["```","~~~"]).default("```"),preserveFrontmatter:De.z.boolean().default(true)}).strict(),vt=De.z.record(De.z.string(),De.z.string()),We=De.z.object({open:De.z.boolean(),ticks:De.z.number().int().min(0)}).strict();De.z.object({inlineState:We,isInside:De.z.any()}).strict();De.z.object({start:De.z.number().int().min(0),end:De.z.number().int().min(0),openLine:De.z.string(),marker:De.z.string(),indent:De.z.string()}).strict();De.z.object({tables:Oe.optional()}).strict();function oo(e){let t=new ro__default.default({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 Pt(e,t){return {...e,type:"text",content:t,children:void 0}}function so(e){for(let t of e)t.children&&t.children.length>0&&(t.children=io(t.children));}function io(e){let t=0;for(let a of e){if(a.type!=="text")continue;let i=a.content??"",l=0;for(;l<i.length;){let p=i.indexOf("||",l);if(p===-1)break;t+=1,l=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 l=0;for(;l<i.length;){let p=i.indexOf("||",l);if(p===-1){l<i.length&&n.push(Pt(a,i.slice(l)));break}if(s>=r){n.push(Pt(a,i.slice(l)));break}p>l&&n.push(Pt(a,i.slice(l,p))),s+=1,o.spoilerOpen=!o.spoilerOpen,n.push({type:o.spoilerOpen?"spoiler_open":"spoiler_close"}),l=p+2;}}return n}function ao(){return {text:"",styles:[],openStyles:[],links:[],linkStack:[]}}function ue(e){return e.table?.currentCell??e}function Ue(e,t){if(!t)return;let r=ue(e);r.text+=t;}function ye(e,t){let r=ue(e);r.openStyles.push({style:t,start:r.text.length});}function xe(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 An(e){e.env.listStack.length>0||e.table||(e.text+=`
|
|
38
40
|
|
|
39
|
-
`);}function
|
|
40
|
-
`);}function
|
|
41
|
-
`;}for(let a=1;a<o.length;a++)
|
|
42
|
-
`;}else for(let o of r){for(let s=0;s<o.length;s++)
|
|
43
|
-
`;}}function
|
|
44
|
-
`;},l=()=>{e.text+="|";for(let c=0;c<n;c+=1){let
|
|
45
|
-
`;};i(t),l();for(let c of r)i(c);let p=e.text.length;p>a&&e.styles.push({start:a,end:p,style:"code_block"});}function
|
|
46
|
-
`);break;case "paragraph_close":
|
|
41
|
+
`);}function lo(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 co(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 uo(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 fo(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 po(){return {headers:[],rows:[],currentRow:[],currentCell:null,inHeader:false}}function mo(e){return _n(e),{text:e.text,styles:e.styles,links:e.links}}function qe(e){let t=e.text,r=0,n=t.length;for(;r<n&&/\s/.test(t[r]??"");)r+=1;for(;n>r&&/\s/.test(t[n-1]??"");)n-=1;if(r===0&&n===t.length)return e;let o=t.slice(r,n),s=o.length,a=[];for(let l of e.styles){let p=Math.max(0,l.start-r),c=Math.min(s,l.end-r);c>p&&a.push({start:p,end:c,style:l.style});}let i=[];for(let l of e.links){let p=Math.max(0,l.start-r),c=Math.min(s,l.end-r);c>p&&i.push({start:p,end:c,href:l.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 go(e,t){t.text&&(e.text+=t.text);}function Fn(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+=`
|
|
42
|
+
`);}function ho(e){if(!e.table)return;let t=e.table.headers.map(qe),r=e.table.rows.map(o=>o.map(qe));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+=`
|
|
43
|
+
`;}for(let a=1;a<o.length;a++)Fn(e,{header:t[a],value:o[a],columnIndex:a,includeColumnFallback:true});e.text+=`
|
|
44
|
+
`;}else for(let o of r){for(let s=0;s<o.length;s++)Fn(e,{header:t[s],value:o[s],columnIndex:s,includeColumnFallback:false});e.text+=`
|
|
45
|
+
`;}}function bo(e){if(!e.table)return;let t=e.table.headers.map(qe),r=e.table.rows.map(c=>c.map(qe)),n=Math.max(t.length,...r.map(c=>c.length));if(n===0)return;let o=Array.from({length:n},()=>0),s=c=>{for(let u=0;u<n;u+=1){let k=c[u]?.text.length??0;(o[u]??0)<k&&(o[u]=k);}};s(t);for(let c of r)s(c);let a=e.text.length,i=c=>{e.text+="|";for(let u=0;u<n;u+=1){e.text+=" ";let g=c[u];g&&go(e,g);let k=g?.text.length??0,H=(o[u]??0)-k;H>0&&(e.text+=" ".repeat(H)),e.text+=" |";}e.text+=`
|
|
46
|
+
`;},l=()=>{e.text+="|";for(let c=0;c<n;c+=1){let u=o[c]??0,g=Math.max(3,u);e.text+=` ${"-".repeat(g)} |`;}e.text+=`
|
|
47
|
+
`;};i(t),l();for(let c of r)i(c);let p=e.text.length;p>a&&e.styles.push({start:a,end:p,style:"code_block"});}function Mt(e,t){for(let r of e)switch(r.type){case "inline":r.children&&Mt(r.children,t);break;case "text":Ue(t,r.content??"");break;case "em_open":ye(t,"italic");break;case "em_close":xe(t,"italic");break;case "strong_open":ye(t,"bold");break;case "strong_close":xe(t,"bold");break;case "s_open":ye(t,"strikethrough");break;case "s_close":xe(t,"strikethrough");break;case "code_inline":co(t,r.content??"");break;case "spoiler_open":t.enableSpoilers&&ye(t,"spoiler");break;case "spoiler_close":t.enableSpoilers&&xe(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":fo(t);break;case "image":Ue(t,r.content??"");break;case "softbreak":case "hardbreak":Ue(t,`
|
|
48
|
+
`);break;case "paragraph_close":An(t);break;case "heading_open":t.headingStyle==="bold"&&ye(t,"bold");break;case "heading_close":t.headingStyle==="bold"&&xe(t,"bold"),An(t);break;case "blockquote_open":t.blockquotePrefix&&(t.text+=t.blockquotePrefix),ye(t,"blockquote");break;case "blockquote_close":xe(t,"blockquote");break;case "bullet_list_open":t.env.listStack.length>0&&(t.text+=`
|
|
47
49
|
`),t.env.listStack.push({type:"bullet",index:0});break;case "bullet_list_close":t.env.listStack.pop(),t.env.listStack.length===0&&(t.text+=`
|
|
48
50
|
`);break;case "ordered_list_open":{t.env.listStack.length>0&&(t.text+=`
|
|
49
|
-
`);let n=Number(
|
|
50
|
-
`);break;case "list_item_open":
|
|
51
|
+
`);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+=`
|
|
52
|
+
`);break;case "list_item_open":lo(t);break;case "list_item_close":t.text.endsWith(`
|
|
51
53
|
`)||(t.text+=`
|
|
52
|
-
`);break;case "code_block":case "fence":
|
|
54
|
+
`);break;case "code_block":case "fence":uo(t,r.content??"");break;case "html_block":case "html_inline":Ue(t,r.content??"");break;case "table_open":t.tableMode!=="off"&&(t.table=po(),t.hasTables=true);break;case "table_close":t.table&&(t.tableMode==="bullets"?ho(t):t.tableMode==="code"&&bo(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=ao());break;case "th_close":case "td_close":t.table?.currentCell&&(t.table.currentRow.push(mo(t.table.currentCell)),t.table.currentCell=null);break;case "hr":t.text+=`\u2500\u2500\u2500
|
|
53
55
|
|
|
54
|
-
`;break;default:r.children&&
|
|
55
|
-
`);let k=c.findIndex(E=>E.spanIndex===
|
|
56
|
+
`;break;default:r.children&&Mt(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 yo(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 xo(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 Bn(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 Ln(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 wo(e,t,r){if(e.length===0)return [];let n=[];for(let o of e){let s=Ln(o,t,r);s&&n.push({start:s.start-t,end:s.end-t,style:o.style});}return Bn(n)}function So(e,t,r){if(e.length===0)return [];let n=[];for(let o of e){let s=Ln(o,t,r);s&&n.push({start:s.start-t,end:s.end-t,href:o.href});}return n}function we(e,t){try{let r=typeof e=="string"?e:"",n=He.parse(t??{});return Ie(r,n).ir}catch(r){return console.error("Markdown parse error:",r),{text:"",styles:[],links:[]}}}function Ie(e,t){try{let r=typeof e=="string"?e:"",n=He.parse(t),o={listStack:[]},a=oo(n).parse(r||"",o);n.enableSpoilers&&so(a);let i=n.tableMode??"off",l={text:"",styles:[],openStyles:[],links:[],linkStack:[],env:o,headingStyle:n.headingStyle??"none",blockquotePrefix:n.blockquotePrefix??"",enableSpoilers:n.enableSpoilers??!1,tableMode:i,table:null,hasTables:!1};Mt(a,l),_n(l);let c=l.text.trimEnd().length,u=0;for(let E of l.styles)E.style==="code_block"&&E.end>u&&(u=E.end);let g=Math.max(c,u);return {ir:{text:g===l.text.length?l.text:l.text.slice(0,g),styles:Bn(yo(l.styles,g)),links:xo(l.links,g)},hasTables:l.hasTables}}catch(r){return console.error("Markdown parse error:",r),{ir:{text:"",styles:[],links:[]},hasTables:false}}}function $n(e,t){try{let r=Ce.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=be(r.text,n),s=[],a=0;return o.forEach((i,l)=>{if(!i)return;if(l>0)for(;a<r.text.length&&/\s/.test(r.text[a]??"");)a+=1;let p=a,c=Math.min(r.text.length,p+i.length);s.push({text:i,styles:wo(r.styles,p,c),links:So(r.links,p,c)}),a=c;}),s}catch(r){return console.error("Chunk IR error:",r),[]}}chunkVRQQ33YH_cjs.j();var ko={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function Ae(e,t){try{let r=Ce.parse(e),n=kt.parse(t??{});if(!r.text)return "";let o=n.styleMarkers??ko,s=n.escapeText??(u=>u),a=n.buildLink,i=[];for(let u=0;u<r.styles.length;u++){let g=r.styles[u];g&&(i.push({position:g.start,type:"open",style:g.style,spanIndex:u}),i.push({position:g.end,type:"close",style:g.style,spanIndex:u}));}for(let u=0;u<r.links.length;u++){let g=r.links[u];g&&(i.push({position:g.start,type:"link_open",spanIndex:u,href:g.href}),i.push({position:g.end,type:"link_close",spanIndex:u,href:g.href}));}i.sort((u,g)=>{if(u.position!==g.position)return u.position-g.position;let k=(G,V)=>G==="link_open"?0:G==="open"?1:G==="close"?2:G==="link_close"?3:4,E=u.type==="close"||u.type==="link_close",H=g.type==="close"||g.type==="link_close",U=k(u.type,E),q=k(g.type,H);return U!==q?U-q:u.type==="open"&&g.type==="open"?u.spanIndex-g.spanIndex:u.type==="close"&&g.type==="close"?g.spanIndex-u.spanIndex:u.spanIndex-g.spanIndex});let l="",p=0,c=[];for(let u of i){if(u.position>p){let g=r.text.slice(p,u.position);l+=s?s(g):g;}if(u.type==="open"||u.type==="close"){let g=o[u.style];if(g)if(u.type==="open")l+=g.open,c.push(u);else {l+=g.close,u.style==="code_block"&&u.position<r.text.length&&(l+=`
|
|
57
|
+
`);let k=c.findIndex(E=>E.spanIndex===u.spanIndex&&E.type==="open");k!==-1&&c.splice(k,1);}}else if(u.type==="link_open")l+="[",c.push(u);else if(u.type==="link_close"){l+="]("+u.href+")";let g=c.findIndex(k=>k.spanIndex===u.spanIndex&&k.type==="link_open");g!==-1&&c.splice(g,1);}p=u.position;}if(p<r.text.length){let u=r.text.slice(p);l+=s?s(u):u;}return l}catch(r){return console.error("Markdown render error:",r),""}}function Se(e,t){return Ae(e,t)}chunkVRQQ33YH_cjs.j();function To(e){let t=e.replace(/\r\n/g,`
|
|
56
58
|
`).replace(/\r/g,`
|
|
57
59
|
`);if(!t.startsWith("---"))return {frontmatter:"",content:e};let r=t.indexOf(`
|
|
58
|
-
---`,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
|
|
60
|
+
---`,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 Ge(e,t){try{let r=typeof e=="string"?e:"",n=Tt.parse(t??{});if(!r)return "";let{frontmatter:o,content:s}=To(r),a=we(s,{linkify:!0,enableSpoilers:!1,autolink:!0,headingStyle:"none",blockquotePrefix:"",tableMode:"off"}),i=Se(a);return i=i.replace(/\n{3,}/g,`
|
|
59
61
|
|
|
60
62
|
`),i=i.trimEnd()+`
|
|
61
63
|
`,n.preserveFrontmatter&&o&&(i=o+`
|
|
62
|
-
`+i),i}catch(r){return console.error("Markdown format error:",r),e}}chunkVRQQ33YH_cjs.j();function
|
|
63
|
-
`).trim(),linesConsumed:n-t}}function
|
|
64
|
-
`),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:c,linesConsumed:
|
|
64
|
+
`+i),i}catch(r){return console.error("Markdown format error:",r),e}}chunkVRQQ33YH_cjs.j();function vo(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Po(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 Ro(e){try{let t=jn__default.default.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=Po(o);a&&(r[s]=a);}return r}catch{return null}}function Mo(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(`
|
|
65
|
+
`).trim(),linesConsumed:n-t}}function Eo(e){let t={},r=e.split(`
|
|
66
|
+
`),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:c,linesConsumed:u}=Mo(r,n);c&&(t[a]={value:c,kind:"multiline",rawInline:i}),n+=u;continue}}let l=vo(i);l&&(t[a]={value:l,kind:"inline",rawInline:i}),n+=1;}return t}function Co(e){let t={};for(let[r,n]of Object.entries(e))t[r]=n.value;return t}function Oo(e){return /^[|>][+-]?(\d+)?[+-]?$/.test(e)}function Io(e){let{lineEntry:t,yamlValue:r}=e;return r.kind!=="structured"||t.kind!=="inline"||Oo(t.rawInline)?false:t.value.includes(":")}function Ao(e){let t=e.replace(/\r\n/g,`
|
|
65
67
|
`).replace(/\r/g,`
|
|
66
68
|
`);if(!t.startsWith("---"))return;let r=t.indexOf(`
|
|
67
|
-
---`,3);if(r!==-1)return t.slice(4,r)}function
|
|
68
|
-
${
|
|
69
|
-
---`}catch(t){return console.warn("Failed to serialize frontmatter:",t),""}}function
|
|
69
|
+
---`,3);if(r!==-1)return t.slice(4,r)}function Fe(e){try{if(typeof e!="string")return {};let t=Ao(e);if(!t)return {};let r=Eo(t),n=Ro(t);if(n===null)return Co(r);let o={};for(let[s,a]of Object.entries(n)){o[s]=a.value;let i=r[s];i&&Io({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 Ye(e){try{let t=vt.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 `---
|
|
70
|
+
${jn__default.default.stringify(r,{lineWidth:0,defaultStringType:"QUOTE_DOUBLE"}).trim()}
|
|
71
|
+
---`}catch(t){return console.warn("Failed to serialize frontmatter:",t),""}}function Ve(e){try{if(typeof e!="string")return {frontmatter:{},content:""};let t=e.replace(/\r\n/g,`
|
|
70
72
|
`).replace(/\r/g,`
|
|
71
73
|
`);if(!t.startsWith("---"))return {frontmatter:{},content:e};let r=t.indexOf(`
|
|
72
|
-
---`,3);if(r===-1)return {frontmatter:{},content:e};let n=t.slice(4,r),o=t.slice(r+4).trimStart();return {frontmatter:
|
|
73
|
-
`,o),a=s===-1?t.length:s,i=t.slice(o,a),l=i.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(l){let p=l[1],c=l[2];if(!p||!c){o=a+1;continue}let
|
|
74
|
-
Content-Type: ${de(
|
|
74
|
+
---`,3);if(r===-1)return {frontmatter:{},content:e};let n=t.slice(4,r),o=t.slice(r+4).trimStart();return {frontmatter:Fe(e),content:o}}catch(t){return console.warn("Failed to extract frontmatter:",t),{frontmatter:{},content:e}}}chunkVRQQ33YH_cjs.j();chunkVRQQ33YH_cjs.j();function Je(e){try{let t=De.z.string().parse(e),r=[],n,o=0;for(;o<=t.length;){let s=t.indexOf(`
|
|
75
|
+
`,o),a=s===-1?t.length:s,i=t.slice(o,a),l=i.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(l){let p=l[1],c=l[2];if(!p||!c){o=a+1;continue}let u=c[0];if(!u){o=a+1;continue}let g=c.length;if(!n)n={start:o,markerChar:u,markerLen:g,openLine:i,marker:c,indent:p};else if(n.markerChar===u&&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 Et(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 Nn(e,t){return !Et(e,t)}function Xe(){return {open:false,ticks:0}}function Ke(e,t){try{let r=De.z.string().parse(e),n=t?We.parse(t):Xe(),o=Je(r),s={open:n.open,ticks:n.ticks},{spans:a,state:i}=Bo(r,o,s);return {inlineState:i,isInside:l=>$o(l,o)||jo(l,a)}}catch(r){return console.warn("Invalid input for buildCodeSpanIndex:",r),{inlineState:Xe(),isInside:()=>false}}}function Bo(e,t,r){let n=[],o=r.open,s=r.ticks,a=o?0:-1,i=0;for(;i<e.length;){let l=Lo(t,i);if(l){i=l.end;continue}if(e[i]!=="`"){i+=1;continue}let p=i,c=0;for(;i<e.length&&e[i]==="`";)c+=1,i+=1;if(!o){o=true,s=c,a=p;continue}c===s&&(n.push([a,i]),o=false,s=0,a=-1);}return o&&n.push([a,e.length]),{spans:n,state:{open:o,ticks:s}}}function Lo(e,t){return e.find(r=>t>=r.start&&t<r.end)}function $o(e,t){return t.some(r=>e>=r.start&&e<r.end)}function jo(e,t){return t.some(([r,n])=>e>=r&&e<n)}chunkVRQQ33YH_cjs.j();var Do={bold:{open:"**",close:"**"},italic:{open:"_",close:"_"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function Ze(e,t){try{let r=De.z.string().parse(e),n=Oe.parse(t);if(!r||n==="off")return r;let{ir:o,hasTables:s}=Ie(r,{linkify:!1,enableSpoilers:!1,autolink:!1,headingStyle:"none",blockquotePrefix:"",tableMode:n});return s?Ae(o,{styleMarkers:Do,escapeText:a=>a,buildLink:(a,i)=>{let l=a.href.trim();return !l||!i.slice(a.start,a.end)?null:{start:a.start,end:a.end,open:"[",close:`](${l})`}}}):r}catch(r){return console.warn("Invalid input for convertMarkdownTables:",r),typeof e=="string"?e:""}}exports.Markdown=void 0;(p=>{function e(c,u){try{return we(c,u)}catch(g){return console.warn("Markdown.parse error:",g),{text:"",styles:[],links:[]}}}p.parse=e;function t(c,u){try{return Se(c,u)}catch(g){return console.warn("Markdown.render error:",g),""}}p.render=t;function r(c,u){try{return Ge(c,u)}catch(g){return console.warn("Markdown.format error:",g),typeof c=="string"?c:""}}p.format=r;function n(c){try{return Fe(c)}catch(u){return console.warn("Markdown.parseFrontmatter error:",u),{}}}p.parseFrontmatter=n;function o(c){try{return Ye(c)}catch(u){return console.warn("Markdown.serializeFrontmatter error:",u),""}}p.serializeFrontmatter=o;function s(c){try{return Ve(c)}catch(u){return console.warn("Markdown.extractFrontmatter error:",u),{frontmatter:{},content:typeof c=="string"?c:""}}}p.extractFrontmatter=s;function a(c,u,g){try{return be(c,u,g)}catch(k){return console.warn("Markdown.chunk error:",k),typeof c=="string"&&c.length>0?[c]:[]}}p.chunk=a;function i(c,u){try{return Ke(c,u)}catch(g){return console.warn("Markdown.buildCodeIndex error:",g),{inlineState:{open:false,ticks:0},isInside:()=>false}}}p.buildCodeIndex=i;function l(c,u){try{return Ze(c,u)}catch(g){return console.warn("Markdown.convertTables error:",g),typeof c=="string"?c:""}}p.convertTables=l;})(exports.Markdown||(exports.Markdown={}));chunkVRQQ33YH_cjs.j();function Dn(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r[r.length-1]??""}function zo(e){if(!e)return "";let r=e.replace(/[/\\]+$/,"").split(/[/\\]/);return r.slice(0,r.length-1).join("/")+"/"}function Ho(e){if(!e)return "";let t=e.split(".");return t[t.length-1]}function Wo(e,t=20){let r=Dn(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 Uo(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)}chunkVRQQ33YH_cjs.j();var qo=["load failed","network connection was lost","network request failed","failed to fetch","econnreset","econnrefused","etimedout","socket hang up"];function Go(e){if(!e)return false;let t=String(e instanceof Error?e.message:e).toLowerCase();return qo.some(r=>t.includes(r))}async function Ot(e,t={}){let{attempts:r=3,delay:n=500,factor:o=2,maxDelay:s=1e4,retryIf:a=Go}=t,i;for(let l=0;l<r;l++)try{return await e()}catch(p){if(i=p,l===r-1||!a(p))throw p;let c=Math.min(n*o**l,s);await new Promise(u=>setTimeout(u,c));}throw i}chunkVRQQ33YH_cjs.j();exports.Fetch=void 0;(Ht=>{let e=chunkZHSHEAQD_cjs.m.create({service:"fetch"}),t=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"],r=false,n=null;function o(){return t.some(I=>{let C=process.env[I];return typeof C=="string"&&C.trim().length>0})}Ht.hasProxyConfigured=o;function s(){let I=process.env.http_proxy||process.env.HTTP_PROXY;return process.env.https_proxy||process.env.HTTPS_PROXY||I}Ht.getProxyUrl=s;function a(I={}){let C=I.httpProxy||I.httpsProxy||s();if(!C){e.warn("[Fetch] No proxy configured, HTTP_PROXY/HTTPS_PROXY environment variables not set");return}let _=new undici.ProxyAgent({uri:C,connectTimeout:I.connectTimeout||1e4,keepAliveTimeout:I.keepAliveTimeout||3e4});n=undici.getGlobalDispatcher(),undici.setGlobalDispatcher(_),r=true,e.info(`[Fetch] Global proxy enabled: ${C}`);}Ht.enableProxy=a;function i(){!r||!n||(undici.setGlobalDispatcher(n),r=false,n=null,e.info("[Fetch] \u5168\u5C40\u4EE3\u7406\u5DF2\u7981\u7528"));}Ht.disableProxy=i;function l(){return r}Ht.isProxyEnabled=l;async function p(I,C){let _=C?.timeout||3e4,W=C?.responseType||"json",{timeout:Y,responseType:ve,...$}=C||{},S=null,m=null;try{$.signal||(S=new AbortController,m=setTimeout(()=>S.abort(),_));let f=await fetch(I,{...$,signal:$.signal||S.signal});m&&clearTimeout(m);let d;switch(W){case "arrayBuffer":d=await f.arrayBuffer();break;case "blob":d=await f.blob();break;case "buffer":{let y=await f.arrayBuffer();d=Buffer.from(y);break}case "text":d=await f.text();break;default:{let y=await f.text();try{d=JSON.parse(y);}catch{d=y;}break}}return {ok:f.ok,status:f.status,statusText:f.statusText,headers:f.headers,data:d,url:f.url}}catch(f){throw m&&clearTimeout(m),f}}async function c(I,C){let _=C?.retries??0,W=C?.retryDelay??1e3,{retries:Y,retryDelay:ve,responseType:$,...S}=C||{};return Ot(()=>p(I,{...S,responseType:C?.responseType}),{attempts:_+1,delay:W,maxDelay:W*2**(_+1)})}async function u(I,C){return c(I,{method:"GET",...C})}Ht.get=u;async function g(I,C,_){return c(I,{method:"POST",headers:{"Content-Type":"application/json",..._?.headers},body:C?JSON.stringify(C):void 0,..._})}Ht.post=g;async function k(I,C,_){return c(I,{method:"PUT",headers:{"Content-Type":"application/json",..._?.headers},body:C?JSON.stringify(C):void 0,..._})}Ht.put=k;async function E(I,C,_){return c(I,{method:"DELETE",headers:{"Content-Type":"application/json",..._?.headers},body:C?JSON.stringify(C):void 0,..._})}Ht.del=E;async function H(I,C,_){return c(I,{method:"PATCH",headers:{"Content-Type":"application/json",..._?.headers},body:C?JSON.stringify(C):void 0,..._})}Ht.patch=H;async function U(I,C){return c(I,C)}Ht.request=U;function q(I={}){return o()?(a(I),true):false}Ht.autoProxy=q;let G=5*1024*1024;function V(I){return new TextEncoder().encode(I)}function de(I){return chunkYPKMFQLR_cjs.c.mimeType(I)}function se(I){return I.startsWith("file://")}async function fe(I){let C=url.fileURLToPath(I);return await exports.PKG.file(C).bytes()}async function ke(I,C,_){let W=`----FetchFormBoundary${Date.now()}`,Y=[],$=C.some(h=>h.filename||h.value instanceof Uint8Array||Buffer.isBuffer(h.value))&&!_?.timeout?3e5:_?.timeout;for(let h of C){let w=h.maxSize??G,P=h.filename,v=`Content-Disposition: form-data; name="${h.name}"${P?`; filename="${P}"`:""}`;P&&(v+=`\r
|
|
76
|
+
Content-Type: ${de(P)}`),v+=`\r
|
|
75
77
|
\r
|
|
76
|
-
`,
|
|
77
|
-
--${W}--`),m=
|
|
78
|
+
`,Y.push(V(v));let T=h.value;if(typeof T=="string")if(se(T)){let O=await fe(T);if(P||(P=T.split("/").pop()||"file"),O.byteLength>w)throw new Error(`File size ${O.byteLength} exceeds limit ${w} bytes: ${P}`);Y.push(O);}else Y.push(V(T));else if(Buffer.isBuffer(T)){if(T.byteLength>w)throw new Error(`Buffer size ${T.byteLength} exceeds limit ${w} bytes: ${h.name}`);Y.push(new Uint8Array(T.buffer,T.byteOffset,T.byteLength));}else if(T instanceof Uint8Array){if(T.byteLength>w)throw new Error(`File size ${T.byteLength} exceeds limit ${w} bytes: ${h.name}`);Y.push(T);}}let S=V(`\r
|
|
79
|
+
--${W}--`),m=V(`\r
|
|
78
80
|
--${W}\r
|
|
79
|
-
`),f=[];f.push(
|
|
80
|
-
`));for(let h=0;h<
|
|
81
|
-
`)));f.push(S);let
|
|
82
|
-
`);u=w.pop()??"";for(let R of w)if(R.startsWith("data: ")){let v=R.slice(6);if(v==="[DONE]"){C.onComplete?.();return}C.onMessage?.(v);}}C.onComplete?.();}catch(_){_.name!=="AbortError"&&C.onError?.(_);}})(),()=>{W.abort();}}Dt.sse=Te;})(exports.Fetch||(exports.Fetch={}));chunkVRQQ33YH_cjs.j();exports.Slug=void 0;(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;})(exports.Slug||(exports.Slug={}));chunkVRQQ33YH_cjs.j();function zn(e){let t=new AbortController,r=setTimeout(t.abort.bind(t),e);return {controller:t,signal:t.signal,clearTimeout:()=>globalThis.clearTimeout(r)}}function Jo(e,...t){let r=zn(e);return {signal:AbortSignal.any([r.signal,...t]),clearTimeout:r.clearTimeout}}chunkVRQQ33YH_cjs.j();exports.Archive=void 0;(t=>{async function e(r,n){if(process.platform==="win32"){let o=he__default.default.resolve(r),s=he__default.default.resolve(n),a=`Expand-Archive -Path '${o}' -DestinationPath '${s}' -Force`,i=await exports.Shell.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 exports.Shell.run(void 0,o);if(s.code!==0)throw new Error(`unzip exited with code ${s.code}: ${s.stderr}`)}}t.extractZip=e;})(exports.Archive||(exports.Archive={}));chunkVRQQ33YH_cjs.j();exports.Color=void 0;(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;})(exports.Color||(exports.Color={}));chunkVRQQ33YH_cjs.j();exports.Context=void 0;(r=>{class e extends Error{constructor(s){super(`No context found for ${s}`);chunkVRQQ33YH_cjs.c(this,"name",s);}}r.NotFound=e;function t(n){let o=new async_hooks.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;})(exports.Context||(exports.Context={}));chunkVRQQ33YH_cjs.j();function Zo(e){return {[Symbol.dispose](){e();},[Symbol.asyncDispose](){return Promise.resolve(e())}}}chunkVRQQ33YH_cjs.j();exports.EventLoop=void 0;(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;})(exports.EventLoop||(exports.EventLoop={}));chunkVRQQ33YH_cjs.j();function Xo(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`}chunkVRQQ33YH_cjs.j();exports.Keybind=void 0;(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 d of p)if(!c.includes(d)||!e(i[d],l[d]))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("+"),d={ctrl:false,meta:false,shift:false,super:false,leader:false,name:""};for(let g of c)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;})(exports.Keybind||(exports.Keybind={}));chunkVRQQ33YH_cjs.j();exports.Locale=void 0;(p=>{function e(c){return c.replace(/\b\w/g,d=>d.toUpperCase())}p.titlecase=e;function t(c){return new Date(c).toLocaleTimeString(void 0,{timeStyle:"short"})}p.time=t;function r(c){let d=new Date(c),g=t(c),k=d.toLocaleDateString();return `${g} \xB7 ${k}`}p.datetime=r;function n(c){let d=new Date(c),g=new Date;return d.getFullYear()===g.getFullYear()&&d.getMonth()===g.getMonth()&&d.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 k=Math.floor(c/6e4),E=Math.floor(c%6e4/1e3);return `${k}m ${E}s`}if(c<864e5){let k=Math.floor(c/36e5),E=Math.floor(c%36e5/6e4);return `${k}h ${E}m`}let d=Math.floor(c/36e5);return `${Math.floor(c%36e5/864e5)}d ${d}h`}p.duration=s;function a(c,d){return c.length<=d?c:c.slice(0,d-1)+"\u2026"}p.truncate=a;function i(c,d=35){if(c.length<=d)return c;let g="\u2026",k=Math.ceil((d-g.length)/2),E=Math.floor((d-g.length)/2);return c.slice(0,k)+g+c.slice(-E)}p.truncateMiddle=i;function l(c,d,g){return (c===1?d:g).replace("{}",c.toString())}p.pluralize=l;})(exports.Locale||(exports.Locale={}));chunkVRQQ33YH_cjs.j();var Qo=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"];function es(){return Qo.some(e=>process.env[e])}function ts(){return process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy}function ns(){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)}}chunkVRQQ33YH_cjs.j();var jt=class{constructor(){chunkVRQQ33YH_cjs.c(this,"queue",[]);chunkVRQQ33YH_cjs.c(this,"resolvers",[]);}push(t){let r=this.resolvers.shift();r?r(t):this.queue.push(t);}async next(){return this.queue.length>0?this.queue.shift():new Promise(t=>this.resolvers.push(t))}async*[Symbol.asyncIterator](){for(;;)yield await this.next();}};async function rs(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);}}));}chunkVRQQ33YH_cjs.j();function os(){let e,t=new Promise(r=>e=r);return {trigger(){return e()},wait(){return t}}}chunkVRQQ33YH_cjs.j();function ss(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);})])}chunkVRQQ33YH_cjs.j();exports.Token=void 0;(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,d=Math.round(p/1.5),g=Math.round(c/4);return Math.max(0,d+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,d=i.cache?.write??0;return l+p+c+d}a.total=s;})(exports.Token||(exports.Token={}));chunkVRQQ33YH_cjs.j();function as(e){let t={};for(let[r,n]of Object.entries(e.required().shape))t[r]=n.nullable();return ze__default.default.object(t)}chunkVRQQ33YH_cjs.j();exports.Wildcard=void 0;(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[d,g]of p)e(a,d)&&(c=g);return c}s.all=r;function n(a,i){let l=Object.entries(i),p=t(l),c;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)))&&(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}})(exports.Wildcard||(exports.Wildcard={}));Object.defineProperty(exports,"Filesystem",{enumerable:true,get:function(){return chunkYPKMFQLR_cjs.c}});Object.defineProperty(exports,"Glob",{enumerable:true,get:function(){return chunkYPKMFQLR_cjs.a}});Object.defineProperty(exports,"MIME_TYPES",{enumerable:true,get:function(){return chunkYPKMFQLR_cjs.b}});Object.defineProperty(exports,"Log",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.m}});Object.defineProperty(exports,"PackageRegistry",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.o}});Object.defineProperty(exports,"Semver",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.n}});Object.defineProperty(exports,"addMinutesInTimezone",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.l}});Object.defineProperty(exports,"formatLocalISO",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.a}});Object.defineProperty(exports,"formatLocalISOCompact",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.b}});Object.defineProperty(exports,"formatLogTime",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.f}});Object.defineProperty(exports,"formatLogTimeMs",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.g}});Object.defineProperty(exports,"getTimezoneOffset",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.h}});Object.defineProperty(exports,"getTimezoneParts",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.i}});Object.defineProperty(exports,"isValidTimezone",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.j}});Object.defineProperty(exports,"normalizeTimezone",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.k}});Object.defineProperty(exports,"now",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.c}});Object.defineProperty(exports,"nowLocalISO",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.d}});Object.defineProperty(exports,"parseLocalISO",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.e}});Object.defineProperty(exports,"Lock",{enumerable:true,get:function(){return chunkYC4AEMOP_cjs.a}});Object.defineProperty(exports,"Hono",{enumerable:true,get:function(){return hono.Hono}});Object.defineProperty(exports,"createNodeWebSocket",{enumerable:true,get:function(){return nodeWs.createNodeWebSocket}});Object.defineProperty(exports,"cors",{enumerable:true,get:function(){return cors.cors}});Object.defineProperty(exports,"logger",{enumerable:true,get:function(){return logger.logger}});Object.defineProperty(exports,"compress",{enumerable:true,get:function(){return compress.compress}});Object.defineProperty(exports,"secureHeaders",{enumerable:true,get:function(){return secureHeaders.secureHeaders}});Object.defineProperty(exports,"timeout",{enumerable:true,get:function(){return timeout.timeout}});Object.defineProperty(exports,"HTTPException",{enumerable:true,get:function(){return httpException.HTTPException}});Object.defineProperty(exports,"validator",{enumerable:true,get:function(){return validator.validator}});Object.defineProperty(exports,"zValidator",{enumerable:true,get:function(){return zodValidator.zValidator}});exports.$=Br;exports.AsyncQueue=jt;exports.NamedError=mt;exports.PkgShell=Re;exports.abortAfter=zn;exports.abortAfterAny=Jo;exports.buildCodeSpanIndex=Ze;exports.chunkMarkdownIR=Bn;exports.chunkText=be;exports.chunkTextByBreakResolver=xt;exports.convertMarkdownTables=Xe;exports.createInlineCodeState=Ke;exports.createPkgShell=ce;exports.createRESTServer=lt;exports.createRPCServer=at;exports.createServer=ae;exports.createStreamingServer=ut;exports.createWebSocketServer=ct;exports.defer=Zo;exports.detectPlatform=fn;exports.escapeCommandArg=pt;exports.escapeCommandArgSafe=dn;exports.extractFrontmatter=Ge;exports.findFenceSpanAt=Mt;exports.findLast=or;exports.fn=_r;exports.formatDuration=Xo;exports.formatMarkdown=Ye;exports.getDirectory=zo;exports.getFileExtension=Do;exports.getFilename=jn;exports.getFilenameTruncated=Ho;exports.getProxyConfig=ns;exports.getProxyUrl=ts;exports.git=Hr;exports.iife=Jr;exports.isSafeFenceBreak=_n;exports.joinCommandArgs=me;exports.lazy=$e;exports.lazyAsync=ar;exports.loadEnv=Dr;exports.loadTextFile=Vr;exports.loadTextFileAsync=Gr;exports.markdownToIR=we;exports.markdownToIRWithMeta=Oe;exports.needsShellExecution=cn;exports.parseCommand=re;exports.parseCommandWithOptions=un;exports.parseFenceSpans=Je;exports.parseFrontmatterBlock=Ae;exports.parseModelId=Kr;exports.proxied=es;exports.readableStreamToText=Fr;exports.renderMarkdown=Se;exports.renderMarkdownWithMarkers=Fe;exports.retry=Ct;exports.scanParenAwareBreakpoints=yt;exports.serializeFrontmatter=Ve;exports.shell=mn;exports.signal=os;exports.startServer=dr;exports.truncateMiddle=Wo;exports.updateSchema=as;exports.whichSync=Ar;exports.withTimeout=ss;exports.work=rs;
|
|
81
|
+
`),f=[];f.push(V(`--${W}\r
|
|
82
|
+
`));for(let h=0;h<Y.length;h++)f.push(Y[h]),h%2===1&&h<Y.length-1&&(f.push(m),f.push(V(`--${W}\r
|
|
83
|
+
`)));f.push(S);let d=f.reduce((h,w)=>h+w.length,0),y=new Uint8Array(d),x=0;for(let h of f)y.set(h,x),x+=h.length;return c(I,{method:"POST",headers:{"Content-Type":`multipart/form-data; boundary=${W}`,..._?.headers},body:y,timeout:$,..._})}Ht.postForm=ke;function Te(I,C,_){let W=new AbortController,Y=W.signal;return (async()=>{try{let $={Accept:"text/event-stream",..._?.headers||{}},S=await fetch(I,{..._,headers:$,signal:Y});if(!S.ok)throw new Error(`SSE connection failed: ${S.status}`);let m=S.body?.getReader();if(!m)throw new Error("SSE stream not available");let f=new TextDecoder("utf-8"),d="";for(;!Y.aborted;){let{done:y,value:x}=await m.read();if(y)break;let h=f.decode(x,{stream:!0});d+=h;let w=d.split(`
|
|
84
|
+
`);d=w.pop()??"";for(let P of w)if(P.startsWith("data: ")){let v=P.slice(6);if(v==="[DONE]"){C.onComplete?.();return}C.onMessage?.(v);}}C.onComplete?.();}catch($){$.name!=="AbortError"&&C.onError?.($);}})(),()=>{W.abort();}}Ht.sse=Te;})(exports.Fetch||(exports.Fetch={}));chunkVRQQ33YH_cjs.j();exports.Slug=void 0;(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;})(exports.Slug||(exports.Slug={}));chunkVRQQ33YH_cjs.j();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 Xo(e,...t){let r=Hn(e);return {signal:AbortSignal.any([r.signal,...t]),clearTimeout:r.clearTimeout}}chunkVRQQ33YH_cjs.j();exports.Archive=void 0;(t=>{async function e(r,n){if(process.platform==="win32"){let o=he__default.default.resolve(r),s=he__default.default.resolve(n),a=`Expand-Archive -Path '${o}' -DestinationPath '${s}' -Force`,i=await exports.Shell.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 exports.Shell.run(void 0,o);if(s.code!==0)throw new Error(`unzip exited with code ${s.code}: ${s.stderr}`)}}t.extractZip=e;})(exports.Archive||(exports.Archive={}));chunkVRQQ33YH_cjs.j();exports.Color=void 0;(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;})(exports.Color||(exports.Color={}));chunkVRQQ33YH_cjs.j();exports.Context=void 0;(r=>{class e extends Error{constructor(s){super(`No context found for ${s}`);chunkVRQQ33YH_cjs.c(this,"name",s);}}r.NotFound=e;function t(n){let o=new async_hooks.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;})(exports.Context||(exports.Context={}));chunkVRQQ33YH_cjs.j();function Zo(e){return {[Symbol.dispose](){e();},[Symbol.asyncDispose](){return Promise.resolve(e())}}}chunkVRQQ33YH_cjs.j();exports.EventLoop=void 0;(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;})(exports.EventLoop||(exports.EventLoop={}));chunkVRQQ33YH_cjs.j();function Qo(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`}chunkVRQQ33YH_cjs.j();exports.Keybind=void 0;(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;})(exports.Keybind||(exports.Keybind={}));chunkVRQQ33YH_cjs.j();exports.Locale=void 0;(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),k=u.toLocaleDateString();return `${g} \xB7 ${k}`}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 k=Math.floor(c/6e4),E=Math.floor(c%6e4/1e3);return `${k}m ${E}s`}if(c<864e5){let k=Math.floor(c/36e5),E=Math.floor(c%36e5/6e4);return `${k}h ${E}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",k=Math.ceil((u-g.length)/2),E=Math.floor((u-g.length)/2);return c.slice(0,k)+g+c.slice(-E)}p.truncateMiddle=i;function l(c,u,g){return (c===1?u:g).replace("{}",c.toString())}p.pluralize=l;})(exports.Locale||(exports.Locale={}));chunkVRQQ33YH_cjs.j();var es=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"];function ts(){return es.some(e=>process.env[e])}function ns(){return process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy}function rs(){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)}}chunkVRQQ33YH_cjs.j();var Nt=class{constructor(){chunkVRQQ33YH_cjs.c(this,"queue",[]);chunkVRQQ33YH_cjs.c(this,"resolvers",[]);}push(t){let r=this.resolvers.shift();r?r(t):this.queue.push(t);}async next(){return this.queue.length>0?this.queue.shift():new Promise(t=>this.resolvers.push(t))}async*[Symbol.asyncIterator](){for(;;)yield await this.next();}};async function os(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);}}));}chunkVRQQ33YH_cjs.j();function ss(){let e,t=new Promise(r=>e=r);return {trigger(){return e()},wait(){return t}}}chunkVRQQ33YH_cjs.j();function is(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);})])}chunkVRQQ33YH_cjs.j();exports.Token=void 0;(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;})(exports.Token||(exports.Token={}));chunkVRQQ33YH_cjs.j();function ls(e){let t={};for(let[r,n]of Object.entries(e.required().shape))t[r]=n.nullable();return De__default.default.object(t)}chunkVRQQ33YH_cjs.j();exports.Wildcard=void 0;(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 k=u.split(/\s+/);e(a.head,k[0])&&(k.length===1||o(a.tail,k.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}})(exports.Wildcard||(exports.Wildcard={}));Object.defineProperty(exports,"Filesystem",{enumerable:true,get:function(){return chunkYPKMFQLR_cjs.c}});Object.defineProperty(exports,"Glob",{enumerable:true,get:function(){return chunkYPKMFQLR_cjs.a}});Object.defineProperty(exports,"MIME_TYPES",{enumerable:true,get:function(){return chunkYPKMFQLR_cjs.b}});Object.defineProperty(exports,"Log",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.m}});Object.defineProperty(exports,"PackageRegistry",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.o}});Object.defineProperty(exports,"Semver",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.n}});Object.defineProperty(exports,"addMinutesInTimezone",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.l}});Object.defineProperty(exports,"formatLocalISO",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.a}});Object.defineProperty(exports,"formatLocalISOCompact",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.b}});Object.defineProperty(exports,"formatLogTime",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.f}});Object.defineProperty(exports,"formatLogTimeMs",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.g}});Object.defineProperty(exports,"getTimezoneOffset",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.h}});Object.defineProperty(exports,"getTimezoneParts",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.i}});Object.defineProperty(exports,"isValidTimezone",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.j}});Object.defineProperty(exports,"normalizeTimezone",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.k}});Object.defineProperty(exports,"now",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.c}});Object.defineProperty(exports,"nowLocalISO",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.d}});Object.defineProperty(exports,"parseLocalISO",{enumerable:true,get:function(){return chunkZHSHEAQD_cjs.e}});Object.defineProperty(exports,"Lock",{enumerable:true,get:function(){return chunkYC4AEMOP_cjs.a}});Object.defineProperty(exports,"Hono",{enumerable:true,get:function(){return hono.Hono}});Object.defineProperty(exports,"createNodeWebSocket",{enumerable:true,get:function(){return nodeWs.createNodeWebSocket}});Object.defineProperty(exports,"cors",{enumerable:true,get:function(){return cors.cors}});Object.defineProperty(exports,"logger",{enumerable:true,get:function(){return logger.logger}});Object.defineProperty(exports,"compress",{enumerable:true,get:function(){return compress.compress}});Object.defineProperty(exports,"secureHeaders",{enumerable:true,get:function(){return secureHeaders.secureHeaders}});Object.defineProperty(exports,"timeout",{enumerable:true,get:function(){return timeout.timeout}});Object.defineProperty(exports,"HTTPException",{enumerable:true,get:function(){return httpException.HTTPException}});Object.defineProperty(exports,"validator",{enumerable:true,get:function(){return validator.validator}});Object.defineProperty(exports,"zValidator",{enumerable:true,get:function(){return zodValidator.zValidator}});exports.$=$r;exports.AsyncQueue=Nt;exports.NamedError=mt;exports.PkgShell=Pe;exports.abortAfter=Hn;exports.abortAfterAny=Xo;exports.buildCodeSpanIndex=Ke;exports.chunkMarkdownIR=$n;exports.chunkText=be;exports.chunkTextByBreakResolver=wt;exports.convertMarkdownTables=Ze;exports.createInlineCodeState=Xe;exports.createPkgShell=ce;exports.createRESTServer=lt;exports.createRPCServer=at;exports.createServer=ae;exports.createStreamingServer=ut;exports.createWebSocketServer=ct;exports.defer=Zo;exports.detectPlatform=pn;exports.escapeCommandArg=pt;exports.escapeCommandArgSafe=fn;exports.extractFrontmatter=Ve;exports.findFenceSpanAt=Et;exports.findLast=ir;exports.fn=Nr;exports.formatDuration=Qo;exports.formatMarkdown=Ge;exports.getDirectory=zo;exports.getFileExtension=Ho;exports.getFilename=Dn;exports.getFilenameTruncated=Wo;exports.getProxyConfig=rs;exports.getProxyUrl=ns;exports.git=Wr;exports.iife=Xr;exports.isSafeFenceBreak=Nn;exports.joinCommandArgs=me;exports.lazy=Le;exports.lazyAsync=cr;exports.loadEnv=Hr;exports.loadTextFile=Vr;exports.loadTextFileAsync=Jr;exports.markdownToIR=we;exports.markdownToIRWithMeta=Ie;exports.needsShellExecution=un;exports.parseCommand=re;exports.parseCommandWithOptions=dn;exports.parseFenceSpans=Je;exports.parseFrontmatterBlock=Fe;exports.parseModelId=Kr;exports.proxied=ts;exports.readableStreamToText=_r;exports.renderMarkdown=Se;exports.renderMarkdownWithMarkers=Ae;exports.retry=Ot;exports.scanParenAwareBreakpoints=xt;exports.serializeFrontmatter=Ye;exports.shell=gn;exports.signal=ss;exports.startServer=pr;exports.truncateMiddle=Uo;exports.updateSchema=ls;exports.whichSync=Br;exports.withTimeout=is;exports.work=os;
|