@kabmo-labs/kabmo 0.6.0 → 0.6.1
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/client/index.html
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap"
|
|
65
65
|
/>
|
|
66
66
|
<!--app-head-->
|
|
67
|
-
<link rel="stylesheet" crossorigin href="./static/js/index-nzyjf92m.css"><script type="module" crossorigin src="./static/js/index-
|
|
67
|
+
<link rel="stylesheet" crossorigin href="./static/js/index-nzyjf92m.css"><script type="module" crossorigin src="./static/js/index-aq0e78gv.js"></script></head>
|
|
68
68
|
<body>
|
|
69
69
|
<div id="app"></div>
|
|
70
70
|
<!--app-bootstrap-->
|
package/dist/client/index.js
CHANGED
|
@@ -663,7 +663,7 @@ return u.substring(s,qi)
|
|
|
663
663
|
`:`c.headers={}
|
|
664
664
|
for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
665
665
|
`},listen(e){return(t,r)=>{if(typeof Bun>"u")throw Error(".listen() is designed to run on Bun only. If you are running Elysia in other environment please use a dedicated plugin or export the handler via Elysia.fetch");if(e.compile(),typeof t=="string"){if(!Jg(t))throw Error("Port must be a numeric value");t=parseInt(t)}let n=(s,{withAsync:a=!1}={})=>{let c={},l=[];if(e.event.request?.length||e.event.trace?.length||e.extender.higherOrderFunctions.length)return a?Promise.resolve(c):c;for(let[u,d]of Object.entries(s))if(u=encodeURI(u),Xg){if(!d)continue;for(let[f,p]of Object.entries(d))if(!(!p||!(f in F1))){if(p instanceof Promise){a&&(c[u]||(c[u]={}),l.push(p.then((h)=>{h instanceof Response&&(c[u][f]=h),Cp(h)&&(c[u][f]=h)})));continue}!(p instanceof Response)&&!Cp(p)||(c[u]||(c[u]={}),c[u][f]=p)}}else{if(!d)continue;if(d instanceof Promise){a&&(c[u]||(c[u]={}),l.push(d.then((f)=>{f instanceof Response&&(c[u]=f)})));continue}if(!(d instanceof Response))continue;c[u]=d}return a?Promise.all(l).then(()=>c):c},o=M1(Nh(Nh(n(e.router.response),O1(e)),e.config.serve?.routes)),i=typeof t=="object"?{development:!Bi,reusePort:!0,idleTimeout:30,...e.config.serve||{},...t||{},routes:o,websocket:{...e.config.websocket||{},...KS||{},...t.websocket||{}},fetch:e.fetch}:{development:!Bi,reusePort:!0,idleTimeout:30,...e.config.serve||{},routes:o,websocket:{...e.config.websocket||{},...KS||{}},port:t,fetch:e.fetch};if(e.server=Bun.serve(i),e.event.start)for(let s=0;s<e.event.start.length;s++)e.event.start[s].fn(e);r&&r(e.server),process.on("beforeExit",async()=>{if(e.server&&(await e.server.stop?.(),e.server=null,e.event.stop))for(let s=0;s<e.event.stop.length;s++)e.event.stop[s].fn(e)}),e.promisedModules.then(async()=>{e.config.aot,e.compile();let s=M1(Nh(Nh(await n(e.router.response,{withAsync:!0}),O1(e)),e.config.serve?.routes));e.server?.reload({...i,fetch:e.fetch,routes:s}),Bun?.gc(!1)})}},async stop(e,t){if(e.server){if(await e.server.stop(t),e.server=null,e.event.stop?.length)for(let r=0;r<e.event.stop.length;r++)e.event.stop[r].fn(e)}else console.log("Elysia isn't running. Call `app.listen` to start the server.",Error().stack)},ws(e,t,r){let{parse:n,body:o,response:i,...s}=r,a=St(o,{modules:e.definitions.typebox,models:e.definitions.type,normalize:e.config.normalize}),c=a?a.provider==="standard"?(u)=>a.schema["~standard"].validate(u).issues:(u)=>a.Check(u)===!1:void 0,l=St(i,{modules:e.definitions.typebox,models:e.definitions.type,normalize:e.config.normalize});e.route("WS",t,async(u)=>{let d=u.server??e.server,{set:f,path:p,qi:h,headers:g,query:y,params:b}=u;if(u.validator=l,r.upgrade)if(typeof r.upgrade=="function"){let S=r.upgrade(u);S instanceof Promise&&await S}else r.upgrade&&Object.assign(f.headers,r.upgrade);if(f.cookie&&Re(f.cookie)){let S=xp(f.cookie);S&&(f.headers["set-cookie"]=S)}f.headers["set-cookie"]&&Array.isArray(f.headers["set-cookie"])&&(f.headers=IS(new Headers(f.headers),f.headers["set-cookie"]));let w=C1(l),E=I1(n),A;if(typeof r.beforeHandle=="function"){let S=r.beforeHandle(u);S instanceof Promise&&await S}let v=[...r.error?Array.isArray(r.error)?r.error:[r.error]:[],...(e.event.error??[]).map((S)=>typeof S=="function"?S:S.fn)].filter((S)=>S),T=v.length>0,I=T?async(S,D)=>{for(let L of v){let P=L(Object.assign(u,{error:D}));if(P instanceof Promise&&(P=await P),await w(S,P),P)break}}:()=>{};if(!d?.upgrade(u.request,{headers:Re(f.headers)?f.headers:void 0,data:{...u,get id(){return A||(A=Di())},validator:l,ping(S,D){r.ping?.(S,D)},pong(S,D){r.pong?.(S,D)},open:async(S)=>{try{await w(S,r.open?.(new Yl(S,u)))}catch(D){I(S,D)}},message:async(S,D)=>{let L=await E(S,D);if(c&&c(L)){let P=new ie("message",a,L);return T?I(S,P):void S.send(P.message)}try{await w(S,r.message?.(new Yl(S,u,L),L))}catch(P){I(S,P)}},drain:async(S)=>{try{await w(S,r.drain?.(new Yl(S,u)))}catch(D){I(S,D)}},close:async(S,D,L)=>{try{await w(S,r.close?.(new Yl(S,u),D,L))}catch(P){I(S,P)}}}}))return Qo(400,"Expected a websocket connection")},{...s,websocket:r})}};var Fh=Pn?Bun.env:typeof process<"u"&&process?.env?process.env:{};var j1=/^(.+)\[(\d+)\]$/,L1=new Set(["__proto__","constructor","prototype"]),B1=(e)=>{if(L1.has(e))return!0;let t=e.match(j1);return t?L1.has(t[1]):!1},U1=(e)=>{let t=e.match(j1);return t?{name:t[1],index:parseInt(t[2],10)}:null},Nre=(e)=>{if(!(typeof e!="string"||e.charCodeAt(0)!==123))try{let t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return t}catch{return}},qS=(e,t,r)=>{let n=t.split("."),o=n.pop();if(B1(o)||n.some(B1))return;let i=e;for(let a of n){let c=U1(a);if(c){Array.isArray(i[c.name])||(i[c.name]=[]);let l=i[c.name][c.index],u=typeof File<"u"&&l instanceof File;(!l||typeof l!="object"||Array.isArray(l)||u)&&(i[c.name][c.index]=Nre(l)??{}),i=i[c.name][c.index]}else(!i[a]||typeof i[a]!="object")&&(i[a]={}),i=i[a]}let s=U1(o);s?(Array.isArray(i[s.name])||(i[s.name]=[]),i[s.name][s.index]=r):i[o]=r},VS=(e)=>{if(e.length===1){let o=e[0];if(typeof o=="string"&&(o.charCodeAt(0)===123||o.charCodeAt(0)===91))try{let i=JSON.parse(o);if(i&&typeof i=="object")return i}catch{}return e[0]}let t=e.find((o)=>typeof o=="string");if(!t||typeof File>"u")return e;let r=e.filter((o)=>o instanceof File);if(!r.length||t.charCodeAt(0)!==123)return e;let n;try{n=JSON.parse(t)}catch{return e}return typeof n!="object"||n===null?e:(!("file"in n)&&r.length===1?n.file=r[0]:!("files"in n)&&r.length>1&&(n.files=r),n)},GS=(e,t)=>{let r=e.schema;if(!r)return;r.$defs?.[r.$ref]&&(r=r.$defs[r.$ref]);let n=ti(r);if(n)for(let[o,i]of Object.entries(n))t[o]??=i.default};async function dc(e,t,r){let n=await t.Validate(r);if(n.issues)throw new ie(e,t,r,!1,n.issues);return n.value}var $S=(e)=>{let{mapResponse:t,mapEarlyResponse:r}=e["~adapter"].handler,n=e.setHeaders;return async(o)=>{let i=o.url,s=i.indexOf("/",11),a=i.indexOf("?",s+1),c=a===-1?i.substring(s):i.substring(s,a),l={cookie:{},status:200,headers:n?{...n}:{}},u=Object.assign({},e.singleton.decorator,{set:l,store:e.singleton.store,request:o,path:c,qi:a,error:Qo,status:Qo,redirect:za}),d;try{if(e.event.request)for(let D=0;D<e.event.request.length;D++){let L=e.event.request[D].fn,P=L(u);if(P instanceof Promise&&(P=await P),P=r(P,l),P)return u.response=P}let f=o.method==="GET"&&o.headers.get("upgrade")?.toLowerCase()==="websocket"?"WS":o.method,p=e.router.dynamic.find(o.method,c)??e.router.dynamic.find(f,c)??e.router.dynamic.find("ALL",c);if(!p)throw u.query=a===-1?{}:Ls(i.substring(a+1)),new Fl;let{handle:h,validator:g,content:y,route:b}=p.store;if(d=p.store.hooks,d.config?.mount)return await d.config.mount(o);let w;if(o.method!=="GET"&&o.method!=="HEAD")if(y)switch(y){case"application/json":w=await o.json();break;case"text/plain":w=await o.text();break;case"application/x-www-form-urlencoded":w=Ls(await o.text());break;case"application/octet-stream":w=await o.arrayBuffer();break;case"multipart/form-data":{w={};let D=await o.formData(),L=new Map;D.forEach((P,j)=>{let B=L.get(j);B?B.push(P):L.set(j,[P])});for(let[P,j]of L){if(w[P])continue;let B=VS(j);P.includes(".")||P.includes("[")?qS(w,P,B):w[P]=B}break}}else{let D;if(o.body&&(D=o.headers.get("content-type")),D){let L=D.indexOf(";");if(L!==-1&&(D=D.slice(0,L)),u.contentType=D,d.parse)for(let P=0;P<d.parse.length;P++){let j=d.parse[P].fn;if(typeof j=="string")switch(j){case"json":case"application/json":w=await o.json();break;case"text":case"text/plain":w=await o.text();break;case"urlencoded":case"application/x-www-form-urlencoded":w=Ls(await o.text());break;case"arrayBuffer":case"application/octet-stream":w=await o.arrayBuffer();break;case"formdata":case"multipart/form-data":{w={};let B=await o.formData(),J=new Map;B.forEach((te,oe)=>{let re=J.get(oe);re?re.push(te):J.set(oe,[te])});for(let[te,oe]of J){if(w[te])continue;let re=VS(oe);te.includes(".")||te.includes("[")?qS(w,te,re):w[te]=re}break}default:{let B=e["~parser"][j];if(B){let J=B(u,D);if(J instanceof Promise&&(J=await J),J){w=J;break}}break}}else{let B=j(u,D);if(B instanceof Promise&&(B=await B),B){w=B;break}}}if(delete u.contentType,w===void 0)switch(D){case"application/json":w=await o.json();break;case"text/plain":w=await o.text();break;case"application/x-www-form-urlencoded":w=Ls(await o.text());break;case"application/octet-stream":w=await o.arrayBuffer();break;case"multipart/form-data":{w={};let P=await o.formData(),j=new Map;P.forEach((B,J)=>{let te=j.get(J);te?te.push(B):j.set(J,[B])});for(let[B,J]of j){if(w[B])continue;let te=VS(J);B.includes(".")||B.includes("[")?qS(w,B,te):w[B]=te}break}}}}u.route=b,u.body=w,u.params=p?.params||void 0,u.query=a===-1?{}:Ls(i.substring(a+1)),u.headers={};for(let[D,L]of o.headers.entries())u.headers[D]=L;let E={domain:e.config.cookie?.domain??g?.cookie?.config.domain,expires:e.config.cookie?.expires??g?.cookie?.config.expires,httpOnly:e.config.cookie?.httpOnly??g?.cookie?.config.httpOnly,maxAge:e.config.cookie?.maxAge??g?.cookie?.config.maxAge,path:e.config.cookie?.path??g?.cookie?.config.path,priority:e.config.cookie?.priority??g?.cookie?.config.priority,partitioned:e.config.cookie?.partitioned??g?.cookie?.config.partitioned,sameSite:e.config.cookie?.sameSite??g?.cookie?.config.sameSite,secure:e.config.cookie?.secure??g?.cookie?.config.secure,secrets:e.config.cookie?.secrets??g?.cookie?.config.secrets,sign:e.config.cookie?.sign??g?.cookie?.config.sign},A=o.headers.get("cookie");u.cookie=await xh(u.set,A,E);let v=g?.createHeaders?.();v&&GS(v,u.headers);let T=g?.createParams?.();T&&GS(T,u.params);let I=g?.createQuery?.();if(I&&GS(I,u.query),d.transform)for(let D=0;D<d.transform.length;D++){let L=d.transform[D],P=L.fn(u);if(P instanceof Promise&&(P=await P),P instanceof wt){let j=r(P,u.set);if(j)return u.response=j}L.subType==="derive"&&Object.assign(u,P)}if(g){if(v){let L=structuredClone(u.headers);for(let[P,j]of o.headers)L[P]=j;if(v.provider==="standard")u.headers=await dc("header",v,L);else if(g.headers.Check(L)===!1)throw new ie("header",g.headers,L)}else g.headers?.Decode&&(u.headers=g.headers.Decode(u.headers));if(T?.provider==="standard")u.params=await dc("params",T,u.params);else{if(T?.Check(u.params)===!1)throw new ie("params",g.params,u.params);g.params?.Decode&&(u.params=g.params.Decode(u.params))}if(g.query?.schema){let L=g.query.schema;L.$defs?.[L.$ref]&&(L=L.$defs[L.$ref]);let P=ti(L);if(P)for(let j of Object.keys(P)){let B=P[j];(B.type==="array"||B.items?.type==="string")&&typeof u.query[j]=="string"&&u.query[j]&&(u.query[j]=u.query[j].split(","))}}if(I?.provider==="standard")u.query=await dc("query",I,u.query);else{if(I?.Check(u.query)===!1)throw new ie("query",g.query,u.query);g.query?.Decode&&(u.query=g.query.Decode(u.query))}if(g.createCookie?.()){let L={};for(let[P,j]of Object.entries(u.cookie))L[P]=j.value;if(g.cookie.provider==="standard"){L=await dc("cookie",g.cookie,L);for(let P of Object.keys(L))u.cookie[P].value=L[P]}else{if(g.cookie.Check(L)===!1)throw new ie("cookie",g.cookie,L);g.cookie?.Decode&&(L=g.cookie.Decode(L))}}let D=g.createBody?.();if(D?.provider==="standard")u.body=await dc("body",D,w);else{if(D?.Check(w)===!1)throw new ie("body",g.body,w);if(g.body?.Decode){let L=g.body.Decode(w);L instanceof Promise&&(L=await L),u.body=L?.value??L}}}if(d.beforeHandle)for(let D=0;D<d.beforeHandle.length;D++){let L=d.beforeHandle[D],P=L.fn(u);if(P instanceof Promise&&(P=await P),P instanceof wt){let j=r(P,u.set);if(j)return u.response=j}if(L.subType==="resolve"){Object.assign(u,P);continue}if(P!==void 0){if(u.response=P,d.afterHandle)for(let B=0;B<d.afterHandle.length;B++){let J=d.afterHandle[B].fn(u);J instanceof Promise&&(J=await J),J&&(P=J)}let j=r(P,u.set);if(j)return u.response=j}}let S=typeof h=="function"?h(u):h;if(S instanceof Promise&&(S=await S),d.afterHandle?.length){u.response=S;for(let D=0;D<d.afterHandle.length;D++){let L=d.afterHandle[D].fn(u);L instanceof Promise&&(L=await L);let P=L instanceof wt,j=P?L.code:l.status?typeof l.status=="string"?Xo[l.status]:l.status:200;P&&(l.status=j,L=L.response);let B=g?.createResponse?.()?.[j];if(B?.provider==="standard")L=await dc("response",B,L);else if(B?.Check(L)===!1)if(B?.Clean)try{let te=B.Clean(L);if(B?.Check(te)===!1)throw new ie("response",B,L);L=te}catch(te){throw te instanceof ie?te:new ie("response",B,L)}else throw new ie("response",B,L);if(B?.Encode&&(u.response=L=B.Encode(L)),B?.Clean)try{u.response=L=B.Clean(L)}catch{}let J=r(L,u.set);if(J!==void 0)return u.response=J}}else{let D=S instanceof wt,L=D?S.code:l.status?typeof l.status=="string"?Xo[l.status]:l.status:200;D&&(l.status=L,S=S.response);let P=g?.createResponse?.()?.[L];if(P?.provider==="standard")S=await dc("response",P,S);else if(P?.Check(S)===!1)if(P?.Clean)try{let j=P.Clean(S);if(P?.Check(j)===!1)throw new ie("response",P,S);S=j}catch(j){throw j instanceof ie?j:new ie("response",P,S)}else throw new ie("response",P,S);if(P?.Encode&&(S=P.Encode(S)),P?.Clean)try{S=P.Clean(S)}catch{}}if(u.set.cookie&&E?.sign){let D=E.secrets?typeof E.secrets=="string"?E.secrets:E.secrets[0]:void 0;if(E.sign===!0){if(D)for(let[L,P]of Object.entries(u.set.cookie))u.set.cookie[L].value=await Ml(P.value,D)}else{let L=ti(g?.cookie?.schema);if(D)for(let P of E.sign)!L||!(P in L)||u.set.cookie[P]?.value&&(u.set.cookie[P].value=await Ml(u.set.cookie[P].value,D))}}return t(u.response=S,u.set)}catch(f){let p=f instanceof Va&&f.error?f.error:f;return e.handleError(u,p)}finally{let f=d?d.afterResponse:e.event.afterResponse;f&&($g?setImmediate(async()=>{for(let p of f)await p.fn(u)}):Promise.resolve().then(async()=>{for(let p of f)await p.fn(u)}))}}},W1=(e)=>{let{mapResponse:t}=e["~adapter"].handler;return async(r,n)=>{let o=Object.assign(r,{error:n,code:n.code});if(o.set=r.set,typeof n?.toResponse=="function"&&!(n instanceof ie)&&!(n instanceof Va))try{let i=n.toResponse();typeof i?.then=="function"&&(i=await i),i instanceof Response&&(r.set.status=i.status),r.response=i}catch{}if(!r.response&&e.event.error)for(let i=0;i<e.event.error.length;i++){let s=e.event.error[i].fn(o);if(s instanceof Promise&&(s=await s),s!=null)return r.response=t(s,r.set)}if(r.response){if(e.event.mapResponse)for(let i=0;i<e.event.mapResponse.length;i++){let s=e.event.mapResponse[i].fn(o);s instanceof Promise&&(s=await s),s!=null&&(r.response=s)}return t(r.response,r.set)}return r.set.status=n.status??500,t(typeof n.cause=="string"?n.cause:n.message,r.set)}};var H1;H1=Symbol.dispose;var Fre=class e{constructor(t={}){this.server=null,this.dependencies={},this["~Prefix"]="",this["~Singleton"]=null,this["~Definitions"]=null,this["~Metadata"]=null,this["~Ephemeral"]=null,this["~Volatile"]=null,this["~Routes"]=null,this.singleton={decorator:{},store:{},derive:{},resolve:{}},this.definitions={typebox:V.Module({}),type:{},error:{}},this.extender={macro:{},higherOrderFunctions:[]},this.validator={global:null,scoped:null,local:null,getCandidate(){return!this.global&&!this.scoped&&!this.local?{body:void 0,headers:void 0,params:void 0,query:void 0,cookie:void 0,response:void 0}:Ol(Ol(this.global,this.scoped),this.local)}},this.standaloneValidator={global:null,scoped:null,local:null},this.event={},this.router={"~http":void 0,get http(){return this["~http"]||(this["~http"]=new Ea({lazy:!0,onParam:zS.default})),this["~http"]},"~dynamic":void 0,get dynamic(){return this["~dynamic"]||(this["~dynamic"]=new Ea({onParam:zS.default})),this["~dynamic"]},static:{},response:{},history:[]},this.routeTree={},this.inference={body:!1,cookie:!1,headers:!1,query:!1,set:!1,server:!1,path:!1,route:!1,url:!1},this["~parser"]={},this.handle=async(r)=>this.fetch(r),this.handleError=async(r,n)=>(this.handleError=this.config.aot?HS(this):W1(this))(r,n),this.listen=(r,n)=>(this["~adapter"].listen(this)(r,n),this),this.stop=async(r)=>(await this["~adapter"].stop?.(this,r),this),this[H1]=()=>{this.server&&this.stop()},t.tags&&(t.detail?t.detail.tags=t.tags:t.detail={tags:t.tags}),this.config={aot:Fh.ELYSIA_AOT!=="false",nativeStaticResponse:!0,encodeSchema:!0,normalize:!0,...t,prefix:t.prefix?t.prefix.charCodeAt(0)===47?t.prefix:`/${t.prefix}`:void 0,cookie:{path:"/",...t?.cookie},experimental:t?.experimental??{},seed:t?.seed===void 0?"":t?.seed},this["~adapter"]=t.adapter??(typeof Bun<"u"?D1:Tp),t?.analytic&&(t?.name||t?.seed!==void 0)&&(this.telemetry={stack:Error().stack})}get store(){return this.singleton.store}get decorator(){return this.singleton.decorator}get routes(){return this.router.history}getGlobalRoutes(){return this.router.history}getGlobalDefinitions(){return this.definitions}getServer(){return this.server}getParent(){return null}get promisedModules(){return this._promisedModules||(this._promisedModules=new Qx(console.error,()=>{})),this._promisedModules}env(t,r=Fh){if(St(t,{modules:this.definitions.typebox,dynamic:!0,additionalProperties:!0,coerce:!0,sanitize:()=>this.config.sanitize}).Check(r)===!1){let n=new ie("env",t,r);throw Error(n.all.map((o)=>o.summary).join(`
|
|
666
|
-
`))}return this}wrap(t){return this.extender.higherOrderFunctions.push({checksum:Ni(JSON.stringify({name:this.config.name,seed:this.config.seed,content:t.toString()})),fn:t}),this}get models(){let t={};for(let r of Object.keys(this.definitions.type))t[r]=St(this.definitions.typebox.Import(r),{models:this.definitions.type});return t.modules=this.definitions.typebox,t}add(t,r,n,o,i){let s=i?.skipPrefix??!1,a=i?.allowMeta??!1;o??={},this.applyMacro(o);let c=[];if(o.standaloneValidator&&(c=c.concat(o.standaloneValidator)),this.standaloneValidator.local&&(c=c.concat(this.standaloneValidator.local)),this.standaloneValidator.scoped&&(c=c.concat(this.standaloneValidator.scoped)),this.standaloneValidator.global&&(c=c.concat(this.standaloneValidator.global)),r!==""&&r.charCodeAt(0)!==47&&(r="/"+r),this.config.prefix&&!s&&(r=this.config.prefix+r),o?.type)switch(o.type){case"text":o.type="text/plain";break;case"json":o.type="application/json";break;case"formdata":o.type="multipart/form-data";break;case"urlencoded":o.type="application/x-www-form-urlencoded";break;case"arrayBuffer":o.type="application/octet-stream";break;default:break}let l=this.validator.getCandidate(),u={body:o?.body??l?.body,headers:o?.headers??l?.headers,params:o?.params??l?.params,query:o?.query??l?.query,cookie:o?.cookie??l?.cookie,response:o?.response??l?.response},d=this.config.precompile===!0||typeof this.config.precompile=="object"&&this.config.precompile.compose===!0,f=()=>{let P=this.definitions.type,j=!this.config.aot,B=this.config.normalize,J=this.definitions.typebox,te=()=>this.config.sanitize,oe=()=>{if(u.cookie||c.find((re)=>re.cookie))return v1({modules:J,validator:u.cookie,defaultConfig:this.config.cookie,normalize:B,config:u.cookie?.config??{},dynamic:j,models:P,validators:c.map((re)=>re.cookie),sanitize:te})};return d?{body:St(u.body,{modules:J,dynamic:j,models:P,normalize:B,additionalCoerce:(()=>{let re=US(u.body,P,J);return re&&O in re&&(lr("File",re)||lr("Files",re))?LS():Ep()})(),validators:c.map((re)=>re.body),sanitize:te}),headers:St(u.headers,{modules:J,dynamic:j,models:P,additionalProperties:!0,coerce:!0,additionalCoerce:lc(),validators:c.map((re)=>re.headers),sanitize:te}),params:St(u.params,{modules:J,dynamic:j,models:P,coerce:!0,additionalCoerce:lc(),validators:c.map((re)=>re.params),sanitize:te}),query:St(u.query,{modules:J,dynamic:j,models:P,normalize:B,coerce:!0,additionalCoerce:DS(),validators:c.map((re)=>re.query),sanitize:te}),cookie:oe(),response:Ph(u.response,{modules:J,dynamic:j,models:P,normalize:B,validators:c.map((re)=>re.response),sanitize:te})}:{createBody(){return this.body?this.body:this.body=St(u.body,{modules:J,dynamic:j,models:P,normalize:B,additionalCoerce:(()=>{let re=US(u.body,P,J);return re&&O in re&&(lr("File",re)||lr("Files",re))?LS():Ep()})(),validators:c.map((re)=>re.body),sanitize:te})},createHeaders(){return this.headers?this.headers:this.headers=St(u.headers,{modules:J,dynamic:j,models:P,normalize:B,additionalProperties:!B,coerce:!0,additionalCoerce:lc(),validators:c.map((re)=>re.headers),sanitize:te})},createParams(){return this.params?this.params:this.params=St(u.params,{modules:J,dynamic:j,models:P,normalize:B,coerce:!0,additionalCoerce:lc(),validators:c.map((re)=>re.params),sanitize:te})},createQuery(){return this.query?this.query:this.query=St(u.query,{modules:J,dynamic:j,models:P,normalize:B,coerce:!0,additionalCoerce:DS(),validators:c.map((re)=>re.query),sanitize:te})},createCookie(){return this.cookie?this.cookie:this.cookie=oe()},createResponse(){return this.response?this.response:this.response=Ph(u.response,{modules:J,dynamic:j,models:P,normalize:B,validators:c.map((re)=>re.response),sanitize:te})}}};(l.body||l.cookie||l.headers||l.params||l.query||l.response)&&(o=Yo(o,l)),o.tags&&(o.detail?o.detail.tags=o.tags:o.detail={tags:o.tags}),Re(this.config.detail)&&(o.detail=$t(Object.assign({},this.config.detail),o.detail));let p=Re(this.event)?Yo(this.event,Zx(o)):{...kO(Zx(o))};if(c.length&&Object.assign(p,{standaloneValidator:c}),this.config.aot===!1){let P=f();this.router.dynamic.add(t,r,{validator:P,hooks:p,content:o?.type,handle:n,route:r});let j=Ya(r,{dynamic:!0});if(r!==j&&this.router.dynamic.add(t,j,{validator:P,hooks:p,content:o?.type,handle:n,route:r}),!this.config.strictPath){let B=Ja(r);this.router.dynamic.add(t,B,{validator:P,hooks:p,content:o?.type,handle:n,route:r});let J=Ya(B);B!==J&&this.router.dynamic.add(t,B,{validator:P,hooks:p,content:o?.type,handle:n,route:r})}this.router.history.push({method:t,path:r,composed:null,handler:n,compile:void 0,hooks:p});return}let h=this["~adapter"].handler,g=typeof n!="function"?()=>{let P=h.createNativeStaticHandler?.(n,p,{headers:Object.assign({},this.setHeaders)});return P instanceof Promise?P.then((j)=>{if(j)return j}):P?.()}:void 0,y=this.config.nativeStaticResponse===!0,b=(P)=>{!y||!g||(Xg?this.router.response[P]?this.router.response[P][t]=g():this.router.response[P]={[t]:g()}:this.router.response[P]=g())};b(r);let w,E=()=>{if(w)return w;let P=E1({app:this,path:r,method:t,hooks:p,validator:f(),handler:typeof n!="function"&&typeof h.createStaticHandler!="function"?()=>n:n,allowMeta:a,inference:this.inference});return this.router.history[v]&&(w=this.router.history[v].composed=P),P},A;if(`${t}_${r}`in this.routeTree)for(let P=0;P<this.router.history.length;P++){let j=this.router.history[P];if(j.path===r&&j.method===t){A=P;break}}else this.routeTree[`${t}_${r}`]=this.router.history.length;let v=A??this.router.history.length,T=this.router.history,I=d?E():(P)=>w?w(P):(T[v].composed=E())(P);A!==void 0?this.router.history[A]=Object.assign({method:t,path:r,composed:I,compile:E,handler:n,hooks:p},c.length?{standaloneValidators:c}:void 0,o.webSocket?{websocket:o.websocket}:void 0):this.router.history.push(Object.assign({method:t,path:r,composed:I,compile:E,handler:n,hooks:p},o.webSocket?{websocket:o.websocket}:void 0));let S={handler:d?T[v].composed:void 0,compile(){return this.handler=E()}},D=this.router.static,L=r.indexOf(":")===-1&&r.indexOf("*")===-1;if(t==="WS"){if(L){r in D?D[r][t]=v:D[r]={[t]:v};return}this.router.http.add("WS",r,S),this.config.strictPath||this.router.http.add("WS",Ja(r),S);let P=Ya(r,{dynamic:!0});r!==P&&this.router.http.add("WS",P,S);return}if(L)r in D?D[r][t]=v:D[r]={[t]:v},this.config.strictPath||b(Ja(r));else{if(this.router.http.add(t,r,S),!this.config.strictPath){let j=Ja(r);b(j),this.router.http.add(t,j,S)}let P=Ya(r,{dynamic:!0});r!==P&&(this.router.http.add(t,P,S),b(P))}}headers(t){return t?(this.setHeaders||(this.setHeaders={}),this.setHeaders=$t(this.setHeaders,t),this):this}onStart(t){return this.on("start",t),this}onRequest(t){return this.on("request",t),this}onParse(t,r){return r?this.on(t,"parse",r):typeof t=="string"?this.on("parse",this["~parser"][t]):this.on("parse",t)}parser(t,r){return this["~parser"][t]=r,this}onTransform(t,r){return r?this.on(t,"transform",r):this.on("transform",t)}resolve(t,r){r||(r=t,t={as:"local"});let n={subType:"resolve",fn:r};return this.onBeforeHandle(t,n)}mapResolve(t,r){r||(r=t,t={as:"local"});let n={subType:"mapResolve",fn:r};return this.onBeforeHandle(t,n)}onBeforeHandle(t,r){return r?this.on(t,"beforeHandle",r):this.on("beforeHandle",t)}onAfterHandle(t,r){return r?this.on(t,"afterHandle",r):this.on("afterHandle",t)}mapResponse(t,r){return r?this.on(t,"mapResponse",r):this.on("mapResponse",t)}onAfterResponse(t,r){return r?this.on(t,"afterResponse",r):this.on("afterResponse",t)}trace(t,r){r||(r=t,t={as:"local"}),Array.isArray(r)||(r=[r]);for(let n of r)this.on(t,"trace",y1(n));return this}error(t,r){switch(typeof t){case"string":return r.prototype[Xa]=t,this.definitions.error[t]=r,this;case"function":return this.definitions.error=t(this.definitions.error),this}for(let[n,o]of Object.entries(t))o.prototype[Xa]=n,this.definitions.error[n]=o;return this}onError(t,r){return r?this.on(t,"error",r):this.on("error",t)}onStop(t){return this.on("stop",t),this}on(t,r,n){let o;switch(typeof t){case"string":o=t,n=r;break;case"object":o=r,!Array.isArray(r)&&typeof r=="object"&&(n=r);break}Array.isArray(n)?n=Gt(n):typeof n=="function"?n=[{fn:n}]:n=[n];let i=n;for(let s of i)s.scope=typeof t=="string"?"local":t?.as??"local",(o==="resolve"||o==="derive")&&(s.subType=o);o!=="trace"&&(this.inference=ic({[o]:i.map((s)=>s.fn)},this.inference,this.config.sucrose));for(let s of i){let a=TO(s,"global",{skipIfHasType:!0});switch((this.config.name||this.config.seed)&&(a.checksum=Ni(this.config.name+JSON.stringify(this.config.seed))),o){case"start":this.event.start??=[],this.event.start.push(a);break;case"request":this.event.request??=[],this.event.request.push(a);break;case"parse":this.event.parse??=[],this.event.parse.push(a);break;case"transform":this.event.transform??=[],this.event.transform.push(a);break;case"derive":this.event.transform??=[],this.event.transform.push(Gt(a,"derive"));break;case"beforeHandle":this.event.beforeHandle??=[],this.event.beforeHandle.push(a);break;case"resolve":this.event.beforeHandle??=[],this.event.beforeHandle.push(Gt(a,"resolve"));break;case"afterHandle":this.event.afterHandle??=[],this.event.afterHandle.push(a);break;case"mapResponse":this.event.mapResponse??=[],this.event.mapResponse.push(a);break;case"afterResponse":this.event.afterResponse??=[],this.event.afterResponse.push(a);break;case"trace":this.event.trace??=[],this.event.trace.push(a);break;case"error":this.event.error??=[],this.event.error.push(a);break;case"stop":this.event.stop??=[],this.event.stop.push(a);break}}return this}as(t){return Li(this.event.parse,t),Li(this.event.transform,t),Li(this.event.beforeHandle,t),Li(this.event.afterHandle,t),Li(this.event.mapResponse,t),Li(this.event.afterResponse,t),Li(this.event.trace,t),Li(this.event.error,t),t==="scoped"?(this.validator.scoped=Ol(this.validator.scoped,this.validator.local),this.validator.local=null,this.standaloneValidator.local!==null&&(this.standaloneValidator.scoped||=[],this.standaloneValidator.scoped.push(...this.standaloneValidator.local),this.standaloneValidator.local=null)):t==="global"&&(this.validator.global=Ol(this.validator.global,Ol(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null,this.standaloneValidator.local!==null&&(this.standaloneValidator.scoped||=[],this.standaloneValidator.scoped.push(...this.standaloneValidator.local),this.standaloneValidator.local=null),this.standaloneValidator.scoped!==null&&(this.standaloneValidator.global||=[],this.standaloneValidator.global.push(...this.standaloneValidator.scoped),this.standaloneValidator.scoped=null)),this}group(t,r,n){let o=new e({...this.config,prefix:""});o.singleton={...this.singleton},o.definitions={...this.definitions},o.getServer=()=>this.getServer(),o.inference=Yg(this.inference),o.extender={...this.extender},o["~parser"]=this["~parser"],o.standaloneValidator={local:[...this.standaloneValidator.local??[]],scoped:[...this.standaloneValidator.scoped??[]],global:[...this.standaloneValidator.global??[]]};let i=typeof r=="object",s=(i?n:r)(o);return this.singleton=$t(this.singleton,o.singleton),this.definitions=$t(this.definitions,o.definitions),s.event.request?.length&&(this.event.request=[...this.event.request||[],...s.event.request||[]]),s.event.mapResponse?.length&&(this.event.mapResponse=[...this.event.mapResponse||[],...s.event.mapResponse||[]]),this.model(s.definitions.type),Object.values(o.router.history).forEach(({method:a,path:c,handler:l,hooks:u})=>{if(c=(i?"":this.config.prefix??"")+t+c,i){let{body:d,headers:f,query:p,params:h,cookie:g,response:y,...b}=r,w=u;this.applyMacro(b);let E=d||f||p||h||g||y;this.add(a,c,l,Yo(b,{...w||{},error:w.error?Array.isArray(w.error)?[...w.error??[],...s.event.error??[]]:[w.error,...s.event.error??[]]:s.event.error,standaloneValidator:b.standaloneValidator||w.standaloneValidator||E?[...b.standaloneValidator??[],...w.standaloneValidator??[],...E?[{body:d,headers:f,query:p,params:h,cookie:g,response:y}]:[]]:void 0}),void 0)}else this.add(a,c,l,Yo(u,{error:s.event.error}),{skipPrefix:!0})}),this}guard(t,r){if(!r){if(typeof t=="object"){this.applyMacro(t),t.detail&&(this.config.detail?this.config.detail=$t(Object.assign({},this.config.detail),t.detail):this.config.detail=t.detail),t.tags&&(this.config.detail?this.config.detail.tags=t.tags:this.config.detail={tags:t.tags});let i=t.as??"local";if(t.schema==="standalone"){this.standaloneValidator[i]||(this.standaloneValidator[i]=[]);let s=t?.response?typeof t.response=="string"||O in t.response||"~standard"in t.response?{200:t.response}:t?.response:void 0;this.standaloneValidator[i].push({body:t.body,headers:t.headers,params:t.params,query:t.query,response:s,cookie:t.cookie})}else this.validator[i]={body:t.body??this.validator[i]?.body,headers:t.headers??this.validator[i]?.headers,params:t.params??this.validator[i]?.params,query:t.query??this.validator[i]?.query,response:t.response??this.validator[i]?.response,cookie:t.cookie??this.validator[i]?.cookie};return t.parse&&this.on({as:i},"parse",t.parse),t.transform&&this.on({as:i},"transform",t.transform),t.derive&&this.on({as:i},"derive",t.derive),t.beforeHandle&&this.on({as:i},"beforeHandle",t.beforeHandle),t.resolve&&this.on({as:i},"resolve",t.resolve),t.afterHandle&&this.on({as:i},"afterHandle",t.afterHandle),t.mapResponse&&this.on({as:i},"mapResponse",t.mapResponse),t.afterResponse&&this.on({as:i},"afterResponse",t.afterResponse),t.error&&this.on({as:i},"error",t.error),this}return this.guard({},t)}let n=new e({...this.config,prefix:""});n.singleton={...this.singleton},n.definitions={...this.definitions},n.inference=Yg(this.inference),n.extender={...this.extender},n.getServer=()=>this.getServer();let o=r(n);if(this.singleton=$t(this.singleton,n.singleton),this.definitions=$t(this.definitions,n.definitions),o.getServer=()=>this.server,o.event.request?.length&&(this.event.request=[...this.event.request||[],...o.event.request||[]]),o.event.mapResponse?.length&&(this.event.mapResponse=[...this.event.mapResponse||[],...o.event.mapResponse||[]]),this.model(o.definitions.type),Object.values(n.router.history).forEach(({method:i,path:s,handler:a,hooks:c})=>{let{body:l,headers:u,query:d,params:f,cookie:p,response:h,...g}=t,y=l||u||d||f||p||h;this.add(i,s,a,Yo(g,{...c||{},error:c.error?Array.isArray(c.error)?[...c.error??[],...o.event.error??[]]:[c.error,...o.event.error??[]]:o.event.error,standaloneValidator:y?[...c.standaloneValidator??[],{body:l,headers:u,query:d,params:f,cookie:p,response:h}]:c.standaloneValidator}))}),n.promisedModules.size>0){let i=n.router.history.length;for(let s of n.promisedModules.promises)this.promisedModules.add(s.then(()=>{let{body:a,headers:c,query:l,params:u,cookie:d,response:f,...p}=t,h=a||c||l||u||d||f,g=i;i=n.router.history.length;for(let y=g;y<n.router.history.length;y++){let{method:b,path:w,handler:E,hooks:A}=n.router.history[y];this.add(b,w,E,Yo(p,{...A||{},error:A.error?Array.isArray(A.error)?[...A.error??[],...o.event.error??[]]:[A.error,...o.event.error??[]]:o.event.error,standaloneValidator:h?[...A.standaloneValidator??[],{body:a,headers:c,query:l,params:u,cookie:d,response:f}]:A.standaloneValidator}))}}))}return this}use(t){if(!t)return this;if(Array.isArray(t)){let r=this;for(let n of t)r=r.use(n);return r}return t instanceof Promise?(this.promisedModules.add(t.then((r)=>{if(typeof r=="function")return r(this);if(r instanceof e)return this._use(r).compile();if(r.constructor?.name==="Elysia")return this._use(r).compile();if(typeof r.default=="function")return r.default(this);if(r.default instanceof e)return this._use(r.default);if(r.constructor?.name==="Elysia")return this._use(r.default);if(r.constructor?.name==="_Elysia")return this._use(r.default);try{return this._use(r.default)}catch(n){throw console.error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.'),n}}).then((r)=>(r&&typeof r.compile=="function"&&r.compile(),r))),this):this._use(t)}propagatePromiseModules(t){if(t.promisedModules.size<=0)return this;for(let r of t.promisedModules.promises)this.promisedModules.add(r.then((n)=>{if(!n)return;let o=this._use(n);return o instanceof Promise?o.then((i)=>{i?i.compile():n.compile()}):n.compile()}));return this}_use(t){if(typeof t=="function"){let o=t(this);return o instanceof Promise?(this.promisedModules.add(o.then((i)=>{if(i instanceof e){i.getServer=()=>this.getServer(),i.getGlobalRoutes=()=>this.getGlobalRoutes(),i.getGlobalDefinitions=()=>this.getGlobalDefinitions(),i.model(this.definitions.type),i.error(this.definitions.error);for(let{method:s,path:a,handler:c,hooks:l}of Object.values(i.router.history))this.add(s,a,c,l,void 0);return i===this?void 0:(this.propagatePromiseModules(i),i)}return typeof i=="function"?i(this):typeof i.default=="function"?i.default(this):this._use(i)}).then((i)=>(i&&typeof i.compile=="function"&&i.compile(),i))),this):o}this.propagatePromiseModules(t);let r=t.config.name,n=t.config.seed;if(t.getParent=()=>this,t.getServer=()=>this.getServer(),t.getGlobalRoutes=()=>this.getGlobalRoutes(),t.getGlobalDefinitions=()=>this.getGlobalDefinitions(),t.standaloneValidator?.scoped&&(this.standaloneValidator.local?this.standaloneValidator.local=this.standaloneValidator.local.concat(t.standaloneValidator.scoped):this.standaloneValidator.local=t.standaloneValidator.scoped),t.standaloneValidator?.global&&(this.standaloneValidator.global?this.standaloneValidator.global=this.standaloneValidator.global.concat(t.standaloneValidator.global):this.standaloneValidator.global=t.standaloneValidator.global),Re(t["~parser"])&&(this["~parser"]={...t["~parser"],...this["~parser"]}),t.setHeaders&&this.headers(t.setHeaders),r){r in this.dependencies||(this.dependencies[r]=[]);let o=n!==void 0?Ni(r+JSON.stringify(n)):0;this.dependencies[r].some(({checksum:i})=>o===i)||(this.extender.macro={...this.extender.macro,...t.extender.macro},this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(t.extender.higherOrderFunctions))}else Re(t.extender.macro)&&(this.extender.macro={...this.extender.macro,...t.extender.macro}),t.extender.higherOrderFunctions.length&&(this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(t.extender.higherOrderFunctions));if(t.extender.higherOrderFunctions.length){tS(this.extender.higherOrderFunctions);let o=[];for(let i=0;i<this.extender.higherOrderFunctions.length;i++){let s=this.extender.higherOrderFunctions[i];s.checksum&&(o.includes(s.checksum)&&(this.extender.higherOrderFunctions.splice(i,1),i--),o.push(s.checksum))}o.length=0}this.inference=yh(this.inference,t.inference),Re(t.singleton.decorator)&&this.decorate(t.singleton.decorator),Re(t.singleton.store)&&this.state(t.singleton.store),Re(t.definitions.type)&&this.model(t.definitions.type),Re(t.definitions.error)&&this.error(t.definitions.error),Re(t.extender.macro)&&(this.extender.macro={...this.extender.macro,...t.extender.macro});for(let{method:o,path:i,handler:s,hooks:a}of Object.values(t.router.history))this.add(o,i,s,a);if(r){r in this.dependencies||(this.dependencies[r]=[]);let o=n!==void 0?Ni(r+JSON.stringify(n)):0;if(this.dependencies[r].some(({checksum:i})=>o===i))return this;this.dependencies[r].push(this.config?.analytic?{name:t.config.name,seed:t.config.seed,checksum:o,dependencies:t.dependencies,stack:t.telemetry?.stack,routes:t.router.history,decorators:t.singleton,store:t.singleton.store,error:t.definitions.error,derive:t.event.transform?.filter((i)=>i?.subType==="derive").map((i)=>({fn:i.toString(),stack:Error().stack??""})),resolve:t.event.transform?.filter((i)=>i?.subType==="resolve").map((i)=>({fn:i.toString(),stack:Error().stack??""}))}:{name:t.config.name,seed:t.config.seed,checksum:o,dependencies:t.dependencies}),Re(t.event)&&(this.event=Jx(this.event,Yx(t.event),o))}else Re(t.event)&&(this.event=Jx(this.event,Yx(t.event)));return t.validator.global&&(this.validator.global=Yo(this.validator.global,{...t.validator.global})),t.validator.scoped&&(this.validator.local=Yo(this.validator.local,{...t.validator.scoped})),this}macro(t,r){if(typeof t=="string"&&!r)throw Error("Macro function is required");return typeof t=="string"?this.extender.macro[t]=r:this.extender.macro={...this.extender.macro,...t},this}applyMacro(t,r=t,{iteration:n=0,applied:o={}}={}){if(n>=16)return;let i=this.extender.macro;for(let[s,a]of Object.entries(r)){if(!(s in i))continue;let c=typeof i[s]=="function"?i[s](a):i[s];if(!c||typeof i[s]=="object"&&a===!1)return;let l=Ni(s+JSON.stringify(c.seed??a));if(!(l in o)){o[l]=!0;for(let[u,d]of Object.entries(c))if(u!=="seed"){if(u in EO){vO(t,u,d),delete t[s];continue}if(u==="introspect"){d?.(t),delete t[s];continue}if(u==="detail"){t.detail||(t.detail={}),t.detail=$t(t.detail,d,{mergeArray:!0}),delete t[s];continue}if(u in i){this.applyMacro(t,{[u]:d},{applied:o,iteration:n+1}),delete t[s];continue}switch((u==="derive"||u==="resolve")&&typeof d=="function"&&(d={fn:d,subType:u}),typeof t[u]){case"function":t[u]=[t[u],d];break;case"object":Array.isArray(t[u])?t[u].push(d):t[u]=[t[u],d];break;case"undefined":t[u]=d;break}delete t[s]}}}}mount(t,r,n){if(t instanceof e||typeof t=="function"||t.length===0||t==="/"){let a=typeof t=="function"?t:t instanceof e?t.compile().fetch:r instanceof e?r.compile().fetch:typeof r=="function"?r:(()=>{throw Error("Invalid handler")})(),c=({request:l,path:u})=>a(new Request(Gg(l.url,u),l));return this.route("ALL","/*",c,{parse:"none",...n,detail:{...n?.detail,hide:!0},config:{mount:a}}),this}let o=r instanceof e?r.compile().fetch:typeof r=="function"?r:(()=>{throw Error("Invalid handler")})(),i=(typeof t=="string"&&this.config.prefix?this.config.prefix+t:t).length-(t.endsWith("*")?1:0),s=({request:a,path:c})=>o(new Request(Gg(a.url,c.slice(i)||"/"),a));return this.route("ALL",t,s,{parse:"none",...n,detail:{...n?.detail,hide:!0},config:{mount:o}}),this.route("ALL",t+(t.endsWith("/")?"*":"/*"),s,{parse:"none",...n,detail:{...n?.detail,hide:!0},config:{mount:o}}),this}get(t,r,n){return this.add("GET",t,r,n),this}post(t,r,n){return this.add("POST",t,r,n),this}put(t,r,n){return this.add("PUT",t,r,n),this}patch(t,r,n){return this.add("PATCH",t,r,n),this}delete(t,r,n){return this.add("DELETE",t,r,n),this}options(t,r,n){return this.add("OPTIONS",t,r,n),this}all(t,r,n){return this.add("ALL",t,r,n),this}head(t,r,n){return this.add("HEAD",t,r,n),this}connect(t,r,n){return this.add("CONNECT",t,r,n),this}route(t,r,n,o){return this.add(t.toUpperCase(),r,n,o,o?.config),this}ws(t,r){return this["~adapter"].ws?this["~adapter"].ws(this,t,r):console.warn("Current adapter doesn't support WebSocket"),this}state(t,r,n){r===void 0?(n=t,t={as:"append"},r=""):n===void 0&&(typeof t=="string"?(n=r,r=t,t={as:"append"}):typeof t=="object"&&(n=r,r=""));let{as:o}=t;if(typeof r!="string")return this;switch(typeof n){case"object":return!n||!Re(n)?this:r?((r in this.singleton.store)?this.singleton.store[r]=$t(this.singleton.store[r],n,{override:o==="override"}):this.singleton.store[r]=n,this):n===null?this:(this.singleton.store=$t(this.singleton.store,n,{override:o==="override"}),this);case"function":return r?(o==="override"||!(r in this.singleton.store))&&(this.singleton.store[r]=n):this.singleton.store=n(this.singleton.store),this;default:return(o==="override"||!(r in this.singleton.store))&&(this.singleton.store[r]=n),this}}decorate(t,r,n){r===void 0?(n=t,t={as:"append"},r=""):n===void 0&&(typeof t=="string"?(n=r,r=t,t={as:"append"}):typeof t=="object"&&(n=r,r=""));let{as:o}=t;if(typeof r!="string")return this;switch(typeof n){case"object":return r?((r in this.singleton.decorator)?this.singleton.decorator[r]=$t(this.singleton.decorator[r],n,{override:o==="override"}):this.singleton.decorator[r]=n,this):n===null?this:(this.singleton.decorator=$t(this.singleton.decorator,n,{override:o==="override"}),this);case"function":return r?(o==="override"||!(r in this.singleton.decorator))&&(this.singleton.decorator[r]=n):this.singleton.decorator=n(this.singleton.decorator),this;default:return(o==="override"||!(r in this.singleton.decorator))&&(this.singleton.decorator[r]=n),this}}derive(t,r){r||(r=t,t={as:"local"});let n={subType:"derive",fn:r};return this.onTransform(t,n)}model(t,r){let n=(o)=>{let i={};for(let s in o)"~standard"in o[s]||(i[s]=o[s]);return i};switch(typeof t){case"object":let o={},i=Object.entries(t);if(!i.length)return this;for(let[c,l]of i)c in this.definitions.type||("~standard"in l?this.definitions.type[c]=l:(o[c]=this.definitions.type[c]=l,o[c].$id??=`#/components/schemas/${c}`));return this.definitions.typebox=V.Module({...this.definitions.typebox.$defs,...o}),this;case"function":let s=t(this.definitions.type);return this.definitions.type=s,this.definitions.typebox=V.Module(n(s)),this;case"string":if(!r)break;if(this.definitions.type[t]=r,"~standard"in r)return this;let a={...r,id:r.$id??`#/components/schemas/${t}`};return this.definitions.typebox=V.Module({...this.definitions.typebox.$defs,...a}),this}return r?(this.definitions.type[t]=r,("~standard"in r)?this:(this.definitions.typebox=V.Module({...this.definitions.typebox.$defs,[t]:r}),this)):this}Ref(t){return V.Ref(t)}mapDerive(t,r){r||(r=t,t={as:"local"});let n={subType:"mapDerive",fn:r};return this.onTransform(t,n)}affix(t,r,n){if(n==="")return this;let o=["_","-"," "],i=(l)=>l[0].toUpperCase()+l.slice(1),s=t==="prefix"?(l,u)=>o.includes(l.at(-1)??"")?l+u:l+i(u):o.includes(n.at(-1)??"")?(l,u)=>u+l:(l,u)=>u+i(l),a=(l)=>{let u={};switch(l){case"decorator":for(let d in this.singleton.decorator)u[s(n,d)]=this.singleton.decorator[d];this.singleton.decorator=u;break;case"state":for(let d in this.singleton.store)u[s(n,d)]=this.singleton.store[d];this.singleton.store=u;break;case"model":for(let d in this.definitions.type)u[s(n,d)]=this.definitions.type[d];this.definitions.type=u;break;case"error":for(let d in this.definitions.error)u[s(n,d)]=this.definitions.error[d];this.definitions.error=u;break}},c=Array.isArray(r)?r:[r];for(let l of c.some((u)=>u==="all")?["decorator","state","model","error"]:c)a(l);return this}prefix(t,r){return this.affix("prefix",t,r)}suffix(t,r){return this.affix("suffix",t,r)}compile(){return this["~adapter"].beforeCompile?.(this),this["~adapter"].isWebStandard?(this._handle=this.config.aot?Oh(this):$S(this),Object.defineProperty(this,"fetch",{value:this._handle,configurable:!0,writable:!0}),typeof this.server?.reload=="function"&&this.server.reload({...this.server||{},fetch:this.fetch}),this):(typeof this.server?.reload=="function"&&this.server.reload(this.server||{}),this._handle=Oh(this),this)}get fetch(){let t=this.config.aot?Oh(this):$S(this);return Object.defineProperty(this,"fetch",{value:t,configurable:!0,writable:!0}),t}get modules(){return this.promisedModules}},Jn=Fre;var Dh={name:"@kabmo-labs/kabmo",version:"0.6.0",description:"Web console and diagnostic workbench for AI coding agents \u2014 Elysia + Preact on Bun.",license:"UNLICENSED",author:"Wijanarko Putra Rajeb <wijanarko.rajeb@gmail.com>",type:"module",engines:{bun:">=1.4.0"},publishConfig:{access:"public"},bin:{kabmo:"./src/cli/kabmo.js"},repository:{type:"git",url:"git+https://github.com/kabmo-labs/kabmo.git"},homepage:"https://github.com/kabmo-labs/kabmo#readme",bugs:{url:"https://github.com/kabmo-labs/kabmo/issues"},keywords:["kabmo","coding-agent","agent","console","elysia","preact","bun"],files:["src","extensions","index.html","bunfig.toml","public","tsconfig.json","marketplace","dist/client"],scripts:{dev:"bun run --hot src/server/index.ts --kabmo-server","dev:lan":"HOST=0.0.0.0 bun run --hot src/server/index.ts --kabmo-server",build:"bun run scripts/build-client.ts","omp:schema":"bun run scripts/omp-schema.mjs","omp:schema:check":"bun run scripts/omp-schema.mjs --check",start:"NODE_ENV=production bun run src/server/index.ts --kabmo-server",typecheck:"tsc",clean:"rm -rf dist",lint:"tsc --noEmit",test:"bun test","test:e2e":"playwright test --config tests/e2e/playwright.config.ts","readme:media":"bun run scripts/readme-media.ts","typecheck:e2e":"tsc --noEmit -p tests/e2e","publish:plugins":"bash .github/scripts/publish-plugin-packages.sh packages/kabmo-sdk packages/kabmo-ui"},dependencies:{"@fontsource/fira-code":"^5.3.0","@kabmo-labs/kabmo-sdk":"workspace:*","@kabmo-labs/kabmo-ui":"workspace:*","@shikijs/langs":"^4.4.3","@shikijs/themes":"^4.4.3","@tailwindcss/postcss":"^4.1.14","@xterm/addon-fit":"^0.11.0","@xterm/addon-webgl":"^0.19.0","@xterm/xterm":"^6.0.0",dompurify:"^3.4.15",elysia:"^1.4.30",katex:"^0.18.7","lucide-preact":"^1.47.0",mammoth:"^1.13.0",marked:"^18.0.11","marked-linkify-it":"^4.0.2",mermaid:"^12.0.0",postcss:"^8.5.16",preact:"^10.29.8","read-excel-file":"^9.3.12",remend:"^1.3.1",ripgrep:"^0.3.1",shiki:"^4.4.3",tailwindcss:"^4.1.14",yaml:"^2.9.1"},devDependencies:{"@playwright/test":"^1.64.0","@semantic-release/changelog":"^7.0.0","@semantic-release/commit-analyzer":"^13.0.1","@semantic-release/git":"^11.0.1","@semantic-release/github":"^12.0.10","@semantic-release/npm":"^13.2.0","@semantic-release/release-notes-generator":"^14.1.1","@types/bun":"^1.4.2","@types/node":"^22.14.0","bun-types":"^1.4.2","conventional-changelog-conventionalcommits":"^9.3.1","happy-dom":"^20.14.5","semantic-release":"^25.0.9",typescript:"~5.8.2"},workspaces:["packages/*"]};var K1=iI("{\"index\":\"./dist/client/index.html\",\"files\":[{\"input\":\"../../index.html\",\"path\":\"./dist/client/static/js/index-ae9z0yvm.js\",\"loader\":\"js\",\"isEntry\":true,\"headers\":{\"etag\":\"ii6pX4B-e3Q\",\"content-type\":\"text/javascript;charset=utf-8\"}},{\"input\":\"../../index.html\",\"path\":\"./dist/client/index.html\",\"loader\":\"html\",\"isEntry\":true,\"headers\":{\"etag\":\"NZJH1Yf1VtA\",\"content-type\":\"text/html;charset=utf-8\"}},{\"input\":\"../../index.html\",\"path\":\"./dist/client/static/js/index-nzyjf92m.css\",\"loader\":\"css\",\"isEntry\":true,\"headers\":{\"etag\":\"tb-e8s_JorQ\",\"content-type\":\"text/css;charset=utf-8\"}},{\"input\":\"../../public/manifest.webmanifest\",\"path\":\"./dist/client/static/manifest-42r8wcmg.webmanifest\",\"loader\":\"file\",\"isEntry\":false,\"headers\":{\"etag\":\"xGK4yFzs1NA\",\"content-type\":\"application/manifest+json\"}},{\"input\":\"../../public/icon.svg\",\"path\":\"./dist/client/static/icon-8h6v1jcy.svg\",\"loader\":\"file\",\"isEntry\":false,\"headers\":{\"etag\":\"yFEme-ESbP4\",\"content-type\":\"image/svg+xml\"}},{\"input\":\"../../public/icon-192x192.png\",\"path\":\"./dist/client/static/icon-192x192-kz5bvz85.png\",\"loader\":\"file\",\"isEntry\":false,\"headers\":{\"etag\":\"819lS3sfyKU\",\"content-type\":\"image/png\"}},{\"input\":\"../../public/apple-touch-icon.png\",\"path\":\"./dist/client/static/apple-touch-icon-bbhgf3mq.png\",\"loader\":\"file\",\"isEntry\":false,\"headers\":{\"etag\":\"K8vRUA9jdJc\",\"content-type\":\"image/png\"}}]}");function m(e,t={}){let r=new Headers(t.headers);if(!r.has("content-type"))r.set("content-type","application/json; charset=utf-8");return new Response(JSON.stringify(e),{status:t.status??200,headers:r})}var ue={"cache-control":"no-store"};import{brotliCompressSync as Bre,constants as Ure}from"zlib";var JS=1024,q1=/^(text\/|application\/(json|javascript|xml|wasm|svg))/,jre=["zstd","br","gzip"];function V1(e){return q1.test(e)}function YS(e){if(!e)return null;for(let t of jre)if(e.includes(t))return t;return null}function XS(e,t){if(t==="zstd")return Bun.zstdCompressSync(e,{level:3});if(t==="br")return Bre(e,{params:{[Ure.BROTLI_PARAM_QUALITY]:4}});return Bun.gzipSync(e,{level:6})}async function js(e,t){if(!t)return e;let r=e.headers.get("content-type")??"";if(r.includes("text/event-stream"))return e;if(!q1.test(r))return e;if(e.status===204||e.status===304)return e;let n=YS(t);if(!n)return e;let o=new Uint8Array(await e.arrayBuffer());if(o.byteLength<JS)return Wre(e,o);let i=XS(o,n),s=new Headers(e.headers);return s.set("content-encoding",n),s.set("content-length",String(i.byteLength)),s.append("vary","accept-encoding"),new Response(i,{status:e.status,headers:s})}function Wre(e,t){return new Response(t,{status:e.status,headers:e.headers})}function G(e,t,r={}){let n=[];if(e.loader)n.push({method:"GET",path:t,handler:e.loader});else if(e.action)n.push({method:"GET",path:t,handler:z});if(e.action)for(let o of r.mutating??["POST","PUT","PATCH","DELETE"])n.push({method:o,path:t,handler:e.action});return n}var z=()=>new Response(JSON.stringify({error:"Method not allowed"}),{status:405,headers:{"content-type":"application/json; charset=utf-8"}});async function Ws(e){try{return{ok:!0,body:await e.json()}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}function dn(e,t){let r=e[t];return r?r:null}function Oo(e,t=500){return m({error:e instanceof Error?e.message:String(e)},{status:t})}async function Hre(e){if(e instanceof Response)return e;if(e instanceof ReadableStream)return new Response(e,{headers:{"content-type":"text/event-stream","cache-control":"no-cache"}});return new Response(JSON.stringify(e??null),{status:200,headers:{"content-type":"application/json; charset=utf-8"}})}function Kre(e){return async({request:t,params:r})=>{try{let n=await Hre(await e({request:t,params:r}));return await js(n,t.headers.get("accept-encoding"))}catch(n){let o=n instanceof Error?n.message:String(n);return new Response(JSON.stringify({error:o}),{status:500,headers:{"content-type":"application/json; charset=utf-8"}})}}}function G1(e,t){let r=e;for(let{method:n,path:o,handler:i}of t){let s=Kre(i);if(n==="GET")r=r.get(o,s);else if(n==="POST")r=r.post(o,s);else if(n==="PUT")r=r.put(o,s);else if(n==="PATCH")r=r.patch(o,s);else r=r.delete(o,s)}return r}function Tt(e,t,r){return[{method:"GET",path:t,handler:r??z},...["POST","PUT","PATCH","DELETE"].map((n)=>({method:n,path:t,handler:e}))]}import{existsSync as QS,realpathSync as qre}from"fs";import{homedir as $1,tmpdir as _Ke}from"os";import*as Bt from"path";var z1="omp",Vre=".omp";function J1(){return Bun.env.PI_CONFIG_DIR||Vre}function On(){return Bt.join($1(),J1())}function le(){let e=Bun.env.PI_CODING_AGENT_DIR;if(e)return Bt.resolve(e);return Bt.join(On(),"agent")}function Y1(){let e=Bun.env.PI_CODING_AGENT_DIR;if(e)return Bt.resolve(e)===Bt.join(On(),"agent");return!0}function Gre(){if(process.platform!=="linux"&&process.platform!=="darwin")return;if(!Y1())return;let e=Bun.env.XDG_DATA_HOME;if(!e)return;try{let t=Bt.join(e,z1);return QS(t)?t:void 0}catch{return}}function $re(e){let t=Gre();return Bt.join(t??le(),e)}function Yn(){return $re("sessions")}function X1(){return Bt.join(le(),"projects.json")}function Q1(){if(process.platform!=="linux"&&process.platform!=="darwin")return On();if(!Y1())return On();let e=Bun.env.XDG_DATA_HOME;if(!e)return On();try{let t=Bt.join(e,z1);return QS(t)?t:On()}catch{return On()}}function Z1(){return Bt.join(Q1(),"plugins")}function ZS(){return Bt.join(Q1(),"marketplaces.json")}function _1(e){let t=$1(),r=J1(),n=Bt.resolve(e);for(let o of[r,".git"]){let i=n;while(i!==t){if(QS(Bt.join(i,o)))return Bt.join(i,r,"plugins");let s=Bt.dirname(i);if(s===i)break;i=s}}return Bt.join(n,r,"plugins")}function Lh(e){try{return qre.native(e)}catch{return e}}async function Y(e){try{return await Bun.file(e).stat(),!0}catch{return!1}}function Xl(e){let t=Lh(e);return t.replace(/\/+$/,"")||t}import ek from"fs";import*as Uh from"path";function k(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function rr(e){let t=[];for(let r of e.split(`
|
|
666
|
+
`))}return this}wrap(t){return this.extender.higherOrderFunctions.push({checksum:Ni(JSON.stringify({name:this.config.name,seed:this.config.seed,content:t.toString()})),fn:t}),this}get models(){let t={};for(let r of Object.keys(this.definitions.type))t[r]=St(this.definitions.typebox.Import(r),{models:this.definitions.type});return t.modules=this.definitions.typebox,t}add(t,r,n,o,i){let s=i?.skipPrefix??!1,a=i?.allowMeta??!1;o??={},this.applyMacro(o);let c=[];if(o.standaloneValidator&&(c=c.concat(o.standaloneValidator)),this.standaloneValidator.local&&(c=c.concat(this.standaloneValidator.local)),this.standaloneValidator.scoped&&(c=c.concat(this.standaloneValidator.scoped)),this.standaloneValidator.global&&(c=c.concat(this.standaloneValidator.global)),r!==""&&r.charCodeAt(0)!==47&&(r="/"+r),this.config.prefix&&!s&&(r=this.config.prefix+r),o?.type)switch(o.type){case"text":o.type="text/plain";break;case"json":o.type="application/json";break;case"formdata":o.type="multipart/form-data";break;case"urlencoded":o.type="application/x-www-form-urlencoded";break;case"arrayBuffer":o.type="application/octet-stream";break;default:break}let l=this.validator.getCandidate(),u={body:o?.body??l?.body,headers:o?.headers??l?.headers,params:o?.params??l?.params,query:o?.query??l?.query,cookie:o?.cookie??l?.cookie,response:o?.response??l?.response},d=this.config.precompile===!0||typeof this.config.precompile=="object"&&this.config.precompile.compose===!0,f=()=>{let P=this.definitions.type,j=!this.config.aot,B=this.config.normalize,J=this.definitions.typebox,te=()=>this.config.sanitize,oe=()=>{if(u.cookie||c.find((re)=>re.cookie))return v1({modules:J,validator:u.cookie,defaultConfig:this.config.cookie,normalize:B,config:u.cookie?.config??{},dynamic:j,models:P,validators:c.map((re)=>re.cookie),sanitize:te})};return d?{body:St(u.body,{modules:J,dynamic:j,models:P,normalize:B,additionalCoerce:(()=>{let re=US(u.body,P,J);return re&&O in re&&(lr("File",re)||lr("Files",re))?LS():Ep()})(),validators:c.map((re)=>re.body),sanitize:te}),headers:St(u.headers,{modules:J,dynamic:j,models:P,additionalProperties:!0,coerce:!0,additionalCoerce:lc(),validators:c.map((re)=>re.headers),sanitize:te}),params:St(u.params,{modules:J,dynamic:j,models:P,coerce:!0,additionalCoerce:lc(),validators:c.map((re)=>re.params),sanitize:te}),query:St(u.query,{modules:J,dynamic:j,models:P,normalize:B,coerce:!0,additionalCoerce:DS(),validators:c.map((re)=>re.query),sanitize:te}),cookie:oe(),response:Ph(u.response,{modules:J,dynamic:j,models:P,normalize:B,validators:c.map((re)=>re.response),sanitize:te})}:{createBody(){return this.body?this.body:this.body=St(u.body,{modules:J,dynamic:j,models:P,normalize:B,additionalCoerce:(()=>{let re=US(u.body,P,J);return re&&O in re&&(lr("File",re)||lr("Files",re))?LS():Ep()})(),validators:c.map((re)=>re.body),sanitize:te})},createHeaders(){return this.headers?this.headers:this.headers=St(u.headers,{modules:J,dynamic:j,models:P,normalize:B,additionalProperties:!B,coerce:!0,additionalCoerce:lc(),validators:c.map((re)=>re.headers),sanitize:te})},createParams(){return this.params?this.params:this.params=St(u.params,{modules:J,dynamic:j,models:P,normalize:B,coerce:!0,additionalCoerce:lc(),validators:c.map((re)=>re.params),sanitize:te})},createQuery(){return this.query?this.query:this.query=St(u.query,{modules:J,dynamic:j,models:P,normalize:B,coerce:!0,additionalCoerce:DS(),validators:c.map((re)=>re.query),sanitize:te})},createCookie(){return this.cookie?this.cookie:this.cookie=oe()},createResponse(){return this.response?this.response:this.response=Ph(u.response,{modules:J,dynamic:j,models:P,normalize:B,validators:c.map((re)=>re.response),sanitize:te})}}};(l.body||l.cookie||l.headers||l.params||l.query||l.response)&&(o=Yo(o,l)),o.tags&&(o.detail?o.detail.tags=o.tags:o.detail={tags:o.tags}),Re(this.config.detail)&&(o.detail=$t(Object.assign({},this.config.detail),o.detail));let p=Re(this.event)?Yo(this.event,Zx(o)):{...kO(Zx(o))};if(c.length&&Object.assign(p,{standaloneValidator:c}),this.config.aot===!1){let P=f();this.router.dynamic.add(t,r,{validator:P,hooks:p,content:o?.type,handle:n,route:r});let j=Ya(r,{dynamic:!0});if(r!==j&&this.router.dynamic.add(t,j,{validator:P,hooks:p,content:o?.type,handle:n,route:r}),!this.config.strictPath){let B=Ja(r);this.router.dynamic.add(t,B,{validator:P,hooks:p,content:o?.type,handle:n,route:r});let J=Ya(B);B!==J&&this.router.dynamic.add(t,B,{validator:P,hooks:p,content:o?.type,handle:n,route:r})}this.router.history.push({method:t,path:r,composed:null,handler:n,compile:void 0,hooks:p});return}let h=this["~adapter"].handler,g=typeof n!="function"?()=>{let P=h.createNativeStaticHandler?.(n,p,{headers:Object.assign({},this.setHeaders)});return P instanceof Promise?P.then((j)=>{if(j)return j}):P?.()}:void 0,y=this.config.nativeStaticResponse===!0,b=(P)=>{!y||!g||(Xg?this.router.response[P]?this.router.response[P][t]=g():this.router.response[P]={[t]:g()}:this.router.response[P]=g())};b(r);let w,E=()=>{if(w)return w;let P=E1({app:this,path:r,method:t,hooks:p,validator:f(),handler:typeof n!="function"&&typeof h.createStaticHandler!="function"?()=>n:n,allowMeta:a,inference:this.inference});return this.router.history[v]&&(w=this.router.history[v].composed=P),P},A;if(`${t}_${r}`in this.routeTree)for(let P=0;P<this.router.history.length;P++){let j=this.router.history[P];if(j.path===r&&j.method===t){A=P;break}}else this.routeTree[`${t}_${r}`]=this.router.history.length;let v=A??this.router.history.length,T=this.router.history,I=d?E():(P)=>w?w(P):(T[v].composed=E())(P);A!==void 0?this.router.history[A]=Object.assign({method:t,path:r,composed:I,compile:E,handler:n,hooks:p},c.length?{standaloneValidators:c}:void 0,o.webSocket?{websocket:o.websocket}:void 0):this.router.history.push(Object.assign({method:t,path:r,composed:I,compile:E,handler:n,hooks:p},o.webSocket?{websocket:o.websocket}:void 0));let S={handler:d?T[v].composed:void 0,compile(){return this.handler=E()}},D=this.router.static,L=r.indexOf(":")===-1&&r.indexOf("*")===-1;if(t==="WS"){if(L){r in D?D[r][t]=v:D[r]={[t]:v};return}this.router.http.add("WS",r,S),this.config.strictPath||this.router.http.add("WS",Ja(r),S);let P=Ya(r,{dynamic:!0});r!==P&&this.router.http.add("WS",P,S);return}if(L)r in D?D[r][t]=v:D[r]={[t]:v},this.config.strictPath||b(Ja(r));else{if(this.router.http.add(t,r,S),!this.config.strictPath){let j=Ja(r);b(j),this.router.http.add(t,j,S)}let P=Ya(r,{dynamic:!0});r!==P&&(this.router.http.add(t,P,S),b(P))}}headers(t){return t?(this.setHeaders||(this.setHeaders={}),this.setHeaders=$t(this.setHeaders,t),this):this}onStart(t){return this.on("start",t),this}onRequest(t){return this.on("request",t),this}onParse(t,r){return r?this.on(t,"parse",r):typeof t=="string"?this.on("parse",this["~parser"][t]):this.on("parse",t)}parser(t,r){return this["~parser"][t]=r,this}onTransform(t,r){return r?this.on(t,"transform",r):this.on("transform",t)}resolve(t,r){r||(r=t,t={as:"local"});let n={subType:"resolve",fn:r};return this.onBeforeHandle(t,n)}mapResolve(t,r){r||(r=t,t={as:"local"});let n={subType:"mapResolve",fn:r};return this.onBeforeHandle(t,n)}onBeforeHandle(t,r){return r?this.on(t,"beforeHandle",r):this.on("beforeHandle",t)}onAfterHandle(t,r){return r?this.on(t,"afterHandle",r):this.on("afterHandle",t)}mapResponse(t,r){return r?this.on(t,"mapResponse",r):this.on("mapResponse",t)}onAfterResponse(t,r){return r?this.on(t,"afterResponse",r):this.on("afterResponse",t)}trace(t,r){r||(r=t,t={as:"local"}),Array.isArray(r)||(r=[r]);for(let n of r)this.on(t,"trace",y1(n));return this}error(t,r){switch(typeof t){case"string":return r.prototype[Xa]=t,this.definitions.error[t]=r,this;case"function":return this.definitions.error=t(this.definitions.error),this}for(let[n,o]of Object.entries(t))o.prototype[Xa]=n,this.definitions.error[n]=o;return this}onError(t,r){return r?this.on(t,"error",r):this.on("error",t)}onStop(t){return this.on("stop",t),this}on(t,r,n){let o;switch(typeof t){case"string":o=t,n=r;break;case"object":o=r,!Array.isArray(r)&&typeof r=="object"&&(n=r);break}Array.isArray(n)?n=Gt(n):typeof n=="function"?n=[{fn:n}]:n=[n];let i=n;for(let s of i)s.scope=typeof t=="string"?"local":t?.as??"local",(o==="resolve"||o==="derive")&&(s.subType=o);o!=="trace"&&(this.inference=ic({[o]:i.map((s)=>s.fn)},this.inference,this.config.sucrose));for(let s of i){let a=TO(s,"global",{skipIfHasType:!0});switch((this.config.name||this.config.seed)&&(a.checksum=Ni(this.config.name+JSON.stringify(this.config.seed))),o){case"start":this.event.start??=[],this.event.start.push(a);break;case"request":this.event.request??=[],this.event.request.push(a);break;case"parse":this.event.parse??=[],this.event.parse.push(a);break;case"transform":this.event.transform??=[],this.event.transform.push(a);break;case"derive":this.event.transform??=[],this.event.transform.push(Gt(a,"derive"));break;case"beforeHandle":this.event.beforeHandle??=[],this.event.beforeHandle.push(a);break;case"resolve":this.event.beforeHandle??=[],this.event.beforeHandle.push(Gt(a,"resolve"));break;case"afterHandle":this.event.afterHandle??=[],this.event.afterHandle.push(a);break;case"mapResponse":this.event.mapResponse??=[],this.event.mapResponse.push(a);break;case"afterResponse":this.event.afterResponse??=[],this.event.afterResponse.push(a);break;case"trace":this.event.trace??=[],this.event.trace.push(a);break;case"error":this.event.error??=[],this.event.error.push(a);break;case"stop":this.event.stop??=[],this.event.stop.push(a);break}}return this}as(t){return Li(this.event.parse,t),Li(this.event.transform,t),Li(this.event.beforeHandle,t),Li(this.event.afterHandle,t),Li(this.event.mapResponse,t),Li(this.event.afterResponse,t),Li(this.event.trace,t),Li(this.event.error,t),t==="scoped"?(this.validator.scoped=Ol(this.validator.scoped,this.validator.local),this.validator.local=null,this.standaloneValidator.local!==null&&(this.standaloneValidator.scoped||=[],this.standaloneValidator.scoped.push(...this.standaloneValidator.local),this.standaloneValidator.local=null)):t==="global"&&(this.validator.global=Ol(this.validator.global,Ol(this.validator.scoped,this.validator.local)),this.validator.scoped=null,this.validator.local=null,this.standaloneValidator.local!==null&&(this.standaloneValidator.scoped||=[],this.standaloneValidator.scoped.push(...this.standaloneValidator.local),this.standaloneValidator.local=null),this.standaloneValidator.scoped!==null&&(this.standaloneValidator.global||=[],this.standaloneValidator.global.push(...this.standaloneValidator.scoped),this.standaloneValidator.scoped=null)),this}group(t,r,n){let o=new e({...this.config,prefix:""});o.singleton={...this.singleton},o.definitions={...this.definitions},o.getServer=()=>this.getServer(),o.inference=Yg(this.inference),o.extender={...this.extender},o["~parser"]=this["~parser"],o.standaloneValidator={local:[...this.standaloneValidator.local??[]],scoped:[...this.standaloneValidator.scoped??[]],global:[...this.standaloneValidator.global??[]]};let i=typeof r=="object",s=(i?n:r)(o);return this.singleton=$t(this.singleton,o.singleton),this.definitions=$t(this.definitions,o.definitions),s.event.request?.length&&(this.event.request=[...this.event.request||[],...s.event.request||[]]),s.event.mapResponse?.length&&(this.event.mapResponse=[...this.event.mapResponse||[],...s.event.mapResponse||[]]),this.model(s.definitions.type),Object.values(o.router.history).forEach(({method:a,path:c,handler:l,hooks:u})=>{if(c=(i?"":this.config.prefix??"")+t+c,i){let{body:d,headers:f,query:p,params:h,cookie:g,response:y,...b}=r,w=u;this.applyMacro(b);let E=d||f||p||h||g||y;this.add(a,c,l,Yo(b,{...w||{},error:w.error?Array.isArray(w.error)?[...w.error??[],...s.event.error??[]]:[w.error,...s.event.error??[]]:s.event.error,standaloneValidator:b.standaloneValidator||w.standaloneValidator||E?[...b.standaloneValidator??[],...w.standaloneValidator??[],...E?[{body:d,headers:f,query:p,params:h,cookie:g,response:y}]:[]]:void 0}),void 0)}else this.add(a,c,l,Yo(u,{error:s.event.error}),{skipPrefix:!0})}),this}guard(t,r){if(!r){if(typeof t=="object"){this.applyMacro(t),t.detail&&(this.config.detail?this.config.detail=$t(Object.assign({},this.config.detail),t.detail):this.config.detail=t.detail),t.tags&&(this.config.detail?this.config.detail.tags=t.tags:this.config.detail={tags:t.tags});let i=t.as??"local";if(t.schema==="standalone"){this.standaloneValidator[i]||(this.standaloneValidator[i]=[]);let s=t?.response?typeof t.response=="string"||O in t.response||"~standard"in t.response?{200:t.response}:t?.response:void 0;this.standaloneValidator[i].push({body:t.body,headers:t.headers,params:t.params,query:t.query,response:s,cookie:t.cookie})}else this.validator[i]={body:t.body??this.validator[i]?.body,headers:t.headers??this.validator[i]?.headers,params:t.params??this.validator[i]?.params,query:t.query??this.validator[i]?.query,response:t.response??this.validator[i]?.response,cookie:t.cookie??this.validator[i]?.cookie};return t.parse&&this.on({as:i},"parse",t.parse),t.transform&&this.on({as:i},"transform",t.transform),t.derive&&this.on({as:i},"derive",t.derive),t.beforeHandle&&this.on({as:i},"beforeHandle",t.beforeHandle),t.resolve&&this.on({as:i},"resolve",t.resolve),t.afterHandle&&this.on({as:i},"afterHandle",t.afterHandle),t.mapResponse&&this.on({as:i},"mapResponse",t.mapResponse),t.afterResponse&&this.on({as:i},"afterResponse",t.afterResponse),t.error&&this.on({as:i},"error",t.error),this}return this.guard({},t)}let n=new e({...this.config,prefix:""});n.singleton={...this.singleton},n.definitions={...this.definitions},n.inference=Yg(this.inference),n.extender={...this.extender},n.getServer=()=>this.getServer();let o=r(n);if(this.singleton=$t(this.singleton,n.singleton),this.definitions=$t(this.definitions,n.definitions),o.getServer=()=>this.server,o.event.request?.length&&(this.event.request=[...this.event.request||[],...o.event.request||[]]),o.event.mapResponse?.length&&(this.event.mapResponse=[...this.event.mapResponse||[],...o.event.mapResponse||[]]),this.model(o.definitions.type),Object.values(n.router.history).forEach(({method:i,path:s,handler:a,hooks:c})=>{let{body:l,headers:u,query:d,params:f,cookie:p,response:h,...g}=t,y=l||u||d||f||p||h;this.add(i,s,a,Yo(g,{...c||{},error:c.error?Array.isArray(c.error)?[...c.error??[],...o.event.error??[]]:[c.error,...o.event.error??[]]:o.event.error,standaloneValidator:y?[...c.standaloneValidator??[],{body:l,headers:u,query:d,params:f,cookie:p,response:h}]:c.standaloneValidator}))}),n.promisedModules.size>0){let i=n.router.history.length;for(let s of n.promisedModules.promises)this.promisedModules.add(s.then(()=>{let{body:a,headers:c,query:l,params:u,cookie:d,response:f,...p}=t,h=a||c||l||u||d||f,g=i;i=n.router.history.length;for(let y=g;y<n.router.history.length;y++){let{method:b,path:w,handler:E,hooks:A}=n.router.history[y];this.add(b,w,E,Yo(p,{...A||{},error:A.error?Array.isArray(A.error)?[...A.error??[],...o.event.error??[]]:[A.error,...o.event.error??[]]:o.event.error,standaloneValidator:h?[...A.standaloneValidator??[],{body:a,headers:c,query:l,params:u,cookie:d,response:f}]:A.standaloneValidator}))}}))}return this}use(t){if(!t)return this;if(Array.isArray(t)){let r=this;for(let n of t)r=r.use(n);return r}return t instanceof Promise?(this.promisedModules.add(t.then((r)=>{if(typeof r=="function")return r(this);if(r instanceof e)return this._use(r).compile();if(r.constructor?.name==="Elysia")return this._use(r).compile();if(typeof r.default=="function")return r.default(this);if(r.default instanceof e)return this._use(r.default);if(r.constructor?.name==="Elysia")return this._use(r.default);if(r.constructor?.name==="_Elysia")return this._use(r.default);try{return this._use(r.default)}catch(n){throw console.error('Invalid plugin type. Expected Elysia instance, function, or module with "default" as Elysia instance or function that returns Elysia instance.'),n}}).then((r)=>(r&&typeof r.compile=="function"&&r.compile(),r))),this):this._use(t)}propagatePromiseModules(t){if(t.promisedModules.size<=0)return this;for(let r of t.promisedModules.promises)this.promisedModules.add(r.then((n)=>{if(!n)return;let o=this._use(n);return o instanceof Promise?o.then((i)=>{i?i.compile():n.compile()}):n.compile()}));return this}_use(t){if(typeof t=="function"){let o=t(this);return o instanceof Promise?(this.promisedModules.add(o.then((i)=>{if(i instanceof e){i.getServer=()=>this.getServer(),i.getGlobalRoutes=()=>this.getGlobalRoutes(),i.getGlobalDefinitions=()=>this.getGlobalDefinitions(),i.model(this.definitions.type),i.error(this.definitions.error);for(let{method:s,path:a,handler:c,hooks:l}of Object.values(i.router.history))this.add(s,a,c,l,void 0);return i===this?void 0:(this.propagatePromiseModules(i),i)}return typeof i=="function"?i(this):typeof i.default=="function"?i.default(this):this._use(i)}).then((i)=>(i&&typeof i.compile=="function"&&i.compile(),i))),this):o}this.propagatePromiseModules(t);let r=t.config.name,n=t.config.seed;if(t.getParent=()=>this,t.getServer=()=>this.getServer(),t.getGlobalRoutes=()=>this.getGlobalRoutes(),t.getGlobalDefinitions=()=>this.getGlobalDefinitions(),t.standaloneValidator?.scoped&&(this.standaloneValidator.local?this.standaloneValidator.local=this.standaloneValidator.local.concat(t.standaloneValidator.scoped):this.standaloneValidator.local=t.standaloneValidator.scoped),t.standaloneValidator?.global&&(this.standaloneValidator.global?this.standaloneValidator.global=this.standaloneValidator.global.concat(t.standaloneValidator.global):this.standaloneValidator.global=t.standaloneValidator.global),Re(t["~parser"])&&(this["~parser"]={...t["~parser"],...this["~parser"]}),t.setHeaders&&this.headers(t.setHeaders),r){r in this.dependencies||(this.dependencies[r]=[]);let o=n!==void 0?Ni(r+JSON.stringify(n)):0;this.dependencies[r].some(({checksum:i})=>o===i)||(this.extender.macro={...this.extender.macro,...t.extender.macro},this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(t.extender.higherOrderFunctions))}else Re(t.extender.macro)&&(this.extender.macro={...this.extender.macro,...t.extender.macro}),t.extender.higherOrderFunctions.length&&(this.extender.higherOrderFunctions=this.extender.higherOrderFunctions.concat(t.extender.higherOrderFunctions));if(t.extender.higherOrderFunctions.length){tS(this.extender.higherOrderFunctions);let o=[];for(let i=0;i<this.extender.higherOrderFunctions.length;i++){let s=this.extender.higherOrderFunctions[i];s.checksum&&(o.includes(s.checksum)&&(this.extender.higherOrderFunctions.splice(i,1),i--),o.push(s.checksum))}o.length=0}this.inference=yh(this.inference,t.inference),Re(t.singleton.decorator)&&this.decorate(t.singleton.decorator),Re(t.singleton.store)&&this.state(t.singleton.store),Re(t.definitions.type)&&this.model(t.definitions.type),Re(t.definitions.error)&&this.error(t.definitions.error),Re(t.extender.macro)&&(this.extender.macro={...this.extender.macro,...t.extender.macro});for(let{method:o,path:i,handler:s,hooks:a}of Object.values(t.router.history))this.add(o,i,s,a);if(r){r in this.dependencies||(this.dependencies[r]=[]);let o=n!==void 0?Ni(r+JSON.stringify(n)):0;if(this.dependencies[r].some(({checksum:i})=>o===i))return this;this.dependencies[r].push(this.config?.analytic?{name:t.config.name,seed:t.config.seed,checksum:o,dependencies:t.dependencies,stack:t.telemetry?.stack,routes:t.router.history,decorators:t.singleton,store:t.singleton.store,error:t.definitions.error,derive:t.event.transform?.filter((i)=>i?.subType==="derive").map((i)=>({fn:i.toString(),stack:Error().stack??""})),resolve:t.event.transform?.filter((i)=>i?.subType==="resolve").map((i)=>({fn:i.toString(),stack:Error().stack??""}))}:{name:t.config.name,seed:t.config.seed,checksum:o,dependencies:t.dependencies}),Re(t.event)&&(this.event=Jx(this.event,Yx(t.event),o))}else Re(t.event)&&(this.event=Jx(this.event,Yx(t.event)));return t.validator.global&&(this.validator.global=Yo(this.validator.global,{...t.validator.global})),t.validator.scoped&&(this.validator.local=Yo(this.validator.local,{...t.validator.scoped})),this}macro(t,r){if(typeof t=="string"&&!r)throw Error("Macro function is required");return typeof t=="string"?this.extender.macro[t]=r:this.extender.macro={...this.extender.macro,...t},this}applyMacro(t,r=t,{iteration:n=0,applied:o={}}={}){if(n>=16)return;let i=this.extender.macro;for(let[s,a]of Object.entries(r)){if(!(s in i))continue;let c=typeof i[s]=="function"?i[s](a):i[s];if(!c||typeof i[s]=="object"&&a===!1)return;let l=Ni(s+JSON.stringify(c.seed??a));if(!(l in o)){o[l]=!0;for(let[u,d]of Object.entries(c))if(u!=="seed"){if(u in EO){vO(t,u,d),delete t[s];continue}if(u==="introspect"){d?.(t),delete t[s];continue}if(u==="detail"){t.detail||(t.detail={}),t.detail=$t(t.detail,d,{mergeArray:!0}),delete t[s];continue}if(u in i){this.applyMacro(t,{[u]:d},{applied:o,iteration:n+1}),delete t[s];continue}switch((u==="derive"||u==="resolve")&&typeof d=="function"&&(d={fn:d,subType:u}),typeof t[u]){case"function":t[u]=[t[u],d];break;case"object":Array.isArray(t[u])?t[u].push(d):t[u]=[t[u],d];break;case"undefined":t[u]=d;break}delete t[s]}}}}mount(t,r,n){if(t instanceof e||typeof t=="function"||t.length===0||t==="/"){let a=typeof t=="function"?t:t instanceof e?t.compile().fetch:r instanceof e?r.compile().fetch:typeof r=="function"?r:(()=>{throw Error("Invalid handler")})(),c=({request:l,path:u})=>a(new Request(Gg(l.url,u),l));return this.route("ALL","/*",c,{parse:"none",...n,detail:{...n?.detail,hide:!0},config:{mount:a}}),this}let o=r instanceof e?r.compile().fetch:typeof r=="function"?r:(()=>{throw Error("Invalid handler")})(),i=(typeof t=="string"&&this.config.prefix?this.config.prefix+t:t).length-(t.endsWith("*")?1:0),s=({request:a,path:c})=>o(new Request(Gg(a.url,c.slice(i)||"/"),a));return this.route("ALL",t,s,{parse:"none",...n,detail:{...n?.detail,hide:!0},config:{mount:o}}),this.route("ALL",t+(t.endsWith("/")?"*":"/*"),s,{parse:"none",...n,detail:{...n?.detail,hide:!0},config:{mount:o}}),this}get(t,r,n){return this.add("GET",t,r,n),this}post(t,r,n){return this.add("POST",t,r,n),this}put(t,r,n){return this.add("PUT",t,r,n),this}patch(t,r,n){return this.add("PATCH",t,r,n),this}delete(t,r,n){return this.add("DELETE",t,r,n),this}options(t,r,n){return this.add("OPTIONS",t,r,n),this}all(t,r,n){return this.add("ALL",t,r,n),this}head(t,r,n){return this.add("HEAD",t,r,n),this}connect(t,r,n){return this.add("CONNECT",t,r,n),this}route(t,r,n,o){return this.add(t.toUpperCase(),r,n,o,o?.config),this}ws(t,r){return this["~adapter"].ws?this["~adapter"].ws(this,t,r):console.warn("Current adapter doesn't support WebSocket"),this}state(t,r,n){r===void 0?(n=t,t={as:"append"},r=""):n===void 0&&(typeof t=="string"?(n=r,r=t,t={as:"append"}):typeof t=="object"&&(n=r,r=""));let{as:o}=t;if(typeof r!="string")return this;switch(typeof n){case"object":return!n||!Re(n)?this:r?((r in this.singleton.store)?this.singleton.store[r]=$t(this.singleton.store[r],n,{override:o==="override"}):this.singleton.store[r]=n,this):n===null?this:(this.singleton.store=$t(this.singleton.store,n,{override:o==="override"}),this);case"function":return r?(o==="override"||!(r in this.singleton.store))&&(this.singleton.store[r]=n):this.singleton.store=n(this.singleton.store),this;default:return(o==="override"||!(r in this.singleton.store))&&(this.singleton.store[r]=n),this}}decorate(t,r,n){r===void 0?(n=t,t={as:"append"},r=""):n===void 0&&(typeof t=="string"?(n=r,r=t,t={as:"append"}):typeof t=="object"&&(n=r,r=""));let{as:o}=t;if(typeof r!="string")return this;switch(typeof n){case"object":return r?((r in this.singleton.decorator)?this.singleton.decorator[r]=$t(this.singleton.decorator[r],n,{override:o==="override"}):this.singleton.decorator[r]=n,this):n===null?this:(this.singleton.decorator=$t(this.singleton.decorator,n,{override:o==="override"}),this);case"function":return r?(o==="override"||!(r in this.singleton.decorator))&&(this.singleton.decorator[r]=n):this.singleton.decorator=n(this.singleton.decorator),this;default:return(o==="override"||!(r in this.singleton.decorator))&&(this.singleton.decorator[r]=n),this}}derive(t,r){r||(r=t,t={as:"local"});let n={subType:"derive",fn:r};return this.onTransform(t,n)}model(t,r){let n=(o)=>{let i={};for(let s in o)"~standard"in o[s]||(i[s]=o[s]);return i};switch(typeof t){case"object":let o={},i=Object.entries(t);if(!i.length)return this;for(let[c,l]of i)c in this.definitions.type||("~standard"in l?this.definitions.type[c]=l:(o[c]=this.definitions.type[c]=l,o[c].$id??=`#/components/schemas/${c}`));return this.definitions.typebox=V.Module({...this.definitions.typebox.$defs,...o}),this;case"function":let s=t(this.definitions.type);return this.definitions.type=s,this.definitions.typebox=V.Module(n(s)),this;case"string":if(!r)break;if(this.definitions.type[t]=r,"~standard"in r)return this;let a={...r,id:r.$id??`#/components/schemas/${t}`};return this.definitions.typebox=V.Module({...this.definitions.typebox.$defs,...a}),this}return r?(this.definitions.type[t]=r,("~standard"in r)?this:(this.definitions.typebox=V.Module({...this.definitions.typebox.$defs,[t]:r}),this)):this}Ref(t){return V.Ref(t)}mapDerive(t,r){r||(r=t,t={as:"local"});let n={subType:"mapDerive",fn:r};return this.onTransform(t,n)}affix(t,r,n){if(n==="")return this;let o=["_","-"," "],i=(l)=>l[0].toUpperCase()+l.slice(1),s=t==="prefix"?(l,u)=>o.includes(l.at(-1)??"")?l+u:l+i(u):o.includes(n.at(-1)??"")?(l,u)=>u+l:(l,u)=>u+i(l),a=(l)=>{let u={};switch(l){case"decorator":for(let d in this.singleton.decorator)u[s(n,d)]=this.singleton.decorator[d];this.singleton.decorator=u;break;case"state":for(let d in this.singleton.store)u[s(n,d)]=this.singleton.store[d];this.singleton.store=u;break;case"model":for(let d in this.definitions.type)u[s(n,d)]=this.definitions.type[d];this.definitions.type=u;break;case"error":for(let d in this.definitions.error)u[s(n,d)]=this.definitions.error[d];this.definitions.error=u;break}},c=Array.isArray(r)?r:[r];for(let l of c.some((u)=>u==="all")?["decorator","state","model","error"]:c)a(l);return this}prefix(t,r){return this.affix("prefix",t,r)}suffix(t,r){return this.affix("suffix",t,r)}compile(){return this["~adapter"].beforeCompile?.(this),this["~adapter"].isWebStandard?(this._handle=this.config.aot?Oh(this):$S(this),Object.defineProperty(this,"fetch",{value:this._handle,configurable:!0,writable:!0}),typeof this.server?.reload=="function"&&this.server.reload({...this.server||{},fetch:this.fetch}),this):(typeof this.server?.reload=="function"&&this.server.reload(this.server||{}),this._handle=Oh(this),this)}get fetch(){let t=this.config.aot?Oh(this):$S(this);return Object.defineProperty(this,"fetch",{value:t,configurable:!0,writable:!0}),t}get modules(){return this.promisedModules}},Jn=Fre;var Dh={name:"@kabmo-labs/kabmo",version:"0.6.1",description:"Web console and diagnostic workbench for AI coding agents \u2014 Elysia + Preact on Bun.",license:"UNLICENSED",author:"Wijanarko Putra Rajeb <wijanarko.rajeb@gmail.com>",type:"module",engines:{bun:">=1.4.0"},publishConfig:{access:"public"},bin:{kabmo:"./src/cli/kabmo.js"},repository:{type:"git",url:"git+https://github.com/kabmo-labs/kabmo.git"},homepage:"https://github.com/kabmo-labs/kabmo#readme",bugs:{url:"https://github.com/kabmo-labs/kabmo/issues"},keywords:["kabmo","coding-agent","agent","console","elysia","preact","bun"],files:["src","extensions","index.html","bunfig.toml","public","tsconfig.json","marketplace","dist/client"],scripts:{dev:"bun run --hot src/server/index.ts --kabmo-server","dev:lan":"HOST=0.0.0.0 bun run --hot src/server/index.ts --kabmo-server",build:"bun run scripts/build-client.ts","omp:schema":"bun run scripts/omp-schema.mjs","omp:schema:check":"bun run scripts/omp-schema.mjs --check",start:"NODE_ENV=production bun run src/server/index.ts --kabmo-server",typecheck:"tsc",clean:"rm -rf dist",lint:"tsc --noEmit",test:"bun test","test:e2e":"playwright test --config tests/e2e/playwright.config.ts","readme:media":"bun run scripts/readme-media.ts","typecheck:e2e":"tsc --noEmit -p tests/e2e","publish:plugins":"bash .github/scripts/publish-plugin-packages.sh packages/kabmo-sdk packages/kabmo-ui"},dependencies:{"@fontsource/fira-code":"^5.3.0","@kabmo-labs/kabmo-sdk":"workspace:*","@kabmo-labs/kabmo-ui":"workspace:*","@shikijs/langs":"^4.4.3","@shikijs/themes":"^4.4.3","@tailwindcss/postcss":"^4.1.14","@xterm/addon-fit":"^0.11.0","@xterm/addon-webgl":"^0.19.0","@xterm/xterm":"^6.0.0",dompurify:"^3.4.15",elysia:"^1.4.30",katex:"^0.18.7","lucide-preact":"^1.47.0",mammoth:"^1.13.0",marked:"^18.0.11","marked-linkify-it":"^4.0.2",mermaid:"^12.0.0",postcss:"^8.5.16",preact:"^10.29.8","read-excel-file":"^9.3.12",remend:"^1.3.1",ripgrep:"^0.3.1",shiki:"^4.4.3",tailwindcss:"^4.1.14",yaml:"^2.9.1"},devDependencies:{"@playwright/test":"^1.64.0","@semantic-release/changelog":"^7.0.0","@semantic-release/commit-analyzer":"^13.0.1","@semantic-release/git":"^11.0.1","@semantic-release/github":"^12.0.10","@semantic-release/npm":"^13.2.0","@semantic-release/release-notes-generator":"^14.1.1","@types/bun":"^1.4.2","@types/node":"^22.14.0","bun-types":"^1.4.2","conventional-changelog-conventionalcommits":"^9.3.1","happy-dom":"^20.14.5","semantic-release":"^25.0.9",typescript:"~5.8.2"},workspaces:["packages/*"]};var K1=iI("{\"index\":\"./dist/client/index.html\",\"files\":[{\"input\":\"../../index.html\",\"path\":\"./dist/client/static/js/index-aq0e78gv.js\",\"loader\":\"js\",\"isEntry\":true,\"headers\":{\"etag\":\"SvcADgcIMDs\",\"content-type\":\"text/javascript;charset=utf-8\"}},{\"input\":\"../../index.html\",\"path\":\"./dist/client/index.html\",\"loader\":\"html\",\"isEntry\":true,\"headers\":{\"etag\":\"7GJ0QTLEhjc\",\"content-type\":\"text/html;charset=utf-8\"}},{\"input\":\"../../index.html\",\"path\":\"./dist/client/static/js/index-nzyjf92m.css\",\"loader\":\"css\",\"isEntry\":true,\"headers\":{\"etag\":\"tb-e8s_JorQ\",\"content-type\":\"text/css;charset=utf-8\"}},{\"input\":\"../../public/manifest.webmanifest\",\"path\":\"./dist/client/static/manifest-42r8wcmg.webmanifest\",\"loader\":\"file\",\"isEntry\":false,\"headers\":{\"etag\":\"xGK4yFzs1NA\",\"content-type\":\"application/manifest+json\"}},{\"input\":\"../../public/icon.svg\",\"path\":\"./dist/client/static/icon-8h6v1jcy.svg\",\"loader\":\"file\",\"isEntry\":false,\"headers\":{\"etag\":\"yFEme-ESbP4\",\"content-type\":\"image/svg+xml\"}},{\"input\":\"../../public/icon-192x192.png\",\"path\":\"./dist/client/static/icon-192x192-kz5bvz85.png\",\"loader\":\"file\",\"isEntry\":false,\"headers\":{\"etag\":\"819lS3sfyKU\",\"content-type\":\"image/png\"}},{\"input\":\"../../public/apple-touch-icon.png\",\"path\":\"./dist/client/static/apple-touch-icon-bbhgf3mq.png\",\"loader\":\"file\",\"isEntry\":false,\"headers\":{\"etag\":\"K8vRUA9jdJc\",\"content-type\":\"image/png\"}}]}");function m(e,t={}){let r=new Headers(t.headers);if(!r.has("content-type"))r.set("content-type","application/json; charset=utf-8");return new Response(JSON.stringify(e),{status:t.status??200,headers:r})}var ue={"cache-control":"no-store"};import{brotliCompressSync as Bre,constants as Ure}from"zlib";var JS=1024,q1=/^(text\/|application\/(json|javascript|xml|wasm|svg))/,jre=["zstd","br","gzip"];function V1(e){return q1.test(e)}function YS(e){if(!e)return null;for(let t of jre)if(e.includes(t))return t;return null}function XS(e,t){if(t==="zstd")return Bun.zstdCompressSync(e,{level:3});if(t==="br")return Bre(e,{params:{[Ure.BROTLI_PARAM_QUALITY]:4}});return Bun.gzipSync(e,{level:6})}async function js(e,t){if(!t)return e;let r=e.headers.get("content-type")??"";if(r.includes("text/event-stream"))return e;if(!q1.test(r))return e;if(e.status===204||e.status===304)return e;let n=YS(t);if(!n)return e;let o=new Uint8Array(await e.arrayBuffer());if(o.byteLength<JS)return Wre(e,o);let i=XS(o,n),s=new Headers(e.headers);return s.set("content-encoding",n),s.set("content-length",String(i.byteLength)),s.append("vary","accept-encoding"),new Response(i,{status:e.status,headers:s})}function Wre(e,t){return new Response(t,{status:e.status,headers:e.headers})}function G(e,t,r={}){let n=[];if(e.loader)n.push({method:"GET",path:t,handler:e.loader});else if(e.action)n.push({method:"GET",path:t,handler:z});if(e.action)for(let o of r.mutating??["POST","PUT","PATCH","DELETE"])n.push({method:o,path:t,handler:e.action});return n}var z=()=>new Response(JSON.stringify({error:"Method not allowed"}),{status:405,headers:{"content-type":"application/json; charset=utf-8"}});async function Ws(e){try{return{ok:!0,body:await e.json()}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}function dn(e,t){let r=e[t];return r?r:null}function Oo(e,t=500){return m({error:e instanceof Error?e.message:String(e)},{status:t})}async function Hre(e){if(e instanceof Response)return e;if(e instanceof ReadableStream)return new Response(e,{headers:{"content-type":"text/event-stream","cache-control":"no-cache"}});return new Response(JSON.stringify(e??null),{status:200,headers:{"content-type":"application/json; charset=utf-8"}})}function Kre(e){return async({request:t,params:r})=>{try{let n=await Hre(await e({request:t,params:r}));return await js(n,t.headers.get("accept-encoding"))}catch(n){let o=n instanceof Error?n.message:String(n);return new Response(JSON.stringify({error:o}),{status:500,headers:{"content-type":"application/json; charset=utf-8"}})}}}function G1(e,t){let r=e;for(let{method:n,path:o,handler:i}of t){let s=Kre(i);if(n==="GET")r=r.get(o,s);else if(n==="POST")r=r.post(o,s);else if(n==="PUT")r=r.put(o,s);else if(n==="PATCH")r=r.patch(o,s);else r=r.delete(o,s)}return r}function Tt(e,t,r){return[{method:"GET",path:t,handler:r??z},...["POST","PUT","PATCH","DELETE"].map((n)=>({method:n,path:t,handler:e}))]}import{existsSync as QS,realpathSync as qre}from"fs";import{homedir as $1,tmpdir as _Ke}from"os";import*as Bt from"path";var z1="omp",Vre=".omp";function J1(){return Bun.env.PI_CONFIG_DIR||Vre}function On(){return Bt.join($1(),J1())}function le(){let e=Bun.env.PI_CODING_AGENT_DIR;if(e)return Bt.resolve(e);return Bt.join(On(),"agent")}function Y1(){let e=Bun.env.PI_CODING_AGENT_DIR;if(e)return Bt.resolve(e)===Bt.join(On(),"agent");return!0}function Gre(){if(process.platform!=="linux"&&process.platform!=="darwin")return;if(!Y1())return;let e=Bun.env.XDG_DATA_HOME;if(!e)return;try{let t=Bt.join(e,z1);return QS(t)?t:void 0}catch{return}}function $re(e){let t=Gre();return Bt.join(t??le(),e)}function Yn(){return $re("sessions")}function X1(){return Bt.join(le(),"projects.json")}function Q1(){if(process.platform!=="linux"&&process.platform!=="darwin")return On();if(!Y1())return On();let e=Bun.env.XDG_DATA_HOME;if(!e)return On();try{let t=Bt.join(e,z1);return QS(t)?t:On()}catch{return On()}}function Z1(){return Bt.join(Q1(),"plugins")}function ZS(){return Bt.join(Q1(),"marketplaces.json")}function _1(e){let t=$1(),r=J1(),n=Bt.resolve(e);for(let o of[r,".git"]){let i=n;while(i!==t){if(QS(Bt.join(i,o)))return Bt.join(i,r,"plugins");let s=Bt.dirname(i);if(s===i)break;i=s}}return Bt.join(n,r,"plugins")}function Lh(e){try{return qre.native(e)}catch{return e}}async function Y(e){try{return await Bun.file(e).stat(),!0}catch{return!1}}function Xl(e){let t=Lh(e);return t.replace(/\/+$/,"")||t}import ek from"fs";import*as Uh from"path";function k(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function rr(e){let t=[];for(let r of e.split(`
|
|
667
667
|
`)){let n=r.trim();if(!n)continue;try{t.push(JSON.parse(n))}catch{}}return t}function eN(e){let t=e.endsWith("\\")?e.slice(0,-1):e;try{return JSON.parse(`"${t}"`)}catch{return t.replace(/\\n/g,`
|
|
668
668
|
`).replace(/\\r/g,"\r").replace(/\\t/g,"\t").replace(/\\"/g,'"').replace(/\\\\/g,"\\")}}function ur(e,t,r=0){let n=e.indexOf(`"${t}"`,r);if(n===-1)return;let o=e.indexOf(":",n+t.length+2);if(o===-1)return;let i=o+1;while(i<e.length){let c=e.charCodeAt(i);if(c!==32&&c!==9&&c!==10&&c!==13)break;i++}if(e.charCodeAt(i)!==34)return;let s=i+1,a=!1;for(let c=s;c<e.length;c++){let l=e.charCodeAt(c);if(a){a=!1;continue}if(l===92){a=!0;continue}if(l===34)return eN(e.slice(s,c))}return eN(e.slice(s))}function rN(e){let t=0,r=0;while(r<e.length){let n=e.indexOf('"type"',r);if(n===-1)break;let o=e.indexOf(":",n+6);if(o===-1)break;if(ur(e,"type",n)==="message")t++;r=o+1}return t}function tN(e){if(e===void 0)return;return e.trim()?e:null}function zre(e,t){if(e?.type!=="session"||typeof e.id!=="string")return;return{id:e.id,cwd:typeof e.cwd==="string"?e.cwd:void 0,title:t===null?void 0:t??(typeof e.title==="string"?e.title:void 0),parentSession:typeof e.parentSession==="string"?e.parentSession:void 0,timestamp:typeof e.timestamp==="string"?e.timestamp:void 0}}function Jre(e,t){if(ur(e,"type")!=="session")return;let r=ur(e,"id");if(!r)return;return{id:r,cwd:ur(e,"cwd"),title:t===null?void 0:t??ur(e,"title"),parentSession:ur(e,"parentSession"),timestamp:ur(e,"timestamp")}}function nN(e,t){let r=t[0],n=tN(r?.type==="title"&&typeof r.title==="string"?r.title:void 0),o=zre(t[r?.type==="title"?1:0],n);if(o)return o;let i,s=!0;for(let a of e.split(/\r?\n/)){let c=a.trim();if(!c)continue;if(s&&ur(c,"type")==="title"){i=tN(ur(c,"title")),s=!1;continue}return Jre(c,i)}return}var _S=4096,Yre=16384,oN=1048576;async function iN(e,t){let r=Bun.file(e),n=await r.stat(),o=Math.min(t,n.size);return{text:o>0?await r.slice(0,o).text():"",size:n.size,mtime:new Date(n.mtimeMs),mtimeMs:n.mtimeMs}}var Xre={session_exit:!0};function Qre(e){let t,r,n,o=!1;try{let a=JSON.parse(e);if(k(a))o=!0,t=a.type,r=a.customType,n=a.timestamp}catch{}if(!o)n=ur(e,"timestamp"),t=ur(e,"type"),r=ur(e,"customType");let i;if(typeof n==="number"&&Number.isFinite(n))i=new Date(n);else if(typeof n==="string"){let a=new Date(n);if(!Number.isNaN(a.getTime()))i=a}if(!i)return;let s=t==="custom"&&typeof r==="string"&&Xre[r]===!0;return{at:i,lifecycle:s}}async function sN(e,t,r){if(t<=0)return;let n=Yre;for(;;){let o=Math.max(0,t-n),i;if(t<=_S)i=r;else if(o===0)try{i=await Bun.file(e).text()}catch{return}else try{i=await Bun.file(e).slice(o-1).text()}catch{return}let s=i.split(`
|
|
669
669
|
`);if(o>0)s.shift();for(let a=s.length-1;a>=0;a--){let c=s[a].trim();if(!c.includes('"timestamp"'))continue;let l=Qre(c);if(l&&!l.lifecycle)return l.at}if(o===0||n>=oN)return;n=Math.min(n*4,oN)}}var cN=/User invoked the \\?"([^"\\]+)\\?" skill/,Bh="skill-prompt";function aN(e){if(typeof e==="string")return e;if(!Array.isArray(e))return"";return e.map((t)=>k(t)&&typeof t.text==="string"?t.text:"").join("")}function lN(e,t){let r=e.trim();if(!r)return"";let n=t?.trim();return n?`/skill:${r} ${n}`:`/skill:${r}`}function Mp(e){if(e.type==="custom_message"&&e.customType===Bh){if(e.attribution!==void 0&&e.attribution!=="user")return;let r=k(e.details)?e.details:void 0,n=typeof r?.name==="string"?r.name:cN.exec(aN(e.content))?.[1];if(!n)return;let o=typeof r?.args==="string"?r.args:void 0;return lN(n,o)||void 0}if(e.type!=="message")return;let t=k(e.message)?e.message:void 0;if(!t||t.role!=="user")return;return aN(t.content).trim()||void 0}function uN(e){let t,r=e.indexOf('"role"');while(r!==-1){let o=ur(e,"role",r),i=ur(e,"content",r)??ur(e,"text",r);if(i){if(o==="user")return i;if(!t&&(o==="developer"||o==="assistant"))t=i}r=e.indexOf('"role"',r+6)}let n=e.indexOf('"customType"');while(n!==-1){if(ur(e,"customType",n)===Bh){let o=cN.exec(e.slice(n))?.[1];if(o)return lN(o)}n=e.indexOf('"customType"',n+12)}return t}var pc=256;async function dN(e){try{let{text:t,size:r,mtime:n,mtimeMs:o}=await iN(e,_S),i=await sN(e,r,t),s=rr(t),a=nN(t,s);if(!a)return;let c=0,l="",u;for(let d=1;d<s.length;d++){let f=s[d];if(f.type==="compaction"&&typeof f.shortSummary==="string")u=f.shortSummary;if(f.type==="message"&&f.message)c++;if(!l){let p=Mp(f);if(p)l=p}}return l||=uN(t)??"",{path:e,id:a.id,cwd:a.cwd??"",title:a.title??u,parentSessionPath:a.parentSession,created:new Date(a.timestamp??""),modified:i??n,fileMtime:n,fileMtimeMs:o,messageCount:Math.max(c,rN(t)),size:r,firstMessage:l||"(no messages)"}}catch{return}}var pN=3,Zre=2048;async function _re(e=Yn()){try{await Bun.file(e).stat()}catch{return[]}if(!globalThis.__kabmoSessionFileListCache)globalThis.__kabmoSessionFileListCache=new Map;let t=globalThis.__kabmoSessionFileListCache,r=t.get(e);if(r){let s=!0;for(let a of await ek.promises.readdir(e,{withFileTypes:!0})){if(!a.isDirectory())continue;try{let c=await Bun.file(Uh.join(e,a.name)).stat();if(r.dirMtimes.get(a.name)!==c.mtimeMs){s=!1;break}}catch{s=!1;break}}if(s&&r.dirMtimes.size>0)return r.files}let n=[],o=new Map,i=[];try{i=await ek.promises.readdir(e,{withFileTypes:!0})}catch{}for(let s of i){if(!s.isDirectory())continue;let a=Uh.join(e,s.name);try{o.set(s.name,(await Bun.file(a).stat()).mtimeMs)}catch{continue}let c=[];try{c=await ek.promises.readdir(a,{withFileTypes:!0})}catch{continue}for(let l of c){if(!l.isFile()||!l.name.endsWith(".jsonl"))continue;n.push(Uh.join(a,l.name))}}return t.set(e,{dirMtimes:o,files:n}),globalThis.__kabmoSessionIdIndex?.delete(e),n}function ene(){let e=globalThis.__kabmoSessionScanCache;if(e&&e.version===pN)return e.entries;let t={version:pN,entries:new Map};return globalThis.__kabmoSessionScanCache=t,t.entries}async function tne(e){let t;try{t=await Bun.file(e).stat()}catch{return}let r=ene(),n=r.get(e);if(n){let i=n;if(i.size===t.size&&i.fileMtimeMs===t.mtimeMs)return r.delete(e),r.set(e,i),i;r.delete(e)}let o=await dN(e);if(o){r.set(e,o);while(r.size>Zre){let i=r.keys().next().value;if(i===void 0)break;r.delete(i)}}return o}async function rne(e,t,r){let n=Array(e.length),o=0,i=Array(Math.min(t,e.length)).fill(null).map(async()=>{for(;;){let s=o++;if(s>=e.length)return;n[s]=await r(e[s])}});return await Promise.all(i),n}var nne=32;async function tk(e=Yn()){let t=await _re(e),r=await rne(t,nne,(o)=>tne(o)),n=[];for(let o of r)if(o)n.push(o);return n.sort((o,i)=>i.modified.getTime()-o.modified.getTime()),n}async function rk(e=Yn()){let t=globalThis.__kabmoSessionIdIndex??=new Map,r=t.get(e);if(r)return r.entries;let n=new Map;for(let o of await tk(e))if(!n.has(o.id))n.set(o.id,o.path);return t.set(e,{entries:n}),n}function vt(){globalThis.__kabmoSessionFileListCache?.clear(),globalThis.__kabmoSessionScanCache?.entries.clear(),globalThis.__kabmoSessionIdIndex?.clear()}async function Ql(e){try{let r=(await Bun.file(e).slice(0,pc+4096).text()).split(`
|