@sequenzy/mcp 0.0.19 → 0.0.21
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/index.js +18 -7
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/index.js
CHANGED
|
@@ -27,7 +27,7 @@ var O5=Object.create;var{getPrototypeOf:M5,defineProperty:HQ,getOwnPropertyNames
|
|
|
27
27
|
|
|
28
28
|
`)}U.write("payload.value = newResult;"),U.write("return payload;");let T=U.compile();return(E,v)=>T(A,E,v)},J,$=D1,z=!h6.jitless,K=z&&AQ.value,B=X.catchall,D;Q._zod.parse=(A,U)=>{D??(D=W.value);let O=A.value;if(!$(O))return A.issues.push({expected:"object",code:"invalid_type",input:O,inst:Q}),A;if(z&&K&&U?.async===!1&&U.jitless!==!0){if(!J)J=G(X.shape);if(A=J(A,U),!B)return A;return EY([],O,A,U,D,Q)}return Y(A,U)}});function l8(Q,X,Y,W){for(let J of Q)if(J.issues.length===0)return X.value=J.value,X;let G=Q.filter((J)=>!s0(J));if(G.length===1)return X.value=G[0].value,G[0];return X.issues.push({code:"invalid_union",input:X.value,inst:Y,errors:Q.map((J)=>J.issues.map(($)=>E0($,W,Z0())))}),X}var PQ=L("$ZodUnion",(Q,X)=>{i.init(Q,X),l(Q._zod,"optin",()=>X.options.some((G)=>G._zod.optin==="optional")?"optional":void 0),l(Q._zod,"optout",()=>X.options.some((G)=>G._zod.optout==="optional")?"optional":void 0),l(Q._zod,"values",()=>{if(X.options.every((G)=>G._zod.values))return new Set(X.options.flatMap((G)=>Array.from(G._zod.values)));return}),l(Q._zod,"pattern",()=>{if(X.options.every((G)=>G._zod.pattern)){let G=X.options.map((J)=>J._zod.pattern);return new RegExp(`^(${G.map((J)=>p1(J.source)).join("|")})$`)}return});let Y=X.options.length===1,W=X.options[0]._zod.run;Q._zod.parse=(G,J)=>{if(Y)return W(G,J);let $=!1,z=[];for(let H of X.options){let K=H._zod.run({value:G.value,issues:[]},J);if(K instanceof Promise)z.push(K),$=!0;else{if(K.issues.length===0)return K;z.push(K)}}if(!$)return l8(z,G,Q,J);return Promise.all(z).then((H)=>{return l8(H,G,Q,J)})}}),TY=L("$ZodDiscriminatedUnion",(Q,X)=>{PQ.init(Q,X);let Y=Q._zod.parse;l(Q._zod,"propValues",()=>{let G={};for(let J of X.options){let $=J._zod.propValues;if(!$||Object.keys($).length===0)throw Error(`Invalid discriminated union option at index "${X.options.indexOf(J)}"`);for(let[z,H]of Object.entries($)){if(!G[z])G[z]=new Set;for(let K of H)G[z].add(K)}}return G});let W=N1(()=>{let G=X.options,J=new Map;for(let $ of G){let z=$._zod.propValues?.[X.discriminator];if(!z||z.size===0)throw Error(`Invalid discriminated union option at index "${X.options.indexOf($)}"`);for(let H of z){if(J.has(H))throw Error(`Duplicate discriminator value "${String(H)}"`);J.set(H,$)}}return J});Q._zod.parse=(G,J)=>{let $=G.value;if(!D1($))return G.issues.push({code:"invalid_type",expected:"object",input:$,inst:Q}),G;let z=W.value.get($?.[X.discriminator]);if(z)return z._zod.run(G,J);if(X.unionFallback)return Y(G,J);return G.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:X.discriminator,input:$,path:[X.discriminator],inst:Q}),G}}),SY=L("$ZodIntersection",(Q,X)=>{i.init(Q,X),Q._zod.parse=(Y,W)=>{let G=Y.value,J=X.left._zod.run({value:G,issues:[]},W),$=X.right._zod.run({value:G,issues:[]},W);if(J instanceof Promise||$ instanceof Promise)return Promise.all([J,$]).then(([H,K])=>{return c8(Y,H,K)});return c8(Y,J,$)}});function wQ(Q,X){if(Q===X)return{valid:!0,data:Q};if(Q instanceof Date&&X instanceof Date&&+Q===+X)return{valid:!0,data:Q};if(a0(Q)&&a0(X)){let Y=Object.keys(X),W=Object.keys(Q).filter((J)=>Y.indexOf(J)!==-1),G={...Q,...X};for(let J of W){let $=wQ(Q[J],X[J]);if(!$.valid)return{valid:!1,mergeErrorPath:[J,...$.mergeErrorPath]};G[J]=$.data}return{valid:!0,data:G}}if(Array.isArray(Q)&&Array.isArray(X)){if(Q.length!==X.length)return{valid:!1,mergeErrorPath:[]};let Y=[];for(let W=0;W<Q.length;W++){let G=Q[W],J=X[W],$=wQ(G,J);if(!$.valid)return{valid:!1,mergeErrorPath:[W,...$.mergeErrorPath]};Y.push($.data)}return{valid:!0,data:Y}}return{valid:!1,mergeErrorPath:[]}}function c8(Q,X,Y){if(X.issues.length)Q.issues.push(...X.issues);if(Y.issues.length)Q.issues.push(...Y.issues);if(s0(Q))return Q;let W=wQ(X.value,Y.value);if(!W.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(W.mergeErrorPath)}`);return Q.value=W.data,Q}var RY=L("$ZodRecord",(Q,X)=>{i.init(Q,X),Q._zod.parse=(Y,W)=>{let G=Y.value;if(!a0(G))return Y.issues.push({expected:"record",code:"invalid_type",input:G,inst:Q}),Y;let J=[];if(X.keyType._zod.values){let $=X.keyType._zod.values;Y.value={};for(let H of $)if(typeof H==="string"||typeof H==="number"||typeof H==="symbol"){let K=X.valueType._zod.run({value:G[H],issues:[]},W);if(K instanceof Promise)J.push(K.then((B)=>{if(B.issues.length)Y.issues.push(...m0(H,B.issues));Y.value[H]=B.value}));else{if(K.issues.length)Y.issues.push(...m0(H,K.issues));Y.value[H]=K.value}}let z;for(let H in G)if(!$.has(H))z=z??[],z.push(H);if(z&&z.length>0)Y.issues.push({code:"unrecognized_keys",input:G,inst:Q,keys:z})}else{Y.value={};for(let $ of Reflect.ownKeys(G)){if($==="__proto__")continue;let z=X.keyType._zod.run({value:$,issues:[]},W);if(z instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(z.issues.length){Y.issues.push({code:"invalid_key",origin:"record",issues:z.issues.map((K)=>E0(K,W,Z0())),input:$,path:[$],inst:Q}),Y.value[z.value]=z.value;continue}let H=X.valueType._zod.run({value:G[$],issues:[]},W);if(H instanceof Promise)J.push(H.then((K)=>{if(K.issues.length)Y.issues.push(...m0($,K.issues));Y.value[z.value]=K.value}));else{if(H.issues.length)Y.issues.push(...m0($,H.issues));Y.value[z.value]=H.value}}}if(J.length)return Promise.all(J).then(()=>Y);return Y}});var CY=L("$ZodEnum",(Q,X)=>{i.init(Q,X);let Y=BQ(X.entries),W=new Set(Y);Q._zod.values=W,Q._zod.pattern=new RegExp(`^(${Y.filter((G)=>FQ.has(typeof G)).map((G)=>typeof G==="string"?f0(G):G.toString()).join("|")})$`),Q._zod.parse=(G,J)=>{let $=G.value;if(W.has($))return G;return G.issues.push({code:"invalid_value",values:Y,input:$,inst:Q}),G}}),kY=L("$ZodLiteral",(Q,X)=>{if(i.init(Q,X),X.values.length===0)throw Error("Cannot create literal schema with no valid values");Q._zod.values=new Set(X.values),Q._zod.pattern=new RegExp(`^(${X.values.map((Y)=>typeof Y==="string"?f0(Y):Y?f0(Y.toString()):String(Y)).join("|")})$`),Q._zod.parse=(Y,W)=>{let G=Y.value;if(Q._zod.values.has(G))return Y;return Y.issues.push({code:"invalid_value",values:X.values,input:G,inst:Q}),Y}});var vY=L("$ZodTransform",(Q,X)=>{i.init(Q,X),Q._zod.parse=(Y,W)=>{if(W.direction==="backward")throw new m1(Q.constructor.name);let G=X.transform(Y.value,Y);if(W.async)return(G instanceof Promise?G:Promise.resolve(G)).then(($)=>{return Y.value=$,Y});if(G instanceof Promise)throw new g0;return Y.value=G,Y}});function p8(Q,X){if(Q.issues.length&&X===void 0)return{issues:[],value:void 0};return Q}var xY=L("$ZodOptional",(Q,X)=>{i.init(Q,X),Q._zod.optin="optional",Q._zod.optout="optional",l(Q._zod,"values",()=>{return X.innerType._zod.values?new Set([...X.innerType._zod.values,void 0]):void 0}),l(Q._zod,"pattern",()=>{let Y=X.innerType._zod.pattern;return Y?new RegExp(`^(${p1(Y.source)})?$`):void 0}),Q._zod.parse=(Y,W)=>{if(X.innerType._zod.optin==="optional"){let G=X.innerType._zod.run(Y,W);if(G instanceof Promise)return G.then((J)=>p8(J,Y.value));return p8(G,Y.value)}if(Y.value===void 0)return Y;return X.innerType._zod.run(Y,W)}}),_Y=L("$ZodNullable",(Q,X)=>{i.init(Q,X),l(Q._zod,"optin",()=>X.innerType._zod.optin),l(Q._zod,"optout",()=>X.innerType._zod.optout),l(Q._zod,"pattern",()=>{let Y=X.innerType._zod.pattern;return Y?new RegExp(`^(${p1(Y.source)}|null)$`):void 0}),l(Q._zod,"values",()=>{return X.innerType._zod.values?new Set([...X.innerType._zod.values,null]):void 0}),Q._zod.parse=(Y,W)=>{if(Y.value===null)return Y;return X.innerType._zod.run(Y,W)}}),yY=L("$ZodDefault",(Q,X)=>{i.init(Q,X),Q._zod.optin="optional",l(Q._zod,"values",()=>X.innerType._zod.values),Q._zod.parse=(Y,W)=>{if(W.direction==="backward")return X.innerType._zod.run(Y,W);if(Y.value===void 0)return Y.value=X.defaultValue,Y;let G=X.innerType._zod.run(Y,W);if(G instanceof Promise)return G.then((J)=>i8(J,X));return i8(G,X)}});function i8(Q,X){if(Q.value===void 0)Q.value=X.defaultValue;return Q}var hY=L("$ZodPrefault",(Q,X)=>{i.init(Q,X),Q._zod.optin="optional",l(Q._zod,"values",()=>X.innerType._zod.values),Q._zod.parse=(Y,W)=>{if(W.direction==="backward")return X.innerType._zod.run(Y,W);if(Y.value===void 0)Y.value=X.defaultValue;return X.innerType._zod.run(Y,W)}}),uY=L("$ZodNonOptional",(Q,X)=>{i.init(Q,X),l(Q._zod,"values",()=>{let Y=X.innerType._zod.values;return Y?new Set([...Y].filter((W)=>W!==void 0)):void 0}),Q._zod.parse=(Y,W)=>{let G=X.innerType._zod.run(Y,W);if(G instanceof Promise)return G.then((J)=>n8(J,Q));return n8(G,Q)}});function n8(Q,X){if(!Q.issues.length&&Q.value===void 0)Q.issues.push({code:"invalid_type",expected:"nonoptional",input:Q.value,inst:X});return Q}var gY=L("$ZodCatch",(Q,X)=>{i.init(Q,X),l(Q._zod,"optin",()=>X.innerType._zod.optin),l(Q._zod,"optout",()=>X.innerType._zod.optout),l(Q._zod,"values",()=>X.innerType._zod.values),Q._zod.parse=(Y,W)=>{if(W.direction==="backward")return X.innerType._zod.run(Y,W);let G=X.innerType._zod.run(Y,W);if(G instanceof Promise)return G.then((J)=>{if(Y.value=J.value,J.issues.length)Y.value=X.catchValue({...Y,error:{issues:J.issues.map(($)=>E0($,W,Z0()))},input:Y.value}),Y.issues=[];return Y});if(Y.value=G.value,G.issues.length)Y.value=X.catchValue({...Y,error:{issues:G.issues.map((J)=>E0(J,W,Z0()))},input:Y.value}),Y.issues=[];return Y}});var fY=L("$ZodPipe",(Q,X)=>{i.init(Q,X),l(Q._zod,"values",()=>X.in._zod.values),l(Q._zod,"optin",()=>X.in._zod.optin),l(Q._zod,"optout",()=>X.out._zod.optout),l(Q._zod,"propValues",()=>X.in._zod.propValues),Q._zod.parse=(Y,W)=>{if(W.direction==="backward"){let J=X.out._zod.run(Y,W);if(J instanceof Promise)return J.then(($)=>d6($,X.in,W));return d6(J,X.in,W)}let G=X.in._zod.run(Y,W);if(G instanceof Promise)return G.then((J)=>d6(J,X.out,W));return d6(G,X.out,W)}});function d6(Q,X,Y){if(Q.issues.length)return Q.aborted=!0,Q;return X._zod.run({value:Q.value,issues:Q.issues},Y)}var mY=L("$ZodReadonly",(Q,X)=>{i.init(Q,X),l(Q._zod,"propValues",()=>X.innerType._zod.propValues),l(Q._zod,"values",()=>X.innerType._zod.values),l(Q._zod,"optin",()=>X.innerType._zod.optin),l(Q._zod,"optout",()=>X.innerType._zod.optout),Q._zod.parse=(Y,W)=>{if(W.direction==="backward")return X.innerType._zod.run(Y,W);let G=X.innerType._zod.run(Y,W);if(G instanceof Promise)return G.then(d8);return d8(G)}});function d8(Q){return Q.value=Object.freeze(Q.value),Q}var lY=L("$ZodCustom",(Q,X)=>{X0.init(Q,X),i.init(Q,X),Q._zod.parse=(Y,W)=>{return Y},Q._zod.check=(Y)=>{let W=Y.value,G=X.fn(W);if(G instanceof Promise)return G.then((J)=>r8(J,Y,W,Q));r8(G,Y,W,Q);return}});function r8(Q,X,Y,W){if(!Q){let G={code:"custom",input:Y,inst:W,path:[...W._zod.def.path??[]],continue:!W._zod.def.abort};if(W._zod.def.params)G.params=W._zod.def.params;X.issues.push(w1(G))}}var YH=(Q)=>{let X=typeof Q;switch(X){case"number":return Number.isNaN(Q)?"NaN":"number";case"object":{if(Array.isArray(Q))return"array";if(Q===null)return"null";if(Object.getPrototypeOf(Q)!==Object.prototype&&Q.constructor)return Q.constructor.name}}return X},WH=()=>{let Q={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function X(W){return Q[W]??null}let Y={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return(W)=>{switch(W.code){case"invalid_type":return`Invalid input: expected ${W.expected}, received ${YH(W.input)}`;case"invalid_value":if(W.values.length===1)return`Invalid input: expected ${m6(W.values[0])}`;return`Invalid option: expected one of ${u6(W.values,"|")}`;case"too_big":{let G=W.inclusive?"<=":"<",J=X(W.origin);if(J)return`Too big: expected ${W.origin??"value"} to have ${G}${W.maximum.toString()} ${J.unit??"elements"}`;return`Too big: expected ${W.origin??"value"} to be ${G}${W.maximum.toString()}`}case"too_small":{let G=W.inclusive?">=":">",J=X(W.origin);if(J)return`Too small: expected ${W.origin} to have ${G}${W.minimum.toString()} ${J.unit}`;return`Too small: expected ${W.origin} to be ${G}${W.minimum.toString()}`}case"invalid_format":{let G=W;if(G.format==="starts_with")return`Invalid string: must start with "${G.prefix}"`;if(G.format==="ends_with")return`Invalid string: must end with "${G.suffix}"`;if(G.format==="includes")return`Invalid string: must include "${G.includes}"`;if(G.format==="regex")return`Invalid string: must match pattern ${G.pattern}`;return`Invalid ${Y[G.format]??W.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${W.divisor}`;case"unrecognized_keys":return`Unrecognized key${W.keys.length>1?"s":""}: ${u6(W.keys,", ")}`;case"invalid_key":return`Invalid key in ${W.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${W.origin}`;default:return"Invalid input"}}};function bQ(){return{localeError:WH()}}var SV=Symbol("ZodOutput"),RV=Symbol("ZodInput");class cY{constructor(){this._map=new WeakMap,this._idmap=new Map}add(Q,...X){let Y=X[0];if(this._map.set(Q,Y),Y&&typeof Y==="object"&&"id"in Y){if(this._idmap.has(Y.id))throw Error(`ID ${Y.id} already exists in the registry`);this._idmap.set(Y.id,Q)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(Q){let X=this._map.get(Q);if(X&&typeof X==="object"&&"id"in X)this._idmap.delete(X.id);return this._map.delete(Q),this}get(Q){let X=Q._zod.parent;if(X){let Y={...this.get(X)??{}};delete Y.id;let W={...Y,...this._map.get(Q)};return Object.keys(W).length?W:void 0}return this._map.get(Q)}has(Q){return this._map.has(Q)}}function GH(){return new cY}var t1=GH();function pY(Q,X){return new Q({type:"string",...b(X)})}function iY(Q,X){return new Q({type:"string",format:"email",check:"string_format",abort:!1,...b(X)})}function EQ(Q,X){return new Q({type:"string",format:"guid",check:"string_format",abort:!1,...b(X)})}function nY(Q,X){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,...b(X)})}function dY(Q,X){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...b(X)})}function rY(Q,X){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...b(X)})}function oY(Q,X){return new Q({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...b(X)})}function tY(Q,X){return new Q({type:"string",format:"url",check:"string_format",abort:!1,...b(X)})}function aY(Q,X){return new Q({type:"string",format:"emoji",check:"string_format",abort:!1,...b(X)})}function sY(Q,X){return new Q({type:"string",format:"nanoid",check:"string_format",abort:!1,...b(X)})}function eY(Q,X){return new Q({type:"string",format:"cuid",check:"string_format",abort:!1,...b(X)})}function QW(Q,X){return new Q({type:"string",format:"cuid2",check:"string_format",abort:!1,...b(X)})}function XW(Q,X){return new Q({type:"string",format:"ulid",check:"string_format",abort:!1,...b(X)})}function YW(Q,X){return new Q({type:"string",format:"xid",check:"string_format",abort:!1,...b(X)})}function WW(Q,X){return new Q({type:"string",format:"ksuid",check:"string_format",abort:!1,...b(X)})}function GW(Q,X){return new Q({type:"string",format:"ipv4",check:"string_format",abort:!1,...b(X)})}function JW(Q,X){return new Q({type:"string",format:"ipv6",check:"string_format",abort:!1,...b(X)})}function $W(Q,X){return new Q({type:"string",format:"cidrv4",check:"string_format",abort:!1,...b(X)})}function zW(Q,X){return new Q({type:"string",format:"cidrv6",check:"string_format",abort:!1,...b(X)})}function HW(Q,X){return new Q({type:"string",format:"base64",check:"string_format",abort:!1,...b(X)})}function KW(Q,X){return new Q({type:"string",format:"base64url",check:"string_format",abort:!1,...b(X)})}function BW(Q,X){return new Q({type:"string",format:"e164",check:"string_format",abort:!1,...b(X)})}function DW(Q,X){return new Q({type:"string",format:"jwt",check:"string_format",abort:!1,...b(X)})}function AW(Q,X){return new Q({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...b(X)})}function FW(Q,X){return new Q({type:"string",format:"date",check:"string_format",...b(X)})}function LW(Q,X){return new Q({type:"string",format:"time",check:"string_format",precision:null,...b(X)})}function UW(Q,X){return new Q({type:"string",format:"duration",check:"string_format",...b(X)})}function OW(Q,X){return new Q({type:"number",checks:[],...b(X)})}function MW(Q,X){return new Q({type:"number",check:"number_format",abort:!1,format:"safeint",...b(X)})}function VW(Q,X){return new Q({type:"boolean",...b(X)})}function qW(Q,X){return new Q({type:"null",...b(X)})}function ZW(Q){return new Q({type:"unknown"})}function NW(Q,X){return new Q({type:"never",...b(X)})}function t6(Q,X){return new qQ({check:"less_than",...b(X),value:Q,inclusive:!1})}function a1(Q,X){return new qQ({check:"less_than",...b(X),value:Q,inclusive:!0})}function a6(Q,X){return new ZQ({check:"greater_than",...b(X),value:Q,inclusive:!1})}function s1(Q,X){return new ZQ({check:"greater_than",...b(X),value:Q,inclusive:!0})}function s6(Q,X){return new I8({check:"multiple_of",...b(X),value:Q})}function e6(Q,X){return new S8({check:"max_length",...b(X),maximum:Q})}function j1(Q,X){return new R8({check:"min_length",...b(X),minimum:Q})}function Q4(Q,X){return new C8({check:"length_equals",...b(X),length:Q})}function IQ(Q,X){return new k8({check:"string_format",format:"regex",...b(X),pattern:Q})}function TQ(Q){return new v8({check:"string_format",format:"lowercase",...b(Q)})}function SQ(Q){return new x8({check:"string_format",format:"uppercase",...b(Q)})}function RQ(Q,X){return new _8({check:"string_format",format:"includes",...b(X),includes:Q})}function CQ(Q,X){return new y8({check:"string_format",format:"starts_with",...b(X),prefix:Q})}function kQ(Q,X){return new h8({check:"string_format",format:"ends_with",...b(X),suffix:Q})}function A1(Q){return new u8({check:"overwrite",tx:Q})}function vQ(Q){return A1((X)=>X.normalize(Q))}function xQ(){return A1((Q)=>Q.trim())}function _Q(){return A1((Q)=>Q.toLowerCase())}function yQ(){return A1((Q)=>Q.toUpperCase())}function wW(Q,X,Y){return new Q({type:"array",element:X,...b(Y)})}function jW(Q,X,Y){let W=b(Y);return W.abort??(W.abort=!0),new Q({type:"custom",check:"custom",fn:X,...W})}function PW(Q,X,Y){return new Q({type:"custom",check:"custom",fn:X,...b(Y)})}function bW(Q){let X=JH((Y)=>{return Y.addIssue=(W)=>{if(typeof W==="string")Y.issues.push(w1(W,Y.value,X._zod.def));else{let G=W;if(G.fatal)G.continue=!1;G.code??(G.code="custom"),G.input??(G.input=Y.value),G.inst??(G.inst=X),G.continue??(G.continue=!X._zod.def.abort),Y.issues.push(w1(G))}},Q(Y.value,Y)});return X}function JH(Q,X){let Y=new X0({check:"custom",...b(X)});return Y._zod.check=Q,Y}function P1(Q){return!!Q._zod}function e0(Q,X){if(P1(Q))return d1(Q,X);return Q.safeParse(X)}function X4(Q){if(!Q)return;let X;if(P1(Q))X=Q._zod?.def?.shape;else X=Q.shape;if(!X)return;if(typeof X==="function")try{return X()}catch{return}return X}function EW(Q){if(P1(Q)){let J=Q._zod?.def;if(J){if(J.value!==void 0)return J.value;if(Array.isArray(J.values)&&J.values.length>0)return J.values[0]}}let Y=Q._def;if(Y){if(Y.value!==void 0)return Y.value;if(Array.isArray(Y.values)&&Y.values.length>0)return Y.values[0]}let W=Q.value;if(W!==void 0)return W;return}var Q6={};CX(Q6,{time:()=>gQ,duration:()=>fQ,datetime:()=>hQ,date:()=>uQ,ZodISOTime:()=>SW,ZodISODuration:()=>RW,ZodISODateTime:()=>IW,ZodISODate:()=>TW});var IW=L("ZodISODateTime",(Q,X)=>{$Y.init(Q,X),r.init(Q,X)});function hQ(Q){return AW(IW,Q)}var TW=L("ZodISODate",(Q,X)=>{zY.init(Q,X),r.init(Q,X)});function uQ(Q){return FW(TW,Q)}var SW=L("ZodISOTime",(Q,X)=>{HY.init(Q,X),r.init(Q,X)});function gQ(Q){return LW(SW,Q)}var RW=L("ZodISODuration",(Q,X)=>{KY.init(Q,X),r.init(Q,X)});function fQ(Q){return UW(RW,Q)}var CW=(Q,X)=>{l6.init(Q,X),Q.name="ZodError",Object.defineProperties(Q,{format:{value:(Y)=>lX(Q,Y)},flatten:{value:(Y)=>mX(Q,Y)},addIssue:{value:(Y)=>{Q.issues.push(Y),Q.message=JSON.stringify(Q.issues,Z1,2)}},addIssues:{value:(Y)=>{Q.issues.push(...Y),Q.message=JSON.stringify(Q.issues,Z1,2)}},isEmpty:{get(){return Q.issues.length===0}}})},Uq=L("ZodError",CW),V0=L("ZodError",CW,{Parent:Error});var kW=c6(V0),vW=p6(V0),xW=n1(V0),_W=r1(V0),yW=cX(V0),hW=pX(V0),uW=iX(V0),gW=nX(V0),fW=dX(V0),mW=rX(V0),lW=oX(V0),cW=tX(V0);var s=L("ZodType",(Q,X)=>{return i.init(Q,X),Q.def=X,Q.type=X.type,Object.defineProperty(Q,"_def",{value:X}),Q.check=(...Y)=>{return Q.clone(u.mergeDefs(X,{checks:[...X.checks??[],...Y.map((W)=>typeof W==="function"?{_zod:{check:W,def:{check:"custom"},onattach:[]}}:W)]}))},Q.clone=(Y,W)=>b0(Q,Y,W),Q.brand=()=>Q,Q.register=(Y,W)=>{return Y.add(Q,W),Q},Q.parse=(Y,W)=>kW(Q,Y,W,{callee:Q.parse}),Q.safeParse=(Y,W)=>xW(Q,Y,W),Q.parseAsync=async(Y,W)=>vW(Q,Y,W,{callee:Q.parseAsync}),Q.safeParseAsync=async(Y,W)=>_W(Q,Y,W),Q.spa=Q.safeParseAsync,Q.encode=(Y,W)=>yW(Q,Y,W),Q.decode=(Y,W)=>hW(Q,Y,W),Q.encodeAsync=async(Y,W)=>uW(Q,Y,W),Q.decodeAsync=async(Y,W)=>gW(Q,Y,W),Q.safeEncode=(Y,W)=>fW(Q,Y,W),Q.safeDecode=(Y,W)=>mW(Q,Y,W),Q.safeEncodeAsync=async(Y,W)=>lW(Q,Y,W),Q.safeDecodeAsync=async(Y,W)=>cW(Q,Y,W),Q.refine=(Y,W)=>Q.check(X3(Y,W)),Q.superRefine=(Y)=>Q.check(Y3(Y)),Q.overwrite=(Y)=>Q.check(A1(Y)),Q.optional=()=>a(Q),Q.nullable=()=>nW(Q),Q.nullish=()=>a(nW(Q)),Q.nonoptional=(Y)=>oH(Q,Y),Q.array=()=>x(Q),Q.or=(Y)=>p([Q,Y]),Q.and=(Y)=>W4(Q,Y),Q.transform=(Y)=>lQ(Q,aW(Y)),Q.default=(Y)=>nH(Q,Y),Q.prefault=(Y)=>rH(Q,Y),Q.catch=(Y)=>aH(Q,Y),Q.pipe=(Y)=>lQ(Q,Y),Q.readonly=()=>Q3(Q),Q.describe=(Y)=>{let W=Q.clone();return t1.add(W,{description:Y}),W},Object.defineProperty(Q,"description",{get(){return t1.get(Q)?.description},configurable:!0}),Q.meta=(...Y)=>{if(Y.length===0)return t1.get(Q);let W=Q.clone();return t1.add(W,Y[0]),W},Q.isOptional=()=>Q.safeParse(void 0).success,Q.isNullable=()=>Q.safeParse(null).success,Q}),dW=L("_ZodString",(Q,X)=>{o6.init(Q,X),s.init(Q,X);let Y=Q._zod.bag;Q.format=Y.format??null,Q.minLength=Y.minimum??null,Q.maxLength=Y.maximum??null,Q.regex=(...W)=>Q.check(IQ(...W)),Q.includes=(...W)=>Q.check(RQ(...W)),Q.startsWith=(...W)=>Q.check(CQ(...W)),Q.endsWith=(...W)=>Q.check(kQ(...W)),Q.min=(...W)=>Q.check(j1(...W)),Q.max=(...W)=>Q.check(e6(...W)),Q.length=(...W)=>Q.check(Q4(...W)),Q.nonempty=(...W)=>Q.check(j1(1,...W)),Q.lowercase=(W)=>Q.check(TQ(W)),Q.uppercase=(W)=>Q.check(SQ(W)),Q.trim=()=>Q.check(xQ()),Q.normalize=(...W)=>Q.check(vQ(...W)),Q.toLowerCase=()=>Q.check(_Q()),Q.toUpperCase=()=>Q.check(yQ())}),LH=L("ZodString",(Q,X)=>{o6.init(Q,X),dW.init(Q,X),Q.email=(Y)=>Q.check(iY(UH,Y)),Q.url=(Y)=>Q.check(tY(OH,Y)),Q.jwt=(Y)=>Q.check(DW(CH,Y)),Q.emoji=(Y)=>Q.check(aY(MH,Y)),Q.guid=(Y)=>Q.check(EQ(pW,Y)),Q.uuid=(Y)=>Q.check(nY(Y4,Y)),Q.uuidv4=(Y)=>Q.check(dY(Y4,Y)),Q.uuidv6=(Y)=>Q.check(rY(Y4,Y)),Q.uuidv7=(Y)=>Q.check(oY(Y4,Y)),Q.nanoid=(Y)=>Q.check(sY(VH,Y)),Q.guid=(Y)=>Q.check(EQ(pW,Y)),Q.cuid=(Y)=>Q.check(eY(qH,Y)),Q.cuid2=(Y)=>Q.check(QW(ZH,Y)),Q.ulid=(Y)=>Q.check(XW(NH,Y)),Q.base64=(Y)=>Q.check(HW(TH,Y)),Q.base64url=(Y)=>Q.check(KW(SH,Y)),Q.xid=(Y)=>Q.check(YW(wH,Y)),Q.ksuid=(Y)=>Q.check(WW(jH,Y)),Q.ipv4=(Y)=>Q.check(GW(PH,Y)),Q.ipv6=(Y)=>Q.check(JW(bH,Y)),Q.cidrv4=(Y)=>Q.check($W(EH,Y)),Q.cidrv6=(Y)=>Q.check(zW(IH,Y)),Q.e164=(Y)=>Q.check(BW(RH,Y)),Q.datetime=(Y)=>Q.check(hQ(Y)),Q.date=(Y)=>Q.check(uQ(Y)),Q.time=(Y)=>Q.check(gQ(Y)),Q.duration=(Y)=>Q.check(fQ(Y))});function F(Q){return pY(LH,Q)}var r=L("ZodStringFormat",(Q,X)=>{n.init(Q,X),dW.init(Q,X)}),UH=L("ZodEmail",(Q,X)=>{a8.init(Q,X),r.init(Q,X)});var pW=L("ZodGUID",(Q,X)=>{o8.init(Q,X),r.init(Q,X)});var Y4=L("ZodUUID",(Q,X)=>{t8.init(Q,X),r.init(Q,X)});var OH=L("ZodURL",(Q,X)=>{s8.init(Q,X),r.init(Q,X)});var MH=L("ZodEmoji",(Q,X)=>{e8.init(Q,X),r.init(Q,X)});var VH=L("ZodNanoID",(Q,X)=>{QY.init(Q,X),r.init(Q,X)});var qH=L("ZodCUID",(Q,X)=>{XY.init(Q,X),r.init(Q,X)});var ZH=L("ZodCUID2",(Q,X)=>{YY.init(Q,X),r.init(Q,X)});var NH=L("ZodULID",(Q,X)=>{WY.init(Q,X),r.init(Q,X)});var wH=L("ZodXID",(Q,X)=>{GY.init(Q,X),r.init(Q,X)});var jH=L("ZodKSUID",(Q,X)=>{JY.init(Q,X),r.init(Q,X)});var PH=L("ZodIPv4",(Q,X)=>{BY.init(Q,X),r.init(Q,X)});var bH=L("ZodIPv6",(Q,X)=>{DY.init(Q,X),r.init(Q,X)});var EH=L("ZodCIDRv4",(Q,X)=>{AY.init(Q,X),r.init(Q,X)});var IH=L("ZodCIDRv6",(Q,X)=>{FY.init(Q,X),r.init(Q,X)});var TH=L("ZodBase64",(Q,X)=>{UY.init(Q,X),r.init(Q,X)});var SH=L("ZodBase64URL",(Q,X)=>{OY.init(Q,X),r.init(Q,X)});var RH=L("ZodE164",(Q,X)=>{MY.init(Q,X),r.init(Q,X)});var CH=L("ZodJWT",(Q,X)=>{VY.init(Q,X),r.init(Q,X)});var rW=L("ZodNumber",(Q,X)=>{jQ.init(Q,X),s.init(Q,X),Q.gt=(W,G)=>Q.check(a6(W,G)),Q.gte=(W,G)=>Q.check(s1(W,G)),Q.min=(W,G)=>Q.check(s1(W,G)),Q.lt=(W,G)=>Q.check(t6(W,G)),Q.lte=(W,G)=>Q.check(a1(W,G)),Q.max=(W,G)=>Q.check(a1(W,G)),Q.int=(W)=>Q.check(iW(W)),Q.safe=(W)=>Q.check(iW(W)),Q.positive=(W)=>Q.check(a6(0,W)),Q.nonnegative=(W)=>Q.check(s1(0,W)),Q.negative=(W)=>Q.check(t6(0,W)),Q.nonpositive=(W)=>Q.check(a1(0,W)),Q.multipleOf=(W,G)=>Q.check(s6(W,G)),Q.step=(W,G)=>Q.check(s6(W,G)),Q.finite=()=>Q;let Y=Q._zod.bag;Q.minValue=Math.max(Y.minimum??Number.NEGATIVE_INFINITY,Y.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,Q.maxValue=Math.min(Y.maximum??Number.POSITIVE_INFINITY,Y.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,Q.isInt=(Y.format??"").includes("int")||Number.isSafeInteger(Y.multipleOf??0.5),Q.isFinite=!0,Q.format=Y.format??null});function m(Q){return OW(rW,Q)}var kH=L("ZodNumberFormat",(Q,X)=>{qY.init(Q,X),rW.init(Q,X)});function iW(Q){return MW(kH,Q)}var vH=L("ZodBoolean",(Q,X)=>{ZY.init(Q,X),s.init(Q,X)});function Q0(Q){return VW(vH,Q)}var xH=L("ZodNull",(Q,X)=>{NY.init(Q,X),s.init(Q,X)});function cQ(Q){return qW(xH,Q)}var _H=L("ZodUnknown",(Q,X)=>{wY.init(Q,X),s.init(Q,X)});function o(){return ZW(_H)}var yH=L("ZodNever",(Q,X)=>{jY.init(Q,X),s.init(Q,X)});function hH(Q){return NW(yH,Q)}var uH=L("ZodArray",(Q,X)=>{PY.init(Q,X),s.init(Q,X),Q.element=X.element,Q.min=(Y,W)=>Q.check(j1(Y,W)),Q.nonempty=(Y)=>Q.check(j1(1,Y)),Q.max=(Y,W)=>Q.check(e6(Y,W)),Q.length=(Y,W)=>Q.check(Q4(Y,W)),Q.unwrap=()=>Q.element});function x(Q,X){return wW(uH,Q,X)}var oW=L("ZodObject",(Q,X)=>{IY.init(Q,X),s.init(Q,X),u.defineLazy(Q,"shape",()=>{return X.shape}),Q.keyof=()=>F0(Object.keys(Q._zod.def.shape)),Q.catchall=(Y)=>Q.clone({...Q._zod.def,catchall:Y}),Q.passthrough=()=>Q.clone({...Q._zod.def,catchall:o()}),Q.loose=()=>Q.clone({...Q._zod.def,catchall:o()}),Q.strict=()=>Q.clone({...Q._zod.def,catchall:hH()}),Q.strip=()=>Q.clone({...Q._zod.def,catchall:void 0}),Q.extend=(Y)=>{return u.extend(Q,Y)},Q.safeExtend=(Y)=>{return u.safeExtend(Q,Y)},Q.merge=(Y)=>u.merge(Q,Y),Q.pick=(Y)=>u.pick(Q,Y),Q.omit=(Y)=>u.omit(Q,Y),Q.partial=(...Y)=>u.partial(sW,Q,Y[0]),Q.required=(...Y)=>u.required(eW,Q,Y[0])});function N(Q,X){let Y={type:"object",shape:Q??{},...u.normalizeParams(X)};return new oW(Y)}function B0(Q,X){return new oW({type:"object",shape:Q,catchall:o(),...u.normalizeParams(X)})}var tW=L("ZodUnion",(Q,X)=>{PQ.init(Q,X),s.init(Q,X),Q.options=X.options});function p(Q,X){return new tW({type:"union",options:Q,...u.normalizeParams(X)})}var gH=L("ZodDiscriminatedUnion",(Q,X)=>{tW.init(Q,X),TY.init(Q,X)});function pQ(Q,X,Y){return new gH({type:"union",options:X,discriminator:Q,...u.normalizeParams(Y)})}var fH=L("ZodIntersection",(Q,X)=>{SY.init(Q,X),s.init(Q,X)});function W4(Q,X){return new fH({type:"intersection",left:Q,right:X})}var mH=L("ZodRecord",(Q,X)=>{RY.init(Q,X),s.init(Q,X),Q.keyType=X.keyType,Q.valueType=X.valueType});function t(Q,X,Y){return new mH({type:"record",keyType:Q,valueType:X,...u.normalizeParams(Y)})}var mQ=L("ZodEnum",(Q,X)=>{CY.init(Q,X),s.init(Q,X),Q.enum=X.entries,Q.options=Object.values(X.entries);let Y=new Set(Object.keys(X.entries));Q.extract=(W,G)=>{let J={};for(let $ of W)if(Y.has($))J[$]=X.entries[$];else throw Error(`Key ${$} not found in enum`);return new mQ({...X,checks:[],...u.normalizeParams(G),entries:J})},Q.exclude=(W,G)=>{let J={...X.entries};for(let $ of W)if(Y.has($))delete J[$];else throw Error(`Key ${$} not found in enum`);return new mQ({...X,checks:[],...u.normalizeParams(G),entries:J})}});function F0(Q,X){let Y=Array.isArray(Q)?Object.fromEntries(Q.map((W)=>[W,W])):Q;return new mQ({type:"enum",entries:Y,...u.normalizeParams(X)})}var lH=L("ZodLiteral",(Q,X)=>{kY.init(Q,X),s.init(Q,X),Q.values=new Set(X.values),Object.defineProperty(Q,"value",{get(){if(X.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return X.values[0]}})});function j(Q,X){return new lH({type:"literal",values:Array.isArray(Q)?Q:[Q],...u.normalizeParams(X)})}var cH=L("ZodTransform",(Q,X)=>{vY.init(Q,X),s.init(Q,X),Q._zod.parse=(Y,W)=>{if(W.direction==="backward")throw new m1(Q.constructor.name);Y.addIssue=(J)=>{if(typeof J==="string")Y.issues.push(u.issue(J,Y.value,X));else{let $=J;if($.fatal)$.continue=!1;$.code??($.code="custom"),$.input??($.input=Y.value),$.inst??($.inst=Q),Y.issues.push(u.issue($))}};let G=X.transform(Y.value,Y);if(G instanceof Promise)return G.then((J)=>{return Y.value=J,Y});return Y.value=G,Y}});function aW(Q){return new cH({type:"transform",transform:Q})}var sW=L("ZodOptional",(Q,X)=>{xY.init(Q,X),s.init(Q,X),Q.unwrap=()=>Q._zod.def.innerType});function a(Q){return new sW({type:"optional",innerType:Q})}var pH=L("ZodNullable",(Q,X)=>{_Y.init(Q,X),s.init(Q,X),Q.unwrap=()=>Q._zod.def.innerType});function nW(Q){return new pH({type:"nullable",innerType:Q})}var iH=L("ZodDefault",(Q,X)=>{yY.init(Q,X),s.init(Q,X),Q.unwrap=()=>Q._zod.def.innerType,Q.removeDefault=Q.unwrap});function nH(Q,X){return new iH({type:"default",innerType:Q,get defaultValue(){return typeof X==="function"?X():u.shallowClone(X)}})}var dH=L("ZodPrefault",(Q,X)=>{hY.init(Q,X),s.init(Q,X),Q.unwrap=()=>Q._zod.def.innerType});function rH(Q,X){return new dH({type:"prefault",innerType:Q,get defaultValue(){return typeof X==="function"?X():u.shallowClone(X)}})}var eW=L("ZodNonOptional",(Q,X)=>{uY.init(Q,X),s.init(Q,X),Q.unwrap=()=>Q._zod.def.innerType});function oH(Q,X){return new eW({type:"nonoptional",innerType:Q,...u.normalizeParams(X)})}var tH=L("ZodCatch",(Q,X)=>{gY.init(Q,X),s.init(Q,X),Q.unwrap=()=>Q._zod.def.innerType,Q.removeCatch=Q.unwrap});function aH(Q,X){return new tH({type:"catch",innerType:Q,catchValue:typeof X==="function"?X:()=>X})}var sH=L("ZodPipe",(Q,X)=>{fY.init(Q,X),s.init(Q,X),Q.in=X.in,Q.out=X.out});function lQ(Q,X){return new sH({type:"pipe",in:Q,out:X})}var eH=L("ZodReadonly",(Q,X)=>{mY.init(Q,X),s.init(Q,X),Q.unwrap=()=>Q._zod.def.innerType});function Q3(Q){return new eH({type:"readonly",innerType:Q})}var QG=L("ZodCustom",(Q,X)=>{lY.init(Q,X),s.init(Q,X)});function XG(Q,X){return jW(QG,Q??(()=>!0),X)}function X3(Q,X={}){return PW(QG,Q,X)}function Y3(Q){return bW(Q)}function iQ(Q,X){return lQ(aW(Q),X)}Z0(bQ());var nQ="2025-11-25";var YG=[nQ,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Q1="io.modelcontextprotocol/related-task",J4="2.0",Y0=XG((Q)=>Q!==null&&(typeof Q==="object"||typeof Q==="function")),WG=p([F(),m().int()]),GG=F(),BZ=B0({ttl:p([m(),cQ()]).optional(),pollInterval:m().optional()}),W3=N({ttl:m().optional()}),G3=N({taskId:F()}),dQ=B0({progressToken:WG.optional(),[Q1]:G3.optional()}),q0=N({_meta:dQ.optional()}),X6=q0.extend({task:W3.optional()}),JG=(Q)=>X6.safeParse(Q).success,W0=N({method:F(),params:q0.loose().optional()}),N0=N({_meta:dQ.optional()}),w0=N({method:F(),params:N0.loose().optional()}),G0=B0({_meta:dQ.optional()}),$4=p([F(),m().int()]),$G=N({jsonrpc:j(J4),id:$4,...W0.shape}).strict(),rQ=(Q)=>$G.safeParse(Q).success,zG=N({jsonrpc:j(J4),...w0.shape}).strict(),HG=(Q)=>zG.safeParse(Q).success,oQ=N({jsonrpc:j(J4),id:$4,result:G0}).strict(),Y6=(Q)=>oQ.safeParse(Q).success;var _;(function(Q){Q[Q.ConnectionClosed=-32000]="ConnectionClosed",Q[Q.RequestTimeout=-32001]="RequestTimeout",Q[Q.ParseError=-32700]="ParseError",Q[Q.InvalidRequest=-32600]="InvalidRequest",Q[Q.MethodNotFound=-32601]="MethodNotFound",Q[Q.InvalidParams=-32602]="InvalidParams",Q[Q.InternalError=-32603]="InternalError",Q[Q.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(_||(_={}));var tQ=N({jsonrpc:j(J4),id:$4.optional(),error:N({code:m().int(),message:F(),data:o().optional()})}).strict();var KG=(Q)=>tQ.safeParse(Q).success;var BG=p([$G,zG,oQ,tQ]),DZ=p([oQ,tQ]),z4=G0.strict(),J3=N0.extend({requestId:$4.optional(),reason:F().optional()}),H4=w0.extend({method:j("notifications/cancelled"),params:J3}),$3=N({src:F(),mimeType:F().optional(),sizes:x(F()).optional(),theme:F0(["light","dark"]).optional()}),W6=N({icons:x($3).optional()}),b1=N({name:F(),title:F().optional()}),DG=b1.extend({...b1.shape,...W6.shape,version:F(),websiteUrl:F().optional(),description:F().optional()}),z3=W4(N({applyDefaults:Q0().optional()}),t(F(),o())),H3=iQ((Q)=>{if(Q&&typeof Q==="object"&&!Array.isArray(Q)){if(Object.keys(Q).length===0)return{form:{}}}return Q},W4(N({form:z3.optional(),url:Y0.optional()}),t(F(),o()).optional())),K3=B0({list:Y0.optional(),cancel:Y0.optional(),requests:B0({sampling:B0({createMessage:Y0.optional()}).optional(),elicitation:B0({create:Y0.optional()}).optional()}).optional()}),B3=B0({list:Y0.optional(),cancel:Y0.optional(),requests:B0({tools:B0({call:Y0.optional()}).optional()}).optional()}),D3=N({experimental:t(F(),Y0).optional(),sampling:N({context:Y0.optional(),tools:Y0.optional()}).optional(),elicitation:H3.optional(),roots:N({listChanged:Q0().optional()}).optional(),tasks:K3.optional()}),A3=q0.extend({protocolVersion:F(),capabilities:D3,clientInfo:DG}),aQ=W0.extend({method:j("initialize"),params:A3});var F3=N({experimental:t(F(),Y0).optional(),logging:Y0.optional(),completions:Y0.optional(),prompts:N({listChanged:Q0().optional()}).optional(),resources:N({subscribe:Q0().optional(),listChanged:Q0().optional()}).optional(),tools:N({listChanged:Q0().optional()}).optional(),tasks:B3.optional()}),L3=G0.extend({protocolVersion:F(),capabilities:F3,serverInfo:DG,instructions:F().optional()}),sQ=w0.extend({method:j("notifications/initialized"),params:N0.optional()});var K4=W0.extend({method:j("ping"),params:q0.optional()}),U3=N({progress:m(),total:a(m()),message:a(F())}),O3=N({...N0.shape,...U3.shape,progressToken:WG}),B4=w0.extend({method:j("notifications/progress"),params:O3}),M3=q0.extend({cursor:GG.optional()}),G6=W0.extend({params:M3.optional()}),J6=G0.extend({nextCursor:GG.optional()}),V3=F0(["working","input_required","completed","failed","cancelled"]),$6=N({taskId:F(),status:V3,ttl:p([m(),cQ()]),createdAt:F(),lastUpdatedAt:F(),pollInterval:a(m()),statusMessage:a(F())}),E1=G0.extend({task:$6}),q3=N0.merge($6),z6=w0.extend({method:j("notifications/tasks/status"),params:q3}),D4=W0.extend({method:j("tasks/get"),params:q0.extend({taskId:F()})}),A4=G0.merge($6),F4=W0.extend({method:j("tasks/result"),params:q0.extend({taskId:F()})}),AZ=G0.loose(),L4=G6.extend({method:j("tasks/list")}),U4=J6.extend({tasks:x($6)}),O4=W0.extend({method:j("tasks/cancel"),params:q0.extend({taskId:F()})}),AG=G0.merge($6),FG=N({uri:F(),mimeType:a(F()),_meta:t(F(),o()).optional()}),LG=FG.extend({text:F()}),eQ=F().refine((Q)=>{try{return atob(Q),!0}catch{return!1}},{message:"Invalid Base64 string"}),UG=FG.extend({blob:eQ}),H6=F0(["user","assistant"]),I1=N({audience:x(H6).optional(),priority:m().min(0).max(1).optional(),lastModified:Q6.datetime({offset:!0}).optional()}),OG=N({...b1.shape,...W6.shape,uri:F(),description:a(F()),mimeType:a(F()),annotations:I1.optional(),_meta:a(B0({}))}),Z3=N({...b1.shape,...W6.shape,uriTemplate:F(),description:a(F()),mimeType:a(F()),annotations:I1.optional(),_meta:a(B0({}))}),Q9=G6.extend({method:j("resources/list")}),N3=J6.extend({resources:x(OG)}),w3=G6.extend({method:j("resources/templates/list")}),j3=J6.extend({resourceTemplates:x(Z3)}),X9=q0.extend({uri:F()}),P3=X9,Y9=W0.extend({method:j("resources/read"),params:P3}),b3=G0.extend({contents:x(p([LG,UG]))}),E3=w0.extend({method:j("notifications/resources/list_changed"),params:N0.optional()}),I3=X9,T3=W0.extend({method:j("resources/subscribe"),params:I3}),S3=X9,R3=W0.extend({method:j("resources/unsubscribe"),params:S3}),C3=N0.extend({uri:F()}),k3=w0.extend({method:j("notifications/resources/updated"),params:C3}),v3=N({name:F(),description:a(F()),required:a(Q0())}),x3=N({...b1.shape,...W6.shape,description:a(F()),arguments:a(x(v3)),_meta:a(B0({}))}),_3=G6.extend({method:j("prompts/list")}),y3=J6.extend({prompts:x(x3)}),h3=q0.extend({name:F(),arguments:t(F(),F()).optional()}),u3=W0.extend({method:j("prompts/get"),params:h3}),W9=N({type:j("text"),text:F(),annotations:I1.optional(),_meta:t(F(),o()).optional()}),G9=N({type:j("image"),data:eQ,mimeType:F(),annotations:I1.optional(),_meta:t(F(),o()).optional()}),J9=N({type:j("audio"),data:eQ,mimeType:F(),annotations:I1.optional(),_meta:t(F(),o()).optional()}),g3=N({type:j("tool_use"),name:F(),id:F(),input:t(F(),o()),_meta:t(F(),o()).optional()}),f3=N({type:j("resource"),resource:p([LG,UG]),annotations:I1.optional(),_meta:t(F(),o()).optional()}),m3=OG.extend({type:j("resource_link")}),$9=p([W9,G9,J9,m3,f3]),l3=N({role:H6,content:$9}),c3=G0.extend({description:F().optional(),messages:x(l3)}),p3=w0.extend({method:j("notifications/prompts/list_changed"),params:N0.optional()}),i3=N({title:F().optional(),readOnlyHint:Q0().optional(),destructiveHint:Q0().optional(),idempotentHint:Q0().optional(),openWorldHint:Q0().optional()}),n3=N({taskSupport:F0(["required","optional","forbidden"]).optional()}),MG=N({...b1.shape,...W6.shape,description:F().optional(),inputSchema:N({type:j("object"),properties:t(F(),Y0).optional(),required:x(F()).optional()}).catchall(o()),outputSchema:N({type:j("object"),properties:t(F(),Y0).optional(),required:x(F()).optional()}).catchall(o()).optional(),annotations:i3.optional(),execution:n3.optional(),_meta:t(F(),o()).optional()}),z9=G6.extend({method:j("tools/list")}),d3=J6.extend({tools:x(MG)}),M4=G0.extend({content:x($9).default([]),structuredContent:t(F(),o()).optional(),isError:Q0().optional()}),FZ=M4.or(G0.extend({toolResult:o()})),r3=X6.extend({name:F(),arguments:t(F(),o()).optional()}),K6=W0.extend({method:j("tools/call"),params:r3}),o3=w0.extend({method:j("notifications/tools/list_changed"),params:N0.optional()}),LZ=N({autoRefresh:Q0().default(!0),debounceMs:m().int().nonnegative().default(300)}),B6=F0(["debug","info","notice","warning","error","critical","alert","emergency"]),t3=q0.extend({level:B6}),H9=W0.extend({method:j("logging/setLevel"),params:t3}),a3=N0.extend({level:B6,logger:F().optional(),data:o()}),s3=w0.extend({method:j("notifications/message"),params:a3}),e3=N({name:F().optional()}),QK=N({hints:x(e3).optional(),costPriority:m().min(0).max(1).optional(),speedPriority:m().min(0).max(1).optional(),intelligencePriority:m().min(0).max(1).optional()}),XK=N({mode:F0(["auto","required","none"]).optional()}),YK=N({type:j("tool_result"),toolUseId:F().describe("The unique identifier for the corresponding tool call."),content:x($9).default([]),structuredContent:N({}).loose().optional(),isError:Q0().optional(),_meta:t(F(),o()).optional()}),WK=pQ("type",[W9,G9,J9]),G4=pQ("type",[W9,G9,J9,g3,YK]),GK=N({role:H6,content:p([G4,x(G4)]),_meta:t(F(),o()).optional()}),JK=X6.extend({messages:x(GK),modelPreferences:QK.optional(),systemPrompt:F().optional(),includeContext:F0(["none","thisServer","allServers"]).optional(),temperature:m().optional(),maxTokens:m().int(),stopSequences:x(F()).optional(),metadata:Y0.optional(),tools:x(MG).optional(),toolChoice:XK.optional()}),$K=W0.extend({method:j("sampling/createMessage"),params:JK}),K9=G0.extend({model:F(),stopReason:a(F0(["endTurn","stopSequence","maxTokens"]).or(F())),role:H6,content:WK}),B9=G0.extend({model:F(),stopReason:a(F0(["endTurn","stopSequence","maxTokens","toolUse"]).or(F())),role:H6,content:p([G4,x(G4)])}),zK=N({type:j("boolean"),title:F().optional(),description:F().optional(),default:Q0().optional()}),HK=N({type:j("string"),title:F().optional(),description:F().optional(),minLength:m().optional(),maxLength:m().optional(),format:F0(["email","uri","date","date-time"]).optional(),default:F().optional()}),KK=N({type:F0(["number","integer"]),title:F().optional(),description:F().optional(),minimum:m().optional(),maximum:m().optional(),default:m().optional()}),BK=N({type:j("string"),title:F().optional(),description:F().optional(),enum:x(F()),default:F().optional()}),DK=N({type:j("string"),title:F().optional(),description:F().optional(),oneOf:x(N({const:F(),title:F()})),default:F().optional()}),AK=N({type:j("string"),title:F().optional(),description:F().optional(),enum:x(F()),enumNames:x(F()).optional(),default:F().optional()}),FK=p([BK,DK]),LK=N({type:j("array"),title:F().optional(),description:F().optional(),minItems:m().optional(),maxItems:m().optional(),items:N({type:j("string"),enum:x(F())}),default:x(F()).optional()}),UK=N({type:j("array"),title:F().optional(),description:F().optional(),minItems:m().optional(),maxItems:m().optional(),items:N({anyOf:x(N({const:F(),title:F()}))}),default:x(F()).optional()}),OK=p([LK,UK]),MK=p([AK,FK,OK]),VK=p([MK,zK,HK,KK]),qK=X6.extend({mode:j("form").optional(),message:F(),requestedSchema:N({type:j("object"),properties:t(F(),VK),required:x(F()).optional()})}),ZK=X6.extend({mode:j("url"),message:F(),elicitationId:F(),url:F().url()}),NK=p([qK,ZK]),wK=W0.extend({method:j("elicitation/create"),params:NK}),jK=N0.extend({elicitationId:F()}),PK=w0.extend({method:j("notifications/elicitation/complete"),params:jK}),V4=G0.extend({action:F0(["accept","decline","cancel"]),content:iQ((Q)=>Q===null?void 0:Q,t(F(),p([F(),m(),Q0(),x(F())])).optional())}),bK=N({type:j("ref/resource"),uri:F()});var EK=N({type:j("ref/prompt"),name:F()}),IK=q0.extend({ref:p([EK,bK]),argument:N({name:F(),value:F()}),context:N({arguments:t(F(),F()).optional()}).optional()}),TK=W0.extend({method:j("completion/complete"),params:IK});var SK=G0.extend({completion:B0({values:x(F()).max(100),total:a(m().int()),hasMore:a(Q0())})}),RK=N({uri:F().startsWith("file://"),name:F().optional(),_meta:t(F(),o()).optional()}),CK=W0.extend({method:j("roots/list"),params:q0.optional()}),D9=G0.extend({roots:x(RK)}),kK=w0.extend({method:j("notifications/roots/list_changed"),params:N0.optional()}),UZ=p([K4,aQ,TK,H9,u3,_3,Q9,w3,Y9,T3,R3,K6,z9,D4,F4,L4,O4]),OZ=p([H4,B4,sQ,kK,z6]),MZ=p([z4,K9,B9,V4,D9,A4,U4,E1]),VZ=p([K4,$K,wK,CK,D4,F4,L4,O4]),qZ=p([H4,B4,s3,k3,E3,o3,p3,z6,PK]),ZZ=p([z4,L3,SK,c3,y3,N3,j3,b3,M4,d3,A4,U4,E1]);class C extends Error{constructor(Q,X,Y){super(`MCP error ${Q}: ${X}`);this.code=Q,this.data=Y,this.name="McpError"}static fromError(Q,X,Y){if(Q===_.UrlElicitationRequired&&Y){let W=Y;if(W.elicitations)return new VG(W.elicitations,X)}return new C(Q,X,Y)}}class VG extends C{constructor(Q,X=`URL elicitation${Q.length>1?"s":""} required`){super(_.UrlElicitationRequired,X,{elicitations:Q})}get elicitations(){return this.data?.elicitations??[]}}function X1(Q){return Q==="completed"||Q==="failed"||Q==="cancelled"}var vK=Symbol("Let zodToJsonSchema decide on which parser to use");var eZ=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function A9(Q){let Y=X4(Q)?.method;if(!Y)throw Error("Schema is missing a method literal");let W=EW(Y);if(typeof W!=="string")throw Error("Schema method literal must be a string");return W}function F9(Q,X){let Y=e0(Q,X);if(!Y.success)throw Y.error;return Y.data}var gK=60000;class L9{constructor(Q){if(this._options=Q,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(H4,(X)=>{this._oncancel(X)}),this.setNotificationHandler(B4,(X)=>{this._onprogress(X)}),this.setRequestHandler(K4,(X)=>({})),this._taskStore=Q?.taskStore,this._taskMessageQueue=Q?.taskMessageQueue,this._taskStore)this.setRequestHandler(D4,async(X,Y)=>{let W=await this._taskStore.getTask(X.params.taskId,Y.sessionId);if(!W)throw new C(_.InvalidParams,"Failed to retrieve task: Task not found");return{...W}}),this.setRequestHandler(F4,async(X,Y)=>{let W=async()=>{let G=X.params.taskId;if(this._taskMessageQueue){let $;while($=await this._taskMessageQueue.dequeue(G,Y.sessionId)){if($.type==="response"||$.type==="error"){let z=$.message,H=z.id,K=this._requestResolvers.get(H);if(K)if(this._requestResolvers.delete(H),$.type==="response")K(z);else{let B=z,D=new C(B.error.code,B.error.message,B.error.data);K(D)}else{let B=$.type==="response"?"Response":"Error";this._onerror(Error(`${B} handler missing for request ${H}`))}continue}await this._transport?.send($.message,{relatedRequestId:Y.requestId})}}let J=await this._taskStore.getTask(G,Y.sessionId);if(!J)throw new C(_.InvalidParams,`Task not found: ${G}`);if(!X1(J.status))return await this._waitForTaskUpdate(G,Y.signal),await W();if(X1(J.status)){let $=await this._taskStore.getTaskResult(G,Y.sessionId);return this._clearTaskQueue(G),{...$,_meta:{...$._meta,[Q1]:{taskId:G}}}}return await W()};return await W()}),this.setRequestHandler(L4,async(X,Y)=>{try{let{tasks:W,nextCursor:G}=await this._taskStore.listTasks(X.params?.cursor,Y.sessionId);return{tasks:W,nextCursor:G,_meta:{}}}catch(W){throw new C(_.InvalidParams,`Failed to list tasks: ${W instanceof Error?W.message:String(W)}`)}}),this.setRequestHandler(O4,async(X,Y)=>{try{let W=await this._taskStore.getTask(X.params.taskId,Y.sessionId);if(!W)throw new C(_.InvalidParams,`Task not found: ${X.params.taskId}`);if(X1(W.status))throw new C(_.InvalidParams,`Cannot cancel task in terminal status: ${W.status}`);await this._taskStore.updateTaskStatus(X.params.taskId,"cancelled","Client cancelled task execution.",Y.sessionId),this._clearTaskQueue(X.params.taskId);let G=await this._taskStore.getTask(X.params.taskId,Y.sessionId);if(!G)throw new C(_.InvalidParams,`Task not found after cancellation: ${X.params.taskId}`);return{_meta:{},...G}}catch(W){if(W instanceof C)throw W;throw new C(_.InvalidRequest,`Failed to cancel task: ${W instanceof Error?W.message:String(W)}`)}})}async _oncancel(Q){if(!Q.params.requestId)return;this._requestHandlerAbortControllers.get(Q.params.requestId)?.abort(Q.params.reason)}_setupTimeout(Q,X,Y,W,G=!1){this._timeoutInfo.set(Q,{timeoutId:setTimeout(W,X),startTime:Date.now(),timeout:X,maxTotalTimeout:Y,resetTimeoutOnProgress:G,onTimeout:W})}_resetTimeout(Q){let X=this._timeoutInfo.get(Q);if(!X)return!1;let Y=Date.now()-X.startTime;if(X.maxTotalTimeout&&Y>=X.maxTotalTimeout)throw this._timeoutInfo.delete(Q),C.fromError(_.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:X.maxTotalTimeout,totalElapsed:Y});return clearTimeout(X.timeoutId),X.timeoutId=setTimeout(X.onTimeout,X.timeout),!0}_cleanupTimeout(Q){let X=this._timeoutInfo.get(Q);if(X)clearTimeout(X.timeoutId),this._timeoutInfo.delete(Q)}async connect(Q){this._transport=Q;let X=this.transport?.onclose;this._transport.onclose=()=>{X?.(),this._onclose()};let Y=this.transport?.onerror;this._transport.onerror=(G)=>{Y?.(G),this._onerror(G)};let W=this._transport?.onmessage;this._transport.onmessage=(G,J)=>{if(W?.(G,J),Y6(G)||KG(G))this._onresponse(G);else if(rQ(G))this._onrequest(G,J);else if(HG(G))this._onnotification(G);else this._onerror(Error(`Unknown message type: ${JSON.stringify(G)}`))},await this._transport.start()}_onclose(){let Q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();let X=C.fromError(_.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let Y of Q.values())Y(X)}_onerror(Q){this.onerror?.(Q)}_onnotification(Q){let X=this._notificationHandlers.get(Q.method)??this.fallbackNotificationHandler;if(X===void 0)return;Promise.resolve().then(()=>X(Q)).catch((Y)=>this._onerror(Error(`Uncaught error in notification handler: ${Y}`)))}_onrequest(Q,X){let Y=this._requestHandlers.get(Q.method)??this.fallbackRequestHandler,W=this._transport,G=Q.params?._meta?.[Q1]?.taskId;if(Y===void 0){let K={jsonrpc:"2.0",id:Q.id,error:{code:_.MethodNotFound,message:"Method not found"}};if(G&&this._taskMessageQueue)this._enqueueTaskMessage(G,{type:"error",message:K,timestamp:Date.now()},W?.sessionId).catch((B)=>this._onerror(Error(`Failed to enqueue error response: ${B}`)));else W?.send(K).catch((B)=>this._onerror(Error(`Failed to send an error response: ${B}`)));return}let J=new AbortController;this._requestHandlerAbortControllers.set(Q.id,J);let $=JG(Q.params)?Q.params.task:void 0,z=this._taskStore?this.requestTaskStore(Q,W?.sessionId):void 0,H={signal:J.signal,sessionId:W?.sessionId,_meta:Q.params?._meta,sendNotification:async(K)=>{let B={relatedRequestId:Q.id};if(G)B.relatedTask={taskId:G};await this.notification(K,B)},sendRequest:async(K,B,D)=>{let A={...D,relatedRequestId:Q.id};if(G&&!A.relatedTask)A.relatedTask={taskId:G};let U=A.relatedTask?.taskId??G;if(U&&z)await z.updateTaskStatus(U,"input_required");return await this.request(K,B,A)},authInfo:X?.authInfo,requestId:Q.id,requestInfo:X?.requestInfo,taskId:G,taskStore:z,taskRequestedTtl:$?.ttl,closeSSEStream:X?.closeSSEStream,closeStandaloneSSEStream:X?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if($)this.assertTaskHandlerCapability(Q.method)}).then(()=>Y(Q,H)).then(async(K)=>{if(J.signal.aborted)return;let B={result:K,jsonrpc:"2.0",id:Q.id};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"response",message:B,timestamp:Date.now()},W?.sessionId);else await W?.send(B)},async(K)=>{if(J.signal.aborted)return;let B={jsonrpc:"2.0",id:Q.id,error:{code:Number.isSafeInteger(K.code)?K.code:_.InternalError,message:K.message??"Internal error",...K.data!==void 0&&{data:K.data}}};if(G&&this._taskMessageQueue)await this._enqueueTaskMessage(G,{type:"error",message:B,timestamp:Date.now()},W?.sessionId);else await W?.send(B)}).catch((K)=>this._onerror(Error(`Failed to send response: ${K}`))).finally(()=>{this._requestHandlerAbortControllers.delete(Q.id)})}_onprogress(Q){let{progressToken:X,...Y}=Q.params,W=Number(X),G=this._progressHandlers.get(W);if(!G){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(Q)}`));return}let J=this._responseHandlers.get(W),$=this._timeoutInfo.get(W);if($&&J&&$.resetTimeoutOnProgress)try{this._resetTimeout(W)}catch(z){this._responseHandlers.delete(W),this._progressHandlers.delete(W),this._cleanupTimeout(W),J(z);return}G(Y)}_onresponse(Q){let X=Number(Q.id),Y=this._requestResolvers.get(X);if(Y){if(this._requestResolvers.delete(X),Y6(Q))Y(Q);else{let J=new C(Q.error.code,Q.error.message,Q.error.data);Y(J)}return}let W=this._responseHandlers.get(X);if(W===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(Q)}`));return}this._responseHandlers.delete(X),this._cleanupTimeout(X);let G=!1;if(Y6(Q)&&Q.result&&typeof Q.result==="object"){let J=Q.result;if(J.task&&typeof J.task==="object"){let $=J.task;if(typeof $.taskId==="string")G=!0,this._taskProgressTokens.set($.taskId,X)}}if(!G)this._progressHandlers.delete(X);if(Y6(Q))W(Q);else{let J=C.fromError(Q.error.code,Q.error.message,Q.error.data);W(J)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(Q,X,Y){let{task:W}=Y??{};if(!W){try{yield{type:"result",result:await this.request(Q,X,Y)}}catch(J){yield{type:"error",error:J instanceof C?J:new C(_.InternalError,String(J))}}return}let G;try{let J=await this.request(Q,E1,Y);if(J.task)G=J.task.taskId,yield{type:"taskCreated",task:J.task};else throw new C(_.InternalError,"Task creation did not return a task");while(!0){let $=await this.getTask({taskId:G},Y);if(yield{type:"taskStatus",task:$},X1($.status)){if($.status==="completed")yield{type:"result",result:await this.getTaskResult({taskId:G},X,Y)};else if($.status==="failed")yield{type:"error",error:new C(_.InternalError,`Task ${G} failed`)};else if($.status==="cancelled")yield{type:"error",error:new C(_.InternalError,`Task ${G} was cancelled`)};return}if($.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:G},X,Y)};return}let z=$.pollInterval??this._options?.defaultTaskPollInterval??1000;await new Promise((H)=>setTimeout(H,z)),Y?.signal?.throwIfAborted()}}catch(J){yield{type:"error",error:J instanceof C?J:new C(_.InternalError,String(J))}}}request(Q,X,Y){let{relatedRequestId:W,resumptionToken:G,onresumptiontoken:J,task:$,relatedTask:z}=Y??{};return new Promise((H,K)=>{let B=(V)=>{K(V)};if(!this._transport){B(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{if(this.assertCapabilityForMethod(Q.method),$)this.assertTaskCapability(Q.method)}catch(V){B(V);return}Y?.signal?.throwIfAborted();let D=this._requestMessageId++,A={...Q,jsonrpc:"2.0",id:D};if(Y?.onprogress)this._progressHandlers.set(D,Y.onprogress),A.params={...Q.params,_meta:{...Q.params?._meta||{},progressToken:D}};if($)A.params={...A.params,task:$};if(z)A.params={...A.params,_meta:{...A.params?._meta||{},[Q1]:z}};let U=(V)=>{this._responseHandlers.delete(D),this._progressHandlers.delete(D),this._cleanupTimeout(D),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:D,reason:String(V)}},{relatedRequestId:W,resumptionToken:G,onresumptiontoken:J}).catch((E)=>this._onerror(Error(`Failed to send cancellation: ${E}`)));let T=V instanceof C?V:new C(_.RequestTimeout,String(V));K(T)};this._responseHandlers.set(D,(V)=>{if(Y?.signal?.aborted)return;if(V instanceof Error)return K(V);try{let T=e0(X,V.result);if(!T.success)K(T.error);else H(T.data)}catch(T){K(T)}}),Y?.signal?.addEventListener("abort",()=>{U(Y?.signal?.reason)});let O=Y?.timeout??gK,M=()=>U(C.fromError(_.RequestTimeout,"Request timed out",{timeout:O}));this._setupTimeout(D,O,Y?.maxTotalTimeout,M,Y?.resetTimeoutOnProgress??!1);let q=z?.taskId;if(q){let V=(T)=>{let E=this._responseHandlers.get(D);if(E)E(T);else this._onerror(Error(`Response handler missing for side-channeled request ${D}`))};this._requestResolvers.set(D,V),this._enqueueTaskMessage(q,{type:"request",message:A,timestamp:Date.now()}).catch((T)=>{this._cleanupTimeout(D),K(T)})}else this._transport.send(A,{relatedRequestId:W,resumptionToken:G,onresumptiontoken:J}).catch((V)=>{this._cleanupTimeout(D),K(V)})})}async getTask(Q,X){return this.request({method:"tasks/get",params:Q},A4,X)}async getTaskResult(Q,X,Y){return this.request({method:"tasks/result",params:Q},X,Y)}async listTasks(Q,X){return this.request({method:"tasks/list",params:Q},U4,X)}async cancelTask(Q,X){return this.request({method:"tasks/cancel",params:Q},AG,X)}async notification(Q,X){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability(Q.method);let Y=X?.relatedTask?.taskId;if(Y){let $={...Q,jsonrpc:"2.0",params:{...Q.params,_meta:{...Q.params?._meta||{},[Q1]:X.relatedTask}}};await this._enqueueTaskMessage(Y,{type:"notification",message:$,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(Q.method)&&!Q.params&&!X?.relatedRequestId&&!X?.relatedTask){if(this._pendingDebouncedNotifications.has(Q.method))return;this._pendingDebouncedNotifications.add(Q.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(Q.method),!this._transport)return;let $={...Q,jsonrpc:"2.0"};if(X?.relatedTask)$={...$,params:{...$.params,_meta:{...$.params?._meta||{},[Q1]:X.relatedTask}}};this._transport?.send($,X).catch((z)=>this._onerror(z))});return}let J={...Q,jsonrpc:"2.0"};if(X?.relatedTask)J={...J,params:{...J.params,_meta:{...J.params?._meta||{},[Q1]:X.relatedTask}}};await this._transport.send(J,X)}setRequestHandler(Q,X){let Y=A9(Q);this.assertRequestHandlerCapability(Y),this._requestHandlers.set(Y,(W,G)=>{let J=F9(Q,W);return Promise.resolve(X(J,G))})}removeRequestHandler(Q){this._requestHandlers.delete(Q)}assertCanSetRequestHandler(Q){if(this._requestHandlers.has(Q))throw Error(`A request handler for ${Q} already exists, which would be overridden`)}setNotificationHandler(Q,X){let Y=A9(Q);this._notificationHandlers.set(Y,(W)=>{let G=F9(Q,W);return Promise.resolve(X(G))})}removeNotificationHandler(Q){this._notificationHandlers.delete(Q)}_cleanupTaskProgressHandler(Q){let X=this._taskProgressTokens.get(Q);if(X!==void 0)this._progressHandlers.delete(X),this._taskProgressTokens.delete(Q)}async _enqueueTaskMessage(Q,X,Y){if(!this._taskStore||!this._taskMessageQueue)throw Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let W=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(Q,X,Y,W)}async _clearTaskQueue(Q,X){if(this._taskMessageQueue){let Y=await this._taskMessageQueue.dequeueAll(Q,X);for(let W of Y)if(W.type==="request"&&rQ(W.message)){let G=W.message.id,J=this._requestResolvers.get(G);if(J)J(new C(_.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(G);else this._onerror(Error(`Resolver missing for request ${G} during task ${Q} cleanup`))}}}async _waitForTaskUpdate(Q,X){let Y=this._options?.defaultTaskPollInterval??1000;try{let W=await this._taskStore?.getTask(Q);if(W?.pollInterval)Y=W.pollInterval}catch{}return new Promise((W,G)=>{if(X.aborted){G(new C(_.InvalidRequest,"Request cancelled"));return}let J=setTimeout(W,Y);X.addEventListener("abort",()=>{clearTimeout(J),G(new C(_.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(Q,X){let Y=this._taskStore;if(!Y)throw Error("No task store configured");return{createTask:async(W)=>{if(!Q)throw Error("No request provided");return await Y.createTask(W,Q.id,{method:Q.method,params:Q.params},X)},getTask:async(W)=>{let G=await Y.getTask(W,X);if(!G)throw new C(_.InvalidParams,"Failed to retrieve task: Task not found");return G},storeTaskResult:async(W,G,J)=>{await Y.storeTaskResult(W,G,J,X);let $=await Y.getTask(W,X);if($){let z=z6.parse({method:"notifications/tasks/status",params:$});if(await this.notification(z),X1($.status))this._cleanupTaskProgressHandler(W)}},getTaskResult:(W)=>{return Y.getTaskResult(W,X)},updateTaskStatus:async(W,G,J)=>{let $=await Y.getTask(W,X);if(!$)throw new C(_.InvalidParams,`Task "${W}" not found - it may have been cleaned up`);if(X1($.status))throw new C(_.InvalidParams,`Cannot update task "${W}" from terminal status "${$.status}" to "${G}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await Y.updateTaskStatus(W,G,J,X);let z=await Y.getTask(W,X);if(z){let H=z6.parse({method:"notifications/tasks/status",params:z});if(await this.notification(H),X1(z.status))this._cleanupTaskProgressHandler(W)}},listTasks:(W)=>{return Y.listTasks(W,X)}}}}function qG(Q){return Q!==null&&typeof Q==="object"&&!Array.isArray(Q)}function ZG(Q,X){let Y={...Q};for(let W in X){let G=W,J=X[G];if(J===void 0)continue;let $=Y[G];if(qG($)&&qG(J))Y[G]={...$,...J};else Y[G]=J}return Y}var a7=RX(HX(),1),s7=RX(t7(),1);function rM(){let Q=new a7.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return s7.default(Q),Q}class VX{constructor(Q){this._ajv=Q??rM()}getValidator(Q){let X="$id"in Q&&typeof Q.$id==="string"?this._ajv.getSchema(Q.$id)??this._ajv.compile(Q):this._ajv.compile(Q);return(Y)=>{if(X(Y))return{valid:!0,data:Y,errorMessage:void 0};else return{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(X.errors)}}}}class qX{constructor(Q){this._server=Q}requestStream(Q,X,Y){return this._server.requestStream(Q,X,Y)}async getTask(Q,X){return this._server.getTask({taskId:Q},X)}async getTaskResult(Q,X,Y){return this._server.getTaskResult({taskId:Q},X,Y)}async listTasks(Q,X){return this._server.listTasks(Q?{cursor:Q}:void 0,X)}async cancelTask(Q,X){return this._server.cancelTask({taskId:Q},X)}}function e7(Q,X,Y){if(!Q)throw Error(`${Y} does not support task creation (required for ${X})`);switch(X){case"tools/call":if(!Q.tools?.call)throw Error(`${Y} does not support task creation for tools/call (required for ${X})`);break;default:break}}function Q5(Q,X,Y){if(!Q)throw Error(`${Y} does not support task creation (required for ${X})`);switch(X){case"sampling/createMessage":if(!Q.sampling?.createMessage)throw Error(`${Y} does not support task creation for sampling/createMessage (required for ${X})`);break;case"elicitation/create":if(!Q.elicitation?.create)throw Error(`${Y} does not support task creation for elicitation/create (required for ${X})`);break;default:break}}class ZX extends L9{constructor(Q,X){super(X);if(this._serverInfo=Q,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(B6.options.map((Y,W)=>[Y,W])),this.isMessageIgnored=(Y,W)=>{let G=this._loggingLevels.get(W);return G?this.LOG_LEVEL_SEVERITY.get(Y)<this.LOG_LEVEL_SEVERITY.get(G):!1},this._capabilities=X?.capabilities??{},this._instructions=X?.instructions,this._jsonSchemaValidator=X?.jsonSchemaValidator??new VX,this.setRequestHandler(aQ,(Y)=>this._oninitialize(Y)),this.setNotificationHandler(sQ,()=>this.oninitialized?.()),this._capabilities.logging)this.setRequestHandler(H9,async(Y,W)=>{let G=W.sessionId||W.requestInfo?.headers["mcp-session-id"]||void 0,{level:J}=Y.params,$=B6.safeParse(J);if($.success)this._loggingLevels.set(G,$.data);return{}})}get experimental(){if(!this._experimental)this._experimental={tasks:new qX(this)};return this._experimental}registerCapabilities(Q){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=ZG(this._capabilities,Q)}setRequestHandler(Q,X){let W=X4(Q)?.method;if(!W)throw Error("Schema is missing a method literal");let G;if(P1(W)){let $=W;G=$._zod?.def?.value??$.value}else{let $=W;G=$._def?.value??$.value}if(typeof G!=="string")throw Error("Schema method literal must be a string");if(G==="tools/call"){let $=async(z,H)=>{let K=e0(K6,z);if(!K.success){let U=K.error instanceof Error?K.error.message:String(K.error);throw new C(_.InvalidParams,`Invalid tools/call request: ${U}`)}let{params:B}=K.data,D=await Promise.resolve(X(z,H));if(B.task){let U=e0(E1,D);if(!U.success){let O=U.error instanceof Error?U.error.message:String(U.error);throw new C(_.InvalidParams,`Invalid task creation result: ${O}`)}return U.data}let A=e0(M4,D);if(!A.success){let U=A.error instanceof Error?A.error.message:String(A.error);throw new C(_.InvalidParams,`Invalid tools/call result: ${U}`)}return A.data};return super.setRequestHandler(Q,$)}return super.setRequestHandler(Q,X)}assertCapabilityForMethod(Q){switch(Q){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${Q})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${Q})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${Q})`);break;case"ping":break}}assertNotificationCapability(Q){switch(Q){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${Q})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${Q})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${Q})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${Q})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(Q){if(!this._capabilities)return;switch(Q){case"completion/complete":if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${Q})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${Q})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${Q})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${Q})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${Q})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${Q})`);break;case"ping":case"initialize":break}}assertTaskCapability(Q){Q5(this._clientCapabilities?.tasks?.requests,Q,"Client")}assertTaskHandlerCapability(Q){if(!this._capabilities)return;e7(this._capabilities.tasks?.requests,Q,"Server")}async _oninitialize(Q){let X=Q.params.protocolVersion;return this._clientCapabilities=Q.params.capabilities,this._clientVersion=Q.params.clientInfo,{protocolVersion:YG.includes(X)?X:nQ,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},z4)}async createMessage(Q,X){if(Q.tools||Q.toolChoice){if(!this._clientCapabilities?.sampling?.tools)throw Error("Client does not support sampling tools capability.")}if(Q.messages.length>0){let Y=Q.messages[Q.messages.length-1],W=Array.isArray(Y.content)?Y.content:[Y.content],G=W.some((H)=>H.type==="tool_result"),J=Q.messages.length>1?Q.messages[Q.messages.length-2]:void 0,$=J?Array.isArray(J.content)?J.content:[J.content]:[],z=$.some((H)=>H.type==="tool_use");if(G){if(W.some((H)=>H.type!=="tool_result"))throw Error("The last message must contain only tool_result content if any is present");if(!z)throw Error("tool_result blocks are not matching any tool_use from the previous message")}if(z){let H=new Set($.filter((B)=>B.type==="tool_use").map((B)=>B.id)),K=new Set(W.filter((B)=>B.type==="tool_result").map((B)=>B.toolUseId));if(H.size!==K.size||![...H].every((B)=>K.has(B)))throw Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}if(Q.tools)return this.request({method:"sampling/createMessage",params:Q},B9,X);return this.request({method:"sampling/createMessage",params:Q},K9,X)}async elicitInput(Q,X){switch(Q.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support url elicitation.");let W=Q;return this.request({method:"elicitation/create",params:W},V4,X)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw Error("Client does not support form elicitation.");let W=Q.mode==="form"?Q:{...Q,mode:"form"},G=await this.request({method:"elicitation/create",params:W},V4,X);if(G.action==="accept"&&G.content&&W.requestedSchema)try{let $=this._jsonSchemaValidator.getValidator(W.requestedSchema)(G.content);if(!$.valid)throw new C(_.InvalidParams,`Elicitation response content does not match requested schema: ${$.errorMessage}`)}catch(J){if(J instanceof C)throw J;throw new C(_.InternalError,`Error validating elicitation response: ${J instanceof Error?J.message:String(J)}`)}return G}}}createElicitationCompletionNotifier(Q,X){if(!this._clientCapabilities?.elicitation?.url)throw Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:Q}},X)}async listRoots(Q,X){return this.request({method:"roots/list",params:Q},D9,X)}async sendLoggingMessage(Q,X){if(this._capabilities.logging){if(!this.isMessageIgnored(Q.level,X))return this.notification({method:"notifications/message",params:Q})}}async sendResourceUpdated(Q){return this.notification({method:"notifications/resources/updated",params:Q})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}import Y5 from"node:process";class NX{append(Q){this._buffer=this._buffer?Buffer.concat([this._buffer,Q]):Q}readMessage(){if(!this._buffer)return null;let Q=this._buffer.indexOf(`
|
|
29
29
|
`);if(Q===-1)return null;let X=this._buffer.toString("utf8",0,Q).replace(/\r$/,"");return this._buffer=this._buffer.subarray(Q+1),oM(X)}clear(){this._buffer=void 0}}function oM(Q){return BG.parse(JSON.parse(Q))}function X5(Q){return JSON.stringify(Q)+`
|
|
30
|
-
`}class wX{constructor(Q=Y5.stdin,X=Y5.stdout){this._stdin=Q,this._stdout=X,this._readBuffer=new NX,this._started=!1,this._ondata=(Y)=>{this._readBuffer.append(Y),this.processReadBuffer()},this._onerror=(Y)=>{this.onerror?.(Y)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let Q=this._readBuffer.readMessage();if(Q===null)break;this.onmessage?.(Q)}catch(Q){this.onerror?.(Q)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(Q){return new Promise((X)=>{let Y=X5(Q);if(this._stdout.write(Y))X();else this._stdout.once("drain",X)})}}var W5={name:"@sequenzy/mcp",version:"0.0.
|
|
30
|
+
`}class wX{constructor(Q=Y5.stdin,X=Y5.stdout){this._stdin=Q,this._stdout=X,this._readBuffer=new NX,this._started=!1,this._ondata=(Y)=>{this._readBuffer.append(Y),this.processReadBuffer()},this._onerror=(Y)=>{this.onerror?.(Y)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let Q=this._readBuffer.readMessage();if(Q===null)break;this.onmessage?.(Q)}catch(Q){this.onerror?.(Q)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(Q){return new Promise((X)=>{let Y=X5(Q);if(this._stdout.write(Y))X();else this._stdout.once("drain",X)})}}var W5={name:"@sequenzy/mcp",version:"0.0.21",mcpName:"io.github.polnikale/sequenzy-mcp",description:"Sequenzy MCP server for AI-powered email marketing automation",type:"module",bin:{"sequenzy-mcp":"dist/index.js"},main:"./dist/index.js",exports:{".":"./dist/index.js","./server.json":"./server.json"},scripts:{dev:"bun --watch src/index.ts",build:"bun build src/index.ts --outdir dist --target node --minify",start:"node dist/index.js","type-check":"tsc --noEmit",test:"bun test","test:watch":"bun test --watch",prepublishOnly:"bun run build"},dependencies:{"@modelcontextprotocol/sdk":"^1.0.0"},devDependencies:{"@types/bun":"latest","@types/node":"^22.0.0","bun-types":"latest",typescript:"^5.8.0"},files:["dist","server.json"],keywords:["sequenzy","email","mcp","ai","claude","automation"],license:"MIT",publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/sequenzy/sequenzy.git"}};class g1 extends Error{statusCode;rawDetails;code;constructor(Q,X,Y,W){super(Q);this.statusCode=X;this.rawDetails=Y;this.code=W;this.name="McpApiError"}}function aM(Q){if(Q instanceof g1)return{message:Q.message,statusCode:Q.statusCode,code:Q.code,rawDetails:Q.rawDetails};if(Q instanceof Error)return{message:Q.message};return{message:String(Q)}}function sM(Q){let X=aM(Q),Y=X.message.trim()||"Unknown error",W=Y.toLowerCase(),G=X.rawDetails?.trim()||Y;if(X.code==="MCP_AUTH_REQUIRED"||W.includes("sequenzy_api_key environment variable is required"))return{title:"Missing MCP API key",description:"The MCP server started without a Sequenzy API key, so it cannot authenticate any tool or resource request.",howToFix:"Add `SEQUENZY_API_KEY` to the MCP server environment, or run `npx @sequenzy/setup` to configure the integration automatically.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(X.statusCode===401||X.code==="UNAUTHORIZED")return{title:"Authentication failed",description:"The MCP server reached Sequenzy, but the current API key was rejected.",howToFix:"Replace `SEQUENZY_API_KEY` with a valid personal API key, then restart the MCP client so it reconnects with fresh credentials.",docsUrl:"https://docs.sequenzy.com/authentication",details:G};if(X.statusCode===403||W.includes("access denied"))return{title:"Access denied",description:"The current API key is valid, but it does not have permission to access the requested company or action.",howToFix:"Use an API key that belongs to the right account, or select a company the key can access before retrying the tool call.",docsUrl:"https://docs.sequenzy.com/authentication",details:G};if(W.includes("no company available")||W.includes("company not found"))return{title:"Company selection required",description:"The MCP server could not resolve a company for this request.",howToFix:"Call `get_account` to inspect available companies, then call `select_company`, or pass `companyId` explicitly in the next tool call.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(X.statusCode===404||W.includes("not found"))return{title:"Requested resource not found",description:"Sequenzy could not find the requested campaign, template, sequence, company, or subscriber.",howToFix:"List or fetch the resource collection first, then retry the tool with a confirmed ID or email value.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(X.statusCode===429||W.includes("rate limit"))return{title:"Rate limited",description:"Sequenzy temporarily slowed this MCP request because too many requests were sent too quickly.",howToFix:"Wait briefly before retrying. If the client is looping, reduce retries or add backoff before the next tool call.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(X.code==="NETWORK_ERROR"||W.includes("fetch failed"))return{title:"Network or configuration error",description:"The MCP server could not reach the Sequenzy API from this environment.",howToFix:"Check connectivity and verify `SEQUENZY_API_URL` if you override it in the MCP environment.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(W.includes("unknown tool")||W.includes("unknown resource"))return{title:"Unsupported MCP request",description:"The client asked for a tool or resource name that this Sequenzy MCP server does not expose.",howToFix:"Refresh the client's tool list and call only the names returned by `list_tools` or `list_resources`.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(W.includes("is required")||W.includes("invalid"))return{title:"Invalid MCP input",description:"The tool call was missing a required field or included an invalid value.",howToFix:"Review the tool schema, supply the missing argument, and retry the request with corrected input.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};if(X.statusCode&&X.statusCode>=500)return{title:"Sequenzy server error",description:"The request reached Sequenzy, but the server could not complete it successfully.",howToFix:"Retry once. If it still fails, keep the details below and consult the docs before escalating.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G};return{title:"Tool execution failed",description:"The MCP server could not complete the requested operation.",howToFix:"Review the details below, adjust the tool input or credentials, and retry.",docsUrl:"https://docs.sequenzy.com/concepts/mcp",details:G}}function q1(Q){let X=sM(Q);return[`Sequenzy MCP error: ${X.title}`,`Description: ${X.description}`,`How to fix: ${X.howToFix}`,`Docs: ${X.docsUrl}`,`Details: ${X.details}`].join(`
|
|
31
31
|
`)}var jX=["product-info","domain","tracking","localization","integrations","products","events","tags","labels","goals","sync-rules","api-keys","widgets","team","danger"],G5={dashboard:"/dashboard/company/{companyId}",campaigns:"/dashboard/company/{companyId}/campaign",campaign:"/dashboard/company/{companyId}/campaign/{campaignId}",campaignList:"/dashboard/company/{companyId}/campaign/list/{status}",sequences:"/dashboard/company/{companyId}/sequences",sequence:"/dashboard/company/{companyId}/sequences/{sequenceId}",sequenceList:"/dashboard/company/{companyId}/sequences/list/{status}",settings:"/dashboard/company/{companyId}/settings",settingsTab:"/dashboard/company/{companyId}/settings?tab={tab}",emails:"/dashboard/company/{companyId}/emails",email:"/dashboard/company/{companyId}/emails/{emailId}",subscribers:"/dashboard/company/{companyId}/subscribers",segments:"/dashboard/company/{companyId}/segments",metrics:"/dashboard/company/{companyId}/metrics",transactional:"/dashboard/company/{companyId}/transactional",transactionalEmail:"/dashboard/company/{companyId}/transactional/{transactionalId}",domain:"/dashboard/company/{companyId}/settings/domain/{domainId}",domainVerify:"/dashboard/company/{companyId}/settings/domain/{domainId}/verify"};function eM(Q){let Y=(Q??process.env.SEQUENZY_APP_URL??"https://sequenzy.com").trim().replace(/\/+$/,"");return Y.length>0?Y:"https://sequenzy.com"}function r0(Q){let X=Q?.trim();return X?X:void 0}function K1(Q){return encodeURIComponent(Q)}function z0(Q,X){return`${Q}${X}`}function H0(Q,X=""){return`/dashboard/company/${K1(Q)}${X}`}function J5(Q,X,Y){return z0(Q,`${H0(X,"/settings")}?tab=${encodeURIComponent(Y)}`)}function QV(Q,X){let Y=jX.map((W)=>[W,X?J5(Q,X,W):""]);return Object.fromEntries(Y)}function B1(Q={},X){let Y=eM(X),W=r0(Q.companyId),G={},J=QV(Y,W);if(!W)return{appUrl:Y,routeTemplates:G5,settingsTabValues:jX,urls:G,settingsUrls:J};G.dashboard=z0(Y,H0(W)),G.campaigns=z0(Y,H0(W,"/campaign")),G.sequences=z0(Y,H0(W,"/sequences")),G.settings=z0(Y,H0(W,"/settings")),G.emails=z0(Y,H0(W,"/emails")),G.subscribers=z0(Y,H0(W,"/subscribers")),G.segments=z0(Y,H0(W,"/segments")),G.metrics=z0(Y,H0(W,"/metrics")),G.transactional=z0(Y,H0(W,"/transactional"));let $=r0(Q.campaignId);if($)G.campaign=z0(Y,H0(W,`/campaign/${K1($)}`));let z=r0(Q.sequenceId);if(z)G.sequence=z0(Y,H0(W,`/sequences/${K1(z)}`));let H=r0(Q.emailId)??r0(Q.templateId);if(H)G.email=z0(Y,H0(W,`/emails/${K1(H)}`)),G.template=G.email;let K=r0(Q.transactionalId);if(K)G.transactionalEmail=z0(Y,H0(W,`/transactional/${K1(K)}`));let B=r0(Q.domainId);if(B)G.domain=z0(Y,H0(W,`/settings/domain/${K1(B)}`)),G.domainVerify=`${G.domain}/verify`;let D=r0(Q.status);if(D)G.campaignList=z0(Y,H0(W,`/campaign/list/${K1(D)}`)),G.sequenceList=z0(Y,H0(W,`/sequences/list/${K1(D)}`));let A=r0(Q.settingsTab);if(A)G.settingsTab=J5(Y,W,A);return{appUrl:Y,routeTemplates:G5,settingsTabValues:jX,urls:G,settingsUrls:J}}var $5=[{uri:"sequenzy://dashboard",name:"Dashboard Overview",description:"Live overview stats for the last 7 days",mimeType:"application/json"},{uri:"sequenzy://company",name:"Current Company",description:"The currently selected company, including localization settings",mimeType:"application/json"},{uri:"sequenzy://campaigns/recent",name:"Recent Campaigns",description:"Last 10 campaigns with status and basic stats",mimeType:"application/json"},{uri:"sequenzy://subscribers/recent",name:"Recent Subscribers",description:"Most recently added subscribers",mimeType:"application/json"},{uri:"sequenzy://subscribers/engaged",name:"Engaged Subscribers",description:"Most active/engaged subscribers",mimeType:"application/json"},{uri:"sequenzy://sequences",name:"Sequences",description:"All email sequences with status",mimeType:"application/json"},{uri:"sequenzy://templates",name:"Templates",description:"All available email templates with localization status",mimeType:"application/json"},{uri:"sequenzy://segments",name:"Segments",description:"All defined segments with subscriber counts",mimeType:"application/json"},{uri:"sequenzy://tags",name:"Tags",description:"All tags with usage counts",mimeType:"application/json"},{uri:"sequenzy://health",name:"Deliverability Health",description:"Email deliverability metrics and health status",mimeType:"application/json"},{uri:"sequenzy://app-routes",name:"Dashboard URL Routes",description:"Route templates and settings tabs for building Sequenzy dashboard links",mimeType:"application/json"}];async function z5(Q){try{let X;switch(Q){case"sequenzy://dashboard":X=await w("GET","/api/v1/metrics?period=7d");break;case"sequenzy://company":{let Y=await w("GET","/api/v1/account"),W=_6()??Y.currentCompanyId;if(!W)throw Error("No company available. Create or select a company first.");X=await w("GET",`/api/v1/companies/${W}`);break}case"sequenzy://campaigns/recent":X=await w("GET","/api/v1/campaigns?limit=10");break;case"sequenzy://subscribers/recent":X=await w("GET","/api/v1/subscribers?sort=createdAt&limit=20");break;case"sequenzy://subscribers/engaged":X=await w("GET","/api/v1/subscribers?sort=engagement&limit=20");break;case"sequenzy://sequences":X=await w("GET","/api/v1/sequences");break;case"sequenzy://templates":X=await w("GET","/api/v1/templates");break;case"sequenzy://segments":X=await w("GET","/api/v1/segments");break;case"sequenzy://tags":X=await w("GET","/api/v1/tags");break;case"sequenzy://health":X=await w("GET","/api/v1/health/deliverability");break;case"sequenzy://app-routes":X=B1();break;default:throw Error(`Unknown resource: ${Q}`)}return{contents:[{uri:Q,mimeType:"application/json",text:JSON.stringify(X,null,2)}]}}catch(X){return{contents:[{uri:Q,mimeType:"text/plain",text:q1(X)}]}}}var XV={type:"object",properties:{id:{type:"string",description:"Optional filter ID. Any stable string works; one will be generated if omitted."},field:{type:"string",enum:["status","tag","email","emailProvider","added","firstName","lastName","list","emailSent","emailOpened","emailClicked","emailBounced","emailComplained","attribute","event","segment","stripeProduct","stripeCurrentProduct","stripeTrialProduct"],description:"Filter field. Use `event` for custom subscriber events, `segment` for saved segment membership, and `stripeProduct`/`stripeCurrentProduct`/`stripeTrialProduct` for Stripe product-based segments. Engagement fields (`emailSent`, `emailOpened`, `emailClicked`, `emailBounced`, `emailComplained`) accept a time range as the value or a specific campaign via `campaign:<campaign_id>`."},operator:{type:"string",enum:["is","is_not","is_empty","is_not_empty","contains","not_contains","less_than","more_than","at_least","less_than_count","gte","lte","gt","lt"],description:"Filter operator. Use `is_empty` or `is_not_empty` for fields that can be blank, including custom attributes. For `stripeProduct`, use `is` or `is_not` with a raw product ID, and `at_least` or `less_than_count` with `productId:count`. For `event`, use `is`, `is_not`, `at_least`, or `less_than_count`. For engagement fields, use `is` (event happened) or `is_not` (event did not happen)."},value:{type:"string",description:"Filter value. For custom attribute empty checks, use `attributeName:` such as `last_logged_in:`. Event examples: `saas.purchase:30d`, `saas.purchase:all`, or `saas.purchase:5:30d` for thresholds. Segment values are segment IDs. Stripe product examples: `prod_123` for bought/didn't buy, `prod_123:3` for payment thresholds. Engagement examples: `7d`, `30d`, `90d`, `180d`, `all` for rolling time windows, or `campaign:<campaign_id>` to scope to a specific sent campaign (use `list_campaigns` to find IDs)."}},required:["field","operator","value"],additionalProperties:!1},YV={type:"object",properties:{kind:{type:"string",enum:["group"]},id:{type:"string",description:"Stable group ID. Any string works; one will be generated if omitted."},joinOperator:{type:"string",enum:["and","or"],description:"How children in this group combine."},children:{type:"array",minItems:1,items:{type:"object",description:'Either a filter leaf (`kind: "filter"`) or another group (`kind: "group"`).'}}},required:["kind","joinOperator","children"],additionalProperties:!0};function K5(Q){if(!Array.isArray(Q))return Q;return Q.map((X)=>{if(typeof X!=="object"||X===null)return X;let Y=X;if(typeof Y.id==="string"&&Y.id.trim()!=="")return Y;return{...Y,id:crypto.randomUUID()}})}function B5(Q){if(typeof Q!=="object"||Q===null)return Q;let X=Q;if(X.kind==="filter"){let Y=K5([X]);return Array.isArray(Y)?Y[0]:X}if(X.kind!=="group")return Q;return{...X,id:typeof X.id==="string"&&X.id.trim()!==""?X.id:crypto.randomUUID(),children:Array.isArray(X.children)?X.children.map(B5):[]}}function WQ(Q,X,Y){if(X.html!==void 0&&X.blocks!==void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`, not both.`);if(X.blocks!==void 0&&!Array.isArray(X.blocks))throw Error(`\`blocks\` must be an array when calling \`${Q}\`.`);if(Y?.requireContent&&X.html===void 0&&X.blocks===void 0)throw Error(`Provide either \`html\` or \`blocks\` when calling \`${Q}\`.`)}function WV(Q){WQ("create_campaign",Q);let X=f(Q,"prompt")!==void 0,Y=Q.html!==void 0,W=Q.blocks!==void 0,G=Q.templateId!==void 0;if(Q.prompt!==void 0&&!X)throw Error("`prompt` cannot be empty when calling `create_campaign`.");if(X&&(Y||W||G))throw Error("Provide either `prompt`, `html`, `blocks`, or `templateId` when calling `create_campaign`, not multiple content sources.");if(!X&&(Q.style!==void 0||Q.tone!==void 0))throw Error("`style` and `tone` can only be used with `prompt` when calling `create_campaign`.");if(!X&&f(Q,"subject")===void 0)throw Error("`subject` is required unless `prompt` is provided when calling `create_campaign`.")}function GV(Q){if(!Q||typeof Q!=="object")return null;let X=Q;if(X.success!==!1)return null;if(typeof X.error==="string")return Error(X.error);if(X.error&&typeof X.error==="object"&&typeof X.error.message==="string")return Error(X.error.message);if(typeof X.message==="string")return Error(X.message);return Error("The tool returned an unsuccessful response.")}function h0(Q){return typeof Q==="object"&&Q!==null&&!Array.isArray(Q)}function H5(Q){return Q.trim().toLowerCase().replace(/\s+/g,"-")}function JV(Q){let X=new URLSearchParams;if(typeof Q.query==="string"&&Q.query.trim()!=="")X.set("query",Q.query.trim());if(Array.isArray(Q.tags)&&Q.tags.length>0)X.set("tags",Q.tags.filter((Y)=>typeof Y==="string"&&Y.trim()!=="").join(","));if(typeof Q.segmentId==="string"&&Q.segmentId.trim()!=="")X.set("segmentId",Q.segmentId);return X.set("page",String(Q.page)),X.set("limit",String(Q.pageSize)),X}async function $V(Q,X){let Y=typeof Q.limit==="number"&&Number.isFinite(Q.limit)?Math.max(1,Math.trunc(Q.limit)):void 0,W=Math.min(100,Math.max(1,Y??100)),G=[],J=1,$=0,z=0,H=0;while(!0){let B=JV({query:Q.query,tags:Q.tags,segmentId:Q.segmentId,page:J,pageSize:W}),D=await w("GET",`/api/v1/subscribers?${B.toString()}`,void 0,X);$=D.pagination?.total??D.subscribers.length,z=D.pagination?.totalPages??1,H+=1,G.push(...D.subscribers??[]);let A=Y!==void 0&&G.length>=Y,U=D.pagination?J>=D.pagination.totalPages:(D.subscribers??[]).length<W;if(A||U)break;J+=1}let K=Y!==void 0?G.slice(0,Y):G;return{success:!0,subscribers:K,pagination:{page:1,limit:W,total:$,totalPages:z,fetchedPages:H},returned:K.length,truncated:Y!==void 0&&$>0&&K.length<$}}async function PX(Q,X){return w("GET",`/api/v1/subscribers/${encodeURIComponent(Q)}`,void 0,X)}function f(Q,X){let Y=Q[X];if(typeof Y!=="string")return;let W=Y.trim();return W.length>0?W:void 0}async function D5(Q){let X=f(Q,"companyId");if(X)return X;let Y=_6();if(Y)return Y;try{return(await w("GET","/api/v1/account")).currentCompanyId??void 0}catch{return}}function GQ(Q,X){if(!h0(Q)||!X)return Q;return{...Q,url:X}}function bX(Q,X,Y){if(!Array.isArray(Q)||!X)return Q;return Q.map((W)=>{if(!h0(W))return W;let G=f(W,"id");if(!G)return W;let J=B1({companyId:X,...Y==="campaign"&&{campaignId:G},...Y==="sequence"&&{sequenceId:G},...Y==="template"&&{emailId:G}}),$=Y==="campaign"?J.urls.campaign:Y==="sequence"?J.urls.sequence:J.urls.email;return GQ(W,$)})}function zV(Q){if(!Array.isArray(Q))return Q;return Q.map((X)=>{if(!h0(X))return X;let Y=f(X,"id");if(!Y)return X;let W=B1({companyId:Y});return{...X,url:W.urls.dashboard,settingsUrl:W.urls.settings}})}var HV=new Set(["get_account","select_company","create_company","get_company","list_campaigns","get_campaign","create_campaign","update_campaign","send_test_email","list_sequences","get_sequence","create_sequence","update_sequence","enable_sequence","disable_sequence","list_templates","get_template","create_template","update_template"]);async function KV(Q,X,Y){if(!h0(Y)||!HV.has(Q))return Y;let W=h0(Y.company)?Y.company:void 0,J=f(Y,"selectedCompanyId")??f(Y,"currentCompanyId")??f(Y,"companyId")??(W?f(W,"id"):void 0)??(W?f(W,"companyId"):void 0)??await D5(X);if(!J)return Y;let $=h0(Y.campaign)?Y.campaign:void 0,z=h0(Y.sequence)?Y.sequence:void 0,H=h0(Y.template)?Y.template:void 0,K={companyId:J,campaignId:f(X,"campaignId")??f(Y,"campaignId")??($?f($,"id"):void 0),sequenceId:f(X,"sequenceId")??f(Y,"sequenceId")??(z?f(z,"id"):void 0),emailId:f(X,"templateId")??f(Y,"templateId")??(H?f(H,"id"):void 0),status:f(X,"status")},B=B1(K),D=W?B1({companyId:J}):void 0;return{...Y,...Array.isArray(Y.companies)&&{companies:zV(Y.companies)},...Array.isArray(Y.campaigns)&&{campaigns:bX(Y.campaigns,J,"campaign")},...Array.isArray(Y.sequences)&&{sequences:bX(Y.sequences,J,"sequence")},...Array.isArray(Y.templates)&&{templates:bX(Y.templates,J,"template")},...W&&D!==void 0&&{company:{...W,url:D.urls.dashboard,settingsUrl:D.urls.settings}},...$&&B.urls.campaign!==void 0&&{campaign:GQ($,B.urls.campaign)},...z&&B.urls.sequence!==void 0&&{sequence:GQ(z,B.urls.sequence)},...H&&B.urls.email!==void 0&&{template:GQ(H,B.urls.email)},appUrls:B.urls}}var A5=[{name:"get_account",description:`Get current account information including available companies. IMPORTANT: If you have access to multiple companies, you MUST either:
|
|
32
32
|
1. Call select_company first to choose which company to work with, OR
|
|
33
33
|
2. Pass companyId explicitly in each tool call
|
|
@@ -72,7 +72,13 @@ IMPORTANT GUIDELINES:
|
|
|
72
72
|
- Tell the user what specific user action should trigger each event
|
|
73
73
|
- Be specific: "Track 'project.created' when user creates their first project"
|
|
74
74
|
|
|
75
|
-
4.
|
|
75
|
+
4. MATCHING FIELD ENROLLMENT:
|
|
76
|
+
- Use enrollmentMode: "matching_field" only with trigger: "event_received".
|
|
77
|
+
- Use enrollmentFieldPath for custom event payload fields, for example "order.id" or "product.providerVariantId".
|
|
78
|
+
- This blocks duplicate active runs for the same subscriber + field value, but still allows separate active runs for different products, variants, orders, or other event-scoped objects.
|
|
79
|
+
- Leave enrollmentFieldPath empty for Shopify back-in-stock and replenishment events so Sequenzy uses its built-in product/variant matching defaults.
|
|
80
|
+
|
|
81
|
+
5. SEQUENCE TRIGGER RECIPES - USE THESE EXACT CONFIGURATIONS:
|
|
76
82
|
|
|
77
83
|
TRIAL CONVERSION:
|
|
78
84
|
- trigger: tag_added, tagName: "trial"
|
|
@@ -99,10 +105,15 @@ IMPORTANT GUIDELINES:
|
|
|
99
105
|
- Auto-stops when: user triggers "saas.upgrade" event
|
|
100
106
|
- Goal: Encourage customers to upgrade to higher plans
|
|
101
107
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
ONBOARDING:
|
|
109
|
+
- trigger: event_received, eventName: "signup.completed"
|
|
110
|
+
- Auto-stops when: "onboarding.completed" event fires
|
|
111
|
+
- Goal: Guide new users through product setup
|
|
112
|
+
|
|
113
|
+
PRODUCT / ORDER-SCOPED EVENT SEQUENCE:
|
|
114
|
+
- trigger: event_received, eventName: "ecommerce.order_placed"
|
|
115
|
+
- enrollmentMode: "matching_field", enrollmentFieldPath: "order.id"
|
|
116
|
+
- Goal: Run one active sequence per specific order without duplicate active runs for the same order
|
|
106
117
|
|
|
107
118
|
WELCOME SERIES:
|
|
108
119
|
- trigger: contact_added (optionally with listId)
|
|
@@ -162,4 +173,4 @@ BUILT-IN EVENTS (auto-fired by payment integrations):
|
|
|
162
173
|
|
|
163
174
|
OTHER BUILT-IN EVENTS:
|
|
164
175
|
- email.opened, email.clicked, email.replied, email.bounced, email.unsubscribed
|
|
165
|
-
- contact.subscribed, contact.unsubscribed`,inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the sequence in. If not provided, uses the currently selected company."},name:{type:"string",description:"Sequence name (e.g., 'User Onboarding', 'Welcome Series')"},trigger:{type:"string",enum:["contact_added","tag_added","segment_entered","event_received","inactivity","frequency"],description:"Trigger type: 'contact_added' (when added to a list), 'tag_added' (when tag is applied), 'segment_entered' (when a contact newly enters a saved segment), 'event_received' (when custom event fires), 'inactivity' (when subscriber hasn't performed an event for X days), 'frequency' (when subscriber performs event X times in Y days)"},listId:{type:"string",description:"List ID to trigger on (for contact_added trigger). If not provided, triggers on any list."},tagName:{type:"string",description:"Tag name to trigger on (required for tag_added trigger)"},segmentId:{type:"string",description:"Segment ID to trigger on (required for segment_entered trigger). Use list_segments first to choose a saved segment."},eventName:{type:"string",description:"Event name to trigger on (required for event_received, inactivity, and frequency triggers)"},inactiveDays:{type:"number",description:"Number of days of inactivity (required for inactivity trigger, must be >= 1)"},minCount:{type:"number",description:"Minimum event count (required for frequency trigger, must be >= 1)"},timeWindowDays:{type:"number",description:"Time window in days for frequency trigger (required for frequency trigger, must be >= 1)"},emailCount:{type:"number",description:"Number of emails in the sequence (default: 5, max: 10)"},goal:{type:"string",description:"What this sequence should accomplish for AI generation. Be specific to the app's actual features and user journey. Avoid generic goals that don't match the app's business model."},steps:{type:"array",description:"Explicit sequence steps. Omit type for email steps, or use type: 'create_discount' for a Stripe discount action. Later email steps can reference the most recent discount with {{discount.code}}, {{discount.percentOff}}, {{discount.amountOff}}, and {{discount.expiresAt}}.",items:{type:"object",properties:{type:{type:"string",enum:["email","create_discount","discount"],description:"Step type. Omit or use 'email' for email content. Use 'create_discount' to generate a discount code before later emails."},subject:{type:"string",description:"Email subject. Required for email steps."},previewText:{type:"string",description:"Email preview text."},blocks:{type:"array",description:"Sequenzy email blocks. Provide blocks or html for email steps.",items:{type:"object"}},html:{type:"string",description:"HTML content for email steps. Will be converted to Sequenzy blocks."},delay:{type:"object",description:"Delay before this step.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"}}},name:{type:"string",description:"Email template name for email steps."},discount:{type:"object",description:"Discount configuration for create_discount steps. Prefer this nested shape for new integrations; legacy top-level discount fields are still accepted.",properties:{label:{type:"string",description:"Builder label for the discount step."},provider:{type:"string",enum:["stripe"],description:"Discount provider. Currently only 'stripe'."},discountType:{type:"string",enum:["percent","amount"],description:"Discount type."},percentOff:{type:"number",description:"Percent discount from 1 to 100. Required when discountType is percent."},amountOff:{type:"number",description:"Fixed amount discount in the smallest currency unit, for example 500 for $5. Required when discountType is amount."},currency:{type:"string",description:"ISO currency for amount discounts. Defaults to usd."},duration:{type:"string",enum:["once","forever","repeating"],description:"Stripe coupon duration. Defaults to once."},durationInMonths:{type:"number",description:"Required for repeating discounts."},appliesToAllPlans:{type:"boolean",description:"Whether the discount applies to all plans. Defaults to true."},planIds:{type:"array",description:"Stripe product IDs, such as prod_abc123, when appliesToAllPlans is false.",items:{type:"string"}},codePrefix:{type:"string",description:"Optional prefix for generated promotion codes."},maxRedemptions:{type:"number",description:"Maximum promotion code redemptions. Use 1 for subscriber-specific codes."},expiresAt:{type:"string",description:"Optional future expiration date or ISO timestamp."},expiresInHours:{type:"number",description:"Optional relative expiration in hours, resolved when each subscriber's code is created (e.g., 48 for a 48-hour window per subscriber). Takes precedence over expiresAt."},name:{type:"string",description:"Optional provider coupon name."}}},label:{type:"string",description:"Legacy top-level discount label. Prefer discount.label."},provider:{type:"string",enum:["stripe"],description:"Legacy top-level discount provider. Prefer discount.provider."},discountType:{type:"string",enum:["percent","amount"],description:"Legacy top-level discount type. Prefer discount.discountType."},percentOff:{type:"number",description:"Percent discount from 1 to 100. Required when discountType is percent."},amountOff:{type:"number",description:"Fixed amount discount in the smallest currency unit, for example 500 for $5. Required when discountType is amount."},currency:{type:"string",description:"ISO currency for amount discounts. Defaults to usd."},duration:{type:"string",enum:["once","forever","repeating"],description:"Stripe coupon duration. Defaults to once."},durationInMonths:{type:"number",description:"Required for repeating discounts."},appliesToAllPlans:{type:"boolean",description:"Whether the discount applies to all plans. Defaults to true."},planIds:{type:"array",description:"Stripe product IDs, such as prod_abc123, when appliesToAllPlans is false.",items:{type:"string"}},codePrefix:{type:"string",description:"Optional prefix for generated promotion codes."},maxRedemptions:{type:"number",description:"Maximum promotion code redemptions. Use 1 for subscriber-specific codes."},expiresAt:{type:"string",description:"Optional future expiration date or ISO timestamp."},expiresInHours:{type:"number",description:"Optional relative expiration in hours, resolved when each subscriber's code is created (e.g., 48 for a 48-hour window per subscriber). Takes precedence over expiresAt."}}}}},required:["name","trigger"]}},{name:"update_sequence",description:"Update an existing sequence. To target a specific step, use the emailId or nodeId returned in get_sequence.sequence.emails.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"},name:{type:"string",description:"Sequence name"},emails:{type:"array",description:"Updated sequence emails. If you omit emailId/nodeId, items are matched by existing step order.",items:{type:"object",properties:{emailId:{type:"string",description:"Optional target linked email template ID for a step. Use the emailId returned in get_sequence.sequence.emails."},nodeId:{type:"string",description:"Optional target action_email node ID for a step. Use the nodeId returned in get_sequence.sequence.emails."},name:{type:"string",description:"Updated step/template name"},subject:{type:"string",description:"Updated email subject"},previewText:{type:"string",description:"Updated preview text"},html:{type:"string",description:"Updated HTML content. Will be converted to Sequenzy blocks."},htmlContent:{type:"string",description:"Alias for html. Use this when updating HTML content for a step."},blocks:{type:"array",description:"Updated Sequenzy block JSON for the step"}}}},steps:{type:"array",description:"Alias for emails. Supports the same fields and matching rules.",items:{type:"object",properties:{emailId:{type:"string",description:"Optional target linked email template ID for a step. Use the emailId returned in get_sequence.sequence.emails."},nodeId:{type:"string",description:"Optional target action_email node ID for a step. Use the nodeId returned in get_sequence.sequence.emails."},name:{type:"string",description:"Updated step/template name"},subject:{type:"string",description:"Updated email subject"},previewText:{type:"string",description:"Updated preview text"},html:{type:"string",description:"Updated HTML content. Will be converted to Sequenzy blocks."},htmlContent:{type:"string",description:"Alias for html. Use this when updating HTML content for a step."},blocks:{type:"array",description:"Updated Sequenzy block JSON for the step"}}}}},required:["sequenceId"]}},{name:"enable_sequence",description:"Enable/activate a sequence. IMPORTANT: Only call this when the user EXPLICITLY asks to enable or activate a sequence. Never enable sequences automatically after creation - the user must review the content first.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"disable_sequence",description:"Disable/pause a sequence",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"delete_sequence",description:"Delete a sequence",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"send_email",description:"Send a transactional email to a single recipient",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},to:{type:"string",description:"Recipient email address"},subject:{type:"string",description:"Email subject (required if not using templateId)"},html:{type:"string",description:"Email HTML content (required if not using templateId)"},templateId:{type:"string",description:"Template ID to use (alternative to html)"},variables:{type:"object",description:"Variables for template personalization"}},required:["to"]}},{name:"get_stats",description:"Get overview statistics for a time period",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},period:{type:"string",description:"Time period: 7d, 30d, or 90d (default: 7d)"}}}},{name:"get_campaign_stats",description:"Get detailed statistics for a campaign",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"}},required:["campaignId"]}},{name:"get_sequence_stats",description:"Get statistics for a sequence, including per-step failed subscribers and failure reasons",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"get_subscriber_activity",description:"Get recent activity, email stats, and current sequence enrollments for a subscriber",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address"}},required:["email"]}},{name:"generate_email",description:"Generate email blocks from a prompt",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},prompt:{type:"string",description:"Description of the email to generate"},style:{type:"string",description:"Style: minimal, branded, promotional"},tone:{type:"string",description:"Tone: professional, casual, friendly"}},required:["prompt"]}},{name:"generate_sequence",description:"[DEPRECATED - Use create_sequence instead] Generate a multi-email sequence from a goal. Note: create_sequence now handles AI generation automatically.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},goal:{type:"string",description:"Goal of the sequence (e.g., 'onboard new SaaS trial users')"},emailCount:{type:"number",description:"Number of emails in the sequence (default: 5, max: 10)"},durationDays:{type:"number",description:"Total duration in days (default: 14)"}},required:["goal"]}},{name:"generate_subject_lines",description:"Generate A/B test subject line variants",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},topic:{type:"string",description:"Topic or context for the subject lines"},count:{type:"number",description:"Number of variants to generate (default: 5)"}},required:["topic"]}}];async function F5(Q,X){try{let Y;switch(Q){case"get_account":{let G=await w("GET","/api/v1/account"),J=_6();Y={...G,selectedCompanyId:J??G.currentCompanyId};break}case"select_company":{let G=X.companyId,J=await w("GET","/api/v1/account"),$=J.companies?.find((z)=>z.id===G);if(!$)throw Error(`Company not found. Available companies: ${J.companies?.map((z)=>`${z.name} (${z.id})`).join(", ")??"none"}`);EX(G),Y={success:!0,message:`Switched to company: ${$.name}`,companyId:$.id,companyName:$.name};break}case"get_app_urls":{let G=await D5(X);Y={...B1({companyId:G,campaignId:f(X,"campaignId"),sequenceId:f(X,"sequenceId"),emailId:f(X,"emailId")??f(X,"templateId"),transactionalId:f(X,"transactionalId"),domainId:f(X,"domainId"),status:f(X,"status"),settingsTab:f(X,"settingsTab")}),...G===void 0&&{note:"No company ID is selected. Call get_account, select_company, or pass companyId to get concrete dashboard URLs."}};break}case"create_company":{let G=await w("POST","/api/v1/companies",{name:X.name,domain:X.domain});if(!G.success)throw Error("Failed to create company");let J=G.company.id,$=6,z=0,H=G.company.status;while(H==="processing"&&z<$){await new Promise((D)=>setTimeout(D,20000)),z++;let B=await w("GET",`/api/v1/companies/${J}`);if(B.success)H=B.company.status}EX(J);let K=await w("GET",`/api/v1/companies/${J}`);Y={success:!0,company:K.company,message:H==="processing"?"Company created but still processing. You can continue using it while processing completes.":`Company '${K.company.name}' created and ready to use.`,autoSelected:!0};break}case"get_company":{let G=X.companyId;Y=await w("GET",`/api/v1/companies/${G}`);break}case"create_api_key":{let G=X.companyId;Y=await w("POST","/api/v1/api-keys",{name:X.name},G);break}case"list_websites":{let G=X.companyId;Y=await w("GET","/api/v1/websites",void 0,G);break}case"add_website":{let G=X.companyId;Y=await w("POST","/api/v1/websites",{domain:X.domain},G);break}case"check_website":{let G=X.companyId;Y=await w("GET",`/api/v1/websites/${X.domain}`,void 0,G);break}case"get_integration_guide":Y=await w("POST","/api/v1/integration-guide",X);break;case"add_subscriber":{let G=X.companyId;Y=await w("POST","/api/v1/subscribers",{email:X.email,customAttributes:X.attributes,tags:X.tags,lists:X.listIds},G);break}case"update_subscriber":{let G=X.companyId,J=await PX(String(X.email),G),$=Array.isArray(J.subscriber.tags)?J.subscriber.tags.filter((D)=>typeof D==="string"):[],z=Array.isArray(X.addTags)?X.addTags.filter((D)=>typeof D==="string"&&D.trim()!=="").map(H5):[],H=new Set(Array.isArray(X.removeTags)?X.removeTags.filter((D)=>typeof D==="string"&&D.trim()!=="").map(H5):[]),K=$.filter((D)=>!H.has(D));for(let D of z)if(!K.includes(D))K.push(D);let B={};if(h0(X.attributes))B.customAttributes={...h0(J.subscriber.customAttributes)?J.subscriber.customAttributes:{},...X.attributes};if(X.addTags||X.removeTags)B.tags=K;Y=await w("PATCH",`/api/v1/subscribers/${encodeURIComponent(String(X.email))}`,B,G);break}case"remove_subscriber":{let G=X.companyId;if(X.hardDelete===!0)Y=await w("DELETE",`/api/v1/subscribers/${encodeURIComponent(String(X.email))}`,void 0,G);else Y=await w("PATCH",`/api/v1/subscribers/${encodeURIComponent(String(X.email))}`,{status:"unsubscribed"},G);break}case"get_subscriber":{let G=X.companyId;Y=await PX(String(X.email),G);break}case"search_subscribers":{let G=X.companyId;Y=await $V(X,G);break}case"list_tags":{let G=X.companyId;Y=await w("GET","/api/v1/tags",void 0,G);break}case"list_lists":{let G=X.companyId;Y=await w("GET","/api/v1/lists",void 0,G);break}case"create_list":{let G=X.companyId;Y=await w("POST","/api/v1/lists",X,G);break}case"list_segments":{let G=X.companyId;Y=await w("GET","/api/v1/segments",void 0,G);break}case"create_segment":{let G=X.companyId;Y=await w("POST","/api/v1/segments",{...X,...X.filters!==void 0?{filters:K5(X.filters)}:{},...X.root!==void 0?{root:B5(X.root)}:{}},G);break}case"get_segment_count":{let G=X.companyId;Y=await w("GET",`/api/v1/segments/${X.segmentId}/count`,void 0,G);break}case"list_templates":{let G=X.companyId;Y=await w("GET","/api/v1/templates",void 0,G);break}case"get_template":{let G=X.companyId;Y=await w("GET",`/api/v1/templates/${X.templateId}`,void 0,G);break}case"create_template":{let G=X.companyId;WQ("create_template",X,{requireContent:!0}),Y=await w("POST","/api/v1/templates",X,G);break}case"update_template":{let G=X.companyId,J=new Set(["companyId","templateId","name","subject","html","blocks"]),$=Object.keys(X).filter((z)=>!J.has(z));if($.length>0)throw Error(`\`update_template\` accepts only \`name\`, \`subject\`, \`html\`, and \`blocks\` update fields. Unsupported field${$.length===1?"":"s"}: ${$.map((z)=>`\`${z}\``).join(", ")}.`);if(WQ("update_template",X),X.name===void 0&&X.subject===void 0&&X.html===void 0&&X.blocks===void 0)throw Error("Provide at least one of `name`, `subject`, `html`, or `blocks` when calling `update_template`.");Y=await w("PUT",`/api/v1/templates/${X.templateId}`,X,G);break}case"delete_template":{let G=X.companyId;Y=await w("DELETE",`/api/v1/templates/${X.templateId}`,void 0,G);break}case"list_campaigns":{let G=X.companyId,J=new URLSearchParams;if(X.status)J.set("status",String(X.status));Y=await w("GET",`/api/v1/campaigns?${J}`,void 0,G);break}case"get_campaign":{let G=X.companyId;Y=await w("GET",`/api/v1/campaigns/${X.campaignId}`,void 0,G);break}case"create_campaign":{let G=X.companyId;WV(X);let J=f(X,"prompt");if(J!==void 0){let $=await w("POST","/api/v1/generate/email",{prompt:J,...X.style!==void 0&&{style:X.style},...X.tone!==void 0&&{tone:X.tone}},G),z=f(X,"subject")??(typeof $.subject==="string"&&$.subject.trim()!==""?$.subject.trim():void 0);if(!z)throw Error("`create_campaign` prompt generation did not return a subject. Provide `subject` explicitly.");let H=Array.isArray($.blocks)&&$.blocks.length>0?$.blocks:void 0,K=typeof $.html==="string"&&$.html.trim()!==""?$.html:void 0;if(H===void 0&&K===void 0)throw Error("`create_campaign` prompt generation did not return email blocks. Try again or provide `html` or `blocks` explicitly.");Y=await w("POST","/api/v1/campaigns",{name:X.name,subject:z,...H!==void 0?{blocks:H}:{html:K},...X.segmentId!==void 0&&{segmentId:X.segmentId}},G);break}Y=await w("POST","/api/v1/campaigns",X,G);break}case"update_campaign":{let G=X.companyId,J=new Set(["companyId","campaignId","name","subject","html","blocks","replyTo","replyProfileId"]),$=Object.keys(X).filter((z)=>!J.has(z));if($.length>0)throw Error(`\`update_campaign\` accepts only \`name\`, \`subject\`, \`html\`, \`blocks\`, \`replyTo\`, and \`replyProfileId\` update fields. Unsupported field${$.length===1?"":"s"}: ${$.map((z)=>`\`${z}\``).join(", ")}.`);if(WQ("update_campaign",X),X.replyTo!==void 0&&X.replyProfileId!==void 0)throw Error("Provide either `replyTo` or `replyProfileId` when calling `update_campaign`, not both.");if(X.name===void 0&&X.subject===void 0&&X.html===void 0&&X.blocks===void 0&&X.replyTo===void 0&&X.replyProfileId===void 0)throw Error("Provide at least one of `name`, `subject`, `html`, `blocks`, `replyTo`, or `replyProfileId` when calling `update_campaign`.");Y=await w("PUT",`/api/v1/campaigns/${X.campaignId}`,X,G);break}case"send_test_email":{let G=X.companyId;Y=await w("POST",`/api/v1/campaigns/${X.campaignId}/test`,{to:X.to},G);break}case"list_sequences":{let G=X.companyId;Y=await w("GET","/api/v1/sequences",void 0,G);break}case"get_sequence":{let G=X.companyId;Y=await w("GET",`/api/v1/sequences/${X.sequenceId}`,void 0,G);break}case"create_sequence":{let G=X.companyId,J=Array.isArray(X.steps)&&X.steps.length>0,$=await w("POST","/api/v1/sequences",X,G);if(!$.success){Y=$;break}let z=$.sequence.id;if(J){let A=await w("GET",`/api/v1/sequences/${z}`,void 0,G);if(A.success)Y={success:!0,sequence:A.sequence,message:`Sequence "${A.sequence.name}" created with explicit steps. Review it before enabling.`};else Y=A;break}let H=6,K=0,B="pending";while(B!=="complete"&&K<H){await new Promise((U)=>setTimeout(U,20000)),K++;let A=await w("GET",`/api/v1/sequences/${z}`,void 0,G);if(A.success)B=A.sequence.enrichmentStatus}let D=await w("GET",`/api/v1/sequences/${z}`,void 0,G);if(D.success)Y={success:!0,sequence:D.sequence,message:D.sequence.enrichmentStatus==="complete"?`Sequence "${D.sequence.name}" created with ${D.sequence.emailCount} AI-generated emails. The sequence is ready to review and enable.`:`Sequence "${D.sequence.name}" created. Email enrichment is still in progress (${D.sequence.enrichedCount}/${D.sequence.emailCount} emails generated). You can check status with get_sequence.`};else Y=D;break}case"update_sequence":{let G=X.companyId;Y=await w("PUT",`/api/v1/sequences/${X.sequenceId}`,X,G);break}case"enable_sequence":{let G=X.companyId;Y=await w("POST",`/api/v1/sequences/${X.sequenceId}/enable`,void 0,G);break}case"disable_sequence":{let G=X.companyId;Y=await w("POST",`/api/v1/sequences/${X.sequenceId}/disable`,void 0,G);break}case"delete_sequence":{let G=X.companyId;Y=await w("DELETE",`/api/v1/sequences/${X.sequenceId}`,void 0,G);break}case"send_email":{let G=X.companyId;Y=await w("POST","/api/v1/transactional/send",X,G);break}case"get_stats":{let G=X.companyId,J=X.period??"7d";Y=await w("GET",`/api/v1/metrics?period=${J}`,void 0,G);break}case"get_campaign_stats":{let G=X.companyId;Y=await w("GET",`/api/v1/metrics/campaigns/${X.campaignId}`,void 0,G);break}case"get_sequence_stats":{let G=X.companyId;Y=await w("GET",`/api/v1/metrics/sequences/${X.sequenceId}`,void 0,G);break}case"get_subscriber_activity":{let G=X.companyId,J=await PX(String(X.email),G);Y={success:J.success,email:J.subscriber.email,emailStats:J.subscriber.emailStats??null,activity:J.subscriber.activity??[],sequenceEnrollments:J.subscriber.sequenceEnrollments??[]};break}case"generate_email":{let G=X.companyId;Y=await w("POST","/api/v1/generate/email",X,G);break}case"generate_sequence":{let G=X.companyId;Y=await w("POST","/api/v1/generate/sequence",X,G);break}case"generate_subject_lines":{let G=X.companyId;Y=await w("POST","/api/v1/generate/subjects",X,G);break}default:throw Error(`Unknown tool: ${Q}`)}let W=GV(Y);if(W)throw W;return Y=await KV(Q,X,Y),{content:[{type:"text",text:JSON.stringify(Y,null,2)}]}}catch(Y){return{isError:!0,content:[{type:"text",text:q1(Y)}]}}}var BV=process.env.SEQUENZY_API_URL??"https://api.sequenzy.com",L5=process.env.SEQUENZY_API_KEY,IX=null;if(!L5)console.error(q1(new g1("SEQUENZY_API_KEY environment variable is required",401,void 0,"MCP_AUTH_REQUIRED"))),process.exit(1);function _6(){return IX}function EX(Q){IX=Q}var y6=new ZX({name:"sequenzy",version:W5.version},{capabilities:{tools:{},resources:{}}});function DV(Q){if(!Q.trim())return{message:"Request failed"};try{let X=JSON.parse(Q);if(typeof X==="string")return{message:X};if(typeof X.error==="string")return{message:X.error,code:X.code};if(X.error&&typeof X.error==="object")return{message:X.error.message??X.message??Q,code:X.error.code??X.code};return{message:X.message??Q,code:X.code}}catch{return{message:Q}}}async function w(Q,X,Y,W){let G={"Content-Type":"application/json",Authorization:`Bearer ${L5}`},J=W??IX;if(J)G["x-company-id"]=J;let $;try{$=await fetch(`${BV}${X}`,{method:Q,headers:G,body:Y?JSON.stringify(Y):void 0})}catch(z){throw new g1(z instanceof Error?z.message:"Failed to reach Sequenzy API",0,void 0,"NETWORK_ERROR")}if(!$.ok){let z=await $.text(),H=DV(z);throw new g1(H.message,$.status,z,H.code)}return $.json()}y6.setRequestHandler(z9,async()=>{return{tools:A5}});y6.setRequestHandler(K6,async(Q)=>{let{name:X,arguments:Y}=Q.params;return F5(X,Y??{})});y6.setRequestHandler(Q9,async()=>{return{resources:$5}});y6.setRequestHandler(Y9,async(Q)=>{let{uri:X}=Q.params;return z5(X)});async function AV(){let Q=new wX;await y6.connect(Q),console.error("Sequenzy MCP server running on stdio")}AV().catch((Q)=>{console.error(q1(Q)),process.exit(1)});export{EX as setSelectedCompanyId,_6 as getSelectedCompanyId,w as apiRequest};
|
|
176
|
+
- contact.subscribed, contact.unsubscribed`,inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID to create the sequence in. If not provided, uses the currently selected company."},name:{type:"string",description:"Sequence name (e.g., 'User Onboarding', 'Welcome Series')"},trigger:{type:"string",enum:["contact_added","tag_added","segment_entered","event_received","inactivity","frequency"],description:"Trigger type: 'contact_added' (when added to a list), 'tag_added' (when tag is applied), 'segment_entered' (when a contact newly enters a saved segment), 'event_received' (when custom event fires), 'inactivity' (when subscriber hasn't performed an event for X days), 'frequency' (when subscriber performs event X times in Y days)"},listId:{type:"string",description:"List ID to trigger on (for contact_added trigger). If not provided, triggers on any list."},tagName:{type:"string",description:"Tag name to trigger on (required for tag_added trigger)"},segmentId:{type:"string",description:"Segment ID to trigger on (required for segment_entered trigger). Use list_segments first to choose a saved segment."},eventName:{type:"string",description:"Event name to trigger on (required for event_received, inactivity, and frequency triggers)"},inactiveDays:{type:"number",description:"Number of days of inactivity (required for inactivity trigger, must be >= 1)"},minCount:{type:"number",description:"Minimum event count (required for frequency trigger, must be >= 1)"},timeWindowDays:{type:"number",description:"Time window in days for frequency trigger (required for frequency trigger, must be >= 1)"},emailCount:{type:"number",description:"Number of emails in the sequence (default: 5, max: 10)"},goal:{type:"string",description:"What this sequence should accomplish for AI generation. Be specific to the app's actual features and user journey. Avoid generic goals that don't match the app's business model."},enrollmentMode:{type:"string",enum:["unlimited","one_time","matching_field"],description:"Sequence re-entry mode. Use 'matching_field' only for event_received triggers when duplicate active runs should be blocked per event field value."},enrollmentFieldPath:{type:"string",description:"Dot-path event property used by enrollmentMode='matching_field', such as 'order.id' or 'product.providerVariantId'. Leave omitted for Shopify back-in-stock/replenishment product-variant defaults."},stopCondition:{type:"object",description:"Optional explicit auto-stop condition. Use { type: 'has_tag', value: 'customer' } to end the sequence when a subscriber gets a tag, { type: 'does_not_have_tag', value: 'trial' } when a tag is removed, { type: 'removed_from_list', value: 'list_123' } when they leave a list, { type: 'event_received', value: 'onboarding.completed' } when an event is tracked, or { type: 'none', value: null } for no auto-stop.",properties:{type:{type:"string",enum:["none","has_tag","does_not_have_tag","added_to_list","removed_from_list","event_received"],description:"Stop condition type."},value:{type:["string","null"],description:"Tag name, list ID, or event name for the stop condition. Use null or omit for type 'none'."}},required:["type"]},steps:{type:"array",description:"Explicit sequence steps. Omit type for email steps, or use type: 'create_discount' for a Stripe discount action. Later email steps can reference the most recent discount with {{discount.code}}, {{discount.percentOff}}, {{discount.amountOff}}, and {{discount.expiresAt}}.",items:{type:"object",properties:{type:{type:"string",enum:["email","create_discount","discount"],description:"Step type. Omit or use 'email' for email content. Use 'create_discount' to generate a discount code before later emails."},subject:{type:"string",description:"Email subject. Required for email steps."},previewText:{type:"string",description:"Email preview text."},blocks:{type:"array",description:"Sequenzy email blocks. Provide blocks or html for email steps.",items:{type:"object"}},html:{type:"string",description:"HTML content for email steps. Will be converted to Sequenzy blocks."},delay:{type:"object",description:"Delay before this step.",properties:{days:{type:"number"},hours:{type:"number"},minutes:{type:"number"}}},name:{type:"string",description:"Email template name for email steps."},discount:{type:"object",description:"Discount configuration for create_discount steps. Prefer this nested shape for new integrations; legacy top-level discount fields are still accepted.",properties:{label:{type:"string",description:"Builder label for the discount step."},provider:{type:"string",enum:["stripe"],description:"Discount provider. Currently only 'stripe'."},discountType:{type:"string",enum:["percent","amount"],description:"Discount type."},percentOff:{type:"number",description:"Percent discount from 1 to 100. Required when discountType is percent."},amountOff:{type:"number",description:"Fixed amount discount in the smallest currency unit, for example 500 for $5. Required when discountType is amount."},currency:{type:"string",description:"ISO currency for amount discounts. Defaults to usd."},duration:{type:"string",enum:["once","forever","repeating"],description:"Stripe coupon duration. Defaults to once."},durationInMonths:{type:"number",description:"Required for repeating discounts."},appliesToAllPlans:{type:"boolean",description:"Whether the discount applies to all plans. Defaults to true."},planIds:{type:"array",description:"Stripe product IDs, such as prod_abc123, when appliesToAllPlans is false.",items:{type:"string"}},codePrefix:{type:"string",description:"Optional prefix for generated promotion codes."},maxRedemptions:{type:"number",description:"Maximum promotion code redemptions. Use 1 for subscriber-specific codes."},expiresAt:{type:"string",description:"Optional future expiration date or ISO timestamp."},expiresInHours:{type:"number",description:"Optional relative expiration in hours, resolved when each subscriber's code is created (e.g., 48 for a 48-hour window per subscriber). Takes precedence over expiresAt."},name:{type:"string",description:"Optional provider coupon name."}}},label:{type:"string",description:"Legacy top-level discount label. Prefer discount.label."},provider:{type:"string",enum:["stripe"],description:"Legacy top-level discount provider. Prefer discount.provider."},discountType:{type:"string",enum:["percent","amount"],description:"Legacy top-level discount type. Prefer discount.discountType."},percentOff:{type:"number",description:"Percent discount from 1 to 100. Required when discountType is percent."},amountOff:{type:"number",description:"Fixed amount discount in the smallest currency unit, for example 500 for $5. Required when discountType is amount."},currency:{type:"string",description:"ISO currency for amount discounts. Defaults to usd."},duration:{type:"string",enum:["once","forever","repeating"],description:"Stripe coupon duration. Defaults to once."},durationInMonths:{type:"number",description:"Required for repeating discounts."},appliesToAllPlans:{type:"boolean",description:"Whether the discount applies to all plans. Defaults to true."},planIds:{type:"array",description:"Stripe product IDs, such as prod_abc123, when appliesToAllPlans is false.",items:{type:"string"}},codePrefix:{type:"string",description:"Optional prefix for generated promotion codes."},maxRedemptions:{type:"number",description:"Maximum promotion code redemptions. Use 1 for subscriber-specific codes."},expiresAt:{type:"string",description:"Optional future expiration date or ISO timestamp."},expiresInHours:{type:"number",description:"Optional relative expiration in hours, resolved when each subscriber's code is created (e.g., 48 for a 48-hour window per subscriber). Takes precedence over expiresAt."}}}}},required:["name","trigger"]}},{name:"update_sequence",description:"Update an existing sequence. To target a specific step, use the emailId or nodeId returned in get_sequence.sequence.emails. You can also update enrollmentMode and enrollmentFieldPath for event-triggered matching-field enrollment.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"},name:{type:"string",description:"Sequence name"},enrollmentMode:{type:"string",enum:["unlimited","one_time","matching_field"],description:"Updated sequence re-entry mode. 'matching_field' is only valid for event-based sequence triggers."},enrollmentFieldPath:{anyOf:[{type:"string"},{type:"null"}],description:"Dot-path event property used by enrollmentMode='matching_field', such as 'order.id' or 'product.providerVariantId'. Set to null through the API to clear it; omit to leave unchanged."},stopCondition:{type:"object",description:"Update the sequence auto-stop condition. Example: { type: 'has_tag', value: 'customer' } ends the sequence when the subscriber has that tag. Use { type: 'removed_from_list', value: 'list_123' } to stop when they leave a list, or { type: 'none', value: null } to clear it.",properties:{type:{type:"string",enum:["none","has_tag","does_not_have_tag","added_to_list","removed_from_list","event_received"]},value:{type:["string","null"],description:"Tag name, list ID, or event name for the stop condition."}},required:["type"]},branch:{type:"object",description:"Insert an if/else branch into an existing sequence. The branch is inserted after afterNodeId and creates an if path plus an else fallback path. Use get_sequence first to choose afterNodeId.",properties:{afterNodeId:{type:"string",description:"Existing node ID to insert the branch after. Use a nodeId from get_sequence.sequence.nodes or get_sequence.sequence.emails."},label:{type:"string",description:"Optional branch node label."},branches:{type:"array",description:"Conditional branches evaluated in order. An else fallback is created automatically.",items:{type:"object",properties:{id:{type:"string",description:"Optional stable branch ID. Defaults to branch-0, branch-1, etc."},label:{type:"string",description:"Display label, e.g. 'If has customer tag'."},conditionType:{type:"string",enum:["has_tag","in_list","field_equals","field_contains","field_greater_than","field_less_than"],description:"Condition type for this branch."},tagName:{type:"string",description:"Tag name for has_tag conditions. This can be used instead of tagId."},tagId:{type:"string",description:"Tag ID or tag name for has_tag conditions."},listId:{type:"string",description:"List ID for in_list conditions."},fieldName:{type:"string",description:"Subscriber attribute name for field conditions."},fieldValue:{type:"string",description:"Comparison value for field conditions."}},required:["conditionType"]}}},required:["afterNodeId","branches"]},emails:{type:"array",description:"Updated sequence emails. If you omit emailId/nodeId, items are matched by existing step order.",items:{type:"object",properties:{emailId:{type:"string",description:"Optional target linked email template ID for a step. Use the emailId returned in get_sequence.sequence.emails."},nodeId:{type:"string",description:"Optional target action_email node ID for a step. Use the nodeId returned in get_sequence.sequence.emails."},name:{type:"string",description:"Updated step/template name"},subject:{type:"string",description:"Updated email subject"},previewText:{type:"string",description:"Updated preview text"},html:{type:"string",description:"Updated HTML content. Will be converted to Sequenzy blocks."},htmlContent:{type:"string",description:"Alias for html. Use this when updating HTML content for a step."},blocks:{type:"array",description:"Updated Sequenzy block JSON for the step"}}}},steps:{type:"array",description:"Alias for emails. Supports the same fields and matching rules.",items:{type:"object",properties:{emailId:{type:"string",description:"Optional target linked email template ID for a step. Use the emailId returned in get_sequence.sequence.emails."},nodeId:{type:"string",description:"Optional target action_email node ID for a step. Use the nodeId returned in get_sequence.sequence.emails."},name:{type:"string",description:"Updated step/template name"},subject:{type:"string",description:"Updated email subject"},previewText:{type:"string",description:"Updated preview text"},html:{type:"string",description:"Updated HTML content. Will be converted to Sequenzy blocks."},htmlContent:{type:"string",description:"Alias for html. Use this when updating HTML content for a step."},blocks:{type:"array",description:"Updated Sequenzy block JSON for the step"}}}}},required:["sequenceId"]}},{name:"enable_sequence",description:"Enable/activate a sequence. IMPORTANT: Only call this when the user EXPLICITLY asks to enable or activate a sequence. Never enable sequences automatically after creation - the user must review the content first.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"disable_sequence",description:"Disable/pause a sequence",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"delete_sequence",description:"Delete a sequence",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"send_email",description:"Send a transactional email to a single recipient",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},to:{type:"string",description:"Recipient email address"},subject:{type:"string",description:"Email subject (required if not using templateId)"},html:{type:"string",description:"Email HTML content (required if not using templateId)"},templateId:{type:"string",description:"Template ID to use (alternative to html)"},variables:{type:"object",description:"Variables for template personalization"}},required:["to"]}},{name:"get_stats",description:"Get overview statistics for a time period",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},period:{type:"string",description:"Time period: 7d, 30d, or 90d (default: 7d)"}}}},{name:"get_campaign_stats",description:"Get detailed statistics for a campaign",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},campaignId:{type:"string",description:"Campaign ID"}},required:["campaignId"]}},{name:"get_sequence_stats",description:"Get statistics for a sequence, including per-step failed subscribers and failure reasons",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},sequenceId:{type:"string",description:"Sequence ID"}},required:["sequenceId"]}},{name:"get_subscriber_activity",description:"Get recent activity, email stats, and current sequence enrollments for a subscriber",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},email:{type:"string",description:"Subscriber email address"}},required:["email"]}},{name:"generate_email",description:"Generate email blocks from a prompt",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},prompt:{type:"string",description:"Description of the email to generate"},style:{type:"string",description:"Style: minimal, branded, promotional"},tone:{type:"string",description:"Tone: professional, casual, friendly"}},required:["prompt"]}},{name:"generate_sequence",description:"[DEPRECATED - Use create_sequence instead] Generate a multi-email sequence from a goal. Note: create_sequence now handles AI generation automatically.",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},goal:{type:"string",description:"Goal of the sequence (e.g., 'onboard new SaaS trial users')"},emailCount:{type:"number",description:"Number of emails in the sequence (default: 5, max: 10)"},durationDays:{type:"number",description:"Total duration in days (default: 14)"}},required:["goal"]}},{name:"generate_subject_lines",description:"Generate A/B test subject line variants",inputSchema:{type:"object",properties:{companyId:{type:"string",description:"Company ID. If not provided, uses the currently selected company."},topic:{type:"string",description:"Topic or context for the subject lines"},count:{type:"number",description:"Number of variants to generate (default: 5)"}},required:["topic"]}}];async function F5(Q,X){try{let Y;switch(Q){case"get_account":{let G=await w("GET","/api/v1/account"),J=_6();Y={...G,selectedCompanyId:J??G.currentCompanyId};break}case"select_company":{let G=X.companyId,J=await w("GET","/api/v1/account"),$=J.companies?.find((z)=>z.id===G);if(!$)throw Error(`Company not found. Available companies: ${J.companies?.map((z)=>`${z.name} (${z.id})`).join(", ")??"none"}`);EX(G),Y={success:!0,message:`Switched to company: ${$.name}`,companyId:$.id,companyName:$.name};break}case"get_app_urls":{let G=await D5(X);Y={...B1({companyId:G,campaignId:f(X,"campaignId"),sequenceId:f(X,"sequenceId"),emailId:f(X,"emailId")??f(X,"templateId"),transactionalId:f(X,"transactionalId"),domainId:f(X,"domainId"),status:f(X,"status"),settingsTab:f(X,"settingsTab")}),...G===void 0&&{note:"No company ID is selected. Call get_account, select_company, or pass companyId to get concrete dashboard URLs."}};break}case"create_company":{let G=await w("POST","/api/v1/companies",{name:X.name,domain:X.domain});if(!G.success)throw Error("Failed to create company");let J=G.company.id,$=6,z=0,H=G.company.status;while(H==="processing"&&z<$){await new Promise((D)=>setTimeout(D,20000)),z++;let B=await w("GET",`/api/v1/companies/${J}`);if(B.success)H=B.company.status}EX(J);let K=await w("GET",`/api/v1/companies/${J}`);Y={success:!0,company:K.company,message:H==="processing"?"Company created but still processing. You can continue using it while processing completes.":`Company '${K.company.name}' created and ready to use.`,autoSelected:!0};break}case"get_company":{let G=X.companyId;Y=await w("GET",`/api/v1/companies/${G}`);break}case"create_api_key":{let G=X.companyId;Y=await w("POST","/api/v1/api-keys",{name:X.name},G);break}case"list_websites":{let G=X.companyId;Y=await w("GET","/api/v1/websites",void 0,G);break}case"add_website":{let G=X.companyId;Y=await w("POST","/api/v1/websites",{domain:X.domain},G);break}case"check_website":{let G=X.companyId;Y=await w("GET",`/api/v1/websites/${X.domain}`,void 0,G);break}case"get_integration_guide":Y=await w("POST","/api/v1/integration-guide",X);break;case"add_subscriber":{let G=X.companyId;Y=await w("POST","/api/v1/subscribers",{email:X.email,customAttributes:X.attributes,tags:X.tags,lists:X.listIds},G);break}case"update_subscriber":{let G=X.companyId,J=await PX(String(X.email),G),$=Array.isArray(J.subscriber.tags)?J.subscriber.tags.filter((D)=>typeof D==="string"):[],z=Array.isArray(X.addTags)?X.addTags.filter((D)=>typeof D==="string"&&D.trim()!=="").map(H5):[],H=new Set(Array.isArray(X.removeTags)?X.removeTags.filter((D)=>typeof D==="string"&&D.trim()!=="").map(H5):[]),K=$.filter((D)=>!H.has(D));for(let D of z)if(!K.includes(D))K.push(D);let B={};if(h0(X.attributes))B.customAttributes={...h0(J.subscriber.customAttributes)?J.subscriber.customAttributes:{},...X.attributes};if(X.addTags||X.removeTags)B.tags=K;Y=await w("PATCH",`/api/v1/subscribers/${encodeURIComponent(String(X.email))}`,B,G);break}case"remove_subscriber":{let G=X.companyId;if(X.hardDelete===!0)Y=await w("DELETE",`/api/v1/subscribers/${encodeURIComponent(String(X.email))}`,void 0,G);else Y=await w("PATCH",`/api/v1/subscribers/${encodeURIComponent(String(X.email))}`,{status:"unsubscribed"},G);break}case"get_subscriber":{let G=X.companyId;Y=await PX(String(X.email),G);break}case"search_subscribers":{let G=X.companyId;Y=await $V(X,G);break}case"list_tags":{let G=X.companyId;Y=await w("GET","/api/v1/tags",void 0,G);break}case"list_lists":{let G=X.companyId;Y=await w("GET","/api/v1/lists",void 0,G);break}case"create_list":{let G=X.companyId;Y=await w("POST","/api/v1/lists",X,G);break}case"list_segments":{let G=X.companyId;Y=await w("GET","/api/v1/segments",void 0,G);break}case"create_segment":{let G=X.companyId;Y=await w("POST","/api/v1/segments",{...X,...X.filters!==void 0?{filters:K5(X.filters)}:{},...X.root!==void 0?{root:B5(X.root)}:{}},G);break}case"get_segment_count":{let G=X.companyId;Y=await w("GET",`/api/v1/segments/${X.segmentId}/count`,void 0,G);break}case"list_templates":{let G=X.companyId;Y=await w("GET","/api/v1/templates",void 0,G);break}case"get_template":{let G=X.companyId;Y=await w("GET",`/api/v1/templates/${X.templateId}`,void 0,G);break}case"create_template":{let G=X.companyId;WQ("create_template",X,{requireContent:!0}),Y=await w("POST","/api/v1/templates",X,G);break}case"update_template":{let G=X.companyId,J=new Set(["companyId","templateId","name","subject","html","blocks"]),$=Object.keys(X).filter((z)=>!J.has(z));if($.length>0)throw Error(`\`update_template\` accepts only \`name\`, \`subject\`, \`html\`, and \`blocks\` update fields. Unsupported field${$.length===1?"":"s"}: ${$.map((z)=>`\`${z}\``).join(", ")}.`);if(WQ("update_template",X),X.name===void 0&&X.subject===void 0&&X.html===void 0&&X.blocks===void 0)throw Error("Provide at least one of `name`, `subject`, `html`, or `blocks` when calling `update_template`.");Y=await w("PUT",`/api/v1/templates/${X.templateId}`,X,G);break}case"delete_template":{let G=X.companyId;Y=await w("DELETE",`/api/v1/templates/${X.templateId}`,void 0,G);break}case"list_campaigns":{let G=X.companyId,J=new URLSearchParams;if(X.status)J.set("status",String(X.status));Y=await w("GET",`/api/v1/campaigns?${J}`,void 0,G);break}case"get_campaign":{let G=X.companyId;Y=await w("GET",`/api/v1/campaigns/${X.campaignId}`,void 0,G);break}case"create_campaign":{let G=X.companyId;WV(X);let J=f(X,"prompt");if(J!==void 0){let $=await w("POST","/api/v1/generate/email",{prompt:J,...X.style!==void 0&&{style:X.style},...X.tone!==void 0&&{tone:X.tone}},G),z=f(X,"subject")??(typeof $.subject==="string"&&$.subject.trim()!==""?$.subject.trim():void 0);if(!z)throw Error("`create_campaign` prompt generation did not return a subject. Provide `subject` explicitly.");let H=Array.isArray($.blocks)&&$.blocks.length>0?$.blocks:void 0,K=typeof $.html==="string"&&$.html.trim()!==""?$.html:void 0;if(H===void 0&&K===void 0)throw Error("`create_campaign` prompt generation did not return email blocks. Try again or provide `html` or `blocks` explicitly.");Y=await w("POST","/api/v1/campaigns",{name:X.name,subject:z,...H!==void 0?{blocks:H}:{html:K},...X.segmentId!==void 0&&{segmentId:X.segmentId}},G);break}Y=await w("POST","/api/v1/campaigns",X,G);break}case"update_campaign":{let G=X.companyId,J=new Set(["companyId","campaignId","name","subject","html","blocks","replyTo","replyProfileId"]),$=Object.keys(X).filter((z)=>!J.has(z));if($.length>0)throw Error(`\`update_campaign\` accepts only \`name\`, \`subject\`, \`html\`, \`blocks\`, \`replyTo\`, and \`replyProfileId\` update fields. Unsupported field${$.length===1?"":"s"}: ${$.map((z)=>`\`${z}\``).join(", ")}.`);if(WQ("update_campaign",X),X.replyTo!==void 0&&X.replyProfileId!==void 0)throw Error("Provide either `replyTo` or `replyProfileId` when calling `update_campaign`, not both.");if(X.name===void 0&&X.subject===void 0&&X.html===void 0&&X.blocks===void 0&&X.replyTo===void 0&&X.replyProfileId===void 0)throw Error("Provide at least one of `name`, `subject`, `html`, `blocks`, `replyTo`, or `replyProfileId` when calling `update_campaign`.");Y=await w("PUT",`/api/v1/campaigns/${X.campaignId}`,X,G);break}case"send_test_email":{let G=X.companyId;Y=await w("POST",`/api/v1/campaigns/${X.campaignId}/test`,{to:X.to},G);break}case"list_sequences":{let G=X.companyId;Y=await w("GET","/api/v1/sequences",void 0,G);break}case"get_sequence":{let G=X.companyId;Y=await w("GET",`/api/v1/sequences/${X.sequenceId}`,void 0,G);break}case"create_sequence":{let G=X.companyId,J=Array.isArray(X.steps)&&X.steps.length>0,$=await w("POST","/api/v1/sequences",X,G);if(!$.success){Y=$;break}let z=$.sequence.id;if(J){let A=await w("GET",`/api/v1/sequences/${z}`,void 0,G);if(A.success)Y={success:!0,sequence:A.sequence,message:`Sequence "${A.sequence.name}" created with explicit steps. Review it before enabling.`};else Y=A;break}let H=6,K=0,B="pending";while(B!=="complete"&&K<H){await new Promise((U)=>setTimeout(U,20000)),K++;let A=await w("GET",`/api/v1/sequences/${z}`,void 0,G);if(A.success)B=A.sequence.enrichmentStatus}let D=await w("GET",`/api/v1/sequences/${z}`,void 0,G);if(D.success)Y={success:!0,sequence:D.sequence,message:D.sequence.enrichmentStatus==="complete"?`Sequence "${D.sequence.name}" created with ${D.sequence.emailCount} AI-generated emails. The sequence is ready to review and enable.`:`Sequence "${D.sequence.name}" created. Email enrichment is still in progress (${D.sequence.enrichedCount}/${D.sequence.emailCount} emails generated). You can check status with get_sequence.`};else Y=D;break}case"update_sequence":{let G=X.companyId;Y=await w("PUT",`/api/v1/sequences/${X.sequenceId}`,X,G);break}case"enable_sequence":{let G=X.companyId;Y=await w("POST",`/api/v1/sequences/${X.sequenceId}/enable`,void 0,G);break}case"disable_sequence":{let G=X.companyId;Y=await w("POST",`/api/v1/sequences/${X.sequenceId}/disable`,void 0,G);break}case"delete_sequence":{let G=X.companyId;Y=await w("DELETE",`/api/v1/sequences/${X.sequenceId}`,void 0,G);break}case"send_email":{let G=X.companyId;Y=await w("POST","/api/v1/transactional/send",X,G);break}case"get_stats":{let G=X.companyId,J=X.period??"7d";Y=await w("GET",`/api/v1/metrics?period=${J}`,void 0,G);break}case"get_campaign_stats":{let G=X.companyId;Y=await w("GET",`/api/v1/metrics/campaigns/${X.campaignId}`,void 0,G);break}case"get_sequence_stats":{let G=X.companyId;Y=await w("GET",`/api/v1/metrics/sequences/${X.sequenceId}`,void 0,G);break}case"get_subscriber_activity":{let G=X.companyId,J=await PX(String(X.email),G);Y={success:J.success,email:J.subscriber.email,emailStats:J.subscriber.emailStats??null,activity:J.subscriber.activity??[],sequenceEnrollments:J.subscriber.sequenceEnrollments??[]};break}case"generate_email":{let G=X.companyId;Y=await w("POST","/api/v1/generate/email",X,G);break}case"generate_sequence":{let G=X.companyId;Y=await w("POST","/api/v1/generate/sequence",X,G);break}case"generate_subject_lines":{let G=X.companyId;Y=await w("POST","/api/v1/generate/subjects",X,G);break}default:throw Error(`Unknown tool: ${Q}`)}let W=GV(Y);if(W)throw W;return Y=await KV(Q,X,Y),{content:[{type:"text",text:JSON.stringify(Y,null,2)}]}}catch(Y){return{isError:!0,content:[{type:"text",text:q1(Y)}]}}}var BV=process.env.SEQUENZY_API_URL??"https://api.sequenzy.com",L5=process.env.SEQUENZY_API_KEY,IX=null;if(!L5)console.error(q1(new g1("SEQUENZY_API_KEY environment variable is required",401,void 0,"MCP_AUTH_REQUIRED"))),process.exit(1);function _6(){return IX}function EX(Q){IX=Q}var y6=new ZX({name:"sequenzy",version:W5.version},{capabilities:{tools:{},resources:{}}});function DV(Q){if(!Q.trim())return{message:"Request failed"};try{let X=JSON.parse(Q);if(typeof X==="string")return{message:X};if(typeof X.error==="string")return{message:X.error,code:X.code};if(X.error&&typeof X.error==="object")return{message:X.error.message??X.message??Q,code:X.error.code??X.code};return{message:X.message??Q,code:X.code}}catch{return{message:Q}}}async function w(Q,X,Y,W){let G={"Content-Type":"application/json",Authorization:`Bearer ${L5}`},J=W??IX;if(J)G["x-company-id"]=J;let $;try{$=await fetch(`${BV}${X}`,{method:Q,headers:G,body:Y?JSON.stringify(Y):void 0})}catch(z){throw new g1(z instanceof Error?z.message:"Failed to reach Sequenzy API",0,void 0,"NETWORK_ERROR")}if(!$.ok){let z=await $.text(),H=DV(z);throw new g1(H.message,$.status,z,H.code)}return $.json()}y6.setRequestHandler(z9,async()=>{return{tools:A5}});y6.setRequestHandler(K6,async(Q)=>{let{name:X,arguments:Y}=Q.params;return F5(X,Y??{})});y6.setRequestHandler(Q9,async()=>{return{resources:$5}});y6.setRequestHandler(Y9,async(Q)=>{let{uri:X}=Q.params;return z5(X)});async function AV(){let Q=new wX;await y6.connect(Q),console.error("Sequenzy MCP server running on stdio")}AV().catch((Q)=>{console.error(q1(Q)),process.exit(1)});export{EX as setSelectedCompanyId,_6 as getSelectedCompanyId,w as apiRequest};
|
package/package.json
CHANGED
package/server.json
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
"source": "github",
|
|
8
8
|
"subfolder": "packages/mcp"
|
|
9
9
|
},
|
|
10
|
-
"version": "0.0.
|
|
10
|
+
"version": "0.0.21",
|
|
11
11
|
"packages": [
|
|
12
12
|
{
|
|
13
13
|
"registryType": "npm",
|
|
14
14
|
"identifier": "@sequenzy/mcp",
|
|
15
|
-
"version": "0.0.
|
|
15
|
+
"version": "0.0.21",
|
|
16
16
|
"runtime": "node",
|
|
17
17
|
"transport": {
|
|
18
18
|
"type": "stdio"
|