hivemind-agents 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hivemind.mjs +1 -1
- package/package.json +2 -2
package/dist/hivemind.mjs
CHANGED
|
@@ -124,7 +124,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
124
124
|
deps: ${n}}`,"params")};var CM={keyword:"dependencies",type:"object",schemaType:"object",error:yr.error,code(e){let[t,n]=UM(e);JT(e,t),BT(e,n)}};function UM({schema:e}){let t={},n={};for(let i in e){if(i==="__proto__")continue;let r=Array.isArray(e[i])?t:n;r[i]=e[i]}return[t,n]}s(UM,"splitDependencies");function JT(e,t=e.schema){let{gen:n,data:i,it:r}=e;if(Object.keys(t).length===0)return;let o=n.let("missing");for(let a in t){let c=t[a];if(c.length===0)continue;let u=(0,Ec.propertyInData)(n,i,a,r.opts.ownProperties);e.setParams({property:a,depsCount:c.length,deps:c.join(", ")}),r.allErrors?n.if(u,()=>{for(let l of c)(0,Ec.checkReportMissingProp)(e,l)}):(n.if((0,Vb._)`${u} && (${(0,Ec.checkMissingProp)(e,c,o)})`),(0,Ec.reportMissingProp)(e,o),n.else())}}s(JT,"validatePropertyDeps");yr.validatePropertyDeps=JT;function BT(e,t=e.schema){let{gen:n,data:i,keyword:r,it:o}=e,a=n.name("valid");for(let c in t)(0,RM.alwaysValidSchema)(o,t[c])||(n.if((0,Ec.propertyInData)(n,i,c,o.opts.ownProperties),()=>{let u=e.subschema({keyword:r,schemaProp:c},a);e.mergeValidEvaluated(u,a)},()=>n.var(a,!0)),e.ok(a))}s(BT,"validateSchemaDeps");yr.validateSchemaDeps=BT;yr.default=CM});var GT=A(Fb=>{"use strict";Object.defineProperty(Fb,"__esModule",{value:!0});var HT=te(),ZM=le(),MM={message:"property name must be valid",params:s(({params:e})=>(0,HT._)`{propertyName: ${e.propertyName}}`,"params")},LM={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:MM,code(e){let{gen:t,schema:n,data:i,it:r}=e;if((0,ZM.alwaysValidSchema)(r,n))return;let o=t.name("valid");t.forIn("key",i,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},o),t.if((0,HT.not)(o),()=>{e.error(!0),r.allErrors||t.break()})}),e.ok(o)}};Fb.default=LM});var Jb=A(qb=>{"use strict";Object.defineProperty(qb,"__esModule",{value:!0});var _p=Ft(),nr=te(),VM=Ur(),$p=le(),FM={message:"must NOT have additional properties",params:s(({params:e})=>(0,nr._)`{additionalProperty: ${e.additionalProperty}}`,"params")},qM={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:FM,code(e){let{gen:t,schema:n,parentSchema:i,data:r,errsCount:o,it:a}=e;if(!o)throw new Error("ajv implementation error");let{allErrors:c,opts:u}=a;if(a.props=!0,u.removeAdditional!=="all"&&(0,$p.alwaysValidSchema)(a,n))return;let l=(0,_p.allSchemaProperties)(i.properties),d=(0,_p.allSchemaProperties)(i.patternProperties);f(),e.ok((0,nr._)`${o} === ${VM.default.errors}`);function f(){t.forIn("key",r,v=>{!l.length&&!d.length?h(v):t.if(p(v),()=>h(v))})}s(f,"checkAdditionalProperties");function p(v){let b;if(l.length>8){let k=(0,$p.schemaRefOrVal)(a,i.properties,"properties");b=(0,_p.isOwnProperty)(t,k,v)}else l.length?b=(0,nr.or)(...l.map(k=>(0,nr._)`${v} === ${k}`)):b=nr.nil;return d.length&&(b=(0,nr.or)(b,...d.map(k=>(0,nr._)`${(0,_p.usePattern)(e,k)}.test(${v})`))),(0,nr.not)(b)}s(p,"isAdditional");function m(v){t.code((0,nr._)`delete ${r}[${v}]`)}s(m,"deleteAdditional");function h(v){if(u.removeAdditional==="all"||u.removeAdditional&&n===!1){m(v);return}if(n===!1){e.setParams({additionalProperty:v}),e.error(),c||t.break();return}if(typeof n=="object"&&!(0,$p.alwaysValidSchema)(a,n)){let b=t.name("valid");u.removeAdditional==="failing"?(g(v,b,!1),t.if((0,nr.not)(b),()=>{e.reset(),m(v)})):(g(v,b),c||t.if((0,nr.not)(b),()=>t.break()))}}s(h,"additionalPropertyCode");function g(v,b,k){let z={keyword:"additionalProperties",dataProp:v,dataPropType:$p.Type.Str};k===!1&&Object.assign(z,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(z,b)}s(g,"applyAdditionalSchema")}};qb.default=qM});var YT=A(Kb=>{"use strict";Object.defineProperty(Kb,"__esModule",{value:!0});var JM=gc(),WT=Ft(),Bb=le(),XT=Jb(),BM={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:n,parentSchema:i,data:r,it:o}=e;o.opts.removeAdditional==="all"&&i.additionalProperties===void 0&&XT.default.code(new JM.KeywordCxt(o,XT.default,"additionalProperties"));let a=(0,WT.allSchemaProperties)(n);for(let f of a)o.definedProperties.add(f);o.opts.unevaluated&&a.length&&o.props!==!0&&(o.props=Bb.mergeEvaluated.props(t,(0,Bb.toHash)(a),o.props));let c=a.filter(f=>!(0,Bb.alwaysValidSchema)(o,n[f]));if(c.length===0)return;let u=t.name("valid");for(let f of c)l(f)?d(f):(t.if((0,WT.propertyInData)(t,r,f,o.opts.ownProperties)),d(f),o.allErrors||t.else().var(u,!0),t.endIf()),e.it.definedProperties.add(f),e.ok(u);function l(f){return o.opts.useDefaults&&!o.compositeRule&&n[f].default!==void 0}s(l,"hasDefault");function d(f){e.subschema({keyword:"properties",schemaProp:f,dataProp:f},u)}s(d,"applyPropertySchema")}};Kb.default=BM});var rO=A(Hb=>{"use strict";Object.defineProperty(Hb,"__esModule",{value:!0});var QT=Ft(),bp=te(),eO=le(),tO=le(),KM={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:n,data:i,parentSchema:r,it:o}=e,{opts:a}=o,c=(0,QT.allSchemaProperties)(n),u=c.filter(g=>(0,eO.alwaysValidSchema)(o,n[g]));if(c.length===0||u.length===c.length&&(!o.opts.unevaluated||o.props===!0))return;let l=a.strictSchema&&!a.allowMatchingProperties&&r.properties,d=t.name("valid");o.props!==!0&&!(o.props instanceof bp.Name)&&(o.props=(0,tO.evaluatedPropsToName)(t,o.props));let{props:f}=o;p();function p(){for(let g of c)l&&m(g),o.allErrors?h(g):(t.var(d,!0),h(g),t.if(d))}s(p,"validatePatternProperties");function m(g){for(let v in l)new RegExp(g).test(v)&&(0,eO.checkStrictMode)(o,`property ${v} matches pattern ${g} (use allowMatchingProperties)`)}s(m,"checkMatchingProperties");function h(g){t.forIn("key",i,v=>{t.if((0,bp._)`${(0,QT.usePattern)(e,g)}.test(${v})`,()=>{let b=u.includes(g);b||e.subschema({keyword:"patternProperties",schemaProp:g,dataProp:v,dataPropType:tO.Type.Str},d),o.opts.unevaluated&&f!==!0?t.assign((0,bp._)`${f}[${v}]`,!0):!b&&!o.allErrors&&t.if((0,bp.not)(d),()=>t.break())})})}s(h,"validateProperties")}};Hb.default=KM});var nO=A(Gb=>{"use strict";Object.defineProperty(Gb,"__esModule",{value:!0});var HM=le(),GM={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:n,it:i}=e;if((0,HM.alwaysValidSchema)(i,n)){e.fail();return}let r=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},r),e.failResult(r,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Gb.default=GM});var iO=A(Wb=>{"use strict";Object.defineProperty(Wb,"__esModule",{value:!0});var WM=Ft(),XM={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:WM.validateUnion,error:{message:"must match a schema in anyOf"}};Wb.default=XM});var oO=A(Xb=>{"use strict";Object.defineProperty(Xb,"__esModule",{value:!0});var xp=te(),YM=le(),QM={message:"must match exactly one schema in oneOf",params:s(({params:e})=>(0,xp._)`{passingSchemas: ${e.passing}}`,"params")},eL={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:QM,code(e){let{gen:t,schema:n,parentSchema:i,it:r}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(r.opts.discriminator&&i.discriminator)return;let o=n,a=t.let("valid",!1),c=t.let("passing",null),u=t.name("_valid");e.setParams({passing:c}),t.block(l),e.result(a,()=>e.reset(),()=>e.error(!0));function l(){o.forEach((d,f)=>{let p;(0,YM.alwaysValidSchema)(r,d)?t.var(u,!0):p=e.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},u),f>0&&t.if((0,xp._)`${u} && ${a}`).assign(a,!1).assign(c,(0,xp._)`[${c}, ${f}]`).else(),t.if(u,()=>{t.assign(a,!0),t.assign(c,f),p&&e.mergeEvaluated(p,xp.Name)})})}s(l,"validateOneOf")}};Xb.default=eL});var aO=A(Yb=>{"use strict";Object.defineProperty(Yb,"__esModule",{value:!0});var tL=le(),rL={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:n,it:i}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");let r=t.name("valid");n.forEach((o,a)=>{if((0,tL.alwaysValidSchema)(i,o))return;let c=e.subschema({keyword:"allOf",schemaProp:a},r);e.ok(r),e.mergeEvaluated(c)})}};Yb.default=rL});var uO=A(Qb=>{"use strict";Object.defineProperty(Qb,"__esModule",{value:!0});var kp=te(),cO=le(),nL={message:s(({params:e})=>(0,kp.str)`must match "${e.ifClause}" schema`,"message"),params:s(({params:e})=>(0,kp._)`{failingKeyword: ${e.ifClause}}`,"params")},iL={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:nL,code(e){let{gen:t,parentSchema:n,it:i}=e;n.then===void 0&&n.else===void 0&&(0,cO.checkStrictMode)(i,'"if" without "then" and "else" is ignored');let r=sO(i,"then"),o=sO(i,"else");if(!r&&!o)return;let a=t.let("valid",!0),c=t.name("_valid");if(u(),e.reset(),r&&o){let d=t.let("ifClause");e.setParams({ifClause:d}),t.if(c,l("then",d),l("else",d))}else r?t.if(c,l("then")):t.if((0,kp.not)(c),l("else"));e.pass(a,()=>e.error(!0));function u(){let d=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},c);e.mergeEvaluated(d)}s(u,"validateIf");function l(d,f){return()=>{let p=e.subschema({keyword:d},c);t.assign(a,c),e.mergeValidEvaluated(p,a),f?t.assign(f,(0,kp._)`${d}`):e.setParams({ifClause:d})}}s(l,"validateClause")}};function sO(e,t){let n=e.schema[t];return n!==void 0&&!(0,cO.alwaysValidSchema)(e,n)}s(sO,"hasSchema");Qb.default=iL});var lO=A(ex=>{"use strict";Object.defineProperty(ex,"__esModule",{value:!0});var oL=le(),aL={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){t.if===void 0&&(0,oL.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};ex.default=aL});var dO=A(tx=>{"use strict";Object.defineProperty(tx,"__esModule",{value:!0});var sL=Cb(),cL=LT(),uL=Ub(),lL=FT(),dL=qT(),fL=KT(),pL=GT(),mL=Jb(),hL=YT(),gL=rO(),vL=nO(),yL=iO(),_L=oO(),$L=aO(),bL=uO(),xL=lO();function kL(e=!1){let t=[vL.default,yL.default,_L.default,$L.default,bL.default,xL.default,pL.default,mL.default,fL.default,hL.default,gL.default];return e?t.push(cL.default,lL.default):t.push(sL.default,uL.default),t.push(dL.default),t}s(kL,"getApplicator");tx.default=kL});var fO=A(rx=>{"use strict";Object.defineProperty(rx,"__esModule",{value:!0});var Ae=te(),wL={message:s(({schemaCode:e})=>(0,Ae.str)`must match format "${e}"`,"message"),params:s(({schemaCode:e})=>(0,Ae._)`{format: ${e}}`,"params")},SL={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:wL,code(e,t){let{gen:n,data:i,$data:r,schema:o,schemaCode:a,it:c}=e,{opts:u,errSchemaPath:l,schemaEnv:d,self:f}=c;if(!u.validateFormats)return;r?p():m();function p(){let h=n.scopeValue("formats",{ref:f.formats,code:u.code.formats}),g=n.const("fDef",(0,Ae._)`${h}[${a}]`),v=n.let("fType"),b=n.let("format");n.if((0,Ae._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>n.assign(v,(0,Ae._)`${g}.type || "string"`).assign(b,(0,Ae._)`${g}.validate`),()=>n.assign(v,(0,Ae._)`"string"`).assign(b,g)),e.fail$data((0,Ae.or)(k(),z()));function k(){return u.strictSchema===!1?Ae.nil:(0,Ae._)`${a} && !${b}`}s(k,"unknownFmt");function z(){let U=d.$async?(0,Ae._)`(${g}.async ? await ${b}(${i}) : ${b}(${i}))`:(0,Ae._)`${b}(${i})`,D=(0,Ae._)`(typeof ${b} == "function" ? ${U} : ${b}.test(${i}))`;return(0,Ae._)`${b} && ${b} !== true && ${v} === ${t} && !${D}`}s(z,"invalidFmt")}s(p,"validate$DataFormat");function m(){let h=f.formats[o];if(!h){k();return}if(h===!0)return;let[g,v,b]=z(h);g===t&&e.pass(U());function k(){if(u.strictSchema===!1){f.logger.warn(D());return}throw new Error(D());function D(){return`unknown format "${o}" ignored in schema at path "${l}"`}}s(k,"unknownFormat");function z(D){let W=D instanceof RegExp?(0,Ae.regexpCode)(D):u.code.formats?(0,Ae._)`${u.code.formats}${(0,Ae.getProperty)(o)}`:void 0,Se=n.scopeValue("formats",{key:o,ref:D,code:W});return typeof D=="object"&&!(D instanceof RegExp)?[D.type||"string",D.validate,(0,Ae._)`${Se}.validate`]:["string",D,Se]}s(z,"getFormat");function U(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!d.$async)throw new Error("async format in sync schema");return(0,Ae._)`await ${b}(${i})`}return typeof v=="function"?(0,Ae._)`${b}(${i})`:(0,Ae._)`${b}.test(${i})`}s(U,"validCondition")}s(m,"validateFormat")}};rx.default=SL});var pO=A(nx=>{"use strict";Object.defineProperty(nx,"__esModule",{value:!0});var IL=fO(),zL=[IL.default];nx.default=zL});var mO=A(ia=>{"use strict";Object.defineProperty(ia,"__esModule",{value:!0});ia.contentVocabulary=ia.metadataVocabulary=void 0;ia.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ia.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var gO=A(ix=>{"use strict";Object.defineProperty(ix,"__esModule",{value:!0});var PL=kT(),TL=CT(),OL=dO(),EL=pO(),hO=mO(),jL=[PL.default,TL.default,(0,OL.default)(),EL.default,hO.metadataVocabulary,hO.contentVocabulary];ix.default=jL});var yO=A(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});wp.DiscrError=void 0;var vO;(function(e){e.Tag="tag",e.Mapping="mapping"})(vO||(wp.DiscrError=vO={}))});var $O=A(ax=>{"use strict";Object.defineProperty(ax,"__esModule",{value:!0});var oa=te(),ox=yO(),_O=op(),NL=vc(),DL=le(),AL={message:s(({params:{discrError:e,tagName:t}})=>e===ox.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,"message"),params:s(({params:{discrError:e,tag:t,tagName:n}})=>(0,oa._)`{error: ${e}, tag: ${n}, tagValue: ${t}}`,"params")},RL={keyword:"discriminator",type:"object",schemaType:"object",error:AL,code(e){let{gen:t,data:n,schema:i,parentSchema:r,it:o}=e,{oneOf:a}=r;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let c=i.propertyName;if(typeof c!="string")throw new Error("discriminator: requires propertyName");if(i.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");let u=t.let("valid",!1),l=t.const("tag",(0,oa._)`${n}${(0,oa.getProperty)(c)}`);t.if((0,oa._)`typeof ${l} == "string"`,()=>d(),()=>e.error(!1,{discrError:ox.DiscrError.Tag,tag:l,tagName:c})),e.ok(u);function d(){let m=p();t.if(!1);for(let h in m)t.elseIf((0,oa._)`${l} === ${h}`),t.assign(u,f(m[h]));t.else(),e.error(!1,{discrError:ox.DiscrError.Mapping,tag:l,tagName:c}),t.endIf()}s(d,"validateMapping");function f(m){let h=t.name("valid"),g=e.subschema({keyword:"oneOf",schemaProp:m},h);return e.mergeEvaluated(g,oa.Name),h}s(f,"applyTagSchema");function p(){var m;let h={},g=b(r),v=!0;for(let U=0;U<a.length;U++){let D=a[U];if(D?.$ref&&!(0,DL.schemaHasRulesButRef)(D,o.self.RULES)){let Se=D.$ref;if(D=_O.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,Se),D instanceof _O.SchemaEnv&&(D=D.schema),D===void 0)throw new NL.default(o.opts.uriResolver,o.baseId,Se)}let W=(m=D?.properties)===null||m===void 0?void 0:m[c];if(typeof W!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${c}"`);v=v&&(g||b(D)),k(W,U)}if(!v)throw new Error(`discriminator: "${c}" must be required`);return h;function b({required:U}){return Array.isArray(U)&&U.includes(c)}function k(U,D){if(U.const)z(U.const,D);else if(U.enum)for(let W of U.enum)z(W,D);else throw new Error(`discriminator: "properties/${c}" must have "const" or "enum"`)}function z(U,D){if(typeof U!="string"||U in h)throw new Error(`discriminator: "${c}" values must be unique strings`);h[U]=D}}s(p,"getMapping")}};ax.default=RL});var bO=A((BX,CL)=>{CL.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var cx=A((Te,sx)=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.MissingRefError=Te.ValidationError=Te.CodeGen=Te.Name=Te.nil=Te.stringify=Te.str=Te._=Te.KeywordCxt=Te.Ajv=void 0;var UL=vT(),ZL=gO(),ML=$O(),xO=bO(),LL=["/properties"],Sp="http://json-schema.org/draft-07/schema",aa=class extends UL.default{static{s(this,"Ajv")}_addVocabularies(){super._addVocabularies(),ZL.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(ML.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(xO,LL):xO;this.addMetaSchema(t,Sp,!1),this.refs["http://json-schema.org/schema"]=Sp}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Sp)?Sp:void 0)}};Te.Ajv=aa;sx.exports=Te=aa;sx.exports.Ajv=aa;Object.defineProperty(Te,"__esModule",{value:!0});Te.default=aa;var VL=gc();Object.defineProperty(Te,"KeywordCxt",{enumerable:!0,get:s(function(){return VL.KeywordCxt},"get")});var sa=te();Object.defineProperty(Te,"_",{enumerable:!0,get:s(function(){return sa._},"get")});Object.defineProperty(Te,"str",{enumerable:!0,get:s(function(){return sa.str},"get")});Object.defineProperty(Te,"stringify",{enumerable:!0,get:s(function(){return sa.stringify},"get")});Object.defineProperty(Te,"nil",{enumerable:!0,get:s(function(){return sa.nil},"get")});Object.defineProperty(Te,"Name",{enumerable:!0,get:s(function(){return sa.Name},"get")});Object.defineProperty(Te,"CodeGen",{enumerable:!0,get:s(function(){return sa.CodeGen},"get")});var FL=np();Object.defineProperty(Te,"ValidationError",{enumerable:!0,get:s(function(){return FL.default},"get")});var qL=vc();Object.defineProperty(Te,"MissingRefError",{enumerable:!0,get:s(function(){return qL.default},"get")})});var OO=A($r=>{"use strict";Object.defineProperty($r,"__esModule",{value:!0});$r.formatNames=$r.fastFormats=$r.fullFormats=void 0;function _r(e,t){return{validate:e,compare:t}}s(_r,"fmtDef");$r.fullFormats={date:_r(IO,fx),time:_r(lx(!0),px),"date-time":_r(kO(!0),PO),"iso-time":_r(lx(),zO),"iso-date-time":_r(kO(),TO),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:WL,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:n2,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:XL,int32:{type:"number",validate:e2},int64:{type:"number",validate:t2},float:{type:"number",validate:SO},double:{type:"number",validate:SO},password:!0,binary:!0};$r.fastFormats={...$r.fullFormats,date:_r(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,fx),time:_r(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,px),"date-time":_r(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,PO),"iso-time":_r(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,zO),"iso-date-time":_r(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,TO),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};$r.formatNames=Object.keys($r.fullFormats);function JL(e){return e%4===0&&(e%100!==0||e%400===0)}s(JL,"isLeapYear");var BL=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,KL=[0,31,28,31,30,31,30,31,31,30,31,30,31];function IO(e){let t=BL.exec(e);if(!t)return!1;let n=+t[1],i=+t[2],r=+t[3];return i>=1&&i<=12&&r>=1&&r<=(i===2&&JL(n)?29:KL[i])}s(IO,"date");function fx(e,t){if(e&&t)return e>t?1:e<t?-1:0}s(fx,"compareDate");var ux=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function lx(e){return s(function(n){let i=ux.exec(n);if(!i)return!1;let r=+i[1],o=+i[2],a=+i[3],c=i[4],u=i[5]==="-"?-1:1,l=+(i[6]||0),d=+(i[7]||0);if(l>23||d>59||e&&!c)return!1;if(r<=23&&o<=59&&a<60)return!0;let f=o-d*u,p=r-l*u-(f<0?1:0);return(p===23||p===-1)&&(f===59||f===-1)&&a<61},"time")}s(lx,"getTime");function px(e,t){if(!(e&&t))return;let n=new Date("2020-01-01T"+e).valueOf(),i=new Date("2020-01-01T"+t).valueOf();if(n&&i)return n-i}s(px,"compareTime");function zO(e,t){if(!(e&&t))return;let n=ux.exec(e),i=ux.exec(t);if(n&&i)return e=n[1]+n[2]+n[3],t=i[1]+i[2]+i[3],e>t?1:e<t?-1:0}s(zO,"compareIsoTime");var dx=/t|\s/i;function kO(e){let t=lx(e);return s(function(i){let r=i.split(dx);return r.length===2&&IO(r[0])&&t(r[1])},"date_time")}s(kO,"getDateTime");function PO(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),i=new Date(t).valueOf();if(n&&i)return n-i}s(PO,"compareDateTime");function TO(e,t){if(!(e&&t))return;let[n,i]=e.split(dx),[r,o]=t.split(dx),a=fx(n,r);if(a!==void 0)return a||px(i,o)}s(TO,"compareIsoDateTime");var HL=/\/|:/,GL=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function WL(e){return HL.test(e)&&GL.test(e)}s(WL,"uri");var wO=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function XL(e){return wO.lastIndex=0,wO.test(e)}s(XL,"byte");var YL=-(2**31),QL=2**31-1;function e2(e){return Number.isInteger(e)&&e<=QL&&e>=YL}s(e2,"validateInt32");function t2(e){return Number.isInteger(e)}s(t2,"validateInt64");function SO(){return!0}s(SO,"validateNumber");var r2=/[^\\]\\Z/;function n2(e){if(r2.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}s(n2,"regex")});var EO=A(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.formatLimitDefinition=void 0;var i2=cx(),ir=te(),wn=ir.operators,Ip={formatMaximum:{okStr:"<=",ok:wn.LTE,fail:wn.GT},formatMinimum:{okStr:">=",ok:wn.GTE,fail:wn.LT},formatExclusiveMaximum:{okStr:"<",ok:wn.LT,fail:wn.GTE},formatExclusiveMinimum:{okStr:">",ok:wn.GT,fail:wn.LTE}},o2={message:s(({keyword:e,schemaCode:t})=>(0,ir.str)`should be ${Ip[e].okStr} ${t}`,"message"),params:s(({keyword:e,schemaCode:t})=>(0,ir._)`{comparison: ${Ip[e].okStr}, limit: ${t}}`,"params")};ca.formatLimitDefinition={keyword:Object.keys(Ip),type:"string",schemaType:"string",$data:!0,error:o2,code(e){let{gen:t,data:n,schemaCode:i,keyword:r,it:o}=e,{opts:a,self:c}=o;if(!a.validateFormats)return;let u=new i2.KeywordCxt(o,c.RULES.all.format.definition,"format");u.$data?l():d();function l(){let p=t.scopeValue("formats",{ref:c.formats,code:a.code.formats}),m=t.const("fmt",(0,ir._)`${p}[${u.schemaCode}]`);e.fail$data((0,ir.or)((0,ir._)`typeof ${m} != "object"`,(0,ir._)`${m} instanceof RegExp`,(0,ir._)`typeof ${m}.compare != "function"`,f(m)))}s(l,"validate$DataFormat");function d(){let p=u.schema,m=c.formats[p];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${r}": format "${p}" does not define "compare" function`);let h=t.scopeValue("formats",{key:p,ref:m,code:a.code.formats?(0,ir._)`${a.code.formats}${(0,ir.getProperty)(p)}`:void 0});e.fail$data(f(h))}s(d,"validateFormat");function f(p){return(0,ir._)`${p}.compare(${n}, ${i}) ${Ip[r].fail} 0`}s(f,"compareCode")},dependencies:["format"]};var a2=s(e=>(e.addKeyword(ca.formatLimitDefinition),e),"formatLimitPlugin");ca.default=a2});var AO=A((jc,DO)=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});var ua=OO(),s2=EO(),mx=te(),jO=new mx.Name("fullFormats"),c2=new mx.Name("fastFormats"),hx=s((e,t={keywords:!0})=>{if(Array.isArray(t))return NO(e,t,ua.fullFormats,jO),e;let[n,i]=t.mode==="fast"?[ua.fastFormats,c2]:[ua.fullFormats,jO],r=t.formats||ua.formatNames;return NO(e,r,n,i),t.keywords&&(0,s2.default)(e),e},"formatsPlugin");hx.get=(e,t="full")=>{let i=(t==="fast"?ua.fastFormats:ua.fullFormats)[e];if(!i)throw new Error(`Unknown format "${e}"`);return i};function NO(e,t,n,i){var r,o;(r=(o=e.opts.code).formats)!==null&&r!==void 0||(o.formats=(0,mx._)`require("ajv-formats/dist/formats").${i}`);for(let a of t)e.addFormat(a,n[a])}s(NO,"addFormats");DO.exports=jc=hx;Object.defineProperty(jc,"__esModule",{value:!0});jc.default=hx});function u2(){let e=new RO.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,CO.default)(e),e}var RO,CO,zp,UO=$(()=>{RO=wx(cx(),1),CO=wx(AO(),1);s(u2,"createDefaultAjvInstance");zp=class{static{s(this,"AjvJsonSchemaValidator")}constructor(t){this._ajv=t??u2()}getValidator(t){let n="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return i=>n(i)?{valid:!0,data:i,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(n.errors)}}}});var Pp,ZO=$(()=>{Bo();Pp=class{static{s(this,"ExperimentalServerTasks")}constructor(t){this._server=t}requestStream(t,n,i){return this._server.requestStream(t,n,i)}createMessageStream(t,n){let i=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!i?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let r=t.messages[t.messages.length-1],o=Array.isArray(r.content)?r.content:[r.content],a=o.some(d=>d.type==="tool_result"),c=t.messages.length>1?t.messages[t.messages.length-2]:void 0,u=c?Array.isArray(c.content)?c.content:[c.content]:[],l=u.some(d=>d.type==="tool_use");if(a){if(o.some(d=>d.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){let d=new Set(u.filter(p=>p.type==="tool_use").map(p=>p.id)),f=new Set(o.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(d.size!==f.size||![...d].every(p=>f.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},tc,n)}elicitInputStream(t,n){let i=this._server.getClientCapabilities(),r=t.mode??"form";switch(r){case"url":{if(!i?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!i?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let o=r==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:o},Jo,n)}async getTask(t,n){return this._server.getTask({taskId:t},n)}async getTaskResult(t,n,i){return this._server.getTaskResult({taskId:t},n,i)}async listTasks(t,n){return this._server.listTasks(t?{cursor:t}:void 0,n)}async cancelTask(t,n){return this._server.cancelTask({taskId:t},n)}}});function MO(e,t,n){if(!e)throw new Error(`${n} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${n} does not support task creation for tools/call (required for ${t})`);break;default:break}}function LO(e,t,n){if(!e)throw new Error(`${n} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${n} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var VO=$(()=>{s(MO,"assertToolsCallTaskCapability");s(LO,"assertClientRequestTaskCapability")});var Tp,FO=$(()=>{Cz();Bo();UO();Ns();ZO();VO();Tp=class extends qf{static{s(this,"Server")}constructor(t,n){super(n),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(ec.options.map((i,r)=>[i,r])),this.isMessageIgnored=(i,r)=>{let o=this._loggingLevels.get(r);return o?this.LOG_LEVEL_SEVERITY.get(i)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=n?.capabilities??{},this._instructions=n?.instructions,this._jsonSchemaValidator=n?.jsonSchemaValidator??new zp,this.setRequestHandler(k_,i=>this._oninitialize(i)),this.setNotificationHandler(w_,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(E_,async(i,r)=>{let o=r.sessionId||r.requestInfo?.headers["mcp-session-id"]||void 0,{level:a}=i.params,c=ec.safeParse(a);return c.success&&this._loggingLevels.set(o,c.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Pp(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Rz(this._capabilities,t)}setRequestHandler(t,n){let r=cn(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let o=jo(r);if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let c=s(async(u,l)=>{let d=sn(qo,u);if(!d.success){let h=d.error instanceof Error?d.error.message:String(d.error);throw new Z(V.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:f}=d.data,p=await Promise.resolve(n(u,l));if(f.task){let h=sn(Vo,p);if(!h.success){let g=h.error instanceof Error?h.error.message:String(h.error);throw new Z(V.InvalidParams,`Invalid task creation result: ${g}`)}return h.data}let m=sn(jf,p);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new Z(V.InvalidParams,`Invalid tools/call result: ${h}`)}return m.data},"wrappedHandler");return super.setRequestHandler(t,c)}return super.setRequestHandler(t,n)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){LO(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&MO(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let n=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:RI.includes(n)?n:y_,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},gf)}async createMessage(t,n){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let i=t.messages[t.messages.length-1],r=Array.isArray(i.content)?i.content:[i.content],o=r.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(o){if(r.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(r.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==d.size||![...l].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},j_,n):this.request({method:"sampling/createMessage",params:t},tc,n)}async elicitInput(t,n){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let r=t;return this.request({method:"elicitation/create",params:r},Jo,n)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let r=t.mode==="form"?t:{...t,mode:"form"},o=await this.request({method:"elicitation/create",params:r},Jo,n);if(o.action==="accept"&&o.content&&r.requestedSchema)try{let c=this._jsonSchemaValidator.getValidator(r.requestedSchema)(o.content);if(!c.valid)throw new Z(V.InvalidParams,`Elicitation response content does not match requested schema: ${c.errorMessage}`)}catch(a){throw a instanceof Z?a:new Z(V.InternalError,`Error validating elicitation response: ${a instanceof Error?a.message:String(a)}`)}return o}}}createElicitationCompletionNotifier(t,n){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},n)}async listRoots(t,n){return this.request({method:"roots/list",params:t},N_,n)}async sendLoggingMessage(t,n){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,n))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}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 gx(e){return!!e&&typeof e=="object"&&JO in e}function BO(e){return e[JO]?.complete}var JO,qO,KO=$(()=>{JO=Symbol.for("mcp.completable");s(gx,"isCompletable");s(BO,"getCompleter");(function(e){e.Completable="McpCompletable"})(qO||(qO={}))});var HO=$(()=>{});function d2(e){let t=[];if(e.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!l2.test(e)){let n=e.split("").filter(i=>!/[A-Za-z0-9._-]/.test(i)).filter((i,r,o)=>o.indexOf(i)===r);return t.push(`Tool name contains invalid characters: ${n.map(i=>`"${i}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function f2(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let n of t)console.warn(` - ${n}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function vx(e){let t=d2(e);return f2(e,t.warnings),t.isValid}var l2,GO=$(()=>{l2=/^[A-Za-z0-9._-]{1,128}$/;s(d2,"validateToolName");s(f2,"issueToolNameWarning");s(vx,"validateAndWarnToolName")});var Op,WO=$(()=>{Op=class{static{s(this,"ExperimentalMcpServerTasks")}constructor(t){this._mcpServer=t}registerToolTask(t,n,i){let r={taskSupport:"required",...n.execution};if(r.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,n.title,n.description,n.inputSchema,n.outputSchema,n.annotations,r,n._meta,i)}}});var yx=$(()=>{ff();ff()});function p2(e,t){let n=0,i=[e];for(;i.length>0;){let r=i.pop();if(!(r===null||typeof r!="object"))if(Array.isArray(r))for(let o of r){if(++n>t)return n;o!==null&&typeof o=="object"&&i.push(o)}else for(let o in r){if(!Object.prototype.hasOwnProperty.call(r,o))continue;if(++n>t)return n;let a=r[o];a!==null&&typeof a=="object"&&i.push(a)}}return n}function m2(e){if(!(e===void 0||e===1/0)){if(typeof e!="number"||Number.isNaN(e)||e<1)throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(e)}`);return e}}function QO(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function eE(e){return"_def"in e||"_zod"in e||QO(e)}function _x(e){return typeof e!="object"||e===null||eE(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(QO)}function XO(e){if(e){if(_x(e))return Hn(e);if(!eE(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function g2(e){let t=cn(e);return t?Object.entries(t).map(([n,i])=>{let r=i0(i),o=o0(i);return{name:n,description:r,required:!o}}):[]}function Sn(e){let n=cn(e)?.method;if(!n)throw new Error("Schema is missing a method literal");let i=jo(n);if(typeof i=="string")return i;throw new Error("Schema method literal must be a string")}function YO(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var Ep,h2,Nc,tE=$(()=>{FO();Ns();g$();Bo();KO();HO();GO();WO();yx();s(p2,"toolInputElementCount");s(m2,"resolveMaxToolInputElements");Ep=class{static{s(this,"McpServer")}constructor(t,n){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Tp(t,n),this._maxToolInputElements=m2(n?.maxToolInputElements)}get experimental(){return this._experimental||(this._experimental={tasks:new Op(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Sn(Ef)),this.server.assertCanSetRequestHandler(Sn(qo)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Ef,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,n])=>{let i={name:t,title:n.title,description:n.description,inputSchema:(()=>{let r=Eo(n.inputSchema);return r?p$(r,{strictUnions:!0,pipeStrategy:"input"}):h2})(),annotations:n.annotations,execution:n.execution,_meta:n._meta};if(n.outputSchema){let r=Eo(n.outputSchema);r&&(i.outputSchema=p$(r,{strictUnions:!0,pipeStrategy:"output"}))}return i})})),this.server.setRequestHandler(qo,async(t,n)=>{try{let i=this._registeredTools[t.params.name];if(!i)throw new Z(V.InvalidParams,`Tool ${t.params.name} not found`);if(!i.enabled)throw new Z(V.InvalidParams,`Tool ${t.params.name} disabled`);let r=!!t.params.task,o=i.execution?.taskSupport,a="createTask"in i.handler;if((o==="required"||o==="optional")&&!a)throw new Z(V.InternalError,`Tool ${t.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!r)throw new Z(V.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(o==="optional"&&!r&&a)return await this.handleAutomaticTaskPolling(i,t,n);let c=await this.validateToolInput(i,t.params.arguments,t.params.name),u=await this.executeToolHandler(i,c,n);return r||await this.validateToolOutput(i,u,t.params.name),u}catch(i){if(i instanceof Z&&i.code===V.UrlElicitationRequired)throw i;return this.createToolError(i instanceof Error?i.message:String(i))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,n,i){if(this._maxToolInputElements!==void 0&&p2(n,this._maxToolInputElements)>this._maxToolInputElements)throw new Z(V.InvalidParams,`Invalid arguments for tool ${i}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!t.inputSchema)return;let o=Eo(t.inputSchema)??t.inputSchema,a=await Nd(o,n??{});if(!a.success){let c="error"in a?a.error:"Unknown error",u=Dd(c);throw new Z(V.InvalidParams,`Input validation error: Invalid arguments for tool ${i}: ${u}`)}return a.data}async validateToolOutput(t,n,i){if(!t.outputSchema||!("content"in n)||n.isError)return;if(!n.structuredContent)throw new Z(V.InvalidParams,`Output validation error: Tool ${i} has an output schema but no structured content was provided`);let r=Eo(t.outputSchema),o=await Nd(r,n.structuredContent);if(!o.success){let a="error"in o?o.error:"Unknown error",c=Dd(a);throw new Z(V.InvalidParams,`Output validation error: Invalid structured content for tool ${i}: ${c}`)}}async executeToolHandler(t,n,i){let r=t.handler;if("createTask"in r){if(!i.taskStore)throw new Error("No task store provided.");let a={...i,taskStore:i.taskStore};if(t.inputSchema){let c=r;return await Promise.resolve(c.createTask(n,a))}else{let c=r;return await Promise.resolve(c.createTask(a))}}if(t.inputSchema){let a=r;return await Promise.resolve(a(n,i))}else{let a=r;return await Promise.resolve(a(i))}}async handleAutomaticTaskPolling(t,n,i){if(!i.taskStore)throw new Error("No task store provided for task-capable tool.");let r=await this.validateToolInput(t,n.params.arguments,n.params.name),o=t.handler,a={...i,taskStore:i.taskStore},c=r?await Promise.resolve(o.createTask(r,a)):await Promise.resolve(o.createTask(a)),u=c.task.taskId,l=c.task,d=l.pollInterval??5e3;for(;l.status!=="completed"&&l.status!=="failed"&&l.status!=="cancelled";){await new Promise(p=>setTimeout(p,d));let f=await i.taskStore.getTask(u);if(!f)throw new Z(V.InternalError,`Task ${u} not found during polling`);l=f}return await i.taskStore.getTaskResult(u)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Sn(Nf)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Nf,async t=>{switch(t.params.ref.type){case"ref/prompt":return YI(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return QI(t),this.handleResourceCompletion(t,t.params.ref);default:throw new Z(V.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,n){let i=this._registeredPrompts[n.name];if(!i)throw new Z(V.InvalidParams,`Prompt ${n.name} not found`);if(!i.enabled)throw new Z(V.InvalidParams,`Prompt ${n.name} disabled`);if(!i.argsSchema)return Nc;let o=cn(i.argsSchema)?.[t.params.argument.name];if(!gx(o))return Nc;let a=BO(o);if(!a)return Nc;let c=await a(t.params.argument.value,t.params.context);return YO(c)}async handleResourceCompletion(t,n){let i=Object.values(this._registeredResourceTemplates).find(a=>a.resourceTemplate.uriTemplate.toString()===n.uri);if(!i){if(this._registeredResources[n.uri])return Nc;throw new Z(V.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let r=i.resourceTemplate.completeCallback(t.params.argument.name);if(!r)return Nc;let o=await r(t.params.argument.value,t.params.context);return YO(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Sn(If)),this.server.assertCanSetRequestHandler(Sn(zf)),this.server.assertCanSetRequestHandler(Sn(Pf)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(If,async(t,n)=>{let i=Object.entries(this._registeredResources).filter(([o,a])=>a.enabled).map(([o,a])=>({uri:o,name:a.name,...a.metadata})),r=[];for(let o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;let a=await o.resourceTemplate.listCallback(n);for(let c of a.resources)r.push({...o.metadata,...c})}return{resources:[...i,...r]}}),this.server.setRequestHandler(zf,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([n,i])=>({name:n,uriTemplate:i.resourceTemplate.uriTemplate.toString(),...i.metadata}))})),this.server.setRequestHandler(Pf,async(t,n)=>{let i=new URL(t.params.uri),r=this._registeredResources[i.toString()];if(r){if(!r.enabled)throw new Z(V.InvalidParams,`Resource ${i} disabled`);return r.readCallback(i,n)}for(let o of Object.values(this._registeredResourceTemplates)){let a=o.resourceTemplate.uriTemplate.match(i.toString());if(a)return o.readCallback(i,a,n)}throw new Z(V.InvalidParams,`Resource ${i} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Sn(Tf)),this.server.assertCanSetRequestHandler(Sn(Of)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Tf,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,n])=>({name:t,title:n.title,description:n.description,arguments:n.argsSchema?g2(n.argsSchema):void 0}))})),this.server.setRequestHandler(Of,async(t,n)=>{let i=this._registeredPrompts[t.params.name];if(!i)throw new Z(V.InvalidParams,`Prompt ${t.params.name} not found`);if(!i.enabled)throw new Z(V.InvalidParams,`Prompt ${t.params.name} disabled`);if(i.argsSchema){let r=Eo(i.argsSchema),o=await Nd(r,t.params.arguments??{});if(!o.success){let u="error"in o?o.error:"Unknown error",l=Dd(u);throw new Z(V.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${l}`)}let a=o.data,c=i.callback;return await Promise.resolve(c(a,n))}else{let r=i.callback;return await Promise.resolve(r(n))}}),this._promptHandlersInitialized=!0)}resource(t,n,...i){let r;typeof i[0]=="object"&&(r=i.shift());let o=i[0];if(typeof n=="string"){if(this._registeredResources[n])throw new Error(`Resource ${n} is already registered`);let a=this._createRegisteredResource(t,void 0,n,r,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let a=this._createRegisteredResourceTemplate(t,void 0,n,r,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}}registerResource(t,n,i,r){if(typeof n=="string"){if(this._registeredResources[n])throw new Error(`Resource ${n} is already registered`);let o=this._createRegisteredResource(t,i.title,n,i,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let o=this._createRegisteredResourceTemplate(t,i.title,n,i,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(t,n,i,r,o){let a={name:t,title:n,metadata:r,readCallback:o,enabled:!0,disable:s(()=>a.update({enabled:!1}),"disable"),enable:s(()=>a.update({enabled:!0}),"enable"),remove:s(()=>a.update({uri:null}),"remove"),update:s(c=>{typeof c.uri<"u"&&c.uri!==i&&(delete this._registeredResources[i],c.uri&&(this._registeredResources[c.uri]=a)),typeof c.name<"u"&&(a.name=c.name),typeof c.title<"u"&&(a.title=c.title),typeof c.metadata<"u"&&(a.metadata=c.metadata),typeof c.callback<"u"&&(a.readCallback=c.callback),typeof c.enabled<"u"&&(a.enabled=c.enabled),this.sendResourceListChanged()},"update")};return this._registeredResources[i]=a,a}_createRegisteredResourceTemplate(t,n,i,r,o){let a={resourceTemplate:i,title:n,metadata:r,readCallback:o,enabled:!0,disable:s(()=>a.update({enabled:!1}),"disable"),enable:s(()=>a.update({enabled:!0}),"enable"),remove:s(()=>a.update({name:null}),"remove"),update:s(l=>{typeof l.name<"u"&&l.name!==t&&(delete this._registeredResourceTemplates[t],l.name&&(this._registeredResourceTemplates[l.name]=a)),typeof l.title<"u"&&(a.title=l.title),typeof l.template<"u"&&(a.resourceTemplate=l.template),typeof l.metadata<"u"&&(a.metadata=l.metadata),typeof l.callback<"u"&&(a.readCallback=l.callback),typeof l.enabled<"u"&&(a.enabled=l.enabled),this.sendResourceListChanged()},"update")};this._registeredResourceTemplates[t]=a;let c=i.uriTemplate.variableNames;return Array.isArray(c)&&c.some(l=>!!i.completeCallback(l))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(t,n,i,r,o){let a={title:n,description:i,argsSchema:r===void 0?void 0:Hn(r),callback:o,enabled:!0,disable:s(()=>a.update({enabled:!1}),"disable"),enable:s(()=>a.update({enabled:!0}),"enable"),remove:s(()=>a.update({name:null}),"remove"),update:s(c=>{typeof c.name<"u"&&c.name!==t&&(delete this._registeredPrompts[t],c.name&&(this._registeredPrompts[c.name]=a)),typeof c.title<"u"&&(a.title=c.title),typeof c.description<"u"&&(a.description=c.description),typeof c.argsSchema<"u"&&(a.argsSchema=Hn(c.argsSchema)),typeof c.callback<"u"&&(a.callback=c.callback),typeof c.enabled<"u"&&(a.enabled=c.enabled),this.sendPromptListChanged()},"update")};return this._registeredPrompts[t]=a,r&&Object.values(r).some(u=>{let l=u instanceof Yn?u._def?.innerType:u;return gx(l)})&&this.setCompletionRequestHandler(),a}_createRegisteredTool(t,n,i,r,o,a,c,u,l){vx(t);let d={title:n,description:i,inputSchema:XO(r),outputSchema:XO(o),annotations:a,execution:c,_meta:u,handler:l,enabled:!0,disable:s(()=>d.update({enabled:!1}),"disable"),enable:s(()=>d.update({enabled:!0}),"enable"),remove:s(()=>d.update({name:null}),"remove"),update:s(f=>{typeof f.name<"u"&&f.name!==t&&(typeof f.name=="string"&&vx(f.name),delete this._registeredTools[t],f.name&&(this._registeredTools[f.name]=d)),typeof f.title<"u"&&(d.title=f.title),typeof f.description<"u"&&(d.description=f.description),typeof f.paramsSchema<"u"&&(d.inputSchema=Hn(f.paramsSchema)),typeof f.outputSchema<"u"&&(d.outputSchema=Hn(f.outputSchema)),typeof f.callback<"u"&&(d.handler=f.callback),typeof f.annotations<"u"&&(d.annotations=f.annotations),typeof f._meta<"u"&&(d._meta=f._meta),typeof f.enabled<"u"&&(d.enabled=f.enabled),this.sendToolListChanged()},"update")};return this._registeredTools[t]=d,this.setToolRequestHandlers(),this.sendToolListChanged(),d}tool(t,...n){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let i,r,o,a;if(typeof n[0]=="string"&&(i=n.shift()),n.length>1){let u=n[0];if(_x(u))r=n.shift(),n.length>1&&typeof n[0]=="object"&&n[0]!==null&&!_x(n[0])&&(a=n.shift());else if(typeof u=="object"&&u!==null){if(Object.values(u).some(l=>typeof l=="object"&&l!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);a=n.shift()}}let c=n[0];return this._createRegisteredTool(t,void 0,i,r,o,a,{taskSupport:"forbidden"},void 0,c)}registerTool(t,n,i){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:r,description:o,inputSchema:a,outputSchema:c,annotations:u,_meta:l}=n;return this._createRegisteredTool(t,r,o,a,c,u,{taskSupport:"forbidden"},l,i)}prompt(t,...n){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let i;typeof n[0]=="string"&&(i=n.shift());let r;n.length>1&&(r=n.shift());let o=n[0],a=this._createRegisteredPrompt(t,void 0,i,r,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}registerPrompt(t,n,i){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:r,description:o,argsSchema:a}=n,c=this._createRegisteredPrompt(t,r,o,a,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),c}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,n){return this.server.sendLoggingMessage(t,n)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},h2={type:"object",properties:{}};s(QO,"isZodTypeLike");s(eE,"isZodSchemaInstance");s(_x,"isZodRawShapeCompat");s(XO,"getZodSchemaObject");s(g2,"promptArgumentsFromSchema");s(Sn,"getMethodValue");s(YO,"createCompletionResult");Nc={completion:{values:[],hasMore:!1}}});function y2(e){return qI.parse(JSON.parse(e))}function rE(e){return JSON.stringify(e)+`
|
|
125
125
|
`}var v2,jp,nE=$(()=>{Bo();v2=10*1024*1024,jp=class{static{s(this,"ReadBuffer")}constructor(t){this._maxBufferSize=t?.maxBufferSize??v2}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
126
126
|
`);if(t===-1)return null;let n=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),y2(n)}clear(){this._buffer=void 0}};s(y2,"deserializeMessage");s(rE,"serializeMessage")});import iE from"node:process";var Np,oE=$(()=>{nE();Np=class{static{s(this,"StdioServerTransport")}constructor(t=iE.stdin,n=iE.stdout,i){this._stdin=t,this._stdout=n,this._started=!1,this._ondata=r=>{try{this._readBuffer.append(r),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}},this._onerror=r=>{this.onerror?.(r)},this._readBuffer=new jp({maxBufferSize:i?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(n=>{let i=rE(t);this._stdout.write(i)?n():this._stdout.once("drain",n)})}}});var sE={};mt(sE,{runMcp:()=>b2});async function b2(){let e=new Ep({name:"hivemind",version:_2}),t=s(()=>Fr(process.env.HIVEMIND_CWD||process.cwd()),"repo"),n=s((r,o)=>{let a=t();if(!a)return Dp(aE,!0);kr(a),zr(a);let[c]=Jr(a,[r]);return Dp(`${o} ${$2} [op:${c.id}]`)},"publish"),i=s((r,o,a)=>jt(it(r).ops).get(ar({kind:o,key:a})),"entry");e.registerTool("plan_get",{description:"Read the team's shared plan: goals, contracts (APIs/schemas/types), decisions, tasks and open questions.",inputSchema:{kind:Ie.enum(Nt).optional().describe("Only return this kind of entry")}},async({kind:r})=>{let o=t();if(!o)return Dp(aE,!0);kr(o);let a=it(o).ops.filter(c=>!r||c.kind===r);return Dp(`You are ${o.memberId}.
|
|
127
|
-
${vi(a)}`)}),e.registerTool("task_claim",{description:"Claim a task so teammates know you are working on it. Call before starting a piece of work.",inputSchema:{key:Ie.string().describe('Short stable id, e.g. "auth-api"'),title:Ie.string(),areas:Ie.array(Ie.string()).optional().describe("Files, directories or topics this task touches")}},async({key:r,title:o,areas:a})=>{let c=t(),u=c&&i(c,"task",r),l=u?.status==="open"?u.data.owner:void 0,d=c&&l&&l!==c.memberId&&u?.data.status==="doing"?` Warning: ${l} had already claimed this task; coordinate with them.`:"";return n({kind:"task",key:r,data:{title:o,status:"doing",owner:c?.memberId,...a?{areas:a}:{}}},`Claimed task "${r}".${d}`)}),e.registerTool("task_update",{description:"Update a task: progress note, status change, or mark done/blocked.",inputSchema:{key:Ie.string(),status:Ie.enum(["todo","doing","done","blocked"]).optional(),note:Ie.string().optional()}},async({key:r,status:o,note:a})=>n({kind:"task",key:r,data:{...o?{status:o}:{},...a?{note:a}:{}}},`Updated task "${r}".`)),e.registerTool("contract_publish",{description:"Publish or change something other agents build against: an API route and its request/response shape, a DB schema, a shared type, an env var, or file ownership. Set breaking=true if existing consumers must change.",inputSchema:{key:Ie.string().describe('Stable name, e.g. "POST /api/login" or "User"'),spec:Ie.string().describe('The concrete shape, e.g. "{ id: uuid, email: string }"'),breaking:Ie.boolean().optional(),areas:Ie.array(Ie.string()).optional()}},async({key:r,spec:o,breaking:a,areas:c})=>n({kind:"contract",key:r,data:{spec:o,breaking:a??!1,...c?{areas:c}:{}}},`Published contract "${r}"${a?" as BREAKING":""}.`)),e.registerTool("decision_log",{description:"Record a project decision teammates should follow (library choice, convention, architecture).",inputSchema:{key:Ie.string(),text:Ie.string(),rationale:Ie.string().optional()}},async({key:r,text:o,rationale:a})=>n({kind:"decision",key:r,data:{text:o,...a?{rationale:a}:{}}},`Logged decision "${r}".`)),e.registerTool("goal_set",{description:"Set or change a project goal / scope statement.",inputSchema:{key:Ie.string(),text:Ie.string()}},async({key:r,text:o})=>n({kind:"goal",key:r,data:{text:o}},`Set goal "${r}".`)),e.registerTool("question",{description:"Ask the team an open question, or answer one (providing answer closes it for discussion).",inputSchema:{key:Ie.string(),text:Ie.string().optional(),answer:Ie.string().optional()}},async({key:r,text:o,answer:a})=>n({kind:"question",key:r,data:{...o?{text:o}:{},...a?{answer:a}:{}}},a?`Answered "${r}".`:`Asked "${r}".`)),e.registerTool("plan_remove",{description:"Remove an obsolete entry from the plan.",inputSchema:{kind:Ie.enum(Nt),key:Ie.string()}},async({kind:r,key:o})=>n({type:"close",kind:r,key:o},`Removed ${r} "${o}".`)),await e.connect(new Np)}var _2,Dp,aE,$2,cE=$(()=>{"use strict";tE();oE();yx();yi();gi();bi();ki();Pn();Br();_2="0.1.
|
|
127
|
+
${vi(a)}`)}),e.registerTool("task_claim",{description:"Claim a task so teammates know you are working on it. Call before starting a piece of work.",inputSchema:{key:Ie.string().describe('Short stable id, e.g. "auth-api"'),title:Ie.string(),areas:Ie.array(Ie.string()).optional().describe("Files, directories or topics this task touches")}},async({key:r,title:o,areas:a})=>{let c=t(),u=c&&i(c,"task",r),l=u?.status==="open"?u.data.owner:void 0,d=c&&l&&l!==c.memberId&&u?.data.status==="doing"?` Warning: ${l} had already claimed this task; coordinate with them.`:"";return n({kind:"task",key:r,data:{title:o,status:"doing",owner:c?.memberId,...a?{areas:a}:{}}},`Claimed task "${r}".${d}`)}),e.registerTool("task_update",{description:"Update a task: progress note, status change, or mark done/blocked.",inputSchema:{key:Ie.string(),status:Ie.enum(["todo","doing","done","blocked"]).optional(),note:Ie.string().optional()}},async({key:r,status:o,note:a})=>n({kind:"task",key:r,data:{...o?{status:o}:{},...a?{note:a}:{}}},`Updated task "${r}".`)),e.registerTool("contract_publish",{description:"Publish or change something other agents build against: an API route and its request/response shape, a DB schema, a shared type, an env var, or file ownership. Set breaking=true if existing consumers must change.",inputSchema:{key:Ie.string().describe('Stable name, e.g. "POST /api/login" or "User"'),spec:Ie.string().describe('The concrete shape, e.g. "{ id: uuid, email: string }"'),breaking:Ie.boolean().optional(),areas:Ie.array(Ie.string()).optional()}},async({key:r,spec:o,breaking:a,areas:c})=>n({kind:"contract",key:r,data:{spec:o,breaking:a??!1,...c?{areas:c}:{}}},`Published contract "${r}"${a?" as BREAKING":""}.`)),e.registerTool("decision_log",{description:"Record a project decision teammates should follow (library choice, convention, architecture).",inputSchema:{key:Ie.string(),text:Ie.string(),rationale:Ie.string().optional()}},async({key:r,text:o,rationale:a})=>n({kind:"decision",key:r,data:{text:o,...a?{rationale:a}:{}}},`Logged decision "${r}".`)),e.registerTool("goal_set",{description:"Set or change a project goal / scope statement.",inputSchema:{key:Ie.string(),text:Ie.string()}},async({key:r,text:o})=>n({kind:"goal",key:r,data:{text:o}},`Set goal "${r}".`)),e.registerTool("question",{description:"Ask the team an open question, or answer one (providing answer closes it for discussion).",inputSchema:{key:Ie.string(),text:Ie.string().optional(),answer:Ie.string().optional()}},async({key:r,text:o,answer:a})=>n({kind:"question",key:r,data:{...o?{text:o}:{},...a?{answer:a}:{}}},a?`Answered "${r}".`:`Asked "${r}".`)),e.registerTool("plan_remove",{description:"Remove an obsolete entry from the plan.",inputSchema:{kind:Ie.enum(Nt),key:Ie.string()}},async({kind:r,key:o})=>n({type:"close",kind:r,key:o},`Removed ${r} "${o}".`)),await e.connect(new Np)}var _2,Dp,aE,$2,cE=$(()=>{"use strict";tE();oE();yx();yi();gi();bi();ki();Pn();Br();_2="0.1.1",Dp=s((e,t=!1)=>({content:[{type:"text",text:e}],...t?{isError:t}:{}}),"text"),aE='hivemind is inactive here: not inside a git repository with an "origin" remote.',$2="Teammates' agents will see it at their next tool call.";s(b2,"runMcp")});var xx={};mt(xx,{INTEGRATIONS:()=>pi,hivemindHome:()=>lE,install:()=>P2,launcherPath:()=>Lr,uninstall:()=>T2});import{execFileSync as bx}from"node:child_process";import ze from"node:fs";import Zp from"node:os";import Oe from"node:path";function x2(){try{let e=bx("sh",["-c","command -v node"],{encoding:"utf8"}).trim();if(e)return e}catch{}return process.execPath}function k2(){ze.mkdirSync(Rp(),{recursive:!0});let e=Oe.join(Rp(),"hivemind.mjs");Oe.resolve(process.argv[1])!==e&&ze.copyFileSync(process.argv[1],e),ze.writeFileSync(Lr(),`#!/bin/sh
|
|
128
128
|
# hivemind launcher: keeps agent configs stable across node and hivemind upgrades.
|
|
129
129
|
NODE="${x2()}"
|
|
130
130
|
[ -x "$NODE" ] || NODE="$(command -v node)"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hivemind-agents",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A shared, live plan for teams of coding agents (Claude Code, Codex, Cursor). Syncs through your git remote: no server, no account.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"darwin",
|
|
36
36
|
"linux"
|
|
37
37
|
],
|
|
38
|
-
"mcpName": "io.github.
|
|
38
|
+
"mcpName": "io.github.Leonhest/hivemind",
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "node build.mjs",
|
|
41
41
|
"typecheck": "tsc --noEmit",
|