codeplane-linux-x64-baseline-musl 28.21.15 → 28.21.17
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/bin/codeplane +0 -0
- package/bin/runtime/tui/node-main.js +4 -4
- package/package.json +1 -1
package/bin/codeplane
CHANGED
|
Binary file
|
|
@@ -739,7 +739,7 @@ ${A?A().outerHTML:""}`);return A()}if(Eu.completed)Eu.completed.add(u);return Eu
|
|
|
739
739
|
`)}if(d6.hasName(A,"UICancelledError"))return""}function trA(A){return kJA(A)}var sn0=k(()=>{Xg();ZY()});var Vv,yk1;var $HA=k(async()=>{sn0();GrA();await N0([IA(),OU()]);({use:Vv,provider:yk1}=Wq({name:"Exit",init:(A)=>{let u=n8(),q,F,G={set:(g)=>{let Q=q;return q=g,()=>{q=Q}},clear:()=>{q=void 0},get:()=>q},w=Object.assign((g)=>{if(F)return F;return F=(async()=>{if(await A.onBeforeExit?.(),u.setTerminalTitle(""),u.destroy(),FrA(),g){let j=brA(g)??trA(g);if(j)process.stderr.write(j+`
|
|
740
740
|
`)}let Q=G.get();if(Q)process.stdout.write(Q+`
|
|
741
741
|
`);await A.onExit?.()})(),F},{message:G});return process.on("SIGHUP",()=>w()),w}}))});var VP,vk1;var L8A=k(async()=>{await OU();({use:VP,provider:vk1}=Wq({name:"Args",init:(A)=>A}))});var yrA,en0;var Ap0=k(()=>{i0();Mu();yrA=class yrA extends L.Class("ConsoleState")({consoleManagedProviders:L.mutable(L.Array(L.String)),activeOrgName:L.optional(L.String),switchableOrgCount:L.Number}){static zod=B0(this)};en0=yrA.make({consoleManagedProviders:[],activeOrgName:void 0,switchableOrgCount:0})});import lk1 from"path";var V4,ik1;var WQ=k(async()=>{iF();bk1();U6();Ap0();await N0([Yx(),M8A(),Wg(),OU(),$HA(),L8A(),Sp(),Oo()]);({use:V4,provider:ik1}=Wq({name:"Sync",init:()=>{let[A,u]=F4({provider_next:{all:[],catalog:[],default:{},connected:[]},console_state:en0,provider_auth:{},config:{},status:"loading",agent:[],permission:{},question:{},command:[],provider:[],provider_default:{},session:[],session_status:{},session_diff:{},todo:{},message:{},part:{},lsp:[],mcp:{},mcp_resource:{},formatter:[],vcs:void 0}),q=YP(),F=WU(),G=k4(),w=h$(),g=new Set,Q=F.workspace.current();function j(){if(!w.get("session_directory_filter_enabled",!0))return{scope:"project"};if(!F.data.instance.path.worktree||!F.data.instance.path.directory)return{scope:"project"};return{path:lk1.relative(lk1.resolve(F.data.instance.path.worktree),F.data.instance.path.directory).replaceAll("\\","/")}}function K(){return G.client.session.list({start:Date.now()-2592000000,...j()}).then((X)=>(X.data??[]).toSorted((Y,V)=>Y.id.localeCompare(V.id)))}q.subscribe((X)=>{switch(X.type){case"server.instance.disposed":O();break;case"permission.replied":{let Y=A.permission[X.properties.sessionID];if(!Y)break;let V=FX.search(Y,X.properties.requestID,(Z)=>Z.id);if(!V.found)break;u("permission",X.properties.sessionID,Cq((Z)=>{Z.splice(V.index,1)}));break}case"permission.asked":{let Y=X.properties,V=A.permission[Y.sessionID];if(!V){u("permission",Y.sessionID,[Y]);break}let Z=FX.search(V,Y.id,(H)=>H.id);if(Z.found){u("permission",Y.sessionID,Z.index,Mq(Y));break}u("permission",Y.sessionID,Cq((H)=>{H.splice(Z.index,0,Y)}));break}case"question.replied":case"question.rejected":{let Y=A.question[X.properties.sessionID];if(!Y)break;let V=FX.search(Y,X.properties.requestID,(Z)=>Z.id);if(!V.found)break;u("question",X.properties.sessionID,Cq((Z)=>{Z.splice(V.index,1)}));break}case"question.asked":{let Y=X.properties,V=A.question[Y.sessionID];if(!V){u("question",Y.sessionID,[Y]);break}let Z=FX.search(V,Y.id,(H)=>H.id);if(Z.found){u("question",Y.sessionID,Z.index,Mq(Y));break}u("question",Y.sessionID,Cq((H)=>{H.splice(Z.index,0,Y)}));break}case"todo.updated":u("todo",X.properties.sessionID,X.properties.todos);break;case"session.diff":u("session_diff",X.properties.sessionID,X.properties.diff);break;case"session.deleted":{let Y=FX.search(A.session,X.properties.info.id,(V)=>V.id);if(Y.found)u("session",Cq((V)=>{V.splice(Y.index,1)}));break}case"session.updated":{let Y=FX.search(A.session,X.properties.info.id,(V)=>V.id);if(Y.found){u("session",Y.index,Mq(X.properties.info));break}u("session",Cq((V)=>{V.splice(Y.index,0,X.properties.info)}));break}case"session.status":{u("session_status",X.properties.sessionID,X.properties.status);break}case"message.updated":{let Y=A.message[X.properties.info.sessionID];if(!Y){u("message",X.properties.info.sessionID,[X.properties.info]);break}let V=FX.search(Y,X.properties.info.id,(H)=>H.id);if(V.found){u("message",X.properties.info.sessionID,V.index,Mq(X.properties.info));break}u("message",X.properties.info.sessionID,Cq((H)=>{H.splice(V.index,0,X.properties.info)}));let Z=A.message[X.properties.info.sessionID];if(Z.length>100){let H=Z[0];N7(()=>{u("message",X.properties.info.sessionID,Cq((N)=>{N.shift()})),u("part",Cq((N)=>{delete N[H.id]}))})}break}case"message.removed":{let Y=A.message[X.properties.sessionID],V=FX.search(Y,X.properties.messageID,(Z)=>Z.id);if(V.found)u("message",X.properties.sessionID,Cq((Z)=>{Z.splice(V.index,1)}));break}case"message.part.updated":{let Y=A.part[X.properties.part.messageID];if(!Y){u("part",X.properties.part.messageID,[X.properties.part]);break}let V=FX.search(Y,X.properties.part.id,(Z)=>Z.id);if(V.found){u("part",X.properties.part.messageID,V.index,Mq(X.properties.part));break}u("part",X.properties.part.messageID,Cq((Z)=>{Z.splice(V.index,0,X.properties.part)}));break}case"message.part.delta":{let Y=A.part[X.properties.messageID];if(!Y)break;let V=FX.search(Y,X.properties.partID,(Z)=>Z.id);if(!V.found)break;u("part",X.properties.messageID,Cq((Z)=>{let H=Z[V.index],N=X.properties.field,B=H[N];H[N]=(B??"")+X.properties.delta}));break}case"message.part.removed":{let Y=A.part[X.properties.messageID],V=FX.search(Y,X.properties.partID,(Z)=>Z.id);if(V.found)u("part",X.properties.messageID,Cq((Z)=>{Z.splice(V.index,1)}));break}case"lsp.updated":{let Y=F.workspace.current();G.client.lsp.status({workspace:Y}).then((V)=>u("lsp",V.data??[]));break}case"vcs.branch.updated":{u("vcs",{branch:X.properties.branch});break}}});let U=Vv(),_=VP();async function O(X={}){let Y=X.fatal??!0,V=F.workspace.current();if(V!==Q)g.clear(),Q=V;let Z=F.sync(),H=Z.then(()=>K()),N=G.client.config.providers({workspace:V},{throwOnError:!0}),B=G.client.provider.list({workspace:V},{throwOnError:!0}),M=G.client.experimental.console.get({workspace:V},{throwOnError:!0}).then((z)=>z.data).catch(()=>en0),x=G.client.app.agents({workspace:V},{throwOnError:!0}),$=G.client.config.get({workspace:V},{throwOnError:!0}),E=[N,B,x,$,Z,..._.continue?[H]:[]];await Promise.all(E).then(async()=>{let z=N.then((f)=>f.data),T=B.then((f)=>f.data),D=M,C=x.then((f)=>f.data??[]),t=$.then((f)=>f.data),S=_.continue?H:void 0;return Promise.all([z,T,D,C,t,...S?[S]:[]]).then((f)=>{let r=f[0],l=f[1],e=f[2],s=f[3],a=f[4],uA=f[5];N7(()=>{if(u("provider",Mq(r.providers)),u("provider_default",Mq(r.default)),u("provider_next",Mq(l)),u("console_state",Mq(e)),u("agent",Mq(s)),u("config",Mq(a)),uA!==void 0)u("session",Mq(uA))})})}).then(()=>{if(A.status!=="complete")u("status","partial");Promise.all([..._.continue?[]:[H.then((z)=>u("session",Mq(z)))],M.then((z)=>u("console_state",Mq(z))),G.client.command.list({workspace:V}).then((z)=>u("command",Mq(z.data??[]))),G.client.lsp.status({workspace:V}).then((z)=>u("lsp",Mq(z.data??[]))),G.client.mcp.status({workspace:V}).then((z)=>u("mcp",Mq(z.data??{}))),G.client.experimental.resource.list({workspace:V}).then((z)=>u("mcp_resource",Mq(z.data??{}))),G.client.formatter.status({workspace:V}).then((z)=>u("formatter",Mq(z.data??[]))),G.client.session.status({workspace:V}).then((z)=>{u("session_status",Mq(z.data??{}))}),G.client.provider.auth({workspace:V}).then((z)=>u("provider_auth",Mq(z.data??{}))),G.client.vcs.get({workspace:V}).then((z)=>u("vcs",Mq(z.data))),F.workspace.sync()]).then(()=>{u("status","complete")})}).catch(async(z)=>{if(Jd0.error("tui bootstrap failed",{error:z instanceof Error?z.message:String(z),name:z instanceof Error?z.name:void 0,stack:z instanceof Error?z.stack:void 0}),Y)await U(z);else throw z})}b5(()=>{O()});let W={data:A,set:u,get status(){return A.status},get ready(){if(process.env.CODEPLANE_FAST_BOOT)return!0;return A.status!=="loading"},get path(){return F.instance.path()},session:{get(X){let Y=FX.search(A.session,X,(V)=>V.id);if(Y.found)return A.session[Y.index];return},query(){return j()},async refresh(){let X=await K();u("session",Mq(X))},status(X){let Y=W.session.get(X);if(!Y)return"idle";if(Y.time.compacting)return"compacting";let Z=(A.message[X]??[]).at(-1);if(!Z)return"idle";if(Z.role==="user")return"working";return Z.time.completed?"idle":"working"},async sync(X){if(g.has(X))return;let[Y,V,Z,H]=await Promise.all([G.client.session.get({sessionID:X},{throwOnError:!0}),G.client.session.messages({sessionID:X,limit:100}),G.client.session.todo({sessionID:X}),G.client.session.diff({sessionID:X})]);u(Cq((N)=>{let B=FX.search(N.session,X,(M)=>M.id);if(B.found)N.session[B.index]=Y.data;if(!B.found)N.session.splice(B.index,0,Y.data);N.todo[X]=Z.data??[],N.message[X]=V.data.map((M)=>M.info);for(let M of V.data)N.part[M.info.id]=M.parts;N.session_diff[X]=H.data??[]})),g.add(X)}},bootstrap:O};return W}}))});var E8A=I((ck1,vrA)=>{((A,u)=>{if(typeof define==="function"&&define.amd)define([],u);else if(typeof vrA==="object"&&vrA.exports)vrA.exports=u();else A.fuzzysort=u()})(ck1,(A)=>{var u=(m,v)=>{if(!m||!v)return s;var gA=W(m);if(!f(v))v=O(v);var d=gA.bitflags;if((d&v._bitflags)!==d)return s;return Y(gA,v)},q=(m,v,gA)=>{if(!m)return gA?.all?X(v,gA):e;var d=W(m),GA=d.bitflags,OA=d.containsSpace,y=U(gA?.threshold||0),c=gA?.limit||r,FA=0,UA=0,jA=v.length;function b(MA){if(FA<c)n.add(MA),++FA;else if(++UA,MA._score>n.peek()._score)n.replaceTop(MA)}if(gA?.key){var qA=gA.key;for(var AA=0;AA<jA;++AA){var JA=v[AA],p=S(JA,qA);if(!p)continue;if(!f(p))p=O(p);if((GA&p._bitflags)!==GA)continue;var WA=Y(d,p);if(WA===s)continue;if(WA._score<y)continue;WA.obj=JA,b(WA)}}else if(gA?.keys){var $A=gA.keys,PA=$A.length;A:for(var AA=0;AA<jA;++AA){var JA=v[AA];{var DA=0;for(var rA=0;rA<PA;++rA){var qA=$A[rA],p=S(JA,qA);if(!p){C[rA]=a;continue}if(!f(p))p=O(p);C[rA]=p,DA|=p._bitflags}if((GA&DA)!==GA)continue}if(OA)for(let iA=0;iA<d.spaceSearches.length;iA++)T[iA]=l;for(var rA=0;rA<PA;++rA){if(p=C[rA],p===a){t[rA]=a;continue}if(t[rA]=Y(d,p,!1,OA),t[rA]===s){t[rA]=a;continue}if(OA)for(let j0=0;j0<d.spaceSearches.length;j0++){if(D[j0]>-1000){if(T[j0]>l){var W0=(T[j0]+D[j0])/4;if(W0>T[j0])T[j0]=W0}}if(D[j0]>T[j0])T[j0]=D[j0]}}if(OA){for(let iA=0;iA<d.spaceSearches.length;iA++)if(T[iA]===l)continue A}else{var Q0=!1;for(let iA=0;iA<PA;iA++)if(t[iA]._score!==l){Q0=!0;break}if(!Q0)continue}var E0=new Q(PA);for(let iA=0;iA<PA;iA++)E0[iA]=t[iA];if(OA){var C0=0;for(let iA=0;iA<d.spaceSearches.length;iA++)C0+=T[iA]}else{var C0=l;for(let j0=0;j0<PA;j0++){var WA=E0[j0];if(WA._score>-1000){if(C0>l){var W0=(C0+WA._score)/4;if(W0>C0)C0=W0}}if(WA._score>C0)C0=WA._score}}if(E0.obj=JA,E0._score=C0,gA?.scoreFn){if(C0=gA.scoreFn(E0),!C0)continue;C0=U(C0),E0._score=C0}if(C0<y)continue;b(E0)}}else for(var AA=0;AA<jA;++AA){var p=v[AA];if(!p)continue;if(!f(p))p=O(p);if((GA&p._bitflags)!==GA)continue;var WA=Y(d,p);if(WA===s)continue;if(WA._score<y)continue;b(WA)}if(FA===0)return e;var XA=Array(FA);for(var AA=FA-1;AA>=0;--AA)XA[AA]=n.poll();return XA.total=FA+UA,XA},F=(m,v="<b>",gA="</b>")=>{var d=typeof v==="function"?v:void 0,GA=m.target,OA=GA.length,y=m.indexes,c="",FA=0,UA=0,jA=!1,b=[];for(var qA=0;qA<OA;++qA){var AA=GA[qA];if(y[UA]===qA){if(++UA,!jA)if(jA=!0,d)b.push(c),c="";else c+=v;if(UA===y.length){if(d)c+=AA,b.push(d(c,FA++)),c="",b.push(GA.substr(qA+1));else c+=AA+gA+GA.substr(qA+1);break}}else if(jA)if(jA=!1,d)b.push(d(c,FA++)),c="";else c+=gA;c+=AA}return d?b:c},G=(m)=>{if(typeof m==="number")m=""+m;else if(typeof m!=="string")m="";var v=H(m);return j(m,{_targetLower:v._lower,_targetLowerCodes:v.lowerCodes,_bitflags:v.bitflags})},w=()=>{M.clear(),x.clear()};class g{get["indexes"](){return this._indexes.slice(0,this._indexes.len).sort((m,v)=>m-v)}set["indexes"](m){return this._indexes=m}["highlight"](m,v){return F(this,m,v)}get["score"](){return K(this._score)}set["score"](m){this._score=U(m)}}class Q extends Array{get["score"](){return K(this._score)}set["score"](m){this._score=U(m)}}var j=(m,v)=>{let gA=new g;return gA.target=m,gA.obj=v.obj??s,gA._score=v._score??l,gA._indexes=v._indexes??[],gA._targetLower=v._targetLower??"",gA._targetLowerCodes=v._targetLowerCodes??s,gA._nextBeginningIndexes=v._nextBeginningIndexes??s,gA._bitflags=v._bitflags??0,gA},K=(m)=>{if(m===l)return 0;if(m>1)return m;return Math.E**(((-m+1)**0.04307-1)*-2)},U=(m)=>{if(m===0)return l;if(m>1)return m;return 1-Math.pow(Math.log(m)/-2+1,23.218017181332716)},_=(m)=>{if(typeof m==="number")m=""+m;else if(typeof m!=="string")m="";m=m.trim();var v=H(m),gA=[];if(v.containsSpace){var d=m.split(/\s+/);d=[...new Set(d)];for(var GA=0;GA<d.length;GA++){if(d[GA]==="")continue;var OA=H(d[GA]);gA.push({lowerCodes:OA.lowerCodes,_lower:d[GA].toLowerCase(),containsSpace:!1})}}return{lowerCodes:v.lowerCodes,_lower:v._lower,containsSpace:v.containsSpace,bitflags:v.bitflags,spaceSearches:gA}},O=(m)=>{if(m.length>999)return G(m);var v=M.get(m);if(v!==void 0)return v;return v=G(m),M.set(m,v),v},W=(m)=>{if(m.length>999)return _(m);var v=x.get(m);if(v!==void 0)return v;return v=_(m),x.set(m,v),v},X=(m,v)=>{var gA=[];gA.total=m.length;var d=v?.limit||r;if(v?.key)for(var GA=0;GA<m.length;GA++){var OA=m[GA],y=S(OA,v.key);if(y==s)continue;if(!f(y))y=O(y);var c=j(y.target,{_score:y._score,obj:OA});if(gA.push(c),gA.length>=d)return gA}else if(v?.keys)for(var GA=0;GA<m.length;GA++){var OA=m[GA],FA=new Q(v.keys.length);for(var UA=v.keys.length-1;UA>=0;--UA){var y=S(OA,v.keys[UA]);if(!y){FA[UA]=a;continue}if(!f(y))y=O(y);y._score=l,y._indexes.len=0,FA[UA]=y}if(FA.obj=OA,FA._score=l,gA.push(FA),gA.length>=d)return gA}else for(var GA=0;GA<m.length;GA++){var y=m[GA];if(y==s)continue;if(!f(y))y=O(y);if(y._score=l,y._indexes.len=0,gA.push(y),gA.length>=d)return gA}return gA},Y=(m,v,gA=!1,d=!1)=>{if(gA===!1&&m.containsSpace)return V(m,v,d);var{_lower:GA,lowerCodes:OA}=m,y=OA[0],c=v._targetLowerCodes,FA=OA.length,UA=c.length,AA=0,jA=0,b=0;for(;;){var qA=y===c[jA];if(qA){if($[b++]=jA,++AA,AA===FA)break;y=OA[AA]}if(++jA,jA>=UA)return s}var AA=0,JA=!1,p=0,WA=v._nextBeginningIndexes;if(WA===s)WA=v._nextBeginningIndexes=B(v.target);jA=$[0]===0?0:WA[$[0]-1];var $A=0;if(jA!==UA)for(;;)if(jA>=UA){if(AA<=0)break;if(++$A,$A>200)break;--AA;var PA=E[--p];jA=WA[PA]}else{var qA=OA[AA]===c[jA];if(qA){if(E[p++]=jA,++AA,AA===FA){JA=!0;break}++jA}else jA=WA[jA]}var DA=FA<=1?-1:v._targetLower.indexOf(GA,$[0]),rA=!!~DA,W0=!rA?!1:DA===0||v._nextBeginningIndexes[DA-1]===DA;if(rA&&!W0)for(var Q0=0;Q0<WA.length;Q0=WA[Q0]){if(Q0<=DA)continue;for(var E0=0;E0<FA;E0++)if(OA[E0]!==v._targetLowerCodes[Q0+E0])break;if(E0===FA){DA=Q0,W0=!0;break}}var C0=(iA)=>{var j0=0,dA=0;for(var F0=1;F0<FA;++F0)if(iA[F0]-iA[F0-1]!==1)j0-=iA[F0],++dA;var BA=iA[FA-1]-iA[0]-(FA-1);if(j0-=(12+BA)*dA,iA[0]!==0)j0-=iA[0]*iA[0]*0.2;if(!JA)j0*=1000;else{var RA=1;for(var F0=WA[0];F0<UA;F0=WA[F0])++RA;if(RA>24)j0*=(RA-24)*10}if(j0-=(UA-FA)/2,rA)j0/=1+FA*FA*1;if(W0)j0/=1+FA*FA*1;return j0-=(UA-FA)/2,j0};if(!JA){if(rA)for(var Q0=0;Q0<FA;++Q0)$[Q0]=DA+Q0;var XA=$,MA=C0(XA)}else if(W0){for(var Q0=0;Q0<FA;++Q0)$[Q0]=DA+Q0;var XA=$,MA=C0($)}else var XA=E,MA=C0(E);v._score=MA;for(var Q0=0;Q0<FA;++Q0)v._indexes[Q0]=XA[Q0];v._indexes.len=FA;let TA=new g;return TA.target=v.target,TA._score=v._score,TA._indexes=v._indexes,TA},V=(m,v,gA)=>{var d=new Set,GA=0,OA=s,y=0,c=m.spaceSearches,FA=c.length,UA=0,jA=()=>{for(let W0=UA-1;W0>=0;W0--)v._nextBeginningIndexes[z[W0*2+0]]=z[W0*2+1]},b=!1;for(var rA=0;rA<FA;++rA){D[rA]=l;var qA=c[rA];if(OA=Y(qA,v),gA){if(OA===s)continue;b=!0}else if(OA===s)return jA(),s;var AA=rA===FA-1;if(!AA){var JA=OA._indexes,p=!0;for(let Q0=0;Q0<JA.len-1;Q0++)if(JA[Q0+1]-JA[Q0]!==1){p=!1;break}if(p){var WA=JA[JA.len-1]+1,$A=v._nextBeginningIndexes[WA-1];for(let Q0=WA-1;Q0>=0;Q0--){if($A!==v._nextBeginningIndexes[Q0])break;v._nextBeginningIndexes[Q0]=WA,z[UA*2+0]=Q0,z[UA*2+1]=$A,UA++}}}if(GA+=OA._score/FA,D[rA]=OA._score/FA,OA._indexes[0]<y)GA-=(y-OA._indexes[0])*2;y=OA._indexes[0];for(var PA=0;PA<OA._indexes.len;++PA)d.add(OA._indexes[PA])}if(gA&&!b)return s;jA();var DA=Y(m,v,!0);if(DA!==s&&DA._score>GA){if(gA)for(var rA=0;rA<FA;++rA)D[rA]=DA._score/FA;return DA}if(gA)OA=v;OA._score=GA;var rA=0;for(let W0 of d)OA._indexes[rA++]=W0;return OA._indexes.len=rA,OA},Z=(m)=>m.replace(/\p{Script=Latin}+/gu,(v)=>v.normalize("NFD")).replace(/[\u0300-\u036f]/g,""),H=(m)=>{m=Z(m);var v=m.length,gA=m.toLowerCase(),d=[],GA=0,OA=!1;for(var y=0;y<v;++y){var c=d[y]=gA.charCodeAt(y);if(c===32){OA=!0;continue}var FA=c>=97&&c<=122?c-97:c>=48&&c<=57?26:c<=127?30:31;GA|=1<<FA}return{lowerCodes:d,bitflags:GA,containsSpace:OA,_lower:gA}},N=(m)=>{var v=m.length,gA=[],d=0,GA=!1,OA=!1;for(var y=0;y<v;++y){var c=m.charCodeAt(y),FA=c>=65&&c<=90,UA=FA||c>=97&&c<=122||c>=48&&c<=57,jA=FA&&!GA||!OA||!UA;if(GA=FA,OA=UA,jA)gA[d++]=y}return gA},B=(m)=>{m=Z(m);var v=m.length,gA=N(m),d=[],GA=gA[0],OA=0;for(var y=0;y<v;++y)if(GA>y)d[y]=GA;else GA=gA[++OA],d[y]=GA===void 0?v:GA;return d},M=new Map,x=new Map,$=[],E=[],z=[],T=[],D=[],C=[],t=[],S=(m,v)=>{var gA=m[v];if(gA!==void 0)return gA;if(typeof v==="function")return v(m);var d=v;if(!Array.isArray(v))d=v.split(".");var GA=d.length,OA=-1;while(m&&++OA<GA)m=m[d[OA]];return m},f=(m)=>{return typeof m==="object"&&typeof m._bitflags==="number"},r=1/0,l=-r,e=[];e.total=0;var s=null,a=G(""),uA=(m)=>{var v=[],gA=0,d={},GA=(OA)=>{for(var y=0,c=v[y],FA=1;FA<gA;){var UA=FA+1;y=FA,UA<gA&&v[UA]._score<v[FA]._score&&(y=UA),v[y-1>>1]=v[y],FA=1+(y<<1)}for(var jA=y-1>>1;y>0&&c._score<v[jA]._score;jA=(y=jA)-1>>1)v[y]=v[jA];v[y]=c};return d.add=(OA)=>{var y=gA;v[gA++]=OA;for(var c=y-1>>1;y>0&&OA._score<v[c]._score;c=(y=c)-1>>1)v[y]=v[c];v[y]=OA},d.poll=(OA)=>{if(gA!==0){var y=v[0];return v[0]=v[--gA],GA(),y}},d.peek=(OA)=>{if(gA!==0)return v[0]},d.replaceTop=(OA)=>{v[0]=OA,GA()},d},n=uA();return{single:u,go:q,prepare:G,cleanup:w}})});var aq;var Zv=k(()=>{tL0();aq={match:HF1,fromParsedKey:NF1,toString:BF1,parse:$F1}});var A9,dk1;var qV=k(async()=>{U6();Zv();rw();iF();await N0([IA(),OU(),HC()]);({use:A9,provider:dk1}=Wq({name:"Keybind",init:()=>{let A=wO(),u=yA(()=>{return nF(A.keybinds??{},$Y((K)=>aq.parse(K)))}),[q,F]=F4({leader:!1}),G=n8(),w,g;function Q(K){if(K){if(F("leader",!0),w=G.currentFocusedRenderable,w?.blur(),g)clearTimeout(g);g=setTimeout(()=>{if(!q.leader)return;if(Q(!1),!w||w.isDestroyed)return;w.focus()},2000);return}if(!K){if(w&&!G.currentFocusedRenderable)w.focus();F("leader",!1)}}G4(async(K)=>{if(!q.leader&&j.match("leader",K)){Q(!0);return}if(q.leader&&K.name)setImmediate(()=>{if(w&&G.currentFocusedRenderable===w)w.focus();Q(!1)})});let j={get all(){return u()},get leader(){return q.leader},parse(K){if(K.name==="\x1F")return aq.fromParsedKey({...K,name:"_",ctrl:!0},q.leader);return aq.fromParsedKey(K,q.leader)},match(K,U){let _=u()[K]??aq.parse(K);if(!_.length)return!1;let O=j.parse(U);for(let W of _)if(aq.match(W,O))return!0;return!1},print(K){let U=u()[K]?.at(0)??aq.parse(K).at(0);if(!U)return"";let _=aq.toString(U),O=u().leader?.[0];if(!O)return _;return _.replace("<leader>",aq.toString(O))}};return j}}))});var A3;var FV=k(()=>{A3={titlecase:EF1,time:otA,datetime:vL0,todayTimeOrDateTime:xF1,number:zF1,duration:RF1,truncate:DF1,truncateMiddle:PF1,pluralize:TF1}});class up0{speed;constructor(A){this.speed=A}tick(A){return this.speed}reset(){}}function b$(A){if(A?.scroll_acceleration?.enabled)return new Jn;if(A?.scroll_speed!==void 0)return new up0(A.scroll_speed);return new up0(3)}var Xo=k(async()=>{await D8()});function I3(A){let u=Ju(),{theme:q}=V2(),F=wO(),G=yA(()=>b$(F)),[w,g]=F4({selected:0,filter:"",input:"keyboard"});B4(JB(()=>A.current,(E)=>{if(E){let z=_().findIndex((T)=>_E(T.value,E));if(z>=0)g("selected",z)}}));let Q,j=yA(()=>{if(A.skipFilter)return A.options.filter((D)=>D.disabled!==!0);let E=w.filter.toLowerCase(),z=nF(A.options,yk((D)=>D.disabled!==!0));if(!E)return z;return nk1.go(E,z,{keys:["title","category"],scoreFn:(D)=>D[0].score*2+D[1].score}).map((D)=>D.obj)});B4(()=>{j(),g("input","keyboard")});let K=yA(()=>A.flat&&w.filter.length>0),U=yA(()=>{if(K())return[["",j()]];return nF(j(),mL0((z)=>z.category??""),kp())}),_=yA(()=>{return nF(U(),uOA(([E,z])=>z))}),O=yA(()=>{let E=U().reduce((z,[T],D)=>{if(!T)return z;return z+(D>0?2:1)},0);return _().length+E}),W=l7(),X=yA(()=>Math.min(O(),Math.floor(W().height/2)-6)),Y=yA(()=>_()[w.selected]);B4(JB([()=>w.filter,()=>A.current],([E,z])=>{setTimeout(()=>{if(E.length>0)Z(0,!0);else if(z){let T=_().findIndex((D)=>_E(D.value,z));if(T>=0)Z(T,!0)}},0)}));function V(E){if(_().length===0)return;let z=w.selected+E;if(z<0)z=_().length-1;if(z>=_().length)z=0;Z(z,!0)}function Z(E,z=!1){g("selected",E);let T=Y();if(T)A.onMove?.(T);if(!N)return;let D=N.getChildren().find((t)=>{return t.id===JSON.stringify(Y()?.value)});if(!D)return;let C=D.y-N.y;if(z){let t=Math.floor(N.height/2);N.scrollBy(C-t)}else{if(C>=N.height)N.scrollBy(C-N.height+1);if(C<0){if(N.scrollBy(C),_E(_()[0].value,Y()?.value))N.scrollTo(0)}}}let H=A9();G4((E)=>{if(g("input","keyboard"),E.name==="up"||E.ctrl&&E.name==="p")V(-1);if(E.name==="down"||E.ctrl&&E.name==="n")V(1);if(E.name==="pageup")V(-10);if(E.name==="pagedown")V(10);if(E.name==="home")Z(0);if(E.name==="end")Z(_().length-1);if(E.name==="return"){let z=Y();if(z){if(E.preventDefault(),E.stopPropagation(),z.onSelect)z.onSelect(u);A.onSelect?.(z)}}for(let z of A.keybind??[]){if(z.disabled||!z.keybind)continue;if(aq.match(z.keybind,H.parse(E))){let T=Y();if(T)E.preventDefault(),z.onTrigger(T)}}});let N,B={get filter(){return w.filter},get filtered(){return j()}};A.ref?.(B);let M=yA(()=>A.keybind?.filter((E)=>!E.disabled&&E.keybind)??[]),x=yA(()=>M().filter((E)=>E.side!=="right")),$=yA(()=>M().filter((E)=>E.side==="right"));return(()=>{var E=o("box"),z=o("box"),T=o("box"),D=o("text"),C=o("text"),t=o("span"),S=o("box"),f=o("input");return wA(E,z),P(E,"gap",1),P(E,"paddingBottom",1),wA(z,T),wA(z,S),P(z,"paddingLeft",4),P(z,"paddingRight",4),wA(T,D),wA(T,C),P(T,"flexDirection","row"),P(T,"justifyContent","space-between"),P(T,"alignItems","center"),VA(D,()=>A.title),wA(C,t),P(C,"onMouseUp",()=>u.clear()),wA(t,mA("esc")),wA(S,f),P(S,"paddingTop",1),vg((r)=>{Q=r,Q.traits={status:"FILTER"},setTimeout(()=>{if(!Q)return;if(Q.isDestroyed)return;Q.focus()},1)},f),P(f,"onInput",(r)=>{N7(()=>{g("filter",r),A.onFilter?.(r)})}),VA(E,QA(X0,{get when(){return U().length>0},get fallback(){return(()=>{var r=o("box"),l=o("text");return wA(r,l),P(r,"paddingLeft",4),P(r,"paddingRight",4),P(r,"paddingTop",1),wA(l,mA("No results found")),SA((e)=>P(l,"fg",q.textMuted,e)),r})()},get children(){var r=o("scrollbox");return vg((l)=>N=l,r),P(r,"paddingLeft",1),P(r,"paddingRight",1),P(r,"scrollbarOptions",{visible:!1}),VA(r,QA(K6,{get each(){return U()},children:([l,e],s)=>[QA(X0,{when:l,get children(){var a=o("box");return P(a,"paddingLeft",3),VA(a,QA(X0,{get when(){return e[0]?.categoryView},get fallback(){return(()=>{var uA=o("text");return VA(uA,l),SA((n)=>{var m=q.accent,v=z6.BOLD;return m!==n.e&&(n.e=P(uA,"fg",m,n.e)),v!==n.t&&(n.t=P(uA,"attributes",v,n.t)),n},{e:void 0,t:void 0}),uA})()},get children(){return e[0]?.categoryView}})),SA((uA)=>P(a,"paddingTop",s()>0?1:0,uA)),a}}),QA(K6,{each:e,children:(a)=>{let uA=yA(()=>_E(a.value,Y()?.value)),n=yA(()=>_E(a.value,A.current));return(()=>{var m=o("box");return P(m,"flexDirection","row"),P(m,"position","relative"),P(m,"onMouseMove",()=>{g("input","mouse")}),P(m,"onMouseUp",()=>{a.onSelect?.(u),A.onSelect?.(a)}),P(m,"onMouseOver",()=>{if(w.input!=="mouse")return;let v=_().findIndex((gA)=>_E(gA.value,a.value));if(v===-1)return;Z(v)}),P(m,"onMouseDown",()=>{let v=_().findIndex((gA)=>_E(gA.value,a.value));if(v===-1)return;Z(v)}),P(m,"paddingRight",3),P(m,"gap",1),VA(m,QA(X0,{get when(){return f2(()=>!n())()&&a.margin},get children(){var v=o("box");return P(v,"position","absolute"),P(v,"left",1),P(v,"flexShrink",0),VA(v,()=>a.margin),v}}),null),VA(m,QA(FS3,{get title(){return a.title},get footer(){return f2(()=>!!K())()?a.category??a.footer:a.footer},get description(){return f2(()=>a.description!==l)()?a.description:void 0},get active(){return uA()},get current(){return n()},get gutter(){return a.gutter}}),null),SA((v)=>{var gA=JSON.stringify(a.value),d=uA()?a.bg??q.primary:m2.fromInts(0,0,0,0),GA=n()||a.gutter?1:3;return gA!==v.e&&(v.e=P(m,"id",gA,v.e)),d!==v.t&&(v.t=P(m,"backgroundColor",d,v.t)),GA!==v.a&&(v.a=P(m,"paddingLeft",GA,v.a)),v},{e:void 0,t:void 0,a:void 0}),m})()}})]})),SA((l)=>{var e=G(),s=X();return e!==l.e&&(l.e=P(r,"scrollAcceleration",e,l.e)),s!==l.t&&(l.t=P(r,"maxHeight",s,l.t)),l},{e:void 0,t:void 0}),r}}),null),VA(E,QA(X0,{get when(){return M().length},get fallback(){return(()=>{var r=o("box");return P(r,"flexShrink",0),r})()},get children(){var r=o("box"),l=o("box"),e=o("box");return wA(r,l),wA(r,e),P(r,"paddingRight",2),P(r,"paddingLeft",4),P(r,"flexDirection","row"),P(r,"justifyContent","space-between"),P(r,"flexShrink",0),P(r,"paddingTop",1),P(r,"border",["top"]),P(l,"flexDirection","row"),P(l,"gap",2),VA(l,QA(K6,{get each(){return x()},children:(s)=>(()=>{var a=o("text"),uA=o("span"),n=o("b"),m=mA(" "),v=o("span");return wA(a,uA),wA(a,v),wA(uA,n),wA(uA,m),VA(n,()=>s.title),VA(v,()=>aq.toString(s.keybind)),SA((gA)=>{var d={fg:q.text},GA={fg:q.textMuted};return d!==gA.e&&(gA.e=P(uA,"style",d,gA.e)),GA!==gA.t&&(gA.t=P(v,"style",GA,gA.t)),gA},{e:void 0,t:void 0}),a})()})),P(e,"flexDirection","row"),P(e,"gap",2),VA(e,QA(K6,{get each(){return $()},children:(s)=>(()=>{var a=o("text"),uA=o("span"),n=o("b"),m=mA(" "),v=o("span");return wA(a,uA),wA(a,v),wA(uA,n),wA(uA,m),VA(n,()=>s.title),VA(v,()=>aq.toString(s.keybind)),SA((gA)=>{var d={fg:q.text},GA={fg:q.textMuted};return d!==gA.e&&(gA.e=P(uA,"style",d,gA.e)),GA!==gA.t&&(gA.t=P(v,"style",GA,gA.t)),gA},{e:void 0,t:void 0}),a})()})),SA((s)=>P(r,"borderColor",q.borderSubtle,s)),r}}),null),SA((r)=>{var l=q.accent,e=z6.BOLD,s=q.textMuted,a={fg:q.textMuted},uA=q.backgroundPanel,n=q.primary,m=q.textMuted,v=A.placeholder??"Search",gA=q.textMuted;return l!==r.e&&(r.e=P(D,"fg",l,r.e)),e!==r.t&&(r.t=P(D,"attributes",e,r.t)),s!==r.a&&(r.a=P(C,"fg",s,r.a)),a!==r.o&&(r.o=P(t,"style",a,r.o)),uA!==r.i&&(r.i=P(f,"focusedBackgroundColor",uA,r.i)),n!==r.n&&(r.n=P(f,"cursorColor",n,r.n)),m!==r.s&&(r.s=P(f,"focusedTextColor",m,r.s)),v!==r.h&&(r.h=P(f,"placeholder",v,r.h)),gA!==r.r&&(r.r=P(f,"placeholderColor",gA,r.r)),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),E})()}function FS3(A){let{theme:u}=V2(),q=m$(u);return[QA(X0,{get when(){return A.current},get children(){var F=o("text");return wA(F,mA("\u25CF")),P(F,"flexShrink",0),P(F,"marginRight",0),SA((G)=>P(F,"fg",A.active?q:A.current?u.primary:u.text,G)),F}}),QA(X0,{get when(){return f2(()=>!A.current)()&&A.gutter},get children(){var F=o("box");return P(F,"flexShrink",0),P(F,"marginRight",0),VA(F,()=>A.gutter?.()),F}}),(()=>{var F=o("text");return P(F,"flexGrow",1),P(F,"overflow","hidden"),P(F,"wrapMode","none"),P(F,"paddingLeft",3),VA(F,()=>A3.truncate(A.title,61),null),VA(F,QA(X0,{get when(){return A.description},get children(){var G=o("span"),w=mA(" ");return wA(G,w),VA(G,()=>A.description,null),SA((g)=>P(G,"style",{fg:A.active?q:u.textMuted},g)),G}}),null),SA((G)=>{var w=A.active?q:A.current?u.primary:u.text,g=A.active?z6.BOLD:void 0;return w!==G.e&&(G.e=P(F,"fg",w,G.e)),g!==G.t&&(G.t=P(F,"attributes",g,G.t)),G},{e:void 0,t:void 0}),F})(),QA(X0,{get when(){return A.footer},get children(){var F=o("box"),G=o("text");return wA(F,G),P(F,"flexShrink",0),VA(G,()=>A.footer),SA((w)=>P(G,"fg",A.active?q:u.textMuted,w)),F}})]}var nk1;var oj=k(async()=>{rw();U6();iF();rw();Zv();FV();await N0([IA(),IA(),IA(),IA(),IA(),IA(),IA(),IA(),IA(),D8(),F8(),IA(),_7(),qV(),Xo(),HC()]);nk1=u2(E8A(),1)});var qp0;var pk1=k(()=>{qp0={dots:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]},dots2:{interval:80,frames:["\u28FE","\u28FD","\u28FB","\u28BF","\u287F","\u28DF","\u28EF","\u28F7"]},dots3:{interval:80,frames:["\u280B","\u2819","\u281A","\u281E","\u2816","\u2826","\u2834","\u2832","\u2833","\u2813"]},dots4:{interval:80,frames:["\u2804","\u2806","\u2807","\u280B","\u2819","\u2838","\u2830","\u2820","\u2830","\u2838","\u2819","\u280B","\u2807","\u2806"]},dots5:{interval:80,frames:["\u280B","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B"]},dots6:{interval:80,frames:["\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2834","\u2832","\u2812","\u2802","\u2802","\u2812","\u281A","\u2819","\u2809","\u2801"]},dots7:{interval:80,frames:["\u2808","\u2809","\u280B","\u2813","\u2812","\u2810","\u2810","\u2812","\u2816","\u2826","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808"]},dots8:{interval:80,frames:["\u2801","\u2801","\u2809","\u2819","\u281A","\u2812","\u2802","\u2802","\u2812","\u2832","\u2834","\u2824","\u2804","\u2804","\u2824","\u2820","\u2820","\u2824","\u2826","\u2816","\u2812","\u2810","\u2810","\u2812","\u2813","\u280B","\u2809","\u2808","\u2808"]},dots9:{interval:80,frames:["\u28B9","\u28BA","\u28BC","\u28F8","\u28C7","\u2867","\u2857","\u284F"]},dots10:{interval:80,frames:["\u2884","\u2882","\u2881","\u2841","\u2848","\u2850","\u2860"]},dots11:{interval:100,frames:["\u2801","\u2802","\u2804","\u2840","\u2880","\u2820","\u2810","\u2808"]},dots12:{interval:80,frames:["\u2880\u2800","\u2840\u2800","\u2804\u2800","\u2882\u2800","\u2842\u2800","\u2805\u2800","\u2883\u2800","\u2843\u2800","\u280D\u2800","\u288B\u2800","\u284B\u2800","\u280D\u2801","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2888\u2829","\u2840\u2899","\u2804\u2859","\u2882\u2829","\u2842\u2898","\u2805\u2858","\u2883\u2828","\u2843\u2890","\u280D\u2850","\u288B\u2820","\u284B\u2880","\u280D\u2841","\u288B\u2801","\u284B\u2801","\u280D\u2809","\u280B\u2809","\u280B\u2809","\u2809\u2819","\u2809\u2819","\u2809\u2829","\u2808\u2899","\u2808\u2859","\u2808\u2829","\u2800\u2899","\u2800\u2859","\u2800\u2829","\u2800\u2898","\u2800\u2858","\u2800\u2828","\u2800\u2890","\u2800\u2850","\u2800\u2820","\u2800\u2880","\u2800\u2840"]},dots13:{interval:80,frames:["\u28FC","\u28F9","\u28BB","\u283F","\u285F","\u28CF","\u28E7","\u28F6"]},dots14:{interval:80,frames:["\u2809\u2809","\u2808\u2819","\u2800\u2839","\u2800\u28B8","\u2800\u28F0","\u2880\u28E0","\u28C0\u28C0","\u28C4\u2840","\u28C6\u2800","\u2847\u2800","\u280F\u2800","\u280B\u2801"]},dots8Bit:{interval:80,frames:["\u2800","\u2801","\u2802","\u2803","\u2804","\u2805","\u2806","\u2807","\u2840","\u2841","\u2842","\u2843","\u2844","\u2845","\u2846","\u2847","\u2808","\u2809","\u280A","\u280B","\u280C","\u280D","\u280E","\u280F","\u2848","\u2849","\u284A","\u284B","\u284C","\u284D","\u284E","\u284F","\u2810","\u2811","\u2812","\u2813","\u2814","\u2815","\u2816","\u2817","\u2850","\u2851","\u2852","\u2853","\u2854","\u2855","\u2856","\u2857","\u2818","\u2819","\u281A","\u281B","\u281C","\u281D","\u281E","\u281F","\u2858","\u2859","\u285A","\u285B","\u285C","\u285D","\u285E","\u285F","\u2820","\u2821","\u2822","\u2823","\u2824","\u2825","\u2826","\u2827","\u2860","\u2861","\u2862","\u2863","\u2864","\u2865","\u2866","\u2867","\u2828","\u2829","\u282A","\u282B","\u282C","\u282D","\u282E","\u282F","\u2868","\u2869","\u286A","\u286B","\u286C","\u286D","\u286E","\u286F","\u2830","\u2831","\u2832","\u2833","\u2834","\u2835","\u2836","\u2837","\u2870","\u2871","\u2872","\u2873","\u2874","\u2875","\u2876","\u2877","\u2838","\u2839","\u283A","\u283B","\u283C","\u283D","\u283E","\u283F","\u2878","\u2879","\u287A","\u287B","\u287C","\u287D","\u287E","\u287F","\u2880","\u2881","\u2882","\u2883","\u2884","\u2885","\u2886","\u2887","\u28C0","\u28C1","\u28C2","\u28C3","\u28C4","\u28C5","\u28C6","\u28C7","\u2888","\u2889","\u288A","\u288B","\u288C","\u288D","\u288E","\u288F","\u28C8","\u28C9","\u28CA","\u28CB","\u28CC","\u28CD","\u28CE","\u28CF","\u2890","\u2891","\u2892","\u2893","\u2894","\u2895","\u2896","\u2897","\u28D0","\u28D1","\u28D2","\u28D3","\u28D4","\u28D5","\u28D6","\u28D7","\u2898","\u2899","\u289A","\u289B","\u289C","\u289D","\u289E","\u289F","\u28D8","\u28D9","\u28DA","\u28DB","\u28DC","\u28DD","\u28DE","\u28DF","\u28A0","\u28A1","\u28A2","\u28A3","\u28A4","\u28A5","\u28A6","\u28A7","\u28E0","\u28E1","\u28E2","\u28E3","\u28E4","\u28E5","\u28E6","\u28E7","\u28A8","\u28A9","\u28AA","\u28AB","\u28AC","\u28AD","\u28AE","\u28AF","\u28E8","\u28E9","\u28EA","\u28EB","\u28EC","\u28ED","\u28EE","\u28EF","\u28B0","\u28B1","\u28B2","\u28B3","\u28B4","\u28B5","\u28B6","\u28B7","\u28F0","\u28F1","\u28F2","\u28F3","\u28F4","\u28F5","\u28F6","\u28F7","\u28B8","\u28B9","\u28BA","\u28BB","\u28BC","\u28BD","\u28BE","\u28BF","\u28F8","\u28F9","\u28FA","\u28FB","\u28FC","\u28FD","\u28FE","\u28FF"]},dotsCircle:{interval:80,frames:["\u288E ","\u280E\u2801","\u280A\u2811","\u2808\u2831"," \u2871","\u2880\u2870","\u2884\u2860","\u2886\u2840"]},sand:{interval:80,frames:["\u2801","\u2802","\u2804","\u2840","\u2848","\u2850","\u2860","\u28C0","\u28C1","\u28C2","\u28C4","\u28CC","\u28D4","\u28E4","\u28E5","\u28E6","\u28EE","\u28F6","\u28F7","\u28FF","\u287F","\u283F","\u289F","\u281F","\u285B","\u281B","\u282B","\u288B","\u280B","\u280D","\u2849","\u2809","\u2811","\u2821","\u2881"]},line:{interval:130,frames:["-","\\","|","/"]},line2:{interval:100,frames:["\u2802","-","\u2013","\u2014","\u2013","-"]},rollingLine:{interval:80,frames:["/ "," - "," \\ "," |"," |"," \\ "," - ","/ "]},pipe:{interval:100,frames:["\u2524","\u2518","\u2534","\u2514","\u251C","\u250C","\u252C","\u2510"]},simpleDots:{interval:400,frames:[". ",".. ","..."," "]},simpleDotsScrolling:{interval:200,frames:[". ",".. ","..."," .."," ."," "]},star:{interval:70,frames:["\u2736","\u2738","\u2739","\u273A","\u2739","\u2737"]},star2:{interval:80,frames:["+","x","*"]},flip:{interval:70,frames:["_","_","_","-","`","`","'","\xB4","-","_","_","_"]},hamburger:{interval:100,frames:["\u2631","\u2632","\u2634"]},growVertical:{interval:120,frames:["\u2581","\u2583","\u2584","\u2585","\u2586","\u2587","\u2586","\u2585","\u2584","\u2583"]},growHorizontal:{interval:120,frames:["\u258F","\u258E","\u258D","\u258C","\u258B","\u258A","\u2589","\u258A","\u258B","\u258C","\u258D","\u258E"]},balloon:{interval:140,frames:[" ",".","o","O","@","*"," "]},balloon2:{interval:120,frames:[".","o","O","\xB0","O","o","."]},noise:{interval:100,frames:["\u2593","\u2592","\u2591"]},bounce:{interval:120,frames:["\u2801","\u2802","\u2804","\u2802"]},boxBounce:{interval:120,frames:["\u2596","\u2598","\u259D","\u2597"]},boxBounce2:{interval:100,frames:["\u258C","\u2580","\u2590","\u2584"]},triangle:{interval:50,frames:["\u25E2","\u25E3","\u25E4","\u25E5"]},binary:{interval:80,frames:["010010","001100","100101","111010","111101","010111","101011","111000","110011","110101"]},arc:{interval:100,frames:["\u25DC","\u25E0","\u25DD","\u25DE","\u25E1","\u25DF"]},circle:{interval:120,frames:["\u25E1","\u2299","\u25E0"]},squareCorners:{interval:180,frames:["\u25F0","\u25F3","\u25F2","\u25F1"]},circleQuarters:{interval:120,frames:["\u25F4","\u25F7","\u25F6","\u25F5"]},circleHalves:{interval:50,frames:["\u25D0","\u25D3","\u25D1","\u25D2"]},squish:{interval:100,frames:["\u256B","\u256A"]},toggle:{interval:250,frames:["\u22B6","\u22B7"]},toggle2:{interval:80,frames:["\u25AB","\u25AA"]},toggle3:{interval:120,frames:["\u25A1","\u25A0"]},toggle4:{interval:100,frames:["\u25A0","\u25A1","\u25AA","\u25AB"]},toggle5:{interval:100,frames:["\u25AE","\u25AF"]},toggle6:{interval:300,frames:["\u101D","\u1040"]},toggle7:{interval:80,frames:["\u29BE","\u29BF"]},toggle8:{interval:100,frames:["\u25CD","\u25CC"]},toggle9:{interval:100,frames:["\u25C9","\u25CE"]},toggle10:{interval:100,frames:["\u3282","\u3280","\u3281"]},toggle11:{interval:50,frames:["\u29C7","\u29C6"]},toggle12:{interval:120,frames:["\u2617","\u2616"]},toggle13:{interval:80,frames:["=","*","-"]},arrow:{interval:100,frames:["\u2190","\u2196","\u2191","\u2197","\u2192","\u2198","\u2193","\u2199"]},arrow2:{interval:80,frames:["\u2B06\uFE0F ","\u2197\uFE0F ","\u27A1\uFE0F ","\u2198\uFE0F ","\u2B07\uFE0F ","\u2199\uFE0F ","\u2B05\uFE0F ","\u2196\uFE0F "]},arrow3:{interval:120,frames:["\u25B9\u25B9\u25B9\u25B9\u25B9","\u25B8\u25B9\u25B9\u25B9\u25B9","\u25B9\u25B8\u25B9\u25B9\u25B9","\u25B9\u25B9\u25B8\u25B9\u25B9","\u25B9\u25B9\u25B9\u25B8\u25B9","\u25B9\u25B9\u25B9\u25B9\u25B8"]},bouncingBar:{interval:80,frames:["[ ]","[= ]","[== ]","[=== ]","[====]","[ ===]","[ ==]","[ =]","[ ]","[ =]","[ ==]","[ ===]","[====]","[=== ]","[== ]","[= ]"]},bouncingBall:{interval:80,frames:["( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF)","( \u25CF )","( \u25CF )","( \u25CF )","( \u25CF )","(\u25CF )"]},smiley:{interval:200,frames:["\uD83D\uDE04 ","\uD83D\uDE1D "]},monkey:{interval:300,frames:["\uD83D\uDE48 ","\uD83D\uDE48 ","\uD83D\uDE49 ","\uD83D\uDE4A "]},hearts:{interval:100,frames:["\uD83D\uDC9B ","\uD83D\uDC99 ","\uD83D\uDC9C ","\uD83D\uDC9A ","\uD83D\uDC97 "]},clock:{interval:100,frames:["\uD83D\uDD5B ","\uD83D\uDD50 ","\uD83D\uDD51 ","\uD83D\uDD52 ","\uD83D\uDD53 ","\uD83D\uDD54 ","\uD83D\uDD55 ","\uD83D\uDD56 ","\uD83D\uDD57 ","\uD83D\uDD58 ","\uD83D\uDD59 ","\uD83D\uDD5A "]},earth:{interval:180,frames:["\uD83C\uDF0D ","\uD83C\uDF0E ","\uD83C\uDF0F "]},material:{interval:17,frames:["\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2588","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581","\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581\u2581"]},moon:{interval:80,frames:["\uD83C\uDF11 ","\uD83C\uDF12 ","\uD83C\uDF13 ","\uD83C\uDF14 ","\uD83C\uDF15 ","\uD83C\uDF16 ","\uD83C\uDF17 ","\uD83C\uDF18 "]},runner:{interval:140,frames:["\uD83D\uDEB6 ","\uD83C\uDFC3 "]},pong:{interval:80,frames:["\u2590\u2802 \u258C","\u2590\u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802\u258C","\u2590 \u2820\u258C","\u2590 \u2840\u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590 \u2820 \u258C","\u2590 \u2802 \u258C","\u2590 \u2808 \u258C","\u2590 \u2802 \u258C","\u2590 \u2820 \u258C","\u2590 \u2840 \u258C","\u2590\u2820 \u258C"]},shark:{interval:120,frames:["\u2590|\\____________\u258C","\u2590_|\\___________\u258C","\u2590__|\\__________\u258C","\u2590___|\\_________\u258C","\u2590____|\\________\u258C","\u2590_____|\\_______\u258C","\u2590______|\\______\u258C","\u2590_______|\\_____\u258C","\u2590________|\\____\u258C","\u2590_________|\\___\u258C","\u2590__________|\\__\u258C","\u2590___________|\\_\u258C","\u2590____________|\\\u258C","\u2590____________/|\u258C","\u2590___________/|_\u258C","\u2590__________/|__\u258C","\u2590_________/|___\u258C","\u2590________/|____\u258C","\u2590_______/|_____\u258C","\u2590______/|______\u258C","\u2590_____/|_______\u258C","\u2590____/|________\u258C","\u2590___/|_________\u258C","\u2590__/|__________\u258C","\u2590_/|___________\u258C","\u2590/|____________\u258C"]},dqpb:{interval:100,frames:["d","q","p","b"]},weather:{interval:100,frames:["\u2600\uFE0F ","\u2600\uFE0F ","\u2600\uFE0F ","\uD83C\uDF24 ","\u26C5\uFE0F ","\uD83C\uDF25 ","\u2601\uFE0F ","\uD83C\uDF27 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\u26C8 ","\uD83C\uDF28 ","\uD83C\uDF27 ","\uD83C\uDF28 ","\u2601\uFE0F ","\uD83C\uDF25 ","\u26C5\uFE0F ","\uD83C\uDF24 ","\u2600\uFE0F ","\u2600\uFE0F "]},christmas:{interval:400,frames:["\uD83C\uDF32","\uD83C\uDF84"]},grenade:{interval:80,frames:["\u060C ","\u2032 "," \xB4 "," \u203E "," \u2E0C"," \u2E0A"," |"," \u204E"," \u2055"," \u0DF4 "," \u2053"," "," "," "]},point:{interval:125,frames:["\u2219\u2219\u2219","\u25CF\u2219\u2219","\u2219\u25CF\u2219","\u2219\u2219\u25CF","\u2219\u2219\u2219"]},layer:{interval:150,frames:["-","=","\u2261"]},betaWave:{interval:80,frames:["\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1\u03B2","\u03B2\u03B2\u03B2\u03B2\u03B2\u03B2\u03C1"]},fingerDance:{interval:160,frames:["\uD83E\uDD18 ","\uD83E\uDD1F ","\uD83D\uDD96 ","\u270B ","\uD83E\uDD1A ","\uD83D\uDC46 "]},fistBump:{interval:80,frames:["\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\uD83E\uDD1C\u3000\u3000\u3000\u3000\uD83E\uDD1B ","\u3000\uD83E\uDD1C\u3000\u3000\uD83E\uDD1B\u3000 ","\u3000\u3000\uD83E\uDD1C\uD83E\uDD1B\u3000\u3000 ","\u3000\uD83E\uDD1C\u2728\uD83E\uDD1B\u3000\u3000 ","\uD83E\uDD1C\u3000\u2728\u3000\uD83E\uDD1B\u3000 "]},soccerHeader:{interval:80,frames:[" \uD83E\uDDD1\u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F\uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 ","\uD83E\uDDD1 \u26BD\uFE0F \uD83E\uDDD1 "]},mindblown:{interval:160,frames:["\uD83D\uDE10 ","\uD83D\uDE10 ","\uD83D\uDE2E ","\uD83D\uDE2E ","\uD83D\uDE26 ","\uD83D\uDE26 ","\uD83D\uDE27 ","\uD83D\uDE27 ","\uD83E\uDD2F ","\uD83D\uDCA5 ","\u2728 ","\u3000 ","\u3000 ","\u3000 "]},speaker:{interval:160,frames:["\uD83D\uDD08 ","\uD83D\uDD09 ","\uD83D\uDD0A ","\uD83D\uDD09 "]},orangePulse:{interval:100,frames:["\uD83D\uDD38 ","\uD83D\uDD36 ","\uD83D\uDFE0 ","\uD83D\uDFE0 ","\uD83D\uDD36 "]},bluePulse:{interval:100,frames:["\uD83D\uDD39 ","\uD83D\uDD37 ","\uD83D\uDD35 ","\uD83D\uDD35 ","\uD83D\uDD37 "]},orangeBluePulse:{interval:100,frames:["\uD83D\uDD38 ","\uD83D\uDD36 ","\uD83D\uDFE0 ","\uD83D\uDFE0 ","\uD83D\uDD36 ","\uD83D\uDD39 ","\uD83D\uDD37 ","\uD83D\uDD35 ","\uD83D\uDD35 ","\uD83D\uDD37 "]},timeTravel:{interval:100,frames:["\uD83D\uDD5B ","\uD83D\uDD5A ","\uD83D\uDD59 ","\uD83D\uDD58 ","\uD83D\uDD57 ","\uD83D\uDD56 ","\uD83D\uDD55 ","\uD83D\uDD54 ","\uD83D\uDD53 ","\uD83D\uDD52 ","\uD83D\uDD51 ","\uD83D\uDD50 "]},aesthetic:{interval:80,frames:["\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B1","\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0\u25B0","\u25B0\u25B1\u25B1\u25B1\u25B1\u25B1\u25B1"]},dwarfFortress:{interval:80,frames:[" \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A\u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 ","\u263A \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\u2588\xA3\xA3\xA3 "," \u263A \u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2588\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2593\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2592\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A\u2591\u2588\xA3\xA3\xA3 "," \u263A \u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2588\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2592\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A\u2591\xA3\xA3\xA3 "," \u263A \xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\xA3\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2593\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2592\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A\u2591\xA3\xA3 "," \u263A \xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\xA3\xA3 "," \u263A\u2593\xA3 "," \u263A\u2593\xA3 "," \u263A\u2592\xA3 "," \u263A\u2592\xA3 "," \u263A\u2591\xA3 "," \u263A\u2591\xA3 "," \u263A \xA3 "," \u263A\xA3 "," \u263A\xA3 "," \u263A\u2593 "," \u263A\u2593 "," \u263A\u2592 "," \u263A\u2592 "," \u263A\u2591 "," \u263A\u2591 "," \u263A "," \u263A &"," \u263A \u263C&"," \u263A \u263C &"," \u263A\u263C &"," \u263A\u263C & "," \u203C & "," \u263A & "," \u203C & "," \u263A & "," \u203C & "," \u263A & ","\u203C & "," & "," & "," & \u2591 "," & \u2592 "," & \u2593 "," & \xA3 "," & \u2591\xA3 "," & \u2592\xA3 "," & \u2593\xA3 "," & \xA3\xA3 "," & \u2591\xA3\xA3 "," & \u2592\xA3\xA3 ","& \u2593\xA3\xA3 ","& \xA3\xA3\xA3 "," \u2591\xA3\xA3\xA3 "," \u2592\xA3\xA3\xA3 "," \u2593\xA3\xA3\xA3 "," \u2588\xA3\xA3\xA3 "," \u2591\u2588\xA3\xA3\xA3 "," \u2592\u2588\xA3\xA3\xA3 "," \u2593\u2588\xA3\xA3\xA3 "," \u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2591\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2592\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2593\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "," \u2588\u2588\u2588\u2588\u2588\u2588\xA3\xA3\xA3 "]},fish:{interval:80,frames:["~~~~~~~~~~~~~~~~~~~~","> ~~~~~~~~~~~~~~~~~~","\xBA> ~~~~~~~~~~~~~~~~~","(\xBA> ~~~~~~~~~~~~~~~~","((\xBA> ~~~~~~~~~~~~~~~","<((\xBA> ~~~~~~~~~~~~~~","><((\xBA> ~~~~~~~~~~~~~"," ><((\xBA> ~~~~~~~~~~~~","~ ><((\xBA> ~~~~~~~~~~~","~~ <>((\xBA> ~~~~~~~~~~","~~~ ><((\xBA> ~~~~~~~~~","~~~~ <>((\xBA> ~~~~~~~~","~~~~~ ><((\xBA> ~~~~~~~","~~~~~~ <>((\xBA> ~~~~~~","~~~~~~~ ><((\xBA> ~~~~~","~~~~~~~~ <>((\xBA> ~~~~","~~~~~~~~~ ><((\xBA> ~~~","~~~~~~~~~~ <>((\xBA> ~~","~~~~~~~~~~~ ><((\xBA> ~","~~~~~~~~~~~~ <>((\xBA> ","~~~~~~~~~~~~~ ><((\xBA>","~~~~~~~~~~~~~~ <>((\xBA","~~~~~~~~~~~~~~~ ><((","~~~~~~~~~~~~~~~~ <>(","~~~~~~~~~~~~~~~~~ ><","~~~~~~~~~~~~~~~~~~ <","~~~~~~~~~~~~~~~~~~~~"]}}});var Yo,aC9;var ak1=k(()=>{pk1();Yo=qp0,aC9=Object.keys(qp0)});var rk1;var ok1=k(async()=>{ak1();await D8();rk1=class extends d8{_name;_frames;_interval;_autoplay;_backgroundColor;_color;_currentFrameIndex=0;_encodedFrames={};_lib=tg();_intervalId=null;_defaultOptions={name:"dots",frames:Yo.dots.frames,interval:Yo.dots.interval,autoplay:!0,backgroundColor:"transparent",color:"white"};constructor(A,u){super(A,u),this._name=u.name,this._frames=this._name?Yo[this._name].frames:u.frames??this._defaultOptions.frames,this._interval=this._name?Yo[this._name].interval:u.interval??this._defaultOptions.interval,this._autoplay=u.autoplay??this._defaultOptions.autoplay,this._backgroundColor=u.backgroundColor??this._defaultOptions.backgroundColor,this._color=u.color??this._defaultOptions.color,this.width=Math.max(...this._frames.map((q)=>q.length)),this.height=1,this._encodeFrames(),this._autoplay&&this.start()}_encodeFrames(){for(let A of this._frames){let u=this._lib.encodeUnicode(A,this.ctx.widthMethod);u&&(this._encodedFrames[A]=u)}}_freeFrames(){for(let A in this._encodedFrames)this._encodedFrames[A]&&this._lib.freeUnicode(this._encodedFrames[A]);this._encodedFrames={}}get interval(){return this._interval}set interval(A){this.stop(),this._interval=A,this.start()}get name(){return this._name}set name(A){this._freeFrames(),this._name=A,this._frames=this._name?Yo[this._name].frames:this._defaultOptions.frames,this._interval=this._name?Yo[this._name].interval:this._defaultOptions.interval,this.width=Math.max(...this._frames.map((u)=>u.length)),this._encodeFrames(),this.requestRender()}get frames(){return this._frames}set frames(A){this._freeFrames(),this._frames=A.length===0?this._defaultOptions.frames:A,this._encodeFrames(),this.width=Math.max(...this._frames.map((u)=>u.length)),this.requestRender()}get color(){return this._color}set color(A){this._color=A,this.requestRender()}get backgroundColor(){return this._backgroundColor}set backgroundColor(A){this._backgroundColor=A,this.requestRender()}start(){this._intervalId||=setInterval(()=>{this._currentFrameIndex=(this._currentFrameIndex+1)%this._frames.length,this.requestRender()},this._interval)}stop(){this._intervalId&&=(clearInterval(this._intervalId),null)}renderSelf(A){if(!this.visible)return;let u=this._frames[this._currentFrameIndex];if(!u)return;let q=this._encodedFrames[u];if(!q)return;let F=this.x;for(let G=0;G<q.data.length;G++){let w=typeof this._color=="function"?this._color(this._currentFrameIndex,G,this._frames.length,q.data.length):this._color;A.drawChar(q.data[G].char,F,this.y,l0(w),l0(this._backgroundColor)),F+=q.data[G].width}}destroySelf(){this.stop(),this._freeFrames(),super.destroySelf()}}});var Fp0=k(async()=>{await N0([ok1(),IA()]);NfA({spinner:rk1})});function t$(A){let{theme:u}=V2(),q=h$(),F=()=>A.color??u.textMuted;return QA(X0,{get when(){return q.get("animations_enabled",!0)},get fallback(){return(()=>{var G=o("text"),w=mA("\u22EF ");return wA(G,w),VA(G,()=>A.children,null),SA((g)=>P(G,"fg",F(),g)),G})()},get children(){var G=o("box"),w=o("spinner");return wA(G,w),P(G,"flexDirection","row"),P(G,"gap",1),P(w,"frames",wS3),P(w,"interval",80),VA(G,QA(X0,{get when(){return A.children},get children(){var g=o("text");return VA(g,()=>A.children),SA((Q)=>P(g,"fg",F(),Q)),g}}),null),SA((g)=>P(w,"color",F(),g)),G}})}var wS3;var x8A=k(async()=>{U6();await N0([IA(),IA(),IA(),IA(),IA(),IA(),IA(),F8(),Oo(),Fp0()]);wS3=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"]});function GV(A){let u=Ju(),{theme:q}=V2(),F;return G4((G)=>{if(A.busy){if(G.name==="escape")return;G.preventDefault(),G.stopPropagation();return}if(G.name==="return")G.preventDefault(),G.stopPropagation(),A.onConfirm?.(F.plainText)}),b5(()=>{u.setSize("medium"),setTimeout(()=>{if(!F||F.isDestroyed)return;if(A.busy)return;F.focus()},1),F.gotoLineEnd()}),B4(()=>{if(!F||F.isDestroyed)return;let G=A.busy?{suspend:!0,status:"BUSY"}:{};if(F.traits=G,A.busy){F.blur();return}F.focus()}),(()=>{var G=o("box"),w=o("box"),g=o("text"),Q=o("text"),j=o("box"),K=o("textarea"),U=o("box");return wA(G,w),wA(G,j),wA(G,U),P(G,"paddingLeft",2),P(G,"paddingRight",2),P(G,"gap",1),wA(w,g),wA(w,Q),P(w,"flexDirection","row"),P(w,"justifyContent","space-between"),VA(g,()=>A.title),wA(Q,mA("esc")),P(Q,"onMouseUp",()=>u.clear()),wA(j,K),P(j,"gap",1),VA(j,()=>A.description,K),vg((_)=>{F=_},K),P(K,"onSubmit",()=>{if(A.busy)return;A.onConfirm?.(F.plainText)}),P(K,"height",3),VA(j,QA(X0,{get when(){return A.busy},get children(){return QA(t$,{get color(){return q.textMuted},get children(){return A.busyText??"Working..."}})}}),null),P(U,"paddingBottom",1),P(U,"gap",1),P(U,"flexDirection","row"),VA(U,QA(X0,{get when(){return!A.busy},get fallback(){return(()=>{var _=o("text");return wA(_,mA("processing...")),SA((O)=>P(_,"fg",q.textMuted,O)),_})()},get children(){var _=o("text"),O=mA("enter "),W=o("span");return wA(_,O),wA(_,W),wA(W,mA("submit")),SA((X)=>{var Y=q.text,V={fg:q.textMuted};return Y!==X.e&&(X.e=P(_,"fg",Y,X.e)),V!==X.t&&(X.t=P(W,"style",V,X.t)),X},{e:void 0,t:void 0}),_}})),SA((_)=>{var O=z6.BOLD,W=q.accent,X=q.textMuted,Y=A.busy?[]:[{name:"return",action:"submit"}],V=A.value,Z=A.placeholder??"Enter text",H=q.textMuted,N=A.busy?q.textMuted:q.text,B=A.busy?q.textMuted:q.text,M=A.busy?q.backgroundElement:q.text;return O!==_.e&&(_.e=P(g,"attributes",O,_.e)),W!==_.t&&(_.t=P(g,"fg",W,_.t)),X!==_.a&&(_.a=P(Q,"fg",X,_.a)),Y!==_.o&&(_.o=P(K,"keyBindings",Y,_.o)),V!==_.i&&(_.i=P(K,"initialValue",V,_.i)),Z!==_.n&&(_.n=P(K,"placeholder",Z,_.n)),H!==_.s&&(_.s=P(K,"placeholderColor",H,_.s)),N!==_.h&&(_.h=P(K,"textColor",N,_.h)),B!==_.r&&(_.r=P(K,"focusedTextColor",B,_.r)),M!==_.d&&(_.d=P(K,"cursorColor",M,_.d)),_},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),G})()}var MHA=k(async()=>{U6();await N0([IA(),IA(),IA(),IA(),IA(),IA(),IA(),IA(),IA(),IA(),D8(),F8(),_7(),IA(),x8A()]);GV.show=(A,u,q)=>{return new Promise((F)=>{A.replace(()=>QA(GV,JY({title:u},q,{onConfirm:(G)=>F(G),onCancel:()=>F(null)})),()=>F(null))})}});function wV(A,u,q){let F=(G)=>Object.defineProperty(A,u,{value:G,enumerable:!0,writable:!0});return Object.defineProperty(A,u,{configurable:!0,enumerable:!0,get(){let G=q();return F(G),G},set(G){F(G)}}),A}import{promisify as gS3}from"util";import QS3 from"process";import{execFile as jS3}from"child_process";async function Gp0(){if(QS3.platform!=="darwin")throw Error("macOS only");let{stdout:A}=await KS3("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),q=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(A)?.groups.id??"com.apple.Safari";if(q==="com.apple.safari")return"com.apple.Safari";return q}var KS3;var sk1=k(()=>{KS3=gS3(jS3)});import US3 from"process";import{promisify as _S3}from"util";import{execFile as JS3,execFileSync as tf9}from"child_process";async function ek1(A,{humanReadableOutput:u=!0,signal:q}={}){if(US3.platform!=="darwin")throw Error("macOS only");let F=u?[]:["-ss"],G={};if(q)G.signal=q;let{stdout:w}=await OS3("osascript",["-e",A,F],G);return w.trim()}var OS3;var AS1=k(()=>{OS3=_S3(JS3)});async function wp0(A){return ek1(`tell application "Finder" to set app_path to application file id "${A}" as string
|
|
742
|
-
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var uS1=k(()=>{AS1()});import{promisify as WS3}from"util";import{execFile as XS3}from"child_process";async function gp0(A=YS3){let{stdout:u}=await A("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),q=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(u);if(!q)throw new qS1(`Cannot find Windows browser in stdout: ${JSON.stringify(u)}`);let{id:F}=q.groups,G=F.lastIndexOf("."),w=F.lastIndexOf("-"),g=G===-1?void 0:F.slice(0,G),Q=w===-1?void 0:F.slice(0,w);return lrA[F]??lrA[g]??lrA[Q]??{name:F,id:F}}var YS3,lrA,df9,qS1;var FS1=k(()=>{YS3=WS3(XS3),lrA={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},df9=new Map(Object.entries(lrA));qS1=class qS1 extends Error{}});import{promisify as VS3}from"util";import Qp0 from"process";import{execFile as ZS3}from"child_process";async function LHA(){if(Qp0.platform==="darwin"){let A=await Gp0();return{name:await wp0(A),id:A}}if(Qp0.platform==="linux"){let{stdout:A}=await HS3("xdg-mime",["query","default","x-scheme-handler/http"]),u=A.trim();return{name:NS3(u.replace(/.desktop$/,"").replace("-"," ")),id:u}}if(Qp0.platform==="win32")return gp0();throw Error("Only macOS, Linux, and Windows are supported")}var HS3,NS3=(A)=>A.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,(u)=>u.toUpperCase());var jp0=k(()=>{sk1();uS1();FS1();HS3=VS3(ZS3)});import EHA from"process";import{Buffer as jS1}from"buffer";import KS1 from"path";import{fileURLToPath as BS3}from"url";import $S3 from"util";import US1 from"child_process";import Kp0,{constants as _S1}from"fs/promises";async function ES3(){let A=await JS1(),u='(Get-ItemProperty -Path "HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice").ProgId',q=jS1.from('(Get-ItemProperty -Path "HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice").ProgId',"utf16le").toString("base64"),{stdout:F}=await MS3(A,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",q],{encoding:"utf8"}),G=F.trim(),w={ChromeHTML:"com.google.chrome",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return w[G]?{id:w[G]}:{}}function QS1(A){if(typeof A==="string"||Array.isArray(A))return A;let{[wS1]:u}=A;if(!u)throw Error(`${wS1} is not supported`);return u}function _p0({[z8A]:A},{wsl:u}){if(u&&qO)return QS1(u);if(!A)throw Error(`${z8A} is not supported`);return QS1(A)}var MS3,Up0,GS1,z8A,wS1,LS3,JS1=async()=>{return`${await LS3()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},gS1=async(A,u)=>{let q;for(let F of A)try{return await u(F)}catch(G){q=G}throw q},irA=async(A)=>{if(A={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...A},Array.isArray(A.app))return gS1(A.app,(Q)=>irA({...A,app:Q}));let{name:u,arguments:q=[]}=A.app??{};if(q=[...q],Array.isArray(u))return gS1(u,(Q)=>irA({...A,app:{name:Q,arguments:q}}));if(u==="browser"||u==="browserPrivate"){let Q={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},j={chrome:"--incognito",firefox:"--private-window",edge:"--inPrivate"},K=qO?await ES3():await LHA();if(K.id in Q){let U=Q[K.id];if(u==="browserPrivate")q.push(j[U]);return irA({...A,app:{name:R8A[U],arguments:q}})}throw Error(`${K.name} is not supported as a default browser`)}let F,G=[],w={};if(z8A==="darwin"){if(F="open",A.wait)G.push("--wait-apps");if(A.background)G.push("--background");if(A.newInstance)G.push("--new");if(u)G.push("-a",u)}else if(z8A==="win32"||qO&&!YC()&&!u){if(F=qO?await JS1():`${EHA.env.SYSTEMROOT||EHA.env.windir||"C:\\Windows"}\\System32\\WindowsPowerShell\\v1.0\\powershell`,G.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),!qO)w.windowsVerbatimArguments=!0;let Q=["Start"];if(A.wait)Q.push("-Wait");if(u){if(Q.push(`"\`"${u}\`""`),A.target)q.push(A.target)}else if(A.target)Q.push(`"${A.target}"`);if(q.length>0)q=q.map((j)=>`"\`"${j}\`""`),Q.push("-ArgumentList",q.join(","));A.target=jS1.from(Q.join(" "),"utf16le").toString("base64")}else{if(u)F=u;else{let Q=!Up0||Up0==="/",j=!1;try{await Kp0.access(GS1,_S1.X_OK),j=!0}catch{}F=EHA.versions.electron??(z8A==="android"||Q||!j)?"xdg-open":GS1}if(q.length>0)G.push(...q);if(!A.wait)w.stdio="ignore",w.detached=!0}if(z8A==="darwin"&&q.length>0)G.push("--args",...q);if(A.target)G.push(A.target);let g=US1.spawn(F,G,w);if(A.wait)return new Promise((Q,j)=>{g.once("error",j),g.once("close",(K)=>{if(!A.allowNonzeroExitCode&&K>0){j(Error(`Exited with code ${K}`));return}Q(g)})});return g.unref(),g},xS3=(A,u)=>{if(typeof A!=="string")throw TypeError("Expected a `target`");return irA({...u,target:A})},R8A,Hv;var xHA=k(()=>{uHA();jp0();maA();MS3=$S3.promisify(US1.execFile),Up0=KS1.dirname(BS3(import.meta.url)),GS1=KS1.join(Up0,"xdg-open"),{platform:z8A,arch:wS1}=EHA,LS3=(()=>{let u;return async function(){if(u)return u;let q="/etc/wsl.conf",F=!1;try{await Kp0.access(q,_S1.F_OK),F=!0}catch{}if(!F)return"/mnt/";let G=await Kp0.readFile(q,{encoding:"utf8"}),w=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(G);if(!w)return"/mnt/";return u=w.groups.mountPoint.trim(),u=u.endsWith("/")?u:`${u}/`,u}})();R8A={};wV(R8A,"chrome",()=>_p0({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));wV(R8A,"firefox",()=>_p0({darwin:"firefox",win32:"C:\\Program Files\\Mozilla Firefox\\firefox.exe",linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));wV(R8A,"edge",()=>_p0({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));wV(R8A,"browser",()=>"browser");wV(R8A,"browserPrivate",()=>"browserPrivate");Hv=xS3});function Jp0(A){let u=A.children??A.href;return(()=>{var q=o("text");return P(q,"onMouseUp",()=>{Hv(A.href).catch(()=>{})}),VA(q,u),SA((F)=>P(q,"fg",A.fg,F)),q})()}var OS1=k(async()=>{xHA();await N0([IA(),IA(),IA(),IA()])});function S7(A){return A()}import zS3 from"path";function WS1(A){let[u,...q]=A.split("/");return{providerID:u,modelID:q.join("/")}}var XQ,XS1;var ZP=k(async()=>{iF();U6();rw();uO();await N0([OU(),WQ(),F8(),P3(),Xx(),L8A(),Wg(),D8()]);({use:XQ,provider:XS1}=Wq({name:"Local",init:()=>{let A=V4(),u=k4(),q=Aj();function F(K){return!!A.data.provider.find((_)=>_.id===K.providerID)?.models[K.modelID]}function G(...K){for(let U of K){let _=U();if(!_)continue;if(F(_))return _}}let w=S7(()=>{let K=yA(()=>A.data.agent.filter((Y)=>Y.mode!=="subagent"&&!Y.hidden)),U=yA(()=>A.data.agent.filter((Y)=>!Y.hidden)),[_,O]=F4({current:void 0}),{theme:W}=V2(),X=yA(()=>[W.secondary,W.accent,W.success,W.warning,W.primary,W.error,W.info]);return{list(){return K()},current(){return K().find((Y)=>Y.name===_.current)??K().at(0)},set(Y){if(!K().some((V)=>V.name===Y))return q.show({variant:"warning",message:`Agent not found: ${Y}`,duration:3000});O("current",Y)},move(Y){N7(()=>{let V=this.current();if(!V)return;let Z=K().findIndex((N)=>N.name===V.name)+Y;if(Z<0)Z=K().length-1;if(Z>=K().length)Z=0;let H=K()[Z];O("current",H.name)})},color(Y){let V=U().findIndex((H)=>H.name===Y);if(V===-1)return X()[0];let Z=U()[V];if(Z?.color){let H=Z.color;if(H.startsWith("#"))return m2.fromHex(H);return W[H]}return X()[V%X().length]}}}),g=S7(()=>{let[K,U]=F4({ready:!1,model:{},recent:[],favorite:[],variant:{}}),_=zS3.join(U2.Path.state,"model.json"),O={pending:!1};function W(){if(!K.ready){O.pending=!0;return}O.pending=!1,M5.writeJson(_,{recent:K.recent,favorite:K.favorite,variant:K.variant})}M5.readJson(_).then((Z)=>{if(Array.isArray(Z.recent))U("recent",Z.recent);if(Array.isArray(Z.favorite))U("favorite",Z.favorite);if(typeof Z.variant==="object"&&Z.variant!==null)U("variant",Z.variant)}).catch(()=>{}).finally(()=>{if(U("ready",!0),O.pending)W()});let X=VP(),Y=yA(()=>{if(X.model){let{providerID:M,modelID:x}=WS1(X.model);if(F({providerID:M,modelID:x}))return{providerID:M,modelID:x}}if(A.data.config.model){let{providerID:M,modelID:x}=WS1(A.data.config.model);if(F({providerID:M,modelID:x}))return{providerID:M,modelID:x}}for(let M of K.recent)if(F(M))return M;let Z=A.data.provider[0];if(!Z)return;let H=A.data.provider_default[Z.id],N=Object.values(Z.models)[0],B=H??N?.id;if(!B)return;return{providerID:Z.id,modelID:B}}),V=yA(()=>{let Z=w.current();return G(()=>Z&&K.model[Z.name],()=>Z&&Z.model,Y)??void 0});return{current:V,get ready(){return K.ready},recent(){return K.recent},favorite(){return K.favorite},parsed:yA(()=>{let Z=V();if(!Z)return{provider:"Connect a provider",model:"No provider selected",reasoning:!1};let H=A.data.provider.find((B)=>B.id===Z.providerID),N=H?.models[Z.modelID];return{provider:H?.name??Z.providerID,model:N?.name??Z.modelID,reasoning:N?.capabilities?.reasoning??!1}}),cycle(Z){let H=V();if(!H)return;let N=K.recent,B=N.findIndex((E)=>E.providerID===H.providerID&&E.modelID===H.modelID);if(B===-1)return;let M=B+Z;if(M<0)M=N.length-1;if(M>=N.length)M=0;let x=N[M];if(!x)return;let $=w.current();if(!$)return;U("model",$.name,{...x})},cycleFavorite(Z){let H=K.favorite.filter((E)=>F(E));if(!H.length){q.show({variant:"info",message:"Add a favorite model to use this shortcut",duration:3000});return}let N=V(),B=-1;if(N)B=H.findIndex((E)=>E.providerID===N.providerID&&E.modelID===N.modelID);if(B===-1)B=Z===1?0:H.length-1;else{if(B+=Z,B<0)B=H.length-1;if(B>=H.length)B=0}let M=H[B];if(!M)return;let x=w.current();if(!x)return;U("model",x.name,{...M});let $=ntA([M,...K.recent],(E)=>`${E.providerID}/${E.modelID}`);if($.length>10)$.pop();U("recent",$.map((E)=>({providerID:E.providerID,modelID:E.modelID}))),W()},set(Z,H){N7(()=>{if(!F(Z)){q.show({message:`Model ${Z.providerID}/${Z.modelID} is not valid`,variant:"warning",duration:3000});return}let N=w.current();if(!N)return;if(U("model",N.name,Z),H?.recent){let B=ntA([Z,...K.recent],(M)=>`${M.providerID}/${M.modelID}`);if(B.length>10)B.pop();U("recent",B.map((M)=>({providerID:M.providerID,modelID:M.modelID}))),W()}})},toggleFavorite(Z){N7(()=>{if(!F(Z)){q.show({message:`Model ${Z.providerID}/${Z.modelID} is not valid`,variant:"warning",duration:3000});return}let N=K.favorite.some((B)=>B.providerID===Z.providerID&&B.modelID===Z.modelID)?K.favorite.filter((B)=>B.providerID!==Z.providerID||B.modelID!==Z.modelID):[Z,...K.favorite];U("favorite",N.map((B)=>({providerID:B.providerID,modelID:B.modelID}))),W()})},variant:{selected(){let Z=V();if(!Z)return;let H=`${Z.providerID}/${Z.modelID}`;return K.variant[H]},current(){let Z=this.selected();if(!Z)return;if(!this.list().includes(Z))return;return Z},list(){let Z=V();if(!Z)return[];let N=A.data.provider.find((B)=>B.id===Z.providerID)?.models[Z.modelID];if(!N?.variants)return[];return Object.keys(N.variants)},set(Z){let H=V();if(!H)return;let N=`${H.providerID}/${H.modelID}`;U("variant",N,Z??"default"),W()},cycle(){let Z=this.list();if(Z.length===0)return;let H=this.current();if(!H){this.set(Z[0]);return}let N=Z.indexOf(H);if(N===-1||N===Z.length-1){this.set(void 0);return}this.set(Z[N+1])}}}}),Q={isEnabled(K){return A.data.mcp[K]?.status==="connected"},async toggle(K){if(A.data.mcp[K]?.status==="connected")await u.client.mcp.disconnect({name:K});else await u.client.mcp.connect({name:K})}};return B4(()=>{let K=w.current();if(!K)return;if(K.model)if(F(K.model))g.set({providerID:K.model.providerID,modelID:K.model.modelID});else q.show({variant:"warning",message:`Agent ${K.name}'s configured model ${K.model.providerID}/${K.model.modelID} is not valid`,duration:3000})}),{model:g,agent:w,mcp:Q}}}))});function crA(){let A=XQ(),u=Ju(),q=yA(()=>{return[{value:"default",title:"Default",onSelect:()=>{u.clear(),A.model.variant.set(void 0)}},...A.model.variant.list().map((F)=>({value:F,title:F,onSelect:()=>{u.clear(),A.model.variant.set(F)}}))]});return QA(I3,{get options(){return q()},title:"Select variant",get current(){return A.model.variant.selected()},flat:!0})}var Op0=k(async()=>{U6();await N0([IA(),ZP(),oj(),_7()])});function D8A(){let A=V4();return yA(()=>A.data.provider.some((u)=>u.id!=="opencode"||Object.values(u.models).some((q)=>q.cost?.input!==0)))}var drA=k(async()=>{U6();await WQ()});function P8A(A){let u=XQ(),q=V4(),F=Ju(),G=A9(),[w,g]=g2(""),Q=D8A(),j=Yp0(),K=yA(()=>Q()&&!A.providerID),U=yA(()=>{let X=w().trim(),Y=K()&&X.length===0,V=Q()?u.model.favorite():[],Z=u.model.recent();function H($,E){if(!Y)return[];return $.flatMap((z)=>{let T=q.data.provider.find((C)=>C.id===z.providerID);if(!T)return[];let D=T.models[z.modelID];if(!D)return[];return[{key:z,value:{providerID:T.id,modelID:D.id},title:D.name??z.modelID,description:T.name,category:E,disabled:T.id==="opencode"&&D.id.includes("-nano"),footer:D.cost?.input===0&&T.id==="opencode"?"Free":void 0,onSelect:()=>{W(T.id,D.id)}}]})}let N=H(V,"Favorites"),B=H(Z.filter(($)=>!V.some((E)=>E.providerID===$.providerID&&E.modelID===$.modelID)),"Recent"),M=nF(q.data.provider,TW(($)=>$.id!=="opencode",($)=>$.name),uOA(($)=>nF($.models,kp(),yk(([E,z])=>z.status!=="deprecated"),yk(([E,z])=>A.providerID?z.providerID===A.providerID:!0),Et(([E,z])=>({value:{providerID:$.id,modelID:E},title:z.name??E,description:V.some((T)=>T.providerID===$.id&&T.modelID===E)?"(Favorite)":void 0,category:Q()?$.name:void 0,disabled:$.id==="opencode"&&E.includes("-nano"),footer:z.cost?.input===0&&$.id==="opencode"?"Free":void 0,onSelect(){W($.id,E)}})),yk((E)=>{if(!Y)return!0;if(V.some((z)=>z.providerID===E.value.providerID&&z.modelID===E.value.modelID))return!1;if(Z.some((z)=>z.providerID===E.value.providerID&&z.modelID===E.value.modelID))return!1;return!0}),TW((E)=>E.footer!=="Free",(E)=>E.title)))),x=!Q()?nF(j(),Et(($)=>({...$,category:"Popular providers"})),kL0(6)):[];if(X)return[...Wp0.go(X,M,{keys:["title","category"]}).map(($)=>$.obj),...Wp0.go(X,x,{keys:["title"]}).map(($)=>$.obj)];return[...N,...B,...M,...x]}),_=yA(()=>A.providerID?q.data.provider.find((X)=>X.id===A.providerID):null),O=yA(()=>{let X=_();if(!X)return"Select model";return X.name});function W(X,Y){u.model.set({providerID:X,modelID:Y},{recent:!0});let V=u.model.variant.list(),Z=u.model.variant.selected();if(Z==="default"||Z&&V.includes(Z)){F.clear();return}if(V.length>0){F.replace(()=>QA(crA,{}));return}F.clear()}return QA(I3,{get options(){return U()},get keybind(){return[{keybind:G.all.model_provider_list?.[0],title:Q()?"Connect provider":"View all providers",onTrigger(){F.replace(()=>QA(Vo,{}))}},{keybind:G.all.model_favorite_toggle?.[0],title:"Favorite",disabled:!Q(),onTrigger:(X)=>{u.model.toggleFavorite(X.value)}}]},onFilter:g,flat:!0,skipFilter:!0,get title(){return O()},get current(){return u.model.current()}})}var Wp0;var Xp0=k(async()=>{U6();rw();await N0([IA(),ZP(),WQ(),oj(),_7(),nrA(),Op0(),qV(),drA()]);Wp0=u2(E8A(),1)});var RS3=(A,u)=>Array.isArray(A)?A.includes(u):A.has(u),YS1=(A,u)=>RS3(A,u);function Yp0(){let A=V4(),u=Ju(),q=k4(),F=Aj(),{theme:G}=V2(),w=D8A();return yA(()=>{return nF(A.data.provider_next.all,yk((Q)=>Q.id!=="opencode"),TW((Q)=>VS1[Q.id]??99),Et((Q)=>{let j=YS1(A.data.console_state.consoleManagedProviders,Q.id),K=A.data.provider_next.connected.includes(Q.id);return{title:Q.name,value:Q.id,description:{anthropic:"(API key)",openai:"(ChatGPT Plus/Pro or API key)"}[Q.id],footer:j?A.data.console_state.activeOrgName:void 0,category:Q.id in VS1?"Popular":"Other",gutter:K&&w()?()=>(()=>{var U=o("text");return wA(U,mA("\u2713")),SA((_)=>P(U,"fg",G.success,_)),U})():void 0,async onSelect(){if(j)return;let U=A.data.provider_auth[Q.id]??[{type:"api",label:"API key"}],_=0;if(U.length>1)_=await new Promise((W)=>{u.replace(()=>QA(I3,{title:"Select auth method",get options(){return U.map((X,Y)=>({title:X.label,value:Y}))},onSelect:(X)=>W(X.value)}),()=>W(null))});if(_==null)return;let O=U[_];if(O.type==="oauth"){let W;if(O.prompts?.length){let Y=await ZS1({dialog:u,prompts:O.prompts});if(!Y)return;W=Y}let X=await q.client.provider.oauth.authorize({providerID:Q.id,method:_,inputs:W});if(X.error){F.show({variant:"error",message:JSON.stringify(X.error)}),u.clear();return}if(X.data?.method==="code")u.replace(()=>QA(PS3,{get providerID(){return Q.id},get title(){return O.label},index:_,get authorization(){return X.data}}));if(X.data?.method==="auto")u.replace(()=>QA(DS3,{get providerID(){return Q.id},get title(){return O.label},index:_,get authorization(){return X.data}}))}if(O.type==="api"){let W;if(O.prompts?.length){let X=await ZS1({dialog:u,prompts:O.prompts});if(!X)return;W=X}return u.replace(()=>QA(TS3,{get providerID(){return Q.id},get title(){return O.label},metadata:W}))}}}}))})}function Vo(){let A=Yp0();return QA(I3,{title:"Connect a provider",get options(){return A()}})}function DS3(A){let{theme:u}=V2(),q=k4(),F=Ju(),G=V4(),w=Aj();return G4((g)=>{if(g.name==="c"&&!g.ctrl&&!g.meta){let Q=A.authorization.instructions.match(/[A-Z0-9]{4}-[A-Z0-9]{4,5}/)?.[0]??A.authorization.url;AX(Q).then(()=>w.show({message:"Copied to clipboard",variant:"info"})).catch(w.error)}}),b5(async()=>{if((await q.client.provider.oauth.callback({providerID:A.providerID,method:A.index})).error){F.clear();return}await q.client.instance.dispose(),await G.bootstrap(),F.replace(()=>QA(P8A,{get providerID(){return A.providerID}}))}),(()=>{var g=o("box"),Q=o("box"),j=o("text"),K=o("text"),U=o("box"),_=o("text"),O=o("text"),W=o("text"),X=mA("c "),Y=o("span");return wA(g,Q),wA(g,U),wA(g,O),wA(g,W),P(g,"paddingLeft",2),P(g,"paddingRight",2),P(g,"gap",1),P(g,"paddingBottom",1),wA(Q,j),wA(Q,K),P(Q,"flexDirection","row"),P(Q,"justifyContent","space-between"),VA(j,()=>A.title),wA(K,mA("esc")),P(K,"onMouseUp",()=>F.clear()),wA(U,_),P(U,"gap",1),VA(U,QA(Jp0,{get href(){return A.authorization.url},get fg(){return u.primary}}),_),VA(_,()=>A.authorization.instructions),wA(O,mA("Waiting for authorization...")),wA(W,X),wA(W,Y),wA(Y,mA("copy")),SA((V)=>{var Z=z6.BOLD,H=u.text,N=u.textMuted,B=u.textMuted,M=u.textMuted,x=u.text,$={fg:u.textMuted};return Z!==V.e&&(V.e=P(j,"attributes",Z,V.e)),H!==V.t&&(V.t=P(j,"fg",H,V.t)),N!==V.a&&(V.a=P(K,"fg",N,V.a)),B!==V.o&&(V.o=P(_,"fg",B,V.o)),M!==V.i&&(V.i=P(O,"fg",M,V.i)),x!==V.n&&(V.n=P(W,"fg",x,V.n)),$!==V.s&&(V.s=P(Y,"style",$,V.s)),V},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),g})()}function PS3(A){let{theme:u}=V2(),q=k4(),F=V4(),G=Ju(),[w,g]=g2(!1);return QA(GV,{get title(){return A.title},placeholder:"Authorization code",onConfirm:async(Q)=>{let{error:j}=await q.client.provider.oauth.callback({providerID:A.providerID,method:A.index,code:Q});if(!j){await q.client.instance.dispose(),await F.bootstrap(),G.replace(()=>QA(P8A,{get providerID(){return A.providerID}}));return}g(!0)},description:()=>(()=>{var Q=o("box"),j=o("text");return wA(Q,j),P(Q,"gap",1),VA(j,()=>A.authorization.instructions),VA(Q,QA(Jp0,{get href(){return A.authorization.url},get fg(){return u.primary}}),null),VA(Q,QA(X0,{get when(){return w()},get children(){var K=o("text");return wA(K,mA("Invalid code")),SA((U)=>P(K,"fg",u.error,U)),K}}),null),SA((K)=>P(j,"fg",u.textMuted,K)),Q})()})}function TS3(A){let u=Ju(),q=k4(),F=V4();return QA(GV,{get title(){return A.title},placeholder:"API key",onConfirm:async(G)=>{if(!G)return;await q.client.auth.set({providerID:A.providerID,auth:{type:"api",key:G,...A.metadata?{metadata:A.metadata}:{}}}),await q.client.instance.dispose(),await F.bootstrap(),u.replace(()=>QA(P8A,{get providerID(){return A.providerID}}))}})}async function ZS1(A){let u={};for(let q of A.prompts){if(q.when){let G=u[q.when.key];if(G===void 0)continue;if(!(q.when.op==="eq"?G===q.when.value:G!==q.when.value))continue}if(q.type==="select"){let G=await new Promise((w)=>{A.dialog.replace(()=>QA(I3,{get title(){return q.message},get options(){return q.options.map((g)=>({title:g.label,value:g.value,description:g.hint}))},onSelect:(g)=>w(g.value)}),()=>w(null))});if(G===null)return null;u[q.key]=G;continue}let F=await new Promise((G)=>{A.dialog.replace(()=>QA(GV,{get title(){return q.message},get placeholder(){return q.placeholder},onConfirm:(w)=>G(w)}),()=>G(null))});if(F===null)return null;u[q.key]=F}return u}var VS1;var nrA=k(async()=>{U6();rw();VC();await N0([IA(),IA(),IA(),IA(),IA(),IA(),IA(),WQ(),oj(),_7(),Wg(),MHA(),OS1(),F8(),D8(),Xp0(),IA(),Xx(),drA()]);VS1={openai:1,"github-copilot":2,anthropic:3,google:4}});var Vx="28.21.15",HS1="-desktop",NS1="-mobile";function x_(A){return A.trim().replace(/^[vV]/,"")}function zHA(A){let u=x_(A);if(!u.endsWith(BS1))return!1;return Boolean(Zo.default.valid(u.slice(0,-BS1.length)))}function RHA(A){let u=x_(A);if(!u.endsWith($S1))return!1;return Boolean(Zo.default.valid(u.slice(0,-$S1.length)))}function prA(A){return zHA(A)||RHA(A)}function $C(A){let u=x_(A);return Zo.default.valid(u)??Zo.default.coerce(u)?.version}function Vp0(A,u){let q=$C(A),F=$C(u);if(q&&F)return Zo.default.eq(q,F);return x_(A)===x_(u)}function arA(A,u){if(Vp0(A,u))return!1;let q=$C(A),F=$C(u);if(q&&F)return Zo.default.gt(F,q);return x_(A)!==x_(u)}var Zo,S4,gV,T8A,BS1,$S1;var sj=k(()=>{Zo=u2(fG(),1),S4=typeof CODEPLANE_VERSION==="string"?CODEPLANE_VERSION:"local",gV=typeof CODEPLANE_CHANNEL==="string"?CODEPLANE_CHANNEL:"local",T8A=gV==="local",BS1=HS1,$S1=NS1});function MS1(A){let u=l7(),q=n8(),F=async()=>{await A.onBeforeExit?.(),q.setTerminalTitle(""),q.destroy(),FrA(),await A.onExit()};G4((U)=>{if(U.ctrl&&U.name==="c")F()});let[G,w]=g2(!1),g=new URL("https://github.com/anomalyco/codeplane/issues/new?template=bug-report.yml"),Q=A.mode==="light",j={bg:Q?"#ffffff":"#0a0a0a",text:Q?"#1a1a1a":"#eeeeee",muted:Q?"#8a8a8a":"#808080",primary:Q?"#3b7dd8":"#fab283"};if(A.error.message)g.searchParams.set("title",`opentui: fatal: ${A.error.message}`);if(A.error.stack)g.searchParams.set("description","```\n"+A.error.stack.substring(0,6000-g.toString().length)+"...\n```");g.searchParams.set("opencode-version",S4);let K=()=>{AX(g.toString()).then(()=>{w(!0)})};return(()=>{var U=o("box"),_=o("box"),O=o("text"),W=o("box"),X=o("text"),Y=o("box"),V=o("text"),Z=o("box"),H=o("text"),N=o("box"),B=o("text"),M=o("scrollbox"),x=o("text"),$=o("text");return wA(U,_),wA(U,Y),wA(U,M),wA(U,$),P(U,"flexDirection","column"),P(U,"gap",1),wA(_,O),wA(_,W),P(_,"flexDirection","row"),P(_,"gap",1),P(_,"alignItems","center"),wA(O,mA("Please report an issue.")),wA(W,X),P(W,"onMouseUp",K),P(W,"padding",1),wA(X,mA("Copy issue URL (exception info pre-filled)")),VA(_,(()=>{var E=f2(()=>!!G());return()=>E()&&(()=>{var z=o("text");return wA(z,mA("Successfully copied")),SA((T)=>P(z,"fg",j.muted,T)),z})()})(),null),wA(Y,V),wA(Y,Z),wA(Y,N),P(Y,"flexDirection","row"),P(Y,"gap",2),P(Y,"alignItems","center"),wA(V,mA("A fatal error occurred!")),wA(Z,H),P(Z,"padding",1),wA(H,mA("Reset TUI")),wA(N,B),P(N,"onMouseUp",F),P(N,"padding",1),wA(B,mA("Exit")),wA(M,x),VA(x,()=>A.error.stack),VA($,()=>A.error.message),SA((E)=>{var z=j.bg,T=z6.BOLD,D=j.text,C=j.primary,t=z6.BOLD,S=j.bg,f=j.text,r=A.reset,l=j.primary,e=j.bg,s=j.primary,a=j.bg,uA=Math.floor(u().height*0.7),n=b$(),m=j.muted,v=j.text;return z!==E.e&&(E.e=P(U,"backgroundColor",z,E.e)),T!==E.t&&(E.t=P(O,"attributes",T,E.t)),D!==E.a&&(E.a=P(O,"fg",D,E.a)),C!==E.o&&(E.o=P(W,"backgroundColor",C,E.o)),t!==E.i&&(E.i=P(X,"attributes",t,E.i)),S!==E.n&&(E.n=P(X,"fg",S,E.n)),f!==E.s&&(E.s=P(V,"fg",f,E.s)),r!==E.h&&(E.h=P(Z,"onMouseUp",r,E.h)),l!==E.r&&(E.r=P(Z,"backgroundColor",l,E.r)),e!==E.d&&(E.d=P(H,"fg",e,E.d)),s!==E.l&&(E.l=P(N,"backgroundColor",s,E.l)),a!==E.u&&(E.u=P(B,"fg",a,E.u)),uA!==E.c&&(E.c=P(M,"height",uA,E.c)),n!==E.w&&(E.w=P(M,"scrollAcceleration",n,E.w)),m!==E.m&&(E.m=P(x,"fg",m,E.m)),v!==E.f&&(E.f=P($,"fg",v,E.f)),E},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0,m:void 0,f:void 0}),U})()}var LS1=k(async()=>{VC();U6();sj();GrA();await N0([IA(),IA(),IA(),IA(),IA(),IA(),IA(),D8(),IA(),Xo()])});function ES1(A){let{theme:u}=V2();return(()=>{var q=o("box"),F=o("text"),G=mA("Unknown plugin route: "),w=o("box"),g=o("text");return wA(q,F),wA(q,w),P(q,"width","100%"),P(q,"height","100%"),P(q,"alignItems","center"),P(q,"justifyContent","center"),P(q,"flexDirection","column"),P(q,"gap",1),wA(F,G),VA(F,()=>A.id,null),wA(w,g),P(w,"paddingLeft",1),P(w,"paddingRight",1),wA(g,mA("go home")),SA((Q)=>{var j=u.warning,K=A.onHome,U=u.backgroundElement,_=u.text;return j!==Q.e&&(Q.e=P(F,"fg",j,Q.e)),K!==Q.t&&(Q.t=P(w,"onMouseUp",K,Q.t)),U!==Q.a&&(Q.a=P(w,"backgroundColor",U,Q.a)),_!==Q.o&&(Q.o=P(g,"fg",_,Q.o)),Q},{e:void 0,t:void 0,a:void 0,o:void 0}),q})()}var xS1=k(async()=>{await N0([IA(),IA(),IA(),IA(),IA(),IA(),F8()])});import{Database as Zp0}from"bun:sqlite";import zS1 from"os";import Ho from"path";async function DS1(A,u=process.cwd()){let q=fS3(A,u);if(q.type!=="row")return q;let F=q.row;if(!F.buffer_path)return{type:"empty"};let G=hS3(A,F);if(G.type!=="selections")return G;let w=G.selections.flatMap((K)=>{if(K.selection_start==null||K.selection_end==null)return[];return[{start:Math.min(K.selection_start,K.selection_end),end:Math.max(K.selection_start,K.selection_end)}]}).sort((K,U)=>K.start-U.start||K.end-U.end);if(w.length===0)return{type:"unavailable"};let g=mS3(A,F),Q=g.type==="contents"&&g.contents!=null?g.contents:await Bun.file(F.buffer_path).text().catch(()=>{return});if(Q==null)return{type:"unavailable"};let j=w.map((K)=>{let U=RS1(Q,K.start),_=RS1(Q,K.end);return{text:Q.slice(U,_),selection:lS3(Q,U,_)}});return{type:"selection",selection:{filePath:F.buffer_path,source:"zed",ranges:j}}}function fS3(A,u){let q;try{q=new Zp0(A,{readonly:!0});let F=q.query(`select
|
|
742
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var uS1=k(()=>{AS1()});import{promisify as WS3}from"util";import{execFile as XS3}from"child_process";async function gp0(A=YS3){let{stdout:u}=await A("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),q=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(u);if(!q)throw new qS1(`Cannot find Windows browser in stdout: ${JSON.stringify(u)}`);let{id:F}=q.groups,G=F.lastIndexOf("."),w=F.lastIndexOf("-"),g=G===-1?void 0:F.slice(0,G),Q=w===-1?void 0:F.slice(0,w);return lrA[F]??lrA[g]??lrA[Q]??{name:F,id:F}}var YS3,lrA,df9,qS1;var FS1=k(()=>{YS3=WS3(XS3),lrA={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},df9=new Map(Object.entries(lrA));qS1=class qS1 extends Error{}});import{promisify as VS3}from"util";import Qp0 from"process";import{execFile as ZS3}from"child_process";async function LHA(){if(Qp0.platform==="darwin"){let A=await Gp0();return{name:await wp0(A),id:A}}if(Qp0.platform==="linux"){let{stdout:A}=await HS3("xdg-mime",["query","default","x-scheme-handler/http"]),u=A.trim();return{name:NS3(u.replace(/.desktop$/,"").replace("-"," ")),id:u}}if(Qp0.platform==="win32")return gp0();throw Error("Only macOS, Linux, and Windows are supported")}var HS3,NS3=(A)=>A.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,(u)=>u.toUpperCase());var jp0=k(()=>{sk1();uS1();FS1();HS3=VS3(ZS3)});import EHA from"process";import{Buffer as jS1}from"buffer";import KS1 from"path";import{fileURLToPath as BS3}from"url";import $S3 from"util";import US1 from"child_process";import Kp0,{constants as _S1}from"fs/promises";async function ES3(){let A=await JS1(),u='(Get-ItemProperty -Path "HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice").ProgId',q=jS1.from('(Get-ItemProperty -Path "HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice").ProgId',"utf16le").toString("base64"),{stdout:F}=await MS3(A,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",q],{encoding:"utf8"}),G=F.trim(),w={ChromeHTML:"com.google.chrome",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return w[G]?{id:w[G]}:{}}function QS1(A){if(typeof A==="string"||Array.isArray(A))return A;let{[wS1]:u}=A;if(!u)throw Error(`${wS1} is not supported`);return u}function _p0({[z8A]:A},{wsl:u}){if(u&&qO)return QS1(u);if(!A)throw Error(`${z8A} is not supported`);return QS1(A)}var MS3,Up0,GS1,z8A,wS1,LS3,JS1=async()=>{return`${await LS3()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},gS1=async(A,u)=>{let q;for(let F of A)try{return await u(F)}catch(G){q=G}throw q},irA=async(A)=>{if(A={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...A},Array.isArray(A.app))return gS1(A.app,(Q)=>irA({...A,app:Q}));let{name:u,arguments:q=[]}=A.app??{};if(q=[...q],Array.isArray(u))return gS1(u,(Q)=>irA({...A,app:{name:Q,arguments:q}}));if(u==="browser"||u==="browserPrivate"){let Q={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},j={chrome:"--incognito",firefox:"--private-window",edge:"--inPrivate"},K=qO?await ES3():await LHA();if(K.id in Q){let U=Q[K.id];if(u==="browserPrivate")q.push(j[U]);return irA({...A,app:{name:R8A[U],arguments:q}})}throw Error(`${K.name} is not supported as a default browser`)}let F,G=[],w={};if(z8A==="darwin"){if(F="open",A.wait)G.push("--wait-apps");if(A.background)G.push("--background");if(A.newInstance)G.push("--new");if(u)G.push("-a",u)}else if(z8A==="win32"||qO&&!YC()&&!u){if(F=qO?await JS1():`${EHA.env.SYSTEMROOT||EHA.env.windir||"C:\\Windows"}\\System32\\WindowsPowerShell\\v1.0\\powershell`,G.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),!qO)w.windowsVerbatimArguments=!0;let Q=["Start"];if(A.wait)Q.push("-Wait");if(u){if(Q.push(`"\`"${u}\`""`),A.target)q.push(A.target)}else if(A.target)Q.push(`"${A.target}"`);if(q.length>0)q=q.map((j)=>`"\`"${j}\`""`),Q.push("-ArgumentList",q.join(","));A.target=jS1.from(Q.join(" "),"utf16le").toString("base64")}else{if(u)F=u;else{let Q=!Up0||Up0==="/",j=!1;try{await Kp0.access(GS1,_S1.X_OK),j=!0}catch{}F=EHA.versions.electron??(z8A==="android"||Q||!j)?"xdg-open":GS1}if(q.length>0)G.push(...q);if(!A.wait)w.stdio="ignore",w.detached=!0}if(z8A==="darwin"&&q.length>0)G.push("--args",...q);if(A.target)G.push(A.target);let g=US1.spawn(F,G,w);if(A.wait)return new Promise((Q,j)=>{g.once("error",j),g.once("close",(K)=>{if(!A.allowNonzeroExitCode&&K>0){j(Error(`Exited with code ${K}`));return}Q(g)})});return g.unref(),g},xS3=(A,u)=>{if(typeof A!=="string")throw TypeError("Expected a `target`");return irA({...u,target:A})},R8A,Hv;var xHA=k(()=>{uHA();jp0();maA();MS3=$S3.promisify(US1.execFile),Up0=KS1.dirname(BS3(import.meta.url)),GS1=KS1.join(Up0,"xdg-open"),{platform:z8A,arch:wS1}=EHA,LS3=(()=>{let u;return async function(){if(u)return u;let q="/etc/wsl.conf",F=!1;try{await Kp0.access(q,_S1.F_OK),F=!0}catch{}if(!F)return"/mnt/";let G=await Kp0.readFile(q,{encoding:"utf8"}),w=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(G);if(!w)return"/mnt/";return u=w.groups.mountPoint.trim(),u=u.endsWith("/")?u:`${u}/`,u}})();R8A={};wV(R8A,"chrome",()=>_p0({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));wV(R8A,"firefox",()=>_p0({darwin:"firefox",win32:"C:\\Program Files\\Mozilla Firefox\\firefox.exe",linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));wV(R8A,"edge",()=>_p0({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));wV(R8A,"browser",()=>"browser");wV(R8A,"browserPrivate",()=>"browserPrivate");Hv=xS3});function Jp0(A){let u=A.children??A.href;return(()=>{var q=o("text");return P(q,"onMouseUp",()=>{Hv(A.href).catch(()=>{})}),VA(q,u),SA((F)=>P(q,"fg",A.fg,F)),q})()}var OS1=k(async()=>{xHA();await N0([IA(),IA(),IA(),IA()])});function S7(A){return A()}import zS3 from"path";function WS1(A){let[u,...q]=A.split("/");return{providerID:u,modelID:q.join("/")}}var XQ,XS1;var ZP=k(async()=>{iF();U6();rw();uO();await N0([OU(),WQ(),F8(),P3(),Xx(),L8A(),Wg(),D8()]);({use:XQ,provider:XS1}=Wq({name:"Local",init:()=>{let A=V4(),u=k4(),q=Aj();function F(K){return!!A.data.provider.find((_)=>_.id===K.providerID)?.models[K.modelID]}function G(...K){for(let U of K){let _=U();if(!_)continue;if(F(_))return _}}let w=S7(()=>{let K=yA(()=>A.data.agent.filter((Y)=>Y.mode!=="subagent"&&!Y.hidden)),U=yA(()=>A.data.agent.filter((Y)=>!Y.hidden)),[_,O]=F4({current:void 0}),{theme:W}=V2(),X=yA(()=>[W.secondary,W.accent,W.success,W.warning,W.primary,W.error,W.info]);return{list(){return K()},current(){return K().find((Y)=>Y.name===_.current)??K().at(0)},set(Y){if(!K().some((V)=>V.name===Y))return q.show({variant:"warning",message:`Agent not found: ${Y}`,duration:3000});O("current",Y)},move(Y){N7(()=>{let V=this.current();if(!V)return;let Z=K().findIndex((N)=>N.name===V.name)+Y;if(Z<0)Z=K().length-1;if(Z>=K().length)Z=0;let H=K()[Z];O("current",H.name)})},color(Y){let V=U().findIndex((H)=>H.name===Y);if(V===-1)return X()[0];let Z=U()[V];if(Z?.color){let H=Z.color;if(H.startsWith("#"))return m2.fromHex(H);return W[H]}return X()[V%X().length]}}}),g=S7(()=>{let[K,U]=F4({ready:!1,model:{},recent:[],favorite:[],variant:{}}),_=zS3.join(U2.Path.state,"model.json"),O={pending:!1};function W(){if(!K.ready){O.pending=!0;return}O.pending=!1,M5.writeJson(_,{recent:K.recent,favorite:K.favorite,variant:K.variant})}M5.readJson(_).then((Z)=>{if(Array.isArray(Z.recent))U("recent",Z.recent);if(Array.isArray(Z.favorite))U("favorite",Z.favorite);if(typeof Z.variant==="object"&&Z.variant!==null)U("variant",Z.variant)}).catch(()=>{}).finally(()=>{if(U("ready",!0),O.pending)W()});let X=VP(),Y=yA(()=>{if(X.model){let{providerID:M,modelID:x}=WS1(X.model);if(F({providerID:M,modelID:x}))return{providerID:M,modelID:x}}if(A.data.config.model){let{providerID:M,modelID:x}=WS1(A.data.config.model);if(F({providerID:M,modelID:x}))return{providerID:M,modelID:x}}for(let M of K.recent)if(F(M))return M;let Z=A.data.provider[0];if(!Z)return;let H=A.data.provider_default[Z.id],N=Object.values(Z.models)[0],B=H??N?.id;if(!B)return;return{providerID:Z.id,modelID:B}}),V=yA(()=>{let Z=w.current();return G(()=>Z&&K.model[Z.name],()=>Z&&Z.model,Y)??void 0});return{current:V,get ready(){return K.ready},recent(){return K.recent},favorite(){return K.favorite},parsed:yA(()=>{let Z=V();if(!Z)return{provider:"Connect a provider",model:"No provider selected",reasoning:!1};let H=A.data.provider.find((B)=>B.id===Z.providerID),N=H?.models[Z.modelID];return{provider:H?.name??Z.providerID,model:N?.name??Z.modelID,reasoning:N?.capabilities?.reasoning??!1}}),cycle(Z){let H=V();if(!H)return;let N=K.recent,B=N.findIndex((E)=>E.providerID===H.providerID&&E.modelID===H.modelID);if(B===-1)return;let M=B+Z;if(M<0)M=N.length-1;if(M>=N.length)M=0;let x=N[M];if(!x)return;let $=w.current();if(!$)return;U("model",$.name,{...x})},cycleFavorite(Z){let H=K.favorite.filter((E)=>F(E));if(!H.length){q.show({variant:"info",message:"Add a favorite model to use this shortcut",duration:3000});return}let N=V(),B=-1;if(N)B=H.findIndex((E)=>E.providerID===N.providerID&&E.modelID===N.modelID);if(B===-1)B=Z===1?0:H.length-1;else{if(B+=Z,B<0)B=H.length-1;if(B>=H.length)B=0}let M=H[B];if(!M)return;let x=w.current();if(!x)return;U("model",x.name,{...M});let $=ntA([M,...K.recent],(E)=>`${E.providerID}/${E.modelID}`);if($.length>10)$.pop();U("recent",$.map((E)=>({providerID:E.providerID,modelID:E.modelID}))),W()},set(Z,H){N7(()=>{if(!F(Z)){q.show({message:`Model ${Z.providerID}/${Z.modelID} is not valid`,variant:"warning",duration:3000});return}let N=w.current();if(!N)return;if(U("model",N.name,Z),H?.recent){let B=ntA([Z,...K.recent],(M)=>`${M.providerID}/${M.modelID}`);if(B.length>10)B.pop();U("recent",B.map((M)=>({providerID:M.providerID,modelID:M.modelID}))),W()}})},toggleFavorite(Z){N7(()=>{if(!F(Z)){q.show({message:`Model ${Z.providerID}/${Z.modelID} is not valid`,variant:"warning",duration:3000});return}let N=K.favorite.some((B)=>B.providerID===Z.providerID&&B.modelID===Z.modelID)?K.favorite.filter((B)=>B.providerID!==Z.providerID||B.modelID!==Z.modelID):[Z,...K.favorite];U("favorite",N.map((B)=>({providerID:B.providerID,modelID:B.modelID}))),W()})},variant:{selected(){let Z=V();if(!Z)return;let H=`${Z.providerID}/${Z.modelID}`;return K.variant[H]},current(){let Z=this.selected();if(!Z)return;if(!this.list().includes(Z))return;return Z},list(){let Z=V();if(!Z)return[];let N=A.data.provider.find((B)=>B.id===Z.providerID)?.models[Z.modelID];if(!N?.variants)return[];return Object.keys(N.variants)},set(Z){let H=V();if(!H)return;let N=`${H.providerID}/${H.modelID}`;U("variant",N,Z??"default"),W()},cycle(){let Z=this.list();if(Z.length===0)return;let H=this.current();if(!H){this.set(Z[0]);return}let N=Z.indexOf(H);if(N===-1||N===Z.length-1){this.set(void 0);return}this.set(Z[N+1])}}}}),Q={isEnabled(K){return A.data.mcp[K]?.status==="connected"},async toggle(K){if(A.data.mcp[K]?.status==="connected")await u.client.mcp.disconnect({name:K});else await u.client.mcp.connect({name:K})}};return B4(()=>{let K=w.current();if(!K)return;if(K.model)if(F(K.model))g.set({providerID:K.model.providerID,modelID:K.model.modelID});else q.show({variant:"warning",message:`Agent ${K.name}'s configured model ${K.model.providerID}/${K.model.modelID} is not valid`,duration:3000})}),{model:g,agent:w,mcp:Q}}}))});function crA(){let A=XQ(),u=Ju(),q=yA(()=>{return[{value:"default",title:"Default",onSelect:()=>{u.clear(),A.model.variant.set(void 0)}},...A.model.variant.list().map((F)=>({value:F,title:F,onSelect:()=>{u.clear(),A.model.variant.set(F)}}))]});return QA(I3,{get options(){return q()},title:"Select variant",get current(){return A.model.variant.selected()},flat:!0})}var Op0=k(async()=>{U6();await N0([IA(),ZP(),oj(),_7()])});function D8A(){let A=V4();return yA(()=>A.data.provider.some((u)=>u.id!=="opencode"||Object.values(u.models).some((q)=>q.cost?.input!==0)))}var drA=k(async()=>{U6();await WQ()});function P8A(A){let u=XQ(),q=V4(),F=Ju(),G=A9(),[w,g]=g2(""),Q=D8A(),j=Yp0(),K=yA(()=>Q()&&!A.providerID),U=yA(()=>{let X=w().trim(),Y=K()&&X.length===0,V=Q()?u.model.favorite():[],Z=u.model.recent();function H($,E){if(!Y)return[];return $.flatMap((z)=>{let T=q.data.provider.find((C)=>C.id===z.providerID);if(!T)return[];let D=T.models[z.modelID];if(!D)return[];return[{key:z,value:{providerID:T.id,modelID:D.id},title:D.name??z.modelID,description:T.name,category:E,disabled:T.id==="opencode"&&D.id.includes("-nano"),footer:D.cost?.input===0&&T.id==="opencode"?"Free":void 0,onSelect:()=>{W(T.id,D.id)}}]})}let N=H(V,"Favorites"),B=H(Z.filter(($)=>!V.some((E)=>E.providerID===$.providerID&&E.modelID===$.modelID)),"Recent"),M=nF(q.data.provider,TW(($)=>$.id!=="opencode",($)=>$.name),uOA(($)=>nF($.models,kp(),yk(([E,z])=>z.status!=="deprecated"),yk(([E,z])=>A.providerID?z.providerID===A.providerID:!0),Et(([E,z])=>({value:{providerID:$.id,modelID:E},title:z.name??E,description:V.some((T)=>T.providerID===$.id&&T.modelID===E)?"(Favorite)":void 0,category:Q()?$.name:void 0,disabled:$.id==="opencode"&&E.includes("-nano"),footer:z.cost?.input===0&&$.id==="opencode"?"Free":void 0,onSelect(){W($.id,E)}})),yk((E)=>{if(!Y)return!0;if(V.some((z)=>z.providerID===E.value.providerID&&z.modelID===E.value.modelID))return!1;if(Z.some((z)=>z.providerID===E.value.providerID&&z.modelID===E.value.modelID))return!1;return!0}),TW((E)=>E.footer!=="Free",(E)=>E.title)))),x=!Q()?nF(j(),Et(($)=>({...$,category:"Popular providers"})),kL0(6)):[];if(X)return[...Wp0.go(X,M,{keys:["title","category"]}).map(($)=>$.obj),...Wp0.go(X,x,{keys:["title"]}).map(($)=>$.obj)];return[...N,...B,...M,...x]}),_=yA(()=>A.providerID?q.data.provider.find((X)=>X.id===A.providerID):null),O=yA(()=>{let X=_();if(!X)return"Select model";return X.name});function W(X,Y){u.model.set({providerID:X,modelID:Y},{recent:!0});let V=u.model.variant.list(),Z=u.model.variant.selected();if(Z==="default"||Z&&V.includes(Z)){F.clear();return}if(V.length>0){F.replace(()=>QA(crA,{}));return}F.clear()}return QA(I3,{get options(){return U()},get keybind(){return[{keybind:G.all.model_provider_list?.[0],title:Q()?"Connect provider":"View all providers",onTrigger(){F.replace(()=>QA(Vo,{}))}},{keybind:G.all.model_favorite_toggle?.[0],title:"Favorite",disabled:!Q(),onTrigger:(X)=>{u.model.toggleFavorite(X.value)}}]},onFilter:g,flat:!0,skipFilter:!0,get title(){return O()},get current(){return u.model.current()}})}var Wp0;var Xp0=k(async()=>{U6();rw();await N0([IA(),ZP(),WQ(),oj(),_7(),nrA(),Op0(),qV(),drA()]);Wp0=u2(E8A(),1)});var RS3=(A,u)=>Array.isArray(A)?A.includes(u):A.has(u),YS1=(A,u)=>RS3(A,u);function Yp0(){let A=V4(),u=Ju(),q=k4(),F=Aj(),{theme:G}=V2(),w=D8A();return yA(()=>{return nF(A.data.provider_next.all,yk((Q)=>Q.id!=="opencode"),TW((Q)=>VS1[Q.id]??99),Et((Q)=>{let j=YS1(A.data.console_state.consoleManagedProviders,Q.id),K=A.data.provider_next.connected.includes(Q.id);return{title:Q.name,value:Q.id,description:{anthropic:"(API key)",openai:"(ChatGPT Plus/Pro or API key)"}[Q.id],footer:j?A.data.console_state.activeOrgName:void 0,category:Q.id in VS1?"Popular":"Other",gutter:K&&w()?()=>(()=>{var U=o("text");return wA(U,mA("\u2713")),SA((_)=>P(U,"fg",G.success,_)),U})():void 0,async onSelect(){if(j)return;let U=A.data.provider_auth[Q.id]??[{type:"api",label:"API key"}],_=0;if(U.length>1)_=await new Promise((W)=>{u.replace(()=>QA(I3,{title:"Select auth method",get options(){return U.map((X,Y)=>({title:X.label,value:Y}))},onSelect:(X)=>W(X.value)}),()=>W(null))});if(_==null)return;let O=U[_];if(O.type==="oauth"){let W;if(O.prompts?.length){let Y=await ZS1({dialog:u,prompts:O.prompts});if(!Y)return;W=Y}let X=await q.client.provider.oauth.authorize({providerID:Q.id,method:_,inputs:W});if(X.error){F.show({variant:"error",message:JSON.stringify(X.error)}),u.clear();return}if(X.data?.method==="code")u.replace(()=>QA(PS3,{get providerID(){return Q.id},get title(){return O.label},index:_,get authorization(){return X.data}}));if(X.data?.method==="auto")u.replace(()=>QA(DS3,{get providerID(){return Q.id},get title(){return O.label},index:_,get authorization(){return X.data}}))}if(O.type==="api"){let W;if(O.prompts?.length){let X=await ZS1({dialog:u,prompts:O.prompts});if(!X)return;W=X}return u.replace(()=>QA(TS3,{get providerID(){return Q.id},get title(){return O.label},metadata:W}))}}}}))})}function Vo(){let A=Yp0();return QA(I3,{title:"Connect a provider",get options(){return A()}})}function DS3(A){let{theme:u}=V2(),q=k4(),F=Ju(),G=V4(),w=Aj();return G4((g)=>{if(g.name==="c"&&!g.ctrl&&!g.meta){let Q=A.authorization.instructions.match(/[A-Z0-9]{4}-[A-Z0-9]{4,5}/)?.[0]??A.authorization.url;AX(Q).then(()=>w.show({message:"Copied to clipboard",variant:"info"})).catch(w.error)}}),b5(async()=>{if((await q.client.provider.oauth.callback({providerID:A.providerID,method:A.index})).error){F.clear();return}await q.client.instance.dispose(),await G.bootstrap(),F.replace(()=>QA(P8A,{get providerID(){return A.providerID}}))}),(()=>{var g=o("box"),Q=o("box"),j=o("text"),K=o("text"),U=o("box"),_=o("text"),O=o("text"),W=o("text"),X=mA("c "),Y=o("span");return wA(g,Q),wA(g,U),wA(g,O),wA(g,W),P(g,"paddingLeft",2),P(g,"paddingRight",2),P(g,"gap",1),P(g,"paddingBottom",1),wA(Q,j),wA(Q,K),P(Q,"flexDirection","row"),P(Q,"justifyContent","space-between"),VA(j,()=>A.title),wA(K,mA("esc")),P(K,"onMouseUp",()=>F.clear()),wA(U,_),P(U,"gap",1),VA(U,QA(Jp0,{get href(){return A.authorization.url},get fg(){return u.primary}}),_),VA(_,()=>A.authorization.instructions),wA(O,mA("Waiting for authorization...")),wA(W,X),wA(W,Y),wA(Y,mA("copy")),SA((V)=>{var Z=z6.BOLD,H=u.text,N=u.textMuted,B=u.textMuted,M=u.textMuted,x=u.text,$={fg:u.textMuted};return Z!==V.e&&(V.e=P(j,"attributes",Z,V.e)),H!==V.t&&(V.t=P(j,"fg",H,V.t)),N!==V.a&&(V.a=P(K,"fg",N,V.a)),B!==V.o&&(V.o=P(_,"fg",B,V.o)),M!==V.i&&(V.i=P(O,"fg",M,V.i)),x!==V.n&&(V.n=P(W,"fg",x,V.n)),$!==V.s&&(V.s=P(Y,"style",$,V.s)),V},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),g})()}function PS3(A){let{theme:u}=V2(),q=k4(),F=V4(),G=Ju(),[w,g]=g2(!1);return QA(GV,{get title(){return A.title},placeholder:"Authorization code",onConfirm:async(Q)=>{let{error:j}=await q.client.provider.oauth.callback({providerID:A.providerID,method:A.index,code:Q});if(!j){await q.client.instance.dispose(),await F.bootstrap(),G.replace(()=>QA(P8A,{get providerID(){return A.providerID}}));return}g(!0)},description:()=>(()=>{var Q=o("box"),j=o("text");return wA(Q,j),P(Q,"gap",1),VA(j,()=>A.authorization.instructions),VA(Q,QA(Jp0,{get href(){return A.authorization.url},get fg(){return u.primary}}),null),VA(Q,QA(X0,{get when(){return w()},get children(){var K=o("text");return wA(K,mA("Invalid code")),SA((U)=>P(K,"fg",u.error,U)),K}}),null),SA((K)=>P(j,"fg",u.textMuted,K)),Q})()})}function TS3(A){let u=Ju(),q=k4(),F=V4();return QA(GV,{get title(){return A.title},placeholder:"API key",onConfirm:async(G)=>{if(!G)return;await q.client.auth.set({providerID:A.providerID,auth:{type:"api",key:G,...A.metadata?{metadata:A.metadata}:{}}}),await q.client.instance.dispose(),await F.bootstrap(),u.replace(()=>QA(P8A,{get providerID(){return A.providerID}}))}})}async function ZS1(A){let u={};for(let q of A.prompts){if(q.when){let G=u[q.when.key];if(G===void 0)continue;if(!(q.when.op==="eq"?G===q.when.value:G!==q.when.value))continue}if(q.type==="select"){let G=await new Promise((w)=>{A.dialog.replace(()=>QA(I3,{get title(){return q.message},get options(){return q.options.map((g)=>({title:g.label,value:g.value,description:g.hint}))},onSelect:(g)=>w(g.value)}),()=>w(null))});if(G===null)return null;u[q.key]=G;continue}let F=await new Promise((G)=>{A.dialog.replace(()=>QA(GV,{get title(){return q.message},get placeholder(){return q.placeholder},onConfirm:(w)=>G(w)}),()=>G(null))});if(F===null)return null;u[q.key]=F}return u}var VS1;var nrA=k(async()=>{U6();rw();VC();await N0([IA(),IA(),IA(),IA(),IA(),IA(),IA(),WQ(),oj(),_7(),Wg(),MHA(),OS1(),F8(),D8(),Xp0(),IA(),Xx(),drA()]);VS1={openai:1,"github-copilot":2,anthropic:3,google:4}});var Vx="28.21.17",HS1="-desktop",NS1="-mobile";function x_(A){return A.trim().replace(/^[vV]/,"")}function zHA(A){let u=x_(A);if(!u.endsWith(BS1))return!1;return Boolean(Zo.default.valid(u.slice(0,-BS1.length)))}function RHA(A){let u=x_(A);if(!u.endsWith($S1))return!1;return Boolean(Zo.default.valid(u.slice(0,-$S1.length)))}function prA(A){return zHA(A)||RHA(A)}function $C(A){let u=x_(A);return Zo.default.valid(u)??Zo.default.coerce(u)?.version}function Vp0(A,u){let q=$C(A),F=$C(u);if(q&&F)return Zo.default.eq(q,F);return x_(A)===x_(u)}function arA(A,u){if(Vp0(A,u))return!1;let q=$C(A),F=$C(u);if(q&&F)return Zo.default.gt(F,q);return x_(A)!==x_(u)}var Zo,S4,gV,T8A,BS1,$S1;var sj=k(()=>{Zo=u2(fG(),1),S4=typeof CODEPLANE_VERSION==="string"?CODEPLANE_VERSION:"local",gV=typeof CODEPLANE_CHANNEL==="string"?CODEPLANE_CHANNEL:"local",T8A=gV==="local",BS1=HS1,$S1=NS1});function MS1(A){let u=l7(),q=n8(),F=async()=>{await A.onBeforeExit?.(),q.setTerminalTitle(""),q.destroy(),FrA(),await A.onExit()};G4((U)=>{if(U.ctrl&&U.name==="c")F()});let[G,w]=g2(!1),g=new URL("https://github.com/anomalyco/codeplane/issues/new?template=bug-report.yml"),Q=A.mode==="light",j={bg:Q?"#ffffff":"#0a0a0a",text:Q?"#1a1a1a":"#eeeeee",muted:Q?"#8a8a8a":"#808080",primary:Q?"#3b7dd8":"#fab283"};if(A.error.message)g.searchParams.set("title",`opentui: fatal: ${A.error.message}`);if(A.error.stack)g.searchParams.set("description","```\n"+A.error.stack.substring(0,6000-g.toString().length)+"...\n```");g.searchParams.set("opencode-version",S4);let K=()=>{AX(g.toString()).then(()=>{w(!0)})};return(()=>{var U=o("box"),_=o("box"),O=o("text"),W=o("box"),X=o("text"),Y=o("box"),V=o("text"),Z=o("box"),H=o("text"),N=o("box"),B=o("text"),M=o("scrollbox"),x=o("text"),$=o("text");return wA(U,_),wA(U,Y),wA(U,M),wA(U,$),P(U,"flexDirection","column"),P(U,"gap",1),wA(_,O),wA(_,W),P(_,"flexDirection","row"),P(_,"gap",1),P(_,"alignItems","center"),wA(O,mA("Please report an issue.")),wA(W,X),P(W,"onMouseUp",K),P(W,"padding",1),wA(X,mA("Copy issue URL (exception info pre-filled)")),VA(_,(()=>{var E=f2(()=>!!G());return()=>E()&&(()=>{var z=o("text");return wA(z,mA("Successfully copied")),SA((T)=>P(z,"fg",j.muted,T)),z})()})(),null),wA(Y,V),wA(Y,Z),wA(Y,N),P(Y,"flexDirection","row"),P(Y,"gap",2),P(Y,"alignItems","center"),wA(V,mA("A fatal error occurred!")),wA(Z,H),P(Z,"padding",1),wA(H,mA("Reset TUI")),wA(N,B),P(N,"onMouseUp",F),P(N,"padding",1),wA(B,mA("Exit")),wA(M,x),VA(x,()=>A.error.stack),VA($,()=>A.error.message),SA((E)=>{var z=j.bg,T=z6.BOLD,D=j.text,C=j.primary,t=z6.BOLD,S=j.bg,f=j.text,r=A.reset,l=j.primary,e=j.bg,s=j.primary,a=j.bg,uA=Math.floor(u().height*0.7),n=b$(),m=j.muted,v=j.text;return z!==E.e&&(E.e=P(U,"backgroundColor",z,E.e)),T!==E.t&&(E.t=P(O,"attributes",T,E.t)),D!==E.a&&(E.a=P(O,"fg",D,E.a)),C!==E.o&&(E.o=P(W,"backgroundColor",C,E.o)),t!==E.i&&(E.i=P(X,"attributes",t,E.i)),S!==E.n&&(E.n=P(X,"fg",S,E.n)),f!==E.s&&(E.s=P(V,"fg",f,E.s)),r!==E.h&&(E.h=P(Z,"onMouseUp",r,E.h)),l!==E.r&&(E.r=P(Z,"backgroundColor",l,E.r)),e!==E.d&&(E.d=P(H,"fg",e,E.d)),s!==E.l&&(E.l=P(N,"backgroundColor",s,E.l)),a!==E.u&&(E.u=P(B,"fg",a,E.u)),uA!==E.c&&(E.c=P(M,"height",uA,E.c)),n!==E.w&&(E.w=P(M,"scrollAcceleration",n,E.w)),m!==E.m&&(E.m=P(x,"fg",m,E.m)),v!==E.f&&(E.f=P($,"fg",v,E.f)),E},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0,m:void 0,f:void 0}),U})()}var LS1=k(async()=>{VC();U6();sj();GrA();await N0([IA(),IA(),IA(),IA(),IA(),IA(),IA(),D8(),IA(),Xo()])});function ES1(A){let{theme:u}=V2();return(()=>{var q=o("box"),F=o("text"),G=mA("Unknown plugin route: "),w=o("box"),g=o("text");return wA(q,F),wA(q,w),P(q,"width","100%"),P(q,"height","100%"),P(q,"alignItems","center"),P(q,"justifyContent","center"),P(q,"flexDirection","column"),P(q,"gap",1),wA(F,G),VA(F,()=>A.id,null),wA(w,g),P(w,"paddingLeft",1),P(w,"paddingRight",1),wA(g,mA("go home")),SA((Q)=>{var j=u.warning,K=A.onHome,U=u.backgroundElement,_=u.text;return j!==Q.e&&(Q.e=P(F,"fg",j,Q.e)),K!==Q.t&&(Q.t=P(w,"onMouseUp",K,Q.t)),U!==Q.a&&(Q.a=P(w,"backgroundColor",U,Q.a)),_!==Q.o&&(Q.o=P(g,"fg",_,Q.o)),Q},{e:void 0,t:void 0,a:void 0,o:void 0}),q})()}var xS1=k(async()=>{await N0([IA(),IA(),IA(),IA(),IA(),IA(),F8()])});import{Database as Zp0}from"bun:sqlite";import zS1 from"os";import Ho from"path";async function DS1(A,u=process.cwd()){let q=fS3(A,u);if(q.type!=="row")return q;let F=q.row;if(!F.buffer_path)return{type:"empty"};let G=hS3(A,F);if(G.type!=="selections")return G;let w=G.selections.flatMap((K)=>{if(K.selection_start==null||K.selection_end==null)return[];return[{start:Math.min(K.selection_start,K.selection_end),end:Math.max(K.selection_start,K.selection_end)}]}).sort((K,U)=>K.start-U.start||K.end-U.end);if(w.length===0)return{type:"unavailable"};let g=mS3(A,F),Q=g.type==="contents"&&g.contents!=null?g.contents:await Bun.file(F.buffer_path).text().catch(()=>{return});if(Q==null)return{type:"unavailable"};let j=w.map((K)=>{let U=RS1(Q,K.start),_=RS1(Q,K.end);return{text:Q.slice(U,_),selection:lS3(Q,U,_)}});return{type:"selection",selection:{filePath:F.buffer_path,source:"zed",ranges:j}}}function fS3(A,u){let q;try{q=new Zp0(A,{readonly:!0});let F=q.query(`select
|
|
743
743
|
i.kind as item_kind,
|
|
744
744
|
e.item_id as editor_id,
|
|
745
745
|
i.workspace_id as workspace_id,
|
|
@@ -1846,7 +1846,7 @@ return `+str.trim()+`;
|
|
|
1846
1846
|
`:A}});var Gm6=I((ibF,Fm6)=>{var s3q=_EA();Fm6.exports=function(A,u){let q=s3q(u);if(A.data==null)A.data={};if(typeof q.excerpt==="function")return q.excerpt(A,q);let F=A.data.excerpt_separator||q.excerpt_separator;if(F==null&&(q.excerpt===!1||q.excerpt==null))return A;let G=typeof q.excerpt==="string"?q.excerpt:F||q.delimiters[0],w=A.content.indexOf(G);if(w!==-1)A.excerpt=A.content.slice(0,w);return A}});var Qm6=I((cbF,gm6)=>{var wm6=GEA(),e3q=T92(),bFA=Z50();gm6.exports=function(A){if(wm6(A)!=="object")A={content:A};if(wm6(A.data)!=="object")A.data={};if(A.contents&&A.content==null)A.content=A.contents;return bFA.define(A,"orig",bFA.toBuffer(A.content)),bFA.define(A,"language",A.language||""),bFA.define(A,"matter",A.matter||""),bFA.define(A,"stringify",function(u,q){if(q&&q.language)A.language=q.language;return e3q(A,u,q)}),A.content=bFA.toString(A.content),A.isEmpty=!1,A.excerpt="",A}});var Km6=I((dbF,jm6)=>{var A8q=P92(),u8q=_EA();jm6.exports=function(A,u,q){let F=u8q(q),G=A8q(A,F);if(typeof G.parse!=="function")throw TypeError('expected "'+A+'.parse" to be a function');return G.parse(u,F)}});var Om6=I((nbF,Jm6)=>{var q8q=ZA("fs"),F8q=wf6(),I92=_EA(),G8q=T92(),Um6=Gm6(),w8q=D92(),g8q=Qm6(),Q8q=Km6(),_m6=Z50();function xX(A,u){if(A==="")return{data:{},content:A,excerpt:"",orig:A};let q=g8q(A),F=xX.cache[q.content];if(!u){if(F)return q=Object.assign({},F),q.orig=F.orig,q;xX.cache[q.content]=q}return j8q(q,u)}function j8q(A,u){let q=I92(u),F=q.delimiters[0],G=`
|
|
1847
1847
|
`+q.delimiters[1],w=A.content;if(q.language)A.language=q.language;let g=F.length;if(!_m6.startsWith(w,F,g))return Um6(A,q),A;if(w.charAt(g)===F.slice(-1))return A;w=w.slice(g);let Q=w.length,j=xX.language(w,q);if(j.name)A.language=j.name,w=w.slice(j.raw.length);let K=w.indexOf(G);if(K===-1)K=Q;if(A.matter=w.slice(0,K),A.matter.replace(/^\s*#[^\n]+/gm,"").trim()==="")A.isEmpty=!0,A.empty=A.content,A.data={};else A.data=Q8q(A.language,A.matter,q);if(K===Q)A.content="";else{if(A.content=w.slice(K+G.length),A.content[0]==="\r")A.content=A.content.slice(1);if(A.content[0]===`
|
|
1848
1848
|
`)A.content=A.content.slice(1)}if(Um6(A,q),q.sections===!0||typeof q.section==="function")F8q(A,q.section);return A}xX.engines=w8q;xX.stringify=function(A,u,q){if(typeof A==="string")A=xX(A,q);return G8q(A,u,q)};xX.read=function(A,u){let q=q8q.readFileSync(A,"utf8"),F=xX(q,u);return F.path=A,F};xX.test=function(A,u){return _m6.startsWith(A,I92(u).delimiters[0])};xX.language=function(A,u){let F=I92(u).delimiters[0];if(xX.test(A))A=A.slice(F.length);let G=A.slice(0,A.search(/\r?\n/));return{raw:G,name:G?G.trim():""}};xX.cache={};xX.clearCache=function(){xX.cache={}};Jm6.exports=xX});var RT={};bA(RT,{shell:()=>U8q,parse:()=>tFA,files:()=>K8q,fallbackSanitization:()=>Ym6,SHELL_REGEX:()=>Xm6,FrontmatterError:()=>oe,FILE_REGEX:()=>Wm6});function K8q(A){return Array.from(A.matchAll(Wm6))}function U8q(A){return Array.from(A.matchAll(Xm6))}function Ym6(A){let u=A.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!u)return A;let q=u[1],F=q.split(/\r?\n/),G=[];for(let g of F){if(g.trim().startsWith("#")||g.trim()===""){G.push(g);continue}if(g.match(/^\s+/)){G.push(g);continue}let Q=g.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\s*:\s*(.*)$/);if(!Q){G.push(g);continue}let j=Q[1],K=Q[2].trim();if(K===""||K===">"||K==="|"||K.startsWith('"')||K.startsWith("'")){G.push(g);continue}if(K.includes(":")){G.push(`${j}: |-`),G.push(` ${K}`);continue}G.push(g)}let w=G.join(`
|
|
1849
|
-
`);return A.replace(q,()=>w)}async function tFA(A){let u=await q1.readText(A);try{return k92.default(u)}catch{try{return k92.default(Ym6(u))}catch(q){throw new oe({path:A,message:`${A}: Failed to parse YAML frontmatter: ${q instanceof Error?q.message:String(q)}`},{cause:q})}}}var k92,Wm6,Xm6,oe;var H50=k(async()=>{Xg();Xu();await Z1();k92=u2(Om6(),1),Wm6=/(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g,Xm6=/!`([^`]+)`/g;oe=d6.create("ConfigFrontmatterError",J.object({path:J.string(),message:J.string()}))});var Wi;var JEA=k(()=>{i0();Xu();Mu();z5();Wi=L.String.annotate({[Y8]:NA.string().meta({$ref:"https://models.dev/model-schema.json#/$defs/Model"})}).pipe(y0((A)=>({zod:B0(A)})))});var Xi={};bA(Xi,{Rule:()=>A7,Object:()=>Vm6,Info:()=>O8q,ConfigPermission:()=>Xi,Action:()=>h_});var h_,Vm6,A7,Zm6,_8q,Hm6=(A)=>typeof A==="string"?{"*":A}:A,J8q,O8q;var OEA=k(()=>{OEA();i0();Xu();Mu();z5();h_=L.Literals(["ask","allow","deny"]).annotate({identifier:"PermissionActionConfig"}).pipe(y0((A)=>({zod:B0(A)}))),Vm6=L.Record(L.String,h_).annotate({identifier:"PermissionObjectConfig"}).pipe(y0((A)=>({zod:B0(A)}))),A7=L.Union([h_,Vm6]).annotate({identifier:"PermissionRuleConfig"}).pipe(y0((A)=>({zod:B0(A)}))),Zm6=L.StructWithRest(L.Struct({read:L.optional(A7),edit:L.optional(A7),glob:L.optional(A7),grep:L.optional(A7),list:L.optional(A7),project:L.optional(A7),tools:L.optional(A7),git:L.optional(A7),forge:L.optional(A7),bash:L.optional(A7),task:L.optional(A7),external_directory:L.optional(A7),todowrite:L.optional(h_),question:L.optional(h_),webfetch:L.optional(h_),websearch:L.optional(h_),codesearch:L.optional(h_),lsp:L.optional(A7),doom_loop:L.optional(h_),skill:L.optional(A7)}),[L.Record(L.String,A7)]),_8q=L.Union([h_,Zm6]),J8q=NA.union([B0(h_),NA.intersection(NA.record(NA.string(),B0(A7)),NA.object({read:B0(A7).optional(),edit:B0(A7).optional(),glob:B0(A7).optional(),grep:B0(A7).optional(),list:B0(A7).optional(),project:B0(A7).optional(),tools:B0(A7).optional(),git:B0(A7).optional(),forge:B0(A7).optional(),bash:B0(A7).optional(),task:B0(A7).optional(),external_directory:B0(A7).optional(),todowrite:B0(h_).optional(),question:B0(h_).optional(),webfetch:B0(h_).optional(),websearch:B0(h_).optional(),codesearch:B0(h_).optional(),lsp:B0(A7).optional(),doom_loop:B0(h_).optional(),skill:B0(A7).optional()}).catchall(B0(A7)))]).transform(Hm6),O8q=_8q.pipe(L.decodeTo(Zm6,{decode:fY.transform(Hm6),encode:fY.passthrough({strict:!1})})).annotate({identifier:"PermissionConfig"}).annotate({[Y8]:J8q}).pipe(y0((A)=>({zod:B0(A)})))});var WEA={};bA(WEA,{Session:()=>x6});var Jj=k(async()=>{await DT()});var Yi={};bA(Yi,{loadMode:()=>H8q,load:()=>Z8q,Info:()=>S92,ConfigAgent:()=>Yi});async function Z8q(A){let u={};for(let q of await Ow.scan("{agent,agents}/**/*.md",{cwd:A,absolute:!0,dot:!0,symlink:!0})){let F=await tFA(q).catch(async(j)=>{let K=oe.isInstance(j)?j.data.message:`Failed to parse agent ${q}`,{Session:U}=await Jj().then(() => WEA);m1.publish(U.Event.Error,{error:new d6.Unknown({message:K}).toObject()}),Nm6.error("failed to load agent",{agent:q,err:j});return});if(!F)continue;let g={name:FEA(q,["/.codeplane/agent/","/.codeplane/agents/","/agent/","/agents/"]),...F.data,prompt:F.content.trim()},Q=S92.safeParse(g);if(Q.success){u[g.name]=Q.data;continue}throw new LC({path:q,issues:Q.error.issues},{cause:Q.error})}return u}async function H8q(A){let u={};for(let q of await Ow.scan("{mode,modes}/*.md",{cwd:A,absolute:!0,dot:!0,symlink:!0})){let F=await tFA(q).catch(async(g)=>{let Q=oe.isInstance(g)?g.data.message:`Failed to parse mode ${q}`,{Session:j}=await Jj().then(() => WEA);m1.publish(j.Event.Error,{error:new d6.Unknown({message:Q}).toObject()}),Nm6.error("failed to load mode",{mode:q,err:g});return});if(!F)continue;let G={name:FEA(q,[]),...F.data,prompt:F.content.trim()},w=S92.safeParse(G);if(w.success)u[G.name]={...w.data,mode:"primary"}}return u}var Nm6,W8q,X8q,Y8q,V8q=(A)=>{let u={...A.options};for(let[G,w]of Object.entries(A))if(!Y8q.has(G))u[G]=w;let q={};for(let[G,w]of Object.entries(A.tools??{})){let g=w?"allow":"deny";if(G==="write"||G==="edit"||G==="patch"){q.edit=g;continue}q[G]=g}globalThis.Object.assign(q,A.permission);let F=A.steps??A.maxSteps;return{...A,options:u,permission:q,...F!==void 0?{steps:F}:{}}},S92;var N50=k(async()=>{i0();Mu();z5();Xg();KE();_92();Nv();JEA();OEA();await N0([N50(),y8(),Z1(),H50()]);Nm6=Q2.create({service:"config"}),W8q=L.Union([L.String.check(L.isPattern(/^#[0-9a-fA-F]{6}$/)),L.Literals(["primary","secondary","accent","success","warning","error","info"])]),X8q=L.StructWithRest(L.Struct({model:L.optional(Wi),variant:L.optional(L.String).annotate({description:"Default model variant for this agent (applies only when using the agent's configured model)."}),temperature:L.optional(L.Number),top_p:L.optional(L.Number),prompt:L.optional(L.String),tools:L.optional(L.Record(L.String,L.Boolean)).annotate({description:"@deprecated Use 'permission' field instead"}),disable:L.optional(L.Boolean),description:L.optional(L.String).annotate({description:"Description of when to use the agent"}),mode:L.optional(L.Literals(["subagent","primary","all"])),hidden:L.optional(L.Boolean).annotate({description:"Hide this subagent from the @ autocomplete menu (default: false, only applies to mode: subagent)"}),options:L.optional(L.Record(L.String,L.Any)),color:L.optional(W8q).annotate({description:"Hex color code (e.g., #FF5733) or theme color (e.g., primary)"}),steps:L.optional(uV).annotate({description:"Maximum number of agentic iterations before forcing text-only response"}),maxSteps:L.optional(uV).annotate({description:"@deprecated Use 'steps' field instead."}),permission:L.optional(Xi.Info)}),[L.Record(L.String,L.Any)]),Y8q=new Set(["name","model","variant","prompt","description","temperature","top_p","mode","hidden","color","steps","maxSteps","options","permission","disable","tools"]),S92=B0(X8q).transform(V8q).meta({ref:"AgentConfig"})});var se={};bA(se,{load:()=>B8q,Info:()=>Bm6,ConfigCommand:()=>se});async function B8q(A){let u={};for(let q of await Ow.scan("{command,commands}/**/*.md",{cwd:A,absolute:!0,dot:!0,symlink:!0})){let F=await tFA(q).catch(async(j)=>{let K=oe.isInstance(j)?j.data.message:`Failed to parse command ${q}`,{Session:U}=await Jj().then(() => WEA);m1.publish(U.Event.Error,{error:new d6.Unknown({message:K}).toObject()}),N8q.error("failed to load command",{command:q,err:j});return});if(!F)continue;let g={name:FEA(q,["/.codeplane/command/","/.codeplane/commands/","/command/","/commands/"]),...F.data,template:F.content.trim()},Q=Bm6.zod.safeParse(g);if(Q.success){u[g.name]=Q.data;continue}throw new LC({path:q,issues:Q.error.issues},{cause:Q.error})}return u}var N8q,Bm6;var B50=k(async()=>{i0();Xg();KE();Mu();z5();_92();Nv();JEA();await N0([B50(),Z1(),y8(),H50()]);N8q=Q2.create({service:"config"}),Bm6=L.Struct({template:L.String,description:L.optional(L.String),agent:L.optional(L.String),model:L.optional(Wi),subtask:L.optional(L.Boolean)}).pipe(y0((A)=>({zod:B0(A)})))});var yFA={};bA(yFA,{Info:()=>$8q,ConfigCommit:()=>yFA});var $8q;var $50=k(()=>{$50();i0();Mu();z5();$8q=L.Struct({coauthor:L.optional(L.Boolean).annotate({description:"When true, commits made through Codeplane include Co-Authored-By: codeplane-agent[bot] <287208015+codeplane-agent[bot]@users.noreply.github.com>."})}).annotate({identifier:"CommitConfig"}).pipe(y0((A)=>({zod:B0(A)})))});var vFA={};bA(vFA,{Info:()=>M8q,Entry:()=>$m6,ConfigFormatter:()=>vFA});var $m6,M8q;var M50=k(()=>{M50();i0();Mu();z5();$m6=L.Struct({disabled:L.optional(L.Boolean),command:L.optional(L.mutable(L.Array(L.String))),environment:L.optional(L.Record(L.String,L.String)),extensions:L.optional(L.mutable(L.Array(L.String)))}).pipe(y0((A)=>({zod:B0(A)}))),M8q=L.Union([L.Boolean,L.Record(L.String,$m6)]).pipe(y0((A)=>({zod:B0(A)})))});var lFA={};bA(lFA,{Provider:()=>Mm6,Instance:()=>Em6,Info:()=>L8q,Credential:()=>Lm6,ConfigGit:()=>lFA});var Mm6,Lm6,Em6,L8q;var L50=k(()=>{L50();i0();Mu();z5();Mm6=L.Literals(["github","gitlab","bitbucket","azure-devops","generic"]).annotate({identifier:"GitProviderConfig"}).pipe(y0((A)=>({zod:B0(A)}))),Lm6=L.Struct({type:L.optional(L.Literals(["stored","env","ssh","none"])),key:L.optional(L.String).annotate({description:"Key in the local codeplane auth store, usually git:<instance-name>"}),env:L.optional(L.String).annotate({description:"Environment variable containing the token/password for this Git host"}),username:L.optional(L.String).annotate({description:"Username used with HTTPS basic auth. Defaults to oauth2 for GitLab and x-access-token otherwise."}),sshCommand:L.optional(L.String).annotate({description:"Optional GIT_SSH_COMMAND for SSH remotes, for example ssh -i ~/.ssh/id_ed25519"})}).annotate({identifier:"GitCredentialConfig"}).pipe(y0((A)=>({zod:B0(A)}))),Em6=L.Struct({url:L.String.annotate({description:"Base URL for the Git host, for example https://github.com or https://gitlab.example.com"}),provider:L.optional(Mm6),hosts:L.optional(L.mutable(L.Array(L.String))).annotate({description:"Additional hostnames that should match this instance"}),defaultRemote:L.optional(L.String).annotate({description:"Preferred remote name for operations that need a remote"}),credential:L.optional(Lm6)}).annotate({identifier:"GitInstanceConfig"}).pipe(y0((A)=>({zod:B0(A)}))),L8q=L.Record(L.String,Em6).annotate({identifier:"GitConfig"}).pipe(y0((A)=>({zod:B0(A)})))});var iFA={};bA(iFA,{Layout:()=>E8q,ConfigLayout:()=>iFA});var E8q;var C92=k(()=>{i0();Mu();z5();C92();E8q=L.Literals(["auto","stretch"]).annotate({identifier:"LayoutConfig"}).pipe(y0((A)=>({zod:B0(A)})))});var cFA={};bA(cFA,{requiresExtensionsForCustomServers:()=>Rm6,Info:()=>x8q,Entry:()=>zm6,Disabled:()=>xm6,ConfigLSP:()=>cFA});var xm6,zm6,Rm6,x8q;var E50=k(async()=>{i0();Mu();z5();await N0([E50(),eu0()]);xm6=L.Struct({disabled:L.Literal(!0)}).pipe(y0((A)=>({zod:B0(A)}))),zm6=L.Union([xm6,L.Struct({command:L.mutable(L.Array(L.String)),extensions:L.optional(L.mutable(L.Array(L.String))),disabled:L.optional(L.Boolean),env:L.optional(L.Record(L.String,L.String)),initialization:L.optional(L.Record(L.String,L.Unknown))})]).pipe(y0((A)=>({zod:B0(A)}))),Rm6=L.makeFilter((A)=>{if(typeof A==="boolean")return;let u=new Set(Object.values(ZFA).map((F)=>F.id));return Object.entries(A).every(([F,G])=>{if("disabled"in G&&G.disabled)return!0;if(u.has(F))return!0;return"extensions"in G&&Boolean(G.extensions)})?void 0:"For custom LSP servers, 'extensions' array is required."}),x8q=L.Union([L.Boolean,L.Record(L.String,zm6)]).check(Rm6).pipe(y0((A)=>({zod:B0(A)})))});var ee={};bA(ee,{readManagedPreferences:()=>I8q,parseManagedPlist:()=>Tm6,managedConfigDir:()=>T8q,ConfigManaged:()=>ee});import{existsSync as z8q}from"fs";import R8q from"os";import f92 from"path";function P8q(){switch(process.platform){case"darwin":return"/Library/Application Support/Codeplane";case"win32":return f92.join(process.env.ProgramData||"C:\\ProgramData","Codeplane");default:return"/etc/Codeplane"}}function T8q(){return process.env.CODEPLANE_TEST_MANAGED_CONFIG_DIR||P8q()}function Tm6(A){let u=JSON.parse(A);for(let q of Object.keys(u))if(D8q.has(q))delete u[q];return JSON.stringify(u)}async function I8q(){if(process.platform!=="darwin")return;let A=R8q.userInfo().username,u=[f92.join("/Library/Managed Preferences",A,`${Pm6}.plist`),f92.join("/Library/Managed Preferences",`${Pm6}.plist`)];for(let q of u){if(!z8q(q))continue;Dm6.info("reading macOS managed preferences",{path:q});let F=await jq.run(["plutil","-convert","json","-o","-",q],{nothrow:!0});if(F.code!==0){Dm6.warn("failed to convert managed preferences plist",{path:q});continue}return{source:`mobileconfig:${q}`,text:Tm6(F.stdout.toString())}}return}var Dm6,Pm6="cc.codeplane.managed",D8q;var x50=k(async()=>{await N0([x50(),Z1()]);Dm6=Q2.create({service:"config"}),D8q=new Set(["PayloadDisplayName","PayloadIdentifier","PayloadType","PayloadUUID","PayloadVersion","_manualProfile"])});var Vi={};bA(Vi,{Remote:()=>Sm6,OAuth:()=>km6,Local:()=>Im6,Info:()=>k8q,ConfigMCP:()=>Vi});var Im6,km6,Sm6,k8q;var XEA=k(()=>{i0();Mu();z5();XEA();Im6=L.Struct({type:L.Literal("local").annotate({description:"Type of MCP server connection"}),command:L.mutable(L.Array(L.String)).annotate({description:"Command and arguments to run the MCP server"}),environment:L.optional(L.Record(L.String,L.String)).annotate({description:"Environment variables to set when running the MCP server"}),enabled:L.optional(L.Boolean).annotate({description:"Enable or disable the MCP server on startup"}),timeout:L.optional(L.Number).annotate({description:"Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified."})}).annotate({identifier:"McpLocalConfig"}).pipe(y0((A)=>({zod:B0(A)}))),km6=L.Struct({clientId:L.optional(L.String).annotate({description:"OAuth client ID. If not provided, dynamic client registration (RFC 7591) will be attempted."}),clientSecret:L.optional(L.String).annotate({description:"OAuth client secret (if required by the authorization server)"}),scope:L.optional(L.String).annotate({description:"OAuth scopes to request during authorization"}),redirectUri:L.optional(L.String).annotate({description:"OAuth redirect URI (default: http://127.0.0.1:19876/mcp/oauth/callback)."})}).annotate({identifier:"McpOAuthConfig"}).pipe(y0((A)=>({zod:B0(A)}))),Sm6=L.Struct({type:L.Literal("remote").annotate({description:"Type of MCP server connection"}),url:L.String.annotate({description:"URL of the remote MCP server"}),enabled:L.optional(L.Boolean).annotate({description:"Enable or disable the MCP server on startup"}),headers:L.optional(L.Record(L.String,L.String)).annotate({description:"Headers to send with the request"}),oauth:L.optional(L.Union([km6,L.Literal(!1)])).annotate({description:"OAuth authentication configuration for the MCP server. Set to false to disable OAuth auto-detection."}),timeout:L.optional(L.Number).annotate({description:"Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified."})}).annotate({identifier:"McpRemoteConfig"}).pipe(y0((A)=>({zod:B0(A)}))),k8q=L.Union([Im6,Sm6]).annotate({discriminator:"type"}).pipe(y0((A)=>({zod:B0(A)})))});var dFA={};bA(dFA,{Registry:()=>fm6,Info:()=>S8q,ConfigNpm:()=>dFA,Client:()=>Cm6});var Cm6,fm6,S8q;var z50=k(()=>{z50();i0();Mu();z5();Cm6=L.Literals(["auto","npm","pnpm","bun","yarn"]).pipe(y0((A)=>({zod:B0(A)}))),fm6=L.Struct({registry:L.optional(L.String),token:L.optional(L.String),always_auth:L.optional(L.Boolean)}).pipe(y0((A)=>({zod:B0(A)}))),S8q=L.Struct({client:L.optional(Cm6),registry:L.optional(L.String),token:L.optional(L.String),always_auth:L.optional(L.Boolean),scopes:L.optional(L.Record(L.String,fm6))}).pipe(y0((A)=>({zod:B0(A)})))});var nFA={};bA(nFA,{Model:()=>hm6,Info:()=>C8q,ConfigProvider:()=>nFA});var hm6,C8q;var R50=k(()=>{i0();Mu();z5();R50();hm6=L.Struct({id:L.optional(L.String),name:L.optional(L.String),family:L.optional(L.String),release_date:L.optional(L.String),attachment:L.optional(L.Boolean),reasoning:L.optional(L.Boolean),temperature:L.optional(L.Boolean),tool_call:L.optional(L.Boolean),interleaved:L.optional(L.Union([L.Literal(!0),L.Struct({field:L.Literals(["reasoning_content","reasoning_details"])})])),cost:L.optional(L.Struct({input:L.Number,output:L.Number,cache_read:L.optional(L.Number),cache_write:L.optional(L.Number),context_over_200k:L.optional(L.Struct({input:L.Number,output:L.Number,cache_read:L.optional(L.Number),cache_write:L.optional(L.Number)}))})),limit:L.optional(L.Struct({context:L.Number,input:L.optional(L.Number),output:L.Number})),modalities:L.optional(L.Struct({input:L.mutable(L.Array(L.Literals(["text","audio","image","video","pdf"]))),output:L.mutable(L.Array(L.Literals(["text","audio","image","video","pdf"])))})),experimental:L.optional(L.Boolean),status:L.optional(L.Literals(["alpha","beta","deprecated"])),provider:L.optional(L.Struct({npm:L.optional(L.String),api:L.optional(L.String)})),options:L.optional(L.Record(L.String,L.Any)),headers:L.optional(L.Record(L.String,L.String)),variants:L.optional(L.Record(L.String,L.StructWithRest(L.Struct({disabled:L.optional(L.Boolean).annotate({description:"Disable this variant for the model"})}),[L.Record(L.String,L.Any)])).annotate({description:"Variant-specific configuration"}))}).pipe(y0((A)=>({zod:B0(A)}))),C8q=L.Struct({api:L.optional(L.String),name:L.optional(L.String),env:L.optional(L.mutable(L.Array(L.String))),id:L.optional(L.String),npm:L.optional(L.String),whitelist:L.optional(L.mutable(L.Array(L.String))),blacklist:L.optional(L.mutable(L.Array(L.String))),options:L.optional(L.StructWithRest(L.Struct({apiKey:L.optional(L.String),baseURL:L.optional(L.String),enterpriseUrl:L.optional(L.String).annotate({description:"GitHub Enterprise URL for copilot authentication"}),setCacheKey:L.optional(L.Boolean).annotate({description:"Enable promptCacheKey for this provider (default false)"}),timeout:L.optional(L.Union([uV,L.Literal(!1)]).annotate({description:"Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout."})).annotate({description:"Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout."}),chunkTimeout:L.optional(uV).annotate({description:"Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted."})}),[L.Record(L.String,L.Any)])),models:L.optional(L.Record(L.String,hm6))}).annotate({identifier:"ProviderConfig"}).pipe(y0((A)=>({zod:B0(A)})))});var pFA={};bA(pFA,{Server:()=>f8q,ConfigServer:()=>pFA});var f8q;var h92=k(()=>{i0();Mu();z5();h92();f8q=L.Struct({port:L.optional(uV).annotate({description:"Port to listen on"}),hostname:L.optional(L.String).annotate({description:"Hostname to listen on"}),mdns:L.optional(L.Boolean).annotate({description:"Enable mDNS service discovery"}),mdnsDomain:L.optional(L.String).annotate({description:"Custom domain name for mDNS service (default: codeplane.local)"}),cors:L.optional(L.mutable(L.Array(L.String))).annotate({description:"Additional domains to allow for CORS"})}).annotate({identifier:"ServerConfig"}).pipe(y0((A)=>({zod:B0(A)})))});var aFA={};bA(aFA,{Info:()=>h8q,ConfigSkills:()=>aFA});var h8q;var D50=k(()=>{i0();Mu();z5();D50();h8q=L.Struct({paths:L.optional(L.Array(L.String)).annotate({description:"Additional paths to skill folders"}),urls:L.optional(L.Array(L.String)).annotate({description:"URLs to fetch skills from (e.g., https://example.com/.well-known/skills/)"})}).pipe(y0((A)=>({zod:B0(A)})))});var t1={};bA(t1,{layer:()=>ym6,defaultLayer:()=>n8q,Service:()=>k50,Server:()=>y8q,Layout:()=>v8q,Info:()=>I50,ConfigDirectoryTypoError:()=>d8q});import TT from"path";import{pathToFileURL as m8q}from"url";import b8q from"os";import mm6 from"fs/promises";import{existsSync as P50}from"fs";function bm6(A,u){let q=Kq(A,u);if(A.instructions&&u.instructions)q.instructions=Array.from(new Set([...A.instructions,...u.instructions]));return q}async function t8q(A,u){if(!A.plugin)return A;for(let q=0;q<A.plugin.length;q++)A.plugin[q]=await xU.resolvePluginSpec(A.plugin[q],u);return A}function c8q(A){return i8q.map((u)=>TT.join(A,u))}function T50(){return TT.join(U2.Path.config,"codeplane.jsonc")}function tm6(A,u,q=[]){if(!w3(u)){let F=l8A(A,q,u,{formattingOptions:{insertSpaces:!0,tabSize:2}});return i8A(A,F)}return Object.entries(u).reduce((F,[G,w])=>{if(w===void 0)return F;return tm6(F,w,[...q,G])},A)}function YEA(A){let{plugin_origins:u,...q}=A;return q}var PT,y8q,v8q,Oz,l8q,I50,k50,i8q,d8q,ym6,n8q;var vm6=k(async()=>{Xu();rw();Xg();v4();dHA();sj();l$();mC6();U3();i0();Lr0();OqA();Mu();z5();$50();M50();L50();C92();XEA();JEA();z50();c8A();OEA();R50();h92();D50();await N0([Z1(),P3(),LX(),q50(),H8(),PFA(),I5(),N50(),B50(),E50(),x50(),zo(),$e(),gLA(),Sf()]);PT=Q2.create({service:"config"});y8q=pFA.Server.zod,v8q=iFA.Layout.zod,Oz=L.Any.annotate({[Y8]:Yi.Info}),l8q=L.Any.annotate({[Y8]:Q2.Level}),I50=L.Struct({$schema:L.optional(L.String).annotate({description:"JSON schema reference for configuration validation"}),logLevel:L.optional(l8q).annotate({description:"Log level"}),server:L.optional(pFA.Server).annotate({description:"Server configuration for codeplane serve and web commands"}),command:L.optional(L.Record(L.String,se.Info)).annotate({description:"Command configuration, see https://github.com/devinoldenburg/codeplane"}),commit:L.optional(yFA.Info).annotate({description:"Commit behavior for Codeplane-created commits."}),skills:L.optional(aFA.Info).annotate({description:"Additional skill folder paths"}),watcher:L.optional(L.Struct({ignore:L.optional(L.mutable(L.Array(L.String)))})),snapshot:L.optional(L.Boolean).annotate({description:"Enable or disable snapshot tracking. When false, filesystem snapshots are not recorded and undoing or reverting will not undo/redo file changes. Defaults to true."}),plugin:L.optional(L.mutable(L.Array(xU.Spec))),share:L.optional(L.Literals(["manual","auto","disabled"])).annotate({description:"Control sharing behavior:'manual' allows manual sharing via commands, 'auto' enables automatic sharing, 'disabled' disables all sharing"}),autoshare:L.optional(L.Boolean).annotate({description:"@deprecated Use 'share' field instead. Share newly created sessions automatically"}),autoupdate:L.optional(L.Union([L.Boolean,L.Literal("notify")])).annotate({description:"Automatically update to the latest version. Set to true to auto-update, false to disable, or 'notify' to show update notifications"}),disabled_providers:L.optional(L.mutable(L.Array(L.String))).annotate({description:"Disable providers that are loaded automatically"}),enabled_providers:L.optional(L.mutable(L.Array(L.String))).annotate({description:"When set, ONLY these providers will be enabled. All other providers will be ignored"}),model:L.optional(Wi).annotate({description:"Model to use in the format of provider/model, eg anthropic/claude-2"}),npm:L.optional(dFA.Info).annotate({description:"Native npm registry, auth, and package-manager integration settings"}),small_model:L.optional(Wi).annotate({description:"Small model to use for tasks like title generation in the format of provider/model"}),default_agent:L.optional(L.String).annotate({description:"Default agent to use when none is specified. Must be a primary agent. Falls back to 'build' if not set or if the specified agent is invalid."}),username:L.optional(L.String).annotate({description:"Custom username to display in conversations instead of system username"}),mode:L.optional(L.StructWithRest(L.Struct({build:L.optional(Oz),plan:L.optional(Oz)}),[L.Record(L.String,Oz)])).annotate({description:"@deprecated Use `agent` field instead."}),agent:L.optional(L.StructWithRest(L.Struct({plan:L.optional(Oz),build:L.optional(Oz),general:L.optional(Oz),explore:L.optional(Oz),title:L.optional(Oz),summary:L.optional(Oz),compaction:L.optional(Oz)}),[L.Record(L.String,Oz)])).annotate({description:"Agent configuration, see https://github.com/devinoldenburg/codeplane"}),provider:L.optional(L.Record(L.String,nFA.Info)).annotate({description:"Custom provider configurations and model overrides"}),mcp:L.optional(L.Record(L.String,L.Union([Vi.Info,L.Any.annotate({[Y8]:NA.object({enabled:NA.boolean()}).strict()})]))).annotate({description:"MCP (Model Context Protocol) server configurations"}),formatter:L.optional(vFA.Info),git:L.optional(lFA.Info).annotate({description:"Named Git host configuration for native git tool operations and credentials"}),lsp:L.optional(cFA.Info),instructions:L.optional(L.mutable(L.Array(L.String))).annotate({description:"Additional instruction files or patterns to include"}),layout:L.optional(iFA.Layout).annotate({description:"@deprecated Always uses stretch layout."}),permission:L.optional(Xi.Info),tools:L.optional(L.Record(L.String,L.Boolean)),enterprise:L.optional(L.Struct({url:L.optional(L.String).annotate({description:"Enterprise URL"})})),tool_output:L.optional(L.Struct({max_lines:L.optional(uV).annotate({description:"Maximum lines of tool output before it is truncated and saved to disk (default: 2000)"}),max_bytes:L.optional(uV).annotate({description:"Maximum bytes of tool output before it is truncated and saved to disk (default: 51200)"})})).annotate({description:"Thresholds for truncating tool output. When output exceeds either limit, the full text is written to the truncation directory and a preview is returned."}),compaction:L.optional(L.Struct({auto:L.optional(L.Boolean).annotate({description:"Enable automatic compaction when context is full (default: true)"}),prune:L.optional(L.Boolean).annotate({description:"Enable pruning of old tool outputs (default: true)"}),tail_turns:L.optional(BC).annotate({description:"Number of recent user turns, including their following assistant/tool responses, to keep verbatim during compaction (default: 2)"}),preserve_recent_tokens:L.optional(BC).annotate({description:"Maximum number of tokens from recent turns to preserve verbatim after compaction"}),reserved:L.optional(BC).annotate({description:"Token buffer for compaction. Leaves enough window to avoid overflow during compaction."})})),experimental:L.optional(L.Struct({disable_paste_summary:L.optional(L.Boolean),batch_tool:L.optional(L.Boolean).annotate({description:"Enable the batch tool"}),openTelemetry:L.optional(L.Boolean).annotate({description:"Enable OpenTelemetry spans for AI SDK calls (using the 'experimental_telemetry' flag)"}),primary_tools:L.optional(L.mutable(L.Array(L.String))).annotate({description:"Tools that should only be available to primary agents."}),continue_loop_on_deny:L.optional(L.Boolean).annotate({description:"Continue the agent loop when a tool call is denied"}),mcp_timeout:L.optional(uV).annotate({description:"Timeout in milliseconds for model context protocol (MCP) requests"})}))}).annotate({identifier:"Config"}).pipe(y0((A)=>({zod:B0(A).strict().meta({ref:"Config"})})));k50=class k50 extends m0.Service()("@codeplane/Config"){};i8q=["codeplane.jsonc","codeplane.json","config.json"];d8q=d6.create("ConfigDirectoryTypoError",NA.object({path:NA.string(),dir:NA.string(),suggestion:NA.string()})),ym6=fA.effect(k50,R.gen(function*(){let A=yield*P2.Service,u=yield*l8.Service,q=yield*EX.Service,F=yield*sf.Service,G=yield*h7.Service,w=R.fnUntraced(function*(x){return yield*A.readFileString(x).pipe(R.catchIf(($)=>$.reason._tag==="NotFound",()=>R.succeed(void 0)),R.orDie)}),g=R.fnUntraced(function*(x,$){let E="path"in $?$.path:$.source,z=yield*R.promise(()=>ll.substitute("path"in $?{text:x,type:"path",path:$.path}:{text:x,type:"virtual",...$})),T=gO.jsonc(z,E),D=gO.schema(I50.zod,T,E);if(!("path"in $))return D;if(yield*R.promise(()=>t8q(D,$.path)),!D.$schema){D.$schema="https://example.invalid/config.json";let C=x.replace(/^\s*\{/,`{
|
|
1849
|
+
`);return A.replace(q,()=>w)}async function tFA(A){let u=await q1.readText(A);try{return k92.default(u)}catch{try{return k92.default(Ym6(u))}catch(q){throw new oe({path:A,message:`${A}: Failed to parse YAML frontmatter: ${q instanceof Error?q.message:String(q)}`},{cause:q})}}}var k92,Wm6,Xm6,oe;var H50=k(async()=>{Xg();Xu();await Z1();k92=u2(Om6(),1),Wm6=/(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g,Xm6=/!`([^`]+)`/g;oe=d6.create("ConfigFrontmatterError",J.object({path:J.string(),message:J.string()}))});var Wi;var JEA=k(()=>{i0();Xu();Mu();z5();Wi=L.String.annotate({[Y8]:NA.string().meta({$ref:"https://models.dev/model-schema.json#/$defs/Model"})}).pipe(y0((A)=>({zod:B0(A)})))});var Xi={};bA(Xi,{Rule:()=>A7,Object:()=>Vm6,Info:()=>O8q,ConfigPermission:()=>Xi,Action:()=>h_});var h_,Vm6,A7,Zm6,_8q,Hm6=(A)=>typeof A==="string"?{"*":A}:A,J8q,O8q;var OEA=k(()=>{OEA();i0();Xu();Mu();z5();h_=L.Literals(["ask","allow","deny"]).annotate({identifier:"PermissionActionConfig"}).pipe(y0((A)=>({zod:B0(A)}))),Vm6=L.Record(L.String,h_).annotate({identifier:"PermissionObjectConfig"}).pipe(y0((A)=>({zod:B0(A)}))),A7=L.Union([h_,Vm6]).annotate({identifier:"PermissionRuleConfig"}).pipe(y0((A)=>({zod:B0(A)}))),Zm6=L.StructWithRest(L.Struct({read:L.optional(A7),edit:L.optional(A7),glob:L.optional(A7),grep:L.optional(A7),list:L.optional(A7),project:L.optional(A7),tools:L.optional(A7),git:L.optional(A7),forge:L.optional(A7),bash:L.optional(A7),task:L.optional(A7),external_directory:L.optional(A7),todowrite:L.optional(h_),question:L.optional(h_),webfetch:L.optional(h_),websearch:L.optional(h_),codesearch:L.optional(h_),lsp:L.optional(A7),doom_loop:L.optional(h_),skill:L.optional(A7)}),[L.Record(L.String,A7)]),_8q=L.Union([h_,Zm6]),J8q=NA.union([B0(h_),NA.intersection(NA.record(NA.string(),B0(A7)),NA.object({read:B0(A7).optional(),edit:B0(A7).optional(),glob:B0(A7).optional(),grep:B0(A7).optional(),list:B0(A7).optional(),project:B0(A7).optional(),tools:B0(A7).optional(),git:B0(A7).optional(),forge:B0(A7).optional(),bash:B0(A7).optional(),task:B0(A7).optional(),external_directory:B0(A7).optional(),todowrite:B0(h_).optional(),question:B0(h_).optional(),webfetch:B0(h_).optional(),websearch:B0(h_).optional(),codesearch:B0(h_).optional(),lsp:B0(A7).optional(),doom_loop:B0(h_).optional(),skill:B0(A7).optional()}).catchall(B0(A7)))]).transform(Hm6),O8q=_8q.pipe(L.decodeTo(Zm6,{decode:fY.transform(Hm6),encode:fY.passthrough({strict:!1})})).annotate({identifier:"PermissionConfig"}).annotate({[Y8]:J8q}).pipe(y0((A)=>({zod:B0(A)})))});var WEA={};bA(WEA,{Session:()=>x6});var Jj=k(async()=>{await DT()});var Yi={};bA(Yi,{loadMode:()=>H8q,load:()=>Z8q,Info:()=>S92,ConfigAgent:()=>Yi});async function Z8q(A){let u={};for(let q of await Ow.scan("{agent,agents}/**/*.md",{cwd:A,absolute:!0,dot:!0,symlink:!0})){let F=await tFA(q).catch(async(j)=>{let K=oe.isInstance(j)?j.data.message:`Failed to parse agent ${q}`,{Session:U}=await Jj().then(() => WEA);m1.publish(U.Event.Error,{error:new d6.Unknown({message:K}).toObject()}),Nm6.error("failed to load agent",{agent:q,err:j});return});if(!F)continue;let g={name:FEA(q,["/.codeplane/agent/","/.codeplane/agents/","/agent/","/agents/"]),...F.data,prompt:F.content.trim()},Q=S92.safeParse(g);if(Q.success){u[g.name]=Q.data;continue}throw new LC({path:q,issues:Q.error.issues},{cause:Q.error})}return u}async function H8q(A){let u={};for(let q of await Ow.scan("{mode,modes}/*.md",{cwd:A,absolute:!0,dot:!0,symlink:!0})){let F=await tFA(q).catch(async(g)=>{let Q=oe.isInstance(g)?g.data.message:`Failed to parse mode ${q}`,{Session:j}=await Jj().then(() => WEA);m1.publish(j.Event.Error,{error:new d6.Unknown({message:Q}).toObject()}),Nm6.error("failed to load mode",{mode:q,err:g});return});if(!F)continue;let G={name:FEA(q,[]),...F.data,prompt:F.content.trim()},w=S92.safeParse(G);if(w.success)u[G.name]={...w.data,mode:"primary"}}return u}var Nm6,W8q,X8q,Y8q,V8q=(A)=>{let u={...A.options};for(let[G,w]of Object.entries(A))if(!Y8q.has(G))u[G]=w;let q={};for(let[G,w]of Object.entries(A.tools??{})){let g=w?"allow":"deny";if(G==="write"||G==="edit"||G==="patch"){q.edit=g;continue}q[G]=g}globalThis.Object.assign(q,A.permission);let F=A.steps??A.maxSteps;return{...A,options:u,permission:q,...F!==void 0?{steps:F}:{}}},S92;var N50=k(async()=>{i0();Mu();z5();Xg();KE();_92();Nv();JEA();OEA();await N0([N50(),y8(),Z1(),H50()]);Nm6=Q2.create({service:"config"}),W8q=L.Union([L.String.check(L.isPattern(/^#[0-9a-fA-F]{6}$/)),L.Literals(["primary","secondary","accent","success","warning","error","info"])]),X8q=L.StructWithRest(L.Struct({model:L.optional(Wi),variant:L.optional(L.String).annotate({description:"Default model variant for this agent (applies only when using the agent's configured model)."}),temperature:L.optional(L.Number),top_p:L.optional(L.Number),prompt:L.optional(L.String),tools:L.optional(L.Record(L.String,L.Boolean)).annotate({description:"@deprecated Use 'permission' field instead"}),disable:L.optional(L.Boolean),description:L.optional(L.String).annotate({description:"Description of when to use the agent"}),mode:L.optional(L.Literals(["subagent","primary","all"])),hidden:L.optional(L.Boolean).annotate({description:"Hide this subagent from the @ autocomplete menu (default: false, only applies to mode: subagent)"}),options:L.optional(L.Record(L.String,L.Any)),color:L.optional(W8q).annotate({description:"Hex color code (e.g., #FF5733) or theme color (e.g., primary)"}),steps:L.optional(uV).annotate({description:"Maximum number of agentic iterations before forcing text-only response"}),maxSteps:L.optional(uV).annotate({description:"@deprecated Use 'steps' field instead."}),permission:L.optional(Xi.Info)}),[L.Record(L.String,L.Any)]),Y8q=new Set(["name","model","variant","prompt","description","temperature","top_p","mode","hidden","color","steps","maxSteps","options","permission","disable","tools"]),S92=B0(X8q).transform(V8q).meta({ref:"AgentConfig"})});var se={};bA(se,{load:()=>B8q,Info:()=>Bm6,ConfigCommand:()=>se});async function B8q(A){let u={};for(let q of await Ow.scan("{command,commands}/**/*.md",{cwd:A,absolute:!0,dot:!0,symlink:!0})){let F=await tFA(q).catch(async(j)=>{let K=oe.isInstance(j)?j.data.message:`Failed to parse command ${q}`,{Session:U}=await Jj().then(() => WEA);m1.publish(U.Event.Error,{error:new d6.Unknown({message:K}).toObject()}),N8q.error("failed to load command",{command:q,err:j});return});if(!F)continue;let g={name:FEA(q,["/.codeplane/command/","/.codeplane/commands/","/command/","/commands/"]),...F.data,template:F.content.trim()},Q=Bm6.zod.safeParse(g);if(Q.success){u[g.name]=Q.data;continue}throw new LC({path:q,issues:Q.error.issues},{cause:Q.error})}return u}var N8q,Bm6;var B50=k(async()=>{i0();Xg();KE();Mu();z5();_92();Nv();JEA();await N0([B50(),Z1(),y8(),H50()]);N8q=Q2.create({service:"config"}),Bm6=L.Struct({template:L.String,description:L.optional(L.String),agent:L.optional(L.String),model:L.optional(Wi),subtask:L.optional(L.Boolean)}).pipe(y0((A)=>({zod:B0(A)})))});var yFA={};bA(yFA,{Info:()=>$8q,ConfigCommit:()=>yFA});var $8q;var $50=k(()=>{$50();i0();Mu();z5();$8q=L.Struct({coauthor:L.optional(L.Boolean).annotate({description:"When true, commits made through Codeplane include Co-Authored-By: codeplane-agent[bot] <287208015+codeplane-agent[bot]@users.noreply.github.com>."})}).annotate({identifier:"CommitConfig"}).pipe(y0((A)=>({zod:B0(A)})))});var vFA={};bA(vFA,{Info:()=>M8q,Entry:()=>$m6,ConfigFormatter:()=>vFA});var $m6,M8q;var M50=k(()=>{M50();i0();Mu();z5();$m6=L.Struct({disabled:L.optional(L.Boolean),command:L.optional(L.mutable(L.Array(L.String))),environment:L.optional(L.Record(L.String,L.String)),extensions:L.optional(L.mutable(L.Array(L.String)))}).pipe(y0((A)=>({zod:B0(A)}))),M8q=L.Union([L.Boolean,L.Record(L.String,$m6)]).pipe(y0((A)=>({zod:B0(A)})))});var lFA={};bA(lFA,{Provider:()=>Mm6,Instance:()=>Em6,Info:()=>L8q,Credential:()=>Lm6,ConfigGit:()=>lFA});var Mm6,Lm6,Em6,L8q;var L50=k(()=>{L50();i0();Mu();z5();Mm6=L.Literals(["github","gitlab","bitbucket","azure-devops","generic"]).annotate({identifier:"GitProviderConfig"}).pipe(y0((A)=>({zod:B0(A)}))),Lm6=L.Struct({type:L.optional(L.Literals(["stored","env","ssh","none"])),key:L.optional(L.String).annotate({description:"Key in the local codeplane auth store, usually git:<instance-name>"}),env:L.optional(L.String).annotate({description:"Environment variable containing the token/password for this Git host"}),username:L.optional(L.String).annotate({description:"Username used with HTTPS basic auth. Defaults to oauth2 for GitLab and x-access-token otherwise."}),sshCommand:L.optional(L.String).annotate({description:"Optional GIT_SSH_COMMAND for SSH remotes, for example ssh -i ~/.ssh/id_ed25519"})}).annotate({identifier:"GitCredentialConfig"}).pipe(y0((A)=>({zod:B0(A)}))),Em6=L.Struct({url:L.String.annotate({description:"Base URL for the Git host, for example https://github.com or https://gitlab.example.com"}),provider:L.optional(Mm6),hosts:L.optional(L.mutable(L.Array(L.String))).annotate({description:"Additional hostnames that should match this instance"}),defaultRemote:L.optional(L.String).annotate({description:"Preferred remote name for operations that need a remote"}),credential:L.optional(Lm6)}).annotate({identifier:"GitInstanceConfig"}).pipe(y0((A)=>({zod:B0(A)}))),L8q=L.Record(L.String,Em6).annotate({identifier:"GitConfig"}).pipe(y0((A)=>({zod:B0(A)})))});var iFA={};bA(iFA,{Layout:()=>E8q,ConfigLayout:()=>iFA});var E8q;var C92=k(()=>{i0();Mu();z5();C92();E8q=L.Literals(["auto","stretch"]).annotate({identifier:"LayoutConfig"}).pipe(y0((A)=>({zod:B0(A)})))});var cFA={};bA(cFA,{requiresExtensionsForCustomServers:()=>Rm6,Info:()=>x8q,Entry:()=>zm6,Disabled:()=>xm6,ConfigLSP:()=>cFA});var xm6,zm6,Rm6,x8q;var E50=k(async()=>{i0();Mu();z5();await N0([E50(),eu0()]);xm6=L.Struct({disabled:L.Literal(!0)}).pipe(y0((A)=>({zod:B0(A)}))),zm6=L.Union([xm6,L.Struct({command:L.mutable(L.Array(L.String)),extensions:L.optional(L.mutable(L.Array(L.String))),disabled:L.optional(L.Boolean),env:L.optional(L.Record(L.String,L.String)),initialization:L.optional(L.Record(L.String,L.Unknown))})]).pipe(y0((A)=>({zod:B0(A)}))),Rm6=L.makeFilter((A)=>{if(typeof A==="boolean")return;let u=new Set(Object.values(ZFA).map((F)=>F.id));return Object.entries(A).every(([F,G])=>{if("disabled"in G&&G.disabled)return!0;if(u.has(F))return!0;return"extensions"in G&&Boolean(G.extensions)})?void 0:"For custom LSP servers, 'extensions' array is required."}),x8q=L.Union([L.Boolean,L.Record(L.String,zm6)]).check(Rm6).pipe(y0((A)=>({zod:B0(A)})))});var ee={};bA(ee,{readManagedPreferences:()=>I8q,parseManagedPlist:()=>Tm6,managedConfigDir:()=>T8q,ConfigManaged:()=>ee});import{existsSync as z8q}from"fs";import R8q from"os";import f92 from"path";function P8q(){switch(process.platform){case"darwin":return"/Library/Application Support/Codeplane";case"win32":return f92.join(process.env.ProgramData||"C:\\ProgramData","Codeplane");default:return"/etc/Codeplane"}}function T8q(){return process.env.CODEPLANE_TEST_MANAGED_CONFIG_DIR||P8q()}function Tm6(A){let u=JSON.parse(A);for(let q of Object.keys(u))if(D8q.has(q))delete u[q];return JSON.stringify(u)}async function I8q(){if(process.platform!=="darwin")return;let A=R8q.userInfo().username,u=[f92.join("/Library/Managed Preferences",A,`${Pm6}.plist`),f92.join("/Library/Managed Preferences",`${Pm6}.plist`)];for(let q of u){if(!z8q(q))continue;Dm6.info("reading macOS managed preferences",{path:q});let F=await jq.run(["plutil","-convert","json","-o","-",q],{nothrow:!0});if(F.code!==0){Dm6.warn("failed to convert managed preferences plist",{path:q});continue}return{source:`mobileconfig:${q}`,text:Tm6(F.stdout.toString())}}return}var Dm6,Pm6="cc.codeplane.managed",D8q;var x50=k(async()=>{await N0([x50(),Z1()]);Dm6=Q2.create({service:"config"}),D8q=new Set(["PayloadDisplayName","PayloadIdentifier","PayloadType","PayloadUUID","PayloadVersion","_manualProfile"])});var Vi={};bA(Vi,{Remote:()=>Sm6,OAuth:()=>km6,Local:()=>Im6,Info:()=>k8q,ConfigMCP:()=>Vi});var Im6,km6,Sm6,k8q;var XEA=k(()=>{i0();Mu();z5();XEA();Im6=L.Struct({type:L.Literal("local").annotate({description:"Type of MCP server connection"}),command:L.mutable(L.Array(L.String)).annotate({description:"Command and arguments to run the MCP server"}),environment:L.optional(L.Record(L.String,L.String)).annotate({description:"Environment variables to set when running the MCP server"}),enabled:L.optional(L.Boolean).annotate({description:"Enable or disable the MCP server on startup"}),timeout:L.optional(L.Number).annotate({description:"Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified."})}).annotate({identifier:"McpLocalConfig"}).pipe(y0((A)=>({zod:B0(A)}))),km6=L.Struct({clientId:L.optional(L.String).annotate({description:"OAuth client ID. If not provided, dynamic client registration (RFC 7591) will be attempted."}),clientSecret:L.optional(L.String).annotate({description:"OAuth client secret (if required by the authorization server)"}),scope:L.optional(L.String).annotate({description:"OAuth scopes to request during authorization"}),callbackPort:L.optional(L.Number).annotate({description:"Local OAuth callback port used when redirectUri is omitted. Defaults to 19876."}),redirectUri:L.optional(L.String).annotate({description:"OAuth redirect URI (default: http://127.0.0.1:19876/mcp/oauth/callback)."})}).annotate({identifier:"McpOAuthConfig"}).pipe(y0((A)=>({zod:B0(A)}))),Sm6=L.Struct({type:L.Literal("remote").annotate({description:"Type of MCP server connection"}),url:L.String.annotate({description:"URL of the remote MCP server"}),enabled:L.optional(L.Boolean).annotate({description:"Enable or disable the MCP server on startup"}),headers:L.optional(L.Record(L.String,L.String)).annotate({description:"Headers to send with the request"}),oauth:L.optional(L.Union([km6,L.Literal(!1)])).annotate({description:"OAuth authentication configuration for the MCP server. Set to false to disable OAuth auto-detection."}),timeout:L.optional(L.Number).annotate({description:"Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified."})}).annotate({identifier:"McpRemoteConfig"}).pipe(y0((A)=>({zod:B0(A)}))),k8q=L.Union([Im6,Sm6]).annotate({discriminator:"type"}).pipe(y0((A)=>({zod:B0(A)})))});var dFA={};bA(dFA,{Registry:()=>fm6,Info:()=>S8q,ConfigNpm:()=>dFA,Client:()=>Cm6});var Cm6,fm6,S8q;var z50=k(()=>{z50();i0();Mu();z5();Cm6=L.Literals(["auto","npm","pnpm","bun","yarn"]).pipe(y0((A)=>({zod:B0(A)}))),fm6=L.Struct({registry:L.optional(L.String),token:L.optional(L.String),always_auth:L.optional(L.Boolean)}).pipe(y0((A)=>({zod:B0(A)}))),S8q=L.Struct({client:L.optional(Cm6),registry:L.optional(L.String),token:L.optional(L.String),always_auth:L.optional(L.Boolean),scopes:L.optional(L.Record(L.String,fm6))}).pipe(y0((A)=>({zod:B0(A)})))});var nFA={};bA(nFA,{Model:()=>hm6,Info:()=>C8q,ConfigProvider:()=>nFA});var hm6,C8q;var R50=k(()=>{i0();Mu();z5();R50();hm6=L.Struct({id:L.optional(L.String),name:L.optional(L.String),family:L.optional(L.String),release_date:L.optional(L.String),attachment:L.optional(L.Boolean),reasoning:L.optional(L.Boolean),temperature:L.optional(L.Boolean),tool_call:L.optional(L.Boolean),interleaved:L.optional(L.Union([L.Literal(!0),L.Struct({field:L.Literals(["reasoning_content","reasoning_details"])})])),cost:L.optional(L.Struct({input:L.Number,output:L.Number,cache_read:L.optional(L.Number),cache_write:L.optional(L.Number),context_over_200k:L.optional(L.Struct({input:L.Number,output:L.Number,cache_read:L.optional(L.Number),cache_write:L.optional(L.Number)}))})),limit:L.optional(L.Struct({context:L.Number,input:L.optional(L.Number),output:L.Number})),modalities:L.optional(L.Struct({input:L.mutable(L.Array(L.Literals(["text","audio","image","video","pdf"]))),output:L.mutable(L.Array(L.Literals(["text","audio","image","video","pdf"])))})),experimental:L.optional(L.Boolean),status:L.optional(L.Literals(["alpha","beta","deprecated"])),provider:L.optional(L.Struct({npm:L.optional(L.String),api:L.optional(L.String)})),options:L.optional(L.Record(L.String,L.Any)),headers:L.optional(L.Record(L.String,L.String)),variants:L.optional(L.Record(L.String,L.StructWithRest(L.Struct({disabled:L.optional(L.Boolean).annotate({description:"Disable this variant for the model"})}),[L.Record(L.String,L.Any)])).annotate({description:"Variant-specific configuration"}))}).pipe(y0((A)=>({zod:B0(A)}))),C8q=L.Struct({api:L.optional(L.String),name:L.optional(L.String),env:L.optional(L.mutable(L.Array(L.String))),id:L.optional(L.String),npm:L.optional(L.String),whitelist:L.optional(L.mutable(L.Array(L.String))),blacklist:L.optional(L.mutable(L.Array(L.String))),options:L.optional(L.StructWithRest(L.Struct({apiKey:L.optional(L.String),baseURL:L.optional(L.String),enterpriseUrl:L.optional(L.String).annotate({description:"GitHub Enterprise URL for copilot authentication"}),setCacheKey:L.optional(L.Boolean).annotate({description:"Enable promptCacheKey for this provider (default false)"}),timeout:L.optional(L.Union([uV,L.Literal(!1)]).annotate({description:"Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout."})).annotate({description:"Timeout in milliseconds for requests to this provider. Default is 300000 (5 minutes). Set to false to disable timeout."}),chunkTimeout:L.optional(uV).annotate({description:"Timeout in milliseconds between streamed SSE chunks for this provider. If no chunk arrives within this window, the request is aborted."})}),[L.Record(L.String,L.Any)])),models:L.optional(L.Record(L.String,hm6))}).annotate({identifier:"ProviderConfig"}).pipe(y0((A)=>({zod:B0(A)})))});var pFA={};bA(pFA,{Server:()=>f8q,ConfigServer:()=>pFA});var f8q;var h92=k(()=>{i0();Mu();z5();h92();f8q=L.Struct({port:L.optional(uV).annotate({description:"Port to listen on"}),hostname:L.optional(L.String).annotate({description:"Hostname to listen on"}),mdns:L.optional(L.Boolean).annotate({description:"Enable mDNS service discovery"}),mdnsDomain:L.optional(L.String).annotate({description:"Custom domain name for mDNS service (default: codeplane.local)"}),cors:L.optional(L.mutable(L.Array(L.String))).annotate({description:"Additional domains to allow for CORS"})}).annotate({identifier:"ServerConfig"}).pipe(y0((A)=>({zod:B0(A)})))});var aFA={};bA(aFA,{Info:()=>h8q,ConfigSkills:()=>aFA});var h8q;var D50=k(()=>{i0();Mu();z5();D50();h8q=L.Struct({paths:L.optional(L.Array(L.String)).annotate({description:"Additional paths to skill folders"}),urls:L.optional(L.Array(L.String)).annotate({description:"URLs to fetch skills from (e.g., https://example.com/.well-known/skills/)"})}).pipe(y0((A)=>({zod:B0(A)})))});var t1={};bA(t1,{layer:()=>ym6,defaultLayer:()=>n8q,Service:()=>k50,Server:()=>y8q,Layout:()=>v8q,Info:()=>I50,ConfigDirectoryTypoError:()=>d8q});import TT from"path";import{pathToFileURL as m8q}from"url";import b8q from"os";import mm6 from"fs/promises";import{existsSync as P50}from"fs";function bm6(A,u){let q=Kq(A,u);if(A.instructions&&u.instructions)q.instructions=Array.from(new Set([...A.instructions,...u.instructions]));return q}async function t8q(A,u){if(!A.plugin)return A;for(let q=0;q<A.plugin.length;q++)A.plugin[q]=await xU.resolvePluginSpec(A.plugin[q],u);return A}function c8q(A){return i8q.map((u)=>TT.join(A,u))}function T50(){return TT.join(U2.Path.config,"codeplane.jsonc")}function tm6(A,u,q=[]){if(!w3(u)){let F=l8A(A,q,u,{formattingOptions:{insertSpaces:!0,tabSize:2}});return i8A(A,F)}return Object.entries(u).reduce((F,[G,w])=>{if(w===void 0)return F;return tm6(F,w,[...q,G])},A)}function YEA(A){let{plugin_origins:u,...q}=A;return q}var PT,y8q,v8q,Oz,l8q,I50,k50,i8q,d8q,ym6,n8q;var vm6=k(async()=>{Xu();rw();Xg();v4();dHA();sj();l$();mC6();U3();i0();Lr0();OqA();Mu();z5();$50();M50();L50();C92();XEA();JEA();z50();c8A();OEA();R50();h92();D50();await N0([Z1(),P3(),LX(),q50(),H8(),PFA(),I5(),N50(),B50(),E50(),x50(),zo(),$e(),gLA(),Sf()]);PT=Q2.create({service:"config"});y8q=pFA.Server.zod,v8q=iFA.Layout.zod,Oz=L.Any.annotate({[Y8]:Yi.Info}),l8q=L.Any.annotate({[Y8]:Q2.Level}),I50=L.Struct({$schema:L.optional(L.String).annotate({description:"JSON schema reference for configuration validation"}),logLevel:L.optional(l8q).annotate({description:"Log level"}),server:L.optional(pFA.Server).annotate({description:"Server configuration for codeplane serve and web commands"}),command:L.optional(L.Record(L.String,se.Info)).annotate({description:"Command configuration, see https://github.com/devinoldenburg/codeplane"}),commit:L.optional(yFA.Info).annotate({description:"Commit behavior for Codeplane-created commits."}),skills:L.optional(aFA.Info).annotate({description:"Additional skill folder paths"}),watcher:L.optional(L.Struct({ignore:L.optional(L.mutable(L.Array(L.String)))})),snapshot:L.optional(L.Boolean).annotate({description:"Enable or disable snapshot tracking. When false, filesystem snapshots are not recorded and undoing or reverting will not undo/redo file changes. Defaults to true."}),plugin:L.optional(L.mutable(L.Array(xU.Spec))),share:L.optional(L.Literals(["manual","auto","disabled"])).annotate({description:"Control sharing behavior:'manual' allows manual sharing via commands, 'auto' enables automatic sharing, 'disabled' disables all sharing"}),autoshare:L.optional(L.Boolean).annotate({description:"@deprecated Use 'share' field instead. Share newly created sessions automatically"}),autoupdate:L.optional(L.Union([L.Boolean,L.Literal("notify")])).annotate({description:"Automatically update to the latest version. Set to true to auto-update, false to disable, or 'notify' to show update notifications"}),disabled_providers:L.optional(L.mutable(L.Array(L.String))).annotate({description:"Disable providers that are loaded automatically"}),enabled_providers:L.optional(L.mutable(L.Array(L.String))).annotate({description:"When set, ONLY these providers will be enabled. All other providers will be ignored"}),model:L.optional(Wi).annotate({description:"Model to use in the format of provider/model, eg anthropic/claude-2"}),npm:L.optional(dFA.Info).annotate({description:"Native npm registry, auth, and package-manager integration settings"}),small_model:L.optional(Wi).annotate({description:"Small model to use for tasks like title generation in the format of provider/model"}),default_agent:L.optional(L.String).annotate({description:"Default agent to use when none is specified. Must be a primary agent. Falls back to 'build' if not set or if the specified agent is invalid."}),username:L.optional(L.String).annotate({description:"Custom username to display in conversations instead of system username"}),mode:L.optional(L.StructWithRest(L.Struct({build:L.optional(Oz),plan:L.optional(Oz)}),[L.Record(L.String,Oz)])).annotate({description:"@deprecated Use `agent` field instead."}),agent:L.optional(L.StructWithRest(L.Struct({plan:L.optional(Oz),build:L.optional(Oz),general:L.optional(Oz),explore:L.optional(Oz),title:L.optional(Oz),summary:L.optional(Oz),compaction:L.optional(Oz)}),[L.Record(L.String,Oz)])).annotate({description:"Agent configuration, see https://github.com/devinoldenburg/codeplane"}),provider:L.optional(L.Record(L.String,nFA.Info)).annotate({description:"Custom provider configurations and model overrides"}),mcp:L.optional(L.Record(L.String,L.Union([Vi.Info,L.Any.annotate({[Y8]:NA.object({enabled:NA.boolean()}).strict()})]))).annotate({description:"MCP (Model Context Protocol) server configurations"}),formatter:L.optional(vFA.Info),git:L.optional(lFA.Info).annotate({description:"Named Git host configuration for native git tool operations and credentials"}),lsp:L.optional(cFA.Info),instructions:L.optional(L.mutable(L.Array(L.String))).annotate({description:"Additional instruction files or patterns to include"}),layout:L.optional(iFA.Layout).annotate({description:"@deprecated Always uses stretch layout."}),permission:L.optional(Xi.Info),tools:L.optional(L.Record(L.String,L.Boolean)),enterprise:L.optional(L.Struct({url:L.optional(L.String).annotate({description:"Enterprise URL"})})),tool_output:L.optional(L.Struct({max_lines:L.optional(uV).annotate({description:"Maximum lines of tool output before it is truncated and saved to disk (default: 2000)"}),max_bytes:L.optional(uV).annotate({description:"Maximum bytes of tool output before it is truncated and saved to disk (default: 51200)"})})).annotate({description:"Thresholds for truncating tool output. When output exceeds either limit, the full text is written to the truncation directory and a preview is returned."}),compaction:L.optional(L.Struct({auto:L.optional(L.Boolean).annotate({description:"Enable automatic compaction when context is full (default: true)"}),prune:L.optional(L.Boolean).annotate({description:"Enable pruning of old tool outputs (default: true)"}),tail_turns:L.optional(BC).annotate({description:"Number of recent user turns, including their following assistant/tool responses, to keep verbatim during compaction (default: 2)"}),preserve_recent_tokens:L.optional(BC).annotate({description:"Maximum number of tokens from recent turns to preserve verbatim after compaction"}),reserved:L.optional(BC).annotate({description:"Token buffer for compaction. Leaves enough window to avoid overflow during compaction."})})),experimental:L.optional(L.Struct({disable_paste_summary:L.optional(L.Boolean),batch_tool:L.optional(L.Boolean).annotate({description:"Enable the batch tool"}),openTelemetry:L.optional(L.Boolean).annotate({description:"Enable OpenTelemetry spans for AI SDK calls (using the 'experimental_telemetry' flag)"}),primary_tools:L.optional(L.mutable(L.Array(L.String))).annotate({description:"Tools that should only be available to primary agents."}),continue_loop_on_deny:L.optional(L.Boolean).annotate({description:"Continue the agent loop when a tool call is denied"}),mcp_timeout:L.optional(uV).annotate({description:"Timeout in milliseconds for model context protocol (MCP) requests"})}))}).annotate({identifier:"Config"}).pipe(y0((A)=>({zod:B0(A).strict().meta({ref:"Config"})})));k50=class k50 extends m0.Service()("@codeplane/Config"){};i8q=["codeplane.jsonc","codeplane.json","config.json"];d8q=d6.create("ConfigDirectoryTypoError",NA.object({path:NA.string(),dir:NA.string(),suggestion:NA.string()})),ym6=fA.effect(k50,R.gen(function*(){let A=yield*P2.Service,u=yield*l8.Service,q=yield*EX.Service,F=yield*sf.Service,G=yield*h7.Service,w=R.fnUntraced(function*(x){return yield*A.readFileString(x).pipe(R.catchIf(($)=>$.reason._tag==="NotFound",()=>R.succeed(void 0)),R.orDie)}),g=R.fnUntraced(function*(x,$){let E="path"in $?$.path:$.source,z=yield*R.promise(()=>ll.substitute("path"in $?{text:x,type:"path",path:$.path}:{text:x,type:"virtual",...$})),T=gO.jsonc(z,E),D=gO.schema(I50.zod,T,E);if(!("path"in $))return D;if(yield*R.promise(()=>t8q(D,$.path)),!D.$schema){D.$schema="https://example.invalid/config.json";let C=x.replace(/^\s*\{/,`{
|
|
1850
1850
|
"$schema": "https://example.invalid/config.json",`);yield*A.writeFileString($.path,C).pipe(R.catch(()=>R.void))}return D}),Q=R.fnUntraced(function*(x){PT.info("loading",{path:x});let $=yield*w(x);if(!$)return{};return yield*g($,{path:x})}),j=R.fnUntraced(function*(){let x=T50();if(!P50(x))for(let T of c8q(U2.Path.config).filter((D)=>D!==x)){if(!P50(T))continue;let D=yield*w(T);if(!D)continue;yield*A.writeFileString(x,D).pipe(R.orDie);break}let E=yield*Q(T50()),z=TT.join(U2.Path.config,"config");if(P50(z))yield*R.promise(()=>import(m8q(z).href,{with:{type:"toml"}}).then(async(T)=>{let{provider:D,model:C,...t}=T.default;if(D&&C)E.model=`${D}/${C}`;E.$schema="https://example.invalid/config.json",E=Kq(E,t),await mm6.writeFile(T50(),JSON.stringify(E,null,2)),await mm6.unlink(z)}).catch(()=>{}));return E}),[K,U]=yield*R.cachedInvalidateWithTTL(j().pipe(R.tapError((x)=>R.sync(()=>PT.error("failed to load global config, using defaults",{error:String(x)}))),R.orElseSucceed(()=>({}))),t4.infinity),_=R.fn("Config.getGlobal")(function*(){return yield*K}),O=R.fn("Config.ensureGitignore")(function*(x){let $=TT.join(x,".gitignore");if(!(yield*A.existsSafe($)))yield*A.writeFileString($,["node_modules","package.json","package-lock.json","bun.lock",".gitignore"].join(`
|
|
1851
1851
|
`)).pipe(R.catchIf((z)=>z.reason._tag==="PermissionDenied",()=>R.void))}),W=R.fn("Config.loadInstanceState")(function*(x){let $=yield*u.all().pipe(R.orDie),E={},z=new Set,T,D=R.fnUntraced(function*(a){if(a.startsWith("http://")||a.startsWith("https://"))return"global";if(a==="CODEPLANE_CONFIG_CONTENT")return"local";if(yield*p$.use((uA)=>R.succeed(z2.containsPath(a,uA))))return"local";return"global"}),C=R.fnUntraced(function*(a,uA,n){if(!uA?.length)return;let m=n??(yield*D(a)),v=xU.deduplicatePluginOrigins([...E.plugin_origins??[],...uA.map((gA)=>({spec:gA,source:a,scope:m}))]);E.plugin=v.map((gA)=>gA.spec),E.plugin_origins=v}),t=(a,uA,n)=>{return E=bm6(E,uA),C(a,uA.plugin,n)};for(let[a,uA]of Object.entries($))if(uA.type==="wellknown"){let n=a.replace(/\/+$/,"");process.env[uA.key]=uA.token,PT.debug("fetching remote config",{url:`${n}/.well-known/codeplane`});let m=yield*R.promise(()=>fetch(`${n}/.well-known/codeplane`));if(!m.ok)throw Error(`failed to fetch remote config from ${n}: ${m.status}`);let gA=(yield*R.promise(()=>m.json())).config??{};if(!gA.$schema)gA.$schema="https://example.invalid/config.json";let d=`${n}/.well-known/codeplane`,GA=yield*g(JSON.stringify(gA),{dir:TT.dirname(d),source:d});yield*t(d,GA,"global"),PT.debug("loaded remote config from well-known",{url:n})}let S=yield*_();if(yield*t(U2.Path.config,S,"global"),t0.CODEPLANE_CONFIG)yield*t(t0.CODEPLANE_CONFIG,yield*Q(t0.CODEPLANE_CONFIG)),PT.debug("loaded custom config",{path:t0.CODEPLANE_CONFIG});if(!t0.CODEPLANE_DISABLE_PROJECT_CONFIG)for(let a of yield*BP.files("codeplane",x.directory,x.worktree).pipe(R.orDie))yield*t(a,yield*Q(a),"local");E.agent=E.agent||{},E.mode=E.mode||{},E.plugin=E.plugin||[];let f=yield*BP.directories(x.directory,x.worktree);if(t0.CODEPLANE_CONFIG_DIR)PT.debug("loading config from CODEPLANE_CONFIG_DIR",{path:t0.CODEPLANE_CONFIG_DIR});let r=[];for(let a of f){if(a.endsWith(".codeplane")||a===t0.CODEPLANE_CONFIG_DIR)for(let m of["codeplane.json","codeplane.jsonc"]){let v=TT.join(a,m);PT.debug(`loading config from ${v}`),yield*t(v,yield*Q(v)),E.agent??={},E.mode??={},E.plugin??=[]}yield*O(a).pipe(R.orDie);let uA=yield*G.install(a,{add:[{name:"@codeplane-ai/plugin",version:T8A?void 0:S4}]}).pipe(R.exit,R.tap((m)=>y5.isFailure(m)?R.sync(()=>{PT.warn("background dependency install failed",{dir:a,error:String(m.cause)})}):R.void),R.asVoid,R.forkDetach);r.push(uA),E.command=Kq(E.command??{},yield*R.promise(()=>se.load(a))),E.agent=Kq(E.agent??{},yield*R.promise(()=>Yi.load(a))),E.agent=Kq(E.agent??{},yield*R.promise(()=>Yi.loadMode(a)));let n=yield*R.promise(()=>xU.load(a));yield*C(a,n)}if(process.env.CODEPLANE_CONFIG_CONTENT){let uA=yield*g(process.env.CODEPLANE_CONFIG_CONTENT,{dir:x.directory,source:"CODEPLANE_CONFIG_CONTENT"});yield*t("CODEPLANE_CONFIG_CONTENT",uA,"local"),PT.debug("loaded custom config from CODEPLANE_CONFIG_CONTENT")}let l=b0.getOrUndefined(yield*q.active().pipe(R.catch(()=>R.succeed(b0.none()))));if(l?.active_org_id){let{id:a,active_org_id:uA,url:n}=l;yield*R.gen(function*(){let[m,v]=yield*R.all([q.config(a,uA),q.token(a)],{concurrency:2});if(b0.isSome(v))process.env.CODEPLANE_CONSOLE_TOKEN=v.value,yield*F.set("CODEPLANE_CONSOLE_TOKEN",v.value);if(b0.isSome(m)){let gA=`${n}/api/config`,d=yield*g(JSON.stringify(m.value),{dir:TT.dirname(gA),source:gA});for(let GA of Object.keys(d.provider??{}))z.add(GA);yield*t(gA,d,"global")}}).pipe(R.withSpan("Config.loadActiveOrgConfig"),R.catch((m)=>{return PT.debug("failed to fetch remote account config",{error:m instanceof Error?m.message:String(m)}),R.void}))}let e=ee.managedConfigDir();if(P50(e))for(let a of["codeplane.json","codeplane.jsonc"]){let uA=TT.join(e,a);yield*t(uA,yield*Q(uA),"global")}let s=yield*R.promise(()=>ee.readManagedPreferences());if(s)E=bm6(E,yield*g(s.text,{dir:TT.dirname(s.source),source:s.source}));for(let[a,uA]of Object.entries(E.mode??{}))E.agent=Kq(E.agent??{},{[a]:{...uA,mode:"primary"}});if(t0.CODEPLANE_PERMISSION)E.permission=Kq(E.permission??{},JSON.parse(t0.CODEPLANE_PERMISSION));if(E.tools){let a={};for(let[uA,n]of Object.entries(E.tools)){let m=n?"allow":"deny";if(uA==="write"||uA==="edit"||uA==="patch"){a.edit=m;continue}a[uA]=m}E.permission=Kq(a,E.permission??{})}if(!E.username)E.username=b8q.userInfo().username;if(E.autoshare===!0&&!E.share)E.share="auto";if(t0.CODEPLANE_DISABLE_AUTOCOMPACT)E.compaction={...E.compaction,auto:!1};if(t0.CODEPLANE_DISABLE_PRUNE)E.compaction={...E.compaction,prune:!1};return{config:E,directories:f,deps:r,consoleState:{consoleManagedProviders:Array.from(z),activeOrgName:T,switchableOrgCount:0}}},R.provideService(P2.Service,A)),X=yield*z0.make(R.fn("Config.state")(function*(x){return yield*W(x).pipe(R.orDie)})),Y=R.fn("Config.get")(function*(){return yield*z0.use(X,(x)=>x.config)}),V=R.fn("Config.directories")(function*(){return yield*z0.use(X,(x)=>x.directories)}),Z=R.fn("Config.getConsoleState")(function*(){return yield*z0.use(X,(x)=>x.consoleState)}),H=R.fn("Config.waitForDependencies")(function*(){yield*z0.useEffect(X,(x)=>R.forEach(x.deps,xq.join,{concurrency:"unbounded"}).pipe(R.asVoid))}),N=R.fn("Config.update")(function*(x){let $=yield*z0.directory,E=TT.join($,"config.json"),z=yield*Q(E);yield*A.writeFileString(E,JSON.stringify(Kq(YEA(z),YEA(x)),null,2)).pipe(R.orDie),yield*R.promise(()=>z2.dispose())}),B=R.fn("Config.invalidate")(function*(x){yield*U;let $=z2.disposeAll().catch(()=>{return}).finally(()=>Xq.emit("event",{directory:"global",payload:{type:hC6.Disposed.type,properties:{}}}));if(x)yield*R.promise(()=>$)}),M=R.fn("Config.updateGlobal")(function*(x){let $=T50(),E=(yield*w($))??"{}",z;if(!$.endsWith(".jsonc")){let T=gO.schema(I50.zod,gO.jsonc(E,$),$),D=Kq(YEA(T),YEA(x));yield*A.writeFileString($,JSON.stringify(D,null,2)).pipe(R.orDie),z=D}else{let T=tm6(E,YEA(x));z=gO.schema(I50.zod,gO.jsonc(T,$),$),yield*A.writeFileString($,T).pipe(R.orDie)}return yield*B(),z});return k50.of({get:Y,getGlobal:_,getConsoleState:Z,update:N,updateGlobal:M,invalidate:B,directories:V,waitForDependencies:H})})),n8q=ym6.pipe(fA.provide(FqA.defaultLayer),fA.provide(P2.defaultLayer),fA.provide(sf.defaultLayer),fA.provide(l8.defaultLayer),fA.provide(EX.defaultLayer),fA.provide(h7.defaultLayer))});var Vq=k(async()=>{$50();Nv();M50();L50();XEA();JEA();z50();c8A();OEA();R50();D50();await N0([vm6(),N50(),B50(),E50(),gLA(),x50(),H50(),zo()])});var VEA={};bA(VEA,{report:()=>p8q,pretty:()=>im6,Diagnostic:()=>VEA});function im6(A){let q={1:"ERROR",2:"WARN",3:"INFO",4:"HINT"}[A.severity||1],F=A.range.start.line+1,G=A.range.start.character+1;return`${q} [${F}:${G}] ${A.message}`}function p8q(A,u){let q=u.filter((g)=>g.severity===1);if(q.length===0)return"";let F=q.slice(0,lm6),G=q.length-lm6,w=G>0?`
|
|
1852
1852
|
... and ${G} more`:"";return`<diagnostics file="${A}">
|
|
@@ -4602,7 +4602,7 @@ Any attempt to use tools is a critical violation. Respond with text ONLY.`;var j
|
|
|
4602
4602
|
|
|
4603
4603
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let g of A.seen.entries()){let Q=g[1];if(u===g[0]){w(g);continue}if(A.external){let K=A.external.registry.get(g[0])?.id;if(u!==g[0]&&K){w(g);continue}}if(A.metadataRegistry.get(g[0])?.id){w(g);continue}if(Q.cycle){w(g);continue}if(Q.count>1){if(A.reused==="ref"){w(g);continue}}}}function FX2(A,u){let q=A.seen.get(u);if(!q)throw Error("Unprocessed schema. This is a bug in Zod.");let F=(g)=>{let Q=A.seen.get(g);if(Q.ref===null)return;let j=Q.def??Q.schema,K={...j},U=Q.ref;if(Q.ref=null,U){F(U);let O=A.seen.get(U),W=O.schema;if(W.$ref&&(A.target==="draft-07"||A.target==="draft-04"||A.target==="openapi-3.0"))j.allOf=j.allOf??[],j.allOf.push(W);else Object.assign(j,W);if(Object.assign(j,K),g._zod.parent===U)for(let Y in j){if(Y==="$ref"||Y==="allOf")continue;if(!(Y in K))delete j[Y]}if(W.$ref&&O.def)for(let Y in j){if(Y==="$ref"||Y==="allOf")continue;if(Y in O.def&&JSON.stringify(j[Y])===JSON.stringify(O.def[Y]))delete j[Y]}}let _=g._zod.parent;if(_&&_!==U){F(_);let O=A.seen.get(_);if(O?.schema.$ref){if(j.$ref=O.schema.$ref,O.def)for(let W in j){if(W==="$ref"||W==="allOf")continue;if(W in O.def&&JSON.stringify(j[W])===JSON.stringify(O.def[W]))delete j[W]}}}A.override({zodSchema:g,jsonSchema:j,path:Q.path??[]})};for(let g of[...A.seen.entries()].reverse())F(g[0]);let G={};if(A.target==="draft-2020-12")G.$schema="https://json-schema.org/draft/2020-12/schema";else if(A.target==="draft-07")G.$schema="http://json-schema.org/draft-07/schema#";else if(A.target==="draft-04")G.$schema="http://json-schema.org/draft-04/schema#";else if(A.target==="openapi-3.0");if(A.external?.uri){let g=A.external.registry.get(u)?.id;if(!g)throw Error("Schema is missing an `id` property");G.$id=A.external.uri(g)}Object.assign(G,q.def??q.schema);let w=A.external?.defs??{};for(let g of A.seen.entries()){let Q=g[1];if(Q.def&&Q.defId)w[Q.defId]=Q.def}if(A.external);else if(Object.keys(w).length>0)if(A.target==="draft-2020-12")G.$defs=w;else G.definitions=w;try{let g=JSON.parse(JSON.stringify(G));return Object.defineProperty(g,"~standard",{value:{...u["~standard"],jsonSchema:{input:MPA(u,"input",A.processors),output:MPA(u,"output",A.processors)}},enumerable:!1,writable:!1}),g}catch(g){throw Error("Error converting schema to JSON.")}}function hX(A,u){let q=u??{seen:new Set};if(q.seen.has(A))return!1;q.seen.add(A);let F=A._zod.def;if(F.type==="transform")return!0;if(F.type==="array")return hX(F.element,q);if(F.type==="set")return hX(F.valueType,q);if(F.type==="lazy")return hX(F.getter(),q);if(F.type==="promise"||F.type==="optional"||F.type==="nonoptional"||F.type==="nullable"||F.type==="readonly"||F.type==="default"||F.type==="prefault")return hX(F.innerType,q);if(F.type==="intersection")return hX(F.left,q)||hX(F.right,q);if(F.type==="record"||F.type==="map")return hX(F.keyType,q)||hX(F.valueType,q);if(F.type==="pipe")return hX(F.in,q)||hX(F.out,q);if(F.type==="object"){for(let G in F.shape)if(hX(F.shape[G],q))return!0;return!1}if(F.type==="union"){for(let G of F.options)if(hX(G,q))return!0;return!1}if(F.type==="tuple"){for(let G of F.items)if(hX(G,q))return!0;if(F.rest&&hX(F.rest,q))return!0;return!1}return!1}var WKu=(A,u={})=>(q)=>{let F=uX2({...q,processors:u});return PQ(A,F),qX2(F,A),FX2(F,A)},MPA=(A,u,q={})=>(F)=>{let{libraryOptions:G,target:w}=F??{},g=uX2({...G??{},target:w,io:u,processors:q});return PQ(A,g),qX2(g,A),FX2(g,A)};var WF0=k(()=>{yW2()});var ocq,XKu=(A,u,q,F)=>{let G=q;G.type="string";let{minimum:w,maximum:g,format:Q,patterns:j,contentEncoding:K}=A._zod.bag;if(typeof w==="number")G.minLength=w;if(typeof g==="number")G.maxLength=g;if(Q){if(G.format=ocq[Q]??Q,G.format==="")delete G.format;if(Q==="time")delete G.format}if(K)G.contentEncoding=K;if(j&&j.size>0){let U=[...j];if(U.length===1)G.pattern=U[0].source;else if(U.length>1)G.allOf=[...U.map((_)=>({...u.target==="draft-07"||u.target==="draft-04"||u.target==="openapi-3.0"?{type:"string"}:{},pattern:_.source}))]}},YKu=(A,u,q,F)=>{let G=q,{minimum:w,maximum:g,format:Q,multipleOf:j,exclusiveMaximum:K,exclusiveMinimum:U}=A._zod.bag;if(typeof Q==="string"&&Q.includes("int"))G.type="integer";else G.type="number";if(typeof U==="number")if(u.target==="draft-04"||u.target==="openapi-3.0")G.minimum=U,G.exclusiveMinimum=!0;else G.exclusiveMinimum=U;if(typeof w==="number"){if(G.minimum=w,typeof U==="number"&&u.target!=="draft-04")if(U>=w)delete G.minimum;else delete G.exclusiveMinimum}if(typeof K==="number")if(u.target==="draft-04"||u.target==="openapi-3.0")G.maximum=K,G.exclusiveMaximum=!0;else G.exclusiveMaximum=K;if(typeof g==="number"){if(G.maximum=g,typeof K==="number"&&u.target!=="draft-04")if(K<=g)delete G.maximum;else delete G.exclusiveMaximum}if(typeof j==="number")G.multipleOf=j},VKu=(A,u,q,F)=>{q.type="boolean"},ZKu=(A,u,q,F)=>{if(u.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},HKu=(A,u,q,F)=>{if(u.target==="openapi-3.0")q.type="string",q.nullable=!0,q.enum=[null];else q.type="null"},NKu=(A,u,q,F)=>{q.not={}},BKu=(A,u,q,F)=>{},$Ku=(A,u,q,F)=>{},MKu=(A,u,q,F)=>{if(u.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},LKu=(A,u,q,F)=>{let G=A._zod.def,w=OPA(G.entries);if(w.every((g)=>typeof g==="number"))q.type="number";if(w.every((g)=>typeof g==="string"))q.type="string";q.enum=w},EKu=(A,u,q,F)=>{let G=A._zod.def,w=[];for(let g of G.values)if(g===void 0){if(u.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof g==="bigint")if(u.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else w.push(Number(g));else w.push(g);if(w.length===0);else if(w.length===1){let g=w[0];if(q.type=g===null?"null":typeof g,u.target==="draft-04"||u.target==="openapi-3.0")q.enum=[g];else q.const=g}else{if(w.every((g)=>typeof g==="number"))q.type="number";if(w.every((g)=>typeof g==="string"))q.type="string";if(w.every((g)=>typeof g==="boolean"))q.type="boolean";if(w.every((g)=>g===null))q.type="null";q.enum=w}},xKu=(A,u,q,F)=>{if(u.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},zKu=(A,u,q,F)=>{if(u.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},RKu=(A,u,q,F)=>{let G=q,w=A._zod.def,{minimum:g,maximum:Q}=A._zod.bag;if(typeof g==="number")G.minItems=g;if(typeof Q==="number")G.maxItems=Q;G.type="array",G.items=PQ(w.element,u,{...F,path:[...F.path,"items"]})},DKu=(A,u,q,F)=>{let G=q,w=A._zod.def;G.type="object",G.properties={};let g=w.shape;for(let K in g)G.properties[K]=PQ(g[K],u,{...F,path:[...F.path,"properties",K]});let Q=new Set(Object.keys(g)),j=new Set([...Q].filter((K)=>{let U=w.shape[K]._zod;if(u.io==="input")return U.optin===void 0;else return U.optout===void 0}));if(j.size>0)G.required=Array.from(j);if(w.catchall?._zod.def.type==="never")G.additionalProperties=!1;else if(!w.catchall){if(u.io==="output")G.additionalProperties=!1}else if(w.catchall)G.additionalProperties=PQ(w.catchall,u,{...F,path:[...F.path,"additionalProperties"]})},PKu=(A,u,q,F)=>{let G=A._zod.def,w=G.inclusive===!1,g=G.options.map((Q,j)=>PQ(Q,u,{...F,path:[...F.path,w?"oneOf":"anyOf",j]}));if(w)q.oneOf=g;else q.anyOf=g},TKu=(A,u,q,F)=>{let G=A._zod.def,w=PQ(G.left,u,{...F,path:[...F.path,"allOf",0]}),g=PQ(G.right,u,{...F,path:[...F.path,"allOf",1]}),Q=(K)=>("allOf"in K)&&Object.keys(K).length===1,j=[...Q(w)?w.allOf:[w],...Q(g)?g.allOf:[g]];q.allOf=j},IKu=(A,u,q,F)=>{let G=q,w=A._zod.def;G.type="object";let g=w.keyType,j=g._zod.bag?.patterns;if(w.mode==="loose"&&j&&j.size>0){let U=PQ(w.valueType,u,{...F,path:[...F.path,"patternProperties","*"]});G.patternProperties={};for(let _ of j)G.patternProperties[_.source]=U}else{if(u.target==="draft-07"||u.target==="draft-2020-12")G.propertyNames=PQ(w.keyType,u,{...F,path:[...F.path,"propertyNames"]});G.additionalProperties=PQ(w.valueType,u,{...F,path:[...F.path,"additionalProperties"]})}let K=g._zod.values;if(K){let U=[...K].filter((_)=>typeof _==="string"||typeof _==="number");if(U.length>0)G.required=U}},kKu=(A,u,q,F)=>{let G=A._zod.def,w=PQ(G.innerType,u,F),g=u.seen.get(A);if(u.target==="openapi-3.0")g.ref=G.innerType,q.nullable=!0;else q.anyOf=[w,{type:"null"}]},SKu=(A,u,q,F)=>{let G=A._zod.def;PQ(G.innerType,u,F);let w=u.seen.get(A);w.ref=G.innerType},CKu=(A,u,q,F)=>{let G=A._zod.def;PQ(G.innerType,u,F);let w=u.seen.get(A);w.ref=G.innerType,q.default=JSON.parse(JSON.stringify(G.defaultValue))},fKu=(A,u,q,F)=>{let G=A._zod.def;PQ(G.innerType,u,F);let w=u.seen.get(A);if(w.ref=G.innerType,u.io==="input")q._prefault=JSON.parse(JSON.stringify(G.defaultValue))},hKu=(A,u,q,F)=>{let G=A._zod.def;PQ(G.innerType,u,F);let w=u.seen.get(A);w.ref=G.innerType;let g;try{g=G.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}q.default=g},mKu=(A,u,q,F)=>{let G=A._zod.def,w=u.io==="input"?G.in._zod.def.type==="transform"?G.out:G.in:G.out;PQ(w,u,F);let g=u.seen.get(A);g.ref=w},bKu=(A,u,q,F)=>{let G=A._zod.def;PQ(G.innerType,u,F);let w=u.seen.get(A);w.ref=G.innerType,q.readOnly=!0},GX2=(A,u,q,F)=>{let G=A._zod.def;PQ(G.innerType,u,F);let w=u.seen.get(A);w.ref=G.innerType};var tKu=k(()=>{WF0();iz();ocq={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""}});var yKu=()=>{};var uZ=k(()=>{iz();gF0();_F0();yKu();EgA();RW2();zW2();Bju();QF0();SW2();yW2();OKu();WF0()});var vKu=k(()=>{uZ()});var lKu=()=>{};var iKu=()=>{};var cKu=()=>{};var dKu=()=>{};var nKu=k(()=>{uZ();_F0();cKu();dKu();vKu();lKu();iKu()});var pKu=k(()=>{nKu()});function IgA(A){return!!A._zod}function dz(A,u){if(IgA(A))return ZPA(A,u);return A.safeParse(u)}function XF0(A){if(!A)return;let u;if(IgA(A))u=A._zod?.def?.shape;else u=A.shape;if(!u)return;if(typeof u==="function")try{return u()}catch{return}return u}function aKu(A){if(IgA(A)){let w=A._zod?.def;if(w){if(w.value!==void 0)return w.value;if(Array.isArray(w.values)&&w.values.length>0)return w.values[0]}}let q=A._def;if(q){if(q.value!==void 0)return q.value;if(Array.isArray(q.values)&&q.values.length>0)return q.values[0]}let F=A.value;if(F!==void 0)return F;return}var YF0=k(()=>{pKu()});var wX2=k(()=>{uZ()});var LPA={};bA(LPA,{time:()=>jX2,duration:()=>KX2,datetime:()=>gX2,date:()=>QX2,ZodISOTime:()=>sKu,ZodISODuration:()=>eKu,ZodISODateTime:()=>rKu,ZodISODate:()=>oKu});function gX2(A){return pju(rKu,A)}function QX2(A){return aju(oKu,A)}function jX2(A){return rju(sKu,A)}function KX2(A){return oju(eKu,A)}var rKu,oKu,sKu,eKu;var UX2=k(()=>{uZ();VF0();rKu=Z2("ZodISODateTime",(A,u)=>{CQu.init(A,u),oG.init(A,u)});oKu=Z2("ZodISODate",(A,u)=>{fQu.init(A,u),oG.init(A,u)});sKu=Z2("ZodISOTime",(A,u)=>{hQu.init(A,u),oG.init(A,u)});eKu=Z2("ZodISODuration",(A,u)=>{mQu.init(A,u),oG.init(A,u)})});var uUu=(A,u)=>{uF0.init(A,u),A.name="ZodError",Object.defineProperties(A,{format:{value:(q)=>xW2(A,q)},flatten:{value:(q)=>EW2(A,q)},addIssue:{value:(q)=>{A.issues.push(q),A.message=JSON.stringify(A.issues,xgA,2)}},addIssues:{value:(q)=>{A.issues.push(...q),A.message=JSON.stringify(A.issues,xgA,2)}},isEmpty:{get(){return A.issues.length===0}}})},uOG,IN;var _X2=k(()=>{uZ();uZ();iz();uOG=Z2("ZodError",uUu),IN=Z2("ZodError",uUu,{Parent:Error})});var qUu,FUu,GUu,wUu,gUu,QUu,jUu,KUu,UUu,_Uu,JUu,OUu;var JX2=k(()=>{uZ();_X2();qUu=qF0(IN),FUu=FF0(IN),GUu=VPA(IN),wUu=HPA(IN),gUu=Hgu(IN),QUu=Ngu(IN),jUu=Bgu(IN),KUu=$gu(IN),UUu=Mgu(IN),_Uu=Lgu(IN),JUu=Egu(IN),OUu=xgu(IN)});function I0(A){return xju(XX2,A)}function HUu(A){return lW2(ZUu,A)}function Pq(A){return sju(HF0,A)}function XUu(A){return AKu(Ldq,A)}function _F(A){return uKu(YX2,A)}function BUu(A){return GKu(Edq,A)}function $Uu(){return wKu(xdq)}function sG(){return gKu(zdq)}function Ddq(A){return QKu(Rdq,A)}function R6(A,u){return KKu(Pdq,A,u)}function k6(A,u){let q={type:"object",shape:A??{},...Nq.normalizeParams(u)};return new LUu(q)}function VK(A,u){return new LUu({type:"object",shape:A,catchall:sG(),...Nq.normalizeParams(u)})}function $G(A,u){return new EUu({type:"union",options:A,...Nq.normalizeParams(u)})}function VX2(A,u,q){return new Tdq({type:"union",options:u,discriminator:A,...Nq.normalizeParams(q)})}function NF0(A,u){return new Idq({type:"intersection",left:A,right:u})}function tF(A,u,q){return new kdq({type:"record",keyType:A,valueType:u,...Nq.normalizeParams(q)})}function qZ(A,u){let q=Array.isArray(A)?Object.fromEntries(A.map((F)=>[F,F])):A;return new OX2({type:"enum",entries:q,...Nq.normalizeParams(u)})}function bu(A,u){return new Sdq({type:"literal",values:Array.isArray(A)?A:[A],...Nq.normalizeParams(u)})}function xUu(A){return new Cdq({type:"transform",transform:A})}function eG(A){return new zUu({type:"optional",innerType:A})}function hdq(A){return new fdq({type:"optional",innerType:A})}function YUu(A){return new mdq({type:"nullable",innerType:A})}function tdq(A,u){return new bdq({type:"default",innerType:A,get defaultValue(){return typeof u==="function"?u():Nq.shallowClone(u)}})}function vdq(A,u){return new ydq({type:"prefault",innerType:A,get defaultValue(){return typeof u==="function"?u():Nq.shallowClone(u)}})}function ldq(A,u){return new RUu({type:"nonoptional",innerType:A,...Nq.normalizeParams(u)})}function cdq(A,u){return new idq({type:"catch",innerType:A,catchValue:typeof u==="function"?u:()=>u})}function WX2(A,u){return new ddq({type:"pipe",in:A,out:u})}function pdq(A){return new ndq({type:"readonly",innerType:A})}function PUu(A,u){return UKu(DUu,A??(()=>!0),u)}function adq(A,u={}){return _Ku(DUu,A,u)}function rdq(A){return JKu(A)}function ZX2(A,u){return WX2(xUu(A),u)}var UF,VUu,XX2,oG,jdq,WUu,ZF0,ZUu,Kdq,Udq,_dq,Jdq,Odq,Wdq,Xdq,Ydq,Vdq,Zdq,Hdq,Ndq,Bdq,$dq,Mdq,HF0,Ldq,YX2,NUu,Edq,xdq,zdq,Rdq,MUu,Pdq,LUu,EUu,Tdq,Idq,kdq,OX2,Sdq,Cdq,zUu,fdq,mdq,bdq,ydq,RUu,idq,ddq,ndq,DUu;var VF0=k(()=>{uZ();uZ();tKu();WF0();wX2();UX2();JX2();UF=Z2("ZodType",(A,u)=>{return f9.init(A,u),Object.assign(A["~standard"],{jsonSchema:{input:MPA(A,"input"),output:MPA(A,"output")}}),A.toJSONSchema=WKu(A,{}),A.def=u,A.type=u.type,Object.defineProperty(A,"_def",{value:u}),A.check=(...q)=>{return A.clone(Nq.mergeDefs(u,{checks:[...u.checks??[],...q.map((F)=>typeof F==="function"?{_zod:{check:F,def:{check:"custom"},onattach:[]}}:F)]}),{parent:!0})},A.with=A.check,A.clone=(q,F)=>uL(A,q,F),A.brand=()=>A,A.register=(q,F)=>{return q.add(A,F),A},A.parse=(q,F)=>qUu(A,q,F,{callee:A.parse}),A.safeParse=(q,F)=>GUu(A,q,F),A.parseAsync=async(q,F)=>FUu(A,q,F,{callee:A.parseAsync}),A.safeParseAsync=async(q,F)=>wUu(A,q,F),A.spa=A.safeParseAsync,A.encode=(q,F)=>gUu(A,q,F),A.decode=(q,F)=>QUu(A,q,F),A.encodeAsync=async(q,F)=>jUu(A,q,F),A.decodeAsync=async(q,F)=>KUu(A,q,F),A.safeEncode=(q,F)=>UUu(A,q,F),A.safeDecode=(q,F)=>_Uu(A,q,F),A.safeEncodeAsync=async(q,F)=>JUu(A,q,F),A.safeDecodeAsync=async(q,F)=>OUu(A,q,F),A.refine=(q,F)=>A.check(adq(q,F)),A.superRefine=(q)=>A.check(rdq(q)),A.overwrite=(q)=>A.check(Dc(q)),A.optional=()=>eG(A),A.exactOptional=()=>hdq(A),A.nullable=()=>YUu(A),A.nullish=()=>eG(YUu(A)),A.nonoptional=(q)=>ldq(A,q),A.array=()=>R6(A),A.or=(q)=>$G([A,q]),A.and=(q)=>NF0(A,q),A.transform=(q)=>WX2(A,xUu(q)),A.default=(q)=>tdq(A,q),A.prefault=(q)=>vdq(A,q),A.catch=(q)=>cdq(A,q),A.pipe=(q)=>WX2(A,q),A.readonly=()=>pdq(A),A.describe=(q)=>{let F=A.clone();return Rc.add(F,{description:q}),F},Object.defineProperty(A,"description",{get(){return Rc.get(A)?.description},configurable:!0}),A.meta=(...q)=>{if(q.length===0)return Rc.get(A);let F=A.clone();return Rc.add(F,q[0]),F},A.isOptional=()=>A.safeParse(void 0).success,A.isNullable=()=>A.safeParse(null).success,A.apply=(q)=>q(A),A}),VUu=Z2("_ZodString",(A,u)=>{UF0.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(F,G,w)=>XKu(A,F,G,w);let q=A._zod.bag;A.format=q.format??null,A.minLength=q.minimum??null,A.maxLength=q.maximum??null,A.regex=(...F)=>A.check(iW2(...F)),A.includes=(...F)=>A.check(nW2(...F)),A.startsWith=(...F)=>A.check(pW2(...F)),A.endsWith=(...F)=>A.check(aW2(...F)),A.min=(...F)=>A.check(TgA(...F)),A.max=(...F)=>A.check(JF0(...F)),A.length=(...F)=>A.check(OF0(...F)),A.nonempty=(...F)=>A.check(TgA(1,...F)),A.lowercase=(F)=>A.check(cW2(F)),A.uppercase=(F)=>A.check(dW2(F)),A.trim=()=>A.check(oW2()),A.normalize=(...F)=>A.check(rW2(...F)),A.toLowerCase=()=>A.check(sW2()),A.toUpperCase=()=>A.check(eW2()),A.slugify=()=>A.check(AX2())}),XX2=Z2("ZodString",(A,u)=>{UF0.init(A,u),VUu.init(A,u),A.email=(q)=>A.check(Rju(jdq,q)),A.url=(q)=>A.check(lW2(ZUu,q)),A.jwt=(q)=>A.check(nju(Mdq,q)),A.emoji=(q)=>A.check(kju(Kdq,q)),A.guid=(q)=>A.check(vW2(WUu,q)),A.uuid=(q)=>A.check(Dju(ZF0,q)),A.uuidv4=(q)=>A.check(Pju(ZF0,q)),A.uuidv6=(q)=>A.check(Tju(ZF0,q)),A.uuidv7=(q)=>A.check(Iju(ZF0,q)),A.nanoid=(q)=>A.check(Sju(Udq,q)),A.guid=(q)=>A.check(vW2(WUu,q)),A.cuid=(q)=>A.check(Cju(_dq,q)),A.cuid2=(q)=>A.check(fju(Jdq,q)),A.ulid=(q)=>A.check(hju(Odq,q)),A.base64=(q)=>A.check(iju(Ndq,q)),A.base64url=(q)=>A.check(cju(Bdq,q)),A.xid=(q)=>A.check(mju(Wdq,q)),A.ksuid=(q)=>A.check(bju(Xdq,q)),A.ipv4=(q)=>A.check(tju(Ydq,q)),A.ipv6=(q)=>A.check(yju(Vdq,q)),A.cidrv4=(q)=>A.check(vju(Zdq,q)),A.cidrv6=(q)=>A.check(lju(Hdq,q)),A.e164=(q)=>A.check(dju($dq,q)),A.datetime=(q)=>A.check(gX2(q)),A.date=(q)=>A.check(QX2(q)),A.time=(q)=>A.check(jX2(q)),A.duration=(q)=>A.check(KX2(q))});oG=Z2("ZodStringFormat",(A,u)=>{BG.init(A,u),VUu.init(A,u)}),jdq=Z2("ZodEmail",(A,u)=>{xQu.init(A,u),oG.init(A,u)}),WUu=Z2("ZodGUID",(A,u)=>{LQu.init(A,u),oG.init(A,u)}),ZF0=Z2("ZodUUID",(A,u)=>{EQu.init(A,u),oG.init(A,u)}),ZUu=Z2("ZodURL",(A,u)=>{zQu.init(A,u),oG.init(A,u)});Kdq=Z2("ZodEmoji",(A,u)=>{RQu.init(A,u),oG.init(A,u)}),Udq=Z2("ZodNanoID",(A,u)=>{DQu.init(A,u),oG.init(A,u)}),_dq=Z2("ZodCUID",(A,u)=>{PQu.init(A,u),oG.init(A,u)}),Jdq=Z2("ZodCUID2",(A,u)=>{TQu.init(A,u),oG.init(A,u)}),Odq=Z2("ZodULID",(A,u)=>{IQu.init(A,u),oG.init(A,u)}),Wdq=Z2("ZodXID",(A,u)=>{kQu.init(A,u),oG.init(A,u)}),Xdq=Z2("ZodKSUID",(A,u)=>{SQu.init(A,u),oG.init(A,u)}),Ydq=Z2("ZodIPv4",(A,u)=>{bQu.init(A,u),oG.init(A,u)}),Vdq=Z2("ZodIPv6",(A,u)=>{tQu.init(A,u),oG.init(A,u)}),Zdq=Z2("ZodCIDRv4",(A,u)=>{yQu.init(A,u),oG.init(A,u)}),Hdq=Z2("ZodCIDRv6",(A,u)=>{vQu.init(A,u),oG.init(A,u)}),Ndq=Z2("ZodBase64",(A,u)=>{iQu.init(A,u),oG.init(A,u)}),Bdq=Z2("ZodBase64URL",(A,u)=>{cQu.init(A,u),oG.init(A,u)}),$dq=Z2("ZodE164",(A,u)=>{dQu.init(A,u),oG.init(A,u)}),Mdq=Z2("ZodJWT",(A,u)=>{nQu.init(A,u),oG.init(A,u)}),HF0=Z2("ZodNumber",(A,u)=>{fW2.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(F,G,w)=>YKu(A,F,G,w),A.gt=(F,G)=>A.check(PgA(F,G)),A.gte=(F,G)=>A.check(cz(F,G)),A.min=(F,G)=>A.check(cz(F,G)),A.lt=(F,G)=>A.check(DgA(F,G)),A.lte=(F,G)=>A.check(oh(F,G)),A.max=(F,G)=>A.check(oh(F,G)),A.int=(F)=>A.check(XUu(F)),A.safe=(F)=>A.check(XUu(F)),A.positive=(F)=>A.check(PgA(0,F)),A.nonnegative=(F)=>A.check(cz(0,F)),A.negative=(F)=>A.check(DgA(0,F)),A.nonpositive=(F)=>A.check(oh(0,F)),A.multipleOf=(F,G)=>A.check($PA(F,G)),A.step=(F,G)=>A.check($PA(F,G)),A.finite=()=>A;let q=A._zod.bag;A.minValue=Math.max(q.minimum??Number.NEGATIVE_INFINITY,q.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,A.maxValue=Math.min(q.maximum??Number.POSITIVE_INFINITY,q.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,A.isInt=(q.format??"").includes("int")||Number.isSafeInteger(q.multipleOf??0.5),A.isFinite=!0,A.format=q.format??null});Ldq=Z2("ZodNumberFormat",(A,u)=>{pQu.init(A,u),HF0.init(A,u)});YX2=Z2("ZodBoolean",(A,u)=>{aQu.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>VKu(A,q,F,G)});NUu=Z2("ZodBigInt",(A,u)=>{rQu.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(F,G,w)=>ZKu(A,F,G,w),A.gte=(F,G)=>A.check(cz(F,G)),A.min=(F,G)=>A.check(cz(F,G)),A.gt=(F,G)=>A.check(PgA(F,G)),A.gte=(F,G)=>A.check(cz(F,G)),A.min=(F,G)=>A.check(cz(F,G)),A.lt=(F,G)=>A.check(DgA(F,G)),A.lte=(F,G)=>A.check(oh(F,G)),A.max=(F,G)=>A.check(oh(F,G)),A.positive=(F)=>A.check(PgA(BigInt(0),F)),A.negative=(F)=>A.check(DgA(BigInt(0),F)),A.nonpositive=(F)=>A.check(oh(BigInt(0),F)),A.nonnegative=(F)=>A.check(cz(BigInt(0),F)),A.multipleOf=(F,G)=>A.check($PA(F,G));let q=A._zod.bag;A.minValue=q.minimum??null,A.maxValue=q.maximum??null,A.format=q.format??null}),Edq=Z2("ZodNull",(A,u)=>{oQu.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>HKu(A,q,F,G)});xdq=Z2("ZodAny",(A,u)=>{sQu.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>BKu(A,q,F,G)});zdq=Z2("ZodUnknown",(A,u)=>{eQu.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>$Ku(A,q,F,G)});Rdq=Z2("ZodNever",(A,u)=>{Aju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>NKu(A,q,F,G)});MUu=Z2("ZodDate",(A,u)=>{uju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(F,G,w)=>MKu(A,F,G,w),A.min=(F,G)=>A.check(cz(F,G)),A.max=(F,G)=>A.check(oh(F,G));let q=A._zod.bag;A.minDate=q.minimum?new Date(q.minimum):null,A.maxDate=q.maximum?new Date(q.maximum):null}),Pdq=Z2("ZodArray",(A,u)=>{qju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>RKu(A,q,F,G),A.element=u.element,A.min=(q,F)=>A.check(TgA(q,F)),A.nonempty=(q)=>A.check(TgA(1,q)),A.max=(q,F)=>A.check(JF0(q,F)),A.length=(q,F)=>A.check(OF0(q,F)),A.unwrap=()=>A.element});LUu=Z2("ZodObject",(A,u)=>{wju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>DKu(A,q,F,G),Nq.defineLazy(A,"shape",()=>{return u.shape}),A.keyof=()=>qZ(Object.keys(A._zod.def.shape)),A.catchall=(q)=>A.clone({...A._zod.def,catchall:q}),A.passthrough=()=>A.clone({...A._zod.def,catchall:sG()}),A.loose=()=>A.clone({...A._zod.def,catchall:sG()}),A.strict=()=>A.clone({...A._zod.def,catchall:Ddq()}),A.strip=()=>A.clone({...A._zod.def,catchall:void 0}),A.extend=(q)=>{return Nq.extend(A,q)},A.safeExtend=(q)=>{return Nq.safeExtend(A,q)},A.merge=(q)=>Nq.merge(A,q),A.pick=(q)=>Nq.pick(A,q),A.omit=(q)=>Nq.omit(A,q),A.partial=(...q)=>Nq.partial(zUu,A,q[0]),A.required=(...q)=>Nq.required(RUu,A,q[0])});EUu=Z2("ZodUnion",(A,u)=>{hW2.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>PKu(A,q,F,G),A.options=u.options});Tdq=Z2("ZodDiscriminatedUnion",(A,u)=>{EUu.init(A,u),gju.init(A,u)});Idq=Z2("ZodIntersection",(A,u)=>{Qju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>TKu(A,q,F,G)});kdq=Z2("ZodRecord",(A,u)=>{jju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>IKu(A,q,F,G),A.keyType=u.keyType,A.valueType=u.valueType});OX2=Z2("ZodEnum",(A,u)=>{Kju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(F,G,w)=>LKu(A,F,G,w),A.enum=u.entries,A.options=Object.values(u.entries);let q=new Set(Object.keys(u.entries));A.extract=(F,G)=>{let w={};for(let g of F)if(q.has(g))w[g]=u.entries[g];else throw Error(`Key ${g} not found in enum`);return new OX2({...u,checks:[],...Nq.normalizeParams(G),entries:w})},A.exclude=(F,G)=>{let w={...u.entries};for(let g of F)if(q.has(g))delete w[g];else throw Error(`Key ${g} not found in enum`);return new OX2({...u,checks:[],...Nq.normalizeParams(G),entries:w})}});Sdq=Z2("ZodLiteral",(A,u)=>{Uju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>EKu(A,q,F,G),A.values=new Set(u.values),Object.defineProperty(A,"value",{get(){if(u.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return u.values[0]}})});Cdq=Z2("ZodTransform",(A,u)=>{_ju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>zKu(A,q,F,G),A._zod.parse=(q,F)=>{if(F.direction==="backward")throw new _PA(A.constructor.name);q.addIssue=(w)=>{if(typeof w==="string")q.issues.push(Nq.issue(w,q.value,u));else{let g=w;if(g.fatal)g.continue=!1;g.code??(g.code="custom"),g.input??(g.input=q.value),g.inst??(g.inst=A),q.issues.push(Nq.issue(g))}};let G=u.transform(q.value,q);if(G instanceof Promise)return G.then((w)=>{return q.value=w,q});return q.value=G,q}});zUu=Z2("ZodOptional",(A,u)=>{mW2.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>GX2(A,q,F,G),A.unwrap=()=>A._zod.def.innerType});fdq=Z2("ZodExactOptional",(A,u)=>{Jju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>GX2(A,q,F,G),A.unwrap=()=>A._zod.def.innerType});mdq=Z2("ZodNullable",(A,u)=>{Oju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>kKu(A,q,F,G),A.unwrap=()=>A._zod.def.innerType});bdq=Z2("ZodDefault",(A,u)=>{Wju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>CKu(A,q,F,G),A.unwrap=()=>A._zod.def.innerType,A.removeDefault=A.unwrap});ydq=Z2("ZodPrefault",(A,u)=>{Xju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>fKu(A,q,F,G),A.unwrap=()=>A._zod.def.innerType});RUu=Z2("ZodNonOptional",(A,u)=>{Yju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>SKu(A,q,F,G),A.unwrap=()=>A._zod.def.innerType});idq=Z2("ZodCatch",(A,u)=>{Vju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>hKu(A,q,F,G),A.unwrap=()=>A._zod.def.innerType,A.removeCatch=A.unwrap});ddq=Z2("ZodPipe",(A,u)=>{Zju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>mKu(A,q,F,G),A.in=u.in,A.out=u.out});ndq=Z2("ZodReadonly",(A,u)=>{Hju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>bKu(A,q,F,G),A.unwrap=()=>A._zod.def.innerType});DUu=Z2("ZodCustom",(A,u)=>{Nju.init(A,u),UF.init(A,u),A._zod.processJSONSchema=(q,F,G)=>xKu(A,q,F,G)})});var IUu,TUu;var kUu=k(()=>{IUu={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};(function(A){})(TUu||(TUu={}))});var BF0={};bA(BF0,{string:()=>odq,number:()=>sdq,date:()=>unq,boolean:()=>edq,bigint:()=>Anq});function odq(A){return zju(XX2,A)}function sdq(A){return eju(HF0,A)}function edq(A){return qKu(YX2,A)}function Anq(A){return FKu(NUu,A)}function unq(A){return jKu(MUu,A)}var SUu=k(()=>{uZ();VF0()});var CUu=k(()=>{uZ();uZ();$ju();uZ();_F0();UX2();SUu();VF0();wX2();_X2();JX2();kUu();TN(bW2())});var fUu=k(()=>{CUu()});var HX2=k(()=>{fUu()});var SgA="2025-11-25",mUu,Pc="io.modelcontextprotocol/related-task",MF0="2.0",ZK,bUu,tUu,VWG,qnq,Fnq,NX2,kN,EPA,yUu=(A)=>EPA.safeParse(A).success,o_,qL,FL,s_,LF0,vUu,xPA=(A)=>vUu.safeParse(A).success,lUu,iUu=(A)=>lUu.safeParse(A).success,BX2,m0A=(A)=>BX2.safeParse(A).success,x4,$X2,cUu=(A)=>$X2.safeParse(A).success,Tc,ZWG,b0A,Gnq,EF0,wnq,zPA,kgA,dUu,gnq,Qnq,jnq,Knq,Unq,_nq,Jnq,Onq,MX2,nUu,pUu=(A)=>nUu.safeParse(A).success,xF0,Wnq,Xnq,zF0,Ynq,RPA,DPA,Vnq,PPA,t0A,Znq,TPA,RF0,DF0,PF0,HWG,TF0,IF0,kF0,aUu,rUu,oUu,LX2,sUu,IPA,CgA,eUu,Hnq,Nnq,EX2,Bnq,xX2,zX2,$nq,Mnq,RX2,DX2,Lnq,Enq,xnq,znq,Rnq,Dnq,Pnq,Tnq,Inq,PX2,knq,Snq,TX2,IX2,kX2,Cnq,fnq,hnq,SX2,mnq,CX2,fX2,bnq,tnq,A_u,ynq,hX2,Ic,NWG,vnq,lnq,kPA,u_u,q_u,inq,cnq,dnq,nnq,pnq,anq,rnq,onq,snq,$F0,enq,Apq,mX2,bX2,tX2,upq,qpq,Fpq,Gpq,wpq,gpq,Qpq,jpq,Kpq,Upq,_pq,Jpq,Opq,Wpq,Xpq,yX2,Ypq,Vpq,vX2,Zpq,Hpq,Npq,Bpq,lX2,$pq,Mpq,Lpq,Epq,BWG,$WG,MWG,LWG,EWG,xWG,D5,F_u;var sh=k(()=>{HX2();mUu=[SgA,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],ZK=PUu((A)=>A!==null&&(typeof A==="object"||typeof A==="function")),bUu=$G([I0(),Pq().int()]),tUu=I0(),VWG=VK({ttl:Pq().optional(),pollInterval:Pq().optional()}),qnq=k6({ttl:Pq().optional()}),Fnq=k6({taskId:I0()}),NX2=VK({progressToken:bUu.optional(),[Pc]:Fnq.optional()}),kN=k6({_meta:NX2.optional()}),EPA=kN.extend({task:qnq.optional()}),o_=k6({method:I0(),params:kN.loose().optional()}),qL=k6({_meta:NX2.optional()}),FL=k6({method:I0(),params:qL.loose().optional()}),s_=VK({_meta:NX2.optional()}),LF0=$G([I0(),Pq().int()]),vUu=k6({jsonrpc:bu(MF0),id:LF0,...o_.shape}).strict(),lUu=k6({jsonrpc:bu(MF0),...FL.shape}).strict(),BX2=k6({jsonrpc:bu(MF0),id:LF0,result:s_}).strict();(function(A){A[A.ConnectionClosed=-32000]="ConnectionClosed",A[A.RequestTimeout=-32001]="RequestTimeout",A[A.ParseError=-32700]="ParseError",A[A.InvalidRequest=-32600]="InvalidRequest",A[A.MethodNotFound=-32601]="MethodNotFound",A[A.InvalidParams=-32602]="InvalidParams",A[A.InternalError=-32603]="InternalError",A[A.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(x4||(x4={}));$X2=k6({jsonrpc:bu(MF0),id:LF0.optional(),error:k6({code:Pq().int(),message:I0(),data:sG().optional()})}).strict(),Tc=$G([vUu,lUu,BX2,$X2]),ZWG=$G([BX2,$X2]),b0A=s_.strict(),Gnq=qL.extend({requestId:LF0.optional(),reason:I0().optional()}),EF0=FL.extend({method:bu("notifications/cancelled"),params:Gnq}),wnq=k6({src:I0(),mimeType:I0().optional(),sizes:R6(I0()).optional(),theme:qZ(["light","dark"]).optional()}),zPA=k6({icons:R6(wnq).optional()}),kgA=k6({name:I0(),title:I0().optional()}),dUu=kgA.extend({...kgA.shape,...zPA.shape,version:I0(),websiteUrl:I0().optional(),description:I0().optional()}),gnq=NF0(k6({applyDefaults:_F().optional()}),tF(I0(),sG())),Qnq=ZX2((A)=>{if(A&&typeof A==="object"&&!Array.isArray(A)){if(Object.keys(A).length===0)return{form:{}}}return A},NF0(k6({form:gnq.optional(),url:ZK.optional()}),tF(I0(),sG()).optional())),jnq=VK({list:ZK.optional(),cancel:ZK.optional(),requests:VK({sampling:VK({createMessage:ZK.optional()}).optional(),elicitation:VK({create:ZK.optional()}).optional()}).optional()}),Knq=VK({list:ZK.optional(),cancel:ZK.optional(),requests:VK({tools:VK({call:ZK.optional()}).optional()}).optional()}),Unq=k6({experimental:tF(I0(),ZK).optional(),sampling:k6({context:ZK.optional(),tools:ZK.optional()}).optional(),elicitation:Qnq.optional(),roots:k6({listChanged:_F().optional()}).optional(),tasks:jnq.optional(),extensions:tF(I0(),ZK).optional()}),_nq=kN.extend({protocolVersion:I0(),capabilities:Unq,clientInfo:dUu}),Jnq=o_.extend({method:bu("initialize"),params:_nq}),Onq=k6({experimental:tF(I0(),ZK).optional(),logging:ZK.optional(),completions:ZK.optional(),prompts:k6({listChanged:_F().optional()}).optional(),resources:k6({subscribe:_F().optional(),listChanged:_F().optional()}).optional(),tools:k6({listChanged:_F().optional()}).optional(),tasks:Knq.optional(),extensions:tF(I0(),ZK).optional()}),MX2=s_.extend({protocolVersion:I0(),capabilities:Onq,serverInfo:dUu,instructions:I0().optional()}),nUu=FL.extend({method:bu("notifications/initialized"),params:qL.optional()}),xF0=o_.extend({method:bu("ping"),params:kN.optional()}),Wnq=k6({progress:Pq(),total:eG(Pq()),message:eG(I0())}),Xnq=k6({...qL.shape,...Wnq.shape,progressToken:bUu}),zF0=FL.extend({method:bu("notifications/progress"),params:Xnq}),Ynq=kN.extend({cursor:tUu.optional()}),RPA=o_.extend({params:Ynq.optional()}),DPA=s_.extend({nextCursor:tUu.optional()}),Vnq=qZ(["working","input_required","completed","failed","cancelled"]),PPA=k6({taskId:I0(),status:Vnq,ttl:$G([Pq(),BUu()]),createdAt:I0(),lastUpdatedAt:I0(),pollInterval:eG(Pq()),statusMessage:eG(I0())}),t0A=s_.extend({task:PPA}),Znq=qL.merge(PPA),TPA=FL.extend({method:bu("notifications/tasks/status"),params:Znq}),RF0=o_.extend({method:bu("tasks/get"),params:kN.extend({taskId:I0()})}),DF0=s_.merge(PPA),PF0=o_.extend({method:bu("tasks/result"),params:kN.extend({taskId:I0()})}),HWG=s_.loose(),TF0=RPA.extend({method:bu("tasks/list")}),IF0=DPA.extend({tasks:R6(PPA)}),kF0=o_.extend({method:bu("tasks/cancel"),params:kN.extend({taskId:I0()})}),aUu=s_.merge(PPA),rUu=k6({uri:I0(),mimeType:eG(I0()),_meta:tF(I0(),sG()).optional()}),oUu=rUu.extend({text:I0()}),LX2=I0().refine((A)=>{try{return atob(A),!0}catch{return!1}},{message:"Invalid Base64 string"}),sUu=rUu.extend({blob:LX2}),IPA=qZ(["user","assistant"]),CgA=k6({audience:R6(IPA).optional(),priority:Pq().min(0).max(1).optional(),lastModified:LPA.datetime({offset:!0}).optional()}),eUu=k6({...kgA.shape,...zPA.shape,uri:I0(),description:eG(I0()),mimeType:eG(I0()),size:eG(Pq()),annotations:CgA.optional(),_meta:eG(VK({}))}),Hnq=k6({...kgA.shape,...zPA.shape,uriTemplate:I0(),description:eG(I0()),mimeType:eG(I0()),annotations:CgA.optional(),_meta:eG(VK({}))}),Nnq=RPA.extend({method:bu("resources/list")}),EX2=DPA.extend({resources:R6(eUu)}),Bnq=RPA.extend({method:bu("resources/templates/list")}),xX2=DPA.extend({resourceTemplates:R6(Hnq)}),zX2=kN.extend({uri:I0()}),$nq=zX2,Mnq=o_.extend({method:bu("resources/read"),params:$nq}),RX2=s_.extend({contents:R6($G([oUu,sUu]))}),DX2=FL.extend({method:bu("notifications/resources/list_changed"),params:qL.optional()}),Lnq=zX2,Enq=o_.extend({method:bu("resources/subscribe"),params:Lnq}),xnq=zX2,znq=o_.extend({method:bu("resources/unsubscribe"),params:xnq}),Rnq=qL.extend({uri:I0()}),Dnq=FL.extend({method:bu("notifications/resources/updated"),params:Rnq}),Pnq=k6({name:I0(),description:eG(I0()),required:eG(_F())}),Tnq=k6({...kgA.shape,...zPA.shape,description:eG(I0()),arguments:eG(R6(Pnq)),_meta:eG(VK({}))}),Inq=RPA.extend({method:bu("prompts/list")}),PX2=DPA.extend({prompts:R6(Tnq)}),knq=kN.extend({name:I0(),arguments:tF(I0(),I0()).optional()}),Snq=o_.extend({method:bu("prompts/get"),params:knq}),TX2=k6({type:bu("text"),text:I0(),annotations:CgA.optional(),_meta:tF(I0(),sG()).optional()}),IX2=k6({type:bu("image"),data:LX2,mimeType:I0(),annotations:CgA.optional(),_meta:tF(I0(),sG()).optional()}),kX2=k6({type:bu("audio"),data:LX2,mimeType:I0(),annotations:CgA.optional(),_meta:tF(I0(),sG()).optional()}),Cnq=k6({type:bu("tool_use"),name:I0(),id:I0(),input:tF(I0(),sG()),_meta:tF(I0(),sG()).optional()}),fnq=k6({type:bu("resource"),resource:$G([oUu,sUu]),annotations:CgA.optional(),_meta:tF(I0(),sG()).optional()}),hnq=eUu.extend({type:bu("resource_link")}),SX2=$G([TX2,IX2,kX2,hnq,fnq]),mnq=k6({role:IPA,content:SX2}),CX2=s_.extend({description:I0().optional(),messages:R6(mnq)}),fX2=FL.extend({method:bu("notifications/prompts/list_changed"),params:qL.optional()}),bnq=k6({title:I0().optional(),readOnlyHint:_F().optional(),destructiveHint:_F().optional(),idempotentHint:_F().optional(),openWorldHint:_F().optional()}),tnq=k6({taskSupport:qZ(["required","optional","forbidden"]).optional()}),A_u=k6({...kgA.shape,...zPA.shape,description:I0().optional(),inputSchema:k6({type:bu("object"),properties:tF(I0(),ZK).optional(),required:R6(I0()).optional()}).catchall(sG()),outputSchema:k6({type:bu("object"),properties:tF(I0(),ZK).optional(),required:R6(I0()).optional()}).catchall(sG()).optional(),annotations:bnq.optional(),execution:tnq.optional(),_meta:tF(I0(),sG()).optional()}),ynq=RPA.extend({method:bu("tools/list")}),hX2=DPA.extend({tools:R6(A_u)}),Ic=s_.extend({content:R6(SX2).default([]),structuredContent:tF(I0(),sG()).optional(),isError:_F().optional()}),NWG=Ic.or(s_.extend({toolResult:sG()})),vnq=EPA.extend({name:I0(),arguments:tF(I0(),sG()).optional()}),lnq=o_.extend({method:bu("tools/call"),params:vnq}),kPA=FL.extend({method:bu("notifications/tools/list_changed"),params:qL.optional()}),u_u=k6({autoRefresh:_F().default(!0),debounceMs:Pq().int().nonnegative().default(300)}),q_u=qZ(["debug","info","notice","warning","error","critical","alert","emergency"]),inq=kN.extend({level:q_u}),cnq=o_.extend({method:bu("logging/setLevel"),params:inq}),dnq=qL.extend({level:q_u,logger:I0().optional(),data:sG()}),nnq=FL.extend({method:bu("notifications/message"),params:dnq}),pnq=k6({name:I0().optional()}),anq=k6({hints:R6(pnq).optional(),costPriority:Pq().min(0).max(1).optional(),speedPriority:Pq().min(0).max(1).optional(),intelligencePriority:Pq().min(0).max(1).optional()}),rnq=k6({mode:qZ(["auto","required","none"]).optional()}),onq=k6({type:bu("tool_result"),toolUseId:I0().describe("The unique identifier for the corresponding tool call."),content:R6(SX2).default([]),structuredContent:k6({}).loose().optional(),isError:_F().optional(),_meta:tF(I0(),sG()).optional()}),snq=VX2("type",[TX2,IX2,kX2]),$F0=VX2("type",[TX2,IX2,kX2,Cnq,onq]),enq=k6({role:IPA,content:$G([$F0,R6($F0)]),_meta:tF(I0(),sG()).optional()}),Apq=EPA.extend({messages:R6(enq),modelPreferences:anq.optional(),systemPrompt:I0().optional(),includeContext:qZ(["none","thisServer","allServers"]).optional(),temperature:Pq().optional(),maxTokens:Pq().int(),stopSequences:R6(I0()).optional(),metadata:ZK.optional(),tools:R6(A_u).optional(),toolChoice:rnq.optional()}),mX2=o_.extend({method:bu("sampling/createMessage"),params:Apq}),bX2=s_.extend({model:I0(),stopReason:eG(qZ(["endTurn","stopSequence","maxTokens"]).or(I0())),role:IPA,content:snq}),tX2=s_.extend({model:I0(),stopReason:eG(qZ(["endTurn","stopSequence","maxTokens","toolUse"]).or(I0())),role:IPA,content:$G([$F0,R6($F0)])}),upq=k6({type:bu("boolean"),title:I0().optional(),description:I0().optional(),default:_F().optional()}),qpq=k6({type:bu("string"),title:I0().optional(),description:I0().optional(),minLength:Pq().optional(),maxLength:Pq().optional(),format:qZ(["email","uri","date","date-time"]).optional(),default:I0().optional()}),Fpq=k6({type:qZ(["number","integer"]),title:I0().optional(),description:I0().optional(),minimum:Pq().optional(),maximum:Pq().optional(),default:Pq().optional()}),Gpq=k6({type:bu("string"),title:I0().optional(),description:I0().optional(),enum:R6(I0()),default:I0().optional()}),wpq=k6({type:bu("string"),title:I0().optional(),description:I0().optional(),oneOf:R6(k6({const:I0(),title:I0()})),default:I0().optional()}),gpq=k6({type:bu("string"),title:I0().optional(),description:I0().optional(),enum:R6(I0()),enumNames:R6(I0()).optional(),default:I0().optional()}),Qpq=$G([Gpq,wpq]),jpq=k6({type:bu("array"),title:I0().optional(),description:I0().optional(),minItems:Pq().optional(),maxItems:Pq().optional(),items:k6({type:bu("string"),enum:R6(I0())}),default:R6(I0()).optional()}),Kpq=k6({type:bu("array"),title:I0().optional(),description:I0().optional(),minItems:Pq().optional(),maxItems:Pq().optional(),items:k6({anyOf:R6(k6({const:I0(),title:I0()}))}),default:R6(I0()).optional()}),Upq=$G([jpq,Kpq]),_pq=$G([gpq,Qpq,Upq]),Jpq=$G([_pq,upq,qpq,Fpq]),Opq=EPA.extend({mode:bu("form").optional(),message:I0(),requestedSchema:k6({type:bu("object"),properties:tF(I0(),Jpq),required:R6(I0()).optional()})}),Wpq=EPA.extend({mode:bu("url"),message:I0(),elicitationId:I0(),url:I0().url()}),Xpq=$G([Opq,Wpq]),yX2=o_.extend({method:bu("elicitation/create"),params:Xpq}),Ypq=qL.extend({elicitationId:I0()}),Vpq=FL.extend({method:bu("notifications/elicitation/complete"),params:Ypq}),vX2=s_.extend({action:qZ(["accept","decline","cancel"]),content:ZX2((A)=>A===null?void 0:A,tF(I0(),$G([I0(),Pq(),_F(),R6(I0())])).optional())}),Zpq=k6({type:bu("ref/resource"),uri:I0()}),Hpq=k6({type:bu("ref/prompt"),name:I0()}),Npq=kN.extend({ref:$G([Hpq,Zpq]),argument:k6({name:I0(),value:I0()}),context:k6({arguments:tF(I0(),I0()).optional()}).optional()}),Bpq=o_.extend({method:bu("completion/complete"),params:Npq}),lX2=s_.extend({completion:VK({values:R6(I0()).max(100),total:eG(Pq().int()),hasMore:eG(_F())})}),$pq=k6({uri:I0().startsWith("file://"),name:I0().optional(),_meta:tF(I0(),sG()).optional()}),Mpq=o_.extend({method:bu("roots/list"),params:kN.optional()}),Lpq=s_.extend({roots:R6($pq)}),Epq=FL.extend({method:bu("notifications/roots/list_changed"),params:qL.optional()}),BWG=$G([xF0,Jnq,Bpq,cnq,Snq,Inq,Nnq,Bnq,Mnq,Enq,znq,lnq,ynq,RF0,PF0,TF0,kF0]),$WG=$G([EF0,zF0,nUu,Epq,TPA]),MWG=$G([b0A,bX2,tX2,vX2,Lpq,DF0,IF0,t0A]),LWG=$G([xF0,mX2,yX2,Mpq,RF0,PF0,TF0,kF0]),EWG=$G([EF0,zF0,nnq,Dnq,DX2,kPA,fX2,TPA,Vpq]),xWG=$G([b0A,MX2,lX2,CX2,PX2,EX2,xX2,RX2,Ic,hX2,DF0,IF0,t0A]);D5=class D5 extends Error{constructor(A,u,q){super(`MCP error ${A}: ${u}`);this.code=A,this.data=q,this.name="McpError"}static fromError(A,u,q){if(A===x4.UrlElicitationRequired&&q){let F=q;if(F.elicitations)return new F_u(F.elicitations,u)}return new D5(A,u,q)}};F_u=class F_u extends D5{constructor(A,u=`URL elicitation${A.length>1?"s":""} required`){super(x4.UrlElicitationRequired,u,{elicitations:A})}get elicitations(){return this.data?.elicitations??[]}}});function kc(A){return A==="completed"||A==="failed"||A==="cancelled"}var xpq;var SF0=k(()=>{xpq=Symbol("Let zodToJsonSchema decide on which parser to use")});var iX2=k(()=>{SF0()});var GL=()=>{};var cX2=k(()=>{Xj()});var dX2=()=>{};var CF0=k(()=>{Xj()});var nX2=k(()=>{Xj()});var pX2=()=>{};var aX2=k(()=>{Xj()});var rX2=k(()=>{Xj();GL()});var oX2=k(()=>{Xj()});var wXG;var fF0=k(()=>{wXG=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789")});var hF0=k(()=>{Xj();fF0();CF0();GL()});var sX2=k(()=>{Xj();hF0();GL()});var eX2=k(()=>{GL()});var mF0=k(()=>{Xj()});var AY2=k(()=>{Xj();mF0()});var uY2=()=>{};var qY2=k(()=>{Xj()});var FY2=k(()=>{Xj();GL()});var GY2=k(()=>{Xj()});var wY2=k(()=>{Xj()});var gY2=k(()=>{Xj()});var QY2=k(()=>{Xj()});var jY2=k(()=>{GL()});var KY2=k(()=>{GL()});var UY2=k(()=>{Xj()});var _Y2=k(()=>{GL();cX2();dX2();CF0();nX2();pX2();aX2();rX2();oX2();sX2();eX2();AY2();uY2();qY2();FY2();GY2();wY2();hF0();gY2();fF0();QY2();jY2();mF0();KY2();UY2()});var Xj=k(()=>{SF0();_Y2();GL()});var G_u=()=>{};var JY2=k(()=>{Xj();iX2();GL()});var w_u=k(()=>{JY2();SF0();iX2();Xj();G_u();GL();cX2();dX2();CF0();nX2();pX2();aX2();rX2();oX2();sX2();eX2();AY2();uY2();qY2();FY2();GY2();wY2();UY2();hF0();gY2();fF0();QY2();jY2();mF0();KY2();_Y2();JY2()});function OY2(A){let q=XF0(A)?.method;if(!q)throw Error("Schema is missing a method literal");let F=aKu(q);if(typeof F!=="string")throw Error("Schema method literal must be a string");return F}function WY2(A,u){let q=dz(A,u);if(!q.success)throw q.error;return q.data}var g_u=k(()=>{YF0();w_u()});class XY2{constructor(A){if(this._options=A,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(EF0,(u)=>{this._oncancel(u)}),this.setNotificationHandler(zF0,(u)=>{this._onprogress(u)}),this.setRequestHandler(xF0,(u)=>({})),this._taskStore=A?.taskStore,this._taskMessageQueue=A?.taskMessageQueue,this._taskStore)this.setRequestHandler(RF0,async(u,q)=>{let F=await this._taskStore.getTask(u.params.taskId,q.sessionId);if(!F)throw new D5(x4.InvalidParams,"Failed to retrieve task: Task not found");return{...F}}),this.setRequestHandler(PF0,async(u,q)=>{let F=async()=>{let G=u.params.taskId;if(this._taskMessageQueue){let g;while(g=await this._taskMessageQueue.dequeue(G,q.sessionId)){if(g.type==="response"||g.type==="error"){let Q=g.message,j=Q.id,K=this._requestResolvers.get(j);if(K)if(this._requestResolvers.delete(j),g.type==="response")K(Q);else{let U=Q,_=new D5(U.error.code,U.error.message,U.error.data);K(_)}else{let U=g.type==="response"?"Response":"Error";this._onerror(Error(`${U} handler missing for request ${j}`))}continue}await this._transport?.send(g.message,{relatedRequestId:q.requestId})}}let w=await this._taskStore.getTask(G,q.sessionId);if(!w)throw new D5(x4.InvalidParams,`Task not found: ${G}`);if(!kc(w.status))return await this._waitForTaskUpdate(G,q.signal),await F();if(kc(w.status)){let g=await this._taskStore.getTaskResult(G,q.sessionId);return this._clearTaskQueue(G),{...g,_meta:{...g._meta,[Pc]:{taskId:G}}}}return await F()};return await F()}),this.setRequestHandler(TF0,async(u,q)=>{try{let{tasks:F,nextCursor:G}=await this._taskStore.listTasks(u.params?.cursor,q.sessionId);return{tasks:F,nextCursor:G,_meta:{}}}catch(F){throw new D5(x4.InvalidParams,`Failed to list tasks: ${F instanceof Error?F.message:String(F)}`)}}),this.setRequestHandler(kF0,async(u,q)=>{try{let F=await this._taskStore.getTask(u.params.taskId,q.sessionId);if(!F)throw new D5(x4.InvalidParams,`Task not found: ${u.params.taskId}`);if(kc(F.status))throw new D5(x4.InvalidParams,`Cannot cancel task in terminal status: ${F.status}`);await this._taskStore.updateTaskStatus(u.params.taskId,"cancelled","Client cancelled task execution.",q.sessionId),this._clearTaskQueue(u.params.taskId);let G=await this._taskStore.getTask(u.params.taskId,q.sessionId);if(!G)throw new D5(x4.InvalidParams,`Task not found after cancellation: ${u.params.taskId}`);return{_meta:{},...G}}catch(F){if(F instanceof D5)throw F;throw new D5(x4.InvalidRequest,`Failed to cancel task: ${F instanceof Error?F.message:String(F)}`)}})}async _oncancel(A){if(!A.params.requestId)return;this._requestHandlerAbortControllers.get(A.params.requestId)?.abort(A.params.reason)}_setupTimeout(A,u,q,F,G=!1){this._timeoutInfo.set(A,{timeoutId:setTimeout(F,u),startTime:Date.now(),timeout:u,maxTotalTimeout:q,resetTimeoutOnProgress:G,onTimeout:F})}_resetTimeout(A){let u=this._timeoutInfo.get(A);if(!u)return!1;let q=Date.now()-u.startTime;if(u.maxTotalTimeout&&q>=u.maxTotalTimeout)throw this._timeoutInfo.delete(A),D5.fromError(x4.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:u.maxTotalTimeout,totalElapsed:q});return clearTimeout(u.timeoutId),u.timeoutId=setTimeout(u.onTimeout,u.timeout),!0}_cleanupTimeout(A){let u=this._timeoutInfo.get(A);if(u)clearTimeout(u.timeoutId),this._timeoutInfo.delete(A)}async connect(A){if(this._transport)throw Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=A;let u=this.transport?.onclose;this._transport.onclose=()=>{u?.(),this._onclose()};let q=this.transport?.onerror;this._transport.onerror=(G)=>{q?.(G),this._onerror(G)};let F=this._transport?.onmessage;this._transport.onmessage=(G,w)=>{if(F?.(G,w),m0A(G)||cUu(G))this._onresponse(G);else if(xPA(G))this._onrequest(G,w);else if(iUu(G))this._onnotification(G);else this._onerror(Error(`Unknown message type: ${JSON.stringify(G)}`))},await this._transport.start()}_onclose(){let A=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let q of this._timeoutInfo.values())clearTimeout(q.timeoutId);this._timeoutInfo.clear();for(let q of this._requestHandlerAbortControllers.values())q.abort();this._requestHandlerAbortControllers.clear();let u=D5.fromError(x4.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let q of A.values())q(u)}_onerror(A){this.onerror?.(A)}_onnotification(A){let u=this._notificationHandlers.get(A.method)??this.fallbackNotificationHandler;if(u===void 0)return;Promise.resolve().then(()=>u(A)).catch((q)=>this._onerror(Error(`Uncaught error in notification handler: ${q}`)))}_onrequest(A,u){let q=this._requestHandlers.get(A.method)??this.fallbackRequestHandler,F=this._transport,G=A.params?._meta?.[Pc]?.taskId;if(q===void 0){let K={jsonrpc:"2.0",id:A.id,error:{code:x4.MethodNotFound,message:"Method not found"}};if(G&&this._taskMessageQueue)this._enqueueTaskMessage(G,{type:"error",message:K,timestamp:Date.now()},F?.sessionId).catch((U)=>this._onerror(Error(`Failed to enqueue error response: ${U}`)));else F?.send(K).catch((U)=>this._onerror(Error(`Failed to send an error response: ${U}`)));return}let w=new AbortController;this._requestHandlerAbortControllers.set(A.id,w);let g=yUu(A.params)?A.params.task:void 0,Q=this._taskStore?this.requestTaskStore(A,F?.sessionId):void 0,j={signal:w.signal,sessionId:F?.sessionId,_meta:A.params?._meta,sendNotification:async(K)=>{if(w.signal.aborted)return;let U={relatedRequestId:A.id};if(G)U.relatedTask={taskId:G};await this.notification(K,U)},sendRequest:async(K,U,_)=>{if(w.signal.aborted)throw new D5(x4.ConnectionClosed,"Request was cancelled");let O={..._,relatedRequestId:A.id};if(G&&!O.relatedTask)O.relatedTask={taskId:G};let W=O.relatedTask?.taskId??G;if(W&&Q)await Q.updateTaskStatus(W,"input_required");return await this.request(K,U,O)},authInfo:u?.authInfo,requestId:A.id,requestInfo:u?.requestInfo,taskId:G,taskStore:Q,taskRequestedTtl:g?.ttl,closeSSEStream:u?.closeSSEStream,closeStandaloneSSEStream:u?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(g)this.assertTaskHandlerCapability(A.method)}).then(()=>q(A,j)).then(async(K)=>{if(w.signal.aborted)return;let U={result:K,jsonrpc:"2.0",id:A.id};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"response",message:U,timestamp:Date.now()},F?.sessionId);else await F?.send(U)},async(K)=>{if(w.signal.aborted)return;let U={jsonrpc:"2.0",id:A.id,error:{code:Number.isSafeInteger(K.code)?K.code:x4.InternalError,message:K.message??"Internal error",...K.data!==void 0&&{data:K.data}}};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"error",message:U,timestamp:Date.now()},F?.sessionId);else await F?.send(U)}).catch((K)=>this._onerror(Error(`Failed to send response: ${K}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(A.id)===w)this._requestHandlerAbortControllers.delete(A.id)})}_onprogress(A){let{progressToken:u,...q}=A.params,F=Number(u),G=this._progressHandlers.get(F);if(!G){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(A)}`));return}let w=this._responseHandlers.get(F),g=this._timeoutInfo.get(F);if(g&&w&&g.resetTimeoutOnProgress)try{this._resetTimeout(F)}catch(Q){this._responseHandlers.delete(F),this._progressHandlers.delete(F),this._cleanupTimeout(F),w(Q);return}G(q)}_onresponse(A){let u=Number(A.id),q=this._requestResolvers.get(u);if(q){if(this._requestResolvers.delete(u),m0A(A))q(A);else{let w=new D5(A.error.code,A.error.message,A.error.data);q(w)}return}let F=this._responseHandlers.get(u);if(F===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(A)}`));return}this._responseHandlers.delete(u),this._cleanupTimeout(u);let G=!1;if(m0A(A)&&A.result&&typeof A.result==="object"){let w=A.result;if(w.task&&typeof w.task==="object"){let g=w.task;if(typeof g.taskId==="string")G=!0,this._taskProgressTokens.set(g.taskId,u)}}if(!G)this._progressHandlers.delete(u);if(m0A(A))F(A);else{let w=D5.fromError(A.error.code,A.error.message,A.error.data);F(w)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(A,u,q){let{task:F}=q??{};if(!F){try{yield{type:"result",result:await this.request(A,u,q)}}catch(w){yield{type:"error",error:w instanceof D5?w:new D5(x4.InternalError,String(w))}}return}let G;try{let w=await this.request(A,t0A,q);if(w.task)G=w.task.taskId,yield{type:"taskCreated",task:w.task};else throw new D5(x4.InternalError,"Task creation did not return a task");while(!0){let g=await this.getTask({taskId:G},q);if(yield{type:"taskStatus",task:g},kc(g.status)){if(g.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:G},u,q)};else if(g.status==="failed")yield{type:"error",error:new D5(x4.InternalError,`Task ${G} failed`)};else if(g.status==="cancelled")yield{type:"error",error:new D5(x4.InternalError,`Task ${G} was cancelled`)};return}if(g.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:G},u,q)};return}let Q=g.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((j)=>setTimeout(j,Q)),q?.signal?.throwIfAborted()}}catch(w){yield{type:"error",error:w instanceof D5?w:new D5(x4.InternalError,String(w))}}}request(A,u,q){let{relatedRequestId:F,resumptionToken:G,onresumptiontoken:w,task:g,relatedTask:Q}=q??{};return new Promise((j,K)=>{let U=(Z)=>{K(Z)};if(!this._transport){U(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(A.method),g)this.assertTaskCapability(A.method)}catch(Z){U(Z);return}q?.signal?.throwIfAborted();let _=this._requestMessageId++,O={...A,jsonrpc:"2.0",id:_};if(q?.onprogress)this._progressHandlers.set(_,q.onprogress),O.params={...A.params,_meta:{...A.params?._meta||{},progressToken:_}};if(g)O.params={...O.params,task:g};if(Q)O.params={...O.params,_meta:{...O.params?._meta||{},[Pc]:Q}};let W=(Z)=>{this._responseHandlers.delete(_),this._progressHandlers.delete(_),this._cleanupTimeout(_),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:_,reason:String(Z)}},{relatedRequestId:F,resumptionToken:G,onresumptiontoken:w}).catch((N)=>this._onerror(Error(`Failed to send cancellation: ${N}`)));let H=Z instanceof D5?Z:new D5(x4.RequestTimeout,String(Z));K(H)};this._responseHandlers.set(_,(Z)=>{if(q?.signal?.aborted)return;if(Z instanceof Error)return K(Z);try{let H=dz(u,Z.result);if(!H.success)K(H.error);else j(H.data)}catch(H){K(H)}}),q?.signal?.addEventListener("abort",()=>{W(q?.signal?.reason)});let X=q?.timeout??Ipq,Y=()=>W(D5.fromError(x4.RequestTimeout,"Request timed out",{timeout:X}));this._setupTimeout(_,X,q?.maxTotalTimeout,Y,q?.resetTimeoutOnProgress??!1);let V=Q?.taskId;if(V){let Z=(H)=>{let N=this._responseHandlers.get(_);if(N)N(H);else this._onerror(Error(`Response handler missing for side-channeled request ${_}`))};this._requestResolvers.set(_,Z),this._enqueueTaskMessage(V,{type:"request",message:O,timestamp:Date.now()}).catch((H)=>{this._cleanupTimeout(_),K(H)})}else this._transport.send(O,{relatedRequestId:F,resumptionToken:G,onresumptiontoken:w}).catch((Z)=>{this._cleanupTimeout(_),K(Z)})})}async getTask(A,u){return this.request({method:"tasks/get",params:A},DF0,u)}async getTaskResult(A,u,q){return this.request({method:"tasks/result",params:A},u,q)}async listTasks(A,u){return this.request({method:"tasks/list",params:A},IF0,u)}async cancelTask(A,u){return this.request({method:"tasks/cancel",params:A},aUu,u)}async notification(A,u){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(A.method);let q=u?.relatedTask?.taskId;if(q){let g={...A,jsonrpc:"2.0",params:{...A.params,_meta:{...A.params?._meta||{},[Pc]:u.relatedTask}}};await this._enqueueTaskMessage(q,{type:"notification",message:g,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(A.method)&&!A.params&&!u?.relatedRequestId&&!u?.relatedTask){if(this._pendingDebouncedNotifications.has(A.method))return;this._pendingDebouncedNotifications.add(A.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(A.method),!this._transport)return;let g={...A,jsonrpc:"2.0"};if(u?.relatedTask)g={...g,params:{...g.params,_meta:{...g.params?._meta||{},[Pc]:u.relatedTask}}};this._transport?.send(g,u).catch((Q)=>this._onerror(Q))});return}let w={...A,jsonrpc:"2.0"};if(u?.relatedTask)w={...w,params:{...w.params,_meta:{...w.params?._meta||{},[Pc]:u.relatedTask}}};await this._transport.send(w,u)}setRequestHandler(A,u){let q=OY2(A);this.assertRequestHandlerCapability(q),this._requestHandlers.set(q,(F,G)=>{let w=WY2(A,F);return Promise.resolve(u(w,G))})}removeRequestHandler(A){this._requestHandlers.delete(A)}assertCanSetRequestHandler(A){if(this._requestHandlers.has(A))throw Error(`A request handler for ${A} already exists, which would be overridden`)}setNotificationHandler(A,u){let q=OY2(A);this._notificationHandlers.set(q,(F)=>{let G=WY2(A,F);return Promise.resolve(u(G))})}removeNotificationHandler(A){this._notificationHandlers.delete(A)}_cleanupTaskProgressHandler(A){let u=this._taskProgressTokens.get(A);if(u!==void 0)this._progressHandlers.delete(u),this._taskProgressTokens.delete(A)}async _enqueueTaskMessage(A,u,q){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let F=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(A,u,q,F)}async _clearTaskQueue(A,u){if(this._taskMessageQueue){let q=await this._taskMessageQueue.dequeueAll(A,u);for(let F of q)if(F.type==="request"&&xPA(F.message)){let G=F.message.id,w=this._requestResolvers.get(G);if(w)w(new D5(x4.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(G);else this._onerror(Error(`Resolver missing for request ${G} during task ${A} cleanup`))}}}async _waitForTaskUpdate(A,u){let q=this._options?.defaultTaskPollInterval??1000;try{let F=await this._taskStore?.getTask(A);if(F?.pollInterval)q=F.pollInterval}catch{}return new Promise((F,G)=>{if(u.aborted){G(new D5(x4.InvalidRequest,"Request cancelled"));return}let w=setTimeout(F,q);u.addEventListener("abort",()=>{clearTimeout(w),G(new D5(x4.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(A,u){let q=this._taskStore;if(!q)throw Error("No task store configured");return{createTask:async(F)=>{if(!A)throw Error("No request provided");return await q.createTask(F,A.id,{method:A.method,params:A.params},u)},getTask:async(F)=>{let G=await q.getTask(F,u);if(!G)throw new D5(x4.InvalidParams,"Failed to retrieve task: Task not found");return G},storeTaskResult:async(F,G,w)=>{await q.storeTaskResult(F,G,w,u);let g=await q.getTask(F,u);if(g){let Q=TPA.parse({method:"notifications/tasks/status",params:g});if(await this.notification(Q),kc(g.status))this._cleanupTaskProgressHandler(F)}},getTaskResult:(F)=>{return q.getTaskResult(F,u)},updateTaskStatus:async(F,G,w)=>{let g=await q.getTask(F,u);if(!g)throw new D5(x4.InvalidParams,`Task "${F}" not found - it may have been cleaned up`);if(kc(g.status))throw new D5(x4.InvalidParams,`Cannot update task "${F}" from terminal status "${g.status}" to "${G}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await q.updateTaskStatus(F,G,w,u);let Q=await q.getTask(F,u);if(Q){let j=TPA.parse({method:"notifications/tasks/status",params:Q});if(await this.notification(j),kc(Q.status))this._cleanupTaskProgressHandler(F)}},listTasks:(F)=>{return q.listTasks(F,u)}}}}function Q_u(A){return A!==null&&typeof A==="object"&&!Array.isArray(A)}function j_u(A,u){let q={...A};for(let F in u){let G=F,w=u[G];if(w===void 0)continue;let g=q[G];if(Q_u(g)&&Q_u(w))q[G]={...g,...w};else q[G]=w}return q}var Ipq=60000;var K_u=k(()=>{YF0();sh();g_u()});function kpq(){let A=new U_u.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return __u.default(A),A}class YY2{constructor(A){this._ajv=A??kpq()}getValidator(A){let u="$id"in A&&typeof A.$id==="string"?this._ajv.getSchema(A.$id)??this._ajv.compile(A):this._ajv.compile(A);return(q)=>{if(u(q))return{valid:!0,data:q,errorMessage:void 0};else return{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(u.errors)}}}}var U_u,__u;var J_u=k(()=>{U_u=u2(OxA(),1),__u=u2(C30(),1)});class VY2{constructor(A){this._client=A}async*callToolStream(A,u=Ic,q){let F=this._client,G={...q,task:q?.task??(F.isToolTask(A.name)?{}:void 0)},w=F.requestStream({method:"tools/call",params:A},u,G),g=F.getToolOutputValidator(A.name);for await(let Q of w){if(Q.type==="result"&&g){let j=Q.result;if(!j.structuredContent&&!j.isError){yield{type:"error",error:new D5(x4.InvalidRequest,`Tool ${A.name} has an output schema but did not return structured content`)};return}if(j.structuredContent)try{let K=g(j.structuredContent);if(!K.valid){yield{type:"error",error:new D5(x4.InvalidParams,`Structured content does not match the tool's output schema: ${K.errorMessage}`)};return}}catch(K){if(K instanceof D5){yield{type:"error",error:K};return}yield{type:"error",error:new D5(x4.InvalidParams,`Failed to validate structured content: ${K instanceof Error?K.message:String(K)}`)};return}}yield Q}}async getTask(A,u){return this._client.getTask({taskId:A},u)}async getTaskResult(A,u,q){return this._client.getTaskResult({taskId:A},u,q)}async listTasks(A,u){return this._client.listTasks(A?{cursor:A}:void 0,u)}async cancelTask(A,u){return this._client.cancelTask({taskId:A},u)}requestStream(A,u,q){return this._client.requestStream(A,u,q)}}var O_u=k(()=>{sh()});function W_u(A,u,q){if(!A)throw Error(`${q} does not support task creation (required for ${u})`);switch(u){case"tools/call":if(!A.tools?.call)throw Error(`${q} does not support task creation for tools/call (required for ${u})`);break;default:break}}function X_u(A,u,q){if(!A)throw Error(`${q} does not support task creation (required for ${u})`);switch(u){case"sampling/createMessage":if(!A.sampling?.createMessage)throw Error(`${q} does not support task creation for sampling/createMessage (required for ${u})`);break;case"elicitation/create":if(!A.elicitation?.create)throw Error(`${q} does not support task creation for elicitation/create (required for ${u})`);break;default:break}}function bF0(A,u){if(!A||u===null||typeof u!=="object")return;if(A.type==="object"&&A.properties&&typeof A.properties==="object"){let q=u,F=A.properties;for(let G of Object.keys(F)){let w=F[G];if(q[G]===void 0&&Object.prototype.hasOwnProperty.call(w,"default"))q[G]=w.default;if(q[G]!==void 0)bF0(w,q[G])}}if(Array.isArray(A.anyOf)){for(let q of A.anyOf)if(typeof q!=="boolean")bF0(q,u)}if(Array.isArray(A.oneOf)){for(let q of A.oneOf)if(typeof q!=="boolean")bF0(q,u)}}function Spq(A){if(!A)return{supportsFormMode:!1,supportsUrlMode:!1};let u=A.form!==void 0,q=A.url!==void 0;return{supportsFormMode:u||!u&&!q,supportsUrlMode:q}}var tF0;var Y_u=k(()=>{K_u();sh();J_u();YF0();O_u();tF0=class tF0 extends XY2{constructor(A,u){super(u);if(this._clientInfo=A,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=u?.capabilities??{},this._jsonSchemaValidator=u?.jsonSchemaValidator??new YY2,u?.listChanged)this._pendingListChangedConfig=u.listChanged}_setupListChangedHandlers(A){if(A.tools&&this._serverCapabilities?.tools?.listChanged)this._setupListChangedHandler("tools",kPA,A.tools,async()=>{return(await this.listTools()).tools});if(A.prompts&&this._serverCapabilities?.prompts?.listChanged)this._setupListChangedHandler("prompts",fX2,A.prompts,async()=>{return(await this.listPrompts()).prompts});if(A.resources&&this._serverCapabilities?.resources?.listChanged)this._setupListChangedHandler("resources",DX2,A.resources,async()=>{return(await this.listResources()).resources})}get experimental(){if(!this._experimental)this._experimental={tasks:new VY2(this)};return this._experimental}registerCapabilities(A){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=j_u(this._capabilities,A)}setRequestHandler(A,u){let F=XF0(A)?.method;if(!F)throw Error("Schema is missing a method literal");let G;if(IgA(F)){let g=F;G=g._zod?.def?.value??g.value}else{let g=F;G=g._def?.value??g.value}if(typeof G!=="string")throw Error("Schema method literal must be a string");let w=G;if(w==="elicitation/create"){let g=async(Q,j)=>{let K=dz(yX2,Q);if(!K.success){let Z=K.error instanceof Error?K.error.message:String(K.error);throw new D5(x4.InvalidParams,`Invalid elicitation request: ${Z}`)}let{params:U}=K.data;U.mode=U.mode??"form";let{supportsFormMode:_,supportsUrlMode:O}=Spq(this._capabilities.elicitation);if(U.mode==="form"&&!_)throw new D5(x4.InvalidParams,"Client does not support form-mode elicitation requests");if(U.mode==="url"&&!O)throw new D5(x4.InvalidParams,"Client does not support URL-mode elicitation requests");let W=await Promise.resolve(u(Q,j));if(U.task){let Z=dz(t0A,W);if(!Z.success){let H=Z.error instanceof Error?Z.error.message:String(Z.error);throw new D5(x4.InvalidParams,`Invalid task creation result: ${H}`)}return Z.data}let X=dz(vX2,W);if(!X.success){let Z=X.error instanceof Error?X.error.message:String(X.error);throw new D5(x4.InvalidParams,`Invalid elicitation result: ${Z}`)}let Y=X.data,V=U.mode==="form"?U.requestedSchema:void 0;if(U.mode==="form"&&Y.action==="accept"&&Y.content&&V){if(this._capabilities.elicitation?.form?.applyDefaults)try{bF0(V,Y.content)}catch{}}return Y};return super.setRequestHandler(A,g)}if(w==="sampling/createMessage"){let g=async(Q,j)=>{let K=dz(mX2,Q);if(!K.success){let Y=K.error instanceof Error?K.error.message:String(K.error);throw new D5(x4.InvalidParams,`Invalid sampling request: ${Y}`)}let{params:U}=K.data,_=await Promise.resolve(u(Q,j));if(U.task){let Y=dz(t0A,_);if(!Y.success){let V=Y.error instanceof Error?Y.error.message:String(Y.error);throw new D5(x4.InvalidParams,`Invalid task creation result: ${V}`)}return Y.data}let W=U.tools||U.toolChoice?tX2:bX2,X=dz(W,_);if(!X.success){let Y=X.error instanceof Error?X.error.message:String(X.error);throw new D5(x4.InvalidParams,`Invalid sampling result: ${Y}`)}return X.data};return super.setRequestHandler(A,g)}return super.setRequestHandler(A,u)}assertCapability(A,u){if(!this._serverCapabilities?.[A])throw Error(`Server does not support ${A} (required for ${u})`)}async connect(A,u){if(await super.connect(A),A.sessionId!==void 0)return;try{let q=await this.request({method:"initialize",params:{protocolVersion:SgA,capabilities:this._capabilities,clientInfo:this._clientInfo}},MX2,u);if(q===void 0)throw Error(`Server sent invalid initialize result: ${q}`);if(!mUu.includes(q.protocolVersion))throw Error(`Server's protocol version is not supported: ${q.protocolVersion}`);if(this._serverCapabilities=q.capabilities,this._serverVersion=q.serverInfo,A.setProtocolVersion)A.setProtocolVersion(q.protocolVersion);if(this._instructions=q.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig)this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0}catch(q){throw this.close(),q}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(A){switch(A){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw Error(`Server does not support logging (required for ${A})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw Error(`Server does not support prompts (required for ${A})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw Error(`Server does not support resources (required for ${A})`);if(A==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw Error(`Server does not support resource subscriptions (required for ${A})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw Error(`Server does not support tools (required for ${A})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw Error(`Server does not support completions (required for ${A})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(A){switch(A){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw Error(`Client does not support roots list changed notifications (required for ${A})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(A){if(!this._capabilities)return;switch(A){case"sampling/createMessage":if(!this._capabilities.sampling)throw Error(`Client does not support sampling capability (required for ${A})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw Error(`Client does not support elicitation capability (required for ${A})`);break;case"roots/list":if(!this._capabilities.roots)throw Error(`Client does not support roots capability (required for ${A})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw Error(`Client does not support tasks capability (required for ${A})`);break;case"ping":break}}assertTaskCapability(A){W_u(this._serverCapabilities?.tasks?.requests,A,"Server")}assertTaskHandlerCapability(A){if(!this._capabilities)return;X_u(this._capabilities.tasks?.requests,A,"Client")}async ping(A){return this.request({method:"ping"},b0A,A)}async complete(A,u){return this.request({method:"completion/complete",params:A},lX2,u)}async setLoggingLevel(A,u){return this.request({method:"logging/setLevel",params:{level:A}},b0A,u)}async getPrompt(A,u){return this.request({method:"prompts/get",params:A},CX2,u)}async listPrompts(A,u){return this.request({method:"prompts/list",params:A},PX2,u)}async listResources(A,u){return this.request({method:"resources/list",params:A},EX2,u)}async listResourceTemplates(A,u){return this.request({method:"resources/templates/list",params:A},xX2,u)}async readResource(A,u){return this.request({method:"resources/read",params:A},RX2,u)}async subscribeResource(A,u){return this.request({method:"resources/subscribe",params:A},b0A,u)}async unsubscribeResource(A,u){return this.request({method:"resources/unsubscribe",params:A},b0A,u)}async callTool(A,u=Ic,q){if(this.isToolTaskRequired(A.name))throw new D5(x4.InvalidRequest,`Tool "${A.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let F=await this.request({method:"tools/call",params:A},u,q),G=this.getToolOutputValidator(A.name);if(G){if(!F.structuredContent&&!F.isError)throw new D5(x4.InvalidRequest,`Tool ${A.name} has an output schema but did not return structured content`);if(F.structuredContent)try{let w=G(F.structuredContent);if(!w.valid)throw new D5(x4.InvalidParams,`Structured content does not match the tool's output schema: ${w.errorMessage}`)}catch(w){if(w instanceof D5)throw w;throw new D5(x4.InvalidParams,`Failed to validate structured content: ${w instanceof Error?w.message:String(w)}`)}}return F}isToolTask(A){if(!this._serverCapabilities?.tasks?.requests?.tools?.call)return!1;return this._cachedKnownTaskTools.has(A)}isToolTaskRequired(A){return this._cachedRequiredTaskTools.has(A)}cacheToolMetadata(A){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let u of A){if(u.outputSchema){let F=this._jsonSchemaValidator.getValidator(u.outputSchema);this._cachedToolOutputValidators.set(u.name,F)}let q=u.execution?.taskSupport;if(q==="required"||q==="optional")this._cachedKnownTaskTools.add(u.name);if(q==="required")this._cachedRequiredTaskTools.add(u.name)}}getToolOutputValidator(A){return this._cachedToolOutputValidators.get(A)}async listTools(A,u){let q=await this.request({method:"tools/list",params:A},hX2,u);return this.cacheToolMetadata(q.tools),q}_setupListChangedHandler(A,u,q,F){let G=u_u.safeParse(q);if(!G.success)throw Error(`Invalid ${A} listChanged options: ${G.error.message}`);if(typeof q.onChanged!=="function")throw Error(`Invalid ${A} listChanged options: onChanged must be a function`);let{autoRefresh:w,debounceMs:g}=G.data,{onChanged:Q}=q,j=async()=>{if(!w){Q(null,null);return}try{let U=await F();Q(null,U)}catch(U){let _=U instanceof Error?U:Error(String(U));Q(_,null)}},K=()=>{if(g){let U=this._listChangedDebounceTimers.get(A);if(U)clearTimeout(U);let _=setTimeout(j,g);this._listChangedDebounceTimers.set(A,_)}else j()};this.setNotificationHandler(u,K)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}});function fgA(A){if(!A)return{};if(A instanceof Headers)return Object.fromEntries(A.entries());if(Array.isArray(A))return Object.fromEntries(A);return{...A}}function yF0(A=fetch,u){if(!u)return A;return async(q,F)=>{let G={...u,...F,headers:F?.headers?{...fgA(u.headers),...fgA(F.headers)}:u.headers};return A(q,G)}}async function Cpq(A){return(await ZY2).getRandomValues(new Uint8Array(A))}async function fpq(A){let q=Math.pow(2,8)-Math.pow(2,8)%66,F="";while(F.length<A){let G=await Cpq(A-F.length);for(let w of G)if(w<q)F+="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~"[w%66]}return F}async function hpq(A){return await fpq(A)}async function mpq(A){let u=await(await ZY2).subtle.digest("SHA-256",new TextEncoder().encode(A));return btoa(String.fromCharCode(...new Uint8Array(u))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function HY2(A){if(!A)A=43;if(A<43||A>128)throw`Expected a length between 43 and 128. Received ${A}.`;let u=await hpq(A),q=await mpq(u);return{code_verifier:u,code_challenge:q}}var ZY2;var V_u=k(()=>{ZY2=globalThis.crypto});var AJ,H_u,NY2,bpq,N_u,B_u,$_u,Z_u,tpq,ypq,M_u,YZG,VZG;var BY2=k(()=>{HX2();AJ=HUu().superRefine((A,u)=>{if(!URL.canParse(A))return u.addIssue({code:IUu.custom,message:"URL must be parseable",fatal:!0}),XW2}).refine((A)=>{let u=new URL(A);return u.protocol!=="javascript:"&&u.protocol!=="data:"&&u.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),H_u=VK({resource:I0().url(),authorization_servers:R6(AJ).optional(),jwks_uri:I0().url().optional(),scopes_supported:R6(I0()).optional(),bearer_methods_supported:R6(I0()).optional(),resource_signing_alg_values_supported:R6(I0()).optional(),resource_name:I0().optional(),resource_documentation:I0().optional(),resource_policy_uri:I0().url().optional(),resource_tos_uri:I0().url().optional(),tls_client_certificate_bound_access_tokens:_F().optional(),authorization_details_types_supported:R6(I0()).optional(),dpop_signing_alg_values_supported:R6(I0()).optional(),dpop_bound_access_tokens_required:_F().optional()}),NY2=VK({issuer:I0(),authorization_endpoint:AJ,token_endpoint:AJ,registration_endpoint:AJ.optional(),scopes_supported:R6(I0()).optional(),response_types_supported:R6(I0()),response_modes_supported:R6(I0()).optional(),grant_types_supported:R6(I0()).optional(),token_endpoint_auth_methods_supported:R6(I0()).optional(),token_endpoint_auth_signing_alg_values_supported:R6(I0()).optional(),service_documentation:AJ.optional(),revocation_endpoint:AJ.optional(),revocation_endpoint_auth_methods_supported:R6(I0()).optional(),revocation_endpoint_auth_signing_alg_values_supported:R6(I0()).optional(),introspection_endpoint:I0().optional(),introspection_endpoint_auth_methods_supported:R6(I0()).optional(),introspection_endpoint_auth_signing_alg_values_supported:R6(I0()).optional(),code_challenge_methods_supported:R6(I0()).optional(),client_id_metadata_document_supported:_F().optional()}),bpq=VK({issuer:I0(),authorization_endpoint:AJ,token_endpoint:AJ,userinfo_endpoint:AJ.optional(),jwks_uri:AJ,registration_endpoint:AJ.optional(),scopes_supported:R6(I0()).optional(),response_types_supported:R6(I0()),response_modes_supported:R6(I0()).optional(),grant_types_supported:R6(I0()).optional(),acr_values_supported:R6(I0()).optional(),subject_types_supported:R6(I0()),id_token_signing_alg_values_supported:R6(I0()),id_token_encryption_alg_values_supported:R6(I0()).optional(),id_token_encryption_enc_values_supported:R6(I0()).optional(),userinfo_signing_alg_values_supported:R6(I0()).optional(),userinfo_encryption_alg_values_supported:R6(I0()).optional(),userinfo_encryption_enc_values_supported:R6(I0()).optional(),request_object_signing_alg_values_supported:R6(I0()).optional(),request_object_encryption_alg_values_supported:R6(I0()).optional(),request_object_encryption_enc_values_supported:R6(I0()).optional(),token_endpoint_auth_methods_supported:R6(I0()).optional(),token_endpoint_auth_signing_alg_values_supported:R6(I0()).optional(),display_values_supported:R6(I0()).optional(),claim_types_supported:R6(I0()).optional(),claims_supported:R6(I0()).optional(),service_documentation:I0().optional(),claims_locales_supported:R6(I0()).optional(),ui_locales_supported:R6(I0()).optional(),claims_parameter_supported:_F().optional(),request_parameter_supported:_F().optional(),request_uri_parameter_supported:_F().optional(),require_request_uri_registration:_F().optional(),op_policy_uri:AJ.optional(),op_tos_uri:AJ.optional(),client_id_metadata_document_supported:_F().optional()}),N_u=k6({...bpq.shape,...NY2.pick({code_challenge_methods_supported:!0}).shape}),B_u=k6({access_token:I0(),id_token:I0().optional(),token_type:I0(),expires_in:BF0.number().optional(),scope:I0().optional(),refresh_token:I0().optional()}).strip(),$_u=k6({error:I0(),error_description:I0().optional(),error_uri:I0().optional()}),Z_u=AJ.optional().or(bu("").transform(()=>{return})),tpq=k6({redirect_uris:R6(AJ),token_endpoint_auth_method:I0().optional(),grant_types:R6(I0()).optional(),response_types:R6(I0()).optional(),client_name:I0().optional(),client_uri:AJ.optional(),logo_uri:Z_u,scope:I0().optional(),contacts:R6(I0()).optional(),tos_uri:Z_u,policy_uri:I0().optional(),jwks_uri:AJ.optional(),jwks:$Uu().optional(),software_id:I0().optional(),software_version:I0().optional(),software_statement:I0().optional()}).strip(),ypq=k6({client_id:I0(),client_secret:I0().optional(),client_id_issued_at:Pq().optional(),client_secret_expires_at:Pq().optional()}).strip(),M_u=tpq.merge(ypq),YZG=k6({error:I0(),error_description:I0().optional()}).strip(),VZG=k6({token:I0(),token_type_hint:I0().optional()}).strip()});function L_u(A){let u=typeof A==="string"?new URL(A):new URL(A.href);return u.hash="",u}function E_u({requestedResource:A,configuredResource:u}){let q=typeof A==="string"?new URL(A):new URL(A.href),F=typeof u==="string"?new URL(u):new URL(u.href);if(q.origin!==F.origin)return!1;if(q.pathname.length<F.pathname.length)return!1;let G=q.pathname.endsWith("/")?q.pathname:q.pathname+"/",w=F.pathname.endsWith("/")?F.pathname:F.pathname+"/";return G.startsWith(w)}var Yj,vF0,hgA,mgA,bgA,lF0,iF0,cF0,Sc,dF0,nF0,pF0,aF0,rF0,oF0,tgA,sF0,eF0,x_u;var z_u=k(()=>{Yj=class Yj extends Error{constructor(A,u){super(A);this.errorUri=u,this.name=this.constructor.name}toResponseObject(){let A={error:this.errorCode,error_description:this.message};if(this.errorUri)A.error_uri=this.errorUri;return A}get errorCode(){return this.constructor.errorCode}};vF0=class vF0 extends Yj{};vF0.errorCode="invalid_request";hgA=class hgA extends Yj{};hgA.errorCode="invalid_client";mgA=class mgA extends Yj{};mgA.errorCode="invalid_grant";bgA=class bgA extends Yj{};bgA.errorCode="unauthorized_client";lF0=class lF0 extends Yj{};lF0.errorCode="unsupported_grant_type";iF0=class iF0 extends Yj{};iF0.errorCode="invalid_scope";cF0=class cF0 extends Yj{};cF0.errorCode="access_denied";Sc=class Sc extends Yj{};Sc.errorCode="server_error";dF0=class dF0 extends Yj{};dF0.errorCode="temporarily_unavailable";nF0=class nF0 extends Yj{};nF0.errorCode="unsupported_response_type";pF0=class pF0 extends Yj{};pF0.errorCode="unsupported_token_type";aF0=class aF0 extends Yj{};aF0.errorCode="invalid_token";rF0=class rF0 extends Yj{};rF0.errorCode="method_not_allowed";oF0=class oF0 extends Yj{};oF0.errorCode="too_many_requests";tgA=class tgA extends Yj{};tgA.errorCode="invalid_client_metadata";sF0=class sF0 extends Yj{};sF0.errorCode="insufficient_scope";eF0=class eF0 extends Yj{};eF0.errorCode="invalid_target";x_u={[vF0.errorCode]:vF0,[hgA.errorCode]:hgA,[mgA.errorCode]:mgA,[bgA.errorCode]:bgA,[lF0.errorCode]:lF0,[iF0.errorCode]:iF0,[cF0.errorCode]:cF0,[Sc.errorCode]:Sc,[dF0.errorCode]:dF0,[nF0.errorCode]:nF0,[pF0.errorCode]:pF0,[aF0.errorCode]:aF0,[rF0.errorCode]:rF0,[oF0.errorCode]:oF0,[tgA.errorCode]:tgA,[sF0.errorCode]:sF0,[eF0.errorCode]:eF0}});function vpq(A){return["client_secret_basic","client_secret_post","none"].includes(A)}function lpq(A,u){let q=A.client_secret!==void 0;if("token_endpoint_auth_method"in A&&A.token_endpoint_auth_method&&vpq(A.token_endpoint_auth_method)&&(u.length===0||u.includes(A.token_endpoint_auth_method)))return A.token_endpoint_auth_method;if(u.length===0)return q?"client_secret_basic":"none";if(q&&u.includes("client_secret_basic"))return"client_secret_basic";if(q&&u.includes("client_secret_post"))return"client_secret_post";if(u.includes("none"))return"none";return q?"client_secret_post":"none"}function ipq(A,u,q,F){let{client_id:G,client_secret:w}=u;switch(A){case"client_secret_basic":cpq(G,w,q);return;case"client_secret_post":dpq(G,w,F);return;case"none":npq(G,F);return;default:throw Error(`Unsupported client authentication method: ${A}`)}}function cpq(A,u,q){if(!u)throw Error("client_secret_basic authentication requires a client_secret");let F=btoa(`${A}:${u}`);q.set("Authorization",`Basic ${F}`)}function dpq(A,u,q){if(q.set("client_id",A),u)q.set("client_secret",u)}function npq(A,u){u.set("client_id",A)}async function D_u(A){let u=A instanceof Response?A.status:void 0,q=A instanceof Response?await A.text():A;try{let F=$_u.parse(JSON.parse(q)),{error:G,error_description:w,error_uri:g}=F;return new(x_u[G]||Sc)(w||"",g)}catch(F){let G=`${u?`HTTP ${u}: `:""}Invalid OAuth error response: ${F}. Raw body: ${q}`;return new Sc(G)}}async function Am(A,u){try{return await LY2(A,u)}catch(q){if(q instanceof hgA||q instanceof bgA)return await A.invalidateCredentials?.("all"),await LY2(A,u);else if(q instanceof mgA)return await A.invalidateCredentials?.("tokens"),await LY2(A,u);throw q}}async function LY2(A,{serverUrl:u,authorizationCode:q,scope:F,resourceMetadataUrl:G,fetchFn:w}){let g=await A.discoveryState?.(),Q,j,K,U=G;if(!U&&g?.resourceMetadataUrl)U=new URL(g.resourceMetadataUrl);if(g?.authorizationServerUrl){if(j=g.authorizationServerUrl,Q=g.resourceMetadata,K=g.authorizationServerMetadata??await T_u(j,{fetchFn:w}),!Q)try{Q=await P_u(u,{resourceMetadataUrl:U},w)}catch{}if(K!==g.authorizationServerMetadata||Q!==g.resourceMetadata)await A.saveDiscoveryState?.({authorizationServerUrl:String(j),resourceMetadataUrl:U?.toString(),resourceMetadata:Q,authorizationServerMetadata:K})}else{let N=await Aaq(u,{resourceMetadataUrl:U,fetchFn:w});j=N.authorizationServerUrl,K=N.authorizationServerMetadata,Q=N.resourceMetadata,await A.saveDiscoveryState?.({authorizationServerUrl:String(j),resourceMetadataUrl:U?.toString(),resourceMetadata:Q,authorizationServerMetadata:K})}let _=await apq(u,A,Q),O=F||Q?.scopes_supported?.join(" ")||A.clientMetadata.scope,W=await Promise.resolve(A.clientInformation());if(!W){if(q!==void 0)throw Error("Existing OAuth client information is required when exchanging an authorization code");let N=K?.client_id_metadata_document_supported===!0,B=A.clientMetadataUrl;if(B&&!ppq(B))throw new tgA(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${B}`);if(N&&B)W={client_id:B},await A.saveClientInformation?.(W);else{if(!A.saveClientInformation)throw Error("OAuth client information must be saveable for dynamic registration");let x=await waq(j,{metadata:K,clientMetadata:A.clientMetadata,scope:O,fetchFn:w});await A.saveClientInformation(x),W=x}}let X=!A.redirectUrl;if(q!==void 0||X){let N=await Gaq(A,j,{metadata:K,resource:_,authorizationCode:q,fetchFn:w});return await A.saveTokens(N),"AUTHORIZED"}let Y=await A.tokens();if(Y?.refresh_token)try{let N=await Faq(j,{metadata:K,clientInformation:W,refreshToken:Y.refresh_token,resource:_,addClientAuthentication:A.addClientAuthentication,fetchFn:w});return await A.saveTokens(N),"AUTHORIZED"}catch(N){if(!(N instanceof Yj)||N instanceof Sc);else throw N}let V=A.state?await A.state():void 0,{authorizationUrl:Z,codeVerifier:H}=await uaq(j,{metadata:K,clientInformation:W,state:V,redirectUrl:A.redirectUrl,scope:O,resource:_});return await A.saveCodeVerifier(H),await A.redirectToAuthorization(Z),"REDIRECT"}function ppq(A){if(!A)return!1;try{let u=new URL(A);return u.protocol==="https:"&&u.pathname!=="/"}catch{return!1}}async function apq(A,u,q){let F=L_u(A);if(u.validateResourceURL)return await u.validateResourceURL(F,q?.resource);if(!q)return;if(!E_u({requestedResource:F,configuredResource:q.resource}))throw Error(`Protected resource ${q.resource} does not match expected ${F} (or origin)`);return new URL(q.resource)}function ygA(A){let u=A.headers.get("WWW-Authenticate");if(!u)return{};let[q,F]=u.split(" ");if(q.toLowerCase()!=="bearer"||!F)return{};let G=EY2(A,"resource_metadata")||void 0,w;if(G)try{w=new URL(G)}catch{}let g=EY2(A,"scope")||void 0,Q=EY2(A,"error")||void 0;return{resourceMetadataUrl:w,scope:g,error:Q}}function EY2(A,u){let q=A.headers.get("WWW-Authenticate");if(!q)return null;let F=new RegExp(`${u}=(?:"([^"]+)"|([^\\s,]+))`),G=q.match(F);if(G)return G[1]||G[2];return null}async function P_u(A,u,q=fetch){let F=await spq(A,"oauth-protected-resource",q,{protocolVersion:u?.protocolVersion,metadataUrl:u?.resourceMetadataUrl});if(!F||F.status===404)throw await F?.body?.cancel(),Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!F.ok)throw await F.body?.cancel(),Error(`HTTP ${F.status} trying to load well-known OAuth protected resource metadata.`);return H_u.parse(await F.json())}async function xY2(A,u,q=fetch){try{return await q(A,{headers:u})}catch(F){if(F instanceof TypeError)if(u)return xY2(A,void 0,q);else return;throw F}}function rpq(A,u="",q={}){if(u.endsWith("/"))u=u.slice(0,-1);return q.prependPathname?`${u}/.well-known/${A}`:`/.well-known/${A}${u}`}async function R_u(A,u,q=fetch){return await xY2(A,{"MCP-Protocol-Version":u},q)}function opq(A,u){return!A||A.status>=400&&A.status<500&&u!=="/"}async function spq(A,u,q,F){let G=new URL(A),w=F?.protocolVersion??SgA,g;if(F?.metadataUrl)g=new URL(F.metadataUrl);else{let j=rpq(u,G.pathname);g=new URL(j,F?.metadataServerUrl??G),g.search=G.search}let Q=await R_u(g,w,q);if(!F?.metadataUrl&&opq(Q,G.pathname)){let j=new URL(`/.well-known/${u}`,G);Q=await R_u(j,w,q)}return Q}function epq(A){let u=typeof A==="string"?new URL(A):A,q=u.pathname!=="/",F=[];if(!q)return F.push({url:new URL("/.well-known/oauth-authorization-server",u.origin),type:"oauth"}),F.push({url:new URL("/.well-known/openid-configuration",u.origin),type:"oidc"}),F;let G=u.pathname;if(G.endsWith("/"))G=G.slice(0,-1);return F.push({url:new URL(`/.well-known/oauth-authorization-server${G}`,u.origin),type:"oauth"}),F.push({url:new URL(`/.well-known/openid-configuration${G}`,u.origin),type:"oidc"}),F.push({url:new URL(`${G}/.well-known/openid-configuration`,u.origin),type:"oidc"}),F}async function T_u(A,{fetchFn:u=fetch,protocolVersion:q=SgA}={}){let F={"MCP-Protocol-Version":q,Accept:"application/json"},G=epq(A);for(let{url:w,type:g}of G){let Q=await xY2(w,F,u);if(!Q)continue;if(!Q.ok){if(await Q.body?.cancel(),Q.status>=400&&Q.status<500)continue;throw Error(`HTTP ${Q.status} trying to load ${g==="oauth"?"OAuth":"OpenID provider"} metadata from ${w}`)}if(g==="oauth")return NY2.parse(await Q.json());else return N_u.parse(await Q.json())}return}async function Aaq(A,u){let q,F;try{if(q=await P_u(A,{resourceMetadataUrl:u?.resourceMetadataUrl},u?.fetchFn),q.authorization_servers&&q.authorization_servers.length>0)F=q.authorization_servers[0]}catch{}if(!F)F=String(new URL("/",A));let G=await T_u(F,{fetchFn:u?.fetchFn});return{authorizationServerUrl:F,authorizationServerMetadata:G,resourceMetadata:q}}async function uaq(A,{metadata:u,clientInformation:q,redirectUrl:F,scope:G,state:w,resource:g}){let Q;if(u){if(Q=new URL(u.authorization_endpoint),!u.response_types_supported.includes($Y2))throw Error(`Incompatible auth server: does not support response type ${$Y2}`);if(u.code_challenge_methods_supported&&!u.code_challenge_methods_supported.includes(MY2))throw Error(`Incompatible auth server: does not support code challenge method ${MY2}`)}else Q=new URL("/authorize",A);let j=await HY2(),K=j.code_verifier,U=j.code_challenge;if(Q.searchParams.set("response_type",$Y2),Q.searchParams.set("client_id",q.client_id),Q.searchParams.set("code_challenge",U),Q.searchParams.set("code_challenge_method",MY2),Q.searchParams.set("redirect_uri",String(F)),w)Q.searchParams.set("state",w);if(G)Q.searchParams.set("scope",G);if(G?.includes("offline_access"))Q.searchParams.append("prompt","consent");if(g)Q.searchParams.set("resource",g.href);return{authorizationUrl:Q,codeVerifier:K}}function qaq(A,u,q){return new URLSearchParams({grant_type:"authorization_code",code:A,code_verifier:u,redirect_uri:String(q)})}async function I_u(A,{metadata:u,tokenRequestParams:q,clientInformation:F,addClientAuthentication:G,resource:w,fetchFn:g}){let Q=u?.token_endpoint?new URL(u.token_endpoint):new URL("/token",A),j=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(w)q.set("resource",w.href);if(G)await G(j,q,Q,u);else if(F){let U=u?.token_endpoint_auth_methods_supported??[],_=lpq(F,U);ipq(_,F,j,q)}let K=await(g??fetch)(Q,{method:"POST",headers:j,body:q});if(!K.ok)throw await D_u(K);return B_u.parse(await K.json())}async function Faq(A,{metadata:u,clientInformation:q,refreshToken:F,resource:G,addClientAuthentication:w,fetchFn:g}){let Q=new URLSearchParams({grant_type:"refresh_token",refresh_token:F}),j=await I_u(A,{metadata:u,tokenRequestParams:Q,clientInformation:q,addClientAuthentication:w,resource:G,fetchFn:g});return{refresh_token:F,...j}}async function Gaq(A,u,{metadata:q,resource:F,authorizationCode:G,fetchFn:w}={}){let g=A.clientMetadata.scope,Q;if(A.prepareTokenRequest)Q=await A.prepareTokenRequest(g);if(!Q){if(!G)throw Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!A.redirectUrl)throw Error("redirectUrl is required for authorization_code flow");let K=await A.codeVerifier();Q=qaq(G,K,A.redirectUrl)}let j=await A.clientInformation();return I_u(u,{metadata:q,tokenRequestParams:Q,clientInformation:j??void 0,addClientAuthentication:A.addClientAuthentication,resource:F,fetchFn:w})}async function waq(A,{metadata:u,clientMetadata:q,scope:F,fetchFn:G}){let w;if(u){if(!u.registration_endpoint)throw Error("Incompatible auth server: does not support dynamic client registration");w=new URL(u.registration_endpoint)}else w=new URL("/register",A);let g=await(G??fetch)(w,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...q,...F!==void 0?{scope:F}:{}})});if(!g.ok)throw await D_u(g);return M_u.parse(await g.json())}var uJ,$Y2="code",MY2="S256";var AG0=k(()=>{V_u();sh();BY2();BY2();z_u();uJ=class uJ extends Error{constructor(A){super(A??"Unauthorized")}}});class uG0{constructor(A,u){this._hasCompletedAuthFlow=!1,this._url=A,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=u?.requestInit,this._authProvider=u?.authProvider,this._fetch=u?.fetch,this._fetchWithInit=yF0(u?.fetch,u?.requestInit),this._sessionId=u?.sessionId,this._reconnectionOptions=u?.reconnectionOptions??gaq}async _authThenStart(){if(!this._authProvider)throw new uJ("No auth provider");let A;try{A=await Am(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(u){throw this.onerror?.(u),u}if(A!=="AUTHORIZED")throw new uJ;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let A={};if(this._authProvider){let q=await this._authProvider.tokens();if(q)A.Authorization=`Bearer ${q.access_token}`}if(this._sessionId)A["mcp-session-id"]=this._sessionId;if(this._protocolVersion)A["mcp-protocol-version"]=this._protocolVersion;let u=fgA(this._requestInit?.headers);return new Headers({...A,...u})}async _startOrAuthSse(A){let{resumptionToken:u}=A;try{let q=await this._commonHeaders();if(q.set("Accept","text/event-stream"),u)q.set("last-event-id",u);let F=await(this._fetch??fetch)(this._url,{method:"GET",headers:q,signal:this._abortController?.signal});if(!F.ok){if(await F.body?.cancel(),F.status===401&&this._authProvider)return await this._authThenStart();if(F.status===405)return;throw new y0A(F.status,`Failed to open SSE stream: ${F.statusText}`)}this._handleSseStream(F.body,A,!0)}catch(q){throw this.onerror?.(q),q}}_getNextReconnectionDelay(A){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let u=this._reconnectionOptions.initialReconnectionDelay,q=this._reconnectionOptions.reconnectionDelayGrowFactor,F=this._reconnectionOptions.maxReconnectionDelay;return Math.min(u*Math.pow(q,A),F)}_scheduleReconnection(A,u=0){let q=this._reconnectionOptions.maxRetries;if(u>=q){this.onerror?.(Error(`Maximum reconnection attempts (${q}) exceeded.`));return}let F=this._getNextReconnectionDelay(u);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(A).catch((G)=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${G instanceof Error?G.message:String(G)}`)),this._scheduleReconnection(A,u+1)})},F)}_handleSseStream(A,u,q){if(!A)return;let{onresumptiontoken:F,replayMessageId:G}=u,w,g=!1,Q=!1;(async()=>{try{let K=A.pipeThrough(new TextDecoderStream).pipeThrough(new Te({onRetry:(O)=>{this._serverRetryMs=O}})).getReader();while(!0){let{value:O,done:W}=await K.read();if(W)break;if(O.id)w=O.id,g=!0,F?.(O.id);if(!O.data)continue;if(!O.event||O.event==="message")try{let X=Tc.parse(JSON.parse(O.data));if(m0A(X)){if(Q=!0,G!==void 0)X.id=G}this.onmessage?.(X)}catch(X){this.onerror?.(X)}}if((q||g)&&!Q&&this._abortController&&!this._abortController.signal.aborted)this._scheduleReconnection({resumptionToken:w,onresumptiontoken:F,replayMessageId:G},0)}catch(K){if(this.onerror?.(Error(`SSE stream disconnected: ${K}`)),(q||g)&&!Q&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:w,onresumptiontoken:F,replayMessageId:G},0)}catch(O){this.onerror?.(Error(`Failed to reconnect: ${O instanceof Error?O.message:String(O)}`))}}})()}async start(){if(this._abortController)throw Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(A){if(!this._authProvider)throw new uJ("No auth provider");if(await Am(this._authProvider,{serverUrl:this._url,authorizationCode:A,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new uJ("Failed to authorize")}async close(){if(this._reconnectionTimeout)clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0;this._abortController?.abort(),this.onclose?.()}async send(A,u){try{let{resumptionToken:q,onresumptiontoken:F}=u||{};if(q){this._startOrAuthSse({resumptionToken:q,replayMessageId:xPA(A)?A.id:void 0}).catch((_)=>this.onerror?.(_));return}let G=await this._commonHeaders();G.set("content-type","application/json"),G.set("accept","application/json, text/event-stream");let w={...this._requestInit,method:"POST",headers:G,body:JSON.stringify(A),signal:this._abortController?.signal},g=await(this._fetch??fetch)(this._url,w),Q=g.headers.get("mcp-session-id");if(Q)this._sessionId=Q;if(!g.ok){let _=await g.text().catch(()=>null);if(g.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new y0A(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:O,scope:W}=ygA(g);if(this._resourceMetadataUrl=O,this._scope=W,await Am(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new uJ;return this._hasCompletedAuthFlow=!0,this.send(A)}if(g.status===403&&this._authProvider){let{resourceMetadataUrl:O,scope:W,error:X}=ygA(g);if(X==="insufficient_scope"){let Y=g.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===Y)throw new y0A(403,"Server returned 403 after trying upscoping");if(W)this._scope=W;if(O)this._resourceMetadataUrl=O;if(this._lastUpscopingHeader=Y??void 0,await Am(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new uJ;return this.send(A)}}throw new y0A(g.status,`Error POSTing to endpoint: ${_}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,g.status===202){if(await g.body?.cancel(),pUu(A))this._startOrAuthSse({resumptionToken:void 0}).catch((_)=>this.onerror?.(_));return}let K=(Array.isArray(A)?A:[A]).filter((_)=>("method"in _)&&("id"in _)&&_.id!==void 0).length>0,U=g.headers.get("content-type");if(K)if(U?.includes("text/event-stream"))this._handleSseStream(g.body,{onresumptiontoken:F},!1);else if(U?.includes("application/json")){let _=await g.json(),O=Array.isArray(_)?_.map((W)=>Tc.parse(W)):[Tc.parse(_)];for(let W of O)this.onmessage?.(W)}else throw await g.body?.cancel(),new y0A(-1,`Unexpected content type: ${U}`);else await g.body?.cancel()}catch(q){throw this.onerror?.(q),q}}get sessionId(){return this._sessionId}async terminateSession(){if(!this._sessionId)return;try{let A=await this._commonHeaders(),u={...this._requestInit,method:"DELETE",headers:A,signal:this._abortController?.signal},q=await(this._fetch??fetch)(this._url,u);if(await q.body?.cancel(),!q.ok&&q.status!==405)throw new y0A(q.status,`Failed to terminate session: ${q.statusText}`);this._sessionId=void 0}catch(A){throw this.onerror?.(A),A}}setProtocolVersion(A){this._protocolVersion=A}get protocolVersion(){return this._protocolVersion}async resumeStream(A,u){await this._startOrAuthSse({resumptionToken:A,onresumptiontoken:u?.onresumptiontoken})}}var gaq,y0A;var k_u=k(()=>{sh();AG0();Du0();gaq={initialReconnectionDelay:1000,maxReconnectionDelay:30000,reconnectionDelayGrowFactor:1.5,maxRetries:2};y0A=class y0A extends Error{constructor(A,u){super(`Streamable HTTP error: ${u}`);this.code=A}}});function Qaq(A){let u=globalThis.DOMException;return typeof u=="function"?new u(A,"SyntaxError"):SyntaxError(A)}function RY2(A){return A instanceof Error?"errors"in A&&Array.isArray(A.errors)?A.errors.map(RY2).join(", "):("cause"in A)&&A.cause instanceof Error?`${A}: ${RY2(A.cause)}`:A.message:`${A}`}function S_u(A){return{type:A.type,message:A.message,code:A.code,defaultPrevented:A.defaultPrevented,cancelable:A.cancelable,timeStamp:A.timeStamp}}function jaq(){let A="document"in globalThis?globalThis.document:void 0;return A&&typeof A=="object"&&"baseURI"in A&&typeof A.baseURI=="string"?A.baseURI:void 0}var zY2,f_u=(A)=>{throw TypeError(A)},fY2=(A,u,q)=>u.has(A)||f_u("Cannot "+q),E8=(A,u,q)=>(fY2(A,u,"read from private field"),q?q.call(A):u.get(A)),HK=(A,u,q)=>u.has(A)?f_u("Cannot add the same private member more than once"):u instanceof WeakSet?u.add(A):u.set(A,q),Aw=(A,u,q,F)=>(fY2(A,u,"write to private field"),u.set(A,q),q),um=(A,u,q)=>(fY2(A,u,"access private method"),q),FZ,v0A,vgA,qG0,FG0,hPA,cgA,mPA,Cc,lgA,dgA,igA,CPA,nz,DY2,PY2,TY2,C_u,IY2,kY2,fPA,SY2,CY2,ngA;var h_u=k(()=>{bq2();zY2=class zY2 extends Event{constructor(A,u){var q,F;super(A),this.code=(q=u==null?void 0:u.code)!=null?q:void 0,this.message=(F=u==null?void 0:u.message)!=null?F:void 0}[Symbol.for("nodejs.util.inspect.custom")](A,u,q){return q(S_u(this),u)}[Symbol.for("Deno.customInspect")](A,u){return A(S_u(this),u)}};ngA=class ngA extends EventTarget{constructor(A,u){var q,F;super(),HK(this,nz),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,HK(this,FZ),HK(this,v0A),HK(this,vgA),HK(this,qG0),HK(this,FG0),HK(this,hPA),HK(this,cgA),HK(this,mPA,null),HK(this,Cc),HK(this,lgA),HK(this,dgA,null),HK(this,igA,null),HK(this,CPA,null),HK(this,PY2,async(G)=>{var w;E8(this,lgA).reset();let{body:g,redirected:Q,status:j,headers:K}=G;if(j===204){um(this,nz,fPA).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(Q?Aw(this,vgA,new URL(G.url)):Aw(this,vgA,void 0),j!==200){um(this,nz,fPA).call(this,`Non-200 status code (${j})`,j);return}if(!(K.get("content-type")||"").startsWith("text/event-stream")){um(this,nz,fPA).call(this,'Invalid content type, expected "text/event-stream"',j);return}if(E8(this,FZ)===this.CLOSED)return;Aw(this,FZ,this.OPEN);let U=new Event("open");if((w=E8(this,CPA))==null||w.call(this,U),this.dispatchEvent(U),typeof g!="object"||!g||!("getReader"in g)){um(this,nz,fPA).call(this,"Invalid response body, expected a web ReadableStream",j),this.close();return}let _=new TextDecoder,O=g.getReader(),W=!0;do{let{done:X,value:Y}=await O.read();Y&&E8(this,lgA).feed(_.decode(Y,{stream:!X})),X&&(W=!1,E8(this,lgA).reset(),um(this,nz,SY2).call(this))}while(W)}),HK(this,TY2,(G)=>{Aw(this,Cc,void 0),!(G.name==="AbortError"||G.type==="aborted")&&um(this,nz,SY2).call(this,RY2(G))}),HK(this,IY2,(G)=>{typeof G.id=="string"&&Aw(this,mPA,G.id);let w=new MessageEvent(G.event||"message",{data:G.data,origin:E8(this,vgA)?E8(this,vgA).origin:E8(this,v0A).origin,lastEventId:G.id||""});E8(this,igA)&&(!G.event||G.event==="message")&&E8(this,igA).call(this,w),this.dispatchEvent(w)}),HK(this,kY2,(G)=>{Aw(this,hPA,G)}),HK(this,CY2,()=>{Aw(this,cgA,void 0),E8(this,FZ)===this.CONNECTING&&um(this,nz,DY2).call(this)});try{if(A instanceof URL)Aw(this,v0A,A);else if(typeof A=="string")Aw(this,v0A,new URL(A,jaq()));else throw Error("Invalid URL")}catch{throw Qaq("An invalid or illegal string was specified")}Aw(this,lgA,Ru0({onEvent:E8(this,IY2),onRetry:E8(this,kY2)})),Aw(this,FZ,this.CONNECTING),Aw(this,hPA,3000),Aw(this,FG0,(q=u==null?void 0:u.fetch)!=null?q:globalThis.fetch),Aw(this,qG0,(F=u==null?void 0:u.withCredentials)!=null?F:!1),um(this,nz,DY2).call(this)}get readyState(){return E8(this,FZ)}get url(){return E8(this,v0A).href}get withCredentials(){return E8(this,qG0)}get onerror(){return E8(this,dgA)}set onerror(A){Aw(this,dgA,A)}get onmessage(){return E8(this,igA)}set onmessage(A){Aw(this,igA,A)}get onopen(){return E8(this,CPA)}set onopen(A){Aw(this,CPA,A)}addEventListener(A,u,q){let F=u;super.addEventListener(A,F,q)}removeEventListener(A,u,q){let F=u;super.removeEventListener(A,F,q)}close(){E8(this,cgA)&&clearTimeout(E8(this,cgA)),E8(this,FZ)!==this.CLOSED&&(E8(this,Cc)&&E8(this,Cc).abort(),Aw(this,FZ,this.CLOSED),Aw(this,Cc,void 0))}};FZ=new WeakMap,v0A=new WeakMap,vgA=new WeakMap,qG0=new WeakMap,FG0=new WeakMap,hPA=new WeakMap,cgA=new WeakMap,mPA=new WeakMap,Cc=new WeakMap,lgA=new WeakMap,dgA=new WeakMap,igA=new WeakMap,CPA=new WeakMap,nz=new WeakSet,DY2=function(){Aw(this,FZ,this.CONNECTING),Aw(this,Cc,new AbortController),E8(this,FG0)(E8(this,v0A),um(this,nz,C_u).call(this)).then(E8(this,PY2)).catch(E8(this,TY2))},PY2=new WeakMap,TY2=new WeakMap,C_u=function(){var A;let u={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...E8(this,mPA)?{"Last-Event-ID":E8(this,mPA)}:void 0},cache:"no-store",signal:(A=E8(this,Cc))==null?void 0:A.signal};return"window"in globalThis&&(u.credentials=this.withCredentials?"include":"same-origin"),u},IY2=new WeakMap,kY2=new WeakMap,fPA=function(A,u){var q;E8(this,FZ)!==this.CLOSED&&Aw(this,FZ,this.CLOSED);let F=new zY2("error",{code:u,message:A});(q=E8(this,dgA))==null||q.call(this,F),this.dispatchEvent(F)},SY2=function(A,u){var q;if(E8(this,FZ)===this.CLOSED)return;Aw(this,FZ,this.CONNECTING);let F=new zY2("error",{code:u,message:A});(q=E8(this,dgA))==null||q.call(this,F),this.dispatchEvent(F),Aw(this,cgA,setTimeout(E8(this,CY2),E8(this,hPA)))},CY2=new WeakMap,ngA.CONNECTING=0,ngA.OPEN=1,ngA.CLOSED=2});class hY2{constructor(A,u){this._url=A,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=u?.eventSourceInit,this._requestInit=u?.requestInit,this._authProvider=u?.authProvider,this._fetch=u?.fetch,this._fetchWithInit=yF0(u?.fetch,u?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new uJ("No auth provider");let A;try{A=await Am(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(u){throw this.onerror?.(u),u}if(A!=="AUTHORIZED")throw new uJ;return await this._startOrAuth()}async _commonHeaders(){let A={};if(this._authProvider){let q=await this._authProvider.tokens();if(q)A.Authorization=`Bearer ${q.access_token}`}if(this._protocolVersion)A["mcp-protocol-version"]=this._protocolVersion;let u=fgA(this._requestInit?.headers);return new Headers({...A,...u})}_startOrAuth(){let A=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((u,q)=>{this._eventSource=new ngA(this._url.href,{...this._eventSourceInit,fetch:async(F,G)=>{let w=await this._commonHeaders();w.set("Accept","text/event-stream");let g=await A(F,{...G,headers:w});if(g.status===401&&g.headers.has("www-authenticate")){let{resourceMetadataUrl:Q,scope:j}=ygA(g);this._resourceMetadataUrl=Q,this._scope=j}return g}}),this._abortController=new AbortController,this._eventSource.onerror=(F)=>{if(F.code===401&&this._authProvider){this._authThenStart().then(u,q);return}let G=new m_u(F.code,F.message,F);q(G),this.onerror?.(G)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",(F)=>{let G=F;try{if(this._endpoint=new URL(G.data,this._url),this._endpoint.origin!==this._url.origin)throw Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(w){q(w),this.onerror?.(w),this.close();return}u()}),this._eventSource.onmessage=(F)=>{let G=F,w;try{w=Tc.parse(JSON.parse(G.data))}catch(g){this.onerror?.(g);return}this.onmessage?.(w)}})}async start(){if(this._eventSource)throw Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(A){if(!this._authProvider)throw new uJ("No auth provider");if(await Am(this._authProvider,{serverUrl:this._url,authorizationCode:A,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new uJ("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(A){if(!this._endpoint)throw Error("Not connected");try{let u=await this._commonHeaders();u.set("content-type","application/json");let q={...this._requestInit,method:"POST",headers:u,body:JSON.stringify(A),signal:this._abortController?.signal},F=await(this._fetch??fetch)(this._endpoint,q);if(!F.ok){let G=await F.text().catch(()=>null);if(F.status===401&&this._authProvider){let{resourceMetadataUrl:w,scope:g}=ygA(F);if(this._resourceMetadataUrl=w,this._scope=g,await Am(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new uJ;return this.send(A)}throw Error(`Error POSTing to endpoint (HTTP ${F.status}): ${G}`)}await F.body?.cancel()}catch(u){throw this.onerror?.(u),u}}setProtocolVersion(A){this._protocolVersion=A}}var m_u;var b_u=k(()=>{h_u();sh();AG0();m_u=class m_u extends Error{constructor(A,u,q){super(`SSE error: ${u}`);this.code=A,this.event=q}}});class mY2{append(A){this._buffer=this._buffer?Buffer.concat([this._buffer,A]):A}readMessage(){if(!this._buffer)return null;let A=this._buffer.indexOf(`
|
|
4604
4604
|
`);if(A===-1)return null;let u=this._buffer.toString("utf8",0,A).replace(/\r$/,"");return this._buffer=this._buffer.subarray(A+1),Kaq(u)}clear(){this._buffer=void 0}}function Kaq(A){return Tc.parse(JSON.parse(A))}function t_u(A){return JSON.stringify(A)+`
|
|
4605
|
-
`}var y_u=k(()=>{sh()});import bY2 from"process";import{PassThrough as Uaq}from"stream";function Jaq(){let A={};for(let u of _aq){let q=bY2.env[u];if(q===void 0)continue;if(q.startsWith("()"))continue;A[u]=q}return A}class GG0{constructor(A){if(this._readBuffer=new mY2,this._stderrStream=null,this._serverParams=A,A.stderr==="pipe"||A.stderr==="overlapped")this._stderrStream=new Uaq}async start(){if(this._process)throw Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((A,u)=>{if(this._process=v_u.default(this._serverParams.command,this._serverParams.args??[],{env:{...Jaq(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:bY2.platform==="win32",cwd:this._serverParams.cwd}),this._process.on("error",(q)=>{u(q),this.onerror?.(q)}),this._process.on("spawn",()=>{A()}),this._process.on("close",(q)=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",(q)=>{this.onerror?.(q)}),this._process.stdout?.on("data",(q)=>{this._readBuffer.append(q),this.processReadBuffer()}),this._process.stdout?.on("error",(q)=>{this.onerror?.(q)}),this._stderrStream&&this._process.stderr)this._process.stderr.pipe(this._stderrStream)})}get stderr(){if(this._stderrStream)return this._stderrStream;return this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){while(!0)try{let A=this._readBuffer.readMessage();if(A===null)break;this.onmessage?.(A)}catch(A){this.onerror?.(A)}}async close(){if(this._process){let A=this._process;this._process=void 0;let u=new Promise((q)=>{A.once("close",()=>{q()})});try{A.stdin?.end()}catch{}if(await Promise.race([u,new Promise((q)=>setTimeout(q,2000).unref())]),A.exitCode===null){try{A.kill("SIGTERM")}catch{}await Promise.race([u,new Promise((q)=>setTimeout(q,2000).unref())])}if(A.exitCode===null)try{A.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(A){return new Promise((u)=>{if(!this._process?.stdin)throw Error("Not connected");let q=t_u(A);if(this._process.stdin.write(q))u();else this._process.stdin.once("drain",u)})}}var v_u,_aq;var l_u=k(()=>{y_u();v_u=u2(zp(),1),_aq=bY2.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"]});class wG0{mcpName;serverUrl;config;callbacks;auth;constructor(A,u,q,F,G){this.mcpName=A;this.serverUrl=u;this.config=q;this.callbacks=F;this.auth=G}get redirectUrl(){if(this.config.redirectUri)return this.config.redirectUri;return`http://127.0.0.1:${agA}${pgA}`}get clientMetadata(){return{redirect_uris:[this.redirectUrl],client_name:"Codeplane",client_uri:"https://github.com/devinoldenburg/codeplane",grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:this.config.clientSecret?"client_secret_post":"none"}}async clientInformation(){if(this.config.clientId)return{client_id:this.config.clientId,client_secret:this.config.clientSecret};let A=await R.runPromise(this.auth.getForUrl(this.mcpName,this.serverUrl));if(A?.clientInfo){if(A.clientInfo.clientSecretExpiresAt&&A.clientInfo.clientSecretExpiresAt<Date.now()/1000){bPA.info("client secret expired, need to re-register",{mcpName:this.mcpName});return}return{client_id:A.clientInfo.clientId,client_secret:A.clientInfo.clientSecret}}return}async saveClientInformation(A){await R.runPromise(this.auth.updateClientInfo(this.mcpName,{clientId:A.client_id,clientSecret:A.client_secret,clientIdIssuedAt:A.client_id_issued_at,clientSecretExpiresAt:A.client_secret_expires_at},this.serverUrl)),bPA.info("saved dynamically registered client",{mcpName:this.mcpName,clientId:A.client_id})}async tokens(){let A=await R.runPromise(this.auth.getForUrl(this.mcpName,this.serverUrl));if(!A?.tokens)return;return{access_token:A.tokens.accessToken,token_type:"Bearer",refresh_token:A.tokens.refreshToken,expires_in:A.tokens.expiresAt?Math.max(0,Math.floor(A.tokens.expiresAt-Date.now()/1000)):void 0,scope:A.tokens.scope}}async saveTokens(A){await R.runPromise(this.auth.updateTokens(this.mcpName,{accessToken:A.access_token,refreshToken:A.refresh_token,expiresAt:A.expires_in?Date.now()/1000+A.expires_in:void 0,scope:A.scope},this.serverUrl)),bPA.info("saved oauth tokens",{mcpName:this.mcpName})}async redirectToAuthorization(A){bPA.info("redirecting to authorization",{mcpName:this.mcpName,url:A.toString()}),await this.callbacks.onRedirect(A)}async saveCodeVerifier(A){await R.runPromise(this.auth.updateCodeVerifier(this.mcpName,A))}async codeVerifier(){let A=await R.runPromise(this.auth.get(this.mcpName));if(!A?.codeVerifier)throw Error(`No code verifier saved for MCP server: ${this.mcpName}`);return A.codeVerifier}async saveState(A){await R.runPromise(this.auth.updateOAuthState(this.mcpName,A))}async state(){let A=await R.runPromise(this.auth.get(this.mcpName));if(A?.oauthState)return A.oauthState;let u=Array.from(crypto.getRandomValues(new Uint8Array(32))).map((q)=>q.toString(16).padStart(2,"0")).join("");return await R.runPromise(this.auth.updateOAuthState(this.mcpName,u)),u}async invalidateCredentials(A){bPA.info("invalidating credentials",{mcpName:this.mcpName,type:A});let u=await R.runPromise(this.auth.get(this.mcpName));if(!u)return;switch(A){case"all":await R.runPromise(this.auth.remove(this.mcpName));break;case"client":delete u.clientInfo,await R.runPromise(this.auth.set(this.mcpName,u));break;case"tokens":delete u.tokens,await R.runPromise(this.auth.set(this.mcpName,u));break}}}function i_u(A){if(!A)return{port:agA,path:pgA};try{let u=new URL(A),q=u.port?parseInt(u.port,10):u.protocol==="https:"?443:80,F=u.pathname||pgA;return{port:q,path:F}}catch{return{port:agA,path:pgA}}}var bPA,agA=19876,pgA="/mcp/oauth/callback";var tY2=k(async()=>{i0();await Z1();bPA=Q2.create({service:"mcp.oauth"})});var c0A={};bA(c0A,{waitForCallback:()=>Haq,stop:()=>n_u,isRunning:()=>Baq,isPortInUse:()=>d_u,ensureRunning:()=>Zaq,cancelPending:()=>Naq,McpOAuthCallback:()=>c0A});import{createConnection as Oaq}from"net";import{createServer as Waq}from"http";function c_u(A){for(let[u,q]of i0A)if(q===A){i0A.delete(u);break}}function Vaq(A,u){let q=new URL(A.url||"/",`http://localhost:${rgA}`);if(q.pathname!==QG0){u.writeHead(404),u.end("Not found");return}let F=q.searchParams.get("code"),G=q.searchParams.get("state"),w=q.searchParams.get("error"),g=q.searchParams.get("error_description");if(l0A.info("received oauth callback",{hasCode:!!F,state:G,error:w}),!G){l0A.error("oauth callback missing state parameter",{url:q.toString()}),u.writeHead(400,{"Content-Type":"text/html"}),u.end(gG0("Missing required state parameter - potential CSRF attack"));return}if(w){let j=g||w;if(GZ.has(G)){let K=GZ.get(G);clearTimeout(K.timeout),GZ.delete(G),c_u(G),K.reject(Error(j))}u.writeHead(200,{"Content-Type":"text/html"}),u.end(gG0(j));return}if(!F){u.writeHead(400,{"Content-Type":"text/html"}),u.end(gG0("No authorization code provided"));return}if(!GZ.has(G)){l0A.error("oauth callback with invalid state",{state:G,pendingStates:Array.from(GZ.keys())}),u.writeHead(400,{"Content-Type":"text/html"}),u.end(gG0("Invalid or expired state parameter - potential CSRF attack"));return}let Q=GZ.get(G);clearTimeout(Q.timeout),GZ.delete(G),c_u(G),Q.resolve(F),u.writeHead(200,{"Content-Type":"text/html"}),u.end(Xaq)}async function Zaq(A){let{port:u,path:q}=i_u(A);if(qm&&(rgA!==u||QG0!==q))l0A.info("stopping oauth callback server to reconfigure",{oldPort:rgA,newPort:u}),await n_u();if(qm)return;if(await d_u(u)){l0A.info("oauth callback server already running on another instance",{port:u});return}rgA=u,QG0=q,qm=Waq(Vaq),await new Promise((G,w)=>{qm.listen(rgA,()=>{l0A.info("oauth callback server started",{port:rgA,path:QG0}),G()}),qm.on("error",w)})}function Haq(A,u){if(u)i0A.set(u,A);return new Promise((q,F)=>{let G=setTimeout(()=>{if(GZ.has(A)){if(GZ.delete(A),u)i0A.delete(u);F(Error("OAuth callback timeout - authorization took too long"))}},Yaq);GZ.set(A,{resolve:q,reject:F,timeout:G})})}function Naq(A){let q=i0A.get(A)??A,F=GZ.get(q);if(F)clearTimeout(F.timeout),GZ.delete(q),i0A.delete(A),F.reject(Error("Authorization cancelled"))}async function d_u(A=agA){return new Promise((u)=>{let q=Oaq(A,"127.0.0.1");q.on("connect",()=>{q.destroy(),u(!0)}),q.on("error",()=>{u(!1)})})}async function n_u(){if(qm)await new Promise((A)=>qm.close(()=>A())),qm=void 0,l0A.info("oauth callback server stopped");for(let[A,u]of GZ)clearTimeout(u.timeout),u.reject(Error("OAuth callback server stopped"));GZ.clear(),i0A.clear()}function Baq(){return qm!==void 0}var l0A,rgA,QG0,Xaq=`<!DOCTYPE html>
|
|
4605
|
+
`}var y_u=k(()=>{sh()});import bY2 from"process";import{PassThrough as Uaq}from"stream";function Jaq(){let A={};for(let u of _aq){let q=bY2.env[u];if(q===void 0)continue;if(q.startsWith("()"))continue;A[u]=q}return A}class GG0{constructor(A){if(this._readBuffer=new mY2,this._stderrStream=null,this._serverParams=A,A.stderr==="pipe"||A.stderr==="overlapped")this._stderrStream=new Uaq}async start(){if(this._process)throw Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((A,u)=>{if(this._process=v_u.default(this._serverParams.command,this._serverParams.args??[],{env:{...Jaq(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:bY2.platform==="win32",cwd:this._serverParams.cwd}),this._process.on("error",(q)=>{u(q),this.onerror?.(q)}),this._process.on("spawn",()=>{A()}),this._process.on("close",(q)=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",(q)=>{this.onerror?.(q)}),this._process.stdout?.on("data",(q)=>{this._readBuffer.append(q),this.processReadBuffer()}),this._process.stdout?.on("error",(q)=>{this.onerror?.(q)}),this._stderrStream&&this._process.stderr)this._process.stderr.pipe(this._stderrStream)})}get stderr(){if(this._stderrStream)return this._stderrStream;return this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){while(!0)try{let A=this._readBuffer.readMessage();if(A===null)break;this.onmessage?.(A)}catch(A){this.onerror?.(A)}}async close(){if(this._process){let A=this._process;this._process=void 0;let u=new Promise((q)=>{A.once("close",()=>{q()})});try{A.stdin?.end()}catch{}if(await Promise.race([u,new Promise((q)=>setTimeout(q,2000).unref())]),A.exitCode===null){try{A.kill("SIGTERM")}catch{}await Promise.race([u,new Promise((q)=>setTimeout(q,2000).unref())])}if(A.exitCode===null)try{A.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(A){return new Promise((u)=>{if(!this._process?.stdin)throw Error("Not connected");let q=t_u(A);if(this._process.stdin.write(q))u();else this._process.stdin.once("drain",u)})}}var v_u,_aq;var l_u=k(()=>{y_u();v_u=u2(zp(),1),_aq=bY2.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"]});class wG0{mcpName;serverUrl;config;callbacks;auth;constructor(A,u,q,F,G){this.mcpName=A;this.serverUrl=u;this.config=q;this.callbacks=F;this.auth=G}get redirectUrl(){if(this.config.redirectUri)return this.config.redirectUri;return`http://127.0.0.1:${this.config.callbackPort??agA}${pgA}`}get clientMetadata(){return{redirect_uris:[this.redirectUrl],client_name:"Codeplane",client_uri:"https://github.com/devinoldenburg/codeplane",grant_types:["authorization_code","refresh_token"],response_types:["code"],scope:this.config.scope,token_endpoint_auth_method:this.config.clientSecret?"client_secret_post":"none"}}async clientInformation(){if(this.config.clientId)return{client_id:this.config.clientId,client_secret:this.config.clientSecret};let A=await R.runPromise(this.auth.getForUrl(this.mcpName,this.serverUrl));if(A?.clientInfo){if(A.clientInfo.clientSecretExpiresAt&&A.clientInfo.clientSecretExpiresAt<Date.now()/1000){bPA.info("client secret expired, need to re-register",{mcpName:this.mcpName});return}return{client_id:A.clientInfo.clientId,client_secret:A.clientInfo.clientSecret}}return}async saveClientInformation(A){await R.runPromise(this.auth.updateClientInfo(this.mcpName,{clientId:A.client_id,clientSecret:A.client_secret,clientIdIssuedAt:A.client_id_issued_at,clientSecretExpiresAt:A.client_secret_expires_at},this.serverUrl)),bPA.info("saved dynamically registered client",{mcpName:this.mcpName,clientId:A.client_id})}async tokens(){let A=await R.runPromise(this.auth.getForUrl(this.mcpName,this.serverUrl));if(!A?.tokens)return;return{access_token:A.tokens.accessToken,token_type:"Bearer",refresh_token:A.tokens.refreshToken,expires_in:A.tokens.expiresAt?Math.max(0,Math.floor(A.tokens.expiresAt-Date.now()/1000)):void 0,scope:A.tokens.scope}}async saveTokens(A){await R.runPromise(this.auth.updateTokens(this.mcpName,{accessToken:A.access_token,refreshToken:A.refresh_token,expiresAt:A.expires_in?Date.now()/1000+A.expires_in:void 0,scope:A.scope},this.serverUrl)),bPA.info("saved oauth tokens",{mcpName:this.mcpName})}async redirectToAuthorization(A){bPA.info("redirecting to authorization",{mcpName:this.mcpName,url:A.toString()}),await this.callbacks.onRedirect(A)}async saveCodeVerifier(A){await R.runPromise(this.auth.updateCodeVerifier(this.mcpName,A))}async codeVerifier(){let A=await R.runPromise(this.auth.get(this.mcpName));if(!A?.codeVerifier)throw Error(`No code verifier saved for MCP server: ${this.mcpName}`);return A.codeVerifier}async saveState(A){await R.runPromise(this.auth.updateOAuthState(this.mcpName,A))}async state(){let A=await R.runPromise(this.auth.get(this.mcpName));if(A?.oauthState)return A.oauthState;let u=Array.from(crypto.getRandomValues(new Uint8Array(32))).map((q)=>q.toString(16).padStart(2,"0")).join("");return await R.runPromise(this.auth.updateOAuthState(this.mcpName,u)),u}async invalidateCredentials(A){bPA.info("invalidating credentials",{mcpName:this.mcpName,type:A});let u=await R.runPromise(this.auth.get(this.mcpName));if(!u)return;switch(A){case"all":await R.runPromise(this.auth.remove(this.mcpName));break;case"client":delete u.clientInfo,await R.runPromise(this.auth.set(this.mcpName,u));break;case"tokens":delete u.tokens,await R.runPromise(this.auth.set(this.mcpName,u));break}}}function i_u(A){if(!A)return{port:agA,path:pgA};try{let u=new URL(A),q=u.port?parseInt(u.port,10):u.protocol==="https:"?443:80,F=u.pathname||pgA;return{port:q,path:F}}catch{return{port:agA,path:pgA}}}var bPA,agA=19876,pgA="/mcp/oauth/callback";var tY2=k(async()=>{i0();await Z1();bPA=Q2.create({service:"mcp.oauth"})});var c0A={};bA(c0A,{waitForCallback:()=>Haq,stop:()=>n_u,isRunning:()=>Baq,isPortInUse:()=>d_u,ensureRunning:()=>Zaq,cancelPending:()=>Naq,McpOAuthCallback:()=>c0A});import{createConnection as Oaq}from"net";import{createServer as Waq}from"http";function c_u(A){for(let[u,q]of i0A)if(q===A){i0A.delete(u);break}}function Vaq(A,u){let q=new URL(A.url||"/",`http://localhost:${rgA}`);if(q.pathname!==QG0){u.writeHead(404),u.end("Not found");return}let F=q.searchParams.get("code"),G=q.searchParams.get("state"),w=q.searchParams.get("error"),g=q.searchParams.get("error_description");if(l0A.info("received oauth callback",{hasCode:!!F,state:G,error:w}),!G){l0A.error("oauth callback missing state parameter",{url:q.toString()}),u.writeHead(400,{"Content-Type":"text/html"}),u.end(gG0("Missing required state parameter - potential CSRF attack"));return}if(w){let j=g||w;if(GZ.has(G)){let K=GZ.get(G);clearTimeout(K.timeout),GZ.delete(G),c_u(G),K.reject(Error(j))}u.writeHead(200,{"Content-Type":"text/html"}),u.end(gG0(j));return}if(!F){u.writeHead(400,{"Content-Type":"text/html"}),u.end(gG0("No authorization code provided"));return}if(!GZ.has(G)){l0A.error("oauth callback with invalid state",{state:G,pendingStates:Array.from(GZ.keys())}),u.writeHead(400,{"Content-Type":"text/html"}),u.end(gG0("Invalid or expired state parameter - potential CSRF attack"));return}let Q=GZ.get(G);clearTimeout(Q.timeout),GZ.delete(G),c_u(G),Q.resolve(F),u.writeHead(200,{"Content-Type":"text/html"}),u.end(Xaq)}async function Zaq(A){let{port:u,path:q}=i_u(A);if(qm&&(rgA!==u||QG0!==q))l0A.info("stopping oauth callback server to reconfigure",{oldPort:rgA,newPort:u}),await n_u();if(qm)return;if(await d_u(u)){l0A.info("oauth callback server already running on another instance",{port:u});return}rgA=u,QG0=q,qm=Waq(Vaq),await new Promise((G,w)=>{qm.listen(rgA,()=>{l0A.info("oauth callback server started",{port:rgA,path:QG0}),G()}),qm.on("error",w)})}function Haq(A,u){if(u)i0A.set(u,A);return new Promise((q,F)=>{let G=setTimeout(()=>{if(GZ.has(A)){if(GZ.delete(A),u)i0A.delete(u);F(Error("OAuth callback timeout - authorization took too long"))}},Yaq);GZ.set(A,{resolve:q,reject:F,timeout:G})})}function Naq(A){let q=i0A.get(A)??A,F=GZ.get(q);if(F)clearTimeout(F.timeout),GZ.delete(q),i0A.delete(A),F.reject(Error("Authorization cancelled"))}async function d_u(A=agA){return new Promise((u)=>{let q=Oaq(A,"127.0.0.1");q.on("connect",()=>{q.destroy(),u(!0)}),q.on("error",()=>{u(!1)})})}async function n_u(){if(qm)await new Promise((A)=>qm.close(()=>A())),qm=void 0,l0A.info("oauth callback server stopped");for(let[A,u]of GZ)clearTimeout(u.timeout),u.reject(Error("OAuth callback server stopped"));GZ.clear(),i0A.clear()}function Baq(){return qm!==void 0}var l0A,rgA,QG0,Xaq=`<!DOCTYPE html>
|
|
4606
4606
|
<html>
|
|
4607
4607
|
<head>
|
|
4608
4608
|
<title>Codeplane - Authorization Successful</title>
|
|
@@ -4639,7 +4639,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4639
4639
|
<div class="error">${A}</div>
|
|
4640
4640
|
</div>
|
|
4641
4641
|
</body>
|
|
4642
|
-
</html>`,qm,GZ,i0A,Yaq=300000;var yY2=k(async()=>{await N0([Z1(),tY2(),yY2()]);l0A=Q2.create({service:"mcp.oauth-callback"}),rgA=agA,QG0=pgA,GZ=new Map,i0A=new Map});var fc={};bA(fc,{layer:()=>r_u,defaultLayer:()=>Laq,Tokens:()=>p_u,Service:()=>jG0,McpAuth:()=>fc,Entry:()=>Maq,ClientInfo:()=>a_u});import $aq from"path";var p_u,a_u,Maq,vY2,jG0,r_u,Laq;var KG0=k(async()=>{Xu();i0();U3();await N0([P3(),KG0()]);p_u=NA.object({accessToken:NA.string(),refreshToken:NA.string().optional(),expiresAt:NA.number().optional(),scope:NA.string().optional()}),a_u=NA.object({clientId:NA.string(),clientSecret:NA.string().optional(),clientIdIssuedAt:NA.number().optional(),clientSecretExpiresAt:NA.number().optional()}),Maq=NA.object({tokens:p_u.optional(),clientInfo:a_u.optional(),codeVerifier:NA.string().optional(),oauthState:NA.string().optional(),serverUrl:NA.string().optional()}),vY2=$aq.join(U2.Path.data,"mcp-auth.json");jG0=class jG0 extends m0.Service()("@codeplane/McpAuth"){};r_u=fA.effect(jG0,R.gen(function*(){let A=yield*P2.Service,u=R.fn("McpAuth.all")(function*(){return yield*A.readJson(vY2).pipe(R.map((V)=>V),R.catch(()=>R.succeed({})))}),q=R.fn("McpAuth.get")(function*(V){return(yield*u())[V]}),F=R.fn("McpAuth.getForUrl")(function*(V,Z){let H=yield*q(V);if(!H)return;if(!H.serverUrl)return;if(H.serverUrl!==Z)return;return H}),G=R.fn("McpAuth.set")(function*(V,Z,H){let N=yield*u();if(H)Z.serverUrl=H;yield*A.writeJson(vY2,{...N,[V]:Z},384).pipe(R.orDie)}),w=R.fn("McpAuth.remove")(function*(V){let Z=yield*u();delete Z[V],yield*A.writeJson(vY2,Z,384).pipe(R.orDie)}),g=(V,Z)=>R.fn(`McpAuth.${Z}`)(function*(H,N,B){let M=(yield*q(H))??{};M[V]=N,yield*G(H,M,B)}),Q=(V,Z)=>R.fn(`McpAuth.${Z}`)(function*(H){let N=yield*q(H);if(N)delete N[V],yield*G(H,N)}),j=g("tokens","updateTokens"),K=g("clientInfo","updateClientInfo"),U=g("codeVerifier","updateCodeVerifier"),_=g("oauthState","updateOAuthState"),O=Q("codeVerifier","clearCodeVerifier"),W=Q("oauthState","clearOAuthState"),X=R.fn("McpAuth.getOAuthState")(function*(V){return(yield*q(V))?.oauthState}),Y=R.fn("McpAuth.isTokenExpired")(function*(V){let Z=yield*q(V);if(!Z?.tokens)return null;if(!Z.tokens.expiresAt)return!1;return Z.tokens.expiresAt<Date.now()/1000});return jG0.of({all:u,get:q,getForUrl:F,set:G,remove:w,updateTokens:j,updateClientInfo:K,updateCodeVerifier:U,clearCodeVerifier:O,updateOAuthState:_,getOAuthState:X,clearOAuthState:W,isTokenExpired:Y})})),Laq=r_u.pipe(fA.provide(P2.defaultLayer))});var MG={};bA(MG,{layer:()=>e_u,defaultLayer:()=>Caq,ToolsChanged:()=>o_u,Status:()=>Iaq,Service:()=>JG0,Resource:()=>Eaq,MCP:()=>MG,Failed:()=>xaq,BrowserOpenFailed:()=>s_u});function UG0(A){return typeof A==="object"&&A!==null&&"type"in A}function kaq(A,u,q){let F=A.inputSchema,G={...F,type:"object",properties:F.properties??{},additionalProperties:!1};return hLA({description:A.description??"",inputSchema:SV(G),execute:async(w)=>{return u.callTool({name:A.name,arguments:w||{}},Ic,{resetTimeoutOnProgress:!0,timeout:q})}})}function lY2(A,u,q){return R.tryPromise({try:()=>te(u.listTools(),q??iY2),catch:(F)=>F instanceof Error?F:Error(String(F))}).pipe(R.map((F)=>F.tools),R.catch((F)=>{return yw.error("failed to get tools from client",{key:A,error:F}),R.succeed(void 0)}))}function Saq(A,u,q,F){return R.tryPromise({try:()=>q(u),catch:(G)=>{return yw.error(`failed to get ${F}`,{clientName:A,error:G.message}),G}}).pipe(R.map((G)=>{let w={},g=_G0(A);for(let Q of G)w[g+":"+_G0(Q.name)]={...Q,client:A};return w}),R.orElseSucceed(()=>{return}))}var yw,iY2=30000,Eaq,o_u,s_u,xaq,zaq,Raq,Daq,Paq,Taq,Iaq,ogA,_G0=(A)=>A.replace(/[^a-zA-Z0-9_-]/g,"_"),JG0,e_u,Caq;var hc=k(async()=>{me();Y_u();k_u();b_u();l_u();AG0();sh();Xg();$0();sj();U3();E9();xHA();i0();KV();GM();Mu();z5();await N0([Vq(),Z1(),tY2(),yY2(),KG0(),y8(),I5(),I5(),hc()]);yw=Q2.create({service:"mcp"}),Eaq=yf.object({name:yf.string(),uri:yf.string(),description:yf.string().optional(),mimeType:yf.string().optional(),client:yf.string()}).meta({ref:"McpResource"}),o_u=P6.define("mcp.tools.changed",L.Struct({server:L.String})),s_u=P6.define("mcp.browser.open.failed",L.Struct({mcpName:L.String,url:L.String})),xaq=d6.create("MCPFailed",yf.object({name:yf.string()})),zaq=L.Struct({status:L.Literal("connected")}).annotate({identifier:"MCPStatusConnected"}),Raq=L.Struct({status:L.Literal("disabled")}).annotate({identifier:"MCPStatusDisabled"}),Daq=L.Struct({status:L.Literal("failed"),error:L.String}).annotate({identifier:"MCPStatusFailed"}),Paq=L.Struct({status:L.Literal("needs_auth")}).annotate({identifier:"MCPStatusNeedsAuth"}),Taq=L.Struct({status:L.Literal("needs_client_registration"),error:L.String}).annotate({identifier:"MCPStatusNeedsClientRegistration"}),Iaq=L.Union([zaq,Raq,Daq,Paq,Taq]).annotate({identifier:"MCPStatus",discriminator:"status"}).pipe(y0((A)=>({zod:B0(A)}))),ogA=new Map;JG0=class JG0 extends m0.Service()("@codeplane/MCP"){};e_u=fA.effect(JG0,R.gen(function*(){let A=yield*zw.ChildProcessSpawner,u=yield*fc.Service,q=yield*m1.Service,F=(a,uA)=>R.acquireUseRelease(R.succeed(a),(n)=>R.tryPromise({try:()=>{let m=new tF0({name:"codeplane",version:S4});return te(m.connect(n),uA).then(()=>m)},catch:(m)=>m instanceof Error?m:Error(String(m))}),(n,m)=>y5.isFailure(m)?R.tryPromise(()=>n.close()).pipe(R.ignore):R.void),G={status:{status:"disabled"}},w=R.fn("MCP.connectRemote")(function*(a,uA){let n=uA.oauth===!1,m=typeof uA.oauth==="object"?uA.oauth:void 0,v;if(!n)v=new wG0(a,uA.url,{clientId:m?.clientId,clientSecret:m?.clientSecret,scope:m?.scope,redirectUri:m?.redirectUri},{onRedirect:async(OA)=>{yw.info("oauth redirect requested",{key:a,url:OA.toString()})}},u);let gA=[{name:"StreamableHTTP",transport:new uG0(new URL(uA.url),{authProvider:v,requestInit:uA.headers?{headers:uA.headers}:void 0})},{name:"SSE",transport:new hY2(new URL(uA.url),{authProvider:v,requestInit:uA.headers?{headers:uA.headers}:void 0})}],d=uA.timeout??iY2,GA;for(let{name:OA,transport:y}of gA){let c=yield*F(y,d).pipe(R.map((FA)=>({client:FA,transportName:OA})),R.catch((FA)=>{let UA=FA instanceof Error?FA:Error(String(FA));if(FA instanceof uJ||v&&UA.message.includes("OAuth")){if(yw.info("mcp server requires authentication",{key:a,transport:OA}),UA.message.includes("registration")||UA.message.includes("client_id"))return GA={status:"needs_client_registration",error:"Server does not support dynamic client registration. Please provide clientId in config."},yw.warn("mcp server requires pre-registered client id",{key:a}),R.succeed(void 0);return ogA.set(a,y),GA={status:"needs_auth"},yw.warn("mcp server requires authentication",{key:a}),R.succeed(void 0)}return yw.debug("transport connection failed",{key:a,transport:OA,url:uA.url,error:UA.message}),GA={status:"failed",error:UA.message},R.succeed(void 0)}));if(c)return yw.info("connected",{key:a,transport:c.transportName}),{client:c.client,status:{status:"connected"}};if(GA?.status==="needs_auth"||GA?.status==="needs_client_registration")break}return{client:void 0,status:GA??{status:"failed",error:"Unknown error"}}}),g=R.fn("MCP.connectLocal")(function*(a,uA){let[n,...m]=uA.command,v=yield*z0.directory,gA=new GG0({stderr:"pipe",command:n,args:m,cwd:v,env:{...process.env,...n==="codeplane"?{BUN_BE_BUN:"1"}:{},...uA.environment}});gA.stderr?.on("data",(GA)=>{yw.info(`mcp stderr: ${GA.toString()}`,{key:a})});let d=uA.timeout??iY2;return yield*F(gA,d).pipe(R.map((GA)=>({client:GA,status:{status:"connected"}})),R.catch((GA)=>{let OA=GA instanceof Error?GA.message:String(GA);return yw.error("local mcp startup failed",{key:a,command:uA.command,cwd:v,error:OA}),R.succeed({client:void 0,status:{status:"failed",error:OA}})}))}),Q=R.fn("MCP.create")(function*(a,uA){if(uA.enabled===!1)return yw.info("mcp server disabled",{key:a}),G;yw.info("found",{key:a,type:uA.type});let{client:n,status:m}=uA.type==="remote"?yield*w(a,uA):yield*g(a,uA);if(!n)return{status:m};let v=yield*lY2(a,n,uA.timeout);if(!v)return yield*R.tryPromise(()=>n.close()).pipe(R.ignore),{status:{status:"failed",error:"Failed to get tools"}};return yw.info("create() successfully created client",{key:a,toolCount:v.length}),{mcpClient:n,status:m,defs:v}}),j=yield*t1.Service,K=R.fnUntraced(function*(a){if(process.platform==="win32")return[];let uA=[],n=[a];while(n.length>0){let m=n.shift(),v=yield*A.spawn(V8.make("pgrep",["-P",String(m)],{stdin:"ignore"})),gA=yield*k2.mkString(k2.decodeText(v.stdout));yield*v.exitCode;for(let d of gA.split(`
|
|
4642
|
+
</html>`,qm,GZ,i0A,Yaq=300000;var yY2=k(async()=>{await N0([Z1(),tY2(),yY2()]);l0A=Q2.create({service:"mcp.oauth-callback"}),rgA=agA,QG0=pgA,GZ=new Map,i0A=new Map});var fc={};bA(fc,{layer:()=>r_u,defaultLayer:()=>Laq,Tokens:()=>p_u,Service:()=>jG0,McpAuth:()=>fc,Entry:()=>Maq,ClientInfo:()=>a_u});import $aq from"path";var p_u,a_u,Maq,vY2,jG0,r_u,Laq;var KG0=k(async()=>{Xu();i0();U3();await N0([P3(),KG0()]);p_u=NA.object({accessToken:NA.string(),refreshToken:NA.string().optional(),expiresAt:NA.number().optional(),scope:NA.string().optional()}),a_u=NA.object({clientId:NA.string(),clientSecret:NA.string().optional(),clientIdIssuedAt:NA.number().optional(),clientSecretExpiresAt:NA.number().optional()}),Maq=NA.object({tokens:p_u.optional(),clientInfo:a_u.optional(),codeVerifier:NA.string().optional(),oauthState:NA.string().optional(),serverUrl:NA.string().optional()}),vY2=$aq.join(U2.Path.data,"mcp-auth.json");jG0=class jG0 extends m0.Service()("@codeplane/McpAuth"){};r_u=fA.effect(jG0,R.gen(function*(){let A=yield*P2.Service,u=R.fn("McpAuth.all")(function*(){return yield*A.readJson(vY2).pipe(R.map((V)=>V),R.catch(()=>R.succeed({})))}),q=R.fn("McpAuth.get")(function*(V){return(yield*u())[V]}),F=R.fn("McpAuth.getForUrl")(function*(V,Z){let H=yield*q(V);if(!H)return;if(!H.serverUrl)return;if(H.serverUrl!==Z)return;return H}),G=R.fn("McpAuth.set")(function*(V,Z,H){let N=yield*u();if(H)Z.serverUrl=H;yield*A.writeJson(vY2,{...N,[V]:Z},384).pipe(R.orDie)}),w=R.fn("McpAuth.remove")(function*(V){let Z=yield*u();delete Z[V],yield*A.writeJson(vY2,Z,384).pipe(R.orDie)}),g=(V,Z)=>R.fn(`McpAuth.${Z}`)(function*(H,N,B){let M=(yield*q(H))??{};M[V]=N,yield*G(H,M,B)}),Q=(V,Z)=>R.fn(`McpAuth.${Z}`)(function*(H){let N=yield*q(H);if(N)delete N[V],yield*G(H,N)}),j=g("tokens","updateTokens"),K=g("clientInfo","updateClientInfo"),U=g("codeVerifier","updateCodeVerifier"),_=g("oauthState","updateOAuthState"),O=Q("codeVerifier","clearCodeVerifier"),W=Q("oauthState","clearOAuthState"),X=R.fn("McpAuth.getOAuthState")(function*(V){return(yield*q(V))?.oauthState}),Y=R.fn("McpAuth.isTokenExpired")(function*(V){let Z=yield*q(V);if(!Z?.tokens)return null;if(!Z.tokens.expiresAt)return!1;return Z.tokens.expiresAt<Date.now()/1000});return jG0.of({all:u,get:q,getForUrl:F,set:G,remove:w,updateTokens:j,updateClientInfo:K,updateCodeVerifier:U,clearCodeVerifier:O,updateOAuthState:_,getOAuthState:X,clearOAuthState:W,isTokenExpired:Y})})),Laq=r_u.pipe(fA.provide(P2.defaultLayer))});var MG={};bA(MG,{layer:()=>e_u,defaultLayer:()=>Caq,ToolsChanged:()=>o_u,Status:()=>Iaq,Service:()=>JG0,Resource:()=>Eaq,MCP:()=>MG,Failed:()=>xaq,BrowserOpenFailed:()=>s_u});function UG0(A){return typeof A==="object"&&A!==null&&"type"in A}function kaq(A,u,q){let F=A.inputSchema,G={...F,type:"object",properties:F.properties??{},additionalProperties:!1};return hLA({description:A.description??"",inputSchema:SV(G),execute:async(w)=>{return u.callTool({name:A.name,arguments:w||{}},Ic,{resetTimeoutOnProgress:!0,timeout:q})}})}function lY2(A,u,q){return R.tryPromise({try:()=>te(u.listTools(),q??iY2),catch:(F)=>F instanceof Error?F:Error(String(F))}).pipe(R.map((F)=>F.tools),R.catch((F)=>{return yw.error("failed to get tools from client",{key:A,error:F}),R.succeed(void 0)}))}function Saq(A,u,q,F){return R.tryPromise({try:()=>q(u),catch:(G)=>{return yw.error(`failed to get ${F}`,{clientName:A,error:G.message}),G}}).pipe(R.map((G)=>{let w={},g=_G0(A);for(let Q of G)w[g+":"+_G0(Q.name)]={...Q,client:A};return w}),R.orElseSucceed(()=>{return}))}var yw,iY2=30000,Eaq,o_u,s_u,xaq,zaq,Raq,Daq,Paq,Taq,Iaq,ogA,_G0=(A)=>A.replace(/[^a-zA-Z0-9_-]/g,"_"),JG0,e_u,Caq;var hc=k(async()=>{me();Y_u();k_u();b_u();l_u();AG0();sh();Xg();$0();sj();U3();E9();xHA();i0();KV();GM();Mu();z5();await N0([Vq(),Z1(),tY2(),yY2(),KG0(),y8(),I5(),I5(),hc()]);yw=Q2.create({service:"mcp"}),Eaq=yf.object({name:yf.string(),uri:yf.string(),description:yf.string().optional(),mimeType:yf.string().optional(),client:yf.string()}).meta({ref:"McpResource"}),o_u=P6.define("mcp.tools.changed",L.Struct({server:L.String})),s_u=P6.define("mcp.browser.open.failed",L.Struct({mcpName:L.String,url:L.String})),xaq=d6.create("MCPFailed",yf.object({name:yf.string()})),zaq=L.Struct({status:L.Literal("connected")}).annotate({identifier:"MCPStatusConnected"}),Raq=L.Struct({status:L.Literal("disabled")}).annotate({identifier:"MCPStatusDisabled"}),Daq=L.Struct({status:L.Literal("failed"),error:L.String}).annotate({identifier:"MCPStatusFailed"}),Paq=L.Struct({status:L.Literal("needs_auth")}).annotate({identifier:"MCPStatusNeedsAuth"}),Taq=L.Struct({status:L.Literal("needs_client_registration"),error:L.String}).annotate({identifier:"MCPStatusNeedsClientRegistration"}),Iaq=L.Union([zaq,Raq,Daq,Paq,Taq]).annotate({identifier:"MCPStatus",discriminator:"status"}).pipe(y0((A)=>({zod:B0(A)}))),ogA=new Map;JG0=class JG0 extends m0.Service()("@codeplane/MCP"){};e_u=fA.effect(JG0,R.gen(function*(){let A=yield*zw.ChildProcessSpawner,u=yield*fc.Service,q=yield*m1.Service,F=(a,uA)=>R.acquireUseRelease(R.succeed(a),(n)=>R.tryPromise({try:()=>{let m=new tF0({name:"codeplane",version:S4});return te(m.connect(n),uA).then(()=>m)},catch:(m)=>m instanceof Error?m:Error(String(m))}),(n,m)=>y5.isFailure(m)?R.tryPromise(()=>n.close()).pipe(R.ignore):R.void),G={status:{status:"disabled"}},w=R.fn("MCP.connectRemote")(function*(a,uA){let n=uA.oauth===!1,m=typeof uA.oauth==="object"?uA.oauth:void 0,v;if(!n)v=new wG0(a,uA.url,{clientId:m?.clientId,clientSecret:m?.clientSecret,scope:m?.scope,callbackPort:m?.callbackPort,redirectUri:m?.redirectUri},{onRedirect:async(OA)=>{yw.info("oauth redirect requested",{key:a,url:OA.toString()})}},u);let gA=[{name:"StreamableHTTP",transport:new uG0(new URL(uA.url),{authProvider:v,requestInit:uA.headers?{headers:uA.headers}:void 0})},{name:"SSE",transport:new hY2(new URL(uA.url),{authProvider:v,requestInit:uA.headers?{headers:uA.headers}:void 0})}],d=uA.timeout??iY2,GA;for(let{name:OA,transport:y}of gA){let c=yield*F(y,d).pipe(R.map((FA)=>({client:FA,transportName:OA})),R.catch((FA)=>{let UA=FA instanceof Error?FA:Error(String(FA));if(FA instanceof uJ||v&&UA.message.includes("OAuth")){if(yw.info("mcp server requires authentication",{key:a,transport:OA}),UA.message.includes("registration")||UA.message.includes("client_id"))return GA={status:"needs_client_registration",error:"Server does not support dynamic client registration. Please provide clientId in config."},yw.warn("mcp server requires pre-registered client id",{key:a}),R.succeed(void 0);return ogA.set(a,y),GA={status:"needs_auth"},yw.warn("mcp server requires authentication",{key:a}),R.succeed(void 0)}return yw.debug("transport connection failed",{key:a,transport:OA,url:uA.url,error:UA.message}),GA={status:"failed",error:UA.message},R.succeed(void 0)}));if(c)return yw.info("connected",{key:a,transport:c.transportName}),{client:c.client,status:{status:"connected"}};if(GA?.status==="needs_auth"||GA?.status==="needs_client_registration")break}return{client:void 0,status:GA??{status:"failed",error:"Unknown error"}}}),g=R.fn("MCP.connectLocal")(function*(a,uA){let[n,...m]=uA.command,v=yield*z0.directory,gA=new GG0({stderr:"pipe",command:n,args:m,cwd:v,env:{...process.env,...n==="codeplane"?{BUN_BE_BUN:"1"}:{},...uA.environment}});gA.stderr?.on("data",(GA)=>{yw.info(`mcp stderr: ${GA.toString()}`,{key:a})});let d=uA.timeout??iY2;return yield*F(gA,d).pipe(R.map((GA)=>({client:GA,status:{status:"connected"}})),R.catch((GA)=>{let OA=GA instanceof Error?GA.message:String(GA);return yw.error("local mcp startup failed",{key:a,command:uA.command,cwd:v,error:OA}),R.succeed({client:void 0,status:{status:"failed",error:OA}})}))}),Q=R.fn("MCP.create")(function*(a,uA){if(uA.enabled===!1)return yw.info("mcp server disabled",{key:a}),G;yw.info("found",{key:a,type:uA.type});let{client:n,status:m}=uA.type==="remote"?yield*w(a,uA):yield*g(a,uA);if(!n)return{status:m};let v=yield*lY2(a,n,uA.timeout);if(!v)return yield*R.tryPromise(()=>n.close()).pipe(R.ignore),{status:{status:"failed",error:"Failed to get tools"}};return yw.info("create() successfully created client",{key:a,toolCount:v.length}),{mcpClient:n,status:m,defs:v}}),j=yield*t1.Service,K=R.fnUntraced(function*(a){if(process.platform==="win32")return[];let uA=[],n=[a];while(n.length>0){let m=n.shift(),v=yield*A.spawn(V8.make("pgrep",["-P",String(m)],{stdin:"ignore"})),gA=yield*k2.mkString(k2.decodeText(v.stdout));yield*v.exitCode;for(let d of gA.split(`
|
|
4643
4643
|
`)){let GA=parseInt(d,10);if(!isNaN(GA)&&!uA.includes(GA))uA.push(GA),n.push(GA)}}return uA},R.scoped,R.catch(()=>R.succeed([])));function U(a){a.toolVersion++,delete a.toolsCache}function _(a,uA,n,m,v){n.setNotificationHandler(kPA,async()=>{if(yw.info("tools list changed notification received",{server:uA}),a.clients[uA]!==n||a.status[uA]?.status!=="connected")return;let gA=await m.promise(lY2(uA,n,v));if(!gA)return;if(a.clients[uA]!==n||a.status[uA]?.status!=="connected")return;a.defs[uA]=gA,delete a.toolCache[uA],U(a),await m.promise(q.publish(o_u,{server:uA}).pipe(R.ignore))})}let O=yield*z0.make(R.fn("MCP.state")(function*(){let a=yield*j.get(),uA=yield*HQ.make(),n=a.mcp??{},m={status:{},clients:{},defs:{},toolCache:{},toolVersion:0};return yield*R.forEach(Object.entries(n),([v,gA])=>R.gen(function*(){if(!UG0(gA)){yw.error("Ignoring MCP config entry without type",{key:v});return}if(gA.enabled===!1){m.status[v]={status:"disabled"};return}let d=yield*Q(v,gA).pipe(R.catch(()=>R.void));if(!d)return;if(m.status[v]=d.status,d.mcpClient)m.clients[v]=d.mcpClient,m.defs[v]=d.defs,_(m,v,d.mcpClient,uA,gA.timeout)}),{concurrency:"unbounded"}),yield*R.addFinalizer(()=>R.gen(function*(){yield*R.forEach(Object.values(m.clients),(v)=>R.gen(function*(){let gA=v.transport instanceof GG0?v.transport.pid:null;if(typeof gA==="number"){let d=yield*K(gA);for(let GA of d)try{process.kill(GA,"SIGTERM")}catch{}}yield*R.tryPromise(()=>v.close()).pipe(R.ignore)}),{concurrency:"unbounded"}),ogA.clear()})),m}));function W(a,uA){let n=a.clients[uA];if(delete a.defs[uA],delete a.toolCache[uA],U(a),!n)return R.void;return R.tryPromise(()=>n.close()).pipe(R.ignore)}let X=R.fnUntraced(function*(a,uA,n,m,v){let gA=yield*HQ.make();return yield*W(a,uA),a.status[uA]={status:"connected"},a.clients[uA]=n,a.defs[uA]=m,_(a,uA,n,gA,v),a.status[uA]}),Y=R.fn("MCP.status")(function*(){let a=yield*z0.get(O),n=(yield*j.get()).mcp??{},m={};for(let[v,gA]of Object.entries(n)){if(!UG0(gA))continue;m[v]=a.status[v]??{status:"disabled"}}return m}),V=R.fn("MCP.clients")(function*(){return(yield*z0.get(O)).clients}),Z=R.fn("MCP.createAndStore")(function*(a,uA){let n=yield*z0.get(O),m=yield*Q(a,uA);if(n.status[a]=m.status,!m.mcpClient)return yield*W(n,a),delete n.clients[a],m.status;return yield*X(n,a,m.mcpClient,m.defs,uA.timeout)}),H=R.fn("MCP.add")(function*(a,uA){return yield*Z(a,uA),{status:(yield*z0.get(O)).status}}),N=R.fn("MCP.connect")(function*(a){let uA=yield*C(a);if(!uA){yw.error("MCP config not found or invalid",{name:a});return}yield*Z(a,{...uA,enabled:!0})}),B=R.fn("MCP.disconnect")(function*(a){let uA=yield*z0.get(O);yield*W(uA,a),delete uA.clients[a],uA.status[a]={status:"disabled"}}),M=R.fn("MCP.tools")(function*(){let a=yield*z0.get(O),uA=yield*j.get(),n=uA.mcp??{},m=uA.experimental?.mcp_timeout,v=Object.entries(a.clients).flatMap(([GA,OA])=>{if(a.status[GA]?.status!=="connected")return[];let y=n[GA],c=y&&UG0(y)?y:void 0;return[{clientName:GA,client:OA,timeout:c?.timeout??m}]}),gA=v.map((GA)=>[GA.clientName,GA.timeout??""].join("\x00")).join("\x1F");if(a.toolsCache?.version===a.toolVersion&&a.toolsCache.timeoutKey===gA)return a.toolsCache.tools;yield*R.forEach(v,(GA)=>R.gen(function*(){let OA=a.defs[GA.clientName];if(!OA){yw.warn("missing cached tools for connected server",{clientName:GA.clientName});return}let y=a.toolCache[GA.clientName];if(y?.defs===OA&&y.timeout===GA.timeout)return;let c={};for(let FA of OA)c[_G0(GA.clientName)+"_"+_G0(FA.name)]=kaq(FA,GA.client,GA.timeout);a.toolCache[GA.clientName]={defs:OA,timeout:GA.timeout,tools:c}}),{concurrency:"unbounded"});let d=Object.assign({},...v.map((GA)=>a.toolCache[GA.clientName]?.tools??{}));return a.toolsCache={version:a.toolVersion,timeoutKey:gA,tools:d},d});function x(a,uA,n){return R.forEach(Object.entries(a.clients).filter(([m])=>a.status[m]?.status==="connected"),([m,v])=>Saq(m,v,uA,n).pipe(R.map((gA)=>Object.entries(gA??{}))),{concurrency:"unbounded"}).pipe(R.map((m)=>Object.fromEntries(m.flat())))}let $=R.fn("MCP.prompts")(function*(){let a=yield*z0.get(O);return yield*x(a,(uA)=>uA.listPrompts().then((n)=>n.prompts),"prompts")}),E=R.fn("MCP.resources")(function*(){let a=yield*z0.get(O);return yield*x(a,(uA)=>uA.listResources().then((n)=>n.resources),"resources")}),z=R.fnUntraced(function*(a,uA,n,m){let gA=(yield*z0.get(O)).clients[a];if(!gA){yw.warn(`client not found for ${n}`,{clientName:a});return}return yield*R.tryPromise({try:()=>uA(gA),catch:(d)=>{return yw.error(`failed to ${n}`,{clientName:a,...m,error:d?.message}),d}}).pipe(R.orElseSucceed(()=>{return}))}),T=R.fn("MCP.getPrompt")(function*(a,uA,n){return yield*z(a,(m)=>m.getPrompt({name:uA,arguments:n}),"getPrompt",{promptName:uA})}),D=R.fn("MCP.readResource")(function*(a,uA){return yield*z(a,(n)=>n.readResource({uri:uA}),"readResource",{resourceUri:uA})}),C=R.fnUntraced(function*(a){let n=(yield*j.get()).mcp?.[a];if(!n||!UG0(n))return;return n}),t=R.fn("MCP.startAuth")(function*(a){let uA=yield*C(a);if(!uA)throw Error(`MCP server ${a} not found or disabled`);if(uA.type!=="remote")throw Error(`MCP server ${a} is not a remote server`);if(uA.oauth===!1)throw Error(`MCP server ${a} has OAuth explicitly disabled`);let n=typeof uA.oauth==="object"?uA.oauth:void 0;yield*R.promise(()=>c0A.ensureRunning(n?.redirectUri));let m=Array.from(crypto.getRandomValues(new Uint8Array(32))).map((GA)=>GA.toString(16).padStart(2,"0")).join("");yield*u.updateOAuthState(a,m);let v,gA=new wG0(a,uA.url,{clientId:n?.clientId,clientSecret:n?.clientSecret,scope:n?.scope,redirectUri:n?.redirectUri},{onRedirect:async(GA)=>{v=GA}},u),d=new uG0(new URL(uA.url),{authProvider:gA});return yield*R.tryPromise({try:()=>{let GA=new tF0({name:"codeplane",version:S4});return GA.connect(d).then(()=>({authorizationUrl:"",oauthState:m,client:GA}))},catch:(GA)=>GA}).pipe(R.catch((GA)=>{if(GA instanceof uJ&&v)return ogA.set(a,d),R.succeed({authorizationUrl:v.toString(),oauthState:m});return R.die(GA)}))}),S=R.fn("MCP.authenticate")(function*(a){let uA=yield*t(a);if(!uA.authorizationUrl){let gA="client"in uA?uA.client:void 0,d=yield*C(a);if(!d)return yield*R.tryPromise(()=>gA?.close()??Promise.resolve()).pipe(R.ignore),{status:"failed",error:"MCP config not found after auth"};let GA=gA?yield*lY2(a,gA,d.timeout):void 0;if(!gA||!GA)return yield*R.tryPromise(()=>gA?.close()??Promise.resolve()).pipe(R.ignore),{status:"failed",error:"Failed to get tools"};let OA=yield*z0.get(O);return yield*u.clearOAuthState(a),yield*X(OA,a,gA,GA,d.timeout)}yw.info("opening browser for oauth",{mcpName:a,url:uA.authorizationUrl,state:uA.oauthState});let n=c0A.waitForCallback(uA.oauthState,a);yield*R.tryPromise(()=>Hv(uA.authorizationUrl)).pipe(R.flatMap((gA)=>R.callback((d)=>{let GA=setTimeout(()=>d(R.void),500);gA.on("error",(OA)=>{clearTimeout(GA),d(R.fail(OA))}),gA.on("exit",(OA)=>{if(OA!==null&&OA!==0)clearTimeout(GA),d(R.fail(Error(`Browser open failed with exit code ${OA}`)))})})),R.catch(()=>{return yw.warn("failed to open browser, user must open URL manually",{mcpName:a}),q.publish(s_u,{mcpName:a,url:uA.authorizationUrl}).pipe(R.ignore)}));let m=yield*R.promise(()=>n);if((yield*u.getOAuthState(a))!==uA.oauthState)throw yield*u.clearOAuthState(a),Error("OAuth state mismatch - potential CSRF attack");return yield*u.clearOAuthState(a),yield*f(a,m)}),f=R.fn("MCP.finishAuth")(function*(a,uA){let n=ogA.get(a);if(!n)throw Error(`No pending OAuth flow for MCP server: ${a}`);let m=yield*R.tryPromise({try:()=>n.finishAuth(uA).then(()=>!0),catch:(gA)=>{return yw.error("failed to finish oauth",{mcpName:a,error:gA}),gA}}).pipe(R.option);if(b0.isNone(m))return{status:"failed",error:"OAuth completion failed"};yield*u.clearCodeVerifier(a),ogA.delete(a);let v=yield*C(a);if(!v)return{status:"failed",error:"MCP config not found after auth"};return yield*Z(a,v)}),r=R.fn("MCP.removeAuth")(function*(a){yield*u.remove(a),c0A.cancelPending(a),ogA.delete(a),yw.info("removed oauth credentials",{mcpName:a})}),l=R.fn("MCP.supportsOAuth")(function*(a){let uA=yield*C(a);if(!uA)return!1;return uA.type==="remote"&&uA.oauth!==!1}),e=R.fn("MCP.hasStoredTokens")(function*(a){return!!(yield*u.get(a))?.tokens}),s=R.fn("MCP.getAuthStatus")(function*(a){if(!(yield*u.get(a))?.tokens)return"not_authenticated";return(yield*u.isTokenExpired(a))?"expired":"authenticated"});return JG0.of({status:Y,clients:V,tools:M,prompts:$,resources:E,add:H,connect:N,disconnect:B,getPrompt:T,readResource:D,startAuth:t,authenticate:S,finishAuth:f,removeAuth:r,supportsOAuth:l,hasStoredTokens:e,getAuthStatus:s})})),Caq=e_u.pipe(fA.provide(fc.layer),fA.provide(m1.layer),fA.provide(t1.defaultLayer),fA.provide(Dw),fA.provide(P2.defaultLayer))});import OG0 from"crypto";function haq(A){let u=Math.floor(A()*WG0)%WG0;return uJu.charAt(u)}function maq(A){let u=baq(),q=u&&(u.crypto||u.msCrypto)||(typeof OG0<"u"?OG0:null);if(typeof q?.getRandomValues==="function")return()=>{let F=new Uint8Array(1);return q.getRandomValues(F),F[0]/255};else if(typeof q?.randomBytes==="function")return()=>q.randomBytes(1).readUInt8()/255;else if(OG0?.randomBytes)return()=>OG0.randomBytes(1).readUInt8()/255;throw new sgA(d0A.PRNGDetectFailure,"Failed to find a reliable PRNG")}function baq(){if(vaq())return self;if(typeof window<"u")return window;if(typeof global<"u")return global;if(typeof globalThis<"u")return globalThis;return null}function taq(A,u){let q="";for(;A>0;A--)q=haq(u)+q;return q}function yaq(A,u=qJu){if(isNaN(A))throw new sgA(d0A.EncodeTimeValueMalformed,`Time must be a number: ${A}`);else if(A>AJu)throw new sgA(d0A.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${AJu}: ${A}`);else if(A<0)throw new sgA(d0A.EncodeTimeNegative,`Time must be positive: ${A}`);else if(Number.isInteger(A)===!1)throw new sgA(d0A.EncodeTimeValueMalformed,`Time must be an integer: ${A}`);let q,F="";for(let G=u;G>0;G--)q=A%WG0,F=uJu.charAt(q)+F,A=(A-q)/WG0;return F}function vaq(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function cY2(A,u){let q=u||maq(),F=!A||isNaN(A)?Date.now():A;return yaq(F,qJu)+taq(faq,q)}var uJu="0123456789ABCDEFGHJKMNPQRSTVWXYZ",WG0=32,faq=16,qJu=10,AJu=281474976710655,d0A,sgA;var FJu=k(()=>{(function(A){A.Base32IncorrectEncoding="B32_ENC_INVALID",A.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",A.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",A.EncodeTimeNegative="ENC_TIME_NEG",A.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",A.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",A.PRNGDetectFailure="PRNG_DETECT",A.ULIDInvalid="ULID_INVALID",A.Unexpected="UNEXPECTED",A.UUIDInvalid="UUID_INVALID"})(d0A||(d0A={}));sgA=class sgA extends Error{constructor(A,u){super(`${u} (${A})`);this.name="ULIDError",this.code=A}}});var dY2=`Run the local full-stack Tetris agent audit.
|
|
4644
4644
|
|
|
4645
4645
|
Use the current project configuration and native tools.
|