@novu/framework 2.10.1-alpha.6 → 2.10.1-alpha.7

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.
Files changed (40) hide show
  1. package/dist/cjs/{index-BAY1Gj4h.d.cts → index-DtCBrkhW.d.cts} +27 -25
  2. package/dist/cjs/index.cjs +2 -2
  3. package/dist/cjs/index.d.cts +1 -1
  4. package/dist/cjs/servers/express.cjs +2 -2
  5. package/dist/cjs/servers/express.d.cts +2 -2
  6. package/dist/cjs/servers/h3.cjs +30 -30
  7. package/dist/cjs/servers/h3.d.cts +2 -2
  8. package/dist/cjs/servers/lambda.cjs +2 -2
  9. package/dist/cjs/servers/lambda.d.cts +2 -2
  10. package/dist/cjs/servers/nest.cjs +2 -2
  11. package/dist/cjs/servers/nest.d.cts +2 -2
  12. package/dist/cjs/servers/next.cjs +2 -2
  13. package/dist/cjs/servers/next.d.cts +2 -2
  14. package/dist/cjs/servers/nuxt.cjs +30 -30
  15. package/dist/cjs/servers/nuxt.d.cts +2 -2
  16. package/dist/cjs/servers/remix.cjs +2 -2
  17. package/dist/cjs/servers/remix.d.cts +2 -2
  18. package/dist/cjs/servers/sveltekit.cjs +2 -2
  19. package/dist/cjs/servers/sveltekit.d.cts +2 -2
  20. package/dist/esm/{chunk-H2XIPY7V.js → chunk-E6L6ATIB.js} +2 -2
  21. package/dist/esm/{index-DiFdSsia.d.ts → index-CAMe0gXf.d.ts} +27 -25
  22. package/dist/esm/index.d.ts +1 -1
  23. package/dist/esm/index.js +1 -1
  24. package/dist/esm/servers/express.d.ts +2 -2
  25. package/dist/esm/servers/express.js +1 -1
  26. package/dist/esm/servers/h3.d.ts +2 -2
  27. package/dist/esm/servers/h3.js +1 -1
  28. package/dist/esm/servers/lambda.d.ts +2 -2
  29. package/dist/esm/servers/lambda.js +1 -1
  30. package/dist/esm/servers/nest.d.ts +2 -2
  31. package/dist/esm/servers/nest.js +1 -1
  32. package/dist/esm/servers/next.d.ts +2 -2
  33. package/dist/esm/servers/next.js +1 -1
  34. package/dist/esm/servers/nuxt.d.ts +2 -2
  35. package/dist/esm/servers/nuxt.js +1 -1
  36. package/dist/esm/servers/remix.d.ts +2 -2
  37. package/dist/esm/servers/remix.js +1 -1
  38. package/dist/esm/servers/sveltekit.d.ts +2 -2
  39. package/dist/esm/servers/sveltekit.js +1 -1
  40. package/package.json +1 -1
@@ -89,7 +89,7 @@ et dolore magna aliqua Ut enim ad minim veniam quis nostrud exercitation ullamco
89
89
  commodo consequat Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
90
90
  pariatur Excepteur sint occaecat cupidatat non proident sunt in culpa qui officia deserunt mollit anim id est
91
91
  laborum`.split(/\W/),Jt=ua,Yt={type:Ge.ALLOWED_TYPES},Yn=da,Rr=fa,Gn=ha,Gt=pa,zn=ga,Xn=ma,Cr="[a-zA-Z][a-zA-Z0-9+-.]*",zt=`https?://{hostname}(?:${Cr})+`,Qn="(?:\\?([a-z]{1,7}(=\\w{1,5})?&){0,3})?",He={email:"[a-zA-Z\\d][a-zA-Z\\d-]{1,13}[a-zA-Z\\d]@{hostname}",hostname:"[a-zA-Z]{1,33}\\.[a-z]{2,4}",ipv6:"[a-f\\d]{4}(:[a-f\\d]{4}){7}",uri:zt,slug:"[a-zA-Z\\d_-]+","uri-reference":`${zt}${Qn}`,"uri-template":zt.replace("(?:","(?:/\\{[a-z][:a-zA-Z0-9-]*\\}|"),"json-pointer":`(/(?:${Cr.replace("]*","/]*")}|~[01]))+`,uuid:"^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$",duration:"^P(?!$)((\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?|(\\d+W)?)$"},He.iri=He["uri-reference"],He["iri-reference"]=He["uri-reference"],He["idn-email"]=He.email,He["idn-hostname"]=He.hostname,Zn=new RegExp(`\\{(${Object.keys(He).join("|")})\\}`),es=ya,ts=Sa,rs={boolean:Hn,null:Kn,array:qn,integer:Vn,number:Ir,object:Yn,string:ts},It=rs,ns=mt,ss=({refs:n,schema:i,container:o,synchronous:d,refDepthMax:f,refDepthMin:y})=>{let g={},k={},W=0,_,U;return g.resolveSchema=(T,V,j)=>{if(T==null)return null;if(typeof T.generate=="function")return T;if(typeof(T.$id||T.id)=="string"&&(delete T.id,delete T.$id,delete T.$schema),typeof T.$ref=="string"){let Z=Math.max(y,f)-1;if(T.$ref==="#"||k[T.$ref]<0||_===T.$ref&&++W>Z)return T.$ref!=="#"&&U&&U.length===j.length?pe.getLocalRef(i,T.$ref,d&&n):(delete T.$ref,T);typeof k[T.$ref]=="undefined"&&(k[T.$ref]=ee.number(y,f)-1),U=j,_=T.$ref;let se;T.$ref.indexOf("#/")===-1?se=n[T.$ref]||null:se=pe.getLocalRef(i,T.$ref,d&&n)||null;let me;if(typeof se!="undefined"){if(!se&&ne("ignoreMissingRefs")!==!0)throw new Error(`Reference not found: ${T.$ref}`);k[T.$ref]-=1,pe.merge(T,se||{}),me=d&&se&&se.$ref}return me||delete T.$ref,T}if(Array.isArray(T.allOf)){let Z=T.allOf;delete T.allOf,Z.forEach(se=>{let me=g.resolveSchema(se,null,j);pe.merge(T,typeof me.thunk=="function"?me.thunk(T):me),Array.isArray(T.allOf)&&g.resolveSchema(T,V,j)})}if(Array.isArray(T.oneOf||T.anyOf)&&j[j.length-2]!=="dependencies"){let Z=T.oneOf||T.anyOf;return T.enum&&T.oneOf&&(T.enum=T.enum.filter(se=>pe.validate(se,Z))),{thunk(se){let me=pe.omitProps(T,["anyOf","oneOf"]),we=ee.pick(Z);return pe.merge(me,we),Z.forEach(H=>{H.required&&H!==we&&H.required.forEach(A=>{if(we.required&&we.required.includes(A))return;let E=me.required&&me.required.includes(A);me.properties&&!E&&delete me.properties[A],se&&se.properties&&delete se.properties[A]})}),me}}}if(Object.keys(T).forEach(Z=>{(Array.isArray(T[Z])||typeof T[Z]=="object")&&!pe.isKey(Z)&&(T[Z]=g.resolveSchema(T[Z],Z,j.concat(Z)))}),j){let Z=j[j.length-1];if(Z==="properties"||Z==="items")return T}return o.wrap(T)},g},is=ss,xr=_a,Nr=ka,Pe=Sr(En(),1),Ma=Pe.default.binaryOptions,Ta=Pe.default.boolOptions,Ia=Pe.default.intOptions,Ra=Pe.default.nullOptions,Ca=Pe.default.strOptions,xa=Pe.default.Schema,Na=Pe.default.Alias,Pa=Pe.default.Collection,La=Pe.default.Merge,$a=Pe.default.Node,Fa=Pe.default.Pair,Da=Pe.default.Scalar,as=Pe.default.YAMLMap,os=Pe.default.YAMLSeq,Rt=va,Qe=new Ln,_e=(n,i,o)=>(console.debug("[json-schema-faker] calling JSONSchemaFaker() is deprecated, call either .generate() or .resolve()"),o&&console.debug("[json-schema-faker] local references are only supported by calling .resolve()"),_e.generate(n,i)),_e.generateWithContext=(n,i)=>{let o=un(i,n);return xr(o,n,Qe,!0)},_e.generate=(n,i)=>Nr(_e.generateWithContext(n,i)),_e.generateYAML=(n,i)=>Rt(_e.generateWithContext(n,i)),_e.resolveWithContext=(n,i,o)=>{typeof i=="string"&&(o=i,i={}),o=o||(typeof process!="undefined"&&typeof process.cwd=="function"?process.cwd():""),o=`${o.replace(/\/+$/,"")}/`;let d=un(i,n),f={order:1,canRead(g){let k=g.url.replace("/:",":");return d[k]||d[k.split("/").pop()]},read(g,k){try{k(null,this.canRead(g))}catch(W){k(W)}}},{$RefParser:y}=_r();return y.bundle(o,n,{resolve:{file:{order:100},http:{order:200},fixedRefs:f},dereference:{circular:"ignore"}}).then(g=>xr(d,g,Qe)).catch(g=>{throw new Error(`Error while resolving schema (${g.message})`)})},_e.resolve=(n,i,o)=>_e.resolveWithContext(n,i,o).then(Nr),_e.resolveYAML=(n,i,o)=>_e.resolveWithContext(n,i,o).then(Rt),cn(),_e.format=Tr,_e.option=ne,_e.random=ee,_e.extend=(n,i)=>(Qe.extend(n,i),_e),_e.define=(n,i)=>(Qe.define(n,i),_e),_e.reset=n=>(Qe.reset(n),cn(),_e),_e.locate=n=>Qe.get(n),_e.VERSION="0.5.5",ls={..._e},cs=_e}}),Ua=p({"src/src/main.iife.js"(n,i){var o=(Wa(),C(Q));typeof $RefParser!="undefined"&&typeof JSONPath!="undefined"&&o.setDependencies({...JSONPath,$RefParser}),typeof window!="undefined"&&(window.JSONSchemaFaker=o.default),i.exports=o.default,i.exports.JSONSchemaFaker=o.JSONSchemaFaker}});return Ua()})();((t,e)=>{t.JSONSchemaFaker=e()})(typeof self!="undefined"?self:typeof window!="undefined"?window:globalThis,()=>rr);rr.random.shuffle=function(){return["[placeholder]"]};rr.option({useDefaultValue:!0,alwaysFakeOptionals:!0});function Gs(t){return rr.generate(t)}var zs=async(t,e)=>{let r=new TextEncoder,s=r.encode(t),a=r.encode(e),p=await crypto.subtle.importKey("raw",s,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),m=await crypto.subtle.sign("HMAC",p,a);return Array.from(new Uint8Array(m)).map(M=>M.toString(16).padStart(2,"0")).join("")};import{Response as eo}from"cross-fetch";var mc=()=>typeof Response!="undefined"?Response:eo,Xs=async()=>{if(process.env.NOVU_BRIDGE_ORIGIN)return`${process.env.NOVU_BRIDGE_ORIGIN}/api/novu`;if(process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"&&process.env.NEXT_PUBLIC_VERCEL_URL)return`https://${process.env.NEXT_PUBLIC_VERCEL_URL}/api/novu`;try{if(process.env.NODE_ENV==="development"||process.env.NODE_ENV==="dev"){let e=await(await fetch("http://localhost:2022/.well-known/novu")).json();return`${e.tunnelOrigin}${e.route}`}}catch(t){console.error(t)}return""};function Qs(t){return!!t&&typeof t=="object"&&"error"in t&&"message"in t&&"statusCode"in t}var nr=(t,e)=>{if(!t)throw new As;return{post:async(r,s)=>{let a=await fetch(`${e}/v1${r}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${t}`},body:JSON.stringify(s)}),p=await a.json();if(a.ok)return p;throw Qs(p)?new Es(p.statusCode,p.error,p.message):new Zt(p)},delete:async r=>(await fetch(`${e}/v1${r}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${t}`}})).json()}};import St from"chalk";var be={info:t=>St.blue(t),warning:t=>St.yellow(t),error:t=>St.red(t),success:t=>St.green(t),underline:t=>St.underline(t),bold:t=>St.bold(t)},Te={SUCCESS:be.success("\u2714"),ERROR:be.error("\u2717"),WARNING:be.warning("\u26A0"),INFO:be.info("\u2139"),ARROW:be.bold("\u2192"),MOCK:be.info("\u25CB"),HYDRATED:be.bold(be.info("\u2192")),STEP:be.info("\u03C3"),ACTION:be.info("\u03B1"),DURATION:be.info("\u0394"),PROVIDER:be.info("\u2699"),OUTPUT:be.info("\u21E2"),INPUT:be.info("\u21E0"),WORKFLOW:be.info("\u03C9"),STATE:be.info("\u03C3"),EXECUTE:be.info("\u03B5"),PREVIEW:be.info("\u03C1")};function sr(t){return t||process.env.NOVU_API_URL||"https://api.novu.co"}function ir(t){return t||process.env.NOVU_SECRET_KEY||process.env.NOVU_API_KEY||""}import ei from"sanitize-html";var to=["src","alt","width","height","loading","srcset","sizes","crossorigin","usemap","ismap","class","id","style","title","dir","lang"];function ro(t){return t.toLowerCase().startsWith("on")}function no(t){return t.replace(/<\/([a-zA-Z][a-zA-Z0-9]*)\s*\/[^>]*>/g,"</$1>")}var so={allowedTags:ei.defaults.allowedTags.concat(["style","img","html","head","body","link","meta","title"]),allowedAttributes:!1,transformTags:{"*":(t,e)=>{let r={};for(let[s,a]of Object.entries(e))ro(s)||(r[s]=a);return{tagName:t,attribs:r}},img:(t,e)=>{let r={};for(let[s,a]of Object.entries(e))to.includes(s.toLowerCase())&&(r[s]=a);return{tagName:t,attribs:r}}},allowVulnerableTags:!0,parseStyleAttributes:!1,parser:{lowerCaseAttributeNames:!0}},Zs=t=>{if(!t)return t;let e=no(t),r=/^<!DOCTYPE .*?>/,s=e.match(r),a=ei(e,so);return s?s[0]+a:a},ar=t=>Object.keys(t).reduce((e,r)=>{let s=t[r];return typeof s=="string"?e[r]=Zs(s):Array.isArray(s)?e[r]=s.map(a=>typeof a=="string"?Zs(a):typeof a=="object"?ar(a):a):typeof s=="object"&&s!==null?e[r]=ar(s):e[r]=s,e},{});function ti(t,e=!0){e&&(console.log(`
