@rizom/brain 0.2.0-alpha.340 → 0.2.0-alpha.341
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/brain.js +38 -38
- package/dist/chunks/app-y7q0xdcg.js +5 -0
- package/dist/chunks/blog-post-adapter-ae6xkt56.js +5 -0
- package/dist/chunks/{index-aqgmcpkn.js → index-03yfn024.js} +2 -2
- package/dist/chunks/{index-vn7e2ctj.js → index-046155sg.js} +2 -2
- package/dist/chunks/{index-2emvdp0b.js → index-6n3gspsw.js} +3 -3
- package/dist/chunks/{index-4q6q0h7s.js → index-9pgv29vq.js} +3 -3
- package/dist/chunks/{index-4q6q0h7s.js.map → index-9pgv29vq.js.map} +1 -1
- package/dist/chunks/{index-b07ff2bs.js → index-atscxmvg.js} +2 -2
- package/dist/chunks/{index-qe487m15.js → index-f0wsc8k2.js} +2 -2
- package/dist/chunks/{index-1cn8hres.js → index-njsbgnad.js} +2 -2
- package/dist/chunks/{index-42dsww4h.js → index-nwfpmtvv.js} +2 -2
- package/dist/chunks/{index-0x4e8bmm.js → index-pzbj62c8.js} +2 -2
- package/dist/chunks/{index-ap5vwjap.js → index-sqdhe2fa.js} +3 -3
- package/dist/chunks/{index-ap5vwjap.js.map → index-sqdhe2fa.js.map} +5 -5
- package/dist/chunks/linkedin-template-sq3f3xr1.js +5 -0
- package/dist/chunks/{rss-datasource-wzbv8k94.js → rss-datasource-10fgjdhb.js} +2 -2
- package/dist/entities.js +1 -1
- package/dist/git-broker.js +1 -1
- package/dist/index.js +1 -1
- package/dist/interfaces.js +1 -1
- package/dist/model.d.ts +4 -0
- package/dist/model.js +39 -39
- package/dist/model.js.map +4 -4
- package/dist/plugins.js +1 -1
- package/dist/services.js +1 -1
- package/dist/templates.d.ts +5 -0
- package/dist/templates.js +1 -1
- package/dist/ui/app.js +2 -2
- package/dist/ui/app.js.map +4 -4
- package/package.json +1 -1
- package/dist/chunks/app-dabfj0vn.js +0 -5
- package/dist/chunks/blog-post-adapter-tbppq1ge.js +0 -5
- package/dist/chunks/linkedin-template-j6zqergh.js +0 -5
- /package/dist/chunks/{app-dabfj0vn.js.map → app-y7q0xdcg.js.map} +0 -0
- /package/dist/chunks/{blog-post-adapter-tbppq1ge.js.map → blog-post-adapter-ae6xkt56.js.map} +0 -0
- /package/dist/chunks/{index-aqgmcpkn.js.map → index-03yfn024.js.map} +0 -0
- /package/dist/chunks/{index-vn7e2ctj.js.map → index-046155sg.js.map} +0 -0
- /package/dist/chunks/{index-2emvdp0b.js.map → index-6n3gspsw.js.map} +0 -0
- /package/dist/chunks/{index-b07ff2bs.js.map → index-atscxmvg.js.map} +0 -0
- /package/dist/chunks/{index-qe487m15.js.map → index-f0wsc8k2.js.map} +0 -0
- /package/dist/chunks/{index-1cn8hres.js.map → index-njsbgnad.js.map} +0 -0
- /package/dist/chunks/{index-42dsww4h.js.map → index-nwfpmtvv.js.map} +0 -0
- /package/dist/chunks/{index-0x4e8bmm.js.map → index-pzbj62c8.js.map} +0 -0
- /package/dist/chunks/{linkedin-template-j6zqergh.js.map → linkedin-template-sq3f3xr1.js.map} +0 -0
- /package/dist/chunks/{rss-datasource-wzbv8k94.js.map → rss-datasource-10fgjdhb.js.map} +0 -0
package/dist/ui/app.js
CHANGED
|
@@ -4293,7 +4293,7 @@ ${e.preview}`:e.summary,input:e.input??{}};switch(e.state){case"approval-request
|
|
|
4293
4293
|
`+ae.slice(ze,Le),ze=Le+1;qe=et}if(Ze+=`
|
|
4294
4294
|
`,ae.length-ze>Ae&&qe>ze)Ze+=ae.slice(ze,qe)+`
|
|
4295
4295
|
`+ae.slice(qe+1);else Ze+=ae.slice(ze);return Ze.slice(1)}function ye(ae){let Ae="",ue=0;for(let we=0;we<ae.length;ue>=65536?we+=2:we++){ue=ce(ae,we);let ze=I[ue];if(!ze&&ne(ue)){if(Ae+=ae[we],ue>=65536)Ae+=ae[we+1]}else Ae+=ze||M(ue)}return Ae}function Ce(ae,Ae,ue){let we="",ze=ae.tag;for(let Le=0,qe=ue.length;Le<qe;Le+=1){let et=ue[Le];if(ae.replacer)et=ae.replacer.call(ue,String(Le),et);if(de(ae,Ae,et,!1,!1)||typeof et>"u"&&de(ae,Ae,null,!1,!1)){if(we!=="")we+=","+(!ae.condenseFlow?" ":"");we+=ae.dump}}ae.tag=ze,ae.dump="["+we+"]"}function Ie(ae,Ae,ue,we){let ze="",Le=ae.tag;for(let qe=0,et=ue.length;qe<et;qe+=1){let Ze=ue[qe];if(ae.replacer)Ze=ae.replacer.call(ue,String(qe),Ze);if(de(ae,Ae+1,Ze,!0,!0,!1,!0)||typeof Ze>"u"&&de(ae,Ae+1,null,!0,!0,!1,!0)){if(!we||ze!=="")ze+=q(ae,Ae);if(ae.dump&&s===ae.dump.charCodeAt(0))ze+="-";else ze+="- ";ze+=ae.dump}}ae.tag=Le,ae.dump=ze||"[]"}function Ee(ae,Ae,ue){let we="",ze=ae.tag,Le=Object.keys(ue);for(let qe=0,et=Le.length;qe<et;qe+=1){let Ze="";if(we!=="")Ze+=", ";if(ae.condenseFlow)Ze+='"';let He=Le[qe],ot=ue[He];if(ae.replacer)ot=ae.replacer.call(ue,He,ot);if(!de(ae,Ae,He,!1,!1))continue;if(ae.dump.length>1024)Ze+="? ";if(Ze+=ae.dump+(ae.condenseFlow?'"':"")+":"+(ae.condenseFlow?"":" "),!de(ae,Ae,ot,!1,!1))continue;Ze+=ae.dump,we+=Ze}ae.tag=ze,ae.dump="{"+we+"}"}function J(ae,Ae,ue,we){let ze="",Le=ae.tag,qe=Object.keys(ue);if(ae.sortKeys===!0)qe.sort();else if(typeof ae.sortKeys==="function")qe.sort(ae.sortKeys);else if(ae.sortKeys)throw new t("sortKeys must be a boolean or a function");for(let et=0,Ze=qe.length;et<Ze;et+=1){let He="";if(!we||ze!=="")He+=q(ae,Ae);let ot=qe[et],Ne=ue[ot];if(ae.replacer)Ne=ae.replacer.call(ue,ot,Ne);if(!de(ae,Ae+1,ot,!0,!0,!0))continue;let bt=ae.tag!==null&&ae.tag!=="?"||ae.dump&&ae.dump.length>1024;if(bt)if(ae.dump&&s===ae.dump.charCodeAt(0))He+="?";else He+="? ";if(He+=ae.dump,bt)He+=q(ae,Ae);if(!de(ae,Ae+1,Ne,!0,bt))continue;if(ae.dump&&s===ae.dump.charCodeAt(0))He+=":";else He+=": ";He+=ae.dump,ze+=He}ae.tag=Le,ae.dump=ze||"{}"}function Be(ae,Ae,ue){let we=ue?ae.explicitTypes:ae.implicitTypes;for(let ze=0,Le=we.length;ze<Le;ze+=1){let qe=we[ze];if((qe.instanceOf||qe.predicate)&&(!qe.instanceOf||typeof Ae==="object"&&Ae instanceof qe.instanceOf)&&(!qe.predicate||qe.predicate(Ae))){if(ue)if(qe.multi&&qe.representName)ae.tag=qe.representName(Ae);else ae.tag=qe.tag;else ae.tag="?";if(qe.represent){let et=ae.styleMap[qe.tag]||qe.defaultStyle,Ze;if(r.call(qe.represent)==="[object Function]")Ze=qe.represent(Ae,et);else if(a.call(qe.represent,et))Ze=qe.represent[et](Ae,et);else throw new t("!<"+qe.tag+'> tag resolver accepts not "'+et+'" style');ae.dump=Ze}return!0}}return!1}function de(ae,Ae,ue,we,ze,Le,qe){if(ae.tag=null,ae.dump=ue,!Be(ae,ue,!1))Be(ae,ue,!0);let et=r.call(ae.dump),Ze=we;if(we)we=ae.flowLevel<0||ae.flowLevel>Ae;let He=et==="[object Object]"||et==="[object Array]",ot,Ne;if(He)ot=ae.duplicates.indexOf(ue),Ne=ot!==-1;if(ae.tag!==null&&ae.tag!=="?"||Ne||ae.indent!==2&&Ae>0)ze=!1;if(Ne&&ae.usedDuplicates[ot])ae.dump="*ref_"+ot;else{if(He&&Ne&&!ae.usedDuplicates[ot])ae.usedDuplicates[ot]=!0;if(et==="[object Object]"){if(we&&Object.keys(ae.dump).length!==0){if(J(ae,Ae,ae.dump,ze),Ne)ae.dump="&ref_"+ot+ae.dump}else if(Ee(ae,Ae,ae.dump),Ne)ae.dump="&ref_"+ot+" "+ae.dump}else if(et==="[object Array]"){if(we&&ae.dump.length!==0){if(ae.noArrayIndent&&!qe&&Ae>0)Ie(ae,Ae-1,ae.dump,ze);else Ie(ae,Ae,ae.dump,ze);if(Ne)ae.dump="&ref_"+ot+ae.dump}else if(Ce(ae,Ae,ae.dump),Ne)ae.dump="&ref_"+ot+" "+ae.dump}else if(et==="[object String]"){if(ae.tag!=="?")Te(ae,ae.dump,Ae,Le,Ze)}else if(et==="[object Undefined]")return!1;else{if(ae.skipInvalid)return!1;throw new t("unacceptable kind of an object to dump "+et)}if(ae.tag!==null&&ae.tag!=="?"){let bt=encodeURI(ae.tag[0]==="!"?ae.tag.slice(1):ae.tag).replace(/!/g,"%21");if(ae.tag[0]==="!")bt="!"+bt;else if(bt.slice(0,18)==="tag:yaml.org,2002:")bt="!!"+bt.slice(18);else bt="!<"+bt+">";ae.dump=bt+" "+ae.dump}}return!0}function te(ae,Ae){let ue=[],we=[];De(ae,ue,we);let ze=we.length;for(let Le=0;Le<ze;Le+=1)Ae.duplicates.push(ue[we[Le]]);Ae.usedDuplicates=Array(ze)}function De(ae,Ae,ue){if(ae!==null&&typeof ae==="object"){let we=Ae.indexOf(ae);if(we!==-1){if(ue.indexOf(we)===-1)ue.push(we)}else if(Ae.push(ae),Array.isArray(ae))for(let ze=0,Le=ae.length;ze<Le;ze+=1)De(ae[ze],Ae,ue);else{let ze=Object.keys(ae);for(let Le=0,qe=ze.length;Le<qe;Le+=1)De(ae[ze[Le]],Ae,ue)}}}function oe(ae,Ae){Ae=Ae||{};let ue=new N(Ae);if(!ue.noRefs)te(ae,ue);let we=ae;if(ue.replacer)we=ue.replacer.call({"":we},"",we);if(de(ue,0,we,!0,!0))return ue.dump+`
|
|
4296
|
-
`;return""}return APe.dump=oe,APe}var ndn;function iVr(){if(ndn)return Rd;ndn=1;let e=rVr(),t=aVr();function n(r,a){return function(){throw Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+a+" instead, which is now safe by default.")}}return Rd.Type=zp(),Rd.Schema=rdn(),Rd.FAILSAFE_SCHEMA=sdn(),Rd.JSON_SCHEMA=pdn(),Rd.CORE_SCHEMA=mdn(),Rd.DEFAULT_SCHEMA=gPe(),Rd.load=e.load,Rd.loadAll=e.loadAll,Rd.dump=t.dump,Rd.YAMLException=KO(),Rd.types={binary:fdn(),float:ddn(),map:odn(),null:cdn(),pairs:bdn(),set:ydn(),timestamp:Adn(),bool:ldn(),int:udn(),merge:gdn(),omap:hdn(),seq:idn(),str:adn()},Rd.safeLoad=n("safeLoad","load"),Rd.safeLoadAll=n("safeLoadAll","loadAll"),Rd.safeDump=n("safeDump","dump"),Rd}var Rec=iVr();var Lec=P.record(P.string(),P.unknown());var AVr=P.object({slug:P.string(),title:P.string(),type:P.string(),entityId:P.string(),contentHash:P.string()});var gVr=Boe.omit({url:!0,analyticsScript:!0}),fVr=gVr.extend({title:P.string().optional().describe("Optional site title override"),description:P.string().optional().describe("Optional site description override")});var kdn=["primary","secondary"];var hVr=P.custom((e)=>typeof e==="function","Expected a React component"),bVr=P.strictObject({show:P.boolean().optional(),label:P.string().min(1).optional(),slot:P.enum(kdn).optional(),priority:P.number().optional()}),yVr=P.strictObject({id:P.string().min(1),template:P.string().min(1),content:P.unknown().optional(),dataQuery:P.looseObject({entityType:P.string().optional(),template:P.string().optional(),query:P.record(P.string(),P.unknown()).optional()}).optional(),order:P.number().optional()}),wVr=P.strictObject({id:P.string().min(1),path:P.string().startsWith("/"),title:P.string().optional(),pageLabel:P.string().optional(),description:P.string().optional(),sections:P.array(yVr).optional(),layout:P.string().min(1).optional(),fullscreen:P.boolean().optional(),pluginId:P.string().optional(),sourceEntityType:P.string().optional(),external:P.boolean().optional(),navigation:bVr.optional()}),vVr=P.strictObject({label:P.string().min(1),pluralName:P.string().min(1).optional(),layout:P.string().min(1).optional(),paginate:P.boolean().optional(),pageSize:P.number().int().positive().optional(),navigation:P.strictObject({show:P.boolean().optional(),slot:P.enum(kdn).optional(),priority:P.number().optional()}).optional()}),kVr=P.strictObject({schema:P.custom((e)=>e instanceof P.ZodType,"Expected a Zod schema"),component:P.custom((e)=>typeof e==="function","Expected a React component"),title:P.string().min(1),description:P.string(),requiredPermission:P.enum(["admin","trusted","public"]).optional(),fullscreen:P.boolean().optional()}),vdn=P.strictObject({namespace:P.string().min(1),sections:P.record(P.string(),kVr)}),CVr=P.record(P.string(),P.json()),xVr=P.record(P.string(),P.record(P.string(),CVr)),Cdn=P.strictObject({layouts:P.record(P.string(),hVr).refine((e)=>typeof e.default==="function",{message:'Site layouts must include a "default" component'}),routes:P.array(wVr),content:xVr.optional(),sections:P.union([vdn,P.array(vdn)]).optional(),themeOverride:P.string().optional(),headScripts:P.array(P.string()).optional(),entityDisplay:P.record(P.string(),vVr),staticAssets:P.record(P.string(),P.string()).optional()}).superRefine((e,t)=>{let n=new Set;for(let[i,o]of e.routes.entries()){if(n.has(o.id))t.addIssue({code:"custom",path:["routes",i,"id"],message:`Duplicate route id "${o.id}"`});n.add(o.id);let s=o.layout??"default";if(!e.layouts[s])t.addIssue({code:"custom",path:["routes",i,"layout"],message:`Unknown layout "${s}"`})}let r=Array.isArray(e.sections)?e.sections:e.sections?[e.sections]:[],a=new Map(r.map((i)=>[i.namespace,i]));if(a.size!==r.length)t.addIssue({code:"custom",path:["sections"],message:"Section group namespaces must be unique"});for(let[i,o]of Object.entries(e.content??{})){let s=a.get(i);if(!s){t.addIssue({code:"custom",path:["content",i],message:`Content namespace "${i}" has no section group`});continue}for(let[l,u]of Object.entries(o)){let d=s.sections[l];if(!d){t.addIssue({code:"custom",path:["content",i,l],message:`Content section "${i}.${l}" is not defined`});continue}let p=d.schema.safeParse(u);if(!p.success)t.addIssue({code:"custom",path:["content",i,l],message:`Content does not satisfy the "${i}.${l}" schema: ${P.prettifyError(p.error)}`})}}});var _Vr=P.string();function EVr(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}var BVr=P.custom((e)=>{if(!EVr(e))return!1;let{plugin:t,...n}=e;if(t!==void 0&&typeof t!=="function")return!1;return Cdn.safeParse(n).success});function Vy(e=12){return kO(e)}var hPe=P.enum(["file_operations","content_operations","data_processing","batch_processing"]),SVr=P.object({pluginId:P.string().optional(),progressToken:P.union([P.string(),P.number()]).optional(),operationType:hPe,operationTarget:P.string().optional(),interfaceType:P.string().optional(),conversationId:P.string().optional(),channelId:P.string().optional(),requestedByActor:UA.optional(),requestedByUserId:P.string().optional(),requestedByInterface:P.string().optional(),silent:P.boolean().optional(),provenance:W8.optional()}),oQ=P.object({pluginId:P.string().optional(),progressToken:P.union([P.string(),P.number()]).optional(),operationType:hPe,operationTarget:P.string().optional(),interfaceType:P.string().optional(),conversationId:P.string().optional(),channelId:P.string().optional(),requestedByActor:UA.optional(),requestedByUserId:P.string().optional(),requestedByInterface:P.string().optional(),silent:P.boolean().optional(),provenance:W8.optional(),rootJobId:P.string()}),anc=P.enum(["none","skip","replace","coalesce"]);var TVr=P.object({id:P.string(),type:P.string(),data:P.string(),status:P.enum(["pending","processing","completed","failed"]),source:P.string().nullable(),priority:P.number(),retryCount:P.number(),maxRetries:P.number(),lastError:P.string().nullable(),createdAt:P.number(),scheduledFor:P.number(),startedAt:P.number().nullable(),completedAt:P.number().nullable(),attemptId:P.string().nullable(),workerSlotId:P.string().nullable(),workerSessionId:P.string().nullable(),leaseExpiresAt:P.number().nullable(),attemptHeartbeatAt:P.number().nullable(),runtimeUpdatedAt:P.number().nullable(),metadata:oQ,progress:P.custom((e)=>typeof e==="object"&&e!==null&&("progress"in e)&&typeof e.progress==="number").nullable(),result:P.unknown().nullable().optional()});var bPe=P.enum(["pending","processing","completed","failed"]),xdn=P.enum(["completed","failed"]);var DVr=P.object({id:P.string(),type:P.string(),status:bPe,data:P.unknown(),result:P.unknown().optional(),lastError:P.string().optional().nullable(),attempts:P.number(),maxRetries:P.number(),priority:P.number(),createdAt:P.date(),updatedAt:P.date(),processedAt:P.date().optional().nullable(),completedAt:P.date().optional().nullable(),failedAt:P.date().optional().nullable()}),RVr=P.object({jobId:P.string(),type:P.string(),status:xdn,result:P.unknown().optional(),error:P.string().optional()}),_dn=P.object({success:P.literal(!1),error:P.string().optional()}),yPe=P.object({id:P.string(),type:P.enum(["job","batch"]),status:bPe,message:P.string().optional(),progress:P.object({current:P.number(),total:P.number(),percentage:P.number()}).optional(),aggregationKey:P.string().optional(),batchDetails:P.object({totalOperations:P.number(),completedOperations:P.number(),failedOperations:P.number(),currentOperation:P.string().optional(),errors:P.array(P.string()).optional()}).optional(),jobDetails:P.object({jobType:P.string(),priority:P.number(),retryCount:P.number()}).optional(),metadata:oQ});var Anc=(()=>new RegExp("^(?<scheme>[A-Za-z][A-Za-z.+-]*):(//(?<authority>[^/?#]*))?(?<path>[^?#]*)(\\?(?<query>[^#]*))?(#(?<fragment>.*))?$","su"))();var gnc=(()=>new RegExp("^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\[\\]]*)|(\\[(?<host_br>[^\\[\\]]*)\\]))(:(?<port>[0-9]*))?$","su"))();var sQ;if(typeof WebSocket<"u")sQ=WebSocket;else if(typeof global<"u")sQ=global.WebSocket;else if(typeof window<"u")sQ=window.WebSocket;else if(typeof self<"u")sQ=self.WebSocket;var Unc=-9223372036854775808n;var xPe;if(typeof queueMicrotask<"u")xPe=queueMicrotask;else{let e=Promise.resolve();xPe=(t)=>{e.then(t)}}var BZr=Fn(EPe(),1);var IZr=Fn(EPe(),1);var Mn=Symbol.for("drizzle:entityKind");function Qd(e,t){if(!e||typeof e!=="object")return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,Mn))throw Error(`Class "${t.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e).constructor;if(n)while(n){if(Mn in n&&n[Mn]===t[Mn])return!0;n=Object.getPrototypeOf(n)}return!1}class H1{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[Mn]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class XO{static[Mn]="ColumnBuilder";config;constructor(e,t,n){this.config={name:e,keyAsName:e==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){if(this.config.name!=="")return;this.config.name=e}}var qm=Symbol.for("drizzle:Name");class BPe{static[Mn]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,t){if(this.reference=()=>{let{name:n,columns:r,foreignColumns:a}=e();return{name:n,columns:r,foreignTable:a[0].table,foreignColumns:a}},t)this._onUpdate=t.onUpdate,this._onDelete=t.onDelete}onUpdate(e){return this._onUpdate=e===void 0?"no action":e,this}onDelete(e){return this._onDelete=e===void 0?"no action":e,this}build(e){return new zdn(e,this)}}class zdn{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[Mn]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map((o)=>o.name),a=n.map((o)=>o.name),i=[this.table[qm],...r,n[0].table[qm],...a];return e??`${i.join("_")}_fk`}}function Doe(e,...t){return e(...t)}function IPe(e,t){return`${e[qm]}_${t.join("_")}_unique`}class jdn{constructor(e,t){this.name=t,this.columns=e}static[Mn]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new qdn(e,this.columns,this.nullsNotDistinctConfig,this.name)}}class SZr{static[Mn]="PgUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new jdn(e,this.name)}}class qdn{constructor(e,t,n,r){this.table=e,this.columns=t,this.name=r??IPe(this.table,this.columns.map((a)=>a.name)),this.nullsNotDistinct=n}static[Mn]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function Gdn(e,t,n){for(let r=t;r<e.length;r++){let a=e[r];if(a==="\\"){r++;continue}if(a==='"')return[e.slice(t,r).replace(/\\/g,""),r+1];if(n)continue;if(a===","||a==="}")return[e.slice(t,r).replace(/\\/g,""),r]}return[e.slice(t).replace(/\\/g,""),e.length]}function Udn(e,t=0){let n=[],r=t,a=!1;while(r<e.length){let i=e[r];if(i===","){if(a||r===t)n.push("");a=!0,r++;continue}if(a=!1,i==="\\"){r+=2;continue}if(i==='"'){let[l,u]=Gdn(e,r+1,!0);n.push(l),r=u;continue}if(i==="}")return[n,r+1];if(i==="{"){let[l,u]=Udn(e,r+1);n.push(l),r=u;continue}let[o,s]=Gdn(e,r,!1);n.push(o),r=s}return[n,r]}function Hdn(e){let[t]=Udn(e,1);return t}function SPe(e){return`{${e.map((t)=>{if(Array.isArray(t))return SPe(t);if(typeof t==="string")return`"${t.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${t}`}).join(",")}}`}class e7 extends XO{foreignKeyConfigs=[];static[Mn]="PgColumnBuilder";array(e){return new Ydn(this.config.name,this,e)}references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e,t){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=t?.nulls,this}generatedAlwaysAs(e){return this.config.generated={as:e,type:"always",mode:"stored"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>Doe((a,i)=>{let o=new BPe(()=>{let s=a();return{columns:[e],foreignColumns:[s]}});if(i.onUpdate)o.onUpdate(i.onUpdate);if(i.onDelete)o.onDelete(i.onDelete);return o.build(t)},n,r))}buildExtraConfigColumn(e){return new Wdn(e,this.config)}}class lQ extends H1{constructor(e,t){if(!t.uniqueName)t.uniqueName=IPe(e,[t.name]);super(e,t);this.table=e}static[Mn]="PgColumn"}class Wdn extends lQ{static[Mn]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(e){return this.indexConfig.opClass=e,this}}class TZr{static[Mn]="IndexedColumn";constructor(e,t,n,r){this.name=e,this.keyAsName=t,this.type=n,this.indexConfig=r}name;keyAsName;type;indexConfig}class Ydn extends e7{static[Mn]="PgArrayBuilder";constructor(e,t,n){super(e,"array","PgArray");this.config.baseBuilder=t,this.config.size=n}build(e){let t=this.config.baseBuilder.build(e);return new TPe(e,this.config,t)}}class TPe extends lQ{constructor(e,t,n,r){super(e,t);this.baseColumn=n,this.range=r,this.size=t.size}size;static[Mn]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue(e){if(typeof e==="string")e=Hdn(e);return e.map((t)=>this.baseColumn.mapFromDriverValue(t))}mapToDriverValue(e,t=!1){let n=e.map((r)=>r===null?null:Qd(this.baseColumn,TPe)?this.baseColumn.mapToDriverValue(r,!0):this.baseColumn.mapToDriverValue(r));if(t)return n;return SPe(n)}}class DZr extends e7{static[Mn]="PgEnumObjectColumnBuilder";constructor(e,t){super(e,"string","PgEnumObjectColumn");this.config.enum=t}build(e){return new Zdn(e,this.config)}}class Zdn extends lQ{static[Mn]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}}var Vdn=Symbol.for("drizzle:isPgEnum");function Kdn(e){return!!e&&typeof e==="function"&&Vdn in e&&e[Vdn]===!0}class RZr extends e7{static[Mn]="PgEnumColumnBuilder";constructor(e,t){super(e,"string","PgEnumColumn");this.config.enum=t}build(e){return new Jdn(e,this.config)}}class Jdn extends lQ{static[Mn]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}}class t7{static[Mn]="Subquery";constructor(e,t,n,r=!1,a=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:n,isWith:r,usedTables:a}}}class QZr extends t7{static[Mn]="WithSubquery"}var Xdn="0.45.2";var DPe,RPe,epn={startActiveSpan(e,t){if(!DPe)return t();if(!RPe)RPe=DPe.trace.getTracer("drizzle-orm",Xdn);return Doe((n,r)=>r.startActiveSpan(e,(a)=>{try{return t(a)}catch(i){throw a.setStatus({code:n.SpanStatusCode.ERROR,message:i instanceof Error?i.message:"Unknown error"}),i}finally{a.end()}}),DPe,RPe)}};var uQ=Symbol.for("drizzle:ViewBaseConfig");var QPe=Symbol.for("drizzle:Schema"),tpn=Symbol.for("drizzle:Columns"),npn=Symbol.for("drizzle:ExtraConfigColumns"),LPe=Symbol.for("drizzle:OriginalName"),MPe=Symbol.for("drizzle:BaseName"),n7=Symbol.for("drizzle:IsAlias"),rpn=Symbol.for("drizzle:ExtraConfigBuilder"),LZr=Symbol.for("drizzle:IsDrizzleTable");class ul{static[Mn]="Table";static Symbol={Name:qm,Schema:QPe,OriginalName:LPe,Columns:tpn,ExtraConfigColumns:npn,BaseName:MPe,IsAlias:n7,ExtraConfigBuilder:rpn};[qm];[LPe];[QPe];[tpn];[npn];[MPe];[n7]=!1;[LZr]=!0;[rpn]=void 0;constructor(e,t,n){this[qm]=this[LPe]=e,this[QPe]=t,this[MPe]=n}}class MZr{static[Mn]="FakePrimitiveParam"}function FZr(e){return e!==null&&e!==void 0&&typeof e.getSQL==="function"}function NZr(e){let t={sql:"",params:[]};for(let n of e)if(t.sql+=n.sql,t.params.push(...n.params),n.typings?.length){if(!t.typings)t.typings=[];t.typings.push(...n.typings)}return t}class tf{static[Mn]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new dl([this])}}class dl{constructor(e){this.queryChunks=e;for(let t of e)if(Qd(t,ul)){let n=t[ul.Symbol.Schema];this.usedTables.push(n===void 0?t[ul.Symbol.Name]:n+"."+t[ul.Symbol.Name])}}static[Mn]="SQL";decoder=apn;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return epn.startActiveSpan("drizzle.buildSQL",(t)=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(e,t){let n=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:r,escapeName:a,escapeParam:i,prepareTyping:o,inlineParams:s,paramStartIndex:l}=n;return NZr(e.map((u)=>{if(Qd(u,tf))return{sql:u.value.join(""),params:[]};if(Qd(u,Roe))return{sql:a(u.value),params:[]};if(u===void 0)return{sql:"",params:[]};if(Array.isArray(u)){let d=[new tf("(")];for(let[p,m]of u.entries())if(d.push(m),p<u.length-1)d.push(new tf(", "));return d.push(new tf(")")),this.buildQueryFromSourceParams(d,n)}if(Qd(u,dl))return this.buildQueryFromSourceParams(u.queryChunks,{...n,inlineParams:s||u.shouldInlineParams});if(Qd(u,ul)){let d=u[ul.Symbol.Schema],p=u[ul.Symbol.Name];return{sql:d===void 0||u[n7]?a(p):a(d)+"."+a(p),params:[]}}if(Qd(u,H1)){let d=r.getColumnCasing(u);if(t.invokeSource==="indexes")return{sql:a(d),params:[]};let p=u.table[ul.Symbol.Schema];return{sql:u.table[n7]||p===void 0?a(u.table[ul.Symbol.Name])+"."+a(d):a(p)+"."+a(u.table[ul.Symbol.Name])+"."+a(d),params:[]}}if(Qd(u,opn)){let d=u[uQ].schema,p=u[uQ].name;return{sql:d===void 0||u[uQ].isAlias?a(p):a(d)+"."+a(p),params:[]}}if(Qd(u,FPe)){if(Qd(u.value,Qoe))return{sql:i(l.value++,u),params:[u],typings:["none"]};let d=u.value===null?null:u.encoder.mapToDriverValue(u.value);if(Qd(d,dl))return this.buildQueryFromSourceParams([d],n);if(s)return{sql:this.mapInlineParam(d,n),params:[]};let p=["none"];if(o)p=[o(u.encoder)];return{sql:i(l.value++,d),params:[d],typings:p}}if(Qd(u,Qoe))return{sql:i(l.value++,u),params:[u],typings:["none"]};if(Qd(u,dl.Aliased)&&u.fieldAlias!==void 0)return{sql:a(u.fieldAlias),params:[]};if(Qd(u,t7)){if(u._.isWith)return{sql:a(u._.alias),params:[]};return this.buildQueryFromSourceParams([new tf("("),u._.sql,new tf(") "),new Roe(u._.alias)],n)}if(Kdn(u)){if(u.schema)return{sql:a(u.schema)+"."+a(u.enumName),params:[]};return{sql:a(u.enumName),params:[]}}if(FZr(u)){if(u.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([u.getSQL()],n);return this.buildQueryFromSourceParams([new tf("("),u.getSQL(),new tf(")")],n)}if(s)return{sql:this.mapInlineParam(u,n),params:[]};return{sql:i(l.value++,u),params:[u],typings:["none"]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return"null";if(typeof e==="number"||typeof e==="boolean")return e.toString();if(typeof e==="string")return t(e);if(typeof e==="object"){let n=e.toString();if(n==="[object Object]")return t(JSON.stringify(e));return t(n)}throw Error("Unexpected param value: "+e)}getSQL(){return this}as(e){if(e===void 0)return this;return new dl.Aliased(this,e)}mapWith(e){return this.decoder=typeof e==="function"?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}}class Roe{constructor(e){this.value=e}static[Mn]="Name";brand;getSQL(){return new dl([this])}}var apn={mapFromDriverValue:(e)=>e},ipn={mapToDriverValue:(e)=>e},nsc={...apn,...ipn};class FPe{constructor(e,t=ipn){this.value=e,this.encoder=t}static[Mn]="Param";brand;getSQL(){return new dl([this])}}function WA(e,...t){let n=[];if(t.length>0||e.length>0&&e[0]!=="")n.push(new tf(e[0]));for(let[r,a]of t.entries())n.push(a,new tf(e[r+1]));return new dl(n)}((e)=>{function t(){return new dl([])}e.empty=t;function n(l){return new dl(l)}e.fromList=n;function r(l){return new dl([new tf(l)])}e.raw=r;function a(l,u){let d=[];for(let[p,m]of l.entries()){if(p>0&&u!==void 0)d.push(u);d.push(m)}return new dl(d)}e.join=a;function i(l){return new Roe(l)}e.identifier=i;function o(l){return new Qoe(l)}e.placeholder=o;function s(l,u){return new FPe(l,u)}e.param=s})(WA||(WA={}));((e)=>{class t{constructor(n,r){this.sql=n,this.fieldAlias=r}static[Mn]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(dl||(dl={}));class Qoe{constructor(e){this.name=e}static[Mn]="Placeholder";getSQL(){return new dl([this])}}var PZr=Symbol.for("drizzle:IsDrizzleView");class opn{static[Mn]="View";[uQ];[PZr]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[uQ]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new dl([this])}}H1.prototype.getSQL=function(){return new dl([this])};ul.prototype.getSQL=function(){return new dl([this])};t7.prototype.getSQL=function(){return new dl([this])};function Jy(e,t){return{name:typeof e==="string"&&e.length>0?e:"",config:typeof e==="object"?e:t}}var NPe=typeof TextDecoder>"u"?null:new TextDecoder;class PPe{static[Mn]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){if(this.reference=()=>{let{name:n,columns:r,foreignColumns:a}=e();return{name:n,columns:r,foreignTable:a[0].table,foreignColumns:a}},t)this._onUpdate=t.onUpdate,this._onDelete=t.onDelete}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new spn(e,this)}}class spn{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[Mn]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map((o)=>o.name),a=n.map((o)=>o.name),i=[this.table[qm],...r,n[0].table[qm],...a];return e??`${i.join("_")}_fk`}}function $Pe(e,t){return`${e[qm]}_${t.join("_")}_unique`}class cpn{constructor(e,t){this.name=t,this.columns=e}static[Mn]="SQLiteUniqueConstraintBuilder";columns;build(e){return new lpn(e,this.columns,this.name)}}class $Zr{static[Mn]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new cpn(e,this.name)}}class lpn{constructor(e,t,n){this.table=e,this.columns=t,this.name=n??$Pe(this.table,this.columns.map((r)=>r.name))}static[Mn]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}class mu extends XO{static[Mn]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>((a,i)=>{let o=new PPe(()=>{let s=a();return{columns:[e],foreignColumns:[s]}});if(i.onUpdate)o.onUpdate(i.onUpdate);if(i.onDelete)o.onDelete(i.onDelete);return o.build(t)})(n,r))}}class Au extends H1{constructor(e,t){if(!t.uniqueName)t.uniqueName=$Pe(e,[t.name]);super(e,t);this.table=e}static[Mn]="SQLiteColumn"}class upn extends mu{static[Mn]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new dpn(e,this.config)}}class dpn extends Au{static[Mn]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString("utf8"))}return BigInt(NPe.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}}class ppn extends mu{static[Mn]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new mpn(e,this.config)}}class mpn extends Au{static[Mn]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString("utf8"))}return JSON.parse(NPe.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}}class Apn extends mu{static[Mn]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new gpn(e,this.config)}}class gpn extends Au{static[Mn]="SQLiteBlobBuffer";mapFromDriverValue(e){if(Buffer.isBuffer(e))return e;return Buffer.from(e)}getSQLType(){return"blob"}}function Loe(e,t){let{name:n,config:r}=Jy(e,t);if(r?.mode==="json")return new ppn(n);if(r?.mode==="bigint")return new upn(n);return new Apn(n)}class fpn extends mu{static[Mn]="SQLiteCustomColumnBuilder";constructor(e,t,n){super(e,"custom","SQLiteCustomColumn");this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new hpn(e,this.config)}}class hpn extends Au{static[Mn]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t);this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==="function"?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==="function"?this.mapTo(e):e}}function Moe(e){return(t,n)=>{let{name:r,config:a}=Jy(t,n);return new fpn(r,a,e)}}class Foe extends mu{static[Mn]="SQLiteBaseIntegerBuilder";constructor(e,t,n){super(e,t,n);this.config.autoIncrement=!1}primaryKey(e){if(e?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}}class Noe extends Au{static[Mn]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}}class bpn extends Foe{static[Mn]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new ypn(e,this.config)}}class ypn extends Noe{static[Mn]="SQLiteInteger"}class wpn extends Foe{static[Mn]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp");this.config.mode=t}defaultNow(){return this.default(WA`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new vpn(e,this.config)}}class vpn extends Noe{static[Mn]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){if(this.config.mode==="timestamp")return new Date(e*1000);return new Date(e)}mapToDriverValue(e){let t=e.getTime();if(this.config.mode==="timestamp")return Math.floor(t/1000);return t}}class kpn extends Foe{static[Mn]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean");this.config.mode=t}build(e){return new Cpn(e,this.config)}}class Cpn extends Noe{static[Mn]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}}function Wr(e,t){let{name:n,config:r}=Jy(e,t);if(r?.mode==="timestamp"||r?.mode==="timestamp_ms")return new wpn(n,r.mode);if(r?.mode==="boolean")return new kpn(n,r.mode);return new bpn(n)}class xpn extends mu{static[Mn]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new _pn(e,this.config)}}class _pn extends Au{static[Mn]="SQLiteNumeric";mapFromDriverValue(e){if(typeof e==="string")return e;return String(e)}getSQLType(){return"numeric"}}class Epn extends mu{static[Mn]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber")}build(e){return new Bpn(e,this.config)}}class Bpn extends Au{static[Mn]="SQLiteNumericNumber";mapFromDriverValue(e){if(typeof e==="number")return e;return Number(e)}mapToDriverValue=String;getSQLType(){return"numeric"}}class Ipn extends mu{static[Mn]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt")}build(e){return new Spn(e,this.config)}}class Spn extends Au{static[Mn]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}function Tpn(e,t){let{name:n,config:r}=Jy(e,t),a=r?.mode;return a==="number"?new Epn(n):a==="bigint"?new Ipn(n):new xpn(n)}class Dpn extends mu{static[Mn]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new Rpn(e,this.config)}}class Rpn extends Au{static[Mn]="SQLiteReal";getSQLType(){return"real"}}function Qpn(e){return new Dpn(e??"")}class Lpn extends mu{static[Mn]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText");this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new Mpn(e,this.config)}}class Mpn extends Au{static[Mn]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}}class Fpn extends mu{static[Mn]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new Npn(e,this.config)}}class Npn extends Au{static[Mn]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}function Bn(e,t={}){let{name:n,config:r}=Jy(e,t);if(r.mode==="json")return new Fpn(n);return new Lpn(n,r)}function Ppn(){return{blob:Loe,customType:Moe,integer:Wr,numeric:Tpn,real:Qpn,text:Bn}}var OPe=Symbol.for("drizzle:SQLiteInlineForeignKeys");class r7 extends ul{static[Mn]="SQLiteTable";static Symbol=Object.assign({},ul.Symbol,{InlineForeignKeys:OPe});[ul.Symbol.Columns];[OPe]=[];[ul.Symbol.ExtraConfigBuilder]=void 0}function OZr(e,t,n,r,a=e){let i=new r7(e,r,a),o=typeof t==="function"?t(Ppn()):t,s=Object.fromEntries(Object.entries(o).map(([u,d])=>{let p=d;p.setName(u);let m=p.build(i);return i[OPe].push(...p.buildForeignKeys(m,i)),[u,m]})),l=Object.assign(i,s);if(l[ul.Symbol.Columns]=s,l[ul.Symbol.ExtraConfigColumns]=s,n)l[r7.Symbol.ExtraConfigBuilder]=n;return l}var Jo=(e,t,n)=>OZr(e,t,n);class $pn{constructor(e,t){this.name=e,this.value=t}static[Mn]="SQLiteCheckBuilder";brand;build(e){return new Opn(e,this)}}class Opn{constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}static[Mn]="SQLiteCheck";name;value}function W1(e,t){return new $pn(e,t)}class zPe{constructor(e,t){this.name=e,this.unique=t}static[Mn]="SQLiteIndexBuilderOn";on(...e){return new zpn(this.name,e,this.unique)}}class zpn{static[Mn]="SQLiteIndexBuilder";config;constructor(e,t,n){this.config={name:e,columns:t,unique:n,where:void 0}}where(e){return this.config.where=e,this}build(e){return new jpn(this.config,e)}}class jpn{static[Mn]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}function qo(e){return new zPe(e,!1)}function jPe(e){return new zPe(e,!0)}function YA(...e){if(e[0].columns)return new qPe(e[0].columns,e[0].name);return new qPe(e)}class qPe{static[Mn]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new qpn(e,this.columns,this.name)}}class qpn{constructor(e,t,n){this.table=e,this.columns=t,this.name=n}static[Mn]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[r7.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}var Gpn=Jo("job_queue",{id:Bn("id").primaryKey().$defaultFn(()=>Vy()),type:Bn("type").notNull(),data:Bn("data").notNull(),result:Bn("result",{mode:"json"}),progress:Bn("progress",{mode:"json"}).$type(),source:Bn("source"),metadata:Bn("metadata",{mode:"json"}).$type().notNull(),status:Bn("status",{enum:["pending","processing","completed","failed"]}).notNull().default("pending"),priority:Wr("priority").notNull().default(0),retryCount:Wr("retryCount").notNull().default(0),maxRetries:Wr("maxRetries").notNull().default(3),lastError:Bn("lastError"),createdAt:Wr("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:Wr("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:Wr("startedAt"),completedAt:Wr("completedAt"),attemptId:Bn("attemptId"),workerSlotId:Bn("workerSlotId"),workerSessionId:Bn("workerSessionId"),leaseExpiresAt:Wr("leaseExpiresAt"),attemptHeartbeatAt:Wr("attemptHeartbeatAt"),runtimeUpdatedAt:Wr("runtimeUpdatedAt")},(e)=>({queueReadyIdx:qo("idx_job_queue_ready").on(e.status,e.priority,e.scheduledFor),jobTypeIdx:qo("idx_job_queue_type").on(e.type,e.status),runtimeUpdatesIdx:qo("idx_job_queue_runtime_updates").on(e.runtimeUpdatedAt,e.id),jobSourceIdx:qo("idx_job_queue_source").on(e.source)})),Upn=Jo("job_worker_sessions",{slotId:Bn("slotId").primaryKey(),sessionId:Bn("sessionId").notNull().unique(),startedAt:Wr("startedAt").notNull(),heartbeatAt:Wr("heartbeatAt").notNull(),expiresAt:Wr("expiresAt").notNull().default(0)},(e)=>({heartbeatIdx:qo("idx_job_worker_sessions_heartbeat").on(e.heartbeatAt),expiresIdx:qo("idx_job_worker_sessions_expires").on(e.expiresAt)}));class GPe{tails=new Map;async run(e,t){let n=this.tails.get(e),r=()=>{},a=new Promise((i)=>{r=i});this.tails.set(e,a),await n;try{return await t()}finally{if(r(),this.tails.get(e)===a)this.tails.delete(e)}}}var Icc=P.looseObject({deduplicationKey:P.string().optional()});var Ncc=new GPe;var{AsyncLocalStorage:zcc}=(()=>({}));var vlc=P.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},P.record(P.string(),P.unknown()));var xlc=P.record(P.string(),P.unknown());var YZr=P.custom((e)=>typeof e==="object"&&e!==null&&("safeParse"in e)),Glc=P.object({name:P.string(),schema:YZr});var $oe=Jo("conversations",{id:Bn("id").primaryKey(),sessionId:Bn("session_id").notNull(),interfaceType:Bn("interface_type").notNull(),channelId:Bn("channel_id").notNull(),personId:Bn("person_id"),started:Bn("started").notNull(),lastActive:Bn("last_active").notNull(),metadata:Bn("metadata"),created:Bn("created").notNull(),updated:Bn("updated").notNull()},(e)=>({sessionIdx:qo("idx_conversations_session").on(e.sessionId),channelIdx:qo("idx_conversations_channel").on(e.channelId),personIdx:qo("idx_conversations_person").on(e.personId),interfaceSessionIdx:qo("idx_conversations_interface_session").on(e.interfaceType,e.sessionId),interfaceChannelIdx:qo("idx_conversations_interface_channel").on(e.interfaceType,e.channelId)})),Ypn=Jo("messages",{id:Bn("id").primaryKey(),conversationId:Bn("conversation_id").notNull().references(()=>$oe.id,{onDelete:"cascade"}),role:Bn("role").notNull(),content:Bn("content").notNull(),timestamp:Bn("timestamp").notNull(),metadata:Bn("metadata")},(e)=>({conversationIdx:qo("idx_messages_conversation").on(e.conversationId),timestampIdx:qo("idx_messages_timestamp").on(e.timestamp)})),Vpn=Jo("summary_tracking",{conversationId:Bn("conversation_id").primaryKey().references(()=>$oe.id,{onDelete:"cascade"}),lastSummarizedAt:Bn("last_summarized_at"),lastMessageId:Bn("last_message_id"),messagesSinceSummary:Wr("messages_since_summary").default(0),updated:Bn("updated").notNull()});var euc=P.preprocess((e)=>{if(typeof e!=="string")return e;try{return JSON.parse(e)}catch{return}},P.record(P.string(),P.unknown())).catch({});var o7=P.object({identity:UA,interfaceType:P.string(),role:H8,displayName:P.string().optional(),username:P.string().optional(),isBot:P.boolean().optional()}),VZr=P.preprocess(ZZr,o7);function ZZr(e){if(!KZr(e)||"identity"in e)return e;let{actorId:t,interfaceType:n,role:r}=e;if(typeof t!=="string"||typeof n!=="string"||r!=="user"&&r!=="assistant")return e;let{userId:a,canonicalId:i}=e;return{identity:sNe({actorId:t,interfaceType:n,role:r,...typeof a==="string"?{userId:a}:{},...typeof i==="string"?{canonicalId:i}:{}}),interfaceType:n,role:r,...typeof e.displayName==="string"?{displayName:e.displayName}:{},...typeof e.username==="string"?{username:e.username}:{},...typeof e.isBot==="boolean"?{isBot:e.isBot}:{}}}var s7=P.object({messageId:P.string().optional(),channelId:P.string().optional(),channelName:P.string().optional(),threadId:P.string().optional(),metadata:P.record(P.string(),P.unknown()).optional()}),Zpn=P.looseObject({actor:VZr.optional(),source:s7.optional()});function KZr(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var JZr=P.object({id:P.string(),conversationId:P.string(),role:P.string(),content:P.string(),timestamp:P.string(),metadata:P.string().nullable()}),Kpn=P.object({conversationId:P.string(),messageCount:P.number(),messages:P.array(JZr),windowStart:P.number(),windowEnd:P.number(),windowSize:P.number(),timestamp:P.string()});var c7=P.record(P.string(),P.unknown());var tKr=P.object({id:P.string(),sessionId:P.string(),interfaceType:P.string(),channelId:P.string(),personId:P.string().optional(),channelName:P.string().optional(),startedAt:P.string(),lastActiveAt:P.string(),createdAt:P.string(),updatedAt:P.string(),metadata:c7}),nKr=P.object({id:P.string(),conversationId:P.string(),role:H8,content:P.string(),timestamp:P.string(),metadata:c7});var Xpn=P.object({name:P.string(),role:P.string(),purpose:P.string(),values:P.array(P.string())}),emn=P.object({name:P.string(),organization:P.string().optional(),description:P.string().optional(),avatar:P.string().optional(),website:P.string().optional(),email:P.string().optional(),socialLinks:P.array(P.object({platform:P.enum(["github","instagram","linkedin","email","website"]),url:P.string(),label:P.string().optional()})).optional()});var tmn=P.object({name:P.string(),description:P.string(),tags:P.array(P.string()),examples:P.array(P.string())});td();var nmn=/^[a-f0-9]{64}$/,rmn=/^asset:\/\/sha256\/([a-f0-9]{64})$/,amn="asset://sha256/";var Ooe=P.custom((e)=>typeof e==="string"&&rmn.test(e),{message:"Invalid SHA-256 asset reference"}),iKr=P.object({ref:Ooe,digest:P.string().regex(nmn),sizeBytes:P.number().int().nonnegative()}).refine((e)=>VPe(e.ref)===e.digest,{message:"Asset reference and digest must match",path:["digest"]});function YPe(e){return Ooe.parse(e)}function VPe(e){return YPe(e).slice(amn.length)}var imn=Jo("assets",{digest:Bn("digest").notNull().primaryKey(),bytes:Loe("bytes",{mode:"buffer"}).notNull(),sizeBytes:Wr("size_bytes").notNull(),created:Wr("created").notNull().$defaultFn(()=>Date.now())},(e)=>({digestLengthCheck:W1("assets_digest_length_check",WA`length(${e.digest}) = 64`),digestAlphabetCheck:W1("assets_digest_alphabet_check",WA`${e.digest} NOT GLOB '*[^0-9a-f]*'`),bytesTypeCheck:W1("assets_bytes_type_check",WA`typeof(${e.bytes}) = 'blob'`),sizeNonnegativeCheck:W1("assets_size_nonnegative_check",WA`${e.sizeBytes} >= 0`),sizeMatchesBytesCheck:W1("assets_size_matches_bytes_check",WA`length(${e.bytes}) = ${e.sizeBytes}`)}));var l7=Jo("entities",{id:Bn("id").notNull(),entityType:Bn("entityType").notNull(),content:Bn("content").notNull(),contentHash:Bn("contentHash").notNull(),visibility:Bn("visibility",{enum:["public","shared","restricted"]}).notNull().default("public"),metadata:Bn("metadata",{mode:"json"}).$type().notNull().default(WA`'{}'`),created:Wr("created").notNull().$defaultFn(()=>Date.now()),updated:Wr("updated").notNull().$defaultFn(()=>Date.now())},(e)=>({pk:YA({columns:[e.id,e.entityType]}),visibilityCheck:W1("entities_visibility_check",WA`${e.visibility} IN ('public', 'shared', 'restricted')`)}));var omn=Jo("entity_export_intents",{entityType:Bn("entity_type").notNull(),entityId:Bn("entity_id").notNull(),operation:Bn("operation",{enum:["upsert","delete"]}).notNull(),revision:Bn("revision").notNull(),markedAt:Wr("marked_at").notNull()},(e)=>({pk:YA({columns:[e.entityType,e.entityId]}),markedAtIdx:qo("entity_export_intents_marked_at_idx").on(e.markedAt)}));var smn=Jo("projection_entity_owners",{entityType:Bn("entity_type").notNull(),entityId:Bn("entity_id").notNull(),ruleId:Bn("rule_id").notNull(),ruleVersion:Bn("rule_version").notNull(),inputFingerprint:Bn("input_fingerprint").notNull(),claimedAt:Wr("claimed_at").notNull()},(e)=>({pk:YA({columns:[e.entityType,e.entityId]}),ruleIdx:qo("projection_entity_owners_rule_idx").on(e.ruleId)})),cmn=Jo("projection_dirty_inputs",{generation:Wr("generation").primaryKey({autoIncrement:!0}),sourceType:Bn("source_type").notNull(),sourceId:Bn("source_id").notNull(),revision:Bn("revision").notNull(),operation:Bn("operation",{enum:["upsert","delete"]}).notNull(),markedAt:Wr("marked_at").notNull()},(e)=>({generationIdx:qo("projection_dirty_inputs_generation_idx").on(e.generation)})),u7=Jo("projection_waves",{id:Bn("id").primaryKey(),cutoffGeneration:Wr("cutoff_generation").notNull(),graphFingerprint:Bn("graph_fingerprint").notNull(),admissionEpoch:Wr("admission_epoch").notNull().default(0),status:Bn("status",{enum:["running","completed","failed","superseded"]}).notNull(),startedAt:Wr("started_at").notNull(),completedAt:Wr("completed_at")}),lmn=Jo("projection_incidents",{waveId:Bn("wave_id").primaryKey().references(()=>u7.id,{onDelete:"cascade"}),ruleId:Bn("rule_id").notNull(),jobId:Bn("job_id"),failureReason:Bn("failure_reason").notNull(),recoveryGeneration:Wr("recovery_generation").notNull(),createdAt:Wr("created_at").notNull(),resolvedAt:Wr("resolved_at")},(e)=>({unresolvedIdx:qo("projection_incidents_unresolved_idx").on(e.resolvedAt,e.createdAt)})),umn=Jo("projection_wave_inputs",{waveId:Bn("wave_id").notNull().references(()=>u7.id,{onDelete:"cascade"}),sourceType:Bn("source_type").notNull(),sourceId:Bn("source_id").notNull(),revision:Bn("revision").notNull(),operation:Bn("operation",{enum:["upsert","delete"]}).notNull(),generation:Wr("generation").notNull()},(e)=>({pk:YA({columns:[e.waveId,e.sourceType,e.sourceId]}),generationIdx:qo("projection_wave_inputs_generation_idx").on(e.waveId,e.generation)})),dmn=Jo("projection_wave_rules",{waveId:Bn("wave_id").notNull().references(()=>u7.id,{onDelete:"cascade"}),ruleId:Bn("rule_id").notNull(),targetType:Bn("target_type").notNull(),level:Wr("level").notNull(),jobId:Bn("job_id"),status:Bn("status",{enum:["pending","queued","completed","failed"]}).notNull(),inputFingerprint:Bn("input_fingerprint"),changedTargets:Bn("changed_targets",{mode:"json"}).$type().notNull().default([])},(e)=>({pk:YA({columns:[e.waveId,e.ruleId]}),statusIdx:qo("projection_wave_rules_status_idx").on(e.waveId,e.status,e.level)})),pmn=Jo("projection_rule_memos",{ruleId:Bn("rule_id").notNull(),ruleVersion:Bn("rule_version").notNull(),inputFingerprint:Bn("input_fingerprint").notNull(),writeIntents:Bn("write_intents",{mode:"json"}).$type().notNull(),createdAt:Wr("created_at").notNull()},(e)=>({pk:YA({columns:[e.ruleId,e.ruleVersion,e.inputFingerprint]})}));var mmn=Moe({dataType(){return"F32_BLOB(1536)"},toDriver(e){return Buffer.from(e.buffer)},fromDriver(e){return new Float32Array(e.buffer,e.byteOffset,e.byteLength/4)}});var zoe=Jo("embeddings",{entityId:Bn("entity_id").notNull(),entityType:Bn("entity_type").notNull(),embedding:mmn("embedding").notNull(),contentHash:Bn("content_hash").notNull()},(e)=>({pk:YA({columns:[e.entityId,e.entityType]})}));var ipc=P.object({id:P.string().min(1,"Entity ID is required"),entityType:P.string().min(1,"Entity type is required"),contentHash:P.string().min(1,"Content hash is required"),operation:P.enum(["create","update"])});var ZPe=P.enum(["public","shared","restricted"]),Y1=P.union([ZPe,P.literal("private")]).optional().transform((e)=>{if(e===void 0)return"public";if(e==="private")return"restricted";return e});var Hv=P.object({id:P.string(),entityType:P.string(),content:P.string(),created:P.string().datetime(),updated:P.string().datetime(),visibility:Y1,metadata:P.record(P.string(),P.unknown()),contentHash:P.string()}),oKr=P.enum(["public","shared","restricted"]),hmn=P.object({id:P.string(),entityType:P.string(),content:P.string(),created:P.string().datetime(),updated:P.string().datetime(),visibility:P.union([oKr,P.literal("private")]).optional().transform((e)=>{if(e===void 0)return"public";if(e==="private")return"restricted";return e}),metadata:P.record(P.string(),P.unknown()),contentHash:P.string()}),JPe=P.object({}),sKr=P.object({mediaType:P.string(),url:P.string(),downloadUrl:P.string().optional(),previewUrl:P.string().optional(),filename:P.string().optional(),sizeBytes:P.number().optional(),source:P.object({entityType:P.string().optional(),entityId:P.string().optional(),attachmentType:P.string().optional()}).optional()});var ypc=P.object({limit:P.number().int().positive().optional().default(20),offset:P.number().int().min(0).optional().default(0),types:P.array(P.string()).optional().default([]),excludeTypes:P.array(P.string()).optional().default([]),weight:P.record(P.string(),P.number()).optional(),visibilityScope:P.enum(["public","shared","restricted"]).optional(),includeUngenerated:P.boolean().optional().default(!1),minScore:P.number().min(0).optional()}),wpc=P.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},P.record(P.string(),P.unknown()));var cKr=Fn(DNe(),1);var Cpc=P.object({visibility:P.enum(["public","shared","restricted","private"]).optional().transform((e)=>{if(e===void 0)return;return e==="private"?"restricted":e})});var Bpc=P.looseObject({issues:P.array(P.looseObject({message:P.string()}))});var Mpc=P.record(P.string(),P.unknown());var lKr=P.object({field:P.string(),direction:P.enum(["asc","desc"]),nullsFirst:P.boolean().optional()}),qpc=P.object({limit:P.number().int().positive().optional(),offset:P.number().int().min(0).optional().default(0),sortFields:P.array(lKr).optional(),filter:P.object({metadata:P.record(P.string(),P.unknown()).optional(),visibilityScope:P.enum(["public","shared","restricted"]).optional()}).optional(),publishedOnly:P.boolean().optional()});var Kpc=P.custom((e)=>typeof e==="object"&&e!==null&&!Array.isArray(e));var Jpc=P.object({id:P.string().min(1),entityType:P.string().min(1),contentHash:P.string().min(1)});var{AsyncLocalStorage:umc}=(()=>({}));var pQ=P.lazy(()=>P.union([P.null(),P.boolean(),P.number().finite().refine((e)=>!Number.isInteger(e)||Number.isSafeInteger(e),{message:"integer exceeds the JSON-safe range"}),P.string(),P.array(pQ),P.record(P.string(),pQ)])),a2=P.record(P.string(),pQ),dKr=P.strictObject({id:P.string().trim().min(1),entityType:P.string().trim().min(1),content:P.string(),metadata:a2,visibility:Y1}),d7=P.discriminatedUnion("operation",[P.strictObject({operation:P.literal("upsert"),entity:dKr}),P.strictObject({operation:P.literal("delete"),entityType:P.string().trim().min(1),id:P.string().trim().min(1)})]);var pKr=Jo("projection_admission_state",{id:Wr("id").primaryKey(),epoch:Wr("epoch").notNull().default(0)}),wmn=Jo("projection_batches",{id:Bn("id").primaryKey(),source:Bn("source").notNull(),operationId:Bn("operation_id").notNull(),status:Bn("status",{enum:["preparing","open","closed","abandoned"]}).notNull(),ownerKind:Bn("owner_kind",{enum:["callback","job-root"]}).notNull(),ownerToken:Bn("owner_token").notNull(),rootJobId:Bn("root_job_id"),expectedChildren:Wr("expected_children").notNull().default(0),enqueueComplete:Wr("enqueue_complete").notNull().default(0),enqueueFailed:Wr("enqueue_failed").notNull().default(0),openedAt:Wr("opened_at").notNull(),lastProgressAt:Wr("last_progress_at").notNull(),leaseExpiresAt:Wr("lease_expires_at"),terminalAt:Wr("terminal_at"),recoveredAt:Wr("recovered_at"),firstGeneration:Wr("first_generation"),highestGeneration:Wr("highest_generation"),mutationCount:Wr("mutation_count").notNull().default(0),recoveryGeneration:Wr("recovery_generation")},(e)=>({operationIdx:jPe("projection_batches_operation_idx").on(e.source,e.operationId),admissionIdx:qo("projection_batches_admission_idx").on(e.status,e.openedAt),rootJobIdx:qo("projection_batches_root_job_idx").on(e.rootJobId),recoveryIdx:qo("projection_batches_recovery_idx").on(e.recoveredAt,e.recoveryGeneration)})),mKr=Jo("projection_batch_children",{batchId:Bn("batch_id").notNull().references(()=>wmn.id,{onDelete:"cascade"}),childKey:Bn("child_key").notNull(),jobId:Bn("job_id"),status:Bn("status",{enum:["expected","active","completed","failed","missing"]}).notNull().default("expected"),terminalAt:Wr("terminal_at")},(e)=>({pk:YA({columns:[e.batchId,e.childKey]}),jobIdx:jPe("projection_batch_children_job_idx").on(e.jobId),statusIdx:qo("projection_batch_children_status_idx").on(e.batchId,e.status)}));var vmc=P.strictObject({sourceType:P.string().trim().min(1),sourceId:P.string().trim().min(1),revision:P.string().trim().min(1),operation:P.enum(["upsert","delete"]),markedAt:P.number().int().nonnegative()}),kmc=P.strictObject({waveId:P.string().trim().min(1),ruleId:P.string().trim().min(1),jobId:P.string().trim().min(1).nullable(),failureReason:P.string().trim().min(1).max(500),failedAt:P.number().int().nonnegative()}),Cmc=P.strictObject({ruleId:P.string().trim().min(1),ruleVersion:P.string().trim().min(1),inputFingerprint:P.string().trim().min(1)}),xmc=P.strictObject({entityType:P.string().trim().min(1),id:P.string().trim().min(1)}),_mc=P.strictObject({ruleId:P.string().trim().min(1),targetType:P.string().trim().min(1),level:P.number().int().nonnegative()}),gKr=P.strictObject({source:P.string().trim().min(1).max(100),operationId:P.string().trim().min(1).max(200)});var fKr=gKr.extend({rootJobId:P.string().trim().min(1).max(200),expectedChildren:P.number().int().positive().max(1e4)}),Emc=fKr.extend({rootJobId:P.string().trim().min(1).max(200),childKey:P.string().trim().min(1).max(200),expectedChildren:P.number().int().positive().max(1e4),jobId:P.string().trim().min(1).max(200)}),Bmc=P.strictObject({operationId:P.string().trim().min(1).max(200),childKey:P.string().trim().min(1).max(200),jobId:P.string().trim().min(1).max(200),outcome:P.enum(["completed","failed"])}),Imc=P.strictObject({entityType:P.string().trim().min(1),entityId:P.string().trim().min(1),operation:P.enum(["upsert","delete"]),contentHash:P.string().min(1).optional()});var kAc=P.record(P.string(),P.unknown());var xmn=P.object({currentPage:P.number(),totalPages:P.number(),totalItems:P.number(),pageSize:P.number(),hasNextPage:P.boolean(),hasPrevPage:P.boolean()});var $Kr=P.object({name:P.string(),description:P.string(),schema:P.any(),basePrompt:P.string().optional(),useKnowledgeContext:P.boolean().optional(),requiredPermission:P.enum(["admin","trusted","public"]),formatter:P.any().optional(),overlayFormatter:P.any().optional(),layout:P.object({component:P.any().optional(),fullscreen:P.boolean().optional()}).optional(),dataSourceId:P.string().optional()});var Bmn=P.enum(["admin","trusted","public"]),OKr=P.enum(["create","update","delete","extract","publish"]),AQ=P.enum(["never","admin","trusted","public"]),Imn=P.strictObject({create:AQ.optional(),update:AQ.optional(),delete:AQ.optional(),extract:AQ.optional(),publish:AQ.optional()}),zKr=P.record(P.string(),Imn);var jKr=P.enum(["site-content-preview","site-content-production"]),Smn=P.enum(["web","image","pdf"]),t5e=P.custom((e)=>typeof e==="function"),qKr=P.object({name:P.string(),schema:P.any(),description:P.string().optional(),pluginId:P.string(),renderers:P.object({web:P.union([t5e,P.string()]).optional(),image:P.union([t5e,P.string()]).optional(),pdf:P.union([t5e,P.string()]).optional()})}),GKr=P.object({enableContentGeneration:P.boolean().default(!1),outputDir:P.string(),workingDir:P.string().optional(),environment:P.enum(["preview","production"]).default("preview"),siteConfig:P.object({title:P.string(),description:P.string(),url:P.string().optional()}).optional()}),UKr=P.object({success:P.boolean(),routesBuilt:P.number(),errors:P.array(P.string()).optional(),warnings:P.array(P.string()).optional()});var Rmn=P.object({});var wfc=P.strictObject({id:P.string().trim().min(1),version:P.string().trim().min(1),sources:P.array(P.strictObject({kind:P.literal("entity"),types:P.array(P.string().trim().min(1)).min(1),excludeTypes:P.array(P.string().trim().min(1)).optional()})),targetType:P.string().trim().min(1),sourceChangeBatchDelayMs:P.number().int().nonnegative().default(0)});var Ofc=P.union([P.string(),P.number().finite(),P.boolean(),P.null()]);var KKr=/^[a-z][a-z0-9-]*$/,JKr=P.strictObject({source:P.string().min(1).max(500),flags:P.string().regex(/^[imu]*$/).optional()}),qfc=P.strictObject({type:P.string().trim().regex(KKr),displayName:P.string().trim().min(1).max(100),subjectLabel:P.string().trim().min(1).max(100),subjectPattern:JKr.optional(),manualDelivery:P.boolean().optional()});var Qmn=/[\s\\\p{Cc}\p{Cf}]/u;function Lmn(e){if(typeof e!=="string"||e!==e.trim()||e.length===0||e.length>2048||!e.startsWith("/")||e.startsWith("//")||Qmn.test(e))return;try{let t=new URL(e,"https://brains.invalid");if(t.origin!=="https://brains.invalid")return;let n=`${t.pathname}${t.search}${t.hash}`;return n.length>0&&n.length<=2048&&n.startsWith("/")&&!n.startsWith("//")&&!Qmn.test(n)?n:void 0}catch{return}}var XKr=/^[a-z][a-z0-9-]*$/,nf=P.string().trim().regex(XKr),Woe=P.string().trim().min(1).max(300),Mmn=P.enum(["high","normal"]),n5e=nf.max(40),r5e=nf.max(40),Fmn=P.strictObject({value:r5e,label:P.string().trim().min(1).max(100)}),Nmn=P.strictObject({key:n5e,label:P.string().trim().min(1).max(100),values:P.array(Fmn).min(1).max(20)}).superRefine((e,t)=>{let n=new Set;for(let r of e.values){if(n.has(r.value))t.addIssue({code:"custom",path:["values"],message:`Duplicate inbox facet value: ${r.value}`});n.add(r.value)}}),Pmn=P.array(Nmn).max(8).superRefine((e,t)=>{let n=new Set;for(let r of e){if(n.has(r.key))t.addIssue({code:"custom",path:[],message:`Duplicate inbox facet key: ${r.key}`});n.add(r.key)}}),$mn=P.record(n5e,r5e).refine((e)=>Object.keys(e).length<=8,{message:"Inbox items may declare at most eight facets"}),eJr=P.string().regex(/^[a-z][A-Za-z0-9]{0,39}$/),tJr=P.string().min(1).max(300).refine((e)=>!/[\p{Cc}\p{Cf}]/u.test(e),{message:"Inbox follow-up context values cannot contain controls"}),nJr=P.strictObject({kind:nf,context:P.record(eJr,tJr).refine((e)=>Object.keys(e).length<=8,{message:"Inbox follow-up context may contain at most eight entries"})}),rJr=P.array(nJr).max(8).superRefine((e,t)=>{let n=new Set;for(let r of e){if(n.has(r.kind))t.addIssue({code:"custom",path:[],message:`Duplicate inbox follow-up kind: ${r.kind}`});n.add(r.kind)}}),Omn=P.strictObject({id:nf,label:P.string().trim().min(1).max(100),confirm:P.boolean().optional()}),zmn=P.strictObject({entityType:P.string().trim().min(1).max(100),entityId:P.string().trim().min(1).max(300)}),jmn=P.strictObject({label:P.string().trim().min(1).max(300),personId:P.string().trim().min(1).max(200).optional()}),a5e=P.strictObject({id:Woe,title:P.string().trim().min(1).max(160),summary:P.string().trim().min(1).max(1000).optional(),contact:jmn.optional(),threadOrdinal:P.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),receivedAt:P.iso.datetime(),urgency:Mmn,entityRef:zmn.optional(),facets:$mn.optional(),followUps:rJr.optional(),actions:P.array(Omn).max(10)}).superRefine((e,t)=>{let n=new Set;for(let r of e.actions){if(n.has(r.id))t.addIssue({code:"custom",path:["actions"],message:`Duplicate inbox action id: ${r.id}`});n.add(r.id)}}),aJr=P.array(a5e).max(1000),qmn=P.strictObject({permissionLevel:P.enum(["admin","trusted","public"])}),iJr=P.strictObject({kind:P.literal("plain"),text:P.string().max(1e5),truncated:P.boolean()}),oJr=P.strictObject({sourceId:nf,displayName:P.string().trim().min(1).max(100)}),sJr=P.strictObject({sourceId:nf,displayName:P.string().trim().min(1).max(100),facets:Pmn.optional()});var cJr=2048,lJr=8192,Jfc=P.strictObject({kind:nf,label:P.string().trim().min(1).max(100),priority:P.number().int().min(0).max(1000),mode:P.enum(["universal","declared"]),permissionLevel:P.enum(["admin","trusted","public"]),contextSchema:P.custom((e)=>typeof e==="object"&&e!==null&&("safeParse"in e)&&typeof e.safeParse==="function").optional(),applies:P.custom((e)=>typeof e==="function"),resolve:P.custom((e)=>typeof e==="function")}).superRefine((e,t)=>{if(e.mode==="declared"&&e.contextSchema===void 0)t.addIssue({code:"custom",path:["contextSchema"],message:"Declared inbox follow-up kinds require a context schema"});if(e.mode==="universal"&&e.contextSchema!==void 0)t.addIssue({code:"custom",path:["contextSchema"],message:"Universal inbox follow-up kinds cannot accept context"})}),Xfc=P.strictObject({href:P.string(),state:P.unknown().optional()}),uJr=P.record(P.string(),P.json()).refine((e)=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=lJr,{message:"Inbox follow-up state is too large"}),dJr=P.strictObject({kind:nf,label:P.string().trim().min(1).max(100),href:P.string().min(1).max(cJr).refine((e)=>Lmn(e)===e),state:uJr.optional()});var{mkdir:chc,readdir:lhc,readFile:uhc,rm:dhc,stat:phc,writeFile:mhc}=(()=>({}));function Xy(e){if(typeof e!=="string")throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function Gmn(e,t){var n="",r=0,a=-1,i=0,o;for(var s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(a===s-1||i===1);else if(a!==s-1&&i===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){var l=n.lastIndexOf("/");if(l!==n.length-1){if(l===-1)n="",r=0;else n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/");a=s,i=0;continue}}else if(n.length===2||n.length===1){n="",r=0,a=s,i=0;continue}}if(t){if(n.length>0)n+="/..";else n="..";r=2}}else{if(n.length>0)n+="/"+e.slice(a+1,s);else n=e.slice(a+1,s);r=s-a-1}a=s,i=0}else if(o===46&&i!==-1)++i;else i=-1}return n}function pJr(e,t){var n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");if(!n)return r;if(n===t.root)return n+r;return n+e+r}function i5e(){var e="",t=!1,n;for(var r=arguments.length-1;r>=-1&&!t;r--){var a;if(r>=0)a=arguments[r];else{if(n===void 0)n=process.cwd();a=n}if(Xy(a),a.length===0)continue;e=a+"/"+e,t=a.charCodeAt(0)===47}if(e=Gmn(e,!t),t)if(e.length>0)return"/"+e;else return"/";else if(e.length>0)return e;else return"."}function Umn(e){if(Xy(e),e.length===0)return".";var t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;if(e=Gmn(e,!t),e.length===0&&!t)e=".";if(e.length>0&&n)e+="/";if(t)return"/"+e;return e}function mJr(e){return Xy(e),e.length>0&&e.charCodeAt(0)===47}function Hmn(){if(arguments.length===0)return".";var e;for(var t=0;t<arguments.length;++t){var n=arguments[t];if(Xy(n),n.length>0)if(e===void 0)e=n;else e+="/"+n}if(e===void 0)return".";return Umn(e)}function AJr(e,t){if(Xy(e),Xy(t),e===t)return"";if(e=i5e(e),t=i5e(t),e===t)return"";var n=1;for(;n<e.length;++n)if(e.charCodeAt(n)!==47)break;var r=e.length,a=r-n,i=1;for(;i<t.length;++i)if(t.charCodeAt(i)!==47)break;var o=t.length,s=o-i,l=a<s?a:s,u=-1,d=0;for(;d<=l;++d){if(d===l){if(s>l){if(t.charCodeAt(i+d)===47)return t.slice(i+d+1);else if(d===0)return t.slice(i+d)}else if(a>l){if(e.charCodeAt(n+d)===47)u=d;else if(d===0)u=0}break}var p=e.charCodeAt(n+d),m=t.charCodeAt(i+d);if(p!==m)break;else if(p===47)u=d}var A="";for(d=n+u+1;d<=r;++d)if(d===r||e.charCodeAt(d)===47)if(A.length===0)A+="..";else A+="/..";if(A.length>0)return A+t.slice(i+u);else{if(i+=u,t.charCodeAt(i)===47)++i;return t.slice(i)}}function gJr(e){return e}function Wmn(e){if(Xy(e),e.length===0)return".";var t=e.charCodeAt(0),n=t===47,r=-1,a=!0;for(var i=e.length-1;i>=1;--i)if(t=e.charCodeAt(i),t===47){if(!a){r=i;break}}else a=!1;if(r===-1)return n?"/":".";if(n&&r===1)return"//";return e.slice(0,r)}function Ymn(e,t){if(t!==void 0&&typeof t!=="string")throw TypeError('"ext" argument must be a string');Xy(e);var n=0,r=-1,a=!0,i;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var o=t.length-1,s=-1;for(i=e.length-1;i>=0;--i){var l=e.charCodeAt(i);if(l===47){if(!a){n=i+1;break}}else{if(s===-1)a=!1,s=i+1;if(o>=0)if(l===t.charCodeAt(o)){if(--o===-1)r=i}else o=-1,r=s}}if(n===r)r=s;else if(r===-1)r=e.length;return e.slice(n,r)}else{for(i=e.length-1;i>=0;--i)if(e.charCodeAt(i)===47){if(!a){n=i+1;break}}else if(r===-1)a=!1,r=i+1;if(r===-1)return"";return e.slice(n,r)}}function fJr(e){Xy(e);var t=-1,n=0,r=-1,a=!0,i=0;for(var o=e.length-1;o>=0;--o){var s=e.charCodeAt(o);if(s===47){if(!a){n=o+1;break}continue}if(r===-1)a=!1,r=o+1;if(s===46){if(t===-1)t=o;else if(i!==1)i=1}else if(t!==-1)i=-1}if(t===-1||r===-1||i===0||i===1&&t===r-1&&t===n+1)return"";return e.slice(t,r)}function hJr(e){if(e===null||typeof e!=="object")throw TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return pJr("/",e)}function bJr(e){Xy(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var n=e.charCodeAt(0),r=n===47,a;if(r)t.root="/",a=1;else a=0;var i=-1,o=0,s=-1,l=!0,u=e.length-1,d=0;for(;u>=a;--u){if(n=e.charCodeAt(u),n===47){if(!l){o=u+1;break}continue}if(s===-1)l=!1,s=u+1;if(n===46){if(i===-1)i=u;else if(d!==1)d=1}else if(i!==-1)d=-1}if(i===-1||s===-1||d===0||d===1&&i===s-1&&i===o+1){if(s!==-1)if(o===0&&r)t.base=t.name=e.slice(1,s);else t.base=t.name=e.slice(o,s)}else{if(o===0&&r)t.name=e.slice(1,i),t.base=e.slice(1,s);else t.name=e.slice(o,i),t.base=e.slice(o,s);t.ext=e.slice(i,s)}if(o>0)t.dir=e.slice(0,o-1);else if(r)t.dir="/";return t}var yJr="/",wJr=":",ihc=((e)=>(e.posix=e,e))({resolve:i5e,normalize:Umn,isAbsolute:mJr,join:Hmn,relative:AJr,_makeLong:gJr,dirname:Wmn,basename:Ymn,extname:fJr,format:hJr,parse:bJr,sep:yJr,delimiter:wJr,win32:null,posix:null});var o5e=/^upload-[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;var fhc=P.object({id:P.string().regex(o5e),ref:P.object({kind:P.string().min(1),id:P.string().regex(o5e)}),filename:P.string().min(1),mediaType:P.string().min(1),sizeBytes:P.number().nonnegative(),createdAt:P.string().datetime(),metadata:P.record(P.string(),P.unknown()).optional()});var _hc=P.record(P.string(),P.unknown()),Ehc=P.object({items:P.array(P.object({operation:P.enum(["upsert","delete"]),id:P.string(),source:a2.optional()}))});var Rhc=P.object({});var{AsyncLocalStorage:gwc}=(()=>({}));var{create:CJr,defineProperty:Yoe,getOwnPropertyDescriptor:xJr,getOwnPropertyNames:_Jr,getPrototypeOf:EJr}=Object,BJr=Object.prototype.hasOwnProperty,Vmn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Zmn=(e,t)=>{let n={};for(var r in e)Yoe(n,r,{get:e[r],enumerable:!0});if(t)Yoe(n,Symbol.toStringTag,{value:"Module"});return n},IJr=(e,t,n,r)=>{if(t&&typeof t==="object"||typeof t==="function"){for(var a=_Jr(t),i=0,o=a.length,s;i<o;i++)if(s=a[i],!BJr.call(e,s)&&s!==n)Yoe(e,s,{get:((l)=>t[l]).bind(null,s),enumerable:!(r=xJr(t,s))||r.enumerable})}return e},Kmn=(e,t,n)=>(n=e!=null?CJr(EJr(e)):{},IJr(t||!e||!e.__esModule?Yoe(n,"default",{value:e,enumerable:!0}):n,e));var SJr=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Jmn=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),TJr=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),DJr=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function Xmn(e){return typeof e==="string"&&Jmn.has(e.replace(/#$/,""))}function eAn(e,t){if(!("$schema"in e)||typeof e.$schema!=="string")return"2020-12";let n=e.$schema.replace(/#$/,"");if(SJr.has(n))return"2020-12";if(Jmn.has(n))return"2019-09";if(TJr.has(n)||DJr.has(n))return"draft-7";throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var o2="2025-11-25";var Voe=[o2,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Zoe="io.modelcontextprotocol/related-task",s2="io.modelcontextprotocol/protocolVersion",fQ="io.modelcontextprotocol/clientInfo",Yv="io.modelcontextprotocol/serverInfo",Vv="io.modelcontextprotocol/clientCapabilities",p7="io.modelcontextprotocol/subscriptionId",Z1="io.modelcontextprotocol/logLevel";var c2="2.0";var V1=Yk(()=>lr([Ge(),kn(),ir(),db(),nr(Ge(),V1),Wt(V1)])),bc=nr(Ge(),V1),l5e=Wt(V1),m7=lr([Ge(),kn().int()]),A7=Ge(),Koe=St({ttl:kn().optional()}),Joe=St({taskId:Ge()}),g7=$r({progressToken:m7.optional(),[Zoe]:Joe.optional()}),fu=St({_meta:g7.optional()}),l2=fu.extend({task:Koe.optional()}),yc=St({method:Ge(),params:fu.loose().optional()}),Ld=St({_meta:g7.optional()}),Md=St({method:Ge(),params:Ld.loose().optional()}),f7=$r({get[Yv](){return yQ.optional().catch(void 0)}}),wc=$r({_meta:f7.optional()}),K1=lr([Ge(),kn().int()]),h7=St({jsonrpc:Vt(c2),id:K1,...yc.shape}).strict(),b7=St({jsonrpc:Vt(c2),...Md.shape}).strict(),hQ=St({jsonrpc:Vt(c2),id:K1,result:wc}).strict(),bQ=St({jsonrpc:Vt(c2),id:K1.optional(),error:St({code:kn().int(),message:Ge(),data:Er().optional()})}).strict(),Xoe=lr([h7,b7,hQ,bQ]),u5e=lr([hQ,bQ]),y7=wc.strict(),ese=Ld.extend({requestId:K1.optional(),reason:Ge().optional()}),w7=Md.extend({method:Vt("notifications/cancelled"),params:ese}),tse=St({src:Ge(),mimeType:Ge().optional(),sizes:Wt(Ge()).optional(),theme:ca(["light","dark"]).optional()}),J1=St({icons:Wt(tse).optional()}),Wv=St({name:Ge(),title:Ge().optional()}),yQ=Wv.extend({...Wv.shape,...J1.shape,version:Ge(),websiteUrl:Ge().optional(),description:Ge().optional()}),RJr=hf(St({applyDefaults:ir().optional()}),bc),QJr=D0((e)=>{if(e&&typeof e==="object"&&!Array.isArray(e)&&Object.keys(e).length===0)return{form:{}};return e},hf(St({form:RJr.optional(),url:bc.optional()}),bc.optional())),nse=$r({list:bc.optional(),cancel:bc.optional(),requests:$r({sampling:$r({createMessage:bc.optional()}).optional(),elicitation:$r({create:bc.optional()}).optional()}).optional()}),rse=$r({list:bc.optional(),cancel:bc.optional(),requests:$r({tools:$r({call:bc.optional()}).optional()}).optional()}),ase=St({experimental:nr(Ge(),bc).optional(),sampling:St({context:bc.optional(),tools:bc.optional()}).optional(),elicitation:QJr.optional(),roots:St({listChanged:ir().optional()}).optional(),tasks:nse.optional(),extensions:nr(Ge(),bc).optional()}),ise=fu.extend({protocolVersion:Ge(),capabilities:ase,clientInfo:yQ}),ose=yc.extend({method:Vt("initialize"),params:ise}),v7=St({experimental:nr(Ge(),bc).optional(),logging:bc.optional(),completions:bc.optional(),prompts:St({listChanged:ir().optional()}).optional(),resources:St({subscribe:ir().optional(),listChanged:ir().optional()}).optional(),tools:St({listChanged:ir().optional()}).optional(),tasks:rse.optional(),extensions:nr(Ge(),bc).optional()}),sse=wc.extend({protocolVersion:Ge(),capabilities:v7,serverInfo:yQ,instructions:Ge().optional()}),cse=Md.extend({method:Vt("notifications/initialized"),params:Ld.optional()}),lse=yc.extend({method:Vt("server/discover"),params:fu.optional()}),use=wc.extend({supportedVersions:Wt(Ge()),capabilities:v7,instructions:Ge().optional()}),k7=yc.extend({method:Vt("ping"),params:fu.optional()}),dse=St({progress:kn(),total:Br(kn()),message:Br(Ge())}),pse=St({...Ld.shape,...dse.shape,progressToken:m7}),C7=Md.extend({method:Vt("notifications/progress"),params:pse}),mse=fu.extend({cursor:A7.optional()}),X1=yc.extend({params:mse.optional()}),e_=wc.extend({nextCursor:A7.optional()}),x7=St({uri:Ge(),mimeType:Br(Ge()),_meta:nr(Ge(),Er()).optional()}),_7=x7.extend({text:Ge()}),d5e=Ge().refine((e)=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),E7=x7.extend({blob:d5e}),t_=ca(["user","assistant"]),Zv=St({audience:Wt(t_).optional(),priority:kn().min(0).max(1).optional(),lastModified:cA.datetime({offset:!0}).optional()}),B7=St({...Wv.shape,...J1.shape,uri:Ge(),description:Br(Ge()),mimeType:Br(Ge()),size:Br(kn()),annotations:Zv.optional(),_meta:Br($r({}))}),Ase=St({...Wv.shape,...J1.shape,uriTemplate:Ge(),description:Br(Ge()),mimeType:Br(Ge()),annotations:Zv.optional(),_meta:Br($r({}))}),gse=X1.extend({method:Vt("resources/list")}),fse=e_.extend({resources:Wt(B7)}),hse=X1.extend({method:Vt("resources/templates/list")}),bse=e_.extend({resourceTemplates:Wt(Ase)}),wQ=fu.extend({uri:Ge()}),yse=wQ,wse=yc.extend({method:Vt("resources/read"),params:yse}),vse=wc.extend({contents:Wt(lr([_7,E7]))}),kse=Md.extend({method:Vt("notifications/resources/list_changed"),params:Ld.optional()}),Cse=wQ,xse=yc.extend({method:Vt("resources/subscribe"),params:Cse}),_se=wQ,Ese=yc.extend({method:Vt("resources/unsubscribe"),params:_se}),I7=St({toolsListChanged:ir().optional(),promptsListChanged:ir().optional(),resourcesListChanged:ir().optional(),resourceSubscriptions:Wt(Ge()).optional()}),Bse=fu.extend({notifications:I7}),Ise=yc.extend({method:Vt("subscriptions/listen"),params:Bse}),Sse=Ld.extend({notifications:I7}),Tse=Md.extend({method:Vt("notifications/subscriptions/acknowledged"),params:Sse}),Dse=f7.extend({[p7]:K1}),Rse=wc.extend({_meta:Dse}),Qse=Ld.extend({uri:Ge()}),Lse=Md.extend({method:Vt("notifications/resources/updated"),params:Qse}),Mse=St({name:Ge(),description:Br(Ge()),required:Br(ir())}),Fse=St({...Wv.shape,...J1.shape,description:Br(Ge()),arguments:Br(Wt(Mse)),_meta:Br($r({}))}),Nse=X1.extend({method:Vt("prompts/list")}),Pse=e_.extend({prompts:Wt(Fse)}),$se=fu.extend({name:Ge(),arguments:nr(Ge(),Ge()).optional()}),Ose=yc.extend({method:Vt("prompts/get"),params:$se}),vQ=St({type:Vt("text"),text:Ge(),annotations:Zv.optional(),_meta:nr(Ge(),Er()).optional()}),kQ=St({type:Vt("image"),data:d5e,mimeType:Ge(),annotations:Zv.optional(),_meta:nr(Ge(),Er()).optional()}),CQ=St({type:Vt("audio"),data:d5e,mimeType:Ge(),annotations:Zv.optional(),_meta:nr(Ge(),Er()).optional()}),zse=St({type:Vt("tool_use"),name:Ge(),id:Ge(),input:nr(Ge(),Er()),_meta:nr(Ge(),Er()).optional()}),jse=St({type:Vt("resource"),resource:lr([_7,E7]),annotations:Zv.optional(),_meta:nr(Ge(),Er()).optional()}),qse=B7.extend({type:Vt("resource_link")}),xQ=lr([vQ,kQ,CQ,qse,jse]),Gse=St({role:t_,content:xQ}),Use=wc.extend({description:Ge().optional(),messages:Wt(Gse)}),Hse=Md.extend({method:Vt("notifications/prompts/list_changed"),params:Ld.optional()}),Wse=St({title:Ge().optional(),readOnlyHint:ir().optional(),destructiveHint:ir().optional(),idempotentHint:ir().optional(),openWorldHint:ir().optional()}),Yse=St({taskSupport:ca(["required","optional","forbidden"]).optional()}),S7=St({...Wv.shape,...J1.shape,description:Ge().optional(),inputSchema:St({type:Vt("object"),properties:nr(Ge(),V1).optional(),required:Wt(Ge()).optional()}).catchall(Er()),outputSchema:$r({$schema:Ge().optional()}).optional(),annotations:Wse.optional(),execution:Yse.optional(),_meta:nr(Ge(),Er()).optional()}),Vse=X1.extend({method:Vt("tools/list")}),Zse=e_.extend({tools:Wt(S7)}),T7=wc.extend({content:Wt(xQ).default([]),structuredContent:Er().optional(),isError:ir().optional()}),p5e=T7.or(wc.extend({toolResult:Er()})),Kse=l2.extend({name:Ge(),arguments:nr(Ge(),Er()).optional()}),Jse=yc.extend({method:Vt("tools/call"),params:Kse}),Xse=Md.extend({method:Vt("notifications/tools/list_changed"),params:Ld.optional()}),m5e=St({autoRefresh:ir().default(!0),debounceMs:kn().int().nonnegative().default(300)}),n_=ca(["debug","info","notice","warning","error","critical","alert","emergency"]),ece=fu.extend({level:n_}),tce=yc.extend({method:Vt("logging/setLevel"),params:ece}),nce=Ld.extend({level:n_,logger:Ge().optional(),data:Er()}),rce=Md.extend({method:Vt("notifications/message"),params:nce}),ace=St({name:Ge().optional()}),ice=St({hints:Wt(ace).optional(),costPriority:kn().min(0).max(1).optional(),speedPriority:kn().min(0).max(1).optional(),intelligencePriority:kn().min(0).max(1).optional()}),oce=St({mode:ca(["auto","required","none"]).optional()}),sce=St({type:Vt("tool_result"),toolUseId:Ge().describe("The unique identifier for the corresponding tool call."),content:Wt(xQ),structuredContent:Er().optional(),isError:ir().optional(),_meta:nr(Ge(),Er()).optional()}),cce=Wk("type",[vQ,kQ,CQ]),i2=Wk("type",[vQ,kQ,CQ,zse,sce]),lce=St({role:t_,content:lr([i2,Wt(i2)]),_meta:nr(Ge(),Er()).optional()}),uce=l2.extend({messages:Wt(lce),modelPreferences:ice.optional(),systemPrompt:Ge().optional(),includeContext:ca(["none","thisServer","allServers"]).optional(),temperature:kn().optional(),maxTokens:kn().int(),stopSequences:Wt(Ge()).optional(),metadata:bc.optional(),tools:Wt(S7).optional(),toolChoice:oce.optional()}),dce=yc.extend({method:Vt("sampling/createMessage"),params:uce}),pce=wc.extend({model:Ge(),stopReason:Br(ca(["endTurn","stopSequence","maxTokens"]).or(Ge())),role:t_,content:cce}),mce=wc.extend({model:Ge(),stopReason:Br(ca(["endTurn","stopSequence","maxTokens","toolUse"]).or(Ge())),role:t_,content:lr([i2,Wt(i2)])}),D7=St({type:Vt("boolean"),title:Ge().optional(),description:Ge().optional(),default:ir().optional()}),_Q=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),minLength:kn().optional(),maxLength:kn().optional(),format:ca(["email","uri","date","date-time"]).optional(),default:Ge().optional()}),EQ=St({type:ca(["number","integer"]),title:Ge().optional(),description:Ge().optional(),minimum:kn().optional(),maximum:kn().optional(),default:kn().optional()}),R7=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),enum:Wt(Ge()),default:Ge().optional()}),Q7=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),oneOf:Wt(St({const:Ge(),title:Ge()})),default:Ge().optional()}),L7=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),enum:Wt(Ge()),enumNames:Wt(Ge()).optional(),default:Ge().optional()}),Ace=lr([R7,Q7]),M7=St({type:Vt("array"),title:Ge().optional(),description:Ge().optional(),minItems:kn().optional(),maxItems:kn().optional(),items:St({type:Vt("string"),enum:Wt(Ge())}),default:Wt(Ge()).optional()}),F7=St({type:Vt("array"),title:Ge().optional(),description:Ge().optional(),minItems:kn().optional(),maxItems:kn().optional(),items:St({anyOf:Wt(St({const:Ge(),title:Ge()}))}),default:Wt(Ge()).optional()}),gce=lr([M7,F7]),fce=lr([L7,Ace,gce]),N7=lr([fce,D7,_Q,EQ]),BQ=l2.extend({mode:Vt("form").optional(),message:Ge(),requestedSchema:St({type:Vt("object"),properties:nr(Ge(),N7),required:Wt(Ge()).optional()}).catchall(Er())}),hce=l2.extend({mode:Vt("url"),message:Ge(),elicitationId:Ge(),url:Ge().url()}),bce=lr([BQ,hce]),yce=yc.extend({method:Vt("elicitation/create"),params:bce}),wce=Ld.extend({elicitationId:Ge()}),vce=Md.extend({method:Vt("notifications/elicitation/complete"),params:wce}),kce=wc.extend({action:ca(["accept","decline","cancel"]),content:D0((e)=>e===null?void 0:e,nr(Ge(),lr([Ge(),kn(),ir(),Wt(Ge())])).optional())}),Cce=St({type:Vt("ref/resource"),uri:Ge()}),xce=St({type:Vt("ref/prompt"),name:Ge()}),_ce=fu.extend({ref:lr([xce,Cce]),argument:St({name:Ge(),value:Ge()}),context:St({arguments:nr(Ge(),Ge()).optional()}).optional()}),Ece=yc.extend({method:Vt("completion/complete"),params:_ce}),Bce=wc.extend({completion:$r({values:Wt(Ge()).max(100),total:Br(kn().int()),hasMore:Br(ir())})}),Ice=St({uri:Ge().startsWith("file://"),name:Ge().optional(),_meta:nr(Ge(),Er()).optional()}),Sce=yc.extend({method:Vt("roots/list"),params:fu.optional()}),Tce=wc.extend({roots:Wt(Ice)}),Dce=Md.extend({method:Vt("notifications/roots/list_changed"),params:Ld.optional()}),A5e=$r({ttl:kn().optional(),pollInterval:kn().optional()}),Rce=ca(["working","input_required","completed","failed","cancelled"]),r_=St({taskId:Ge(),status:Rce,ttl:lr([kn(),db()]),createdAt:Ge(),lastUpdatedAt:Ge(),pollInterval:Br(kn()),statusMessage:Br(Ge())}),g5e=wc.extend({task:r_}),Qce=Ld.merge(r_),f5e=Md.extend({method:Vt("notifications/tasks/status"),params:Qce}),h5e=yc.extend({method:Vt("tasks/get"),params:fu.extend({taskId:Ge()})}),b5e=wc.merge(r_),y5e=yc.extend({method:Vt("tasks/result"),params:fu.extend({taskId:Ge()})}),w5e=wc.loose(),v5e=X1.extend({method:Vt("tasks/list")}),k5e=e_.extend({tasks:Wt(r_)}),C5e=yc.extend({method:Vt("tasks/cancel"),params:fu.extend({taskId:Ge()})}),x5e=wc.merge(r_),_5e=lr([k7,ose,lse,Ece,tce,Ose,Nse,gse,hse,wse,xse,Ese,Ise,Jse,Vse]),E5e=lr([w7,C7,cse,Dce]),B5e=lr([y7,pce,mce,kce,Tce]),I5e=lr([k7,dce,yce,Sce]),S5e=lr([w7,C7,rce,Lse,kse,Xse,Hse,Tse,vce]),T5e=lr([y7,sse,use,Bce,Use,Pse,fse,bse,vse,T7,Zse,Rse]),gu=UT().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Rbe.custom,message:"URL must be parseable",fatal:!0}),dL}).refine((e)=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),D5e=$r({resource:Ge().url(),authorization_servers:Wt(gu).optional(),jwks_uri:Ge().url().optional(),scopes_supported:Wt(Ge()).optional(),bearer_methods_supported:Wt(Ge()).optional(),resource_signing_alg_values_supported:Wt(Ge()).optional(),resource_name:Ge().optional(),resource_documentation:Ge().optional(),resource_policy_uri:Ge().url().optional(),resource_tos_uri:Ge().url().optional(),tls_client_certificate_bound_access_tokens:ir().optional(),authorization_details_types_supported:Wt(Ge()).optional(),dpop_signing_alg_values_supported:Wt(Ge()).optional(),dpop_bound_access_tokens_required:ir().optional()}),Lce=$r({issuer:Ge(),authorization_endpoint:gu,token_endpoint:gu,registration_endpoint:gu.optional(),scopes_supported:Wt(Ge()).optional(),response_types_supported:Wt(Ge()),response_modes_supported:Wt(Ge()).optional(),grant_types_supported:Wt(Ge()).optional(),token_endpoint_auth_methods_supported:Wt(Ge()).optional(),token_endpoint_auth_signing_alg_values_supported:Wt(Ge()).optional(),service_documentation:gu.optional(),revocation_endpoint:gu.optional(),revocation_endpoint_auth_methods_supported:Wt(Ge()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Wt(Ge()).optional(),introspection_endpoint:Ge().optional(),introspection_endpoint_auth_methods_supported:Wt(Ge()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Wt(Ge()).optional(),code_challenge_methods_supported:Wt(Ge()).optional(),client_id_metadata_document_supported:ir().optional(),authorization_response_iss_parameter_supported:ir().optional().catch(void 0)}),Mce=$r({issuer:Ge(),authorization_endpoint:gu,token_endpoint:gu,userinfo_endpoint:gu.optional(),jwks_uri:gu,registration_endpoint:gu.optional(),scopes_supported:Wt(Ge()).optional(),response_types_supported:Wt(Ge()),response_modes_supported:Wt(Ge()).optional(),grant_types_supported:Wt(Ge()).optional(),acr_values_supported:Wt(Ge()).optional(),subject_types_supported:Wt(Ge()),id_token_signing_alg_values_supported:Wt(Ge()),id_token_encryption_alg_values_supported:Wt(Ge()).optional(),id_token_encryption_enc_values_supported:Wt(Ge()).optional(),userinfo_signing_alg_values_supported:Wt(Ge()).optional(),userinfo_encryption_alg_values_supported:Wt(Ge()).optional(),userinfo_encryption_enc_values_supported:Wt(Ge()).optional(),request_object_signing_alg_values_supported:Wt(Ge()).optional(),request_object_encryption_alg_values_supported:Wt(Ge()).optional(),request_object_encryption_enc_values_supported:Wt(Ge()).optional(),token_endpoint_auth_methods_supported:Wt(Ge()).optional(),token_endpoint_auth_signing_alg_values_supported:Wt(Ge()).optional(),display_values_supported:Wt(Ge()).optional(),claim_types_supported:Wt(Ge()).optional(),claims_supported:Wt(Ge()).optional(),service_documentation:Ge().optional(),claims_locales_supported:Wt(Ge()).optional(),ui_locales_supported:Wt(Ge()).optional(),claims_parameter_supported:ir().optional(),request_parameter_supported:ir().optional(),request_uri_parameter_supported:ir().optional(),require_request_uri_registration:ir().optional(),op_policy_uri:gu.optional(),op_tos_uri:gu.optional(),client_id_metadata_document_supported:ir().optional(),authorization_response_iss_parameter_supported:ir().optional().catch(void 0)}),R5e=St({...Mce.shape,...Lce.pick({code_challenge_methods_supported:!0}).shape}),Q5e=St({access_token:Ge(),id_token:Ge().optional(),token_type:Ge(),expires_in:WL.number().optional(),scope:Ge().optional(),refresh_token:Ge().optional()}).strip(),L5e=St({issued_token_type:Vt("urn:ietf:params:oauth:token-type:id-jag"),access_token:Ge(),token_type:Ge().optional(),expires_in:kn().optional(),scope:Ge().optional()}).strip(),M5e=St({error:Ge(),error_description:Ge().optional(),error_uri:Ge().optional()}),c5e=gu.optional().or(Vt("").transform(()=>{return})),Fce=St({redirect_uris:Wt(gu),token_endpoint_auth_method:Ge().optional(),grant_types:Wt(Ge()).optional(),response_types:Wt(Ge()).optional(),application_type:Ge().optional(),client_name:Ge().optional(),client_uri:gu.optional(),logo_uri:c5e,scope:Ge().optional(),contacts:Wt(Ge()).optional(),tos_uri:c5e,policy_uri:Ge().optional(),jwks_uri:gu.optional(),jwks:jG().optional(),software_id:Ge().optional(),software_version:Ge().optional(),software_statement:Ge().optional()}).strip(),Nce=St({client_id:Ge(),client_secret:Ge().optional(),client_id_issued_at:kn().optional(),client_secret_expires_at:kn().optional()}).strip(),F5e=Fce.merge(Nce),N5e=St({error:Ge(),error_description:Ge().optional()}).strip(),P5e=St({token:Ge(),token_type_hint:Ge().optional()}).strip();var j5e=Symbol.for("mcp.sdk.errorBrands");function Y5e(e,t){let n=new Set,r=t;while(typeof r==="function"){let a=r.mcpBrand;if(Object.prototype.hasOwnProperty.call(r,"mcpBrand")&&typeof a==="string")n.add(a);r=Object.getPrototypeOf(r)}if(n.size===0)return;Object.defineProperty(e,j5e,{value:n,enumerable:!1,configurable:!0})}function SQ(e,t){try{if(typeof t==="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand==="string"&&Object.prototype.hasOwnProperty.call(t,j5e)){let n=t[j5e];if(n&&typeof n.has==="function"&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var LJr=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return SQ(this,t)}static isInstance(t){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return SQ(this,t)}constructor(t,n,r){super(n);this.code=t,this.errorUri=r,this.name="OAuthError",Y5e(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};if(this.errorUri)t.error_uri=this.errorUri;return t}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}},oi=function(e){return e.NotConnected="NOT_CONNECTED",e.AlreadyConnected="ALREADY_CONNECTED",e.NotInitialized="NOT_INITIALIZED",e.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",e.RequestTimeout="REQUEST_TIMEOUT",e.ConnectionClosed="CONNECTION_CLOSED",e.SendFailed="SEND_FAILED",e.InvalidResult="INVALID_RESULT",e.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",e.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",e.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",e.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",e.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",e.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",e.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",e.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",e.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",e.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",e.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",e}({}),$a=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return SQ(this,e)}static isInstance(e){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return SQ(this,e)}constructor(e,t,n){super(t);this.code=e,this.data=n,this.name="SdkError",Y5e(this,new.target)}},MJr=class extends $a{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,n){super(e,t,n);this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};function uAn(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function FJr(e,t,n){return e==="elicitation"&&t==="form"&&n.form===void 0&&n.url===void 0}function vAn(e){switch(e.method){case"elicitation/create":if(e.params?.mode==="url")return{elicitation:{url:{}}};return{elicitation:{form:{}}};case"sampling/createMessage":{let t=e.params;if(t!==void 0&&(t.tools!==void 0||t.toolChoice!==void 0))return{sampling:{tools:{}}};return{sampling:{}}}case"roots/list":return{roots:{}};default:return}}function Gce(e,t){let n={};for(let[r,a]of Object.entries(e)){if(a===void 0)continue;let i=t===void 0?void 0:t[r];if(i===void 0){n[r]=a;continue}if(uAn(a)&&uAn(i)){let o={};for(let[s,l]of Object.entries(a))if(l!==void 0&&i[s]===void 0&&!FJr(r,s,i))o[s]=l;if(Object.keys(o).length>0)n[r]=o}}return Object.keys(n).length>0?n:void 0}var NJr="2026-07-28";function q7(e){return e>=NJr}function kAn(e){return e.filter((t)=>!q7(t))}function V5e(e){return e.filter((t)=>q7(t))}function CAn(e){let t=e.structuredContent;if(t===void 0)return e;if(!(typeof t!=="object"||t===null||Array.isArray(t)))return e;if(e.content?.some((n)=>n.type==="text")??!1)return e;return{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}var xAn=["task","inputRequests","requestState"];function Z5e(e){if(e===null||typeof e!=="object"||Array.isArray(e)||e.content!==void 0||xAn.some((t)=>(t in e)))return e;return{...e,content:[]}}function PJr(){let e=Yk(()=>lr([Ge(),kn(),ir(),db(),nr(Ge(),e),Wt(e)])),t=nr(Ge(),e),n=lr([Ge(),kn().int()]),r=Ge(),a=St({ttl:kn().optional()}),i=St({taskId:Ge()}),o=$r({progressToken:n.optional(),"io.modelcontextprotocol/related-task":i.optional()}),s=St({_meta:o.optional()}),l=s.extend({task:a.optional()}),u=St({method:Ge(),params:s.loose().optional()}),d=St({_meta:o.optional()}),p=St({method:Ge(),params:d.loose().optional()}),m=$r({_meta:o.optional()}),A=lr([Ge(),kn().int()]),f=m.strict(),y=d.extend({requestId:A.optional(),reason:Ge().optional()}),v=p.extend({method:Vt("notifications/cancelled"),params:y}),x=St({src:Ge(),mimeType:Ge().optional(),sizes:Wt(Ge()).optional(),theme:ca(["light","dark"]).optional()}),_=St({icons:Wt(x).optional()}),E=St({name:Ge(),title:Ge().optional()}),F=E.extend({...E.shape,..._.shape,version:Ge(),websiteUrl:Ge().optional(),description:Ge().optional()}),T=hf(St({applyDefaults:ir().optional()}),t),R=D0((Na)=>{if(Na&&typeof Na==="object"&&!Array.isArray(Na)&&Object.keys(Na).length===0)return{form:{}};return Na},hf(St({form:T.optional(),url:t.optional()}),t.optional())),O=$r({list:t.optional(),cancel:t.optional(),requests:$r({sampling:$r({createMessage:t.optional()}).optional(),elicitation:$r({create:t.optional()}).optional()}).optional()}),j=$r({list:t.optional(),cancel:t.optional(),requests:$r({tools:$r({call:t.optional()}).optional()}).optional()}),H=St({experimental:nr(Ge(),t).optional(),sampling:St({context:t.optional(),tools:t.optional()}).optional(),elicitation:R.optional(),roots:St({listChanged:ir().optional()}).optional(),tasks:O.optional(),extensions:nr(Ge(),t).optional()}),G=s.extend({protocolVersion:Ge(),capabilities:H,clientInfo:F}),W=u.extend({method:Vt("initialize"),params:G}),b=St({experimental:nr(Ge(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:St({listChanged:ir().optional()}).optional(),resources:St({subscribe:ir().optional(),listChanged:ir().optional()}).optional(),tools:St({listChanged:ir().optional()}).optional(),tasks:j.optional(),extensions:nr(Ge(),t).optional()}),k=m.extend({protocolVersion:Ge(),capabilities:b,serverInfo:F,instructions:Ge().optional()}),I=p.extend({method:Vt("notifications/initialized"),params:d.optional()}),C=u.extend({method:Vt("ping"),params:s.optional()}),B=St({progress:kn(),total:Br(kn()),message:Br(Ge())}),L=St({...d.shape,...B.shape,progressToken:n}),M=p.extend({method:Vt("notifications/progress"),params:L}),Q=s.extend({cursor:r.optional()}),w=u.extend({params:Q.optional()}),N=m.extend({nextCursor:r.optional()}),U=St({uri:Ge(),mimeType:Br(Ge()),_meta:nr(Ge(),Er()).optional()}),q=U.extend({text:Ge()}),Z=Ge().refine((Na)=>{try{return atob(Na),!0}catch{return!1}},{message:"Invalid Base64 string"}),ee=U.extend({blob:Z}),ne=ca(["user","assistant"]),re=St({audience:Wt(ne).optional(),priority:kn().min(0).max(1).optional(),lastModified:cA.datetime({offset:!0}).optional()}),ke=St({...E.shape,..._.shape,uri:Ge(),description:Br(Ge()),mimeType:Br(Ge()),size:Br(kn()),annotations:re.optional(),_meta:Br($r({}))}),se=St({...E.shape,..._.shape,uriTemplate:Ge(),description:Br(Ge()),mimeType:Br(Ge()),annotations:re.optional(),_meta:Br($r({}))}),he=w.extend({method:Vt("resources/list")}),ce=N.extend({resources:Wt(ke)}),ge=w.extend({method:Vt("resources/templates/list")}),Qe=N.extend({resourceTemplates:Wt(se)}),Oe=s.extend({uri:Ge()}),_e=Oe,Re=u.extend({method:Vt("resources/read"),params:_e}),We=m.extend({contents:Wt(lr([q,ee]))}),be=p.extend({method:Vt("notifications/resources/list_changed"),params:d.optional()}),Te=Oe,Me=u.extend({method:Vt("resources/subscribe"),params:Te}),me=Oe,le=u.extend({method:Vt("resources/unsubscribe"),params:me}),fe=d.extend({uri:Ge()}),ye=p.extend({method:Vt("notifications/resources/updated"),params:fe}),Ce=St({name:Ge(),description:Br(Ge()),required:Br(ir())}),Ie=St({...E.shape,..._.shape,description:Br(Ge()),arguments:Br(Wt(Ce)),_meta:Br($r({}))}),Ee=w.extend({method:Vt("prompts/list")}),J=N.extend({prompts:Wt(Ie)}),Be=s.extend({name:Ge(),arguments:nr(Ge(),Ge()).optional()}),de=u.extend({method:Vt("prompts/get"),params:Be}),te=St({type:Vt("text"),text:Ge(),annotations:re.optional(),_meta:nr(Ge(),Er()).optional()}),De=St({type:Vt("image"),data:Z,mimeType:Ge(),annotations:re.optional(),_meta:nr(Ge(),Er()).optional()}),oe=St({type:Vt("audio"),data:Z,mimeType:Ge(),annotations:re.optional(),_meta:nr(Ge(),Er()).optional()}),ae=St({type:Vt("tool_use"),name:Ge(),id:Ge(),input:nr(Ge(),Er()),_meta:nr(Ge(),Er()).optional()}),Ae=St({type:Vt("resource"),resource:lr([q,ee]),annotations:re.optional(),_meta:nr(Ge(),Er()).optional()}),ue=ke.extend({type:Vt("resource_link")}),we=lr([te,De,oe,ue,Ae]),ze=St({role:ne,content:we}),Le=m.extend({description:Ge().optional(),messages:Wt(ze)}),qe=p.extend({method:Vt("notifications/prompts/list_changed"),params:d.optional()}),et=St({title:Ge().optional(),readOnlyHint:ir().optional(),destructiveHint:ir().optional(),idempotentHint:ir().optional(),openWorldHint:ir().optional()}),Ze=St({taskSupport:ca(["required","optional","forbidden"]).optional()}),He=St({...E.shape,..._.shape,description:Ge().optional(),inputSchema:St({type:Vt("object"),properties:nr(Ge(),e).optional(),required:Wt(Ge()).optional()}).catchall(Er()),outputSchema:St({type:Vt("object"),properties:nr(Ge(),e).optional(),required:Wt(Ge()).optional()}).catchall(Er()).optional(),annotations:et.optional(),execution:Ze.optional(),_meta:nr(Ge(),Er()).optional()}),ot=w.extend({method:Vt("tools/list")}),Ne=N.extend({tools:Wt(He)}),bt=m.extend({content:Wt(we),structuredContent:nr(Ge(),Er()).optional(),isError:ir().optional()}),rt=l.extend({name:Ge(),arguments:nr(Ge(),Er()).optional()}),yt=u.extend({method:Vt("tools/call"),params:rt}),$e=p.extend({method:Vt("notifications/tools/list_changed"),params:d.optional()}),nt=ca(["debug","info","notice","warning","error","critical","alert","emergency"]),st=s.extend({level:nt}),lt=u.extend({method:Vt("logging/setLevel"),params:st}),Tt=d.extend({level:nt,logger:Ge().optional(),data:Er()}),Pe=p.extend({method:Vt("notifications/message"),params:Tt}),vt=St({name:Ge().optional()}),Kt=St({hints:Wt(vt).optional(),costPriority:kn().min(0).max(1).optional(),speedPriority:kn().min(0).max(1).optional(),intelligencePriority:kn().min(0).max(1).optional()}),mt=St({mode:ca(["auto","required","none"]).optional()}),Ve=St({type:Vt("tool_result"),toolUseId:Ge().describe("The unique identifier for the corresponding tool call."),content:Wt(we),structuredContent:St({}).loose().optional(),isError:ir().optional(),_meta:nr(Ge(),Er()).optional()}),Lt=Wk("type",[te,De,oe]),pt=Wk("type",[te,De,oe,ae,Ve]),wt=St({role:ne,content:lr([pt,Wt(pt)]),_meta:nr(Ge(),Er()).optional()}),wn=l.extend({messages:Wt(wt),modelPreferences:Kt.optional(),systemPrompt:Ge().optional(),includeContext:ca(["none","thisServer","allServers"]).optional(),temperature:kn().optional(),maxTokens:kn().int(),stopSequences:Wt(Ge()).optional(),metadata:t.optional(),tools:Wt(He).optional(),toolChoice:mt.optional()}),sn=u.extend({method:Vt("sampling/createMessage"),params:wn}),dn=m.extend({model:Ge(),stopReason:Br(ca(["endTurn","stopSequence","maxTokens"]).or(Ge())),role:ne,content:Lt}),Hn=m.extend({model:Ge(),stopReason:Br(ca(["endTurn","stopSequence","maxTokens","toolUse"]).or(Ge())),role:ne,content:lr([pt,Wt(pt)])}),Cn=St({type:Vt("boolean"),title:Ge().optional(),description:Ge().optional(),default:ir().optional()}),bn=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),minLength:kn().optional(),maxLength:kn().optional(),format:ca(["email","uri","date","date-time"]).optional(),default:Ge().optional()}),Gn=St({type:ca(["number","integer"]),title:Ge().optional(),description:Ge().optional(),minimum:kn().optional(),maximum:kn().optional(),default:kn().optional()}),Nt=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),enum:Wt(Ge()),default:Ge().optional()}),jt=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),oneOf:Wt(St({const:Ge(),title:Ge()})),default:Ge().optional()}),an=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),enum:Wt(Ge()),enumNames:Wt(Ge()).optional(),default:Ge().optional()}),On=lr([Nt,jt]),In=St({type:Vt("array"),title:Ge().optional(),description:Ge().optional(),minItems:kn().optional(),maxItems:kn().optional(),items:St({type:Vt("string"),enum:Wt(Ge())}),default:Wt(Ge()).optional()}),er=St({type:Vt("array"),title:Ge().optional(),description:Ge().optional(),minItems:kn().optional(),maxItems:kn().optional(),items:St({anyOf:Wt(St({const:Ge(),title:Ge()}))}),default:Wt(Ge()).optional()}),Tr=lr([In,er]),Jn=lr([an,On,Tr]),ln=lr([Jn,Cn,bn,Gn]),Xt=l.extend({mode:Vt("form").optional(),message:Ge(),requestedSchema:St({type:Vt("object"),properties:nr(Ge(),ln),required:Wt(Ge()).optional()}).catchall(Er())}),gn=l.extend({mode:Vt("url"),message:Ge(),elicitationId:Ge(),url:Ge().url()}),pn=lr([Xt,gn]),mn=u.extend({method:Vt("elicitation/create"),params:pn}),pr=d.extend({elicitationId:Ge()}),at=p.extend({method:Vt("notifications/elicitation/complete"),params:pr}),Si=m.extend({action:ca(["accept","decline","cancel"]),content:D0((Na)=>Na===null?void 0:Na,nr(Ge(),lr([Ge(),kn(),ir(),Wt(Ge())])).optional())}),ut=St({type:Vt("ref/resource"),uri:Ge()}),Lr=St({type:Vt("ref/prompt"),name:Ge()}),Ro=s.extend({ref:lr([Lr,ut]),argument:St({name:Ge(),value:Ge()}),context:St({arguments:nr(Ge(),Ge()).optional()}).optional()}),Nc=u.extend({method:Vt("completion/complete"),params:Ro}),bu=m.extend({completion:$r({values:Wt(Ge()).max(100),total:Br(kn().int()),hasMore:Br(ir())})}),Fd=St({uri:Ge().startsWith("file://"),name:Ge().optional(),_meta:nr(Ge(),Er()).optional()}),nd=u.extend({method:Vt("roots/list"),params:s.optional()}),Pi=m.extend({roots:Wt(Fd)}),ps=p.extend({method:Vt("notifications/roots/list_changed"),params:d.optional()}),Pc=$r({ttl:kn().optional(),pollInterval:kn().optional()}),Ln=ca(["working","input_required","completed","failed","cancelled"]),At=St({taskId:Ge(),status:Ln,ttl:lr([kn(),db()]),createdAt:Ge(),lastUpdatedAt:Ge(),pollInterval:Br(kn()),statusMessage:Br(Ge())}),$t=m.extend({task:At}),Dn=d.merge(At),Yn=p.extend({method:Vt("notifications/tasks/status"),params:Dn}),ea=u.extend({method:Vt("tasks/get"),params:s.extend({taskId:Ge()})}),pa=m.merge(At),ei=u.extend({method:Vt("tasks/result"),params:s.extend({taskId:Ge()})}),Go=m.loose(),wi=w.extend({method:Vt("tasks/list")}),ma=N.extend({tasks:Wt(At)}),$c=u.extend({method:Vt("tasks/cancel"),params:s.extend({taskId:Ge()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:a,RelatedTaskMetadataSchema:i,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:l,RequestSchema:u,NotificationsParamsSchema:d,NotificationSchema:p,ResultSchema:m,RequestIdSchema:A,EmptyResultSchema:f,CancelledNotificationParamsSchema:y,CancelledNotificationSchema:v,IconSchema:x,IconsSchema:_,BaseMetadataSchema:E,ImplementationSchema:F,ClientTasksCapabilitySchema:O,ServerTasksCapabilitySchema:j,ClientCapabilitiesSchema:H,InitializeRequestParamsSchema:G,InitializeRequestSchema:W,ServerCapabilitiesSchema:b,InitializeResultSchema:k,InitializedNotificationSchema:I,PingRequestSchema:C,ProgressSchema:B,ProgressNotificationParamsSchema:L,ProgressNotificationSchema:M,PaginatedRequestParamsSchema:Q,PaginatedRequestSchema:w,PaginatedResultSchema:N,ResourceContentsSchema:U,TextResourceContentsSchema:q,BlobResourceContentsSchema:ee,RoleSchema:ne,AnnotationsSchema:re,ResourceSchema:ke,ResourceTemplateSchema:se,ListResourcesRequestSchema:he,ListResourcesResultSchema:ce,ListResourceTemplatesRequestSchema:ge,ListResourceTemplatesResultSchema:Qe,ResourceRequestParamsSchema:Oe,ReadResourceRequestParamsSchema:_e,ReadResourceRequestSchema:Re,ReadResourceResultSchema:We,ResourceListChangedNotificationSchema:be,SubscribeRequestParamsSchema:Te,SubscribeRequestSchema:Me,UnsubscribeRequestParamsSchema:me,UnsubscribeRequestSchema:le,ResourceUpdatedNotificationParamsSchema:fe,ResourceUpdatedNotificationSchema:ye,PromptArgumentSchema:Ce,PromptSchema:Ie,ListPromptsRequestSchema:Ee,ListPromptsResultSchema:J,GetPromptRequestParamsSchema:Be,GetPromptRequestSchema:de,TextContentSchema:te,ImageContentSchema:De,AudioContentSchema:oe,ToolUseContentSchema:ae,EmbeddedResourceSchema:Ae,ResourceLinkSchema:ue,ContentBlockSchema:we,PromptMessageSchema:ze,GetPromptResultSchema:Le,PromptListChangedNotificationSchema:qe,ToolAnnotationsSchema:et,ToolExecutionSchema:Ze,ToolSchema:He,ListToolsRequestSchema:ot,ListToolsResultSchema:Ne,CallToolResultSchema:bt,CallToolRequestParamsSchema:rt,CallToolRequestSchema:yt,ToolListChangedNotificationSchema:$e,LoggingLevelSchema:nt,SetLevelRequestParamsSchema:st,SetLevelRequestSchema:lt,LoggingMessageNotificationParamsSchema:Tt,LoggingMessageNotificationSchema:Pe,ModelHintSchema:vt,ModelPreferencesSchema:Kt,ToolChoiceSchema:mt,ToolResultContentSchema:Ve,SamplingContentSchema:Lt,SamplingMessageContentBlockSchema:pt,SamplingMessageSchema:wt,CreateMessageRequestParamsSchema:wn,CreateMessageRequestSchema:sn,CreateMessageResultSchema:dn,CreateMessageResultWithToolsSchema:Hn,BooleanSchemaSchema:Cn,StringSchemaSchema:bn,NumberSchemaSchema:Gn,UntitledSingleSelectEnumSchemaSchema:Nt,TitledSingleSelectEnumSchemaSchema:jt,LegacyTitledEnumSchemaSchema:an,SingleSelectEnumSchemaSchema:On,UntitledMultiSelectEnumSchemaSchema:In,TitledMultiSelectEnumSchemaSchema:er,MultiSelectEnumSchemaSchema:Tr,EnumSchemaSchema:Jn,PrimitiveSchemaDefinitionSchema:ln,ElicitRequestFormParamsSchema:Xt,ElicitRequestURLParamsSchema:gn,ElicitRequestParamsSchema:pn,ElicitRequestSchema:mn,ElicitationCompleteNotificationParamsSchema:pr,ElicitationCompleteNotificationSchema:at,ElicitResultSchema:Si,ResourceTemplateReferenceSchema:ut,PromptReferenceSchema:Lr,CompleteRequestParamsSchema:Ro,CompleteRequestSchema:Nc,CompleteResultSchema:bu,RootSchema:Fd,ListRootsRequestSchema:nd,ListRootsResultSchema:Pi,RootsListChangedNotificationSchema:ps,TaskCreationParamsSchema:Pc,TaskStatusSchema:Ln,TaskSchema:At,CreateTaskResultSchema:$t,TaskStatusNotificationParamsSchema:Dn,TaskStatusNotificationSchema:Yn,GetTaskRequestSchema:ea,GetTaskResultSchema:pa,GetTaskPayloadRequestSchema:ei,GetTaskPayloadResultSchema:Go,ListTasksRequestSchema:wi,ListTasksResultSchema:ma,CancelTaskRequestSchema:$c,CancelTaskResultSchema:m.merge(At),ClientRequestSchema:lr([C,W,Nc,lt,de,Ee,he,ge,Re,Me,le,yt,ot,ea,ei,wi,$c]),ClientNotificationSchema:lr([v,M,I,ps,Yn]),ClientResultSchema:lr([f,dn,Hn,Si,Pi,pa,ma,$t]),ServerRequestSchema:lr([C,sn,mn,nd,ea,ei,wi,$c]),ServerNotificationSchema:lr([v,M,Pe,ye,be,$e,qe,Yn,at]),ServerResultSchema:lr([f,k,bu,Le,J,ce,Qe,We,bt,Ne,pa,ma,$t]),CallToolResultWireSchema:Er().superRefine((Na,i_)=>{if(typeof Na!=="object"||Na===null||Array.isArray(Na)||Na.content!==void 0)return;for(let Gm of xAn)if(Gm in Na){i_.addIssue({code:"custom",message:`content is required when the body carries '${Gm}' — another result family cannot default into an empty tools/call success`});return}}).transform(Z5e).pipe(bt)}}var $Jr;function _An(){return $Jr??=PJr()}function EAn(e){return e.type!=="object"}var OJr=new Set(["const","enum","default","examples"]),zJr=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function dAn(e){return e!==void 0&&!(typeof e==="string"&&e.startsWith("#"))}function jJr(e){let t=typeof e.$schema==="string"?e.$schema:void 0;if(dAn(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let n=Xmn(e.$schema)&&e.$recursiveAnchor!==!0,r=(a,i)=>{if(Array.isArray(a))return a.map((l)=>r(l,!1));if(a===null||typeof a!=="object")return a;if(!i&&dAn(a.$id))return a;let o={},s=!1;for(let[l,u]of Object.entries(a))if(i)o[l]=r(u,!1);else if((l==="$ref"||l==="$dynamicRef")&&typeof u==="string")o[l]=u==="#"?"#/properties/result":u.startsWith("#/")?`#/properties/result${u.slice(1)}`:u;else if(l==="$recursiveRef"&&u==="#"&&n)s=!0;else if(OJr.has(l))o[l]=u;else if(zJr.has(l))o[l]=r(u,!0);else o[l]=r(u,!1);if(s)if("$ref"in o)o.allOf=[...Array.isArray(o.allOf)?o.allOf:[],{$ref:"#/properties/result"}];else o.$ref="#/properties/result";return o};return{...t!==void 0&&{$schema:t},type:"object",properties:{result:r(e,!1)},required:["result"]}}var BAn={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},IAn={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},qJr={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Pce;function K5e(){if(Pce)return Pce;let e=_An();return Pce={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},Pce}function SAn(e){return Object.prototype.hasOwnProperty.call(BAn,e)}function TAn(e){return Object.prototype.hasOwnProperty.call(IAn,e)}function GJr(e){return Object.prototype.hasOwnProperty.call(qJr,e)}function UJr(e){return GJr(e)?K5e().resultSchemas[e]:void 0}function HJr(e){return SAn(e)?K5e().requestSchemas[e]:void 0}function WJr(e){return TAn(e)?K5e().notificationSchemas[e]:void 0}var jhc=Object.keys(BAn),qhc=Object.keys(IAn);function q5e(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function $ce(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:"invalid",message:String(n.error)}}var pAn={ok:!1,reason:"not-in-era"};function mAn(e){return q5e(e)&&q5e(e.outputSchema)&&EAn(e.outputSchema)}function AAn(e){return e}var J5e={era:"2025-11-25",hasRequestMethod:SAn,hasNotificationMethod:TAn,validateRequest:(e,t)=>$ce(HJr(e),t),validateResult:(e,t)=>$ce(UJr(e),t),validateNotification:(e,t)=>$ce(WJr(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>pAn,validateInputResponse:()=>pAn,samplingResultVariant:(e,t)=>{let n=_An();return $ce(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)},outboundEnvelope:(e)=>{return},validateEnvelopeMeta:(e)=>[],projectCallToolResult(e,t){let n=CAn(e),r=n.structuredContent;if(r===void 0)return n;let a=typeof r!=="object"||r===null||Array.isArray(r),i=t!==void 0&&EAn(t);if(!a&&!i)return n;return{...n,structuredContent:{result:r}}},decodeResult(e,t){if(q5e(t)&&"resultType"in t){let n={...t};return delete n.resultType,{kind:"complete",result:AAn(n)}}return{kind:"complete",result:AAn(t)}},encodeResult(e,t){if(e!=="tools/list")return t;let n=t.tools;if(!Array.isArray(n)||!n.some((r)=>mAn(r)))return t;return{...t,tools:n.map((r)=>mAn(r)?{...r,outputSchema:jJr(r.outputSchema)}:r)}},encodeErrorCode:(e)=>e===-32002?-32602:e,checkInboundEnvelope:(e)=>{return}};function YJr(){let e=Yk(()=>lr([Ge(),kn(),ir(),db(),nr(Ge(),e),Wt(e)])),t=nr(Ge(),e),n=lr([Ge(),kn().int()]),r=Ge(),a=lr([Ge(),kn().int()]),i=ca(["user","assistant"]),o=ca(["debug","info","notice","warning","error","critical","alert","emergency"]),s=Ge().refine((ma)=>{try{return atob(ma),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=St({ttl:kn().optional()}),u=St({taskId:Ge()}),d=$r({progressToken:n.optional(),"io.modelcontextprotocol/related-task":u.optional()}),p=St({_meta:d.optional()}),m=p.extend({task:l.optional()}),A=St({_meta:d.optional()}),f=St({method:Ge(),params:A.loose().optional()}),y=St({src:Ge(),mimeType:Ge().optional(),sizes:Wt(Ge()).optional(),theme:ca(["light","dark"]).optional()}),v=St({icons:Wt(y).optional()}),x=St({name:Ge(),title:Ge().optional()}),_=x.extend({...x.shape,...v.shape,version:Ge(),websiteUrl:Ge().optional(),description:Ge().optional()}),E=hf(St({applyDefaults:ir().optional()}),t),F=D0((ma)=>{if(ma&&typeof ma==="object"&&!Array.isArray(ma)&&Object.keys(ma).length===0)return{form:{}};return ma},hf(St({form:E.optional(),url:t.optional()}),t.optional())),T=$r({list:t.optional(),cancel:t.optional(),requests:$r({sampling:$r({createMessage:t.optional()}).optional(),elicitation:$r({create:t.optional()}).optional()}).optional()}),R=$r({list:t.optional(),cancel:t.optional(),requests:$r({tools:$r({call:t.optional()}).optional()}).optional()}),O=St({experimental:nr(Ge(),t).optional(),sampling:St({context:t.optional(),tools:t.optional()}).optional(),elicitation:F.optional(),roots:St({listChanged:ir().optional()}).optional(),tasks:T.optional(),extensions:nr(Ge(),t).optional()}),j=St({experimental:nr(Ge(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:St({listChanged:ir().optional()}).optional(),resources:St({subscribe:ir().optional(),listChanged:ir().optional()}).optional(),tools:St({listChanged:ir().optional()}).optional(),tasks:R.optional(),extensions:nr(Ge(),t).optional()}),H=St({progress:kn(),total:Br(kn()),message:Br(Ge())}),G=St({...A.shape,...H.shape,progressToken:n}),W=f.extend({method:Vt("notifications/progress"),params:G}),b=A.extend({level:o,logger:Ge().optional(),data:Er()}),k=f.extend({method:Vt("notifications/message"),params:b}),I=St({uri:Ge(),mimeType:Br(Ge()),_meta:nr(Ge(),Er()).optional()}),C=I.extend({text:Ge()}),B=I.extend({blob:s}),L=St({audience:Wt(i).optional(),priority:kn().min(0).max(1).optional(),lastModified:cA.datetime({offset:!0}).optional()}),M=St({...x.shape,...v.shape,uri:Ge(),description:Br(Ge()),mimeType:Br(Ge()),size:Br(kn()),annotations:L.optional(),_meta:Br($r({}))}),Q=St({...x.shape,...v.shape,uriTemplate:Ge(),description:Br(Ge()),mimeType:Br(Ge()),annotations:L.optional(),_meta:Br($r({}))}),w=f.extend({method:Vt("notifications/resources/list_changed"),params:A.optional()}),N=A.extend({uri:Ge()}),U=f.extend({method:Vt("notifications/resources/updated"),params:N}),q=St({name:Ge(),description:Br(Ge()),required:Br(ir())}),Z=St({...x.shape,...v.shape,description:Br(Ge()),arguments:Br(Wt(q)),_meta:Br($r({}))}),ee=f.extend({method:Vt("notifications/prompts/list_changed"),params:A.optional()}),ne=St({type:Vt("text"),text:Ge(),annotations:L.optional(),_meta:nr(Ge(),Er()).optional()}),re=St({type:Vt("image"),data:s,mimeType:Ge(),annotations:L.optional(),_meta:nr(Ge(),Er()).optional()}),ke=St({type:Vt("audio"),data:s,mimeType:Ge(),annotations:L.optional(),_meta:nr(Ge(),Er()).optional()}),se=St({type:Vt("tool_use"),name:Ge(),id:Ge(),input:nr(Ge(),Er()),_meta:nr(Ge(),Er()).optional()}),he=St({type:Vt("resource"),resource:lr([C,B]),annotations:L.optional(),_meta:nr(Ge(),Er()).optional()}),ce=M.extend({type:Vt("resource_link")}),ge=lr([ne,re,ke,ce,he]),Qe=St({role:i,content:ge}),Oe=St({title:Ge().optional(),readOnlyHint:ir().optional(),destructiveHint:ir().optional(),idempotentHint:ir().optional(),openWorldHint:ir().optional()}),_e=f.extend({method:Vt("notifications/tools/list_changed"),params:A.optional()}),Re=St({name:Ge().optional()}),We=St({hints:Wt(Re).optional(),costPriority:kn().min(0).max(1).optional(),speedPriority:kn().min(0).max(1).optional(),intelligencePriority:kn().min(0).max(1).optional()}),be=St({mode:ca(["auto","required","none"]).optional()}),Te=St({type:Vt("boolean"),title:Ge().optional(),description:Ge().optional(),default:ir().optional()}),Me=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),minLength:kn().optional(),maxLength:kn().optional(),format:ca(["email","uri","date","date-time"]).optional(),default:Ge().optional()}),me=St({type:ca(["number","integer"]),title:Ge().optional(),description:Ge().optional(),minimum:kn().optional(),maximum:kn().optional(),default:kn().optional()}),le=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),enum:Wt(Ge()),default:Ge().optional()}),fe=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),oneOf:Wt(St({const:Ge(),title:Ge()})),default:Ge().optional()}),ye=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),enum:Wt(Ge()),enumNames:Wt(Ge()).optional(),default:Ge().optional()}),Ce=lr([le,fe]),Ie=St({type:Vt("array"),title:Ge().optional(),description:Ge().optional(),minItems:kn().optional(),maxItems:kn().optional(),items:St({type:Vt("string"),enum:Wt(Ge())}),default:Wt(Ge()).optional()}),Ee=St({type:Vt("array"),title:Ge().optional(),description:Ge().optional(),minItems:kn().optional(),maxItems:kn().optional(),items:St({anyOf:Wt(St({const:Ge(),title:Ge()}))}),default:Wt(Ge()).optional()}),J=lr([Ie,Ee]),Be=lr([ye,Ce,J]),de=lr([Be,Te,Me,me]),te=m.extend({mode:Vt("form").optional(),message:Ge(),requestedSchema:St({type:Vt("object"),properties:nr(Ge(),de),required:Wt(Ge()).optional()}).catchall(Er())}),De=St({type:Vt("ref/resource"),uri:Ge()}),oe=St({type:Vt("ref/prompt"),name:Ge()}),ae=St({uri:Ge().startsWith("file://"),name:Ge().optional(),_meta:nr(Ge(),Er()).optional()}),Ae=O.shape,ue=St({experimental:Ae.experimental,sampling:Ae.sampling,elicitation:Ae.elicitation,roots:Ae.roots,extensions:Ae.extensions}),we=j.shape,ze=St({experimental:we.experimental,logging:we.logging,completions:we.completions,prompts:we.prompts,resources:we.resources,tools:we.tools,extensions:we.extensions}),Le=$r({progressToken:n.optional(),[s2]:Ge(),[fQ]:_.optional(),[Vv]:ue,[Z1]:o.optional()}),qe=St({...x.shape,...v.shape,description:Ge().optional(),inputSchema:$r({$schema:Ge().optional(),type:Vt("object")}),outputSchema:$r({$schema:Ge().optional()}).optional(),annotations:Oe.optional(),_meta:nr(Ge(),Er()).optional()}),et=St({type:Vt("tool_result"),toolUseId:Ge(),content:Wt(ge),structuredContent:Er().optional(),isError:ir().optional(),_meta:nr(Ge(),Er()).optional()}),Ze=lr([ne,re,ke,se,et]),He=St({role:i,content:lr([Ze,Wt(Ze)]),_meta:nr(Ge(),Er()).optional()}),ot=Ge(),Ne=$r({[Yv]:_.optional().catch(void 0)}),bt=Ne.optional();function rt(ma){return $r({_meta:bt,resultType:ot.default("complete"),...ma})}let yt=rt({}),$e=rt({nextCursor:r.optional()}),nt=rt({content:Wt(ge),structuredContent:Er().optional(),isError:ir().optional()}),st=rt({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),tools:Wt(qe),nextCursor:r.optional()}),lt=rt({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),prompts:Wt(Z),nextCursor:r.optional()}),Tt=rt({description:Ge().optional(),messages:Wt(Qe)}),Pe=rt({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),resources:Wt(M),nextCursor:r.optional()}),vt=rt({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),resourceTemplates:Wt(Q),nextCursor:r.optional()}),Kt=rt({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),contents:Wt(lr([C,B]))}),mt=rt({completion:St({values:Wt(Ge()).max(100),total:kn().int().optional(),hasMore:ir().optional()}).loose()}),Ve=rt({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"])}),Lt=rt({ttlMs:kn().int().min(0).catch(0),cacheScope:ca(["public","private"]).catch("private"),supportedVersions:Wt(Ge()),capabilities:ze,instructions:Ge().optional()}),pt=St({messages:Wt(He),modelPreferences:We.optional(),systemPrompt:Ge().optional(),includeContext:ca(["none","thisServer","allServers"]).optional(),temperature:kn().optional(),maxTokens:kn().int(),stopSequences:Wt(Ge()).optional(),metadata:t.optional(),tools:Wt(qe).optional(),toolChoice:be.optional()}),wt=St({method:Vt("sampling/createMessage"),params:pt}),wn=St({method:Vt("roots/list"),params:St({_meta:nr(Ge(),Er()).optional()}).optional()}),sn=St({...He.shape,model:Ge(),stopReason:Ge().optional()}),dn=St({roots:Wt(ae)}),Hn=St({action:ca(["accept","decline","cancel"]),content:nr(Ge(),lr([Ge(),kn(),ir(),Wt(Ge())])).optional()}),Cn=St({mode:Vt("url"),message:Ge(),url:Ge().url()}),bn=lr([te,Cn]),Gn=St({method:Vt("elicitation/create"),params:bn}),Nt=lr([wt,wn,Gn]),jt=lr([sn,dn,Hn]),an=nr(Ge(),Nt),On=nr(Ge(),jt),In=rt({inputRequests:an.optional(),requestState:Ge().optional()}),er={inputResponses:On.optional(),requestState:Ge().optional()},Tr=St({_meta:Le,...er}),Jn=$r({progressToken:n.optional()});function ln(ma,$c){return St({method:Vt(ma),params:St({_meta:Le,...$c})})}function Xt(ma,$c){return St({method:Vt(ma),params:St({_meta:Jn.optional(),...$c}).optional()})}let gn={name:Ge(),arguments:nr(Ge(),Er()).optional(),...er},pn={cursor:r.optional()},mn=ln("tools/call",gn),pr=ln("tools/list",pn),at=ln("prompts/list",pn),Si=ln("prompts/get",{name:Ge(),arguments:nr(Ge(),Ge()).optional(),...er}),ut=ln("resources/list",pn),Lr=ln("resources/templates/list",pn),Ro=ln("resources/read",{uri:Ge(),...er}),Nc={ref:lr([oe,De]),argument:St({name:Ge(),value:Ge()}),context:St({arguments:nr(Ge(),Ge()).optional()}).optional()},bu=ln("completion/complete",Nc),Fd=ln("server/discover",{}),nd=St({toolsListChanged:ir().optional(),promptsListChanged:ir().optional(),resourcesListChanged:ir().optional(),resourceSubscriptions:Wt(Ge()).optional()}),Pi={notifications:nd},ps=ln("subscriptions/listen",Pi),Pc=Ne.extend({"io.modelcontextprotocol/subscriptionId":a}),Ln=$r({_meta:Pc,resultType:ot.default("complete")}),At={"tools/call":Xt("tools/call",gn),"tools/list":Xt("tools/list",pn),"prompts/get":Xt("prompts/get",{name:Ge(),arguments:nr(Ge(),Ge()).optional()}),"prompts/list":Xt("prompts/list",pn),"resources/list":Xt("resources/list",pn),"resources/templates/list":Xt("resources/templates/list",pn),"resources/read":Xt("resources/read",{uri:Ge()}),"completion/complete":Xt("completion/complete",Nc),"server/discover":Xt("server/discover",{}),"subscriptions/listen":Xt("subscriptions/listen",Pi)};function $t(ma){return $r({_meta:bt,...ma})}let Dn={"tools/call":$t({content:Wt(ge),structuredContent:Er().optional(),isError:ir().optional()}),"tools/list":$t({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),tools:Wt(qe),nextCursor:r.optional()}),"prompts/get":$t({description:Ge().optional(),messages:Wt(Qe)}),"prompts/list":$t({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),prompts:Wt(Z),nextCursor:r.optional()}),"resources/list":$t({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),resources:Wt(M),nextCursor:r.optional()}),"resources/templates/list":$t({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),resourceTemplates:Wt(Q),nextCursor:r.optional()}),"resources/read":$t({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),contents:Wt(lr([C,B]))}),"completion/complete":$t({completion:St({values:Wt(Ge()).max(100),total:kn().int().optional(),hasMore:ir().optional()}).loose()}),"server/discover":$t({ttlMs:kn().int().min(0).catch(0),cacheScope:ca(["public","private"]).catch("private"),supportedVersions:Wt(Ge()),capabilities:ze,instructions:Ge().optional()}),"subscriptions/listen":$t({})},Yn=$r({"io.modelcontextprotocol/subscriptionId":a.optional()}),ea=St({method:Vt("notifications/subscriptions/acknowledged"),params:St({_meta:Yn.optional(),notifications:nd})}),pa=St({_meta:Yn.optional(),requestId:a,reason:Ge().optional()}),ei=St({method:Vt("notifications/cancelled"),params:pa}),Go={"notifications/cancelled":ei,"notifications/progress":W,"notifications/message":k,"notifications/resources/updated":U,"notifications/resources/list_changed":w,"notifications/tools/list_changed":_e,"notifications/prompts/list_changed":ee,"notifications/subscriptions/acknowledged":ea},wi=(ma)=>St({jsonrpc:Vt("2.0"),id:lr([Ge(),kn().int()]),result:ma}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:a,RoleSchema:i,LoggingLevelSchema:o,TaskMetadataSchema:l,RelatedTaskMetadataSchema:u,RequestMetaSchema:d,BaseRequestParamsSchema:p,TaskAugmentedRequestParamsSchema:m,NotificationsParamsSchema:A,NotificationSchema:f,IconSchema:y,IconsSchema:v,BaseMetadataSchema:x,ImplementationSchema:_,ClientTasksCapabilitySchema:T,ServerTasksCapabilitySchema:R,ClientCapabilitiesSchema:O,ServerCapabilitiesSchema:j,ProgressSchema:H,ProgressNotificationParamsSchema:G,ProgressNotificationSchema:W,LoggingMessageNotificationParamsSchema:b,LoggingMessageNotificationSchema:k,ResourceContentsSchema:I,TextResourceContentsSchema:C,BlobResourceContentsSchema:B,AnnotationsSchema:L,ResourceSchema:M,ResourceTemplateSchema:Q,ResourceListChangedNotificationSchema:w,ResourceUpdatedNotificationParamsSchema:N,ResourceUpdatedNotificationSchema:U,PromptArgumentSchema:q,PromptSchema:Z,PromptListChangedNotificationSchema:ee,TextContentSchema:ne,ImageContentSchema:re,AudioContentSchema:ke,ToolUseContentSchema:se,EmbeddedResourceSchema:he,ResourceLinkSchema:ce,ContentBlockSchema:ge,PromptMessageSchema:Qe,ToolAnnotationsSchema:Oe,ToolListChangedNotificationSchema:_e,ModelHintSchema:Re,ModelPreferencesSchema:We,ToolChoiceSchema:be,BooleanSchemaSchema:Te,StringSchemaSchema:Me,NumberSchemaSchema:me,UntitledSingleSelectEnumSchemaSchema:le,TitledSingleSelectEnumSchemaSchema:fe,LegacyTitledEnumSchemaSchema:ye,SingleSelectEnumSchemaSchema:Ce,UntitledMultiSelectEnumSchemaSchema:Ie,TitledMultiSelectEnumSchemaSchema:Ee,MultiSelectEnumSchemaSchema:J,EnumSchemaSchema:Be,PrimitiveSchemaDefinitionSchema:de,ElicitRequestFormParamsSchema:te,ResourceTemplateReferenceSchema:De,PromptReferenceSchema:oe,RootSchema:ae,ClientCapabilities2026Schema:ue,ServerCapabilities2026Schema:ze,RequestMetaEnvelopeSchema:Le,ToolSchema:qe,ToolResultContentSchema:et,SamplingMessageContentBlockSchema:Ze,SamplingMessageSchema:He,ResultTypeSchema:ot,ResultMetaSchema:Ne,ResultSchema:yt,PaginatedResultSchema:$e,CallToolResultSchema:nt,ListToolsResultSchema:st,ListPromptsResultSchema:lt,GetPromptResultSchema:Tt,ListResourcesResultSchema:Pe,ListResourceTemplatesResultSchema:vt,ReadResourceResultSchema:Kt,CompleteResultSchema:mt,CacheableResultSchema:Ve,DiscoverResultSchema:Lt,CreateMessageRequestParamsSchema:pt,CreateMessageRequestSchema:wt,ListRootsRequestSchema:wn,CreateMessageResultSchema:sn,ListRootsResultSchema:dn,ElicitResultSchema:Hn,ElicitRequestURLParamsSchema:Cn,ElicitRequestParamsSchema:bn,ElicitRequestSchema:Gn,InputRequestSchema:Nt,InputResponseSchema:jt,InputRequestsSchema:an,InputResponsesSchema:On,InputRequiredResultSchema:In,InputResponseRequestParamsSchema:Tr,CallToolRequestSchema:mn,ListToolsRequestSchema:pr,ListPromptsRequestSchema:at,GetPromptRequestSchema:Si,ListResourcesRequestSchema:ut,ListResourceTemplatesRequestSchema:Lr,ReadResourceRequestSchema:Ro,CompleteRequestSchema:bu,DiscoverRequestSchema:Fd,SubscriptionFilterSchema:nd,SubscriptionsListenRequestSchema:ps,SubscriptionsListenResultMetaSchema:Pc,SubscriptionsListenResultSchema:Ln,dispatchRequestSchemas:At,dispatchResultSchemas:Dn,NotificationMetaSchema:Yn,SubscriptionsAcknowledgedNotificationSchema:ea,CancelledNotificationParamsSchema:pa,CancelledNotificationSchema:ei,notificationSchemas2026:Go,JSONRPCResultResponseSchema:wi(yt),CallToolResultResponseSchema:wi(lr([nt,In])),ListToolsResultResponseSchema:wi(st),ListPromptsResultResponseSchema:wi(lt),GetPromptResultResponseSchema:wi(lr([Tt,In])),ListResourcesResultResponseSchema:wi(Pe),ListResourceTemplatesResultResponseSchema:wi(vt),ReadResourceResultResponseSchema:wi(lr([Kt,In])),CompleteResultResponseSchema:wi(mt),DiscoverResultResponseSchema:wi(Lt)}}var VJr;function u2(){return VJr??=YJr()}var ZJr=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function KJr(e){return ZJr.includes(e)}var IQ=Symbol("modelcontextprotocol.resultCacheHintFallback");function DAn(e,t){if(t===void 0)return e;let n=e[IQ];if(n===void 0)return{...e,[IQ]:t};let r={},a=n.ttlMs??t.ttlMs;if(a!==void 0)r.ttlMs=a;let i=n.cacheScope??t.cacheScope;if(i!==void 0)r.cacheScope=i;return{...e,[IQ]:r}}function JJr(e){return e[IQ]}function X5e(e){return typeof e==="number"&&Number.isSafeInteger(e)&&e>=0}function e$e(e){return e==="public"||e==="private"}function RAn(e,t){if(e.ttlMs!==void 0&&!X5e(e.ttlMs))throw RangeError(`Invalid cache hint for ${t}: ttlMs must be a non-negative safe integer (got ${String(e.ttlMs)})`);if(e.cacheScope!==void 0&&!e$e(e.cacheScope))throw RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}var Qr=function(e){return e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.ResourceNotFound=-32002]="ResourceNotFound",e[e.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",e[e.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired",e}({}),Ai=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return SQ(this,t)}static isInstance(t){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return SQ(this,t)}constructor(t,n,r){super(n);this.code=t,this.data=r,this.name="ProtocolError",Y5e(this,new.target)}static fromError(t,n,r){if(t===Qr.UrlElicitationRequired&&r){let a=r;if(a.elicitations)return new QAn(a.elicitations,n)}if(t===Qr.UnsupportedProtocolVersion&&r){let a=r;if(Array.isArray(a.supported)&&typeof a.requested==="string")return new LAn({supported:a.supported,requested:a.requested},n)}if(t===Qr.InvalidParams||t===Qr.ResourceNotFound){let a=r;if(typeof a?.uri==="string"&&(t===Qr.ResourceNotFound||Object.keys(a).length===1))return new t$e(a.uri,n)}if(t===Qr.MissingRequiredClientCapability&&r){let a=r;if(a.requiredCapabilities!==null&&typeof a.requiredCapabilities==="object"&&!Array.isArray(a.requiredCapabilities))return new Uce({requiredCapabilities:a.requiredCapabilities},n)}return new e(t,n,r)}},t$e=class extends Ai{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(Qr.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},QAn=class extends Ai{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(Qr.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},LAn=class extends Ai{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(Qr.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Uce=class extends Ai{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(Qr.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},XJr=0,eXr="private",tXr=["tools/call","prompts/get","resources/read"];function nXr(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:"complete"};if(n==="complete")return t;if(tXr.includes(e))return t;throw new Ai(Qr.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function rXr(e,t){let n=JJr(t);if(t.resultType!=="complete"||!KJr(e))return n===void 0?t:cXr(t);let r=t,a=X5e(r.ttlMs)?r.ttlMs:oXr(n),i=e$e(r.cacheScope)?r.cacheScope:sXr(n),o={...r,ttlMs:a,cacheScope:i};return delete o[IQ],o}function aXr(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function iXr(e,t){if(t===void 0)return e;let n=e._meta;if(n===void 0)return{...e,_meta:{[Yv]:t}};if(!aXr(n))return e;if(n[Yv]!==void 0)return e;return{...e,_meta:{...n,[Yv]:t}}}function oXr(e){return e!==void 0&&X5e(e.ttlMs)?e.ttlMs:XJr}function sXr(e){return e!==void 0&&e$e(e.cacheScope)?e.cacheScope:eXr}function cXr(e){let t={...e};return delete t[IQ],t}var lXr=["elicitation/create","sampling/createMessage","roots/list"],Oce;function MAn(){if(Oce)return Oce;let e=u2();return Oce={request:{"elicitation/create":St({method:Vt("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":St({method:Vt("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":St({method:Vt("roots/list"),params:$r({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},Oce}function FAn(e){return lXr.includes(e)}function $5e(e){return FAn(e)?MAn().request[e]:void 0}function uXr(e){return FAn(e)?MAn().response[e]:void 0}var n$e={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},NAn={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function PAn(e){return Object.prototype.hasOwnProperty.call(n$e,e)}function $An(e){return Object.prototype.hasOwnProperty.call(NAn,e)}function dXr(e){return Object.prototype.hasOwnProperty.call(n$e,e)}function pXr(e){return PAn(e)?u2().dispatchRequestSchemas[e]:void 0}function mXr(e){return dXr(e)?u2().dispatchResultSchemas[e]:void 0}function AXr(e){return $An(e)?u2().notificationSchemas2026[e]:void 0}var Ghc=Object.keys(n$e),Uhc=Object.keys(NAn);function O7(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function P7(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:"invalid",message:String(n.error)}}var gXr={ok:!1,reason:"not-in-era"},fXr=[s2,Vv];function hXr(e,t){let n=t,r=!1,a=()=>{if(!r)n={...n},r=!0;return n},i=t.tools;if(e==="tools/list"&&Array.isArray(i)&&i.some((s)=>O7(s)&&("execution"in s)))a().tools=i.map((s)=>{if(!O7(s)||!("execution"in s))return s;let l={...s};return delete l.execution,l});let o=t.capabilities;if(O7(o)&&"tasks"in o){let s={...o};delete s.tasks,a().capabilities=s}return n}var r$e={era:"2026-07-28",hasRequestMethod:PAn,hasNotificationMethod:$An,hasInputRequestMethod:(e)=>$5e(e)!==void 0,validateRequest:(e,t)=>P7(pXr(e),t),validateResult:(e,t)=>P7(mXr(e),t),validateNotification:(e,t)=>P7(AXr(e),t),validateInputRequest:(e,t)=>P7($5e(e),t),validateInputResponse:(e,t)=>P7(uXr(e),t),samplingResultVariant:()=>gXr,outboundEnvelope(e){return{[s2]:e.protocolVersion,[fQ]:e.clientInfo,[Vv]:e.clientCapabilities,...e.logLevel!==void 0&&{[Z1]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let r of fXr)if(!(r in e))t.push({key:r,problem:"missing"});let n=u2().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let r of n.error.issues){let a=r.path.map(String),i=a.length>0?a.join("."):"_meta";if(a.length===1&&t.some((o)=>o.key===i&&o.problem==="missing"))continue;t.push({key:i,problem:r.message})}return t},projectCallToolResult:(e)=>CAn(e),inputRequestSchema:$5e,decodeResult(e,t){if(!O7(t))return{kind:"invalid",error:new $a(oi.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:"invalid",error:new $a(oi.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:"missing-resultType"})};if(typeof n!=="string")return{kind:"invalid",error:new $a(oi.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n==="input_required"){let o=t.inputRequests,s=O7(o)?o:{},l=t.requestState;if(Object.keys(s).length===0&&typeof l!=="string")return{kind:"invalid",error:new $a(oi.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:"input-required-missing-both"})};return{kind:"input_required",inputRequests:s,...typeof l==="string"&&{requestState:l}}}if(n!=="complete")return{kind:"invalid",error:new $a(oi.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=bXr(),a=Object.hasOwn(r,e)?r[e]:void 0;if(a!==void 0){let o=a.safeParse(t);if(!o.success)return{kind:"invalid",error:new $a(oi.InvalidResult,`Invalid result for ${e}: ${o.error}`,{method:e})}}let i={...t};return delete i.resultType,{kind:"complete",result:i}},encodeResult(e,t,n){return iXr(rXr(e,nXr(e,hXr(e,t))),n)},encodeErrorCode:(e)=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let t=u2().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map((n)=>n.message).join("; ")}`}},zce;function bXr(){if(zce)return zce;let e=u2();return zce={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},zce}var a$e="2026-07-28";function TQ(e){return e!==void 0&&q7(e)?r$e:J5e}function gAn(e){if(e.revision!==void 0)return TQ(e.revision).era;return e.era==="modern"?r$e.era:J5e.era}function O5e(e){return OAn.some((t)=>t.hasRequestMethod(e))}function z5e(e){return OAn.some((t)=>t.hasNotificationMethod(e))}var OAn=[J5e,r$e];var yXr=Zmn({AnnotationsSchema:()=>Zv,AudioContentSchema:()=>CQ,BaseMetadataSchema:()=>Wv,BaseRequestParamsSchema:()=>fu,BlobResourceContentsSchema:()=>E7,BooleanSchemaSchema:()=>D7,CallToolRequestParamsSchema:()=>Kse,CallToolRequestSchema:()=>Jse,CallToolResultSchema:()=>T7,CancelTaskRequestSchema:()=>C5e,CancelTaskResultSchema:()=>x5e,CancelledNotificationParamsSchema:()=>ese,CancelledNotificationSchema:()=>w7,ClientCapabilitiesSchema:()=>ase,ClientNotificationSchema:()=>E5e,ClientRequestSchema:()=>_5e,ClientResultSchema:()=>B5e,ClientTasksCapabilitySchema:()=>nse,CompatibilityCallToolResultSchema:()=>p5e,CompleteRequestParamsSchema:()=>_ce,CompleteRequestSchema:()=>Ece,CompleteResultSchema:()=>Bce,ContentBlockSchema:()=>xQ,CreateMessageRequestParamsSchema:()=>uce,CreateMessageRequestSchema:()=>dce,CreateMessageResultSchema:()=>pce,CreateMessageResultWithToolsSchema:()=>mce,CreateTaskResultSchema:()=>g5e,CursorSchema:()=>A7,DiscoverRequestSchema:()=>lse,DiscoverResultSchema:()=>use,ElicitRequestFormParamsSchema:()=>BQ,ElicitRequestParamsSchema:()=>bce,ElicitRequestSchema:()=>yce,ElicitRequestURLParamsSchema:()=>hce,ElicitResultSchema:()=>kce,ElicitationCompleteNotificationParamsSchema:()=>wce,ElicitationCompleteNotificationSchema:()=>vce,EmbeddedResourceSchema:()=>jse,EmptyResultSchema:()=>y7,EnumSchemaSchema:()=>fce,GetPromptRequestParamsSchema:()=>$se,GetPromptRequestSchema:()=>Ose,GetPromptResultSchema:()=>Use,GetTaskPayloadRequestSchema:()=>y5e,GetTaskPayloadResultSchema:()=>w5e,GetTaskRequestSchema:()=>h5e,GetTaskResultSchema:()=>b5e,IconSchema:()=>tse,IconsSchema:()=>J1,ImageContentSchema:()=>kQ,ImplementationSchema:()=>yQ,InitializeRequestParamsSchema:()=>ise,InitializeRequestSchema:()=>ose,InitializeResultSchema:()=>sse,InitializedNotificationSchema:()=>cse,JSONArraySchema:()=>l5e,JSONObjectSchema:()=>bc,JSONRPCErrorResponseSchema:()=>bQ,JSONRPCMessageSchema:()=>Xoe,JSONRPCNotificationSchema:()=>b7,JSONRPCRequestSchema:()=>h7,JSONRPCResponseSchema:()=>u5e,JSONRPCResultResponseSchema:()=>hQ,JSONValueSchema:()=>V1,LegacyTitledEnumSchemaSchema:()=>L7,ListChangedOptionsBaseSchema:()=>m5e,ListPromptsRequestSchema:()=>Nse,ListPromptsResultSchema:()=>Pse,ListResourceTemplatesRequestSchema:()=>hse,ListResourceTemplatesResultSchema:()=>bse,ListResourcesRequestSchema:()=>gse,ListResourcesResultSchema:()=>fse,ListRootsRequestSchema:()=>Sce,ListRootsResultSchema:()=>Tce,ListTasksRequestSchema:()=>v5e,ListTasksResultSchema:()=>k5e,ListToolsRequestSchema:()=>Vse,ListToolsResultSchema:()=>Zse,LoggingLevelSchema:()=>n_,LoggingMessageNotificationParamsSchema:()=>nce,LoggingMessageNotificationSchema:()=>rce,ModelHintSchema:()=>ace,ModelPreferencesSchema:()=>ice,MultiSelectEnumSchemaSchema:()=>gce,NotificationSchema:()=>Md,NotificationsParamsSchema:()=>Ld,NumberSchemaSchema:()=>EQ,PaginatedRequestParamsSchema:()=>mse,PaginatedRequestSchema:()=>X1,PaginatedResultSchema:()=>e_,PingRequestSchema:()=>k7,PrimitiveSchemaDefinitionSchema:()=>N7,ProgressNotificationParamsSchema:()=>pse,ProgressNotificationSchema:()=>C7,ProgressSchema:()=>dse,ProgressTokenSchema:()=>m7,PromptArgumentSchema:()=>Mse,PromptListChangedNotificationSchema:()=>Hse,PromptMessageSchema:()=>Gse,PromptReferenceSchema:()=>xce,PromptSchema:()=>Fse,ReadResourceRequestParamsSchema:()=>yse,ReadResourceRequestSchema:()=>wse,ReadResourceResultSchema:()=>vse,RelatedTaskMetadataSchema:()=>Joe,RequestIdSchema:()=>K1,RequestMetaSchema:()=>g7,RequestSchema:()=>yc,ResourceContentsSchema:()=>x7,ResourceLinkSchema:()=>qse,ResourceListChangedNotificationSchema:()=>kse,ResourceRequestParamsSchema:()=>wQ,ResourceSchema:()=>B7,ResourceTemplateReferenceSchema:()=>Cce,ResourceTemplateSchema:()=>Ase,ResourceUpdatedNotificationParamsSchema:()=>Qse,ResourceUpdatedNotificationSchema:()=>Lse,ResultMetaObjectSchema:()=>f7,ResultSchema:()=>wc,RoleSchema:()=>t_,RootSchema:()=>Ice,RootsListChangedNotificationSchema:()=>Dce,SamplingContentSchema:()=>cce,SamplingMessageContentBlockSchema:()=>i2,SamplingMessageSchema:()=>lce,ServerCapabilitiesSchema:()=>v7,ServerNotificationSchema:()=>S5e,ServerRequestSchema:()=>I5e,ServerResultSchema:()=>T5e,ServerTasksCapabilitySchema:()=>rse,SetLevelRequestParamsSchema:()=>ece,SetLevelRequestSchema:()=>tce,SingleSelectEnumSchemaSchema:()=>Ace,StringSchemaSchema:()=>_Q,SubscribeRequestParamsSchema:()=>Cse,SubscribeRequestSchema:()=>xse,SubscriptionFilterSchema:()=>I7,SubscriptionsAcknowledgedNotificationParamsSchema:()=>Sse,SubscriptionsAcknowledgedNotificationSchema:()=>Tse,SubscriptionsListenRequestParamsSchema:()=>Bse,SubscriptionsListenRequestSchema:()=>Ise,SubscriptionsListenResultMetaSchema:()=>Dse,SubscriptionsListenResultSchema:()=>Rse,TaskAugmentedRequestParamsSchema:()=>l2,TaskCreationParamsSchema:()=>A5e,TaskMetadataSchema:()=>Koe,TaskSchema:()=>r_,TaskStatusNotificationParamsSchema:()=>Qce,TaskStatusNotificationSchema:()=>f5e,TaskStatusSchema:()=>Rce,TextContentSchema:()=>vQ,TextResourceContentsSchema:()=>_7,TitledMultiSelectEnumSchemaSchema:()=>F7,TitledSingleSelectEnumSchemaSchema:()=>Q7,ToolAnnotationsSchema:()=>Wse,ToolChoiceSchema:()=>oce,ToolExecutionSchema:()=>Yse,ToolListChangedNotificationSchema:()=>Xse,ToolResultContentSchema:()=>sce,ToolSchema:()=>S7,ToolUseContentSchema:()=>zse,UnsubscribeRequestParamsSchema:()=>_se,UnsubscribeRequestSchema:()=>Ese,UntitledMultiSelectEnumSchemaSchema:()=>M7,UntitledSingleSelectEnumSchemaSchema:()=>R7});var zAn=(e)=>h7.safeParse(e).success,jAn=(e)=>b7.safeParse(e).success,G5e=(e)=>hQ.safeParse(e).success,qAn=(e)=>bQ.safeParse(e).success;var d2=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&e.resultType==="input_required";var jce=-32020,Hhc=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32000],conformance:[],rationale:"The modern era is POST-only; GET/DELETE are body-less 2025-era session operations and are method-routed to legacy serving (405 when legacy serving is not configured), before any body is read."},{rung:"jsonrpc-shape",order:2,evaluatedAt:"edge",codes:[Qr.InvalidRequest],conformance:["server-stateless"],rationale:"The body must be a JSON-RPC request or notification: posted responses and batch arrays containing a modern or invalid element are rejected before classification (element-wise batch rule); all-legacy arrays stay legacy traffic."},{rung:"era-classification",order:3,evaluatedAt:"edge",codes:[jce,Qr.UnsupportedProtocolVersion],conformance:["server-stateless","http-header-validation","http-custom-header-server-validation"],rationale:"Body-primary era classification with the protocol-version header as a cross-check; a header/body disagreement is rejected with -32020 (HeaderMismatch), and an envelope-less request on a modern-only endpoint is answered with the unsupported-protocol-version error naming the supported revisions."},{rung:"envelope",order:4,evaluatedAt:"edge",codes:[Qr.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope — and a missing envelope on a request whose protocol-version header names a modern revision — is an invalid-params rejection naming the offending or missing key(s); never a silent fall back to legacy handling. This is the only place an invalid-params rejection maps to HTTP 400."},{rung:"method-registry",order:5,evaluatedAt:"dispatch",codes:[Qr.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision’s registry (or with no handler installed) answers method-not-found before params or capabilities are looked at."},{rung:"request-params",order:6,evaluatedAt:"dispatch",codes:[Qr.InvalidParams],conformance:[],rationale:"Per-method params validation; emitted in-band by the dispatch layer (HTTP 200), never via the ladder status table."},{rung:"standard-header-validation",order:7,evaluatedAt:"pre-dispatch",codes:[jce],conformance:["http-header-validation"],rationale:"SEP-2243 standard `Mcp-Method` / `Mcp-Name` headers — presence, sentinel decoding, and `Mcp-Name` ↔ body cross-check — are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The classifier’s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5–6) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[Qr.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced — pinning the spec-mandated HTTP 400 independently of how dispatch- and handler-produced errors are mapped. The documented order (after method resolution and params validation) is preserved observably only while the requirement table is empty: once a served method gains a requirement entry, a request that is missing the capability and would also fail a dispatch rung is answered by this gate first, so the entry must consult the method registry before the gate if the documented precedence is to stay observable."},{rung:"param-header-validation",order:9,evaluatedAt:"pre-dispatch",codes:[jce],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool’s `x-mcp-header` declarations and the body `arguments` after the tool registry is known and before dispatch reaches the handler; a missing/disagreeing/malformed header is rejected 400 / -32020 with the same shape as the standard-header cross-checks. The documented order (after method resolution and params validation) is preserved observably only when the body `arguments` would otherwise validate: the check runs pre-dispatch, so a `tools/call` that fails BOTH this rung and a dispatch-time rung (e.g. order-6 `request-params`, -32602) is answered by this gate first with 400 / -32020, not by the earlier-ordered rung."}],wXr={[Qr.ParseError]:400,[Qr.InvalidRequest]:400,[Qr.MethodNotFound]:404,[Qr.UnsupportedProtocolVersion]:400,[Qr.MissingRequiredClientCapability]:400,[jce]:400};function Hce(e,t){return ML(e,t)}function $7(e){return new Set(e.flatMap((t)=>Object.keys(t.shape)))}function U5e(e){if(e==null)return!1;let t=typeof e;if(t!=="object"&&t!=="function")return!1;if(!("~standard"in e))return!1;return typeof e["~standard"]?.validate==="function"}var fAn=!1,H5e="draft-2020-12";function GAn(e,t="input"){let n=e["~standard"],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:H5e});else if(n.vendor==="zod"){if(!("_zod"in e))throw Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");if(!fAn)fAn=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.");r=S0(e,{target:H5e,io:t})}else throw Error(`Schema library "${n.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t==="output"){if(r.type!==void 0)return r;return UAn(r)?{type:"object",...r}:r}if(r.type!==void 0&&r.type!=="object")throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...r}}function UAn(e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;for(let t of["oneOf","anyOf","allOf"]){let n=e[t];if(Array.isArray(n)&&n.length>0)return n.every((r)=>r!==null&&typeof r==="object"&&(r.type==="object"||UAn(r)))}return!1}function vXr(e){if(!e.path?.length)return e.message;return`${e.path.map((t)=>String(typeof t==="object"?t.key:t)).join(".")}: ${e.message}`}async function qce(e,t){let n=await e["~standard"].validate(t);if(n.issues&&n.issues.length>0)return{success:!1,error:n.issues.map((r)=>vXr(r)).join(", ")};return{success:!0,data:n.value}}function kXr(e){let t=S0(e,{target:H5e,io:"input"});return typeof t.pattern==="string"?t.pattern:void 0}var CXr=/\\\.\\d\{(\d+)\}/;function xXr(e){let t=CXr.exec(e),n=[void 0,-1,0];if(t)n.push(Number(t[1]));return[!1,!0].flatMap((r)=>[!1,!0].flatMap((a)=>n.map((i)=>cA.datetime({local:r,offset:a,precision:i}))))}function _Xr(e,t){let n;switch(e){case"email":n=[_G()];break;case"uri":n=[UT()];break;case"date":n=[cA.date()];break;case"date-time":n=xXr(t);break}return new Set(n.map((r)=>kXr(r)).filter((r)=>r!==void 0))}function EXr(e,t,n){if(n!=="zod")return!0;return _Xr(e,t).has(t)}function j7(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function BXr(e){try{return GAn(e,"input")}catch(t){let n=t instanceof Error?t.message:String(t);throw new Ai(Qr.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${n}`)}}var IXr=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function i$e(e){return IXr.has(e)||e.startsWith("x-")}var SXr=new Set(["$schema",...Object.keys(BQ.shape.requestedSchema.shape)]),hAn={string:$7([_Q,R7,Q7,L7]),number:$7([EQ]),integer:$7([EQ]),boolean:$7([D7]),array:$7([M7,F7])},TXr=new Set(_Q.shape.format.unwrap().options);function DXr(e,t,n,r){if(!j7(e))return e;let a=typeof e.type==="string"&&Object.hasOwn(hAn,e.type)?hAn[e.type]:void 0;if(a===void 0)return e;let i={};for(let[o,s]of Object.entries(e))if(a.has(o)||i$e(o))i[o]=s;else if(o==="pattern"&&e.type==="string"&&typeof e.format==="string"){if(!TXr.has(e.format))i[o]=s;else if(typeof s!=="string"||!EXr(e.format,s,n))r.push(`${t}.${o}`)}else r.push(`${t}.${o}`);return i}function RXr(e,t){let n={},r=[];for(let[a,i]of Object.entries(e))if(a==="properties"&&j7(i))n[a]=Object.fromEntries(Object.entries(i).map(([o,s])=>[o,DXr(s,`properties.${o}`,t,r)]));else if(SXr.has(a))n[a]=i;else if(!i$e(a))r.push(a);if(r.length>0)throw new Ai(Qr.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(", ")}`);return n}function QXr(e,t){if(!j7(e.properties))return t;let n=Object.entries(e.properties).filter(([,r])=>!Hce(N7,r).success).map(([r])=>`properties.${r}`);return n.length>0?n.join(", "):t}function W5e(e,t,n=""){if(Array.isArray(e)&&Array.isArray(t))return e.flatMap((r,a)=>W5e(r,t[a],`${n}[${a}]`));if(!j7(e)||!j7(t))return[];return Object.entries(e).flatMap(([r,a])=>{let i=n?`${n}.${r}`:r;if(!Object.prototype.hasOwnProperty.call(t,r))return i$e(r)?[]:[i];return W5e(a,t[r],i)})}function LXr(e){if(!U5e(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,n=RXr(BXr(e.requestedSchema),t),r=Hce(BQ.shape.requestedSchema,n);if(!r.success)throw new Ai(Qr.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${QXr(n,r.error.message)}`);let a=W5e(n,r.data);if(a.length>0)throw new Ai(Qr.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${a.join(", ")}`);let i=(r.data.required??[]).filter((o)=>!Object.prototype.hasOwnProperty.call(r.data.properties,o));if(i.length>0)throw new Ai(Qr.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${i.join(", ")}`);return{...e,mode:"form",requestedSchema:r.data}}function MXr(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==="string";if(!t&&!n)throw TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}var FXr=Object.assign(MXr,{elicit(e){try{return{method:"elicitation/create",params:LXr(e)}}catch(t){throw t instanceof Ai?TypeError(t.message,{cause:t}):t}},elicitUrl(e){return{method:"elicitation/create",params:{...e,mode:"url"}}},createMessage(e){return{method:"sampling/createMessage",params:e}},listRoots(){return{method:"roots/list"}}});var HAn=250;function WAn(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function YAn(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason instanceof $a?t.reason:new $a(oi.RequestTimeout,String(t.reason)));return}let a=setTimeout(()=>{t?.removeEventListener("abort",i),n()},e),i=()=>{clearTimeout(a),r(t?.reason instanceof $a?t.reason:new $a(oi.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",i,{once:!0})})}function VAn(e){let t=new AbortController,n=()=>t.abort(e?.reason);if(e?.addEventListener("abort",n,{once:!0}),e?.aborted)t.abort(e.reason);return{signal:t.signal,abort:(r)=>t.abort(r),dispose:()=>e?.removeEventListener("abort",n)}}var NXr=["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"],PXr={IdJagTokenExchangeResponseSchema:L5e,OAuthClientInformationFullSchema:F5e,OAuthClientInformationSchema:Nce,OAuthClientMetadataSchema:Fce,OAuthClientRegistrationErrorSchema:N5e,OAuthErrorResponseSchema:M5e,OAuthMetadataSchema:Lce,OAuthProtectedResourceMetadataSchema:D5e,OAuthTokenRevocationRequestSchema:P5e,OAuthTokensSchema:Q5e,OpenIdProviderDiscoveryMetadataSchema:R5e,OpenIdProviderMetadataSchema:Mce},ZAn={},KAn={};function JAn(e,t){let n=e.slice(0,-6);ZAn[n]=t,KAn[n]=(r)=>t.safeParse(r).success}for(let e of NXr)JAn(e,yXr[e]);for(let[e,t]of Object.entries(PXr))JAn(e,t);var $Xr=Object.freeze(ZAn),OXr=Object.freeze(KAn);function zXr(e){switch(e){case"initialize":case"notifications/initialized":return TQ(void 0);case"server/discover":return TQ(a$e);default:return}}var XAn=60000,jXr=[s2,fQ,Vv,Z1],qXr=["inputResponses","requestState"];function bAn(e,t){let n=e.params;if(!z7(n))return{message:e,lifted:{}};let r=n._meta,a=z7(r)?jXr.filter((l)=>(l in r)):[],i=t==="request"?qXr.filter((l)=>(l in n)):[];if(a.length===0&&i.length===0)return{message:e,lifted:{}};let o={},s={...n};if(a.length>0&&z7(r)){let l={},u={...r};for(let d of a)l[d]=r[d],delete u[d];if(o.envelope=l,Object.keys(u).length>0)s._meta=u;else delete s._meta}for(let l of i){if(l==="inputResponses")o.inputResponses=s[l];if(l==="requestState")o.requestState=s[l];delete s[l]}return{message:{...e,params:s},lifted:o}}function yAn(e,t){let n=e.validateResult(t,void 0);if(!n.ok&&n.reason==="not-in-era")return;return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(r){let a=e.validateResult(t,r);if(a.ok)return{value:a.value};return{issues:[{message:a.reason==="invalid"?a.message:`not-in-era: ${t}`}]}}}}}function G7(e){return()=>e}var GXr=G7(void 0);function o$e(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:G7(t)}}}var UXr;var s$e=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{UXr=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Voe,this.setNotificationHandler("notifications/cancelled",(t)=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",(t)=>{this._onprogress(t)}),this.setRequestHandler("ping",(t)=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new $a(oi.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,a=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:a,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new $a(oi.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);if(t)clearTimeout(t.timeoutId),this._timeoutInfo.delete(e)}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let n=this.transport?.onerror;this._transport.onerror=(a)=>{n?.(a),this._onerror(a)};let r=this._transport?.onmessage;this._transport.onmessage=(a,i)=>{if(r?.(a,i),G5e(a)||qAn(a))this._onresponse(a);else if(zAn(a))this._onrequest(a,i);else if(jAn(a))this._onnotification(a,i);else this._onerror(Error(`Unknown message type: ${JSON.stringify(a)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new $a(oi.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let r of e.values())r(n);for(let r of t.values())r.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=bAn(e,"notification"),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let o=gAn(t.classification);if(o!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${o} but this instance serves ${r.era}`));return}}if(z5e(n.method)&&!r.hasNotificationMethod(n.method))return;let a=this._notificationHandlers.get(n.method),i=this.fallbackNotificationHandler;if(a===void 0&&i===void 0)return;Promise.resolve().then(()=>a===void 0?i(n):a(n,r)).catch((o)=>this._onerror(Error(`Uncaught error in notification handler: ${o}`)))}_onrequest(e,t){let{message:n,lifted:r}=bAn(e,"request"),a=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop"){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let i=this._transport,o=(y,v,x)=>{let _={jsonrpc:"2.0",id:n.id,error:{code:y,message:v,...x!==void 0&&{data:x}}};i?.send(_).catch((E)=>this._onerror(Error(`Failed to send an error response: ${E}`)))};if(t?.classification!==void 0){let y=gAn(t.classification);if(y!==a.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${y} but this instance serves ${a.era}`));let v=t.classification.revision??y;o(Qr.UnsupportedProtocolVersion,`Unsupported protocol version: ${v}`,{supported:this._supportedProtocolVersions,requested:v});return}}if(O5e(n.method)&&!a.hasRequestMethod(n.method)){o(Qr.MethodNotFound,"Method not found");return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(Qr.MethodNotFound,"Method not found");return}let l=a.checkInboundEnvelope(r);if(l!==void 0){o(Qr.InvalidParams,l);return}let u=(y,v)=>this._notificationViaCodec(this._resolveOutboundCodec(y.method),y,{...v,relatedRequestId:n.id}),d=(y,v,x)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(y.method),y,v,{...x,relatedRequestId:n.id}),p=new AbortController;this._requestHandlerAbortControllers.set(n.id,p);let m=r.inputResponses===void 0?void 0:HXr(r.inputResponses),A={sessionId:i?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...m!==void 0&&{inputResponses:m.accepted},...m!==void 0&&m.droppedKeys.length>0&&{droppedInputResponseKeys:m.droppedKeys},requestState:r.requestState===void 0?GXr:G7(r.requestState),signal:p.signal,send:(y,v,x)=>{let _=this._resolveOutboundCodec(y.method);if(this._assertOutboundRequestInEra(_,y.method),U5e(v))return d(y,v,x);let E=yAn(_,y.method);if(E===void 0)throw TypeError(`'${y.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return d(y,E,v)},notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},f=this.buildContext(A,t);Promise.resolve().then(()=>s(n,f)).then(async(y)=>{if(p.signal.aborted)return;let v;try{v=a.encodeResult(n.method,y,this._outboundServerInfo())}catch(_){this._onerror(Error(`Failed to encode result for ${n.method}: ${_}`)),o(Qr.InternalError,"Internal error");return}let x={result:v,jsonrpc:"2.0",id:n.id};await i?.send(x)},async(y)=>{if(p.signal.aborted)return;let v=Number.isSafeInteger(y.code)?y.code:Qr.InternalError,x={jsonrpc:"2.0",id:n.id,error:{code:a.encodeErrorCode(v),message:y.message??"Internal error",...y.data!==void 0&&{data:y.data}}};await i?.send(x)}).catch((y)=>this._onerror(Error(`Failed to send response: ${y}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(n.id)===p)this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),a=this._progressHandlers.get(r);if(!a){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&i&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(s){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),i(s);return}a(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),G5e(e))n(e);else n(Ai.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),U5e(t))return this._requestWithSchemaViaCodec(r,e,t,n);let a=yAn(r,e.method);if(a===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,a,t)}_negotiatedWireCodec(){return TQ(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=zXr(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(O5e(t)&&!e.hasRequestMethod(t))throw new $a(oi.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:a,resumptionToken:i,onresumptiontoken:o,headers:s}=r??{},l=Date.now(),u,d;return new Promise((p,m)=>{let A=(R)=>{m(R)};if(!this._transport){A(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(R){A(R);return}if(r?.signal?.aborted){let R=r.signal.reason;throw R instanceof $a?R:new $a(oi.RequestTimeout,String(R))}let f=e.era===a$e&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,y=this._requestMessageId++;d=y;let v={...t,jsonrpc:"2.0",id:y};if(r?.onprogress)this._progressHandlers.set(y,r.onprogress),v.params={...t.params,_meta:{...t.params?._meta,progressToken:y}};let x=this._envelopeOutbound(v),_=!1,E=(R)=>{if(_)return;if(this._progressHandlers.delete(y),f===void 0)this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:y,reason:String(R)}}),{relatedRequestId:a,resumptionToken:i,onresumptiontoken:o}).catch((O)=>this._onerror(Error(`Failed to send cancellation: ${O}`)));else f.abort();m(R instanceof $a?R:new $a(oi.RequestTimeout,String(R)))};this._responseHandlers.set(y,(R)=>{if(r?.signal?.aborted)return;if(_=!0,R instanceof Error)return m(R);let O;try{O=e.decodeResult(t.method,R.result)}catch(H){return m(H instanceof Error?H:Error(String(H)))}if(O.kind==="invalid")return m(O.error);if(O.kind==="input_required"){if(r?.allowInputRequired===!0)return p(WXr(O));let H={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:l,retry:(G,W)=>this._requestWithSchemaViaCodec(e,G===void 0?{method:t.method}:{method:t.method,params:G},n,W)};return p(this._resolveNonCompleteResult(O,H))}let j=O.result;qce(n,j).then((H)=>{if(H.success)p(H.data);else m(new $a(oi.InvalidResult,`Invalid result for ${t.method}: ${H.error}`))},m)}),u=()=>E(r?.signal?.reason),r?.signal?.addEventListener("abort",u,{once:!0});let F=r?.timeout??XAn,T=()=>E(new $a(oi.RequestTimeout,"Request timed out",{timeout:F}));this._setupTimeout(y,F,r?.maxTotalTimeout,T,r?.resetTimeoutOnProgress??!1),this._transport.send(x,{relatedRequestId:a,resumptionToken:i,onresumptiontoken:o,headers:s,requestSignal:f?.signal}).catch((R)=>{this._progressHandlers.delete(y),m(R)})}).finally(()=>{if(u)r?.signal?.removeEventListener("abort",u);if(d!==void 0)this._responseHandlers.delete(d),this._cleanupTimeout(d)})}async notification(e,t){return this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new $a(oi.NotConnected,"Not connected");if(z5e(t.method)&&!e.hasNotificationMethod(t.method))throw new $a(oi.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;this._transport?.send(r,n).catch((a)=>this._onerror(a))});return}await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==="function"){if(!O5e(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(a,i)=>{let o=this._negotiatedWireCodec(),s=o.validateRequest(e,a);if(!s.ok&&s.reason==="not-in-era")s=o.validateInputRequest(e,a);if(!s.ok){if(s.reason==="not-in-era")throw new Ai(Qr.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(s.message)}return Promise.resolve(t(s.value,i))}}else if(n)r=async(a,i)=>{let o=await qce(t.params,{...a.params});if(!o.success)throw new Ai(Qr.InvalidParams,`Invalid params for ${e}: ${o.error}`);return n(o.data,i)};else throw TypeError("setRequestHandler: handler is required");this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==="function"){if(!z5e(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(r,a)=>{let i=a.validateNotification(e,r);if(!i.ok){if(i.reason==="not-in-era")throw new Ai(Qr.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(i.message)}return Promise.resolve(t(i.value))});return}if(!n)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async(r)=>{let a=await qce(t.params,{...r.params});if(!a.success)throw new Ai(Qr.InvalidParams,`Invalid params for notification ${e}: ${a.error}`);await n(a.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function z7(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function c$e(e,t){let n={...e};for(let r in t){let a=r,i=t[a];if(i===void 0)continue;let o=n[a];n[a]=z7(o)&&z7(i)?{...o,...i}:i}return n}function wAn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function HXr(e){let t={},n=[];if(!wAn(e))return{accepted:t,droppedKeys:n};for(let[r,a]of Object.entries(e)){if(!wAn(a)||"method"in a||"result"in a){n.push(r);continue}t[r]=a}return{accepted:t,droppedKeys:n}}function WXr(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState}}}/*!
|
|
4296
|
+
`;return""}return APe.dump=oe,APe}var ndn;function iVr(){if(ndn)return Rd;ndn=1;let e=rVr(),t=aVr();function n(r,a){return function(){throw Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+a+" instead, which is now safe by default.")}}return Rd.Type=zp(),Rd.Schema=rdn(),Rd.FAILSAFE_SCHEMA=sdn(),Rd.JSON_SCHEMA=pdn(),Rd.CORE_SCHEMA=mdn(),Rd.DEFAULT_SCHEMA=gPe(),Rd.load=e.load,Rd.loadAll=e.loadAll,Rd.dump=t.dump,Rd.YAMLException=KO(),Rd.types={binary:fdn(),float:ddn(),map:odn(),null:cdn(),pairs:bdn(),set:ydn(),timestamp:Adn(),bool:ldn(),int:udn(),merge:gdn(),omap:hdn(),seq:idn(),str:adn()},Rd.safeLoad=n("safeLoad","load"),Rd.safeLoadAll=n("safeLoadAll","loadAll"),Rd.safeDump=n("safeDump","dump"),Rd}var Rec=iVr();var Lec=P.record(P.string(),P.unknown());var AVr=P.object({slug:P.string(),title:P.string(),type:P.string(),entityId:P.string(),contentHash:P.string()});var gVr=Boe.omit({url:!0,analyticsScript:!0}),fVr=gVr.extend({title:P.string().optional().describe("Optional site title override"),description:P.string().optional().describe("Optional site description override")});var kdn=["primary","secondary"];var hVr=P.custom((e)=>typeof e==="function","Expected a React component"),bVr=P.strictObject({show:P.boolean().optional(),label:P.string().min(1).optional(),slot:P.enum(kdn).optional(),priority:P.number().optional()}),yVr=P.strictObject({id:P.string().min(1),template:P.string().min(1),content:P.unknown().optional(),dataQuery:P.looseObject({entityType:P.string().optional(),template:P.string().optional(),query:P.record(P.string(),P.unknown()).optional()}).optional(),order:P.number().optional()}),wVr=P.strictObject({id:P.string().min(1),path:P.string().startsWith("/"),title:P.string().optional(),pageLabel:P.string().optional(),description:P.string().optional(),sections:P.array(yVr).optional(),layout:P.string().min(1).optional(),fullscreen:P.boolean().optional(),pluginId:P.string().optional(),sourceEntityType:P.string().optional(),external:P.boolean().optional(),navigation:bVr.optional()}),vVr=P.strictObject({label:P.string().min(1),pluralName:P.string().min(1).optional(),layout:P.string().min(1).optional(),paginate:P.boolean().optional(),pageSize:P.number().int().positive().optional(),navigation:P.strictObject({show:P.boolean().optional(),slot:P.enum(kdn).optional(),priority:P.number().optional()}).optional()}),kVr=P.strictObject({schema:P.custom((e)=>e instanceof P.ZodType,"Expected a Zod schema"),component:P.custom((e)=>typeof e==="function","Expected a React component"),title:P.string().min(1),description:P.string(),requiredPermission:P.enum(["admin","trusted","public"]).optional(),fullscreen:P.boolean().optional()}),vdn=P.strictObject({namespace:P.string().min(1),sections:P.record(P.string(),kVr)}),CVr=P.record(P.string(),P.json()),xVr=P.record(P.string(),P.record(P.string(),CVr)),Cdn=P.strictObject({layouts:P.record(P.string(),hVr).refine((e)=>typeof e.default==="function",{message:'Site layouts must include a "default" component'}),routes:P.array(wVr),content:xVr.optional(),sections:P.union([vdn,P.array(vdn)]).optional(),themeOverride:P.string().optional(),headScripts:P.array(P.string()).optional(),entityDisplay:P.record(P.string(),vVr),staticAssets:P.record(P.string(),P.string()).optional()}).superRefine((e,t)=>{let n=new Set;for(let[i,o]of e.routes.entries()){if(n.has(o.id))t.addIssue({code:"custom",path:["routes",i,"id"],message:`Duplicate route id "${o.id}"`});n.add(o.id);let s=o.layout??"default";if(!e.layouts[s])t.addIssue({code:"custom",path:["routes",i,"layout"],message:`Unknown layout "${s}"`})}let r=Array.isArray(e.sections)?e.sections:e.sections?[e.sections]:[],a=new Map(r.map((i)=>[i.namespace,i]));if(a.size!==r.length)t.addIssue({code:"custom",path:["sections"],message:"Section group namespaces must be unique"});for(let[i,o]of Object.entries(e.content??{})){let s=a.get(i);if(!s){t.addIssue({code:"custom",path:["content",i],message:`Content namespace "${i}" has no section group`});continue}for(let[l,u]of Object.entries(o)){let d=s.sections[l];if(!d){t.addIssue({code:"custom",path:["content",i,l],message:`Content section "${i}.${l}" is not defined`});continue}let p=d.schema.safeParse(u);if(!p.success)t.addIssue({code:"custom",path:["content",i,l],message:`Content does not satisfy the "${i}.${l}" schema: ${P.prettifyError(p.error)}`})}}});var _Vr=P.string();function EVr(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}var BVr=P.custom((e)=>{if(!EVr(e))return!1;let{plugin:t,...n}=e;if(t!==void 0&&typeof t!=="function")return!1;return Cdn.safeParse(n).success});function Vy(e=12){return kO(e)}var hPe=P.enum(["file_operations","content_operations","data_processing","batch_processing"]),SVr=P.object({pluginId:P.string().optional(),progressToken:P.union([P.string(),P.number()]).optional(),operationType:hPe,operationTarget:P.string().optional(),interfaceType:P.string().optional(),conversationId:P.string().optional(),channelId:P.string().optional(),requestedByActor:UA.optional(),requestedByUserId:P.string().optional(),requestedByInterface:P.string().optional(),silent:P.boolean().optional(),provenance:W8.optional()}),oQ=P.object({pluginId:P.string().optional(),progressToken:P.union([P.string(),P.number()]).optional(),operationType:hPe,operationTarget:P.string().optional(),interfaceType:P.string().optional(),conversationId:P.string().optional(),channelId:P.string().optional(),requestedByActor:UA.optional(),requestedByUserId:P.string().optional(),requestedByInterface:P.string().optional(),silent:P.boolean().optional(),provenance:W8.optional(),rootJobId:P.string()}),anc=P.enum(["none","skip","replace","coalesce"]);var TVr=P.object({id:P.string(),type:P.string(),data:P.string(),status:P.enum(["pending","processing","completed","failed"]),source:P.string().nullable(),priority:P.number(),retryCount:P.number(),maxRetries:P.number(),lastError:P.string().nullable(),createdAt:P.number(),scheduledFor:P.number(),startedAt:P.number().nullable(),completedAt:P.number().nullable(),attemptId:P.string().nullable(),workerSlotId:P.string().nullable(),workerSessionId:P.string().nullable(),leaseExpiresAt:P.number().nullable(),attemptHeartbeatAt:P.number().nullable(),runtimeUpdatedAt:P.number().nullable(),metadata:oQ,progress:P.custom((e)=>typeof e==="object"&&e!==null&&("progress"in e)&&typeof e.progress==="number").nullable(),result:P.unknown().nullable().optional()});var bPe=P.enum(["pending","processing","completed","failed"]),xdn=P.enum(["completed","failed"]);var DVr=P.object({id:P.string(),type:P.string(),status:bPe,data:P.unknown(),result:P.unknown().optional(),lastError:P.string().optional().nullable(),attempts:P.number(),maxRetries:P.number(),priority:P.number(),createdAt:P.date(),updatedAt:P.date(),processedAt:P.date().optional().nullable(),completedAt:P.date().optional().nullable(),failedAt:P.date().optional().nullable()}),RVr=P.object({jobId:P.string(),type:P.string(),status:xdn,result:P.unknown().optional(),error:P.string().optional()}),_dn=P.object({success:P.literal(!1),error:P.string().optional()}),yPe=P.object({id:P.string(),type:P.enum(["job","batch"]),status:bPe,message:P.string().optional(),progress:P.object({current:P.number(),total:P.number(),percentage:P.number()}).optional(),aggregationKey:P.string().optional(),batchDetails:P.object({totalOperations:P.number(),completedOperations:P.number(),failedOperations:P.number(),currentOperation:P.string().optional(),errors:P.array(P.string()).optional()}).optional(),jobDetails:P.object({jobType:P.string(),priority:P.number(),retryCount:P.number()}).optional(),metadata:oQ});var Anc=(()=>new RegExp("^(?<scheme>[A-Za-z][A-Za-z.+-]*):(//(?<authority>[^/?#]*))?(?<path>[^?#]*)(\\?(?<query>[^#]*))?(#(?<fragment>.*))?$","su"))();var gnc=(()=>new RegExp("^((?<username>[^:]*)(:(?<password>.*))?@)?((?<host>[^:\\[\\]]*)|(\\[(?<host_br>[^\\[\\]]*)\\]))(:(?<port>[0-9]*))?$","su"))();var sQ;if(typeof WebSocket<"u")sQ=WebSocket;else if(typeof global<"u")sQ=global.WebSocket;else if(typeof window<"u")sQ=window.WebSocket;else if(typeof self<"u")sQ=self.WebSocket;var Unc=-9223372036854775808n;var xPe;if(typeof queueMicrotask<"u")xPe=queueMicrotask;else{let e=Promise.resolve();xPe=(t)=>{e.then(t)}}var BZr=Fn(EPe(),1);var IZr=Fn(EPe(),1);var Mn=Symbol.for("drizzle:entityKind");function Qd(e,t){if(!e||typeof e!=="object")return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,Mn))throw Error(`Class "${t.name??"<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e).constructor;if(n)while(n){if(Mn in n&&n[Mn]===t[Mn])return!0;n=Object.getPrototypeOf(n)}return!1}class H1{constructor(e,t){this.table=e,this.config=t,this.name=t.name,this.keyAsName=t.keyAsName,this.notNull=t.notNull,this.default=t.default,this.defaultFn=t.defaultFn,this.onUpdateFn=t.onUpdateFn,this.hasDefault=t.hasDefault,this.primary=t.primaryKey,this.isUnique=t.isUnique,this.uniqueName=t.uniqueName,this.uniqueType=t.uniqueType,this.dataType=t.dataType,this.columnType=t.columnType,this.generated=t.generated,this.generatedIdentity=t.generatedIdentity}static[Mn]="Column";name;keyAsName;primary;notNull;default;defaultFn;onUpdateFn;hasDefault;isUnique;uniqueName;uniqueType;dataType;columnType;enumValues=void 0;generated=void 0;generatedIdentity=void 0;config;mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}class XO{static[Mn]="ColumnBuilder";config;constructor(e,t,n){this.config={name:e,keyAsName:e==="",notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:t,columnType:n,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$default=this.$defaultFn;$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}$onUpdate=this.$onUpdateFn;primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){if(this.config.name!=="")return;this.config.name=e}}var qm=Symbol.for("drizzle:Name");class BPe{static[Mn]="PgForeignKeyBuilder";reference;_onUpdate="no action";_onDelete="no action";constructor(e,t){if(this.reference=()=>{let{name:n,columns:r,foreignColumns:a}=e();return{name:n,columns:r,foreignTable:a[0].table,foreignColumns:a}},t)this._onUpdate=t.onUpdate,this._onDelete=t.onDelete}onUpdate(e){return this._onUpdate=e===void 0?"no action":e,this}onDelete(e){return this._onDelete=e===void 0?"no action":e,this}build(e){return new zdn(e,this)}}class zdn{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[Mn]="PgForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map((o)=>o.name),a=n.map((o)=>o.name),i=[this.table[qm],...r,n[0].table[qm],...a];return e??`${i.join("_")}_fk`}}function Doe(e,...t){return e(...t)}function IPe(e,t){return`${e[qm]}_${t.join("_")}_unique`}class jdn{constructor(e,t){this.name=t,this.columns=e}static[Mn]="PgUniqueConstraintBuilder";columns;nullsNotDistinctConfig=!1;nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new qdn(e,this.columns,this.nullsNotDistinctConfig,this.name)}}class SZr{static[Mn]="PgUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new jdn(e,this.name)}}class qdn{constructor(e,t,n,r){this.table=e,this.columns=t,this.name=r??IPe(this.table,this.columns.map((a)=>a.name)),this.nullsNotDistinct=n}static[Mn]="PgUniqueConstraint";columns;name;nullsNotDistinct=!1;getName(){return this.name}}function Gdn(e,t,n){for(let r=t;r<e.length;r++){let a=e[r];if(a==="\\"){r++;continue}if(a==='"')return[e.slice(t,r).replace(/\\/g,""),r+1];if(n)continue;if(a===","||a==="}")return[e.slice(t,r).replace(/\\/g,""),r]}return[e.slice(t).replace(/\\/g,""),e.length]}function Udn(e,t=0){let n=[],r=t,a=!1;while(r<e.length){let i=e[r];if(i===","){if(a||r===t)n.push("");a=!0,r++;continue}if(a=!1,i==="\\"){r+=2;continue}if(i==='"'){let[l,u]=Gdn(e,r+1,!0);n.push(l),r=u;continue}if(i==="}")return[n,r+1];if(i==="{"){let[l,u]=Udn(e,r+1);n.push(l),r=u;continue}let[o,s]=Gdn(e,r,!1);n.push(o),r=s}return[n,r]}function Hdn(e){let[t]=Udn(e,1);return t}function SPe(e){return`{${e.map((t)=>{if(Array.isArray(t))return SPe(t);if(typeof t==="string")return`"${t.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`;return`${t}`}).join(",")}}`}class e7 extends XO{foreignKeyConfigs=[];static[Mn]="PgColumnBuilder";array(e){return new Ydn(this.config.name,this,e)}references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e,t){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=t?.nulls,this}generatedAlwaysAs(e){return this.config.generated={as:e,type:"always",mode:"stored"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>Doe((a,i)=>{let o=new BPe(()=>{let s=a();return{columns:[e],foreignColumns:[s]}});if(i.onUpdate)o.onUpdate(i.onUpdate);if(i.onDelete)o.onDelete(i.onDelete);return o.build(t)},n,r))}buildExtraConfigColumn(e){return new Wdn(e,this.config)}}class lQ extends H1{constructor(e,t){if(!t.uniqueName)t.uniqueName=IPe(e,[t.name]);super(e,t);this.table=e}static[Mn]="PgColumn"}class Wdn extends lQ{static[Mn]="ExtraConfigColumn";getSQLType(){return this.getSQLType()}indexConfig={order:this.config.order??"asc",nulls:this.config.nulls??"last",opClass:this.config.opClass};defaultConfig={order:"asc",nulls:"last",opClass:void 0};asc(){return this.indexConfig.order="asc",this}desc(){return this.indexConfig.order="desc",this}nullsFirst(){return this.indexConfig.nulls="first",this}nullsLast(){return this.indexConfig.nulls="last",this}op(e){return this.indexConfig.opClass=e,this}}class TZr{static[Mn]="IndexedColumn";constructor(e,t,n,r){this.name=e,this.keyAsName=t,this.type=n,this.indexConfig=r}name;keyAsName;type;indexConfig}class Ydn extends e7{static[Mn]="PgArrayBuilder";constructor(e,t,n){super(e,"array","PgArray");this.config.baseBuilder=t,this.config.size=n}build(e){let t=this.config.baseBuilder.build(e);return new TPe(e,this.config,t)}}class TPe extends lQ{constructor(e,t,n,r){super(e,t);this.baseColumn=n,this.range=r,this.size=t.size}size;static[Mn]="PgArray";getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==="number"?this.size:""}]`}mapFromDriverValue(e){if(typeof e==="string")e=Hdn(e);return e.map((t)=>this.baseColumn.mapFromDriverValue(t))}mapToDriverValue(e,t=!1){let n=e.map((r)=>r===null?null:Qd(this.baseColumn,TPe)?this.baseColumn.mapToDriverValue(r,!0):this.baseColumn.mapToDriverValue(r));if(t)return n;return SPe(n)}}class DZr extends e7{static[Mn]="PgEnumObjectColumnBuilder";constructor(e,t){super(e,"string","PgEnumObjectColumn");this.config.enum=t}build(e){return new Zdn(e,this.config)}}class Zdn extends lQ{static[Mn]="PgEnumObjectColumn";enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}}var Vdn=Symbol.for("drizzle:isPgEnum");function Kdn(e){return!!e&&typeof e==="function"&&Vdn in e&&e[Vdn]===!0}class RZr extends e7{static[Mn]="PgEnumColumnBuilder";constructor(e,t){super(e,"string","PgEnumColumn");this.config.enum=t}build(e){return new Jdn(e,this.config)}}class Jdn extends lQ{static[Mn]="PgEnumColumn";enum=this.config.enum;enumValues=this.config.enum.enumValues;constructor(e,t){super(e,t);this.enum=t.enum}getSQLType(){return this.enum.enumName}}class t7{static[Mn]="Subquery";constructor(e,t,n,r=!1,a=[]){this._={brand:"Subquery",sql:e,selectedFields:t,alias:n,isWith:r,usedTables:a}}}class QZr extends t7{static[Mn]="WithSubquery"}var Xdn="0.45.2";var DPe,RPe,epn={startActiveSpan(e,t){if(!DPe)return t();if(!RPe)RPe=DPe.trace.getTracer("drizzle-orm",Xdn);return Doe((n,r)=>r.startActiveSpan(e,(a)=>{try{return t(a)}catch(i){throw a.setStatus({code:n.SpanStatusCode.ERROR,message:i instanceof Error?i.message:"Unknown error"}),i}finally{a.end()}}),DPe,RPe)}};var uQ=Symbol.for("drizzle:ViewBaseConfig");var QPe=Symbol.for("drizzle:Schema"),tpn=Symbol.for("drizzle:Columns"),npn=Symbol.for("drizzle:ExtraConfigColumns"),LPe=Symbol.for("drizzle:OriginalName"),MPe=Symbol.for("drizzle:BaseName"),n7=Symbol.for("drizzle:IsAlias"),rpn=Symbol.for("drizzle:ExtraConfigBuilder"),LZr=Symbol.for("drizzle:IsDrizzleTable");class ul{static[Mn]="Table";static Symbol={Name:qm,Schema:QPe,OriginalName:LPe,Columns:tpn,ExtraConfigColumns:npn,BaseName:MPe,IsAlias:n7,ExtraConfigBuilder:rpn};[qm];[LPe];[QPe];[tpn];[npn];[MPe];[n7]=!1;[LZr]=!0;[rpn]=void 0;constructor(e,t,n){this[qm]=this[LPe]=e,this[QPe]=t,this[MPe]=n}}class MZr{static[Mn]="FakePrimitiveParam"}function FZr(e){return e!==null&&e!==void 0&&typeof e.getSQL==="function"}function NZr(e){let t={sql:"",params:[]};for(let n of e)if(t.sql+=n.sql,t.params.push(...n.params),n.typings?.length){if(!t.typings)t.typings=[];t.typings.push(...n.typings)}return t}class tf{static[Mn]="StringChunk";value;constructor(e){this.value=Array.isArray(e)?e:[e]}getSQL(){return new dl([this])}}class dl{constructor(e){this.queryChunks=e;for(let t of e)if(Qd(t,ul)){let n=t[ul.Symbol.Schema];this.usedTables.push(n===void 0?t[ul.Symbol.Name]:n+"."+t[ul.Symbol.Name])}}static[Mn]="SQL";decoder=apn;shouldInlineParams=!1;usedTables=[];append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return epn.startActiveSpan("drizzle.buildSQL",(t)=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(e,t){let n=Object.assign({},t,{inlineParams:t.inlineParams||this.shouldInlineParams,paramStartIndex:t.paramStartIndex||{value:0}}),{casing:r,escapeName:a,escapeParam:i,prepareTyping:o,inlineParams:s,paramStartIndex:l}=n;return NZr(e.map((u)=>{if(Qd(u,tf))return{sql:u.value.join(""),params:[]};if(Qd(u,Roe))return{sql:a(u.value),params:[]};if(u===void 0)return{sql:"",params:[]};if(Array.isArray(u)){let d=[new tf("(")];for(let[p,m]of u.entries())if(d.push(m),p<u.length-1)d.push(new tf(", "));return d.push(new tf(")")),this.buildQueryFromSourceParams(d,n)}if(Qd(u,dl))return this.buildQueryFromSourceParams(u.queryChunks,{...n,inlineParams:s||u.shouldInlineParams});if(Qd(u,ul)){let d=u[ul.Symbol.Schema],p=u[ul.Symbol.Name];return{sql:d===void 0||u[n7]?a(p):a(d)+"."+a(p),params:[]}}if(Qd(u,H1)){let d=r.getColumnCasing(u);if(t.invokeSource==="indexes")return{sql:a(d),params:[]};let p=u.table[ul.Symbol.Schema];return{sql:u.table[n7]||p===void 0?a(u.table[ul.Symbol.Name])+"."+a(d):a(p)+"."+a(u.table[ul.Symbol.Name])+"."+a(d),params:[]}}if(Qd(u,opn)){let d=u[uQ].schema,p=u[uQ].name;return{sql:d===void 0||u[uQ].isAlias?a(p):a(d)+"."+a(p),params:[]}}if(Qd(u,FPe)){if(Qd(u.value,Qoe))return{sql:i(l.value++,u),params:[u],typings:["none"]};let d=u.value===null?null:u.encoder.mapToDriverValue(u.value);if(Qd(d,dl))return this.buildQueryFromSourceParams([d],n);if(s)return{sql:this.mapInlineParam(d,n),params:[]};let p=["none"];if(o)p=[o(u.encoder)];return{sql:i(l.value++,d),params:[d],typings:p}}if(Qd(u,Qoe))return{sql:i(l.value++,u),params:[u],typings:["none"]};if(Qd(u,dl.Aliased)&&u.fieldAlias!==void 0)return{sql:a(u.fieldAlias),params:[]};if(Qd(u,t7)){if(u._.isWith)return{sql:a(u._.alias),params:[]};return this.buildQueryFromSourceParams([new tf("("),u._.sql,new tf(") "),new Roe(u._.alias)],n)}if(Kdn(u)){if(u.schema)return{sql:a(u.schema)+"."+a(u.enumName),params:[]};return{sql:a(u.enumName),params:[]}}if(FZr(u)){if(u.shouldOmitSQLParens?.())return this.buildQueryFromSourceParams([u.getSQL()],n);return this.buildQueryFromSourceParams([new tf("("),u.getSQL(),new tf(")")],n)}if(s)return{sql:this.mapInlineParam(u,n),params:[]};return{sql:i(l.value++,u),params:[u],typings:["none"]}}))}mapInlineParam(e,{escapeString:t}){if(e===null)return"null";if(typeof e==="number"||typeof e==="boolean")return e.toString();if(typeof e==="string")return t(e);if(typeof e==="object"){let n=e.toString();if(n==="[object Object]")return t(JSON.stringify(e));return t(n)}throw Error("Unexpected param value: "+e)}getSQL(){return this}as(e){if(e===void 0)return this;return new dl.Aliased(this,e)}mapWith(e){return this.decoder=typeof e==="function"?{mapFromDriverValue:e}:e,this}inlineParams(){return this.shouldInlineParams=!0,this}if(e){return e?this:void 0}}class Roe{constructor(e){this.value=e}static[Mn]="Name";brand;getSQL(){return new dl([this])}}var apn={mapFromDriverValue:(e)=>e},ipn={mapToDriverValue:(e)=>e},nsc={...apn,...ipn};class FPe{constructor(e,t=ipn){this.value=e,this.encoder=t}static[Mn]="Param";brand;getSQL(){return new dl([this])}}function WA(e,...t){let n=[];if(t.length>0||e.length>0&&e[0]!=="")n.push(new tf(e[0]));for(let[r,a]of t.entries())n.push(a,new tf(e[r+1]));return new dl(n)}((e)=>{function t(){return new dl([])}e.empty=t;function n(l){return new dl(l)}e.fromList=n;function r(l){return new dl([new tf(l)])}e.raw=r;function a(l,u){let d=[];for(let[p,m]of l.entries()){if(p>0&&u!==void 0)d.push(u);d.push(m)}return new dl(d)}e.join=a;function i(l){return new Roe(l)}e.identifier=i;function o(l){return new Qoe(l)}e.placeholder=o;function s(l,u){return new FPe(l,u)}e.param=s})(WA||(WA={}));((e)=>{class t{constructor(n,r){this.sql=n,this.fieldAlias=r}static[Mn]="SQL.Aliased";isSelectionField=!1;getSQL(){return this.sql}clone(){return new t(this.sql,this.fieldAlias)}}e.Aliased=t})(dl||(dl={}));class Qoe{constructor(e){this.name=e}static[Mn]="Placeholder";getSQL(){return new dl([this])}}var PZr=Symbol.for("drizzle:IsDrizzleView");class opn{static[Mn]="View";[uQ];[PZr]=!0;constructor({name:e,schema:t,selectedFields:n,query:r}){this[uQ]={name:e,originalName:e,schema:t,selectedFields:n,query:r,isExisting:!r,isAlias:!1}}getSQL(){return new dl([this])}}H1.prototype.getSQL=function(){return new dl([this])};ul.prototype.getSQL=function(){return new dl([this])};t7.prototype.getSQL=function(){return new dl([this])};function Jy(e,t){return{name:typeof e==="string"&&e.length>0?e:"",config:typeof e==="object"?e:t}}var NPe=typeof TextDecoder>"u"?null:new TextDecoder;class PPe{static[Mn]="SQLiteForeignKeyBuilder";reference;_onUpdate;_onDelete;constructor(e,t){if(this.reference=()=>{let{name:n,columns:r,foreignColumns:a}=e();return{name:n,columns:r,foreignTable:a[0].table,foreignColumns:a}},t)this._onUpdate=t.onUpdate,this._onDelete=t.onDelete}onUpdate(e){return this._onUpdate=e,this}onDelete(e){return this._onDelete=e,this}build(e){return new spn(e,this)}}class spn{constructor(e,t){this.table=e,this.reference=t.reference,this.onUpdate=t._onUpdate,this.onDelete=t._onDelete}static[Mn]="SQLiteForeignKey";reference;onUpdate;onDelete;getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map((o)=>o.name),a=n.map((o)=>o.name),i=[this.table[qm],...r,n[0].table[qm],...a];return e??`${i.join("_")}_fk`}}function $Pe(e,t){return`${e[qm]}_${t.join("_")}_unique`}class cpn{constructor(e,t){this.name=t,this.columns=e}static[Mn]="SQLiteUniqueConstraintBuilder";columns;build(e){return new lpn(e,this.columns,this.name)}}class $Zr{static[Mn]="SQLiteUniqueOnConstraintBuilder";name;constructor(e){this.name=e}on(...e){return new cpn(e,this.name)}}class lpn{constructor(e,t,n){this.table=e,this.columns=t,this.name=n??$Pe(this.table,this.columns.map((r)=>r.name))}static[Mn]="SQLiteUniqueConstraint";columns;name;getName(){return this.name}}class mu extends XO{static[Mn]="SQLiteColumnBuilder";foreignKeyConfigs=[];references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e){return this.config.isUnique=!0,this.config.uniqueName=e,this}generatedAlwaysAs(e,t){return this.config.generated={as:e,type:"always",mode:t?.mode??"virtual"},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>((a,i)=>{let o=new PPe(()=>{let s=a();return{columns:[e],foreignColumns:[s]}});if(i.onUpdate)o.onUpdate(i.onUpdate);if(i.onDelete)o.onDelete(i.onDelete);return o.build(t)})(n,r))}}class Au extends H1{constructor(e,t){if(!t.uniqueName)t.uniqueName=$Pe(e,[t.name]);super(e,t);this.table=e}static[Mn]="SQLiteColumn"}class upn extends mu{static[Mn]="SQLiteBigIntBuilder";constructor(e){super(e,"bigint","SQLiteBigInt")}build(e){return new dpn(e,this.config)}}class dpn extends Au{static[Mn]="SQLiteBigInt";getSQLType(){return"blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return BigInt(t.toString("utf8"))}return BigInt(NPe.decode(e))}mapToDriverValue(e){return Buffer.from(e.toString())}}class ppn extends mu{static[Mn]="SQLiteBlobJsonBuilder";constructor(e){super(e,"json","SQLiteBlobJson")}build(e){return new mpn(e,this.config)}}class mpn extends Au{static[Mn]="SQLiteBlobJson";getSQLType(){return"blob"}mapFromDriverValue(e){if(typeof Buffer<"u"&&Buffer.from){let t=Buffer.isBuffer(e)?e:e instanceof ArrayBuffer?Buffer.from(e):e.buffer?Buffer.from(e.buffer,e.byteOffset,e.byteLength):Buffer.from(e);return JSON.parse(t.toString("utf8"))}return JSON.parse(NPe.decode(e))}mapToDriverValue(e){return Buffer.from(JSON.stringify(e))}}class Apn extends mu{static[Mn]="SQLiteBlobBufferBuilder";constructor(e){super(e,"buffer","SQLiteBlobBuffer")}build(e){return new gpn(e,this.config)}}class gpn extends Au{static[Mn]="SQLiteBlobBuffer";mapFromDriverValue(e){if(Buffer.isBuffer(e))return e;return Buffer.from(e)}getSQLType(){return"blob"}}function Loe(e,t){let{name:n,config:r}=Jy(e,t);if(r?.mode==="json")return new ppn(n);if(r?.mode==="bigint")return new upn(n);return new Apn(n)}class fpn extends mu{static[Mn]="SQLiteCustomColumnBuilder";constructor(e,t,n){super(e,"custom","SQLiteCustomColumn");this.config.fieldConfig=t,this.config.customTypeParams=n}build(e){return new hpn(e,this.config)}}class hpn extends Au{static[Mn]="SQLiteCustomColumn";sqlName;mapTo;mapFrom;constructor(e,t){super(e,t);this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return typeof this.mapFrom==="function"?this.mapFrom(e):e}mapToDriverValue(e){return typeof this.mapTo==="function"?this.mapTo(e):e}}function Moe(e){return(t,n)=>{let{name:r,config:a}=Jy(t,n);return new fpn(r,a,e)}}class Foe extends mu{static[Mn]="SQLiteBaseIntegerBuilder";constructor(e,t,n){super(e,t,n);this.config.autoIncrement=!1}primaryKey(e){if(e?.autoIncrement)this.config.autoIncrement=!0;return this.config.hasDefault=!0,super.primaryKey()}}class Noe extends Au{static[Mn]="SQLiteBaseInteger";autoIncrement=this.config.autoIncrement;getSQLType(){return"integer"}}class bpn extends Foe{static[Mn]="SQLiteIntegerBuilder";constructor(e){super(e,"number","SQLiteInteger")}build(e){return new ypn(e,this.config)}}class ypn extends Noe{static[Mn]="SQLiteInteger"}class wpn extends Foe{static[Mn]="SQLiteTimestampBuilder";constructor(e,t){super(e,"date","SQLiteTimestamp");this.config.mode=t}defaultNow(){return this.default(WA`(cast((julianday('now') - 2440587.5)*86400000 as integer))`)}build(e){return new vpn(e,this.config)}}class vpn extends Noe{static[Mn]="SQLiteTimestamp";mode=this.config.mode;mapFromDriverValue(e){if(this.config.mode==="timestamp")return new Date(e*1000);return new Date(e)}mapToDriverValue(e){let t=e.getTime();if(this.config.mode==="timestamp")return Math.floor(t/1000);return t}}class kpn extends Foe{static[Mn]="SQLiteBooleanBuilder";constructor(e,t){super(e,"boolean","SQLiteBoolean");this.config.mode=t}build(e){return new Cpn(e,this.config)}}class Cpn extends Noe{static[Mn]="SQLiteBoolean";mode=this.config.mode;mapFromDriverValue(e){return Number(e)===1}mapToDriverValue(e){return e?1:0}}function Wr(e,t){let{name:n,config:r}=Jy(e,t);if(r?.mode==="timestamp"||r?.mode==="timestamp_ms")return new wpn(n,r.mode);if(r?.mode==="boolean")return new kpn(n,r.mode);return new bpn(n)}class xpn extends mu{static[Mn]="SQLiteNumericBuilder";constructor(e){super(e,"string","SQLiteNumeric")}build(e){return new _pn(e,this.config)}}class _pn extends Au{static[Mn]="SQLiteNumeric";mapFromDriverValue(e){if(typeof e==="string")return e;return String(e)}getSQLType(){return"numeric"}}class Epn extends mu{static[Mn]="SQLiteNumericNumberBuilder";constructor(e){super(e,"number","SQLiteNumericNumber")}build(e){return new Bpn(e,this.config)}}class Bpn extends Au{static[Mn]="SQLiteNumericNumber";mapFromDriverValue(e){if(typeof e==="number")return e;return Number(e)}mapToDriverValue=String;getSQLType(){return"numeric"}}class Ipn extends mu{static[Mn]="SQLiteNumericBigIntBuilder";constructor(e){super(e,"bigint","SQLiteNumericBigInt")}build(e){return new Spn(e,this.config)}}class Spn extends Au{static[Mn]="SQLiteNumericBigInt";mapFromDriverValue=BigInt;mapToDriverValue=String;getSQLType(){return"numeric"}}function Tpn(e,t){let{name:n,config:r}=Jy(e,t),a=r?.mode;return a==="number"?new Epn(n):a==="bigint"?new Ipn(n):new xpn(n)}class Dpn extends mu{static[Mn]="SQLiteRealBuilder";constructor(e){super(e,"number","SQLiteReal")}build(e){return new Rpn(e,this.config)}}class Rpn extends Au{static[Mn]="SQLiteReal";getSQLType(){return"real"}}function Qpn(e){return new Dpn(e??"")}class Lpn extends mu{static[Mn]="SQLiteTextBuilder";constructor(e,t){super(e,"string","SQLiteText");this.config.enumValues=t.enum,this.config.length=t.length}build(e){return new Mpn(e,this.config)}}class Mpn extends Au{static[Mn]="SQLiteText";enumValues=this.config.enumValues;length=this.config.length;constructor(e,t){super(e,t)}getSQLType(){return`text${this.config.length?`(${this.config.length})`:""}`}}class Fpn extends mu{static[Mn]="SQLiteTextJsonBuilder";constructor(e){super(e,"json","SQLiteTextJson")}build(e){return new Npn(e,this.config)}}class Npn extends Au{static[Mn]="SQLiteTextJson";getSQLType(){return"text"}mapFromDriverValue(e){return JSON.parse(e)}mapToDriverValue(e){return JSON.stringify(e)}}function Bn(e,t={}){let{name:n,config:r}=Jy(e,t);if(r.mode==="json")return new Fpn(n);return new Lpn(n,r)}function Ppn(){return{blob:Loe,customType:Moe,integer:Wr,numeric:Tpn,real:Qpn,text:Bn}}var OPe=Symbol.for("drizzle:SQLiteInlineForeignKeys");class r7 extends ul{static[Mn]="SQLiteTable";static Symbol=Object.assign({},ul.Symbol,{InlineForeignKeys:OPe});[ul.Symbol.Columns];[OPe]=[];[ul.Symbol.ExtraConfigBuilder]=void 0}function OZr(e,t,n,r,a=e){let i=new r7(e,r,a),o=typeof t==="function"?t(Ppn()):t,s=Object.fromEntries(Object.entries(o).map(([u,d])=>{let p=d;p.setName(u);let m=p.build(i);return i[OPe].push(...p.buildForeignKeys(m,i)),[u,m]})),l=Object.assign(i,s);if(l[ul.Symbol.Columns]=s,l[ul.Symbol.ExtraConfigColumns]=s,n)l[r7.Symbol.ExtraConfigBuilder]=n;return l}var Jo=(e,t,n)=>OZr(e,t,n);class $pn{constructor(e,t){this.name=e,this.value=t}static[Mn]="SQLiteCheckBuilder";brand;build(e){return new Opn(e,this)}}class Opn{constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}static[Mn]="SQLiteCheck";name;value}function W1(e,t){return new $pn(e,t)}class zPe{constructor(e,t){this.name=e,this.unique=t}static[Mn]="SQLiteIndexBuilderOn";on(...e){return new zpn(this.name,e,this.unique)}}class zpn{static[Mn]="SQLiteIndexBuilder";config;constructor(e,t,n){this.config={name:e,columns:t,unique:n,where:void 0}}where(e){return this.config.where=e,this}build(e){return new jpn(this.config,e)}}class jpn{static[Mn]="SQLiteIndex";config;constructor(e,t){this.config={...e,table:t}}}function qo(e){return new zPe(e,!1)}function jPe(e){return new zPe(e,!0)}function YA(...e){if(e[0].columns)return new qPe(e[0].columns,e[0].name);return new qPe(e)}class qPe{static[Mn]="SQLitePrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new qpn(e,this.columns,this.name)}}class qpn{constructor(e,t,n){this.table=e,this.columns=t,this.name=n}static[Mn]="SQLitePrimaryKey";columns;name;getName(){return this.name??`${this.table[r7.Symbol.Name]}_${this.columns.map((e)=>e.name).join("_")}_pk`}}var Gpn=Jo("job_queue",{id:Bn("id").primaryKey().$defaultFn(()=>Vy()),type:Bn("type").notNull(),data:Bn("data").notNull(),result:Bn("result",{mode:"json"}),progress:Bn("progress",{mode:"json"}).$type(),source:Bn("source"),metadata:Bn("metadata",{mode:"json"}).$type().notNull(),status:Bn("status",{enum:["pending","processing","completed","failed"]}).notNull().default("pending"),priority:Wr("priority").notNull().default(0),retryCount:Wr("retryCount").notNull().default(0),maxRetries:Wr("maxRetries").notNull().default(3),lastError:Bn("lastError"),createdAt:Wr("createdAt").notNull().$defaultFn(()=>Date.now()),scheduledFor:Wr("scheduledFor").notNull().$defaultFn(()=>Date.now()),startedAt:Wr("startedAt"),completedAt:Wr("completedAt"),attemptId:Bn("attemptId"),workerSlotId:Bn("workerSlotId"),workerSessionId:Bn("workerSessionId"),leaseExpiresAt:Wr("leaseExpiresAt"),attemptHeartbeatAt:Wr("attemptHeartbeatAt"),runtimeUpdatedAt:Wr("runtimeUpdatedAt")},(e)=>({queueReadyIdx:qo("idx_job_queue_ready").on(e.status,e.priority,e.scheduledFor),jobTypeIdx:qo("idx_job_queue_type").on(e.type,e.status),runtimeUpdatesIdx:qo("idx_job_queue_runtime_updates").on(e.runtimeUpdatedAt,e.id),jobSourceIdx:qo("idx_job_queue_source").on(e.source)})),Upn=Jo("job_worker_sessions",{slotId:Bn("slotId").primaryKey(),sessionId:Bn("sessionId").notNull().unique(),startedAt:Wr("startedAt").notNull(),heartbeatAt:Wr("heartbeatAt").notNull(),expiresAt:Wr("expiresAt").notNull().default(0)},(e)=>({heartbeatIdx:qo("idx_job_worker_sessions_heartbeat").on(e.heartbeatAt),expiresIdx:qo("idx_job_worker_sessions_expires").on(e.expiresAt)}));class GPe{tails=new Map;async run(e,t){let n=this.tails.get(e),r=()=>{},a=new Promise((i)=>{r=i});this.tails.set(e,a),await n;try{return await t()}finally{if(r(),this.tails.get(e)===a)this.tails.delete(e)}}}var Icc=P.looseObject({deduplicationKey:P.string().optional()});var Ncc=new GPe;var{AsyncLocalStorage:zcc}=(()=>({}));var vlc=P.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},P.record(P.string(),P.unknown()));var xlc=P.record(P.string(),P.unknown());var YZr=P.custom((e)=>typeof e==="object"&&e!==null&&("safeParse"in e)),Glc=P.object({name:P.string(),schema:YZr});var $oe=Jo("conversations",{id:Bn("id").primaryKey(),sessionId:Bn("session_id").notNull(),interfaceType:Bn("interface_type").notNull(),channelId:Bn("channel_id").notNull(),personId:Bn("person_id"),started:Bn("started").notNull(),lastActive:Bn("last_active").notNull(),metadata:Bn("metadata"),created:Bn("created").notNull(),updated:Bn("updated").notNull()},(e)=>({sessionIdx:qo("idx_conversations_session").on(e.sessionId),channelIdx:qo("idx_conversations_channel").on(e.channelId),personIdx:qo("idx_conversations_person").on(e.personId),interfaceSessionIdx:qo("idx_conversations_interface_session").on(e.interfaceType,e.sessionId),interfaceChannelIdx:qo("idx_conversations_interface_channel").on(e.interfaceType,e.channelId)})),Ypn=Jo("messages",{id:Bn("id").primaryKey(),conversationId:Bn("conversation_id").notNull().references(()=>$oe.id,{onDelete:"cascade"}),role:Bn("role").notNull(),content:Bn("content").notNull(),timestamp:Bn("timestamp").notNull(),metadata:Bn("metadata")},(e)=>({conversationIdx:qo("idx_messages_conversation").on(e.conversationId),timestampIdx:qo("idx_messages_timestamp").on(e.timestamp)})),Vpn=Jo("summary_tracking",{conversationId:Bn("conversation_id").primaryKey().references(()=>$oe.id,{onDelete:"cascade"}),lastSummarizedAt:Bn("last_summarized_at"),lastMessageId:Bn("last_message_id"),messagesSinceSummary:Wr("messages_since_summary").default(0),updated:Bn("updated").notNull()});var euc=P.preprocess((e)=>{if(typeof e!=="string")return e;try{return JSON.parse(e)}catch{return}},P.record(P.string(),P.unknown())).catch({});var o7=P.object({identity:UA,interfaceType:P.string(),role:H8,displayName:P.string().optional(),username:P.string().optional(),isBot:P.boolean().optional()}),VZr=P.preprocess(ZZr,o7);function ZZr(e){if(!KZr(e)||"identity"in e)return e;let{actorId:t,interfaceType:n,role:r}=e;if(typeof t!=="string"||typeof n!=="string"||r!=="user"&&r!=="assistant")return e;let{userId:a,canonicalId:i}=e;return{identity:sNe({actorId:t,interfaceType:n,role:r,...typeof a==="string"?{userId:a}:{},...typeof i==="string"?{canonicalId:i}:{}}),interfaceType:n,role:r,...typeof e.displayName==="string"?{displayName:e.displayName}:{},...typeof e.username==="string"?{username:e.username}:{},...typeof e.isBot==="boolean"?{isBot:e.isBot}:{}}}var s7=P.object({messageId:P.string().optional(),channelId:P.string().optional(),channelName:P.string().optional(),threadId:P.string().optional(),metadata:P.record(P.string(),P.unknown()).optional()}),Zpn=P.looseObject({actor:VZr.optional(),source:s7.optional()});function KZr(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var JZr=P.object({id:P.string(),conversationId:P.string(),role:P.string(),content:P.string(),timestamp:P.string(),metadata:P.string().nullable()}),Kpn=P.object({conversationId:P.string(),messageCount:P.number(),messages:P.array(JZr),windowStart:P.number(),windowEnd:P.number(),windowSize:P.number(),timestamp:P.string()});var c7=P.record(P.string(),P.unknown());var tKr=P.object({id:P.string(),sessionId:P.string(),interfaceType:P.string(),channelId:P.string(),personId:P.string().optional(),channelName:P.string().optional(),startedAt:P.string(),lastActiveAt:P.string(),createdAt:P.string(),updatedAt:P.string(),metadata:c7}),nKr=P.object({id:P.string(),conversationId:P.string(),role:H8,content:P.string(),timestamp:P.string(),metadata:c7});var Xpn=P.object({name:P.string(),role:P.string(),purpose:P.string(),values:P.array(P.string())}),emn=P.object({name:P.string(),organization:P.string().optional(),description:P.string().optional(),avatar:P.string().optional(),website:P.string().optional(),email:P.string().optional(),socialLinks:P.array(P.object({platform:P.enum(["github","instagram","linkedin","email","website"]),url:P.string(),label:P.string().optional()})).optional()});var tmn=P.object({name:P.string(),description:P.string(),tags:P.array(P.string()),examples:P.array(P.string())});td();var nmn=/^[a-f0-9]{64}$/,rmn=/^asset:\/\/sha256\/([a-f0-9]{64})$/,amn="asset://sha256/";var Ooe=P.custom((e)=>typeof e==="string"&&rmn.test(e),{message:"Invalid SHA-256 asset reference"}),iKr=P.object({ref:Ooe,digest:P.string().regex(nmn),sizeBytes:P.number().int().nonnegative()}).refine((e)=>VPe(e.ref)===e.digest,{message:"Asset reference and digest must match",path:["digest"]});function YPe(e){return Ooe.parse(e)}function VPe(e){return YPe(e).slice(amn.length)}var imn=Jo("assets",{digest:Bn("digest").notNull().primaryKey(),bytes:Loe("bytes",{mode:"buffer"}).notNull(),sizeBytes:Wr("size_bytes").notNull(),created:Wr("created").notNull().$defaultFn(()=>Date.now())},(e)=>({digestLengthCheck:W1("assets_digest_length_check",WA`length(${e.digest}) = 64`),digestAlphabetCheck:W1("assets_digest_alphabet_check",WA`${e.digest} NOT GLOB '*[^0-9a-f]*'`),bytesTypeCheck:W1("assets_bytes_type_check",WA`typeof(${e.bytes}) = 'blob'`),sizeNonnegativeCheck:W1("assets_size_nonnegative_check",WA`${e.sizeBytes} >= 0`),sizeMatchesBytesCheck:W1("assets_size_matches_bytes_check",WA`length(${e.bytes}) = ${e.sizeBytes}`)}));var l7=Jo("entities",{id:Bn("id").notNull(),entityType:Bn("entityType").notNull(),content:Bn("content").notNull(),contentHash:Bn("contentHash").notNull(),visibility:Bn("visibility",{enum:["public","shared","restricted"]}).notNull().default("public"),metadata:Bn("metadata",{mode:"json"}).$type().notNull().default(WA`'{}'`),created:Wr("created").notNull().$defaultFn(()=>Date.now()),updated:Wr("updated").notNull().$defaultFn(()=>Date.now())},(e)=>({pk:YA({columns:[e.id,e.entityType]}),visibilityCheck:W1("entities_visibility_check",WA`${e.visibility} IN ('public', 'shared', 'restricted')`)}));var omn=Jo("entity_export_intents",{entityType:Bn("entity_type").notNull(),entityId:Bn("entity_id").notNull(),operation:Bn("operation",{enum:["upsert","delete"]}).notNull(),revision:Bn("revision").notNull(),markedAt:Wr("marked_at").notNull()},(e)=>({pk:YA({columns:[e.entityType,e.entityId]}),markedAtIdx:qo("entity_export_intents_marked_at_idx").on(e.markedAt)}));var smn=Jo("projection_entity_owners",{entityType:Bn("entity_type").notNull(),entityId:Bn("entity_id").notNull(),ruleId:Bn("rule_id").notNull(),ruleVersion:Bn("rule_version").notNull(),inputFingerprint:Bn("input_fingerprint").notNull(),claimedAt:Wr("claimed_at").notNull()},(e)=>({pk:YA({columns:[e.entityType,e.entityId]}),ruleIdx:qo("projection_entity_owners_rule_idx").on(e.ruleId)})),cmn=Jo("projection_dirty_inputs",{generation:Wr("generation").primaryKey({autoIncrement:!0}),sourceType:Bn("source_type").notNull(),sourceId:Bn("source_id").notNull(),revision:Bn("revision").notNull(),operation:Bn("operation",{enum:["upsert","delete"]}).notNull(),markedAt:Wr("marked_at").notNull()},(e)=>({generationIdx:qo("projection_dirty_inputs_generation_idx").on(e.generation)})),u7=Jo("projection_waves",{id:Bn("id").primaryKey(),cutoffGeneration:Wr("cutoff_generation").notNull(),graphFingerprint:Bn("graph_fingerprint").notNull(),admissionEpoch:Wr("admission_epoch").notNull().default(0),status:Bn("status",{enum:["running","completed","failed","superseded"]}).notNull(),startedAt:Wr("started_at").notNull(),completedAt:Wr("completed_at")}),lmn=Jo("projection_incidents",{waveId:Bn("wave_id").primaryKey().references(()=>u7.id,{onDelete:"cascade"}),ruleId:Bn("rule_id").notNull(),jobId:Bn("job_id"),failureReason:Bn("failure_reason").notNull(),recoveryGeneration:Wr("recovery_generation").notNull(),createdAt:Wr("created_at").notNull(),resolvedAt:Wr("resolved_at")},(e)=>({unresolvedIdx:qo("projection_incidents_unresolved_idx").on(e.resolvedAt,e.createdAt)})),umn=Jo("projection_wave_inputs",{waveId:Bn("wave_id").notNull().references(()=>u7.id,{onDelete:"cascade"}),sourceType:Bn("source_type").notNull(),sourceId:Bn("source_id").notNull(),revision:Bn("revision").notNull(),operation:Bn("operation",{enum:["upsert","delete"]}).notNull(),generation:Wr("generation").notNull()},(e)=>({pk:YA({columns:[e.waveId,e.sourceType,e.sourceId]}),generationIdx:qo("projection_wave_inputs_generation_idx").on(e.waveId,e.generation)})),dmn=Jo("projection_wave_rules",{waveId:Bn("wave_id").notNull().references(()=>u7.id,{onDelete:"cascade"}),ruleId:Bn("rule_id").notNull(),targetType:Bn("target_type").notNull(),level:Wr("level").notNull(),jobId:Bn("job_id"),status:Bn("status",{enum:["pending","queued","completed","failed"]}).notNull(),inputFingerprint:Bn("input_fingerprint"),changedTargets:Bn("changed_targets",{mode:"json"}).$type().notNull().default([])},(e)=>({pk:YA({columns:[e.waveId,e.ruleId]}),statusIdx:qo("projection_wave_rules_status_idx").on(e.waveId,e.status,e.level)})),pmn=Jo("projection_rule_memos",{ruleId:Bn("rule_id").notNull(),ruleVersion:Bn("rule_version").notNull(),inputFingerprint:Bn("input_fingerprint").notNull(),writeIntents:Bn("write_intents",{mode:"json"}).$type().notNull(),createdAt:Wr("created_at").notNull()},(e)=>({pk:YA({columns:[e.ruleId,e.ruleVersion,e.inputFingerprint]})}));var mmn=Moe({dataType(){return"F32_BLOB(1536)"},toDriver(e){return Buffer.from(e.buffer)},fromDriver(e){return new Float32Array(e.buffer,e.byteOffset,e.byteLength/4)}});var zoe=Jo("embeddings",{entityId:Bn("entity_id").notNull(),entityType:Bn("entity_type").notNull(),embedding:mmn("embedding").notNull(),contentHash:Bn("content_hash").notNull()},(e)=>({pk:YA({columns:[e.entityId,e.entityType]})}));var ipc=P.object({id:P.string().min(1,"Entity ID is required"),entityType:P.string().min(1,"Entity type is required"),contentHash:P.string().min(1,"Content hash is required"),operation:P.enum(["create","update"])});var ZPe=P.enum(["public","shared","restricted"]),Y1=P.union([ZPe,P.literal("private")]).optional().transform((e)=>{if(e===void 0)return"public";if(e==="private")return"restricted";return e});var Hv=P.object({id:P.string(),entityType:P.string(),content:P.string(),created:P.string().datetime(),updated:P.string().datetime(),visibility:Y1,metadata:P.record(P.string(),P.unknown()),contentHash:P.string()}),oKr=P.enum(["public","shared","restricted"]),hmn=P.object({id:P.string(),entityType:P.string(),content:P.string(),created:P.string().datetime(),updated:P.string().datetime(),visibility:P.union([oKr,P.literal("private")]).optional().transform((e)=>{if(e===void 0)return"public";if(e==="private")return"restricted";return e}),metadata:P.record(P.string(),P.unknown()),contentHash:P.string()}),JPe=P.object({}),sKr=P.object({mediaType:P.string(),url:P.string(),downloadUrl:P.string().optional(),previewUrl:P.string().optional(),filename:P.string().optional(),sizeBytes:P.number().optional(),source:P.object({entityType:P.string().optional(),entityId:P.string().optional(),attachmentType:P.string().optional()}).optional()});var ypc=P.object({limit:P.number().int().positive().optional().default(20),offset:P.number().int().min(0).optional().default(0),types:P.array(P.string()).optional().default([]),excludeTypes:P.array(P.string()).optional().default([]),weight:P.record(P.string(),P.number()).optional(),visibilityScope:P.enum(["public","shared","restricted"]).optional(),includeUngenerated:P.boolean().optional().default(!1),minScore:P.number().min(0).optional()}),wpc=P.preprocess((e)=>{if(typeof e!=="string")return e;return JSON.parse(e)},P.record(P.string(),P.unknown()));var cKr=Fn(DNe(),1);var Cpc=P.object({visibility:P.enum(["public","shared","restricted","private"]).optional().transform((e)=>{if(e===void 0)return;return e==="private"?"restricted":e})});var Bpc=P.looseObject({issues:P.array(P.looseObject({message:P.string()}))});var Mpc=P.record(P.string(),P.unknown());var lKr=P.object({field:P.string(),direction:P.enum(["asc","desc"]),nullsFirst:P.boolean().optional()}),qpc=P.object({limit:P.number().int().positive().optional(),offset:P.number().int().min(0).optional().default(0),sortFields:P.array(lKr).optional(),filter:P.object({metadata:P.record(P.string(),P.unknown()).optional(),visibilityScope:P.enum(["public","shared","restricted"]).optional()}).optional(),publishedOnly:P.boolean().optional()});var Kpc=P.custom((e)=>typeof e==="object"&&e!==null&&!Array.isArray(e));var Jpc=P.object({id:P.string().min(1),entityType:P.string().min(1),contentHash:P.string().min(1)});var{AsyncLocalStorage:umc}=(()=>({}));var pQ=P.lazy(()=>P.union([P.null(),P.boolean(),P.number().finite().refine((e)=>!Number.isInteger(e)||Number.isSafeInteger(e),{message:"integer exceeds the JSON-safe range"}),P.string(),P.array(pQ),P.record(P.string(),pQ)])),a2=P.record(P.string(),pQ),dKr=P.strictObject({id:P.string().trim().min(1),entityType:P.string().trim().min(1),content:P.string(),metadata:a2,visibility:Y1}),d7=P.discriminatedUnion("operation",[P.strictObject({operation:P.literal("upsert"),entity:dKr}),P.strictObject({operation:P.literal("delete"),entityType:P.string().trim().min(1),id:P.string().trim().min(1)})]);var pKr=Jo("projection_admission_state",{id:Wr("id").primaryKey(),epoch:Wr("epoch").notNull().default(0)}),wmn=Jo("projection_batches",{id:Bn("id").primaryKey(),source:Bn("source").notNull(),operationId:Bn("operation_id").notNull(),status:Bn("status",{enum:["preparing","open","closed","abandoned"]}).notNull(),ownerKind:Bn("owner_kind",{enum:["callback","job-root"]}).notNull(),ownerToken:Bn("owner_token").notNull(),rootJobId:Bn("root_job_id"),expectedChildren:Wr("expected_children").notNull().default(0),enqueueComplete:Wr("enqueue_complete").notNull().default(0),enqueueFailed:Wr("enqueue_failed").notNull().default(0),openedAt:Wr("opened_at").notNull(),lastProgressAt:Wr("last_progress_at").notNull(),leaseExpiresAt:Wr("lease_expires_at"),terminalAt:Wr("terminal_at"),recoveredAt:Wr("recovered_at"),firstGeneration:Wr("first_generation"),highestGeneration:Wr("highest_generation"),mutationCount:Wr("mutation_count").notNull().default(0),recoveryGeneration:Wr("recovery_generation")},(e)=>({operationIdx:jPe("projection_batches_operation_idx").on(e.source,e.operationId),admissionIdx:qo("projection_batches_admission_idx").on(e.status,e.openedAt),rootJobIdx:qo("projection_batches_root_job_idx").on(e.rootJobId),recoveryIdx:qo("projection_batches_recovery_idx").on(e.recoveredAt,e.recoveryGeneration)})),mKr=Jo("projection_batch_children",{batchId:Bn("batch_id").notNull().references(()=>wmn.id,{onDelete:"cascade"}),childKey:Bn("child_key").notNull(),jobId:Bn("job_id"),status:Bn("status",{enum:["expected","active","completed","failed","missing"]}).notNull().default("expected"),terminalAt:Wr("terminal_at")},(e)=>({pk:YA({columns:[e.batchId,e.childKey]}),jobIdx:jPe("projection_batch_children_job_idx").on(e.jobId),statusIdx:qo("projection_batch_children_status_idx").on(e.batchId,e.status)}));var vmc=P.strictObject({sourceType:P.string().trim().min(1),sourceId:P.string().trim().min(1),revision:P.string().trim().min(1),operation:P.enum(["upsert","delete"]),markedAt:P.number().int().nonnegative()}),kmc=P.strictObject({waveId:P.string().trim().min(1),ruleId:P.string().trim().min(1),jobId:P.string().trim().min(1).nullable(),failureReason:P.string().trim().min(1).max(500),failedAt:P.number().int().nonnegative()}),Cmc=P.strictObject({ruleId:P.string().trim().min(1),ruleVersion:P.string().trim().min(1),inputFingerprint:P.string().trim().min(1)}),xmc=P.strictObject({entityType:P.string().trim().min(1),id:P.string().trim().min(1)}),_mc=P.strictObject({ruleId:P.string().trim().min(1),targetType:P.string().trim().min(1),level:P.number().int().nonnegative()}),gKr=P.strictObject({source:P.string().trim().min(1).max(100),operationId:P.string().trim().min(1).max(200)});var fKr=gKr.extend({rootJobId:P.string().trim().min(1).max(200),expectedChildren:P.number().int().positive().max(1e4)}),Emc=fKr.extend({rootJobId:P.string().trim().min(1).max(200),childKey:P.string().trim().min(1).max(200),expectedChildren:P.number().int().positive().max(1e4),jobId:P.string().trim().min(1).max(200)}),Bmc=P.strictObject({operationId:P.string().trim().min(1).max(200),childKey:P.string().trim().min(1).max(200),jobId:P.string().trim().min(1).max(200),outcome:P.enum(["completed","failed"])}),Imc=P.strictObject({entityType:P.string().trim().min(1),entityId:P.string().trim().min(1),operation:P.enum(["upsert","delete"]),contentHash:P.string().min(1).optional()});var kAc=P.record(P.string(),P.unknown());var xmn=P.object({currentPage:P.number(),totalPages:P.number(),totalItems:P.number(),pageSize:P.number(),hasNextPage:P.boolean(),hasPrevPage:P.boolean()});var $Kr=P.object({name:P.string(),description:P.string(),schema:P.any(),basePrompt:P.string().optional(),useKnowledgeContext:P.boolean().optional(),requiredPermission:P.enum(["admin","trusted","public"]),renderVersion:P.string().min(1).optional(),formatter:P.any().optional(),overlayFormatter:P.any().optional(),layout:P.object({component:P.any().optional(),fullscreen:P.boolean().optional()}).optional(),dataSourceId:P.string().optional()});var Bmn=P.enum(["admin","trusted","public"]),OKr=P.enum(["create","update","delete","extract","publish"]),AQ=P.enum(["never","admin","trusted","public"]),Imn=P.strictObject({create:AQ.optional(),update:AQ.optional(),delete:AQ.optional(),extract:AQ.optional(),publish:AQ.optional()}),zKr=P.record(P.string(),Imn);var jKr=P.enum(["site-content-preview","site-content-production"]),Smn=P.enum(["web","image","pdf"]),t5e=P.custom((e)=>typeof e==="function"),qKr=P.object({name:P.string(),schema:P.any(),description:P.string().optional(),pluginId:P.string(),renderVersion:P.string().min(1).optional(),renderers:P.object({web:P.union([t5e,P.string()]).optional(),image:P.union([t5e,P.string()]).optional(),pdf:P.union([t5e,P.string()]).optional()})}),GKr=P.object({enableContentGeneration:P.boolean().default(!1),outputDir:P.string(),workingDir:P.string().optional(),environment:P.enum(["preview","production"]).default("preview"),siteConfig:P.object({title:P.string(),description:P.string(),url:P.string().optional()}).optional()}),UKr=P.object({success:P.boolean(),routesBuilt:P.number(),errors:P.array(P.string()).optional(),warnings:P.array(P.string()).optional()});var Rmn=P.object({});var wfc=P.strictObject({id:P.string().trim().min(1),version:P.string().trim().min(1),sources:P.array(P.strictObject({kind:P.literal("entity"),types:P.array(P.string().trim().min(1)).min(1),excludeTypes:P.array(P.string().trim().min(1)).optional()})),targetType:P.string().trim().min(1),sourceChangeBatchDelayMs:P.number().int().nonnegative().default(0)});var Ofc=P.union([P.string(),P.number().finite(),P.boolean(),P.null()]);var KKr=/^[a-z][a-z0-9-]*$/,JKr=P.strictObject({source:P.string().min(1).max(500),flags:P.string().regex(/^[imu]*$/).optional()}),qfc=P.strictObject({type:P.string().trim().regex(KKr),displayName:P.string().trim().min(1).max(100),subjectLabel:P.string().trim().min(1).max(100),subjectPattern:JKr.optional(),manualDelivery:P.boolean().optional()});var Qmn=/[\s\\\p{Cc}\p{Cf}]/u;function Lmn(e){if(typeof e!=="string"||e!==e.trim()||e.length===0||e.length>2048||!e.startsWith("/")||e.startsWith("//")||Qmn.test(e))return;try{let t=new URL(e,"https://brains.invalid");if(t.origin!=="https://brains.invalid")return;let n=`${t.pathname}${t.search}${t.hash}`;return n.length>0&&n.length<=2048&&n.startsWith("/")&&!n.startsWith("//")&&!Qmn.test(n)?n:void 0}catch{return}}var XKr=/^[a-z][a-z0-9-]*$/,nf=P.string().trim().regex(XKr),Woe=P.string().trim().min(1).max(300),Mmn=P.enum(["high","normal"]),n5e=nf.max(40),r5e=nf.max(40),Fmn=P.strictObject({value:r5e,label:P.string().trim().min(1).max(100)}),Nmn=P.strictObject({key:n5e,label:P.string().trim().min(1).max(100),values:P.array(Fmn).min(1).max(20)}).superRefine((e,t)=>{let n=new Set;for(let r of e.values){if(n.has(r.value))t.addIssue({code:"custom",path:["values"],message:`Duplicate inbox facet value: ${r.value}`});n.add(r.value)}}),Pmn=P.array(Nmn).max(8).superRefine((e,t)=>{let n=new Set;for(let r of e){if(n.has(r.key))t.addIssue({code:"custom",path:[],message:`Duplicate inbox facet key: ${r.key}`});n.add(r.key)}}),$mn=P.record(n5e,r5e).refine((e)=>Object.keys(e).length<=8,{message:"Inbox items may declare at most eight facets"}),eJr=P.string().regex(/^[a-z][A-Za-z0-9]{0,39}$/),tJr=P.string().min(1).max(300).refine((e)=>!/[\p{Cc}\p{Cf}]/u.test(e),{message:"Inbox follow-up context values cannot contain controls"}),nJr=P.strictObject({kind:nf,context:P.record(eJr,tJr).refine((e)=>Object.keys(e).length<=8,{message:"Inbox follow-up context may contain at most eight entries"})}),rJr=P.array(nJr).max(8).superRefine((e,t)=>{let n=new Set;for(let r of e){if(n.has(r.kind))t.addIssue({code:"custom",path:[],message:`Duplicate inbox follow-up kind: ${r.kind}`});n.add(r.kind)}}),Omn=P.strictObject({id:nf,label:P.string().trim().min(1).max(100),confirm:P.boolean().optional()}),zmn=P.strictObject({entityType:P.string().trim().min(1).max(100),entityId:P.string().trim().min(1).max(300)}),jmn=P.strictObject({label:P.string().trim().min(1).max(300),personId:P.string().trim().min(1).max(200).optional()}),a5e=P.strictObject({id:Woe,title:P.string().trim().min(1).max(160),summary:P.string().trim().min(1).max(1000).optional(),contact:jmn.optional(),threadOrdinal:P.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),receivedAt:P.iso.datetime(),urgency:Mmn,entityRef:zmn.optional(),facets:$mn.optional(),followUps:rJr.optional(),actions:P.array(Omn).max(10)}).superRefine((e,t)=>{let n=new Set;for(let r of e.actions){if(n.has(r.id))t.addIssue({code:"custom",path:["actions"],message:`Duplicate inbox action id: ${r.id}`});n.add(r.id)}}),aJr=P.array(a5e).max(1000),qmn=P.strictObject({permissionLevel:P.enum(["admin","trusted","public"])}),iJr=P.strictObject({kind:P.literal("plain"),text:P.string().max(1e5),truncated:P.boolean()}),oJr=P.strictObject({sourceId:nf,displayName:P.string().trim().min(1).max(100)}),sJr=P.strictObject({sourceId:nf,displayName:P.string().trim().min(1).max(100),facets:Pmn.optional()});var cJr=2048,lJr=8192,Jfc=P.strictObject({kind:nf,label:P.string().trim().min(1).max(100),priority:P.number().int().min(0).max(1000),mode:P.enum(["universal","declared"]),permissionLevel:P.enum(["admin","trusted","public"]),contextSchema:P.custom((e)=>typeof e==="object"&&e!==null&&("safeParse"in e)&&typeof e.safeParse==="function").optional(),applies:P.custom((e)=>typeof e==="function"),resolve:P.custom((e)=>typeof e==="function")}).superRefine((e,t)=>{if(e.mode==="declared"&&e.contextSchema===void 0)t.addIssue({code:"custom",path:["contextSchema"],message:"Declared inbox follow-up kinds require a context schema"});if(e.mode==="universal"&&e.contextSchema!==void 0)t.addIssue({code:"custom",path:["contextSchema"],message:"Universal inbox follow-up kinds cannot accept context"})}),Xfc=P.strictObject({href:P.string(),state:P.unknown().optional()}),uJr=P.record(P.string(),P.json()).refine((e)=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=lJr,{message:"Inbox follow-up state is too large"}),dJr=P.strictObject({kind:nf,label:P.string().trim().min(1).max(100),href:P.string().min(1).max(cJr).refine((e)=>Lmn(e)===e),state:uJr.optional()});var{mkdir:chc,readdir:lhc,readFile:uhc,rm:dhc,stat:phc,writeFile:mhc}=(()=>({}));function Xy(e){if(typeof e!=="string")throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function Gmn(e,t){var n="",r=0,a=-1,i=0,o;for(var s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(a===s-1||i===1);else if(a!==s-1&&i===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){var l=n.lastIndexOf("/");if(l!==n.length-1){if(l===-1)n="",r=0;else n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/");a=s,i=0;continue}}else if(n.length===2||n.length===1){n="",r=0,a=s,i=0;continue}}if(t){if(n.length>0)n+="/..";else n="..";r=2}}else{if(n.length>0)n+="/"+e.slice(a+1,s);else n=e.slice(a+1,s);r=s-a-1}a=s,i=0}else if(o===46&&i!==-1)++i;else i=-1}return n}function pJr(e,t){var n=t.dir||t.root,r=t.base||(t.name||"")+(t.ext||"");if(!n)return r;if(n===t.root)return n+r;return n+e+r}function i5e(){var e="",t=!1,n;for(var r=arguments.length-1;r>=-1&&!t;r--){var a;if(r>=0)a=arguments[r];else{if(n===void 0)n=process.cwd();a=n}if(Xy(a),a.length===0)continue;e=a+"/"+e,t=a.charCodeAt(0)===47}if(e=Gmn(e,!t),t)if(e.length>0)return"/"+e;else return"/";else if(e.length>0)return e;else return"."}function Umn(e){if(Xy(e),e.length===0)return".";var t=e.charCodeAt(0)===47,n=e.charCodeAt(e.length-1)===47;if(e=Gmn(e,!t),e.length===0&&!t)e=".";if(e.length>0&&n)e+="/";if(t)return"/"+e;return e}function mJr(e){return Xy(e),e.length>0&&e.charCodeAt(0)===47}function Hmn(){if(arguments.length===0)return".";var e;for(var t=0;t<arguments.length;++t){var n=arguments[t];if(Xy(n),n.length>0)if(e===void 0)e=n;else e+="/"+n}if(e===void 0)return".";return Umn(e)}function AJr(e,t){if(Xy(e),Xy(t),e===t)return"";if(e=i5e(e),t=i5e(t),e===t)return"";var n=1;for(;n<e.length;++n)if(e.charCodeAt(n)!==47)break;var r=e.length,a=r-n,i=1;for(;i<t.length;++i)if(t.charCodeAt(i)!==47)break;var o=t.length,s=o-i,l=a<s?a:s,u=-1,d=0;for(;d<=l;++d){if(d===l){if(s>l){if(t.charCodeAt(i+d)===47)return t.slice(i+d+1);else if(d===0)return t.slice(i+d)}else if(a>l){if(e.charCodeAt(n+d)===47)u=d;else if(d===0)u=0}break}var p=e.charCodeAt(n+d),m=t.charCodeAt(i+d);if(p!==m)break;else if(p===47)u=d}var A="";for(d=n+u+1;d<=r;++d)if(d===r||e.charCodeAt(d)===47)if(A.length===0)A+="..";else A+="/..";if(A.length>0)return A+t.slice(i+u);else{if(i+=u,t.charCodeAt(i)===47)++i;return t.slice(i)}}function gJr(e){return e}function Wmn(e){if(Xy(e),e.length===0)return".";var t=e.charCodeAt(0),n=t===47,r=-1,a=!0;for(var i=e.length-1;i>=1;--i)if(t=e.charCodeAt(i),t===47){if(!a){r=i;break}}else a=!1;if(r===-1)return n?"/":".";if(n&&r===1)return"//";return e.slice(0,r)}function Ymn(e,t){if(t!==void 0&&typeof t!=="string")throw TypeError('"ext" argument must be a string');Xy(e);var n=0,r=-1,a=!0,i;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var o=t.length-1,s=-1;for(i=e.length-1;i>=0;--i){var l=e.charCodeAt(i);if(l===47){if(!a){n=i+1;break}}else{if(s===-1)a=!1,s=i+1;if(o>=0)if(l===t.charCodeAt(o)){if(--o===-1)r=i}else o=-1,r=s}}if(n===r)r=s;else if(r===-1)r=e.length;return e.slice(n,r)}else{for(i=e.length-1;i>=0;--i)if(e.charCodeAt(i)===47){if(!a){n=i+1;break}}else if(r===-1)a=!1,r=i+1;if(r===-1)return"";return e.slice(n,r)}}function fJr(e){Xy(e);var t=-1,n=0,r=-1,a=!0,i=0;for(var o=e.length-1;o>=0;--o){var s=e.charCodeAt(o);if(s===47){if(!a){n=o+1;break}continue}if(r===-1)a=!1,r=o+1;if(s===46){if(t===-1)t=o;else if(i!==1)i=1}else if(t!==-1)i=-1}if(t===-1||r===-1||i===0||i===1&&t===r-1&&t===n+1)return"";return e.slice(t,r)}function hJr(e){if(e===null||typeof e!=="object")throw TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return pJr("/",e)}function bJr(e){Xy(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var n=e.charCodeAt(0),r=n===47,a;if(r)t.root="/",a=1;else a=0;var i=-1,o=0,s=-1,l=!0,u=e.length-1,d=0;for(;u>=a;--u){if(n=e.charCodeAt(u),n===47){if(!l){o=u+1;break}continue}if(s===-1)l=!1,s=u+1;if(n===46){if(i===-1)i=u;else if(d!==1)d=1}else if(i!==-1)d=-1}if(i===-1||s===-1||d===0||d===1&&i===s-1&&i===o+1){if(s!==-1)if(o===0&&r)t.base=t.name=e.slice(1,s);else t.base=t.name=e.slice(o,s)}else{if(o===0&&r)t.name=e.slice(1,i),t.base=e.slice(1,s);else t.name=e.slice(o,i),t.base=e.slice(o,s);t.ext=e.slice(i,s)}if(o>0)t.dir=e.slice(0,o-1);else if(r)t.dir="/";return t}var yJr="/",wJr=":",ihc=((e)=>(e.posix=e,e))({resolve:i5e,normalize:Umn,isAbsolute:mJr,join:Hmn,relative:AJr,_makeLong:gJr,dirname:Wmn,basename:Ymn,extname:fJr,format:hJr,parse:bJr,sep:yJr,delimiter:wJr,win32:null,posix:null});var o5e=/^upload-[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;var fhc=P.object({id:P.string().regex(o5e),ref:P.object({kind:P.string().min(1),id:P.string().regex(o5e)}),filename:P.string().min(1),mediaType:P.string().min(1),sizeBytes:P.number().nonnegative(),createdAt:P.string().datetime(),metadata:P.record(P.string(),P.unknown()).optional()});var _hc=P.record(P.string(),P.unknown()),Ehc=P.object({items:P.array(P.object({operation:P.enum(["upsert","delete"]),id:P.string(),source:a2.optional()}))});var Rhc=P.object({});var{AsyncLocalStorage:gwc}=(()=>({}));var{create:CJr,defineProperty:Yoe,getOwnPropertyDescriptor:xJr,getOwnPropertyNames:_Jr,getPrototypeOf:EJr}=Object,BJr=Object.prototype.hasOwnProperty,Vmn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Zmn=(e,t)=>{let n={};for(var r in e)Yoe(n,r,{get:e[r],enumerable:!0});if(t)Yoe(n,Symbol.toStringTag,{value:"Module"});return n},IJr=(e,t,n,r)=>{if(t&&typeof t==="object"||typeof t==="function"){for(var a=_Jr(t),i=0,o=a.length,s;i<o;i++)if(s=a[i],!BJr.call(e,s)&&s!==n)Yoe(e,s,{get:((l)=>t[l]).bind(null,s),enumerable:!(r=xJr(t,s))||r.enumerable})}return e},Kmn=(e,t,n)=>(n=e!=null?CJr(EJr(e)):{},IJr(t||!e||!e.__esModule?Yoe(n,"default",{value:e,enumerable:!0}):n,e));var SJr=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Jmn=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),TJr=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),DJr=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function Xmn(e){return typeof e==="string"&&Jmn.has(e.replace(/#$/,""))}function eAn(e,t){if(!("$schema"in e)||typeof e.$schema!=="string")return"2020-12";let n=e.$schema.replace(/#$/,"");if(SJr.has(n))return"2020-12";if(Jmn.has(n))return"2019-09";if(TJr.has(n)||DJr.has(n))return"draft-7";throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var o2="2025-11-25";var Voe=[o2,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Zoe="io.modelcontextprotocol/related-task",s2="io.modelcontextprotocol/protocolVersion",fQ="io.modelcontextprotocol/clientInfo",Yv="io.modelcontextprotocol/serverInfo",Vv="io.modelcontextprotocol/clientCapabilities",p7="io.modelcontextprotocol/subscriptionId",Z1="io.modelcontextprotocol/logLevel";var c2="2.0";var V1=Yk(()=>lr([Ge(),kn(),ir(),db(),nr(Ge(),V1),Wt(V1)])),bc=nr(Ge(),V1),l5e=Wt(V1),m7=lr([Ge(),kn().int()]),A7=Ge(),Koe=St({ttl:kn().optional()}),Joe=St({taskId:Ge()}),g7=$r({progressToken:m7.optional(),[Zoe]:Joe.optional()}),fu=St({_meta:g7.optional()}),l2=fu.extend({task:Koe.optional()}),yc=St({method:Ge(),params:fu.loose().optional()}),Ld=St({_meta:g7.optional()}),Md=St({method:Ge(),params:Ld.loose().optional()}),f7=$r({get[Yv](){return yQ.optional().catch(void 0)}}),wc=$r({_meta:f7.optional()}),K1=lr([Ge(),kn().int()]),h7=St({jsonrpc:Vt(c2),id:K1,...yc.shape}).strict(),b7=St({jsonrpc:Vt(c2),...Md.shape}).strict(),hQ=St({jsonrpc:Vt(c2),id:K1,result:wc}).strict(),bQ=St({jsonrpc:Vt(c2),id:K1.optional(),error:St({code:kn().int(),message:Ge(),data:Er().optional()})}).strict(),Xoe=lr([h7,b7,hQ,bQ]),u5e=lr([hQ,bQ]),y7=wc.strict(),ese=Ld.extend({requestId:K1.optional(),reason:Ge().optional()}),w7=Md.extend({method:Vt("notifications/cancelled"),params:ese}),tse=St({src:Ge(),mimeType:Ge().optional(),sizes:Wt(Ge()).optional(),theme:ca(["light","dark"]).optional()}),J1=St({icons:Wt(tse).optional()}),Wv=St({name:Ge(),title:Ge().optional()}),yQ=Wv.extend({...Wv.shape,...J1.shape,version:Ge(),websiteUrl:Ge().optional(),description:Ge().optional()}),RJr=hf(St({applyDefaults:ir().optional()}),bc),QJr=D0((e)=>{if(e&&typeof e==="object"&&!Array.isArray(e)&&Object.keys(e).length===0)return{form:{}};return e},hf(St({form:RJr.optional(),url:bc.optional()}),bc.optional())),nse=$r({list:bc.optional(),cancel:bc.optional(),requests:$r({sampling:$r({createMessage:bc.optional()}).optional(),elicitation:$r({create:bc.optional()}).optional()}).optional()}),rse=$r({list:bc.optional(),cancel:bc.optional(),requests:$r({tools:$r({call:bc.optional()}).optional()}).optional()}),ase=St({experimental:nr(Ge(),bc).optional(),sampling:St({context:bc.optional(),tools:bc.optional()}).optional(),elicitation:QJr.optional(),roots:St({listChanged:ir().optional()}).optional(),tasks:nse.optional(),extensions:nr(Ge(),bc).optional()}),ise=fu.extend({protocolVersion:Ge(),capabilities:ase,clientInfo:yQ}),ose=yc.extend({method:Vt("initialize"),params:ise}),v7=St({experimental:nr(Ge(),bc).optional(),logging:bc.optional(),completions:bc.optional(),prompts:St({listChanged:ir().optional()}).optional(),resources:St({subscribe:ir().optional(),listChanged:ir().optional()}).optional(),tools:St({listChanged:ir().optional()}).optional(),tasks:rse.optional(),extensions:nr(Ge(),bc).optional()}),sse=wc.extend({protocolVersion:Ge(),capabilities:v7,serverInfo:yQ,instructions:Ge().optional()}),cse=Md.extend({method:Vt("notifications/initialized"),params:Ld.optional()}),lse=yc.extend({method:Vt("server/discover"),params:fu.optional()}),use=wc.extend({supportedVersions:Wt(Ge()),capabilities:v7,instructions:Ge().optional()}),k7=yc.extend({method:Vt("ping"),params:fu.optional()}),dse=St({progress:kn(),total:Br(kn()),message:Br(Ge())}),pse=St({...Ld.shape,...dse.shape,progressToken:m7}),C7=Md.extend({method:Vt("notifications/progress"),params:pse}),mse=fu.extend({cursor:A7.optional()}),X1=yc.extend({params:mse.optional()}),e_=wc.extend({nextCursor:A7.optional()}),x7=St({uri:Ge(),mimeType:Br(Ge()),_meta:nr(Ge(),Er()).optional()}),_7=x7.extend({text:Ge()}),d5e=Ge().refine((e)=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),E7=x7.extend({blob:d5e}),t_=ca(["user","assistant"]),Zv=St({audience:Wt(t_).optional(),priority:kn().min(0).max(1).optional(),lastModified:cA.datetime({offset:!0}).optional()}),B7=St({...Wv.shape,...J1.shape,uri:Ge(),description:Br(Ge()),mimeType:Br(Ge()),size:Br(kn()),annotations:Zv.optional(),_meta:Br($r({}))}),Ase=St({...Wv.shape,...J1.shape,uriTemplate:Ge(),description:Br(Ge()),mimeType:Br(Ge()),annotations:Zv.optional(),_meta:Br($r({}))}),gse=X1.extend({method:Vt("resources/list")}),fse=e_.extend({resources:Wt(B7)}),hse=X1.extend({method:Vt("resources/templates/list")}),bse=e_.extend({resourceTemplates:Wt(Ase)}),wQ=fu.extend({uri:Ge()}),yse=wQ,wse=yc.extend({method:Vt("resources/read"),params:yse}),vse=wc.extend({contents:Wt(lr([_7,E7]))}),kse=Md.extend({method:Vt("notifications/resources/list_changed"),params:Ld.optional()}),Cse=wQ,xse=yc.extend({method:Vt("resources/subscribe"),params:Cse}),_se=wQ,Ese=yc.extend({method:Vt("resources/unsubscribe"),params:_se}),I7=St({toolsListChanged:ir().optional(),promptsListChanged:ir().optional(),resourcesListChanged:ir().optional(),resourceSubscriptions:Wt(Ge()).optional()}),Bse=fu.extend({notifications:I7}),Ise=yc.extend({method:Vt("subscriptions/listen"),params:Bse}),Sse=Ld.extend({notifications:I7}),Tse=Md.extend({method:Vt("notifications/subscriptions/acknowledged"),params:Sse}),Dse=f7.extend({[p7]:K1}),Rse=wc.extend({_meta:Dse}),Qse=Ld.extend({uri:Ge()}),Lse=Md.extend({method:Vt("notifications/resources/updated"),params:Qse}),Mse=St({name:Ge(),description:Br(Ge()),required:Br(ir())}),Fse=St({...Wv.shape,...J1.shape,description:Br(Ge()),arguments:Br(Wt(Mse)),_meta:Br($r({}))}),Nse=X1.extend({method:Vt("prompts/list")}),Pse=e_.extend({prompts:Wt(Fse)}),$se=fu.extend({name:Ge(),arguments:nr(Ge(),Ge()).optional()}),Ose=yc.extend({method:Vt("prompts/get"),params:$se}),vQ=St({type:Vt("text"),text:Ge(),annotations:Zv.optional(),_meta:nr(Ge(),Er()).optional()}),kQ=St({type:Vt("image"),data:d5e,mimeType:Ge(),annotations:Zv.optional(),_meta:nr(Ge(),Er()).optional()}),CQ=St({type:Vt("audio"),data:d5e,mimeType:Ge(),annotations:Zv.optional(),_meta:nr(Ge(),Er()).optional()}),zse=St({type:Vt("tool_use"),name:Ge(),id:Ge(),input:nr(Ge(),Er()),_meta:nr(Ge(),Er()).optional()}),jse=St({type:Vt("resource"),resource:lr([_7,E7]),annotations:Zv.optional(),_meta:nr(Ge(),Er()).optional()}),qse=B7.extend({type:Vt("resource_link")}),xQ=lr([vQ,kQ,CQ,qse,jse]),Gse=St({role:t_,content:xQ}),Use=wc.extend({description:Ge().optional(),messages:Wt(Gse)}),Hse=Md.extend({method:Vt("notifications/prompts/list_changed"),params:Ld.optional()}),Wse=St({title:Ge().optional(),readOnlyHint:ir().optional(),destructiveHint:ir().optional(),idempotentHint:ir().optional(),openWorldHint:ir().optional()}),Yse=St({taskSupport:ca(["required","optional","forbidden"]).optional()}),S7=St({...Wv.shape,...J1.shape,description:Ge().optional(),inputSchema:St({type:Vt("object"),properties:nr(Ge(),V1).optional(),required:Wt(Ge()).optional()}).catchall(Er()),outputSchema:$r({$schema:Ge().optional()}).optional(),annotations:Wse.optional(),execution:Yse.optional(),_meta:nr(Ge(),Er()).optional()}),Vse=X1.extend({method:Vt("tools/list")}),Zse=e_.extend({tools:Wt(S7)}),T7=wc.extend({content:Wt(xQ).default([]),structuredContent:Er().optional(),isError:ir().optional()}),p5e=T7.or(wc.extend({toolResult:Er()})),Kse=l2.extend({name:Ge(),arguments:nr(Ge(),Er()).optional()}),Jse=yc.extend({method:Vt("tools/call"),params:Kse}),Xse=Md.extend({method:Vt("notifications/tools/list_changed"),params:Ld.optional()}),m5e=St({autoRefresh:ir().default(!0),debounceMs:kn().int().nonnegative().default(300)}),n_=ca(["debug","info","notice","warning","error","critical","alert","emergency"]),ece=fu.extend({level:n_}),tce=yc.extend({method:Vt("logging/setLevel"),params:ece}),nce=Ld.extend({level:n_,logger:Ge().optional(),data:Er()}),rce=Md.extend({method:Vt("notifications/message"),params:nce}),ace=St({name:Ge().optional()}),ice=St({hints:Wt(ace).optional(),costPriority:kn().min(0).max(1).optional(),speedPriority:kn().min(0).max(1).optional(),intelligencePriority:kn().min(0).max(1).optional()}),oce=St({mode:ca(["auto","required","none"]).optional()}),sce=St({type:Vt("tool_result"),toolUseId:Ge().describe("The unique identifier for the corresponding tool call."),content:Wt(xQ),structuredContent:Er().optional(),isError:ir().optional(),_meta:nr(Ge(),Er()).optional()}),cce=Wk("type",[vQ,kQ,CQ]),i2=Wk("type",[vQ,kQ,CQ,zse,sce]),lce=St({role:t_,content:lr([i2,Wt(i2)]),_meta:nr(Ge(),Er()).optional()}),uce=l2.extend({messages:Wt(lce),modelPreferences:ice.optional(),systemPrompt:Ge().optional(),includeContext:ca(["none","thisServer","allServers"]).optional(),temperature:kn().optional(),maxTokens:kn().int(),stopSequences:Wt(Ge()).optional(),metadata:bc.optional(),tools:Wt(S7).optional(),toolChoice:oce.optional()}),dce=yc.extend({method:Vt("sampling/createMessage"),params:uce}),pce=wc.extend({model:Ge(),stopReason:Br(ca(["endTurn","stopSequence","maxTokens"]).or(Ge())),role:t_,content:cce}),mce=wc.extend({model:Ge(),stopReason:Br(ca(["endTurn","stopSequence","maxTokens","toolUse"]).or(Ge())),role:t_,content:lr([i2,Wt(i2)])}),D7=St({type:Vt("boolean"),title:Ge().optional(),description:Ge().optional(),default:ir().optional()}),_Q=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),minLength:kn().optional(),maxLength:kn().optional(),format:ca(["email","uri","date","date-time"]).optional(),default:Ge().optional()}),EQ=St({type:ca(["number","integer"]),title:Ge().optional(),description:Ge().optional(),minimum:kn().optional(),maximum:kn().optional(),default:kn().optional()}),R7=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),enum:Wt(Ge()),default:Ge().optional()}),Q7=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),oneOf:Wt(St({const:Ge(),title:Ge()})),default:Ge().optional()}),L7=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),enum:Wt(Ge()),enumNames:Wt(Ge()).optional(),default:Ge().optional()}),Ace=lr([R7,Q7]),M7=St({type:Vt("array"),title:Ge().optional(),description:Ge().optional(),minItems:kn().optional(),maxItems:kn().optional(),items:St({type:Vt("string"),enum:Wt(Ge())}),default:Wt(Ge()).optional()}),F7=St({type:Vt("array"),title:Ge().optional(),description:Ge().optional(),minItems:kn().optional(),maxItems:kn().optional(),items:St({anyOf:Wt(St({const:Ge(),title:Ge()}))}),default:Wt(Ge()).optional()}),gce=lr([M7,F7]),fce=lr([L7,Ace,gce]),N7=lr([fce,D7,_Q,EQ]),BQ=l2.extend({mode:Vt("form").optional(),message:Ge(),requestedSchema:St({type:Vt("object"),properties:nr(Ge(),N7),required:Wt(Ge()).optional()}).catchall(Er())}),hce=l2.extend({mode:Vt("url"),message:Ge(),elicitationId:Ge(),url:Ge().url()}),bce=lr([BQ,hce]),yce=yc.extend({method:Vt("elicitation/create"),params:bce}),wce=Ld.extend({elicitationId:Ge()}),vce=Md.extend({method:Vt("notifications/elicitation/complete"),params:wce}),kce=wc.extend({action:ca(["accept","decline","cancel"]),content:D0((e)=>e===null?void 0:e,nr(Ge(),lr([Ge(),kn(),ir(),Wt(Ge())])).optional())}),Cce=St({type:Vt("ref/resource"),uri:Ge()}),xce=St({type:Vt("ref/prompt"),name:Ge()}),_ce=fu.extend({ref:lr([xce,Cce]),argument:St({name:Ge(),value:Ge()}),context:St({arguments:nr(Ge(),Ge()).optional()}).optional()}),Ece=yc.extend({method:Vt("completion/complete"),params:_ce}),Bce=wc.extend({completion:$r({values:Wt(Ge()).max(100),total:Br(kn().int()),hasMore:Br(ir())})}),Ice=St({uri:Ge().startsWith("file://"),name:Ge().optional(),_meta:nr(Ge(),Er()).optional()}),Sce=yc.extend({method:Vt("roots/list"),params:fu.optional()}),Tce=wc.extend({roots:Wt(Ice)}),Dce=Md.extend({method:Vt("notifications/roots/list_changed"),params:Ld.optional()}),A5e=$r({ttl:kn().optional(),pollInterval:kn().optional()}),Rce=ca(["working","input_required","completed","failed","cancelled"]),r_=St({taskId:Ge(),status:Rce,ttl:lr([kn(),db()]),createdAt:Ge(),lastUpdatedAt:Ge(),pollInterval:Br(kn()),statusMessage:Br(Ge())}),g5e=wc.extend({task:r_}),Qce=Ld.merge(r_),f5e=Md.extend({method:Vt("notifications/tasks/status"),params:Qce}),h5e=yc.extend({method:Vt("tasks/get"),params:fu.extend({taskId:Ge()})}),b5e=wc.merge(r_),y5e=yc.extend({method:Vt("tasks/result"),params:fu.extend({taskId:Ge()})}),w5e=wc.loose(),v5e=X1.extend({method:Vt("tasks/list")}),k5e=e_.extend({tasks:Wt(r_)}),C5e=yc.extend({method:Vt("tasks/cancel"),params:fu.extend({taskId:Ge()})}),x5e=wc.merge(r_),_5e=lr([k7,ose,lse,Ece,tce,Ose,Nse,gse,hse,wse,xse,Ese,Ise,Jse,Vse]),E5e=lr([w7,C7,cse,Dce]),B5e=lr([y7,pce,mce,kce,Tce]),I5e=lr([k7,dce,yce,Sce]),S5e=lr([w7,C7,rce,Lse,kse,Xse,Hse,Tse,vce]),T5e=lr([y7,sse,use,Bce,Use,Pse,fse,bse,vse,T7,Zse,Rse]),gu=UT().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Rbe.custom,message:"URL must be parseable",fatal:!0}),dL}).refine((e)=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),D5e=$r({resource:Ge().url(),authorization_servers:Wt(gu).optional(),jwks_uri:Ge().url().optional(),scopes_supported:Wt(Ge()).optional(),bearer_methods_supported:Wt(Ge()).optional(),resource_signing_alg_values_supported:Wt(Ge()).optional(),resource_name:Ge().optional(),resource_documentation:Ge().optional(),resource_policy_uri:Ge().url().optional(),resource_tos_uri:Ge().url().optional(),tls_client_certificate_bound_access_tokens:ir().optional(),authorization_details_types_supported:Wt(Ge()).optional(),dpop_signing_alg_values_supported:Wt(Ge()).optional(),dpop_bound_access_tokens_required:ir().optional()}),Lce=$r({issuer:Ge(),authorization_endpoint:gu,token_endpoint:gu,registration_endpoint:gu.optional(),scopes_supported:Wt(Ge()).optional(),response_types_supported:Wt(Ge()),response_modes_supported:Wt(Ge()).optional(),grant_types_supported:Wt(Ge()).optional(),token_endpoint_auth_methods_supported:Wt(Ge()).optional(),token_endpoint_auth_signing_alg_values_supported:Wt(Ge()).optional(),service_documentation:gu.optional(),revocation_endpoint:gu.optional(),revocation_endpoint_auth_methods_supported:Wt(Ge()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Wt(Ge()).optional(),introspection_endpoint:Ge().optional(),introspection_endpoint_auth_methods_supported:Wt(Ge()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Wt(Ge()).optional(),code_challenge_methods_supported:Wt(Ge()).optional(),client_id_metadata_document_supported:ir().optional(),authorization_response_iss_parameter_supported:ir().optional().catch(void 0)}),Mce=$r({issuer:Ge(),authorization_endpoint:gu,token_endpoint:gu,userinfo_endpoint:gu.optional(),jwks_uri:gu,registration_endpoint:gu.optional(),scopes_supported:Wt(Ge()).optional(),response_types_supported:Wt(Ge()),response_modes_supported:Wt(Ge()).optional(),grant_types_supported:Wt(Ge()).optional(),acr_values_supported:Wt(Ge()).optional(),subject_types_supported:Wt(Ge()),id_token_signing_alg_values_supported:Wt(Ge()),id_token_encryption_alg_values_supported:Wt(Ge()).optional(),id_token_encryption_enc_values_supported:Wt(Ge()).optional(),userinfo_signing_alg_values_supported:Wt(Ge()).optional(),userinfo_encryption_alg_values_supported:Wt(Ge()).optional(),userinfo_encryption_enc_values_supported:Wt(Ge()).optional(),request_object_signing_alg_values_supported:Wt(Ge()).optional(),request_object_encryption_alg_values_supported:Wt(Ge()).optional(),request_object_encryption_enc_values_supported:Wt(Ge()).optional(),token_endpoint_auth_methods_supported:Wt(Ge()).optional(),token_endpoint_auth_signing_alg_values_supported:Wt(Ge()).optional(),display_values_supported:Wt(Ge()).optional(),claim_types_supported:Wt(Ge()).optional(),claims_supported:Wt(Ge()).optional(),service_documentation:Ge().optional(),claims_locales_supported:Wt(Ge()).optional(),ui_locales_supported:Wt(Ge()).optional(),claims_parameter_supported:ir().optional(),request_parameter_supported:ir().optional(),request_uri_parameter_supported:ir().optional(),require_request_uri_registration:ir().optional(),op_policy_uri:gu.optional(),op_tos_uri:gu.optional(),client_id_metadata_document_supported:ir().optional(),authorization_response_iss_parameter_supported:ir().optional().catch(void 0)}),R5e=St({...Mce.shape,...Lce.pick({code_challenge_methods_supported:!0}).shape}),Q5e=St({access_token:Ge(),id_token:Ge().optional(),token_type:Ge(),expires_in:WL.number().optional(),scope:Ge().optional(),refresh_token:Ge().optional()}).strip(),L5e=St({issued_token_type:Vt("urn:ietf:params:oauth:token-type:id-jag"),access_token:Ge(),token_type:Ge().optional(),expires_in:kn().optional(),scope:Ge().optional()}).strip(),M5e=St({error:Ge(),error_description:Ge().optional(),error_uri:Ge().optional()}),c5e=gu.optional().or(Vt("").transform(()=>{return})),Fce=St({redirect_uris:Wt(gu),token_endpoint_auth_method:Ge().optional(),grant_types:Wt(Ge()).optional(),response_types:Wt(Ge()).optional(),application_type:Ge().optional(),client_name:Ge().optional(),client_uri:gu.optional(),logo_uri:c5e,scope:Ge().optional(),contacts:Wt(Ge()).optional(),tos_uri:c5e,policy_uri:Ge().optional(),jwks_uri:gu.optional(),jwks:jG().optional(),software_id:Ge().optional(),software_version:Ge().optional(),software_statement:Ge().optional()}).strip(),Nce=St({client_id:Ge(),client_secret:Ge().optional(),client_id_issued_at:kn().optional(),client_secret_expires_at:kn().optional()}).strip(),F5e=Fce.merge(Nce),N5e=St({error:Ge(),error_description:Ge().optional()}).strip(),P5e=St({token:Ge(),token_type_hint:Ge().optional()}).strip();var j5e=Symbol.for("mcp.sdk.errorBrands");function Y5e(e,t){let n=new Set,r=t;while(typeof r==="function"){let a=r.mcpBrand;if(Object.prototype.hasOwnProperty.call(r,"mcpBrand")&&typeof a==="string")n.add(a);r=Object.getPrototypeOf(r)}if(n.size===0)return;Object.defineProperty(e,j5e,{value:n,enumerable:!1,configurable:!0})}function SQ(e,t){try{if(typeof t==="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand==="string"&&Object.prototype.hasOwnProperty.call(t,j5e)){let n=t[j5e];if(n&&typeof n.has==="function"&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var LJr=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return SQ(this,t)}static isInstance(t){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return SQ(this,t)}constructor(t,n,r){super(n);this.code=t,this.errorUri=r,this.name="OAuthError",Y5e(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};if(this.errorUri)t.error_uri=this.errorUri;return t}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}},oi=function(e){return e.NotConnected="NOT_CONNECTED",e.AlreadyConnected="ALREADY_CONNECTED",e.NotInitialized="NOT_INITIALIZED",e.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",e.RequestTimeout="REQUEST_TIMEOUT",e.ConnectionClosed="CONNECTION_CLOSED",e.SendFailed="SEND_FAILED",e.InvalidResult="INVALID_RESULT",e.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",e.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",e.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",e.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",e.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",e.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",e.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",e.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",e.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",e.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",e.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",e}({}),$a=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return SQ(this,e)}static isInstance(e){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return SQ(this,e)}constructor(e,t,n){super(t);this.code=e,this.data=n,this.name="SdkError",Y5e(this,new.target)}},MJr=class extends $a{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,n){super(e,t,n);this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};function uAn(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function FJr(e,t,n){return e==="elicitation"&&t==="form"&&n.form===void 0&&n.url===void 0}function vAn(e){switch(e.method){case"elicitation/create":if(e.params?.mode==="url")return{elicitation:{url:{}}};return{elicitation:{form:{}}};case"sampling/createMessage":{let t=e.params;if(t!==void 0&&(t.tools!==void 0||t.toolChoice!==void 0))return{sampling:{tools:{}}};return{sampling:{}}}case"roots/list":return{roots:{}};default:return}}function Gce(e,t){let n={};for(let[r,a]of Object.entries(e)){if(a===void 0)continue;let i=t===void 0?void 0:t[r];if(i===void 0){n[r]=a;continue}if(uAn(a)&&uAn(i)){let o={};for(let[s,l]of Object.entries(a))if(l!==void 0&&i[s]===void 0&&!FJr(r,s,i))o[s]=l;if(Object.keys(o).length>0)n[r]=o}}return Object.keys(n).length>0?n:void 0}var NJr="2026-07-28";function q7(e){return e>=NJr}function kAn(e){return e.filter((t)=>!q7(t))}function V5e(e){return e.filter((t)=>q7(t))}function CAn(e){let t=e.structuredContent;if(t===void 0)return e;if(!(typeof t!=="object"||t===null||Array.isArray(t)))return e;if(e.content?.some((n)=>n.type==="text")??!1)return e;return{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}var xAn=["task","inputRequests","requestState"];function Z5e(e){if(e===null||typeof e!=="object"||Array.isArray(e)||e.content!==void 0||xAn.some((t)=>(t in e)))return e;return{...e,content:[]}}function PJr(){let e=Yk(()=>lr([Ge(),kn(),ir(),db(),nr(Ge(),e),Wt(e)])),t=nr(Ge(),e),n=lr([Ge(),kn().int()]),r=Ge(),a=St({ttl:kn().optional()}),i=St({taskId:Ge()}),o=$r({progressToken:n.optional(),"io.modelcontextprotocol/related-task":i.optional()}),s=St({_meta:o.optional()}),l=s.extend({task:a.optional()}),u=St({method:Ge(),params:s.loose().optional()}),d=St({_meta:o.optional()}),p=St({method:Ge(),params:d.loose().optional()}),m=$r({_meta:o.optional()}),A=lr([Ge(),kn().int()]),f=m.strict(),y=d.extend({requestId:A.optional(),reason:Ge().optional()}),v=p.extend({method:Vt("notifications/cancelled"),params:y}),x=St({src:Ge(),mimeType:Ge().optional(),sizes:Wt(Ge()).optional(),theme:ca(["light","dark"]).optional()}),_=St({icons:Wt(x).optional()}),E=St({name:Ge(),title:Ge().optional()}),F=E.extend({...E.shape,..._.shape,version:Ge(),websiteUrl:Ge().optional(),description:Ge().optional()}),T=hf(St({applyDefaults:ir().optional()}),t),R=D0((Na)=>{if(Na&&typeof Na==="object"&&!Array.isArray(Na)&&Object.keys(Na).length===0)return{form:{}};return Na},hf(St({form:T.optional(),url:t.optional()}),t.optional())),O=$r({list:t.optional(),cancel:t.optional(),requests:$r({sampling:$r({createMessage:t.optional()}).optional(),elicitation:$r({create:t.optional()}).optional()}).optional()}),j=$r({list:t.optional(),cancel:t.optional(),requests:$r({tools:$r({call:t.optional()}).optional()}).optional()}),H=St({experimental:nr(Ge(),t).optional(),sampling:St({context:t.optional(),tools:t.optional()}).optional(),elicitation:R.optional(),roots:St({listChanged:ir().optional()}).optional(),tasks:O.optional(),extensions:nr(Ge(),t).optional()}),G=s.extend({protocolVersion:Ge(),capabilities:H,clientInfo:F}),W=u.extend({method:Vt("initialize"),params:G}),b=St({experimental:nr(Ge(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:St({listChanged:ir().optional()}).optional(),resources:St({subscribe:ir().optional(),listChanged:ir().optional()}).optional(),tools:St({listChanged:ir().optional()}).optional(),tasks:j.optional(),extensions:nr(Ge(),t).optional()}),k=m.extend({protocolVersion:Ge(),capabilities:b,serverInfo:F,instructions:Ge().optional()}),I=p.extend({method:Vt("notifications/initialized"),params:d.optional()}),C=u.extend({method:Vt("ping"),params:s.optional()}),B=St({progress:kn(),total:Br(kn()),message:Br(Ge())}),L=St({...d.shape,...B.shape,progressToken:n}),M=p.extend({method:Vt("notifications/progress"),params:L}),Q=s.extend({cursor:r.optional()}),w=u.extend({params:Q.optional()}),N=m.extend({nextCursor:r.optional()}),U=St({uri:Ge(),mimeType:Br(Ge()),_meta:nr(Ge(),Er()).optional()}),q=U.extend({text:Ge()}),Z=Ge().refine((Na)=>{try{return atob(Na),!0}catch{return!1}},{message:"Invalid Base64 string"}),ee=U.extend({blob:Z}),ne=ca(["user","assistant"]),re=St({audience:Wt(ne).optional(),priority:kn().min(0).max(1).optional(),lastModified:cA.datetime({offset:!0}).optional()}),ke=St({...E.shape,..._.shape,uri:Ge(),description:Br(Ge()),mimeType:Br(Ge()),size:Br(kn()),annotations:re.optional(),_meta:Br($r({}))}),se=St({...E.shape,..._.shape,uriTemplate:Ge(),description:Br(Ge()),mimeType:Br(Ge()),annotations:re.optional(),_meta:Br($r({}))}),he=w.extend({method:Vt("resources/list")}),ce=N.extend({resources:Wt(ke)}),ge=w.extend({method:Vt("resources/templates/list")}),Qe=N.extend({resourceTemplates:Wt(se)}),Oe=s.extend({uri:Ge()}),_e=Oe,Re=u.extend({method:Vt("resources/read"),params:_e}),We=m.extend({contents:Wt(lr([q,ee]))}),be=p.extend({method:Vt("notifications/resources/list_changed"),params:d.optional()}),Te=Oe,Me=u.extend({method:Vt("resources/subscribe"),params:Te}),me=Oe,le=u.extend({method:Vt("resources/unsubscribe"),params:me}),fe=d.extend({uri:Ge()}),ye=p.extend({method:Vt("notifications/resources/updated"),params:fe}),Ce=St({name:Ge(),description:Br(Ge()),required:Br(ir())}),Ie=St({...E.shape,..._.shape,description:Br(Ge()),arguments:Br(Wt(Ce)),_meta:Br($r({}))}),Ee=w.extend({method:Vt("prompts/list")}),J=N.extend({prompts:Wt(Ie)}),Be=s.extend({name:Ge(),arguments:nr(Ge(),Ge()).optional()}),de=u.extend({method:Vt("prompts/get"),params:Be}),te=St({type:Vt("text"),text:Ge(),annotations:re.optional(),_meta:nr(Ge(),Er()).optional()}),De=St({type:Vt("image"),data:Z,mimeType:Ge(),annotations:re.optional(),_meta:nr(Ge(),Er()).optional()}),oe=St({type:Vt("audio"),data:Z,mimeType:Ge(),annotations:re.optional(),_meta:nr(Ge(),Er()).optional()}),ae=St({type:Vt("tool_use"),name:Ge(),id:Ge(),input:nr(Ge(),Er()),_meta:nr(Ge(),Er()).optional()}),Ae=St({type:Vt("resource"),resource:lr([q,ee]),annotations:re.optional(),_meta:nr(Ge(),Er()).optional()}),ue=ke.extend({type:Vt("resource_link")}),we=lr([te,De,oe,ue,Ae]),ze=St({role:ne,content:we}),Le=m.extend({description:Ge().optional(),messages:Wt(ze)}),qe=p.extend({method:Vt("notifications/prompts/list_changed"),params:d.optional()}),et=St({title:Ge().optional(),readOnlyHint:ir().optional(),destructiveHint:ir().optional(),idempotentHint:ir().optional(),openWorldHint:ir().optional()}),Ze=St({taskSupport:ca(["required","optional","forbidden"]).optional()}),He=St({...E.shape,..._.shape,description:Ge().optional(),inputSchema:St({type:Vt("object"),properties:nr(Ge(),e).optional(),required:Wt(Ge()).optional()}).catchall(Er()),outputSchema:St({type:Vt("object"),properties:nr(Ge(),e).optional(),required:Wt(Ge()).optional()}).catchall(Er()).optional(),annotations:et.optional(),execution:Ze.optional(),_meta:nr(Ge(),Er()).optional()}),ot=w.extend({method:Vt("tools/list")}),Ne=N.extend({tools:Wt(He)}),bt=m.extend({content:Wt(we),structuredContent:nr(Ge(),Er()).optional(),isError:ir().optional()}),rt=l.extend({name:Ge(),arguments:nr(Ge(),Er()).optional()}),yt=u.extend({method:Vt("tools/call"),params:rt}),$e=p.extend({method:Vt("notifications/tools/list_changed"),params:d.optional()}),nt=ca(["debug","info","notice","warning","error","critical","alert","emergency"]),st=s.extend({level:nt}),lt=u.extend({method:Vt("logging/setLevel"),params:st}),Tt=d.extend({level:nt,logger:Ge().optional(),data:Er()}),Pe=p.extend({method:Vt("notifications/message"),params:Tt}),vt=St({name:Ge().optional()}),Kt=St({hints:Wt(vt).optional(),costPriority:kn().min(0).max(1).optional(),speedPriority:kn().min(0).max(1).optional(),intelligencePriority:kn().min(0).max(1).optional()}),mt=St({mode:ca(["auto","required","none"]).optional()}),Ve=St({type:Vt("tool_result"),toolUseId:Ge().describe("The unique identifier for the corresponding tool call."),content:Wt(we),structuredContent:St({}).loose().optional(),isError:ir().optional(),_meta:nr(Ge(),Er()).optional()}),Lt=Wk("type",[te,De,oe]),pt=Wk("type",[te,De,oe,ae,Ve]),wt=St({role:ne,content:lr([pt,Wt(pt)]),_meta:nr(Ge(),Er()).optional()}),wn=l.extend({messages:Wt(wt),modelPreferences:Kt.optional(),systemPrompt:Ge().optional(),includeContext:ca(["none","thisServer","allServers"]).optional(),temperature:kn().optional(),maxTokens:kn().int(),stopSequences:Wt(Ge()).optional(),metadata:t.optional(),tools:Wt(He).optional(),toolChoice:mt.optional()}),sn=u.extend({method:Vt("sampling/createMessage"),params:wn}),dn=m.extend({model:Ge(),stopReason:Br(ca(["endTurn","stopSequence","maxTokens"]).or(Ge())),role:ne,content:Lt}),Hn=m.extend({model:Ge(),stopReason:Br(ca(["endTurn","stopSequence","maxTokens","toolUse"]).or(Ge())),role:ne,content:lr([pt,Wt(pt)])}),Cn=St({type:Vt("boolean"),title:Ge().optional(),description:Ge().optional(),default:ir().optional()}),bn=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),minLength:kn().optional(),maxLength:kn().optional(),format:ca(["email","uri","date","date-time"]).optional(),default:Ge().optional()}),Gn=St({type:ca(["number","integer"]),title:Ge().optional(),description:Ge().optional(),minimum:kn().optional(),maximum:kn().optional(),default:kn().optional()}),Nt=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),enum:Wt(Ge()),default:Ge().optional()}),jt=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),oneOf:Wt(St({const:Ge(),title:Ge()})),default:Ge().optional()}),an=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),enum:Wt(Ge()),enumNames:Wt(Ge()).optional(),default:Ge().optional()}),On=lr([Nt,jt]),In=St({type:Vt("array"),title:Ge().optional(),description:Ge().optional(),minItems:kn().optional(),maxItems:kn().optional(),items:St({type:Vt("string"),enum:Wt(Ge())}),default:Wt(Ge()).optional()}),er=St({type:Vt("array"),title:Ge().optional(),description:Ge().optional(),minItems:kn().optional(),maxItems:kn().optional(),items:St({anyOf:Wt(St({const:Ge(),title:Ge()}))}),default:Wt(Ge()).optional()}),Tr=lr([In,er]),Jn=lr([an,On,Tr]),ln=lr([Jn,Cn,bn,Gn]),Xt=l.extend({mode:Vt("form").optional(),message:Ge(),requestedSchema:St({type:Vt("object"),properties:nr(Ge(),ln),required:Wt(Ge()).optional()}).catchall(Er())}),gn=l.extend({mode:Vt("url"),message:Ge(),elicitationId:Ge(),url:Ge().url()}),pn=lr([Xt,gn]),mn=u.extend({method:Vt("elicitation/create"),params:pn}),pr=d.extend({elicitationId:Ge()}),at=p.extend({method:Vt("notifications/elicitation/complete"),params:pr}),Si=m.extend({action:ca(["accept","decline","cancel"]),content:D0((Na)=>Na===null?void 0:Na,nr(Ge(),lr([Ge(),kn(),ir(),Wt(Ge())])).optional())}),ut=St({type:Vt("ref/resource"),uri:Ge()}),Lr=St({type:Vt("ref/prompt"),name:Ge()}),Ro=s.extend({ref:lr([Lr,ut]),argument:St({name:Ge(),value:Ge()}),context:St({arguments:nr(Ge(),Ge()).optional()}).optional()}),Nc=u.extend({method:Vt("completion/complete"),params:Ro}),bu=m.extend({completion:$r({values:Wt(Ge()).max(100),total:Br(kn().int()),hasMore:Br(ir())})}),Fd=St({uri:Ge().startsWith("file://"),name:Ge().optional(),_meta:nr(Ge(),Er()).optional()}),nd=u.extend({method:Vt("roots/list"),params:s.optional()}),Pi=m.extend({roots:Wt(Fd)}),ps=p.extend({method:Vt("notifications/roots/list_changed"),params:d.optional()}),Pc=$r({ttl:kn().optional(),pollInterval:kn().optional()}),Ln=ca(["working","input_required","completed","failed","cancelled"]),At=St({taskId:Ge(),status:Ln,ttl:lr([kn(),db()]),createdAt:Ge(),lastUpdatedAt:Ge(),pollInterval:Br(kn()),statusMessage:Br(Ge())}),$t=m.extend({task:At}),Dn=d.merge(At),Yn=p.extend({method:Vt("notifications/tasks/status"),params:Dn}),ea=u.extend({method:Vt("tasks/get"),params:s.extend({taskId:Ge()})}),pa=m.merge(At),ei=u.extend({method:Vt("tasks/result"),params:s.extend({taskId:Ge()})}),Go=m.loose(),wi=w.extend({method:Vt("tasks/list")}),ma=N.extend({tasks:Wt(At)}),$c=u.extend({method:Vt("tasks/cancel"),params:s.extend({taskId:Ge()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:a,RelatedTaskMetadataSchema:i,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:l,RequestSchema:u,NotificationsParamsSchema:d,NotificationSchema:p,ResultSchema:m,RequestIdSchema:A,EmptyResultSchema:f,CancelledNotificationParamsSchema:y,CancelledNotificationSchema:v,IconSchema:x,IconsSchema:_,BaseMetadataSchema:E,ImplementationSchema:F,ClientTasksCapabilitySchema:O,ServerTasksCapabilitySchema:j,ClientCapabilitiesSchema:H,InitializeRequestParamsSchema:G,InitializeRequestSchema:W,ServerCapabilitiesSchema:b,InitializeResultSchema:k,InitializedNotificationSchema:I,PingRequestSchema:C,ProgressSchema:B,ProgressNotificationParamsSchema:L,ProgressNotificationSchema:M,PaginatedRequestParamsSchema:Q,PaginatedRequestSchema:w,PaginatedResultSchema:N,ResourceContentsSchema:U,TextResourceContentsSchema:q,BlobResourceContentsSchema:ee,RoleSchema:ne,AnnotationsSchema:re,ResourceSchema:ke,ResourceTemplateSchema:se,ListResourcesRequestSchema:he,ListResourcesResultSchema:ce,ListResourceTemplatesRequestSchema:ge,ListResourceTemplatesResultSchema:Qe,ResourceRequestParamsSchema:Oe,ReadResourceRequestParamsSchema:_e,ReadResourceRequestSchema:Re,ReadResourceResultSchema:We,ResourceListChangedNotificationSchema:be,SubscribeRequestParamsSchema:Te,SubscribeRequestSchema:Me,UnsubscribeRequestParamsSchema:me,UnsubscribeRequestSchema:le,ResourceUpdatedNotificationParamsSchema:fe,ResourceUpdatedNotificationSchema:ye,PromptArgumentSchema:Ce,PromptSchema:Ie,ListPromptsRequestSchema:Ee,ListPromptsResultSchema:J,GetPromptRequestParamsSchema:Be,GetPromptRequestSchema:de,TextContentSchema:te,ImageContentSchema:De,AudioContentSchema:oe,ToolUseContentSchema:ae,EmbeddedResourceSchema:Ae,ResourceLinkSchema:ue,ContentBlockSchema:we,PromptMessageSchema:ze,GetPromptResultSchema:Le,PromptListChangedNotificationSchema:qe,ToolAnnotationsSchema:et,ToolExecutionSchema:Ze,ToolSchema:He,ListToolsRequestSchema:ot,ListToolsResultSchema:Ne,CallToolResultSchema:bt,CallToolRequestParamsSchema:rt,CallToolRequestSchema:yt,ToolListChangedNotificationSchema:$e,LoggingLevelSchema:nt,SetLevelRequestParamsSchema:st,SetLevelRequestSchema:lt,LoggingMessageNotificationParamsSchema:Tt,LoggingMessageNotificationSchema:Pe,ModelHintSchema:vt,ModelPreferencesSchema:Kt,ToolChoiceSchema:mt,ToolResultContentSchema:Ve,SamplingContentSchema:Lt,SamplingMessageContentBlockSchema:pt,SamplingMessageSchema:wt,CreateMessageRequestParamsSchema:wn,CreateMessageRequestSchema:sn,CreateMessageResultSchema:dn,CreateMessageResultWithToolsSchema:Hn,BooleanSchemaSchema:Cn,StringSchemaSchema:bn,NumberSchemaSchema:Gn,UntitledSingleSelectEnumSchemaSchema:Nt,TitledSingleSelectEnumSchemaSchema:jt,LegacyTitledEnumSchemaSchema:an,SingleSelectEnumSchemaSchema:On,UntitledMultiSelectEnumSchemaSchema:In,TitledMultiSelectEnumSchemaSchema:er,MultiSelectEnumSchemaSchema:Tr,EnumSchemaSchema:Jn,PrimitiveSchemaDefinitionSchema:ln,ElicitRequestFormParamsSchema:Xt,ElicitRequestURLParamsSchema:gn,ElicitRequestParamsSchema:pn,ElicitRequestSchema:mn,ElicitationCompleteNotificationParamsSchema:pr,ElicitationCompleteNotificationSchema:at,ElicitResultSchema:Si,ResourceTemplateReferenceSchema:ut,PromptReferenceSchema:Lr,CompleteRequestParamsSchema:Ro,CompleteRequestSchema:Nc,CompleteResultSchema:bu,RootSchema:Fd,ListRootsRequestSchema:nd,ListRootsResultSchema:Pi,RootsListChangedNotificationSchema:ps,TaskCreationParamsSchema:Pc,TaskStatusSchema:Ln,TaskSchema:At,CreateTaskResultSchema:$t,TaskStatusNotificationParamsSchema:Dn,TaskStatusNotificationSchema:Yn,GetTaskRequestSchema:ea,GetTaskResultSchema:pa,GetTaskPayloadRequestSchema:ei,GetTaskPayloadResultSchema:Go,ListTasksRequestSchema:wi,ListTasksResultSchema:ma,CancelTaskRequestSchema:$c,CancelTaskResultSchema:m.merge(At),ClientRequestSchema:lr([C,W,Nc,lt,de,Ee,he,ge,Re,Me,le,yt,ot,ea,ei,wi,$c]),ClientNotificationSchema:lr([v,M,I,ps,Yn]),ClientResultSchema:lr([f,dn,Hn,Si,Pi,pa,ma,$t]),ServerRequestSchema:lr([C,sn,mn,nd,ea,ei,wi,$c]),ServerNotificationSchema:lr([v,M,Pe,ye,be,$e,qe,Yn,at]),ServerResultSchema:lr([f,k,bu,Le,J,ce,Qe,We,bt,Ne,pa,ma,$t]),CallToolResultWireSchema:Er().superRefine((Na,i_)=>{if(typeof Na!=="object"||Na===null||Array.isArray(Na)||Na.content!==void 0)return;for(let Gm of xAn)if(Gm in Na){i_.addIssue({code:"custom",message:`content is required when the body carries '${Gm}' — another result family cannot default into an empty tools/call success`});return}}).transform(Z5e).pipe(bt)}}var $Jr;function _An(){return $Jr??=PJr()}function EAn(e){return e.type!=="object"}var OJr=new Set(["const","enum","default","examples"]),zJr=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function dAn(e){return e!==void 0&&!(typeof e==="string"&&e.startsWith("#"))}function jJr(e){let t=typeof e.$schema==="string"?e.$schema:void 0;if(dAn(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let n=Xmn(e.$schema)&&e.$recursiveAnchor!==!0,r=(a,i)=>{if(Array.isArray(a))return a.map((l)=>r(l,!1));if(a===null||typeof a!=="object")return a;if(!i&&dAn(a.$id))return a;let o={},s=!1;for(let[l,u]of Object.entries(a))if(i)o[l]=r(u,!1);else if((l==="$ref"||l==="$dynamicRef")&&typeof u==="string")o[l]=u==="#"?"#/properties/result":u.startsWith("#/")?`#/properties/result${u.slice(1)}`:u;else if(l==="$recursiveRef"&&u==="#"&&n)s=!0;else if(OJr.has(l))o[l]=u;else if(zJr.has(l))o[l]=r(u,!0);else o[l]=r(u,!1);if(s)if("$ref"in o)o.allOf=[...Array.isArray(o.allOf)?o.allOf:[],{$ref:"#/properties/result"}];else o.$ref="#/properties/result";return o};return{...t!==void 0&&{$schema:t},type:"object",properties:{result:r(e,!1)},required:["result"]}}var BAn={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},IAn={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},qJr={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Pce;function K5e(){if(Pce)return Pce;let e=_An();return Pce={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},Pce}function SAn(e){return Object.prototype.hasOwnProperty.call(BAn,e)}function TAn(e){return Object.prototype.hasOwnProperty.call(IAn,e)}function GJr(e){return Object.prototype.hasOwnProperty.call(qJr,e)}function UJr(e){return GJr(e)?K5e().resultSchemas[e]:void 0}function HJr(e){return SAn(e)?K5e().requestSchemas[e]:void 0}function WJr(e){return TAn(e)?K5e().notificationSchemas[e]:void 0}var jhc=Object.keys(BAn),qhc=Object.keys(IAn);function q5e(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function $ce(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:"invalid",message:String(n.error)}}var pAn={ok:!1,reason:"not-in-era"};function mAn(e){return q5e(e)&&q5e(e.outputSchema)&&EAn(e.outputSchema)}function AAn(e){return e}var J5e={era:"2025-11-25",hasRequestMethod:SAn,hasNotificationMethod:TAn,validateRequest:(e,t)=>$ce(HJr(e),t),validateResult:(e,t)=>$ce(UJr(e),t),validateNotification:(e,t)=>$ce(WJr(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>pAn,validateInputResponse:()=>pAn,samplingResultVariant:(e,t)=>{let n=_An();return $ce(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)},outboundEnvelope:(e)=>{return},validateEnvelopeMeta:(e)=>[],projectCallToolResult(e,t){let n=CAn(e),r=n.structuredContent;if(r===void 0)return n;let a=typeof r!=="object"||r===null||Array.isArray(r),i=t!==void 0&&EAn(t);if(!a&&!i)return n;return{...n,structuredContent:{result:r}}},decodeResult(e,t){if(q5e(t)&&"resultType"in t){let n={...t};return delete n.resultType,{kind:"complete",result:AAn(n)}}return{kind:"complete",result:AAn(t)}},encodeResult(e,t){if(e!=="tools/list")return t;let n=t.tools;if(!Array.isArray(n)||!n.some((r)=>mAn(r)))return t;return{...t,tools:n.map((r)=>mAn(r)?{...r,outputSchema:jJr(r.outputSchema)}:r)}},encodeErrorCode:(e)=>e===-32002?-32602:e,checkInboundEnvelope:(e)=>{return}};function YJr(){let e=Yk(()=>lr([Ge(),kn(),ir(),db(),nr(Ge(),e),Wt(e)])),t=nr(Ge(),e),n=lr([Ge(),kn().int()]),r=Ge(),a=lr([Ge(),kn().int()]),i=ca(["user","assistant"]),o=ca(["debug","info","notice","warning","error","critical","alert","emergency"]),s=Ge().refine((ma)=>{try{return atob(ma),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=St({ttl:kn().optional()}),u=St({taskId:Ge()}),d=$r({progressToken:n.optional(),"io.modelcontextprotocol/related-task":u.optional()}),p=St({_meta:d.optional()}),m=p.extend({task:l.optional()}),A=St({_meta:d.optional()}),f=St({method:Ge(),params:A.loose().optional()}),y=St({src:Ge(),mimeType:Ge().optional(),sizes:Wt(Ge()).optional(),theme:ca(["light","dark"]).optional()}),v=St({icons:Wt(y).optional()}),x=St({name:Ge(),title:Ge().optional()}),_=x.extend({...x.shape,...v.shape,version:Ge(),websiteUrl:Ge().optional(),description:Ge().optional()}),E=hf(St({applyDefaults:ir().optional()}),t),F=D0((ma)=>{if(ma&&typeof ma==="object"&&!Array.isArray(ma)&&Object.keys(ma).length===0)return{form:{}};return ma},hf(St({form:E.optional(),url:t.optional()}),t.optional())),T=$r({list:t.optional(),cancel:t.optional(),requests:$r({sampling:$r({createMessage:t.optional()}).optional(),elicitation:$r({create:t.optional()}).optional()}).optional()}),R=$r({list:t.optional(),cancel:t.optional(),requests:$r({tools:$r({call:t.optional()}).optional()}).optional()}),O=St({experimental:nr(Ge(),t).optional(),sampling:St({context:t.optional(),tools:t.optional()}).optional(),elicitation:F.optional(),roots:St({listChanged:ir().optional()}).optional(),tasks:T.optional(),extensions:nr(Ge(),t).optional()}),j=St({experimental:nr(Ge(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:St({listChanged:ir().optional()}).optional(),resources:St({subscribe:ir().optional(),listChanged:ir().optional()}).optional(),tools:St({listChanged:ir().optional()}).optional(),tasks:R.optional(),extensions:nr(Ge(),t).optional()}),H=St({progress:kn(),total:Br(kn()),message:Br(Ge())}),G=St({...A.shape,...H.shape,progressToken:n}),W=f.extend({method:Vt("notifications/progress"),params:G}),b=A.extend({level:o,logger:Ge().optional(),data:Er()}),k=f.extend({method:Vt("notifications/message"),params:b}),I=St({uri:Ge(),mimeType:Br(Ge()),_meta:nr(Ge(),Er()).optional()}),C=I.extend({text:Ge()}),B=I.extend({blob:s}),L=St({audience:Wt(i).optional(),priority:kn().min(0).max(1).optional(),lastModified:cA.datetime({offset:!0}).optional()}),M=St({...x.shape,...v.shape,uri:Ge(),description:Br(Ge()),mimeType:Br(Ge()),size:Br(kn()),annotations:L.optional(),_meta:Br($r({}))}),Q=St({...x.shape,...v.shape,uriTemplate:Ge(),description:Br(Ge()),mimeType:Br(Ge()),annotations:L.optional(),_meta:Br($r({}))}),w=f.extend({method:Vt("notifications/resources/list_changed"),params:A.optional()}),N=A.extend({uri:Ge()}),U=f.extend({method:Vt("notifications/resources/updated"),params:N}),q=St({name:Ge(),description:Br(Ge()),required:Br(ir())}),Z=St({...x.shape,...v.shape,description:Br(Ge()),arguments:Br(Wt(q)),_meta:Br($r({}))}),ee=f.extend({method:Vt("notifications/prompts/list_changed"),params:A.optional()}),ne=St({type:Vt("text"),text:Ge(),annotations:L.optional(),_meta:nr(Ge(),Er()).optional()}),re=St({type:Vt("image"),data:s,mimeType:Ge(),annotations:L.optional(),_meta:nr(Ge(),Er()).optional()}),ke=St({type:Vt("audio"),data:s,mimeType:Ge(),annotations:L.optional(),_meta:nr(Ge(),Er()).optional()}),se=St({type:Vt("tool_use"),name:Ge(),id:Ge(),input:nr(Ge(),Er()),_meta:nr(Ge(),Er()).optional()}),he=St({type:Vt("resource"),resource:lr([C,B]),annotations:L.optional(),_meta:nr(Ge(),Er()).optional()}),ce=M.extend({type:Vt("resource_link")}),ge=lr([ne,re,ke,ce,he]),Qe=St({role:i,content:ge}),Oe=St({title:Ge().optional(),readOnlyHint:ir().optional(),destructiveHint:ir().optional(),idempotentHint:ir().optional(),openWorldHint:ir().optional()}),_e=f.extend({method:Vt("notifications/tools/list_changed"),params:A.optional()}),Re=St({name:Ge().optional()}),We=St({hints:Wt(Re).optional(),costPriority:kn().min(0).max(1).optional(),speedPriority:kn().min(0).max(1).optional(),intelligencePriority:kn().min(0).max(1).optional()}),be=St({mode:ca(["auto","required","none"]).optional()}),Te=St({type:Vt("boolean"),title:Ge().optional(),description:Ge().optional(),default:ir().optional()}),Me=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),minLength:kn().optional(),maxLength:kn().optional(),format:ca(["email","uri","date","date-time"]).optional(),default:Ge().optional()}),me=St({type:ca(["number","integer"]),title:Ge().optional(),description:Ge().optional(),minimum:kn().optional(),maximum:kn().optional(),default:kn().optional()}),le=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),enum:Wt(Ge()),default:Ge().optional()}),fe=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),oneOf:Wt(St({const:Ge(),title:Ge()})),default:Ge().optional()}),ye=St({type:Vt("string"),title:Ge().optional(),description:Ge().optional(),enum:Wt(Ge()),enumNames:Wt(Ge()).optional(),default:Ge().optional()}),Ce=lr([le,fe]),Ie=St({type:Vt("array"),title:Ge().optional(),description:Ge().optional(),minItems:kn().optional(),maxItems:kn().optional(),items:St({type:Vt("string"),enum:Wt(Ge())}),default:Wt(Ge()).optional()}),Ee=St({type:Vt("array"),title:Ge().optional(),description:Ge().optional(),minItems:kn().optional(),maxItems:kn().optional(),items:St({anyOf:Wt(St({const:Ge(),title:Ge()}))}),default:Wt(Ge()).optional()}),J=lr([Ie,Ee]),Be=lr([ye,Ce,J]),de=lr([Be,Te,Me,me]),te=m.extend({mode:Vt("form").optional(),message:Ge(),requestedSchema:St({type:Vt("object"),properties:nr(Ge(),de),required:Wt(Ge()).optional()}).catchall(Er())}),De=St({type:Vt("ref/resource"),uri:Ge()}),oe=St({type:Vt("ref/prompt"),name:Ge()}),ae=St({uri:Ge().startsWith("file://"),name:Ge().optional(),_meta:nr(Ge(),Er()).optional()}),Ae=O.shape,ue=St({experimental:Ae.experimental,sampling:Ae.sampling,elicitation:Ae.elicitation,roots:Ae.roots,extensions:Ae.extensions}),we=j.shape,ze=St({experimental:we.experimental,logging:we.logging,completions:we.completions,prompts:we.prompts,resources:we.resources,tools:we.tools,extensions:we.extensions}),Le=$r({progressToken:n.optional(),[s2]:Ge(),[fQ]:_.optional(),[Vv]:ue,[Z1]:o.optional()}),qe=St({...x.shape,...v.shape,description:Ge().optional(),inputSchema:$r({$schema:Ge().optional(),type:Vt("object")}),outputSchema:$r({$schema:Ge().optional()}).optional(),annotations:Oe.optional(),_meta:nr(Ge(),Er()).optional()}),et=St({type:Vt("tool_result"),toolUseId:Ge(),content:Wt(ge),structuredContent:Er().optional(),isError:ir().optional(),_meta:nr(Ge(),Er()).optional()}),Ze=lr([ne,re,ke,se,et]),He=St({role:i,content:lr([Ze,Wt(Ze)]),_meta:nr(Ge(),Er()).optional()}),ot=Ge(),Ne=$r({[Yv]:_.optional().catch(void 0)}),bt=Ne.optional();function rt(ma){return $r({_meta:bt,resultType:ot.default("complete"),...ma})}let yt=rt({}),$e=rt({nextCursor:r.optional()}),nt=rt({content:Wt(ge),structuredContent:Er().optional(),isError:ir().optional()}),st=rt({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),tools:Wt(qe),nextCursor:r.optional()}),lt=rt({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),prompts:Wt(Z),nextCursor:r.optional()}),Tt=rt({description:Ge().optional(),messages:Wt(Qe)}),Pe=rt({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),resources:Wt(M),nextCursor:r.optional()}),vt=rt({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),resourceTemplates:Wt(Q),nextCursor:r.optional()}),Kt=rt({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),contents:Wt(lr([C,B]))}),mt=rt({completion:St({values:Wt(Ge()).max(100),total:kn().int().optional(),hasMore:ir().optional()}).loose()}),Ve=rt({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"])}),Lt=rt({ttlMs:kn().int().min(0).catch(0),cacheScope:ca(["public","private"]).catch("private"),supportedVersions:Wt(Ge()),capabilities:ze,instructions:Ge().optional()}),pt=St({messages:Wt(He),modelPreferences:We.optional(),systemPrompt:Ge().optional(),includeContext:ca(["none","thisServer","allServers"]).optional(),temperature:kn().optional(),maxTokens:kn().int(),stopSequences:Wt(Ge()).optional(),metadata:t.optional(),tools:Wt(qe).optional(),toolChoice:be.optional()}),wt=St({method:Vt("sampling/createMessage"),params:pt}),wn=St({method:Vt("roots/list"),params:St({_meta:nr(Ge(),Er()).optional()}).optional()}),sn=St({...He.shape,model:Ge(),stopReason:Ge().optional()}),dn=St({roots:Wt(ae)}),Hn=St({action:ca(["accept","decline","cancel"]),content:nr(Ge(),lr([Ge(),kn(),ir(),Wt(Ge())])).optional()}),Cn=St({mode:Vt("url"),message:Ge(),url:Ge().url()}),bn=lr([te,Cn]),Gn=St({method:Vt("elicitation/create"),params:bn}),Nt=lr([wt,wn,Gn]),jt=lr([sn,dn,Hn]),an=nr(Ge(),Nt),On=nr(Ge(),jt),In=rt({inputRequests:an.optional(),requestState:Ge().optional()}),er={inputResponses:On.optional(),requestState:Ge().optional()},Tr=St({_meta:Le,...er}),Jn=$r({progressToken:n.optional()});function ln(ma,$c){return St({method:Vt(ma),params:St({_meta:Le,...$c})})}function Xt(ma,$c){return St({method:Vt(ma),params:St({_meta:Jn.optional(),...$c}).optional()})}let gn={name:Ge(),arguments:nr(Ge(),Er()).optional(),...er},pn={cursor:r.optional()},mn=ln("tools/call",gn),pr=ln("tools/list",pn),at=ln("prompts/list",pn),Si=ln("prompts/get",{name:Ge(),arguments:nr(Ge(),Ge()).optional(),...er}),ut=ln("resources/list",pn),Lr=ln("resources/templates/list",pn),Ro=ln("resources/read",{uri:Ge(),...er}),Nc={ref:lr([oe,De]),argument:St({name:Ge(),value:Ge()}),context:St({arguments:nr(Ge(),Ge()).optional()}).optional()},bu=ln("completion/complete",Nc),Fd=ln("server/discover",{}),nd=St({toolsListChanged:ir().optional(),promptsListChanged:ir().optional(),resourcesListChanged:ir().optional(),resourceSubscriptions:Wt(Ge()).optional()}),Pi={notifications:nd},ps=ln("subscriptions/listen",Pi),Pc=Ne.extend({"io.modelcontextprotocol/subscriptionId":a}),Ln=$r({_meta:Pc,resultType:ot.default("complete")}),At={"tools/call":Xt("tools/call",gn),"tools/list":Xt("tools/list",pn),"prompts/get":Xt("prompts/get",{name:Ge(),arguments:nr(Ge(),Ge()).optional()}),"prompts/list":Xt("prompts/list",pn),"resources/list":Xt("resources/list",pn),"resources/templates/list":Xt("resources/templates/list",pn),"resources/read":Xt("resources/read",{uri:Ge()}),"completion/complete":Xt("completion/complete",Nc),"server/discover":Xt("server/discover",{}),"subscriptions/listen":Xt("subscriptions/listen",Pi)};function $t(ma){return $r({_meta:bt,...ma})}let Dn={"tools/call":$t({content:Wt(ge),structuredContent:Er().optional(),isError:ir().optional()}),"tools/list":$t({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),tools:Wt(qe),nextCursor:r.optional()}),"prompts/get":$t({description:Ge().optional(),messages:Wt(Qe)}),"prompts/list":$t({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),prompts:Wt(Z),nextCursor:r.optional()}),"resources/list":$t({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),resources:Wt(M),nextCursor:r.optional()}),"resources/templates/list":$t({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),resourceTemplates:Wt(Q),nextCursor:r.optional()}),"resources/read":$t({ttlMs:kn().int().min(0),cacheScope:ca(["public","private"]),contents:Wt(lr([C,B]))}),"completion/complete":$t({completion:St({values:Wt(Ge()).max(100),total:kn().int().optional(),hasMore:ir().optional()}).loose()}),"server/discover":$t({ttlMs:kn().int().min(0).catch(0),cacheScope:ca(["public","private"]).catch("private"),supportedVersions:Wt(Ge()),capabilities:ze,instructions:Ge().optional()}),"subscriptions/listen":$t({})},Yn=$r({"io.modelcontextprotocol/subscriptionId":a.optional()}),ea=St({method:Vt("notifications/subscriptions/acknowledged"),params:St({_meta:Yn.optional(),notifications:nd})}),pa=St({_meta:Yn.optional(),requestId:a,reason:Ge().optional()}),ei=St({method:Vt("notifications/cancelled"),params:pa}),Go={"notifications/cancelled":ei,"notifications/progress":W,"notifications/message":k,"notifications/resources/updated":U,"notifications/resources/list_changed":w,"notifications/tools/list_changed":_e,"notifications/prompts/list_changed":ee,"notifications/subscriptions/acknowledged":ea},wi=(ma)=>St({jsonrpc:Vt("2.0"),id:lr([Ge(),kn().int()]),result:ma}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:a,RoleSchema:i,LoggingLevelSchema:o,TaskMetadataSchema:l,RelatedTaskMetadataSchema:u,RequestMetaSchema:d,BaseRequestParamsSchema:p,TaskAugmentedRequestParamsSchema:m,NotificationsParamsSchema:A,NotificationSchema:f,IconSchema:y,IconsSchema:v,BaseMetadataSchema:x,ImplementationSchema:_,ClientTasksCapabilitySchema:T,ServerTasksCapabilitySchema:R,ClientCapabilitiesSchema:O,ServerCapabilitiesSchema:j,ProgressSchema:H,ProgressNotificationParamsSchema:G,ProgressNotificationSchema:W,LoggingMessageNotificationParamsSchema:b,LoggingMessageNotificationSchema:k,ResourceContentsSchema:I,TextResourceContentsSchema:C,BlobResourceContentsSchema:B,AnnotationsSchema:L,ResourceSchema:M,ResourceTemplateSchema:Q,ResourceListChangedNotificationSchema:w,ResourceUpdatedNotificationParamsSchema:N,ResourceUpdatedNotificationSchema:U,PromptArgumentSchema:q,PromptSchema:Z,PromptListChangedNotificationSchema:ee,TextContentSchema:ne,ImageContentSchema:re,AudioContentSchema:ke,ToolUseContentSchema:se,EmbeddedResourceSchema:he,ResourceLinkSchema:ce,ContentBlockSchema:ge,PromptMessageSchema:Qe,ToolAnnotationsSchema:Oe,ToolListChangedNotificationSchema:_e,ModelHintSchema:Re,ModelPreferencesSchema:We,ToolChoiceSchema:be,BooleanSchemaSchema:Te,StringSchemaSchema:Me,NumberSchemaSchema:me,UntitledSingleSelectEnumSchemaSchema:le,TitledSingleSelectEnumSchemaSchema:fe,LegacyTitledEnumSchemaSchema:ye,SingleSelectEnumSchemaSchema:Ce,UntitledMultiSelectEnumSchemaSchema:Ie,TitledMultiSelectEnumSchemaSchema:Ee,MultiSelectEnumSchemaSchema:J,EnumSchemaSchema:Be,PrimitiveSchemaDefinitionSchema:de,ElicitRequestFormParamsSchema:te,ResourceTemplateReferenceSchema:De,PromptReferenceSchema:oe,RootSchema:ae,ClientCapabilities2026Schema:ue,ServerCapabilities2026Schema:ze,RequestMetaEnvelopeSchema:Le,ToolSchema:qe,ToolResultContentSchema:et,SamplingMessageContentBlockSchema:Ze,SamplingMessageSchema:He,ResultTypeSchema:ot,ResultMetaSchema:Ne,ResultSchema:yt,PaginatedResultSchema:$e,CallToolResultSchema:nt,ListToolsResultSchema:st,ListPromptsResultSchema:lt,GetPromptResultSchema:Tt,ListResourcesResultSchema:Pe,ListResourceTemplatesResultSchema:vt,ReadResourceResultSchema:Kt,CompleteResultSchema:mt,CacheableResultSchema:Ve,DiscoverResultSchema:Lt,CreateMessageRequestParamsSchema:pt,CreateMessageRequestSchema:wt,ListRootsRequestSchema:wn,CreateMessageResultSchema:sn,ListRootsResultSchema:dn,ElicitResultSchema:Hn,ElicitRequestURLParamsSchema:Cn,ElicitRequestParamsSchema:bn,ElicitRequestSchema:Gn,InputRequestSchema:Nt,InputResponseSchema:jt,InputRequestsSchema:an,InputResponsesSchema:On,InputRequiredResultSchema:In,InputResponseRequestParamsSchema:Tr,CallToolRequestSchema:mn,ListToolsRequestSchema:pr,ListPromptsRequestSchema:at,GetPromptRequestSchema:Si,ListResourcesRequestSchema:ut,ListResourceTemplatesRequestSchema:Lr,ReadResourceRequestSchema:Ro,CompleteRequestSchema:bu,DiscoverRequestSchema:Fd,SubscriptionFilterSchema:nd,SubscriptionsListenRequestSchema:ps,SubscriptionsListenResultMetaSchema:Pc,SubscriptionsListenResultSchema:Ln,dispatchRequestSchemas:At,dispatchResultSchemas:Dn,NotificationMetaSchema:Yn,SubscriptionsAcknowledgedNotificationSchema:ea,CancelledNotificationParamsSchema:pa,CancelledNotificationSchema:ei,notificationSchemas2026:Go,JSONRPCResultResponseSchema:wi(yt),CallToolResultResponseSchema:wi(lr([nt,In])),ListToolsResultResponseSchema:wi(st),ListPromptsResultResponseSchema:wi(lt),GetPromptResultResponseSchema:wi(lr([Tt,In])),ListResourcesResultResponseSchema:wi(Pe),ListResourceTemplatesResultResponseSchema:wi(vt),ReadResourceResultResponseSchema:wi(lr([Kt,In])),CompleteResultResponseSchema:wi(mt),DiscoverResultResponseSchema:wi(Lt)}}var VJr;function u2(){return VJr??=YJr()}var ZJr=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function KJr(e){return ZJr.includes(e)}var IQ=Symbol("modelcontextprotocol.resultCacheHintFallback");function DAn(e,t){if(t===void 0)return e;let n=e[IQ];if(n===void 0)return{...e,[IQ]:t};let r={},a=n.ttlMs??t.ttlMs;if(a!==void 0)r.ttlMs=a;let i=n.cacheScope??t.cacheScope;if(i!==void 0)r.cacheScope=i;return{...e,[IQ]:r}}function JJr(e){return e[IQ]}function X5e(e){return typeof e==="number"&&Number.isSafeInteger(e)&&e>=0}function e$e(e){return e==="public"||e==="private"}function RAn(e,t){if(e.ttlMs!==void 0&&!X5e(e.ttlMs))throw RangeError(`Invalid cache hint for ${t}: ttlMs must be a non-negative safe integer (got ${String(e.ttlMs)})`);if(e.cacheScope!==void 0&&!e$e(e.cacheScope))throw RangeError(`Invalid cache hint for ${t}: cacheScope must be 'public' or 'private' (got ${String(e.cacheScope)})`)}var Qr=function(e){return e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.ResourceNotFound=-32002]="ResourceNotFound",e[e.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",e[e.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired",e}({}),Ai=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return SQ(this,t)}static isInstance(t){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return SQ(this,t)}constructor(t,n,r){super(n);this.code=t,this.data=r,this.name="ProtocolError",Y5e(this,new.target)}static fromError(t,n,r){if(t===Qr.UrlElicitationRequired&&r){let a=r;if(a.elicitations)return new QAn(a.elicitations,n)}if(t===Qr.UnsupportedProtocolVersion&&r){let a=r;if(Array.isArray(a.supported)&&typeof a.requested==="string")return new LAn({supported:a.supported,requested:a.requested},n)}if(t===Qr.InvalidParams||t===Qr.ResourceNotFound){let a=r;if(typeof a?.uri==="string"&&(t===Qr.ResourceNotFound||Object.keys(a).length===1))return new t$e(a.uri,n)}if(t===Qr.MissingRequiredClientCapability&&r){let a=r;if(a.requiredCapabilities!==null&&typeof a.requiredCapabilities==="object"&&!Array.isArray(a.requiredCapabilities))return new Uce({requiredCapabilities:a.requiredCapabilities},n)}return new e(t,n,r)}},t$e=class extends Ai{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(Qr.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},QAn=class extends Ai{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(Qr.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},LAn=class extends Ai{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(Qr.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Uce=class extends Ai{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(Qr.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},XJr=0,eXr="private",tXr=["tools/call","prompts/get","resources/read"];function nXr(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:"complete"};if(n==="complete")return t;if(tXr.includes(e))return t;throw new Ai(Qr.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function rXr(e,t){let n=JJr(t);if(t.resultType!=="complete"||!KJr(e))return n===void 0?t:cXr(t);let r=t,a=X5e(r.ttlMs)?r.ttlMs:oXr(n),i=e$e(r.cacheScope)?r.cacheScope:sXr(n),o={...r,ttlMs:a,cacheScope:i};return delete o[IQ],o}function aXr(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function iXr(e,t){if(t===void 0)return e;let n=e._meta;if(n===void 0)return{...e,_meta:{[Yv]:t}};if(!aXr(n))return e;if(n[Yv]!==void 0)return e;return{...e,_meta:{...n,[Yv]:t}}}function oXr(e){return e!==void 0&&X5e(e.ttlMs)?e.ttlMs:XJr}function sXr(e){return e!==void 0&&e$e(e.cacheScope)?e.cacheScope:eXr}function cXr(e){let t={...e};return delete t[IQ],t}var lXr=["elicitation/create","sampling/createMessage","roots/list"],Oce;function MAn(){if(Oce)return Oce;let e=u2();return Oce={request:{"elicitation/create":St({method:Vt("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":St({method:Vt("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":St({method:Vt("roots/list"),params:$r({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},Oce}function FAn(e){return lXr.includes(e)}function $5e(e){return FAn(e)?MAn().request[e]:void 0}function uXr(e){return FAn(e)?MAn().response[e]:void 0}var n$e={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},NAn={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function PAn(e){return Object.prototype.hasOwnProperty.call(n$e,e)}function $An(e){return Object.prototype.hasOwnProperty.call(NAn,e)}function dXr(e){return Object.prototype.hasOwnProperty.call(n$e,e)}function pXr(e){return PAn(e)?u2().dispatchRequestSchemas[e]:void 0}function mXr(e){return dXr(e)?u2().dispatchResultSchemas[e]:void 0}function AXr(e){return $An(e)?u2().notificationSchemas2026[e]:void 0}var Ghc=Object.keys(n$e),Uhc=Object.keys(NAn);function O7(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function P7(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:"invalid",message:String(n.error)}}var gXr={ok:!1,reason:"not-in-era"},fXr=[s2,Vv];function hXr(e,t){let n=t,r=!1,a=()=>{if(!r)n={...n},r=!0;return n},i=t.tools;if(e==="tools/list"&&Array.isArray(i)&&i.some((s)=>O7(s)&&("execution"in s)))a().tools=i.map((s)=>{if(!O7(s)||!("execution"in s))return s;let l={...s};return delete l.execution,l});let o=t.capabilities;if(O7(o)&&"tasks"in o){let s={...o};delete s.tasks,a().capabilities=s}return n}var r$e={era:"2026-07-28",hasRequestMethod:PAn,hasNotificationMethod:$An,hasInputRequestMethod:(e)=>$5e(e)!==void 0,validateRequest:(e,t)=>P7(pXr(e),t),validateResult:(e,t)=>P7(mXr(e),t),validateNotification:(e,t)=>P7(AXr(e),t),validateInputRequest:(e,t)=>P7($5e(e),t),validateInputResponse:(e,t)=>P7(uXr(e),t),samplingResultVariant:()=>gXr,outboundEnvelope(e){return{[s2]:e.protocolVersion,[fQ]:e.clientInfo,[Vv]:e.clientCapabilities,...e.logLevel!==void 0&&{[Z1]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let r of fXr)if(!(r in e))t.push({key:r,problem:"missing"});let n=u2().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let r of n.error.issues){let a=r.path.map(String),i=a.length>0?a.join("."):"_meta";if(a.length===1&&t.some((o)=>o.key===i&&o.problem==="missing"))continue;t.push({key:i,problem:r.message})}return t},projectCallToolResult:(e)=>CAn(e),inputRequestSchema:$5e,decodeResult(e,t){if(!O7(t))return{kind:"invalid",error:new $a(oi.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:"invalid",error:new $a(oi.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:"missing-resultType"})};if(typeof n!=="string")return{kind:"invalid",error:new $a(oi.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n==="input_required"){let o=t.inputRequests,s=O7(o)?o:{},l=t.requestState;if(Object.keys(s).length===0&&typeof l!=="string")return{kind:"invalid",error:new $a(oi.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:"input-required-missing-both"})};return{kind:"input_required",inputRequests:s,...typeof l==="string"&&{requestState:l}}}if(n!=="complete")return{kind:"invalid",error:new $a(oi.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=bXr(),a=Object.hasOwn(r,e)?r[e]:void 0;if(a!==void 0){let o=a.safeParse(t);if(!o.success)return{kind:"invalid",error:new $a(oi.InvalidResult,`Invalid result for ${e}: ${o.error}`,{method:e})}}let i={...t};return delete i.resultType,{kind:"complete",result:i}},encodeResult(e,t,n){return iXr(rXr(e,nXr(e,hXr(e,t))),n)},encodeErrorCode:(e)=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let t=u2().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map((n)=>n.message).join("; ")}`}},zce;function bXr(){if(zce)return zce;let e=u2();return zce={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},zce}var a$e="2026-07-28";function TQ(e){return e!==void 0&&q7(e)?r$e:J5e}function gAn(e){if(e.revision!==void 0)return TQ(e.revision).era;return e.era==="modern"?r$e.era:J5e.era}function O5e(e){return OAn.some((t)=>t.hasRequestMethod(e))}function z5e(e){return OAn.some((t)=>t.hasNotificationMethod(e))}var OAn=[J5e,r$e];var yXr=Zmn({AnnotationsSchema:()=>Zv,AudioContentSchema:()=>CQ,BaseMetadataSchema:()=>Wv,BaseRequestParamsSchema:()=>fu,BlobResourceContentsSchema:()=>E7,BooleanSchemaSchema:()=>D7,CallToolRequestParamsSchema:()=>Kse,CallToolRequestSchema:()=>Jse,CallToolResultSchema:()=>T7,CancelTaskRequestSchema:()=>C5e,CancelTaskResultSchema:()=>x5e,CancelledNotificationParamsSchema:()=>ese,CancelledNotificationSchema:()=>w7,ClientCapabilitiesSchema:()=>ase,ClientNotificationSchema:()=>E5e,ClientRequestSchema:()=>_5e,ClientResultSchema:()=>B5e,ClientTasksCapabilitySchema:()=>nse,CompatibilityCallToolResultSchema:()=>p5e,CompleteRequestParamsSchema:()=>_ce,CompleteRequestSchema:()=>Ece,CompleteResultSchema:()=>Bce,ContentBlockSchema:()=>xQ,CreateMessageRequestParamsSchema:()=>uce,CreateMessageRequestSchema:()=>dce,CreateMessageResultSchema:()=>pce,CreateMessageResultWithToolsSchema:()=>mce,CreateTaskResultSchema:()=>g5e,CursorSchema:()=>A7,DiscoverRequestSchema:()=>lse,DiscoverResultSchema:()=>use,ElicitRequestFormParamsSchema:()=>BQ,ElicitRequestParamsSchema:()=>bce,ElicitRequestSchema:()=>yce,ElicitRequestURLParamsSchema:()=>hce,ElicitResultSchema:()=>kce,ElicitationCompleteNotificationParamsSchema:()=>wce,ElicitationCompleteNotificationSchema:()=>vce,EmbeddedResourceSchema:()=>jse,EmptyResultSchema:()=>y7,EnumSchemaSchema:()=>fce,GetPromptRequestParamsSchema:()=>$se,GetPromptRequestSchema:()=>Ose,GetPromptResultSchema:()=>Use,GetTaskPayloadRequestSchema:()=>y5e,GetTaskPayloadResultSchema:()=>w5e,GetTaskRequestSchema:()=>h5e,GetTaskResultSchema:()=>b5e,IconSchema:()=>tse,IconsSchema:()=>J1,ImageContentSchema:()=>kQ,ImplementationSchema:()=>yQ,InitializeRequestParamsSchema:()=>ise,InitializeRequestSchema:()=>ose,InitializeResultSchema:()=>sse,InitializedNotificationSchema:()=>cse,JSONArraySchema:()=>l5e,JSONObjectSchema:()=>bc,JSONRPCErrorResponseSchema:()=>bQ,JSONRPCMessageSchema:()=>Xoe,JSONRPCNotificationSchema:()=>b7,JSONRPCRequestSchema:()=>h7,JSONRPCResponseSchema:()=>u5e,JSONRPCResultResponseSchema:()=>hQ,JSONValueSchema:()=>V1,LegacyTitledEnumSchemaSchema:()=>L7,ListChangedOptionsBaseSchema:()=>m5e,ListPromptsRequestSchema:()=>Nse,ListPromptsResultSchema:()=>Pse,ListResourceTemplatesRequestSchema:()=>hse,ListResourceTemplatesResultSchema:()=>bse,ListResourcesRequestSchema:()=>gse,ListResourcesResultSchema:()=>fse,ListRootsRequestSchema:()=>Sce,ListRootsResultSchema:()=>Tce,ListTasksRequestSchema:()=>v5e,ListTasksResultSchema:()=>k5e,ListToolsRequestSchema:()=>Vse,ListToolsResultSchema:()=>Zse,LoggingLevelSchema:()=>n_,LoggingMessageNotificationParamsSchema:()=>nce,LoggingMessageNotificationSchema:()=>rce,ModelHintSchema:()=>ace,ModelPreferencesSchema:()=>ice,MultiSelectEnumSchemaSchema:()=>gce,NotificationSchema:()=>Md,NotificationsParamsSchema:()=>Ld,NumberSchemaSchema:()=>EQ,PaginatedRequestParamsSchema:()=>mse,PaginatedRequestSchema:()=>X1,PaginatedResultSchema:()=>e_,PingRequestSchema:()=>k7,PrimitiveSchemaDefinitionSchema:()=>N7,ProgressNotificationParamsSchema:()=>pse,ProgressNotificationSchema:()=>C7,ProgressSchema:()=>dse,ProgressTokenSchema:()=>m7,PromptArgumentSchema:()=>Mse,PromptListChangedNotificationSchema:()=>Hse,PromptMessageSchema:()=>Gse,PromptReferenceSchema:()=>xce,PromptSchema:()=>Fse,ReadResourceRequestParamsSchema:()=>yse,ReadResourceRequestSchema:()=>wse,ReadResourceResultSchema:()=>vse,RelatedTaskMetadataSchema:()=>Joe,RequestIdSchema:()=>K1,RequestMetaSchema:()=>g7,RequestSchema:()=>yc,ResourceContentsSchema:()=>x7,ResourceLinkSchema:()=>qse,ResourceListChangedNotificationSchema:()=>kse,ResourceRequestParamsSchema:()=>wQ,ResourceSchema:()=>B7,ResourceTemplateReferenceSchema:()=>Cce,ResourceTemplateSchema:()=>Ase,ResourceUpdatedNotificationParamsSchema:()=>Qse,ResourceUpdatedNotificationSchema:()=>Lse,ResultMetaObjectSchema:()=>f7,ResultSchema:()=>wc,RoleSchema:()=>t_,RootSchema:()=>Ice,RootsListChangedNotificationSchema:()=>Dce,SamplingContentSchema:()=>cce,SamplingMessageContentBlockSchema:()=>i2,SamplingMessageSchema:()=>lce,ServerCapabilitiesSchema:()=>v7,ServerNotificationSchema:()=>S5e,ServerRequestSchema:()=>I5e,ServerResultSchema:()=>T5e,ServerTasksCapabilitySchema:()=>rse,SetLevelRequestParamsSchema:()=>ece,SetLevelRequestSchema:()=>tce,SingleSelectEnumSchemaSchema:()=>Ace,StringSchemaSchema:()=>_Q,SubscribeRequestParamsSchema:()=>Cse,SubscribeRequestSchema:()=>xse,SubscriptionFilterSchema:()=>I7,SubscriptionsAcknowledgedNotificationParamsSchema:()=>Sse,SubscriptionsAcknowledgedNotificationSchema:()=>Tse,SubscriptionsListenRequestParamsSchema:()=>Bse,SubscriptionsListenRequestSchema:()=>Ise,SubscriptionsListenResultMetaSchema:()=>Dse,SubscriptionsListenResultSchema:()=>Rse,TaskAugmentedRequestParamsSchema:()=>l2,TaskCreationParamsSchema:()=>A5e,TaskMetadataSchema:()=>Koe,TaskSchema:()=>r_,TaskStatusNotificationParamsSchema:()=>Qce,TaskStatusNotificationSchema:()=>f5e,TaskStatusSchema:()=>Rce,TextContentSchema:()=>vQ,TextResourceContentsSchema:()=>_7,TitledMultiSelectEnumSchemaSchema:()=>F7,TitledSingleSelectEnumSchemaSchema:()=>Q7,ToolAnnotationsSchema:()=>Wse,ToolChoiceSchema:()=>oce,ToolExecutionSchema:()=>Yse,ToolListChangedNotificationSchema:()=>Xse,ToolResultContentSchema:()=>sce,ToolSchema:()=>S7,ToolUseContentSchema:()=>zse,UnsubscribeRequestParamsSchema:()=>_se,UnsubscribeRequestSchema:()=>Ese,UntitledMultiSelectEnumSchemaSchema:()=>M7,UntitledSingleSelectEnumSchemaSchema:()=>R7});var zAn=(e)=>h7.safeParse(e).success,jAn=(e)=>b7.safeParse(e).success,G5e=(e)=>hQ.safeParse(e).success,qAn=(e)=>bQ.safeParse(e).success;var d2=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&e.resultType==="input_required";var jce=-32020,Hhc=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32000],conformance:[],rationale:"The modern era is POST-only; GET/DELETE are body-less 2025-era session operations and are method-routed to legacy serving (405 when legacy serving is not configured), before any body is read."},{rung:"jsonrpc-shape",order:2,evaluatedAt:"edge",codes:[Qr.InvalidRequest],conformance:["server-stateless"],rationale:"The body must be a JSON-RPC request or notification: posted responses and batch arrays containing a modern or invalid element are rejected before classification (element-wise batch rule); all-legacy arrays stay legacy traffic."},{rung:"era-classification",order:3,evaluatedAt:"edge",codes:[jce,Qr.UnsupportedProtocolVersion],conformance:["server-stateless","http-header-validation","http-custom-header-server-validation"],rationale:"Body-primary era classification with the protocol-version header as a cross-check; a header/body disagreement is rejected with -32020 (HeaderMismatch), and an envelope-less request on a modern-only endpoint is answered with the unsupported-protocol-version error naming the supported revisions."},{rung:"envelope",order:4,evaluatedAt:"edge",codes:[Qr.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope — and a missing envelope on a request whose protocol-version header names a modern revision — is an invalid-params rejection naming the offending or missing key(s); never a silent fall back to legacy handling. This is the only place an invalid-params rejection maps to HTTP 400."},{rung:"method-registry",order:5,evaluatedAt:"dispatch",codes:[Qr.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision’s registry (or with no handler installed) answers method-not-found before params or capabilities are looked at."},{rung:"request-params",order:6,evaluatedAt:"dispatch",codes:[Qr.InvalidParams],conformance:[],rationale:"Per-method params validation; emitted in-band by the dispatch layer (HTTP 200), never via the ladder status table."},{rung:"standard-header-validation",order:7,evaluatedAt:"pre-dispatch",codes:[jce],conformance:["http-header-validation"],rationale:"SEP-2243 standard `Mcp-Method` / `Mcp-Name` headers — presence, sentinel decoding, and `Mcp-Name` ↔ body cross-check — are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The classifier’s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5–6) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[Qr.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced — pinning the spec-mandated HTTP 400 independently of how dispatch- and handler-produced errors are mapped. The documented order (after method resolution and params validation) is preserved observably only while the requirement table is empty: once a served method gains a requirement entry, a request that is missing the capability and would also fail a dispatch rung is answered by this gate first, so the entry must consult the method registry before the gate if the documented precedence is to stay observable."},{rung:"param-header-validation",order:9,evaluatedAt:"pre-dispatch",codes:[jce],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool’s `x-mcp-header` declarations and the body `arguments` after the tool registry is known and before dispatch reaches the handler; a missing/disagreeing/malformed header is rejected 400 / -32020 with the same shape as the standard-header cross-checks. The documented order (after method resolution and params validation) is preserved observably only when the body `arguments` would otherwise validate: the check runs pre-dispatch, so a `tools/call` that fails BOTH this rung and a dispatch-time rung (e.g. order-6 `request-params`, -32602) is answered by this gate first with 400 / -32020, not by the earlier-ordered rung."}],wXr={[Qr.ParseError]:400,[Qr.InvalidRequest]:400,[Qr.MethodNotFound]:404,[Qr.UnsupportedProtocolVersion]:400,[Qr.MissingRequiredClientCapability]:400,[jce]:400};function Hce(e,t){return ML(e,t)}function $7(e){return new Set(e.flatMap((t)=>Object.keys(t.shape)))}function U5e(e){if(e==null)return!1;let t=typeof e;if(t!=="object"&&t!=="function")return!1;if(!("~standard"in e))return!1;return typeof e["~standard"]?.validate==="function"}var fAn=!1,H5e="draft-2020-12";function GAn(e,t="input"){let n=e["~standard"],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:H5e});else if(n.vendor==="zod"){if(!("_zod"in e))throw Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");if(!fAn)fAn=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.");r=S0(e,{target:H5e,io:t})}else throw Error(`Schema library "${n.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t==="output"){if(r.type!==void 0)return r;return UAn(r)?{type:"object",...r}:r}if(r.type!==void 0&&r.type!=="object")throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...r}}function UAn(e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;for(let t of["oneOf","anyOf","allOf"]){let n=e[t];if(Array.isArray(n)&&n.length>0)return n.every((r)=>r!==null&&typeof r==="object"&&(r.type==="object"||UAn(r)))}return!1}function vXr(e){if(!e.path?.length)return e.message;return`${e.path.map((t)=>String(typeof t==="object"?t.key:t)).join(".")}: ${e.message}`}async function qce(e,t){let n=await e["~standard"].validate(t);if(n.issues&&n.issues.length>0)return{success:!1,error:n.issues.map((r)=>vXr(r)).join(", ")};return{success:!0,data:n.value}}function kXr(e){let t=S0(e,{target:H5e,io:"input"});return typeof t.pattern==="string"?t.pattern:void 0}var CXr=/\\\.\\d\{(\d+)\}/;function xXr(e){let t=CXr.exec(e),n=[void 0,-1,0];if(t)n.push(Number(t[1]));return[!1,!0].flatMap((r)=>[!1,!0].flatMap((a)=>n.map((i)=>cA.datetime({local:r,offset:a,precision:i}))))}function _Xr(e,t){let n;switch(e){case"email":n=[_G()];break;case"uri":n=[UT()];break;case"date":n=[cA.date()];break;case"date-time":n=xXr(t);break}return new Set(n.map((r)=>kXr(r)).filter((r)=>r!==void 0))}function EXr(e,t,n){if(n!=="zod")return!0;return _Xr(e,t).has(t)}function j7(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function BXr(e){try{return GAn(e,"input")}catch(t){let n=t instanceof Error?t.message:String(t);throw new Ai(Qr.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${n}`)}}var IXr=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function i$e(e){return IXr.has(e)||e.startsWith("x-")}var SXr=new Set(["$schema",...Object.keys(BQ.shape.requestedSchema.shape)]),hAn={string:$7([_Q,R7,Q7,L7]),number:$7([EQ]),integer:$7([EQ]),boolean:$7([D7]),array:$7([M7,F7])},TXr=new Set(_Q.shape.format.unwrap().options);function DXr(e,t,n,r){if(!j7(e))return e;let a=typeof e.type==="string"&&Object.hasOwn(hAn,e.type)?hAn[e.type]:void 0;if(a===void 0)return e;let i={};for(let[o,s]of Object.entries(e))if(a.has(o)||i$e(o))i[o]=s;else if(o==="pattern"&&e.type==="string"&&typeof e.format==="string"){if(!TXr.has(e.format))i[o]=s;else if(typeof s!=="string"||!EXr(e.format,s,n))r.push(`${t}.${o}`)}else r.push(`${t}.${o}`);return i}function RXr(e,t){let n={},r=[];for(let[a,i]of Object.entries(e))if(a==="properties"&&j7(i))n[a]=Object.fromEntries(Object.entries(i).map(([o,s])=>[o,DXr(s,`properties.${o}`,t,r)]));else if(SXr.has(a))n[a]=i;else if(!i$e(a))r.push(a);if(r.length>0)throw new Ai(Qr.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(", ")}`);return n}function QXr(e,t){if(!j7(e.properties))return t;let n=Object.entries(e.properties).filter(([,r])=>!Hce(N7,r).success).map(([r])=>`properties.${r}`);return n.length>0?n.join(", "):t}function W5e(e,t,n=""){if(Array.isArray(e)&&Array.isArray(t))return e.flatMap((r,a)=>W5e(r,t[a],`${n}[${a}]`));if(!j7(e)||!j7(t))return[];return Object.entries(e).flatMap(([r,a])=>{let i=n?`${n}.${r}`:r;if(!Object.prototype.hasOwnProperty.call(t,r))return i$e(r)?[]:[i];return W5e(a,t[r],i)})}function LXr(e){if(!U5e(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,n=RXr(BXr(e.requestedSchema),t),r=Hce(BQ.shape.requestedSchema,n);if(!r.success)throw new Ai(Qr.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${QXr(n,r.error.message)}`);let a=W5e(n,r.data);if(a.length>0)throw new Ai(Qr.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${a.join(", ")}`);let i=(r.data.required??[]).filter((o)=>!Object.prototype.hasOwnProperty.call(r.data.properties,o));if(i.length>0)throw new Ai(Qr.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${i.join(", ")}`);return{...e,mode:"form",requestedSchema:r.data}}function MXr(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==="string";if(!t&&!n)throw TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}var FXr=Object.assign(MXr,{elicit(e){try{return{method:"elicitation/create",params:LXr(e)}}catch(t){throw t instanceof Ai?TypeError(t.message,{cause:t}):t}},elicitUrl(e){return{method:"elicitation/create",params:{...e,mode:"url"}}},createMessage(e){return{method:"sampling/createMessage",params:e}},listRoots(){return{method:"roots/list"}}});var HAn=250;function WAn(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function YAn(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason instanceof $a?t.reason:new $a(oi.RequestTimeout,String(t.reason)));return}let a=setTimeout(()=>{t?.removeEventListener("abort",i),n()},e),i=()=>{clearTimeout(a),r(t?.reason instanceof $a?t.reason:new $a(oi.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",i,{once:!0})})}function VAn(e){let t=new AbortController,n=()=>t.abort(e?.reason);if(e?.addEventListener("abort",n,{once:!0}),e?.aborted)t.abort(e.reason);return{signal:t.signal,abort:(r)=>t.abort(r),dispose:()=>e?.removeEventListener("abort",n)}}var NXr=["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"],PXr={IdJagTokenExchangeResponseSchema:L5e,OAuthClientInformationFullSchema:F5e,OAuthClientInformationSchema:Nce,OAuthClientMetadataSchema:Fce,OAuthClientRegistrationErrorSchema:N5e,OAuthErrorResponseSchema:M5e,OAuthMetadataSchema:Lce,OAuthProtectedResourceMetadataSchema:D5e,OAuthTokenRevocationRequestSchema:P5e,OAuthTokensSchema:Q5e,OpenIdProviderDiscoveryMetadataSchema:R5e,OpenIdProviderMetadataSchema:Mce},ZAn={},KAn={};function JAn(e,t){let n=e.slice(0,-6);ZAn[n]=t,KAn[n]=(r)=>t.safeParse(r).success}for(let e of NXr)JAn(e,yXr[e]);for(let[e,t]of Object.entries(PXr))JAn(e,t);var $Xr=Object.freeze(ZAn),OXr=Object.freeze(KAn);function zXr(e){switch(e){case"initialize":case"notifications/initialized":return TQ(void 0);case"server/discover":return TQ(a$e);default:return}}var XAn=60000,jXr=[s2,fQ,Vv,Z1],qXr=["inputResponses","requestState"];function bAn(e,t){let n=e.params;if(!z7(n))return{message:e,lifted:{}};let r=n._meta,a=z7(r)?jXr.filter((l)=>(l in r)):[],i=t==="request"?qXr.filter((l)=>(l in n)):[];if(a.length===0&&i.length===0)return{message:e,lifted:{}};let o={},s={...n};if(a.length>0&&z7(r)){let l={},u={...r};for(let d of a)l[d]=r[d],delete u[d];if(o.envelope=l,Object.keys(u).length>0)s._meta=u;else delete s._meta}for(let l of i){if(l==="inputResponses")o.inputResponses=s[l];if(l==="requestState")o.requestState=s[l];delete s[l]}return{message:{...e,params:s},lifted:o}}function yAn(e,t){let n=e.validateResult(t,void 0);if(!n.ok&&n.reason==="not-in-era")return;return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(r){let a=e.validateResult(t,r);if(a.ok)return{value:a.value};return{issues:[{message:a.reason==="invalid"?a.message:`not-in-era: ${t}`}]}}}}}function G7(e){return()=>e}var GXr=G7(void 0);function o$e(e,t){return{...e,mcpReq:{...e.mcpReq,requestState:G7(t)}}}var UXr;var s$e=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{UXr=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Voe,this.setNotificationHandler("notifications/cancelled",(t)=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",(t)=>{this._onprogress(t)}),this.setRequestHandler("ping",(t)=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new $a(oi.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,a=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:a,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new $a(oi.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);if(t)clearTimeout(t.timeoutId),this._timeoutInfo.delete(e)}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let n=this.transport?.onerror;this._transport.onerror=(a)=>{n?.(a),this._onerror(a)};let r=this._transport?.onmessage;this._transport.onmessage=(a,i)=>{if(r?.(a,i),G5e(a)||qAn(a))this._onresponse(a);else if(zAn(a))this._onrequest(a,i);else if(jAn(a))this._onnotification(a,i);else this._onerror(Error(`Unknown message type: ${JSON.stringify(a)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new $a(oi.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let r of e.values())r(n);for(let r of t.values())r.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=bAn(e,"notification"),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let o=gAn(t.classification);if(o!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${o} but this instance serves ${r.era}`));return}}if(z5e(n.method)&&!r.hasNotificationMethod(n.method))return;let a=this._notificationHandlers.get(n.method),i=this.fallbackNotificationHandler;if(a===void 0&&i===void 0)return;Promise.resolve().then(()=>a===void 0?i(n):a(n,r)).catch((o)=>this._onerror(Error(`Uncaught error in notification handler: ${o}`)))}_onrequest(e,t){let{message:n,lifted:r}=bAn(e,"request"),a=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop"){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let i=this._transport,o=(y,v,x)=>{let _={jsonrpc:"2.0",id:n.id,error:{code:y,message:v,...x!==void 0&&{data:x}}};i?.send(_).catch((E)=>this._onerror(Error(`Failed to send an error response: ${E}`)))};if(t?.classification!==void 0){let y=gAn(t.classification);if(y!==a.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${y} but this instance serves ${a.era}`));let v=t.classification.revision??y;o(Qr.UnsupportedProtocolVersion,`Unsupported protocol version: ${v}`,{supported:this._supportedProtocolVersions,requested:v});return}}if(O5e(n.method)&&!a.hasRequestMethod(n.method)){o(Qr.MethodNotFound,"Method not found");return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(Qr.MethodNotFound,"Method not found");return}let l=a.checkInboundEnvelope(r);if(l!==void 0){o(Qr.InvalidParams,l);return}let u=(y,v)=>this._notificationViaCodec(this._resolveOutboundCodec(y.method),y,{...v,relatedRequestId:n.id}),d=(y,v,x)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(y.method),y,v,{...x,relatedRequestId:n.id}),p=new AbortController;this._requestHandlerAbortControllers.set(n.id,p);let m=r.inputResponses===void 0?void 0:HXr(r.inputResponses),A={sessionId:i?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...m!==void 0&&{inputResponses:m.accepted},...m!==void 0&&m.droppedKeys.length>0&&{droppedInputResponseKeys:m.droppedKeys},requestState:r.requestState===void 0?GXr:G7(r.requestState),signal:p.signal,send:(y,v,x)=>{let _=this._resolveOutboundCodec(y.method);if(this._assertOutboundRequestInEra(_,y.method),U5e(v))return d(y,v,x);let E=yAn(_,y.method);if(E===void 0)throw TypeError(`'${y.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return d(y,E,v)},notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},f=this.buildContext(A,t);Promise.resolve().then(()=>s(n,f)).then(async(y)=>{if(p.signal.aborted)return;let v;try{v=a.encodeResult(n.method,y,this._outboundServerInfo())}catch(_){this._onerror(Error(`Failed to encode result for ${n.method}: ${_}`)),o(Qr.InternalError,"Internal error");return}let x={result:v,jsonrpc:"2.0",id:n.id};await i?.send(x)},async(y)=>{if(p.signal.aborted)return;let v=Number.isSafeInteger(y.code)?y.code:Qr.InternalError,x={jsonrpc:"2.0",id:n.id,error:{code:a.encodeErrorCode(v),message:y.message??"Internal error",...y.data!==void 0&&{data:y.data}}};await i?.send(x)}).catch((y)=>this._onerror(Error(`Failed to send response: ${y}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(n.id)===p)this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),a=this._progressHandlers.get(r);if(!a){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&i&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(s){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),i(s);return}a(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),G5e(e))n(e);else n(Ai.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),U5e(t))return this._requestWithSchemaViaCodec(r,e,t,n);let a=yAn(r,e.method);if(a===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,a,t)}_negotiatedWireCodec(){return TQ(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=zXr(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(O5e(t)&&!e.hasRequestMethod(t))throw new $a(oi.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:a,resumptionToken:i,onresumptiontoken:o,headers:s}=r??{},l=Date.now(),u,d;return new Promise((p,m)=>{let A=(R)=>{m(R)};if(!this._transport){A(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(R){A(R);return}if(r?.signal?.aborted){let R=r.signal.reason;throw R instanceof $a?R:new $a(oi.RequestTimeout,String(R))}let f=e.era===a$e&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,y=this._requestMessageId++;d=y;let v={...t,jsonrpc:"2.0",id:y};if(r?.onprogress)this._progressHandlers.set(y,r.onprogress),v.params={...t.params,_meta:{...t.params?._meta,progressToken:y}};let x=this._envelopeOutbound(v),_=!1,E=(R)=>{if(_)return;if(this._progressHandlers.delete(y),f===void 0)this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:y,reason:String(R)}}),{relatedRequestId:a,resumptionToken:i,onresumptiontoken:o}).catch((O)=>this._onerror(Error(`Failed to send cancellation: ${O}`)));else f.abort();m(R instanceof $a?R:new $a(oi.RequestTimeout,String(R)))};this._responseHandlers.set(y,(R)=>{if(r?.signal?.aborted)return;if(_=!0,R instanceof Error)return m(R);let O;try{O=e.decodeResult(t.method,R.result)}catch(H){return m(H instanceof Error?H:Error(String(H)))}if(O.kind==="invalid")return m(O.error);if(O.kind==="input_required"){if(r?.allowInputRequired===!0)return p(WXr(O));let H={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:l,retry:(G,W)=>this._requestWithSchemaViaCodec(e,G===void 0?{method:t.method}:{method:t.method,params:G},n,W)};return p(this._resolveNonCompleteResult(O,H))}let j=O.result;qce(n,j).then((H)=>{if(H.success)p(H.data);else m(new $a(oi.InvalidResult,`Invalid result for ${t.method}: ${H.error}`))},m)}),u=()=>E(r?.signal?.reason),r?.signal?.addEventListener("abort",u,{once:!0});let F=r?.timeout??XAn,T=()=>E(new $a(oi.RequestTimeout,"Request timed out",{timeout:F}));this._setupTimeout(y,F,r?.maxTotalTimeout,T,r?.resetTimeoutOnProgress??!1),this._transport.send(x,{relatedRequestId:a,resumptionToken:i,onresumptiontoken:o,headers:s,requestSignal:f?.signal}).catch((R)=>{this._progressHandlers.delete(y),m(R)})}).finally(()=>{if(u)r?.signal?.removeEventListener("abort",u);if(d!==void 0)this._responseHandlers.delete(d),this._cleanupTimeout(d)})}async notification(e,t){return this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new $a(oi.NotConnected,"Not connected");if(z5e(t.method)&&!e.hasNotificationMethod(t.method))throw new $a(oi.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;this._transport?.send(r,n).catch((a)=>this._onerror(a))});return}await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==="function"){if(!O5e(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(a,i)=>{let o=this._negotiatedWireCodec(),s=o.validateRequest(e,a);if(!s.ok&&s.reason==="not-in-era")s=o.validateInputRequest(e,a);if(!s.ok){if(s.reason==="not-in-era")throw new Ai(Qr.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(s.message)}return Promise.resolve(t(s.value,i))}}else if(n)r=async(a,i)=>{let o=await qce(t.params,{...a.params});if(!o.success)throw new Ai(Qr.InvalidParams,`Invalid params for ${e}: ${o.error}`);return n(o.data,i)};else throw TypeError("setRequestHandler: handler is required");this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==="function"){if(!z5e(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(r,a)=>{let i=a.validateNotification(e,r);if(!i.ok){if(i.reason==="not-in-era")throw new Ai(Qr.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(i.message)}return Promise.resolve(t(i.value))});return}if(!n)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async(r)=>{let a=await qce(t.params,{...r.params});if(!a.success)throw new Ai(Qr.InvalidParams,`Invalid params for notification ${e}: ${a.error}`);await n(a.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function z7(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function c$e(e,t){let n={...e};for(let r in t){let a=r,i=t[a];if(i===void 0)continue;let o=n[a];n[a]=z7(o)&&z7(i)?{...o,...i}:i}return n}function wAn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function HXr(e){let t={},n=[];if(!wAn(e))return{accepted:t,droppedKeys:n};for(let[r,a]of Object.entries(e)){if(!wAn(a)||"method"in a||"result"in a){n.push(r);continue}t[r]=a}return{accepted:t,droppedKeys:n}}function WXr(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState}}}/*!
|
|
4297
4297
|
* content-type
|
|
4298
4298
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
4299
4299
|
* MIT Licensed
|
|
@@ -4302,4 +4302,4 @@ Known schemas:
|
|
|
4302
4302
|
- ${Object.keys(r).join(`
|
|
4303
4303
|
- `)}`,Error(Ce)}let fe=`${s}/$ref`,ye=Vs(e,le,n,r,a,i,o,fe,l);if(!ye.valid)Me.push({instanceLocation:o,keyword:"$ref",keywordLocation:fe,error:"A subschema had errors."},...ye.errors);if(n==="4"||n==="7")return{valid:Me.length===0,errors:Me}}if(Array.isArray(f)){let le=f.length,fe=!1;for(let ye=0;ye<le;ye++)if(d===f[ye]||f[ye]==="integer"&&d==="number"&&e%1===0&&e===e){fe=!0;break}if(!fe)Me.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${d}" is invalid. Expected "${f.join('", "')}".`})}else if(f==="integer"){if(d!=="number"||e%1||e!==e)Me.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${d}" is invalid. Expected "${f}".`})}else if(f!==void 0&&d!==f)Me.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${d}" is invalid. Expected "${f}".`});if(y!==void 0){if(d==="object"||d==="array"){if(!U7(e,y))Me.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(y)}.`})}else if(e!==y)Me.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(y)}.`})}if(v!==void 0){if(d==="object"||d==="array"){if(!v.some((le)=>U7(e,le)))Me.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`})}else if(!v.some((le)=>e===le))Me.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(v)}.`})}if(_!==void 0){let le=`${s}/not`;if(Vs(e,_,n,r,a,i,o,le).valid)Me.push({instanceLocation:o,keyword:"not",keywordLocation:le,error:'Instance matched "not" schema.'})}let me=[];if(E!==void 0){let le=`${s}/anyOf`,fe=Me.length,ye=!1;for(let Ce=0;Ce<E.length;Ce++){let Ie=E[Ce],Ee=Object.create(l),J=Vs(e,Ie,n,r,a,A===!0?i:null,o,`${le}/${Ce}`,Ee);if(Me.push(...J.errors),ye=ye||J.valid,J.valid)me.push(Ee)}if(ye)Me.length=fe;else Me.splice(fe,0,{instanceLocation:o,keyword:"anyOf",keywordLocation:le,error:"Instance does not match any subschemas."})}if(F!==void 0){let le=`${s}/allOf`,fe=Me.length,ye=!0;for(let Ce=0;Ce<F.length;Ce++){let Ie=F[Ce],Ee=Object.create(l),J=Vs(e,Ie,n,r,a,A===!0?i:null,o,`${le}/${Ce}`,Ee);if(Me.push(...J.errors),ye=ye&&J.valid,J.valid)me.push(Ee)}if(ye)Me.length=fe;else Me.splice(fe,0,{instanceLocation:o,keyword:"allOf",keywordLocation:le,error:"Instance does not match every subschema."})}if(T!==void 0){let le=`${s}/oneOf`,fe=Me.length,ye=T.filter((Ce,Ie)=>{let Ee=Object.create(l),J=Vs(e,Ce,n,r,a,A===!0?i:null,o,`${le}/${Ie}`,Ee);if(Me.push(...J.errors),J.valid)me.push(Ee);return J.valid}).length;if(ye===1)Me.length=fe;else Me.splice(fe,0,{instanceLocation:o,keyword:"oneOf",keywordLocation:le,error:`Instance does not match exactly one subschema (${ye} matches).`})}if(d==="object"||d==="array")Object.assign(l,...me);if(R!==void 0){let le=`${s}/if`;if(Vs(e,R,n,r,a,i,o,le,l).valid){if(O!==void 0){let fe=Vs(e,O,n,r,a,i,o,`${s}/then`,l);if(!fe.valid)Me.push({instanceLocation:o,keyword:"if",keywordLocation:le,error:'Instance does not match "then" schema.'},...fe.errors)}}else if(j!==void 0){let fe=Vs(e,j,n,r,a,i,o,`${s}/else`,l);if(!fe.valid)Me.push({instanceLocation:o,keyword:"if",keywordLocation:le,error:'Instance does not match "else" schema.'},...fe.errors)}}if(d==="object"){if(x!==void 0){for(let Ce of x)if(!(Ce in e))Me.push({instanceLocation:o,keyword:"required",keywordLocation:`${s}/required`,error:`Instance does not have required property "${Ce}".`})}let le=Object.keys(e);if(I!==void 0&&le.length<I)Me.push({instanceLocation:o,keyword:"minProperties",keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${I} properties.`});if(C!==void 0&&le.length>C)Me.push({instanceLocation:o,keyword:"maxProperties",keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${C} properties.`});if(B!==void 0){let Ce=`${s}/propertyNames`;for(let Ie in e){let Ee=`${o}/${Bh(Ie)}`,J=Vs(Ie,B,n,r,a,i,Ee,Ce);if(!J.valid)Me.push({instanceLocation:o,keyword:"propertyNames",keywordLocation:Ce,error:`Property name "${Ie}" does not match schema.`},...J.errors)}}if(L!==void 0){let Ce=`${s}/dependantRequired`;for(let Ie in L)if(Ie in e){let Ee=L[Ie];for(let J of Ee)if(!(J in e))Me.push({instanceLocation:o,keyword:"dependentRequired",keywordLocation:Ce,error:`Instance has "${Ie}" but does not have "${J}".`})}}if(M!==void 0)for(let Ce in M){let Ie=`${s}/dependentSchemas`;if(Ce in e){let Ee=Vs(e,M[Ce],n,r,a,i,o,`${Ie}/${Bh(Ce)}`,l);if(!Ee.valid)Me.push({instanceLocation:o,keyword:"dependentSchemas",keywordLocation:Ie,error:`Instance has "${Ce}" but does not match dependant schema.`},...Ee.errors)}}if(Q!==void 0){let Ce=`${s}/dependencies`;for(let Ie in Q)if(Ie in e){let Ee=Q[Ie];if(Array.isArray(Ee)){for(let J of Ee)if(!(J in e))Me.push({instanceLocation:o,keyword:"dependencies",keywordLocation:Ce,error:`Instance has "${Ie}" but does not have "${J}".`})}else{let J=Vs(e,Ee,n,r,a,i,o,`${Ce}/${Bh(Ie)}`);if(!J.valid)Me.push({instanceLocation:o,keyword:"dependencies",keywordLocation:Ce,error:`Instance has "${Ie}" but does not match dependant schema.`},...J.errors)}}}let fe=Object.create(null),ye=!1;if(G!==void 0){let Ce=`${s}/properties`;for(let Ie in G){if(!(Ie in e))continue;let Ee=`${o}/${Bh(Ie)}`,J=Vs(e[Ie],G[Ie],n,r,a,i,Ee,`${Ce}/${Bh(Ie)}`);if(J.valid)l[Ie]=fe[Ie]=!0;else if(ye=a,Me.push({instanceLocation:o,keyword:"properties",keywordLocation:Ce,error:`Property "${Ie}" does not match schema.`},...J.errors),ye)break}}if(!ye&&W!==void 0){let Ce=`${s}/patternProperties`;for(let Ie in W){let Ee=new RegExp(Ie,"u"),J=W[Ie];for(let Be in e){if(!Ee.test(Be))continue;let de=`${o}/${Bh(Be)}`,te=Vs(e[Be],J,n,r,a,i,de,`${Ce}/${Bh(Ie)}`);if(te.valid)l[Be]=fe[Be]=!0;else ye=a,Me.push({instanceLocation:o,keyword:"patternProperties",keywordLocation:Ce,error:`Property "${Be}" matches pattern "${Ie}" but does not match associated schema.`},...te.errors)}}}if(!ye&&b!==void 0){let Ce=`${s}/additionalProperties`;for(let Ie in e){if(fe[Ie])continue;let Ee=`${o}/${Bh(Ie)}`,J=Vs(e[Ie],b,n,r,a,i,Ee,Ce);if(J.valid)l[Ie]=!0;else ye=a,Me.push({instanceLocation:o,keyword:"additionalProperties",keywordLocation:Ce,error:`Property "${Ie}" does not match additional properties schema.`},...J.errors)}}else if(!ye&&k!==void 0){let Ce=`${s}/unevaluatedProperties`;for(let Ie in e)if(!l[Ie]){let Ee=`${o}/${Bh(Ie)}`,J=Vs(e[Ie],k,n,r,a,i,Ee,Ce);if(J.valid)l[Ie]=!0;else Me.push({instanceLocation:o,keyword:"unevaluatedProperties",keywordLocation:Ce,error:`Property "${Ie}" does not match unevaluated properties schema.`},...J.errors)}}}else if(d==="array"){if(ke!==void 0&&e.length>ke)Me.push({instanceLocation:o,keyword:"maxItems",keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${ke}).`});if(re!==void 0&&e.length<re)Me.push({instanceLocation:o,keyword:"minItems",keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${re}).`});let le=e.length,fe=0,ye=!1;if(w!==void 0){let Ce=`${s}/prefixItems`,Ie=Math.min(w.length,le);for(;fe<Ie;fe++){let Ee=Vs(e[fe],w[fe],n,r,a,i,`${o}/${fe}`,`${Ce}/${fe}`);if(l[fe]=!0,!Ee.valid){if(ye=a,Me.push({instanceLocation:o,keyword:"prefixItems",keywordLocation:Ce,error:"Items did not match schema."},...Ee.errors),ye)break}}}if(N!==void 0){let Ce=`${s}/items`;if(Array.isArray(N)){let Ie=Math.min(N.length,le);for(;fe<Ie;fe++){let Ee=Vs(e[fe],N[fe],n,r,a,i,`${o}/${fe}`,`${Ce}/${fe}`);if(l[fe]=!0,!Ee.valid){if(ye=a,Me.push({instanceLocation:o,keyword:"items",keywordLocation:Ce,error:"Items did not match schema."},...Ee.errors),ye)break}}}else for(;fe<le;fe++){let Ie=Vs(e[fe],N,n,r,a,i,`${o}/${fe}`,Ce);if(l[fe]=!0,!Ie.valid){if(ye=a,Me.push({instanceLocation:o,keyword:"items",keywordLocation:Ce,error:"Items did not match schema."},...Ie.errors),ye)break}}if(!ye&&U!==void 0){let Ie=`${s}/additionalItems`;for(;fe<le;fe++){let Ee=Vs(e[fe],U,n,r,a,i,`${o}/${fe}`,Ie);if(l[fe]=!0,!Ee.valid)ye=a,Me.push({instanceLocation:o,keyword:"additionalItems",keywordLocation:Ie,error:"Items did not match additional items schema."},...Ee.errors)}}}if(Z!==void 0)if(le===0&&ee===void 0)Me.push({instanceLocation:o,keyword:"contains",keywordLocation:`${s}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(ee!==void 0&&le<ee)Me.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array has less items (${le}) than minContains (${ee}).`});else{let Ce=`${s}/contains`,Ie=Me.length,Ee=0;for(let J=0;J<le;J++){let Be=Vs(e[J],Z,n,r,a,i,`${o}/${J}`,Ce);if(Be.valid)l[J]=!0,Ee++;else Me.push(...Be.errors)}if(Ee>=(ee||0))Me.length=Ie;if(ee===void 0&&ne===void 0&&Ee===0)Me.splice(Ie,0,{instanceLocation:o,keyword:"contains",keywordLocation:Ce,error:"Array does not contain item matching schema."});else if(ee!==void 0&&Ee<ee)Me.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array must contain at least ${ee} items matching schema. Only ${Ee} items were found.`});else if(ne!==void 0&&Ee>ne)Me.push({instanceLocation:o,keyword:"maxContains",keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${ne} items matching schema. ${Ee} items were found.`})}if(!ye&&q!==void 0){let Ce=`${s}/unevaluatedItems`;for(;fe<le;fe++){if(l[fe])continue;let Ie=Vs(e[fe],q,n,r,a,i,`${o}/${fe}`,Ce);if(l[fe]=!0,!Ie.valid)Me.push({instanceLocation:o,keyword:"unevaluatedItems",keywordLocation:Ce,error:"Items did not match unevaluated items schema."},...Ie.errors)}}if(se)for(let Ce=0;Ce<le;Ce++){let Ie=e[Ce],Ee=typeof Ie==="object"&&Ie!==null;for(let J=0;J<le;J++){if(Ce===J)continue;let Be=e[J];if(Ie===Be||Ee&&typeof Be==="object"&&Be!==null&&U7(Ie,Be))Me.push({instanceLocation:o,keyword:"uniqueItems",keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${Ce} and ${J}.`}),Ce=Number.MAX_SAFE_INTEGER,J=Number.MAX_SAFE_INTEGER}}}else if(d==="number"){if(n==="4"){if(he!==void 0&&(ge===!0&&e<=he||e<he))Me.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${ge?"or equal to ":""} ${he}.`});if(ce!==void 0&&(Qe===!0&&e>=ce||e>ce))Me.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Qe?"or equal to ":""} ${ce}.`})}else{if(he!==void 0&&e<he)Me.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${he}.`});if(ce!==void 0&&e>ce)Me.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${ce}.`});if(ge!==void 0&&e<=ge)Me.push({instanceLocation:o,keyword:"exclusiveMinimum",keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${ge}.`});if(Qe!==void 0&&e>=Qe)Me.push({instanceLocation:o,keyword:"exclusiveMaximum",keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${Qe}.`})}if(Oe!==void 0){let le=e%Oe;if(Math.abs(0-le)>=0.00000011920929&&Math.abs(Oe-le)>=0.00000011920929)Me.push({instanceLocation:o,keyword:"multipleOf",keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${Oe}.`})}}else if(d==="string"){let le=_e===void 0&&Re===void 0?0:Cea(e);if(_e!==void 0&&le<_e)Me.push({instanceLocation:o,keyword:"minLength",keywordLocation:`${s}/minLength`,error:`String is too short (${le} < ${_e}).`});if(Re!==void 0&&le>Re)Me.push({instanceLocation:o,keyword:"maxLength",keywordLocation:`${s}/maxLength`,error:`String is too long (${le} > ${Re}).`});if(We!==void 0&&!new RegExp(We,"u").test(e))Me.push({instanceLocation:o,keyword:"pattern",keywordLocation:`${s}/pattern`,error:"String does not match pattern."});if(H!==void 0&&egn[H]&&!egn[H](e))Me.push({instanceLocation:o,keyword:"format",keywordLocation:`${s}/format`,error:`String does not match format "${H}".`})}return{valid:Me.length===0,errors:Me}}var xea=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",n=!0){this.schema=e,this.draft=t,this.shortCircuit=n,this.lookup=p2(e)}validate(e){return Vs(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){if(t)e={...e,$id:t};p2(e,this.lookup)}},Wce=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=eAn(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return t==="draft-7"?"7":t}getValidator(e){let t=new xea(e,this.draft??this._draftFor(e),this.shortcircuit);return(n)=>{let r=t.validate(n);return r.valid?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:r.errors.map((a)=>`${a.instanceLocation}: ${a.error}`).join("; ")}}}};var Sea=8,Tea=600000;function Dea(e){if(e?.maxRounds!==void 0&&(!Number.isInteger(e.maxRounds)||e.maxRounds<1))throw RangeError(`inputRequired.maxRounds must be a positive integer (got ${e.maxRounds})`);if(e?.roundTimeoutMs!==void 0&&(!Number.isFinite(e.roundTimeoutMs)||e.roundTimeoutMs<=0))throw RangeError(`inputRequired.roundTimeoutMs must be a positive number (got ${e.roundTimeoutMs})`);return{maxRounds:e?.maxRounds??Sea,roundTimeoutMs:e?.roundTimeoutMs??Tea,legacyShim:e?.legacyShim??!0}}function rgn(e,t,n){if(n===null||typeof n!=="object"||typeof n.method!=="string")throw new Ai(Qr.InternalError,`Handler for ${e} returned an invalid input request '${t}': each inputRequests entry must be an embedded elicitation/create, sampling/createMessage, or roots/list request`);let r=n,a=vAn(r);if(a===void 0)throw new Ai(Qr.InternalError,`Handler for ${e} returned an input request '${t}' of kind '${r.method}', which is not an embedded request the 2026-07-28 revision defines`);return{embedded:r,required:a}}function Rea(){let e=globalThis.crypto;if(e?.randomUUID!==void 0)return e.randomUUID();let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=[...t].map((r)=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function l$e(e,t){if(e==="tools/call")return{content:[{type:"text",text:t}],isError:!0};throw new Ai(Qr.InternalError,t)}var Qea=class{constructor(e){this._host=e}async fulfill(e,t,n,r,a){let{maxRounds:i,roundTimeoutMs:o}=this._host,s=r.mcpReq.signal,l=a,u=0;while(!0){if(u+=1,u>i)return l$e(e,WAn(e,i));let d=l.inputRequests,p=d!=null&&Object.keys(d).length>0,m=typeof l.requestState==="string"?l.requestState:void 0;if(!p&&m===void 0)throw new Ai(Qr.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);let A;if(p){let v=this._host.resolvedClientCapabilities(r),x=[];for(let[E,F]of Object.entries(d)){let{embedded:T,required:R}=rgn(e,E,F);if(T.method!=="roots/list"&&T.params===void 0)throw new Ai(Qr.InternalError,`Handler for ${e} returned an input request '${E}' of kind '${T.method}' without params`);if(Gce(R,v)!==void 0)return l$e(e,`Cannot request input '${E}' (${T.method}): the client on this 2025-era connection did not declare the required capability${v===void 0?" (no client capabilities are available on this connection — per-request legacy serving cannot receive server-to-client requests)":""}`);x.push([E,T])}let _=VAn(s);try{let E={relatedRequestId:r.mcpReq.id,timeout:o,resetTimeoutOnProgress:!0,onprogress:()=>{},signal:_.signal},F=await Promise.all(x.map(async([T,R])=>{try{return[T,await this._dispatchLeg(R,E)]}catch(O){throw _.abort(O),O}}));A=Object.fromEntries(F)}catch(E){if(s.aborted)throw E;return l$e(e,`Fulfilling input required by '${e}' failed: ${E instanceof Error?E.message:String(E)}`)}finally{_.dispose()}}else await YAn(HAn,s);let f={...r,mcpReq:{...r.mcpReq,inputResponses:A,droppedInputResponseKeys:void 0,requestState:G7(m)}};if(m!==void 0){let v=await this._host.verifyRequestState(m,f,e);if(v!==void 0)f=o$e(f,v)}let y=await t(n,f);if(!d2(y))return y;l=y}}async _dispatchLeg(e,t){switch(e.method){case"elicitation/create":{let n=e.params;if(n.mode==="url"&&n.elicitationId===void 0)n={...n,elicitationId:Rea()};return await this._host.sendElicitation(n,t)}case"sampling/createMessage":return await this._host.sendSampling(e.params,t);case"roots/list":return await this._host.listRoots(e.params,t)}}},Lea=new Set(["tools/call","prompts/get","resources/read"]),Mea,Fea,Nea;var Pea=class extends s$e{_clientCapabilities;_clientVersion;static{Mea=(e,t)=>{if(t.clientCapabilities!==void 0)e._clientCapabilities=t.clientCapabilities;if(t.clientInfo!==void 0)e._clientVersion=t.clientInfo},Fea=(e,t)=>{let n=t.filter((r)=>!e._supportedProtocolVersions.includes(r));if(n.length>0)e._supportedProtocolVersions=[...e._supportedProtocolVersions,...n];e.setRequestHandler("server/discover",()=>e._ondiscover())},Nea=(e)=>e._serverInfo}_capabilities;_instructions;_jsonSchemaValidator;_cacheHints;_requestStateVerify;_inputRequiredServing;_legacyShim;_legacyInputRequiredShim(){return this._legacyShim??=new Qea({maxRounds:this._inputRequiredServing.maxRounds,roundTimeoutMs:this._inputRequiredServing.roundTimeoutMs,resolvedClientCapabilities:(e)=>this._inputRequestCapabilityView(e),verifyRequestState:(e,t,n)=>this._verifyRequestState(e,t,n),sendElicitation:(e,t)=>this._sendElicitationLeg(e,t,{validateAcceptedContent:!1}),sendSampling:(e,t)=>this.createMessage(e,t),listRoots:(e,t)=>this.listRoots(e,t)})}oninitialized;constructor(e,t){super(t);if(this._serverInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new Wce,this._requestStateVerify=t?.requestState?.verify,this._inputRequiredServing=Dea(t?.inputRequired),t?.cacheHints!==void 0){for(let[n,r]of Object.entries(t.cacheHints))if(r!==void 0)RAn(r,`cacheHints['${n}']`);this._cacheHints=t.cacheHints}if(this.setRequestHandler("initialize",(n)=>this._oninitialize(n)),this.setNotificationHandler("notifications/initialized",()=>this.oninitialized?.()),V5e(this._supportedProtocolVersions).length>0)this.setRequestHandler("server/discover",()=>this._ondiscover());if(this._capabilities.logging)this._registerLoggingHandler()}_registerLoggingHandler(){this.setRequestHandler("logging/setLevel",async(e,t)=>{let n=t.sessionId||t.http?.req?.headers.get("mcp-session-id")||void 0,{level:r}=e.params,a=Hce(n_,r);if(a.success)this._loggingLevels.set(n,a.data);return{}})}buildContext(e,t){let n=e.http||t?.request||t?.closeSSEStream||t?.closeStandaloneSSEStream;return{...e,mcpReq:{...e.mcpReq,log:(r,a,i)=>{if(!this._capabilities.logging)return Promise.resolve();let o;if(this._servedModernEra()){if(o=e.mcpReq.envelope?.[Z1],o===void 0)return Promise.resolve()}else o=this._loggingLevels.get(e.sessionId)??this._loggingLevels.get(void 0);if(o!==void 0&&this.LOG_LEVEL_SEVERITY.get(r)<this.LOG_LEVEL_SEVERITY.get(o))return Promise.resolve();return e.mcpReq.notify({method:"notifications/message",params:{level:r,data:a,logger:i}})},elicitInput:(r,a)=>this.elicitInput(r,a),requestSampling:(r,a)=>this.createMessage(r,a)},http:n?{...e.http,req:t?.request,closeSSE:t?.closeSSEStream,closeStandaloneSSE:t?.closeStandaloneSSEStream}:void 0}}_loggingLevels=new Map;LOG_LEVEL_SEVERITY=new Map(n_.options.map((e,t)=>[e,t]));isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1};registerCapabilities(e){if(this.transport)throw new $a(oi.AlreadyConnected,"Cannot register capabilities after connecting to transport");let t=!!this._capabilities.logging;if(this._capabilities=c$e(this._capabilities,e),!t&&this._capabilities.logging)this._registerLoggingHandler()}_wrapHandler(e,t){if(e!=="tools/call"){let n=this._cacheHints?.[e],r=Lea.has(e);if(n===void 0&&!r)return async(a,i)=>{let o=await t(a,i);if(d2(o))throw new Ai(Qr.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return o};return async(a,i)=>{let o=r?await this._invokeInputRequiredCapableHandler(e,t,a,i):await t(a,i);if(d2(o)){if(!r)throw new Ai(Qr.InternalError,`Handler for ${e} returned an input-required result, but only tools/call, prompts/get and resources/read support input_required (protocol revision 2026-07-28)`);return o}return n===void 0?o:DAn(o,n)}}return async(n,r)=>{let a=TQ(this._negotiatedProtocolVersion),i=a.validateRequest("tools/call",n);if(!i.ok)throw new Ai(i.reason==="not-in-era"?Qr.InternalError:Qr.InvalidParams,i.reason==="not-in-era"?"No wire schema for tools/call in the resolved era":`Invalid tools/call request: ${i.message}`);let o=await this._invokeInputRequiredCapableHandler("tools/call",t,n,r);if(d2(o))return o;let s=Z5e(o),l=a.validateResult("tools/call",s);if(!l.ok)throw new Ai(l.reason==="not-in-era"?Qr.InternalError:Qr.InvalidParams,l.reason==="not-in-era"?"No wire schema for tools/call in the resolved era":`Invalid tools/call result: ${l.message}`);return l.value}}_servedModernEra(){return this._negotiatedProtocolVersion!==void 0&&q7(this._negotiatedProtocolVersion)}async _invokeInputRequiredCapableHandler(e,t,n,r){let a=this._servedModernEra(),i=r.mcpReq.requestState();if(i!==void 0&&typeof i!=="string")throw new Ai(Qr.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"});let o=r;if(typeof i==="string"){let p=await this._verifyRequestState(i,r,e);if(p!==void 0)o=o$e(r,p)}let s;try{s=await t(n,o)}catch(p){if(p instanceof Ai&&p.code===Qr.UrlElicitationRequired){if(!a)throw p;throw new Ai(Qr.InternalError,`URL elicitation cannot be signalled by throwing UrlElicitationRequiredError on protocol revision ${this._negotiatedProtocolVersion}: return inputRequired({ inputRequests: { …: inputRequired.elicitUrl(...) } }) from the handler instead. The urlElicitationRequired error (-32042) of earlier revisions is not available on this revision.`)}throw p}if(!d2(s))return s;if(!a){if(!this._inputRequiredServing.legacyShim)throw new Ai(Qr.InternalError,`Handler for ${e} returned an input-required result, but this request is served on protocol revision ${this._negotiatedProtocolVersion??o2}, which has no input_required vocabulary`);return await this._legacyInputRequiredShim().fulfill(e,t,n,o,s)}let l=s.inputRequests,u=l!=null&&Object.keys(l).length>0,d=typeof s.requestState==="string";if(!u&&!d)throw new Ai(Qr.InternalError,`Handler for ${e} returned an input-required result with neither inputRequests nor requestState (every InputRequiredResult must include at least one of the two)`);if(u){let p=this._inputRequestCapabilityView(r);for(let[m,A]of Object.entries(l)){let{embedded:f,required:y}=rgn(e,m,A),v=Gce(y,p);if(v!==void 0)throw new Uce({requiredCapabilities:v},`Cannot request input '${m}' (${f.method}): the request's client capabilities do not declare the required capability`)}}return s}async _verifyRequestState(e,t,n){if(this._requestStateVerify===void 0)return;try{return await this._requestStateVerify(e,t)}catch(r){throw this.onerror?.(Error(`requestState verification rejected ${n}: ${r instanceof Error?r.message:String(r)}`)),new Ai(Qr.InvalidParams,"Invalid or expired requestState",{reason:"invalid_request_state"})}}_inputRequestCapabilityView(e){return this._servedModernEra()?e.mcpReq.envelope?.[Vv]:this._clientCapabilities}_assertPushApiInServedEra(e){if(this._servedModernEra())throw new $a(oi.MethodNotSupportedByProtocolVersion,`Server-to-client requests are not available on protocol revision ${this._negotiatedProtocolVersion}: '${e}' cannot be sent while serving a request on that revision. Return inputRequired({ ... }) from the handler instead — the client fulfils the embedded requests and retries the original request (multi round-trip requests).`,{method:e,era:"2026-07-28"})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new $a(oi.CapabilityNotSupported,`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new $a(oi.CapabilityNotSupported,`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new $a(oi.CapabilityNotSupported,`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new $a(oi.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new $a(oi.CapabilityNotSupported,`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new $a(oi.CapabilityNotSupported,`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new $a(oi.CapabilityNotSupported,`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new $a(oi.CapabilityNotSupported,`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"completion/complete":if(!this._capabilities.completions)throw new $a(oi.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new $a(oi.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new $a(oi.CapabilityNotSupported,`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new $a(oi.CapabilityNotSupported,`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new $a(oi.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case"ping":case"initialize":break}}async _oninitialize(e){let t=e.params.protocolVersion;this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo;let n=kAn(this._supportedProtocolVersions),r=n.includes(t)?t:n[0]??o2;return this._negotiatedProtocolVersion=r,this.transport?.setProtocolVersion?.(r),{protocolVersion:r,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}_ondiscover(){return{supportedVersions:V5e(this._supportedProtocolVersions),capabilities:$ea(this.getCapabilities()),...this._instructions&&{instructions:this._instructions}}}_outboundServerInfo(){return this._serverInfo}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}projectCallToolResult(e,t){return this._wireCodec().projectCallToolResult(e,t)}getCapabilities(){return this._capabilities}async ping(){return this._assertPushApiInServedEra("ping"),this.request({method:"ping"})}async createMessage(e,t){if(this._assertPushApiInServedEra("sampling/createMessage"),(e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new $a(oi.CapabilityNotSupported,"Client does not support sampling tools capability.");if(e.messages.length>0){let i=e.messages.at(-1),o=Array.isArray(i.content)?i.content:[i.content],s=o.some((p)=>p.type==="tool_result"),l=e.messages.length>1?e.messages.at(-2):void 0,u=l?Array.isArray(l.content)?l.content:[l.content]:[],d=u.some((p)=>p.type==="tool_use");if(s){if(o.some((p)=>p.type!=="tool_result"))throw new Ai(Qr.InvalidParams,"The last message must contain only tool_result content if any is present");if(!d)throw new Ai(Qr.InvalidParams,"tool_result blocks are not matching any tool_use from the previous message")}if(d){let p=new Set(u.filter((A)=>A.type==="tool_use").map((A)=>A.id)),m=new Set(o.filter((A)=>A.type==="tool_result").map((A)=>A.toolUseId));if(p.size!==m.size||![...p].every((A)=>m.has(A)))throw new Ai(Qr.InvalidParams,"ids of tool_result blocks and tool_use blocks from previous message do not match")}}let n=Boolean(e.tools||e.toolChoice),r=await this.request({method:"sampling/createMessage",params:e},t),a=this._wireCodec().samplingResultVariant(n,r);if(!a.ok)throw new $a(oi.InvalidResult,`Invalid sampling/createMessage result: ${a.reason==="invalid"?a.message:a.reason}`);return a.value}async elicitInput(e,t){switch(this._assertPushApiInServedEra("elicitation/create"),e.mode??"form"){case"url":if(!this._clientCapabilities?.elicitation?.url)throw new $a(oi.CapabilityNotSupported,"Client does not support url elicitation.");break;case"form":if(!this._clientCapabilities?.elicitation?.form)throw new $a(oi.CapabilityNotSupported,"Client does not support form elicitation.");break}return this._sendElicitationLeg(e,t)}async _sendElicitationLeg(e,t,n){let r=e.mode??"form",a=n?.validateAcceptedContent??!0;switch(r){case"url":{let i=e;return this.request({method:"elicitation/create",params:i},t)}case"form":{let i=e.mode==="form"?e:{...e,mode:"form"},o=await this.request({method:"elicitation/create",params:i},t);if(a&&o.action==="accept"&&o.content&&i.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(i.requestedSchema)(o.content);if(!s.valid)throw new Ai(Qr.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(s){if(s instanceof Ai)throw s;throw new Ai(Qr.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}return o}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new $a(oi.CapabilityNotSupported,"Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},t)}async listRoots(e,t){return this._assertPushApiInServedEra("roots/list"),this.request({method:"roots/list",params:e},t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};function $ea(e){return{...e}}var agn=P.object({interfaceType:P.string(),actor:UA,displayName:P.string().optional(),conversationId:P.string().optional(),channelId:P.string().optional(),channelName:P.string().optional(),runId:P.string().optional(),toolCallId:P.string().optional(),userPermissionLevel:P.enum(["admin","trusted","public"]).optional(),isAnchor:P.boolean().optional()}),ign=P.strictObject({success:P.literal(!0),data:P.unknown().optional(),message:P.string().optional(),cached:P.literal(!0).optional()}),ogn=P.strictObject({success:P.literal(!1),error:P.string(),code:P.string().optional()}),sgn=P.strictObject({needsConfirmation:P.literal(!0),toolName:P.string(),summary:P.string(),completionSummary:P.string().optional(),preview:P.string().optional(),args:P.unknown()}),Yce=P.union([ign,ogn,sgn]);var myc=P.union([P.looseObject({success:P.literal(!0)}),P.object({success:P.literal(!1),error:P.string()})]);var cgn=P.union([P.object({success:P.literal(!0),data:P.unknown(),message:P.string().optional()}),P.object({success:P.literal(!1),error:P.string(),code:P.string().optional()})]);td();var d0c=Symbol("rizom.studio-workspace-executor");var p$e=P.enum(["text","url","number","checkbox","select"]),Jea=p$e.exclude(["select"]);var hr=P.string().trim().min(1).max(120),H7=P.string().trim().min(1).max(400),Or=P.string().trim().min(1).max(160),hu=P.string().max(500),a_=P.string().max(4000),Xea=P.string().max(1e5),jp=P.enum(["good","warn","neutral","error"]),Zce=P.union([P.string().max(2000),P.number().finite(),P.boolean(),P.null()]),lgn=P.string().max(2048).refine((e)=>{try{let t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"}catch{return!1}},{message:"External operator links must use http or https"});function eta(e){return e!==null&&typeof e==="object"&&"kind"in e&&e.kind==="rizom-entity"&&"type"in e&&typeof e.type==="string"&&e.type.length>0}var tta=P.custom(eta,{message:"Expected an imported entity definition"});function nta(e){return e!==null&&typeof e==="object"&&"kind"in e&&e.kind==="rizom-entity-catalog"&&"id"in e&&typeof e.id==="string"&&"label"in e&&typeof e.label==="string"}var rta=P.custom(nta,{message:"Expected an imported entity catalog definition"});function ata(e){return{kind:"external",href:e.external}}function ita(e){return{kind:"entity",entityType:e.entity.type,id:e.id}}var ugn=P.union([P.object({target:P.literal("account-settings")}).strict(),P.object({target:P.literal("invitations")}).strict(),P.object({target:P.literal("admin-peer-invite"),peerId:hr,displayName:Or}).strict(),P.object({target:P.literal("inbox")}).strict(),P.object({target:P.literal("inbox"),source:P.literal("mail"),filter:P.enum(["high-priority","needs-reply","unclassified"]).optional()}).strict(),P.object({target:P.literal("publishing")}).strict(),P.object({target:P.literal("site")}).strict(),P.object({target:P.literal("inbox-open-entity"),entityType:hr,entityId:hr}).strict(),P.object({target:P.literal("inbox-capture-note"),title:hu,summary:P.string().trim().min(1).max(1000).optional(),entityType:hr,entityId:hr}).strict(),P.object({target:P.literal("inbox-discuss-in-chat"),sourceId:hr,itemId:P.string().trim().min(1).max(300),label:P.string().trim().min(1).max(160)}).strict()]);function ota(e){return{kind:"entity",entityType:e.entityType,id:e.id}}function sta(e){return{kind:"launch",launch:e.launch}}function cta(e){return{kind:"detail",itemId:e.detail.itemId}}var Vce=P.union([P.object({external:lgn}).strict().transform(ata),P.object({entity:tta,id:hr}).strict().transform(ita),P.object({catalog:rta,entityType:hr,id:hr}).strict().transform(ota),P.object({launch:ugn}).strict().transform(sta),P.object({detail:P.object({itemId:H7}).strict()}).strict().transform(cta),P.object({kind:P.literal("external"),href:lgn}).strict(),P.object({kind:P.literal("entity"),entityType:hr,id:hr}).strict(),P.object({kind:P.literal("launch"),launch:ugn}).strict(),P.object({kind:P.literal("detail"),itemId:H7}).strict()]),lta=P.object({label:Or,value:P.union([P.string().max(500),P.number().finite()]),caption:hu.optional(),tone:jp.optional()}).strict(),uta=P.object({label:Or,value:Zce}).strict(),pgn=P.object({type:P.literal("stats"),id:hr.optional(),items:P.array(lta).max(20)}).strict(),mgn=P.object({type:P.literal("key-values"),id:hr.optional(),items:P.array(uta).max(40)}).strict(),Agn=P.object({type:P.literal("notice"),id:hr.optional(),title:Or.optional(),text:a_,tone:jp.optional()}).strict(),dta=P.object({type:P.literal("text"),id:hr.optional(),label:Or.optional(),text:Xea,truncated:P.boolean().optional()}).strict(),pta=P.object({id:hr,label:Or,value:Zce.optional(),description:a_.optional(),tone:jp.optional()}).strict(),ggn=P.object({type:P.literal("group"),id:hr,label:Or,items:P.array(pta).max(50)}).strict(),mta=P.object({id:hr,label:Or,status:P.enum(["idle","active","complete","failed"]),detail:hu.optional()}).strict(),fgn=P.object({type:P.literal("flow"),id:hr,label:Or,direction:P.enum(["forward","bidirectional"]).optional(),steps:P.array(mta).min(2).max(20)}).strict(),Ata=P.object({id:hr,label:Or,value:P.number().finite().nonnegative(),max:P.number().finite().positive().optional(),unit:Or.optional(),tone:jp.optional()}).strict().superRefine((e,t)=>{if(e.max!==void 0&&e.value>e.max)t.addIssue({code:"custom",message:"Meter value cannot exceed its maximum",path:["value"]})}),hgn=P.object({type:P.literal("meters"),id:hr,items:P.array(Ata).max(30)}).strict(),bgn=P.object({type:P.literal("progress"),id:hr,label:Or,state:Or,detail:a_.optional(),startedAt:P.string().datetime().optional(),updatedAt:P.string().datetime().optional(),progress:P.number().finite().min(0).max(1).optional(),tone:jp.optional()}).strict(),gta=P.string().trim().min(1).max(120).regex(/^[a-z][a-zA-Z0-9_.-]*$/),fta=P.object({value:Or,label:Or,count:P.number().int().nonnegative().optional()}).strict(),hta=P.object({key:gta,label:Or,value:Or.optional(),allLabel:Or.optional(),options:P.array(fta).max(100)}).strict(),bta=P.object({type:P.literal("query"),id:hr,controls:P.array(hta).max(20),pagination:P.object({offset:P.number().int().nonnegative(),limit:P.number().int().min(1).max(100),total:P.number().int().nonnegative(),label:Or.optional()}).strict().optional()}).strict().superRefine((e,t)=>{let n=new Set;for(let[r,a]of e.controls.entries()){if(n.has(a.key))t.addIssue({code:"custom",message:`Query key "${a.key}" is duplicated`,path:["controls",r,"key"]});n.add(a.key)}}),ygn=P.object({type:P.literal("links"),id:hr.optional(),items:P.array(P.object({label:Or,target:Vce}).strict()).max(30)}).strict(),yta=P.object({label:Or,tone:jp.optional()}).strict(),wta=P.object({value:hr,label:Or,count:P.number().int().nonnegative().optional(),emphasis:P.literal("gap").optional()}).strict(),m$e=200,wgn=50,vta=m$e*wgn+1,vgn=P.object({label:Or,defaultValue:hr,allValue:hr.optional(),options:P.array(wta).min(1).max(vta)}).strict().superRefine((e,t)=>{let n=new Set;for(let[r,a]of e.options.entries()){if(n.has(a.value))t.addIssue({code:"custom",message:`List filter value "${a.value}" is duplicated`,path:["options",r,"value"]});n.add(a.value)}if(!n.has(e.defaultValue))t.addIssue({code:"custom",message:`List filter default "${e.defaultValue}" has no matching option`,path:["defaultValue"]})}),A$e=P.object({id:H7,title:hu,description:a_.optional(),meta:hu.optional(),metadata:P.array(hu).max(20).optional(),tags:P.array(Or).max(30).optional(),count:P.number().finite().optional(),badges:P.array(yta).max(10).optional(),filterValues:P.array(hr).max(wgn).optional(),links:P.array(P.object({label:Or,target:Vce}).strict()).max(10).optional(),tone:jp.optional(),link:Vce.optional()}).strict(),kta=P.object({type:P.literal("list"),id:hr,empty:hu,filter:vgn.optional(),items:P.array(A$e).max(m$e)}).strict().superRefine((e,t)=>{let n=new Set;for(let[r,a]of e.items.entries()){if(n.has(a.id))t.addIssue({code:"custom",message:`List item id "${a.id}" is duplicated`,path:["items",r,"id"]});n.add(a.id)}if(e.filter){let r=new Set(e.filter.options.map((i)=>i.value)),a=e.filter.allValue??"all";for(let[i,o]of e.items.entries())for(let s of o.filterValues??[])if(s!==a&&!r.has(s))t.addIssue({code:"custom",message:`List item filter value "${s}" has no matching option`,path:["items",i,"filterValues"]})}}),kgn=P.object({key:hr,label:Or,align:P.enum(["start","center","end"]).optional()}).strict(),Cgn=P.object({key:hr,label:Or,values:P.array(Zce).max(50)}).strict(),Cta=P.union([Zce,P.array(P.string().max(500)).max(50)]),xgn=P.object({id:H7,cells:P.record(P.string(),Cta),link:Vce.optional()}).strict(),xta=P.object({type:P.literal("table"),id:hr,empty:hu,filters:P.array(Cgn).max(20).optional(),columns:P.array(kgn).min(1).max(30),rows:P.array(xgn).max(500)}).strict().superRefine((e,t)=>{let n=new Set;for(let[a,i]of e.columns.entries()){if(n.has(i.key))t.addIssue({code:"custom",message:`Table column key "${i.key}" is duplicated`,path:["columns",a,"key"]});n.add(i.key)}for(let[a,i]of(e.filters??[]).entries())if(!n.has(i.key))t.addIssue({code:"custom",message:`Table filter key "${i.key}" has no matching column`,path:["filters",a,"key"]});let r=new Set;for(let[a,i]of e.rows.entries()){if(r.has(i.id))t.addIssue({code:"custom",message:`Table row id "${i.id}" is duplicated`,path:["rows",a,"id"]});r.add(i.id);for(let o of Object.keys(i.cells))if(!n.has(o))t.addIssue({code:"custom",message:`Table cell key "${o}" has no matching column`,path:["rows",a,"cells",o]})}}),_ta=P.object({id:hr,label:Or,tone:jp.optional(),empty:hu,items:P.array(A$e).max(100)}).strict().superRefine((e,t)=>{let n=new Set;for(let[r,a]of e.items.entries()){if(n.has(a.id))t.addIssue({code:"custom",message:`Matrix item id "${a.id}" is duplicated`,path:["items",r,"id"]});n.add(a.id)}}),Eta=P.object({type:P.literal("matrix"),id:hr,columns:P.union([P.literal(1),P.literal(2),P.literal(3),P.literal(4)]).optional(),cells:P.array(_ta).min(1).max(12)}).strict().superRefine((e,t)=>{let n=new Set;for(let[r,a]of e.cells.entries()){if(n.has(a.id))t.addIssue({code:"custom",message:`Matrix cell id "${a.id}" is duplicated`,path:["cells",r,"id"]});n.add(a.id)}}),_gn=P.object({label:Or,tone:jp.optional()}).strict(),Egn=P.object({sourceId:hr,targetId:hr,label:Or.optional(),tone:jp.optional()}).strict(),DQ=P.number().finite().min(0).max(1),Bta=P.object({id:hr,label:Or,category:Or,x:DQ,y:DQ,zoneId:hr.optional(),tone:jp.optional(),details:P.array(hu).max(20).optional()}).strict(),Ita=P.object({id:hr,label:Or,x:DQ,y:DQ,memberIds:P.array(hr).max(500)}).strict(),Sta=P.object({type:P.literal("spatial"),layout:P.literal("cartesian"),id:hr,label:Or,description:a_,points:P.array(Bta).max(500),zones:P.array(Ita).max(100),relationships:P.array(Egn).max(2000).optional(),legend:P.array(_gn).max(20)}).strict().superRefine((e,t)=>{let n=new Set;for(let[i,o]of e.points.entries()){if(n.has(o.id))t.addIssue({code:"custom",message:`Spatial point id "${o.id}" is duplicated`,path:["points",i,"id"]});n.add(o.id)}let r=new Set;for(let[i,o]of e.zones.entries()){if(r.has(o.id)||n.has(o.id))t.addIssue({code:"custom",message:`Spatial zone id "${o.id}" is duplicated`,path:["zones",i,"id"]});r.add(o.id);for(let s of o.memberIds)if(!n.has(s))t.addIssue({code:"custom",message:`Spatial zone member "${s}" has no matching point`,path:["zones",i,"memberIds"]})}for(let[i,o]of e.points.entries())if(o.zoneId&&!r.has(o.zoneId))t.addIssue({code:"custom",message:`Spatial point zone "${o.zoneId}" has no matching zone`,path:["points",i,"zoneId"]});let a=new Set([...n,...r]);for(let[i,o]of(e.relationships??[]).entries())if(!a.has(o.sourceId)||!a.has(o.targetId))t.addIssue({code:"custom",message:"Spatial relationship endpoints must reference declared points or zones",path:["relationships",i]})}),Tta=P.object({id:hr,label:Or,kind:Or,status:Or,tags:P.array(Or).max(30).optional(),distance:DQ,bearing:P.number().finite().min(0).lt(360),relatedIds:P.array(hr).max(100).optional(),tone:jp.optional(),details:P.array(hu).max(20).optional()}).strict(),Dta=P.object({id:hr,label:Or,memberIds:P.array(hr).min(2).max(500)}).strict(),Rta=P.object({id:hr,label:Or,maxDistance:DQ}).strict(),Qta=P.object({type:P.literal("spatial"),layout:P.literal("radial"),id:hr,label:Or,description:a_,centerLabel:Or,centerKind:P.enum(["identity","centroid"]),points:P.array(Tta).max(500),clusters:P.array(Dta).max(100).optional(),relationships:P.array(Egn).max(2000).optional(),strata:P.array(Rta).min(1).max(10),legend:P.array(_gn).max(20)}).strict().superRefine((e,t)=>{let n=new Set;for(let[i,o]of e.points.entries()){if(n.has(o.id))t.addIssue({code:"custom",message:`Spatial point id "${o.id}" is duplicated`,path:["points",i,"id"]});n.add(o.id)}for(let[i,o]of e.points.entries())for(let s of o.relatedIds??[])if(!n.has(s))t.addIssue({code:"custom",message:`Related point "${s}" is not declared`,path:["points",i,"relatedIds"]});let r=new Set;for(let[i,o]of(e.clusters??[]).entries()){if(r.has(o.id))t.addIssue({code:"custom",message:`Spatial cluster id "${o.id}" is duplicated`,path:["clusters",i,"id"]});r.add(o.id);for(let s of o.memberIds)if(!n.has(s))t.addIssue({code:"custom",message:`Spatial cluster member "${s}" has no matching point`,path:["clusters",i,"memberIds"]})}for(let[i,o]of(e.relationships??[]).entries())if(!n.has(o.sourceId)||!n.has(o.targetId))t.addIssue({code:"custom",message:"Spatial relationship endpoints must reference declared points",path:["relationships",i]});let a=-1;for(let[i,o]of e.strata.entries()){if(o.maxDistance<=a)t.addIssue({code:"custom",message:"Radial strata must increase by maximum distance",path:["strata",i,"maxDistance"]});a=o.maxDistance}}),Bgn=P.discriminatedUnion("layout",[Sta,Qta]),Ign=P.union([pgn,mgn,Agn,ggn,fgn,hgn,bgn,ygn,kta,xta,Eta,Bgn]),Lta=P.object({type:P.literal("tabs"),id:hr,label:Or,defaultTab:hr,tabs:P.array(P.object({id:hr,label:Or,count:P.number().int().nonnegative().optional(),blocks:P.array(Ign).max(30)}).strict()).min(1).max(12)}).strict().superRefine((e,t)=>{let n=new Set;for(let[r,a]of e.tabs.entries()){if(n.has(a.id))t.addIssue({code:"custom",message:`Tab id "${a.id}" is duplicated`,path:["tabs",r,"id"]});n.add(a.id)}if(!n.has(e.defaultTab))t.addIssue({code:"custom",message:`Default tab "${e.defaultTab}" has no matching tab`,path:["defaultTab"]})});function Mta(e){return e!==null&&typeof e==="object"&&"kind"in e&&e.kind==="rizom-workspace-action"&&"name"in e&&typeof e.name==="string"&&"input"in e&&typeof e.input==="object"&&e.input!==null&&"safeParse"in e.input&&typeof e.input.safeParse==="function"}var Fta=P.custom(Mta,{message:"Expected a workspace action definition"}),Nta=P.object({id:hr,label:Or,description:a_.optional(),confirmation:P.literal("prepared").optional()}).strict(),dgn=P.object({value:P.string().trim().min(1).max(500),label:Or}).strict(),Pta=P.object({label:Or,control:p$e,secret:P.boolean().optional(),options:P.array(dgn).min(1).max(100).optional(),labelBy:P.object({field:hr,values:P.array(dgn).min(1).max(100)}).strict().optional()}).strict(),$ta=P.object({presentation:P.enum(["inline","disclosure"]).optional(),submitLabel:Or.optional(),fields:P.record(hr,Pta)}).strict(),Ota=P.object({label:Or,copyable:P.boolean().optional(),sensitive:P.boolean().optional()}).strict(),zta=P.object({title:Or,fields:P.record(hr,Ota)}).strict(),Kce=P.object({action:Fta,input:P.unknown().optional(),form:$ta.optional(),result:zta.optional(),capability:Nta.optional(),disabled:P.boolean().optional()}).strict(),Sgn=A$e.extend({actions:P.array(Kce).max(20).optional()}),Tgn=P.object({type:P.literal("list"),id:hr,empty:hu,filter:vgn.optional(),items:P.array(Sgn).max(m$e)}).strict().superRefine((e,t)=>{let n=new Set;for(let[r,a]of e.items.entries()){if(n.has(a.id))t.addIssue({code:"custom",message:`List item id "${a.id}" is duplicated`,path:["items",r,"id"]});n.add(a.id)}if(e.filter){let r=new Set(e.filter.options.map((i)=>i.value)),a=e.filter.allValue??"all";for(let[i,o]of e.items.entries())for(let s of o.filterValues??[])if(s!==a&&!r.has(s))t.addIssue({code:"custom",message:`List item filter value "${s}" has no matching option`,path:["items",i,"filterValues"]})}}),jta=xgn.extend({actions:P.array(Kce).max(20).optional()}),Dgn=P.object({type:P.literal("table"),id:hr,empty:hu,filters:P.array(Cgn).max(20).optional(),columns:P.array(kgn).min(1).max(30),rows:P.array(jta).max(500)}).strict().superRefine((e,t)=>{let n=new Set;for(let[a,i]of e.columns.entries()){if(n.has(i.key))t.addIssue({code:"custom",message:`Table column key "${i.key}" is duplicated`,path:["columns",a,"key"]});n.add(i.key)}for(let[a,i]of(e.filters??[]).entries())if(!n.has(i.key))t.addIssue({code:"custom",message:`Table filter key "${i.key}" has no matching column`,path:["filters",a,"key"]});let r=new Set;for(let[a,i]of e.rows.entries()){if(r.has(i.id))t.addIssue({code:"custom",message:`Table row id "${i.id}" is duplicated`,path:["rows",a,"id"]});r.add(i.id);for(let o of Object.keys(i.cells))if(!n.has(o))t.addIssue({code:"custom",message:`Table cell key "${o}" has no matching column`,path:["rows",a,"cells",o]})}}),qta=P.object({id:hr,label:Or,tone:jp.optional(),empty:hu,items:P.array(Sgn).max(100)}).strict().superRefine((e,t)=>{let n=new Set;for(let[r,a]of e.items.entries()){if(n.has(a.id))t.addIssue({code:"custom",message:`Matrix item id "${a.id}" is duplicated`,path:["items",r,"id"]});n.add(a.id)}}),Gta=P.object({type:P.literal("matrix"),id:hr,columns:P.union([P.literal(1),P.literal(2),P.literal(3),P.literal(4)]).optional(),cells:P.array(qta).min(1).max(12)}).strict().superRefine((e,t)=>{let n=new Set;for(let[r,a]of e.cells.entries()){if(n.has(a.id))t.addIssue({code:"custom",message:`Matrix cell id "${a.id}" is duplicated`,path:["cells",r,"id"]});n.add(a.id)}}),Uta=Kce.extend({type:P.literal("action"),id:hr.optional()}),Hta=P.object({type:P.literal("actions"),id:hr.optional(),items:P.array(Kce).max(30)}).strict(),RQ=P.union([pgn,mgn,Agn,dta,ggn,fgn,hgn,bgn,bta,ygn,Tgn,Dgn,Gta,Bgn,Uta,Hta]),Wta=P.object({type:P.literal("tabs"),id:hr,label:Or,defaultTab:hr,queryKey:hr.optional(),tabs:P.array(P.object({id:hr,label:Or,count:P.number().int().nonnegative().optional(),blocks:P.array(P.lazy(()=>P.union([RQ,W7,Rgn,Qgn]))).max(30)}).strict()).min(1).max(12)}).strict().superRefine((e,t)=>{let n=new Set;for(let[r,a]of e.tabs.entries()){if(n.has(a.id))t.addIssue({code:"custom",message:`Tab id "${a.id}" is duplicated`,path:["tabs",r,"id"]});n.add(a.id)}if(!n.has(e.defaultTab))t.addIssue({code:"custom",message:`Default tab "${e.defaultTab}" has no matching tab`,path:["defaultTab"]})}),W7=P.object({type:P.literal("card"),id:hr,label:Or,tone:jp.optional(),blocks:P.array(RQ).max(12)}).strict(),Rgn=P.object({type:P.literal("detail"),id:hr,queryKey:hr,empty:hu,master:P.union([Tgn,Dgn]),open:P.object({forId:H7,title:Or,blocks:P.array(P.union([RQ,W7])).max(30)}).strict().optional()}).strict(),Qgn=P.object({type:P.literal("columns"),id:hr,primary:P.array(P.union([RQ,W7])).max(20),aside:P.array(P.union([RQ,W7])).max(12)}).strict(),_0c=P.object({kicker:Or.optional(),title:hu.optional(),description:a_.optional(),status:P.object({label:Or,detail:hu.optional(),tone:jp.optional()}).strict().optional(),blocks:P.array(P.union([RQ,Wta,Rgn,Qgn,W7])).max(50)}).strict().superRefine((e,t)=>{let n=new Set;for(let[r,a]of e.blocks.entries()){if(a.id===void 0)continue;if(n.has(a.id))t.addIssue({code:"custom",message:`Operator view block id "${a.id}" is duplicated`,path:["blocks",r,"id"]});n.add(a.id)}});var E0c=P.json();var Yta=P.object({title:hu.optional(),blocks:P.array(P.union([Ign,Lta])).max(50)}).strict().superRefine((e,t)=>{let n=new Set;for(let[r,a]of e.blocks.entries()){if(a.id===void 0)continue;if(n.has(a.id))t.addIssue({code:"custom",message:`Operator view block id "${a.id}" is duplicated`,path:["blocks",r,"id"]});n.add(a.id)}}),Vta=P.object({items:P.array(P.object({label:Or,value:P.string().max(500),tone:P.enum(["good","warn"]).optional()}).strict()).max(4),attention:P.number().int().nonnegative().optional()}).strict(),B0c=P.object({view:Yta,digest:Vta.optional()}).strict();var D0c=Symbol("rizom.workspace-action-executor");var q0c=P.object({actionId:P.string().trim().min(1).max(120),input:P.unknown(),mode:P.enum(["prepare","execute"]).default("execute"),confirmationToken:P.string().uuid().optional()}).strict(),G0c=P.object({capability:P.object({confirmation:P.literal("prepared").optional()})}).passthrough(),U0c=P.array(P.string().trim().min(1).max(120)).max(200).transform((e)=>[...new Set(e)]),H0c=P.object({summary:P.string().trim().min(1).max(500),revision:P.string().trim().min(1).max(500)});var W0c=P.json();var Y0c=Object.freeze({config:Object.freeze({}),state:Object.freeze({}),accountSettings:void 0});var awc=Object.freeze({config:Object.freeze({}),state:Object.freeze({}),accountSettings:void 0});var ivc=P.enum(["tool:invoking","tool:completed","tool:failed"]),ovc=P.object({toolName:P.string().min(1),conversationId:P.string().min(1),interfaceType:P.string().min(1),channelId:P.string().min(1).optional(),channelName:P.string().min(1).optional(),toolCallId:P.string().min(1).optional(),error:P.string().optional()});var pna=["meet.google.com","zoom.us","teams.microsoft.com","whereby.com","gather.town","calendly.com","cal.com","discord.com","discord.gg","cdn.discordapp.com","media.discordapp.net","giphy.com","tenor.com","wetransfer.com","file.io"],g$e=P.object({captureUrls:P.boolean().default(!1),blockedUrlDomains:P.array(P.string()).default(pna)});var bna=P.object({status:P.enum(["healthy","warning","error","unknown"]),message:P.string().optional(),lastCheck:P.date().optional(),details:P.record(P.string(),P.unknown()).optional()}),jgn=P.object({name:P.string(),pluginId:P.string(),status:P.string(),health:bna.optional()});var qgn=P.enum(["admin","trusted","public"]),Y7=P.object({label:P.string(),url:P.string(),pluginId:P.string(),priority:P.number().default(100),visibility:qgn.default("public"),requiresActiveSession:P.boolean().optional()}),h$e=P.enum(["human","agent","admin","protocol"]),b$e=P.enum(["available","coming-soon","disabled"]),V7=P.object({id:P.string(),label:P.string(),description:P.string().optional(),href:P.string(),kind:h$e,pluginId:P.string(),priority:P.number().default(100),visibility:qgn.default("public"),requiresActiveSession:P.boolean().optional(),status:b$e.default("available")}),Jce=P.object({entityType:P.string(),count:P.number()}),y$e=P.object({status:P.enum(["operational","degraded"]),reasons:P.array(P.string()),worker:P.object({state:P.enum(["active","missing","stale"]),activeSessions:P.number().int().nonnegative(),staleSessions:P.number().int().nonnegative(),latestHeartbeatAgeMs:P.number().nonnegative().nullable()}),queue:P.object({duePending:P.number().int().nonnegative(),processing:P.number().int().nonnegative(),oldestDuePendingAgeMs:P.number().nonnegative().nullable(),latestClaimAgeMs:P.number().nonnegative().nullable(),stalled:P.boolean()})}),Ggn=P.object({model:P.string(),version:P.string(),uptime:P.number(),entities:P.number(),entityCounts:P.array(Jce),embeddings:P.number(),backgroundWork:y$e,ai:P.object({model:P.string(),embeddingModel:P.string()}),daemons:P.array(jgn),endpoints:P.array(Y7),interactions:P.array(V7)});var ckc=P.object({id:P.string(),type:P.string(),version:P.string(),status:P.string()}),lkc=P.object({name:P.string(),description:P.string()});var yna=P.object({id:P.string(),version:P.string(),type:P.enum(["core","entity","service","interface"]),description:P.string().optional(),dependencies:P.array(P.string()).optional(),packageName:P.string()});var Ugn=P.looseObject({id:P.string().optional(),limit:P.number().optional(),page:P.number().optional(),pageSize:P.number().optional(),baseUrl:P.string().optional()}),wna=P.looseObject({entityType:P.string().optional(),query:Ugn.optional()});var w$e=P.object({kind:P.string().min(1),id:P.string().min(1)}),Hgn=P.object({kind:P.literal("text"),filename:P.string().min(1),mediaType:P.string().min(1),content:P.string(),sizeBytes:P.number().nonnegative().optional(),source:w$e.optional()}),vna=P.custom((e)=>e instanceof Uint8Array),kna=P.object({kind:P.literal("file"),filename:P.string().min(1),mediaType:P.string().min(1),data:vna,sizeBytes:P.number().nonnegative().optional(),source:w$e.optional()}),Wgn=P.discriminatedUnion("kind",[Hgn,kna]),Cna=P.object({userPermissionLevel:P.enum(["admin","trusted","public"]).optional(),isAnchor:P.boolean().optional(),interfaceType:P.string().optional(),channelId:P.string().optional(),channelName:P.string().optional(),actor:o7.optional(),source:s7.optional(),attachments:P.array(Wgn).optional()});var xna=P.object({status:P.enum(["healthy","warning","error","unknown"]),message:P.string().optional(),lastCheck:P.string().optional(),details:P.record(P.string(),P.unknown()).optional()}),_na=P.object({name:P.string(),pluginId:P.string(),status:P.string(),health:xna.optional()}),Ena=P.object({model:P.string(),version:P.string(),uptime:P.number(),entities:P.number(),entityCounts:P.array(Jce),embeddings:P.number(),ai:P.object({model:P.string(),embeddingModel:P.string()}),daemons:P.array(_na),endpoints:P.array(Y7),interactions:P.array(V7)});var v$e=P.object({name:P.string().min(1),status:P.enum(["healthy","degraded","unhealthy"]),message:P.string().optional(),details:P.record(P.string(),P.unknown()).optional()}),Ygn=P.object({totals:P.object({pending:P.number().int().nonnegative(),processing:P.number().int().nonnegative(),completed:P.number().int().nonnegative(),failed:P.number().int().nonnegative()}),byType:P.array(P.object({type:P.string().min(1),status:P.enum(["pending","processing","completed","failed"]),count:P.number().int().nonnegative()})),oldestPendingAgeMs:P.number().nonnegative().nullable(),duePending:P.number().int().nonnegative(),oldestDuePendingAgeMs:P.number().nonnegative().nullable(),latestClaimAgeMs:P.number().nonnegative().nullable(),oldestProcessingAgeMs:P.number().nonnegative().nullable(),staleLeaseCount:P.number().int().nonnegative(),workerSessions:P.object({total:P.number().int().nonnegative(),active:P.number().int().nonnegative(),stale:P.number().int().nonnegative(),latestHeartbeatAgeMs:P.number().nonnegative().nullable()})}),Vgn=P.object({memory:P.object({rssBytes:P.number().int().nonnegative(),heapUsedBytes:P.number().int().nonnegative(),heapTotalBytes:P.number().int().nonnegative()}),fileDescriptors:P.number().int().nonnegative().nullable(),processes:P.object({total:P.number().int().nonnegative().nullable(),zombies:P.number().int().nonnegative().nullable()}),queue:Ygn.nullable(),projection:P.object({initialized:P.boolean(),trackedRoots:P.number().int().nonnegative(),openCircuits:P.array(P.object({projectionId:P.string().min(1),reason:P.string().min(1),openedAt:P.number().int().nonnegative(),expiresAt:P.number().int().nonnegative()}))}),worker:P.object({total:P.number().int().nonnegative(),active:P.number().int().nonnegative(),stale:P.number().int().nonnegative(),latestHeartbeatAgeMs:P.number().nonnegative().nullable()})}),Bna=P.object({status:P.enum(["ready","not_ready"]),operationalStatus:P.enum(["operational","degraded"]),checkedAt:P.iso.datetime(),checks:P.array(v$e),resources:Vgn});var Lkc=P.string().trim().min(1).max(200),Mkc=P.string().trim().min(1).max(100).regex(/^[a-z0-9][a-z0-9.-]*$/);var Ina=P.union([P.object({success:P.boolean(),data:P.unknown().optional(),error:P.string().optional()}),P.object({noop:P.literal(!0)})]),Sna=P.object({id:P.string(),timestamp:P.string(),type:P.string(),source:P.string(),target:P.string().optional(),metadata:c7.optional()});var Tna=P.object({kind:P.string().min(1),id:P.string().min(1)}),Dna=P.object({kind:P.string().min(1),filename:P.string().min(1),mediaType:P.string().min(1),sizeBytes:P.number().nonnegative().optional(),source:Tna.optional()}),Vkc=P.array(Dna),Zkc=P.array(N8),Kkc=P.array(xO),Jkc=P.record(P.string(),P.unknown());var Xgn=Hv.extend({id:P.literal("brain-character"),entityType:P.literal("brain-character")}),C$e=P.object({name:P.string().describe("The brain's friendly display name"),role:P.string().describe("The brain's primary role"),purpose:P.string().describe("The brain's purpose and goals"),values:P.array(P.string()).describe("Core values that guide behavior")});var exc=P.record(P.string(),P.unknown());var efn=Hv.extend({id:P.literal("anchor-profile"),entityType:P.literal("anchor-profile")}),tfn=P.enum(["person","team","organization"]),Z7=P.object({name:P.string().describe("Name of the anchor"),organization:P.string().optional().describe("Organization the anchor belongs to"),description:P.string().optional().describe("Short description or biography"),avatar:P.string().optional().describe("URL or asset path to avatar/logo"),website:P.string().optional().describe("Primary website URL"),email:P.string().optional().describe("Contact email"),socialLinks:P.array(P.object({platform:P.enum(["github","instagram","linkedin","email","website"]).describe("Social media platform"),url:P.string().describe("Profile or contact URL"),label:P.string().optional().describe("Optional display label")})).optional().describe("Social media and contact links")});var Xce=P.enum(["person","team","organization"]),vxc=P.object({kind:P.string().trim().min(1),category:Xce,labels:P.object({singular:P.string().trim().min(1),plural:P.string().trim().min(1)})});var nfn=P.looseObject({id:P.string(),description:P.string(),name:P.string().optional(),tags:P.array(P.string()).optional().default([])}),hra=Z7.extend({kind:P.string().trim().min(1).optional(),category:Xce.optional()}).superRefine((e,t)=>{if(e.kind===void 0!==(e.category===void 0))t.addIssue({code:"custom",message:"Anchor kind and category must be provided together"})}),bra=P.looseObject({uri:P.string(),params:P.record(P.string(),P.unknown()).optional()}),yra=P.looseObject({name:P.string(),url:P.string(),description:P.string().optional(),skills:P.array(nfn).optional().default([]),capabilities:P.looseObject({extensions:P.array(bra).optional().default([])}).optional()});q8();var rfn=(e)=>P.string().trim().min(1).max(e).refine((t)=>!/[\p{Cc}\p{Cf}]/u.test(t)),vra=P.strictObject({sourceId:nf,itemId:Woe,label:rfn(160)}),kra=P.strictObject({version:P.literal(2),text:rfn(500),context:vra}),afn=P.object({webChatPrefill:kra}).passthrough();function ifn(e){let{webChatPrefill:t,...n}=e;return n}function ofn(e,t){let n=afn.safeParse(e);if(!n.success)return;return t(),{text:n.data.webChatPrefill.text,context:n.data.webChatPrefill.context}}var E$e=Fn(lo(),1);function sfn(e,t){e.setQueryData(Yy.sessions(),(n=[])=>n.map((r)=>r.id===t.conversationId?{...r,title:t.title}:r))}function cfn(e,t){e.removeQueries({queryKey:Yy.history(t)}),e.setQueryData(Yy.sessions(),(n=[])=>n.filter((r)=>r.id!==t))}async function _$e(e,t){if(e.ok)return;throw Error(xoe(e,t))}async function lfn(e){let t=await fetch(`/api/chat/sessions?id=${encodeURIComponent(e.conversationId)}`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e.title})});await _$e(t,"Could not rename that session.")}async function ufn(e){let t=await fetch(`/api/chat/sessions/archive?id=${encodeURIComponent(e.conversationId)}`,{method:"PUT",credentials:"include"});await _$e(t,"Could not archive that session.")}async function dfn(e){let t=await fetch(`/api/chat/sessions?id=${encodeURIComponent(e.conversationId)}`,{method:"DELETE",credentials:"include"});await _$e(t,"Could not delete that session.")}function pfn(e){let t=_0(),[n,r]=E$e.useState(null),[a,i]=E$e.useState(""),o=uL({mutationFn:lfn}),s=uL({mutationFn:ufn}),l=uL({mutationFn:dfn});function u(){r(null),i("")}function d(p){if(cfn(t,p.id),p.id===e.activeConversationId)e.onActiveSessionRemoved();u(),e.onSettled()}return{dialog:n,renameDraft:a,renamingConversationId:o.isPending?o.variables.conversationId:null,archivingConversationId:s.isPending?s.variables.conversationId:null,deletingConversationId:l.isPending?l.variables.conversationId:null,setRenameDraft:i,openRenameDialog:(p)=>{i(p.title),r({kind:"rename",session:p})},openArchiveDialog:(p)=>{r({kind:"archive",session:p})},openDeleteDialog:(p)=>{r({kind:"delete",session:p})},closeDialog:u,renameConversation:(p,m)=>{let A=m.trim();if(e.chatIsBusy||o.isPending||!A||A===p.title){u();return}e.setError(null),o.mutate({conversationId:p.id,title:A},{onSuccess:()=>{sfn(t,{conversationId:p.id,title:A}),u(),e.onSettled()},onError:(f)=>e.setError(f.message)})},archiveConversation:(p)=>{if(e.chatIsBusy||s.isPending)return;e.setError(null),s.mutate({conversationId:p.id},{onSuccess:()=>d(p),onError:(m)=>e.setError(m.message)})},deleteConversation:(p)=>{if(e.chatIsBusy||l.isPending)return;e.setError(null),l.mutate({conversationId:p.id},{onSuccess:()=>d(p),onError:(m)=>e.setError(m.message)})}}}var br=Fn(Qi(),1),mfn=[];function Afn(){let[e]=Ps.useState(()=>ofn(window.history.state,()=>{window.history.replaceState(ifn(window.history.state),"",window.location.href)})),[t,n]=Ps.useState(e?.text??""),[r,a]=Ps.useState(e?.context??null),[i,o]=Ps.useState(()=>{if(!e)return vun();let ce=VO();return _oe(ce),ce}),s=_0(),l=$pe(hun()),u=l.data??mfn,d=l.error?.message??null,[p,m]=Ps.useState(null),A=Ps.useRef(e!==void 0),f=Ps.useRef(0),[y,v]=Ps.useState(null),[x,_]=Ps.useState([]),[E,F]=Ps.useState(!1),[T,R]=Ps.useState(null),[O,j]=Ps.useState(null);function H(){F(!1)}let G=Ps.useRef(null),W=Ps.useMemo(()=>new mM({api:"/api/chat",credentials:"include"}),[]),b=Ps.useMemo(()=>new dU({id:i,messages:x,transport:W,onData:(ce)=>{let ge=wun(ce);if(ge)j(ge)},onError:()=>{j(null)},onFinish:()=>{j(null)},sendAutomaticallyWhen:hVe}),[i,x,W]),{messages:k,sendMessage:I,setMessages:C,status:B,error:L,stop:M,clearError:Q,addToolApprovalResponse:w}=kVe({chat:b});function N(){f.current+=1,v(null);let ce=VO();_oe(ce),C([]),_([]),o(ce),n(""),a(null)}let U=pfn({chatIsBusy:aQ(B),activeConversationId:i,onActiveSessionRemoved:N,setError:m,onSettled:()=>iQ(G.current)});Ps.useEffect(()=>{if(G.current)kun(G.current)},[t]),Ps.useEffect(()=>{iQ(G.current)},[]);async function q(){await l.refetch()}function Z(ce){let ge=new Date().toISOString(),Qe={id:i,title:run(ce),lastActiveAt:ge};s.setQueryData(Yy.sessions(),(Oe)=>{let _e=Oe??mfn,Re=_e.find((Te)=>Te.id===i),We=Re&&Re.title!=="New conversation"?{...Re,lastActiveAt:ge}:Qe,be=_e.filter((Te)=>Te.id!==i);return[We,...be]})}async function ee(ce){if(aQ(B)||y)return;let ge=++f.current;m(null),v(ce),await bun({load:async()=>{let Qe=await s.fetchQuery({...fun(ce),staleTime:0});return pun(Qe)},isCurrent:()=>ge===f.current,onSuccess:(Qe)=>{_oe(ce),C(Qe),_(Qe),o(ce),n(""),a(null),H(),iQ(G.current)},onError:(Qe)=>{m(Ys(Qe,"Could not reopen that session."))},onSettled:()=>v(null)})}Ps.useEffect(()=>{if(!l.isSuccess||A.current)return;if(A.current=!0,u.some((ce)=>ce.id===i))ee(i)},[i,u,l.isSuccess]);async function ne(ce,ge=[]){let Qe=(ce??t).trim();if(!Qe&&ge.length===0||aQ(B))return;if(m(null),ge.length>0)R({tone:"success",message:`Uploading ${ge.length===1?"attachment":"attachments"}…`});let Oe;try{Oe=await Zln(Qe,ge)}catch(Re){let We=koe(Re,"upload");if(We.uploadNotice)R(We.uploadNotice);m(We.historyError);return}if(Oe.uploadNoticeMessage)R({tone:"success",message:Oe.uploadNoticeMessage});else R(null);Z(Oe.title),n("");let{payload:_e}=Oe;I(_e,r?{body:{inboxContext:r}}:void 0).catch((Re)=>{let We=koe(Re,"send");if(We.uploadNotice)R(We.uploadNotice);if(m(We.historyError),Qe)n((be)=>be||Qe)}).finally(()=>{s.invalidateQueries({queryKey:Yy.history(i)}),q(),iQ(G.current)})}async function re(ce){if(aQ(B))return;m(null);try{let ge=await fetch("/api/chat/actions",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({conversationId:i,action:{type:"event",event:ce.event,...ce.fromState?{fromState:ce.fromState}:{}}})});if(!ge.ok)throw Error(`Runtime action failed: ${ge.status}`);let Qe=await ge.json(),Oe=[];if(Qe.text&&Qe.text.trim().length>0)Oe.push({type:"text",text:Qe.text});for(let _e of Qe.toolResults??[])Oe.push({type:"data-tool-result",data:_e});for(let _e of Qe.cards??[])Oe.push({type:_e.kind==="sources"?"data-sources":_e.kind==="actions"?"data-actions":"data-attachment",data:_e});if(Oe.length>0)C((_e)=>[..._e,{id:`runtime-${crypto.randomUUID()}`,role:"assistant",parts:Oe}]);s.invalidateQueries({queryKey:Yy.history(i)}),q()}catch(ge){let Qe=koe(ge,"send");if(Qe.uploadNotice)R(Qe.uploadNotice);m(Qe.historyError)}}function ke(){m(null),N(),H(),iQ(G.current)}Ps.useEffect(()=>(window.__consoleJumpLocal=(ce)=>{let ge=sun(u,ce);return ge?[ge]:[]},()=>{delete window.__consoleJumpLocal}),[u]),Ps.useEffect(()=>{let ce=()=>{let ge=cun(window.location.hash);if(ge===null)return;window.history.replaceState(null,"",window.location.pathname),ee(ge)};return ce(),window.addEventListener("hashchange",ce),()=>window.removeEventListener("hashchange",ce)},[]);function se(ce){return(ge)=>{H(),ce(ge)}}let he=u.find((ce)=>ce.id===i)?.title;return br.jsxDEV("div",{className:"web-chat-shell","data-web-chat-app":"true","data-web-chat-ui":"ai-elements-v0","data-conversation-id":i,"data-drawer-open":E?"true":"false",children:[br.jsxDEV("div",{className:"web-chat-mobile-drawer-scrim","aria-hidden":"true",onClick:H},void 0,!1,void 0,this),br.jsxDEV("button",{type:"button",className:"web-chat-mobile-drawer-close","aria-label":"Close sessions",onClick:H,children:br.jsxDEV("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:br.jsxDEV("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),U.dialog?br.jsxDEV(iun,{dialog:U.dialog,renameDraft:U.renameDraft,renamePending:U.renamingConversationId!==null,archivePending:U.archivingConversationId!==null,deletePending:U.deletingConversationId!==null,onRenameDraftChange:U.setRenameDraft,onClose:U.closeDialog,onRename:U.renameConversation,onArchive:U.archiveConversation,onDelete:U.deleteConversation},void 0,!1,void 0,this):null,br.jsxDEV(oun,{sessions:u,isLoading:l.isPending,sessionError:d,activeConversationId:i,loadingConversationId:y,deletingConversationId:U.deletingConversationId,archivingConversationId:U.archivingConversationId,renamingConversationId:U.renamingConversationId,chatIsBusy:aQ(B),onRetry:()=>void q(),onSelect:(ce)=>void ee(ce),onNewConversation:ke,onRename:se(U.openRenameDialog),onArchive:se(U.openArchiveDialog),onDelete:se(U.openDeleteDialog)},void 0,!1,void 0,this),br.jsxDEV("main",{className:"web-chat-app","aria-label":"Brain chat",children:[br.jsxDEV("header",{className:"web-chat-header",children:[br.jsxDEV("button",{type:"button",className:"web-chat-mobile-trigger","aria-label":"Open sessions","aria-expanded":E,"data-active":E?"true":"false",onClick:()=>F(!0),children:br.jsxDEV("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6","aria-hidden":"true",children:br.jsxDEV("path",{d:"M2.5 4.5h11M2.5 8h11M2.5 11.5h7",strokeLinecap:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),br.jsxDEV("div",{children:[br.jsxDEV("span",{className:"web-chat-header-eyebrow",children:["Brain · Chat",k.length>0?br.jsxDEV(br.Fragment,{children:[" · ",br.jsxDEV("strong",{children:[k.length," message",k.length===1?"":"s"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this),br.jsxDEV("h1",{children:he??br.jsxDEV(br.Fragment,{children:["New ",br.jsxDEV("em",{children:"conversation"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),br.jsxDEV("p",{children:he?"Active conversation":"A field log for talking with the brain"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),br.jsxDEV("div",{className:"web-chat-header-actions",children:br.jsxDEV("button",{className:"web-chat-mobile-new",type:"button","aria-label":"New conversation",onClick:ke,children:br.jsxDEV("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.75","aria-hidden":"true",children:br.jsxDEV("path",{d:"M8 3v10M3 8h10",strokeLinecap:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p?br.jsxDEV("div",{className:"web-chat-session-notice","data-tone":"error",role:"alert",children:[br.jsxDEV("span",{className:"web-chat-session-notice-tag",children:"Session drift"},void 0,!1,void 0,this),br.jsxDEV("p",{children:p},void 0,!1,void 0,this),br.jsxDEV("button",{type:"button",onClick:()=>m(null),children:"Dismiss"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,br.jsxDEV(cZe,{children:br.jsxDEV(lZe,{children:k.length===0?br.jsxDEV(uZe,{title:"Begin a field note.",description:"Ask the brain about entities, notes, prompts, or recent work — the thread grows from the first message."},void 0,!1,void 0,this):k.map((ce)=>br.jsxDEV(Oan,{from:ce.role,"data-role":ce.role,children:[br.jsxDEV("div",{className:"web-chat-message-header",children:ce.role==="user"?"you":"brain"},void 0,!1,void 0,this),br.jsxDEV(zan,{className:"web-chat-message-bubble",children:br.jsxDEV(tun,{parts:ce.parts,handlers:{addToolApprovalResponse:w,onPromptAction:(ge)=>void ne(ge),onEventAction:(ge)=>void re(ge)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},ce.id,!0,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),B!=="ready"?br.jsxDEV("p",{className:"web-chat-status","data-status":B,children:[br.jsxDEV("span",{className:"web-chat-status-rail","aria-hidden":"true"},void 0,!1,void 0,this),br.jsxDEV("span",{className:"web-chat-status-phrase",children:O??yun(B)},void 0,!1,void 0,this),br.jsxDEV("span",{className:"web-chat-status-meta",children:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,L?br.jsxDEV("div",{className:"web-chat-error",role:"alert",children:[br.jsxDEV("span",{className:"web-chat-error-tag",children:"[ signal lost ]"},void 0,!1,void 0,this),br.jsxDEV("p",{children:L.message},void 0,!1,void 0,this),br.jsxDEV("button",{type:"button",onClick:Q,children:"Dismiss"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,T?br.jsxDEV("p",{className:"web-chat-file-notice","data-tone":T.tone,children:T.message},void 0,!1,void 0,this):null,br.jsxDEV(Xan,{accept:Hln,maxFileSize:Wln,multiple:!0,onError:(ce)=>R({tone:"error",message:ce.message}),onSubmit:(ce)=>ne(ce.text,ce.files),children:[br.jsxDEV("label",{htmlFor:"web-chat-input",children:"Message"},void 0,!1,void 0,this),br.jsxDEV(tin,{children:[r?br.jsxDEV("div",{className:"web-chat-inbox-context",role:"status",children:[br.jsxDEV("span",{className:"web-chat-inbox-context-icon","aria-hidden":"true",children:br.jsxDEV("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.35",children:[br.jsxDEV("rect",{x:"2.25",y:"3.5",width:"11.5",height:"9",rx:"1.5"},void 0,!1,void 0,this),br.jsxDEV("path",{d:"m3.25 5 4.75 3.75L12.75 5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),br.jsxDEV("span",{className:"web-chat-inbox-context-kicker",children:"Inbox"},void 0,!1,void 0,this),br.jsxDEV("span",{className:"web-chat-inbox-context-divider","aria-hidden":"true"},void 0,!1,void 0,this),br.jsxDEV("span",{className:"web-chat-inbox-context-label",title:r.label,children:r.label},void 0,!1,void 0,this),br.jsxDEV("button",{type:"button","aria-label":`Detach Inbox context: ${r.label}`,title:"Remove Inbox context",onClick:()=>a(null),children:br.jsxDEV("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:br.jsxDEV("path",{d:"m3 3 6 6m0-6L3 9",strokeLinecap:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null,br.jsxDEV(oin,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this),br.jsxDEV(ein,{id:"web-chat-input",ref:G,value:t,"aria-label":"Message",placeholder:"Plant a question…",onInput:(ce)=>n(ce.currentTarget.value)},void 0,!1,void 0,this),br.jsxDEV(nin,{children:[br.jsxDEV(rin,{children:br.jsxDEV(iin,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),br.jsxDEV(sin,{input:t,status:B,onStop:M},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function gfn(){return new Mpe({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1},mutations:{retry:!1}}})}var B$e=Fn(Qi(),1),ffn=document.querySelector("[data-web-chat-root]");if(ffn){let e=gfn();hfn.createRoot(ffn).render(B$e.jsxDEV(Npe,{client:e,children:B$e.jsxDEV(Afn,{},void 0,!1,void 0,this)},void 0,!1,void 0,this))}
|
|
4304
4304
|
|
|
4305
|
-
//# debugId=
|
|
4305
|
+
//# debugId=2496AC0DB736AEE164756E2164756E21
|