@easbot/utils 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +47 -44
- package/dist/index.d.cts +27 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.mjs +47 -44
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,66 +1,69 @@
|
|
|
1
|
-
'use strict';var chunkPJIZPZPO_cjs=require('./chunks/chunk-PJIZPZPO.cjs'),chunk3U5YF6EI_cjs=require('./chunks/chunk-3U5YF6EI.cjs'),chunkEN7LFV4R_cjs=require('./chunks/chunk-EN7LFV4R.cjs'),chunkAUS6KQNI_cjs=require('./chunks/chunk-AUS6KQNI.cjs'),chunkXBAP2B6J_cjs=require('./chunks/chunk-XBAP2B6J.cjs'),
|
|
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
|
|
1
|
+
'use strict';var chunkPJIZPZPO_cjs=require('./chunks/chunk-PJIZPZPO.cjs'),chunk3U5YF6EI_cjs=require('./chunks/chunk-3U5YF6EI.cjs'),chunkEN7LFV4R_cjs=require('./chunks/chunk-EN7LFV4R.cjs'),chunkAUS6KQNI_cjs=require('./chunks/chunk-AUS6KQNI.cjs'),chunkXBAP2B6J_cjs=require('./chunks/chunk-XBAP2B6J.cjs'),Ie=require('fs/promises'),Ee=require('zod'),crypto$1=require('crypto'),dotenv=require('dotenv'),rt=require('path'),fs=require('fs'),xdgBasedir=require('xdg-basedir'),url=require('url'),Qn=require('markdown-it'),Gt=require('yaml'),undici=require('undici'),async_hooks=require('async_hooks'),He=require('readline'),util=require('util'),stream=require('stream'),T=require('picocolors');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Ie__default=/*#__PURE__*/_interopDefault(Ie);var Ee__default=/*#__PURE__*/_interopDefault(Ee);var rt__default=/*#__PURE__*/_interopDefault(rt);var Qn__default=/*#__PURE__*/_interopDefault(Qn);var Gt__default=/*#__PURE__*/_interopDefault(Gt);var He__namespace=/*#__PURE__*/_interopNamespace(He);var T__default=/*#__PURE__*/_interopDefault(T);chunkXBAP2B6J_cjs.e();chunkXBAP2B6J_cjs.e();function Fn(t,e){for(let n=t.length-1;n>=0;n-=1){let r=t[n];if(r!==void 0&&e(r,n,t))return r}}chunkXBAP2B6J_cjs.e();exports.Binary=void 0;(n=>{function t(r,o,a){let c=0,s=r.length-1;for(;c<=s;){let l=Math.floor((c+s)/2),p=r[l];if(p===void 0)break;let u=a(p);if(u===o)return {found:true,index:l};u<o?c=l+1:s=l-1;}return {found:false,index:c}}n.search=t;function e(r,o,a){let c=a(o),s=0,l=r.length;for(;s<l;){let p=Math.floor((s+l)/2),u=r[p];if(u===void 0)break;a(u)<c?s=p+1:l=p;}return r.splice(s,0,o),r}n.insert=e;})(exports.Binary||(exports.Binary={}));chunkXBAP2B6J_cjs.e();exports.Encode=void 0;(a=>{function t(c){let s=new TextEncoder().encode(c),l=Array.from(s,p=>String.fromCharCode(p)).join("");return btoa(l).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}a.base64Encode=t;function e(c){let s=atob(c.replace(/-/g,"+").replace(/_/g,"/")),l=Uint8Array.from(s,p=>p.charCodeAt(0));return new TextDecoder().decode(l)}a.base64Decode=e;async function n(c,s="SHA-256"){let p=new TextEncoder().encode(c),u=await crypto.subtle.digest(s,p);return Array.from(new Uint8Array(u)).map(f=>f.toString(16).padStart(2,"0")).join("")}a.hash=n;function r(c){if(!c)return;let s=2166136261;for(let l=0;l<c.length;l++)s^=c.charCodeAt(l),s=Math.imul(s,16777619);return (s>>>0).toString(36)}a.checksum=r;function o(c,s=5e5){if(!c)return;if(c.length<=s)return r(c);let l=4096,u=[0,Math.floor(c.length*.25),Math.floor(c.length*.5),Math.floor(c.length*.75),c.length-l].map(d=>{let m=Math.max(0,Math.min(c.length-l,d-Math.floor(l/2)));return r(c.slice(m,m+l))??""}).join(":");return `${c.length}:${u}`}a.sampledChecksum=o;})(exports.Encode||(exports.Encode={}));chunkXBAP2B6J_cjs.e();chunkXBAP2B6J_cjs.e();exports.Identifier=void 0;(d=>{let t={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 e(m){return Ee__default.default.string().startsWith(t[m])}d.schema=e;let n=26,r=0,o=0;function a(m,f){return s(m,false,f)}d.ascending=a;function c(m,f){return s(m,true,f)}d.descending=c;function s(m,f,g){if(!g)return p(m,f);if(!g.startsWith(t[m]))throw new Error(`ID ${g} does not start with ${t[m]}`);return g}function l(m){let f="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",g="",S=crypto$1.randomBytes(m);for(let i=0;i<m;i++){let b=S[i];b!==void 0&&(g+=f[b%62]);}return g}function p(m,f,g){let S=g??Date.now();S!==r&&(r=S,o=0),o++;let i=BigInt(S)*BigInt(4096)+BigInt(o);i=f?~i:i;let b=Buffer.alloc(6);for(let P=0;P<6;P++)b[P]=Number(i>>BigInt(40-8*P)&BigInt(255));return t[m]+"_"+b.toString("hex")+l(n-12)}d.create=p;function u(m){let f=m.split("_")[0];if(!f)return 0;let g=m.slice(f.length+1,f.length+13),S=BigInt("0x"+g);return Number(S/BigInt(4096))}d.timestamp=u;})(exports.Identifier||(exports.Identifier={}));exports.TruncateContent=void 0;(p=>{p.DEFAULT_MAX_CHARS=4e3,p.DIRECTION="head",p.DIR=chunkEN7LFV4R_cjs.d.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),p.GLOB=chunkEN7LFV4R_cjs.d.join(p.DIR,"*");let o=10080*60*1e3;function a(u,d,m){return m?`[Content truncated. Source: ${m}
|
|
2
|
+
Full ${d} saved to: ${u}
|
|
3
|
+
Use Read tool with offset/limit parameters to view specific sections.]`:`[Content truncated. Full ${d} saved to: ${u}
|
|
4
|
+
Use Read tool with offset/limit parameters to view specific sections.]`}async function c(u,d={}){let m=d.maxChars??4e3,f=d.direction??p.DIRECTION,g=d.label??"content",S=d.sourcePath,i=chunkEN7LFV4R_cjs.d.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),b=d.dir??i;if(u.length<=m)return {content:u,truncated:false};let P=exports.Identifier.ascending("context"),E=chunkEN7LFV4R_cjs.d.join(b,P);await Ie__default.default.mkdir(b,{recursive:true}).catch(()=>{}),await Ie__default.default.writeFile(E,u,"utf-8");let U=u.length-m,_;f==="head"?_=u.slice(0,m):_=u.slice(-m);let L=a(E,g,S),N=`${U} characters truncated`;return {content:f==="head"?`${_}
|
|
5
5
|
|
|
6
|
-
...${
|
|
6
|
+
...${N}...
|
|
7
7
|
|
|
8
|
-
${
|
|
8
|
+
${L}`:`...${N}...
|
|
9
9
|
|
|
10
|
-
${
|
|
10
|
+
${L}
|
|
11
11
|
|
|
12
|
-
${
|
|
13
|
-
`):e;for(let r=0;r<n.length;r++){let o=n[r];this.parseRule(o,r+1);}return this}parseRule(e,n){let r=e,o=e;if(r.length===0||r.startsWith("#"))return;let
|
|
12
|
+
${_}`,truncated:true,outputPath:E,originalLength:u.length,removedLength:U,label:g}}p.truncate=c;function s(u){return u.truncated?a(u.outputPath,u.label):""}p.formatHint=s;async function l(){let u=exports.Identifier.timestamp(exports.Identifier.create("context",false,Date.now()-o)),m=(await Ie__default.default.readdir(p.DIR).catch(()=>[])).filter(f=>f.startsWith("context_"));for(let f of m)exports.Identifier.timestamp(f)>=u||await Ie__default.default.unlink(chunkEN7LFV4R_cjs.d.join(p.DIR,f)).catch(()=>{});}p.cleanup=l;})(exports.TruncateContent||(exports.TruncateContent={}));chunkXBAP2B6J_cjs.e();exports.SessionTitle=void 0;(s=>{let t="New session - ",e="Child session - ";s.parentTitlePrefix=t,s.childTitlePrefix=e;function o(l=false){return (l?e:t)+chunkAUS6KQNI_cjs.b(new Date)}s.createDefault=o;function a(l){return new RegExp(`^(${t}|${e})\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[+-]\\d{2}:\\d{2}$`).test(l)}s.isDefault=a;function c(l){let p=l.match(/^(.+) \(fork #(\d+)\)$/);if(p){let u=p[1]??"",d=parseInt(p[2]??"0",10);return `${u} (fork #${d+1})`}return `${l} (fork #1)`}s.getForked=c;})(exports.SessionTitle||(exports.SessionTitle={}));chunkXBAP2B6J_cjs.e();var xe=class xe extends Error{static create(e,n){var a;let r=Ee__default.default.object({name:Ee__default.default.literal(e),data:n}).meta({ref:e}),o=(a=class extends xe{constructor(s,l){super(e,l);chunkXBAP2B6J_cjs.c(this,"data",s);chunkXBAP2B6J_cjs.c(this,"name",e);this.name=e;}static isInstance(s){return s!==null&&typeof s=="object"&&"name"in s&&s.name===e}schema(){return r}toObject(){return {name:e,data:this.data}}},chunkXBAP2B6J_cjs.c(a,"Schema",r),a);return Object.defineProperty(o,"name",{value:e}),o}};chunkXBAP2B6J_cjs.c(xe,"Unknown",xe.create("UnknownError",Ee__default.default.object({message:Ee__default.default.string()})));var Qe=xe;chunkXBAP2B6J_cjs.e();exports.Ignore=void 0;(e=>{function t(n){return new tt(n)}e.create=t;})(exports.Ignore||(exports.Ignore={}));var tt=class{constructor(e){chunkXBAP2B6J_cjs.c(this,"rules",[]);chunkXBAP2B6J_cjs.c(this,"ignorecase");chunkXBAP2B6J_cjs.c(this,"debug");this.ignorecase=e?.ignorecase??false,this.debug=e?.debug??false;}add(e){let n=typeof e=="string"?e.split(`
|
|
13
|
+
`):e;for(let r=0;r<n.length;r++){let o=n[r];this.parseRule(o,r+1);}return this}parseRule(e,n){let r=e,o=e;if(r.length===0||r.startsWith("#"))return;let a=r.startsWith("!");if(a&&(r=r.slice(1)),r=r.trim(),r.length===0||(r.startsWith("\\#")&&(r=r.slice(1)),r.startsWith("#")))return;let c=r.startsWith("/");c&&(r=r.slice(1));let s=r.endsWith("/");s&&(r=r.slice(0,-1)),r.length!==0&&this.rules.push({pattern:r,negative:a,isDirectory:s,anchored:c,original:o,lineNumber:n});}ignores(e,n){let r=this.normalizePath(e),o=n??e.endsWith("/"),a=this.checkIgnore(r,o);return this.debug&&console.log(`Ignore.ignores("${e}", isDirectory=${o}) => ${a}`),a}checkIgnore(e,n){let r=false;for(let o of this.rules)o.isDirectory&&!n||this.matchPath(o,e)&&(o.negative?r=false:r=true);return r}matchPath(e,n){let r=this.ignorecase?n.toLowerCase():n,a=this.ignorecase?e.pattern.toLowerCase():e.pattern;if(e.anchored)return chunkEN7LFV4R_cjs.a.match(r,a);if(a.includes("/"))return chunkEN7LFV4R_cjs.a.match(r,a);let c=r.split("/");for(let s of c)if(chunkEN7LFV4R_cjs.a.match(s,a))return true;return false}filter(e){return e.filter(n=>!this.ignores(n))}createFilter(){return e=>!this.ignores(e)}normalizePath(e){let n=e.replace(/\\/g,"/");if(n==="/")return "";for(;n.startsWith("./");)n=n.slice(2);return n.endsWith("/")&&n.length>1&&(n=n.slice(0,-1)),n}};chunkXBAP2B6J_cjs.e();function Ot(t,e){let n=r=>{let o;try{o=t.parse(r);}catch(a){throw console.trace("schema validation failure stack trace:"),a instanceof Ee.z.ZodError&&console.error("schema validation issues:",JSON.stringify(a.issues,null,2)),a}return e(o)};return n.force=r=>e(r),n.schema=t,n}var An=Ot;exports.Fn=void 0;(e=>e.fn=Ot)(exports.Fn||(exports.Fn={}));chunkXBAP2B6J_cjs.e();function Nn(t={}){let e=t.isDevelopment??false,n=e?".env.dev":".env",r=t.globalConfigPath??(xdgBasedir.xdgConfig?rt__default.default.join(xdgBasedir.xdgConfig,"easbot"):void 0),o=t.projectRoot??process.cwd(),a=o?rt__default.default.join(o,".easbot"):void 0,c=[{root:r,label:"global"},{root:o,label:"project"},{root:a,label:"workspace"}];for(let{root:s}of c){if(!s)continue;let l=rt__default.default.join(s,n);if(!fs.existsSync(l))continue;let p=dotenv.config({path:l,override:true,debug:e,encoding:"utf-8",quiet:!e});if(e&&p.parsed){let d=["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(m=>m in p.parsed);d.length>0&&console.warn(`[loadEnv] ${l} contains keys that have no effect: ${d.join(", ")}.
|
|
14
14
|
Reason: xdg-basedir caches XDG_* on import, so this .env file loads too late.
|
|
15
|
-
How to override: export them in the shell before loadEnv() runs, or set process.env directly.`);}}}chunkXBAP2B6J_cjs.e();async function
|
|
16
|
-
`?o=s:/\s/.test(l)&&(
|
|
15
|
+
How to override: export them in the shell before loadEnv() runs, or set process.env directly.`);}}}chunkXBAP2B6J_cjs.e();async function zn(t,e){if(process.env.EASBOT_CLIENT==="acp")try{let a=process.platform==="win32"?"cmd":void 0,c=chunk3U5YF6EI_cjs.G.spawn(a,`git ${t.join(" ")}`,{stdin:void 0,stdout:"pipe",stderr:"pipe",cwd:e.cwd,env:e.env?{...process.env,...e.env}:process.env}),[s,l,p]=await Promise.all([c.exited,new Response(c.stdout).arrayBuffer(),new Response(c.stderr).arrayBuffer()]),u=Buffer.from(l),d=Buffer.from(p);return {exitCode:s,text:()=>u.toString(),stdout:u,stderr:d}}catch(a){let c=Buffer.from(a instanceof Error?a.message:String(a));return {exitCode:1,text:()=>"",stdout:Buffer.alloc(0),stderr:c}}let n=e.env?{...process.env,...e.env}:void 0,r=chunk3U5YF6EI_cjs.G.$`git ${t.join(" ")}`.quiet().nothrow().cwd(e.cwd);n&&(r=r.env(n));let o=await r;return {exitCode:o.exitCode,text:()=>o.text(),stdout:o.stdout,stderr:o.stderr}}chunkXBAP2B6J_cjs.e();function Ct(t){return t?rt.dirname(url.fileURLToPath(t)):typeof __dirname<"u"?__dirname:process.cwd()}function Ft(t,e,n=3){function r(o,a){if(a>n||!fs.existsSync(o))return null;try{let c=fs.readdirSync(o);for(let s of c){let l=rt.join(o,s);try{let p=fs.statSync(l);if(p.isFile()&&l.endsWith(e))return l;if(p.isDirectory()&&a<n){let u=r(l,a+1);if(u)return u}}catch{}}}catch{}return null}return r(t,0)}function _t(t,e){let n=rt.join(t,e);if(fs.existsSync(n))return n;let r=e.split("/").pop()||e,o=t;for(let a=0;a<5;a++){let c=rt.join(o,"assets","txt");if(fs.existsSync(c)){let p=Ft(c,r,5);if(p)return p}let s=rt.join(o,"dist","assets","txt");if(fs.existsSync(s)){let p=Ft(s,r,5);if(p)return p}let l=rt.join(o,"..");if(l===o)break;o=l;}return n}function Un(t,e){return chunk3U5YF6EI_cjs.c.lazy(()=>{try{let n=Ct(e),r=_t(n,t);return chunk3U5YF6EI_cjs.D.file(r).textSync()}catch(n){throw console.error(`Failed to load text file: ${t}`,n),n}})}function qn(t,e){return chunk3U5YF6EI_cjs.c.lazy(async()=>{try{let n=Ct(e),r=_t(n,t);return await chunk3U5YF6EI_cjs.D.file(r).text()}catch(n){throw console.error(`Failed to load text file: ${t}`,n),n}})}chunkXBAP2B6J_cjs.e();function Gn(t){return t()}chunkXBAP2B6J_cjs.e();function Yn(t){if(!t||typeof t!="string")return {provider:"",model:""};let e=t.indexOf("/");return e===-1?{provider:"",model:t}:{provider:t.substring(0,e),model:t.substring(e+1)}}chunkXBAP2B6J_cjs.e();chunkXBAP2B6J_cjs.e();chunkXBAP2B6J_cjs.e();function ot(t,e,n,r=()=>true){let o=-1,a=-1,c=0;for(let s=e;s<n;s++){if(!r(s))continue;let l=t[s];if(l){if(l==="("){c+=1;continue}if(l===")"&&c>0){c-=1;continue}c===0&&(l===`
|
|
16
|
+
`?o=s:/\s/.test(l)&&(a=s));}}return {lastNewline:o,lastWhitespace:a}}function Vn(t,e){if(!t)return [];if(e<=0)return [t];if(t.length<=e)return [t]}function ae(t,e,n){try{let r=Ee.z.string().parse(t),o=Ee.z.number().int().parse(e),a=Vn(r,o);if(a)return a;let c=st(r,o,s=>{let{lastNewline:l,lastWhitespace:p}=ot(s,0,s.length);return l>0?l:p});return n?.minLength&&n.minLength>0&&(c=At(c,n.minLength)),c}catch(r){return console.warn("Invalid input for chunkText:",r),typeof t=="string"&&t.length>0?[t]:[]}}function At(t,e){if(t.length<=1||e<=0)return t;let n=[],r=t[0]??"";for(let o=1;o<t.length;o++){let a=t[o]??"";r.length<e?r=r+`
|
|
17
17
|
|
|
18
|
-
`+
|
|
18
|
+
`+a:(n.push(r),r=a);}if(r.length>0)if(r.length<e&&n.length>0){let o=n.pop();n.push(o+`
|
|
19
19
|
|
|
20
|
-
`+r);}else n.push(r);return n}function
|
|
20
|
+
`+r);}else n.push(r);return n}function st(t,e,n){if(!t)return [];if(e<=0||t.length<=e)return [t];let r=[],o=t;for(;o.length>e;){let a=o.slice(0,e),c=n(a),s=Number.isFinite(c)&&c>0&&c<=e?c:e,p=o.slice(0,s).trimEnd();p.length>0&&r.push(p);let u=s<o.length&&o[s]!==void 0&&/\s/.test(o[s]),d=Math.min(o.length,s+(u?1:0));o=o.slice(d).trimStart();}return o.length>0&&r.push(o),r}chunkXBAP2B6J_cjs.e();var it=Ee.z.enum(["bold","italic","strikethrough","code","code_block","spoiler","blockquote"]),$t=Ee.z.object({start:Ee.z.number().int().min(0),end:Ee.z.number().int().min(0),style:it}).strict().refine(t=>t.end>=t.start,{message:"end must be greater than or equal to start"}),Dt=Ee.z.object({start:Ee.z.number().int().min(0),end:Ee.z.number().int().min(0),href:Ee.z.string().min(1)}).strict().refine(t=>t.end>=t.start,{message:"end must be greater than or equal to start"}),ke=Ee.z.object({text:Ee.z.string(),styles:Ee.z.array($t),links:Ee.z.array(Dt)}).strict(),we=Ee.z.enum(["off","bullets","code"]),Ce=Ee.z.object({linkify:Ee.z.boolean().default(true),enableSpoilers:Ee.z.boolean().default(false),headingStyle:Ee.z.enum(["none","bold"]).default("none"),blockquotePrefix:Ee.z.string().default(""),autolink:Ee.z.boolean().default(true),tableMode:we.default("off")}).partial().default({}),Nt=Ee.z.object({open:Ee.z.string(),close:Ee.z.string()}).strict(),at=Ee.z.object({styleMarkers:Ee.z.record(it,Nt).optional(),escapeText:Ee.z.any().optional(),buildLink:Ee.z.any().optional()}).strict();Ee.z.object({start:Ee.z.number().int().min(0),end:Ee.z.number().int().min(0),open:Ee.z.string(),close:Ee.z.string()}).strict();var ct=Ee.z.object({indentSize:Ee.z.number().int().min(1).default(2),listMarker:Ee.z.enum(["\u2022","-","*"]).default("\u2022"),codeBlockMarker:Ee.z.enum(["```","~~~"]).default("```"),preserveFrontmatter:Ee.z.boolean().default(true)}).strict(),lt=Ee.z.record(Ee.z.string(),Ee.z.string()),_e=Ee.z.object({open:Ee.z.boolean(),ticks:Ee.z.number().int().min(0)}).strict();Ee.z.object({inlineState:_e,isInside:Ee.z.any()}).strict();Ee.z.object({start:Ee.z.number().int().min(0),end:Ee.z.number().int().min(0),openLine:Ee.z.string(),marker:Ee.z.string(),indent:Ee.z.string()}).strict();Ee.z.object({tables:we.optional()}).strict();function er(t){let e=new Qn__default.default({html:false,linkify:t.linkify??true,breaks:false,typographer:false});return e.enable("strikethrough"),t.tableMode&&t.tableMode!=="off"?e.enable("table"):e.disable("table"),t.autolink===false&&e.disable("autolink"),e}function zt(t,e){if(t.attrGet)return t.attrGet(e);if(t.attrs){for(let[n,r]of t.attrs)if(n===e)return r}return null}function ut(t,e){return {...t,type:"text",content:e,children:void 0}}function tr(t){for(let e of t)e.children&&e.children.length>0&&(e.children=nr(e.children));}function nr(t){let e=0;for(let c of t){if(c.type!=="text")continue;let s=c.content??"",l=0;for(;l<s.length;){let p=s.indexOf("||",l);if(p===-1)break;e+=1,l=p+2;}}if(e<2)return t;let n=e-e%2,r=[],o={spoilerOpen:false},a=0;for(let c of t){if(c.type!=="text"){r.push(c);continue}let s=c.content??"";if(!s.includes("||")){r.push(c);continue}let l=0;for(;l<s.length;){let p=s.indexOf("||",l);if(p===-1){l<s.length&&r.push(ut(c,s.slice(l)));break}if(a>=n){r.push(ut(c,s.slice(l)));break}p>l&&r.push(ut(c,s.slice(l,p))),a+=1,o.spoilerOpen=!o.spoilerOpen,r.push({type:o.spoilerOpen?"spoiler_open":"spoiler_close"}),l=p+2;}}return r}function rr(){return {text:"",styles:[],openStyles:[],links:[],linkStack:[]}}function se(t){return t.table?.currentCell??t}function Le(t,e){if(!e)return;let n=se(t);n.text+=e;}function ce(t,e){let n=se(t);n.openStyles.push({style:e,start:n.text.length});}function le(t,e){let n=se(t);for(let r=n.openStyles.length-1;r>=0;r-=1){let o=n.openStyles[r];if(o?.style===e){let a=o.start;n.openStyles.splice(r,1);let c=n.text.length;c>a&&n.styles.push({start:a,end:c,style:e});return}}}function Bt(t){t.env.listStack.length>0||t.table||(t.text+=`
|
|
21
21
|
|
|
22
|
-
`);}function
|
|
23
|
-
`);}function
|
|
24
|
-
`;}for(let
|
|
25
|
-
`;}else for(let o of n){for(let
|
|
26
|
-
`;}}function
|
|
27
|
-
`;},l=()=>{t.text+="|";for(let
|
|
28
|
-
`;};s(e),l();for(let
|
|
29
|
-
`);break;case "paragraph_close":
|
|
22
|
+
`);}function or(t){let e=t.env.listStack,n=e[e.length-1];if(!n)return;n.index+=1;let r=" ".repeat(Math.max(0,e.length-1)),o=n.type==="ordered"?`${n.index}. `:"\u2022 ";t.text+=`${r}${o}`;}function sr(t,e){if(!e)return;let n=se(t),r=n.text.length;n.text+=e,n.styles.push({start:r,end:r+e.length,style:"code"});}function ir(t,e){let n=e??"",r=se(t),o=r.text.length;r.text+=n,r.styles.push({start:o,end:o+n.length,style:"code_block"});}function ar(t){let e=se(t),n=e.linkStack.pop();if(!n?.href)return;let r=n.href.trim();if(!r)return;let o=n.labelStart,a=e.text.length;if(a<=o){e.links.push({start:o,end:a,href:r});return}e.links.push({start:o,end:a,href:r});}function cr(){return {headers:[],rows:[],currentRow:[],currentCell:null,inHeader:false}}function lr(t){return Wt(t),{text:t.text,styles:t.styles,links:t.links}}function Ae(t){let e=t.text,n=0,r=e.length;for(;n<r&&/\s/.test(e[n]??"");)n+=1;for(;r>n&&/\s/.test(e[r-1]??"");)r-=1;if(n===0&&r===e.length)return t;let o=e.slice(n,r),a=o.length,c=[];for(let l of t.styles){let p=Math.max(0,l.start-n),u=Math.min(a,l.end-n);u>p&&c.push({start:p,end:u,style:l.style});}let s=[];for(let l of t.links){let p=Math.max(0,l.start-n),u=Math.min(a,l.end-n);u>p&&s.push({start:p,end:u,href:l.href});}return {text:o,styles:c,links:s}}function dt(t,e){if(!e.text)return;let n=t.text.length;t.text+=e.text;for(let r of e.styles)t.styles.push({start:n+r.start,end:n+r.end,style:r.style});for(let r of e.links)t.links.push({start:n+r.start,end:n+r.end,href:r.href});}function ur(t,e){e.text&&(t.text+=e.text);}function jt(t,e){let{header:n,value:r,columnIndex:o,includeColumnFallback:a}=e;r?.text&&(t.text+="\u2022 ",n?.text?(dt(t,n),t.text+=": "):a&&(t.text+=`Column ${o}: `),dt(t,r),t.text+=`
|
|
23
|
+
`);}function dr(t){if(!t.table)return;let e=t.table.headers.map(Ae),n=t.table.rows.map(o=>o.map(Ae));if(e.length===0&&n.length===0)return;if(e.length>1&&n.length>0)for(let o of n){if(o.length===0)continue;let a=o[0];if(a?.text){let c=t.text.length;dt(t,a);let s=t.text.length;s>c&&t.styles.push({start:c,end:s,style:"bold"}),t.text+=`
|
|
24
|
+
`;}for(let c=1;c<o.length;c++)jt(t,{header:e[c],value:o[c],columnIndex:c,includeColumnFallback:true});t.text+=`
|
|
25
|
+
`;}else for(let o of n){for(let a=0;a<o.length;a++)jt(t,{header:e[a],value:o[a],columnIndex:a,includeColumnFallback:false});t.text+=`
|
|
26
|
+
`;}}function fr(t){if(!t.table)return;let e=t.table.headers.map(Ae),n=t.table.rows.map(u=>u.map(Ae)),r=Math.max(e.length,...n.map(u=>u.length));if(r===0)return;let o=Array.from({length:r},()=>0),a=u=>{for(let d=0;d<r;d+=1){let f=u[d]?.text.length??0;(o[d]??0)<f&&(o[d]=f);}};a(e);for(let u of n)a(u);let c=t.text.length,s=u=>{t.text+="|";for(let d=0;d<r;d+=1){t.text+=" ";let m=u[d];m&&ur(t,m);let f=m?.text.length??0,S=(o[d]??0)-f;S>0&&(t.text+=" ".repeat(S)),t.text+=" |";}t.text+=`
|
|
27
|
+
`;},l=()=>{t.text+="|";for(let u=0;u<r;u+=1){let d=o[u]??0,m=Math.max(3,d);t.text+=` ${"-".repeat(m)} |`;}t.text+=`
|
|
28
|
+
`;};s(e),l();for(let u of n)s(u);let p=t.text.length;p>c&&t.styles.push({start:c,end:p,style:"code_block"});}function ft(t,e){for(let n of t)switch(n.type){case "inline":n.children&&ft(n.children,e);break;case "text":Le(e,n.content??"");break;case "em_open":ce(e,"italic");break;case "em_close":le(e,"italic");break;case "strong_open":ce(e,"bold");break;case "strong_close":le(e,"bold");break;case "s_open":ce(e,"strikethrough");break;case "s_close":le(e,"strikethrough");break;case "code_inline":sr(e,n.content??"");break;case "spoiler_open":e.enableSpoilers&&ce(e,"spoiler");break;case "spoiler_close":e.enableSpoilers&&le(e,"spoiler");break;case "link_open":{let r=zt(n,"href")??"",o=se(e);o.linkStack.push({href:r,labelStart:o.text.length});break}case "link_close":ar(e);break;case "image":Le(e,n.content??"");break;case "softbreak":case "hardbreak":Le(e,`
|
|
29
|
+
`);break;case "paragraph_close":Bt(e);break;case "heading_open":e.headingStyle==="bold"&&ce(e,"bold");break;case "heading_close":e.headingStyle==="bold"&&le(e,"bold"),Bt(e);break;case "blockquote_open":e.blockquotePrefix&&(e.text+=e.blockquotePrefix),ce(e,"blockquote");break;case "blockquote_close":le(e,"blockquote");break;case "bullet_list_open":e.env.listStack.length>0&&(e.text+=`
|
|
30
30
|
`),e.env.listStack.push({type:"bullet",index:0});break;case "bullet_list_close":e.env.listStack.pop(),e.env.listStack.length===0&&(e.text+=`
|
|
31
31
|
`);break;case "ordered_list_open":{e.env.listStack.length>0&&(e.text+=`
|
|
32
|
-
`);let r=Number(
|
|
33
|
-
`);break;case "list_item_open":
|
|
32
|
+
`);let r=Number(zt(n,"start")??"1");e.env.listStack.push({type:"ordered",index:r-1});break}case "ordered_list_close":e.env.listStack.pop(),e.env.listStack.length===0&&(e.text+=`
|
|
33
|
+
`);break;case "list_item_open":or(e);break;case "list_item_close":e.text.endsWith(`
|
|
34
34
|
`)||(e.text+=`
|
|
35
|
-
`);break;case "code_block":case "fence":
|
|
35
|
+
`);break;case "code_block":case "fence":ir(e,n.content??"");break;case "html_block":case "html_inline":Le(e,n.content??"");break;case "table_open":e.tableMode!=="off"&&(e.table=cr(),e.hasTables=true);break;case "table_close":e.table&&(e.tableMode==="bullets"?dr(e):e.tableMode==="code"&&fr(e)),e.table=null;break;case "thead_open":e.table&&(e.table.inHeader=true);break;case "thead_close":e.table&&(e.table.inHeader=false);break;case "tbody_open":case "tbody_close":break;case "tr_open":e.table&&(e.table.currentRow=[]);break;case "tr_close":e.table&&(e.table.inHeader?e.table.headers=e.table.currentRow:e.table.rows.push(e.table.currentRow),e.table.currentRow=[]);break;case "th_open":case "td_open":e.table&&(e.table.currentCell=rr());break;case "th_close":case "td_close":e.table?.currentCell&&(e.table.currentRow.push(lr(e.table.currentCell)),e.table.currentCell=null);break;case "hr":e.text+=`\u2500\u2500\u2500
|
|
36
36
|
|
|
37
|
-
`;break;default:n.children&&
|
|
38
|
-
`);let
|
|
37
|
+
`;break;default:n.children&&ft(n.children,e);break}}function Wt(t){for(let e=t.openStyles.length-1;e>=0;e-=1){let n=t.openStyles[e];if(!n)continue;let r=t.text.length;r>n.start&&t.styles.push({start:n.start,end:r,style:n.style});}t.openStyles=[];}function pr(t,e){let n=[];for(let r of t){let o=Math.max(0,Math.min(r.start,e)),a=Math.max(o,Math.min(r.end,e));a>o&&n.push({start:o,end:a,style:r.style});}return n}function mr(t,e){let n=[];for(let r of t){let o=Math.max(0,Math.min(r.start,e)),a=Math.max(o,Math.min(r.end,e));a>o&&n.push({start:o,end:a,href:r.href});}return n}function Ht(t){let e=[...t].toSorted((r,o)=>r.start!==o.start?r.start-o.start:r.end!==o.end?r.end-o.end:r.style.localeCompare(o.style)),n=[];for(let r of e){let o=n[n.length-1];if(o&&o.style===r.style&&(r.start<o.end||r.start===o.end&&r.style!=="blockquote")){o.end=Math.max(o.end,r.end);continue}n.push({...r});}return n}function Ut(t,e,n){let r=Math.max(t.start,e),o=Math.min(t.end,n);return o<=r?null:{start:r,end:o}}function hr(t,e,n){if(t.length===0)return [];let r=[];for(let o of t){let a=Ut(o,e,n);a&&r.push({start:a.start-e,end:a.end-e,style:o.style});}return Ht(r)}function gr(t,e,n){if(t.length===0)return [];let r=[];for(let o of t){let a=Ut(o,e,n);a&&r.push({start:a.start-e,end:a.end-e,href:o.href});}return r}function ue(t,e){try{let n=typeof t=="string"?t:"",r=Ce.parse(e??{});return Se(n,r).ir}catch(n){return console.error("Markdown parse error:",n),{text:"",styles:[],links:[]}}}function Se(t,e){try{let n=typeof t=="string"?t:"",r=Ce.parse(e),o={listStack:[]},c=er(r).parse(n||"",o);r.enableSpoilers&&tr(c);let s=r.tableMode??"off",l={text:"",styles:[],openStyles:[],links:[],linkStack:[],env:o,headingStyle:r.headingStyle??"none",blockquotePrefix:r.blockquotePrefix??"",enableSpoilers:r.enableSpoilers??!1,tableMode:s,table:null,hasTables:!1};ft(c,l),Wt(l);let u=l.text.trimEnd().length,d=0;for(let g of l.styles)g.style==="code_block"&&g.end>d&&(d=g.end);let m=Math.max(u,d);return {ir:{text:m===l.text.length?l.text:l.text.slice(0,m),styles:Ht(pr(l.styles,m)),links:mr(l.links,m)},hasTables:l.hasTables}}catch(n){return console.error("Markdown parse error:",n),{ir:{text:"",styles:[],links:[]},hasTables:false}}}function qt(t,e){try{let n=ke.parse(t),r=typeof e=="number"&&e>0?e:0;if(!n.text)return [];if(r<=0||n.text.length<=r)return [n];let o=ae(n.text,r),a=[],c=0;return o.forEach((s,l)=>{if(!s)return;if(l>0)for(;c<n.text.length&&/\s/.test(n.text[c]??"");)c+=1;let p=c,u=Math.min(n.text.length,p+s.length);a.push({text:s,styles:hr(n.styles,p,u),links:gr(n.links,p,u)}),c=u;}),a}catch(n){return console.error("Chunk IR error:",n),[]}}chunkXBAP2B6J_cjs.e();var br={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function Te(t,e){try{let n=ke.parse(t),r=at.parse(e??{});if(!n.text)return "";let o=r.styleMarkers??br,a=r.escapeText??(d=>d),c=r.buildLink,s=[];for(let d=0;d<n.styles.length;d++){let m=n.styles[d];m&&(s.push({position:m.start,type:"open",style:m.style,spanIndex:d}),s.push({position:m.end,type:"close",style:m.style,spanIndex:d}));}for(let d=0;d<n.links.length;d++){let m=n.links[d];m&&(s.push({position:m.start,type:"link_open",spanIndex:d,href:m.href}),s.push({position:m.end,type:"link_close",spanIndex:d,href:m.href}));}s.sort((d,m)=>{if(d.position!==m.position)return d.position-m.position;let f=(P,E)=>P==="link_open"?0:P==="open"?1:P==="close"?2:P==="link_close"?3:4,g=d.type==="close"||d.type==="link_close",S=m.type==="close"||m.type==="link_close",i=f(d.type,g),b=f(m.type,S);return i!==b?i-b:d.type==="open"&&m.type==="open"?d.spanIndex-m.spanIndex:d.type==="close"&&m.type==="close"?m.spanIndex-d.spanIndex:d.spanIndex-m.spanIndex});let l="",p=0,u=[];for(let d of s){if(d.position>p){let m=n.text.slice(p,d.position);l+=a?a(m):m;}if(d.type==="open"||d.type==="close"){let m=o[d.style];if(m)if(d.type==="open")l+=m.open,u.push(d);else {l+=m.close,d.style==="code_block"&&d.position<n.text.length&&(l+=`
|
|
38
|
+
`);let f=u.findIndex(g=>g.spanIndex===d.spanIndex&&g.type==="open");f!==-1&&u.splice(f,1);}}else if(d.type==="link_open")l+="[",u.push(d);else if(d.type==="link_close"){l+="]("+d.href+")";let m=u.findIndex(f=>f.spanIndex===d.spanIndex&&f.type==="link_open");m!==-1&&u.splice(m,1);}p=d.position;}if(p<n.text.length){let d=n.text.slice(p);l+=a?a(d):d;}return l}catch(n){return console.error("Markdown render error:",n),""}}function de(t,e){return Te(t,e)}chunkXBAP2B6J_cjs.e();function xr(t){let e=t.replace(/\r\n/g,`
|
|
39
39
|
`).replace(/\r/g,`
|
|
40
40
|
`);if(!e.startsWith("---"))return {frontmatter:"",content:t};let n=e.indexOf(`
|
|
41
|
-
---`,3);if(n===-1)return {frontmatter:"",content:t};let r=e.slice(0,n+4),o=e.slice(n+4).trimStart();return {frontmatter:r,content:o}}function
|
|
41
|
+
---`,3);if(n===-1)return {frontmatter:"",content:t};let r=e.slice(0,n+4),o=e.slice(n+4).trimStart();return {frontmatter:r,content:o}}function $e(t,e){try{let n=typeof t=="string"?t:"",r=ct.parse(e??{});if(!n)return "";let{frontmatter:o,content:a}=xr(n),c=ue(a,{linkify:!0,enableSpoilers:!1,autolink:!0,headingStyle:"none",blockquotePrefix:"",tableMode:"off"}),s=de(c);return s=s.replace(/\n{3,}/g,`
|
|
42
42
|
|
|
43
43
|
`),s=s.trimEnd()+`
|
|
44
44
|
`,r.preserveFrontmatter&&o&&(s=o+`
|
|
45
|
-
`+s),s}catch(n){return console.error("Markdown format error:",n),t}}chunkXBAP2B6J_cjs.e();function
|
|
46
|
-
`).trim(),linesConsumed:r-e}}function
|
|
47
|
-
`),r=0;for(;r<n.length;){let o=n[r];if(!o){r+=1;continue}let
|
|
45
|
+
`+s),s}catch(n){return console.error("Markdown format error:",n),t}}chunkXBAP2B6J_cjs.e();function yr(t){return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function kr(t){if(t!=null){if(typeof t=="string")return {value:t.trim(),kind:"scalar"};if(typeof t=="number"||typeof t=="boolean")return {value:String(t),kind:"scalar"};if(typeof t=="object")try{return {value:JSON.stringify(t),kind:"structured"}}catch{return}}}function wr(t){try{let e=Gt__default.default.parse(t,{schema:"core"});if(!e||typeof e!="object"||Array.isArray(e))return null;let n={};for(let[r,o]of Object.entries(e)){let a=r.trim();if(!a)continue;let c=kr(o);c&&(n[a]=c);}return n}catch{return null}}function Sr(t,e){let n=[],r=e+1;for(;r<t.length;){let a=t[r];if(!a){r+=1;continue}if(a.length>0&&!a.startsWith(" ")&&!a.startsWith(" "))break;n.push(a),r+=1;}return {value:n.join(`
|
|
46
|
+
`).trim(),linesConsumed:r-e}}function Tr(t){let e={},n=t.split(`
|
|
47
|
+
`),r=0;for(;r<n.length;){let o=n[r];if(!o){r+=1;continue}let a=o.match(/^([\w-]+):\s*(.*)$/);if(!a?.[1]||!a[2]){r+=1;continue}let c=a[1],s=a[2].trim();if(!c){r+=1;continue}if(!s&&r+1<n.length){let p=n[r+1];if(p&&(p.startsWith(" ")||p.startsWith(" "))){let{value:u,linesConsumed:d}=Sr(n,r);u&&(e[c]={value:u,kind:"multiline",rawInline:s}),r+=d;continue}}let l=yr(s);l&&(e[c]={value:l,kind:"inline",rawInline:s}),r+=1;}return e}function Mr(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.value;return e}function Ir(t){return /^[|>][+-]?(\d+)?[+-]?$/.test(t)}function vr(t){let{lineEntry:e,yamlValue:n}=t;return n.kind!=="structured"||e.kind!=="inline"||Ir(e.rawInline)?false:e.value.includes(":")}function Rr(t){let e=t.replace(/\r\n/g,`
|
|
48
48
|
`).replace(/\r/g,`
|
|
49
49
|
`);if(!e.startsWith("---"))return;let n=e.indexOf(`
|
|
50
|
-
---`,3);if(n!==-1)return e.slice(4,n)}function
|
|
51
|
-
${
|
|
52
|
-
---`}catch(e){return console.warn("Failed to serialize frontmatter:",e),""}}function
|
|
50
|
+
---`,3);if(n!==-1)return e.slice(4,n)}function Me(t){try{if(typeof t!="string")return {};let e=Rr(t);if(!e)return {};let n=Tr(e),r=wr(e);if(r===null)return Mr(n);let o={};for(let[a,c]of Object.entries(r)){o[a]=c.value;let s=n[a];s&&vr({lineEntry:s,yamlValue:c})&&(o[a]=s.value);}for(let[a,c]of Object.entries(n))a in o||(o[a]=c.value);return o}catch(e){return console.warn("Failed to parse frontmatter:",e),{}}}function De(t){try{let e=lt.parse(t);if(Object.keys(e).length===0)return "";let n={};for(let[o,a]of Object.entries(e))try{let c=JSON.parse(a);n[o]=c;}catch{n[o]=a;}return `---
|
|
51
|
+
${Gt__default.default.stringify(n,{lineWidth:0,defaultStringType:"QUOTE_DOUBLE"}).trim()}
|
|
52
|
+
---`}catch(e){return console.warn("Failed to serialize frontmatter:",e),""}}function Ne(t){try{if(typeof t!="string")return {frontmatter:{},content:""};let e=t.replace(/\r\n/g,`
|
|
53
53
|
`).replace(/\r/g,`
|
|
54
54
|
`);if(!e.startsWith("---"))return {frontmatter:{},content:t};let n=e.indexOf(`
|
|
55
|
-
---`,3);if(n===-1)return {frontmatter:{},content:t};let r=e.slice(4,n),o=e.slice(n+4).trimStart();return {frontmatter:
|
|
56
|
-
`,o),a
|
|
57
|
-
Content-Type: ${
|
|
55
|
+
---`,3);if(n===-1)return {frontmatter:{},content:t};let r=e.slice(4,n),o=e.slice(n+4).trimStart();return {frontmatter:Me(t),content:o}}catch(e){return console.warn("Failed to extract frontmatter:",e),{frontmatter:{},content:t}}}chunkXBAP2B6J_cjs.e();chunkXBAP2B6J_cjs.e();function ze(t){try{let e=Ee.z.string().parse(t),n=[],r,o=0;for(;o<=e.length;){let a=e.indexOf(`
|
|
56
|
+
`,o),c=a===-1?e.length:a,s=e.slice(o,c),l=s.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(l){let p=l[1],u=l[2];if(!p||!u){o=c+1;continue}let d=u[0];if(!d){o=c+1;continue}let m=u.length;if(!r)r={start:o,markerChar:d,markerLen:m,openLine:s,marker:u,indent:p};else if(r.markerChar===d&&m>=r.markerLen){let f=c;n.push({start:r.start,end:f,openLine:r.openLine,marker:r.marker,indent:r.indent}),r=void 0;}}if(a===-1)break;o=a+1;}return r&&n.push({start:r.start,end:e.length,openLine:r.openLine,marker:r.marker,indent:r.indent}),n}catch(e){return console.warn("Invalid input for parseFenceSpans:",e),[]}}function pt(t,e){let n=0,r=t.length-1;for(;n<=r;){let o=Math.floor((n+r)/2),a=t[o];if(!a)break;if(e<=a.start){r=o-1;continue}if(e>=a.end){n=o+1;continue}return a}}function Yt(t,e){return !pt(t,e)}function Be(){return {open:false,ticks:0}}function je(t,e){try{let n=Ee.z.string().parse(t),r=e?_e.parse(e):Be(),o=ze(n),a={open:r.open,ticks:r.ticks},{spans:c,state:s}=Er(n,o,a);return {inlineState:s,isInside:l=>Cr(l,o)||_r(l,c)}}catch(n){return console.warn("Invalid input for buildCodeSpanIndex:",n),{inlineState:Be(),isInside:()=>false}}}function Er(t,e,n){let r=[],o=n.open,a=n.ticks,c=o?0:-1,s=0;for(;s<t.length;){let l=Fr(e,s);if(l){s=l.end;continue}if(t[s]!=="`"){s+=1;continue}let p=s,u=0;for(;s<t.length&&t[s]==="`";)u+=1,s+=1;if(!o){o=true,a=u,c=p;continue}u===a&&(r.push([c,s]),o=false,a=0,c=-1);}return o&&r.push([c,t.length]),{spans:r,state:{open:o,ticks:a}}}function Fr(t,e){return t.find(n=>e>=n.start&&e<n.end)}function Cr(t,e){return e.some(n=>t>=n.start&&t<n.end)}function _r(t,e){return e.some(([n,r])=>t>=n&&t<r)}chunkXBAP2B6J_cjs.e();var Ar={bold:{open:"**",close:"**"},italic:{open:"_",close:"_"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function We(t,e){try{let n=Ee.z.string().parse(t),r=we.parse(e);if(!n||r==="off")return n;let{ir:o,hasTables:a}=Se(n,{linkify:!1,enableSpoilers:!1,autolink:!1,headingStyle:"none",blockquotePrefix:"",tableMode:r});return a?Te(o,{styleMarkers:Ar,escapeText:c=>c,buildLink:(c,s)=>{let l=c.href.trim();return !l||!s.slice(c.start,c.end)?null:{start:c.start,end:c.end,open:"[",close:`](${l})`}}}):n}catch(n){return console.warn("Invalid input for convertMarkdownTables:",n),typeof t=="string"?t:""}}exports.Markdown=void 0;(p=>{function t(u,d){try{return ue(u,d)}catch(m){return console.warn("Markdown.parse error:",m),{text:"",styles:[],links:[]}}}p.parse=t;function e(u,d){try{return de(u,d)}catch(m){return console.warn("Markdown.render error:",m),""}}p.render=e;function n(u,d){try{return $e(u,d)}catch(m){return console.warn("Markdown.format error:",m),typeof u=="string"?u:""}}p.format=n;function r(u){try{return Me(u)}catch(d){return console.warn("Markdown.parseFrontmatter error:",d),{}}}p.parseFrontmatter=r;function o(u){try{return De(u)}catch(d){return console.warn("Markdown.serializeFrontmatter error:",d),""}}p.serializeFrontmatter=o;function a(u){try{return Ne(u)}catch(d){return console.warn("Markdown.extractFrontmatter error:",d),{frontmatter:{},content:typeof u=="string"?u:""}}}p.extractFrontmatter=a;function c(u,d,m){try{return ae(u,d,m)}catch(f){return console.warn("Markdown.chunk error:",f),typeof u=="string"&&u.length>0?[u]:[]}}p.chunk=c;function s(u,d){try{return je(u,d)}catch(m){return console.warn("Markdown.buildCodeIndex error:",m),{inlineState:{open:false,ticks:0},isInside:()=>false}}}p.buildCodeIndex=s;function l(u,d){try{return We(u,d)}catch(m){return console.warn("Markdown.convertTables error:",m),typeof u=="string"?u:""}}p.convertTables=l;})(exports.Markdown||(exports.Markdown={}));chunkXBAP2B6J_cjs.e();function Vt(t){if(!t)return "";let n=t.replace(/[/\\]+$/,"").split(/[/\\]/);return n[n.length-1]??""}function $r(t){if(!t)return "";let n=t.replace(/[/\\]+$/,"").split(/[/\\]/);return n.slice(0,n.length-1).join("/")+"/"}function Dr(t){if(!t)return "";let e=t.split(".");return e[e.length-1]}function Nr(t,e=20){let n=Vt(t);if(n.length<=e)return n;let r=n.lastIndexOf("."),o=r<=0?"":n.slice(r),a=e-o.length-1;return a<=0?n.slice(0,e-1)+"\u2026":n.slice(0,a)+"\u2026"+o}function zr(t,e=20){if(t.length<=e)return t;let n=e-1,r=Math.ceil(n/2),o=Math.floor(n/2);return t.slice(0,r)+"\u2026"+t.slice(-o)}chunkXBAP2B6J_cjs.e();var Br=["load failed","network connection was lost","network request failed","failed to fetch","econnreset","econnrefused","etimedout","socket hang up"];function jr(t){if(!t)return false;let e=String(t instanceof Error?t.message:t).toLowerCase();return Br.some(n=>e.includes(n))}async function ht(t,e={}){let{attempts:n=3,delay:r=500,factor:o=2,maxDelay:a=1e4,retryIf:c=jr}=e,s;for(let l=0;l<n;l++)try{return await t()}catch(p){if(s=p,l===n-1||!c(p))throw p;let u=Math.min(r*o**l,a);await new Promise(d=>setTimeout(d,u));}throw s}chunkXBAP2B6J_cjs.e();exports.Fetch=void 0;(I=>{let t=chunkAUS6KQNI_cjs.m.create({service:"fetch"}),e=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"],n=false,r=null;function o(){return e.some(x=>{let y=process.env[x];return typeof y=="string"&&y.trim().length>0})}I.hasProxyConfigured=o;function a(){let x=process.env.http_proxy||process.env.HTTP_PROXY;return process.env.https_proxy||process.env.HTTPS_PROXY||x}I.getProxyUrl=a;function c(x={}){let y=x.httpProxy||x.httpsProxy||a();if(!y){t.warn("[Fetch] No proxy configured, HTTP_PROXY/HTTPS_PROXY environment variables not set");return}let v=new undici.ProxyAgent({uri:y,connectTimeout:x.connectTimeout||1e4,keepAliveTimeout:x.keepAliveTimeout||3e4});r=undici.getGlobalDispatcher(),undici.setGlobalDispatcher(v),n=true,t.info(`[Fetch] Global proxy enabled: ${y}`);}I.enableProxy=c;function s(){!n||!r||(undici.setGlobalDispatcher(r),n=false,r=null,t.info("[Fetch] \u5168\u5C40\u4EE3\u7406\u5DF2\u7981\u7528"));}I.disableProxy=s;function l(){return n}I.isProxyEnabled=l;async function p(x,y){let v=y?.timeout||3e4,z=y?.responseType||"json",{timeout:D,responseType:q,...B}=y||{},R=null,A=null;try{B.signal||(R=new AbortController,A=setTimeout(()=>R.abort(),v));let O=await fetch(x,{...B,signal:B.signal||R.signal});A&&clearTimeout(A);let C;switch(z){case "arrayBuffer":C=await O.arrayBuffer();break;case "blob":C=await O.blob();break;case "buffer":{let K=await O.arrayBuffer();C=Buffer.from(K);break}case "text":C=await O.text();break;default:{let K=await O.text();try{C=JSON.parse(K);}catch{C=K;}break}}return {ok:O.ok,status:O.status,statusText:O.statusText,headers:O.headers,data:C,url:O.url}}catch(O){throw A&&clearTimeout(A),O}}async function u(x,y){let v=y?.retries??0,z=y?.retryDelay??1e3,{retries:D,retryDelay:q,responseType:B,...R}=y||{};return ht(()=>p(x,{...R,responseType:y?.responseType}),{attempts:v+1,delay:z,maxDelay:z*2**(v+1)})}async function d(x,y){return u(x,{method:"GET",...y})}I.get=d;async function m(x,y,v){return u(x,{method:"POST",headers:{"Content-Type":"application/json",...v?.headers},body:y?JSON.stringify(y):void 0,...v})}I.post=m;async function f(x,y,v){return u(x,{method:"PUT",headers:{"Content-Type":"application/json",...v?.headers},body:y?JSON.stringify(y):void 0,...v})}I.put=f;async function g(x,y,v){return u(x,{method:"DELETE",headers:{"Content-Type":"application/json",...v?.headers},body:y?JSON.stringify(y):void 0,...v})}I.del=g;async function S(x,y,v){return u(x,{method:"PATCH",headers:{"Content-Type":"application/json",...v?.headers},body:y?JSON.stringify(y):void 0,...v})}I.patch=S;async function i(x,y){return u(x,y)}I.request=i;function b(x={}){return o()?(c(x),true):false}I.autoProxy=b;let P=5*1024*1024;function E(x){return new TextEncoder().encode(x)}function U(x){return chunkEN7LFV4R_cjs.d.mimeType(x)}function _(x){return x.startsWith("file://")}async function L(x){let y=url.fileURLToPath(x);return await chunk3U5YF6EI_cjs.D.file(y).bytes()}async function N(x,y,v){let z=`----FetchFormBoundary${Date.now()}`,D=[],B=y.some($=>$.filename||$.value instanceof Uint8Array||Buffer.isBuffer($.value))&&!v?.timeout?3e5:v?.timeout;for(let $ of y){let Y=$.maxSize??P,V=$.filename,Z=`Content-Disposition: form-data; name="${$.name}"${V?`; filename="${V}"`:""}`;V&&(Z+=`\r
|
|
57
|
+
Content-Type: ${U(V)}`),Z+=`\r
|
|
58
58
|
\r
|
|
59
|
-
`,
|
|
60
|
-
--${
|
|
61
|
-
--${
|
|
62
|
-
`),
|
|
63
|
-
`));for(let
|
|
64
|
-
`)));
|
|
65
|
-
`);
|
|
66
|
-
`)}P.tree=s;async function l(p){let g=await e();return g?f(g,p):(t.debug("ripgrep not available, using pure JS fallback for search()",{cwd:p.cwd,pattern:p.pattern}),c(p))}P.search=l;async function f(p,g){let M=["--json","--glob=!.git/*"];if(g.follow&&M.push("--follow"),g.glob)for(let C of g.glob)M.push(`--glob=${C}`);g.limit&&M.push(`--max-count=${g.limit}`),M.push("--"),M.push(g.pattern);let O=await chunk3U5YF6EI_cjs.D.run([p,...M],{cwd:g.cwd});if(O.code!==0)return [];let N=g.hidden!==false,A=O.stdout.split(/\r?\n/).filter(Boolean),F=[];for(let C of A)try{let B=JSON.parse(C);if(B?.type!=="match")continue;let S=B.data;if(!S?.path?.text||!S?.lines?.text)continue;let x=chunkEN7LFV4R_cjs.d.toUnixPath(S.path.text);if(!N&&x.split("/").some(y=>y.startsWith(".")))continue;if(F.push({path:x,lines:S.lines.text,line_number:S.line_number,absolute_offset:S.absolute_offset??0}),g.limit&&F.length>=g.limit)break}catch{}return F}async function c(p){let g;try{g=new RegExp(p.pattern);}catch{return []}try{if(!(await me__default.default.stat(p.cwd)).isDirectory())throw Object.assign(new Error(`Not a directory: '${p.cwd}'`),{code:"ENOTDIR",errno:-20,path:p.cwd})}catch(S){throw S.code==="ENOENT"?Object.assign(new Error(`No such file or directory: '${p.cwd}'`),{code:"ENOENT",errno:-2,path:p.cwd}):S}let M=[],O=[];if(p.glob)for(let S of p.glob)S.startsWith("!")?O.push(S.slice(1)):M.push(S);let N=p.hidden!==false,A=[],F=M.length>0?M:["**/*"],C=new Set,B=[];for(let S of F){p.signal?.throwIfAborted();let x=await chunkEN7LFV4R_cjs.b.scan(S,{cwd:p.cwd,absolute:false,include:"file",dot:N,symlink:p.follow??false,maxDepth:void 0,ignore:O});for(let y of x)C.has(y)||(C.add(y),B.push(y));}for(let S of B){if(p.signal?.throwIfAborted(),p.limit&&A.length>=p.limit)break;let x=chunkEN7LFV4R_cjs.d.join(p.cwd,S),y;try{y=await me__default.default.readFile(x,"utf-8");}catch{continue}let R=y.split(/\r?\n/),L=0;for(let _=0;_<R.length;_++){let H=R[_]??"";if(g.test(H)&&(A.push({path:S,lines:H,line_number:_+1,absolute_offset:L}),p.limit&&A.length>=p.limit))break;L+=Buffer.byteLength(H,"utf-8")+1;}}return A}function u(p,g){return chunkEN7LFV4R_cjs.a.match(p,g)}P.match=u;let d=chunk3U5YF6EI_cjs.a(async()=>await e());async function h(){return await d()}P.filepathCached=h,P._ready=chunk3U5YF6EI_cjs.a(async()=>{let p=await e();return t.debug("Grep initialized",{ripgrep:p?"available":"fallback (pure JS)"}),p});})(exports.Grep||(exports.Grep={}));chunkXBAP2B6J_cjs.e();exports.Keybind=void 0;(a=>{function t(s,l){if(s===l)return true;if(typeof s!="object"||typeof l!="object"||s===null||l===null)return false;let f=Object.keys(s),c=Object.keys(l);if(f.length!==c.length)return false;for(let u of f)if(!c.includes(u)||!t(s[u],l[u]))return false;return true}function e(s){return {...s,super:s.super??false}}function n(s,l){return s?t(e(s),e(l)):false}a.match=n;function r(s,l=false){return {name:s.name,ctrl:s.ctrl,meta:s.meta,shift:s.shift,super:s.super??false,leader:l}}a.fromParsedKey=r;function o(s){if(!s)return "";let l=[];s.ctrl&&l.push("ctrl"),s.meta&&l.push("alt"),s.super&&l.push("super"),s.shift&&l.push("shift"),s.name&&(s.name==="delete"?l.push("del"):l.push(s.name));let f=l.join("+");return s.leader&&(f=f?`<leader> ${f}`:"<leader>"),f}a.keyToString=o;function i(s){return s==="none"?[]:s.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 d of c)switch(d){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=d;break}return u})}a.parse=i;})(exports.Keybind||(exports.Keybind={}));chunkXBAP2B6J_cjs.e();exports.Locale=void 0;(d=>{d.SUPPORTED_LANGS=["zh-CN","en-US"],d.DEFAULT_LANG="zh-CN";function n(h,k="EASBOT_LANG"){let P=[h,process.env[k]?.trim()];for(let p of P)if(p&&d.SUPPORTED_LANGS.includes(p))return p;return d.DEFAULT_LANG}d.resolveLocaleLang=n;function r(h){return h.replace(/\b\w/g,k=>k.toUpperCase())}d.titlecase=r;function o(h){return new Date(h).toLocaleTimeString(void 0,{timeStyle:"short"})}d.time=o;function i(h){let k=new Date(h),P=o(h),p=k.toLocaleDateString();return `${P} \xB7 ${p}`}d.datetime=i;function a(h){let k=new Date(h),P=new Date;return k.getFullYear()===P.getFullYear()&&k.getMonth()===P.getMonth()&&k.getDate()===P.getDate()?o(h):i(h)}d.todayTimeOrDateTime=a;function s(h){return h>=1e6?(h/1e6).toFixed(1)+"M":h>=1e3?(h/1e3).toFixed(1)+"K":h.toString()}d.number=s;function l(h){if(h<1e3)return `${h}ms`;if(h<6e4)return `${(h/1e3).toFixed(1)}s`;if(h<36e5){let p=Math.floor(h/6e4),g=Math.floor(h%6e4/1e3);return `${p}m ${g}s`}if(h<864e5){let p=Math.floor(h/36e5),g=Math.floor(h%36e5/6e4);return `${p}h ${g}m`}let k=Math.floor(h/36e5);return `${Math.floor(h%36e5/864e5)}d ${k}h`}d.duration=l;function f(h,k){return h.length<=k?h:h.slice(0,k-1)+"\u2026"}d.truncate=f;function c(h,k=35){if(h.length<=k)return h;let P="\u2026",p=Math.ceil((k-P.length)/2),g=Math.floor((k-P.length)/2);return h.slice(0,p)+P+h.slice(-g)}d.truncateMiddle=c;function u(h,k,P){return (h===1?k:P).replace("{}",h.toString())}d.pluralize=u;})(exports.Locale||(exports.Locale={}));var Sr=exports.Locale.resolveLocaleLang,Tr=exports.Locale.SUPPORTED_LANGS,Mr=exports.Locale.DEFAULT_LANG;chunkXBAP2B6J_cjs.e();var Rr=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"];function Ir(){return Rr.some(t=>process.env[t])}function Pr(){return process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy}function vr(){let t=process.env.HTTP_PROXY||process.env.http_proxy,e=process.env.HTTPS_PROXY||process.env.https_proxy;return {http:t,https:e,enabled:!!(t||e)}}chunkXBAP2B6J_cjs.e();var ut=class{constructor(){chunkXBAP2B6J_cjs.c(this,"queue",[]);chunkXBAP2B6J_cjs.c(this,"resolvers",[]);}push(e){let n=this.resolvers.shift();n?n(e):this.queue.push(e);}async next(){return this.queue.length>0?this.queue.shift():new Promise(e=>this.resolvers.push(e))}async*[Symbol.asyncIterator](){for(;;)yield await this.next();}};async function Or(t,e,n){let r=[...e];await Promise.all(Array.from({length:t},async()=>{for(;;){let o=r.pop();if(o===void 0)return;await n(o);}}));}chunkXBAP2B6J_cjs.e();function Fr(){let t,e=new Promise(n=>t=n);return {trigger(){return t()},wait(){return e}}}chunkXBAP2B6J_cjs.e();function Er(t,e){let n;return Promise.race([t.then(r=>(clearTimeout(n),r)),new Promise((r,o)=>{n=setTimeout(()=>{o(new Error(`Operation timed out after ${e}ms`));},e);})])}chunkXBAP2B6J_cjs.e();exports.Token=void 0;(a=>{let n=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function r(s){if(!s)return 0;let l=String(s),f=(l.match(n)||[]).length,c=l.length-f,u=Math.round(f/1.5),d=Math.round(c/4);return Math.max(0,u+d)}a.estimate=r;function o(s){if(s==null)return 0;try{let l=typeof s=="string"?s:JSON.stringify(s);return r(l)}catch{return 0}}a.estimateObject=o;function i(s){if(s.total!==void 0&&s.total>0)return s.total;let l=s.input??0,f=s.output??0,c=s.cache?.read??0,u=s.cache?.write??0;return l+f+c+u}a.total=i;})(exports.Token||(exports.Token={}));chunkXBAP2B6J_cjs.e();function Cr(t){let e={},n=t.shape??t.required().shape;for(let[r,o]of Object.entries(n))e[r]=o.nullable().optional();return xe__default.default.object(e)}Object.defineProperty(exports,"Lock",{enumerable:true,get:function(){return chunkPJIZPZPO_cjs.a}});Object.defineProperty(exports,"$",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.H}});Object.defineProperty(exports,"HTTPException",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.j}});Object.defineProperty(exports,"Hono",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.d}});Object.defineProperty(exports,"Lazy",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.c}});Object.defineProperty(exports,"PKG",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.D}});Object.defineProperty(exports,"PkgShell",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.A}});Object.defineProperty(exports,"Shell",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.G}});Object.defineProperty(exports,"compress",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.g}});Object.defineProperty(exports,"cors",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.e}});Object.defineProperty(exports,"createNodeWebSocket",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.s}});Object.defineProperty(exports,"createPkgShell",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.B}});Object.defineProperty(exports,"createRESTServer",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.p}});Object.defineProperty(exports,"createRPCServer",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.n}});Object.defineProperty(exports,"createServer",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.m}});Object.defineProperty(exports,"createStreamingServer",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.r}});Object.defineProperty(exports,"createWebSocketServer",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.q}});Object.defineProperty(exports,"detectPlatform",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.y}});Object.defineProperty(exports,"escapeCommandArg",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.w}});Object.defineProperty(exports,"escapeCommandArgSafe",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.x}});Object.defineProperty(exports,"joinCommandArgs",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.z}});Object.defineProperty(exports,"lazy",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.a}});Object.defineProperty(exports,"lazyAsync",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.b}});Object.defineProperty(exports,"logger",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.f}});Object.defineProperty(exports,"needsShellExecution",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.u}});Object.defineProperty(exports,"parseCommand",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.t}});Object.defineProperty(exports,"parseCommandWithOptions",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.v}});Object.defineProperty(exports,"readableStreamToText",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.E}});Object.defineProperty(exports,"secureHeaders",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.h}});Object.defineProperty(exports,"shell",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.C}});Object.defineProperty(exports,"startServer",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.o}});Object.defineProperty(exports,"timeout",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.i}});Object.defineProperty(exports,"validator",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.k}});Object.defineProperty(exports,"whichSync",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.F}});Object.defineProperty(exports,"zValidator",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.l}});Object.defineProperty(exports,"Filesystem",{enumerable:true,get:function(){return chunkEN7LFV4R_cjs.d}});Object.defineProperty(exports,"Glob",{enumerable:true,get:function(){return chunkEN7LFV4R_cjs.b}});Object.defineProperty(exports,"MIME_TYPES",{enumerable:true,get:function(){return chunkEN7LFV4R_cjs.c}});Object.defineProperty(exports,"Wildcard",{enumerable:true,get:function(){return chunkEN7LFV4R_cjs.a}});Object.defineProperty(exports,"Log",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.m}});Object.defineProperty(exports,"PackageRegistry",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.o}});Object.defineProperty(exports,"Semver",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.n}});Object.defineProperty(exports,"addMinutesInTimezone",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.l}});Object.defineProperty(exports,"formatLocalISO",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.a}});Object.defineProperty(exports,"formatLocalISOCompact",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.b}});Object.defineProperty(exports,"formatLogTime",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.f}});Object.defineProperty(exports,"formatLogTimeMs",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.g}});Object.defineProperty(exports,"getTimezoneOffset",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.h}});Object.defineProperty(exports,"getTimezoneParts",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.i}});Object.defineProperty(exports,"isValidTimezone",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.j}});Object.defineProperty(exports,"normalizeTimezone",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.k}});Object.defineProperty(exports,"now",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.c}});Object.defineProperty(exports,"nowLocalISO",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.d}});Object.defineProperty(exports,"parseLocalISO",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.e}});exports.AsyncQueue=ut;exports.DEFAULT_LANG=Mr;exports.NamedError=ze;exports.SUPPORTED_LANGS=Tr;exports.abortAfter=Ct;exports.abortAfterAny=br;exports.buildCodeSpanIndex=Fe;exports.chunkMarkdownIR=vt;exports.chunkText=ee;exports.chunkTextByBreakResolver=qe;exports.convertMarkdownTables=Ee;exports.createInlineCodeState=Oe;exports.defer=kr;exports.extractFrontmatter=Pe;exports.findFenceSpanAt=Qe;exports.findLast=rn;exports.fn=ln;exports.formatDuration=wr;exports.formatMarkdown=Re;exports.getDirectory=cr;exports.getFileExtension=ur;exports.getFilename=Et;exports.getFilenameTruncated=fr;exports.getProxyConfig=vr;exports.getProxyUrl=Pr;exports.git=dn;exports.iife=xn;exports.isSafeFenceBreak=Ft;exports.loadEnv=fn;exports.loadTextFile=yn;exports.loadTextFileAsync=bn;exports.markdownToIR=re;exports.markdownToIRWithMeta=fe;exports.parseFenceSpans=ve;exports.parseFrontmatterBlock=pe;exports.parseModelId=kn;exports.proxied=Ir;exports.renderMarkdown=oe;exports.renderMarkdownWithMarkers=de;exports.resolveLocaleLang=Sr;exports.retry=tt;exports.scanParenAwareBreakpoints=Ue;exports.serializeFrontmatter=Ie;exports.signal=Fr;exports.truncateMiddle=dr;exports.updateSchema=Cr;exports.withTimeout=Er;exports.work=Or;
|
|
59
|
+
`,D.push(E(Z));let H=$.value;if(typeof H=="string")if(_(H)){let pe=await L(H);if(V||(V=H.split("/").pop()||"file"),pe.byteLength>Y)throw new Error(`File size ${pe.byteLength} exceeds limit ${Y} bytes: ${V}`);D.push(pe);}else D.push(E(H));else if(Buffer.isBuffer(H)){if(H.byteLength>Y)throw new Error(`Buffer size ${H.byteLength} exceeds limit ${Y} bytes: ${$.name}`);D.push(new Uint8Array(H.buffer,H.byteOffset,H.byteLength));}else if(H instanceof Uint8Array){if(H.byteLength>Y)throw new Error(`File size ${H.byteLength} exceeds limit ${Y} bytes: ${$.name}`);D.push(H);}}let R=E(`\r
|
|
60
|
+
--${z}--`),A=E(`\r
|
|
61
|
+
--${z}\r
|
|
62
|
+
`),O=[];O.push(E(`--${z}\r
|
|
63
|
+
`));for(let $=0;$<D.length;$++)O.push(D[$]),$%2===1&&$<D.length-1&&(O.push(A),O.push(E(`--${z}\r
|
|
64
|
+
`)));O.push(R);let C=O.reduce(($,Y)=>$+Y.length,0),K=new Uint8Array(C),ie=0;for(let $ of O)K.set($,ie),ie+=$.length;return u(x,{method:"POST",headers:{"Content-Type":`multipart/form-data; boundary=${z}`,...v?.headers},body:K,timeout:B,...v})}I.postForm=N;function W(x,y,v){let z=new AbortController,D=z.signal;return (async()=>{try{let B={Accept:"text/event-stream",...v?.headers||{}},R=await fetch(x,{...v,headers:B,signal:D});if(!R.ok)throw new Error(`SSE connection failed: ${R.status}`);let A=R.body?.getReader();if(!A)throw new Error("SSE stream not available");let O=new TextDecoder("utf-8"),C="";for(;!D.aborted;){let{done:K,value:ie}=await A.read();if(K)break;let $=O.decode(ie,{stream:!0});C+=$;let Y=C.split(`
|
|
65
|
+
`);C=Y.pop()??"";for(let V of Y)if(V.startsWith("data: ")){let Z=V.slice(6);if(Z==="[DONE]"){y.onComplete?.();return}y.onMessage?.(Z);}}y.onComplete?.();}catch(B){B.name!=="AbortError"&&y.onError?.(B);}})(),()=>{z.abort();}}I.sse=W;})(exports.Fetch||(exports.Fetch={}));chunkXBAP2B6J_cjs.e();exports.Slug=void 0;(r=>{let t=["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"],e=["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 n(){return [t[Math.floor(Math.random()*t.length)],e[Math.floor(Math.random()*e.length)]].join("-")}r.create=n;})(exports.Slug||(exports.Slug={}));chunkXBAP2B6J_cjs.e();function Kt(t){let e=new AbortController,n=setTimeout(e.abort.bind(e),t);return {controller:e,signal:e.signal,clearTimeout:()=>globalThis.clearTimeout(n)}}function qr(t,...e){let n=Kt(t);return {signal:AbortSignal.any([n.signal,...e]),clearTimeout:n.clearTimeout}}chunkXBAP2B6J_cjs.e();exports.Archive=void 0;(e=>{async function t(n,r){if(process.platform==="win32"){let o=rt__default.default.resolve(n),a=rt__default.default.resolve(r),c=`Expand-Archive -Path '${o}' -DestinationPath '${a}' -Force`,s=await chunk3U5YF6EI_cjs.G.run("powershell",`-NoProfile -NonInteractive -Command "$global:ProgressPreference = 'SilentlyContinue'; ${c}"`);if(s.code!==0)throw new Error(`PowerShell exited with code ${s.code}: ${s.stderr}`)}else {let o=`unzip -o -q ${n} -d ${r}`,a=await chunk3U5YF6EI_cjs.G.run(void 0,o);if(a.code!==0)throw new Error(`unzip exited with code ${a.code}: ${a.stderr}`)}}e.extractZip=t;})(exports.Archive||(exports.Archive={}));chunkXBAP2B6J_cjs.e();exports.Color=void 0;(r=>{function t(o){return o?/^#[0-9a-fA-F]{6}$/.test(o):false}r.isValidHex=t;function e(o){let a=parseInt(o.slice(1,3),16),c=parseInt(o.slice(3,5),16),s=parseInt(o.slice(5,7),16);return {r:a,g:c,b:s}}r.hexToRgb=e;function n(o){if(!t(o))return;let{r:a,g:c,b:s}=e(o);return `\x1B[38;2;${a};${c};${s}m\x1B[1m`}r.hexToAnsiBold=n;})(exports.Color||(exports.Color={}));chunkXBAP2B6J_cjs.e();exports.Context=void 0;(n=>{class t extends Error{constructor(a){super(`No context found for ${a}`);chunkXBAP2B6J_cjs.c(this,"name",a);}}n.NotFound=t;function e(r){let o=new async_hooks.AsyncLocalStorage;return {use(){let a=o.getStore();if(!a)throw new t(r);return a},provide(a,c){return o.run(a,c)}}}n.create=e;})(exports.Context||(exports.Context={}));chunkXBAP2B6J_cjs.e();function Yr(t){return {[Symbol.dispose](){t();},[Symbol.asyncDispose](){return Promise.resolve(t())}}}chunkXBAP2B6J_cjs.e();exports.EventLoop=void 0;(e=>{async function t(){return new Promise(n=>{let r=()=>{process._getActiveHandles().length===0&&process._getActiveRequests().length===0?n():setImmediate(r);};r();})}e.wait=t;})(exports.EventLoop||(exports.EventLoop={}));chunkXBAP2B6J_cjs.e();function Vr(t){if(t<=0)return "";if(t<60)return `${t}s`;if(t<3600){let n=Math.floor(t/60),r=t%60;return r>0?`${n}m ${r}s`:`${n}m`}if(t<86400){let n=Math.floor(t/3600),r=Math.floor(t%3600/60);return r>0?`${n}h ${r}m`:`${n}h`}if(t<604800){let n=Math.floor(t/86400);return n===1?"~1 day":`~${n} days`}let e=Math.floor(t/604800);return e===1?"~1 week":`~${e} weeks`}chunkXBAP2B6J_cjs.e();exports.Grep=void 0;(S=>{let t=chunkAUS6KQNI_cjs.m.create({service:"grep"});async function e(){return n()}S.filepath=e;let n=chunk3U5YF6EI_cjs.b(async()=>{let i=await chunk3U5YF6EI_cjs.D.which("rg");if(!i)return null;try{if(!(await Ie__default.default.stat(i)).isFile())return null}catch{return null}try{let b=await chunk3U5YF6EI_cjs.D.run([i,"--version"],{timeout:5e3});if(b.code!==0||!b.stdout.startsWith("ripgrep "))return t.warn("rg failed self-test, falling back to pure JS",{filepath:i,code:b.code,stderr:b.stderr.slice(0,200)}),null}catch(b){return t.warn("rg spawn failed during self-test, falling back to pure JS",{filepath:i,error:b.message.slice(0,200)}),null}return i});async function r(){return await e()!==null}S.isUsingRipgrep=r;async function*o(i){i.signal?.throwIfAborted();let b=await e();b?yield*a(b,i):(t.debug("ripgrep not available, using pure JS fallback for files()",{cwd:i.cwd}),yield*c(i));}S.files=o;async function*a(i,b){b.signal?.throwIfAborted();let P=["--files","--glob=!.git/*"];b.follow&&P.push("--follow");let E=b.hidden!==false;if(b.maxDepth!==void 0&&P.push(`--max-depth=${b.maxDepth}`),b.glob)for(let L of b.glob)P.push(`--glob=${L}`);try{if(!(await Ie__default.default.stat(b.cwd)).isDirectory())throw Object.assign(new Error(`Not a directory: '${b.cwd}'`),{code:"ENOTDIR",errno:-20,path:b.cwd})}catch(L){throw L.code==="ENOENT"?Object.assign(new Error(`No such file or directory: '${b.cwd}'`),{code:"ENOENT",errno:-2,path:b.cwd}):L}let U=await chunk3U5YF6EI_cjs.D.run([i,...P],{cwd:b.cwd});if(U.code!==0&&U.code!==1)return;let _=U.stdout.split(/\r?\n/);for(let L of _){b.signal?.throwIfAborted();let N=L.trim();if(!N)continue;let W=chunkEN7LFV4R_cjs.d.toUnixPath(N);!E&&W.split("/").some(I=>I.startsWith("."))||(yield W);}}async function*c(i){i.signal?.throwIfAborted();try{if(!(await Ie__default.default.stat(i.cwd)).isDirectory())throw Object.assign(new Error(`Not a directory: '${i.cwd}'`),{code:"ENOTDIR",errno:-20,path:i.cwd})}catch(I){throw I.code==="ENOENT"?Object.assign(new Error(`No such file or directory: '${i.cwd}'`),{code:"ENOENT",errno:-2,path:i.cwd}):I}let b=[],P=[];if(i.glob)for(let I of i.glob)I.startsWith("!")?P.push(I.slice(1)):b.push(I);let E=b.length>0?b:["**/*"],U=i.hidden!==false,_=new Set,L=chunkEN7LFV4R_cjs.b.DEFAULT_MAX_DEPTH,N;i.maxDepth===void 0?N=L:i.maxDepth<0?N=1:N=i.maxDepth+1;let W=Math.min(Math.max(N,1),L);for(let I of E){i.signal?.throwIfAborted();let x=await chunkEN7LFV4R_cjs.b.scan(I,{cwd:i.cwd,absolute:false,include:"file",dot:U,symlink:i.follow??false,maxDepth:W,ignore:P});for(let y of x)!U&&y.split("/").some(v=>v.startsWith("."))||_.add(y);}for(let I of Array.from(_).sort())i.signal?.throwIfAborted(),yield I;i.signal?.throwIfAborted();}async function s(i){t.debug("tree",{cwd:i.cwd}),i.signal?.throwIfAborted();let b=i.hidden!==false,P=i.glob??[],E=P.filter(R=>!R.startsWith("!")),U=P.filter(R=>R.startsWith("!")).map(R=>R.slice(1)),_=E.length>0?E:["**/*"],L=new Set,N=[];for(let R of _){i.signal?.throwIfAborted();let A=await chunkEN7LFV4R_cjs.b.scan(R,{cwd:i.cwd,absolute:false,include:"file",dot:b,symlink:false,maxDepth:chunkEN7LFV4R_cjs.b.DEFAULT_MAX_DEPTH});for(let O of A)L.has(O)||(L.add(O),N.push(O));}let W=N.filter(R=>{for(let A of U)if(chunkEN7LFV4R_cjs.b.match(A,R))return false;return true});function I(R,A){let O=R.children.get(A);if(O)return O;let C={name:A,children:new Map};return R.children.set(A,C),C}let x={children:new Map};for(let R of W){let A=R.split("/");if(A.length<2)continue;let O=x;for(let C of A.slice(0,-1))O=I(O,C);}let y=Array.from(x.children.values()).sort((R,A)=>R.name.localeCompare(A.name)),v=i.limit??Number.POSITIVE_INFINITY,z=[],D=y.map(R=>({node:R,path:R.name})),q=0,B=0;for(;D.length>0;){let R=D.shift();if(!R)break;if(q++,B<v){z.push(R.path),B++;for(let A of Array.from(R.node.children.values()).sort((O,C)=>O.name.localeCompare(C.name))){if(B>=v)break;D.push({node:A,path:`${R.path}/${A.name}`});}}}return q>B&&z.push(`[${B}/${q} shown, ${q-B} truncated]`),z.join(`
|
|
66
|
+
`)}S.tree=s;async function l(i){let b=await e();return b?p(b,i):(t.debug("ripgrep not available, using pure JS fallback for search()",{cwd:i.cwd,pattern:i.pattern}),u(i))}S.search=l;async function p(i,b){let P=["--json","--glob=!.git/*"];if(b.follow&&P.push("--follow"),b.glob)for(let N of b.glob)P.push(`--glob=${N}`);b.limit&&P.push(`--max-count=${b.limit}`),P.push("--"),P.push(b.pattern);let E=await chunk3U5YF6EI_cjs.D.run([i,...P],{cwd:b.cwd});if(E.code!==0)return [];let U=b.hidden!==false,_=E.stdout.split(/\r?\n/).filter(Boolean),L=[];for(let N of _)try{let W=JSON.parse(N);if(W?.type!=="match")continue;let I=W.data;if(!I?.path?.text||!I?.lines?.text)continue;let x=chunkEN7LFV4R_cjs.d.toUnixPath(I.path.text);if(!U&&x.split("/").some(y=>y.startsWith(".")))continue;if(L.push({path:x,lines:I.lines.text,line_number:I.line_number,absolute_offset:I.absolute_offset??0}),b.limit&&L.length>=b.limit)break}catch{}return L}async function u(i){let b;try{b=new RegExp(i.pattern);}catch{return []}try{if(!(await Ie__default.default.stat(i.cwd)).isDirectory())throw Object.assign(new Error(`Not a directory: '${i.cwd}'`),{code:"ENOTDIR",errno:-20,path:i.cwd})}catch(I){throw I.code==="ENOENT"?Object.assign(new Error(`No such file or directory: '${i.cwd}'`),{code:"ENOENT",errno:-2,path:i.cwd}):I}let P=[],E=[];if(i.glob)for(let I of i.glob)I.startsWith("!")?E.push(I.slice(1)):P.push(I);let U=i.hidden!==false,_=[],L=P.length>0?P:["**/*"],N=new Set,W=[];for(let I of L){i.signal?.throwIfAborted();let x=await chunkEN7LFV4R_cjs.b.scan(I,{cwd:i.cwd,absolute:false,include:"file",dot:U,symlink:i.follow??false,maxDepth:void 0,ignore:E});for(let y of x)N.has(y)||(N.add(y),W.push(y));}for(let I of W){if(i.signal?.throwIfAborted(),i.limit&&_.length>=i.limit)break;let x=chunkEN7LFV4R_cjs.d.join(i.cwd,I),y;try{y=await Ie__default.default.readFile(x,"utf-8");}catch{continue}let v=y.split(/\r?\n/),z=0;for(let D=0;D<v.length;D++){let q=v[D]??"";if(b.test(q)&&(_.push({path:I,lines:q,line_number:D+1,absolute_offset:z}),i.limit&&_.length>=i.limit))break;z+=Buffer.byteLength(q,"utf-8")+1;}}return _}function d(i,b){return chunkEN7LFV4R_cjs.a.match(i,b)}S.match=d;let m=chunk3U5YF6EI_cjs.a(async()=>await e());async function f(){return await m()}S.filepathCached=f,S._ready=chunk3U5YF6EI_cjs.a(async()=>{let i=await e();return t.debug("Grep initialized",{ripgrep:i?"available":"fallback (pure JS)"}),i});})(exports.Grep||(exports.Grep={}));chunkXBAP2B6J_cjs.e();exports.Keybind=void 0;(c=>{function t(s,l){if(s===l)return true;if(typeof s!="object"||typeof l!="object"||s===null||l===null)return false;let p=Object.keys(s),u=Object.keys(l);if(p.length!==u.length)return false;for(let d of p)if(!u.includes(d)||!t(s[d],l[d]))return false;return true}function e(s){return {...s,super:s.super??false}}function n(s,l){return s?t(e(s),e(l)):false}c.match=n;function r(s,l=false){return {name:s.name,ctrl:s.ctrl,meta:s.meta,shift:s.shift,super:s.super??false,leader:l}}c.fromParsedKey=r;function o(s){if(!s)return "";let l=[];s.ctrl&&l.push("ctrl"),s.meta&&l.push("alt"),s.super&&l.push("super"),s.shift&&l.push("shift"),s.name&&(s.name==="delete"?l.push("del"):l.push(s.name));let p=l.join("+");return s.leader&&(p=p?`<leader> ${p}`:"<leader>"),p}c.keyToString=o;function a(s){return s==="none"?[]:s.split(",").map(l=>{let u=l.replace(/<leader>/g,"leader+").toLowerCase().split("+"),d={ctrl:false,meta:false,shift:false,super:false,leader:false,name:""};for(let m of u)switch(m){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=m;break}return d})}c.parse=a;})(exports.Keybind||(exports.Keybind={}));chunkXBAP2B6J_cjs.e();exports.Locale=void 0;(m=>{m.SUPPORTED_LANGS=["zh-CN","en-US"],m.DEFAULT_LANG="zh-CN";function n(f,g="EASBOT_LANG"){let S=[f,process.env[g]?.trim()];for(let i of S)if(i&&m.SUPPORTED_LANGS.includes(i))return i;return m.DEFAULT_LANG}m.resolveLocaleLang=n;function r(f){return f.replace(/\b\w/g,g=>g.toUpperCase())}m.titlecase=r;function o(f){return new Date(f).toLocaleTimeString(void 0,{timeStyle:"short"})}m.time=o;function a(f){let g=new Date(f),S=o(f),i=g.toLocaleDateString();return `${S} \xB7 ${i}`}m.datetime=a;function c(f){let g=new Date(f),S=new Date;return g.getFullYear()===S.getFullYear()&&g.getMonth()===S.getMonth()&&g.getDate()===S.getDate()?o(f):a(f)}m.todayTimeOrDateTime=c;function s(f){return f>=1e6?(f/1e6).toFixed(1)+"M":f>=1e3?(f/1e3).toFixed(1)+"K":f.toString()}m.number=s;function l(f){if(f<1e3)return `${f}ms`;if(f<6e4)return `${(f/1e3).toFixed(1)}s`;if(f<36e5){let i=Math.floor(f/6e4),b=Math.floor(f%6e4/1e3);return `${i}m ${b}s`}if(f<864e5){let i=Math.floor(f/36e5),b=Math.floor(f%36e5/6e4);return `${i}h ${b}m`}let g=Math.floor(f/36e5);return `${Math.floor(f%36e5/864e5)}d ${g}h`}m.duration=l;function p(f,g){return f.length<=g?f:f.slice(0,g-1)+"\u2026"}m.truncate=p;function u(f,g=35){if(f.length<=g)return f;let S="\u2026",i=Math.ceil((g-S.length)/2),b=Math.floor((g-S.length)/2);return f.slice(0,i)+S+f.slice(-b)}m.truncateMiddle=u;function d(f,g,S){return (f===1?g:S).replace("{}",f.toString())}m.pluralize=d;})(exports.Locale||(exports.Locale={}));var Xr=exports.Locale.resolveLocaleLang,Kr=exports.Locale.SUPPORTED_LANGS,Jr=exports.Locale.DEFAULT_LANG;chunkXBAP2B6J_cjs.e();var Zr=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"];function Qr(){return Zr.some(t=>process.env[t])}function eo(){return process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy}function to(){let t=process.env.HTTP_PROXY||process.env.http_proxy,e=process.env.HTTPS_PROXY||process.env.https_proxy;return {http:t,https:e,enabled:!!(t||e)}}chunkXBAP2B6J_cjs.e();var Mt=class{constructor(){chunkXBAP2B6J_cjs.c(this,"queue",[]);chunkXBAP2B6J_cjs.c(this,"resolvers",[]);}push(e){let n=this.resolvers.shift();n?n(e):this.queue.push(e);}async next(){return this.queue.length>0?this.queue.shift():new Promise(e=>this.resolvers.push(e))}async*[Symbol.asyncIterator](){for(;;)yield await this.next();}};async function no(t,e,n){let r=[...e];await Promise.all(Array.from({length:t},async()=>{for(;;){let o=r.pop();if(o===void 0)return;await n(o);}}));}chunkXBAP2B6J_cjs.e();function ro(){let t,e=new Promise(n=>t=n);return {trigger(){return t()},wait(){return e}}}chunkXBAP2B6J_cjs.e();function oo(t,e){let n;return Promise.race([t.then(r=>(clearTimeout(n),r)),new Promise((r,o)=>{n=setTimeout(()=>{o(new Error(`Operation timed out after ${e}ms`));},e);})])}chunkXBAP2B6J_cjs.e();exports.Token=void 0;(c=>{let n=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function r(s){if(!s)return 0;let l=String(s),p=(l.match(n)||[]).length,u=l.length-p,d=Math.round(p/1.5),m=Math.round(u/4);return Math.max(0,d+m)}c.estimate=r;function o(s){if(s==null)return 0;try{let l=typeof s=="string"?s:JSON.stringify(s);return r(l)}catch{return 0}}c.estimateObject=o;function a(s){if(s.total!==void 0&&s.total>0)return s.total;let l=s.input??0,p=s.output??0,u=s.cache?.read??0,d=s.cache?.write??0;return l+p+u+d}c.total=a;})(exports.Token||(exports.Token={}));chunkXBAP2B6J_cjs.e();function io(t){let e={},n=t.shape??t.required().shape;for(let[r,o]of Object.entries(n))e[r]=o.nullable().optional();return Ee__default.default.object(e)}chunkXBAP2B6J_cjs.e();var lo=new stream.Writable({write(t,e,n){n();}});exports.CliSearch=void 0;(m=>{m.cancelSymbol=Symbol("CliSearch.cancel");function e(f){let g=0;for(let S of f){let i=S.codePointAt(0);if(i===void 0||i===0)continue;let b=i>=4352&&i<=4447||i>=8986&&i<=8987||i>=9001&&i<=9002||i>=9193&&i<=9196||i===9200||i===9203||i>=9725&&i<=9726||i>=9748&&i<=9749||i>=9800&&i<=9811||i===9855||i===9875||i===9889||i>=9898&&i<=9899||i>=9917&&i<=9918||i>=9924&&i<=9925||i===9934||i===9940||i===9962||i>=9970&&i<=9971||i===9973||i===9978||i===9981||i===9989||i>=9994&&i<=9995||i===10024||i===10060||i===10062||i>=10067&&i<=10069||i===10071||i>=10133&&i<=10135||i===10160||i===10175||i>=11035&&i<=11036||i===11088||i===11093||i>=11904&&i<=42191&&i!==12351||i>=43360&&i<=43388||i>=44032&&i<=55203||i>=63744&&i<=64255||i>=65040&&i<=65049||i>=65072&&i<=65135||i>=65280&&i<=65376||i>=65504&&i<=65510||i>=126976&&i<=129535;g+=b?2:1;}return g}m.approxStringWidth=e;function n(f,g){let S=util.stripVTControlCharacters(f),i=Math.max(1,g),b=e(S);return Math.max(1,Math.ceil(b/i))}m.visualRowsForLine=n;function r(f,g){let S=g!==void 0&&g>0?g:process.stdout.columns&&process.stdout.columns>0?process.stdout.columns:80,i=0;for(let b of f)i+=n(b,S);return i}m.countVisualRowsForLines=r;function o(f){let g=new Array(f.length);for(let S=0;S<f.length;S++){let i=f[S],b=i.value===null||i.value===void 0?"":String(i.value);g[S]={...i,searchKey:`${i.label}
|
|
67
|
+
${b}`.toLowerCase()};}return g}function a(f,g){return g===""||f.searchKey.includes(g)}function c(f,g){return g<=0||f<0?0:f>=g?g-1:f}function s(f){if(f?.length!==1)return false;let g=f.codePointAt(0);return !(g===void 0||g<32||g===127||g===27)}function l(){let f=process.stdout.rows;if(!f||f<=0)return 8;let g=Math.floor((f-8)/2);return Math.max(5,Math.min(15,g))}function p(f,g){try{f.write(g);}catch{}}function u(f){if(f&&f.isTTY&&typeof f.setRawMode=="function")try{f.setRawMode(!1);}catch{}}function d(f){let g=f.message,S=o(f.items),i=Math.max(1,f.maxVisible??l()),b=f.initialSelected??[],P=f.required??false,E=f.lockedSection;return new Promise(U=>{let _=process.stdin,L=process.stdout,N=He__namespace.createInterface({input:_,output:lo,terminal:false});try{_.isTTY&&_.setRawMode?.(!0);}catch{}He__namespace.emitKeypressEvents(_,N);let W="",I="",x=0,y=new Set(b),v=0,z=false,D=E?E.items.map(F=>F.value):[],q=E?E.items.map(F=>F.label):[],B=[],R=()=>{if(B.length=0,I==="")for(let F=0;F<S.length;F++){let k=S[F];B.push(k);}else for(let F=0;F<S.length;F++){let k=S[F];a(k,I)&&B.push(k);}return B},A=()=>{if(v>0){p(L,`\x1B[${v}A`);for(let F=0;F<v;F++)p(L,"\x1B[2K\x1B[1B");p(L,`\x1B[${v}A`);}},O=()=>{let F=q.slice();for(let k=0;k<S.length;k++){let j=S[k];y.has(j.value)&&F.push(j.label);}return F},C=(F="active")=>{A();let k=[],j=R(),Ue=F==="active"||F==="error"?"\u25C6":F==="cancel"?"\u25A0":"\u25C7",en=F==="cancel"?T__default.default.red(Ue):F==="error"?T__default.default.red(Ue):T__default.default.green(Ue);if(k.push(`${en} ${T__default.default.bold(g)}`),F==="active"||F==="error"){if(E&&E.items.length>0){k.push(T__default.default.dim("\u2502"));let ne=`${T__default.default.bold(E.title)} ${T__default.default.dim("\u2500\u2500 always included")}`;k.push(`${T__default.default.dim("\u2502")} ${T__default.default.dim("\u2500\u2500")} ${ne} ${T__default.default.dim("\u2500".repeat(12))}`);for(let he of E.items)k.push(`${T__default.default.dim("\u2502")} ${T__default.default.green("\u2022")} ${T__default.default.bold(he.label)}`);E.hiddenCount&&E.hiddenCount>0&&k.push(`${T__default.default.dim("\u2502")} ${T__default.default.dim(`...and ${E.hiddenCount} more`)}`),k.push(T__default.default.dim("\u2502")),k.push(`${T__default.default.dim("\u2502")} ${T__default.default.dim("\u2500\u2500")} ${T__default.default.bold("Additional agents")} ${T__default.default.dim("\u2500".repeat(29))}`);}let qe=`${T__default.default.dim("\u2502")} ${T__default.default.dim("Search:")} ${W}${T__default.default.inverse(" ")}`;k.push(qe),k.push(`${T__default.default.dim("\u2502")} ${T__default.default.dim("\u2191\u2193 move \xB7 space select \xB7 enter confirm")}`),k.push(T__default.default.dim("\u2502"));let tn=Math.max(0,j.length-i),nn=x-Math.floor(i/2),Ge=Math.max(0,Math.min(nn,tn)),Rt=Math.min(j.length,Ge+i);if(j.length===0)k.push(`${T__default.default.dim("\u2502")} ${T__default.default.dim("No matches found")}`);else {for(let Q=Ge;Q<Rt;Q++){let ge=j[Q],rn=y.has(ge.value),Pt=Q===x,on=rn?T__default.default.green("\u25CF"):T__default.default.dim("\u25CB"),sn=Pt?T__default.default.underline(ge.label):ge.label,an=ge.hint?T__default.default.dim(` (${ge.hint})`):"",cn=Pt?T__default.default.cyan("\u276F"):" ";k.push(`${T__default.default.dim("\u2502")} ${cn} ${on} ${sn}${an}`);}let ne=Ge,he=j.length-Rt;if(ne>0||he>0){let Q=[];ne>0&&Q.push(`\u2191 ${ne} more`),he>0&&Q.push(`\u2193 ${he} more`),k.push(`${T__default.default.dim("\u2502")} ${T__default.default.dim(Q.join(" "))}`);}}k.push(T__default.default.dim("\u2502"));let me=O();if(me.length===0)k.push(`${T__default.default.dim("\u2502")} ${T__default.default.dim("Selected: (none)")}`);else {let ne=me.length<=3?me.join(", "):`${me.slice(0,3).join(", ")} +${me.length-3} more`;k.push(`${T__default.default.dim("\u2502")} ${T__default.default.green("Selected:")} ${ne}`);}F==="error"&&k.push(`${T__default.default.dim("\u2502")} ${T__default.default.red("\u26A0 Please select at least one item before submitting")}`),k.push(`${T__default.default.dim("\u2514")}`);}else if(F==="submit"){let qe=O();k.push(`${T__default.default.dim("\u2502")} ${T__default.default.dim(qe.join(", "))}`);}else k.push(`${T__default.default.dim("\u2502")} ${T__default.default.strikethrough(T__default.default.dim("Cancelled"))}`);p(L,`${k.join(`
|
|
68
|
+
`)}
|
|
69
|
+
`);try{v=r(k,L.columns);}catch{v=k.length;}},K=false,ie=()=>{if(!K){K=true;try{_.removeListener("keypress",vt),_.removeListener("end",Z);}catch{}try{process.removeListener("SIGINT",H),process.removeListener("SIGTERM",H);}catch{}u(_);try{N.close();}catch{}}},$=F=>{z||(z=true,ie(),U(F));},Y=()=>{if(P&&y.size===0&&D.length===0){C("error");return}C("submit"),$([...D,...Array.from(y)]);},V=()=>{C("cancel"),$(m.cancelSymbol);},Z=()=>{V();},H=()=>{u(_);},pe=F=>{let k=F[x];k&&(y.has(k.value)?y.delete(k.value):y.add(k.value));},Zt=F=>{W+=F,I+=F.toLowerCase();},Qt=()=>{W.length!==0&&(W=W.slice(0,-1),I=I.slice(0,-1));},vt=(F,k)=>{if(!k)return;let j=R();if(x=c(x,j.length),k.name==="return"){Y();return}if(k.name==="escape"||k.ctrl&&k.name==="c"){V();return}if(k.name==="up"||k.name==="left"){j.length>0&&(x=c(x-1,j.length),C());return}if(k.name==="down"||k.name==="right"){j.length>0&&(x=c(x+1,j.length),C());return}if(k.name==="pageup"){j.length>0&&(x=c(x-i,j.length),C());return}if(k.name==="pagedown"){j.length>0&&(x=c(x+i,j.length),C());return}if(k.name==="home"){j.length>0&&(x=0,C());return}if(k.name==="end"){j.length>0&&(x=j.length-1,C());return}if(k.name==="space"){pe(j),C();return}if(k.name==="backspace"){W.length>0&&(Qt(),x=0,C());return}!k.ctrl&&!k.meta&&s(k.sequence)&&(Zt(k.sequence),x=0,C());};_.on("keypress",vt),_.once("end",Z),process.on("SIGINT",H),process.on("SIGTERM",H),C();})}m.multiselect=d;})(exports.CliSearch||(exports.CliSearch={}));exports.CliSearch.cancelSymbol;exports.CliSearch.multiselect;Object.defineProperty(exports,"Lock",{enumerable:true,get:function(){return chunkPJIZPZPO_cjs.a}});Object.defineProperty(exports,"$",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.H}});Object.defineProperty(exports,"HTTPException",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.j}});Object.defineProperty(exports,"Hono",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.d}});Object.defineProperty(exports,"Lazy",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.c}});Object.defineProperty(exports,"PKG",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.D}});Object.defineProperty(exports,"PkgShell",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.A}});Object.defineProperty(exports,"Shell",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.G}});Object.defineProperty(exports,"compress",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.g}});Object.defineProperty(exports,"cors",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.e}});Object.defineProperty(exports,"createNodeWebSocket",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.s}});Object.defineProperty(exports,"createPkgShell",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.B}});Object.defineProperty(exports,"createRESTServer",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.p}});Object.defineProperty(exports,"createRPCServer",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.n}});Object.defineProperty(exports,"createServer",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.m}});Object.defineProperty(exports,"createStreamingServer",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.r}});Object.defineProperty(exports,"createWebSocketServer",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.q}});Object.defineProperty(exports,"detectPlatform",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.y}});Object.defineProperty(exports,"escapeCommandArg",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.w}});Object.defineProperty(exports,"escapeCommandArgSafe",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.x}});Object.defineProperty(exports,"joinCommandArgs",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.z}});Object.defineProperty(exports,"lazy",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.a}});Object.defineProperty(exports,"lazyAsync",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.b}});Object.defineProperty(exports,"logger",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.f}});Object.defineProperty(exports,"needsShellExecution",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.u}});Object.defineProperty(exports,"parseCommand",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.t}});Object.defineProperty(exports,"parseCommandWithOptions",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.v}});Object.defineProperty(exports,"readableStreamToText",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.E}});Object.defineProperty(exports,"secureHeaders",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.h}});Object.defineProperty(exports,"shell",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.C}});Object.defineProperty(exports,"startServer",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.o}});Object.defineProperty(exports,"timeout",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.i}});Object.defineProperty(exports,"validator",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.k}});Object.defineProperty(exports,"whichSync",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.F}});Object.defineProperty(exports,"zValidator",{enumerable:true,get:function(){return chunk3U5YF6EI_cjs.l}});Object.defineProperty(exports,"Filesystem",{enumerable:true,get:function(){return chunkEN7LFV4R_cjs.d}});Object.defineProperty(exports,"Glob",{enumerable:true,get:function(){return chunkEN7LFV4R_cjs.b}});Object.defineProperty(exports,"MIME_TYPES",{enumerable:true,get:function(){return chunkEN7LFV4R_cjs.c}});Object.defineProperty(exports,"Wildcard",{enumerable:true,get:function(){return chunkEN7LFV4R_cjs.a}});Object.defineProperty(exports,"Log",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.m}});Object.defineProperty(exports,"PackageRegistry",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.o}});Object.defineProperty(exports,"Semver",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.n}});Object.defineProperty(exports,"addMinutesInTimezone",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.l}});Object.defineProperty(exports,"formatLocalISO",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.a}});Object.defineProperty(exports,"formatLocalISOCompact",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.b}});Object.defineProperty(exports,"formatLogTime",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.f}});Object.defineProperty(exports,"formatLogTimeMs",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.g}});Object.defineProperty(exports,"getTimezoneOffset",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.h}});Object.defineProperty(exports,"getTimezoneParts",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.i}});Object.defineProperty(exports,"isValidTimezone",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.j}});Object.defineProperty(exports,"normalizeTimezone",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.k}});Object.defineProperty(exports,"now",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.c}});Object.defineProperty(exports,"nowLocalISO",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.d}});Object.defineProperty(exports,"parseLocalISO",{enumerable:true,get:function(){return chunkAUS6KQNI_cjs.e}});exports.AsyncQueue=Mt;exports.DEFAULT_LANG=Jr;exports.NamedError=Qe;exports.SUPPORTED_LANGS=Kr;exports.abortAfter=Kt;exports.abortAfterAny=qr;exports.buildCodeSpanIndex=je;exports.chunkMarkdownIR=qt;exports.chunkText=ae;exports.chunkTextByBreakResolver=st;exports.convertMarkdownTables=We;exports.createInlineCodeState=Be;exports.defer=Yr;exports.extractFrontmatter=Ne;exports.findFenceSpanAt=pt;exports.findLast=Fn;exports.fn=An;exports.formatDuration=Vr;exports.formatMarkdown=$e;exports.getDirectory=$r;exports.getFileExtension=Dr;exports.getFilename=Vt;exports.getFilenameTruncated=Nr;exports.getProxyConfig=to;exports.getProxyUrl=eo;exports.git=zn;exports.iife=Gn;exports.isSafeFenceBreak=Yt;exports.loadEnv=Nn;exports.loadTextFile=Un;exports.loadTextFileAsync=qn;exports.markdownToIR=ue;exports.markdownToIRWithMeta=Se;exports.parseFenceSpans=ze;exports.parseFrontmatterBlock=Me;exports.parseModelId=Yn;exports.proxied=Qr;exports.renderMarkdown=de;exports.renderMarkdownWithMarkers=Te;exports.resolveLocaleLang=Xr;exports.retry=ht;exports.scanParenAwareBreakpoints=ot;exports.serializeFrontmatter=De;exports.signal=ro;exports.truncateMiddle=zr;exports.updateSchema=io;exports.withTimeout=oo;exports.work=no;
|
package/dist/index.d.cts
CHANGED
|
@@ -1422,4 +1422,30 @@ declare namespace Log {
|
|
|
1422
1422
|
function create(tags?: Record<string, any>): Logger;
|
|
1423
1423
|
}
|
|
1424
1424
|
|
|
1425
|
-
|
|
1425
|
+
declare namespace CliSearch {
|
|
1426
|
+
interface Item<T> {
|
|
1427
|
+
value: T;
|
|
1428
|
+
label: string;
|
|
1429
|
+
hint?: string;
|
|
1430
|
+
}
|
|
1431
|
+
interface LockedSection<T> {
|
|
1432
|
+
title: string;
|
|
1433
|
+
items: Item<T>[];
|
|
1434
|
+
hiddenCount?: number;
|
|
1435
|
+
}
|
|
1436
|
+
interface MultiselectOptions<T> {
|
|
1437
|
+
message: string;
|
|
1438
|
+
items: Item<T>[];
|
|
1439
|
+
maxVisible?: number;
|
|
1440
|
+
initialSelected?: T[];
|
|
1441
|
+
required?: boolean;
|
|
1442
|
+
lockedSection?: LockedSection<T>;
|
|
1443
|
+
}
|
|
1444
|
+
const cancelSymbol: unique symbol;
|
|
1445
|
+
function approxStringWidth(plain: string): number;
|
|
1446
|
+
function visualRowsForLine(line: string, columns: number): number;
|
|
1447
|
+
function countVisualRowsForLines(lines: string[], columns: number | undefined): number;
|
|
1448
|
+
function multiselect<T>(options: MultiselectOptions<T>): Promise<T[] | typeof cancelSymbol>;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
export { $, Archive, AsyncQueue, Binary, CliSearch, type CodeSpanIndex$1 as CodeSpanIndex, Color, Context, DEFAULT_LANG, type EasServer, Encode, EventLoop, type FenceSpan$1 as FenceSpan, Fetch, type FetchResponse, Filesystem, Fn, type FormatOptions, type GitResult, Glob, Grep, Identifier, Ignore, type InlineCodeState$1 as InlineCodeState, Keybind, type Lang, Lazy, Locale, Lock, Log, MIME_TYPES, Markdown, type MarkdownConfig, type MarkdownIR, type MarkdownLinkSpan, type MarkdownParseOptions, type MarkdownStyle, type MarkdownStyleSpan, type MarkdownTableMode, type MiddlewareDefinition, NamedError, type NodeSpawnObjectArgs, type NodeSpawnOptions, type NodeSpawnResult, type NodeWhichOptions, PKG, PackageRegistry, type ParseCommandResult, type ParsedFrontmatter, type ParsedVersion, PkgShell, type ProxyOptions, type RPCMethod, type RenderLink, type RenderOptions, type RequestOptions, type RouteDefinition, type SSEHandler, SUPPORTED_LANGS, Semver, type ServerOptions, SessionTitle, Shell, Slug, type StreamHandler, type StyleMarker, type TimezoneDateParts, Token, TruncateContent, type WebSocketHandler, type WebSocketRouteDefinition, Wildcard, abortAfter, abortAfterAny, addMinutesInTimezone, buildCodeSpanIndex, chunkMarkdownIR, chunkText, chunkTextByBreakResolver, convertMarkdownTables, createInlineCodeState, createPkgShell, createRESTServer, createRPCServer, createServer, createStreamingServer, createWebSocketServer, defer, detectPlatform, escapeCommandArg, escapeCommandArgSafe, extractFrontmatter, findFenceSpanAt, findLast, fn, formatDuration, formatLocalISO, formatLocalISOCompact, formatLogTime, formatLogTimeMs, formatMarkdown, getDirectory, getFileExtension, getFilename, getFilenameTruncated, getProxyConfig, getProxyUrl, getTimezoneOffset, getTimezoneParts, git, iife, isSafeFenceBreak, isValidTimezone, joinCommandArgs, lazy, lazyAsync, loadEnv, loadTextFile, loadTextFileAsync, markdownToIR, markdownToIRWithMeta, needsShellExecution, normalizeTimezone, now, nowLocalISO, parseCommand, parseCommandWithOptions, parseFenceSpans, parseFrontmatterBlock, parseLocalISO, parseModelId, proxied, readableStreamToText, renderMarkdown, renderMarkdownWithMarkers, resolveLocaleLang, retry, scanParenAwareBreakpoints, serializeFrontmatter, shell, signal, startServer, truncateMiddle, updateSchema, whichSync, withTimeout, work };
|
package/dist/index.d.ts
CHANGED
|
@@ -1422,4 +1422,30 @@ declare namespace Log {
|
|
|
1422
1422
|
function create(tags?: Record<string, any>): Logger;
|
|
1423
1423
|
}
|
|
1424
1424
|
|
|
1425
|
-
|
|
1425
|
+
declare namespace CliSearch {
|
|
1426
|
+
interface Item<T> {
|
|
1427
|
+
value: T;
|
|
1428
|
+
label: string;
|
|
1429
|
+
hint?: string;
|
|
1430
|
+
}
|
|
1431
|
+
interface LockedSection<T> {
|
|
1432
|
+
title: string;
|
|
1433
|
+
items: Item<T>[];
|
|
1434
|
+
hiddenCount?: number;
|
|
1435
|
+
}
|
|
1436
|
+
interface MultiselectOptions<T> {
|
|
1437
|
+
message: string;
|
|
1438
|
+
items: Item<T>[];
|
|
1439
|
+
maxVisible?: number;
|
|
1440
|
+
initialSelected?: T[];
|
|
1441
|
+
required?: boolean;
|
|
1442
|
+
lockedSection?: LockedSection<T>;
|
|
1443
|
+
}
|
|
1444
|
+
const cancelSymbol: unique symbol;
|
|
1445
|
+
function approxStringWidth(plain: string): number;
|
|
1446
|
+
function visualRowsForLine(line: string, columns: number): number;
|
|
1447
|
+
function countVisualRowsForLines(lines: string[], columns: number | undefined): number;
|
|
1448
|
+
function multiselect<T>(options: MultiselectOptions<T>): Promise<T[] | typeof cancelSymbol>;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
export { $, Archive, AsyncQueue, Binary, CliSearch, type CodeSpanIndex$1 as CodeSpanIndex, Color, Context, DEFAULT_LANG, type EasServer, Encode, EventLoop, type FenceSpan$1 as FenceSpan, Fetch, type FetchResponse, Filesystem, Fn, type FormatOptions, type GitResult, Glob, Grep, Identifier, Ignore, type InlineCodeState$1 as InlineCodeState, Keybind, type Lang, Lazy, Locale, Lock, Log, MIME_TYPES, Markdown, type MarkdownConfig, type MarkdownIR, type MarkdownLinkSpan, type MarkdownParseOptions, type MarkdownStyle, type MarkdownStyleSpan, type MarkdownTableMode, type MiddlewareDefinition, NamedError, type NodeSpawnObjectArgs, type NodeSpawnOptions, type NodeSpawnResult, type NodeWhichOptions, PKG, PackageRegistry, type ParseCommandResult, type ParsedFrontmatter, type ParsedVersion, PkgShell, type ProxyOptions, type RPCMethod, type RenderLink, type RenderOptions, type RequestOptions, type RouteDefinition, type SSEHandler, SUPPORTED_LANGS, Semver, type ServerOptions, SessionTitle, Shell, Slug, type StreamHandler, type StyleMarker, type TimezoneDateParts, Token, TruncateContent, type WebSocketHandler, type WebSocketRouteDefinition, Wildcard, abortAfter, abortAfterAny, addMinutesInTimezone, buildCodeSpanIndex, chunkMarkdownIR, chunkText, chunkTextByBreakResolver, convertMarkdownTables, createInlineCodeState, createPkgShell, createRESTServer, createRPCServer, createServer, createStreamingServer, createWebSocketServer, defer, detectPlatform, escapeCommandArg, escapeCommandArgSafe, extractFrontmatter, findFenceSpanAt, findLast, fn, formatDuration, formatLocalISO, formatLocalISOCompact, formatLogTime, formatLogTimeMs, formatMarkdown, getDirectory, getFileExtension, getFilename, getFilenameTruncated, getProxyConfig, getProxyUrl, getTimezoneOffset, getTimezoneParts, git, iife, isSafeFenceBreak, isValidTimezone, joinCommandArgs, lazy, lazyAsync, loadEnv, loadTextFile, loadTextFileAsync, markdownToIR, markdownToIRWithMeta, needsShellExecution, normalizeTimezone, now, nowLocalISO, parseCommand, parseCommandWithOptions, parseFenceSpans, parseFrontmatterBlock, parseLocalISO, parseModelId, proxied, readableStreamToText, renderMarkdown, renderMarkdownWithMarkers, resolveLocaleLang, retry, scanParenAwareBreakpoints, serializeFrontmatter, shell, signal, startServer, truncateMiddle, updateSchema, whichSync, withTimeout, work };
|
package/dist/index.mjs
CHANGED
|
@@ -1,66 +1,69 @@
|
|
|
1
|
-
export{a as Lock}from'./chunks/chunk-EWRFKUXM.mjs';import {b,D,a,G,c as c$1}from'./chunks/chunk-WW6DVU53.mjs';export{H as $,j as HTTPException,d as Hono,c as Lazy,D as PKG,A as PkgShell,G as Shell,g as compress,e as cors,s as createNodeWebSocket,B as createPkgShell,p as createRESTServer,n as createRPCServer,m as createServer,r as createStreamingServer,q as createWebSocketServer,y as detectPlatform,w as escapeCommandArg,x as escapeCommandArgSafe,z as joinCommandArgs,a as lazy,b as lazyAsync,f as logger,u as needsShellExecution,t as parseCommand,v as parseCommandWithOptions,E as readableStreamToText,h as secureHeaders,C as shell,o as startServer,i as timeout,k as validator,F as whichSync,l as zValidator}from'./chunks/chunk-WW6DVU53.mjs';import {d,b as b$2,a as a$1}from'./chunks/chunk-6BCTOX3Z.mjs';export{d as Filesystem,b as Glob,c as MIME_TYPES,a as Wildcard}from'./chunks/chunk-6BCTOX3Z.mjs';import {m,b as b$1}from'./chunks/chunk-DELWLFU5.mjs';export{m as Log,o as PackageRegistry,n as Semver,l as addMinutesInTimezone,a as formatLocalISO,b as formatLocalISOCompact,f as formatLogTime,g as formatLogTimeMs,h as getTimezoneOffset,i as getTimezoneParts,j as isValidTimezone,k as normalizeTimezone,c as now,d as nowLocalISO,e as parseLocalISO}from'./chunks/chunk-DELWLFU5.mjs';import {f,c,d as d$1}from'./chunks/chunk-MHARKEDN.mjs';import
|
|
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
|
|
1
|
+
export{a as Lock}from'./chunks/chunk-EWRFKUXM.mjs';import {b,D,a,G,c as c$1}from'./chunks/chunk-WW6DVU53.mjs';export{H as $,j as HTTPException,d as Hono,c as Lazy,D as PKG,A as PkgShell,G as Shell,g as compress,e as cors,s as createNodeWebSocket,B as createPkgShell,p as createRESTServer,n as createRPCServer,m as createServer,r as createStreamingServer,q as createWebSocketServer,y as detectPlatform,w as escapeCommandArg,x as escapeCommandArgSafe,z as joinCommandArgs,a as lazy,b as lazyAsync,f as logger,u as needsShellExecution,t as parseCommand,v as parseCommandWithOptions,E as readableStreamToText,h as secureHeaders,C as shell,o as startServer,i as timeout,k as validator,F as whichSync,l as zValidator}from'./chunks/chunk-WW6DVU53.mjs';import {d,b as b$2,a as a$1}from'./chunks/chunk-6BCTOX3Z.mjs';export{d as Filesystem,b as Glob,c as MIME_TYPES,a as Wildcard}from'./chunks/chunk-6BCTOX3Z.mjs';import {m,b as b$1}from'./chunks/chunk-DELWLFU5.mjs';export{m as Log,o as PackageRegistry,n as Semver,l as addMinutesInTimezone,a as formatLocalISO,b as formatLocalISOCompact,f as formatLogTime,g as formatLogTimeMs,h as getTimezoneOffset,i as getTimezoneParts,j as isValidTimezone,k as normalizeTimezone,c as now,d as nowLocalISO,e as parseLocalISO}from'./chunks/chunk-DELWLFU5.mjs';import {f,c,d as d$1}from'./chunks/chunk-MHARKEDN.mjs';import ve from'fs/promises';import Fe,{z}from'zod';import {randomBytes}from'crypto';import {config}from'dotenv';import ot,{dirname,join}from'path';import {existsSync,readdirSync,statSync}from'fs';import {xdgConfig}from'xdg-basedir';import {fileURLToPath}from'url';import er from'markdown-it';import Yt from'yaml';import {ProxyAgent,getGlobalDispatcher,setGlobalDispatcher}from'undici';import {AsyncLocalStorage}from'async_hooks';import*as Ue from'readline';import {stripVTControlCharacters}from'util';import {Writable}from'stream';import T from'picocolors';f();f();function Cn(t,e){for(let n=t.length-1;n>=0;n-=1){let r=t[n];if(r!==void 0&&e(r,n,t))return r}}f();var Ke;(n=>{function t(r,o,a){let c=0,s=r.length-1;for(;c<=s;){let l=Math.floor((c+s)/2),p=r[l];if(p===void 0)break;let u=a(p);if(u===o)return {found:true,index:l};u<o?c=l+1:s=l-1;}return {found:false,index:c}}n.search=t;function e(r,o,a){let c=a(o),s=0,l=r.length;for(;s<l;){let p=Math.floor((s+l)/2),u=r[p];if(u===void 0)break;a(u)<c?s=p+1:l=p;}return r.splice(s,0,o),r}n.insert=e;})(Ke||(Ke={}));f();var Je;(a=>{function t(c){let s=new TextEncoder().encode(c),l=Array.from(s,p=>String.fromCharCode(p)).join("");return btoa(l).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}a.base64Encode=t;function e(c){let s=atob(c.replace(/-/g,"+").replace(/_/g,"/")),l=Uint8Array.from(s,p=>p.charCodeAt(0));return new TextDecoder().decode(l)}a.base64Decode=e;async function n(c,s="SHA-256"){let p=new TextEncoder().encode(c),u=await crypto.subtle.digest(s,p);return Array.from(new Uint8Array(u)).map(f=>f.toString(16).padStart(2,"0")).join("")}a.hash=n;function r(c){if(!c)return;let s=2166136261;for(let l=0;l<c.length;l++)s^=c.charCodeAt(l),s=Math.imul(s,16777619);return (s>>>0).toString(36)}a.checksum=r;function o(c,s=5e5){if(!c)return;if(c.length<=s)return r(c);let l=4096,u=[0,Math.floor(c.length*.25),Math.floor(c.length*.5),Math.floor(c.length*.75),c.length-l].map(d=>{let m=Math.max(0,Math.min(c.length-l,d-Math.floor(l/2)));return r(c.slice(m,m+l))??""}).join(":");return `${c.length}:${u}`}a.sampledChecksum=o;})(Je||(Je={}));f();f();var ne;(d=>{let t={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 e(m){return Fe.string().startsWith(t[m])}d.schema=e;let n=26,r=0,o=0;function a(m,f){return s(m,false,f)}d.ascending=a;function c(m,f){return s(m,true,f)}d.descending=c;function s(m,f,g){if(!g)return p(m,f);if(!g.startsWith(t[m]))throw new Error(`ID ${g} does not start with ${t[m]}`);return g}function l(m){let f="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",g="",S=randomBytes(m);for(let i=0;i<m;i++){let b=S[i];b!==void 0&&(g+=f[b%62]);}return g}function p(m,f,g){let S=g??Date.now();S!==r&&(r=S,o=0),o++;let i=BigInt(S)*BigInt(4096)+BigInt(o);i=f?~i:i;let b=Buffer.alloc(6);for(let O=0;O<6;O++)b[O]=Number(i>>BigInt(40-8*O)&BigInt(255));return t[m]+"_"+b.toString("hex")+l(n-12)}d.create=p;function u(m){let f=m.split("_")[0];if(!f)return 0;let g=m.slice(f.length+1,f.length+13),S=BigInt("0x"+g);return Number(S/BigInt(4096))}d.timestamp=u;})(ne||(ne={}));var Ze;(p=>{p.DEFAULT_MAX_CHARS=4e3,p.DIRECTION="head",p.DIR=d.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),p.GLOB=d.join(p.DIR,"*");let o=10080*60*1e3;function a(u,d,m){return m?`[Content truncated. Source: ${m}
|
|
2
|
+
Full ${d} saved to: ${u}
|
|
3
|
+
Use Read tool with offset/limit parameters to view specific sections.]`:`[Content truncated. Full ${d} saved to: ${u}
|
|
4
|
+
Use Read tool with offset/limit parameters to view specific sections.]`}async function c(u,d$1={}){let m=d$1.maxChars??4e3,f=d$1.direction??p.DIRECTION,g=d$1.label??"content",S=d$1.sourcePath,i=d.join(process.env.EASBOT_DATA_PATH??`${process.cwd()}/data`,"context-output"),b=d$1.dir??i;if(u.length<=m)return {content:u,truncated:false};let O=ne.ascending("context"),F=d.join(b,O);await ve.mkdir(b,{recursive:true}).catch(()=>{}),await ve.writeFile(F,u,"utf-8");let q=u.length-m,L;f==="head"?L=u.slice(0,m):L=u.slice(-m);let A=a(F,g,S),z=`${q} characters truncated`;return {content:f==="head"?`${L}
|
|
5
5
|
|
|
6
|
-
...${
|
|
6
|
+
...${z}...
|
|
7
7
|
|
|
8
|
-
${
|
|
8
|
+
${A}`:`...${z}...
|
|
9
9
|
|
|
10
|
-
${
|
|
10
|
+
${A}
|
|
11
11
|
|
|
12
|
-
${L}`,truncated:true,outputPath:F,originalLength:
|
|
13
|
-
`):e;for(let r=0;r<n.length;r++){let o=n[r];this.parseRule(o,r+1);}return this}parseRule(e,n){let r=e,o=e;if(r.length===0||r.startsWith("#"))return;let
|
|
12
|
+
${L}`,truncated:true,outputPath:F,originalLength:u.length,removedLength:q,label:g}}p.truncate=c;function s(u){return u.truncated?a(u.outputPath,u.label):""}p.formatHint=s;async function l(){let u=ne.timestamp(ne.create("context",false,Date.now()-o)),m=(await ve.readdir(p.DIR).catch(()=>[])).filter(f=>f.startsWith("context_"));for(let f of m)ne.timestamp(f)>=u||await ve.unlink(d.join(p.DIR,f)).catch(()=>{});}p.cleanup=l;})(Ze||(Ze={}));f();var Qe;(s=>{let t="New session - ",e="Child session - ";s.parentTitlePrefix=t,s.childTitlePrefix=e;function o(l=false){return (l?e:t)+b$1(new Date)}s.createDefault=o;function a(l){return new RegExp(`^(${t}|${e})\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[+-]\\d{2}:\\d{2}$`).test(l)}s.isDefault=a;function c(l){let p=l.match(/^(.+) \(fork #(\d+)\)$/);if(p){let u=p[1]??"",d=parseInt(p[2]??"0",10);return `${u} (fork #${d+1})`}return `${l} (fork #1)`}s.getForked=c;})(Qe||(Qe={}));f();var ye=class ye extends Error{static create(e,n){var a;let r=Fe.object({name:Fe.literal(e),data:n}).meta({ref:e}),o=(a=class extends ye{constructor(s,l){super(e,l);c(this,"data",s);c(this,"name",e);this.name=e;}static isInstance(s){return s!==null&&typeof s=="object"&&"name"in s&&s.name===e}schema(){return r}toObject(){return {name:e,data:this.data}}},c(a,"Schema",r),a);return Object.defineProperty(o,"name",{value:e}),o}};c(ye,"Unknown",ye.create("UnknownError",Fe.object({message:Fe.string()})));var et=ye;f();var tt;(e=>{function t(n){return new nt(n)}e.create=t;})(tt||(tt={}));var nt=class{constructor(e){c(this,"rules",[]);c(this,"ignorecase");c(this,"debug");this.ignorecase=e?.ignorecase??false,this.debug=e?.debug??false;}add(e){let n=typeof e=="string"?e.split(`
|
|
13
|
+
`):e;for(let r=0;r<n.length;r++){let o=n[r];this.parseRule(o,r+1);}return this}parseRule(e,n){let r=e,o=e;if(r.length===0||r.startsWith("#"))return;let a=r.startsWith("!");if(a&&(r=r.slice(1)),r=r.trim(),r.length===0||(r.startsWith("\\#")&&(r=r.slice(1)),r.startsWith("#")))return;let c=r.startsWith("/");c&&(r=r.slice(1));let s=r.endsWith("/");s&&(r=r.slice(0,-1)),r.length!==0&&this.rules.push({pattern:r,negative:a,isDirectory:s,anchored:c,original:o,lineNumber:n});}ignores(e,n){let r=this.normalizePath(e),o=n??e.endsWith("/"),a=this.checkIgnore(r,o);return this.debug&&console.log(`Ignore.ignores("${e}", isDirectory=${o}) => ${a}`),a}checkIgnore(e,n){let r=false;for(let o of this.rules)o.isDirectory&&!n||this.matchPath(o,e)&&(o.negative?r=false:r=true);return r}matchPath(e,n){let r=this.ignorecase?n.toLowerCase():n,a=this.ignorecase?e.pattern.toLowerCase():e.pattern;if(e.anchored)return a$1.match(r,a);if(a.includes("/"))return a$1.match(r,a);let c=r.split("/");for(let s of c)if(a$1.match(s,a))return true;return false}filter(e){return e.filter(n=>!this.ignores(n))}createFilter(){return e=>!this.ignores(e)}normalizePath(e){let n=e.replace(/\\/g,"/");if(n==="/")return "";for(;n.startsWith("./");)n=n.slice(2);return n.endsWith("/")&&n.length>1&&(n=n.slice(0,-1)),n}};f();function Et(t,e){let n=r=>{let o;try{o=t.parse(r);}catch(a){throw console.trace("schema validation failure stack trace:"),a instanceof z.ZodError&&console.error("schema validation issues:",JSON.stringify(a.issues,null,2)),a}return e(o)};return n.force=r=>e(r),n.schema=t,n}var $n=Et,rt;(e=>e.fn=Et)(rt||(rt={}));f();function zn(t={}){let e=t.isDevelopment??false,n=e?".env.dev":".env",r=t.globalConfigPath??(xdgConfig?ot.join(xdgConfig,"easbot"):void 0),o=t.projectRoot??process.cwd(),a=o?ot.join(o,".easbot"):void 0,c=[{root:r,label:"global"},{root:o,label:"project"},{root:a,label:"workspace"}];for(let{root:s}of c){if(!s)continue;let l=ot.join(s,n);if(!existsSync(l))continue;let p=config({path:l,override:true,debug:e,encoding:"utf-8",quiet:!e});if(e&&p.parsed){let d=["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(m=>m in p.parsed);d.length>0&&console.warn(`[loadEnv] ${l} contains keys that have no effect: ${d.join(", ")}.
|
|
14
14
|
Reason: xdg-basedir caches XDG_* on import, so this .env file loads too late.
|
|
15
|
-
How to override: export them in the shell before loadEnv() runs, or set process.env directly.`);}}}f();async function
|
|
16
|
-
`?o=s:/\s/.test(l)&&(
|
|
15
|
+
How to override: export them in the shell before loadEnv() runs, or set process.env directly.`);}}}f();async function Bn(t,e){if(process.env.EASBOT_CLIENT==="acp")try{let a=process.platform==="win32"?"cmd":void 0,c=G.spawn(a,`git ${t.join(" ")}`,{stdin:void 0,stdout:"pipe",stderr:"pipe",cwd:e.cwd,env:e.env?{...process.env,...e.env}:process.env}),[s,l,p]=await Promise.all([c.exited,new Response(c.stdout).arrayBuffer(),new Response(c.stderr).arrayBuffer()]),u=Buffer.from(l),d=Buffer.from(p);return {exitCode:s,text:()=>u.toString(),stdout:u,stderr:d}}catch(a){let c=Buffer.from(a instanceof Error?a.message:String(a));return {exitCode:1,text:()=>"",stdout:Buffer.alloc(0),stderr:c}}let n=e.env?{...process.env,...e.env}:void 0,r=G.$`git ${t.join(" ")}`.quiet().nothrow().cwd(e.cwd);n&&(r=r.env(n));let o=await r;return {exitCode:o.exitCode,text:()=>o.text(),stdout:o.stdout,stderr:o.stderr}}f();function _t(t){return t?dirname(fileURLToPath(t)):typeof d$1<"u"?d$1:process.cwd()}function Ct(t,e,n=3){function r(o,a){if(a>n||!existsSync(o))return null;try{let c=readdirSync(o);for(let s of c){let l=join(o,s);try{let p=statSync(l);if(p.isFile()&&l.endsWith(e))return l;if(p.isDirectory()&&a<n){let u=r(l,a+1);if(u)return u}}catch{}}}catch{}return null}return r(t,0)}function Lt(t,e){let n=join(t,e);if(existsSync(n))return n;let r=e.split("/").pop()||e,o=t;for(let a=0;a<5;a++){let c=join(o,"assets","txt");if(existsSync(c)){let p=Ct(c,r,5);if(p)return p}let s=join(o,"dist","assets","txt");if(existsSync(s)){let p=Ct(s,r,5);if(p)return p}let l=join(o,"..");if(l===o)break;o=l;}return n}function qn(t,e){return c$1.lazy(()=>{try{let n=_t(e),r=Lt(n,t);return D.file(r).textSync()}catch(n){throw console.error(`Failed to load text file: ${t}`,n),n}})}function Gn(t,e){return c$1.lazy(async()=>{try{let n=_t(e),r=Lt(n,t);return await D.file(r).text()}catch(n){throw console.error(`Failed to load text file: ${t}`,n),n}})}f();function Yn(t){return t()}f();function Vn(t){if(!t||typeof t!="string")return {provider:"",model:""};let e=t.indexOf("/");return e===-1?{provider:"",model:t}:{provider:t.substring(0,e),model:t.substring(e+1)}}f();f();f();function st(t,e,n,r=()=>true){let o=-1,a=-1,c=0;for(let s=e;s<n;s++){if(!r(s))continue;let l=t[s];if(l){if(l==="("){c+=1;continue}if(l===")"&&c>0){c-=1;continue}c===0&&(l===`
|
|
16
|
+
`?o=s:/\s/.test(l)&&(a=s));}}return {lastNewline:o,lastWhitespace:a}}function Xn(t,e){if(!t)return [];if(e<=0)return [t];if(t.length<=e)return [t]}function ce(t,e,n){try{let r=z.string().parse(t),o=z.number().int().parse(e),a=Xn(r,o);if(a)return a;let c=it(r,o,s=>{let{lastNewline:l,lastWhitespace:p}=st(s,0,s.length);return l>0?l:p});return n?.minLength&&n.minLength>0&&(c=$t(c,n.minLength)),c}catch(r){return console.warn("Invalid input for chunkText:",r),typeof t=="string"&&t.length>0?[t]:[]}}function $t(t,e){if(t.length<=1||e<=0)return t;let n=[],r=t[0]??"";for(let o=1;o<t.length;o++){let a=t[o]??"";r.length<e?r=r+`
|
|
17
17
|
|
|
18
|
-
`+
|
|
18
|
+
`+a:(n.push(r),r=a);}if(r.length>0)if(r.length<e&&n.length>0){let o=n.pop();n.push(o+`
|
|
19
19
|
|
|
20
|
-
`+r);}else n.push(r);return n}function
|
|
20
|
+
`+r);}else n.push(r);return n}function it(t,e,n){if(!t)return [];if(e<=0||t.length<=e)return [t];let r=[],o=t;for(;o.length>e;){let a=o.slice(0,e),c=n(a),s=Number.isFinite(c)&&c>0&&c<=e?c:e,p=o.slice(0,s).trimEnd();p.length>0&&r.push(p);let u=s<o.length&&o[s]!==void 0&&/\s/.test(o[s]),d=Math.min(o.length,s+(u?1:0));o=o.slice(d).trimStart();}return o.length>0&&r.push(o),r}f();var at=z.enum(["bold","italic","strikethrough","code","code_block","spoiler","blockquote"]),Dt=z.object({start:z.number().int().min(0),end:z.number().int().min(0),style:at}).strict().refine(t=>t.end>=t.start,{message:"end must be greater than or equal to start"}),Nt=z.object({start:z.number().int().min(0),end:z.number().int().min(0),href:z.string().min(1)}).strict().refine(t=>t.end>=t.start,{message:"end must be greater than or equal to start"}),we=z.object({text:z.string(),styles:z.array(Dt),links:z.array(Nt)}).strict(),Se=z.enum(["off","bullets","code"]),_e=z.object({linkify:z.boolean().default(true),enableSpoilers:z.boolean().default(false),headingStyle:z.enum(["none","bold"]).default("none"),blockquotePrefix:z.string().default(""),autolink:z.boolean().default(true),tableMode:Se.default("off")}).partial().default({}),zt=z.object({open:z.string(),close:z.string()}).strict(),ct=z.object({styleMarkers:z.record(at,zt).optional(),escapeText:z.any().optional(),buildLink:z.any().optional()}).strict();z.object({start:z.number().int().min(0),end:z.number().int().min(0),open:z.string(),close:z.string()}).strict();var lt=z.object({indentSize:z.number().int().min(1).default(2),listMarker:z.enum(["\u2022","-","*"]).default("\u2022"),codeBlockMarker:z.enum(["```","~~~"]).default("```"),preserveFrontmatter:z.boolean().default(true)}).strict(),ut=z.record(z.string(),z.string()),Le=z.object({open:z.boolean(),ticks:z.number().int().min(0)}).strict();z.object({inlineState:Le,isInside:z.any()}).strict();z.object({start:z.number().int().min(0),end:z.number().int().min(0),openLine:z.string(),marker:z.string(),indent:z.string()}).strict();z.object({tables:Se.optional()}).strict();function tr(t){let e=new er({html:false,linkify:t.linkify??true,breaks:false,typographer:false});return e.enable("strikethrough"),t.tableMode&&t.tableMode!=="off"?e.enable("table"):e.disable("table"),t.autolink===false&&e.disable("autolink"),e}function Bt(t,e){if(t.attrGet)return t.attrGet(e);if(t.attrs){for(let[n,r]of t.attrs)if(n===e)return r}return null}function dt(t,e){return {...t,type:"text",content:e,children:void 0}}function nr(t){for(let e of t)e.children&&e.children.length>0&&(e.children=rr(e.children));}function rr(t){let e=0;for(let c of t){if(c.type!=="text")continue;let s=c.content??"",l=0;for(;l<s.length;){let p=s.indexOf("||",l);if(p===-1)break;e+=1,l=p+2;}}if(e<2)return t;let n=e-e%2,r=[],o={spoilerOpen:false},a=0;for(let c of t){if(c.type!=="text"){r.push(c);continue}let s=c.content??"";if(!s.includes("||")){r.push(c);continue}let l=0;for(;l<s.length;){let p=s.indexOf("||",l);if(p===-1){l<s.length&&r.push(dt(c,s.slice(l)));break}if(a>=n){r.push(dt(c,s.slice(l)));break}p>l&&r.push(dt(c,s.slice(l,p))),a+=1,o.spoilerOpen=!o.spoilerOpen,r.push({type:o.spoilerOpen?"spoiler_open":"spoiler_close"}),l=p+2;}}return r}function or(){return {text:"",styles:[],openStyles:[],links:[],linkStack:[]}}function ie(t){return t.table?.currentCell??t}function Ae(t,e){if(!e)return;let n=ie(t);n.text+=e;}function le(t,e){let n=ie(t);n.openStyles.push({style:e,start:n.text.length});}function ue(t,e){let n=ie(t);for(let r=n.openStyles.length-1;r>=0;r-=1){let o=n.openStyles[r];if(o?.style===e){let a=o.start;n.openStyles.splice(r,1);let c=n.text.length;c>a&&n.styles.push({start:a,end:c,style:e});return}}}function jt(t){t.env.listStack.length>0||t.table||(t.text+=`
|
|
21
21
|
|
|
22
|
-
`);}function
|
|
23
|
-
`);}function
|
|
24
|
-
`;}for(let
|
|
25
|
-
`;}else for(let o of n){for(let
|
|
26
|
-
`;}}function
|
|
27
|
-
`;},l=()=>{t.text+="|";for(let
|
|
28
|
-
`;};s(e),l();for(let
|
|
29
|
-
`);break;case "paragraph_close":
|
|
22
|
+
`);}function sr(t){let e=t.env.listStack,n=e[e.length-1];if(!n)return;n.index+=1;let r=" ".repeat(Math.max(0,e.length-1)),o=n.type==="ordered"?`${n.index}. `:"\u2022 ";t.text+=`${r}${o}`;}function ir(t,e){if(!e)return;let n=ie(t),r=n.text.length;n.text+=e,n.styles.push({start:r,end:r+e.length,style:"code"});}function ar(t,e){let n=e??"",r=ie(t),o=r.text.length;r.text+=n,r.styles.push({start:o,end:o+n.length,style:"code_block"});}function cr(t){let e=ie(t),n=e.linkStack.pop();if(!n?.href)return;let r=n.href.trim();if(!r)return;let o=n.labelStart,a=e.text.length;if(a<=o){e.links.push({start:o,end:a,href:r});return}e.links.push({start:o,end:a,href:r});}function lr(){return {headers:[],rows:[],currentRow:[],currentCell:null,inHeader:false}}function ur(t){return Ht(t),{text:t.text,styles:t.styles,links:t.links}}function $e(t){let e=t.text,n=0,r=e.length;for(;n<r&&/\s/.test(e[n]??"");)n+=1;for(;r>n&&/\s/.test(e[r-1]??"");)r-=1;if(n===0&&r===e.length)return t;let o=e.slice(n,r),a=o.length,c=[];for(let l of t.styles){let p=Math.max(0,l.start-n),u=Math.min(a,l.end-n);u>p&&c.push({start:p,end:u,style:l.style});}let s=[];for(let l of t.links){let p=Math.max(0,l.start-n),u=Math.min(a,l.end-n);u>p&&s.push({start:p,end:u,href:l.href});}return {text:o,styles:c,links:s}}function ft(t,e){if(!e.text)return;let n=t.text.length;t.text+=e.text;for(let r of e.styles)t.styles.push({start:n+r.start,end:n+r.end,style:r.style});for(let r of e.links)t.links.push({start:n+r.start,end:n+r.end,href:r.href});}function dr(t,e){e.text&&(t.text+=e.text);}function Wt(t,e){let{header:n,value:r,columnIndex:o,includeColumnFallback:a}=e;r?.text&&(t.text+="\u2022 ",n?.text?(ft(t,n),t.text+=": "):a&&(t.text+=`Column ${o}: `),ft(t,r),t.text+=`
|
|
23
|
+
`);}function fr(t){if(!t.table)return;let e=t.table.headers.map($e),n=t.table.rows.map(o=>o.map($e));if(e.length===0&&n.length===0)return;if(e.length>1&&n.length>0)for(let o of n){if(o.length===0)continue;let a=o[0];if(a?.text){let c=t.text.length;ft(t,a);let s=t.text.length;s>c&&t.styles.push({start:c,end:s,style:"bold"}),t.text+=`
|
|
24
|
+
`;}for(let c=1;c<o.length;c++)Wt(t,{header:e[c],value:o[c],columnIndex:c,includeColumnFallback:true});t.text+=`
|
|
25
|
+
`;}else for(let o of n){for(let a=0;a<o.length;a++)Wt(t,{header:e[a],value:o[a],columnIndex:a,includeColumnFallback:false});t.text+=`
|
|
26
|
+
`;}}function pr(t){if(!t.table)return;let e=t.table.headers.map($e),n=t.table.rows.map(u=>u.map($e)),r=Math.max(e.length,...n.map(u=>u.length));if(r===0)return;let o=Array.from({length:r},()=>0),a=u=>{for(let d=0;d<r;d+=1){let f=u[d]?.text.length??0;(o[d]??0)<f&&(o[d]=f);}};a(e);for(let u of n)a(u);let c=t.text.length,s=u=>{t.text+="|";for(let d=0;d<r;d+=1){t.text+=" ";let m=u[d];m&&dr(t,m);let f=m?.text.length??0,S=(o[d]??0)-f;S>0&&(t.text+=" ".repeat(S)),t.text+=" |";}t.text+=`
|
|
27
|
+
`;},l=()=>{t.text+="|";for(let u=0;u<r;u+=1){let d=o[u]??0,m=Math.max(3,d);t.text+=` ${"-".repeat(m)} |`;}t.text+=`
|
|
28
|
+
`;};s(e),l();for(let u of n)s(u);let p=t.text.length;p>c&&t.styles.push({start:c,end:p,style:"code_block"});}function pt(t,e){for(let n of t)switch(n.type){case "inline":n.children&&pt(n.children,e);break;case "text":Ae(e,n.content??"");break;case "em_open":le(e,"italic");break;case "em_close":ue(e,"italic");break;case "strong_open":le(e,"bold");break;case "strong_close":ue(e,"bold");break;case "s_open":le(e,"strikethrough");break;case "s_close":ue(e,"strikethrough");break;case "code_inline":ir(e,n.content??"");break;case "spoiler_open":e.enableSpoilers&&le(e,"spoiler");break;case "spoiler_close":e.enableSpoilers&&ue(e,"spoiler");break;case "link_open":{let r=Bt(n,"href")??"",o=ie(e);o.linkStack.push({href:r,labelStart:o.text.length});break}case "link_close":cr(e);break;case "image":Ae(e,n.content??"");break;case "softbreak":case "hardbreak":Ae(e,`
|
|
29
|
+
`);break;case "paragraph_close":jt(e);break;case "heading_open":e.headingStyle==="bold"&&le(e,"bold");break;case "heading_close":e.headingStyle==="bold"&&ue(e,"bold"),jt(e);break;case "blockquote_open":e.blockquotePrefix&&(e.text+=e.blockquotePrefix),le(e,"blockquote");break;case "blockquote_close":ue(e,"blockquote");break;case "bullet_list_open":e.env.listStack.length>0&&(e.text+=`
|
|
30
30
|
`),e.env.listStack.push({type:"bullet",index:0});break;case "bullet_list_close":e.env.listStack.pop(),e.env.listStack.length===0&&(e.text+=`
|
|
31
31
|
`);break;case "ordered_list_open":{e.env.listStack.length>0&&(e.text+=`
|
|
32
|
-
`);let r=Number(
|
|
33
|
-
`);break;case "list_item_open":
|
|
32
|
+
`);let r=Number(Bt(n,"start")??"1");e.env.listStack.push({type:"ordered",index:r-1});break}case "ordered_list_close":e.env.listStack.pop(),e.env.listStack.length===0&&(e.text+=`
|
|
33
|
+
`);break;case "list_item_open":sr(e);break;case "list_item_close":e.text.endsWith(`
|
|
34
34
|
`)||(e.text+=`
|
|
35
|
-
`);break;case "code_block":case "fence":
|
|
35
|
+
`);break;case "code_block":case "fence":ar(e,n.content??"");break;case "html_block":case "html_inline":Ae(e,n.content??"");break;case "table_open":e.tableMode!=="off"&&(e.table=lr(),e.hasTables=true);break;case "table_close":e.table&&(e.tableMode==="bullets"?fr(e):e.tableMode==="code"&&pr(e)),e.table=null;break;case "thead_open":e.table&&(e.table.inHeader=true);break;case "thead_close":e.table&&(e.table.inHeader=false);break;case "tbody_open":case "tbody_close":break;case "tr_open":e.table&&(e.table.currentRow=[]);break;case "tr_close":e.table&&(e.table.inHeader?e.table.headers=e.table.currentRow:e.table.rows.push(e.table.currentRow),e.table.currentRow=[]);break;case "th_open":case "td_open":e.table&&(e.table.currentCell=or());break;case "th_close":case "td_close":e.table?.currentCell&&(e.table.currentRow.push(ur(e.table.currentCell)),e.table.currentCell=null);break;case "hr":e.text+=`\u2500\u2500\u2500
|
|
36
36
|
|
|
37
|
-
`;break;default:n.children&&
|
|
38
|
-
`);let
|
|
37
|
+
`;break;default:n.children&&pt(n.children,e);break}}function Ht(t){for(let e=t.openStyles.length-1;e>=0;e-=1){let n=t.openStyles[e];if(!n)continue;let r=t.text.length;r>n.start&&t.styles.push({start:n.start,end:r,style:n.style});}t.openStyles=[];}function mr(t,e){let n=[];for(let r of t){let o=Math.max(0,Math.min(r.start,e)),a=Math.max(o,Math.min(r.end,e));a>o&&n.push({start:o,end:a,style:r.style});}return n}function hr(t,e){let n=[];for(let r of t){let o=Math.max(0,Math.min(r.start,e)),a=Math.max(o,Math.min(r.end,e));a>o&&n.push({start:o,end:a,href:r.href});}return n}function Ut(t){let e=[...t].toSorted((r,o)=>r.start!==o.start?r.start-o.start:r.end!==o.end?r.end-o.end:r.style.localeCompare(o.style)),n=[];for(let r of e){let o=n[n.length-1];if(o&&o.style===r.style&&(r.start<o.end||r.start===o.end&&r.style!=="blockquote")){o.end=Math.max(o.end,r.end);continue}n.push({...r});}return n}function qt(t,e,n){let r=Math.max(t.start,e),o=Math.min(t.end,n);return o<=r?null:{start:r,end:o}}function gr(t,e,n){if(t.length===0)return [];let r=[];for(let o of t){let a=qt(o,e,n);a&&r.push({start:a.start-e,end:a.end-e,style:o.style});}return Ut(r)}function br(t,e,n){if(t.length===0)return [];let r=[];for(let o of t){let a=qt(o,e,n);a&&r.push({start:a.start-e,end:a.end-e,href:o.href});}return r}function de(t,e){try{let n=typeof t=="string"?t:"",r=_e.parse(e??{});return Te(n,r).ir}catch(n){return console.error("Markdown parse error:",n),{text:"",styles:[],links:[]}}}function Te(t,e){try{let n=typeof t=="string"?t:"",r=_e.parse(e),o={listStack:[]},c=tr(r).parse(n||"",o);r.enableSpoilers&&nr(c);let s=r.tableMode??"off",l={text:"",styles:[],openStyles:[],links:[],linkStack:[],env:o,headingStyle:r.headingStyle??"none",blockquotePrefix:r.blockquotePrefix??"",enableSpoilers:r.enableSpoilers??!1,tableMode:s,table:null,hasTables:!1};pt(c,l),Ht(l);let u=l.text.trimEnd().length,d=0;for(let g of l.styles)g.style==="code_block"&&g.end>d&&(d=g.end);let m=Math.max(u,d);return {ir:{text:m===l.text.length?l.text:l.text.slice(0,m),styles:Ut(mr(l.styles,m)),links:hr(l.links,m)},hasTables:l.hasTables}}catch(n){return console.error("Markdown parse error:",n),{ir:{text:"",styles:[],links:[]},hasTables:false}}}function Gt(t,e){try{let n=we.parse(t),r=typeof e=="number"&&e>0?e:0;if(!n.text)return [];if(r<=0||n.text.length<=r)return [n];let o=ce(n.text,r),a=[],c=0;return o.forEach((s,l)=>{if(!s)return;if(l>0)for(;c<n.text.length&&/\s/.test(n.text[c]??"");)c+=1;let p=c,u=Math.min(n.text.length,p+s.length);a.push({text:s,styles:gr(n.styles,p,u),links:br(n.links,p,u)}),c=u;}),a}catch(n){return console.error("Chunk IR error:",n),[]}}f();var xr={bold:{open:"**",close:"**"},italic:{open:"*",close:"*"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function Me(t,e){try{let n=we.parse(t),r=ct.parse(e??{});if(!n.text)return "";let o=r.styleMarkers??xr,a=r.escapeText??(d=>d),c=r.buildLink,s=[];for(let d=0;d<n.styles.length;d++){let m=n.styles[d];m&&(s.push({position:m.start,type:"open",style:m.style,spanIndex:d}),s.push({position:m.end,type:"close",style:m.style,spanIndex:d}));}for(let d=0;d<n.links.length;d++){let m=n.links[d];m&&(s.push({position:m.start,type:"link_open",spanIndex:d,href:m.href}),s.push({position:m.end,type:"link_close",spanIndex:d,href:m.href}));}s.sort((d,m)=>{if(d.position!==m.position)return d.position-m.position;let f=(O,F)=>O==="link_open"?0:O==="open"?1:O==="close"?2:O==="link_close"?3:4,g=d.type==="close"||d.type==="link_close",S=m.type==="close"||m.type==="link_close",i=f(d.type,g),b=f(m.type,S);return i!==b?i-b:d.type==="open"&&m.type==="open"?d.spanIndex-m.spanIndex:d.type==="close"&&m.type==="close"?m.spanIndex-d.spanIndex:d.spanIndex-m.spanIndex});let l="",p=0,u=[];for(let d of s){if(d.position>p){let m=n.text.slice(p,d.position);l+=a?a(m):m;}if(d.type==="open"||d.type==="close"){let m=o[d.style];if(m)if(d.type==="open")l+=m.open,u.push(d);else {l+=m.close,d.style==="code_block"&&d.position<n.text.length&&(l+=`
|
|
38
|
+
`);let f=u.findIndex(g=>g.spanIndex===d.spanIndex&&g.type==="open");f!==-1&&u.splice(f,1);}}else if(d.type==="link_open")l+="[",u.push(d);else if(d.type==="link_close"){l+="]("+d.href+")";let m=u.findIndex(f=>f.spanIndex===d.spanIndex&&f.type==="link_open");m!==-1&&u.splice(m,1);}p=d.position;}if(p<n.text.length){let d=n.text.slice(p);l+=a?a(d):d;}return l}catch(n){return console.error("Markdown render error:",n),""}}function fe(t,e){return Me(t,e)}f();function yr(t){let e=t.replace(/\r\n/g,`
|
|
39
39
|
`).replace(/\r/g,`
|
|
40
40
|
`);if(!e.startsWith("---"))return {frontmatter:"",content:t};let n=e.indexOf(`
|
|
41
|
-
---`,3);if(n===-1)return {frontmatter:"",content:t};let r=e.slice(0,n+4),o=e.slice(n+4).trimStart();return {frontmatter:r,content:o}}function
|
|
41
|
+
---`,3);if(n===-1)return {frontmatter:"",content:t};let r=e.slice(0,n+4),o=e.slice(n+4).trimStart();return {frontmatter:r,content:o}}function De(t,e){try{let n=typeof t=="string"?t:"",r=lt.parse(e??{});if(!n)return "";let{frontmatter:o,content:a}=yr(n),c=de(a,{linkify:!0,enableSpoilers:!1,autolink:!0,headingStyle:"none",blockquotePrefix:"",tableMode:"off"}),s=fe(c);return s=s.replace(/\n{3,}/g,`
|
|
42
42
|
|
|
43
43
|
`),s=s.trimEnd()+`
|
|
44
44
|
`,r.preserveFrontmatter&&o&&(s=o+`
|
|
45
|
-
`+s),s}catch(n){return console.error("Markdown format error:",n),t}}f();function
|
|
46
|
-
`).trim(),linesConsumed:r-e}}function
|
|
47
|
-
`),r=0;for(;r<n.length;){let o=n[r];if(!o){r+=1;continue}let
|
|
45
|
+
`+s),s}catch(n){return console.error("Markdown format error:",n),t}}f();function kr(t){return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function wr(t){if(t!=null){if(typeof t=="string")return {value:t.trim(),kind:"scalar"};if(typeof t=="number"||typeof t=="boolean")return {value:String(t),kind:"scalar"};if(typeof t=="object")try{return {value:JSON.stringify(t),kind:"structured"}}catch{return}}}function Sr(t){try{let e=Yt.parse(t,{schema:"core"});if(!e||typeof e!="object"||Array.isArray(e))return null;let n={};for(let[r,o]of Object.entries(e)){let a=r.trim();if(!a)continue;let c=wr(o);c&&(n[a]=c);}return n}catch{return null}}function Tr(t,e){let n=[],r=e+1;for(;r<t.length;){let a=t[r];if(!a){r+=1;continue}if(a.length>0&&!a.startsWith(" ")&&!a.startsWith(" "))break;n.push(a),r+=1;}return {value:n.join(`
|
|
46
|
+
`).trim(),linesConsumed:r-e}}function Mr(t){let e={},n=t.split(`
|
|
47
|
+
`),r=0;for(;r<n.length;){let o=n[r];if(!o){r+=1;continue}let a=o.match(/^([\w-]+):\s*(.*)$/);if(!a?.[1]||!a[2]){r+=1;continue}let c=a[1],s=a[2].trim();if(!c){r+=1;continue}if(!s&&r+1<n.length){let p=n[r+1];if(p&&(p.startsWith(" ")||p.startsWith(" "))){let{value:u,linesConsumed:d}=Tr(n,r);u&&(e[c]={value:u,kind:"multiline",rawInline:s}),r+=d;continue}}let l=kr(s);l&&(e[c]={value:l,kind:"inline",rawInline:s}),r+=1;}return e}function Ir(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.value;return e}function vr(t){return /^[|>][+-]?(\d+)?[+-]?$/.test(t)}function Rr(t){let{lineEntry:e,yamlValue:n}=t;return n.kind!=="structured"||e.kind!=="inline"||vr(e.rawInline)?false:e.value.includes(":")}function Pr(t){let e=t.replace(/\r\n/g,`
|
|
48
48
|
`).replace(/\r/g,`
|
|
49
49
|
`);if(!e.startsWith("---"))return;let n=e.indexOf(`
|
|
50
|
-
---`,3);if(n!==-1)return e.slice(4,n)}function
|
|
51
|
-
${
|
|
52
|
-
---`}catch(e){return console.warn("Failed to serialize frontmatter:",e),""}}function
|
|
50
|
+
---`,3);if(n!==-1)return e.slice(4,n)}function Ie(t){try{if(typeof t!="string")return {};let e=Pr(t);if(!e)return {};let n=Mr(e),r=Sr(e);if(r===null)return Ir(n);let o={};for(let[a,c]of Object.entries(r)){o[a]=c.value;let s=n[a];s&&Rr({lineEntry:s,yamlValue:c})&&(o[a]=s.value);}for(let[a,c]of Object.entries(n))a in o||(o[a]=c.value);return o}catch(e){return console.warn("Failed to parse frontmatter:",e),{}}}function Ne(t){try{let e=ut.parse(t);if(Object.keys(e).length===0)return "";let n={};for(let[o,a]of Object.entries(e))try{let c=JSON.parse(a);n[o]=c;}catch{n[o]=a;}return `---
|
|
51
|
+
${Yt.stringify(n,{lineWidth:0,defaultStringType:"QUOTE_DOUBLE"}).trim()}
|
|
52
|
+
---`}catch(e){return console.warn("Failed to serialize frontmatter:",e),""}}function ze(t){try{if(typeof t!="string")return {frontmatter:{},content:""};let e=t.replace(/\r\n/g,`
|
|
53
53
|
`).replace(/\r/g,`
|
|
54
54
|
`);if(!e.startsWith("---"))return {frontmatter:{},content:t};let n=e.indexOf(`
|
|
55
|
-
---`,3);if(n===-1)return {frontmatter:{},content:t};let r=e.slice(4,n),o=e.slice(n+4).trimStart();return {frontmatter:
|
|
56
|
-
`,o),a
|
|
57
|
-
Content-Type: ${
|
|
55
|
+
---`,3);if(n===-1)return {frontmatter:{},content:t};let r=e.slice(4,n),o=e.slice(n+4).trimStart();return {frontmatter:Ie(t),content:o}}catch(e){return console.warn("Failed to extract frontmatter:",e),{frontmatter:{},content:t}}}f();f();function Be(t){try{let e=z.string().parse(t),n=[],r,o=0;for(;o<=e.length;){let a=e.indexOf(`
|
|
56
|
+
`,o),c=a===-1?e.length:a,s=e.slice(o,c),l=s.match(/^( {0,3})(`{3,}|~{3,})(.*)$/);if(l){let p=l[1],u=l[2];if(!p||!u){o=c+1;continue}let d=u[0];if(!d){o=c+1;continue}let m=u.length;if(!r)r={start:o,markerChar:d,markerLen:m,openLine:s,marker:u,indent:p};else if(r.markerChar===d&&m>=r.markerLen){let f=c;n.push({start:r.start,end:f,openLine:r.openLine,marker:r.marker,indent:r.indent}),r=void 0;}}if(a===-1)break;o=a+1;}return r&&n.push({start:r.start,end:e.length,openLine:r.openLine,marker:r.marker,indent:r.indent}),n}catch(e){return console.warn("Invalid input for parseFenceSpans:",e),[]}}function mt(t,e){let n=0,r=t.length-1;for(;n<=r;){let o=Math.floor((n+r)/2),a=t[o];if(!a)break;if(e<=a.start){r=o-1;continue}if(e>=a.end){n=o+1;continue}return a}}function Vt(t,e){return !mt(t,e)}function je(){return {open:false,ticks:0}}function We(t,e){try{let n=z.string().parse(t),r=e?Le.parse(e):je(),o=Be(n),a={open:r.open,ticks:r.ticks},{spans:c,state:s}=Fr(n,o,a);return {inlineState:s,isInside:l=>_r(l,o)||Lr(l,c)}}catch(n){return console.warn("Invalid input for buildCodeSpanIndex:",n),{inlineState:je(),isInside:()=>false}}}function Fr(t,e,n){let r=[],o=n.open,a=n.ticks,c=o?0:-1,s=0;for(;s<t.length;){let l=Cr(e,s);if(l){s=l.end;continue}if(t[s]!=="`"){s+=1;continue}let p=s,u=0;for(;s<t.length&&t[s]==="`";)u+=1,s+=1;if(!o){o=true,a=u,c=p;continue}u===a&&(r.push([c,s]),o=false,a=0,c=-1);}return o&&r.push([c,t.length]),{spans:r,state:{open:o,ticks:a}}}function Cr(t,e){return t.find(n=>e>=n.start&&e<n.end)}function _r(t,e){return e.some(n=>t>=n.start&&t<n.end)}function Lr(t,e){return e.some(([n,r])=>t>=n&&t<r)}f();var $r={bold:{open:"**",close:"**"},italic:{open:"_",close:"_"},strikethrough:{open:"~~",close:"~~"},code:{open:"`",close:"`"},code_block:{open:"```\n",close:"```"},spoiler:{open:"||",close:"||"},blockquote:{open:"> ",close:""}};function He(t,e){try{let n=z.string().parse(t),r=Se.parse(e);if(!n||r==="off")return n;let{ir:o,hasTables:a}=Te(n,{linkify:!1,enableSpoilers:!1,autolink:!1,headingStyle:"none",blockquotePrefix:"",tableMode:r});return a?Me(o,{styleMarkers:$r,escapeText:c=>c,buildLink:(c,s)=>{let l=c.href.trim();return !l||!s.slice(c.start,c.end)?null:{start:c.start,end:c.end,open:"[",close:`](${l})`}}}):n}catch(n){return console.warn("Invalid input for convertMarkdownTables:",n),typeof t=="string"?t:""}}var ht;(p=>{function t(u,d){try{return de(u,d)}catch(m){return console.warn("Markdown.parse error:",m),{text:"",styles:[],links:[]}}}p.parse=t;function e(u,d){try{return fe(u,d)}catch(m){return console.warn("Markdown.render error:",m),""}}p.render=e;function n(u,d){try{return De(u,d)}catch(m){return console.warn("Markdown.format error:",m),typeof u=="string"?u:""}}p.format=n;function r(u){try{return Ie(u)}catch(d){return console.warn("Markdown.parseFrontmatter error:",d),{}}}p.parseFrontmatter=r;function o(u){try{return Ne(u)}catch(d){return console.warn("Markdown.serializeFrontmatter error:",d),""}}p.serializeFrontmatter=o;function a(u){try{return ze(u)}catch(d){return console.warn("Markdown.extractFrontmatter error:",d),{frontmatter:{},content:typeof u=="string"?u:""}}}p.extractFrontmatter=a;function c(u,d,m){try{return ce(u,d,m)}catch(f){return console.warn("Markdown.chunk error:",f),typeof u=="string"&&u.length>0?[u]:[]}}p.chunk=c;function s(u,d){try{return We(u,d)}catch(m){return console.warn("Markdown.buildCodeIndex error:",m),{inlineState:{open:false,ticks:0},isInside:()=>false}}}p.buildCodeIndex=s;function l(u,d){try{return He(u,d)}catch(m){return console.warn("Markdown.convertTables error:",m),typeof u=="string"?u:""}}p.convertTables=l;})(ht||(ht={}));f();function Xt(t){if(!t)return "";let n=t.replace(/[/\\]+$/,"").split(/[/\\]/);return n[n.length-1]??""}function Dr(t){if(!t)return "";let n=t.replace(/[/\\]+$/,"").split(/[/\\]/);return n.slice(0,n.length-1).join("/")+"/"}function Nr(t){if(!t)return "";let e=t.split(".");return e[e.length-1]}function zr(t,e=20){let n=Xt(t);if(n.length<=e)return n;let r=n.lastIndexOf("."),o=r<=0?"":n.slice(r),a=e-o.length-1;return a<=0?n.slice(0,e-1)+"\u2026":n.slice(0,a)+"\u2026"+o}function Br(t,e=20){if(t.length<=e)return t;let n=e-1,r=Math.ceil(n/2),o=Math.floor(n/2);return t.slice(0,r)+"\u2026"+t.slice(-o)}f();var jr=["load failed","network connection was lost","network request failed","failed to fetch","econnreset","econnrefused","etimedout","socket hang up"];function Wr(t){if(!t)return false;let e=String(t instanceof Error?t.message:t).toLowerCase();return jr.some(n=>e.includes(n))}async function gt(t,e={}){let{attempts:n=3,delay:r=500,factor:o=2,maxDelay:a=1e4,retryIf:c=Wr}=e,s;for(let l=0;l<n;l++)try{return await t()}catch(p){if(s=p,l===n-1||!c(p))throw p;let u=Math.min(r*o**l,a);await new Promise(d=>setTimeout(d,u));}throw s}f();var bt;(v=>{let t=m.create({service:"fetch"}),e=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"],n=false,r=null;function o(){return e.some(x=>{let y=process.env[x];return typeof y=="string"&&y.trim().length>0})}v.hasProxyConfigured=o;function a(){let x=process.env.http_proxy||process.env.HTTP_PROXY;return process.env.https_proxy||process.env.HTTPS_PROXY||x}v.getProxyUrl=a;function c(x={}){let y=x.httpProxy||x.httpsProxy||a();if(!y){t.warn("[Fetch] No proxy configured, HTTP_PROXY/HTTPS_PROXY environment variables not set");return}let R=new ProxyAgent({uri:y,connectTimeout:x.connectTimeout||1e4,keepAliveTimeout:x.keepAliveTimeout||3e4});r=getGlobalDispatcher(),setGlobalDispatcher(R),n=true,t.info(`[Fetch] Global proxy enabled: ${y}`);}v.enableProxy=c;function s(){!n||!r||(setGlobalDispatcher(r),n=false,r=null,t.info("[Fetch] \u5168\u5C40\u4EE3\u7406\u5DF2\u7981\u7528"));}v.disableProxy=s;function l(){return n}v.isProxyEnabled=l;async function p(x,y){let R=y?.timeout||3e4,B=y?.responseType||"json",{timeout:N,responseType:G,...j}=y||{},P=null,$=null;try{j.signal||(P=new AbortController,$=setTimeout(()=>P.abort(),R));let E=await fetch(x,{...j,signal:j.signal||P.signal});$&&clearTimeout($);let _;switch(B){case "arrayBuffer":_=await E.arrayBuffer();break;case "blob":_=await E.blob();break;case "buffer":{let J=await E.arrayBuffer();_=Buffer.from(J);break}case "text":_=await E.text();break;default:{let J=await E.text();try{_=JSON.parse(J);}catch{_=J;}break}}return {ok:E.ok,status:E.status,statusText:E.statusText,headers:E.headers,data:_,url:E.url}}catch(E){throw $&&clearTimeout($),E}}async function u(x,y){let R=y?.retries??0,B=y?.retryDelay??1e3,{retries:N,retryDelay:G,responseType:j,...P}=y||{};return gt(()=>p(x,{...P,responseType:y?.responseType}),{attempts:R+1,delay:B,maxDelay:B*2**(R+1)})}async function d$1(x,y){return u(x,{method:"GET",...y})}v.get=d$1;async function m$1(x,y,R){return u(x,{method:"POST",headers:{"Content-Type":"application/json",...R?.headers},body:y?JSON.stringify(y):void 0,...R})}v.post=m$1;async function f(x,y,R){return u(x,{method:"PUT",headers:{"Content-Type":"application/json",...R?.headers},body:y?JSON.stringify(y):void 0,...R})}v.put=f;async function g(x,y,R){return u(x,{method:"DELETE",headers:{"Content-Type":"application/json",...R?.headers},body:y?JSON.stringify(y):void 0,...R})}v.del=g;async function S(x,y,R){return u(x,{method:"PATCH",headers:{"Content-Type":"application/json",...R?.headers},body:y?JSON.stringify(y):void 0,...R})}v.patch=S;async function i(x,y){return u(x,y)}v.request=i;function b(x={}){return o()?(c(x),true):false}v.autoProxy=b;let O=5*1024*1024;function F(x){return new TextEncoder().encode(x)}function q(x){return d.mimeType(x)}function L(x){return x.startsWith("file://")}async function A(x){let y=fileURLToPath(x);return await D.file(y).bytes()}async function z(x,y,R){let B=`----FetchFormBoundary${Date.now()}`,N=[],j=y.some(D=>D.filename||D.value instanceof Uint8Array||Buffer.isBuffer(D.value))&&!R?.timeout?3e5:R?.timeout;for(let D of y){let V=D.maxSize??O,X=D.filename,Q=`Content-Disposition: form-data; name="${D.name}"${X?`; filename="${X}"`:""}`;X&&(Q+=`\r
|
|
57
|
+
Content-Type: ${q(X)}`),Q+=`\r
|
|
58
58
|
\r
|
|
59
|
-
`,
|
|
60
|
-
--${
|
|
61
|
-
--${
|
|
62
|
-
`),
|
|
63
|
-
`));for(let
|
|
64
|
-
`)));
|
|
65
|
-
`)
|
|
66
|
-
`)}
|
|
59
|
+
`,N.push(F(Q));let U=D.value;if(typeof U=="string")if(L(U)){let me=await A(U);if(X||(X=U.split("/").pop()||"file"),me.byteLength>V)throw new Error(`File size ${me.byteLength} exceeds limit ${V} bytes: ${X}`);N.push(me);}else N.push(F(U));else if(Buffer.isBuffer(U)){if(U.byteLength>V)throw new Error(`Buffer size ${U.byteLength} exceeds limit ${V} bytes: ${D.name}`);N.push(new Uint8Array(U.buffer,U.byteOffset,U.byteLength));}else if(U instanceof Uint8Array){if(U.byteLength>V)throw new Error(`File size ${U.byteLength} exceeds limit ${V} bytes: ${D.name}`);N.push(U);}}let P=F(`\r
|
|
60
|
+
--${B}--`),$=F(`\r
|
|
61
|
+
--${B}\r
|
|
62
|
+
`),E=[];E.push(F(`--${B}\r
|
|
63
|
+
`));for(let D=0;D<N.length;D++)E.push(N[D]),D%2===1&&D<N.length-1&&(E.push($),E.push(F(`--${B}\r
|
|
64
|
+
`)));E.push(P);let _=E.reduce((D,V)=>D+V.length,0),J=new Uint8Array(_),ae=0;for(let D of E)J.set(D,ae),ae+=D.length;return u(x,{method:"POST",headers:{"Content-Type":`multipart/form-data; boundary=${B}`,...R?.headers},body:J,timeout:j,...R})}v.postForm=z;function H(x,y,R){let B=new AbortController,N=B.signal;return (async()=>{try{let j={Accept:"text/event-stream",...R?.headers||{}},P=await fetch(x,{...R,headers:j,signal:N});if(!P.ok)throw new Error(`SSE connection failed: ${P.status}`);let $=P.body?.getReader();if(!$)throw new Error("SSE stream not available");let E=new TextDecoder("utf-8"),_="";for(;!N.aborted;){let{done:J,value:ae}=await $.read();if(J)break;let D=E.decode(ae,{stream:!0});_+=D;let V=_.split(`
|
|
65
|
+
`);_=V.pop()??"";for(let X of V)if(X.startsWith("data: ")){let Q=X.slice(6);if(Q==="[DONE]"){y.onComplete?.();return}y.onMessage?.(Q);}}y.onComplete?.();}catch(j){j.name!=="AbortError"&&y.onError?.(j);}})(),()=>{B.abort();}}v.sse=H;})(bt||(bt={}));f();var xt;(r=>{let t=["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"],e=["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 n(){return [t[Math.floor(Math.random()*t.length)],e[Math.floor(Math.random()*e.length)]].join("-")}r.create=n;})(xt||(xt={}));f();function Jt(t){let e=new AbortController,n=setTimeout(e.abort.bind(e),t);return {controller:e,signal:e.signal,clearTimeout:()=>globalThis.clearTimeout(n)}}function Gr(t,...e){let n=Jt(t);return {signal:AbortSignal.any([n.signal,...e]),clearTimeout:n.clearTimeout}}f();var yt;(e=>{async function t(n,r){if(process.platform==="win32"){let o=ot.resolve(n),a=ot.resolve(r),c=`Expand-Archive -Path '${o}' -DestinationPath '${a}' -Force`,s=await G.run("powershell",`-NoProfile -NonInteractive -Command "$global:ProgressPreference = 'SilentlyContinue'; ${c}"`);if(s.code!==0)throw new Error(`PowerShell exited with code ${s.code}: ${s.stderr}`)}else {let o=`unzip -o -q ${n} -d ${r}`,a=await G.run(void 0,o);if(a.code!==0)throw new Error(`unzip exited with code ${a.code}: ${a.stderr}`)}}e.extractZip=t;})(yt||(yt={}));f();var kt;(r=>{function t(o){return o?/^#[0-9a-fA-F]{6}$/.test(o):false}r.isValidHex=t;function e(o){let a=parseInt(o.slice(1,3),16),c=parseInt(o.slice(3,5),16),s=parseInt(o.slice(5,7),16);return {r:a,g:c,b:s}}r.hexToRgb=e;function n(o){if(!t(o))return;let{r:a,g:c,b:s}=e(o);return `\x1B[38;2;${a};${c};${s}m\x1B[1m`}r.hexToAnsiBold=n;})(kt||(kt={}));f();var wt;(n=>{class t extends Error{constructor(a){super(`No context found for ${a}`);c(this,"name",a);}}n.NotFound=t;function e(r){let o=new AsyncLocalStorage;return {use(){let a=o.getStore();if(!a)throw new t(r);return a},provide(a,c){return o.run(a,c)}}}n.create=e;})(wt||(wt={}));f();function Vr(t){return {[Symbol.dispose](){t();},[Symbol.asyncDispose](){return Promise.resolve(t())}}}f();var St;(e=>{async function t(){return new Promise(n=>{let r=()=>{process._getActiveHandles().length===0&&process._getActiveRequests().length===0?n():setImmediate(r);};r();})}e.wait=t;})(St||(St={}));f();function Xr(t){if(t<=0)return "";if(t<60)return `${t}s`;if(t<3600){let n=Math.floor(t/60),r=t%60;return r>0?`${n}m ${r}s`:`${n}m`}if(t<86400){let n=Math.floor(t/3600),r=Math.floor(t%3600/60);return r>0?`${n}h ${r}m`:`${n}h`}if(t<604800){let n=Math.floor(t/86400);return n===1?"~1 day":`~${n} days`}let e=Math.floor(t/604800);return e===1?"~1 week":`~${e} weeks`}f();var Tt;(S=>{let t=m.create({service:"grep"});async function e(){return n()}S.filepath=e;let n=b(async()=>{let i=await D.which("rg");if(!i)return null;try{if(!(await ve.stat(i)).isFile())return null}catch{return null}try{let b=await D.run([i,"--version"],{timeout:5e3});if(b.code!==0||!b.stdout.startsWith("ripgrep "))return t.warn("rg failed self-test, falling back to pure JS",{filepath:i,code:b.code,stderr:b.stderr.slice(0,200)}),null}catch(b){return t.warn("rg spawn failed during self-test, falling back to pure JS",{filepath:i,error:b.message.slice(0,200)}),null}return i});async function r(){return await e()!==null}S.isUsingRipgrep=r;async function*o(i){i.signal?.throwIfAborted();let b=await e();b?yield*a$2(b,i):(t.debug("ripgrep not available, using pure JS fallback for files()",{cwd:i.cwd}),yield*c(i));}S.files=o;async function*a$2(i,b){b.signal?.throwIfAborted();let O=["--files","--glob=!.git/*"];b.follow&&O.push("--follow");let F=b.hidden!==false;if(b.maxDepth!==void 0&&O.push(`--max-depth=${b.maxDepth}`),b.glob)for(let A of b.glob)O.push(`--glob=${A}`);try{if(!(await ve.stat(b.cwd)).isDirectory())throw Object.assign(new Error(`Not a directory: '${b.cwd}'`),{code:"ENOTDIR",errno:-20,path:b.cwd})}catch(A){throw A.code==="ENOENT"?Object.assign(new Error(`No such file or directory: '${b.cwd}'`),{code:"ENOENT",errno:-2,path:b.cwd}):A}let q=await D.run([i,...O],{cwd:b.cwd});if(q.code!==0&&q.code!==1)return;let L=q.stdout.split(/\r?\n/);for(let A of L){b.signal?.throwIfAborted();let z=A.trim();if(!z)continue;let H=d.toUnixPath(z);!F&&H.split("/").some(v=>v.startsWith("."))||(yield H);}}async function*c(i){i.signal?.throwIfAborted();try{if(!(await ve.stat(i.cwd)).isDirectory())throw Object.assign(new Error(`Not a directory: '${i.cwd}'`),{code:"ENOTDIR",errno:-20,path:i.cwd})}catch(v){throw v.code==="ENOENT"?Object.assign(new Error(`No such file or directory: '${i.cwd}'`),{code:"ENOENT",errno:-2,path:i.cwd}):v}let b=[],O=[];if(i.glob)for(let v of i.glob)v.startsWith("!")?O.push(v.slice(1)):b.push(v);let F=b.length>0?b:["**/*"],q=i.hidden!==false,L=new Set,A=b$2.DEFAULT_MAX_DEPTH,z;i.maxDepth===void 0?z=A:i.maxDepth<0?z=1:z=i.maxDepth+1;let H=Math.min(Math.max(z,1),A);for(let v of F){i.signal?.throwIfAborted();let x=await b$2.scan(v,{cwd:i.cwd,absolute:false,include:"file",dot:q,symlink:i.follow??false,maxDepth:H,ignore:O});for(let y of x)!q&&y.split("/").some(R=>R.startsWith("."))||L.add(y);}for(let v of Array.from(L).sort())i.signal?.throwIfAborted(),yield v;i.signal?.throwIfAborted();}async function s(i){t.debug("tree",{cwd:i.cwd}),i.signal?.throwIfAborted();let b=i.hidden!==false,O=i.glob??[],F=O.filter(P=>!P.startsWith("!")),q=O.filter(P=>P.startsWith("!")).map(P=>P.slice(1)),L=F.length>0?F:["**/*"],A=new Set,z=[];for(let P of L){i.signal?.throwIfAborted();let $=await b$2.scan(P,{cwd:i.cwd,absolute:false,include:"file",dot:b,symlink:false,maxDepth:b$2.DEFAULT_MAX_DEPTH});for(let E of $)A.has(E)||(A.add(E),z.push(E));}let H=z.filter(P=>{for(let $ of q)if(b$2.match($,P))return false;return true});function v(P,$){let E=P.children.get($);if(E)return E;let _={name:$,children:new Map};return P.children.set($,_),_}let x={children:new Map};for(let P of H){let $=P.split("/");if($.length<2)continue;let E=x;for(let _ of $.slice(0,-1))E=v(E,_);}let y=Array.from(x.children.values()).sort((P,$)=>P.name.localeCompare($.name)),R=i.limit??Number.POSITIVE_INFINITY,B=[],N=y.map(P=>({node:P,path:P.name})),G=0,j=0;for(;N.length>0;){let P=N.shift();if(!P)break;if(G++,j<R){B.push(P.path),j++;for(let $ of Array.from(P.node.children.values()).sort((E,_)=>E.name.localeCompare(_.name))){if(j>=R)break;N.push({node:$,path:`${P.path}/${$.name}`});}}}return G>j&&B.push(`[${j}/${G} shown, ${G-j} truncated]`),B.join(`
|
|
66
|
+
`)}S.tree=s;async function l(i){let b=await e();return b?p(b,i):(t.debug("ripgrep not available, using pure JS fallback for search()",{cwd:i.cwd,pattern:i.pattern}),u(i))}S.search=l;async function p(i,b){let O=["--json","--glob=!.git/*"];if(b.follow&&O.push("--follow"),b.glob)for(let z of b.glob)O.push(`--glob=${z}`);b.limit&&O.push(`--max-count=${b.limit}`),O.push("--"),O.push(b.pattern);let F=await D.run([i,...O],{cwd:b.cwd});if(F.code!==0)return [];let q=b.hidden!==false,L=F.stdout.split(/\r?\n/).filter(Boolean),A=[];for(let z of L)try{let H=JSON.parse(z);if(H?.type!=="match")continue;let v=H.data;if(!v?.path?.text||!v?.lines?.text)continue;let x=d.toUnixPath(v.path.text);if(!q&&x.split("/").some(y=>y.startsWith(".")))continue;if(A.push({path:x,lines:v.lines.text,line_number:v.line_number,absolute_offset:v.absolute_offset??0}),b.limit&&A.length>=b.limit)break}catch{}return A}async function u(i){let b;try{b=new RegExp(i.pattern);}catch{return []}try{if(!(await ve.stat(i.cwd)).isDirectory())throw Object.assign(new Error(`Not a directory: '${i.cwd}'`),{code:"ENOTDIR",errno:-20,path:i.cwd})}catch(v){throw v.code==="ENOENT"?Object.assign(new Error(`No such file or directory: '${i.cwd}'`),{code:"ENOENT",errno:-2,path:i.cwd}):v}let O=[],F=[];if(i.glob)for(let v of i.glob)v.startsWith("!")?F.push(v.slice(1)):O.push(v);let q=i.hidden!==false,L=[],A=O.length>0?O:["**/*"],z=new Set,H=[];for(let v of A){i.signal?.throwIfAborted();let x=await b$2.scan(v,{cwd:i.cwd,absolute:false,include:"file",dot:q,symlink:i.follow??false,maxDepth:void 0,ignore:F});for(let y of x)z.has(y)||(z.add(y),H.push(y));}for(let v of H){if(i.signal?.throwIfAborted(),i.limit&&L.length>=i.limit)break;let x=d.join(i.cwd,v),y;try{y=await ve.readFile(x,"utf-8");}catch{continue}let R=y.split(/\r?\n/),B=0;for(let N=0;N<R.length;N++){let G=R[N]??"";if(b.test(G)&&(L.push({path:v,lines:G,line_number:N+1,absolute_offset:B}),i.limit&&L.length>=i.limit))break;B+=Buffer.byteLength(G,"utf-8")+1;}}return L}function d$1(i,b){return a$1.match(i,b)}S.match=d$1;let m$1=a(async()=>await e());async function f(){return await m$1()}S.filepathCached=f,S._ready=a(async()=>{let i=await e();return t.debug("Grep initialized",{ripgrep:i?"available":"fallback (pure JS)"}),i});})(Tt||(Tt={}));f();var Mt;(c=>{function t(s,l){if(s===l)return true;if(typeof s!="object"||typeof l!="object"||s===null||l===null)return false;let p=Object.keys(s),u=Object.keys(l);if(p.length!==u.length)return false;for(let d of p)if(!u.includes(d)||!t(s[d],l[d]))return false;return true}function e(s){return {...s,super:s.super??false}}function n(s,l){return s?t(e(s),e(l)):false}c.match=n;function r(s,l=false){return {name:s.name,ctrl:s.ctrl,meta:s.meta,shift:s.shift,super:s.super??false,leader:l}}c.fromParsedKey=r;function o(s){if(!s)return "";let l=[];s.ctrl&&l.push("ctrl"),s.meta&&l.push("alt"),s.super&&l.push("super"),s.shift&&l.push("shift"),s.name&&(s.name==="delete"?l.push("del"):l.push(s.name));let p=l.join("+");return s.leader&&(p=p?`<leader> ${p}`:"<leader>"),p}c.keyToString=o;function a(s){return s==="none"?[]:s.split(",").map(l=>{let u=l.replace(/<leader>/g,"leader+").toLowerCase().split("+"),d={ctrl:false,meta:false,shift:false,super:false,leader:false,name:""};for(let m of u)switch(m){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=m;break}return d})}c.parse=a;})(Mt||(Mt={}));f();var pe;(m=>{m.SUPPORTED_LANGS=["zh-CN","en-US"],m.DEFAULT_LANG="zh-CN";function n(f,g="EASBOT_LANG"){let S=[f,process.env[g]?.trim()];for(let i of S)if(i&&m.SUPPORTED_LANGS.includes(i))return i;return m.DEFAULT_LANG}m.resolveLocaleLang=n;function r(f){return f.replace(/\b\w/g,g=>g.toUpperCase())}m.titlecase=r;function o(f){return new Date(f).toLocaleTimeString(void 0,{timeStyle:"short"})}m.time=o;function a(f){let g=new Date(f),S=o(f),i=g.toLocaleDateString();return `${S} \xB7 ${i}`}m.datetime=a;function c(f){let g=new Date(f),S=new Date;return g.getFullYear()===S.getFullYear()&&g.getMonth()===S.getMonth()&&g.getDate()===S.getDate()?o(f):a(f)}m.todayTimeOrDateTime=c;function s(f){return f>=1e6?(f/1e6).toFixed(1)+"M":f>=1e3?(f/1e3).toFixed(1)+"K":f.toString()}m.number=s;function l(f){if(f<1e3)return `${f}ms`;if(f<6e4)return `${(f/1e3).toFixed(1)}s`;if(f<36e5){let i=Math.floor(f/6e4),b=Math.floor(f%6e4/1e3);return `${i}m ${b}s`}if(f<864e5){let i=Math.floor(f/36e5),b=Math.floor(f%36e5/6e4);return `${i}h ${b}m`}let g=Math.floor(f/36e5);return `${Math.floor(f%36e5/864e5)}d ${g}h`}m.duration=l;function p(f,g){return f.length<=g?f:f.slice(0,g-1)+"\u2026"}m.truncate=p;function u(f,g=35){if(f.length<=g)return f;let S="\u2026",i=Math.ceil((g-S.length)/2),b=Math.floor((g-S.length)/2);return f.slice(0,i)+S+f.slice(-b)}m.truncateMiddle=u;function d(f,g,S){return (f===1?g:S).replace("{}",f.toString())}m.pluralize=d;})(pe||(pe={}));var Kr=pe.resolveLocaleLang,Jr=pe.SUPPORTED_LANGS,Zr=pe.DEFAULT_LANG;f();var Qr=["HTTP_PROXY","HTTPS_PROXY","http_proxy","https_proxy"];function eo(){return Qr.some(t=>process.env[t])}function to(){return process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy}function no(){let t=process.env.HTTP_PROXY||process.env.http_proxy,e=process.env.HTTPS_PROXY||process.env.https_proxy;return {http:t,https:e,enabled:!!(t||e)}}f();var It=class{constructor(){c(this,"queue",[]);c(this,"resolvers",[]);}push(e){let n=this.resolvers.shift();n?n(e):this.queue.push(e);}async next(){return this.queue.length>0?this.queue.shift():new Promise(e=>this.resolvers.push(e))}async*[Symbol.asyncIterator](){for(;;)yield await this.next();}};async function ro(t,e,n){let r=[...e];await Promise.all(Array.from({length:t},async()=>{for(;;){let o=r.pop();if(o===void 0)return;await n(o);}}));}f();function oo(){let t,e=new Promise(n=>t=n);return {trigger(){return t()},wait(){return e}}}f();function so(t,e){let n;return Promise.race([t.then(r=>(clearTimeout(n),r)),new Promise((r,o)=>{n=setTimeout(()=>{o(new Error(`Operation timed out after ${e}ms`));},e);})])}f();var vt;(c=>{let n=/[\u4e00-\u9fff\u3400-\u4dbf]/g;function r(s){if(!s)return 0;let l=String(s),p=(l.match(n)||[]).length,u=l.length-p,d=Math.round(p/1.5),m=Math.round(u/4);return Math.max(0,d+m)}c.estimate=r;function o(s){if(s==null)return 0;try{let l=typeof s=="string"?s:JSON.stringify(s);return r(l)}catch{return 0}}c.estimateObject=o;function a(s){if(s.total!==void 0&&s.total>0)return s.total;let l=s.input??0,p=s.output??0,u=s.cache?.read??0,d=s.cache?.write??0;return l+p+u+d}c.total=a;})(vt||(vt={}));f();function ao(t){let e={},n=t.shape??t.required().shape;for(let[r,o]of Object.entries(n))e[r]=o.nullable().optional();return Fe.object(e)}f();var uo=new Writable({write(t,e,n){n();}}),Re;(m=>{m.cancelSymbol=Symbol("CliSearch.cancel");function e(f){let g=0;for(let S of f){let i=S.codePointAt(0);if(i===void 0||i===0)continue;let b=i>=4352&&i<=4447||i>=8986&&i<=8987||i>=9001&&i<=9002||i>=9193&&i<=9196||i===9200||i===9203||i>=9725&&i<=9726||i>=9748&&i<=9749||i>=9800&&i<=9811||i===9855||i===9875||i===9889||i>=9898&&i<=9899||i>=9917&&i<=9918||i>=9924&&i<=9925||i===9934||i===9940||i===9962||i>=9970&&i<=9971||i===9973||i===9978||i===9981||i===9989||i>=9994&&i<=9995||i===10024||i===10060||i===10062||i>=10067&&i<=10069||i===10071||i>=10133&&i<=10135||i===10160||i===10175||i>=11035&&i<=11036||i===11088||i===11093||i>=11904&&i<=42191&&i!==12351||i>=43360&&i<=43388||i>=44032&&i<=55203||i>=63744&&i<=64255||i>=65040&&i<=65049||i>=65072&&i<=65135||i>=65280&&i<=65376||i>=65504&&i<=65510||i>=126976&&i<=129535;g+=b?2:1;}return g}m.approxStringWidth=e;function n(f,g){let S=stripVTControlCharacters(f),i=Math.max(1,g),b=e(S);return Math.max(1,Math.ceil(b/i))}m.visualRowsForLine=n;function r(f,g){let S=g!==void 0&&g>0?g:process.stdout.columns&&process.stdout.columns>0?process.stdout.columns:80,i=0;for(let b of f)i+=n(b,S);return i}m.countVisualRowsForLines=r;function o(f){let g=new Array(f.length);for(let S=0;S<f.length;S++){let i=f[S],b=i.value===null||i.value===void 0?"":String(i.value);g[S]={...i,searchKey:`${i.label}
|
|
67
|
+
${b}`.toLowerCase()};}return g}function a(f,g){return g===""||f.searchKey.includes(g)}function c(f,g){return g<=0||f<0?0:f>=g?g-1:f}function s(f){if(f?.length!==1)return false;let g=f.codePointAt(0);return !(g===void 0||g<32||g===127||g===27)}function l(){let f=process.stdout.rows;if(!f||f<=0)return 8;let g=Math.floor((f-8)/2);return Math.max(5,Math.min(15,g))}function p(f,g){try{f.write(g);}catch{}}function u(f){if(f&&f.isTTY&&typeof f.setRawMode=="function")try{f.setRawMode(!1);}catch{}}function d(f){let g=f.message,S=o(f.items),i=Math.max(1,f.maxVisible??l()),b=f.initialSelected??[],O=f.required??false,F=f.lockedSection;return new Promise(q=>{let L=process.stdin,A=process.stdout,z=Ue.createInterface({input:L,output:uo,terminal:false});try{L.isTTY&&L.setRawMode?.(!0);}catch{}Ue.emitKeypressEvents(L,z);let H="",v="",x=0,y=new Set(b),R=0,B=false,N=F?F.items.map(C=>C.value):[],G=F?F.items.map(C=>C.label):[],j=[],P=()=>{if(j.length=0,v==="")for(let C=0;C<S.length;C++){let k=S[C];j.push(k);}else for(let C=0;C<S.length;C++){let k=S[C];a(k,v)&&j.push(k);}return j},$=()=>{if(R>0){p(A,`\x1B[${R}A`);for(let C=0;C<R;C++)p(A,"\x1B[2K\x1B[1B");p(A,`\x1B[${R}A`);}},E=()=>{let C=G.slice();for(let k=0;k<S.length;k++){let W=S[k];y.has(W.value)&&C.push(W.label);}return C},_=(C="active")=>{$();let k=[],W=P(),qe=C==="active"||C==="error"?"\u25C6":C==="cancel"?"\u25A0":"\u25C7",tn=C==="cancel"?T.red(qe):C==="error"?T.red(qe):T.green(qe);if(k.push(`${tn} ${T.bold(g)}`),C==="active"||C==="error"){if(F&&F.items.length>0){k.push(T.dim("\u2502"));let re=`${T.bold(F.title)} ${T.dim("\u2500\u2500 always included")}`;k.push(`${T.dim("\u2502")} ${T.dim("\u2500\u2500")} ${re} ${T.dim("\u2500".repeat(12))}`);for(let ge of F.items)k.push(`${T.dim("\u2502")} ${T.green("\u2022")} ${T.bold(ge.label)}`);F.hiddenCount&&F.hiddenCount>0&&k.push(`${T.dim("\u2502")} ${T.dim(`...and ${F.hiddenCount} more`)}`),k.push(T.dim("\u2502")),k.push(`${T.dim("\u2502")} ${T.dim("\u2500\u2500")} ${T.bold("Additional agents")} ${T.dim("\u2500".repeat(29))}`);}let Ge=`${T.dim("\u2502")} ${T.dim("Search:")} ${H}${T.inverse(" ")}`;k.push(Ge),k.push(`${T.dim("\u2502")} ${T.dim("\u2191\u2193 move \xB7 space select \xB7 enter confirm")}`),k.push(T.dim("\u2502"));let nn=Math.max(0,W.length-i),rn=x-Math.floor(i/2),Ye=Math.max(0,Math.min(rn,nn)),Pt=Math.min(W.length,Ye+i);if(W.length===0)k.push(`${T.dim("\u2502")} ${T.dim("No matches found")}`);else {for(let ee=Ye;ee<Pt;ee++){let be=W[ee],on=y.has(be.value),Ot=ee===x,sn=on?T.green("\u25CF"):T.dim("\u25CB"),an=Ot?T.underline(be.label):be.label,cn=be.hint?T.dim(` (${be.hint})`):"",ln=Ot?T.cyan("\u276F"):" ";k.push(`${T.dim("\u2502")} ${ln} ${sn} ${an}${cn}`);}let re=Ye,ge=W.length-Pt;if(re>0||ge>0){let ee=[];re>0&&ee.push(`\u2191 ${re} more`),ge>0&&ee.push(`\u2193 ${ge} more`),k.push(`${T.dim("\u2502")} ${T.dim(ee.join(" "))}`);}}k.push(T.dim("\u2502"));let he=E();if(he.length===0)k.push(`${T.dim("\u2502")} ${T.dim("Selected: (none)")}`);else {let re=he.length<=3?he.join(", "):`${he.slice(0,3).join(", ")} +${he.length-3} more`;k.push(`${T.dim("\u2502")} ${T.green("Selected:")} ${re}`);}C==="error"&&k.push(`${T.dim("\u2502")} ${T.red("\u26A0 Please select at least one item before submitting")}`),k.push(`${T.dim("\u2514")}`);}else if(C==="submit"){let Ge=E();k.push(`${T.dim("\u2502")} ${T.dim(Ge.join(", "))}`);}else k.push(`${T.dim("\u2502")} ${T.strikethrough(T.dim("Cancelled"))}`);p(A,`${k.join(`
|
|
68
|
+
`)}
|
|
69
|
+
`);try{R=r(k,A.columns);}catch{R=k.length;}},J=false,ae=()=>{if(!J){J=true;try{L.removeListener("keypress",Rt),L.removeListener("end",Q);}catch{}try{process.removeListener("SIGINT",U),process.removeListener("SIGTERM",U);}catch{}u(L);try{z.close();}catch{}}},D=C=>{B||(B=true,ae(),q(C));},V=()=>{if(O&&y.size===0&&N.length===0){_("error");return}_("submit"),D([...N,...Array.from(y)]);},X=()=>{_("cancel"),D(m.cancelSymbol);},Q=()=>{X();},U=()=>{u(L);},me=C=>{let k=C[x];k&&(y.has(k.value)?y.delete(k.value):y.add(k.value));},Qt=C=>{H+=C,v+=C.toLowerCase();},en=()=>{H.length!==0&&(H=H.slice(0,-1),v=v.slice(0,-1));},Rt=(C,k)=>{if(!k)return;let W=P();if(x=c(x,W.length),k.name==="return"){V();return}if(k.name==="escape"||k.ctrl&&k.name==="c"){X();return}if(k.name==="up"||k.name==="left"){W.length>0&&(x=c(x-1,W.length),_());return}if(k.name==="down"||k.name==="right"){W.length>0&&(x=c(x+1,W.length),_());return}if(k.name==="pageup"){W.length>0&&(x=c(x-i,W.length),_());return}if(k.name==="pagedown"){W.length>0&&(x=c(x+i,W.length),_());return}if(k.name==="home"){W.length>0&&(x=0,_());return}if(k.name==="end"){W.length>0&&(x=W.length-1,_());return}if(k.name==="space"){me(W),_();return}if(k.name==="backspace"){H.length>0&&(en(),x=0,_());return}!k.ctrl&&!k.meta&&s(k.sequence)&&(Qt(k.sequence),x=0,_());};L.on("keypress",Rt),L.once("end",Q),process.on("SIGINT",U),process.on("SIGTERM",U),_();})}m.multiselect=d;})(Re||(Re={}));Re.cancelSymbol;Re.multiselect;export{yt as Archive,It as AsyncQueue,Ke as Binary,Re as CliSearch,kt as Color,wt as Context,Zr as DEFAULT_LANG,Je as Encode,St as EventLoop,bt as Fetch,rt as Fn,Tt as Grep,ne as Identifier,tt as Ignore,Mt as Keybind,pe as Locale,ht as Markdown,et as NamedError,Jr as SUPPORTED_LANGS,Qe as SessionTitle,xt as Slug,vt as Token,Ze as TruncateContent,Jt as abortAfter,Gr as abortAfterAny,We as buildCodeSpanIndex,Gt as chunkMarkdownIR,ce as chunkText,it as chunkTextByBreakResolver,He as convertMarkdownTables,je as createInlineCodeState,Vr as defer,ze as extractFrontmatter,mt as findFenceSpanAt,Cn as findLast,$n as fn,Xr as formatDuration,De as formatMarkdown,Dr as getDirectory,Nr as getFileExtension,Xt as getFilename,zr as getFilenameTruncated,no as getProxyConfig,to as getProxyUrl,Bn as git,Yn as iife,Vt as isSafeFenceBreak,zn as loadEnv,qn as loadTextFile,Gn as loadTextFileAsync,de as markdownToIR,Te as markdownToIRWithMeta,Be as parseFenceSpans,Ie as parseFrontmatterBlock,Vn as parseModelId,eo as proxied,fe as renderMarkdown,Me as renderMarkdownWithMarkers,Kr as resolveLocaleLang,gt as retry,st as scanParenAwareBreakpoints,Ne as serializeFrontmatter,oo as signal,Br as truncateMiddle,ao as updateSchema,so as withTimeout,ro as work};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easbot/utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "Shared utilities library for EASBOT ecosystem",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"@hono/standard-validator": "^0.2.2",
|
|
47
47
|
"@hono/zod-validator": "^0.7.6",
|
|
48
48
|
"dotenv": "^17.4.2",
|
|
49
|
+
"picocolors": "1.1.1",
|
|
49
50
|
"glob": "^13.0.6",
|
|
50
51
|
"hono": "^4.12.18",
|
|
51
52
|
"hono-openapi": "^1.3.0",
|
|
@@ -55,10 +56,9 @@
|
|
|
55
56
|
"xdg-basedir": "^5.1.0",
|
|
56
57
|
"yaml": "^2.9.0",
|
|
57
58
|
"zod": "^4.4.3",
|
|
58
|
-
"@easbot/types": "0.3.
|
|
59
|
+
"@easbot/types": "0.3.11"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
|
-
"@biomejs/biome": "^2.4.14",
|
|
62
62
|
"@types/markdown-it": "^14.1.2",
|
|
63
63
|
"@types/node": "^25.6.2",
|
|
64
64
|
"@types/ws": "^8.18.1",
|