92
- ${be.bold(be.underline("Discovered workflowId:"))} '${t.workflowId}'`),t.steps.forEach((r,s)=>{let a=s===t.steps.length-1;console.log(`${a?"\u2514":"\u251C"} ${Te.STEP} Discovered stepId: '${r.stepId}' Type: '${r.type}'`),r.providers.forEach((m,M)=>{let C=M===r.providers.length-1;console.log(`${a?" ":"\u2502"} ${C?"\u2514":"\u251C"} ${Te.PROVIDER} Discovered provider: '${m.type}'`)})}))}import{jsonrepair as io}from"jsonrepair";function ao(t){let e=t.trim();return(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))&&e.length>2}function oo(t){try{return JSON.parse(t),t}catch{try{return io(t)}catch{return t}}}function ri(t){return Object.fromEntries(Object.entries(t).map(([e,r])=>typeof r=="string"?[e,ao(r)?oo(r):r]:typeof r=="object"&&r!==null&&!Array.isArray(r)?[e,ri(r)]:[e,r]))}function ni(t){return!(t!=null&&t.data)||typeof t.data!="object"||Array.isArray(t.data)?t:{...t,data:ri(t.data)}}function si(){return["development",void 0,"dev"].includes(process.env.NODE_ENV)}var Ft=class{constructor(e){this.discoveredWorkflows=new Map;this.discoverWorkflowPromises=new Map;this.registeredAgents=new Map;this.version="2.10.1-alpha.6";let r=this.buildOptions(e);this.apiUrl=r.apiUrl,this.secretKey=r.secretKey,this.strictAuthentication=r.strictAuthentication,this.verbose=r.verbose,this.templateEngine=Ns()}buildOptions(e){let r={apiUrl:sr(e==null?void 0:e.apiUrl),secretKey:ir(e==null?void 0:e.secretKey),strictAuthentication:!si(),verbose:si()};return(e==null?void 0:e.strictAuthentication)!==void 0?r.strictAuthentication=e.strictAuthentication:process.env.NOVU_STRICT_AUTHENTICATION_ENABLED!==void 0&&(r.strictAuthentication=process.env.NOVU_STRICT_AUTHENTICATION_ENABLED==="true"),(e==null?void 0:e.verbose)!==void 0&&(r.verbose=e.verbose),r}log(...e){this.verbose&&console.log(...e)}async addWorkflows(e){for(let r of e){if(this.discoveredWorkflows.has(r.id))continue;let s=this.discoverWorkflowPromises.get(r.id);if(s){await s;continue}let a=this.addWorkflow(r);this.discoverWorkflowPromises.set(r.id,a),await a}}addAgents(e){for(let r of e)this.registeredAgents.set(r.id,r)}getAgent(e){return this.registeredAgents.get(e)}async addWorkflow(e){try{let r=await e.discover();ti(r,this.verbose),this.discoveredWorkflows.set(e.id,r)}finally{this.discoverWorkflowPromises.delete(e.id)}}healthCheck(){let e=this.getRegisteredWorkflows(),r=e.length,s=e.reduce((a,p)=>a+p.steps.length,0);return{status:"ok",sdkVersion:"2.10.1-alpha.6",frameworkVersion:"2024-06-26",discovered:{workflows:r,steps:s}}}getWorkflow(e){let r=this.discoveredWorkflows.get(e);if(r)return r;throw new Fr(e)}getStep(e,r){let a=this.getWorkflow(e).steps.find(p=>p.stepId===r);if(a)return a;throw new Rs(r)}getRegisteredWorkflows(){return Array.from(this.discoveredWorkflows.values())}discover(){return{workflows:this.getRegisteredWorkflows(),agents:Array.from(this.registeredAgents.keys()).map(e=>({agentId:e}))}}mock(e){try{return Gs(e)}catch(r){return console.warn("Failed to mock schema, returning empty object:",r),{}}}async validate(e,r,s,a,p,m,M){let C=await tr(r,e);if(C.success)return C.data;switch(s){case"event":this.throwInvalidEvent(a,p,C.errors);case"step":this.throwInvalidStep(m,a,p,C.errors);case"provider":this.throwInvalidProvider(m,M,a,p,C.errors);default:throw new Error(`Invalid component: '${s}'`)}}throwInvalidProvider(e,r,s,a,p){if(!e)throw new Error("stepId is required");if(!r)throw new Error("providerId is required");switch(s){case"output":throw new ys(a,e,r,p);default:throw new Error(`Invalid payload type: '${s}'`)}}throwInvalidStep(e,r,s,a){if(!e)throw new Error("stepId is required");switch(r){case"output":throw new ps(s,e,a);case"result":throw new gs(s,e,a);case"controls":throw new hs(s,e,a);default:throw new Error(`Invalid payload type: '${r}'`)}}throwInvalidEvent(e,r,s){switch(e){case"controls":throw new fs(r,s);case"payload":throw new Lr(r,s);default:throw new Error(`Invalid payload type: '${e}'`)}}executeStepFactory(e,r,s){return async(a,p,m)=>{if(s())return;let M=this.getStep(e.workflowId,a),C=e.action==="preview";if(!C&&a===e.stepId){let Ae=await this.createStepControls(M,e),Ie=await this.compileControls(Ae,e);if(await this.shouldSkip(m==null?void 0:m.skip,Ie))return r({options:{skip:!0},outputs:{},providers:{}}),{}}let Q=this.previewStep.bind(this),oe=this.executeStep.bind(this),ie=await(C?Q:oe)(e,{...M,providers:M.providers.map(Ae=>{var Je;let Ie=(Je=m==null?void 0:m.providers)==null?void 0:Je[Ae.type];if(!Ie)throw new _s(Ae.type);return{...Ae,resolve:Ie}}),resolve:p});return this.shouldSanitize({stepType:M.type,options:m})&&(ie={...ie,outputs:ar(ie.outputs)}),a===e.stepId&&r({...ie,options:{skip:!1}}),ie.outputs}}shouldSanitize({stepType:e,options:r}){return(r==null?void 0:r.disableOutputSanitization)===!0?!1:["email","in_app"].includes(e)}async shouldSkip(e,r){return e?e(r):!1}async executeWorkflow(e){let a=`${{execute:"Executing",preview:"Previewing"}[e.action]||e.action} workflowId:`;this.log(`
92
+ ${be.bold(be.underline("Discovered workflowId:"))} '${t.workflowId}'`),t.steps.forEach((r,s)=>{let a=s===t.steps.length-1;console.log(`${a?"\u2514":"\u251C"} ${Te.STEP} Discovered stepId: '${r.stepId}' Type: '${r.type}'`),r.providers.forEach((m,M)=>{let C=M===r.providers.length-1;console.log(`${a?" ":"\u2502"} ${C?"\u2514":"\u251C"} ${Te.PROVIDER} Discovered provider: '${m.type}'`)})}))}import{jsonrepair as io}from"jsonrepair";function ao(t){let e=t.trim();return(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))&&e.length>2}function oo(t){try{return JSON.parse(t),t}catch{try{return io(t)}catch{return t}}}function ri(t){return Object.fromEntries(Object.entries(t).map(([e,r])=>typeof r=="string"?[e,ao(r)?oo(r):r]:typeof r=="object"&&r!==null&&!Array.isArray(r)?[e,ri(r)]:[e,r]))}function ni(t){return!(t!=null&&t.data)||typeof t.data!="object"||Array.isArray(t.data)?t:{...t,data:ri(t.data)}}function si(){return["development",void 0,"dev"].includes(process.env.NODE_ENV)}var Ft=class{constructor(e){this.discoveredWorkflows=new Map;this.discoverWorkflowPromises=new Map;this.registeredAgents=new Map;this.version="2.10.1-alpha.7";let r=this.buildOptions(e);this.apiUrl=r.apiUrl,this.secretKey=r.secretKey,this.strictAuthentication=r.strictAuthentication,this.verbose=r.verbose,this.templateEngine=Ns()}buildOptions(e){let r={apiUrl:sr(e==null?void 0:e.apiUrl),secretKey:ir(e==null?void 0:e.secretKey),strictAuthentication:!si(),verbose:si()};return(e==null?void 0:e.strictAuthentication)!==void 0?r.strictAuthentication=e.strictAuthentication:process.env.NOVU_STRICT_AUTHENTICATION_ENABLED!==void 0&&(r.strictAuthentication=process.env.NOVU_STRICT_AUTHENTICATION_ENABLED==="true"),(e==null?void 0:e.verbose)!==void 0&&(r.verbose=e.verbose),r}log(...e){this.verbose&&console.log(...e)}async addWorkflows(e){for(let r of e){if(this.discoveredWorkflows.has(r.id))continue;let s=this.discoverWorkflowPromises.get(r.id);if(s){await s;continue}let a=this.addWorkflow(r);this.discoverWorkflowPromises.set(r.id,a),await a}}addAgents(e){for(let r of e)this.registeredAgents.set(r.id,r)}getAgent(e){return this.registeredAgents.get(e)}async addWorkflow(e){try{let r=await e.discover();ti(r,this.verbose),this.discoveredWorkflows.set(e.id,r)}finally{this.discoverWorkflowPromises.delete(e.id)}}healthCheck(){let e=this.getRegisteredWorkflows(),r=e.length,s=e.reduce((a,p)=>a+p.steps.length,0);return{status:"ok",sdkVersion:"2.10.1-alpha.7",frameworkVersion:"2024-06-26",discovered:{workflows:r,steps:s}}}getWorkflow(e){let r=this.discoveredWorkflows.get(e);if(r)return r;throw new Fr(e)}getStep(e,r){let a=this.getWorkflow(e).steps.find(p=>p.stepId===r);if(a)return a;throw new Rs(r)}getRegisteredWorkflows(){return Array.from(this.discoveredWorkflows.values())}discover(){return{workflows:this.getRegisteredWorkflows(),agents:Array.from(this.registeredAgents.keys()).map(e=>({agentId:e}))}}mock(e){try{return Gs(e)}catch(r){return console.warn("Failed to mock schema, returning empty object:",r),{}}}async validate(e,r,s,a,p,m,M){let C=await tr(r,e);if(C.success)return C.data;switch(s){case"event":this.throwInvalidEvent(a,p,C.errors);case"step":this.throwInvalidStep(m,a,p,C.errors);case"provider":this.throwInvalidProvider(m,M,a,p,C.errors);default:throw new Error(`Invalid component: '${s}'`)}}throwInvalidProvider(e,r,s,a,p){if(!e)throw new Error("stepId is required");if(!r)throw new Error("providerId is required");switch(s){case"output":throw new ys(a,e,r,p);default:throw new Error(`Invalid payload type: '${s}'`)}}throwInvalidStep(e,r,s,a){if(!e)throw new Error("stepId is required");switch(r){case"output":throw new ps(s,e,a);case"result":throw new gs(s,e,a);case"controls":throw new hs(s,e,a);default:throw new Error(`Invalid payload type: '${r}'`)}}throwInvalidEvent(e,r,s){switch(e){case"controls":throw new fs(r,s);case"payload":throw new Lr(r,s);default:throw new Error(`Invalid payload type: '${e}'`)}}executeStepFactory(e,r,s){return async(a,p,m)=>{if(s())return;let M=this.getStep(e.workflowId,a),C=e.action==="preview";if(!C&&a===e.stepId){let Ae=await this.createStepControls(M,e),Ie=await this.compileControls(Ae,e);if(await this.shouldSkip(m==null?void 0:m.skip,Ie))return r({options:{skip:!0},outputs:{},providers:{}}),{}}let Q=this.previewStep.bind(this),oe=this.executeStep.bind(this),ie=await(C?Q:oe)(e,{...M,providers:M.providers.map(Ae=>{var Je;let Ie=(Je=m==null?void 0:m.providers)==null?void 0:Je[Ae.type];if(!Ie)throw new _s(Ae.type);return{...Ae,resolve:Ie}}),resolve:p});return this.shouldSanitize({stepType:M.type,options:m})&&(ie={...ie,outputs:ar(ie.outputs)}),a===e.stepId&&r({...ie,options:{skip:!1}}),ie.outputs}}shouldSanitize({stepType:e,options:r}){return(r==null?void 0:r.disableOutputSanitization)===!0?!1:["email","in_app"].includes(e)}async shouldSkip(e,r){return e?e(r):!1}async executeWorkflow(e){let a=`${{execute:"Executing",preview:"Previewing"}[e.action]||e.action} workflowId:`;this.log(`
93
93
  ${be.bold(be.underline(a))} '${e.workflowId}'`);let p=this.getWorkflow(e.workflowId),m=process.hrtime(),M={outputs:{},providers:{},options:{skip:!1}},C,Q=!1,oe=new Promise(Ye=>{C=Ye}),X=Ye=>{if(Q)throw new Error("setResult can only be called once per workflow execution");C(),Q=!0,M=Ye},ie=()=>Q,Ae;try{if(e.action==="execute"&&!e.payload)throw new Lr(e.workflowId,{message:"Event `payload` is required"});let Ye=await this.createExecutionPayload(e,p),qe={...e,payload:Ye};await Promise.race([oe,p.execute({payload:Ye,env:e.env,controls:{},subscriber:e.subscriber,context:e.context,step:{email:this.executeStepFactory(qe,X,ie),sms:this.executeStepFactory(qe,X,ie),inApp:this.executeStepFactory(qe,X,ie),digest:this.executeStepFactory(qe,X,ie),delay:this.executeStepFactory(qe,X,ie),push:this.executeStepFactory(qe,X,ie),chat:this.executeStepFactory(qe,X,ie),custom:this.executeStepFactory(qe,X,ie),throttle:this.executeStepFactory(qe,X,ie)}})])}catch(Ye){Ae=Ye}let Ie=process.hrtime(m),Je=Ie[0],We=Ie[1],ut=Je*1e3+We/1e6,Xe=Ae?Te.ERROR:Te.SUCCESS,pt={execute:"Executed",preview:"Previewed"}[e.action]||e.action;if(this.log(`${Xe} ${pt} workflowId: \`${e.workflowId}\``),this.prettyPrintExecute(e,ut,Ae),Ae)throw Ae;return{outputs:M.outputs,providers:M.providers,options:M.options,metadata:{status:"success",error:!1,duration:ut}}}async createExecutionPayload(e,r){let{payload:s}=e;if(e.action==="preview"){let p=this.mock(r.payload.schema);s=Object.assign(p,s)}return await this.validate(s,r.payload.unknownSchema,"event","payload",e.workflowId)}prettyPrintExecute(e,r,s){if(!this.verbose)return;let a=s?Te.ERROR:Te.SUCCESS,m={execute:"Executed",preview:"Previewed"}[e.action]||e.action,M=s?"Failed to execute":m,C=s?be.error:be.success,Q=`${a} ${M} workflowId: '${e.workflowId}`;console.log(`
94
94
  ${be.bold(C(Q))}'`),console.log(` \u251C ${Te.STEP} stepId: '${e.stepId}'`),console.log(` \u251C ${Te.ACTION} action: '${e.action}'`),console.log(` \u2514 ${Te.DURATION} duration: '${r.toFixed(2)}ms'
95
95
  `)}async executeProviders(e,r,s){return r.providers.reduce(async(a,p)=>{let m=await a,M=this.previewProvider.bind(this),C=this.executeProvider.bind(this),oe=await(e.action==="preview"?M:C)(e,r,p,s);return{...m,[p.type]:oe}},Promise.resolve({}))}previewProvider(e,r,s,a){return this.log(` ${Te.MOCK} Mocked provider: \`${s.type}\``),this.mock(s.outputs.schema)}async executeProvider(e,r,s,a){try{if(e.stepId===r.stepId){let p=await this.createStepControls(r,e),m=await s.resolve({controls:p,outputs:a}),M=await this.validate(m,s.outputs.unknownSchema,"step","output",e.workflowId,r.stepId,s.type);return this.log(` ${Te.SUCCESS} Executed provider: \`${s.type}\``),{...M,_passthrough:m._passthrough}}else return this.log(` ${Te.HYDRATED} Hydrated provider: \`${s.type}\``),{}}catch(p){throw this.log(` ${Te.ERROR} Failed to execute provider: \`${s.type}\``),new ks(s.type,e.action,p)}}async executeStep(e,r){if(e.stepId===r.stepId)try{let s=await this.createStepControls(r,e),a=await this.compileControls(s,e),p=await r.resolve(a),m=await this.validate(p,r.outputs.unknownSchema,"step","output",e.workflowId,r.stepId),M=await this.executeProviders(e,r,m);return this.log(` ${Te.SUCCESS} Executed stepId: \`${r.stepId}\``),{outputs:m,providers:M}}catch(s){throw this.log(` ${Te.ERROR} Failed to execute stepId: \`${r.stepId}\``),xt(s)?s:new $r(r.stepId,e.action,s)}else try{let s=this.getStepState(e,r.stepId);if(s){let a=await this.validate(s.outputs,r.results.unknownSchema,"step","result",e.workflowId,r.stepId);return this.log(` ${Te.HYDRATED} Hydrated stepId: \`${r.stepId}\``),{outputs:a,providers:await this.executeProviders(e,r,a)}}else throw new ds(e.workflowId,r.stepId)}catch(s){throw this.log(` ${Te.ERROR} Failed to hydrate stepId: \`${r.stepId}\``),s}}async compileControls(e,r){var s;try{let a=this.preprocessTranslationPatterns(JSON.stringify(e));a=this.preprocessFilterTranslationArgs(a);let p=this.templateEngine.parse(a),m=this.getWorkflow(r.workflowId),M={workflow:{workflowId:m.workflowId,name:m.name,description:m.description,tags:m.tags,severity:m.severity},payload:r.payload,subscriber:r.subscriber,context:r.context,steps:co(r.state),env:(s=r.env)!=null?s:{}},C=await this.templateEngine.render(p,M),Q=this.postprocessTranslationMarkers(C),oe=lo(Q),X=JSON.parse(oe);return ni(X)}catch(a){throw new ms(r.workflowId,r.stepId,a)}}preprocessTranslationPatterns(e){return e.replace(/\{\{\s*t\.([\p{L}\p{N}_.-]+)\s*\}\}/gu,"[T:$1]")}preprocessFilterTranslationArgs(e){return e.replace(/'t\.([\p{L}\p{N}_.-]+)'/gu,"'[T:$1]'")}postprocessTranslationMarkers(e){return e.replace(/\[T:([\p{L}\p{N}_.-]+)\]/gu,"{{t.$1}}")}async createStepControls(e,r){return await this.validate(r.controls,e.controls.unknownSchema,"step","controls",r.workflowId,e.stepId)}async previewStep(e,r){try{return await this.constructStepForPreview(e,r)}catch(s){throw this.log(` ${Te.ERROR} Failed to preview stepId: \`${r.stepId}\``),xt(s)?s:new $r(r.stepId,e.action,s)}}async constructStepForPreview(e,r){return e.stepId===r.stepId?await this.previewRequiredStep(r,e):await this.extractMockDataForPreviousSteps(e,r)}async extractMockDataForPreviousSteps(e,r){let s={},a=this.getStepState(e,r.stepId),p=this.mock(r.results.schema);return{outputs:xs(p,(a==null?void 0:a.outputs)||{}),providers:await this.executeProviders(e,r,s)}}async previewRequiredStep(e,r){let s=await this.createStepControls(e,r),a=await this.compileControls(s,r),p=await e.resolve(a),m=await this.validate(p,e.outputs.unknownSchema,"step","output",r.workflowId,e.stepId);return this.log(` ${Te.MOCK} Mocked stepId: \`${e.stepId}\``),{outputs:m,providers:await this.executeProviders(r,e,m)}}getStepState(e,r){return e.state.find(s=>s.stepId===r)}getStepCode(e,r){return{code:this.getStep(e,r).resolve.toString()}}getWorkflowCode(e){return{code:this.getWorkflow(e).execute.toString()}}getCode(e,r){let s;if(e)r?s=this.getStepCode(e,r):s=this.getWorkflowCode(e);else throw new Fr(e);return s}};function co(t){let e={};for(let r of t)e[r.stepId]=r.outputs;return e}var bt=Symbol.for("workflow-serialize"),At=Symbol.for("workflow-deserialize");var uo=Object.defineProperty,fo=Object.defineProperties,ho=Object.getOwnPropertyDescriptors,ii=Object.getOwnPropertySymbols,po=Object.prototype.hasOwnProperty,go=Object.prototype.propertyIsEnumerable,ai=(t,e,r)=>e in t?uo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ui=(t,e)=>{for(var r in e||(e={}))po.call(e,r)&&ai(t,r,e[r]);if(ii)for(var r of ii(e))go.call(e,r)&&ai(t,r,e[r]);return t},di=(t,e)=>fo(t,ho(e)),Fe=(t,e)=>{let r=!1,s=!1;for(let a=0;a<e;a+=1){if(t[a]==="\\"&&a+1<t.length&&t[a+1]==="`"){a+=1;continue}if(t.substring(a,a+3)==="```"){s=!s,a+=2;continue}!s&&t[a]==="`"&&(r=!r)}return r||s},mo=(t,e)=>{let r=t.substring(e,e+3)==="```",s=e>0&&t.substring(e-1,e+2)==="```",a=e>1&&t.substring(e-2,e+1)==="```";return r||s||a},yo=t=>{let e=0;for(let r=0;r<t.length;r+=1){if(t[r]==="\\"&&r+1<t.length&&t[r+1]==="`"){r+=1;continue}t[r]==="`"&&!mo(t,r)&&(e+=1)}return e},ot=(t,e)=>{let r=!1,s=!1,a=-1;for(let p=0;p<t.length;p+=1){if(t[p]==="\\"&&p+1<t.length&&t[p+1]==="`"){p+=1;continue}if(t.substring(p,p+3)==="```"){s=!s,p+=2;continue}if(!s&&t[p]==="`")if(r){if(a<e&&e<p)return!0;r=!1,a=-1}else r=!0,a=p}return!1},wo=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,So=t=>!t||typeof t!="string"||!t.includes(">")?t:t.replace(wo,(e,r,s,a)=>Fe(t,a)?e:`${r}\\>${s}`),bo=/(\*\*)([^*]*\*?)$/,Ao=/(__)([^_]*?)$/,Eo=/(\*\*\*)([^*]*?)$/,_o=/(\*)([^*]*?)$/,ko=/(_)([^_]*?)$/,Oo=/(`)([^`]*?)$/,vo=/(~~)([^~]*?)$/,ft=/^[\s_~*`]*$/,fi=/^[\s]*[-*+][\s]+$/,Mo=/[\p{L}\p{N}_]/u,To=/^```[^`\n]*```?$/,Io=/^\*{4,}$/,Ro=/(__)([^_]+)_$/,Co=/(~~)([^~]+)~$/,oi=/~~/g,lt=t=>{if(!t)return!1;let e=t.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95?!0:Mo.test(t)};var xo=(t,e)=>{let r=1;for(let s=e-1;s>=0;s-=1)if(t[s]==="]")r+=1;else if(t[s]==="["&&(r-=1,r===0))return s;return-1},hi=(t,e)=>{let r=1;for(let s=e+1;s<t.length;s+=1)if(t[s]==="[")r+=1;else if(t[s]==="]"&&(r-=1,r===0))return s;return-1},or=(t,e)=>{let r=!1,s=!1;for(let a=0;a<t.length&&a<e;a+=1){if(t[a]==="\\"&&t[a+1]==="$"){a+=1;continue}t[a]==="$"&&(t[a+1]==="$"?(s=!s,a+=1,r=!1):s||(r=!r))}return r||s},No=(t,e)=>{for(let r=e;r<t.length;r+=1){if(t[r]===")")return!0;if(t[r]===`
@@ -127,4 +127,4 @@ $$`:`${t}$$`},il=t=>rl(t)%2===0?t:sl(t),al=t=>nl(t)%2===1?`${t}$`:t,ol=(t,e,r)=>
127
127
  `),s=t.split(`
128
128
  `);r&&s.length>0&&s.at(-1)===""&&s.pop();let a=[],p=!1,m=!1;for(let C=0;C<s.length;C++){let Q=s[C].trim();if(!p&&(Q.startsWith("```")||Q.startsWith("~~~"))){m=!m,a.push(s[C]);continue}if(m){a.push(s[C]);continue}let oe=Q!==""&&(zr.test(Q)||Xr.test(Q));if(oe&&!p){let X=!1;for(let ie=C;ie<s.length;ie++){let Ae=s[ie].trim();if(Xr.test(Ae)){X=!0;break}if(Ae===""||!zr.test(Ae))break}X&&(a.push("```"),p=!0)}else!oe&&p&&(a.push("```"),p=!1);a.push(s[C])}p&&e&&a.push("```");let M=a.join(`
129
129
  `);return r&&(M+=`
130
- `),M}function Nl(t){return"adapterName"in t&&!("adapter"in t)}var _i="thread-state:";function Pl(t){return t!==null&&typeof t=="object"&&Symbol.asyncIterator in t}var Gu=class Qr{constructor(e){re(this,"id");re(this,"channelId");re(this,"isDM");re(this,"channelVisibility");re(this,"_adapter");re(this,"_adapterName");re(this,"_stateAdapterInstance");re(this,"_recentMessages",[]);re(this,"_isSubscribedContext");re(this,"_currentMessage");re(this,"_streamingUpdateIntervalMs");re(this,"_fallbackStreamingPlaceholderText");re(this,"_channel");re(this,"_messageHistory");re(this,"_logger");var r,s,a,p;this.id=e.id,this.channelId=e.channelId,this.isDM=(r=e.isDM)!=null?r:!1,this.channelVisibility=(s=e.channelVisibility)!=null?s:"unknown",this._isSubscribedContext=(a=e.isSubscribedContext)!=null?a:!1,this._currentMessage=e.currentMessage,this._logger=e.logger,this._streamingUpdateIntervalMs=(p=e.streamingUpdateIntervalMs)!=null?p:500,this._fallbackStreamingPlaceholderText=e.fallbackStreamingPlaceholderText!==void 0?e.fallbackStreamingPlaceholderText:"...",Nl(e)?this._adapterName=e.adapterName:(this._adapter=e.adapter,this._stateAdapterInstance=e.stateAdapter,this._messageHistory=e.messageHistory),e.initialMessage&&(this._recentMessages=[e.initialMessage])}get adapter(){if(this._adapter)return this._adapter;if(!this._adapterName)throw new Error("Thread has no adapter configured");let r=lr().getAdapter(this._adapterName);if(!r)throw new Error(`Adapter "${this._adapterName}" not found in Chat singleton`);return this._adapter=r,r}get _stateAdapter(){if(this._stateAdapterInstance)return this._stateAdapterInstance;let e=lr();return this._stateAdapterInstance=e.getState(),this._stateAdapterInstance}get recentMessages(){return this._recentMessages}set recentMessages(e){this._recentMessages=e}get state(){return this._stateAdapter.get(`${_i}${this.id}`)}async setState(e,r){let s=`${_i}${this.id}`;if(r!=null&&r.replace)await this._stateAdapter.set(s,e,cr);else{let p={...await this._stateAdapter.get(s),...e};await this._stateAdapter.set(s,p,cr)}}get channel(){if(!this._channel){let e=Ml(this.adapter,this.id);this._channel=new vl({id:e,adapter:this.adapter,stateAdapter:this._stateAdapter,isDM:this.isDM,channelVisibility:this.channelVisibility,messageHistory:this._messageHistory})}return this._channel}get messages(){let e=this.adapter,r=this.id,s=this._messageHistory;return{async*[Symbol.asyncIterator](){let a,p=!1;for(;;){let m=await e.fetchMessages(r,{cursor:a,direction:"backward"}),M=[...m.messages].reverse();for(let C of M)p=!0,yield C;if(!m.nextCursor||m.messages.length===0)break;a=m.nextCursor}if(!p&&s){let m=await s.getMessages(r);for(let M=m.length-1;M>=0;M--)yield m[M]}}}}get allMessages(){let e=this.adapter,r=this.id,s=this._messageHistory;return{async*[Symbol.asyncIterator](){let a,p=!1;for(;;){let m=await e.fetchMessages(r,{limit:100,cursor:a,direction:"forward"});for(let M of m.messages)p=!0,yield M;if(!m.nextCursor||m.messages.length===0)break;a=m.nextCursor}if(!p&&s){let m=await s.getMessages(r);for(let M of m)yield M}}}}async isSubscribed(){return this._isSubscribedContext?!0:this._stateAdapter.isSubscribed(this.id)}async subscribe(){await this._stateAdapter.subscribe(this.id),this.adapter.onThreadSubscribe&&await this.adapter.onThreadSubscribe(this.id)}async unsubscribe(){await this._stateAdapter.unsubscribe(this.id)}async post(e){if(vi(e))return await this.handlePostableObject(e),e;if(Pl(e))return this.handleStream(e);let r=e;if(Ke(e)){let p=je(e);if(!p)throw new Error("Invalid JSX element: must be a Card element");r=p}let s=await this.adapter.postMessage(this.id,r),a=this.createSentMessage(s.id,r,s.threadId);return this._messageHistory&&await this._messageHistory.append(this.id,new ht(a)),a}async handlePostableObject(e){await Mi(e,this.adapter,this.id,(r,s)=>this.adapter.postMessage(r,s),this._logger)}async postEphemeral(e,r,s){let{fallbackToDM:a}=s,p=typeof e=="string"?e:e.userId,m;if(Ke(r)){let M=je(r);if(!M)throw new Error("Invalid JSX element: must be a Card element");m=M}else m=r;if(this.adapter.postEphemeral)return this.adapter.postEphemeral(this.id,p,m);if(!a)return null;if(this.adapter.openDM){let M=await this.adapter.openDM(p),C=await this.adapter.postMessage(M,m);return{id:C.id,threadId:M,usedFallback:!0,raw:C.raw}}return null}async schedule(e,r){let s;if(Ke(e)){let a=je(e);if(!a)throw new Error("Invalid JSX element: must be a Card element");s=a}else s=e;if(!this.adapter.scheduleMessage)throw new Ti("Scheduled messages are not supported by this adapter","scheduling");return this.adapter.scheduleMessage(this.id,s,r)}async handleStream(e){var p;let r=Oi(e),s={};if(this._currentMessage){s.recipientUserId=this._currentMessage.author.userId;let m=this._currentMessage.raw;s.recipientTeamId=(p=m==null?void 0:m.team_id)!=null?p:m==null?void 0:m.team}if(this.adapter.stream){let m="",M={[Symbol.asyncIterator]:()=>{let oe=r[Symbol.asyncIterator]();return{async next(){let X=await oe.next();if(!X.done){let ie=X.value;typeof ie=="string"?m+=ie:ie.type==="markdown_text"&&(m+=ie.text)}return X}}}},C=await this.adapter.stream(this.id,M,s),Q=this.createSentMessage(C.id,{markdown:m},C.threadId);return this._messageHistory&&await this._messageHistory.append(this.id,new ht(Q)),Q}let a={[Symbol.asyncIterator]:()=>{let m=r[Symbol.asyncIterator]();return{async next(){for(;;){let M=await m.next();if(M.done)return{value:void 0,done:!0};let C=M.value;if(typeof C=="string")return{value:C,done:!1};if(C.type==="markdown_text")return{value:C.text,done:!1}}}}}};return this.fallbackStream(a,s)}async startTyping(e){await this.adapter.startTyping(this.id,e)}async fallbackStream(e,r){var ut;let s=(ut=r==null?void 0:r.updateIntervalMs)!=null?ut:this._streamingUpdateIntervalMs,a=this._fallbackStreamingPlaceholderText,p=a===null?null:await this.adapter.postMessage(this.id,a),m=this.id,M=new Il,C="",Q=!1,oe=null,X=null;p&&(m=p.threadId||this.id,C=a!=null?a:"");let ie=()=>{X=setTimeout(()=>{oe=Ae()},s)},Ae=async()=>{var it;if(Q||!p)return;let Xe=M.render();if(Xe!==C)try{await this.adapter.editMessage(m,p.id,{markdown:Xe}),C=Xe}catch(pt){(it=this._logger)==null||it.warn("fallbackStream edit failed",pt)}Q||ie()};p&&ie();try{for await(let Xe of e)if(M.push(Xe),!p){let it=M.render();p=await this.adapter.postMessage(this.id,{markdown:it}),m=p.threadId||this.id,C=it,ie()}}finally{Q=!0,X&&(clearTimeout(X),X=null)}oe&&await oe;let Ie=M.getText(),Je=M.finish();p||(p=await this.adapter.postMessage(this.id,{markdown:Ie}),m=p.threadId||this.id,C=Ie),Je!==C&&await this.adapter.editMessage(m,p.id,{markdown:Ie});let We=this.createSentMessage(p.id,{markdown:Ie},m);return this._messageHistory&&await this._messageHistory.append(this.id,new ht(We)),We}async refresh(){let e=await this.adapter.fetchMessages(this.id,{limit:50});e.messages.length>0?this._recentMessages=e.messages:this._messageHistory?this._recentMessages=await this._messageHistory.getMessages(this.id,50):this._recentMessages=[]}mentionUser(e){return`<@${e}>`}toJSON(){var e;return{_type:"chat:Thread",id:this.id,channelId:this.channelId,channelVisibility:this.channelVisibility,currentMessage:(e=this._currentMessage)==null?void 0:e.toJSON(),isDM:this.isDM,adapterName:this.adapter.name}}static fromJSON(e,r){let s=new Qr({id:e.id,adapterName:e.adapterName,channelId:e.channelId,channelVisibility:e.channelVisibility,currentMessage:e.currentMessage?ht.fromJSON(e.currentMessage):void 0,isDM:e.isDM});return r&&(s._adapter=r),s}static[bt](e){return e.toJSON()}static[At](e){return Qr.fromJSON(e)}createSentMessage(e,r,s){let a=this.adapter,p=s||this.id,m=this,{plainText:M,formatted:C,attachments:Q}=Ll(r);return{id:e,threadId:p,text:M,formatted:C,raw:null,links:[],author:{userId:"self",userName:a.userName,fullName:a.userName,isBot:!0,isMe:!0},metadata:{dateSent:new Date,edited:!1},attachments:Q,toJSON(){return new ht(this).toJSON()},async edit(X){let ie=X;if(Ke(X)){let Ae=je(X);if(!Ae)throw new Error("Invalid JSX element: must be a Card element");ie=Ae}return await a.editMessage(p,e,ie),m.createSentMessage(e,ie)},async delete(){await a.deleteMessage(p,e)},async addReaction(X){await a.addReaction(p,e,X)},async removeReaction(X){await a.removeReaction(p,e,X)}}}createSentMessageFromMessage(e){let r=this.adapter,s=this.id,a=e.id,p=this;return{id:e.id,threadId:e.threadId,text:e.text,formatted:e.formatted,raw:e.raw,author:e.author,metadata:e.metadata,attachments:e.attachments,links:e.links,isMention:e.isMention,toJSON(){return e.toJSON()},async edit(m){let M=m;if(Ke(m)){let C=je(m);if(!C)throw new Error("Invalid JSX element: must be a Card element");M=C}return await r.editMessage(s,a,M),p.createSentMessage(a,M,s)},async delete(){await r.deleteMessage(s,a)},async addReaction(m){await r.addReaction(s,a,m)},async removeReaction(m){await r.removeReaction(s,a,m)}}}};function Ll(t){if(typeof t=="string")return{plainText:t,formatted:nt([rt([tt(t)])]),attachments:[]};if("raw"in t)return{plainText:t.raw,formatted:nt([rt([tt(t.raw)])]),attachments:t.attachments||[]};if("markdown"in t){let e=Dr(t.markdown);return{plainText:Nt(e),formatted:e,attachments:t.attachments||[]}}if("ast"in t)return{plainText:Nt(t.ast),formatted:t.ast,attachments:t.attachments||[]};if("card"in t){let e=t.fallbackText||Pt(t.card);return{plainText:e,formatted:nt([rt([tt(e)])]),attachments:[]}}if("type"in t&&t.type==="card"){let e=Pt(t);return{plainText:e,formatted:nt([rt([tt(e)])]),attachments:[]}}throw new Error("Invalid PostableMessage format")}var zu=300*1e3,Xu=1440*60*1e3;var ki=new Map;function Et(t){let e=ki.get(t);return e||(e=Object.freeze({name:t,toString:()=>`{{emoji:${t}}}`,toJSON:()=>`{{emoji:${t}}}`}),ki.set(t,e)),e}var $l={thumbs_up:{slack:["+1","thumbsup"],gchat:"\u{1F44D}"},thumbs_down:{slack:["-1","thumbsdown"],gchat:"\u{1F44E}"},clap:{slack:"clap",gchat:"\u{1F44F}"},wave:{slack:"wave",gchat:"\u{1F44B}"},pray:{slack:"pray",gchat:"\u{1F64F}"},muscle:{slack:"muscle",gchat:"\u{1F4AA}"},ok_hand:{slack:"ok_hand",gchat:"\u{1F44C}"},point_up:{slack:"point_up",gchat:"\u{1F446}"},point_down:{slack:"point_down",gchat:"\u{1F447}"},point_left:{slack:"point_left",gchat:"\u{1F448}"},point_right:{slack:"point_right",gchat:"\u{1F449}"},raised_hands:{slack:"raised_hands",gchat:"\u{1F64C}"},shrug:{slack:"shrug",gchat:"\u{1F937}"},facepalm:{slack:"facepalm",gchat:"\u{1F926}"},heart:{slack:"heart",gchat:["\u2764\uFE0F","\u2764"]},smile:{slack:["smile","slightly_smiling_face"],gchat:"\u{1F60A}"},laugh:{slack:["laughing","satisfied","joy"],gchat:["\u{1F602}","\u{1F606}"]},thinking:{slack:"thinking_face",gchat:"\u{1F914}"},sad:{slack:["cry","sad","white_frowning_face"],gchat:"\u{1F622}"},cry:{slack:"sob",gchat:"\u{1F62D}"},angry:{slack:"angry",gchat:"\u{1F620}"},love_eyes:{slack:"heart_eyes",gchat:"\u{1F60D}"},cool:{slack:"sunglasses",gchat:"\u{1F60E}"},wink:{slack:"wink",gchat:"\u{1F609}"},surprised:{slack:"open_mouth",gchat:"\u{1F62E}"},worried:{slack:"worried",gchat:"\u{1F61F}"},confused:{slack:"confused",gchat:"\u{1F615}"},neutral:{slack:"neutral_face",gchat:"\u{1F610}"},sleeping:{slack:"sleeping",gchat:"\u{1F634}"},sick:{slack:"nauseated_face",gchat:"\u{1F922}"},mind_blown:{slack:"exploding_head",gchat:"\u{1F92F}"},relieved:{slack:"relieved",gchat:"\u{1F60C}"},grimace:{slack:"grimacing",gchat:"\u{1F62C}"},rolling_eyes:{slack:"rolling_eyes",gchat:"\u{1F644}"},hug:{slack:"hugging_face",gchat:"\u{1F917}"},zany:{slack:"zany_face",gchat:"\u{1F92A}"},check:{slack:["white_check_mark","heavy_check_mark"],gchat:["\u2705","\u2714\uFE0F"]},x:{slack:["x","heavy_multiplication_x"],gchat:["\u274C","\u2716\uFE0F"]},question:{slack:"question",gchat:["\u2753","?"]},exclamation:{slack:"exclamation",gchat:"\u2757"},warning:{slack:"warning",gchat:"\u26A0\uFE0F"},stop:{slack:"octagonal_sign",gchat:"\u{1F6D1}"},info:{slack:"information_source",gchat:"\u2139\uFE0F"},100:{slack:"100",gchat:"\u{1F4AF}"},fire:{slack:"fire",gchat:"\u{1F525}"},star:{slack:"star",gchat:"\u2B50"},sparkles:{slack:"sparkles",gchat:"\u2728"},lightning:{slack:"zap",gchat:"\u26A1"},boom:{slack:"boom",gchat:"\u{1F4A5}"},eyes:{slack:"eyes",gchat:"\u{1F440}"},green_circle:{slack:"large_green_circle",gchat:"\u{1F7E2}"},yellow_circle:{slack:"large_yellow_circle",gchat:"\u{1F7E1}"},red_circle:{slack:"red_circle",gchat:"\u{1F534}"},blue_circle:{slack:"large_blue_circle",gchat:"\u{1F535}"},white_circle:{slack:"white_circle",gchat:"\u26AA"},black_circle:{slack:"black_circle",gchat:"\u26AB"},rocket:{slack:"rocket",gchat:"\u{1F680}"},party:{slack:["tada","partying_face"],gchat:["\u{1F389}","\u{1F973}"]},confetti:{slack:"confetti_ball",gchat:"\u{1F38A}"},balloon:{slack:"balloon",gchat:"\u{1F388}"},gift:{slack:"gift",gchat:"\u{1F381}"},trophy:{slack:"trophy",gchat:"\u{1F3C6}"},medal:{slack:"first_place_medal",gchat:"\u{1F947}"},lightbulb:{slack:"bulb",gchat:"\u{1F4A1}"},gear:{slack:"gear",gchat:"\u2699\uFE0F"},wrench:{slack:"wrench",gchat:"\u{1F527}"},hammer:{slack:"hammer",gchat:"\u{1F528}"},bug:{slack:"bug",gchat:"\u{1F41B}"},link:{slack:"link",gchat:"\u{1F517}"},lock:{slack:"lock",gchat:"\u{1F512}"},unlock:{slack:"unlock",gchat:"\u{1F513}"},key:{slack:"key",gchat:"\u{1F511}"},pin:{slack:"pushpin",gchat:"\u{1F4CC}"},memo:{slack:"memo",gchat:"\u{1F4DD}"},clipboard:{slack:"clipboard",gchat:"\u{1F4CB}"},calendar:{slack:"calendar",gchat:"\u{1F4C5}"},clock:{slack:"clock1",gchat:"\u{1F550}"},hourglass:{slack:"hourglass",gchat:"\u23F3"},bell:{slack:"bell",gchat:"\u{1F514}"},megaphone:{slack:"mega",gchat:"\u{1F4E2}"},speech_bubble:{slack:"speech_balloon",gchat:"\u{1F4AC}"},email:{slack:"email",gchat:"\u{1F4E7}"},inbox:{slack:"inbox_tray",gchat:"\u{1F4E5}"},outbox:{slack:"outbox_tray",gchat:"\u{1F4E4}"},package:{slack:"package",gchat:"\u{1F4E6}"},folder:{slack:"file_folder",gchat:"\u{1F4C1}"},file:{slack:"page_facing_up",gchat:"\u{1F4C4}"},chart_up:{slack:"chart_with_upwards_trend",gchat:"\u{1F4C8}"},chart_down:{slack:"chart_with_downwards_trend",gchat:"\u{1F4C9}"},coffee:{slack:"coffee",gchat:"\u2615"},pizza:{slack:"pizza",gchat:"\u{1F355}"},beer:{slack:"beer",gchat:"\u{1F37A}"},arrow_up:{slack:"arrow_up",gchat:"\u2B06\uFE0F"},arrow_down:{slack:"arrow_down",gchat:"\u2B07\uFE0F"},arrow_left:{slack:"arrow_left",gchat:"\u2B05\uFE0F"},arrow_right:{slack:"arrow_right",gchat:"\u27A1\uFE0F"},refresh:{slack:"arrows_counterclockwise",gchat:"\u{1F504}"},sun:{slack:"sunny",gchat:"\u2600\uFE0F"},cloud:{slack:"cloud",gchat:"\u2601\uFE0F"},rain:{slack:"rain_cloud",gchat:"\u{1F327}\uFE0F"},snow:{slack:"snowflake",gchat:"\u2744\uFE0F"},rainbow:{slack:"rainbow",gchat:"\u{1F308}"}},Fl=class{constructor(t){re(this,"emojiMap");re(this,"slackToNormalized");re(this,"gchatToNormalized");this.emojiMap={...$l,...t},this.slackToNormalized=new Map,this.gchatToNormalized=new Map,this.buildReverseMaps()}buildReverseMaps(){for(let[t,e]of Object.entries(this.emojiMap)){let r=Array.isArray(e.slack)?e.slack:[e.slack];for(let a of r)this.slackToNormalized.set(a.toLowerCase(),t);let s=Array.isArray(e.gchat)?e.gchat:[e.gchat];for(let a of s)this.gchatToNormalized.set(a,t)}}fromSlack(t){var s;let e=t.replace(/^:|:$/g,"").toLowerCase(),r=(s=this.slackToNormalized.get(e))!=null?s:t;return Et(r)}fromGChat(t){var r;let e=(r=this.gchatToNormalized.get(t))!=null?r:t;return Et(e)}fromTeams(t){var s;let r=(s={like:"thumbs_up",heart:"heart",laugh:"laugh",surprised:"surprised",sad:"sad",angry:"angry"}[t])!=null?s:t;return Et(r)}toSlack(t){let e=typeof t=="string"?t:t.name,r=this.emojiMap[e];return r?Array.isArray(r.slack)?r.slack[0]:r.slack:e}toGChat(t){let e=typeof t=="string"?t:t.name,r=this.emojiMap[e];return r?Array.isArray(r.gchat)?r.gchat[0]:r.gchat:e}toDiscord(t){return this.toGChat(t)}matches(t,e){let r=typeof e=="string"?e:e.name,s=this.emojiMap[r];if(!s)return t===r;let a=Array.isArray(s.slack)?s.slack:[s.slack],p=Array.isArray(s.gchat)?s.gchat:[s.gchat],m=t.replace(/^:|:$/g,"").toLowerCase();return a.some(M=>M.toLowerCase()===m)||p.includes(t)}extend(t){Object.assign(this.emojiMap,t),this.buildReverseMaps()}},Dl=new Fl;function Wl(t){let e=["thumbs_up","thumbs_down","clap","wave","pray","muscle","ok_hand","point_up","point_down","point_left","point_right","raised_hands","shrug","facepalm","heart","smile","laugh","thinking","sad","cry","angry","love_eyes","cool","wink","surprised","worried","confused","neutral","sleeping","sick","mind_blown","relieved","grimace","rolling_eyes","hug","zany","check","x","question","exclamation","warning","stop","info","100","fire","star","sparkles","lightning","boom","eyes","green_circle","yellow_circle","red_circle","blue_circle","white_circle","black_circle","rocket","party","confetti","balloon","gift","trophy","medal","lightbulb","gear","wrench","hammer","bug","link","lock","unlock","key","pin","memo","clipboard","calendar","clock","hourglass","bell","megaphone","speech_bubble","email","inbox","outbox","package","folder","file","chart_up","chart_down","coffee","pizza","beer","arrow_up","arrow_down","arrow_left","arrow_right","refresh","sun","cloud","rain","snow","rainbow"],r={custom:s=>Et(s)};for(let s of e)r[s]=Et(s);if(t){for(let s of Object.keys(t))r[s]=Et(s);Dl.extend(t)}return r}var Qu=Wl(),Ii=Fs,Ri=Ds,Ci=Ps;var xi=Ws,Ni=Ls,Pi=$s;var Li=Hs,$i=Bs,Fi=Us;var Ul={400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",408:"Request Timeout",409:"Conflict",422:"Unprocessable Entity",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"};function ur(t){return typeof t=="string"&&t.trim()?t:!t||typeof t!="object"?null:ur(t.message)}function Hl(t){if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object")return null;let r=e,s=ur(r.message);if(s)return s;let a=ur(r.error);if(a)return a;let p=r.errors;return Array.isArray(p)?ur(p[0]):null}var ct=class extends Error{constructor(e,r){var m;let s=(m=Ul[e])!=null?m:e,a=Hl(r),p=a?`Delivery failed: ${s}: ${a}`:`Delivery failed: ${s}`;super(p),this.name="AgentDeliveryError",this.statusCode=e,this.responseBody=r}};var Bl=5*1024*1024,jl=5*1024*1024,Di=32768,Kl=/^[A-Za-z0-9+/]*={0,2}$/;function ql(t){return"type"in t&&t.type==="card"}function Ut(t,e){return t.filename?`"${t.filename}"`:`at index ${e}`}function Wi(){return globalThis.Buffer}function Vl(t){var e,r,s;return(s=(r=(e=Wi())==null?void 0:e.isBuffer)==null?void 0:r.call(e,t))!=null?s:!1}function Jl(t){return typeof Blob!="undefined"&&t instanceof Blob}function Zr(t){let e=Wi();if(e)return e.from(t).toString("base64");if(typeof btoa!="function")throw new Error("Unable to encode file data: base64 encoding is not available in this runtime.");let r="";for(let s=0;s<t.length;s+=Di){let a=t.subarray(s,s+Di);r+=String.fromCharCode(...a)}return btoa(r)}function Ui(t){let e=t.replace(/\s/g,""),r=e.length%4;if(!e||r===1||!Kl.test(e))return null;let s=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-s}function Wt(t,e,r){if(t>Bl)throw new Error(`Invalid file ${Ut(e,r)}: inline data must be 5 MB or smaller. Use a publicly-accessible URL for larger files.`)}async function Yl(t,e,r){if(typeof t=="string"){let s=Ui(t);if(s===null)throw new Error(`Invalid file ${Ut(e,r)}: data must be a base64-encoded string.`);return Wt(s,e,r),t}if(Vl(t))return Wt(t.byteLength,e,r),t.toString("base64");if(t instanceof Uint8Array)return Wt(t.byteLength,e,r),Zr(t);if(t instanceof ArrayBuffer)return Wt(t.byteLength,e,r),Zr(new Uint8Array(t));if(Jl(t))return Wt(t.size,e,r),Zr(new Uint8Array(await t.arrayBuffer()));throw new Error(`Invalid file ${Ut(e,r)}: data must be a base64 string, Buffer, Uint8Array, ArrayBuffer, or Blob.`)}async function Gl(t){if(!(t!=null&&t.length))return;let e=[],r=0;for(let[s,a]of t.entries()){let p=a.data,m=a.url,M=p!=null,C=m!=null;if(M===C)throw new Error(`Invalid file ${Ut(a,s)}: provide exactly one of data or url.`);if(M){let Q=await Yl(p,a,s),oe=Ui(Q);if(r+=oe!=null?oe:0,r>jl)throw new Error("Invalid files: total inline data must be 5 MB or smaller. Use publicly-accessible URLs for larger files.");e.push({...a,data:Q});continue}if(C&&typeof m!="string")throw new Error(`Invalid file ${Ut(a,s)}: url must be a string.`);e.push(a)}return e}async function Hi(t,e){let r=await Gl(e);if(typeof t=="string")return r?{markdown:t,files:r}:{markdown:t};if(Ke(t)){let s=je(t);if(s)return{card:s}}if(ql(t))return{card:t};throw new Error("Invalid message content \u2014 expected string or CardElement")}var en=class{constructor(e,r,s,a,p){this.conversationId=s;this.integrationIdentifier=a;this.poster=p;this.messageId=e,this.platformThreadId=r}async edit(e,r){let s=await this.poster.post({conversationId:this.conversationId,integrationIdentifier:this.integrationIdentifier,edit:{messageId:this.messageId,content:await Hi(e,r==null?void 0:r.files)}});if(!s)throw new Error("Agent edit did not return a message handle");return this.messageId=s.messageId,this.platformThreadId=s.platformThreadId,this}},Ht=class{constructor(e,r){this._signals=[];this._pendingReactions=[];this._resolveSignal=null;var a,p;this.event=e.event,this.action=(a=e.action)!=null?a:null,this.message=e.message,this.reaction=e.reaction,this.conversation=e.conversation,this.subscriber=e.subscriber,this.history=e.history,this.platform=e.platform,this.platformContext=e.platformContext,this._replyUrl=e.replyUrl,this._conversationId=e.conversationId,this._integrationIdentifier=e.integrationIdentifier,this._secretKey=r,this._poster={post:m=>this._post(m)},this._metadataState={...(p=e.conversation.metadata)!=null?p:{}};let s=this;this.metadata={get(m){return s._metadataState[m]},set(m,M){s._metadataState[m]=M,s._signals.push({type:"metadata",action:"set",key:m,value:M})},delete(m){delete s._metadataState[m],s._signals.push({type:"metadata",action:"delete",key:m})},clear(){s._metadataState={},s._signals.push({type:"metadata",action:"clear"})},get current(){return{...s._metadataState}}}}async reply(e,r){let s={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,reply:await Hi(e,r==null?void 0:r.files)};this._signals.length&&(s.signals=this._signals,this._signals=[]),this._pendingReactions.length&&(s.addReactions=this._pendingReactions,this._pendingReactions=[]),this._resolveSignal&&(s.resolve=this._resolveSignal,this._resolveSignal=null);let a=await this._post(s);if(!a)throw new Error("Agent reply did not return a message handle");return new en(a.messageId,a.platformThreadId,this._conversationId,this._integrationIdentifier,this._poster)}resolve(e){this._resolveSignal={summary:e}}trigger(e,r){this._signals.push({...r,type:"trigger",workflowId:e})}addReaction(e,r){this._pendingReactions.push({messageId:e,emojiName:r})}async flush(){if(!this._signals.length&&!this._resolveSignal&&!this._pendingReactions.length)return;let e={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier};this._signals.length&&(e.signals=this._signals,this._signals=[]),this._pendingReactions.length&&(e.addReactions=this._pendingReactions,this._pendingReactions=[]),this._resolveSignal&&(e.resolve=this._resolveSignal,this._resolveSignal=null),await this._post(e)}async _post(e){let r=await fetch(this._replyUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${this._secretKey}`},body:JSON.stringify(e)});if(!r.ok){let a=await r.text().catch(()=>"");throw new ct(r.status,a)}let s=await r.text().catch(()=>"");if(!s)return null;try{let a=JSON.parse(s),p=a&&typeof a=="object"&&"data"in a?a.data:a;if(p&&typeof p.messageId=="string"&&typeof p.platformThreadId=="string")return{messageId:p.messageId,platformThreadId:p.platformThreadId}}catch{}return null}};function Bi(t,e){if(!t)throw new Error("agent() requires a non-empty agentId");if(!(e!=null&&e.onMessage))throw new Error(`agent('${t}') requires an onMessage handler`);return{id:t,handlers:e}}var Bt=(a=>(a.ON_MESSAGE="onMessage",a.ON_ACTION="onAction",a.ON_RESOLVE="onResolve",a.ON_REACTION="onReaction",a))(Bt||{});var tn=class{constructor(e){this.handler=e.handler,this.client=e.client?e.client:new Ft,this.workflows=e.workflows||[],this.agents=e.agents||[],this.http=nr(this.client.secretKey,this.client.apiUrl),this.frameworkName=e.frameworkName,this.hmacEnabled=this.client.strictAuthentication,this.client.addAgents(this.agents)}createHandler(){return async(...e)=>{await this.client.addWorkflows(this.workflows);let r=await this.handler(...e),s=await this.handleAction({actions:r});return r.transformResponse(s)}}getStaticHeaders(){let e=`novu-framework:v${this.client.version}`;return{"content-type":"application/json","access-control-allow-origin":"*","access-control-allow-private-network":"true","access-control-allow-methods":"GET, POST","access-control-allow-headers":"*","access-control-max-age":"604800","novu-framework-version":"2024-06-26","novu-framework-sdk":"2.10.1-alpha.6","novu-framework-server":this.frameworkName,"user-agent":e}}createResponse(e,r){return{status:e,body:JSON.stringify(r),headers:{...this.getStaticHeaders()}}}createError(e){return{status:e.statusCode,body:JSON.stringify({message:e.message,data:e.data,code:e.code}),headers:this.getStaticHeaders()}}async handleAction({actions:e}){let r=await e.url(),s=await e.method(),a=r.searchParams.get("action")||"health-check",p=r.searchParams.get("workflowId")||"",m=r.searchParams.get("stepId")||"",M=r.searchParams.get("agentId")||"",C=r.searchParams.get("event")||"",Q=await e.headers("novu-signature")||"",oe={};try{s==="POST"&&(oe=await e.body())}catch{}try{a!=="health-check"&&await this.validateHmac(oe,Q);let X=this.getPostActionMap(oe,p,m,a,M,C,e.waitUntil),ie=this.getGetActionMap(p,m);if(s==="POST")return await this.handlePostAction(a,X);if(s==="GET")return await this.handleGetAction(a,ie);if(s==="OPTIONS")return this.createResponse(200,{})}catch(X){return this.handleError(X)}return this.createError(new bs(s))}getPostActionMap(e,r,s,a,p,m,M){return{trigger:this.triggerAction({workflowId:r,...e}),execute:async()=>{let C=await this.client.executeWorkflow({...e,workflowId:r,stepId:s,action:a});return this.createResponse(200,C)},preview:async()=>{let C=await this.client.executeWorkflow({...e,workflowId:r,stepId:s,action:a});return this.createResponse(200,C)},"agent-event":async()=>{let C=this.client.getAgent(p);if(!C)return this.createResponse(404,{error:`Agent '${p}' not registered`});let Q=new Ht(e,this.client.secretKey),oe=this.runAgentHandler(C,m,Q).catch(X=>{X instanceof ct?console.error(`[agent:${p}] ${X.message}`):console.error(`[agent:${p}] Handler error:`,X)});return M&&M(oe),this.createResponse(200,{status:"ack"})}}}triggerAction(e){return async()=>{let r={name:e.workflowId,to:e.to,payload:(e==null?void 0:e.payload)||{},transactionId:e.transactionId,overrides:e.overrides||{},...e.actor&&{actor:e.actor},...e.bridgeUrl&&{bridgeUrl:e.bridgeUrl},...e.controls&&{controls:e.controls},...e.context&&{context:e.context}},s=await this.http.post("/events/trigger",r);return this.createResponse(200,s)}}getGetActionMap(e,r){return{discover:async()=>{let s=await this.client.discover();return this.createResponse(200,s)},"health-check":async()=>{let s=await this.client.healthCheck();return this.createResponse(200,s)},code:async()=>{let s=await this.client.getCode(e,r);return this.createResponse(200,s)}}}async handlePostAction(e,r){if(Object.values(Qt).includes(e)){let s=r[e];return s()}else throw new er(e,Qt)}async handleGetAction(e,r){if(Object.values(Pr).includes(e)){let s=r[e];return s()}else throw new er(e,Pr)}async runAgentHandler(e,r,s){let a=async p=>{p!=null&&await s.reply(p)};switch(r){case"onMessage":await a(await e.handlers.onMessage({message:s.message,ctx:s}));break;case"onAction":e.handlers.onAction&&await a(await e.handlers.onAction({actionId:s.action.actionId,value:s.action.value,ctx:s}));break;case"onReaction":e.handlers.onReaction&&await a(await e.handlers.onReaction({reaction:s.reaction,ctx:s}));break;case"onResolve":e.handlers.onResolve&&await a(await e.handlers.onResolve({ctx:s}));break;default:throw new er(r,Bt)}await s.flush()}handleError(e){if(xt(e))return e.statusCode>=500&&console.error(e),this.createError(e);if(Ss(e))return this.createError(e);{let r=new Zt(e);return console.error(r),this.createError(r)}}async validateHmac(e,r){if(!this.hmacEnabled)return;if(!r)throw new vs;if(!this.client.secretKey)throw new Is;let[s,a]=r.split(",");if(!s||!a)throw new Ms;let[p,m]=s.split("="),[M,C]=a.split("=");if(Number(p)<Date.now()-1500)throw new Ts;if(!(await zs(this.client.secretKey,`${m}.${JSON.stringify(e)}`)===C))throw new Os}};async function _t(t,e,r){if(t.steps.some(s=>s.stepId===e))throw new Cs(e);t.steps.push(r)}async function dr(t,e,r,s){return async(a,p,m={})=>{let M=(m==null?void 0:m.controlSchema)||De;return await _t(t,a,{stepId:a,type:e,controls:{schema:await xe(M),unknownSchema:M},outputs:{schema:await xe(r),unknownSchema:r},results:{schema:await xe(s),unknownSchema:s},resolve:p,code:p.toString(),options:m,providers:[]}),{_ctx:{timestamp:Date.now(),state:{status:"pending",error:!1}}}}}async function ji(t,e,r){let s=Wr[e],a=Object.entries(r).map(async([p,m])=>{let M=s[p];return{type:p,code:m.toString(),resolve:m,outputs:{schema:await xe(M.output),unknownSchema:M.output}}});t.providers.push(...await Promise.all(a))}async function kt(t,e,r,s){return async(a,p,m={})=>{let M=(m==null?void 0:m.controlSchema)||De,C={stepId:a,type:e,controls:{schema:await xe(M),unknownSchema:M},outputs:{schema:await xe(r),unknownSchema:r},results:{schema:await xe(s),unknownSchema:s},resolve:p,code:p.toString(),options:m,providers:[]};return await _t(t,a,C),Object.keys(m.providers||{}).length>0&&await ji(C,e,m.providers||{}),{_ctx:{timestamp:Date.now(),state:{status:"pending",error:!1}}}}}async function rn(t,e){return async(r,s,a={})=>{let p=(a==null?void 0:a.controlSchema)||De,m=(a==null?void 0:a.outputSchema)||De,[M,C]=await Promise.all([xe(p),xe(m)]);return await _t(t,r,{stepId:r,type:e,controls:{schema:M,unknownSchema:p},outputs:{schema:C,unknownSchema:m},results:{schema:C,unknownSchema:m},resolve:s,code:s.toString(),options:a,providers:[]}),{_ctx:{timestamp:Date.now(),state:{status:"pending",error:!1}}}}}var zl={email:"email",sms:"sms",push:"push",inApp:"in_app",chat:"chat"};function Ki(t){if(!t)return{};let e={};return t.all&&(e.all=t.all),Object.entries(t.channels||{}).forEach(([r,s])=>{let a=zl[r];a&&(e.channels||(e.channels={}),e.channels[a]=s)}),e}function Ql(t,e,r){let s=r||{};return{id:t,trigger:async m=>{let M=nr(ir(m.secretKey),sr(m.apiUrl)),C=m.payload||{},Q;if(s.payloadSchema){let Ie=await tr(s.payloadSchema,C);if(Ie.success===!1)throw new ws(t,Ie.errors);Q=Ie.data}else Q=m.payload;let oe=await Xs(),X={name:t,to:m.to,payload:{...Q},...m.transactionId&&{transactionId:m.transactionId},...m.overrides&&{overrides:m.overrides},...m.actor&&{actor:m.actor},...m.context&&{context:m.context},...oe&&{bridgeUrl:oe}},ie=await M.post("/events/trigger",X);return{cancel:async()=>M.delete(`/events/trigger/${ie.transactionId}`),data:ie}},discover:async()=>{var M;let m={workflowId:t,severity:(M=s.severity)!=null?M:"none",steps:[],code:e.toString(),payload:{schema:await xe(s.payloadSchema||De),unknownSchema:s.payloadSchema||De},controls:{schema:await xe(s.controlSchema||De),unknownSchema:s.controlSchema||De},env:{schema:await xe(s.envSchema||De),unknownSchema:s.envSchema||De},tags:s.tags||[],preferences:Ki(s.preferences),name:s.name,description:s.description,execute:e};return await e({payload:{},subscriber:{},env:{},controls:{},context:{},step:{push:await kt(m,"push",Ve.push.output,Ve.push.result),chat:await kt(m,"chat",Ve.chat.output,Ve.chat.result),email:await kt(m,"email",Ve.email.output,Ve.email.result),sms:await kt(m,"sms",Ve.sms.output,Ve.sms.result),inApp:await kt(m,"in_app",Ve.in_app.output,Ve.in_app.result),digest:await dr(m,"digest",Hr.output,Hr.result),delay:await dr(m,"delay",Ur.output,Ur.result),throttle:await dr(m,"throttle",Br.output,Br.result),custom:await rn(m,"custom"),httpRequest:await rn(m,"http_request")}}),m}}}export{mc as a,Ft as b,Ii as c,Ri as d,Ci as e,xi as f,Ni as g,Pi as h,Li as i,$i as j,Fi as k,ct as l,Bi as m,Bt as n,tn as o,Ql as p};
130
+ `),M}function Nl(t){return"adapterName"in t&&!("adapter"in t)}var _i="thread-state:";function Pl(t){return t!==null&&typeof t=="object"&&Symbol.asyncIterator in t}var Gu=class Qr{constructor(e){re(this,"id");re(this,"channelId");re(this,"isDM");re(this,"channelVisibility");re(this,"_adapter");re(this,"_adapterName");re(this,"_stateAdapterInstance");re(this,"_recentMessages",[]);re(this,"_isSubscribedContext");re(this,"_currentMessage");re(this,"_streamingUpdateIntervalMs");re(this,"_fallbackStreamingPlaceholderText");re(this,"_channel");re(this,"_messageHistory");re(this,"_logger");var r,s,a,p;this.id=e.id,this.channelId=e.channelId,this.isDM=(r=e.isDM)!=null?r:!1,this.channelVisibility=(s=e.channelVisibility)!=null?s:"unknown",this._isSubscribedContext=(a=e.isSubscribedContext)!=null?a:!1,this._currentMessage=e.currentMessage,this._logger=e.logger,this._streamingUpdateIntervalMs=(p=e.streamingUpdateIntervalMs)!=null?p:500,this._fallbackStreamingPlaceholderText=e.fallbackStreamingPlaceholderText!==void 0?e.fallbackStreamingPlaceholderText:"...",Nl(e)?this._adapterName=e.adapterName:(this._adapter=e.adapter,this._stateAdapterInstance=e.stateAdapter,this._messageHistory=e.messageHistory),e.initialMessage&&(this._recentMessages=[e.initialMessage])}get adapter(){if(this._adapter)return this._adapter;if(!this._adapterName)throw new Error("Thread has no adapter configured");let r=lr().getAdapter(this._adapterName);if(!r)throw new Error(`Adapter "${this._adapterName}" not found in Chat singleton`);return this._adapter=r,r}get _stateAdapter(){if(this._stateAdapterInstance)return this._stateAdapterInstance;let e=lr();return this._stateAdapterInstance=e.getState(),this._stateAdapterInstance}get recentMessages(){return this._recentMessages}set recentMessages(e){this._recentMessages=e}get state(){return this._stateAdapter.get(`${_i}${this.id}`)}async setState(e,r){let s=`${_i}${this.id}`;if(r!=null&&r.replace)await this._stateAdapter.set(s,e,cr);else{let p={...await this._stateAdapter.get(s),...e};await this._stateAdapter.set(s,p,cr)}}get channel(){if(!this._channel){let e=Ml(this.adapter,this.id);this._channel=new vl({id:e,adapter:this.adapter,stateAdapter:this._stateAdapter,isDM:this.isDM,channelVisibility:this.channelVisibility,messageHistory:this._messageHistory})}return this._channel}get messages(){let e=this.adapter,r=this.id,s=this._messageHistory;return{async*[Symbol.asyncIterator](){let a,p=!1;for(;;){let m=await e.fetchMessages(r,{cursor:a,direction:"backward"}),M=[...m.messages].reverse();for(let C of M)p=!0,yield C;if(!m.nextCursor||m.messages.length===0)break;a=m.nextCursor}if(!p&&s){let m=await s.getMessages(r);for(let M=m.length-1;M>=0;M--)yield m[M]}}}}get allMessages(){let e=this.adapter,r=this.id,s=this._messageHistory;return{async*[Symbol.asyncIterator](){let a,p=!1;for(;;){let m=await e.fetchMessages(r,{limit:100,cursor:a,direction:"forward"});for(let M of m.messages)p=!0,yield M;if(!m.nextCursor||m.messages.length===0)break;a=m.nextCursor}if(!p&&s){let m=await s.getMessages(r);for(let M of m)yield M}}}}async isSubscribed(){return this._isSubscribedContext?!0:this._stateAdapter.isSubscribed(this.id)}async subscribe(){await this._stateAdapter.subscribe(this.id),this.adapter.onThreadSubscribe&&await this.adapter.onThreadSubscribe(this.id)}async unsubscribe(){await this._stateAdapter.unsubscribe(this.id)}async post(e){if(vi(e))return await this.handlePostableObject(e),e;if(Pl(e))return this.handleStream(e);let r=e;if(Ke(e)){let p=je(e);if(!p)throw new Error("Invalid JSX element: must be a Card element");r=p}let s=await this.adapter.postMessage(this.id,r),a=this.createSentMessage(s.id,r,s.threadId);return this._messageHistory&&await this._messageHistory.append(this.id,new ht(a)),a}async handlePostableObject(e){await Mi(e,this.adapter,this.id,(r,s)=>this.adapter.postMessage(r,s),this._logger)}async postEphemeral(e,r,s){let{fallbackToDM:a}=s,p=typeof e=="string"?e:e.userId,m;if(Ke(r)){let M=je(r);if(!M)throw new Error("Invalid JSX element: must be a Card element");m=M}else m=r;if(this.adapter.postEphemeral)return this.adapter.postEphemeral(this.id,p,m);if(!a)return null;if(this.adapter.openDM){let M=await this.adapter.openDM(p),C=await this.adapter.postMessage(M,m);return{id:C.id,threadId:M,usedFallback:!0,raw:C.raw}}return null}async schedule(e,r){let s;if(Ke(e)){let a=je(e);if(!a)throw new Error("Invalid JSX element: must be a Card element");s=a}else s=e;if(!this.adapter.scheduleMessage)throw new Ti("Scheduled messages are not supported by this adapter","scheduling");return this.adapter.scheduleMessage(this.id,s,r)}async handleStream(e){var p;let r=Oi(e),s={};if(this._currentMessage){s.recipientUserId=this._currentMessage.author.userId;let m=this._currentMessage.raw;s.recipientTeamId=(p=m==null?void 0:m.team_id)!=null?p:m==null?void 0:m.team}if(this.adapter.stream){let m="",M={[Symbol.asyncIterator]:()=>{let oe=r[Symbol.asyncIterator]();return{async next(){let X=await oe.next();if(!X.done){let ie=X.value;typeof ie=="string"?m+=ie:ie.type==="markdown_text"&&(m+=ie.text)}return X}}}},C=await this.adapter.stream(this.id,M,s),Q=this.createSentMessage(C.id,{markdown:m},C.threadId);return this._messageHistory&&await this._messageHistory.append(this.id,new ht(Q)),Q}let a={[Symbol.asyncIterator]:()=>{let m=r[Symbol.asyncIterator]();return{async next(){for(;;){let M=await m.next();if(M.done)return{value:void 0,done:!0};let C=M.value;if(typeof C=="string")return{value:C,done:!1};if(C.type==="markdown_text")return{value:C.text,done:!1}}}}}};return this.fallbackStream(a,s)}async startTyping(e){await this.adapter.startTyping(this.id,e)}async fallbackStream(e,r){var ut;let s=(ut=r==null?void 0:r.updateIntervalMs)!=null?ut:this._streamingUpdateIntervalMs,a=this._fallbackStreamingPlaceholderText,p=a===null?null:await this.adapter.postMessage(this.id,a),m=this.id,M=new Il,C="",Q=!1,oe=null,X=null;p&&(m=p.threadId||this.id,C=a!=null?a:"");let ie=()=>{X=setTimeout(()=>{oe=Ae()},s)},Ae=async()=>{var it;if(Q||!p)return;let Xe=M.render();if(Xe!==C)try{await this.adapter.editMessage(m,p.id,{markdown:Xe}),C=Xe}catch(pt){(it=this._logger)==null||it.warn("fallbackStream edit failed",pt)}Q||ie()};p&&ie();try{for await(let Xe of e)if(M.push(Xe),!p){let it=M.render();p=await this.adapter.postMessage(this.id,{markdown:it}),m=p.threadId||this.id,C=it,ie()}}finally{Q=!0,X&&(clearTimeout(X),X=null)}oe&&await oe;let Ie=M.getText(),Je=M.finish();p||(p=await this.adapter.postMessage(this.id,{markdown:Ie}),m=p.threadId||this.id,C=Ie),Je!==C&&await this.adapter.editMessage(m,p.id,{markdown:Ie});let We=this.createSentMessage(p.id,{markdown:Ie},m);return this._messageHistory&&await this._messageHistory.append(this.id,new ht(We)),We}async refresh(){let e=await this.adapter.fetchMessages(this.id,{limit:50});e.messages.length>0?this._recentMessages=e.messages:this._messageHistory?this._recentMessages=await this._messageHistory.getMessages(this.id,50):this._recentMessages=[]}mentionUser(e){return`<@${e}>`}toJSON(){var e;return{_type:"chat:Thread",id:this.id,channelId:this.channelId,channelVisibility:this.channelVisibility,currentMessage:(e=this._currentMessage)==null?void 0:e.toJSON(),isDM:this.isDM,adapterName:this.adapter.name}}static fromJSON(e,r){let s=new Qr({id:e.id,adapterName:e.adapterName,channelId:e.channelId,channelVisibility:e.channelVisibility,currentMessage:e.currentMessage?ht.fromJSON(e.currentMessage):void 0,isDM:e.isDM});return r&&(s._adapter=r),s}static[bt](e){return e.toJSON()}static[At](e){return Qr.fromJSON(e)}createSentMessage(e,r,s){let a=this.adapter,p=s||this.id,m=this,{plainText:M,formatted:C,attachments:Q}=Ll(r);return{id:e,threadId:p,text:M,formatted:C,raw:null,links:[],author:{userId:"self",userName:a.userName,fullName:a.userName,isBot:!0,isMe:!0},metadata:{dateSent:new Date,edited:!1},attachments:Q,toJSON(){return new ht(this).toJSON()},async edit(X){let ie=X;if(Ke(X)){let Ae=je(X);if(!Ae)throw new Error("Invalid JSX element: must be a Card element");ie=Ae}return await a.editMessage(p,e,ie),m.createSentMessage(e,ie)},async delete(){await a.deleteMessage(p,e)},async addReaction(X){await a.addReaction(p,e,X)},async removeReaction(X){await a.removeReaction(p,e,X)}}}createSentMessageFromMessage(e){let r=this.adapter,s=this.id,a=e.id,p=this;return{id:e.id,threadId:e.threadId,text:e.text,formatted:e.formatted,raw:e.raw,author:e.author,metadata:e.metadata,attachments:e.attachments,links:e.links,isMention:e.isMention,toJSON(){return e.toJSON()},async edit(m){let M=m;if(Ke(m)){let C=je(m);if(!C)throw new Error("Invalid JSX element: must be a Card element");M=C}return await r.editMessage(s,a,M),p.createSentMessage(a,M,s)},async delete(){await r.deleteMessage(s,a)},async addReaction(m){await r.addReaction(s,a,m)},async removeReaction(m){await r.removeReaction(s,a,m)}}}};function Ll(t){if(typeof t=="string")return{plainText:t,formatted:nt([rt([tt(t)])]),attachments:[]};if("raw"in t)return{plainText:t.raw,formatted:nt([rt([tt(t.raw)])]),attachments:t.attachments||[]};if("markdown"in t){let e=Dr(t.markdown);return{plainText:Nt(e),formatted:e,attachments:t.attachments||[]}}if("ast"in t)return{plainText:Nt(t.ast),formatted:t.ast,attachments:t.attachments||[]};if("card"in t){let e=t.fallbackText||Pt(t.card);return{plainText:e,formatted:nt([rt([tt(e)])]),attachments:[]}}if("type"in t&&t.type==="card"){let e=Pt(t);return{plainText:e,formatted:nt([rt([tt(e)])]),attachments:[]}}throw new Error("Invalid PostableMessage format")}var zu=300*1e3,Xu=1440*60*1e3;var ki=new Map;function Et(t){let e=ki.get(t);return e||(e=Object.freeze({name:t,toString:()=>`{{emoji:${t}}}`,toJSON:()=>`{{emoji:${t}}}`}),ki.set(t,e)),e}var $l={thumbs_up:{slack:["+1","thumbsup"],gchat:"\u{1F44D}"},thumbs_down:{slack:["-1","thumbsdown"],gchat:"\u{1F44E}"},clap:{slack:"clap",gchat:"\u{1F44F}"},wave:{slack:"wave",gchat:"\u{1F44B}"},pray:{slack:"pray",gchat:"\u{1F64F}"},muscle:{slack:"muscle",gchat:"\u{1F4AA}"},ok_hand:{slack:"ok_hand",gchat:"\u{1F44C}"},point_up:{slack:"point_up",gchat:"\u{1F446}"},point_down:{slack:"point_down",gchat:"\u{1F447}"},point_left:{slack:"point_left",gchat:"\u{1F448}"},point_right:{slack:"point_right",gchat:"\u{1F449}"},raised_hands:{slack:"raised_hands",gchat:"\u{1F64C}"},shrug:{slack:"shrug",gchat:"\u{1F937}"},facepalm:{slack:"facepalm",gchat:"\u{1F926}"},heart:{slack:"heart",gchat:["\u2764\uFE0F","\u2764"]},smile:{slack:["smile","slightly_smiling_face"],gchat:"\u{1F60A}"},laugh:{slack:["laughing","satisfied","joy"],gchat:["\u{1F602}","\u{1F606}"]},thinking:{slack:"thinking_face",gchat:"\u{1F914}"},sad:{slack:["cry","sad","white_frowning_face"],gchat:"\u{1F622}"},cry:{slack:"sob",gchat:"\u{1F62D}"},angry:{slack:"angry",gchat:"\u{1F620}"},love_eyes:{slack:"heart_eyes",gchat:"\u{1F60D}"},cool:{slack:"sunglasses",gchat:"\u{1F60E}"},wink:{slack:"wink",gchat:"\u{1F609}"},surprised:{slack:"open_mouth",gchat:"\u{1F62E}"},worried:{slack:"worried",gchat:"\u{1F61F}"},confused:{slack:"confused",gchat:"\u{1F615}"},neutral:{slack:"neutral_face",gchat:"\u{1F610}"},sleeping:{slack:"sleeping",gchat:"\u{1F634}"},sick:{slack:"nauseated_face",gchat:"\u{1F922}"},mind_blown:{slack:"exploding_head",gchat:"\u{1F92F}"},relieved:{slack:"relieved",gchat:"\u{1F60C}"},grimace:{slack:"grimacing",gchat:"\u{1F62C}"},rolling_eyes:{slack:"rolling_eyes",gchat:"\u{1F644}"},hug:{slack:"hugging_face",gchat:"\u{1F917}"},zany:{slack:"zany_face",gchat:"\u{1F92A}"},check:{slack:["white_check_mark","heavy_check_mark"],gchat:["\u2705","\u2714\uFE0F"]},x:{slack:["x","heavy_multiplication_x"],gchat:["\u274C","\u2716\uFE0F"]},question:{slack:"question",gchat:["\u2753","?"]},exclamation:{slack:"exclamation",gchat:"\u2757"},warning:{slack:"warning",gchat:"\u26A0\uFE0F"},stop:{slack:"octagonal_sign",gchat:"\u{1F6D1}"},info:{slack:"information_source",gchat:"\u2139\uFE0F"},100:{slack:"100",gchat:"\u{1F4AF}"},fire:{slack:"fire",gchat:"\u{1F525}"},star:{slack:"star",gchat:"\u2B50"},sparkles:{slack:"sparkles",gchat:"\u2728"},lightning:{slack:"zap",gchat:"\u26A1"},boom:{slack:"boom",gchat:"\u{1F4A5}"},eyes:{slack:"eyes",gchat:"\u{1F440}"},green_circle:{slack:"large_green_circle",gchat:"\u{1F7E2}"},yellow_circle:{slack:"large_yellow_circle",gchat:"\u{1F7E1}"},red_circle:{slack:"red_circle",gchat:"\u{1F534}"},blue_circle:{slack:"large_blue_circle",gchat:"\u{1F535}"},white_circle:{slack:"white_circle",gchat:"\u26AA"},black_circle:{slack:"black_circle",gchat:"\u26AB"},rocket:{slack:"rocket",gchat:"\u{1F680}"},party:{slack:["tada","partying_face"],gchat:["\u{1F389}","\u{1F973}"]},confetti:{slack:"confetti_ball",gchat:"\u{1F38A}"},balloon:{slack:"balloon",gchat:"\u{1F388}"},gift:{slack:"gift",gchat:"\u{1F381}"},trophy:{slack:"trophy",gchat:"\u{1F3C6}"},medal:{slack:"first_place_medal",gchat:"\u{1F947}"},lightbulb:{slack:"bulb",gchat:"\u{1F4A1}"},gear:{slack:"gear",gchat:"\u2699\uFE0F"},wrench:{slack:"wrench",gchat:"\u{1F527}"},hammer:{slack:"hammer",gchat:"\u{1F528}"},bug:{slack:"bug",gchat:"\u{1F41B}"},link:{slack:"link",gchat:"\u{1F517}"},lock:{slack:"lock",gchat:"\u{1F512}"},unlock:{slack:"unlock",gchat:"\u{1F513}"},key:{slack:"key",gchat:"\u{1F511}"},pin:{slack:"pushpin",gchat:"\u{1F4CC}"},memo:{slack:"memo",gchat:"\u{1F4DD}"},clipboard:{slack:"clipboard",gchat:"\u{1F4CB}"},calendar:{slack:"calendar",gchat:"\u{1F4C5}"},clock:{slack:"clock1",gchat:"\u{1F550}"},hourglass:{slack:"hourglass",gchat:"\u23F3"},bell:{slack:"bell",gchat:"\u{1F514}"},megaphone:{slack:"mega",gchat:"\u{1F4E2}"},speech_bubble:{slack:"speech_balloon",gchat:"\u{1F4AC}"},email:{slack:"email",gchat:"\u{1F4E7}"},inbox:{slack:"inbox_tray",gchat:"\u{1F4E5}"},outbox:{slack:"outbox_tray",gchat:"\u{1F4E4}"},package:{slack:"package",gchat:"\u{1F4E6}"},folder:{slack:"file_folder",gchat:"\u{1F4C1}"},file:{slack:"page_facing_up",gchat:"\u{1F4C4}"},chart_up:{slack:"chart_with_upwards_trend",gchat:"\u{1F4C8}"},chart_down:{slack:"chart_with_downwards_trend",gchat:"\u{1F4C9}"},coffee:{slack:"coffee",gchat:"\u2615"},pizza:{slack:"pizza",gchat:"\u{1F355}"},beer:{slack:"beer",gchat:"\u{1F37A}"},arrow_up:{slack:"arrow_up",gchat:"\u2B06\uFE0F"},arrow_down:{slack:"arrow_down",gchat:"\u2B07\uFE0F"},arrow_left:{slack:"arrow_left",gchat:"\u2B05\uFE0F"},arrow_right:{slack:"arrow_right",gchat:"\u27A1\uFE0F"},refresh:{slack:"arrows_counterclockwise",gchat:"\u{1F504}"},sun:{slack:"sunny",gchat:"\u2600\uFE0F"},cloud:{slack:"cloud",gchat:"\u2601\uFE0F"},rain:{slack:"rain_cloud",gchat:"\u{1F327}\uFE0F"},snow:{slack:"snowflake",gchat:"\u2744\uFE0F"},rainbow:{slack:"rainbow",gchat:"\u{1F308}"}},Fl=class{constructor(t){re(this,"emojiMap");re(this,"slackToNormalized");re(this,"gchatToNormalized");this.emojiMap={...$l,...t},this.slackToNormalized=new Map,this.gchatToNormalized=new Map,this.buildReverseMaps()}buildReverseMaps(){for(let[t,e]of Object.entries(this.emojiMap)){let r=Array.isArray(e.slack)?e.slack:[e.slack];for(let a of r)this.slackToNormalized.set(a.toLowerCase(),t);let s=Array.isArray(e.gchat)?e.gchat:[e.gchat];for(let a of s)this.gchatToNormalized.set(a,t)}}fromSlack(t){var s;let e=t.replace(/^:|:$/g,"").toLowerCase(),r=(s=this.slackToNormalized.get(e))!=null?s:t;return Et(r)}fromGChat(t){var r;let e=(r=this.gchatToNormalized.get(t))!=null?r:t;return Et(e)}fromTeams(t){var s;let r=(s={like:"thumbs_up",heart:"heart",laugh:"laugh",surprised:"surprised",sad:"sad",angry:"angry"}[t])!=null?s:t;return Et(r)}toSlack(t){let e=typeof t=="string"?t:t.name,r=this.emojiMap[e];return r?Array.isArray(r.slack)?r.slack[0]:r.slack:e}toGChat(t){let e=typeof t=="string"?t:t.name,r=this.emojiMap[e];return r?Array.isArray(r.gchat)?r.gchat[0]:r.gchat:e}toDiscord(t){return this.toGChat(t)}matches(t,e){let r=typeof e=="string"?e:e.name,s=this.emojiMap[r];if(!s)return t===r;let a=Array.isArray(s.slack)?s.slack:[s.slack],p=Array.isArray(s.gchat)?s.gchat:[s.gchat],m=t.replace(/^:|:$/g,"").toLowerCase();return a.some(M=>M.toLowerCase()===m)||p.includes(t)}extend(t){Object.assign(this.emojiMap,t),this.buildReverseMaps()}},Dl=new Fl;function Wl(t){let e=["thumbs_up","thumbs_down","clap","wave","pray","muscle","ok_hand","point_up","point_down","point_left","point_right","raised_hands","shrug","facepalm","heart","smile","laugh","thinking","sad","cry","angry","love_eyes","cool","wink","surprised","worried","confused","neutral","sleeping","sick","mind_blown","relieved","grimace","rolling_eyes","hug","zany","check","x","question","exclamation","warning","stop","info","100","fire","star","sparkles","lightning","boom","eyes","green_circle","yellow_circle","red_circle","blue_circle","white_circle","black_circle","rocket","party","confetti","balloon","gift","trophy","medal","lightbulb","gear","wrench","hammer","bug","link","lock","unlock","key","pin","memo","clipboard","calendar","clock","hourglass","bell","megaphone","speech_bubble","email","inbox","outbox","package","folder","file","chart_up","chart_down","coffee","pizza","beer","arrow_up","arrow_down","arrow_left","arrow_right","refresh","sun","cloud","rain","snow","rainbow"],r={custom:s=>Et(s)};for(let s of e)r[s]=Et(s);if(t){for(let s of Object.keys(t))r[s]=Et(s);Dl.extend(t)}return r}var Qu=Wl(),Ii=Fs,Ri=Ds,Ci=Ps;var xi=Ws,Ni=Ls,Pi=$s;var Li=Hs,$i=Bs,Fi=Us;var Ul={400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",408:"Request Timeout",409:"Conflict",422:"Unprocessable Entity",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"};function ur(t){return typeof t=="string"&&t.trim()?t:!t||typeof t!="object"?null:ur(t.message)}function Hl(t){if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object")return null;let r=e,s=ur(r.message);if(s)return s;let a=ur(r.error);if(a)return a;let p=r.errors;return Array.isArray(p)?ur(p[0]):null}var ct=class extends Error{constructor(e,r){var m;let s=(m=Ul[e])!=null?m:e,a=Hl(r),p=a?`Delivery failed: ${s}: ${a}`:`Delivery failed: ${s}`;super(p),this.name="AgentDeliveryError",this.statusCode=e,this.responseBody=r}};var Bl=5*1024*1024,jl=5*1024*1024,Di=32768,Kl=/^[A-Za-z0-9+/]*={0,2}$/;function ql(t){return"type"in t&&t.type==="card"}function Ut(t,e){return t.filename?`"${t.filename}"`:`at index ${e}`}function Wi(){return globalThis.Buffer}function Vl(t){var e,r,s;return(s=(r=(e=Wi())==null?void 0:e.isBuffer)==null?void 0:r.call(e,t))!=null?s:!1}function Jl(t){return typeof Blob!="undefined"&&t instanceof Blob}function Zr(t){let e=Wi();if(e)return e.from(t).toString("base64");if(typeof btoa!="function")throw new Error("Unable to encode file data: base64 encoding is not available in this runtime.");let r="";for(let s=0;s<t.length;s+=Di){let a=t.subarray(s,s+Di);r+=String.fromCharCode(...a)}return btoa(r)}function Ui(t){let e=t.replace(/\s/g,""),r=e.length%4;if(!e||r===1||!Kl.test(e))return null;let s=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-s}function Wt(t,e,r){if(t>Bl)throw new Error(`Invalid file ${Ut(e,r)}: inline data must be 5 MB or smaller. Use a publicly-accessible URL for larger files.`)}async function Yl(t,e,r){if(typeof t=="string"){let s=Ui(t);if(s===null)throw new Error(`Invalid file ${Ut(e,r)}: data must be a base64-encoded string.`);return Wt(s,e,r),t}if(Vl(t))return Wt(t.byteLength,e,r),t.toString("base64");if(t instanceof Uint8Array)return Wt(t.byteLength,e,r),Zr(t);if(t instanceof ArrayBuffer)return Wt(t.byteLength,e,r),Zr(new Uint8Array(t));if(Jl(t))return Wt(t.size,e,r),Zr(new Uint8Array(await t.arrayBuffer()));throw new Error(`Invalid file ${Ut(e,r)}: data must be a base64 string, Buffer, Uint8Array, ArrayBuffer, or Blob.`)}async function Gl(t){if(!(t!=null&&t.length))return;let e=[],r=0;for(let[s,a]of t.entries()){let p=a.data,m=a.url,M=p!=null,C=m!=null;if(M===C)throw new Error(`Invalid file ${Ut(a,s)}: provide exactly one of data or url.`);if(M){let Q=await Yl(p,a,s),oe=Ui(Q);if(r+=oe!=null?oe:0,r>jl)throw new Error("Invalid files: total inline data must be 5 MB or smaller. Use publicly-accessible URLs for larger files.");e.push({...a,data:Q});continue}if(C&&typeof m!="string")throw new Error(`Invalid file ${Ut(a,s)}: url must be a string.`);e.push(a)}return e}async function Hi(t,e){let r=await Gl(e);if(typeof t=="string")return r?{markdown:t,files:r}:{markdown:t};if(Ke(t)){let s=je(t);if(s)return{card:s}}if(ql(t))return{card:t};throw new Error("Invalid message content \u2014 expected string or CardElement")}var en=class{constructor(e,r,s,a,p){this.conversationId=s;this.integrationIdentifier=a;this.poster=p;this.messageId=e,this.platformThreadId=r}async edit(e,r){let s=await this.poster.post({conversationId:this.conversationId,integrationIdentifier:this.integrationIdentifier,edit:{messageId:this.messageId,content:await Hi(e,r==null?void 0:r.files)}});if(!s)throw new Error("Agent edit did not return a message handle");return this.messageId=s.messageId,this.platformThreadId=s.platformThreadId,this}},Ht=class{constructor(e,r){this._signals=[];this._pendingReactions=[];this._resolveSignal=null;var a,p;this.event=e.event,this.action=(a=e.action)!=null?a:null,this.message=e.message,this.reaction=e.reaction,this.conversation=e.conversation,this.subscriber=e.subscriber,this.history=e.history,this.platform=e.platform,this.platformContext=e.platformContext,this._replyUrl=e.replyUrl,this._conversationId=e.conversationId,this._integrationIdentifier=e.integrationIdentifier,this._secretKey=r,this._poster={post:m=>this._post(m)},this._metadataState={...(p=e.conversation.metadata)!=null?p:{}};let s=this;this.metadata={get(m){return s._metadataState[m]},set(m,M){s._metadataState[m]=M,s._signals.push({type:"metadata",action:"set",key:m,value:M})},delete(m){delete s._metadataState[m],s._signals.push({type:"metadata",action:"delete",key:m})},clear(){s._metadataState={},s._signals.push({type:"metadata",action:"clear"})},get current(){return{...s._metadataState}}}}async reply(e,r){let s={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,reply:await Hi(e,r==null?void 0:r.files)};this._signals.length&&(s.signals=this._signals,this._signals=[]),this._pendingReactions.length&&(s.addReactions=this._pendingReactions,this._pendingReactions=[]),this._resolveSignal&&(s.resolve=this._resolveSignal,this._resolveSignal=null);let a=await this._post(s);if(!a)throw new Error("Agent reply did not return a message handle");return new en(a.messageId,a.platformThreadId,this._conversationId,this._integrationIdentifier,this._poster)}resolve(e){this._resolveSignal={summary:e}}trigger(e,r){this._signals.push({...r,type:"trigger",workflowId:e})}addReaction(e,r){this._pendingReactions.push({messageId:e,emojiName:r})}async flush(){if(!this._signals.length&&!this._resolveSignal&&!this._pendingReactions.length)return;let e={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier};this._signals.length&&(e.signals=this._signals,this._signals=[]),this._pendingReactions.length&&(e.addReactions=this._pendingReactions,this._pendingReactions=[]),this._resolveSignal&&(e.resolve=this._resolveSignal,this._resolveSignal=null),await this._post(e)}async _post(e){let r=await fetch(this._replyUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${this._secretKey}`},body:JSON.stringify(e)});if(!r.ok){let a=await r.text().catch(()=>"");throw new ct(r.status,a)}let s=await r.text().catch(()=>"");if(!s)return null;try{let a=JSON.parse(s),p=a&&typeof a=="object"&&"data"in a?a.data:a;if(p&&typeof p.messageId=="string"&&typeof p.platformThreadId=="string")return{messageId:p.messageId,platformThreadId:p.platformThreadId}}catch{}return null}};function Bi(t,e){if(!t)throw new Error("agent() requires a non-empty agentId");if(!(e!=null&&e.onMessage))throw new Error(`agent('${t}') requires an onMessage handler`);return{id:t,handlers:e}}var Bt=(a=>(a.ON_MESSAGE="onMessage",a.ON_ACTION="onAction",a.ON_RESOLVE="onResolve",a.ON_REACTION="onReaction",a))(Bt||{});var tn=class{constructor(e){this.handler=e.handler,this.client=e.client?e.client:new Ft,this.workflows=e.workflows||[],this.agents=e.agents||[],this.http=nr(this.client.secretKey,this.client.apiUrl),this.frameworkName=e.frameworkName,this.hmacEnabled=this.client.strictAuthentication,this.client.addAgents(this.agents)}createHandler(){return async(...e)=>{await this.client.addWorkflows(this.workflows);let r=await this.handler(...e),s=await this.handleAction({actions:r});return r.transformResponse(s)}}getStaticHeaders(){let e=`novu-framework:v${this.client.version}`;return{"content-type":"application/json","access-control-allow-origin":"*","access-control-allow-private-network":"true","access-control-allow-methods":"GET, POST","access-control-allow-headers":"*","access-control-max-age":"604800","novu-framework-version":"2024-06-26","novu-framework-sdk":"2.10.1-alpha.7","novu-framework-server":this.frameworkName,"user-agent":e}}createResponse(e,r){return{status:e,body:JSON.stringify(r),headers:{...this.getStaticHeaders()}}}createError(e){return{status:e.statusCode,body:JSON.stringify({message:e.message,data:e.data,code:e.code}),headers:this.getStaticHeaders()}}async handleAction({actions:e}){let r=await e.url(),s=await e.method(),a=r.searchParams.get("action")||"health-check",p=r.searchParams.get("workflowId")||"",m=r.searchParams.get("stepId")||"",M=r.searchParams.get("agentId")||"",C=r.searchParams.get("event")||"",Q=await e.headers("novu-signature")||"",oe={};try{s==="POST"&&(oe=await e.body())}catch{}try{a!=="health-check"&&await this.validateHmac(oe,Q);let X=this.getPostActionMap(oe,p,m,a,M,C,e.waitUntil),ie=this.getGetActionMap(p,m);if(s==="POST")return await this.handlePostAction(a,X);if(s==="GET")return await this.handleGetAction(a,ie);if(s==="OPTIONS")return this.createResponse(200,{})}catch(X){return this.handleError(X)}return this.createError(new bs(s))}getPostActionMap(e,r,s,a,p,m,M){return{trigger:this.triggerAction({workflowId:r,...e}),execute:async()=>{let C=await this.client.executeWorkflow({...e,workflowId:r,stepId:s,action:a});return this.createResponse(200,C)},preview:async()=>{let C=await this.client.executeWorkflow({...e,workflowId:r,stepId:s,action:a});return this.createResponse(200,C)},"agent-event":async()=>{let C=this.client.getAgent(p);if(!C)return this.createResponse(404,{error:`Agent '${p}' not registered`});let Q=new Ht(e,this.client.secretKey),oe=this.runAgentHandler(C,m,Q).catch(X=>{X instanceof ct?console.error(`[agent:${p}] ${X.message}`):console.error(`[agent:${p}] Handler error:`,X)});return M&&M(oe),this.createResponse(200,{status:"ack"})}}}triggerAction(e){return async()=>{let r={name:e.workflowId,to:e.to,payload:(e==null?void 0:e.payload)||{},transactionId:e.transactionId,overrides:e.overrides||{},...e.actor&&{actor:e.actor},...e.bridgeUrl&&{bridgeUrl:e.bridgeUrl},...e.controls&&{controls:e.controls},...e.context&&{context:e.context}},s=await this.http.post("/events/trigger",r);return this.createResponse(200,s)}}getGetActionMap(e,r){return{discover:async()=>{let s=await this.client.discover();return this.createResponse(200,s)},"health-check":async()=>{let s=await this.client.healthCheck();return this.createResponse(200,s)},code:async()=>{let s=await this.client.getCode(e,r);return this.createResponse(200,s)}}}async handlePostAction(e,r){if(Object.values(Qt).includes(e)){let s=r[e];return s()}else throw new er(e,Qt)}async handleGetAction(e,r){if(Object.values(Pr).includes(e)){let s=r[e];return s()}else throw new er(e,Pr)}async runAgentHandler(e,r,s){let a=async p=>{p!=null&&await s.reply(p)};switch(r){case"onMessage":await a(await e.handlers.onMessage(s.message,s));break;case"onAction":e.handlers.onAction&&await a(await e.handlers.onAction(s.action,s));break;case"onReaction":e.handlers.onReaction&&await a(await e.handlers.onReaction(s.reaction,s));break;case"onResolve":e.handlers.onResolve&&await a(await e.handlers.onResolve(s));break;default:throw new er(r,Bt)}await s.flush()}handleError(e){if(xt(e))return e.statusCode>=500&&console.error(e),this.createError(e);if(Ss(e))return this.createError(e);{let r=new Zt(e);return console.error(r),this.createError(r)}}async validateHmac(e,r){if(!this.hmacEnabled)return;if(!r)throw new vs;if(!this.client.secretKey)throw new Is;let[s,a]=r.split(",");if(!s||!a)throw new Ms;let[p,m]=s.split("="),[M,C]=a.split("=");if(Number(p)<Date.now()-1500)throw new Ts;if(!(await zs(this.client.secretKey,`${m}.${JSON.stringify(e)}`)===C))throw new Os}};async function _t(t,e,r){if(t.steps.some(s=>s.stepId===e))throw new Cs(e);t.steps.push(r)}async function dr(t,e,r,s){return async(a,p,m={})=>{let M=(m==null?void 0:m.controlSchema)||De;return await _t(t,a,{stepId:a,type:e,controls:{schema:await xe(M),unknownSchema:M},outputs:{schema:await xe(r),unknownSchema:r},results:{schema:await xe(s),unknownSchema:s},resolve:p,code:p.toString(),options:m,providers:[]}),{_ctx:{timestamp:Date.now(),state:{status:"pending",error:!1}}}}}async function ji(t,e,r){let s=Wr[e],a=Object.entries(r).map(async([p,m])=>{let M=s[p];return{type:p,code:m.toString(),resolve:m,outputs:{schema:await xe(M.output),unknownSchema:M.output}}});t.providers.push(...await Promise.all(a))}async function kt(t,e,r,s){return async(a,p,m={})=>{let M=(m==null?void 0:m.controlSchema)||De,C={stepId:a,type:e,controls:{schema:await xe(M),unknownSchema:M},outputs:{schema:await xe(r),unknownSchema:r},results:{schema:await xe(s),unknownSchema:s},resolve:p,code:p.toString(),options:m,providers:[]};return await _t(t,a,C),Object.keys(m.providers||{}).length>0&&await ji(C,e,m.providers||{}),{_ctx:{timestamp:Date.now(),state:{status:"pending",error:!1}}}}}async function rn(t,e){return async(r,s,a={})=>{let p=(a==null?void 0:a.controlSchema)||De,m=(a==null?void 0:a.outputSchema)||De,[M,C]=await Promise.all([xe(p),xe(m)]);return await _t(t,r,{stepId:r,type:e,controls:{schema:M,unknownSchema:p},outputs:{schema:C,unknownSchema:m},results:{schema:C,unknownSchema:m},resolve:s,code:s.toString(),options:a,providers:[]}),{_ctx:{timestamp:Date.now(),state:{status:"pending",error:!1}}}}}var zl={email:"email",sms:"sms",push:"push",inApp:"in_app",chat:"chat"};function Ki(t){if(!t)return{};let e={};return t.all&&(e.all=t.all),Object.entries(t.channels||{}).forEach(([r,s])=>{let a=zl[r];a&&(e.channels||(e.channels={}),e.channels[a]=s)}),e}function Ql(t,e,r){let s=r||{};return{id:t,trigger:async m=>{let M=nr(ir(m.secretKey),sr(m.apiUrl)),C=m.payload||{},Q;if(s.payloadSchema){let Ie=await tr(s.payloadSchema,C);if(Ie.success===!1)throw new ws(t,Ie.errors);Q=Ie.data}else Q=m.payload;let oe=await Xs(),X={name:t,to:m.to,payload:{...Q},...m.transactionId&&{transactionId:m.transactionId},...m.overrides&&{overrides:m.overrides},...m.actor&&{actor:m.actor},...m.context&&{context:m.context},...oe&&{bridgeUrl:oe}},ie=await M.post("/events/trigger",X);return{cancel:async()=>M.delete(`/events/trigger/${ie.transactionId}`),data:ie}},discover:async()=>{var M;let m={workflowId:t,severity:(M=s.severity)!=null?M:"none",steps:[],code:e.toString(),payload:{schema:await xe(s.payloadSchema||De),unknownSchema:s.payloadSchema||De},controls:{schema:await xe(s.controlSchema||De),unknownSchema:s.controlSchema||De},env:{schema:await xe(s.envSchema||De),unknownSchema:s.envSchema||De},tags:s.tags||[],preferences:Ki(s.preferences),name:s.name,description:s.description,execute:e};return await e({payload:{},subscriber:{},env:{},controls:{},context:{},step:{push:await kt(m,"push",Ve.push.output,Ve.push.result),chat:await kt(m,"chat",Ve.chat.output,Ve.chat.result),email:await kt(m,"email",Ve.email.output,Ve.email.result),sms:await kt(m,"sms",Ve.sms.output,Ve.sms.result),inApp:await kt(m,"in_app",Ve.in_app.output,Ve.in_app.result),digest:await dr(m,"digest",Hr.output,Hr.result),delay:await dr(m,"delay",Ur.output,Ur.result),throttle:await dr(m,"throttle",Br.output,Br.result),custom:await rn(m,"custom"),httpRequest:await rn(m,"http_request")}}),m}}}export{mc as a,Ft as b,Ii as c,Ri as d,Ci as e,xi as f,Ni as g,Pi as h,Li as i,$i as j,Fi as k,ct as l,Bi as m,Bt as n,tn as o,Ql as p};
@@ -126,10 +126,15 @@ interface ReplyContent {
126
126
  card?: CardElement;
127
127
  files?: FileRef[];
128
128
  }
