@novu/framework 2.11.2-alpha.0 → 2.11.2-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/cjs/{agent.types-DdgaVUb7.d.cts → agent.types-Dqm2VBTO.d.cts} +56 -2
  2. package/dist/cjs/ai-sdk/index.cjs +1 -1
  3. package/dist/cjs/ai-sdk/index.d.cts +2 -1
  4. package/dist/cjs/{health-check.types-CkUmYLNG.d.cts → health-check.types-B9FbzRbm.d.cts} +2 -2
  5. package/dist/cjs/{index-BCp3U0UG.d.cts → index-1DobCKAF.d.cts} +4 -33
  6. package/dist/cjs/index.cjs +72 -72
  7. package/dist/cjs/index.d.cts +4 -4
  8. package/dist/cjs/internal/index.cjs +1 -1
  9. package/dist/cjs/internal/index.d.cts +7 -5
  10. package/dist/cjs/langchain/index.cjs +1 -1
  11. package/dist/cjs/langchain/index.d.cts +2 -1
  12. package/dist/cjs/servers/express.cjs +86 -86
  13. package/dist/cjs/servers/express.d.cts +5 -5
  14. package/dist/cjs/servers/h3.cjs +93 -93
  15. package/dist/cjs/servers/h3.d.cts +5 -5
  16. package/dist/cjs/servers/lambda.cjs +72 -72
  17. package/dist/cjs/servers/lambda.d.cts +5 -5
  18. package/dist/cjs/servers/nest.cjs +105 -105
  19. package/dist/cjs/servers/nest.d.cts +7 -7
  20. package/dist/cjs/servers/next.cjs +86 -86
  21. package/dist/cjs/servers/next.d.cts +5 -5
  22. package/dist/cjs/servers/nuxt.cjs +93 -93
  23. package/dist/cjs/servers/nuxt.d.cts +5 -5
  24. package/dist/cjs/servers/remix.cjs +86 -86
  25. package/dist/cjs/servers/remix.d.cts +5 -5
  26. package/dist/cjs/servers/sveltekit.cjs +91 -91
  27. package/dist/cjs/servers/sveltekit.d.cts +5 -5
  28. package/dist/cjs/step-resolver.cjs +1 -1
  29. package/dist/cjs/step-resolver.d.cts +2 -2
  30. package/dist/cjs/{subscriber.types-DxMMRBIi.d.cts → subscriber.types-DubxcL8q.d.cts} +16 -0
  31. package/dist/cjs/validators.cjs +1 -1
  32. package/dist/esm/{agent.types-Bu3DhlVb.d.ts → agent.types-E3sxq6xr.d.ts} +56 -2
  33. package/dist/esm/ai-sdk/index.d.ts +2 -1
  34. package/dist/esm/ai-sdk/index.js +1 -1
  35. package/dist/esm/{chunk-DKQLYSZS.js → chunk-22DBAEUX.js} +1 -1
  36. package/dist/esm/{chunk-QTWEINJ4.js → chunk-CANJPWLT.js} +1 -1
  37. package/dist/esm/chunk-E2MET7IR.js +1 -0
  38. package/dist/esm/chunk-Q6BV36LU.js +98 -0
  39. package/dist/esm/{health-check.types-nDCnGlmX.d.ts → health-check.types-BNocZ4Wk.d.ts} +2 -2
  40. package/dist/esm/{index-DEehllqa.d.ts → index-aVljLqR4.d.ts} +4 -33
  41. package/dist/esm/index.d.ts +4 -4
  42. package/dist/esm/index.js +1 -1
  43. package/dist/esm/internal/index.d.ts +7 -5
  44. package/dist/esm/internal/index.js +1 -1
  45. package/dist/esm/langchain/index.d.ts +2 -1
  46. package/dist/esm/langchain/index.js +1 -1
  47. package/dist/esm/servers/express.d.ts +5 -5
  48. package/dist/esm/servers/express.js +1 -1
  49. package/dist/esm/servers/h3.d.ts +5 -5
  50. package/dist/esm/servers/h3.js +1 -1
  51. package/dist/esm/servers/lambda.d.ts +5 -5
  52. package/dist/esm/servers/lambda.js +1 -1
  53. package/dist/esm/servers/nest.d.ts +7 -7
  54. package/dist/esm/servers/nest.js +1 -1
  55. package/dist/esm/servers/next.d.ts +5 -5
  56. package/dist/esm/servers/next.js +1 -1
  57. package/dist/esm/servers/nuxt.d.ts +5 -5
  58. package/dist/esm/servers/nuxt.js +1 -1
  59. package/dist/esm/servers/remix.d.ts +5 -5
  60. package/dist/esm/servers/remix.js +1 -1
  61. package/dist/esm/servers/sveltekit.d.ts +5 -5
  62. package/dist/esm/servers/sveltekit.js +1 -1
  63. package/dist/esm/step-resolver.d.ts +2 -2
  64. package/dist/esm/step-resolver.js +1 -1
  65. package/dist/esm/{subscriber.types-BbyO_Cz6.d.ts → subscriber.types-CmybpXhA.d.ts} +16 -0
  66. package/dist/esm/validators.js +1 -1
  67. package/package.json +2 -2
  68. package/dist/esm/chunk-KLIOXJR3.js +0 -1
  69. package/dist/esm/chunk-YF62BBGH.js +0 -98
@@ -1,9 +1,9 @@
1
- export { A as AgentDeliveryError, C as Client, N as NovuRequestHandler, S as ServeHandlerOptions, a as agent, w as workflow } from './index-BCp3U0UG.cjs';
2
- export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from './health-check.types-CkUmYLNG.cjs';
1
+ export { C as Client, N as NovuRequestHandler, S as ServeHandlerOptions, a as agent, w as workflow } from './index-1DobCKAF.cjs';
2
+ export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from './health-check.types-B9FbzRbm.cjs';
3
3
  export { Actions, Button, Card, CardChild, CardElement, CardLink, CardText, Divider, Select, SelectOption, TextInput } from 'chat';
4
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentConversation, f as AgentHandlerContext, g as AgentHandlers, h as AgentHistoryEntry, i as AgentMessage, j as AgentMessageAuthor, k as AgentMessageContext, l as AgentPlatformContext, m as AgentReaction, n as AgentReactionContext, o as AgentResolveContext, p as AgentSubscriber, q as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, r as ToolApprovalConfig, s as ToolApprovalDecision } from './agent.types-DdgaVUb7.cjs';
4
+ export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentContext, e as AgentConversation, f as AgentDeliveryError, g as AgentError, h as AgentHandlerContext, 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 AgentResolveContext, r as AgentSubscriber, s as AgentToolCall, F as FileRef, M as MessageContent, R as ReplyHandle, T as ToolApprovalCard, t as ToolApprovalConfig, u as ToolApprovalDecision, v as toAgentError } from './agent.types-Dqm2VBTO.cjs';
5
5
  export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, step } from './step-resolver.cjs';
6
- export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from './subscriber.types-DxMMRBIi.cjs';
6
+ export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from './subscriber.types-DubxcL8q.cjs';
7
7
  import './util.types-DaFfsxgy.cjs';
8
8
  import './base.schema.types-BApIn9jr.cjs';
9
9
  import 'json-schema-to-ts';
