@swifty.js/swifty 0.0.15 → 0.0.16
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/{agent-KIMFD4RH.js → agent-3T6JNTAT.js} +1 -1
- package/dist/anthropic-3NHEY4SF.js +4 -0
- package/dist/{checker-RSBYV6EP.js → checker-NVYS3GH6.js} +1 -1
- package/dist/{chunk-F24VPQ2I.js → chunk-4XCKINK4.js} +1 -1
- package/dist/{chunk-MNZYPUTY.js → chunk-7IRGXEBO.js} +1 -1
- package/dist/{chunk-6AOZQ3ON.js → chunk-FZUA4PEF.js} +83 -82
- package/dist/{chunk-6ZXBZB2Y.js → chunk-HXLSOWKW.js} +1 -1
- package/dist/{chunk-CYMOBNZF.js → chunk-LC766IV2.js} +1 -1
- package/dist/{chunk-32AZCTP4.js → chunk-RKJQNZWW.js} +1 -1
- package/dist/{chunk-J5LWUHF6.js → chunk-RTOI4JAC.js} +18 -17
- package/dist/{chunk-5CPQ6RWA.js → chunk-YOZTZPFE.js} +1 -1
- package/dist/glob.wasm +0 -0
- package/dist/main.js +180 -180
- package/dist/{openai-HEG2P5DF.js → openai-VS2R4V7J.js} +1 -1
- package/dist/{server-EXSHPT5H.js → server-2FJMXEAV.js} +19 -19
- package/package.json +2 -2
- package/dist/anthropic-K3YA64W4.js +0 -4
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __swiftyCreateRequire } from "node:module";
|
|
3
3
|
const require = __swiftyCreateRequire(import.meta.url);
|
|
4
|
-
import{b as Gl,h as po}from"./chunk-CYMOBNZF.js";import{a as tr}from"./chunk-6ZXBZB2Y.js";import{a as Fe,b as Rl,c as lo,d as uo}from"./chunk-F24VPQ2I.js";import{e as rr}from"./chunk-32AZCTP4.js";import{a as Ol}from"./chunk-5CPQ6RWA.js";import{a as ft}from"./chunk-7MHXMDYC.js";import{A as Fl,B as Ul,C as T,D as E,I as x,K as oi,L as ql,M as ni,O as F,Q as bt,R as Hr,S,T as Ao,a as xl,d as Tl,e as ke,f as Dl,g as $l,h as p,i as Pl,j as H,k as W,l as jl,m as Nl,n as ne,o as _,p as k,q as ce,r as ee,s as ti,t as ri,u as K,v as Re,w as v,x as re,y as zl,z as si}from"./chunk-J5LWUHF6.js";import{a as mo,b as Hl,c as Yl,f as Jl}from"./chunk-A3NIT2ZF.js";import{a as Ll}from"./chunk-E55KH72M.js";import{a as mt,b as B,d as co}from"./chunk-X3UA5OZL.js";var os=B(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.regexpCode=Y.getEsmExportName=Y.getProperty=Y.safeStringify=Y.stringify=Y.strConcat=Y.addCodeArg=Y.str=Y._=Y.nil=Y._Code=Y.Name=Y.IDENTIFIER=Y._CodeOrName=void 0;var rs=class{};Y._CodeOrName=rs;Y.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Dt=class extends rs{constructor(e){if(super(),!Y.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Y.Name=Dt;var Pe=class extends rs{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,s)=>`${r}${s}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,s)=>(s instanceof Dt&&(r[s.str]=(r[s.str]||0)+1),r),{})}};Y._Code=Pe;Y.nil=new Pe("");function gu(t,...e){let r=[t[0]],s=0;for(;s<e.length;)Pi(r,e[s]),r.push(t[++s]);return new Pe(r)}Y._=gu;var $i=new Pe("+");function hu(t,...e){let r=[ss(t[0])],s=0;for(;s<e.length;)r.push($i),Pi(r,e[s]),r.push($i,ss(t[++s]));return py(r),new Pe(r)}Y.str=hu;function Pi(t,e){e instanceof Pe?t.push(...e._items):e instanceof Dt?t.push(e):t.push(gy(e))}Y.addCodeArg=Pi;function py(t){let e=1;for(;e<t.length-1;){if(t[e]===$i){let r=my(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function my(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Dt||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Dt))return`"${t}${e.slice(1)}`}function fy(t,e){return e.emptyStr()?t:t.emptyStr()?e:hu`${t}${e}`}Y.strConcat=fy;function gy(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:ss(Array.isArray(t)?t.join(","):t)}function hy(t){return new Pe(ss(t))}Y.stringify=hy;function ss(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Y.safeStringify=ss;function yy(t){return typeof t=="string"&&Y.IDENTIFIER.test(t)?new Pe(`.${t}`):gu`[${t}]`}Y.getProperty=yy;function Ey(t){if(typeof t=="string"&&Y.IDENTIFIER.test(t))return new Pe(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}Y.getEsmExportName=Ey;function wy(t){return new Pe(t.toString())}Y.regexpCode=wy});var zi=B(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.ValueScope=ve.ValueScopeName=ve.Scope=ve.varKinds=ve.UsedValueState=void 0;var Se=os(),ji=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},vo;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(vo||(ve.UsedValueState=vo={}));ve.varKinds={const:new Se.Name("const"),let:new Se.Name("let"),var:new Se.Name("var")};var Mo=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Se.Name?e:this.name(e)}name(e){return new Se.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,s;if(!((s=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||s===void 0)&&s.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};ve.Scope=Mo;var bo=class extends Se.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:s}){this.value=e,this.scopePath=(0,Se._)`.${new Se.Name(r)}[${s}]`}};ve.ValueScopeName=bo;var Cy=(0,Se._)`\n`,Ni=class extends Mo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Cy:Se.nil}}get(){return this._scope}name(e){return new bo(e,this._newName(e))}value(e,r){var s;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:n}=o,i=(s=r.key)!==null&&s!==void 0?s:r.ref,a=this._values[n];if(a){let l=a.get(i);if(l)return l}else a=this._values[n]=new Map;a.set(i,o);let c=this._scope[n]||(this._scope[n]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:n,itemIndex:u}),o}getValue(e,r){let s=this._values[e];if(s)return s.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,s=>{if(s.scopePath===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return(0,Se._)`${e}${s.scopePath}`})}scopeCode(e=this._values,r,s){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,s)}_reduceValues(e,r,s={},o){let n=Se.nil;for(let i in e){let a=e[i];if(!a)continue;let c=s[i]=s[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,vo.Started);let l=r(u);if(l){let d=this.opts.es5?ve.varKinds.var:ve.varKinds.const;n=(0,Se._)`${n}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))n=(0,Se._)`${n}${l}${this.opts._n}`;else throw new ji(u);c.set(u,vo.Completed)})}return n}};ve.ValueScope=Ni});var N=B(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.or=z.and=z.not=z.CodeGen=z.operators=z.varKinds=z.ValueScopeName=z.ValueScope=z.Scope=z.Name=z.regexpCode=z.stringify=z.getProperty=z.nil=z.strConcat=z.str=z._=void 0;var O=os(),Ue=zi(),Et=os();Object.defineProperty(z,"_",{enumerable:!0,get:function(){return Et._}});Object.defineProperty(z,"str",{enumerable:!0,get:function(){return Et.str}});Object.defineProperty(z,"strConcat",{enumerable:!0,get:function(){return Et.strConcat}});Object.defineProperty(z,"nil",{enumerable:!0,get:function(){return Et.nil}});Object.defineProperty(z,"getProperty",{enumerable:!0,get:function(){return Et.getProperty}});Object.defineProperty(z,"stringify",{enumerable:!0,get:function(){return Et.stringify}});Object.defineProperty(z,"regexpCode",{enumerable:!0,get:function(){return Et.regexpCode}});Object.defineProperty(z,"Name",{enumerable:!0,get:function(){return Et.Name}});var Do=zi();Object.defineProperty(z,"Scope",{enumerable:!0,get:function(){return Do.Scope}});Object.defineProperty(z,"ValueScope",{enumerable:!0,get:function(){return Do.ValueScope}});Object.defineProperty(z,"ValueScopeName",{enumerable:!0,get:function(){return Do.ValueScopeName}});Object.defineProperty(z,"varKinds",{enumerable:!0,get:function(){return Do.varKinds}});z.operators={GT:new O._Code(">"),GTE:new O._Code(">="),LT:new O._Code("<"),LTE:new O._Code("<="),EQ:new O._Code("==="),NEQ:new O._Code("!=="),NOT:new O._Code("!"),OR:new O._Code("||"),AND:new O._Code("&&"),ADD:new O._Code("+")};var tt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Fi=class extends tt{constructor(e,r,s){super(),this.varKind=e,this.name=r,this.rhs=s}render({es5:e,_n:r}){let s=e?Ue.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${s} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=cr(this.rhs,e,r)),this}get names(){return this.rhs instanceof O._CodeOrName?this.rhs.names:{}}},xo=class extends tt{constructor(e,r,s){super(),this.lhs=e,this.rhs=r,this.sideEffects=s}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof O.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=cr(this.rhs,e,r),this}get names(){let e=this.lhs instanceof O.Name?{}:{...this.lhs.names};return To(e,this.rhs)}},Ui=class extends xo{constructor(e,r,s,o){super(e,s,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},qi=class extends tt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Oi=class extends tt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Li=class extends tt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Gi=class extends tt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=cr(this.code,e,r),this}get names(){return this.code instanceof O._CodeOrName?this.code.names:{}}},ns=class extends tt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,s)=>r+s.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let s=e[r].optimizeNodes();Array.isArray(s)?e.splice(r,1,...s):s?e[r]=s:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:s}=this,o=s.length;for(;o--;){let n=s[o];n.optimizeNames(e,r)||(Iy(e,n.names),s.splice(o,1))}return s.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>jt(e,r.names),{})}},rt=class extends ns{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Hi=class extends ns{},ar=class extends rt{};ar.kind="else";var $t=class t extends rt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let s=r.optimizeNodes();r=this.else=Array.isArray(s)?new ar(s):s}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(yu(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var s;if(this.else=(s=this.else)===null||s===void 0?void 0:s.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=cr(this.condition,e,r),this}get names(){let e=super.names;return To(e,this.condition),this.else&&jt(e,this.else.names),e}};$t.kind="if";var Pt=class extends rt{};Pt.kind="for";var Yi=class extends Pt{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=cr(this.iteration,e,r),this}get names(){return jt(super.names,this.iteration.names)}},Ji=class extends Pt{constructor(e,r,s,o){super(),this.varKind=e,this.name=r,this.from=s,this.to=o}render(e){let r=e.es5?Ue.varKinds.var:this.varKind,{name:s,from:o,to:n}=this;return`for(${r} ${s}=${o}; ${s}<${n}; ${s}++)`+super.render(e)}get names(){let e=To(super.names,this.from);return To(e,this.to)}},Ro=class extends Pt{constructor(e,r,s,o){super(),this.loop=e,this.varKind=r,this.name=s,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=cr(this.iterable,e,r),this}get names(){return jt(super.names,this.iterable.names)}},is=class extends rt{constructor(e,r,s){super(),this.name=e,this.args=r,this.async=s}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};is.kind="func";var as=class extends ns{render(e){return"return "+super.render(e)}};as.kind="return";var Wi=class extends rt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var s,o;return super.optimizeNames(e,r),(s=this.catch)===null||s===void 0||s.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&jt(e,this.catch.names),this.finally&&jt(e,this.finally.names),e}},cs=class extends rt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};cs.kind="catch";var ls=class extends rt{render(e){return"finally"+super.render(e)}};ls.kind="finally";var Vi=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
5
|
-
`:""},this._extScope=e,this._scope=new Ue.Scope({parent:e}),this._nodes=[new Hi]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let s=this._extScope.value(e,r);return(this._values[s.prefix]||(this._values[s.prefix]=new Set)).add(s),s}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,s,o){let n=this._scope.toName(r);return s!==void 0&&o&&(this._constants[n.str]=s),this._leafNode(new Fi(e,n,s)),n}const(e,r,s){return this._def(Ue.varKinds.const,e,r,s)}let(e,r,s){return this._def(Ue.varKinds.let,e,r,s)}var(e,r,s){return this._def(Ue.varKinds.var,e,r,s)}assign(e,r,s){return this._leafNode(new xo(e,r,s))}add(e,r){return this._leafNode(new Ui(e,z.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==O.nil&&this._leafNode(new Gi(e)),this}object(...e){let r=["{"];for(let[s,o]of e)r.length>1&&r.push(","),r.push(s),(s!==o||this.opts.es5)&&(r.push(":"),(0,O.addCodeArg)(r,o));return r.push("}"),new O._Code(r)}if(e,r,s){if(this._blockNode(new $t(e)),r&&s)this.code(r).else().code(s).endIf();else if(r)this.code(r).endIf();else if(s)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new $t(e))}else(){return this._elseNode(new ar)}endIf(){return this._endBlockNode($t,ar)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Yi(e),r)}forRange(e,r,s,o,n=this.opts.es5?Ue.varKinds.var:Ue.varKinds.let){let i=this._scope.toName(e);return this._for(new Ji(n,i,r,s),()=>o(i))}forOf(e,r,s,o=Ue.varKinds.const){let n=this._scope.toName(e);if(this.opts.es5){let i=r instanceof O.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,O._)`${i}.length`,a=>{this.var(n,(0,O._)`${i}[${a}]`),s(n)})}return this._for(new Ro("of",o,n,r),()=>s(n))}forIn(e,r,s,o=this.opts.es5?Ue.varKinds.var:Ue.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,O._)`Object.keys(${r})`,s);let n=this._scope.toName(e);return this._for(new Ro("in",o,n,r),()=>s(n))}endFor(){return this._endBlockNode(Pt)}label(e){return this._leafNode(new qi(e))}break(e){return this._leafNode(new Oi(e))}return(e){let r=new as;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(as)}try(e,r,s){if(!r&&!s)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Wi;if(this._blockNode(o),this.code(e),r){let n=this.name("e");this._currNode=o.catch=new cs(n),r(n)}return s&&(this._currNode=o.finally=new ls,this.code(s)),this._endBlockNode(cs,ls)}throw(e){return this._leafNode(new Li(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let s=this._nodes.length-r;if(s<0||e!==void 0&&s!==e)throw new Error(`CodeGen: wrong number of nodes: ${s} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=O.nil,s,o){return this._blockNode(new is(e,r,s)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(is)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let s=this._currNode;if(s instanceof e||r&&s instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof $t))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};z.CodeGen=Vi;function jt(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function To(t,e){return e instanceof O._CodeOrName?jt(t,e.names):t}function cr(t,e,r){if(t instanceof O.Name)return s(t);if(!o(t))return t;return new O._Code(t._items.reduce((n,i)=>(i instanceof O.Name&&(i=s(i)),i instanceof O._Code?n.push(...i._items):n.push(i),n),[]));function s(n){let i=r[n.str];return i===void 0||e[n.str]!==1?n:(delete e[n.str],i)}function o(n){return n instanceof O._Code&&n._items.some(i=>i instanceof O.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function Iy(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function yu(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,O._)`!${Ki(t)}`}z.not=yu;var By=Eu(z.operators.AND);function Qy(...t){return t.reduce(By)}z.and=Qy;var _y=Eu(z.operators.OR);function ky(...t){return t.reduce(_y)}z.or=ky;function Eu(t){return(e,r)=>e===O.nil?r:r===O.nil?e:(0,O._)`${Ki(e)} ${t} ${Ki(r)}`}function Ki(t){return t instanceof O.Name?t:(0,O._)`(${t})`}});var L=B(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.checkStrictMode=U.getErrorPath=U.Type=U.useFunc=U.setEvaluated=U.evaluatedPropsToName=U.mergeEvaluated=U.eachItem=U.unescapeJsonPointer=U.escapeJsonPointer=U.escapeFragment=U.unescapeFragment=U.schemaRefOrVal=U.schemaHasRulesButRef=U.schemaHasRules=U.checkUnknownRules=U.alwaysValidSchema=U.toHash=void 0;var V=N(),Sy=os();function vy(t){let e={};for(let r of t)e[r]=!0;return e}U.toHash=vy;function My(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Iu(t,e),!Bu(e,t.self.RULES.all))}U.alwaysValidSchema=My;function Iu(t,e=t.schema){let{opts:r,self:s}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=s.RULES.keywords;for(let n in e)o[n]||ku(t,`unknown keyword: "${n}"`)}U.checkUnknownRules=Iu;function Bu(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}U.schemaHasRules=Bu;function by(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}U.schemaHasRulesButRef=by;function xy({topSchemaRef:t,schemaPath:e},r,s,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,V._)`${r}`}return(0,V._)`${t}${e}${(0,V.getProperty)(s)}`}U.schemaRefOrVal=xy;function Ry(t){return Qu(decodeURIComponent(t))}U.unescapeFragment=Ry;function Ty(t){return encodeURIComponent(Xi(t))}U.escapeFragment=Ty;function Xi(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}U.escapeJsonPointer=Xi;function Qu(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}U.unescapeJsonPointer=Qu;function Dy(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}U.eachItem=Dy;function wu({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:s}){return(o,n,i,a)=>{let c=i===void 0?n:i instanceof V.Name?(n instanceof V.Name?t(o,n,i):e(o,n,i),i):n instanceof V.Name?(e(o,i,n),n):r(n,i);return a===V.Name&&!(c instanceof V.Name)?s(o,c):c}}U.mergeEvaluated={props:wu({mergeNames:(t,e,r)=>t.if((0,V._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,V._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,V._)`${r} || {}`).code((0,V._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,V._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,V._)`${r} || {}`),ea(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:_u}),items:wu({mergeNames:(t,e,r)=>t.if((0,V._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,V._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,V._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,V._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function _u(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,V._)`{}`);return e!==void 0&&ea(t,r,e),r}U.evaluatedPropsToName=_u;function ea(t,e,r){Object.keys(r).forEach(s=>t.assign((0,V._)`${e}${(0,V.getProperty)(s)}`,!0))}U.setEvaluated=ea;var Cu={};function $y(t,e){return t.scopeValue("func",{ref:e,code:Cu[e.code]||(Cu[e.code]=new Sy._Code(e.code))})}U.useFunc=$y;var Zi;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Zi||(U.Type=Zi={}));function Py(t,e,r){if(t instanceof V.Name){let s=e===Zi.Num;return r?s?(0,V._)`"[" + ${t} + "]"`:(0,V._)`"['" + ${t} + "']"`:s?(0,V._)`"/" + ${t}`:(0,V._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,V.getProperty)(t).toString():"/"+Xi(t)}U.getErrorPath=Py;function ku(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}U.checkStrictMode=ku});var st=B(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});var ye=N(),jy={data:new ye.Name("data"),valCxt:new ye.Name("valCxt"),instancePath:new ye.Name("instancePath"),parentData:new ye.Name("parentData"),parentDataProperty:new ye.Name("parentDataProperty"),rootData:new ye.Name("rootData"),dynamicAnchors:new ye.Name("dynamicAnchors"),vErrors:new ye.Name("vErrors"),errors:new ye.Name("errors"),this:new ye.Name("this"),self:new ye.Name("self"),scope:new ye.Name("scope"),json:new ye.Name("json"),jsonPos:new ye.Name("jsonPos"),jsonLen:new ye.Name("jsonLen"),jsonPart:new ye.Name("jsonPart")};ta.default=jy});var us=B(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.extendErrors=Ee.resetErrorsCount=Ee.reportExtraError=Ee.reportError=Ee.keyword$DataError=Ee.keywordError=void 0;var G=N(),$o=L(),Ce=st();Ee.keywordError={message:({keyword:t})=>(0,G.str)`must pass "${t}" keyword validation`};Ee.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,G.str)`"${t}" keyword must be ${e} ($data)`:(0,G.str)`"${t}" keyword is invalid ($data)`};function Ny(t,e=Ee.keywordError,r,s){let{it:o}=t,{gen:n,compositeRule:i,allErrors:a}=o,c=Mu(t,e,r);s??(i||a)?Su(n,c):vu(o,(0,G._)`[${c}]`)}Ee.reportError=Ny;function zy(t,e=Ee.keywordError,r){let{it:s}=t,{gen:o,compositeRule:n,allErrors:i}=s,a=Mu(t,e,r);Su(o,a),n||i||vu(s,Ce.default.vErrors)}Ee.reportExtraError=zy;function Fy(t,e){t.assign(Ce.default.errors,e),t.if((0,G._)`${Ce.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,G._)`${Ce.default.vErrors}.length`,e),()=>t.assign(Ce.default.vErrors,null)))}Ee.resetErrorsCount=Fy;function Uy({gen:t,keyword:e,schemaValue:r,data:s,errsCount:o,it:n}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,Ce.default.errors,a=>{t.const(i,(0,G._)`${Ce.default.vErrors}[${a}]`),t.if((0,G._)`${i}.instancePath === undefined`,()=>t.assign((0,G._)`${i}.instancePath`,(0,G.strConcat)(Ce.default.instancePath,n.errorPath))),t.assign((0,G._)`${i}.schemaPath`,(0,G.str)`${n.errSchemaPath}/${e}`),n.opts.verbose&&(t.assign((0,G._)`${i}.schema`,r),t.assign((0,G._)`${i}.data`,s))})}Ee.extendErrors=Uy;function Su(t,e){let r=t.const("err",e);t.if((0,G._)`${Ce.default.vErrors} === null`,()=>t.assign(Ce.default.vErrors,(0,G._)`[${r}]`),(0,G._)`${Ce.default.vErrors}.push(${r})`),t.code((0,G._)`${Ce.default.errors}++`)}function vu(t,e){let{gen:r,validateName:s,schemaEnv:o}=t;o.$async?r.throw((0,G._)`new ${t.ValidationError}(${e})`):(r.assign((0,G._)`${s}.errors`,e),r.return(!1))}var Nt={keyword:new G.Name("keyword"),schemaPath:new G.Name("schemaPath"),params:new G.Name("params"),propertyName:new G.Name("propertyName"),message:new G.Name("message"),schema:new G.Name("schema"),parentSchema:new G.Name("parentSchema")};function Mu(t,e,r){let{createErrors:s}=t.it;return s===!1?(0,G._)`{}`:qy(t,e,r)}function qy(t,e,r={}){let{gen:s,it:o}=t,n=[Oy(o,r),Ly(t,r)];return Gy(t,e,n),s.object(...n)}function Oy({errorPath:t},{instancePath:e}){let r=e?(0,G.str)`${t}${(0,$o.getErrorPath)(e,$o.Type.Str)}`:t;return[Ce.default.instancePath,(0,G.strConcat)(Ce.default.instancePath,r)]}function Ly({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:s}){let o=s?e:(0,G.str)`${e}/${t}`;return r&&(o=(0,G.str)`${o}${(0,$o.getErrorPath)(r,$o.Type.Str)}`),[Nt.schemaPath,o]}function Gy(t,{params:e,message:r},s){let{keyword:o,data:n,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;s.push([Nt.keyword,o],[Nt.params,typeof e=="function"?e(t):e||(0,G._)`{}`]),c.messages&&s.push([Nt.message,typeof r=="function"?r(t):r]),c.verbose&&s.push([Nt.schema,i],[Nt.parentSchema,(0,G._)`${l}${d}`],[Ce.default.data,n]),u&&s.push([Nt.propertyName,u])}});var xu=B(lr=>{"use strict";Object.defineProperty(lr,"__esModule",{value:!0});lr.boolOrEmptySchema=lr.topBoolOrEmptySchema=void 0;var Hy=us(),Yy=N(),Jy=st(),Wy={message:"boolean schema is false"};function Vy(t){let{gen:e,schema:r,validateName:s}=t;r===!1?bu(t,!1):typeof r=="object"&&r.$async===!0?e.return(Jy.default.data):(e.assign((0,Yy._)`${s}.errors`,null),e.return(!0))}lr.topBoolOrEmptySchema=Vy;function Ky(t,e){let{gen:r,schema:s}=t;s===!1?(r.var(e,!1),bu(t)):r.var(e,!0)}lr.boolOrEmptySchema=Ky;function bu(t,e){let{gen:r,data:s}=t,o={gen:r,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,Hy.reportError)(o,Wy,void 0,e)}});var ra=B(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.getRules=ur.isJSONType=void 0;var Zy=["string","number","integer","boolean","null","object","array"],Xy=new Set(Zy);function eE(t){return typeof t=="string"&&Xy.has(t)}ur.isJSONType=eE;function tE(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}ur.getRules=tE});var sa=B(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.shouldUseRule=wt.shouldUseGroup=wt.schemaHasRulesForType=void 0;function rE({schema:t,self:e},r){let s=e.RULES.types[r];return s&&s!==!0&&Ru(t,s)}wt.schemaHasRulesForType=rE;function Ru(t,e){return e.rules.some(r=>Tu(t,r))}wt.shouldUseGroup=Ru;function Tu(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(s=>t[s]!==void 0))}wt.shouldUseRule=Tu});var ds=B(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.reportTypeError=we.checkDataTypes=we.checkDataType=we.coerceAndCheckDataType=we.getJSONTypes=we.getSchemaTypes=we.DataType=void 0;var sE=ra(),oE=sa(),nE=us(),j=N(),Du=L(),dr;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(dr||(we.DataType=dr={}));function iE(t){let e=$u(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}we.getSchemaTypes=iE;function $u(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(sE.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}we.getJSONTypes=$u;function aE(t,e){let{gen:r,data:s,opts:o}=t,n=cE(e,o.coerceTypes),i=e.length>0&&!(n.length===0&&e.length===1&&(0,oE.schemaHasRulesForType)(t,e[0]));if(i){let a=na(e,s,o.strictNumbers,dr.Wrong);r.if(a,()=>{n.length?lE(t,e,n):ia(t)})}return i}we.coerceAndCheckDataType=aE;var Pu=new Set(["string","number","integer","boolean","null"]);function cE(t,e){return e?t.filter(r=>Pu.has(r)||e==="array"&&r==="array"):[]}function lE(t,e,r){let{gen:s,data:o,opts:n}=t,i=s.let("dataType",(0,j._)`typeof ${o}`),a=s.let("coerced",(0,j._)`undefined`);n.coerceTypes==="array"&&s.if((0,j._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>s.assign(o,(0,j._)`${o}[0]`).assign(i,(0,j._)`typeof ${o}`).if(na(e,o,n.strictNumbers),()=>s.assign(a,o))),s.if((0,j._)`${a} !== undefined`);for(let u of r)(Pu.has(u)||u==="array"&&n.coerceTypes==="array")&&c(u);s.else(),ia(t),s.endIf(),s.if((0,j._)`${a} !== undefined`,()=>{s.assign(o,a),uE(t,a)});function c(u){switch(u){case"string":s.elseIf((0,j._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,j._)`"" + ${o}`).elseIf((0,j._)`${o} === null`).assign(a,(0,j._)`""`);return;case"number":s.elseIf((0,j._)`${i} == "boolean" || ${o} === null
|
|
4
|
+
import{b as Gl,h as po}from"./chunk-LC766IV2.js";import{a as tr}from"./chunk-HXLSOWKW.js";import{a as Ue,b as Rl,c as lo,d as uo}from"./chunk-4XCKINK4.js";import{e as rr}from"./chunk-RKJQNZWW.js";import{a as Ll}from"./chunk-YOZTZPFE.js";import{a as ft}from"./chunk-7MHXMDYC.js";import{A as Ul,B as Fl,C as D,D as y,I as R,K as oi,L as Ol,M as ni,O as U,Q as bt,R as Hr,S as k,T as Ao,a as xl,d as Dl,e as Se,f as Tl,g as $l,h as d,i as Pl,j as H,k as W,l as jl,m as Nl,n as ne,o as _,p as S,q as ce,r as ee,s as ti,t as ri,u as K,v as Re,w as M,x as re,y as zl,z as si}from"./chunk-RTOI4JAC.js";import{a as mo,b as Hl,c as Yl,f as Jl}from"./chunk-A3NIT2ZF.js";import{a as ql}from"./chunk-E55KH72M.js";import{a as mt,b as Q,d as co}from"./chunk-X3UA5OZL.js";var os=Q(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.regexpCode=Y.getEsmExportName=Y.getProperty=Y.safeStringify=Y.stringify=Y.strConcat=Y.addCodeArg=Y.str=Y._=Y.nil=Y._Code=Y.Name=Y.IDENTIFIER=Y._CodeOrName=void 0;var rs=class{};Y._CodeOrName=rs;Y.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Tt=class extends rs{constructor(e){if(super(),!Y.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Y.Name=Tt;var Pe=class extends rs{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,s)=>`${r}${s}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,s)=>(s instanceof Tt&&(r[s.str]=(r[s.str]||0)+1),r),{})}};Y._Code=Pe;Y.nil=new Pe("");function gu(t,...e){let r=[t[0]],s=0;for(;s<e.length;)Pi(r,e[s]),r.push(t[++s]);return new Pe(r)}Y._=gu;var $i=new Pe("+");function hu(t,...e){let r=[ss(t[0])],s=0;for(;s<e.length;)r.push($i),Pi(r,e[s]),r.push($i,ss(t[++s]));return dE(r),new Pe(r)}Y.str=hu;function Pi(t,e){e instanceof Pe?t.push(...e._items):e instanceof Tt?t.push(e):t.push(fE(e))}Y.addCodeArg=Pi;function dE(t){let e=1;for(;e<t.length-1;){if(t[e]===$i){let r=pE(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function pE(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Tt||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Tt))return`"${t}${e.slice(1)}`}function mE(t,e){return e.emptyStr()?t:t.emptyStr()?e:hu`${t}${e}`}Y.strConcat=mE;function fE(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:ss(Array.isArray(t)?t.join(","):t)}function gE(t){return new Pe(ss(t))}Y.stringify=gE;function ss(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Y.safeStringify=ss;function hE(t){return typeof t=="string"&&Y.IDENTIFIER.test(t)?new Pe(`.${t}`):gu`[${t}]`}Y.getProperty=hE;function EE(t){if(typeof t=="string"&&Y.IDENTIFIER.test(t))return new Pe(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}Y.getEsmExportName=EE;function yE(t){return new Pe(t.toString())}Y.regexpCode=yE});var zi=Q(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.ValueScope=Me.ValueScopeName=Me.Scope=Me.varKinds=Me.UsedValueState=void 0;var ke=os(),ji=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Mo;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Mo||(Me.UsedValueState=Mo={}));Me.varKinds={const:new ke.Name("const"),let:new ke.Name("let"),var:new ke.Name("var")};var vo=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof ke.Name?e:this.name(e)}name(e){return new ke.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,s;if(!((s=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||s===void 0)&&s.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Me.Scope=vo;var bo=class extends ke.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:s}){this.value=e,this.scopePath=(0,ke._)`.${new ke.Name(r)}[${s}]`}};Me.ValueScopeName=bo;var wE=(0,ke._)`\n`,Ni=class extends vo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?wE:ke.nil}}get(){return this._scope}name(e){return new bo(e,this._newName(e))}value(e,r){var s;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:n}=o,i=(s=r.key)!==null&&s!==void 0?s:r.ref,a=this._values[n];if(a){let l=a.get(i);if(l)return l}else a=this._values[n]=new Map;a.set(i,o);let c=this._scope[n]||(this._scope[n]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:n,itemIndex:u}),o}getValue(e,r){let s=this._values[e];if(s)return s.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,s=>{if(s.scopePath===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return(0,ke._)`${e}${s.scopePath}`})}scopeCode(e=this._values,r,s){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,s)}_reduceValues(e,r,s={},o){let n=ke.nil;for(let i in e){let a=e[i];if(!a)continue;let c=s[i]=s[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Mo.Started);let l=r(u);if(l){let A=this.opts.es5?Me.varKinds.var:Me.varKinds.const;n=(0,ke._)`${n}${A} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))n=(0,ke._)`${n}${l}${this.opts._n}`;else throw new ji(u);c.set(u,Mo.Completed)})}return n}};Me.ValueScope=Ni});var N=Q(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});z.or=z.and=z.not=z.CodeGen=z.operators=z.varKinds=z.ValueScopeName=z.ValueScope=z.Scope=z.Name=z.regexpCode=z.stringify=z.getProperty=z.nil=z.strConcat=z.str=z._=void 0;var L=os(),Fe=zi(),yt=os();Object.defineProperty(z,"_",{enumerable:!0,get:function(){return yt._}});Object.defineProperty(z,"str",{enumerable:!0,get:function(){return yt.str}});Object.defineProperty(z,"strConcat",{enumerable:!0,get:function(){return yt.strConcat}});Object.defineProperty(z,"nil",{enumerable:!0,get:function(){return yt.nil}});Object.defineProperty(z,"getProperty",{enumerable:!0,get:function(){return yt.getProperty}});Object.defineProperty(z,"stringify",{enumerable:!0,get:function(){return yt.stringify}});Object.defineProperty(z,"regexpCode",{enumerable:!0,get:function(){return yt.regexpCode}});Object.defineProperty(z,"Name",{enumerable:!0,get:function(){return yt.Name}});var To=zi();Object.defineProperty(z,"Scope",{enumerable:!0,get:function(){return To.Scope}});Object.defineProperty(z,"ValueScope",{enumerable:!0,get:function(){return To.ValueScope}});Object.defineProperty(z,"ValueScopeName",{enumerable:!0,get:function(){return To.ValueScopeName}});Object.defineProperty(z,"varKinds",{enumerable:!0,get:function(){return To.varKinds}});z.operators={GT:new L._Code(">"),GTE:new L._Code(">="),LT:new L._Code("<"),LTE:new L._Code("<="),EQ:new L._Code("==="),NEQ:new L._Code("!=="),NOT:new L._Code("!"),OR:new L._Code("||"),AND:new L._Code("&&"),ADD:new L._Code("+")};var tt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Ui=class extends tt{constructor(e,r,s){super(),this.varKind=e,this.name=r,this.rhs=s}render({es5:e,_n:r}){let s=e?Fe.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${s} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=cr(this.rhs,e,r)),this}get names(){return this.rhs instanceof L._CodeOrName?this.rhs.names:{}}},xo=class extends tt{constructor(e,r,s){super(),this.lhs=e,this.rhs=r,this.sideEffects=s}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof L.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=cr(this.rhs,e,r),this}get names(){let e=this.lhs instanceof L.Name?{}:{...this.lhs.names};return Do(e,this.rhs)}},Fi=class extends xo{constructor(e,r,s,o){super(e,s,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Oi=class extends tt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Li=class extends tt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},qi=class extends tt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Gi=class extends tt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=cr(this.code,e,r),this}get names(){return this.code instanceof L._CodeOrName?this.code.names:{}}},ns=class extends tt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,s)=>r+s.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let s=e[r].optimizeNodes();Array.isArray(s)?e.splice(r,1,...s):s?e[r]=s:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:s}=this,o=s.length;for(;o--;){let n=s[o];n.optimizeNames(e,r)||(CE(e,n.names),s.splice(o,1))}return s.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>jt(e,r.names),{})}},rt=class extends ns{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Hi=class extends ns{},ar=class extends rt{};ar.kind="else";var $t=class t extends rt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let s=r.optimizeNodes();r=this.else=Array.isArray(s)?new ar(s):s}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Eu(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var s;if(this.else=(s=this.else)===null||s===void 0?void 0:s.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=cr(this.condition,e,r),this}get names(){let e=super.names;return Do(e,this.condition),this.else&&jt(e,this.else.names),e}};$t.kind="if";var Pt=class extends rt{};Pt.kind="for";var Yi=class extends Pt{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=cr(this.iteration,e,r),this}get names(){return jt(super.names,this.iteration.names)}},Ji=class extends Pt{constructor(e,r,s,o){super(),this.varKind=e,this.name=r,this.from=s,this.to=o}render(e){let r=e.es5?Fe.varKinds.var:this.varKind,{name:s,from:o,to:n}=this;return`for(${r} ${s}=${o}; ${s}<${n}; ${s}++)`+super.render(e)}get names(){let e=Do(super.names,this.from);return Do(e,this.to)}},Ro=class extends Pt{constructor(e,r,s,o){super(),this.loop=e,this.varKind=r,this.name=s,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=cr(this.iterable,e,r),this}get names(){return jt(super.names,this.iterable.names)}},is=class extends rt{constructor(e,r,s){super(),this.name=e,this.args=r,this.async=s}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};is.kind="func";var as=class extends ns{render(e){return"return "+super.render(e)}};as.kind="return";var Wi=class extends rt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var s,o;return super.optimizeNames(e,r),(s=this.catch)===null||s===void 0||s.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&jt(e,this.catch.names),this.finally&&jt(e,this.finally.names),e}},cs=class extends rt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};cs.kind="catch";var ls=class extends rt{render(e){return"finally"+super.render(e)}};ls.kind="finally";var Vi=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
5
|
+
`:""},this._extScope=e,this._scope=new Fe.Scope({parent:e}),this._nodes=[new Hi]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let s=this._extScope.value(e,r);return(this._values[s.prefix]||(this._values[s.prefix]=new Set)).add(s),s}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,s,o){let n=this._scope.toName(r);return s!==void 0&&o&&(this._constants[n.str]=s),this._leafNode(new Ui(e,n,s)),n}const(e,r,s){return this._def(Fe.varKinds.const,e,r,s)}let(e,r,s){return this._def(Fe.varKinds.let,e,r,s)}var(e,r,s){return this._def(Fe.varKinds.var,e,r,s)}assign(e,r,s){return this._leafNode(new xo(e,r,s))}add(e,r){return this._leafNode(new Fi(e,z.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==L.nil&&this._leafNode(new Gi(e)),this}object(...e){let r=["{"];for(let[s,o]of e)r.length>1&&r.push(","),r.push(s),(s!==o||this.opts.es5)&&(r.push(":"),(0,L.addCodeArg)(r,o));return r.push("}"),new L._Code(r)}if(e,r,s){if(this._blockNode(new $t(e)),r&&s)this.code(r).else().code(s).endIf();else if(r)this.code(r).endIf();else if(s)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new $t(e))}else(){return this._elseNode(new ar)}endIf(){return this._endBlockNode($t,ar)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Yi(e),r)}forRange(e,r,s,o,n=this.opts.es5?Fe.varKinds.var:Fe.varKinds.let){let i=this._scope.toName(e);return this._for(new Ji(n,i,r,s),()=>o(i))}forOf(e,r,s,o=Fe.varKinds.const){let n=this._scope.toName(e);if(this.opts.es5){let i=r instanceof L.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,L._)`${i}.length`,a=>{this.var(n,(0,L._)`${i}[${a}]`),s(n)})}return this._for(new Ro("of",o,n,r),()=>s(n))}forIn(e,r,s,o=this.opts.es5?Fe.varKinds.var:Fe.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,L._)`Object.keys(${r})`,s);let n=this._scope.toName(e);return this._for(new Ro("in",o,n,r),()=>s(n))}endFor(){return this._endBlockNode(Pt)}label(e){return this._leafNode(new Oi(e))}break(e){return this._leafNode(new Li(e))}return(e){let r=new as;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(as)}try(e,r,s){if(!r&&!s)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Wi;if(this._blockNode(o),this.code(e),r){let n=this.name("e");this._currNode=o.catch=new cs(n),r(n)}return s&&(this._currNode=o.finally=new ls,this.code(s)),this._endBlockNode(cs,ls)}throw(e){return this._leafNode(new qi(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let s=this._nodes.length-r;if(s<0||e!==void 0&&s!==e)throw new Error(`CodeGen: wrong number of nodes: ${s} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=L.nil,s,o){return this._blockNode(new is(e,r,s)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(is)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let s=this._currNode;if(s instanceof e||r&&s instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof $t))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};z.CodeGen=Vi;function jt(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Do(t,e){return e instanceof L._CodeOrName?jt(t,e.names):t}function cr(t,e,r){if(t instanceof L.Name)return s(t);if(!o(t))return t;return new L._Code(t._items.reduce((n,i)=>(i instanceof L.Name&&(i=s(i)),i instanceof L._Code?n.push(...i._items):n.push(i),n),[]));function s(n){let i=r[n.str];return i===void 0||e[n.str]!==1?n:(delete e[n.str],i)}function o(n){return n instanceof L._Code&&n._items.some(i=>i instanceof L.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function CE(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Eu(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,L._)`!${Ki(t)}`}z.not=Eu;var IE=yu(z.operators.AND);function BE(...t){return t.reduce(IE)}z.and=BE;var QE=yu(z.operators.OR);function _E(...t){return t.reduce(QE)}z.or=_E;function yu(t){return(e,r)=>e===L.nil?r:r===L.nil?e:(0,L._)`${Ki(e)} ${t} ${Ki(r)}`}function Ki(t){return t instanceof L.Name?t:(0,L._)`(${t})`}});var q=Q(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.checkStrictMode=F.getErrorPath=F.Type=F.useFunc=F.setEvaluated=F.evaluatedPropsToName=F.mergeEvaluated=F.eachItem=F.unescapeJsonPointer=F.escapeJsonPointer=F.escapeFragment=F.unescapeFragment=F.schemaRefOrVal=F.schemaHasRulesButRef=F.schemaHasRules=F.checkUnknownRules=F.alwaysValidSchema=F.toHash=void 0;var V=N(),SE=os();function kE(t){let e={};for(let r of t)e[r]=!0;return e}F.toHash=kE;function ME(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Iu(t,e),!Bu(e,t.self.RULES.all))}F.alwaysValidSchema=ME;function Iu(t,e=t.schema){let{opts:r,self:s}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=s.RULES.keywords;for(let n in e)o[n]||Su(t,`unknown keyword: "${n}"`)}F.checkUnknownRules=Iu;function Bu(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}F.schemaHasRules=Bu;function vE(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}F.schemaHasRulesButRef=vE;function bE({topSchemaRef:t,schemaPath:e},r,s,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,V._)`${r}`}return(0,V._)`${t}${e}${(0,V.getProperty)(s)}`}F.schemaRefOrVal=bE;function xE(t){return Qu(decodeURIComponent(t))}F.unescapeFragment=xE;function RE(t){return encodeURIComponent(Xi(t))}F.escapeFragment=RE;function Xi(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}F.escapeJsonPointer=Xi;function Qu(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}F.unescapeJsonPointer=Qu;function DE(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}F.eachItem=DE;function wu({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:s}){return(o,n,i,a)=>{let c=i===void 0?n:i instanceof V.Name?(n instanceof V.Name?t(o,n,i):e(o,n,i),i):n instanceof V.Name?(e(o,i,n),n):r(n,i);return a===V.Name&&!(c instanceof V.Name)?s(o,c):c}}F.mergeEvaluated={props:wu({mergeNames:(t,e,r)=>t.if((0,V._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,V._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,V._)`${r} || {}`).code((0,V._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,V._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,V._)`${r} || {}`),ea(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:_u}),items:wu({mergeNames:(t,e,r)=>t.if((0,V._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,V._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,V._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,V._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function _u(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,V._)`{}`);return e!==void 0&&ea(t,r,e),r}F.evaluatedPropsToName=_u;function ea(t,e,r){Object.keys(r).forEach(s=>t.assign((0,V._)`${e}${(0,V.getProperty)(s)}`,!0))}F.setEvaluated=ea;var Cu={};function TE(t,e){return t.scopeValue("func",{ref:e,code:Cu[e.code]||(Cu[e.code]=new SE._Code(e.code))})}F.useFunc=TE;var Zi;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Zi||(F.Type=Zi={}));function $E(t,e,r){if(t instanceof V.Name){let s=e===Zi.Num;return r?s?(0,V._)`"[" + ${t} + "]"`:(0,V._)`"['" + ${t} + "']"`:s?(0,V._)`"/" + ${t}`:(0,V._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,V.getProperty)(t).toString():"/"+Xi(t)}F.getErrorPath=$E;function Su(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}F.checkStrictMode=Su});var st=Q(ta=>{"use strict";Object.defineProperty(ta,"__esModule",{value:!0});var Ee=N(),PE={data:new Ee.Name("data"),valCxt:new Ee.Name("valCxt"),instancePath:new Ee.Name("instancePath"),parentData:new Ee.Name("parentData"),parentDataProperty:new Ee.Name("parentDataProperty"),rootData:new Ee.Name("rootData"),dynamicAnchors:new Ee.Name("dynamicAnchors"),vErrors:new Ee.Name("vErrors"),errors:new Ee.Name("errors"),this:new Ee.Name("this"),self:new Ee.Name("self"),scope:new Ee.Name("scope"),json:new Ee.Name("json"),jsonPos:new Ee.Name("jsonPos"),jsonLen:new Ee.Name("jsonLen"),jsonPart:new Ee.Name("jsonPart")};ta.default=PE});var us=Q(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.extendErrors=ye.resetErrorsCount=ye.reportExtraError=ye.reportError=ye.keyword$DataError=ye.keywordError=void 0;var G=N(),$o=q(),Ce=st();ye.keywordError={message:({keyword:t})=>(0,G.str)`must pass "${t}" keyword validation`};ye.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,G.str)`"${t}" keyword must be ${e} ($data)`:(0,G.str)`"${t}" keyword is invalid ($data)`};function jE(t,e=ye.keywordError,r,s){let{it:o}=t,{gen:n,compositeRule:i,allErrors:a}=o,c=vu(t,e,r);s??(i||a)?ku(n,c):Mu(o,(0,G._)`[${c}]`)}ye.reportError=jE;function NE(t,e=ye.keywordError,r){let{it:s}=t,{gen:o,compositeRule:n,allErrors:i}=s,a=vu(t,e,r);ku(o,a),n||i||Mu(s,Ce.default.vErrors)}ye.reportExtraError=NE;function zE(t,e){t.assign(Ce.default.errors,e),t.if((0,G._)`${Ce.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,G._)`${Ce.default.vErrors}.length`,e),()=>t.assign(Ce.default.vErrors,null)))}ye.resetErrorsCount=zE;function UE({gen:t,keyword:e,schemaValue:r,data:s,errsCount:o,it:n}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,Ce.default.errors,a=>{t.const(i,(0,G._)`${Ce.default.vErrors}[${a}]`),t.if((0,G._)`${i}.instancePath === undefined`,()=>t.assign((0,G._)`${i}.instancePath`,(0,G.strConcat)(Ce.default.instancePath,n.errorPath))),t.assign((0,G._)`${i}.schemaPath`,(0,G.str)`${n.errSchemaPath}/${e}`),n.opts.verbose&&(t.assign((0,G._)`${i}.schema`,r),t.assign((0,G._)`${i}.data`,s))})}ye.extendErrors=UE;function ku(t,e){let r=t.const("err",e);t.if((0,G._)`${Ce.default.vErrors} === null`,()=>t.assign(Ce.default.vErrors,(0,G._)`[${r}]`),(0,G._)`${Ce.default.vErrors}.push(${r})`),t.code((0,G._)`${Ce.default.errors}++`)}function Mu(t,e){let{gen:r,validateName:s,schemaEnv:o}=t;o.$async?r.throw((0,G._)`new ${t.ValidationError}(${e})`):(r.assign((0,G._)`${s}.errors`,e),r.return(!1))}var Nt={keyword:new G.Name("keyword"),schemaPath:new G.Name("schemaPath"),params:new G.Name("params"),propertyName:new G.Name("propertyName"),message:new G.Name("message"),schema:new G.Name("schema"),parentSchema:new G.Name("parentSchema")};function vu(t,e,r){let{createErrors:s}=t.it;return s===!1?(0,G._)`{}`:FE(t,e,r)}function FE(t,e,r={}){let{gen:s,it:o}=t,n=[OE(o,r),LE(t,r)];return qE(t,e,n),s.object(...n)}function OE({errorPath:t},{instancePath:e}){let r=e?(0,G.str)`${t}${(0,$o.getErrorPath)(e,$o.Type.Str)}`:t;return[Ce.default.instancePath,(0,G.strConcat)(Ce.default.instancePath,r)]}function LE({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:s}){let o=s?e:(0,G.str)`${e}/${t}`;return r&&(o=(0,G.str)`${o}${(0,$o.getErrorPath)(r,$o.Type.Str)}`),[Nt.schemaPath,o]}function qE(t,{params:e,message:r},s){let{keyword:o,data:n,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:A}=a;s.push([Nt.keyword,o],[Nt.params,typeof e=="function"?e(t):e||(0,G._)`{}`]),c.messages&&s.push([Nt.message,typeof r=="function"?r(t):r]),c.verbose&&s.push([Nt.schema,i],[Nt.parentSchema,(0,G._)`${l}${A}`],[Ce.default.data,n]),u&&s.push([Nt.propertyName,u])}});var xu=Q(lr=>{"use strict";Object.defineProperty(lr,"__esModule",{value:!0});lr.boolOrEmptySchema=lr.topBoolOrEmptySchema=void 0;var GE=us(),HE=N(),YE=st(),JE={message:"boolean schema is false"};function WE(t){let{gen:e,schema:r,validateName:s}=t;r===!1?bu(t,!1):typeof r=="object"&&r.$async===!0?e.return(YE.default.data):(e.assign((0,HE._)`${s}.errors`,null),e.return(!0))}lr.topBoolOrEmptySchema=WE;function VE(t,e){let{gen:r,schema:s}=t;s===!1?(r.var(e,!1),bu(t)):r.var(e,!0)}lr.boolOrEmptySchema=VE;function bu(t,e){let{gen:r,data:s}=t,o={gen:r,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,GE.reportError)(o,JE,void 0,e)}});var ra=Q(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.getRules=ur.isJSONType=void 0;var KE=["string","number","integer","boolean","null","object","array"],ZE=new Set(KE);function XE(t){return typeof t=="string"&&ZE.has(t)}ur.isJSONType=XE;function ey(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}ur.getRules=ey});var sa=Q(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.shouldUseRule=wt.shouldUseGroup=wt.schemaHasRulesForType=void 0;function ty({schema:t,self:e},r){let s=e.RULES.types[r];return s&&s!==!0&&Ru(t,s)}wt.schemaHasRulesForType=ty;function Ru(t,e){return e.rules.some(r=>Du(t,r))}wt.shouldUseGroup=Ru;function Du(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(s=>t[s]!==void 0))}wt.shouldUseRule=Du});var As=Q(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.reportTypeError=we.checkDataTypes=we.checkDataType=we.coerceAndCheckDataType=we.getJSONTypes=we.getSchemaTypes=we.DataType=void 0;var ry=ra(),sy=sa(),oy=us(),j=N(),Tu=q(),Ar;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Ar||(we.DataType=Ar={}));function ny(t){let e=$u(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}we.getSchemaTypes=ny;function $u(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(ry.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}we.getJSONTypes=$u;function iy(t,e){let{gen:r,data:s,opts:o}=t,n=ay(e,o.coerceTypes),i=e.length>0&&!(n.length===0&&e.length===1&&(0,sy.schemaHasRulesForType)(t,e[0]));if(i){let a=na(e,s,o.strictNumbers,Ar.Wrong);r.if(a,()=>{n.length?cy(t,e,n):ia(t)})}return i}we.coerceAndCheckDataType=iy;var Pu=new Set(["string","number","integer","boolean","null"]);function ay(t,e){return e?t.filter(r=>Pu.has(r)||e==="array"&&r==="array"):[]}function cy(t,e,r){let{gen:s,data:o,opts:n}=t,i=s.let("dataType",(0,j._)`typeof ${o}`),a=s.let("coerced",(0,j._)`undefined`);n.coerceTypes==="array"&&s.if((0,j._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>s.assign(o,(0,j._)`${o}[0]`).assign(i,(0,j._)`typeof ${o}`).if(na(e,o,n.strictNumbers),()=>s.assign(a,o))),s.if((0,j._)`${a} !== undefined`);for(let u of r)(Pu.has(u)||u==="array"&&n.coerceTypes==="array")&&c(u);s.else(),ia(t),s.endIf(),s.if((0,j._)`${a} !== undefined`,()=>{s.assign(o,a),ly(t,a)});function c(u){switch(u){case"string":s.elseIf((0,j._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,j._)`"" + ${o}`).elseIf((0,j._)`${o} === null`).assign(a,(0,j._)`""`);return;case"number":s.elseIf((0,j._)`${i} == "boolean" || ${o} === null
|
|
6
6
|
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,j._)`+${o}`);return;case"integer":s.elseIf((0,j._)`${i} === "boolean" || ${o} === null
|
|
7
7
|
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,j._)`+${o}`);return;case"boolean":s.elseIf((0,j._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,j._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":s.elseIf((0,j._)`${o} === "" || ${o} === 0 || ${o} === false`),s.assign(a,null);return;case"array":s.elseIf((0,j._)`${i} === "string" || ${i} === "number"
|
|
8
|
-
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,j._)`[${o}]`)}}}function uE({gen:t,parentData:e,parentDataProperty:r},s){t.if((0,j._)`${e} !== undefined`,()=>t.assign((0,j._)`${e}[${r}]`,s))}function oa(t,e,r,s=dr.Correct){let o=s===dr.Correct?j.operators.EQ:j.operators.NEQ,n;switch(t){case"null":return(0,j._)`${e} ${o} null`;case"array":n=(0,j._)`Array.isArray(${e})`;break;case"object":n=(0,j._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":n=i((0,j._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":n=i();break;default:return(0,j._)`typeof ${e} ${o} ${t}`}return s===dr.Correct?n:(0,j.not)(n);function i(a=j.nil){return(0,j.and)((0,j._)`typeof ${e} == "number"`,a,r?(0,j._)`isFinite(${e})`:j.nil)}}we.checkDataType=oa;function na(t,e,r,s){if(t.length===1)return oa(t[0],e,r,s);let o,n=(0,Du.toHash)(t);if(n.array&&n.object){let i=(0,j._)`typeof ${e} != "object"`;o=n.null?i:(0,j._)`!${e} || ${i}`,delete n.null,delete n.array,delete n.object}else o=j.nil;n.number&&delete n.integer;for(let i in n)o=(0,j.and)(o,oa(i,e,r,s));return o}we.checkDataTypes=na;var dE={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,j._)`{type: ${t}}`:(0,j._)`{type: ${e}}`};function ia(t){let e=AE(t);(0,nE.reportError)(e,dE)}we.reportTypeError=ia;function AE(t){let{gen:e,data:r,schema:s}=t,o=(0,Du.schemaRefOrVal)(t,s,"type");return{gen:e,keyword:"type",data:r,schema:s.type,schemaCode:o,schemaValue:o,parentSchema:s,params:{},it:t}}});var Nu=B(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.assignDefaults=void 0;var Ar=N(),pE=L();function mE(t,e){let{properties:r,items:s}=t.schema;if(e==="object"&&r)for(let o in r)ju(t,o,r[o].default);else e==="array"&&Array.isArray(s)&&s.forEach((o,n)=>ju(t,n,o.default))}Po.assignDefaults=mE;function ju(t,e,r){let{gen:s,compositeRule:o,data:n,opts:i}=t;if(r===void 0)return;let a=(0,Ar._)`${n}${(0,Ar.getProperty)(e)}`;if(o){(0,pE.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,Ar._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Ar._)`${c} || ${a} === null || ${a} === ""`),s.if(c,(0,Ar._)`${a} = ${(0,Ar.stringify)(r)}`)}});var je=B(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.validateUnion=J.validateArray=J.usePattern=J.callValidateCode=J.schemaProperties=J.allSchemaProperties=J.noPropertyInData=J.propertyInData=J.isOwnProperty=J.hasPropFunc=J.reportMissingProp=J.checkMissingProp=J.checkReportMissingProp=void 0;var Z=N(),aa=L(),Ct=st(),fE=L();function gE(t,e){let{gen:r,data:s,it:o}=t;r.if(la(r,s,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,Z._)`${e}`},!0),t.error()})}J.checkReportMissingProp=gE;function hE({gen:t,data:e,it:{opts:r}},s,o){return(0,Z.or)(...s.map(n=>(0,Z.and)(la(t,e,n,r.ownProperties),(0,Z._)`${o} = ${n}`)))}J.checkMissingProp=hE;function yE(t,e){t.setParams({missingProperty:e},!0),t.error()}J.reportMissingProp=yE;function zu(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Z._)`Object.prototype.hasOwnProperty`})}J.hasPropFunc=zu;function ca(t,e,r){return(0,Z._)`${zu(t)}.call(${e}, ${r})`}J.isOwnProperty=ca;function EE(t,e,r,s){let o=(0,Z._)`${e}${(0,Z.getProperty)(r)} !== undefined`;return s?(0,Z._)`${o} && ${ca(t,e,r)}`:o}J.propertyInData=EE;function la(t,e,r,s){let o=(0,Z._)`${e}${(0,Z.getProperty)(r)} === undefined`;return s?(0,Z.or)(o,(0,Z.not)(ca(t,e,r))):o}J.noPropertyInData=la;function Fu(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}J.allSchemaProperties=Fu;function wE(t,e){return Fu(e).filter(r=>!(0,aa.alwaysValidSchema)(t,e[r]))}J.schemaProperties=wE;function CE({schemaCode:t,data:e,it:{gen:r,topSchemaRef:s,schemaPath:o,errorPath:n},it:i},a,c,u){let l=u?(0,Z._)`${t}, ${e}, ${s}${o}`:e,d=[[Ct.default.instancePath,(0,Z.strConcat)(Ct.default.instancePath,n)],[Ct.default.parentData,i.parentData],[Ct.default.parentDataProperty,i.parentDataProperty],[Ct.default.rootData,Ct.default.rootData]];i.opts.dynamicRef&&d.push([Ct.default.dynamicAnchors,Ct.default.dynamicAnchors]);let A=(0,Z._)`${l}, ${r.object(...d)}`;return c!==Z.nil?(0,Z._)`${a}.call(${c}, ${A})`:(0,Z._)`${a}(${A})`}J.callValidateCode=CE;var IE=(0,Z._)`new RegExp`;function BE({gen:t,it:{opts:e}},r){let s=e.unicodeRegExp?"u":"",{regExp:o}=e.code,n=o(r,s);return t.scopeValue("pattern",{key:n.toString(),ref:n,code:(0,Z._)`${o.code==="new RegExp"?IE:(0,fE.useFunc)(t,o)}(${r}, ${s})`})}J.usePattern=BE;function QE(t){let{gen:e,data:r,keyword:s,it:o}=t,n=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(n,!0),i(()=>e.break()),n;function i(a){let c=e.const("len",(0,Z._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:s,dataProp:u,dataPropType:aa.Type.Num},n),e.if((0,Z.not)(n),a)})}}J.validateArray=QE;function _E(t){let{gen:e,schema:r,keyword:s,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,aa.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:s,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,Z._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,Z.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}J.validateUnion=_E});var Ou=B(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.validateKeywordUsage=We.validSchemaType=We.funcKeywordCode=We.macroKeywordCode=void 0;var Ie=N(),zt=st(),kE=je(),SE=us();function vE(t,e){let{gen:r,keyword:s,schema:o,parentSchema:n,it:i}=t,a=e.macro.call(i.self,o,n,i),c=qu(r,s,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:Ie.nil,errSchemaPath:`${i.errSchemaPath}/${s}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}We.macroKeywordCode=vE;function ME(t,e){var r;let{gen:s,keyword:o,schema:n,parentSchema:i,$data:a,it:c}=t;xE(c,e);let u=!a&&e.compile?e.compile.call(c.self,n,i,c):e.validate,l=qu(s,o,u),d=s.let("valid");t.block$data(d,A),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function A(){if(e.errors===!1)f(),e.modifying&&Uu(t),h(()=>t.error());else{let y=e.async?m():g();e.modifying&&Uu(t),h(()=>bE(t,y))}}function m(){let y=s.let("ruleErrs",null);return s.try(()=>f((0,Ie._)`await `),C=>s.assign(d,!1).if((0,Ie._)`${C} instanceof ${c.ValidationError}`,()=>s.assign(y,(0,Ie._)`${C}.errors`),()=>s.throw(C))),y}function g(){let y=(0,Ie._)`${l}.errors`;return s.assign(y,null),f(Ie.nil),y}function f(y=e.async?(0,Ie._)`await `:Ie.nil){let C=c.opts.passContext?zt.default.this:zt.default.self,Q=!("compile"in e&&!a||e.schema===!1);s.assign(d,(0,Ie._)`${y}${(0,kE.callValidateCode)(t,l,C,Q)}`,e.modifying)}function h(y){var C;s.if((0,Ie.not)((C=e.valid)!==null&&C!==void 0?C:d),y)}}We.funcKeywordCode=ME;function Uu(t){let{gen:e,data:r,it:s}=t;e.if(s.parentData,()=>e.assign(r,(0,Ie._)`${s.parentData}[${s.parentDataProperty}]`))}function bE(t,e){let{gen:r}=t;r.if((0,Ie._)`Array.isArray(${e})`,()=>{r.assign(zt.default.vErrors,(0,Ie._)`${zt.default.vErrors} === null ? ${e} : ${zt.default.vErrors}.concat(${e})`).assign(zt.default.errors,(0,Ie._)`${zt.default.vErrors}.length`),(0,SE.extendErrors)(t)},()=>t.error())}function xE({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function qu(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Ie.stringify)(r)})}function RE(t,e,r=!1){return!e.length||e.some(s=>s==="array"?Array.isArray(t):s==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==s||r&&typeof t>"u")}We.validSchemaType=RE;function TE({schema:t,opts:e,self:r,errSchemaPath:s},o,n){if(Array.isArray(o.keyword)?!o.keyword.includes(n):o.keyword!==n)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${n}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[n])){let c=`keyword "${n}" value is invalid at path "${s}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}We.validateKeywordUsage=TE});var Gu=B(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.extendSubschemaMode=It.extendSubschemaData=It.getSubschema=void 0;var Ve=N(),Lu=L();function DE(t,{keyword:e,schemaProp:r,schema:s,schemaPath:o,errSchemaPath:n,topSchemaRef:i}){if(e!==void 0&&s!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Ve._)`${t.schemaPath}${(0,Ve.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Ve._)`${t.schemaPath}${(0,Ve.getProperty)(e)}${(0,Ve.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Lu.escapeFragment)(r)}`}}if(s!==void 0){if(o===void 0||n===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:o,topSchemaRef:i,errSchemaPath:n}}throw new Error('either "keyword" or "schema" must be passed')}It.getSubschema=DE;function $E(t,e,{dataProp:r,dataPropType:s,data:o,dataTypes:n,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,A=a.let("data",(0,Ve._)`${e.data}${(0,Ve.getProperty)(r)}`,!0);c(A),t.errorPath=(0,Ve.str)`${u}${(0,Lu.getErrorPath)(r,s,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Ve._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof Ve.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}n&&(t.dataTypes=n);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}It.extendSubschemaData=$E;function PE(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:s,createErrors:o,allErrors:n}){s!==void 0&&(t.compositeRule=s),o!==void 0&&(t.createErrors=o),n!==void 0&&(t.allErrors=n),t.jtdDiscriminator=e,t.jtdMetadata=r}It.extendSubschemaMode=PE});var ua=B((uR,Hu)=>{"use strict";Hu.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var s,o,n;if(Array.isArray(e)){if(s=e.length,s!=r.length)return!1;for(o=s;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(n=Object.keys(e),s=n.length,s!==Object.keys(r).length)return!1;for(o=s;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,n[o]))return!1;for(o=s;o--!==0;){var i=n[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Ju=B((dR,Yu)=>{"use strict";var Bt=Yu.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var s=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};jo(e,s,o,t,"",t)};Bt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Bt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Bt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Bt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function jo(t,e,r,s,o,n,i,a,c,u){if(s&&typeof s=="object"&&!Array.isArray(s)){e(s,o,n,i,a,c,u);for(var l in s){var d=s[l];if(Array.isArray(d)){if(l in Bt.arrayKeywords)for(var A=0;A<d.length;A++)jo(t,e,r,d[A],o+"/"+l+"/"+A,n,o,l,s,A)}else if(l in Bt.propsKeywords){if(d&&typeof d=="object")for(var m in d)jo(t,e,r,d[m],o+"/"+l+"/"+jE(m),n,o,l,s,m)}else(l in Bt.keywords||t.allKeys&&!(l in Bt.skipKeywords))&&jo(t,e,r,d,o+"/"+l,n,o,l,s)}r(s,o,n,i,a,c,u)}}function jE(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var As=B(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.getSchemaRefs=Me.resolveUrl=Me.normalizeId=Me._getFullPath=Me.getFullPath=Me.inlineRef=void 0;var NE=L(),zE=ua(),FE=Ju(),UE=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function qE(t,e=!0){return typeof t=="boolean"?!0:e===!0?!da(t):e?Wu(t)<=e:!1}Me.inlineRef=qE;var OE=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function da(t){for(let e in t){if(OE.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(da)||typeof r=="object"&&da(r))return!0}return!1}function Wu(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!UE.has(r)&&(typeof t[r]=="object"&&(0,NE.eachItem)(t[r],s=>e+=Wu(s)),e===1/0))return 1/0}return e}function Vu(t,e="",r){r!==!1&&(e=pr(e));let s=t.parse(e);return Ku(t,s)}Me.getFullPath=Vu;function Ku(t,e){return t.serialize(e).split("#")[0]+"#"}Me._getFullPath=Ku;var LE=/#\/?$/;function pr(t){return t?t.replace(LE,""):""}Me.normalizeId=pr;function GE(t,e,r){return r=pr(r),t.resolve(e,r)}Me.resolveUrl=GE;var HE=/^[a-z_][-a-z0-9._]*$/i;function YE(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:s}=this.opts,o=pr(t[r]||e),n={"":o},i=Vu(s,o,!1),a={},c=new Set;return FE(t,{allKeys:!0},(d,A,m,g)=>{if(g===void 0)return;let f=i+A,h=n[g];typeof d[r]=="string"&&(h=y.call(this,d[r])),C.call(this,d.$anchor),C.call(this,d.$dynamicAnchor),n[A]=h;function y(Q){let R=this.opts.uriResolver.resolve;if(Q=pr(h?R(h,Q):Q),c.has(Q))throw l(Q);c.add(Q);let w=this.refs[Q];return typeof w=="string"&&(w=this.refs[w]),typeof w=="object"?u(d,w.schema,Q):Q!==pr(f)&&(Q[0]==="#"?(u(d,a[Q],Q),a[Q]=d):this.refs[Q]=f),Q}function C(Q){if(typeof Q=="string"){if(!HE.test(Q))throw new Error(`invalid anchor "${Q}"`);y.call(this,`#${Q}`)}}}),a;function u(d,A,m){if(A!==void 0&&!zE(d,A))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Me.getSchemaRefs=YE});var fs=B(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.getData=Qt.KeywordCxt=Qt.validateFunctionCode=void 0;var rd=xu(),Zu=ds(),pa=sa(),No=ds(),JE=Nu(),ms=Ou(),Aa=Gu(),M=N(),$=st(),WE=As(),ot=L(),ps=us();function VE(t){if(nd(t)&&(id(t),od(t))){XE(t);return}sd(t,()=>(0,rd.topBoolOrEmptySchema)(t))}Qt.validateFunctionCode=VE;function sd({gen:t,validateName:e,schema:r,schemaEnv:s,opts:o},n){o.code.es5?t.func(e,(0,M._)`${$.default.data}, ${$.default.valCxt}`,s.$async,()=>{t.code((0,M._)`"use strict"; ${Xu(r,o)}`),ZE(t,o),t.code(n)}):t.func(e,(0,M._)`${$.default.data}, ${KE(o)}`,s.$async,()=>t.code(Xu(r,o)).code(n))}function KE(t){return(0,M._)`{${$.default.instancePath}="", ${$.default.parentData}, ${$.default.parentDataProperty}, ${$.default.rootData}=${$.default.data}${t.dynamicRef?(0,M._)`, ${$.default.dynamicAnchors}={}`:M.nil}}={}`}function ZE(t,e){t.if($.default.valCxt,()=>{t.var($.default.instancePath,(0,M._)`${$.default.valCxt}.${$.default.instancePath}`),t.var($.default.parentData,(0,M._)`${$.default.valCxt}.${$.default.parentData}`),t.var($.default.parentDataProperty,(0,M._)`${$.default.valCxt}.${$.default.parentDataProperty}`),t.var($.default.rootData,(0,M._)`${$.default.valCxt}.${$.default.rootData}`),e.dynamicRef&&t.var($.default.dynamicAnchors,(0,M._)`${$.default.valCxt}.${$.default.dynamicAnchors}`)},()=>{t.var($.default.instancePath,(0,M._)`""`),t.var($.default.parentData,(0,M._)`undefined`),t.var($.default.parentDataProperty,(0,M._)`undefined`),t.var($.default.rootData,$.default.data),e.dynamicRef&&t.var($.default.dynamicAnchors,(0,M._)`{}`)})}function XE(t){let{schema:e,opts:r,gen:s}=t;sd(t,()=>{r.$comment&&e.$comment&&cd(t),ow(t),s.let($.default.vErrors,null),s.let($.default.errors,0),r.unevaluated&&ew(t),ad(t),aw(t)})}function ew(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,M._)`${r}.evaluated`),e.if((0,M._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,M._)`${t.evaluated}.props`,(0,M._)`undefined`)),e.if((0,M._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,M._)`${t.evaluated}.items`,(0,M._)`undefined`))}function Xu(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,M._)`/*# sourceURL=${r} */`:M.nil}function tw(t,e){if(nd(t)&&(id(t),od(t))){rw(t,e);return}(0,rd.boolOrEmptySchema)(t,e)}function od({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function nd(t){return typeof t.schema!="boolean"}function rw(t,e){let{schema:r,gen:s,opts:o}=t;o.$comment&&r.$comment&&cd(t),nw(t),iw(t);let n=s.const("_errs",$.default.errors);ad(t,n),s.var(e,(0,M._)`${n} === ${$.default.errors}`)}function id(t){(0,ot.checkUnknownRules)(t),sw(t)}function ad(t,e){if(t.opts.jtd)return ed(t,[],!1,e);let r=(0,Zu.getSchemaTypes)(t.schema),s=(0,Zu.coerceAndCheckDataType)(t,r);ed(t,r,!s,e)}function sw(t){let{schema:e,errSchemaPath:r,opts:s,self:o}=t;e.$ref&&s.ignoreKeywordsWithRef&&(0,ot.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function ow(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,ot.checkStrictMode)(t,"default is ignored in the schema root")}function nw(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,WE.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function iw(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function cd({gen:t,schemaEnv:e,schema:r,errSchemaPath:s,opts:o}){let n=r.$comment;if(o.$comment===!0)t.code((0,M._)`${$.default.self}.logger.log(${n})`);else if(typeof o.$comment=="function"){let i=(0,M.str)`${s}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,M._)`${$.default.self}.opts.$comment(${n}, ${i}, ${a}.schema)`)}}function aw(t){let{gen:e,schemaEnv:r,validateName:s,ValidationError:o,opts:n}=t;r.$async?e.if((0,M._)`${$.default.errors} === 0`,()=>e.return($.default.data),()=>e.throw((0,M._)`new ${o}(${$.default.vErrors})`)):(e.assign((0,M._)`${s}.errors`,$.default.vErrors),n.unevaluated&&cw(t),e.return((0,M._)`${$.default.errors} === 0`))}function cw({gen:t,evaluated:e,props:r,items:s}){r instanceof M.Name&&t.assign((0,M._)`${e}.props`,r),s instanceof M.Name&&t.assign((0,M._)`${e}.items`,s)}function ed(t,e,r,s){let{gen:o,schema:n,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(n.$ref&&(c.ignoreKeywordsWithRef||!(0,ot.schemaHasRulesButRef)(n,l))){o.block(()=>ud(t,"$ref",l.all.$ref.definition));return}c.jtd||lw(t,e),o.block(()=>{for(let A of l.rules)d(A);d(l.post)});function d(A){(0,pa.shouldUseGroup)(n,A)&&(A.type?(o.if((0,No.checkDataType)(A.type,i,c.strictNumbers)),td(t,A),e.length===1&&e[0]===A.type&&r&&(o.else(),(0,No.reportTypeError)(t)),o.endIf()):td(t,A),a||o.if((0,M._)`${$.default.errors} === ${s||0}`))}}function td(t,e){let{gen:r,schema:s,opts:{useDefaults:o}}=t;o&&(0,JE.assignDefaults)(t,e.type),r.block(()=>{for(let n of e.rules)(0,pa.shouldUseRule)(s,n)&&ud(t,n.keyword,n.definition,e.type)})}function lw(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(uw(t,e),t.opts.allowUnionTypes||dw(t,e),Aw(t,t.dataTypes))}function uw(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{ld(t.dataTypes,r)||ma(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),mw(t,e)}}function dw(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&ma(t,"use allowUnionTypes to allow union type keyword")}function Aw(t,e){let r=t.self.RULES.all;for(let s in r){let o=r[s];if(typeof o=="object"&&(0,pa.shouldUseRule)(t.schema,o)){let{type:n}=o.definition;n.length&&!n.some(i=>pw(e,i))&&ma(t,`missing type "${n.join(",")}" for keyword "${s}"`)}}}function pw(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function ld(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function mw(t,e){let r=[];for(let s of t.dataTypes)ld(e,s)?r.push(s):e.includes("integer")&&s==="number"&&r.push("integer");t.dataTypes=r}function ma(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,ot.checkStrictMode)(t,e,t.opts.strictTypes)}var zo=class{constructor(e,r,s){if((0,ms.validateKeywordUsage)(e,r,s),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=s,this.data=e.data,this.schema=e.schema[s],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,ot.schemaRefOrVal)(e,this.schema,s,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",dd(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,ms.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${s} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",$.default.errors))}result(e,r,s){this.failResult((0,M.not)(e),r,s)}failResult(e,r,s){this.gen.if(e),s?s():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,M.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,M._)`${r} !== undefined && (${(0,M.or)(this.invalid$data(),e)})`)}error(e,r,s){if(r){this.setParams(r),this._error(e,s),this.setParams({});return}this._error(e,s)}_error(e,r){(e?ps.reportExtraError:ps.reportError)(this,this.def.error,r)}$dataError(){(0,ps.reportError)(this,this.def.$dataError||ps.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,ps.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,s=M.nil){this.gen.block(()=>{this.check$data(e,s),r()})}check$data(e=M.nil,r=M.nil){if(!this.$data)return;let{gen:s,schemaCode:o,schemaType:n,def:i}=this;s.if((0,M.or)((0,M._)`${o} === undefined`,r)),e!==M.nil&&s.assign(e,!0),(n.length||i.validateSchema)&&(s.elseIf(this.invalid$data()),this.$dataError(),e!==M.nil&&s.assign(e,!1)),s.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:s,def:o,it:n}=this;return(0,M.or)(i(),a());function i(){if(s.length){if(!(r instanceof M.Name))throw new Error("ajv implementation error");let c=Array.isArray(s)?s:[s];return(0,M._)`${(0,No.checkDataTypes)(c,r,n.opts.strictNumbers,No.DataType.Wrong)}`}return M.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,M._)`!${c}(${r})`}return M.nil}}subschema(e,r){let s=(0,Aa.getSubschema)(this.it,e);(0,Aa.extendSubschemaData)(s,this.it,e),(0,Aa.extendSubschemaMode)(s,e);let o={...this.it,...s,items:void 0,props:void 0};return tw(o,r),o}mergeEvaluated(e,r){let{it:s,gen:o}=this;s.opts.unevaluated&&(s.props!==!0&&e.props!==void 0&&(s.props=ot.mergeEvaluated.props(o,e.props,s.props,r)),s.items!==!0&&e.items!==void 0&&(s.items=ot.mergeEvaluated.items(o,e.items,s.items,r)))}mergeValidEvaluated(e,r){let{it:s,gen:o}=this;if(s.opts.unevaluated&&(s.props!==!0||s.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,M.Name)),!0}};Qt.KeywordCxt=zo;function ud(t,e,r,s){let o=new zo(t,r,e);"code"in r?r.code(o,s):o.$data&&r.validate?(0,ms.funcKeywordCode)(o,r):"macro"in r?(0,ms.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,ms.funcKeywordCode)(o,r)}var fw=/^\/(?:[^~]|~0|~1)*$/,gw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function dd(t,{dataLevel:e,dataNames:r,dataPathArr:s}){let o,n;if(t==="")return $.default.rootData;if(t[0]==="/"){if(!fw.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,n=$.default.rootData}else{let u=gw.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return s[e-l]}if(l>e)throw new Error(c("data",l));if(n=r[e-l],!o)return n}let i=n,a=o.split("/");for(let u of a)u&&(n=(0,M._)`${n}${(0,M.getProperty)((0,ot.unescapeJsonPointer)(u))}`,i=(0,M._)`${i} && ${n}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Qt.getData=dd});var Fo=B(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});var fa=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};ga.default=fa});var gs=B(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});var ha=As(),ya=class extends Error{constructor(e,r,s,o){super(o||`can't resolve reference ${s} from id ${r}`),this.missingRef=(0,ha.resolveUrl)(e,r,s),this.missingSchema=(0,ha.normalizeId)((0,ha.getFullPath)(e,this.missingRef))}};Ea.default=ya});var qo=B(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.resolveSchema=Ne.getCompilingSchema=Ne.resolveRef=Ne.compileSchema=Ne.SchemaEnv=void 0;var qe=N(),hw=Fo(),Ft=st(),Oe=As(),Ad=L(),yw=fs(),mr=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let s;typeof e.schema=="object"&&(s=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,Oe.normalizeId)(s?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=s?.$async,this.refs={}}};Ne.SchemaEnv=mr;function Ca(t){let e=pd.call(this,t);if(e)return e;let r=(0,Oe.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:s,lines:o}=this.opts.code,{ownProperties:n}=this.opts,i=new qe.CodeGen(this.scope,{es5:s,lines:o,ownProperties:n}),a;t.$async&&(a=i.scopeValue("Error",{ref:hw.default,code:(0,qe._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:Ft.default.data,parentData:Ft.default.parentData,parentDataProperty:Ft.default.parentDataProperty,dataNames:[Ft.default.data],dataPathArr:[qe.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,qe.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:qe.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,qe._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,yw.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(Ft.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let m=new Function(`${Ft.default.self}`,`${Ft.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:g,items:f}=u;m.evaluated={props:g instanceof qe.Name?void 0:g,items:f instanceof qe.Name?void 0:f,dynamicProps:g instanceof qe.Name,dynamicItems:f instanceof qe.Name},m.source&&(m.source.evaluated=(0,qe.stringify)(m.evaluated))}return t.validate=m,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}Ne.compileSchema=Ca;function Ew(t,e,r){var s;r=(0,Oe.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let n=Iw.call(this,t,r);if(n===void 0){let i=(s=t.localRefs)===null||s===void 0?void 0:s[r],{schemaId:a}=this.opts;i&&(n=new mr({schema:i,schemaId:a,root:t,baseId:e}))}if(n!==void 0)return t.refs[r]=ww.call(this,n)}Ne.resolveRef=Ew;function ww(t){return(0,Oe.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Ca.call(this,t)}function pd(t){for(let e of this._compilations)if(Cw(e,t))return e}Ne.getCompilingSchema=pd;function Cw(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Iw(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Uo.call(this,t,e)}function Uo(t,e){let r=this.opts.uriResolver.parse(e),s=(0,Oe._getFullPath)(this.opts.uriResolver,r),o=(0,Oe.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&s===o)return wa.call(this,r,t);let n=(0,Oe.normalizeId)(s),i=this.refs[n]||this.schemas[n];if(typeof i=="string"){let a=Uo.call(this,t,i);return typeof a?.schema!="object"?void 0:wa.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Ca.call(this,i),n===(0,Oe.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,Oe.resolveUrl)(this.opts.uriResolver,o,u)),new mr({schema:a,schemaId:c,root:t,baseId:o})}return wa.call(this,r,i)}}Ne.resolveSchema=Uo;var Bw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function wa(t,{baseId:e,schema:r,root:s}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,Ad.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Bw.has(a)&&u&&(e=(0,Oe.resolveUrl)(this.opts.uriResolver,e,u))}let n;if(typeof r!="boolean"&&r.$ref&&!(0,Ad.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Oe.resolveUrl)(this.opts.uriResolver,e,r.$ref);n=Uo.call(this,s,a)}let{schemaId:i}=this.opts;if(n=n||new mr({schema:r,schemaId:i,root:s,baseId:e}),n.schema!==n.root.schema)return n}});var md=B((hR,Qw)=>{Qw.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var Qa=B((yR,wd)=>{"use strict";var _w=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),gd=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),Ia=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),hd=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),kw=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Ba(t){let e="",r=0,s=0;for(s=0;s<t.length;s++)if(r=t[s].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[s];break}for(s+=1;s<t.length;s++){if(r=t[s].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[s]}return e}var Sw=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function fd(t){return t.length=0,!0}function vw(t,e,r){if(t.length){let s=Ba(t);if(s!=="")e.push(s);else return r.error=!0,!1;t.length=0}return!0}function Mw(t){let e=0,r={error:!1,address:"",zone:""},s=[],o=[],n=!1,i=!1,a=vw;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(n===!0&&(i=!0),!a(o,s,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(n=!0),s.push(":");continue}else if(u==="%"){if(!a(o,s,r))break;a=fd}else{o.push(u);continue}}return o.length&&(a===fd?r.zone=o.join(""):i?s.push(o.join("")):s.push(Ba(o))),r.address=s.join(""),r}function yd(t){if(bw(t,":")<2)return{host:t,isIPV6:!1};let e=Mw(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,s=e.address;return e.zone&&(r+="%"+e.zone,s+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:s}}}function bw(t,e){let r=0;for(let s=0;s<t.length;s++)t[s]===e&&r++;return r}function xw(t){let e=t,r=[],s=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((s=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,s)),e=e.slice(s)}return r.join("")}var Rw={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},Tw=/[@/?#:]/g,Dw=/[@/?#]/g;function Ed(t,e){let r=e?Dw:Tw;return r.lastIndex=0,t.replace(r,s=>Rw[s])}function $w(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let s=0;s<t.length;s++){if(t[s]==="%"&&s+2<t.length){let o=t.slice(s+1,s+3);if(Ia(o)){let n=o.toUpperCase(),i=String.fromCharCode(parseInt(n,16));e&&hd(i)?r+=i:r+="%"+n,s+=2;continue}}r+=t[s]}return r}function Pw(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let s=t.slice(r+1,r+3);if(Ia(s)){let o=s.toUpperCase(),n=String.fromCharCode(parseInt(o,16));n!=="."&&hd(n)?e+=n:e+="%"+o,r+=2;continue}}kw(t[r])?e+=t[r]:e+=escape(t[r])}return e}function jw(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let s=t.slice(r+1,r+3);if(Ia(s)){e+="%"+s.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function Nw(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!gd(r)){let s=yd(r);s.isIPV6===!0?r=`[${s.escapedHost}]`:r=Ed(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}wd.exports={nonSimpleDomain:Sw,recomposeAuthority:Nw,reescapeHostDelimiters:Ed,normalizePercentEncoding:$w,normalizePathEncoding:Pw,escapePreservingEscapes:jw,removeDotSegments:xw,isIPv4:gd,isUUID:_w,normalizeIPv6:yd,stringArrayToHexStripped:Ba}});var _d=B((ER,Qd)=>{"use strict";var{isUUID:zw}=Qa(),Fw=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Uw=["http","https","ws","wss","urn","urn:uuid"];function qw(t){return Uw.indexOf(t)!==-1}function _a(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function Cd(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function Id(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function Ow(t){return t.secure=_a(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function Lw(t){if((t.port===(_a(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function Gw(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(Fw);if(r){let s=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${s}:${e.nid||t.nid}`,n=ka(o);t.path=void 0,n&&(t=n.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function Hw(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",s=t.nid.toLowerCase(),o=`${r}:${e.nid||s}`,n=ka(o);n&&(t=n.serialize(t,e));let i=t,a=t.nss;return i.path=`${s||e.nid}:${a}`,e.skipEscape=!0,i}function Yw(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!zw(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Jw(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var Bd={scheme:"http",domainHost:!0,parse:Cd,serialize:Id},Ww={scheme:"https",domainHost:Bd.domainHost,parse:Cd,serialize:Id},Oo={scheme:"ws",domainHost:!0,parse:Ow,serialize:Lw},Vw={scheme:"wss",domainHost:Oo.domainHost,parse:Oo.parse,serialize:Oo.serialize},Kw={scheme:"urn",parse:Gw,serialize:Hw,skipNormalize:!0},Zw={scheme:"urn:uuid",parse:Yw,serialize:Jw,skipNormalize:!0},Lo={http:Bd,https:Ww,ws:Oo,wss:Vw,urn:Kw,"urn:uuid":Zw};Object.setPrototypeOf(Lo,null);function ka(t){return t&&(Lo[t]||Lo[t.toLowerCase()])||void 0}Qd.exports={wsIsSecure:_a,SCHEMES:Lo,isValidSchemeName:qw,getSchemeHandler:ka}});var xd=B((wR,Go)=>{"use strict";var{normalizeIPv6:Xw,removeDotSegments:hs,recomposeAuthority:eC,normalizePercentEncoding:tC,normalizePathEncoding:rC,escapePreservingEscapes:sC,reescapeHostDelimiters:oC,isIPv4:nC,nonSimpleDomain:iC}=Qa(),{SCHEMES:aC,getSchemeHandler:Sd}=_d();function cC(t,e){return typeof t=="string"?t=mC(t,e):typeof t=="object"&&(t=fr(Ut(t,e),e)),t}function lC(t,e,r){let s=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=vd(fr(t,s),fr(e,s),s,!0);return s.skipEscape=!0,Ut(o,s)}function vd(t,e,r,s){let o={};return s||(t=fr(Ut(t,r),r),e=fr(Ut(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=hs(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=hs(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=hs(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=hs(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function uC(t,e,r){let s=kd(t,r),o=kd(e,r);return s!==void 0&&o!==void 0&&s.toLowerCase()===o.toLowerCase()}function Ut(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},s=Object.assign({},e),o=[],n=Sd(s.scheme||r.scheme);n&&n.serialize&&n.serialize(r,s),r.path!==void 0&&(s.skipEscape?r.path=tC(r.path):(r.path=sC(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),s.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=eC(r);if(i!==void 0&&(s.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!s.absolutePath&&(!n||!n.absolutePath)&&(a=hs(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var dC=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,AC=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/;function pC(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function Md(t,e){let r=Object.assign({},e),s={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,n=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(AC);i!==null&&i[1].indexOf("\\")!==-1&&(s.error="URI authority must not contain a literal backslash.",o=!0);let a=t.match(dC);if(a){s.scheme=a[1],s.userinfo=a[3],s.host=a[4],s.port=parseInt(a[5],10),s.path=a[6]||"",s.query=a[7],s.fragment=a[8],isNaN(s.port)&&(s.port=a[5]);let c=pC(s,a);if(c!==void 0&&(s.error=s.error||c,o=!0),s.host)if(nC(s.host)===!1){let d=Xw(s.host);s.host=d.host.toLowerCase(),n=d.isIPV6}else n=!0;s.scheme===void 0&&s.userinfo===void 0&&s.host===void 0&&s.port===void 0&&s.query===void 0&&!s.path?s.reference="same-document":s.scheme===void 0?s.reference="relative":s.fragment===void 0?s.reference="absolute":s.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==s.reference&&(s.error=s.error||"URI is not a "+r.reference+" reference.");let u=Sd(r.scheme||s.scheme);if(!r.unicodeSupport&&(!u||!u.unicodeSupport)&&s.host&&(r.domainHost||u&&u.domainHost)&&n===!1&&iC(s.host))try{s.host=new URL("http://"+s.host).hostname}catch(l){s.error=s.error||"Host's domain name can not be converted to ASCII: "+l}if((!u||u&&!u.skipNormalize)&&(t.indexOf("%")!==-1&&(s.scheme!==void 0&&(s.scheme=unescape(s.scheme)),s.host!==void 0&&(s.host=oC(unescape(s.host),n))),s.path&&(s.path=rC(s.path)),s.fragment))try{s.fragment=encodeURI(decodeURIComponent(s.fragment))}catch{s.error=s.error||"URI malformed"}u&&u.parse&&u.parse(s,r)}else s.error=s.error||"URI can not be parsed.";return{parsed:s,malformedAuthorityOrPort:o}}function fr(t,e){return Md(t,e).parsed}function mC(t,e){return bd(t,e).normalized}function bd(t,e){let{parsed:r,malformedAuthorityOrPort:s}=Md(t,e);return{normalized:s?t:Ut(r,e),malformedAuthorityOrPort:s}}function kd(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:s}=bd(t,e);return s?void 0:r}if(typeof t=="object")return Ut(t,e)}var Sa={SCHEMES:aC,normalize:cC,resolve:lC,resolveComponent:vd,equal:uC,serialize:Ut,parse:fr};Go.exports=Sa;Go.exports.default=Sa;Go.exports.fastUri=Sa});var Td=B(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});var Rd=xd();Rd.code='require("ajv/dist/runtime/uri").default';va.default=Rd});var Ud=B(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.CodeGen=me.Name=me.nil=me.stringify=me.str=me._=me.KeywordCxt=void 0;var fC=fs();Object.defineProperty(me,"KeywordCxt",{enumerable:!0,get:function(){return fC.KeywordCxt}});var gr=N();Object.defineProperty(me,"_",{enumerable:!0,get:function(){return gr._}});Object.defineProperty(me,"str",{enumerable:!0,get:function(){return gr.str}});Object.defineProperty(me,"stringify",{enumerable:!0,get:function(){return gr.stringify}});Object.defineProperty(me,"nil",{enumerable:!0,get:function(){return gr.nil}});Object.defineProperty(me,"Name",{enumerable:!0,get:function(){return gr.Name}});Object.defineProperty(me,"CodeGen",{enumerable:!0,get:function(){return gr.CodeGen}});var gC=Fo(),Nd=gs(),hC=ra(),ys=qo(),yC=N(),Es=As(),Ho=ds(),ba=L(),Dd=md(),EC=Td(),zd=(t,e)=>new RegExp(t,e);zd.code="new RegExp";var wC=["removeAdditional","useDefaults","coerceTypes"],CC=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),IC={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},BC={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$d=200;function QC(t){var e,r,s,o,n,i,a,c,u,l,d,A,m,g,f,h,y,C,Q,R,w,I,P,se,oe;let _e=t.strict,Gr=(e=t.code)===null||e===void 0?void 0:e.optimize,io=Gr===!0||Gr===void 0?1:Gr||0,ao=(s=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&s!==void 0?s:zd,pt=(o=t.uriResolver)!==null&&o!==void 0?o:EC.default;return{strictSchema:(i=(n=t.strictSchema)!==null&&n!==void 0?n:_e)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:_e)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:_e)!==null&&l!==void 0?l:"log",strictTuples:(A=(d=t.strictTuples)!==null&&d!==void 0?d:_e)!==null&&A!==void 0?A:"log",strictRequired:(g=(m=t.strictRequired)!==null&&m!==void 0?m:_e)!==null&&g!==void 0?g:!1,code:t.code?{...t.code,optimize:io,regExp:ao}:{optimize:io,regExp:ao},loopRequired:(f=t.loopRequired)!==null&&f!==void 0?f:$d,loopEnum:(h=t.loopEnum)!==null&&h!==void 0?h:$d,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(C=t.messages)!==null&&C!==void 0?C:!0,inlineRefs:(Q=t.inlineRefs)!==null&&Q!==void 0?Q:!0,schemaId:(R=t.schemaId)!==null&&R!==void 0?R:"$id",addUsedSchema:(w=t.addUsedSchema)!==null&&w!==void 0?w:!0,validateSchema:(I=t.validateSchema)!==null&&I!==void 0?I:!0,validateFormats:(P=t.validateFormats)!==null&&P!==void 0?P:!0,unicodeRegExp:(se=t.unicodeRegExp)!==null&&se!==void 0?se:!0,int32range:(oe=t.int32range)!==null&&oe!==void 0?oe:!0,uriResolver:pt}}var ws=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...QC(e)};let{es5:r,lines:s}=this.opts.code;this.scope=new yC.ValueScope({scope:{},prefixes:CC,es5:r,lines:s}),this.logger=bC(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,hC.getRules)(),Pd.call(this,IC,e,"NOT SUPPORTED"),Pd.call(this,BC,e,"DEPRECATED","warn"),this._metaOpts=vC.call(this),e.formats&&kC.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&SC.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),_C.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:s}=this.opts,o=Dd;s==="id"&&(o={...Dd},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[s],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let s;if(typeof e=="string"){if(s=this.getSchema(e),!s)throw new Error(`no schema with key or ref "${e}"`)}else s=this.compile(e);let o=s(r);return"$async"in s||(this.errors=s.errors),o}compile(e,r){let s=this._addSchema(e,r);return s.validate||this._compileSchemaEnv(s)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:s}=this.opts;return o.call(this,e,r);async function o(l,d){await n.call(this,l.$schema);let A=this._addSchema(l,d);return A.validate||i.call(this,A)}async function n(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Nd.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await n.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=s(l))}finally{delete this._loading[l]}}}addSchema(e,r,s,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,s,o);return this}let n;if(typeof e=="object"){let{schemaId:i}=this.opts;if(n=e[i],n!==void 0&&typeof n!="string")throw new Error(`schema ${i} must be string`)}return r=(0,Es.normalizeId)(r||n),this._checkUnique(r),this.schemas[r]=this._addSchema(e,s,r,o,!0),this}addMetaSchema(e,r,s=this.opts.validateSchema){return this.addSchema(e,r,!0,s),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let s;if(s=e.$schema,s!==void 0&&typeof s!="string")throw new Error("$schema must be a string");if(s=s||this.opts.defaultMeta||this.defaultMeta(),!s)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(s,e);if(!o&&r){let n="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(n);else throw new Error(n)}return o}getSchema(e){let r;for(;typeof(r=jd.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:s}=this.opts,o=new ys.SchemaEnv({schema:{},schemaId:s});if(r=ys.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=jd.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let s=e[this.opts.schemaId];return s&&(s=(0,Es.normalizeId)(s),delete this.schemas[s],delete this.refs[s]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let s;if(typeof e=="string")s=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=s);else if(typeof e=="object"&&r===void 0){if(r=e,s=r.keyword,Array.isArray(s)&&!s.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(RC.call(this,s,r),!r)return(0,ba.eachItem)(s,n=>Ma.call(this,n)),this;DC.call(this,r);let o={...r,type:(0,Ho.getJSONTypes)(r.type),schemaType:(0,Ho.getJSONTypes)(r.schemaType)};return(0,ba.eachItem)(s,o.type.length===0?n=>Ma.call(this,n,o):n=>o.type.forEach(i=>Ma.call(this,n,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let s of r.rules){let o=s.rules.findIndex(n=>n.keyword===e);o>=0&&s.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:s="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${s}${o.instancePath} ${o.message}`).reduce((o,n)=>o+r+n)}$dataMetaSchema(e,r){let s=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let n=o.split("/").slice(1),i=e;for(let a of n)i=i[a];for(let a in s){let c=s[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=Fd(l))}}return e}_removeAllSchemas(e,r){for(let s in e){let o=e[s];(!r||r.test(s))&&(typeof o=="string"?delete e[s]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[s]))}}_addSchema(e,r,s,o=this.opts.validateSchema,n=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;s=(0,Es.normalizeId)(i||s);let u=Es.getSchemaRefs.call(this,e,s);return c=new ys.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:s,localRefs:u}),this._cache.set(c.schema,c),n&&!s.startsWith("#")&&(s&&this._checkUnique(s),this.refs[s]=c),o&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):ys.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{ys.compileSchema.call(this,e)}finally{this.opts=r}}};ws.ValidationError=gC.default;ws.MissingRefError=Nd.default;me.default=ws;function Pd(t,e,r,s="error"){for(let o in t){let n=o;n in e&&this.logger[s](`${r}: option ${o}. ${t[n]}`)}}function jd(t){return t=(0,Es.normalizeId)(t),this.schemas[t]||this.refs[t]}function _C(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function kC(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function SC(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function vC(){let t={...this.opts};for(let e of wC)delete t[e];return t}var MC={log(){},warn(){},error(){}};function bC(t){if(t===!1)return MC;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var xC=/^[a-z_$][a-z0-9_$:-]*$/i;function RC(t,e){let{RULES:r}=this;if((0,ba.eachItem)(t,s=>{if(r.keywords[s])throw new Error(`Keyword ${s} is already defined`);if(!xC.test(s))throw new Error(`Keyword ${s} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function Ma(t,e,r){var s;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:n}=this,i=o?n.post:n.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},n.rules.push(i)),n.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,Ho.getJSONTypes)(e.type),schemaType:(0,Ho.getJSONTypes)(e.schemaType)}};e.before?TC.call(this,i,a,e.before):i.rules.push(a),n.all[t]=a,(s=e.implements)===null||s===void 0||s.forEach(c=>this.addKeyword(c))}function TC(t,e,r){let s=t.rules.findIndex(o=>o.keyword===r);s>=0?t.rules.splice(s,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function DC(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Fd(e)),t.validateSchema=this.compile(e,!0))}var $C={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Fd(t){return{anyOf:[t,$C]}}});var qd=B(xa=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});var PC={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};xa.default=PC});var Hd=B(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.callRef=qt.getValidate=void 0;var jC=gs(),Od=je(),be=N(),hr=st(),Ld=qo(),Yo=L(),NC={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:s}=t,{baseId:o,schemaEnv:n,validateName:i,opts:a,self:c}=s,{root:u}=n;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=Ld.resolveRef.call(c,u,o,r);if(l===void 0)throw new jC.default(s.opts.uriResolver,o,r);if(l instanceof Ld.SchemaEnv)return A(l);return m(l);function d(){if(n===u)return Jo(t,i,n,n.$async);let g=e.scopeValue("root",{ref:u});return Jo(t,(0,be._)`${g}.validate`,u,u.$async)}function A(g){let f=Gd(t,g);Jo(t,f,g,g.$async)}function m(g){let f=e.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,be.stringify)(g)}:{ref:g}),h=e.name("valid"),y=t.subschema({schema:g,dataTypes:[],schemaPath:be.nil,topSchemaRef:f,errSchemaPath:r},h);t.mergeEvaluated(y),t.ok(h)}}};function Gd(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,be._)`${r.scopeValue("wrapper",{ref:e})}.validate`}qt.getValidate=Gd;function Jo(t,e,r,s){let{gen:o,it:n}=t,{allErrors:i,schemaEnv:a,opts:c}=n,u=c.passContext?hr.default.this:be.nil;s?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let g=o.let("valid");o.try(()=>{o.code((0,be._)`await ${(0,Od.callValidateCode)(t,e,u)}`),m(e),i||o.assign(g,!0)},f=>{o.if((0,be._)`!(${f} instanceof ${n.ValidationError})`,()=>o.throw(f)),A(f),i||o.assign(g,!1)}),t.ok(g)}function d(){t.result((0,Od.callValidateCode)(t,e,u),()=>m(e),()=>A(e))}function A(g){let f=(0,be._)`${g}.errors`;o.assign(hr.default.vErrors,(0,be._)`${hr.default.vErrors} === null ? ${f} : ${hr.default.vErrors}.concat(${f})`),o.assign(hr.default.errors,(0,be._)`${hr.default.vErrors}.length`)}function m(g){var f;if(!n.opts.unevaluated)return;let h=(f=r?.validate)===null||f===void 0?void 0:f.evaluated;if(n.props!==!0)if(h&&!h.dynamicProps)h.props!==void 0&&(n.props=Yo.mergeEvaluated.props(o,h.props,n.props));else{let y=o.var("props",(0,be._)`${g}.evaluated.props`);n.props=Yo.mergeEvaluated.props(o,y,n.props,be.Name)}if(n.items!==!0)if(h&&!h.dynamicItems)h.items!==void 0&&(n.items=Yo.mergeEvaluated.items(o,h.items,n.items));else{let y=o.var("items",(0,be._)`${g}.evaluated.items`);n.items=Yo.mergeEvaluated.items(o,y,n.items,be.Name)}}}qt.callRef=Jo;qt.default=NC});var Yd=B(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});var zC=qd(),FC=Hd(),UC=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",zC.default,FC.default];Ra.default=UC});var Jd=B(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});var Wo=N(),_t=Wo.operators,Vo={maximum:{okStr:"<=",ok:_t.LTE,fail:_t.GT},minimum:{okStr:">=",ok:_t.GTE,fail:_t.LT},exclusiveMaximum:{okStr:"<",ok:_t.LT,fail:_t.GTE},exclusiveMinimum:{okStr:">",ok:_t.GT,fail:_t.LTE}},qC={message:({keyword:t,schemaCode:e})=>(0,Wo.str)`must be ${Vo[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Wo._)`{comparison: ${Vo[t].okStr}, limit: ${e}}`},OC={keyword:Object.keys(Vo),type:"number",schemaType:"number",$data:!0,error:qC,code(t){let{keyword:e,data:r,schemaCode:s}=t;t.fail$data((0,Wo._)`${r} ${Vo[e].fail} ${s} || isNaN(${r})`)}};Ta.default=OC});var Wd=B(Da=>{"use strict";Object.defineProperty(Da,"__esModule",{value:!0});var Cs=N(),LC={message:({schemaCode:t})=>(0,Cs.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Cs._)`{multipleOf: ${t}}`},GC={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:LC,code(t){let{gen:e,data:r,schemaCode:s,it:o}=t,n=o.opts.multipleOfPrecision,i=e.let("res"),a=n?(0,Cs._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${n}`:(0,Cs._)`${i} !== parseInt(${i})`;t.fail$data((0,Cs._)`(${s} === 0 || (${i} = ${r}/${s}, ${a}))`)}};Da.default=GC});var Kd=B($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});function Vd(t){let e=t.length,r=0,s=0,o;for(;s<e;)r++,o=t.charCodeAt(s++),o>=55296&&o<=56319&&s<e&&(o=t.charCodeAt(s),(o&64512)===56320&&s++);return r}$a.default=Vd;Vd.code='require("ajv/dist/runtime/ucs2length").default'});var Zd=B(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});var Ot=N(),HC=L(),YC=Kd(),JC={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Ot.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Ot._)`{limit: ${t}}`},WC={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:JC,code(t){let{keyword:e,data:r,schemaCode:s,it:o}=t,n=e==="maxLength"?Ot.operators.GT:Ot.operators.LT,i=o.opts.unicode===!1?(0,Ot._)`${r}.length`:(0,Ot._)`${(0,HC.useFunc)(t.gen,YC.default)}(${r})`;t.fail$data((0,Ot._)`${i} ${n} ${s}`)}};Pa.default=WC});var Xd=B(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});var VC=je(),KC=L(),yr=N(),ZC={message:({schemaCode:t})=>(0,yr.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,yr._)`{pattern: ${t}}`},XC={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:ZC,code(t){let{gen:e,data:r,$data:s,schema:o,schemaCode:n,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(s){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,yr._)`new RegExp`:(0,KC.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,yr._)`${u}(${n}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,yr._)`!${l}`)}else{let c=(0,VC.usePattern)(t,o);t.fail$data((0,yr._)`!${c}.test(${r})`)}}};ja.default=XC});var eA=B(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});var Is=N(),eI={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Is.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Is._)`{limit: ${t}}`},tI={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:eI,code(t){let{keyword:e,data:r,schemaCode:s}=t,o=e==="maxProperties"?Is.operators.GT:Is.operators.LT;t.fail$data((0,Is._)`Object.keys(${r}).length ${o} ${s}`)}};Na.default=tI});var tA=B(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});var Bs=je(),Qs=N(),rI=L(),sI={message:({params:{missingProperty:t}})=>(0,Qs.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Qs._)`{missingProperty: ${t}}`},oI={keyword:"required",type:"object",schemaType:"array",$data:!0,error:sI,code(t){let{gen:e,schema:r,schemaCode:s,data:o,$data:n,it:i}=t,{opts:a}=i;if(!n&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let m=t.parentSchema.properties,{definedProperties:g}=t.it;for(let f of r)if(m?.[f]===void 0&&!g.has(f)){let h=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${f}" is not defined at "${h}" (strictRequired)`;(0,rI.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||n)t.block$data(Qs.nil,d);else for(let m of r)(0,Bs.checkReportMissingProp)(t,m)}function l(){let m=e.let("missing");if(c||n){let g=e.let("valid",!0);t.block$data(g,()=>A(m,g)),t.ok(g)}else e.if((0,Bs.checkMissingProp)(t,r,m)),(0,Bs.reportMissingProp)(t,m),e.else()}function d(){e.forOf("prop",s,m=>{t.setParams({missingProperty:m}),e.if((0,Bs.noPropertyInData)(e,o,m,a.ownProperties),()=>t.error())})}function A(m,g){t.setParams({missingProperty:m}),e.forOf(m,s,()=>{e.assign(g,(0,Bs.propertyInData)(e,o,m,a.ownProperties)),e.if((0,Qs.not)(g),()=>{t.error(),e.break()})},Qs.nil)}}};za.default=oI});var rA=B(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});var _s=N(),nI={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,_s.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,_s._)`{limit: ${t}}`},iI={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:nI,code(t){let{keyword:e,data:r,schemaCode:s}=t,o=e==="maxItems"?_s.operators.GT:_s.operators.LT;t.fail$data((0,_s._)`${r}.length ${o} ${s}`)}};Fa.default=iI});var Ko=B(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});var sA=ua();sA.code='require("ajv/dist/runtime/equal").default';Ua.default=sA});var oA=B(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});var qa=ds(),fe=N(),aI=L(),cI=Ko(),lI={message:({params:{i:t,j:e}})=>(0,fe.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,fe._)`{i: ${t}, j: ${e}}`},uI={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:lI,code(t){let{gen:e,data:r,$data:s,schema:o,parentSchema:n,schemaCode:i,it:a}=t;if(!s&&!o)return;let c=e.let("valid"),u=n.items?(0,qa.getSchemaTypes)(n.items):[];t.block$data(c,l,(0,fe._)`${i} === false`),t.ok(c);function l(){let g=e.let("i",(0,fe._)`${r}.length`),f=e.let("j");t.setParams({i:g,j:f}),e.assign(c,!0),e.if((0,fe._)`${g} > 1`,()=>(d()?A:m)(g,f))}function d(){return u.length>0&&!u.some(g=>g==="object"||g==="array")}function A(g,f){let h=e.name("item"),y=(0,qa.checkDataTypes)(u,h,a.opts.strictNumbers,qa.DataType.Wrong),C=e.const("indices",(0,fe._)`{}`);e.for((0,fe._)`;${g}--;`,()=>{e.let(h,(0,fe._)`${r}[${g}]`),e.if(y,(0,fe._)`continue`),u.length>1&&e.if((0,fe._)`typeof ${h} == "string"`,(0,fe._)`${h} += "_"`),e.if((0,fe._)`typeof ${C}[${h}] == "number"`,()=>{e.assign(f,(0,fe._)`${C}[${h}]`),t.error(),e.assign(c,!1).break()}).code((0,fe._)`${C}[${h}] = ${g}`)})}function m(g,f){let h=(0,aI.useFunc)(e,cI.default),y=e.name("outer");e.label(y).for((0,fe._)`;${g}--;`,()=>e.for((0,fe._)`${f} = ${g}; ${f}--;`,()=>e.if((0,fe._)`${h}(${r}[${g}], ${r}[${f}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};Oa.default=uI});var nA=B(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});var La=N(),dI=L(),AI=Ko(),pI={message:"must be equal to constant",params:({schemaCode:t})=>(0,La._)`{allowedValue: ${t}}`},mI={keyword:"const",$data:!0,error:pI,code(t){let{gen:e,data:r,$data:s,schemaCode:o,schema:n}=t;s||n&&typeof n=="object"?t.fail$data((0,La._)`!${(0,dI.useFunc)(e,AI.default)}(${r}, ${o})`):t.fail((0,La._)`${n} !== ${r}`)}};Ga.default=mI});var iA=B(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});var ks=N(),fI=L(),gI=Ko(),hI={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,ks._)`{allowedValues: ${t}}`},yI={keyword:"enum",schemaType:"array",$data:!0,error:hI,code(t){let{gen:e,data:r,$data:s,schema:o,schemaCode:n,it:i}=t;if(!s&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,fI.useFunc)(e,gI.default)),l;if(a||s)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=e.const("vSchema",n);l=(0,ks.or)(...o.map((g,f)=>A(m,f)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",n,m=>e.if((0,ks._)`${u()}(${r}, ${m})`,()=>e.assign(l,!0).break()))}function A(m,g){let f=o[g];return typeof f=="object"&&f!==null?(0,ks._)`${u()}(${r}, ${m}[${g}])`:(0,ks._)`${r} === ${f}`}}};Ha.default=yI});var aA=B(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});var EI=Jd(),wI=Wd(),CI=Zd(),II=Xd(),BI=eA(),QI=tA(),_I=rA(),kI=oA(),SI=nA(),vI=iA(),MI=[EI.default,wI.default,CI.default,II.default,BI.default,QI.default,_I.default,kI.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},SI.default,vI.default];Ya.default=MI});var Wa=B(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.validateAdditionalItems=void 0;var Lt=N(),Ja=L(),bI={message:({params:{len:t}})=>(0,Lt.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Lt._)`{limit: ${t}}`},xI={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:bI,code(t){let{parentSchema:e,it:r}=t,{items:s}=e;if(!Array.isArray(s)){(0,Ja.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}cA(t,s)}};function cA(t,e){let{gen:r,schema:s,data:o,keyword:n,it:i}=t;i.items=!0;let a=r.const("len",(0,Lt._)`${o}.length`);if(s===!1)t.setParams({len:e.length}),t.pass((0,Lt._)`${a} <= ${e.length}`);else if(typeof s=="object"&&!(0,Ja.alwaysValidSchema)(i,s)){let u=r.var("valid",(0,Lt._)`${a} <= ${e.length}`);r.if((0,Lt.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:n,dataProp:l,dataPropType:Ja.Type.Num},u),i.allErrors||r.if((0,Lt.not)(u),()=>r.break())})}}Ss.validateAdditionalItems=cA;Ss.default=xI});var Va=B(vs=>{"use strict";Object.defineProperty(vs,"__esModule",{value:!0});vs.validateTuple=void 0;var lA=N(),Zo=L(),RI=je(),TI={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return uA(t,"additionalItems",e);r.items=!0,!(0,Zo.alwaysValidSchema)(r,e)&&t.ok((0,RI.validateArray)(t))}};function uA(t,e,r=t.schema){let{gen:s,parentSchema:o,data:n,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Zo.mergeEvaluated.items(s,r.length,a.items));let c=s.name("valid"),u=s.const("len",(0,lA._)`${n}.length`);r.forEach((d,A)=>{(0,Zo.alwaysValidSchema)(a,d)||(s.if((0,lA._)`${u} > ${A}`,()=>t.subschema({keyword:i,schemaProp:A,dataProp:A},c)),t.ok(c))});function l(d){let{opts:A,errSchemaPath:m}=a,g=r.length,f=g===d.minItems&&(g===d.maxItems||d[e]===!1);if(A.strictTuples&&!f){let h=`"${i}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,Zo.checkStrictMode)(a,h,A.strictTuples)}}}vs.validateTuple=uA;vs.default=TI});var dA=B(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});var DI=Va(),$I={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,DI.validateTuple)(t,"items")};Ka.default=$I});var pA=B(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});var AA=N(),PI=L(),jI=je(),NI=Wa(),zI={message:({params:{len:t}})=>(0,AA.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,AA._)`{limit: ${t}}`},FI={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:zI,code(t){let{schema:e,parentSchema:r,it:s}=t,{prefixItems:o}=r;s.items=!0,!(0,PI.alwaysValidSchema)(s,e)&&(o?(0,NI.validateAdditionalItems)(t,o):t.ok((0,jI.validateArray)(t)))}};Za.default=FI});var mA=B(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});var ze=N(),Xo=L(),UI={message:({params:{min:t,max:e}})=>e===void 0?(0,ze.str)`must contain at least ${t} valid item(s)`:(0,ze.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,ze._)`{minContains: ${t}}`:(0,ze._)`{minContains: ${t}, maxContains: ${e}}`},qI={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:UI,code(t){let{gen:e,schema:r,parentSchema:s,data:o,it:n}=t,i,a,{minContains:c,maxContains:u}=s;n.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,ze._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,Xo.checkStrictMode)(n,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,Xo.checkStrictMode)(n,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Xo.alwaysValidSchema)(n,r)){let f=(0,ze._)`${l} >= ${i}`;a!==void 0&&(f=(0,ze._)`${f} && ${l} <= ${a}`),t.pass(f);return}n.items=!0;let d=e.name("valid");a===void 0&&i===1?m(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,ze._)`${o}.length > 0`,A)):(e.let(d,!1),A()),t.result(d,()=>t.reset());function A(){let f=e.name("_valid"),h=e.let("count",0);m(f,()=>e.if(f,()=>g(h)))}function m(f,h){e.forRange("i",0,l,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:Xo.Type.Num,compositeRule:!0},f),h()})}function g(f){e.code((0,ze._)`${f}++`),a===void 0?e.if((0,ze._)`${f} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,ze._)`${f} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,ze._)`${f} >= ${i}`,()=>e.assign(d,!0)))}}};Xa.default=qI});var hA=B(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.validateSchemaDeps=Ke.validatePropertyDeps=Ke.error=void 0;var ec=N(),OI=L(),Ms=je();Ke.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let s=e===1?"property":"properties";return(0,ec.str)`must have ${s} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:s}})=>(0,ec._)`{property: ${t},
|
|
8
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,j._)`[${o}]`)}}}function ly({gen:t,parentData:e,parentDataProperty:r},s){t.if((0,j._)`${e} !== undefined`,()=>t.assign((0,j._)`${e}[${r}]`,s))}function oa(t,e,r,s=Ar.Correct){let o=s===Ar.Correct?j.operators.EQ:j.operators.NEQ,n;switch(t){case"null":return(0,j._)`${e} ${o} null`;case"array":n=(0,j._)`Array.isArray(${e})`;break;case"object":n=(0,j._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":n=i((0,j._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":n=i();break;default:return(0,j._)`typeof ${e} ${o} ${t}`}return s===Ar.Correct?n:(0,j.not)(n);function i(a=j.nil){return(0,j.and)((0,j._)`typeof ${e} == "number"`,a,r?(0,j._)`isFinite(${e})`:j.nil)}}we.checkDataType=oa;function na(t,e,r,s){if(t.length===1)return oa(t[0],e,r,s);let o,n=(0,Tu.toHash)(t);if(n.array&&n.object){let i=(0,j._)`typeof ${e} != "object"`;o=n.null?i:(0,j._)`!${e} || ${i}`,delete n.null,delete n.array,delete n.object}else o=j.nil;n.number&&delete n.integer;for(let i in n)o=(0,j.and)(o,oa(i,e,r,s));return o}we.checkDataTypes=na;var uy={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,j._)`{type: ${t}}`:(0,j._)`{type: ${e}}`};function ia(t){let e=Ay(t);(0,oy.reportError)(e,uy)}we.reportTypeError=ia;function Ay(t){let{gen:e,data:r,schema:s}=t,o=(0,Tu.schemaRefOrVal)(t,s,"type");return{gen:e,keyword:"type",data:r,schema:s.type,schemaCode:o,schemaValue:o,parentSchema:s,params:{},it:t}}});var Nu=Q(Po=>{"use strict";Object.defineProperty(Po,"__esModule",{value:!0});Po.assignDefaults=void 0;var dr=N(),dy=q();function py(t,e){let{properties:r,items:s}=t.schema;if(e==="object"&&r)for(let o in r)ju(t,o,r[o].default);else e==="array"&&Array.isArray(s)&&s.forEach((o,n)=>ju(t,n,o.default))}Po.assignDefaults=py;function ju(t,e,r){let{gen:s,compositeRule:o,data:n,opts:i}=t;if(r===void 0)return;let a=(0,dr._)`${n}${(0,dr.getProperty)(e)}`;if(o){(0,dy.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,dr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,dr._)`${c} || ${a} === null || ${a} === ""`),s.if(c,(0,dr._)`${a} = ${(0,dr.stringify)(r)}`)}});var je=Q(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.validateUnion=J.validateArray=J.usePattern=J.callValidateCode=J.schemaProperties=J.allSchemaProperties=J.noPropertyInData=J.propertyInData=J.isOwnProperty=J.hasPropFunc=J.reportMissingProp=J.checkMissingProp=J.checkReportMissingProp=void 0;var Z=N(),aa=q(),Ct=st(),my=q();function fy(t,e){let{gen:r,data:s,it:o}=t;r.if(la(r,s,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,Z._)`${e}`},!0),t.error()})}J.checkReportMissingProp=fy;function gy({gen:t,data:e,it:{opts:r}},s,o){return(0,Z.or)(...s.map(n=>(0,Z.and)(la(t,e,n,r.ownProperties),(0,Z._)`${o} = ${n}`)))}J.checkMissingProp=gy;function hy(t,e){t.setParams({missingProperty:e},!0),t.error()}J.reportMissingProp=hy;function zu(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Z._)`Object.prototype.hasOwnProperty`})}J.hasPropFunc=zu;function ca(t,e,r){return(0,Z._)`${zu(t)}.call(${e}, ${r})`}J.isOwnProperty=ca;function Ey(t,e,r,s){let o=(0,Z._)`${e}${(0,Z.getProperty)(r)} !== undefined`;return s?(0,Z._)`${o} && ${ca(t,e,r)}`:o}J.propertyInData=Ey;function la(t,e,r,s){let o=(0,Z._)`${e}${(0,Z.getProperty)(r)} === undefined`;return s?(0,Z.or)(o,(0,Z.not)(ca(t,e,r))):o}J.noPropertyInData=la;function Uu(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}J.allSchemaProperties=Uu;function yy(t,e){return Uu(e).filter(r=>!(0,aa.alwaysValidSchema)(t,e[r]))}J.schemaProperties=yy;function wy({schemaCode:t,data:e,it:{gen:r,topSchemaRef:s,schemaPath:o,errorPath:n},it:i},a,c,u){let l=u?(0,Z._)`${t}, ${e}, ${s}${o}`:e,A=[[Ct.default.instancePath,(0,Z.strConcat)(Ct.default.instancePath,n)],[Ct.default.parentData,i.parentData],[Ct.default.parentDataProperty,i.parentDataProperty],[Ct.default.rootData,Ct.default.rootData]];i.opts.dynamicRef&&A.push([Ct.default.dynamicAnchors,Ct.default.dynamicAnchors]);let p=(0,Z._)`${l}, ${r.object(...A)}`;return c!==Z.nil?(0,Z._)`${a}.call(${c}, ${p})`:(0,Z._)`${a}(${p})`}J.callValidateCode=wy;var Cy=(0,Z._)`new RegExp`;function Iy({gen:t,it:{opts:e}},r){let s=e.unicodeRegExp?"u":"",{regExp:o}=e.code,n=o(r,s);return t.scopeValue("pattern",{key:n.toString(),ref:n,code:(0,Z._)`${o.code==="new RegExp"?Cy:(0,my.useFunc)(t,o)}(${r}, ${s})`})}J.usePattern=Iy;function By(t){let{gen:e,data:r,keyword:s,it:o}=t,n=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(n,!0),i(()=>e.break()),n;function i(a){let c=e.const("len",(0,Z._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:s,dataProp:u,dataPropType:aa.Type.Num},n),e.if((0,Z.not)(n),a)})}}J.validateArray=By;function Qy(t){let{gen:e,schema:r,keyword:s,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,aa.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:s,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,Z._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,Z.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}J.validateUnion=Qy});var Lu=Q(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.validateKeywordUsage=We.validSchemaType=We.funcKeywordCode=We.macroKeywordCode=void 0;var Ie=N(),zt=st(),_y=je(),Sy=us();function ky(t,e){let{gen:r,keyword:s,schema:o,parentSchema:n,it:i}=t,a=e.macro.call(i.self,o,n,i),c=Ou(r,s,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:Ie.nil,errSchemaPath:`${i.errSchemaPath}/${s}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}We.macroKeywordCode=ky;function My(t,e){var r;let{gen:s,keyword:o,schema:n,parentSchema:i,$data:a,it:c}=t;by(c,e);let u=!a&&e.compile?e.compile.call(c.self,n,i,c):e.validate,l=Ou(s,o,u),A=s.let("valid");t.block$data(A,p),t.ok((r=e.valid)!==null&&r!==void 0?r:A);function p(){if(e.errors===!1)f(),e.modifying&&Fu(t),h(()=>t.error());else{let w=e.async?m():g();e.modifying&&Fu(t),h(()=>vy(t,w))}}function m(){let w=s.let("ruleErrs",null);return s.try(()=>f((0,Ie._)`await `),C=>s.assign(A,!1).if((0,Ie._)`${C} instanceof ${c.ValidationError}`,()=>s.assign(w,(0,Ie._)`${C}.errors`),()=>s.throw(C))),w}function g(){let w=(0,Ie._)`${l}.errors`;return s.assign(w,null),f(Ie.nil),w}function f(w=e.async?(0,Ie._)`await `:Ie.nil){let C=c.opts.passContext?zt.default.this:zt.default.self,I=!("compile"in e&&!a||e.schema===!1);s.assign(A,(0,Ie._)`${w}${(0,_y.callValidateCode)(t,l,C,I)}`,e.modifying)}function h(w){var C;s.if((0,Ie.not)((C=e.valid)!==null&&C!==void 0?C:A),w)}}We.funcKeywordCode=My;function Fu(t){let{gen:e,data:r,it:s}=t;e.if(s.parentData,()=>e.assign(r,(0,Ie._)`${s.parentData}[${s.parentDataProperty}]`))}function vy(t,e){let{gen:r}=t;r.if((0,Ie._)`Array.isArray(${e})`,()=>{r.assign(zt.default.vErrors,(0,Ie._)`${zt.default.vErrors} === null ? ${e} : ${zt.default.vErrors}.concat(${e})`).assign(zt.default.errors,(0,Ie._)`${zt.default.vErrors}.length`),(0,Sy.extendErrors)(t)},()=>t.error())}function by({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Ou(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Ie.stringify)(r)})}function xy(t,e,r=!1){return!e.length||e.some(s=>s==="array"?Array.isArray(t):s==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==s||r&&typeof t>"u")}We.validSchemaType=xy;function Ry({schema:t,opts:e,self:r,errSchemaPath:s},o,n){if(Array.isArray(o.keyword)?!o.keyword.includes(n):o.keyword!==n)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${n}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[n])){let c=`keyword "${n}" value is invalid at path "${s}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}We.validateKeywordUsage=Ry});var Gu=Q(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.extendSubschemaMode=It.extendSubschemaData=It.getSubschema=void 0;var Ve=N(),qu=q();function Dy(t,{keyword:e,schemaProp:r,schema:s,schemaPath:o,errSchemaPath:n,topSchemaRef:i}){if(e!==void 0&&s!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Ve._)`${t.schemaPath}${(0,Ve.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Ve._)`${t.schemaPath}${(0,Ve.getProperty)(e)}${(0,Ve.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,qu.escapeFragment)(r)}`}}if(s!==void 0){if(o===void 0||n===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:o,topSchemaRef:i,errSchemaPath:n}}throw new Error('either "keyword" or "schema" must be passed')}It.getSubschema=Dy;function Ty(t,e,{dataProp:r,dataPropType:s,data:o,dataTypes:n,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:A}=e,p=a.let("data",(0,Ve._)`${e.data}${(0,Ve.getProperty)(r)}`,!0);c(p),t.errorPath=(0,Ve.str)`${u}${(0,qu.getErrorPath)(r,s,A.jsPropertySyntax)}`,t.parentDataProperty=(0,Ve._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof Ve.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}n&&(t.dataTypes=n);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}It.extendSubschemaData=Ty;function $y(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:s,createErrors:o,allErrors:n}){s!==void 0&&(t.compositeRule=s),o!==void 0&&(t.createErrors=o),n!==void 0&&(t.allErrors=n),t.jtdDiscriminator=e,t.jtdMetadata=r}It.extendSubschemaMode=$y});var ua=Q((uR,Hu)=>{"use strict";Hu.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var s,o,n;if(Array.isArray(e)){if(s=e.length,s!=r.length)return!1;for(o=s;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(n=Object.keys(e),s=n.length,s!==Object.keys(r).length)return!1;for(o=s;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,n[o]))return!1;for(o=s;o--!==0;){var i=n[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Ju=Q((AR,Yu)=>{"use strict";var Bt=Yu.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var s=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};jo(e,s,o,t,"",t)};Bt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Bt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Bt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Bt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function jo(t,e,r,s,o,n,i,a,c,u){if(s&&typeof s=="object"&&!Array.isArray(s)){e(s,o,n,i,a,c,u);for(var l in s){var A=s[l];if(Array.isArray(A)){if(l in Bt.arrayKeywords)for(var p=0;p<A.length;p++)jo(t,e,r,A[p],o+"/"+l+"/"+p,n,o,l,s,p)}else if(l in Bt.propsKeywords){if(A&&typeof A=="object")for(var m in A)jo(t,e,r,A[m],o+"/"+l+"/"+Py(m),n,o,l,s,m)}else(l in Bt.keywords||t.allKeys&&!(l in Bt.skipKeywords))&&jo(t,e,r,A,o+"/"+l,n,o,l,s)}r(s,o,n,i,a,c,u)}}function Py(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var ds=Q(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.getSchemaRefs=ve.resolveUrl=ve.normalizeId=ve._getFullPath=ve.getFullPath=ve.inlineRef=void 0;var jy=q(),Ny=ua(),zy=Ju(),Uy=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Fy(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Aa(t):e?Wu(t)<=e:!1}ve.inlineRef=Fy;var Oy=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Aa(t){for(let e in t){if(Oy.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Aa)||typeof r=="object"&&Aa(r))return!0}return!1}function Wu(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!Uy.has(r)&&(typeof t[r]=="object"&&(0,jy.eachItem)(t[r],s=>e+=Wu(s)),e===1/0))return 1/0}return e}function Vu(t,e="",r){r!==!1&&(e=pr(e));let s=t.parse(e);return Ku(t,s)}ve.getFullPath=Vu;function Ku(t,e){return t.serialize(e).split("#")[0]+"#"}ve._getFullPath=Ku;var Ly=/#\/?$/;function pr(t){return t?t.replace(Ly,""):""}ve.normalizeId=pr;function qy(t,e,r){return r=pr(r),t.resolve(e,r)}ve.resolveUrl=qy;var Gy=/^[a-z_][-a-z0-9._]*$/i;function Hy(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:s}=this.opts,o=pr(t[r]||e),n={"":o},i=Vu(s,o,!1),a={},c=new Set;return zy(t,{allKeys:!0},(A,p,m,g)=>{if(g===void 0)return;let f=i+p,h=n[g];typeof A[r]=="string"&&(h=w.call(this,A[r])),C.call(this,A.$anchor),C.call(this,A.$dynamicAnchor),n[p]=h;function w(I){let b=this.opts.uriResolver.resolve;if(I=pr(h?b(h,I):I),c.has(I))throw l(I);c.add(I);let E=this.refs[I];return typeof E=="string"&&(E=this.refs[E]),typeof E=="object"?u(A,E.schema,I):I!==pr(f)&&(I[0]==="#"?(u(A,a[I],I),a[I]=A):this.refs[I]=f),I}function C(I){if(typeof I=="string"){if(!Gy.test(I))throw new Error(`invalid anchor "${I}"`);w.call(this,`#${I}`)}}}),a;function u(A,p,m){if(p!==void 0&&!Ny(A,p))throw l(m)}function l(A){return new Error(`reference "${A}" resolves to more than one schema`)}}ve.getSchemaRefs=Hy});var fs=Q(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.getData=Qt.KeywordCxt=Qt.validateFunctionCode=void 0;var rA=xu(),Zu=As(),pa=sa(),No=As(),Yy=Nu(),ms=Lu(),da=Gu(),v=N(),$=st(),Jy=ds(),ot=q(),ps=us();function Wy(t){if(nA(t)&&(iA(t),oA(t))){Zy(t);return}sA(t,()=>(0,rA.topBoolOrEmptySchema)(t))}Qt.validateFunctionCode=Wy;function sA({gen:t,validateName:e,schema:r,schemaEnv:s,opts:o},n){o.code.es5?t.func(e,(0,v._)`${$.default.data}, ${$.default.valCxt}`,s.$async,()=>{t.code((0,v._)`"use strict"; ${Xu(r,o)}`),Ky(t,o),t.code(n)}):t.func(e,(0,v._)`${$.default.data}, ${Vy(o)}`,s.$async,()=>t.code(Xu(r,o)).code(n))}function Vy(t){return(0,v._)`{${$.default.instancePath}="", ${$.default.parentData}, ${$.default.parentDataProperty}, ${$.default.rootData}=${$.default.data}${t.dynamicRef?(0,v._)`, ${$.default.dynamicAnchors}={}`:v.nil}}={}`}function Ky(t,e){t.if($.default.valCxt,()=>{t.var($.default.instancePath,(0,v._)`${$.default.valCxt}.${$.default.instancePath}`),t.var($.default.parentData,(0,v._)`${$.default.valCxt}.${$.default.parentData}`),t.var($.default.parentDataProperty,(0,v._)`${$.default.valCxt}.${$.default.parentDataProperty}`),t.var($.default.rootData,(0,v._)`${$.default.valCxt}.${$.default.rootData}`),e.dynamicRef&&t.var($.default.dynamicAnchors,(0,v._)`${$.default.valCxt}.${$.default.dynamicAnchors}`)},()=>{t.var($.default.instancePath,(0,v._)`""`),t.var($.default.parentData,(0,v._)`undefined`),t.var($.default.parentDataProperty,(0,v._)`undefined`),t.var($.default.rootData,$.default.data),e.dynamicRef&&t.var($.default.dynamicAnchors,(0,v._)`{}`)})}function Zy(t){let{schema:e,opts:r,gen:s}=t;sA(t,()=>{r.$comment&&e.$comment&&cA(t),sw(t),s.let($.default.vErrors,null),s.let($.default.errors,0),r.unevaluated&&Xy(t),aA(t),iw(t)})}function Xy(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,v._)`${r}.evaluated`),e.if((0,v._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,v._)`${t.evaluated}.props`,(0,v._)`undefined`)),e.if((0,v._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,v._)`${t.evaluated}.items`,(0,v._)`undefined`))}function Xu(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,v._)`/*# sourceURL=${r} */`:v.nil}function ew(t,e){if(nA(t)&&(iA(t),oA(t))){tw(t,e);return}(0,rA.boolOrEmptySchema)(t,e)}function oA({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function nA(t){return typeof t.schema!="boolean"}function tw(t,e){let{schema:r,gen:s,opts:o}=t;o.$comment&&r.$comment&&cA(t),ow(t),nw(t);let n=s.const("_errs",$.default.errors);aA(t,n),s.var(e,(0,v._)`${n} === ${$.default.errors}`)}function iA(t){(0,ot.checkUnknownRules)(t),rw(t)}function aA(t,e){if(t.opts.jtd)return eA(t,[],!1,e);let r=(0,Zu.getSchemaTypes)(t.schema),s=(0,Zu.coerceAndCheckDataType)(t,r);eA(t,r,!s,e)}function rw(t){let{schema:e,errSchemaPath:r,opts:s,self:o}=t;e.$ref&&s.ignoreKeywordsWithRef&&(0,ot.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function sw(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,ot.checkStrictMode)(t,"default is ignored in the schema root")}function ow(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,Jy.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function nw(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function cA({gen:t,schemaEnv:e,schema:r,errSchemaPath:s,opts:o}){let n=r.$comment;if(o.$comment===!0)t.code((0,v._)`${$.default.self}.logger.log(${n})`);else if(typeof o.$comment=="function"){let i=(0,v.str)`${s}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,v._)`${$.default.self}.opts.$comment(${n}, ${i}, ${a}.schema)`)}}function iw(t){let{gen:e,schemaEnv:r,validateName:s,ValidationError:o,opts:n}=t;r.$async?e.if((0,v._)`${$.default.errors} === 0`,()=>e.return($.default.data),()=>e.throw((0,v._)`new ${o}(${$.default.vErrors})`)):(e.assign((0,v._)`${s}.errors`,$.default.vErrors),n.unevaluated&&aw(t),e.return((0,v._)`${$.default.errors} === 0`))}function aw({gen:t,evaluated:e,props:r,items:s}){r instanceof v.Name&&t.assign((0,v._)`${e}.props`,r),s instanceof v.Name&&t.assign((0,v._)`${e}.items`,s)}function eA(t,e,r,s){let{gen:o,schema:n,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(n.$ref&&(c.ignoreKeywordsWithRef||!(0,ot.schemaHasRulesButRef)(n,l))){o.block(()=>uA(t,"$ref",l.all.$ref.definition));return}c.jtd||cw(t,e),o.block(()=>{for(let p of l.rules)A(p);A(l.post)});function A(p){(0,pa.shouldUseGroup)(n,p)&&(p.type?(o.if((0,No.checkDataType)(p.type,i,c.strictNumbers)),tA(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,No.reportTypeError)(t)),o.endIf()):tA(t,p),a||o.if((0,v._)`${$.default.errors} === ${s||0}`))}}function tA(t,e){let{gen:r,schema:s,opts:{useDefaults:o}}=t;o&&(0,Yy.assignDefaults)(t,e.type),r.block(()=>{for(let n of e.rules)(0,pa.shouldUseRule)(s,n)&&uA(t,n.keyword,n.definition,e.type)})}function cw(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(lw(t,e),t.opts.allowUnionTypes||uw(t,e),Aw(t,t.dataTypes))}function lw(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{lA(t.dataTypes,r)||ma(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),pw(t,e)}}function uw(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&ma(t,"use allowUnionTypes to allow union type keyword")}function Aw(t,e){let r=t.self.RULES.all;for(let s in r){let o=r[s];if(typeof o=="object"&&(0,pa.shouldUseRule)(t.schema,o)){let{type:n}=o.definition;n.length&&!n.some(i=>dw(e,i))&&ma(t,`missing type "${n.join(",")}" for keyword "${s}"`)}}}function dw(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function lA(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function pw(t,e){let r=[];for(let s of t.dataTypes)lA(e,s)?r.push(s):e.includes("integer")&&s==="number"&&r.push("integer");t.dataTypes=r}function ma(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,ot.checkStrictMode)(t,e,t.opts.strictTypes)}var zo=class{constructor(e,r,s){if((0,ms.validateKeywordUsage)(e,r,s),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=s,this.data=e.data,this.schema=e.schema[s],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,ot.schemaRefOrVal)(e,this.schema,s,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",AA(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,ms.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${s} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",$.default.errors))}result(e,r,s){this.failResult((0,v.not)(e),r,s)}failResult(e,r,s){this.gen.if(e),s?s():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,v.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,v._)`${r} !== undefined && (${(0,v.or)(this.invalid$data(),e)})`)}error(e,r,s){if(r){this.setParams(r),this._error(e,s),this.setParams({});return}this._error(e,s)}_error(e,r){(e?ps.reportExtraError:ps.reportError)(this,this.def.error,r)}$dataError(){(0,ps.reportError)(this,this.def.$dataError||ps.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,ps.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,s=v.nil){this.gen.block(()=>{this.check$data(e,s),r()})}check$data(e=v.nil,r=v.nil){if(!this.$data)return;let{gen:s,schemaCode:o,schemaType:n,def:i}=this;s.if((0,v.or)((0,v._)`${o} === undefined`,r)),e!==v.nil&&s.assign(e,!0),(n.length||i.validateSchema)&&(s.elseIf(this.invalid$data()),this.$dataError(),e!==v.nil&&s.assign(e,!1)),s.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:s,def:o,it:n}=this;return(0,v.or)(i(),a());function i(){if(s.length){if(!(r instanceof v.Name))throw new Error("ajv implementation error");let c=Array.isArray(s)?s:[s];return(0,v._)`${(0,No.checkDataTypes)(c,r,n.opts.strictNumbers,No.DataType.Wrong)}`}return v.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,v._)`!${c}(${r})`}return v.nil}}subschema(e,r){let s=(0,da.getSubschema)(this.it,e);(0,da.extendSubschemaData)(s,this.it,e),(0,da.extendSubschemaMode)(s,e);let o={...this.it,...s,items:void 0,props:void 0};return ew(o,r),o}mergeEvaluated(e,r){let{it:s,gen:o}=this;s.opts.unevaluated&&(s.props!==!0&&e.props!==void 0&&(s.props=ot.mergeEvaluated.props(o,e.props,s.props,r)),s.items!==!0&&e.items!==void 0&&(s.items=ot.mergeEvaluated.items(o,e.items,s.items,r)))}mergeValidEvaluated(e,r){let{it:s,gen:o}=this;if(s.opts.unevaluated&&(s.props!==!0||s.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,v.Name)),!0}};Qt.KeywordCxt=zo;function uA(t,e,r,s){let o=new zo(t,r,e);"code"in r?r.code(o,s):o.$data&&r.validate?(0,ms.funcKeywordCode)(o,r):"macro"in r?(0,ms.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,ms.funcKeywordCode)(o,r)}var mw=/^\/(?:[^~]|~0|~1)*$/,fw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function AA(t,{dataLevel:e,dataNames:r,dataPathArr:s}){let o,n;if(t==="")return $.default.rootData;if(t[0]==="/"){if(!mw.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,n=$.default.rootData}else{let u=fw.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return s[e-l]}if(l>e)throw new Error(c("data",l));if(n=r[e-l],!o)return n}let i=n,a=o.split("/");for(let u of a)u&&(n=(0,v._)`${n}${(0,v.getProperty)((0,ot.unescapeJsonPointer)(u))}`,i=(0,v._)`${i} && ${n}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Qt.getData=AA});var Uo=Q(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});var fa=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};ga.default=fa});var gs=Q(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});var ha=ds(),Ea=class extends Error{constructor(e,r,s,o){super(o||`can't resolve reference ${s} from id ${r}`),this.missingRef=(0,ha.resolveUrl)(e,r,s),this.missingSchema=(0,ha.normalizeId)((0,ha.getFullPath)(e,this.missingRef))}};ya.default=Ea});var Oo=Q(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.resolveSchema=Ne.getCompilingSchema=Ne.resolveRef=Ne.compileSchema=Ne.SchemaEnv=void 0;var Oe=N(),gw=Uo(),Ut=st(),Le=ds(),dA=q(),hw=fs(),mr=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let s;typeof e.schema=="object"&&(s=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,Le.normalizeId)(s?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=s?.$async,this.refs={}}};Ne.SchemaEnv=mr;function Ca(t){let e=pA.call(this,t);if(e)return e;let r=(0,Le.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:s,lines:o}=this.opts.code,{ownProperties:n}=this.opts,i=new Oe.CodeGen(this.scope,{es5:s,lines:o,ownProperties:n}),a;t.$async&&(a=i.scopeValue("Error",{ref:gw.default,code:(0,Oe._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:Ut.default.data,parentData:Ut.default.parentData,parentDataProperty:Ut.default.parentDataProperty,dataNames:[Ut.default.data],dataPathArr:[Oe.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Oe.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Oe.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Oe._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,hw.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let A=i.toString();l=`${i.scopeRefs(Ut.default.scope)}return ${A}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let m=new Function(`${Ut.default.self}`,`${Ut.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:A,scopeValues:i._values}),this.opts.unevaluated){let{props:g,items:f}=u;m.evaluated={props:g instanceof Oe.Name?void 0:g,items:f instanceof Oe.Name?void 0:f,dynamicProps:g instanceof Oe.Name,dynamicItems:f instanceof Oe.Name},m.source&&(m.source.evaluated=(0,Oe.stringify)(m.evaluated))}return t.validate=m,t}catch(A){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),A}finally{this._compilations.delete(t)}}Ne.compileSchema=Ca;function Ew(t,e,r){var s;r=(0,Le.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let n=Cw.call(this,t,r);if(n===void 0){let i=(s=t.localRefs)===null||s===void 0?void 0:s[r],{schemaId:a}=this.opts;i&&(n=new mr({schema:i,schemaId:a,root:t,baseId:e}))}if(n!==void 0)return t.refs[r]=yw.call(this,n)}Ne.resolveRef=Ew;function yw(t){return(0,Le.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Ca.call(this,t)}function pA(t){for(let e of this._compilations)if(ww(e,t))return e}Ne.getCompilingSchema=pA;function ww(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Cw(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Fo.call(this,t,e)}function Fo(t,e){let r=this.opts.uriResolver.parse(e),s=(0,Le._getFullPath)(this.opts.uriResolver,r),o=(0,Le.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&s===o)return wa.call(this,r,t);let n=(0,Le.normalizeId)(s),i=this.refs[n]||this.schemas[n];if(typeof i=="string"){let a=Fo.call(this,t,i);return typeof a?.schema!="object"?void 0:wa.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Ca.call(this,i),n===(0,Le.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,Le.resolveUrl)(this.opts.uriResolver,o,u)),new mr({schema:a,schemaId:c,root:t,baseId:o})}return wa.call(this,r,i)}}Ne.resolveSchema=Fo;var Iw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function wa(t,{baseId:e,schema:r,root:s}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,dA.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Iw.has(a)&&u&&(e=(0,Le.resolveUrl)(this.opts.uriResolver,e,u))}let n;if(typeof r!="boolean"&&r.$ref&&!(0,dA.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Le.resolveUrl)(this.opts.uriResolver,e,r.$ref);n=Fo.call(this,s,a)}let{schemaId:i}=this.opts;if(n=n||new mr({schema:r,schemaId:i,root:s,baseId:e}),n.schema!==n.root.schema)return n}});var mA=Q((hR,Bw)=>{Bw.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var Qa=Q((ER,wA)=>{"use strict";var Qw=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),gA=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),Ia=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),hA=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),_w=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Ba(t){let e="",r=0,s=0;for(s=0;s<t.length;s++)if(r=t[s].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[s];break}for(s+=1;s<t.length;s++){if(r=t[s].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[s]}return e}var Sw=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function fA(t){return t.length=0,!0}function kw(t,e,r){if(t.length){let s=Ba(t);if(s!=="")e.push(s);else return r.error=!0,!1;t.length=0}return!0}function Mw(t){let e=0,r={error:!1,address:"",zone:""},s=[],o=[],n=!1,i=!1,a=kw;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(n===!0&&(i=!0),!a(o,s,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(n=!0),s.push(":");continue}else if(u==="%"){if(!a(o,s,r))break;a=fA}else{o.push(u);continue}}return o.length&&(a===fA?r.zone=o.join(""):i?s.push(o.join("")):s.push(Ba(o))),r.address=s.join(""),r}function EA(t){if(vw(t,":")<2)return{host:t,isIPV6:!1};let e=Mw(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,s=e.address;return e.zone&&(r+="%"+e.zone,s+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:s}}}function vw(t,e){let r=0;for(let s=0;s<t.length;s++)t[s]===e&&r++;return r}function bw(t){let e=t,r=[],s=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((s=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,s)),e=e.slice(s)}return r.join("")}var xw={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},Rw=/[@/?#:]/g,Dw=/[@/?#]/g;function yA(t,e){let r=e?Dw:Rw;return r.lastIndex=0,t.replace(r,s=>xw[s])}function Tw(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let s=0;s<t.length;s++){if(t[s]==="%"&&s+2<t.length){let o=t.slice(s+1,s+3);if(Ia(o)){let n=o.toUpperCase(),i=String.fromCharCode(parseInt(n,16));e&&hA(i)?r+=i:r+="%"+n,s+=2;continue}}r+=t[s]}return r}function $w(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let s=t.slice(r+1,r+3);if(Ia(s)){let o=s.toUpperCase(),n=String.fromCharCode(parseInt(o,16));n!=="."&&hA(n)?e+=n:e+="%"+o,r+=2;continue}}_w(t[r])?e+=t[r]:e+=escape(t[r])}return e}function Pw(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let s=t.slice(r+1,r+3);if(Ia(s)){e+="%"+s.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function jw(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!gA(r)){let s=EA(r);s.isIPV6===!0?r=`[${s.escapedHost}]`:r=yA(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}wA.exports={nonSimpleDomain:Sw,recomposeAuthority:jw,reescapeHostDelimiters:yA,normalizePercentEncoding:Tw,normalizePathEncoding:$w,escapePreservingEscapes:Pw,removeDotSegments:bw,isIPv4:gA,isUUID:Qw,normalizeIPv6:EA,stringArrayToHexStripped:Ba}});var _A=Q((yR,QA)=>{"use strict";var{isUUID:Nw}=Qa(),zw=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Uw=["http","https","ws","wss","urn","urn:uuid"];function Fw(t){return Uw.indexOf(t)!==-1}function _a(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function CA(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function IA(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function Ow(t){return t.secure=_a(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function Lw(t){if((t.port===(_a(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function qw(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(zw);if(r){let s=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${s}:${e.nid||t.nid}`,n=Sa(o);t.path=void 0,n&&(t=n.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function Gw(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",s=t.nid.toLowerCase(),o=`${r}:${e.nid||s}`,n=Sa(o);n&&(t=n.serialize(t,e));let i=t,a=t.nss;return i.path=`${s||e.nid}:${a}`,e.skipEscape=!0,i}function Hw(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!Nw(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Yw(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var BA={scheme:"http",domainHost:!0,parse:CA,serialize:IA},Jw={scheme:"https",domainHost:BA.domainHost,parse:CA,serialize:IA},Lo={scheme:"ws",domainHost:!0,parse:Ow,serialize:Lw},Ww={scheme:"wss",domainHost:Lo.domainHost,parse:Lo.parse,serialize:Lo.serialize},Vw={scheme:"urn",parse:qw,serialize:Gw,skipNormalize:!0},Kw={scheme:"urn:uuid",parse:Hw,serialize:Yw,skipNormalize:!0},qo={http:BA,https:Jw,ws:Lo,wss:Ww,urn:Vw,"urn:uuid":Kw};Object.setPrototypeOf(qo,null);function Sa(t){return t&&(qo[t]||qo[t.toLowerCase()])||void 0}QA.exports={wsIsSecure:_a,SCHEMES:qo,isValidSchemeName:Fw,getSchemeHandler:Sa}});var xA=Q((wR,Go)=>{"use strict";var{normalizeIPv6:Zw,removeDotSegments:hs,recomposeAuthority:Xw,normalizePercentEncoding:eC,normalizePathEncoding:tC,escapePreservingEscapes:rC,reescapeHostDelimiters:sC,isIPv4:oC,nonSimpleDomain:nC}=Qa(),{SCHEMES:iC,getSchemeHandler:kA}=_A();function aC(t,e){return typeof t=="string"?t=pC(t,e):typeof t=="object"&&(t=fr(Ft(t,e),e)),t}function cC(t,e,r){let s=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=MA(fr(t,s),fr(e,s),s,!0);return s.skipEscape=!0,Ft(o,s)}function MA(t,e,r,s){let o={};return s||(t=fr(Ft(t,r),r),e=fr(Ft(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=hs(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=hs(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=hs(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=hs(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function lC(t,e,r){let s=SA(t,r),o=SA(e,r);return s!==void 0&&o!==void 0&&s.toLowerCase()===o.toLowerCase()}function Ft(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},s=Object.assign({},e),o=[],n=kA(s.scheme||r.scheme);n&&n.serialize&&n.serialize(r,s),r.path!==void 0&&(s.skipEscape?r.path=eC(r.path):(r.path=rC(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),s.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=Xw(r);if(i!==void 0&&(s.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!s.absolutePath&&(!n||!n.absolutePath)&&(a=hs(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var uC=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,AC=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/;function dC(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function vA(t,e){let r=Object.assign({},e),s={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,n=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(AC);i!==null&&i[1].indexOf("\\")!==-1&&(s.error="URI authority must not contain a literal backslash.",o=!0);let a=t.match(uC);if(a){s.scheme=a[1],s.userinfo=a[3],s.host=a[4],s.port=parseInt(a[5],10),s.path=a[6]||"",s.query=a[7],s.fragment=a[8],isNaN(s.port)&&(s.port=a[5]);let c=dC(s,a);if(c!==void 0&&(s.error=s.error||c,o=!0),s.host)if(oC(s.host)===!1){let A=Zw(s.host);s.host=A.host.toLowerCase(),n=A.isIPV6}else n=!0;s.scheme===void 0&&s.userinfo===void 0&&s.host===void 0&&s.port===void 0&&s.query===void 0&&!s.path?s.reference="same-document":s.scheme===void 0?s.reference="relative":s.fragment===void 0?s.reference="absolute":s.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==s.reference&&(s.error=s.error||"URI is not a "+r.reference+" reference.");let u=kA(r.scheme||s.scheme);if(!r.unicodeSupport&&(!u||!u.unicodeSupport)&&s.host&&(r.domainHost||u&&u.domainHost)&&n===!1&&nC(s.host))try{s.host=new URL("http://"+s.host).hostname}catch(l){s.error=s.error||"Host's domain name can not be converted to ASCII: "+l}if((!u||u&&!u.skipNormalize)&&(t.indexOf("%")!==-1&&(s.scheme!==void 0&&(s.scheme=unescape(s.scheme)),s.host!==void 0&&(s.host=sC(unescape(s.host),n))),s.path&&(s.path=tC(s.path)),s.fragment))try{s.fragment=encodeURI(decodeURIComponent(s.fragment))}catch{s.error=s.error||"URI malformed"}u&&u.parse&&u.parse(s,r)}else s.error=s.error||"URI can not be parsed.";return{parsed:s,malformedAuthorityOrPort:o}}function fr(t,e){return vA(t,e).parsed}function pC(t,e){return bA(t,e).normalized}function bA(t,e){let{parsed:r,malformedAuthorityOrPort:s}=vA(t,e);return{normalized:s?t:Ft(r,e),malformedAuthorityOrPort:s}}function SA(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:s}=bA(t,e);return s?void 0:r}if(typeof t=="object")return Ft(t,e)}var ka={SCHEMES:iC,normalize:aC,resolve:cC,resolveComponent:MA,equal:lC,serialize:Ft,parse:fr};Go.exports=ka;Go.exports.default=ka;Go.exports.fastUri=ka});var DA=Q(Ma=>{"use strict";Object.defineProperty(Ma,"__esModule",{value:!0});var RA=xA();RA.code='require("ajv/dist/runtime/uri").default';Ma.default=RA});var FA=Q(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.CodeGen=me.Name=me.nil=me.stringify=me.str=me._=me.KeywordCxt=void 0;var mC=fs();Object.defineProperty(me,"KeywordCxt",{enumerable:!0,get:function(){return mC.KeywordCxt}});var gr=N();Object.defineProperty(me,"_",{enumerable:!0,get:function(){return gr._}});Object.defineProperty(me,"str",{enumerable:!0,get:function(){return gr.str}});Object.defineProperty(me,"stringify",{enumerable:!0,get:function(){return gr.stringify}});Object.defineProperty(me,"nil",{enumerable:!0,get:function(){return gr.nil}});Object.defineProperty(me,"Name",{enumerable:!0,get:function(){return gr.Name}});Object.defineProperty(me,"CodeGen",{enumerable:!0,get:function(){return gr.CodeGen}});var fC=Uo(),NA=gs(),gC=ra(),Es=Oo(),hC=N(),ys=ds(),Ho=As(),ba=q(),TA=mA(),EC=DA(),zA=(t,e)=>new RegExp(t,e);zA.code="new RegExp";var yC=["removeAdditional","useDefaults","coerceTypes"],wC=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),CC={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},IC={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},$A=200;function BC(t){var e,r,s,o,n,i,a,c,u,l,A,p,m,g,f,h,w,C,I,b,E,B,P,se,oe;let _e=t.strict,Gr=(e=t.code)===null||e===void 0?void 0:e.optimize,io=Gr===!0||Gr===void 0?1:Gr||0,ao=(s=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&s!==void 0?s:zA,pt=(o=t.uriResolver)!==null&&o!==void 0?o:EC.default;return{strictSchema:(i=(n=t.strictSchema)!==null&&n!==void 0?n:_e)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:_e)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:_e)!==null&&l!==void 0?l:"log",strictTuples:(p=(A=t.strictTuples)!==null&&A!==void 0?A:_e)!==null&&p!==void 0?p:"log",strictRequired:(g=(m=t.strictRequired)!==null&&m!==void 0?m:_e)!==null&&g!==void 0?g:!1,code:t.code?{...t.code,optimize:io,regExp:ao}:{optimize:io,regExp:ao},loopRequired:(f=t.loopRequired)!==null&&f!==void 0?f:$A,loopEnum:(h=t.loopEnum)!==null&&h!==void 0?h:$A,meta:(w=t.meta)!==null&&w!==void 0?w:!0,messages:(C=t.messages)!==null&&C!==void 0?C:!0,inlineRefs:(I=t.inlineRefs)!==null&&I!==void 0?I:!0,schemaId:(b=t.schemaId)!==null&&b!==void 0?b:"$id",addUsedSchema:(E=t.addUsedSchema)!==null&&E!==void 0?E:!0,validateSchema:(B=t.validateSchema)!==null&&B!==void 0?B:!0,validateFormats:(P=t.validateFormats)!==null&&P!==void 0?P:!0,unicodeRegExp:(se=t.unicodeRegExp)!==null&&se!==void 0?se:!0,int32range:(oe=t.int32range)!==null&&oe!==void 0?oe:!0,uriResolver:pt}}var ws=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...BC(e)};let{es5:r,lines:s}=this.opts.code;this.scope=new hC.ValueScope({scope:{},prefixes:wC,es5:r,lines:s}),this.logger=vC(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,gC.getRules)(),PA.call(this,CC,e,"NOT SUPPORTED"),PA.call(this,IC,e,"DEPRECATED","warn"),this._metaOpts=kC.call(this),e.formats&&_C.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&SC.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),QC.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:s}=this.opts,o=TA;s==="id"&&(o={...TA},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[s],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let s;if(typeof e=="string"){if(s=this.getSchema(e),!s)throw new Error(`no schema with key or ref "${e}"`)}else s=this.compile(e);let o=s(r);return"$async"in s||(this.errors=s.errors),o}compile(e,r){let s=this._addSchema(e,r);return s.validate||this._compileSchemaEnv(s)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:s}=this.opts;return o.call(this,e,r);async function o(l,A){await n.call(this,l.$schema);let p=this._addSchema(l,A);return p.validate||i.call(this,p)}async function n(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(A){if(!(A instanceof NA.default))throw A;return a.call(this,A),await c.call(this,A.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:A}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${A} cannot be resolved`)}async function c(l){let A=await u.call(this,l);this.refs[l]||await n.call(this,A.$schema),this.refs[l]||this.addSchema(A,l,r)}async function u(l){let A=this._loading[l];if(A)return A;try{return await(this._loading[l]=s(l))}finally{delete this._loading[l]}}}addSchema(e,r,s,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,s,o);return this}let n;if(typeof e=="object"){let{schemaId:i}=this.opts;if(n=e[i],n!==void 0&&typeof n!="string")throw new Error(`schema ${i} must be string`)}return r=(0,ys.normalizeId)(r||n),this._checkUnique(r),this.schemas[r]=this._addSchema(e,s,r,o,!0),this}addMetaSchema(e,r,s=this.opts.validateSchema){return this.addSchema(e,r,!0,s),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let s;if(s=e.$schema,s!==void 0&&typeof s!="string")throw new Error("$schema must be a string");if(s=s||this.opts.defaultMeta||this.defaultMeta(),!s)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(s,e);if(!o&&r){let n="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(n);else throw new Error(n)}return o}getSchema(e){let r;for(;typeof(r=jA.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:s}=this.opts,o=new Es.SchemaEnv({schema:{},schemaId:s});if(r=Es.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=jA.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let s=e[this.opts.schemaId];return s&&(s=(0,ys.normalizeId)(s),delete this.schemas[s],delete this.refs[s]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let s;if(typeof e=="string")s=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=s);else if(typeof e=="object"&&r===void 0){if(r=e,s=r.keyword,Array.isArray(s)&&!s.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(xC.call(this,s,r),!r)return(0,ba.eachItem)(s,n=>va.call(this,n)),this;DC.call(this,r);let o={...r,type:(0,Ho.getJSONTypes)(r.type),schemaType:(0,Ho.getJSONTypes)(r.schemaType)};return(0,ba.eachItem)(s,o.type.length===0?n=>va.call(this,n,o):n=>o.type.forEach(i=>va.call(this,n,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let s of r.rules){let o=s.rules.findIndex(n=>n.keyword===e);o>=0&&s.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:s="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${s}${o.instancePath} ${o.message}`).reduce((o,n)=>o+r+n)}$dataMetaSchema(e,r){let s=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let n=o.split("/").slice(1),i=e;for(let a of n)i=i[a];for(let a in s){let c=s[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=UA(l))}}return e}_removeAllSchemas(e,r){for(let s in e){let o=e[s];(!r||r.test(s))&&(typeof o=="string"?delete e[s]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[s]))}}_addSchema(e,r,s,o=this.opts.validateSchema,n=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;s=(0,ys.normalizeId)(i||s);let u=ys.getSchemaRefs.call(this,e,s);return c=new Es.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:s,localRefs:u}),this._cache.set(c.schema,c),n&&!s.startsWith("#")&&(s&&this._checkUnique(s),this.refs[s]=c),o&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):Es.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{Es.compileSchema.call(this,e)}finally{this.opts=r}}};ws.ValidationError=fC.default;ws.MissingRefError=NA.default;me.default=ws;function PA(t,e,r,s="error"){for(let o in t){let n=o;n in e&&this.logger[s](`${r}: option ${o}. ${t[n]}`)}}function jA(t){return t=(0,ys.normalizeId)(t),this.schemas[t]||this.refs[t]}function QC(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function _C(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function SC(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function kC(){let t={...this.opts};for(let e of yC)delete t[e];return t}var MC={log(){},warn(){},error(){}};function vC(t){if(t===!1)return MC;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var bC=/^[a-z_$][a-z0-9_$:-]*$/i;function xC(t,e){let{RULES:r}=this;if((0,ba.eachItem)(t,s=>{if(r.keywords[s])throw new Error(`Keyword ${s} is already defined`);if(!bC.test(s))throw new Error(`Keyword ${s} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function va(t,e,r){var s;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:n}=this,i=o?n.post:n.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},n.rules.push(i)),n.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,Ho.getJSONTypes)(e.type),schemaType:(0,Ho.getJSONTypes)(e.schemaType)}};e.before?RC.call(this,i,a,e.before):i.rules.push(a),n.all[t]=a,(s=e.implements)===null||s===void 0||s.forEach(c=>this.addKeyword(c))}function RC(t,e,r){let s=t.rules.findIndex(o=>o.keyword===r);s>=0?t.rules.splice(s,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function DC(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=UA(e)),t.validateSchema=this.compile(e,!0))}var TC={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function UA(t){return{anyOf:[t,TC]}}});var OA=Q(xa=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});var $C={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};xa.default=$C});var HA=Q(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.callRef=Ot.getValidate=void 0;var PC=gs(),LA=je(),be=N(),hr=st(),qA=Oo(),Yo=q(),jC={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:s}=t,{baseId:o,schemaEnv:n,validateName:i,opts:a,self:c}=s,{root:u}=n;if((r==="#"||r==="#/")&&o===u.baseId)return A();let l=qA.resolveRef.call(c,u,o,r);if(l===void 0)throw new PC.default(s.opts.uriResolver,o,r);if(l instanceof qA.SchemaEnv)return p(l);return m(l);function A(){if(n===u)return Jo(t,i,n,n.$async);let g=e.scopeValue("root",{ref:u});return Jo(t,(0,be._)`${g}.validate`,u,u.$async)}function p(g){let f=GA(t,g);Jo(t,f,g,g.$async)}function m(g){let f=e.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,be.stringify)(g)}:{ref:g}),h=e.name("valid"),w=t.subschema({schema:g,dataTypes:[],schemaPath:be.nil,topSchemaRef:f,errSchemaPath:r},h);t.mergeEvaluated(w),t.ok(h)}}};function GA(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,be._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Ot.getValidate=GA;function Jo(t,e,r,s){let{gen:o,it:n}=t,{allErrors:i,schemaEnv:a,opts:c}=n,u=c.passContext?hr.default.this:be.nil;s?l():A();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let g=o.let("valid");o.try(()=>{o.code((0,be._)`await ${(0,LA.callValidateCode)(t,e,u)}`),m(e),i||o.assign(g,!0)},f=>{o.if((0,be._)`!(${f} instanceof ${n.ValidationError})`,()=>o.throw(f)),p(f),i||o.assign(g,!1)}),t.ok(g)}function A(){t.result((0,LA.callValidateCode)(t,e,u),()=>m(e),()=>p(e))}function p(g){let f=(0,be._)`${g}.errors`;o.assign(hr.default.vErrors,(0,be._)`${hr.default.vErrors} === null ? ${f} : ${hr.default.vErrors}.concat(${f})`),o.assign(hr.default.errors,(0,be._)`${hr.default.vErrors}.length`)}function m(g){var f;if(!n.opts.unevaluated)return;let h=(f=r?.validate)===null||f===void 0?void 0:f.evaluated;if(n.props!==!0)if(h&&!h.dynamicProps)h.props!==void 0&&(n.props=Yo.mergeEvaluated.props(o,h.props,n.props));else{let w=o.var("props",(0,be._)`${g}.evaluated.props`);n.props=Yo.mergeEvaluated.props(o,w,n.props,be.Name)}if(n.items!==!0)if(h&&!h.dynamicItems)h.items!==void 0&&(n.items=Yo.mergeEvaluated.items(o,h.items,n.items));else{let w=o.var("items",(0,be._)`${g}.evaluated.items`);n.items=Yo.mergeEvaluated.items(o,w,n.items,be.Name)}}}Ot.callRef=Jo;Ot.default=jC});var YA=Q(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});var NC=OA(),zC=HA(),UC=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",NC.default,zC.default];Ra.default=UC});var JA=Q(Da=>{"use strict";Object.defineProperty(Da,"__esModule",{value:!0});var Wo=N(),_t=Wo.operators,Vo={maximum:{okStr:"<=",ok:_t.LTE,fail:_t.GT},minimum:{okStr:">=",ok:_t.GTE,fail:_t.LT},exclusiveMaximum:{okStr:"<",ok:_t.LT,fail:_t.GTE},exclusiveMinimum:{okStr:">",ok:_t.GT,fail:_t.LTE}},FC={message:({keyword:t,schemaCode:e})=>(0,Wo.str)`must be ${Vo[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Wo._)`{comparison: ${Vo[t].okStr}, limit: ${e}}`},OC={keyword:Object.keys(Vo),type:"number",schemaType:"number",$data:!0,error:FC,code(t){let{keyword:e,data:r,schemaCode:s}=t;t.fail$data((0,Wo._)`${r} ${Vo[e].fail} ${s} || isNaN(${r})`)}};Da.default=OC});var WA=Q(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});var Cs=N(),LC={message:({schemaCode:t})=>(0,Cs.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Cs._)`{multipleOf: ${t}}`},qC={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:LC,code(t){let{gen:e,data:r,schemaCode:s,it:o}=t,n=o.opts.multipleOfPrecision,i=e.let("res"),a=n?(0,Cs._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${n}`:(0,Cs._)`${i} !== parseInt(${i})`;t.fail$data((0,Cs._)`(${s} === 0 || (${i} = ${r}/${s}, ${a}))`)}};Ta.default=qC});var KA=Q($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});function VA(t){let e=t.length,r=0,s=0,o;for(;s<e;)r++,o=t.charCodeAt(s++),o>=55296&&o<=56319&&s<e&&(o=t.charCodeAt(s),(o&64512)===56320&&s++);return r}$a.default=VA;VA.code='require("ajv/dist/runtime/ucs2length").default'});var ZA=Q(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});var Lt=N(),GC=q(),HC=KA(),YC={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Lt.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Lt._)`{limit: ${t}}`},JC={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:YC,code(t){let{keyword:e,data:r,schemaCode:s,it:o}=t,n=e==="maxLength"?Lt.operators.GT:Lt.operators.LT,i=o.opts.unicode===!1?(0,Lt._)`${r}.length`:(0,Lt._)`${(0,GC.useFunc)(t.gen,HC.default)}(${r})`;t.fail$data((0,Lt._)`${i} ${n} ${s}`)}};Pa.default=JC});var XA=Q(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});var WC=je(),VC=q(),Er=N(),KC={message:({schemaCode:t})=>(0,Er.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,Er._)`{pattern: ${t}}`},ZC={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:KC,code(t){let{gen:e,data:r,$data:s,schema:o,schemaCode:n,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(s){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Er._)`new RegExp`:(0,VC.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,Er._)`${u}(${n}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,Er._)`!${l}`)}else{let c=(0,WC.usePattern)(t,o);t.fail$data((0,Er._)`!${c}.test(${r})`)}}};ja.default=ZC});var ed=Q(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});var Is=N(),XC={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Is.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Is._)`{limit: ${t}}`},eI={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:XC,code(t){let{keyword:e,data:r,schemaCode:s}=t,o=e==="maxProperties"?Is.operators.GT:Is.operators.LT;t.fail$data((0,Is._)`Object.keys(${r}).length ${o} ${s}`)}};Na.default=eI});var td=Q(za=>{"use strict";Object.defineProperty(za,"__esModule",{value:!0});var Bs=je(),Qs=N(),tI=q(),rI={message:({params:{missingProperty:t}})=>(0,Qs.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Qs._)`{missingProperty: ${t}}`},sI={keyword:"required",type:"object",schemaType:"array",$data:!0,error:rI,code(t){let{gen:e,schema:r,schemaCode:s,data:o,$data:n,it:i}=t,{opts:a}=i;if(!n&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let m=t.parentSchema.properties,{definedProperties:g}=t.it;for(let f of r)if(m?.[f]===void 0&&!g.has(f)){let h=i.schemaEnv.baseId+i.errSchemaPath,w=`required property "${f}" is not defined at "${h}" (strictRequired)`;(0,tI.checkStrictMode)(i,w,i.opts.strictRequired)}}function u(){if(c||n)t.block$data(Qs.nil,A);else for(let m of r)(0,Bs.checkReportMissingProp)(t,m)}function l(){let m=e.let("missing");if(c||n){let g=e.let("valid",!0);t.block$data(g,()=>p(m,g)),t.ok(g)}else e.if((0,Bs.checkMissingProp)(t,r,m)),(0,Bs.reportMissingProp)(t,m),e.else()}function A(){e.forOf("prop",s,m=>{t.setParams({missingProperty:m}),e.if((0,Bs.noPropertyInData)(e,o,m,a.ownProperties),()=>t.error())})}function p(m,g){t.setParams({missingProperty:m}),e.forOf(m,s,()=>{e.assign(g,(0,Bs.propertyInData)(e,o,m,a.ownProperties)),e.if((0,Qs.not)(g),()=>{t.error(),e.break()})},Qs.nil)}}};za.default=sI});var rd=Q(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});var _s=N(),oI={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,_s.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,_s._)`{limit: ${t}}`},nI={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:oI,code(t){let{keyword:e,data:r,schemaCode:s}=t,o=e==="maxItems"?_s.operators.GT:_s.operators.LT;t.fail$data((0,_s._)`${r}.length ${o} ${s}`)}};Ua.default=nI});var Ko=Q(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});var sd=ua();sd.code='require("ajv/dist/runtime/equal").default';Fa.default=sd});var od=Q(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});var Oa=As(),fe=N(),iI=q(),aI=Ko(),cI={message:({params:{i:t,j:e}})=>(0,fe.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,fe._)`{i: ${t}, j: ${e}}`},lI={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:cI,code(t){let{gen:e,data:r,$data:s,schema:o,parentSchema:n,schemaCode:i,it:a}=t;if(!s&&!o)return;let c=e.let("valid"),u=n.items?(0,Oa.getSchemaTypes)(n.items):[];t.block$data(c,l,(0,fe._)`${i} === false`),t.ok(c);function l(){let g=e.let("i",(0,fe._)`${r}.length`),f=e.let("j");t.setParams({i:g,j:f}),e.assign(c,!0),e.if((0,fe._)`${g} > 1`,()=>(A()?p:m)(g,f))}function A(){return u.length>0&&!u.some(g=>g==="object"||g==="array")}function p(g,f){let h=e.name("item"),w=(0,Oa.checkDataTypes)(u,h,a.opts.strictNumbers,Oa.DataType.Wrong),C=e.const("indices",(0,fe._)`{}`);e.for((0,fe._)`;${g}--;`,()=>{e.let(h,(0,fe._)`${r}[${g}]`),e.if(w,(0,fe._)`continue`),u.length>1&&e.if((0,fe._)`typeof ${h} == "string"`,(0,fe._)`${h} += "_"`),e.if((0,fe._)`typeof ${C}[${h}] == "number"`,()=>{e.assign(f,(0,fe._)`${C}[${h}]`),t.error(),e.assign(c,!1).break()}).code((0,fe._)`${C}[${h}] = ${g}`)})}function m(g,f){let h=(0,iI.useFunc)(e,aI.default),w=e.name("outer");e.label(w).for((0,fe._)`;${g}--;`,()=>e.for((0,fe._)`${f} = ${g}; ${f}--;`,()=>e.if((0,fe._)`${h}(${r}[${g}], ${r}[${f}])`,()=>{t.error(),e.assign(c,!1).break(w)})))}}};La.default=lI});var nd=Q(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});var qa=N(),uI=q(),AI=Ko(),dI={message:"must be equal to constant",params:({schemaCode:t})=>(0,qa._)`{allowedValue: ${t}}`},pI={keyword:"const",$data:!0,error:dI,code(t){let{gen:e,data:r,$data:s,schemaCode:o,schema:n}=t;s||n&&typeof n=="object"?t.fail$data((0,qa._)`!${(0,uI.useFunc)(e,AI.default)}(${r}, ${o})`):t.fail((0,qa._)`${n} !== ${r}`)}};Ga.default=pI});var id=Q(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});var Ss=N(),mI=q(),fI=Ko(),gI={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Ss._)`{allowedValues: ${t}}`},hI={keyword:"enum",schemaType:"array",$data:!0,error:gI,code(t){let{gen:e,data:r,$data:s,schema:o,schemaCode:n,it:i}=t;if(!s&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,mI.useFunc)(e,fI.default)),l;if(a||s)l=e.let("valid"),t.block$data(l,A);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=e.const("vSchema",n);l=(0,Ss.or)(...o.map((g,f)=>p(m,f)))}t.pass(l);function A(){e.assign(l,!1),e.forOf("v",n,m=>e.if((0,Ss._)`${u()}(${r}, ${m})`,()=>e.assign(l,!0).break()))}function p(m,g){let f=o[g];return typeof f=="object"&&f!==null?(0,Ss._)`${u()}(${r}, ${m}[${g}])`:(0,Ss._)`${r} === ${f}`}}};Ha.default=hI});var ad=Q(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});var EI=JA(),yI=WA(),wI=ZA(),CI=XA(),II=ed(),BI=td(),QI=rd(),_I=od(),SI=nd(),kI=id(),MI=[EI.default,yI.default,wI.default,CI.default,II.default,BI.default,QI.default,_I.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},SI.default,kI.default];Ya.default=MI});var Wa=Q(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.validateAdditionalItems=void 0;var qt=N(),Ja=q(),vI={message:({params:{len:t}})=>(0,qt.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,qt._)`{limit: ${t}}`},bI={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:vI,code(t){let{parentSchema:e,it:r}=t,{items:s}=e;if(!Array.isArray(s)){(0,Ja.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}cd(t,s)}};function cd(t,e){let{gen:r,schema:s,data:o,keyword:n,it:i}=t;i.items=!0;let a=r.const("len",(0,qt._)`${o}.length`);if(s===!1)t.setParams({len:e.length}),t.pass((0,qt._)`${a} <= ${e.length}`);else if(typeof s=="object"&&!(0,Ja.alwaysValidSchema)(i,s)){let u=r.var("valid",(0,qt._)`${a} <= ${e.length}`);r.if((0,qt.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:n,dataProp:l,dataPropType:Ja.Type.Num},u),i.allErrors||r.if((0,qt.not)(u),()=>r.break())})}}ks.validateAdditionalItems=cd;ks.default=bI});var Va=Q(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});Ms.validateTuple=void 0;var ld=N(),Zo=q(),xI=je(),RI={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return ud(t,"additionalItems",e);r.items=!0,!(0,Zo.alwaysValidSchema)(r,e)&&t.ok((0,xI.validateArray)(t))}};function ud(t,e,r=t.schema){let{gen:s,parentSchema:o,data:n,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Zo.mergeEvaluated.items(s,r.length,a.items));let c=s.name("valid"),u=s.const("len",(0,ld._)`${n}.length`);r.forEach((A,p)=>{(0,Zo.alwaysValidSchema)(a,A)||(s.if((0,ld._)`${u} > ${p}`,()=>t.subschema({keyword:i,schemaProp:p,dataProp:p},c)),t.ok(c))});function l(A){let{opts:p,errSchemaPath:m}=a,g=r.length,f=g===A.minItems&&(g===A.maxItems||A[e]===!1);if(p.strictTuples&&!f){let h=`"${i}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,Zo.checkStrictMode)(a,h,p.strictTuples)}}}Ms.validateTuple=ud;Ms.default=RI});var Ad=Q(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});var DI=Va(),TI={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,DI.validateTuple)(t,"items")};Ka.default=TI});var pd=Q(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});var dd=N(),$I=q(),PI=je(),jI=Wa(),NI={message:({params:{len:t}})=>(0,dd.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,dd._)`{limit: ${t}}`},zI={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:NI,code(t){let{schema:e,parentSchema:r,it:s}=t,{prefixItems:o}=r;s.items=!0,!(0,$I.alwaysValidSchema)(s,e)&&(o?(0,jI.validateAdditionalItems)(t,o):t.ok((0,PI.validateArray)(t)))}};Za.default=zI});var md=Q(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});var ze=N(),Xo=q(),UI={message:({params:{min:t,max:e}})=>e===void 0?(0,ze.str)`must contain at least ${t} valid item(s)`:(0,ze.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,ze._)`{minContains: ${t}}`:(0,ze._)`{minContains: ${t}, maxContains: ${e}}`},FI={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:UI,code(t){let{gen:e,schema:r,parentSchema:s,data:o,it:n}=t,i,a,{minContains:c,maxContains:u}=s;n.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,ze._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,Xo.checkStrictMode)(n,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,Xo.checkStrictMode)(n,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Xo.alwaysValidSchema)(n,r)){let f=(0,ze._)`${l} >= ${i}`;a!==void 0&&(f=(0,ze._)`${f} && ${l} <= ${a}`),t.pass(f);return}n.items=!0;let A=e.name("valid");a===void 0&&i===1?m(A,()=>e.if(A,()=>e.break())):i===0?(e.let(A,!0),a!==void 0&&e.if((0,ze._)`${o}.length > 0`,p)):(e.let(A,!1),p()),t.result(A,()=>t.reset());function p(){let f=e.name("_valid"),h=e.let("count",0);m(f,()=>e.if(f,()=>g(h)))}function m(f,h){e.forRange("i",0,l,w=>{t.subschema({keyword:"contains",dataProp:w,dataPropType:Xo.Type.Num,compositeRule:!0},f),h()})}function g(f){e.code((0,ze._)`${f}++`),a===void 0?e.if((0,ze._)`${f} >= ${i}`,()=>e.assign(A,!0).break()):(e.if((0,ze._)`${f} > ${a}`,()=>e.assign(A,!1).break()),i===1?e.assign(A,!0):e.if((0,ze._)`${f} >= ${i}`,()=>e.assign(A,!0)))}}};Xa.default=FI});var hd=Q(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.validateSchemaDeps=Ke.validatePropertyDeps=Ke.error=void 0;var ec=N(),OI=q(),vs=je();Ke.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let s=e===1?"property":"properties";return(0,ec.str)`must have ${s} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:s}})=>(0,ec._)`{property: ${t},
|
|
9
9
|
missingProperty: ${s},
|
|
10
10
|
depsCount: ${e},
|
|
11
|
-
deps: ${r}}`};var LI={keyword:"dependencies",type:"object",schemaType:"object",error:Ke.error,code(t){let[e,r]=GI(t);fA(t,e),gA(t,r)}};function GI({schema:t}){let e={},r={};for(let s in t){if(s==="__proto__")continue;let o=Array.isArray(t[s])?e:r;o[s]=t[s]}return[e,r]}function fA(t,e=t.schema){let{gen:r,data:s,it:o}=t;if(Object.keys(e).length===0)return;let n=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,Ms.propertyInData)(r,s,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,Ms.checkReportMissingProp)(t,u)}):(r.if((0,ec._)`${c} && (${(0,Ms.checkMissingProp)(t,a,n)})`),(0,Ms.reportMissingProp)(t,n),r.else())}}Ke.validatePropertyDeps=fA;function gA(t,e=t.schema){let{gen:r,data:s,keyword:o,it:n}=t,i=r.name("valid");for(let a in e)(0,OI.alwaysValidSchema)(n,e[a])||(r.if((0,Ms.propertyInData)(r,s,a,n.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}Ke.validateSchemaDeps=gA;Ke.default=LI});var EA=B(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});var yA=N(),HI=L(),YI={message:"property name must be valid",params:({params:t})=>(0,yA._)`{propertyName: ${t.propertyName}}`},JI={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:YI,code(t){let{gen:e,schema:r,data:s,it:o}=t;if((0,HI.alwaysValidSchema)(o,r))return;let n=e.name("valid");e.forIn("key",s,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},n),e.if((0,yA.not)(n),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(n)}};tc.default=JI});var sc=B(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});var en=je(),Le=N(),WI=st(),tn=L(),VI={message:"must NOT have additional properties",params:({params:t})=>(0,Le._)`{additionalProperty: ${t.additionalProperty}}`},KI={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:VI,code(t){let{gen:e,schema:r,parentSchema:s,data:o,errsCount:n,it:i}=t;if(!n)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,tn.alwaysValidSchema)(i,r))return;let u=(0,en.allSchemaProperties)(s.properties),l=(0,en.allSchemaProperties)(s.patternProperties);d(),t.ok((0,Le._)`${n} === ${WI.default.errors}`);function d(){e.forIn("key",o,h=>{!u.length&&!l.length?g(h):e.if(A(h),()=>g(h))})}function A(h){let y;if(u.length>8){let C=(0,tn.schemaRefOrVal)(i,s.properties,"properties");y=(0,en.isOwnProperty)(e,C,h)}else u.length?y=(0,Le.or)(...u.map(C=>(0,Le._)`${h} === ${C}`)):y=Le.nil;return l.length&&(y=(0,Le.or)(y,...l.map(C=>(0,Le._)`${(0,en.usePattern)(t,C)}.test(${h})`))),(0,Le.not)(y)}function m(h){e.code((0,Le._)`delete ${o}[${h}]`)}function g(h){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(h);return}if(r===!1){t.setParams({additionalProperty:h}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,tn.alwaysValidSchema)(i,r)){let y=e.name("valid");c.removeAdditional==="failing"?(f(h,y,!1),e.if((0,Le.not)(y),()=>{t.reset(),m(h)})):(f(h,y),a||e.if((0,Le.not)(y),()=>e.break()))}}function f(h,y,C){let Q={keyword:"additionalProperties",dataProp:h,dataPropType:tn.Type.Str};C===!1&&Object.assign(Q,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(Q,y)}}};rc.default=KI});var IA=B(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});var ZI=fs(),wA=je(),oc=L(),CA=sc(),XI={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:s,data:o,it:n}=t;n.opts.removeAdditional==="all"&&s.additionalProperties===void 0&&CA.default.code(new ZI.KeywordCxt(n,CA.default,"additionalProperties"));let i=(0,wA.allSchemaProperties)(r);for(let d of i)n.definedProperties.add(d);n.opts.unevaluated&&i.length&&n.props!==!0&&(n.props=oc.mergeEvaluated.props(e,(0,oc.toHash)(i),n.props));let a=i.filter(d=>!(0,oc.alwaysValidSchema)(n,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,wA.propertyInData)(e,o,d,n.opts.ownProperties)),l(d),n.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return n.opts.useDefaults&&!n.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};nc.default=XI});var kA=B(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});var BA=je(),rn=N(),QA=L(),_A=L(),eB={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:s,parentSchema:o,it:n}=t,{opts:i}=n,a=(0,BA.allSchemaProperties)(r),c=a.filter(f=>(0,QA.alwaysValidSchema)(n,r[f]));if(a.length===0||c.length===a.length&&(!n.opts.unevaluated||n.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");n.props!==!0&&!(n.props instanceof rn.Name)&&(n.props=(0,_A.evaluatedPropsToName)(e,n.props));let{props:d}=n;A();function A(){for(let f of a)u&&m(f),n.allErrors?g(f):(e.var(l,!0),g(f),e.if(l))}function m(f){for(let h in u)new RegExp(f).test(h)&&(0,QA.checkStrictMode)(n,`property ${h} matches pattern ${f} (use allowMatchingProperties)`)}function g(f){e.forIn("key",s,h=>{e.if((0,rn._)`${(0,BA.usePattern)(t,f)}.test(${h})`,()=>{let y=c.includes(f);y||t.subschema({keyword:"patternProperties",schemaProp:f,dataProp:h,dataPropType:_A.Type.Str},l),n.opts.unevaluated&&d!==!0?e.assign((0,rn._)`${d}[${h}]`,!0):!y&&!n.allErrors&&e.if((0,rn.not)(l),()=>e.break())})})}}};ic.default=eB});var SA=B(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});var tB=L(),rB={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:s}=t;if((0,tB.alwaysValidSchema)(s,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};ac.default=rB});var vA=B(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var sB=je(),oB={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:sB.validateUnion,error:{message:"must match a schema in anyOf"}};cc.default=oB});var MA=B(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var sn=N(),nB=L(),iB={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,sn._)`{passingSchemas: ${t.passing}}`},aB={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:iB,code(t){let{gen:e,schema:r,parentSchema:s,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&s.discriminator)return;let n=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){n.forEach((l,d)=>{let A;(0,nB.alwaysValidSchema)(o,l)?e.var(c,!0):A=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,sn._)`${c} && ${i}`).assign(i,!1).assign(a,(0,sn._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),A&&t.mergeEvaluated(A,sn.Name)})})}}};lc.default=aB});var bA=B(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});var cB=L(),lB={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((n,i)=>{if((0,cB.alwaysValidSchema)(s,n))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};uc.default=lB});var TA=B(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});var on=N(),RA=L(),uB={message:({params:t})=>(0,on.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,on._)`{failingKeyword: ${t.ifClause}}`},dB={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:uB,code(t){let{gen:e,parentSchema:r,it:s}=t;r.then===void 0&&r.else===void 0&&(0,RA.checkStrictMode)(s,'"if" without "then" and "else" is ignored');let o=xA(s,"then"),n=xA(s,"else");if(!o&&!n)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&n){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,on.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let A=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(A,i),d?e.assign(d,(0,on._)`${l}`):t.setParams({ifClause:l})}}}};function xA(t,e){let r=t.schema[e];return r!==void 0&&!(0,RA.alwaysValidSchema)(t,r)}dc.default=dB});var DA=B(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});var AB=L(),pB={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,AB.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};Ac.default=pB});var $A=B(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var mB=Wa(),fB=dA(),gB=Va(),hB=pA(),yB=mA(),EB=hA(),wB=EA(),CB=sc(),IB=IA(),BB=kA(),QB=SA(),_B=vA(),kB=MA(),SB=bA(),vB=TA(),MB=DA();function bB(t=!1){let e=[QB.default,_B.default,kB.default,SB.default,vB.default,MB.default,wB.default,CB.default,EB.default,IB.default,BB.default];return t?e.push(fB.default,hB.default):e.push(mB.default,gB.default),e.push(yB.default),e}pc.default=bB});var PA=B(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});var ie=N(),xB={message:({schemaCode:t})=>(0,ie.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ie._)`{format: ${t}}`},RB={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:xB,code(t,e){let{gen:r,data:s,$data:o,schema:n,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?A():m();function A(){let g=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),f=r.const("fDef",(0,ie._)`${g}[${i}]`),h=r.let("fType"),y=r.let("format");r.if((0,ie._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>r.assign(h,(0,ie._)`${f}.type || "string"`).assign(y,(0,ie._)`${f}.validate`),()=>r.assign(h,(0,ie._)`"string"`).assign(y,f)),t.fail$data((0,ie.or)(C(),Q()));function C(){return c.strictSchema===!1?ie.nil:(0,ie._)`${i} && !${y}`}function Q(){let R=l.$async?(0,ie._)`(${f}.async ? await ${y}(${s}) : ${y}(${s}))`:(0,ie._)`${y}(${s})`,w=(0,ie._)`(typeof ${y} == "function" ? ${R} : ${y}.test(${s}))`;return(0,ie._)`${y} && ${y} !== true && ${h} === ${e} && !${w}`}}function m(){let g=d.formats[n];if(!g){C();return}if(g===!0)return;let[f,h,y]=Q(g);f===e&&t.pass(R());function C(){if(c.strictSchema===!1){d.logger.warn(w());return}throw new Error(w());function w(){return`unknown format "${n}" ignored in schema at path "${u}"`}}function Q(w){let I=w instanceof RegExp?(0,ie.regexpCode)(w):c.code.formats?(0,ie._)`${c.code.formats}${(0,ie.getProperty)(n)}`:void 0,P=r.scopeValue("formats",{key:n,ref:w,code:I});return typeof w=="object"&&!(w instanceof RegExp)?[w.type||"string",w.validate,(0,ie._)`${P}.validate`]:["string",w,P]}function R(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ie._)`await ${y}(${s})`}return typeof h=="function"?(0,ie._)`${y}(${s})`:(0,ie._)`${y}.test(${s})`}}}};mc.default=RB});var jA=B(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});var TB=PA(),DB=[TB.default];fc.default=DB});var NA=B(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.contentVocabulary=Er.metadataVocabulary=void 0;Er.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Er.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var FA=B(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});var $B=Yd(),PB=aA(),jB=$A(),NB=jA(),zA=NA(),zB=[$B.default,PB.default,(0,jB.default)(),NB.default,zA.metadataVocabulary,zA.contentVocabulary];gc.default=zB});var qA=B(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.DiscrError=void 0;var UA;(function(t){t.Tag="tag",t.Mapping="mapping"})(UA||(nn.DiscrError=UA={}))});var LA=B(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});var wr=N(),hc=qA(),OA=qo(),FB=gs(),UB=L(),qB={message:({params:{discrError:t,tagName:e}})=>t===hc.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,wr._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},OB={keyword:"discriminator",type:"object",schemaType:"object",error:qB,code(t){let{gen:e,data:r,schema:s,parentSchema:o,it:n}=t,{oneOf:i}=o;if(!n.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=s.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(s.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,wr._)`${r}${(0,wr.getProperty)(a)}`);e.if((0,wr._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:hc.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let m=A();e.if(!1);for(let g in m)e.elseIf((0,wr._)`${u} === ${g}`),e.assign(c,d(m[g]));e.else(),t.error(!1,{discrError:hc.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(m){let g=e.name("valid"),f=t.subschema({keyword:"oneOf",schemaProp:m},g);return t.mergeEvaluated(f,wr.Name),g}function A(){var m;let g={},f=y(o),h=!0;for(let R=0;R<i.length;R++){let w=i[R];if(w?.$ref&&!(0,UB.schemaHasRulesButRef)(w,n.self.RULES)){let P=w.$ref;if(w=OA.resolveRef.call(n.self,n.schemaEnv.root,n.baseId,P),w instanceof OA.SchemaEnv&&(w=w.schema),w===void 0)throw new FB.default(n.opts.uriResolver,n.baseId,P)}let I=(m=w?.properties)===null||m===void 0?void 0:m[a];if(typeof I!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);h=h&&(f||y(w)),C(I,R)}if(!h)throw new Error(`discriminator: "${a}" must be required`);return g;function y({required:R}){return Array.isArray(R)&&R.includes(a)}function C(R,w){if(R.const)Q(R.const,w);else if(R.enum)for(let I of R.enum)Q(I,w);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function Q(R,w){if(typeof R!="string"||R in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[R]=w}}}};yc.default=OB});var GA=B((cT,LB)=>{LB.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 wc=B((X,Ec)=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.MissingRefError=X.ValidationError=X.CodeGen=X.Name=X.nil=X.stringify=X.str=X._=X.KeywordCxt=X.Ajv=void 0;var GB=Ud(),HB=FA(),YB=LA(),HA=GA(),JB=["/properties"],an="http://json-schema.org/draft-07/schema",Cr=class extends GB.default{_addVocabularies(){super._addVocabularies(),HB.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(YB.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(HA,JB):HA;this.addMetaSchema(e,an,!1),this.refs["http://json-schema.org/schema"]=an}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(an)?an:void 0)}};X.Ajv=Cr;Ec.exports=X=Cr;Ec.exports.Ajv=Cr;Object.defineProperty(X,"__esModule",{value:!0});X.default=Cr;var WB=fs();Object.defineProperty(X,"KeywordCxt",{enumerable:!0,get:function(){return WB.KeywordCxt}});var Ir=N();Object.defineProperty(X,"_",{enumerable:!0,get:function(){return Ir._}});Object.defineProperty(X,"str",{enumerable:!0,get:function(){return Ir.str}});Object.defineProperty(X,"stringify",{enumerable:!0,get:function(){return Ir.stringify}});Object.defineProperty(X,"nil",{enumerable:!0,get:function(){return Ir.nil}});Object.defineProperty(X,"Name",{enumerable:!0,get:function(){return Ir.Name}});Object.defineProperty(X,"CodeGen",{enumerable:!0,get:function(){return Ir.CodeGen}});var VB=Fo();Object.defineProperty(X,"ValidationError",{enumerable:!0,get:function(){return VB.default}});var KB=gs();Object.defineProperty(X,"MissingRefError",{enumerable:!0,get:function(){return KB.default}})});var ep=B(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.formatNames=Xe.fastFormats=Xe.fullFormats=void 0;function Ze(t,e){return{validate:t,compare:e}}Xe.fullFormats={date:Ze(VA,Qc),time:Ze(Ic(!0),_c),"date-time":Ze(YA(!0),ZA),"iso-time":Ze(Ic(),KA),"iso-date-time":Ze(YA(),XA),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:sQ,"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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((:[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:uQ,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:oQ,int32:{type:"number",validate:aQ},int64:{type:"number",validate:cQ},float:{type:"number",validate:WA},double:{type:"number",validate:WA},password:!0,binary:!0};Xe.fastFormats={...Xe.fullFormats,date:Ze(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Qc),time:Ze(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,_c),"date-time":Ze(/^\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,ZA),"iso-time":Ze(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,KA),"iso-date-time":Ze(/^\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,XA),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};Xe.formatNames=Object.keys(Xe.fullFormats);function ZB(t){return t%4===0&&(t%100!==0||t%400===0)}var XB=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,eQ=[0,31,28,31,30,31,30,31,31,30,31,30,31];function VA(t){let e=XB.exec(t);if(!e)return!1;let r=+e[1],s=+e[2],o=+e[3];return s>=1&&s<=12&&o>=1&&o<=(s===2&&ZB(r)?29:eQ[s])}function Qc(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Cc=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Ic(t){return function(r){let s=Cc.exec(r);if(!s)return!1;let o=+s[1],n=+s[2],i=+s[3],a=s[4],c=s[5]==="-"?-1:1,u=+(s[6]||0),l=+(s[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&n<=59&&i<60)return!0;let d=n-l*c,A=o-u*c-(d<0?1:0);return(A===23||A===-1)&&(d===59||d===-1)&&i<61}}function _c(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),s=new Date("2020-01-01T"+e).valueOf();if(r&&s)return r-s}function KA(t,e){if(!(t&&e))return;let r=Cc.exec(t),s=Cc.exec(e);if(r&&s)return t=r[1]+r[2]+r[3],e=s[1]+s[2]+s[3],t>e?1:t<e?-1:0}var Bc=/t|\s/i;function YA(t){let e=Ic(t);return function(s){let o=s.split(Bc);return o.length===2&&VA(o[0])&&e(o[1])}}function ZA(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),s=new Date(e).valueOf();if(r&&s)return r-s}function XA(t,e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?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function sQ(t){return tQ.test(t)&&rQ.test(t)}var JA=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function oQ(t){return JA.lastIndex=0,JA.test(t)}var nQ=-(2**31),iQ=2**31-1;function aQ(t){return Number.isInteger(t)&&t<=iQ&&t>=nQ}function cQ(t){return Number.isInteger(t)}function WA(){return!0}var lQ=/[^\\]\\Z/;function uQ(t){if(lQ.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var tp=B(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.formatLimitDefinition=void 0;var dQ=wc(),Ge=N(),kt=Ge.operators,cn={formatMaximum:{okStr:"<=",ok:kt.LTE,fail:kt.GT},formatMinimum:{okStr:">=",ok:kt.GTE,fail:kt.LT},formatExclusiveMaximum:{okStr:"<",ok:kt.LT,fail:kt.GTE},formatExclusiveMinimum:{okStr:">",ok:kt.GT,fail:kt.LTE}},AQ={message:({keyword:t,schemaCode:e})=>(0,Ge.str)`should be ${cn[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Ge._)`{comparison: ${cn[t].okStr}, limit: ${e}}`};Br.formatLimitDefinition={keyword:Object.keys(cn),type:"string",schemaType:"string",$data:!0,error:AQ,code(t){let{gen:e,data:r,schemaCode:s,keyword:o,it:n}=t,{opts:i,self:a}=n;if(!i.validateFormats)return;let c=new dQ.KeywordCxt(n,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let A=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=e.const("fmt",(0,Ge._)`${A}[${c.schemaCode}]`);t.fail$data((0,Ge.or)((0,Ge._)`typeof ${m} != "object"`,(0,Ge._)`${m} instanceof RegExp`,(0,Ge._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let A=c.schema,m=a.formats[A];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${A}" does not define "compare" function`);let g=e.scopeValue("formats",{key:A,ref:m,code:i.code.formats?(0,Ge._)`${i.code.formats}${(0,Ge.getProperty)(A)}`:void 0});t.fail$data(d(g))}function d(A){return(0,Ge._)`${A}.compare(${r}, ${s}) ${cn[o].fail} 0`}},dependencies:["format"]};var pQ=t=>(t.addKeyword(Br.formatLimitDefinition),t);Br.default=pQ});var np=B((bs,op)=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});var Qr=ep(),mQ=tp(),kc=N(),rp=new kc.Name("fullFormats"),fQ=new kc.Name("fastFormats"),Sc=(t,e={keywords:!0})=>{if(Array.isArray(e))return sp(t,e,Qr.fullFormats,rp),t;let[r,s]=e.mode==="fast"?[Qr.fastFormats,fQ]:[Qr.fullFormats,rp],o=e.formats||Qr.formatNames;return sp(t,o,r,s),e.keywords&&(0,mQ.default)(t),t};Sc.get=(t,e="full")=>{let s=(e==="fast"?Qr.fastFormats:Qr.fullFormats)[t];if(!s)throw new Error(`Unknown format "${t}"`);return s};function sp(t,e,r,s){var o,n;(o=(n=t.opts.code).formats)!==null&&o!==void 0||(n.formats=(0,kc._)`require("ajv-formats/dist/formats").${s}`);for(let i of e)t.addFormat(i,r[i])}op.exports=bs=Sc;Object.defineProperty(bs,"__esModule",{value:!0});bs.default=Sc});var Dp=B((LT,Tp)=>{"use strict";Tp.exports=Rp;Rp.sync=YQ;var bp=mt("fs");function HQ(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var s=0;s<r.length;s++){var o=r[s].toLowerCase();if(o&&t.substr(-o.length).toLowerCase()===o)return!0}return!1}function xp(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:HQ(e,r)}function Rp(t,e,r){bp.stat(t,function(s,o){r(s,s?!1:xp(o,t,e))})}function YQ(t,e){return xp(bp.statSync(t),t,e)}});var zp=B((GT,Np)=>{"use strict";Np.exports=Pp;Pp.sync=JQ;var $p=mt("fs");function Pp(t,e,r){$p.stat(t,function(s,o){r(s,s?!1:jp(o,e))})}function JQ(t,e){return jp($p.statSync(t),e)}function jp(t,e){return t.isFile()&&WQ(t,e)}function WQ(t,e){var r=t.mode,s=t.uid,o=t.gid,n=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),i=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),u=parseInt("001",8),l=a|c,d=r&u||r&c&&o===i||r&a&&s===n||r&l&&n===0;return d}});var Up=B((YT,Fp)=>{"use strict";var HT=mt("fs"),En;process.platform==="win32"||global.TESTING_WINDOWS?En=Dp():En=zp();Fp.exports=Yc;Yc.sync=VQ;function Yc(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(s,o){Yc(t,e||{},function(n,i){n?o(n):s(i)})})}En(t,e||{},function(s,o){s&&(s.code==="EACCES"||e&&e.ignoreErrors)&&(s=null,o=!1),r(s,o)})}function VQ(t,e){try{return En.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Jp=B((JT,Yp)=>{"use strict";var Rr=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",qp=mt("path"),KQ=Rr?";":":",Op=Up(),Lp=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Gp=(t,e)=>{let r=e.colon||KQ,s=t.match(/\//)||Rr&&t.match(/\\/)?[""]:[...Rr?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],o=Rr?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",n=Rr?o.split(r):[""];return Rr&&t.indexOf(".")!==-1&&n[0]!==""&&n.unshift(""),{pathEnv:s,pathExt:n,pathExtExe:o}},Hp=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:s,pathExt:o,pathExtExe:n}=Gp(t,e),i=[],a=u=>new Promise((l,d)=>{if(u===s.length)return e.all&&i.length?l(i):d(Lp(t));let A=s[u],m=/^".*"$/.test(A)?A.slice(1,-1):A,g=qp.join(m,t),f=!m&&/^\.[\\\/]/.test(t)?t.slice(0,2)+g:g;l(c(f,u,0))}),c=(u,l,d)=>new Promise((A,m)=>{if(d===o.length)return A(a(l+1));let g=o[d];Op(u+g,{pathExt:n},(f,h)=>{if(!f&&h)if(e.all)i.push(u+g);else return A(u+g);return A(c(u,l,d+1))})});return r?a(0).then(u=>r(null,u),r):a(0)},ZQ=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:s,pathExtExe:o}=Gp(t,e),n=[];for(let i=0;i<r.length;i++){let a=r[i],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=qp.join(c,t),l=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;for(let d=0;d<s.length;d++){let A=l+s[d];try{if(Op.sync(A,{pathExt:o}))if(e.all)n.push(A);else return A}catch{}}}if(e.all&&n.length)return n;if(e.nothrow)return null;throw Lp(t)};Yp.exports=Hp;Hp.sync=ZQ});var Vp=B((WT,Jc)=>{"use strict";var Wp=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(s=>s.toUpperCase()==="PATH")||"Path"};Jc.exports=Wp;Jc.exports.default=Wp});var em=B((VT,Xp)=>{"use strict";var Kp=mt("path"),XQ=Jp(),e_=Vp();function Zp(t,e){let r=t.options.env||process.env,s=process.cwd(),o=t.options.cwd!=null,n=o&&process.chdir!==void 0&&!process.chdir.disabled;if(n)try{process.chdir(t.options.cwd)}catch{}let i;try{i=XQ.sync(t.command,{path:r[e_({env:r})],pathExt:e?Kp.delimiter:void 0})}catch{}finally{n&&process.chdir(s)}return i&&(i=Kp.resolve(o?t.options.cwd:"",i)),i}function t_(t){return Zp(t)||Zp(t,!0)}Xp.exports=t_});var tm=B((KT,Vc)=>{"use strict";var Wc=/([()\][%!^"`<>&|;, *?])/g;function r_(t){return t=t.replace(Wc,"^$1"),t}function s_(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(Wc,"^$1"),e&&(t=t.replace(Wc,"^$1")),t}Vc.exports.command=r_;Vc.exports.argument=s_});var sm=B((ZT,rm)=>{"use strict";rm.exports=/^#!(.*)/});var nm=B((XT,om)=>{"use strict";var o_=sm();om.exports=(t="")=>{let e=t.match(o_);if(!e)return null;let[r,s]=e[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?s:s?`${o} ${s}`:o}});var am=B((eD,im)=>{"use strict";var Kc=mt("fs"),n_=nm();function i_(t){let r=Buffer.alloc(150),s;try{s=Kc.openSync(t,"r"),Kc.readSync(s,r,0,150,0),Kc.closeSync(s)}catch{}return n_(r.toString())}im.exports=i_});var dm=B((tD,um)=>{"use strict";var a_=mt("path"),cm=em(),lm=tm(),c_=am(),l_=process.platform==="win32",u_=/\.(?:com|exe)$/i,d_=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function A_(t){t.file=cm(t);let e=t.file&&c_(t.file);return e?(t.args.unshift(t.file),t.command=e,cm(t)):t.file}function p_(t){if(!l_)return t;let e=A_(t),r=!u_.test(e);if(t.options.forceShell||r){let s=d_.test(e);t.command=a_.normalize(t.command),t.command=lm.command(t.command),t.args=t.args.map(n=>lm.argument(n,s));let o=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${o}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function m_(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let s={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?s:p_(s)}um.exports=m_});var mm=B((rD,pm)=>{"use strict";var Zc=process.platform==="win32";function Xc(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function f_(t,e){if(!Zc)return;let r=t.emit;t.emit=function(s,o){if(s==="exit"){let n=Am(o,e);if(n)return r.call(t,"error",n)}return r.apply(t,arguments)}}function Am(t,e){return Zc&&t===1&&!e.file?Xc(e.original,"spawn"):null}function g_(t,e){return Zc&&t===1&&!e.file?Xc(e.original,"spawnSync"):null}pm.exports={hookChildProcess:f_,verifyENOENT:Am,verifyENOENTSync:g_,notFoundError:Xc}});var hm=B((sD,Tr)=>{"use strict";var fm=mt("child_process"),el=dm(),tl=mm();function gm(t,e,r){let s=el(t,e,r),o=fm.spawn(s.command,s.args,s.options);return tl.hookChildProcess(o,s),o}function h_(t,e,r){let s=el(t,e,r),o=fm.spawnSync(s.command,s.args,s.options);return o.error=o.error||tl.verifyENOENTSync(o.status,s),o}Tr.exports=gm;Tr.exports.spawn=gm;Tr.exports.sync=h_;Tr.exports._parse=el;Tr.exports._enoent=tl});var Bm=B(sl=>{"use strict";var wm=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,B_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Cm=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,Q_=/\\([\u000b\u0020-\u00ff])/g,__=/([\\"])/g,Im=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;sl.format=k_;sl.parse=S_;function k_(t){if(!t||typeof t!="object")throw new TypeError("argument obj is required");var e=t.parameters,r=t.type;if(!r||!Im.test(r))throw new TypeError("invalid type");var s=r;if(e&&typeof e=="object")for(var o,n=Object.keys(e).sort(),i=0;i<n.length;i++){if(o=n[i],!Cm.test(o))throw new TypeError("invalid parameter name");s+="; "+o+"="+M_(e[o])}return s}function S_(t){if(!t)throw new TypeError("argument string is required");var e=typeof t=="object"?v_(t):t;if(typeof e!="string")throw new TypeError("argument string is required to be a string");var r=e.indexOf(";"),s=r!==-1?e.slice(0,r).trim():e.trim();if(!Im.test(s))throw new TypeError("invalid media type");var o=new b_(s.toLowerCase());if(r!==-1){var n,i,a;for(wm.lastIndex=r;i=wm.exec(e);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,n=i[1].toLowerCase(),a=i[2],a.charCodeAt(0)===34&&(a=a.slice(1,-1),a.indexOf("\\")!==-1&&(a=a.replace(Q_,"$1"))),o.parameters[n]=a}if(r!==e.length)throw new TypeError("invalid parameter format")}return o}function v_(t){var e;if(typeof t.getHeader=="function"?e=t.getHeader("content-type"):typeof t.headers=="object"&&(e=t.headers&&t.headers["content-type"]),typeof e!="string")throw new TypeError("content-type header is missing from object");return e}function M_(t){var e=String(t);if(Cm.test(e))return e;if(e.length>0&&!B_.test(e))throw new TypeError("invalid parameter value");return'"'+e.replace(__,"\\$1")+'"'}function b_(t){this.parameters=Object.create(null),this.type=t}});async function ii(t,e){switch(t.protocol){case"anthropic":{let{AnthropicClient:r}=await import("./anthropic-K3YA64W4.js");return new r(t,e)}case"openai":{let{OpenAIClient:r}=await import("./openai-HEG2P5DF.js");return new r(t,e)}case"openai-compat":{let{OpenAICompatClient:r}=await import("./openai-HEG2P5DF.js");return new r(t,e)}default:throw new Error(`Unknown protocol: ${String(t.protocol)}`)}}var or="2025-11-25";var Wl=[or,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],gt="io.modelcontextprotocol/related-task",go="2.0",le=zl(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Vl=ee([p(),H().int()]),Kl=p(),c0=ce({ttl:H().optional(),pollInterval:H().optional()}),jg=k({ttl:H().optional()}),Ng=k({taskId:p()}),ci=ce({progressToken:Vl.optional(),[gt]:Ng.optional()}),Te=k({_meta:ci.optional()}),Yr=Te.extend({task:jg.optional()}),Zl=t=>Yr.safeParse(t).success,de=k({method:p(),params:Te.loose().optional()}),De=k({_meta:ci.optional()}),$e=k({method:p(),params:De.loose().optional()}),Ae=ce({_meta:ci.optional()}),ho=ee([p(),H().int()]),Xl=k({jsonrpc:v(go),id:ho,...de.shape}).strict(),Jr=t=>Xl.safeParse(t).success,eu=k({jsonrpc:v(go),...$e.shape}).strict(),tu=t=>eu.safeParse(t).success,li=k({jsonrpc:v(go),id:ho,result:Ae}).strict(),xt=t=>li.safeParse(t).success;var D;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(D||(D={}));var ui=k({jsonrpc:v(go),id:ho.optional(),error:k({code:H().int(),message:p(),data:ne().optional()})}).strict();var ru=t=>ui.safeParse(t).success;var ht=ee([Xl,eu,li,ui]),l0=ee([li,ui]),Rt=Ae.strict(),zg=De.extend({requestId:ho.optional(),reason:p().optional()}),yo=$e.extend({method:v("notifications/cancelled"),params:zg}),Fg=k({src:p(),mimeType:p().optional(),sizes:_(p()).optional(),theme:Re(["light","dark"]).optional()}),Wr=k({icons:_(Fg).optional()}),sr=k({name:p(),title:p().optional()}),su=sr.extend({...sr.shape,...Wr.shape,version:p(),websiteUrl:p().optional(),description:p().optional()}),Ug=ri(k({applyDefaults:W().optional()}),K(p(),ne())),qg=si(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,ri(k({form:Ug.optional(),url:le.optional()}),K(p(),ne()).optional())),Og=ce({list:le.optional(),cancel:le.optional(),requests:ce({sampling:ce({createMessage:le.optional()}).optional(),elicitation:ce({create:le.optional()}).optional()}).optional()}),Lg=ce({list:le.optional(),cancel:le.optional(),requests:ce({tools:ce({call:le.optional()}).optional()}).optional()}),Gg=k({experimental:K(p(),le).optional(),sampling:k({context:le.optional(),tools:le.optional()}).optional(),elicitation:qg.optional(),roots:k({listChanged:W().optional()}).optional(),tasks:Og.optional(),extensions:K(p(),le).optional()}),Hg=Te.extend({protocolVersion:p(),capabilities:Gg,clientInfo:su}),Yg=de.extend({method:v("initialize"),params:Hg});var Jg=k({experimental:K(p(),le).optional(),logging:le.optional(),completions:le.optional(),prompts:k({listChanged:W().optional()}).optional(),resources:k({subscribe:W().optional(),listChanged:W().optional()}).optional(),tools:k({listChanged:W().optional()}).optional(),tasks:Lg.optional(),extensions:K(p(),le).optional()}),di=Ae.extend({protocolVersion:p(),capabilities:Jg,serverInfo:su,instructions:p().optional()}),ou=$e.extend({method:v("notifications/initialized"),params:De.optional()}),nu=t=>ou.safeParse(t).success,Eo=de.extend({method:v("ping"),params:Te.optional()}),Wg=k({progress:H(),total:re(H()),message:re(p())}),Vg=k({...De.shape,...Wg.shape,progressToken:Vl}),wo=$e.extend({method:v("notifications/progress"),params:Vg}),Kg=Te.extend({cursor:Kl.optional()}),Vr=de.extend({params:Kg.optional()}),Kr=Ae.extend({nextCursor:Kl.optional()}),Zg=Re(["working","input_required","completed","failed","cancelled"]),Zr=k({taskId:p(),status:Zg,ttl:ee([H(),jl()]),createdAt:p(),lastUpdatedAt:p(),pollInterval:re(H()),statusMessage:re(p())}),Tt=Ae.extend({task:Zr}),Xg=De.merge(Zr),Xr=$e.extend({method:v("notifications/tasks/status"),params:Xg}),Co=de.extend({method:v("tasks/get"),params:Te.extend({taskId:p()})}),Io=Ae.merge(Zr),Bo=de.extend({method:v("tasks/result"),params:Te.extend({taskId:p()})}),u0=Ae.loose(),Qo=Vr.extend({method:v("tasks/list")}),_o=Kr.extend({tasks:_(Zr)}),ko=de.extend({method:v("tasks/cancel"),params:Te.extend({taskId:p()})}),iu=Ae.merge(Zr),au=k({uri:p(),mimeType:re(p()),_meta:K(p(),ne()).optional()}),cu=au.extend({text:p()}),Ai=p().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),lu=au.extend({blob:Ai}),es=Re(["user","assistant"]),nr=k({audience:_(es).optional(),priority:H().min(0).max(1).optional(),lastModified:Tl.datetime({offset:!0}).optional()}),uu=k({...sr.shape,...Wr.shape,uri:p(),description:re(p()),mimeType:re(p()),size:re(H()),annotations:nr.optional(),_meta:re(ce({}))}),eh=k({...sr.shape,...Wr.shape,uriTemplate:p(),description:re(p()),mimeType:re(p()),annotations:nr.optional(),_meta:re(ce({}))}),th=Vr.extend({method:v("resources/list")}),pi=Kr.extend({resources:_(uu)}),rh=Vr.extend({method:v("resources/templates/list")}),mi=Kr.extend({resourceTemplates:_(eh)}),fi=Te.extend({uri:p()}),sh=fi,oh=de.extend({method:v("resources/read"),params:sh}),gi=Ae.extend({contents:_(ee([cu,lu]))}),hi=$e.extend({method:v("notifications/resources/list_changed"),params:De.optional()}),nh=fi,ih=de.extend({method:v("resources/subscribe"),params:nh}),ah=fi,ch=de.extend({method:v("resources/unsubscribe"),params:ah}),lh=De.extend({uri:p()}),uh=$e.extend({method:v("notifications/resources/updated"),params:lh}),dh=k({name:p(),description:re(p()),required:re(W())}),Ah=k({...sr.shape,...Wr.shape,description:re(p()),arguments:re(_(dh)),_meta:re(ce({}))}),ph=Vr.extend({method:v("prompts/list")}),yi=Kr.extend({prompts:_(Ah)}),mh=Te.extend({name:p(),arguments:K(p(),p()).optional()}),fh=de.extend({method:v("prompts/get"),params:mh}),Ei=k({type:v("text"),text:p(),annotations:nr.optional(),_meta:K(p(),ne()).optional()}),wi=k({type:v("image"),data:Ai,mimeType:p(),annotations:nr.optional(),_meta:K(p(),ne()).optional()}),Ci=k({type:v("audio"),data:Ai,mimeType:p(),annotations:nr.optional(),_meta:K(p(),ne()).optional()}),gh=k({type:v("tool_use"),name:p(),id:p(),input:K(p(),ne()),_meta:K(p(),ne()).optional()}),hh=k({type:v("resource"),resource:ee([cu,lu]),annotations:nr.optional(),_meta:K(p(),ne()).optional()}),yh=uu.extend({type:v("resource_link")}),Ii=ee([Ei,wi,Ci,yh,hh]),Eh=k({role:es,content:Ii}),Bi=Ae.extend({description:p().optional(),messages:_(Eh)}),Qi=$e.extend({method:v("notifications/prompts/list_changed"),params:De.optional()}),wh=k({title:p().optional(),readOnlyHint:W().optional(),destructiveHint:W().optional(),idempotentHint:W().optional(),openWorldHint:W().optional()}),Ch=k({taskSupport:Re(["required","optional","forbidden"]).optional()}),du=k({...sr.shape,...Wr.shape,description:p().optional(),inputSchema:k({type:v("object"),properties:K(p(),le).optional(),required:_(p()).optional()}).catchall(ne()),outputSchema:k({type:v("object"),properties:K(p(),le).optional(),required:_(p()).optional()}).catchall(ne()).optional(),annotations:wh.optional(),execution:Ch.optional(),_meta:K(p(),ne()).optional()}),Ih=Vr.extend({method:v("tools/list")}),_i=Kr.extend({tools:_(du)}),ir=Ae.extend({content:_(Ii).default([]),structuredContent:K(p(),ne()).optional(),isError:W().optional()}),d0=ir.or(Ae.extend({toolResult:ne()})),Bh=Yr.extend({name:p(),arguments:K(p(),ne()).optional()}),Qh=de.extend({method:v("tools/call"),params:Bh}),ki=$e.extend({method:v("notifications/tools/list_changed"),params:De.optional()}),Au=k({autoRefresh:W().default(!0),debounceMs:H().int().nonnegative().default(300)}),pu=Re(["debug","info","notice","warning","error","critical","alert","emergency"]),_h=Te.extend({level:pu}),kh=de.extend({method:v("logging/setLevel"),params:_h}),Sh=De.extend({level:pu,logger:p().optional(),data:ne()}),vh=$e.extend({method:v("notifications/message"),params:Sh}),Mh=k({name:p().optional()}),bh=k({hints:_(Mh).optional(),costPriority:H().min(0).max(1).optional(),speedPriority:H().min(0).max(1).optional(),intelligencePriority:H().min(0).max(1).optional()}),xh=k({mode:Re(["auto","required","none"]).optional()}),Rh=k({type:v("tool_result"),toolUseId:p().describe("The unique identifier for the corresponding tool call."),content:_(Ii).default([]),structuredContent:k({}).loose().optional(),isError:W().optional(),_meta:K(p(),ne()).optional()}),Th=ti("type",[Ei,wi,Ci]),fo=ti("type",[Ei,wi,Ci,gh,Rh]),Dh=k({role:es,content:ee([fo,_(fo)]),_meta:K(p(),ne()).optional()}),$h=Yr.extend({messages:_(Dh),modelPreferences:bh.optional(),systemPrompt:p().optional(),includeContext:Re(["none","thisServer","allServers"]).optional(),temperature:H().optional(),maxTokens:H().int(),stopSequences:_(p()).optional(),metadata:le.optional(),tools:_(du).optional(),toolChoice:xh.optional()}),Si=de.extend({method:v("sampling/createMessage"),params:$h}),vi=Ae.extend({model:p(),stopReason:re(Re(["endTurn","stopSequence","maxTokens"]).or(p())),role:es,content:Th}),Mi=Ae.extend({model:p(),stopReason:re(Re(["endTurn","stopSequence","maxTokens","toolUse"]).or(p())),role:es,content:ee([fo,_(fo)])}),Ph=k({type:v("boolean"),title:p().optional(),description:p().optional(),default:W().optional()}),jh=k({type:v("string"),title:p().optional(),description:p().optional(),minLength:H().optional(),maxLength:H().optional(),format:Re(["email","uri","date","date-time"]).optional(),default:p().optional()}),Nh=k({type:Re(["number","integer"]),title:p().optional(),description:p().optional(),minimum:H().optional(),maximum:H().optional(),default:H().optional()}),zh=k({type:v("string"),title:p().optional(),description:p().optional(),enum:_(p()),default:p().optional()}),Fh=k({type:v("string"),title:p().optional(),description:p().optional(),oneOf:_(k({const:p(),title:p()})),default:p().optional()}),Uh=k({type:v("string"),title:p().optional(),description:p().optional(),enum:_(p()),enumNames:_(p()).optional(),default:p().optional()}),qh=ee([zh,Fh]),Oh=k({type:v("array"),title:p().optional(),description:p().optional(),minItems:H().optional(),maxItems:H().optional(),items:k({type:v("string"),enum:_(p())}),default:_(p()).optional()}),Lh=k({type:v("array"),title:p().optional(),description:p().optional(),minItems:H().optional(),maxItems:H().optional(),items:k({anyOf:_(k({const:p(),title:p()}))}),default:_(p()).optional()}),Gh=ee([Oh,Lh]),Hh=ee([Uh,qh,Gh]),Yh=ee([Hh,Ph,jh,Nh]),Jh=Yr.extend({mode:v("form").optional(),message:p(),requestedSchema:k({type:v("object"),properties:K(p(),Yh),required:_(p()).optional()})}),Wh=Yr.extend({mode:v("url"),message:p(),elicitationId:p(),url:p().url()}),Vh=ee([Jh,Wh]),bi=de.extend({method:v("elicitation/create"),params:Vh}),Kh=De.extend({elicitationId:p()}),Zh=$e.extend({method:v("notifications/elicitation/complete"),params:Kh}),xi=Ae.extend({action:Re(["accept","decline","cancel"]),content:si(t=>t===null?void 0:t,K(p(),ee([p(),H(),W(),_(p())])).optional())}),Xh=k({type:v("ref/resource"),uri:p()});var ey=k({type:v("ref/prompt"),name:p()}),ty=Te.extend({ref:ee([ey,Xh]),argument:k({name:p(),value:p()}),context:k({arguments:K(p(),p()).optional()}).optional()}),ry=de.extend({method:v("completion/complete"),params:ty});var Ri=Ae.extend({completion:ce({values:_(p()).max(100),total:re(H().int()),hasMore:re(W())})}),sy=k({uri:p().startsWith("file://"),name:p().optional(),_meta:K(p(),ne()).optional()}),oy=de.extend({method:v("roots/list"),params:Te.optional()}),ny=Ae.extend({roots:_(sy)}),iy=$e.extend({method:v("notifications/roots/list_changed"),params:De.optional()}),A0=ee([Eo,Yg,ry,kh,fh,ph,th,rh,oh,ih,ch,Qh,Ih,Co,Bo,Qo,ko]),p0=ee([yo,wo,ou,iy,Xr]),m0=ee([Rt,vi,Mi,xi,ny,Io,_o,Tt]),f0=ee([Eo,Si,bi,oy,Co,Bo,Qo,ko]),g0=ee([yo,wo,vh,uh,hi,ki,Qi,Xr,Zh]),h0=ee([Rt,di,Ri,Bi,yi,pi,mi,gi,ir,_i,Io,_o,Tt]),b=class t extends Error{constructor(e,r,s){super(`MCP error ${e}: ${r}`),this.code=e,this.data=s,this.name="McpError"}static fromError(e,r,s){if(e===D.UrlElicitationRequired&&s){let o=s;if(o.elicitations)return new ai(o.elicitations,r)}return new t(e,r,s)}},ai=class extends b{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(D.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function yt(t){return t==="completed"||t==="failed"||t==="cancelled"}var V0=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Ti(t){let r=lo(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let s=uo(r);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function Di(t,e){let r=Fe(t,e);if(!r.success)throw r.error;return r.data}var Ay=6e4,So=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(yo,r=>{this._oncancel(r)}),this.setNotificationHandler(wo,r=>{this._onprogress(r)}),this.setRequestHandler(Eo,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Co,async(r,s)=>{let o=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!o)throw new b(D.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Bo,async(r,s)=>{let o=async()=>{let n=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(n,s.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,A=new b(d.error.code,d.error.message,d.error.data);l(A)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:s.requestId})}}let i=await this._taskStore.getTask(n,s.sessionId);if(!i)throw new b(D.InvalidParams,`Task not found: ${n}`);if(!yt(i.status))return await this._waitForTaskUpdate(n,s.signal),await o();if(yt(i.status)){let a=await this._taskStore.getTaskResult(n,s.sessionId);return this._clearTaskQueue(n),{...a,_meta:{...a._meta,[gt]:{taskId:n}}}}return await o()};return await o()}),this.setRequestHandler(Qo,async(r,s)=>{try{let{tasks:o,nextCursor:n}=await this._taskStore.listTasks(r.params?.cursor,s.sessionId);return{tasks:o,nextCursor:n,_meta:{}}}catch(o){throw new b(D.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(ko,async(r,s)=>{try{let o=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!o)throw new b(D.InvalidParams,`Task not found: ${r.params.taskId}`);if(yt(o.status))throw new b(D.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(r.params.taskId);let n=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!n)throw new b(D.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...n}}catch(o){throw o instanceof b?o:new b(D.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,s,o,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:s,resetTimeoutOnProgress:n,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let s=Date.now()-r.startTime;if(r.maxTotalTimeout&&s>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),b.fromError(D.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:s});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let s=this.transport?.onerror;this._transport.onerror=n=>{s?.(n),this._onerror(n)};let o=this._transport?.onmessage;this._transport.onmessage=(n,i)=>{o?.(n,i),xt(n)||ru(n)?this._onresponse(n):Jr(n)?this._onrequest(n,i):tu(n)?this._onnotification(n):this._onerror(new Error(`Unknown message type: ${JSON.stringify(n)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(let s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();let r=b.fromError(D.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let s of e.values())s(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,r){let s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,n=e.params?._meta?.[gt]?.taskId;if(s===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:D.MethodNotFound,message:"Method not found"}};n&&this._taskMessageQueue?this._enqueueTaskMessage(n,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=Zl(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};n&&(d.relatedTask={taskId:n}),await this.notification(l,d)},sendRequest:async(l,d,A)=>{if(i.signal.aborted)throw new b(D.ConnectionClosed,"Request was cancelled");let m={...A,relatedRequestId:e.id};n&&!m.relatedTask&&(m.relatedTask={taskId:n});let g=m.relatedTask?.taskId??n;return g&&c&&await c.updateTaskStatus(g,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:n,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:D.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...s}=e.params,o=Number(r),n=this._progressHandlers.get(o);if(!n){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}n(s)}_onresponse(e){let r=Number(e.id),s=this._requestResolvers.get(r);if(s){if(this._requestResolvers.delete(r),xt(e))s(e);else{let i=new b(e.error.code,e.error.message,e.error.data);s(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let n=!1;if(xt(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(n=!0,this._taskProgressTokens.set(a.taskId,r))}}if(n||this._progressHandlers.delete(r),xt(e))o(e);else{let i=b.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,s){let{task:o}=s??{};if(!o){try{yield{type:"result",result:await this.request(e,r,s)}}catch(i){yield{type:"error",error:i instanceof b?i:new b(D.InternalError,String(i))}}return}let n;try{let i=await this.request(e,Tt,s);if(i.task)n=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new b(D.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:n},s);if(yield{type:"taskStatus",task:a},yt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:n},r,s)}:a.status==="failed"?yield{type:"error",error:new b(D.InternalError,`Task ${n} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new b(D.InternalError,`Task ${n} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:n},r,s)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),s?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof b?i:new b(D.InternalError,String(i))}}}request(e,r,s){let{relatedRequestId:o,resumptionToken:n,onresumptiontoken:i,task:a,relatedTask:c}=s??{};return new Promise((u,l)=>{let d=C=>{l(C)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(C){d(C);return}s?.signal?.throwIfAborted();let A=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:A};s?.onprogress&&(this._progressHandlers.set(A,s.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:A}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[gt]:c}});let g=C=>{this._responseHandlers.delete(A),this._progressHandlers.delete(A),this._cleanupTimeout(A),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:A,reason:String(C)}},{relatedRequestId:o,resumptionToken:n,onresumptiontoken:i}).catch(R=>this._onerror(new Error(`Failed to send cancellation: ${R}`)));let Q=C instanceof b?C:new b(D.RequestTimeout,String(C));l(Q)};this._responseHandlers.set(A,C=>{if(!s?.signal?.aborted){if(C instanceof Error)return l(C);try{let Q=Fe(r,C.result);Q.success?u(Q.data):l(Q.error)}catch(Q){l(Q)}}}),s?.signal?.addEventListener("abort",()=>{g(s?.signal?.reason)});let f=s?.timeout??Ay,h=()=>g(b.fromError(D.RequestTimeout,"Request timed out",{timeout:f}));this._setupTimeout(A,f,s?.maxTotalTimeout,h,s?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let C=Q=>{let R=this._responseHandlers.get(A);R?R(Q):this._onerror(new Error(`Response handler missing for side-channeled request ${A}`))};this._requestResolvers.set(A,C),this._enqueueTaskMessage(y,{type:"request",message:m,timestamp:Date.now()}).catch(Q=>{this._cleanupTimeout(A),l(Q)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:n,onresumptiontoken:i}).catch(C=>{this._cleanupTimeout(A),l(C)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Io,r)}async getTaskResult(e,r,s){return this.request({method:"tasks/result",params:e},r,s)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},_o,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},iu,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let s=r?.relatedTask?.taskId;if(s){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[gt]:r.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[gt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[gt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let s=Ti(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(o,n)=>{let i=Di(e,o);return Promise.resolve(r(i,n))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let s=Ti(e);this._notificationHandlers.set(s,o=>{let n=Di(e,o);return Promise.resolve(r(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,s){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,s,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let s=await this._taskMessageQueue.dequeueAll(e,r);for(let o of s)if(o.type==="request"&&Jr(o.message)){let n=o.message.id,i=this._requestResolvers.get(n);i?(i(new b(D.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(n)):this._onerror(new Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let s=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(s=o.pollInterval)}catch{}return new Promise((o,n)=>{if(r.aborted){n(new b(D.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,s);r.addEventListener("abort",()=>{clearTimeout(i),n(new b(D.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await s.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let n=await s.getTask(o,r);if(!n)throw new b(D.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(o,n,i)=>{await s.storeTaskResult(o,n,i,r);let a=await s.getTask(o,r);if(a){let c=Xr.parse({method:"notifications/tasks/status",params:a});await this.notification(c),yt(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>s.getTaskResult(o,r),updateTaskStatus:async(o,n,i)=>{let a=await s.getTask(o,r);if(!a)throw new b(D.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(yt(a.status))throw new b(D.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(o,n,i,r);let c=await s.getTask(o,r);if(c){let u=Xr.parse({method:"notifications/tasks/status",params:c});await this.notification(u),yt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>s.listTasks(o,r)}}};function mu(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function fu(t,e){let r={...t};for(let s in e){let o=s,n=e[o];if(n===void 0)continue;let i=r[o];mu(i)&&mu(n)?r[o]={...i,...n}:r[o]=n}return r}var ip=co(wc(),1),ap=co(np(),1);function gQ(){let t=new ip.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,ap.default)(t),t}var ln=class{constructor(e){this._ajv=e??gQ()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return s=>r(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var un=class{constructor(e){this._client=e}async*callToolStream(e,r=ir,s){let o=this._client,n={...s,task:s?.task??(o.isToolTask(e.name)?{}:void 0)},i=o.requestStream({method:"tools/call",params:e},r,n),a=o.getToolOutputValidator(e.name);for await(let c of i){if(c.type==="result"&&a){let u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new b(D.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new b(D.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof b){yield{type:"error",error:l};return}yield{type:"error",error:new b(D.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(e,r){return this._client.getTask({taskId:e},r)}async getTaskResult(e,r,s){return this._client.getTaskResult({taskId:e},r,s)}async listTasks(e,r){return this._client.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._client.cancelTask({taskId:e},r)}requestStream(e,r,s){return this._client.requestStream(e,r,s)}};function cp(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function lp(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}function dn(t,e){if(!(!t||e===null||typeof e!="object")){if(t.type==="object"&&t.properties&&typeof t.properties=="object"){let r=e,s=t.properties;for(let o of Object.keys(s)){let n=s[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(n,"default")&&(r[o]=n.default),r[o]!==void 0&&dn(n,r[o])}}if(Array.isArray(t.anyOf))for(let r of t.anyOf)typeof r!="boolean"&&dn(r,e);if(Array.isArray(t.oneOf))for(let r of t.oneOf)typeof r!="boolean"&&dn(r,e)}}function hQ(t){if(!t)return{supportsFormMode:!1,supportsUrlMode:!1};let e=t.form!==void 0,r=t.url!==void 0;return{supportsFormMode:e||!e&&!r,supportsUrlMode:r}}var An=class extends So{constructor(e,r){super(r),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=r?.capabilities??{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new ln,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",ki,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Qi,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",hi,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new un(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=fu(this._capabilities,e)}setRequestHandler(e,r){let o=lo(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let n=uo(o);if(typeof n!="string")throw new Error("Schema method literal must be a string");let i=n;if(i==="elicitation/create"){let a=async(c,u)=>{let l=Fe(bi,c);if(!l.success){let C=l.error instanceof Error?l.error.message:String(l.error);throw new b(D.InvalidParams,`Invalid elicitation request: ${C}`)}let{params:d}=l.data;d.mode=d.mode??"form";let{supportsFormMode:A,supportsUrlMode:m}=hQ(this._capabilities.elicitation);if(d.mode==="form"&&!A)throw new b(D.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new b(D.InvalidParams,"Client does not support URL-mode elicitation requests");let g=await Promise.resolve(r(c,u));if(d.task){let C=Fe(Tt,g);if(!C.success){let Q=C.error instanceof Error?C.error.message:String(C.error);throw new b(D.InvalidParams,`Invalid task creation result: ${Q}`)}return C.data}let f=Fe(xi,g);if(!f.success){let C=f.error instanceof Error?f.error.message:String(f.error);throw new b(D.InvalidParams,`Invalid elicitation result: ${C}`)}let h=f.data,y=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&h.action==="accept"&&h.content&&y&&this._capabilities.elicitation?.form?.applyDefaults)try{dn(y,h.content)}catch{}return h};return super.setRequestHandler(e,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=Fe(Si,c);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new b(D.InvalidParams,`Invalid sampling request: ${h}`)}let{params:d}=l.data,A=await Promise.resolve(r(c,u));if(d.task){let h=Fe(Tt,A);if(!h.success){let y=h.error instanceof Error?h.error.message:String(h.error);throw new b(D.InvalidParams,`Invalid task creation result: ${y}`)}return h.data}let g=d.tools||d.toolChoice?Mi:vi,f=Fe(g,A);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new b(D.InvalidParams,`Invalid sampling result: ${h}`)}return f.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapability(e,r){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${r})`)}async connect(e,r){if(await super.connect(e),e.sessionId===void 0)try{let s=await this.request({method:"initialize",params:{protocolVersion:or,capabilities:this._capabilities,clientInfo:this._clientInfo}},di,r);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!Wl.includes(s.protocolVersion))throw new Error(`Server's protocol version is not supported: ${s.protocolVersion}`);this._serverCapabilities=s.capabilities,this._serverVersion=s.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(s.protocolVersion),this._instructions=s.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(s){throw this.close(),s}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break;case"ping":break}}assertTaskCapability(e){cp(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&lp(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},Rt,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},Ri,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},Rt,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},Bi,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},yi,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},pi,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},mi,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},gi,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},Rt,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},Rt,r)}async callTool(e,r=ir,s){if(this.isToolTaskRequired(e.name))throw new b(D.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let o=await this.request({method:"tools/call",params:e},r,s),n=this.getToolOutputValidator(e.name);if(n){if(!o.structuredContent&&!o.isError)throw new b(D.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(o.structuredContent)try{let i=n(o.structuredContent);if(!i.valid)throw new b(D.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof b?i:new b(D.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return o}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of e){if(r.outputSchema){let o=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,o)}let s=r.execution?.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(r.name),s==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){let s=await this.request({method:"tools/list",params:e},_i,r);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,r,s,o){let n=Au.safeParse(s);if(!n.success)throw new Error(`Invalid ${e} listChanged options: ${n.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=n.data,{onChanged:c}=s,u=async()=>{if(!i){c(null,null);return}try{let d=await o();c(null,d)}catch(d){let A=d instanceof Error?d:new Error(String(d));c(A,null)}},l=()=>{if(a){let d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);let A=setTimeout(u,a);this._listChangedDebounceTimers.set(e,A)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var xs=class extends Error{constructor(e,r){super(e),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}},up=10,yQ=13,Gt=32;function vc(t){}function pn(t){if(typeof t=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:e=vc,onError:r=vc,onRetry:s=vc,onComment:o,maxBufferSize:n}=t,i=[],a=0,c=!0,u,l="",d=0,A,m=!1;function g(w){if(m)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,w.charCodeAt(0)===239&&w.charCodeAt(1)===187&&w.charCodeAt(2)===191&&(w=w.slice(3))),i.length===0){let se=h(w);se!==""&&(i.push(se),a=se.length),f();return}if(w.indexOf(`
|
|
12
|
-
`)===-1&&
|
|
13
|
-
`,
|
|
14
|
-
`,
|
|
15
|
-
`,
|
|
16
|
-
${_e}`,
|
|
17
|
-
`,
|
|
18
|
-
`,
|
|
19
|
-
${bl}`,
|
|
20
|
-
${I}`,d++;break;case"id":u=I.includes("\0")?void 0:I;break;case"retry":/^\d+$/.test(I)?s(parseInt(I,10)):r(new xs(`Invalid \`retry\` value: "${I}"`,{type:"invalid-retry",value:I,line:P}));break;default:r(new xs(`Unknown field "${w.length>20?`${w.slice(0,20)}\u2026`:w}"`,{type:"unknown-field",field:w,value:I,line:P}));break}}function Q(){d>0&&e({id:u,event:A,data:l}),u=void 0,l="",d=0,A=void 0}function R(w={}){if(w.consume&&i.length>0){let I=i.join("");y(I,0,I.length)}c=!0,u=void 0,l="",d=0,A=void 0,i.length=0,a=0,m=!1}return{feed:g,reset:R}}function dp(t,e,r){return r===100&&t.charCodeAt(e+1)===97&&t.charCodeAt(e+2)===116&&t.charCodeAt(e+3)===97&&t.charCodeAt(e+4)===58}function Ap(t,e,r){return r===101&&t.charCodeAt(e+1)===118&&t.charCodeAt(e+2)===101&&t.charCodeAt(e+3)===110&&t.charCodeAt(e+4)===116&&t.charCodeAt(e+5)===58}var fn=class extends Event{constructor(e,r){var s,o;super(e),this.code=(s=r?.code)!=null?s:void 0,this.message=(o=r?.message)!=null?o:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,r,s){return s(pp(this),r)}[Symbol.for("Deno.customInspect")](e,r){return e(pp(this),r)}};function EQ(t){let e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function Mc(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(Mc).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${Mc(t.cause)}`:t.message:`${t}`}function pp(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var fp=t=>{throw TypeError(t)},jc=(t,e,r)=>e.has(t)||fp("Cannot "+r),q=(t,e,r)=>(jc(t,e,"read from private field"),r?r.call(t):e.get(t)),ue=(t,e,r)=>e.has(t)?fp("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),te=(t,e,r,s)=>(jc(t,e,"write to private field"),e.set(t,r),r),nt=(t,e,r)=>(jc(t,e,"access private method"),r),xe,Ht,_r,mn,gn,Ds,vr,$s,St,kr,Mr,Sr,Rs,He,bc,xc,Rc,mp,Tc,Dc,Ts,$c,Pc,Yt=class extends EventTarget{constructor(e,r){var s,o;super(),ue(this,He),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,ue(this,xe),ue(this,Ht),ue(this,_r),ue(this,mn),ue(this,gn),ue(this,Ds),ue(this,vr),ue(this,$s,null),ue(this,St),ue(this,kr),ue(this,Mr,null),ue(this,Sr,null),ue(this,Rs,null),ue(this,xc,async n=>{var i;q(this,kr).reset();let{body:a,redirected:c,status:u,headers:l}=n;if(u===204){nt(this,He,Ts).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?te(this,_r,new URL(n.url)):te(this,_r,void 0),u!==200){nt(this,He,Ts).call(this,`Non-200 status code (${u})`,u);return}if(!(l.get("content-type")||"").startsWith("text/event-stream")){nt(this,He,Ts).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(q(this,xe)===this.CLOSED)return;te(this,xe,this.OPEN);let d=new Event("open");if((i=q(this,Rs))==null||i.call(this,d),this.dispatchEvent(d),typeof a!="object"||!a||!("getReader"in a)){nt(this,He,Ts).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}let A=new TextDecoder,m=a.getReader(),g=!0;do{let{done:f,value:h}=await m.read();h&&q(this,kr).feed(A.decode(h,{stream:!f})),f&&(g=!1,q(this,kr).reset(),nt(this,He,$c).call(this))}while(g)}),ue(this,Rc,n=>{te(this,St,void 0),!(n.name==="AbortError"||n.type==="aborted")&&nt(this,He,$c).call(this,Mc(n))}),ue(this,Tc,n=>{typeof n.id=="string"&&te(this,$s,n.id);let i=new MessageEvent(n.event||"message",{data:n.data,origin:q(this,_r)?q(this,_r).origin:q(this,Ht).origin,lastEventId:n.id||""});q(this,Sr)&&(!n.event||n.event==="message")&&q(this,Sr).call(this,i),this.dispatchEvent(i)}),ue(this,Dc,n=>{te(this,Ds,n)}),ue(this,Pc,()=>{te(this,vr,void 0),q(this,xe)===this.CONNECTING&&nt(this,He,bc).call(this)});try{if(e instanceof URL)te(this,Ht,e);else if(typeof e=="string")te(this,Ht,new URL(e,wQ()));else throw new Error("Invalid URL")}catch{throw EQ("An invalid or illegal string was specified")}te(this,kr,pn({onEvent:q(this,Tc),onRetry:q(this,Dc)})),te(this,xe,this.CONNECTING),te(this,Ds,3e3),te(this,gn,(s=r?.fetch)!=null?s:globalThis.fetch),te(this,mn,(o=r?.withCredentials)!=null?o:!1),nt(this,He,bc).call(this)}get readyState(){return q(this,xe)}get url(){return q(this,Ht).href}get withCredentials(){return q(this,mn)}get onerror(){return q(this,Mr)}set onerror(e){te(this,Mr,e)}get onmessage(){return q(this,Sr)}set onmessage(e){te(this,Sr,e)}get onopen(){return q(this,Rs)}set onopen(e){te(this,Rs,e)}addEventListener(e,r,s){let o=r;super.addEventListener(e,o,s)}removeEventListener(e,r,s){let o=r;super.removeEventListener(e,o,s)}close(){q(this,vr)&&clearTimeout(q(this,vr)),q(this,xe)!==this.CLOSED&&(q(this,St)&&q(this,St).abort(),te(this,xe,this.CLOSED),te(this,St,void 0))}};xe=new WeakMap,Ht=new WeakMap,_r=new WeakMap,mn=new WeakMap,gn=new WeakMap,Ds=new WeakMap,vr=new WeakMap,$s=new WeakMap,St=new WeakMap,kr=new WeakMap,Mr=new WeakMap,Sr=new WeakMap,Rs=new WeakMap,He=new WeakSet,bc=function(){te(this,xe,this.CONNECTING),te(this,St,new AbortController),q(this,gn)(q(this,Ht),nt(this,He,mp).call(this)).then(q(this,xc)).catch(q(this,Rc))},xc=new WeakMap,Rc=new WeakMap,mp=function(){var t;let e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...q(this,$s)?{"Last-Event-ID":q(this,$s)}:void 0},cache:"no-store",signal:(t=q(this,St))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Tc=new WeakMap,Dc=new WeakMap,Ts=function(t,e){var r;q(this,xe)!==this.CLOSED&&te(this,xe,this.CLOSED);let s=new fn("error",{code:e,message:t});(r=q(this,Mr))==null||r.call(this,s),this.dispatchEvent(s)},$c=function(t,e){var r;if(q(this,xe)===this.CLOSED)return;te(this,xe,this.CONNECTING);let s=new fn("error",{code:e,message:t});(r=q(this,Mr))==null||r.call(this,s),this.dispatchEvent(s),te(this,vr,setTimeout(q(this,Pc),q(this,Ds)))},Pc=new WeakMap,Yt.CONNECTING=0,Yt.OPEN=1,Yt.CLOSED=2;function wQ(){let t="document"in globalThis?globalThis.document:void 0;return t&&typeof t=="object"&&"baseURI"in t&&typeof t.baseURI=="string"?t.baseURI:void 0}function br(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}function hn(t=fetch,e){return e?async(r,s)=>{let o={...e,...s,headers:s?.headers?{...br(e.headers),...br(s.headers)}:e.headers};return t(r,o)}:t}var Nc;Nc=globalThis.crypto?.webcrypto??globalThis.crypto??import("crypto").then(t=>t.webcrypto);async function CQ(t){return(await Nc).getRandomValues(new Uint8Array(t))}async function IQ(t){let e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%e.length,s="";for(;s.length<t;){let o=await CQ(t-s.length);for(let n of o)n<r&&(s+=e[n%e.length])}return s}async function BQ(t){return await IQ(t)}async function QQ(t){let e=await(await Nc).subtle.digest("SHA-256",new TextEncoder().encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function zc(t){if(t||(t=43),t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;let e=await BQ(t),r=await QQ(e);return{code_verifier:e,code_challenge:r}}var ge=Pl().superRefine((t,e)=>{if(!URL.canParse(t))return e.addIssue({code:Fl.custom,message:"URL must be parseable",fatal:!0}),xl}).refine(t=>{let e=new URL(t);return e.protocol!=="javascript:"&&e.protocol!=="data:"&&e.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),hp=ce({resource:p().url(),authorization_servers:_(ge).optional(),jwks_uri:p().url().optional(),scopes_supported:_(p()).optional(),bearer_methods_supported:_(p()).optional(),resource_signing_alg_values_supported:_(p()).optional(),resource_name:p().optional(),resource_documentation:p().optional(),resource_policy_uri:p().url().optional(),resource_tos_uri:p().url().optional(),tls_client_certificate_bound_access_tokens:W().optional(),authorization_details_types_supported:_(p()).optional(),dpop_signing_alg_values_supported:_(p()).optional(),dpop_bound_access_tokens_required:W().optional()}),Fc=ce({issuer:p(),authorization_endpoint:ge,token_endpoint:ge,registration_endpoint:ge.optional(),scopes_supported:_(p()).optional(),response_types_supported:_(p()),response_modes_supported:_(p()).optional(),grant_types_supported:_(p()).optional(),token_endpoint_auth_methods_supported:_(p()).optional(),token_endpoint_auth_signing_alg_values_supported:_(p()).optional(),service_documentation:ge.optional(),revocation_endpoint:ge.optional(),revocation_endpoint_auth_methods_supported:_(p()).optional(),revocation_endpoint_auth_signing_alg_values_supported:_(p()).optional(),introspection_endpoint:p().optional(),introspection_endpoint_auth_methods_supported:_(p()).optional(),introspection_endpoint_auth_signing_alg_values_supported:_(p()).optional(),code_challenge_methods_supported:_(p()).optional(),client_id_metadata_document_supported:W().optional()}),_Q=ce({issuer:p(),authorization_endpoint:ge,token_endpoint:ge,userinfo_endpoint:ge.optional(),jwks_uri:ge,registration_endpoint:ge.optional(),scopes_supported:_(p()).optional(),response_types_supported:_(p()),response_modes_supported:_(p()).optional(),grant_types_supported:_(p()).optional(),acr_values_supported:_(p()).optional(),subject_types_supported:_(p()),id_token_signing_alg_values_supported:_(p()),id_token_encryption_alg_values_supported:_(p()).optional(),id_token_encryption_enc_values_supported:_(p()).optional(),userinfo_signing_alg_values_supported:_(p()).optional(),userinfo_encryption_alg_values_supported:_(p()).optional(),userinfo_encryption_enc_values_supported:_(p()).optional(),request_object_signing_alg_values_supported:_(p()).optional(),request_object_encryption_alg_values_supported:_(p()).optional(),request_object_encryption_enc_values_supported:_(p()).optional(),token_endpoint_auth_methods_supported:_(p()).optional(),token_endpoint_auth_signing_alg_values_supported:_(p()).optional(),display_values_supported:_(p()).optional(),claim_types_supported:_(p()).optional(),claims_supported:_(p()).optional(),service_documentation:p().optional(),claims_locales_supported:_(p()).optional(),ui_locales_supported:_(p()).optional(),claims_parameter_supported:W().optional(),request_parameter_supported:W().optional(),request_uri_parameter_supported:W().optional(),require_request_uri_registration:W().optional(),op_policy_uri:ge.optional(),op_tos_uri:ge.optional(),client_id_metadata_document_supported:W().optional()}),yp=k({..._Q.shape,...Fc.pick({code_challenge_methods_supported:!0}).shape}),Ep=k({access_token:p(),id_token:p().optional(),token_type:p(),expires_in:Ul.number().optional(),scope:p().optional(),refresh_token:p().optional()}).strip(),wp=k({error:p(),error_description:p().optional(),error_uri:p().optional()}),gp=ge.optional().or(v("").transform(()=>{})),kQ=k({redirect_uris:_(ge),token_endpoint_auth_method:p().optional(),grant_types:_(p()).optional(),response_types:_(p()).optional(),client_name:p().optional(),client_uri:ge.optional(),logo_uri:gp,scope:p().optional(),contacts:_(p()).optional(),tos_uri:gp,policy_uri:p().optional(),jwks_uri:ge.optional(),jwks:Nl().optional(),software_id:p().optional(),software_version:p().optional(),software_statement:p().optional()}).strip(),SQ=k({client_id:p(),client_secret:p().optional(),client_id_issued_at:H().optional(),client_secret_expires_at:H().optional()}).strip(),Cp=kQ.merge(SQ),ST=k({error:p(),error_description:p().optional()}).strip(),vT=k({token:p(),token_type_hint:p().optional()}).strip();function Ip(t){let e=typeof t=="string"?new URL(t):new URL(t.href);return e.hash="",e}function Bp({requestedResource:t,configuredResource:e}){let r=typeof t=="string"?new URL(t):new URL(t.href),s=typeof e=="string"?new URL(e):new URL(e.href);if(r.origin!==s.origin||r.pathname.length<s.pathname.length)return!1;let o=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return o.startsWith(n)}var ae=class extends Error{constructor(e,r){super(e),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Ps=class extends ae{};Ps.errorCode="invalid_request";var Jt=class extends ae{};Jt.errorCode="invalid_client";var Wt=class extends ae{};Wt.errorCode="invalid_grant";var Vt=class extends ae{};Vt.errorCode="unauthorized_client";var js=class extends ae{};js.errorCode="unsupported_grant_type";var Ns=class extends ae{};Ns.errorCode="invalid_scope";var zs=class extends ae{};zs.errorCode="access_denied";var it=class extends ae{};it.errorCode="server_error";var Fs=class extends ae{};Fs.errorCode="temporarily_unavailable";var Us=class extends ae{};Us.errorCode="unsupported_response_type";var qs=class extends ae{};qs.errorCode="unsupported_token_type";var Os=class extends ae{};Os.errorCode="invalid_token";var Ls=class extends ae{};Ls.errorCode="method_not_allowed";var Gs=class extends ae{};Gs.errorCode="too_many_requests";var Kt=class extends ae{};Kt.errorCode="invalid_client_metadata";var Hs=class extends ae{};Hs.errorCode="insufficient_scope";var Ys=class extends ae{};Ys.errorCode="invalid_target";var Qp={[Ps.errorCode]:Ps,[Jt.errorCode]:Jt,[Wt.errorCode]:Wt,[Vt.errorCode]:Vt,[js.errorCode]:js,[Ns.errorCode]:Ns,[zs.errorCode]:zs,[it.errorCode]:it,[Fs.errorCode]:Fs,[Us.errorCode]:Us,[qs.errorCode]:qs,[Os.errorCode]:Os,[Ls.errorCode]:Ls,[Gs.errorCode]:Gs,[Kt.errorCode]:Kt,[Hs.errorCode]:Hs,[Ys.errorCode]:Ys};var Be=class extends Error{constructor(e){super(e??"Unauthorized")}};function vQ(t){return["client_secret_basic","client_secret_post","none"].includes(t)}var Uc="code",qc="S256";function MQ(t,e){let r=t.client_secret!==void 0;return"token_endpoint_auth_method"in t&&t.token_endpoint_auth_method&&vQ(t.token_endpoint_auth_method)&&(e.length===0||e.includes(t.token_endpoint_auth_method))?t.token_endpoint_auth_method:e.length===0?r?"client_secret_basic":"none":r&&e.includes("client_secret_basic")?"client_secret_basic":r&&e.includes("client_secret_post")?"client_secret_post":e.includes("none")?"none":r?"client_secret_post":"none"}function bQ(t,e,r,s){let{client_id:o,client_secret:n}=e;switch(t){case"client_secret_basic":xQ(o,n,r);return;case"client_secret_post":RQ(o,n,s);return;case"none":TQ(o,s);return;default:throw new Error(`Unsupported client authentication method: ${t}`)}}function xQ(t,e,r){if(!e)throw new Error("client_secret_basic authentication requires a client_secret");let s=btoa(`${t}:${e}`);r.set("Authorization",`Basic ${s}`)}function RQ(t,e,r){r.set("client_id",t),e&&r.set("client_secret",e)}function TQ(t,e){e.set("client_id",t)}async function kp(t){let e=t instanceof Response?t.status:void 0,r=t instanceof Response?await t.text():t;try{let s=wp.parse(JSON.parse(r)),{error:o,error_description:n,error_uri:i}=s,a=Qp[o]||it;return new a(n||"",i)}catch(s){let o=`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${s}. Raw body: ${r}`;return new it(o)}}async function at(t,e){try{return await Oc(t,e)}catch(r){if(r instanceof Jt||r instanceof Vt)return await t.invalidateCredentials?.("all"),await Oc(t,e);if(r instanceof Wt)return await t.invalidateCredentials?.("tokens"),await Oc(t,e);throw r}}async function Oc(t,{serverUrl:e,authorizationCode:r,scope:s,resourceMetadataUrl:o,fetchFn:n}){let i=await t.discoveryState?.(),a,c,u,l=o;if(!l&&i?.resourceMetadataUrl&&(l=new URL(i.resourceMetadataUrl)),i?.authorizationServerUrl){if(c=i.authorizationServerUrl,a=i.resourceMetadata,u=i.authorizationServerMetadata??await vp(c,{fetchFn:n}),!a)try{a=await Sp(e,{resourceMetadataUrl:l},n)}catch{}(u!==i.authorizationServerMetadata||a!==i.resourceMetadata)&&await t.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}else{let Q=await FQ(e,{resourceMetadataUrl:l,fetchFn:n});c=Q.authorizationServerUrl,u=Q.authorizationServerMetadata,a=Q.resourceMetadata,await t.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}let d=await $Q(e,t,a),A=s||a?.scopes_supported?.join(" ")||t.clientMetadata.scope,m=await Promise.resolve(t.clientInformation());if(!m){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let Q=u?.client_id_metadata_document_supported===!0,R=t.clientMetadataUrl;if(R&&!DQ(R))throw new Kt(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${R}`);if(Q&&R)m={client_id:R},await t.saveClientInformation?.(m);else{if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");let I=await GQ(c,{metadata:u,clientMetadata:t.clientMetadata,scope:A,fetchFn:n});await t.saveClientInformation(I),m=I}}let g=!t.redirectUrl;if(r!==void 0||g){let Q=await LQ(t,c,{metadata:u,resource:d,authorizationCode:r,fetchFn:n});return await t.saveTokens(Q),"AUTHORIZED"}let f=await t.tokens();if(f?.refresh_token)try{let Q=await OQ(c,{metadata:u,clientInformation:m,refreshToken:f.refresh_token,resource:d,addClientAuthentication:t.addClientAuthentication,fetchFn:n});return await t.saveTokens(Q),"AUTHORIZED"}catch(Q){if(!(!(Q instanceof ae)||Q instanceof it))throw Q}let h=t.state?await t.state():void 0,{authorizationUrl:y,codeVerifier:C}=await UQ(c,{metadata:u,clientInformation:m,state:h,redirectUrl:t.redirectUrl,scope:A,resource:d});return await t.saveCodeVerifier(C),await t.redirectToAuthorization(y),"REDIRECT"}function DQ(t){if(!t)return!1;try{let e=new URL(t);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}async function $Q(t,e,r){let s=Ip(t);if(e.validateResourceURL)return await e.validateResourceURL(s,r?.resource);if(r){if(!Bp({requestedResource:s,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${s} (or origin)`);return new URL(r.resource)}}function xr(t){let e=t.headers.get("WWW-Authenticate");if(!e)return{};let[r,s]=e.split(" ");if(r.toLowerCase()!=="bearer"||!s)return{};let o=Lc(t,"resource_metadata")||void 0,n;if(o)try{n=new URL(o)}catch{}let i=Lc(t,"scope")||void 0,a=Lc(t,"error")||void 0;return{resourceMetadataUrl:n,scope:i,error:a}}function Lc(t,e){let r=t.headers.get("WWW-Authenticate");if(!r)return null;let s=new RegExp(`${e}=(?:"([^"]+)"|([^\\s,]+))`),o=r.match(s);return o?o[1]||o[2]:null}async function Sp(t,e,r=fetch){let s=await NQ(t,"oauth-protected-resource",r,{protocolVersion:e?.protocolVersion,metadataUrl:e?.resourceMetadataUrl});if(!s||s.status===404)throw await s?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!s.ok)throw await s.body?.cancel(),new Error(`HTTP ${s.status} trying to load well-known OAuth protected resource metadata.`);return hp.parse(await s.json())}async function Gc(t,e,r=fetch){try{return await r(t,{headers:e})}catch(s){if(s instanceof TypeError)return e?Gc(t,void 0,r):void 0;throw s}}function PQ(t,e="",r={}){return e.endsWith("/")&&(e=e.slice(0,-1)),r.prependPathname?`${e}/.well-known/${t}`:`/.well-known/${t}${e}`}async function _p(t,e,r=fetch){return await Gc(t,{"MCP-Protocol-Version":e},r)}function jQ(t,e){return!t||t.status>=400&&t.status<500&&e!=="/"}async function NQ(t,e,r,s){let o=new URL(t),n=s?.protocolVersion??or,i;if(s?.metadataUrl)i=new URL(s.metadataUrl);else{let c=PQ(e,o.pathname);i=new URL(c,s?.metadataServerUrl??o),i.search=o.search}let a=await _p(i,n,r);if(!s?.metadataUrl&&jQ(a,o.pathname)){let c=new URL(`/.well-known/${e}`,o);a=await _p(c,n,r)}return a}function zQ(t){let e=typeof t=="string"?new URL(t):t,r=e.pathname!=="/",s=[];if(!r)return s.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),s.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),s;let o=e.pathname;return o.endsWith("/")&&(o=o.slice(0,-1)),s.push({url:new URL(`/.well-known/oauth-authorization-server${o}`,e.origin),type:"oauth"}),s.push({url:new URL(`/.well-known/openid-configuration${o}`,e.origin),type:"oidc"}),s.push({url:new URL(`${o}/.well-known/openid-configuration`,e.origin),type:"oidc"}),s}async function vp(t,{fetchFn:e=fetch,protocolVersion:r=or}={}){let s={"MCP-Protocol-Version":r,Accept:"application/json"},o=zQ(t);for(let{url:n,type:i}of o){let a=await Gc(n,s,e);if(a){if(!a.ok){if(await a.body?.cancel(),a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${n}`)}return i==="oauth"?Fc.parse(await a.json()):yp.parse(await a.json())}}}async function FQ(t,e){let r,s;try{r=await Sp(t,{resourceMetadataUrl:e?.resourceMetadataUrl},e?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(s=r.authorization_servers[0])}catch{}s||(s=String(new URL("/",t)));let o=await vp(s,{fetchFn:e?.fetchFn});return{authorizationServerUrl:s,authorizationServerMetadata:o,resourceMetadata:r}}async function UQ(t,{metadata:e,clientInformation:r,redirectUrl:s,scope:o,state:n,resource:i}){let a;if(e){if(a=new URL(e.authorization_endpoint),!e.response_types_supported.includes(Uc))throw new Error(`Incompatible auth server: does not support response type ${Uc}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(qc))throw new Error(`Incompatible auth server: does not support code challenge method ${qc}`)}else a=new URL("/authorize",t);let c=await zc(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",Uc),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",qc),a.searchParams.set("redirect_uri",String(s)),n&&a.searchParams.set("state",n),o&&a.searchParams.set("scope",o),o?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",i.href),{authorizationUrl:a,codeVerifier:u}}function qQ(t,e,r){return new URLSearchParams({grant_type:"authorization_code",code:t,code_verifier:e,redirect_uri:String(r)})}async function Mp(t,{metadata:e,tokenRequestParams:r,clientInformation:s,addClientAuthentication:o,resource:n,fetchFn:i}){let a=e?.token_endpoint?new URL(e.token_endpoint):new URL("/token",t),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(n&&r.set("resource",n.href),o)await o(c,r,a,e);else if(s){let l=e?.token_endpoint_auth_methods_supported??[],d=MQ(s,l);bQ(d,s,c,r)}let u=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await kp(u);return Ep.parse(await u.json())}async function OQ(t,{metadata:e,clientInformation:r,refreshToken:s,resource:o,addClientAuthentication:n,fetchFn:i}){let a=new URLSearchParams({grant_type:"refresh_token",refresh_token:s}),c=await Mp(t,{metadata:e,tokenRequestParams:a,clientInformation:r,addClientAuthentication:n,resource:o,fetchFn:i});return{refresh_token:s,...c}}async function LQ(t,e,{metadata:r,resource:s,authorizationCode:o,fetchFn:n}={}){let i=t.clientMetadata.scope,a;if(t.prepareTokenRequest&&(a=await t.prepareTokenRequest(i)),!a){if(!o)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!t.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let u=await t.codeVerifier();a=qQ(o,u,t.redirectUrl)}let c=await t.clientInformation();return Mp(e,{metadata:r,tokenRequestParams:a,clientInformation:c??void 0,addClientAuthentication:t.addClientAuthentication,resource:s,fetchFn:n})}async function GQ(t,{metadata:e,clientMetadata:r,scope:s,fetchFn:o}){let n;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");n=new URL(e.registration_endpoint)}else n=new URL("/register",t);let i=await(o??fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...s!==void 0?{scope:s}:{}})});if(!i.ok)throw await kp(i);return Cp.parse(await i.json())}var Hc=class extends Error{constructor(e,r,s){super(`SSE error: ${r}`),this.code=e,this.event=s}},yn=class{constructor(e,r){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=r?.eventSourceInit,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=hn(r?.fetch,r?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new Be("No auth provider");let e;try{e=await at(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new Be;return await this._startOrAuth()}async _commonHeaders(){let e={};if(this._authProvider){let s=await this._authProvider.tokens();s&&(e.Authorization=`Bearer ${s.access_token}`)}this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);let r=br(this._requestInit?.headers);return new Headers({...e,...r})}_startOrAuth(){let e=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((r,s)=>{this._eventSource=new Yt(this._url.href,{...this._eventSourceInit,fetch:async(o,n)=>{let i=await this._commonHeaders();i.set("Accept","text/event-stream");let a=await e(o,{...n,headers:i});if(a.status===401&&a.headers.has("www-authenticate")){let{resourceMetadataUrl:c,scope:u}=xr(a);this._resourceMetadataUrl=c,this._scope=u}return a}}),this._abortController=new AbortController,this._eventSource.onerror=o=>{if(o.code===401&&this._authProvider){this._authThenStart().then(r,s);return}let n=new Hc(o.code,o.message,o);s(n),this.onerror?.(n)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",o=>{let n=o;try{if(this._endpoint=new URL(n.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(i){s(i),this.onerror?.(i),this.close();return}r()}),this._eventSource.onmessage=o=>{let n=o,i;try{i=ht.parse(JSON.parse(n.data))}catch(a){this.onerror?.(a);return}this.onmessage?.(i)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new Be("No auth provider");if(await at(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Be("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw new Error("Not connected");try{let r=await this._commonHeaders();r.set("content-type","application/json");let s={...this._requestInit,method:"POST",headers:r,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._endpoint,s);if(!o.ok){let n=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){let{resourceMetadataUrl:i,scope:a}=xr(o);if(this._resourceMetadataUrl=i,this._scope=a,await at(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Be;return this.send(e)}throw new Error(`Error POSTing to endpoint (HTTP ${o.status}): ${n}`)}await o.body?.cancel()}catch(r){throw this.onerror?.(r),r}}setProtocolVersion(e){this._protocolVersion=e}};var Em=co(hm(),1);import rl from"process";import{PassThrough as w_}from"stream";var y_=10*1024*1024,wn=class{constructor(e){this._maxBufferSize=e?.maxBufferSize??y_}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
21
|
-
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),E_(r)}clear(){this._buffer=void 0}};function E_(t){return ht.parse(JSON.parse(t))}function
|
|
22
|
-
`}var C_=rl.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function I_(){let t={};for(let e of C_){let r=rl.env[e];r!==void 0&&(r.startsWith("()")||(t[e]=r))}return t}var Cn=class{constructor(e){this._stderrStream=null,this._serverParams=e,this._readBuffer=new wn({maxBufferSize:e.maxBufferSize}),(e.stderr==="pipe"||e.stderr==="overlapped")&&(this._stderrStream=new w_)}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,r)=>{this._process=(0,Em.default)(this._serverParams.command,this._serverParams.args??[],{env:{...I_(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:rl.platform==="win32",cwd:this._serverParams.cwd}),this._process.on("error",s=>{r(s),this.onerror?.(s)}),this._process.on("spawn",()=>{e()}),this._process.on("close",s=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",s=>{this.onerror?.(s)}),this._process.stdout?.on("data",s=>{try{this._readBuffer.append(s),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}}),this._process.stdout?.on("error",s=>{this.onerror?.(s)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){return this._stderrStream?this._stderrStream:this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){if(this._process){let e=this._process;this._process=void 0;let r=new Promise(s=>{e.once("close",()=>{s()})});try{e.stdin?.end()}catch{}if(await Promise.race([r,new Promise(s=>setTimeout(s,2e3).unref())]),e.exitCode===null){try{e.kill("SIGTERM")}catch{}await Promise.race([r,new Promise(s=>setTimeout(s,2e3).unref())])}if(e.exitCode===null)try{e.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(e){return new Promise(r=>{if(!this._process?.stdin)throw new Error("Not connected");let s=ym(e);this._process.stdin.write(s)?r():this._process.stdin.once("drain",r)})}};var Qm=co(Bm(),1);function _m(t){if(t)try{return Qm.default.parse(t).type}catch{let e=(t.split(";",1)[0]??"").trim().toLowerCase();return e===""||t.slice(e.length).includes(",")?void 0:e}}var In=class extends TransformStream{constructor({onError:e,onRetry:r,onComment:s,maxBufferSize:o}={}){let n;super({start(i){n=pn({onEvent:a=>{i.enqueue(a)},onError(a){typeof e=="function"&&e(a),(e==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:s,maxBufferSize:o})},transform(i){n.feed(i)}})}};var x_={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},vt=class extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}},Bn=class{constructor(e,r){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=hn(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??x_}async _authThenStart(){if(!this._authProvider)throw new Be("No auth provider");let e;try{e=await at(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new Be;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let s=await this._authProvider.tokens();s&&(e.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);let r=br(this._requestInit?.headers);return new Headers({...e,...r})}async _startOrAuthSse(e){let{resumptionToken:r}=e;try{let s=await this._commonHeaders();s.set("Accept","text/event-stream"),r&&s.set("last-event-id",r);let o=await(this._fetch??fetch)(this._url,{method:"GET",headers:s,signal:this._abortController?.signal});if(!o.ok){if(await o.body?.cancel(),o.status===401&&this._authProvider)return await this._authThenStart();if(o.status===405)return;throw new vt(o.status,`Failed to open SSE stream: ${o.statusText}`)}this._handleSseStream(o.body,e,!0)}catch(s){throw this.onerror?.(s),s}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,o=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(s,e),o)}_scheduleReconnection(e,r=0){let s=this._reconnectionOptions.maxRetries;if(r>=s){this.onerror?.(new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}let o=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,r+1)})},o)}_handleSseStream(e,r,s){if(!e)return;let{onresumptiontoken:o,replayMessageId:n}=r,i,a=!1,c=!1;(async()=>{try{let l=e.pipeThrough(new TextDecoderStream).pipeThrough(new In({onRetry:m=>{this._serverRetryMs=m}})).getReader();for(;;){let{value:m,done:g}=await l.read();if(g)break;if(m.id&&(i=m.id,a=!0,o?.(m.id)),!!m.data&&(!m.event||m.event==="message"))try{let f=ht.parse(JSON.parse(m.data));xt(f)&&(c=!0,n!==void 0&&(f.id=n)),this.onmessage?.(f)}catch(f){this.onerror?.(f)}}(s||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:n},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(s||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:n},0)}catch(m){this.onerror?.(new Error(`Failed to reconnect: ${m instanceof Error?m.message:String(m)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new Be("No auth provider");if(await at(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Be("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,r){try{let{resumptionToken:s,onresumptiontoken:o}=r||{};if(s){this._startOrAuthSse({resumptionToken:s,replayMessageId:Jr(e)?e.id:void 0}).catch(m=>this.onerror?.(m));return}let n=await this._commonHeaders();n.set("content-type","application/json"),n.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(e),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let m=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new vt(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:g,scope:f}=xr(a);if(this._resourceMetadataUrl=g,this._scope=f,await at(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Be;return this._hasCompletedAuthFlow=!0,this.send(e)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:g,scope:f,error:h}=xr(a);if(h==="insufficient_scope"){let y=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===y)throw new vt(403,"Server returned 403 after trying upscoping");if(f&&(this._scope=f),g&&(this._resourceMetadataUrl=g),this._lastUpscopingHeader=y??void 0,await at(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Be;return this.send(e)}}throw new vt(a.status,`Error POSTing to endpoint: ${m}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),nu(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(m=>this.onerror?.(m));return}let l=(Array.isArray(e)?e:[e]).filter(m=>"method"in m&&"id"in m&&m.id!==void 0).length>0,d=a.headers.get("content-type"),A=_m(d);if(l)if(A==="text/event-stream")this._handleSseStream(a.body,{onresumptiontoken:o},!1);else if(A==="application/json"){let m=await a.json(),g=Array.isArray(m)?m.map(f=>ht.parse(f)):[ht.parse(m)];for(let f of g)this.onmessage?.(f)}else throw await a.body?.cancel(),new vt(-1,`Unexpected content type: ${d}`);else await a.body?.cancel()}catch(s){throw this.onerror?.(s),s}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._url,r);if(await s.body?.cancel(),!s.ok&&s.status!==405)throw new vt(s.status,`Failed to terminate session: ${s.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,r){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:r?.onresumptiontoken})}};import{readFileSync as R_,statSync as T_}from"fs";import{extname as D_}from"path";import ol from"sharp";var $_=x({module:"images"});function km(t){if(t==="image/png"||t==="image/jpeg"||t==="image/gif"||t==="image/webp")return t;throw new Error(`Unsupported image media type: "${t}"`)}var al=5*1024*1024,nl=al*3/4,Mt=2e3,QD=10,Dr=class extends Error{constructor(e){super(e),this.name="ImageTooLargeError"}},P_={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp"};function j_(t){return P_[D_(t).toLowerCase()]??null}function Sm(t){return j_(t)!==null}function N_(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?"image/png":t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255?"image/jpeg":t.length>=6&&t[0]===71&&t[1]===73&&t[2]===70?"image/gif":t.length>=12&&t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80?"image/webp":null}async function vm(t){if(!T_(t).isFile())throw new Error(`Not a file: ${t}`);let r=R_(t),s=N_(r);if(!s)throw new Error(`File ${t} has an image extension but its contents are not a supported image format (png/jpeg/gif/webp)`);let o=await cl(r,s);return{mediaType:o.mediaType,data:o.data,sourcePath:t,byteLength:o.byteLength}}function il(t,e){return{data:t.toString("base64"),mediaType:e,byteLength:t.length}}function Js(t){return`${(t/(1024*1024)).toFixed(1)}MB`}async function cl(t,e){if(t.length===0)throw new Dr("Image file is empty (0 bytes)");if(t.length<=nl)return il(t,e);try{return await z_(t,e)}catch(r){throw r instanceof Dr?r:($_.warn({err:r},"sharp compression failed"),new Dr(`Image is ${Js(t.length)} raw (${Js(t.length*4/3)} base64-encoded, API limit ${Js(al)}) and compression failed. Please provide a smaller image.`))}}async function z_(t,e){let r=await ol(t).metadata(),s=r.width??Mt,o=r.height??Mt;s>Mt&&(o=Math.max(1,Math.round(o*Mt/s)),s=Mt),o>Mt&&(s=Math.max(1,Math.round(s*Mt/o)),o=Mt);let n=e==="image/png"||e==="image/gif";for(let i=0;i<3;i++){if(n){let a=await ol(t).resize(s,o,{fit:"inside",withoutEnlargement:!0}).png({compressionLevel:8,palette:!0}).toBuffer();if(a.length<=nl)return il(a,"image/png")}for(let a of[80,60,40,20]){let c=await ol(t).resize(s,o,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:a}).toBuffer();if(c.length<=nl)return il(c,"image/jpeg")}s=Math.max(1,Math.round(s/2)),o=Math.max(1,Math.round(o/2))}throw new Dr(`Unable to compress image (${Js(t.length)} raw) under the ${Js(al)} API limit. Please provide a smaller image.`)}import{readFileSync as F_}from"fs";import Mm from"path";import{fileURLToPath as U_}from"url";var q_=T.object({version:T.string()});function O_(){return"0.0.15"}var bm=O_();var Rm=x({module:"mcp"});function xm(t){return t.replace(/\$\{(\w+)\}|\$(\w+)/g,(e,r,s)=>process.env[r||s]??"")}function L_(t){let e={};for(let[r,s]of Object.entries(t))e[r]=s??"";return e}var G_=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function H_(t){let e=[],r=[];for(let o of t){let n=ql(o)?o:{};if(n.type==="image"&&typeof n.data=="string"&&typeof n.mimeType=="string"&&G_.has(n.mimeType))try{let i=await cl(Buffer.from(n.data,"base64"),km(n.mimeType));r.push({type:"image",source:{type:"base64",media_type:i.mediaType,data:i.data}});continue}catch(i){Rm.warn({err:i},"mcp image dropped (too large to fit the API limit)"),e.push("[note: an image returned by the tool was too large and was dropped]");continue}e.push(n.type==="text"&&typeof n.text=="string"?n.text:JSON.stringify(o))}let s=e.join(`
|
|
23
|
-
`);return r.length===0?s:[...s?[{type:"text",text:s}]:[],...r]}var Qn=class{name;config;client=null;transport=null;constructor(e){this.name=e.name,this.config=e}async connect(){if(this.config.command){let e=process.env;if(this.config.env)for(let[r,s]of Object.entries(this.config.env))e[r]=xm(s);this.transport=new Cn({command:this.config.command,args:this.config.args??[],env:L_(e),stderr:"ignore"})}else if(this.config.url){let e=new URL(this.config.url),r={};if(this.config.headers)for(let[o,n]of Object.entries(this.config.headers))r[o]=xm(n);let s={requestInit:{headers:r}};this.transport=this.config.transport==="sse"?new
|
|
11
|
+
deps: ${r}}`};var LI={keyword:"dependencies",type:"object",schemaType:"object",error:Ke.error,code(t){let[e,r]=qI(t);fd(t,e),gd(t,r)}};function qI({schema:t}){let e={},r={};for(let s in t){if(s==="__proto__")continue;let o=Array.isArray(t[s])?e:r;o[s]=t[s]}return[e,r]}function fd(t,e=t.schema){let{gen:r,data:s,it:o}=t;if(Object.keys(e).length===0)return;let n=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,vs.propertyInData)(r,s,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,vs.checkReportMissingProp)(t,u)}):(r.if((0,ec._)`${c} && (${(0,vs.checkMissingProp)(t,a,n)})`),(0,vs.reportMissingProp)(t,n),r.else())}}Ke.validatePropertyDeps=fd;function gd(t,e=t.schema){let{gen:r,data:s,keyword:o,it:n}=t,i=r.name("valid");for(let a in e)(0,OI.alwaysValidSchema)(n,e[a])||(r.if((0,vs.propertyInData)(r,s,a,n.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}Ke.validateSchemaDeps=gd;Ke.default=LI});var yd=Q(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});var Ed=N(),GI=q(),HI={message:"property name must be valid",params:({params:t})=>(0,Ed._)`{propertyName: ${t.propertyName}}`},YI={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:HI,code(t){let{gen:e,schema:r,data:s,it:o}=t;if((0,GI.alwaysValidSchema)(o,r))return;let n=e.name("valid");e.forIn("key",s,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},n),e.if((0,Ed.not)(n),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(n)}};tc.default=YI});var sc=Q(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});var en=je(),qe=N(),JI=st(),tn=q(),WI={message:"must NOT have additional properties",params:({params:t})=>(0,qe._)`{additionalProperty: ${t.additionalProperty}}`},VI={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:WI,code(t){let{gen:e,schema:r,parentSchema:s,data:o,errsCount:n,it:i}=t;if(!n)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,tn.alwaysValidSchema)(i,r))return;let u=(0,en.allSchemaProperties)(s.properties),l=(0,en.allSchemaProperties)(s.patternProperties);A(),t.ok((0,qe._)`${n} === ${JI.default.errors}`);function A(){e.forIn("key",o,h=>{!u.length&&!l.length?g(h):e.if(p(h),()=>g(h))})}function p(h){let w;if(u.length>8){let C=(0,tn.schemaRefOrVal)(i,s.properties,"properties");w=(0,en.isOwnProperty)(e,C,h)}else u.length?w=(0,qe.or)(...u.map(C=>(0,qe._)`${h} === ${C}`)):w=qe.nil;return l.length&&(w=(0,qe.or)(w,...l.map(C=>(0,qe._)`${(0,en.usePattern)(t,C)}.test(${h})`))),(0,qe.not)(w)}function m(h){e.code((0,qe._)`delete ${o}[${h}]`)}function g(h){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(h);return}if(r===!1){t.setParams({additionalProperty:h}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,tn.alwaysValidSchema)(i,r)){let w=e.name("valid");c.removeAdditional==="failing"?(f(h,w,!1),e.if((0,qe.not)(w),()=>{t.reset(),m(h)})):(f(h,w),a||e.if((0,qe.not)(w),()=>e.break()))}}function f(h,w,C){let I={keyword:"additionalProperties",dataProp:h,dataPropType:tn.Type.Str};C===!1&&Object.assign(I,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(I,w)}}};rc.default=VI});var Id=Q(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});var KI=fs(),wd=je(),oc=q(),Cd=sc(),ZI={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:s,data:o,it:n}=t;n.opts.removeAdditional==="all"&&s.additionalProperties===void 0&&Cd.default.code(new KI.KeywordCxt(n,Cd.default,"additionalProperties"));let i=(0,wd.allSchemaProperties)(r);for(let A of i)n.definedProperties.add(A);n.opts.unevaluated&&i.length&&n.props!==!0&&(n.props=oc.mergeEvaluated.props(e,(0,oc.toHash)(i),n.props));let a=i.filter(A=>!(0,oc.alwaysValidSchema)(n,r[A]));if(a.length===0)return;let c=e.name("valid");for(let A of a)u(A)?l(A):(e.if((0,wd.propertyInData)(e,o,A,n.opts.ownProperties)),l(A),n.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(A),t.ok(c);function u(A){return n.opts.useDefaults&&!n.compositeRule&&r[A].default!==void 0}function l(A){t.subschema({keyword:"properties",schemaProp:A,dataProp:A},c)}}};nc.default=ZI});var Sd=Q(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});var Bd=je(),rn=N(),Qd=q(),_d=q(),XI={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:s,parentSchema:o,it:n}=t,{opts:i}=n,a=(0,Bd.allSchemaProperties)(r),c=a.filter(f=>(0,Qd.alwaysValidSchema)(n,r[f]));if(a.length===0||c.length===a.length&&(!n.opts.unevaluated||n.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");n.props!==!0&&!(n.props instanceof rn.Name)&&(n.props=(0,_d.evaluatedPropsToName)(e,n.props));let{props:A}=n;p();function p(){for(let f of a)u&&m(f),n.allErrors?g(f):(e.var(l,!0),g(f),e.if(l))}function m(f){for(let h in u)new RegExp(f).test(h)&&(0,Qd.checkStrictMode)(n,`property ${h} matches pattern ${f} (use allowMatchingProperties)`)}function g(f){e.forIn("key",s,h=>{e.if((0,rn._)`${(0,Bd.usePattern)(t,f)}.test(${h})`,()=>{let w=c.includes(f);w||t.subschema({keyword:"patternProperties",schemaProp:f,dataProp:h,dataPropType:_d.Type.Str},l),n.opts.unevaluated&&A!==!0?e.assign((0,rn._)`${A}[${h}]`,!0):!w&&!n.allErrors&&e.if((0,rn.not)(l),()=>e.break())})})}}};ic.default=XI});var kd=Q(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});var eB=q(),tB={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:s}=t;if((0,eB.alwaysValidSchema)(s,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};ac.default=tB});var Md=Q(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var rB=je(),sB={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:rB.validateUnion,error:{message:"must match a schema in anyOf"}};cc.default=sB});var vd=Q(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var sn=N(),oB=q(),nB={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,sn._)`{passingSchemas: ${t.passing}}`},iB={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:nB,code(t){let{gen:e,schema:r,parentSchema:s,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&s.discriminator)return;let n=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){n.forEach((l,A)=>{let p;(0,oB.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:A,compositeRule:!0},c),A>0&&e.if((0,sn._)`${c} && ${i}`).assign(i,!1).assign(a,(0,sn._)`[${a}, ${A}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,A),p&&t.mergeEvaluated(p,sn.Name)})})}}};lc.default=iB});var bd=Q(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});var aB=q(),cB={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((n,i)=>{if((0,aB.alwaysValidSchema)(s,n))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};uc.default=cB});var Dd=Q(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});var on=N(),Rd=q(),lB={message:({params:t})=>(0,on.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,on._)`{failingKeyword: ${t.ifClause}}`},uB={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:lB,code(t){let{gen:e,parentSchema:r,it:s}=t;r.then===void 0&&r.else===void 0&&(0,Rd.checkStrictMode)(s,'"if" without "then" and "else" is ignored');let o=xd(s,"then"),n=xd(s,"else");if(!o&&!n)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&n){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,on.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,A){return()=>{let p=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(p,i),A?e.assign(A,(0,on._)`${l}`):t.setParams({ifClause:l})}}}};function xd(t,e){let r=t.schema[e];return r!==void 0&&!(0,Rd.alwaysValidSchema)(t,r)}Ac.default=uB});var Td=Q(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});var AB=q(),dB={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,AB.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};dc.default=dB});var $d=Q(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var pB=Wa(),mB=Ad(),fB=Va(),gB=pd(),hB=md(),EB=hd(),yB=yd(),wB=sc(),CB=Id(),IB=Sd(),BB=kd(),QB=Md(),_B=vd(),SB=bd(),kB=Dd(),MB=Td();function vB(t=!1){let e=[BB.default,QB.default,_B.default,SB.default,kB.default,MB.default,yB.default,wB.default,EB.default,CB.default,IB.default];return t?e.push(mB.default,gB.default):e.push(pB.default,fB.default),e.push(hB.default),e}pc.default=vB});var Pd=Q(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});var ie=N(),bB={message:({schemaCode:t})=>(0,ie.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ie._)`{format: ${t}}`},xB={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:bB,code(t,e){let{gen:r,data:s,$data:o,schema:n,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:A}=a;if(!c.validateFormats)return;o?p():m();function p(){let g=r.scopeValue("formats",{ref:A.formats,code:c.code.formats}),f=r.const("fDef",(0,ie._)`${g}[${i}]`),h=r.let("fType"),w=r.let("format");r.if((0,ie._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>r.assign(h,(0,ie._)`${f}.type || "string"`).assign(w,(0,ie._)`${f}.validate`),()=>r.assign(h,(0,ie._)`"string"`).assign(w,f)),t.fail$data((0,ie.or)(C(),I()));function C(){return c.strictSchema===!1?ie.nil:(0,ie._)`${i} && !${w}`}function I(){let b=l.$async?(0,ie._)`(${f}.async ? await ${w}(${s}) : ${w}(${s}))`:(0,ie._)`${w}(${s})`,E=(0,ie._)`(typeof ${w} == "function" ? ${b} : ${w}.test(${s}))`;return(0,ie._)`${w} && ${w} !== true && ${h} === ${e} && !${E}`}}function m(){let g=A.formats[n];if(!g){C();return}if(g===!0)return;let[f,h,w]=I(g);f===e&&t.pass(b());function C(){if(c.strictSchema===!1){A.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${n}" ignored in schema at path "${u}"`}}function I(E){let B=E instanceof RegExp?(0,ie.regexpCode)(E):c.code.formats?(0,ie._)`${c.code.formats}${(0,ie.getProperty)(n)}`:void 0,P=r.scopeValue("formats",{key:n,ref:E,code:B});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,ie._)`${P}.validate`]:["string",E,P]}function b(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ie._)`await ${w}(${s})`}return typeof h=="function"?(0,ie._)`${w}(${s})`:(0,ie._)`${w}.test(${s})`}}}};mc.default=xB});var jd=Q(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});var RB=Pd(),DB=[RB.default];fc.default=DB});var Nd=Q(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});yr.contentVocabulary=yr.metadataVocabulary=void 0;yr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];yr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Ud=Q(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});var TB=YA(),$B=ad(),PB=$d(),jB=jd(),zd=Nd(),NB=[TB.default,$B.default,(0,PB.default)(),jB.default,zd.metadataVocabulary,zd.contentVocabulary];gc.default=NB});var Od=Q(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});nn.DiscrError=void 0;var Fd;(function(t){t.Tag="tag",t.Mapping="mapping"})(Fd||(nn.DiscrError=Fd={}))});var qd=Q(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});var wr=N(),hc=Od(),Ld=Oo(),zB=gs(),UB=q(),FB={message:({params:{discrError:t,tagName:e}})=>t===hc.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,wr._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},OB={keyword:"discriminator",type:"object",schemaType:"object",error:FB,code(t){let{gen:e,data:r,schema:s,parentSchema:o,it:n}=t,{oneOf:i}=o;if(!n.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=s.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(s.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,wr._)`${r}${(0,wr.getProperty)(a)}`);e.if((0,wr._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:hc.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let m=p();e.if(!1);for(let g in m)e.elseIf((0,wr._)`${u} === ${g}`),e.assign(c,A(m[g]));e.else(),t.error(!1,{discrError:hc.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function A(m){let g=e.name("valid"),f=t.subschema({keyword:"oneOf",schemaProp:m},g);return t.mergeEvaluated(f,wr.Name),g}function p(){var m;let g={},f=w(o),h=!0;for(let b=0;b<i.length;b++){let E=i[b];if(E?.$ref&&!(0,UB.schemaHasRulesButRef)(E,n.self.RULES)){let P=E.$ref;if(E=Ld.resolveRef.call(n.self,n.schemaEnv.root,n.baseId,P),E instanceof Ld.SchemaEnv&&(E=E.schema),E===void 0)throw new zB.default(n.opts.uriResolver,n.baseId,P)}let B=(m=E?.properties)===null||m===void 0?void 0:m[a];if(typeof B!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);h=h&&(f||w(E)),C(B,b)}if(!h)throw new Error(`discriminator: "${a}" must be required`);return g;function w({required:b}){return Array.isArray(b)&&b.includes(a)}function C(b,E){if(b.const)I(b.const,E);else if(b.enum)for(let B of b.enum)I(B,E);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function I(b,E){if(typeof b!="string"||b in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[b]=E}}}};Ec.default=OB});var Gd=Q((cD,LB)=>{LB.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 wc=Q((X,yc)=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.MissingRefError=X.ValidationError=X.CodeGen=X.Name=X.nil=X.stringify=X.str=X._=X.KeywordCxt=X.Ajv=void 0;var qB=FA(),GB=Ud(),HB=qd(),Hd=Gd(),YB=["/properties"],an="http://json-schema.org/draft-07/schema",Cr=class extends qB.default{_addVocabularies(){super._addVocabularies(),GB.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(HB.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(Hd,YB):Hd;this.addMetaSchema(e,an,!1),this.refs["http://json-schema.org/schema"]=an}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(an)?an:void 0)}};X.Ajv=Cr;yc.exports=X=Cr;yc.exports.Ajv=Cr;Object.defineProperty(X,"__esModule",{value:!0});X.default=Cr;var JB=fs();Object.defineProperty(X,"KeywordCxt",{enumerable:!0,get:function(){return JB.KeywordCxt}});var Ir=N();Object.defineProperty(X,"_",{enumerable:!0,get:function(){return Ir._}});Object.defineProperty(X,"str",{enumerable:!0,get:function(){return Ir.str}});Object.defineProperty(X,"stringify",{enumerable:!0,get:function(){return Ir.stringify}});Object.defineProperty(X,"nil",{enumerable:!0,get:function(){return Ir.nil}});Object.defineProperty(X,"Name",{enumerable:!0,get:function(){return Ir.Name}});Object.defineProperty(X,"CodeGen",{enumerable:!0,get:function(){return Ir.CodeGen}});var WB=Uo();Object.defineProperty(X,"ValidationError",{enumerable:!0,get:function(){return WB.default}});var VB=gs();Object.defineProperty(X,"MissingRefError",{enumerable:!0,get:function(){return VB.default}})});var ep=Q(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.formatNames=Xe.fastFormats=Xe.fullFormats=void 0;function Ze(t,e){return{validate:t,compare:e}}Xe.fullFormats={date:Ze(Vd,Qc),time:Ze(Ic(!0),_c),"date-time":Ze(Yd(!0),Zd),"iso-time":Ze(Ic(),Kd),"iso-date-time":Ze(Yd(),Xd),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:rQ,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?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&'"()*+,;=:@/?]|%[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:lQ,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:sQ,int32:{type:"number",validate:iQ},int64:{type:"number",validate:aQ},float:{type:"number",validate:Wd},double:{type:"number",validate:Wd},password:!0,binary:!0};Xe.fastFormats={...Xe.fullFormats,date:Ze(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Qc),time:Ze(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,_c),"date-time":Ze(/^\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,Zd),"iso-time":Ze(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Kd),"iso-date-time":Ze(/^\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,Xd),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};Xe.formatNames=Object.keys(Xe.fullFormats);function KB(t){return t%4===0&&(t%100!==0||t%400===0)}var ZB=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,XB=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Vd(t){let e=ZB.exec(t);if(!e)return!1;let r=+e[1],s=+e[2],o=+e[3];return s>=1&&s<=12&&o>=1&&o<=(s===2&&KB(r)?29:XB[s])}function Qc(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Cc=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Ic(t){return function(r){let s=Cc.exec(r);if(!s)return!1;let o=+s[1],n=+s[2],i=+s[3],a=s[4],c=s[5]==="-"?-1:1,u=+(s[6]||0),l=+(s[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&n<=59&&i<60)return!0;let A=n-l*c,p=o-u*c-(A<0?1:0);return(p===23||p===-1)&&(A===59||A===-1)&&i<61}}function _c(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),s=new Date("2020-01-01T"+e).valueOf();if(r&&s)return r-s}function Kd(t,e){if(!(t&&e))return;let r=Cc.exec(t),s=Cc.exec(e);if(r&&s)return t=r[1]+r[2]+r[3],e=s[1]+s[2]+s[3],t>e?1:t<e?-1:0}var Bc=/t|\s/i;function Yd(t){let e=Ic(t);return function(s){let o=s.split(Bc);return o.length===2&&Vd(o[0])&&e(o[1])}}function Zd(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),s=new Date(e).valueOf();if(r&&s)return r-s}function Xd(t,e){if(!(t&&e))return;let[r,s]=t.split(Bc),[o,n]=e.split(Bc),i=Qc(r,o);if(i!==void 0)return i||_c(s,n)}var eQ=/\/|:/,tQ=/^(?:[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 rQ(t){return eQ.test(t)&&tQ.test(t)}var Jd=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function sQ(t){return Jd.lastIndex=0,Jd.test(t)}var oQ=-(2**31),nQ=2**31-1;function iQ(t){return Number.isInteger(t)&&t<=nQ&&t>=oQ}function aQ(t){return Number.isInteger(t)}function Wd(){return!0}var cQ=/[^\\]\\Z/;function lQ(t){if(cQ.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var tp=Q(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.formatLimitDefinition=void 0;var uQ=wc(),Ge=N(),St=Ge.operators,cn={formatMaximum:{okStr:"<=",ok:St.LTE,fail:St.GT},formatMinimum:{okStr:">=",ok:St.GTE,fail:St.LT},formatExclusiveMaximum:{okStr:"<",ok:St.LT,fail:St.GTE},formatExclusiveMinimum:{okStr:">",ok:St.GT,fail:St.LTE}},AQ={message:({keyword:t,schemaCode:e})=>(0,Ge.str)`should be ${cn[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Ge._)`{comparison: ${cn[t].okStr}, limit: ${e}}`};Br.formatLimitDefinition={keyword:Object.keys(cn),type:"string",schemaType:"string",$data:!0,error:AQ,code(t){let{gen:e,data:r,schemaCode:s,keyword:o,it:n}=t,{opts:i,self:a}=n;if(!i.validateFormats)return;let c=new uQ.KeywordCxt(n,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=e.const("fmt",(0,Ge._)`${p}[${c.schemaCode}]`);t.fail$data((0,Ge.or)((0,Ge._)`typeof ${m} != "object"`,(0,Ge._)`${m} instanceof RegExp`,(0,Ge._)`typeof ${m}.compare != "function"`,A(m)))}function l(){let p=c.schema,m=a.formats[p];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let g=e.scopeValue("formats",{key:p,ref:m,code:i.code.formats?(0,Ge._)`${i.code.formats}${(0,Ge.getProperty)(p)}`:void 0});t.fail$data(A(g))}function A(p){return(0,Ge._)`${p}.compare(${r}, ${s}) ${cn[o].fail} 0`}},dependencies:["format"]};var dQ=t=>(t.addKeyword(Br.formatLimitDefinition),t);Br.default=dQ});var np=Q((bs,op)=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});var Qr=ep(),pQ=tp(),Sc=N(),rp=new Sc.Name("fullFormats"),mQ=new Sc.Name("fastFormats"),kc=(t,e={keywords:!0})=>{if(Array.isArray(e))return sp(t,e,Qr.fullFormats,rp),t;let[r,s]=e.mode==="fast"?[Qr.fastFormats,mQ]:[Qr.fullFormats,rp],o=e.formats||Qr.formatNames;return sp(t,o,r,s),e.keywords&&(0,pQ.default)(t),t};kc.get=(t,e="full")=>{let s=(e==="fast"?Qr.fastFormats:Qr.fullFormats)[t];if(!s)throw new Error(`Unknown format "${t}"`);return s};function sp(t,e,r,s){var o,n;(o=(n=t.opts.code).formats)!==null&&o!==void 0||(n.formats=(0,Sc._)`require("ajv-formats/dist/formats").${s}`);for(let i of e)t.addFormat(i,r[i])}op.exports=bs=kc;Object.defineProperty(bs,"__esModule",{value:!0});bs.default=kc});var Tp=Q((qD,Dp)=>{"use strict";Dp.exports=Rp;Rp.sync=HQ;var bp=mt("fs");function GQ(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var s=0;s<r.length;s++){var o=r[s].toLowerCase();if(o&&t.substr(-o.length).toLowerCase()===o)return!0}return!1}function xp(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:GQ(e,r)}function Rp(t,e,r){bp.stat(t,function(s,o){r(s,s?!1:xp(o,t,e))})}function HQ(t,e){return xp(bp.statSync(t),t,e)}});var zp=Q((GD,Np)=>{"use strict";Np.exports=Pp;Pp.sync=YQ;var $p=mt("fs");function Pp(t,e,r){$p.stat(t,function(s,o){r(s,s?!1:jp(o,e))})}function YQ(t,e){return jp($p.statSync(t),e)}function jp(t,e){return t.isFile()&&JQ(t,e)}function JQ(t,e){var r=t.mode,s=t.uid,o=t.gid,n=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),i=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),u=parseInt("001",8),l=a|c,A=r&u||r&c&&o===i||r&a&&s===n||r&l&&n===0;return A}});var Fp=Q((YD,Up)=>{"use strict";var HD=mt("fs"),yn;process.platform==="win32"||global.TESTING_WINDOWS?yn=Tp():yn=zp();Up.exports=Yc;Yc.sync=WQ;function Yc(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(s,o){Yc(t,e||{},function(n,i){n?o(n):s(i)})})}yn(t,e||{},function(s,o){s&&(s.code==="EACCES"||e&&e.ignoreErrors)&&(s=null,o=!1),r(s,o)})}function WQ(t,e){try{return yn.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Jp=Q((JD,Yp)=>{"use strict";var Rr=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Op=mt("path"),VQ=Rr?";":":",Lp=Fp(),qp=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Gp=(t,e)=>{let r=e.colon||VQ,s=t.match(/\//)||Rr&&t.match(/\\/)?[""]:[...Rr?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],o=Rr?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",n=Rr?o.split(r):[""];return Rr&&t.indexOf(".")!==-1&&n[0]!==""&&n.unshift(""),{pathEnv:s,pathExt:n,pathExtExe:o}},Hp=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:s,pathExt:o,pathExtExe:n}=Gp(t,e),i=[],a=u=>new Promise((l,A)=>{if(u===s.length)return e.all&&i.length?l(i):A(qp(t));let p=s[u],m=/^".*"$/.test(p)?p.slice(1,-1):p,g=Op.join(m,t),f=!m&&/^\.[\\\/]/.test(t)?t.slice(0,2)+g:g;l(c(f,u,0))}),c=(u,l,A)=>new Promise((p,m)=>{if(A===o.length)return p(a(l+1));let g=o[A];Lp(u+g,{pathExt:n},(f,h)=>{if(!f&&h)if(e.all)i.push(u+g);else return p(u+g);return p(c(u,l,A+1))})});return r?a(0).then(u=>r(null,u),r):a(0)},KQ=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:s,pathExtExe:o}=Gp(t,e),n=[];for(let i=0;i<r.length;i++){let a=r[i],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=Op.join(c,t),l=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;for(let A=0;A<s.length;A++){let p=l+s[A];try{if(Lp.sync(p,{pathExt:o}))if(e.all)n.push(p);else return p}catch{}}}if(e.all&&n.length)return n;if(e.nothrow)return null;throw qp(t)};Yp.exports=Hp;Hp.sync=KQ});var Vp=Q((WD,Jc)=>{"use strict";var Wp=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(s=>s.toUpperCase()==="PATH")||"Path"};Jc.exports=Wp;Jc.exports.default=Wp});var em=Q((VD,Xp)=>{"use strict";var Kp=mt("path"),ZQ=Jp(),XQ=Vp();function Zp(t,e){let r=t.options.env||process.env,s=process.cwd(),o=t.options.cwd!=null,n=o&&process.chdir!==void 0&&!process.chdir.disabled;if(n)try{process.chdir(t.options.cwd)}catch{}let i;try{i=ZQ.sync(t.command,{path:r[XQ({env:r})],pathExt:e?Kp.delimiter:void 0})}catch{}finally{n&&process.chdir(s)}return i&&(i=Kp.resolve(o?t.options.cwd:"",i)),i}function e_(t){return Zp(t)||Zp(t,!0)}Xp.exports=e_});var tm=Q((KD,Vc)=>{"use strict";var Wc=/([()\][%!^"`<>&|;, *?])/g;function t_(t){return t=t.replace(Wc,"^$1"),t}function r_(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(Wc,"^$1"),e&&(t=t.replace(Wc,"^$1")),t}Vc.exports.command=t_;Vc.exports.argument=r_});var sm=Q((ZD,rm)=>{"use strict";rm.exports=/^#!(.*)/});var nm=Q((XD,om)=>{"use strict";var s_=sm();om.exports=(t="")=>{let e=t.match(s_);if(!e)return null;let[r,s]=e[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?s:s?`${o} ${s}`:o}});var am=Q((eT,im)=>{"use strict";var Kc=mt("fs"),o_=nm();function n_(t){let r=Buffer.alloc(150),s;try{s=Kc.openSync(t,"r"),Kc.readSync(s,r,0,150,0),Kc.closeSync(s)}catch{}return o_(r.toString())}im.exports=n_});var Am=Q((tT,um)=>{"use strict";var i_=mt("path"),cm=em(),lm=tm(),a_=am(),c_=process.platform==="win32",l_=/\.(?:com|exe)$/i,u_=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function A_(t){t.file=cm(t);let e=t.file&&a_(t.file);return e?(t.args.unshift(t.file),t.command=e,cm(t)):t.file}function d_(t){if(!c_)return t;let e=A_(t),r=!l_.test(e);if(t.options.forceShell||r){let s=u_.test(e);t.command=i_.normalize(t.command),t.command=lm.command(t.command),t.args=t.args.map(n=>lm.argument(n,s));let o=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${o}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function p_(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let s={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?s:d_(s)}um.exports=p_});var mm=Q((rT,pm)=>{"use strict";var Zc=process.platform==="win32";function Xc(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function m_(t,e){if(!Zc)return;let r=t.emit;t.emit=function(s,o){if(s==="exit"){let n=dm(o,e);if(n)return r.call(t,"error",n)}return r.apply(t,arguments)}}function dm(t,e){return Zc&&t===1&&!e.file?Xc(e.original,"spawn"):null}function f_(t,e){return Zc&&t===1&&!e.file?Xc(e.original,"spawnSync"):null}pm.exports={hookChildProcess:m_,verifyENOENT:dm,verifyENOENTSync:f_,notFoundError:Xc}});var hm=Q((sT,Dr)=>{"use strict";var fm=mt("child_process"),el=Am(),tl=mm();function gm(t,e,r){let s=el(t,e,r),o=fm.spawn(s.command,s.args,s.options);return tl.hookChildProcess(o,s),o}function g_(t,e,r){let s=el(t,e,r),o=fm.spawnSync(s.command,s.args,s.options);return o.error=o.error||tl.verifyENOENTSync(o.status,s),o}Dr.exports=gm;Dr.exports.spawn=gm;Dr.exports.sync=g_;Dr.exports._parse=el;Dr.exports._enoent=tl});var Bm=Q(sl=>{"use strict";var wm=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Cm=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,B_=/\\([\u000b\u0020-\u00ff])/g,Q_=/([\\"])/g,Im=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;sl.format=__;sl.parse=S_;function __(t){if(!t||typeof t!="object")throw new TypeError("argument obj is required");var e=t.parameters,r=t.type;if(!r||!Im.test(r))throw new TypeError("invalid type");var s=r;if(e&&typeof e=="object")for(var o,n=Object.keys(e).sort(),i=0;i<n.length;i++){if(o=n[i],!Cm.test(o))throw new TypeError("invalid parameter name");s+="; "+o+"="+M_(e[o])}return s}function S_(t){if(!t)throw new TypeError("argument string is required");var e=typeof t=="object"?k_(t):t;if(typeof e!="string")throw new TypeError("argument string is required to be a string");var r=e.indexOf(";"),s=r!==-1?e.slice(0,r).trim():e.trim();if(!Im.test(s))throw new TypeError("invalid media type");var o=new v_(s.toLowerCase());if(r!==-1){var n,i,a;for(wm.lastIndex=r;i=wm.exec(e);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,n=i[1].toLowerCase(),a=i[2],a.charCodeAt(0)===34&&(a=a.slice(1,-1),a.indexOf("\\")!==-1&&(a=a.replace(B_,"$1"))),o.parameters[n]=a}if(r!==e.length)throw new TypeError("invalid parameter format")}return o}function k_(t){var e;if(typeof t.getHeader=="function"?e=t.getHeader("content-type"):typeof t.headers=="object"&&(e=t.headers&&t.headers["content-type"]),typeof e!="string")throw new TypeError("content-type header is missing from object");return e}function M_(t){var e=String(t);if(Cm.test(e))return e;if(e.length>0&&!I_.test(e))throw new TypeError("invalid parameter value");return'"'+e.replace(Q_,"\\$1")+'"'}function v_(t){this.parameters=Object.create(null),this.type=t}});async function ii(t,e){switch(t.protocol){case"anthropic":{let{AnthropicClient:r}=await import("./anthropic-3NHEY4SF.js");return new r(t,e)}case"openai":{let{OpenAIClient:r}=await import("./openai-VS2R4V7J.js");return new r(t,e)}case"openai-compat":{let{OpenAICompatClient:r}=await import("./openai-VS2R4V7J.js");return new r(t,e)}default:throw new Error(`Unknown protocol: ${String(t.protocol)}`)}}var or="2025-11-25";var Wl=[or,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],gt="io.modelcontextprotocol/related-task",go="2.0",le=zl(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Vl=ee([d(),H().int()]),Kl=d(),cv=ce({ttl:H().optional(),pollInterval:H().optional()}),Pg=S({ttl:H().optional()}),jg=S({taskId:d()}),ci=ce({progressToken:Vl.optional(),[gt]:jg.optional()}),De=S({_meta:ci.optional()}),Yr=De.extend({task:Pg.optional()}),Zl=t=>Yr.safeParse(t).success,Ae=S({method:d(),params:De.loose().optional()}),Te=S({_meta:ci.optional()}),$e=S({method:d(),params:Te.loose().optional()}),de=ce({_meta:ci.optional()}),ho=ee([d(),H().int()]),Xl=S({jsonrpc:M(go),id:ho,...Ae.shape}).strict(),Jr=t=>Xl.safeParse(t).success,eu=S({jsonrpc:M(go),...$e.shape}).strict(),tu=t=>eu.safeParse(t).success,li=S({jsonrpc:M(go),id:ho,result:de}).strict(),xt=t=>li.safeParse(t).success;var T;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(T||(T={}));var ui=S({jsonrpc:M(go),id:ho.optional(),error:S({code:H().int(),message:d(),data:ne().optional()})}).strict();var ru=t=>ui.safeParse(t).success;var ht=ee([Xl,eu,li,ui]),lv=ee([li,ui]),Rt=de.strict(),Ng=Te.extend({requestId:ho.optional(),reason:d().optional()}),Eo=$e.extend({method:M("notifications/cancelled"),params:Ng}),zg=S({src:d(),mimeType:d().optional(),sizes:_(d()).optional(),theme:Re(["light","dark"]).optional()}),Wr=S({icons:_(zg).optional()}),sr=S({name:d(),title:d().optional()}),su=sr.extend({...sr.shape,...Wr.shape,version:d(),websiteUrl:d().optional(),description:d().optional()}),Ug=ri(S({applyDefaults:W().optional()}),K(d(),ne())),Fg=si(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,ri(S({form:Ug.optional(),url:le.optional()}),K(d(),ne()).optional())),Og=ce({list:le.optional(),cancel:le.optional(),requests:ce({sampling:ce({createMessage:le.optional()}).optional(),elicitation:ce({create:le.optional()}).optional()}).optional()}),Lg=ce({list:le.optional(),cancel:le.optional(),requests:ce({tools:ce({call:le.optional()}).optional()}).optional()}),qg=S({experimental:K(d(),le).optional(),sampling:S({context:le.optional(),tools:le.optional()}).optional(),elicitation:Fg.optional(),roots:S({listChanged:W().optional()}).optional(),tasks:Og.optional(),extensions:K(d(),le).optional()}),Gg=De.extend({protocolVersion:d(),capabilities:qg,clientInfo:su}),Hg=Ae.extend({method:M("initialize"),params:Gg});var Yg=S({experimental:K(d(),le).optional(),logging:le.optional(),completions:le.optional(),prompts:S({listChanged:W().optional()}).optional(),resources:S({subscribe:W().optional(),listChanged:W().optional()}).optional(),tools:S({listChanged:W().optional()}).optional(),tasks:Lg.optional(),extensions:K(d(),le).optional()}),Ai=de.extend({protocolVersion:d(),capabilities:Yg,serverInfo:su,instructions:d().optional()}),ou=$e.extend({method:M("notifications/initialized"),params:Te.optional()}),nu=t=>ou.safeParse(t).success,yo=Ae.extend({method:M("ping"),params:De.optional()}),Jg=S({progress:H(),total:re(H()),message:re(d())}),Wg=S({...Te.shape,...Jg.shape,progressToken:Vl}),wo=$e.extend({method:M("notifications/progress"),params:Wg}),Vg=De.extend({cursor:Kl.optional()}),Vr=Ae.extend({params:Vg.optional()}),Kr=de.extend({nextCursor:Kl.optional()}),Kg=Re(["working","input_required","completed","failed","cancelled"]),Zr=S({taskId:d(),status:Kg,ttl:ee([H(),jl()]),createdAt:d(),lastUpdatedAt:d(),pollInterval:re(H()),statusMessage:re(d())}),Dt=de.extend({task:Zr}),Zg=Te.merge(Zr),Xr=$e.extend({method:M("notifications/tasks/status"),params:Zg}),Co=Ae.extend({method:M("tasks/get"),params:De.extend({taskId:d()})}),Io=de.merge(Zr),Bo=Ae.extend({method:M("tasks/result"),params:De.extend({taskId:d()})}),uv=de.loose(),Qo=Vr.extend({method:M("tasks/list")}),_o=Kr.extend({tasks:_(Zr)}),So=Ae.extend({method:M("tasks/cancel"),params:De.extend({taskId:d()})}),iu=de.merge(Zr),au=S({uri:d(),mimeType:re(d()),_meta:K(d(),ne()).optional()}),cu=au.extend({text:d()}),di=d().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),lu=au.extend({blob:di}),es=Re(["user","assistant"]),nr=S({audience:_(es).optional(),priority:H().min(0).max(1).optional(),lastModified:Dl.datetime({offset:!0}).optional()}),uu=S({...sr.shape,...Wr.shape,uri:d(),description:re(d()),mimeType:re(d()),size:re(H()),annotations:nr.optional(),_meta:re(ce({}))}),Xg=S({...sr.shape,...Wr.shape,uriTemplate:d(),description:re(d()),mimeType:re(d()),annotations:nr.optional(),_meta:re(ce({}))}),eh=Vr.extend({method:M("resources/list")}),pi=Kr.extend({resources:_(uu)}),th=Vr.extend({method:M("resources/templates/list")}),mi=Kr.extend({resourceTemplates:_(Xg)}),fi=De.extend({uri:d()}),rh=fi,sh=Ae.extend({method:M("resources/read"),params:rh}),gi=de.extend({contents:_(ee([cu,lu]))}),hi=$e.extend({method:M("notifications/resources/list_changed"),params:Te.optional()}),oh=fi,nh=Ae.extend({method:M("resources/subscribe"),params:oh}),ih=fi,ah=Ae.extend({method:M("resources/unsubscribe"),params:ih}),ch=Te.extend({uri:d()}),lh=$e.extend({method:M("notifications/resources/updated"),params:ch}),uh=S({name:d(),description:re(d()),required:re(W())}),Ah=S({...sr.shape,...Wr.shape,description:re(d()),arguments:re(_(uh)),_meta:re(ce({}))}),dh=Vr.extend({method:M("prompts/list")}),Ei=Kr.extend({prompts:_(Ah)}),ph=De.extend({name:d(),arguments:K(d(),d()).optional()}),mh=Ae.extend({method:M("prompts/get"),params:ph}),yi=S({type:M("text"),text:d(),annotations:nr.optional(),_meta:K(d(),ne()).optional()}),wi=S({type:M("image"),data:di,mimeType:d(),annotations:nr.optional(),_meta:K(d(),ne()).optional()}),Ci=S({type:M("audio"),data:di,mimeType:d(),annotations:nr.optional(),_meta:K(d(),ne()).optional()}),fh=S({type:M("tool_use"),name:d(),id:d(),input:K(d(),ne()),_meta:K(d(),ne()).optional()}),gh=S({type:M("resource"),resource:ee([cu,lu]),annotations:nr.optional(),_meta:K(d(),ne()).optional()}),hh=uu.extend({type:M("resource_link")}),Ii=ee([yi,wi,Ci,hh,gh]),Eh=S({role:es,content:Ii}),Bi=de.extend({description:d().optional(),messages:_(Eh)}),Qi=$e.extend({method:M("notifications/prompts/list_changed"),params:Te.optional()}),yh=S({title:d().optional(),readOnlyHint:W().optional(),destructiveHint:W().optional(),idempotentHint:W().optional(),openWorldHint:W().optional()}),wh=S({taskSupport:Re(["required","optional","forbidden"]).optional()}),Au=S({...sr.shape,...Wr.shape,description:d().optional(),inputSchema:S({type:M("object"),properties:K(d(),le).optional(),required:_(d()).optional()}).catchall(ne()),outputSchema:S({type:M("object"),properties:K(d(),le).optional(),required:_(d()).optional()}).catchall(ne()).optional(),annotations:yh.optional(),execution:wh.optional(),_meta:K(d(),ne()).optional()}),Ch=Vr.extend({method:M("tools/list")}),_i=Kr.extend({tools:_(Au)}),ir=de.extend({content:_(Ii).default([]),structuredContent:K(d(),ne()).optional(),isError:W().optional()}),Av=ir.or(de.extend({toolResult:ne()})),Ih=Yr.extend({name:d(),arguments:K(d(),ne()).optional()}),Bh=Ae.extend({method:M("tools/call"),params:Ih}),Si=$e.extend({method:M("notifications/tools/list_changed"),params:Te.optional()}),du=S({autoRefresh:W().default(!0),debounceMs:H().int().nonnegative().default(300)}),pu=Re(["debug","info","notice","warning","error","critical","alert","emergency"]),Qh=De.extend({level:pu}),_h=Ae.extend({method:M("logging/setLevel"),params:Qh}),Sh=Te.extend({level:pu,logger:d().optional(),data:ne()}),kh=$e.extend({method:M("notifications/message"),params:Sh}),Mh=S({name:d().optional()}),vh=S({hints:_(Mh).optional(),costPriority:H().min(0).max(1).optional(),speedPriority:H().min(0).max(1).optional(),intelligencePriority:H().min(0).max(1).optional()}),bh=S({mode:Re(["auto","required","none"]).optional()}),xh=S({type:M("tool_result"),toolUseId:d().describe("The unique identifier for the corresponding tool call."),content:_(Ii).default([]),structuredContent:S({}).loose().optional(),isError:W().optional(),_meta:K(d(),ne()).optional()}),Rh=ti("type",[yi,wi,Ci]),fo=ti("type",[yi,wi,Ci,fh,xh]),Dh=S({role:es,content:ee([fo,_(fo)]),_meta:K(d(),ne()).optional()}),Th=Yr.extend({messages:_(Dh),modelPreferences:vh.optional(),systemPrompt:d().optional(),includeContext:Re(["none","thisServer","allServers"]).optional(),temperature:H().optional(),maxTokens:H().int(),stopSequences:_(d()).optional(),metadata:le.optional(),tools:_(Au).optional(),toolChoice:bh.optional()}),ki=Ae.extend({method:M("sampling/createMessage"),params:Th}),Mi=de.extend({model:d(),stopReason:re(Re(["endTurn","stopSequence","maxTokens"]).or(d())),role:es,content:Rh}),vi=de.extend({model:d(),stopReason:re(Re(["endTurn","stopSequence","maxTokens","toolUse"]).or(d())),role:es,content:ee([fo,_(fo)])}),$h=S({type:M("boolean"),title:d().optional(),description:d().optional(),default:W().optional()}),Ph=S({type:M("string"),title:d().optional(),description:d().optional(),minLength:H().optional(),maxLength:H().optional(),format:Re(["email","uri","date","date-time"]).optional(),default:d().optional()}),jh=S({type:Re(["number","integer"]),title:d().optional(),description:d().optional(),minimum:H().optional(),maximum:H().optional(),default:H().optional()}),Nh=S({type:M("string"),title:d().optional(),description:d().optional(),enum:_(d()),default:d().optional()}),zh=S({type:M("string"),title:d().optional(),description:d().optional(),oneOf:_(S({const:d(),title:d()})),default:d().optional()}),Uh=S({type:M("string"),title:d().optional(),description:d().optional(),enum:_(d()),enumNames:_(d()).optional(),default:d().optional()}),Fh=ee([Nh,zh]),Oh=S({type:M("array"),title:d().optional(),description:d().optional(),minItems:H().optional(),maxItems:H().optional(),items:S({type:M("string"),enum:_(d())}),default:_(d()).optional()}),Lh=S({type:M("array"),title:d().optional(),description:d().optional(),minItems:H().optional(),maxItems:H().optional(),items:S({anyOf:_(S({const:d(),title:d()}))}),default:_(d()).optional()}),qh=ee([Oh,Lh]),Gh=ee([Uh,Fh,qh]),Hh=ee([Gh,$h,Ph,jh]),Yh=Yr.extend({mode:M("form").optional(),message:d(),requestedSchema:S({type:M("object"),properties:K(d(),Hh),required:_(d()).optional()})}),Jh=Yr.extend({mode:M("url"),message:d(),elicitationId:d(),url:d().url()}),Wh=ee([Yh,Jh]),bi=Ae.extend({method:M("elicitation/create"),params:Wh}),Vh=Te.extend({elicitationId:d()}),Kh=$e.extend({method:M("notifications/elicitation/complete"),params:Vh}),xi=de.extend({action:Re(["accept","decline","cancel"]),content:si(t=>t===null?void 0:t,K(d(),ee([d(),H(),W(),_(d())])).optional())}),Zh=S({type:M("ref/resource"),uri:d()});var Xh=S({type:M("ref/prompt"),name:d()}),eE=De.extend({ref:ee([Xh,Zh]),argument:S({name:d(),value:d()}),context:S({arguments:K(d(),d()).optional()}).optional()}),tE=Ae.extend({method:M("completion/complete"),params:eE});var Ri=de.extend({completion:ce({values:_(d()).max(100),total:re(H().int()),hasMore:re(W())})}),rE=S({uri:d().startsWith("file://"),name:d().optional(),_meta:K(d(),ne()).optional()}),sE=Ae.extend({method:M("roots/list"),params:De.optional()}),oE=de.extend({roots:_(rE)}),nE=$e.extend({method:M("notifications/roots/list_changed"),params:Te.optional()}),dv=ee([yo,Hg,tE,_h,mh,dh,eh,th,sh,nh,ah,Bh,Ch,Co,Bo,Qo,So]),pv=ee([Eo,wo,ou,nE,Xr]),mv=ee([Rt,Mi,vi,xi,oE,Io,_o,Dt]),fv=ee([yo,ki,bi,sE,Co,Bo,Qo,So]),gv=ee([Eo,wo,kh,lh,hi,Si,Qi,Xr,Kh]),hv=ee([Rt,Ai,Ri,Bi,Ei,pi,mi,gi,ir,_i,Io,_o,Dt]),x=class t extends Error{constructor(e,r,s){super(`MCP error ${e}: ${r}`),this.code=e,this.data=s,this.name="McpError"}static fromError(e,r,s){if(e===T.UrlElicitationRequired&&s){let o=s;if(o.elicitations)return new ai(o.elicitations,r)}return new t(e,r,s)}},ai=class extends x{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(T.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Et(t){return t==="completed"||t==="failed"||t==="cancelled"}var Vv=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Di(t){let r=lo(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let s=uo(r);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function Ti(t,e){let r=Ue(t,e);if(!r.success)throw r.error;return r.data}var AE=6e4,ko=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Eo,r=>{this._oncancel(r)}),this.setNotificationHandler(wo,r=>{this._onprogress(r)}),this.setRequestHandler(yo,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Co,async(r,s)=>{let o=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!o)throw new x(T.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Bo,async(r,s)=>{let o=async()=>{let n=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(n,s.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let A=c,p=new x(A.error.code,A.error.message,A.error.data);l(p)}else{let A=a.type==="response"?"Response":"Error";this._onerror(new Error(`${A} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:s.requestId})}}let i=await this._taskStore.getTask(n,s.sessionId);if(!i)throw new x(T.InvalidParams,`Task not found: ${n}`);if(!Et(i.status))return await this._waitForTaskUpdate(n,s.signal),await o();if(Et(i.status)){let a=await this._taskStore.getTaskResult(n,s.sessionId);return this._clearTaskQueue(n),{...a,_meta:{...a._meta,[gt]:{taskId:n}}}}return await o()};return await o()}),this.setRequestHandler(Qo,async(r,s)=>{try{let{tasks:o,nextCursor:n}=await this._taskStore.listTasks(r.params?.cursor,s.sessionId);return{tasks:o,nextCursor:n,_meta:{}}}catch(o){throw new x(T.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(So,async(r,s)=>{try{let o=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!o)throw new x(T.InvalidParams,`Task not found: ${r.params.taskId}`);if(Et(o.status))throw new x(T.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(r.params.taskId);let n=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!n)throw new x(T.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...n}}catch(o){throw o instanceof x?o:new x(T.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,s,o,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:s,resetTimeoutOnProgress:n,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let s=Date.now()-r.startTime;if(r.maxTotalTimeout&&s>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),x.fromError(T.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:s});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let s=this.transport?.onerror;this._transport.onerror=n=>{s?.(n),this._onerror(n)};let o=this._transport?.onmessage;this._transport.onmessage=(n,i)=>{o?.(n,i),xt(n)||ru(n)?this._onresponse(n):Jr(n)?this._onrequest(n,i):tu(n)?this._onnotification(n):this._onerror(new Error(`Unknown message type: ${JSON.stringify(n)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(let s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();let r=x.fromError(T.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let s of e.values())s(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,r){let s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,n=e.params?._meta?.[gt]?.taskId;if(s===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:T.MethodNotFound,message:"Method not found"}};n&&this._taskMessageQueue?this._enqueueTaskMessage(n,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(A=>this._onerror(new Error(`Failed to enqueue error response: ${A}`))):o?.send(l).catch(A=>this._onerror(new Error(`Failed to send an error response: ${A}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=Zl(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let A={relatedRequestId:e.id};n&&(A.relatedTask={taskId:n}),await this.notification(l,A)},sendRequest:async(l,A,p)=>{if(i.signal.aborted)throw new x(T.ConnectionClosed,"Request was cancelled");let m={...p,relatedRequestId:e.id};n&&!m.relatedTask&&(m.relatedTask={taskId:n});let g=m.relatedTask?.taskId??n;return g&&c&&await c.updateTaskStatus(g,"input_required"),await this.request(l,A,m)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:n,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,u)).then(async l=>{if(i.signal.aborted)return;let A={result:l,jsonrpc:"2.0",id:e.id};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"response",message:A,timestamp:Date.now()},o?.sessionId):await o?.send(A)},async l=>{if(i.signal.aborted)return;let A={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:T.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"error",message:A,timestamp:Date.now()},o?.sessionId):await o?.send(A)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...s}=e.params,o=Number(r),n=this._progressHandlers.get(o);if(!n){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}n(s)}_onresponse(e){let r=Number(e.id),s=this._requestResolvers.get(r);if(s){if(this._requestResolvers.delete(r),xt(e))s(e);else{let i=new x(e.error.code,e.error.message,e.error.data);s(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let n=!1;if(xt(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(n=!0,this._taskProgressTokens.set(a.taskId,r))}}if(n||this._progressHandlers.delete(r),xt(e))o(e);else{let i=x.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,s){let{task:o}=s??{};if(!o){try{yield{type:"result",result:await this.request(e,r,s)}}catch(i){yield{type:"error",error:i instanceof x?i:new x(T.InternalError,String(i))}}return}let n;try{let i=await this.request(e,Dt,s);if(i.task)n=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new x(T.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:n},s);if(yield{type:"taskStatus",task:a},Et(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:n},r,s)}:a.status==="failed"?yield{type:"error",error:new x(T.InternalError,`Task ${n} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new x(T.InternalError,`Task ${n} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:n},r,s)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),s?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof x?i:new x(T.InternalError,String(i))}}}request(e,r,s){let{relatedRequestId:o,resumptionToken:n,onresumptiontoken:i,task:a,relatedTask:c}=s??{};return new Promise((u,l)=>{let A=C=>{l(C)};if(!this._transport){A(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(C){A(C);return}s?.signal?.throwIfAborted();let p=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:p};s?.onprogress&&(this._progressHandlers.set(p,s.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[gt]:c}});let g=C=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(C)}},{relatedRequestId:o,resumptionToken:n,onresumptiontoken:i}).catch(b=>this._onerror(new Error(`Failed to send cancellation: ${b}`)));let I=C instanceof x?C:new x(T.RequestTimeout,String(C));l(I)};this._responseHandlers.set(p,C=>{if(!s?.signal?.aborted){if(C instanceof Error)return l(C);try{let I=Ue(r,C.result);I.success?u(I.data):l(I.error)}catch(I){l(I)}}}),s?.signal?.addEventListener("abort",()=>{g(s?.signal?.reason)});let f=s?.timeout??AE,h=()=>g(x.fromError(T.RequestTimeout,"Request timed out",{timeout:f}));this._setupTimeout(p,f,s?.maxTotalTimeout,h,s?.resetTimeoutOnProgress??!1);let w=c?.taskId;if(w){let C=I=>{let b=this._responseHandlers.get(p);b?b(I):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,C),this._enqueueTaskMessage(w,{type:"request",message:m,timestamp:Date.now()}).catch(I=>{this._cleanupTimeout(p),l(I)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:n,onresumptiontoken:i}).catch(C=>{this._cleanupTimeout(p),l(C)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Io,r)}async getTaskResult(e,r,s){return this.request({method:"tasks/result",params:e},r,s)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},_o,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},iu,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let s=r?.relatedTask?.taskId;if(s){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[gt]:r.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[gt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[gt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let s=Di(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(o,n)=>{let i=Ti(e,o);return Promise.resolve(r(i,n))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let s=Di(e);this._notificationHandlers.set(s,o=>{let n=Ti(e,o);return Promise.resolve(r(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,s){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,s,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let s=await this._taskMessageQueue.dequeueAll(e,r);for(let o of s)if(o.type==="request"&&Jr(o.message)){let n=o.message.id,i=this._requestResolvers.get(n);i?(i(new x(T.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(n)):this._onerror(new Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let s=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(s=o.pollInterval)}catch{}return new Promise((o,n)=>{if(r.aborted){n(new x(T.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,s);r.addEventListener("abort",()=>{clearTimeout(i),n(new x(T.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await s.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let n=await s.getTask(o,r);if(!n)throw new x(T.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(o,n,i)=>{await s.storeTaskResult(o,n,i,r);let a=await s.getTask(o,r);if(a){let c=Xr.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Et(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>s.getTaskResult(o,r),updateTaskStatus:async(o,n,i)=>{let a=await s.getTask(o,r);if(!a)throw new x(T.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Et(a.status))throw new x(T.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(o,n,i,r);let c=await s.getTask(o,r);if(c){let u=Xr.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Et(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>s.listTasks(o,r)}}};function mu(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function fu(t,e){let r={...t};for(let s in e){let o=s,n=e[o];if(n===void 0)continue;let i=r[o];mu(i)&&mu(n)?r[o]={...i,...n}:r[o]=n}return r}var ip=co(wc(),1),ap=co(np(),1);function fQ(){let t=new ip.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,ap.default)(t),t}var ln=class{constructor(e){this._ajv=e??fQ()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return s=>r(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var un=class{constructor(e){this._client=e}async*callToolStream(e,r=ir,s){let o=this._client,n={...s,task:s?.task??(o.isToolTask(e.name)?{}:void 0)},i=o.requestStream({method:"tools/call",params:e},r,n),a=o.getToolOutputValidator(e.name);for await(let c of i){if(c.type==="result"&&a){let u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new x(T.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new x(T.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof x){yield{type:"error",error:l};return}yield{type:"error",error:new x(T.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(e,r){return this._client.getTask({taskId:e},r)}async getTaskResult(e,r,s){return this._client.getTaskResult({taskId:e},r,s)}async listTasks(e,r){return this._client.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._client.cancelTask({taskId:e},r)}requestStream(e,r,s){return this._client.requestStream(e,r,s)}};function cp(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function lp(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}function An(t,e){if(!(!t||e===null||typeof e!="object")){if(t.type==="object"&&t.properties&&typeof t.properties=="object"){let r=e,s=t.properties;for(let o of Object.keys(s)){let n=s[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(n,"default")&&(r[o]=n.default),r[o]!==void 0&&An(n,r[o])}}if(Array.isArray(t.anyOf))for(let r of t.anyOf)typeof r!="boolean"&&An(r,e);if(Array.isArray(t.oneOf))for(let r of t.oneOf)typeof r!="boolean"&&An(r,e)}}function gQ(t){if(!t)return{supportsFormMode:!1,supportsUrlMode:!1};let e=t.form!==void 0,r=t.url!==void 0;return{supportsFormMode:e||!e&&!r,supportsUrlMode:r}}var dn=class extends ko{constructor(e,r){super(r),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=r?.capabilities??{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new ln,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Si,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Qi,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",hi,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new un(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=fu(this._capabilities,e)}setRequestHandler(e,r){let o=lo(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let n=uo(o);if(typeof n!="string")throw new Error("Schema method literal must be a string");let i=n;if(i==="elicitation/create"){let a=async(c,u)=>{let l=Ue(bi,c);if(!l.success){let C=l.error instanceof Error?l.error.message:String(l.error);throw new x(T.InvalidParams,`Invalid elicitation request: ${C}`)}let{params:A}=l.data;A.mode=A.mode??"form";let{supportsFormMode:p,supportsUrlMode:m}=gQ(this._capabilities.elicitation);if(A.mode==="form"&&!p)throw new x(T.InvalidParams,"Client does not support form-mode elicitation requests");if(A.mode==="url"&&!m)throw new x(T.InvalidParams,"Client does not support URL-mode elicitation requests");let g=await Promise.resolve(r(c,u));if(A.task){let C=Ue(Dt,g);if(!C.success){let I=C.error instanceof Error?C.error.message:String(C.error);throw new x(T.InvalidParams,`Invalid task creation result: ${I}`)}return C.data}let f=Ue(xi,g);if(!f.success){let C=f.error instanceof Error?f.error.message:String(f.error);throw new x(T.InvalidParams,`Invalid elicitation result: ${C}`)}let h=f.data,w=A.mode==="form"?A.requestedSchema:void 0;if(A.mode==="form"&&h.action==="accept"&&h.content&&w&&this._capabilities.elicitation?.form?.applyDefaults)try{An(w,h.content)}catch{}return h};return super.setRequestHandler(e,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=Ue(ki,c);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new x(T.InvalidParams,`Invalid sampling request: ${h}`)}let{params:A}=l.data,p=await Promise.resolve(r(c,u));if(A.task){let h=Ue(Dt,p);if(!h.success){let w=h.error instanceof Error?h.error.message:String(h.error);throw new x(T.InvalidParams,`Invalid task creation result: ${w}`)}return h.data}let g=A.tools||A.toolChoice?vi:Mi,f=Ue(g,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new x(T.InvalidParams,`Invalid sampling result: ${h}`)}return f.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapability(e,r){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${r})`)}async connect(e,r){if(await super.connect(e),e.sessionId===void 0)try{let s=await this.request({method:"initialize",params:{protocolVersion:or,capabilities:this._capabilities,clientInfo:this._clientInfo}},Ai,r);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!Wl.includes(s.protocolVersion))throw new Error(`Server's protocol version is not supported: ${s.protocolVersion}`);this._serverCapabilities=s.capabilities,this._serverVersion=s.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(s.protocolVersion),this._instructions=s.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(s){throw this.close(),s}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break;case"ping":break}}assertTaskCapability(e){cp(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&lp(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},Rt,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},Ri,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},Rt,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},Bi,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},Ei,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},pi,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},mi,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},gi,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},Rt,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},Rt,r)}async callTool(e,r=ir,s){if(this.isToolTaskRequired(e.name))throw new x(T.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let o=await this.request({method:"tools/call",params:e},r,s),n=this.getToolOutputValidator(e.name);if(n){if(!o.structuredContent&&!o.isError)throw new x(T.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(o.structuredContent)try{let i=n(o.structuredContent);if(!i.valid)throw new x(T.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof x?i:new x(T.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return o}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of e){if(r.outputSchema){let o=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,o)}let s=r.execution?.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(r.name),s==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){let s=await this.request({method:"tools/list",params:e},_i,r);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,r,s,o){let n=du.safeParse(s);if(!n.success)throw new Error(`Invalid ${e} listChanged options: ${n.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=n.data,{onChanged:c}=s,u=async()=>{if(!i){c(null,null);return}try{let A=await o();c(null,A)}catch(A){let p=A instanceof Error?A:new Error(String(A));c(p,null)}},l=()=>{if(a){let A=this._listChangedDebounceTimers.get(e);A&&clearTimeout(A);let p=setTimeout(u,a);this._listChangedDebounceTimers.set(e,p)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var xs=class extends Error{constructor(e,r){super(e),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}},up=10,hQ=13,Gt=32;function Mc(t){}function pn(t){if(typeof t=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:e=Mc,onError:r=Mc,onRetry:s=Mc,onComment:o,maxBufferSize:n}=t,i=[],a=0,c=!0,u,l="",A=0,p,m=!1;function g(E){if(m)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,E.charCodeAt(0)===239&&E.charCodeAt(1)===187&&E.charCodeAt(2)===191&&(E=E.slice(3))),i.length===0){let se=h(E);se!==""&&(i.push(se),a=se.length),f();return}if(E.indexOf(`
|
|
12
|
+
`)===-1&&E.indexOf("\r")===-1){i.push(E),a+=E.length,f();return}i.push(E);let B=i.join("");i.length=0,a=0;let P=h(B);P!==""&&(i.push(P),a=P.length),f()}function f(){n!==void 0&&(a+l.length<=n||(m=!0,i.length=0,a=0,u=void 0,l="",A=0,p=void 0,r(new xs(`Buffered data exceeded max buffer size of ${n} characters`,{type:"max-buffer-size-exceeded"}))))}function h(E){let B=0;if(E.indexOf("\r")===-1){let P=E.indexOf(`
|
|
13
|
+
`,B);for(;P!==-1;){if(B===P){A>0&&e({id:u,event:p,data:l}),u=void 0,l="",A=0,p=void 0,B=P+1,P=E.indexOf(`
|
|
14
|
+
`,B);continue}let se=E.charCodeAt(B);if(Ap(E,B,se)){let oe=E.charCodeAt(B+5)===Gt?B+6:B+5,_e=E.slice(oe,P);if(A===0&&E.charCodeAt(P+1)===up){e({id:u,event:p,data:_e}),u=void 0,l="",p=void 0,B=P+2,P=E.indexOf(`
|
|
15
|
+
`,B);continue}l=A===0?_e:`${l}
|
|
16
|
+
${_e}`,A++}else dp(E,B,se)?p=E.slice(E.charCodeAt(B+6)===Gt?B+7:B+6,P)||void 0:w(E,B,P);B=P+1,P=E.indexOf(`
|
|
17
|
+
`,B)}return E.slice(B)}for(;B<E.length;){let P=E.indexOf("\r",B),se=E.indexOf(`
|
|
18
|
+
`,B),oe=-1;if(P!==-1&&se!==-1?oe=P<se?P:se:P!==-1?P===E.length-1?oe=-1:oe=P:se!==-1&&(oe=se),oe===-1)break;w(E,B,oe),B=oe+1,E.charCodeAt(B-1)===hQ&&E.charCodeAt(B)===up&&B++}return E.slice(B)}function w(E,B,P){if(B===P){I();return}let se=E.charCodeAt(B);if(Ap(E,B,se)){let pt=E.charCodeAt(B+5)===Gt?B+6:B+5,bl=E.slice(pt,P);l=A===0?bl:`${l}
|
|
19
|
+
${bl}`,A++;return}if(dp(E,B,se)){p=E.slice(E.charCodeAt(B+6)===Gt?B+7:B+6,P)||void 0;return}if(se===105&&E.charCodeAt(B+1)===100&&E.charCodeAt(B+2)===58){let pt=E.slice(E.charCodeAt(B+3)===Gt?B+4:B+3,P);u=pt.includes("\0")?void 0:pt;return}if(se===58){if(o){let pt=E.slice(B,P);o(pt.slice(E.charCodeAt(B+1)===Gt?2:1))}return}let oe=E.slice(B,P),_e=oe.indexOf(":");if(_e===-1){C(oe,"",oe);return}let Gr=oe.slice(0,_e),io=oe.charCodeAt(_e+1)===Gt?2:1,ao=oe.slice(_e+io);C(Gr,ao,oe)}function C(E,B,P){switch(E){case"event":p=B||void 0;break;case"data":l=A===0?B:`${l}
|
|
20
|
+
${B}`,A++;break;case"id":u=B.includes("\0")?void 0:B;break;case"retry":/^\d+$/.test(B)?s(parseInt(B,10)):r(new xs(`Invalid \`retry\` value: "${B}"`,{type:"invalid-retry",value:B,line:P}));break;default:r(new xs(`Unknown field "${E.length>20?`${E.slice(0,20)}\u2026`:E}"`,{type:"unknown-field",field:E,value:B,line:P}));break}}function I(){A>0&&e({id:u,event:p,data:l}),u=void 0,l="",A=0,p=void 0}function b(E={}){if(E.consume&&i.length>0){let B=i.join("");w(B,0,B.length)}c=!0,u=void 0,l="",A=0,p=void 0,i.length=0,a=0,m=!1}return{feed:g,reset:b}}function Ap(t,e,r){return r===100&&t.charCodeAt(e+1)===97&&t.charCodeAt(e+2)===116&&t.charCodeAt(e+3)===97&&t.charCodeAt(e+4)===58}function dp(t,e,r){return r===101&&t.charCodeAt(e+1)===118&&t.charCodeAt(e+2)===101&&t.charCodeAt(e+3)===110&&t.charCodeAt(e+4)===116&&t.charCodeAt(e+5)===58}var fn=class extends Event{constructor(e,r){var s,o;super(e),this.code=(s=r?.code)!=null?s:void 0,this.message=(o=r?.message)!=null?o:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,r,s){return s(pp(this),r)}[Symbol.for("Deno.customInspect")](e,r){return e(pp(this),r)}};function EQ(t){let e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function vc(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(vc).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${vc(t.cause)}`:t.message:`${t}`}function pp(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var fp=t=>{throw TypeError(t)},jc=(t,e,r)=>e.has(t)||fp("Cannot "+r),O=(t,e,r)=>(jc(t,e,"read from private field"),r?r.call(t):e.get(t)),ue=(t,e,r)=>e.has(t)?fp("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),te=(t,e,r,s)=>(jc(t,e,"write to private field"),e.set(t,r),r),nt=(t,e,r)=>(jc(t,e,"access private method"),r),xe,Ht,_r,mn,gn,Ts,Mr,$s,kt,Sr,vr,kr,Rs,He,bc,xc,Rc,mp,Dc,Tc,Ds,$c,Pc,Yt=class extends EventTarget{constructor(e,r){var s,o;super(),ue(this,He),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,ue(this,xe),ue(this,Ht),ue(this,_r),ue(this,mn),ue(this,gn),ue(this,Ts),ue(this,Mr),ue(this,$s,null),ue(this,kt),ue(this,Sr),ue(this,vr,null),ue(this,kr,null),ue(this,Rs,null),ue(this,xc,async n=>{var i;O(this,Sr).reset();let{body:a,redirected:c,status:u,headers:l}=n;if(u===204){nt(this,He,Ds).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?te(this,_r,new URL(n.url)):te(this,_r,void 0),u!==200){nt(this,He,Ds).call(this,`Non-200 status code (${u})`,u);return}if(!(l.get("content-type")||"").startsWith("text/event-stream")){nt(this,He,Ds).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(O(this,xe)===this.CLOSED)return;te(this,xe,this.OPEN);let A=new Event("open");if((i=O(this,Rs))==null||i.call(this,A),this.dispatchEvent(A),typeof a!="object"||!a||!("getReader"in a)){nt(this,He,Ds).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}let p=new TextDecoder,m=a.getReader(),g=!0;do{let{done:f,value:h}=await m.read();h&&O(this,Sr).feed(p.decode(h,{stream:!f})),f&&(g=!1,O(this,Sr).reset(),nt(this,He,$c).call(this))}while(g)}),ue(this,Rc,n=>{te(this,kt,void 0),!(n.name==="AbortError"||n.type==="aborted")&&nt(this,He,$c).call(this,vc(n))}),ue(this,Dc,n=>{typeof n.id=="string"&&te(this,$s,n.id);let i=new MessageEvent(n.event||"message",{data:n.data,origin:O(this,_r)?O(this,_r).origin:O(this,Ht).origin,lastEventId:n.id||""});O(this,kr)&&(!n.event||n.event==="message")&&O(this,kr).call(this,i),this.dispatchEvent(i)}),ue(this,Tc,n=>{te(this,Ts,n)}),ue(this,Pc,()=>{te(this,Mr,void 0),O(this,xe)===this.CONNECTING&&nt(this,He,bc).call(this)});try{if(e instanceof URL)te(this,Ht,e);else if(typeof e=="string")te(this,Ht,new URL(e,yQ()));else throw new Error("Invalid URL")}catch{throw EQ("An invalid or illegal string was specified")}te(this,Sr,pn({onEvent:O(this,Dc),onRetry:O(this,Tc)})),te(this,xe,this.CONNECTING),te(this,Ts,3e3),te(this,gn,(s=r?.fetch)!=null?s:globalThis.fetch),te(this,mn,(o=r?.withCredentials)!=null?o:!1),nt(this,He,bc).call(this)}get readyState(){return O(this,xe)}get url(){return O(this,Ht).href}get withCredentials(){return O(this,mn)}get onerror(){return O(this,vr)}set onerror(e){te(this,vr,e)}get onmessage(){return O(this,kr)}set onmessage(e){te(this,kr,e)}get onopen(){return O(this,Rs)}set onopen(e){te(this,Rs,e)}addEventListener(e,r,s){let o=r;super.addEventListener(e,o,s)}removeEventListener(e,r,s){let o=r;super.removeEventListener(e,o,s)}close(){O(this,Mr)&&clearTimeout(O(this,Mr)),O(this,xe)!==this.CLOSED&&(O(this,kt)&&O(this,kt).abort(),te(this,xe,this.CLOSED),te(this,kt,void 0))}};xe=new WeakMap,Ht=new WeakMap,_r=new WeakMap,mn=new WeakMap,gn=new WeakMap,Ts=new WeakMap,Mr=new WeakMap,$s=new WeakMap,kt=new WeakMap,Sr=new WeakMap,vr=new WeakMap,kr=new WeakMap,Rs=new WeakMap,He=new WeakSet,bc=function(){te(this,xe,this.CONNECTING),te(this,kt,new AbortController),O(this,gn)(O(this,Ht),nt(this,He,mp).call(this)).then(O(this,xc)).catch(O(this,Rc))},xc=new WeakMap,Rc=new WeakMap,mp=function(){var t;let e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...O(this,$s)?{"Last-Event-ID":O(this,$s)}:void 0},cache:"no-store",signal:(t=O(this,kt))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Dc=new WeakMap,Tc=new WeakMap,Ds=function(t,e){var r;O(this,xe)!==this.CLOSED&&te(this,xe,this.CLOSED);let s=new fn("error",{code:e,message:t});(r=O(this,vr))==null||r.call(this,s),this.dispatchEvent(s)},$c=function(t,e){var r;if(O(this,xe)===this.CLOSED)return;te(this,xe,this.CONNECTING);let s=new fn("error",{code:e,message:t});(r=O(this,vr))==null||r.call(this,s),this.dispatchEvent(s),te(this,Mr,setTimeout(O(this,Pc),O(this,Ts)))},Pc=new WeakMap,Yt.CONNECTING=0,Yt.OPEN=1,Yt.CLOSED=2;function yQ(){let t="document"in globalThis?globalThis.document:void 0;return t&&typeof t=="object"&&"baseURI"in t&&typeof t.baseURI=="string"?t.baseURI:void 0}function br(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}function hn(t=fetch,e){return e?async(r,s)=>{let o={...e,...s,headers:s?.headers?{...br(e.headers),...br(s.headers)}:e.headers};return t(r,o)}:t}var Nc;Nc=globalThis.crypto?.webcrypto??globalThis.crypto??import("crypto").then(t=>t.webcrypto);async function wQ(t){return(await Nc).getRandomValues(new Uint8Array(t))}async function CQ(t){let e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%e.length,s="";for(;s.length<t;){let o=await wQ(t-s.length);for(let n of o)n<r&&(s+=e[n%e.length])}return s}async function IQ(t){return await CQ(t)}async function BQ(t){let e=await(await Nc).subtle.digest("SHA-256",new TextEncoder().encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function zc(t){if(t||(t=43),t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;let e=await IQ(t),r=await BQ(e);return{code_verifier:e,code_challenge:r}}var ge=Pl().superRefine((t,e)=>{if(!URL.canParse(t))return e.addIssue({code:Ul.custom,message:"URL must be parseable",fatal:!0}),xl}).refine(t=>{let e=new URL(t);return e.protocol!=="javascript:"&&e.protocol!=="data:"&&e.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),hp=ce({resource:d().url(),authorization_servers:_(ge).optional(),jwks_uri:d().url().optional(),scopes_supported:_(d()).optional(),bearer_methods_supported:_(d()).optional(),resource_signing_alg_values_supported:_(d()).optional(),resource_name:d().optional(),resource_documentation:d().optional(),resource_policy_uri:d().url().optional(),resource_tos_uri:d().url().optional(),tls_client_certificate_bound_access_tokens:W().optional(),authorization_details_types_supported:_(d()).optional(),dpop_signing_alg_values_supported:_(d()).optional(),dpop_bound_access_tokens_required:W().optional()}),Uc=ce({issuer:d(),authorization_endpoint:ge,token_endpoint:ge,registration_endpoint:ge.optional(),scopes_supported:_(d()).optional(),response_types_supported:_(d()),response_modes_supported:_(d()).optional(),grant_types_supported:_(d()).optional(),token_endpoint_auth_methods_supported:_(d()).optional(),token_endpoint_auth_signing_alg_values_supported:_(d()).optional(),service_documentation:ge.optional(),revocation_endpoint:ge.optional(),revocation_endpoint_auth_methods_supported:_(d()).optional(),revocation_endpoint_auth_signing_alg_values_supported:_(d()).optional(),introspection_endpoint:d().optional(),introspection_endpoint_auth_methods_supported:_(d()).optional(),introspection_endpoint_auth_signing_alg_values_supported:_(d()).optional(),code_challenge_methods_supported:_(d()).optional(),client_id_metadata_document_supported:W().optional()}),QQ=ce({issuer:d(),authorization_endpoint:ge,token_endpoint:ge,userinfo_endpoint:ge.optional(),jwks_uri:ge,registration_endpoint:ge.optional(),scopes_supported:_(d()).optional(),response_types_supported:_(d()),response_modes_supported:_(d()).optional(),grant_types_supported:_(d()).optional(),acr_values_supported:_(d()).optional(),subject_types_supported:_(d()),id_token_signing_alg_values_supported:_(d()),id_token_encryption_alg_values_supported:_(d()).optional(),id_token_encryption_enc_values_supported:_(d()).optional(),userinfo_signing_alg_values_supported:_(d()).optional(),userinfo_encryption_alg_values_supported:_(d()).optional(),userinfo_encryption_enc_values_supported:_(d()).optional(),request_object_signing_alg_values_supported:_(d()).optional(),request_object_encryption_alg_values_supported:_(d()).optional(),request_object_encryption_enc_values_supported:_(d()).optional(),token_endpoint_auth_methods_supported:_(d()).optional(),token_endpoint_auth_signing_alg_values_supported:_(d()).optional(),display_values_supported:_(d()).optional(),claim_types_supported:_(d()).optional(),claims_supported:_(d()).optional(),service_documentation:d().optional(),claims_locales_supported:_(d()).optional(),ui_locales_supported:_(d()).optional(),claims_parameter_supported:W().optional(),request_parameter_supported:W().optional(),request_uri_parameter_supported:W().optional(),require_request_uri_registration:W().optional(),op_policy_uri:ge.optional(),op_tos_uri:ge.optional(),client_id_metadata_document_supported:W().optional()}),Ep=S({...QQ.shape,...Uc.pick({code_challenge_methods_supported:!0}).shape}),yp=S({access_token:d(),id_token:d().optional(),token_type:d(),expires_in:Fl.number().optional(),scope:d().optional(),refresh_token:d().optional()}).strip(),wp=S({error:d(),error_description:d().optional(),error_uri:d().optional()}),gp=ge.optional().or(M("").transform(()=>{})),_Q=S({redirect_uris:_(ge),token_endpoint_auth_method:d().optional(),grant_types:_(d()).optional(),response_types:_(d()).optional(),client_name:d().optional(),client_uri:ge.optional(),logo_uri:gp,scope:d().optional(),contacts:_(d()).optional(),tos_uri:gp,policy_uri:d().optional(),jwks_uri:ge.optional(),jwks:Nl().optional(),software_id:d().optional(),software_version:d().optional(),software_statement:d().optional()}).strip(),SQ=S({client_id:d(),client_secret:d().optional(),client_id_issued_at:H().optional(),client_secret_expires_at:H().optional()}).strip(),Cp=_Q.merge(SQ),kD=S({error:d(),error_description:d().optional()}).strip(),MD=S({token:d(),token_type_hint:d().optional()}).strip();function Ip(t){let e=typeof t=="string"?new URL(t):new URL(t.href);return e.hash="",e}function Bp({requestedResource:t,configuredResource:e}){let r=typeof t=="string"?new URL(t):new URL(t.href),s=typeof e=="string"?new URL(e):new URL(e.href);if(r.origin!==s.origin||r.pathname.length<s.pathname.length)return!1;let o=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return o.startsWith(n)}var ae=class extends Error{constructor(e,r){super(e),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Ps=class extends ae{};Ps.errorCode="invalid_request";var Jt=class extends ae{};Jt.errorCode="invalid_client";var Wt=class extends ae{};Wt.errorCode="invalid_grant";var Vt=class extends ae{};Vt.errorCode="unauthorized_client";var js=class extends ae{};js.errorCode="unsupported_grant_type";var Ns=class extends ae{};Ns.errorCode="invalid_scope";var zs=class extends ae{};zs.errorCode="access_denied";var it=class extends ae{};it.errorCode="server_error";var Us=class extends ae{};Us.errorCode="temporarily_unavailable";var Fs=class extends ae{};Fs.errorCode="unsupported_response_type";var Os=class extends ae{};Os.errorCode="unsupported_token_type";var Ls=class extends ae{};Ls.errorCode="invalid_token";var qs=class extends ae{};qs.errorCode="method_not_allowed";var Gs=class extends ae{};Gs.errorCode="too_many_requests";var Kt=class extends ae{};Kt.errorCode="invalid_client_metadata";var Hs=class extends ae{};Hs.errorCode="insufficient_scope";var Ys=class extends ae{};Ys.errorCode="invalid_target";var Qp={[Ps.errorCode]:Ps,[Jt.errorCode]:Jt,[Wt.errorCode]:Wt,[Vt.errorCode]:Vt,[js.errorCode]:js,[Ns.errorCode]:Ns,[zs.errorCode]:zs,[it.errorCode]:it,[Us.errorCode]:Us,[Fs.errorCode]:Fs,[Os.errorCode]:Os,[Ls.errorCode]:Ls,[qs.errorCode]:qs,[Gs.errorCode]:Gs,[Kt.errorCode]:Kt,[Hs.errorCode]:Hs,[Ys.errorCode]:Ys};var Be=class extends Error{constructor(e){super(e??"Unauthorized")}};function kQ(t){return["client_secret_basic","client_secret_post","none"].includes(t)}var Fc="code",Oc="S256";function MQ(t,e){let r=t.client_secret!==void 0;return"token_endpoint_auth_method"in t&&t.token_endpoint_auth_method&&kQ(t.token_endpoint_auth_method)&&(e.length===0||e.includes(t.token_endpoint_auth_method))?t.token_endpoint_auth_method:e.length===0?r?"client_secret_basic":"none":r&&e.includes("client_secret_basic")?"client_secret_basic":r&&e.includes("client_secret_post")?"client_secret_post":e.includes("none")?"none":r?"client_secret_post":"none"}function vQ(t,e,r,s){let{client_id:o,client_secret:n}=e;switch(t){case"client_secret_basic":bQ(o,n,r);return;case"client_secret_post":xQ(o,n,s);return;case"none":RQ(o,s);return;default:throw new Error(`Unsupported client authentication method: ${t}`)}}function bQ(t,e,r){if(!e)throw new Error("client_secret_basic authentication requires a client_secret");let s=btoa(`${t}:${e}`);r.set("Authorization",`Basic ${s}`)}function xQ(t,e,r){r.set("client_id",t),e&&r.set("client_secret",e)}function RQ(t,e){e.set("client_id",t)}async function Sp(t){let e=t instanceof Response?t.status:void 0,r=t instanceof Response?await t.text():t;try{let s=wp.parse(JSON.parse(r)),{error:o,error_description:n,error_uri:i}=s,a=Qp[o]||it;return new a(n||"",i)}catch(s){let o=`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${s}. Raw body: ${r}`;return new it(o)}}async function at(t,e){try{return await Lc(t,e)}catch(r){if(r instanceof Jt||r instanceof Vt)return await t.invalidateCredentials?.("all"),await Lc(t,e);if(r instanceof Wt)return await t.invalidateCredentials?.("tokens"),await Lc(t,e);throw r}}async function Lc(t,{serverUrl:e,authorizationCode:r,scope:s,resourceMetadataUrl:o,fetchFn:n}){let i=await t.discoveryState?.(),a,c,u,l=o;if(!l&&i?.resourceMetadataUrl&&(l=new URL(i.resourceMetadataUrl)),i?.authorizationServerUrl){if(c=i.authorizationServerUrl,a=i.resourceMetadata,u=i.authorizationServerMetadata??await Mp(c,{fetchFn:n}),!a)try{a=await kp(e,{resourceMetadataUrl:l},n)}catch{}(u!==i.authorizationServerMetadata||a!==i.resourceMetadata)&&await t.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}else{let I=await zQ(e,{resourceMetadataUrl:l,fetchFn:n});c=I.authorizationServerUrl,u=I.authorizationServerMetadata,a=I.resourceMetadata,await t.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}let A=await TQ(e,t,a),p=s||a?.scopes_supported?.join(" ")||t.clientMetadata.scope,m=await Promise.resolve(t.clientInformation());if(!m){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let I=u?.client_id_metadata_document_supported===!0,b=t.clientMetadataUrl;if(b&&!DQ(b))throw new Kt(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${b}`);if(I&&b)m={client_id:b},await t.saveClientInformation?.(m);else{if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");let B=await qQ(c,{metadata:u,clientMetadata:t.clientMetadata,scope:p,fetchFn:n});await t.saveClientInformation(B),m=B}}let g=!t.redirectUrl;if(r!==void 0||g){let I=await LQ(t,c,{metadata:u,resource:A,authorizationCode:r,fetchFn:n});return await t.saveTokens(I),"AUTHORIZED"}let f=await t.tokens();if(f?.refresh_token)try{let I=await OQ(c,{metadata:u,clientInformation:m,refreshToken:f.refresh_token,resource:A,addClientAuthentication:t.addClientAuthentication,fetchFn:n});return await t.saveTokens(I),"AUTHORIZED"}catch(I){if(!(!(I instanceof ae)||I instanceof it))throw I}let h=t.state?await t.state():void 0,{authorizationUrl:w,codeVerifier:C}=await UQ(c,{metadata:u,clientInformation:m,state:h,redirectUrl:t.redirectUrl,scope:p,resource:A});return await t.saveCodeVerifier(C),await t.redirectToAuthorization(w),"REDIRECT"}function DQ(t){if(!t)return!1;try{let e=new URL(t);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}async function TQ(t,e,r){let s=Ip(t);if(e.validateResourceURL)return await e.validateResourceURL(s,r?.resource);if(r){if(!Bp({requestedResource:s,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${s} (or origin)`);return new URL(r.resource)}}function xr(t){let e=t.headers.get("WWW-Authenticate");if(!e)return{};let[r,s]=e.split(" ");if(r.toLowerCase()!=="bearer"||!s)return{};let o=qc(t,"resource_metadata")||void 0,n;if(o)try{n=new URL(o)}catch{}let i=qc(t,"scope")||void 0,a=qc(t,"error")||void 0;return{resourceMetadataUrl:n,scope:i,error:a}}function qc(t,e){let r=t.headers.get("WWW-Authenticate");if(!r)return null;let s=new RegExp(`${e}=(?:"([^"]+)"|([^\\s,]+))`),o=r.match(s);return o?o[1]||o[2]:null}async function kp(t,e,r=fetch){let s=await jQ(t,"oauth-protected-resource",r,{protocolVersion:e?.protocolVersion,metadataUrl:e?.resourceMetadataUrl});if(!s||s.status===404)throw await s?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!s.ok)throw await s.body?.cancel(),new Error(`HTTP ${s.status} trying to load well-known OAuth protected resource metadata.`);return hp.parse(await s.json())}async function Gc(t,e,r=fetch){try{return await r(t,{headers:e})}catch(s){if(s instanceof TypeError)return e?Gc(t,void 0,r):void 0;throw s}}function $Q(t,e="",r={}){return e.endsWith("/")&&(e=e.slice(0,-1)),r.prependPathname?`${e}/.well-known/${t}`:`/.well-known/${t}${e}`}async function _p(t,e,r=fetch){return await Gc(t,{"MCP-Protocol-Version":e},r)}function PQ(t,e){return!t||t.status>=400&&t.status<500&&e!=="/"}async function jQ(t,e,r,s){let o=new URL(t),n=s?.protocolVersion??or,i;if(s?.metadataUrl)i=new URL(s.metadataUrl);else{let c=$Q(e,o.pathname);i=new URL(c,s?.metadataServerUrl??o),i.search=o.search}let a=await _p(i,n,r);if(!s?.metadataUrl&&PQ(a,o.pathname)){let c=new URL(`/.well-known/${e}`,o);a=await _p(c,n,r)}return a}function NQ(t){let e=typeof t=="string"?new URL(t):t,r=e.pathname!=="/",s=[];if(!r)return s.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),s.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),s;let o=e.pathname;return o.endsWith("/")&&(o=o.slice(0,-1)),s.push({url:new URL(`/.well-known/oauth-authorization-server${o}`,e.origin),type:"oauth"}),s.push({url:new URL(`/.well-known/openid-configuration${o}`,e.origin),type:"oidc"}),s.push({url:new URL(`${o}/.well-known/openid-configuration`,e.origin),type:"oidc"}),s}async function Mp(t,{fetchFn:e=fetch,protocolVersion:r=or}={}){let s={"MCP-Protocol-Version":r,Accept:"application/json"},o=NQ(t);for(let{url:n,type:i}of o){let a=await Gc(n,s,e);if(a){if(!a.ok){if(await a.body?.cancel(),a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${n}`)}return i==="oauth"?Uc.parse(await a.json()):Ep.parse(await a.json())}}}async function zQ(t,e){let r,s;try{r=await kp(t,{resourceMetadataUrl:e?.resourceMetadataUrl},e?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(s=r.authorization_servers[0])}catch{}s||(s=String(new URL("/",t)));let o=await Mp(s,{fetchFn:e?.fetchFn});return{authorizationServerUrl:s,authorizationServerMetadata:o,resourceMetadata:r}}async function UQ(t,{metadata:e,clientInformation:r,redirectUrl:s,scope:o,state:n,resource:i}){let a;if(e){if(a=new URL(e.authorization_endpoint),!e.response_types_supported.includes(Fc))throw new Error(`Incompatible auth server: does not support response type ${Fc}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(Oc))throw new Error(`Incompatible auth server: does not support code challenge method ${Oc}`)}else a=new URL("/authorize",t);let c=await zc(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",Fc),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",Oc),a.searchParams.set("redirect_uri",String(s)),n&&a.searchParams.set("state",n),o&&a.searchParams.set("scope",o),o?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",i.href),{authorizationUrl:a,codeVerifier:u}}function FQ(t,e,r){return new URLSearchParams({grant_type:"authorization_code",code:t,code_verifier:e,redirect_uri:String(r)})}async function vp(t,{metadata:e,tokenRequestParams:r,clientInformation:s,addClientAuthentication:o,resource:n,fetchFn:i}){let a=e?.token_endpoint?new URL(e.token_endpoint):new URL("/token",t),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(n&&r.set("resource",n.href),o)await o(c,r,a,e);else if(s){let l=e?.token_endpoint_auth_methods_supported??[],A=MQ(s,l);vQ(A,s,c,r)}let u=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await Sp(u);return yp.parse(await u.json())}async function OQ(t,{metadata:e,clientInformation:r,refreshToken:s,resource:o,addClientAuthentication:n,fetchFn:i}){let a=new URLSearchParams({grant_type:"refresh_token",refresh_token:s}),c=await vp(t,{metadata:e,tokenRequestParams:a,clientInformation:r,addClientAuthentication:n,resource:o,fetchFn:i});return{refresh_token:s,...c}}async function LQ(t,e,{metadata:r,resource:s,authorizationCode:o,fetchFn:n}={}){let i=t.clientMetadata.scope,a;if(t.prepareTokenRequest&&(a=await t.prepareTokenRequest(i)),!a){if(!o)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!t.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let u=await t.codeVerifier();a=FQ(o,u,t.redirectUrl)}let c=await t.clientInformation();return vp(e,{metadata:r,tokenRequestParams:a,clientInformation:c??void 0,addClientAuthentication:t.addClientAuthentication,resource:s,fetchFn:n})}async function qQ(t,{metadata:e,clientMetadata:r,scope:s,fetchFn:o}){let n;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");n=new URL(e.registration_endpoint)}else n=new URL("/register",t);let i=await(o??fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...s!==void 0?{scope:s}:{}})});if(!i.ok)throw await Sp(i);return Cp.parse(await i.json())}var Hc=class extends Error{constructor(e,r,s){super(`SSE error: ${r}`),this.code=e,this.event=s}},En=class{constructor(e,r){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=r?.eventSourceInit,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=hn(r?.fetch,r?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new Be("No auth provider");let e;try{e=await at(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new Be;return await this._startOrAuth()}async _commonHeaders(){let e={};if(this._authProvider){let s=await this._authProvider.tokens();s&&(e.Authorization=`Bearer ${s.access_token}`)}this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);let r=br(this._requestInit?.headers);return new Headers({...e,...r})}_startOrAuth(){let e=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((r,s)=>{this._eventSource=new Yt(this._url.href,{...this._eventSourceInit,fetch:async(o,n)=>{let i=await this._commonHeaders();i.set("Accept","text/event-stream");let a=await e(o,{...n,headers:i});if(a.status===401&&a.headers.has("www-authenticate")){let{resourceMetadataUrl:c,scope:u}=xr(a);this._resourceMetadataUrl=c,this._scope=u}return a}}),this._abortController=new AbortController,this._eventSource.onerror=o=>{if(o.code===401&&this._authProvider){this._authThenStart().then(r,s);return}let n=new Hc(o.code,o.message,o);s(n),this.onerror?.(n)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",o=>{let n=o;try{if(this._endpoint=new URL(n.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(i){s(i),this.onerror?.(i),this.close();return}r()}),this._eventSource.onmessage=o=>{let n=o,i;try{i=ht.parse(JSON.parse(n.data))}catch(a){this.onerror?.(a);return}this.onmessage?.(i)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new Be("No auth provider");if(await at(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Be("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw new Error("Not connected");try{let r=await this._commonHeaders();r.set("content-type","application/json");let s={...this._requestInit,method:"POST",headers:r,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._endpoint,s);if(!o.ok){let n=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){let{resourceMetadataUrl:i,scope:a}=xr(o);if(this._resourceMetadataUrl=i,this._scope=a,await at(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Be;return this.send(e)}throw new Error(`Error POSTing to endpoint (HTTP ${o.status}): ${n}`)}await o.body?.cancel()}catch(r){throw this.onerror?.(r),r}}setProtocolVersion(e){this._protocolVersion=e}};var ym=co(hm(),1);import rl from"process";import{PassThrough as y_}from"stream";var h_=10*1024*1024,wn=class{constructor(e){this._maxBufferSize=e?.maxBufferSize??h_}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
21
|
+
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),E_(r)}clear(){this._buffer=void 0}};function E_(t){return ht.parse(JSON.parse(t))}function Em(t){return JSON.stringify(t)+`
|
|
22
|
+
`}var w_=rl.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function C_(){let t={};for(let e of w_){let r=rl.env[e];r!==void 0&&(r.startsWith("()")||(t[e]=r))}return t}var Cn=class{constructor(e){this._stderrStream=null,this._serverParams=e,this._readBuffer=new wn({maxBufferSize:e.maxBufferSize}),(e.stderr==="pipe"||e.stderr==="overlapped")&&(this._stderrStream=new y_)}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,r)=>{this._process=(0,ym.default)(this._serverParams.command,this._serverParams.args??[],{env:{...C_(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:rl.platform==="win32",cwd:this._serverParams.cwd}),this._process.on("error",s=>{r(s),this.onerror?.(s)}),this._process.on("spawn",()=>{e()}),this._process.on("close",s=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",s=>{this.onerror?.(s)}),this._process.stdout?.on("data",s=>{try{this._readBuffer.append(s),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}}),this._process.stdout?.on("error",s=>{this.onerror?.(s)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){return this._stderrStream?this._stderrStream:this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){if(this._process){let e=this._process;this._process=void 0;let r=new Promise(s=>{e.once("close",()=>{s()})});try{e.stdin?.end()}catch{}if(await Promise.race([r,new Promise(s=>setTimeout(s,2e3).unref())]),e.exitCode===null){try{e.kill("SIGTERM")}catch{}await Promise.race([r,new Promise(s=>setTimeout(s,2e3).unref())])}if(e.exitCode===null)try{e.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(e){return new Promise(r=>{if(!this._process?.stdin)throw new Error("Not connected");let s=Em(e);this._process.stdin.write(s)?r():this._process.stdin.once("drain",r)})}};var Qm=co(Bm(),1);function _m(t){if(t)try{return Qm.default.parse(t).type}catch{let e=(t.split(";",1)[0]??"").trim().toLowerCase();return e===""||t.slice(e.length).includes(",")?void 0:e}}var In=class extends TransformStream{constructor({onError:e,onRetry:r,onComment:s,maxBufferSize:o}={}){let n;super({start(i){n=pn({onEvent:a=>{i.enqueue(a)},onError(a){typeof e=="function"&&e(a),(e==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:s,maxBufferSize:o})},transform(i){n.feed(i)}})}};var b_={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Mt=class extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}},Bn=class{constructor(e,r){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=hn(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??b_}async _authThenStart(){if(!this._authProvider)throw new Be("No auth provider");let e;try{e=await at(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new Be;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let s=await this._authProvider.tokens();s&&(e.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);let r=br(this._requestInit?.headers);return new Headers({...e,...r})}async _startOrAuthSse(e){let{resumptionToken:r}=e;try{let s=await this._commonHeaders();s.set("Accept","text/event-stream"),r&&s.set("last-event-id",r);let o=await(this._fetch??fetch)(this._url,{method:"GET",headers:s,signal:this._abortController?.signal});if(!o.ok){if(await o.body?.cancel(),o.status===401&&this._authProvider)return await this._authThenStart();if(o.status===405)return;throw new Mt(o.status,`Failed to open SSE stream: ${o.statusText}`)}this._handleSseStream(o.body,e,!0)}catch(s){throw this.onerror?.(s),s}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,o=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(s,e),o)}_scheduleReconnection(e,r=0){let s=this._reconnectionOptions.maxRetries;if(r>=s){this.onerror?.(new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}let o=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,r+1)})},o)}_handleSseStream(e,r,s){if(!e)return;let{onresumptiontoken:o,replayMessageId:n}=r,i,a=!1,c=!1;(async()=>{try{let l=e.pipeThrough(new TextDecoderStream).pipeThrough(new In({onRetry:m=>{this._serverRetryMs=m}})).getReader();for(;;){let{value:m,done:g}=await l.read();if(g)break;if(m.id&&(i=m.id,a=!0,o?.(m.id)),!!m.data&&(!m.event||m.event==="message"))try{let f=ht.parse(JSON.parse(m.data));xt(f)&&(c=!0,n!==void 0&&(f.id=n)),this.onmessage?.(f)}catch(f){this.onerror?.(f)}}(s||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:n},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(s||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:n},0)}catch(m){this.onerror?.(new Error(`Failed to reconnect: ${m instanceof Error?m.message:String(m)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new Be("No auth provider");if(await at(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Be("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,r){try{let{resumptionToken:s,onresumptiontoken:o}=r||{};if(s){this._startOrAuthSse({resumptionToken:s,replayMessageId:Jr(e)?e.id:void 0}).catch(m=>this.onerror?.(m));return}let n=await this._commonHeaders();n.set("content-type","application/json"),n.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(e),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let m=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Mt(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:g,scope:f}=xr(a);if(this._resourceMetadataUrl=g,this._scope=f,await at(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Be;return this._hasCompletedAuthFlow=!0,this.send(e)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:g,scope:f,error:h}=xr(a);if(h==="insufficient_scope"){let w=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===w)throw new Mt(403,"Server returned 403 after trying upscoping");if(f&&(this._scope=f),g&&(this._resourceMetadataUrl=g),this._lastUpscopingHeader=w??void 0,await at(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Be;return this.send(e)}}throw new Mt(a.status,`Error POSTing to endpoint: ${m}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),nu(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(m=>this.onerror?.(m));return}let l=(Array.isArray(e)?e:[e]).filter(m=>"method"in m&&"id"in m&&m.id!==void 0).length>0,A=a.headers.get("content-type"),p=_m(A);if(l)if(p==="text/event-stream")this._handleSseStream(a.body,{onresumptiontoken:o},!1);else if(p==="application/json"){let m=await a.json(),g=Array.isArray(m)?m.map(f=>ht.parse(f)):[ht.parse(m)];for(let f of g)this.onmessage?.(f)}else throw await a.body?.cancel(),new Mt(-1,`Unexpected content type: ${A}`);else await a.body?.cancel()}catch(s){throw this.onerror?.(s),s}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._url,r);if(await s.body?.cancel(),!s.ok&&s.status!==405)throw new Mt(s.status,`Failed to terminate session: ${s.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,r){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:r?.onresumptiontoken})}};import{readFileSync as x_,statSync as R_}from"fs";import{extname as D_}from"path";import ol from"sharp";var T_=R({module:"images"});function Sm(t){if(t==="image/png"||t==="image/jpeg"||t==="image/gif"||t==="image/webp")return t;throw new Error(`Unsupported image media type: "${t}"`)}var al=5*1024*1024,nl=al*3/4,vt=2e3,QT=10,Tr=class extends Error{constructor(e){super(e),this.name="ImageTooLargeError"}},$_={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp"};function P_(t){return $_[D_(t).toLowerCase()]??null}function km(t){return P_(t)!==null}function j_(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?"image/png":t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255?"image/jpeg":t.length>=6&&t[0]===71&&t[1]===73&&t[2]===70?"image/gif":t.length>=12&&t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80?"image/webp":null}async function Mm(t){if(!R_(t).isFile())throw new Error(`Not a file: ${t}`);let r=x_(t),s=j_(r);if(!s)throw new Error(`File ${t} has an image extension but its contents are not a supported image format (png/jpeg/gif/webp)`);let o=await cl(r,s);return{mediaType:o.mediaType,data:o.data,sourcePath:t,byteLength:o.byteLength}}function il(t,e){return{data:t.toString("base64"),mediaType:e,byteLength:t.length}}function Js(t){return`${(t/(1024*1024)).toFixed(1)}MB`}async function cl(t,e){if(t.length===0)throw new Tr("Image file is empty (0 bytes)");if(t.length<=nl)return il(t,e);try{return await N_(t,e)}catch(r){throw r instanceof Tr?r:(T_.warn({err:r},"sharp compression failed"),new Tr(`Image is ${Js(t.length)} raw (${Js(t.length*4/3)} base64-encoded, API limit ${Js(al)}) and compression failed. Please provide a smaller image.`))}}async function N_(t,e){let r=await ol(t).metadata(),s=r.width??vt,o=r.height??vt;s>vt&&(o=Math.max(1,Math.round(o*vt/s)),s=vt),o>vt&&(s=Math.max(1,Math.round(s*vt/o)),o=vt);let n=e==="image/png"||e==="image/gif";for(let i=0;i<3;i++){if(n){let a=await ol(t).resize(s,o,{fit:"inside",withoutEnlargement:!0}).png({compressionLevel:8,palette:!0}).toBuffer();if(a.length<=nl)return il(a,"image/png")}for(let a of[80,60,40,20]){let c=await ol(t).resize(s,o,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:a}).toBuffer();if(c.length<=nl)return il(c,"image/jpeg")}s=Math.max(1,Math.round(s/2)),o=Math.max(1,Math.round(o/2))}throw new Tr(`Unable to compress image (${Js(t.length)} raw) under the ${Js(al)} API limit. Please provide a smaller image.`)}import{readFileSync as z_}from"fs";import vm from"path";import{fileURLToPath as U_}from"url";var F_=D.object({version:D.string()});function O_(){return"0.0.16"}var bm=O_();var Rm=R({module:"mcp"});function xm(t){return t.replace(/\$\{(\w+)\}|\$(\w+)/g,(e,r,s)=>process.env[r||s]??"")}function L_(t){let e={};for(let[r,s]of Object.entries(t))e[r]=s??"";return e}var q_=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function G_(t){let e=[],r=[];for(let o of t){let n=Ol(o)?o:{};if(n.type==="image"&&typeof n.data=="string"&&typeof n.mimeType=="string"&&q_.has(n.mimeType))try{let i=await cl(Buffer.from(n.data,"base64"),Sm(n.mimeType));r.push({type:"image",source:{type:"base64",media_type:i.mediaType,data:i.data}});continue}catch(i){Rm.warn({err:i},"mcp image dropped (too large to fit the API limit)"),e.push("[note: an image returned by the tool was too large and was dropped]");continue}e.push(n.type==="text"&&typeof n.text=="string"?n.text:JSON.stringify(o))}let s=e.join(`
|
|
23
|
+
`);return r.length===0?s:[...s?[{type:"text",text:s}]:[],...r]}var Qn=class{name;config;client=null;transport=null;constructor(e){this.name=e.name,this.config=e}async connect(){if(this.config.command){let e=process.env;if(this.config.env)for(let[r,s]of Object.entries(this.config.env))e[r]=xm(s);this.transport=new Cn({command:this.config.command,args:this.config.args??[],env:L_(e),stderr:"ignore"})}else if(this.config.url){let e=new URL(this.config.url),r={};if(this.config.headers)for(let[o,n]of Object.entries(this.config.headers))r[o]=xm(n);let s={requestInit:{headers:r}};this.transport=this.config.transport==="sse"?new En(e,s):new Bn(e,s)}else throw new Error(`MCP server '${this.name}': needs either 'command' (stdio) or 'url' (http/sse)`);this.client=new dn({name:"swifty",version:bm},{}),await this.client.connect(this.transport)}getInstructions(){return this.client?.getInstructions()??""}async listTools(){if(!this.client)throw new Error("Not connected");return(await this.client.listTools()).tools.map(({name:r,description:s,inputSchema:{properties:o,...n}})=>({name:r,description:s??"",inputSchema:{...n,properties:o??{}}}))}async callTool(e,r){if(!this.client)throw new Error("Not connected");let s=await this.client.callTool({name:e,arguments:r}),o;return s.content&&Array.isArray(s.content)?o=await G_(s.content):o=JSON.stringify(s),{output:o,isError:s.isError===!0}}async disconnect(){try{await this.client?.close()}catch(e){Rm.error({err:e},"mcp operation failed")}this.client=null,this.transport=null}};var H_=R({module:"mcp"}),Dm=class{clients=new Map;async connectAll(e){let r={tools:[],servers:[],errors:[],instructions:[]};for(let s of e){let o=new Qn(s);try{await o.connect(),this.clients.set(s.name,o),r.servers.push(s.name);let n=await o.listTools();for(let a of n)r.tools.push({serverName:s.name,tool:a});let i=o.getInstructions();i&&r.instructions.push({serverName:s.name,text:i})}catch(n){H_.error({err:n},"mcp operation failed"),r.errors.push({serverName:s.name,error:U(n)})}}return r}getClient(e){return this.clients.get(e)}async disconnectAll(){for(let e of this.clients.values())await e.disconnect();this.clients.clear()}};import{execSync as Om}from"child_process";import{platform as Y_,arch as J_}from"os";function Tm(){return{name:"Identity",priority:0,content:`You are Swifty, an AI programming assistant running in a terminal.
|
|
24
24
|
You assist users with software engineering tasks, including writing code, debugging, refactoring, explaining code, and executing commands.
|
|
25
25
|
|
|
26
26
|
IMPORTANT: Avoid introducing security vulnerabilities such as command injection, XSS, SQL injection, and other common exploits. Prioritize writing secure, correct code.
|
|
@@ -74,7 +74,7 @@ When encountering obstacles, never use a destructive action as a shortcut. Diagn
|
|
|
74
74
|
- Do not use emoji unless the user explicitly requests it. All communication should default to emoji-free.
|
|
75
75
|
- Keep responses concise and direct.
|
|
76
76
|
- When referencing specific code, use the file_path:line_number format for easy navigation.
|
|
77
|
-
- Do not use a colon before a tool call. For example, do not write "Let me read this file:" followed by a tool call; instead write "Let me read this file." with a period.`}}function
|
|
77
|
+
- Do not use a colon before a tool call. For example, do not write "Let me read this file:" followed by a tool call; instead write "Let me read this file." with a period.`}}function Um(){return{name:"TextOutput",priority:60,content:`# Text Output (Does Not Apply to Tool Calls)
|
|
78
78
|
|
|
79
79
|
Assume the user cannot see most tool calls or your internal reasoning \u2014 only your text output. Before the first tool call, state in one sentence what you are about to do. At key milestones during the work, provide brief updates: what you found, where you changed direction, what blocked you. Brevity is acceptable \u2014 silence is not. One sentence per update is usually sufficient.
|
|
80
80
|
|
|
@@ -84,11 +84,11 @@ End-of-turn summary: one to two sentences. What changed, what is next. No more.
|
|
|
84
84
|
|
|
85
85
|
Match the response style to the task: for simple questions, give a direct answer without headings or sections.
|
|
86
86
|
|
|
87
|
-
In code: do not write comments by default. Never write multi-paragraph docstring or multi-line comment blocks \u2014 at most one short comment line. Do not create planning, decision, or analysis documents unless the user requests them \u2014 work from the conversation context and do not produce intermediate files.`}}function
|
|
88
|
-
`)}}var
|
|
87
|
+
In code: do not write comments by default. Never write multi-paragraph docstring or multi-line comment blocks \u2014 at most one short comment line. Do not create planning, decision, or analysis documents unless the user requests them \u2014 work from the conversation context and do not produce intermediate files.`}}function Fm(t){let e=["# Environment",` - Working directory: ${t.workDir}`,` - Platform: ${t.os}/${t.arch}`,` - Shell: ${t.shell}`,` - Git repository: ${t.isGitRepo?"true":"false"}`];return t.isGitRepo&&t.gitBranch&&e.push(` - Git branch: ${t.gitBranch}`),t.model&&e.push(` - Model: ${t.model}`),e.push(` - Date: ${t.date}`),{name:"Environment",priority:70,content:e.join(`
|
|
88
|
+
`)}}var W_=R({module:"prompt"}),ll=class{sections=[];add(e){return this.sections.push(e),this}build(){return[...this.sections].sort((r,s)=>r.priority-s.priority).map(r=>r.content.trim()).filter(Boolean).join(`
|
|
89
89
|
|
|
90
|
-
`)}};function
|
|
91
|
-
`),isError:!1})}},ef=class{constructor(e){this.mgr=e}mgr;name="TeamDelete";description="Delete a team and stop its members.";category="read";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{name:{type:"string"}},required:["name"]}}}async execute(e,r){let s=
|
|
90
|
+
`)}};function Lm(t){let e={workDir:t,os:Y_(),arch:J_(),shell:process.env.SHELL??"bash",isGitRepo:!1,gitBranch:"",model:"",date:new Date().toISOString().split("T")[0]};try{Om("git rev-parse --is-inside-work-tree",{cwd:t,stdio:["pipe","pipe","pipe"],encoding:"utf-8"}).trim()==="true"&&(e.isGitRepo=!0,e.gitBranch=Om("git rev-parse --abbrev-ref HEAD",{cwd:t,stdio:["pipe","pipe","pipe"],encoding:"utf-8"}).trim())}catch(r){W_.error({err:r},"prompt operation failed")}return e}function qm(t){let e=new ll;return e.add(Tm()),e.add($m()),e.add(Pm()),e.add(jm()),e.add(Nm()),e.add(zm()),e.add(Um()),e.add(Fm(t)),e.build()}import{randomBytes as V_}from"crypto";var _n="text",Zt="shutdown_request",Sn="shutdown_response",K_="plan_approval_request",$r="plan_approval_response",Gm="[shutdown]";function Hm(){return`req-${V_(8).toString("hex")}`}function kn(t,e,r,s,o){return{from:t,text:s,timestamp:new Date().toISOString(),type:e,requestId:r,...o===void 0?{}:{approve:o}}}function Mn(t,e=""){let r=e||"team is wrapping up";return kn(t,Zt,Hm(),`${Gm} ${r}`)}function vn(t,e,r,s=""){return kn(t,Sn,e,s,r)}function Ym(t,e){return kn(t,K_,Hm(),e)}function Jm(t,e,r,s=""){return kn(t,$r,e,s,r)}function Wm(t){return t.type===Zt?!0:(t.text??"").trim().startsWith(Gm)}function ul(t){return t.approve===!0}var Al=class{names=new Map;register(e,r){this.names.set(e,r)}resolve(e){let r=this.names.get(e);if(r!==void 0)return r;for(let s of this.names.values())if(s===e)return e}unregister(e){this.names.delete(e)}clear(){this.names.clear()}},Vm;function Pr(){return Vm??=new Al,Vm}var Z_=R({module:"teams"}),Km=class{constructor(e){this.mgr=e}mgr;name="TeamCreate";description="Create a team for coordinating multiple agents.";category="read";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{team_name:{type:"string",description:"Name for the team"},description:{type:"string",description:"What this team will work on"}},required:["team_name"]}}}async execute(e,r){let s=k(r,"team_name");if(!s)return Promise.resolve({output:"Error: team_name is required",isError:!0});let o=s;for(let a=2;this.mgr.get(o);a++)o=`${s}-${String(a)}`;let n=k(r,"description"),i=this.mgr.create(o,void 0,{leadAgentId:"lead",description:n});return{output:`Team '${i.name}' created (mode: ${i.mode}). Use Agent tool with team_name='${i.name}' to add teammates.`,isError:!1}}},Zm=class{constructor(e,r){this.mgr=e;this.runAgent=r}mgr;runAgent;name="SpawnTeammate";description="Spawn a teammate in a team to work on a task in the background. Its result is delivered back to you on the team channel when it finishes.";category="read";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{team:{type:"string",description:"Team name (created if missing)"},name:{type:"string",description:"Teammate name"},task:{type:"string",description:"The task for the teammate"}},required:["team","name","task"]}}}async execute(e,r){let s=k(r,"team"),o=k(r,"name"),n=k(r,"task");return!s||!o||!n?Promise.resolve({output:"Error: team, name and task are required",isError:!0}):((this.mgr.get(s)??this.mgr.create(s)).spawnTeammate(o,n,this.runAgent),Promise.resolve({output:`Teammate '${o}' spawned in team '${s}'. Its result will arrive on the team channel; keep working and watch for it.`,isError:!1}))}},bn=class{constructor(e,r="lead"){this.mgr=e;this.senderName=r}mgr;senderName;name="SendMessage";description="Send a message to a teammate's mailbox. Use to='*' to broadcast to all teammates.";category="read";senderTeam(){let e=this.mgr.list();for(let r of e)if(r.getMember(this.senderName))return r;return e[0]}schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{to:{type:"string",description:"Teammate name, or '*' to broadcast"},content:{type:"string",description:"Message content. For shutdown_request this is the reason; for plan_approval_response this is your feedback when rejecting."},type:{type:"string",enum:[_n,Zt,Sn,$r],description:"Message kind, defaults to 'text'. Use 'shutdown_request' to ask a teammate to wrap up (it replies with shutdown_response). Use 'plan_approval_response' to answer a teammate's plan, together with 'approve' and, when rejecting, feedback in 'content'."},request_id:{type:"string",description:"Required for plan_approval_response: copy the requestId from the teammate's plan approval request so it knows which plan you are answering."},approve:{type:"boolean",description:"Required for plan_approval_response: true to let the teammate start executing, false to send it back to revise."}},required:["to","content"]}}}async execute(e,r){let s=k(r,"to"),o=k(r,"content"),n=this.senderTeam();if(!n)return{output:"No active team found for this sender.",isError:!0};let i=typeof r.type=="string"?r.type:_n;if(i!==_n){let c=typeof r.request_id=="string"?r.request_id:"",u=typeof r.approve=="boolean"?r.approve:void 0,l;switch(i){case Zt:l=Mn(this.senderName,o);break;case Sn:if(u===void 0)return{output:"shutdown_response requires 'approve'.",isError:!0};l=vn(this.senderName,c,u,o);break;case $r:if(!c||u===void 0)return{output:"plan_approval_response requires both 'request_id' and 'approve'.",isError:!0};l=Jm(this.senderName,c,u,o);break;default:return{output:`Unsupported message type ${i}.`,isError:!0}}let A=s==="lead"?n.leadMailbox:n.getMember(s)?.mailbox;return A?(await A.send(this.senderName,l.text,l),{output:`${i} sent to '${s}'.`,isError:!1}):{output:`Teammate '${s}' not found.`,isError:!0}}if(s==="*"){let c=0;for(let u of n.listMembers())u.name!==this.senderName&&(await n.sendMessage(this.senderName,u.name,o),c++);return{output:`Message broadcast to ${String(c)} teammate(s).`,isError:!1}}let a=Pr().resolve(s)??s;try{await n.sendMessage(this.senderName,a,o)}catch(c){return Z_.error({err:c},"teams operation failed"),{output:`Error: ${U(c)}`,isError:!0}}return{output:`Message sent to '${s}'.`,isError:!1}}},Xm=class{constructor(e){this.mgr=e}mgr;name="ListTeams";description="List teams and their members.";category="read";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{},required:[]}}}execute(){let e=this.mgr.list();if(e.length===0)return Promise.resolve({output:"No teams.",isError:!1});let r=e.map(s=>{let o=s.listMembers().map(n=>`${n.name}${n.active?" (active)":""}`).join(", ")||"(no members)";return`${s.name} [${s.mode}]: ${o}`});return Promise.resolve({output:r.join(`
|
|
91
|
+
`),isError:!1})}},ef=class{constructor(e){this.mgr=e}mgr;name="TeamDelete";description="Delete a team and stop its members.";category="read";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{name:{type:"string"}},required:["name"]}}}async execute(e,r){let s=k(r,"name");return await this.mgr.delete(s),{output:`Team '${s}' deleted.`,isError:!1}}};var tf=[{name:"general-purpose",description:"General-purpose agent for researching complex questions, exploring codebase, and executing multi-step tasks."},{name:"plan",description:`You are a software architect. This is a read-only planning task.
|
|
92
92
|
Prohibited actions:
|
|
93
93
|
Creating, modifying, or deleting files, Asking questions
|
|
94
94
|
Workflow:
|
|
@@ -105,17 +105,17 @@ Tool invocation strategy:
|
|
|
105
105
|
- Use ReadFile to read files at specified paths
|
|
106
106
|
- Only execute read-only Bash commands
|
|
107
107
|
- Invoke multiple tools in parallel whenever possible to maximize efficiency
|
|
108
|
-
`,disallowedTools:["EditFile","WriteFile"],permissionMode:"plan",model:"haiku"}];import{randomBytes as
|
|
108
|
+
`,disallowedTools:["EditFile","WriteFile"],permissionMode:"plan",model:"haiku"}];import{randomBytes as wS}from"crypto";var X_=new Set(["pending","in_progress","completed","blocked"]),xn=class{constructor(e,r,s=""){this.mgr=e;this.teamName=r;this.agentName=s}mgr;teamName;agentName;name="TaskCreate";description="Create a shared task in the team's task board. Supports dependency tracking with blocks/blocked_by fields.";category="command";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{title:{type:"string",description:"Short task title"},description:{type:"string",description:"Optional task details"},assignee:{type:"string",description:"Teammate name to assign this task to"},blocks:{type:"array",items:{type:"string"},description:"IDs of tasks that this task blocks"},blocked_by:{type:"array",items:{type:"string"},description:"IDs of tasks that block this task"}},required:["title"]}}}execute(e,r){let s=k(r,"title");if(!s)return Promise.resolve({output:"Error: 'title' is required",isError:!0});let o=this.mgr.getTaskStore(this.teamName);if(!o)return Promise.resolve({output:`Task store not found for team '${this.teamName}'`,isError:!0});let n=o.create(s,k(r,"description"),k(r,"assignee"),Hr(r.blocks),Hr(r.blocked_by),this.agentName);return Promise.resolve({output:`Task created:
|
|
109
109
|
ID: ${n.id}
|
|
110
110
|
Title: ${n.title}
|
|
111
111
|
Status: ${n.status}
|
|
112
|
-
Assignee: ${n.assignee||"(unassigned)"}`,isError:!1})}},Rn=class{constructor(e,r){this.mgr=e;this.teamName=r}mgr;teamName;name="TaskGet";description="Get details of a shared task by ID, including dependency information.";category="read";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{task_id:{type:"string",description:"ID of the task to fetch"}},required:["task_id"]}}}execute(e,r){let s=
|
|
113
|
-
`),isError:!1})}},
|
|
114
|
-
`),isError:!1})}},
|
|
115
|
-
`)){if(!s||s.startsWith("#")||s.startsWith("^"))continue;let o=s.indexOf(" ");if(o!==-1&&s.slice(o+1)===e){let n=s.slice(0,o);return pl.test(n)?n:""}}}catch(r){Qe.error({err:r},"worktree operation failed")}return""}async function gl(t,e){let r=await rf(t,e);if(r)return r;let s=await
|
|
112
|
+
Assignee: ${n.assignee||"(unassigned)"}`,isError:!1})}},Rn=class{constructor(e,r){this.mgr=e;this.teamName=r}mgr;teamName;name="TaskGet";description="Get details of a shared task by ID, including dependency information.";category="read";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{task_id:{type:"string",description:"ID of the task to fetch"}},required:["task_id"]}}}execute(e,r){let s=k(r,"task_id");if(!s)return Promise.resolve({output:"Error: 'task_id' is required",isError:!0});let o=this.mgr.getTaskStore(this.teamName);if(!o)return Promise.resolve({output:`Task store not found for team '${this.teamName}'`,isError:!0});let n=o.get(s);if(!n)return Promise.resolve({output:`Task '${s}' not found`,isError:!0});let i=[`Task ${n.id}:`,` Title: ${n.title}`,` Status: ${n.status}`,` Assignee: ${n.assignee||"(unassigned)"}`,` Created by: ${n.createdBy||"(unknown)"}`];return n.description&&i.push(` Description: ${n.description}`),n.blocks.length&&i.push(` Blocks: ${n.blocks.join(", ")}`),n.blockedBy.length&&i.push(` Blocked by: ${n.blockedBy.join(", ")}`),Promise.resolve({output:i.join(`
|
|
113
|
+
`),isError:!1})}},Dn=class{constructor(e,r){this.mgr=e;this.teamName=r}mgr;teamName;name="TaskList";description="List all shared tasks in the team's task board. Optionally filter by status (pending/in_progress/completed/blocked) or assignee.";category="read";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{status:{type:"string",description:"Filter by status"},assignee:{type:"string",description:"Filter by assignee name"}},required:[]}}}execute(e,r){let s=this.mgr.getTaskStore(this.teamName);if(!s)return Promise.resolve({output:`Task store not found for team '${this.teamName}'`,isError:!0});let o=k(r,"status")||void 0,n=k(r,"assignee")||void 0,i=s.listTasks(o,n);if(i.length===0){let u=[];o&&u.push(`status=${o}`),n&&u.push(`assignee=${n}`);let l=u.length?` (filters: ${u.join(", ")})`:"";return Promise.resolve({output:`No tasks found${l}`,isError:!1})}let a={pending:"\u25CB",in_progress:"\u25D0",completed:"\u25CF",blocked:"\u2715"},c=[`Tasks (${String(i.length)}):`];for(let u of i){let l=a[u.status]??"?",A=u.assignee?` [${u.assignee}]`:"",p=u.blockedBy.length?` (blocked by: ${u.blockedBy.join(", ")})`:"";c.push(` ${l} [${u.id}] ${u.title}${A}${p}`)}return Promise.resolve({output:c.join(`
|
|
114
|
+
`),isError:!1})}},Tn=class{constructor(e,r){this.mgr=e;this.teamName=r}mgr;teamName;name="TaskUpdate";description="Update a shared task's status, assignee, description, or dependencies. Use add_blocks/add_blocked_by to add dependency relations.";category="command";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{task_id:{type:"string",description:"ID of the task to update"},status:{type:"string",description:"New status: pending/in_progress/completed/blocked"},assignee:{type:"string",description:"Teammate name to assign"},description:{type:"string",description:"New description"},add_blocks:{type:"array",items:{type:"string"},description:"Task IDs to add to the blocks list"},add_blocked_by:{type:"array",items:{type:"string"},description:"Task IDs to add to the blocked_by list"}},required:["task_id"]}}}execute(e,r){let s=k(r,"task_id");if(!s)return Promise.resolve({output:"Error: 'task_id' is required",isError:!0});let o=k(r,"status");if(o&&!X_.has(o))return Promise.resolve({output:`Invalid status '${o}'. Must be one of: blocked, completed, in_progress, pending`,isError:!0});let n=this.mgr.getTaskStore(this.teamName);if(!n)return Promise.resolve({output:`Task store not found for team '${this.teamName}'`,isError:!0});let i=[],a={};o&&(a.status=o,i.push(`status \u2192 ${o}`)),typeof r.assignee=="string"&&(a.assignee=r.assignee,i.push(`assignee \u2192 ${a.assignee||"(unassigned)"}`)),typeof r.description=="string"&&(a.description=r.description,i.push("description updated"));let c=Hr(r.add_blocks);c.length&&(a.addBlocks=c,i.push(`blocks += ${c.join(", ")}`));let u=Hr(r.add_blocked_by);u.length&&(a.addBlockedBy=u,i.push(`blocked_by += ${u.join(", ")}`));let l=n.update(s,a);return l?Promise.resolve({output:`Task ${l.id} updated: ${i.length?i.join("; "):"no changes"}`,isError:!1}):Promise.resolve({output:`Task '${s}' not found`,isError:!0})}};import{exec as eS}from"child_process";import{access as tS,cp as dl,mkdir as rS,readFile as jr,stat as sf,symlink as sS}from"fs/promises";import{dirname as oS,isAbsolute as of,join as he}from"path";import{promisify as nS}from"util";var Qe=R({module:"worktree"}),ct=nS(eS),iS=/^[a-zA-Z0-9/._+@-]+$/,pl=/^[0-9a-f]{40}([0-9a-f]{24})?$/;function ml(t){if(!t||t.startsWith("-")||t.startsWith("/")||t.includes(".."))return!1;let e=t.split("/");for(let r of e)if(r==="."||r==="")return!1;return iS.test(t)}async function Nr(t){try{return await tS(t),!0}catch(e){return Qe.error({err:e},"worktree operation failed"),!1}}async function aS(t){try{let e=he(t,"commondir"),r=(await jr(e,"utf-8")).trim();return of(r)?r:he(t,r)}catch(e){return Qe.error({err:e},"worktree operation failed"),""}}async function cS(t){let e;try{e=(await jr(he(t,"HEAD"),"utf-8")).trim()}catch(r){return Qe.error({err:r},"worktree operation failed"),null}if(e.startsWith("ref:")){let r=e.slice(4).trim();if(r.startsWith("refs/heads/")){let o=r.slice(11);return ml(o)?{branch:o}:null}if(!ml(r))return null;let s=await gl(t,r);return s?{sha:s}:null}return pl.test(e)?{sha:e}:null}async function rf(t,e){try{let r=(await jr(he(t,e),"utf-8")).trim();if(r.startsWith("ref:")){let s=r.slice(4).trim();return ml(s)?await gl(t,s):""}return pl.test(r)?r:""}catch(r){Qe.error({err:r},"worktree operation failed")}try{let r=await jr(he(t,"packed-refs"),"utf-8");for(let s of r.split(`
|
|
115
|
+
`)){if(!s||s.startsWith("#")||s.startsWith("^"))continue;let o=s.indexOf(" ");if(o!==-1&&s.slice(o+1)===e){let n=s.slice(0,o);return pl.test(n)?n:""}}}catch(r){Qe.error({err:r},"worktree operation failed")}return""}async function gl(t,e){let r=await rf(t,e);if(r)return r;let s=await aS(t);return s&&s!==t?rf(s,e):""}async function fl(t){let e;try{e=(await jr(he(t,".git"),"utf-8")).trim()}catch(n){return Qe.error({err:n},"worktree operation failed"),""}if(!e.startsWith("gitdir:"))return"";let r=e.slice(7).trim(),s=of(r)?r:he(t,r),o=await cS(s);return o?o.branch?gl(s,"refs/heads/"+o.branch):o.sha??"":""}async function Ws(t,e){let r=e??(await ct("git rev-parse --show-toplevel")).stdout.trim(),s=he(r,".swifty","worktrees",t),o=`worktree-${t}`;if(await Nr(s)){let a=await fl(s);if(a)return{path:s,branch:o,headCommit:a,gitRoot:r};let{stdout:c}=await ct("git rev-parse HEAD",{cwd:s});return{path:s,branch:o,headCommit:c.trim(),gitRoot:r}}await ct(`git worktree add -B "${o}" "${s}"`,{cwd:r}),await lS(r,s);let n=await fl(s);if(n)return{path:s,branch:o,headCommit:n,gitRoot:r};let{stdout:i}=await ct("git rev-parse HEAD",{cwd:s});return{path:s,branch:o,headCommit:i.trim(),gitRoot:r}}async function nf(t,e,r){try{await ct(`git worktree remove "${t}" --force`,{cwd:r})}catch(s){Qe.error({err:s},"worktree operation failed")}try{await ct(`git branch -D "${e}"`,{cwd:r})}catch(s){Qe.error({err:s},"worktree operation failed")}}async function af(t,e){try{let{stdout:r}=await ct("git status --porcelain",{cwd:t});return r.trim()?!0:(await fl(t)||(await ct("git rev-parse HEAD",{cwd:t})).stdout.trim())!==e}catch(r){return Qe.error({err:r},"worktree operation failed"),!0}}function hl(t,e){return`You are working in a git worktree at: ${e}
|
|
116
116
|
The parent project is at: ${t}
|
|
117
|
-
Changes made here are isolated from the parent working tree.`}async function
|
|
118
|
-
`).map(n=>n.trim()).filter(n=>n&&!n.startsWith("#"));for(let n of o)if(!n.includes(".."))try{let i=he(t,n);if(!await Nr(i))continue;let a=he(e,n);await
|
|
117
|
+
Changes made here are isolated from the parent working tree.`}async function lS(t,e){await uS(t,e),await AS(t,e),await dS(t,e),await pS(t,e)}async function uS(t,e){try{let r=he(t,".swifty");if(!await Nr(r))return;let s=he(e,".swifty");await dl(r,s,{recursive:!0})}catch(r){Qe.error({err:r},"failed to copy .swifty/ to worktree")}}async function AS(t,e){try{let r=[he(t,".husky"),he(t,".git","hooks")],s;for(let o of r)try{if((await sf(o)).isDirectory()){s=o;break}}catch(n){Qe.error({err:n},"worktree operation failed")}if(!s)return;await ct(`git config core.hooksPath "${s}"`,{cwd:e})}catch(r){Qe.error({err:r},"failed to configure hooks path in worktree")}}async function dS(t,e){try{let r=he(t,"node_modules");if(!await Nr(r))return;let s=he(e,"node_modules");if(await Nr(s))return;await sS(r,s)}catch(r){Qe.warn({err:r},"failed to symlink node_modules in worktree")}}async function pS(t,e){try{let r=he(t,".worktreeinclude");if(!await Nr(r))return;let o=(await jr(r,"utf-8")).split(`
|
|
118
|
+
`).map(n=>n.trim()).filter(n=>n&&!n.startsWith("#"));for(let n of o)if(!n.includes(".."))try{let i=he(t,n);if(!await Nr(i))continue;let a=he(e,n);await rS(oS(a),{recursive:!0}),(await sf(i)).isDirectory()?await dl(i,a,{recursive:!0}):await dl(i,a)}catch(i){Qe.error({err:i},"worktree operation failed")}}catch(r){Qe.error({err:r},"failed to process .worktreeinclude")}}import{readdirSync as mS,readFileSync as fS,existsSync as gS}from"fs";import{homedir as hS}from"os";import{join as El}from"path";var lf=R({module:"subagent"});function uf(t){let e=[...tf],r=hS();r&&cf(El(r,".swifty","agents"),e);let s=[El(t,".swifty","agents")];for(let o of s)cf(o,e);return e}function cf(t,e){if(!gS(t))return;let r=mS(t).filter(s=>s.endsWith(".md"));for(let s of r)try{let o=fS(El(t,s),"utf-8"),n=yS(o);if(n){let i=e.findIndex(a=>a.name===n.name);i>=0?e[i]=n:e.push(n)}}catch(o){lf.error({err:o},"subagent operation failed");continue}}var ES=y.looseObject({name:y.string(),description:y.string().optional(),tools:y.array(y.string()).optional(),disallowed_tools:y.array(y.string()).optional(),system_prompt:y.string().optional(),max_turns:y.number().optional(),model:y.string().optional(),background:y.boolean().optional(),isolation:y.literal("worktree").optional()});function yS(t){if(!t.startsWith("---"))return null;let e=t.indexOf("---",3);if(e===-1)return null;let r=t.slice(3,e).trim(),s=t.slice(e+3).trim();try{let o=ft.load(r),n=Se(ES,o);return{name:n.name,description:n.description??s.slice(0,200),tools:n.tools,disallowedTools:n.disallowed_tools,systemPromptOverride:n.system_prompt,maxTurns:n.max_turns,model:n.model,background:n.background,isolation:n.isolation,initialPrompt:s}}catch(o){return lf.error({err:o},"subagent operation failed"),null}}var CS=R({module:"subagent"}),IS="general-purpose";function Af(){return`agent-a${wS(4).toString("hex").slice(0,7)}`}var pf="<fork_boilerplate>",BS="agent:builtin:fork",QS=`${pf}
|
|
119
119
|
You are a forked worker process. You are NOT the main agent.
|
|
120
120
|
Rules (non-negotiable):
|
|
121
121
|
1. Do NOT fork again.
|
|
@@ -123,7 +123,7 @@ Rules (non-negotiable):
|
|
|
123
123
|
3. Use tools directly: read files, search code, make changes.
|
|
124
124
|
4. Stay strictly within your assigned task scope.
|
|
125
125
|
5. Final report must be under 500 characters, starting with "Scope:".
|
|
126
|
-
</fork_boilerplate>`,
|
|
126
|
+
</fork_boilerplate>`,df=class{name="Agent";description="Launch a subagent to handle complex, multi-step tasks.";category="read";definitions;registry;conversation;querySource="";teamManager;workDir;forkDisabled=!1;teamRunAgentFactory;spawnHandler;forkHandler;constructor(e,r,s,o,n){this.definitions=uf(e),this.workDir=e,this.registry=r,this.spawnHandler=s,this.conversation=o,this.forkHandler=n}setTeamManager(e,r){this.teamManager=e,this.teamRunAgentFactory=r}schema(){let e=this.definitions.map(r=>r.name);return{name:this.name,description:this.buildDescription(),input_schema:{type:"object",properties:{description:{type:"string",description:"Short description of what the agent will do"},prompt:{type:"string",description:"The task for the agent to perform"},subagent_type:{type:"string",enum:e,description:"Agent type. Omit to fork current conversation context."},model:{type:"string",description:"Override the model for this agent."},run_in_background:{type:"boolean",description:"Run in background",default:!1},isolation:{type:"string",enum:["worktree"],description:"Set to 'worktree' to run the agent in its own Git worktree, so its edits cannot collide with the parent or with other agents working in parallel."},plan_mode_required:{type:"boolean",description:"Only meaningful together with team_name. When true, the teammate starts in plan mode: it can read and investigate but cannot modify anything until it submits a plan and you approve it via SendMessage with type='plan_approval_response'. Use it for risky or ambiguous tasks where a wrong direction would cost a lot of rework."},team_name:{type:"string",description:"REQUIRED when creating team members. Spawns the agent as a long-running teammate under this team (created via TeamCreate). Unlike regular subagents, team members persist after the lead returns and communicate via SendMessage. Without team_name the agent runs as a one-shot subagent that blocks and returns inline."}},required:["description","prompt"]}}}buildDescription(){let e=`Launch a subagent to handle a complex task. Each subagent runs independently with its own context. The subagent cannot see the current conversation.
|
|
127
127
|
|
|
128
128
|
This is ONE tool with multiple roles. Roles are NOT separate tools \u2014 you pick one by passing its name in the "subagent_type" parameter. Do not search for a tool named after a role; call THIS tool ("Agent") and set "subagent_type".
|
|
129
129
|
|
|
@@ -141,23 +141,23 @@ Example call shape:
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
Write a detailed prompt explaining what the subagent should do and why \u2014 it has no prior context.
|
|
144
|
-
When tasks are independent, launch multiple subagents in parallel by making multiple Agent tool calls in a single response.`,e}async execute(e,r){let s=
|
|
144
|
+
When tasks are independent, launch multiple subagents in parallel by making multiple Agent tool calls in a single response.`,e}async execute(e,r){let s=k(r,"description"),o=k(r,"prompt");if(!s||!o)return{output:"Error: description and prompt are required",isError:!0};let n=k(r,"subagent_type")||(this.forkDisabled?IS:""),i=k(r,"model"),a=Ao(r,"run_in_background"),c=k(r,"team_name"),u=k(r,"isolation");if(c&&this.teamManager&&this.teamRunAgentFactory)return await this.runAsTeammate(c,s,o,r.plan_mode_required===!0,u==="worktree");if(!n)return this.runFork(o,s,i);let l=this.definitions.find(m=>m.name===n);if(!l)return{output:`Error: unknown agent type '${n}'. Available: ${this.definitions.map(m=>m.name).join(", ")}`,isError:!0};let A=o,p;if(u==="worktree"||l.isolation==="worktree")try{let m=await Ws(Af());p=m.path,A=`${hl(this.workDir,m.path)}
|
|
145
145
|
|
|
146
|
-
${o}`}catch(m){return{output:`Error creating agent worktree: ${
|
|
146
|
+
${o}`}catch(m){return{output:`Error creating agent worktree: ${U(m)}`,isError:!0}}try{return{output:await this.spawnHandler(l,A,a||!!l.background,i,p),isError:!1}}catch(m){return{output:`Agent error: ${U(m)}`,isError:!0}}}async runAsTeammate(e,r,s,o,n){if(!this.teamManager)return{output:`Error: team manager '${e}' not found.`,isError:!0};let i=this.teamManager.get(e)??this.teamManager.create(e,void 0,{leadAgentId:"lead",description:r}),a=r.replace(/\s+/g,"-").toLowerCase().slice(0,30),c=2,u=a;for(;i.getMember(a);)a=`${u}-${String(c++)}`;let l=new mo;for(let g of this.registry.listTools())Hl.has(g.name)||Yl.has(g.name)||l.register(g);l.register(new bn(this.teamManager,a)),l.register(new xn(this.teamManager,e,a)),l.register(new Rn(this.teamManager,e)),l.register(new Dn(this.teamManager,e)),l.register(new Tn(this.teamManager,e));let A=o?new rr(this.workDir,"plan"):void 0,p=s;if(n)try{let g=await Ws(Af());i.setMemberMeta(a,{worktreePath:g.path}),p=`${hl(this.workDir,g.path)}
|
|
147
147
|
|
|
148
|
-
${s}`}catch(g){return{output:`Error creating teammate worktree: ${
|
|
149
|
-
The teammate is now working on the assigned task.`,isError:!1}}async runFork(e,r,s){if(!this.conversation||!this.forkHandler)return{output:"Error: fork requires parent conversation context",isError:!0};if(this.querySource===
|
|
148
|
+
${s}`}catch(g){return{output:`Error creating teammate worktree: ${U(g)}`,isError:!0}}let m=this.teamRunAgentFactory?.(l,A);return m&&i.spawnTeammate(a,p,m,A),{output:`Teammate '${a}' spawned in team '${e}' (mode: ${i.mode})${o?", starting in plan mode":""}.
|
|
149
|
+
The teammate is now working on the assigned task.`,isError:!1}}async runFork(e,r,s){if(!this.conversation||!this.forkHandler)return{output:"Error: fork requires parent conversation context",isError:!0};if(this.querySource===BS)return{output:"Error: cannot fork from a forked agent. Use subagent_type to spawn a definition-based agent instead.",isError:!0};for(let o of this.conversation.getMessages())if(typeof o.content=="string"&&o.content.includes(pf))return{output:"Error: cannot fork from a forked agent. Use subagent_type to spawn a definition-based agent instead.",isError:!0};try{let{cloneRegistryForFork:o}=await import("./tool-filter-334HOWZK.js"),n=o(this.registry);return await this.forkHandler(`${QS}
|
|
150
150
|
|
|
151
151
|
Your task:
|
|
152
|
-
${e}`,this.conversation,n,s),{output:`Forked agent "${r}" launched in background. Results will arrive via task-notification.`,isError:!1}}catch(o){return
|
|
152
|
+
${e}`,this.conversation,n,s),{output:`Forked agent "${r}" launched in background. Results will arrive via task-notification.`,isError:!1}}catch(o){return CS.error({err:o},"subagent operation failed"),{output:`Fork error: ${U(o)}`,isError:!0}}}};var _S={haiku:"claude-haiku-4-5-20251001",sonnet:"claude-sonnet-4-6-20250514",opus:"claude-opus-4-6-20250514"};function mf(t){return _S[t]??t}async function F$(t,e,r,s,o,n,i,a,c,u){let l=c??t.model,A=l?mf(l):o.model,p=Lm(n);p.model=A;let m=t.systemPromptOverride??qm(p),g=l?await ii({...o,model:A},m):r,f=Jl(s,t.tools,t.disallowedTools,!1),h=t.permissionMode??"acceptEdits",w=u??new rr(n,h),C=new tr;C.addUserMessage(e);let I=new po({client:g,registry:f,checker:w,conversation:C,workDir:n,maxIterations:t.maxTurns??200}),b="",E=0;for await(let B of I.run())switch(B.type){case"stream_text":b+=B.text;break;case"tool_use":i?.({lastTool:B.toolName}),a?.({type:"tool_use",toolName:B.toolName,args:B.args});break;case"usage":a?.({type:"usage",usage:{inputTokens:B.usage.inputTokens,outputTokens:B.usage.outputTokens}});break;case"turn_complete":i?.({turn:++E});break;case"loop_complete":return b||"[No output]";case"error":return b?`${b}
|
|
153
153
|
|
|
154
|
-
[Error: ${I.error.message}]`:`Error: ${I.error.message}`}return R||"[No output]"}var Sk=new Set(["Agent","SendMessage","TaskStop","SyntheticOutput","TeamDelete"]);function vk(t){return Sk.has(t)}function O$(t=!1){return t?vk:()=>!0}function L$(t=!1){return t}var ff=class{constructor(e){this.teamManager=e}teamManager;name="TaskStop";description="Stop a running teammate. Pass the teammate name as it appears in the from= field of a team-notification. Use this when you sent a teammate in the wrong direction \u2014 for example when the user changes requirements after you launched it.";category="command";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{teammate:{type:"string",description:"Name of the teammate to stop, exactly as it appears in the from= field of a team-notification"}},required:["teammate"]}}}async execute(e,r){let s=S(r,"teammate","");if(!s)return{output:"Error: teammate is required",isError:!0};for(let o of this.teamManager.list()){let n=o.members.get(s);if(n)return n.active?(await o.stopMember(s),{output:`Teammate '${s}' in team '${o.name}' stopped.`,isError:!1}):{output:`Teammate '${s}' in team '${o.name}' is not running, nothing to stop`,isError:!1}}return{output:`Error: teammate '${s}' not found. Known teammates: ${this.knownMembers()}`,isError:!0}}knownMembers(){let e=[];for(let r of this.teamManager.list())for(let s of r.members.keys())e.push(s);return e.length>0?e.join(", "):"(none)"}};import{mkdirSync as yS,readFileSync as ES,rmSync as wS}from"fs";import{join as Bl}from"path";var gf=["Accomplishing","Architecting","Baking","Barking","Woofing","Howling","Be-bopping'","Befuddling","Boogieing","Boondoggling","Bootstrapping","Brewing","Calculating","Canoodling","Caramelizing","Cascading","Cerebrating","Choreographing","Churning","Coalescing","Cogitating","Combobulating","Composing","Computing","Concocting","Considering","Contemplating","Cooking","Crafting","Creating","Crunching","Crystallizing","Cultivating","Deciphering","Deliberating","Dilly-dallying","Discombobulating","Doodling","Elucidating","Enchanting","Envisioning","Fermenting","Finagling","Flamb\xE9ing","Flummoxing","Forging","Frolicking","Gallivanting","Garnishing","Generating","Germinating","Grooving","Harmonizing","Hatching","Honking","Ideating","Imagining","Improvising","Incubating","Inferring","Infusing","Kneading","Lollygagging","Manifesting","Marinating","Meandering","Metamorphosing","Mewing","Moonwalking","Moseying","Mulling","Musing","Noodling","Orbiting","Orchestrating","Percolating","Philosophizing","Pondering","Pontificating","Pouncing","Purring","Puzzling","Razzle-dazzling","Ruminating","Scampering","Simmering","Sketching","Spelunking","Spinning","Sprouting","Synthesizing","Thinking","Tinkering","Transfiguring","Transmuting","Undulating","Unfurling","Unravelling","Vibing","Wandering","Whisking","Working","Wrangling","Zigzagging"];function El(){return gf[Math.floor(Math.random()*gf.length)]}var hf=["Accomplished","Baked","Brewed","Cooked","Crafted","Crunched","Forged","Hatched","Pondered","Synthesized","Tinkered","Worked","Wrangled","Computed","Created","Composed","Conjured","Concocted","Cultivated","Deciphered"];function J$(){return hf[Math.floor(Math.random()*hf.length)]}import{execSync as $n,spawn as Mk}from"child_process";var yf=x({module:"teams"});function wf(){return process.platform==="win32"?"in-process":bk()}function bk(){return process.env.TMUX?"tmux":process.env.ITERM_SESSION_ID?"iterm":"in-process"}function Cf(t){return/^[A-Za-z0-9_/.:=-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function Ef(t){return[t.command,...t.args].map(Cf).join(" ")}function If(t){switch(t.mode){case"in-process":{let e=Mk(t.command,t.args,{cwd:t.cwd,stdio:["pipe","pipe","pipe"],env:{...process.env,...t.env}});return{cancel:()=>e.kill("SIGTERM")}}case"tmux":{let e=`swifty-${Date.now().toString(36)}`,r=Ef(t);try{$n(`tmux new-window -t "${e}" -n teammate "${r}"`,{cwd:t.cwd,encoding:"utf-8",stdio:["pipe","pipe","pipe"]})}catch(s){yf.error({err:s},"teams operation failed"),$n(`tmux new-session -d -s "${e}" -n teammate "${r}"`,{cwd:t.cwd,encoding:"utf-8",stdio:["pipe","pipe","pipe"]})}return{cancel:()=>{try{$n(`tmux kill-session -t "${e}"`,{stdio:["pipe","pipe","pipe"]})}catch(s){yf.error({err:s},"teams operation failed")}},paneId:e}}case"iterm":{let e=Ef(t),n=['tell application "iTerm2"'," tell current window"," create tab with default profile",` tell current session to write text "${`cd ${Cf(t.cwd)} && ${e}`.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`," end tell","end tell"].map(i=>`-e '${i.replace(/'/g,"'\\''")}'`).join(" ");return $n(`osascript ${n}`,{cwd:t.cwd,encoding:"utf-8",stdio:["pipe","pipe","pipe"]}),{cancel:()=>{}}}default:throw new Error(`Unknown team mode: ${String(t.mode)}`)}}import{readFileSync as xk,writeFileSync as Rk,mkdirSync as Tk,existsSync as Dk,unlinkSync as Qf,statSync as $k,openSync as Pk,closeSync as jk}from"fs";import{join as Nk}from"path";var Vs=x({module:"teams"}),zk=E.object({from:E.string(),text:E.string(),timestamp:E.string(),read:E.boolean().optional(),type:E.string().optional(),requestId:E.string().optional(),approve:E.boolean().optional()}),Bf=5e3,Fk=1e4,Uk=5,qk=80,Ok=E.looseObject({errno:E.number().optional(),code:E.string().optional(),path:E.string().optional(),syscall:E.string().optional()});function Lk(t){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)}function Gk(t){let e=Date.now()+Bf,r=Uk;for(;;)try{let s=Pk(t,"wx");jk(s);return}catch(s){Vs.error({err:s},"teams operation failed");let{data:o,success:n}=Dl(Ok,s),i="";if(n&&o.code&&(i=o.code),i!=="EEXIST")throw s;try{let a=$k(t);if(Date.now()-a.mtimeMs>Fk)try{Qf(t);continue}catch(c){Vs.error({err:c},"teams operation failed")}}catch(a){Vs.error({err:a},"teams operation failed")}if(Date.now()>=e)throw new Error(`mailbox lock ${t}: timed out after ${String(Bf)}ms, message not written`);Lk(r+Math.floor(Math.random()*r)),r=Math.min(r*2,qk)}}function Hk(t){try{Qf(t)}catch(e){Vs.error({err:e},"teams operation failed")}}function wl(t,e){let r=t+".lock";Gk(r);try{return e()}finally{Hk(r)}}var Ks=class{filePath;constructor(e,r){Tk(e,{recursive:!0}),this.filePath=Nk(e,`${r}.json`)}readAll(){if(!Dk(this.filePath))return[];try{let e=JSON.parse(xk(this.filePath,"utf-8")),r=[];if(Array.isArray(e))for(let s of e){let o=zk.safeParse(s);o.success&&r.push(o.data)}return r}catch(e){return Vs.error({err:e},"teams operation failed"),[]}}writeAll(e){Rk(this.filePath,JSON.stringify(e,null,2),"utf-8")}async send(e,r,s){let o=s??{from:e,text:r,timestamp:new Date().toISOString()};return o.read=!1,wl(this.filePath,()=>{let n=this.readAll();n.push(o),this.writeAll(n)}),Promise.resolve()}receiveSync(){return wl(this.filePath,()=>{let e=this.readAll(),r=e.filter(s=>!s.read);if(r.length>0){for(let s of e)s.read=!0;this.writeAll(e)}return r})}async receive(){return Promise.resolve(this.receiveSync())}unreadCount(){return this.readAll().filter(e=>!e.read).length}markAllRead(){wl(this.filePath,()=>{let e=this.readAll(),r=!1;for(let s of e)s.read||(s.read=!0,r=!0);r&&this.writeAll(e)})}async*poll(e=1e3){for(;;){let r=await this.receive();for(let s of r)yield s;await new Promise(s=>setTimeout(s,e))}}};var _f=T.object({toolName:T.string(),input:T.record(T.string(),T.unknown()),activityDescription:T.string()}),Yk=T.object({toolUseCount:T.number(),tokenCount:T.number(),lastActivity:_f.optional(),recentActivities:T.array(_f)}),iP=T.object({name:T.string(),teamName:T.string(),status:T.enum(["running","idle","completed","failed","stopped"]),progress:Yk,startTime:T.number(),spinnerVerb:T.string(),lastMessage:T.string().optional()});function Cl(){return{toolUseCount:0,tokenCount:0,lastActivity:void 0,recentActivities:[]}}function kf(t,e,r){t.toolUseCount++;let s=Jk(e,r),o={toolName:e,input:r,activityDescription:s};t.lastActivity=o,t.recentActivities.push(o),t.recentActivities.length>5&&t.recentActivities.shift()}function Sf(t,e,r){t.tokenCount=e+r}function Jk(t,e){switch(t){case"ReadFile":return`Reading ${S(e,"file_path","file")}`;case"EditFile":return`Editing ${S(e,"file_path","file")}`;case"WriteFile":return`Writing ${S(e,"file_path","file")}`;case"Bash":{let r=S(e,"command","");return`Running ${r.length>40?r.slice(0,40)+"...":r}`}case"Glob":return`Searching ${S(e,"pattern","files")}`;case"Grep":return`Grepping ${S(e,"pattern","pattern")}`;default:return t}}function aP(t){return t.length?t[t.length-1].activityDescription:""}function cP(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"k":String(t)}import{readFileSync as Wk,writeFileSync as Vk,mkdirSync as Kk,existsSync as Zk}from"fs";import{dirname as Xk}from"path";var eS=E.object({id:E.string(),title:E.string(),description:E.string().default(""),status:E.string().default("pending"),assignee:E.string().default(""),blocks:E.array(E.string()).default([]),blocked_by:E.array(E.string()).default([]),created_by:E.string().default("")}),tS=E.object({next_id:E.number().int().positive().default(1),tasks:E.array(eS).default([])}),Zs=class{path;nextId=1;tasks=[];constructor(e){this.path=e,this.load()}load(){if(Zk(this.path))try{let e=JSON.parse(Wk(this.path,"utf-8")),r=ke(tS,e);this.nextId=r.next_id,this.tasks=r.tasks.map(s=>({id:s.id,title:s.title,description:s.description,status:s.status,assignee:s.assignee,blocks:s.blocks,blockedBy:s.blocked_by,createdBy:s.created_by}))}catch{}}save(){Kk(Xk(this.path),{recursive:!0});let e={next_id:this.nextId,tasks:this.tasks.map(r=>({id:r.id,title:r.title,description:r.description,status:r.status,assignee:r.assignee,blocks:r.blocks,blocked_by:r.blockedBy,created_by:r.createdBy}))};Vk(this.path,JSON.stringify(e,null,2),"utf-8")}create(e,r="",s="",o=[],n=[],i=""){let a={id:String(this.nextId++),title:e,description:r,status:"pending",assignee:s,blocks:[...o],blockedBy:[...n],createdBy:i};return this.tasks.push(a),this.save(),a}get(e){return this.load(),this.tasks.find(r=>r.id===e)}listTasks(e,r){return this.load(),this.tasks.filter(s=>!(e&&s.status!==e||r&&s.assignee!==r))}update(e,r){this.load();let s=this.tasks.find(o=>o.id===e);if(s){r.status!==void 0&&(s.status=r.status),r.assignee!==void 0&&(s.assignee=r.assignee),r.description!==void 0&&(s.description=r.description);for(let o of r.addBlocks??[])s.blocks.includes(o)||s.blocks.push(o);for(let o of r.addBlockedBy??[])s.blockedBy.includes(o)||s.blockedBy.push(o);return this.save(),s}}initEmpty(){this.tasks=[],this.nextId=1,this.save()}};import{existsSync as rS,mkdirSync as sS,readFileSync as oS,writeFileSync as nS}from"fs";import{homedir as iS}from"os";import{dirname as aS,join as Il}from"path";var cS=E.object({agentId:E.string(),name:E.string(),agentType:E.string().optional(),model:E.string().optional(),joinedAt:E.number(),worktreePath:E.string().optional(),backendType:E.string().optional(),isActive:E.boolean().optional()}),lS=E.object({name:E.string(),description:E.string().optional(),createdAt:E.number(),leadAgentId:E.string(),members:E.array(cS)});function uS(){return Il(iS(),".swifty","teams")}function dS(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function Xs(t){return Il(uS(),dS(t))}function vf(t){return Il(Xs(t),"config.json")}function Mf(t){let e=vf(t);if(!rS(e))return null;try{let r=JSON.parse(oS(e,"utf-8"));return lS.parse(r)}catch{return null}}function bf(t,e){try{let r=vf(t);sS(aS(r),{recursive:!0}),nS(r,JSON.stringify(e,null,2),"utf-8")}catch{}}import{mkdirSync as AS,readFileSync as wP,writeFileSync as pS,existsSync as CP}from"fs";import{join as xf}from"path";var kP=x({module:"teams"}),mS=E.object({tool_use_id:E.string(),tool_name:E.string(),arguments:E.record(E.string(),E.unknown())}),fS=E.object({tool_use_id:E.string(),content:E.string(),is_error:E.boolean().optional()}),SP=E.object({role:E.string(),content:E.string().optional(),tool_uses:E.array(mS).optional(),tool_results:E.array(fS).optional()});function gS(t){let e=[];for(let r of t.getMessages()){let s={role:r.role,content:oi(r.content)};r.toolUses&&r.toolUses.length>0&&(s.tool_uses=r.toolUses.map(o=>({tool_use_id:o.toolUseId,tool_name:o.toolName,arguments:o.arguments}))),r.toolResults&&r.toolResults.length>0&&(s.tool_results=r.toolResults.map(o=>({tool_use_id:o.toolUseId,content:oi(o.content),is_error:o.isError||void 0}))),e.push(s)}return e}function hS(t,e){return xf(t,".swifty","teams",e,"transcripts")}function Rf(t,e,r,s){let o=hS(t,e);AS(o,{recursive:!0});let n=xf(o,`${r}.json`),i=gS(s);return pS(n,JSON.stringify(i,null,2),"utf-8"),n}var Tf=x({module:"teams"}),Pn=class t{name;mode;members=new Map;leadMailbox;mailboxDir;workDir;leadAgentId="";description;createdAt=Math.floor(Date.now()/1e3);constructor(e,r,s){this.name=e,this.mode=r,this.workDir=s,this.mailboxDir=Bl(Xs(e),"inboxes"),yS(this.mailboxDir,{recursive:!0}),this.leadMailbox=new Ks(this.mailboxDir,"lead")}addMember(e){let r=new Ks(this.mailboxDir,e),s={name:e,active:!1,mailbox:r,agentId:e,joinedAt:Math.floor(Date.now()/1e3)};return this.members.set(e,s),this.persist(),s}setMemberMeta(e,r){let s=this.members.get(e);s&&(s.agentType=r.agentType,s.model=r.model,s.worktreePath=r.worktreePath,this.persist())}snapshot(){return{name:this.name,description:this.description,createdAt:this.createdAt,leadAgentId:this.leadAgentId,members:[...this.members.values()].map(e=>({agentId:e.agentId??e.name,name:e.name,agentType:e.agentType,model:e.model,joinedAt:e.joinedAt??0,worktreePath:e.worktreePath,backendType:this.mode,isActive:e.active}))}}persist(){bf(this.name,this.snapshot())}static IDLE_POLL_INTERVAL_MS=500;static SHUTDOWN_PREFIX="[shutdown]";spawnTeammate(e,r,s,o){if(this.mode==="in-process"){this.spawnInProcess(e,r,s,o);return}try{this.spawnExternal(e,r)}catch{this.spawnInProcess(e,r,s,o)}}spawnExternal(e,r){let s=this.addMember(e);s.active=!0,Pr().register(e,e),s.uiState={name:e,teamName:this.name,status:"running",progress:Cl(),startTime:Date.now(),spinnerVerb:El()};let o=process.argv[1]??"src/main.tsx",n={mode:this.mode,command:"bun",args:["run",o,"--teammate","--team-dir",this.mailboxDir,"--team-name",this.name,"--member-name",e,"--task",r],cwd:this.workDir},{cancel:i,paneId:a}=If(n);s.cancel=i,s.paneId=a,s.external=!0}spawnInProcess(e,r,s,o){let n=this.addMember(e);n.active=!0,n.checker=o,Pr().register(e,e);let i={name:e,teamName:this.name,status:"running",progress:Cl(),startTime:Date.now(),spinnerVerb:El()};n.uiState=i;let a=c=>{switch(c.type){case"tool_use":c.toolName&&c.args&&kf(i.progress,c.toolName,c.args);break;case"usage":c.usage&&Sf(i.progress,c.usage.inputTokens,c.usage.outputTokens);break;case"stream_text":c.text&&(i.lastMessage=c.text);break}};(async()=>{let c=r,u="available";try{for(;n.active;){i.status="running";let l=await s(c,a);if(i.lastMessage=l.length>200?l.slice(0,200)+"...":l,n.checker?.mode==="plan"){i.status="idle";let A=await this.runPlanApproval(n,this.readPlanForReview());if(A===null)break;c=A;continue}i.status="idle",await this.leadMailbox.send(e,`[idle] ${e} (reason: ${u})`),u="available";let d=await this.waitForNextPromptOrShutdown(n);if(d.shutdown||!n.active){let A=d.shutdown;if(A?.type===Zt){let m=Mn(n.name,A.requestId??"",!0,"acknowledged, shutting down");await this.leadMailbox.send(n.name,m.text,m)}break}c=d.prompt}i.status="completed"}catch(l){Tf.error({err:l},"teams operation failed"),i.status="failed",i.lastMessage=F(l),await this.leadMailbox.send(e,`[idle] ${e} (reason: failed)`)}finally{if(n.active=!1,i.status==="running"&&(i.status="idle"),n.conversation)try{Rf(this.workDir,this.name,e,n.conversation)}catch(l){Tf.error({err:l},"teams operation failed")}}})()}async waitForNextPromptOrShutdown(e){for(;e.active;){await new Promise(n=>setTimeout(n,t.IDLE_POLL_INTERVAL_MS));let r=e.mailbox.receiveSync();if(r.length===0)continue;let s=r.find(n=>Wm(n));return s?{prompt:"",shutdown:s}:{prompt:`You have new messages from your team:
|
|
154
|
+
[Error: ${B.error.message}]`:`Error: ${B.error.message}`}return b||"[No output]"}var SS=new Set(["Agent","SendMessage","TaskStop","SyntheticOutput","TeamDelete"]);function kS(t){return SS.has(t)}function L$(t=!1){return t?kS:()=>!0}function q$(t=!1){return t}var ff=class{constructor(e){this.teamManager=e}teamManager;name="TaskStop";description="Stop a running teammate. Pass the teammate name as it appears in the from= field of a team-notification. Use this when you sent a teammate in the wrong direction \u2014 for example when the user changes requirements after you launched it.";category="command";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{teammate:{type:"string",description:"Name of the teammate to stop, exactly as it appears in the from= field of a team-notification"}},required:["teammate"]}}}async execute(e,r){let s=k(r,"teammate","");if(!s)return{output:"Error: teammate is required",isError:!0};for(let o of this.teamManager.list()){let n=o.members.get(s);if(n)return n.active?(await o.stopMember(s),{output:`Teammate '${s}' in team '${o.name}' stopped.`,isError:!1}):{output:`Teammate '${s}' in team '${o.name}' is not running, nothing to stop`,isError:!1}}return{output:`Error: teammate '${s}' not found. Known teammates: ${this.knownMembers()}`,isError:!0}}knownMembers(){let e=[];for(let r of this.teamManager.list())for(let s of r.members.keys())e.push(s);return e.length>0?e.join(", "):"(none)"}};import{mkdirSync as hk,readFileSync as Ek,rmSync as yk}from"fs";import{join as Bl}from"path";var gf=["Accomplishing","Architecting","Baking","Barking","Woofing","Howling","Be-bopping'","Befuddling","Boogieing","Boondoggling","Bootstrapping","Brewing","Calculating","Canoodling","Caramelizing","Cascading","Cerebrating","Choreographing","Churning","Coalescing","Cogitating","Combobulating","Composing","Computing","Concocting","Considering","Contemplating","Cooking","Crafting","Creating","Crunching","Crystallizing","Cultivating","Deciphering","Deliberating","Dilly-dallying","Discombobulating","Doodling","Elucidating","Enchanting","Envisioning","Fermenting","Finagling","Flamb\xE9ing","Flummoxing","Forging","Frolicking","Gallivanting","Garnishing","Generating","Germinating","Grooving","Harmonizing","Hatching","Honking","Ideating","Imagining","Improvising","Incubating","Inferring","Infusing","Kneading","Lollygagging","Manifesting","Marinating","Meandering","Metamorphosing","Mewing","Moonwalking","Moseying","Mulling","Musing","Noodling","Orbiting","Orchestrating","Percolating","Philosophizing","Pondering","Pontificating","Pouncing","Purring","Puzzling","Razzle-dazzling","Ruminating","Scampering","Simmering","Sketching","Spelunking","Spinning","Sprouting","Synthesizing","Thinking","Tinkering","Transfiguring","Transmuting","Undulating","Unfurling","Unravelling","Vibing","Wandering","Whisking","Working","Wrangling","Zigzagging"];function yl(){return gf[Math.floor(Math.random()*gf.length)]}var hf=["Accomplished","Baked","Brewed","Cooked","Crafted","Crunched","Forged","Hatched","Pondered","Synthesized","Tinkered","Worked","Wrangled","Computed","Created","Composed","Conjured","Concocted","Cultivated","Deciphered"];function J$(){return hf[Math.floor(Math.random()*hf.length)]}import{execSync as $n,spawn as MS}from"child_process";var Ef=R({module:"teams"});function wf(){return process.platform==="win32"?"in-process":vS()}function vS(){return process.env.TMUX?"tmux":process.env.ITERM_SESSION_ID?"iterm":"in-process"}function Cf(t){return/^[A-Za-z0-9_/.:=-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function yf(t){return[t.command,...t.args].map(Cf).join(" ")}function If(t){switch(t.mode){case"in-process":{let e=MS(t.command,t.args,{cwd:t.cwd,stdio:["pipe","pipe","pipe"],env:{...process.env,...t.env}});return{cancel:()=>e.kill("SIGTERM")}}case"tmux":{let e=`swifty-${Date.now().toString(36)}`,r=yf(t);try{$n(`tmux new-window -t "${e}" -n teammate "${r}"`,{cwd:t.cwd,encoding:"utf-8",stdio:["pipe","pipe","pipe"]})}catch(s){Ef.error({err:s},"teams operation failed"),$n(`tmux new-session -d -s "${e}" -n teammate "${r}"`,{cwd:t.cwd,encoding:"utf-8",stdio:["pipe","pipe","pipe"]})}return{cancel:()=>{try{$n(`tmux kill-session -t "${e}"`,{stdio:["pipe","pipe","pipe"]})}catch(s){Ef.error({err:s},"teams operation failed")}},paneId:e}}case"iterm":{let e=yf(t),n=['tell application "iTerm2"'," tell current window"," create tab with default profile",` tell current session to write text "${`cd ${Cf(t.cwd)} && ${e}`.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`," end tell","end tell"].map(i=>`-e '${i.replace(/'/g,"'\\''")}'`).join(" ");return $n(`osascript ${n}`,{cwd:t.cwd,encoding:"utf-8",stdio:["pipe","pipe","pipe"]}),{cancel:()=>{}}}default:throw new Error(`Unknown team mode: ${String(t.mode)}`)}}import{readFileSync as bS,writeFileSync as xS,mkdirSync as RS,existsSync as DS,unlinkSync as Qf,statSync as TS,openSync as $S,closeSync as PS}from"fs";import{join as jS}from"path";var Vs=R({module:"teams"}),NS=y.object({from:y.string(),text:y.string(),timestamp:y.string(),read:y.boolean().optional(),type:y.string().optional(),requestId:y.string().optional(),approve:y.boolean().optional()}),Bf=5e3,zS=1e4,US=5,FS=80,OS=y.looseObject({errno:y.number().optional(),code:y.string().optional(),path:y.string().optional(),syscall:y.string().optional()});function LS(t){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)}function qS(t){let e=Date.now()+Bf,r=US;for(;;)try{let s=$S(t,"wx");PS(s);return}catch(s){Vs.error({err:s},"teams operation failed");let{data:o,success:n}=Tl(OS,s),i="";if(n&&o.code&&(i=o.code),i!=="EEXIST")throw s;try{let a=TS(t);if(Date.now()-a.mtimeMs>zS)try{Qf(t);continue}catch(c){Vs.error({err:c},"teams operation failed")}}catch(a){Vs.error({err:a},"teams operation failed")}if(Date.now()>=e)throw new Error(`mailbox lock ${t}: timed out after ${String(Bf)}ms, message not written`);LS(r+Math.floor(Math.random()*r)),r=Math.min(r*2,FS)}}function GS(t){try{Qf(t)}catch(e){Vs.error({err:e},"teams operation failed")}}function wl(t,e){let r=t+".lock";qS(r);try{return e()}finally{GS(r)}}var Ks=class{filePath;constructor(e,r){RS(e,{recursive:!0}),this.filePath=jS(e,`${r}.json`)}readAll(){if(!DS(this.filePath))return[];try{let e=JSON.parse(bS(this.filePath,"utf-8")),r=[];if(Array.isArray(e))for(let s of e){let o=NS.safeParse(s);o.success&&r.push(o.data)}return r}catch(e){return Vs.error({err:e},"teams operation failed"),[]}}writeAll(e){xS(this.filePath,JSON.stringify(e,null,2),"utf-8")}async send(e,r,s){let o=s??{from:e,text:r,timestamp:new Date().toISOString()};return o.read=!1,wl(this.filePath,()=>{let n=this.readAll();n.push(o),this.writeAll(n)}),Promise.resolve()}receiveSync(){return wl(this.filePath,()=>{let e=this.readAll(),r=e.filter(s=>!s.read);if(r.length>0){for(let s of e)s.read=!0;this.writeAll(e)}return r})}async receive(){return Promise.resolve(this.receiveSync())}unreadCount(){return this.readAll().filter(e=>!e.read).length}markAllRead(){wl(this.filePath,()=>{let e=this.readAll(),r=!1;for(let s of e)s.read||(s.read=!0,r=!0);r&&this.writeAll(e)})}async*poll(e=1e3){for(;;){let r=await this.receive();for(let s of r)yield s;await new Promise(s=>setTimeout(s,e))}}};var _f=D.object({toolName:D.string(),input:D.record(D.string(),D.unknown()),activityDescription:D.string()}),HS=D.object({toolUseCount:D.number(),tokenCount:D.number(),lastActivity:_f.optional(),recentActivities:D.array(_f)}),iP=D.object({name:D.string(),teamName:D.string(),status:D.enum(["running","idle","completed","failed","stopped"]),progress:HS,startTime:D.number(),spinnerVerb:D.string(),lastMessage:D.string().optional()});function Cl(){return{toolUseCount:0,tokenCount:0,lastActivity:void 0,recentActivities:[]}}function Sf(t,e,r){t.toolUseCount++;let s=YS(e,r),o={toolName:e,input:r,activityDescription:s};t.lastActivity=o,t.recentActivities.push(o),t.recentActivities.length>5&&t.recentActivities.shift()}function kf(t,e,r){t.tokenCount=e+r}function YS(t,e){switch(t){case"ReadFile":return`Reading ${k(e,"file_path","file")}`;case"EditFile":return`Editing ${k(e,"file_path","file")}`;case"WriteFile":return`Writing ${k(e,"file_path","file")}`;case"Bash":{let r=k(e,"command","");return`Running ${r.length>40?r.slice(0,40)+"...":r}`}case"Glob":return`Searching ${k(e,"pattern","files")}`;case"Grep":return`Grepping ${k(e,"pattern","pattern")}`;default:return t}}function aP(t){return t.length?t[t.length-1].activityDescription:""}function cP(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"k":String(t)}import{readFileSync as JS,writeFileSync as WS,mkdirSync as VS,existsSync as KS}from"fs";import{dirname as ZS}from"path";var XS=y.object({id:y.string(),title:y.string(),description:y.string().default(""),status:y.string().default("pending"),assignee:y.string().default(""),blocks:y.array(y.string()).default([]),blocked_by:y.array(y.string()).default([]),created_by:y.string().default("")}),ek=y.object({next_id:y.number().int().positive().default(1),tasks:y.array(XS).default([])}),Zs=class{path;nextId=1;tasks=[];constructor(e){this.path=e,this.load()}load(){if(KS(this.path))try{let e=JSON.parse(JS(this.path,"utf-8")),r=Se(ek,e);this.nextId=r.next_id,this.tasks=r.tasks.map(s=>({id:s.id,title:s.title,description:s.description,status:s.status,assignee:s.assignee,blocks:s.blocks,blockedBy:s.blocked_by,createdBy:s.created_by}))}catch{}}save(){VS(ZS(this.path),{recursive:!0});let e={next_id:this.nextId,tasks:this.tasks.map(r=>({id:r.id,title:r.title,description:r.description,status:r.status,assignee:r.assignee,blocks:r.blocks,blocked_by:r.blockedBy,created_by:r.createdBy}))};WS(this.path,JSON.stringify(e,null,2),"utf-8")}create(e,r="",s="",o=[],n=[],i=""){let a={id:String(this.nextId++),title:e,description:r,status:"pending",assignee:s,blocks:[...o],blockedBy:[...n],createdBy:i};return this.tasks.push(a),this.save(),a}get(e){return this.load(),this.tasks.find(r=>r.id===e)}listTasks(e,r){return this.load(),this.tasks.filter(s=>!(e&&s.status!==e||r&&s.assignee!==r))}update(e,r){this.load();let s=this.tasks.find(o=>o.id===e);if(s){r.status!==void 0&&(s.status=r.status),r.assignee!==void 0&&(s.assignee=r.assignee),r.description!==void 0&&(s.description=r.description);for(let o of r.addBlocks??[])s.blocks.includes(o)||s.blocks.push(o);for(let o of r.addBlockedBy??[])s.blockedBy.includes(o)||s.blockedBy.push(o);return this.save(),s}}initEmpty(){this.tasks=[],this.nextId=1,this.save()}};import{existsSync as tk,mkdirSync as rk,readFileSync as sk,writeFileSync as ok}from"fs";import{homedir as nk}from"os";import{dirname as ik,join as Il}from"path";var ak=y.object({agentId:y.string(),name:y.string(),agentType:y.string().optional(),model:y.string().optional(),joinedAt:y.number(),worktreePath:y.string().optional(),backendType:y.string().optional(),isActive:y.boolean().optional()}),ck=y.object({name:y.string(),description:y.string().optional(),createdAt:y.number(),leadAgentId:y.string(),members:y.array(ak)});function lk(){return Il(nk(),".swifty","teams")}function uk(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function Xs(t){return Il(lk(),uk(t))}function Mf(t){return Il(Xs(t),"config.json")}function vf(t){let e=Mf(t);if(!tk(e))return null;try{let r=JSON.parse(sk(e,"utf-8"));return ck.parse(r)}catch{return null}}function bf(t,e){try{let r=Mf(t);rk(ik(r),{recursive:!0}),ok(r,JSON.stringify(e,null,2),"utf-8")}catch{}}import{mkdirSync as Ak,readFileSync as wP,writeFileSync as dk,existsSync as CP}from"fs";import{join as xf}from"path";var SP=R({module:"teams"}),pk=y.object({tool_use_id:y.string(),tool_name:y.string(),arguments:y.record(y.string(),y.unknown())}),mk=y.object({tool_use_id:y.string(),content:y.string(),is_error:y.boolean().optional()}),kP=y.object({role:y.string(),content:y.string().optional(),tool_uses:y.array(pk).optional(),tool_results:y.array(mk).optional()});function fk(t){let e=[];for(let r of t.getMessages()){let s={role:r.role,content:oi(r.content)};r.toolUses&&r.toolUses.length>0&&(s.tool_uses=r.toolUses.map(o=>({tool_use_id:o.toolUseId,tool_name:o.toolName,arguments:o.arguments}))),r.toolResults&&r.toolResults.length>0&&(s.tool_results=r.toolResults.map(o=>({tool_use_id:o.toolUseId,content:oi(o.content),is_error:o.isError||void 0}))),e.push(s)}return e}function gk(t,e){return xf(t,".swifty","teams",e,"transcripts")}function Rf(t,e,r,s){let o=gk(t,e);Ak(o,{recursive:!0});let n=xf(o,`${r}.json`),i=fk(s);return dk(n,JSON.stringify(i,null,2),"utf-8"),n}var Df=R({module:"teams"}),Pn=class t{name;mode;members=new Map;leadMailbox;mailboxDir;workDir;leadAgentId="";description;createdAt=Math.floor(Date.now()/1e3);constructor(e,r,s){this.name=e,this.mode=r,this.workDir=s,this.mailboxDir=Bl(Xs(e),"inboxes"),hk(this.mailboxDir,{recursive:!0}),this.leadMailbox=new Ks(this.mailboxDir,"lead")}addMember(e){let r=new Ks(this.mailboxDir,e),s={name:e,active:!1,mailbox:r,agentId:e,joinedAt:Math.floor(Date.now()/1e3)};return this.members.set(e,s),this.persist(),s}setMemberMeta(e,r){let s=this.members.get(e);s&&(s.agentType=r.agentType,s.model=r.model,s.worktreePath=r.worktreePath,this.persist())}snapshot(){return{name:this.name,description:this.description,createdAt:this.createdAt,leadAgentId:this.leadAgentId,members:[...this.members.values()].map(e=>({agentId:e.agentId??e.name,name:e.name,agentType:e.agentType,model:e.model,joinedAt:e.joinedAt??0,worktreePath:e.worktreePath,backendType:this.mode,isActive:e.active}))}}persist(){bf(this.name,this.snapshot())}static IDLE_POLL_INTERVAL_MS=500;static SHUTDOWN_PREFIX="[shutdown]";spawnTeammate(e,r,s,o){if(this.mode==="in-process"){this.spawnInProcess(e,r,s,o);return}try{this.spawnExternal(e,r)}catch{this.spawnInProcess(e,r,s,o)}}spawnExternal(e,r){let s=this.addMember(e);s.active=!0,Pr().register(e,e),s.uiState={name:e,teamName:this.name,status:"running",progress:Cl(),startTime:Date.now(),spinnerVerb:yl()};let o=process.argv[1]??"src/main.tsx",n={mode:this.mode,command:"bun",args:["run",o,"--teammate","--team-dir",this.mailboxDir,"--team-name",this.name,"--member-name",e,"--task",r],cwd:this.workDir},{cancel:i,paneId:a}=If(n);s.cancel=i,s.paneId=a,s.external=!0}spawnInProcess(e,r,s,o){let n=this.addMember(e);n.active=!0,n.checker=o,Pr().register(e,e);let i={name:e,teamName:this.name,status:"running",progress:Cl(),startTime:Date.now(),spinnerVerb:yl()};n.uiState=i;let a=c=>{switch(c.type){case"tool_use":c.toolName&&c.args&&Sf(i.progress,c.toolName,c.args);break;case"usage":c.usage&&kf(i.progress,c.usage.inputTokens,c.usage.outputTokens);break;case"stream_text":c.text&&(i.lastMessage=c.text);break}};(async()=>{let c=r,u="available";try{for(;n.active;){i.status="running";let l=await s(c,a);if(i.lastMessage=l.length>200?l.slice(0,200)+"...":l,n.checker?.mode==="plan"){i.status="idle";let p=await this.runPlanApproval(n,this.readPlanForReview());if(p===null)break;c=p;continue}i.status="idle",await this.leadMailbox.send(e,`[idle] ${e} (reason: ${u})`),u="available";let A=await this.waitForNextPromptOrShutdown(n);if(A.shutdown||!n.active){let p=A.shutdown;if(p?.type===Zt){let m=vn(n.name,p.requestId??"",!0,"acknowledged, shutting down");await this.leadMailbox.send(n.name,m.text,m)}break}c=A.prompt}i.status="completed"}catch(l){Df.error({err:l},"teams operation failed"),i.status="failed",i.lastMessage=U(l),await this.leadMailbox.send(e,`[idle] ${e} (reason: failed)`)}finally{if(n.active=!1,i.status==="running"&&(i.status="idle"),n.conversation)try{Rf(this.workDir,this.name,e,n.conversation)}catch(l){Df.error({err:l},"teams operation failed")}}})()}async waitForNextPromptOrShutdown(e){for(;e.active;){await new Promise(n=>setTimeout(n,t.IDLE_POLL_INTERVAL_MS));let r=e.mailbox.receiveSync();if(r.length===0)continue;let s=r.find(n=>Wm(n));return s?{prompt:"",shutdown:s}:{prompt:`You have new messages from your team:
|
|
155
155
|
|
|
156
156
|
${r.map(n=>`From ${n.from}: ${n.text}`).join(`
|
|
157
157
|
|
|
158
|
-
`)}`}}return{prompt:"",shutdown:
|
|
159
|
-
Please revise the plan accordingly and resubmit.`}return null}getMember(e){return this.members.get(e)}async sendMessage(e,r,s){let o=this.members.get(r);if(!o)throw new Error(`Member '${r}' not found in team '${this.name}'`);await o.mailbox.send(e,s)}async stopMember(e){let r=this.members.get(e);r&&(await this.stopOne(r),this.persist())}async stopAll(){for(let e of this.members.values())await this.stopOne(e)}async stopOne(e){if(e.active=!1,e.uiState?.status==="running"&&(e.uiState.status="stopped"),e.external)try{await e.mailbox.send("lead",`${t.SHUTDOWN_PREFIX} stop`)}catch{}e.cancel?.()}listMembers(){return[...this.members.values()]}getTeammateStates(){return this.listMembers().filter(e=>e.uiState).map(e=>e.uiState)}},
|
|
160
|
-
`))}return e}};function
|
|
158
|
+
`)}`}}return{prompt:"",shutdown:Mn("lead","member deactivated")}}readPlanForReview(){try{let e=Ek(Gl(this.workDir),"utf-8");if(e.trim())return e}catch{}return"(Plan file is empty \u2014 the teammate may not have written the plan as expected)"}async runPlanApproval(e,r){let s=Ym(e.name,r);for(await this.leadMailbox.send(e.name,s.text,s);e.active;){await new Promise(o=>setTimeout(o,t.IDLE_POLL_INTERVAL_MS));for(let o of e.mailbox.receiveSync())if(o.type===$r&&o.requestId===s.requestId)return ul(o)&&e.checker&&(e.checker.mode="default"),ul(o)?"The Lead has approved your plan. Begin execution now.":`The Lead rejected your plan. Feedback: ${o.text}
|
|
159
|
+
Please revise the plan accordingly and resubmit.`}return null}getMember(e){return this.members.get(e)}async sendMessage(e,r,s){let o=this.members.get(r);if(!o)throw new Error(`Member '${r}' not found in team '${this.name}'`);await o.mailbox.send(e,s)}async stopMember(e){let r=this.members.get(e);r&&(await this.stopOne(r),this.persist())}async stopAll(){for(let e of this.members.values())await this.stopOne(e)}async stopOne(e){if(e.active=!1,e.uiState?.status==="running"&&(e.uiState.status="stopped"),e.external)try{await e.mailbox.send("lead",`${t.SHUTDOWN_PREFIX} stop`)}catch{}e.cancel?.()}listMembers(){return[...this.members.values()]}getTeammateStates(){return this.listMembers().filter(e=>e.uiState).map(e=>e.uiState)}},Tf=class{teams=new Map;workDir;taskStores=new Map;constructor(e){this.workDir=e}teamDir(e){return Xs(e)}create(e,r=wf(),s={}){let o=new Pn(e,r,this.workDir);o.leadAgentId=s.leadAgentId??"",o.description=s.description,this.teams.set(e,o);let n=new Zs(Bl(this.teamDir(e),"tasks.json"));return n.initEmpty(),this.taskStores.set(e,n),o.persist(),o}get(e){let r=this.teams.get(e);if(r)return r;let s=vf(e);if(!s)return;let o=s.members.find(i=>i.backendType)?.backendType,n=new Pn(s.name,wk(o)?o:"in-process",this.workDir);n.leadAgentId=s.leadAgentId,n.description=s.description,n.createdAt=s.createdAt;for(let i of s.members){let a=n.addMember(i.name);a.agentId=i.agentId,a.agentType=i.agentType,a.model=i.model,a.worktreePath=i.worktreePath,a.joinedAt=i.joinedAt,a.active=i.isActive===!0}return this.teams.set(e,n),n}getTaskStore(e){let r=this.taskStores.get(e);if(r)return r;let s=new Zs(Bl(this.teamDir(e),"tasks.json"));return this.taskStores.set(e,s),s}list(){return[...this.teams.values()]}async delete(e){let r=this.teams.get(e);if(r){let s=Pr();for(let o of r.listMembers())s.unregister(o.name);await r.stopAll(),this.teams.delete(e)}this.taskStores.delete(e),yk(Xs(e),{recursive:!0,force:!0})}getAllTeammateStates(){return this.list().flatMap(e=>e.getTeammateStates())}drainLeads(){let e=[];for(let r of this.teams.values()){let s=r.leadMailbox.receiveSync();if(s.length===0)continue;let o=[];o.push(`<task-notification team="${r.name}">`);for(let n of s)o.push(`from=${n.from}: ${n.text}`);o.push("</task-notification>"),e.push(o.join(`
|
|
160
|
+
`))}return e}};function wk(t){return t==="in-process"||t==="tmux"||t==="iterm"}import{execFile as Ck}from"child_process";var $f=`
|
|
161
161
|
Execute a shell command and return stdout and stderr.
|
|
162
162
|
|
|
163
163
|
IMPORTANT: Avoid using this tool to run cat, head, tail, sed, awk or echo commands. Instead use the dedicated ReadFile, EditFile, or WriteFile tools which provide a better experience.
|
|
@@ -219,9 +219,10 @@ Usage Notes
|
|
|
219
219
|
|
|
220
220
|
- Supports patterns like "**/*.ts", "src/js/*.js", "*.{ts,tsx}".
|
|
221
221
|
- Search from "." or a specific path, never from "/".
|
|
222
|
+
- Hidden (dot) files and directories are included, so "**/*.yml" also finds ".github/workflows/ci.yml".
|
|
222
223
|
- Automatically skips .git, node_modules, __pycache__, and similar directories.
|
|
223
224
|
- Use this instead of find or ls command via Bash.
|
|
224
|
-
`,
|
|
225
|
+
`,Uf=`
|
|
225
226
|
Search file content using a regex pattern (case-insensitive), returning file:line:content matches.
|
|
226
227
|
|
|
227
228
|
Usage Notes
|
|
@@ -232,34 +233,34 @@ Usage Notes
|
|
|
232
233
|
- Search from "." or a specific path, never from "/".
|
|
233
234
|
- Automatically skips .git, node_modules, __pycache__, and similar directories.
|
|
234
235
|
- Use this instead of grep or rg commands via Bash.
|
|
235
|
-
`;var jn=new Set([".claude",".git",".swifty",".next",".venv",".mypy_cache",".tox","__pycache__","build","dist","node_modules","vendor","venv"]);var
|
|
236
|
-
`;if(c&&(
|
|
237
|
-
Exit code ${String(l)} (${
|
|
238
|
-
Exit code ${String(l)}`}i({output:
|
|
236
|
+
`;var jn=new Set([".claude",".git",".swifty",".next",".venv",".mypy_cache",".tox","__pycache__","build","dist","node_modules","vendor","venv"]);var Ff=600;function Ik(t){let r=(t.split("|").pop()?.trim()??t).split(/\s+/);for(let s of r)if(!(s.includes("=")&&!s.startsWith("-")))return s.split("/").pop()??s;return""}var Bk=new Map([["grep",new Map([[1,"no matches found"]])],["egrep",new Map([[1,"no matches found"]])],["fgrep",new Map([[1,"no matches found"]])],["rg",new Map([[1,"no matches found"]])],["diff",new Map([[1,"files differ"]])],["test",new Map([[1,"condition is false"]])],["[",new Map([[1,"condition is false"]])],["find",new Map([[1,"partial success"]])]]);function Qk(t,e){let r=Ik(t);return Bk.get(r)?.get(e)??""}var Of=class{name="Bash";description=$f;category="command";sandbox=null;sandboxConfig={allowWrite:[],denyWrite:[],networkEnabled:!0};schema(){let e={type:"object",properties:{command:{type:"string",description:"Shell command to execute"},timeout:{type:"integer",description:"Timeout in seconds (max 600)",default:120}},required:["command"]};return{name:this.name,description:this.description,input_schema:e}}execute(e,r){let s=k(r,"command");if(!s)return Promise.resolve({output:"Error: command is required",isError:!0});let o=bt(r,"timeout",120);o>Ff&&(o=Ff);let n=s;return this.sandbox?.available()&&(n=this.sandbox.wrap(s,this.sandboxConfig)),new Promise(i=>{Ck("bash",["-c",n],{cwd:e.workDir,timeout:o*1e3,killSignal:"SIGTERM",encoding:"utf-8",maxBuffer:10*1024*1024,...e.abortSignal?{signal:e.abortSignal}:{}},(a,c,u)=>{if(a?.name==="AbortError"){i({output:"Error: command interrupted",isError:!0});return}if(a&&a.killed&&a.signal==="SIGTERM"){i({output:`Error: command timed out after ${String(o)}s`,isError:!0});return}if(a&&typeof a.code!="number"&&!c&&!u){i({output:`Error executing command: ${a.message}`,isError:!0});return}let l=a&&typeof a.code=="number"?a.code:0,A=`$ ${s}
|
|
237
|
+
`;if(c&&(A+=c),u&&(A+=u),l!==0){let p=Qk(s,l);A+=p?`
|
|
238
|
+
Exit code ${String(l)} (${p})`:`
|
|
239
|
+
Exit code ${String(l)}`}i({output:A,isError:!1})})})}};import{readFile as _k,writeFile as Sk}from"fs/promises";function Lf(t,e){let r=t.split(`
|
|
239
240
|
`),s=e.split(`
|
|
240
|
-
`),o=0,n=Math.min(r.length,s.length);for(;o<n&&r[o]===s[o];)o++;let i=0,a=n-o;for(;i<a&&r[r.length-1-i]===s[s.length-1-i];)i++;let c=r.slice(o,r.length-i),u=s.slice(o,s.length-i),l=Math.max(0,o-3),
|
|
241
|
-
`),additions:u.length,removals:c.length}}var
|
|
242
|
-
${l}`,isError:!1}}catch(l){return
|
|
243
|
-
`).slice(n,n+i);e.fileStateCache?.record(s,o.mtimeMs);let l=u.map((
|
|
244
|
-
`),isError:!1})}catch(a){return Wf.error({err:a},"tool operation failed"),Promise.resolve({output:`Error reading file: ${
|
|
241
|
+
`),o=0,n=Math.min(r.length,s.length);for(;o<n&&r[o]===s[o];)o++;let i=0,a=n-o;for(;i<a&&r[r.length-1-i]===s[s.length-1-i];)i++;let c=r.slice(o,r.length-i),u=s.slice(o,s.length-i),l=Math.max(0,o-3),A=r.slice(l,o),p=Math.min(r.length,r.length-i+3),m=r.slice(r.length-i,p),g=[],f=l+1,h=l+1,w=!1,C=(I,b,E)=>{if(g.length>=200){w=!0;return}g.push(`${I} ${String(b).padStart(4)} ${E}`)};for(let I of A)C(" ",f,I),f++,h++;for(let I of c)C("-",f,I),f++;for(let I of u)C("+",h,I),h++;for(let I of m)C(" ",f,I),f++,h++;return w&&g.push(` ... (diff truncated at ${String(200)} lines)`),{text:g.join(`
|
|
242
|
+
`),additions:u.length,removals:c.length}}var qf=R({module:"tools"}),Nn=class{name="EditFile";description=jf;category="write";schema(){let e={type:"object",properties:{file_path:{type:"string",description:"Absolute path to the file"},old_string:{type:"string",description:"Exact string to find and replace"},new_string:{type:"string",description:"Replacement string"},replace_all:{type:"boolean",description:"Replace all occurrences of old_string (default false)",default:!1}},required:["file_path","old_string","new_string"]};return{name:this.name,description:this.description,input_schema:e}}async execute(e,r){let s=k(r,"file_path"),o=k(r,"old_string"),n=k(r,"new_string"),i=Ao(r,"replace_all");if(!s)return{output:"Error: file_path is required",isError:!0};if(!o)return{output:"Error: old_string is required",isError:!0};if(o===n)return{output:"Error: old_string and new_string MUST be different",isError:!0};if(e.fileStateCache){let l=e.fileStateCache.check(s);if(!l.ok)return{output:l.error,isError:!0}}e.fileHistory?.trackEdit(s);let a;try{a=await _k(s,"utf-8")}catch(l){return qf.error({err:l},"tool operation failed"),{output:`Error reading file: ${U(l)}`,isError:!0}}let c=a.split(o).length-1;if(c===0)return{output:"Error: old_string not found in file",isError:!0};if(!i&&c>1)return{output:`Error: old_string found ${String(c)} times in file. It must be unique. Add more surrounding context, or set replace_all to true`,isError:!0};let u=i?a.replaceAll(o,n):a.replace(o,n);try{await Sk(s,u,"utf-8"),e.fileStateCache?.update(s);let{text:l,additions:A,removals:p}=Lf(a,u);return{output:`${i&&c>1?`Updated ${s} with ${String(A)} addition${A===1?"":"s"} and ${String(p)} removal${p===1?"":"s"} (${String(c)} replacements)`:`Updated ${s} with ${String(A)} addition${A===1?"":"s"} and ${String(p)} removal${p===1?"":"s"}`}
|
|
243
|
+
${l}`,isError:!1}}catch(l){return qf.error({err:l},"tool operation failed"),{output:`Error writing file: ${U(l)}`,isError:!0}}}};import{statSync as Gf}from"fs";var Hf=R({module:"file-state-cache"}),Yf=class{cache=new Map;record(e,r){this.cache.set(e,r)}check(e){let r=this.cache.get(e);if(r===void 0)return{ok:!1,error:"Error: file has not been read yet, read it first before editing."};let s;try{s=Gf(e).mtimeMs}catch(o){return Hf.error({err:o},"file state cache operation failed"),{ok:!0}}return s>r?{ok:!1,error:"Error: file has been modified since last read, read it again before editing."}:{ok:!0}}update(e){let r;try{r=Gf(e).mtimeMs}catch(s){Hf.error({err:s},"file state cache operation failed"),this.cache.delete(e);return}this.cache.set(e,r)}};import{existsSync as kk,readFileSync as Mk,statSync as vk}from"fs";import{basename as Jf}from"path";var Wf=R({module:"tools"}),zn=class{name="ReadFile";description=Pf;category="read";schema(){let e={type:"object",properties:{file_path:{type:"string",description:"Absolute path to the file"},offset:{type:"integer",description:"Line number to start from (0-based)",default:0},limit:{type:"integer",description:"Max lines to read",default:2e3}},required:["file_path"]};return{name:this.name,description:this.description,input_schema:e}}execute(e,r){let s=k(r,"file_path");if(!s)return Promise.resolve({output:"Error: file_path is required",isError:!0});if(!kk(s))return Promise.resolve({output:`Error: file not found: ${s}`,isError:!0});let o=vk(s);if(o.isDirectory())return Promise.resolve({output:`Error: ${s} is a directory, not a file. Use Glob to list directory contents.`,isError:!0});if(km(s))return this.readImage(e,s,o.mtimeMs);let n=bt(r,"offset",0),i=bt(r,"limit",2e3);try{let u=Mk(s,"utf-8").split(`
|
|
244
|
+
`).slice(n,n+i);e.fileStateCache?.record(s,o.mtimeMs);let l=u.map((A,p)=>`${String(n+p+1)} ${A}`);return Promise.resolve({output:l.join(`
|
|
245
|
+
`),isError:!1})}catch(a){return Wf.error({err:a},"tool operation failed"),Promise.resolve({output:`Error reading file: ${U(a)}`,isError:!0})}}async readImage(e,r,s){try{let o=await Mm(r);e.fileStateCache?.record(r,s);let n={type:"text",text:`[image: ${Jf(r)} \xB7 ${o.mediaType} \xB7 ${bk(o.byteLength)}]`},i={type:"image",source:{type:"base64",media_type:o.mediaType,data:o.data}};return{output:[n,i],isError:!1}}catch(o){return Wf.error({err:o},"image read failed"),{output:`Error reading image ${Jf(r)}: ${U(o)}`,isError:!0}}}};function bk(t){return t>=1024*1024?`${(t/(1024*1024)).toFixed(1)}MB`:t>=1024?`${String(Math.round(t/1024))}KB`:`${String(t)}B`}var Vf=class{constructor(e){this.jsonSchema=e}jsonSchema;name="SyntheticOutput";description="Return structured output in JSON format. Use this tool to return your final response as structured data in non-interactive or coordinator mode sessions.";category="read";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{output:{description:"The structured result: an object, an array, or a plain string"}},required:["output"]}}}execute(e,r){if(!("output"in r))return Promise.resolve({output:"Error: output is required",isError:!0});let s=r.output,o=this.validateSchema(s);if(o)return Promise.resolve({output:`Output does not match required schema: ${o}`,isError:!0});if(typeof s=="string")return Promise.resolve({output:s,isError:!1});try{return Promise.resolve({output:JSON.stringify(s,null,2),isError:!1})}catch(n){return Promise.resolve({output:`Error: output is not serializable: ${U(n)}`,isError:!0})}}validateSchema(e){if(!this.jsonSchema)return"";let r=this.jsonSchema.type;if(typeof r=="string"){let o=Array.isArray(e);if(r==="object"&&!(typeof e=="object"&&e!==null&&!o))return`Expected object, got ${o?"array":typeof e}`;if(r==="array"&&!o)return`Expected array, got ${typeof e}`;if(r==="string"&&typeof e!="string")return`Expected string, got ${o?"array":typeof e}`}let s=this.jsonSchema.required;if(Array.isArray(s)&&typeof e=="object"&&e!==null&&!Array.isArray(e)){let o=s.filter(n=>typeof n=="string"&&!(n in e));if(o.length>0)return`Missing required fields: ${o.join(", ")}`}return""}};var Kf=class{name=ql;description="Search for and load deferred tools by name or keyword.";category="read";registry;constructor(e){this.registry=e}schema(){let e={type:"object",properties:{query:{type:"string",description:'Search query. Use "select:name1,name2" to load specific tools by name, or keywords to search.'},max_results:{type:"integer",description:"Max results to return",default:5}},required:["query"]};return{name:this.name,description:this.description,input_schema:e}}execute(e,r){let s=k(r,"query"),o=bt(r,"max_results",5);if(!s)return Promise.resolve({output:"Error: query is required",isError:!0});if(s.startsWith("select:")){let a=s.slice(7).split(",").map(p=>p.trim()),c=this.registry.findDeferredByNames(a);if(c.length===0)return Promise.resolve({output:`No deferred tools found matching: ${a.join(", ")}`,isError:!1});let u=[];for(let p of c)p.name.startsWith(Ll)?u.push(p.name):this.registry.markDiscovered(p.name);if(u.length>0&&this.registry.mcpLoadingMode==="native")return Promise.resolve({output:`Loaded ${String(u.length)} tool(s): ${u.join(", ")}. You can call them directly now.`,isError:!1,contentBlocks:u.map(p=>({type:"tool_reference",tool_name:p}))});let l=c.map(p=>JSON.stringify(p.schema(),null,2)),A=u.length>0?"\n\nTo invoke any of the tools above, call McpCall with that tool's full name and an `arguments` object matching its input_schema exactly, using the same JSON types.":"";return Promise.resolve({output:l.join(`
|
|
245
246
|
|
|
246
|
-
`)+
|
|
247
|
+
`)+A,isError:!1})}let n=this.registry.searchDeferred(s,o);if(n.length===0)return Promise.resolve({output:"No deferred tools matched the query.",isError:!1});let i=n.map(a=>JSON.stringify(a.schema(),null,2));return Promise.resolve({output:i.join(`
|
|
247
248
|
|
|
248
|
-
`),isError:!1})}};import{statSync as zS}from"fs";import{join as FS,resolve as US}from"path";import{existsSync as RS,readFileSync as TS,readdirSync as DS,lstatSync as $S,statSync as PS}from"fs";import{fileURLToPath as Zf}from"url";var Xt=null;function jS(t,e,r,s){throw new RangeError("@swifty.js/glob-wasm: glob compile aborted (pattern too complex)")}function Xf(t){return new WebAssembly.Instance(new WebAssembly.Module(t),{env:{abort:jS,"Date.now":()=>Date.now(),seed:()=>Math.random()*Number.MAX_SAFE_INTEGER}}).exports}function NS(){if(Xt)return Xt;let t=[new URL("./glob.wasm",import.meta.url),new URL("./release.wasm",import.meta.url),new URL("../build/release.wasm",import.meta.url)];for(let r of t){let s=Zf(r);if(RS(s))return Xt=Xf(TS(s)),Xt}let e="AGFzbQEAAAABPgtgAn9/AX9gAn9/AGABfwF/YAF/AGADf39/AX9gAABgBH9/f38Bf2AEf39/fwBgA39/fwBgAAF/YAN/f34AAg0BA2VudgVhYm9ydAAHAzIxAAICAwYBAAgAAAgEBwEJAwEBAwMCBgAAAAUKBQEBAAQABAIFAwIFAAACAAEEBgIBBAUDAQABBkUNfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38AQfATC38BQayUAgsHdAsIaGFzU2xhc2gALwVfX25ldwAJBV9fcGluACYHX191bnBpbgAlCV9fY29sbGVjdAAnC19fcnR0aV9iYXNlAwsGbWVtb3J5AgAHY29tcGlsZQAqBW1hdGNoACgJZ2xvYk1hdGNoACkKY2FuRGVzY2VuZAArCAEkDAE8Cq1aMVwAIwxBBGskDCMMQawUSARAQcCUAkHwlAJBAUEBEAAACyMMQQA2AgAjDCAANgIAIAEgAEEUaygCEEEBdk8EQCMMQQRqJAxBfw8LIAAgAUEBdGovAQAjDEEEaiQMC1wAIwxBBGskDCMMQawUSARAQcCUAkHwlAJBAUEBEAAACyMMQQA2AgAjDCAANgIAIAAoAgxFBEBBgAtBgA5B8gBBKh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AAACoAAABPAGIAagBlAGMAdAAgAGEAbAByAGUAYQBkAHkAIABwAGkAbgBuAGUAZABBrBMLATwAQbgTCy8CAAAAKAAAAE8AYgBqAGUAYwB0ACAAaQBzACAAbgBvAHQAIABwAGkAbgBuAGUAZABB8BMLDQ4AAAAgAAAAIAAAACAAQZAUCxkCQQAAAkEAAAJBAAACCQAAAkEAAEIAAABCACQQc291cmNlTWFwcGluZ1VSTBIuL3JlbGVhc2Uud2FzbS5tYXA=";if(e.length>0)return Xt=Xf(new Uint8Array(Buffer.from(e,"base64"))),Xt;throw new Error(`@swifty.js/glob-wasm: glob.wasm not found (searched: ${t.map(r=>Zf(r)).join(", ")})`)}function eo(t,e,r){let s=t.__new(e.length<<1,2),o=new Uint16Array(t.memory.buffer,s,e.length);for(let n=0;n<e.length;n++)o[n]=e.charCodeAt(n);t.__pin(s);try{return r(s)}finally{t.__unpin(s)}}var zr=class{pattern;dot;id=0;constructor(e,r){this.pattern=e,this.dot=r?.dot??!1}ensureCompiled(){if(this.id===0){let e=NS();if(Buffer.byteLength(this.pattern,"utf-8")>64*1024)throw new RangeError("glob pattern is too long (limit: 65536 bytes)");this.id=eo(e,this.pattern,r=>e.compile(r))}return Xt}match(e){let r=this.ensureCompiled();return eo(r,e,s=>r.match(this.id,s))!==0}scan(e){let r=this.ensureCompiled(),s=1e3;if(e?.maxResults!==void 0){let A=e.maxResults;if(typeof A!="number"||Number.isNaN(A)||A<0)throw new TypeError("maxResults must be a non-negative number");s=Math.min(Math.floor(A),4294967295)}let o=e?.cwd??".";try{if(!PS(o).isDirectory())throw new Error(`ENOTDIR: not a directory, scan '${o}'`)}catch(A){throw A instanceof Error&&A.message.startsWith("ENOTDIR")?A:new Error(`ENOENT: no such directory, scan '${o}'`)}let n=new Set(e?.exclude??[]),i=e?.dot??this.dot,a=r.hasSlash(this.id)!==0,c=0;for(;c<this.pattern.length&&this.pattern.charCodeAt(c)===33;)c++;let u=a&&c%2===0,l=[],d=(A,m)=>{if(l.length>=s)return;let g;try{g=DS(A)}catch{return}let f=[];for(let h of g){if(!i&&h.length>0&&h.charAt(0)===".")continue;let y;try{let C=$S(`${A}/${h}`);C.isDirectory()?y="dir":C.isFile()||C.isSymbolicLink()?y="file":y="other"}catch{continue}y!=="other"&&f.push({name:h,isDir:y==="dir"})}f.sort((h,y)=>h.name<y.name?-1:h.name>y.name?1:0);for(let h of f){if(l.length>=s)return;if(h.isDir){if(n.has(h.name))continue;if(u){let y=m+h.name;if(!eo(r,y,Q=>r.canDescend(this.id,Q)))continue}d(`${A}/${h.name}`,m+h.name+"/")}else if(a){let y=m+h.name;eo(r,y,Q=>r.match(this.id,Q))&&l.push(y)}else eo(r,h.name,C=>r.match(this.id,C))&&l.push(m+h.name)}};return d(o,""),l}};var eg=x({module:"tools"}),Fn=class{name="Glob";description=zf;category="read";schema(){let e={type:"object",properties:{pattern:{type:"string",description:"Glob pattern (e.g., '**/*.ts', '**/*.go')"},path:{type:"string",description:"Base directory to search from",default:"."}},required:["pattern"]};return{name:this.name,description:this.description,input_schema:e}}execute(e,r){let s=S(r,"pattern");if(!s)return Promise.resolve({output:"Error: pattern is required",isError:!0});let o=US(e.workDir,S(r,"path",e.workDir)),n=1e3;try{let a=new zr(s).scan({cwd:o,exclude:[...jn],maxResults:n});if(a.length===0)return Promise.resolve({output:"No files matched the pattern.",isError:!1});let c=new Map;for(let l of a){let d=0;try{d=zS(FS(o,l)).mtimeMs}catch(A){eg.debug({err:A,match:l},"stat failed while sorting glob results")}c.set(l,d)}a.sort((l,d)=>(c.get(d)??0)-(c.get(l)??0)||l.localeCompare(d));let u=a.join(`
|
|
249
|
+
`),isError:!1})}};import{statSync as Nk}from"fs";import{join as zk,resolve as Uk}from"path";import{existsSync as xk,readFileSync as Rk,readdirSync as Dk,lstatSync as Tk,statSync as $k}from"fs";import{fileURLToPath as Zf}from"url";var Xt=null;function Pk(t,e,r,s){throw new RangeError("@swifty.js/glob-wasm: glob compile aborted (pattern too complex)")}function Xf(t){return new WebAssembly.Instance(new WebAssembly.Module(t),{env:{abort:Pk,"Date.now":()=>Date.now(),seed:()=>Math.random()*Number.MAX_SAFE_INTEGER}}).exports}function jk(){if(Xt)return Xt;let t=[new URL("./glob.wasm",import.meta.url),new URL("./release.wasm",import.meta.url),new URL("../build/release.wasm",import.meta.url)];for(let r of t){let s=Zf(r);if(xk(s))return Xt=Xf(Rk(s)),Xt}let e="AGFzbQEAAAABPgtgAX8Bf2ACf38AYAN/f38Bf2ACf38Bf2ABfwBgBH9/f38Bf2AAAGAEf39/fwBgA39/fwBgAAF/YAN/f34AAg0BA2VudgVhYm9ydAAHAzMyAwAAAwQFAQgDAwgCBwEJBAEBBAQAAAUDAwMGCgYBAQICAgIABgQABgICAAIBBQUAAQUFAwEAAQZFDX8BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AEHwEwt/AUGslAILB3QLCGhhc1NsYXNoADAFX19uZXcACQVfX3BpbgAnB19fdW5waW4AJglfX2NvbGxlY3QAKAtfX3J0dGlfYmFzZQMLBm1lbW9yeQIAB2NvbXBpbGUAKwVtYXRjaAApCWdsb2JNYXRjaAAqCmNhbkRlc2NlbmQALAgBJQwBPAq4XTJcACMMQQRrJAwjDEGsFEgEQEHAlAJB8JQCQQFBARAAAAsjDEEANgIAIwwgADYCACABIABBFGsoAhBBAXZPBEAjDEEEaiQMQX8PCyAAIAFBAXRqLwEAIwxBBGokDAtcACMMQQRrJAwjDEGsFEgEQEHAlAJB8JQCQQFBARAAAAsjDEEANgIAIwwgADYCACAAKAIMRQRAQYALQYAOQfIAQSoQAAALIwwgADYCACAAKAIEKAIAIwxBBGokDAs7ACMMQQRrJAwjDEGsFEgEQEHAlAJB8JQCQQFBARAAAAsjDEEANgIAIwwgADYCACAAKAIMIwxBBGokDAuBAQAjDEEIayQMIwxBrBRIBEBBwJQCQfCUAkEBQQEQAAALIwxCADcDACMMIAA2AgAgASAAKAIMTwRAQYALQYAO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AdAAgAHQAeQBwAGUAIABtAHUAcwB0ACAAYgBlACAAbgB1AGwAbABhAGIAbABlACAAaQBmACAAYQByAHIAYQB5ACAAaQBzACAAaABvAGwAZQB5AEGsEAsBHABBuBALCwIAAAAEAAAAKgAqAEHMEAsBHABB2BALAQEAQewQCwEcAEH4EAsBAQBBjBELARwAQZgRCwUBAAAABABBrBELARwAQbgRCwUBAAAABABBzBELARwAQdgRCwUBAAAABABB7BELARwAQfgRCwUBAAAAAQBBjBILARwAQZgSCwUBAAAABABBrBILARwAQbgSCwEBAEHMEgsBHABB2BILAQEAQewSCwE8AEH4EgsxAgAAACoAAABPAGIAagBlAGMAdAAgAGEAbAByAGUAYQBkAHkAIABwAGkAbgBuAGUAZABBrBMLATwAQbgTCy8CAAAAKAAAAE8AYgBqAGUAYwB0ACAAaQBzACAAbgBvAHQAIABwAGkAbgBuAGUAZABB8BMLDQ4AAAAgAAAAIAAAACAAQZAUCxkCQQAAAkEAAAJBAAACCQAAAkEAAEIAAABCACQQc291cmNlTWFwcGluZ1VSTBIuL3JlbGVhc2Uud2FzbS5tYXA=";if(e.length>0)return Xt=Xf(new Uint8Array(Buffer.from(e,"base64"))),Xt;throw new Error(`@swifty.js/glob-wasm: glob.wasm not found (searched: ${t.map(r=>Zf(r)).join(", ")})`)}function eo(t,e,r){let s=t.__new(e.length<<1,2),o=new Uint16Array(t.memory.buffer,s,e.length);for(let n=0;n<e.length;n++)o[n]=e.charCodeAt(n);t.__pin(s);try{return r(s)}finally{t.__unpin(s)}}var zr=class{pattern;dot;id=0;constructor(e,r){this.pattern=e,this.dot=r?.dot??!1}ensureCompiled(){if(this.id===0){let e=jk();if(Buffer.byteLength(this.pattern,"utf-8")>64*1024)throw new RangeError("glob pattern is too long (limit: 65536 bytes)");this.id=eo(e,this.pattern,r=>e.compile(r))}return Xt}match(e){let r=this.ensureCompiled(),s=this.dot?1:0;return eo(r,e,o=>r.match(this.id,o,s))!==0}scan(e){let r=this.ensureCompiled(),s=1e3;if(e?.maxResults!==void 0){let g=e.maxResults;if(typeof g!="number"||Number.isNaN(g)||g<0)throw new TypeError("maxResults must be a non-negative number");s=Math.min(Math.floor(g),4294967295)}let o=e?.cwd??".";try{if(!$k(o).isDirectory())throw new Error(`ENOTDIR: not a directory, scan '${o}'`)}catch(g){throw g instanceof Error&&g.message.startsWith("ENOTDIR")?g:new Error(`ENOENT: no such directory, scan '${o}'`)}let n=new Set(e?.exclude??[]),i=e?.dot??this.dot,a=i?1:0,c=r.hasSlash(this.id)!==0,u=0;for(;u<this.pattern.length&&this.pattern.charCodeAt(u)===33;)u++;let l=u%2===1,A=c&&!l,p=[],m=(g,f)=>{if(p.length>=s)return;let h;try{h=Dk(g)}catch{return}let w=[];for(let C of h){if(!i&&l&&C.charAt(0)===".")continue;let I;try{let b=Tk(`${g}/${C}`);b.isDirectory()?I="dir":b.isFile()||b.isSymbolicLink()?I="file":I="other"}catch{continue}I!=="other"&&w.push({name:C,isDir:I==="dir"})}w.sort((C,I)=>C.name<I.name?-1:C.name>I.name?1:0);for(let C of w){if(p.length>=s)return;if(C.isDir){if(n.has(C.name))continue;if(A){let I=f+C.name;if(!eo(r,I,E=>r.canDescend(this.id,E,a)))continue}else if(!i&&C.name.charAt(0)===".")continue;m(`${g}/${C.name}`,f+C.name+"/")}else if(c){let I=f+C.name;eo(r,I,E=>r.match(this.id,E,a))&&p.push(I)}else eo(r,C.name,b=>r.match(this.id,b,a))&&p.push(f+C.name)}};return m(o,""),p}};var Fk=R({module:"tools"}),Un=class{name="Glob";description=zf;category="read";schema(){let e={type:"object",properties:{pattern:{type:"string",description:"Glob pattern (e.g., '**/*.ts', '**/*.go')"},path:{type:"string",description:"Base directory to search from",default:"."}},required:["pattern"]};return{name:this.name,description:this.description,input_schema:e}}execute(e,r){let s=k(r,"pattern");if(!s)return Promise.resolve({output:"Error: pattern is required",isError:!0});let o=Uk(e.workDir,k(r,"path",e.workDir)),n=1e3;try{let a=new zr(s).scan({cwd:o,exclude:[...jn],dot:!0,maxResults:n});if(a.length===0)return Promise.resolve({output:"No files matched the pattern.",isError:!1});let c=new Map;for(let l of a){let A=0;try{A=Nk(zk(o,l)).mtimeMs}catch{}c.set(l,A)}a.sort((l,A)=>(c.get(A)??0)-(c.get(l)??0)||l.localeCompare(A));let u=a.join(`
|
|
249
250
|
`);return a.length>=n&&(u+=`
|
|
250
|
-
(Results limited to ${String(n)} files. Use a more specific pattern.)`),Promise.resolve({output:u,isError:!1})}catch(i){return
|
|
251
|
-
`),
|
|
251
|
+
(Results limited to ${String(n)} files. Use a more specific pattern.)`),Promise.resolve({output:u,isError:!1})}catch(i){return Fk.error({err:i},"tool operation failed"),Promise.resolve({output:`Error: ${U(i)}`,isError:!0})}}};import{lstat as Ok,readdir as Lk,readFile as qk,stat as eg}from"fs/promises";import{join as Gk,relative as tg,resolve as Hk,sep as Yk}from"path";var to=R({module:"tools"}),ro=500,Ye="\\p{L}\\p{M}\\p{N}_",Jk=new Map([["w",`[${Ye}]`],["W",`[^${Ye}]`],["d","\\p{Nd}"],["D","\\P{Nd}"],["b",`(?:(?<![${Ye}])(?=[${Ye}])|(?<=[${Ye}])(?![${Ye}]))`],["B",`(?:(?<=[${Ye}])(?=[${Ye}])|(?<![${Ye}])(?![${Ye}]))`]]),Wk=new Map([["w",Ye],["d","\\p{Nd}"]]);function Vk(t){let e="",r=!1;for(let s=0;s<t.length;s++){let o=t.charAt(s);if(o==="\\"&&s+1<t.length){let n=t.charAt(s+1);if(n==="x"){let a=/^\{([0-9a-fA-F]{1,6})\}/.exec(t.slice(s+2));if(a&&Number.parseInt(a[1],16)<=1114111){e+=`\\u${a[0]}`,s+=1+a[0].length;continue}}let i=r?Wk.get(n):Jk.get(n);e+=i??o+n,s++;continue}o==="["&&!r?r=!0:o==="]"&&r&&(r=!1),e+=o}return e}var Fn=class{name="Grep";description=Uf;category="read";schema(){let e={type:"object",properties:{pattern:{type:"string",description:"Regex pattern to search"},path:{type:"string",description:"Directory or file to search",default:"."},include:{type:"string",description:"File pattern filter (e.g., '*.ts', 'src/**/*.js')"}},required:["pattern"]};return{name:this.name,description:this.description,input_schema:e}}async execute(e,r){let s=k(r,"pattern");if(!s)return{output:"Error: pattern is required",isError:!0};let o=Hk(e.workDir,k(r,"path",e.workDir)),n=k(r,"include"),i;try{i=new RegExp(Vk(s),"iu")}catch{try{i=new RegExp(s,"i")}catch(g){return to.error({err:g},"tool operation failed"),{output:`Error: invalid regex pattern: ${s}`,isError:!0}}}let a=n?new zr(n,{dot:!0}):null,c=n.includes("/"),u=(g,f)=>{if(!a)return!0;let h=c?tg(e.workDir,g).split(Yk).join("/"):f;return a.match(h)},l=[],A=async g=>{if(l.length>=ro)return;let f;try{f=await Lk(g)}catch(h){to.error({err:h},"tool operation failed");return}for(let h of f){if(l.length>=ro)return;if(jn.has(h))continue;let w=Gk(g,h),C;try{if(C=await Ok(w),C.isSymbolicLink()&&(C=await eg(w),!C.isFile()))continue}catch(I){to.error({err:I},"tool operation failed");continue}if(C.isDirectory())await A(w);else if(C.isFile()){if(!u(w,h))continue;await p(w)}}},p=async g=>{try{let f=await qk(g);if(f.subarray(0,8192).includes(0))return;let h=f.toString("utf-8").split(`
|
|
252
|
+
`),w=tg(e.workDir,g);for(let C=0;C<h.length&&l.length<ro;C++)i.test(h[C])&&l.push(`${w}:${String(C+1)}:${h[C]}`)}catch(f){to.error({err:f},"tool operation failed")}};try{(await eg(o)).isFile()?await p(o):await A(o)}catch(g){return to.error({err:g},"tool operation failed"),{output:`Error: ${U(g)}`,isError:!0}}if(l.length===0)return{output:"No matches found.",isError:!1};let m=l.join(`
|
|
252
253
|
`);return l.length>=ro&&(m+=`
|
|
253
254
|
|
|
254
|
-
(results truncated at ${String(ro)} matches)`),{output:m,isError:!1}}};import{existsSync as
|
|
255
|
-
`).length;return Promise.resolve({output:`Successfully wrote to ${s} (${String(n)} lines)`,isError:!1})}catch(n){return
|
|
255
|
+
(results truncated at ${String(ro)} matches)`),{output:m,isError:!1}}};import{existsSync as Kk,mkdirSync as Zk,writeFileSync as Xk}from"fs";import{dirname as eM}from"path";var tM=R({module:"tools"}),On=class{name="WriteFile";description=Nf;category="write";schema(){let e={type:"object",properties:{file_path:{type:"string",description:"Absolute path to write"},content:{type:"string",description:"Content to write"}},required:["file_path","content"]};return{name:this.name,description:this.description,input_schema:e}}execute(e,r){let s=k(r,"file_path"),o=k(r,"content");if(!s)return Promise.resolve({output:"Error: file_path is required",isError:!0});if(e.fileStateCache&&Kk(s)){let n=e.fileStateCache.check(s);if(!n.ok)return Promise.resolve({output:n.error,isError:!0})}try{e.fileHistory?.trackEdit(s),Zk(eM(s),{recursive:!0}),Xk(s,o,"utf-8"),e.fileStateCache?.update(s);let n=o.split(`
|
|
256
|
+
`).length;return Promise.resolve({output:`Successfully wrote to ${s} (${String(n)} lines)`,isError:!1})}catch(n){return tM.error({err:n},"tool operation failed"),Promise.resolve({output:`Error writing file: ${U(n)}`,isError:!0})}}};import{readdirSync as rM,readFileSync as rg,existsSync as sg,statSync as Ur}from"fs";import{homedir as Ln}from"os";import{join as Je}from"path";var so=R({module:"skills"}),og=class{entries=new Map;workDir="";dirModTimes=new Map;load(e){this.workDir=e;let r=[Je(Ln(),".claude","skills"),Je(Ln(),".github","skills"),Je(Ln(),".swifty","skills"),Je(e,".claude","skills"),Je(e,".github","skills"),Je(e,".swifty","skills")];for(let s of r)sg(s)&&this.scanDirectory(s);this.snapshotDirModTimes()}needsReload(){for(let[r,s]of this.dirModTimes)try{if(Ur(r).mtimeMs!==s)return!0}catch{if(s!==0)return!0}let e=this.skillDirPaths();for(let r of e)if(!this.dirModTimes.has(r))try{return Ur(r),!0}catch{}return!1}reload(){this.entries.clear(),this.load(this.workDir)}snapshotDirModTimes(){this.dirModTimes.clear();for(let e of this.skillDirPaths())try{this.dirModTimes.set(e,Ur(e).mtimeMs)}catch{this.dirModTimes.set(e,0)}}skillDirPaths(){return[Je(Ln(),".swifty","skills"),...this.workDir?[Je(this.workDir,".swifty","skills")]:[]]}scanDirectory(e){let r;try{r=rM(e)}catch(s){so.error({err:s},"skills operation failed");return}for(let s of r){let o=Je(e,s);if(Ur(o).isDirectory()){let i=Je(o,"SKILL.md");sg(i)&&this.loadSkill(i,o,!0)}}}loadSkill(e,r,s){try{let o=rg(e,"utf-8"),n=ng(o);if(!n)return;let i={meta:n.meta,body:n.body,sourceDir:r,isDirectory:s},a=0;try{a=Ur(e).mtimeMs}catch(c){so.error({err:c},"skills operation failed")}this.entries.set(i.meta.name,{skill:i,filePath:e,loadedMtimeMs:a})}catch(o){so.error({err:o},"skills operation failed")}}list(){return[...this.entries.values()].map(e=>e.skill.meta)}get(e){let r=this.entries.get(e);if(r){if(r.filePath&&r.loadedMtimeMs>0)try{let s=Ur(r.filePath).mtimeMs;if(s>r.loadedMtimeMs){let o=rg(r.filePath,"utf-8"),n=ng(o);n&&(r.skill={meta:n.meta,body:n.body,sourceDir:r.skill.sourceDir,isDirectory:r.skill.isDirectory},r.loadedMtimeMs=s)}}catch(s){so.error({err:s},"skills operation failed")}return r.skill}}has(e){return this.entries.has(e)}};function sM(t){let e=k(ni(t),"mode");return e==="inline"||e==="fork"?e:k(ni(t),"context")==="fork"?"fork":"inline"}var oM=D.looseObject({name:D.string(),description:D.string().optional(),allowed_tools:D.array(D.string()).optional(),mode:D.enum(["inline","fork"]).optional(),model:D.string().optional(),fork_context:D.enum(["full","none","recent"]).optional()});function ng(t){if(!t.startsWith("---"))return null;let e=t.indexOf("---",3);if(e===-1)return null;let r=t.slice(3,e).trim(),s=t.slice(e+3).trim();try{let o=ft.load(r),n=Se(oM,o);return{meta:{name:n.name,description:n.description??"",mode:sM(o),model:n.model,forkContext:n.fork_context},body:s}}catch(o){return so.error({err:o},"skills operation failed"),null}}function nN(t,e){let r=t.list();if(r.length===0)return"";let o=[`## Available Skills
|
|
256
257
|
`,`Skills are installed at: ${Je(e,".swifty","skills")}`,`When creating new skills, always place them under this directory as <skill-name>/SKILL.md.
|
|
257
258
|
`,`Only Skill names and one-line descriptions are listed below. To activate a Skill on demand call the LoadSkill tool with {name: "<skill-name>"}. After activation the Skill's full SOP gets pinned to the environment context, and any tools the Skill declares get registered. Users can also invoke a Skill directly with /<name>.
|
|
258
259
|
`,`If the user pastes a Skill URL (skills.sh, github.com tree URL, or raw SKILL.md URL) and asks to install / add / get it, call the InstallSkill tool with {url: "<url>"} \u2014 the new Skill becomes available immediately afterwards.
|
|
259
260
|
`];for(let n of r){let i=n.description.length>200?n.description.slice(0,200)+"\u2026":n.description;o.push(`- /${n.name}: ${i}`)}return o.join(`
|
|
260
|
-
`)}function
|
|
261
|
+
`)}function ig(t,e,r){let s=t.body;return s.includes("$ARGUMENTS")?s=s.replaceAll("$ARGUMENTS",e):e&&(s+=`
|
|
261
262
|
|
|
262
|
-
User Request: ${e}`),r.activateSkill(t.meta.name,s),s}async function
|
|
263
|
+
User Request: ${e}`),r.activateSkill(t.meta.name,s),s}async function ag(t,e,r){let s=t.body;e&&(s+=`
|
|
263
264
|
|
|
264
265
|
ARGUMENTS: ${e}`);let o=t.meta.forkContext??"none";return o==="recent"?s=`Context from parent conversation:
|
|
265
266
|
${r.snapshotParentMessages(5)}
|
|
@@ -267,11 +268,11 @@ ${r.snapshotParentMessages(5)}
|
|
|
267
268
|
${s}`:o==="full"&&(s=`Context from parent conversation:
|
|
268
269
|
${r.snapshotParentMessages(100)}
|
|
269
270
|
|
|
270
|
-
${s}`),r.runSubagent(s)}var
|
|
271
|
+
${s}`),r.runSubagent(s)}var cg=class{constructor(e,r,s){this.catalog=e;this.host=r;this.forkHost=s}catalog;host;forkHost;name="LoadSkill";description="Activate a skill by name. Returns the full SOP body so you can follow its instructions.. Call this when the user's request matches one of the available Skills listed in the available-skills section. Pass the Skill name without a leading slash.";category="read";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{name:{type:"string",description:"Name of the skill to activate"}},required:["name"]}}}async execute(e,r){let s=k(r,"name"),o=this.catalog.get(s);if(!o){let i=this.catalog.list().map(a=>a.name).join(", ")||"(none)";return{output:`Skill '${s}' not found. Available skills: ${i}`,isError:!0}}if(o.meta.mode==="fork"&&this.forkHost)try{return{output:await ag(o,"",this.forkHost),isError:!1}}catch(i){return{output:`Skill '${s}' fork execution failed: ${U(i)}`,isError:!0}}let n=ig(o,"",this.host);return{output:`Skill '${s}' activated.
|
|
271
272
|
|
|
272
|
-
${n}`,isError:!1}}};var
|
|
273
|
+
${n}`,isError:!1}}};var nM=R({module:"tools"}),lg=class{name="EnterWorktree";description="Create and enter a git worktree for isolated work.";category="write";schema(){let e={type:"object",properties:{slug:{type:"string",description:"Short identifier for the worktree (branch name suffix)."}},required:["slug"]};return{name:this.name,description:this.description,input_schema:e}}async execute(e,r){let s=k(r,"slug");if(!s)return Promise.resolve({output:"Error: slug is required",isError:!0});if(!/^[a-zA-Z0-9_-]+$/.test(s))return Promise.resolve({output:"Error: slug must contain only alphanumeric, hyphen, underscore",isError:!0});try{let o=await Ws(s);return{output:`Worktree created at ${o.path}
|
|
273
274
|
Branch: ${o.branch}
|
|
274
|
-
Head: ${o.headCommit}`,isError:!1}}catch(o){return
|
|
275
|
+
Head: ${o.headCommit}`,isError:!1}}catch(o){return nM.error({err:o},"tool operation failed"),{output:`Error creating worktree: ${U(o)}`,isError:!0}}}};var iM=R({module:"tools"}),ug=class{name="ExitWorktree";description="Exit and optionally cleanup a git worktree";category="write";schema(){let e={type:"object",properties:{path:{type:"string",description:"Worktree path"},branch:{type:"string",description:"Worktree branch name"},git_root:{type:"string",description:"Git root directory"},head_commit:{type:"string",description:"Original HEAD commit for change detection"}},required:["path","branch","git_root"]};return{name:this.name,description:this.description,input_schema:e}}async execute(e,r){let s=k(r,"path"),o=k(r,"branch"),n=k(r,"git_root"),i=k(r,"head_commit");if(!s||!o||!n)return{output:"Error: path, branch and git_root are required",isError:!0};if(!(i?af(s,i):!1))try{return await nf(s,o,n),{output:`Worktree cleaned up (no changes): ${s}`,isError:!1}}catch(c){return iM.error({err:c},"tool operation failed"),{output:`Error cleaning up worktree: ${U(c)}`,isError:!0}}return{output:`Worktree has changes, kept at: ${s}
|
|
275
276
|
Branch: ${o}`,isError:!1}}};var Ql=class{commands=new Map;aliasMap=new Map;register(e){if(this.commands.has(e.name))throw new Error(`Command '${e.name}' already registered`);if(this.aliasMap.has(e.name))throw new Error(`Command name '${e.name}' collides with alias of '${this.aliasMap.get(e.name)??""}'`);for(let r of e.aliases){if(this.commands.has(r))throw new Error(`Alias '${r}' for '${e.name}' collides with existing command name`);if(this.aliasMap.has(r))throw new Error(`Alias '${r}' for '${e.name}' already registered by '${this.aliasMap.get(r)??""}'`)}this.commands.set(e.name,e);for(let r of e.aliases)this.aliasMap.set(r,e.name)}hasConflict(e){if(this.find(e.name))return!0;for(let r of e.aliases)if(this.find(r))return!0;return!1}find(e){return this.commands.get(e)??this.commands.get(this.aliasMap.get(e)??"")}complete(e){let r=e.toLowerCase();return[...this.commands.values()].filter(s=>s.name.toLowerCase().startsWith(r)||s.aliases.some(o=>o.toLowerCase().startsWith(r)))}listCommands(){return[...this.commands.values()].sort((e,r)=>e.name.localeCompare(r.name))}};function BN(t){if(!t.startsWith("/"))return null;let e=t.slice(1).trim(),r=e.indexOf(" "),s=r===-1?e:e.slice(0,r);return s.includes("/")?null:r===-1?{name:s,args:""}:{name:s,args:e.slice(r+1).trim()}}function QN(){let t=new Ql;return t.register({name:"help",aliases:["h","?"],type:"local",description:"Show available commands",handler:e=>{if(e.args){let o=t.find(e.args);if(!o)return`Unknown command: ${e.args}`;let n=`/${o.name} \u2014 ${o.description}
|
|
276
277
|
`;return o.aliases.length>0&&(n+=` Aliases: ${o.aliases.join(", ")}
|
|
277
278
|
`),n}let r=t.listCommands(),s=`Available commands:
|
|
@@ -284,39 +285,39 @@ Type /help <command> for details.`,s}}),t.register({name:"clear",aliases:[],type
|
|
|
284
285
|
`)}}),t.register({name:"session",aliases:[],type:"local",description:"Show session info",handler:()=>"Session is active. Use /resume to list past sessions."}),t.register({name:"plan",aliases:["p"],type:"local_ui",description:"Enter plan mode",handler:()=>"plan"}),t.register({name:"resume",aliases:["r"],type:"local_ui",description:"Resume a previous session",handler:()=>"resume"}),t.register({name:"quit",aliases:["exit","q"],type:"local_ui",description:"Exit Swifty",handler:()=>"quit"}),t.register({name:"memory",aliases:[],type:"local",description:"Show memory status",handler:()=>"memory"}),t.register({name:"skills",aliases:[],type:"local_ui",description:"List available skills",handler:()=>"skills"}),t.register({name:"worktree",aliases:["wt"],type:"local_ui",description:"Manage git worktrees",handler:()=>"worktree"}),t.register({name:"code-review",aliases:["cr"],type:"local",description:"Manage code review team (create, add, remove, list)",handler:e=>{let r=e.args.trim();return r?`code-review:${r}`:`Usage: /code-review <command> [args]
|
|
285
286
|
Commands: create, add <name>, remove <name>, list, status`}}),t.register({name:"review",aliases:[],type:"prompt",description:"Review the uncommitted code changes for bugs and improvements",handler:e=>"Review the current uncommitted changes. Run `git status` and `git diff` to see them, then report concrete findings (file:line) for correctness bugs, security issues, and obvious simplifications. Be specific and concise."+(e.args?`
|
|
286
287
|
|
|
287
|
-
Focus on: ${e.args}`:"")}),t.register({name:"rewind",aliases:[],type:"local_ui",description:"Rewind conversation to a previous checkpoint",handler:()=>"rewind"}),t.register({name:"mcp",aliases:[],type:"local",description:"Show MCP server connection status",handler:()=>"mcp"}),t.register({name:"sandbox",aliases:["sb"],type:"local_ui",description:"Toggle OS sandbox mode for command execution",handler:()=>"sandbox"}),t}import{readdirSync as
|
|
288
|
+
Focus on: ${e.args}`:"")}),t.register({name:"rewind",aliases:[],type:"local_ui",description:"Rewind conversation to a previous checkpoint",handler:()=>"rewind"}),t.register({name:"mcp",aliases:[],type:"local",description:"Show MCP server connection status",handler:()=>"mcp"}),t.register({name:"sandbox",aliases:["sb"],type:"local_ui",description:"Toggle OS sandbox mode for command execution",handler:()=>"sandbox"}),t}import{readdirSync as aM,readFileSync as cM,statSync as lM,existsSync as uM}from"fs";import{homedir as AM}from"os";import{join as _l}from"path";function xN(t){let e=new Map,r=[_l(AM(),".swifty","commands"),_l(t,".swifty","commands")];for(let s of r)if(uM(s))for(let o of Ag(s,s))e.set(o.name,o);return[...e.values()]}function Ag(t,e){let r;try{r=aM(e)}catch{return[]}let s=[];for(let o of r){let n=_l(e,o),i;try{i=lM(n)}catch{continue}if(i.isDirectory())s.push(...Ag(t,n));else if(o.endsWith(".md")){let a=mM(t,n);a&&s.push(a)}}return s}function dM(t,e){return e.slice(t.length+1).replace(/\.md$/,"").split(/[/\\]/).map(s=>s.toLowerCase().replace(/ /g,"-")).join(":")}var pM=D.object({description:D.string().optional(),"argument-hint":D.string().optional(),aliases:D.array(D.string()).optional()});function mM(t,e){let r;try{r=cM(e,"utf-8")}catch{return null}let s="",o="",n=[],i=r;if(r.startsWith("---")){let c=r.indexOf("---",3);if(c!==-1){let u=r.slice(3,c).trim();i=r.slice(c+3).trim();try{let l=ft.load(u),A=Se(pM,l);s=A.description??"",o=A["argument-hint"]??"",n=A.aliases??[]}catch{}}}let a=dM(t,e);return a?{name:a,aliases:Array.isArray(n)?n:[],type:"prompt",description:s||(o?`custom command (args: ${o})`:"custom command"),handler:c=>fM(i,c.args)}:null}function fM(t,e){return t.includes("$ARGUMENTS")?t.replaceAll("$ARGUMENTS",e):e?`${t}
|
|
288
289
|
|
|
289
|
-
${e}`:t}import{createHash as
|
|
290
|
+
${e}`:t}import{createHash as gM}from"crypto";import{existsSync as qn,mkdirSync as hM,readFileSync as Gn,unlinkSync as EM,writeFileSync as Hn}from"fs";import{join as Yn,resolve as yM}from"path";var Fr=R({module:"file-history"}),dg=100,pg=60;function mg(t,e){return`${gM("sha256").update(t).digest("hex").slice(0,16)}@v${String(e)}`}var fg=class{sessionDir;trackedFiles=new Map;snapshots=[];constructor(e,r){this.sessionDir=Yn(e,".swifty","file-history",r),hM(this.sessionDir,{recursive:!0})}trackEdit(e){let r=yM(e),o=(this.trackedFiles.get(r)??0)+1;if(qn(r))try{let n=Gn(r),i=mg(r,o);Hn(Yn(this.sessionDir,i),n)}catch(n){Fr.error({err:n},"file-history operation failed")}this.trackedFiles.set(r,o)}makeSnapshot(e,r){let s=r;s.length>pg&&(s=s.slice(0,pg)+"...");let o={};for(let[n,i]of this.trackedFiles){let a=mg(n,i),c=Yn(this.sessionDir,a);if(!qn(c)&&qn(n))try{Hn(c,Gn(n))}catch(u){Fr.error({err:u},"file-history operation failed")}o[n]={backupPath:c,version:i,time:new Date().toISOString()}}this.snapshots.push({messageIndex:e,userText:s,backups:o,timestamp:new Date().toISOString()}),this.snapshots.length>dg&&(this.snapshots=this.snapshots.slice(this.snapshots.length-dg))}rewind(e){if(e<0||e>=this.snapshots.length)throw new Error(`Invalid snapshot index: ${String(e)}`);let r=this.snapshots[e],s=[];for(let[o,n]of Object.entries(r.backups)){let i=null;try{i=Gn(n.backupPath)}catch(l){if(Fr.error({err:l},"file-history operation failed"),qn(o))try{EM(o)}catch(A){Fr.error({err:A},"file-history operation failed")}continue}let a=null;try{a=Gn(o)}catch(l){Fr.error({err:l},"file-history operation failed")}let c=i.toString(),u=a?.toString();if(c!==u)try{Hn(o,i),s.push(o)}catch(l){Fr.error({err:l},"file-history operation failed")}}this.snapshots=this.snapshots.slice(0,e+1);for(let[o,n]of Object.entries(r.backups))this.trackedFiles.set(o,n.version);return s}getSnapshots(){return[...this.snapshots]}hasSnapshots(){return this.snapshots.length>0}save(){let e=Yn(this.sessionDir,"snapshots.json");Hn(e,JSON.stringify(this.snapshots,null,2),"utf-8")}};import{exec as wM}from"child_process";var Or=R({module:"hooks"});function CM(t,e){return new Promise((r,s)=>{wM(t,{shell:"bash",encoding:"utf-8",timeout:3e4,env:e.env,maxBuffer:10*1024*1024},(o,n)=>{o?s(o):r(n)})})}var gg=class{hooks;firedOnce=new Set;notifications=[];agentRunner;constructor(e){this.hooks=e}recordNotification(e){e.trim()&&this.notifications.push(e)}drainNotifications(){let e=this.notifications;return this.notifications=[],e}async fire(e,r){let s=[];for(let o of this.hooks)if(o.event===e){if(o.once){let n=o.id??`${o.event}-${o.action.type}`;if(this.firedOnce.has(n))continue;this.firedOnce.add(n)}if(!(o.condition&&!IM(o.condition,r))){if(o.async){this.executeAction(o,r).then(n=>{this.recordNotification(n.output)}).catch(n=>{this.recordNotification(`Async hook error: ${U(n)}`)}),s.push({output:"(async)",success:!0,reject:!1});continue}try{let n=await this.executeAction(o,r);if(s.push(n),n.reject&&e==="pre_tool_use")break}catch(n){Or.error({err:n},"hooks operation failed");let i=o.on_error??"ignore";if(i==="fail"){let a=`Hook error: ${U(n)}`;s.push({output:a,success:!1,reject:!1})}else if(i==="reject"){let a=`Hook error (rejecting): ${U(n)}`;s.push({output:a,success:!1,reject:!0})}}}}return s}async firePreToolHooks(e,r){let s={event:"pre_tool_use",toolName:e,args:r,filePath:k(r,"file_path",k(r,"path",""))},o=await this.fire("pre_tool_use",s);for(let n of o)if(n.reject)return{rejected:!0,reason:n.output};return{rejected:!1,reason:""}}async executeAction(e,r){switch(e.action.type){case"command":{let s=e.action.command??"";try{return{output:(await CM(s,{env:{...process.env,SWIFTY_EVENT:r.event,SWIFTY_TOOL:r.toolName??"",SWIFTY_FILE_PATH:r.filePath??""}})).trim(),success:!0,reject:e.reject??!1}}catch(o){throw Or.error({err:o},"hooks operation failed"),o}}case"prompt":return{output:e.action.prompt??"",success:!0,reject:!1};case"http":{let s=e.action.url??"",o=e.action.method??"POST";try{let n=await fetch(s,{method:o,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});return{output:await n.text(),success:n.ok,reject:e.reject??!1}}catch(n){throw Or.error({err:n},"hooks operation failed"),n}}case"agent":{if(!this.agentRunner)return{output:"agent-type hook configured but no AgentRunner registered",success:!1,reject:e.reject??!1};let s=e.action.prompt??e.action.command??"";try{return{output:await this.agentRunner(s,r),success:!0,reject:e.reject??!1}}catch(o){return Or.error({err:o},"hooks operation failed"),{output:U(o),success:!1,reject:e.reject??!1}}}default:return{output:"",success:!0,reject:!1}}}};function IM(t,e){let r=t.split(/\s*(&&|\|\|)\s*/),s=Sl(r[0],e);for(let o=1;o<r.length;o+=2){let n=r[o],i=Sl(r[o+1],e);n==="&&"?s=s&&i:n==="||"&&(s=s||i)}return s}function Sl(t,e){let r=t.trim();if(r.startsWith("!"))return!Sl(r.slice(1),e);let s=/^(\w+)\s*==\s*"([^"]*)"$/.exec(r);if(s)return Jn(s[1],e)===s[2];let o=/^(\w+)\s*!=\s*"([^"]*)"$/.exec(r);if(o)return Jn(o[1],e)!==o[2];let n=/^(\w+)\s*=~\s*"([^"]*)"$/.exec(r);if(n){let a=Jn(n[1],e);try{return new RegExp(n[2]).test(a)}catch(c){return Or.error({err:c},"hooks operation failed"),!1}}let i=/^(\w+)\s*=\*\s*"([^"]*)"$/.exec(r);if(i){let a=Jn(i[1],e),c=i[2].replace(/\*\*/g,".*").replace(/\*/g,"[^/]*").replace(/\?/g,".");try{return new RegExp(`^${c}$`).test(a)}catch(u){return Or.error({err:u},"hooks operation failed"),!1}}return!1}function Jn(t,e){switch(t){case"tool":return e.toolName??"";case"event":return e.event;case"file_path":return e.filePath??"";case"message":return e.message??"";default:return k(e.args??{},t,"")}}function ON(t){let e=new Set(["session_start","session_end","turn_start","turn_end","pre_send","post_receive","pre_tool_use","post_tool_use","shutdown"]),r=new Set(["command","prompt","http","agent"]),s=[];for(let o=0;o<t.length;o++){let n=t[o],i=n.id?`hook[${String(o)}] (id="${n.id}")`:`hook[${String(o)}]`;if(n.event?e.has(n.event)||s.push(`${i}: invalid event '${n.event}'`):s.push(`${i}: event is required`),!n.action.type)s.push(`${i}: action.type is required`);else if(!r.has(n.action.type))s.push(`${i}: invalid action type '${n.action.type}'`);else switch(n.action.type){case"command":n.action.command?.trim()||s.push(`${i}: action.command must be non-empty for type "command"`);break;case"prompt":n.action.prompt?.trim()||s.push(`${i}: action.prompt must be non-empty for type "prompt"`);break;case"http":n.action.url?.trim()||s.push(`${i}: action.url must be non-empty for type "http"`);break;case"agent":!n.action.prompt?.trim()&&!n.action.command?.trim()&&s.push(`${i}: action.prompt (or action.command) must be non-empty for type "agent"`);break}n.reject&&n.async&&s.push(`${i}: reject and async are mutually exclusive`)}return s.length>0?new Error(s.join("; ")):null}import{readFileSync as Wn,readdirSync as Vn,unlinkSync as BM,existsSync as Kn,mkdirSync as QM,writeFileSync as _M,statSync as SM}from"fs";import{homedir as kM}from"os";import{join as er,relative as MM,basename as vM}from"path";function hg(t){return Math.max(0,Math.floor((Date.now()-t)/864e5))}function Eg(t){let e=hg(t);return e===0?"today":e===1?"yesterday":`${String(e)} days ago`}function yg(t){let e=hg(t);return e<=1?"":`This memory is ${String(e)} days old. Memories are point-in-time observations, not live state \u2014 claims about code behavior or file:line citations may be outdated. Verify against current code before asserting as fact.`}var lt=R({module:"memory"}),Lr=200,no=25e3,oo="MEMORY.md";function wg(t){let e=Buffer.from(t,"utf-8");if(e.length<=no)return t;let r=e.lastIndexOf(10,no-1);if(r>0)return e.subarray(0,r).toString("utf-8");let s=no;for(;s>0&&(e[s]&192)===128;)s--;return e.subarray(0,s).toString("utf-8")}function kl(t){return t<1024?`${String(t)}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var bM=y.object({selected_memories:y.array(y.string())}),xM=`You are selecting memories that will be useful to Swifty as it processes a user's query. You will be given the user's query and a list of available memory files with their filenames and descriptions.
|
|
290
291
|
|
|
291
292
|
Return a list of filenames for the memories that will clearly be useful to Swifty as it processes the user's query (up to 5). Only include memories that you are certain will be helpful based on their name and description.
|
|
292
293
|
- If you are unsure if a memory will be useful in processing the user's query, then do not include it in your list. Be selective and discerning.
|
|
293
294
|
- If there are no memories in the list that would clearly be useful, feel free to return an empty list.
|
|
294
295
|
- If a list of recently-used tools is provided, do not select memories that are usage reference or API documentation for those tools (Swifty is already exercising them). DO still select memories containing warnings, gotchas, or known issues about those tools \u2014 active use is exactly when those matter.
|
|
295
296
|
|
|
296
|
-
Respond with valid JSON only, no markdown, in this exact shape: {"selected_memories": ["filename1.md", "filename2.md"]}`,Zn=class{userDir;projectDir;constructor(e){this.userDir=er(
|
|
297
|
-
`),n=Buffer.byteLength(o,"utf-8"),i=s>
|
|
298
|
-
${o}`;let c=
|
|
299
|
-
`)),u;return a&&!i?u=`${
|
|
297
|
+
Respond with valid JSON only, no markdown, in this exact shape: {"selected_memories": ["filename1.md", "filename2.md"]}`,Zn=class{userDir;projectDir;constructor(e){this.userDir=er(kM(),".swifty","memory"),this.projectDir=er(e,".swifty","memory")}loadAll(){let e=[];for(let r of[this.userDir,this.projectDir]){if(!Kn(r))continue;let s=Vn(r).filter(o=>o.endsWith(".md")&&o!==oo);for(let o of s){let n=er(r,o);try{let i=Wn(n,"utf-8"),a=Ml(i);a&&e.push({path:n,name:a.name??o.replace(".md",""),description:a.description??"",type:a.type??"reference",content:a.body})}catch(i){lt.error({err:i},"memory operation failed");continue}}}return this.rebuildIndex(),e}getMemories(){return this.loadAll()}buildSystemReminder(){let e=this.loadAll();if(e.length===0)return"";let r=e.map(l=>`- [${l.name}] (${l.type}): ${l.description}`),s=r.length,o=r.join(`
|
|
298
|
+
`),n=Buffer.byteLength(o,"utf-8"),i=s>Lr,a=n>no;if(!i&&!a)return`Active memories:
|
|
299
|
+
${o}`;let c=wg(r.slice(0,Lr).join(`
|
|
300
|
+
`)),u;return a&&!i?u=`${kl(n)} (limit: ${kl(no)}) \u2014 index entries are too long`:i&&!a?u=`${String(s)} lines (limit: ${String(Lr)})`:u=`${String(s)} lines and ${kl(n)}`,`Active memories:
|
|
300
301
|
${c}
|
|
301
302
|
|
|
302
|
-
> WARNING: ${oo} is ${u}. Only part of it was loaded. Keep index entries to one line under ~200 chars; move detail into topic files.`}clear(){for(let e of[this.userDir,this.projectDir]){if(!Kn(e))continue;let r=Vn(e).filter(s=>s.endsWith(".md"));for(let s of r)try{
|
|
303
|
-
`));
|
|
304
|
-
`,"utf-8")}async findRelevantMemories(e,r,s=[],o=new Set){let n=[];for(let[f,h]of[[this.userDir,"user"],[this.projectDir,"project"]]){let
|
|
303
|
+
> WARNING: ${oo} is ${u}. Only part of it was loaded. Keep index entries to one line under ~200 chars; move detail into topic files.`}clear(){for(let e of[this.userDir,this.projectDir]){if(!Kn(e))continue;let r=Vn(e).filter(s=>s.endsWith(".md"));for(let s of r)try{BM(er(e,s))}catch(o){lt.error({err:o},"memory operation failed");continue}}}rebuildIndex(){let e=[];for(let o of[this.userDir,this.projectDir]){if(!Kn(o))continue;let n=Vn(o).filter(i=>i.endsWith(".md")&&i!==oo);try{for(let i of n){let a=er(o,i);try{let c=Wn(a,"utf-8"),u=Ml(c);if(!u)continue;let l=u.name??i.replace(".md",""),A=u.description??"",p=MM(this.projectDir,a)||i;e.push({name:l,relPath:p,description:A})}catch(c){lt.error({err:c},"memory operation failed");continue}}}catch(i){lt.error({err:i},"memory operation failed");continue}}e.sort((o,n)=>o.name.localeCompare(n.name,void 0,{sensitivity:"base"}));let r=[];for(let o of e)o.description?r.push(`- [${o.name}](${o.relPath}) \u2014 ${o.description}`):r.push(`- [${o.name}](${o.relPath})`);let s=wg(r.slice(0,Lr).join(`
|
|
304
|
+
`));QM(this.projectDir,{recursive:!0}),_M(er(this.projectDir,oo),s+`
|
|
305
|
+
`,"utf-8")}async findRelevantMemories(e,r,s=[],o=new Set){let n=[];for(let[f,h]of[[this.userDir,"user"],[this.projectDir,"project"]]){let w=RM(f,h);n.push(...w)}let i=n.filter(f=>!o.has(f.filePath));if(i.length===0)return[];let a=DM(i),c="";s.length>0&&(c=`
|
|
305
306
|
|
|
306
307
|
Recently used tools: `+s.join(", "));let u=`Query: ${e}
|
|
307
308
|
|
|
308
309
|
Available memories:
|
|
309
|
-
${a}${c}`,l="";try{let f=new tr;f.addUserMessage(
|
|
310
|
+
${a}${c}`,l="";try{let f=new tr;f.addUserMessage(xM+`
|
|
310
311
|
|
|
311
|
-
`+u);let h=r.stream(f,[]);for await(let
|
|
312
|
-
`];for(let s of e){let o;try{o=Wn(s.path,"utf-8")}catch{continue}let n=
|
|
313
|
-
`);let i=
|
|
312
|
+
`+u);let h=r.stream(f,[]);for await(let w of h)w.type==="text_delta"&&(l+=w.text)}catch(f){return lt.error({err:f},"memory operation failed"),[]}let A=TM(l);if(!A)return[];let p;try{let f=JSON.parse(A);p=Se(bM,f)}catch(f){return lt.error({err:f},"memory operation failed"),[]}let m=new Map;for(let f of i)m.set(f.filePath,f),m.has(f.filename)||m.set(f.filename,f);let g=[];for(let f of p.selected_memories){let h=m.get(f);h&&g.push({path:h.filePath,mtimeMs:h.mtimeMs})}return g}renderReminder(e){if(e.length===0)return"";let r=[`The following relevant memories from prior conversations may help:
|
|
313
|
+
`];for(let s of e){let o;try{o=Wn(s.path,"utf-8")}catch{continue}let n=vM(s.path);r.push(`## Memory: ${n} (saved ${Eg(s.mtimeMs)})
|
|
314
|
+
`);let i=yg(s.mtimeMs);i&&r.push(i+`
|
|
314
315
|
`),r.push(o+`
|
|
315
316
|
|
|
316
317
|
---
|
|
317
318
|
`)}return r.join(`
|
|
318
|
-
`)}};function
|
|
319
|
-
`)}function
|
|
319
|
+
`)}};function RM(t,e){if(!Kn(t))return[];let r;try{r=Vn(t).filter(o=>o.endsWith(".md")&&o!==oo)}catch(o){return lt.error({err:o},"memory operation failed"),[]}let s=[];for(let o of r){let n=er(t,o);try{let i=SM(n);if(!i.isFile())continue;let a=Wn(n,"utf-8"),c=Ml(a);if(!c)continue;s.push({filename:o,filePath:n,scope:e,mtimeMs:i.mtimeMs,description:c.description??"",type:c.type??""})}catch(i){lt.error({err:i},"memory operation failed");continue}}return s.sort((o,n)=>n.mtimeMs-o.mtimeMs),s.length>Lr&&(s.length=Lr),s}function DM(t){if(t.length===0)return"";let e=[];for(let r of t){let s=r.scope?`[${r.scope}-scope] `:"",o=r.type?`[${r.type}] `:"",n=new Date(r.mtimeMs).toISOString(),i=r.filePath||r.filename;r.description?e.push(`- ${s}${o}${i} (${n}): ${r.description}`):e.push(`- ${s}${o}${i} (${n})`)}return e.join(`
|
|
320
|
+
`)}function TM(t){let e=t.trim();if(e.startsWith("{"))return e;let r=e.indexOf("{");if(r<0)return"";let s=e.lastIndexOf("}");return s<r?"":e.slice(r,s+1)}var $M=y.looseObject({name:y.string().optional(),description:y.string().optional(),type:y.string().optional(),metadata:y.looseObject({type:y.string().optional()}).optional()});function Ml(t){if(!t.startsWith("---"))return{body:t};let e=t.indexOf("---",3);if(e===-1)return{body:t};let r=t.slice(3,e).trim(),s=t.slice(e+3).trim();try{let o=ft.load(r),n=Se($M,o),i=n.type,a=n.metadata?.type;return{name:n.name,description:n.description,type:i??a,body:s}}catch(o){return lt.error({err:o},"memory operation failed"),{body:t}}}import{readdirSync as PM,readFileSync as jM,existsSync as NM,mkdirSync as zM,writeFileSync as UM}from"fs";import{homedir as Xn}from"os";import{join as ut,basename as Cg}from"path";var Ig=class{client;workDir;inProgress=!1;pendingContext=null;turnsSinceLastExtraction=0;lastMemoryMessageIdx=0;constructor(e,r){this.client=e,this.workDir=r}async extract(e){return this.inProgress?(this.pendingContext=e,[]):this.runExtraction(e,!1)}async runExtraction(e,r){if(!r&&(this.turnsSinceLastExtraction++,this.turnsSinceLastExtraction<1))return[];this.turnsSinceLastExtraction=0,this.inProgress=!0;let s=[];try{s=await this.doExtract(e)}finally{this.inProgress=!1;let o=this.pendingContext;if(this.pendingContext=null,o!==null){let n=await this.runExtraction(o,!0);s=[...s,...n]}}return s}scanExistingMemories(){let e=[ut(this.workDir,".swifty","memory"),ut(Xn(),".swifty","memory")],r=[];for(let s of e)if(NM(s))try{let o=PM(s).filter(n=>n.endsWith(".md")&&n!=="MEMORY.md");for(let n of o)try{let i=jM(ut(s,n),"utf-8"),a=/type:\s*(.+)/.exec(i),c=/description:\s*(.+)/.exec(i),u=a?.[1]?.trim()??"reference",l=c?.[1]?.trim()??"";r.push(`- [${u}] ${n}: ${l}`)}catch{}}catch{}return r.length>0?r.join(`
|
|
320
321
|
`):""}buildExtractionPrompt(e){let r=this.scanExistingMemories(),s=ut(this.workDir,".swifty","memory"),o=ut(Xn(),".swifty","memory"),n="";return r&&(n=`
|
|
321
322
|
|
|
322
323
|
## Existing memory files
|
|
@@ -324,25 +325,25 @@ ${a}${c}`,l="";try{let f=new tr;f.addUserMessage(xv+`
|
|
|
324
325
|
${r}
|
|
325
326
|
|
|
326
327
|
Check this list before writing \u2014 update an existing file rather than creating a duplicate.`),["You are now acting as the memory extraction subagent. Analyze the conversation below and use the tools to update persistent memory files.","","Available tools: ReadFile, WriteFile, EditFile, Glob, Grep. EditFile requires a prior ReadFile of the same file.","","You have a limited turn budget. The efficient strategy is: turn 1 \u2014 issue all ReadFile calls in parallel for every file you might update; turn 2 \u2014 issue all WriteFile/EditFile calls in parallel.","",`You MUST only use content from the conversation to update memories. Do not investigate source code.${n}`,"","## Memory storage paths","",`- \`user\` and \`feedback\` type \u2192 write to \`${o}/\` (user-level; follows the human across projects)`,`- \`project\` and \`reference\` type \u2192 write to \`${s}/\` (project-level; lives with this repo)`,"","Pick the type first, then write the memory file (and its MEMORY.md pointer) into the matching directory.","","## Memory types","","- **user**: Information about the user's role, goals, preferences, knowledge","- **feedback**: Guidance the user gave about how to approach work (corrections AND confirmations)","- **project**: Ongoing work, goals, decisions, deadlines within the project","- **reference**: Pointers to external resources (URLs, docs, tools)","","## What NOT to save","","- Code patterns, architecture, file paths \u2014 derivable from reading the project","- Git history \u2014 use git log/blame","- Debugging solutions \u2014 the fix is in the code","- Anything in CLAUDE.md / SWIFTY.md files","- Ephemeral task details, current conversation context","","## How to save memories","","**Step 1** \u2014 write the memory to its own file using this frontmatter format:","","```markdown","---","name: {{short-kebab-case-slug}}","description: {{one-line summary}}","metadata:"," type: {{user, feedback, project, reference}}","---","","{{memory content}}","```","","**Step 2** \u2014 add a pointer to MEMORY.md in the SAME directory. Each entry one line: `- [Title](file.md) \u2014 one-line hook`","","- Do not write duplicate memories. Check existing files first.","- If no memories are worth saving, do nothing.","","## Conversation to analyze","",e].join(`
|
|
327
|
-
`)}async doExtract(e){let r=this.buildExtractionPrompt(e),s=new mo;s.register(new zn),s.register(new
|
|
328
|
+
`)}async doExtract(e){let r=this.buildExtractionPrompt(e),s=new mo;s.register(new zn),s.register(new On),s.register(new Nn),s.register(new Un),s.register(new Fn);let o=new rr(this.workDir,"bypassPermissions");o.allowExtraRoot(ut(Xn(),".swifty","memory"));let n=new tr;n.addUserMessage(r);let i=new po({client:this.client,registry:s,checker:o,conversation:n,workDir:this.workDir,maxIterations:5}),a="";for await(let A of i.run())A.type==="stream_text"&&(a+=A.text);let u=this.extractWrittenPaths(n.getMessages()).filter(A=>Cg(A)!=="MEMORY.md"),l;return u.length>0?l=u.map(A=>Cg(A)):l=this.persistTextMemories(a),l.length>0&&new Zn(this.workDir).rebuildIndex(),l}extractWrittenPaths(e){let r=[];for(let s of e){if(s.role!=="assistant"||typeof s.content!="string")continue;let o=s.content.matchAll(/"file_path"\s*:\s*"([^"]+)"/g);for(let n of o)n[1]&&(n[1].includes("memory")||n[1].endsWith(".md"))&&r.push(n[1])}return[...new Set(r)]}persistTextMemories(e){let r=this.parseTextMemoryBlocks(e);if(r.length===0)return[];let s=[];for(let o of r){let n=this.dirForMemoryType(o.type);zM(n,{recursive:!0}),UM(ut(n,`${o.name}.md`),this.formatMemoryFile(o),"utf-8"),s.push(o.name)}return s}parseTextMemoryBlocks(e){let r=e.trim();if(r===""||r==="NONE")return[];let s=[],o=r.split(/^---\s*$/m);for(let n of o){let i=this.parseTextMemoryBlock(n);i&&s.push(i)}return s}parseTextMemoryBlock(e){let r=e.split(`
|
|
328
329
|
`),s={name:"",type:"",description:"",body:""},o=[],n=!1;for(let i of r){let a=/^MEMORY_NAME:\s*(.*)$/i.exec(i),c=/^MEMORY_TYPE:\s*(.*)$/i.exec(i),u=/^MEMORY_DESC:\s*(.*)$/i.exec(i),l=/^MEMORY_BODY:\s?(.*)$/i.exec(i);a?(s.name=a[1].trim(),n=!1):c?(s.type=c[1].trim(),n=!1):u?(s.description=u[1].trim(),n=!1):l?(s.body=l[1],n=!0):n&&o.push(i)}return s.body&&(s.body=[s.body,...o].join(`
|
|
329
330
|
`).replace(/\s+$/,"")),s.name?(s.type||(s.type="reference"),s):null}dirForMemoryType(e){let r=e.toLowerCase();return r==="user"||r==="feedback"?ut(Xn(),".swifty","memory"):ut(this.workDir,".swifty","memory")}formatMemoryFile(e){return["---",`name: ${e.name}`,`description: ${e.description}`,`type: ${e.type}`,"---","",e.body,""].join(`
|
|
330
|
-
`)}};import{readFileSync as
|
|
331
|
+
`)}};import{readFileSync as Bg,existsSync as Qg}from"fs";import{homedir as _g}from"os";import{join as At,dirname as ei,resolve as vl,isAbsolute as FM,relative as OM}from"path";var dt=R({module:"memory"}),LM=5;function Ez(t){let e=qM(t);if(e.length===0)return"";let r=[];for(let s of e){let o=s.path;try{let n=OM(t,s.path);n.startsWith("..")||(o=n)}catch(n){dt.error({err:n},"memory operation failed")}r.push(`Contents of ${o}:
|
|
331
332
|
|
|
332
333
|
${s.content.replace(/\n+$/,"")}`)}return r.join(`
|
|
333
334
|
|
|
334
335
|
---
|
|
335
336
|
|
|
336
|
-
`)}function
|
|
337
|
-
`),n=[],i=!1;for(let a of o){let c=a.trim();if(c.startsWith("```")){i=!i,n.push(a);continue}if(!i){let u=
|
|
338
|
-
`)}function
|
|
339
|
-
`),isError:!1})}},
|
|
337
|
+
`)}function qM(t){let e=[],r=new Set;try{let o=_g();qr(e,r,At(o,".swifty","SWIFTY.md")),qr(e,r,At(o,".swifty","AGENTS.md"))}catch(o){dt.error({err:o},"memory operation failed")}let s=YM(t);for(let o of s)qr(e,r,At(o,"SWIFTY.md")),qr(e,r,At(o,"AGENTS.md")),qr(e,r,At(o,".swifty","SWIFTY.md"));return qr(e,r,At(t,"SWIFTY.local.md")),e}function qr(t,e,r){let s;try{s=vl(r)}catch(i){dt.error({err:i},"memory operation failed");return}if(e.has(s)||!Qg(s))return;let o;try{o=Bg(s,"utf-8")}catch(i){dt.error({err:i},"memory operation failed");return}e.add(s);let n=Sg(o,ei(s),e,0);t.push({path:s,content:n})}function Sg(t,e,r,s){if(s>LM)return t;let o=t.split(`
|
|
338
|
+
`),n=[],i=!1;for(let a of o){let c=a.trim();if(c.startsWith("```")){i=!i,n.push(a);continue}if(!i){let u=GM(c);if(u){let l=HM(u,e);if(l){let A;try{A=vl(l)}catch(p){dt.error({err:p},"memory operation failed"),n.push(a);continue}if(!r.has(A))try{let p=Bg(A,"utf-8");r.add(A),n.push(`<!-- included from ${u} -->`),n.push(Sg(p,ei(A),r,s+1));continue}catch(p){dt.error({err:p},"memory operation failed")}}}}n.push(a)}return n.join(`
|
|
339
|
+
`)}function GM(t){if(!t.startsWith("@")||t.startsWith("@@"))return"";let e=t.slice(1);return!e||/[\s\t]/.test(e)?"":e.startsWith("./")||e.startsWith("../")||e.startsWith("~/")||e.startsWith("/")?e:""}function HM(t,e){if(t.startsWith("~/"))try{return At(_g(),t.slice(2))}catch(r){return dt.error({err:r},"memory operation failed"),""}return FM(t)?t:At(e,t)}function YM(t){let e;try{e=vl(t)}catch(n){return dt.error({err:n},"memory operation failed"),[t]}let r=JM(e);if(!r)return[e];let s=[],o=e;for(;s.unshift(o),o!==r;){let n=ei(o);if(n===o)break;o=n}return s}function JM(t){let e=t;for(;;){try{let s=At(e,".git");if(Qg(s))return e}catch(s){dt.error({err:s},"memory operation failed")}let r=ei(e);if(r===e)return"";e=r}}import{readFileSync as WM,writeFileSync as VM,mkdirSync as KM,existsSync as ZM}from"fs";import{join as XM,dirname as ev}from"path";var tv=R({module:"todo"}),rv=y.enum(["pending","in_progress","completed"]),sv=y.object({id:y.string(),subject:y.string(),description:y.string(),status:rv,owner:y.string().optional(),activeForm:y.string().optional(),blocks:y.array(y.string()),blockedBy:y.array(y.string()),metadata:y.record(y.string(),y.unknown())}),kg=class{filePath;constructor(e,r){this.filePath=XM(e,".swifty","tasks",`${r}.json`)}load(){if(!ZM(this.filePath))return[];try{let e=WM(this.filePath,"utf-8"),r=JSON.parse(e);return Se(y.array(sv),r)}catch(e){return tv.error({err:e},"todo operation failed"),[]}}save(e){KM(ev(this.filePath),{recursive:!0}),VM(this.filePath,JSON.stringify(e,null,2),"utf-8")}};var Mg=class{tasks=new Map;nextId=1;store;constructor(e){e&&this.useStore(e)}useStore(e){this.store=e,this.tasks.clear();let r=0;for(let s of e.load()){this.tasks.set(s.id,s);let o=parseInt(s.id,10);!Number.isNaN(o)&&o>r&&(r=o)}this.nextId=r+1}persist(){this.store?.save([...this.tasks.values()])}create(e,r,s){let o={id:String(this.nextId++),subject:e,description:r,status:"pending",activeForm:s,blocks:[],blockedBy:[],metadata:{}};return this.tasks.set(o.id,o),this.persist(),o}get(e){return this.tasks.get(e)}list(){return[...this.tasks.values()]}update(e,r){let s=this.tasks.get(e);if(s)return s={...s,...r},this.tasks.set(e,s),this.persist(),s}delete(e){let r=this.tasks.delete(e);return r&&this.persist(),r}addBlocks(e,r){let s=this.tasks.get(e);if(s){for(let o of r){s.blocks.includes(o)||s.blocks.push(o);let n=this.tasks.get(o);n&&!n.blockedBy.includes(e)&&n.blockedBy.push(e)}this.persist()}}addBlockedBy(e,r){let s=this.tasks.get(e);if(s){for(let o of r){s.blockedBy.includes(o)||s.blockedBy.push(o);let n=this.tasks.get(o);n&&!n.blocks.includes(e)&&n.blocks.push(e)}this.persist()}}};var vg=class{name="TaskCreate";description="Create a new task to track work.";category="read";list;constructor(e){this.list=e}schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{subject:{type:"string",description:"Brief task title"},description:{type:"string",description:"What needs to be done"},activeForm:{type:"string",description:"Present continuous form for spinner"}},required:["subject","description"]}}}execute(e,r){let s=k(r,"subject"),o=k(r,"description"),n=k(r,"activeForm")||void 0;if(!s)return Promise.resolve({output:"Error: subject is required",isError:!0});let i=this.list.create(s,o,n);return Promise.resolve({output:`Task #${i.id} created successfully: ${i.subject}`,isError:!1})}},bg=class{name="TaskGet";description="Get a task by its ID.";category="read";list;constructor(e){this.list=e}schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{taskId:{type:"string",description:"Task ID"}},required:["taskId"]}}}execute(e,r){let s=k(r,"taskId"),o=this.list.get(s);return o?Promise.resolve({output:JSON.stringify(o,null,2),isError:!1}):Promise.resolve({output:"Task not found",isError:!0})}},xg=class{name="TaskList";description="List all tasks.";category="read";list;constructor(e){this.list=e}schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{}}}}execute(){let e=this.list.list();if(e.length===0)return Promise.resolve({output:"No tasks found",isError:!1});let r=e.map(s=>`#${s.id}. [${s.status}] ${s.subject}${s.owner?` (${s.owner})`:""}`);return Promise.resolve({output:r.join(`
|
|
340
|
+
`),isError:!1})}},Rg=class{name="TaskUpdate";description="Update a task's status, subject, or other fields.";category="read";list;constructor(e){this.list=e}schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{taskId:{type:"string",description:"Task ID"},status:{type:"string",description:"New status: pending, in_progress, completed, deleted"},subject:{type:"string",description:"New subject"},description:{type:"string",description:"New description"},owner:{type:"string",description:"New owner"},addBlocks:{type:"array",items:{type:"string"},description:"Tasks this one blocks"},addBlockedBy:{type:"array",items:{type:"string"},description:"Tasks blocking this one"}},required:["taskId"]}}}async execute(e,r){let s=await Rl(ov,r);if(!s.success)return{output:U(s.error),isError:!0};let{taskId:o,status:n,subject:i,description:a,owner:c,addBlocks:u,addBlockedBy:l}=s.data;if(!o)return Promise.resolve({output:"Error: taskId is required",isError:!0});if(n==="deleted")return this.list.delete(o),Promise.resolve({output:`Task #${o} deleted`,isError:!1});let A={};return n&&(A.status=n),i&&(A.subject=i),a&&(A.description=a),c&&(A.owner=c),this.list.update(o,A)?(u&&this.list.addBlocks(o,u),l&&this.list.addBlockedBy(o,l),{output:`Updated task #${o} status`,isError:!1}):{output:"Task not found",isError:!0}}},ov=y.object({taskId:y.string(),subject:y.string().optional(),description:y.string().optional(),status:y.enum(["pending","in_progress","completed","deleted"]).optional(),owner:y.string().optional(),addBlocks:y.array(y.string()).optional(),addBlockedBy:y.array(y.string()).optional()});var nv=D.object({label:D.string(),description:D.string().optional()}),iv=D.object({question:D.string(),header:D.string(),options:D.array(nv),multiSelect:D.boolean()}),Dg=class{constructor(e){this.ask=e}ask;name="AskUserQuestion";description=`
|
|
340
341
|
Ask the user 1 to 4 single-choice or multiple-choices questions and wait for their answers. Each question needs 1 to 4 options; an "Other" option for custom input is added automatically.
|
|
341
342
|
Set "multiSelect: true" when choices are not mutually exclusive (single-choice), set "multiSelect: false" otherwise (multiple-choices).
|
|
342
|
-
`;category="read";schema(){let e={type:"object",properties:{questions:{type:"array",description:"question",minItems:1,maxItems:4,items:{type:"object",properties:{question:{type:"string",description:"The question to ask"},header:{type:"string",description:"Short label/category (<=12 chars)"},options:{type:"array",description:"options",minItems:2,maxItems:4,items:{type:"object",properties:{label:{type:"string",description:"label"},description:{type:"string",description:"description"}},required:["label"]}},multiSelect:{type:"boolean",description:"Set to true for multiple-choice, false for single-choice"}},required:["question","header","options","multiSelect"]}}},required:["questions"]};return{name:this.name,description:this.description,input_schema:e}}async execute(e,r){let{success:s,data:o,error:n}=await $l(
|
|
343
|
+
`;category="read";schema(){let e={type:"object",properties:{questions:{type:"array",description:"question",minItems:1,maxItems:4,items:{type:"object",properties:{question:{type:"string",description:"The question to ask"},header:{type:"string",description:"Short label/category (<=12 chars)"},options:{type:"array",description:"options",minItems:2,maxItems:4,items:{type:"object",properties:{label:{type:"string",description:"label"},description:{type:"string",description:"description"}},required:["label"]}},multiSelect:{type:"boolean",description:"Set to true for multiple-choice, false for single-choice"}},required:["question","header","options","multiSelect"]}}},required:["questions"]};return{name:this.name,description:this.description,input_schema:e}}async execute(e,r){let{success:s,data:o,error:n}=await $l(D.object({questions:D.array(iv)}),r);if(!s)return{output:n.message,isError:!0};let i=o.questions;if(!Array.isArray(i)||i.length<1||i.length>4)return{output:"Error: must have 1-4 questions",isError:!0};for(let u of i)if(!Array.isArray(u.options)||u.options.length<2||u.options.length>4)return{output:`Error: question '${u.question}' must have 2-4 options`,isError:!0};let a=await this.ask(i);return{output:`User has answered your questions: ${Object.entries(a).map(([u,l])=>`"${u}" = "${l}"`).join(", ")}. You can now continue with the user's answers`,isError:!1}}};var Tg=class{name="ExitPlanMode";description=`
|
|
343
344
|
Exit plan mode and present the plan for user approval.
|
|
344
345
|
Call this when your plan is complete and written to the plan file.
|
|
345
|
-
`;category="read";isPlanMode=null;planExists=null;schema(){let e={type:"object",properties:{}};return{name:this.name,description:this.description,input_schema:e}}execute(e,r){return this.isPlanMode&&!this.isPlanMode()?Promise.resolve({output:"You are not in plan mode. This tool is only for exiting plan mode after writing a plan.",isError:!0}):this.planExists&&!this.planExists()?Promise.resolve({output:"No plan file found. Please write your plan to the plan file before calling ExitPlanMode.",isError:!0}):Promise.resolve({output:"Plan mode will be exited after this turn. The user will be shown the plan approval dialog. Do not call any more tools \u2014 end your turn now.",isError:!1})}};export{ii as a,ht as b,
|
|
346
|
+
`;category="read";isPlanMode=null;planExists=null;schema(){let e={type:"object",properties:{}};return{name:this.name,description:this.description,input_schema:e}}execute(e,r){return this.isPlanMode&&!this.isPlanMode()?Promise.resolve({output:"You are not in plan mode. This tool is only for exiting plan mode after writing a plan.",isError:!0}):this.planExists&&!this.planExists()?Promise.resolve({output:"No plan file found. Please write your plan to the plan file before calling ExitPlanMode.",isError:!0}):Promise.resolve({output:"Plan mode will be exited after this turn. The user will be shown the plan approval dialog. Do not call any more tools \u2014 end your turn now.",isError:!1})}};export{ii as a,ht as b,dn as c,Bm as d,QT as e,km as f,Mm as g,bm as h,Dm as i,Lm as j,qm as k,xn as l,Rn as m,Dn as n,Tn as o,Km as p,Zm as q,bn as r,Xm as s,ef as t,tf as u,df as v,mf as w,F$ as x,L$ as y,q$ as z,ff as A,yl as B,J$ as C,Ks as D,aP as E,cP as F,Tf as G,jn as H,Of as I,Nn as J,Yf as K,zn as L,Vf as M,Kf as N,Un as O,Fn as P,On as Q,og as R,nN as S,ig as T,ag as U,cg as V,lg as W,ug as X,BN as Y,QN as Z,xN as _,fg as $,gg as aa,ON as ba,Zn as ca,Ig as da,Ez as ea,kg as fa,Mg as ga,vg as ha,bg as ia,xg as ja,Rg as ka,Dg as la,Tg as ma};
|
|
346
347
|
/*! Bundled license information:
|
|
347
348
|
|
|
348
349
|
content-type/index.js:
|