129
- /** Data carried by a button click or other interactive action. */
129
+ /**
130
+ * Data carried by a button click or other interactive action.
131
+ *
132
+ * Used both on the bridge wire (`AgentBridgeRequest.action`) and as the
133
+ * handler-facing argument passed to `onAction(action, ctx)`.
134
+ */
130
135
  interface AgentAction {
131
136
  /** The `id` prop of the clicked `<Button>` or action element. */
132
- actionId: string;
137
+ id: string;
133
138
  /** The `value` prop of the clicked element, if set. */
134
139
  value?: string;
135
140
  /** Platform-native message ID of the message containing the clicked button/action. */
@@ -258,8 +263,6 @@ interface AgentContextBase {
258
263
  /** Context passed to the `onMessage` handler. */
259
264
  interface AgentMessageContext extends AgentContextBase {
260
265
  readonly event: 'onMessage';
261
- /** The incoming message that triggered this handler. */
262
- readonly message: AgentMessage;
263
266
  }
264
267
  /** Context passed to the `onAction` handler. */
265
268
  interface AgentActionContext extends AgentContextBase {
@@ -282,42 +285,41 @@ type AgentContext = AgentMessageContext | AgentActionContext | AgentReactionCont
282
285
  interface AgentHandlers {
283
286
  /**
284
287
  * Fires on every text message the user sends.
285
- * `message` is the incoming message. `ctx` provides conversation history, subscriber,
286
- * metadata, and reply/trigger methods.
288
+ *
289
+ * @param message - The incoming message that triggered this handler.
290
+ * @param ctx - Conversation history, subscriber, metadata, and reply/trigger methods.
291
+ *
287
292
  * Return a string or JSX card to reply, or call `ctx.reply()` directly
288
293
  * for more control (e.g. editing a message in place).
289
294
  */
290
- onMessage: (payload: {
291
- message: AgentMessage;
292
- ctx: AgentMessageContext;
293
- }) => Awaitable<MessageContent | void>;
295
+ onMessage: (message: AgentMessage, ctx: AgentMessageContext) => Awaitable<MessageContent | void>;
294
296
  /**
295
297
  * Fires when the user adds or removes an emoji reaction to a message.
296
- * `reaction` carries the emoji and whether it was added or removed.
298
+ *
299
+ * @param reaction - The emoji reaction (carries the emoji and whether it was added or removed).
300
+ * @param ctx - Conversation context (history, subscriber, metadata, reply/trigger methods).
301
+ *
297
302
  * Return a string or card to post a reply, or return nothing to silently acknowledge.
298
303
  */
299
- onReaction?: (payload: {
300
- reaction: AgentReaction;
301
- ctx: AgentReactionContext;
302
- }) => Awaitable<MessageContent | void>;
304
+ onReaction?: (reaction: AgentReaction, ctx: AgentReactionContext) => Awaitable<MessageContent | void>;
303
305
  /**
304
306
  * Fires when the user clicks a `<Button>` or other interactive element.
305
- * `actionId` is the `id` prop of the clicked element; `value` is its `value` prop.
307
+ *
308
+ * @param action - The interactive action that triggered this handler.
309
+ * `action.id` is the `id` prop of the clicked element; `action.value` is its `value` prop.
310
+ * @param ctx - Conversation context (history, subscriber, metadata, reply/trigger methods).
311
+ *
306
312
  * Return a string or card to reply, or return nothing to silently acknowledge the click.
307
313
  */
308
- onAction?: (payload: {
309
- actionId: string;
310
- value?: string;
311
- ctx: AgentActionContext;
312
- }) => Awaitable<MessageContent | void>;
314
+ onAction?: (action: AgentAction, ctx: AgentActionContext) => Awaitable<MessageContent | void>;
313
315
  /**
314
316
  * Fires after `ctx.resolve()` is called and the conversation is marked resolved.
315
317
  * Use for post-resolution side-effects (e.g. triggering a follow-up workflow).
316
- * Access subscriber and conversation via `ctx.subscriber` and `ctx.conversation`.
318
+ *
319
+ * @param ctx - Conversation context. Access subscriber and conversation via
320
+ * `ctx.subscriber` and `ctx.conversation`.
317
321
  */
318
- onResolve?: (payload: {
319
- ctx: AgentResolveContext;
320
- }) => Awaitable<MessageContent | void>;
322
+ onResolve?: (ctx: AgentResolveContext) => Awaitable<MessageContent | void>;
321
323
  }
322
324
  interface Agent {
323
325
  id: string;
@@ -1,4 +1,4 @@
1
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, S as ServeHandlerOptions, w as Signal, T as TriggerSignal, x as agent, y as workflow } from './index-DiFdSsia.js';
1
+ export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, S as ServeHandlerOptions, w as Signal, T as TriggerSignal, x as agent, y as workflow } from './index-CAMe0gXf.js';
2
2
  export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from './health-check.types-C5lg4csi.js';
3
3
  export { Actions, Button, Card, CardChild, CardElement, CardLink, CardText, Divider, Select, SelectOption, TextInput } from 'chat';
4
4
  export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, step } from './step-resolver.js';
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{b,c,d,e,f,g,h,i,j,k,l,m,n,o,p as r}from"./chunk-H2XIPY7V.js";import"./chunk-T2VIX2ZH.js";import{a as s}from"./chunk-2M25EATE.js";import"./chunk-U3IL7QCI.js";import{O as q}from"./chunk-6GCCKYZC.js";import{a as p}from"./chunk-CBLKARLC.js";import{f as a}from"./chunk-EWC7I6UD.js";import"./chunk-52LSX2V5.js";export{c as Actions,l as AgentDeliveryError,n as AgentEventEnum,d as Button,e as Card,f as CardLink,g as CardText,b as Client,a as CronExpression,h as Divider,o as NovuRequestHandler,i as Select,j as SelectOption,q as SeverityLevelEnum,k as TextInput,m as agent,p as providerSchemas,s as step,r as workflow};
1
+ import{b,c,d,e,f,g,h,i,j,k,l,m,n,o,p as r}from"./chunk-E6L6ATIB.js";import"./chunk-T2VIX2ZH.js";import{a as s}from"./chunk-2M25EATE.js";import"./chunk-U3IL7QCI.js";import{O as q}from"./chunk-6GCCKYZC.js";import{a as p}from"./chunk-CBLKARLC.js";import{f as a}from"./chunk-EWC7I6UD.js";import"./chunk-52LSX2V5.js";export{c as Actions,l as AgentDeliveryError,n as AgentEventEnum,d as Button,e as Card,f as CardLink,g as CardText,b as Client,a as CronExpression,h as Divider,o as NovuRequestHandler,i as Select,j as SelectOption,q as SeverityLevelEnum,k as TextInput,m as agent,p as providerSchemas,s as step,r as workflow};
@@ -1,5 +1,5 @@
1
- import { S as ServeHandlerOptions } from '../index-DiFdSsia.js';
2
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-DiFdSsia.js';
1
+ import { S as ServeHandlerOptions } from '../index-CAMe0gXf.js';
2
+ export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-CAMe0gXf.js';
3
3
  export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-C5lg4csi.js';
4
4
  export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-CbMgjzR-.js';
5
5
  import { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.js';
@@ -1 +1 @@
1
- import{b as h,c,d as m,e as f,f as H,g as v,h as w,i as E,j as S,k as x,l as A,m as N,n as R,o as a,p as k}from"../chunk-H2XIPY7V.js";import"../chunk-T2VIX2ZH.js";import{a as O}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as b}from"../chunk-6GCCKYZC.js";import{a as V}from"../chunk-CBLKARLC.js";import{f as y}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";var l="express",F=p=>new a({frameworkName:l,...p,handler:(t,o)=>({body:()=>t.body,headers:e=>{let r=t.headers[e];return Array.isArray(r)?r[0]:r},method:()=>t.method||"GET",url:()=>{let e=t.headers.host||"",r=e!=null&&e.includes("://")?"":`${t.protocol||"https"}://`;return new URL(t.originalUrl||t.url||"",`${r}${e||""}`)},queryString:e=>{let r=t.query[e];return Array.isArray(r)?r[0]:r},transformResponse:({body:e,headers:r,status:s})=>(Object.entries(r).forEach(([n,d])=>{o.setHeader(n,d)}),o.status(s).send(e))})}).createHandler();export{c as Actions,A as AgentDeliveryError,R as AgentEventEnum,m as Button,f as Card,H as CardLink,v as CardText,h as Client,y as CronExpression,w as Divider,a as NovuRequestHandler,E as Select,S as SelectOption,b as SeverityLevelEnum,x as TextInput,N as agent,l as frameworkName,V as providerSchemas,F as serve,O as step,k as workflow};
1
+ import{b as h,c,d as m,e as f,f as H,g as v,h as w,i as E,j as S,k as x,l as A,m as N,n as R,o as a,p as k}from"../chunk-E6L6ATIB.js";import"../chunk-T2VIX2ZH.js";import{a as O}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as b}from"../chunk-6GCCKYZC.js";import{a as V}from"../chunk-CBLKARLC.js";import{f as y}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";var l="express",F=p=>new a({frameworkName:l,...p,handler:(t,o)=>({body:()=>t.body,headers:e=>{let r=t.headers[e];return Array.isArray(r)?r[0]:r},method:()=>t.method||"GET",url:()=>{let e=t.headers.host||"",r=e!=null&&e.includes("://")?"":`${t.protocol||"https"}://`;return new URL(t.originalUrl||t.url||"",`${r}${e||""}`)},queryString:e=>{let r=t.query[e];return Array.isArray(r)?r[0]:r},transformResponse:({body:e,headers:r,status:s})=>(Object.entries(r).forEach(([n,d])=>{o.setHeader(n,d)}),o.status(s).send(e))})}).createHandler();export{c as Actions,A as AgentDeliveryError,R as AgentEventEnum,m as Button,f as Card,H as CardLink,v as CardText,h as Client,y as CronExpression,w as Divider,a as NovuRequestHandler,E as Select,S as SelectOption,b as SeverityLevelEnum,x as TextInput,N as agent,l as frameworkName,V as providerSchemas,F as serve,O as step,k as workflow};
@@ -1,7 +1,7 @@
1
1
  import * as h3 from 'h3';