@@ -1 +1 @@
1
- "use strict";var oi=Object.create;var k=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var si=Object.getOwnPropertyNames;var ai=Object.getPrototypeOf,li=Object.prototype.hasOwnProperty;var ke=(e,t,i)=>()=>{if(i)throw i[0];try{return e&&(t=e(e=0)),t}catch(o){throw i=[o],o}};var De=(e,t)=>{for(var i in t)k(e,i,{get:t[i],enumerable:!0})},Me=(e,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of si(t))!li.call(e,n)&&n!==i&&k(e,n,{get:()=>t[n],enumerable:!(o=ri(t,n))||o.enumerable});return e};var Ue=(e,t,i)=>(i=e!=null?oi(ai(e)):{},Me(t||!e||!e.__esModule?k(i,"default",{value:e,enumerable:!0}):i,e)),pi=e=>Me(k({},"__esModule",{value:!0}),e);function yi(e={}){var t;return{type:"card",title:e.title,subtitle:e.subtitle,imageUrl:e.imageUrl,children:(t=e.children)!=null?t:[]}}function lt(e,t={}){return{type:"text",content:e,style:t.style}}function pt(e){return{type:"image",url:e.url,alt:e.alt}}function ct(){return{type:"divider"}}function dt(e){return{type:"section",children:e}}function ut(e){return{type:"actions",children:e}}function mt(e){return{type:"button",id:e.id,label:e.label,style:e.style,value:e.value,disabled:e.disabled,actionType:e.actionType,callbackUrl:e.callbackUrl}}function ht(e){return{type:"link-button",id:e.id,url:e.url,label:e.label,style:e.style}}function yt(e){return{type:"field",label:e.label,value:e.value}}function gt(e){return{type:"fields",children:e}}function ft(e){return{type:"table",headers:e.headers,rows:e.rows,align:e.align}}function bt(e){return{type:"link",url:e.url,label:e.label}}function fi(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="modal"}function bi(e){let t=e.filter(i=>typeof i=="object"&&i!==null&&"type"in i&&gi.includes(i.type));return t.length<e.length&&console.warn("[chat] Modal contains unsupported child elements that were ignored"),t}function Tt(e){var t;return{type:"modal",callbackId:e.callbackId,callbackUrl:e.callbackUrl,title:e.title,submitLabel:e.submitLabel,closeLabel:e.closeLabel,notifyOnClose:e.notifyOnClose,privateMetadata:e.privateMetadata,children:(t=e.children)!=null?t:[]}}function wt(e){return{type:"text_input",id:e.id,label:e.label,placeholder:e.placeholder,initialValue:e.initialValue,multiline:e.multiline,optional:e.optional,maxLength:e.maxLength}}function At(e){if(!e.options||e.options.length===0)throw new Error("Select requires at least one option");return{type:"select",id:e.id,label:e.label,placeholder:e.placeholder,options:e.options,initialOption:e.initialOption,optional:e.optional}}function St(e){return{type:"external_select",id:e.id,initialOption:e.initialOption,label:e.label,placeholder:e.placeholder,minQueryLength:e.minQueryLength,optional:e.optional}}function vt(e){return{label:e.label,value:e.value,description:e.description}}function Rt(e){if(!e.options||e.options.length===0)throw new Error("RadioSelect requires at least one option");return{type:"radio_select",id:e.id,label:e.label,options:e.options,initialOption:e.initialOption,optional:e.optional}}function Y(e){return typeof e=="object"&&e!==null&&e.$$typeof===xe}function _e(e){if(e==null)return[];if(Array.isArray(e))return e.flatMap(_e);if(Y(e)){let t=Ie(e);return t?[t]:[]}return typeof e=="object"&&"type"in e?[e]:typeof e=="string"||typeof e=="number"?[String(e)]:[]}function Ti(e){return!("id"in e||"url"in e||"label"in e)}function wi(e){return"id"in e&&typeof e.id=="string"&&!("url"in e)}function Ai(e){return"url"in e&&typeof e.url=="string"&&!("id"in e)}function Oe(e){return"url"in e&&typeof e.url=="string"&&!("id"in e)&&!("alt"in e)&&!("style"in e)}function Si(e){return"url"in e&&typeof e.url=="string"}function vi(e){return"label"in e&&"value"in e&&typeof e.label=="string"&&typeof e.value=="string"}function Ri(e){return!("id"in e||"url"in e||"callbackId"in e)&&("title"in e||"subtitle"in e||"imageUrl"in e)}function xi(e){return"callbackId"in e&&"title"in e}function _i(e){return"id"in e&&"label"in e&&!("options"in e)&&!("value"in e)}function xt(e){return"id"in e&&"label"in e&&!("value"in e)}function Oi(e){return"id"in e&&"label"in e&&!("value"in e)&&!("children"in e)}function Ii(e){return"label"in e&&"value"in e&&!("id"in e)}function Ie(e){var c,p,h,l;let{type:t,props:i,children:o}=e,n=_e(o);if(t===lt){let d=Ti(i)?i:{style:void 0},A=n.length>0?n.map(String).join(""):String((c=d.children)!=null?c:"");return lt(A,{style:d.style})}if(t===dt)return dt(n);if(t===ut)return ut(n);if(t===gt)return gt(n);if(t===mt){if(!wi(i))throw new Error("Button requires an 'id' prop");let d=n.length>0?n.map(String).join(""):(p=i.label)!=null?p:"";return mt({id:i.id,label:d,style:i.style,value:i.value,actionType:i.actionType,callbackUrl:i.callbackUrl,disabled:i.disabled})}if(t===ht){if(!Ai(i))throw new Error("LinkButton requires a 'url' prop");let d=n.length>0?n.map(String).join(""):(h=i.label)!=null?h:"";return ht({id:i.id,url:i.url,label:d,style:i.style})}if(t===bt){if(!Oe(i))throw new Error("CardLink requires a 'url' prop");let d=n.length>0?n.map(String).join(""):(l=i.label)!=null?l:"";return bt({url:i.url,label:d})}if(t===pt){if(!Si(i))throw new Error("Image requires a 'url' prop");return pt({url:i.url,alt:i.alt})}if(t===yt){if(!vi(i))throw new Error("Field requires 'label' and 'value' props");return yt({label:i.label,value:i.value})}if(t===ct)return ct();if(t===Tt){if(!xi(i))throw new Error("Modal requires 'callbackId' and 'title' props");return Tt({callbackId:i.callbackId,callbackUrl:i.callbackUrl,title:i.title,submitLabel:i.submitLabel,closeLabel:i.closeLabel,notifyOnClose:i.notifyOnClose,privateMetadata:i.privateMetadata,children:bi(n)})}if(t===wt){if(!_i(i))throw new Error("TextInput requires 'id' and 'label' props");return wt({id:i.id,label:i.label,placeholder:i.placeholder,initialValue:i.initialValue,multiline:i.multiline,optional:i.optional,maxLength:i.maxLength})}if(t===At){if(!xt(i))throw new Error("Select requires 'id' and 'label' props");return At({id:i.id,label:i.label,placeholder:i.placeholder,initialOption:i.initialOption,optional:i.optional,options:n})}if(t===St){if(!Oi(i))throw new Error("ExternalSelect requires 'id' and 'label' props");return St({id:i.id,initialOption:i.initialOption,label:i.label,placeholder:i.placeholder,minQueryLength:i.minQueryLength,optional:i.optional})}if(t===Rt){if(!xt(i))throw new Error("RadioSelect requires 'id' and 'label' props");return Rt({id:i.id,label:i.label,initialOption:i.initialOption,optional:i.optional,options:n})}if(t===vt){if(!Ii(i))throw new Error("SelectOption requires 'label' and 'value' props");return vt({label:i.label,value:i.value,description:i.description})}if(t===ft){let d=i;return ft({headers:d.headers,rows:d.rows})}let a=Ri(i)?i:{};return yi({title:a.title,subtitle:a.subtitle,imageUrl:a.imageUrl,children:n})}function Pe(e,t,i){let{children:o,...n}=t;return{$$typeof:xe,type:e,props:n,children:o!=null?[o]:[]}}function _t(e,t,i){let{children:o,...n}=t,a;return Array.isArray(o)?a=o:o!=null?a=[o]:a=[],{$$typeof:xe,type:e,props:n,children:a}}function It(e){return _e(e.children)}function Pt(e){if(Y(e)){let t=Ie(e);if(t&&typeof t=="object"&&"type"in t&&t.type==="card")return t}return typeof e=="object"&&e!==null&&"type"in e&&e.type==="card"?e:null}function Et(e){if(Y(e)){let t=Ie(e);if(t&&typeof t=="object"&&"type"in t&&t.type==="modal")return t}return fi(e)?e:null}function Ct(e){if(Y(e))return!0;if(typeof e=="object"&&e!==null&&"$$typeof"in e&&typeof e.$$typeof=="symbol"){let t=e.$$typeof.toString();return t.includes("react.element")||t.includes("react.transitional.element")}return!1}var gi,xe,Ot,Nt=ke(()=>{"use strict";gi=["text_input","select","external_select","radio_select","text","fields"];xe=Symbol.for("chat.jsx.element");Ot=Pe});var kt={};De(kt,{Fragment:()=>It,isCardLinkProps:()=>Oe,isJSX:()=>Ct,jsx:()=>Pe,jsxDEV:()=>Ot,jsxs:()=>_t,toCardElement:()=>Pt,toModalElement:()=>Et});var Dt=ke(()=>{"use strict";Nt()});var on={};De(on,{ActionStepEnum:()=>Be,AgentContextImpl:()=>V,AgentEventEnum:()=>Re,BadRequestError:()=>y,BridgeError:()=>W,ChannelStepEnum:()=>qe,ConflictError:()=>I,CronExpression:()=>Ye,ErrorCodeEnum:()=>g,ExecutionEventControlsInvalidError:()=>z,ExecutionEventPayloadInvalidError:()=>G,ExecutionProviderOutputInvalidError:()=>Z,ExecutionStateControlsInvalidError:()=>X,ExecutionStateCorruptError:()=>J,ExecutionStateOutputInvalidError:()=>K,ExecutionStateResultInvalidError:()=>H,FILTER_VALIDATORS:()=>di,ForbiddenError:()=>$,FrameworkError:()=>f,GetActionEnum:()=>Fe,HttpHeaderKeysEnum:()=>B,HttpMethodEnum:()=>D,HttpQueryKeysEnum:()=>Ve,HttpStatusEnum:()=>x,InvalidActionError:()=>ne,JobStatusEnum:()=>Qt,MethodNotAllowedError:()=>ie,MissingSecretKeyError:()=>oe,NotFoundError:()=>O,NovuApiEndpointsEnum:()=>je,PlatformError:()=>re,PostActionEnum:()=>Le,ProviderExecutionFailedError:()=>ae,ProviderNotFoundError:()=>se,ResourceConflictError:()=>v,ResourceEnum:()=>_,ResourceExecutionFailed:()=>R,ResourceNotFoundError:()=>T,SIGNATURE_TIMESTAMP_TOLERANCE:()=>ci,SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES:()=>q,ServerError:()=>S,SeverityLevelEnum:()=>Zt,SignatureExpiredError:()=>de,SignatureInvalidError:()=>ce,SignatureMismatchError:()=>le,SignatureNotFoundError:()=>pe,SignatureVersionInvalidError:()=>me,SigningKeyNotFoundError:()=>ue,StepAlreadyExistsError:()=>ye,StepControlCompilationFailedError:()=>Q,StepExecutionFailedError:()=>ge,StepNotFoundError:()=>he,UnauthorizedError:()=>b,WorkflowAlreadyExistsError:()=>be,WorkflowChannelEnum:()=>$e,WorkflowNotFoundError:()=>fe,WorkflowPayloadInvalidError:()=>ee,actionStepSchemas:()=>Bt,buildApprovalActionId:()=>P,channelStepSchemas:()=>Ht,createLiquidEngine:()=>ii,digest:()=>Te,isFrameworkError:()=>Je,isNativeError:()=>We,parseApprovalActionId:()=>st,pluralize:()=>we,toSentence:()=>Se,toSentenceArgsValidator:()=>ve});module.exports=pi(on);var Le=(n=>(n.TRIGGER="trigger",n.EXECUTE="execute",n.PREVIEW="preview",n.AGENT_EVENT="agent-event",n))(Le||{}),Fe=(o=>(o.DISCOVER="discover",o.HEALTH_CHECK="health-check",o.CODE="code",o))(Fe||{});var je=(i=>(i.SYNC="/v1/bridge/sync",i.DIFF="/v1/bridge/diff",i))(je||{}),q=5,ci=3e5;var Ye=(s=>(s.EVERY_SECOND="* * * * * *",s.EVERY_5_SECONDS="*/5 * * * * *",s.EVERY_10_SECONDS="*/10 * * * * *",s.EVERY_30_SECONDS="*/30 * * * * *",s.EVERY_MINUTE="*/1 * * * *",s.EVERY_5_MINUTES="0 */5 * * * *",s.EVERY_10_MINUTES="0 */10 * * * *",s.EVERY_30_MINUTES="0 */30 * * * *",s.EVERY_HOUR="0 0-23/1 * * *",s.EVERY_2_HOURS="0 0-23/2 * * *",s.EVERY_3_HOURS="0 0-23/3 * * *",s.EVERY_4_HOURS="0 0-23/4 * * *",s.EVERY_5_HOURS="0 0-23/5 * * *",s.EVERY_6_HOURS="0 0-23/6 * * *",s.EVERY_7_HOURS="0 0-23/7 * * *",s.EVERY_8_HOURS="0 0-23/8 * * *",s.EVERY_9_HOURS="0 0-23/9 * * *",s.EVERY_10_HOURS="0 0-23/10 * * *",s.EVERY_11_HOURS="0 0-23/11 * * *",s.EVERY_12_HOURS="0 0-23/12 * * *",s.EVERY_DAY_AT_1AM="0 01 * * *",s.EVERY_DAY_AT_2AM="0 02 * * *",s.EVERY_DAY_AT_3AM="0 03 * * *",s.EVERY_DAY_AT_4AM="0 04 * * *",s.EVERY_DAY_AT_5AM="0 05 * * *",s.EVERY_DAY_AT_6AM="0 06 * * *",s.EVERY_DAY_AT_7AM="0 07 * * *",s.EVERY_DAY_AT_8AM="0 08 * * *",s.EVERY_DAY_AT_9AM="0 09 * * *",s.EVERY_DAY_AT_10AM="0 10 * * *",s.EVERY_DAY_AT_11AM="0 11 * * *",s.EVERY_DAY_AT_NOON="0 12 * * *",s.EVERY_DAY_AT_1PM="0 13 * * *",s.EVERY_DAY_AT_2PM="0 14 * * *",s.EVERY_DAY_AT_3PM="0 15 * * *",s.EVERY_DAY_AT_4PM="0 16 * * *",s.EVERY_DAY_AT_5PM="0 17 * * *",s.EVERY_DAY_AT_6PM="0 18 * * *",s.EVERY_DAY_AT_7PM="0 19 * * *",s.EVERY_DAY_AT_8PM="0 20 * * *",s.EVERY_DAY_AT_9PM="0 21 * * *",s.EVERY_DAY_AT_10PM="0 22 * * *",s.EVERY_DAY_AT_11PM="0 23 * * *",s.EVERY_DAY_AT_MIDNIGHT="0 0 * * *",s.EVERY_WEEK="0 0 * * 0",s.EVERY_WEEKDAY="0 0 * * 1-5",s.EVERY_WEEKEND="0 0 * * 6,0",s.EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT="0 0 1 * *",s.EVERY_1ST_DAY_OF_MONTH_AT_NOON="0 12 1 * *",s.EVERY_2ND_DAY_OF_MONTH_AT_10AM="0 10 2 * *",s.EVERY_2ND_HOUR="0 */2 * * *",s.EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM="0 1-23/2 * * *",s.EVERY_2ND_MONTH="0 0 1 */2 *",s.EVERY_QUARTER="0 0 1 */3 *",s.EVERY_6_MONTHS="0 0 1 */6 *",s.EVERY_YEAR="0 0 1 0 *",s.EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM="0 */30 9-17 * * *",s.EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM="0 */30 9-18 * * *",s.EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM="0 */30 10-19 * * *",s.MONDAY_TO_FRIDAY_AT_1AM="0 0 01 * * 1-5",s.MONDAY_TO_FRIDAY_AT_2AM="0 0 02 * * 1-5",s.MONDAY_TO_FRIDAY_AT_3AM="0 0 03 * * 1-5",s.MONDAY_TO_FRIDAY_AT_4AM="0 0 04 * * 1-5",s.MONDAY_TO_FRIDAY_AT_5AM="0 0 05 * * 1-5",s.MONDAY_TO_FRIDAY_AT_6AM="0 0 06 * * 1-5",s.MONDAY_TO_FRIDAY_AT_7AM="0 0 07 * * 1-5",s.MONDAY_TO_FRIDAY_AT_8AM="0 0 08 * * 1-5",s.MONDAY_TO_FRIDAY_AT_9AM="0 0 09 * * 1-5",s.MONDAY_TO_FRIDAY_AT_09_30AM="0 30 09 * * 1-5",s.MONDAY_TO_FRIDAY_AT_10AM="0 0 10 * * 1-5",s.MONDAY_TO_FRIDAY_AT_11AM="0 0 11 * * 1-5",s.MONDAY_TO_FRIDAY_AT_11_30AM="0 30 11 * * 1-5",s.MONDAY_TO_FRIDAY_AT_12PM="0 0 12 * * 1-5",s.MONDAY_TO_FRIDAY_AT_1PM="0 0 13 * * 1-5",s.MONDAY_TO_FRIDAY_AT_2PM="0 0 14 * * 1-5",s.MONDAY_TO_FRIDAY_AT_3PM="0 0 15 * * 1-5",s.MONDAY_TO_FRIDAY_AT_4PM="0 0 16 * * 1-5",s.MONDAY_TO_FRIDAY_AT_5PM="0 0 17 * * 1-5",s.MONDAY_TO_FRIDAY_AT_6PM="0 0 18 * * 1-5",s.MONDAY_TO_FRIDAY_AT_7PM="0 0 19 * * 1-5",s.MONDAY_TO_FRIDAY_AT_8PM="0 0 20 * * 1-5",s.MONDAY_TO_FRIDAY_AT_9PM="0 0 21 * * 1-5",s.MONDAY_TO_FRIDAY_AT_10PM="0 0 22 * * 1-5",s.MONDAY_TO_FRIDAY_AT_11PM="0 0 23 * * 1-5",s))(Ye||{});var g=(u=>(u.BRIDGE_ERROR="BridgeError",u.EXECUTION_EVENT_CONTROL_INVALID_ERROR="ExecutionEventControlInvalidError",u.EXECUTION_EVENT_PAYLOAD_INVALID_ERROR="ExecutionEventPayloadInvalidError",u.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",u.EXECUTION_STATE_CONTROL_INVALID_ERROR="ExecutionStateControlInvalidError",u.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",u.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",u.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",u.INVALID_ACTION_ERROR="InvalidActionError",u.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",u.MISSING_DEPENDENCY_ERROR="MissingDependencyError",u.MISSING_SECRET_KEY_ERROR="MissingSecretKeyError",u.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",u.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",u.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",u.SIGNATURE_INVALID_ERROR="SignatureInvalidError",u.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",u.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",u.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",u.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",u.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",u.STEP_CONTROL_COMPILATION_FAILED_ERROR="StepControlCompilationFailedError",u.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",u.STEP_NOT_FOUND_ERROR="StepNotFoundError",u.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",u.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",u.WORKFLOW_PAYLOAD_INVALID_ERROR="WorkflowPayloadInvalidError",u))(g||{});var B=(m=>(m.NOVU_SIGNATURE="novu-signature",m.NOVU_ANONYMOUS="novu-anonymous",m.NOVU_FRAMEWORK_SDK="novu-framework-sdk",m.NOVU_FRAMEWORK_SERVER="novu-framework-server",m.NOVU_FRAMEWORK_VERSION="novu-framework-version",m.USER_AGENT="user-agent",m.CONTENT_TYPE="content-type",m.ACCESS_CONTROL_ALLOW_ORIGIN="access-control-allow-origin",m.ACCESS_CONTROL_ALLOW_METHODS="access-control-allow-methods",m.ACCESS_CONTROL_ALLOW_HEADERS="access-control-allow-headers",m.ACCESS_CONTROL_MAX_AGE="access-control-max-age",m.ACCESS_CONTROL_ALLOW_PRIVATE_NETWORK="access-control-allow-private-network",m))(B||{});var D=(o=>(o.POST="POST",o.GET="GET",o.OPTIONS="OPTIONS",o))(D||{});var Ve=(c=>(c.WORKFLOW_ID="workflowId",c.STEP_ID="stepId",c.ACTION="action",c.SOURCE="source",c.AGENT_ID="agentId",c.EVENT="event",c))(Ve||{});var x=(r=>(r[r.CONTINUE=100]="CONTINUE",r[r.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",r[r.PROCESSING=102]="PROCESSING",r[r.EARLYHINTS=103]="EARLYHINTS",r[r.OK=200]="OK",r[r.CREATED=201]="CREATED",r[r.ACCEPTED=202]="ACCEPTED",r[r.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",r[r.NO_CONTENT=204]="NO_CONTENT",r[r.RESET_CONTENT=205]="RESET_CONTENT",r[r.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",r[r.AMBIGUOUS=300]="AMBIGUOUS",r[r.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",r[r.FOUND=302]="FOUND",r[r.SEE_OTHER=303]="SEE_OTHER",r[r.NOT_MODIFIED=304]="NOT_MODIFIED",r[r.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",r[r.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",r[r.BAD_REQUEST=400]="BAD_REQUEST",r[r.UNAUTHORIZED=401]="UNAUTHORIZED",r[r.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",r[r.FORBIDDEN=403]="FORBIDDEN",r[r.NOT_FOUND=404]="NOT_FOUND",r[r.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",r[r.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",r[r.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",r[r.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",r[r.CONFLICT=409]="CONFLICT",r[r.GONE=410]="GONE",r[r.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",r[r.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",r[r.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",r[r.URI_TOO_LONG=414]="URI_TOO_LONG",r[r.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",r[r.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",r[r.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",r[r.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",r[r.MISDIRECTED=421]="MISDIRECTED",r[r.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",r[r.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",r[r.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",r[r.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",r[r.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",r[r.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",r[r.BAD_GATEWAY=502]="BAD_GATEWAY",r[r.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",r[r.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",r[r.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",r))(x||{});var _=(o=>(o.WORKFLOW="workflow",o.PROVIDER="provider",o.STEP="step",o))(_||{});var qe=(a=>(a.EMAIL="email",a.SMS="sms",a.PUSH="push",a.CHAT="chat",a.IN_APP="in_app",a))(qe||{}),Be=(a=>(a.DIGEST="digest",a.DELAY="delay",a.THROTTLE="throttle",a.CUSTOM="custom",a.HTTP_REQUEST="http_request",a))(Be||{});var $e=(a=>(a.EMAIL="email",a.SMS="sms",a.PUSH="push",a.CHAT="chat",a.IN_APP="inApp",a))($e||{});var We=e=>{var i,o;if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return(o=(i=t==null?void 0:t.constructor)==null?void 0:i.name.endsWith("Error"))!=null?o:!1},f=class extends Error{},O=class extends f{constructor(){super(...arguments);this.statusCode=404}},y=class extends f{constructor(){super(...arguments);this.statusCode=400}},b=class extends f{constructor(){super(...arguments);this.statusCode=401}},S=class extends f{constructor(t,{cause:i}={}){var o;We(i)?(super(`${t}: ${i.message}`),this.data={stack:(o=i.stack)!=null?o:t}):(super(`${t}${i?`: ${JSON.stringify(i,null,2)}`:""}`),this.data={stack:t})}},I=class extends f{constructor(){super(...arguments);this.statusCode=409}},$=class extends f{constructor(){super(...arguments);this.statusCode=403}};var W=class extends S{constructor(i){super("Unknown BridgeError",{cause:i});this.statusCode=500;this.code="BridgeError"}};var J=class extends y{constructor(i,o){super(`Workflow with id: \`${i}\` has a corrupt state. Step with id: \`${o}\` does not exist. Please provide the missing state.`);this.code="ExecutionStateCorruptError";this.data={workflowId:i,stepId:o}}},G=class extends y{constructor(i,o){super(`Workflow with id: \`${i}\` has invalid \`payload\`. Please provide the correct event payload.`);this.code="ExecutionEventPayloadInvalidError";this.data=o}},z=class extends y{constructor(i,o){super(`Workflow with id: \`${i}\` has invalid \`controls\`. Please provide the correct event controls.`);this.code="ExecutionEventControlInvalidError";this.data=o}},X=class extends y{constructor(i,o,n){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${o}\` has invalid \`controls\`. Please provide the correct step controls.`);this.code="ExecutionStateControlInvalidError";this.data=n}},K=class extends y{constructor(i,o,n){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${o}\` has invalid output. Please provide the correct step output.`);this.code="ExecutionStateOutputInvalidError";this.data=n}},H=class extends y{constructor(i,o,n){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${o}\` has invalid result. Please provide the correct step result.`);this.code="ExecutionStateResultInvalidError";this.data=n}},Q=class extends y{constructor(i,o,n){super(`Workflow with id: \`${i}\` has invalid controls syntax in step with id: \`${o}\`. Please correct step control syntax.`);this.code="StepControlCompilationFailedError";this.data=n}},Z=class extends y{constructor(i,o,n,a){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${o}\` and provider with id: \`${n}\` has invalid output. Please provide the correct provider output.`);this.code="ExecutionProviderOutputInvalidError";this.data=a}},ee=class extends y{constructor(i,o){super(`Workflow with id: \`${i}\` has invalid \`payload\`. Please provide the correct payload.`);this.code="WorkflowPayloadInvalidError";this.data=o}};var Je=e=>Object.values(g).includes(e==null?void 0:e.code);var te=e=>Object.values(e).map(t=>`\`${t}\``).join(", "),M=e=>e.replaceAll(/(\w)(\w*)/g,(t,i,o)=>i.toUpperCase()+o.toLowerCase()).replaceAll(/[\s-]+/g,"");var ie=class extends f{constructor(){super(...arguments);this.code="MethodNotAllowedError";this.statusCode=405;this.message=`Method not allowed. Please use one of ${te(D)}`}},ne=class extends y{constructor(i,o){super(`Invalid query string: \`action\`=\`${i}\`. Please use one of ${te(o)}`);this.code="InvalidActionError"}},oe=class extends y{constructor(){super("Missing secret key. Set the `NOVU_SECRET_KEY` environment variable or pass `secretKey` to the client options.");this.code="MissingSecretKeyError"}};var re=class extends Error{constructor(t,i,o){super(),this.data={message:o},this.statusCode=t,this.code=i}};var v=class extends I{constructor(t,i){super(`${M(t)} with id: \`${i}\` already exists. Please use a different id.`)}},T=class extends O{constructor(t,i){super(`${M(t)} with id: \`${i}\` does not exist. Please provide a valid id.`)}},R=class extends S{constructor(i,o,n,a){super(`Failed to ${n} ${M(i)} with id: \`${o}\``,{cause:a});this.statusCode=502}};var se=class extends T{constructor(i){super("provider",i);this.code="ProviderNotFoundError"}},ae=class extends R{constructor(i,o,n){super("provider",i,o,n);this.code="ProviderExecutionFailedError"}};var le=class extends b{constructor(){super("Signature does not match the expected signature. Please ensure the signature provided in the `novu-signature` header is correct and try again.");this.code="SignatureMismatchError"}},pe=class extends b{constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");this.code="SignatureNotFoundError"}},ce=class extends b{constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");this.code="SignatureInvalidError"}},de=class extends b{constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`novu-signature\` header`);this.code="SignatureExpiredError"}},ue=class extends b{constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");this.code="SigningKeyNotFoundError"}},me=class extends b{constructor(){super("Signature version is invalid. Please provide a signature version with version `v1` in the `novu-signature` header");this.code="SignatureVersionInvalidError"}};var he=class extends T{constructor(i){super("step",i);this.code="StepNotFoundError"}},ye=class extends v{constructor(i){super("step",i);this.code="StepAlreadyExistsError"}},ge=class extends R{constructor(i,o,n){super("step",i,o,n);this.code="StepExecutionFailedError"}};var fe=class extends T{constructor(i){super("workflow",i);this.code="WorkflowNotFoundError"}},be=class extends v{constructor(i){super("workflow",i);this.code="WorkflowAlreadyExistsError"}};function U(e,t){let i=t.split(".").reduce((o,n)=>{if(o&&typeof o=="object")return o[n]},e);if(i==null)return"";if(typeof i=="string")return i;if(typeof i=="number"||typeof i=="boolean")return String(i);if(typeof i=="object"){let o=JSON.stringify(i);return o==="{}"?"":o}return""}function Te(e,t=2,i,o=", "){if(!Array.isArray(e)||e.length===0)return"";let n=i?e.map(p=>typeof p!="object"||!p?"":U(p,i)):e;if(n.length===1)return n[0];if(n.length===2)return`${n[0]} and ${n[1]}`;if(n.length===3&&t>=3)return`${n[0]}, ${o}${n[1]} and ${n[2]}`;let a=n.slice(0,t),c=n.length-t;return`${a.join(o)} and ${c} ${c===1?"other":"others"}`}var Ge=Ue(require("pluralize"),1);function we(e,t="",i="",o="true"){if(e==null)return"";let n=0;if(Array.isArray(e)?n=e.length:typeof e=="object"?n=Object.keys(e).length:typeof e=="string"?n=+e:typeof e=="number"?n=e:n=Number(e),Number.isNaN(n)&&(n=0),n<=0)return"";let a;return i?a=n===1?t:i:a=(0,Ge.default)(t,n),o==="true"?`${n} ${a}`:a}var Ae=require("liquidjs"),Xe=Ue(require("pluralize"),1),w=require("zod");var Ke="",He=2,Qe="other",Ze=", ",et=" and ",tt=", and ",ze={0:"keyPath",1:"limit",2:"overflowSuffix",3:"wordsConnector",4:"twoWordsConnector",5:"lastWordConnector"};function Se(e,t=Ke,i=He,o=Qe,n=Ze,a=et,c=tt){if(!Array.isArray(e)||e.length===0)return"";let p=t?e.map(m=>typeof m!="object"||!m?"":U(m,t)):e,h=p.length;if(h===1)return p[0];if(h===2)return`${p[0]}${a}${p[1]}`;if(i>=h){let m=p.slice(0,h-1),Ne=p[h-1];return`${m.join(n)}${c}${Ne}`}let l=p.slice(0,i),d=h-i,A=i===1?a:c;return`${l.join(n)}${A}${d} ${(0,Xe.default)(o,d)}`}function ve(e={},...t){let{requireKeyPath:i=!1}=e,o=[];if(t.length<1)return o.push({message:"Expected at least 1 argument",begin:0,end:0,value:""}),o;let n=w.z.object({keyPath:i?w.z.string().min(1,"must be non-empty"):w.z.string().optional().default(Ke),limit:w.z.number().optional().default(He).refine(p=>p>=0,"must be greater than or equal to 0"),overflowSuffix:w.z.string().optional().default(Qe),wordsConnector:w.z.string().optional().default(Ze),twoWordsConnector:w.z.string().optional().default(et),lastWordConnector:w.z.string().optional().default(tt)}),a={};t.forEach((p,h)=>{if(!Array.isArray(p)){let l=p.getText();(p.kind===Ae.TokenKind.Quoted||p.kind===Ae.TokenKind.Number)&&(l=p.content);let d=ze[h];a[d]=l}});let c=n.safeParse(a);if(!c.success)for(let p of c.error.issues){let h="string";"type"in p&&(h=p.type);let l=p.path[0],d=Object.entries(ze).find(([Ne,ni])=>ni===l),A=d?parseInt(d[0],10):null,m=typeof A=="number"?t[A]:null;m&&!Array.isArray(m)&&o.push({message:`"toSentence" expects a ${h}${p.message?` that ${p.message}`:""} for argument "${l}"`,begin:m.begin,end:m.end,value:m.getText()})}return o}var di={toSentence:ve};var ui={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 L(e){return typeof e=="string"&&e.trim()?e:!e||typeof e!="object"?null:L(e.message)}function mi(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;let i=t,o=L(i.message);if(o)return o;let n=L(i.error);if(n)return n;let a=i.errors;return Array.isArray(a)?L(a[0]):null}var F=class extends Error{constructor(t,i){var c;let o=(c=ui[t])!=null?c:t,n=mi(i),a=n?`Delivery failed: ${o}: ${n}`:`Delivery failed: ${o}`;super(a),this.name="AgentDeliveryError",this.statusCode=t,this.responseBody=i}};var it=Symbol.for("novu.agent.runtimeContext");var Re=(n=>(n.ON_MESSAGE="onMessage",n.ON_ACTION="onAction",n.ON_RESOLVE="onResolve",n.ON_REACTION="onReaction",n))(Re||{}),j=class{constructor(){this.__novuPendingApproval=!0}};function nt(e){return"type"in e&&e.type==="card"}function ot(e){return typeof e=="object"&&e!==null&&e.type==="tool-approval-card"}var rt="tool-approval";function hi(e){return e==="approve"||e==="deny"}function P(e,t){return`${rt}:${e}:${t}`}function st(e){let[t,i,...o]=(e!=null?e:"").split(":"),n=o.join(":");return t!==rt||!hi(i)||!n?null:{approved:i==="approve",approvalId:n}}async function at(e,t,i,o){var l,d;let n=o!=null?o:t.id,a={approve:P("approve",n),deny:P("deny",n)},c=A=>({type:"tool-approval-card",...A}),p=(d=(l=i==null?void 0:i.renderApproval)==null?void 0:l.call(i,{toolCall:t,actionIds:a,approvalCard:c}))!=null?d:c(),h={approvalId:n,toolCallId:t.id,name:t.name,input:t.input};if(e.emitToolApprovalRequest(h),ot(p)){await e.replyApprovalCard(p);return}await e.reply(p)}var Pi=5*1024*1024,Ei=5*1024*1024,Mt=32768,Ci=/^[A-Za-z0-9+/]*={0,2}$/;function N(e,t){return e.filename?`"${e.filename}"`:`at index ${t}`}function Lt(){return globalThis.Buffer}function Ni(e){var t,i,o;return(o=(i=(t=Lt())==null?void 0:t.isBuffer)==null?void 0:i.call(t,e))!=null?o:!1}function ki(e){return typeof Blob!="undefined"&&e instanceof Blob}function Ee(e){let t=Lt();if(t)return t.from(e).toString("base64");if(typeof btoa!="function")throw new Error("Unable to encode file data: base64 encoding is not available in this runtime.");let i="";for(let o=0;o<e.length;o+=Mt){let n=e.subarray(o,o+Mt);i+=String.fromCharCode(...n)}return btoa(i)}function Ft(e){let t=e.replace(/\s/g,""),i=t.length%4;if(!t||i===1||!Ci.test(t))return null;let o=t.endsWith("==")?2:t.endsWith("=")?1:0;return Math.floor(t.length*3/4)-o}function E(e,t,i){if(e>Pi)throw new Error(`Invalid file ${N(t,i)}: inline data must be 5 MB or smaller. Use a publicly-accessible URL for larger files.`)}async function Di(e,t,i){if(typeof e=="string"){let o=Ft(e);if(o===null)throw new Error(`Invalid file ${N(t,i)}: data must be a base64-encoded string.`);return E(o,t,i),e}if(Ni(e))return E(e.byteLength,t,i),e.toString("base64");if(e instanceof Uint8Array)return E(e.byteLength,t,i),Ee(e);if(e instanceof ArrayBuffer)return E(e.byteLength,t,i),Ee(new Uint8Array(e));if(ki(e))return E(e.size,t,i),Ee(new Uint8Array(await e.arrayBuffer()));throw new Error(`Invalid file ${N(t,i)}: data must be a base64 string, Buffer, Uint8Array, ArrayBuffer, or Blob.`)}async function Mi(e){if(!(e!=null&&e.length))return;let t=[],i=0;for(let[o,n]of e.entries()){let a=n.data,c=n.url,p=a!=null,h=c!=null;if(p===h)throw new Error(`Invalid file ${N(n,o)}: provide exactly one of data or url.`);if(p){let l=await Di(a,n,o),d=Ft(l);if(i+=d!=null?d:0,i>Ei)throw new Error("Invalid files: total inline data must be 5 MB or smaller. Use publicly-accessible URLs for larger files.");t.push({...n,data:l});continue}if(h&&typeof c!="string")throw new Error(`Invalid file ${N(n,o)}: url must be a string.`);t.push(n)}return t}async function jt(e,t){let i=await Mi(t);if(typeof e=="string")return i?{markdown:e,files:i}:{markdown:e};let{isJSX:o,toCardElement:n}=await Promise.resolve().then(()=>(Dt(),kt));if(o(e)){let a=n(e);if(a)return i?{card:a,files:i}:{card:a}}if(nt(e))return i?{card:e,files:i}:{card:e};throw new Error("Invalid message content \u2014 expected string or CardElement")}var C=class{constructor(t,i,o,n,a){this.conversationId=o;this.integrationIdentifier=n;this.poster=a;this.editedByHandler=!1;this.messageId=t,this.platformThreadId=i}async edit(t,i){this.editedByHandler=!0;let o=await this.poster.post({conversationId:this.conversationId,integrationIdentifier:this.integrationIdentifier,edit:{messageId:this.messageId,content:await jt(t,i==null?void 0:i.files)}});if(!o)throw new Error("Agent edit did not return a message handle");return this.messageId=o.messageId,this.platformThreadId=o.platformThreadId,this}async delete(){await this.poster.post({conversationId:this.conversationId,integrationIdentifier:this.integrationIdentifier,deleteMessages:[{messageId:this.messageId}]})}},Ut;Ut=it;var V=class{constructor(t,i,o){this[Ut]=!0;this._signals=[];this._toolResults=[];this._pendingToolApprovalRequest=null;this._pendingReactions=[];this._pendingDeletes=[];this._resolveSignal=null;var p,h;this.event=t.event,this.action=(p=t.action)!=null?p:null,this.message=t.message,this.reaction=t.reaction,this.conversation=t.conversation,this.subscriber=t.subscriber,this.history=t.history,this.platform=t.platform,this.platformContext=t.platformContext,this._replyUrl=t.replyUrl,this._conversationId=t.conversationId,this._integrationIdentifier=t.integrationIdentifier,this._secretKey=i,this._poster={post:l=>this._post(l)},this._toolApprovalConfig=o,this._metadataState={...(h=t.conversation.metadata)!=null?h:{}};let n=this;this.metadata={get(l){return n._metadataState[l]},set(l,d){n._metadataState[l]=d,n._signals.push({type:"metadata",action:"set",key:l,value:d})},delete(l){delete n._metadataState[l],n._signals.push({type:"metadata",action:"delete",key:l})},clear(){n._metadataState={},n._signals.push({type:"metadata",action:"clear"})},get current(){return{...n._metadataState}}};let a=l=>this._post({conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,typing:l}).then(()=>{}),c=(l=>a(l===void 0?{}:{status:l}));c.stop=()=>a("stop"),this.typing=c,this.toolApproval={request:async l=>(await at(this,l,this._toolApprovalConfig),new j)}}asMessageContext(){return this}async reply(t,i){let o=await jt(t,i==null?void 0:i.files),n={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,reply:o};this._drainSideEffects(n);let a=await this._post(n);if(!a)throw new Error("Agent reply did not return a message handle");return new C(a.messageId,a.platformThreadId,this._conversationId,this._integrationIdentifier,this._poster)}async replyApprovalCard(t){let i={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,reply:{toolApprovalCard:t}};this._drainSideEffects(i);let o=await this._post(i);if(!o)throw new Error("Agent approval card reply did not return a message handle");return new C(o.messageId,o.platformThreadId,this._conversationId,this._integrationIdentifier,this._poster)}createReplyHandle(t){return new C(t,"",this._conversationId,this._integrationIdentifier,this._poster)}resolve(t){this._resolveSignal={summary:t}}trigger(t,i){this._signals.push({...i,type:"trigger",workflowId:t})}emitToolApprovalRequest(t){if(this._pendingToolApprovalRequest)throw new Error("Only one tool approval request can be queued before the next reply");this._pendingToolApprovalRequest=t}emitToolResult(t){this._toolResults.push(t)}addReaction(t,i){this._pendingReactions.push({messageId:t,emojiName:i})}deleteMessage(t){this._pendingDeletes.push({messageId:t})}async flush(){if(!this._hasPendingSideEffects())return;let t={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier};this._drainSideEffects(t),await this._post(t)}_hasPendingSideEffects(){return!!(this._pendingToolApprovalRequest||this._signals.length||this._toolResults.length||this._resolveSignal||this._pendingReactions.length||this._pendingDeletes.length)}_drainSideEffects(t){this._pendingToolApprovalRequest&&(t.toolApprovalRequest=this._pendingToolApprovalRequest,this._pendingToolApprovalRequest=null),this._signals.length&&(t.signals=this._signals,this._signals=[]),this._toolResults.length&&(t.toolResults=this._toolResults,this._toolResults=[]),this._pendingReactions.length&&(t.addReactions=this._pendingReactions,this._pendingReactions=[]),this._pendingDeletes.length&&(t.deleteMessages=this._pendingDeletes,this._pendingDeletes=[]),this._resolveSignal&&(t.resolve=this._resolveSignal,this._resolveSignal=null)}async _post(t){let i=await fetch(this._replyUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${this._secretKey}`},body:JSON.stringify(t)});if(!i.ok){let n=await i.text().catch(()=>"");throw new F(i.status,n)}let o=await i.text().catch(()=>"");if(!o)return null;try{let n=JSON.parse(o),a=n&&typeof n=="object"&&"data"in n?n.data:n;if(a&&typeof a.messageId=="string"&&typeof a.platformThreadId=="string")return{messageId:a.messageId,platformThreadId:a.platformThreadId}}catch{}return null}};var Ui={type:"object",properties:{type:{enum:["regular"]},amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]},extendToSchedule:{type:"boolean"}},required:["amount","unit"],additionalProperties:!1},Li={type:"object",properties:{type:{enum:["timed"]},cron:{type:"string"},extendToSchedule:{type:"boolean"}},required:["cron"],additionalProperties:!1},Fi={type:"object",properties:{type:{enum:["dynamic"]},dynamicKey:{type:"string"},extendToSchedule:{type:"boolean"}},required:["dynamicKey"],additionalProperties:!1},ji={oneOf:[Ui,Li,Fi]},Yi={type:"object",properties:{duration:{type:"number"}},required:["duration"],additionalProperties:!1},Yt={output:ji,result:Yi};var Vi={type:"object",properties:{type:{enum:["regular"]},amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]},digestKey:{type:"string"},lookBackWindow:{type:"object",properties:{amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]}},required:["amount","unit"],additionalProperties:!1},extendToSchedule:{type:"boolean"}},required:["amount","unit"],additionalProperties:!1},qi={type:"object",properties:{type:{enum:["timed"]},cron:{type:"string"},digestKey:{type:"string"},extendToSchedule:{type:"boolean"}},required:["cron"],additionalProperties:!1},Bi={oneOf:[Vi,qi]},$i={type:"object",properties:{eventCount:{type:"number"},events:{type:"array",items:{type:"object",properties:{id:{type:"string"},time:{type:"string"},payload:{type:"object"}},required:["id","time","payload"],additionalProperties:!1}}},required:["events"],additionalProperties:!1},Vt={output:Bi,result:$i};var qt={output:{type:"object",properties:{type:{type:"string",enum:["fixed","dynamic"]},amount:{type:"number"},unit:{type:"string",enum:["minutes","hours","days"]},dynamicKey:{type:"string"},threshold:{type:"number"},throttleKey:{type:"string"}},required:["type"],additionalProperties:!1},result:{type:"object",properties:{throttled:{type:"boolean",description:"Whether the workflow execution was throttled"},executionCount:{type:"number",description:"Number of executions within the throttle window"},threshold:{type:"number",description:"The throttle threshold that was applied"},windowStart:{type:"string",format:"date-time",description:"Start time of the throttle window"}},required:["throttled"],additionalProperties:!1}};var Bt={delay:Yt,digest:Vt,throttle:qt};var Wi={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},Ji={type:"object",properties:{},required:[],additionalProperties:!1},$t={output:Wi,result:Ji};var Gi={type:"object",properties:{subject:{type:"string",minLength:1},body:{type:"string"},from:{type:"object",properties:{email:{type:"string"},name:{type:"string"}},additionalProperties:!1}},required:["subject","body"],additionalProperties:!1},zi={type:"object",properties:{},required:[],additionalProperties:!1},Wt={output:Gi,result:zi};var Xi="^(?!mailto:)(?:(https?):\\/\\/[^\\s/$.?#].[^\\s]*)|^(\\/[^\\s]*)$",Gt={type:"object",properties:{url:{type:"string",pattern:Xi},target:{type:"string",enum:["_self","_blank","_parent","_top","_unfencedTop"],default:"_blank"}},if:{properties:{url:{type:"string",pattern:"^/"}}},then:{properties:{target:{default:"_self"}}},else:{properties:{target:{default:"_blank"}}},required:["url"],additionalProperties:!1},Jt={type:"object",properties:{label:{type:"string"},redirect:Gt},required:["label"],additionalProperties:!1},Ki={type:"object",properties:{subject:{type:"string",minLength:1},body:{type:"string",minLength:1},avatar:{type:"string",format:"uri"},primaryAction:Jt,secondaryAction:Jt,data:{type:"object",additionalProperties:!0},redirect:Gt},anyOf:[{required:["subject"]},{required:["body"]}],additionalProperties:!1},Hi={type:"object",properties:{seen:{type:"boolean"},read:{type:"boolean"},lastSeenDate:{type:"string",format:"date-time",nullable:!0},lastReadDate:{type:"string",format:"date-time",nullable:!0}},required:["seen","read","lastSeenDate","lastReadDate"],additionalProperties:!1},zt={output:Ki,result:Hi};var Qi={type:"object",properties:{subject:{type:"string"},body:{type:"string"}},required:["subject","body"],additionalProperties:!1},Zi={type:"object",properties:{},required:[],additionalProperties:!1},Xt={output:Qi,result:Zi};var en={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},tn={type:"object",properties:{},required:[],additionalProperties:!1},Kt={output:en,result:tn};var Ht={chat:$t,sms:Kt,push:Xt,email:Wt,in_app:zt};var Qt=(l=>(l.PENDING="pending",l.QUEUED="queued",l.RUNNING="running",l.COMPLETED="completed",l.FAILED="failed",l.DELAYED="delayed",l.CANCELED="canceled",l.MERGED="merged",l.SKIPPED="skipped",l))(Qt||{});var Zt=(n=>(n.NONE="none",n.LOW="low",n.MEDIUM="medium",n.HIGH="high",n))(Zt||{});var ei=require("liquidjs");function nn(e){return Array.isArray(e)||typeof e=="object"&&e!==null?ti(e):typeof e=="string"?e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):e==null?"":String(e)}var ti=(e,t=0)=>Array.isArray(e)||typeof e=="object"&&e!==null?JSON.stringify(e,null,t).replace(/"/g,"'").replace(/\n/g,"\\n"):e==null?"":String(e);function ii(e){let t=new ei.Liquid({outputEscape:nn,...e});return t.registerFilter("json",(i,o)=>ti(i,o)),t.registerFilter("digest",Te),t.registerFilter("toSentence",Se),t.registerFilter("pluralize",we),t}0&&(module.exports={ActionStepEnum,AgentContextImpl,AgentEventEnum,BadRequestError,BridgeError,ChannelStepEnum,ConflictError,CronExpression,ErrorCodeEnum,ExecutionEventControlsInvalidError,ExecutionEventPayloadInvalidError,ExecutionProviderOutputInvalidError,ExecutionStateControlsInvalidError,ExecutionStateCorruptError,ExecutionStateOutputInvalidError,ExecutionStateResultInvalidError,FILTER_VALIDATORS,ForbiddenError,FrameworkError,GetActionEnum,HttpHeaderKeysEnum,HttpMethodEnum,HttpQueryKeysEnum,HttpStatusEnum,InvalidActionError,JobStatusEnum,MethodNotAllowedError,MissingSecretKeyError,NotFoundError,NovuApiEndpointsEnum,PlatformError,PostActionEnum,ProviderExecutionFailedError,ProviderNotFoundError,ResourceConflictError,ResourceEnum,ResourceExecutionFailed,ResourceNotFoundError,SIGNATURE_TIMESTAMP_TOLERANCE,SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES,ServerError,SeverityLevelEnum,SignatureExpiredError,SignatureInvalidError,SignatureMismatchError,SignatureNotFoundError,SignatureVersionInvalidError,SigningKeyNotFoundError,StepAlreadyExistsError,StepControlCompilationFailedError,StepExecutionFailedError,StepNotFoundError,UnauthorizedError,WorkflowAlreadyExistsError,WorkflowChannelEnum,WorkflowNotFoundError,WorkflowPayloadInvalidError,actionStepSchemas,buildApprovalActionId,channelStepSchemas,createLiquidEngine,digest,isFrameworkError,isNativeError,parseApprovalActionId,pluralize,toSentence,toSentenceArgsValidator});
1
+ "use strict";var sn=Object.create;var k=Object.defineProperty;var an=Object.getOwnPropertyDescriptor;var ln=Object.getOwnPropertyNames;var pn=Object.getPrototypeOf,cn=Object.prototype.hasOwnProperty;var De=(e,n,t)=>()=>{if(t)throw t[0];try{return e&&(n=e(e=0)),n}catch(i){throw t=[i],i}};var Me=(e,n)=>{for(var t in n)k(e,t,{get:n[t],enumerable:!0})},Ue=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of ln(n))!cn.call(e,o)&&o!==t&&k(e,o,{get:()=>n[o],enumerable:!(i=an(n,o))||i.enumerable});return e};var Le=(e,n,t)=>(t=e!=null?sn(pn(e)):{},Ue(n||!e||!e.__esModule?k(t,"default",{value:e,enumerable:!0}):t,e)),dn=e=>Ue(k({},"__esModule",{value:!0}),e);function bn(e={}){var n;return{type:"card",title:e.title,subtitle:e.subtitle,imageUrl:e.imageUrl,children:(n=e.children)!=null?n:[]}}function pt(e,n={}){return{type:"text",content:e,style:n.style}}function ct(e){return{type:"image",url:e.url,alt:e.alt}}function dt(){return{type:"divider"}}function ut(e){return{type:"section",children:e}}function mt(e){return{type:"actions",children:e}}function ht(e){return{type:"button",id:e.id,label:e.label,style:e.style,value:e.value,disabled:e.disabled,actionType:e.actionType,callbackUrl:e.callbackUrl}}function yt(e){return{type:"link-button",id:e.id,url:e.url,label:e.label,style:e.style}}function gt(e){return{type:"field",label:e.label,value:e.value}}function ft(e){return{type:"fields",children:e}}function bt(e){return{type:"table",headers:e.headers,rows:e.rows,align:e.align}}function Tt(e){return{type:"link",url:e.url,label:e.label}}function wn(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="modal"}function An(e){let n=e.filter(t=>typeof t=="object"&&t!==null&&"type"in t&&Tn.includes(t.type));return n.length<e.length&&console.warn("[chat] Modal contains unsupported child elements that were ignored"),n}function wt(e){var n;return{type:"modal",callbackId:e.callbackId,callbackUrl:e.callbackUrl,title:e.title,submitLabel:e.submitLabel,closeLabel:e.closeLabel,notifyOnClose:e.notifyOnClose,privateMetadata:e.privateMetadata,children:(n=e.children)!=null?n:[]}}function At(e){return{type:"text_input",id:e.id,label:e.label,placeholder:e.placeholder,initialValue:e.initialValue,multiline:e.multiline,optional:e.optional,maxLength:e.maxLength}}function St(e){if(!e.options||e.options.length===0)throw new Error("Select requires at least one option");return{type:"select",id:e.id,label:e.label,placeholder:e.placeholder,options:e.options,initialOption:e.initialOption,optional:e.optional}}function vt(e){return{type:"external_select",id:e.id,initialOption:e.initialOption,label:e.label,placeholder:e.placeholder,minQueryLength:e.minQueryLength,optional:e.optional}}function Rt(e){return{label:e.label,value:e.value,description:e.description}}function xt(e){if(!e.options||e.options.length===0)throw new Error("RadioSelect requires at least one option");return{type:"radio_select",id:e.id,label:e.label,options:e.options,initialOption:e.initialOption,optional:e.optional}}function Y(e){return typeof e=="object"&&e!==null&&e.$$typeof===_e}function Oe(e){if(e==null)return[];if(Array.isArray(e))return e.flatMap(Oe);if(Y(e)){let n=Ee(e);return n?[n]:[]}return typeof e=="object"&&"type"in e?[e]:typeof e=="string"||typeof e=="number"?[String(e)]:[]}function Sn(e){return!("id"in e||"url"in e||"label"in e)}function vn(e){return"id"in e&&typeof e.id=="string"&&!("url"in e)}function Rn(e){return"url"in e&&typeof e.url=="string"&&!("id"in e)}function Ie(e){return"url"in e&&typeof e.url=="string"&&!("id"in e)&&!("alt"in e)&&!("style"in e)}function xn(e){return"url"in e&&typeof e.url=="string"}function _n(e){return"label"in e&&"value"in e&&typeof e.label=="string"&&typeof e.value=="string"}function On(e){return!("id"in e||"url"in e||"callbackId"in e)&&("title"in e||"subtitle"in e||"imageUrl"in e)}function In(e){return"callbackId"in e&&"title"in e}function En(e){return"id"in e&&"label"in e&&!("options"in e)&&!("value"in e)}function _t(e){return"id"in e&&"label"in e&&!("value"in e)}function Pn(e){return"id"in e&&"label"in e&&!("value"in e)&&!("children"in e)}function Cn(e){return"label"in e&&"value"in e&&!("id"in e)}function Ee(e){var d,p,h,l;let{type:n,props:t,children:i}=e,o=Oe(i);if(n===pt){let c=Sn(t)?t:{style:void 0},A=o.length>0?o.map(String).join(""):String((d=c.children)!=null?d:"");return pt(A,{style:c.style})}if(n===ut)return ut(o);if(n===mt)return mt(o);if(n===ft)return ft(o);if(n===ht){if(!vn(t))throw new Error("Button requires an 'id' prop");let c=o.length>0?o.map(String).join(""):(p=t.label)!=null?p:"";return ht({id:t.id,label:c,style:t.style,value:t.value,actionType:t.actionType,callbackUrl:t.callbackUrl,disabled:t.disabled})}if(n===yt){if(!Rn(t))throw new Error("LinkButton requires a 'url' prop");let c=o.length>0?o.map(String).join(""):(h=t.label)!=null?h:"";return yt({id:t.id,url:t.url,label:c,style:t.style})}if(n===Tt){if(!Ie(t))throw new Error("CardLink requires a 'url' prop");let c=o.length>0?o.map(String).join(""):(l=t.label)!=null?l:"";return Tt({url:t.url,label:c})}if(n===ct){if(!xn(t))throw new Error("Image requires a 'url' prop");return ct({url:t.url,alt:t.alt})}if(n===gt){if(!_n(t))throw new Error("Field requires 'label' and 'value' props");return gt({label:t.label,value:t.value})}if(n===dt)return dt();if(n===wt){if(!In(t))throw new Error("Modal requires 'callbackId' and 'title' props");return wt({callbackId:t.callbackId,callbackUrl:t.callbackUrl,title:t.title,submitLabel:t.submitLabel,closeLabel:t.closeLabel,notifyOnClose:t.notifyOnClose,privateMetadata:t.privateMetadata,children:An(o)})}if(n===At){if(!En(t))throw new Error("TextInput requires 'id' and 'label' props");return At({id:t.id,label:t.label,placeholder:t.placeholder,initialValue:t.initialValue,multiline:t.multiline,optional:t.optional,maxLength:t.maxLength})}if(n===St){if(!_t(t))throw new Error("Select requires 'id' and 'label' props");return St({id:t.id,label:t.label,placeholder:t.placeholder,initialOption:t.initialOption,optional:t.optional,options:o})}if(n===vt){if(!Pn(t))throw new Error("ExternalSelect requires 'id' and 'label' props");return vt({id:t.id,initialOption:t.initialOption,label:t.label,placeholder:t.placeholder,minQueryLength:t.minQueryLength,optional:t.optional})}if(n===xt){if(!_t(t))throw new Error("RadioSelect requires 'id' and 'label' props");return xt({id:t.id,label:t.label,initialOption:t.initialOption,optional:t.optional,options:o})}if(n===Rt){if(!Cn(t))throw new Error("SelectOption requires 'label' and 'value' props");return Rt({label:t.label,value:t.value,description:t.description})}if(n===bt){let c=t;return bt({headers:c.headers,rows:c.rows})}let a=On(t)?t:{};return bn({title:a.title,subtitle:a.subtitle,imageUrl:a.imageUrl,children:o})}function Pe(e,n,t){let{children:i,...o}=n;return{$$typeof:_e,type:e,props:o,children:i!=null?[i]:[]}}function Ot(e,n,t){let{children:i,...o}=n,a;return Array.isArray(i)?a=i:i!=null?a=[i]:a=[],{$$typeof:_e,type:e,props:o,children:a}}function Et(e){return Oe(e.children)}function Pt(e){if(Y(e)){let n=Ee(e);if(n&&typeof n=="object"&&"type"in n&&n.type==="card")return n}return typeof e=="object"&&e!==null&&"type"in e&&e.type==="card"?e:null}function Ct(e){if(Y(e)){let n=Ee(e);if(n&&typeof n=="object"&&"type"in n&&n.type==="modal")return n}return wn(e)?e:null}function Nt(e){if(Y(e))return!0;if(typeof e=="object"&&e!==null&&"$$typeof"in e&&typeof e.$$typeof=="symbol"){let n=e.$$typeof.toString();return n.includes("react.element")||n.includes("react.transitional.element")}return!1}var Tn,_e,It,kt=De(()=>{"use strict";Tn=["text_input","select","external_select","radio_select","text","fields"];_e=Symbol.for("chat.jsx.element");It=Pe});var Dt={};Me(Dt,{Fragment:()=>Et,isCardLinkProps:()=>Ie,isJSX:()=>Nt,jsx:()=>Pe,jsxDEV:()=>It,jsxs:()=>Ot,toCardElement:()=>Pt,toModalElement:()=>Ct});var Mt=De(()=>{"use strict";kt()});var si={};Me(si,{ActionStepEnum:()=>$e,AgentContextImpl:()=>V,AgentEventEnum:()=>xe,BadRequestError:()=>y,BridgeError:()=>W,ChannelStepEnum:()=>Be,ConflictError:()=>I,CronExpression:()=>Ve,ErrorCodeEnum:()=>g,ExecutionEventControlsInvalidError:()=>z,ExecutionEventPayloadInvalidError:()=>G,ExecutionProviderOutputInvalidError:()=>Z,ExecutionStateControlsInvalidError:()=>X,ExecutionStateCorruptError:()=>J,ExecutionStateOutputInvalidError:()=>K,ExecutionStateResultInvalidError:()=>H,FILTER_VALIDATORS:()=>mn,ForbiddenError:()=>$,FrameworkError:()=>f,GetActionEnum:()=>je,HttpHeaderKeysEnum:()=>B,HttpMethodEnum:()=>D,HttpQueryKeysEnum:()=>qe,HttpStatusEnum:()=>x,InvalidActionError:()=>ie,JobStatusEnum:()=>Zt,MethodNotAllowedError:()=>ne,MissingSecretKeyError:()=>oe,NotFoundError:()=>O,NovuApiEndpointsEnum:()=>Ye,PlatformError:()=>re,PostActionEnum:()=>Fe,ProviderExecutionFailedError:()=>ae,ProviderNotFoundError:()=>se,ResourceConflictError:()=>v,ResourceEnum:()=>_,ResourceExecutionFailed:()=>R,ResourceNotFoundError:()=>T,SIGNATURE_TIMESTAMP_TOLERANCE:()=>un,SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES:()=>q,ServerError:()=>S,SeverityLevelEnum:()=>en,SignatureExpiredError:()=>de,SignatureInvalidError:()=>ce,SignatureMismatchError:()=>le,SignatureNotFoundError:()=>pe,SignatureVersionInvalidError:()=>me,SigningKeyNotFoundError:()=>ue,StepAlreadyExistsError:()=>ye,StepControlCompilationFailedError:()=>Q,StepExecutionFailedError:()=>ge,StepNotFoundError:()=>he,UnauthorizedError:()=>b,WorkflowAlreadyExistsError:()=>be,WorkflowChannelEnum:()=>We,WorkflowNotFoundError:()=>fe,WorkflowPayloadInvalidError:()=>ee,actionStepSchemas:()=>$t,buildApprovalActionId:()=>E,channelStepSchemas:()=>Qt,createLiquidEngine:()=>on,digest:()=>Te,isFrameworkError:()=>Ge,isNativeError:()=>Je,parseApprovalActionId:()=>at,pluralize:()=>we,toSentence:()=>Se,toSentenceArgsValidator:()=>ve});module.exports=dn(si);var Fe=(o=>(o.TRIGGER="trigger",o.EXECUTE="execute",o.PREVIEW="preview",o.AGENT_EVENT="agent-event",o))(Fe||{}),je=(i=>(i.DISCOVER="discover",i.HEALTH_CHECK="health-check",i.CODE="code",i))(je||{});var Ye=(t=>(t.SYNC="/v1/bridge/sync",t.DIFF="/v1/bridge/diff",t))(Ye||{}),q=5,un=3e5;var Ve=(s=>(s.EVERY_SECOND="* * * * * *",s.EVERY_5_SECONDS="*/5 * * * * *",s.EVERY_10_SECONDS="*/10 * * * * *",s.EVERY_30_SECONDS="*/30 * * * * *",s.EVERY_MINUTE="*/1 * * * *",s.EVERY_5_MINUTES="0 */5 * * * *",s.EVERY_10_MINUTES="0 */10 * * * *",s.EVERY_30_MINUTES="0 */30 * * * *",s.EVERY_HOUR="0 0-23/1 * * *",s.EVERY_2_HOURS="0 0-23/2 * * *",s.EVERY_3_HOURS="0 0-23/3 * * *",s.EVERY_4_HOURS="0 0-23/4 * * *",s.EVERY_5_HOURS="0 0-23/5 * * *",s.EVERY_6_HOURS="0 0-23/6 * * *",s.EVERY_7_HOURS="0 0-23/7 * * *",s.EVERY_8_HOURS="0 0-23/8 * * *",s.EVERY_9_HOURS="0 0-23/9 * * *",s.EVERY_10_HOURS="0 0-23/10 * * *",s.EVERY_11_HOURS="0 0-23/11 * * *",s.EVERY_12_HOURS="0 0-23/12 * * *",s.EVERY_DAY_AT_1AM="0 01 * * *",s.EVERY_DAY_AT_2AM="0 02 * * *",s.EVERY_DAY_AT_3AM="0 03 * * *",s.EVERY_DAY_AT_4AM="0 04 * * *",s.EVERY_DAY_AT_5AM="0 05 * * *",s.EVERY_DAY_AT_6AM="0 06 * * *",s.EVERY_DAY_AT_7AM="0 07 * * *",s.EVERY_DAY_AT_8AM="0 08 * * *",s.EVERY_DAY_AT_9AM="0 09 * * *",s.EVERY_DAY_AT_10AM="0 10 * * *",s.EVERY_DAY_AT_11AM="0 11 * * *",s.EVERY_DAY_AT_NOON="0 12 * * *",s.EVERY_DAY_AT_1PM="0 13 * * *",s.EVERY_DAY_AT_2PM="0 14 * * *",s.EVERY_DAY_AT_3PM="0 15 * * *",s.EVERY_DAY_AT_4PM="0 16 * * *",s.EVERY_DAY_AT_5PM="0 17 * * *",s.EVERY_DAY_AT_6PM="0 18 * * *",s.EVERY_DAY_AT_7PM="0 19 * * *",s.EVERY_DAY_AT_8PM="0 20 * * *",s.EVERY_DAY_AT_9PM="0 21 * * *",s.EVERY_DAY_AT_10PM="0 22 * * *",s.EVERY_DAY_AT_11PM="0 23 * * *",s.EVERY_DAY_AT_MIDNIGHT="0 0 * * *",s.EVERY_WEEK="0 0 * * 0",s.EVERY_WEEKDAY="0 0 * * 1-5",s.EVERY_WEEKEND="0 0 * * 6,0",s.EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT="0 0 1 * *",s.EVERY_1ST_DAY_OF_MONTH_AT_NOON="0 12 1 * *",s.EVERY_2ND_DAY_OF_MONTH_AT_10AM="0 10 2 * *",s.EVERY_2ND_HOUR="0 */2 * * *",s.EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM="0 1-23/2 * * *",s.EVERY_2ND_MONTH="0 0 1 */2 *",s.EVERY_QUARTER="0 0 1 */3 *",s.EVERY_6_MONTHS="0 0 1 */6 *",s.EVERY_YEAR="0 0 1 0 *",s.EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM="0 */30 9-17 * * *",s.EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM="0 */30 9-18 * * *",s.EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM="0 */30 10-19 * * *",s.MONDAY_TO_FRIDAY_AT_1AM="0 0 01 * * 1-5",s.MONDAY_TO_FRIDAY_AT_2AM="0 0 02 * * 1-5",s.MONDAY_TO_FRIDAY_AT_3AM="0 0 03 * * 1-5",s.MONDAY_TO_FRIDAY_AT_4AM="0 0 04 * * 1-5",s.MONDAY_TO_FRIDAY_AT_5AM="0 0 05 * * 1-5",s.MONDAY_TO_FRIDAY_AT_6AM="0 0 06 * * 1-5",s.MONDAY_TO_FRIDAY_AT_7AM="0 0 07 * * 1-5",s.MONDAY_TO_FRIDAY_AT_8AM="0 0 08 * * 1-5",s.MONDAY_TO_FRIDAY_AT_9AM="0 0 09 * * 1-5",s.MONDAY_TO_FRIDAY_AT_09_30AM="0 30 09 * * 1-5",s.MONDAY_TO_FRIDAY_AT_10AM="0 0 10 * * 1-5",s.MONDAY_TO_FRIDAY_AT_11AM="0 0 11 * * 1-5",s.MONDAY_TO_FRIDAY_AT_11_30AM="0 30 11 * * 1-5",s.MONDAY_TO_FRIDAY_AT_12PM="0 0 12 * * 1-5",s.MONDAY_TO_FRIDAY_AT_1PM="0 0 13 * * 1-5",s.MONDAY_TO_FRIDAY_AT_2PM="0 0 14 * * 1-5",s.MONDAY_TO_FRIDAY_AT_3PM="0 0 15 * * 1-5",s.MONDAY_TO_FRIDAY_AT_4PM="0 0 16 * * 1-5",s.MONDAY_TO_FRIDAY_AT_5PM="0 0 17 * * 1-5",s.MONDAY_TO_FRIDAY_AT_6PM="0 0 18 * * 1-5",s.MONDAY_TO_FRIDAY_AT_7PM="0 0 19 * * 1-5",s.MONDAY_TO_FRIDAY_AT_8PM="0 0 20 * * 1-5",s.MONDAY_TO_FRIDAY_AT_9PM="0 0 21 * * 1-5",s.MONDAY_TO_FRIDAY_AT_10PM="0 0 22 * * 1-5",s.MONDAY_TO_FRIDAY_AT_11PM="0 0 23 * * 1-5",s))(Ve||{});var g=(u=>(u.BRIDGE_ERROR="BridgeError",u.EXECUTION_EVENT_CONTROL_INVALID_ERROR="ExecutionEventControlInvalidError",u.EXECUTION_EVENT_PAYLOAD_INVALID_ERROR="ExecutionEventPayloadInvalidError",u.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",u.EXECUTION_STATE_CONTROL_INVALID_ERROR="ExecutionStateControlInvalidError",u.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",u.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",u.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",u.INVALID_ACTION_ERROR="InvalidActionError",u.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",u.MISSING_DEPENDENCY_ERROR="MissingDependencyError",u.MISSING_SECRET_KEY_ERROR="MissingSecretKeyError",u.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",u.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",u.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",u.SIGNATURE_INVALID_ERROR="SignatureInvalidError",u.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",u.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",u.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",u.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",u.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",u.STEP_CONTROL_COMPILATION_FAILED_ERROR="StepControlCompilationFailedError",u.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",u.STEP_NOT_FOUND_ERROR="StepNotFoundError",u.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",u.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",u.WORKFLOW_PAYLOAD_INVALID_ERROR="WorkflowPayloadInvalidError",u))(g||{});var B=(m=>(m.NOVU_SIGNATURE="novu-signature",m.NOVU_ANONYMOUS="novu-anonymous",m.NOVU_FRAMEWORK_SDK="novu-framework-sdk",m.NOVU_FRAMEWORK_SERVER="novu-framework-server",m.NOVU_FRAMEWORK_VERSION="novu-framework-version",m.USER_AGENT="user-agent",m.CONTENT_TYPE="content-type",m.ACCESS_CONTROL_ALLOW_ORIGIN="access-control-allow-origin",m.ACCESS_CONTROL_ALLOW_METHODS="access-control-allow-methods",m.ACCESS_CONTROL_ALLOW_HEADERS="access-control-allow-headers",m.ACCESS_CONTROL_MAX_AGE="access-control-max-age",m.ACCESS_CONTROL_ALLOW_PRIVATE_NETWORK="access-control-allow-private-network",m))(B||{});var D=(i=>(i.POST="POST",i.GET="GET",i.OPTIONS="OPTIONS",i))(D||{});var qe=(d=>(d.WORKFLOW_ID="workflowId",d.STEP_ID="stepId",d.ACTION="action",d.SOURCE="source",d.AGENT_ID="agentId",d.EVENT="event",d))(qe||{});var x=(r=>(r[r.CONTINUE=100]="CONTINUE",r[r.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",r[r.PROCESSING=102]="PROCESSING",r[r.EARLYHINTS=103]="EARLYHINTS",r[r.OK=200]="OK",r[r.CREATED=201]="CREATED",r[r.ACCEPTED=202]="ACCEPTED",r[r.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",r[r.NO_CONTENT=204]="NO_CONTENT",r[r.RESET_CONTENT=205]="RESET_CONTENT",r[r.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",r[r.AMBIGUOUS=300]="AMBIGUOUS",r[r.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",r[r.FOUND=302]="FOUND",r[r.SEE_OTHER=303]="SEE_OTHER",r[r.NOT_MODIFIED=304]="NOT_MODIFIED",r[r.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",r[r.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",r[r.BAD_REQUEST=400]="BAD_REQUEST",r[r.UNAUTHORIZED=401]="UNAUTHORIZED",r[r.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",r[r.FORBIDDEN=403]="FORBIDDEN",r[r.NOT_FOUND=404]="NOT_FOUND",r[r.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",r[r.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",r[r.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",r[r.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",r[r.CONFLICT=409]="CONFLICT",r[r.GONE=410]="GONE",r[r.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",r[r.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",r[r.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",r[r.URI_TOO_LONG=414]="URI_TOO_LONG",r[r.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",r[r.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",r[r.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",r[r.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",r[r.MISDIRECTED=421]="MISDIRECTED",r[r.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",r[r.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",r[r.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",r[r.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",r[r.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",r[r.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",r[r.BAD_GATEWAY=502]="BAD_GATEWAY",r[r.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",r[r.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",r[r.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",r))(x||{});var _=(i=>(i.WORKFLOW="workflow",i.PROVIDER="provider",i.STEP="step",i))(_||{});var Be=(a=>(a.EMAIL="email",a.SMS="sms",a.PUSH="push",a.CHAT="chat",a.IN_APP="in_app",a))(Be||{}),$e=(a=>(a.DIGEST="digest",a.DELAY="delay",a.THROTTLE="throttle",a.CUSTOM="custom",a.HTTP_REQUEST="http_request",a))($e||{});var We=(a=>(a.EMAIL="email",a.SMS="sms",a.PUSH="push",a.CHAT="chat",a.IN_APP="inApp",a))(We||{});var Je=e=>{var t,i;if(typeof e!="object"||e===null)return!1;let n=Object.getPrototypeOf(e);return(i=(t=n==null?void 0:n.constructor)==null?void 0:t.name.endsWith("Error"))!=null?i:!1},f=class extends Error{},O=class extends f{constructor(){super(...arguments);this.statusCode=404}},y=class extends f{constructor(){super(...arguments);this.statusCode=400}},b=class extends f{constructor(){super(...arguments);this.statusCode=401}},S=class extends f{constructor(n,{cause:t}={}){var i;Je(t)?(super(`${n}: ${t.message}`),this.data={stack:(i=t.stack)!=null?i:n}):(super(`${n}${t?`: ${JSON.stringify(t,null,2)}`:""}`),this.data={stack:n})}},I=class extends f{constructor(){super(...arguments);this.statusCode=409}},$=class extends f{constructor(){super(...arguments);this.statusCode=403}};var W=class extends S{constructor(t){super("Unknown BridgeError",{cause:t});this.statusCode=500;this.code="BridgeError"}};var J=class extends y{constructor(t,i){super(`Workflow with id: \`${t}\` has a corrupt state. Step with id: \`${i}\` does not exist. Please provide the missing state.`);this.code="ExecutionStateCorruptError";this.data={workflowId:t,stepId:i}}},G=class extends y{constructor(t,i){super(`Workflow with id: \`${t}\` has invalid \`payload\`. Please provide the correct event payload.`);this.code="ExecutionEventPayloadInvalidError";this.data=i}},z=class extends y{constructor(t,i){super(`Workflow with id: \`${t}\` has invalid \`controls\`. Please provide the correct event controls.`);this.code="ExecutionEventControlInvalidError";this.data=i}},X=class extends y{constructor(t,i,o){super(`Workflow with id: \`${t}\` has an invalid state. Step with id: \`${i}\` has invalid \`controls\`. Please provide the correct step controls.`);this.code="ExecutionStateControlInvalidError";this.data=o}},K=class extends y{constructor(t,i,o){super(`Workflow with id: \`${t}\` has an invalid state. Step with id: \`${i}\` has invalid output. Please provide the correct step output.`);this.code="ExecutionStateOutputInvalidError";this.data=o}},H=class extends y{constructor(t,i,o){super(`Workflow with id: \`${t}\` has an invalid state. Step with id: \`${i}\` has invalid result. Please provide the correct step result.`);this.code="ExecutionStateResultInvalidError";this.data=o}},Q=class extends y{constructor(t,i,o){super(`Workflow with id: \`${t}\` has invalid controls syntax in step with id: \`${i}\`. Please correct step control syntax.`);this.code="StepControlCompilationFailedError";this.data=o}},Z=class extends y{constructor(t,i,o,a){super(`Workflow with id: \`${t}\` has an invalid state. Step with id: \`${i}\` and provider with id: \`${o}\` has invalid output. Please provide the correct provider output.`);this.code="ExecutionProviderOutputInvalidError";this.data=a}},ee=class extends y{constructor(t,i){super(`Workflow with id: \`${t}\` has invalid \`payload\`. Please provide the correct payload.`);this.code="WorkflowPayloadInvalidError";this.data=i}};var Ge=e=>Object.values(g).includes(e==null?void 0:e.code);var te=e=>Object.values(e).map(n=>`\`${n}\``).join(", "),M=e=>e.replaceAll(/(\w)(\w*)/g,(n,t,i)=>t.toUpperCase()+i.toLowerCase()).replaceAll(/[\s-]+/g,"");var ne=class extends f{constructor(){super(...arguments);this.code="MethodNotAllowedError";this.statusCode=405;this.message=`Method not allowed. Please use one of ${te(D)}`}},ie=class extends y{constructor(t,i){super(`Invalid query string: \`action\`=\`${t}\`. Please use one of ${te(i)}`);this.code="InvalidActionError"}},oe=class extends y{constructor(){super("Missing secret key. Set the `NOVU_SECRET_KEY` environment variable or pass `secretKey` to the client options.");this.code="MissingSecretKeyError"}};var re=class extends Error{constructor(n,t,i){super(),this.data={message:i},this.statusCode=n,this.code=t}};var v=class extends I{constructor(n,t){super(`${M(n)} with id: \`${t}\` already exists. Please use a different id.`)}},T=class extends O{constructor(n,t){super(`${M(n)} with id: \`${t}\` does not exist. Please provide a valid id.`)}},R=class extends S{constructor(t,i,o,a){super(`Failed to ${o} ${M(t)} with id: \`${i}\``,{cause:a});this.statusCode=502}};var se=class extends T{constructor(t){super("provider",t);this.code="ProviderNotFoundError"}},ae=class extends R{constructor(t,i,o){super("provider",t,i,o);this.code="ProviderExecutionFailedError"}};var le=class extends b{constructor(){super("Signature does not match the expected signature. Please ensure the signature provided in the `novu-signature` header is correct and try again.");this.code="SignatureMismatchError"}},pe=class extends b{constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");this.code="SignatureNotFoundError"}},ce=class extends b{constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");this.code="SignatureInvalidError"}},de=class extends b{constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`novu-signature\` header`);this.code="SignatureExpiredError"}},ue=class extends b{constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");this.code="SigningKeyNotFoundError"}},me=class extends b{constructor(){super("Signature version is invalid. Please provide a signature version with version `v1` in the `novu-signature` header");this.code="SignatureVersionInvalidError"}};var he=class extends T{constructor(t){super("step",t);this.code="StepNotFoundError"}},ye=class extends v{constructor(t){super("step",t);this.code="StepAlreadyExistsError"}},ge=class extends R{constructor(t,i,o){super("step",t,i,o);this.code="StepExecutionFailedError"}};var fe=class extends T{constructor(t){super("workflow",t);this.code="WorkflowNotFoundError"}},be=class extends v{constructor(t){super("workflow",t);this.code="WorkflowAlreadyExistsError"}};function U(e,n){let t=n.split(".").reduce((i,o)=>{if(i&&typeof i=="object")return i[o]},e);if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(typeof t=="object"){let i=JSON.stringify(t);return i==="{}"?"":i}return""}function Te(e,n=2,t,i=", "){if(!Array.isArray(e)||e.length===0)return"";let o=t?e.map(p=>typeof p!="object"||!p?"":U(p,t)):e;if(o.length===1)return o[0];if(o.length===2)return`${o[0]} and ${o[1]}`;if(o.length===3&&n>=3)return`${o[0]}, ${i}${o[1]} and ${o[2]}`;let a=o.slice(0,n),d=o.length-n;return`${a.join(i)} and ${d} ${d===1?"other":"others"}`}var ze=Le(require("pluralize"),1);function we(e,n="",t="",i="true"){if(e==null)return"";let o=0;if(Array.isArray(e)?o=e.length:typeof e=="object"?o=Object.keys(e).length:typeof e=="string"?o=+e:typeof e=="number"?o=e:o=Number(e),Number.isNaN(o)&&(o=0),o<=0)return"";let a;return t?a=o===1?n:t:a=(0,ze.default)(n,o),i==="true"?`${o} ${a}`:a}var Ae=require("liquidjs"),Ke=Le(require("pluralize"),1),w=require("zod");var He="",Qe=2,Ze="other",et=", ",tt=" and ",nt=", and ",Xe={0:"keyPath",1:"limit",2:"overflowSuffix",3:"wordsConnector",4:"twoWordsConnector",5:"lastWordConnector"};function Se(e,n=He,t=Qe,i=Ze,o=et,a=tt,d=nt){if(!Array.isArray(e)||e.length===0)return"";let p=n?e.map(m=>typeof m!="object"||!m?"":U(m,n)):e,h=p.length;if(h===1)return p[0];if(h===2)return`${p[0]}${a}${p[1]}`;if(t>=h){let m=p.slice(0,h-1),ke=p[h-1];return`${m.join(o)}${d}${ke}`}let l=p.slice(0,t),c=h-t,A=t===1?a:d;return`${l.join(o)}${A}${c} ${(0,Ke.default)(i,c)}`}function ve(e={},...n){let{requireKeyPath:t=!1}=e,i=[];if(n.length<1)return i.push({message:"Expected at least 1 argument",begin:0,end:0,value:""}),i;let o=w.z.object({keyPath:t?w.z.string().min(1,"must be non-empty"):w.z.string().optional().default(He),limit:w.z.number().optional().default(Qe).refine(p=>p>=0,"must be greater than or equal to 0"),overflowSuffix:w.z.string().optional().default(Ze),wordsConnector:w.z.string().optional().default(et),twoWordsConnector:w.z.string().optional().default(tt),lastWordConnector:w.z.string().optional().default(nt)}),a={};n.forEach((p,h)=>{if(!Array.isArray(p)){let l=p.getText();(p.kind===Ae.TokenKind.Quoted||p.kind===Ae.TokenKind.Number)&&(l=p.content);let c=Xe[h];a[c]=l}});let d=o.safeParse(a);if(!d.success)for(let p of d.error.issues){let h="string";"type"in p&&(h=p.type);let l=p.path[0],c=Object.entries(Xe).find(([ke,rn])=>rn===l),A=c?parseInt(c[0],10):null,m=typeof A=="number"?n[A]:null;m&&!Array.isArray(m)&&i.push({message:`"toSentence" expects a ${h}${p.message?` that ${p.message}`:""} for argument "${l}"`,begin:m.begin,end:m.end,value:m.getText()})}return i}var mn={toSentence:ve};var hn={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 L(e){return typeof e=="string"&&e.trim()?e:!e||typeof e!="object"?null:L(e.message)}function yn(e){if(!e)return null;let n;try{n=JSON.parse(e)}catch{return null}if(!n||typeof n!="object")return null;let t=n,i=L(t.message);if(i)return i;let o=L(t.error);if(o)return o;let a=t.errors;return Array.isArray(a)?L(a[0]):null}function gn(e,n){var o;let t=(o=hn[e])!=null?o:e,i=yn(n);return i?`Delivery failed: ${t}: ${i}`:`Delivery failed: ${t}`}var Re=class extends Error{constructor(n,t){super(n),this.name="AgentError",this.cause=t==null?void 0:t.cause,this.delivery=t==null?void 0:t.delivery}},F=class extends Re{constructor(n,t){let i={statusCode:n,responseBody:t};super(gn(n,t),{delivery:i}),this.name="AgentDeliveryError",this.statusCode=n,this.responseBody=t}};var it=Symbol.for("novu.agent.runtimeContext");var xe=(o=>(o.ON_MESSAGE="onMessage",o.ON_ACTION="onAction",o.ON_RESOLVE="onResolve",o.ON_REACTION="onReaction",o))(xe||{}),j=class{constructor(){this.__novuPendingApproval=!0}};function ot(e){return"type"in e&&e.type==="card"}function rt(e){return typeof e=="object"&&e!==null&&e.type==="tool-approval-card"}var st="tool-approval";function fn(e){return e==="approve"||e==="deny"}function E(e,n){return`${st}:${e}:${n}`}function at(e){let[n,t,...i]=(e!=null?e:"").split(":"),o=i.join(":");return n!==st||!fn(t)||!o?null:{approved:t==="approve",approvalId:o}}async function lt(e,n,t,i){var l,c;let o=i!=null?i:n.id,a={approve:E("approve",o),deny:E("deny",o)},d=A=>({type:"tool-approval-card",...A}),p=(c=(l=t==null?void 0:t.renderApproval)==null?void 0:l.call(t,{toolCall:n,actionIds:a,approvalCard:d}))!=null?c:d(),h={approvalId:o,toolCallId:n.id,name:n.name,input:n.input};if(e.emitToolApprovalRequest(h),rt(p)){await e.replyApprovalCard(p);return}await e.reply(p)}var Nn=5*1024*1024,kn=5*1024*1024,Ut=32768,Dn=/^[A-Za-z0-9+/]*={0,2}$/;function N(e,n){return e.filename?`"${e.filename}"`:`at index ${n}`}function Ft(){return globalThis.Buffer}function Mn(e){var n,t,i;return(i=(t=(n=Ft())==null?void 0:n.isBuffer)==null?void 0:t.call(n,e))!=null?i:!1}function Un(e){return typeof Blob!="undefined"&&e instanceof Blob}function Ce(e){let n=Ft();if(n)return n.from(e).toString("base64");if(typeof btoa!="function")throw new Error("Unable to encode file data: base64 encoding is not available in this runtime.");let t="";for(let i=0;i<e.length;i+=Ut){let o=e.subarray(i,i+Ut);t+=String.fromCharCode(...o)}return btoa(t)}function jt(e){let n=e.replace(/\s/g,""),t=n.length%4;if(!n||t===1||!Dn.test(n))return null;let i=n.endsWith("==")?2:n.endsWith("=")?1:0;return Math.floor(n.length*3/4)-i}function P(e,n,t){if(e>Nn)throw new Error(`Invalid file ${N(n,t)}: inline data must be 5 MB or smaller. Use a publicly-accessible URL for larger files.`)}async function Ln(e,n,t){if(typeof e=="string"){let i=jt(e);if(i===null)throw new Error(`Invalid file ${N(n,t)}: data must be a base64-encoded string.`);return P(i,n,t),e}if(Mn(e))return P(e.byteLength,n,t),e.toString("base64");if(e instanceof Uint8Array)return P(e.byteLength,n,t),Ce(e);if(e instanceof ArrayBuffer)return P(e.byteLength,n,t),Ce(new Uint8Array(e));if(Un(e))return P(e.size,n,t),Ce(new Uint8Array(await e.arrayBuffer()));throw new Error(`Invalid file ${N(n,t)}: data must be a base64 string, Buffer, Uint8Array, ArrayBuffer, or Blob.`)}async function Fn(e){if(!(e!=null&&e.length))return;let n=[],t=0;for(let[i,o]of e.entries()){let a=o.data,d=o.url,p=a!=null,h=d!=null;if(p===h)throw new Error(`Invalid file ${N(o,i)}: provide exactly one of data or url.`);if(p){let l=await Ln(a,o,i),c=jt(l);if(t+=c!=null?c:0,t>kn)throw new Error("Invalid files: total inline data must be 5 MB or smaller. Use publicly-accessible URLs for larger files.");n.push({...o,data:l});continue}if(h&&typeof d!="string")throw new Error(`Invalid file ${N(o,i)}: url must be a string.`);n.push(o)}return n}async function Yt(e,n){let t=await Fn(n);if(typeof e=="string")return t?{markdown:e,files:t}:{markdown:e};let{isJSX:i,toCardElement:o}=await Promise.resolve().then(()=>(Mt(),Dt));if(i(e)){let a=o(e);if(a)return t?{card:a,files:t}:{card:a}}if(ot(e))return t?{card:e,files:t}:{card:e};throw new Error("Invalid message content \u2014 expected string or CardElement")}var C=class{constructor(n,t,i,o,a){this.conversationId=i;this.integrationIdentifier=o;this.poster=a;this.editedByHandler=!1;this.messageId=n,this.platformThreadId=t}async edit(n,t){this.editedByHandler=!0;let i=await this.poster.post({conversationId:this.conversationId,integrationIdentifier:this.integrationIdentifier,edit:{messageId:this.messageId,content:await Yt(n,t==null?void 0:t.files)}});if(!i)throw new Error("Agent edit did not return a message handle");return this.messageId=i.messageId,this.platformThreadId=i.platformThreadId,this}async delete(){await this.poster.post({conversationId:this.conversationId,integrationIdentifier:this.integrationIdentifier,deleteMessages:[{messageId:this.messageId}]})}},Lt;Lt=it;var V=class{constructor(n,t,i){this[Lt]=!0;this._signals=[];this._toolResults=[];this._pendingToolApprovalRequest=null;this._pendingReactions=[];this._pendingDeletes=[];this._resolveSignal=null;var p,h;this.event=n.event,this.action=(p=n.action)!=null?p:null,this.message=n.message,this.reaction=n.reaction,this.conversation=n.conversation,this.subscriber=n.subscriber,this.history=n.history,this.platform=n.platform,this.platformContext=n.platformContext,this._replyUrl=n.replyUrl,this._conversationId=n.conversationId,this._integrationIdentifier=n.integrationIdentifier,this._secretKey=t,this._poster={post:l=>this._post(l)},this._toolApprovalConfig=i,this._metadataState={...(h=n.conversation.metadata)!=null?h:{}};let o=this;this.metadata={get(l){return o._metadataState[l]},set(l,c){o._metadataState[l]=c,o._signals.push({type:"metadata",action:"set",key:l,value:c})},delete(l){delete o._metadataState[l],o._signals.push({type:"metadata",action:"delete",key:l})},clear(){o._metadataState={},o._signals.push({type:"metadata",action:"clear"})},get current(){return{...o._metadataState}}};let a=l=>this._post({conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,typing:l}).then(()=>{}),d=(l=>a(l===void 0?{}:{status:l}));d.stop=()=>a("stop"),this.typing=d,this.toolApproval={request:async l=>(await lt(this,l,this._toolApprovalConfig),new j)}}asMessageContext(){return this}async reply(n,t){let i=await Yt(n,t==null?void 0:t.files),o={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,reply:i};this._drainSideEffects(o);let a=await this._post(o);if(!a)throw new Error("Agent reply did not return a message handle");return new C(a.messageId,a.platformThreadId,this._conversationId,this._integrationIdentifier,this._poster)}async replyApprovalCard(n){let t={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,reply:{toolApprovalCard:n}};this._drainSideEffects(t);let i=await this._post(t);if(!i)throw new Error("Agent approval card reply did not return a message handle");return new C(i.messageId,i.platformThreadId,this._conversationId,this._integrationIdentifier,this._poster)}createReplyHandle(n){return new C(n,"",this._conversationId,this._integrationIdentifier,this._poster)}resolve(n){this._resolveSignal={summary:n}}trigger(n,t){this._signals.push({...t,type:"trigger",workflowId:n})}emitToolApprovalRequest(n){if(this._pendingToolApprovalRequest)throw new Error("Only one tool approval request can be queued before the next reply");this._pendingToolApprovalRequest=n}emitToolResult(n){this._toolResults.push(n)}addReaction(n,t){this._pendingReactions.push({messageId:n,emojiName:t})}deleteMessage(n){this._pendingDeletes.push({messageId:n})}async reportTurnError(){try{await this._post({conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier,error:!0})}catch(n){console.error("[agent] Failed to report turn error:",n)}}async flush(){if(!this._hasPendingSideEffects())return;let n={conversationId:this._conversationId,integrationIdentifier:this._integrationIdentifier};this._drainSideEffects(n),await this._post(n)}_hasPendingSideEffects(){return!!(this._pendingToolApprovalRequest||this._signals.length||this._toolResults.length||this._resolveSignal||this._pendingReactions.length||this._pendingDeletes.length)}_drainSideEffects(n){this._pendingToolApprovalRequest&&(n.toolApprovalRequest=this._pendingToolApprovalRequest,this._pendingToolApprovalRequest=null),this._signals.length&&(n.signals=this._signals,this._signals=[]),this._toolResults.length&&(n.toolResults=this._toolResults,this._toolResults=[]),this._pendingReactions.length&&(n.addReactions=this._pendingReactions,this._pendingReactions=[]),this._pendingDeletes.length&&(n.deleteMessages=this._pendingDeletes,this._pendingDeletes=[]),this._resolveSignal&&(n.resolve=this._resolveSignal,this._resolveSignal=null)}async _post(n){let t=await fetch(this._replyUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${this._secretKey}`},body:JSON.stringify(n)});if(!t.ok){let o=await t.text().catch(()=>"");throw new F(t.status,o)}let i=await t.text().catch(()=>"");if(!i)return null;try{let o=JSON.parse(i),a=o&&typeof o=="object"&&"data"in o?o.data:o;if(a&&typeof a.messageId=="string"&&typeof a.platformThreadId=="string")return{messageId:a.messageId,platformThreadId:a.platformThreadId}}catch{}return null}};var jn={type:"object",properties:{type:{enum:["regular"]},amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]},extendToSchedule:{type:"boolean"}},required:["amount","unit"],additionalProperties:!1},Yn={type:"object",properties:{type:{enum:["timed"]},cron:{type:"string"},extendToSchedule:{type:"boolean"}},required:["cron"],additionalProperties:!1},Vn={type:"object",properties:{type:{enum:["dynamic"]},dynamicKey:{type:"string"},extendToSchedule:{type:"boolean"}},required:["dynamicKey"],additionalProperties:!1},qn={oneOf:[jn,Yn,Vn]},Bn={type:"object",properties:{duration:{type:"number"}},required:["duration"],additionalProperties:!1},Vt={output:qn,result:Bn};var $n={type:"object",properties:{type:{enum:["regular"]},amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]},digestKey:{type:"string"},lookBackWindow:{type:"object",properties:{amount:{type:"number"},unit:{type:"string",enum:["seconds","minutes","hours","days","weeks","months"]}},required:["amount","unit"],additionalProperties:!1},extendToSchedule:{type:"boolean"}},required:["amount","unit"],additionalProperties:!1},Wn={type:"object",properties:{type:{enum:["timed"]},cron:{type:"string"},digestKey:{type:"string"},extendToSchedule:{type:"boolean"}},required:["cron"],additionalProperties:!1},Jn={oneOf:[$n,Wn]},Gn={type:"object",properties:{eventCount:{type:"number"},events:{type:"array",items:{type:"object",properties:{id:{type:"string"},time:{type:"string"},payload:{type:"object"}},required:["id","time","payload"],additionalProperties:!1}}},required:["events"],additionalProperties:!1},qt={output:Jn,result:Gn};var Bt={output:{type:"object",properties:{type:{type:"string",enum:["fixed","dynamic"]},amount:{type:"number"},unit:{type:"string",enum:["minutes","hours","days"]},dynamicKey:{type:"string"},threshold:{type:"number"},throttleKey:{type:"string"}},required:["type"],additionalProperties:!1},result:{type:"object",properties:{throttled:{type:"boolean",description:"Whether the workflow execution was throttled"},executionCount:{type:"number",description:"Number of executions within the throttle window"},threshold:{type:"number",description:"The throttle threshold that was applied"},windowStart:{type:"string",format:"date-time",description:"Start time of the throttle window"}},required:["throttled"],additionalProperties:!1}};var $t={delay:Vt,digest:qt,throttle:Bt};var zn={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},Xn={type:"object",properties:{},required:[],additionalProperties:!1},Wt={output:zn,result:Xn};var Kn={type:"object",properties:{subject:{type:"string",minLength:1},body:{type:"string"},from:{type:"object",properties:{email:{type:"string"},name:{type:"string"}},additionalProperties:!1}},required:["subject","body"],additionalProperties:!1},Hn={type:"object",properties:{},required:[],additionalProperties:!1},Jt={output:Kn,result:Hn};var Qn="^(?!mailto:)(?:(https?):\\/\\/[^\\s/$.?#].[^\\s]*)|^(\\/[^\\s]*)$",zt={type:"object",properties:{url:{type:"string",pattern:Qn},target:{type:"string",enum:["_self","_blank","_parent","_top","_unfencedTop"],default:"_blank"}},if:{properties:{url:{type:"string",pattern:"^/"}}},then:{properties:{target:{default:"_self"}}},else:{properties:{target:{default:"_blank"}}},required:["url"],additionalProperties:!1},Gt={type:"object",properties:{label:{type:"string"},redirect:zt},required:["label"],additionalProperties:!1},Zn={type:"object",properties:{subject:{type:"string",minLength:1},body:{type:"string",minLength:1},avatar:{type:"string",format:"uri"},primaryAction:Gt,secondaryAction:Gt,data:{type:"object",additionalProperties:!0},redirect:zt},anyOf:[{required:["subject"]},{required:["body"]}],additionalProperties:!1},ei={type:"object",properties:{seen:{type:"boolean"},read:{type:"boolean"},lastSeenDate:{type:"string",format:"date-time",nullable:!0},lastReadDate:{type:"string",format:"date-time",nullable:!0}},required:["seen","read","lastSeenDate","lastReadDate"],additionalProperties:!1},Xt={output:Zn,result:ei};var ti={type:"object",properties:{subject:{type:"string"},body:{type:"string"}},required:["subject","body"],additionalProperties:!1},ni={type:"object",properties:{},required:[],additionalProperties:!1},Kt={output:ti,result:ni};var ii={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},oi={type:"object",properties:{},required:[],additionalProperties:!1},Ht={output:ii,result:oi};var Qt={chat:Wt,sms:Ht,push:Kt,email:Jt,in_app:Xt};var Zt=(l=>(l.PENDING="pending",l.QUEUED="queued",l.RUNNING="running",l.COMPLETED="completed",l.FAILED="failed",l.DELAYED="delayed",l.CANCELED="canceled",l.MERGED="merged",l.SKIPPED="skipped",l))(Zt||{});var en=(o=>(o.NONE="none",o.LOW="low",o.MEDIUM="medium",o.HIGH="high",o))(en||{});var tn=require("liquidjs");function ri(e){return Array.isArray(e)||typeof e=="object"&&e!==null?nn(e):typeof e=="string"?e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):e==null?"":String(e)}var nn=(e,n=0)=>Array.isArray(e)||typeof e=="object"&&e!==null?JSON.stringify(e,null,n).replace(/"/g,"'").replace(/\n/g,"\\n"):e==null?"":String(e);function on(e){let n=new tn.Liquid({outputEscape:ri,...e});return n.registerFilter("json",(t,i)=>nn(t,i)),n.registerFilter("digest",Te),n.registerFilter("toSentence",Se),n.registerFilter("pluralize",we),n}0&&(module.exports={ActionStepEnum,AgentContextImpl,AgentEventEnum,BadRequestError,BridgeError,ChannelStepEnum,ConflictError,CronExpression,ErrorCodeEnum,ExecutionEventControlsInvalidError,ExecutionEventPayloadInvalidError,ExecutionProviderOutputInvalidError,ExecutionStateControlsInvalidError,ExecutionStateCorruptError,ExecutionStateOutputInvalidError,ExecutionStateResultInvalidError,FILTER_VALIDATORS,ForbiddenError,FrameworkError,GetActionEnum,HttpHeaderKeysEnum,HttpMethodEnum,HttpQueryKeysEnum,HttpStatusEnum,InvalidActionError,JobStatusEnum,MethodNotAllowedError,MissingSecretKeyError,NotFoundError,NovuApiEndpointsEnum,PlatformError,PostActionEnum,ProviderExecutionFailedError,ProviderNotFoundError,ResourceConflictError,ResourceEnum,ResourceExecutionFailed,ResourceNotFoundError,SIGNATURE_TIMESTAMP_TOLERANCE,SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES,ServerError,SeverityLevelEnum,SignatureExpiredError,SignatureInvalidError,SignatureMismatchError,SignatureNotFoundError,SignatureVersionInvalidError,SigningKeyNotFoundError,StepAlreadyExistsError,StepControlCompilationFailedError,StepExecutionFailedError,StepNotFoundError,UnauthorizedError,WorkflowAlreadyExistsError,WorkflowChannelEnum,WorkflowNotFoundError,WorkflowPayloadInvalidError,actionStepSchemas,buildApprovalActionId,channelStepSchemas,createLiquidEngine,digest,isFrameworkError,isNativeError,parseApprovalActionId,pluralize,toSentence,toSentenceArgsValidator});
@@ -1,10 +1,10 @@
1
- import { P as PostActionEnum } from '../health-check.types-CkUmYLNG.cjs';
2
- export { b as CancelEventTriggerResponse, c as ChannelPreference, C as ClientOptions, d as CodeResult, a as CronExpression, D as DiscoverAgentOutput, e as DiscoverOutput, f as DiscoverProviderOutput, g as DiscoverStepOutput, h as DiscoverWorkflowOutput, i as Event, j as EventTriggerParams, k as EventTriggerResponse, l as EventTriggerResult, m as Execute, E as ExecuteInput, n as ExecuteOutput, o as ExecuteOutputMetadata, p as ExecuteOutputOptions, G as GetActionEnum, H as HealthCheck, L as Logger, S as SeverityLevelEnum, q as State, r as StepType, W as Workflow, s as WorkflowChannelEnum, t as WorkflowOptions, u as WorkflowPreference, v as WorkflowPreferences } from '../health-check.types-CkUmYLNG.cjs';
3
- export { e as ActionStep, A as ActionStepEnum, f as ChannelStep, c as ChannelStepEnum, g as ChatOutput, h as ChatOutputUnvalidated, i as ChatResult, a as ContextPayload, C as ContextResolved, j as ContextValue, k as CustomStep, D as DelayDynamicOutput, l as DelayDynamicOutputUnvalidated, m as DelayOutput, n as DelayOutputUnvalidated, o as DelayRegularOutput, q as DelayRegularOutputUnvalidated, r as DelayResult, s as DelayTimedOutput, t as DelayTimedOutputUnvalidated, u as DigestOutput, v as DigestOutputUnvalidated, w as DigestRegularOutput, x as DigestRegularOutputUnvalidated, y as DigestResult, z as DigestTimedOutput, B as DigestTimedOutputUnvalidated, F as EmailOutput, G as EmailOutputUnvalidated, H as EmailResult, E as EnvironmentSystemVariables, I as InAppOutput, J as InAppOutputUnvalidated, K as InAppResult, L as JobStatusEnum, P as PushOutput, M as PushOutputUnvalidated, N as PushResult, O as Skip, Q as SmsOutput, R as SmsOutputUnvalidated, T as SmsResult, b as Step, U as StepContext, d as StepOptions, V as StepOutput, S as Subscriber, X as ThrottleOutput, Y as ThrottleOutputUnvalidated, Z as ThrottleResult, _ as actionStepSchemas, $ as channelStepSchemas } from '../subscriber.types-DxMMRBIi.cjs';
1
+ import { P as PostActionEnum } from '../health-check.types-B9FbzRbm.cjs';
2
+ export { b as CancelEventTriggerResponse, c as ChannelPreference, C as ClientOptions, d as CodeResult, a as CronExpression, D as DiscoverAgentOutput, e as DiscoverOutput, f as DiscoverProviderOutput, g as DiscoverStepOutput, h as DiscoverWorkflowOutput, i as Event, j as EventTriggerParams, k as EventTriggerResponse, l as EventTriggerResult, m as Execute, E as ExecuteInput, n as ExecuteOutput, o as ExecuteOutputMetadata, p as ExecuteOutputOptions, G as GetActionEnum, H as HealthCheck, L as Logger, S as SeverityLevelEnum, q as State, r as StepType, W as Workflow, s as WorkflowChannelEnum, t as WorkflowOptions, u as WorkflowPreference, v as WorkflowPreferences } from '../health-check.types-B9FbzRbm.cjs';
3
+ export { e as ActionStep, A as ActionStepEnum, f as ChannelStep, c as ChannelStepEnum, g as ChatOutput, h as ChatOutputUnvalidated, i as ChatResult, a as ContextPayload, C as ContextResolved, j as ContextValue, k as CustomStep, D as DelayDynamicOutput, l as DelayDynamicOutputUnvalidated, m as DelayOutput, n as DelayOutputUnvalidated, o as DelayRegularOutput, q as DelayRegularOutputUnvalidated, r as DelayResult, s as DelayTimedOutput, t as DelayTimedOutputUnvalidated, u as DigestOutput, v as DigestOutputUnvalidated, w as DigestRegularOutput, x as DigestRegularOutputUnvalidated, y as DigestResult, z as DigestTimedOutput, B as DigestTimedOutputUnvalidated, F as EmailOutput, G as EmailOutputUnvalidated, H as EmailResult, E as EnvironmentSystemVariables, I as InAppOutput, J as InAppOutputUnvalidated, K as InAppResult, L as JobStatusEnum, P as PushOutput, M as PushOutputUnvalidated, N as PushResult, O as Skip, Q as SmsOutput, R as SmsOutputUnvalidated, T as SmsResult, b as Step, U as StepContext, d as StepOptions, V as StepOutput, S as Subscriber, X as ThrottleOutput, Y as ThrottleOutputUnvalidated, Z as ThrottleResult, _ as actionStepSchemas, $ as channelStepSchemas } from '../subscriber.types-DubxcL8q.cjs';
4
4
  import { Filter, LiquidOptions, Liquid } from 'liquidjs';
5
5
  import { Emoji } from 'chat';
6
- import { f as AgentHandlerContext, w as ToolResult, x as ToolApprovalRequestPayload, T as ToolApprovalCard, R as ReplyHandle, k as AgentMessageContext, y as AgentEventEnum, a as AgentAction, i as AgentMessage, m as AgentReaction, e as AgentConversation, p as AgentSubscriber, h as AgentHistoryEntry, l as AgentPlatformContext, z as TypingControl, B as ToolApprovalControl, C as AgentBridgeRequest, r as ToolApprovalConfig, M as MessageContent, F as FileRef, D as AgentReplyPayload, S as SentMessageInfo, t as TriggerRecipientsPayload } from '../agent.types-DdgaVUb7.cjs';
7
- export { E as DeleteMessagePayload, G as EditPayload, H as MetadataSignal, P as ParsedApprovalAction, J as ReplyContent, K as Signal, L as TriggerSignal, N as buildApprovalActionId, O as parseApprovalActionId } from '../agent.types-DdgaVUb7.cjs';
6
+ import { h as AgentHandlerContext, z as ToolResult, B as ToolApprovalRequestPayload, T as ToolApprovalCard, R as ReplyHandle, m as AgentMessageContext, C as AgentEventEnum, a as AgentAction, k as AgentMessage, o as AgentReaction, e as AgentConversation, r as AgentSubscriber, j as AgentHistoryEntry, n as AgentPlatformContext, D as TypingControl, E as ToolApprovalControl, G as AgentBridgeRequest, t as ToolApprovalConfig, M as MessageContent, F as FileRef, H as AgentReplyPayload, S as SentMessageInfo, w as TriggerRecipientsPayload } from '../agent.types-Dqm2VBTO.cjs';
7
+ export { J as DeleteMessagePayload, K as EditPayload, L as MetadataSignal, P as ParsedApprovalAction, N as ReplyContent, O as Signal, Q as TriggerSignal, U as buildApprovalActionId, V as parseApprovalActionId } from '../agent.types-Dqm2VBTO.cjs';
8
8
  export { a as FromSchema, F as FromSchemaUnvalidated, J as JsonSchema, S as Schema, Z as ZodSchema, b as ZodSchemaMinimal } from '../base.schema.types-BApIn9jr.cjs';
9
9
  export { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.cjs';
10
10
  export { A as Awaitable, C as ConditionalPartial, D as DeepPartial, b as DeepRequired, E as Either, I as Indexable, c as PickOptional, d as PickOptionalKeys, e as PickRequired, P as PickRequiredKeys, a as Prettify } from '../util.types-DaFfsxgy.cjs';
@@ -500,6 +500,8 @@ declare class AgentContextImpl implements AgentRuntimeContext {
500
500
  emitToolResult(result: ToolResult): void;
501
501
  addReaction(messageId: string, emojiName: Emoji): void;
502
502
  deleteMessage(messageId: string): void;
503
+ /** Best-effort failure report to Novu. Never throws. */
504
+ reportTurnError(): Promise<void>;
503
505
  /**
504
506
  * Flush any remaining signals that weren't sent with reply().
505
507
  * Called internally after onResolve returns.
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var W=(e,t)=>{for(var o in t)v(e,o,{get:t[o],enumerable:!0})},Z=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Q(t))!K.call(e,a)&&a!==o&&v(e,a,{get:()=>t[a],enumerable:!(n=G(t,a))||n.enumerable});return e};var ee=e=>Z(v({},"__esModule",{value:!0}),e);var he={};W(he,{NovuToolApprovalRequired:()=>g,agent:()=>J,toLangChainMessages:()=>m});module.exports=ee(he);var d=require("@langchain/core/messages");var c=require("@langchain/core/messages"),h="tool_approval_request",E="tool_approval_decision",N="tool_result",te=JSON.stringify({type:"execution-denied"});function T(e){var o;let t=e.toolData;if(!(!t||typeof t.approvalId!="string"||typeof t.toolCallId!="string"))return{approvalId:t.approvalId,toolCallId:t.toolCallId,name:(o=t.toolName)!=null?o:"tool",input:t.input}}function P(e){let t=e.toolData;if(!(!t||typeof t.approvalId!="string"||typeof t.approved!="boolean"))return{approvalId:t.approvalId,approved:t.approved}}function L(e){let t=e.toolData;if(!(!t||typeof t.toolCallId!="string"))return{toolCallId:t.toolCallId,toolName:t.toolName,output:t.output}}function S(e,t){let o=new Set,n=new Map,a=new Map;for(let r of e)if(r.type===h){let s=T(r);s&&a.set(s.approvalId,s.toolCallId)}else if(r.type===E){let s=P(r);s&&!s.approved&&o.add(s.approvalId)}else if(r.type===N){let s=L(r);s&&n.set(s.toolCallId,s)}if(t)for(let[r,s]of t)n.set(r,s);return{deniedApprovalIds:o,toolResults:n,approvalIdToToolCallId:a}}function oe(e,t){return t.deniedApprovalIds.has(e.approvalId)?"denied":t.toolResults.has(e.toolCallId)?"resolved":"in-flight"}function M(e){var t;return new c.AIMessage({content:"",tool_calls:[{id:e.toolCallId,name:e.name,args:(t=e.input)!=null?t:{},type:"tool_call"}]})}function ne(e){return typeof e=="string"?e:JSON.stringify(e)}function ae(e){var t;return new c.ToolMessage({content:ne(e.output),tool_call_id:e.toolCallId,name:(t=e.toolName)!=null?t:"tool"})}function re(e){return new c.ToolMessage({content:te,tool_call_id:e.toolCallId,name:e.name,status:"error"})}function H(e,t){let o=T(e);if(!o)return[];let n=oe(o,t);switch(n){case"denied":return[M(o),re(o)];case"resolved":{let a=t.toolResults.get(o.toolCallId);return a?[M(o),ae(a)]:[]}case"in-flight":return[];default:return n}}function _(e){let t=new Set,o=new Set,n=[];for(let a of e)if(a.type===h){let r=T(a);r&&n.push({approvalId:r.approvalId,toolCallId:r.toolCallId,toolName:r.name,input:r.input})}else if(a.type===E){let r=P(a);r!=null&&r.approved&&t.add(r.approvalId)}else if(a.type===N){let r=L(a);r&&o.add(r.toolCallId)}return n.filter(a=>t.has(a.approvalId)&&!o.has(a.toolCallId)).map(({toolCallId:a,toolName:r,input:s})=>({toolCallId:a,toolName:r,input:s}))}var se="message",le="tool_approval_request";function k(e){return e==="agent"||e==="assistant"}function ie(e){let t=new Set;for(let o of e)!k(o.role)&&o.role!=="system"&&o.senderName&&t.add(o.senderName);return t.size}function pe(e,t){if(!e.content.trim())return;if(k(e.role))return new d.AIMessage(e.content);let n=t&&e.senderName?`${e.senderName}: ${e.content}`:e.content;return new d.HumanMessage(n)}function ue(e,t,o){switch(e.type){case se:{let n=pe(e,t);return n?[n]:[]}case le:return H(e,o);default:return[]}}function m(e,t,o){let n=ie(e)>1,a=S(e,o),r=e.flatMap(s=>ue(s,n,a));return t?[new d.SystemMessage(t),...r]:r}var de=Symbol.for("novu.agent.runtimeContext");function ge(e){return e[de]===!0}function y(e){if(!ge(e))throw new Error("Agent context must be created by Novu dispatch");return e}var f=require("@langchain/core/messages"),Y=require("langchain");function q(e){return"type"in e&&e.type==="card"}function b(e){return typeof e=="object"&&e!==null&&e.type==="tool-approval-card"}var B=require("@langchain/core/messages"),D=require("langchain");var ce="tool-approval";function R(e,t){return`${ce}:${e}:${t}`}async function O(e,t,o,n){var p,u;let a=n!=null?n:t.id,r={approve:R("approve",a),deny:R("deny",a)},s=F=>({type:"tool-approval-card",...F}),l=(u=(p=o==null?void 0:o.renderApproval)==null?void 0:p.call(o,{toolCall:t,actionIds:r,approvalCard:s}))!=null?u:s(),i={approvalId:a,toolCallId:t.id,name:t.name,input:t.input};if(e.emitToolApprovalRequest(i),b(l)){await e.replyApprovalCard(l);return}await e.reply(l)}var g=class extends Error{constructor(t){super(`Tool "${t.toolName}" requires approval`),this.name="NovuToolApprovalRequired",this.toolCallId=t.toolCallId,this.toolName=t.toolName,this.input=t.input}},fe=10;function U(e){let t=e;for(let o=0;o<fe&&t!=null;o+=1){if(t instanceof g)return t;t=t.cause}}function j(e){return(0,D.createMiddleware)({name:"novu-tool-approval",wrapToolCall:async(t,o)=>{let{id:n,name:a,args:r}=t.toolCall,s=r!=null?r:{};if(e({id:n,name:a,args:s}))throw new g({toolCallId:n!=null?n:a,toolName:a,input:s});return o(t)}})}async function $(e,t,o){let n={id:t.toolCallId,name:t.toolName,input:t.input};await O(e,n,o)}function me(e){return(0,B.isBaseMessage)(e)?e.content:e}function ye(e){let t=new Map;for(let o of e!=null?e:[])t.set(o.name,o);return t}async function V(e,t){var r;let o=_(t.history),n=new Map;if(o.length===0)return n;let a=ye(e);for(let s of o){let l=a.get(s.toolName);if(!l)continue;let i=me(await l.invoke((r=s.input)!=null?r:{}));n.set(s.toolCallId,{toolCallId:s.toolCallId,toolName:s.toolName,output:i}),t.emitToolResult({toolCallId:s.toolCallId,toolName:s.toolName,output:i,preview:`Tool "${s.toolName}" result`})}return n}var X=require("@langchain/core/messages");function Ae(e){var o;let t=new Set;for(let n of e.history)n.type==="tool_approval_request"&&((o=n.toolData)!=null&&o.toolCallId)&&t.add(n.toolData.toolCallId);return t}function Ce(e,t){var n;let o=new Set(t);for(let a of e.history)a.type==="tool_result"&&((n=a.toolData)!=null&&n.toolCallId)&&o.add(a.toolData.toolCallId);return o}function ve(e){return typeof e=="string"?e:JSON.stringify(e)}function I(e,t,o=new Set){var r;let n=Ae(t);if(n.size===0)return;let a=Ce(t,o);for(let s of e){if(!(0,X.isToolMessage)(s))continue;let l=s.tool_call_id;!n.has(l)||a.has(l)||(a.add(l),t.emitToolResult({toolCallId:l,toolName:s.name,output:ve(s.content),preview:`Tool "${(r=s.name)!=null?r:l}" result`}))}}function z(e){if(typeof e!="object"||e===null)return!1;let t=e.model;return typeof t=="string"||typeof t=="object"&&t!==null}function Te(e){return typeof e=="object"&&e!==null&&Array.isArray(e.messages)}function A(e){return typeof e!="object"||e===null||q(e)?!1:(0,f.isBaseMessage)(e)||z(e)||Te(e)}function Re(e){return typeof e=="string"?e:e.map(t=>{let o=t;return o.type==="text"&&typeof o.text=="string"?o.text:""}).join("")}function w(e){for(let t=e.length-1;t>=0;t-=1){let o=e[t];if((0,f.isAIMessage)(o))return Re(o.content).trim()}return""}async function x(e,t){if(!e){await t.typing.stop();return}await t.reply(e)}async function Ie(e,t,o){var i;let n=await V(e.tools,t),a=m(t.history,void 0,n),r=[];e.needsApproval&&r.push(j(e.needsApproval)),e.middleware&&r.push(...e.middleware);let s=(0,Y.createAgent)({model:e.model,tools:(i=e.tools)!=null?i:[],...e.system?{prompt:e.system}:{},...r.length>0?{middleware:r}:{}}),l;try{l=await s.invoke({messages:a})}catch(p){let u=U(p);if(u){await $(t,u,o);return}throw p}I(l.messages,t,new Set(n.keys())),await x(w(l.messages),t)}async function C(e,t,o){if(z(e)){await Ie(e,t,o);return}if((0,f.isBaseMessage)(e)){await x(w([e]),t);return}I(e.messages,t),await x(w(e.messages),t)}var we={text:"",platformMessageId:"",author:{userId:"",fullName:"",userName:"",isBot:!1},timestamp:""};function xe(e){return typeof e=="object"&&e!==null&&"messageId"in e&&"platformThreadId"in e}function Me(e,t){let o=typeof t=="function"?{onMessage:t}:t;if(typeof o.onMessage!="function")throw new Error(`agent('${e}') requires an onMessage handler`);return o}function J(e,t){if(!e)throw new Error("agent() requires a non-empty agentId");let o=Me(e,t),n=o.toolApproval,a=typeof o.onToolApproval=="function",r=async l=>{let i=y(l),p=await o.onMessage(we,i.asMessageContext());A(p)&&await C(p,i,n)},s={onMessage:async(l,i)=>{let p=await o.onMessage(l,i);if(A(p)){await C(p,y(i),n);return}return p},onToolApproval:async(l,i)=>{let p=y(i);if(o.onToolApproval){let u=await o.onToolApproval(l,i);if(A(u)){await C(u,p,n);return}u!=null&&!xe(u)&&await p.reply(u)}await r(i)},...n&&{toolApproval:n},...o.onAction&&{onAction:o.onAction},...o.onReaction&&{onReaction:o.onReaction},...o.onResolve&&{onResolve:o.onResolve}};return{id:e,handlers:s,userOnToolApproval:a}}0&&(module.exports={NovuToolApprovalRequired,agent,toLangChainMessages});
1
+ "use strict";var v=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var W=(e,o)=>{for(var t in o)v(e,t,{get:o[t],enumerable:!0})},Z=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of Q(o))!K.call(e,r)&&r!==t&&v(e,r,{get:()=>o[r],enumerable:!(n=G(o,r))||n.enumerable});return e};var ee=e=>Z(v({},"__esModule",{value:!0}),e);var he={};W(he,{NovuToolApprovalRequired:()=>g,agent:()=>J,toLangChainMessages:()=>m});module.exports=ee(he);var d=require("@langchain/core/messages");var c=require("@langchain/core/messages"),h="tool_approval_request",E="tool_approval_decision",N="tool_result",oe=JSON.stringify({type:"execution-denied"});function T(e){var t;let o=e.toolData;if(!(!o||typeof o.approvalId!="string"||typeof o.toolCallId!="string"))return{approvalId:o.approvalId,toolCallId:o.toolCallId,name:(t=o.toolName)!=null?t:"tool",input:o.input}}function P(e){let o=e.toolData;if(!(!o||typeof o.approvalId!="string"||typeof o.approved!="boolean"))return{approvalId:o.approvalId,approved:o.approved}}function L(e){let o=e.toolData;if(!(!o||typeof o.toolCallId!="string"))return{toolCallId:o.toolCallId,toolName:o.toolName,output:o.output}}function S(e,o){let t=new Set,n=new Map,r=new Map;for(let a of e)if(a.type===h){let s=T(a);s&&r.set(s.approvalId,s.toolCallId)}else if(a.type===E){let s=P(a);s&&!s.approved&&t.add(s.approvalId)}else if(a.type===N){let s=L(a);s&&n.set(s.toolCallId,s)}if(o)for(let[a,s]of o)n.set(a,s);return{deniedApprovalIds:t,toolResults:n,approvalIdToToolCallId:r}}function te(e,o){return o.deniedApprovalIds.has(e.approvalId)?"denied":o.toolResults.has(e.toolCallId)?"resolved":"in-flight"}function M(e){var o;return new c.AIMessage({content:"",tool_calls:[{id:e.toolCallId,name:e.name,args:(o=e.input)!=null?o:{},type:"tool_call"}]})}function ne(e){return typeof e=="string"?e:JSON.stringify(e)}function re(e){var o;return new c.ToolMessage({content:ne(e.output),tool_call_id:e.toolCallId,name:(o=e.toolName)!=null?o:"tool"})}function ae(e){return new c.ToolMessage({content:oe,tool_call_id:e.toolCallId,name:e.name,status:"error"})}function H(e,o){let t=T(e);if(!t)return[];let n=te(t,o);switch(n){case"denied":return[M(t),ae(t)];case"resolved":{let r=o.toolResults.get(t.toolCallId);return r?[M(t),re(r)]:[]}case"in-flight":return[];default:return n}}function _(e){let o=new Set,t=new Set,n=[];for(let r of e)if(r.type===h){let a=T(r);a&&n.push({approvalId:a.approvalId,toolCallId:a.toolCallId,toolName:a.name,input:a.input})}else if(r.type===E){let a=P(r);a!=null&&a.approved&&o.add(a.approvalId)}else if(r.type===N){let a=L(r);a&&t.add(a.toolCallId)}return n.filter(r=>o.has(r.approvalId)&&!t.has(r.toolCallId)).map(({toolCallId:r,toolName:a,input:s})=>({toolCallId:r,toolName:a,input:s}))}var se="message",le="tool_approval_request";function k(e){return e==="agent"||e==="assistant"}function ie(e){let o=new Set;for(let t of e)!k(t.role)&&t.role!=="system"&&t.senderName&&o.add(t.senderName);return o.size}function pe(e,o){if(!e.content.trim())return;if(k(e.role))return new d.AIMessage(e.content);let n=o&&e.senderName?`${e.senderName}: ${e.content}`:e.content;return new d.HumanMessage(n)}function ue(e,o,t){switch(e.type){case se:{let n=pe(e,o);return n?[n]:[]}case le:return H(e,t);default:return[]}}function m(e,o,t){let n=ie(e)>1,r=S(e,t),a=e.flatMap(s=>ue(s,n,r));return o?[new d.SystemMessage(o),...a]:a}var de=Symbol.for("novu.agent.runtimeContext");function ge(e){return e[de]===!0}function y(e){if(!ge(e))throw new Error("Agent context must be created by Novu dispatch");return e}var f=require("@langchain/core/messages"),Y=require("langchain");function q(e){return"type"in e&&e.type==="card"}function b(e){return typeof e=="object"&&e!==null&&e.type==="tool-approval-card"}var B=require("@langchain/core/messages"),D=require("langchain");var ce="tool-approval";function R(e,o){return`${ce}:${e}:${o}`}async function O(e,o,t,n){var p,u;let r=n!=null?n:o.id,a={approve:R("approve",r),deny:R("deny",r)},s=F=>({type:"tool-approval-card",...F}),l=(u=(p=t==null?void 0:t.renderApproval)==null?void 0:p.call(t,{toolCall:o,actionIds:a,approvalCard:s}))!=null?u:s(),i={approvalId:r,toolCallId:o.id,name:o.name,input:o.input};if(e.emitToolApprovalRequest(i),b(l)){await e.replyApprovalCard(l);return}await e.reply(l)}var g=class extends Error{constructor(o){super(`Tool "${o.toolName}" requires approval`),this.name="NovuToolApprovalRequired",this.toolCallId=o.toolCallId,this.toolName=o.toolName,this.input=o.input}},fe=10;function U(e){let o=e;for(let t=0;t<fe&&o!=null;t+=1){if(o instanceof g)return o;o=o.cause}}function j(e){return(0,D.createMiddleware)({name:"novu-tool-approval",wrapToolCall:async(o,t)=>{let{id:n,name:r,args:a}=o.toolCall,s=a!=null?a:{};if(e({id:n,name:r,args:s}))throw new g({toolCallId:n!=null?n:r,toolName:r,input:s});return t(o)}})}async function $(e,o,t){let n={id:o.toolCallId,name:o.toolName,input:o.input};await O(e,n,t)}function me(e){return(0,B.isBaseMessage)(e)?e.content:e}function ye(e){let o=new Map;for(let t of e!=null?e:[])o.set(t.name,t);return o}async function V(e,o){var a;let t=_(o.history),n=new Map;if(t.length===0)return n;let r=ye(e);for(let s of t){let l=r.get(s.toolName);if(!l)continue;let i=me(await l.invoke((a=s.input)!=null?a:{}));n.set(s.toolCallId,{toolCallId:s.toolCallId,toolName:s.toolName,output:i}),o.emitToolResult({toolCallId:s.toolCallId,toolName:s.toolName,output:i,preview:`Tool "${s.toolName}" result`})}return n}var X=require("@langchain/core/messages");function Ae(e){var t;let o=new Set;for(let n of e.history)n.type==="tool_approval_request"&&((t=n.toolData)!=null&&t.toolCallId)&&o.add(n.toolData.toolCallId);return o}function Ce(e,o){var n;let t=new Set(o);for(let r of e.history)r.type==="tool_result"&&((n=r.toolData)!=null&&n.toolCallId)&&t.add(r.toolData.toolCallId);return t}function ve(e){return typeof e=="string"?e:JSON.stringify(e)}function I(e,o,t=new Set){var a;let n=Ae(o);if(n.size===0)return;let r=Ce(o,t);for(let s of e){if(!(0,X.isToolMessage)(s))continue;let l=s.tool_call_id;!n.has(l)||r.has(l)||(r.add(l),o.emitToolResult({toolCallId:l,toolName:s.name,output:ve(s.content),preview:`Tool "${(a=s.name)!=null?a:l}" result`}))}}function z(e){if(typeof e!="object"||e===null)return!1;let o=e.model;return typeof o=="string"||typeof o=="object"&&o!==null}function Te(e){return typeof e=="object"&&e!==null&&Array.isArray(e.messages)}function A(e){return typeof e!="object"||e===null||q(e)?!1:(0,f.isBaseMessage)(e)||z(e)||Te(e)}function Re(e){return typeof e=="string"?e:e.map(o=>{let t=o;return t.type==="text"&&typeof t.text=="string"?t.text:""}).join("")}function w(e){for(let o=e.length-1;o>=0;o-=1){let t=e[o];if((0,f.isAIMessage)(t))return Re(t.content).trim()}return""}async function x(e,o){if(!e){await o.typing.stop();return}await o.reply(e)}async function Ie(e,o,t){var i;let n=await V(e.tools,o),r=m(o.history,void 0,n),a=[];e.needsApproval&&a.push(j(e.needsApproval)),e.middleware&&a.push(...e.middleware);let s=(0,Y.createAgent)({model:e.model,tools:(i=e.tools)!=null?i:[],...e.system?{prompt:e.system}:{},...a.length>0?{middleware:a}:{}}),l;try{l=await s.invoke({messages:r})}catch(p){let u=U(p);if(u){await $(o,u,t);return}throw p}I(l.messages,o,new Set(n.keys())),await x(w(l.messages),o)}async function C(e,o,t){if(z(e)){await Ie(e,o,t);return}if((0,f.isBaseMessage)(e)){await x(w([e]),o);return}I(e.messages,o),await x(w(e.messages),o)}var we={text:"",platformMessageId:"",author:{userId:"",fullName:"",userName:"",isBot:!1},timestamp:""};function xe(e){return typeof e=="object"&&e!==null&&"messageId"in e&&"platformThreadId"in e}function Me(e,o){let t=typeof o=="function"?{onMessage:o}:o;if(typeof t.onMessage!="function")throw new Error(`agent('${e}') requires an onMessage handler`);return t}function J(e,o){if(!e)throw new Error("agent() requires a non-empty agentId");let t=Me(e,o),n=t.toolApproval,r=typeof t.onToolApproval=="function",a=async l=>{let i=y(l),p=await t.onMessage(we,i.asMessageContext());A(p)&&await C(p,i,n)},s={onMessage:async(l,i)=>{let p=await t.onMessage(l,i);if(A(p)){await C(p,y(i),n);return}return p},onToolApproval:async(l,i)=>{let p=y(i);if(t.onToolApproval){let u=await t.onToolApproval(l,i);if(A(u)){await C(u,p,n);return}u!=null&&!xe(u)&&await p.reply(u)}await a(i)},...n&&{toolApproval:n},...t.onAction&&{onAction:t.onAction},...t.onReaction&&{onReaction:t.onReaction},...t.onResolve&&{onResolve:t.onResolve},...t.onError&&{onError:t.onError}};return{id:e,handlers:s,userOnToolApproval:r}}0&&(module.exports={NovuToolApprovalRequired,agent,toLangChainMessages});
@@ -1,5 +1,5 @@
1
1
  import { BaseMessage } from '@langchain/core/messages';
2
- import { h as AgentHistoryEntry, g as AgentHandlers, i as AgentMessage, k as AgentMessageContext, M as MessageContent, s as ToolApprovalDecision, b as AgentActionContext, R as ReplyHandle, A as Agent } from '../agent.types-DdgaVUb7.cjs';
2
+ import { j as AgentHistoryEntry, i as AgentHandlers, k as AgentMessage, m as AgentMessageContext, M as MessageContent, u as ToolApprovalDecision, b as AgentActionContext, R as ReplyHandle, A as Agent } from '../agent.types-Dqm2VBTO.cjs';
3
3
  import { LanguageModelLike } from '@langchain/core/language_models/base';
4
4
  import { StructuredToolInterface } from '@langchain/core/tools';
5
5
  import { AgentMiddleware } from 'langchain';
@@ -73,6 +73,7 @@ type LangChainAgentHandlers = Omit<AgentHandlers, 'onMessage' | 'onToolApproval'
73
73
  * `LangChainResult` to drive the resume yourself.
74
74
  */
75
75
  onToolApproval?: (decision: ToolApprovalDecision, ctx: AgentActionContext) => Awaitable<MessageContent | LangChainResult | ReplyHandle | void>;
76
+ onError?: AgentHandlers['onError'];
76
77
  };
77
78
 
78
79
  type LangChainMessageHandler = LangChainAgentHandlers['onMessage'];