2
2
  import { H3Event } from 'h3';
3
- import { S as ServeHandlerOptions } from '../index-DiFdSsia.js';
4
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-DiFdSsia.js';
3
+ import { S as ServeHandlerOptions } from '../index-CAMe0gXf.js';
4
+ export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-CAMe0gXf.js';
5
5
  export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-C5lg4csi.js';
6
6
  export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-CbMgjzR-.js';
7
7
  import { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.js';
@@ -1 +1 @@
1
- import{b as y,c as H,d as S,e as i,f,g,h as N,i as w,j as c,k as E,l as k,m as x,n as O,o as t,p as F}from"../chunk-H2XIPY7V.js";import"../chunk-T2VIX2ZH.js";import{a as $}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as q}from"../chunk-6GCCKYZC.js";import{a as b}from"../chunk-CBLKARLC.js";import{f as l}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";import{getHeader as o,getQuery as a,readBody as p,send as n,setHeaders as m}from"h3";var h="h3",D=d=>new t({frameworkName:h,...d,handler:r=>({body:()=>p(r),headers:e=>o(r,e),method:()=>r.method,url:()=>new URL(String(r.path),`${process.env.NODE_ENV==="development"?"http":"https"}://${String(o(r,"host"))}`),queryString:e=>String(a(r)[e]),transformResponse:e=>{let{res:s}=r.node;return s.statusCode=e.status,m(r,e.headers),n(r,e.body)}})}).createHandler();export{H as Actions,k as AgentDeliveryError,O as AgentEventEnum,S as Button,i as Card,f as CardLink,g as CardText,y as Client,l as CronExpression,N as Divider,t as NovuRequestHandler,w as Select,c as SelectOption,q as SeverityLevelEnum,E as TextInput,x as agent,h as frameworkName,b as providerSchemas,D as serve,$ as step,F as workflow};
1
+ import{b as y,c as H,d as S,e as i,f,g,h as N,i as w,j as c,k as E,l as k,m as x,n as O,o as t,p as F}from"../chunk-E6L6ATIB.js";import"../chunk-T2VIX2ZH.js";import{a as $}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as q}from"../chunk-6GCCKYZC.js";import{a as b}from"../chunk-CBLKARLC.js";import{f as l}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";import{getHeader as o,getQuery as a,readBody as p,send as n,setHeaders as m}from"h3";var h="h3",D=d=>new t({frameworkName:h,...d,handler:r=>({body:()=>p(r),headers:e=>o(r,e),method:()=>r.method,url:()=>new URL(String(r.path),`${process.env.NODE_ENV==="development"?"http":"https"}://${String(o(r,"host"))}`),queryString:e=>String(a(r)[e]),transformResponse:e=>{let{res:s}=r.node;return s.statusCode=e.status,m(r,e.headers),n(r,e.body)}})}).createHandler();export{H as Actions,k as AgentDeliveryError,O as AgentEventEnum,S as Button,i as Card,f as CardLink,g as CardText,y as Client,l as CronExpression,N as Divider,t as NovuRequestHandler,w as Select,c as SelectOption,q as SeverityLevelEnum,E as TextInput,x as agent,h as frameworkName,b as providerSchemas,D as serve,$ as step,F as workflow};
@@ -1,7 +1,7 @@
1
1
  import * as aws_lambda from 'aws-lambda';
2
2
  import { APIGatewayProxyEventV2, APIGatewayProxyResult } from 'aws-lambda';
3
- import { S as ServeHandlerOptions } from '../index-DiFdSsia.js';
4
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-DiFdSsia.js';
3
+ import { S as ServeHandlerOptions } from '../index-CAMe0gXf.js';
4
+ export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-CAMe0gXf.js';
5
5
  export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-C5lg4csi.js';
6
6
  import { a as Either } from '../subscriber.types-CbMgjzR-.js';
7
7
  export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-CbMgjzR-.js';
@@ -1 +1 @@
1
- import{b as u,c as P,d as h,e as i,f as w,g as l,h as f,i as x,j as c,k as E,l as I,m as A,n as G,o as n,p as q}from"../chunk-H2XIPY7V.js";import"../chunk-T2VIX2ZH.js";import{a as g}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as b}from"../chunk-6GCCKYZC.js";import{a as S}from"../chunk-CBLKARLC.js";import{f as m}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";var p="lambda",H=y=>new n({frameworkName:p,...y,handler:r=>{let s=(e=>e.version==="2.0")(r);return{url:()=>{let e=s?r.requestContext.http.path:r.path,t=r.headers["x-forwarded-proto"]||"https",a=new URL(e,`${t}://${r.headers.host||r.headers.Host||""}`);for(let o in r.queryStringParameters)o&&a.searchParams.set(o,r.queryStringParameters[o]);return a},body:()=>{let e="{}";return r.body&&(e=r.isBase64Encoded?Buffer.from(r.body,"base64").toString():r.body),JSON.parse(e)},headers:e=>r.headers[e],queryString:e=>{var t;return(t=r.queryStringParameters)==null?void 0:t[e]},transformResponse:({body:e,status:t,headers:a})=>Promise.resolve({body:e,statusCode:t,headers:a}),method:()=>s?r.requestContext.http.method:r.httpMethod}}}).createHandler();export{P as Actions,I as AgentDeliveryError,G as AgentEventEnum,h as Button,i as Card,w as CardLink,l as CardText,u as Client,m as CronExpression,f as Divider,n as NovuRequestHandler,x as Select,c as SelectOption,b as SeverityLevelEnum,E as TextInput,A as agent,p as frameworkName,S as providerSchemas,H as serve,g as step,q as workflow};
1
+ import{b as u,c as P,d as h,e as i,f as w,g as l,h as f,i as x,j as c,k as E,l as I,m as A,n as G,o as n,p as q}from"../chunk-E6L6ATIB.js";import"../chunk-T2VIX2ZH.js";import{a as g}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as b}from"../chunk-6GCCKYZC.js";import{a as S}from"../chunk-CBLKARLC.js";import{f as m}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";var p="lambda",H=y=>new n({frameworkName:p,...y,handler:r=>{let s=(e=>e.version==="2.0")(r);return{url:()=>{let e=s?r.requestContext.http.path:r.path,t=r.headers["x-forwarded-proto"]||"https",a=new URL(e,`${t}://${r.headers.host||r.headers.Host||""}`);for(let o in r.queryStringParameters)o&&a.searchParams.set(o,r.queryStringParameters[o]);return a},body:()=>{let e="{}";return r.body&&(e=r.isBase64Encoded?Buffer.from(r.body,"base64").toString():r.body),JSON.parse(e)},headers:e=>r.headers[e],queryString:e=>{var t;return(t=r.queryStringParameters)==null?void 0:t[e]},transformResponse:({body:e,status:t,headers:a})=>Promise.resolve({body:e,statusCode:t,headers:a}),method:()=>s?r.requestContext.http.method:r.httpMethod}}}).createHandler();export{P as Actions,I as AgentDeliveryError,G as AgentEventEnum,h as Button,i as Card,w as CardLink,l as CardText,u as Client,m as CronExpression,f as Divider,n as NovuRequestHandler,x as Select,c as SelectOption,b as SeverityLevelEnum,E as TextInput,A as agent,p as frameworkName,S as providerSchemas,H as serve,g as step,q as workflow};
@@ -1,5 +1,5 @@
1
- import { I as INovuRequestHandlerOptions, N as NovuRequestHandler, S as ServeHandlerOptions, C as Client, A as Agent } from '../index-DiFdSsia.js';
2
- export { a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-DiFdSsia.js';
1
+ import { I as INovuRequestHandlerOptions, N as NovuRequestHandler, S as ServeHandlerOptions, C as Client, A as Agent } from '../index-CAMe0gXf.js';
2
+ export { a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-CAMe0gXf.js';
3
3
  import { W as Workflow } from '../health-check.types-C5lg4csi.js';
4
4
  export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum } from '../health-check.types-C5lg4csi.js';
5
5
  export { Actions, Button, Card, CardChild, CardElement, CardLink, CardText, Divider, Select, SelectOption, TextInput } from 'chat';
@@ -1 +1 @@
1
- import{b as g,c as G,d as U,e as j,f as C,g as D,h as F,i as k,j as B,k as L,l as $,m as K,n as z,o as y,p as W}from"../chunk-H2XIPY7V.js";import"../chunk-T2VIX2ZH.js";import{a as X}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as Q}from"../chunk-6GCCKYZC.js";import{a as J}from"../chunk-CBLKARLC.js";import{f as V}from"../chunk-EWC7I6UD.js";import{d as a,e as n}from"../chunk-52LSX2V5.js";import{Inject as R,Injectable as E}from"@nestjs/common";import{ConfigurableModuleBuilder as x}from"@nestjs/common";var{ConfigurableModuleClass:d,MODULE_OPTIONS_TOKEN:m,OPTIONS_TYPE:ee,ASYNC_OPTIONS_TYPE:re}=new x().setClassMethodName("register").setFactoryMethodName("createNovuModuleOptions").setExtras(l=>({...l,isGlobal:!0})).build();var P="REGISTER_API_PATH";import{Injectable as I}from"@nestjs/common";var i=class{handler(e,r){return{body:()=>e.body,headers:t=>{let p=e.headers[t.toLowerCase()];return Array.isArray(p)?p[0]:p},method:()=>e.method||"GET",queryString:t=>{let p=e.query[t];return Array.isArray(p)?p[0]:p},url:()=>{let t=e.headers.host||"",p=t!=null&&t.includes("://")?"":`${e.protocol||"https"}://`;return new URL(e.originalUrl||e.url||"",`${p}${t||""}`)},transformResponse:({body:t,headers:p,status:T})=>(Object.entries(p).forEach(([N,S])=>{r.setHeader(N,S)}),r.status(T).send(t))}}};i=a([I()],i);var _="nest",u=class{constructor(e,r){this.options=e;this.novuHandler=r;this.novuRequestHandler=new y({frameworkName:_,...this.options,handler:this.novuHandler.handler})}async handleRequest(e,r){await this.novuRequestHandler.createHandler()(e,r)}};u=a([E(),n(0,R(m)),n(1,R(i))],u);import{Controller as A,Get as H,Inject as q,Options as b,Post as w,Req as f,Res as O}from"@nestjs/common";var s=class{constructor(e){this.novuService=e}async handleGet(e,r){await this.novuService.handleRequest(e,r)}async handlePost(e,r){await this.novuService.handleRequest(e,r)}async handleOptions(e,r){await this.novuService.handleRequest(e,r)}};a([H(),n(0,f()),n(1,O())],s.prototype,"handleGet",1),a([w(),n(0,f()),n(1,O())],s.prototype,"handlePost",1),a([b(),n(0,f()),n(1,O())],s.prototype,"handleOptions",1),s=a([A(),n(0,q(u))],s);import{Module as Y}from"@nestjs/common";import{PATH_METADATA as M}from"@nestjs/common/constants";var h={provide:P,useFactory:l=>{if(!l.apiPath)throw new Error("`apiPath` must be provided to set the controller path");Reflect.defineMetadata(M,l.apiPath,s)},inject:[m]};function v(l,e=[]){return e.reduce((r,o)=>o(r),l)}var c=class extends d{static register(e,r){var t;let o=d.register(e);return o.controllers=[v(s,e.controllerDecorators||[])],(t=o.providers)==null||t.push(h,u,i,...r||[]),o.exports=[u,i],o}static registerAsync(e,r){var t;let o=d.registerAsync(e);return o.controllers=[s],(t=o.providers)==null||t.push(h,u,i,...r||[]),o.exports=[u,i],o}};c=a([Y({})],c);export{G as Actions,$ as AgentDeliveryError,z as AgentEventEnum,U as Button,j as Card,C as CardLink,D as CardText,g as Client,V as CronExpression,F as Divider,m as NOVU_OPTIONS,u as NovuClient,s as NovuController,i as NovuHandler,c as NovuModule,y as NovuRequestHandler,P as REGISTER_API_PATH,k as Select,B as SelectOption,Q as SeverityLevelEnum,L as TextInput,K as agent,_ as frameworkName,J as providerSchemas,h as registerApiPath,X as step,W as workflow};
1
+ import{b as g,c as G,d as U,e as j,f as C,g as D,h as F,i as k,j as B,k as L,l as $,m as K,n as z,o as y,p as W}from"../chunk-E6L6ATIB.js";import"../chunk-T2VIX2ZH.js";import{a as X}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as Q}from"../chunk-6GCCKYZC.js";import{a as J}from"../chunk-CBLKARLC.js";import{f as V}from"../chunk-EWC7I6UD.js";import{d as a,e as n}from"../chunk-52LSX2V5.js";import{Inject as R,Injectable as E}from"@nestjs/common";import{ConfigurableModuleBuilder as x}from"@nestjs/common";var{ConfigurableModuleClass:d,MODULE_OPTIONS_TOKEN:m,OPTIONS_TYPE:ee,ASYNC_OPTIONS_TYPE:re}=new x().setClassMethodName("register").setFactoryMethodName("createNovuModuleOptions").setExtras(l=>({...l,isGlobal:!0})).build();var P="REGISTER_API_PATH";import{Injectable as I}from"@nestjs/common";var i=class{handler(e,r){return{body:()=>e.body,headers:t=>{let p=e.headers[t.toLowerCase()];return Array.isArray(p)?p[0]:p},method:()=>e.method||"GET",queryString:t=>{let p=e.query[t];return Array.isArray(p)?p[0]:p},url:()=>{let t=e.headers.host||"",p=t!=null&&t.includes("://")?"":`${e.protocol||"https"}://`;return new URL(e.originalUrl||e.url||"",`${p}${t||""}`)},transformResponse:({body:t,headers:p,status:T})=>(Object.entries(p).forEach(([N,S])=>{r.setHeader(N,S)}),r.status(T).send(t))}}};i=a([I()],i);var _="nest",u=class{constructor(e,r){this.options=e;this.novuHandler=r;this.novuRequestHandler=new y({frameworkName:_,...this.options,handler:this.novuHandler.handler})}async handleRequest(e,r){await this.novuRequestHandler.createHandler()(e,r)}};u=a([E(),n(0,R(m)),n(1,R(i))],u);import{Controller as A,Get as H,Inject as q,Options as b,Post as w,Req as f,Res as O}from"@nestjs/common";var s=class{constructor(e){this.novuService=e}async handleGet(e,r){await this.novuService.handleRequest(e,r)}async handlePost(e,r){await this.novuService.handleRequest(e,r)}async handleOptions(e,r){await this.novuService.handleRequest(e,r)}};a([H(),n(0,f()),n(1,O())],s.prototype,"handleGet",1),a([w(),n(0,f()),n(1,O())],s.prototype,"handlePost",1),a([b(),n(0,f()),n(1,O())],s.prototype,"handleOptions",1),s=a([A(),n(0,q(u))],s);import{Module as Y}from"@nestjs/common";import{PATH_METADATA as M}from"@nestjs/common/constants";var h={provide:P,useFactory:l=>{if(!l.apiPath)throw new Error("`apiPath` must be provided to set the controller path");Reflect.defineMetadata(M,l.apiPath,s)},inject:[m]};function v(l,e=[]){return e.reduce((r,o)=>o(r),l)}var c=class extends d{static register(e,r){var t;let o=d.register(e);return o.controllers=[v(s,e.controllerDecorators||[])],(t=o.providers)==null||t.push(h,u,i,...r||[]),o.exports=[u,i],o}static registerAsync(e,r){var t;let o=d.registerAsync(e);return o.controllers=[s],(t=o.providers)==null||t.push(h,u,i,...r||[]),o.exports=[u,i],o}};c=a([Y({})],c);export{G as Actions,$ as AgentDeliveryError,z as AgentEventEnum,U as Button,j as Card,C as CardLink,D as CardText,g as Client,V as CronExpression,F as Divider,m as NOVU_OPTIONS,u as NovuClient,s as NovuController,i as NovuHandler,c as NovuModule,y as NovuRequestHandler,P as REGISTER_API_PATH,k as Select,B as SelectOption,Q as SeverityLevelEnum,L as TextInput,K as agent,_ as frameworkName,J as providerSchemas,h as registerApiPath,X as step,W as workflow};
@@ -1,6 +1,6 @@
1
1
  import { NextRequest } from 'next/server';
2
- import { S as ServeHandlerOptions } from '../index-DiFdSsia.js';
3
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-DiFdSsia.js';
2
+ import { S as ServeHandlerOptions } from '../index-CAMe0gXf.js';
3
+ export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-CAMe0gXf.js';
4
4
  export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-C5lg4csi.js';
5
5
  export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-CbMgjzR-.js';
6
6
  import { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.js';
@@ -1 +1 @@
1
- import{a as l,b as x,c as q,d as S,e as T,f as w,g as P,h as A,i as E,j as b,k as v,l as g,m as F,n as j,o as c,p as I}from"../chunk-H2XIPY7V.js";import"../chunk-T2VIX2ZH.js";import{a as U}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as G}from"../chunk-6GCCKYZC.js";import{a as k}from"../chunk-CBLKARLC.js";import{f as O}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";var m="next",N=o=>typeof o=="object"&&o!==null&&typeof o.setHeader=="function"&&typeof o.status=="function"&&typeof o.send=="function",D=o=>{let p=new c({frameworkName:m,...o,handler:(h,R,d)=>{let n=R,i=e=>{let t=typeof n.headers.get=="function"?n.headers.get(e):n.headers[e];return Array.isArray(t)?t[0]:t};return{body:()=>typeof n.json=="function"?n.json():n.body,headers:i,method:()=>h||n.method||"",queryString:(e,t)=>{var a;let r=((a=n.query)==null?void 0:a[e])||t.searchParams.get(e);return Array.isArray(r)?r[0]:r},url:()=>{let e;try{e=new URL(n.url)}catch{}if(e){let s=i("host");if(s){let u=new URL(s.includes("://")?s:`${e.protocol}//${s}`);e.protocol=u.protocol,e.host=u.host,e.port=u.port,e.username=u.username,e.password=u.password}return e}let t="https",r=i("host")||"";try{(process.env.NODE_ENV==="development"||process.env.NODE_ENV==="dev")&&(t="http")}catch{}return new URL(n.url,`${t}://${r}`)},transformResponse:({body:e,headers:t,status:r})=>{if(N(d)){Object.entries(t).forEach(([s,u])=>{d.setHeader(s,u)}),d.status(r).send(e);return}let a=l();return new a(e,{status:r,headers:t})}}}}).createHandler(),f=p.bind(null,void 0);return Object.defineProperties(f,{GET:{value:p.bind(null,"GET")},POST:{value:p.bind(null,"POST")},OPTIONS:{value:p.bind(null,"OPTIONS")}})};export{q as Actions,g as AgentDeliveryError,j as AgentEventEnum,S as Button,T as Card,w as CardLink,P as CardText,x as Client,O as CronExpression,A as Divider,c as NovuRequestHandler,E as Select,b as SelectOption,G as SeverityLevelEnum,v as TextInput,F as agent,m as frameworkName,k as providerSchemas,D as serve,U as step,I as workflow};
1
+ import{a as l,b as x,c as q,d as S,e as T,f as w,g as P,h as A,i as E,j as b,k as v,l as g,m as F,n as j,o as c,p as I}from"../chunk-E6L6ATIB.js";import"../chunk-T2VIX2ZH.js";import{a as U}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as G}from"../chunk-6GCCKYZC.js";import{a as k}from"../chunk-CBLKARLC.js";import{f as O}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";var m="next",N=o=>typeof o=="object"&&o!==null&&typeof o.setHeader=="function"&&typeof o.status=="function"&&typeof o.send=="function",D=o=>{let p=new c({frameworkName:m,...o,handler:(h,R,d)=>{let n=R,i=e=>{let t=typeof n.headers.get=="function"?n.headers.get(e):n.headers[e];return Array.isArray(t)?t[0]:t};return{body:()=>typeof n.json=="function"?n.json():n.body,headers:i,method:()=>h||n.method||"",queryString:(e,t)=>{var a;let r=((a=n.query)==null?void 0:a[e])||t.searchParams.get(e);return Array.isArray(r)?r[0]:r},url:()=>{let e;try{e=new URL(n.url)}catch{}if(e){let s=i("host");if(s){let u=new URL(s.includes("://")?s:`${e.protocol}//${s}`);e.protocol=u.protocol,e.host=u.host,e.port=u.port,e.username=u.username,e.password=u.password}return e}let t="https",r=i("host")||"";try{(process.env.NODE_ENV==="development"||process.env.NODE_ENV==="dev")&&(t="http")}catch{}return new URL(n.url,`${t}://${r}`)},transformResponse:({body:e,headers:t,status:r})=>{if(N(d)){Object.entries(t).forEach(([s,u])=>{d.setHeader(s,u)}),d.status(r).send(e);return}let a=l();return new a(e,{status:r,headers:t})}}}}).createHandler(),f=p.bind(null,void 0);return Object.defineProperties(f,{GET:{value:p.bind(null,"GET")},POST:{value:p.bind(null,"POST")},OPTIONS:{value:p.bind(null,"OPTIONS")}})};export{q as Actions,g as AgentDeliveryError,j as AgentEventEnum,S as Button,T as Card,w as CardLink,P as CardText,x as Client,O as CronExpression,A as Divider,c as NovuRequestHandler,E as Select,b as SelectOption,G as SeverityLevelEnum,v as TextInput,F as agent,m as frameworkName,k as providerSchemas,D as serve,U as step,I as workflow};
@@ -1,7 +1,7 @@
1
1
  import * as h3 from 'h3';
2
2
  import { H3Event } from 'h3';
3
- import { S as ServeHandlerOptions } from '../index-DiFdSsia.js';
4
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-DiFdSsia.js';
3
+ import { S as ServeHandlerOptions } from '../index-CAMe0gXf.js';
4
+ export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-CAMe0gXf.js';
5
5
  export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-C5lg4csi.js';
6
6
  export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-CbMgjzR-.js';
7
7
  import { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.js';
@@ -1 +1 @@
1
- import{b as H,c as S,d as i,e as y,f,g,h as N,i as w,j as c,k as x,l as E,m as k,n as O,o as t,p as F}from"../chunk-H2XIPY7V.js";import"../chunk-T2VIX2ZH.js";import{a as $}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as q}from"../chunk-6GCCKYZC.js";import{a as b}from"../chunk-CBLKARLC.js";import{f as l}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";import{getHeader as o,getQuery as a,readBody as n,send as p,setHeaders as m}from"h3";var u="nuxt",L=d=>new t({frameworkName:u,...d,handler:r=>({queryString:e=>String(a(r)[e]),body:()=>n(r),headers:e=>o(r,e),url:()=>new URL(String(r.path),`${process.env.NODE_ENV==="development"?"http":"https"}://${String(o(r,"host"))}`),method:()=>r.method,transformResponse:e=>{let{res:s}=r.node;return s.statusCode=e.status,m(r,e.headers),p(r,e.body)}})}).createHandler();export{S as Actions,E as AgentDeliveryError,O as AgentEventEnum,i as Button,y as Card,f as CardLink,g as CardText,H as Client,l as CronExpression,N as Divider,t as NovuRequestHandler,w as Select,c as SelectOption,q as SeverityLevelEnum,x as TextInput,k as agent,u as frameworkName,b as providerSchemas,L as serve,$ as step,F as workflow};
1
+ import{b as H,c as S,d as i,e as y,f,g,h as N,i as w,j as c,k as x,l as E,m as k,n as O,o as t,p as F}from"../chunk-E6L6ATIB.js";import"../chunk-T2VIX2ZH.js";import{a as $}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as q}from"../chunk-6GCCKYZC.js";import{a as b}from"../chunk-CBLKARLC.js";import{f as l}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";import{getHeader as o,getQuery as a,readBody as n,send as p,setHeaders as m}from"h3";var u="nuxt",L=d=>new t({frameworkName:u,...d,handler:r=>({queryString:e=>String(a(r)[e]),body:()=>n(r),headers:e=>o(r,e),url:()=>new URL(String(r.path),`${process.env.NODE_ENV==="development"?"http":"https"}://${String(o(r,"host"))}`),method:()=>r.method,transformResponse:e=>{let{res:s}=r.node;return s.statusCode=e.status,m(r,e.headers),p(r,e.body)}})}).createHandler();export{S as Actions,E as AgentDeliveryError,O as AgentEventEnum,i as Button,y as Card,f as CardLink,g as CardText,H as Client,l as CronExpression,N as Divider,t as NovuRequestHandler,w as Select,c as SelectOption,q as SeverityLevelEnum,x as TextInput,k as agent,u as frameworkName,b as providerSchemas,L as serve,$ as step,F as workflow};
@@ -1,5 +1,5 @@
1
- import { S as ServeHandlerOptions } from '../index-DiFdSsia.js';
2
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-DiFdSsia.js';
1
+ import { S as ServeHandlerOptions } from '../index-CAMe0gXf.js';
2
+ export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-CAMe0gXf.js';
3
3
  export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-C5lg4csi.js';
4
4
  export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-CbMgjzR-.js';
5
5
  import { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.js';
@@ -1 +1 @@
1
- import{a as t,b as h,c as l,d as R,e as c,f as i,g as w,h as f,i as x,j as k,k as v,l as H,m as N,n as S,o,p as q}from"../chunk-H2XIPY7V.js";import"../chunk-T2VIX2ZH.js";import{a as F}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as y}from"../chunk-6GCCKYZC.js";import{a as g}from"../chunk-CBLKARLC.js";import{f as u}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";var m="remix",j=s=>new o({frameworkName:m,...s,handler:({request:e})=>({body:()=>e.json(),headers:r=>e.headers.get(r),method:()=>e.method,url:()=>new URL(e.url,`https://${e.headers.get("host")||""}`),transformResponse:({body:r,status:n,headers:p})=>{let a=t();return new a(r,{status:n,headers:p})}})}).createHandler();export{l as Actions,H as AgentDeliveryError,S as AgentEventEnum,R as Button,c as Card,i as CardLink,w as CardText,h as Client,u as CronExpression,f as Divider,o as NovuRequestHandler,x as Select,k as SelectOption,y as SeverityLevelEnum,v as TextInput,N as agent,m as frameworkName,g as providerSchemas,j as serve,F as step,q as workflow};
1
+ import{a as t,b as h,c as l,d as R,e as c,f as i,g as w,h as f,i as x,j as k,k as v,l as H,m as N,n as S,o,p as q}from"../chunk-E6L6ATIB.js";import"../chunk-T2VIX2ZH.js";import{a as F}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as y}from"../chunk-6GCCKYZC.js";import{a as g}from"../chunk-CBLKARLC.js";import{f as u}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";var m="remix",j=s=>new o({frameworkName:m,...s,handler:({request:e})=>({body:()=>e.json(),headers:r=>e.headers.get(r),method:()=>e.method,url:()=>new URL(e.url,`https://${e.headers.get("host")||""}`),transformResponse:({body:r,status:n,headers:p})=>{let a=t();return new a(r,{status:n,headers:p})}})}).createHandler();export{l as Actions,H as AgentDeliveryError,S as AgentEventEnum,R as Button,c as Card,i as CardLink,w as CardText,h as Client,u as CronExpression,f as Divider,o as NovuRequestHandler,x as Select,k as SelectOption,y as SeverityLevelEnum,v as TextInput,N as agent,m as frameworkName,g as providerSchemas,j as serve,F as step,q as workflow};
@@ -1,6 +1,6 @@
1
1
  import { RequestEvent } from '@sveltejs/kit';
2
- import { S as ServeHandlerOptions } from '../index-DiFdSsia.js';
3
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-DiFdSsia.js';
2
+ import { S as ServeHandlerOptions } from '../index-CAMe0gXf.js';
3
+ export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, w as Signal, T as TriggerSignal, x as agent, y as workflow } from '../index-CAMe0gXf.js';
4
4
  export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from '../health-check.types-C5lg4csi.js';
5
5
  export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from '../subscriber.types-CbMgjzR-.js';
6
6
  import { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.js';
@@ -1 +1 @@
1
- import{a as r,b as E,c as P,d as R,e as T,f as S,g as c,h as f,i as h,j as N,k as q,l as F,m as b,n as w,o as s,p as I}from"../chunk-H2XIPY7V.js";import"../chunk-T2VIX2ZH.js";import{a as k}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as G}from"../chunk-6GCCKYZC.js";import{a as y}from"../chunk-CBLKARLC.js";import{f as v}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";var m="sveltekit",x=o=>{let t=new s({frameworkName:m,...o,handler:(u,e)=>({method:()=>u||e.request.method||"",body:()=>e.request.json(),headers:n=>e.request.headers.get(n),url:()=>{let n=process.env.NODE_ENV==="development"||process.env.NODE_ENV==="dev"?"http":"https";return new URL(e.request.url,`${n}://${e.request.headers.get("host")||""}`)},transformResponse:({body:n,headers:d,status:a})=>{let l=r();return new l(n,{status:a,headers:d})}})}).createHandler(),p=t.bind(null,void 0);return Object.defineProperties(p,{GET:{value:t.bind(null,"GET")},POST:{value:t.bind(null,"POST")},OPTIONS:{value:t.bind(null,"OPTIONS")}})};export{P as Actions,F as AgentDeliveryError,w as AgentEventEnum,R as Button,T as Card,S as CardLink,c as CardText,E as Client,v as CronExpression,f as Divider,s as NovuRequestHandler,h as Select,N as SelectOption,G as SeverityLevelEnum,q as TextInput,b as agent,m as frameworkName,y as providerSchemas,x as serve,k as step,I as workflow};
1
+ import{a as r,b as E,c as P,d as R,e as T,f as S,g as c,h as f,i as h,j as N,k as q,l as F,m as b,n as w,o as s,p as I}from"../chunk-E6L6ATIB.js";import"../chunk-T2VIX2ZH.js";import{a as k}from"../chunk-2M25EATE.js";import"../chunk-U3IL7QCI.js";import{O as G}from"../chunk-6GCCKYZC.js";import{a as y}from"../chunk-CBLKARLC.js";import{f as v}from"../chunk-EWC7I6UD.js";import"../chunk-52LSX2V5.js";var m="sveltekit",x=o=>{let t=new s({frameworkName:m,...o,handler:(u,e)=>({method:()=>u||e.request.method||"",body:()=>e.request.json(),headers:n=>e.request.headers.get(n),url:()=>{let n=process.env.NODE_ENV==="development"||process.env.NODE_ENV==="dev"?"http":"https";return new URL(e.request.url,`${n}://${e.request.headers.get("host")||""}`)},transformResponse:({body:n,headers:d,status:a})=>{let l=r();return new l(n,{status:a,headers:d})}})}).createHandler(),p=t.bind(null,void 0);return Object.defineProperties(p,{GET:{value:t.bind(null,"GET")},POST:{value:t.bind(null,"POST")},OPTIONS:{value:t.bind(null,"OPTIONS")}})};export{P as Actions,F as AgentDeliveryError,w as AgentEventEnum,R as Button,T as Card,S as CardLink,c as CardText,E as Client,v as CronExpression,f as Divider,s as NovuRequestHandler,h as Select,N as SelectOption,G as SeverityLevelEnum,q as TextInput,b as agent,m as frameworkName,y as providerSchemas,x as serve,k as step,I as workflow};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novu/framework",
3
- "version": "2.10.1-alpha.6",
3
+ "version": "2.10.1-alpha.7",
4
4
  "description": "The Code-First Notifications Workflow SDK.",
5
5
  "main": "./dist/cjs/index.cjs",
6
6
  "types": "./dist/cjs/index.d.cts",